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/sched.h>
14 #include <linux/pci.h>
15 #include <linux/ide.h>
16 #include <linux/ioport.h>
17 #include <linux/irq.h>
19 #include <asm/addrspace.h>
20 #include <asm/bcache.h>
22 #include <asm/reboot.h>
23 #include <asm/gdb-stub.h>
25 #include <asm/nile4.h>
26 #include <asm/ddb5xxx/ddb5074.h>
27 #include <asm/ddb5xxx/ddb5xxx.h>
29 static void (*back_to_prom) (void) = (void (*)(void)) 0xbfc00000;
31 static void ddb_machine_restart(char *command)
36 t = nile4_in32(NILE4_PCICTRL + 4);
38 nile4_out32(NILE4_PCICTRL + 4, t);
40 t = nile4_in32(NILE4_CPUSTAT);
42 nile4_out32(NILE4_CPUSTAT, t);
47 static void ddb_machine_halt(void)
49 printk("DDB Vrc-5074 halted.\n");
54 static void ddb_machine_power_off(void)
56 printk("DDB Vrc-5074 halted. Please turn off the power.\n");
61 extern void rtc_ds1386_init(unsigned long base);
63 extern void (*board_timer_setup) (struct irqaction * irq);
65 static void __init ddb_timer_init(struct irqaction *irq)
67 /* set the clock to 1 Hz */
68 nile4_out32(NILE4_T2CTRL, 1000000);
69 /* enable the General-Purpose Timer */
70 nile4_out32(NILE4_T2CTRL + 4, 0x00000001);
72 nile4_out32(NILE4_T2CNTR, 0);
73 /* enable interrupt */
74 setup_irq(nile4_to_irq(NILE4_INT_GPT), irq);
75 nile4_enable_irq(nile4_to_irq(NILE4_INT_GPT));
76 change_c0_status(ST0_IM,
77 IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4);
81 static void __init ddb_time_init(void)
83 /* we have ds1396 RTC chip */
84 rtc_ds1386_init(KSEG1ADDR(DDB_PCI_MEM_BASE));
89 static void __init ddb5074_setup(void)
91 extern int panic_timeout;
93 set_io_port_base(NILE4_PCI_IO_BASE);
94 isa_slot_offset = NILE4_PCI_MEM_BASE;
95 board_timer_setup = ddb_timer_init;
96 board_time_init = ddb_time_init;
99 _machine_restart = ddb_machine_restart;
100 _machine_halt = ddb_machine_halt;
101 _machine_power_off = ddb_machine_power_off;
103 ddb_out32(DDB_BAR0, 0);
105 ddb_set_pmr(DDB_PCIINIT0, DDB_PCICMD_IO, 0, 0x10);
106 ddb_set_pmr(DDB_PCIINIT1, DDB_PCICMD_MEM, DDB_PCI_MEM_BASE , 0x10);
108 /* Reboot on panic */
112 early_initcall(ddb5074_setup);
114 #define USE_NILE4_SERIAL 0
117 #define ns16550_in(reg) nile4_in8((reg)*8)
118 #define ns16550_out(reg, val) nile4_out8((reg)*8, (val))
120 #define NS16550_BASE (NILE4_PCI_IO_BASE+0x03f8)
121 static inline u8 ns16550_in(u32 reg)
123 return *(volatile u8 *) (NS16550_BASE + reg);
126 static inline void ns16550_out(u32 reg, u8 val)
128 *(volatile u8 *) (NS16550_BASE + reg) = val;
132 #define NS16550_RBR 0
133 #define NS16550_THR 0
134 #define NS16550_DLL 0
135 #define NS16550_IER 1
136 #define NS16550_DLM 1
137 #define NS16550_FCR 2
138 #define NS16550_IIR 2
139 #define NS16550_LCR 3
140 #define NS16550_MCR 4
141 #define NS16550_LSR 5
142 #define NS16550_MSR 6
143 #define NS16550_SCR 7
145 #define NS16550_LSR_DR 0x01 /* Data ready */
146 #define NS16550_LSR_OE 0x02 /* Overrun */
147 #define NS16550_LSR_PE 0x04 /* Parity error */
148 #define NS16550_LSR_FE 0x08 /* Framing error */
149 #define NS16550_LSR_BI 0x10 /* Break */
150 #define NS16550_LSR_THRE 0x20 /* Xmit holding register empty */
151 #define NS16550_LSR_TEMT 0x40 /* Xmitter empty */
152 #define NS16550_LSR_ERR 0x80 /* Error */
158 ns16550_out(NS16550_LCR, 0x80);
159 ns16550_out(NS16550_DLM, 0x00);
160 ns16550_out(NS16550_DLL, 0x36); /* 9600 baud */
161 ns16550_out(NS16550_LCR, 0x00);
162 ns16550_out(NS16550_LCR, 0x03);
163 ns16550_out(NS16550_FCR, 0x47);
171 while (!(ns16550_in(NS16550_LSR) & NS16550_LSR_THRE));
172 ns16550_out(NS16550_THR, c);
174 while (!(ns16550_in(NS16550_LSR) & NS16550_LSR_THRE));
175 ns16550_out(NS16550_THR, '\r');
179 void _puts(const char *s)
188 while (!(ns16550_in(NS16550_LSR) & NS16550_LSR_DR));
189 return ns16550_in(NS16550_RBR);
194 return (ns16550_in(NS16550_LSR) & NS16550_LSR_DR) != 0;
199 * Hexadecimal 7-segment LED
201 void ddb5074_led_hex(int hex)
208 * LEDs D2 and D3, connected to the GPIO pins of the PMU in the ALi M1543
210 struct pci_dev *pci_pmu = NULL;
212 void ddb5074_led_d2(int on)
217 pci_read_config_byte(pci_pmu, 0x7e, &t);
222 pci_write_config_byte(pci_pmu, 0x7e, t);
226 void ddb5074_led_d3(int on)
231 pci_read_config_byte(pci_pmu, 0x7e, &t);
236 pci_write_config_byte(pci_pmu, 0x7e, t);