aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Lauss <manuel.lauss@gmail.com>2014-07-23 10:36:24 -0400
committerRalf Baechle <ralf@linux-mips.org>2014-07-30 07:53:28 -0400
commit1d09de7dc76ef96a9a2c7c0244e20f12d68e6ef8 (patch)
tree929cb54b63224fc65d7b56d52b00a89bb236b9a0
parent2ef1bb99116e49226e8bab8ebab255f12fa8a99e (diff)
MIPS: Alchemy: introduce helpers to access SYS register block.
This patch changes all absolute SYS_XY registers to offsets from the SYS block base, prefixes them with AU1000 to avoid silent failures due to changed addresses, and introduces helper functions to read/write them. No functional changes, comparing assembly of a few select functions shows no differences. Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com> Cc: Linux-MIPS <linux-mips@linux-mips.org> Patchwork: https://patchwork.linux-mips.org/patch/7464/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r--arch/mips/alchemy/board-mtx1.c4
-rw-r--r--arch/mips/alchemy/board-xxs1500.c4
-rw-r--r--arch/mips/alchemy/common/clocks.c6
-rw-r--r--arch/mips/alchemy/common/irq.c5
-rw-r--r--arch/mips/alchemy/common/platform.c2
-rw-r--r--arch/mips/alchemy/common/power.c26
-rw-r--r--arch/mips/alchemy/common/time.c23
-rw-r--r--arch/mips/alchemy/devboards/db1000.c5
-rw-r--r--arch/mips/alchemy/devboards/db1200.c19
-rw-r--r--arch/mips/alchemy/devboards/db1550.c10
-rw-r--r--arch/mips/alchemy/devboards/pm.c39
-rw-r--r--arch/mips/include/asm/mach-au1x00/au1000.h75
-rw-r--r--arch/mips/include/asm/mach-au1x00/gpio-au1000.h56
-rw-r--r--drivers/mmc/host/au1xmmc.c2
-rw-r--r--drivers/rtc/rtc-au1xxx.c18
-rw-r--r--drivers/video/fbdev/au1100fb.c11
-rw-r--r--drivers/video/fbdev/au1200fb.c6
17 files changed, 152 insertions, 159 deletions
diff --git a/arch/mips/alchemy/board-mtx1.c b/arch/mips/alchemy/board-mtx1.c
index 25a59a23547e..1e3b102389ef 100644
--- a/arch/mips/alchemy/board-mtx1.c
+++ b/arch/mips/alchemy/board-mtx1.c
@@ -85,10 +85,10 @@ void __init board_setup(void)
85#endif /* IS_ENABLED(CONFIG_USB_OHCI_HCD) */ 85#endif /* IS_ENABLED(CONFIG_USB_OHCI_HCD) */
86 86
87 /* Initialize sys_pinfunc */ 87 /* Initialize sys_pinfunc */
88 au_writel(SYS_PF_NI2, SYS_PINFUNC); 88 alchemy_wrsys(SYS_PF_NI2, AU1000_SYS_PINFUNC);
89 89
90 /* Initialize GPIO */ 90 /* Initialize GPIO */
91 au_writel(~0, KSEG1ADDR(AU1000_SYS_PHYS_ADDR) + SYS_TRIOUTCLR); 91 alchemy_wrsys(~0, AU1000_SYS_TRIOUTCLR);
92 alchemy_gpio_direction_output(0, 0); /* Disable M66EN (PCI 66MHz) */ 92 alchemy_gpio_direction_output(0, 0); /* Disable M66EN (PCI 66MHz) */
93 alchemy_gpio_direction_output(3, 1); /* Disable PCI CLKRUN# */ 93 alchemy_gpio_direction_output(3, 1); /* Disable PCI CLKRUN# */
94 alchemy_gpio_direction_output(1, 1); /* Enable EXT_IO3 */ 94 alchemy_gpio_direction_output(1, 1); /* Enable EXT_IO3 */
diff --git a/arch/mips/alchemy/board-xxs1500.c b/arch/mips/alchemy/board-xxs1500.c
index 3fb814be0e91..0fc53e08a894 100644
--- a/arch/mips/alchemy/board-xxs1500.c
+++ b/arch/mips/alchemy/board-xxs1500.c
@@ -87,9 +87,9 @@ void __init board_setup(void)
87 alchemy_gpio2_enable(); 87 alchemy_gpio2_enable();
88 88
89 /* Set multiple use pins (UART3/GPIO) to UART (it's used as UART too) */ 89 /* Set multiple use pins (UART3/GPIO) to UART (it's used as UART too) */
90 pin_func = au_readl(SYS_PINFUNC) & ~SYS_PF_UR3; 90 pin_func = alchemy_rdsys(AU1000_SYS_PINFUNC) & ~SYS_PF_UR3;
91 pin_func |= SYS_PF_UR3; 91 pin_func |= SYS_PF_UR3;
92 au_writel(pin_func, SYS_PINFUNC); 92 alchemy_wrsys(pin_func, AU1000_SYS_PINFUNC);
93 93
94 /* Enable UART */ 94 /* Enable UART */
95 alchemy_uart_enable(AU1000_UART3_PHYS_ADDR); 95 alchemy_uart_enable(AU1000_UART3_PHYS_ADDR);
diff --git a/arch/mips/alchemy/common/clocks.c b/arch/mips/alchemy/common/clocks.c
index f38298a8b98c..0e41416fa682 100644
--- a/arch/mips/alchemy/common/clocks.c
+++ b/arch/mips/alchemy/common/clocks.c
@@ -91,13 +91,13 @@ unsigned long au1xxx_calc_clock(void)
91 if (au1xxx_cpu_has_pll_wo()) 91 if (au1xxx_cpu_has_pll_wo())
92 cpu_speed = 396000000; 92 cpu_speed = 396000000;
93 else 93 else
94 cpu_speed = (au_readl(SYS_CPUPLL) & 0x0000003f) * AU1000_SRC_CLK; 94 cpu_speed = (alchemy_rdsys(AU1000_SYS_CPUPLL) & 0x3f) * AU1000_SRC_CLK;
95 95
96 /* On Alchemy CPU:counter ratio is 1:1 */ 96 /* On Alchemy CPU:counter ratio is 1:1 */
97 mips_hpt_frequency = cpu_speed; 97 mips_hpt_frequency = cpu_speed;
98 /* Equation: Baudrate = CPU / (SD * 2 * CLKDIV * 16) */ 98 /* Equation: Baudrate = CPU / (SD * 2 * CLKDIV * 16) */
99 set_au1x00_uart_baud_base(cpu_speed / (2 * ((int)(au_readl(SYS_POWERCTRL) 99 set_au1x00_uart_baud_base(cpu_speed / (2 *
100 & 0x03) + 2) * 16)); 100 ((alchemy_rdsys(AU1000_SYS_POWERCTRL) & 0x03) + 2) * 16));
101 101
102 set_au1x00_speed(cpu_speed); 102 set_au1x00_speed(cpu_speed);
103 103
diff --git a/arch/mips/alchemy/common/irq.c b/arch/mips/alchemy/common/irq.c
index 63a71817a00c..6cb60abfdcc9 100644
--- a/arch/mips/alchemy/common/irq.c
+++ b/arch/mips/alchemy/common/irq.c
@@ -389,13 +389,12 @@ static int au1x_ic1_setwake(struct irq_data *d, unsigned int on)
389 return -EINVAL; 389 return -EINVAL;
390 390
391 local_irq_save(flags); 391 local_irq_save(flags);
392 wakemsk = __raw_readl((void __iomem *)SYS_WAKEMSK); 392 wakemsk = alchemy_rdsys(AU1000_SYS_WAKEMSK);
393 if (on) 393 if (on)
394 wakemsk |= 1 << bit; 394 wakemsk |= 1 << bit;
395 else 395 else
396 wakemsk &= ~(1 << bit); 396 wakemsk &= ~(1 << bit);
397 __raw_writel(wakemsk, (void __iomem *)SYS_WAKEMSK); 397 alchemy_wrsys(wakemsk, AU1000_SYS_WAKEMSK);
398 wmb();
399 local_irq_restore(flags); 398 local_irq_restore(flags);
400 399
401 return 0; 400 return 0;
diff --git a/arch/mips/alchemy/common/platform.c b/arch/mips/alchemy/common/platform.c
index 9837a134a6d6..fb89d213523b 100644
--- a/arch/mips/alchemy/common/platform.c
+++ b/arch/mips/alchemy/common/platform.c
@@ -420,7 +420,7 @@ static void __init alchemy_setup_macs(int ctype)
420 memcpy(au1xxx_eth1_platform_data.mac, ethaddr, 6); 420 memcpy(au1xxx_eth1_platform_data.mac, ethaddr, 6);
421 421
422 /* Register second MAC if enabled in pinfunc */ 422 /* Register second MAC if enabled in pinfunc */
423 if (!(au_readl(SYS_PINFUNC) & (u32)SYS_PF_NI2)) { 423 if (!(alchemy_rdsys(AU1000_SYS_PINFUNC) & SYS_PF_NI2)) {
424 ret = platform_device_register(&au1xxx_eth1_device); 424 ret = platform_device_register(&au1xxx_eth1_device);
425 if (ret) 425 if (ret)
426 printk(KERN_INFO "Alchemy: failed to register MAC1\n"); 426 printk(KERN_INFO "Alchemy: failed to register MAC1\n");
diff --git a/arch/mips/alchemy/common/power.c b/arch/mips/alchemy/common/power.c
index bdb28dee8fdd..2d3831b02091 100644
--- a/arch/mips/alchemy/common/power.c
+++ b/arch/mips/alchemy/common/power.c
@@ -54,14 +54,14 @@ static unsigned int sleep_static_memctlr[4][3];
54static void save_core_regs(void) 54static void save_core_regs(void)
55{ 55{
56 /* Clocks and PLLs. */ 56 /* Clocks and PLLs. */
57 sleep_sys_clocks[0] = au_readl(SYS_FREQCTRL0); 57 sleep_sys_clocks[0] = alchemy_rdsys(AU1000_SYS_FREQCTRL0);
58 sleep_sys_clocks[1] = au_readl(SYS_FREQCTRL1); 58 sleep_sys_clocks[1] = alchemy_rdsys(AU1000_SYS_FREQCTRL1);
59 sleep_sys_clocks[2] = au_readl(SYS_CLKSRC); 59 sleep_sys_clocks[2] = alchemy_rdsys(AU1000_SYS_CLKSRC);
60 sleep_sys_clocks[3] = au_readl(SYS_CPUPLL); 60 sleep_sys_clocks[3] = alchemy_rdsys(AU1000_SYS_CPUPLL);
61 sleep_sys_clocks[4] = au_readl(SYS_AUXPLL); 61 sleep_sys_clocks[4] = alchemy_rdsys(AU1000_SYS_AUXPLL);
62 62
63 /* pin mux config */ 63 /* pin mux config */
64 sleep_sys_pinfunc = au_readl(SYS_PINFUNC); 64 sleep_sys_pinfunc = alchemy_rdsys(AU1000_SYS_PINFUNC);
65 65
66 /* Save the static memory controller configuration. */ 66 /* Save the static memory controller configuration. */
67 sleep_static_memctlr[0][0] = au_readl(MEM_STCFG0); 67 sleep_static_memctlr[0][0] = au_readl(MEM_STCFG0);
@@ -85,16 +85,14 @@ static void restore_core_regs(void)
85 * one of those Au1000 with a write-only PLL, where we dont 85 * one of those Au1000 with a write-only PLL, where we dont
86 * have a valid value) 86 * have a valid value)
87 */ 87 */
88 au_writel(sleep_sys_clocks[0], SYS_FREQCTRL0); 88 alchemy_wrsys(sleep_sys_clocks[0], AU1000_SYS_FREQCTRL0);
89 au_writel(sleep_sys_clocks[1], SYS_FREQCTRL1); 89 alchemy_wrsys(sleep_sys_clocks[1], AU1000_SYS_FREQCTRL1);
90 au_writel(sleep_sys_clocks[2], SYS_CLKSRC); 90 alchemy_wrsys(sleep_sys_clocks[2], AU1000_SYS_CLKSRC);
91 au_writel(sleep_sys_clocks[4], SYS_AUXPLL); 91 alchemy_wrsys(sleep_sys_clocks[4], AU1000_SYS_AUXPLL);
92 if (!au1xxx_cpu_has_pll_wo()) 92 if (!au1xxx_cpu_has_pll_wo())
93 au_writel(sleep_sys_clocks[3], SYS_CPUPLL); 93 alchemy_wrsys(sleep_sys_clocks[3], AU1000_SYS_CPUPLL);
94 au_sync();
95 94
96 au_writel(sleep_sys_pinfunc, SYS_PINFUNC); 95 alchemy_wrsys(sleep_sys_pinfunc, AU1000_SYS_PINFUNC);
97 au_sync();
98 96
99 /* Restore the static memory controller configuration. */ 97 /* Restore the static memory controller configuration. */
100 au_writel(sleep_static_memctlr[0][0], MEM_STCFG0); 98 au_writel(sleep_static_memctlr[0][0], MEM_STCFG0);
diff --git a/arch/mips/alchemy/common/time.c b/arch/mips/alchemy/common/time.c
index 93fa586d52e2..50e17e13c18b 100644
--- a/arch/mips/alchemy/common/time.c
+++ b/arch/mips/alchemy/common/time.c
@@ -46,7 +46,7 @@
46 46
47static cycle_t au1x_counter1_read(struct clocksource *cs) 47static cycle_t au1x_counter1_read(struct clocksource *cs)
48{ 48{
49 return au_readl(SYS_RTCREAD); 49 return alchemy_rdsys(AU1000_SYS_RTCREAD);
50} 50}
51 51
52static struct clocksource au1x_counter1_clocksource = { 52static struct clocksource au1x_counter1_clocksource = {
@@ -60,12 +60,11 @@ static struct clocksource au1x_counter1_clocksource = {
60static int au1x_rtcmatch2_set_next_event(unsigned long delta, 60static int au1x_rtcmatch2_set_next_event(unsigned long delta,
61 struct clock_event_device *cd) 61 struct clock_event_device *cd)
62{ 62{
63 delta += au_readl(SYS_RTCREAD); 63 delta += alchemy_rdsys(AU1000_SYS_RTCREAD);
64 /* wait for register access */ 64 /* wait for register access */
65 while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_M21) 65 while (alchemy_rdsys(AU1000_SYS_CNTRCTRL) & SYS_CNTRL_M21)
66 ; 66 ;
67 au_writel(delta, SYS_RTCMATCH2); 67 alchemy_wrsys(delta, AU1000_SYS_RTCMATCH2);
68 au_sync();
69 68
70 return 0; 69 return 0;
71} 70}
@@ -112,31 +111,29 @@ static int __init alchemy_time_init(unsigned int m2int)
112 * (the 32S bit seems to be stuck set to 1 once a single clock- 111 * (the 32S bit seems to be stuck set to 1 once a single clock-
113 * edge is detected, hence the timeouts). 112 * edge is detected, hence the timeouts).
114 */ 113 */
115 if (CNTR_OK != (au_readl(SYS_COUNTER_CNTRL) & CNTR_OK)) 114 if (CNTR_OK != (alchemy_rdsys(AU1000_SYS_CNTRCTRL) & CNTR_OK))
116 goto cntr_err; 115 goto cntr_err;
117 116
118 /* 117 /*
119 * setup counter 1 (RTC) to tick at full speed 118 * setup counter 1 (RTC) to tick at full speed
120 */ 119 */
121 t = 0xffffff; 120 t = 0xffffff;
122 while ((au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_T1S) && --t) 121 while ((alchemy_rdsys(AU1000_SYS_CNTRCTRL) & SYS_CNTRL_T1S) && --t)
123 asm volatile ("nop"); 122 asm volatile ("nop");
124 if (!t) 123 if (!t)
125 goto cntr_err; 124 goto cntr_err;
126 125
127 au_writel(0, SYS_RTCTRIM); /* 32.768 kHz */ 126 alchemy_wrsys(0, AU1000_SYS_RTCTRIM); /* 32.768 kHz */
128 au_sync();
129 127
130 t = 0xffffff; 128 t = 0xffffff;
131 while ((au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C1S) && --t) 129 while ((alchemy_rdsys(AU1000_SYS_CNTRCTRL) & SYS_CNTRL_C1S) && --t)
132 asm volatile ("nop"); 130 asm volatile ("nop");
133 if (!t) 131 if (!t)
134 goto cntr_err; 132 goto cntr_err;
135 au_writel(0, SYS_RTCWRITE); 133 alchemy_wrsys(0, AU1000_SYS_RTCWRITE);
136 au_sync();
137 134
138 t = 0xffffff; 135 t = 0xffffff;
139 while ((au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C1S) && --t) 136 while ((alchemy_rdsys(AU1000_SYS_CNTRCTRL) & SYS_CNTRL_C1S) && --t)
140 asm volatile ("nop"); 137 asm volatile ("nop");
141 if (!t) 138 if (!t)
142 goto cntr_err; 139 goto cntr_err;
diff --git a/arch/mips/alchemy/devboards/db1000.c b/arch/mips/alchemy/devboards/db1000.c
index 92dd929d4057..8201f00d575b 100644
--- a/arch/mips/alchemy/devboards/db1000.c
+++ b/arch/mips/alchemy/devboards/db1000.c
@@ -518,10 +518,9 @@ int __init db1000_dev_setup(void)
518 gpio_direction_input(20); /* sd1 cd# */ 518 gpio_direction_input(20); /* sd1 cd# */
519 519
520 /* spi_gpio on SSI0 pins */ 520 /* spi_gpio on SSI0 pins */
521 pfc = __raw_readl((void __iomem *)SYS_PINFUNC); 521 pfc = alchemy_rdsys(AU1000_SYS_PINFUNC);
522 pfc |= (1 << 0); /* SSI0 pins as GPIOs */ 522 pfc |= (1 << 0); /* SSI0 pins as GPIOs */
523 __raw_writel(pfc, (void __iomem *)SYS_PINFUNC); 523 alchemy_wrsys(pfc, AU1000_SYS_PINFUNC);
524 wmb();
525 524
526 spi_register_board_info(db1100_spi_info, 525 spi_register_board_info(db1100_spi_info,
527 ARRAY_SIZE(db1100_spi_info)); 526 ARRAY_SIZE(db1100_spi_info));
diff --git a/arch/mips/alchemy/devboards/db1200.c b/arch/mips/alchemy/devboards/db1200.c
index 9e46667f2597..408c36f37699 100644
--- a/arch/mips/alchemy/devboards/db1200.c
+++ b/arch/mips/alchemy/devboards/db1200.c
@@ -150,12 +150,11 @@ int __init db1200_board_setup(void)
150 (whoami >> 4) & 0xf, (whoami >> 8) & 0xf, whoami & 0xf); 150 (whoami >> 4) & 0xf, (whoami >> 8) & 0xf, whoami & 0xf);
151 151
152 /* SMBus/SPI on PSC0, Audio on PSC1 */ 152 /* SMBus/SPI on PSC0, Audio on PSC1 */
153 pfc = __raw_readl((void __iomem *)SYS_PINFUNC); 153 pfc = alchemy_rdsys(AU1000_SYS_PINFUNC);
154 pfc &= ~(SYS_PINFUNC_P0A | SYS_PINFUNC_P0B); 154 pfc &= ~(SYS_PINFUNC_P0A | SYS_PINFUNC_P0B);
155 pfc &= ~(SYS_PINFUNC_P1A | SYS_PINFUNC_P1B | SYS_PINFUNC_FS3); 155 pfc &= ~(SYS_PINFUNC_P1A | SYS_PINFUNC_P1B | SYS_PINFUNC_FS3);
156 pfc |= SYS_PINFUNC_P1C; /* SPI is configured later */ 156 pfc |= SYS_PINFUNC_P1C; /* SPI is configured later */
157 __raw_writel(pfc, (void __iomem *)SYS_PINFUNC); 157 alchemy_wrsys(pfc, AU1000_SYS_PINFUNC);
158 wmb();
159 158
160 /* Clock configurations: PSC0: ~50MHz via Clkgen0, derived from 159 /* Clock configurations: PSC0: ~50MHz via Clkgen0, derived from
161 * CPU clock; all other clock generators off/unused. 160 * CPU clock; all other clock generators off/unused.
@@ -166,16 +165,13 @@ int __init db1200_board_setup(void)
166 div = ((div >> 1) - 1) & 0xff; 165 div = ((div >> 1) - 1) & 0xff;
167 166
168 freq0 = div << SYS_FC_FRDIV0_BIT; 167 freq0 = div << SYS_FC_FRDIV0_BIT;
169 __raw_writel(freq0, (void __iomem *)SYS_FREQCTRL0); 168 alchemy_wrsys(freq0, AU1000_SYS_FREQCTRL0);
170 wmb();
171 freq0 |= SYS_FC_FE0; /* enable F0 */ 169 freq0 |= SYS_FC_FE0; /* enable F0 */
172 __raw_writel(freq0, (void __iomem *)SYS_FREQCTRL0); 170 alchemy_wrsys(freq0, AU1000_SYS_FREQCTRL0);
173 wmb();
174 171
175 /* psc0_intclk comes 1:1 from F0 */ 172 /* psc0_intclk comes 1:1 from F0 */
176 clksrc = SYS_CS_MUX_FQ0 << SYS_CS_ME0_BIT; 173 clksrc = SYS_CS_MUX_FQ0 << SYS_CS_ME0_BIT;
177 __raw_writel(clksrc, (void __iomem *)SYS_CLKSRC); 174 alchemy_wrsys(clksrc, AU1000_SYS_CLKSRC);
178 wmb();
179 175
180 return 0; 176 return 0;
181} 177}
@@ -886,7 +882,7 @@ int __init db1200_dev_setup(void)
886 * As a result, in SPI mode, OTG simply won't work (PSC0 uses 882 * As a result, in SPI mode, OTG simply won't work (PSC0 uses
887 * it as an input pin which is pulled high on the boards). 883 * it as an input pin which is pulled high on the boards).
888 */ 884 */
889 pfc = __raw_readl((void __iomem *)SYS_PINFUNC) & ~SYS_PINFUNC_P0A; 885 pfc = alchemy_rdsys(AU1000_SYS_PINFUNC) & ~SYS_PINFUNC_P0A;
890 886
891 /* switch off OTG VBUS supply */ 887 /* switch off OTG VBUS supply */
892 gpio_request(215, "otg-vbus"); 888 gpio_request(215, "otg-vbus");
@@ -912,8 +908,7 @@ int __init db1200_dev_setup(void)
912 printk(KERN_INFO " S6.8 ON : PSC0 mode SPI\n"); 908 printk(KERN_INFO " S6.8 ON : PSC0 mode SPI\n");
913 printk(KERN_INFO " OTG port VBUS supply disabled\n"); 909 printk(KERN_INFO " OTG port VBUS supply disabled\n");
914 } 910 }
915 __raw_writel(pfc, (void __iomem *)SYS_PINFUNC); 911 alchemy_wrsys(pfc, AU1000_SYS_PINFUNC);
916 wmb();
917 912
918 /* Audio: DIP7 selects I2S(0)/AC97(1), but need I2C for I2S! 913 /* Audio: DIP7 selects I2S(0)/AC97(1), but need I2C for I2S!
919 * so: DIP7=1 || DIP8=0 => AC97, DIP7=0 && DIP8=1 => I2S 914 * so: DIP7=1 || DIP8=0 => AC97, DIP7=0 && DIP8=1 => I2S
diff --git a/arch/mips/alchemy/devboards/db1550.c b/arch/mips/alchemy/devboards/db1550.c
index bbd8d9884702..392fb89270d6 100644
--- a/arch/mips/alchemy/devboards/db1550.c
+++ b/arch/mips/alchemy/devboards/db1550.c
@@ -31,16 +31,16 @@
31static void __init db1550_hw_setup(void) 31static void __init db1550_hw_setup(void)
32{ 32{
33 void __iomem *base; 33 void __iomem *base;
34 unsigned long v;
34 35
35 /* complete SPI setup: link psc0_intclk to a 48MHz source, 36 /* complete SPI setup: link psc0_intclk to a 48MHz source,
36 * and assign GPIO16 to PSC0_SYNC1 (SPI cs# line) as well as PSC1_SYNC 37 * and assign GPIO16 to PSC0_SYNC1 (SPI cs# line) as well as PSC1_SYNC
37 * for AC97 on PB1550. 38 * for AC97 on PB1550.
38 */ 39 */
39 base = (void __iomem *)SYS_CLKSRC; 40 v = alchemy_rdsys(AU1000_SYS_CLKSRC);
40 __raw_writel(__raw_readl(base) | 0x000001e0, base); 41 alchemy_wrsys(v | 0x000001e0, AU1000_SYS_CLKSRC);
41 base = (void __iomem *)SYS_PINFUNC; 42 v = alchemy_rdsys(AU1000_SYS_PINFUNC);
42 __raw_writel(__raw_readl(base) | 1 | SYS_PF_PSC1_S1, base); 43 alchemy_wrsys(v | 1 | SYS_PF_PSC1_S1, AU1000_SYS_PINFUNC);
43 wmb();
44 44
45 /* reset the AC97 codec now, the reset time in the psc-ac97 driver 45 /* reset the AC97 codec now, the reset time in the psc-ac97 driver
46 * is apparently too short although it's ridiculous as it is. 46 * is apparently too short although it's ridiculous as it is.
diff --git a/arch/mips/alchemy/devboards/pm.c b/arch/mips/alchemy/devboards/pm.c
index 61e90fe9eab1..bfeb8f3c0be6 100644
--- a/arch/mips/alchemy/devboards/pm.c
+++ b/arch/mips/alchemy/devboards/pm.c
@@ -45,23 +45,20 @@ static int db1x_pm_enter(suspend_state_t state)
45 alchemy_gpio1_input_enable(); 45 alchemy_gpio1_input_enable();
46 46
47 /* clear and setup wake cause and source */ 47 /* clear and setup wake cause and source */
48 au_writel(0, SYS_WAKEMSK); 48 alchemy_wrsys(0, AU1000_SYS_WAKEMSK);
49 au_sync(); 49 alchemy_wrsys(0, AU1000_SYS_WAKESRC);
50 au_writel(0, SYS_WAKESRC);
51 au_sync();
52 50
53 au_writel(db1x_pm_wakemsk, SYS_WAKEMSK); 51 alchemy_wrsys(db1x_pm_wakemsk, AU1000_SYS_WAKEMSK);
54 au_sync();
55 52
56 /* setup 1Hz-timer-based wakeup: wait for reg access */ 53 /* setup 1Hz-timer-based wakeup: wait for reg access */
57 while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_M20) 54 while (alchemy_rdsys(AU1000_SYS_CNTRCTRL) & SYS_CNTRL_M20)
58 asm volatile ("nop"); 55 asm volatile ("nop");
59 56
60 au_writel(au_readl(SYS_TOYREAD) + db1x_pm_sleep_secs, SYS_TOYMATCH2); 57 alchemy_wrsys(alchemy_rdsys(AU1000_SYS_TOYREAD) + db1x_pm_sleep_secs,
61 au_sync(); 58 AU1000_SYS_TOYMATCH2);
62 59
63 /* wait for value to really hit the register */ 60 /* wait for value to really hit the register */
64 while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_M20) 61 while (alchemy_rdsys(AU1000_SYS_CNTRCTRL) & SYS_CNTRL_M20)
65 asm volatile ("nop"); 62 asm volatile ("nop");
66 63
67 /* ...and now the sandman can come! */ 64 /* ...and now the sandman can come! */
@@ -102,12 +99,10 @@ static void db1x_pm_end(void)
102 /* read and store wakeup source, the clear the register. To 99 /* read and store wakeup source, the clear the register. To
103 * be able to clear it, WAKEMSK must be cleared first. 100 * be able to clear it, WAKEMSK must be cleared first.
104 */ 101 */
105 db1x_pm_last_wakesrc = au_readl(SYS_WAKESRC); 102 db1x_pm_last_wakesrc = alchemy_rdsys(AU1000_SYS_WAKESRC);
106
107 au_writel(0, SYS_WAKEMSK);
108 au_writel(0, SYS_WAKESRC);
109 au_sync();
110 103
104 alchemy_wrsys(0, AU1000_SYS_WAKEMSK);
105 alchemy_wrsys(0, AU1000_SYS_WAKESRC);
111} 106}
112 107
113static const struct platform_suspend_ops db1x_pm_ops = { 108static const struct platform_suspend_ops db1x_pm_ops = {
@@ -242,17 +237,13 @@ static int __init pm_init(void)
242 * for confirmation since there's plenty of time from here to 237 * for confirmation since there's plenty of time from here to
243 * the next suspend cycle. 238 * the next suspend cycle.
244 */ 239 */
245 if (au_readl(SYS_TOYTRIM) != 32767) { 240 if (alchemy_rdsys(AU1000_SYS_TOYTRIM) != 32767)
246 au_writel(32767, SYS_TOYTRIM); 241 alchemy_wrsys(32767, AU1000_SYS_TOYTRIM);
247 au_sync();
248 }
249 242
250 db1x_pm_last_wakesrc = au_readl(SYS_WAKESRC); 243 db1x_pm_last_wakesrc = alchemy_rdsys(AU1000_SYS_WAKESRC);
251 244
252 au_writel(0, SYS_WAKESRC); 245 alchemy_wrsys(0, AU1000_SYS_WAKESRC);
253 au_sync(); 246 alchemy_wrsys(0, AU1000_SYS_WAKEMSK);
254 au_writel(0, SYS_WAKEMSK);
255 au_sync();
256 247
257 suspend_set_ops(&db1x_pm_ops); 248 suspend_set_ops(&db1x_pm_ops);
258 249
diff --git a/arch/mips/include/asm/mach-au1x00/au1000.h b/arch/mips/include/asm/mach-au1x00/au1000.h
index 16cd01236dc3..c8cfca9c3167 100644
--- a/arch/mips/include/asm/mach-au1x00/au1000.h
+++ b/arch/mips/include/asm/mach-au1x00/au1000.h
@@ -335,8 +335,7 @@
335 335
336 336
337/* Programmable Counters 0 and 1 */ 337/* Programmable Counters 0 and 1 */
338#define SYS_BASE 0xB1900000 338#define AU1000_SYS_CNTRCTRL 0x14
339#define SYS_COUNTER_CNTRL (SYS_BASE + 0x14)
340# define SYS_CNTRL_E1S (1 << 23) 339# define SYS_CNTRL_E1S (1 << 23)
341# define SYS_CNTRL_T1S (1 << 20) 340# define SYS_CNTRL_T1S (1 << 20)
342# define SYS_CNTRL_M21 (1 << 19) 341# define SYS_CNTRL_M21 (1 << 19)
@@ -358,24 +357,24 @@
358# define SYS_CNTRL_C0S (1 << 0) 357# define SYS_CNTRL_C0S (1 << 0)
359 358
360/* Programmable Counter 0 Registers */ 359/* Programmable Counter 0 Registers */
361#define SYS_TOYTRIM (SYS_BASE + 0) 360#define AU1000_SYS_TOYTRIM 0x00
362#define SYS_TOYWRITE (SYS_BASE + 4) 361#define AU1000_SYS_TOYWRITE 0x04
363#define SYS_TOYMATCH0 (SYS_BASE + 8) 362#define AU1000_SYS_TOYMATCH0 0x08
364#define SYS_TOYMATCH1 (SYS_BASE + 0xC) 363#define AU1000_SYS_TOYMATCH1 0x0c
365#define SYS_TOYMATCH2 (SYS_BASE + 0x10) 364#define AU1000_SYS_TOYMATCH2 0x10
366#define SYS_TOYREAD (SYS_BASE + 0x40) 365#define AU1000_SYS_TOYREAD 0x40
367 366
368/* Programmable Counter 1 Registers */ 367/* Programmable Counter 1 Registers */
369#define SYS_RTCTRIM (SYS_BASE + 0x44) 368#define AU1000_SYS_RTCTRIM 0x44
370#define SYS_RTCWRITE (SYS_BASE + 0x48) 369#define AU1000_SYS_RTCWRITE 0x48
371#define SYS_RTCMATCH0 (SYS_BASE + 0x4C) 370#define AU1000_SYS_RTCMATCH0 0x4c
372#define SYS_RTCMATCH1 (SYS_BASE + 0x50) 371#define AU1000_SYS_RTCMATCH1 0x50
373#define SYS_RTCMATCH2 (SYS_BASE + 0x54) 372#define AU1000_SYS_RTCMATCH2 0x54
374#define SYS_RTCREAD (SYS_BASE + 0x58) 373#define AU1000_SYS_RTCREAD 0x58
375 374
376 375
377/* GPIO */ 376/* GPIO */
378#define SYS_PINFUNC 0xB190002C 377#define AU1000_SYS_PINFUNC 0x2C
379# define SYS_PF_USB (1 << 15) /* 2nd USB device/host */ 378# define SYS_PF_USB (1 << 15) /* 2nd USB device/host */
380# define SYS_PF_U3 (1 << 14) /* GPIO23/U3TXD */ 379# define SYS_PF_U3 (1 << 14) /* GPIO23/U3TXD */
381# define SYS_PF_U2 (1 << 13) /* GPIO22/U2TXD */ 380# define SYS_PF_U2 (1 << 13) /* GPIO22/U2TXD */
@@ -445,21 +444,21 @@
445#define SYS_PINFUNC_S1B (1 << 2) 444#define SYS_PINFUNC_S1B (1 << 2)
446 445
447/* Power Management */ 446/* Power Management */
448#define SYS_SCRATCH0 0xB1900018 447#define AU1000_SYS_SCRATCH0 0x18
449#define SYS_SCRATCH1 0xB190001C 448#define AU1000_SYS_SCRATCH1 0x1c
450#define SYS_WAKEMSK 0xB1900034 449#define AU1000_SYS_WAKEMSK 0x34
451#define SYS_ENDIAN 0xB1900038 450#define AU1000_SYS_ENDIAN 0x38
452#define SYS_POWERCTRL 0xB190003C 451#define AU1000_SYS_POWERCTRL 0x3c
453#define SYS_WAKESRC 0xB190005C 452#define AU1000_SYS_WAKESRC 0x5c
454#define SYS_SLPPWR 0xB1900078 453#define AU1000_SYS_SLPPWR 0x78
455#define SYS_SLEEP 0xB190007C 454#define AU1000_SYS_SLEEP 0x7c
456 455
457#define SYS_WAKEMSK_D2 (1 << 9) 456#define SYS_WAKEMSK_D2 (1 << 9)
458#define SYS_WAKEMSK_M2 (1 << 8) 457#define SYS_WAKEMSK_M2 (1 << 8)
459#define SYS_WAKEMSK_GPIO(x) (1 << (x)) 458#define SYS_WAKEMSK_GPIO(x) (1 << (x))
460 459
461/* Clock Controller */ 460/* Clock Controller */
462#define SYS_FREQCTRL0 0xB1900020 461#define AU1000_SYS_FREQCTRL0 0x20
463# define SYS_FC_FRDIV2_BIT 22 462# define SYS_FC_FRDIV2_BIT 22
464# define SYS_FC_FRDIV2_MASK (0xff << SYS_FC_FRDIV2_BIT) 463# define SYS_FC_FRDIV2_MASK (0xff << SYS_FC_FRDIV2_BIT)
465# define SYS_FC_FE2 (1 << 21) 464# define SYS_FC_FE2 (1 << 21)
@@ -472,7 +471,7 @@
472# define SYS_FC_FRDIV0_MASK (0xff << SYS_FC_FRDIV0_BIT) 471# define SYS_FC_FRDIV0_MASK (0xff << SYS_FC_FRDIV0_BIT)
473# define SYS_FC_FE0 (1 << 1) 472# define SYS_FC_FE0 (1 << 1)
474# define SYS_FC_FS0 (1 << 0) 473# define SYS_FC_FS0 (1 << 0)
475#define SYS_FREQCTRL1 0xB1900024 474#define AU1000_SYS_FREQCTRL1 0x24
476# define SYS_FC_FRDIV5_BIT 22 475# define SYS_FC_FRDIV5_BIT 22
477# define SYS_FC_FRDIV5_MASK (0xff << SYS_FC_FRDIV5_BIT) 476# define SYS_FC_FRDIV5_MASK (0xff << SYS_FC_FRDIV5_BIT)
478# define SYS_FC_FE5 (1 << 21) 477# define SYS_FC_FE5 (1 << 21)
@@ -485,7 +484,7 @@
485# define SYS_FC_FRDIV3_MASK (0xff << SYS_FC_FRDIV3_BIT) 484# define SYS_FC_FRDIV3_MASK (0xff << SYS_FC_FRDIV3_BIT)
486# define SYS_FC_FE3 (1 << 1) 485# define SYS_FC_FE3 (1 << 1)
487# define SYS_FC_FS3 (1 << 0) 486# define SYS_FC_FS3 (1 << 0)
488#define SYS_CLKSRC 0xB1900028 487#define AU1000_SYS_CLKSRC 0x28
489# define SYS_CS_ME1_BIT 27 488# define SYS_CS_ME1_BIT 27
490# define SYS_CS_ME1_MASK (0x7 << SYS_CS_ME1_BIT) 489# define SYS_CS_ME1_MASK (0x7 << SYS_CS_ME1_BIT)
491# define SYS_CS_DE1 (1 << 26) 490# define SYS_CS_DE1 (1 << 26)
@@ -525,8 +524,12 @@
525# define SYS_CS_MUX_FQ3 0x5 524# define SYS_CS_MUX_FQ3 0x5
526# define SYS_CS_MUX_FQ4 0x6 525# define SYS_CS_MUX_FQ4 0x6
527# define SYS_CS_MUX_FQ5 0x7 526# define SYS_CS_MUX_FQ5 0x7
528#define SYS_CPUPLL 0xB1900060 527
529#define SYS_AUXPLL 0xB1900064 528#define AU1000_SYS_CPUPLL 0x60
529#define AU1000_SYS_AUXPLL 0x64
530
531
532/**********************************************************************/
530 533
531 534
532/* The PCI chip selects are outside the 32bit space, and since we can't 535/* The PCI chip selects are outside the 32bit space, and since we can't
@@ -694,6 +697,22 @@ static inline u32 au_readl(unsigned long reg)
694 return *(volatile u32 *)reg; 697 return *(volatile u32 *)reg;
695} 698}
696 699
700/* helpers to access the SYS_* registers */
701static inline unsigned long alchemy_rdsys(int regofs)
702{
703 void __iomem *b = (void __iomem *)KSEG1ADDR(AU1000_SYS_PHYS_ADDR);
704
705 return __raw_readl(b + regofs);
706}
707
708static inline void alchemy_wrsys(unsigned long v, int regofs)
709{
710 void __iomem *b = (void __iomem *)KSEG1ADDR(AU1000_SYS_PHYS_ADDR);
711
712 __raw_writel(v, b + regofs);
713 wmb(); /* drain writebuffer */
714}
715
697/* Early Au1000 have a write-only SYS_CPUPLL register. */ 716/* Early Au1000 have a write-only SYS_CPUPLL register. */
698static inline int au1xxx_cpu_has_pll_wo(void) 717static inline int au1xxx_cpu_has_pll_wo(void)
699{ 718{
diff --git a/arch/mips/include/asm/mach-au1x00/gpio-au1000.h b/arch/mips/include/asm/mach-au1x00/gpio-au1000.h
index 796afd051c35..9785e4ebb450 100644
--- a/arch/mips/include/asm/mach-au1x00/gpio-au1000.h
+++ b/arch/mips/include/asm/mach-au1x00/gpio-au1000.h
@@ -25,20 +25,20 @@
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 */ 27/* GPIO1 registers within SYS_ area */
28#define SYS_TRIOUTRD 0x100 28#define AU1000_SYS_TRIOUTRD 0x100
29#define SYS_TRIOUTCLR 0x100 29#define AU1000_SYS_TRIOUTCLR 0x100
30#define SYS_OUTPUTRD 0x108 30#define AU1000_SYS_OUTPUTRD 0x108
31#define SYS_OUTPUTSET 0x108 31#define AU1000_SYS_OUTPUTSET 0x108
32#define SYS_OUTPUTCLR 0x10C 32#define AU1000_SYS_OUTPUTCLR 0x10C
33#define SYS_PINSTATERD 0x110 33#define AU1000_SYS_PINSTATERD 0x110
34#define SYS_PININPUTEN 0x110 34#define AU1000_SYS_PININPUTEN 0x110
35 35
36/* register offsets within GPIO2 block */ 36/* register offsets within GPIO2 block */
37#define GPIO2_DIR 0x00 37#define AU1000_GPIO2_DIR 0x00
38#define GPIO2_OUTPUT 0x08 38#define AU1000_GPIO2_OUTPUT 0x08
39#define GPIO2_PINSTATE 0x0C 39#define AU1000_GPIO2_PINSTATE 0x0C
40#define GPIO2_INTENABLE 0x10 40#define AU1000_GPIO2_INTENABLE 0x10
41#define GPIO2_ENABLE 0x14 41#define AU1000_GPIO2_ENABLE 0x14
42 42
43struct gpio; 43struct gpio;
44 44
@@ -217,26 +217,21 @@ static inline int au1200_irq_to_gpio(int irq)
217 */ 217 */
218static inline void alchemy_gpio1_set_value(int gpio, int v) 218static inline void alchemy_gpio1_set_value(int gpio, int v)
219{ 219{
220 void __iomem *base = (void __iomem *)KSEG1ADDR(AU1000_SYS_PHYS_ADDR);
221 unsigned long mask = 1 << (gpio - ALCHEMY_GPIO1_BASE); 220 unsigned long mask = 1 << (gpio - ALCHEMY_GPIO1_BASE);
222 unsigned long r = v ? SYS_OUTPUTSET : SYS_OUTPUTCLR; 221 unsigned long r = v ? AU1000_SYS_OUTPUTSET : AU1000_SYS_OUTPUTCLR;
223 __raw_writel(mask, base + r); 222 alchemy_wrsys(mask, r);
224 wmb();
225} 223}
226 224
227static inline int alchemy_gpio1_get_value(int gpio) 225static inline int alchemy_gpio1_get_value(int gpio)
228{ 226{
229 void __iomem *base = (void __iomem *)KSEG1ADDR(AU1000_SYS_PHYS_ADDR);
230 unsigned long mask = 1 << (gpio - ALCHEMY_GPIO1_BASE); 227 unsigned long mask = 1 << (gpio - ALCHEMY_GPIO1_BASE);
231 return __raw_readl(base + SYS_PINSTATERD) & mask; 228 return alchemy_rdsys(AU1000_SYS_PINSTATERD) & mask;
232} 229}
233 230
234static inline int alchemy_gpio1_direction_input(int gpio) 231static inline int alchemy_gpio1_direction_input(int gpio)
235{ 232{
236 void __iomem *base = (void __iomem *)KSEG1ADDR(AU1000_SYS_PHYS_ADDR);
237 unsigned long mask = 1 << (gpio - ALCHEMY_GPIO1_BASE); 233 unsigned long mask = 1 << (gpio - ALCHEMY_GPIO1_BASE);
238 __raw_writel(mask, base + SYS_TRIOUTCLR); 234 alchemy_wrsys(mask, AU1000_SYS_TRIOUTCLR);
239 wmb();
240 return 0; 235 return 0;
241} 236}
242 237
@@ -279,13 +274,13 @@ static inline void __alchemy_gpio2_mod_dir(int gpio, int to_out)
279{ 274{
280 void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR); 275 void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR);
281 unsigned long mask = 1 << (gpio - ALCHEMY_GPIO2_BASE); 276 unsigned long mask = 1 << (gpio - ALCHEMY_GPIO2_BASE);
282 unsigned long d = __raw_readl(base + GPIO2_DIR); 277 unsigned long d = __raw_readl(base + AU1000_GPIO2_DIR);
283 278
284 if (to_out) 279 if (to_out)
285 d |= mask; 280 d |= mask;
286 else 281 else
287 d &= ~mask; 282 d &= ~mask;
288 __raw_writel(d, base + GPIO2_DIR); 283 __raw_writel(d, base + AU1000_GPIO2_DIR);
289 wmb(); 284 wmb();
290} 285}
291 286
@@ -294,14 +289,15 @@ static inline void alchemy_gpio2_set_value(int gpio, int v)
294 void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR); 289 void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR);
295 unsigned long mask; 290 unsigned long mask;
296 mask = ((v) ? 0x00010001 : 0x00010000) << (gpio - ALCHEMY_GPIO2_BASE); 291 mask = ((v) ? 0x00010001 : 0x00010000) << (gpio - ALCHEMY_GPIO2_BASE);
297 __raw_writel(mask, base + GPIO2_OUTPUT); 292 __raw_writel(mask, base + AU1000_GPIO2_OUTPUT);
298 wmb(); 293 wmb();
299} 294}
300 295
301static inline int alchemy_gpio2_get_value(int gpio) 296static inline int alchemy_gpio2_get_value(int gpio)
302{ 297{
303 void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR); 298 void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR);
304 return __raw_readl(base + GPIO2_PINSTATE) & (1 << (gpio - ALCHEMY_GPIO2_BASE)); 299 return __raw_readl(base + AU1000_GPIO2_PINSTATE) &
300 (1 << (gpio - ALCHEMY_GPIO2_BASE));
305} 301}
306 302
307static inline int alchemy_gpio2_direction_input(int gpio) 303static inline int alchemy_gpio2_direction_input(int gpio)
@@ -352,12 +348,12 @@ static inline int alchemy_gpio2_to_irq(int gpio)
352static inline void __alchemy_gpio2_mod_int(int gpio2, int en) 348static inline void __alchemy_gpio2_mod_int(int gpio2, int en)
353{ 349{
354 void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR); 350 void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR);
355 unsigned long r = __raw_readl(base + GPIO2_INTENABLE); 351 unsigned long r = __raw_readl(base + AU1000_GPIO2_INTENABLE);
356 if (en) 352 if (en)
357 r |= 1 << gpio2; 353 r |= 1 << gpio2;
358 else 354 else
359 r &= ~(1 << gpio2); 355 r &= ~(1 << gpio2);
360 __raw_writel(r, base + GPIO2_INTENABLE); 356 __raw_writel(r, base + AU1000_GPIO2_INTENABLE);
361 wmb(); 357 wmb();
362} 358}
363 359
@@ -434,9 +430,9 @@ static inline void alchemy_gpio2_disable_int(int gpio2)
434static inline void alchemy_gpio2_enable(void) 430static inline void alchemy_gpio2_enable(void)
435{ 431{
436 void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR); 432 void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR);
437 __raw_writel(3, base + GPIO2_ENABLE); /* reset, clock enabled */ 433 __raw_writel(3, base + AU1000_GPIO2_ENABLE); /* reset, clock enabled */
438 wmb(); 434 wmb();
439 __raw_writel(1, base + GPIO2_ENABLE); /* clock enabled */ 435 __raw_writel(1, base + AU1000_GPIO2_ENABLE); /* clock enabled */
440 wmb(); 436 wmb();
441} 437}
442 438
@@ -448,7 +444,7 @@ static inline void alchemy_gpio2_enable(void)
448static inline void alchemy_gpio2_disable(void) 444static inline void alchemy_gpio2_disable(void)
449{ 445{
450 void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR); 446 void __iomem *base = (void __iomem *)KSEG1ADDR(AU1500_GPIO2_PHYS_ADDR);
451 __raw_writel(2, base + GPIO2_ENABLE); /* reset, clock disabled */ 447 __raw_writel(2, base + AU1000_GPIO2_ENABLE); /* reset, clock disabled */
452 wmb(); 448 wmb();
453} 449}
454 450
diff --git a/drivers/mmc/host/au1xmmc.c b/drivers/mmc/host/au1xmmc.c
index f5443a6c4915..0ea43c09803c 100644
--- a/drivers/mmc/host/au1xmmc.c
+++ b/drivers/mmc/host/au1xmmc.c
@@ -602,7 +602,7 @@ static void au1xmmc_set_clock(struct au1xmmc_host *host, int rate)
602 /* From databook: 602 /* From databook:
603 * divisor = ((((cpuclock / sbus_divisor) / 2) / mmcclock) / 2) - 1 603 * divisor = ((((cpuclock / sbus_divisor) / 2) / mmcclock) / 2) - 1
604 */ 604 */
605 pbus /= ((au_readl(SYS_POWERCTRL) & 0x3) + 2); 605 pbus /= ((alchemy_rdsys(AU1000_SYS_POWERCTRL) & 0x3) + 2);
606 pbus /= 2; 606 pbus /= 2;
607 divisor = ((pbus / rate) / 2) - 1; 607 divisor = ((pbus / rate) / 2) - 1;
608 608
diff --git a/drivers/rtc/rtc-au1xxx.c b/drivers/rtc/rtc-au1xxx.c
index ed526a192ce0..fd25e2374d4e 100644
--- a/drivers/rtc/rtc-au1xxx.c
+++ b/drivers/rtc/rtc-au1xxx.c
@@ -32,7 +32,7 @@ static int au1xtoy_rtc_read_time(struct device *dev, struct rtc_time *tm)
32{ 32{
33 unsigned long t; 33 unsigned long t;
34 34
35 t = au_readl(SYS_TOYREAD); 35 t = alchemy_rdsys(AU1000_SYS_TOYREAD);
36 36
37 rtc_time_to_tm(t, tm); 37 rtc_time_to_tm(t, tm);
38 38
@@ -45,13 +45,12 @@ static int au1xtoy_rtc_set_time(struct device *dev, struct rtc_time *tm)
45 45
46 rtc_tm_to_time(tm, &t); 46 rtc_tm_to_time(tm, &t);
47 47
48 au_writel(t, SYS_TOYWRITE); 48 alchemy_wrsys(t, AU1000_SYS_TOYWRITE);
49 au_sync();
50 49
51 /* wait for the pending register write to succeed. This can 50 /* wait for the pending register write to succeed. This can
52 * take up to 6 seconds... 51 * take up to 6 seconds...
53 */ 52 */
54 while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C0S) 53 while (alchemy_rdsys(AU1000_SYS_CNTRCTRL) & SYS_CNTRL_C0S)
55 msleep(1); 54 msleep(1);
56 55
57 return 0; 56 return 0;
@@ -68,7 +67,7 @@ static int au1xtoy_rtc_probe(struct platform_device *pdev)
68 unsigned long t; 67 unsigned long t;
69 int ret; 68 int ret;
70 69
71 t = au_readl(SYS_COUNTER_CNTRL); 70 t = alchemy_rdsys(AU1000_SYS_CNTRCTRL);
72 if (!(t & CNTR_OK)) { 71 if (!(t & CNTR_OK)) {
73 dev_err(&pdev->dev, "counters not working; aborting.\n"); 72 dev_err(&pdev->dev, "counters not working; aborting.\n");
74 ret = -ENODEV; 73 ret = -ENODEV;
@@ -78,10 +77,10 @@ static int au1xtoy_rtc_probe(struct platform_device *pdev)
78 ret = -ETIMEDOUT; 77 ret = -ETIMEDOUT;
79 78
80 /* set counter0 tickrate to 1Hz if necessary */ 79 /* set counter0 tickrate to 1Hz if necessary */
81 if (au_readl(SYS_TOYTRIM) != 32767) { 80 if (alchemy_rdsys(AU1000_SYS_TOYTRIM) != 32767) {
82 /* wait until hardware gives access to TRIM register */ 81 /* wait until hardware gives access to TRIM register */
83 t = 0x00100000; 82 t = 0x00100000;
84 while ((au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_T0S) && --t) 83 while ((alchemy_rdsys(AU1000_SYS_CNTRCTRL) & SYS_CNTRL_T0S) && --t)
85 msleep(1); 84 msleep(1);
86 85
87 if (!t) { 86 if (!t) {
@@ -93,12 +92,11 @@ static int au1xtoy_rtc_probe(struct platform_device *pdev)
93 } 92 }
94 93
95 /* set 1Hz TOY tick rate */ 94 /* set 1Hz TOY tick rate */
96 au_writel(32767, SYS_TOYTRIM); 95 alchemy_wrsys(32767, AU1000_SYS_TOYTRIM);
97 au_sync();
98 } 96 }
99 97
100 /* wait until the hardware allows writes to the counter reg */ 98 /* wait until the hardware allows writes to the counter reg */
101 while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C0S) 99 while (alchemy_rdsys(AU1000_SYS_CNTRCTRL) & SYS_CNTRL_C0S)
102 msleep(1); 100 msleep(1);
103 101
104 rtcdev = devm_rtc_device_register(&pdev->dev, "rtc-au1xxx", 102 rtcdev = devm_rtc_device_register(&pdev->dev, "rtc-au1xxx",
diff --git a/drivers/video/fbdev/au1100fb.c b/drivers/video/fbdev/au1100fb.c
index 372d4aea9d1c..c0832eaff4d1 100644
--- a/drivers/video/fbdev/au1100fb.c
+++ b/drivers/video/fbdev/au1100fb.c
@@ -507,8 +507,9 @@ static int au1100fb_drv_probe(struct platform_device *dev)
507 print_dbg("phys=0x%08x, size=%dK", fbdev->fb_phys, fbdev->fb_len / 1024); 507 print_dbg("phys=0x%08x, size=%dK", fbdev->fb_phys, fbdev->fb_len / 1024);
508 508
509 /* Setup LCD clock to AUX (48 MHz) */ 509 /* Setup LCD clock to AUX (48 MHz) */
510 sys_clksrc = au_readl(SYS_CLKSRC) & ~(SYS_CS_ML_MASK | SYS_CS_DL | SYS_CS_CL); 510 sys_clksrc = alchemy_rdsys(AU1000_SYS_CLKSRC);
511 au_writel((sys_clksrc | (1 << SYS_CS_ML_BIT)), SYS_CLKSRC); 511 sys_clksrc &= ~(SYS_CS_ML_MASK | SYS_CS_DL | SYS_CS_CL);
512 alchemy_wrsys((sys_clksrc | (1 << SYS_CS_ML_BIT)), AU1000_SYS_CLKSRC);
512 513
513 /* load the panel info into the var struct */ 514 /* load the panel info into the var struct */
514 au1100fb_var.bits_per_pixel = fbdev->panel->bpp; 515 au1100fb_var.bits_per_pixel = fbdev->panel->bpp;
@@ -591,13 +592,13 @@ int au1100fb_drv_suspend(struct platform_device *dev, pm_message_t state)
591 return 0; 592 return 0;
592 593
593 /* Save the clock source state */ 594 /* Save the clock source state */
594 sys_clksrc = au_readl(SYS_CLKSRC); 595 sys_clksrc = alchemy_rdsys(AU1000_SYS_CLKSRC);
595 596
596 /* Blank the LCD */ 597 /* Blank the LCD */
597 au1100fb_fb_blank(VESA_POWERDOWN, &fbdev->info); 598 au1100fb_fb_blank(VESA_POWERDOWN, &fbdev->info);
598 599
599 /* Stop LCD clocking */ 600 /* Stop LCD clocking */
600 au_writel(sys_clksrc & ~SYS_CS_ML_MASK, SYS_CLKSRC); 601 alchemy_wrsys(sys_clksrc & ~SYS_CS_ML_MASK, AU1000_SYS_CLKSRC);
601 602
602 memcpy(&fbregs, fbdev->regs, sizeof(struct au1100fb_regs)); 603 memcpy(&fbregs, fbdev->regs, sizeof(struct au1100fb_regs));
603 604
@@ -614,7 +615,7 @@ int au1100fb_drv_resume(struct platform_device *dev)
614 memcpy(fbdev->regs, &fbregs, sizeof(struct au1100fb_regs)); 615 memcpy(fbdev->regs, &fbregs, sizeof(struct au1100fb_regs));
615 616
616 /* Restart LCD clocking */ 617 /* Restart LCD clocking */
617 au_writel(sys_clksrc, SYS_CLKSRC); 618 alchemy_wrsys(sys_clksrc, AU1000_SYS_CLKSRC);
618 619
619 /* Unblank the LCD */ 620 /* Unblank the LCD */
620 au1100fb_fb_blank(VESA_NO_BLANKING, &fbdev->info); 621 au1100fb_fb_blank(VESA_NO_BLANKING, &fbdev->info);
diff --git a/drivers/video/fbdev/au1200fb.c b/drivers/video/fbdev/au1200fb.c
index 4cfba78a1458..2d77334af41b 100644
--- a/drivers/video/fbdev/au1200fb.c
+++ b/drivers/video/fbdev/au1200fb.c
@@ -830,10 +830,10 @@ static void au1200_setpanel(struct panel_settings *newpanel,
830 if (!(panel->mode_clkcontrol & LCD_CLKCONTROL_EXT)) 830 if (!(panel->mode_clkcontrol & LCD_CLKCONTROL_EXT))
831 { 831 {
832 uint32 sys_clksrc; 832 uint32 sys_clksrc;
833 au_writel(panel->mode_auxpll, SYS_AUXPLL); 833 alchemy_wrsys(panel->mode_auxpll, AU1000_SYS_AUXPLL);
834 sys_clksrc = au_readl(SYS_CLKSRC) & ~0x0000001f; 834 sys_clksrc = alchemy_rdsys(AU1000_SYS_CLKSRC) & ~0x0000001f;
835 sys_clksrc |= panel->mode_toyclksrc; 835 sys_clksrc |= panel->mode_toyclksrc;
836 au_writel(sys_clksrc, SYS_CLKSRC); 836 alchemy_wrsys(sys_clksrc, AU1000_SYS_CLKSRC);
837 } 837 }
838 838
839 /* 839 /*