Commit acbcd263 authored by Michael Hennerich's avatar Michael Hennerich Committed by Bryan Wu

[Blackfin] arch: Fix BUG gpio_direction_output API is not compatitable with...

[Blackfin] arch: Fix BUG gpio_direction_output API is not compatitable with GENERIC_GPIO API interface
signef-off-by: default avatarMichael Hennerich <michael.hennerich@analog.com>
Signed-off-by: default avatarBryan Wu <bryan.wu@analog.com>
parent b97b8a99
......@@ -229,6 +229,11 @@ inline int check_gpio(unsigned short gpio)
}
#endif
void gpio_error(unsigned gpio)
{
printk(KERN_ERR "bfin-gpio: GPIO %d wasn't requested!\n", gpio);
}
static void set_label(unsigned short ident, const char *label)
{
......@@ -1034,7 +1039,7 @@ EXPORT_SYMBOL(peripheral_free_list);
* MODIFICATION HISTORY :
**************************************************************/
int gpio_request(unsigned short gpio, const char *label)
int gpio_request(unsigned gpio, const char *label)
{
unsigned long flags;
......@@ -1081,7 +1086,7 @@ int gpio_request(unsigned short gpio, const char *label)
}
EXPORT_SYMBOL(gpio_request);
void gpio_free(unsigned short gpio)
void gpio_free(unsigned gpio)
{
unsigned long flags;
......@@ -1091,7 +1096,7 @@ void gpio_free(unsigned short gpio)
local_irq_save(flags);
if (unlikely(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio)))) {
printk(KERN_ERR "bfin-gpio: GPIO %d wasn't reserved!\n", gpio);
gpio_error(gpio);
dump_stack();
local_irq_restore(flags);
return;
......@@ -1107,34 +1112,47 @@ void gpio_free(unsigned short gpio)
}
EXPORT_SYMBOL(gpio_free);
#ifdef BF548_FAMILY
void gpio_direction_input(unsigned short gpio)
int gpio_direction_input(unsigned gpio)
{
unsigned long flags;
BUG_ON(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio)));
if (!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))) {
gpio_error(gpio);
return -EINVAL;
}
local_irq_save(flags);
gpio_array[gpio_bank(gpio)]->port_dir_clear = gpio_bit(gpio);
gpio_array[gpio_bank(gpio)]->port_inen |= gpio_bit(gpio);
local_irq_restore(flags);
return 0;
}
EXPORT_SYMBOL(gpio_direction_input);
void gpio_direction_output(unsigned short gpio)
int gpio_direction_output(unsigned gpio, int value)
{
unsigned long flags;
BUG_ON(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio)));
if (!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))) {
gpio_error(gpio);
return -EINVAL;
}
local_irq_save(flags);
gpio_array[gpio_bank(gpio)]->port_inen &= ~gpio_bit(gpio);
gpio_set_value(gpio, value);
gpio_array[gpio_bank(gpio)]->port_dir_set = gpio_bit(gpio);
local_irq_restore(flags);
return 0;
}
EXPORT_SYMBOL(gpio_direction_output);
void gpio_set_value(unsigned short gpio, unsigned short arg)
void gpio_set_value(unsigned gpio, int arg)
{
if (arg)
gpio_array[gpio_bank(gpio)]->port_set = gpio_bit(gpio);
......@@ -1144,7 +1162,7 @@ void gpio_set_value(unsigned short gpio, unsigned short arg)
}
EXPORT_SYMBOL(gpio_set_value);
unsigned short gpio_get_value(unsigned short gpio)
int gpio_get_value(unsigned gpio)
{
return (1 & (gpio_array[gpio_bank(gpio)]->port_data >> gpio_sub_n(gpio)));
}
......@@ -1152,31 +1170,42 @@ EXPORT_SYMBOL(gpio_get_value);
#else
void gpio_direction_input(unsigned short gpio)
int gpio_direction_input(unsigned gpio)
{
unsigned long flags;
BUG_ON(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio)));
if (!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))) {
gpio_error(gpio);
return -EINVAL;
}
local_irq_save(flags);
gpio_bankb[gpio_bank(gpio)]->dir &= ~gpio_bit(gpio);
gpio_bankb[gpio_bank(gpio)]->inen |= gpio_bit(gpio);
AWA_DUMMY_READ(inen);
local_irq_restore(flags);
return 0;
}
EXPORT_SYMBOL(gpio_direction_input);
void gpio_direction_output(unsigned short gpio)
int gpio_direction_output(unsigned gpio, int value)
{
unsigned long flags;
BUG_ON(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio)));
if (!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))) {
gpio_error(gpio);
return -EINVAL;
}
local_irq_save(flags);
gpio_bankb[gpio_bank(gpio)]->inen &= ~gpio_bit(gpio);
gpio_set_value(gpio, value);
gpio_bankb[gpio_bank(gpio)]->dir |= gpio_bit(gpio);
AWA_DUMMY_READ(dir);
local_irq_restore(flags);
return 0;
}
EXPORT_SYMBOL(gpio_direction_output);
......
......@@ -317,12 +317,7 @@ static struct resource sl811_hcd_resources[] = {
void sl811_port_power(struct device *dev, int is_on)
{
gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS);
if (is_on)
gpio_set_value(CONFIG_USB_SL811_BFIN_GPIO_VBUS, 1);
else
gpio_set_value(CONFIG_USB_SL811_BFIN_GPIO_VBUS, 0);
gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS, is_on);
}
#endif
......
......@@ -205,12 +205,8 @@ static struct resource sl811_hcd_resources[] = {
void sl811_port_power(struct device *dev, int is_on)
{
gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS);
gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS, is_on);
if (is_on)
gpio_set_value(CONFIG_USB_SL811_BFIN_GPIO_VBUS, 1);
else
gpio_set_value(CONFIG_USB_SL811_BFIN_GPIO_VBUS, 0);
}
#endif
......
......@@ -134,12 +134,8 @@ static struct resource sl811_hcd_resources[] = {
void sl811_port_power(struct device *dev, int is_on)
{
gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS);
gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS, is_on);
if (is_on)
gpio_set_value(CONFIG_USB_SL811_BFIN_GPIO_VBUS, 1);
else
gpio_set_value(CONFIG_USB_SL811_BFIN_GPIO_VBUS, 0);
}
#endif
......
......@@ -250,12 +250,7 @@ static struct resource sl811_hcd_resources[] = {
void sl811_port_power(struct device *dev, int is_on)
{
gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS);
if (is_on)
gpio_set_value(CONFIG_USB_SL811_BFIN_GPIO_VBUS, 1);
else
gpio_set_value(CONFIG_USB_SL811_BFIN_GPIO_VBUS, 0);
gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS, is_on);
}
#endif
......
......@@ -264,8 +264,7 @@ static int request_ports(struct bfin_bf54xfb_info *fbi)
}
}
gpio_direction_output(disp);
gpio_set_value(disp, 1);
gpio_direction_output(disp, 1);
return 0;
}
......
......@@ -426,19 +426,19 @@ struct gpio_port_s {
* MODIFICATION HISTORY :
**************************************************************/
int gpio_request(unsigned short, const char *);
void gpio_free(unsigned short);
int gpio_request(unsigned, const char *);
void gpio_free(unsigned);
void gpio_set_value(unsigned short gpio, unsigned short arg);
unsigned short gpio_get_value(unsigned short gpio);
void gpio_set_value(unsigned gpio, int arg);
int gpio_get_value(unsigned gpio);
#ifndef BF548_FAMILY
#define gpio_get_value(gpio) get_gpio_data(gpio)
#define gpio_set_value(gpio, value) set_gpio_data(gpio, value)
#endif
void gpio_direction_input(unsigned short gpio);
void gpio_direction_output(unsigned short gpio);
int gpio_direction_input(unsigned gpio);
int gpio_direction_output(unsigned gpio, int value);
#include <asm-generic/gpio.h> /* cansleep wrappers */
#include <asm/irq.h>
......
......@@ -146,7 +146,7 @@ static void bfin_serial_hw_init(struct bfin_serial_port *uart)
if (uart->rts_pin >= 0) {
gpio_request(uart->rts_pin, DRIVER_NAME);
gpio_direction_output(uart->rts_pin);
gpio_direction_output(uart->rts_pin, 0);
}
#endif
}
......@@ -111,7 +111,7 @@ static void bfin_serial_hw_init(struct bfin_serial_port *uart)
}
if (uart->rts_pin >= 0) {
gpio_request(uart->rts_pin, DRIVER_NAME);
gpio_direction_input(uart->rts_pin);
gpio_direction_input(uart->rts_pin, 0);
}
#endif
}
......@@ -146,7 +146,7 @@ static void bfin_serial_hw_init(struct bfin_serial_port *uart)
if (uart->rts_pin >= 0) {
gpio_request(uart->rts_pin, DRIVER_NAME);
gpio_direction_output(uart->rts_pin);
gpio_direction_output(uart->rts_pin, 0);
}
#endif
}
......@@ -186,7 +186,7 @@ static void bfin_serial_hw_init(struct bfin_serial_port *uart)
if (uart->rts_pin >= 0) {
gpio_request(uart->rts_pin, DRIVER_NAME);
gpio_direction_output(uart->rts_pin);
gpio_direction_output(uart->rts_pin, 0);
}
#endif
}
......@@ -111,7 +111,7 @@ static void bfin_serial_hw_init(struct bfin_serial_port *uart)
}
if (uart->rts_pin >= 0) {
gpio_request(uart->rts_pin, DRIVER_NAME);
gpio_direction_input(uart->rts_pin);
gpio_direction_input(uart->rts_pin, 0);
}
#endif
}
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