From patchwork Wed Dec 2 10:25:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 57550 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp2772799lbb; Wed, 2 Dec 2015 02:27:13 -0800 (PST) X-Received: by 10.66.139.131 with SMTP id qy3mr3399917pab.71.1449052033741; Wed, 02 Dec 2015 02:27:13 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ku8si3807283pab.179.2015.12.02.02.27.13; Wed, 02 Dec 2015 02:27:13 -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 S1755676AbbLBKZl (ORCPT + 1 other); Wed, 2 Dec 2015 05:25:41 -0500 Received: from mail-wm0-f50.google.com ([74.125.82.50]:36501 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754049AbbLBKZj (ORCPT ); Wed, 2 Dec 2015 05:25:39 -0500 Received: by wmww144 with SMTP id w144so208439453wmw.1 for ; Wed, 02 Dec 2015 02:25:37 -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=l+drl0c3/IFm5v7qgf1cLsYFRsK/dhsCyLwNvVRHJcTsylQRJAWOhSbe2cA4dehDeo iG7tdLHjtWpRFPtYeWe+nPkloKbQEr4S52//gtWeqdeLvq6jfku/2LqYuarVfc8qrIge eYY3TNFMgGywuRAtYvl2tVaQAr2UJh8EIju7d5KWKnHd8nlvERH6oQDqY00LqrLm8Par 8XQot13yuZJ6XvvCd+IZ9jqm0Inf/+YxnjRFWlecqybDcJQsQ/6a46+DhPxwmJxWMTtI mMbUnxb4kBIYPw6ah2VtVtlYklU9N0bU56sHaeHdBuZzh9IEEVkZIgmH8RntyRA1HwJH dMAg== 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=HlAG5WiXP9h0+aD1xPrfwb3DJQctn5ep+XjmdahY7hpEEwtEI4NIGo5MVqweYDXiTr VT2zkqiV911cl7kQLjOCwry/8Q7Pq3/aoC5Jr32HFUlu7yHXcYDwfdnT2pVCSOwL6TTk S8eIM/DVeER4LiY3i/RMqSCBWvW1h5Ca8gb3J1HaBsNQ/XjhCNdWKTJH0/yXhTxj8t+J iPYTa3O4556WNEve7S3/9PelywcBJO7NH0zzZllXmazZa1LWdN/PsFQy9kncgskSBFCk qou41jGTnvLc0KR+GWRa5/pAJzY56KJPgwTPBB4gsMI+mhIcG8IPxQQIh//3FtdpdSGP XeCg== X-Gm-Message-State: ALoCoQna3qXh/4b6sgzOX8btJEFKfbpUnCZhxM/CcBZ8+GhWdHnOBM1AhsTt1eXty0piZ7h+vSI/ X-Received: by 10.194.5.74 with SMTP id q10mr3587938wjq.138.1449051937778; Wed, 02 Dec 2015 02:25:37 -0800 (PST) Received: from bgdev-debian.home ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id bg10sm2077707wjb.46.2015.12.02.02.25.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 02 Dec 2015 02:25:37 -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: Wed, 2 Dec 2015 11:25:20 +0100 Message-Id: <1449051926-21918-4-git-send-email-bgolaszewski@baylibre.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1449051926-21918-1-git-send-email-bgolaszewski@baylibre.com> References: <1449051926-21918-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; }