Linux Audio

Check our new training course

Loading...
v3.1
 
  1/*
  2 *  linux/arch/m68k/hp300/config.c
  3 *
  4 *  Copyright (C) 1998 Philip Blundell <philb@gnu.org>
  5 *
  6 *  This file contains the HP300-specific initialisation code.  It gets
  7 *  called by setup.c.
  8 */
  9
 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>
 
 15
 16#include <asm/bootinfo.h>
 
 
 17#include <asm/machdep.h>
 18#include <asm/blinken.h>
 19#include <asm/io.h>                               /* readb() and writeb() */
 20#include <asm/hp300hw.h>
 21#include <asm/rtc.h>
 22
 23#include "time.h"
 24
 25unsigned long hp300_model;
 26unsigned long hp300_uart_scode = -1;
 27unsigned char ledstate;
 
 28
 29static char s_hp330[] __initdata = "330";
 30static char s_hp340[] __initdata = "340";
 31static char s_hp345[] __initdata = "345";
 32static char s_hp360[] __initdata = "360";
 33static char s_hp370[] __initdata = "370";
 34static char s_hp375[] __initdata = "375";
 35static char s_hp380[] __initdata = "380";
 36static char s_hp385[] __initdata = "385";
 37static char s_hp400[] __initdata = "400";
 38static char s_hp425t[] __initdata = "425t";
 39static char s_hp425s[] __initdata = "425s";
 40static char s_hp425e[] __initdata = "425e";
 41static char s_hp433t[] __initdata = "433t";
 42static char s_hp433s[] __initdata = "433s";
 43static char *hp300_models[] __initdata = {
 44	[HP_320]	= NULL,
 45	[HP_330]	= s_hp330,
 46	[HP_340]	= s_hp340,
 47	[HP_345]	= s_hp345,
 48	[HP_350]	= NULL,
 49	[HP_360]	= s_hp360,
 50	[HP_370]	= s_hp370,
 51	[HP_375]	= s_hp375,
 52	[HP_380]	= s_hp380,
 53	[HP_385]	= s_hp385,
 54	[HP_400]	= s_hp400,
 55	[HP_425T]	= s_hp425t,
 56	[HP_425S]	= s_hp425s,
 57	[HP_425E]	= s_hp425e,
 58	[HP_433T]	= s_hp433t,
 59	[HP_433S]	= s_hp433s,
 60};
 61
 62static char hp300_model_name[13] = "HP9000/";
 63
 64extern void hp300_reset(void);
 65#ifdef CONFIG_SERIAL_8250_CONSOLE
 66extern int hp300_setup_serial_console(void) __init;
 67#endif
 68
 69int __init hp300_parse_bootinfo(const struct bi_record *record)
 70{
 71	int unknown = 0;
 72	const unsigned long *data = record->data;
 73
 74	switch (record->tag) {
 75	case BI_HP300_MODEL:
 76		hp300_model = *data;
 77		break;
 78
 79	case BI_HP300_UART_SCODE:
 80		hp300_uart_scode = *data;
 81		break;
 82
 83	case BI_HP300_UART_ADDR:
 84		/* serial port address: ignored here */
 85		break;
 86
 87        default:
 88		unknown = 1;
 89	}
 90
 91	return unknown;
 92}
 93
 94#ifdef CONFIG_HEARTBEAT
 95static void hp300_pulse(int x)
 96{
 97	if (x)
 98		blinken_leds(0x10, 0);
 99	else
100		blinken_leds(0, 0x10);
101}
102#endif
103
104static void hp300_get_model(char *model)
105{
106	strcpy(model, hp300_model_name);
107}
108
109#define RTCBASE			0xf0420000
110#define RTC_DATA		0x1
111#define RTC_CMD			0x3
112
113#define	RTC_BUSY		0x02
114#define	RTC_DATA_RDY		0x01
115
116#define rtc_busy()		(in_8(RTCBASE + RTC_CMD) & RTC_BUSY)
117#define rtc_data_available()	(in_8(RTCBASE + RTC_CMD) & RTC_DATA_RDY)
118#define rtc_status()		(in_8(RTCBASE + RTC_CMD))
119#define rtc_command(x)		out_8(RTCBASE + RTC_CMD, (x))
120#define rtc_read_data()		(in_8(RTCBASE + RTC_DATA))
121#define rtc_write_data(x)	out_8(RTCBASE + RTC_DATA, (x))
122
123#define RTC_SETREG	0xe0
124#define RTC_WRITEREG	0xc2
125#define RTC_READREG	0xc3
126
127#define RTC_REG_SEC2	0
128#define RTC_REG_SEC1	1
129#define RTC_REG_MIN2	2
130#define RTC_REG_MIN1	3
131#define RTC_REG_HOUR2	4
132#define RTC_REG_HOUR1	5
133#define RTC_REG_WDAY	6
134#define RTC_REG_DAY2	7
135#define RTC_REG_DAY1	8
136#define RTC_REG_MON2	9
137#define RTC_REG_MON1	10
138#define RTC_REG_YEAR2	11
139#define RTC_REG_YEAR1	12
140
141#define RTC_HOUR1_24HMODE 0x8
142
143#define RTC_STAT_MASK	0xf0
144#define RTC_STAT_RDY	0x40
145
146static inline unsigned char hp300_rtc_read(unsigned char reg)
147{
148	unsigned char s, ret;
149	unsigned long flags;
150
151	local_irq_save(flags);
152
153	while (rtc_busy());
154	rtc_command(RTC_SETREG);
155	while (rtc_busy());
156	rtc_write_data(reg);
157	while (rtc_busy());
158	rtc_command(RTC_READREG);
159
160	do {
161		while (!rtc_data_available());
162		s = rtc_status();
163		ret = rtc_read_data();
164	} while ((s & RTC_STAT_MASK) != RTC_STAT_RDY);
165
166	local_irq_restore(flags);
167
168	return ret;
169}
170
171static inline unsigned char hp300_rtc_write(unsigned char reg,
172					    unsigned char val)
173{
174	unsigned char s, ret;
175	unsigned long flags;
176
177	local_irq_save(flags);
178
179	while (rtc_busy());
180	rtc_command(RTC_SETREG);
181	while (rtc_busy());
182	rtc_write_data((val << 4) | reg);
183	while (rtc_busy());
184	rtc_command(RTC_WRITEREG);
185	while (rtc_busy());
186	rtc_command(RTC_READREG);
187
188	do {
189		while (!rtc_data_available());
190		s = rtc_status();
191		ret = rtc_read_data();
192	} while ((s & RTC_STAT_MASK) != RTC_STAT_RDY);
193
194	local_irq_restore(flags);
195
196	return ret;
197}
198
199static int hp300_hwclk(int op, struct rtc_time *t)
200{
201	if (!op) { /* read */
202		t->tm_sec  = hp300_rtc_read(RTC_REG_SEC1) * 10 +
203			hp300_rtc_read(RTC_REG_SEC2);
204		t->tm_min  = hp300_rtc_read(RTC_REG_MIN1) * 10 +
205			hp300_rtc_read(RTC_REG_MIN2);
206		t->tm_hour = (hp300_rtc_read(RTC_REG_HOUR1) & 3) * 10 +
207			hp300_rtc_read(RTC_REG_HOUR2);
208		t->tm_wday = -1;
209		t->tm_mday = hp300_rtc_read(RTC_REG_DAY1) * 10 +
210			hp300_rtc_read(RTC_REG_DAY2);
211		t->tm_mon  = hp300_rtc_read(RTC_REG_MON1) * 10 +
212			hp300_rtc_read(RTC_REG_MON2) - 1;
213		t->tm_year = hp300_rtc_read(RTC_REG_YEAR1) * 10 +
214			hp300_rtc_read(RTC_REG_YEAR2);
215		if (t->tm_year <= 69)
216			t->tm_year += 100;
217	} else {
218		hp300_rtc_write(RTC_REG_SEC1, t->tm_sec / 10);
219		hp300_rtc_write(RTC_REG_SEC2, t->tm_sec % 10);
220		hp300_rtc_write(RTC_REG_MIN1, t->tm_min / 10);
221		hp300_rtc_write(RTC_REG_MIN2, t->tm_min % 10);
222		hp300_rtc_write(RTC_REG_HOUR1,
223				((t->tm_hour / 10) & 3) | RTC_HOUR1_24HMODE);
224		hp300_rtc_write(RTC_REG_HOUR2, t->tm_hour % 10);
225		hp300_rtc_write(RTC_REG_DAY1, t->tm_mday / 10);
226		hp300_rtc_write(RTC_REG_DAY2, t->tm_mday % 10);
227		hp300_rtc_write(RTC_REG_MON1, (t->tm_mon + 1) / 10);
228		hp300_rtc_write(RTC_REG_MON2, (t->tm_mon + 1) % 10);
229		if (t->tm_year >= 100)
230			t->tm_year -= 100;
231		hp300_rtc_write(RTC_REG_YEAR1, t->tm_year / 10);
232		hp300_rtc_write(RTC_REG_YEAR2, t->tm_year % 10);
233	}
234
235	return 0;
236}
237
238static unsigned int hp300_get_ss(void)
239{
240	return hp300_rtc_read(RTC_REG_SEC1) * 10 +
241		hp300_rtc_read(RTC_REG_SEC2);
242}
243
244static void __init hp300_init_IRQ(void)
245{
246}
247
248void __init config_hp300(void)
249{
250	mach_sched_init      = hp300_sched_init;
251	mach_init_IRQ        = hp300_init_IRQ;
252	mach_get_model       = hp300_get_model;
253	mach_gettimeoffset   = hp300_gettimeoffset;
254	mach_hwclk	     = hp300_hwclk;
255	mach_get_ss	     = hp300_get_ss;
256	mach_reset           = hp300_reset;
257#ifdef CONFIG_HEARTBEAT
258	mach_heartbeat       = hp300_pulse;
259#endif
260	mach_max_dma_address = 0xffffffff;
261
262	if (hp300_model >= HP_330 && hp300_model <= HP_433S && hp300_model != HP_350) {
263		printk(KERN_INFO "Detected HP9000 model %s\n", hp300_models[hp300_model-HP_320]);
 
 
264		strcat(hp300_model_name, hp300_models[hp300_model-HP_320]);
265	}
266	else {
267		panic("Unknown HP9000 Model");
268	}
269#ifdef CONFIG_SERIAL_8250_CONSOLE
270	hp300_setup_serial_console();
271#endif
272}
v6.8
  1// SPDX-License-Identifier: GPL-2.0
  2/*
  3 *  linux/arch/m68k/hp300/config.c
  4 *
  5 *  Copyright (C) 1998 Philip Blundell <philb@gnu.org>
  6 *
  7 *  This file contains the HP300-specific initialisation code.  It gets
  8 *  called by setup.c.
  9 */
 10
 11#include <linux/module.h>
 12#include <linux/init.h>
 13#include <linux/string.h>
 14#include <linux/kernel.h>
 15#include <linux/console.h>
 16#include <linux/rtc.h>
 17
 18#include <asm/bootinfo.h>
 19#include <asm/bootinfo-hp300.h>
 20#include <asm/byteorder.h>
 21#include <asm/machdep.h>
 22#include <asm/blinken.h>
 23#include <asm/io.h>                               /* readb() and writeb() */
 24#include <asm/hp300hw.h>
 25#include <asm/config.h>
 26
 27#include "time.h"
 28
 29unsigned long hp300_model;
 30unsigned long hp300_uart_scode = -1;
 31unsigned char hp300_ledstate;
 32EXPORT_SYMBOL(hp300_ledstate);
 33
 34static char s_hp330[] __initdata = "330";
 35static char s_hp340[] __initdata = "340";
 36static char s_hp345[] __initdata = "345";
 37static char s_hp360[] __initdata = "360";
 38static char s_hp370[] __initdata = "370";
 39static char s_hp375[] __initdata = "375";
 40static char s_hp380[] __initdata = "380";
 41static char s_hp385[] __initdata = "385";
 42static char s_hp400[] __initdata = "400";
 43static char s_hp425t[] __initdata = "425t";
 44static char s_hp425s[] __initdata = "425s";
 45static char s_hp425e[] __initdata = "425e";
 46static char s_hp433t[] __initdata = "433t";
 47static char s_hp433s[] __initdata = "433s";
 48static char *hp300_models[] __initdata = {
 49	[HP_320]	= NULL,
 50	[HP_330]	= s_hp330,
 51	[HP_340]	= s_hp340,
 52	[HP_345]	= s_hp345,
 53	[HP_350]	= NULL,
 54	[HP_360]	= s_hp360,
 55	[HP_370]	= s_hp370,
 56	[HP_375]	= s_hp375,
 57	[HP_380]	= s_hp380,
 58	[HP_385]	= s_hp385,
 59	[HP_400]	= s_hp400,
 60	[HP_425T]	= s_hp425t,
 61	[HP_425S]	= s_hp425s,
 62	[HP_425E]	= s_hp425e,
 63	[HP_433T]	= s_hp433t,
 64	[HP_433S]	= s_hp433s,
 65};
 66
 67static char hp300_model_name[13] = "HP9000/";
 68
 69extern void hp300_reset(void);
 70#ifdef CONFIG_SERIAL_8250_CONSOLE
 71extern int hp300_setup_serial_console(void) __init;
 72#endif
 73
 74int __init hp300_parse_bootinfo(const struct bi_record *record)
 75{
 76	int unknown = 0;
 77	const void *data = record->data;
 78
 79	switch (be16_to_cpu(record->tag)) {
 80	case BI_HP300_MODEL:
 81		hp300_model = be32_to_cpup(data);
 82		break;
 83
 84	case BI_HP300_UART_SCODE:
 85		hp300_uart_scode = be32_to_cpup(data);
 86		break;
 87
 88	case BI_HP300_UART_ADDR:
 89		/* serial port address: ignored here */
 90		break;
 91
 92	default:
 93		unknown = 1;
 94	}
 95
 96	return unknown;
 97}
 98
 99#ifdef CONFIG_HEARTBEAT
