2 * arch/mips/ddb5074/setup.c -- NEC DDB Vrc-5074 setup routines
4 * Copyright (C) 2000 Geert Uytterhoeven <geert@sonycom.com>
5 * Sony Software Development Center Europe (SDCE), Brussels
7 #include <linux/config.h>
8 #include <linux/init.h>
9 #include <linux/kbd_ll.h>
10 #include <linux/kernel.h>
11 #include <linux/kdev_t.h>
12 #include <linux/types.h>
13 #include <linux/console.h>
14 #include <linux/sched.h>
15 #include <linux/mc146818rtc.h>
16 #include <linux/pc_keyb.h>
17 #include <linux/pci.h>
18 #include <linux/ide.h>
19 #include <linux/ioport.h>
20 #include <linux/irq.h>
22 #include <asm/addrspace.h>
23 #include <asm/bcache.h>
24 #include <asm/keyboard.h>
26 #include <asm/reboot.h>
27 #include <asm/gdb-stub.h>
29 #include <asm/nile4.h>
30 #include <asm/ddb5xxx/ddb5074.h>
31 #include <asm/ddb5xxx/ddb5xxx.h>
35 extern void rs_kgdb_hook(int);
36 extern void breakpoint(void);
39 extern struct ide_ops std_ide_ops;
40 extern struct kbd_ops std_kbd_ops;
41 extern struct rtc_ops ddb_rtc_ops;
43 static void (*back_to_prom) (void) = (void (*)(void)) 0xbfc00000;
45 static void ddb_machine_restart(char *command)
50 t = nile4_in32(NILE4_PCICTRL + 4);
52 nile4_out32(NILE4_PCICTRL + 4, t);
54 t = nile4_in32(NILE4_CPUSTAT);
56 nile4_out32(NILE4_CPUSTAT, t);
61 static void ddb_machine_halt(void)
63 printk("DDB Vrc-5074 halted.\n");
68 static void ddb_machine_power_off(void)
70 printk("DDB Vrc-5074 halted. Please turn off the power.\n");
75 extern void ddb_irq_setup(void);
76 extern void rtc_ds1386_init(unsigned long base);
78 extern void (*board_timer_setup) (struct irqaction * irq);
80 static void __init ddb_timer_init(struct irqaction *irq)
82 /* set the clock to 1 Hz */
83 nile4_out32(NILE4_T2CTRL, 1000000);
84 /* enable the General-Purpose Timer */
85 nile4_out32(NILE4_T2CTRL + 4, 0x00000001);
87 nile4_out32(NILE4_T2CNTR, 0);
88 /* enable interrupt */
89 setup_irq(nile4_to_irq(NILE4_INT_GPT), irq);
90 nile4_enable_irq(nile4_to_irq(NILE4_INT_GPT));
91 change_c0_status(ST0_IM,
92 IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4);
96 static void __init ddb_time_init(void)
98 /* we have ds1396 RTC chip */
99 rtc_ds1386_init(KSEG1ADDR(DDB_PCI_MEM_BASE));
104 void __init ddb_setup(void)
106 extern int panic_timeout;
108 irq_setup = ddb_irq_setup;
109 set_io_port_base(NILE4_PCI_IO_BASE);
110 isa_slot_offset = NILE4_PCI_MEM_BASE;
111 board_timer_setup = ddb_timer_init;
112 board_time_init = ddb_time_init;
115 _machine_restart = ddb_machine_restart;
116 _machine_halt = ddb_machine_halt;
117 _machine_power_off = ddb_machine_power_off;
119 #ifdef CONFIG_BLK_DEV_IDE
120 ide_ops = &std_ide_ops;
123 #ifdef CONFIG_PC_KEYB
124 kbd_ops = &std_kbd_ops;
127 rtc_ops = &ddb_rtc_ops;
129 ddb_out32(DDB_BAR0, 0);
131 ddb_set_pmr(DDB_PCIINIT0, DDB_PCICMD_IO, 0, 0x10);
132 ddb_set_pmr(DDB_PCIINIT1, DDB_PCICMD_MEM, DDB_PCI_MEM_BASE , 0x10);
135 conswitchp = &dummy_con;
138 /* Reboot on panic */
143 #define USE_NILE4_SERIAL 0
146 #define ns16550_in(reg) nile4_in8((reg)*8)
147 #define ns16550_out(reg, val) nile4_out8((reg)*8, (val))
149 #define NS16550_BASE (NILE4_PCI_IO_BASE+0x03f8)
150 static inline u8 ns16550_in(u32 reg)
152 return *(volatile u8 *) (NS16550_BASE + reg);
155 static inline void ns16550_out(u32 reg, u8 val)
157 *(volatile u8 *) (NS16550_BASE + reg) = val;
161 #define NS16550_RBR 0
162 #define NS16550_THR 0
163 #define NS16550_DLL 0
164 #define NS16550_IER 1
165 #define NS16550_DLM 1
166 #define NS16550_FCR 2
167 #define NS16550_IIR 2
168 #define NS16550_LCR 3
169 #define NS16550_MCR 4
170 #define NS16550_LSR 5
171 #define NS16550_MSR 6
172 #define NS16550_SCR 7
174 #define NS16550_LSR_DR 0x01 /* Data ready */
175 #define NS16550_LSR_OE 0x02 /* Overrun */
176 #define NS16550_LSR_PE 0x04 /* Parity error */
177 #define NS16550_LSR_FE 0x08 /* Framing error */
178 #define NS16550_LSR_BI 0x10 /* Break */
179 #define NS16550_LSR_THRE 0x20 /* Xmit holding register empty */
180 #define NS16550_LSR_TEMT 0x40 /* Xmitter empty */
181 #define NS16550_LSR_ERR 0x80 /* Error */
187 ns16550_out(NS16550_LCR, 0x80);
188 ns16550_out(NS16550_DLM, 0x00);
189 ns16550_out(NS16550_DLL, 0x36); /* 9600 baud */
190 ns16550_out(NS16550_LCR, 0x00);
191 ns16550_out(NS16550_LCR, 0x03);
192 ns16550_out(NS16550_FCR, 0x47);
200 while (!(ns16550_in(NS16550_LSR) & NS16550_LSR_THRE));
201 ns16550_out(NS16550_THR, c);
203 while (!(ns16550_in(NS16550_LSR) & NS16550_LSR_THRE));
204 ns16550_out(NS16550_THR, '\r');
208 void _puts(const char *s)
217 while (!(ns16550_in(NS16550_LSR) & NS16550_LSR_DR));
218 return ns16550_in(NS16550_RBR);
223 return (ns16550_in(NS16550_LSR) & NS16550_LSR_DR) != 0;
228 * Hexadecimal 7-segment LED
230 void ddb5074_led_hex(int hex)
237 * LEDs D2 and D3, connected to the GPIO pins of the PMU in the ALi M1543
239 struct pci_dev *pci_pmu = NULL;
241 void ddb5074_led_d2(int on)
246 pci_read_config_byte(pci_pmu, 0x7e, &t);
251 pci_write_config_byte(pci_pmu, 0x7e, t);
255 void ddb5074_led_d3(int on)
260 pci_read_config_byte(pci_pmu, 0x7e, &t);
265 pci_write_config_byte(pci_pmu, 0x7e, t);