Commit b06f3e19 authored by Aurelien Jarno's avatar Aurelien Jarno Committed by Ralf Baechle

MIPS: BCM47xx: Use the new SSB GPIO API

This patch simplifies the BCM47xx GPIO code by using the new SSB GPIO
API, which does a lot things that were implemented directly in the
BCM47xx code.
Signed-off-by: default avatarAurelien Jarno <aurelien@aurel32.net>
Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent d412283c
...@@ -52,6 +52,7 @@ config BCM47XX ...@@ -52,6 +52,7 @@ config BCM47XX
select SSB select SSB
select SSB_DRIVER_MIPS select SSB_DRIVER_MIPS
select SSB_DRIVER_EXTIF select SSB_DRIVER_EXTIF
select SSB_EMBEDDED
select SSB_PCICORE_HOSTMODE if PCI select SSB_PCICORE_HOSTMODE if PCI
select GENERIC_GPIO select GENERIC_GPIO
select SYS_HAS_EARLY_PRINTK select SYS_HAS_EARLY_PRINTK
......
...@@ -12,68 +12,51 @@ ...@@ -12,68 +12,51 @@
#include <asm/mach-bcm47xx/bcm47xx.h> #include <asm/mach-bcm47xx/bcm47xx.h>
#include <asm/mach-bcm47xx/gpio.h> #include <asm/mach-bcm47xx/gpio.h>
int bcm47xx_gpio_to_irq(unsigned gpio) #if (BCM47XX_CHIPCO_GPIO_LINES > BCM47XX_EXTIF_GPIO_LINES)
static DECLARE_BITMAP(gpio_in_use, BCM47XX_CHIPCO_GPIO_LINES);
#else
static DECLARE_BITMAP(gpio_in_use, BCM47XX_EXTIF_GPIO_LINES);
#endif
int gpio_request(unsigned gpio, const char *tag)
{ {
if (ssb_bcm47xx.chipco.dev) if (ssb_chipco_available(&ssb_bcm47xx.chipco) &&
return ssb_mips_irq(ssb_bcm47xx.chipco.dev) + 2; ((unsigned)gpio >= BCM47XX_CHIPCO_GPIO_LINES))
else if (ssb_bcm47xx.extif.dev)
return ssb_mips_irq(ssb_bcm47xx.extif.dev) + 2;
else
return -EINVAL; return -EINVAL;
}
EXPORT_SYMBOL_GPL(bcm47xx_gpio_to_irq);
int bcm47xx_gpio_get_value(unsigned gpio) if (ssb_extif_available(&ssb_bcm47xx.extif) &&
{ ((unsigned)gpio >= BCM47XX_EXTIF_GPIO_LINES))
if (ssb_bcm47xx.chipco.dev) return -EINVAL;
return ssb_chipco_gpio_in(&ssb_bcm47xx.chipco, 1 << gpio);
else if (ssb_bcm47xx.extif.dev) if (test_and_set_bit(gpio, gpio_in_use))
return ssb_extif_gpio_in(&ssb_bcm47xx.extif, 1 << gpio); return -EBUSY;
else
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(bcm47xx_gpio_get_value); EXPORT_SYMBOL(gpio_request);
void bcm47xx_gpio_set_value(unsigned gpio, int value) void gpio_free(unsigned gpio)
{ {
if (ssb_bcm47xx.chipco.dev) if (ssb_chipco_available(&ssb_bcm47xx.chipco) &&
ssb_chipco_gpio_out(&ssb_bcm47xx.chipco, ((unsigned)gpio >= BCM47XX_CHIPCO_GPIO_LINES))
1 << gpio, return;
value ? 1 << gpio : 0);
else if (ssb_bcm47xx.extif.dev)
ssb_extif_gpio_out(&ssb_bcm47xx.extif,
1 << gpio,
value ? 1 << gpio : 0);
}
EXPORT_SYMBOL_GPL(bcm47xx_gpio_set_value);
int bcm47xx_gpio_direction_input(unsigned gpio) if (ssb_extif_available(&ssb_bcm47xx.extif) &&
{ ((unsigned)gpio >= BCM47XX_EXTIF_GPIO_LINES))
if (ssb_bcm47xx.chipco.dev && (gpio < BCM47XX_CHIPCO_GPIO_LINES)) return;
ssb_chipco_gpio_outen(&ssb_bcm47xx.chipco,
1 << gpio, 0); clear_bit(gpio, gpio_in_use);
else if (ssb_bcm47xx.extif.dev && (gpio < BCM47XX_EXTIF_GPIO_LINES))
ssb_extif_gpio_outen(&ssb_bcm47xx.extif,
1 << gpio, 0);
else
return -EINVAL;
return 0;
} }
EXPORT_SYMBOL_GPL(bcm47xx_gpio_direction_input); EXPORT_SYMBOL(gpio_free);
int bcm47xx_gpio_direction_output(unsigned gpio, int value) int gpio_to_irq(unsigned gpio)
{ {
bcm47xx_gpio_set_value(gpio, value); if (ssb_chipco_available(&ssb_bcm47xx.chipco))
return ssb_mips_irq(ssb_bcm47xx.chipco.dev) + 2;
if (ssb_bcm47xx.chipco.dev && (gpio < BCM47XX_CHIPCO_GPIO_LINES)) else if (ssb_extif_available(&ssb_bcm47xx.extif))
ssb_chipco_gpio_outen(&ssb_bcm47xx.chipco, return ssb_mips_irq(ssb_bcm47xx.extif.dev) + 2;
1 << gpio, 1 << gpio);
else if (ssb_bcm47xx.extif.dev && (gpio < BCM47XX_EXTIF_GPIO_LINES))
ssb_extif_gpio_outen(&ssb_bcm47xx.extif,
1 << gpio, 1 << gpio);
else else
return -EINVAL; return -EINVAL;
return 0;
} }
EXPORT_SYMBOL_GPL(bcm47xx_gpio_direction_output); EXPORT_SYMBOL_GPL(gpio_to_irq);
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/ssb/ssb.h> #include <linux/ssb/ssb.h>
#include <linux/ssb/ssb_embedded.h>
#include <asm/bootinfo.h> #include <asm/bootinfo.h>
#include <asm/reboot.h> #include <asm/reboot.h>
#include <asm/time.h> #include <asm/time.h>
...@@ -41,7 +42,7 @@ static void bcm47xx_machine_restart(char *command) ...@@ -41,7 +42,7 @@ static void bcm47xx_machine_restart(char *command)
printk(KERN_ALERT "Please stand by while rebooting the system...\n"); printk(KERN_ALERT "Please stand by while rebooting the system...\n");
local_irq_disable(); local_irq_disable();
/* Set the watchdog timer to reset immediately */ /* Set the watchdog timer to reset immediately */
ssb_chipco_watchdog_timer_set(&ssb_bcm47xx.chipco, 1); ssb_watchdog_timer_set(&ssb_bcm47xx, 1);
while (1) while (1)
cpu_relax(); cpu_relax();
} }
...@@ -50,7 +51,7 @@ static void bcm47xx_machine_halt(void) ...@@ -50,7 +51,7 @@ static void bcm47xx_machine_halt(void)
{ {
/* Disable interrupts and watchdog and spin forever */ /* Disable interrupts and watchdog and spin forever */
local_irq_disable(); local_irq_disable();
ssb_chipco_watchdog_timer_set(&ssb_bcm47xx.chipco, 0); ssb_watchdog_timer_set(&ssb_bcm47xx, 0);
while (1) while (1)
cpu_relax(); cpu_relax();
} }
......
...@@ -9,47 +9,46 @@ ...@@ -9,47 +9,46 @@
#ifndef __BCM47XX_GPIO_H #ifndef __BCM47XX_GPIO_H
#define __BCM47XX_GPIO_H #define __BCM47XX_GPIO_H
#include <linux/ssb/ssb_embedded.h>
#include <asm/mach-bcm47xx/bcm47xx.h>
#define BCM47XX_EXTIF_GPIO_LINES 5 #define BCM47XX_EXTIF_GPIO_LINES 5
#define BCM47XX_CHIPCO_GPIO_LINES 16 #define BCM47XX_CHIPCO_GPIO_LINES 16
extern int bcm47xx_gpio_to_irq(unsigned gpio); extern int gpio_request(unsigned gpio, const char *label);
extern int bcm47xx_gpio_get_value(unsigned gpio); extern void gpio_free(unsigned gpio);
extern void bcm47xx_gpio_set_value(unsigned gpio, int value); extern int gpio_to_irq(unsigned gpio);
extern int bcm47xx_gpio_direction_input(unsigned gpio);
extern int bcm47xx_gpio_direction_output(unsigned gpio, int value);
static inline int gpio_request(unsigned gpio, const char *label)
{
return 0;
}
static inline void gpio_free(unsigned gpio) static inline int gpio_get_value(unsigned gpio)
{ {
return ssb_gpio_in(&ssb_bcm47xx, 1 << gpio);
} }
static inline int gpio_to_irq(unsigned gpio) static inline void gpio_set_value(unsigned gpio, int value)
{ {
return bcm47xx_gpio_to_irq(gpio); ssb_gpio_out(&ssb_bcm47xx, 1 << gpio, value ? 1 << gpio : 0);
} }
static inline int gpio_get_value(unsigned gpio) static inline int gpio_direction_input(unsigned gpio)
{ {
return bcm47xx_gpio_get_value(gpio); return ssb_gpio_outen(&ssb_bcm47xx, 1 << gpio, 0);
} }
static inline void gpio_set_value(unsigned gpio, int value) static inline int gpio_direction_output(unsigned gpio, int value)
{ {
bcm47xx_gpio_set_value(gpio, value); return ssb_gpio_outen(&ssb_bcm47xx, 1 << gpio, 1 << gpio);
} }
static inline int gpio_direction_input(unsigned gpio) static int gpio_intmask(unsigned gpio, int value)
{ {
return bcm47xx_gpio_direction_input(gpio); return ssb_gpio_intmask(&ssb_bcm47xx, 1 << gpio,
value ? 1 << gpio : 0);
} }
static inline int gpio_direction_output(unsigned gpio, int value) static int gpio_polarity(unsigned gpio, int value)
{ {
return bcm47xx_gpio_direction_output(gpio, value); return ssb_gpio_polarity(&ssb_bcm47xx, 1 << gpio,
value ? 1 << gpio : 0);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment