xref: /linux/arch/sh/boards/mach-se/770x/setup.c (revision 664b0bae0b87f69bc9deb098f5e0158b9cf18e04)
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>
12195e2addSSergei 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  */
smsc_config(int index,int data)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 */
smsc_setup(char ** cmdline_p)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 */
119195e2addSSergei Shtylyov static struct sh_eth_plat_data sh_eth_plat = {
120195e2addSSergei Shtylyov 	.phy = PHY_ID,
121195e2addSSergei Shtylyov 	.phy_interface = PHY_INTERFACE_MODE_MII,
122195e2addSSergei Shtylyov };
123195e2addSSergei Shtylyov 
124da2014a2SPaul Mundt static struct resource sh_eth0_resources[] = {
125da2014a2SPaul Mundt 	[0] = {
126da2014a2SPaul Mundt 		.start = SH_ETH0_BASE,
127*f9a531d6SSergei Shtylyov 		.end = SH_ETH0_BASE + 0x1B8 - 1,
128da2014a2SPaul Mundt 		.flags = IORESOURCE_MEM,
129da2014a2SPaul Mundt 	},
130da2014a2SPaul Mundt 	[1] = {
131*f9a531d6SSergei Shtylyov 		.start = SH_TSU_BASE,
132*f9a531d6SSergei Shtylyov 		.end = SH_TSU_BASE + 0x200 - 1,
133*f9a531d6SSergei Shtylyov 		.flags = IORESOURCE_MEM,
134*f9a531d6SSergei Shtylyov 	},
135*f9a531d6SSergei Shtylyov 	[2] = {
136da2014a2SPaul Mundt 		.start = SH_ETH0_IRQ,
137da2014a2SPaul Mundt 		.end = SH_ETH0_IRQ,
138da2014a2SPaul Mundt 		.flags = IORESOURCE_IRQ,
139da2014a2SPaul Mundt 	},
140da2014a2SPaul Mundt };
141da2014a2SPaul Mundt 
142da2014a2SPaul Mundt static struct platform_device sh_eth0_device = {
1437bbe150dSSergei Shtylyov 	.name = "sh771x-ether",
144da2014a2SPaul Mundt 	.id = 0,
145da2014a2SPaul Mundt 	.dev = {
146195e2addSSergei Shtylyov 		.platform_data = &sh_eth_plat,
147da2014a2SPaul Mundt 	},
148da2014a2SPaul Mundt 	.num_resources = ARRAY_SIZE(sh_eth0_resources),
149da2014a2SPaul Mundt 	.resource = sh_eth0_resources,
150da2014a2SPaul Mundt };
151da2014a2SPaul Mundt 
152da2014a2SPaul Mundt static struct resource sh_eth1_resources[] = {
153da2014a2SPaul Mundt 	[0] = {
154da2014a2SPaul Mundt 		.start = SH_ETH1_BASE,
155*f9a531d6SSergei Shtylyov 		.end = SH_ETH1_BASE + 0x1B8 - 1,
156da2014a2SPaul Mundt 		.flags = IORESOURCE_MEM,
157da2014a2SPaul Mundt 	},
158da2014a2SPaul Mundt 	[1] = {
159*f9a531d6SSergei Shtylyov 		.start = SH_TSU_BASE,
160*f9a531d6SSergei Shtylyov 		.end = SH_TSU_BASE + 0x200 - 1,
161*f9a531d6SSergei Shtylyov 		.flags = IORESOURCE_MEM,
162*f9a531d6SSergei Shtylyov 	},
163*f9a531d6SSergei Shtylyov 	[2] = {
164da2014a2SPaul Mundt 		.start = SH_ETH1_IRQ,
165da2014a2SPaul Mundt 		.end = SH_ETH1_IRQ,
166da2014a2SPaul Mundt 		.flags = IORESOURCE_IRQ,
167da2014a2SPaul Mundt 	},
168da2014a2SPaul Mundt };
169da2014a2SPaul Mundt 
170da2014a2SPaul Mundt static struct platform_device sh_eth1_device = {
1717bbe150dSSergei Shtylyov 	.name = "sh771x-ether",
172da2014a2SPaul Mundt 	.id = 1,
173da2014a2SPaul Mundt 	.dev = {
174195e2addSSergei Shtylyov 		.platform_data = &sh_eth_plat,
175da2014a2SPaul Mundt 	},
176da2014a2SPaul Mundt 	.num_resources = ARRAY_SIZE(sh_eth1_resources),
177da2014a2SPaul Mundt 	.resource = sh_eth1_resources,
178da2014a2SPaul Mundt };
179da2014a2SPaul Mundt #endif
180da2014a2SPaul Mundt 
181da2014a2SPaul Mundt static struct platform_device *se_devices[] __initdata = {
182da2014a2SPaul Mundt 	&heartbeat_device,
183da2014a2SPaul Mundt 	&cf_ide_device,
184da2014a2SPaul Mundt #if defined(CONFIG_CPU_SUBTYPE_SH7710) ||\
185da2014a2SPaul Mundt 	defined(CONFIG_CPU_SUBTYPE_SH7712)
186da2014a2SPaul Mundt 	&sh_eth0_device,
187da2014a2SPaul Mundt 	&sh_eth1_device,
188da2014a2SPaul Mundt #endif
189da2014a2SPaul Mundt };
190da2014a2SPaul Mundt 
se_devices_setup(void)191da2014a2SPaul Mundt static int __init se_devices_setup(void)
192da2014a2SPaul Mundt {
193073da9c0SPaul Mundt 	mrshpc_setup_windows();
194da2014a2SPaul Mundt 	return platform_add_devices(se_devices, ARRAY_SIZE(se_devices));
195da2014a2SPaul Mundt }
196da2014a2SPaul Mundt device_initcall(se_devices_setup);
197da2014a2SPaul Mundt 
198da2014a2SPaul Mundt /*
199da2014a2SPaul Mundt  * The Machine Vector
200da2014a2SPaul Mundt  */
201da2014a2SPaul Mundt static struct sh_machine_vector mv_se __initmv = {
202da2014a2SPaul Mundt 	.mv_name		= "SolutionEngine",
203da2014a2SPaul Mundt 	.mv_setup		= smsc_setup,
204da2014a2SPaul Mundt 	.mv_init_irq		= init_se_IRQ,
205da2014a2SPaul Mundt };
206