aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/include
diff options
context:
space:
mode:
authorManuel Lauss <manuel.lauss@googlemail.com>2011-05-08 04:42:20 -0400
committerRalf Baechle <ralf@linux-mips.org>2011-05-19 04:55:46 -0400
commitb7f720d68c0042cc8ce496e31a61df79a77f1b48 (patch)
treef53474f89918485af4bb81cc1c188d5eff41e377 /arch/mips/include
parent5d4ddcb4279672e69136e746d6de6f01b501b853 (diff)
MIPS: Alchemy: Clean up GPIO registers and accessors
remove au_readl/au_writel, remove the predefined GPIO1/2 KSEG1 register addresses and fix the fallout in all boards and drivers. This also fixes a bug in the mtx-1_wdt driver which was introduced by commit 6ea8115bb6f359df4f45152f2b40e1d4d1891392 ("Convert mtx1 wdt to be a platform device and use generic GPIO API") before this patch mtx-1_wdt only modified GPIO215, the patch then used the gpio resource information as bit index into the GPIO2 register but the conversion to the GPIO API didn't realize that. With this patch the drivers original behaviour is restored and GPIO15 is left alone. Signed-off-by: Manuel Lauss <manuel.lauss@googlemail.com> Cc: Florian Fainelli <florian@openwrt.org> To: Linux-MIPS <linux-mips@linux-mips.org> Cc: linux-watchdog@vger.kernel.org Cc: Wim Van Sebroeck <wim@iguana.be> Patchwork: https://patchwork.linux-mips.org/patch/2381/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org
Diffstat (limited to 'arch/mips/include')
-rw-r--r--arch/mips/include/asm/mach-au1x00/au1000.h27
-rw-r--r--arch/mips/include/asm/mach-au1x00/gpio-au1000.h71
2 files changed, 51 insertions, 47 deletions
diff --git a/arch/mips/include/asm/mach-au1x00/au1000.h b/arch/mips/include/asm/mach-au1x00/au1000.h
index 2dfff4f2651..f260ebed713 100644
--- a/arch/mips/include/asm/mach-au1x00/au1000.h
+++ b/arch/mips/include/asm/mach-au1x00/au1000.h
@@ -702,7 +702,9 @@ enum soc_au1200_ints {
702#define AU1000_UART1_PHYS_ADDR 0x11200000 /* 0234 */ 702#define AU1000_UART1_PHYS_ADDR 0x11200000 /* 0234 */
703#define AU1000_UART2_PHYS_ADDR 0x11300000 /* 0 */ 703#define AU1000_UART2_PHYS_ADDR 0x11300000 /* 0 */
704#define AU1000_UART3_PHYS_ADDR 0x11400000 /* 0123 */ 704#define AU1000_UART3_PHYS_ADDR 0x11400000 /* 0123 */
705#define AU1500_GPIO2_PHYS_ADDR 0x11700000 /* 1234 */
705#define AU1000_IC1_PHYS_ADDR 0x11800000 /* 01234 */ 706#define AU1000_IC1_PHYS_ADDR 0x11800000 /* 01234 */
707#define AU1000_SYS_PHYS_ADDR 0x11900000 /* 01234 */
706#define AU1000_DMA_PHYS_ADDR 0x14002000 /* 012 */ 708#define AU1000_DMA_PHYS_ADDR 0x14002000 /* 012 */
707#define AU1550_DBDMA_PHYS_ADDR 0x14002000 /* 34 */ 709#define AU1550_DBDMA_PHYS_ADDR 0x14002000 /* 34 */
708#define AU1550_DBDMA_CONF_PHYS_ADDR 0x14003000 /* 34 */ 710#define AU1550_DBDMA_CONF_PHYS_ADDR 0x14003000 /* 34 */
@@ -717,7 +719,6 @@ enum soc_au1200_ints {
717#define IRDA_PHYS_ADDR 0x10300000 719#define IRDA_PHYS_ADDR 0x10300000
718#define SSI0_PHYS_ADDR 0x11600000 720#define SSI0_PHYS_ADDR 0x11600000
719#define SSI1_PHYS_ADDR 0x11680000 721#define SSI1_PHYS_ADDR 0x11680000
720#define SYS_PHYS_ADDR 0x11900000
721#define PCMCIA_IO_PHYS_ADDR 0xF00000000ULL 722#define PCMCIA_IO_PHYS_ADDR 0xF00000000ULL
722#define PCMCIA_ATTR_PHYS_ADDR 0xF40000000ULL 723#define PCMCIA_ATTR_PHYS_ADDR 0xF40000000ULL
723#define PCMCIA_MEM_PHYS_ADDR 0xF80000000ULL 724#define PCMCIA_MEM_PHYS_ADDR 0xF80000000ULL
@@ -730,8 +731,6 @@ enum soc_au1200_ints {
730#define STATIC_MEM_PHYS_ADDR 0x14001000 731#define STATIC_MEM_PHYS_ADDR 0x14001000
731#define USBH_PHYS_ADDR 0x10100000 732#define USBH_PHYS_ADDR 0x10100000
732#define PCI_PHYS_ADDR 0x14005000 733#define PCI_PHYS_ADDR 0x14005000
733#define GPIO2_PHYS_ADDR 0x11700000
734#define SYS_PHYS_ADDR 0x11900000
735#define PCI_MEM_PHYS_ADDR 0x400000000ULL 734#define PCI_MEM_PHYS_ADDR 0x400000000ULL
736#define PCI_IO_PHYS_ADDR 0x500000000ULL 735#define PCI_IO_PHYS_ADDR 0x500000000ULL
737#define PCI_CONFIG0_PHYS_ADDR 0x600000000ULL 736#define PCI_CONFIG0_PHYS_ADDR 0x600000000ULL
@@ -750,8 +749,6 @@ enum soc_au1200_ints {
750#define IRDA_PHYS_ADDR 0x10300000 749#define IRDA_PHYS_ADDR 0x10300000
751#define SSI0_PHYS_ADDR 0x11600000 750#define SSI0_PHYS_ADDR 0x11600000
752#define SSI1_PHYS_ADDR 0x11680000 751#define SSI1_PHYS_ADDR 0x11680000
753#define GPIO2_PHYS_ADDR 0x11700000
754#define SYS_PHYS_ADDR 0x11900000
755#define LCD_PHYS_ADDR 0x15000000 752#define LCD_PHYS_ADDR 0x15000000
756#define PCMCIA_IO_PHYS_ADDR 0xF00000000ULL 753#define PCMCIA_IO_PHYS_ADDR 0xF00000000ULL
757#define PCMCIA_ATTR_PHYS_ADDR 0xF40000000ULL 754#define PCMCIA_ATTR_PHYS_ADDR 0xF40000000ULL
@@ -765,8 +762,6 @@ enum soc_au1200_ints {
765#define STATIC_MEM_PHYS_ADDR 0x14001000 762#define STATIC_MEM_PHYS_ADDR 0x14001000
766#define USBH_PHYS_ADDR 0x14020000 763#define USBH_PHYS_ADDR 0x14020000
767#define PCI_PHYS_ADDR 0x14005000 764#define PCI_PHYS_ADDR 0x14005000
768#define GPIO2_PHYS_ADDR 0x11700000
769#define SYS_PHYS_ADDR 0x11900000
770#define PE_PHYS_ADDR 0x14008000 765#define PE_PHYS_ADDR 0x14008000
771#define PSC0_PHYS_ADDR 0x11A00000 766#define PSC0_PHYS_ADDR 0x11A00000
772#define PSC1_PHYS_ADDR 0x11B00000 767#define PSC1_PHYS_ADDR 0x11B00000
@@ -790,8 +785,6 @@ enum soc_au1200_ints {
790#define CIM_PHYS_ADDR 0x14004000 785#define CIM_PHYS_ADDR 0x14004000
791#define USBM_PHYS_ADDR 0x14020000 786#define USBM_PHYS_ADDR 0x14020000
792#define USBH_PHYS_ADDR 0x14020100 787#define USBH_PHYS_ADDR 0x14020100
793#define GPIO2_PHYS_ADDR 0x11700000
794#define SYS_PHYS_ADDR 0x11900000
795#define PSC0_PHYS_ADDR 0x11A00000 788#define PSC0_PHYS_ADDR 0x11A00000
796#define PSC1_PHYS_ADDR 0x11B00000 789#define PSC1_PHYS_ADDR 0x11B00000
797#define LCD_PHYS_ADDR 0x15000000 790#define LCD_PHYS_ADDR 0x15000000
@@ -1359,22 +1352,6 @@ enum soc_au1200_ints {
1359#define SYS_PINFUNC_S1B (1 << 2) 1352#define SYS_PINFUNC_S1B (1 << 2)
1360#endif 1353#endif
1361 1354
1362#define SYS_TRIOUTRD 0xB1900100
1363#define SYS_TRIOUTCLR 0xB1900100
1364#define SYS_OUTPUTRD 0xB1900108
1365#define SYS_OUTPUTSET 0xB1900108
1366#define SYS_OUTPUTCLR 0xB190010C
1367#define SYS_PINSTATERD 0xB1900110
1368#define SYS_PININPUTEN 0xB1900110
1369
1370/* GPIO2, Au1500, Au1550 only */
1371#define GPIO2_BASE 0xB1700000
1372#define GPIO2_DIR (GPIO2_BASE + 0)
1373#define GPIO2_OUTPUT (GPIO2_BASE + 8)
1374#define GPIO2_PINSTATE (GPIO2_BASE + 0xC)
1375#define GPIO2_INTENABLE (GPIO2_BASE + 0x10)
1376#define GPIO2_ENABLE (GPIO2_BASE + 0x14)
1377
1378/* Power Management */ 1355/* Power Management */
1379#define SYS_SCRATCH0 0xB1900018 1356#define SYS_SCRATCH0 0xB1900018
1380#define SYS_SCRATCH1 0xB190001C 1357#define SYS_SCRATCH1 0xB190001C
diff --git a/arch/mips/include/asm/mach-au1x00/gpio-au1000.h b/arch/mips/include/asm/mach-au1x00/gpio-au1000.h
index 8f8c1c55593..1f41a522906 100644
--- a/arch/mips/include/asm/mach-au1x00/gpio-au1000.h
+++ b/arch/mips/include/asm/mach-au1x00/gpio-au1000.h
@@ -24,6 +24,22 @@
24 24
25#define MAKE_IRQ(intc, off) (AU1000_INTC##intc##_INT_BASE + (off)) 25#define MAKE_IRQ(intc, off) (AU1000_INTC##intc##_INT_BASE + (off))
26 26
27/* GPIO1 registers within SYS_ area */
28#define SYS_TRIOUTRD 0x100
29#define SYS_TRIOUTCLR 0x100
30#define SYS_OUTPUTRD 0x108
31#define SYS_OUTPUTSET 0x108
32#define SYS_OUTPUTCLR 0x10C
33#define SYS_PINSTATERD 0x110
34#define SYS_PININPUTEN 0x110
35
36/* register offsets within GPIO2 block */
37#define GPIO2_DIR 0x00
38#define GPIO2_OUTPUT 0x08
39#define GPIO2_PINSTATE 0x0C
40#define GPIO2_INTENABLE 0x10
41#define GPIO2_ENABLE 0x14
42
27struct gpio; 43struct gpio;
28 44
29static inline int au1000_gpio1_to_irq(int gpio) 45static inline int au1000_gpio1_to_irq(int gpio)
@@ -201,23 +217,26 @@ static inline int au1200_irq_to_gpio(int irq)
201 */ 217 */
202static inline void alchemy_gpio1_set_value(int gpio, int v) 218static inline void alchemy_gpio1_set_value(int gpio, int v)
203{ 219{
220 void __iomem *base = (void __iomem *)KSEG1ADDR(AU1000_SYS_PHYS_ADDR);
204 unsigned long mask = 1 << (gpio - ALCHEMY_GPIO1_BASE); 221 unsigned long mask = 1 << (gpio - ALCHEMY_GPIO1_BASE);
205 unsigned long r = v ? SYS_OUTPUTSET : SYS_OUTPUTCLR; 222 unsigned long r = v ? SYS_OUTPUTSET : SYS_OUTPUTCLR;
206 au_writel(mask, r); 223 __raw_writel(mask, base + r);
207 au_sync(); 224 wmb();
208} 225}
209 226
210static inline int alchemy_gpio1_get_value(int gpio) 227static inline int alchemy_gpio1_get_value(int gpio)
211{ 228{
229 void __iomem *base = (void __iomem *)KSEG1ADDR(AU1000_SYS_PHYS_ADDR);
212 unsigned long mask = 1 << (gpio - ALCHEMY_GPIO1_BASE); 230 unsigned long mask = 1 << (gpio - ALCHEMY_GPIO1_BASE);
213 return au_readl(SYS_PINSTATERD) & mask; 231 return __raw_readl(base + SYS_PINSTATERD) & mask;
214} 232}
215 233
216static inline int alchemy_gpio1_direction_input(int gpio) 234static inline int alchemy_gpio1_direction_input(int gpio)
217{ 235{
236 void __iomem *base = (void __iomem *)KSEG1ADDR(AU1000_SYS_PHYS_ADDR);
218 unsigned long mask = 1 << (gpio - ALCHEMY_GPIO1_BASE); 237 unsigned long mask = 1 << (gpio - ALCHEMY_GPIO1_BASE);
219 au_writel(mask, SYS_TRIOUTCLR); 238 __raw_writel(mask, base + SYS_TRIOUTCLR);
220 au_sync(); 239 wmb();
221 return 0; 240 return 0;
222} 241}
223 242
@@ -258,27 +277,31 @@ static inline int alchemy_gpio1_to_irq(int gpio)
258 */ 277 */
259static inline void __alchemy_gpio2_mod_dir(int gpio, int to_out) 278static inline void __alchemy_gpio2_mod_dir(int gpio, int to_out)
260{ 279{
280 void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR);
261 unsigned long mask = 1 << (gpio - ALCHEMY_GPIO2_BASE); 281 unsigned long mask = 1 << (gpio - ALCHEMY_GPIO2_BASE);
262 unsigned long d = au_readl(GPIO2_DIR); 282 unsigned long d = __raw_readl(base + GPIO2_DIR);
283
263 if (to_out) 284 if (to_out)
264 d |= mask; 285 d |= mask;
265 else 286 else
266 d &= ~mask; 287 d &= ~mask;
267 au_writel(d, GPIO2_DIR); 288 __raw_writel(d, base + GPIO2_DIR);
268 au_sync(); 289 wmb();
269} 290}
270 291
271static inline void alchemy_gpio2_set_value(int gpio, int v) 292static inline void alchemy_gpio2_set_value(int gpio, int v)
272{ 293{
294 void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR);
273 unsigned long mask; 295 unsigned long mask;
274 mask = ((v) ? 0x00010001 : 0x00010000) << (gpio - ALCHEMY_GPIO2_BASE); 296 mask = ((v) ? 0x00010001 : 0x00010000) << (gpio - ALCHEMY_GPIO2_BASE);
275 au_writel(mask, GPIO2_OUTPUT); 297 __raw_writel(mask, base + GPIO2_OUTPUT);
276 au_sync(); 298 wmb();
277} 299}
278 300
279static inline int alchemy_gpio2_get_value(int gpio) 301static inline int alchemy_gpio2_get_value(int gpio)
280{ 302{
281 return au_readl(GPIO2_PINSTATE) & (1 << (gpio - ALCHEMY_GPIO2_BASE)); 303 void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR);
304 return __raw_readl(base + GPIO2_PINSTATE) & (1 << (gpio - ALCHEMY_GPIO2_BASE));
282} 305}
283 306
284static inline int alchemy_gpio2_direction_input(int gpio) 307static inline int alchemy_gpio2_direction_input(int gpio)
@@ -330,21 +353,23 @@ static inline int alchemy_gpio2_to_irq(int gpio)
330 */ 353 */
331static inline void alchemy_gpio1_input_enable(void) 354static inline void alchemy_gpio1_input_enable(void)
332{ 355{
333 au_writel(0, SYS_PININPUTEN); /* the write op is key */ 356 void __iomem *base = (void __iomem *)KSEG1ADDR(AU1000_SYS_PHYS_ADDR);
334 au_sync(); 357 __raw_writel(0, base + SYS_PININPUTEN); /* the write op is key */
358 wmb();
335} 359}
336 360
337/* GPIO2 shared interrupts and control */ 361/* GPIO2 shared interrupts and control */
338 362
339static inline void __alchemy_gpio2_mod_int(int gpio2, int en) 363static inline void __alchemy_gpio2_mod_int(int gpio2, int en)
340{ 364{
341 unsigned long r = au_readl(GPIO2_INTENABLE); 365 void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR);
366 unsigned long r = __raw_readl(base + GPIO2_INTENABLE);
342 if (en) 367 if (en)
343 r |= 1 << gpio2; 368 r |= 1 << gpio2;
344 else 369 else
345 r &= ~(1 << gpio2); 370 r &= ~(1 << gpio2);
346 au_writel(r, GPIO2_INTENABLE); 371 __raw_writel(r, base + GPIO2_INTENABLE);
347 au_sync(); 372 wmb();
348} 373}
349 374
350/** 375/**
@@ -419,10 +444,11 @@ static inline void alchemy_gpio2_disable_int(int gpio2)
419 */ 444 */
420static inline void alchemy_gpio2_enable(void) 445static inline void alchemy_gpio2_enable(void)
421{ 446{
422 au_writel(3, GPIO2_ENABLE); /* reset, clock enabled */ 447 void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR);
423 au_sync(); 448 __raw_writel(3, base + GPIO2_ENABLE); /* reset, clock enabled */
424 au_writel(1, GPIO2_ENABLE); /* clock enabled */ 449 wmb();
425 au_sync(); 450 __raw_writel(1, base + GPIO2_ENABLE); /* clock enabled */
451 wmb();
426} 452}
427 453
428/** 454/**
@@ -432,8 +458,9 @@ static inline void alchemy_gpio2_enable(void)
432 */ 458 */
433static inline void alchemy_gpio2_disable(void) 459static inline void alchemy_gpio2_disable(void)
434{ 460{
435 au_writel(2, GPIO2_ENABLE); /* reset, clock disabled */ 461 void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR);
436 au_sync(); 462 __raw_writel(2, base + GPIO2_ENABLE); /* reset, clock disabled */
463 wmb();
437} 464}
438 465
439/**********************************************************************/ 466/**********************************************************************/