Merge branch 'u-boot-atmel/master' into 'u-boot-arm/master'
[oweals/u-boot.git] / arch / blackfin / cpu / gpio.c
index cb96721cf4a7b910e6b57eec984d2098c0dfdee2..f684be531c4b079e516016affde629f5ab0dfe1e 100644 (file)
@@ -66,6 +66,14 @@ static struct gpio_port_t * const gpio_array[] = {
        (struct gpio_port_t *)PORTH_FER,
        (struct gpio_port_t *)PORTI_FER,
        (struct gpio_port_t *)PORTJ_FER,
+#elif defined(CONFIG_BF60x)
+       (struct gpio_port_t *)PORTA_FER,
+       (struct gpio_port_t *)PORTB_FER,
+       (struct gpio_port_t *)PORTC_FER,
+       (struct gpio_port_t *)PORTD_FER,
+       (struct gpio_port_t *)PORTE_FER,
+       (struct gpio_port_t *)PORTF_FER,
+       (struct gpio_port_t *)PORTG_FER,
 #else
 # error no gpio arrays defined
 #endif
@@ -216,6 +224,12 @@ static void port_setup(unsigned gpio, unsigned short usage)
        else
                gpio_array[gpio_bank(gpio)]->port_fer |= gpio_bit(gpio);
        SSYNC();
+#elif defined(CONFIG_BF60x)
+       if (usage == GPIO_USAGE)
+               gpio_array[gpio_bank(gpio)]->port_fer_clear = gpio_bit(gpio);
+       else
+               gpio_array[gpio_bank(gpio)]->port_fer_set = gpio_bit(gpio);
+       SSYNC();
 #endif
 }
 
@@ -290,7 +304,7 @@ static void portmux_setup(unsigned short per)
                }
        }
 }
-#elif defined(CONFIG_BF54x)
+#elif defined(CONFIG_BF54x) || defined(CONFIG_BF60x)
 inline void portmux_setup(unsigned short per)
 {
        u32 pmux;
@@ -330,7 +344,7 @@ inline void portmux_setup(unsigned short per)
 # define portmux_setup(...)  do { } while (0)
 #endif
 
-#ifndef CONFIG_BF54x
+#if !defined(CONFIG_BF54x) && !defined(CONFIG_BF60x)
 /***********************************************************
 *
 * FUNCTIONS: Blackfin General Purpose Ports Access Functions
@@ -534,7 +548,7 @@ int peripheral_request(unsigned short per, const char *label)
                 * be requested and used by several drivers
                 */
 
-#ifdef CONFIG_BF54x
+#if defined(CONFIG_BF54x) || defined(CONFIG_BF60x)
                if (!((per & P_MAYSHARE) && get_portmux(per) == P_FUNCT2MUX(per))) {
 #else
                if (!(per & P_MAYSHARE)) {
@@ -651,7 +665,7 @@ int bfin_gpio_request(unsigned gpio, const char *label)
                       gpio, get_label(gpio));
                return -EBUSY;
        }
-#ifndef CONFIG_BF54x
+#if !defined(CONFIG_BF54x) && !defined(CONFIG_BF60x)
        else {  /* Reset POLAR setting when acquiring a gpio for the first time */
                set_gpio_polar(gpio, 0);
        }
@@ -665,6 +679,7 @@ int bfin_gpio_request(unsigned gpio, const char *label)
        return 0;
 }
 
+#ifdef CONFIG_BFIN_GPIO_TRACK
 void bfin_gpio_free(unsigned gpio)
 {
        if (check_gpio(gpio) < 0)
@@ -679,6 +694,7 @@ void bfin_gpio_free(unsigned gpio)
 
        set_label(gpio, "free");
 }
+#endif
 
 #ifdef BFIN_SPECIAL_GPIO_BANKS
 DECLARE_RESERVED_MAP(special_gpio, gpio_bank(MAX_RESOURCES));
@@ -730,12 +746,16 @@ void bfin_special_gpio_free(unsigned gpio)
 
 static inline void __bfin_gpio_direction_input(unsigned gpio)
 {
-#ifdef CONFIG_BF54x
+#if defined(CONFIG_BF54x) || defined(CONFIG_BF60x)
        gpio_array[gpio_bank(gpio)]->dir_clear = gpio_bit(gpio);
 #else
        gpio_array[gpio_bank(gpio)]->dir &= ~gpio_bit(gpio);
 #endif
+#if defined(CONFIG_BF60x)
+       gpio_array[gpio_bank(gpio)]->inen_set = gpio_bit(gpio);
+#else
        gpio_array[gpio_bank(gpio)]->inen |= gpio_bit(gpio);
+#endif
 }
 
 int bfin_gpio_direction_input(unsigned gpio)
@@ -783,9 +803,13 @@ int bfin_gpio_direction_output(unsigned gpio, int value)
 
        local_irq_save(flags);
 
+#if defined(CONFIG_BF60x)
+       gpio_array[gpio_bank(gpio)]->inen_clear = gpio_bit(gpio);
+#else
        gpio_array[gpio_bank(gpio)]->inen &= ~gpio_bit(gpio);
+#endif
        gpio_set_value(gpio, value);
-#ifdef CONFIG_BF54x
+#if defined(CONFIG_BF54x) || defined(CONFIG_BF60x)
        gpio_array[gpio_bank(gpio)]->dir_set = gpio_bit(gpio);
 #else
        gpio_array[gpio_bank(gpio)]->dir |= gpio_bit(gpio);
@@ -799,7 +823,7 @@ int bfin_gpio_direction_output(unsigned gpio, int value)
 
 int bfin_gpio_get_value(unsigned gpio)
 {
-#ifdef CONFIG_BF54x
+#if defined(CONFIG_BF54x) || defined(CONFIG_BF60x)
        return (1 & (gpio_array[gpio_bank(gpio)]->data >> gpio_sub_n(gpio)));
 #else
        unsigned long flags;