sandbox: add gpio support with libftdi1
v3 cover sandbox: add gpio support with libftdi1
This patch series makes it possible to use FT2232H ACBUS[7:0] pins as gpio pins from sandbox barebox.
There are ready-to-use FT2232H-based boards:
* FT2232H-56Q Mini-Module (http://www.ftdichip.com/Products/Modules/DevelopmentModules.htm#FT2232H-56_Mini)
* FT2232 breakout board (http://dangerousprototypes.com/docs/FT2232_breakout_board)
The main goal of adding gpio functionality to sandbox barebox is using it for connecting real i2c and spi devices to sandbox barebox.
Sample dts-file for at24 i2c eeprom and at25 spi flash is included.
Changes since v2 patch series (http://lists.infradead.org/pipermail/barebox/2018-January/031887.html):
* ftdi USB IDs are moved to dts, parseopt_* functions are unused;
* dts stuff moved to sandbox-libftdi-example.dtsi;
* led example is added.
Changes since v1 patch series (http://lists.infradead.org/pipermail/barebox/2017-October/031306.html):
* rebase on top barebox v2017.12.0;
* ds1307 i2c rtc driver works fine (i2c-gpio,scl-output-only is used);
* parseopt_* functions are used for cmdline parsing.
Changes since RFC v1 patch series (http://lists.infradead.org/pipermail/barebox/2017-February/029106.html):
* rebase on top barebox v2017.10.0;
* libftdi cmdline options are added;
* device tree support is added.
Antony Pavlov (3):
sandbox: avoid symbol conflict for {open,read,close}dir
sandbox: add gpio support with libftdi1
sandbox: add i2c and spi libftdi1 bit-bang example
arch/sandbox/Kconfig | 1 + arch/sandbox/Makefile | 10 +- arch/sandbox/configs/sandbox_defconfig | 21 +++- arch/sandbox/dts/sandbox-libftdi-example.dtsi | 80 +++++++++++++ arch/sandbox/mach-sandbox/include/mach/linux.h | 12 ++ arch/sandbox/os/Makefile | 3 + arch/sandbox/os/ftdi.c | 154 +++++++++++++++++++++++++ drivers/gpio/Kconfig | 4 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-libftdi1.c | 137 ++++++++++++++++++++++ 10 files changed, 420 insertions(+), 3 deletions(-) create mode 100644 arch/sandbox/dts/sandbox-libftdi-example.dtsi create mode 100644 arch/sandbox/os/ftdi.c create mode 100644 drivers/gpio/gpio-libftdi1.c
Signature · 7 lines
2.15.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v3 1/3 sandbox: avoid symbol conflict for {open, read, close}dir
This fixes libusb's /dev/bus/usb directory scan.
--- arch/sandbox/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/sandbox/Makefile +3 -1
@@ -21,7 +21,9 @@ CFLAGS += -Dmalloc=barebox_malloc -Dcalloc=barebox_calloc \ -Dfputs=barebox_fputs -Dsetenv=barebox_setenv \ -Dgetenv=barebox_getenv -Dprintf=barebox_printf \ -Dglob=barebox_glob -Dglobfree=barebox_globfree \ - -Dioctl=barebox_ioctl -Dfstat=barebox_fstat + -Dioctl=barebox_ioctl -Dfstat=barebox_fstat \ + -Dopendir=barebox_opendir -Dreaddir=barebox_readdir \ + -Dclosedir=barebox_closedir machdirs := $(patsubst %,arch/sandbox/mach-%/,$(machine-y))
Signature · 7 lines
2.15.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v3 2/3 sandbox: add gpio support with libftdi1
In reply to Antony Pavlov--- arch/sandbox/Kconfig | 1 + arch/sandbox/Makefile | 6 +- arch/sandbox/mach-sandbox/include/mach/linux.h | 12 ++ arch/sandbox/os/Makefile | 3 + arch/sandbox/os/ftdi.c | 154 +++++++++++++++++++++++++ drivers/gpio/Kconfig | 4 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-libftdi1.c | 137 ++++++++++++++++++++++ 8 files changed, 317 insertions(+), 1 deletion(-)
arch/sandbox/Kconfig +1 -0
@@ -1,6 +1,7 @@ config SANDBOX bool select OFTREE + select GPIOLIB default y config ARCH_TEXT_BASE
arch/sandbox/Makefile +5 -1
@@ -41,9 +41,13 @@ ifeq ($(CONFIG_DRIVER_VIDEO_SDL),y) SDL_LIBS := $(shell pkg-config sdl --libs) endif +ifeq ($(CONFIG_GPIO_LIBFTDI1),y) +FTDI1_LIBS := $(shell pkg-config libftdi1 --libs) +endif + cmd_barebox__ = $(CC) -o $@ -Wl,-T,$(barebox-lds) \ -Wl,--start-group $(barebox-common) -Wl,--end-group \ - -lrt -lpthread $(SDL_LIBS) + -lrt -lpthread $(SDL_LIBS) $(FTDI1_LIBS) common-y += $(BOARD) arch/sandbox/os/
arch/sandbox/mach-sandbox/include/mach/linux.h +12 -0
@@ -38,4 +38,16 @@ void sdl_get_bitfield_rgba(struct fb_bitfield *r, struct fb_bitfield *g, struct fb_bitfield *b, struct fb_bitfield *a);void sdl_setpixel (int x,int y,uint8_t r,uint8_t g,uint8_t b,uint8_t a); +struct ft2232_bitbang ; +struct ft2232_bitbang *barebox_libftdi1_open (int vendor_id,int device_id, +const char *serial); +void barebox_libftdi1_gpio_direction (struct ft2232_bitbang *ftbb, +unsigned off,unsigned dir); +int barebox_libftdi1_gpio_get_value (struct ft2232_bitbang *ftbb, +unsigned off); +void barebox_libftdi1_gpio_set_value (struct ft2232_bitbang *ftbb, +unsigned off,unsigned val); +int barebox_libftdi1_update (struct ft2232_bitbang *ftbb); +void barebox_libftdi1_close (void ); +#endif /* __ASM_ARCH_LINUX_H */
arch/sandbox/os/Makefile +3 -0
@@ -17,3 +17,6 @@ obj-y = common.o tap.o CFLAGS_sdl.o = $(shell pkg-config sdl --cflags) obj-$(CONFIG_DRIVER_VIDEO_SDL) += sdl.o + +CFLAGS_ftdi.o = $(shell pkg-config libftdi1 --cflags) +obj-$(CONFIG_GPIO_LIBFTDI1) += ftdi.o
arch/sandbox/os/ftdi.c new file +154 -0
154 lines not on this page · raw message
drivers/gpio/Kconfig +4 -0
@@ -132,6 +132,10 @@ config GPIO_SX150X Say Y here to build support for the Semtec Sx150x I2C GPIO expander chip. +config GPIO_LIBFTDI1 + bool "libftdi1 driver" + depends on SANDBOX + endmenu endif
drivers/gpio/Makefile +1 -0
@@ -8,6 +8,7 @@ obj-$(CONFIG_GPIO_CLPS711X) += gpio-clps711x.o obj-$(CONFIG_GPIO_DIGIC) += gpio-digic.o obj-$(CONFIG_GPIO_GENERIC) += gpio-generic.o obj-$(CONFIG_GPIO_IMX) += gpio-imx.o +obj-$(CONFIG_GPIO_LIBFTDI1) += gpio-libftdi1.o obj-$(CONFIG_GPIO_MXS) += gpio-mxs.o obj-$(CONFIG_GPIO_JZ4740) += gpio-jz4740.o obj-$(CONFIG_GPIO_MALTA_FPGA_I2C) += gpio-malta-fpga-i2c.o
drivers/gpio/gpio-libftdi1.c new file +137 -0
137 lines not on this page · raw message
Signature · 7 lines
2.15.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v3 3/3 sandbox: add i2c and spi libftdi1 bit-bang example
In reply to Antony PavlovMake necessary changes in sandbox_defconfig:
enable gpio, spi, i2c and led stuff.
Usage:
barebox$ make sandbox_defconfig
barebox$ sed -i "s/# CONFIG_GPIO_LIBFTDI1.*$/CONFIG_GPIO_LIBFTDI1=y/" .config
# edit arch/sandbox/dts/sandbox-libftdi-example.dtsi
barebox$ echo '#include "sandbox-libftdi-example.dtsi"' >> arch/sandbox/dts/sandbox.dts barebox$ make
barebox$ sudo ./barebox -d arch/sandbox/dts/sandbox.dtb
--- arch/sandbox/configs/sandbox_defconfig | 21 ++++++- arch/sandbox/dts/sandbox-libftdi-example.dtsi | 80 +++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 1 deletion(-)
arch/sandbox/configs/sandbox_defconfig +20 -1
@@ -53,6 +53,11 @@ CONFIG_CMD_CRC_CMP=y CONFIG_CMD_MM=y CONFIG_CMD_DETECT=y CONFIG_CMD_FLASH=y +CONFIG_CMD_GPIO=y +CONFIG_CMD_I2C=y +CONFIG_CMD_LED=y +CONFIG_CMD_SPI=y +CONFIG_CMD_LED_TRIGGER=y CONFIG_CMD_2048=y CONFIG_CMD_OF_NODE=y CONFIG_CMD_OF_PROPERTY=y
@@ -66,10 +71,24 @@ CONFIG_NET_NETCONSOLE=y CONFIG_OFDEVICE=y CONFIG_OF_BAREBOX_DRIVERS=y CONFIG_DRIVER_NET_TAP=y -# CONFIG_SPI is not set +CONFIG_DRIVER_SPI_GPIO=y +CONFIG_I2C=y +CONFIG_I2C_GPIO=y +CONFIG_MTD=y +CONFIG_MTD_M25P80=y CONFIG_VIDEO=y CONFIG_FRAMEBUFFER_CONSOLE=y +CONFIG_LED=y +CONFIG_LED_GPIO=y +CONFIG_LED_GPIO_OF=y +CONFIG_LED_GPIO_RGB=y +CONFIG_LED_GPIO_BICOLOR=y +CONFIG_LED_TRIGGERS=y +CONFIG_EEPROM_AT25=y +CONFIG_EEPROM_AT24=y # CONFIG_PINCTRL is not set +CONFIG_RTC_CLASS=y +CONFIG_RTC_DRV_DS1307=y CONFIG_FS_CRAMFS=y CONFIG_FS_EXT4=y CONFIG_FS_TFTP=y
arch/sandbox/dts/sandbox-libftdi-example.dtsi new file +80 -0
80 lines not on this page · raw message
Signature · 7 lines
2.15.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
On Mon, 22 Jan 2018 12:59:15 +0300
Antony Pavlov <[email protected]> wrote:
Sascha!
Please review this patch series.
Quoted 54 lines
This patch series makes it possible to use FT2232H ACBUS[7:0] pins as gpio pins from sandbox barebox.
There are ready-to-use FT2232H-based boards:
* FT2232H-56Q Mini-Module (http://www.ftdichip.com/Products/Modules/DevelopmentModules.htm#FT2232H-56_Mini)
* FT2232 breakout board (http://dangerousprototypes.com/docs/FT2232_breakout_board)The main goal of adding gpio functionality to sandbox barebox is using it for connecting real i2c and spi devices to sandbox barebox.
Sample dts-file for at24 i2c eeprom and at25 spi flash is included.
Changes since v2 patch series (http://lists.infradead.org/pipermail/barebox/2018-January/031887.html):
* ftdi USB IDs are moved to dts, parseopt_* functions are unused;
* dts stuff moved tosandbox-libftdi-example.dtsi;
* led example is added.Changes since v1 patch series (http://lists.infradead.org/pipermail/barebox/2017-October/031306.html):
* rebase on top barebox v2017.12.0;
* ds1307 i2c rtc driver works fine (i2c-gpio,scl-output-only is used);
* parseopt_* functions are used for cmdline parsing.Changes since RFC v1 patch series (http://lists.infradead.org/pipermail/barebox/2017-February/029106.html):
* rebase on top barebox v2017.10.0;
* libftdi cmdline options are added;
* device tree support is added.Antony Pavlov (3):
sandbox: avoid symbol conflict for {open,read,close}dir
sandbox: add gpio support with libftdi1
sandbox: add i2c and spi libftdi1 bit-bang examplearch/sandbox/Kconfig | 1 + arch/sandbox/Makefile | 10 +- arch/sandbox/configs/sandbox_defconfig | 21 +++- arch/sandbox/dts/sandbox-libftdi-example.dtsi | 80 +++++++++++++ arch/sandbox/mach-sandbox/include/mach/linux.h | 12 ++ arch/sandbox/os/Makefile | 3 + arch/sandbox/os/ftdi.c | 154 +++++++++++++++++++++++++ drivers/gpio/Kconfig | 4 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-libftdi1.c | 137 ++++++++++++++++++++++ 10 files changed, 420 insertions(+), 3 deletions(-) create mode 100644 arch/sandbox/dts/sandbox-libftdi-example.dtsi create mode 100644 arch/sandbox/os/ftdi.c create mode 100644 drivers/gpio/gpio-libftdi1.cSignature · 1 line
2.15.1
Signature · 7 lines
Best regards, Antony Pavlov _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v3 3/3] sandbox: add i2c and spi libftdi1 bit-bang example
In reply to Antony PavlovQuoted 47 lines · Antony Pavlov
Make necessary changes in
sandbox_defconfig:
enable gpio, spi, i2c and led stuff.Usage:
barebox$ make
sandbox_defconfig
barebox$ sed -i "s/# CONFIG_GPIO_LIBFTDI1.*$/CONFIG_GPIO_LIBFTDI1=y/" .config# edit arch/sandbox/dts/sandbox-libftdi-example.dtsibarebox$ echo '#include "
sandbox-libftdi-example.dtsi"' >>arch/sandbox/dts/sandbox.dtsbarebox$ make
barebox$ sudo ./barebox -darch/sandbox/dts/sandbox.dtbSigned-off-by Antony Pavlov <[email protected]>--- arch/sandbox/configs/sandbox_defconfig | 21 ++++++- arch/sandbox/dts/sandbox-libftdi-example.dtsi | 80 +++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 1 deletion(-)+++
b/arch/sandbox/dts/sandbox-libftdi-example.dtsiarch/sandbox/dts/sandbox-libftdi-example.dtsi new file +25
-0@@ -0,0 +1,80 @@ +#include <dt-bindings/gpio/gpio.h> + +/ { + gpio0: gpio@0 { + compatible = "barebox,libftdi1-gpio"; + usb,id_vendor = <0x0403>; + usb,id_product = <0x6010>; + + /* + * The serial number can be used to select + * a specific device in case more than + * one is connected to the host. + */ + /* usb,i_serial_number = "20180120"; */ + + /* use ACBUS[7:0] */ + gpio-controller; + #gpio-cells = <2>; + + status = "okay"; + }; + + spi0: spi0 { + compatible = "spi-gpio"; + #address-cells = <1>;
arch/sandbox/dts/sandbox-libftdi-example.dtsi line 35
Quoted 10 lines
arch/sandbox/dts/sandbox-libftdi-example.dtsi new file +10
-0+ #size-cells = <0>; + + gpio-sck = <&gpio0 0 GPIO_ACTIVE_HIGH>; + gpio-mosi = <&gpio0 1 GPIO_ACTIVE_HIGH>; + gpio-miso = <&gpio0 2 GPIO_ACTIVE_HIGH>; + cs-gpios = <&gpio0 3 GPIO_ACTIVE_HIGH>; + + num-chipselects = <1>; + + status = "disabled";
Given that this is an example which is not used unless you include it manually I think you can remove the status properties.
Otherwise this series looks fine to me. I can remove the properties while applying if you like.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v3 3/3] sandbox: add i2c and spi libftdi1 bit-bang example
Quoted 62 lines · On Thu, 25 Jan 2018 08:12:36 +0100 Sascha Hauer <[email protected]> wrote:
Quoted 47 lines · Antony Pavlov
Make necessary changes in
sandbox_defconfig:
enable gpio, spi, i2c and led stuff.Usage:
barebox$ make
sandbox_defconfig
barebox$ sed -i "s/# CONFIG_GPIO_LIBFTDI1.*$/CONFIG_GPIO_LIBFTDI1=y/" .config# edit arch/sandbox/dts/sandbox-libftdi-example.dtsibarebox$ echo '#include "
sandbox-libftdi-example.dtsi"' >>arch/sandbox/dts/sandbox.dtsbarebox$ make
barebox$ sudo ./barebox -darch/sandbox/dts/sandbox.dtbSigned-off-by Antony Pavlov <[email protected]>--- arch/sandbox/configs/sandbox_defconfig | 21 ++++++- arch/sandbox/dts/sandbox-libftdi-example.dtsi | 80 +++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 1 deletion(-)+++
b/arch/sandbox/dts/sandbox-libftdi-example.dtsiarch/sandbox/dts/sandbox-libftdi-example.dtsi new file +25
-0@@ -0,0 +1,80 @@ +#include <dt-bindings/gpio/gpio.h> + +/ { + gpio0: gpio@0 { + compatible = "barebox,libftdi1-gpio"; + usb,id_vendor = <0x0403>; + usb,id_product = <0x6010>; + + /* + * The serial number can be used to select + * a specific device in case more than + * one is connected to the host. + */ + /* usb,i_serial_number = "20180120"; */ + + /* use ACBUS[7:0] */ + gpio-controller; + #gpio-cells = <2>; + + status = "okay"; + }; + + spi0: spi0 { + compatible = "spi-gpio"; + #address-cells = <1>;arch/sandbox/dts/sandbox-libftdi-example.dtsi line 35
Quoted 10 lines
arch/sandbox/dts/sandbox-libftdi-example.dtsi new file +10
-0+ #size-cells = <0>; + + gpio-sck = <&gpio0 0 GPIO_ACTIVE_HIGH>; + gpio-mosi = <&gpio0 1 GPIO_ACTIVE_HIGH>; + gpio-miso = <&gpio0 2 GPIO_ACTIVE_HIGH>; + cs-gpios = <&gpio0 3 GPIO_ACTIVE_HIGH>; + + num-chipselects = <1>; + + status = "disabled";Given that this is an example which is not used unless you include it manually I think you can remove the status properties.
Quoted 2 lines
Otherwise this series looks fine to me. I can remove the properties while applying if you like.
Without status properties this file will be more fail-safe. Please remove the properties and apply the patches.
Please note that this patcheseries does not use parseopt_*() functions so nobody uses the commit 'parseopt: introduce parseopt_u16() and parseopt_str()'.
Signature · 7 lines
Best regards, Antony Pavlov _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v3 3/3] sandbox: add i2c and spi libftdi1 bit-bang example
Quoted 65 lines · Antony Pavlov
Quoted 62 lines · On Thu, 25 Jan 2018 08:12:36 +0100 Sascha Hauer <[email protected]> wrote:
Quoted 47 lines · Antony Pavlov
Make necessary changes in
sandbox_defconfig:
enable gpio, spi, i2c and led stuff.Usage:
barebox$ make
sandbox_defconfig
barebox$ sed -i "s/# CONFIG_GPIO_LIBFTDI1.*$/CONFIG_GPIO_LIBFTDI1=y/" .config# edit arch/sandbox/dts/sandbox-libftdi-example.dtsibarebox$ echo '#include "
sandbox-libftdi-example.dtsi"' >>arch/sandbox/dts/sandbox.dtsbarebox$ make
barebox$ sudo ./barebox -darch/sandbox/dts/sandbox.dtbSigned-off-by Antony Pavlov <[email protected]>--- arch/sandbox/configs/sandbox_defconfig | 21 ++++++- arch/sandbox/dts/sandbox-libftdi-example.dtsi | 80 +++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 1 deletion(-)+++
b/arch/sandbox/dts/sandbox-libftdi-example.dtsiarch/sandbox/dts/sandbox-libftdi-example.dtsi new file +25
-0@@ -0,0 +1,80 @@ +#include <dt-bindings/gpio/gpio.h> + +/ { + gpio0: gpio@0 { + compatible = "barebox,libftdi1-gpio"; + usb,id_vendor = <0x0403>; + usb,id_product = <0x6010>; + + /* + * The serial number can be used to select + * a specific device in case more than + * one is connected to the host. + */ + /* usb,i_serial_number = "20180120"; */ + + /* use ACBUS[7:0] */ + gpio-controller; + #gpio-cells = <2>; + + status = "okay"; + }; + + spi0: spi0 { + compatible = "spi-gpio"; + #address-cells = <1>;arch/sandbox/dts/sandbox-libftdi-example.dtsi line 35
Quoted 10 lines
arch/sandbox/dts/sandbox-libftdi-example.dtsi new file +10
-0+ #size-cells = <0>; + + gpio-sck = <&gpio0 0 GPIO_ACTIVE_HIGH>; + gpio-mosi = <&gpio0 1 GPIO_ACTIVE_HIGH>; + gpio-miso = <&gpio0 2 GPIO_ACTIVE_HIGH>; + cs-gpios = <&gpio0 3 GPIO_ACTIVE_HIGH>; + + num-chipselects = <1>; + + status = "disabled";Given that this is an example which is not used unless you include it manually I think you can remove the status properties.
Quoted 5 lines
Quoted 2 lines
Otherwise this series looks fine to me. I can remove the properties while applying if you like.
Without status properties this file will be more fail-safe. Please remove the properties and apply the patches.
Just did that.
Quoted 3 lines
Please note that this patcheseries does not use parseopt_*() functions so nobody uses the commit 'parseopt: introduce
parseopt_u16()andparseopt_str()'.
That's fine. At least for parseopt_str() it probably won't take long to find a user.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox