2 * arch/powerpc/platforms/83xx/mpc834x_sys.c
4 * MPC834x SYS board specific routines
6 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
14 #include <linux/config.h>
15 #include <linux/stddef.h>
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/errno.h>
19 #include <linux/reboot.h>
20 #include <linux/pci.h>
21 #include <linux/kdev_t.h>
22 #include <linux/major.h>
23 #include <linux/console.h>
24 #include <linux/delay.h>
25 #include <linux/seq_file.h>
26 #include <linux/root_dev.h>
27 #include <linux/module.h>
28 #include <linux/fsl_devices.h>
30 #include <asm/system.h>
31 #include <asm/pgtable.h>
33 #include <asm/atomic.h>
36 #include <asm/machdep.h>
38 #include <asm/bootinfo.h>
39 #include <asm/pci-bridge.h>
40 #include <asm/mpc83xx.h>
42 #include <mm/mmu_decl.h>
45 #include <sysdev/fsl_soc.h>
50 unsigned long isa_io_base = 0;
51 unsigned long isa_mem_base = 0;
55 extern int mpc83xx_pci2_busno;
58 mpc83xx_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
60 static char pci_irq_table[][4] =
62 * PCI IDSEL/INTPIN->INTLINE
66 {PIRQA, PIRQB, PIRQC, PIRQD}, /* idsel 0x11 */
67 {PIRQC, PIRQD, PIRQA, PIRQB}, /* idsel 0x12 */
68 {PIRQD, PIRQA, PIRQB, PIRQC}, /* idsel 0x13 */
70 {PIRQA, PIRQB, PIRQC, PIRQD}, /* idsel 0x15 */
71 {PIRQD, PIRQA, PIRQB, PIRQC}, /* idsel 0x16 */
72 {PIRQC, PIRQD, PIRQA, PIRQB}, /* idsel 0x17 */
73 {PIRQB, PIRQC, PIRQD, PIRQA}, /* idsel 0x18 */
74 {0, 0, 0, 0}, /* idsel 0x19 */
75 {0, 0, 0, 0}, /* idsel 0x20 */
78 const long min_idsel = 0x11, max_idsel = 0x20, irqs_per_slot = 4;
79 return PCI_IRQ_TABLE_LOOKUP;
83 mpc83xx_exclude_device(u_char bus, u_char devfn)
85 if (bus == 0 && PCI_SLOT(devfn) == 0)
86 return PCIBIOS_DEVICE_NOT_FOUND;
87 if (mpc83xx_pci2_busno)
88 if (bus == (mpc83xx_pci2_busno) && PCI_SLOT(devfn) == 0)
89 return PCIBIOS_DEVICE_NOT_FOUND;
90 return PCIBIOS_SUCCESSFUL;
92 #endif /* CONFIG_PCI */
94 /* ************************************************************************
96 * Setup the architecture
100 mpc834x_sys_setup_arch(void)
102 struct device_node *np;
105 ppc_md.progress("mpc834x_sys_setup_arch()", 0);
107 np = of_find_node_by_type(NULL, "cpu");
109 unsigned int *fp = (int *) get_property(np, "clock-frequency", NULL);
111 loops_per_jiffy = *fp / HZ;
113 loops_per_jiffy = 50000000 / HZ;
118 for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
121 ppc_md.pci_swizzle = common_swizzle;
122 ppc_md.pci_map_irq = mpc83xx_map_irq;
123 ppc_md.pci_exclude_device = mpc83xx_exclude_device;
126 #ifdef CONFIG_ROOT_NFS
129 ROOT_DEV = Root_HDA1;
134 mpc834x_sys_init_IRQ(void)
138 IRQ_SENSE_LEVEL, /* EXT 1 */
139 IRQ_SENSE_LEVEL, /* EXT 2 */
142 IRQ_SENSE_LEVEL, /* EXT 4 */
143 IRQ_SENSE_LEVEL, /* EXT 5 */
144 IRQ_SENSE_LEVEL, /* EXT 6 */
145 IRQ_SENSE_LEVEL, /* EXT 7 */
154 ipic_init(get_immrbase() + 0x00700, 0, 0, senses, 8);
156 /* Initialize the default interrupt mapping priorities,
157 * in case the boot rom changed something on us.
159 ipic_set_default_priority();
162 #if defined(CONFIG_I2C_MPC) && defined(CONFIG_SENSORS_DS1374)
163 extern ulong ds1374_get_rtc_time(void);
164 extern int ds1374_set_rtc_time(ulong);
167 mpc834x_rtc_hookup(void)
171 ppc_md.get_rtc_time = ds1374_get_rtc_time;
172 ppc_md.set_rtc_time = ds1374_set_rtc_time;
175 tv.tv_sec = (ppc_md.get_rtc_time)();
176 do_settimeofday(&tv);
180 late_initcall(mpc834x_rtc_hookup);
184 mpc83xx_restart(char *cmd)
186 #define RST_OFFSET 0x00000900
187 #define RST_PROT_REG 0x00000018
188 #define RST_CTRL_REG 0x0000001c
191 // map reset register space
192 reg = ioremap(get_immrbase() + 0x900, 0xff);
196 /* enable software reset "RSTE" */
197 out_be32(reg + (RST_PROT_REG >> 2), 0x52535445);
199 /* set software hard reset */
200 out_be32(reg + (RST_CTRL_REG >> 2), 0x52535445);
205 mpc83xx_time_init(void)
207 #define SPCR_OFFSET 0x00000110
208 #define SPCR_TBEN 0x00400000
209 __be32 __iomem *spcr = ioremap(get_immrbase() + SPCR_OFFSET, 4);
213 out_be32(spcr, tmp|SPCR_TBEN);
222 /* setup the PowerPC module struct */
223 ppc_md.setup_arch = mpc834x_sys_setup_arch;
225 ppc_md.init_IRQ = mpc834x_sys_init_IRQ;
226 ppc_md.get_irq = ipic_get_irq;
228 ppc_md.restart = mpc83xx_restart;
230 ppc_md.time_init = mpc83xx_time_init;
231 ppc_md.set_rtc_time = NULL;
232 ppc_md.get_rtc_time = NULL;
233 ppc_md.calibrate_decr = generic_calibrate_decr;
235 ppc_md.progress = udbg_progress;
238 ppc_md.progress("mpc834x_sys_init(): exit", 0);