2 * arch/ppc/platforms/lopec_setup.c
4 * Setup routines for the Motorola LoPEC.
9 * 2001-2002 (c) MontaVista, Software, Inc. This file is licensed under
10 * the terms of the GNU General Public License version 2. This program
11 * is licensed "as is" without any warranty of any kind, whether express
15 #include <linux/config.h>
16 #include <linux/types.h>
17 #include <linux/delay.h>
18 #include <linux/pci_ids.h>
19 #include <linux/ioport.h>
20 #include <linux/init.h>
21 #include <linux/ide.h>
22 #include <linux/seq_file.h>
23 #include <linux/initrd.h>
24 #include <linux/console.h>
25 #include <linux/root_dev.h>
28 #include <asm/open_pic.h>
29 #include <asm/i8259.h>
31 #include <asm/bootinfo.h>
32 #include <asm/mpc10x.h>
33 #include <asm/hw_irq.h>
34 #include <asm/prep_nvram.h>
36 extern char saved_command_line[];
37 extern void lopec_find_bridges(void);
40 * Define all of the IRQ senses and polarities. Taken from the
41 * LoPEC Programmer's Reference Guide.
43 static u_char lopec_openpic_initsenses[16] __initdata = {
44 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* IRQ 0 */
45 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ 1 */
46 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* IRQ 2 */
47 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ 3 */
48 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* IRQ 4 */
49 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* IRQ 5 */
50 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ 6 */
51 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ 7 */
52 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ 8 */
53 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ 9 */
54 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ 10 */
55 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ 11 */
56 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ 12 */
57 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* IRQ 13 */
58 (IRQ_SENSE_EDGE | IRQ_POLARITY_NEGATIVE), /* IRQ 14 */
59 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE) /* IRQ 15 */
63 lopec_show_cpuinfo(struct seq_file *m)
65 seq_printf(m, "machine\t\t: Motorola LoPEC\n");
70 lopec_irq_canonicalize(u32 irq)
79 lopec_restart(char *cmd)
81 #define LOPEC_SYSSTAT1 0xffe00000
82 /* force a hard reset, if possible */
83 unsigned char reg = *((unsigned char *) LOPEC_SYSSTAT1);
85 *((unsigned char *) LOPEC_SYSSTAT1) = reg;
100 lopec_power_off(void)
105 #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
106 int lopec_ide_ports_known = 0;
107 static unsigned long lopec_ide_regbase[MAX_HWIFS];
108 static unsigned long lopec_ide_ctl_regbase[MAX_HWIFS];
109 static unsigned long lopec_idedma_regbase;
112 lopec_ide_probe(void)
114 struct pci_dev *dev = pci_find_device(PCI_VENDOR_ID_WINBOND,
115 PCI_DEVICE_ID_WINBOND_82C105,
117 lopec_ide_ports_known = 1;
120 lopec_ide_regbase[0] = dev->resource[0].start;
121 lopec_ide_regbase[1] = dev->resource[2].start;
122 lopec_ide_ctl_regbase[0] = dev->resource[1].start;
123 lopec_ide_ctl_regbase[1] = dev->resource[3].start;
124 lopec_idedma_regbase = dev->resource[4].start;
129 lopec_ide_default_irq(unsigned long base)
131 if (lopec_ide_ports_known == 0)
134 if (base == lopec_ide_regbase[0])
136 else if (base == lopec_ide_regbase[1])
143 lopec_ide_default_io_base(int index)
145 if (lopec_ide_ports_known == 0)
147 return lopec_ide_regbase[index];
151 lopec_ide_init_hwif_ports(hw_regs_t *hw, unsigned long data,
152 unsigned long ctl, int *irq)
154 unsigned long reg = data;
155 uint alt_status_base;
158 for(i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++)
159 hw->io_ports[i] = reg++;
161 if (data == lopec_ide_regbase[0]) {
162 alt_status_base = lopec_ide_ctl_regbase[0] + 2;
165 else if (data == lopec_ide_regbase[1]) {
166 alt_status_base = lopec_ide_ctl_regbase[1] + 2;
175 hw->io_ports[IDE_CONTROL_OFFSET] = ctl;
177 hw->io_ports[IDE_CONTROL_OFFSET] = alt_status_base;
183 #endif /* BLK_DEV_IDE */
191 * Provide the open_pic code with the correct table of interrupts.
193 OpenPIC_InitSenses = lopec_openpic_initsenses;
194 OpenPIC_NumInitSenses = sizeof(lopec_openpic_initsenses);
197 * We need to tell openpic_set_sources where things actually are.
198 * mpc10x_common will setup OpenPIC_Addr at ioremap(EUMB phys base +
199 * EPIC offset (0x40000)); The EPIC IRQ Register Address Map -
200 * Interrupt Source Configuration Registers gives these numbers
201 * as offsets starting at 0x50200, we need to adjust occordinly.
203 /* Map serial interrupts 0-15 */
204 openpic_set_sources(0, 16, OpenPIC_Addr + 0x10200);
205 /* Skip reserved space and map i2c and DMA Ch[01] */
206 openpic_set_sources(16, 3, OpenPIC_Addr + 0x11020);
207 /* Skip reserved space and map Message Unit Interrupt (I2O) */
208 openpic_set_sources(19, 1, OpenPIC_Addr + 0x110C0);
210 openpic_init(NUM_8259_INTERRUPTS);
211 /* We have a cascade on OpenPIC IRQ 0, Linux IRQ 16 */
212 openpic_hookup_cascade(NUM_8259_INTERRUPTS, "82c59 cascade",
215 /* Map i8259 interrupts */
216 for(i = 0; i < NUM_8259_INTERRUPTS; i++)
217 irq_desc[i].handler = &i8259_pic;
220 * The EPIC allows for a read in the range of 0xFEF00000 ->
221 * 0xFEFFFFFF to generate a PCI interrupt-acknowledge transaction.
223 i8259_init(0xfef00000);
227 lopec_request_io(void)
232 request_region(0x00, 0x20, "dma1");
233 request_region(0x20, 0x20, "pic1");
234 request_region(0x40, 0x20, "timer");
235 request_region(0x80, 0x10, "dma page reg");
236 request_region(0xa0, 0x20, "pic2");
237 request_region(0xc0, 0x20, "dma2");
242 device_initcall(lopec_request_io);
247 io_block_mapping(0xf0000000, 0xf0000000, 0x10000000, _PAGE_IO);
248 io_block_mapping(0xb0000000, 0xb0000000, 0x10000000, _PAGE_IO);
254 unsigned long batu, batl;
256 __asm__ __volatile__(
264 : "=r" (batu), "=r" (batl));
267 #ifdef CONFIG_SERIAL_TEXT_DEBUG
268 #include <linux/serial.h>
269 #include <linux/serialP.h>
270 #include <linux/serial_reg.h>
271 #include <asm/serial.h>
273 static struct serial_state rs_table[RS_TABLE_SIZE] = {
274 SERIAL_PORT_DFNS /* Defined in <asm/serial.h> */
277 volatile unsigned char *com_port;
278 volatile unsigned char *com_port_lsr;
281 serial_writechar(char c)
283 while ((*com_port_lsr & UART_LSR_THRE) == 0)
289 lopec_progress(char *s, unsigned short hex)
293 com_port = (volatile unsigned char *) rs_table[0].port;
294 com_port_lsr = com_port + UART_LSR;
296 while ((c = *s++) != 0)
299 /* Most messages don't have a newline in them */
300 serial_writechar('\n');
301 serial_writechar('\r');
303 #endif /* CONFIG_SERIAL_TEXT_DEBUG */
308 lopec_setup_arch(void)
311 TODC_INIT(TODC_TYPE_MK48T37, 0, 0,
312 ioremap(0xffe80000, 0x8000), 8);
314 loops_per_jiffy = 100000000/HZ;
316 lopec_find_bridges();
318 #ifdef CONFIG_BLK_DEV_INITRD
320 ROOT_DEV = Root_RAM0;
322 #elif defined(CONFIG_ROOT_NFS)
324 #elif defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
325 ROOT_DEV = Root_HDA1;
327 ROOT_DEV = Root_SDA1;
331 conswitchp = &dummy_con;
333 #ifdef CONFIG_PPCBUG_NVRAM
334 /* Read in NVRAM data */
337 /* if no bootargs, look in NVRAM */
338 if ( cmd_line[0] == '\0' ) {
340 bootargs = prep_nvram_get_var("bootargs");
341 if (bootargs != NULL) {
342 strcpy(cmd_line, bootargs);
344 strcpy(saved_command_line, cmd_line);
351 platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
352 unsigned long r6, unsigned long r7)
354 parse_bootinfo(find_bootinfo());
357 isa_io_base = MPC10X_MAPB_ISA_IO_BASE;
358 isa_mem_base = MPC10X_MAPB_ISA_MEM_BASE;
359 pci_dram_offset = MPC10X_MAPB_DRAM_OFFSET;
360 ISA_DMA_THRESHOLD = 0x00ffffff;
361 DMA_MODE_READ = 0x44;
362 DMA_MODE_WRITE = 0x48;
364 ppc_md.setup_arch = lopec_setup_arch;
365 ppc_md.show_cpuinfo = lopec_show_cpuinfo;
366 ppc_md.irq_canonicalize = lopec_irq_canonicalize;
367 ppc_md.init_IRQ = lopec_init_IRQ;
368 ppc_md.get_irq = openpic_get_irq;
370 ppc_md.restart = lopec_restart;
371 ppc_md.power_off = lopec_power_off;
372 ppc_md.halt = lopec_halt;
374 ppc_md.setup_io_mappings = lopec_map_io;
376 ppc_md.time_init = todc_time_init;
377 ppc_md.set_rtc_time = todc_set_rtc_time;
378 ppc_md.get_rtc_time = todc_get_rtc_time;
379 ppc_md.calibrate_decr = todc_calibrate_decr;
381 ppc_md.nvram_read_val = todc_direct_read_val;
382 ppc_md.nvram_write_val = todc_direct_write_val;
384 #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
385 ppc_ide_md.default_irq = lopec_ide_default_irq;
386 ppc_ide_md.default_io_base = lopec_ide_default_io_base;
387 ppc_ide_md.ide_init_hwif = lopec_ide_init_hwif_ports;
389 #ifdef CONFIG_SERIAL_TEXT_DEBUG
390 ppc_md.progress = lopec_progress;