| Paul Mundt | 94807a3 | 2007-08-08 15:22:04 +0900 | [diff] [blame] | 1 | /* | 
| Paul Mundt | 2c23732 | 2010-10-04 03:00:49 +0900 | [diff] [blame] | 2 |  * arch/sh/boards/mach-x3proto/setup.c | 
| Paul Mundt | 94807a3 | 2007-08-08 15:22:04 +0900 | [diff] [blame] | 3 |  * | 
 | 4 |  * Renesas SH-X3 Prototype Board Support. | 
 | 5 |  * | 
| Paul Mundt | 2c23732 | 2010-10-04 03:00:49 +0900 | [diff] [blame] | 6 |  * Copyright (C) 2007 - 2010  Paul Mundt | 
| Paul Mundt | 94807a3 | 2007-08-08 15:22:04 +0900 | [diff] [blame] | 7 |  * | 
 | 8 |  * This file is subject to the terms and conditions of the GNU General Public | 
 | 9 |  * License.  See the file "COPYING" in the main directory of this archive | 
 | 10 |  * for more details. | 
 | 11 |  */ | 
 | 12 | #include <linux/init.h> | 
 | 13 | #include <linux/platform_device.h> | 
 | 14 | #include <linux/kernel.h> | 
 | 15 | #include <linux/io.h> | 
| Paul Mundt | e77eb36 | 2008-08-05 13:16:56 +0900 | [diff] [blame] | 16 | #include <linux/smc91x.h> | 
| Paul Mundt | 10f0fc1 | 2009-01-07 17:45:02 +0900 | [diff] [blame] | 17 | #include <linux/irq.h> | 
| Yoshihiro Shimoda | fcaf99d | 2009-05-26 09:33:08 +0000 | [diff] [blame] | 18 | #include <linux/interrupt.h> | 
| Paul Mundt | 2c23732 | 2010-10-04 03:00:49 +0900 | [diff] [blame] | 19 | #include <linux/input.h> | 
| Yoshihiro Shimoda | fcaf99d | 2009-05-26 09:33:08 +0000 | [diff] [blame] | 20 | #include <linux/usb/r8a66597.h> | 
| Magnus Damm | 2c59b0b | 2009-07-22 14:41:35 +0000 | [diff] [blame] | 21 | #include <linux/usb/m66592.h> | 
| Paul Mundt | 2c23732 | 2010-10-04 03:00:49 +0900 | [diff] [blame] | 22 | #include <linux/gpio.h> | 
 | 23 | #include <linux/gpio_keys.h> | 
| Paul Mundt | d39d0ed | 2010-10-04 02:50:32 +0900 | [diff] [blame] | 24 | #include <mach/ilsel.h> | 
| Paul Mundt | 2c23732 | 2010-10-04 03:00:49 +0900 | [diff] [blame] | 25 | #include <mach/hardware.h> | 
| Paul Mundt | 3366e35 | 2010-03-30 12:38:01 +0900 | [diff] [blame] | 26 | #include <asm/smp-ops.h> | 
| Paul Mundt | 94807a3 | 2007-08-08 15:22:04 +0900 | [diff] [blame] | 27 |  | 
 | 28 | static struct resource heartbeat_resources[] = { | 
 | 29 | 	[0] = { | 
 | 30 | 		.start	= 0xb8140020, | 
| Paul Mundt | a1fd306 | 2007-08-23 15:11:44 +0900 | [diff] [blame] | 31 | 		.end	= 0xb8140020, | 
| Paul Mundt | 94807a3 | 2007-08-08 15:22:04 +0900 | [diff] [blame] | 32 | 		.flags	= IORESOURCE_MEM, | 
 | 33 | 	}, | 
 | 34 | }; | 
 | 35 |  | 
 | 36 | static struct platform_device heartbeat_device = { | 
 | 37 | 	.name		= "heartbeat", | 
 | 38 | 	.id		= -1, | 
 | 39 | 	.num_resources	= ARRAY_SIZE(heartbeat_resources), | 
 | 40 | 	.resource	= heartbeat_resources, | 
 | 41 | }; | 
 | 42 |  | 
