2 * arch/arm/mach-mv78xx0/common.c
4 * Core functions for Marvell MV78xx0 SoCs
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied.
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/platform_device.h>
14 #include <linux/serial_8250.h>
15 #include <linux/ata_platform.h>
16 #include <linux/ethtool.h>
17 #include <asm/mach/map.h>
18 #include <asm/mach/time.h>
19 #include <mach/mv78xx0.h>
20 #include <mach/bridge-regs.h>
21 #include <plat/cache-feroceon-l2.h>
22 #include <plat/ehci-orion.h>
23 #include <plat/orion_nand.h>
24 #include <plat/time.h>
25 #include <plat/common.h>
26 #include <plat/addr-map.h>
29 static int get_tclk(void);
31 /*****************************************************************************
33 ****************************************************************************/
34 int mv78xx0_core_index(void)
39 * Read Extra Features register.
41 __asm__("mrc p15, 1, %0, c15, c1, 0" : "=r" (extra
));
43 return !!(extra
& 0x00004000);
46 static int get_hclk(void)
51 * HCLK tick rate is configured by DEV_D[7:5] pins.
53 switch ((readl(SAMPLE_AT_RESET_LOW
) >> 5) & 7) {
70 panic("unknown HCLK PLL setting: %.8x\n",
71 readl(SAMPLE_AT_RESET_LOW
));
77 static void get_pclk_l2clk(int hclk
, int core_index
, int *pclk
, int *l2clk
)
82 * Core #0 PCLK/L2CLK is configured by bits [13:8], core #1
83 * PCLK/L2CLK by bits [19:14].
85 if (core_index
== 0) {
86 cfg
= (readl(SAMPLE_AT_RESET_LOW
) >> 8) & 0x3f;
88 cfg
= (readl(SAMPLE_AT_RESET_LOW
) >> 14) & 0x3f;
92 * Bits [11:8] ([17:14] for core #1) configure the PCLK:HCLK
93 * ratio (1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6).
95 *pclk
= ((u64
)hclk
* (2 + (cfg
& 0xf))) >> 1;
98 * Bits [13:12] ([19:18] for core #1) configure the PCLK:L2CLK
101 *l2clk
= *pclk
/ (((cfg
>> 4) & 3) + 1);
104 static int get_tclk(void)
109 * TCLK tick rate is configured by DEV_A[2:0] strap pins.
111 switch ((readl(SAMPLE_AT_RESET_HIGH
) >> 6) & 7) {
119 panic("unknown TCLK PLL setting: %.8x\n",
120 readl(SAMPLE_AT_RESET_HIGH
));
127 /*****************************************************************************
128 * I/O Address Mapping
129 ****************************************************************************/
130 static struct map_desc mv78xx0_io_desc
[] __initdata
= {
132 .virtual = MV78XX0_CORE_REGS_VIRT_BASE
,
134 .length
= MV78XX0_CORE_REGS_SIZE
,
137 .virtual = MV78XX0_PCIE_IO_VIRT_BASE(0),
138 .pfn
= __phys_to_pfn(MV78XX0_PCIE_IO_PHYS_BASE(0)),
139 .length
= MV78XX0_PCIE_IO_SIZE
* 8,
142 .virtual = MV78XX0_REGS_VIRT_BASE
,
143 .pfn
= __phys_to_pfn(MV78XX0_REGS_PHYS_BASE
),
144 .length
= MV78XX0_REGS_SIZE
,
149 void __init
mv78xx0_map_io(void)
154 * Map the right set of per-core registers depending on
155 * which core we are running on.
157 if (mv78xx0_core_index() == 0) {
158 phys
= MV78XX0_CORE0_REGS_PHYS_BASE
;
160 phys
= MV78XX0_CORE1_REGS_PHYS_BASE
;
162 mv78xx0_io_desc
[0].pfn
= __phys_to_pfn(phys
);
164 iotable_init(mv78xx0_io_desc
, ARRAY_SIZE(mv78xx0_io_desc
));
168 /*****************************************************************************
170 ****************************************************************************/
171 void __init
mv78xx0_ehci0_init(void)
173 orion_ehci_init(USB0_PHYS_BASE
, IRQ_MV78XX0_USB_0
, EHCI_PHY_NA
);
177 /*****************************************************************************
179 ****************************************************************************/
180 void __init
mv78xx0_ehci1_init(void)
182 orion_ehci_1_init(USB1_PHYS_BASE
, IRQ_MV78XX0_USB_1
);
186 /*****************************************************************************
188 ****************************************************************************/
189 void __init
mv78xx0_ehci2_init(void)
191 orion_ehci_2_init(USB2_PHYS_BASE
, IRQ_MV78XX0_USB_2
);
195 /*****************************************************************************
197 ****************************************************************************/
198 void __init
mv78xx0_ge00_init(struct mv643xx_eth_platform_data
*eth_data
)
200 orion_ge00_init(eth_data
,
201 GE00_PHYS_BASE
, IRQ_MV78XX0_GE00_SUM
,
202 IRQ_MV78XX0_GE_ERR
, get_tclk());
206 /*****************************************************************************
208 ****************************************************************************/
209 void __init
mv78xx0_ge01_init(struct mv643xx_eth_platform_data
*eth_data
)
211 orion_ge01_init(eth_data
,
212 GE01_PHYS_BASE
, IRQ_MV78XX0_GE01_SUM
,
217 /*****************************************************************************
219 ****************************************************************************/
220 void __init
mv78xx0_ge10_init(struct mv643xx_eth_platform_data
*eth_data
)
225 * On the Z0, ge10 and ge11 are internally connected back
226 * to back, and not brought out.
228 mv78xx0_pcie_id(&dev
, &rev
);
229 if (dev
== MV78X00_Z0_DEV_ID
) {
230 eth_data
->phy_addr
= MV643XX_ETH_PHY_NONE
;
231 eth_data
->speed
= SPEED_1000
;
232 eth_data
->duplex
= DUPLEX_FULL
;
235 orion_ge10_init(eth_data
,
236 GE10_PHYS_BASE
, IRQ_MV78XX0_GE10_SUM
,
241 /*****************************************************************************
243 ****************************************************************************/
244 void __init
mv78xx0_ge11_init(struct mv643xx_eth_platform_data
*eth_data
)
249 * On the Z0, ge10 and ge11 are internally connected back
250 * to back, and not brought out.
252 mv78xx0_pcie_id(&dev
, &rev
);
253 if (dev
== MV78X00_Z0_DEV_ID
) {
254 eth_data
->phy_addr
= MV643XX_ETH_PHY_NONE
;
255 eth_data
->speed
= SPEED_1000
;
256 eth_data
->duplex
= DUPLEX_FULL
;
259 orion_ge11_init(eth_data
,
260 GE11_PHYS_BASE
, IRQ_MV78XX0_GE11_SUM
,
264 /*****************************************************************************
266 ****************************************************************************/
267 void __init
mv78xx0_i2c_init(void)
269 orion_i2c_init(I2C_0_PHYS_BASE
, IRQ_MV78XX0_I2C_0
, 8);
270 orion_i2c_1_init(I2C_1_PHYS_BASE
, IRQ_MV78XX0_I2C_1
, 8);
273 /*****************************************************************************
275 ****************************************************************************/
276 void __init
mv78xx0_sata_init(struct mv_sata_platform_data
*sata_data
)
278 orion_sata_init(sata_data
, SATA_PHYS_BASE
, IRQ_MV78XX0_SATA
);
282 /*****************************************************************************
284 ****************************************************************************/
285 void __init
mv78xx0_uart0_init(void)
287 orion_uart0_init(UART0_VIRT_BASE
, UART0_PHYS_BASE
,
288 IRQ_MV78XX0_UART_0
, get_tclk());
292 /*****************************************************************************
294 ****************************************************************************/
295 void __init
mv78xx0_uart1_init(void)
297 orion_uart1_init(UART1_VIRT_BASE
, UART1_PHYS_BASE
,
298 IRQ_MV78XX0_UART_1
, get_tclk());
302 /*****************************************************************************
304 ****************************************************************************/
305 void __init
mv78xx0_uart2_init(void)
307 orion_uart2_init(UART2_VIRT_BASE
, UART2_PHYS_BASE
,
308 IRQ_MV78XX0_UART_2
, get_tclk());
311 /*****************************************************************************
313 ****************************************************************************/
314 void __init
mv78xx0_uart3_init(void)
316 orion_uart3_init(UART3_VIRT_BASE
, UART3_PHYS_BASE
,
317 IRQ_MV78XX0_UART_3
, get_tclk());
320 /*****************************************************************************
322 ****************************************************************************/
323 void __init
mv78xx0_init_early(void)
325 orion_time_set_base(TIMER_VIRT_BASE
);
328 static void mv78xx0_timer_init(void)
330 orion_time_init(BRIDGE_VIRT_BASE
, BRIDGE_INT_TIMER1_CLR
,
331 IRQ_MV78XX0_TIMER_1
, get_tclk());
334 struct sys_timer mv78xx0_timer
= {
335 .init
= mv78xx0_timer_init
,
339 /*****************************************************************************
341 ****************************************************************************/
342 static char * __init
mv78xx0_id(void)
346 mv78xx0_pcie_id(&dev
, &rev
);
348 if (dev
== MV78X00_Z0_DEV_ID
) {
349 if (rev
== MV78X00_REV_Z0
)
352 return "MV78X00-Rev-Unsupported";
353 } else if (dev
== MV78100_DEV_ID
) {
354 if (rev
== MV78100_REV_A0
)
356 else if (rev
== MV78100_REV_A1
)
359 return "MV78100-Rev-Unsupported";
360 } else if (dev
== MV78200_DEV_ID
) {
361 if (rev
== MV78100_REV_A0
)
364 return "MV78200-Rev-Unsupported";
366 return "Device-Unknown";
370 static int __init
is_l2_writethrough(void)
372 return !!(readl(CPU_CONTROL
) & L2_WRITETHROUGH
);
375 void __init
mv78xx0_init(void)
383 core_index
= mv78xx0_core_index();
385 get_pclk_l2clk(hclk
, core_index
, &pclk
, &l2clk
);
388 printk(KERN_INFO
"%s ", mv78xx0_id());
389 printk("core #%d, ", core_index
);
390 printk("PCLK = %dMHz, ", (pclk
+ 499999) / 1000000);
391 printk("L2 = %dMHz, ", (l2clk
+ 499999) / 1000000);
392 printk("HCLK = %dMHz, ", (hclk
+ 499999) / 1000000);
393 printk("TCLK = %dMHz\n", (tclk
+ 499999) / 1000000);
395 mv78xx0_setup_cpu_mbus();
397 #ifdef CONFIG_CACHE_FEROCEON_L2
398 feroceon_l2_init(is_l2_writethrough());
402 void mv78xx0_restart(char mode
, const char *cmd
)
405 * Enable soft reset to assert RSTOUTn.
407 writel(SOFT_RESET_OUT_EN
, RSTOUTn_MASK
);
412 writel(SOFT_RESET
, SYSTEM_SOFT_RESET
);