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