Message ID | f18ad8a5dc12c010081bc27d19160d0c00be28f5.1478600213.git-series.maxime.ripard@free-electrons.com |
---|---|
State | Deferred |
Delegated to: | Tom Rini |
Headers | show |
Hi Maxime, On Tue, Nov 8, 2016 at 2:19 AM, Maxime Ripard <maxime.ripard@free-electrons.com> wrote: > Add a driver for the Maxim DS2431 1-Wire EEPROM > > Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> > --- > drivers/eeprom/Kconfig | 6 ++++++ > drivers/eeprom/Makefile | 1 + > drivers/eeprom/ds2431.c | 38 ++++++++++++++++++++++++++++++++++++++ > 3 files changed, 45 insertions(+), 0 deletions(-) > create mode 100644 drivers/eeprom/ds2431.c > > diff --git a/drivers/eeprom/Kconfig b/drivers/eeprom/Kconfig > index 8dc597a8d894..98bbd67ba579 100644 > --- a/drivers/eeprom/Kconfig > +++ b/drivers/eeprom/Kconfig > @@ -12,6 +12,12 @@ config EEPROM > > if EEPROM > > +config EEPROM_DS2431 > + bool "Enable Maxim DS2431 EEPROM support" > + depends on W1 > + help > + Maxim DS2431 1-Wire EEPROM support > + > endif > > endmenu > diff --git a/drivers/eeprom/Makefile b/drivers/eeprom/Makefile > index 147dba5ec4b8..93dae0bf5d6d 100644 > --- a/drivers/eeprom/Makefile > +++ b/drivers/eeprom/Makefile > @@ -1,2 +1,3 @@ > obj-$(CONFIG_EEPROM) += eeprom-uclass.o > > +obj-$(CONFIG_EEPROM_DS2431) += ds2431.o > diff --git a/drivers/eeprom/ds2431.c b/drivers/eeprom/ds2431.c > new file mode 100644 > index 000000000000..84c1a126c339 > --- /dev/null > +++ b/drivers/eeprom/ds2431.c > @@ -0,0 +1,38 @@ > +/* > + * Copyright (c) 2015 Free Electrons > + * Copyright (c) 2015 NextThing Co > + * > + * SPDX-License-Identifier: GPL-2.0+ > + */ > + > +#include <common.h> > +#include <linux/err.h> > +#include <dm.h> > +#include <eeprom.h> > +#include <w1.h> > + > +#define W1_F2D_READ_EEPROM 0xf0 > + > +static int ds2431_read_buf(struct udevice *dev, unsigned offset, > + u8 *buf, unsigned count) > +{ > + w1_reset_select(dev); > + > + w1_write_byte(dev, W1_F2D_READ_EEPROM); > + w1_write_byte(dev, offset & 0xff); > + w1_write_byte(dev, offset >> 8); > + > + return w1_read_buf(dev, buf, count); > +} > + > +static const struct eeprom_ops ds2431_ops = { > + .read_buf = ds2431_read_buf, > +}; > + > +U_BOOT_DRIVER(ds2431) = { > + .name = "ds2431", > + .id = UCLASS_EEPROM, > + .ops = &ds2431_ops, Do you want to add a .flags = DM_UC_FLAG_SEQ_ALIAS here? > +}; > + > +U_BOOT_W1_DEVICE(ds2431, W1_FAMILY_DS2431); > -- > git-series 0.8.11 > _______________________________________________ > U-Boot mailing list > U-Boot@lists.denx.de > http://lists.denx.de/mailman/listinfo/u-boot Cheers, Moritz
Hi, On Fri, Nov 11, 2016 at 11:16:39AM -0800, Moritz Fischer wrote: > > +U_BOOT_DRIVER(ds2431) = { > > + .name = "ds2431", > > + .id = UCLASS_EEPROM, > > + .ops = &ds2431_ops, > > Do you want to add a .flags = DM_UC_FLAG_SEQ_ALIAS here? I don't know. I was kind of wondering why U-Boot relies on aliases so much, especially when the Linux DT maintainers are saying that aliases should be avoided entirely, and we'll won't be able to upstream those changes. Thanks! Maxime
On Mon, Nov 14, 2016 at 02:42:59PM +0100, Maxime Ripard wrote: > Hi, > > On Fri, Nov 11, 2016 at 11:16:39AM -0800, Moritz Fischer wrote: > > > +U_BOOT_DRIVER(ds2431) = { > > > + .name = "ds2431", > > > + .id = UCLASS_EEPROM, > > > + .ops = &ds2431_ops, > > > > Do you want to add a .flags = DM_UC_FLAG_SEQ_ALIAS here? > > I don't know. I was kind of wondering why U-Boot relies on aliases so > much, especially when the Linux DT maintainers are saying that aliases > should be avoided entirely, and we'll won't be able to upstream those > changes. Bah. Do you have a pointer to some discussion about this handy? Thanks!
On Mon, Nov 14, 2016 at 10:14:57AM -0500, Tom Rini wrote: > On Mon, Nov 14, 2016 at 02:42:59PM +0100, Maxime Ripard wrote: > > Hi, > > > > On Fri, Nov 11, 2016 at 11:16:39AM -0800, Moritz Fischer wrote: > > > > +U_BOOT_DRIVER(ds2431) = { > > > > + .name = "ds2431", > > > > + .id = UCLASS_EEPROM, > > > > + .ops = &ds2431_ops, > > > > > > Do you want to add a .flags = DM_UC_FLAG_SEQ_ALIAS here? > > > > I don't know. I was kind of wondering why U-Boot relies on aliases so > > much, especially when the Linux DT maintainers are saying that aliases > > should be avoided entirely, and we'll won't be able to upstream those > > changes. > > Bah. Do you have a pointer to some discussion about this handy? Rob said this multiple times, but here is an example: http://lkml.iu.edu/hypermail/linux/kernel/1609.1/00653.html Maxime
Hi Maxime, On 14 November 2016 at 06:42, Maxime Ripard <maxime.ripard@free-electrons.com> wrote: > Hi, > > On Fri, Nov 11, 2016 at 11:16:39AM -0800, Moritz Fischer wrote: >> > +U_BOOT_DRIVER(ds2431) = { >> > + .name = "ds2431", >> > + .id = UCLASS_EEPROM, >> > + .ops = &ds2431_ops, >> >> Do you want to add a .flags = DM_UC_FLAG_SEQ_ALIAS here? > > I don't know. I was kind of wondering why U-Boot relies on aliases so > much, especially when the Linux DT maintainers are saying that aliases > should be avoided entirely, and we'll won't be able to upstream those > changes. U-Boot uses numbering on the command line for lots of device types. E.g. the i2c bus number in the 'i2c' command. The aliases set the numbering. We should add support for moving away from numbering and using names, at least as an option. I have not looked at that yet. Probably we should consider changing command-line parsing to be handled in a common library, with each command receiving a 'parsed' list of args and options. I have not looked at that either. Regards, Simon
Hi Maxime, On 14 November 2016 at 13:12, Maxime Ripard <maxime.ripard@free-electrons.com> wrote: > On Mon, Nov 14, 2016 at 10:14:57AM -0500, Tom Rini wrote: >> On Mon, Nov 14, 2016 at 02:42:59PM +0100, Maxime Ripard wrote: >> > Hi, >> > >> > On Fri, Nov 11, 2016 at 11:16:39AM -0800, Moritz Fischer wrote: >> > > > +U_BOOT_DRIVER(ds2431) = { >> > > > + .name = "ds2431", >> > > > + .id = UCLASS_EEPROM, >> > > > + .ops = &ds2431_ops, >> > > >> > > Do you want to add a .flags = DM_UC_FLAG_SEQ_ALIAS here? >> > >> > I don't know. I was kind of wondering why U-Boot relies on aliases so >> > much, especially when the Linux DT maintainers are saying that aliases >> > should be avoided entirely, and we'll won't be able to upstream those >> > changes. >> >> Bah. Do you have a pointer to some discussion about this handy? > > Rob said this multiple times, but here is an example: > http://lkml.iu.edu/hypermail/linux/kernel/1609.1/00653.html Well that's not really an explanation! - Simon
On Mon, Nov 14, 2016 at 01:44:42PM -0700, Simon Glass wrote: > Hi Maxime, > > On 14 November 2016 at 13:12, Maxime Ripard > <maxime.ripard@free-electrons.com> wrote: > > On Mon, Nov 14, 2016 at 10:14:57AM -0500, Tom Rini wrote: > >> On Mon, Nov 14, 2016 at 02:42:59PM +0100, Maxime Ripard wrote: > >> > Hi, > >> > > >> > On Fri, Nov 11, 2016 at 11:16:39AM -0800, Moritz Fischer wrote: > >> > > > +U_BOOT_DRIVER(ds2431) = { > >> > > > + .name = "ds2431", > >> > > > + .id = UCLASS_EEPROM, > >> > > > + .ops = &ds2431_ops, > >> > > > >> > > Do you want to add a .flags = DM_UC_FLAG_SEQ_ALIAS here? > >> > > >> > I don't know. I was kind of wondering why U-Boot relies on aliases so > >> > much, especially when the Linux DT maintainers are saying that aliases > >> > should be avoided entirely, and we'll won't be able to upstream those > >> > changes. > >> > >> Bah. Do you have a pointer to some discussion about this handy? > > > > Rob said this multiple times, but here is an example: > > http://lkml.iu.edu/hypermail/linux/kernel/1609.1/00653.html > > Well that's not really an explanation! Don't shoot the messenger :) I think I found some other discussion where they discuss it at length: https://patchwork.kernel.org/patch/9133903/ The interesting part is when Rob Herring is involved. Maxime
Hi Maxime, On 14 November 2016 at 14:09, Maxime Ripard <maxime.ripard@free-electrons.com> wrote: > On Mon, Nov 14, 2016 at 01:44:42PM -0700, Simon Glass wrote: >> Hi Maxime, >> >> On 14 November 2016 at 13:12, Maxime Ripard >> <maxime.ripard@free-electrons.com> wrote: >> > On Mon, Nov 14, 2016 at 10:14:57AM -0500, Tom Rini wrote: >> >> On Mon, Nov 14, 2016 at 02:42:59PM +0100, Maxime Ripard wrote: >> >> > Hi, >> >> > >> >> > On Fri, Nov 11, 2016 at 11:16:39AM -0800, Moritz Fischer wrote: >> >> > > > +U_BOOT_DRIVER(ds2431) = { >> >> > > > + .name = "ds2431", >> >> > > > + .id = UCLASS_EEPROM, >> >> > > > + .ops = &ds2431_ops, >> >> > > >> >> > > Do you want to add a .flags = DM_UC_FLAG_SEQ_ALIAS here? >> >> > >> >> > I don't know. I was kind of wondering why U-Boot relies on aliases so >> >> > much, especially when the Linux DT maintainers are saying that aliases >> >> > should be avoided entirely, and we'll won't be able to upstream those >> >> > changes. >> >> >> >> Bah. Do you have a pointer to some discussion about this handy? >> > >> > Rob said this multiple times, but here is an example: >> > http://lkml.iu.edu/hypermail/linux/kernel/1609.1/00653.html >> >> Well that's not really an explanation! > > Don't shoot the messenger :) > > I think I found some other discussion where they discuss it at length: > https://patchwork.kernel.org/patch/9133903/ > > The interesting part is when Rob Herring is involved. Oh dear. That sounds like a change to me. I'm going to leave this one to Tom :-) Regards, Simon
diff --git a/drivers/eeprom/Kconfig b/drivers/eeprom/Kconfig index 8dc597a8d894..98bbd67ba579 100644 --- a/drivers/eeprom/Kconfig +++ b/drivers/eeprom/Kconfig @@ -12,6 +12,12 @@ config EEPROM if EEPROM +config EEPROM_DS2431 + bool "Enable Maxim DS2431 EEPROM support" + depends on W1 + help + Maxim DS2431 1-Wire EEPROM support + endif endmenu diff --git a/drivers/eeprom/Makefile b/drivers/eeprom/Makefile index 147dba5ec4b8..93dae0bf5d6d 100644 --- a/drivers/eeprom/Makefile +++ b/drivers/eeprom/Makefile @@ -1,2 +1,3 @@ obj-$(CONFIG_EEPROM) += eeprom-uclass.o +obj-$(CONFIG_EEPROM_DS2431) += ds2431.o diff --git a/drivers/eeprom/ds2431.c b/drivers/eeprom/ds2431.c new file mode 100644 index 000000000000..84c1a126c339 --- /dev/null +++ b/drivers/eeprom/ds2431.c @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2015 Free Electrons + * Copyright (c) 2015 NextThing Co + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <common.h> +#include <linux/err.h> +#include <dm.h> +#include <eeprom.h> +#include <w1.h> + +#define W1_F2D_READ_EEPROM 0xf0 + +static int ds2431_read_buf(struct udevice *dev, unsigned offset, + u8 *buf, unsigned count) +{ + w1_reset_select(dev); + + w1_write_byte(dev, W1_F2D_READ_EEPROM); + w1_write_byte(dev, offset & 0xff); + w1_write_byte(dev, offset >> 8); + + return w1_read_buf(dev, buf, count); +} + +static const struct eeprom_ops ds2431_ops = { + .read_buf = ds2431_read_buf, +}; + +U_BOOT_DRIVER(ds2431) = { + .name = "ds2431", + .id = UCLASS_EEPROM, + .ops = &ds2431_ops, +}; + +U_BOOT_W1_DEVICE(ds2431, W1_FAMILY_DS2431);
Add a driver for the Maxim DS2431 1-Wire EEPROM Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> --- drivers/eeprom/Kconfig | 6 ++++++ drivers/eeprom/Makefile | 1 + drivers/eeprom/ds2431.c | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 0 deletions(-) create mode 100644 drivers/eeprom/ds2431.c