| Paul Mundt | e77eb36 | 2008-08-05 13:16:56 +0900 | [diff] [blame] | 43 | static struct smc91x_platdata smc91x_info = { | 
 | 44 | 	.flags	= SMC91X_USE_16BIT | SMC91X_NOWAIT, | 
 | 45 | }; | 
 | 46 |  | 
| Paul Mundt | e7109a9 | 2007-08-08 15:27:55 +0900 | [diff] [blame] | 47 | static struct resource smc91x_resources[] = { | 
 | 48 | 	[0] = { | 
 | 49 | 		.start		= 0x18000300, | 
 | 50 | 		.end		= 0x18000300 + 0x10 - 1, | 
 | 51 | 		.flags		= IORESOURCE_MEM, | 
 | 52 | 	}, | 
 | 53 | 	[1] = { | 
 | 54 | 		/* Filled in by ilsel */ | 
 | 55 | 		.flags		= IORESOURCE_IRQ, | 
 | 56 | 	}, | 
 | 57 | }; | 
 | 58 |  | 
 | 59 | static struct platform_device smc91x_device = { | 
 | 60 | 	.name		= "smc91x", | 
 | 61 | 	.id		= -1, | 
 | 62 | 	.resource	= smc91x_resources, | 
 | 63 | 	.num_resources	= ARRAY_SIZE(smc91x_resources), | 
| Paul Mundt | e77eb36 | 2008-08-05 13:16:56 +0900 | [diff] [blame] | 64 | 	.dev	= { | 
 | 65 | 		.platform_data = &smc91x_info, | 
 | 66 | 	}, | 
| Paul Mundt | e7109a9 | 2007-08-08 15:27:55 +0900 | [diff] [blame] | 67 | }; | 
 | 68 |  | 
| Yoshihiro Shimoda | fcaf99d | 2009-05-26 09:33:08 +0000 | [diff] [blame] | 69 | static struct r8a66597_platdata r8a66597_data = { | 
 | 70 | 	.xtal = R8A66597_PLATDATA_XTAL_12MHZ, | 
 | 71 | 	.vif = 1, | 
 | 72 | }; | 
 | 73 |  | 
| Paul Mundt | e7109a9 | 2007-08-08 15:27:55 +0900 | [diff] [blame] | 74 | static struct resource r8a66597_usb_host_resources[] = { | 
 | 75 | 	[0] = { | 
| Paul Mundt | e7109a9 | 2007-08-08 15:27:55 +0900 | [diff] [blame] | 76 | 		.start	= 0x18040000, | 
 | 77 | 		.end	= 0x18080000 - 1, | 
 | 78 | 		.flags	= IORESOURCE_MEM, | 
 | 79 | 	}, | 
 | 80 | 	[1] = { | 
| Paul Mundt | e7109a9 | 2007-08-08 15:27:55 +0900 | [diff] [blame] | 81 | 		/* Filled in by ilsel */ | 
| Yoshihiro Shimoda | fcaf99d | 2009-05-26 09:33:08 +0000 | [diff] [blame] | 82 | 		.flags	= IORESOURCE_IRQ | IRQF_TRIGGER_LOW, | 
| Paul Mundt | e7109a9 | 2007-08-08 15:27:55 +0900 | [diff] [blame] | 83 | 	}, | 
 | 84 | }; | 
 | 85 |  | 
 | 86 | static struct platform_device r8a66597_usb_host_device = { | 
 | 87 | 	.name		= "r8a66597_hcd", | 
 | 88 | 	.id		= -1, | 
 | 89 | 	.dev = { | 
 | 90 | 		.dma_mask		= NULL,		/* don't use dma */ | 
 | 91 | 		.coherent_dma_mask	= 0xffffffff, | 
| Yoshihiro Shimoda | fcaf99d | 2009-05-26 09:33:08 +0000 | [diff] [blame] | 92 | 		.platform_data		= &r8a66597_data, | 
| Paul Mundt | e7109a9 | 2007-08-08 15:27:55 +0900 | [diff] [blame] | 93 | 	}, | 
 | 94 | 	.num_resources	= ARRAY_SIZE(r8a66597_usb_host_resources), | 
 | 95 | 	.resource	= r8a66597_usb_host_resources, | 
 | 96 | }; | 
 | 97 |  | 
