From patchwork Tue Nov 24 09:44:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 57216 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1975779lbb; Tue, 24 Nov 2015 01:52:12 -0800 (PST) X-Received: by 10.98.71.217 with SMTP id p86mr21585053pfi.162.1448358732452; Tue, 24 Nov 2015 01:52:12 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id la1si159952pbc.208.2015.11.24.01.52.12; Tue, 24 Nov 2015 01:52:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-i2c-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-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-i2c-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 S1753343AbbKXJwI (ORCPT + 1 other); Tue, 24 Nov 2015 04:52:08 -0500 Received: from mail-wm0-f46.google.com ([74.125.82.46]:34843 "EHLO mail-wm0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754002AbbKXJov (ORCPT ); Tue, 24 Nov 2015 04:44:51 -0500 Received: by wmuu63 with SMTP id u63so88219276wmu.0 for ; Tue, 24 Nov 2015 01:44:50 -0800 (PST) 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=rj0uYLjT6p0mOnoUrnRQwDYdXFsJra4AsXeLESymG7w=; b=eEBAtBHs86o9MEYDVz9wh85q2ST/Ns3aTUK1RtYQcvEH9TBdOYnFMNOyT0neNE1N7u VXDvRJaN8XahN5dEQItynamuSoTqWiKB33sRM2aCyRaNtaTpQc1q1XtRhKwBXvPZFxnd 8JKkZYTy4cVMRgwzhgbfnmT7ZglfOpu6uVrx4EaIVlPwugQn+gDPZ7TMqaMM+8AFmB+V lQpN7EaTluwkGwP6mb+V6mXVbsqFmyF9zizrdqUZ6yDQOroWXtEaxBiHV7hbZr4FtUTr CyxG11M1v5rZp9Qml8b1FAPSHgSk9VzjxKbUoTqIUlQu/PBxIL5ix8HAEl7G3kOiDQF5 R7AQ== 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=rj0uYLjT6p0mOnoUrnRQwDYdXFsJra4AsXeLESymG7w=; b=hVsew5bbjWMUnj+zfMKntyEvJC6A/fMMfBvpdiUCl0HwjGNSL4cvrmlGZhs18RH3kC u2hjCJcB9zsjz1mtngFdTSjJwAthnM0HpQa7cJFlBGzKssr93zVUp/h/DANybGE0IJlY AJS0nMYBuYIC9WHEWojHxlvc5FsLSJ1YvFRjPIiXOXhMArS8WBcE6gweqDi9ajDIKkwq Y0Kpc/+WCjfr1JL1IjLDbGK54mzHzoEfvncrphujPaU99DzSTU5JVSMaUU2ZDkr9QM9F XJFIipztMxZETtYCz9QZpoaKTvl7hpnJYUu7r7lzGYEuME2aLtVSzbOWnVnSEAOHZMyI LlMQ== X-Gm-Message-State: ALoCoQliiOD6oTlCuPTtZoaAan6CP8I+Z+G3S50jU+PnodNOXFC1fS7wthDcu5ud/R0zk/srDEyg X-Received: by 10.28.156.75 with SMTP id f72mr22416905wme.91.1448358290820; Tue, 24 Nov 2015 01:44:50 -0800 (PST) Received: from bgdev-debian.home ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id cl5sm17353156wjc.29.2015.11.24.01.44.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Nov 2015 01:44:50 -0800 (PST) From: Bartosz Golaszewski To: Wolfram Sang Cc: linux-i2c , LKML , Bartosz Golaszewski Subject: [RESEND PATCH v2 3/9] eeprom: at24: tie up an additional address for at24cs series Date: Tue, 24 Nov 2015 10:44:39 +0100 Message-Id: <1448358285-25016-4-git-send-email-bgolaszewski@baylibre.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1448358285-25016-1-git-send-email-bgolaszewski@baylibre.com> References: <1448358285-25016-1-git-send-email-bgolaszewski@baylibre.com> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@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-i2c" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index 5d7c090..08cc327 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c @@ -103,6 +103,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)) \ @@ -558,6 +560,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); @@ -616,12 +620,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; }