Re: [PATCH RFC] misc/at24: distinguish between eeprom and fram chips

From: Lars Poeschel
Date: Wed Dec 05 2012 - 04:43:21 EST


I see there where to much "no"s to get anything in, but thank you for
your comments and explanations.

> > I wanted to use a fm24c04 i2c fram chip with linux. I grepped the source
> > and found nothing. I later found that my chip can be handled by at24
> > eeprom driver. It creates a sysfs file called eeprom to read from and
> > write to the chip. Userspace has no chance to distinguish if it is
> > writing an eeprom or a fram chip.
>
> Why should it?

Because writes are much faster and it doesn't have to take care on erase
cycles. It could use other write strategies on such devices and update
informations that have to survive power downs more often.

> > diff --git a/drivers/misc/eeprom/Kconfig b/drivers/misc/eeprom/Kconfig
> > index c9e695e..55948a5 100644
> > --- a/drivers/misc/eeprom/Kconfig
> > +++ b/drivers/misc/eeprom/Kconfig
> > @@ -12,6 +12,12 @@ config EEPROM_AT24
> >
> > 24c00, 24c01, 24c02, spd (readonly 24c02), 24c04, 24c08,
> > 24c16, 24c32, 24c64, 24c128, 24c256, 24c512, 24c1024
> >
> > + This driver also supports I2C FRAM chips that are feature
> > + compatible to the 24cxx ones. In your at24_platform_data set
> > + .flags = AT24_FLAG_FRAM. These generic names are supported:
> > +
> > + fm24c04
> > +
>
> The method of accessing EEPROMs is used by way more chips than FRAMs.
> So, I'd prefer to have the text updated more generic like "EEPROMs and
> similar devices like RAMs, ROMs, etc...". Describing setting .flags in
> Kconfig is overkill.

A patch updating Kconfig is below.

> > - chip.page_size = 1;
> > + if (chip.flags & AT24_FLAG_FRAM)
> > + chip.page_size = 128;
> > + else
> > + chip.page_size = 1;
>
> I'd think most FRAMs can have the chip_size as the page_size since they
> probably don't do buffering. But do you know for all the chips out
> there? So, let's still play safe. If you want performance, you need to
> setup the driver properly.

No one knows all chips out there.
For the fm24c04 I use page_size != chip_size. It does not buffer but it has
two pages, 256 bytes each.

-- >8 --