Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 1 | /* |
| 2 | * r8a7779 processor support |
| 3 | * |
Sergei Shtylyov | dace48d | 2013-04-04 18:53:50 +0000 | [diff] [blame] | 4 | * Copyright (C) 2011, 2013 Renesas Solutions Corp. |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 5 | * Copyright (C) 2011 Magnus Damm |
Sergei Shtylyov | dace48d | 2013-04-04 18:53:50 +0000 | [diff] [blame] | 6 | * Copyright (C) 2013 Cogent Embedded, Inc. |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; version 2 of the License. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | */ |
| 21 | #include <linux/kernel.h> |
| 22 | #include <linux/init.h> |
| 23 | #include <linux/interrupt.h> |
| 24 | #include <linux/irq.h> |
Simon Horman | 10e8d4f | 2012-11-21 22:00:15 +0900 | [diff] [blame] | 25 | #include <linux/of_platform.h> |
Laurent Pinchart | 37a72d0 | 2013-03-10 03:31:51 +0100 | [diff] [blame] | 26 | #include <linux/platform_data/gpio-rcar.h> |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 27 | #include <linux/platform_device.h> |
| 28 | #include <linux/delay.h> |
| 29 | #include <linux/input.h> |
| 30 | #include <linux/io.h> |
| 31 | #include <linux/serial_sci.h> |
| 32 | #include <linux/sh_intc.h> |
| 33 | #include <linux/sh_timer.h> |
Vladimir Barinov | a7b9837 | 2013-02-27 23:39:14 +0300 | [diff] [blame] | 34 | #include <linux/dma-mapping.h> |
Sergei Shtylyov | 2c8788b | 2013-06-02 01:30:15 +0400 | [diff] [blame^] | 35 | #include <linux/usb/otg.h> |
| 36 | #include <linux/usb/ehci_pdriver.h> |
| 37 | #include <linux/usb/ohci_pdriver.h> |
| 38 | #include <linux/pm_runtime.h> |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 39 | #include <mach/hardware.h> |
Rob Herring | 250a272 | 2012-01-03 16:57:33 -0600 | [diff] [blame] | 40 | #include <mach/irqs.h> |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 41 | #include <mach/r8a7779.h> |
Magnus Damm | a662c08 | 2012-01-10 15:50:01 +0900 | [diff] [blame] | 42 | #include <mach/common.h> |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 43 | #include <asm/mach-types.h> |
| 44 | #include <asm/mach/arch.h> |
Magnus Damm | df27a2d | 2012-03-06 17:37:01 +0900 | [diff] [blame] | 45 | #include <asm/mach/time.h> |
Magnus Damm | 3e353b87 | 2012-02-29 21:37:43 +0900 | [diff] [blame] | 46 | #include <asm/mach/map.h> |
Magnus Damm | 8bac13f | 2012-03-01 12:48:03 +0900 | [diff] [blame] | 47 | #include <asm/hardware/cache-l2x0.h> |
Magnus Damm | 3e353b87 | 2012-02-29 21:37:43 +0900 | [diff] [blame] | 48 | |
| 49 | static struct map_desc r8a7779_io_desc[] __initdata = { |
| 50 | /* 2M entity map for 0xf0000000 (MPCORE) */ |
| 51 | { |
| 52 | .virtual = 0xf0000000, |
| 53 | .pfn = __phys_to_pfn(0xf0000000), |
| 54 | .length = SZ_2M, |
| 55 | .type = MT_DEVICE_NONSHARED |
| 56 | }, |
| 57 | /* 16M entity map for 0xfexxxxxx (DMAC-S/HPBREG/INTC2/LRAM/DBSC) */ |
| 58 | { |
| 59 | .virtual = 0xfe000000, |
| 60 | .pfn = __phys_to_pfn(0xfe000000), |
| 61 | .length = SZ_16M, |
| 62 | .type = MT_DEVICE_NONSHARED |
| 63 | }, |
| 64 | }; |
| 65 | |
| 66 | void __init r8a7779_map_io(void) |
| 67 | { |
| 68 | iotable_init(r8a7779_io_desc, ARRAY_SIZE(r8a7779_io_desc)); |
| 69 | } |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 70 | |
Laurent Pinchart | 8b6edf3 | 2012-12-15 23:51:26 +0100 | [diff] [blame] | 71 | static struct resource r8a7779_pfc_resources[] = { |
Magnus Damm | 0ccaf5b | 2013-04-12 14:21:29 +0200 | [diff] [blame] | 72 | DEFINE_RES_MEM(0xfffc0000, 0x023c), |
Laurent Pinchart | 8b6edf3 | 2012-12-15 23:51:26 +0100 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | static struct platform_device r8a7779_pfc_device = { |
| 76 | .name = "pfc-r8a7779", |
| 77 | .id = -1, |
| 78 | .resource = r8a7779_pfc_resources, |
| 79 | .num_resources = ARRAY_SIZE(r8a7779_pfc_resources), |
| 80 | }; |
| 81 | |
Laurent Pinchart | 37a72d0 | 2013-03-10 03:31:51 +0100 | [diff] [blame] | 82 | #define R8A7779_GPIO(idx, npins) \ |
| 83 | static struct resource r8a7779_gpio##idx##_resources[] = { \ |
Magnus Damm | 0ccaf5b | 2013-04-12 14:21:29 +0200 | [diff] [blame] | 84 | DEFINE_RES_MEM(0xffc40000 + (0x1000 * (idx)), 0x002c), \ |
| 85 | DEFINE_RES_IRQ(gic_iid(0xad + (idx))), \ |
Laurent Pinchart | 37a72d0 | 2013-03-10 03:31:51 +0100 | [diff] [blame] | 86 | }; \ |
| 87 | \ |
| 88 | static struct gpio_rcar_config r8a7779_gpio##idx##_platform_data = { \ |
| 89 | .gpio_base = 32 * (idx), \ |
| 90 | .irq_base = 0, \ |
| 91 | .number_of_pins = npins, \ |
| 92 | .pctl_name = "pfc-r8a7779", \ |
| 93 | }; \ |
| 94 | \ |
| 95 | static struct platform_device r8a7779_gpio##idx##_device = { \ |
| 96 | .name = "gpio_rcar", \ |
| 97 | .id = idx, \ |
| 98 | .resource = r8a7779_gpio##idx##_resources, \ |
| 99 | .num_resources = ARRAY_SIZE(r8a7779_gpio##idx##_resources), \ |
| 100 | .dev = { \ |
| 101 | .platform_data = &r8a7779_gpio##idx##_platform_data, \ |
| 102 | }, \ |
| 103 | } |
| 104 | |
| 105 | R8A7779_GPIO(0, 32); |
| 106 | R8A7779_GPIO(1, 32); |
| 107 | R8A7779_GPIO(2, 32); |
| 108 | R8A7779_GPIO(3, 32); |
| 109 | R8A7779_GPIO(4, 32); |
| 110 | R8A7779_GPIO(5, 32); |
| 111 | R8A7779_GPIO(6, 9); |
| 112 | |
| 113 | static struct platform_device *r8a7779_pinctrl_devices[] __initdata = { |
| 114 | &r8a7779_pfc_device, |
| 115 | &r8a7779_gpio0_device, |
| 116 | &r8a7779_gpio1_device, |
| 117 | &r8a7779_gpio2_device, |
| 118 | &r8a7779_gpio3_device, |
| 119 | &r8a7779_gpio4_device, |
| 120 | &r8a7779_gpio5_device, |
| 121 | &r8a7779_gpio6_device, |
| 122 | }; |
| 123 | |
Laurent Pinchart | 8b6edf3 | 2012-12-15 23:51:26 +0100 | [diff] [blame] | 124 | void __init r8a7779_pinmux_init(void) |
| 125 | { |
Laurent Pinchart | 37a72d0 | 2013-03-10 03:31:51 +0100 | [diff] [blame] | 126 | platform_add_devices(r8a7779_pinctrl_devices, |
| 127 | ARRAY_SIZE(r8a7779_pinctrl_devices)); |
Laurent Pinchart | 8b6edf3 | 2012-12-15 23:51:26 +0100 | [diff] [blame] | 128 | } |
| 129 | |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 130 | static struct plat_sci_port scif0_platform_data = { |
| 131 | .mapbase = 0xffe40000, |
| 132 | .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, |
| 133 | .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1, |
| 134 | .scbrr_algo_id = SCBRR_ALGO_2, |
| 135 | .type = PORT_SCIF, |
Kuninori Morimoto | dbe95ad | 2013-03-03 23:11:41 -0800 | [diff] [blame] | 136 | .irqs = SCIx_IRQ_MUXED(gic_iid(0x78)), |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 137 | }; |
| 138 | |
| 139 | static struct platform_device scif0_device = { |
| 140 | .name = "sh-sci", |
| 141 | .id = 0, |
| 142 | .dev = { |
| 143 | .platform_data = &scif0_platform_data, |
| 144 | }, |
| 145 | }; |
| 146 | |
| 147 | static struct plat_sci_port scif1_platform_data = { |
| 148 | .mapbase = 0xffe41000, |
| 149 | .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, |
| 150 | .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1, |
| 151 | .scbrr_algo_id = SCBRR_ALGO_2, |
| 152 | .type = PORT_SCIF, |
Kuninori Morimoto | dbe95ad | 2013-03-03 23:11:41 -0800 | [diff] [blame] | 153 | .irqs = SCIx_IRQ_MUXED(gic_iid(0x79)), |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 154 | }; |
| 155 | |
| 156 | static struct platform_device scif1_device = { |
| 157 | .name = "sh-sci", |
| 158 | .id = 1, |
| 159 | .dev = { |
| 160 | .platform_data = &scif1_platform_data, |
| 161 | }, |
| 162 | }; |
| 163 | |
| 164 | static struct plat_sci_port scif2_platform_data = { |
| 165 | .mapbase = 0xffe42000, |
| 166 | .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, |
| 167 | .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1, |
| 168 | .scbrr_algo_id = SCBRR_ALGO_2, |
| 169 | .type = PORT_SCIF, |
Kuninori Morimoto | dbe95ad | 2013-03-03 23:11:41 -0800 | [diff] [blame] | 170 | .irqs = SCIx_IRQ_MUXED(gic_iid(0x7a)), |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 171 | }; |
| 172 | |
| 173 | static struct platform_device scif2_device = { |
| 174 | .name = "sh-sci", |
| 175 | .id = 2, |
| 176 | .dev = { |
| 177 | .platform_data = &scif2_platform_data, |
| 178 | }, |
| 179 | }; |
| 180 | |
| 181 | static struct plat_sci_port scif3_platform_data = { |
| 182 | .mapbase = 0xffe43000, |
| 183 | .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, |
| 184 | .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1, |
| 185 | .scbrr_algo_id = SCBRR_ALGO_2, |
| 186 | .type = PORT_SCIF, |
Kuninori Morimoto | dbe95ad | 2013-03-03 23:11:41 -0800 | [diff] [blame] | 187 | .irqs = SCIx_IRQ_MUXED(gic_iid(0x7b)), |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 188 | }; |
| 189 | |
| 190 | static struct platform_device scif3_device = { |
| 191 | .name = "sh-sci", |
| 192 | .id = 3, |
| 193 | .dev = { |
| 194 | .platform_data = &scif3_platform_data, |
| 195 | }, |
| 196 | }; |
| 197 | |
| 198 | static struct plat_sci_port scif4_platform_data = { |
| 199 | .mapbase = 0xffe44000, |
| 200 | .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, |
| 201 | .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1, |
| 202 | .scbrr_algo_id = SCBRR_ALGO_2, |
| 203 | .type = PORT_SCIF, |
Kuninori Morimoto | dbe95ad | 2013-03-03 23:11:41 -0800 | [diff] [blame] | 204 | .irqs = SCIx_IRQ_MUXED(gic_iid(0x7c)), |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 205 | }; |
| 206 | |
| 207 | static struct platform_device scif4_device = { |
| 208 | .name = "sh-sci", |
| 209 | .id = 4, |
| 210 | .dev = { |
| 211 | .platform_data = &scif4_platform_data, |
| 212 | }, |
| 213 | }; |
| 214 | |
| 215 | static struct plat_sci_port scif5_platform_data = { |
| 216 | .mapbase = 0xffe45000, |
| 217 | .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, |
| 218 | .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1, |
| 219 | .scbrr_algo_id = SCBRR_ALGO_2, |
| 220 | .type = PORT_SCIF, |
Kuninori Morimoto | dbe95ad | 2013-03-03 23:11:41 -0800 | [diff] [blame] | 221 | .irqs = SCIx_IRQ_MUXED(gic_iid(0x7d)), |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 222 | }; |
| 223 | |
| 224 | static struct platform_device scif5_device = { |
| 225 | .name = "sh-sci", |
| 226 | .id = 5, |
| 227 | .dev = { |
| 228 | .platform_data = &scif5_platform_data, |
| 229 | }, |
| 230 | }; |
| 231 | |
| 232 | /* TMU */ |
| 233 | static struct sh_timer_config tmu00_platform_data = { |
| 234 | .name = "TMU00", |
| 235 | .channel_offset = 0x4, |
| 236 | .timer_bit = 0, |
| 237 | .clockevent_rating = 200, |
| 238 | }; |
| 239 | |
| 240 | static struct resource tmu00_resources[] = { |
| 241 | [0] = { |
| 242 | .name = "TMU00", |
| 243 | .start = 0xffd80008, |
| 244 | .end = 0xffd80013, |
| 245 | .flags = IORESOURCE_MEM, |
| 246 | }, |
| 247 | [1] = { |
Kuninori Morimoto | dbe95ad | 2013-03-03 23:11:41 -0800 | [diff] [blame] | 248 | .start = gic_iid(0x40), |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 249 | .flags = IORESOURCE_IRQ, |
| 250 | }, |
| 251 | }; |
| 252 | |
| 253 | static struct platform_device tmu00_device = { |
| 254 | .name = "sh_tmu", |
| 255 | .id = 0, |
| 256 | .dev = { |
| 257 | .platform_data = &tmu00_platform_data, |
| 258 | }, |
| 259 | .resource = tmu00_resources, |
| 260 | .num_resources = ARRAY_SIZE(tmu00_resources), |
| 261 | }; |
| 262 | |
| 263 | static struct sh_timer_config tmu01_platform_data = { |
| 264 | .name = "TMU01", |
| 265 | .channel_offset = 0x10, |
| 266 | .timer_bit = 1, |
| 267 | .clocksource_rating = 200, |
| 268 | }; |
| 269 | |
| 270 | static struct resource tmu01_resources[] = { |
| 271 | [0] = { |
| 272 | .name = "TMU01", |
| 273 | .start = 0xffd80014, |
| 274 | .end = 0xffd8001f, |
| 275 | .flags = IORESOURCE_MEM, |
| 276 | }, |
| 277 | [1] = { |
Kuninori Morimoto | dbe95ad | 2013-03-03 23:11:41 -0800 | [diff] [blame] | 278 | .start = gic_iid(0x41), |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 279 | .flags = IORESOURCE_IRQ, |
| 280 | }, |
| 281 | }; |
| 282 | |
| 283 | static struct platform_device tmu01_device = { |
| 284 | .name = "sh_tmu", |
| 285 | .id = 1, |
| 286 | .dev = { |
| 287 | .platform_data = &tmu01_platform_data, |
| 288 | }, |
| 289 | .resource = tmu01_resources, |
| 290 | .num_resources = ARRAY_SIZE(tmu01_resources), |
| 291 | }; |
| 292 | |
Kuninori Morimoto | ccc2a27 | 2012-10-10 19:56:51 -0700 | [diff] [blame] | 293 | /* I2C */ |
| 294 | static struct resource rcar_i2c0_res[] = { |
| 295 | { |
| 296 | .start = 0xffc70000, |
| 297 | .end = 0xffc70fff, |
| 298 | .flags = IORESOURCE_MEM, |
| 299 | }, { |
Kuninori Morimoto | dbe95ad | 2013-03-03 23:11:41 -0800 | [diff] [blame] | 300 | .start = gic_iid(0x6f), |
Kuninori Morimoto | ccc2a27 | 2012-10-10 19:56:51 -0700 | [diff] [blame] | 301 | .flags = IORESOURCE_IRQ, |
| 302 | }, |
| 303 | }; |
| 304 | |
| 305 | static struct platform_device i2c0_device = { |
| 306 | .name = "i2c-rcar", |
| 307 | .id = 0, |
| 308 | .resource = rcar_i2c0_res, |
| 309 | .num_resources = ARRAY_SIZE(rcar_i2c0_res), |
| 310 | }; |
| 311 | |
| 312 | static struct resource rcar_i2c1_res[] = { |
| 313 | { |
| 314 | .start = 0xffc71000, |
| 315 | .end = 0xffc71fff, |
| 316 | .flags = IORESOURCE_MEM, |
| 317 | }, { |
Kuninori Morimoto | dbe95ad | 2013-03-03 23:11:41 -0800 | [diff] [blame] | 318 | .start = gic_iid(0x72), |
Kuninori Morimoto | ccc2a27 | 2012-10-10 19:56:51 -0700 | [diff] [blame] | 319 | .flags = IORESOURCE_IRQ, |
| 320 | }, |
| 321 | }; |
| 322 | |
| 323 | static struct platform_device i2c1_device = { |
| 324 | .name = "i2c-rcar", |
| 325 | .id = 1, |
| 326 | .resource = rcar_i2c1_res, |
| 327 | .num_resources = ARRAY_SIZE(rcar_i2c1_res), |
| 328 | }; |
| 329 | |
| 330 | static struct resource rcar_i2c2_res[] = { |
| 331 | { |
| 332 | .start = 0xffc72000, |
| 333 | .end = 0xffc72fff, |
| 334 | .flags = IORESOURCE_MEM, |
| 335 | }, { |
Kuninori Morimoto | dbe95ad | 2013-03-03 23:11:41 -0800 | [diff] [blame] | 336 | .start = gic_iid(0x70), |
Kuninori Morimoto | ccc2a27 | 2012-10-10 19:56:51 -0700 | [diff] [blame] | 337 | .flags = IORESOURCE_IRQ, |
| 338 | }, |
| 339 | }; |
| 340 | |
| 341 | static struct platform_device i2c2_device = { |
| 342 | .name = "i2c-rcar", |
| 343 | .id = 2, |
| 344 | .resource = rcar_i2c2_res, |
| 345 | .num_resources = ARRAY_SIZE(rcar_i2c2_res), |
| 346 | }; |
| 347 | |
| 348 | static struct resource rcar_i2c3_res[] = { |
| 349 | { |
| 350 | .start = 0xffc73000, |
| 351 | .end = 0xffc73fff, |
| 352 | .flags = IORESOURCE_MEM, |
| 353 | }, { |
Kuninori Morimoto | dbe95ad | 2013-03-03 23:11:41 -0800 | [diff] [blame] | 354 | .start = gic_iid(0x71), |
Kuninori Morimoto | ccc2a27 | 2012-10-10 19:56:51 -0700 | [diff] [blame] | 355 | .flags = IORESOURCE_IRQ, |
| 356 | }, |
| 357 | }; |
| 358 | |
| 359 | static struct platform_device i2c3_device = { |
| 360 | .name = "i2c-rcar", |
| 361 | .id = 3, |
| 362 | .resource = rcar_i2c3_res, |
| 363 | .num_resources = ARRAY_SIZE(rcar_i2c3_res), |
| 364 | }; |
| 365 | |
Vladimir Barinov | a7b9837 | 2013-02-27 23:39:14 +0300 | [diff] [blame] | 366 | static struct resource sata_resources[] = { |
| 367 | [0] = { |
| 368 | .name = "rcar-sata", |
| 369 | .start = 0xfc600000, |
| 370 | .end = 0xfc601fff, |
| 371 | .flags = IORESOURCE_MEM, |
| 372 | }, |
| 373 | [1] = { |
Sergei Shtylyov | d60cd5f | 2013-03-08 02:31:03 +0300 | [diff] [blame] | 374 | .start = gic_iid(0x84), |
Vladimir Barinov | a7b9837 | 2013-02-27 23:39:14 +0300 | [diff] [blame] | 375 | .flags = IORESOURCE_IRQ, |
| 376 | }, |
| 377 | }; |
| 378 | |
| 379 | static struct platform_device sata_device = { |
| 380 | .name = "sata_rcar", |
| 381 | .id = -1, |
| 382 | .resource = sata_resources, |
| 383 | .num_resources = ARRAY_SIZE(sata_resources), |
| 384 | .dev = { |
| 385 | .dma_mask = &sata_device.dev.coherent_dma_mask, |
| 386 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 387 | }, |
| 388 | }; |
| 389 | |
Sergei Shtylyov | 2c8788b | 2013-06-02 01:30:15 +0400 | [diff] [blame^] | 390 | /* USB PHY */ |
| 391 | static struct resource usb_phy_resources[] = { |
| 392 | [0] = { |
| 393 | .start = 0xffe70000, |
| 394 | .end = 0xffe70900 - 1, |
| 395 | .flags = IORESOURCE_MEM, |
| 396 | }, |
| 397 | [1] = { |
| 398 | .start = 0xfff70000, |
| 399 | .end = 0xfff70900 - 1, |
| 400 | .flags = IORESOURCE_MEM, |
| 401 | }, |
| 402 | }; |
| 403 | |
| 404 | static struct platform_device usb_phy_device = { |
| 405 | .name = "rcar_usb_phy", |
| 406 | .id = -1, |
| 407 | .resource = usb_phy_resources, |
| 408 | .num_resources = ARRAY_SIZE(usb_phy_resources), |
| 409 | }; |
| 410 | |
| 411 | /* USB */ |
| 412 | static struct usb_phy *phy; |
| 413 | |
| 414 | static int usb_power_on(struct platform_device *pdev) |
| 415 | { |
| 416 | if (IS_ERR(phy)) |
| 417 | return PTR_ERR(phy); |
| 418 | |
| 419 | pm_runtime_enable(&pdev->dev); |
| 420 | pm_runtime_get_sync(&pdev->dev); |
| 421 | |
| 422 | usb_phy_init(phy); |
| 423 | |
| 424 | return 0; |
| 425 | } |
| 426 | |
| 427 | static void usb_power_off(struct platform_device *pdev) |
| 428 | { |
| 429 | if (IS_ERR(phy)) |
| 430 | return; |
| 431 | |
| 432 | usb_phy_shutdown(phy); |
| 433 | |
| 434 | pm_runtime_put_sync(&pdev->dev); |
| 435 | pm_runtime_disable(&pdev->dev); |
| 436 | } |
| 437 | |
| 438 | static struct usb_ehci_pdata ehcix_pdata = { |
| 439 | .power_on = usb_power_on, |
| 440 | .power_off = usb_power_off, |
| 441 | .power_suspend = usb_power_off, |
| 442 | }; |
| 443 | |
| 444 | static struct resource ehci0_resources[] = { |
| 445 | [0] = { |
| 446 | .start = 0xffe70000, |
| 447 | .end = 0xffe70400 - 1, |
| 448 | .flags = IORESOURCE_MEM, |
| 449 | }, |
| 450 | [1] = { |
| 451 | .start = gic_iid(0x4c), |
| 452 | .flags = IORESOURCE_IRQ, |
| 453 | }, |
| 454 | }; |
| 455 | |
| 456 | static struct platform_device ehci0_device = { |
| 457 | .name = "ehci-platform", |
| 458 | .id = 0, |
| 459 | .dev = { |
| 460 | .dma_mask = &ehci0_device.dev.coherent_dma_mask, |
| 461 | .coherent_dma_mask = 0xffffffff, |
| 462 | .platform_data = &ehcix_pdata, |
| 463 | }, |
| 464 | .num_resources = ARRAY_SIZE(ehci0_resources), |
| 465 | .resource = ehci0_resources, |
| 466 | }; |
| 467 | |
| 468 | static struct resource ehci1_resources[] = { |
| 469 | [0] = { |
| 470 | .start = 0xfff70000, |
| 471 | .end = 0xfff70400 - 1, |
| 472 | .flags = IORESOURCE_MEM, |
| 473 | }, |
| 474 | [1] = { |
| 475 | .start = gic_iid(0x4d), |
| 476 | .flags = IORESOURCE_IRQ, |
| 477 | }, |
| 478 | }; |
| 479 | |
| 480 | static struct platform_device ehci1_device = { |
| 481 | .name = "ehci-platform", |
| 482 | .id = 1, |
| 483 | .dev = { |
| 484 | .dma_mask = &ehci1_device.dev.coherent_dma_mask, |
| 485 | .coherent_dma_mask = 0xffffffff, |
| 486 | .platform_data = &ehcix_pdata, |
| 487 | }, |
| 488 | .num_resources = ARRAY_SIZE(ehci1_resources), |
| 489 | .resource = ehci1_resources, |
| 490 | }; |
| 491 | |
| 492 | static struct usb_ohci_pdata ohcix_pdata = { |
| 493 | .power_on = usb_power_on, |
| 494 | .power_off = usb_power_off, |
| 495 | .power_suspend = usb_power_off, |
| 496 | }; |
| 497 | |
| 498 | static struct resource ohci0_resources[] = { |
| 499 | [0] = { |
| 500 | .start = 0xffe70400, |
| 501 | .end = 0xffe70800 - 1, |
| 502 | .flags = IORESOURCE_MEM, |
| 503 | }, |
| 504 | [1] = { |
| 505 | .start = gic_iid(0x4c), |
| 506 | .flags = IORESOURCE_IRQ, |
| 507 | }, |
| 508 | }; |
| 509 | |
| 510 | static struct platform_device ohci0_device = { |
| 511 | .name = "ohci-platform", |
| 512 | .id = 0, |
| 513 | .dev = { |
| 514 | .dma_mask = &ohci0_device.dev.coherent_dma_mask, |
| 515 | .coherent_dma_mask = 0xffffffff, |
| 516 | .platform_data = &ohcix_pdata, |
| 517 | }, |
| 518 | .num_resources = ARRAY_SIZE(ohci0_resources), |
| 519 | .resource = ohci0_resources, |
| 520 | }; |
| 521 | |
| 522 | static struct resource ohci1_resources[] = { |
| 523 | [0] = { |
| 524 | .start = 0xfff70400, |
| 525 | .end = 0xfff70800 - 1, |
| 526 | .flags = IORESOURCE_MEM, |
| 527 | }, |
| 528 | [1] = { |
| 529 | .start = gic_iid(0x4d), |
| 530 | .flags = IORESOURCE_IRQ, |
| 531 | }, |
| 532 | }; |
| 533 | |
| 534 | static struct platform_device ohci1_device = { |
| 535 | .name = "ohci-platform", |
| 536 | .id = 1, |
| 537 | .dev = { |
| 538 | .dma_mask = &ohci1_device.dev.coherent_dma_mask, |
| 539 | .coherent_dma_mask = 0xffffffff, |
| 540 | .platform_data = &ohcix_pdata, |
| 541 | }, |
| 542 | .num_resources = ARRAY_SIZE(ohci1_resources), |
| 543 | .resource = ohci1_resources, |
| 544 | }; |
| 545 | |
Sergei Shtylyov | dace48d | 2013-04-04 18:53:50 +0000 | [diff] [blame] | 546 | /* Ether */ |
| 547 | static struct resource ether_resources[] = { |
| 548 | { |
| 549 | .start = 0xfde00000, |
| 550 | .end = 0xfde003ff, |
| 551 | .flags = IORESOURCE_MEM, |
| 552 | }, { |
| 553 | .start = gic_iid(0xb4), |
| 554 | .flags = IORESOURCE_IRQ, |
| 555 | }, |
| 556 | }; |
| 557 | |
Simon Horman | 916ddc3 | 2013-02-19 10:53:05 +0900 | [diff] [blame] | 558 | static struct platform_device *r8a7779_devices_dt[] __initdata = { |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 559 | &scif0_device, |
| 560 | &scif1_device, |
| 561 | &scif2_device, |
| 562 | &scif3_device, |
| 563 | &scif4_device, |
| 564 | &scif5_device, |
| 565 | &tmu00_device, |
| 566 | &tmu01_device, |
Sergei Shtylyov | 2c8788b | 2013-06-02 01:30:15 +0400 | [diff] [blame^] | 567 | &usb_phy_device, |
Simon Horman | 10e8d4f | 2012-11-21 22:00:15 +0900 | [diff] [blame] | 568 | }; |
| 569 | |
Sergei Shtylyov | 2c8788b | 2013-06-02 01:30:15 +0400 | [diff] [blame^] | 570 | static struct platform_device *r8a7779_standard_devices[] __initdata = { |
Kuninori Morimoto | ccc2a27 | 2012-10-10 19:56:51 -0700 | [diff] [blame] | 571 | &i2c0_device, |
| 572 | &i2c1_device, |
| 573 | &i2c2_device, |
| 574 | &i2c3_device, |
Vladimir Barinov | a7b9837 | 2013-02-27 23:39:14 +0300 | [diff] [blame] | 575 | &sata_device, |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 576 | }; |
| 577 | |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 578 | void __init r8a7779_add_standard_devices(void) |
| 579 | { |
Magnus Damm | 8bac13f | 2012-03-01 12:48:03 +0900 | [diff] [blame] | 580 | #ifdef CONFIG_CACHE_L2X0 |
| 581 | /* Early BRESP enable, Shared attribute override enable, 64K*16way */ |
Kuninori Morimoto | ed7d132 | 2012-10-14 23:35:24 -0700 | [diff] [blame] | 582 | l2x0_init(IOMEM(0xf0100000), 0x40470000, 0x82000fff); |
Magnus Damm | 8bac13f | 2012-03-01 12:48:03 +0900 | [diff] [blame] | 583 | #endif |
Magnus Damm | a662c08 | 2012-01-10 15:50:01 +0900 | [diff] [blame] | 584 | r8a7779_pm_init(); |
| 585 | |
Rafael J. Wysocki | 45e5ca5 | 2012-08-07 01:14:14 +0200 | [diff] [blame] | 586 | r8a7779_init_pm_domains(); |
Magnus Damm | a662c08 | 2012-01-10 15:50:01 +0900 | [diff] [blame] | 587 | |
Simon Horman | 916ddc3 | 2013-02-19 10:53:05 +0900 | [diff] [blame] | 588 | platform_add_devices(r8a7779_devices_dt, |
| 589 | ARRAY_SIZE(r8a7779_devices_dt)); |
Sergei Shtylyov | 2c8788b | 2013-06-02 01:30:15 +0400 | [diff] [blame^] | 590 | platform_add_devices(r8a7779_standard_devices, |
| 591 | ARRAY_SIZE(r8a7779_standard_devices)); |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 592 | } |
| 593 | |
Sergei Shtylyov | dace48d | 2013-04-04 18:53:50 +0000 | [diff] [blame] | 594 | void __init r8a7779_add_ether_device(struct sh_eth_plat_data *pdata) |
| 595 | { |
| 596 | platform_device_register_resndata(&platform_bus, "sh_eth", -1, |
| 597 | ether_resources, |
| 598 | ARRAY_SIZE(ether_resources), |
| 599 | pdata, sizeof(*pdata)); |
| 600 | } |
| 601 | |
Magnus Damm | b759bd1 | 2012-05-10 14:57:22 +0900 | [diff] [blame] | 602 | /* do nothing for !CONFIG_SMP or !CONFIG_HAVE_TWD */ |
| 603 | void __init __weak r8a7779_register_twd(void) { } |
| 604 | |
Stephen Warren | 6bb27d7 | 2012-11-08 12:40:59 -0700 | [diff] [blame] | 605 | void __init r8a7779_earlytimer_init(void) |
Magnus Damm | df27a2d | 2012-03-06 17:37:01 +0900 | [diff] [blame] | 606 | { |
| 607 | r8a7779_clock_init(); |
| 608 | shmobile_earlytimer_init(); |
Magnus Damm | b759bd1 | 2012-05-10 14:57:22 +0900 | [diff] [blame] | 609 | r8a7779_register_twd(); |
Magnus Damm | df27a2d | 2012-03-06 17:37:01 +0900 | [diff] [blame] | 610 | } |
| 611 | |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 612 | void __init r8a7779_add_early_devices(void) |
| 613 | { |
Simon Horman | 916ddc3 | 2013-02-19 10:53:05 +0900 | [diff] [blame] | 614 | early_platform_add_devices(r8a7779_devices_dt, |
| 615 | ARRAY_SIZE(r8a7779_devices_dt)); |
Magnus Damm | 3e353b87 | 2012-02-29 21:37:43 +0900 | [diff] [blame] | 616 | |
| 617 | /* Early serial console setup is not included here due to |
| 618 | * memory map collisions. The SCIF serial ports in r8a7779 |
| 619 | * are difficult to entity map 1:1 due to collision with the |
| 620 | * virtual memory range used by the coherent DMA code on ARM. |
| 621 | * |
| 622 | * Anyone wanting to debug early can remove UPF_IOREMAP from |
| 623 | * the sh-sci serial console platform data, adjust mapbase |
| 624 | * to a static M:N virt:phys mapping that needs to be added to |
| 625 | * the mappings passed with iotable_init() above. |
| 626 | * |
| 627 | * Then add a call to shmobile_setup_console() from this function. |
| 628 | * |
| 629 | * As a final step pass earlyprint=sh-sci.2,115200 on the kernel |
| 630 | * command line in case of the marzen board. |
| 631 | */ |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 632 | } |
Simon Horman | 10e8d4f | 2012-11-21 22:00:15 +0900 | [diff] [blame] | 633 | |
Sergei Shtylyov | 2c8788b | 2013-06-02 01:30:15 +0400 | [diff] [blame^] | 634 | static struct platform_device *r8a7779_late_devices[] __initdata = { |
| 635 | &ehci0_device, |
| 636 | &ehci1_device, |
| 637 | &ohci0_device, |
| 638 | &ohci1_device, |
| 639 | }; |
| 640 | |
| 641 | void __init r8a7779_init_late(void) |
| 642 | { |
| 643 | /* get USB PHY */ |
| 644 | phy = usb_get_phy(USB_PHY_TYPE_USB2); |
| 645 | |
| 646 | shmobile_init_late(); |
| 647 | platform_add_devices(r8a7779_late_devices, |
| 648 | ARRAY_SIZE(r8a7779_late_devices)); |
| 649 | } |
| 650 | |
Simon Horman | 10e8d4f | 2012-11-21 22:00:15 +0900 | [diff] [blame] | 651 | #ifdef CONFIG_USE_OF |
Simon Horman | 916ddc3 | 2013-02-19 10:53:05 +0900 | [diff] [blame] | 652 | void __init r8a7779_init_delay(void) |
Simon Horman | 10e8d4f | 2012-11-21 22:00:15 +0900 | [diff] [blame] | 653 | { |
| 654 | shmobile_setup_delay(1000, 2, 4); /* Cortex-A9 @ 1000MHz */ |
Simon Horman | 10e8d4f | 2012-11-21 22:00:15 +0900 | [diff] [blame] | 655 | } |
| 656 | |
| 657 | static const struct of_dev_auxdata r8a7779_auxdata_lookup[] __initconst = { |
| 658 | {}, |
| 659 | }; |
| 660 | |
| 661 | void __init r8a7779_add_standard_devices_dt(void) |
| 662 | { |
| 663 | /* clocks are setup late during boot in the case of DT */ |
| 664 | r8a7779_clock_init(); |
| 665 | |
Simon Horman | 916ddc3 | 2013-02-19 10:53:05 +0900 | [diff] [blame] | 666 | platform_add_devices(r8a7779_devices_dt, |
| 667 | ARRAY_SIZE(r8a7779_devices_dt)); |
Simon Horman | 10e8d4f | 2012-11-21 22:00:15 +0900 | [diff] [blame] | 668 | of_platform_populate(NULL, of_default_bus_match_table, |
| 669 | r8a7779_auxdata_lookup, NULL); |
| 670 | } |
| 671 | |
| 672 | static const char *r8a7779_compat_dt[] __initdata = { |
| 673 | "renesas,r8a7779", |
| 674 | NULL, |
| 675 | }; |
| 676 | |
Kuninori Morimoto | abe0e14 | 2013-03-03 23:11:20 -0800 | [diff] [blame] | 677 | DT_MACHINE_START(R8A7779_DT, "Generic R8A7779 (Flattened Device Tree)") |
Simon Horman | 10e8d4f | 2012-11-21 22:00:15 +0900 | [diff] [blame] | 678 | .map_io = r8a7779_map_io, |
Simon Horman | 916ddc3 | 2013-02-19 10:53:05 +0900 | [diff] [blame] | 679 | .init_early = r8a7779_init_delay, |
Simon Horman | 10e8d4f | 2012-11-21 22:00:15 +0900 | [diff] [blame] | 680 | .nr_irqs = NR_IRQS_LEGACY, |
| 681 | .init_irq = r8a7779_init_irq_dt, |
| 682 | .init_machine = r8a7779_add_standard_devices_dt, |
| 683 | .init_time = shmobile_timer_init, |
Sergei Shtylyov | 2c8788b | 2013-06-02 01:30:15 +0400 | [diff] [blame^] | 684 | .init_late = r8a7779_init_late, |
Simon Horman | 10e8d4f | 2012-11-21 22:00:15 +0900 | [diff] [blame] | 685 | .dt_compat = r8a7779_compat_dt, |
| 686 | MACHINE_END |
| 687 | #endif /* CONFIG_USE_OF */ |