aboutsummaryrefslogtreecommitdiffstats
path: root/arch/blackfin
diff options
context:
space:
mode:
Diffstat (limited to 'arch/blackfin')
-rw-r--r--arch/blackfin/kernel/bfin_gpio.c102
-rw-r--r--arch/blackfin/mach-bf548/gpio.c25
2 files changed, 81 insertions, 46 deletions
diff --git a/arch/blackfin/kernel/bfin_gpio.c b/arch/blackfin/kernel/bfin_gpio.c
index 979cf79d3799..0182ce1fc4fb 100644
--- a/arch/blackfin/kernel/bfin_gpio.c
+++ b/arch/blackfin/kernel/bfin_gpio.c
@@ -118,9 +118,14 @@ static struct gpio_port_t *gpio_bankb[gpio_bank(MAX_BLACKFIN_GPIOS)] = {
118 118
119static unsigned short reserved_gpio_map[gpio_bank(MAX_BLACKFIN_GPIOS)]; 119static unsigned short reserved_gpio_map[gpio_bank(MAX_BLACKFIN_GPIOS)];
120static unsigned short reserved_peri_map[gpio_bank(MAX_BLACKFIN_GPIOS + 16)]; 120static unsigned short reserved_peri_map[gpio_bank(MAX_BLACKFIN_GPIOS + 16)];
121char *str_ident = NULL;
122 121
123#define RESOURCE_LABEL_SIZE 16 122#define MAX_RESOURCES 256
123#define RESOURCE_LABEL_SIZE 16
124
125struct str_ident {
126 char name[RESOURCE_LABEL_SIZE];
127} *str_ident;
128
124 129
125#ifdef CONFIG_PM 130#ifdef CONFIG_PM
126static unsigned short wakeup_map[gpio_bank(MAX_BLACKFIN_GPIOS)]; 131static unsigned short wakeup_map[gpio_bank(MAX_BLACKFIN_GPIOS)];
@@ -152,10 +157,9 @@ static void set_label(unsigned short ident, const char *label)
152{ 157{
153 158
154 if (label && str_ident) { 159 if (label && str_ident) {
155 strncpy(str_ident + ident * RESOURCE_LABEL_SIZE, label, 160 strncpy(str_ident[ident].name, label,
156 RESOURCE_LABEL_SIZE); 161 RESOURCE_LABEL_SIZE);
157 str_ident[ident * RESOURCE_LABEL_SIZE + 162 str_ident[ident].name[RESOURCE_LABEL_SIZE - 1] = 0;
158 RESOURCE_LABEL_SIZE - 1] = 0;
159 } 163 }
160} 164}
161 165
@@ -164,14 +168,13 @@ static char *get_label(unsigned short ident)
164 if (!str_ident) 168 if (!str_ident)
165 return "UNKNOWN"; 169 return "UNKNOWN";
166 170
167 return (str_ident[ident * RESOURCE_LABEL_SIZE] ? 171 return (*str_ident[ident].name ? str_ident[ident].name : "UNKNOWN");
168 (str_ident + ident * RESOURCE_LABEL_SIZE) : "UNKNOWN");
169} 172}
170 173
171static int cmp_label(unsigned short ident, const char *label) 174static int cmp_label(unsigned short ident, const char *label)
172{ 175{
173 if (label && str_ident) 176 if (label && str_ident)
174 return strncmp(str_ident + ident * RESOURCE_LABEL_SIZE, 177 return strncmp(str_ident[ident].name,
175 label, strlen(label)); 178 label, strlen(label));
176 else 179 else
177 return -EINVAL; 180 return -EINVAL;
@@ -194,37 +197,63 @@ static void port_setup(unsigned short gpio, unsigned short usage)
194 197
195#ifdef BF537_FAMILY 198#ifdef BF537_FAMILY
196 199
197#define PMUX_LUT_RES 0 200static struct {
198#define PMUX_LUT_OFFSET 1 201 unsigned short res;
199#define PMUX_LUT_ENTRIES 41 202 unsigned short offset;
200#define PMUX_LUT_SIZE 2 203} port_mux_lut[] = {
201 204 {.res = P_PPI0_D13, .offset = 11},
202static unsigned short port_mux_lut[PMUX_LUT_ENTRIES][PMUX_LUT_SIZE] = { 205 {.res = P_PPI0_D14, .offset = 11},
203 {P_PPI0_D13, 11}, {P_PPI0_D14, 11}, {P_PPI0_D15, 11}, 206 {.res = P_PPI0_D15, .offset = 11},
204 {P_SPORT1_TFS, 11}, {P_SPORT1_TSCLK, 11}, {P_SPORT1_DTPRI, 11}, 207 {.res = P_SPORT1_TFS, .offset = 11},
205 {P_PPI0_D10, 10}, {P_PPI0_D11, 10}, {P_PPI0_D12, 10}, 208 {.res = P_SPORT1_TSCLK, .offset = 11},
206 {P_SPORT1_RSCLK, 10}, {P_SPORT1_RFS, 10}, {P_SPORT1_DRPRI, 10}, 209 {.res = P_SPORT1_DTPRI, .offset = 11},
207 {P_PPI0_D8, 9}, {P_PPI0_D9, 9}, {P_SPORT1_DRSEC, 9}, 210 {.res = P_PPI0_D10, .offset = 10},
208 {P_SPORT1_DTSEC, 9}, {P_TMR2, 8}, {P_PPI0_FS3, 8}, {P_TMR3, 7}, 211 {.res = P_PPI0_D11, .offset = 10},
209 {P_SPI0_SSEL4, 7}, {P_TMR4, 6}, {P_SPI0_SSEL5, 6}, {P_TMR5, 5}, 212 {.res = P_PPI0_D12, .offset = 10},
210 {P_SPI0_SSEL6, 5}, {P_UART1_RX, 4}, {P_UART1_TX, 4}, {P_TMR6, 4}, 213 {.res = P_SPORT1_RSCLK, .offset = 10},
211 {P_TMR7, 4}, {P_UART0_RX, 3}, {P_UART0_TX, 3}, {P_DMAR0, 3}, 214 {.res = P_SPORT1_RFS, .offset = 10},
212 {P_DMAR1, 3}, {P_SPORT0_DTSEC, 1}, {P_SPORT0_DRSEC, 1}, 215 {.res = P_SPORT1_DRPRI, .offset = 10},
213 {P_CAN0_RX, 1}, {P_CAN0_TX, 1}, {P_SPI0_SSEL7, 1}, 216 {.res = P_PPI0_D8, .offset = 9},
214 {P_SPORT0_TFS, 0}, {P_SPORT0_DTPRI, 0}, {P_SPI0_SSEL2, 0}, 217 {.res = P_PPI0_D9, .offset = 9},
215 {P_SPI0_SSEL3, 0} 218 {.res = P_SPORT1_DRSEC, .offset = 9},
219 {.res = P_SPORT1_DTSEC, .offset = 9},
220 {.res = P_TMR2, .offset = 8},
221 {.res = P_PPI0_FS3, .offset = 8},
222 {.res = P_TMR3, .offset = 7},
223 {.res = P_SPI0_SSEL4, .offset = 7},
224 {.res = P_TMR4, .offset = 6},
225 {.res = P_SPI0_SSEL5, .offset = 6},
226 {.res = P_TMR5, .offset = 5},
227 {.res = P_SPI0_SSEL6, .offset = 5},
228 {.res = P_UART1_RX, .offset = 4},
229 {.res = P_UART1_TX, .offset = 4},
230 {.res = P_TMR6, .offset = 4},
231 {.res = P_TMR7, .offset = 4},
232 {.res = P_UART0_RX, .offset = 3},
233 {.res = P_UART0_TX, .offset = 3},
234 {.res = P_DMAR0, .offset = 3},
235 {.res = P_DMAR1, .offset = 3},
236 {.res = P_SPORT0_DTSEC, .offset = 1},
237 {.res = P_SPORT0_DRSEC, .offset = 1},
238 {.res = P_CAN0_RX, .offset = 1},
239 {.res = P_CAN0_TX, .offset = 1},
240 {.res = P_SPI0_SSEL7, .offset = 1},
241 {.res = P_SPORT0_TFS, .offset = 0},
242 {.res = P_SPORT0_DTPRI, .offset = 0},
243 {.res = P_SPI0_SSEL2, .offset = 0},
244 {.res = P_SPI0_SSEL3, .offset = 0},
216}; 245};
217 246
218static void portmux_setup(unsigned short per, unsigned short function) 247static void portmux_setup(unsigned short per, unsigned short function)
219{ 248{
220 u16 y, muxreg, offset; 249 u16 y, offset, muxreg;
221 250
222 for (y = 0; y < PMUX_LUT_ENTRIES; y++) { 251 for (y = 0; y < ARRAY_SIZE(port_mux_lut); y++) {
223 if (port_mux_lut[y][PMUX_LUT_RES] == per) { 252 if (port_mux_lut[y].res == per) {
224 253
225 /* SET PORTMUX REG */ 254 /* SET PORTMUX REG */
226 255
227 offset = port_mux_lut[y][PMUX_LUT_OFFSET]; 256 offset = port_mux_lut[y].offset;
228 muxreg = bfin_read_PORT_MUX(); 257 muxreg = bfin_read_PORT_MUX();
229 258
230 if (offset != 1) { 259 if (offset != 1) {
@@ -262,17 +291,18 @@ static void default_gpio(unsigned short gpio)
262 291
263static int __init bfin_gpio_init(void) 292static int __init bfin_gpio_init(void)
264{ 293{
265 294 str_ident = kcalloc(MAX_RESOURCES,
266 str_ident = kzalloc(RESOURCE_LABEL_SIZE * 256, GFP_KERNEL); 295 sizeof(struct str_ident), GFP_KERNEL);
267 if (!str_ident) 296 if (str_ident == NULL)
268 return -ENOMEM; 297 return -ENOMEM;
269 298
299 memset(str_ident, 0, MAX_RESOURCES * sizeof(struct str_ident));
300
270 printk(KERN_INFO "Blackfin GPIO Controller\n"); 301 printk(KERN_INFO "Blackfin GPIO Controller\n");
271 302
272 return 0; 303 return 0;
273 304
274} 305}
275
276arch_initcall(bfin_gpio_init); 306arch_initcall(bfin_gpio_init);
277 307
278 308
@@ -680,7 +710,7 @@ int peripheral_request(unsigned short per, const char *label)
680 710
681 printk(KERN_ERR 711 printk(KERN_ERR
682 "%s: Peripheral %d function %d is already" 712 "%s: Peripheral %d function %d is already"
683 "reserved by %s !\n", 713 " reserved by %s !\n",
684 __FUNCTION__, ident, P_FUNCT2MUX(per), 714 __FUNCTION__, ident, P_FUNCT2MUX(per),
685 get_label(ident)); 715 get_label(ident));
686 dump_stack(); 716 dump_stack();
diff --git a/arch/blackfin/mach-bf548/gpio.c b/arch/blackfin/mach-bf548/gpio.c
index f3b9deacd332..390dd8c12430 100644
--- a/arch/blackfin/mach-bf548/gpio.c
+++ b/arch/blackfin/mach-bf548/gpio.c
@@ -49,9 +49,13 @@ static struct gpio_port_t *gpio_array[gpio_bank(MAX_BLACKFIN_GPIOS)] = {
49 49
50static unsigned short reserved_gpio_map[gpio_bank(MAX_BLACKFIN_GPIOS)]; 50static unsigned short reserved_gpio_map[gpio_bank(MAX_BLACKFIN_GPIOS)];
51static unsigned short reserved_peri_map[gpio_bank(MAX_BLACKFIN_GPIOS)]; 51static unsigned short reserved_peri_map[gpio_bank(MAX_BLACKFIN_GPIOS)];
52char *str_ident = NULL;
53 52
54#define RESOURCE_LABEL_SIZE 16 53#define MAX_RESOURCES 256
54#define RESOURCE_LABEL_SIZE 16
55
56struct str_ident {
57 char name[RESOURCE_LABEL_SIZE];
58} *str_ident;
55 59
56inline int check_gpio(unsigned short gpio) 60inline int check_gpio(unsigned short gpio)
57{ 61{
@@ -96,10 +100,13 @@ static void port_setup(unsigned short gpio, unsigned short usage)
96static int __init bfin_gpio_init(void) 100static int __init bfin_gpio_init(void)
97{ 101{
98 102
99 str_ident = kzalloc(RESOURCE_LABEL_SIZE * 256, GFP_KERNEL); 103 str_ident = kcalloc(MAX_RESOURCES,
100 if (!str_ident) 104 sizeof(struct str_ident), GFP_KERNEL);
105 if (str_ident == NULL)
101 return -ENOMEM; 106 return -ENOMEM;
102 107
108 memset(str_ident, 0, MAX_RESOURCES * sizeof(struct str_ident));
109
103 printk(KERN_INFO "Blackfin GPIO Controller\n"); 110 printk(KERN_INFO "Blackfin GPIO Controller\n");
104 111
105 return 0; 112 return 0;
@@ -111,10 +118,9 @@ static void set_label(unsigned short ident, const char *label)
111{ 118{
112 119
113 if (label && str_ident) { 120 if (label && str_ident) {
114 strncpy(str_ident + ident * RESOURCE_LABEL_SIZE, label, 121 strncpy(str_ident[ident].name, label,
115 RESOURCE_LABEL_SIZE); 122 RESOURCE_LABEL_SIZE);
116 str_ident[ident * RESOURCE_LABEL_SIZE + 123 str_ident[ident].name[RESOURCE_LABEL_SIZE - 1] = 0;
117 RESOURCE_LABEL_SIZE - 1] = 0;
118 } 124 }
119} 125}
120 126
@@ -123,14 +129,13 @@ static char *get_label(unsigned short ident)
123 if (!str_ident) 129 if (!str_ident)
124 return "UNKNOWN"; 130 return "UNKNOWN";
125 131
126 return (str_ident[ident * RESOURCE_LABEL_SIZE] ? 132 return (*str_ident[ident].name ? str_ident[ident].name : "UNKNOWN");
127 (str_ident + ident * RESOURCE_LABEL_SIZE) : "UNKNOWN");
128} 133}
129 134
130static int cmp_label(unsigned short ident, const char *label) 135static int cmp_label(unsigned short ident, const char *label)
131{ 136{
132 if (label && str_ident) 137 if (label && str_ident)
133 return strncmp(str_ident + ident * RESOURCE_LABEL_SIZE, 138 return strncmp(str_ident[ident].name,
134 label, strlen(label)); 139 label, strlen(label));
135 else 140 else
136 return -EINVAL; 141 return -EINVAL;