From patchwork Thu Jul 6 10:16:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 785106 X-Patchwork-Delegate: bartekgola@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3x3DFl2wQrz9s75 for ; Thu, 6 Jul 2017 20:17:47 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752218AbdGFKRT (ORCPT ); Thu, 6 Jul 2017 06:17:19 -0400 Received: from esa6.microchip.iphmx.com ([216.71.154.253]:58707 "EHLO esa6.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751059AbdGFKRR (ORCPT ); Thu, 6 Jul 2017 06:17:17 -0400 X-IronPort-AV: E=Sophos;i="5.40,316,1496127600"; d="scan'208";a="1984762" Received: from exsmtp02.microchip.com (HELO email.microchip.com) ([198.175.253.38]) by esa6.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 06 Jul 2017 03:17:16 -0700 Received: from m18063-ThinkPad-T460p.mchp-main.com (10.10.76.4) by chn-sv-exch02.mchp-main.com (10.10.76.38) with Microsoft SMTP Server id 14.3.352.0; Thu, 6 Jul 2017 03:17:16 -0700 From: Claudiu Beznea To: , , , , CC: , , , , , Claudiu Beznea Subject: [PATCH 2/3] drivers: misc: eeprom: at24: support reading mac eeprom from different addresses Date: Thu, 6 Jul 2017 13:16:56 +0300 Message-ID: <1499336217-16913-3-git-send-email-claudiu.beznea@microchip.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499336217-16913-1-git-send-email-claudiu.beznea@microchip.com> References: <1499336217-16913-1-git-send-email-claudiu.beznea@microchip.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Add support for reading MAC address from different offsets of EEPROM. The offset is initialized via device tree. If nothing is given as input the old value, 0x90, is used. In this way the driver could be used as generic driver for different vendor memories by only changing the reading offset via device tree. Signed-off-by: Claudiu Beznea --- drivers/misc/eeprom/at24.c | 5 ++++- include/linux/platform_data/at24.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index 764ff5df..53c2b03 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c @@ -365,7 +365,7 @@ static ssize_t at24_eeprom_read_mac(struct at24_data *at24, char *buf, memset(msg, 0, sizeof(msg)); msg[0].addr = client->addr; msg[0].buf = addrbuf; - addrbuf[0] = 0x90 + offset; + addrbuf[0] = at24->chip.mac_offset + offset; msg[0].len = 1; msg[1].addr = client->addr; msg[1].flags = I2C_M_RD; @@ -581,6 +581,9 @@ static void at24_get_pdata(struct device *dev, struct at24_platform_data *chip) */ chip->page_size = 1; } + err = device_property_read_u32(dev, "mac-offset", &chip->mac_offset); + if (err) + chip->mac_offset = 0x90; } static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) diff --git a/include/linux/platform_data/at24.h b/include/linux/platform_data/at24.h index 271a4e2..4e9523e 100644 --- a/include/linux/platform_data/at24.h +++ b/include/linux/platform_data/at24.h @@ -42,6 +42,7 @@ struct at24_platform_data { u32 byte_len; /* size (sum of all addr) */ + u32 mac_offset; u16 page_size; /* for writes */ u8 flags; #define AT24_FLAG_ADDR16 BIT(7) /* address pointer is 16 bit */