All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa@kernel.org>
To: Maxim Kochetkov <fido_max@inbox.ru>, Bartosz Golaszewski <brgl@bgdev.pl>
Cc: linux-i2c@vger.kernel.org, bgolaszewski@baylibre.com,
	arnd@arndb.de, =gregkh@linuxfoundation.org
Subject: Re: [PATCH] eeprom: at24: Add support for 24c1025 EEPROM
Date: Wed, 1 Dec 2021 22:19:17 +0100	[thread overview]
Message-ID: <Yafm1UioIO7DqUUz@kunai> (raw)
In-Reply-To: <20211018210039.129110-1-fido_max@inbox.ru>

[-- Attachment #1: Type: text/plain, Size: 3766 bytes --]

On Tue, Oct 19, 2021 at 12:00:39AM +0300, Maxim Kochetkov wrote:
> Microchip EEPROM 24xx1025 is like a 24c1024. The only difference
> between them is that the I2C address bit used to select between the
> two banks is bit 2 for the 1025 and not bit 0 as in the 1024.
> 
> Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru>

Adding Bartosz' new email to CC...

> ---
>  drivers/misc/eeprom/at24.c | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
> index 305ffad131a2..6543ff6536aa 100644
> --- a/drivers/misc/eeprom/at24.c
> +++ b/drivers/misc/eeprom/at24.c
> @@ -96,6 +96,7 @@ struct at24_data {
>  	 * Some chips tie up multiple I2C addresses; dummy devices reserve
>  	 * them for us, and we'll use them with SMBus calls.
>  	 */
> +	u8 bank_addr_shift;
>  	struct at24_client client[];
>  };
>  
> @@ -123,6 +124,7 @@ MODULE_PARM_DESC(at24_write_timeout, "Time (in ms) to try writes (default 25)");
>  struct at24_chip_data {
>  	u32 byte_len;
>  	u8 flags;
> +	u8 bank_addr_shift;
>  	void (*read_post)(unsigned int off, char *buf, size_t count);
>  };
>  
> @@ -137,6 +139,12 @@ struct at24_chip_data {
>  		.read_post = _read_post,				\
>  	}
>  
> +#define AT24_CHIP_DATA_BS(_name, _len, _flags, _bank_addr_shift)	\
> +	static const struct at24_chip_data _name = {			\
> +		.byte_len = _len, .flags = _flags,			\
> +		.bank_addr_shift = _bank_addr_shift			\
> +	}
> +
>  static void at24_read_post_vaio(unsigned int off, char *buf, size_t count)
>  {
>  	int i;
> @@ -197,6 +205,7 @@ AT24_CHIP_DATA(at24_data_24c128, 131072 / 8, AT24_FLAG_ADDR16);
>  AT24_CHIP_DATA(at24_data_24c256, 262144 / 8, AT24_FLAG_ADDR16);
>  AT24_CHIP_DATA(at24_data_24c512, 524288 / 8, AT24_FLAG_ADDR16);
>  AT24_CHIP_DATA(at24_data_24c1024, 1048576 / 8, AT24_FLAG_ADDR16);
> +AT24_CHIP_DATA_BS(at24_data_24c1025, 1048576 / 8, AT24_FLAG_ADDR16, 2);
>  AT24_CHIP_DATA(at24_data_24c2048, 2097152 / 8, AT24_FLAG_ADDR16);
>  /* identical to 24c08 ? */
>  AT24_CHIP_DATA(at24_data_INT3499, 8192 / 8, 0);
> @@ -225,6 +234,7 @@ static const struct i2c_device_id at24_ids[] = {
>  	{ "24c256",	(kernel_ulong_t)&at24_data_24c256 },
>  	{ "24c512",	(kernel_ulong_t)&at24_data_24c512 },
>  	{ "24c1024",	(kernel_ulong_t)&at24_data_24c1024 },
> +	{ "24c1025",	(kernel_ulong_t)&at24_data_24c1025 },
>  	{ "24c2048",    (kernel_ulong_t)&at24_data_24c2048 },
>  	{ "at24",	0 },
>  	{ /* END OF LIST */ }
> @@ -254,6 +264,7 @@ static const struct of_device_id at24_of_match[] = {
>  	{ .compatible = "atmel,24c256",		.data = &at24_data_24c256 },
>  	{ .compatible = "atmel,24c512",		.data = &at24_data_24c512 },
>  	{ .compatible = "atmel,24c1024",	.data = &at24_data_24c1024 },
> +	{ .compatible = "atmel,24c1025",	.data = &at24_data_24c1025 },
>  	{ .compatible = "atmel,24c2048",	.data = &at24_data_24c2048 },
>  	{ /* END OF LIST */ },
>  };
> @@ -548,7 +559,8 @@ static int at24_make_dummy_client(struct at24_data *at24, unsigned int index,
>  	dev = &base_client->dev;
>  
>  	dummy_client = devm_i2c_new_dummy_device(dev, base_client->adapter,
> -						 base_client->addr + index);
> +						 base_client->addr +
> +						 (index << at24->bank_addr_shift));
>  	if (IS_ERR(dummy_client))
>  		return PTR_ERR(dummy_client);
>  
> @@ -689,6 +701,7 @@ static int at24_probe(struct i2c_client *client)
>  	at24->page_size = page_size;
>  	at24->flags = flags;
>  	at24->read_post = cdata->read_post;
> +	at24->bank_addr_shift = cdata->bank_addr_shift;
>  	at24->num_addresses = num_addresses;
>  	at24->offset_adj = at24_get_offset_adj(flags, byte_len);
>  	at24->client[0].client = client;
> -- 
> 2.32.0
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2021-12-01 21:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-18 21:00 [PATCH] eeprom: at24: Add support for 24c1025 EEPROM Maxim Kochetkov
2021-12-01 21:19 ` Wolfram Sang [this message]
2021-12-03 14:50 ` Bartosz Golaszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yafm1UioIO7DqUUz@kunai \
    --to=wsa@kernel.org \
    --cc==gregkh@linuxfoundation.org \
    --cc=arnd@arndb.de \
    --cc=bgolaszewski@baylibre.com \
    --cc=brgl@bgdev.pl \
    --cc=fido_max@inbox.ru \
    --cc=linux-i2c@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.