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/clk-provider.h>
17 #include <linux/ethtool.h>
18 #include <asm/mach/map.h>
19 #include <asm/mach/time.h>
20 #include <mach/mv78xx0.h>
21 #include <mach/bridge-regs.h>
22 #include <plat/cache-feroceon-l2.h>
23 #include <plat/ehci-orion.h>
24 #include <plat/orion_nand.h>
25 #include <plat/time.h>
26 #include <plat/common.h>
27 #include <plat/addr-map.h>
30 static int get_tclk(void);
32 /*****************************************************************************
34 ****************************************************************************/
35 int mv78xx0_core_index(void)
40 * Read Extra Features register.
42 __asm__("mrc p15, 1, %0, c15, c1, 0" : "=r" (extra
));
44 return !!(extra
& 0x00004000);
47 static int get_hclk(void)
52 * HCLK tick rate is configured by DEV_D[7:5] pins.
54 switch ((readl(SAMPLE_AT_RESET_LOW
) >> 5) & 7) {
71 panic("unknown HCLK PLL setting: %.8x\n",
72 readl(SAMPLE_AT_RESET_LOW
));
78 static void get_pclk_l2clk(int hclk
, int core_index
, int *pclk
, int *l2clk
)
83 * Core #0 PCLK/L2CLK is configured by bits [13:8], core #1
84 * PCLK/L2CLK by bits [19:14].
86 if (core_index
== 0) {
87 cfg
= (readl(SAMPLE_AT_RESET_LOW
) >> 8) & 0x3f;
89 cfg
= (readl(SAMPLE_AT_RESET_LOW
) >> 14) & 0x3f;
93 * Bits [11:8] ([17:14] for core #1) configure the PCLK:HCLK
94 * ratio (1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6).
96 *pclk
= ((u64
)hclk
* (2 + (cfg
& 0xf))) >> 1;
99 * Bits [13:12] ([19:18] for core #1) configure the PCLK:L2CLK
102 *l2clk
= *pclk
/ (((cfg
>> 4) & 3) + 1);
105 static int get_tclk(void)
110 * TCLK tick rate is configured by DEV_A[2:0] strap pins.
112 switch ((readl(SAMPLE_AT_RESET_HIGH
) >> 6) & 7) {
114 tclk_freq
= 166666667;
117 tclk_freq
= 200000000;
120 panic("unknown TCLK PLL setting: %.8x\n",
121 readl(SAMPLE_AT_RESET_HIGH
));
128 /*****************************************************************************
129 * I/O Address Mapping
130 ****************************************************************************/
131 static struct map_desc mv78xx0_io_desc
[] __initdata
= {
133 .virtual = MV78XX0_CORE_REGS_VIRT_BASE
,
135 .length
= MV78XX0_CORE_REGS_SIZE
,
138 .virtual = MV78XX0_PCIE_IO_VIRT_BASE(0),
139 .pfn
= __phys_to_pfn(MV78XX0_PCIE_IO_PHYS_BASE(0)),
140 .length
= MV78XX0_PCIE_IO_SIZE
* 8,
143 .virtual = MV78XX0_REGS_VIRT_BASE
,
144 .pfn
= __phys_to_pfn(MV78XX0_REGS_PHYS_BASE
),
145 .length
= MV78XX0_REGS_SIZE
,
150 void __init
mv78xx0_map_io(void)
155 * Map the right set of per-core registers depending on
156 * which core we are running on.
158 if (mv78xx0_core_index() == 0) {
159 phys
= MV78XX0_CORE0_REGS_PHYS_BASE
;
161 phys
= MV78XX0_CORE1_REGS_PHYS_BASE
;
163 mv78xx0_io_desc
[0].pfn
= __phys_to_pfn(phys
);
165 iotable_init(mv78xx0_io_desc
, ARRAY_SIZE(mv78xx0_io_desc
));
169 /*****************************************************************************
171 ****************************************************************************/
172 static struct clk
*tclk
;
174 static void __init
clk_init(void)
176 tclk
= clk_register_fixed_rate(NULL
, "tclk", NULL
, CLK_IS_ROOT
,
179 orion_clkdev_init(tclk
);
182 /*****************************************************************************
184 ****************************************************************************/
185 void __init
mv78xx0_ehci0_init(void)
187 orion_ehci_init(USB0_PHYS_BASE
, IRQ_MV78XX0_USB_0
, EHCI_PHY_NA
);
191 /*****************************************************************************
193 ****************************************************************************/
194 void __init
mv78xx0_ehci1_init(void)
196 orion_ehci_1_init(USB1_PHYS_BASE
, IRQ_MV78XX0_USB_1
);
200 /*****************************************************************************
202 ****************************************************************************/
203 void __init
mv78xx0_ehci2_init(void)
205 orion_ehci_2_init(USB2_PHYS_BASE
, IRQ_MV78XX0_USB_2
);
209 /*****************************************************************************
211 ****************************************************************************/
212 void __init
mv78xx0_ge00_init(struct mv643xx_eth_platform_data
*eth_data
)
214 orion_ge00_init(eth_data
,
215 GE00_PHYS_BASE
, IRQ_MV78XX0_GE00_SUM
,
220 /*****************************************************************************
222 ****************************************************************************/
223 void __init
mv78xx0_ge01_init(struct mv643xx_eth_platform_data
*eth_data
)
225 orion_ge01_init(eth_data
,
226 GE01_PHYS_BASE
, IRQ_MV78XX0_GE01_SUM
,
231 /*****************************************************************************
233 ****************************************************************************/
234 void __init
mv78xx0_ge10_init(struct mv643xx_eth_platform_data
*eth_data
)
239 * On the Z0, ge10 and ge11 are internally connected back
240 * to back, and not brought out.
242 mv78xx0_pcie_id(&dev
, &rev
);
243 if (dev
== MV78X00_Z0_DEV_ID
) {
244 eth_data
->phy_addr
= MV643XX_ETH_PHY_NONE
;
245 eth_data
->speed
= SPEED_1000
;
246 eth_data
->duplex
= DUPLEX_FULL
;
249 orion_ge10_init(eth_data
,
250 GE10_PHYS_BASE
, IRQ_MV78XX0_GE10_SUM
,
255 /*****************************************************************************
257 ****************************************************************************/
258 void __init
mv78xx0_ge11_init(struct mv643xx_eth_platform_data
*eth_data
)
263 * On the Z0, ge10 and ge11 are internally connected back
264 * to back, and not brought out.
266 mv78xx0_pcie_id(&dev
, &rev
);
267 if (dev
== MV78X00_Z0_DEV_ID
) {
268 eth_data
->phy_addr
= MV643XX_ETH_PHY_NONE
;
269 eth_data
->speed
= SPEED_1000
;
270 eth_data
->duplex
= DUPLEX_FULL
;
273 orion_ge11_init(eth_data
,
274 GE11_PHYS_BASE
, IRQ_MV78XX0_GE11_SUM
,
278 /*****************************************************************************
280 ****************************************************************************/
281 void __init
mv78xx0_i2c_init(void)
283 orion_i2c_init(I2C_0_PHYS_BASE
, IRQ_MV78XX0_I2C_0
, 8);
284 orion_i2c_1_init(I2C_1_PHYS_BASE
, IRQ_MV78XX0_I2C_1
, 8);
287 /*****************************************************************************
289 ****************************************************************************/
290 void __init
mv78xx0_sata_init(struct mv_sata_platform_data
*sata_data
)
292 orion_sata_init(sata_data
, SATA_PHYS_BASE
, IRQ_MV78XX0_SATA
);
296 /*****************************************************************************
298 ****************************************************************************/
299 void __init
mv78xx0_uart0_init(void)
301 orion_uart0_init(UART0_VIRT_BASE
, UART0_PHYS_BASE
,
302 IRQ_MV78XX0_UART_0
, tclk
);
306 /*****************************************************************************
308 ****************************************************************************/
309 void __init
mv78xx0_uart1_init(void)
311 orion_uart1_init(UART1_VIRT_BASE
, UART1_PHYS_BASE
,
312 IRQ_MV78XX0_UART_1
, tclk
);
316 /*****************************************************************************
318 ****************************************************************************/
319 void __init
mv78xx0_uart2_init(void)
321 orion_uart2_init(UART2_VIRT_BASE
, UART2_PHYS_BASE
,
322 IRQ_MV78XX0_UART_2
, tclk
);
325 /*****************************************************************************
327 ****************************************************************************/
328 void __init
mv78xx0_uart3_init(void)
330 orion_uart3_init(UART3_VIRT_BASE
, UART3_PHYS_BASE
,
331 IRQ_MV78XX0_UART_3
, tclk
);
334 /*****************************************************************************
336 ****************************************************************************/
337 void __init
mv78xx0_init_early(void)
339 orion_time_set_base(TIMER_VIRT_BASE
);
342 static void mv78xx0_timer_init(void)
344 orion_time_init(BRIDGE_VIRT_BASE
, BRIDGE_INT_TIMER1_CLR
,
345 IRQ_MV78XX0_TIMER_1
, get_tclk());
348 struct sys_timer mv78xx0_timer
= {
349 .init
= mv78xx0_timer_init
,
353 /*****************************************************************************
355 ****************************************************************************/
356 static char * __init
mv78xx0_id(void)
360 mv78xx0_pcie_id(&dev
, &rev
);
362 if (dev
== MV78X00_Z0_DEV_ID
) {
363 if (rev
== MV78X00_REV_Z0
)
366 return "MV78X00-Rev-Unsupported";
367 } else if (dev
== MV78100_DEV_ID
) {
368 if (rev
== MV78100_REV_A0
)
370 else if (rev
== MV78100_REV_A1
)
373 return "MV78100-Rev-Unsupported";
374 } else if (dev
== MV78200_DEV_ID
) {
375 if (rev
== MV78100_REV_A0
)
378 return "MV78200-Rev-Unsupported";
380 return "Device-Unknown";
384 static int __init
is_l2_writethrough(void)
386 return !!(readl(CPU_CONTROL
) & L2_WRITETHROUGH
);
389 void __init
mv78xx0_init(void)
396 core_index
= mv78xx0_core_index();
398 get_pclk_l2clk(hclk
, core_index
, &pclk
, &l2clk
);
400 printk(KERN_INFO
"%s ", mv78xx0_id());
401 printk("core #%d, ", core_index
);
402 printk("PCLK = %dMHz, ", (pclk
+ 499999) / 1000000);
403 printk("L2 = %dMHz, ", (l2clk
+ 499999) / 1000000);
404 printk("HCLK = %dMHz, ", (hclk
+ 499999) / 1000000);
405 printk("TCLK = %dMHz\n", (get_tclk() + 499999) / 1000000);
407 mv78xx0_setup_cpu_mbus();
409 #ifdef CONFIG_CACHE_FEROCEON_L2
410 feroceon_l2_init(is_l2_writethrough());
413 /* Setup root of clk tree */
417 void mv78xx0_restart(char mode
, const char *cmd
)
420 * Enable soft reset to assert RSTOUTn.
422 writel(SOFT_RESET_OUT_EN
, RSTOUTn_MASK
);
427 writel(SOFT_RESET
, SYSTEM_SOFT_RESET
);