From patchwork Tue Oct 27 11:43:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 55591 Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1739457lbq; Tue, 27 Oct 2015 04:44:35 -0700 (PDT) X-Received: by 10.107.17.149 with SMTP id 21mr41538922ior.21.1445946275611; Tue, 27 Oct 2015 04:44:35 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m70si28852435ioe.132.2015.10.27.04.44.35; Tue, 27 Oct 2015 04:44:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@baylibre_com.20150623.gappssmtp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754213AbbJ0LoT (ORCPT + 28 others); Tue, 27 Oct 2015 07:44:19 -0400 Received: from mail-wi0-f173.google.com ([209.85.212.173]:38586 "EHLO mail-wi0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753986AbbJ0LoO (ORCPT ); Tue, 27 Oct 2015 07:44:14 -0400 Received: by wicll6 with SMTP id ll6so156094662wic.1 for ; Tue, 27 Oct 2015 04:44:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre_com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=toqO0ho3KDCBBdcSLKBD87wAgODAa4alD4LfystkLzQ=; b=nkvUQsab3XzZdToE2hnFkBTIJlPqJJuPr1GuSfxEq049XYuqxSOYsWIY6cX5qgm266 QXJ8QPKHA+mnDI37JO7RvMi4GbA4Zx+UnL4DfNdtF82y0zckQCzJWAxaEqtUptpHVg5S u9cAI6yA3IvDlXFprtqWAkfSSeXnYZIF/bw955BtlK1Z3JL9fgXdCG4Q9D2PobfvVMd3 OdDvDDrTemtDiPMhAF5yCVIp4Soe5pTOoTTDfRgGBz+bXQBEBuZDACDsGjzqSs2VrAiN j7DfqrALm7sFqwj6jfbdqLKmznotYQ3a006NTqcu9WOqiGMcurocCj4u1YBJONspuhSH b/HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=toqO0ho3KDCBBdcSLKBD87wAgODAa4alD4LfystkLzQ=; b=Y+i7EGOMxNHXi0wYnm90jATbHTwJREYcIPithCEtoCZ7Mmru8YWmZezFlsss3MFVmv hIhPHUaaBulEnjBO/rCPNzeoBvvoIqSAmL6g6YU/1RrCAf3Kz3qU9yJfxKey/DZ6JheE ZU/Udls2/gvbSTIIK3pMgOyWKgENG1eNlmbzXxZUaKJewtJwfgnj+pFcRTkDmRV+CTzy Slsq43qSVkyHsaHfGDxEAVvW1af6f419TjkC+zi+LDiyeGg5FpUFb1v5htefEVeGjhbq WTQ250oNKVe2joeT7C2IW/dQ3VL7XFDsl2cfbYPt4i9/kk/V2nm4Z5rqbYaaD44w6UM3 mm3Q== X-Gm-Message-State: ALoCoQmoY1LgKxSGY6aia9UQd6Fa0abTo/Zpu42g8BWkgETguMFhmfpX7+MDOWiwGKqISvW25/sb X-Received: by 10.194.235.170 with SMTP id un10mr26735082wjc.57.1445946253125; Tue, 27 Oct 2015 04:44:13 -0700 (PDT) Received: from localhost.localdomain (cag06-6-78-235-100-105.fbx.proxad.net. [78.235.100.105]) by smtp.gmail.com with ESMTPSA id gd11sm17451281wic.20.2015.10.27.04.44.11 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Oct 2015 04:44:12 -0700 (PDT) From: Bartosz Golaszewski To: Wolfram Sang Cc: linux-i2c , LKML , Bartosz Golaszewski Subject: [PATCH v2 3/9] eeprom: at24: tie up an additional address for at24cs series Date: Tue, 27 Oct 2015 12:43:47 +0100 Message-Id: <1445946233-6071-4-git-send-email-bgolaszewski@baylibre.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1445946233-6071-1-git-send-email-bgolaszewski@baylibre.com> References: <1445946233-6071-1-git-send-email-bgolaszewski@baylibre.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The at24cs series EEPROM chips have an additional read-only memory area, that is visible on a different i2c slave address. Tie it up with a dummy device. Signed-off-by: Bartosz Golaszewski --- drivers/misc/eeprom/at24.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index c6cb7f8..3a75a52 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c @@ -102,6 +102,8 @@ MODULE_PARM_DESC(write_timeout, "Time (in ms) to try writes (default 25)"); #define AT24_BITMASK(x) (BIT(x) - 1) +#define AT24CS_SERIAL_ADDR(addr) (addr + 0x08) + /* create non-zero magic value for given eeprom parameters */ #define AT24_DEVICE_MAGIC(_len, _flags) \ ((1 << AT24_SIZE_FLAGS | (_flags)) \ @@ -543,6 +545,8 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) if (chip.flags & AT24_FLAG_TAKE8ADDR) num_addresses = 8; + else if (chip.flags & AT24_FLAG_SERIAL) + num_addresses = 2; else num_addresses = DIV_ROUND_UP(chip.byte_len, (chip.flags & AT24_FLAG_ADDR16) ? 65536 : 256); @@ -601,12 +605,30 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) at24->client[0] = client; /* use dummy devices for multiple-address chips */ - for (i = 1; i < num_addresses; i++) { - at24->client[i] = i2c_new_dummy(client->adapter, + if (at24->chip.flags & AT24_FLAG_TAKE8ADDR) { + for (i = 1; i < num_addresses; i++) { + at24->client[i] = i2c_new_dummy(client->adapter, + client->addr + i); + if (!at24->client[i]) { + dev_err(&client->dev, + "address 0x%02x unavailable\n", client->addr + i); - if (!at24->client[i]) { + err = -EADDRINUSE; + goto err_clients; + } + } + } + + /* + * at24cs series tie up an additional address for the memory area + * contining the serial number + */ + if (at24->chip.flags & AT24_FLAG_SERIAL) { + at24->client[1] = i2c_new_dummy(client->adapter, + AT24CS_SERIAL_ADDR(client->addr)); + if (!at24->client[1]) { dev_err(&client->dev, "address 0x%02x unavailable\n", - client->addr + i); + AT24CS_SERIAL_ADDR(client->addr)); err = -EADDRINUSE; goto err_clients; }