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/mbus.h>
16 #include <linux/ata_platform.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/orion_nand.h>
24 #include <plat/time.h>
25 #include <plat/common.h>
28 static int get_tclk(void);
30 /*****************************************************************************
32 ****************************************************************************/
33 int mv78xx0_core_index(void)
38 * Read Extra Features register.
40 __asm__("mrc p15, 1, %0, c15, c1, 0" : "=r" (extra
));
42 return !!(extra
& 0x00004000);
45 static int get_hclk(void)
50 * HCLK tick rate is configured by DEV_D[7:5] pins.
52 switch ((readl(SAMPLE_AT_RESET_LOW
) >> 5) & 7) {
69 panic("unknown HCLK PLL setting: %.8x\n",
70 readl(SAMPLE_AT_RESET_LOW
));
76 static void get_pclk_l2clk(int hclk
, int core_index
, int *pclk
, int *l2clk
)
81 * Core #0 PCLK/L2CLK is configured by bits [13:8], core #1
82 * PCLK/L2CLK by bits [19:14].
84 if (core_index
== 0) {
85 cfg
= (readl(SAMPLE_AT_RESET_LOW
) >> 8) & 0x3f;
87 cfg
= (readl(SAMPLE_AT_RESET_LOW
) >> 14) & 0x3f;
91 * Bits [11:8] ([17:14] for core #1) configure the PCLK:HCLK
92 * ratio (1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6).
94 *pclk
= ((u64
)hclk
* (2 + (cfg
& 0xf))) >> 1;
97 * Bits [13:12] ([19:18] for core #1) configure the PCLK:L2CLK
100 *l2clk
= *pclk
/ (((cfg
>> 4) & 3) + 1);
103 static int get_tclk(void)
108 * TCLK tick rate is configured by DEV_A[2:0] strap pins.
110 switch ((readl(SAMPLE_AT_RESET_HIGH
) >> 6) & 7) {
118 panic("unknown TCLK PLL setting: %.8x\n",
119 readl(SAMPLE_AT_RESET_HIGH
));
126 /*****************************************************************************
127 * I/O Address Mapping
128 ****************************************************************************/
129 static struct map_desc mv78xx0_io_desc
[] __initdata
= {
131 .virtual = MV78XX0_CORE_REGS_VIRT_BASE
,
133 .length
= MV78XX0_CORE_REGS_SIZE
,
136 .virtual = MV78XX0_PCIE_IO_VIRT_BASE(0),
137 .pfn
= __phys_to_pfn(MV78XX0_PCIE_IO_PHYS_BASE(0)),
138 .length
= MV78XX0_PCIE_IO_SIZE
* 8,
141 .virtual = MV78XX0_REGS_VIRT_BASE
,
142 .pfn
= __phys_to_pfn(MV78XX0_REGS_PHYS_BASE
),
143 .length
= MV78XX0_REGS_SIZE
,
148 void __init
mv78xx0_map_io(void)
153 * Map the right set of per-core registers depending on
154 * which core we are running on.
156 if (mv78xx0_core_index() == 0) {
157 phys
= MV78XX0_CORE0_REGS_PHYS_BASE
;
159 phys
= MV78XX0_CORE1_REGS_PHYS_BASE
;
161 mv78xx0_io_desc
[0].pfn
= __phys_to_pfn(phys
);
163 iotable_init(mv78xx0_io_desc
, ARRAY_SIZE(mv78xx0_io_desc
));
167 /*****************************************************************************
169 ****************************************************************************/
170 void __init
mv78xx0_ehci0_init(void)
172 orion_ehci_init(&mv78xx0_mbus_dram_info
,
173 USB0_PHYS_BASE
, IRQ_MV78XX0_USB_0
);
177 /*****************************************************************************
179 ****************************************************************************/
180 void __init
mv78xx0_ehci1_init(void)
182 orion_ehci_1_init(&mv78xx0_mbus_dram_info
,
183 USB1_PHYS_BASE
, IRQ_MV78XX0_USB_1
);
187 /*****************************************************************************
189 ****************************************************************************/
190 void __init
mv78xx0_ehci2_init(void)
192 orion_ehci_2_init(&mv78xx0_mbus_dram_info
,
193 USB2_PHYS_BASE
, IRQ_MV78XX0_USB_2
);
197 /*****************************************************************************
199 ****************************************************************************/
200 void __init
mv78xx0_ge00_init(struct mv643xx_eth_platform_data
*eth_data
)
202 orion_ge00_init(eth_data
, &mv78xx0_mbus_dram_info
,
203 GE00_PHYS_BASE
, IRQ_MV78XX0_GE00_SUM
,
204 IRQ_MV78XX0_GE_ERR
, get_tclk());
208 /*****************************************************************************
210 ****************************************************************************/
211 void __init
mv78xx0_ge01_init(struct mv643xx_eth_platform_data
*eth_data
)
213 orion_ge01_init(eth_data
, &mv78xx0_mbus_dram_info
,
214 GE01_PHYS_BASE
, IRQ_MV78XX0_GE01_SUM
,
219 /*****************************************************************************
221 ****************************************************************************/
222 void __init
mv78xx0_ge10_init(struct mv643xx_eth_platform_data
*eth_data
)
227 * On the Z0, ge10 and ge11 are internally connected back
228 * to back, and not brought out.
230 mv78xx0_pcie_id(&dev
, &rev
);
231 if (dev
== MV78X00_Z0_DEV_ID
) {
232 eth_data
->phy_addr
= MV643XX_ETH_PHY_NONE
;
233 eth_data
->speed
= SPEED_1000
;
234 eth_data
->duplex
= DUPLEX_FULL
;
237 orion_ge10_init(eth_data
, &mv78xx0_mbus_dram_info
,
238 GE10_PHYS_BASE
, IRQ_MV78XX0_GE10_SUM
,
243 /*****************************************************************************
245 ****************************************************************************/
246 void __init
mv78xx0_ge11_init(struct mv643xx_eth_platform_data
*eth_data
)
251 * On the Z0, ge10 and ge11 are internally connected back
252 * to back, and not brought out.
254 mv78xx0_pcie_id(&dev
, &rev
);
255 if (dev
== MV78X00_Z0_DEV_ID
) {
256 eth_data
->phy_addr
= MV643XX_ETH_PHY_NONE
;
257 eth_data
->speed
= SPEED_1000
;
258 eth_data
->duplex
= DUPLEX_FULL
;
261 orion_ge11_init(eth_data
, &mv78xx0_mbus_dram_info
,
262 GE11_PHYS_BASE
, IRQ_MV78XX0_GE11_SUM
,
266 /*****************************************************************************
268 ****************************************************************************/
269 void __init
mv78xx0_i2c_init(void)
271 orion_i2c_init(I2C_0_PHYS_BASE
, IRQ_MV78XX0_I2C_0
, 8);
272 orion_i2c_1_init(I2C_1_PHYS_BASE
, IRQ_MV78XX0_I2C_1
, 8);
275 /*****************************************************************************
277 ****************************************************************************/
278 void __init
mv78xx0_sata_init(struct mv_sata_platform_data
*sata_data
)
280 orion_sata_init(sata_data
, &mv78xx0_mbus_dram_info
,
281 SATA_PHYS_BASE
, IRQ_MV78XX0_SATA
);
285 /*****************************************************************************
287 ****************************************************************************/
288 void __init
mv78xx0_uart0_init(void)
290 orion_uart0_init(UART0_VIRT_BASE
, UART0_PHYS_BASE
,
291 IRQ_MV78XX0_UART_0
, get_tclk());
295 /*****************************************************************************
297 ****************************************************************************/
298 void __init
mv78xx0_uart1_init(void)
300 orion_uart1_init(UART1_VIRT_BASE
, UART1_PHYS_BASE
,
301 IRQ_MV78XX0_UART_1
, get_tclk());
305 /*****************************************************************************
307 ****************************************************************************/
308 void __init
mv78xx0_uart2_init(void)
310 orion_uart2_init(UART2_VIRT_BASE
, UART2_PHYS_BASE
,
311 IRQ_MV78XX0_UART_2
, get_tclk());
314 /*****************************************************************************
316 ****************************************************************************/
317 void __init
mv78xx0_uart3_init(void)
319 orion_uart3_init(UART3_VIRT_BASE
, UART3_PHYS_BASE
,
320 IRQ_MV78XX0_UART_3
, get_tclk());
323 /*****************************************************************************
325 ****************************************************************************/
326 void __init
mv78xx0_init_early(void)
328 orion_time_set_base(TIMER_VIRT_BASE
);
331 static void mv78xx0_timer_init(void)
333 orion_time_init(BRIDGE_VIRT_BASE
, BRIDGE_INT_TIMER1_CLR
,
334 IRQ_MV78XX0_TIMER_1
, get_tclk());
337 struct sys_timer mv78xx0_timer
= {
338 .init
= mv78xx0_timer_init
,
342 /*****************************************************************************
344 ****************************************************************************/
345 static char * __init
mv78xx0_id(void)
349 mv78xx0_pcie_id(&dev
, &rev
);
351 if (dev
== MV78X00_Z0_DEV_ID
) {
352 if (rev
== MV78X00_REV_Z0
)
355 return "MV78X00-Rev-Unsupported";
356 } else if (dev
== MV78100_DEV_ID
) {
357 if (rev
== MV78100_REV_A0
)
359 else if (rev
== MV78100_REV_A1
)
362 return "MV78100-Rev-Unsupported";
363 } else if (dev
== MV78200_DEV_ID
) {
364 if (rev
== MV78100_REV_A0
)
367 return "MV78200-Rev-Unsupported";
369 return "Device-Unknown";
373 static int __init
is_l2_writethrough(void)
375 return !!(readl(CPU_CONTROL
) & L2_WRITETHROUGH
);
378 void __init
mv78xx0_init(void)
386 core_index
= mv78xx0_core_index();
388 get_pclk_l2clk(hclk
, core_index
, &pclk
, &l2clk
);
391 printk(KERN_INFO
"%s ", mv78xx0_id());
392 printk("core #%d, ", core_index
);
393 printk("PCLK = %dMHz, ", (pclk
+ 499999) / 1000000);
394 printk("L2 = %dMHz, ", (l2clk
+ 499999) / 1000000);
395 printk("HCLK = %dMHz, ", (hclk
+ 499999) / 1000000);
396 printk("TCLK = %dMHz\n", (tclk
+ 499999) / 1000000);
398 mv78xx0_setup_cpu_mbus();
400 #ifdef CONFIG_CACHE_FEROCEON_L2
401 feroceon_l2_init(is_l2_writethrough());