* [RFC 0/2] sandbox: add gpio support with libftdi1 @ 2017-02-15 7:12 Antony Pavlov 2017-02-15 7:12 ` [RFC 1/2] sandbox: avoid symbol conflict for {open,read,close}dir Antony Pavlov ` (2 more replies) 0 siblings, 3 replies; 7+ messages in thread From: Antony Pavlov @ 2017-02-15 7:12 UTC (permalink / raw) To: barebox This patch series makes it possible to use FT2232H ACBUS[7:0] pins as gpio pins from sandbox barebox. I have tested output gpio functionality by connecting a LED to ACBUS[0] and lightening it with gpio_direction_output and gpio_set_value barebox commands. Also I have performed input test with ACBUS[0] -> ACBUS[1] loopback. The main goal of adding gpio functionality to sandbox barebox is using it for connecting real i2c and spi devices to sandbox barebox (not tested yet). Antony Pavlov (2): sandbox: avoid symbol conflict for {open,read,close}dir sandbox: add gpio support with libftdi1 arch/sandbox/Kconfig | 1 + arch/sandbox/Makefile | 10 +- arch/sandbox/board/board.c | 7 ++ arch/sandbox/mach-sandbox/include/mach/linux.h | 11 ++ arch/sandbox/os/Makefile | 3 + arch/sandbox/os/ftdi.c | 167 +++++++++++++++++++++++++ drivers/gpio/Kconfig | 4 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-libftdi1.c | 116 +++++++++++++++++ 9 files changed, 318 insertions(+), 2 deletions(-) create mode 100644 arch/sandbox/os/ftdi.c create mode 100644 drivers/gpio/gpio-libftdi1.c -- 2.11.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 7+ messages in thread
* [RFC 1/2] sandbox: avoid symbol conflict for {open,read,close}dir 2017-02-15 7:12 [RFC 0/2] sandbox: add gpio support with libftdi1 Antony Pavlov @ 2017-02-15 7:12 ` Antony Pavlov 2017-02-15 7:12 ` [RFC 2/2] sandbox: add gpio support with libftdi1 Antony Pavlov 2017-02-16 7:34 ` [RFC 0/2] " Sascha Hauer 2 siblings, 0 replies; 7+ messages in thread From: Antony Pavlov @ 2017-02-15 7:12 UTC (permalink / raw) To: barebox This fixes libusb's /dev/bus/usb directory scan. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> --- arch/sandbox/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/sandbox/Makefile b/arch/sandbox/Makefile index 8155a790e..9d545c3b7 100644 --- a/arch/sandbox/Makefile +++ b/arch/sandbox/Makefile @@ -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)) -- 2.11.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 7+ messages in thread
* [RFC 2/2] sandbox: add gpio support with libftdi1 2017-02-15 7:12 [RFC 0/2] sandbox: add gpio support with libftdi1 Antony Pavlov 2017-02-15 7:12 ` [RFC 1/2] sandbox: avoid symbol conflict for {open,read,close}dir Antony Pavlov @ 2017-02-15 7:12 ` Antony Pavlov 2017-02-16 7:34 ` [RFC 0/2] " Sascha Hauer 2 siblings, 0 replies; 7+ messages in thread From: Antony Pavlov @ 2017-02-15 7:12 UTC (permalink / raw) To: barebox Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> --- arch/sandbox/Kconfig | 1 + arch/sandbox/Makefile | 6 +- arch/sandbox/board/board.c | 7 ++ arch/sandbox/mach-sandbox/include/mach/linux.h | 11 ++ arch/sandbox/os/Makefile | 3 + arch/sandbox/os/ftdi.c | 167 +++++++++++++++++++++++++ drivers/gpio/Kconfig | 4 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-libftdi1.c | 116 +++++++++++++++++ 9 files changed, 315 insertions(+), 1 deletion(-) diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig index 9c72673bd..3f1cefb83 100644 --- a/arch/sandbox/Kconfig +++ b/arch/sandbox/Kconfig @@ -1,6 +1,7 @@ config SANDBOX bool select OFTREE + select GPIOLIB default y config ARCH_TEXT_BASE diff --git a/arch/sandbox/Makefile b/arch/sandbox/Makefile index 9d545c3b7..85c70b5e8 100644 --- a/arch/sandbox/Makefile +++ b/arch/sandbox/Makefile @@ -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/ diff --git a/arch/sandbox/board/board.c b/arch/sandbox/board/board.c index dcad3c249..5ab47e21c 100644 --- a/arch/sandbox/board/board.c +++ b/arch/sandbox/board/board.c @@ -42,6 +42,11 @@ static struct device_d sdl_device = { .platform_data = &mode, }; +static struct device_d libftdi1_device = { + .id = DEVICE_ID_DYNAMIC, + .name = "libftdi1-gpio", +}; + static int devices_init(void) { platform_device_register(&tap_device); @@ -54,6 +59,8 @@ static int devices_init(void) platform_device_register(&sdl_device); + platform_device_register(&libftdi1_device); + return 0; } diff --git a/arch/sandbox/mach-sandbox/include/mach/linux.h b/arch/sandbox/mach-sandbox/include/mach/linux.h index 1f11ed449..e52180ae4 100644 --- a/arch/sandbox/mach-sandbox/include/mach/linux.h +++ b/arch/sandbox/mach-sandbox/include/mach/linux.h @@ -38,4 +38,15 @@ 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(void); +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 */ diff --git a/arch/sandbox/os/Makefile b/arch/sandbox/os/Makefile index 537f848e0..75baa34a8 100644 --- a/arch/sandbox/os/Makefile +++ b/arch/sandbox/os/Makefile @@ -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 diff --git a/arch/sandbox/os/ftdi.c b/arch/sandbox/os/ftdi.c new file mode 100644 index 000000000..b37903dd5 --- /dev/null +++ b/arch/sandbox/os/ftdi.c @@ -0,0 +1,167 @@ +/* + * sandbox barebox libftdi1 support + * + * Copyright (C) 2016, 2017 Antony Pavlov <antonynpavlov@gmail.com> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <ftdi.h> +#include <errno.h> +#include <mach/linux.h> + +#define GPIOF_DIR_OUT (0 << 0) +#define GPIOF_DIR_IN (1 << 0) + +#define BIT(nr) (1UL << (nr)) + +struct ft2232_bitbang { + struct ftdi_context *ftdi; + uint8_t odata; + uint8_t dir; +}; + +static struct ft2232_bitbang ftbb; + +static inline int ftdi_flush(struct ftdi_context *ftdi) +{ + uint8_t buf[1]; + int ret; + + buf[0] = SEND_IMMEDIATE; + + ret = ftdi_write_data(ftdi, buf, 1); + + return ret; +} + +static int ftdi_get_high_byte_data(struct ftdi_context *ftdi, uint8_t *data) +{ + uint8_t obuf; + int ret; + + obuf = GET_BITS_HIGH; + ret = ftdi_write_data(ftdi, &obuf, 1); + + ret = ftdi_read_data(ftdi, data, 1); + + return ret; +} + +static int ftdi_set_high_byte_data_dir(struct ft2232_bitbang *ftbb) +{ + uint8_t buf[3]; + int ret; + + buf[0] = SET_BITS_HIGH; + buf[1] = ftbb->odata; + buf[2] = ftbb->dir; + + ret = ftdi_write_data(ftbb->ftdi, buf, 3); + ftdi_flush(ftbb->ftdi); + + return ret; +} + +int barebox_libftdi1_update(struct ft2232_bitbang *ftbb) +{ + return ftdi_set_high_byte_data_dir(ftbb); +} + +void barebox_libftdi1_gpio_direction(struct ft2232_bitbang *ftbb, + unsigned off, unsigned dir) +{ + switch (dir) { + case GPIOF_DIR_IN: + ftbb->dir &= ~BIT(off); + break; + case GPIOF_DIR_OUT: + ftbb->dir |= BIT(off); + break; + default: + printf("%s:%d: invalid dir argument\n", __FILE__, __LINE__); + } +} + +int barebox_libftdi1_gpio_get_value(struct ft2232_bitbang *ftbb, unsigned off) +{ + uint8_t data; + + ftdi_get_high_byte_data(ftbb->ftdi, &data); + + return !!(data & BIT(off)); +} + +void barebox_libftdi1_gpio_set_value(struct ft2232_bitbang *ftbb, + unsigned off, unsigned val) +{ + if (val) + ftbb->odata |= BIT(off); + else + ftbb->odata &= ~BIT(off); +} + +int barebox_libftdi1_init(void) +{ + struct ftdi_context *ftdi; + int ret; + + ftdi = ftdi_new(); + if (!ftdi) { + fprintf(stderr, "ftdi_new failed\n"); + goto error; + } + + ret = ftdi_usb_open(ftdi, 0x0403, 0x6010); + if (ret < 0 && ret != -5) { + fprintf(stderr, "unable to open ftdi device: %d (%s)\n", + ret, ftdi_get_error_string(ftdi)); + goto error; + } + + ftdi_set_interface(ftdi, INTERFACE_A); + ftdi_set_bitmode(ftdi, 0x00, BITMODE_MPSSE); + + ftbb.ftdi = ftdi; + + /* reset pins to default neutral state */ + ftbb.dir = 0; + ftbb.odata = 0; + ftdi_set_high_byte_data_dir(&ftbb); + + return 0; + +error: + return -1; +} + +struct ft2232_bitbang *barebox_libftdi1_open(void) +{ + if (barebox_libftdi1_init() < 0) { + printf("Could not initialize ftdi\n"); + return NULL; + } + + return &ftbb; +} + +void barebox_libftdi1_close(void) +{ + struct ftdi_context *ftdi = ftbb.ftdi; + + ftdi_set_interface(ftdi, INTERFACE_ANY); + ftdi_usb_close(ftdi); + ftdi_free(ftdi); +} diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 434c5688b..ed93e868a 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -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 diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index f37dd08f1..f5ed876d5 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -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 diff --git a/drivers/gpio/gpio-libftdi1.c b/drivers/gpio/gpio-libftdi1.c new file mode 100644 index 000000000..1ceb78029 --- /dev/null +++ b/drivers/gpio/gpio-libftdi1.c @@ -0,0 +1,116 @@ +/* + * libftdi1 sandbox barebox GPIO driver + * + * Copyright (C) 2016, 2017 Antony Pavlov <antonynpavlov@gmail.com> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include <common.h> +#include <errno.h> +#include <gpio.h> +#include <init.h> +#include <malloc.h> +#include <mach/linux.h> + +struct libftdi1_gpio_chip { + struct gpio_chip chip; + struct ft2232_bitbang *ftbb; +}; + +static int libftdi1_gpio_direction_input(struct gpio_chip *chip, unsigned off) +{ + struct libftdi1_gpio_chip *gpio = + container_of(chip, struct libftdi1_gpio_chip, chip); + + barebox_libftdi1_gpio_direction(gpio->ftbb, off, GPIOF_DIR_IN); + barebox_libftdi1_update(gpio->ftbb); + + return 0; +} + +static int libftdi1_gpio_direction_output( + struct gpio_chip *chip, unsigned off, int value) +{ + struct libftdi1_gpio_chip *gpio = + container_of(chip, struct libftdi1_gpio_chip, chip); + + barebox_libftdi1_gpio_set_value(gpio->ftbb, off, value); + barebox_libftdi1_gpio_direction(gpio->ftbb, off, GPIOF_DIR_OUT); + barebox_libftdi1_update(gpio->ftbb); + + return 0; +} + +static int libftdi1_gpio_get_value(struct gpio_chip *chip, unsigned off) +{ + struct libftdi1_gpio_chip *gpio = + container_of(chip, struct libftdi1_gpio_chip, chip); + + return barebox_libftdi1_gpio_get_value(gpio->ftbb, off); +} + +static void libftdi1_gpio_set_value( + struct gpio_chip *chip, unsigned off, int value) +{ + struct libftdi1_gpio_chip *gpio = + container_of(chip, struct libftdi1_gpio_chip, chip); + + barebox_libftdi1_gpio_set_value(gpio->ftbb, off, value); + barebox_libftdi1_update(gpio->ftbb); +} + +static struct gpio_ops libftdi1_gpio_ops = { + .direction_input = libftdi1_gpio_direction_input, + .direction_output = libftdi1_gpio_direction_output, + .get = libftdi1_gpio_get_value, + .set = libftdi1_gpio_set_value, +}; + +static int libftdi1_gpio_probe(struct device_d *dev) +{ + struct libftdi1_gpio_chip *gpio; + struct ft2232_bitbang *ftbb; + int ret; + + ftbb = barebox_libftdi1_open(); + if (!ftbb) + return -EIO; + + gpio = xzalloc(sizeof(*gpio)); + + gpio->ftbb = ftbb; + + gpio->chip.dev = dev; + gpio->chip.ops = &libftdi1_gpio_ops; + gpio->chip.base = 0; + gpio->chip.ngpio = 8; + + ret = gpiochip_add(&gpio->chip); + + dev_dbg(dev, "%d: probed gpio%d with base %d\n", + ret, dev->id, gpio->chip.base); + + return 0; +} + +static void libftdi1_gpio_remove(struct device_d *dev) +{ + barebox_libftdi1_close(); +} + +static struct driver_d libftdi1_gpio_driver = { + .name = "libftdi1-gpio", + .probe = libftdi1_gpio_probe, + .remove = libftdi1_gpio_remove, +}; +device_platform_driver(libftdi1_gpio_driver); -- 2.11.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFC 0/2] sandbox: add gpio support with libftdi1 2017-02-15 7:12 [RFC 0/2] sandbox: add gpio support with libftdi1 Antony Pavlov 2017-02-15 7:12 ` [RFC 1/2] sandbox: avoid symbol conflict for {open,read,close}dir Antony Pavlov 2017-02-15 7:12 ` [RFC 2/2] sandbox: add gpio support with libftdi1 Antony Pavlov @ 2017-02-16 7:34 ` Sascha Hauer 2017-02-16 8:28 ` Antony Pavlov 2017-02-16 11:11 ` Ian Abbott 2 siblings, 2 replies; 7+ messages in thread From: Sascha Hauer @ 2017-02-16 7:34 UTC (permalink / raw) To: Antony Pavlov; +Cc: barebox Hi Antony, On Wed, Feb 15, 2017 at 10:12:25AM +0300, Antony Pavlov wrote: > This patch series makes it possible to use FT2232H ACBUS[7:0] > pins as gpio pins from sandbox barebox. > > I have tested output gpio functionality by connecting > a LED to ACBUS[0] and lightening it with gpio_direction_output > and gpio_set_value barebox commands. > > Also I have performed input test with ACBUS[0] -> ACBUS[1] loopback. > > The main goal of adding gpio functionality to sandbox barebox > is using it for connecting real i2c and spi devices to sandbox barebox > (not tested yet). I just read that the FT2232H can even do native I2C and SPI, so no gpio bitbanging would be necessary. Would it be possible to use this mode instead? Otherwise I think there should be a possibility to specify which, if any, FT2232H chip barebox uses. Sascha -- 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 barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFC 0/2] sandbox: add gpio support with libftdi1 2017-02-16 7:34 ` [RFC 0/2] " Sascha Hauer @ 2017-02-16 8:28 ` Antony Pavlov 2017-02-16 8:25 ` Sascha Hauer 2017-02-16 11:11 ` Ian Abbott 1 sibling, 1 reply; 7+ messages in thread From: Antony Pavlov @ 2017-02-16 8:28 UTC (permalink / raw) To: Sascha Hauer; +Cc: barebox On Thu, 16 Feb 2017 08:34:30 +0100 Sascha Hauer <s.hauer@pengutronix.de> wrote: > Hi Antony, > > On Wed, Feb 15, 2017 at 10:12:25AM +0300, Antony Pavlov wrote: > > This patch series makes it possible to use FT2232H ACBUS[7:0] > > pins as gpio pins from sandbox barebox. > > > > I have tested output gpio functionality by connecting > > a LED to ACBUS[0] and lightening it with gpio_direction_output > > and gpio_set_value barebox commands. > > > > Also I have performed input test with ACBUS[0] -> ACBUS[1] loopback. > > > > The main goal of adding gpio functionality to sandbox barebox > > is using it for connecting real i2c and spi devices to sandbox barebox > > (not tested yet). > > I just read that the FT2232H can even do native I2C and SPI, so no gpio > bitbanging would be necessary. I suppose that gpio support itself is valuable. > Would it be possible to use this mode instead? Yes, FT2232H has MPSSE acellerator. Using MPSSE one can increase FT2232 I2C/SPI performance dramatically. I have compared two FT2232 I2C realizations (bitbang and libmpsse, see https://github.com/frantony/mprog/tree/master/i2c_access). on reading of 8 KiB data block from I2C eeprom. libmpsse's bandwidth is 6 KiB per second, bitbang's bandwidth is only 73 bytes per second (nearly 100 times worse). Alas, I have no time to realize ftdi fast i2c/spi support for barebox in the nearest future > Otherwise I think there should be a possibility to specify which, if > any, FT2232H chip barebox uses. I'll add cmdline options to select FT2232H chips on USB bus in v2 patchseries. Also I'll check i2c bitbang support. I can connect ds1307 rtc or at24 eeprom). -- Best regards, Antony Pavlov _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFC 0/2] sandbox: add gpio support with libftdi1 2017-02-16 8:28 ` Antony Pavlov @ 2017-02-16 8:25 ` Sascha Hauer 0 siblings, 0 replies; 7+ messages in thread From: Sascha Hauer @ 2017-02-16 8:25 UTC (permalink / raw) To: Antony Pavlov; +Cc: barebox On Thu, Feb 16, 2017 at 11:28:35AM +0300, Antony Pavlov wrote: > On Thu, 16 Feb 2017 08:34:30 +0100 > Sascha Hauer <s.hauer@pengutronix.de> wrote: > > > Hi Antony, > > > > On Wed, Feb 15, 2017 at 10:12:25AM +0300, Antony Pavlov wrote: > > > This patch series makes it possible to use FT2232H ACBUS[7:0] > > > pins as gpio pins from sandbox barebox. > > > > > > I have tested output gpio functionality by connecting > > > a LED to ACBUS[0] and lightening it with gpio_direction_output > > > and gpio_set_value barebox commands. > > > > > > Also I have performed input test with ACBUS[0] -> ACBUS[1] loopback. > > > > > > The main goal of adding gpio functionality to sandbox barebox > > > is using it for connecting real i2c and spi devices to sandbox barebox > > > (not tested yet). > > > > I just read that the FT2232H can even do native I2C and SPI, so no gpio > > bitbanging would be necessary. > > I suppose that gpio support itself is valuable. > > > Would it be possible to use this mode instead? > > Yes, FT2232H has MPSSE acellerator. > Using MPSSE one can increase FT2232 I2C/SPI performance dramatically. > I have compared two FT2232 I2C realizations (bitbang and libmpsse, > see https://github.com/frantony/mprog/tree/master/i2c_access). > on reading of 8 KiB data block from I2C eeprom. libmpsse's bandwidth is 6 KiB per second, > bitbang's bandwidth is only 73 bytes per second (nearly 100 times worse). > > Alas, I have no time to realize ftdi fast i2c/spi support for barebox in the nearest future Don't worry, I was only curious. > > > Otherwise I think there should be a possibility to specify which, if > > any, FT2232H chip barebox uses. > > I'll add cmdline options to select FT2232H chips on USB bus in v2 patchseries. > Also I'll check i2c bitbang support. I can connect ds1307 rtc or at24 eeprom). Ok. Sascha -- 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 barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFC 0/2] sandbox: add gpio support with libftdi1 2017-02-16 7:34 ` [RFC 0/2] " Sascha Hauer 2017-02-16 8:28 ` Antony Pavlov @ 2017-02-16 11:11 ` Ian Abbott 1 sibling, 0 replies; 7+ messages in thread From: Ian Abbott @ 2017-02-16 11:11 UTC (permalink / raw) To: Sascha Hauer, Antony Pavlov; +Cc: barebox On 16/02/17 07:34, Sascha Hauer wrote: > Hi Antony, > > On Wed, Feb 15, 2017 at 10:12:25AM +0300, Antony Pavlov wrote: >> This patch series makes it possible to use FT2232H ACBUS[7:0] >> pins as gpio pins from sandbox barebox. >> >> I have tested output gpio functionality by connecting >> a LED to ACBUS[0] and lightening it with gpio_direction_output >> and gpio_set_value barebox commands. >> >> Also I have performed input test with ACBUS[0] -> ACBUS[1] loopback. >> >> The main goal of adding gpio functionality to sandbox barebox >> is using it for connecting real i2c and spi devices to sandbox barebox >> (not tested yet). > > I just read that the FT2232H can even do native I2C and SPI, so no gpio > bitbanging would be necessary. Would it be possible to use this mode > instead? > > Otherwise I think there should be a possibility to specify which, if > any, FT2232H chip barebox uses. The MPSSE mode of the FT2232H can sort of do native I2C, but not in a strictly conforming way. The I2C SDA needs to be connected to two pins on the FT2232H, one for output and one for input, and there is a "Drive-Only-Zero" option for the output to ensure it is only driven low, and tri-stated high. However, the I2C SCL is only connected to an output pin on the FT2232H, and is always driven in both directions. Therefore, it does not support "clock-stretching" by I2C slaves (where a slave pulls the SCL line low until it is ready), because it cannot read back the state of the SCL line. Worse, if an I2C slave is doing clock-stretching by driving SCL low, this will contend with the FT2232H driving SCL high at the same time. -- -=( Ian Abbott @ MEV Ltd. E-mail: <abbotti@mev.co.uk> )=- -=( Web: http://www.mev.co.uk/ )=- _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-02-16 11:11 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-02-15 7:12 [RFC 0/2] sandbox: add gpio support with libftdi1 Antony Pavlov 2017-02-15 7:12 ` [RFC 1/2] sandbox: avoid symbol conflict for {open,read,close}dir Antony Pavlov 2017-02-15 7:12 ` [RFC 2/2] sandbox: add gpio support with libftdi1 Antony Pavlov 2017-02-16 7:34 ` [RFC 0/2] " Sascha Hauer 2017-02-16 8:28 ` Antony Pavlov 2017-02-16 8:25 ` Sascha Hauer 2017-02-16 11:11 ` Ian Abbott
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox