]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
tegra2: Use new GPIO APIs in gpio_config_uart()
authorStephen Warren <swarren@nvidia.com>
Thu, 6 Oct 2011 12:52:22 +0000 (12:52 +0000)
committerAlbert ARIBAUD <albert.u.boot@aribaud.net>
Fri, 9 Dec 2011 16:30:08 +0000 (17:30 +0100)
... rather than open-coding the register accesses.

However, gpio_request() typically stores the "label" parameter in a global
data structure. This causes problems when called from gpio_config_uart(),
since the code is running before relocation. To solve this, pass a NULL
string to gpio_request(), and modify gpio_request() not to touch the string
if it's NULL.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Warren <twarren@nvidia.com>
board/nvidia/seaboard/seaboard.c
drivers/gpio/tegra2_gpio.c

index aa77f12ef54c589c1508e7e37221c37bd362aec0..7f2827b8be096f72ee77607a730cfdfe3f7b34d2 100644 (file)
  */
 static void gpio_config_uart_seaboard(void)
 {
-       int gp = GPIO_PI3;
-       struct gpio_ctlr *gpio = (struct gpio_ctlr *)NV_PA_GPIO_BASE;
-       struct gpio_ctlr_bank *bank = &gpio->gpio_bank[GPIO_BANK(gp)];
-       u32 val;
-
        /* Enable UART via GPIO_PI3 (port 8, bit 3) so serial console works */
-       val = readl(&bank->gpio_config[GPIO_PORT(gp)]);
-       val |= 1 << GPIO_BIT(gp);
-       writel(val, &bank->gpio_config[GPIO_PORT(gp)]);
-
-       val = readl(&bank->gpio_out[GPIO_PORT(gp)]);
-       val &= ~(1 << GPIO_BIT(gp));
-       writel(val, &bank->gpio_out[GPIO_PORT(gp)]);
-
-       val = readl(&bank->gpio_dir_out[GPIO_PORT(gp)]);
-       val |= 1 << GPIO_BIT(gp);
-       writel(val, &bank->gpio_dir_out[GPIO_PORT(gp)]);
+       gpio_request(GPIO_PI3, NULL);
+       gpio_direction_output(GPIO_PI3, 0);
 }
 
 void gpio_config_uart(void)
index f686e80637a0eb5619f1e357f2c6b4ea3a9cc36c..22669b6160e6dd27c20e1a4ebf9318055cf83bc4 100644 (file)
@@ -146,8 +146,10 @@ int gpio_request(int gp, const char *label)
        if (gp >= MAX_NUM_GPIOS)
                return -1;
 
-       strncpy(gpio_names[gp].name, label, GPIO_NAME_SIZE);
-       gpio_names[gp].name[GPIO_NAME_SIZE - 1] = '\0';
+       if (label != NULL) {
+               strncpy(gpio_names[gp].name, label, GPIO_NAME_SIZE);
+               gpio_names[gp].name[GPIO_NAME_SIZE - 1] = '\0';
+       }
 
        /* Configure as a GPIO */
        set_config(gp, 1);