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

Blackfin arch: gpio pinmux and resource allocation API required by BF537 on...

Blackfin arch: gpio pinmux and resource allocation API required by BF537 on chip ethernet mac driver
Signed-off-by: default avatarMichael Hennerich <michael.hennerich@analog.com>
Signed-off-by: default avatarBryan Wu <bryan.wu@analog.com>
parent 0b95f22b
...@@ -84,6 +84,7 @@ ...@@ -84,6 +84,7 @@
#include <linux/err.h> #include <linux/err.h>
#include <asm/blackfin.h> #include <asm/blackfin.h>
#include <asm/gpio.h> #include <asm/gpio.h>
#include <asm/portmux.h>
#include <linux/irq.h> #include <linux/irq.h>
#ifdef BF533_FAMILY #ifdef BF533_FAMILY
...@@ -115,7 +116,11 @@ static struct gpio_port_t *gpio_bankb[gpio_bank(MAX_BLACKFIN_GPIOS)] = { ...@@ -115,7 +116,11 @@ static struct gpio_port_t *gpio_bankb[gpio_bank(MAX_BLACKFIN_GPIOS)] = {
}; };
#endif #endif
static unsigned short reserved_map[gpio_bank(MAX_BLACKFIN_GPIOS)]; static unsigned short reserved_gpio_map[gpio_bank(MAX_BLACKFIN_GPIOS)];
static unsigned short reserved_peri_map[gpio_bank(MAX_BLACKFIN_GPIOS + 16)];
char *str_ident = NULL;
#define RESOURCE_LABEL_SIZE 16
#ifdef CONFIG_PM #ifdef CONFIG_PM
static unsigned short wakeup_map[gpio_bank(MAX_BLACKFIN_GPIOS)]; static unsigned short wakeup_map[gpio_bank(MAX_BLACKFIN_GPIOS)];
...@@ -143,13 +148,39 @@ inline int check_gpio(unsigned short gpio) ...@@ -143,13 +148,39 @@ inline int check_gpio(unsigned short gpio)
return 0; return 0;
} }
static void set_label(unsigned short ident, const char *label)
{
if (label && str_ident) {
strncpy(str_ident + ident * RESOURCE_LABEL_SIZE, label,
RESOURCE_LABEL_SIZE);
str_ident[ident * RESOURCE_LABEL_SIZE +
RESOURCE_LABEL_SIZE - 1] = 0;
}
}
static char *get_label(unsigned short ident)
{
if (!str_ident)
return "UNKNOWN";
return (str_ident[ident * RESOURCE_LABEL_SIZE] ?
(str_ident + ident * RESOURCE_LABEL_SIZE) : "UNKNOWN");
}
static int cmp_label(unsigned short ident, const char *label)
{
if (label && str_ident)
return strncmp(str_ident + ident * RESOURCE_LABEL_SIZE,
label, strlen(label));
else
return -EINVAL;
}
#ifdef BF537_FAMILY #ifdef BF537_FAMILY
static void port_setup(unsigned short gpio, unsigned short usage) static void port_setup(unsigned short gpio, unsigned short usage)
{ {
if (usage == GPIO_USAGE) { if (usage == GPIO_USAGE) {
if (*port_fer[gpio_bank(gpio)] & gpio_bit(gpio))
printk(KERN_WARNING "bfin-gpio: Possible Conflict with Peripheral "
"usage and GPIO %d detected!\n", gpio);
*port_fer[gpio_bank(gpio)] &= ~gpio_bit(gpio); *port_fer[gpio_bank(gpio)] &= ~gpio_bit(gpio);
} else } else
*port_fer[gpio_bank(gpio)] |= gpio_bit(gpio); *port_fer[gpio_bank(gpio)] |= gpio_bit(gpio);
...@@ -159,6 +190,56 @@ static void port_setup(unsigned short gpio, unsigned short usage) ...@@ -159,6 +190,56 @@ static void port_setup(unsigned short gpio, unsigned short usage)
# define port_setup(...) do { } while (0) # define port_setup(...) do { } while (0)
#endif #endif
#ifdef BF537_FAMILY
#define PMUX_LUT_RES 0
#define PMUX_LUT_OFFSET 1
#define PMUX_LUT_ENTRIES 41
#define PMUX_LUT_SIZE 2
static unsigned short port_mux_lut[PMUX_LUT_ENTRIES][PMUX_LUT_SIZE] = {
{P_PPI0_D13, 11}, {P_PPI0_D14, 11}, {P_PPI0_D15, 11},
{P_SPORT1_TFS, 11}, {P_SPORT1_TSCLK, 11}, {P_SPORT1_DTPRI, 11},
{P_PPI0_D10, 10}, {P_PPI0_D11, 10}, {P_PPI0_D12, 10},
{P_SPORT1_RSCLK, 10}, {P_SPORT1_RFS, 10}, {P_SPORT1_DRPRI, 10},
{P_PPI0_D8, 9}, {P_PPI0_D9, 9}, {P_SPORT1_DRSEC, 9},
{P_SPORT1_DTSEC, 9}, {P_TMR2, 8}, {P_PPI0_FS3, 8}, {P_TMR3, 7},
{P_SPI0_SSEL4, 7}, {P_TMR4, 6}, {P_SPI0_SSEL5, 6}, {P_TMR5, 5},
{P_SPI0_SSEL6, 5}, {P_UART1_RX, 4}, {P_UART1_TX, 4}, {P_TMR6, 4},
{P_TMR7, 4}, {P_UART0_RX, 3}, {P_UART0_TX, 3}, {P_DMAR0, 3},
{P_DMAR1, 3}, {P_SPORT0_DTSEC, 1}, {P_SPORT0_DRSEC, 1},
{P_CAN0_RX, 1}, {P_CAN0_TX, 1}, {P_SPI0_SSEL7, 1},
{P_SPORT0_TFS, 0}, {P_SPORT0_DTPRI, 0}, {P_SPI0_SSEL2, 0},
{P_SPI0_SSEL3, 0}
};
static void portmux_setup(unsigned short per, unsigned short function)
{
u16 y, muxreg, offset;
for (y = 0; y < PMUX_LUT_ENTRIES; y++) {
if (port_mux_lut[y][PMUX_LUT_RES] == per) {
/* SET PORTMUX REG */
offset = port_mux_lut[y][PMUX_LUT_OFFSET];
muxreg = bfin_read_PORT_MUX();
if (offset != 1) {
muxreg &= ~(1 << offset);
} else {
muxreg &= ~(3 << 1);
}
muxreg |= (function << offset);
bfin_write_PORT_MUX(muxreg);
}
}
}
#else
# define portmux_setup(...) do { } while (0)
#endif
static void default_gpio(unsigned short gpio) static void default_gpio(unsigned short gpio)
{ {
...@@ -179,22 +260,15 @@ static void default_gpio(unsigned short gpio) ...@@ -179,22 +260,15 @@ static void default_gpio(unsigned short gpio)
static int __init bfin_gpio_init(void) static int __init bfin_gpio_init(void)
{ {
int i;
printk(KERN_INFO "Blackfin GPIO Controller\n");
for (i = 0; i < MAX_BLACKFIN_GPIOS; i += GPIO_BANKSIZE) str_ident = kzalloc(RESOURCE_LABEL_SIZE * 256, GFP_KERNEL);
reserved_map[gpio_bank(i)] = 0; if (!str_ident)
return -ENOMEM;
#if defined(BF537_FAMILY) && (defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)) printk(KERN_INFO "Blackfin GPIO Controller\n");
# if defined(CONFIG_BFIN_MAC_RMII)
reserved_map[gpio_bank(PORT_H)] = 0xC373;
# else
reserved_map[gpio_bank(PORT_H)] = 0xFFFF;
# endif
#endif
return 0; return 0;
} }
arch_initcall(bfin_gpio_init); arch_initcall(bfin_gpio_init);
...@@ -223,7 +297,7 @@ arch_initcall(bfin_gpio_init); ...@@ -223,7 +297,7 @@ arch_initcall(bfin_gpio_init);
void set_gpio_ ## name(unsigned short gpio, unsigned short arg) \ void set_gpio_ ## name(unsigned short gpio, unsigned short arg) \
{ \ { \
unsigned long flags; \ unsigned long flags; \
BUG_ON(!(reserved_map[gpio_bank(gpio)] & gpio_bit(gpio))); \ BUG_ON(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))); \
local_irq_save(flags); \ local_irq_save(flags); \
if (arg) \ if (arg) \
gpio_bankb[gpio_bank(gpio)]->name |= gpio_bit(gpio); \ gpio_bankb[gpio_bank(gpio)]->name |= gpio_bit(gpio); \
...@@ -243,7 +317,7 @@ SET_GPIO(both) ...@@ -243,7 +317,7 @@ SET_GPIO(both)
#define SET_GPIO_SC(name) \ #define SET_GPIO_SC(name) \
void set_gpio_ ## name(unsigned short gpio, unsigned short arg) \ void set_gpio_ ## name(unsigned short gpio, unsigned short arg) \
{ \ { \
BUG_ON(!(reserved_map[gpio_bank(gpio)] & gpio_bit(gpio))); \ BUG_ON(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))); \
if (arg) \ if (arg) \
gpio_bankb[gpio_bank(gpio)]->name ## _set = gpio_bit(gpio); \ gpio_bankb[gpio_bank(gpio)]->name ## _set = gpio_bit(gpio); \
else \ else \
...@@ -258,7 +332,7 @@ SET_GPIO_SC(maskb) ...@@ -258,7 +332,7 @@ SET_GPIO_SC(maskb)
void set_gpio_data(unsigned short gpio, unsigned short arg) void set_gpio_data(unsigned short gpio, unsigned short arg)
{ {
unsigned long flags; unsigned long flags;
BUG_ON(!(reserved_map[gpio_bank(gpio)] & gpio_bit(gpio))); BUG_ON(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio)));
local_irq_save(flags); local_irq_save(flags);
if (arg) if (arg)
gpio_bankb[gpio_bank(gpio)]->data_set = gpio_bit(gpio); gpio_bankb[gpio_bank(gpio)]->data_set = gpio_bit(gpio);
...@@ -277,7 +351,7 @@ SET_GPIO_SC(data) ...@@ -277,7 +351,7 @@ SET_GPIO_SC(data)
void set_gpio_toggle(unsigned short gpio) void set_gpio_toggle(unsigned short gpio)
{ {
unsigned long flags; unsigned long flags;
BUG_ON(!(reserved_map[gpio_bank(gpio)] & gpio_bit(gpio))); BUG_ON(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio)));
local_irq_save(flags); local_irq_save(flags);
gpio_bankb[gpio_bank(gpio)]->toggle = gpio_bit(gpio); gpio_bankb[gpio_bank(gpio)]->toggle = gpio_bit(gpio);
bfin_read_CHIPID(); bfin_read_CHIPID();
...@@ -286,7 +360,7 @@ void set_gpio_toggle(unsigned short gpio) ...@@ -286,7 +360,7 @@ void set_gpio_toggle(unsigned short gpio)
#else #else
void set_gpio_toggle(unsigned short gpio) void set_gpio_toggle(unsigned short gpio)
{ {
BUG_ON(!(reserved_map[gpio_bank(gpio)] & gpio_bit(gpio))); BUG_ON(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio)));
gpio_bankb[gpio_bank(gpio)]->toggle = gpio_bit(gpio); gpio_bankb[gpio_bank(gpio)]->toggle = gpio_bit(gpio);
} }
#endif #endif
...@@ -350,7 +424,7 @@ unsigned short get_gpio_data(unsigned short gpio) ...@@ -350,7 +424,7 @@ unsigned short get_gpio_data(unsigned short gpio)
{ {
unsigned long flags; unsigned long flags;
unsigned short ret; unsigned short ret;
BUG_ON(!(reserved_map[gpio_bank(gpio)] & gpio_bit(gpio))); BUG_ON(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio)));
local_irq_save(flags); local_irq_save(flags);
ret = 0x01 & (gpio_bankb[gpio_bank(gpio)]->data >> gpio_sub_n(gpio)); ret = 0x01 & (gpio_bankb[gpio_bank(gpio)]->data >> gpio_sub_n(gpio));
bfin_read_CHIPID(); bfin_read_CHIPID();
...@@ -494,13 +568,14 @@ u32 gpio_pm_setup(void) ...@@ -494,13 +568,14 @@ u32 gpio_pm_setup(void)
gpio_bank_saved[bank].dir = gpio_bankb[bank]->dir; gpio_bank_saved[bank].dir = gpio_bankb[bank]->dir;
gpio_bank_saved[bank].edge = gpio_bankb[bank]->edge; gpio_bank_saved[bank].edge = gpio_bankb[bank]->edge;
gpio_bank_saved[bank].both = gpio_bankb[bank]->both; gpio_bank_saved[bank].both = gpio_bankb[bank]->both;
gpio_bank_saved[bank].reserved = reserved_map[bank]; gpio_bank_saved[bank].reserved =
reserved_gpio_map[bank];
gpio = i; gpio = i;
while (mask) { while (mask) {
if (mask & 1) { if (mask & 1) {
reserved_map[gpio_bank(gpio)] |= reserved_gpio_map[gpio_bank(gpio)] |=
gpio_bit(gpio); gpio_bit(gpio);
bfin_gpio_wakeup_type(gpio, bfin_gpio_wakeup_type(gpio,
wakeup_flags_map[gpio]); wakeup_flags_map[gpio]);
...@@ -540,7 +615,8 @@ void gpio_pm_restore(void) ...@@ -540,7 +615,8 @@ void gpio_pm_restore(void)
gpio_bankb[bank]->edge = gpio_bank_saved[bank].edge; gpio_bankb[bank]->edge = gpio_bank_saved[bank].edge;
gpio_bankb[bank]->both = gpio_bank_saved[bank].both; gpio_bankb[bank]->both = gpio_bank_saved[bank].both;
reserved_map[bank] = gpio_bank_saved[bank].reserved; reserved_gpio_map[bank] =
gpio_bank_saved[bank].reserved;
} }
...@@ -550,6 +626,140 @@ void gpio_pm_restore(void) ...@@ -550,6 +626,140 @@ void gpio_pm_restore(void)
#endif #endif
int peripheral_request(unsigned short per, const char *label)
{
unsigned long flags;
unsigned short ident = P_IDENT(per);
/*
* Don't cares are pins with only one dedicated function
*/
if (per & P_DONTCARE)
return 0;
if (!(per & P_DEFINED))
return -ENODEV;
if (check_gpio(ident) < 0)
return -EINVAL;
local_irq_save(flags);
if (unlikely(reserved_gpio_map[gpio_bank(ident)] & gpio_bit(ident))) {
printk(KERN_ERR
"%s: Peripheral %d is already reserved as GPIO by %s !\n",
__FUNCTION__, ident, get_label(ident));
dump_stack();
local_irq_restore(flags);
return -EBUSY;
}
if (unlikely(reserved_peri_map[gpio_bank(ident)] & gpio_bit(ident))) {
/*
* Pin functions like AMC address strobes my
* be requested and used by several drivers
*/
if (!(per & P_MAYSHARE)) {
/*
* Allow that the identical pin function can
* be requested from the same driver twice
*/
if (cmp_label(ident, label) == 0)
goto anyway;
printk(KERN_ERR
"%s: Peripheral %d function %d is already"
"reserved by %s !\n",
__FUNCTION__, ident, P_FUNCT2MUX(per),
get_label(ident));
dump_stack();
local_irq_restore(flags);
return -EBUSY;
}
}
anyway:
portmux_setup(per, P_FUNCT2MUX(per));
port_setup(ident, PERIPHERAL_USAGE);
reserved_peri_map[gpio_bank(ident)] |= gpio_bit(ident);
local_irq_restore(flags);
set_label(ident, label);
return 0;
}
EXPORT_SYMBOL(peripheral_request);
int peripheral_request_list(unsigned short per[], const char *label)
{
u16 cnt;
int ret;
for (cnt = 0; per[cnt] != 0; cnt++) {
ret = peripheral_request(per[cnt], label);
if (ret < 0)
return ret;
}
return 0;
}
EXPORT_SYMBOL(peripheral_request_list);
void peripheral_free(unsigned short per)
{
unsigned long flags;
unsigned short ident = P_IDENT(per);
if (per & P_DONTCARE)
return;
if (!(per & P_DEFINED))
return;
if (check_gpio(ident) < 0)
return;
local_irq_save(flags);
if (unlikely(!(reserved_peri_map[gpio_bank(ident)]
& gpio_bit(ident)))) {
local_irq_restore(flags);
return;
}
if (!(per & P_MAYSHARE)) {
port_setup(ident, GPIO_USAGE);
}
reserved_peri_map[gpio_bank(ident)] &= ~gpio_bit(ident);
local_irq_restore(flags);
}
EXPORT_SYMBOL(peripheral_free);
void peripheral_free_list(unsigned short per[])
{
u16 cnt;
for (cnt = 0; per[cnt] != 0; cnt++) {
peripheral_free(per[cnt]);
}
}
EXPORT_SYMBOL(peripheral_free_list);
/*********************************************************** /***********************************************************
* *
* FUNCTIONS: Blackfin GPIO Driver * FUNCTIONS: Blackfin GPIO Driver
...@@ -574,13 +784,13 @@ int gpio_request(unsigned short gpio, const char *label) ...@@ -574,13 +784,13 @@ int gpio_request(unsigned short gpio, const char *label)
local_irq_save(flags); local_irq_save(flags);
if (unlikely(reserved_map[gpio_bank(gpio)] & gpio_bit(gpio))) { if (unlikely(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))) {
printk(KERN_ERR "bfin-gpio: GPIO %d is already reserved!\n", gpio); printk(KERN_ERR "bfin-gpio: GPIO %d is already reserved!\n", gpio);
dump_stack(); dump_stack();
local_irq_restore(flags); local_irq_restore(flags);
return -EBUSY; return -EBUSY;
} }
reserved_map[gpio_bank(gpio)] |= gpio_bit(gpio); reserved_gpio_map[gpio_bank(gpio)] |= gpio_bit(gpio);
local_irq_restore(flags); local_irq_restore(flags);
...@@ -599,7 +809,7 @@ void gpio_free(unsigned short gpio) ...@@ -599,7 +809,7 @@ void gpio_free(unsigned short gpio)
local_irq_save(flags); local_irq_save(flags);
if (unlikely(!(reserved_map[gpio_bank(gpio)] & gpio_bit(gpio)))) { if (unlikely(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio)))) {
printk(KERN_ERR "bfin-gpio: GPIO %d wasn't reserved!\n", gpio); printk(KERN_ERR "bfin-gpio: GPIO %d wasn't reserved!\n", gpio);
dump_stack(); dump_stack();
local_irq_restore(flags); local_irq_restore(flags);
...@@ -608,7 +818,7 @@ void gpio_free(unsigned short gpio) ...@@ -608,7 +818,7 @@ void gpio_free(unsigned short gpio)
default_gpio(gpio); default_gpio(gpio);
reserved_map[gpio_bank(gpio)] &= ~gpio_bit(gpio); reserved_gpio_map[gpio_bank(gpio)] &= ~gpio_bit(gpio);
local_irq_restore(flags); local_irq_restore(flags);
} }
...@@ -618,7 +828,7 @@ void gpio_direction_input(unsigned short gpio) ...@@ -618,7 +828,7 @@ void gpio_direction_input(unsigned short gpio)
{ {
unsigned long flags; unsigned long flags;
BUG_ON(!(reserved_map[gpio_bank(gpio)] & gpio_bit(gpio))); BUG_ON(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio)));
local_irq_save(flags); local_irq_save(flags);
gpio_bankb[gpio_bank(gpio)]->dir &= ~gpio_bit(gpio); gpio_bankb[gpio_bank(gpio)]->dir &= ~gpio_bit(gpio);
...@@ -631,7 +841,7 @@ void gpio_direction_output(unsigned short gpio) ...@@ -631,7 +841,7 @@ void gpio_direction_output(unsigned short gpio)
{ {
unsigned long flags; unsigned long flags;
BUG_ON(!(reserved_map[gpio_bank(gpio)] & gpio_bit(gpio))); BUG_ON(!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio)));
local_irq_save(flags); local_irq_save(flags);
gpio_bankb[gpio_bank(gpio)]->inen &= ~gpio_bit(gpio); gpio_bankb[gpio_bank(gpio)]->inen &= ~gpio_bit(gpio);
......
#include <linux/serial.h> #include <linux/serial.h>
#include <asm/dma.h> #include <asm/dma.h>
#include <asm/portmux.h>
#define NR_PORTS 1 #define NR_PORTS 1
...@@ -92,18 +93,24 @@ struct bfin_serial_res bfin_serial_resource[] = { ...@@ -92,18 +93,24 @@ struct bfin_serial_res bfin_serial_resource[] = {
} }
}; };
#define DRIVER_NAME "bfin-uart"
int nr_ports = NR_PORTS; int nr_ports = NR_PORTS;
static void bfin_serial_hw_init(struct bfin_serial_port *uart) static void bfin_serial_hw_init(struct bfin_serial_port *uart)
{ {
#ifdef CONFIG_SERIAL_BFIN_UART0
peripheral_request(P_UART0_TX, DRIVER_NAME);
peripheral_request(P_UART0_RX, DRIVER_NAME);
#endif
#ifdef CONFIG_SERIAL_BFIN_CTSRTS #ifdef CONFIG_SERIAL_BFIN_CTSRTS
if (uart->cts_pin >= 0) { if (uart->cts_pin >= 0) {
gpio_request(uart->cts_pin, NULL); gpio_request(uart->cts_pin, DRIVER_NAME);
gpio_direction_input(uart->cts_pin); gpio_direction_input(uart->cts_pin);
} }
if (uart->rts_pin >= 0) { if (uart->rts_pin >= 0) {
gpio_request(uart->rts_pin, NULL); gpio_request(uart->rts_pin, DRIVER_NAME);
gpio_direction_input(uart->rts_pin); gpio_direction_input(uart->rts_pin);
} }
#endif #endif
......
#include <linux/serial.h> #include <linux/serial.h>
#include <asm/dma.h> #include <asm/dma.h>
#include <asm/portmux.h>
#define NR_PORTS 2 #define NR_PORTS 2
...@@ -122,25 +123,29 @@ struct bfin_serial_res bfin_serial_resource[] = { ...@@ -122,25 +123,29 @@ struct bfin_serial_res bfin_serial_resource[] = {
int nr_ports = ARRAY_SIZE(bfin_serial_resource); int nr_ports = ARRAY_SIZE(bfin_serial_resource);
#define DRIVER_NAME "bfin-uart"
static void bfin_serial_hw_init(struct bfin_serial_port *uart) static void bfin_serial_hw_init(struct bfin_serial_port *uart)
{ {
unsigned short val;
val = bfin_read16(BFIN_PORT_MUX);
val &= ~(PFDE | PFTE);
bfin_write16(BFIN_PORT_MUX, val);
val = bfin_read16(PORTF_FER); #ifdef CONFIG_SERIAL_BFIN_UART0
val |= 0xF; peripheral_request(P_UART0_TX, DRIVER_NAME);
bfin_write16(PORTF_FER, val); peripheral_request(P_UART0_RX, DRIVER_NAME);
#endif
#ifdef CONFIG_SERIAL_BFIN_UART1
peripheral_request(P_UART1_TX, DRIVER_NAME);
peripheral_request(P_UART1_RX, DRIVER_NAME);
#endif
#ifdef CONFIG_SERIAL_BFIN_CTSRTS #ifdef CONFIG_SERIAL_BFIN_CTSRTS
if (uart->cts_pin >= 0) { if (uart->cts_pin >= 0) {
gpio_request(uart->cts_pin, NULL); gpio_request(uart->cts_pin, DRIVER_NAME);
gpio_direction_input(uart->cts_pin); gpio_direction_input(uart->cts_pin);
} }
if (uart->rts_pin >= 0) { if (uart->rts_pin >= 0) {
gpio_request(uart->rts_pin, NULL); gpio_request(uart->rts_pin, DRIVER_NAME);
gpio_direction_output(uart->rts_pin); gpio_direction_output(uart->rts_pin);
} }
#endif #endif
......
#include <linux/serial.h> #include <linux/serial.h>
#include <asm/dma.h> #include <asm/dma.h>
#include <asm/portmux.h>
#define NR_PORTS 1 #define NR_PORTS 1
...@@ -92,18 +93,24 @@ struct bfin_serial_res bfin_serial_resource[] = { ...@@ -92,18 +93,24 @@ struct bfin_serial_res bfin_serial_resource[] = {
} }
}; };
#define DRIVER_NAME "bfin-uart"
int nr_ports = NR_PORTS; int nr_ports = NR_PORTS;
static void bfin_serial_hw_init(struct bfin_serial_port *uart) static void bfin_serial_hw_init(struct bfin_serial_port *uart)
{ {
#ifdef CONFIG_SERIAL_BFIN_UART0
peripheral_request(P_UART0_TX, DRIVER_NAME);
peripheral_request(P_UART0_RX, DRIVER_NAME);
#endif
#ifdef CONFIG_SERIAL_BFIN_CTSRTS #ifdef CONFIG_SERIAL_BFIN_CTSRTS
if (uart->cts_pin >= 0) { if (uart->cts_pin >= 0) {
gpio_request(uart->cts_pin, NULL); gpio_request(uart->cts_pin, DRIVER_NAME);
gpio_direction_input(uart->cts_pin); gpio_direction_input(uart->cts_pin);
} }
if (uart->rts_pin >= 0) { if (uart->rts_pin >= 0) {
gpio_request(uart->rts_pin, NULL); gpio_request(uart->rts_pin, DRIVER_NAME);
gpio_direction_input(uart->rts_pin); gpio_direction_input(uart->rts_pin);
} }
#endif #endif
......
...@@ -14,6 +14,12 @@ ...@@ -14,6 +14,12 @@
#define P_MAYSHARE 0x2000 #define P_MAYSHARE 0x2000
#define P_DONTCARE 0x1000 #define P_DONTCARE 0x1000
int peripheral_request(unsigned short per, const char *label);
void peripheral_free(unsigned short per);
int peripheral_request_list(unsigned short per[], const char *label);
void peripheral_free_list(unsigned short per[]);
#include <asm/gpio.h> #include <asm/gpio.h>
#include <asm/mach/portmux.h> #include <asm/mach/portmux.h>
...@@ -145,6 +151,22 @@ ...@@ -145,6 +151,22 @@
#define P_SPI2_SSEL3 P_UNDEF #define P_SPI2_SSEL3 P_UNDEF
#endif #endif
#ifndef P_SPI2_SSEL4
#define P_SPI2_SSEL4 P_UNDEF
#endif
#ifndef P_SPI2_SSEL5
#define P_SPI2_SSEL5 P_UNDEF
#endif
#ifndef P_SPI2_SSEL6
#define P_SPI2_SSEL6 P_UNDEF
#endif
#ifndef P_SPI2_SSEL7
#define P_SPI2_SSEL7 P_UNDEF
#endif
#ifndef P_SPI2_SCK #ifndef P_SPI2_SCK
#define P_SPI2_SCK P_UNDEF #define P_SPI2_SCK P_UNDEF
#endif #endif
...@@ -513,6 +535,22 @@ ...@@ -513,6 +535,22 @@
#define P_SPI0_SSEL3 P_UNDEF #define P_SPI0_SSEL3 P_UNDEF
#endif #endif
#ifndef P_SPI0_SSEL4
#define P_SPI0_SSEL4 P_UNDEF
#endif
#ifndef P_SPI0_SSEL5
#define P_SPI0_SSEL5 P_UNDEF
#endif
#ifndef P_SPI0_SSEL6
#define P_SPI0_SSEL6 P_UNDEF
#endif
#ifndef P_SPI0_SSEL7
#define P_SPI0_SSEL7 P_UNDEF
#endif
#ifndef P_UART0_TX #ifndef P_UART0_TX
#define P_UART0_TX P_UNDEF #define P_UART0_TX P_UNDEF
#endif #endif
...@@ -741,6 +779,23 @@ ...@@ -741,6 +779,23 @@
#define P_SPI1_SSEL3 P_UNDEF #define P_SPI1_SSEL3 P_UNDEF
#endif #endif
#ifndef P_SPI1_SSEL4
#define P_SPI1_SSEL4 P_UNDEF
#endif
#ifndef P_SPI1_SSEL5
#define P_SPI1_SSEL5 P_UNDEF
#endif
#ifndef P_SPI1_SSEL6
#define P_SPI1_SSEL6 P_UNDEF
#endif
#ifndef P_SPI1_SSEL7
#define P_SPI1_SSEL7 P_UNDEF
#endif
#ifndef P_SPI1_SCK #ifndef P_SPI1_SCK
#define P_SPI1_SCK P_UNDEF #define P_SPI1_SCK P_UNDEF
#endif #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