| Magnus Damm | 2c59b0b | 2009-07-22 14:41:35 +0000 | [diff] [blame] | 98 | static struct m66592_platdata usbf_platdata = { | 
 | 99 | 	.xtal = M66592_PLATDATA_XTAL_24MHZ, | 
 | 100 | 	.vif = 1, | 
 | 101 | }; | 
 | 102 |  | 
| Paul Mundt | e7109a9 | 2007-08-08 15:27:55 +0900 | [diff] [blame] | 103 | static struct resource m66592_usb_peripheral_resources[] = { | 
 | 104 | 	[0] = { | 
 | 105 | 		.name	= "m66592_udc", | 
 | 106 | 		.start	= 0x18080000, | 
 | 107 | 		.end	= 0x180c0000 - 1, | 
 | 108 | 		.flags	= IORESOURCE_MEM, | 
 | 109 | 	}, | 
 | 110 | 	[1] = { | 
 | 111 | 		.name	= "m66592_udc", | 
 | 112 | 		/* Filled in by ilsel */ | 
 | 113 | 		.flags	= IORESOURCE_IRQ, | 
 | 114 | 	}, | 
 | 115 | }; | 
 | 116 |  | 
 | 117 | static struct platform_device m66592_usb_peripheral_device = { | 
 | 118 | 	.name		= "m66592_udc", | 
 | 119 | 	.id		= -1, | 
 | 120 | 	.dev = { | 
 | 121 | 		.dma_mask		= NULL,		/* don't use dma */ | 
 | 122 | 		.coherent_dma_mask	= 0xffffffff, | 
| Magnus Damm | 2c59b0b | 2009-07-22 14:41:35 +0000 | [diff] [blame] | 123 | 		.platform_data		= &usbf_platdata, | 
| Paul Mundt | e7109a9 | 2007-08-08 15:27:55 +0900 | [diff] [blame] | 124 | 	}, | 
 | 125 | 	.num_resources	= ARRAY_SIZE(m66592_usb_peripheral_resources), | 
 | 126 | 	.resource	= m66592_usb_peripheral_resources, | 
 | 127 | }; | 
 | 128 |  | 
