aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/blackfin/include/asm/gpio.h58
-rw-r--r--arch/blackfin/kernel/bfin_gpio.c547
-rw-r--r--arch/blackfin/mach-bf548/include/mach/gpio.h12
3 files changed, 208 insertions, 409 deletions
diff --git a/arch/blackfin/include/asm/gpio.h b/arch/blackfin/include/asm/gpio.h
index 9477d82fcad2..d4a082ef75b4 100644
--- a/arch/blackfin/include/asm/gpio.h
+++ b/arch/blackfin/include/asm/gpio.h
@@ -27,60 +27,6 @@
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */ 28 */
29 29
30/*
31* Number BF537/6/4 BF561 BF533/2/1
32* BF527/5/2
33*
34* GPIO_0 PF0 PF0 PF0
35* GPIO_1 PF1 PF1 PF1
36* GPIO_2 PF2 PF2 PF2
37* GPIO_3 PF3 PF3 PF3
38* GPIO_4 PF4 PF4 PF4
39* GPIO_5 PF5 PF5 PF5
40* GPIO_6 PF6 PF6 PF6
41* GPIO_7 PF7 PF7 PF7
42* GPIO_8 PF8 PF8 PF8
43* GPIO_9 PF9 PF9 PF9
44* GPIO_10 PF10 PF10 PF10
45* GPIO_11 PF11 PF11 PF11
46* GPIO_12 PF12 PF12 PF12
47* GPIO_13 PF13 PF13 PF13
48* GPIO_14 PF14 PF14 PF14
49* GPIO_15 PF15 PF15 PF15
50* GPIO_16 PG0 PF16
51* GPIO_17 PG1 PF17
52* GPIO_18 PG2 PF18
53* GPIO_19 PG3 PF19
54* GPIO_20 PG4 PF20
55* GPIO_21 PG5 PF21
56* GPIO_22 PG6 PF22
57* GPIO_23 PG7 PF23
58* GPIO_24 PG8 PF24
59* GPIO_25 PG9 PF25
60* GPIO_26 PG10 PF26
61* GPIO_27 PG11 PF27
62* GPIO_28 PG12 PF28
63* GPIO_29 PG13 PF29
64* GPIO_30 PG14 PF30
65* GPIO_31 PG15 PF31
66* GPIO_32 PH0 PF32
67* GPIO_33 PH1 PF33
68* GPIO_34 PH2 PF34
69* GPIO_35 PH3 PF35
70* GPIO_36 PH4 PF36
71* GPIO_37 PH5 PF37
72* GPIO_38 PH6 PF38
73* GPIO_39 PH7 PF39
74* GPIO_40 PH8 PF40
75* GPIO_41 PH9 PF41
76* GPIO_42 PH10 PF42
77* GPIO_43 PH11 PF43
78* GPIO_44 PH12 PF44
79* GPIO_45 PH13 PF45
80* GPIO_46 PH14 PF46
81* GPIO_47 PH15 PF47
82*/
83
84#ifndef __ARCH_BLACKFIN_GPIO_H__ 30#ifndef __ARCH_BLACKFIN_GPIO_H__
85#define __ARCH_BLACKFIN_GPIO_H__ 31#define __ARCH_BLACKFIN_GPIO_H__
86 32
@@ -295,10 +241,6 @@ int bfin_gpio_direction_output(unsigned gpio, int value);
295int bfin_gpio_get_value(unsigned gpio); 241int bfin_gpio_get_value(unsigned gpio);
296void bfin_gpio_set_value(unsigned gpio, int value); 242void bfin_gpio_set_value(unsigned gpio, int value);
297 243
298#ifndef BF548_FAMILY
299#define bfin_gpio_set_value(gpio, value) set_gpio_data(gpio, value)
300#endif
301
302#ifdef CONFIG_GPIOLIB 244#ifdef CONFIG_GPIOLIB
303#include <asm-generic/gpio.h> /* cansleep wrappers */ 245#include <asm-generic/gpio.h> /* cansleep wrappers */
304 246
diff --git a/arch/blackfin/kernel/bfin_gpio.c b/arch/blackfin/kernel/bfin_gpio.c
index 05bf85ba7443..7f69f43be987 100644
--- a/arch/blackfin/kernel/bfin_gpio.c
+++ b/arch/blackfin/kernel/bfin_gpio.c
@@ -27,59 +27,6 @@
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */ 28 */
29 29
30/*
31* Number BF537/6/4 BF561 BF533/2/1 BF549/8/4/2
32*
33* GPIO_0 PF0 PF0 PF0 PA0...PJ13
34* GPIO_1 PF1 PF1 PF1
35* GPIO_2 PF2 PF2 PF2
36* GPIO_3 PF3 PF3 PF3
37* GPIO_4 PF4 PF4 PF4
38* GPIO_5 PF5 PF5 PF5
39* GPIO_6 PF6 PF6 PF6
40* GPIO_7 PF7 PF7 PF7
41* GPIO_8 PF8 PF8 PF8
42* GPIO_9 PF9 PF9 PF9
43* GPIO_10 PF10 PF10 PF10
44* GPIO_11 PF11 PF11 PF11
45* GPIO_12 PF12 PF12 PF12
46* GPIO_13 PF13 PF13 PF13
47* GPIO_14 PF14 PF14 PF14
48* GPIO_15 PF15 PF15 PF15
49* GPIO_16 PG0 PF16
50* GPIO_17 PG1 PF17
51* GPIO_18 PG2 PF18
52* GPIO_19 PG3 PF19
53* GPIO_20 PG4 PF20
54* GPIO_21 PG5 PF21
55* GPIO_22 PG6 PF22
56* GPIO_23 PG7 PF23
57* GPIO_24 PG8 PF24
58* GPIO_25 PG9 PF25
59* GPIO_26 PG10 PF26
60* GPIO_27 PG11 PF27
61* GPIO_28 PG12 PF28
62* GPIO_29 PG13 PF29
63* GPIO_30 PG14 PF30
64* GPIO_31 PG15 PF31
65* GPIO_32 PH0 PF32
66* GPIO_33 PH1 PF33
67* GPIO_34 PH2 PF34
68* GPIO_35 PH3 PF35
69* GPIO_36 PH4 PF36
70* GPIO_37 PH5 PF37
71* GPIO_38 PH6 PF38
72* GPIO_39 PH7 PF39
73* GPIO_40 PH8 PF40
74* GPIO_41 PH9 PF41
75* GPIO_42 PH10 PF42
76* GPIO_43 PH11 PF43
77* GPIO_44 PH12 PF44
78* GPIO_45 PH13 PF45
79* GPIO_46 PH14 PF46
80* GPIO_47 PH15 PF47
81*/
82
83#include <linux/delay.h> 30#include <linux/delay.h>
84#include <linux/module.h> 31#include <linux/module.h>
85#include <linux/err.h> 32#include <linux/err.h>
@@ -119,28 +66,42 @@ enum {
119#define AWA_DUMMY_READ(...) do { } while (0) 66#define AWA_DUMMY_READ(...) do { } while (0)
120#endif 67#endif
121 68
69static struct gpio_port_t * const gpio_array[] = {
122#if defined(BF533_FAMILY) || defined(BF538_FAMILY) 70#if defined(BF533_FAMILY) || defined(BF538_FAMILY)
123static struct gpio_port_t *gpio_bankb[] = {
124 (struct gpio_port_t *) FIO_FLAG_D, 71 (struct gpio_port_t *) FIO_FLAG_D,
125}; 72#elif defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY)
126#endif
127
128#if defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY)
129static struct gpio_port_t *gpio_bankb[] = {
130 (struct gpio_port_t *) PORTFIO, 73 (struct gpio_port_t *) PORTFIO,
131 (struct gpio_port_t *) PORTGIO, 74 (struct gpio_port_t *) PORTGIO,
132 (struct gpio_port_t *) PORTHIO, 75 (struct gpio_port_t *) PORTHIO,
76#elif defined(BF561_FAMILY)
77 (struct gpio_port_t *) FIO0_FLAG_D,
78 (struct gpio_port_t *) FIO1_FLAG_D,
79 (struct gpio_port_t *) FIO2_FLAG_D,
80#elif defined(BF548_FAMILY)
81 (struct gpio_port_t *)PORTA_FER,
82 (struct gpio_port_t *)PORTB_FER,
83 (struct gpio_port_t *)PORTC_FER,
84 (struct gpio_port_t *)PORTD_FER,
85 (struct gpio_port_t *)PORTE_FER,
86 (struct gpio_port_t *)PORTF_FER,
87 (struct gpio_port_t *)PORTG_FER,
88 (struct gpio_port_t *)PORTH_FER,
89 (struct gpio_port_t *)PORTI_FER,
90 (struct gpio_port_t *)PORTJ_FER,
91#else
92# error no gpio arrays defined
93#endif
133}; 94};
134 95
135static unsigned short *port_fer[] = { 96#if defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY)
97static unsigned short * const port_fer[] = {
136 (unsigned short *) PORTF_FER, 98 (unsigned short *) PORTF_FER,
137 (unsigned short *) PORTG_FER, 99 (unsigned short *) PORTG_FER,
138 (unsigned short *) PORTH_FER, 100 (unsigned short *) PORTH_FER,
139}; 101};
140#endif
141 102
142#if defined(BF527_FAMILY) || defined(BF518_FAMILY) 103# if !defined(BF537_FAMILY)
143static unsigned short *port_mux[] = { 104static unsigned short * const port_mux[] = {
144 (unsigned short *) PORTF_MUX, 105 (unsigned short *) PORTF_MUX,
145 (unsigned short *) PORTG_MUX, 106 (unsigned short *) PORTG_MUX,
146 (unsigned short *) PORTH_MUX, 107 (unsigned short *) PORTH_MUX,
@@ -152,29 +113,7 @@ u8 pmux_offset[][16] =
152 { 0, 0, 0, 0, 0, 2, 2, 4, 4, 6, 8, 10, 10, 10, 12, 12 }, /* PORTG */ 113 { 0, 0, 0, 0, 0, 2, 2, 4, 4, 6, 8, 10, 10, 10, 12, 12 }, /* PORTG */
153 { 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 4, 4, 4, 4, 4, 4 }, /* PORTH */ 114 { 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 4, 4, 4, 4, 4, 4 }, /* PORTH */
154 }; 115 };
155#endif 116# endif
156
157#ifdef BF561_FAMILY
158static struct gpio_port_t *gpio_bankb[] = {
159 (struct gpio_port_t *) FIO0_FLAG_D,
160 (struct gpio_port_t *) FIO1_FLAG_D,
161 (struct gpio_port_t *) FIO2_FLAG_D,
162};
163#endif
164
165#ifdef BF548_FAMILY
166static struct gpio_port_t *gpio_array[] = {
167 (struct gpio_port_t *)PORTA_FER,
168 (struct gpio_port_t *)PORTB_FER,
169 (struct gpio_port_t *)PORTC_FER,
170 (struct gpio_port_t *)PORTD_FER,
171 (struct gpio_port_t *)PORTE_FER,
172 (struct gpio_port_t *)PORTF_FER,
173 (struct gpio_port_t *)PORTG_FER,
174 (struct gpio_port_t *)PORTH_FER,
175 (struct gpio_port_t *)PORTI_FER,
176 (struct gpio_port_t *)PORTJ_FER,
177};
178#endif 117#endif
179 118
180static unsigned short reserved_gpio_map[GPIO_BANK_NUM]; 119static unsigned short reserved_gpio_map[GPIO_BANK_NUM];
@@ -188,35 +127,9 @@ static struct str_ident {
188} str_ident[MAX_RESOURCES]; 127} str_ident[MAX_RESOURCES];
189 128
190#if defined(CONFIG_PM) 129#if defined(CONFIG_PM)
191#if defined(CONFIG_BF54x)
192static struct gpio_port_s gpio_bank_saved[GPIO_BANK_NUM]; 130static struct gpio_port_s gpio_bank_saved[GPIO_BANK_NUM];
193#else
194static unsigned short wakeup_map[GPIO_BANK_NUM];
195static unsigned char wakeup_flags_map[MAX_BLACKFIN_GPIOS];
196static struct gpio_port_s gpio_bank_saved[GPIO_BANK_NUM];
197
198#ifdef BF533_FAMILY
199static unsigned int sic_iwr_irqs[] = {IRQ_PROG_INTB};
200#endif
201
202#ifdef BF537_FAMILY
203static unsigned int sic_iwr_irqs[] = {IRQ_PROG_INTB, IRQ_PORTG_INTB, IRQ_MAC_TX};
204#endif
205
206#ifdef BF538_FAMILY
207static unsigned int sic_iwr_irqs[] = {IRQ_PORTF_INTB};
208#endif
209
210#if defined(BF527_FAMILY) || defined(BF518_FAMILY)
211static unsigned int sic_iwr_irqs[] = {IRQ_PORTF_INTB, IRQ_PORTG_INTB, IRQ_PORTH_INTB};
212#endif 131#endif
213 132
214#ifdef BF561_FAMILY
215static unsigned int sic_iwr_irqs[] = {IRQ_PROG0_INTB, IRQ_PROG1_INTB, IRQ_PROG2_INTB};
216#endif
217#endif
218#endif /* CONFIG_PM */
219
220inline int check_gpio(unsigned gpio) 133inline int check_gpio(unsigned gpio)
221{ 134{
222#if defined(BF548_FAMILY) 135#if defined(BF548_FAMILY)
@@ -330,9 +243,10 @@ static struct {
330 {.res = P_SPI0_SSEL3, .offset = 0}, 243 {.res = P_SPI0_SSEL3, .offset = 0},
331}; 244};
332 245
333static void portmux_setup(unsigned short per, unsigned short function) 246static void portmux_setup(unsigned short per)
334{ 247{
335 u16 y, offset, muxreg; 248 u16 y, offset, muxreg;
249 u16 function = P_FUNCT2MUX(per);
336 250
337 for (y = 0; y < ARRAY_SIZE(port_mux_lut); y++) { 251 for (y = 0; y < ARRAY_SIZE(port_mux_lut); y++) {
338 if (port_mux_lut[y].res == per) { 252 if (port_mux_lut[y].res == per) {
@@ -353,30 +267,33 @@ static void portmux_setup(unsigned short per, unsigned short function)
353 } 267 }
354} 268}
355#elif defined(BF548_FAMILY) 269#elif defined(BF548_FAMILY)
356inline void portmux_setup(unsigned short portno, unsigned short function) 270inline void portmux_setup(unsigned short per)
357{ 271{
358 u32 pmux; 272 u32 pmux;
273 u16 ident = P_IDENT(per);
274 u16 function = P_FUNCT2MUX(per);
359 275
360 pmux = gpio_array[gpio_bank(portno)]->port_mux; 276 pmux = gpio_array[gpio_bank(ident)]->port_mux;
361 277
362 pmux &= ~(0x3 << (2 * gpio_sub_n(portno))); 278 pmux &= ~(0x3 << (2 * gpio_sub_n(ident)));
363 pmux |= (function & 0x3) << (2 * gpio_sub_n(portno)); 279 pmux |= (function & 0x3) << (2 * gpio_sub_n(ident));
364 280
365 gpio_array[gpio_bank(portno)]->port_mux = pmux; 281 gpio_array[gpio_bank(ident)]->port_mux = pmux;
366} 282}
367 283
368inline u16 get_portmux(unsigned short portno) 284inline u16 get_portmux(unsigned short per)
369{ 285{
370 u32 pmux; 286 u32 pmux;
287 u16 ident = P_IDENT(per);
371 288
372 pmux = gpio_array[gpio_bank(portno)]->port_mux; 289 pmux = gpio_array[gpio_bank(ident)]->port_mux;
373 290
374 return (pmux >> (2 * gpio_sub_n(portno)) & 0x3); 291 return (pmux >> (2 * gpio_sub_n(ident)) & 0x3);
375} 292}
376#elif defined(BF527_FAMILY) || defined(BF518_FAMILY) 293#elif defined(BF527_FAMILY) || defined(BF518_FAMILY)
377inline void portmux_setup(unsigned short portno, unsigned short function) 294inline void portmux_setup(unsigned short per)
378{ 295{
379 u16 pmux, ident = P_IDENT(portno); 296 u16 pmux, ident = P_IDENT(per), function = P_FUNCT2MUX(per);
380 u8 offset = pmux_offset[gpio_bank(ident)][gpio_sub_n(ident)]; 297 u8 offset = pmux_offset[gpio_bank(ident)][gpio_sub_n(ident)];
381 298
382 pmux = *port_mux[gpio_bank(ident)]; 299 pmux = *port_mux[gpio_bank(ident)];
@@ -424,90 +341,71 @@ void set_gpio_ ## name(unsigned gpio, unsigned short arg) \
424 unsigned long flags; \ 341 unsigned long flags; \
425 local_irq_save_hw(flags); \ 342 local_irq_save_hw(flags); \
426 if (arg) \ 343 if (arg) \
427 gpio_bankb[gpio_bank(gpio)]->name |= gpio_bit(gpio); \ 344 gpio_array[gpio_bank(gpio)]->name |= gpio_bit(gpio); \
428 else \ 345 else \
429 gpio_bankb[gpio_bank(gpio)]->name &= ~gpio_bit(gpio); \ 346 gpio_array[gpio_bank(gpio)]->name &= ~gpio_bit(gpio); \
430 AWA_DUMMY_READ(name); \ 347 AWA_DUMMY_READ(name); \
431 local_irq_restore_hw(flags); \ 348 local_irq_restore_hw(flags); \
432} \ 349} \
433EXPORT_SYMBOL(set_gpio_ ## name); 350EXPORT_SYMBOL(set_gpio_ ## name);
434 351
435SET_GPIO(dir) 352SET_GPIO(dir) /* set_gpio_dir() */
436SET_GPIO(inen) 353SET_GPIO(inen) /* set_gpio_inen() */
437SET_GPIO(polar) 354SET_GPIO(polar) /* set_gpio_polar() */
438SET_GPIO(edge) 355SET_GPIO(edge) /* set_gpio_edge() */
439SET_GPIO(both) 356SET_GPIO(both) /* set_gpio_both() */
440 357
441 358
442#if ANOMALY_05000311 || ANOMALY_05000323
443#define SET_GPIO_SC(name) \ 359#define SET_GPIO_SC(name) \
444void set_gpio_ ## name(unsigned gpio, unsigned short arg) \ 360void set_gpio_ ## name(unsigned gpio, unsigned short arg) \
445{ \ 361{ \
446 unsigned long flags; \ 362 unsigned long flags; \
447 local_irq_save_hw(flags); \ 363 if (ANOMALY_05000311 || ANOMALY_05000323) \
448 if (arg) \ 364 local_irq_save_hw(flags); \
449 gpio_bankb[gpio_bank(gpio)]->name ## _set = gpio_bit(gpio); \
450 else \
451 gpio_bankb[gpio_bank(gpio)]->name ## _clear = gpio_bit(gpio); \
452 AWA_DUMMY_READ(name); \
453 local_irq_restore_hw(flags); \
454} \
455EXPORT_SYMBOL(set_gpio_ ## name);
456#else
457#define SET_GPIO_SC(name) \
458void set_gpio_ ## name(unsigned gpio, unsigned short arg) \
459{ \
460 if (arg) \ 365 if (arg) \
461 gpio_bankb[gpio_bank(gpio)]->name ## _set = gpio_bit(gpio); \ 366 gpio_array[gpio_bank(gpio)]->name ## _set = gpio_bit(gpio); \
462 else \ 367 else \
463 gpio_bankb[gpio_bank(gpio)]->name ## _clear = gpio_bit(gpio); \ 368 gpio_array[gpio_bank(gpio)]->name ## _clear = gpio_bit(gpio); \
369 if (ANOMALY_05000311 || ANOMALY_05000323) { \
370 AWA_DUMMY_READ(name); \
371 local_irq_restore_hw(flags); \
372 } \
464} \ 373} \
465EXPORT_SYMBOL(set_gpio_ ## name); 374EXPORT_SYMBOL(set_gpio_ ## name);
466#endif
467 375
468SET_GPIO_SC(maska) 376SET_GPIO_SC(maska)
469SET_GPIO_SC(maskb) 377SET_GPIO_SC(maskb)
470SET_GPIO_SC(data) 378SET_GPIO_SC(data)
471 379
472#if ANOMALY_05000311 || ANOMALY_05000323
473void set_gpio_toggle(unsigned gpio) 380void set_gpio_toggle(unsigned gpio)
474{ 381{
475 unsigned long flags; 382 unsigned long flags;
476 local_irq_save_hw(flags); 383 if (ANOMALY_05000311 || ANOMALY_05000323)
477 gpio_bankb[gpio_bank(gpio)]->toggle = gpio_bit(gpio); 384 local_irq_save_hw(flags);
478 AWA_DUMMY_READ(toggle); 385 gpio_array[gpio_bank(gpio)]->toggle = gpio_bit(gpio);
479 local_irq_restore_hw(flags); 386 if (ANOMALY_05000311 || ANOMALY_05000323) {
480} 387 AWA_DUMMY_READ(toggle);
481#else 388 local_irq_restore_hw(flags);
482void set_gpio_toggle(unsigned gpio) 389 }
483{
484 gpio_bankb[gpio_bank(gpio)]->toggle = gpio_bit(gpio);
485} 390}
486#endif
487EXPORT_SYMBOL(set_gpio_toggle); 391EXPORT_SYMBOL(set_gpio_toggle);
488 392
489 393
490/*Set current PORT date (16-bit word)*/ 394/*Set current PORT date (16-bit word)*/
491 395
492#if ANOMALY_05000311 || ANOMALY_05000323
493#define SET_GPIO_P(name) \ 396#define SET_GPIO_P(name) \
494void set_gpiop_ ## name(unsigned gpio, unsigned short arg) \ 397void set_gpiop_ ## name(unsigned gpio, unsigned short arg) \
495{ \ 398{ \
496 unsigned long flags; \ 399 unsigned long flags; \
497 local_irq_save_hw(flags); \ 400 if (ANOMALY_05000311 || ANOMALY_05000323) \
498 gpio_bankb[gpio_bank(gpio)]->name = arg; \ 401 local_irq_save_hw(flags); \
499 AWA_DUMMY_READ(name); \ 402 gpio_array[gpio_bank(gpio)]->name = arg; \
500 local_irq_restore_hw(flags); \ 403 if (ANOMALY_05000311 || ANOMALY_05000323) { \
501} \ 404 AWA_DUMMY_READ(name); \
502EXPORT_SYMBOL(set_gpiop_ ## name); 405 local_irq_restore_hw(flags); \
503#else 406 } \
504#define SET_GPIO_P(name) \
505void set_gpiop_ ## name(unsigned gpio, unsigned short arg) \
506{ \
507 gpio_bankb[gpio_bank(gpio)]->name = arg; \
508} \ 407} \
509EXPORT_SYMBOL(set_gpiop_ ## name); 408EXPORT_SYMBOL(set_gpiop_ ## name);
510#endif
511 409
512SET_GPIO_P(data) 410SET_GPIO_P(data)
513SET_GPIO_P(dir) 411SET_GPIO_P(dir)
@@ -519,27 +417,21 @@ SET_GPIO_P(maska)
519SET_GPIO_P(maskb) 417SET_GPIO_P(maskb)
520 418
521/* Get a specific bit */ 419/* Get a specific bit */
522#if ANOMALY_05000311 || ANOMALY_05000323
523#define GET_GPIO(name) \ 420#define GET_GPIO(name) \
524unsigned short get_gpio_ ## name(unsigned gpio) \ 421unsigned short get_gpio_ ## name(unsigned gpio) \
525{ \ 422{ \
526 unsigned long flags; \ 423 unsigned long flags; \
527 unsigned short ret; \ 424 unsigned short ret; \
528 local_irq_save_hw(flags); \ 425 if (ANOMALY_05000311 || ANOMALY_05000323) \
529 ret = 0x01 & (gpio_bankb[gpio_bank(gpio)]->name >> gpio_sub_n(gpio)); \ 426 local_irq_save_hw(flags); \
530 AWA_DUMMY_READ(name); \ 427 ret = 0x01 & (gpio_array[gpio_bank(gpio)]->name >> gpio_sub_n(gpio)); \
531 local_irq_restore_hw(flags); \ 428 if (ANOMALY_05000311 || ANOMALY_05000323) { \
429 AWA_DUMMY_READ(name); \
430 local_irq_restore_hw(flags); \
431 } \
532 return ret; \ 432 return ret; \
533} \ 433} \
534EXPORT_SYMBOL(get_gpio_ ## name); 434EXPORT_SYMBOL(get_gpio_ ## name);
535#else
536#define GET_GPIO(name) \
537unsigned short get_gpio_ ## name(unsigned gpio) \
538{ \
539 return (0x01 & (gpio_bankb[gpio_bank(gpio)]->name >> gpio_sub_n(gpio))); \
540} \
541EXPORT_SYMBOL(get_gpio_ ## name);
542#endif
543 435
544GET_GPIO(data) 436GET_GPIO(data)
545GET_GPIO(dir) 437GET_GPIO(dir)
@@ -552,27 +444,21 @@ GET_GPIO(maskb)
552 444
553/*Get current PORT date (16-bit word)*/ 445/*Get current PORT date (16-bit word)*/
554 446
555#if ANOMALY_05000311 || ANOMALY_05000323
556#define GET_GPIO_P(name) \ 447#define GET_GPIO_P(name) \
557unsigned short get_gpiop_ ## name(unsigned gpio) \ 448unsigned short get_gpiop_ ## name(unsigned gpio) \
558{ \ 449{ \
559 unsigned long flags; \ 450 unsigned long flags; \
560 unsigned short ret; \ 451 unsigned short ret; \
561 local_irq_save_hw(flags); \ 452 if (ANOMALY_05000311 || ANOMALY_05000323) \
562 ret = (gpio_bankb[gpio_bank(gpio)]->name); \ 453 local_irq_save_hw(flags); \
563 AWA_DUMMY_READ(name); \ 454 ret = (gpio_array[gpio_bank(gpio)]->name); \
564 local_irq_restore_hw(flags); \ 455 if (ANOMALY_05000311 || ANOMALY_05000323) { \
456 AWA_DUMMY_READ(name); \
457 local_irq_restore_hw(flags); \
458 } \
565 return ret; \ 459 return ret; \
566} \ 460} \
567EXPORT_SYMBOL(get_gpiop_ ## name); 461EXPORT_SYMBOL(get_gpiop_ ## name);
568#else
569#define GET_GPIO_P(name) \
570unsigned short get_gpiop_ ## name(unsigned gpio) \
571{ \
572 return (gpio_bankb[gpio_bank(gpio)]->name);\
573} \
574EXPORT_SYMBOL(get_gpiop_ ## name);
575#endif
576 462
577GET_GPIO_P(data) 463GET_GPIO_P(data)
578GET_GPIO_P(dir) 464GET_GPIO_P(dir)
@@ -585,6 +471,26 @@ GET_GPIO_P(maskb)
585 471
586 472
587#ifdef CONFIG_PM 473#ifdef CONFIG_PM
474
475static unsigned short wakeup_map[GPIO_BANK_NUM];
476static unsigned char wakeup_flags_map[MAX_BLACKFIN_GPIOS];
477
478static const unsigned int sic_iwr_irqs[] = {
479#if defined(BF533_FAMILY)
480 IRQ_PROG_INTB
481#elif defined(BF537_FAMILY)
482 IRQ_PROG_INTB, IRQ_PORTG_INTB, IRQ_MAC_TX
483#elif defined(BF538_FAMILY)
484 IRQ_PORTF_INTB
485#elif defined(BF527_FAMILY) || defined(BF518_FAMILY)
486 IRQ_PORTF_INTB, IRQ_PORTG_INTB, IRQ_PORTH_INTB
487#elif defined(BF561_FAMILY)
488 IRQ_PROG0_INTB, IRQ_PROG1_INTB, IRQ_PROG2_INTB
489#else
490# error no SIC_IWR defined
491#endif
492};
493
588/*********************************************************** 494/***********************************************************
589* 495*
590* FUNCTIONS: Blackfin PM Setup API 496* FUNCTIONS: Blackfin PM Setup API
@@ -669,18 +575,18 @@ u32 bfin_pm_standby_setup(void)
669 mask = wakeup_map[gpio_bank(i)]; 575 mask = wakeup_map[gpio_bank(i)];
670 bank = gpio_bank(i); 576 bank = gpio_bank(i);
671 577
672 gpio_bank_saved[bank].maskb = gpio_bankb[bank]->maskb; 578 gpio_bank_saved[bank].maskb = gpio_array[bank]->maskb;
673 gpio_bankb[bank]->maskb = 0; 579 gpio_array[bank]->maskb = 0;
674 580
675 if (mask) { 581 if (mask) {
676#if defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY) 582#if defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY)
677 gpio_bank_saved[bank].fer = *port_fer[bank]; 583 gpio_bank_saved[bank].fer = *port_fer[bank];
678#endif 584#endif
679 gpio_bank_saved[bank].inen = gpio_bankb[bank]->inen; 585 gpio_bank_saved[bank].inen = gpio_array[bank]->inen;
680 gpio_bank_saved[bank].polar = gpio_bankb[bank]->polar; 586 gpio_bank_saved[bank].polar = gpio_array[bank]->polar;
681 gpio_bank_saved[bank].dir = gpio_bankb[bank]->dir; 587 gpio_bank_saved[bank].dir = gpio_array[bank]->dir;
682 gpio_bank_saved[bank].edge = gpio_bankb[bank]->edge; 588 gpio_bank_saved[bank].edge = gpio_array[bank]->edge;
683 gpio_bank_saved[bank].both = gpio_bankb[bank]->both; 589 gpio_bank_saved[bank].both = gpio_array[bank]->both;
684 gpio_bank_saved[bank].reserved = 590 gpio_bank_saved[bank].reserved =
685 reserved_gpio_map[bank]; 591 reserved_gpio_map[bank];
686 592
@@ -700,7 +606,7 @@ u32 bfin_pm_standby_setup(void)
700 } 606 }
701 607
702 bfin_internal_set_wake(sic_iwr_irqs[bank], 1); 608 bfin_internal_set_wake(sic_iwr_irqs[bank], 1);
703 gpio_bankb[bank]->maskb_set = wakeup_map[gpio_bank(i)]; 609 gpio_array[bank]->maskb_set = wakeup_map[gpio_bank(i)];
704 } 610 }
705 } 611 }
706 612
@@ -721,18 +627,18 @@ void bfin_pm_standby_restore(void)
721#if defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY) 627#if defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY)
722 *port_fer[bank] = gpio_bank_saved[bank].fer; 628 *port_fer[bank] = gpio_bank_saved[bank].fer;
723#endif 629#endif
724 gpio_bankb[bank]->inen = gpio_bank_saved[bank].inen; 630 gpio_array[bank]->inen = gpio_bank_saved[bank].inen;
725 gpio_bankb[bank]->dir = gpio_bank_saved[bank].dir; 631 gpio_array[bank]->dir = gpio_bank_saved[bank].dir;
726 gpio_bankb[bank]->polar = gpio_bank_saved[bank].polar; 632 gpio_array[bank]->polar = gpio_bank_saved[bank].polar;
727 gpio_bankb[bank]->edge = gpio_bank_saved[bank].edge; 633 gpio_array[bank]->edge = gpio_bank_saved[bank].edge;
728 gpio_bankb[bank]->both = gpio_bank_saved[bank].both; 634 gpio_array[bank]->both = gpio_bank_saved[bank].both;
729 635
730 reserved_gpio_map[bank] = 636 reserved_gpio_map[bank] =
731 gpio_bank_saved[bank].reserved; 637 gpio_bank_saved[bank].reserved;
732 bfin_internal_set_wake(sic_iwr_irqs[bank], 0); 638 bfin_internal_set_wake(sic_iwr_irqs[bank], 0);
733 } 639 }
734 640
735 gpio_bankb[bank]->maskb = gpio_bank_saved[bank].maskb; 641 gpio_array[bank]->maskb = gpio_bank_saved[bank].maskb;
736 } 642 }
737 AWA_DUMMY_READ(maskb); 643 AWA_DUMMY_READ(maskb);
738} 644}
@@ -745,21 +651,21 @@ void bfin_gpio_pm_hibernate_suspend(void)
745 bank = gpio_bank(i); 651 bank = gpio_bank(i);
746 652
747#if defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY) 653#if defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY)
748 gpio_bank_saved[bank].fer = *port_fer[bank]; 654 gpio_bank_saved[bank].fer = *port_fer[bank];
749#if defined(BF527_FAMILY) || defined(BF518_FAMILY) 655#if defined(BF527_FAMILY) || defined(BF518_FAMILY)
750 gpio_bank_saved[bank].mux = *port_mux[bank]; 656 gpio_bank_saved[bank].mux = *port_mux[bank];
751#else 657#else
752 if (bank == 0) 658 if (bank == 0)
753 gpio_bank_saved[bank].mux = bfin_read_PORT_MUX(); 659 gpio_bank_saved[bank].mux = bfin_read_PORT_MUX();
754#endif 660#endif
755#endif 661#endif
756 gpio_bank_saved[bank].data = gpio_bankb[bank]->data; 662 gpio_bank_saved[bank].data = gpio_array[bank]->data;
757 gpio_bank_saved[bank].inen = gpio_bankb[bank]->inen; 663 gpio_bank_saved[bank].inen = gpio_array[bank]->inen;
758 gpio_bank_saved[bank].polar = gpio_bankb[bank]->polar; 664 gpio_bank_saved[bank].polar = gpio_array[bank]->polar;
759 gpio_bank_saved[bank].dir = gpio_bankb[bank]->dir; 665 gpio_bank_saved[bank].dir = gpio_array[bank]->dir;
760 gpio_bank_saved[bank].edge = gpio_bankb[bank]->edge; 666 gpio_bank_saved[bank].edge = gpio_array[bank]->edge;
761 gpio_bank_saved[bank].both = gpio_bankb[bank]->both; 667 gpio_bank_saved[bank].both = gpio_array[bank]->both;
762 gpio_bank_saved[bank].maska = gpio_bankb[bank]->maska; 668 gpio_bank_saved[bank].maska = gpio_array[bank]->maska;
763 } 669 }
764 670
765 AWA_DUMMY_READ(maska); 671 AWA_DUMMY_READ(maska);
@@ -770,27 +676,27 @@ void bfin_gpio_pm_hibernate_restore(void)
770 int i, bank; 676 int i, bank;
771 677
772 for (i = 0; i < MAX_BLACKFIN_GPIOS; i += GPIO_BANKSIZE) { 678 for (i = 0; i < MAX_BLACKFIN_GPIOS; i += GPIO_BANKSIZE) {
773 bank = gpio_bank(i); 679 bank = gpio_bank(i);
774 680
775#if defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY) 681#if defined(BF527_FAMILY) || defined(BF537_FAMILY) || defined(BF518_FAMILY)
776#if defined(BF527_FAMILY) || defined(BF518_FAMILY) 682#if defined(BF527_FAMILY) || defined(BF518_FAMILY)
777 *port_mux[bank] = gpio_bank_saved[bank].mux; 683 *port_mux[bank] = gpio_bank_saved[bank].mux;
778#else 684#else
779 if (bank == 0) 685 if (bank == 0)
780 bfin_write_PORT_MUX(gpio_bank_saved[bank].mux); 686 bfin_write_PORT_MUX(gpio_bank_saved[bank].mux);
781#endif 687#endif
782 *port_fer[bank] = gpio_bank_saved[bank].fer; 688 *port_fer[bank] = gpio_bank_saved[bank].fer;
783#endif 689#endif
784 gpio_bankb[bank]->inen = gpio_bank_saved[bank].inen; 690 gpio_array[bank]->inen = gpio_bank_saved[bank].inen;
785 gpio_bankb[bank]->dir = gpio_bank_saved[bank].dir; 691 gpio_array[bank]->dir = gpio_bank_saved[bank].dir;
786 gpio_bankb[bank]->polar = gpio_bank_saved[bank].polar; 692 gpio_array[bank]->polar = gpio_bank_saved[bank].polar;
787 gpio_bankb[bank]->edge = gpio_bank_saved[bank].edge; 693 gpio_array[bank]->edge = gpio_bank_saved[bank].edge;
788 gpio_bankb[bank]->both = gpio_bank_saved[bank].both; 694 gpio_array[bank]->both = gpio_bank_saved[bank].both;
789 695
790 gpio_bankb[bank]->data_set = gpio_bank_saved[bank].data 696 gpio_array[bank]->data_set = gpio_bank_saved[bank].data
791 | gpio_bank_saved[bank].dir; 697 | gpio_bank_saved[bank].dir;
792 698
793 gpio_bankb[bank]->maska = gpio_bank_saved[bank].maska; 699 gpio_array[bank]->maska = gpio_bank_saved[bank].maska;
794 } 700 }
795 AWA_DUMMY_READ(maska); 701 AWA_DUMMY_READ(maska);
796} 702}
@@ -817,12 +723,12 @@ void bfin_gpio_pm_hibernate_suspend(void)
817 for (i = 0; i < MAX_BLACKFIN_GPIOS; i += GPIO_BANKSIZE) { 723 for (i = 0; i < MAX_BLACKFIN_GPIOS; i += GPIO_BANKSIZE) {
818 bank = gpio_bank(i); 724 bank = gpio_bank(i);
819 725
820 gpio_bank_saved[bank].fer = gpio_array[bank]->port_fer; 726 gpio_bank_saved[bank].fer = gpio_array[bank]->port_fer;
821 gpio_bank_saved[bank].mux = gpio_array[bank]->port_mux; 727 gpio_bank_saved[bank].mux = gpio_array[bank]->port_mux;
822 gpio_bank_saved[bank].data = gpio_array[bank]->port_data; 728 gpio_bank_saved[bank].data = gpio_array[bank]->data;
823 gpio_bank_saved[bank].data = gpio_array[bank]->port_data; 729 gpio_bank_saved[bank].data = gpio_array[bank]->data;
824 gpio_bank_saved[bank].inen = gpio_array[bank]->port_inen; 730 gpio_bank_saved[bank].inen = gpio_array[bank]->inen;
825 gpio_bank_saved[bank].dir = gpio_array[bank]->port_dir_set; 731 gpio_bank_saved[bank].dir = gpio_array[bank]->dir_set;
826 } 732 }
827} 733}
828 734
@@ -831,21 +737,21 @@ void bfin_gpio_pm_hibernate_restore(void)
831 int i, bank; 737 int i, bank;
832 738
833 for (i = 0; i < MAX_BLACKFIN_GPIOS; i += GPIO_BANKSIZE) { 739 for (i = 0; i < MAX_BLACKFIN_GPIOS; i += GPIO_BANKSIZE) {
834 bank = gpio_bank(i); 740 bank = gpio_bank(i);
835 741
836 gpio_array[bank]->port_mux = gpio_bank_saved[bank].mux; 742 gpio_array[bank]->port_mux = gpio_bank_saved[bank].mux;
837 gpio_array[bank]->port_fer = gpio_bank_saved[bank].fer; 743 gpio_array[bank]->port_fer = gpio_bank_saved[bank].fer;
838 gpio_array[bank]->port_inen = gpio_bank_saved[bank].inen; 744 gpio_array[bank]->inen = gpio_bank_saved[bank].inen;
839 gpio_array[bank]->port_dir_set = gpio_bank_saved[bank].dir; 745 gpio_array[bank]->dir_set = gpio_bank_saved[bank].dir;
840 gpio_array[bank]->port_set = gpio_bank_saved[bank].data 746 gpio_array[bank]->data_set = gpio_bank_saved[bank].data
841 | gpio_bank_saved[bank].dir; 747 | gpio_bank_saved[bank].dir;
842 } 748 }
843} 749}
844#endif 750#endif
845 751
846unsigned short get_gpio_dir(unsigned gpio) 752unsigned short get_gpio_dir(unsigned gpio)
847{ 753{
848 return (0x01 & (gpio_array[gpio_bank(gpio)]->port_dir_clear >> gpio_sub_n(gpio))); 754 return (0x01 & (gpio_array[gpio_bank(gpio)]->dir_clear >> gpio_sub_n(gpio)));
849} 755}
850EXPORT_SYMBOL(get_gpio_dir); 756EXPORT_SYMBOL(get_gpio_dir);
851 757
@@ -905,9 +811,7 @@ int peripheral_request(unsigned short per, const char *label)
905 */ 811 */
906 812
907#ifdef BF548_FAMILY 813#ifdef BF548_FAMILY
908 u16 funct = get_portmux(ident); 814 if (!((per & P_MAYSHARE) && get_portmux(per) == P_FUNCT2MUX(per))) {
909
910 if (!((per & P_MAYSHARE) && (funct == P_FUNCT2MUX(per)))) {
911#else 815#else
912 if (!(per & P_MAYSHARE)) { 816 if (!(per & P_MAYSHARE)) {
913#endif 817#endif
@@ -931,11 +835,7 @@ int peripheral_request(unsigned short per, const char *label)
931 anyway: 835 anyway:
932 reserved_peri_map[gpio_bank(ident)] |= gpio_bit(ident); 836 reserved_peri_map[gpio_bank(ident)] |= gpio_bit(ident);
933 837
934#ifdef BF548_FAMILY 838 portmux_setup(per);
935 portmux_setup(ident, P_FUNCT2MUX(per));
936#else
937 portmux_setup(per, P_FUNCT2MUX(per));
938#endif
939 port_setup(ident, PERIPHERAL_USAGE); 839 port_setup(ident, PERIPHERAL_USAGE);
940 840
941 local_irq_restore_hw(flags); 841 local_irq_restore_hw(flags);
@@ -1163,8 +1063,16 @@ void bfin_gpio_irq_free(unsigned gpio)
1163 local_irq_restore_hw(flags); 1063 local_irq_restore_hw(flags);
1164} 1064}
1165 1065
1166 1066static inline void __bfin_gpio_direction_input(unsigned gpio)
1067{
1167#ifdef BF548_FAMILY 1068#ifdef BF548_FAMILY
1069 gpio_array[gpio_bank(gpio)]->dir_clear = gpio_bit(gpio);
1070#else
1071 gpio_array[gpio_bank(gpio)]->dir &= ~gpio_bit(gpio);
1072#endif
1073 gpio_array[gpio_bank(gpio)]->inen |= gpio_bit(gpio);
1074}
1075
1168int bfin_gpio_direction_input(unsigned gpio) 1076int bfin_gpio_direction_input(unsigned gpio)
1169{ 1077{
1170 unsigned long flags; 1078 unsigned long flags;
@@ -1175,125 +1083,85 @@ int bfin_gpio_direction_input(unsigned gpio)
1175 } 1083 }
1176 1084
1177 local_irq_save_hw(flags); 1085 local_irq_save_hw(flags);
1178 gpio_array[gpio_bank(gpio)]->port_dir_clear = gpio_bit(gpio); 1086 __bfin_gpio_direction_input(gpio);
1179 gpio_array[gpio_bank(gpio)]->port_inen |= gpio_bit(gpio); 1087 AWA_DUMMY_READ(inen);
1180 local_irq_restore_hw(flags); 1088 local_irq_restore_hw(flags);
1181 1089
1182 return 0; 1090 return 0;
1183} 1091}
1184EXPORT_SYMBOL(bfin_gpio_direction_input); 1092EXPORT_SYMBOL(bfin_gpio_direction_input);
1185 1093
1186int bfin_gpio_direction_output(unsigned gpio, int value) 1094void bfin_gpio_irq_prepare(unsigned gpio)
1187{ 1095{
1096#ifdef BF548_FAMILY
1188 unsigned long flags; 1097 unsigned long flags;
1098#endif
1189 1099
1190 if (!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))) { 1100 port_setup(gpio, GPIO_USAGE);
1191 gpio_error(gpio);
1192 return -EINVAL;
1193 }
1194 1101
1102#ifdef BF548_FAMILY
1195 local_irq_save_hw(flags); 1103 local_irq_save_hw(flags);
1196 gpio_array[gpio_bank(gpio)]->port_inen &= ~gpio_bit(gpio); 1104 __bfin_gpio_direction_input(gpio);
1197 gpio_set_value(gpio, value);
1198 gpio_array[gpio_bank(gpio)]->port_dir_set = gpio_bit(gpio);
1199 local_irq_restore_hw(flags); 1105 local_irq_restore_hw(flags);
1200 1106#endif
1201 return 0;
1202} 1107}
1203EXPORT_SYMBOL(bfin_gpio_direction_output);
1204 1108
1205void bfin_gpio_set_value(unsigned gpio, int arg) 1109void bfin_gpio_set_value(unsigned gpio, int arg)
1206{ 1110{
1207 if (arg) 1111 if (arg)
1208 gpio_array[gpio_bank(gpio)]->port_set = gpio_bit(gpio); 1112 gpio_array[gpio_bank(gpio)]->data_set = gpio_bit(gpio);
1209 else 1113 else
1210 gpio_array[gpio_bank(gpio)]->port_clear = gpio_bit(gpio); 1114 gpio_array[gpio_bank(gpio)]->data_clear = gpio_bit(gpio);
1211} 1115}
1212EXPORT_SYMBOL(bfin_gpio_set_value); 1116EXPORT_SYMBOL(bfin_gpio_set_value);
1213 1117
1214int bfin_gpio_get_value(unsigned gpio) 1118int bfin_gpio_direction_output(unsigned gpio, int value)
1215{
1216 return (1 & (gpio_array[gpio_bank(gpio)]->port_data >> gpio_sub_n(gpio)));
1217}
1218EXPORT_SYMBOL(bfin_gpio_get_value);
1219
1220void bfin_gpio_irq_prepare(unsigned gpio)
1221{ 1119{
1222 unsigned long flags; 1120 unsigned long flags;
1223 1121
1224 port_setup(gpio, GPIO_USAGE); 1122 if (!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))) {
1123 gpio_error(gpio);
1124 return -EINVAL;
1125 }
1225 1126
1226 local_irq_save_hw(flags); 1127 local_irq_save_hw(flags);
1227 gpio_array[gpio_bank(gpio)]->port_dir_clear = gpio_bit(gpio);
1228 gpio_array[gpio_bank(gpio)]->port_inen |= gpio_bit(gpio);
1229 local_irq_restore_hw(flags);
1230}
1231 1128
1129 gpio_array[gpio_bank(gpio)]->inen &= ~gpio_bit(gpio);
1130 gpio_set_value(gpio, value);
1131#ifdef BF548_FAMILY
1132 gpio_array[gpio_bank(gpio)]->dir_set = gpio_bit(gpio);
1232#else 1133#else
1134 gpio_array[gpio_bank(gpio)]->dir |= gpio_bit(gpio);
1135#endif
1136
1137 AWA_DUMMY_READ(dir);
1138 local_irq_restore_hw(flags);
1139
1140 return 0;
1141}
1142EXPORT_SYMBOL(bfin_gpio_direction_output);
1233 1143
1234int bfin_gpio_get_value(unsigned gpio) 1144int bfin_gpio_get_value(unsigned gpio)
1235{ 1145{
1146#ifdef BF548_FAMILY
1147 return (1 & (gpio_array[gpio_bank(gpio)]->data >> gpio_sub_n(gpio)));
1148#else
1236 unsigned long flags; 1149 unsigned long flags;
1237 int ret;
1238 1150
1239 if (unlikely(get_gpio_edge(gpio))) { 1151 if (unlikely(get_gpio_edge(gpio))) {
1152 int ret;
1240 local_irq_save_hw(flags); 1153 local_irq_save_hw(flags);
1241 set_gpio_edge(gpio, 0); 1154 set_gpio_edge(gpio, 0);
1242 ret = get_gpio_data(gpio); 1155 ret = get_gpio_data(gpio);
1243 set_gpio_edge(gpio, 1); 1156 set_gpio_edge(gpio, 1);
1244 local_irq_restore_hw(flags); 1157 local_irq_restore_hw(flags);
1245
1246 return ret; 1158 return ret;
1247 } else 1159 } else
1248 return get_gpio_data(gpio); 1160 return get_gpio_data(gpio);
1161#endif
1249} 1162}
1250EXPORT_SYMBOL(bfin_gpio_get_value); 1163EXPORT_SYMBOL(bfin_gpio_get_value);
1251 1164
1252
1253int bfin_gpio_direction_input(unsigned gpio)
1254{
1255 unsigned long flags;
1256
1257 if (!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))) {
1258 gpio_error(gpio);
1259 return -EINVAL;
1260 }
1261
1262 local_irq_save_hw(flags);
1263 gpio_bankb[gpio_bank(gpio)]->dir &= ~gpio_bit(gpio);
1264 gpio_bankb[gpio_bank(gpio)]->inen |= gpio_bit(gpio);
1265 AWA_DUMMY_READ(inen);
1266 local_irq_restore_hw(flags);
1267
1268 return 0;
1269}
1270EXPORT_SYMBOL(bfin_gpio_direction_input);
1271
1272int bfin_gpio_direction_output(unsigned gpio, int value)
1273{
1274 unsigned long flags;
1275
1276 if (!(reserved_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))) {
1277 gpio_error(gpio);
1278 return -EINVAL;
1279 }
1280
1281 local_irq_save_hw(flags);
1282 gpio_bankb[gpio_bank(gpio)]->inen &= ~gpio_bit(gpio);
1283
1284 if (value)
1285 gpio_bankb[gpio_bank(gpio)]->data_set = gpio_bit(gpio);
1286 else
1287 gpio_bankb[gpio_bank(gpio)]->data_clear = gpio_bit(gpio);
1288
1289 gpio_bankb[gpio_bank(gpio)]->dir |= gpio_bit(gpio);
1290 AWA_DUMMY_READ(dir);
1291 local_irq_restore_hw(flags);
1292
1293 return 0;
1294}
1295EXPORT_SYMBOL(bfin_gpio_direction_output);
1296
1297/* If we are booting from SPI and our board lacks a strong enough pull up, 1165/* If we are booting from SPI and our board lacks a strong enough pull up,
1298 * the core can reset and execute the bootrom faster than the resistor can 1166 * the core can reset and execute the bootrom faster than the resistor can
1299 * pull the signal logically high. To work around this (common) error in 1167 * pull the signal logically high. To work around this (common) error in
@@ -1309,18 +1177,11 @@ void bfin_gpio_reset_spi0_ssel1(void)
1309 u16 gpio = P_IDENT(P_SPI0_SSEL1); 1177 u16 gpio = P_IDENT(P_SPI0_SSEL1);
1310 1178
1311 port_setup(gpio, GPIO_USAGE); 1179 port_setup(gpio, GPIO_USAGE);
1312 gpio_bankb[gpio_bank(gpio)]->data_set = gpio_bit(gpio); 1180 gpio_array[gpio_bank(gpio)]->data_set = gpio_bit(gpio);
1313 AWA_DUMMY_READ(data_set); 1181 AWA_DUMMY_READ(data_set);
1314 udelay(1); 1182 udelay(1);
1315} 1183}
1316 1184
1317void bfin_gpio_irq_prepare(unsigned gpio)
1318{
1319 port_setup(gpio, GPIO_USAGE);
1320}
1321
1322#endif /*BF548_FAMILY */
1323
1324#if defined(CONFIG_PROC_FS) 1185#if defined(CONFIG_PROC_FS)
1325static int gpio_proc_read(char *buf, char **start, off_t offset, 1186static int gpio_proc_read(char *buf, char **start, off_t offset,
1326 int len, int *unused_i, void *unused_v) 1187 int len, int *unused_i, void *unused_v)
@@ -1374,11 +1235,7 @@ int bfin_gpiolib_get_value(struct gpio_chip *chip, unsigned gpio)
1374 1235
1375void bfin_gpiolib_set_value(struct gpio_chip *chip, unsigned gpio, int value) 1236void bfin_gpiolib_set_value(struct gpio_chip *chip, unsigned gpio, int value)
1376{ 1237{
1377#ifdef BF548_FAMILY
1378 return bfin_gpio_set_value(gpio, value); 1238 return bfin_gpio_set_value(gpio, value);
1379#else
1380 return set_gpio_data(gpio, value);
1381#endif
1382} 1239}
1383 1240
1384int bfin_gpiolib_gpio_request(struct gpio_chip *chip, unsigned gpio) 1241int bfin_gpiolib_gpio_request(struct gpio_chip *chip, unsigned gpio)
diff --git a/arch/blackfin/mach-bf548/include/mach/gpio.h b/arch/blackfin/mach-bf548/include/mach/gpio.h
index bba82dc75f16..3a2051709787 100644
--- a/arch/blackfin/mach-bf548/include/mach/gpio.h
+++ b/arch/blackfin/mach-bf548/include/mach/gpio.h
@@ -195,17 +195,17 @@
195struct gpio_port_t { 195struct gpio_port_t {
196 unsigned short port_fer; 196 unsigned short port_fer;
197 unsigned short dummy1; 197 unsigned short dummy1;
198 unsigned short port_data; 198 unsigned short data;
199 unsigned short dummy2; 199 unsigned short dummy2;
200 unsigned short port_set; 200 unsigned short data_set;
201 unsigned short dummy3; 201 unsigned short dummy3;
202 unsigned short port_clear; 202 unsigned short data_clear;
203 unsigned short dummy4; 203 unsigned short dummy4;
204 unsigned short port_dir_set; 204 unsigned short dir_set;
205 unsigned short dummy5; 205 unsigned short dummy5;
206 unsigned short port_dir_clear; 206 unsigned short dir_clear;
207 unsigned short dummy6; 207 unsigned short dummy6;
208 unsigned short port_inen; 208 unsigned short inen;
209 unsigned short dummy7; 209 unsigned short dummy7;
210 unsigned int port_mux; 210 unsigned int port_mux;
211}; 211};