sunxi: chip: Enable the DIP auto-detection
Subsystems (5)
cover sunxi: chip: Enable the DIP auto-detection
The NextThing's C.H.I.P. can have expansion boards called DIPs. Those DIPs are connected through the external headers, and comes with an identification mechanism based on 1-Wire EEPROMs.
That auto-detection works great, because 1-Wire allows the enumeration, and the EEPROMs are guaranteed to have different addresses, which allows us to stack as many DIPs as possible, without any constraints.
Since those DIPs can be close to anything, ranging from a simple PWM-based buzzer to a full featured device such as the PocketCHIP (which comes with a touchscreen, a keyboard, a battery, etc), some adjustments might be needed in U-Boot to be able to present something that just works to the user.
In particular, we need to:
- Apply an overlay if the device is something that should be dealt with early in the boot process (display, storage device)
- Adjust the U-Boot environment if the DIP has a display to change the default video output
- Adjust the kernel command line in previous case for Linux to have the same default
In order to achieve that, we introduced some logic optionally hooked into the sunxi board, two new uclasses for 1-Wire and EEPROMs, and a bunch of new environment variables:
- dip-auto-video to control the automatic video set up (default to yes)
- dip_overlay_cmd that is a script to load the overlay $dip_overlay_name to $dip_addr_r, from whatever place it was stored in, and later apply it.
- kernelarg_video to host the default kernel output in the kernel command line
I think the biggest drawback at the moment is that we maintain a list of DIPs and the actions needed directly into the C code, which will make it quite hard to customise for end users and tedious to maintain in the long term. I couldn't really get my head around a better solution, so feel free to suggest alternative approaches.
Let me know what you think,
Maxime
Maxime Ripard (9):
fdtdec: Fix alias retrieval
sunxi: chip: Add 1-wire node
w1: Add 1-Wire uclass
w1: Add 1-Wire gpio driver
EEPROM: Add an EEPROM uclass
eeprom: Add DS2431 support
video: Allow board hook before video init
sunxi: Add CHIP's DIP support
config: chip: Enable DIP support
arch/arm/dts/sun5i-r8-chip.dts | 15 ++- board/sunxi/Kconfig | 9 +- board/sunxi/Makefile | 1 +- board/sunxi/board.c | 6 +- board/sunxi/dip.c | 227 ++++++++++++++++++++++++++++++- configs/CHIP_defconfig | 5 +- drivers/Kconfig | 4 +- drivers/Makefile | 2 +- drivers/eeprom/Kconfig | 23 +++- drivers/eeprom/Makefile | 3 +- drivers/eeprom/ds2431.c | 38 +++++- drivers/eeprom/eeprom-uclass.c | 57 +++++++- drivers/video/cfb_console.c | 9 +- drivers/w1/Kconfig | 23 +++- drivers/w1/Makefile | 3 +- drivers/w1/w1-gpio.c | 160 +++++++++++++++++++++- drivers/w1/w1-uclass.c | 259 ++++++++++++++++++++++++++++++++++- include/dm/uclass-id.h | 2 +- include/eeprom.h | 21 +++- include/w1.h | 47 ++++++- lib/fdtdec.c | 3 +- 21 files changed, 916 insertions(+), 1 deletion(-) create mode 100644 board/sunxi/dip.c create mode 100644 drivers/eeprom/Kconfig create mode 100644 drivers/eeprom/Makefile create mode 100644 drivers/eeprom/ds2431.c create mode 100644 drivers/eeprom/eeprom-uclass.c create mode 100644 drivers/w1/Kconfig create mode 100644 drivers/w1/Makefile create mode 100644 drivers/w1/w1-gpio.c create mode 100644 drivers/w1/w1-uclass.c create mode 100644 include/eeprom.h create mode 100644 include/w1.h
base-commit: d8bdfc80da39211d95f10d24e79f2e867305f71b
Signature · 1 line
git-series 0.8.11
PATCH RESEND 1/9 fdtdec: Fix alias retrieval
When the subsystem in u-boot ends up with a number, the alias parsing mechanism was off, being confused between the actual number, and the alias number.
Fix the code to start parsing the alias at the end of our subsystem name.
--- lib/fdtdec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
lib/fdtdec.c +2 -1
@@ -538,7 +538,8 @@ int fdtdec_get_alias_seq(const void *blob, const char *base, int offset, slash =strrchr (prop,'/' );if (strcmp (slash +1 , find_name))continue ; - val =trailing_strtol (name); + + val =simple_strtol (name + base_len,NULL ,10 );if (val !=-1 ) { *seqp = val;debug ("Found seq %d\n" , *seqp);
Signature · 1 line
git-series 0.8.11
PATCH RESEND 2/9 sunxi: chip: Add 1-wire node
In reply to Maxime RipardThe CHIP uses on PD2 (a pin incorrectly called LCD_D2) a bitbanged 1-Wire bus to discover the adapters plug into it.
Add that bus to the device tree.
--- arch/arm/dts/sun5i-r8-chip.dts | 15 +++++++++++++++ 1 file changed, 15 insertions(+), 0 deletions(-)
arch/arm/dts/sun5i-r8-chip.dts +15 -0
@@ -59,6 +59,7 @@ i2c2 = &i2c2; serial0 = &uart1; serial1 = &uart3; + w10 = &w1; }; chosen {
@@ -76,6 +77,13 @@ gpio = <&pio 2 19 GPIO_ACTIVE_HIGH>; /* PC19 */ enable-active-high; }; + + w1: onewire { + compatible = "w1-gpio"; + gpios = <&pio 3 2 GPIO_ACTIVE_HIGH>; /* PD2 */ + pinctrl-names = "default"; + pinctrl-0 = <&chip_w1_pin>; + }; }; &be0 {
@@ -175,6 +183,13 @@ allwinner,drive = <SUN4I_PINCTRL_10_MA>; allwinner,pull = <SUN4I_PINCTRL_NO_PULL>; }; + + chip_w1_pin: chip_w1_pin at 0 { + allwinner,pins = "PD2"; + allwinner,function = "gpio_in"; + allwinner,drive = <SUN4I_PINCTRL_10_MA>; + allwinner,pull = <SUN4I_PINCTRL_PULL_UP>; + }; }; ®_dcdc2 {
Signature · 1 line
git-series 0.8.11
PATCH RESEND 3/9 w1: Add 1-Wire uclass
In reply to Maxime RipardWe might want to use 1-Wire devices connected on boards such as EEPROMs in U-Boot.
Provide a framework to be able to do that.
--- drivers/Kconfig | 2 +- drivers/Makefile | 1 +- drivers/w1/Kconfig | 17 +++- drivers/w1/Makefile | 2 +- drivers/w1/w1-uclass.c | 259 ++++++++++++++++++++++++++++++++++++++++++- include/dm/uclass-id.h | 1 +- include/w1.h | 47 ++++++++- 7 files changed, 329 insertions(+), 0 deletions(-) create mode 100644 drivers/w1/Kconfig create mode 100644 drivers/w1/Makefile create mode 100644 drivers/w1/w1-uclass.c create mode 100644 include/w1.h
drivers/Kconfig +2 -0
@@ -84,6 +84,8 @@ source "drivers/usb/Kconfig" source "drivers/video/Kconfig" +source "drivers/w1/Kconfig" + source "drivers/watchdog/Kconfig" config PHYS_TO_BUS
drivers/Makefile +1 -0
@@ -91,6 +91,7 @@ obj-y += input/ obj-y += soc/ obj-$(CONFIG_REMOTEPROC) += remoteproc/ obj-y += thermal/ +obj-y += w1/ obj-$(CONFIG_MACH_PIC32) += ddr/microchip/ endif
drivers/w1/Kconfig new file +17 -0
@@ -0,0 +1,17 @@ +# +# W1 subsystem configuration +# + +menu "1-Wire support" + +config W1 + bool "Enable 1-Wire controllers support" + depends on DM + help + Support for the Dallas 1-Wire bus. + +if W1 + +endif + +endmenu
drivers/w1/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +obj-$(CONFIG_W1) += w1-uclass.o +
drivers/w1/w1-uclass.c new file +259 -0
259 lines not on this page · raw message
include/dm/uclass-id.h +1 -0
@@ -82,6 +82,7 @@ enum uclass_id {UCLASS_VIDEO ,/* Video or LCD device */ UCLASS_VIDEO_BRIDGE ,/* Video bridge, e.g. DisplayPort to LVDS */ UCLASS_VIDEO_CONSOLE ,/* Text console driver for video device */ +UCLASS_W1 ,/* Dallas 1-Wire bus */ UCLASS_COUNT , UCLASS_INVALID = -1,
include/w1.h new file +47 -0
47 lines not on this page · raw message
Signature · 1 line
git-series 0.8.11
PATCH RESEND 4/9 w1: Add 1-Wire gpio driver
In reply to Maxime RipardAdd a bus driver for bitbanging a 1-Wire bus over a GPIO.
--- drivers/w1/Kconfig | 6 ++- drivers/w1/Makefile | 1 +- drivers/w1/w1-gpio.c | 160 ++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 167 insertions(+), 0 deletions(-) create mode 100644 drivers/w1/w1-gpio.c
drivers/w1/Kconfig +6 -0
@@ -12,6 +12,12 @@ config W1 if W1 +config W1_GPIO + bool "Enable 1-Wire GPIO bitbanging" + depends on DM_GPIO + help + Emulate a 1-Wire bus using a GPIO. + endif endmenu
drivers/w1/Makefile +1 -0
@@ -1,2 +1,3 @@ obj-$(CONFIG_W1) += w1-uclass.o +obj-$(CONFIG_W1_GPIO) += w1-gpio.o
drivers/w1/w1-gpio.c new file +160 -0
160 lines not on this page · raw message
Signature · 1 line
git-series 0.8.11
PATCH RESEND 4/9 w1: Add 1-Wire gpio driver
Quoted 192 lines · Maxime Ripard
Add a bus driver for bitbanging a 1-Wire bus over a GPIO.
Signed-off-by Maxime Ripard <[email protected]>--- drivers/w1/Kconfig | 6 ++- drivers/w1/Makefile | 1 +- drivers/w1/w1-gpio.c | 160 ++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 167 insertions(+), 0 deletions(-) create mode 100644 drivers/w1/w1-gpio.cdrivers/w1/Kconfig +6
-0@@ -12,6 +12,12 @@ config W1 if W1 +config W1_GPIO + bool "Enable 1-Wire GPIO bitbanging" + depends on DM_GPIO + help + Emulate a 1-Wire bus using a GPIO. + endif endmenudrivers/w1/Makefile +1
-0@@ -1,2 +1,3 @@ obj-$(CONFIG_W1) += w1-uclass.o +obj-$(CONFIG_W1_GPIO) += w1-gpio.odrivers/w1/w1-gpio.c new file +150
-0@@ -0,0 +1,160 @@ +/* +* Copyright (c) 2015 Free Electrons +* Copyright (c) 2015 NextThing Co +* +* Maxime Ripard <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <dm.h> +#include <w1.h> + +#include <asm/gpio.h> + + +#define W1_TIMING_A 6 +#define W1_TIMING_B 64 +#define W1_TIMING_C 60 +#define W1_TIMING_D 10 +#define W1_TIMING_E 9 +#define W1_TIMING_F 55 +#define W1_TIMING_G 0 +#define W1_TIMING_H 480 +#define W1_TIMING_I 70 +#define W1_TIMING_J 410 + +struct w1_gpio_pdata { +struct gpio_desc gpio; +u64 search_id; +}; + +static bool w1_gpio_read_bit (struct udevice *dev) +{ +struct w1_gpio_pdata *pdata =dev_get_platdata (dev); +int val; + +dm_gpio_set_dir_flags (&pdata->gpio,GPIOD_IS_OUT ); +udelay (W1_TIMING_A ); + +dm_gpio_set_dir_flags (&pdata->gpio,GPIOD_IS_IN ); +udelay (W1_TIMING_E ); + + val =dm_gpio_get_value (&pdata->gpio); +udelay (W1_TIMING_F ); + +return val; +} + +static u8 w1_gpio_read_byte (struct udevice *dev) +{ +int i; +u8 ret =0 ; + +for (i =0 ; i <8 ; ++i) + ret |= (w1_gpio_read_bit (dev) ?1 :0 ) << i; + +return ret; +} + +static void w1_gpio_write_bit (struct udevice *dev,bool bit) +{ +struct w1_gpio_pdata *pdata =dev_get_platdata (dev); + +dm_gpio_set_dir_flags (&pdata->gpio,GPIOD_IS_OUT ); + + bit ?udelay (W1_TIMING_A ) :udelay (W1_TIMING_C ); + +dm_gpio_set_value (&pdata->gpio,1 ); + + bit ?udelay (W1_TIMING_B ) :udelay (W1_TIMING_D ); +} + +static void w1_gpio_write_byte (struct udevice *dev,u8 byte) +{ +int i; + +for (i =0 ; i <8 ; ++i) +w1_gpio_write_bit (dev, (byte >> i) &0x1 ); +} + +static bool w1_gpio_reset (struct udevice *dev) +{ +struct w1_gpio_pdata *pdata =dev_get_platdata (dev); +int val; + +dm_gpio_set_dir_flags (&pdata->gpio,GPIOD_IS_OUT |GPIOD_IS_OUT_ACTIVE ); +udelay (W1_TIMING_G ); + +dm_gpio_set_value (&pdata->gpio,0 ); +udelay (W1_TIMING_H ); + +dm_gpio_set_dir_flags (&pdata->gpio,GPIOD_IS_IN ); +udelay (W1_TIMING_I ); + + val =dm_gpio_get_value (&pdata->gpio); +udelay (W1_TIMING_J ); + +return val; +} + +static u8 w1_gpio_triplet (struct udevice *dev,bool bdir) +{ +u8 id_bit =w1_gpio_read_bit (dev); +u8 comp_bit =w1_gpio_read_bit (dev); +u8 retval; + +if (id_bit && comp_bit) +return 0x03 ;/* error */ + +if (!id_bit && !comp_bit) { +/* Both bits are valid, take the direction given */ + retval = bdir ?0x04 :0 ; + }else { +/* Only one bit is valid, take that direction */ + bdir = id_bit; + retval = id_bit ?0x05 :0x02 ; + } + +w1_gpio_write_bit (dev, bdir); +return retval; +} + + +static const struct w1_ops w1_gpio_ops = { + .read_byte = w1_gpio_read_byte, + .reset = w1_gpio_reset, + .triplet = w1_gpio_triplet, + .write_byte = w1_gpio_write_byte, +}; + +static int w1_gpio_ofdata_to_platdata (struct udevice *dev) +{ +struct w1_gpio_pdata *pdata =dev_get_platdata (dev); +int ret; + + ret =gpio_request_by_name (dev,"gpios" ,0 , &pdata->gpio,0 ); +if (ret <0 ) + goto error; + +return 0 ; + +error: +printf ("Error claiming GPIO %d\n" , ret); +return ret; +}; + +static const struct udevice_id w1_gpio_id[] = { + {"w1-gpio" ,0 }, + { },
drivers/w1/w1-gpio.c line 160
Quoted 10 lines
drivers/w1/w1-gpio.c new file +10
-0+}; + +U_BOOT_DRIVER (w1_gpio_drv) = { + .id =UCLASS_W1 , + .name ="w1_gpio_drv" , + .of_match = w1_gpio_id, + .ofdata_to_platdata = w1_gpio_ofdata_to_platdata, + .ops = &w1_gpio_ops, + .platdata_auto_alloc_size =sizeof (struct w1_gpio_pdata ), +};
Has someone test this on different HW?
As I went through the series will be good to have cmd/w1.c to be able to test that devices.
Thanks,
Michal
Signature · 14 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91 w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel - Xilinx Microblaze Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP SoCs -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: OpenPGP digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161110/3cfd7bfd/attachment.sig>
PATCH RESEND 4/9 w1: Add 1-Wire gpio driver
Quoted 197 lines · Michal Simek
Quoted 196 lines · Maxime Ripard
Add a bus driver for bitbanging a 1-Wire bus over a GPIO.
Signed-off-by Maxime Ripard <[email protected]>--- drivers/w1/Kconfig | 6 ++- drivers/w1/Makefile | 1 +- drivers/w1/w1-gpio.c | 160 ++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 167 insertions(+), 0 deletions(-) create mode 100644 drivers/w1/w1-gpio.cdrivers/w1/Kconfig +6
-0@@ -12,6 +12,12 @@ config W1 if W1 +config W1_GPIO + bool "Enable 1-Wire GPIO bitbanging" + depends on DM_GPIO + help + Emulate a 1-Wire bus using a GPIO. + endif endmenudrivers/w1/Makefile +1
-0@@ -1,2 +1,3 @@ obj-$(CONFIG_W1) += w1-uclass.o +obj-$(CONFIG_W1_GPIO) += w1-gpio.odrivers/w1/w1-gpio.c new file +155
-0@@ -0,0 +1,160 @@ +/* +* Copyright (c) 2015 Free Electrons +* Copyright (c) 2015 NextThing Co +* +* Maxime Ripard <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <dm.h> +#include <w1.h> + +#include <asm/gpio.h> + + +#define W1_TIMING_A 6 +#define W1_TIMING_B 64 +#define W1_TIMING_C 60 +#define W1_TIMING_D 10 +#define W1_TIMING_E 9 +#define W1_TIMING_F 55 +#define W1_TIMING_G 0 +#define W1_TIMING_H 480 +#define W1_TIMING_I 70 +#define W1_TIMING_J 410 + +struct w1_gpio_pdata { +struct gpio_desc gpio; +u64 search_id; +}; + +static bool w1_gpio_read_bit (struct udevice *dev) +{ +struct w1_gpio_pdata *pdata =dev_get_platdata (dev); +int val; + +dm_gpio_set_dir_flags (&pdata->gpio,GPIOD_IS_OUT ); +udelay (W1_TIMING_A ); + +dm_gpio_set_dir_flags (&pdata->gpio,GPIOD_IS_IN ); +udelay (W1_TIMING_E ); + + val =dm_gpio_get_value (&pdata->gpio); +udelay (W1_TIMING_F ); + +return val; +} + +static u8 w1_gpio_read_byte (struct udevice *dev) +{ +int i; +u8 ret =0 ; + +for (i =0 ; i <8 ; ++i) + ret |= (w1_gpio_read_bit (dev) ?1 :0 ) << i; + +return ret; +} + +static void w1_gpio_write_bit (struct udevice *dev,bool bit) +{ +struct w1_gpio_pdata *pdata =dev_get_platdata (dev); + +dm_gpio_set_dir_flags (&pdata->gpio,GPIOD_IS_OUT ); + + bit ?udelay (W1_TIMING_A ) :udelay (W1_TIMING_C ); + +dm_gpio_set_value (&pdata->gpio,1 ); + + bit ?udelay (W1_TIMING_B ) :udelay (W1_TIMING_D ); +} + +static void w1_gpio_write_byte (struct udevice *dev,u8 byte) +{ +int i; + +for (i =0 ; i <8 ; ++i) +w1_gpio_write_bit (dev, (byte >> i) &0x1 ); +} + +static bool w1_gpio_reset (struct udevice *dev) +{ +struct w1_gpio_pdata *pdata =dev_get_platdata (dev); +int val; + +dm_gpio_set_dir_flags (&pdata->gpio,GPIOD_IS_OUT |GPIOD_IS_OUT_ACTIVE ); +udelay (W1_TIMING_G ); + +dm_gpio_set_value (&pdata->gpio,0 ); +udelay (W1_TIMING_H ); + +dm_gpio_set_dir_flags (&pdata->gpio,GPIOD_IS_IN ); +udelay (W1_TIMING_I ); + + val =dm_gpio_get_value (&pdata->gpio); +udelay (W1_TIMING_J ); + +return val; +} + +static u8 w1_gpio_triplet (struct udevice *dev,bool bdir) +{ +u8 id_bit =w1_gpio_read_bit (dev); +u8 comp_bit =w1_gpio_read_bit (dev); +u8 retval; + +if (id_bit && comp_bit) +return 0x03 ;/* error */ + +if (!id_bit && !comp_bit) { +/* Both bits are valid, take the direction given */ + retval = bdir ?0x04 :0 ; + }else { +/* Only one bit is valid, take that direction */ + bdir = id_bit; + retval = id_bit ?0x05 :0x02 ; + } + +w1_gpio_write_bit (dev, bdir); +return retval; +} + + +static const struct w1_ops w1_gpio_ops = { + .read_byte = w1_gpio_read_byte, + .reset = w1_gpio_reset, + .triplet = w1_gpio_triplet, + .write_byte = w1_gpio_write_byte, +}; + +static int w1_gpio_ofdata_to_platdata (struct udevice *dev) +{ +struct w1_gpio_pdata *pdata =dev_get_platdata (dev); +int ret; + + ret =gpio_request_by_name (dev,"gpios" ,0 , &pdata->gpio,0 ); +if (ret <0 ) + goto error; + +return 0 ; + +error: +printf ("Error claiming GPIO %d\n" , ret); +return ret; +}; + +static const struct udevice_id w1_gpio_id[] = { + {"w1-gpio" ,0 }, + { }, +}; + +U_BOOT_DRIVER (w1_gpio_drv) = { + .id =UCLASS_W1 , + .name ="w1_gpio_drv" ,
Quoted 8 lines
drivers/w1/w1-gpio.c line 160
Quoted 6 lines
drivers/w1/w1-gpio.c new file +5
-0+ .of_match = w1_gpio_id, + .ofdata_to_platdata = w1_gpio_ofdata_to_platdata, + .ops = &w1_gpio_ops, + .platdata_auto_alloc_size = sizeof(struct w1_gpio_pdata), +};Has someone test this on different HW?
I didn't, but it looks pretty generic.
The only thing you have to make sure is that you can respect the rather tight timing constraints of the bus. That rules out a GPIO on an I2C expander for example.
Quoted 2 lines
As I went through the series will be good to have
cmd/w1.cto be able to test that devices.
Ack.
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 801 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161111/d199b9a1/attachment.sig>
PATCH RESEND 5/9 EEPROM: Add an EEPROM uclass
In reply to Maxime RipardWe might want to access data stored onto EEPROMs. Create a framework to provide a consistent API.
--- drivers/Kconfig | 2 +- drivers/Makefile | 1 +- drivers/eeprom/Kconfig | 17 ++++++++++- drivers/eeprom/Makefile | 2 +- drivers/eeprom/eeprom-uclass.c | 57 +++++++++++++++++++++++++++++++++++- include/dm/uclass-id.h | 1 +- include/eeprom.h | 21 +++++++++++++- 7 files changed, 101 insertions(+), 0 deletions(-) create mode 100644 drivers/eeprom/Kconfig create mode 100644 drivers/eeprom/Makefile create mode 100644 drivers/eeprom/eeprom-uclass.c create mode 100644 include/eeprom.h
drivers/Kconfig +2 -0
@@ -20,6 +20,8 @@ source "drivers/dfu/Kconfig" source "drivers/dma/Kconfig" +source "drivers/eeprom/Kconfig" + source "drivers/fpga/Kconfig" source "drivers/gpio/Kconfig"
drivers/Makefile +1 -0
@@ -64,6 +64,7 @@ obj-y += block/ obj-$(CONFIG_BOOTCOUNT_LIMIT) += bootcount/ obj-$(CONFIG_CPU) += cpu/ obj-y += crypto/ +obj-y += eeprom/ obj-$(CONFIG_FPGA) += fpga/ obj-y += hwmon/ obj-y += misc/
drivers/eeprom/Kconfig new file +17 -0
@@ -0,0 +1,17 @@ +# +# EEPROM subsystem configuration +# + +menu "EEPROM support" + +config EEPROM + bool "Enable EEPROM support" + depends on DM + help + Support for the EEPROMs + +if EEPROM + +endif + +endmenu
drivers/eeprom/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +obj-$(CONFIG_EEPROM) += eeprom-uclass.o +
drivers/eeprom/eeprom-uclass.c new file +57 -0
57 lines not on this page · raw message
include/dm/uclass-id.h +1 -0
@@ -83,6 +83,7 @@ enum uclass_id {UCLASS_VIDEO_BRIDGE ,/* Video bridge, e.g. DisplayPort to LVDS */ UCLASS_VIDEO_CONSOLE ,/* Text console driver for video device */ UCLASS_W1 ,/* Dallas 1-Wire bus */ +UCLASS_EEPROM ,/* EEPROM */ UCLASS_COUNT , UCLASS_INVALID = -1,
include/eeprom.h new file +21 -0
@@ -0,0 +1,21 @@ +/* +* Copyright (c) 2015 Free Electrons +* Copyright (c) 2015 NextThing Co +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef __EEPROM_H +#define __EEPROM_H + +#include <dm.h> + +struct eeprom_ops { +int (*read_buf)(struct udevice *dev,unsigned offset, +u8 *buf,unsigned count); +}; + +int eeprom_read_buf (struct udevice *dev,unsigned offset, +u8 *buf,unsigned count); + +#endif
Signature · 1 line
git-series 0.8.11
PATCH RESEND 5/9 EEPROM: Add an EEPROM uclass
Hi Maxime,
Quoted 2 lines · Maxime Ripard
We might want to access data stored onto EEPROMs. Create a framework to provide a consistent API.
We have UCLASS_I2C_EEPROM. Can we unify these? If not, please add a sandbox driver and test.
Quoted 48 lines
Signed-off-by Maxime Ripard <[email protected]>--- drivers/Kconfig | 2 +- drivers/Makefile | 1 +- drivers/eeprom/Kconfig | 17 ++++++++++- drivers/eeprom/Makefile | 2 +- drivers/eeprom/eeprom-uclass.c | 57 +++++++++++++++++++++++++++++++++++- include/dm/uclass-id.h | 1 +- include/eeprom.h | 21 +++++++++++++- 7 files changed, 101 insertions(+), 0 deletions(-) create mode 100644 drivers/eeprom/Kconfig create mode 100644 drivers/eeprom/Makefile create mode 100644 drivers/eeprom/eeprom-uclass.c create mode 100644 include/eeprom.hdrivers/Kconfig +2
-0@@ -20,6 +20,8 @@ source "drivers/dfu/Kconfig" source "drivers/dma/Kconfig" +source "drivers/eeprom/Kconfig" + source "drivers/fpga/Kconfig" source "drivers/gpio/Kconfig"drivers/Makefile +1
-0@@ -64,6 +64,7 @@ obj-y += block/ obj-$(CONFIG_BOOTCOUNT_LIMIT) += bootcount/ obj-$(CONFIG_CPU) += cpu/ obj-y += crypto/ +obj-y += eeprom/ obj-$(CONFIG_FPGA) += fpga/ obj-y += hwmon/ obj-y += misc/drivers/eeprom/Kconfig new file +1
-0@@ -0,0 +1,17 @@ +#
drivers/eeprom/Kconfig line 11
Quoted 10 lines
drivers/eeprom/Kconfig new file +10
-0+# EEPROM subsystem configuration +# + +menu "EEPROM support" + +config EEPROM + bool "Enable EEPROM support" + depends on DM + help + Support for the EEPROMs
Please expand this a bit.
Quoted 56 lines
drivers/eeprom/Kconfig new file +6
-0+ +if EEPROM + +endif + +endmenudrivers/eeprom/Makefile new file +2
-0@@ -0,0 +1,2 @@ +obj-$(CONFIG_EEPROM) += eeprom-uclass.o +drivers/eeprom/eeprom-uclass.c new file +36
-0@@ -0,0 +1,57 @@ +/* +* Copyright (c) 2015 Free Electrons +* Copyright (c) 2015 NextThing Co. +* +* Maxime Ripard <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <dm.h> +#include <eeprom.h> + +#include <dm/device-internal.h> + +int eeprom_read_buf (struct udevice *dev,unsigned offset, +u8 *buf,unsigned count) +{ +const struct eeprom_ops *ops =device_get_ops (dev); + +if (!ops->read_buf) +return -ENOSYS ; + +return ops->read_buf (dev, offset, buf, count); +} + + +UCLASS_DRIVER (eeprom) = { + .name ="eeprom" , + .id =UCLASS_EEPROM , +}; + +int eeprom_dm_init (void ) +{ +struct udevice *bus; +struct uclass *uc;
drivers/eeprom/eeprom-uclass.c line 46
Quoted 10 lines
drivers/eeprom/eeprom-uclass.c new file +10
-0+int ret; + + ret =uclass_get (UCLASS_EEPROM , &uc); +if (ret) +return ret; + + uclass_foreach_dev(bus, uc) { + ret =device_probe (bus); +if (ret == -ENODEV ) {/* No such device. */ +printf ("EEPROM not available.\n" );
debug()?
drivers/eeprom/eeprom-uclass.c line 51
Quoted 5 lines
drivers/eeprom/eeprom-uclass.c new file +5
-0+continue ; + } + +if (ret) {/* Other error. */ +printf ("EEPROM probe failed, error %d\n" , ret);
debug()?
Quoted 11 lines
drivers/eeprom/eeprom-uclass.c new file +6
-0+continue ; + } + } + +return 0 ; +}include/dm/uclass-id.h +0
-0
include/dm/uclass-id.h enum uclass_id { · line 86
Quoted 4 lines
include/dm/uclass-id.h +1
-0@@ -83,6 +83,7 @@ enum uclass_id {UCLASS_VIDEO_BRIDGE ,/* Video bridge, e.g. DisplayPort to LVDS */ UCLASS_VIDEO_CONSOLE ,/* Text console driver for video device */ UCLASS_W1 ,/* Dallas 1-Wire bus */ + UCLASS_EEPROM, /* EEPROM */
Please put this in alpha order.
Quoted 10 lines
include/dm/uclass-id.h +0
-0UCLASS_COUNT , UCLASS_INVALID = -1,include/eeprom.h new file +1
-0@@ -0,0 +1,21 @@ +/*
include/eeprom.h line 11
Quoted 10 lines
include/eeprom.h new file +10
-0+* Copyright (c) 2015 Free Electrons +* Copyright (c) 2015 NextThing Co +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef __EEPROM_H +#define __EEPROM_H + +#include <dm.h>
You can use a 'struct udevice *' forward decl instead.
include/eeprom.h line 13
Quoted 2 lines
include/eeprom.h new file +2
-0+ +struct eeprom_ops {
Please add comments
Quoted 10 lines
include/eeprom.h new file +8
-1+int (*read_buf)(struct udevice *dev,unsigned offset, + u8 *buf, unsigned count); +}; + +int eeprom_read_buf (struct udevice *dev,unsigned offset, +u8 *buf,unsigned count); + +#endif --git-series 0.8.11
Regards,
Simon
PATCH RESEND 5/9 EEPROM: Add an EEPROM uclass
Hi Maxime,
Quoted 9 lines · Simon Glass
Hi Maxime,
Quoted 2 lines · Maxime Ripard
We might want to access data stored onto EEPROMs. Create a framework to provide a consistent API.
We have
UCLASS_I2C_EEPROM. Can we unify these? If not, please add a sandbox driver and test.
I've been working on something very similar (the API looks the same obviously, since the ops are pretty trivial, modulo function names)
In my opinion it should be working as follows:
UCLASS_EEPROM
\... I2C_EEPROM
\....SPI_EEPROM (AT25)
I also have some code to make the CMD_EEPROM stuff work, I'll submit a follow up patch,
once we agreed on how the UCLASS_EEPROM looks like.
Cheers,
Moritz
PATCH RESEND 5/9 EEPROM: Add an EEPROM uclass
Hi Moritz,
Quoted 13 lines · Moritz Fischer
Hi Maxime,
Quoted 9 lines · Simon Glass
Hi Maxime,
Quoted 2 lines · Maxime Ripard
We might want to access data stored onto EEPROMs. Create a framework to provide a consistent API.
We have
UCLASS_I2C_EEPROM. Can we unify these? If not, please add a sandbox driver and test.
Quoted 7 lines
I've been working on something very similar (the API looks the same obviously, since the ops are pretty trivial, modulo function names)
In my opinion it should be working as follows:
UCLASS_EEPROM
\...I2C_EEPROM
\....SPI_EEPROM (AT25)
I agree. Different board variations might be using different buses to store the same data, and it's all EEPROM anyway.
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 801 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161114/b782892c/attachment.sig>
PATCH RESEND 6/9 eeprom: Add DS2431 support
In reply to Maxime RipardAdd a driver for the Maxim DS2431 1-Wire EEPROM
--- 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
drivers/eeprom/Kconfig +6 -0
@@ -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
drivers/eeprom/Makefile +1 -0
@@ -1,2 +1,3 @@ obj-$(CONFIG_EEPROM) += eeprom-uclass.o +obj-$(CONFIG_EEPROM_DS2431) += ds2431.o
drivers/eeprom/ds2431.c new file +38 -0
@@ -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 );
Signature · 1 line
git-series 0.8.11
PATCH RESEND 6/9 eeprom: Add DS2431 support
Hi Maxime,
Quoted 66 lines · Maxime Ripard
Add a driver for the Maxim DS2431 1-Wire EEPROM
Signed-off-by Maxime Ripard <[email protected]>--- 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.cdrivers/eeprom/Kconfig +6
-0@@ -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 endmenudrivers/eeprom/Makefile +1
-0@@ -1,2 +1,3 @@ obj-$(CONFIG_EEPROM) += eeprom-uclass.o +obj-$(CONFIG_EEPROM_DS2431) += ds2431.odrivers/eeprom/ds2431.c new file +25
-0@@ -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);
drivers/eeprom/ds2431.c line 35
Quoted 10 lines
drivers/eeprom/ds2431.c new file +10
-0+} + +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?
Quoted 9 lines
drivers/eeprom/ds2431.c new file +3
-1+}; + +U_BOOT_W1_DEVICE (ds2431,W1_FAMILY_DS2431 ); --git-series 0.8.11
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
Cheers,
Moritz
PATCH RESEND 6/9 eeprom: Add DS2431 support
Hi,
Quoted 6 lines · Moritz Fischer
drivers/eeprom/ds2431.c line 35
Quoted 4 lines
drivers/eeprom/ds2431.c new file +4
-0+U_BOOT_DRIVER (ds2431) = { + .name ="ds2431" , + .id =UCLASS_EEPROM , + .ops = &ds2431_ops,Do you want to add a .flags =
DM_UC_FLAG_SEQ_ALIAShere?
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
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 801 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161114/3cddbef0/attachment.sig>
PATCH RESEND 6/9 eeprom: Add DS2431 support
Quoted 8 lines · Maxime Ripard
Hi,
Quoted 5 lines · Moritz Fischer
Quoted 4 lines
drivers/eeprom/ds2431.c new file +4
-0+U_BOOT_DRIVER (ds2431) = { + .name ="ds2431" , + .id =UCLASS_EEPROM , + .ops = &ds2431_ops,
Quoted 6 lines
Quoted 1 line
Do you want to add a .flags =
DM_UC_FLAG_SEQ_ALIAShere?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!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161114/a0a334ba/attachment.sig>
PATCH RESEND 6/9 eeprom: Add DS2431 support
Quoted 9 lines · Tom Rini
Quoted 8 lines · Maxime Ripard
Hi,
Quoted 5 lines · Moritz Fischer
Quoted 4 lines
drivers/eeprom/ds2431.c new file +4
-0+U_BOOT_DRIVER (ds2431) = { + .name ="ds2431" , + .id =UCLASS_EEPROM , + .ops = &ds2431_ops,
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Do you want to add a .flags =
DM_UC_FLAG_SEQ_ALIAShere?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
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 801 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161114/a0ffdcc3/attachment.sig>
PATCH RESEND 6/9 eeprom: Add DS2431 support
Hi Maxime,
Quoted 17 lines · Maxime Ripard
Quoted 16 lines · Tom Rini
Quoted 14 lines · Maxime Ripard
Hi,
Quoted 6 lines · Moritz Fischer
drivers/eeprom/ds2431.c line 35
Quoted 4 lines
drivers/eeprom/ds2431.c new file +4
-0+U_BOOT_DRIVER (ds2431) = { + .name ="ds2431" , + .id =UCLASS_EEPROM , + .ops = &ds2431_ops,Do you want to add a .flags =
DM_UC_FLAG_SEQ_ALIAShere?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.
Quoted 4 lines
Quoted 1 line
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
PATCH RESEND 6/9 eeprom: Add DS2431 support
Quoted 21 lines · Simon Glass
Hi Maxime,
Quoted 17 lines · Maxime Ripard
Quoted 16 lines · Tom Rini
Quoted 14 lines · Maxime Ripard
Hi,
Quoted 6 lines · Moritz Fischer
drivers/eeprom/ds2431.c line 35
Quoted 4 lines
drivers/eeprom/ds2431.c new file +4
-0+U_BOOT_DRIVER (ds2431) = { + .name ="ds2431" , + .id =UCLASS_EEPROM , + .ops = &ds2431_ops,Do you want to add a .flags =
DM_UC_FLAG_SEQ_ALIAShere?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.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
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.htmlWell 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
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 801 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161114/6a3164b2/attachment.sig>
PATCH RESEND 6/9 eeprom: Add DS2431 support
Hi Maxime,
Quoted 27 lines · Maxime Ripard
Quoted 26 lines · Simon Glass
Hi Maxime,
Quoted 21 lines · Maxime Ripard
Quoted 9 lines · Tom Rini
Quoted 8 lines · Maxime Ripard
Hi,
Quoted 5 lines · Moritz Fischer
Quoted 4 lines
(quoted diff) +4
-0+U_BOOT_DRIVER(ds2431) = { + .name = "ds2431", + .id = UCLASS_EEPROM, + .ops = &ds2431_ops,Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Do you want to add a .flags =
DM_UC_FLAG_SEQ_ALIAShere?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
Quoted 8 lines
Quoted 1 line
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
PATCH RESEND 6/9 eeprom: Add DS2431 support
In reply to Maxime RipardHi Maxime,
Quoted 8 lines · Maxime Ripard
Hi,
Quoted 5 lines · Moritz Fischer
Quoted 4 lines
drivers/eeprom/ds2431.c new file +4
-0+U_BOOT_DRIVER (ds2431) = { + .name ="ds2431" , + .id =UCLASS_EEPROM , + .ops = &ds2431_ops,
Quoted 6 lines
Quoted 1 line
Do you want to add a .flags =
DM_UC_FLAG_SEQ_ALIAShere?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
PATCH RESEND 7/9 video: Allow board hook before video init
In reply to Maxime RipardSome boards might need to some additional setup right before initialising the video console.
Add some hook to allow that.
--- drivers/video/cfb_console.c | 9 +++++++++ 1 file changed, 9 insertions(+), 0 deletions(-)
drivers/video/cfb_console.c +9 -0
@@ -2119,6 +2119,11 @@ __weak int board_video_skip(void)return 0 ; } +__weak int board_video_pre_init (void ) +{ +return 0 ; +} +int drv_video_init (void ) {struct stdio_dev console_dev;
@@ -2129,6 +2134,10 @@ int drv_video_init(void)if (board_video_skip ())return 0 ; +/* Allow the board to setup a few things */ +if (board_video_pre_init ()) +return 0 ; +/* Init video chip - returns with framebuffer cleared */ if (cfg_video_init () ==-1 )return 0 ;
Signature · 1 line
git-series 0.8.11
PATCH RESEND 7/9 video: Allow board hook before video init
Hi Maxime,
Quoted 4 lines · Maxime Ripard
Some boards might need to some additional setup right before initialising the video console.
Add some hook to allow that.
Instead of this, can you use driver model (UCLASS_VIDEO)?
Quoted 34 lines
Signed-off-by Maxime Ripard <[email protected]>--- drivers/video/cfb_console.c | 9 +++++++++ 1 file changed, 9 insertions(+), 0 deletions(-)drivers/video/cfb_console.c +9
-1@@ -2119,6 +2119,11 @@ __weak int board_video_skip(void)return 0 ; } +__weak int board_video_pre_init (void ) +{ +return 0 ; +} +int drv_video_init (void ) {struct stdio_dev console_dev;@@ -2129,6 +2134,10 @@ int drv_video_init(void)if (board_video_skip ())return 0 ; +/* Allow the board to setup a few things */ +if (board_video_pre_init ()) +return 0 ; +/* Init video chip - returns with framebuffer cleared */ if (cfg_video_init () ==-1 )return 0 ; --
Quoted 1 line
git-series 0.8.11
Regards,
SImon
PATCH RESEND 7/9 video: Allow board hook before video init
Hi Simon,
Quoted 10 lines · Simon Glass
Hi Maxime,
Quoted 4 lines · Maxime Ripard
Some boards might need to some additional setup right before initialising the video console.
Add some hook to allow that.
Instead of this, can you use driver model (
UCLASS_VIDEO)?
I don't really know the device model that well, hence 'm not really sure how would that help. Can a board register a hook to be called before a driver is probed?
Thanks!
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 801 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161114/755da9c5/attachment.sig>
PATCH RESEND 7/9 video: Allow board hook before video init
Hi Maxime,
Quoted 10 lines · Maxime Ripard
Hi Simon,
Quoted 7 lines · Simon Glass
Hi Maxime,
Quoted 3 lines · Maxime Ripard
Some boards might need to some additional setup right before initialising the video console.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Add some hook to allow that.
Instead of this, can you use driver model (
UCLASS_VIDEO)?I don't really know the device model that well, hence 'm not really sure how would that help. Can a board register a hook to be called before a driver is probed?
My suggest would be that the driver can do whatever is required. What is the board-specific code actually wanting to do?
Regards,
Simon
PATCH RESEND 7/9 video: Allow board hook before video init
Hi Simon,
Quoted 16 lines · Simon Glass
Hi Maxime,
Quoted 12 lines · Maxime Ripard
Hi Simon,
Quoted 9 lines · Simon Glass
Hi Maxime,
Quoted 4 lines · Maxime Ripard
Some boards might need to some additional setup right before initialising the video console.
Add some hook to allow that.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Instead of this, can you use driver model (
UCLASS_VIDEO)?I don't really know the device model that well, hence 'm not really sure how would that help. Can a board register a hook to be called before a driver is probed?
My suggest would be that the driver can do whatever is required. What is the board-specific code actually wanting to do?
We need to adjust the video-mode environment variable that is going to be used in the driver's initialisation. We're doing that by identifying which daughter board is attached, and then setting that value according to the display output we want to use.
So we need some hook that would run between the environment initialisation and the video driver's init.
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 801 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161122/436ba234/attachment.sig>
PATCH RESEND 7/9 video: Allow board hook before video init
Hi Maxime,
Quoted 28 lines · Maxime Ripard
Hi Simon,
Quoted 16 lines · Simon Glass
Hi Maxime,
Quoted 12 lines · Maxime Ripard
Hi Simon,
Quoted 9 lines · Simon Glass
Hi Maxime,
Quoted 4 lines · Maxime Ripard
Some boards might need to some additional setup right before initialising the video console.
Add some hook to allow that.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Instead of this, can you use driver model (
UCLASS_VIDEO)?I don't really know the device model that well, hence 'm not really sure how would that help. Can a board register a hook to be called before a driver is probed?
My suggest would be that the driver can do whatever is required. What is the board-specific code actually wanting to do?
Quoted 7 lines
We need to adjust the video-mode environment variable that is going to be used in the driver's initialisation. We're doing that by identifying which daughter board is attached, and then setting that value according to the display output we want to use.
So we need some hook that would run between the environment initialisation and the video driver's init.
As an example of how you might pass platform data to the video driver, see board_init() in gurnard.c.
Regards,
Simon
PATCH RESEND 7/9 video: Allow board hook before video init
Quoted 37 lines · Simon Glass
Hi Maxime,
Quoted 33 lines · Maxime Ripard
Hi Simon,
Quoted 16 lines · Simon Glass
Hi Maxime,
Quoted 12 lines · Maxime Ripard
Hi Simon,
Quoted 9 lines · Simon Glass
Hi Maxime,
Quoted 4 lines · Maxime Ripard
Some boards might need to some additional setup right before initialising the video console.
Add some hook to allow that.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Instead of this, can you use driver model (
UCLASS_VIDEO)?I don't really know the device model that well, hence 'm not really sure how would that help. Can a board register a hook to be called before a driver is probed?
My suggest would be that the driver can do whatever is required. What is the board-specific code actually wanting to do?
We need to adjust the video-mode environment variable that is going to be used in the driver's initialisation. We're doing that by identifying which daughter board is attached, and then setting that value according to the display output we want to use.
Quoted 5 lines
Quoted 2 lines
So we need some hook that would run between the environment initialisation and the video driver's init.
As an example of how you might pass platform data to the video driver, see
board_init()ingurnard.c.
That's very useful, thanks!
Can you also postpone the probe of one driver, or at least defer a driver's probe until some other is done?
The way we identify the daughter boards also rely on some driver in the device model (a 1-Wire EEPROM, connected on a GPIO, both of them also being part of the device model), so we need to defer the video driver probe until both of them have been probed and accessed.
Thanks!
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 801 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161206/16242271/attachment.sig>
PATCH RESEND 7/9 video: Allow board hook before video init
Hi Maxime,
Quoted 41 lines · Maxime Ripard
Quoted 40 lines · Simon Glass
Hi Maxime,
Quoted 35 lines · Maxime Ripard
Hi Simon,
Quoted 16 lines · Simon Glass
Hi Maxime,
Quoted 12 lines · Maxime Ripard
Hi Simon,
Quoted 9 lines · Simon Glass
Hi Maxime,
Quoted 4 lines · Maxime Ripard
Some boards might need to some additional setup right before initialising the video console.
Add some hook to allow that.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Instead of this, can you use driver model (
UCLASS_VIDEO)?I don't really know the device model that well, hence 'm not really sure how would that help. Can a board register a hook to be called before a driver is probed?
My suggest would be that the driver can do whatever is required. What is the board-specific code actually wanting to do?
We need to adjust the video-mode environment variable that is going to be used in the driver's initialisation. We're doing that by identifying which daughter board is attached, and then setting that value according to the display output we want to use.
So we need some hook that would run between the environment initialisation and the video driver's init.
Quoted 7 lines
Quoted 2 lines
As an example of how you might pass platform data to the video driver, see
board_init()ingurnard.c.That's very useful, thanks!
Can you also postpone the probe of one driver, or at least defer a driver's probe until some other is done?
Well a device is not probed until it is used (or at least that is how it is supposed to work).
So perhaps you can probe the device in the driver that needs it? For example, if video probe needs GPIOs you can probe the GPIOs automatically (e.g. if you use something like gpio_request_by_name() in your video probe()).
Quoted 6 lines
The way we identify the daughter boards also rely on some driver in the device model (a 1-Wire EEPROM, connected on a GPIO, both of them also being part of the device model), so we need to defer the video driver probe until both of them have been probed and accessed.
Regards,
Simon
PATCH RESEND 8/9 sunxi: Add CHIP's DIP support
In reply to Maxime RipardThe NextThing CHIP comes with expansion boards called DIPs.
These DIPs comes with a 1-Wire EEPROM used to enumerate and identify the DIPs currently attached.
Once we know what is connected, we need to do various things, such a load and apply an overlay if relevant, adjust the U-boot environment and the kernel command line, etc.
Add support for this.
--- board/sunxi/Kconfig | 9 ++- board/sunxi/Makefile | 1 +- board/sunxi/board.c | 6 +- board/sunxi/dip.c | 227 ++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 243 insertions(+), 0 deletions(-) create mode 100644 board/sunxi/dip.c
board/sunxi/Kconfig +9 -0
@@ -667,4 +667,13 @@ config SPL_STACK_R_ADDR default 0x4fe00000 if MACH_SUN4I || MACH_SUN5I || MACH_SUN6I || MACH_SUN7I || MACH_SUN8I || MACH_SUN50I default 0x2fe00000 if MACH_SUN9I +config CHIP_DIP + bool "Enable NextThing's CHIP DIP support" + depends on W1_GPIO + depends on EEPROM_DS2431 + ---help--- + The NextThing's CHIP allows to plug expansion boards. These boards can + be enumerated at runtime through a 1-Wire bus, each board having an + EEPROM connected to it, holding data to identify the board holding it. + endif
board/sunxi/Makefile +1 -0
@@ -9,6 +9,7 @@ # SPDX-License-Identifier: GPL-2.0+ # obj-y += board.o +obj-$(CONFIG_CHIP_DIP) += dip.o obj-$(CONFIG_SUNXI_GMAC) += gmac.o obj-$(CONFIG_SUNXI_AHCI) += ahci.o obj-$(CONFIG_MACH_SUN4I) += dram_sun4i_auto.o
board/sunxi/board.c +6 -0
@@ -719,6 +719,12 @@ int ft_board_setup(void *blob, bd_t *bd)*/ setup_environment (blob); +#ifdef CONFIG_CHIP_DIP + r =chip_dip_dt_setup (blob); +if (r) +return r; +#endif +#ifdef CONFIG_VIDEO_DT_SIMPLEFB r =sunxi_simplefb_setup (blob);if (r)
board/sunxi/dip.c new file +227 -0
227 lines not on this page · raw message
Signature · 1 line
git-series 0.8.11
PATCH RESEND 9/9 config: chip: Enable DIP support
In reply to Maxime Ripard--- configs/CHIP_defconfig | 5 +++++ 1 file changed, 5 insertions(+), 0 deletions(-)
configs/CHIP_defconfig +5 -0
@@ -7,6 +7,7 @@ CONFIG_DRAM_TIMINGS_DDR3_800E_1066G_1333J=y # CONFIG_MMC is not set CONFIG_USB0_VBUS_PIN="PB10" CONFIG_VIDEO_COMPOSITE=y +CONFIG_CHIP_DIP=y CONFIG_DEFAULT_DEVICE_TREE="sun5i-r8-chip" CONFIG_SYS_EXTRA_OPTIONS="CONS_INDEX=2" CONFIG_SPL=y
@@ -23,3 +24,7 @@ CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_G_DNL_MANUFACTURER="Allwinner Technology" CONFIG_G_DNL_VENDOR_NUM=0x1f3a CONFIG_G_DNL_PRODUCT_NUM=0x1010 +CONFIG_EEPROM=y +CONFIG_EEPROM_DS2431=y +CONFIG_W1=y +CONFIG_W1_GPIO=y
Signature · 1 line
git-series 0.8.11
cover sunxi: chip: Enable the DIP auto-detection
In reply to Maxime RipardOn Tue, Nov 08, 2016 at 11:19:20AM +0100, Maxime Ripard wrote:
[snip]
Quoted 5 lines
I think the biggest drawback at the moment is that we maintain a list of DIPs and the actions needed directly into the C code, which will make it quite hard to customise for end users and tedious to maintain in the long term. I couldn't really get my head around a better solution, so feel free to suggest alternative approaches.
A thought I had after reading over 8/9 in the series was, could we try something like:
- In C, loop over everything in w1 and set environment variables based on each thing we find.
- In a CONFIG_PREBOOT load a U-Boot shell script in that will look for the right env variables to be set for a given DIP and then do whatever is needed to load in the overlay.
Does that make sense?
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161108/7afd37da/attachment.sig>
cover sunxi: chip: Enable the DIP auto-detection
Hi Tom,
Quoted 17 lines · Tom Rini
On Tue, Nov 08, 2016 at 11:19:20AM +0100, Maxime Ripard wrote:
[snip]
Quoted 5 lines
I think the biggest drawback at the moment is that we maintain a list of DIPs and the actions needed directly into the C code, which will make it quite hard to customise for end users and tedious to maintain in the long term. I couldn't really get my head around a better solution, so feel free to suggest alternative approaches.
A thought I had after reading over 8/9 in the series was, could we try something like:
- In C, loop over everything in w1 and set environment variables based on each thing we find.
- In aCONFIG_PREBOOTload a U-Boot shell script in that will look for the right env variables to be set for a given DIP and then do whatever is needed to load in the overlay.
Quoted 1 line
Does that make sense?
I thought about an environment-based solution too, but I was pretty worried about its scalability. But I guesse that's also the easiest thing to modify by end-users.
However, we have basically, three things to do (so far)
1) Modify the U-Boot environment before the display is initialized
2) Modify the kernel command line
3) Apply an overlay
I think CONFIG_PREBOOT is too late for 1, because the display is already initialized, and too early for 2 and 3, because the command line and DT will probably be set / loaded at bootcmd time.
I think we can decouple 1 and 2 from 3, since doing 2 too early is not an issue, because we might have boards that require to load some overlay but wouldn't need to make environment modifications (like an MMC DIP), or the other way around (even though I fail to see a use case for that at the moment).
So we're left with basically two things:
- Do a bunch of modifications in the environment early
- And apply the overlay very late (basically right before booting the kernel)
So we could do something like having an environment script called dip-<vid>-<pid>-setup called when a DIP is detected (if it exists), and keep the DT overlay logic in its current form.
What do you think?
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 801 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161109/11bba8a8/attachment.sig>
cover sunxi: chip: Enable the DIP auto-detection
Quoted 20 lines · Maxime Ripard
Hi Tom,
Quoted 17 lines · Tom Rini
On Tue, Nov 08, 2016 at 11:19:20AM +0100, Maxime Ripard wrote:
[snip]
Quoted 5 lines
I think the biggest drawback at the moment is that we maintain a list of DIPs and the actions needed directly into the C code, which will make it quite hard to customise for end users and tedious to maintain in the long term. I couldn't really get my head around a better solution, so feel free to suggest alternative approaches.
A thought I had after reading over 8/9 in the series was, could we try something like:
- In C, loop over everything in w1 and set environment variables based on each thing we find.
- In aCONFIG_PREBOOTload a U-Boot shell script in that will look for the right env variables to be set for a given DIP and then do whatever is needed to load in the overlay.
Quoted 5 lines
Quoted 1 line
Does that make sense?
I thought about an environment-based solution too, but I was pretty worried about its scalability. But I guesse that's also the easiest thing to modify by end-users.
Yeah, I share that concern too. But it's also the "easy" one in terms of debug and test too.
Quoted 8 lines
However, we have basically, three things to do (so far)
1) Modify the U-Boot environment before the display is initialized
2) Modify the kernel command line
3) Apply an overlayI think
CONFIG_PREBOOTis too late for 1, because the display is already initialized, and too early for 2 and 3, because the command line and DT will probably be set / loaded at bootcmd time.
Something I honestly wonder about at times is, would it not be better to optimize the default case such that the kernel is up and dealing with the display ASAP? If we go from power-on to Kernel is up and has thrown something on-screen in a few seconds, do we really need a complex solution so that it's up 1 or 2 seconds sooner?
Quoted 5 lines
I think we can decouple 1 and 2 from 3, since doing 2 too early is not an issue, because we might have boards that require to load some overlay but wouldn't need to make environment modifications (like an MMC DIP), or the other way around (even though I fail to see a use case for that at the moment).
OK.
Quoted 10 lines
So we're left with basically two things:
- Do a bunch of modifications in the environment early
- And apply the overlay very late (basically right before booting the kernel)So we could do something like having an environment script called dip-<vid>-<pid>-setup called when a DIP is detected (if it exists), and keep the DT overlay logic in its current form.
What do you think?
I think that might work. I think we really want to avoid having modify U-Boot to add a new DIP, so if we can move things to the point of "Here's your DIP and here's a link to the file you install $here on your board and it just works" we'll be in a good spot.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161111/066c5a79/attachment.sig>
cover sunxi: chip: Enable the DIP auto-detection
In reply to Maxime RipardHi,
Quoted 31 lines · Maxime Ripard
The NextThing's C.H.I.P. can have expansion boards called DIPs. Those DIPs are connected through the external headers, and comes with an identification mechanism based on 1-Wire EEPROMs.
That auto-detection works great, because 1-Wire allows the enumeration, and the EEPROMs are guaranteed to have different addresses, which allows us to stack as many DIPs as possible, without any constraints.
Since those DIPs can be close to anything, ranging from a simple PWM-based buzzer to a full featured device such as the PocketCHIP (which comes with a touchscreen, a keyboard, a battery, etc), some adjustments might be needed in U-Boot to be able to present something that just works to the user.
In particular, we need to:
- Apply an overlay if the device is something that should be dealt with early in the boot process (display, storage device)
- Adjust the U-Boot environment if the DIP has a display to change the default video output
- Adjust the kernel command line in previous case for Linux to have the same defaultIn order to achieve that, we introduced some logic optionally hooked into the sunxi board, two new uclasses for 1-Wire and EEPROMs, and a bunch of new environment variables:
- dip-auto-video to control the automatic video set up (default to yes)
-dip_overlay_cmdthat is a script to load the overlay $dip_overlay_name to $dip_addr_r, from whatever place it was stored in, and later apply it.
-kernelarg_videoto host the default kernel output in the kernel command line
Quoted 7 lines
I think the biggest drawback at the moment is that we maintain a list of DIPs and the actions needed directly into the C code, which will make it quite hard to customise for end users and tedious to maintain in the long term. I couldn't really get my head around a better solution, so feel free to suggest alternative approaches.
Let me know what you think,
The sunxi specific bits look fine to me. I will leave reviewing of the uclass bits to Simon.
Regards,
Hans