Loading Documentation/devicetree/bindings/i2c/i2c-gpio.txt +23 −9 Original line number Diff line number Diff line Loading @@ -2,25 +2,39 @@ Device-Tree bindings for i2c gpio driver Required properties: - compatible = "i2c-gpio"; - gpios: sda and scl gpio - sda-gpios: gpio used for the sda signal, this should be flagged as active high using open drain with (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN) from <dt-bindings/gpio/gpio.h> since the signal is by definition open drain. - scl-gpios: gpio used for the scl signal, this should be flagged as active high using open drain with (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN) from <dt-bindings/gpio/gpio.h> since the signal is by definition open drain. Optional properties: - i2c-gpio,sda-open-drain: sda as open drain - i2c-gpio,scl-open-drain: scl as open drain - i2c-gpio,scl-output-only: scl as output only - i2c-gpio,delay-us: delay between GPIO operations (may depend on each platform) - i2c-gpio,timeout-ms: timeout to get data Deprecated properties, do not use in new device tree sources: - gpios: sda and scl gpio, alternative for {sda,scl}-gpios - i2c-gpio,sda-open-drain: this means that something outside of our control has put the GPIO line used for SDA into open drain mode, and that something is not the GPIO chip. It is essentially an inconsistency flag. - i2c-gpio,scl-open-drain: this means that something outside of our control has put the GPIO line used for SCL into open drain mode, and that something is not the GPIO chip. It is essentially an inconsistency flag. Example nodes: #include <dt-bindings/gpio/gpio.h> i2c@0 { compatible = "i2c-gpio"; gpios = <&pioA 23 0 /* sda */ &pioA 24 0 /* scl */ >; i2c-gpio,sda-open-drain; i2c-gpio,scl-open-drain; sda-gpios = <&pioA 23 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>; scl-gpios = <&pioA 24 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>; i2c-gpio,delay-us = <2>; /* ~100 kHz */ #address-cells = <1>; #size-cells = <0>; Loading arch/arm/mach-ep93xx/core.c +23 −18 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ #include <linux/amba/serial.h> #include <linux/mtd/physmap.h> #include <linux/i2c.h> #include <linux/i2c-gpio.h> #include <linux/gpio/machine.h> #include <linux/spi/spi.h> #include <linux/export.h> #include <linux/irqchip/arm-vic.h> Loading Loading @@ -320,42 +320,47 @@ void __init ep93xx_register_eth(struct ep93xx_eth_data *data, int copy_addr) /************************************************************************* * EP93xx i2c peripheral handling *************************************************************************/ static struct i2c_gpio_platform_data ep93xx_i2c_data; /* All EP93xx devices use the same two GPIO pins for I2C bit-banging */ static struct gpiod_lookup_table ep93xx_i2c_gpiod_table = { .dev_id = "i2c-gpio", .table = { /* Use local offsets on gpiochip/port "G" */ GPIO_LOOKUP_IDX("G", 1, NULL, 0, GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN), GPIO_LOOKUP_IDX("G", 0, NULL, 1, GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN), }, }; static struct platform_device ep93xx_i2c_device = { .name = "i2c-gpio", .id = 0, .dev = { .platform_data = &ep93xx_i2c_data, .platform_data = NULL, }, }; /** * ep93xx_register_i2c - Register the i2c platform device. * @data: platform specific i2c-gpio configuration (__initdata) * @devices: platform specific i2c bus device information (__initdata) * @num: the number of devices on the i2c bus */ void __init ep93xx_register_i2c(struct i2c_gpio_platform_data *data, struct i2c_board_info *devices, int num) void __init ep93xx_register_i2c(struct i2c_board_info *devices, int num) { /* * Set the EEPROM interface pin drive type control. * Defines the driver type for the EECLK and EEDAT pins as either * open drain, which will require an external pull-up, or a normal * CMOS driver. * FIXME: this just sets the two pins as non-opendrain, as no * platforms tries to do that anyway. Flag the applicable lines * as open drain in the GPIO_LOOKUP above and the driver or * gpiolib will handle open drain/open drain emulation as need * be. Right now i2c-gpio emulates open drain which is not * optimal. */ if (data->sda_is_open_drain && data->sda_pin != EP93XX_GPIO_LINE_EEDAT) pr_warning("sda != EEDAT, open drain has no effect\n"); if (data->scl_is_open_drain && data->scl_pin != EP93XX_GPIO_LINE_EECLK) pr_warning("scl != EECLK, open drain has no effect\n"); __raw_writel((data->sda_is_open_drain << 1) | (data->scl_is_open_drain << 0), __raw_writel((0 << 1) | (0 << 0), EP93XX_GPIO_EEDRIVE); ep93xx_i2c_data = *data; i2c_register_board_info(0, devices, num); gpiod_add_lookup_table(&ep93xx_i2c_gpiod_table); platform_device_register(&ep93xx_i2c_device); } Loading arch/arm/mach-ep93xx/edb93xx.c +2 −13 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ #include <linux/init.h> #include <linux/platform_device.h> #include <linux/i2c.h> #include <linux/i2c-gpio.h> #include <linux/spi/spi.h> #include <sound/cs4271.h> Loading Loading @@ -61,14 +60,6 @@ static struct ep93xx_eth_data __initdata edb93xx_eth_data = { /************************************************************************* * EDB93xx i2c peripheral handling *************************************************************************/ static struct i2c_gpio_platform_data __initdata edb93xx_i2c_gpio_data = { .sda_pin = EP93XX_GPIO_LINE_EEDAT, .sda_is_open_drain = 0, .scl_pin = EP93XX_GPIO_LINE_EECLK, .scl_is_open_drain = 0, .udelay = 0, /* default to 100 kHz */ .timeout = 0, /* default to 100 ms */ }; static struct i2c_board_info __initdata edb93xxa_i2c_board_info[] = { { Loading @@ -86,13 +77,11 @@ static void __init edb93xx_register_i2c(void) { if (machine_is_edb9302a() || machine_is_edb9307a() || machine_is_edb9315a()) { ep93xx_register_i2c(&edb93xx_i2c_gpio_data, edb93xxa_i2c_board_info, ep93xx_register_i2c(edb93xxa_i2c_board_info, ARRAY_SIZE(edb93xxa_i2c_board_info)); } else if (machine_is_edb9302() || machine_is_edb9307() || machine_is_edb9312() || machine_is_edb9315()) { ep93xx_register_i2c(&edb93xx_i2c_gpio_data, edb93xx_i2c_board_info, ep93xx_register_i2c(edb93xx_i2c_board_info, ARRAY_SIZE(edb93xx_i2c_board_info)); } } Loading arch/arm/mach-ep93xx/include/mach/platform.h +1 −3 Original line number Diff line number Diff line Loading @@ -7,7 +7,6 @@ #include <linux/reboot.h> struct device; struct i2c_gpio_platform_data; struct i2c_board_info; struct spi_board_info; struct platform_device; Loading Loading @@ -36,8 +35,7 @@ void ep93xx_register_flash(unsigned int width, resource_size_t start, resource_size_t size); void ep93xx_register_eth(struct ep93xx_eth_data *data, int copy_addr); void ep93xx_register_i2c(struct i2c_gpio_platform_data *data, struct i2c_board_info *devices, int num); void ep93xx_register_i2c(struct i2c_board_info *devices, int num); void ep93xx_register_spi(struct ep93xx_spi_info *info, struct spi_board_info *devices, int num); void ep93xx_register_fb(struct ep93xxfb_mach_info *data); Loading arch/arm/mach-ep93xx/simone.c +1 −11 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ #include <linux/init.h> #include <linux/platform_device.h> #include <linux/i2c.h> #include <linux/i2c-gpio.h> #include <linux/mmc/host.h> #include <linux/spi/spi.h> #include <linux/spi/mmc_spi.h> Loading Loading @@ -129,15 +128,6 @@ static struct ep93xx_spi_info simone_spi_info __initdata = { .use_dma = 1, }; static struct i2c_gpio_platform_data __initdata simone_i2c_gpio_data = { .sda_pin = EP93XX_GPIO_LINE_EEDAT, .sda_is_open_drain = 0, .scl_pin = EP93XX_GPIO_LINE_EECLK, .scl_is_open_drain = 0, .udelay = 0, .timeout = 0, }; static struct i2c_board_info __initdata simone_i2c_board_info[] = { { I2C_BOARD_INFO("ds1337", 0x68), Loading @@ -161,7 +151,7 @@ static void __init simone_init_machine(void) ep93xx_register_flash(2, EP93XX_CS6_PHYS_BASE, SZ_8M); ep93xx_register_eth(&simone_eth_data, 1); ep93xx_register_fb(&simone_fb_info); ep93xx_register_i2c(&simone_i2c_gpio_data, simone_i2c_board_info, ep93xx_register_i2c(simone_i2c_board_info, ARRAY_SIZE(simone_i2c_board_info)); ep93xx_register_spi(&simone_spi_info, simone_spi_devices, ARRAY_SIZE(simone_spi_devices)); Loading Loading
Documentation/devicetree/bindings/i2c/i2c-gpio.txt +23 −9 Original line number Diff line number Diff line Loading @@ -2,25 +2,39 @@ Device-Tree bindings for i2c gpio driver Required properties: - compatible = "i2c-gpio"; - gpios: sda and scl gpio - sda-gpios: gpio used for the sda signal, this should be flagged as active high using open drain with (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN) from <dt-bindings/gpio/gpio.h> since the signal is by definition open drain. - scl-gpios: gpio used for the scl signal, this should be flagged as active high using open drain with (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN) from <dt-bindings/gpio/gpio.h> since the signal is by definition open drain. Optional properties: - i2c-gpio,sda-open-drain: sda as open drain - i2c-gpio,scl-open-drain: scl as open drain - i2c-gpio,scl-output-only: scl as output only - i2c-gpio,delay-us: delay between GPIO operations (may depend on each platform) - i2c-gpio,timeout-ms: timeout to get data Deprecated properties, do not use in new device tree sources: - gpios: sda and scl gpio, alternative for {sda,scl}-gpios - i2c-gpio,sda-open-drain: this means that something outside of our control has put the GPIO line used for SDA into open drain mode, and that something is not the GPIO chip. It is essentially an inconsistency flag. - i2c-gpio,scl-open-drain: this means that something outside of our control has put the GPIO line used for SCL into open drain mode, and that something is not the GPIO chip. It is essentially an inconsistency flag. Example nodes: #include <dt-bindings/gpio/gpio.h> i2c@0 { compatible = "i2c-gpio"; gpios = <&pioA 23 0 /* sda */ &pioA 24 0 /* scl */ >; i2c-gpio,sda-open-drain; i2c-gpio,scl-open-drain; sda-gpios = <&pioA 23 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>; scl-gpios = <&pioA 24 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>; i2c-gpio,delay-us = <2>; /* ~100 kHz */ #address-cells = <1>; #size-cells = <0>; Loading
arch/arm/mach-ep93xx/core.c +23 −18 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ #include <linux/amba/serial.h> #include <linux/mtd/physmap.h> #include <linux/i2c.h> #include <linux/i2c-gpio.h> #include <linux/gpio/machine.h> #include <linux/spi/spi.h> #include <linux/export.h> #include <linux/irqchip/arm-vic.h> Loading Loading @@ -320,42 +320,47 @@ void __init ep93xx_register_eth(struct ep93xx_eth_data *data, int copy_addr) /************************************************************************* * EP93xx i2c peripheral handling *************************************************************************/ static struct i2c_gpio_platform_data ep93xx_i2c_data; /* All EP93xx devices use the same two GPIO pins for I2C bit-banging */ static struct gpiod_lookup_table ep93xx_i2c_gpiod_table = { .dev_id = "i2c-gpio", .table = { /* Use local offsets on gpiochip/port "G" */ GPIO_LOOKUP_IDX("G", 1, NULL, 0, GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN), GPIO_LOOKUP_IDX("G", 0, NULL, 1, GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN), }, }; static struct platform_device ep93xx_i2c_device = { .name = "i2c-gpio", .id = 0, .dev = { .platform_data = &ep93xx_i2c_data, .platform_data = NULL, }, }; /** * ep93xx_register_i2c - Register the i2c platform device. * @data: platform specific i2c-gpio configuration (__initdata) * @devices: platform specific i2c bus device information (__initdata) * @num: the number of devices on the i2c bus */ void __init ep93xx_register_i2c(struct i2c_gpio_platform_data *data, struct i2c_board_info *devices, int num) void __init ep93xx_register_i2c(struct i2c_board_info *devices, int num) { /* * Set the EEPROM interface pin drive type control. * Defines the driver type for the EECLK and EEDAT pins as either * open drain, which will require an external pull-up, or a normal * CMOS driver. * FIXME: this just sets the two pins as non-opendrain, as no * platforms tries to do that anyway. Flag the applicable lines * as open drain in the GPIO_LOOKUP above and the driver or * gpiolib will handle open drain/open drain emulation as need * be. Right now i2c-gpio emulates open drain which is not * optimal. */ if (data->sda_is_open_drain && data->sda_pin != EP93XX_GPIO_LINE_EEDAT) pr_warning("sda != EEDAT, open drain has no effect\n"); if (data->scl_is_open_drain && data->scl_pin != EP93XX_GPIO_LINE_EECLK) pr_warning("scl != EECLK, open drain has no effect\n"); __raw_writel((data->sda_is_open_drain << 1) | (data->scl_is_open_drain << 0), __raw_writel((0 << 1) | (0 << 0), EP93XX_GPIO_EEDRIVE); ep93xx_i2c_data = *data; i2c_register_board_info(0, devices, num); gpiod_add_lookup_table(&ep93xx_i2c_gpiod_table); platform_device_register(&ep93xx_i2c_device); } Loading
arch/arm/mach-ep93xx/edb93xx.c +2 −13 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ #include <linux/init.h> #include <linux/platform_device.h> #include <linux/i2c.h> #include <linux/i2c-gpio.h> #include <linux/spi/spi.h> #include <sound/cs4271.h> Loading Loading @@ -61,14 +60,6 @@ static struct ep93xx_eth_data __initdata edb93xx_eth_data = { /************************************************************************* * EDB93xx i2c peripheral handling *************************************************************************/ static struct i2c_gpio_platform_data __initdata edb93xx_i2c_gpio_data = { .sda_pin = EP93XX_GPIO_LINE_EEDAT, .sda_is_open_drain = 0, .scl_pin = EP93XX_GPIO_LINE_EECLK, .scl_is_open_drain = 0, .udelay = 0, /* default to 100 kHz */ .timeout = 0, /* default to 100 ms */ }; static struct i2c_board_info __initdata edb93xxa_i2c_board_info[] = { { Loading @@ -86,13 +77,11 @@ static void __init edb93xx_register_i2c(void) { if (machine_is_edb9302a() || machine_is_edb9307a() || machine_is_edb9315a()) { ep93xx_register_i2c(&edb93xx_i2c_gpio_data, edb93xxa_i2c_board_info, ep93xx_register_i2c(edb93xxa_i2c_board_info, ARRAY_SIZE(edb93xxa_i2c_board_info)); } else if (machine_is_edb9302() || machine_is_edb9307() || machine_is_edb9312() || machine_is_edb9315()) { ep93xx_register_i2c(&edb93xx_i2c_gpio_data, edb93xx_i2c_board_info, ep93xx_register_i2c(edb93xx_i2c_board_info, ARRAY_SIZE(edb93xx_i2c_board_info)); } } Loading
arch/arm/mach-ep93xx/include/mach/platform.h +1 −3 Original line number Diff line number Diff line Loading @@ -7,7 +7,6 @@ #include <linux/reboot.h> struct device; struct i2c_gpio_platform_data; struct i2c_board_info; struct spi_board_info; struct platform_device; Loading Loading @@ -36,8 +35,7 @@ void ep93xx_register_flash(unsigned int width, resource_size_t start, resource_size_t size); void ep93xx_register_eth(struct ep93xx_eth_data *data, int copy_addr); void ep93xx_register_i2c(struct i2c_gpio_platform_data *data, struct i2c_board_info *devices, int num); void ep93xx_register_i2c(struct i2c_board_info *devices, int num); void ep93xx_register_spi(struct ep93xx_spi_info *info, struct spi_board_info *devices, int num); void ep93xx_register_fb(struct ep93xxfb_mach_info *data); Loading
arch/arm/mach-ep93xx/simone.c +1 −11 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ #include <linux/init.h> #include <linux/platform_device.h> #include <linux/i2c.h> #include <linux/i2c-gpio.h> #include <linux/mmc/host.h> #include <linux/spi/spi.h> #include <linux/spi/mmc_spi.h> Loading Loading @@ -129,15 +128,6 @@ static struct ep93xx_spi_info simone_spi_info __initdata = { .use_dma = 1, }; static struct i2c_gpio_platform_data __initdata simone_i2c_gpio_data = { .sda_pin = EP93XX_GPIO_LINE_EEDAT, .sda_is_open_drain = 0, .scl_pin = EP93XX_GPIO_LINE_EECLK, .scl_is_open_drain = 0, .udelay = 0, .timeout = 0, }; static struct i2c_board_info __initdata simone_i2c_board_info[] = { { I2C_BOARD_INFO("ds1337", 0x68), Loading @@ -161,7 +151,7 @@ static void __init simone_init_machine(void) ep93xx_register_flash(2, EP93XX_CS6_PHYS_BASE, SZ_8M); ep93xx_register_eth(&simone_eth_data, 1); ep93xx_register_fb(&simone_fb_info); ep93xx_register_i2c(&simone_i2c_gpio_data, simone_i2c_board_info, ep93xx_register_i2c(simone_i2c_board_info, ARRAY_SIZE(simone_i2c_board_info)); ep93xx_register_spi(&simone_spi_info, simone_spi_devices, ARRAY_SIZE(simone_spi_devices)); Loading