blob: 77c35350ee774d4fa26ed5bc57b70d9d03c7bcab [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Nobuhiro Iwamatsuaa4a5db2006-12-29 01:50:35 +09002/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 * linux/arch/sh/boards/se/770x/setup.c
4 *
5 * Copyright (C) 2000 Kazumoto Kojima
6 *
7 * Hitachi SolutionEngine Support.
8 *
9 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#include <linux/init.h>
Paul Mundt3b4d9532007-02-13 15:42:28 +090011#include <linux/platform_device.h>
Paul Mundt939a24a2008-07-29 21:41:37 +090012#include <mach-se/mach/se.h>
Paul Mundt073da9c2008-12-17 14:41:54 +090013#include <mach-se/mach/mrshpc.h>
14#include <asm/machvec.h>
Paul Mundt711fa802006-10-03 13:14:04 +090015#include <asm/io.h>
16#include <asm/smc37c93x.h>
Paul Mundt8786c952007-08-20 13:03:41 +090017#include <asm/heartbeat.h>
Paul Mundt2c7834a2006-09-27 18:17:31 +090018
Linus Torvalds1da177e2005-04-16 15:20:36 -070019/*
20 * Configure the Super I/O chip
21 */
22static void __init smsc_config(int index, int data)
23{
24 outb_p(index, INDEX_PORT);
25 outb_p(data, DATA_PORT);
26}
27
Paul Mundt2c7834a2006-09-27 18:17:31 +090028/* XXX: Another candidate for a more generic cchip machine vector */
29static void __init smsc_setup(char **cmdline_p)
Linus Torvalds1da177e2005-04-16 15:20:36 -070030{
31 outb_p(CONFIG_ENTER, CONFIG_PORT);
32 outb_p(CONFIG_ENTER, CONFIG_PORT);
33
34 /* FDC */
35 smsc_config(CURRENT_LDN_INDEX, LDN_FDC);
36 smsc_config(ACTIVATE_INDEX, 0x01);
37 smsc_config(IRQ_SELECT_INDEX, 6); /* IRQ6 */
38
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 /* AUXIO (GPIO): to use IDE1 */
40 smsc_config(CURRENT_LDN_INDEX, LDN_AUXIO);
41 smsc_config(GPIO46_INDEX, 0x00); /* nIOROP */
42 smsc_config(GPIO47_INDEX, 0x00); /* nIOWOP */
43
44 /* COM1 */
45 smsc_config(CURRENT_LDN_INDEX, LDN_COM1);
46 smsc_config(ACTIVATE_INDEX, 0x01);
47 smsc_config(IO_BASE_HI_INDEX, 0x03);
48 smsc_config(IO_BASE_LO_INDEX, 0xf8);
49 smsc_config(IRQ_SELECT_INDEX, 4); /* IRQ4 */
50
51 /* COM2 */
52 smsc_config(CURRENT_LDN_INDEX, LDN_COM2);
53 smsc_config(ACTIVATE_INDEX, 0x01);
54 smsc_config(IO_BASE_HI_INDEX, 0x02);
55 smsc_config(IO_BASE_LO_INDEX, 0xf8);
56 smsc_config(IRQ_SELECT_INDEX, 3); /* IRQ3 */
57
58 /* RTC */
59 smsc_config(CURRENT_LDN_INDEX, LDN_RTC);
60 smsc_config(ACTIVATE_INDEX, 0x01);
61 smsc_config(IRQ_SELECT_INDEX, 8); /* IRQ8 */
62
63 /* XXX: PARPORT, KBD, and MOUSE will come here... */
64 outb_p(CONFIG_EXIT, CONFIG_PORT);
65}
66
Nobuhiro Iwamatsuf987fc82007-03-12 15:12:27 +090067
68static struct resource cf_ide_resources[] = {
69 [0] = {
70 .start = PA_MRSHPC_IO + 0x1f0,
71 .end = PA_MRSHPC_IO + 0x1f0 + 8,
72 .flags = IORESOURCE_MEM,
73 },
74 [1] = {
75 .start = PA_MRSHPC_IO + 0x1f0 + 0x206,
Nobuhiro Iwamatsu787d9d72008-06-18 18:32:03 +090076 .end = PA_MRSHPC_IO + 0x1f0 + 8 + 0x206 + 8,
Nobuhiro Iwamatsuf987fc82007-03-12 15:12:27 +090077 .flags = IORESOURCE_MEM,
78 },
79 [2] = {
Nobuhiro Iwamatsu2a8ff452007-04-26 11:51:00 +090080 .start = IRQ_CFCARD,
Nobuhiro Iwamatsuf987fc82007-03-12 15:12:27 +090081 .flags = IORESOURCE_IRQ,
82 },
83};
84
85static struct platform_device cf_ide_device = {
86 .name = "pata_platform",
87 .id = -1,
88 .num_resources = ARRAY_SIZE(cf_ide_resources),
89 .resource = cf_ide_resources,
90};
91
Paul Mundt3b4d9532007-02-13 15:42:28 +090092static unsigned char heartbeat_bit_pos[] = { 8, 9, 10, 11, 12, 13, 14, 15 };
93
Paul Mundt8786c952007-08-20 13:03:41 +090094static struct heartbeat_data heartbeat_data = {
95 .bit_pos = heartbeat_bit_pos,
96 .nr_bits = ARRAY_SIZE(heartbeat_bit_pos),
97};
98
Paul Mundta09d2832010-01-15 12:24:34 +090099static struct resource heartbeat_resource = {
100 .start = PA_LED,
101 .end = PA_LED,
102 .flags = IORESOURCE_MEM | IORESOURCE_MEM_16BIT,
Paul Mundt3b4d9532007-02-13 15:42:28 +0900103};
104
105static struct platform_device heartbeat_device = {
106 .name = "heartbeat",
107 .id = -1,
108 .dev = {
Paul Mundta1fd3062007-08-23 15:11:44 +0900109 .platform_data = &heartbeat_data,
Paul Mundt3b4d9532007-02-13 15:42:28 +0900110 },
Paul Mundta09d2832010-01-15 12:24:34 +0900111 .num_resources = 1,
112 .resource = &heartbeat_resource,
Paul Mundt3b4d9532007-02-13 15:42:28 +0900113};
114
Nobuhiro Iwamatsu48648412008-07-29 14:37:25 +0900115#if defined(CONFIG_CPU_SUBTYPE_SH7710) ||\
116 defined(CONFIG_CPU_SUBTYPE_SH7712)
Nobuhiro Iwamatsuffb91ad2008-06-18 18:29:06 +0900117/* SH771X Ethernet driver */
118static struct resource sh_eth0_resources[] = {
119 [0] = {
120 .start = SH_ETH0_BASE,
121 .end = SH_ETH0_BASE + 0x1B8,
122 .flags = IORESOURCE_MEM,
123 },
124 [1] = {
125 .start = SH_ETH0_IRQ,
126 .end = SH_ETH0_IRQ,
127 .flags = IORESOURCE_IRQ,
128 },
129};
130
131static struct platform_device sh_eth0_device = {
Sergei Shtylyov7bbe1502013-06-07 13:55:08 +0000132 .name = "sh771x-ether",
133 .id = 0,
Nobuhiro Iwamatsuffb91ad2008-06-18 18:29:06 +0900134 .dev = {
135 .platform_data = PHY_ID,
136 },
137 .num_resources = ARRAY_SIZE(sh_eth0_resources),
138 .resource = sh_eth0_resources,
139};
140
141static struct resource sh_eth1_resources[] = {
142 [0] = {
143 .start = SH_ETH1_BASE,
144 .end = SH_ETH1_BASE + 0x1B8,
145 .flags = IORESOURCE_MEM,
146 },
147 [1] = {
148 .start = SH_ETH1_IRQ,
149 .end = SH_ETH1_IRQ,
150 .flags = IORESOURCE_IRQ,
151 },
152};
153
154static struct platform_device sh_eth1_device = {
Sergei Shtylyov7bbe1502013-06-07 13:55:08 +0000155 .name = "sh771x-ether",
156 .id = 1,
Nobuhiro Iwamatsuffb91ad2008-06-18 18:29:06 +0900157 .dev = {
158 .platform_data = PHY_ID,
159 },
160 .num_resources = ARRAY_SIZE(sh_eth1_resources),
161 .resource = sh_eth1_resources,
162};
Nobuhiro Iwamatsu48648412008-07-29 14:37:25 +0900163#endif
Nobuhiro Iwamatsuffb91ad2008-06-18 18:29:06 +0900164
Paul Mundt3b4d9532007-02-13 15:42:28 +0900165static struct platform_device *se_devices[] __initdata = {
166 &heartbeat_device,
Nobuhiro Iwamatsuf987fc82007-03-12 15:12:27 +0900167 &cf_ide_device,
Nobuhiro Iwamatsu48648412008-07-29 14:37:25 +0900168#if defined(CONFIG_CPU_SUBTYPE_SH7710) ||\
169 defined(CONFIG_CPU_SUBTYPE_SH7712)
Nobuhiro Iwamatsuffb91ad2008-06-18 18:29:06 +0900170 &sh_eth0_device,
171 &sh_eth1_device,
Nobuhiro Iwamatsu48648412008-07-29 14:37:25 +0900172#endif
Paul Mundt3b4d9532007-02-13 15:42:28 +0900173};
174
175static int __init se_devices_setup(void)
176{
Paul Mundt073da9c2008-12-17 14:41:54 +0900177 mrshpc_setup_windows();
Paul Mundt3b4d9532007-02-13 15:42:28 +0900178 return platform_add_devices(se_devices, ARRAY_SIZE(se_devices));
179}
Nobuhiro Iwamatsu9465a542007-03-27 18:13:51 +0900180device_initcall(se_devices_setup);
Paul Mundt3b4d9532007-02-13 15:42:28 +0900181
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182/*
Paul Mundt2c7834a2006-09-27 18:17:31 +0900183 * The Machine Vector
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184 */
Paul Mundt82f81f42007-05-15 15:19:34 +0900185static struct sh_machine_vector mv_se __initmv = {
Paul Mundt2c7834a2006-09-27 18:17:31 +0900186 .mv_name = "SolutionEngine",
187 .mv_setup = smsc_setup,
Paul Mundt2c7834a2006-09-27 18:17:31 +0900188 .mv_init_irq = init_se_IRQ,
Paul Mundt2c7834a2006-09-27 18:17:31 +0900189};