2 * linux/arch/m68k/hp300/config.c
4 * Copyright (C) 1998 Philip Blundell <philb@gnu.org>
6 * This file contains the HP300-specific initialisation code. It gets
10 #include <linux/module.h>
11 #include <linux/init.h>
12 #include <linux/string.h>
13 #include <linux/kernel.h>
14 #include <linux/console.h>
16 #include <asm/bootinfo.h>
17 #include <asm/bootinfo-hp300.h>
18 #include <asm/byteorder.h>
19 #include <asm/machdep.h>
20 #include <asm/blinken.h>
21 #include <asm/io.h> /* readb() and writeb() */
22 #include <asm/hp300hw.h>
27 unsigned long hp300_model
;
28 unsigned long hp300_uart_scode
= -1;
29 unsigned char hp300_ledstate
;
30 EXPORT_SYMBOL(hp300_ledstate
);
32 static char s_hp330
[] __initdata
= "330";
33 static char s_hp340
[] __initdata
= "340";
34 static char s_hp345
[] __initdata
= "345";
35 static char s_hp360
[] __initdata
= "360";
36 static char s_hp370
[] __initdata
= "370";
37 static char s_hp375
[] __initdata
= "375";
38 static char s_hp380
[] __initdata
= "380";
39 static char s_hp385
[] __initdata
= "385";
40 static char s_hp400
[] __initdata
= "400";
41 static char s_hp425t
[] __initdata
= "425t";
42 static char s_hp425s
[] __initdata
= "425s";
43 static char s_hp425e
[] __initdata
= "425e";
44 static char s_hp433t
[] __initdata
= "433t";
45 static char s_hp433s
[] __initdata
= "433s";
46 static char *hp300_models
[] __initdata
= {
65 static char hp300_model_name
[13] = "HP9000/";
67 extern void hp300_reset(void);
68 #ifdef CONFIG_SERIAL_8250_CONSOLE
69 extern int hp300_setup_serial_console(void) __init
;
72 int __init
hp300_parse_bootinfo(const struct bi_record
*record
)
75 const void *data
= record
->data
;
77 switch (be16_to_cpu(record
->tag
)) {
79 hp300_model
= be32_to_cpup(data
);
82 case BI_HP300_UART_SCODE
:
83 hp300_uart_scode
= be32_to_cpup(data
);
86 case BI_HP300_UART_ADDR
:
87 /* serial port address: ignored here */
97 #ifdef CONFIG_HEARTBEAT
98 static void hp300_pulse(int x
)
101 blinken_leds(0x10, 0);
103 blinken_leds(0, 0x10);
107 static void hp300_get_model(char *model
)
109 strcpy(model
, hp300_model_name
);
112 #define RTCBASE 0xf0420000
116 #define RTC_BUSY 0x02
117 #define RTC_DATA_RDY 0x01
119 #define rtc_busy() (in_8(RTCBASE + RTC_CMD) & RTC_BUSY)
120 #define rtc_data_available() (in_8(RTCBASE + RTC_CMD) & RTC_DATA_RDY)
121 #define rtc_status() (in_8(RTCBASE + RTC_CMD))
122 #define rtc_command(x) out_8(RTCBASE + RTC_CMD, (x))
123 #define rtc_read_data() (in_8(RTCBASE + RTC_DATA))
124 #define rtc_write_data(x) out_8(RTCBASE + RTC_DATA, (x))
126 #define RTC_SETREG 0xe0
127 #define RTC_WRITEREG 0xc2
128 #define RTC_READREG 0xc3
130 #define RTC_REG_SEC2 0
131 #define RTC_REG_SEC1 1
132 #define RTC_REG_MIN2 2
133 #define RTC_REG_MIN1 3
134 #define RTC_REG_HOUR2 4
135 #define RTC_REG_HOUR1 5
136 #define RTC_REG_WDAY 6
137 #define RTC_REG_DAY2 7
138 #define RTC_REG_DAY1 8
139 #define RTC_REG_MON2 9
140 #define RTC_REG_MON1 10
141 #define RTC_REG_YEAR2 11
142 #define RTC_REG_YEAR1 12
144 #define RTC_HOUR1_24HMODE 0x8
146 #define RTC_STAT_MASK 0xf0
147 #define RTC_STAT_RDY 0x40
149 static inline unsigned char hp300_rtc_read(unsigned char reg
)
151 unsigned char s
, ret
;
154 local_irq_save(flags
);
157 rtc_command(RTC_SETREG
);
161 rtc_command(RTC_READREG
);
164 while (!rtc_data_available());
166 ret
= rtc_read_data();
167 } while ((s
& RTC_STAT_MASK
) != RTC_STAT_RDY
);
169 local_irq_restore(flags
);
174 static inline unsigned char hp300_rtc_write(unsigned char reg
,
177 unsigned char s
, ret
;
180 local_irq_save(flags
);
183 rtc_command(RTC_SETREG
);
185 rtc_write_data((val
<< 4) | reg
);
187 rtc_command(RTC_WRITEREG
);
189 rtc_command(RTC_READREG
);
192 while (!rtc_data_available());
194 ret
= rtc_read_data();
195 } while ((s
& RTC_STAT_MASK
) != RTC_STAT_RDY
);
197 local_irq_restore(flags
);
202 static int hp300_hwclk(int op
, struct rtc_time
*t
)
204 if (!op
) { /* read */
205 t
->tm_sec
= hp300_rtc_read(RTC_REG_SEC1
) * 10 +
206 hp300_rtc_read(RTC_REG_SEC2
);
207 t
->tm_min
= hp300_rtc_read(RTC_REG_MIN1
) * 10 +
208 hp300_rtc_read(RTC_REG_MIN2
);
209 t
->tm_hour
= (hp300_rtc_read(RTC_REG_HOUR1
) & 3) * 10 +
210 hp300_rtc_read(RTC_REG_HOUR2
);
212 t
->tm_mday
= hp300_rtc_read(RTC_REG_DAY1
) * 10 +
213 hp300_rtc_read(RTC_REG_DAY2
);
214 t
->tm_mon
= hp300_rtc_read(RTC_REG_MON1
) * 10 +
215 hp300_rtc_read(RTC_REG_MON2
) - 1;
216 t
->tm_year
= hp300_rtc_read(RTC_REG_YEAR1
) * 10 +
217 hp300_rtc_read(RTC_REG_YEAR2
);
218 if (t
->tm_year
<= 69)
221 hp300_rtc_write(RTC_REG_SEC1
, t
->tm_sec
/ 10);
222 hp300_rtc_write(RTC_REG_SEC2
, t
->tm_sec
% 10);
223 hp300_rtc_write(RTC_REG_MIN1
, t
->tm_min
/ 10);
224 hp300_rtc_write(RTC_REG_MIN2
, t
->tm_min
% 10);
225 hp300_rtc_write(RTC_REG_HOUR1
,
226 ((t
->tm_hour
/ 10) & 3) | RTC_HOUR1_24HMODE
);
227 hp300_rtc_write(RTC_REG_HOUR2
, t
->tm_hour
% 10);
228 hp300_rtc_write(RTC_REG_DAY1
, t
->tm_mday
/ 10);
229 hp300_rtc_write(RTC_REG_DAY2
, t
->tm_mday
% 10);
230 hp300_rtc_write(RTC_REG_MON1
, (t
->tm_mon
+ 1) / 10);
231 hp300_rtc_write(RTC_REG_MON2
, (t
->tm_mon
+ 1) % 10);
232 if (t
->tm_year
>= 100)
234 hp300_rtc_write(RTC_REG_YEAR1
, t
->tm_year
/ 10);
235 hp300_rtc_write(RTC_REG_YEAR2
, t
->tm_year
% 10);
241 static unsigned int hp300_get_ss(void)
243 return hp300_rtc_read(RTC_REG_SEC1
) * 10 +
244 hp300_rtc_read(RTC_REG_SEC2
);
247 static void __init
hp300_init_IRQ(void)
251 void __init
config_hp300(void)
253 mach_sched_init
= hp300_sched_init
;
254 mach_init_IRQ
= hp300_init_IRQ
;
255 mach_get_model
= hp300_get_model
;
256 arch_gettimeoffset
= hp300_gettimeoffset
;
257 mach_hwclk
= hp300_hwclk
;
258 mach_get_ss
= hp300_get_ss
;
259 mach_reset
= hp300_reset
;
260 #ifdef CONFIG_HEARTBEAT
261 mach_heartbeat
= hp300_pulse
;
263 mach_max_dma_address
= 0xffffffff;
265 if (hp300_model
>= HP_330
&& hp300_model
<= HP_433S
&&
266 hp300_model
!= HP_350
) {
267 pr_info("Detected HP9000 model %s\n",
268 hp300_models
[hp300_model
-HP_320
]);
269 strcat(hp300_model_name
, hp300_models
[hp300_model
-HP_320
]);
271 panic("Unknown HP9000 Model");
273 #ifdef CONFIG_SERIAL_8250_CONSOLE
274 hp300_setup_serial_console();