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