2 * arch/m68k/mvme147/config.c
4 * Copyright (C) 1996 Dave Frascone [chaos@mindspring.com]
5 * Cloned from Richard Hirst [richard@sleepie.demon.co.uk]
9 * Copyright (C) 1993 Hamish Macdonald
11 * This file is subject to the terms and conditions of the GNU General Public
12 * License. See the file README.legal in the main directory of this archive
16 #include <linux/types.h>
17 #include <linux/kernel.h>
19 #include <linux/tty.h>
20 #include <linux/console.h>
21 #include <linux/linkage.h>
22 #include <linux/init.h>
23 #include <linux/major.h>
25 #include <asm/bootinfo.h>
26 #include <asm/system.h>
27 #include <asm/pgtable.h>
28 #include <asm/setup.h>
30 #include <asm/traps.h>
32 #include <asm/machdep.h>
33 #include <asm/mvme147hw.h>
36 extern void mvme147_process_int (int level, struct pt_regs *regs);
37 extern void mvme147_init_IRQ (void);
38 extern void mvme147_free_irq (unsigned int, void *);
39 extern int mvme147_get_irq_list (char *);
40 extern void mvme147_enable_irq (unsigned int);
41 extern void mvme147_disable_irq (unsigned int);
42 static void mvme147_get_model(char *model);
43 static int mvme147_get_hardware_list(char *buffer);
44 extern int mvme147_request_irq (unsigned int irq, void (*handler)(int, void *, struct pt_regs *), unsigned long flags, const char *devname, void *dev_id);
45 extern void mvme147_sched_init(void (*handler)(int, void *, struct pt_regs *));
46 extern int mvme147_keyb_init(void);
47 extern int mvme147_kbdrate (struct kbd_repeat *);
48 extern unsigned long mvme147_gettimeoffset (void);
49 extern void mvme147_gettod (int *year, int *mon, int *day, int *hour,
51 extern int mvme147_hwclk (int, struct rtc_time *);
52 extern int mvme147_set_clock_mmss (unsigned long);
53 extern void mvme147_check_partition (struct gendisk *hd, unsigned int dev);
54 extern void mvme147_reset (void);
55 extern void mvme147_waitbut(void);
58 static int bcd2int (unsigned char b);
60 /* Save tick handler routine pointer, will point to do_timer() in
61 * kernel/sched.c, called via mvme147_process_int() */
63 void (*tick_handler)(int, void *, struct pt_regs *);
66 int mvme147_parse_bootinfo(const struct bi_record *bi)
68 if (bi->tag == BI_VME_TYPE || bi->tag == BI_VME_BRDINFO)
74 int mvme147_kbdrate (struct kbd_repeat *k)
81 printk ("\r\n\nCalled mvme147_reset\r\n");
82 m147_pcc->watchdog = 0x0a; /* Clear timer */
83 m147_pcc->watchdog = 0xa5; /* Enable watchdog - 100ms to reset */
88 static void mvme147_get_model(char *model)
90 sprintf(model, "Motorola MVME147");
94 static int mvme147_get_hardware_list(char *buffer)
102 void __init config_mvme147(void)
104 mach_max_dma_address = 0x01000000;
105 mach_sched_init = mvme147_sched_init;
107 mach_keyb_init = mvme147_keyb_init;
108 mach_kbdrate = mvme147_kbdrate;
110 mach_init_IRQ = mvme147_init_IRQ;
111 mach_gettimeoffset = mvme147_gettimeoffset;
112 mach_gettod = mvme147_gettod;
113 mach_hwclk = mvme147_hwclk;
114 mach_set_clock_mmss = mvme147_set_clock_mmss;
115 mach_reset = mvme147_reset;
116 mach_free_irq = mvme147_free_irq;
117 mach_process_int = mvme147_process_int;
118 mach_get_irq_list = mvme147_get_irq_list;
119 mach_request_irq = mvme147_request_irq;
120 enable_irq = mvme147_enable_irq;
121 disable_irq = mvme147_disable_irq;
122 mach_get_model = mvme147_get_model;
123 mach_get_hardware_list = mvme147_get_hardware_list;
125 /* Board type is only set by newer versions of vmelilo/tftplilo */
127 vme_brdtype = VME_TYPE_MVME147;
131 /* Using pcc tick timer 1 */
133 static void mvme147_timer_int (int irq, void *dev_id, struct pt_regs *fp)
135 m147_pcc->t1_int_cntrl = PCC_TIMER_INT_CLR;
136 m147_pcc->t1_int_cntrl = PCC_INT_ENAB|PCC_LEVEL_TIMER1;
137 tick_handler(irq, dev_id, fp);
141 void mvme147_sched_init (void (*timer_routine)(int, void *, struct pt_regs *))
143 tick_handler = timer_routine;
144 request_irq (PCC_IRQ_TIMER1, mvme147_timer_int,
145 IRQ_FLG_REPLACE, "timer 1", NULL);
147 /* Init the clock with a value */
148 /* our clock goes off every 6.25us */
149 m147_pcc->t1_preload = PCC_TIMER_PRELOAD;
150 m147_pcc->t1_cntrl = 0x0; /* clear timer */
151 m147_pcc->t1_cntrl = 0x3; /* start timer */
152 m147_pcc->t1_int_cntrl = PCC_TIMER_INT_CLR; /* clear pending ints */
153 m147_pcc->t1_int_cntrl = PCC_INT_ENAB|PCC_LEVEL_TIMER1;
156 /* This is always executed with interrupts disabled. */
157 /* XXX There are race hazards in this code XXX */
158 unsigned long mvme147_gettimeoffset (void)
160 volatile unsigned short *cp = (volatile unsigned short *)0xfffe1012;
167 n -= PCC_TIMER_PRELOAD;
168 return (unsigned long)n * 25 / 4;
171 extern void mvme147_gettod (int *year, int *mon, int *day, int *hour,
174 m147_rtc->ctrl = RTC_READ;
175 *year = bcd2int (m147_rtc->bcd_year);
176 *mon = bcd2int (m147_rtc->bcd_mth);
177 *day = bcd2int (m147_rtc->bcd_dom);
178 *hour = bcd2int (m147_rtc->bcd_hr);
179 *min = bcd2int (m147_rtc->bcd_min);
180 *sec = bcd2int (m147_rtc->bcd_sec);
184 static int bcd2int (unsigned char b)
186 return ((b>>4)*10 + (b&15));
189 int mvme147_hwclk(int op, struct rtc_time *t)
194 int mvme147_set_clock_mmss (unsigned long nowtime)
199 int mvme147_keyb_init (void)
204 /*------------------- Serial console stuff ------------------------*/
206 static void scc_delay (void)
211 for (n = 0; n < 20; n++)
215 static void scc_write (char ch)
217 volatile char *p = (volatile char *)M147_SCC_A_ADDR;
230 void m147_scc_write (struct console *co, const char *str, unsigned count)
243 restore_flags(flags);
246 void mvme147_init_console_port (struct console *co, int cflag)
248 co->write = m147_scc_write;