| Paul Mundt | 2c23732 | 2010-10-04 03:00:49 +0900 | [diff] [blame] | 129 | static struct gpio_keys_button baseboard_buttons[NR_BASEBOARD_GPIOS] = { | 
 | 130 | 	{ | 
 | 131 | 		.desc		= "key44", | 
 | 132 | 		.code		= KEY_POWER, | 
 | 133 | 		.active_low	= 1, | 
 | 134 | 		.wakeup		= 1, | 
 | 135 | 	}, { | 
 | 136 | 		.desc		= "key43", | 
 | 137 | 		.code		= KEY_SUSPEND, | 
 | 138 | 		.active_low	= 1, | 
 | 139 | 		.wakeup		= 1, | 
 | 140 | 	}, { | 
 | 141 | 		.desc		= "key42", | 
 | 142 | 		.code		= KEY_KATAKANAHIRAGANA, | 
 | 143 | 		.active_low	= 1, | 
 | 144 | 	}, { | 
 | 145 | 		.desc		= "key41", | 
 | 146 | 		.code		= KEY_SWITCHVIDEOMODE, | 
 | 147 | 		.active_low	= 1, | 
 | 148 | 	}, { | 
 | 149 | 		.desc		= "key34", | 
 | 150 | 		.code		= KEY_F12, | 
 | 151 | 		.active_low	= 1, | 
 | 152 | 	}, { | 
 | 153 | 		.desc		= "key33", | 
 | 154 | 		.code		= KEY_F11, | 
 | 155 | 		.active_low	= 1, | 
 | 156 | 	}, { | 
 | 157 | 		.desc		= "key32", | 
 | 158 | 		.code		= KEY_F10, | 
 | 159 | 		.active_low	= 1, | 
 | 160 | 	}, { | 
 | 161 | 		.desc		= "key31", | 
 | 162 | 		.code		= KEY_F9, | 
 | 163 | 		.active_low	= 1, | 
 | 164 | 	}, { | 
 | 165 | 		.desc		= "key24", | 
 | 166 | 		.code		= KEY_F8, | 
 | 167 | 		.active_low	= 1, | 
 | 168 | 	}, { | 
 | 169 | 		.desc		= "key23", | 
 | 170 | 		.code		= KEY_F7, | 
 | 171 | 		.active_low	= 1, | 
 | 172 | 	}, { | 
 | 173 | 		.desc		= "key22", | 
 | 174 | 		.code		= KEY_F6, | 
 | 175 | 		.active_low	= 1, | 
 | 176 | 	}, { | 
 | 177 | 		.desc		= "key21", | 
 | 178 | 		.code		= KEY_F5, | 
 | 179 | 		.active_low	= 1, | 
 | 180 | 	}, { | 
 | 181 | 		.desc		= "key14", | 
 | 182 | 		.code		= KEY_F4, | 
 | 183 | 		.active_low	= 1, | 
 | 184 | 	}, { | 
 | 185 | 		.desc		= "key13", | 
 | 186 | 		.code		= KEY_F3, | 
 | 187 | 		.active_low	= 1, | 
 | 188 | 	}, { | 
 | 189 | 		.desc		= "key12", | 
 | 190 | 		.code		= KEY_F2, | 
 | 191 | 		.active_low	= 1, | 
 | 192 | 	}, { | 
 | 193 | 		.desc		= "key11", | 
 | 194 | 		.code		= KEY_F1, | 
 | 195 | 		.active_low	= 1, | 
 | 196 | 	}, | 
 | 197 | }; | 
 | 198 |  | 
 | 199 | static struct gpio_keys_platform_data baseboard_buttons_data = { | 
 | 200 | 	.buttons	= baseboard_buttons, | 
 | 201 | 	.nbuttons	= ARRAY_SIZE(baseboard_buttons), | 
 | 202 | }; | 
 | 203 |  | 
 | 204 | static struct platform_device baseboard_buttons_device = { | 
 | 205 | 	.name		= "gpio-keys", | 
 | 206 | 	.id		= -1, | 
 | 207 | 	.dev		= { | 
 | 208 | 		.platform_data	= &baseboard_buttons_data, | 
 | 209 | 	}, | 
 | 210 | }; | 
 | 211 |  | 
| Paul Mundt | 94807a3 | 2007-08-08 15:22:04 +0900 | [diff] [blame] | 212 | static struct platform_device *x3proto_devices[] __initdata = { | 
 | 213 | 	&heartbeat_device, | 
| Paul Mundt | e7109a9 | 2007-08-08 15:27:55 +0900 | [diff] [blame] | 214 | 	&smc91x_device, | 
 | 215 | 	&r8a66597_usb_host_device, | 
 | 216 | 	&m66592_usb_peripheral_device, | 
| Paul Mundt | 2c23732 | 2010-10-04 03:00:49 +0900 | [diff] [blame] | 217 | 	&baseboard_buttons_device, | 
| Paul Mundt | 94807a3 | 2007-08-08 15:22:04 +0900 | [diff] [blame] | 218 | }; | 
 | 219 |  | 
