diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2015-09-01 09:43:53 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-09-01 09:43:53 +0200 |
commit | fae6eea0e6af8d9eb8ac02f1a4d6307ebc28fe5b (patch) | |
tree | 06b127d1456e93d49ef7342ae65bb47085bb9ce1 /include | |
parent | f387bc96bb23658ecdaa67bc9bff6fd290f636f8 (diff) | |
parent | ffcabbe125d31dcb4f25dbb8f29be7adcfcf408e (diff) | |
download | barebox-fae6eea0e6af8d9eb8ac02f1a4d6307ebc28fe5b.tar.gz barebox-fae6eea0e6af8d9eb8ac02f1a4d6307ebc28fe5b.tar.xz |
Merge branch 'for-next/gpio'
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-generic/gpio.h | 9 | ||||
-rw-r--r-- | include/gpio.h | 23 | ||||
-rw-r--r-- | include/i2c/i2c.h | 45 |
3 files changed, 67 insertions, 10 deletions
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h deleted file mode 100644 index 767497096a..0000000000 --- a/include/asm-generic/gpio.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef __ASM_GENERIC_GPIO_H -#define __ASM_GENERIC_GPIO_H - -void gpio_set_value(unsigned gpio, int value); -int gpio_get_value(unsigned gpio); -int gpio_direction_output(unsigned gpio, int value); -int gpio_direction_input(unsigned gpio); - -#endif /* __ASM_GENERIC_GPIO_H */ diff --git a/include/gpio.h b/include/gpio.h index f116ea6af7..7b3f512b19 100644 --- a/include/gpio.h +++ b/include/gpio.h @@ -1,7 +1,28 @@ #ifndef __GPIO_H #define __GPIO_H -#include <asm/gpio.h> +#ifdef CONFIG_GENERIC_GPIO +void gpio_set_value(unsigned gpio, int value); +int gpio_get_value(unsigned gpio); +int gpio_direction_output(unsigned gpio, int value); +int gpio_direction_input(unsigned gpio); +#else +static inline void gpio_set_value(unsigned gpio, int value) +{ +} +static inline int gpio_get_value(unsigned gpio) +{ + return 0; +} +static inline int gpio_direction_output(unsigned gpio, int value) +{ + return -EINVAL; +} +static inline int gpio_direction_input(unsigned gpio) +{ + return -EINVAL; +} +#endif #define ARCH_NR_GPIOS 256 diff --git a/include/i2c/i2c.h b/include/i2c/i2c.h index 4696f43e31..12e4827755 100644 --- a/include/i2c/i2c.h +++ b/include/i2c/i2c.h @@ -19,6 +19,8 @@ #include <driver.h> #include <linux/types.h> +struct i2c_adapter; + /* * struct i2c_platform_data - structure of platform data for MXC I2C driver * @param bitrate Bus speed measured in Hz @@ -61,6 +63,47 @@ struct i2c_msg { __u16 len; /**< Number of data bytes in @buf being read from or written to the I2C slave address. */ }; +/** + * struct i2c_bus_recovery_info - I2C bus recovery information + * @recover_bus: Recover routine. Either pass driver's recover_bus() routine, or + * i2c_generic_scl_recovery() or i2c_generic_gpio_recovery(). + * @get_scl: This gets current value of SCL line. Mandatory for generic SCL + * recovery. Used internally for generic GPIO recovery. + * @set_scl: This sets/clears SCL line. Mandatory for generic SCL recovery. Used + * internally for generic GPIO recovery. + * @get_sda: This gets current value of SDA line. Optional for generic SCL + * recovery. Used internally, if sda_gpio is a valid GPIO, for generic GPIO + * recovery. + * @prepare_recovery: This will be called before starting recovery. Platform may + * configure padmux here for SDA/SCL line or something else they want. + * @unprepare_recovery: This will be called after completing recovery. Platform + * may configure padmux here for SDA/SCL line or something else they want. + * @scl_gpio: gpio number of the SCL line. Only required for GPIO recovery. + * @sda_gpio: gpio number of the SDA line. Only required for GPIO recovery. + */ +struct i2c_bus_recovery_info { + int (*recover_bus)(struct i2c_adapter *); + + int (*get_scl)(struct i2c_adapter *); + void (*set_scl)(struct i2c_adapter *, int val); + int (*get_sda)(struct i2c_adapter *); + + void (*prepare_recovery)(struct i2c_adapter *); + void (*unprepare_recovery)(struct i2c_adapter *); + + /* gpio recovery */ + int scl_gpio; + int sda_gpio; +}; + +int i2c_recover_bus(struct i2c_adapter *adap); + +/* Generic recovery routines */ +int i2c_get_scl_gpio_value(struct i2c_adapter *adap); +void i2c_set_scl_gpio_value(struct i2c_adapter *adap, int val); +int i2c_get_sda_gpio_value(struct i2c_adapter *adap); +int i2c_generic_gpio_recovery(struct i2c_adapter *adap); +int i2c_generic_scl_recovery(struct i2c_adapter *adap); /** * i2c_adapter is the structure used to identify a physical i2c bus @@ -74,6 +117,8 @@ struct i2c_adapter { struct list_head list; int retries; void *algo_data; + + struct i2c_bus_recovery_info *bus_recovery_info; }; |