From patchwork Tue Nov 17 09:52:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 56766 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1830134lbb; Tue, 17 Nov 2015 01:55:44 -0800 (PST) X-Received: by 10.66.251.39 with SMTP id zh7mr62721114pac.6.1447754144191; Tue, 17 Nov 2015 01:55:44 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i8si34847371pbq.106.2015.11.17.01.55.42; Tue, 17 Nov 2015 01:55:44 -0800 (PST) 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 S1752899AbbKQJzk (ORCPT + 28 others); Tue, 17 Nov 2015 04:55:40 -0500 Received: from mail-wm0-f49.google.com ([74.125.82.49]:37425 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753472AbbKQJwj (ORCPT ); Tue, 17 Nov 2015 04:52:39 -0500 Received: by wmww144 with SMTP id w144so17539341wmw.0 for ; Tue, 17 Nov 2015 01:52:38 -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=ygC0DxuqUqUI9QtZwo2IFxjv4LuoRZwh3DDmr0yxpDCS9Ktxw4pn393qgDOkvHUiox Nk9bau5PoeigfjSHeAxFQSzOivfRRtT2Jz3fUUH3i9NL59oei9N/dVCa9LrodtZbCULA HvI81/ZgimlPIPguzdPp/FXpZmrUWlTMKj7XVzSo5qe5EtLbn9cxANwwMD9171sjI57b McUZ6rEk+VlT2zlai06SPBFeLahE7d+gbAbyBs3T6VDMDDkHlwoaW4yURfi72Q9weaon jpmSQDAqRICal9Iq4x0TFDxu1+z3hh/55W0VB/dhi94Qp6UFJiNO17L/9ZsB8oamNL6N ORRw== 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=AKmTr9jFlvDbWqpV8ykwY/xsuL2Aefa0mabPFQAd+XV88mcRVNS9nUB4V+LZcjCAYq g+gm3laqdGl90i30f+Xg+2w5wTWVYKKRf+g67nJb/6QsRZzk+/dyCwaPo+kNRLfAO0+8 P3AUKRK+Maao3xzeIMzS/MaOdyVd6QzI1SUasX57Y6TkZpLXEK4+WBbSB8sp9Rew/af+ M0AcujXqBORWgb5caXfQmCZQvjh2gpV0KToVJRcQukF3tSMWmNyv71UmA5q+oJexo1dL 5X/HgGbU6VtUFib5wKkJVibPKiUhxSgDmH5Mg19DaQBHtBTlDltCbTjljJUCaSumBdWa PDuA== X-Gm-Message-State: ALoCoQlogJdCWDucJt8JGMs3dm6KW5ylNapO6eLOCVbkmNKTHcfWVSSw3UmESO6FrSgBB7FGjniw X-Received: by 10.194.249.69 with SMTP id ys5mr46921178wjc.97.1447753958091; Tue, 17 Nov 2015 01:52:38 -0800 (PST) Received: from bgdev-debian.home ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id bk7sm38993546wjb.25.2015.11.17.01.52.37 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Nov 2015 01:52: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: Tue, 17 Nov 2015 10:52:24 +0100 Message-Id: <1447753950-17213-4-git-send-email-bgolaszewski@baylibre.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1447753950-17213-1-git-send-email-bgolaszewski@baylibre.com> References: <1447753950-17213-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 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; }