| Paul Mundt | 4bacd79 | 2010-10-02 22:02:07 +0900 | [diff] [blame] | 220 | static void __init x3proto_init_irq(void) | 
 | 221 | { | 
 | 222 | 	plat_irq_setup_pins(IRQ_MODE_IRL3210); | 
 | 223 |  | 
 | 224 | 	/* Set ICR0.LVLMODE */ | 
 | 225 | 	__raw_writel(__raw_readl(0xfe410000) | (1 << 21), 0xfe410000); | 
 | 226 | } | 
 | 227 |  | 
| Paul Mundt | 94807a3 | 2007-08-08 15:22:04 +0900 | [diff] [blame] | 228 | static int __init x3proto_devices_setup(void) | 
 | 229 | { | 
| Paul Mundt | 2c23732 | 2010-10-04 03:00:49 +0900 | [diff] [blame] | 230 | 	int ret, i; | 
 | 231 |  | 
| Paul Mundt | 4bacd79 | 2010-10-02 22:02:07 +0900 | [diff] [blame] | 232 | 	/* | 
 | 233 | 	 * IRLs are only needed for ILSEL mappings, so flip over the INTC | 
 | 234 | 	 * pins at a later point to enable the GPIOs to settle. | 
 | 235 | 	 */ | 
 | 236 | 	x3proto_init_irq(); | 
 | 237 |  | 
| Paul Mundt | 2c23732 | 2010-10-04 03:00:49 +0900 | [diff] [blame] | 238 | 	/* | 
 | 239 | 	 * Now that ILSELs are available, set up the baseboard GPIOs. | 
 | 240 | 	 */ | 
 | 241 | 	ret = x3proto_gpio_setup(); | 
 | 242 | 	if (unlikely(ret)) | 
 | 243 | 		return ret; | 
 | 244 |  | 
 | 245 | 	/* | 
 | 246 | 	 * Propagate dynamic GPIOs for the baseboard button device. | 
 | 247 | 	 */ | 
 | 248 | 	for (i = 0; i < ARRAY_SIZE(baseboard_buttons); i++) | 
 | 249 | 		baseboard_buttons[i].gpio = x3proto_gpio_chip.base + i; | 
 | 250 |  | 
| Paul Mundt | e7109a9 | 2007-08-08 15:27:55 +0900 | [diff] [blame] | 251 | 	r8a66597_usb_host_resources[1].start = | 
 | 252 | 		r8a66597_usb_host_resources[1].end = ilsel_enable(ILSEL_USBH_I); | 
 | 253 |  | 
 | 254 | 	m66592_usb_peripheral_resources[1].start = | 
 | 255 | 		m66592_usb_peripheral_resources[1].end = ilsel_enable(ILSEL_USBP_I); | 
 | 256 |  | 
 | 257 | 	smc91x_resources[1].start = | 
 | 258 | 		smc91x_resources[1].end = ilsel_enable(ILSEL_LAN); | 
 | 259 |  | 
| Paul Mundt | 94807a3 | 2007-08-08 15:22:04 +0900 | [diff] [blame] | 260 | 	return platform_add_devices(x3proto_devices, | 
 | 261 | 				    ARRAY_SIZE(x3proto_devices)); | 
 | 262 | } | 
 | 263 | device_initcall(x3proto_devices_setup); | 
 | 264 |  | 
| Paul Mundt | 3366e35 | 2010-03-30 12:38:01 +0900 | [diff] [blame] | 265 | static void __init x3proto_setup(char **cmdline_p) | 
 | 266 | { | 
 | 267 | 	register_smp_ops(&shx3_smp_ops); | 
 | 268 | } | 
 | 269 |  | 
| Paul Mundt | 94807a3 | 2007-08-08 15:22:04 +0900 | [diff] [blame] | 270 | static struct sh_machine_vector mv_x3proto __initmv = { | 
 | 271 | 	.mv_name		= "x3proto", | 
| Paul Mundt | 3366e35 | 2010-03-30 12:38:01 +0900 | [diff] [blame] | 272 | 	.mv_setup		= x3proto_setup, | 
| Paul Mundt | 94807a3 | 2007-08-08 15:22:04 +0900 | [diff] [blame] | 273 | }; |