OMAP: GPIO: cleanup GPIO driver
Subsystems (4)
cover OMAP: GPIO: cleanup GPIO driver
Modifies the OMAP GPIO driver to avoid usage of cpu_is* checks for different OMAP architectures. This is done by moving some architecture specific code to mach-omap* and call them from plat-omap* using function pointers. Also remove the register offset macros from OMAP GPIO driver and handle the same in mach-omap*.
Avoid usage of gpio_bank_count and gpio_bank pointer array by means of maintaining a list. Removes the bank->method flag from the GPIO driver.
All OMAP1 SoCs has one MPUIO type GPIO bank. OMAP2+ does not have any MPUIO type GPIO bank. Since MPUIO type GPIO bank is the same for all OMAP1 CPUs, they are handled in plat-omap/ itself as there is no common gpio.c file for all cpu types in mach-omap1. They are identified by using bank->stride flag as it is '0' for other than MPUIO type banks.
Patch series is based on mainline rc4 following commit:91e8549bde9e5cc88c5a2e8c8114389279e240b5
Merge branch 'for-linus' of git://git.kernel.dk/linux-2.6-block
Compile tested for:
- omap1_defconfig
- omap2plus_defconfig
Boot test (success on the following boards):
- OMAP1710-H3
- OMAP2420-H4
- OMAP3430-SDP
- OMAP3430-Zoom2
- OMAP3630-Zoom3
- OMAP4430-SDP
- OMAP4430-Blaze
GPIO module functionality testing (success on the following boards):
- OMAP2420-H4
- OMAP3430-SDP
- OMAP3430-Zoom2
- OMAP3630-Zoom3
- OMAP4430-SDP
- OMAP4430-Blaze
PM Testing (success as given below):
OMAP3430-SDP: retention, off_mode, system_wide suspend, gpio wakeup
OMAP3630-Zoom3: retention, system_wide suspend
using the following:
echo 5 > /sys/devices/platform/omap/omap_uart.0/sleep_timeout echo 5 > /sys/devices/platform/omap/omap_uart.1/sleep_timeout echo 5 > /sys/devices/platform/omap/omap_uart.2/sleep_timeout echo 5 > /sys/devices/platform/omap/omap_uart.3/sleep_timeout echo '5' > /debug/pm_debug/wakeup_timer_seconds echo 1 > /debug/pm_debug/sleep_while_idle
echo 1 > /debug/pm_debug/enable_off_mode
Charulatha V (18):
OMAP1: GPIO: Fix mpuio_init() call
OMAP: GPIO: remove get_gpio_bank()
OMAP: GPIO: Move gpio_get_index() to mach-omap
OMAP: GPIO: Move gpio_valid() to SoC specific files
OMAP: GPIO: cleanup datain,dataout,set dir funcs
OMAP: GPIO: cleanup set trigger func
OMAP: GPIO: cleanup set/get IRQ, clr irqstatus funcs
OMAP: GPIO: req/free: Remove reg offset macros usage
OMAP: GPIO: cleanup gpio_irq_handler
OMAP: GPIO: cleanup set wakeup/suspend/resume funcs
OMAP: GPIO: Remove dependency on gpio_bank_count
OMAP: GPIO: cleanup set_debounce, idle/resume_after_idle
OMAP: GPIO: cleanup save/restore context
OMAP: GPIO: Remove CONFIG_ARCH_OMAP16XX/OMAP2+ defines
OMAP: GPIO: cleanup gpio_show_rev
OMAP: GPIO: move omap_gpio_mod_init to mach-omap
OMAP: GPIO: use dev_err* instead of printk
OMAP: GPIO: Remove usage of bank method
arch/arm/mach-omap1/gpio15xx.c | 110 ++- arch/arm/mach-omap1/gpio16xx.c | 174 +++- arch/arm/mach-omap1/gpio7xx.c | 132 ++- arch/arm/mach-omap2/gpio.c | 476 +++++++++- arch/arm/plat-omap/gpio.c | 1770 ++++++++------------------------ arch/arm/plat-omap/include/plat/gpio.h | 108 ++- 6 files changed, 1380 insertions(+), 1390 deletions(-)
RFC PATCH 1/18 OMAP1: GPIO: Fix mpuio_init() call
In OMAP1 GPIO, MPUIO bank's initialization is called as part of omap_gpio_sysinit() which is an "arch_initcall". mpuio_init() relies on the gpio_bank pointer of MPUIO bank whose memory is allocated only during omap_gpio_probe(). Hence move mpuio_init() call as part of probe after the gpio_bank pointer is initialized.
--- arch/arm/plat-omap/gpio.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/plat-omap/gpio.c +2 -2
@@ -1697,6 +1697,8 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev) ret =init_gpio_info (pdev);if (ret)return ret; +if (cpu_class_is_omap1 ()) +mpuio_init (); } id = pdev->id;
@@ -2110,8 +2112,6 @@ static int __init omap_gpio_sysinit(void) {int ret =0 ; -mpuio_init (); -#if defined(CONFIG_ARCH_OMAP16XX ) || defined(CONFIG_ARCH_OMAP2PLUS )if (cpu_is_omap16xx () ||cpu_class_is_omap2 ()) {if (ret ==0 ) {
Signature · 1 line
1.7.1
RFC PATCH 2/18 OMAP: GPIO: remove get_gpio_bank()
In reply to Charulatha Vuse chip info to get the pointer to the struct gpio_bank for a given GPIO bank and remove get_gpio_bank().
--- arch/arm/plat-omap/gpio.c | 29 ++--------------------------- 1 files changed, 2 insertions(+), 27 deletions(-)
arch/arm/plat-omap/gpio.c +2 -27
@@ -189,31 +189,6 @@ static int bank_width;/* TODO: Analyze removing gpio_bank_count usage from driver code */ int gpio_bank_count; -static inline struct gpio_bank *get_gpio_bank (int gpio) -{ -if (cpu_is_omap15xx ()) { -if (OMAP_GPIO_IS_MPUIO (gpio)) -return &gpio_bank[0 ]; -return &gpio_bank[1 ]; - } -if (cpu_is_omap16xx ()) { -if (OMAP_GPIO_IS_MPUIO (gpio)) -return &gpio_bank[0 ]; -return &gpio_bank[1 + (gpio >>4 )]; - } -if (cpu_is_omap7xx ()) { -if (OMAP_GPIO_IS_MPUIO (gpio)) -return &gpio_bank[0 ]; -return &gpio_bank[1 + (gpio >>5 )]; - } -if (cpu_is_omap24xx ()) -return &gpio_bank[gpio >>5 ]; -if (cpu_is_omap34xx () ||cpu_is_omap44xx ()) -return &gpio_bank[gpio >>5 ]; -BUG (); -return NULL ; -} -static inline int get_gpio_index (int gpio) {if (cpu_is_omap7xx ())
@@ -1393,7 +1368,7 @@ static struct platform_device omap_mpuio_device = {static inline void mpuio_init (void ) { -struct gpio_bank *bank =get_gpio_bank (OMAP_MPUIO (0 )); +struct gpio_bank *bank = &gpio_bank[0 ];platform_set_drvdata (&omap_mpuio_device, bank);if (platform_driver_register (&omap_mpuio_driver) ==0 )
@@ -1469,7 +1444,7 @@ static int gpio_get(struct gpio_chip *chip, unsigned offset)u32 mask; gpio = chip->base + offset; - bank =get_gpio_bank (gpio); + bank = container_of(chip, struct gpio_bank, chip); reg = bank->base; mask =1 <<get_gpio_index (gpio);
Signature · 1 line
1.7.1
RFC PATCH 3/18 OMAP: GPIO: Move gpio_get_index() to mach-omap
In reply to Charulatha Vgpio_get_index() uses cpu_is* checks. Move this function from plat-omap/gpio.c to SoC specific GPIO files in mach-omap*/ and use pdata to pass the function pointer.
--- arch/arm/mach-omap1/gpio15xx.c | 14 ++++++++++ arch/arm/mach-omap1/gpio16xx.c | 18 +++++++++++++- arch/arm/mach-omap1/gpio7xx.c | 18 +++++++++++++- arch/arm/mach-omap2/gpio.c | 12 +++++++++ arch/arm/plat-omap/gpio.c | 42 +++++++++++++------------------- arch/arm/plat-omap/include/plat/gpio.h | 5 ++++ 6 files changed, 82 insertions(+), 27 deletions(-)
arch/arm/mach-omap1/gpio15xx.c +14 -0
@@ -21,6 +21,8 @@#define OMAP1_MPUIO_VBASE OMAP1_MPUIO_BASE#define OMAP1510_GPIO_BASE 0xFFFCE000 +#define OMAP1510_GPIO_INDEX_MASK 0x0f +/* gpio1 */ static struct __initdata resource omap15xx_mpu_gpio_resources[] = { {
@@ -80,6 +82,15 @@ static struct __initdata platform_device omap15xx_gpio = { .resource = omap15xx_gpio_resources, }; +static int get_gpio_index (int gpio) +{ +return gpio &OMAP1510_GPIO_INDEX_MASK ; +} + +static struct omap_gpio_func gpio_fn = { + .get_index = get_gpio_index, +}; +/* * omap15xx_gpio_init needs to be done before * machine_init functions access gpio APIs.
@@ -90,7 +101,10 @@ static int __init omap15xx_gpio_init(void)if (!cpu_is_omap15xx ())return -EINVAL ; + omap15xx_gpio_config.gpio_fn = &gpio_fn;platform_device_register (&omap15xx_mpu_gpio); + + omap15xx_mpu_gpio_config.gpio_fn = &gpio_fn;platform_device_register (&omap15xx_gpio); gpio_bank_count =2 ;
arch/arm/mach-omap1/gpio16xx.c +17 -1
@@ -24,6 +24,8 @@#define OMAP1610_GPIO4_BASE 0xfffbbc00#define OMAP1_MPUIO_VBASE OMAP1_MPUIO_BASE +#define OMAP1610_GPIO_INDEX_MASK 0x0f +/* mpu gpio */ static struct __initdata resource omap16xx_mpu_gpio_resources[] = { {
@@ -178,6 +180,15 @@ static struct __initdata platform_device * omap16xx_gpio_dev[] = { &omap16xx_gpio4, }; +static int get_gpio_index (int gpio) +{ +return gpio &OMAP1610_GPIO_INDEX_MASK ; +} + +static struct omap_gpio_func gpio_fn = { + .get_index = get_gpio_index, +}; +/* * omap16xx_gpio_init needs to be done before * machine_init functions access gpio APIs.
@@ -190,8 +201,13 @@ static int __init omap16xx_gpio_init(void)if (!cpu_is_omap16xx ())return -EINVAL ; -for (i =0 ; i <ARRAY_SIZE (omap16xx_gpio_dev); i++) +for (i =0 ; i <ARRAY_SIZE (omap16xx_gpio_dev); i++) { +struct omap_gpio_platform_data *pdata; + + pdata = omap16xx_gpio_dev[i]->dev.platform_data; + pdata->gpio_fn = &gpio_fn;platform_device_register (omap16xx_gpio_dev[i]); + } gpio_bank_count =ARRAY_SIZE (omap16xx_gpio_dev);
arch/arm/mach-omap1/gpio7xx.c +17 -1
@@ -26,6 +26,8 @@#define OMAP7XX_GPIO6_BASE 0xfffbe800#define OMAP1_MPUIO_VBASE OMAP1_MPUIO_BASE +#define OMAP7XX_GPIO_INDEX_MASK 0x1f +/* mpu gpio */ static struct __initdata resource omap7xx_mpu_gpio_resources[] = { {
@@ -240,6 +242,15 @@ static struct __initdata platform_device * omap7xx_gpio_dev[] = { &omap7xx_gpio6, }; +static int get_gpio_index (int gpio) +{ +return gpio &OMAP7XX_GPIO_INDEX_MASK ; +} + +static struct omap_gpio_func gpio_fn = { + .get_index = get_gpio_index, +}; +/* * omap7xx_gpio_init needs to be done before * machine_init functions access gpio APIs.
@@ -252,8 +263,13 @@ static int __init omap7xx_gpio_init(void)if (!cpu_is_omap7xx ())return -EINVAL ; -for (i =0 ; i <ARRAY_SIZE (omap7xx_gpio_dev); i++) +for (i =0 ; i <ARRAY_SIZE (omap7xx_gpio_dev); i++) { +struct omap_gpio_platform_data *pdata; + + pdata = omap7xx_gpio_dev[i]->dev.platform_data; + pdata->gpio_fn = &gpio_fn;platform_device_register (omap7xx_gpio_dev[i]); + } gpio_bank_count =ARRAY_SIZE (omap7xx_gpio_dev);
arch/arm/mach-omap2/gpio.c +12 -0
@@ -24,6 +24,8 @@#include <plat/omap_hwmod.h> #include <plat/omap_device.h> +#define OMAP2_GPIO_INDEX_MASK 0x1f +static struct omap_device_pm_latency omap_gpio_latency[] = { [0 ] = { .deactivate_func = omap_device_idle_hwmods,
@@ -32,6 +34,15 @@ static struct omap_device_pm_latency omap_gpio_latency[] = { }, }; +static int get_gpio_index (int gpio) +{ +return gpio &OMAP2_GPIO_INDEX_MASK ; +} + +static struct omap_gpio_func gpio_fn = { + .get_index = get_gpio_index, +}; +static int omap2_gpio_dev_init (struct omap_hwmod *oh,void *unused) {struct omap_device *od;
@@ -60,6 +71,7 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused) pdata->bank_width = dev_attr->bank_width; pdata->dbck_flag = dev_attr->dbck_flag; pdata->virtual_irq_start =IH_GPIO_BASE +32 * (id -1 ); + pdata->gpio_fn = &gpio_fn;switch (oh->class->rev) {case 0 :
arch/arm/plat-omap/gpio.c +17 -25
137 lines not on this page · raw message
arch/arm/plat-omap/include/plat/gpio.h +5 -0
@@ -71,8 +71,13 @@ struct omap_gpio_dev_attr {bool dbck_flag;/* dbck required or not - True for OMAP3&4 */ }; +struct omap_gpio_func { +int (*get_index)(int gpio); +}; +struct omap_gpio_platform_data {u16 virtual_irq_start; +struct omap_gpio_func *gpio_fn;int bank_type;int bank_width;/* GPIO bank width */ int bank_stride;/* Only needed for omap1 MPUIO */
Signature · 1 line
1.7.1
RFC PATCH 3/18 OMAP: GPIO: Move gpio_get_index() to mach-omap
Quoted 5 lines · Charulatha V
gpio_get_index()uses cpu_is* checks. Move this function fromplat-omap/gpio.cto SoC specific GPIO files in mach-omap*/ and use pdata to pass the function pointer.Signed-off-by Charulatha V <[email protected]>
This one isn't really needed. The index should be calculated by using the bank width.
Below is a patch doing the same thing but using bitops and avoiding the need for pdata function pointers.
Kevin
RFC PATCH 4/18 OMAP: GPIO: Move gpio_valid() to SoC specific files
In reply to Charulatha Vgpio_valid() implementation is different for different SoCs. Hence handle them in SoC specific gpio files.
--- arch/arm/mach-omap1/gpio15xx.c | 26 ++++++++++++++++++++- arch/arm/mach-omap1/gpio16xx.c | 32 ++++++++++++++++++++++---- arch/arm/mach-omap1/gpio7xx.c | 38 ++++++++++++++++++++++++++------ arch/arm/mach-omap2/gpio.c | 14 +++++++++++- arch/arm/plat-omap/gpio.c | 27 +--------------------- arch/arm/plat-omap/include/plat/gpio.h | 1 + 6 files changed, 98 insertions(+), 40 deletions(-)
arch/arm/mach-omap1/gpio15xx.c +24 -2
@@ -22,6 +22,10 @@#define OMAP1510_GPIO_BASE 0xFFFCE000#define OMAP1510_GPIO_INDEX_MASK 0x0f +#define OMAP1510_GPIO_WIDTH 16 +#define OMAP1510_GPIO_BANK_CNT 2 +#define OMAP1510_NON_MPUIO_GPIO_VALID ((OMAP1510_GPIO_BANK_CNT - 1) *\ + OMAP1510_GPIO_WIDTH)/* gpio1 */ static struct __initdata resource omap15xx_mpu_gpio_resources[] = {
@@ -39,7 +43,7 @@ static struct __initdata resource omap15xx_mpu_gpio_resources[] = {static struct __initdata omap_gpio_platform_data omap15xx_mpu_gpio_config = { .virtual_irq_start =IH_MPUIO_BASE , .bank_type =METHOD_MPUIO , - .bank_width =16 , + .bank_width =OMAP1510_GPIO_WIDTH , .bank_stride =1 , };
@@ -69,7 +73,7 @@ static struct __initdata resource omap15xx_gpio_resources[] = {static struct __initdata omap_gpio_platform_data omap15xx_gpio_config = { .virtual_irq_start =IH_GPIO_BASE , .bank_type =METHOD_GPIO_1510 , - .bank_width =16 , + .bank_width =OMAP1510_GPIO_WIDTH , };static struct __initdata platform_device omap15xx_gpio = {
@@ -87,8 +91,26 @@ static int get_gpio_index(int gpio)return gpio &OMAP1510_GPIO_INDEX_MASK ; } +static int gpio_valid (int gpio) +{ +if (gpio <0 ) +return -EINVAL ; + +if (OMAP_GPIO_IS_MPUIO (gpio)) { +if (gpio >=OMAP_MAX_GPIO_LINES +OMAP1510_GPIO_WIDTH ) +return -EINVAL ; +return 0 ; + } + +if (gpio <OMAP1510_NON_MPUIO_GPIO_VALID ) +return 0 ; + +return -EINVAL ; +} +static struct omap_gpio_func gpio_fn = { .get_index = get_gpio_index, + .gpio_valid = gpio_valid, };/*
arch/arm/mach-omap1/gpio16xx.c +27 -5
@@ -25,6 +25,10 @@#define OMAP1_MPUIO_VBASE OMAP1_MPUIO_BASE#define OMAP1610_GPIO_INDEX_MASK 0x0f +#define OMAP1610_GPIO_WIDTH 16 +#define OMAP1610_GPIO_BANK_CNT 5 +#define OMAP1610_NON_MPUIO_GPIO_VALID ((OMAP1610_GPIO_BANK_CNT - 1) *\ + OMAP1610_GPIO_WIDTH)/* mpu gpio */ static struct __initdata resource omap16xx_mpu_gpio_resources[] = {
@@ -42,7 +46,7 @@ static struct __initdata resource omap16xx_mpu_gpio_resources[] = {static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = { .virtual_irq_start =IH_MPUIO_BASE , .bank_type =METHOD_MPUIO , - .bank_width =16 , + .bank_width =OMAP1610_GPIO_WIDTH , .bank_stride =1 , };
@@ -72,7 +76,7 @@ static struct __initdata resource omap16xx_gpio1_resources[] = {static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = { .virtual_irq_start =IH_GPIO_BASE , .bank_type =METHOD_GPIO_1610 , - .bank_width =16 , + .bank_width =OMAP1610_GPIO_WIDTH , };static struct __initdata platform_device omap16xx_gpio1 = {
@@ -101,7 +105,7 @@ static struct __initdata resource omap16xx_gpio2_resources[] = {static struct __initdata omap_gpio_platform_data omap16xx_gpio2_config = { .virtual_irq_start =IH_GPIO_BASE +16 , .bank_type =METHOD_GPIO_1610 , - .bank_width =16 , + .bank_width =OMAP1610_GPIO_WIDTH , };static struct __initdata platform_device omap16xx_gpio2 = {
@@ -130,7 +134,7 @@ static struct __initdata resource omap16xx_gpio3_resources[] = {static struct __initdata omap_gpio_platform_data omap16xx_gpio3_config = { .virtual_irq_start =IH_GPIO_BASE +32 , .bank_type =METHOD_GPIO_1610 , - .bank_width =16 , + .bank_width =OMAP1610_GPIO_WIDTH , };static struct __initdata platform_device omap16xx_gpio3 = {
@@ -159,7 +163,7 @@ static struct __initdata resource omap16xx_gpio4_resources[] = {static struct __initdata omap_gpio_platform_data omap16xx_gpio4_config = { .virtual_irq_start =IH_GPIO_BASE +48 , .bank_type =METHOD_GPIO_1610 , - .bank_width =16 , + .bank_width =OMAP1610_GPIO_WIDTH , };static struct __initdata platform_device omap16xx_gpio4 = {
@@ -185,8 +189,26 @@ static int get_gpio_index(int gpio)return gpio &OMAP1610_GPIO_INDEX_MASK ; } +static int gpio_valid (int gpio) +{ +if (gpio <0 ) +return -EINVAL ; + +if (OMAP_GPIO_IS_MPUIO (gpio)) { +if (gpio >=OMAP_MAX_GPIO_LINES +OMAP1610_GPIO_WIDTH ) +return -EINVAL ; +return 0 ; + } + +if (gpio <OMAP1610_NON_MPUIO_GPIO_VALID ) +return 0 ; + +return -EINVAL ; +} +static struct omap_gpio_func gpio_fn = { .get_index = get_gpio_index, + .gpio_valid = gpio_valid, };/*
arch/arm/mach-omap1/gpio7xx.c +31 -7
@@ -28,6 +28,12 @@#define OMAP7XX_GPIO_INDEX_MASK 0x1f +#define OMAP7XX_GPIO_WIDTH 32 +#define OMAP7XX_MPUIO_GPIO_PIN_CNT 16 +#define OMAP7XX_GPIO_BANK_CNT 7 +#define OMAP7XX_NON_MPUIO_GPIO_VALID ((OMAP7XX_GPIO_BANK_CNT - 1) *\ + OMAP7XX_GPIO_WIDTH) +/* mpu gpio */ static struct __initdata resource omap7xx_mpu_gpio_resources[] = { {
@@ -44,7 +50,7 @@ static struct __initdata resource omap7xx_mpu_gpio_resources[] = {static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = { .virtual_irq_start =IH_MPUIO_BASE , .bank_type =METHOD_MPUIO , - .bank_width =32 , + .bank_width =OMAP7XX_GPIO_WIDTH , .bank_stride =2 , };
@@ -74,7 +80,7 @@ static struct __initdata resource omap7xx_gpio1_resources[] = {static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config = { .virtual_irq_start =IH_GPIO_BASE , .bank_type =METHOD_GPIO_7XX , - .bank_width =32 , + .bank_width =OMAP7XX_GPIO_WIDTH , };static struct __initdata platform_device omap7xx_gpio1 = {
@@ -103,7 +109,7 @@ static struct __initdata resource omap7xx_gpio2_resources[] = {static struct __initdata omap_gpio_platform_data omap7xx_gpio2_config = { .virtual_irq_start =IH_GPIO_BASE +32 , .bank_type =METHOD_GPIO_7XX , - .bank_width =32 , + .bank_width =OMAP7XX_GPIO_WIDTH , };static struct __initdata platform_device omap7xx_gpio2 = {
@@ -132,7 +138,7 @@ static struct __initdata resource omap7xx_gpio3_resources[] = {static struct __initdata omap_gpio_platform_data omap7xx_gpio3_config = { .virtual_irq_start =IH_GPIO_BASE +64 , .bank_type =METHOD_GPIO_7XX , - .bank_width =32 , + .bank_width =OMAP7XX_GPIO_WIDTH , };static struct __initdata platform_device omap7xx_gpio3 = {
@@ -161,7 +167,7 @@ static struct __initdata resource omap7xx_gpio4_resources[] = {static struct __initdata omap_gpio_platform_data omap7xx_gpio4_config = { .virtual_irq_start =IH_GPIO_BASE +96 , .bank_type =METHOD_GPIO_7XX , - .bank_width =32 , + .bank_width =OMAP7XX_GPIO_WIDTH , };static struct __initdata platform_device omap7xx_gpio4 = {
@@ -190,7 +196,7 @@ static struct __initdata resource omap7xx_gpio5_resources[] = {static struct __initdata omap_gpio_platform_data omap7xx_gpio5_config = { .virtual_irq_start =IH_GPIO_BASE +128 , .bank_type =METHOD_GPIO_7XX , - .bank_width =32 , + .bank_width =OMAP7XX_GPIO_WIDTH , };static struct __initdata platform_device omap7xx_gpio5 = {
@@ -219,7 +225,7 @@ static struct __initdata resource omap7xx_gpio6_resources[] = {static struct __initdata omap_gpio_platform_data omap7xx_gpio6_config = { .virtual_irq_start =IH_GPIO_BASE +160 , .bank_type =METHOD_GPIO_7XX , - .bank_width =32 , + .bank_width =OMAP7XX_GPIO_WIDTH , };static struct __initdata platform_device omap7xx_gpio6 = {
@@ -247,8 +253,26 @@ static int get_gpio_index(int gpio)return gpio &OMAP7XX_GPIO_INDEX_MASK ; } +static int gpio_valid (int gpio) +{ +if (gpio <0 ) +return -EINVAL ; + +if (OMAP_GPIO_IS_MPUIO (gpio)) { +if (gpio >=OMAP_MAX_GPIO_LINES +OMAP7XX_MPUIO_GPIO_PIN_CNT ) +return -EINVAL ; +return 0 ; + } + +if (gpio <OMAP7XX_NON_MPUIO_GPIO_VALID ) +return 0 ; + +return -EINVAL ; +} +static struct omap_gpio_func gpio_fn = { .get_index = get_gpio_index, + .gpio_valid = gpio_valid, };/*
arch/arm/mach-omap2/gpio.c +13 -1
@@ -26,6 +26,8 @@#define OMAP2_GPIO_INDEX_MASK 0x1f +int bank_width; +static struct omap_device_pm_latency omap_gpio_latency[] = { [0 ] = { .deactivate_func = omap_device_idle_hwmods,
@@ -39,8 +41,17 @@ static int get_gpio_index(int gpio)return gpio &OMAP2_GPIO_INDEX_MASK ; } +static int gpio_valid (int gpio) +{ +if ((gpio >=0 ) && (gpio < (gpio_bank_count * bank_width))) +return 0 ; + +return -EINVAL ; +} +static struct omap_gpio_func gpio_fn = { .get_index = get_gpio_index, + .gpio_valid = gpio_valid, };static int omap2_gpio_dev_init (struct omap_hwmod *oh,void *unused)
@@ -68,7 +79,8 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused) } dev_attr = (struct omap_gpio_dev_attr *)oh->dev_attr; - pdata->bank_width = dev_attr->bank_width; + bank_width = dev_attr->bank_width; + pdata->bank_width = bank_width; pdata->dbck_flag = dev_attr->dbck_flag; pdata->virtual_irq_start =IH_GPIO_BASE +32 * (id -1 ); pdata->gpio_fn = &gpio_fn;
arch/arm/plat-omap/gpio.c +2 -25
@@ -190,33 +190,9 @@ static int bank_width;/* TODO: Analyze removing gpio_bank_count usage from driver code */ int gpio_bank_count; -static inline int gpio_valid (int gpio) -{ -if (gpio <0 ) -return -1 ; -if (cpu_class_is_omap1 () &&OMAP_GPIO_IS_MPUIO (gpio)) { -if (gpio >=OMAP_MAX_GPIO_LINES +16 ) -return -1 ; -return 0 ; - } -if (cpu_is_omap15xx () && gpio <16 ) -return 0 ; -if ((cpu_is_omap16xx ()) && gpio <64 ) -return 0 ; -if (cpu_is_omap7xx () && gpio <192 ) -return 0 ; -if (cpu_is_omap2420 () && gpio <128 ) -return 0 ; -if (cpu_is_omap2430 () && gpio <160 ) -return 0 ; -if ((cpu_is_omap34xx () ||cpu_is_omap44xx ()) && gpio <192 ) -return 0 ; -return -1 ; -} -static int check_gpio (int gpio) { -if (unlikely (gpio_valid (gpio) <0 )) { +if (unlikely (gpio_fn.gpio_valid (gpio) <0 )) {printk (KERN_ERR "omap-gpio: invalid GPIO %d\n" , gpio);dump_stack ();return -1 ;
@@ -1666,6 +1642,7 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev)mpuio_init (); gpio_fn.get_index = pdata->gpio_fn->get_index; + gpio_fn.gpio_valid = pdata->gpio_fn->gpio_valid; } id = pdev->id;
arch/arm/plat-omap/include/plat/gpio.h +1 -0
@@ -73,6 +73,7 @@ struct omap_gpio_dev_attr {struct omap_gpio_func {int (*get_index)(int gpio); +int (*gpio_valid)(int gpio); };struct omap_gpio_platform_data {
Signature · 1 line
1.7.1
RFC PATCH 4/18 OMAP: GPIO: Move gpio_valid() to SoC specific files
Quoted 4 lines · Charulatha V
gpio_valid()implementation is different for different SoCs. Hence handle them in SoC specific gpio files.Signed-off-by Charulatha V <[email protected]>
This one is only moving the mess into SoC-specific code.
Looking closer at the gpio_valid() (and check_gpio()) calls, they are actually pointless. These functions are only called in a few places, and where they are called, the GPIO has already been converted from an IRQ or masked, so these functions will never fail.
Kevin
Quoted 363 lines
--- arch/arm/mach-omap1/gpio15xx.c | 26 ++++++++++++++++++++- arch/arm/mach-omap1/gpio16xx.c | 32 ++++++++++++++++++++++---- arch/arm/mach-omap1/gpio7xx.c | 38 ++++++++++++++++++++++++++------ arch/arm/mach-omap2/gpio.c | 14 +++++++++++- arch/arm/plat-omap/gpio.c | 27 +--------------------- arch/arm/plat-omap/include/plat/gpio.h | 1 + 6 files changed, 98 insertions(+), 40 deletions(-)arch/arm/mach-omap1/gpio15xx.c +24
-2@@ -22,6 +22,10 @@#define OMAP1510_GPIO_BASE 0xFFFCE000#define OMAP1510_GPIO_INDEX_MASK 0x0f +#define OMAP1510_GPIO_WIDTH 16 +#define OMAP1510_GPIO_BANK_CNT 2 +#define OMAP1510_NON_MPUIO_GPIO_VALID ((OMAP1510_GPIO_BANK_CNT - 1) *\ + OMAP1510_GPIO_WIDTH)/* gpio1 */ static struct __initdata resource omap15xx_mpu_gpio_resources[] = {@@ -39,7 +43,7 @@ static struct __initdata resource omap15xx_mpu_gpio_resources[] = {static struct __initdata omap_gpio_platform_data omap15xx_mpu_gpio_config = { .virtual_irq_start =IH_MPUIO_BASE , .bank_type =METHOD_MPUIO , - .bank_width =16 , + .bank_width =OMAP1510_GPIO_WIDTH , .bank_stride =1 , };@@ -69,7 +73,7 @@ static struct __initdata resource omap15xx_gpio_resources[] = {static struct __initdata omap_gpio_platform_data omap15xx_gpio_config = { .virtual_irq_start =IH_GPIO_BASE , .bank_type =METHOD_GPIO_1510 , - .bank_width =16 , + .bank_width =OMAP1510_GPIO_WIDTH , };static struct __initdata platform_device omap15xx_gpio = {@@ -87,8 +91,26 @@ static int get_gpio_index(int gpio)return gpio &OMAP1510_GPIO_INDEX_MASK ; } +static int gpio_valid (int gpio) +{ +if (gpio <0 ) +return -EINVAL ; + +if (OMAP_GPIO_IS_MPUIO (gpio)) { +if (gpio >=OMAP_MAX_GPIO_LINES +OMAP1510_GPIO_WIDTH ) +return -EINVAL ; +return 0 ; + } + +if (gpio <OMAP1510_NON_MPUIO_GPIO_VALID ) +return 0 ; + +return -EINVAL ; +} +static struct omap_gpio_func gpio_fn = { .get_index = get_gpio_index, + .gpio_valid = gpio_valid, };/* arch/arm/mach-omap1/gpio16xx.c +27
-5@@ -25,6 +25,10 @@#define OMAP1_MPUIO_VBASE OMAP1_MPUIO_BASE#define OMAP1610_GPIO_INDEX_MASK 0x0f +#define OMAP1610_GPIO_WIDTH 16 +#define OMAP1610_GPIO_BANK_CNT 5 +#define OMAP1610_NON_MPUIO_GPIO_VALID ((OMAP1610_GPIO_BANK_CNT - 1) *\ + OMAP1610_GPIO_WIDTH)/* mpu gpio */ static struct __initdata resource omap16xx_mpu_gpio_resources[] = {@@ -42,7 +46,7 @@ static struct __initdata resource omap16xx_mpu_gpio_resources[] = {static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = { .virtual_irq_start =IH_MPUIO_BASE , .bank_type =METHOD_MPUIO , - .bank_width =16 , + .bank_width =OMAP1610_GPIO_WIDTH , .bank_stride =1 , };@@ -72,7 +76,7 @@ static struct __initdata resource omap16xx_gpio1_resources[] = {static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = { .virtual_irq_start =IH_GPIO_BASE , .bank_type =METHOD_GPIO_1610 , - .bank_width =16 , + .bank_width =OMAP1610_GPIO_WIDTH , };static struct __initdata platform_device omap16xx_gpio1 = {@@ -101,7 +105,7 @@ static struct __initdata resource omap16xx_gpio2_resources[] = {static struct __initdata omap_gpio_platform_data omap16xx_gpio2_config = { .virtual_irq_start =IH_GPIO_BASE +16 , .bank_type =METHOD_GPIO_1610 , - .bank_width =16 , + .bank_width =OMAP1610_GPIO_WIDTH , };static struct __initdata platform_device omap16xx_gpio2 = {@@ -130,7 +134,7 @@ static struct __initdata resource omap16xx_gpio3_resources[] = {static struct __initdata omap_gpio_platform_data omap16xx_gpio3_config = { .virtual_irq_start =IH_GPIO_BASE +32 , .bank_type =METHOD_GPIO_1610 , - .bank_width =16 , + .bank_width =OMAP1610_GPIO_WIDTH , };static struct __initdata platform_device omap16xx_gpio3 = {@@ -159,7 +163,7 @@ static struct __initdata resource omap16xx_gpio4_resources[] = {static struct __initdata omap_gpio_platform_data omap16xx_gpio4_config = { .virtual_irq_start =IH_GPIO_BASE +48 , .bank_type =METHOD_GPIO_1610 , - .bank_width =16 , + .bank_width =OMAP1610_GPIO_WIDTH , };static struct __initdata platform_device omap16xx_gpio4 = {@@ -185,8 +189,26 @@ static int get_gpio_index(int gpio)return gpio &OMAP1610_GPIO_INDEX_MASK ; } +static int gpio_valid (int gpio) +{ +if (gpio <0 ) +return -EINVAL ; + +if (OMAP_GPIO_IS_MPUIO (gpio)) { +if (gpio >=OMAP_MAX_GPIO_LINES +OMAP1610_GPIO_WIDTH ) +return -EINVAL ; +return 0 ; + } + +if (gpio <OMAP1610_NON_MPUIO_GPIO_VALID ) +return 0 ; + +return -EINVAL ; +} +static struct omap_gpio_func gpio_fn = { .get_index = get_gpio_index, + .gpio_valid = gpio_valid, };/* arch/arm/mach-omap1/gpio7xx.c +31
-7@@ -28,6 +28,12 @@#define OMAP7XX_GPIO_INDEX_MASK 0x1f +#define OMAP7XX_GPIO_WIDTH 32 +#define OMAP7XX_MPUIO_GPIO_PIN_CNT 16 +#define OMAP7XX_GPIO_BANK_CNT 7 +#define OMAP7XX_NON_MPUIO_GPIO_VALID ((OMAP7XX_GPIO_BANK_CNT - 1) *\ + OMAP7XX_GPIO_WIDTH) +/* mpu gpio */ static struct __initdata resource omap7xx_mpu_gpio_resources[] = { {@@ -44,7 +50,7 @@ static struct __initdata resource omap7xx_mpu_gpio_resources[] = {static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = { .virtual_irq_start =IH_MPUIO_BASE , .bank_type =METHOD_MPUIO , - .bank_width =32 , + .bank_width =OMAP7XX_GPIO_WIDTH , .bank_stride =2 , };@@ -74,7 +80,7 @@ static struct __initdata resource omap7xx_gpio1_resources[] = {static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config = { .virtual_irq_start =IH_GPIO_BASE , .bank_type =METHOD_GPIO_7XX , - .bank_width =32 , + .bank_width =OMAP7XX_GPIO_WIDTH , };static struct __initdata platform_device omap7xx_gpio1 = {@@ -103,7 +109,7 @@ static struct __initdata resource omap7xx_gpio2_resources[] = {static struct __initdata omap_gpio_platform_data omap7xx_gpio2_config = { .virtual_irq_start =IH_GPIO_BASE +32 , .bank_type =METHOD_GPIO_7XX , - .bank_width =32 , + .bank_width =OMAP7XX_GPIO_WIDTH , };static struct __initdata platform_device omap7xx_gpio2 = {@@ -132,7 +138,7 @@ static struct __initdata resource omap7xx_gpio3_resources[] = {static struct __initdata omap_gpio_platform_data omap7xx_gpio3_config = { .virtual_irq_start =IH_GPIO_BASE +64 , .bank_type =METHOD_GPIO_7XX , - .bank_width =32 , + .bank_width =OMAP7XX_GPIO_WIDTH , };static struct __initdata platform_device omap7xx_gpio3 = {@@ -161,7 +167,7 @@ static struct __initdata resource omap7xx_gpio4_resources[] = {static struct __initdata omap_gpio_platform_data omap7xx_gpio4_config = { .virtual_irq_start =IH_GPIO_BASE +96 , .bank_type =METHOD_GPIO_7XX , - .bank_width =32 , + .bank_width =OMAP7XX_GPIO_WIDTH , };static struct __initdata platform_device omap7xx_gpio4 = {@@ -190,7 +196,7 @@ static struct __initdata resource omap7xx_gpio5_resources[] = {static struct __initdata omap_gpio_platform_data omap7xx_gpio5_config = { .virtual_irq_start =IH_GPIO_BASE +128 , .bank_type =METHOD_GPIO_7XX , - .bank_width =32 , + .bank_width =OMAP7XX_GPIO_WIDTH , };static struct __initdata platform_device omap7xx_gpio5 = {@@ -219,7 +225,7 @@ static struct __initdata resource omap7xx_gpio6_resources[] = {static struct __initdata omap_gpio_platform_data omap7xx_gpio6_config = { .virtual_irq_start =IH_GPIO_BASE +160 , .bank_type =METHOD_GPIO_7XX , - .bank_width =32 , + .bank_width =OMAP7XX_GPIO_WIDTH , };static struct __initdata platform_device omap7xx_gpio6 = {@@ -247,8 +253,26 @@ static int get_gpio_index(int gpio)return gpio &OMAP7XX_GPIO_INDEX_MASK ; } +static int gpio_valid (int gpio) +{ +if (gpio <0 ) +return -EINVAL ; + +if (OMAP_GPIO_IS_MPUIO (gpio)) { +if (gpio >=OMAP_MAX_GPIO_LINES +OMAP7XX_MPUIO_GPIO_PIN_CNT ) +return -EINVAL ; +return 0 ; + } + +if (gpio <OMAP7XX_NON_MPUIO_GPIO_VALID ) +return 0 ; + +return -EINVAL ; +} +static struct omap_gpio_func gpio_fn = { .get_index = get_gpio_index, + .gpio_valid = gpio_valid, };/* arch/arm/mach-omap2/gpio.c +13
-1@@ -26,6 +26,8 @@#define OMAP2_GPIO_INDEX_MASK 0x1f +int bank_width; +static struct omap_device_pm_latency omap_gpio_latency[] = { [0 ] = { .deactivate_func = omap_device_idle_hwmods,@@ -39,8 +41,17 @@ static int get_gpio_index(int gpio)return gpio &OMAP2_GPIO_INDEX_MASK ; } +static int gpio_valid (int gpio) +{ +if ((gpio >=0 ) && (gpio < (gpio_bank_count * bank_width))) +return 0 ; + +return -EINVAL ; +} +static struct omap_gpio_func gpio_fn = { .get_index = get_gpio_index, + .gpio_valid = gpio_valid, };static int omap2_gpio_dev_init (struct omap_hwmod *oh,void *unused)@@ -68,7 +79,8 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused) } dev_attr = (struct omap_gpio_dev_attr *)oh->dev_attr; - pdata->bank_width = dev_attr->bank_width; + bank_width = dev_attr->bank_width; + pdata->bank_width = bank_width; pdata->dbck_flag = dev_attr->dbck_flag; pdata->virtual_irq_start =IH_GPIO_BASE +32 * (id -1 ); pdata->gpio_fn = &gpio_fn;arch/arm/plat-omap/gpio.c +2
-25@@ -190,33 +190,9 @@ static int bank_width;/* TODO: Analyze removing gpio_bank_count usage from driver code */ int gpio_bank_count; -static inline int gpio_valid (int gpio) -{ -if (gpio <0 ) -return -1 ; -if (cpu_class_is_omap1 () &&OMAP_GPIO_IS_MPUIO (gpio)) { -if (gpio >=OMAP_MAX_GPIO_LINES +16 ) -return -1 ; -return 0 ; - } -if (cpu_is_omap15xx () && gpio <16 ) -return 0 ; -if ((cpu_is_omap16xx ()) && gpio <64 ) -return 0 ; -if (cpu_is_omap7xx () && gpio <192 ) -return 0 ; -if (cpu_is_omap2420 () && gpio <128 ) -return 0 ; -if (cpu_is_omap2430 () && gpio <160 ) -return 0 ; -if ((cpu_is_omap34xx () ||cpu_is_omap44xx ()) && gpio <192 ) -return 0 ; -return -1 ; -} -static int check_gpio (int gpio) { -if (unlikely (gpio_valid (gpio) <0 )) { +if (unlikely (gpio_fn.gpio_valid (gpio) <0 )) {printk (KERN_ERR "omap-gpio: invalid GPIO %d\n" , gpio);dump_stack ();return -1 ;@@ -1666,6 +1642,7 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev)mpuio_init (); gpio_fn.get_index = pdata->gpio_fn->get_index; + gpio_fn.gpio_valid = pdata->gpio_fn->gpio_valid; } id = pdev->id;arch/arm/plat-omap/include/plat/gpio.h +1
-0@@ -73,6 +73,7 @@ struct omap_gpio_dev_attr {struct omap_gpio_func {int (*get_index)(int gpio); +int (*gpio_valid)(int gpio); };struct omap_gpio_platform_data {
RFC PATCH 5/18 OMAP: GPIO: cleanup datain,dataout,set dir funcs
In reply to Charulatha V* Define gpio register offsets in SoC specific GPIO files and use these register offsets while doing register read/write
* Remove the usage of CONFIG_ARCH_* checks and cpu_is* checks from the below functions
_set_gpio_direction
_set_gpio_dataout
_get_gpio_dataout
_get_gpio_datain
* MPUIO is a common gpio bank->method for OMAP15xx, OMAP16xx and OMAP7xx SoCs. Each of these SoCs has one bank with MPUIO type. Hence handle MPUIO type GPIO banks in GPIO driver.
Note: After the complete driver is cleaned up, the register offset macros defined in OMAP GPIO driver would be removed
--- arch/arm/mach-omap1/gpio15xx.c | 22 +++ arch/arm/mach-omap1/gpio16xx.c | 32 ++++ arch/arm/mach-omap1/gpio7xx.c | 21 +++ arch/arm/mach-omap2/gpio.c | 72 +++++++++ arch/arm/plat-omap/gpio.c | 261 ++++++++++---------------------- arch/arm/plat-omap/include/plat/gpio.h | 39 +++++ 6 files changed, 265 insertions(+), 182 deletions(-)
arch/arm/mach-omap1/gpio15xx.c +22 -0
@@ -27,6 +27,16 @@#define OMAP1510_NON_MPUIO_GPIO_VALID ((OMAP1510_GPIO_BANK_CNT - 1) *\ OMAP1510_GPIO_WIDTH) +static u16 reg_map[] = { + [DATAIN ] =0x00 , + [DATAOUT ] =0x04 , + [OE ] =0x08 , + [INT_CTRL ] =0x0C , + [IRQENABLE1 ] =0x10 , + [IRQSTATUS_REG0 ] =0x14 , + [CTRL ] =0x18 , +}; +/* gpio1 */ static struct __initdata resource omap15xx_mpu_gpio_resources[] = { {
@@ -86,6 +96,16 @@ static struct __initdata platform_device omap15xx_gpio = { .resource = omap15xx_gpio_resources, }; +static inline u32 gpio_read (void __iomem *base,int reg) +{ +return __raw_readl (base + reg_map[reg]); +} + +static inline void gpio_write (u32 val,void __iomem *base,int reg) +{ +__raw_writel (val, base + reg_map[reg]); +} +static int get_gpio_index (int gpio) {return gpio &OMAP1510_GPIO_INDEX_MASK ;
@@ -111,6 +131,8 @@ static int gpio_valid(int gpio)static struct omap_gpio_func gpio_fn = { .get_index = get_gpio_index, .gpio_valid = gpio_valid, + .gpio_read = gpio_read, + .gpio_write = gpio_write, };/*
arch/arm/mach-omap1/gpio16xx.c +32 -0
@@ -30,6 +30,26 @@#define OMAP1610_NON_MPUIO_GPIO_VALID ((OMAP1610_GPIO_BANK_CNT - 1) *\ OMAP1610_GPIO_WIDTH) +static u16 reg_map[] = { + [REV ] =0x00 , + [SYS_CFG ] =0x10 , + [SYS_STATUS ] =0x14 , + [IRQSTATUS_REG0 ] =0x18 , + [IRQENABLE1 ] =0x1C , + [WAKE_EN ] =0x28 , + [DATAIN ] =0x2C , + [DATAOUT ] =0x30 , + [OE ] =0x34 , + [EDGE_CTRL1 ] =0x38 , + [EDGE_CTRL2 ] =0x3C , + [CLEARIRQENA1 ] =0x9C , + [CLEARWKUENA ] =0xA8 , + [CLEARDATAOUT ] =0xB0 , + [SETIRQENA1 ] =0xDC , + [SETWKUENA ] =0xE8 , + [SETDATAOUT ] =0xF0 , +}; +/* mpu gpio */ static struct __initdata resource omap16xx_mpu_gpio_resources[] = { {
@@ -184,6 +204,16 @@ static struct __initdata platform_device * omap16xx_gpio_dev[] = { &omap16xx_gpio4, }; +static inline u32 gpio_read (void __iomem *base,int reg) +{ +return __raw_readl (base + reg_map[reg]); +} + +static inline void gpio_write (u32 val,void __iomem *base,int reg) +{ +__raw_writel (val, base + reg_map[reg]); +} +static int get_gpio_index (int gpio) {return gpio &OMAP1610_GPIO_INDEX_MASK ;
@@ -209,6 +239,8 @@ static int gpio_valid(int gpio)static struct omap_gpio_func gpio_fn = { .get_index = get_gpio_index, .gpio_valid = gpio_valid, + .gpio_read = gpio_read, + .gpio_write = gpio_write, };/*
arch/arm/mach-omap1/gpio7xx.c +21 -0
@@ -34,6 +34,15 @@#define OMAP7XX_NON_MPUIO_GPIO_VALID ((OMAP7XX_GPIO_BANK_CNT - 1) *\ OMAP7XX_GPIO_WIDTH) +static u16 reg_map[] = { + [DATAIN ] =0x00 , + [DATAOUT ] =0x04 , + [OE ] =0x08 , + [INT_CTRL ] =0x0C , + [IRQENABLE1 ] =0x10 , + [IRQSTATUS_REG0 ] =0x14 , +}; +/* mpu gpio */ static struct __initdata resource omap7xx_mpu_gpio_resources[] = { {
@@ -248,6 +257,16 @@ static struct __initdata platform_device * omap7xx_gpio_dev[] = { &omap7xx_gpio6, }; +static inline u32 gpio_read (void __iomem *base,int reg) +{ +return __raw_readl (base + reg_map[reg]); +} + +static inline void gpio_write (u32 val,void __iomem *base,int reg) +{ +__raw_writel (val, base + reg_map[reg]); +} +static int get_gpio_index (int gpio) {return gpio &OMAP7XX_GPIO_INDEX_MASK ;
@@ -273,6 +292,8 @@ static int gpio_valid(int gpio)static struct omap_gpio_func gpio_fn = { .get_index = get_gpio_index, .gpio_valid = gpio_valid, + .gpio_read = gpio_read, + .gpio_write = gpio_write, };/*
arch/arm/mach-omap2/gpio.c +72 -0
99 lines not on this page · raw message
arch/arm/plat-omap/gpio.c +79 -182
330 lines not on this page · raw message
arch/arm/plat-omap/include/plat/gpio.h +39 -0
@@ -66,6 +66,43 @@#define METHOD_GPIO_24XX 5#define METHOD_GPIO_44XX 6 +enum omap_gpio_reg_offsets { +/* Common Registers*/ +DATAIN ,DATAOUT , +/* Direction Control register/ Output Enable register */ +OE , +IRQSTATUS_REG0 , +/* Interrupt Mask/ Enable register */ +IRQENABLE1 , +CTRL , + +/* OMAP16xx & OMAP2PLUS specific */ +REV , +WAKE_EN , +CLEARIRQENA1 ,SETIRQENA1 , +CLEARWKUENA ,SETWKUENA , +CLEARDATAOUT ,SETDATAOUT , + +/* OMAP2PLUS specific */ +IRQSTATUS_REG1 ,IRQENABLE2 , +LEVELDETECT0 ,LEVELDETECT1 , +RISINGDETECT ,FALLINGDETECT , +DEBOUNCE_EN ,DEBOUNCE_VAL , + +/* OMAP4 specific */ +IRQWAKEN0 ,IRQWAKEN1 , +IRQSTATUSSET0 ,IRQSTATUSSET1 , +IRQSTATUSCLR0 ,IRQSTATUSCLR1 , +IRQSTATUSRAW0 ,IRQSTATUSRAW1 , + +/* OMAP15xx and OMAP7xx specific */ +INT_CTRL , + +/* OMAP16xx specific */ +SYS_CFG ,SYS_STATUS , +EDGE_CTRL1 ,EDGE_CTRL2 , +}; +struct omap_gpio_dev_attr {int bank_width;/* GPIO bank width */ bool dbck_flag;/* dbck required or not - True for OMAP3&4 */
@@ -74,6 +111,8 @@ struct omap_gpio_dev_attr {struct omap_gpio_func {int (*get_index)(int gpio);int (*gpio_valid)(int gpio); +u32 (*gpio_read)(void __iomem *base,int reg); +void (*gpio_write)(u32 val,void __iomem *base,int reg); };struct omap_gpio_platform_data {
Signature · 1 line
1.7.1
RFC PATCH 5/18 OMAP: GPIO: cleanup datain, dataout, set dir funcs
Quoted 12 lines · Charulatha V
* Define gpio register offsets in SoC specific GPIO files and use these register offsets while doing register read/write
* Remove the usage of CONFIG_ARCH_* checks and cpu_is* checks from the below functions
_set_gpio_direction
_set_gpio_dataout
_get_gpio_dataout
_get_gpio_datain
* MPUIO is a common gpiobank->methodfor OMAP15xx, OMAP16xx and OMAP7xx SoCs. Each of these SoCs has one bank with MPUIO type. Hence handle MPUIO type GPIO banks in GPIO driver.
Quoted 4 lines
Note: After the complete driver is cleaned up, the register offset macros defined in OMAP GPIO driver would be removed
Signed-off-by Charulatha V <[email protected]>
IMO, this isn't quite the direction we want to go for this cleanup.
Register offsets should indeed be in SoC specific files, but rather than the driver calling pdata function pointers for the functions, the register offsets should instead be passed into the driver so the driver can have common functions.
Also, MPUIO doesn't need to be treated as a special case. From the
GPIO driver perspective, it's just another GPIO bank. On some SoCs, it happens to have a different width and stride, but the drive should handle that.
I've also started on a GPIO cleanup (currently posted to linux-omap only) and I've taken a different approach.
After I finish reviewing your series, I'll have some more ideas on how we might combine our efforts here.
Kevin
RFC PATCH 6/18 OMAP: GPIO: cleanup set trigger func
In reply to Charulatha VCleanup GPIO set trigger and toggle edge triggering functions by removing the cpu_is checks and the CONFIG_ARCH_* checks .
Some part of the code access the gpio_bank structure which is specific to the OMAP GPIO driver. Therefore such part of the code are handled by means of gpio->method.
--- arch/arm/mach-omap1/gpio15xx.c | 17 ++ arch/arm/mach-omap1/gpio16xx.c | 37 +++++ arch/arm/mach-omap1/gpio7xx.c | 19 +++ arch/arm/mach-omap2/gpio.c | 31 ++++ arch/arm/plat-omap/gpio.c | 264 ++++++++++++-------------------- arch/arm/plat-omap/include/plat/gpio.h | 1 + 6 files changed, 201 insertions(+), 168 deletions(-)
arch/arm/mach-omap1/gpio15xx.c +17 -0
@@ -17,6 +17,7 @@*/ #include <linux/gpio.h> +#include <linux/irq.h> #define OMAP1_MPUIO_VBASE OMAP1_MPUIO_BASE#define OMAP1510_GPIO_BASE 0xFFFCE000
@@ -128,11 +129,27 @@ static int gpio_valid(int gpio)return -EINVAL ; } +static int gpio_set_trigger (void __iomem *base,int gpio,int trigger) +{ +u32 l =gpio_read (base,INT_CTRL ); + +if (trigger &IRQ_TYPE_EDGE_RISING ) + l |=1 << gpio; +else if (trigger &IRQ_TYPE_EDGE_FALLING ) + l &= ~(1 << gpio); +else +return -EINVAL ; + +gpio_write (l, base,INT_CTRL ); +return 0 ; +} +static struct omap_gpio_func gpio_fn = { .get_index = get_gpio_index, .gpio_valid = gpio_valid, .gpio_read = gpio_read, .gpio_write = gpio_write, + .gpio_set_trigger = gpio_set_trigger, };/*
arch/arm/mach-omap1/gpio16xx.c +37 -0
@@ -17,6 +17,7 @@*/ #include <linux/gpio.h> +#include <linux/irq.h> #define OMAP1610_GPIO1_BASE 0xfffbe400#define OMAP1610_GPIO2_BASE 0xfffbec00
@@ -30,6 +31,12 @@#define OMAP1610_NON_MPUIO_GPIO_VALID ((OMAP1610_GPIO_BANK_CNT - 1) *\ OMAP1610_GPIO_WIDTH) +#define OMAP1610_GPIO_USE_EDGE_CTRL2_REG 0x08 +#define OMAP1610_GPIO_SET_FALLING_EDGE 0x01 +#define OMAP1610_GPIO_SET_RISING_EDGE 0x02 +#define OMAP1610_GPIO_BOTH_EDGE_SET 0x03 +#define OMAP1610_GPIO_EDGE_MASK 0x07 +static u16 reg_map[] = { [REV ] =0x00 , [SYS_CFG ] =0x10 ,
@@ -236,11 +243,41 @@ static int gpio_valid(int gpio)return -EINVAL ; } +static int gpio_set_trigger (void __iomem *base,int gpio,int trigger) +{ +u32 offset; +u32 l =0 ; + +if (gpio &OMAP1610_GPIO_USE_EDGE_CTRL2_REG ) + offset =EDGE_CTRL2 ; +else + offset =EDGE_CTRL1 ; + + l =gpio_read (base, offset); + gpio &=OMAP1610_GPIO_EDGE_MASK ; + l &= ~(OMAP1610_GPIO_BOTH_EDGE_SET << (gpio <<1 )); + +if (trigger &IRQ_TYPE_EDGE_RISING ) + l |=OMAP1610_GPIO_SET_RISING_EDGE << (gpio <<1 ); +if (trigger &IRQ_TYPE_EDGE_FALLING ) + l |=OMAP1610_GPIO_SET_FALLING_EDGE << (gpio <<1 ); + +if (trigger) +/* Enable wake-up during idle for dynamic tick */ +gpio_write (1 << gpio, base,SETWKUENA ); +else +gpio_write (1 << gpio, base,CLEARWKUENA ); + +gpio_write (l, base, offset); +return 0 ; +} +static struct omap_gpio_func gpio_fn = { .get_index = get_gpio_index, .gpio_valid = gpio_valid, .gpio_read = gpio_read, .gpio_write = gpio_write, + .gpio_set_trigger = gpio_set_trigger, };/*
arch/arm/mach-omap1/gpio7xx.c +19 -0
@@ -17,6 +17,7 @@*/ #include <linux/gpio.h> +#include <linux/irq.h> #define OMAP7XX_GPIO1_BASE 0xfffbc000#define OMAP7XX_GPIO2_BASE 0xfffbc800
@@ -289,11 +290,29 @@ static int gpio_valid(int gpio)return -EINVAL ; } +static int gpio_set_trigger (void __iomem *base,int gpio,int trigger) +{ +u32 l =0 ; + + l =gpio_read (base,INT_CTRL ); + +if (trigger &IRQ_TYPE_EDGE_RISING ) + l |=1 << gpio; +else if (trigger &IRQ_TYPE_EDGE_FALLING ) + l &= ~(1 << gpio); +else +return -EINVAL ; + +gpio_write (l, base,INT_CTRL ); +return 0 ; +} +static struct omap_gpio_func gpio_fn = { .get_index = get_gpio_index, .gpio_valid = gpio_valid, .gpio_read = gpio_read, .gpio_write = gpio_write, + .gpio_set_trigger = gpio_set_trigger, };/*
arch/arm/mach-omap2/gpio.c +31 -0
@@ -16,6 +16,7 @@* GNU General Public License for more details. */ +#include <linux/irq.h> #include <linux/gpio.h> #include <linux/err.h> #include <linux/slab.h>
@@ -117,11 +118,41 @@ static int gpio_valid(int gpio)return -EINVAL ; } +static inline void modify_irq_type (void __iomem *base,u32 offset, +u32 bit_mask,u32 set) +{ +int l =gpio_read (base, offset); + +if (set) + l |= bit_mask; +else + l &= ~bit_mask; + +gpio_write (l, base, offset); +} + +static int gpio_set_trigger (void __iomem *base,int gpio,int trigger) +{ +u32 gpio_bit =1 << gpio; + +modify_irq_type (base,LEVELDETECT0 , gpio_bit, + trigger &IRQ_TYPE_LEVEL_LOW ); +modify_irq_type (base,LEVELDETECT1 , gpio_bit, + trigger &IRQ_TYPE_LEVEL_HIGH ); +modify_irq_type (base,RISINGDETECT , gpio_bit, + trigger &IRQ_TYPE_EDGE_RISING ); +modify_irq_type (base,FALLINGDETECT , gpio_bit, + trigger &IRQ_TYPE_EDGE_FALLING ); + +return 0 ; +} +static struct omap_gpio_func gpio_fn = { .get_index = get_gpio_index, .gpio_valid = gpio_valid, .gpio_read = gpio_read, .gpio_write = gpio_write, + .gpio_set_trigger = gpio_set_trigger, };static int omap2_gpio_dev_init (struct omap_hwmod *oh,void *unused)
arch/arm/plat-omap/gpio.c +96 -168
349 lines not on this page · raw message
arch/arm/plat-omap/include/plat/gpio.h +1 -0
@@ -113,6 +113,7 @@ struct omap_gpio_func {int (*gpio_valid)(int gpio);u32 (*gpio_read)(void __iomem *base,int reg);void (*gpio_write)(u32 val,void __iomem *base,int reg); +int (*gpio_set_trigger)(void __iomem *base,int gpio,int trigger); };struct omap_gpio_platform_data {
Signature · 1 line
1.7.1
RFC PATCH 7/18 OMAP: GPIO: cleanup set/get IRQ, clr irqstatus funcs
In reply to Charulatha VRemove the usage of CONFIG_ARCH* checks in the following functions of the GPIO driver and move SoC specific code to SoC specific files.
_enable_gpio_irqbank _get_gpio_irqbank_mask _clear_gpio_irqbank
--- arch/arm/mach-omap1/gpio15xx.c | 21 ++++ arch/arm/mach-omap1/gpio16xx.c | 16 +++ arch/arm/mach-omap1/gpio7xx.c | 20 ++++ arch/arm/mach-omap2/gpio.c | 26 +++++ arch/arm/plat-omap/gpio.c | 187 ++++++-------------------------- arch/arm/plat-omap/include/plat/gpio.h | 2 + 6 files changed, 116 insertions(+), 156 deletions(-)
arch/arm/mach-omap1/gpio15xx.c +21 -0
@@ -27,6 +27,7 @@#define OMAP1510_GPIO_BANK_CNT 2#define OMAP1510_NON_MPUIO_GPIO_VALID ((OMAP1510_GPIO_BANK_CNT - 1) *\ OMAP1510_GPIO_WIDTH) +#define OMAP1510_GPIO_IRQENA_MASK 0xffffstatic u16 reg_map[] = { [DATAIN ] =0x00 ,
@@ -144,12 +145,32 @@ static int gpio_set_trigger(void __iomem *base, int gpio, int trigger)return 0 ; } +static u32 gpio_is_irqena (void __iomem *base) +{ +return (~gpio_read (base,IRQENABLE1 )) + &OMAP1510_GPIO_IRQENA_MASK ; +} + +static void gpio_enable_irq (void __iomem *base,int gpio_mask,int enable) +{ +u32 l =gpio_read (base,IRQENABLE1 ); + +if (enable) + l &= ~(gpio_mask); +else + l |= gpio_mask; + +gpio_write (l, base,IRQENABLE1 ); +} +static struct omap_gpio_func gpio_fn = { .get_index = get_gpio_index, .gpio_valid = gpio_valid, .gpio_read = gpio_read, .gpio_write = gpio_write, .gpio_set_trigger = gpio_set_trigger, + .gpio_is_irqena = gpio_is_irqena, + .gpio_enable_irq = gpio_enable_irq, };/*
arch/arm/mach-omap1/gpio16xx.c +16 -0
@@ -30,6 +30,7 @@#define OMAP1610_GPIO_BANK_CNT 5#define OMAP1610_NON_MPUIO_GPIO_VALID ((OMAP1610_GPIO_BANK_CNT - 1) *\ OMAP1610_GPIO_WIDTH) +#define OMAP1610_GPIO_IRQENA_MASK 0xffff#define OMAP1610_GPIO_USE_EDGE_CTRL2_REG 0x08#define OMAP1610_GPIO_SET_FALLING_EDGE 0x01
@@ -272,12 +273,27 @@ static int gpio_set_trigger(void __iomem *base, int gpio, int trigger)return 0 ; } +static u32 gpio_is_irqena (void __iomem *base) +{ +return gpio_read (base,IRQENABLE1 ) &OMAP1610_GPIO_IRQENA_MASK ; +} + +static void gpio_enable_irq (void __iomem *base,int gpio_mask,int enable) +{ +if (enable) +gpio_write (gpio_mask, base,SETIRQENA1 ); +else +gpio_write (gpio_mask, base,CLEARIRQENA1 ); +} +static struct omap_gpio_func gpio_fn = { .get_index = get_gpio_index, .gpio_valid = gpio_valid, .gpio_read = gpio_read, .gpio_write = gpio_write, .gpio_set_trigger = gpio_set_trigger, + .gpio_is_irqena = gpio_is_irqena, + .gpio_enable_irq = gpio_enable_irq, };/*
arch/arm/mach-omap1/gpio7xx.c +20 -0
@@ -34,6 +34,7 @@#define OMAP7XX_GPIO_BANK_CNT 7#define OMAP7XX_NON_MPUIO_GPIO_VALID ((OMAP7XX_GPIO_BANK_CNT - 1) *\ OMAP7XX_GPIO_WIDTH) +#define OMAP7XX_GPIO_IRQENA_MASK 0xffffffffstatic u16 reg_map[] = { [DATAIN ] =0x00 ,
@@ -307,12 +308,31 @@ static int gpio_set_trigger(void __iomem *base, int gpio, int trigger)return 0 ; } +static u32 gpio_is_irqena (void __iomem *base) +{ +return (~gpio_read (base,IRQENABLE1 )) &OMAP7XX_GPIO_IRQENA_MASK ; +} + +static void gpio_enable_irq (void __iomem *base,int gpio_mask,int enable) +{ +u32 l =gpio_read (base,IRQENABLE1 ); + +if (enable) + l &= ~(gpio_mask); +else + l |= gpio_mask; + +gpio_write (l, base,IRQENABLE1 ); +} +static struct omap_gpio_func gpio_fn = { .get_index = get_gpio_index, .gpio_valid = gpio_valid, .gpio_read = gpio_read, .gpio_write = gpio_write, .gpio_set_trigger = gpio_set_trigger, + .gpio_is_irqena = gpio_is_irqena, + .gpio_enable_irq = gpio_enable_irq, };/*
arch/arm/mach-omap2/gpio.c +26 -0
@@ -26,6 +26,7 @@#include <plat/omap_device.h> #define OMAP2_GPIO_INDEX_MASK 0x1f +#define OMAP2_GPIO_IRQENA_MASK 0xffffffffint bank_width;static u16 *reg_map;
@@ -147,12 +148,37 @@ static int gpio_set_trigger(void __iomem *base, int gpio, int trigger)return 0 ; } +static u32 gpio_is_irqena (void __iomem *base) +{ +if (cpu_is_omap44xx ()) +return gpio_read (base,IRQSTATUSSET0 ) &OMAP2_GPIO_IRQENA_MASK ; +else +return gpio_read (base,IRQENABLE1 ) &OMAP2_GPIO_IRQENA_MASK ; +} + +static void gpio_enable_irq (void __iomem *base,int gpio_mask,int enable) +{ +if (cpu_is_omap44xx ()) { +if (enable) +return gpio_write (gpio_mask, base,IRQSTATUSSET0 ); +else +return gpio_write (gpio_mask, base,IRQSTATUSCLR0 ); + }else { +if (enable) +return gpio_write (gpio_mask, base,SETIRQENA1 ); +else +return gpio_write (gpio_mask, base,CLEARIRQENA1 ); + } +} +static struct omap_gpio_func gpio_fn = { .get_index = get_gpio_index, .gpio_valid = gpio_valid, .gpio_read = gpio_read, .gpio_write = gpio_write, .gpio_set_trigger = gpio_set_trigger, + .gpio_is_irqena = gpio_is_irqena, + .gpio_enable_irq = gpio_enable_irq, };static int omap2_gpio_dev_init (struct omap_hwmod *oh,void *unused)
arch/arm/plat-omap/gpio.c +31 -156
232 lines not on this page · raw message
arch/arm/plat-omap/include/plat/gpio.h +2 -0
@@ -114,6 +114,8 @@ struct omap_gpio_func {u32 (*gpio_read)(void __iomem *base,int reg);void (*gpio_write)(u32 val,void __iomem *base,int reg);int (*gpio_set_trigger)(void __iomem *base,int gpio,int trigger); +u32 (*gpio_is_irqena)(void__iomem *base); +void (*gpio_enable_irq)(void __iomem *base,int gpio_mask,int enable); };struct omap_gpio_platform_data {
Signature · 1 line
1.7.1
RFC PATCH 8/18 OMAP: GPIO: req/free: Remove reg offset macros usage
In reply to Charulatha VRemove the usage of register offset macros from
gpio_request/free() APIs.
Instead use the enum omap_gpio_reg_offsets and SoC specific gpio_read/write functions to access the GPIO registers.
--- arch/arm/plat-omap/gpio.c | 65 +++++++++++++------------------------------- 1 files changed, 19 insertions(+), 46 deletions(-)
arch/arm/plat-omap/gpio.c +19 -46
@@ -700,28 +700,17 @@ static int omap_gpio_request(struct gpio_chip *chip, unsigned offset)*/ _set_gpio_triggering (bank, offset,IRQ_TYPE_NONE ); -#ifdef CONFIG_ARCH_OMAP15XX if (bank->method ==METHOD_GPIO_1510 ) { -void __iomem *reg; -/* Claim the pin for MPU */ - reg = bank->base +OMAP1510_GPIO_PIN_CONTROL ; -__raw_writel (__raw_readl (reg) | (1 << offset), reg); +u32 ctrl = gpio_fn.gpio_read (bank->base,CTRL ); + gpio_fn.gpio_write (ctrl | (1 << offset), bank->base,CTRL ); } -#endif -if (!cpu_class_is_omap1 ()) { + +if (bank->method >=METHOD_GPIO_24XX ) {if (!bank->mod_usage) { -void __iomem *reg = bank->base; -u32 ctrl; - -if (cpu_is_omap24xx () ||cpu_is_omap34xx ()) - reg +=OMAP24XX_GPIO_CTRL ; -else if (cpu_is_omap44xx ()) - reg +=OMAP4_GPIO_CTRL ; - ctrl =__raw_readl (reg); +u32 ctrl = gpio_fn.gpio_read (bank->base,CTRL );/* Module is enabled, clocks are not gated */ - ctrl &=0xFFFFFFFE ; -__raw_writel (ctrl, reg); + gpio_fn.gpio_write (ctrl & ~0x1 , bank->base,CTRL ); } bank->mod_usage |=1 << offset; }
@@ -736,43 +725,27 @@ static void omap_gpio_free(struct gpio_chip *chip, unsigned offset)unsigned long flags;spin_lock_irqsave (&bank->lock, flags); -#ifdef CONFIG_ARCH_OMAP16XX -if (bank->method ==METHOD_GPIO_1610 ) { -/* Disable wake-up during idle for dynamic tick */ -void __iomem *reg = bank->base +OMAP1610_GPIO_CLEAR_WAKEUPENA ; -__raw_writel (1 << offset, reg); - } -#endif -#if defined(CONFIG_ARCH_OMAP2 ) || defined(CONFIG_ARCH_OMAP3 ) -if (bank->method ==METHOD_GPIO_24XX ) { + +if ((bank->method ==METHOD_GPIO_1610 ) || + (bank->method ==METHOD_GPIO_24XX )) {/* Disable wake-up during idle for dynamic tick */ -void __iomem *reg = bank->base +OMAP24XX_GPIO_CLEARWKUENA ; -__raw_writel (1 << offset, reg); - } -#endif -#ifdef CONFIG_ARCH_OMAP4 -if (bank->method ==METHOD_GPIO_44XX ) { + gpio_fn.gpio_write (1 << offset, bank->base,CLEARWKUENA ); + }else if (bank->method ==METHOD_GPIO_44XX ) {/* Disable wake-up during idle for dynamic tick */ -void __iomem *reg = bank->base +OMAP4_GPIO_IRQWAKEN0 ; -__raw_writel (1 << offset, reg); + gpio_fn.gpio_write (1 << offset, bank->base,IRQWAKEN0 ); } -#endif -if (!cpu_class_is_omap1 ()) { + + +if (bank->method >=METHOD_GPIO_24XX ) { bank->mod_usage &= ~(1 << offset); +if (!bank->mod_usage) { -void __iomem *reg = bank->base; -u32 ctrl; - -if (cpu_is_omap24xx () ||cpu_is_omap34xx ()) - reg +=OMAP24XX_GPIO_CTRL ; -else if (cpu_is_omap44xx ()) - reg +=OMAP4_GPIO_CTRL ; - ctrl =__raw_readl (reg); +u32 ctrl = gpio_fn.gpio_read (bank->base,CTRL );/* Module is disabled, clocks are gated */ - ctrl |=1 ; -__raw_writel (ctrl, reg); + gpio_fn.gpio_write (ctrl |1 , bank->base,CTRL ); } } +_reset_gpio (bank, bank->chip.base + offset);spin_unlock_irqrestore (&bank->lock, flags); }
Signature · 1 line
1.7.1
RFC PATCH 9/18 OMAP: GPIO: cleanup gpio_irq_handler
In reply to Charulatha VRemove CONFIG_ARCH_OMAP* checks from gpio_irq_handler.
Also correct the multi-line comment style in thegpio_irq_handler.
--- arch/arm/plat-omap/gpio.c | 70 +++++++++++++++++--------------------------- 1 files changed, 27 insertions(+), 43 deletions(-)
arch/arm/plat-omap/gpio.c +27 -43
@@ -761,7 +761,7 @@ static void omap_gpio_free(struct gpio_chip *chip, unsigned offset)*/ static void gpio_irq_handler (unsigned int irq,struct irq_desc *desc) { -void __iomem *isr_reg =NULL ; +u32 isr_val;u32 isr;unsigned int gpio_irq, gpio_index;struct gpio_bank *bank;
@@ -771,58 +771,41 @@ static void gpio_irq_handler(unsigned int irq, struct irq_desc *desc) desc->irq_data.chip->irq_ack (&desc->irq_data); bank =irq_get_handler_data (irq); -#ifdef CONFIG_ARCH_OMAP1 -if (bank->method ==METHOD_MPUIO ) - isr_reg = bank->base + -OMAP_MPUIO_GPIO_INT / bank->stride; -#endif -#ifdef CONFIG_ARCH_OMAP15XX -if (bank->method ==METHOD_GPIO_1510 ) - isr_reg = bank->base +OMAP1510_GPIO_INT_STATUS ; -#endif -#if defined(CONFIG_ARCH_OMAP16XX ) -if (bank->method ==METHOD_GPIO_1610 ) - isr_reg = bank->base +OMAP1610_GPIO_IRQSTATUS1 ; -#endif -#if defined(CONFIG_ARCH_OMAP730 ) || defined(CONFIG_ARCH_OMAP850 ) -if (bank->method ==METHOD_GPIO_7XX ) - isr_reg = bank->base +OMAP7XX_GPIO_INT_STATUS ; -#endif -#if defined(CONFIG_ARCH_OMAP2 ) || defined(CONFIG_ARCH_OMAP3 ) -if (bank->method ==METHOD_GPIO_24XX ) - isr_reg = bank->base +OMAP24XX_GPIO_IRQSTATUS1 ; -#endif -#if defined(CONFIG_ARCH_OMAP4 ) -if (bank->method ==METHOD_GPIO_44XX ) - isr_reg = bank->base +OMAP4_GPIO_IRQSTATUS0 ; -#endif - -if (WARN_ON (!isr_reg)) - goto exit;while (1 ) {u32 isr_saved, level_mask =0 ;u32 enabled; +if (bank->method ==METHOD_MPUIO ) + isr_val =gpio_mpuio_read (bank->base, +OMAP_MPUIO_GPIO_INT / bank->stride); +else + isr_val = gpio_fn.gpio_read (bank->base,IRQSTATUS_REG0 ); + enabled =_get_gpio_irqbank_mask (bank); - isr_saved = isr =__raw_readl (isr_reg) & enabled; + isr = isr_val & enabled; + isr_saved = isr; -if (cpu_is_omap15xx () && (bank->method ==METHOD_MPUIO )) +/* Common for all MPUIO banks */ +if (bank->method ==METHOD_MPUIO ) isr &=0x0000ffff ; -if (cpu_class_is_omap2 ()) { +if (bank->method >=METHOD_GPIO_24XX ) level_mask = bank->level_mask & enabled; - } -/* clear edge sensitive interrupts before handler(s) are -called so that we don't miss any interrupt occurred while -executing them */ +/* +* clear edge sensitive interrupts before handler(s) are +* called so that we don't miss any interrupt occurred +* while executing them +*/ _enable_gpio_irqbank (bank, isr_saved & ~level_mask,0 );_clear_gpio_irqbank (bank, isr_saved & ~level_mask);_enable_gpio_irqbank (bank, isr_saved & ~level_mask,1 ); -/* if there is only edge sensitive GPIO pin interrupts -configured, we could unmask GPIO bank interrupt immediately */ +/* +* if there is only edge sensitive GPIO pin interrupts +* configured, we could unmask GPIO bank interrupt immediately +*/ if (!level_mask && !unmasked) { unmasked =1 ; desc->irq_data.chip->irq_unmask (&desc->irq_data);
@@ -853,11 +836,12 @@ static void gpio_irq_handler(unsigned int irq, struct irq_desc *desc)generic_handle_irq (gpio_irq); } } -/* if bank has any level sensitive GPIO pin interrupt -configured, we must unmask the bank interrupt only after -handler(s) are executed in order to avoid spurious bank -interrupt */ -exit: +/* +* if bank has any level sensitive GPIO pin interrupt +* configured, we must unmask the bank interrupt only after +* handler(s) are executed in order to avoid spurious bank +* interrupt +*/ if (!unmasked) desc->irq_data.chip->irq_unmask (&desc->irq_data); }
Signature · 1 line
1.7.1
RFC PATCH 10/18 OMAP: GPIO: cleanup set wakeup/suspend/resume funcs
In reply to Charulatha VAvoid the usage of cpu_is* checks and CONFIG_ARCH_OMAP* checks from _set_gpio_wakeup and gpio suspend/resume functions.
--- arch/arm/plat-omap/gpio.c | 109 ++++++++++++++------------------------------- 1 files changed, 33 insertions(+), 76 deletions(-)
arch/arm/plat-omap/gpio.c +33 -76
@@ -30,6 +30,7 @@#include <mach/gpio.h> #include <asm/mach/irq.h> +#define OMAP_GPIO_WAKE_SET_CLR_ALL 0xffffffff#define MPUIO_GPIO_IRQENA_MASK 0xffff/* * OMAP1510 GPIO registers
@@ -140,10 +141,8 @@ struct gpio_bank {u16 irq;u16 virtual_irq_start;int method; -#if defined(CONFIG_ARCH_OMAP16XX ) || defined(CONFIG_ARCH_OMAP2PLUS )u32 suspend_wakeup;u32 saved_wakeup; -#endif u32 non_wakeup_gpios;u32 enabled_non_wakeup_gpios;
@@ -630,18 +629,6 @@ static int _set_gpio_wakeup(struct gpio_bank *bank, int gpio, int enable)unsigned long uninitialized_var (flags );switch (bank->method) { -#ifdef CONFIG_ARCH_OMAP16XX -case METHOD_MPUIO : -case METHOD_GPIO_1610 : -spin_lock_irqsave (&bank->lock, flags); -if (enable) - bank->suspend_wakeup |= (1 << gpio); -else - bank->suspend_wakeup &= ~(1 << gpio); -spin_unlock_irqrestore (&bank->lock, flags); -return 0 ; -#endif -#ifdef CONFIG_ARCH_OMAP2PLUS case METHOD_GPIO_24XX :case METHOD_GPIO_44XX :if (bank->non_wakeup_gpios & (1 << gpio)) {
@@ -650,6 +637,8 @@ static int _set_gpio_wakeup(struct gpio_bank *bank, int gpio, int enable) (bank - gpio_bank) * 32 + gpio);return -EINVAL ; } +case METHOD_MPUIO : +case METHOD_GPIO_1610 :spin_lock_irqsave (&bank->lock, flags);if (enable) bank->suspend_wakeup |= (1 << gpio);
@@ -657,7 +646,6 @@ static int _set_gpio_wakeup(struct gpio_bank *bank, int gpio, int enable) bank->suspend_wakeup &= ~(1 << gpio);spin_unlock_irqrestore (&bank->lock, flags);return 0 ; -#endif default :printk (KERN_ERR "Can't enable GPIO wakeup for method %i\n" , bank->method);
@@ -1347,51 +1335,35 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev)return 0 ; } -#if defined(CONFIG_ARCH_OMAP16XX ) || defined(CONFIG_ARCH_OMAP2PLUS )static int omap_gpio_suspend (struct sys_device *dev,pm_message_t mesg) {int i; -if (!cpu_class_is_omap2 () && !cpu_is_omap16xx ()) -return 0 ; -for (i =0 ; i < gpio_bank_count; i++) {struct gpio_bank *bank = &gpio_bank[i]; -void __iomem *wake_status; -void __iomem *wake_clear; -void __iomem *wake_set; +u32 wake_status; +u32 wake_clear; +u32 wake_set;unsigned long flags; -switch (bank->method) { -#ifdef CONFIG_ARCH_OMAP16XX -case METHOD_GPIO_1610 : - wake_status = bank->base +OMAP1610_GPIO_WAKEUPENABLE ; - wake_clear = bank->base +OMAP1610_GPIO_CLEAR_WAKEUPENA ; - wake_set = bank->base +OMAP1610_GPIO_SET_WAKEUPENA ; +if ((bank->method <=METHOD_GPIO_1510 ) || + (bank->method ==METHOD_GPIO_7XX )) {break ; -#endif -#if defined(CONFIG_ARCH_OMAP2 ) || defined(CONFIG_ARCH_OMAP3 ) -case METHOD_GPIO_24XX : - wake_status = bank->base +OMAP24XX_GPIO_WAKE_EN ; - wake_clear = bank->base +OMAP24XX_GPIO_CLEARWKUENA ; - wake_set = bank->base +OMAP24XX_GPIO_SETWKUENA ; -break ; -#endif -#ifdef CONFIG_ARCH_OMAP4 -case METHOD_GPIO_44XX : - wake_status = bank->base +OMAP4_GPIO_IRQWAKEN0 ; - wake_clear = bank->base +OMAP4_GPIO_IRQWAKEN0 ; - wake_set = bank->base +OMAP4_GPIO_IRQWAKEN0 ; -break ; -#endif -default : -continue ; + }else if (bank->method ==METHOD_GPIO_44XX ) { + wake_status =IRQWAKEN0 ; + wake_clear =IRQWAKEN0 ; + wake_set =IRQWAKEN0 ; + }else { + wake_status =WAKE_EN ; + wake_clear =CLEARWKUENA ; + wake_set =SETWKUENA ; }spin_lock_irqsave (&bank->lock, flags); - bank->saved_wakeup =__raw_readl (wake_status); -__raw_writel (0xffffffff , wake_clear); -__raw_writel (bank->suspend_wakeup, wake_set); + bank->saved_wakeup = gpio_fn.gpio_read (bank->base, wake_status); + gpio_fn.gpio_write (OMAP_GPIO_WAKE_SET_CLR_ALL , bank->base, + wake_clear); + gpio_fn.gpio_write (bank->suspend_wakeup, bank->base, wake_set);spin_unlock_irqrestore (&bank->lock, flags); }
@@ -1402,41 +1374,27 @@ static int omap_gpio_resume(struct sys_device *dev) {int i; -if (!cpu_class_is_omap2 () && !cpu_is_omap16xx ()) -return 0 ; -for (i =0 ; i < gpio_bank_count; i++) {struct gpio_bank *bank = &gpio_bank[i]; -void __iomem *wake_clear; -void __iomem *wake_set; +u32 wake_clear; +u32 wake_set;unsigned long flags; -switch (bank->method) { -#ifdef CONFIG_ARCH_OMAP16XX -case METHOD_GPIO_1610 : - wake_clear = bank->base +OMAP1610_GPIO_CLEAR_WAKEUPENA ; - wake_set = bank->base +OMAP1610_GPIO_SET_WAKEUPENA ; +if ((bank->method <=METHOD_GPIO_1510 ) || + (bank->method ==METHOD_GPIO_7XX )) {break ; -#endif -#if defined(CONFIG_ARCH_OMAP2 ) || defined(CONFIG_ARCH_OMAP3 ) -case METHOD_GPIO_24XX : - wake_clear = bank->base +OMAP24XX_GPIO_CLEARWKUENA ; - wake_set = bank->base +OMAP24XX_GPIO_SETWKUENA ; -break ; -#endif -#ifdef CONFIG_ARCH_OMAP4 -case METHOD_GPIO_44XX : - wake_clear = bank->base +OMAP4_GPIO_IRQWAKEN0 ; - wake_set = bank->base +OMAP4_GPIO_IRQWAKEN0 ; -break ; -#endif -default : -continue ; + }else if (bank->method ==METHOD_GPIO_44XX ) { + wake_clear =IRQWAKEN0 ; + wake_set =IRQWAKEN0 ; + }else { + wake_clear =CLEARWKUENA ; + wake_set =SETWKUENA ; }spin_lock_irqsave (&bank->lock, flags); -__raw_writel (0xffffffff , wake_clear); -__raw_writel (bank->saved_wakeup, wake_set); + gpio_fn.gpio_write (OMAP_GPIO_WAKE_SET_CLR_ALL , bank->base, + wake_clear); + gpio_fn.gpio_write (bank->saved_wakeup, bank->base, wake_set);spin_unlock_irqrestore (&bank->lock, flags); }
@@ -1454,7 +1412,6 @@ static struct sys_device omap_gpio_device = { .cls = &omap_gpio_sysclass, }; -#endif #ifdef CONFIG_ARCH_OMAP2PLUS
Signature · 1 line
1.7.1
RFC PATCH 11/18 OMAP: GPIO: Remove dependency on gpio_bank_count
In reply to Charulatha Vgpio_bank_count is the count of number of GPIO devices in a SoC. Remove this dependency from the driver. Also remove the dependency on array of pointers to gpio_bank struct of all GPIO devices.
The cpu_is*() checks used in omap2_gpio_prepare_for_idle() and omap2_gpio_resume_after_idle() would be removed in one of the patches in this series
--- arch/arm/mach-omap1/gpio15xx.c | 1 - arch/arm/mach-omap1/gpio16xx.c | 2 - arch/arm/mach-omap1/gpio7xx.c | 2 - arch/arm/mach-omap2/gpio.c | 1 + arch/arm/plat-omap/gpio.c | 165 ++++++++++++++++---------------- arch/arm/plat-omap/include/plat/gpio.h | 3 - 6 files changed, 83 insertions(+), 91 deletions(-)
arch/arm/mach-omap1/gpio15xx.c +0 -1
@@ -189,7 +189,6 @@ static int __init omap15xx_gpio_init(void) omap15xx_mpu_gpio_config.gpio_fn = &gpio_fn;platform_device_register (&omap15xx_gpio); - gpio_bank_count =2 ;return 0 ; }postcore_initcall (omap15xx_gpio_init);
arch/arm/mach-omap1/gpio16xx.c +0 -2
@@ -316,8 +316,6 @@ static int __init omap16xx_gpio_init(void)platform_device_register (omap16xx_gpio_dev[i]); } - gpio_bank_count =ARRAY_SIZE (omap16xx_gpio_dev); -return 0 ; }postcore_initcall (omap16xx_gpio_init);
arch/arm/mach-omap1/gpio7xx.c +0 -2
@@ -355,8 +355,6 @@ static int __init omap7xx_gpio_init(void)platform_device_register (omap7xx_gpio_dev[i]); } - gpio_bank_count =ARRAY_SIZE (omap7xx_gpio_dev); -return 0 ; }postcore_initcall (omap7xx_gpio_init);
arch/arm/mach-omap2/gpio.c +1 -0
@@ -28,6 +28,7 @@#define OMAP2_GPIO_INDEX_MASK 0x1f#define OMAP2_GPIO_IRQENA_MASK 0xffffffff +int gpio_bank_count;int bank_width;static u16 *reg_map;static u16 omap2_gpio_reg_offsets[] = {
arch/arm/plat-omap/gpio.c +82 -83
316 lines not on this page · raw message
arch/arm/plat-omap/include/plat/gpio.h +0 -3
@@ -127,9 +127,6 @@ struct omap_gpio_platform_data {bool dbck_flag;/* dbck required or not - True for OMAP3&4 */ }; -/* TODO: Analyze removing gpio_bank_count usage from driver code */ -extern int gpio_bank_count; -extern void omap2_gpio_prepare_for_idle (int off_mode);extern void omap2_gpio_resume_after_idle (void );extern void omap_set_gpio_debounce (int gpio,int enable);
Signature · 1 line
1.7.1
RFC PATCH 11/18 OMAP: GPIO: Remove dependency on gpio_bank_count
Quoted 62 lines · Charulatha V
gpio_bank_countis the count of number of GPIO devices in a SoC. Remove this dependency from the driver. Also remove the dependency on array of pointers togpio_bankstruct of all GPIO devices.The cpu_is*() checks used in
omap2_gpio_prepare_for_idle()andomap2_gpio_resume_after_idle()would be removed in one of the patches in this seriesSigned-off-by Charulatha V <[email protected]>--- arch/arm/mach-omap1/gpio15xx.c | 1 - arch/arm/mach-omap1/gpio16xx.c | 2 - arch/arm/mach-omap1/gpio7xx.c | 2 - arch/arm/mach-omap2/gpio.c | 1 + arch/arm/plat-omap/gpio.c | 165 ++++++++++++++++---------------- arch/arm/plat-omap/include/plat/gpio.h | 3 - 6 files changed, 83 insertions(+), 91 deletions(-)arch/arm/mach-omap1/gpio15xx.c +0
-1@@ -189,7 +189,6 @@ static int __init omap15xx_gpio_init(void) omap15xx_mpu_gpio_config.gpio_fn = &gpio_fn;platform_device_register (&omap15xx_gpio); - gpio_bank_count =2 ;return 0 ; }postcore_initcall (omap15xx_gpio_init);arch/arm/mach-omap1/gpio16xx.c +0
-2@@ -316,8 +316,6 @@ static int __init omap16xx_gpio_init(void)platform_device_register (omap16xx_gpio_dev[i]); } - gpio_bank_count =ARRAY_SIZE (omap16xx_gpio_dev); -return 0 ; }postcore_initcall (omap16xx_gpio_init);arch/arm/mach-omap1/gpio7xx.c +0
-2@@ -355,8 +355,6 @@ static int __init omap7xx_gpio_init(void)platform_device_register (omap7xx_gpio_dev[i]); } - gpio_bank_count =ARRAY_SIZE (omap7xx_gpio_dev); -return 0 ; }postcore_initcall (omap7xx_gpio_init);arch/arm/mach-omap2/gpio.c +0
-0
arch/arm/mach-omap2/gpio.c line 31
Quoted 4 lines
arch/arm/mach-omap2/gpio.c +1
-0@@ -28,6 +28,7 @@#define OMAP2_GPIO_INDEX_MASK 0x1f#define OMAP2_GPIO_IRQENA_MASK 0xffffffff +int gpio_bank_count;
Why is this needed here?
Quoted 3 lines
arch/arm/mach-omap2/gpio.c +0
-0int bank_width;static u16 *reg_map;static u16 omap2_gpio_reg_offsets[] = {
[...]
arch/arm/mach-omap2/gpio.c
Quoted 13 lines
void
omap2_gpio_prepare_for_idle(int off_mode)
{arch/arm/mach-omap2/gpio.c +3
-7-int i, c =0 ; -int min =0 ; - -if (cpu_is_omap34xx ()) - min =1 ; +int c =0 ; +struct gpio_bank *bank; -for (i = min; i < gpio_bank_count; i++) { -struct gpio_bank *bank = &gpio_bank[i]; +list_for_each_entry (bank, &omap_gpio_list, node) {
Note that on 34xx, this isn't an equivalent functional change, since the for loop starts a 1 and the list traversal covers all banks.
I think your powerdomain 'can lose context' patch is needed before this one.
Kevin
RFC PATCH 12/18 OMAP: GPIO: cleanup set_debounce, idle/resume_after_idle
In reply to Charulatha Vgpio_set_debounce(), gpio_prepare_for_idle() and gpio_resume_after_idle() are specific to OMAP2PLUS CPUs. These functions rely on "dbck_enable_mask" which is part of GPIO bank structure.
The above mentioned functions are moved to mach-omap2/gpio.c and the required information is passed from the OMAP GPIO driver.
--- arch/arm/mach-omap2/gpio.c | 201 ++++++++++++++++++++++++++++- arch/arm/plat-omap/gpio.c | 223 +++----------------------------- arch/arm/plat-omap/include/plat/gpio.h | 6 + 3 files changed, 222 insertions(+), 208 deletions(-)
arch/arm/mach-omap2/gpio.c +199 -2
@@ -21,13 +21,31 @@#include <linux/err.h> #include <linux/slab.h> #include <linux/interrupt.h> +#include <linux/clk.h> #include <plat/omap_hwmod.h> #include <plat/omap_device.h> #define OMAP2_GPIO_INDEX_MASK 0x1f#define OMAP2_GPIO_IRQENA_MASK 0xffffffff +#define OMAP2_GPIO_DEBOUNCE_MIN_CHK 32 +#define OMAP2_GPIO_DEBOUNCE_MAX_CHK 7936 +#define OMAP2_GPIO_DEBOUNCE_MIN_VAL 0x01 +#define OMAP2_GPIO_DEBOUNCE_MAX_VAL 0xff +#define OMAP2_GPIO_DEBOUNCE_VAL_DIV 0x1f +struct gpio_state { +struct list_head node; +u32 saved_datain; +u32 saved_fallingdetect; +u32 saved_risingdetect; +u32 dbck_enable_mask; +struct clk *dbck; +u16 id; +}; + +static int workaround_enabled; +static LIST_HEAD (omap_gpio_ctx_list);int gpio_bank_count;int bank_width;static u16 *reg_map;
@@ -172,6 +190,161 @@ static void gpio_enable_irq(void __iomem *base, int gpio_mask, int enable) } } +static void gpio_debounce_set (void __iomem *base,unsigned gpio, +unsigned debounce,u16 id) +{ +u32 val; +u32 l =0 ; +struct gpio_state *gpio_dev_state; + +if (debounce <OMAP2_GPIO_DEBOUNCE_MIN_CHK ) + debounce =OMAP2_GPIO_DEBOUNCE_MIN_VAL ; +else if (debounce >OMAP2_GPIO_DEBOUNCE_MAX_CHK ) + debounce =OMAP2_GPIO_DEBOUNCE_MAX_VAL ; +else + debounce = (debounce /OMAP2_GPIO_DEBOUNCE_VAL_DIV ) -1 ; + +gpio_write (debounce, base,DEBOUNCE_VAL ); + + val =gpio_read (base,DEBOUNCE_EN ); + l =1 <<get_gpio_index (gpio); + +list_for_each_entry (gpio_dev_state, &omap_gpio_ctx_list, node) { +if (gpio_dev_state->id == id) { +if (debounce) { + val |= l; +clk_enable (gpio_dev_state->dbck); + }else { + val &= ~l; +clk_disable (gpio_dev_state->dbck); + } + gpio_dev_state->dbck_enable_mask = val; +gpio_write (val, base,DEBOUNCE_EN ); + } + } +} + +static void gpio_prepare_for_idle (u32 enabled_non_wakeup_gpios,u16 id, +void __iomem *base,int off_mode) +{ +int c =0 ; +struct gpio_state *gpio_dev_state; + +list_for_each_entry (gpio_dev_state, &omap_gpio_ctx_list, node) { +u32 l1 =0 , l2 =0 ; +int j; + +if (!gpio_dev_state->id == id) +continue ; + +if ((cpu_is_omap34xx ()) && (id ==0 )) +continue ; + +for (j =0 ; j <hweight_long (gpio_dev_state->dbck_enable_mask); + j++) +clk_disable (gpio_dev_state->dbck); + +if (!off_mode) +continue ; + +/* +* If going to OFF, remove triggering for all +* non-wakeup GPIOs. Otherwise spurious IRQs will be +* generated. See OMAP2420 Errata item 1.101. +*/ +if (!enabled_non_wakeup_gpios) +continue ; + + gpio_dev_state->saved_datain =gpio_read (base,DATAIN ); + l1 =gpio_read (base,FALLINGDETECT ); + l2 =gpio_read (base,RISINGDETECT ); + + gpio_dev_state->saved_fallingdetect = l1; + gpio_dev_state->saved_risingdetect = l2; + l1 &= ~enabled_non_wakeup_gpios; + l2 &= ~enabled_non_wakeup_gpios; + +gpio_write (l1, base,FALLINGDETECT ); +gpio_write (l2, base,RISINGDETECT ); + + c++; + } +if (!c) { + workaround_enabled =0 ; +return ; + } + workaround_enabled =1 ; +} + +static void gpio_resume_after_idle (u32 enabled_non_wakeup_gpios,u16 id, +void __iomem *base) +{ +struct gpio_state *gpio_dev_state; + +list_for_each_entry (gpio_dev_state, &omap_gpio_ctx_list, node) { +u32 l =0 , gen, gen0, gen1; +int j; + +if (!gpio_dev_state->id == id) +continue ; + +if ((cpu_is_omap34xx ()) && (id ==0 )) +continue ; + +for (j =0 ; j <hweight_long (gpio_dev_state->dbck_enable_mask); + j++) +clk_enable (gpio_dev_state->dbck); + +if (!workaround_enabled) +continue ; + +if (!enabled_non_wakeup_gpios) +continue ; + +gpio_write (gpio_dev_state->saved_fallingdetect, base, +FALLINGDETECT ); +gpio_write (gpio_dev_state->saved_risingdetect, base, +RISINGDETECT ); + + l =gpio_read (base,DATAIN ); +/* +* Check if any of the non-wakeup interrupt GPIOs have changed +* state. If so, generate an IRQ by software. This is +* horribly racy, but it's the best we can do to work around +* this silicon bug. +*/ + l ^= gpio_dev_state->saved_datain; + l &= enabled_non_wakeup_gpios; + +/* +* No need to generate IRQs for the rising edge for gpio IRQs +* configured with falling edge only; and vice versa. +*/ + gen0 = l & gpio_dev_state->saved_fallingdetect; + gen0 &= gpio_dev_state->saved_datain; + + gen1 = l & gpio_dev_state->saved_risingdetect; + gen1 &= ~(gpio_dev_state->saved_datain); + +/* FIXME: Consider GPIO IRQs with level detections properly! */ + gen = l & (~(gpio_dev_state->saved_fallingdetect) & + ~(gpio_dev_state->saved_risingdetect)); +/* Consider all GPIO IRQs needed to be updated */ + gen |= gen0 | gen1; + +if (gen) { +u32 old0, old1; + + old0 =gpio_read (base,LEVELDETECT0 ); + old1 =gpio_read (base,LEVELDETECT1 ); +gpio_write (old0 | gen, base,LEVELDETECT0 ); +gpio_write (old1 | gen, base,LEVELDETECT1 ); +gpio_write (old0, base,LEVELDETECT0 ); +gpio_write (old1, base,LEVELDETECT1 ); + } + } +} +static struct omap_gpio_func gpio_fn = { .get_index = get_gpio_index, .gpio_valid = gpio_valid,
@@ -180,6 +353,9 @@ static struct omap_gpio_func gpio_fn = { .gpio_set_trigger = gpio_set_trigger, .gpio_is_irqena = gpio_is_irqena, .gpio_enable_irq = gpio_enable_irq, + .gpio_debounce_set = gpio_debounce_set, + .gpio_idle = gpio_prepare_for_idle, + .gpio_resume_after_idle = gpio_resume_after_idle, };static int omap2_gpio_dev_init (struct omap_hwmod *oh,void *unused)
@@ -189,6 +365,7 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)struct omap_gpio_dev_attr *dev_attr;char *name ="omap_gpio" ;int id; +struct gpio_state *gpio_dev_state;/* * extract the device id from name field available in the
@@ -229,19 +406,39 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)return -EINVAL ; } + gpio_dev_state =kzalloc (sizeof (struct gpio_state ),GFP_KERNEL ); +if (!gpio_dev_state) { +pr_err ("%s:, Memory alloc failed for gpio_dev_state\n" , + __func__); +kfree (pdata); +return -ENOMEM ; + } + + gpio_dev_state->id = id -1 ; +list_add_tail (&gpio_dev_state->node, &omap_gpio_ctx_list); + od =omap_device_build (name, id -1 , oh, pdata,sizeof (*pdata), omap_gpio_latency,ARRAY_SIZE (omap_gpio_latency), false); -kfree (pdata); -if (IS_ERR (od)) {WARN (1 ,"Can't build omap_device for %s:%s.\n" , name, oh->name); +kfree (gpio_dev_state); +kfree (pdata);return PTR_ERR (od); } gpio_bank_count++; +if (pdata->dbck_flag) { + gpio_dev_state->dbck =clk_get (&od->pdev.dev,"dbclk" ); +if (IS_ERR (gpio_dev_state->dbck)) +dev_err (&od->pdev.dev,"Could not get gpio%d dbck\n" , + id); + } + +kfree (pdata); +return 0 ; }
arch/arm/plat-omap/gpio.c +17 -206
277 lines not on this page · raw message
arch/arm/plat-omap/include/plat/gpio.h +6 -0
@@ -116,6 +116,12 @@ struct omap_gpio_func {int (*gpio_set_trigger)(void __iomem *base,int gpio,int trigger);u32 (*gpio_is_irqena)(void__iomem *base);void (*gpio_enable_irq)(void __iomem *base,int gpio_mask,int enable); +void (*gpio_debounce_set)(void __iomem *base,unsigned gpio, +unsigned debounce,u16 id); +void (*gpio_idle)(u32 enabled_non_wakeup_gpios,u16 id, +void __iomem *base,int offmode); +void (*gpio_resume_after_idle)(u32 enabled_non_wakeup_gpios,u16 id, +void __iomem *base); };struct omap_gpio_platform_data {
Signature · 1 line
1.7.1
RFC PATCH 13/18 OMAP: GPIO: cleanup save/restore context
In reply to Charulatha VMove GPIO save/restore context to SoC specific file.
--- arch/arm/mach-omap2/gpio.c | 78 +++++++++++++++++++++++++++ arch/arm/plat-omap/gpio.c | 91 ++++--------------------------- arch/arm/plat-omap/include/plat/gpio.h | 2 + 3 files changed, 92 insertions(+), 79 deletions(-)
arch/arm/mach-omap2/gpio.c +78 -0
@@ -34,6 +34,19 @@#define OMAP2_GPIO_DEBOUNCE_MAX_VAL 0xff#define OMAP2_GPIO_DEBOUNCE_VAL_DIV 0x1f +struct omap_gpio_regs { +u32 irqenable1; +u32 irqenable2; +u32 wake_en; +u32 ctrl; +u32 oe; +u32 leveldetect0; +u32 leveldetect1; +u32 risingdetect; +u32 fallingdetect; +u32 dataout; +}; +struct gpio_state {struct list_head node;u32 saved_datain;
@@ -42,6 +55,7 @@ struct gpio_state {u32 dbck_enable_mask;struct clk *dbck;u16 id; +struct omap_gpio_regs gpio_ctx; };static int workaround_enabled;
@@ -345,6 +359,68 @@ static void gpio_resume_after_idle(u32 enabled_non_wakeup_gpios, u16 id, } } +static void gpio_save_ctx (void __iomem *base,u32 id) +{ +struct gpio_state *gpio_dev_state; + +if (!cpu_is_omap34xx ()) +return ; + +list_for_each_entry (gpio_dev_state, &omap_gpio_ctx_list, node) { +/* saving banks from 2-6 only since GPIO1 is in WKUP */ +if ((gpio_dev_state->id ==0 ) || (gpio_dev_state->id != id)) +continue ; + + gpio_dev_state->gpio_ctx.irqenable1 =gpio_read (base, +IRQENABLE1 ); + gpio_dev_state->gpio_ctx.irqenable2 =gpio_read (base, +IRQENABLE2 ); + gpio_dev_state->gpio_ctx.wake_en =gpio_read (base,WAKE_EN ); + gpio_dev_state->gpio_ctx.ctrl =gpio_read (base,CTRL ); + gpio_dev_state->gpio_ctx.oe =gpio_read (base,OE ); + gpio_dev_state->gpio_ctx.leveldetect0 =gpio_read (base, +LEVELDETECT0 ); + gpio_dev_state->gpio_ctx.leveldetect1 =gpio_read (base, +LEVELDETECT1 ); + gpio_dev_state->gpio_ctx.risingdetect =gpio_read (base, +RISINGDETECT ); + gpio_dev_state->gpio_ctx.fallingdetect =gpio_read (base, +FALLINGDETECT ); + gpio_dev_state->gpio_ctx.dataout =gpio_read (base,DATAOUT ); + } +} + +static void gpio_restore_ctx (void __iomem *base,u32 id) +{ +struct gpio_state *gpio_dev_state; + +if (!cpu_is_omap34xx ()) +return ; + +list_for_each_entry (gpio_dev_state, &omap_gpio_ctx_list, node) { +/* restore the required registers of bank 2-6 */ +if ((gpio_dev_state->id ==0 ) || (gpio_dev_state->id != id)) +continue ; + +gpio_write (gpio_dev_state->gpio_ctx.irqenable1, base, +IRQENABLE1 ); +gpio_write (gpio_dev_state->gpio_ctx.irqenable2, base, +IRQENABLE2 ); +gpio_write (gpio_dev_state->gpio_ctx.wake_en, base,WAKE_EN ); +gpio_write (gpio_dev_state->gpio_ctx.ctrl, base,CTRL ); +gpio_write (gpio_dev_state->gpio_ctx.oe, base,OE ); +gpio_write (gpio_dev_state->gpio_ctx.leveldetect0, base, +LEVELDETECT0 ); +gpio_write (gpio_dev_state->gpio_ctx.leveldetect1, base, +LEVELDETECT1 ); +gpio_write (gpio_dev_state->gpio_ctx.risingdetect, base, +RISINGDETECT ); +gpio_write (gpio_dev_state->gpio_ctx.fallingdetect, base, +FALLINGDETECT ); +gpio_write (gpio_dev_state->gpio_ctx.dataout, base,DATAOUT ); + } +} +static struct omap_gpio_func gpio_fn = { .get_index = get_gpio_index, .gpio_valid = gpio_valid,
@@ -356,6 +432,8 @@ static struct omap_gpio_func gpio_fn = { .gpio_debounce_set = gpio_debounce_set, .gpio_idle = gpio_prepare_for_idle, .gpio_resume_after_idle = gpio_resume_after_idle, + .gpio_save_ctx = gpio_save_ctx, + .gpio_restore_ctx = gpio_restore_ctx, };static int omap2_gpio_dev_init (struct omap_hwmod *oh,void *unused)
arch/arm/plat-omap/gpio.c +12 -79
121 lines not on this page · raw message
arch/arm/plat-omap/include/plat/gpio.h +2 -0
@@ -122,6 +122,8 @@ struct omap_gpio_func { void __iomem *base, int offmode);void (*gpio_resume_after_idle)(u32 enabled_non_wakeup_gpios,u16 id,void __iomem *base); +void (*gpio_save_ctx)(void __iomem *base,u32 id); +void (*gpio_restore_ctx)(void __iomem *base,u32 id); };struct omap_gpio_platform_data {
Signature · 1 line
1.7.1
RFC PATCH 14/18 OMAP: GPIO: Remove CONFIG_ARCH_OMAP16XX/OMAP2+ defines
In reply to Charulatha VSuspend/resume/wakeup capabilities are supported only in OMAP16xx and OMAP2PLUS SoCs. Handle this by using a flag "suspend_resume_support" in pdata.
This requires calling omap_gpio_sysinit() as part of probe instead of having this function as an arch_initcall
--- arch/arm/mach-omap1/gpio16xx.c | 5 ++ arch/arm/mach-omap2/gpio.c | 1 + arch/arm/plat-omap/gpio.c | 96 ++++++++++++++------------------ arch/arm/plat-omap/include/plat/gpio.h | 1 + 4 files changed, 48 insertions(+), 55 deletions(-)
arch/arm/mach-omap1/gpio16xx.c +5 -0
@@ -76,6 +76,7 @@ static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = { .bank_type = METHOD_MPUIO, .bank_width = OMAP1610_GPIO_WIDTH, .bank_stride = 1, + .suspend_resume_support = true, };static struct __initdata platform_device omap16xx_mpu_gpio = {
@@ -105,6 +106,7 @@ static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = { .virtual_irq_start = IH_GPIO_BASE, .bank_type = METHOD_GPIO_1610, .bank_width = OMAP1610_GPIO_WIDTH, + .suspend_resume_support = true, };static struct __initdata platform_device omap16xx_gpio1 = {
@@ -134,6 +136,7 @@ static struct __initdata omap_gpio_platform_data omap16xx_gpio2_config = { .virtual_irq_start = IH_GPIO_BASE + 16, .bank_type = METHOD_GPIO_1610, .bank_width = OMAP1610_GPIO_WIDTH, + .suspend_resume_support = true, };static struct __initdata platform_device omap16xx_gpio2 = {
@@ -163,6 +166,7 @@ static struct __initdata omap_gpio_platform_data omap16xx_gpio3_config = { .virtual_irq_start = IH_GPIO_BASE + 32, .bank_type = METHOD_GPIO_1610, .bank_width = OMAP1610_GPIO_WIDTH, + .suspend_resume_support = true, };static struct __initdata platform_device omap16xx_gpio3 = {
@@ -192,6 +196,7 @@ static struct __initdata omap_gpio_platform_data omap16xx_gpio4_config = { .virtual_irq_start = IH_GPIO_BASE + 48, .bank_type = METHOD_GPIO_1610, .bank_width = OMAP1610_GPIO_WIDTH, + .suspend_resume_support = true, };static struct __initdata platform_device omap16xx_gpio4 = {
arch/arm/mach-omap2/gpio.c +1 -0
@@ -467,6 +467,7 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused) pdata->dbck_flag = dev_attr->dbck_flag; pdata->virtual_irq_start =IH_GPIO_BASE +32 * (id -1 ); pdata->gpio_fn = &gpio_fn; + pdata->suspend_resume_support = true;switch (oh->class->rev) {case 0 :
arch/arm/plat-omap/gpio.c +41 -55
164 lines not on this page · raw message
arch/arm/plat-omap/include/plat/gpio.h +1 -0
@@ -133,6 +133,7 @@ struct omap_gpio_platform_data {int bank_width;/* GPIO bank width */ int bank_stride;/* Only needed for omap1 MPUIO */ bool dbck_flag;/* dbck required or not - True for OMAP3&4 */ +bool suspend_resume_support;/* True for OMAP16XX, OMAP2PLUS */ };extern void omap2_gpio_prepare_for_idle (int off_mode);
Signature · 1 line
1.7.1
RFC PATCH 15/18 OMAP: GPIO: cleanup gpio_show_rev
In reply to Charulatha VRemove cpu_is* checks from omap_gpio_show_rev.
Also display GPIO IP version only once as it is not required to print the IP version of all the banks as they are the same.
--- arch/arm/plat-omap/gpio.c | 17 ++++++++++------- 1 files changed, 10 insertions(+), 7 deletions(-)
arch/arm/plat-omap/gpio.c +10 -7
@@ -1032,12 +1032,10 @@ static void __init omap_gpio_show_rev(struct gpio_bank *bank) {u32 rev; -if (cpu_is_omap16xx () && !(bank->method !=METHOD_MPUIO )) - rev =__raw_readw (bank->base +OMAP1610_GPIO_REVISION ); -else if (cpu_is_omap24xx () ||cpu_is_omap34xx ()) - rev =__raw_readl (bank->base +OMAP24XX_GPIO_REVISION ); -else if (cpu_is_omap44xx ()) - rev =__raw_readl (bank->base +OMAP4_GPIO_REVISION ); +if ((bank->method ==METHOD_GPIO_24XX ) || + (bank->method ==METHOD_GPIO_44XX ) || + (bank->method ==METHOD_GPIO_1610 )) + rev = gpio_fn.gpio_read (bank->base,REV );else return ;
@@ -1170,6 +1168,7 @@ static void __init omap_gpio_chip_init(struct gpio_bank *bank)static int __devinit omap_gpio_probe (struct platform_device *pdev) {static int gpio_init_done; +static int show_rev;struct omap_gpio_platform_data *pdata;struct resource *res;struct gpio_bank *bank;
@@ -1238,7 +1237,6 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev)omap_gpio_mod_init (bank, pdev->id);omap_gpio_chip_init (bank); -omap_gpio_show_rev (bank);list_add_tail (&bank->node, &omap_gpio_list);
@@ -1259,6 +1257,11 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev) gpio_init_done =1 ; } +if ((bank->method !=METHOD_MPUIO ) && (!show_rev)) { +omap_gpio_show_rev (bank); + show_rev =1 ; + } +return 0 ; }
Signature · 1 line
1.7.1
RFC PATCH 16/18 OMAP: GPIO: move omap_gpio_mod_init to mach-omap
In reply to Charulatha VMove omap_gpio_mod_init() from plat-omap/ to mach-omap*/ as this function handles architecture specific GPIO module initialization.
Provide non_wakeup_gpios information through pdata.
With this change all the cpu_is* checks & #ifdef CONFIG_ARCH_OMAP* will be removed from OMAP GPIO driver.
Also remove all the unsused register offset macros.
--- arch/arm/mach-omap1/gpio15xx.c | 7 ++ arch/arm/mach-omap1/gpio16xx.c | 24 +++++ arch/arm/mach-omap1/gpio7xx.c | 7 ++ arch/arm/mach-omap2/gpio.c | 31 +++++- arch/arm/plat-omap/gpio.c | 172 ++------------------------------ arch/arm/plat-omap/include/plat/gpio.h | 2 + 6 files changed, 74 insertions(+), 169 deletions(-)
arch/arm/mach-omap1/gpio15xx.c +7 -0
@@ -163,6 +163,12 @@ static void gpio_enable_irq(void __iomem *base, int gpio_mask, int enable)gpio_write (l, base,IRQENABLE1 ); } +static void gpio_init (void __iomem *base,u32 id) +{ +gpio_write (0xffff , base,INT_CTRL ); +gpio_write (0 , base,IRQSTATUS_REG0 ); +} +static struct omap_gpio_func gpio_fn = { .get_index = get_gpio_index, .gpio_valid = gpio_valid,
@@ -171,6 +177,7 @@ static struct omap_gpio_func gpio_fn = { .gpio_set_trigger = gpio_set_trigger, .gpio_is_irqena = gpio_is_irqena, .gpio_enable_irq = gpio_enable_irq, + .gpio_init = gpio_init, };/*
arch/arm/mach-omap1/gpio16xx.c +24 -0
@@ -291,6 +291,29 @@ static void gpio_enable_irq(void __iomem *base, int gpio_mask, int enable)gpio_write (gpio_mask, base,CLEARIRQENA1 ); } +/* +* GPIO SYSCONFIG needs to be set expicitly in +* the driver code only for OMAP16xx. For OMAP2plus +* this is taken care by PM runtime framework. +* Hence no specific field is required to defined in +* omap_gpio_reg_offsets. +*/ +#define OMAP1610_GPIO_SYSCONFIG 0x0010 + +static void gpio_init (void __iomem *base,u32 id) +{ +gpio_write (0 , base,IRQENABLE1 ); +gpio_write (0xffff , base,IRQSTATUS_REG0 ); +__raw_writew (0x0014 , base +OMAP1610_GPIO_SYSCONFIG ); + +/* +* Enable system clock for GPIO module. +* The CAM_CLK_CTRL *is* really the right place. +*/ +omap_writel (omap_readl (ULPD_CAM_CLK_CTRL ) |0x04 , +ULPD_CAM_CLK_CTRL ); +} +static struct omap_gpio_func gpio_fn = { .get_index = get_gpio_index, .gpio_valid = gpio_valid,
@@ -299,6 +322,7 @@ static struct omap_gpio_func gpio_fn = { .gpio_set_trigger = gpio_set_trigger, .gpio_is_irqena = gpio_is_irqena, .gpio_enable_irq = gpio_enable_irq, + .gpio_init = gpio_init, };/*
arch/arm/mach-omap1/gpio7xx.c +7 -0
@@ -325,6 +325,12 @@ static void gpio_enable_irq(void __iomem *base, int gpio_mask, int enable)gpio_write (l, base,IRQENABLE1 ); } +static void gpio_init (void __iomem *base,u32 id) +{ +gpio_write (0xffffffff , base,INT_CTRL ); +gpio_write (0 , base,IRQSTATUS_REG0 ); +} +static struct omap_gpio_func gpio_fn = { .get_index = get_gpio_index, .gpio_valid = gpio_valid,
@@ -333,6 +339,7 @@ static struct omap_gpio_func gpio_fn = { .gpio_set_trigger = gpio_set_trigger, .gpio_is_irqena = gpio_is_irqena, .gpio_enable_irq = gpio_enable_irq, + .gpio_init = gpio_init, };/*
arch/arm/mach-omap2/gpio.c +27 -4
@@ -421,6 +421,22 @@ static void gpio_restore_ctx(void __iomem *base, u32 id) } } +static void gpio_init (void __iomem *base,u32 id) +{ +if (cpu_is_omap44xx ()) { +gpio_write (0xffffffff , base,IRQSTATUSCLR0 ); +gpio_write (0x00000000 , base,DEBOUNCE_EN ); +/* Initialize interface clk ungated, module enabled */ +gpio_write (0 , base,CTRL ); + }else if (cpu_is_omap34xx ()) { +gpio_write (0x00000000 , base,IRQENABLE1 ); +gpio_write (0xffffffff , base,IRQSTATUS_REG0 ); +gpio_write (0x00000000 , base,DEBOUNCE_EN ); +/* Initialize interface clk ungated, module enabled */ +gpio_write (0 , base,CTRL ); + } +} +static struct omap_gpio_func gpio_fn = { .get_index = get_gpio_index, .gpio_valid = gpio_valid,
@@ -434,6 +450,7 @@ static struct omap_gpio_func gpio_fn = { .gpio_resume_after_idle = gpio_resume_after_idle, .gpio_save_ctx = gpio_save_ctx, .gpio_restore_ctx = gpio_restore_ctx, + .gpio_init = gpio_init, };static int omap2_gpio_dev_init (struct omap_hwmod *oh,void *unused)
@@ -442,7 +459,7 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)struct omap_gpio_platform_data *pdata;struct omap_gpio_dev_attr *dev_attr;char *name ="omap_gpio" ; -int id; +int id, i;struct gpio_state *gpio_dev_state;/*
@@ -454,6 +471,7 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)* or make use of static variable mechanism to handle this. */ sscanf (oh->name,"gpio%d" , &id); + i = id -1 ; pdata =kzalloc (sizeof (struct omap_gpio_platform_data ),GFP_KERNEL );if (!pdata) {
@@ -465,12 +483,17 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused) bank_width = dev_attr->bank_width; pdata->bank_width = bank_width; pdata->dbck_flag = dev_attr->dbck_flag; - pdata->virtual_irq_start =IH_GPIO_BASE +32 * (id -1 ); + pdata->virtual_irq_start =IH_GPIO_BASE +32 * i; pdata->gpio_fn = &gpio_fn; pdata->suspend_resume_support = true;switch (oh->class->rev) {case 0 : +if (!i) + pdata->non_wakeup_gpios =0xe203ffc0 ; +else if (i ==1 ) + pdata->non_wakeup_gpios =0x08700040 ; +/* FALL THROUGH */ case 1 : pdata->bank_type =METHOD_GPIO_24XX ; reg_map = omap2_gpio_reg_offsets;
@@ -493,10 +516,10 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)return -ENOMEM ; } - gpio_dev_state->id = id -1 ; + gpio_dev_state->id = i;list_add_tail (&gpio_dev_state->node, &omap_gpio_ctx_list); - od =omap_device_build (name, id -1 , oh, pdata, + od =omap_device_build (name, i, oh, pdata,sizeof (*pdata), omap_gpio_latency,ARRAY_SIZE (omap_gpio_latency), false);
arch/arm/plat-omap/gpio.c +7 -165
196 lines not on this page · raw message
arch/arm/plat-omap/include/plat/gpio.h +2 -0
@@ -124,6 +124,7 @@ struct omap_gpio_func { void __iomem *base);void (*gpio_save_ctx)(void __iomem *base,u32 id);void (*gpio_restore_ctx)(void __iomem *base,u32 id); +void (*gpio_init)(void __iomem *base,u32 id); };struct omap_gpio_platform_data {
@@ -134,6 +135,7 @@ struct omap_gpio_platform_data {int bank_stride;/* Only needed for omap1 MPUIO */ bool dbck_flag;/* dbck required or not - True for OMAP3&4 */ bool suspend_resume_support;/* True for OMAP16XX, OMAP2PLUS */ +u32 non_wakeup_gpios; };extern void omap2_gpio_prepare_for_idle (int off_mode);
Signature · 1 line
1.7.1
RFC PATCH 17/18 OMAP: GPIO: use dev_err* instead of printk
In reply to Charulatha VUse dev_info()/dev_err() instead of printk in OMAP GPIO driver
--- arch/arm/plat-omap/gpio.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
arch/arm/plat-omap/gpio.c +3 -3
@@ -66,7 +66,7 @@ static int omap_gpio_sysinit(void);static int check_gpio (int gpio) {if (unlikely (gpio_fn.gpio_valid (gpio) <0 )) { -printk (KERN_ERR "omap-gpio: invalid GPIO %d\n" , gpio); +pr_err ("omap-gpio: invalid GPIO %d\n" , gpio);dump_stack ();return -1 ; }
@@ -470,7 +470,7 @@ static int _set_gpio_wakeup(struct gpio_bank *bank, int gpio, int enable)case METHOD_GPIO_24XX :case METHOD_GPIO_44XX :if (bank->non_wakeup_gpios & (1 << gpio)) { -printk (KERN_ERR "Unable to modify wakeup on " +dev_err (bank->dev,"Unable to modify wakeup on " "non-wakeup GPIO%d\n" , bank->id *32 + gpio);return -EINVAL ;
@@ -485,7 +485,7 @@ static int _set_gpio_wakeup(struct gpio_bank *bank, int gpio, int enable)spin_unlock_irqrestore (&bank->lock, flags);return 0 ;default : -printk (KERN_ERR "Can't enable GPIO wakeup for method %i\n" , +dev_err (bank->dev,"Can't enable GPIO wakeup for method %i\n" , bank->method);return -EINVAL ; }
Signature · 1 line
1.7.1
RFC PATCH 18/18 OMAP: GPIO: Remove usage of bank method
In reply to Charulatha VRemove usage of bank->method to identify CPU specific OMAP GPIO bank. Instead identify specific features using flags and accordingly manage. bank->type MPUIO is common for all OMAP1 SoCs. Use bank->stride to identify the MPUIO type bank
--- arch/arm/mach-omap1/gpio15xx.c | 2 - arch/arm/mach-omap1/gpio16xx.c | 24 ++-- arch/arm/mach-omap1/gpio7xx.c | 7 - arch/arm/mach-omap2/gpio.c | 11 ++- arch/arm/plat-omap/gpio.c | 228 +++++++++++++------------------ arch/arm/plat-omap/include/plat/gpio.h | 46 ++++++- 6 files changed, 155 insertions(+), 163 deletions(-)
arch/arm/mach-omap1/gpio15xx.c +0 -2
@@ -54,7 +54,6 @@ static struct __initdata resource omap15xx_mpu_gpio_resources[] = {static struct __initdata omap_gpio_platform_data omap15xx_mpu_gpio_config = { .virtual_irq_start =IH_MPUIO_BASE , - .bank_type =METHOD_MPUIO , .bank_width =OMAP1510_GPIO_WIDTH , .bank_stride =1 , };
@@ -84,7 +83,6 @@ static struct __initdata resource omap15xx_gpio_resources[] = {static struct __initdata omap_gpio_platform_data omap15xx_gpio_config = { .virtual_irq_start =IH_GPIO_BASE , - .bank_type =METHOD_GPIO_1510 , .bank_width =OMAP1510_GPIO_WIDTH , };
arch/arm/mach-omap1/gpio16xx.c +11 -13
@@ -38,6 +38,13 @@#define OMAP1610_GPIO_BOTH_EDGE_SET 0x03#define OMAP1610_GPIO_EDGE_MASK 0x07 +#define OMAP16XX_SPECIFIC_SUPPORT \ + .bank_width = 16,\ + .suspend_resume_support = true,\ + .features = BIT(OMAP_GPIO_REV_SHOW_FLAG) |\ + BIT(OMAP_GPIO_DATAOUT_SET_CLR_REGS_FLAG) |\ + BIT(OMAP_GPIO_DUAL_EDGE_TRIG_FLAG)\ +static u16 reg_map[] = { [REV ] =0x00 , [SYS_CFG ] =0x10 ,
@@ -73,7 +80,6 @@ static struct __initdata resource omap16xx_mpu_gpio_resources[] = {static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = { .virtual_irq_start =IH_MPUIO_BASE , - .bank_type =METHOD_MPUIO , .bank_width =OMAP1610_GPIO_WIDTH , .bank_stride =1 , .suspend_resume_support = true,
@@ -104,9 +110,7 @@ static struct __initdata resource omap16xx_gpio1_resources[] = {static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = { .virtual_irq_start =IH_GPIO_BASE , - .bank_type =METHOD_GPIO_1610 , - .bank_width =OMAP1610_GPIO_WIDTH , - .suspend_resume_support = true, +OMAP16XX_SPECIFIC_SUPPORT , };static struct __initdata platform_device omap16xx_gpio1 = {
@@ -134,9 +138,7 @@ static struct __initdata resource omap16xx_gpio2_resources[] = {static struct __initdata omap_gpio_platform_data omap16xx_gpio2_config = { .virtual_irq_start =IH_GPIO_BASE +16 , - .bank_type =METHOD_GPIO_1610 , - .bank_width =OMAP1610_GPIO_WIDTH , - .suspend_resume_support = true, +OMAP16XX_SPECIFIC_SUPPORT , };static struct __initdata platform_device omap16xx_gpio2 = {
@@ -164,9 +166,7 @@ static struct __initdata resource omap16xx_gpio3_resources[] = {static struct __initdata omap_gpio_platform_data omap16xx_gpio3_config = { .virtual_irq_start =IH_GPIO_BASE +32 , - .bank_type =METHOD_GPIO_1610 , - .bank_width =OMAP1610_GPIO_WIDTH , - .suspend_resume_support = true, +OMAP16XX_SPECIFIC_SUPPORT , };static struct __initdata platform_device omap16xx_gpio3 = {
@@ -194,9 +194,7 @@ static struct __initdata resource omap16xx_gpio4_resources[] = {static struct __initdata omap_gpio_platform_data omap16xx_gpio4_config = { .virtual_irq_start =IH_GPIO_BASE +48 , - .bank_type =METHOD_GPIO_1610 , - .bank_width =OMAP1610_GPIO_WIDTH , - .suspend_resume_support = true, +OMAP16XX_SPECIFIC_SUPPORT , };static struct __initdata platform_device omap16xx_gpio4 = {
arch/arm/mach-omap1/gpio7xx.c +0 -7
@@ -60,7 +60,6 @@ static struct __initdata resource omap7xx_mpu_gpio_resources[] = {static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = { .virtual_irq_start =IH_MPUIO_BASE , - .bank_type =METHOD_MPUIO , .bank_width =OMAP7XX_GPIO_WIDTH , .bank_stride =2 , };
@@ -90,7 +89,6 @@ static struct __initdata resource omap7xx_gpio1_resources[] = {static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config = { .virtual_irq_start =IH_GPIO_BASE , - .bank_type =METHOD_GPIO_7XX , .bank_width =OMAP7XX_GPIO_WIDTH , };
@@ -119,7 +117,6 @@ static struct __initdata resource omap7xx_gpio2_resources[] = {static struct __initdata omap_gpio_platform_data omap7xx_gpio2_config = { .virtual_irq_start =IH_GPIO_BASE +32 , - .bank_type =METHOD_GPIO_7XX , .bank_width =OMAP7XX_GPIO_WIDTH , };
@@ -148,7 +145,6 @@ static struct __initdata resource omap7xx_gpio3_resources[] = {static struct __initdata omap_gpio_platform_data omap7xx_gpio3_config = { .virtual_irq_start =IH_GPIO_BASE +64 , - .bank_type =METHOD_GPIO_7XX , .bank_width =OMAP7XX_GPIO_WIDTH , };
@@ -177,7 +173,6 @@ static struct __initdata resource omap7xx_gpio4_resources[] = {static struct __initdata omap_gpio_platform_data omap7xx_gpio4_config = { .virtual_irq_start =IH_GPIO_BASE +96 , - .bank_type =METHOD_GPIO_7XX , .bank_width =OMAP7XX_GPIO_WIDTH , };
@@ -206,7 +201,6 @@ static struct __initdata resource omap7xx_gpio5_resources[] = {static struct __initdata omap_gpio_platform_data omap7xx_gpio5_config = { .virtual_irq_start =IH_GPIO_BASE +128 , - .bank_type =METHOD_GPIO_7XX , .bank_width =OMAP7XX_GPIO_WIDTH , };
@@ -235,7 +229,6 @@ static struct __initdata resource omap7xx_gpio6_resources[] = {static struct __initdata omap_gpio_platform_data omap7xx_gpio6_config = { .virtual_irq_start =IH_GPIO_BASE +160 , - .bank_type =METHOD_GPIO_7XX , .bank_width =OMAP7XX_GPIO_WIDTH , };
arch/arm/mach-omap2/gpio.c +9 -2
@@ -486,6 +486,12 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused) pdata->virtual_irq_start =IH_GPIO_BASE +32 * i; pdata->gpio_fn = &gpio_fn; pdata->suspend_resume_support = true; + pdata->features =BIT (OMAP_GPIO_LEVEL_TRIGGER_FLAG ) | +BIT (OMAP_GPIO_CLK_GATING_FLAG ) | +BIT (OMAP_GPIO_REV_SHOW_FLAG ) | +BIT (OMAP_GPIO_DATAOUT_SET_CLR_REGS_FLAG ) | +BIT (OMAP_GPIO_DUAL_EDGE_TRIG_FLAG ) | +BIT (OMAP_GPIO_WA_CLR_DSP_INT_FLAG );switch (oh->class->rev) {case 0 :
@@ -493,13 +499,14 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused) pdata->non_wakeup_gpios =0xe203ffc0 ; else if (i == 1) pdata->non_wakeup_gpios = 0x08700040; + + pdata->features |= BIT(OMAP_GPIO_HANDLE_IRQ_LOSS_LOW_PWR_FLAG); /* FALL THROUGH */ case 1: - pdata->bank_type = METHOD_GPIO_24XX; reg_map = omap2_gpio_reg_offsets; break; case 2: - pdata->bank_type = METHOD_GPIO_44XX; + pdata->features |= BIT(OMAP_GPIO_IRQ_WK_ENA_REG_FLAG); reg_map = omap4_gpio_reg_offsets; break; default:
arch/arm/plat-omap/gpio.c +96 -132
494 lines not on this page · raw message
arch/arm/plat-omap/include/plat/gpio.h +39 -7
63 lines not on this page · raw message
Signature · 1 line
1.7.1
cover OMAP: GPIO: cleanup GPIO driver
In reply to Charulatha VHi,
Quoted 10 lines · Charulatha V
Modifies the OMAP GPIO driver to avoid usage of cpu_is* checks for different OMAP architectures. This is done by moving some architecture specific code to mach-omap* and call them from plat-omap* using function pointers. Also remove the register offset macros from OMAP GPIO driver and handle the same in mach-omap*.
Avoid usage of
gpio_bank_countandgpio_bankpointer array by means of maintaining a list. Removes thebank->methodflag from the GPIO driver.
Quoted 6 lines
All OMAP1 SoCs has one MPUIO type GPIO bank. OMAP2+ does not have any MPUIO type GPIO bank. Since MPUIO type GPIO bank is the same for all OMAP1 CPUs, they are handled in plat-omap/ itself as there is no common
gpio.cfile for all cpu types in mach-omap1. They are identified by usingbank->strideflag as it is '0' for other than MPUIO type banks.
The omap gpio code clearly deserves a cleanup, but I think this series does not go far enough. There are only a handful of possible ways to implement a gpio hardware, most of them can be abstracted in a similar way Thomas did for the irq handlers and then we can handle most SoC specific gpio code in generic code.
Something like the following comes to my mind:
struct gpio_chip_mmio_regs {
unsigned long output_set_reg;
unsigned long output_clean_reg;
unsigned long direction_reg;
unsigned long status_reg;
};struct gpio_chip_mmio {
struct gpio_chip_mmio_regs *regs;
void __iomem *base;
void (*direction_output)(struct gpio_chip_mmio *, int);
void (*direction_input)(struct gpio_chip_mmio *, int);
struct gpio_chip chip;
};int gpio_chip_mmio_add(struct gpio_chip_mmio *);
Sascha
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
cover OMAP: GPIO: cleanup GPIO driver
In reply to Charulatha VHi Charu,
Quoted 5 lines · Charulatha V
Modifies the OMAP GPIO driver to avoid usage of cpu_is* checks for different OMAP architectures. This is done by moving some architecture specific code to mach-omap* and call them from plat-omap* using function pointers. Also remove the register offset macros from OMAP GPIO driver and handle the same in mach-omap*.
Thanks for working on this cleanup, this driver really needs a cleanup.
You've hit on all the main areas for cleanup, but unfortunately, it's not really going in the direction I was hoping. Rather than moving code into the SoC specific parts, I was hoping to generalize the driver such that SoC-specific code would just pass in register offsets/options into the common driver. Your current approach isn't really reducing code, it's just moving it around.
I had started on a similar cleanup as well, and will post that series shortly to demonstrate the direction I think the cleanups should be going. I've tackled most of the same functions/areas that you have (except the IRQ triggering stuff), but have a rather different approach. I'll get to the IRQ triggering stuff next (after going on vacation for a week), but feel free to build on top of my series if you like.
The direction I'd like to go is towards having a generalized driver that can not only work across all OMAP SoCs, but also hopefully towards something that can be shared with other SoCs as well. Of course, the first step is cleaning up the OMAP driver, but the next step will be looking for other areas of consolidation. Towards that end, I'm also working towards converting the GPIO IRQs in this driver to use the new generic IRQ chip infrastructure posted by Thomas Gleixner. In my series, you'll see that I started that for the MPUIO IRQs, but the GPIO IRQs will come next.
Kevin
cover OMAP: GPIO: cleanup GPIO driver
Kevin,
Thanks for your comments.
Quoted 19 lines · Kevin Hilman
Hi Charu,
Quoted 5 lines · Charulatha V
Modifies the OMAP GPIO driver to avoid usage of cpu_is* checks for different OMAP architectures. This is done by moving some architecture specific code to mach-omap* and call them from plat-omap* using function pointers. Also remove the register offset macros from OMAP GPIO driver and handle the same in mach-omap*.
Thanks for working on this cleanup, this driver really needs a cleanup.
You've hit on all the main areas for cleanup, but unfortunately, it's not really going in the direction I was hoping. ?Rather than moving code into the SoC specific parts, I was hoping to generalize the driver such that SoC-specific code would just pass in register offsets/options into the common driver. ?Your current approach isn't really reducing code, it's just moving it around.
Quoted 6 lines
I had started on a similar cleanup as well, and will post that series shortly to demonstrate the direction I think the cleanups should be going. ?I've tackled most of the same functions/areas that you have (except the IRQ triggering stuff), but have a rather different approach. I'll get to the IRQ triggering stuff next (after going on vacation for a week), but feel free to build on top of my series if you like.
Sure. I will wait for your series.
-V Charulatha
Quoted 13 lines
The direction I'd like to go is towards having a generalized driver that can not only work across all OMAP SoCs, but also hopefully towards something that can be shared with other SoCs as well. ?Of course, the first step is cleaning up the OMAP driver, but the next step will be looking for other areas of consolidation. ?Towards that end, I'm also working towards converting the GPIO IRQs in this driver to use the new generic IRQ chip infrastructure posted by Thomas Gleixner. ?In my series, you'll see that I started that for the MPUIO IRQs, but the GPIO IRQs will come next.
Kevin