aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-stmp3xxx/pinmux.c
diff options
context:
space:
mode:
authordmitry pervushin <dpervushin@embeddedalley.com>2009-05-31 08:32:11 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2009-05-31 08:55:56 -0400
commit98f420b23a62e0c9df78c5851860d47bf1bc87dd (patch)
treeb7e88059454d2410b1a2107c17a748a03d366fdf /arch/arm/plat-stmp3xxx/pinmux.c
parent3f52326a85666c1cb0210eb5556ef3d483933cfc (diff)
[ARM] 5532/1: Freescale STMP: register definitions [3/3]
Replace HW_zzz register access macros by regular __raw_readl/__raw_writel calls Signed-off-by: dmitry pervushin <dpervushin@embeddedalley.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/plat-stmp3xxx/pinmux.c')
-rw-r--r--arch/arm/plat-stmp3xxx/pinmux.c163
1 files changed, 85 insertions, 78 deletions
diff --git a/arch/arm/plat-stmp3xxx/pinmux.c b/arch/arm/plat-stmp3xxx/pinmux.c
index 9b28cc83f31c..d41200382208 100644
--- a/arch/arm/plat-stmp3xxx/pinmux.c
+++ b/arch/arm/plat-stmp3xxx/pinmux.c
@@ -15,6 +15,7 @@
15 * http://www.opensource.org/licenses/gpl-license.html 15 * http://www.opensource.org/licenses/gpl-license.html
16 * http://www.gnu.org/copyleft/gpl.html 16 * http://www.gnu.org/copyleft/gpl.html
17 */ 17 */
18#define DEBUG
18#include <linux/module.h> 19#include <linux/module.h>
19#include <linux/kernel.h> 20#include <linux/kernel.h>
20#include <linux/errno.h> 21#include <linux/errno.h>
@@ -25,6 +26,7 @@
25#include <linux/irq.h> 26#include <linux/irq.h>
26 27
27#include <mach/hardware.h> 28#include <mach/hardware.h>
29#include <mach/platform.h>
28#include <mach/regs-pinctrl.h> 30#include <mach/regs-pinctrl.h>
29#include <mach/pins.h> 31#include <mach/pins.h>
30#include <mach/pinmux.h> 32#include <mach/pinmux.h>
@@ -33,97 +35,94 @@
33static struct stmp3xxx_pinmux_bank pinmux_banks[] = { 35static struct stmp3xxx_pinmux_bank pinmux_banks[] = {
34 [0] = { 36 [0] = {
35 .hw_muxsel = { 37 .hw_muxsel = {
36 HW_PINCTRL_MUXSEL0_ADDR, 38 REGS_PINCTRL_BASE + HW_PINCTRL_MUXSEL0,
37 HW_PINCTRL_MUXSEL1_ADDR 39 REGS_PINCTRL_BASE + HW_PINCTRL_MUXSEL1,
38 }, 40 },
39 .hw_drive = { 41 .hw_drive = {
40 HW_PINCTRL_DRIVE0_ADDR, 42 REGS_PINCTRL_BASE + HW_PINCTRL_DRIVE0,
41 HW_PINCTRL_DRIVE1_ADDR, 43 REGS_PINCTRL_BASE + HW_PINCTRL_DRIVE1,
42 HW_PINCTRL_DRIVE2_ADDR, 44 REGS_PINCTRL_BASE + HW_PINCTRL_DRIVE2,
43 HW_PINCTRL_DRIVE3_ADDR 45 REGS_PINCTRL_BASE + HW_PINCTRL_DRIVE3,
44 }, 46 },
45 .hw_pull = HW_PINCTRL_PULL0_ADDR, 47 .hw_pull = REGS_PINCTRL_BASE + HW_PINCTRL_PULL0,
46 .functions = { 0x0, 0x1, 0x2, 0x3 }, 48 .functions = { 0x0, 0x1, 0x2, 0x3 },
47 .strengths = { 0x0, 0x1, 0x2, 0x3, 0xff }, 49 .strengths = { 0x0, 0x1, 0x2, 0x3, 0xff },
48 50
49 .hw_gpio_read = HW_PINCTRL_DIN0_ADDR, 51 .hw_gpio_in = REGS_PINCTRL_BASE + HW_PINCTRL_DIN0,
50 .hw_gpio_set = HW_PINCTRL_DOUT0_ADDR + HW_STMP3xxx_SET, 52 .hw_gpio_out = REGS_PINCTRL_BASE + HW_PINCTRL_DOUT0,
51 .hw_gpio_clr = HW_PINCTRL_DOUT0_ADDR + HW_STMP3xxx_CLR, 53 .hw_gpio_doe = REGS_PINCTRL_BASE + HW_PINCTRL_DOE0,
52 .hw_gpio_doe = HW_PINCTRL_DOE0_ADDR,
53 .irq = IRQ_GPIO0, 54 .irq = IRQ_GPIO0,
54 55
55 .pin2irq = HW_PINCTRL_PIN2IRQ0_ADDR, 56 .pin2irq = REGS_PINCTRL_BASE + HW_PINCTRL_PIN2IRQ0,
56 .irqstat = HW_PINCTRL_IRQSTAT0_ADDR, 57 .irqstat = REGS_PINCTRL_BASE + HW_PINCTRL_IRQSTAT0,
57 .irqlevel = HW_PINCTRL_IRQLEVEL0_ADDR, 58 .irqlevel = REGS_PINCTRL_BASE + HW_PINCTRL_IRQLEVEL0,
58 .irqpolarity = HW_PINCTRL_IRQPOL0_ADDR, 59 .irqpolarity = REGS_PINCTRL_BASE + HW_PINCTRL_IRQPOL0,
59 .irqen = HW_PINCTRL_IRQEN0_ADDR, 60 .irqen = REGS_PINCTRL_BASE + HW_PINCTRL_IRQEN0,
60 }, 61 },
61 [1] = { 62 [1] = {
62 .hw_muxsel = { 63 .hw_muxsel = {
63 HW_PINCTRL_MUXSEL2_ADDR, 64 REGS_PINCTRL_BASE + HW_PINCTRL_MUXSEL2,
64 HW_PINCTRL_MUXSEL3_ADDR 65 REGS_PINCTRL_BASE + HW_PINCTRL_MUXSEL3,
65 }, 66 },
66 .hw_drive = { 67 .hw_drive = {
67 HW_PINCTRL_DRIVE4_ADDR, 68 REGS_PINCTRL_BASE + HW_PINCTRL_DRIVE4,
68 HW_PINCTRL_DRIVE5_ADDR, 69 REGS_PINCTRL_BASE + HW_PINCTRL_DRIVE5,
69 HW_PINCTRL_DRIVE6_ADDR, 70 REGS_PINCTRL_BASE + HW_PINCTRL_DRIVE6,
70 HW_PINCTRL_DRIVE7_ADDR 71 REGS_PINCTRL_BASE + HW_PINCTRL_DRIVE7,
71 }, 72 },
72 .hw_pull = HW_PINCTRL_PULL1_ADDR, 73 .hw_pull = REGS_PINCTRL_BASE + HW_PINCTRL_PULL1,
73 .functions = { 0x0, 0x1, 0x2, 0x3 }, 74 .functions = { 0x0, 0x1, 0x2, 0x3 },
74 .strengths = { 0x0, 0x1, 0x2, 0x3, 0xff }, 75 .strengths = { 0x0, 0x1, 0x2, 0x3, 0xff },
75 76
76 .hw_gpio_read = HW_PINCTRL_DIN1_ADDR, 77 .hw_gpio_in = REGS_PINCTRL_BASE + HW_PINCTRL_DIN1,
77 .hw_gpio_set = HW_PINCTRL_DOUT1_ADDR + HW_STMP3xxx_SET, 78 .hw_gpio_out = REGS_PINCTRL_BASE + HW_PINCTRL_DOUT1,
78 .hw_gpio_clr = HW_PINCTRL_DOUT1_ADDR + HW_STMP3xxx_CLR, 79 .hw_gpio_doe = REGS_PINCTRL_BASE + HW_PINCTRL_DOE1,
79 .hw_gpio_doe = HW_PINCTRL_DOE1_ADDR,
80 .irq = IRQ_GPIO1, 80 .irq = IRQ_GPIO1,
81 81
82 .pin2irq = HW_PINCTRL_PIN2IRQ1_ADDR, 82 .pin2irq = REGS_PINCTRL_BASE + HW_PINCTRL_PIN2IRQ1,
83 .irqstat = HW_PINCTRL_IRQSTAT1_ADDR, 83 .irqstat = REGS_PINCTRL_BASE + HW_PINCTRL_IRQSTAT1,
84 .irqlevel = HW_PINCTRL_IRQLEVEL1_ADDR, 84 .irqlevel = REGS_PINCTRL_BASE + HW_PINCTRL_IRQLEVEL1,
85 .irqpolarity = HW_PINCTRL_IRQPOL1_ADDR, 85 .irqpolarity = REGS_PINCTRL_BASE + HW_PINCTRL_IRQPOL1,
86 .irqen = HW_PINCTRL_IRQEN1_ADDR, 86 .irqen = REGS_PINCTRL_BASE + HW_PINCTRL_IRQEN1,
87 }, 87 },
88 [2] = { 88 [2] = {
89 .hw_muxsel = { 89 .hw_muxsel = {
90 HW_PINCTRL_MUXSEL4_ADDR, 90 REGS_PINCTRL_BASE + HW_PINCTRL_MUXSEL4,
91 HW_PINCTRL_MUXSEL5_ADDR, 91 REGS_PINCTRL_BASE + HW_PINCTRL_MUXSEL5,
92 }, 92 },
93 .hw_drive = { 93 .hw_drive = {
94 HW_PINCTRL_DRIVE8_ADDR, 94 REGS_PINCTRL_BASE + HW_PINCTRL_DRIVE8,
95 HW_PINCTRL_DRIVE9_ADDR, 95 REGS_PINCTRL_BASE + HW_PINCTRL_DRIVE9,
96 HW_PINCTRL_DRIVE10_ADDR, 96 REGS_PINCTRL_BASE + HW_PINCTRL_DRIVE10,
97 HW_PINCTRL_DRIVE11_ADDR, 97 REGS_PINCTRL_BASE + HW_PINCTRL_DRIVE11,
98 }, 98 },
99 .hw_pull = HW_PINCTRL_PULL2_ADDR, 99 .hw_pull = REGS_PINCTRL_BASE + HW_PINCTRL_PULL2,
100 .functions = { 0x0, 0x1, 0x2, 0x3 }, 100 .functions = { 0x0, 0x1, 0x2, 0x3 },
101 .strengths = { 0x0, 0x1, 0x2, 0x1, 0x2 }, 101 .strengths = { 0x0, 0x1, 0x2, 0x1, 0x2 },
102 102
103 .hw_gpio_read = HW_PINCTRL_DIN2_ADDR, 103 .hw_gpio_in = REGS_PINCTRL_BASE + HW_PINCTRL_DIN2,
104 .hw_gpio_set = HW_PINCTRL_DOUT2_ADDR + HW_STMP3xxx_SET, 104 .hw_gpio_out = REGS_PINCTRL_BASE + HW_PINCTRL_DOUT2,
105 .hw_gpio_clr = HW_PINCTRL_DOUT2_ADDR + HW_STMP3xxx_CLR, 105 .hw_gpio_doe = REGS_PINCTRL_BASE + HW_PINCTRL_DOE2,
106 .hw_gpio_doe = HW_PINCTRL_DOE2_ADDR,
107 .irq = IRQ_GPIO2, 106 .irq = IRQ_GPIO2,
108 107
109 .pin2irq = HW_PINCTRL_PIN2IRQ2_ADDR, 108 .pin2irq = REGS_PINCTRL_BASE + HW_PINCTRL_PIN2IRQ2,
110 .irqstat = HW_PINCTRL_IRQSTAT2_ADDR, 109 .irqstat = REGS_PINCTRL_BASE + HW_PINCTRL_IRQSTAT2,
111 .irqlevel = HW_PINCTRL_IRQLEVEL2_ADDR, 110 .irqlevel = REGS_PINCTRL_BASE + HW_PINCTRL_IRQLEVEL2,
112 .irqpolarity = HW_PINCTRL_IRQPOL2_ADDR, 111 .irqpolarity = REGS_PINCTRL_BASE + HW_PINCTRL_IRQPOL2,
113 .irqen = HW_PINCTRL_IRQEN2_ADDR, 112 .irqen = REGS_PINCTRL_BASE + HW_PINCTRL_IRQEN2,
114 }, 113 },
115 [3] = { 114 [3] = {
116 .hw_muxsel = { 115 .hw_muxsel = {
117 HW_PINCTRL_MUXSEL6_ADDR, 116 REGS_PINCTRL_BASE + HW_PINCTRL_MUXSEL6,
118 HW_PINCTRL_MUXSEL7_ADDR, 117 REGS_PINCTRL_BASE + HW_PINCTRL_MUXSEL7,
119 }, 118 },
120 .hw_drive = { 119 .hw_drive = {
121 HW_PINCTRL_DRIVE12_ADDR, 120 REGS_PINCTRL_BASE + HW_PINCTRL_DRIVE12,
122 HW_PINCTRL_DRIVE13_ADDR, 121 REGS_PINCTRL_BASE + HW_PINCTRL_DRIVE13,
123 HW_PINCTRL_DRIVE14_ADDR, 122 REGS_PINCTRL_BASE + HW_PINCTRL_DRIVE14,
124 NULL, 123 NULL,
125 }, 124 },
126 .hw_pull = HW_PINCTRL_PULL3_ADDR, 125 .hw_pull = REGS_PINCTRL_BASE + HW_PINCTRL_PULL3,
127 .functions = {0x0, 0x1, 0x2, 0x3}, 126 .functions = {0x0, 0x1, 0x2, 0x3},
128 .strengths = {0x0, 0x1, 0x2, 0x3, 0xff}, 127 .strengths = {0x0, 0x1, 0x2, 0x3, 0xff},
129 }, 128 },
@@ -196,8 +195,8 @@ void stmp3xxx_pin_strength(unsigned id, enum pin_strength strength,
196 195
197 pr_debug("%s: writing 0x%x to 0x%p register\n", __func__, 196 pr_debug("%s: writing 0x%x to 0x%p register\n", __func__,
198 val << shift, hwdrive); 197 val << shift, hwdrive);
199 __raw_writel(HW_DRIVE_PINDRV_MASK << shift, hwdrive + HW_STMP3xxx_CLR); 198 stmp3xxx_clearl(HW_DRIVE_PINDRV_MASK << shift, hwdrive);
200 __raw_writel(val << shift, hwdrive + HW_STMP3xxx_SET); 199 stmp3xxx_setl(val << shift, hwdrive);
201} 200}
202 201
203void stmp3xxx_pin_voltage(unsigned id, enum pin_voltage voltage, 202void stmp3xxx_pin_voltage(unsigned id, enum pin_voltage voltage,
@@ -221,11 +220,9 @@ void stmp3xxx_pin_voltage(unsigned id, enum pin_voltage voltage,
221 pr_debug("%s: changing 0x%x bit in 0x%p register\n", 220 pr_debug("%s: changing 0x%x bit in 0x%p register\n",
222 __func__, HW_DRIVE_PINV_MASK << shift, hwdrive); 221 __func__, HW_DRIVE_PINV_MASK << shift, hwdrive);
223 if (voltage == PIN_1_8V) 222 if (voltage == PIN_1_8V)
224 __raw_writel(HW_DRIVE_PINV_MASK << shift, 223 stmp3xxx_clearl(HW_DRIVE_PINV_MASK << shift, hwdrive);
225 hwdrive + HW_STMP3xxx_CLR);
226 else 224 else
227 __raw_writel(HW_DRIVE_PINV_MASK << shift, 225 stmp3xxx_setl(HW_DRIVE_PINV_MASK << shift, hwdrive);
228 hwdrive + HW_STMP3xxx_SET);
229} 226}
230 227
231void stmp3xxx_pin_pullup(unsigned id, int enable, const char *label) 228void stmp3xxx_pin_pullup(unsigned id, int enable, const char *label)
@@ -245,8 +242,10 @@ void stmp3xxx_pin_pullup(unsigned id, int enable, const char *label)
245 242
246 pr_debug("%s: changing 0x%x bit in 0x%p register\n", 243 pr_debug("%s: changing 0x%x bit in 0x%p register\n",
247 __func__, 1 << pin, hwpull); 244 __func__, 1 << pin, hwpull);
248 __raw_writel(1 << pin, 245 if (enable)
249 hwpull + (enable ? HW_STMP3xxx_SET : HW_STMP3xxx_CLR)); 246 stmp3xxx_setl(1 << pin, hwpull);
247 else
248 stmp3xxx_clearl(1 << pin, hwpull);
250} 249}
251 250
252int stmp3xxx_request_pin(unsigned id, enum pin_fun fun, const char *label) 251int stmp3xxx_request_pin(unsigned id, enum pin_fun fun, const char *label)
@@ -290,8 +289,8 @@ void stmp3xxx_set_pin_type(unsigned id, enum pin_fun fun)
290 shift = (pin % HW_MUXSEL_PIN_NUM) * HW_MUXSEL_PIN_LEN; 289 shift = (pin % HW_MUXSEL_PIN_NUM) * HW_MUXSEL_PIN_LEN;
291 pr_debug("%s: writing 0x%x to 0x%p register\n", 290 pr_debug("%s: writing 0x%x to 0x%p register\n",
292 __func__, val << shift, hwmux); 291 __func__, val << shift, hwmux);
293 __raw_writel(HW_MUXSEL_PINFUN_MASK << shift, hwmux + HW_STMP3xxx_CLR); 292 stmp3xxx_clearl(HW_MUXSEL_PINFUN_MASK << shift, hwmux);
294 __raw_writel(val << shift, hwmux + HW_STMP3xxx_SET); 293 stmp3xxx_setl(val << shift, hwmux);
295} 294}
296 295
297void stmp3xxx_release_pin(unsigned id, const char *label) 296void stmp3xxx_release_pin(unsigned id, const char *label)
@@ -388,10 +387,15 @@ static int stmp3xxx_set_irqtype(unsigned irq, unsigned type)
388 __func__, type); 387 __func__, type);
389 return -ENXIO; 388 return -ENXIO;
390 } 389 }
391 __raw_writel(1 << gpio, 390
392 pm->irqlevel + (l ? HW_STMP3xxx_SET : HW_STMP3xxx_CLR)); 391 if (l)
393 __raw_writel(1 << gpio, 392 stmp3xxx_setl(1 << gpio, pm->irqlevel);
394 pm->irqpolarity + (p ? HW_STMP3xxx_SET : HW_STMP3xxx_CLR)); 393 else
394 stmp3xxx_clearl(1 << gpio, pm->irqlevel);
395 if (p)
396 stmp3xxx_setl(1 << gpio, pm->irqpolarity);
397 else
398 stmp3xxx_clearl(1 << gpio, pm->irqpolarity);
395 return 0; 399 return 0;
396} 400}
397 401
@@ -402,8 +406,8 @@ static void stmp3xxx_pin_ack_irq(unsigned irq)
402 unsigned gpio; 406 unsigned gpio;
403 407
404 stmp3xxx_irq_to_gpio(irq, &pm, &gpio); 408 stmp3xxx_irq_to_gpio(irq, &pm, &gpio);
405 stat = __raw_readl(pm->irqstat) & (1<<gpio); 409 stat = __raw_readl(pm->irqstat) & (1 << gpio);
406 __raw_writel(stat, pm->irqstat + HW_STMP3xxx_CLR); 410 stmp3xxx_clearl(stat, pm->irqstat);
407} 411}
408 412
409static void stmp3xxx_pin_mask_irq(unsigned irq) 413static void stmp3xxx_pin_mask_irq(unsigned irq)
@@ -412,8 +416,8 @@ static void stmp3xxx_pin_mask_irq(unsigned irq)
412 unsigned gpio; 416 unsigned gpio;
413 417
414 stmp3xxx_irq_to_gpio(irq, &pm, &gpio); 418 stmp3xxx_irq_to_gpio(irq, &pm, &gpio);
415 __raw_writel(1 << gpio, pm->irqen + HW_STMP3xxx_CLR); 419 stmp3xxx_clearl(1 << gpio, pm->irqen);
416 __raw_writel(1 << gpio, pm->pin2irq + HW_STMP3xxx_CLR); 420 stmp3xxx_clearl(1 << gpio, pm->pin2irq);
417} 421}
418 422
419static void stmp3xxx_pin_unmask_irq(unsigned irq) 423static void stmp3xxx_pin_unmask_irq(unsigned irq)
@@ -422,8 +426,8 @@ static void stmp3xxx_pin_unmask_irq(unsigned irq)
422 unsigned gpio; 426 unsigned gpio;
423 427
424 stmp3xxx_irq_to_gpio(irq, &pm, &gpio); 428 stmp3xxx_irq_to_gpio(irq, &pm, &gpio);
425 __raw_writel(1 << gpio, pm->irqen + HW_STMP3xxx_SET); 429 stmp3xxx_setl(1 << gpio, pm->irqen);
426 __raw_writel(1 << gpio, pm->pin2irq + HW_STMP3xxx_SET); 430 stmp3xxx_setl(1 << gpio, pm->pin2irq);
427} 431}
428 432
429static inline 433static inline
@@ -443,7 +447,7 @@ static int stmp3xxx_gpio_get(struct gpio_chip *chip, unsigned offset)
443 struct stmp3xxx_pinmux_bank *pm = to_pinmux_bank(chip); 447 struct stmp3xxx_pinmux_bank *pm = to_pinmux_bank(chip);
444 unsigned v; 448 unsigned v;
445 449
446 v = __raw_readl(pm->hw_gpio_read) & (1 << offset); 450 v = __raw_readl(pm->hw_gpio_in) & (1 << offset);
447 return v ? 1 : 0; 451 return v ? 1 : 0;
448} 452}
449 453
@@ -451,14 +455,17 @@ static void stmp3xxx_gpio_set(struct gpio_chip *chip, unsigned offset, int v)
451{ 455{
452 struct stmp3xxx_pinmux_bank *pm = to_pinmux_bank(chip); 456 struct stmp3xxx_pinmux_bank *pm = to_pinmux_bank(chip);
453 457
454 __raw_writel(1 << offset, v ? pm->hw_gpio_set : pm->hw_gpio_clr); 458 if (v)
459 stmp3xxx_setl(1 << offset, pm->hw_gpio_out);
460 else
461 stmp3xxx_clearl(1 << offset, pm->hw_gpio_out);
455} 462}
456 463
457static int stmp3xxx_gpio_output(struct gpio_chip *chip, unsigned offset, int v) 464static int stmp3xxx_gpio_output(struct gpio_chip *chip, unsigned offset, int v)
458{ 465{
459 struct stmp3xxx_pinmux_bank *pm = to_pinmux_bank(chip); 466 struct stmp3xxx_pinmux_bank *pm = to_pinmux_bank(chip);
460 467
461 __raw_writel(1 << offset, pm->hw_gpio_doe + HW_STMP3xxx_SET); 468 stmp3xxx_setl(1 << offset, pm->hw_gpio_doe);
462 stmp3xxx_gpio_set(chip, offset, v); 469 stmp3xxx_gpio_set(chip, offset, v);
463 return 0; 470 return 0;
464} 471}
@@ -467,7 +474,7 @@ static int stmp3xxx_gpio_input(struct gpio_chip *chip, unsigned offset)
467{ 474{
468 struct stmp3xxx_pinmux_bank *pm = to_pinmux_bank(chip); 475 struct stmp3xxx_pinmux_bank *pm = to_pinmux_bank(chip);
469 476
470 __raw_writel(1 << offset, pm->hw_gpio_doe + HW_STMP3xxx_CLR); 477 stmp3xxx_clearl(1 << offset, pm->hw_gpio_doe);
471 return 0; 478 return 0;
472} 479}
473 480