100static void hp300_pulse(int x)
101{
102	if (x)
103		blinken_leds(0x10, 0);
104	else
105		blinken_leds(0, 0x10);
106}
107#endif
108
109static void hp300_get_model(char *model)
110{
111	strcpy(model, hp300_model_name);
112}
113
114#define RTCBASE			0xf0420000
115#define RTC_DATA		0x1
116#define RTC_CMD			0x3
117
118#define	RTC_BUSY		0x02
119#define	RTC_DATA_RDY		0x01
120
121#define rtc_busy()		(in_8(RTCBASE + RTC_CMD) & RTC_BUSY)
122#define rtc_data_available()	(in_8(RTCBASE + RTC_CMD) & RTC_DATA_RDY)
123#define rtc_status()		(in_8(RTCBASE + RTC_CMD))
124#define rtc_command(x)		out_8(RTCBASE + RTC_CMD, (x))
125#define rtc_read_data()		(in_8(RTCBASE + RTC_DATA))
126#define rtc_write_data(x)	out_8(RTCBASE + RTC_DATA, (x))
127
128#define RTC_SETREG	0xe0
129#define RTC_WRITEREG	0xc2
130#define RTC_READREG	0xc3
131
132#define RTC_REG_SEC2	0
133#define RTC_REG_SEC1	1
134#define RTC_REG_MIN2	2
135#define RTC_REG_MIN1	3
136#define RTC_REG_HOUR2	4
137#define RTC_REG_HOUR1	5
138#define RTC_REG_WDAY	6
139#define RTC_REG_DAY2	7
140#define RTC_REG_DAY1	8
141#define RTC_REG_MON2	9
142#define RTC_REG_MON1	10
143#define RTC_REG_YEAR2	11
144#define RTC_REG_YEAR1	12
145
146#define RTC_HOUR1_24HMODE 0x8
147
148#define RTC_STAT_MASK	0xf0
149#define RTC_STAT_RDY	0x40
150
151static inline unsigned char hp300_rtc_read(unsigned char reg)
152{
153	unsigned char s, ret;
154	unsigned long flags;
155
156	local_irq_save(flags);
157
158	while (rtc_busy());
159	rtc_command(RTC_SETREG);
160	while (rtc_busy());
161	rtc_write_data(reg);
162	while (rtc_busy());
163	rtc_command(RTC_READREG);
164
165	do {
166		while (!rtc_data_available());
167		s = rtc_status();
168		ret = rtc_read_data();
169	} while ((s & RTC_STAT_MASK) != RTC_STAT_RDY);
170
171	local_irq_restore(flags);
172
173	return ret;
174}
175
176static inline unsigned char hp300_rtc_write(unsigned char reg,
177					    unsigned char val)
178{
179	unsigned char s, ret;
180	unsigned long flags;
181
182	local_irq_save(flags);
183
184	while (rtc_busy());
185	rtc_command(RTC_SETREG);
186	while (rtc_busy());
187	rtc_write_data((val << 4) | reg);
188	while (rtc_busy());
189	rtc_command(RTC_WRITEREG);
190	while (rtc_busy());
191	rtc_command(RTC_READREG);
192
193	do {
194		while (!rtc_data_available());
195		s = rtc_status();
196		ret = rtc_read_data();
197	} while ((s & RTC_STAT_MASK) != RTC_STAT_RDY);
198
199	local_irq_restore(flags);
200
201	return ret;
202}
203
204static int hp300_hwclk(int op, struct rtc_time *t)
205{
206	if (!op) { /* read */
207		t->tm_sec  = hp300_rtc_read(RTC_REG_SEC1) * 10 +
208			hp300_rtc_read(RTC_REG_SEC2);
209		t->tm_min  = hp300_rtc_read(RTC_REG_MIN1) * 10 +
210			hp300_rtc_read(RTC_REG_MIN2);
211		t->tm_hour = (hp300_rtc_read(RTC_REG_HOUR1) & 3) * 10 +
212			hp300_rtc_read(RTC_REG_HOUR2);
213		t->tm_wday = -1;
214		t->tm_mday = hp300_rtc_read(RTC_REG_DAY1) * 10 +
215			hp300_rtc_read(RTC_REG_DAY2);
216		t->tm_mon  = hp300_rtc_read(RTC_REG_MON1) * 10 +
217			hp300_rtc_read(RTC_REG_MON2) - 1;
218		t->tm_year = hp300_rtc_read(RTC_REG_YEAR1) * 10 +
219			hp300_rtc_read(RTC_REG_YEAR2);
220		if (t->tm_year <= 69)
221			t->tm_year += 100;
222	} else {
223		hp300_rtc_write(RTC_REG_SEC1, t->tm_sec / 10);
224		hp300_rtc_write(RTC_REG_SEC2, t->tm_sec % 10);
225		hp300_rtc_write(RTC_REG_MIN1, t->tm_min / 10);
226		hp300_rtc_write(RTC_REG_MIN2, t->tm_min % 10);
227		hp300_rtc_write(RTC_REG_HOUR1,
228				((t->tm_hour / 10) & 3) | RTC_HOUR1_24HMODE);
229		hp300_rtc_write(RTC_REG_HOUR2, t->tm_hour % 10);
230		hp300_rtc_write(RTC_REG_DAY1, t->tm_mday / 10);
231		hp300_rtc_write(RTC_REG_DAY2, t->tm_mday % 10);
232		hp300_rtc_write(RTC_REG_MON1, (t->tm_mon + 1) / 10);
233		hp300_rtc_write(RTC_REG_MON2, (t->tm_mon + 1) % 10);
234		if (t->tm_year >= 100)
235			t->tm_year -= 100;
236		hp300_rtc_write(RTC_REG_YEAR1, t->tm_year / 10);
237		hp300_rtc_write(RTC_REG_YEAR2, t->tm_year % 10);
238	}
239
240	return 0;
241}
242
 
 
 
 
 
 
243static void __init hp300_init_IRQ(void)
244{
245}
246
247void __init config_hp300(void)
248{
249	mach_sched_init      = hp300_sched_init;
250	mach_init_IRQ        = hp300_init_IRQ;
251	mach_get_model       = hp300_get_model;
 
252	mach_hwclk	     = hp300_hwclk;
 
253	mach_reset           = hp300_reset;
254#ifdef CONFIG_HEARTBEAT
255	mach_heartbeat       = hp300_pulse;
256#endif
 
257
258	if (hp300_model >= HP_330 && hp300_model <= HP_433S &&
259	    hp300_model != HP_350) {
260		pr_info("Detected HP9000 model %s\n",
261			hp300_models[hp300_model-HP_320]);
262		strcat(hp300_model_name, hp300_models[hp300_model-HP_320]);
263	} else {
 
264		panic("Unknown HP9000 Model");
265	}
266#ifdef CONFIG_SERIAL_8250_CONSOLE
267	hp300_setup_serial_console();
268#endif
269}