3 * arch/ppc/platforms/hdpu_setup.c
5 * Board setup routines for the Sky Computers HDPU Compute Blade.
7 * Written by Brian Waite <waite@skycomputers.com>
9 * Based on code done by - Mark A. Greer <mgreer@mvista.com>
10 * Rabeeh Khoury - rabeeh@galileo.co.il
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
18 #include <linux/config.h>
20 #include <linux/pci.h>
21 #include <linux/delay.h>
22 #include <linux/irq.h>
23 #include <linux/ide.h>
24 #include <linux/seq_file.h>
25 #include <linux/platform_device.h>
27 #include <linux/initrd.h>
28 #include <linux/root_dev.h>
29 #include <linux/smp.h>
32 #include <asm/machdep.h>
34 #include <asm/mv64x60.h>
35 #include <asm/ppcboot.h>
36 #include <platforms/hdpu.h>
37 #include <linux/mv643xx.h>
38 #include <linux/hdpu_features.h>
39 #include <linux/device.h>
40 #include <linux/mtd/physmap.h>
42 #define BOARD_VENDOR "Sky Computers"
43 #define BOARD_MACHINE "HDPU-CB-A"
46 int ppcboot_bd_valid = 0;
48 static mv64x60_handle_t bh;
50 extern char cmd_line[];
52 unsigned long hdpu_find_end_of_memory(void);
53 void hdpu_mpsc_progress(char *s, unsigned short hex);
54 void hdpu_heartbeat(void);
56 static void parse_bootinfo(unsigned long r3,
57 unsigned long r4, unsigned long r5,
58 unsigned long r6, unsigned long r7);
59 static void hdpu_set_l1pe(void);
60 static void hdpu_cpustate_set(unsigned char new_state);
62 static DEFINE_SPINLOCK(timebase_lock);
63 static unsigned int timebase_upper = 0, timebase_lower = 0;
64 extern int smp_tb_synchronized;
66 void __devinit hdpu_tben_give(void);
67 void __devinit hdpu_tben_take(void);
71 hdpu_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
73 struct pci_controller *hose = pci_bus_to_hose(dev->bus->number);
75 if (hose->index == 0) {
76 static char pci_irq_table[][4] = {
77 {HDPU_PCI_0_IRQ, 0, 0, 0},
78 {HDPU_PCI_0_IRQ, 0, 0, 0},
81 const long min_idsel = 1, max_idsel = 2, irqs_per_slot = 4;
82 return PCI_IRQ_TABLE_LOOKUP;
84 static char pci_irq_table[][4] = {
85 {HDPU_PCI_1_IRQ, 0, 0, 0},
88 const long min_idsel = 1, max_idsel = 1, irqs_per_slot = 4;
89 return PCI_IRQ_TABLE_LOOKUP;
93 static void __init hdpu_intr_setup(void)
95 mv64x60_write(&bh, MV64x60_GPP_IO_CNTL,
96 (1 | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5) |
97 (1 << 6) | (1 << 7) | (1 << 12) | (1 << 16) |
98 (1 << 18) | (1 << 19) | (1 << 20) | (1 << 21) |
99 (1 << 22) | (1 << 23) | (1 << 24) | (1 << 25) |
100 (1 << 26) | (1 << 27) | (1 << 28) | (1 << 29)));
102 /* XXXX Erranum FEr PCI-#8 */
103 mv64x60_clr_bits(&bh, MV64x60_PCI0_CMD, (1 << 5) | (1 << 9));
104 mv64x60_clr_bits(&bh, MV64x60_PCI1_CMD, (1 << 5) | (1 << 9));
107 * Dismiss and then enable interrupt on GPP interrupt cause
110 mv64x60_write(&bh, MV64x60_GPP_INTR_CAUSE, ~((1 << 8) | (1 << 13)));
111 mv64x60_set_bits(&bh, MV64x60_GPP_INTR_MASK, (1 << 8) | (1 << 13));
114 * Dismiss and then enable interrupt on CPU #0 high cause reg
115 * BIT25 summarizes GPP interrupts 8-15
117 mv64x60_set_bits(&bh, MV64360_IC_CPU0_INTR_MASK_HI, (1 << 25));
120 static void __init hdpu_setup_peripherals(void)
124 mv64x60_set_32bit_window(&bh, MV64x60_CPU2BOOT_WIN,
125 HDPU_EMB_FLASH_BASE, HDPU_EMB_FLASH_SIZE, 0);
126 bh.ci->enable_window_32bit(&bh, MV64x60_CPU2BOOT_WIN);
128 mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_0_WIN,
129 HDPU_TBEN_BASE, HDPU_TBEN_SIZE, 0);
130 bh.ci->enable_window_32bit(&bh, MV64x60_CPU2DEV_0_WIN);
132 mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_1_WIN,
133 HDPU_NEXUS_ID_BASE, HDPU_NEXUS_ID_SIZE, 0);
134 bh.ci->enable_window_32bit(&bh, MV64x60_CPU2DEV_1_WIN);
136 mv64x60_set_32bit_window(&bh, MV64x60_CPU2SRAM_WIN,
137 HDPU_INTERNAL_SRAM_BASE,
138 HDPU_INTERNAL_SRAM_SIZE, 0);
139 bh.ci->enable_window_32bit(&bh, MV64x60_CPU2SRAM_WIN);
141 bh.ci->disable_window_32bit(&bh, MV64x60_ENET2MEM_4_WIN);
142 mv64x60_set_32bit_window(&bh, MV64x60_ENET2MEM_4_WIN, 0, 0, 0);
144 mv64x60_clr_bits(&bh, MV64x60_PCI0_PCI_DECODE_CNTL, (1 << 3));
145 mv64x60_clr_bits(&bh, MV64x60_PCI1_PCI_DECODE_CNTL, (1 << 3));
146 mv64x60_clr_bits(&bh, MV64x60_TIMR_CNTR_0_3_CNTL,
147 ((1 << 0) | (1 << 8) | (1 << 16) | (1 << 24)));
149 /* Enable pipelining */
150 mv64x60_set_bits(&bh, MV64x60_CPU_CONFIG, (1 << 13));
151 /* Enable Snoop Pipelineing */
152 mv64x60_set_bits(&bh, MV64360_D_UNIT_CONTROL_HIGH, (1 << 24));
155 * Change DRAM read buffer assignment.
156 * Assign read buffer 0 dedicated only for CPU,
157 * and the rest read buffer 1.
159 val = mv64x60_read(&bh, MV64360_SDRAM_CONFIG);
160 val = val & 0x03ffffff;
161 val = val | 0xf8000000;
162 mv64x60_write(&bh, MV64360_SDRAM_CONFIG, val);
165 * Configure internal SRAM -
166 * Cache coherent write back, if CONFIG_MV64360_SRAM_CACHE_COHERENT set
168 * Parity error propagation
169 * Arbitration not parked for CPU only
170 * Other bits are reserved.
172 #ifdef CONFIG_MV64360_SRAM_CACHE_COHERENT
173 mv64x60_write(&bh, MV64360_SRAM_CONFIG, 0x001600b2);
175 mv64x60_write(&bh, MV64360_SRAM_CONFIG, 0x001600b0);
181 static void __init hdpu_setup_bridge(void)
183 struct mv64x60_setup_info si;
186 memset(&si, 0, sizeof(si));
188 si.phys_reg_base = HDPU_BRIDGE_REG_BASE;
189 si.pci_0.enable_bus = 1;
190 si.pci_0.pci_io.cpu_base = HDPU_PCI0_IO_START_PROC_ADDR;
191 si.pci_0.pci_io.pci_base_hi = 0;
192 si.pci_0.pci_io.pci_base_lo = HDPU_PCI0_IO_START_PCI_ADDR;
193 si.pci_0.pci_io.size = HDPU_PCI0_IO_SIZE;
194 si.pci_0.pci_io.swap = MV64x60_CPU2PCI_SWAP_NONE;
195 si.pci_0.pci_mem[0].cpu_base = HDPU_PCI0_MEM_START_PROC_ADDR;
196 si.pci_0.pci_mem[0].pci_base_hi = HDPU_PCI0_MEM_START_PCI_HI_ADDR;
197 si.pci_0.pci_mem[0].pci_base_lo = HDPU_PCI0_MEM_START_PCI_LO_ADDR;
198 si.pci_0.pci_mem[0].size = HDPU_PCI0_MEM_SIZE;
199 si.pci_0.pci_mem[0].swap = MV64x60_CPU2PCI_SWAP_NONE;
200 si.pci_0.pci_cmd_bits = 0;
201 si.pci_0.latency_timer = 0x80;
203 si.pci_1.enable_bus = 1;
204 si.pci_1.pci_io.cpu_base = HDPU_PCI1_IO_START_PROC_ADDR;
205 si.pci_1.pci_io.pci_base_hi = 0;
206 si.pci_1.pci_io.pci_base_lo = HDPU_PCI1_IO_START_PCI_ADDR;
207 si.pci_1.pci_io.size = HDPU_PCI1_IO_SIZE;
208 si.pci_1.pci_io.swap = MV64x60_CPU2PCI_SWAP_NONE;
209 si.pci_1.pci_mem[0].cpu_base = HDPU_PCI1_MEM_START_PROC_ADDR;
210 si.pci_1.pci_mem[0].pci_base_hi = HDPU_PCI1_MEM_START_PCI_HI_ADDR;
211 si.pci_1.pci_mem[0].pci_base_lo = HDPU_PCI1_MEM_START_PCI_LO_ADDR;
212 si.pci_1.pci_mem[0].size = HDPU_PCI1_MEM_SIZE;
213 si.pci_1.pci_mem[0].swap = MV64x60_CPU2PCI_SWAP_NONE;
214 si.pci_1.pci_cmd_bits = 0;
215 si.pci_1.latency_timer = 0x80;
217 for (i = 0; i < MV64x60_CPU2MEM_WINDOWS; i++) {
218 #if defined(CONFIG_NOT_COHERENT_CACHE)
219 si.cpu_prot_options[i] = 0;
220 si.enet_options[i] = MV64360_ENET2MEM_SNOOP_NONE;
221 si.mpsc_options[i] = MV64360_MPSC2MEM_SNOOP_NONE;
222 si.idma_options[i] = MV64360_IDMA2MEM_SNOOP_NONE;
224 si.pci_1.acc_cntl_options[i] =
225 MV64360_PCI_ACC_CNTL_SNOOP_NONE |
226 MV64360_PCI_ACC_CNTL_SWAP_NONE |
227 MV64360_PCI_ACC_CNTL_MBURST_128_BYTES |
228 MV64360_PCI_ACC_CNTL_RDSIZE_256_BYTES;
230 si.pci_0.acc_cntl_options[i] =
231 MV64360_PCI_ACC_CNTL_SNOOP_NONE |
232 MV64360_PCI_ACC_CNTL_SWAP_NONE |
233 MV64360_PCI_ACC_CNTL_MBURST_128_BYTES |
234 MV64360_PCI_ACC_CNTL_RDSIZE_256_BYTES;
237 si.cpu_prot_options[i] = 0;
238 si.enet_options[i] = MV64360_ENET2MEM_SNOOP_WB; /* errata */
239 si.mpsc_options[i] = MV64360_MPSC2MEM_SNOOP_WB; /* errata */
240 si.idma_options[i] = MV64360_IDMA2MEM_SNOOP_WB; /* errata */
242 si.pci_0.acc_cntl_options[i] =
243 MV64360_PCI_ACC_CNTL_SNOOP_WB |
244 MV64360_PCI_ACC_CNTL_SWAP_NONE |
245 MV64360_PCI_ACC_CNTL_MBURST_32_BYTES |
246 MV64360_PCI_ACC_CNTL_RDSIZE_256_BYTES;
248 si.pci_1.acc_cntl_options[i] =
249 MV64360_PCI_ACC_CNTL_SNOOP_WB |
250 MV64360_PCI_ACC_CNTL_SWAP_NONE |
251 MV64360_PCI_ACC_CNTL_MBURST_32_BYTES |
252 MV64360_PCI_ACC_CNTL_RDSIZE_256_BYTES;
256 hdpu_cpustate_set(CPUSTATE_KERNEL_MAJOR | CPUSTATE_KERNEL_INIT_PCI);
258 /* Lookup PCI host bridges */
259 mv64x60_init(&bh, &si);
260 pci_dram_offset = 0; /* System mem at same addr on PCI & cpu bus */
261 ppc_md.pci_swizzle = common_swizzle;
262 ppc_md.pci_map_irq = hdpu_map_irq;
264 mv64x60_set_bus(&bh, 0, 0);
265 bh.hose_a->first_busno = 0;
266 bh.hose_a->last_busno = 0xff;
267 bh.hose_a->last_busno = pciauto_bus_scan(bh.hose_a, 0);
269 bh.hose_b->first_busno = bh.hose_a->last_busno + 1;
270 mv64x60_set_bus(&bh, 1, bh.hose_b->first_busno);
271 bh.hose_b->last_busno = 0xff;
272 bh.hose_b->last_busno = pciauto_bus_scan(bh.hose_b,
273 bh.hose_b->first_busno);
275 ppc_md.pci_exclude_device = mv64x60_pci_exclude_device;
277 hdpu_cpustate_set(CPUSTATE_KERNEL_MAJOR | CPUSTATE_KERNEL_INIT_REG);
279 * Enabling of PCI internal-vs-external arbitration
280 * is a platform- and errata-dependent decision.
285 #if defined(CONFIG_SERIAL_MPSC_CONSOLE)
286 static void __init hdpu_early_serial_map(void)
289 static char first_time = 1;
291 #if defined(CONFIG_KGDB_TTYS0)
293 #elif defined(CONFIG_KGDB_TTYS1)
296 #error "Invalid kgdb_tty port"
300 gt_early_mpsc_init(KGDB_PORT,
301 B9600 | CS8 | CREAD | HUPCL | CLOCAL);
310 static void hdpu_init2(void)
315 #if defined(CONFIG_MV643XX_ETH)
316 static void __init hdpu_fixup_eth_pdata(struct platform_device *pd)
319 struct mv643xx_eth_platform_data *eth_pd;
320 eth_pd = pd->dev.platform_data;
322 eth_pd->force_phy_addr = 1;
323 eth_pd->phy_addr = pd->id;
324 eth_pd->speed = SPEED_100;
325 eth_pd->duplex = DUPLEX_FULL;
326 eth_pd->tx_queue_size = 400;
327 eth_pd->rx_queue_size = 800;
331 static void __init hdpu_fixup_mpsc_pdata(struct platform_device *pd)
334 struct mpsc_pdata *pdata;
336 pdata = (struct mpsc_pdata *)pd->dev.platform_data;
338 pdata->max_idle = 40;
339 if (ppcboot_bd_valid)
340 pdata->default_baud = ppcboot_bd.bi_baudrate;
342 pdata->default_baud = HDPU_DEFAULT_BAUD;
343 pdata->brg_clk_src = HDPU_MPSC_CLK_SRC;
344 pdata->brg_clk_freq = HDPU_MPSC_CLK_FREQ;
347 #if defined(CONFIG_HDPU_FEATURES)
348 static void __init hdpu_fixup_cpustate_pdata(struct platform_device *pd)
350 struct platform_device *pds[1];
352 mv64x60_pd_fixup(&bh, pds, 1);
356 static int __init hdpu_platform_notify(struct device *dev)
360 void ((*rtn) (struct platform_device * pdev));
363 MPSC_CTLR_NAME ".0", hdpu_fixup_mpsc_pdata},
364 #if defined(CONFIG_MV643XX_ETH)
366 MV643XX_ETH_NAME ".0", hdpu_fixup_eth_pdata},
368 #if defined(CONFIG_HDPU_FEATURES)
370 HDPU_CPUSTATE_NAME ".0", hdpu_fixup_cpustate_pdata},
373 struct platform_device *pdev;
376 if (dev && dev->bus_id)
377 for (i = 0; i < ARRAY_SIZE(dev_map); i++)
378 if (!strncmp(dev->bus_id, dev_map[i].bus_id,
381 pdev = container_of(dev,
382 struct platform_device,
384 dev_map[i].rtn(pdev);
390 static void __init hdpu_setup_arch(void)
393 ppc_md.progress("hdpu_setup_arch: enter", 0);
394 #ifdef CONFIG_BLK_DEV_INITRD
396 ROOT_DEV = Root_RAM0;
399 #ifdef CONFIG_ROOT_NFS
402 ROOT_DEV = Root_SDA2;
405 ppc_md.heartbeat = hdpu_heartbeat;
407 ppc_md.heartbeat_reset = HZ;
408 ppc_md.heartbeat_count = 1;
411 ppc_md.progress("hdpu_setup_arch: Enabling L2 cache", 0);
413 /* Enable L1 Parity Bits */
416 /* Enable L2 and L3 caches (if 745x) */
417 _set_L2CR(0x80080000);
420 ppc_md.progress("hdpu_setup_arch: enter", 0);
424 hdpu_setup_peripherals();
426 #ifdef CONFIG_SERIAL_MPSC_CONSOLE
427 hdpu_early_serial_map();
430 printk("SKY HDPU Compute Blade \n");
433 ppc_md.progress("hdpu_setup_arch: exit", 0);
435 hdpu_cpustate_set(CPUSTATE_KERNEL_MAJOR | CPUSTATE_KERNEL_OK);
438 static void __init hdpu_init_irq(void)
443 static void __init hdpu_set_l1pe()
446 asm volatile ("mfspr %0, 1011":"=r" (ictrl):);
447 ictrl |= ICTRL_EICE | ICTRL_EDC | ICTRL_EICP;
448 asm volatile ("mtspr 1011, %0"::"r" (ictrl));
452 * Set BAT 1 to map 0xf1000000 to end of physical memory space.
454 static __inline__ void hdpu_set_bat(void)
457 mtspr(SPRN_DBAT1U, 0xf10001fe);
458 mtspr(SPRN_DBAT1L, 0xf100002a);
464 unsigned long __init hdpu_find_end_of_memory(void)
466 return mv64x60_get_mem_size(CONFIG_MV64X60_NEW_BASE,
467 MV64x60_TYPE_MV64360);
470 static void hdpu_reset_board(void)
472 volatile int infinite = 1;
474 hdpu_cpustate_set(CPUSTATE_KERNEL_MAJOR | CPUSTATE_KERNEL_RESET);
478 /* Clear all the LEDs */
479 mv64x60_write(&bh, MV64x60_GPP_VALUE_CLR, ((1 << 4) |
480 (1 << 5) | (1 << 6)));
482 /* disable and invalidate the L2 cache */
486 /* flush and disable L1 I/D cache */
495 "isync\n" "sync\n" "mtspr 1008,5\n" "isync\n" "sync\n");
497 /* Hit the reset bit */
498 mv64x60_write(&bh, MV64x60_GPP_VALUE_CLR, (1 << 3));
506 static void hdpu_restart(char *cmd)
508 volatile ulong i = 10000000;
513 panic("restart failed\n");
516 static void hdpu_halt(void)
520 hdpu_cpustate_set(CPUSTATE_KERNEL_MAJOR | CPUSTATE_KERNEL_HALT);
522 /* Clear all the LEDs */
523 mv64x60_write(&bh, MV64x60_GPP_VALUE_CLR, ((1 << 4) | (1 << 5) |
529 static void hdpu_power_off(void)
535 static int hdpu_show_cpuinfo(struct seq_file *m)
539 pvid = mfspr(SPRN_PVR);
540 seq_printf(m, "vendor\t\t: Sky Computers\n");
541 seq_printf(m, "machine\t\t: HDPU Compute Blade\n");
542 seq_printf(m, "PVID\t\t: 0x%x, vendor: %s\n",
543 pvid, (pvid & (1 << 15) ? "IBM" : "Motorola"));
548 static void __init hdpu_calibrate_decr(void)
552 if (ppcboot_bd_valid)
553 freq = ppcboot_bd.bi_busfreq / 4;
557 printk("time_init: decrementer frequency = %lu.%.6lu MHz\n",
558 freq / 1000000, freq % 1000000);
560 tb_ticks_per_jiffy = freq / HZ;
561 tb_to_us = mulhwu_scale_factor(freq, 1000000);
566 static void parse_bootinfo(unsigned long r3,
567 unsigned long r4, unsigned long r5,
568 unsigned long r6, unsigned long r7)
571 char *cmdline_start = NULL;
575 if ((r3 & 0xf0000000) == 0)
577 if ((r3 & 0xf0000000) == KERNELBASE) {
580 memcpy(&ppcboot_bd, bd, sizeof(ppcboot_bd));
581 ppcboot_bd_valid = 1;
584 #ifdef CONFIG_BLK_DEV_INITRD
585 if (r4 && r5 && r5 > r4) {
586 if ((r4 & 0xf0000000) == 0)
588 if ((r5 & 0xf0000000) == 0)
590 if ((r4 & 0xf0000000) == KERNELBASE) {
593 initrd_below_start_ok = 1;
596 #endif /* CONFIG_BLK_DEV_INITRD */
598 if (r6 && r7 && r7 > r6) {
599 if ((r6 & 0xf0000000) == 0)
601 if ((r7 & 0xf0000000) == 0)
603 if ((r6 & 0xf0000000) == KERNELBASE) {
604 cmdline_start = (void *)r6;
605 cmdline_len = (r7 - r6);
606 strncpy(cmd_line, cmdline_start, cmdline_len);
611 #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
613 hdpu_ide_request_region(ide_ioreg_t from, unsigned int extent, const char *name)
615 request_region(from, extent, name);
619 static void hdpu_ide_release_region(ide_ioreg_t from, unsigned int extent)
621 release_region(from, extent);
626 hdpu_ide_pci_init_hwif_ports(hw_regs_t * hw, ide_ioreg_t data_port,
627 ide_ioreg_t ctrl_port, int *irq)
631 pci_for_each_dev(dev) {
632 if (((dev->class >> 8) == PCI_CLASS_STORAGE_IDE) ||
633 ((dev->class >> 8) == PCI_CLASS_STORAGE_RAID)) {
646 void hdpu_heartbeat(void)
648 if (mv64x60_read(&bh, MV64x60_GPP_VALUE) & (1 << 5))
649 mv64x60_write(&bh, MV64x60_GPP_VALUE_CLR, (1 << 5));
651 mv64x60_write(&bh, MV64x60_GPP_VALUE_SET, (1 << 5));
653 ppc_md.heartbeat_count = ppc_md.heartbeat_reset;
657 static void __init hdpu_map_io(void)
659 io_block_mapping(0xf1000000, 0xf1000000, 0x20000, _PAGE_IO);
663 char hdpu_smp0[] = "SMP Cpu #0";
664 char hdpu_smp1[] = "SMP Cpu #1";
666 static irqreturn_t hdpu_smp_cpu0_int_handler(int irq, void *dev_id,
667 struct pt_regs *regs)
669 volatile unsigned int doorbell;
671 doorbell = mv64x60_read(&bh, MV64360_CPU0_DOORBELL);
673 /* Ack the doorbell interrupts */
674 mv64x60_write(&bh, MV64360_CPU0_DOORBELL_CLR, doorbell);
677 smp_message_recv(0, regs);
680 smp_message_recv(1, regs);
683 smp_message_recv(2, regs);
686 smp_message_recv(3, regs);
691 static irqreturn_t hdpu_smp_cpu1_int_handler(int irq, void *dev_id,
692 struct pt_regs *regs)
694 volatile unsigned int doorbell;
696 doorbell = mv64x60_read(&bh, MV64360_CPU1_DOORBELL);
698 /* Ack the doorbell interrupts */
699 mv64x60_write(&bh, MV64360_CPU1_DOORBELL_CLR, doorbell);
702 smp_message_recv(0, regs);
705 smp_message_recv(1, regs);
708 smp_message_recv(2, regs);
711 smp_message_recv(3, regs);
716 static void smp_hdpu_CPU_two(void)
722 "mtspr 26, 3\n" "li 4,0\n" "mtspr 27,4\n" "rfi");
726 static int smp_hdpu_probe(void)
731 cpu_count_reg = ioremap(HDPU_NEXUS_ID_BASE, HDPU_NEXUS_ID_SIZE);
733 num_cpus = (*cpu_count_reg >> 20) & 0x3;
734 iounmap(cpu_count_reg);
737 /* Validate the bits in the CPLD. If we could not map the reg, return 2.
738 * If the register reported 0 or 3, return 2.
739 * Older CPLD revisions set these bits to all ones (val = 3).
741 if ((num_cpus < 1) || (num_cpus > 2)) {
743 ("Unable to determine the number of processors %d . deafulting to 2.\n",
751 smp_hdpu_message_pass(int target, int msg)
754 printk("SMP %d: smp_message_pass: unknown msg %d\n",
755 smp_processor_id(), msg);
760 mv64x60_write(&bh, MV64360_CPU0_DOORBELL, 1 << msg);
761 mv64x60_write(&bh, MV64360_CPU1_DOORBELL, 1 << msg);
763 case MSG_ALL_BUT_SELF:
764 if (smp_processor_id())
765 mv64x60_write(&bh, MV64360_CPU0_DOORBELL, 1 << msg);
767 mv64x60_write(&bh, MV64360_CPU1_DOORBELL, 1 << msg);
771 mv64x60_write(&bh, MV64360_CPU0_DOORBELL, 1 << msg);
773 mv64x60_write(&bh, MV64360_CPU1_DOORBELL, 1 << msg);
778 static void smp_hdpu_kick_cpu(int nr)
780 volatile unsigned int *bootaddr;
783 ppc_md.progress("smp_hdpu_kick_cpu", 0);
785 hdpu_cpustate_set(CPUSTATE_KERNEL_MAJOR | CPUSTATE_KERNEL_CPU1_KICK);
787 /* Disable BootCS. Must also reduce the windows size to zero. */
788 bh.ci->disable_window_32bit(&bh, MV64x60_CPU2BOOT_WIN);
789 mv64x60_set_32bit_window(&bh, MV64x60_CPU2BOOT_WIN, 0, 0, 0);
791 bootaddr = ioremap(HDPU_INTERNAL_SRAM_BASE, HDPU_INTERNAL_SRAM_SIZE);
794 ppc_md.progress("smp_hdpu_kick_cpu: ioremap failed", 0);
798 memcpy((void *)(bootaddr + 0x40), (void *)&smp_hdpu_CPU_two, 0x20);
800 /* map SRAM to 0xfff00000 */
801 bh.ci->disable_window_32bit(&bh, MV64x60_CPU2SRAM_WIN);
803 mv64x60_set_32bit_window(&bh, MV64x60_CPU2SRAM_WIN,
804 0xfff00000, HDPU_INTERNAL_SRAM_SIZE, 0);
805 bh.ci->enable_window_32bit(&bh, MV64x60_CPU2SRAM_WIN);
807 /* Enable CPU1 arbitration */
808 mv64x60_clr_bits(&bh, MV64x60_CPU_MASTER_CNTL, (1 << 9));
811 * Wait 100mSecond until other CPU has reached __secondary_start.
812 * When it reaches, it is permittable to rever the SRAM mapping etc...
815 *(unsigned long *)KERNELBASE = nr;
816 asm volatile ("dcbf 0,%0"::"r" (KERNELBASE):"memory");
820 /* Set up window for internal sram (256KByte insize) */
821 bh.ci->disable_window_32bit(&bh, MV64x60_CPU2SRAM_WIN);
822 mv64x60_set_32bit_window(&bh, MV64x60_CPU2SRAM_WIN,
823 HDPU_INTERNAL_SRAM_BASE,
824 HDPU_INTERNAL_SRAM_SIZE, 0);
825 bh.ci->enable_window_32bit(&bh, MV64x60_CPU2SRAM_WIN);
827 * Set up windows for embedded FLASH (using boot CS window).
830 bh.ci->disable_window_32bit(&bh, MV64x60_CPU2BOOT_WIN);
831 mv64x60_set_32bit_window(&bh, MV64x60_CPU2BOOT_WIN,
832 HDPU_EMB_FLASH_BASE, HDPU_EMB_FLASH_SIZE, 0);
833 bh.ci->enable_window_32bit(&bh, MV64x60_CPU2BOOT_WIN);
836 static void smp_hdpu_setup_cpu(int cpu_nr)
840 ppc_md.progress("smp_hdpu_setup_cpu 0", 0);
841 mv64x60_write(&bh, MV64360_CPU0_DOORBELL_CLR, 0xff);
842 mv64x60_write(&bh, MV64360_CPU0_DOORBELL_MASK, 0xff);
843 request_irq(60, hdpu_smp_cpu0_int_handler,
844 SA_INTERRUPT, hdpu_smp0, 0);
849 ppc_md.progress("smp_hdpu_setup_cpu 1", 0);
851 hdpu_cpustate_set(CPUSTATE_KERNEL_MAJOR |
852 CPUSTATE_KERNEL_CPU1_OK);
854 /* Enable L1 Parity Bits */
857 /* Enable L2 cache */
859 _set_L2CR(0x80080000);
861 mv64x60_write(&bh, MV64360_CPU1_DOORBELL_CLR, 0x0);
862 mv64x60_write(&bh, MV64360_CPU1_DOORBELL_MASK, 0xff);
863 request_irq(28, hdpu_smp_cpu1_int_handler,
864 SA_INTERRUPT, hdpu_smp1, 0);
869 void __devinit hdpu_tben_give()
871 volatile unsigned long *val = 0;
873 /* By writing 0 to the TBEN_BASE, the timebases is frozen */
874 val = ioremap(HDPU_TBEN_BASE, 4);
878 spin_lock(&timebase_lock);
879 timebase_upper = get_tbu();
880 timebase_lower = get_tbl();
881 spin_unlock(&timebase_lock);
883 while (timebase_upper || timebase_lower)
886 /* By writing 1 to the TBEN_BASE, the timebases is thawed */
894 void __devinit hdpu_tben_take()
896 while (!(timebase_upper || timebase_lower))
899 spin_lock(&timebase_lock);
900 set_tb(timebase_upper, timebase_lower);
903 spin_unlock(&timebase_lock);
906 static struct smp_ops_t hdpu_smp_ops = {
907 .message_pass = smp_hdpu_message_pass,
908 .probe = smp_hdpu_probe,
909 .kick_cpu = smp_hdpu_kick_cpu,
910 .setup_cpu = smp_hdpu_setup_cpu,
911 .give_timebase = hdpu_tben_give,
912 .take_timebase = hdpu_tben_take,
914 #endif /* CONFIG_SMP */
917 platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
918 unsigned long r6, unsigned long r7)
920 parse_bootinfo(r3, r4, r5, r6, r7);
924 ppc_md.setup_arch = hdpu_setup_arch;
925 ppc_md.init = hdpu_init2;
926 ppc_md.show_cpuinfo = hdpu_show_cpuinfo;
927 ppc_md.init_IRQ = hdpu_init_irq;
928 ppc_md.get_irq = mv64360_get_irq;
929 ppc_md.restart = hdpu_restart;
930 ppc_md.power_off = hdpu_power_off;
931 ppc_md.halt = hdpu_halt;
932 ppc_md.find_end_of_memory = hdpu_find_end_of_memory;
933 ppc_md.calibrate_decr = hdpu_calibrate_decr;
934 ppc_md.setup_io_mappings = hdpu_map_io;
936 bh.p_base = CONFIG_MV64X60_NEW_BASE;
937 bh.v_base = (unsigned long *)bh.p_base;
941 #if defined(CONFIG_SERIAL_TEXT_DEBUG)
942 ppc_md.progress = hdpu_mpsc_progress; /* embedded UART */
943 mv64x60_progress_init(bh.p_base);
944 #endif /* CONFIG_SERIAL_TEXT_DEBUG */
947 smp_ops = &hdpu_smp_ops;
948 #endif /* CONFIG_SMP */
950 #if defined(CONFIG_SERIAL_MPSC) || defined(CONFIG_MV643XX_ETH)
951 platform_notify = hdpu_platform_notify;
956 #if defined(CONFIG_SERIAL_TEXT_DEBUG) && defined(CONFIG_SERIAL_MPSC_CONSOLE)
957 /* SMP safe version of the serial text debug routine. Uses Semaphore 0 */
958 void hdpu_mpsc_progress(char *s, unsigned short hex)
960 while (mv64x60_read(&bh, MV64360_WHO_AM_I) !=
961 mv64x60_read(&bh, MV64360_SEMAPHORE_0)) {
963 mv64x60_mpsc_progress(s, hex);
964 mv64x60_write(&bh, MV64360_SEMAPHORE_0, 0xff);
968 static void hdpu_cpustate_set(unsigned char new_state)
970 unsigned int state = (new_state << 21);
971 mv64x60_write(&bh, MV64x60_GPP_VALUE_CLR, (0xff << 21));
972 mv64x60_write(&bh, MV64x60_GPP_VALUE_CLR, state);
975 #ifdef CONFIG_MTD_PHYSMAP
976 static struct mtd_partition hdpu_partitions[] = {
985 .offset = 0x03400000,
988 .name = "Kernel Image",
990 .offset = 0x03C00000,
995 .offset = 0x03EC0000,
1000 .offset = 0x03F00000,
1005 static int __init hdpu_setup_mtd(void)
1008 physmap_set_partitions(hdpu_partitions, 5);
1012 arch_initcall(hdpu_setup_mtd);
1015 #ifdef CONFIG_HDPU_FEATURES
1017 static struct resource hdpu_cpustate_resources[] = {
1019 .name = "addr base",
1020 .start = MV64x60_GPP_VALUE_SET,
1021 .end = MV64x60_GPP_VALUE_CLR + 1,
1022 .flags = IORESOURCE_MEM,
1026 static struct resource hdpu_nexus_resources[] = {
1028 .name = "nexus register",
1029 .start = HDPU_NEXUS_ID_BASE,
1030 .end = HDPU_NEXUS_ID_BASE + HDPU_NEXUS_ID_SIZE,
1031 .flags = IORESOURCE_MEM,
1035 static struct platform_device hdpu_cpustate_device = {
1036 .name = HDPU_CPUSTATE_NAME,
1038 .num_resources = ARRAY_SIZE(hdpu_cpustate_resources),
1039 .resource = hdpu_cpustate_resources,
1042 static struct platform_device hdpu_nexus_device = {
1043 .name = HDPU_NEXUS_NAME,
1045 .num_resources = ARRAY_SIZE(hdpu_nexus_resources),
1046 .resource = hdpu_nexus_resources,
1049 static int __init hdpu_add_pds(void)
1051 platform_device_register(&hdpu_cpustate_device);
1052 platform_device_register(&hdpu_nexus_device);
1056 arch_initcall(hdpu_add_pds);