* [PATCH v2 0/7] sandbox: add gpio support with libftdi1
@ 2018-01-14 21:22 Antony Pavlov
2018-01-14 21:22 ` [PATCH v2 1/7] sandbox: avoid symbol conflict for {open, read, close}dir Antony Pavlov
` (8 more replies)
0 siblings, 9 replies; 16+ messages in thread
From: Antony Pavlov @ 2018-01-14 21:22 UTC (permalink / raw)
To: barebox
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 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 (7):
sandbox: avoid symbol conflict for {open,read,close}dir
sandbox: add gpio support with libftdi1
sandbox: add i2c and spi libftdi1 bit-bang example
move parseopt to lib/
include/parseopt.h: add guard macro
parseopt: introduce parseopt_u16() and parseopt_str()
sandbox: parse libftdi options
arch/sandbox/Kconfig | 1 +
arch/sandbox/Makefile | 10 +-
arch/sandbox/configs/sandbox_defconfig | 26 +++-
arch/sandbox/dts/sandbox.dts | 52 +++++++
arch/sandbox/mach-sandbox/include/mach/linux.h | 11 ++
arch/sandbox/os/Makefile | 3 +
arch/sandbox/os/common.c | 12 +-
arch/sandbox/os/ftdi.c | 181 +++++++++++++++++++++++++
drivers/gpio/Kconfig | 4 +
drivers/gpio/Makefile | 1 +
drivers/gpio/gpio-libftdi1.c | 125 +++++++++++++++++
fs/Makefile | 2 +-
fs/fs.c | 3 +-
fs/nfs.c | 3 +-
fs/parseopt.c | 60 --------
fs/parseopt.h | 2 -
include/parseopt.h | 9 ++
lib/Makefile | 1 +
lib/parseopt.c | 124 +++++++++++++++++
19 files changed, 558 insertions(+), 72 deletions(-)
create mode 100644 arch/sandbox/os/ftdi.c
create mode 100644 drivers/gpio/gpio-libftdi1.c
delete mode 100644 fs/parseopt.c
delete mode 100644 fs/parseopt.h
create mode 100644 include/parseopt.h
create mode 100644 lib/parseopt.c
--
2.15.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v2 1/7] sandbox: avoid symbol conflict for {open, read, close}dir
2018-01-14 21:22 [PATCH v2 0/7] sandbox: add gpio support with libftdi1 Antony Pavlov
@ 2018-01-14 21:22 ` Antony Pavlov
2018-01-14 21:22 ` [PATCH v2 2/7] sandbox: add gpio support with libftdi1 Antony Pavlov
` (7 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Antony Pavlov @ 2018-01-14 21:22 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 8155a790eb..9d545c3b71 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.15.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v2 2/7] sandbox: add gpio support with libftdi1
2018-01-14 21:22 [PATCH v2 0/7] sandbox: add gpio support with libftdi1 Antony Pavlov
2018-01-14 21:22 ` [PATCH v2 1/7] sandbox: avoid symbol conflict for {open, read, close}dir Antony Pavlov
@ 2018-01-14 21:22 ` Antony Pavlov
2018-01-14 21:22 ` [PATCH v2 3/7] sandbox: add i2c and spi libftdi1 bit-bang example Antony Pavlov
` (6 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Antony Pavlov @ 2018-01-14 21:22 UTC (permalink / raw)
To: barebox
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
arch/sandbox/Kconfig | 1 +
arch/sandbox/Makefile | 6 +-
arch/sandbox/mach-sandbox/include/mach/linux.h | 11 ++
arch/sandbox/os/Makefile | 3 +
arch/sandbox/os/ftdi.c | 169 +++++++++++++++++++++++++
drivers/gpio/Kconfig | 4 +
drivers/gpio/Makefile | 1 +
drivers/gpio/gpio-libftdi1.c | 125 ++++++++++++++++++
8 files changed, 319 insertions(+), 1 deletion(-)
diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig
index 9c72673bde..3f1cefb837 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 9d545c3b71..85c70b5e80 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/mach-sandbox/include/mach/linux.h b/arch/sandbox/mach-sandbox/include/mach/linux.h
index 1327a56cab..9abb52e93c 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 537f848e06..75baa34a83 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 0000000000..7302dd0989
--- /dev/null
+++ b/arch/sandbox/os/ftdi.c
@@ -0,0 +1,169 @@
+/*
+ * 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 <ftdi.h>
+
+#define FTDI_VID 0x0403 /* Vendor Id */
+#define FTDI_8U2232C_PID 0x6010 /* Dual channel device */
+
+#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);
+}
+
+static int barebox_libftdi1_init(void)
+{
+ struct ftdi_context *ftdi;
+ int ret;
+ /* default FT2232 values */
+ uint16_t vendor_id = FTDI_VID;
+ uint16_t device_id = FTDI_8U2232C_PID;
+
+ ftdi = ftdi_new();
+ if (!ftdi) {
+ fprintf(stderr, "ftdi_new failed\n");
+ goto error;
+ }
+
+ ret = ftdi_usb_open(ftdi, vendor_id, device_id);
+ 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 434c5688b4..ed93e868ae 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 f37dd08f1a..f5ed876d5e 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 0000000000..21fc8cf034
--- /dev/null
+++ b/drivers/gpio/gpio-libftdi1.c
@@ -0,0 +1,125 @@
+/*
+ * 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 __maybe_unused const struct of_device_id libftdi1_gpio_dt_ids[] = {
+ {
+ .compatible = "barebox,libftdi1-gpio",
+ }, {
+ /* sentinel */
+ },
+};
+
+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,
+ .of_compatible = DRV_OF_COMPAT(libftdi1_gpio_dt_ids),
+};
+device_platform_driver(libftdi1_gpio_driver);
--
2.15.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v2 3/7] sandbox: add i2c and spi libftdi1 bit-bang example
2018-01-14 21:22 [PATCH v2 0/7] sandbox: add gpio support with libftdi1 Antony Pavlov
2018-01-14 21:22 ` [PATCH v2 1/7] sandbox: avoid symbol conflict for {open, read, close}dir Antony Pavlov
2018-01-14 21:22 ` [PATCH v2 2/7] sandbox: add gpio support with libftdi1 Antony Pavlov
@ 2018-01-14 21:22 ` Antony Pavlov
2018-01-17 10:01 ` Sascha Hauer
2018-01-14 21:22 ` [PATCH v2 4/7] move parseopt to lib/ Antony Pavlov
` (5 subsequent siblings)
8 siblings, 1 reply; 16+ messages in thread
From: Antony Pavlov @ 2018-01-14 21:22 UTC (permalink / raw)
To: barebox
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.dts if necessary
barebox$ make
barebox$ sudo ./barebox -d arch/sandbox/dts/sandbox.dtb
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
arch/sandbox/configs/sandbox_defconfig | 26 ++++++++++++++++-
arch/sandbox/dts/sandbox.dts | 52 ++++++++++++++++++++++++++++++++++
2 files changed, 77 insertions(+), 1 deletion(-)
diff --git a/arch/sandbox/configs/sandbox_defconfig b/arch/sandbox/configs/sandbox_defconfig
index dbaff12bfb..6b10adb8ef 100644
--- a/arch/sandbox/configs/sandbox_defconfig
+++ b/arch/sandbox/configs/sandbox_defconfig
@@ -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,29 @@ 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_I2C_MUX=y
+CONFIG_I2C_MUX_PCA954x=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_GPIO_74164=y
+CONFIG_GPIO_PCA953X=y
+CONFIG_GPIO_SX150X=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
diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts
index 2595aa13fa..69568f6d7a 100644
--- a/arch/sandbox/dts/sandbox.dts
+++ b/arch/sandbox/dts/sandbox.dts
@@ -1,7 +1,59 @@
/dts-v1/;
#include "skeleton.dtsi"
+#include <dt-bindings/gpio/gpio.h>
/ {
+ gpio0: gpio@0 {
+ compatible = "barebox,libftdi1-gpio";
+ /* use ACBUS[7:0] */
+ gpio-controller;
+ #gpio-cells = <2>;
+ status = "okay";
+ };
+ spi0 {
+ compatible = "spi-gpio";
+ #address-cells = <1>;
+ #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";
+
+ m25p128@0 {
+ compatible = "m25p128", "jedec,spi-nor";
+ #address-cells = <1>;
+ #size-cells = <1>;
+ reg = <0>;
+ spi-max-frequency = <1000000>;
+ };
+ };
+
+ i2c0: i2c0 {
+ compatible = "i2c-gpio";
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ gpios = <&gpio0 4 GPIO_ACTIVE_HIGH /* sda */
+ &gpio0 5 GPIO_ACTIVE_HIGH /* scl */
+ >;
+ i2c-gpio,scl-output-only;
+
+ status = "disabled";
+
+ eeprom: at24@50 {
+ compatible = "atmel,24c32";
+ reg = <0x50>;
+ };
+
+ rtc: ds1307@68 {
+ compatible = "dallas,ds1307";
+ reg = <0x68>;
+ };
+ };
};
--
2.15.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v2 4/7] move parseopt to lib/
2018-01-14 21:22 [PATCH v2 0/7] sandbox: add gpio support with libftdi1 Antony Pavlov
` (2 preceding siblings ...)
2018-01-14 21:22 ` [PATCH v2 3/7] sandbox: add i2c and spi libftdi1 bit-bang example Antony Pavlov
@ 2018-01-14 21:22 ` Antony Pavlov
2018-01-14 21:22 ` [PATCH v2 5/7] include/parseopt.h: add guard macro Antony Pavlov
` (4 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Antony Pavlov @ 2018-01-14 21:22 UTC (permalink / raw)
To: barebox
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
fs/Makefile | 2 +-
fs/fs.c | 3 +--
fs/nfs.c | 3 +--
{fs => include}/parseopt.h | 0
lib/Makefile | 1 +
{fs => lib}/parseopt.c | 0
6 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/fs/Makefile b/fs/Makefile
index b3f929f506..8e3fd78e92 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -4,7 +4,7 @@ obj-$(CONFIG_FS_RAMFS) += ramfs.o
obj-y += devfs-core.o
obj-$(CONFIG_FS_DEVFS) += devfs.o
obj-$(CONFIG_FS_FAT) += fat/
-obj-y += fs.o parseopt.o
+obj-y += fs.o
obj-$(CONFIG_FS_UBIFS) += ubifs/
obj-$(CONFIG_FS_TFTP) += tftp.o
obj-$(CONFIG_FS_OMAP4_USBBOOT) += omap4_usbbootfs.o
diff --git a/fs/fs.c b/fs/fs.c
index f61ee091b5..ccb4943669 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -35,8 +35,7 @@
#include <libgen.h>
#include <block.h>
#include <libfile.h>
-
-#include "parseopt.h"
+#include <parseopt.h>
char *mkmodestr(unsigned long mode, char *str)
{
diff --git a/fs/nfs.c b/fs/nfs.c
index 97f01cfb34..75cd127eeb 100644
--- a/fs/nfs.c
+++ b/fs/nfs.c
@@ -36,8 +36,7 @@
#include <linux/sizes.h>
#include <byteorder.h>
#include <globalvar.h>
-
-#include "parseopt.h"
+#include <parseopt.h>
#define SUNRPC_PORT 111
diff --git a/fs/parseopt.h b/include/parseopt.h
similarity index 100%
rename from fs/parseopt.h
rename to include/parseopt.h
diff --git a/lib/Makefile b/lib/Makefile
index 1be1742499..8f7ef4e4ed 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -59,3 +59,4 @@ obj-y += reed_solomon/
obj-$(CONFIG_RATP) += ratp.o
obj-y += list_sort.o
obj-y += int_sqrt.o
+obj-y += parseopt.o
diff --git a/fs/parseopt.c b/lib/parseopt.c
similarity index 100%
rename from fs/parseopt.c
rename to lib/parseopt.c
--
2.15.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v2 5/7] include/parseopt.h: add guard macro
2018-01-14 21:22 [PATCH v2 0/7] sandbox: add gpio support with libftdi1 Antony Pavlov
` (3 preceding siblings ...)
2018-01-14 21:22 ` [PATCH v2 4/7] move parseopt to lib/ Antony Pavlov
@ 2018-01-14 21:22 ` Antony Pavlov
2018-01-14 21:22 ` [PATCH v2 6/7] parseopt: introduce parseopt_u16() and parseopt_str() Antony Pavlov
` (3 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Antony Pavlov @ 2018-01-14 21:22 UTC (permalink / raw)
To: barebox
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
include/parseopt.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/parseopt.h b/include/parseopt.h
index abf3be3f35..becc734c2b 100644
--- a/include/parseopt.h
+++ b/include/parseopt.h
@@ -1,2 +1,7 @@
+#ifndef __PARSEOPT_H__
+#define __PARSEOPT_H__
+
void parseopt_b(const char *options, const char *opt, bool *val);
void parseopt_hu(const char *options, const char *opt, unsigned short *val);
+
+#endif /* __PARSEOPT_H__ */
--
2.15.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v2 6/7] parseopt: introduce parseopt_u16() and parseopt_str()
2018-01-14 21:22 [PATCH v2 0/7] sandbox: add gpio support with libftdi1 Antony Pavlov
` (4 preceding siblings ...)
2018-01-14 21:22 ` [PATCH v2 5/7] include/parseopt.h: add guard macro Antony Pavlov
@ 2018-01-14 21:22 ` Antony Pavlov
2018-01-14 21:22 ` [PATCH v2 7/7] sandbox: parse libftdi options Antony Pavlov
` (2 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Antony Pavlov @ 2018-01-14 21:22 UTC (permalink / raw)
To: barebox
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
include/parseopt.h | 2 ++
lib/parseopt.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 66 insertions(+)
diff --git a/include/parseopt.h b/include/parseopt.h
index becc734c2b..1f9763f8c9 100644
--- a/include/parseopt.h
+++ b/include/parseopt.h
@@ -3,5 +3,7 @@
void parseopt_b(const char *options, const char *opt, bool *val);
void parseopt_hu(const char *options, const char *opt, unsigned short *val);
+void parseopt_u16(const char *options, const char *opt, uint16_t *val);
+void parseopt_str(const char *options, const char *opt, char **val);
#endif /* __PARSEOPT_H__ */
diff --git a/lib/parseopt.c b/lib/parseopt.c
index 8ff83019a7..8211733e3b 100644
--- a/lib/parseopt.c
+++ b/lib/parseopt.c
@@ -58,3 +58,67 @@ again:
if (*endp == ',' || *endp == '\0')
*val = v;
}
+
+void parseopt_u16(const char *options, const char *opt, uint16_t *val)
+{
+ const char *start;
+ size_t optlen = strlen(opt);
+ ulong v;
+ char *endp;
+
+again:
+ start = strstr(options, opt);
+
+ if (!start)
+ return;
+
+ if (start > options && start[-1] != ',') {
+ options = start;
+ goto again;
+ }
+
+ if (start[optlen] != '=') {
+ options = start;
+ goto again;
+ }
+
+ v = simple_strtoul(start + optlen + 1, &endp, 0);
+ if (v > U16_MAX)
+ return;
+
+ if (*endp == ',' || *endp == '\0')
+ *val = v;
+}
+
+void parseopt_str(const char *options, const char *opt, char **val)
+{
+ const char *start;
+ size_t optlen = strlen(opt);
+ char *endp;
+ char *parsed;
+
+again:
+ start = strstr(options, opt);
+
+ if (!start)
+ return;
+
+ if (start > options && start[-1] != ',') {
+ options = start;
+ goto again;
+ }
+
+ if (start[optlen] != '=') {
+ options = start;
+ goto again;
+ }
+
+ parsed = (char *)start + optlen + 1;
+ endp = parsed;
+ while (*endp != '\0' && *endp != ',') {
+
+ endp++;
+ }
+
+ *val = xstrndup(parsed, endp - parsed);
+}
--
2.15.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v2 7/7] sandbox: parse libftdi options
2018-01-14 21:22 [PATCH v2 0/7] sandbox: add gpio support with libftdi1 Antony Pavlov
` (5 preceding siblings ...)
2018-01-14 21:22 ` [PATCH v2 6/7] parseopt: introduce parseopt_u16() and parseopt_str() Antony Pavlov
@ 2018-01-14 21:22 ` Antony Pavlov
2018-01-17 9:53 ` [PATCH v2 0/7] sandbox: add gpio support with libftdi1 Sascha Hauer
2018-01-18 18:13 ` Antony Pavlov
8 siblings, 0 replies; 16+ messages in thread
From: Antony Pavlov @ 2018-01-14 21:22 UTC (permalink / raw)
To: barebox
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
arch/sandbox/Makefile | 2 +-
arch/sandbox/os/common.c | 12 ++++++++++--
arch/sandbox/os/ftdi.c | 14 +++++++++++++-
3 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/arch/sandbox/Makefile b/arch/sandbox/Makefile
index 85c70b5e80..95ef7c84fb 100644
--- a/arch/sandbox/Makefile
+++ b/arch/sandbox/Makefile
@@ -23,7 +23,7 @@ CFLAGS += -Dmalloc=barebox_malloc -Dcalloc=barebox_calloc \
-Dglob=barebox_glob -Dglobfree=barebox_globfree \
-Dioctl=barebox_ioctl -Dfstat=barebox_fstat \
-Dopendir=barebox_opendir -Dreaddir=barebox_readdir \
- -Dclosedir=barebox_closedir
+ -Dclosedir=barebox_closedir -Dstrdup=barebox_strdup
machdirs := $(patsubst %,arch/sandbox/mach-%/,$(machine-y))
diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c
index 665e8194ef..161ea5c849 100644
--- a/arch/sandbox/os/common.c
+++ b/arch/sandbox/os/common.c
@@ -51,6 +51,8 @@ int sdl_yres;
static struct termios term_orig, term_vi;
static char erase_char; /* the users erase character */
+const char *libftdi_options;
+
static void rawmode(void)
{
tcgetattr(0, &term_orig);
@@ -322,10 +324,11 @@ static struct option long_options[] = {
{"stdinout", 1, 0, 'B'},
{"xres", 1, 0, 'x'},
{"yres", 1, 0, 'y'},
+ {"libftdi", 1, 0, 'f'},
{0, 0, 0, 0},
};
-static const char optstring[] = "hm:i:e:d:O:I:B:x:y:";
+static const char optstring[] = "hm:i:e:d:O:I:B:x:y:f:";
int main(int argc, char *argv[])
{
@@ -367,6 +370,9 @@ int main(int argc, char *argv[])
case 'y':
sdl_yres = strtoul(optarg, NULL, 0);
break;
+ case 'f':
+ libftdi_options = strdup(optarg);
+ break;
default:
break;
}
@@ -495,7 +501,9 @@ static void print_usage(const char *prgname)
" stdin and stdout. <filein> and <fileout> can be regular\n"
" files or FIFOs.\n"
" -x, --xres=<res> SDL width.\n"
-" -y, --yres=<res> SDL height.\n",
+" -y, --yres=<res> SDL height.\n"
+" -f, --libftdi=<opts> libftdi options, e.g.\n"
+" --libftdi=vendor_id=0x1234,device_id=0x5678,serial=AB0055\n",
prgname
);
}
diff --git a/arch/sandbox/os/ftdi.c b/arch/sandbox/os/ftdi.c
index 7302dd0989..d69bc43180 100644
--- a/arch/sandbox/os/ftdi.c
+++ b/arch/sandbox/os/ftdi.c
@@ -34,6 +34,11 @@ struct ft2232_bitbang {
static struct ft2232_bitbang ftbb;
+extern const char *libftdi_options;
+
+extern void parseopt_u16(const char *options, const char *opt, uint16_t *val);
+extern void parseopt_str(const char *options, const char *opt, char **val);
+
static inline int ftdi_flush(struct ftdi_context *ftdi)
{
uint8_t buf[1];
@@ -119,6 +124,7 @@ static int barebox_libftdi1_init(void)
/* default FT2232 values */
uint16_t vendor_id = FTDI_VID;
uint16_t device_id = FTDI_8U2232C_PID;
+ char *serial = NULL;
ftdi = ftdi_new();
if (!ftdi) {
@@ -126,7 +132,13 @@ static int barebox_libftdi1_init(void)
goto error;
}
- ret = ftdi_usb_open(ftdi, vendor_id, device_id);
+ if (libftdi_options) {
+ parseopt_u16(libftdi_options, "device_id", &device_id);
+ parseopt_u16(libftdi_options, "vendor_id", &vendor_id);
+ parseopt_str(libftdi_options, "serial", &serial);
+ }
+
+ ret = ftdi_usb_open_desc(ftdi, vendor_id, device_id, NULL, serial);
if (ret < 0 && ret != -5) {
fprintf(stderr, "unable to open ftdi device: %d (%s)\n",
ret, ftdi_get_error_string(ftdi));
--
2.15.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 0/7] sandbox: add gpio support with libftdi1
2018-01-14 21:22 [PATCH v2 0/7] sandbox: add gpio support with libftdi1 Antony Pavlov
` (6 preceding siblings ...)
2018-01-14 21:22 ` [PATCH v2 7/7] sandbox: parse libftdi options Antony Pavlov
@ 2018-01-17 9:53 ` Sascha Hauer
2018-01-19 9:29 ` Antony Pavlov
2018-01-18 18:13 ` Antony Pavlov
8 siblings, 1 reply; 16+ messages in thread
From: Sascha Hauer @ 2018-01-17 9:53 UTC (permalink / raw)
To: Antony Pavlov; +Cc: barebox
Hi Antony,
On Mon, Jan 15, 2018 at 12:22:45AM +0300, Antony Pavlov wrote:
> 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.
I applied the parseopt patches for now since they don't need any further
discussions.
What puzzles me a bit is that the libftdi gpio controller is
instantiated from the device tree but configured through the
commandline. It probably has to be like this since we need the
device tree for using the gpios.
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] 16+ messages in thread
* Re: [PATCH v2 3/7] sandbox: add i2c and spi libftdi1 bit-bang example
2018-01-14 21:22 ` [PATCH v2 3/7] sandbox: add i2c and spi libftdi1 bit-bang example Antony Pavlov
@ 2018-01-17 10:01 ` Sascha Hauer
2018-01-19 9:14 ` Antony Pavlov
0 siblings, 1 reply; 16+ messages in thread
From: Sascha Hauer @ 2018-01-17 10:01 UTC (permalink / raw)
To: Antony Pavlov; +Cc: barebox
On Mon, Jan 15, 2018 at 12:22:48AM +0300, Antony Pavlov wrote:
> 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.dts if necessary
>
> barebox$ make
> barebox$ sudo ./barebox -d arch/sandbox/dts/sandbox.dtb
>
> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> ---
> arch/sandbox/configs/sandbox_defconfig | 26 ++++++++++++++++-
> arch/sandbox/dts/sandbox.dts | 52 ++++++++++++++++++++++++++++++++++
> 2 files changed, 77 insertions(+), 1 deletion(-)
>
> diff --git a/arch/sandbox/configs/sandbox_defconfig b/arch/sandbox/configs/sandbox_defconfig
> index dbaff12bfb..6b10adb8ef 100644
> --- a/arch/sandbox/configs/sandbox_defconfig
> +++ b/arch/sandbox/configs/sandbox_defconfig
> @@ -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,29 @@ 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_I2C_MUX=y
> +CONFIG_I2C_MUX_PCA954x=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_GPIO_74164=y
> +CONFIG_GPIO_PCA953X=y
> +CONFIG_GPIO_SX150X=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
> diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts
> index 2595aa13fa..69568f6d7a 100644
> --- a/arch/sandbox/dts/sandbox.dts
> +++ b/arch/sandbox/dts/sandbox.dts
> @@ -1,7 +1,59 @@
> /dts-v1/;
>
> #include "skeleton.dtsi"
> +#include <dt-bindings/gpio/gpio.h>
>
> / {
> + gpio0: gpio@0 {
> + compatible = "barebox,libftdi1-gpio";
> + /* use ACBUS[7:0] */
> + gpio-controller;
> + #gpio-cells = <2>;
> + status = "okay";
> + };
>
> + spi0 {
> + compatible = "spi-gpio";
> + #address-cells = <1>;
> + #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";
> +
> + m25p128@0 {
> + compatible = "m25p128", "jedec,spi-nor";
> + #address-cells = <1>;
> + #size-cells = <1>;
> + reg = <0>;
> + spi-max-frequency = <1000000>;
> + };
> + };
> +
> + i2c0: i2c0 {
> + compatible = "i2c-gpio";
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + gpios = <&gpio0 4 GPIO_ACTIVE_HIGH /* sda */
> + &gpio0 5 GPIO_ACTIVE_HIGH /* scl */
> + >;
> + i2c-gpio,scl-output-only;
> +
> + status = "disabled";
> +
> + eeprom: at24@50 {
> + compatible = "atmel,24c32";
> + reg = <0x50>;
> + };
> +
> + rtc: ds1307@68 {
> + compatible = "dallas,ds1307";
> + reg = <0x68>;
> + };
> + };
Can we move this to a sandbox-libftdi-example.dtsi file which is not
included by default? The rationale is that a user has to read and
understand this file anyway and probably adopt it to his wiring (or his
wiring to this file).
And if we do that, would it be an option to move the vendor/product_id
and serial setting to the device tree aswell? Then we would have all
config in a single place and could also use multiple devices.
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] 16+ messages in thread
* Re: [PATCH v2 0/7] sandbox: add gpio support with libftdi1
2018-01-14 21:22 [PATCH v2 0/7] sandbox: add gpio support with libftdi1 Antony Pavlov
` (7 preceding siblings ...)
2018-01-17 9:53 ` [PATCH v2 0/7] sandbox: add gpio support with libftdi1 Sascha Hauer
@ 2018-01-18 18:13 ` Antony Pavlov
2018-01-19 7:32 ` Sascha Hauer
8 siblings, 1 reply; 16+ messages in thread
From: Antony Pavlov @ 2018-01-18 18:13 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
On Mon, 15 Jan 2018 00:22:45 +0300
Antony Pavlov <antonynpavlov@gmail.com> wrote:
> This patch series makes it possible to use FT2232H ACBUS[7:0]
> pins as gpio pins from sandbox barebox.
Hi Sascha!
Please review this patch series!
> 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 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 (7):
> sandbox: avoid symbol conflict for {open,read,close}dir
> sandbox: add gpio support with libftdi1
> sandbox: add i2c and spi libftdi1 bit-bang example
> move parseopt to lib/
> include/parseopt.h: add guard macro
> parseopt: introduce parseopt_u16() and parseopt_str()
> sandbox: parse libftdi options
>
> arch/sandbox/Kconfig | 1 +
> arch/sandbox/Makefile | 10 +-
> arch/sandbox/configs/sandbox_defconfig | 26 +++-
> arch/sandbox/dts/sandbox.dts | 52 +++++++
> arch/sandbox/mach-sandbox/include/mach/linux.h | 11 ++
> arch/sandbox/os/Makefile | 3 +
> arch/sandbox/os/common.c | 12 +-
> arch/sandbox/os/ftdi.c | 181 +++++++++++++++++++++++++
> drivers/gpio/Kconfig | 4 +
> drivers/gpio/Makefile | 1 +
> drivers/gpio/gpio-libftdi1.c | 125 +++++++++++++++++
> fs/Makefile | 2 +-
> fs/fs.c | 3 +-
> fs/nfs.c | 3 +-
> fs/parseopt.c | 60 --------
> fs/parseopt.h | 2 -
> include/parseopt.h | 9 ++
> lib/Makefile | 1 +
> lib/parseopt.c | 124 +++++++++++++++++
> 19 files changed, 558 insertions(+), 72 deletions(-)
> create mode 100644 arch/sandbox/os/ftdi.c
> create mode 100644 drivers/gpio/gpio-libftdi1.c
> delete mode 100644 fs/parseopt.c
> delete mode 100644 fs/parseopt.h
> create mode 100644 include/parseopt.h
> create mode 100644 lib/parseopt.c
>
> --
> 2.15.1
>
--
Best regards,
Antony Pavlov
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 0/7] sandbox: add gpio support with libftdi1
2018-01-18 18:13 ` Antony Pavlov
@ 2018-01-19 7:32 ` Sascha Hauer
0 siblings, 0 replies; 16+ messages in thread
From: Sascha Hauer @ 2018-01-19 7:32 UTC (permalink / raw)
To: Antony Pavlov; +Cc: barebox
Hi Antony,
On Thu, Jan 18, 2018 at 09:13:50PM +0300, Antony Pavlov wrote:
> On Mon, 15 Jan 2018 00:22:45 +0300
> Antony Pavlov <antonynpavlov@gmail.com> wrote:
>
> > This patch series makes it possible to use FT2232H ACBUS[7:0]
> > pins as gpio pins from sandbox barebox.
>
> Hi Sascha!
>
> Please review this patch series!
I did On January 17 here:
http://lists.infradead.org/pipermail/barebox/2018-January/031909.html
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] 16+ messages in thread
* Re: [PATCH v2 3/7] sandbox: add i2c and spi libftdi1 bit-bang example
2018-01-17 10:01 ` Sascha Hauer
@ 2018-01-19 9:14 ` Antony Pavlov
0 siblings, 0 replies; 16+ messages in thread
From: Antony Pavlov @ 2018-01-19 9:14 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
On Wed, 17 Jan 2018 11:01:06 +0100
Sascha Hauer <s.hauer@pengutronix.de> wrote:
> On Mon, Jan 15, 2018 at 12:22:48AM +0300, Antony Pavlov wrote:
> > 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.dts if necessary
> >
> > barebox$ make
> > barebox$ sudo ./barebox -d arch/sandbox/dts/sandbox.dtb
> >
> > Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> > ---
> > arch/sandbox/configs/sandbox_defconfig | 26 ++++++++++++++++-
> > arch/sandbox/dts/sandbox.dts | 52 ++++++++++++++++++++++++++++++++++
> > 2 files changed, 77 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/sandbox/configs/sandbox_defconfig b/arch/sandbox/configs/sandbox_defconfig
> > index dbaff12bfb..6b10adb8ef 100644
> > --- a/arch/sandbox/configs/sandbox_defconfig
> > +++ b/arch/sandbox/configs/sandbox_defconfig
> > @@ -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,29 @@ 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_I2C_MUX=y
> > +CONFIG_I2C_MUX_PCA954x=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_GPIO_74164=y
> > +CONFIG_GPIO_PCA953X=y
> > +CONFIG_GPIO_SX150X=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
> > diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts
> > index 2595aa13fa..69568f6d7a 100644
> > --- a/arch/sandbox/dts/sandbox.dts
> > +++ b/arch/sandbox/dts/sandbox.dts
> > @@ -1,7 +1,59 @@
> > /dts-v1/;
> >
> > #include "skeleton.dtsi"
> > +#include <dt-bindings/gpio/gpio.h>
> >
> > / {
> > + gpio0: gpio@0 {
> > + compatible = "barebox,libftdi1-gpio";
> > + /* use ACBUS[7:0] */
> > + gpio-controller;
> > + #gpio-cells = <2>;
> > + status = "okay";
> > + };
> >
> > + spi0 {
> > + compatible = "spi-gpio";
> > + #address-cells = <1>;
> > + #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";
> > +
> > + m25p128@0 {
> > + compatible = "m25p128", "jedec,spi-nor";
> > + #address-cells = <1>;
> > + #size-cells = <1>;
> > + reg = <0>;
> > + spi-max-frequency = <1000000>;
> > + };
> > + };
> > +
> > + i2c0: i2c0 {
> > + compatible = "i2c-gpio";
> > + #address-cells = <1>;
> > + #size-cells = <0>;
> > +
> > + gpios = <&gpio0 4 GPIO_ACTIVE_HIGH /* sda */
> > + &gpio0 5 GPIO_ACTIVE_HIGH /* scl */
> > + >;
> > + i2c-gpio,scl-output-only;
> > +
> > + status = "disabled";
> > +
> > + eeprom: at24@50 {
> > + compatible = "atmel,24c32";
> > + reg = <0x50>;
> > + };
> > +
> > + rtc: ds1307@68 {
> > + compatible = "dallas,ds1307";
> > + reg = <0x68>;
> > + };
> > + };
>
> Can we move this to a sandbox-libftdi-example.dtsi file which is not
> included by default? The rationale is that a user has to read and
> understand this file anyway and probably adopt it to his wiring (or his
> wiring to this file).
>
> And if we do that, would it be an option to move the vendor/product_id
> and serial setting to the device tree aswell? Then we would have all
> config in a single place and could also use multiple devices.
Ok. I'll introduce sandbox-libftdi-example.dtsi with more usage examples
(e.g. I have missed LED example).
Also I'll move FTDI USB params into device tree file.
--
Best regards,
Antony Pavlov
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 0/7] sandbox: add gpio support with libftdi1
2018-01-17 9:53 ` [PATCH v2 0/7] sandbox: add gpio support with libftdi1 Sascha Hauer
@ 2018-01-19 9:29 ` Antony Pavlov
2018-01-19 9:40 ` Sascha Hauer
0 siblings, 1 reply; 16+ messages in thread
From: Antony Pavlov @ 2018-01-19 9:29 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
On Wed, 17 Jan 2018 10:53:14 +0100
Sascha Hauer <s.hauer@pengutronix.de> wrote:
> Hi Antony,
>
> On Mon, Jan 15, 2018 at 12:22:45AM +0300, Antony Pavlov wrote:
> > 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.
>
> I applied the parseopt patches for now since they don't need any further
> discussions.
>
There are three common parseopt-related patches:
move parseopt to lib/
include/parseopt.h: add guard macro
parseopt: introduce parseopt_u16() and parseopt_str()
Please confirm that you have got all three patches.
> What puzzles me a bit is that the libftdi gpio controller is
> instantiated from the device tree but configured through the
> commandline. It probably has to be like this since we need the
> device tree for using the gpios.
Getting FTDI chip vendorID and deviceID from device tree is reasonable.
However hardcoding FTDI chip serialnumber into device tree is not so good idea.
In addition dropping cmdline FTDI options parsing makes parseopt_u16() and parseopt_str() unused.
I propose add FTDI chip vendorID, deviceID and serial options to device tree
and keep parsing the same options from cmdline so once can override FTDI chip
serial number from cmdline.
> 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 |
--
Best regards,
Antony Pavlov
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 0/7] sandbox: add gpio support with libftdi1
2018-01-19 9:29 ` Antony Pavlov
@ 2018-01-19 9:40 ` Sascha Hauer
2018-01-19 11:39 ` Antony Pavlov
0 siblings, 1 reply; 16+ messages in thread
From: Sascha Hauer @ 2018-01-19 9:40 UTC (permalink / raw)
To: Antony Pavlov; +Cc: barebox
On Fri, Jan 19, 2018 at 12:29:01PM +0300, Antony Pavlov wrote:
> On Wed, 17 Jan 2018 10:53:14 +0100
> Sascha Hauer <s.hauer@pengutronix.de> wrote:
>
> > Hi Antony,
> >
> > On Mon, Jan 15, 2018 at 12:22:45AM +0300, Antony Pavlov wrote:
> > > 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.
> >
> > I applied the parseopt patches for now since they don't need any further
> > discussions.
> >
>
> There are three common parseopt-related patches:
>
> move parseopt to lib/
> include/parseopt.h: add guard macro
> parseopt: introduce parseopt_u16() and parseopt_str()
>
> Please confirm that you have got all three patches.
>
> > What puzzles me a bit is that the libftdi gpio controller is
> > instantiated from the device tree but configured through the
> > commandline. It probably has to be like this since we need the
> > device tree for using the gpios.
>
> Getting FTDI chip vendorID and deviceID from device tree is reasonable.
> However hardcoding FTDI chip serialnumber into device tree is not so good idea.
> In addition dropping cmdline FTDI options parsing makes parseopt_u16() and parseopt_str() unused.
>
> I propose add FTDI chip vendorID, deviceID and serial options to device tree
> and keep parsing the same options from cmdline so once can override FTDI chip
> serial number from cmdline.
How would you handle multiple FTDI chips then if you want to make use
of more than one at a time?
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] 16+ messages in thread
* Re: [PATCH v2 0/7] sandbox: add gpio support with libftdi1
2018-01-19 9:40 ` Sascha Hauer
@ 2018-01-19 11:39 ` Antony Pavlov
0 siblings, 0 replies; 16+ messages in thread
From: Antony Pavlov @ 2018-01-19 11:39 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
On Fri, 19 Jan 2018 10:40:08 +0100
Sascha Hauer <s.hauer@pengutronix.de> wrote:
> On Fri, Jan 19, 2018 at 12:29:01PM +0300, Antony Pavlov wrote:
> > On Wed, 17 Jan 2018 10:53:14 +0100
> > Sascha Hauer <s.hauer@pengutronix.de> wrote:
> >
> > > Hi Antony,
> > >
> > > On Mon, Jan 15, 2018 at 12:22:45AM +0300, Antony Pavlov wrote:
> > > > 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.
> > >
> > > I applied the parseopt patches for now since they don't need any further
> > > discussions.
> > >
> >
> > There are three common parseopt-related patches:
> >
> > move parseopt to lib/
> > include/parseopt.h: add guard macro
> > parseopt: introduce parseopt_u16() and parseopt_str()
> >
> > Please confirm that you have got all three patches.
> >
> > > What puzzles me a bit is that the libftdi gpio controller is
> > > instantiated from the device tree but configured through the
> > > commandline. It probably has to be like this since we need the
> > > device tree for using the gpios.
> >
> > Getting FTDI chip vendorID and deviceID from device tree is reasonable.
> > However hardcoding FTDI chip serialnumber into device tree is not so good idea.
> > In addition dropping cmdline FTDI options parsing makes parseopt_u16() and parseopt_str() unused.
> >
> > I propose add FTDI chip vendorID, deviceID and serial options to device tree
> > and keep parsing the same options from cmdline so once can override FTDI chip
> > serial number from cmdline.
>
> How would you handle multiple FTDI chips then if you want to make use
> of more than one at a time?
Good question. My current code gives no good means to add more than one FT2232 chip.
I suppose that after adding option-passing-via-dt feature it will be possible
to add more than one FT2232 chip and ... cmdline option passing will interfere with
multi-FT2232 dt in a bad way. Now I think that dropping cmdline parsing is not so bad idea.
>
> 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 |
--
Best regards,
Antony Pavlov
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2018-01-19 11:25 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-14 21:22 [PATCH v2 0/7] sandbox: add gpio support with libftdi1 Antony Pavlov
2018-01-14 21:22 ` [PATCH v2 1/7] sandbox: avoid symbol conflict for {open, read, close}dir Antony Pavlov
2018-01-14 21:22 ` [PATCH v2 2/7] sandbox: add gpio support with libftdi1 Antony Pavlov
2018-01-14 21:22 ` [PATCH v2 3/7] sandbox: add i2c and spi libftdi1 bit-bang example Antony Pavlov
2018-01-17 10:01 ` Sascha Hauer
2018-01-19 9:14 ` Antony Pavlov
2018-01-14 21:22 ` [PATCH v2 4/7] move parseopt to lib/ Antony Pavlov
2018-01-14 21:22 ` [PATCH v2 5/7] include/parseopt.h: add guard macro Antony Pavlov
2018-01-14 21:22 ` [PATCH v2 6/7] parseopt: introduce parseopt_u16() and parseopt_str() Antony Pavlov
2018-01-14 21:22 ` [PATCH v2 7/7] sandbox: parse libftdi options Antony Pavlov
2018-01-17 9:53 ` [PATCH v2 0/7] sandbox: add gpio support with libftdi1 Sascha Hauer
2018-01-19 9:29 ` Antony Pavlov
2018-01-19 9:40 ` Sascha Hauer
2018-01-19 11:39 ` Antony Pavlov
2018-01-18 18:13 ` Antony Pavlov
2018-01-19 7:32 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox