2 * Setup routines for the Motorola LoPEC.
5 * Maintainer: Tom Rini <trini@kernel.crashing.org>
7 * 2001-2004 (c) MontaVista, Software, Inc. This file is licensed under
8 * the terms of the GNU General Public License version 2. This program
9 * is licensed "as is" without any warranty of any kind, whether express
13 #include <linux/types.h>
14 #include <linux/delay.h>
15 #include <linux/pci_ids.h>
16 #include <linux/ioport.h>
17 #include <linux/init.h>
18 #include <linux/seq_file.h>
19 #include <linux/initrd.h>
20 #include <linux/console.h>
21 #include <linux/root_dev.h>
22 #include <linux/pci.h>
24 #include <asm/machdep.h>
25 #include <asm/pci-bridge.h>
27 #include <asm/open_pic.h>
28 #include <asm/i8259.h>
30 #include <asm/bootinfo.h>
31 #include <asm/mpc10x.h>
32 #include <asm/hw_irq.h>
33 #include <asm/prep_nvram.h>
37 * Define all of the IRQ senses and polarities. Taken from the
38 * LoPEC Programmer's Reference Guide.
40 static u_char lopec_openpic_initsenses
[16] __initdata
= {
41 (IRQ_SENSE_LEVEL
| IRQ_POLARITY_POSITIVE
), /* IRQ 0 */
42 (IRQ_SENSE_LEVEL
| IRQ_POLARITY_NEGATIVE
), /* IRQ 1 */
43 (IRQ_SENSE_LEVEL
| IRQ_POLARITY_POSITIVE
), /* IRQ 2 */
44 (IRQ_SENSE_LEVEL
| IRQ_POLARITY_NEGATIVE
), /* IRQ 3 */
45 (IRQ_SENSE_LEVEL
| IRQ_POLARITY_POSITIVE
), /* IRQ 4 */
46 (IRQ_SENSE_LEVEL
| IRQ_POLARITY_POSITIVE
), /* IRQ 5 */
47 (IRQ_SENSE_LEVEL
| IRQ_POLARITY_NEGATIVE
), /* IRQ 6 */
48 (IRQ_SENSE_LEVEL
| IRQ_POLARITY_NEGATIVE
), /* IRQ 7 */
49 (IRQ_SENSE_LEVEL
| IRQ_POLARITY_NEGATIVE
), /* IRQ 8 */
50 (IRQ_SENSE_LEVEL
| IRQ_POLARITY_NEGATIVE
), /* IRQ 9 */
51 (IRQ_SENSE_LEVEL
| IRQ_POLARITY_NEGATIVE
), /* IRQ 10 */
52 (IRQ_SENSE_LEVEL
| IRQ_POLARITY_NEGATIVE
), /* IRQ 11 */
53 (IRQ_SENSE_LEVEL
| IRQ_POLARITY_NEGATIVE
), /* IRQ 12 */
54 (IRQ_SENSE_LEVEL
| IRQ_POLARITY_POSITIVE
), /* IRQ 13 */
55 (IRQ_SENSE_EDGE
| IRQ_POLARITY_NEGATIVE
), /* IRQ 14 */
56 (IRQ_SENSE_LEVEL
| IRQ_POLARITY_NEGATIVE
) /* IRQ 15 */
59 static inline int __init
60 lopec_map_irq(struct pci_dev
*dev
, unsigned char idsel
, unsigned char pin
)
63 static char pci_irq_table
[][4] = {
64 {16, 0, 0, 0}, /* ID 11 - Winbond */
65 {22, 0, 0, 0}, /* ID 12 - SCSI */
66 {0, 0, 0, 0}, /* ID 13 - nothing */
67 {17, 0, 0, 0}, /* ID 14 - 82559 Ethernet */
68 {27, 0, 0, 0}, /* ID 15 - USB */
69 {23, 0, 0, 0}, /* ID 16 - PMC slot 1 */
70 {24, 0, 0, 0}, /* ID 17 - PMC slot 2 */
71 {25, 0, 0, 0}, /* ID 18 - PCI slot */
72 {0, 0, 0, 0}, /* ID 19 - nothing */
73 {0, 0, 0, 0}, /* ID 20 - nothing */
74 {0, 0, 0, 0}, /* ID 21 - nothing */
75 {0, 0, 0, 0}, /* ID 22 - nothing */
76 {0, 0, 0, 0}, /* ID 23 - nothing */
77 {0, 0, 0, 0}, /* ID 24 - PMC slot 1b */
78 {0, 0, 0, 0}, /* ID 25 - nothing */
79 {0, 0, 0, 0} /* ID 26 - PMC Slot 2b */
81 const long min_idsel
= 11, max_idsel
= 26, irqs_per_slot
= 4;
83 irq
= PCI_IRQ_TABLE_LOOKUP
;
91 lopec_setup_winbond_83553(struct pci_controller
*hose
)
95 devfn
= PCI_DEVFN(11,0);
97 /* IDE interrupt routing (primary 14, secondary 15) */
98 early_write_config_byte(hose
, 0, devfn
, 0x43, 0xef);
99 /* PCI interrupt routing */
100 early_write_config_word(hose
, 0, devfn
, 0x44, 0x0000);
102 /* ISA-PCI address decoder */
103 early_write_config_byte(hose
, 0, devfn
, 0x48, 0xf0);
105 /* RTC, kb, not used in PPC */
106 early_write_config_byte(hose
, 0, devfn
, 0x4d, 0x00);
107 early_write_config_byte(hose
, 0, devfn
, 0x4e, 0x04);
108 devfn
= PCI_DEVFN(11, 1);
109 early_write_config_byte(hose
, 0, devfn
, 0x09, 0x8f);
110 early_write_config_dword(hose
, 0, devfn
, 0x40, 0x00ff0011);
114 lopec_find_bridges(void)
116 struct pci_controller
*hose
;
118 hose
= pcibios_alloc_controller();
122 hose
->first_busno
= 0;
123 hose
->last_busno
= 0xff;
125 if (mpc10x_bridge_init(hose
, MPC10X_MEM_MAP_B
, MPC10X_MEM_MAP_B
,
126 MPC10X_MAPB_EUMB_BASE
) == 0) {
128 hose
->mem_resources
[0].end
= 0xffffffff;
129 lopec_setup_winbond_83553(hose
);
130 hose
->last_busno
= pciauto_bus_scan(hose
, hose
->first_busno
);
131 ppc_md
.pci_swizzle
= common_swizzle
;
132 ppc_md
.pci_map_irq
= lopec_map_irq
;
137 lopec_show_cpuinfo(struct seq_file
*m
)
139 seq_printf(m
, "machine\t\t: Motorola LoPEC\n");
144 lopec_restart(char *cmd
)
146 #define LOPEC_SYSSTAT1 0xffe00000
147 /* force a hard reset, if possible */
148 unsigned char reg
= *((unsigned char *) LOPEC_SYSSTAT1
);
150 *((unsigned char *) LOPEC_SYSSTAT1
) = reg
;
154 #undef LOPEC_SYSSTAT1
165 lopec_power_off(void)
176 * Provide the open_pic code with the correct table of interrupts.
178 OpenPIC_InitSenses
= lopec_openpic_initsenses
;
179 OpenPIC_NumInitSenses
= sizeof(lopec_openpic_initsenses
);
181 mpc10x_set_openpic();
183 /* We have a cascade on OpenPIC IRQ 0, Linux IRQ 16 */
184 openpic_hookup_cascade(NUM_8259_INTERRUPTS
, "82c59 cascade",
188 * The EPIC allows for a read in the range of 0xFEF00000 ->
189 * 0xFEFFFFFF to generate a PCI interrupt-acknowledge transaction.
191 i8259_init(0xfef00000, 0);
195 lopec_request_io(void)
200 request_region(0x00, 0x20, "dma1");
201 request_region(0x20, 0x20, "pic1");
202 request_region(0x40, 0x20, "timer");
203 request_region(0x80, 0x10, "dma page reg");
204 request_region(0xa0, 0x20, "pic2");
205 request_region(0xc0, 0x20, "dma2");
210 device_initcall(lopec_request_io
);
215 io_block_mapping(0xf0000000, 0xf0000000, 0x10000000, _PAGE_IO
);
216 io_block_mapping(0xb0000000, 0xb0000000, 0x10000000, _PAGE_IO
);
220 * Set BAT 3 to map 0xf8000000 to end of physical memory space 1-to-1.
222 static __inline__
void
226 mtspr(SPRN_DBAT1U
, 0xf8000ffe);
227 mtspr(SPRN_DBAT1L
, 0xf800002a);
234 lopec_setup_arch(void)
237 TODC_INIT(TODC_TYPE_MK48T37
, 0, 0,
238 ioremap(0xffe80000, 0x8000), 8);
240 loops_per_jiffy
= 100000000/HZ
;
242 lopec_find_bridges();
244 #ifdef CONFIG_BLK_DEV_INITRD
246 ROOT_DEV
= Root_RAM0
;
248 #elif defined(CONFIG_ROOT_NFS)
250 #elif defined(CONFIG_BLK_DEV_IDEDISK)
251 ROOT_DEV
= Root_HDA1
;
253 ROOT_DEV
= Root_SDA1
;
256 #ifdef CONFIG_PPCBUG_NVRAM
257 /* Read in NVRAM data */
260 /* if no bootargs, look in NVRAM */
261 if ( cmd_line
[0] == '\0' ) {
263 bootargs
= prep_nvram_get_var("bootargs");
264 if (bootargs
!= NULL
) {
265 strcpy(cmd_line
, bootargs
);
267 strcpy(boot_command_line
, cmd_line
);
274 platform_init(unsigned long r3
, unsigned long r4
, unsigned long r5
,
275 unsigned long r6
, unsigned long r7
)
277 parse_bootinfo(find_bootinfo());
280 isa_io_base
= MPC10X_MAPB_ISA_IO_BASE
;
281 isa_mem_base
= MPC10X_MAPB_ISA_MEM_BASE
;
282 pci_dram_offset
= MPC10X_MAPB_DRAM_OFFSET
;
283 ISA_DMA_THRESHOLD
= 0x00ffffff;
284 DMA_MODE_READ
= 0x44;
285 DMA_MODE_WRITE
= 0x48;
286 ppc_do_canonicalize_irqs
= 1;
288 ppc_md
.setup_arch
= lopec_setup_arch
;
289 ppc_md
.show_cpuinfo
= lopec_show_cpuinfo
;
290 ppc_md
.init_IRQ
= lopec_init_IRQ
;
291 ppc_md
.get_irq
= openpic_get_irq
;
293 ppc_md
.restart
= lopec_restart
;
294 ppc_md
.power_off
= lopec_power_off
;
295 ppc_md
.halt
= lopec_halt
;
297 ppc_md
.setup_io_mappings
= lopec_map_io
;
299 ppc_md
.time_init
= todc_time_init
;
300 ppc_md
.set_rtc_time
= todc_set_rtc_time
;
301 ppc_md
.get_rtc_time
= todc_get_rtc_time
;
302 ppc_md
.calibrate_decr
= todc_calibrate_decr
;
304 ppc_md
.nvram_read_val
= todc_direct_read_val
;
305 ppc_md
.nvram_write_val
= todc_direct_write_val
;
307 #ifdef CONFIG_SERIAL_TEXT_DEBUG
308 ppc_md
.progress
= gen550_progress
;