omap: gpio: User generic (instead of custom) API
cover omap: gpio: User generic (instead of custom) API
The OMAP boards use a custom api for GPIO operations. While it works, it doesn't help when when we don't know existence of the customization.
I earlier encountered the problem when looking for GPIO related changes when submitting prev set of patches. Since the search for gpio_request() in omap sources returned empty, I had assumed that it isn't supported.
This patchset attempts to adapt the current implementation to use generic API.
Since, the changes impact all OMAP boards, and I wouldn't be able to test on all, I decided to submit changes as RFC. Unless any major issue is found, I will be able to submit as formal patch by end of this week.
Following bash script was used to replace all occurences of the custom API with generic equivalent. After the changes, I have compile tested the OMAP3EVM only. Will be able to test changes only by FRI.
#!/bin/bash
list=search.lst
[ -f ${list} ] && \rm -rf ${list}
grep -l -R "omap_.*_gpio" . > ${list}
sed -i '/\.sh$/d' ${list}
sed -i '/\.o$/d' ${list}
sed -i '/\.orig$/d' ${list}
sed -i '/\.rej$/d' ${list}
sed -i '/\.git/d' ${list}
sed -i '/patch/d' ${list}
sed -i '/diff/d' ${list}
sed -i '/save/d' ${list} for f in cat ${list} ;
do
echo "Fixing $f..."
sed -r -i 's/omap_request_gpio\s*\((\w+)\)/gpio_request(\1, "")/g' "$f"
sed -r -i 's/omap_free_gpio/gpio_free/g' "$f"
sed -r -i 's/omap_set_gpio_direction\s*\((\w+),\s*1\)/gpio_direction_input(\1)/g' "$f"
sed -r -i 's/omap_set_gpio_direction\s*\((\w+),\s*0\)/gpio_direction_output(\1)/g' "$f"
sed -r -i 's/omap_set_gpio_dataout/gpio_set_value/g' "$f"
sed -r -i 's/omap_get_gpio_datain/gpio_get_value/g' "$f"done
Sanjeev Premi (3):
omap: gpio: Use generic API
omap: gpio: generic changes after changing API
omap: gpio: Adapt board files to use generic API
arch/arm/cpu/armv7/omap-common/gpio.c | 74 +++++++++++++++++++++++--------- arch/arm/cpu/armv7/omap4/clocks.c | 4 +- arch/arm/include/asm/arch-omap3/gpio.h | 19 ++++++++ arch/arm/include/asm/omap_gpio.h | 13 ------ board/cm_t35/leds.c | 4 +- board/comelit/dig297/dig297.c | 10 ++-- board/isee/igep0020/igep0020.c | 10 ++-- board/logicpd/zoom2/debug_board.c | 8 ++-- board/logicpd/zoom2/led.c | 36 ++++++++-------- board/logicpd/zoom2/zoom2.c | 8 ++-- board/overo/overo.c | 52 +++++++++++----------- board/ti/beagle/beagle.c | 34 +++++++------- board/ti/beagle/led.c | 12 +++--- board/ti/evm/evm.c | 12 +++--- doc/README.omap3 | 20 ++++---- 15 files changed, 177 insertions(+), 139 deletions(-) create mode 100644 arch/arm/include/asm/arch-omap3/gpio.h
RFC 1/3 omap: gpio: Use generic API
Convert all OMAP specific functions to use the common API definitions in include/asm/gpio.h. In the process, made few additional changes:
- Use -EINVAL consistently. -1 was used in many places.
- Removed one-liner static functions that were used only once. Replaced the content as necessary.
A dummy header was created to meet the include dependency of asm/arch/gpio.h.
---
It appears that file omap_gpio.h can be renamed to gpio.h avoiding the need to create a dummy file, but I have to try this.
arch/arm/cpu/armv7/omap-common/gpio.c | 74 +++++++++++++++++++++++--------- arch/arm/include/asm/arch-omap3/gpio.h | 19 ++++++++ arch/arm/include/asm/omap_gpio.h | 13 ------ 3 files changed, 72 insertions(+), 34 deletions(-) create mode 100644 arch/arm/include/asm/arch-omap3/gpio.h
arch/arm/cpu/armv7/omap-common/gpio.c +53 -21
@@ -36,9 +36,9 @@* published by the Free Software Foundation. */ #include <common.h> -#include <asm/omap_gpio.h> #include <asm/io.h> #include <asm/errno.h> +#include <asm/omap_gpio.h> static inline const struct gpio_bank *get_gpio_bank (int gpio) {
@@ -53,17 +53,17 @@ static inline int get_gpio_index(int gpio)static inline int gpio_valid (int gpio) {if (gpio <0 ) -return -1 ; +return -EINVAL ;if (gpio <192 )return 0 ; -return -1 ; +return -EINVAL ; }static int check_gpio (int gpio) {if (gpio_valid (gpio) <0 ) {printf ("ERROR : check_gpio: invalid GPIO %d\n" , gpio); -return -1 ; +return -EINVAL ; }return 0 ; }
@@ -89,16 +89,6 @@ static void _set_gpio_direction(const struct gpio_bank *bank, int gpio,__raw_writel (l, reg); } -void omap_set_gpio_direction (int gpio,int is_input) -{ -const struct gpio_bank *bank; - -if (check_gpio (gpio) <0 ) -return ; - bank =get_gpio_bank (gpio); -_set_gpio_direction (bank,get_gpio_index (gpio), is_input); -} -static void _set_gpio_dataout (const struct gpio_bank *bank,int gpio,int enable) {
@@ -121,17 +111,23 @@ static void _set_gpio_dataout(const struct gpio_bank *bank, int gpio,__raw_writel (l, reg); } -void omap_set_gpio_dataout (int gpio,int enable) +/** +* Set value of the specified gpio +*/ +void gpio_set_value (int gpio,int value) {const struct gpio_bank *bank;if (check_gpio (gpio) <0 )return ; bank =get_gpio_bank (gpio); -_set_gpio_dataout (bank,get_gpio_index (gpio), enable); +_set_gpio_dataout (bank,get_gpio_index (gpio), value); } -int omap_get_gpio_datain (int gpio) +/** +* Get value of the cpscified gpio +*/ +int gpio_get_value (int gpio) {const struct gpio_bank *bank;void *reg;
@@ -151,20 +147,56 @@ int omap_get_gpio_datain(int gpio) & (1 << get_gpio_index(gpio))) != 0; } -static void _reset_gpio (const struct gpio_bank *bank,int gpio) +/** +* Set gpio direction as input +*/ +int gpio_direction_input (unsigned gpio) { +const struct gpio_bank *bank; + +if (check_gpio (gpio) <0 ) +return -EINVAL ; + + bank =get_gpio_bank (gpio);_set_gpio_direction (bank,get_gpio_index (gpio),1 ); + +return 0 ; } -int omap_request_gpio (int gpio) +/** +* Set gpio direction as output +*/ +int gpio_direction_output (unsigned gpio,int value) { +const struct gpio_bank *bank; +if (check_gpio (gpio) <0 )return -EINVAL ; + bank =get_gpio_bank (gpio); +_set_gpio_dataout (bank,get_gpio_index (gpio), value); +_set_gpio_direction (bank,get_gpio_index (gpio),0 ); +return 0 ; } -void omap_free_gpio (int gpio) +/** +* Request a gpio before using it. +* +* NOTE: Argument 'label' is unused. +*/ +int gpio_request (int gpio,const char *label) +{ +if (check_gpio (gpio) <0 ) +return -EINVAL ; + +return 0 ; +} + +/** +* Reset and free the gpio after using it. +*/ +void gpio_free (unsigned gpio) {const struct gpio_bank *bank;
@@ -172,5 +204,5 @@ void omap_free_gpio(int gpio)return ; bank =get_gpio_bank (gpio); -_reset_gpio (bank, gpio); +_set_gpio_direction (bank,get_gpio_index (gpio),1 ); }
arch/arm/include/asm/arch-omap3/gpio.h new file +19 -0
@@ -0,0 +1,19 @@ +/* +* Copyright (C) 2011, Texas Instruments Incorporated - http://www.ti.com/ +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation version 2. +* +* This program is distributed as is WITHOUT ANY WARRANTY of any +* kind, whether express or implied; without even the implied warranty +* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef _ARCH_GPIO_H_ +#define _ARCH_GPIO_H_ + +/* Empty file required to fulfill include dependency in asm/gpio.h */ + +#endif
arch/arm/include/asm/omap_gpio.h +0 -13
@@ -49,17 +49,4 @@ extern const struct gpio_bank *const omap_gpio_bank;#define METHOD_GPIO_24XX 4 -/* This is the interface */ - -/* Request a gpio before using it */ -int omap_request_gpio (int gpio); -/* Reset and free a gpio after using it */ -void omap_free_gpio (int gpio); -/* Sets the gpio as input or output */ -void omap_set_gpio_direction (int gpio,int is_input); -/* Set or clear a gpio output */ -void omap_set_gpio_dataout (int gpio,int enable); -/* Get the value of a gpio input */ -int omap_get_gpio_datain (int gpio); -#endif /* _GPIO_H_ */
Signature · 1 line
1.7.0.4
RFC 2/3 omap: gpio: generic changes after changing API
In reply to Sanjeev PremiThis patch contains the generic changes required after change to generic API in the previous patch.
---
These changes could have been merged with the previous patch, but kept changes to API separate from the usage.
arch/arm/cpu/armv7/omap4/clocks.c | 4 ++-- doc/README.omap3 | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-)
arch/arm/cpu/armv7/omap4/clocks.c +2 -2
@@ -481,8 +481,8 @@ static void do_scale_tps62361(u32 reg, u32 volt_mv)* VSEL1 is grounded on board. So the following selects * VSEL1 = 0 and VSEL0 = 1 */ -omap_set_gpio_direction (TPS62361_VSEL0_GPIO ,0 ); -omap_set_gpio_dataout (TPS62361_VSEL0_GPIO ,1 ); +gpio_direction_output (TPS62361_VSEL0_GPIO ); +gpio_set_value (TPS62361_VSEL0_GPIO ,1 ); temp =TPS62361_I2C_SLAVE_ADDR | (reg << PRM_VC_VAL_BYPASS_REGADDR_SHIFT) |
doc/README.omap3 +10 -10
@@ -98,24 +98,24 @@ gpio To set a bit : - if (!omap_request_gpio(N)) { - omap_set_gpio_direction(N, 0); - omap_set_gpio_dataout(N, 1); + if (!gpio_request(N, "")) { + gpio_direction_output(N); + gpio_set_value(N, 1); } To clear a bit : - if (!omap_request_gpio(N)) { - omap_set_gpio_direction(N, 0); - omap_set_gpio_dataout(N, 0); + if (!gpio_request(N, "")) { + gpio_direction_output(N); + gpio_set_value(N, 0); } To read a bit : - if (!omap_request_gpio(N)) { - omap_set_gpio_direction(N, 1); - val = omap_get_gpio_datain(N); - omap_free_gpio(N); + if (!gpio_request(N, "")) { + gpio_direction_input(N); + val = gpio_get_value(N); + gpio_free(N); } if (val) printf("GPIO N is set\n");
Signature · 1 line
1.7.0.4
PATCH 3/3 omap: gpio: Adapt board files to use generic API
In reply to Sanjeev PremiThis patch contains updates the sources in the board files to use the generic API.
---
All changes in this patch were done vis script contained in 0/0 of this RFC. Have been able to build for OMAP3EVM so far. Will have to wait until FRI to test.
board/cm_t35/leds.c | 4 +- board/comelit/dig297/dig297.c | 10 +++--- board/isee/igep0020/igep0020.c | 10 +++--- board/logicpd/zoom2/debug_board.c | 8 +++--- board/logicpd/zoom2/led.c | 36 +++++++++++++------------- board/logicpd/zoom2/zoom2.c | 8 +++--- board/overo/overo.c | 52 ++++++++++++++++++------------------ board/ti/beagle/beagle.c | 34 ++++++++++++------------ board/ti/beagle/led.c | 12 ++++---- board/ti/evm/evm.c | 12 ++++---- 10 files changed, 93 insertions(+), 93 deletions(-)
board/cm_t35/leds.c +2 -2
@@ -36,10 +36,10 @@ void __led_init(led_id_t mask, int state)void __led_set (led_id_t mask,int state) { -omap_set_gpio_dataout (leds[mask], state ==STATUS_LED_ON ); +gpio_set_value (leds[mask], state ==STATUS_LED_ON ); }void __led_toggle (led_id_t mask) { -omap_set_gpio_dataout (leds[mask], !omap_get_gpio_datain (leds[mask])); +gpio_set_value (leds[mask], !gpio_get_value (leds[mask])); }
board/comelit/dig297/dig297.c +5 -5
@@ -168,13 +168,13 @@ static void setup_net_chip(void) &ctrl_base->gpmc_nadv_ale);/* Make GPIO 12 as output pin and send a magic pulse through it */ -if (!omap_request_gpio (NET_LAN9221_RESET_GPIO )) { -omap_set_gpio_direction (NET_LAN9221_RESET_GPIO ,0 ); -omap_set_gpio_dataout (NET_LAN9221_RESET_GPIO ,1 ); +if (!gpio_request (NET_LAN9221_RESET_GPIO ,"" )) { +gpio_direction_output (NET_LAN9221_RESET_GPIO ); +gpio_set_value (NET_LAN9221_RESET_GPIO ,1 );udelay (1 ); -omap_set_gpio_dataout (NET_LAN9221_RESET_GPIO ,0 ); +gpio_set_value (NET_LAN9221_RESET_GPIO ,0 );udelay (31000 );/* Should be >= 30ms according to datasheet */ -omap_set_gpio_dataout (NET_LAN9221_RESET_GPIO ,1 ); +gpio_set_value (NET_LAN9221_RESET_GPIO ,1 ); } }#endif /* CONFIG_CMD_NET */
board/isee/igep0020/igep0020.c +5 -5
@@ -81,13 +81,13 @@ static void setup_net_chip(void) &ctrl_base->gpmc_nadv_ale);/* Make GPIO 64 as output pin and send a magic pulse through it */ -if (!omap_request_gpio (64 )) { -omap_set_gpio_direction (64 ,0 ); -omap_set_gpio_dataout (64 ,1 ); +if (!gpio_request (64 ,"" )) { +gpio_direction_output (64 ); +gpio_set_value (64 ,1 );udelay (1 ); -omap_set_gpio_dataout (64 ,0 ); +gpio_set_value (64 ,0 );udelay (1 ); -omap_set_gpio_dataout (64 ,1 ); +gpio_set_value (64 ,1 ); } }#endif
board/logicpd/zoom2/debug_board.c +4 -4
@@ -33,14 +33,14 @@ static void zoom2_debug_board_detect (void) {int val =0 ; -if (!omap_request_gpio (158 )) { +if (!gpio_request (158 ,"" )) {/* * GPIO to query for debug board * 158 db board query */ -omap_set_gpio_direction (158 ,1 ); - val =omap_get_gpio_datain (158 ); -omap_free_gpio (158 ); +gpio_direction_input (158 ); + val =gpio_get_value (158 ); +gpio_free (158 ); }if (!val)
board/logicpd/zoom2/led.c +18 -18
@@ -39,9 +39,9 @@ static unsigned int saved_state[2] = {STATUS_LED_OFF, STATUS_LED_OFF};void red_LED_off (void ) {/* red */ -if (!omap_request_gpio (ZOOM2_LED_RED )) { -omap_set_gpio_direction (ZOOM2_LED_RED ,0 ); -omap_set_gpio_dataout (ZOOM2_LED_RED ,0 ); +if (!gpio_request (ZOOM2_LED_RED ,"" )) { +gpio_direction_output (ZOOM2_LED_RED ); +gpio_set_value (ZOOM2_LED_RED ,0 ); } saved_state[STATUS_LED_RED ] =STATUS_LED_OFF ; }
@@ -49,15 +49,15 @@ void red_LED_off (void)void blue_LED_off (void ) {/* blue */ -if (!omap_request_gpio (ZOOM2_LED_BLUE )) { -omap_set_gpio_direction (ZOOM2_LED_BLUE ,0 ); -omap_set_gpio_dataout (ZOOM2_LED_BLUE ,0 ); +if (!gpio_request (ZOOM2_LED_BLUE ,"" )) { +gpio_direction_output (ZOOM2_LED_BLUE ); +gpio_set_value (ZOOM2_LED_BLUE ,0 ); }/* blue 2 */ -if (!omap_request_gpio (ZOOM2_LED_BLUE2 )) { -omap_set_gpio_direction (ZOOM2_LED_BLUE2 ,0 ); -omap_set_gpio_dataout (ZOOM2_LED_BLUE2 ,0 ); +if (!gpio_request (ZOOM2_LED_BLUE2 ,"" )) { +gpio_direction_output (ZOOM2_LED_BLUE2 ); +gpio_set_value (ZOOM2_LED_BLUE2 ,0 ); } saved_state[STATUS_LED_BLUE ] =STATUS_LED_OFF ; }
@@ -67,9 +67,9 @@ void red_LED_on (void)blue_LED_off ();/* red */ -if (!omap_request_gpio (ZOOM2_LED_RED )) { -omap_set_gpio_direction (ZOOM2_LED_RED ,0 ); -omap_set_gpio_dataout (ZOOM2_LED_RED ,1 ); +if (!gpio_request (ZOOM2_LED_RED ,"" )) { +gpio_direction_output (ZOOM2_LED_RED ); +gpio_set_value (ZOOM2_LED_RED ,1 ); } saved_state[STATUS_LED_RED ] =STATUS_LED_ON ; }
@@ -79,15 +79,15 @@ void blue_LED_on (void)red_LED_off ();/* blue */ -if (!omap_request_gpio (ZOOM2_LED_BLUE )) { -omap_set_gpio_direction (ZOOM2_LED_BLUE ,0 ); -omap_set_gpio_dataout (ZOOM2_LED_BLUE ,1 ); +if (!gpio_request (ZOOM2_LED_BLUE ,"" )) { +gpio_direction_output (ZOOM2_LED_BLUE ); +gpio_set_value (ZOOM2_LED_BLUE ,1 ); }/* blue 2 */ -if (!omap_request_gpio (ZOOM2_LED_BLUE2 )) { -omap_set_gpio_direction (ZOOM2_LED_BLUE2 ,0 ); -omap_set_gpio_dataout (ZOOM2_LED_BLUE2 ,1 ); +if (!gpio_request (ZOOM2_LED_BLUE2 ,"" )) { +gpio_direction_output (ZOOM2_LED_BLUE2 ); +gpio_set_value (ZOOM2_LED_BLUE2 ,1 ); } saved_state[STATUS_LED_BLUE ] =STATUS_LED_ON ;
board/logicpd/zoom2/zoom2.c +4 -4
@@ -89,12 +89,12 @@ void zoom2_identify(void)* and they are not commonly used. They are mentioned here * only for completeness. */ -if (!omap_request_gpio (94 )) { +if (!gpio_request (94 ,"" )) {unsigned int val; -omap_set_gpio_direction (94 ,1 ); - val =omap_get_gpio_datain (94 ); -omap_free_gpio (94 ); +gpio_direction_input (94 ); + val =gpio_get_value (94 ); +gpio_free (94 );if (val) revision =ZOOM2_REVISION_BETA ;
board/overo/overo.c +26 -26
81 lines not on this page · raw message
board/ti/beagle/beagle.c +17 -17
@@ -115,21 +115,21 @@ int get_board_revision(void) {int revision; -if (!omap_request_gpio (171 ) && - !omap_request_gpio (172 ) && - !omap_request_gpio (173 )) { +if (!gpio_request (171 ,"" ) && + !gpio_request (172 ,"" ) && + !gpio_request (173 ,"" )) { -omap_set_gpio_direction (171 ,1 ); -omap_set_gpio_direction (172 ,1 ); -omap_set_gpio_direction (173 ,1 ); +gpio_direction_input (171 ); +gpio_direction_input (172 ); +gpio_direction_input (173 ); - revision =omap_get_gpio_datain (173 ) <<2 | -omap_get_gpio_datain (172 ) <<1 | -omap_get_gpio_datain (171 ); + revision =gpio_get_value (173 ) <<2 | +gpio_get_value (172 ) <<1 | +gpio_get_value (171 ); -omap_free_gpio (171 ); -omap_free_gpio (172 ); -omap_free_gpio (173 ); +gpio_free (171 ); +gpio_free (172 ); +gpio_free (173 ); }else {printf ("Error: unable to acquire board revision GPIOs\n" ); revision =-1 ;
@@ -344,7 +344,7 @@ int board_mmc_init(bd_t *bis)int ehci_hcd_stop (void ) {pr_debug ("Resetting OMAP3 EHCI\n" ); -omap_set_gpio_dataout (GPIO_PHY_RESET ,0 ); +gpio_set_value (GPIO_PHY_RESET ,0 );writel (OMAP_UHH_SYSCONFIG_SOFTRESET ,OMAP3_UHH_BASE +OMAP_UHH_SYSCONFIG );return 0 ; }
@@ -366,9 +366,9 @@ int ehci_hcd_init(void)pr_debug ("Initializing OMAP3 ECHI\n" );/* Put the PHY in RESET */ -omap_request_gpio (GPIO_PHY_RESET ); -omap_set_gpio_direction (GPIO_PHY_RESET ,0 ); -omap_set_gpio_dataout (GPIO_PHY_RESET ,0 ); +gpio_request (GPIO_PHY_RESET ,"" ); +gpio_direction_output (GPIO_PHY_RESET ); +gpio_set_value (GPIO_PHY_RESET ,0 );/* Hold the PHY in RESET for enough time till DIR is high */ /* Refer: ISSUE1 */
@@ -420,7 +420,7 @@ int ehci_hcd_init(void)* PHY is settled and ready */ udelay (10 ); -omap_set_gpio_dataout (GPIO_PHY_RESET ,1 ); +gpio_set_value (GPIO_PHY_RESET ,1 ); hccr = (struct ehci_hccr *)(OMAP3_EHCI_BASE ); hcor = (struct ehci_hcor *)(OMAP3_EHCI_BASE +0x10 );
board/ti/beagle/led.c +6 -6
@@ -71,18 +71,18 @@ void __led_set (led_id_t mask, int state) {#ifdef STATUS_LED_BIT if (STATUS_LED_BIT & mask) { -if (!omap_request_gpio (BEAGLE_LED_USR0 )) { -omap_set_gpio_direction (BEAGLE_LED_USR0 ,0 ); -omap_set_gpio_dataout (BEAGLE_LED_USR0 , state); +if (!gpio_request (BEAGLE_LED_USR0 ,"" )) { +gpio_direction_output (BEAGLE_LED_USR0 ); +gpio_set_value (BEAGLE_LED_USR0 , state); } saved_state[0 ] = state; }#endif #ifdef STATUS_LED_BIT1 if (STATUS_LED_BIT1 & mask) { -if (!omap_request_gpio (BEAGLE_LED_USR1 )) { -omap_set_gpio_direction (BEAGLE_LED_USR1 ,0 ); -omap_set_gpio_dataout (BEAGLE_LED_USR1 , state); +if (!gpio_request (BEAGLE_LED_USR1 ,"" )) { +gpio_direction_output (BEAGLE_LED_USR1 ); +gpio_set_value (BEAGLE_LED_USR1 , state); } saved_state[1 ] = state; }
board/ti/evm/evm.c +6 -6
@@ -33,7 +33,7 @@#include <asm/arch/mem.h> #include <asm/arch/mux.h> #include <asm/arch/sys_proto.h> -#include <asm/arch/gpio.h> +#include <asm/gpio.h> #include <i2c.h> #include <asm/mach-types.h> #include "evm.h"
@@ -195,21 +195,21 @@ static void reset_net_chip(void) rst_gpio =OMAP3EVM_GPIO_ETH_RST_GEN2 ; } - ret =omap_request_gpio (rst_gpio); + ret =gpio_request (rst_gpio,"" );if (ret <0 ) {printf ("Unable to get GPIO %d\n" , rst_gpio);return ; }/* Configure as output */ -omap_set_gpio_direction (rst_gpio,0 ); +gpio_direction_output (rst_gpio,0 );/* Send a pulse on the GPIO pin */ -omap_set_gpio_dataout (rst_gpio,1 ); +gpio_set_value (rst_gpio,1 );udelay (1 ); -omap_set_gpio_dataout (rst_gpio,0 ); +gpio_set_value (rst_gpio,0 );udelay (1 ); -omap_set_gpio_dataout (rst_gpio,1 ); +gpio_set_value (rst_gpio,1 ); }int board_eth_init (bd_t *bis)
Signature · 1 line
1.7.0.4
Premi
PATCH 3/3 omap: gpio: Adapt board files to use generic API
Quoted 8 lines
-----Original Message-----
From: Premi, Sanjeev
Sent: Wednesday, August 31, 2011 1:23 AM
To: u-boot at lists.denx.de
Cc: Premi, Sanjeev; Paulraj, Sandeep; Igor Grinberg; Luca Ceresoli; Enric Balletbo i Serra; Sunil Kumar; Shashi Ranjan; Menon, Nishanth; Steve Sakoman
Subject: [PATCH 3/3] omap: gpio: Adapt board files to use generic API
Sorry, the subject should have read RFC instead of PATCH.
~sanjeev
[...]
cover omap: gpio: User generic (instead of custom) API
In reply to Sanjeev PremiHi Sanjeev,
Quoted 9 lines · Sanjeev Premi
The OMAP boards use a custom api for GPIO operations. While it works, it doesn't help when when we don't know existence of the customization.
I earlier encountered the problem when looking for GPIO related changes when submitting prev set of patches. Since the search for
gpio_request()in omap sources returned empty, I had assumed that it isn't supported.
Quoted 7 lines
This patchset attempts to adapt the current implementation to use generic API.
Since, the changes impact all OMAP boards, and I wouldn't be able to test on all, I decided to submit changes as RFC. Unless any major issue is found, I will be able to submit as formal patch by end of this week.
Tested and working on the dig297 board, on top of the master branch in the u-boot-ti repository.
I also tried to merge your work on the u-boot-arm repo, but it conflicts with the GPIO work recently committed there. You might want to rebase and resubmit when the -ti repo will be in line with the -arm one.
Anyway, for the current version:
Luca
Premi
cover omap: gpio: User generic (instead of custom) API
Quoted 30 lines
-----Original Message-----
From: Luca Ceresoli [mailto:luca.ceresoli at comelit.it]
Sent: Thursday, September 01, 2011 10:19 PM
To: Premi, Sanjeev
Cc: u-boot at lists.denx.de; Paulraj, Sandeep; Igor Grinberg; Enric Balletbo i Serra; Sunil Kumar; Shashi Ranjan; Menon, Nishanth; Steve Sakoman
Subject: Re: [RFC 0/3] omap: gpio: User generic (instead of custom) APIHi Sanjeev,
Quoted 9 lines · Sanjeev Premi
The OMAP boards use a custom api for GPIO operations. While it works, it doesn't help when when we don't know existence of the customization.
I earlier encountered the problem when looking for GPIO related changes when submitting prev set of patches. Since the search for
gpio_request()in omap sources returned empty, I had assumed that it isn't supported.Quoted 7 lines
This patchset attempts to adapt the current implementation to use generic API.
Since, the changes impact all OMAP boards, and I wouldn't be able to test on all, I decided to submit changes as RFC. Unless any major issue is found, I will be able to submit as formal patch by end of this week.
Quoted 7 lines
Tested and working on the dig297 board, on top of the master branch in the u-boot-ti repository.
I also tried to merge your work on the u-boot-arm repo, but it conflicts with the GPIO work recently committed there. You might want to rebase and resubmit when the -ti repo will be in line with the -arm one.
Thanks. I didn't check the -arm repo; had based all patches on the master @ git.denx.de/u-boot.git - assuming there won't been too many changes since recent pull requests.
~sanjeev
(PS: Had to trim the cc: list to ensure message gets through...)
Quoted 5 lines
Anyway, for the current version:
Tested-by Luca Ceresoli <[email protected]>Luca
Premi
cover omap: gpio: User generic (instead of custom) API
In reply to Sanjeev PremiQuoted 89 lines
-----Original Message-----
From: Premi, Sanjeev
Sent: Wednesday, August 31, 2011 1:23 AM
To: u-boot at lists.denx.de
Cc: Premi, Sanjeev; Paulraj, Sandeep; Igor Grinberg; Luca Ceresoli; Enric Balletbo i Serra; Sunil Kumar; Shashi Ranjan; Menon, Nishanth; Steve Sakoman
Subject: [RFC 0/3] omap: gpio: User generic (instead of custom) APIThe OMAP boards use a custom api for GPIO operations. While it works, it doesn't help when when we don't know existence of the customization.
I earlier encountered the problem when looking for GPIO related changes when submitting prev set of patches. Since the search for
gpio_request()in omap sources returned empty, I had assumed that it isn't supported.This patchset attempts to adapt the current implementation to use generic API.
Since, the changes impact all OMAP boards, and I wouldn't be able to test on all, I decided to submit changes as RFC. Unless any major issue is found, I will be able to submit as formal patch by end of this week.
Following bash script was used to replace all occurences of the custom API with generic equivalent. After the changes, I have compile tested the OMAP3EVM only. Will be able to test changes only by FRI.
#!/bin/bash
list=search.lst
[ -f ${list} ] && \rm -rf ${list}
grep -l -R "omap_.*_gpio" . > ${list}
sed -i '/\.sh$/d' ${list} sed -i '/\.o$/d' ${list} sed -i '/\.orig$/d' ${list} sed -i '/\.rej$/d' ${list} sed -i '/\.git/d' ${list} sed -i '/patch/d' ${list} sed -i '/diff/d' ${list} sed -i '/save/d' ${list}for f in
cat ${list};
do
echo "Fixing $f..."sed -r -i
's/omap_request_gpio\s*\((\w+)\)/gpio_request(\1, "")/g' "$f"
sed -r -i 's/omap_free_gpio/gpio_free/g' "$f" sed -r -i
's/omap_set_gpio_direction\s*\((\w+),\s*1\)/gpio_direction_inp ut(\1)/g' "$f"
sed -r -i
's/omap_set_gpio_direction\s*\((\w+),\s*0\)/gpio_direction_out put(\1)/g' "$f"sed -r -i 's/omap_set_gpio_dataout/gpio_set_value/g' "$f" sed -r -i 's/omap_get_gpio_datain/gpio_get_value/g' "$f"done
Sanjeev Premi (3):
omap: gpio: Use generic API
omap: gpio: generic changes after changing API
omap: gpio: Adapt board files to use generic APIarch/arm/cpu/armv7/omap-common/gpio.c | 74 +++++++++++++++++++++++--------- arch/arm/cpu/armv7/omap4/clocks.c | 4 +- arch/arm/include/asm/arch-omap3/gpio.h | 19 ++++++++ arch/arm/include/asm/omap_gpio.h | 13 ------ board/cm_t35/leds.c | 4 +- board/comelit/dig297/dig297.c | 10 ++-- board/isee/igep0020/igep0020.c | 10 ++-- board/logicpd/zoom2/debug_board.c | 8 ++-- board/logicpd/zoom2/led.c | 36 ++++++++-------- board/logicpd/zoom2/zoom2.c | 8 ++-- board/overo/overo.c | 52 +++++++++++----------- board/ti/beagle/beagle.c | 34 +++++++------- board/ti/beagle/led.c | 12 +++--- board/ti/evm/evm.c | 12 +++--- doc/README.omap3 | 20 ++++---- 15 files changed, 177 insertions(+), 139 deletions(-) create mode 100644 arch/arm/include/asm/arch-omap3/gpio.h
Quoted 10 lines
Cc Sandeep Paulraj <[email protected]>Cc Igor Grinberg <[email protected]>Cc Luca Ceresoli <[email protected]>Cc Enric Balletbo i Serra <[email protected]>Cc Sunil Kumar <[email protected]>Cc Shashi Ranjan <[email protected]>Cc Nishanth Menon <[email protected]>Cc Steve Sakoman <[email protected]>
Tested working on the OMAP3EVM.
[bootlog]
U-Boot 2011.06-00396-gfa7a454 (Sep 02 2011 - 10:36:54)
OMAP3630/3730-GP ES2.1, CPU-OPP2, L3-165MHz, Max CPU Clock 1 Ghz OMAP3 EVM board + LPDDR/NAND
I2C: ready DRAM: 384 MiB NAND: 512 MiB
NAND read from offset 260000 failed -74
*** Warning - readenv() failed, using default environment
In: serial Out: serial Err: serial
Read back SMSC id 0x92200000
Die ID #374000029ff80000015f02690c020022
Net: smc911x-0Warning: failed to set MAC address
Hit any key to stop autoboot: 0OMAP3_EVM #
[/bootlog]
I was concerned that 2 failures during boot were due to the changes in this patch set, but foud that they exist on the mainline as well.
Details:
At this commit, omap3_evm_config fails to build:
commit bd061a5214e60c9d1bb24393933323bd1a2dae19
Merge: 98e99e5 fe0ddff
Author: Wolfgang Denk <[email protected]>
Date: Fri Aug 26 15:55:03 2011 +0200 Error is:
make[1]: Entering directory `/home/premi/u-boot/board/ti/evm' evm.c:36:32: fatal error: asm/arch/omap_gpio.h: No such file or directory compilation terminated.
This temporary patch patch was required to fix the build issue on the master branch:
premi # git diff
diff --git a/board/ti/evm/evm.c b/board/ti/evm/evm.c
index 30c1c57..4160cdd 100644
--- a/board/ti/evm/evm.c
+++ b/board/ti/evm/evm.c
@@ -33,7 +33,7 @@
#include <asm/arch/mem.h>
#include <asm/arch/mux.h>
#include <asm/arch/sys_proto.h>
-#include <asm/arch/gpio.h>
+#include <asm/omap_gpio.h>
#include <i2c.h>
#include <asm/mach-types.h>
#include "evm.h"
premi # git logI do have a comment/query regarding this, in 1/1 of my patchset)
[bootlog]
U-Boot 2011.06-00393-gbd061a5-dirty (Sep 02 2011 - 11:03:57)
OMAP3630/3730-GP ES2.1, CPU-OPP2, L3-165MHz, Max CPU Clock 1 Ghz OMAP3 EVM board + LPDDR/NAND
I2C: ready DRAM: 384 MiB NAND: 512 MiB
NAND read from offset 260000 failed -74
*** Warning - readenv() failed, using default environment
In: serial Out: serial Err: serial
Read back SMSC id 0x92200000
Die ID #374000029ff80000015f02690c020022
Net: smc911x-0Warning: failed to set MAC address
Hit any key to stop autoboot: 0OMAP3_EVM #
[/bootlog]
~sanjeev