xref: /openbmc/linux/arch/sh/boards/mach-se/770x/setup.c (revision 7bbe150d8c57c59689c8c50fd7b9915f4a7e10da)
1da2014a2SPaul Mundt /*
2da2014a2SPaul Mundt  * linux/arch/sh/boards/se/770x/setup.c
3da2014a2SPaul Mundt  *
4da2014a2SPaul Mundt  * Copyright (C) 2000  Kazumoto Kojima
5da2014a2SPaul Mundt  *
6da2014a2SPaul Mundt  * Hitachi SolutionEngine Support.
7da2014a2SPaul Mundt  *
8da2014a2SPaul Mundt  */
9da2014a2SPaul Mundt #include <linux/init.h>
10da2014a2SPaul Mundt #include <linux/platform_device.h>
11939a24a6SPaul Mundt #include <mach-se/mach/se.h>
12073da9c0SPaul Mundt #include <mach-se/mach/mrshpc.h>
13073da9c0SPaul Mundt #include <asm/machvec.h>
14da2014a2SPaul Mundt #include <asm/io.h>
15da2014a2SPaul Mundt #include <asm/smc37c93x.h>
16da2014a2SPaul Mundt #include <asm/heartbeat.h>
17da2014a2SPaul Mundt 
18da2014a2SPaul Mundt /*
19da2014a2SPaul Mundt  * Configure the Super I/O chip
20da2014a2SPaul Mundt  */
21da2014a2SPaul Mundt static void __init smsc_config(int index, int data)
22da2014a2SPaul Mundt {
23da2014a2SPaul Mundt 	outb_p(index, INDEX_PORT);
24da2014a2SPaul Mundt 	outb_p(data, DATA_PORT);
25da2014a2SPaul Mundt }
26da2014a2SPaul Mundt 
27da2014a2SPaul Mundt /* XXX: Another candidate for a more generic cchip machine vector */
28da2014a2SPaul Mundt static void __init smsc_setup(char **cmdline_p)
29da2014a2SPaul Mundt {
30da2014a2SPaul Mundt 	outb_p(CONFIG_ENTER, CONFIG_PORT);
31da2014a2SPaul Mundt 	outb_p(CONFIG_ENTER, CONFIG_PORT);
32da2014a2SPaul Mundt 
33da2014a2SPaul Mundt 	/* FDC */
34da2014a2SPaul Mundt 	smsc_config(CURRENT_LDN_INDEX, LDN_FDC);
35da2014a2SPaul Mundt 	smsc_config(ACTIVATE_INDEX, 0x01);
36da2014a2SPaul Mundt 	smsc_config(IRQ_SELECT_INDEX, 6); /* IRQ6 */
37da2014a2SPaul Mundt 
38da2014a2SPaul Mundt 	/* AUXIO (GPIO): to use IDE1 */
39da2014a2SPaul Mundt 	smsc_config(CURRENT_LDN_INDEX, LDN_AUXIO);
40da2014a2SPaul Mundt 	smsc_config(GPIO46_INDEX, 0x00); /* nIOROP */
41da2014a2SPaul Mundt 	smsc_config(GPIO47_INDEX, 0x00); /* nIOWOP */
42da2014a2SPaul Mundt 
43da2014a2SPaul Mundt 	/* COM1 */
44da2014a2SPaul Mundt 	smsc_config(CURRENT_LDN_INDEX, LDN_COM1);
45da2014a2SPaul Mundt 	smsc_config(ACTIVATE_INDEX, 0x01);
46da2014a2SPaul Mundt 	smsc_config(IO_BASE_HI_INDEX, 0x03);
47da2014a2SPaul Mundt 	smsc_config(IO_BASE_LO_INDEX, 0xf8);
48da2014a2SPaul Mundt 	smsc_config(IRQ_SELECT_INDEX, 4); /* IRQ4 */
49da2014a2SPaul Mundt 
50da2014a2SPaul Mundt 	/* COM2 */
51da2014a2SPaul Mundt 	smsc_config(CURRENT_LDN_INDEX, LDN_COM2);
52da2014a2SPaul Mundt 	smsc_config(ACTIVATE_INDEX, 0x01);
53da2014a2SPaul Mundt 	smsc_config(IO_BASE_HI_INDEX, 0x02);
54da2014a2SPaul Mundt 	smsc_config(IO_BASE_LO_INDEX, 0xf8);
55da2014a2SPaul Mundt 	smsc_config(IRQ_SELECT_INDEX, 3); /* IRQ3 */
56da2014a2SPaul Mundt 
57da2014a2SPaul Mundt 	/* RTC */
58da2014a2SPaul Mundt 	smsc_config(CURRENT_LDN_INDEX, LDN_RTC);
59da2014a2SPaul Mundt 	smsc_config(ACTIVATE_INDEX, 0x01);
60da2014a2SPaul Mundt 	smsc_config(IRQ_SELECT_INDEX, 8); /* IRQ8 */
61da2014a2SPaul Mundt 
62da2014a2SPaul Mundt 	/* XXX: PARPORT, KBD, and MOUSE will come here... */
63da2014a2SPaul Mundt 	outb_p(CONFIG_EXIT, CONFIG_PORT);
64da2014a2SPaul Mundt }
65da2014a2SPaul Mundt 
66da2014a2SPaul Mundt 
67da2014a2SPaul Mundt static struct resource cf_ide_resources[] = {
68da2014a2SPaul Mundt 	[0] = {
69da2014a2SPaul Mundt 		.start  = PA_MRSHPC_IO + 0x1f0,
70da2014a2SPaul Mundt 		.end    = PA_MRSHPC_IO + 0x1f0 + 8,
71da2014a2SPaul Mundt 		.flags  = IORESOURCE_MEM,
72da2014a2SPaul Mundt 	},
73da2014a2SPaul Mundt 	[1] = {
74da2014a2SPaul Mundt 		.start  = PA_MRSHPC_IO + 0x1f0 + 0x206,
75da2014a2SPaul Mundt 		.end    = PA_MRSHPC_IO + 0x1f0 + 8 + 0x206 + 8,
76da2014a2SPaul Mundt 		.flags  = IORESOURCE_MEM,
77da2014a2SPaul Mundt 	},
78da2014a2SPaul Mundt 	[2] = {
79da2014a2SPaul Mundt 		.start  = IRQ_CFCARD,
80da2014a2SPaul Mundt 		.flags  = IORESOURCE_IRQ,
81da2014a2SPaul Mundt 	},
82da2014a2SPaul Mundt };
83da2014a2SPaul Mundt 
84da2014a2SPaul Mundt static struct platform_device cf_ide_device  = {
85da2014a2SPaul Mundt 	.name           = "pata_platform",
86da2014a2SPaul Mundt 	.id             = -1,
87da2014a2SPaul Mundt 	.num_resources  = ARRAY_SIZE(cf_ide_resources),
88da2014a2SPaul Mundt 	.resource       = cf_ide_resources,
89da2014a2SPaul Mundt };
90da2014a2SPaul Mundt 
91da2014a2SPaul Mundt static unsigned char heartbeat_bit_pos[] = { 8, 9, 10, 11, 12, 13, 14, 15 };
92da2014a2SPaul Mundt 
93da2014a2SPaul Mundt static struct heartbeat_data heartbeat_data = {
94da2014a2SPaul Mundt 	.bit_pos	= heartbeat_bit_pos,
95da2014a2SPaul Mundt 	.nr_bits	= ARRAY_SIZE(heartbeat_bit_pos),
96da2014a2SPaul Mundt };
97da2014a2SPaul Mundt 
98a09d2831SPaul Mundt static struct resource heartbeat_resource = {
99da2014a2SPaul Mundt 	.start	= PA_LED,
100da2014a2SPaul Mundt 	.end	= PA_LED,
101a09d2831SPaul Mundt 	.flags	= IORESOURCE_MEM | IORESOURCE_MEM_16BIT,
102da2014a2SPaul Mundt };
103da2014a2SPaul Mundt 
104da2014a2SPaul Mundt static struct platform_device heartbeat_device = {
105da2014a2SPaul Mundt 	.name		= "heartbeat",
106da2014a2SPaul Mundt 	.id		= -1,
107da2014a2SPaul Mundt 	.dev	= {
108da2014a2SPaul Mundt 		.platform_data	= &heartbeat_data,
109da2014a2SPaul Mundt 	},
110a09d2831SPaul Mundt 	.num_resources	= 1,
111a09d2831SPaul Mundt 	.resource	= &heartbeat_resource,
112da2014a2SPaul Mundt };
113da2014a2SPaul Mundt 
114da2014a2SPaul Mundt #if defined(CONFIG_CPU_SUBTYPE_SH7710) ||\
115da2014a2SPaul Mundt 	defined(CONFIG_CPU_SUBTYPE_SH7712)
116da2014a2SPaul Mundt /* SH771X Ethernet driver */
117da2014a2SPaul Mundt static struct resource sh_eth0_resources[] = {
118da2014a2SPaul Mundt 	[0] = {
119da2014a2SPaul Mundt 		.start = SH_ETH0_BASE,
120da2014a2SPaul Mundt 		.end = SH_ETH0_BASE + 0x1B8,
121da2014a2SPaul Mundt 		.flags = IORESOURCE_MEM,
122da2014a2SPaul Mundt 	},
123da2014a2SPaul Mundt 	[1] = {
124da2014a2SPaul Mundt 		.start = SH_ETH0_IRQ,
125da2014a2SPaul Mundt 		.end = SH_ETH0_IRQ,
126da2014a2SPaul Mundt 		.flags = IORESOURCE_IRQ,
127da2014a2SPaul Mundt 	},
128da2014a2SPaul Mundt };
129da2014a2SPaul Mundt 
130da2014a2SPaul Mundt static struct platform_device sh_eth0_device = {
131*7bbe150dSSergei Shtylyov 	.name = "sh771x-ether",
132da2014a2SPaul Mundt 	.id = 0,
133da2014a2SPaul Mundt 	.dev = {
134da2014a2SPaul Mundt 		.platform_data = PHY_ID,
135da2014a2SPaul Mundt 	},
136da2014a2SPaul Mundt 	.num_resources = ARRAY_SIZE(sh_eth0_resources),
137da2014a2SPaul Mundt 	.resource = sh_eth0_resources,
138da2014a2SPaul Mundt };
139da2014a2SPaul Mundt 
140da2014a2SPaul Mundt static struct resource sh_eth1_resources[] = {
141da2014a2SPaul Mundt 	[0] = {
142da2014a2SPaul Mundt 		.start = SH_ETH1_BASE,
143da2014a2SPaul Mundt 		.end = SH_ETH1_BASE + 0x1B8,
144da2014a2SPaul Mundt 		.flags = IORESOURCE_MEM,
145da2014a2SPaul Mundt 	},
146da2014a2SPaul Mundt 	[1] = {
147da2014a2SPaul Mundt 		.start = SH_ETH1_IRQ,
148da2014a2SPaul Mundt 		.end = SH_ETH1_IRQ,
149da2014a2SPaul Mundt 		.flags = IORESOURCE_IRQ,
150da2014a2SPaul Mundt 	},
151da2014a2SPaul Mundt };
152da2014a2SPaul Mundt 
153da2014a2SPaul Mundt static struct platform_device sh_eth1_device = {
154*7bbe150dSSergei Shtylyov 	.name = "sh771x-ether",
155da2014a2SPaul Mundt 	.id = 1,
156da2014a2SPaul Mundt 	.dev = {
157da2014a2SPaul Mundt 		.platform_data = PHY_ID,
158da2014a2SPaul Mundt 	},
159da2014a2SPaul Mundt 	.num_resources = ARRAY_SIZE(sh_eth1_resources),
160da2014a2SPaul Mundt 	.resource = sh_eth1_resources,
161da2014a2SPaul Mundt };
162da2014a2SPaul Mundt #endif
163da2014a2SPaul Mundt 
164da2014a2SPaul Mundt static struct platform_device *se_devices[] __initdata = {
165da2014a2SPaul Mundt 	&heartbeat_device,
166da2014a2SPaul Mundt 	&cf_ide_device,
167da2014a2SPaul Mundt #if defined(CONFIG_CPU_SUBTYPE_SH7710) ||\
168da2014a2SPaul Mundt 	defined(CONFIG_CPU_SUBTYPE_SH7712)
169da2014a2SPaul Mundt 	&sh_eth0_device,
170da2014a2SPaul Mundt 	&sh_eth1_device,
171da2014a2SPaul Mundt #endif
172da2014a2SPaul Mundt };
173da2014a2SPaul Mundt 
174da2014a2SPaul Mundt static int __init se_devices_setup(void)
175da2014a2SPaul Mundt {
176073da9c0SPaul Mundt 	mrshpc_setup_windows();
177da2014a2SPaul Mundt 	return platform_add_devices(se_devices, ARRAY_SIZE(se_devices));
178da2014a2SPaul Mundt }
179da2014a2SPaul Mundt device_initcall(se_devices_setup);
180da2014a2SPaul Mundt 
181da2014a2SPaul Mundt /*
182da2014a2SPaul Mundt  * The Machine Vector
183da2014a2SPaul Mundt  */
184da2014a2SPaul Mundt static struct sh_machine_vector mv_se __initmv = {
185da2014a2SPaul Mundt 	.mv_name		= "SolutionEngine",
186da2014a2SPaul Mundt 	.mv_setup		= smsc_setup,
187da2014a2SPaul Mundt 	.mv_init_irq		= init_se_IRQ,
188da2014a2SPaul Mundt };
189