Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 1 | /* |
| 2 | * R8A7740 processor support |
| 3 | * |
| 4 | * Copyright (C) 2011 Renesas Solutions Corp. |
| 5 | * Copyright (C) 2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; version 2 of the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | */ |
Kuninori Morimoto | 6831f3a | 2011-11-10 18:46:23 -0800 | [diff] [blame] | 20 | #include <linux/delay.h> |
Kuninori Morimoto | 3841e6f | 2012-04-24 02:10:05 -0700 | [diff] [blame] | 21 | #include <linux/dma-mapping.h> |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 22 | #include <linux/kernel.h> |
| 23 | #include <linux/init.h> |
Kuninori Morimoto | 6831f3a | 2011-11-10 18:46:23 -0800 | [diff] [blame] | 24 | #include <linux/io.h> |
Bastian Hecht | 0b7d782 | 2013-03-27 14:54:04 +0100 | [diff] [blame] | 25 | #include <linux/platform_data/irq-renesas-intc-irqpin.h> |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 26 | #include <linux/platform_device.h> |
Magnus Damm | 755d57b | 2012-07-06 17:08:07 +0900 | [diff] [blame] | 27 | #include <linux/of_platform.h> |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 28 | #include <linux/serial_sci.h> |
Kuninori Morimoto | 643c330 | 2012-06-25 03:36:49 -0700 | [diff] [blame] | 29 | #include <linux/sh_dma.h> |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 30 | #include <linux/sh_timer.h> |
Hideki EIRAKU | f671e02 | 2013-01-21 19:54:29 +0900 | [diff] [blame] | 31 | #include <linux/platform_data/sh_ipmmu.h> |
Kuninori Morimoto | d7de938 | 2012-06-25 03:43:10 -0700 | [diff] [blame] | 32 | #include <mach/dma-register.h> |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 33 | #include <mach/r8a7740.h> |
Kuninori Morimoto | 8459293 | 2012-07-05 01:25:58 -0700 | [diff] [blame] | 34 | #include <mach/pm-rmobile.h> |
Magnus Damm | d3ab722 | 2012-02-29 21:37:35 +0900 | [diff] [blame] | 35 | #include <mach/common.h> |
Rob Herring | 250a272 | 2012-01-03 16:57:33 -0600 | [diff] [blame] | 36 | #include <mach/irqs.h> |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 37 | #include <asm/mach-types.h> |
Magnus Damm | d3ab722 | 2012-02-29 21:37:35 +0900 | [diff] [blame] | 38 | #include <asm/mach/map.h> |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 39 | #include <asm/mach/arch.h> |
Magnus Damm | 23e5bc0 | 2012-03-06 17:36:53 +0900 | [diff] [blame] | 40 | #include <asm/mach/time.h> |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 41 | |
Magnus Damm | d3ab722 | 2012-02-29 21:37:35 +0900 | [diff] [blame] | 42 | static struct map_desc r8a7740_io_desc[] __initdata = { |
| 43 | /* |
| 44 | * for CPGA/INTC/PFC |
| 45 | * 0xe6000000-0xefffffff -> 0xe6000000-0xefffffff |
| 46 | */ |
| 47 | { |
| 48 | .virtual = 0xe6000000, |
| 49 | .pfn = __phys_to_pfn(0xe6000000), |
| 50 | .length = 160 << 20, |
| 51 | .type = MT_DEVICE_NONSHARED |
| 52 | }, |
| 53 | #ifdef CONFIG_CACHE_L2X0 |
| 54 | /* |
| 55 | * for l2x0_init() |
| 56 | * 0xf0100000-0xf0101000 -> 0xf0002000-0xf0003000 |
| 57 | */ |
| 58 | { |
| 59 | .virtual = 0xf0002000, |
| 60 | .pfn = __phys_to_pfn(0xf0100000), |
| 61 | .length = PAGE_SIZE, |
| 62 | .type = MT_DEVICE_NONSHARED |
| 63 | }, |
| 64 | #endif |
| 65 | }; |
| 66 | |
| 67 | void __init r8a7740_map_io(void) |
| 68 | { |
| 69 | iotable_init(r8a7740_io_desc, ARRAY_SIZE(r8a7740_io_desc)); |
| 70 | } |
| 71 | |
Laurent Pinchart | 02b01ad | 2012-12-15 23:51:25 +0100 | [diff] [blame] | 72 | /* PFC */ |
Magnus Damm | 3404622 | 2013-04-03 15:32:58 +0900 | [diff] [blame^] | 73 | static const struct resource pfc_resources[] = { |
| 74 | DEFINE_RES_MEM(0xe6050000, 0x8000), |
| 75 | DEFINE_RES_MEM(0xe605800c, 0x0020), |
Laurent Pinchart | 02b01ad | 2012-12-15 23:51:25 +0100 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | void __init r8a7740_pinmux_init(void) |
| 79 | { |
Magnus Damm | 3404622 | 2013-04-03 15:32:58 +0900 | [diff] [blame^] | 80 | platform_device_register_simple("pfc-r8a7740", -1, pfc_resources, |
| 81 | ARRAY_SIZE(pfc_resources)); |
Laurent Pinchart | 02b01ad | 2012-12-15 23:51:25 +0100 | [diff] [blame] | 82 | } |
| 83 | |
Bastian Hecht | 0b7d782 | 2013-03-27 14:54:04 +0100 | [diff] [blame] | 84 | static struct renesas_intc_irqpin_config irqpin0_platform_data = { |
| 85 | .irq_base = irq_pin(0), /* IRQ0 -> IRQ7 */ |
| 86 | }; |
| 87 | |
| 88 | static struct resource irqpin0_resources[] = { |
| 89 | DEFINE_RES_MEM(0xe6900000, 4), /* ICR1A */ |
| 90 | DEFINE_RES_MEM(0xe6900010, 4), /* INTPRI00A */ |
| 91 | DEFINE_RES_MEM(0xe6900020, 1), /* INTREQ00A */ |
| 92 | DEFINE_RES_MEM(0xe6900040, 1), /* INTMSK00A */ |
| 93 | DEFINE_RES_MEM(0xe6900060, 1), /* INTMSKCLR00A */ |
| 94 | DEFINE_RES_IRQ(gic_spi(149)), /* IRQ0 */ |
| 95 | DEFINE_RES_IRQ(gic_spi(149)), /* IRQ1 */ |
| 96 | DEFINE_RES_IRQ(gic_spi(149)), /* IRQ2 */ |
| 97 | DEFINE_RES_IRQ(gic_spi(149)), /* IRQ3 */ |
| 98 | DEFINE_RES_IRQ(gic_spi(149)), /* IRQ4 */ |
| 99 | DEFINE_RES_IRQ(gic_spi(149)), /* IRQ5 */ |
| 100 | DEFINE_RES_IRQ(gic_spi(149)), /* IRQ6 */ |
| 101 | DEFINE_RES_IRQ(gic_spi(149)), /* IRQ7 */ |
| 102 | }; |
| 103 | |
| 104 | static struct platform_device irqpin0_device = { |
| 105 | .name = "renesas_intc_irqpin", |
| 106 | .id = 0, |
| 107 | .resource = irqpin0_resources, |
| 108 | .num_resources = ARRAY_SIZE(irqpin0_resources), |
| 109 | .dev = { |
| 110 | .platform_data = &irqpin0_platform_data, |
| 111 | }, |
| 112 | }; |
| 113 | |
| 114 | static struct renesas_intc_irqpin_config irqpin1_platform_data = { |
| 115 | .irq_base = irq_pin(8), /* IRQ8 -> IRQ15 */ |
| 116 | }; |
| 117 | |
| 118 | static struct resource irqpin1_resources[] = { |
| 119 | DEFINE_RES_MEM(0xe6900004, 4), /* ICR2A */ |
| 120 | DEFINE_RES_MEM(0xe6900014, 4), /* INTPRI10A */ |
| 121 | DEFINE_RES_MEM(0xe6900024, 1), /* INTREQ10A */ |
| 122 | DEFINE_RES_MEM(0xe6900044, 1), /* INTMSK10A */ |
| 123 | DEFINE_RES_MEM(0xe6900064, 1), /* INTMSKCLR10A */ |
| 124 | DEFINE_RES_IRQ(gic_spi(149)), /* IRQ8 */ |
| 125 | DEFINE_RES_IRQ(gic_spi(149)), /* IRQ9 */ |
| 126 | DEFINE_RES_IRQ(gic_spi(149)), /* IRQ10 */ |
| 127 | DEFINE_RES_IRQ(gic_spi(149)), /* IRQ11 */ |
| 128 | DEFINE_RES_IRQ(gic_spi(149)), /* IRQ12 */ |
| 129 | DEFINE_RES_IRQ(gic_spi(149)), /* IRQ13 */ |
| 130 | DEFINE_RES_IRQ(gic_spi(149)), /* IRQ14 */ |
| 131 | DEFINE_RES_IRQ(gic_spi(149)), /* IRQ15 */ |
| 132 | }; |
| 133 | |
| 134 | static struct platform_device irqpin1_device = { |
| 135 | .name = "renesas_intc_irqpin", |
| 136 | .id = 1, |
| 137 | .resource = irqpin1_resources, |
| 138 | .num_resources = ARRAY_SIZE(irqpin1_resources), |
| 139 | .dev = { |
| 140 | .platform_data = &irqpin1_platform_data, |
| 141 | }, |
| 142 | }; |
| 143 | |
| 144 | static struct renesas_intc_irqpin_config irqpin2_platform_data = { |
| 145 | .irq_base = irq_pin(16), /* IRQ16 -> IRQ23 */ |
| 146 | }; |
| 147 | |
| 148 | static struct resource irqpin2_resources[] = { |
| 149 | DEFINE_RES_MEM(0xe6900008, 4), /* ICR3A */ |
| 150 | DEFINE_RES_MEM(0xe6900018, 4), /* INTPRI30A */ |
| 151 | DEFINE_RES_MEM(0xe6900028, 1), /* INTREQ30A */ |
| 152 | DEFINE_RES_MEM(0xe6900048, 1), /* INTMSK30A */ |
| 153 | DEFINE_RES_MEM(0xe6900068, 1), /* INTMSKCLR30A */ |
| 154 | DEFINE_RES_IRQ(gic_spi(149)), /* IRQ16 */ |
| 155 | DEFINE_RES_IRQ(gic_spi(149)), /* IRQ17 */ |
| 156 | DEFINE_RES_IRQ(gic_spi(149)), /* IRQ18 */ |
| 157 | DEFINE_RES_IRQ(gic_spi(149)), /* IRQ19 */ |
| 158 | DEFINE_RES_IRQ(gic_spi(149)), /* IRQ20 */ |
| 159 | DEFINE_RES_IRQ(gic_spi(149)), /* IRQ21 */ |
| 160 | DEFINE_RES_IRQ(gic_spi(149)), /* IRQ22 */ |
| 161 | DEFINE_RES_IRQ(gic_spi(149)), /* IRQ23 */ |
| 162 | }; |
| 163 | |
| 164 | static struct platform_device irqpin2_device = { |
| 165 | .name = "renesas_intc_irqpin", |
| 166 | .id = 2, |
| 167 | .resource = irqpin2_resources, |
| 168 | .num_resources = ARRAY_SIZE(irqpin2_resources), |
| 169 | .dev = { |
| 170 | .platform_data = &irqpin2_platform_data, |
| 171 | }, |
| 172 | }; |
| 173 | |
| 174 | static struct renesas_intc_irqpin_config irqpin3_platform_data = { |
| 175 | .irq_base = irq_pin(24), /* IRQ24 -> IRQ31 */ |
| 176 | }; |
| 177 | |
| 178 | static struct resource irqpin3_resources[] = { |
| 179 | DEFINE_RES_MEM(0xe690000c, 4), /* ICR3A */ |
| 180 | DEFINE_RES_MEM(0xe690001c, 4), /* INTPRI30A */ |
| 181 | DEFINE_RES_MEM(0xe690002c, 1), /* INTREQ30A */ |
| 182 | DEFINE_RES_MEM(0xe690004c, 1), /* INTMSK30A */ |
| 183 | DEFINE_RES_MEM(0xe690006c, 1), /* INTMSKCLR30A */ |
| 184 | DEFINE_RES_IRQ(gic_spi(149)), /* IRQ24 */ |
| 185 | DEFINE_RES_IRQ(gic_spi(149)), /* IRQ25 */ |
| 186 | DEFINE_RES_IRQ(gic_spi(149)), /* IRQ26 */ |
| 187 | DEFINE_RES_IRQ(gic_spi(149)), /* IRQ27 */ |
| 188 | DEFINE_RES_IRQ(gic_spi(149)), /* IRQ28 */ |
| 189 | DEFINE_RES_IRQ(gic_spi(149)), /* IRQ29 */ |
| 190 | DEFINE_RES_IRQ(gic_spi(149)), /* IRQ30 */ |
| 191 | DEFINE_RES_IRQ(gic_spi(149)), /* IRQ31 */ |
| 192 | }; |
| 193 | |
| 194 | static struct platform_device irqpin3_device = { |
| 195 | .name = "renesas_intc_irqpin", |
| 196 | .id = 3, |
| 197 | .resource = irqpin3_resources, |
| 198 | .num_resources = ARRAY_SIZE(irqpin3_resources), |
| 199 | .dev = { |
| 200 | .platform_data = &irqpin3_platform_data, |
| 201 | }, |
| 202 | }; |
| 203 | |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 204 | /* SCIFA0 */ |
| 205 | static struct plat_sci_port scif0_platform_data = { |
| 206 | .mapbase = 0xe6c40000, |
| 207 | .flags = UPF_BOOT_AUTOCONF, |
| 208 | .scscr = SCSCR_RE | SCSCR_TE, |
| 209 | .scbrr_algo_id = SCBRR_ALGO_4, |
| 210 | .type = PORT_SCIFA, |
Bastian Hecht | 0b7d782 | 2013-03-27 14:54:04 +0100 | [diff] [blame] | 211 | .irqs = SCIx_IRQ_MUXED(gic_spi(100)), |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 212 | }; |
| 213 | |
| 214 | static struct platform_device scif0_device = { |
| 215 | .name = "sh-sci", |
| 216 | .id = 0, |
| 217 | .dev = { |
| 218 | .platform_data = &scif0_platform_data, |
| 219 | }, |
| 220 | }; |
| 221 | |
| 222 | /* SCIFA1 */ |
| 223 | static struct plat_sci_port scif1_platform_data = { |
| 224 | .mapbase = 0xe6c50000, |
| 225 | .flags = UPF_BOOT_AUTOCONF, |
| 226 | .scscr = SCSCR_RE | SCSCR_TE, |
| 227 | .scbrr_algo_id = SCBRR_ALGO_4, |
| 228 | .type = PORT_SCIFA, |
Bastian Hecht | 0b7d782 | 2013-03-27 14:54:04 +0100 | [diff] [blame] | 229 | .irqs = SCIx_IRQ_MUXED(gic_spi(101)), |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 230 | }; |
| 231 | |
| 232 | static struct platform_device scif1_device = { |
| 233 | .name = "sh-sci", |
| 234 | .id = 1, |
| 235 | .dev = { |
| 236 | .platform_data = &scif1_platform_data, |
| 237 | }, |
| 238 | }; |
| 239 | |
| 240 | /* SCIFA2 */ |
| 241 | static struct plat_sci_port scif2_platform_data = { |
| 242 | .mapbase = 0xe6c60000, |
| 243 | .flags = UPF_BOOT_AUTOCONF, |
| 244 | .scscr = SCSCR_RE | SCSCR_TE, |
| 245 | .scbrr_algo_id = SCBRR_ALGO_4, |
| 246 | .type = PORT_SCIFA, |
Bastian Hecht | 0b7d782 | 2013-03-27 14:54:04 +0100 | [diff] [blame] | 247 | .irqs = SCIx_IRQ_MUXED(gic_spi(102)), |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 248 | }; |
| 249 | |
| 250 | static struct platform_device scif2_device = { |
| 251 | .name = "sh-sci", |
| 252 | .id = 2, |
| 253 | .dev = { |
| 254 | .platform_data = &scif2_platform_data, |
| 255 | }, |
| 256 | }; |
| 257 | |
| 258 | /* SCIFA3 */ |
| 259 | static struct plat_sci_port scif3_platform_data = { |
| 260 | .mapbase = 0xe6c70000, |
| 261 | .flags = UPF_BOOT_AUTOCONF, |
| 262 | .scscr = SCSCR_RE | SCSCR_TE, |
| 263 | .scbrr_algo_id = SCBRR_ALGO_4, |
| 264 | .type = PORT_SCIFA, |
Bastian Hecht | 0b7d782 | 2013-03-27 14:54:04 +0100 | [diff] [blame] | 265 | .irqs = SCIx_IRQ_MUXED(gic_spi(103)), |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 266 | }; |
| 267 | |
| 268 | static struct platform_device scif3_device = { |
| 269 | .name = "sh-sci", |
| 270 | .id = 3, |
| 271 | .dev = { |
| 272 | .platform_data = &scif3_platform_data, |
| 273 | }, |
| 274 | }; |
| 275 | |
| 276 | /* SCIFA4 */ |
| 277 | static struct plat_sci_port scif4_platform_data = { |
| 278 | .mapbase = 0xe6c80000, |
| 279 | .flags = UPF_BOOT_AUTOCONF, |
| 280 | .scscr = SCSCR_RE | SCSCR_TE, |
| 281 | .scbrr_algo_id = SCBRR_ALGO_4, |
| 282 | .type = PORT_SCIFA, |
Bastian Hecht | 0b7d782 | 2013-03-27 14:54:04 +0100 | [diff] [blame] | 283 | .irqs = SCIx_IRQ_MUXED(gic_spi(104)), |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 284 | }; |
| 285 | |
| 286 | static struct platform_device scif4_device = { |
| 287 | .name = "sh-sci", |
| 288 | .id = 4, |
| 289 | .dev = { |
| 290 | .platform_data = &scif4_platform_data, |
| 291 | }, |
| 292 | }; |
| 293 | |
| 294 | /* SCIFA5 */ |
| 295 | static struct plat_sci_port scif5_platform_data = { |
| 296 | .mapbase = 0xe6cb0000, |
| 297 | .flags = UPF_BOOT_AUTOCONF, |
| 298 | .scscr = SCSCR_RE | SCSCR_TE, |
| 299 | .scbrr_algo_id = SCBRR_ALGO_4, |
| 300 | .type = PORT_SCIFA, |
Bastian Hecht | 0b7d782 | 2013-03-27 14:54:04 +0100 | [diff] [blame] | 301 | .irqs = SCIx_IRQ_MUXED(gic_spi(105)), |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 302 | }; |
| 303 | |
| 304 | static struct platform_device scif5_device = { |
| 305 | .name = "sh-sci", |
| 306 | .id = 5, |
| 307 | .dev = { |
| 308 | .platform_data = &scif5_platform_data, |
| 309 | }, |
| 310 | }; |
| 311 | |
| 312 | /* SCIFA6 */ |
| 313 | static struct plat_sci_port scif6_platform_data = { |
| 314 | .mapbase = 0xe6cc0000, |
| 315 | .flags = UPF_BOOT_AUTOCONF, |
| 316 | .scscr = SCSCR_RE | SCSCR_TE, |
| 317 | .scbrr_algo_id = SCBRR_ALGO_4, |
| 318 | .type = PORT_SCIFA, |
Bastian Hecht | 0b7d782 | 2013-03-27 14:54:04 +0100 | [diff] [blame] | 319 | .irqs = SCIx_IRQ_MUXED(gic_spi(106)), |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 320 | }; |
| 321 | |
| 322 | static struct platform_device scif6_device = { |
| 323 | .name = "sh-sci", |
| 324 | .id = 6, |
| 325 | .dev = { |
| 326 | .platform_data = &scif6_platform_data, |
| 327 | }, |
| 328 | }; |
| 329 | |
| 330 | /* SCIFA7 */ |
| 331 | static struct plat_sci_port scif7_platform_data = { |
| 332 | .mapbase = 0xe6cd0000, |
| 333 | .flags = UPF_BOOT_AUTOCONF, |
| 334 | .scscr = SCSCR_RE | SCSCR_TE, |
| 335 | .scbrr_algo_id = SCBRR_ALGO_4, |
| 336 | .type = PORT_SCIFA, |
Bastian Hecht | 0b7d782 | 2013-03-27 14:54:04 +0100 | [diff] [blame] | 337 | .irqs = SCIx_IRQ_MUXED(gic_spi(107)), |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 338 | }; |
| 339 | |
| 340 | static struct platform_device scif7_device = { |
| 341 | .name = "sh-sci", |
| 342 | .id = 7, |
| 343 | .dev = { |
| 344 | .platform_data = &scif7_platform_data, |
| 345 | }, |
| 346 | }; |
| 347 | |
| 348 | /* SCIFB */ |
| 349 | static struct plat_sci_port scifb_platform_data = { |
| 350 | .mapbase = 0xe6c30000, |
| 351 | .flags = UPF_BOOT_AUTOCONF, |
| 352 | .scscr = SCSCR_RE | SCSCR_TE, |
| 353 | .scbrr_algo_id = SCBRR_ALGO_4, |
| 354 | .type = PORT_SCIFB, |
Bastian Hecht | 0b7d782 | 2013-03-27 14:54:04 +0100 | [diff] [blame] | 355 | .irqs = SCIx_IRQ_MUXED(gic_spi(108)), |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 356 | }; |
| 357 | |
| 358 | static struct platform_device scifb_device = { |
| 359 | .name = "sh-sci", |
| 360 | .id = 8, |
| 361 | .dev = { |
| 362 | .platform_data = &scifb_platform_data, |
| 363 | }, |
| 364 | }; |
| 365 | |
| 366 | /* CMT */ |
| 367 | static struct sh_timer_config cmt10_platform_data = { |
| 368 | .name = "CMT10", |
| 369 | .channel_offset = 0x10, |
| 370 | .timer_bit = 0, |
| 371 | .clockevent_rating = 125, |
| 372 | .clocksource_rating = 125, |
| 373 | }; |
| 374 | |
| 375 | static struct resource cmt10_resources[] = { |
| 376 | [0] = { |
| 377 | .name = "CMT10", |
| 378 | .start = 0xe6138010, |
| 379 | .end = 0xe613801b, |
| 380 | .flags = IORESOURCE_MEM, |
| 381 | }, |
| 382 | [1] = { |
Bastian Hecht | 0b7d782 | 2013-03-27 14:54:04 +0100 | [diff] [blame] | 383 | .start = gic_spi(58), |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 384 | .flags = IORESOURCE_IRQ, |
| 385 | }, |
| 386 | }; |
| 387 | |
| 388 | static struct platform_device cmt10_device = { |
| 389 | .name = "sh_cmt", |
| 390 | .id = 10, |
| 391 | .dev = { |
| 392 | .platform_data = &cmt10_platform_data, |
| 393 | }, |
| 394 | .resource = cmt10_resources, |
| 395 | .num_resources = ARRAY_SIZE(cmt10_resources), |
| 396 | }; |
| 397 | |
Kuninori Morimoto | e67d7af | 2012-12-12 02:08:09 -0800 | [diff] [blame] | 398 | /* TMU */ |
| 399 | static struct sh_timer_config tmu00_platform_data = { |
| 400 | .name = "TMU00", |
| 401 | .channel_offset = 0x4, |
| 402 | .timer_bit = 0, |
| 403 | .clockevent_rating = 200, |
| 404 | }; |
| 405 | |
| 406 | static struct resource tmu00_resources[] = { |
| 407 | [0] = { |
| 408 | .name = "TMU00", |
| 409 | .start = 0xfff80008, |
| 410 | .end = 0xfff80014 - 1, |
| 411 | .flags = IORESOURCE_MEM, |
| 412 | }, |
| 413 | [1] = { |
Bastian Hecht | 0b7d782 | 2013-03-27 14:54:04 +0100 | [diff] [blame] | 414 | .start = gic_spi(198), |
Kuninori Morimoto | e67d7af | 2012-12-12 02:08:09 -0800 | [diff] [blame] | 415 | .flags = IORESOURCE_IRQ, |
| 416 | }, |
| 417 | }; |
| 418 | |
| 419 | static struct platform_device tmu00_device = { |
| 420 | .name = "sh_tmu", |
| 421 | .id = 0, |
| 422 | .dev = { |
| 423 | .platform_data = &tmu00_platform_data, |
| 424 | }, |
| 425 | .resource = tmu00_resources, |
| 426 | .num_resources = ARRAY_SIZE(tmu00_resources), |
| 427 | }; |
| 428 | |
| 429 | static struct sh_timer_config tmu01_platform_data = { |
| 430 | .name = "TMU01", |
| 431 | .channel_offset = 0x10, |
| 432 | .timer_bit = 1, |
| 433 | .clocksource_rating = 200, |
| 434 | }; |
| 435 | |
| 436 | static struct resource tmu01_resources[] = { |
| 437 | [0] = { |
| 438 | .name = "TMU01", |
| 439 | .start = 0xfff80014, |
| 440 | .end = 0xfff80020 - 1, |
| 441 | .flags = IORESOURCE_MEM, |
| 442 | }, |
| 443 | [1] = { |
Bastian Hecht | 0b7d782 | 2013-03-27 14:54:04 +0100 | [diff] [blame] | 444 | .start = gic_spi(199), |
Kuninori Morimoto | e67d7af | 2012-12-12 02:08:09 -0800 | [diff] [blame] | 445 | .flags = IORESOURCE_IRQ, |
| 446 | }, |
| 447 | }; |
| 448 | |
| 449 | static struct platform_device tmu01_device = { |
| 450 | .name = "sh_tmu", |
| 451 | .id = 1, |
| 452 | .dev = { |
| 453 | .platform_data = &tmu01_platform_data, |
| 454 | }, |
| 455 | .resource = tmu01_resources, |
| 456 | .num_resources = ARRAY_SIZE(tmu01_resources), |
| 457 | }; |
| 458 | |
| 459 | static struct sh_timer_config tmu02_platform_data = { |
| 460 | .name = "TMU02", |
| 461 | .channel_offset = 0x1C, |
| 462 | .timer_bit = 2, |
| 463 | .clocksource_rating = 200, |
| 464 | }; |
| 465 | |
| 466 | static struct resource tmu02_resources[] = { |
| 467 | [0] = { |
| 468 | .name = "TMU02", |
| 469 | .start = 0xfff80020, |
| 470 | .end = 0xfff8002C - 1, |
| 471 | .flags = IORESOURCE_MEM, |
| 472 | }, |
| 473 | [1] = { |
Bastian Hecht | 0b7d782 | 2013-03-27 14:54:04 +0100 | [diff] [blame] | 474 | .start = gic_spi(200), |
Kuninori Morimoto | e67d7af | 2012-12-12 02:08:09 -0800 | [diff] [blame] | 475 | .flags = IORESOURCE_IRQ, |
| 476 | }, |
| 477 | }; |
| 478 | |
| 479 | static struct platform_device tmu02_device = { |
| 480 | .name = "sh_tmu", |
| 481 | .id = 2, |
| 482 | .dev = { |
| 483 | .platform_data = &tmu02_platform_data, |
| 484 | }, |
| 485 | .resource = tmu02_resources, |
| 486 | .num_resources = ARRAY_SIZE(tmu02_resources), |
| 487 | }; |
| 488 | |
Hideki EIRAKU | f671e02 | 2013-01-21 19:54:29 +0900 | [diff] [blame] | 489 | /* IPMMUI (an IPMMU module for ICB/LMB) */ |
| 490 | static struct resource ipmmu_resources[] = { |
| 491 | [0] = { |
| 492 | .name = "IPMMUI", |
| 493 | .start = 0xfe951000, |
| 494 | .end = 0xfe9510ff, |
| 495 | .flags = IORESOURCE_MEM, |
| 496 | }, |
| 497 | }; |
| 498 | |
| 499 | static const char * const ipmmu_dev_names[] = { |
| 500 | "sh_mobile_lcdc_fb.0", |
| 501 | "sh_mobile_lcdc_fb.1", |
| 502 | "sh_mobile_ceu.0", |
| 503 | }; |
| 504 | |
| 505 | static struct shmobile_ipmmu_platform_data ipmmu_platform_data = { |
| 506 | .dev_names = ipmmu_dev_names, |
| 507 | .num_dev_names = ARRAY_SIZE(ipmmu_dev_names), |
| 508 | }; |
| 509 | |
| 510 | static struct platform_device ipmmu_device = { |
| 511 | .name = "ipmmu", |
| 512 | .id = -1, |
| 513 | .dev = { |
| 514 | .platform_data = &ipmmu_platform_data, |
| 515 | }, |
| 516 | .resource = ipmmu_resources, |
| 517 | .num_resources = ARRAY_SIZE(ipmmu_resources), |
| 518 | }; |
| 519 | |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 520 | static struct platform_device *r8a7740_early_devices[] __initdata = { |
Bastian Hecht | 0b7d782 | 2013-03-27 14:54:04 +0100 | [diff] [blame] | 521 | &irqpin0_device, |
| 522 | &irqpin1_device, |
| 523 | &irqpin2_device, |
| 524 | &irqpin3_device, |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 525 | &scif0_device, |
| 526 | &scif1_device, |
| 527 | &scif2_device, |
| 528 | &scif3_device, |
| 529 | &scif4_device, |
| 530 | &scif5_device, |
| 531 | &scif6_device, |
| 532 | &scif7_device, |
| 533 | &scifb_device, |
| 534 | &cmt10_device, |
Kuninori Morimoto | e67d7af | 2012-12-12 02:08:09 -0800 | [diff] [blame] | 535 | &tmu00_device, |
| 536 | &tmu01_device, |
| 537 | &tmu02_device, |
Hideki EIRAKU | f671e02 | 2013-01-21 19:54:29 +0900 | [diff] [blame] | 538 | &ipmmu_device, |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 539 | }; |
| 540 | |
Kuninori Morimoto | 643c330 | 2012-06-25 03:36:49 -0700 | [diff] [blame] | 541 | /* DMA */ |
Kuninori Morimoto | 643c330 | 2012-06-25 03:36:49 -0700 | [diff] [blame] | 542 | static const struct sh_dmae_slave_config r8a7740_dmae_slaves[] = { |
| 543 | { |
Kuninori Morimoto | cb76eb8 | 2012-06-25 03:37:00 -0700 | [diff] [blame] | 544 | .slave_id = SHDMA_SLAVE_SDHI0_TX, |
| 545 | .addr = 0xe6850030, |
| 546 | .chcr = CHCR_TX(XMIT_SZ_16BIT), |
| 547 | .mid_rid = 0xc1, |
| 548 | }, { |
| 549 | .slave_id = SHDMA_SLAVE_SDHI0_RX, |
| 550 | .addr = 0xe6850030, |
| 551 | .chcr = CHCR_RX(XMIT_SZ_16BIT), |
| 552 | .mid_rid = 0xc2, |
| 553 | }, { |
| 554 | .slave_id = SHDMA_SLAVE_SDHI1_TX, |
| 555 | .addr = 0xe6860030, |
| 556 | .chcr = CHCR_TX(XMIT_SZ_16BIT), |
| 557 | .mid_rid = 0xc9, |
| 558 | }, { |
| 559 | .slave_id = SHDMA_SLAVE_SDHI1_RX, |
| 560 | .addr = 0xe6860030, |
| 561 | .chcr = CHCR_RX(XMIT_SZ_16BIT), |
| 562 | .mid_rid = 0xca, |
| 563 | }, { |
| 564 | .slave_id = SHDMA_SLAVE_SDHI2_TX, |
| 565 | .addr = 0xe6870030, |
| 566 | .chcr = CHCR_TX(XMIT_SZ_16BIT), |
| 567 | .mid_rid = 0xcd, |
| 568 | }, { |
| 569 | .slave_id = SHDMA_SLAVE_SDHI2_RX, |
| 570 | .addr = 0xe6870030, |
| 571 | .chcr = CHCR_RX(XMIT_SZ_16BIT), |
| 572 | .mid_rid = 0xce, |
| 573 | }, { |
Kuninori Morimoto | 643c330 | 2012-06-25 03:36:49 -0700 | [diff] [blame] | 574 | .slave_id = SHDMA_SLAVE_FSIA_TX, |
| 575 | .addr = 0xfe1f0024, |
| 576 | .chcr = CHCR_TX(XMIT_SZ_32BIT), |
| 577 | .mid_rid = 0xb1, |
| 578 | }, { |
| 579 | .slave_id = SHDMA_SLAVE_FSIA_RX, |
| 580 | .addr = 0xfe1f0020, |
| 581 | .chcr = CHCR_RX(XMIT_SZ_32BIT), |
| 582 | .mid_rid = 0xb2, |
| 583 | }, { |
| 584 | .slave_id = SHDMA_SLAVE_FSIB_TX, |
| 585 | .addr = 0xfe1f0064, |
| 586 | .chcr = CHCR_TX(XMIT_SZ_32BIT), |
| 587 | .mid_rid = 0xb5, |
| 588 | }, |
| 589 | }; |
| 590 | |
| 591 | #define DMA_CHANNEL(a, b, c) \ |
| 592 | { \ |
| 593 | .offset = a, \ |
| 594 | .dmars = b, \ |
| 595 | .dmars_bit = c, \ |
| 596 | .chclr_offset = (0x220 - 0x20) + a \ |
| 597 | } |
| 598 | |
| 599 | static const struct sh_dmae_channel r8a7740_dmae_channels[] = { |
| 600 | DMA_CHANNEL(0x00, 0, 0), |
| 601 | DMA_CHANNEL(0x10, 0, 8), |
| 602 | DMA_CHANNEL(0x20, 4, 0), |
| 603 | DMA_CHANNEL(0x30, 4, 8), |
| 604 | DMA_CHANNEL(0x50, 8, 0), |
| 605 | DMA_CHANNEL(0x60, 8, 8), |
| 606 | }; |
| 607 | |
Kuninori Morimoto | 643c330 | 2012-06-25 03:36:49 -0700 | [diff] [blame] | 608 | static struct sh_dmae_pdata dma_platform_data = { |
| 609 | .slave = r8a7740_dmae_slaves, |
| 610 | .slave_num = ARRAY_SIZE(r8a7740_dmae_slaves), |
| 611 | .channel = r8a7740_dmae_channels, |
| 612 | .channel_num = ARRAY_SIZE(r8a7740_dmae_channels), |
Kuninori Morimoto | d7de938 | 2012-06-25 03:43:10 -0700 | [diff] [blame] | 613 | .ts_low_shift = TS_LOW_SHIFT, |
| 614 | .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT, |
| 615 | .ts_high_shift = TS_HI_SHIFT, |
| 616 | .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT, |
| 617 | .ts_shift = dma_ts_shift, |
| 618 | .ts_shift_num = ARRAY_SIZE(dma_ts_shift), |
Kuninori Morimoto | 643c330 | 2012-06-25 03:36:49 -0700 | [diff] [blame] | 619 | .dmaor_init = DMAOR_DME, |
| 620 | .chclr_present = 1, |
| 621 | }; |
| 622 | |
| 623 | /* Resource order important! */ |
| 624 | static struct resource r8a7740_dmae0_resources[] = { |
| 625 | { |
| 626 | /* Channel registers and DMAOR */ |
| 627 | .start = 0xfe008020, |
| 628 | .end = 0xfe00828f, |
| 629 | .flags = IORESOURCE_MEM, |
| 630 | }, |
| 631 | { |
| 632 | /* DMARSx */ |
| 633 | .start = 0xfe009000, |
| 634 | .end = 0xfe00900b, |
| 635 | .flags = IORESOURCE_MEM, |
| 636 | }, |
| 637 | { |
| 638 | .name = "error_irq", |
Bastian Hecht | 0b7d782 | 2013-03-27 14:54:04 +0100 | [diff] [blame] | 639 | .start = gic_spi(34), |
| 640 | .end = gic_spi(34), |
Kuninori Morimoto | 643c330 | 2012-06-25 03:36:49 -0700 | [diff] [blame] | 641 | .flags = IORESOURCE_IRQ, |
| 642 | }, |
| 643 | { |
| 644 | /* IRQ for channels 0-5 */ |
Bastian Hecht | 0b7d782 | 2013-03-27 14:54:04 +0100 | [diff] [blame] | 645 | .start = gic_spi(28), |
| 646 | .end = gic_spi(33), |
Kuninori Morimoto | 643c330 | 2012-06-25 03:36:49 -0700 | [diff] [blame] | 647 | .flags = IORESOURCE_IRQ, |
| 648 | }, |
| 649 | }; |
| 650 | |
| 651 | /* Resource order important! */ |
| 652 | static struct resource r8a7740_dmae1_resources[] = { |
| 653 | { |
| 654 | /* Channel registers and DMAOR */ |
| 655 | .start = 0xfe018020, |
| 656 | .end = 0xfe01828f, |
| 657 | .flags = IORESOURCE_MEM, |
| 658 | }, |
| 659 | { |
| 660 | /* DMARSx */ |
| 661 | .start = 0xfe019000, |
| 662 | .end = 0xfe01900b, |
| 663 | .flags = IORESOURCE_MEM, |
| 664 | }, |
| 665 | { |
| 666 | .name = "error_irq", |
Bastian Hecht | 0b7d782 | 2013-03-27 14:54:04 +0100 | [diff] [blame] | 667 | .start = gic_spi(41), |
| 668 | .end = gic_spi(41), |
Kuninori Morimoto | 643c330 | 2012-06-25 03:36:49 -0700 | [diff] [blame] | 669 | .flags = IORESOURCE_IRQ, |
| 670 | }, |
| 671 | { |
| 672 | /* IRQ for channels 0-5 */ |
Bastian Hecht | 0b7d782 | 2013-03-27 14:54:04 +0100 | [diff] [blame] | 673 | .start = gic_spi(35), |
| 674 | .end = gic_spi(40), |
Kuninori Morimoto | 643c330 | 2012-06-25 03:36:49 -0700 | [diff] [blame] | 675 | .flags = IORESOURCE_IRQ, |
| 676 | }, |
| 677 | }; |
| 678 | |
| 679 | /* Resource order important! */ |
| 680 | static struct resource r8a7740_dmae2_resources[] = { |
| 681 | { |
| 682 | /* Channel registers and DMAOR */ |
| 683 | .start = 0xfe028020, |
| 684 | .end = 0xfe02828f, |
| 685 | .flags = IORESOURCE_MEM, |
| 686 | }, |
| 687 | { |
| 688 | /* DMARSx */ |
| 689 | .start = 0xfe029000, |
| 690 | .end = 0xfe02900b, |
| 691 | .flags = IORESOURCE_MEM, |
| 692 | }, |
| 693 | { |
| 694 | .name = "error_irq", |
Bastian Hecht | 0b7d782 | 2013-03-27 14:54:04 +0100 | [diff] [blame] | 695 | .start = gic_spi(48), |
| 696 | .end = gic_spi(48), |
Kuninori Morimoto | 643c330 | 2012-06-25 03:36:49 -0700 | [diff] [blame] | 697 | .flags = IORESOURCE_IRQ, |
| 698 | }, |
| 699 | { |
| 700 | /* IRQ for channels 0-5 */ |
Bastian Hecht | 0b7d782 | 2013-03-27 14:54:04 +0100 | [diff] [blame] | 701 | .start = gic_spi(42), |
| 702 | .end = gic_spi(47), |
Kuninori Morimoto | 643c330 | 2012-06-25 03:36:49 -0700 | [diff] [blame] | 703 | .flags = IORESOURCE_IRQ, |
| 704 | }, |
| 705 | }; |
| 706 | |
| 707 | static struct platform_device dma0_device = { |
| 708 | .name = "sh-dma-engine", |
| 709 | .id = 0, |
| 710 | .resource = r8a7740_dmae0_resources, |
| 711 | .num_resources = ARRAY_SIZE(r8a7740_dmae0_resources), |
| 712 | .dev = { |
| 713 | .platform_data = &dma_platform_data, |
| 714 | }, |
| 715 | }; |
| 716 | |
| 717 | static struct platform_device dma1_device = { |
| 718 | .name = "sh-dma-engine", |
| 719 | .id = 1, |
| 720 | .resource = r8a7740_dmae1_resources, |
| 721 | .num_resources = ARRAY_SIZE(r8a7740_dmae1_resources), |
| 722 | .dev = { |
| 723 | .platform_data = &dma_platform_data, |
| 724 | }, |
| 725 | }; |
| 726 | |
| 727 | static struct platform_device dma2_device = { |
| 728 | .name = "sh-dma-engine", |
| 729 | .id = 2, |
| 730 | .resource = r8a7740_dmae2_resources, |
| 731 | .num_resources = ARRAY_SIZE(r8a7740_dmae2_resources), |
| 732 | .dev = { |
| 733 | .platform_data = &dma_platform_data, |
| 734 | }, |
| 735 | }; |
| 736 | |
Kuninori Morimoto | dbf382e | 2012-06-25 03:37:10 -0700 | [diff] [blame] | 737 | /* USB-DMAC */ |
Kuninori Morimoto | dbf382e | 2012-06-25 03:37:10 -0700 | [diff] [blame] | 738 | static const struct sh_dmae_channel r8a7740_usb_dma_channels[] = { |
| 739 | { |
| 740 | .offset = 0, |
| 741 | }, { |
| 742 | .offset = 0x20, |
| 743 | }, |
| 744 | }; |
| 745 | |
Kuninori Morimoto | dbf382e | 2012-06-25 03:37:10 -0700 | [diff] [blame] | 746 | static const struct sh_dmae_slave_config r8a7740_usb_dma_slaves[] = { |
| 747 | { |
| 748 | .slave_id = SHDMA_SLAVE_USBHS_TX, |
| 749 | .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE), |
| 750 | }, { |
| 751 | .slave_id = SHDMA_SLAVE_USBHS_RX, |
| 752 | .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE), |
| 753 | }, |
| 754 | }; |
| 755 | |
| 756 | static struct sh_dmae_pdata usb_dma_platform_data = { |
| 757 | .slave = r8a7740_usb_dma_slaves, |
| 758 | .slave_num = ARRAY_SIZE(r8a7740_usb_dma_slaves), |
| 759 | .channel = r8a7740_usb_dma_channels, |
| 760 | .channel_num = ARRAY_SIZE(r8a7740_usb_dma_channels), |
Kuninori Morimoto | d7de938 | 2012-06-25 03:43:10 -0700 | [diff] [blame] | 761 | .ts_low_shift = USBTS_LOW_SHIFT, |
| 762 | .ts_low_mask = USBTS_LOW_BIT << USBTS_LOW_SHIFT, |
| 763 | .ts_high_shift = USBTS_HI_SHIFT, |
| 764 | .ts_high_mask = USBTS_HI_BIT << USBTS_HI_SHIFT, |
Kuninori Morimoto | dbf382e | 2012-06-25 03:37:10 -0700 | [diff] [blame] | 765 | .ts_shift = dma_usbts_shift, |
| 766 | .ts_shift_num = ARRAY_SIZE(dma_usbts_shift), |
| 767 | .dmaor_init = DMAOR_DME, |
| 768 | .chcr_offset = 0x14, |
| 769 | .chcr_ie_bit = 1 << 5, |
| 770 | .dmaor_is_32bit = 1, |
| 771 | .needs_tend_set = 1, |
| 772 | .no_dmars = 1, |
| 773 | .slave_only = 1, |
| 774 | }; |
| 775 | |
| 776 | static struct resource r8a7740_usb_dma_resources[] = { |
| 777 | { |
| 778 | /* Channel registers and DMAOR */ |
| 779 | .start = 0xe68a0020, |
| 780 | .end = 0xe68a0064 - 1, |
| 781 | .flags = IORESOURCE_MEM, |
| 782 | }, |
| 783 | { |
| 784 | /* VCR/SWR/DMICR */ |
| 785 | .start = 0xe68a0000, |
| 786 | .end = 0xe68a0014 - 1, |
| 787 | .flags = IORESOURCE_MEM, |
| 788 | }, |
| 789 | { |
| 790 | /* IRQ for channels */ |
Bastian Hecht | 0b7d782 | 2013-03-27 14:54:04 +0100 | [diff] [blame] | 791 | .start = gic_spi(49), |
| 792 | .end = gic_spi(49), |
Kuninori Morimoto | dbf382e | 2012-06-25 03:37:10 -0700 | [diff] [blame] | 793 | .flags = IORESOURCE_IRQ, |
| 794 | }, |
| 795 | }; |
| 796 | |
| 797 | static struct platform_device usb_dma_device = { |
| 798 | .name = "sh-dma-engine", |
| 799 | .id = 3, |
| 800 | .resource = r8a7740_usb_dma_resources, |
| 801 | .num_resources = ARRAY_SIZE(r8a7740_usb_dma_resources), |
| 802 | .dev = { |
| 803 | .platform_data = &usb_dma_platform_data, |
| 804 | }, |
| 805 | }; |
| 806 | |
Kuninori Morimoto | 6831f3a | 2011-11-10 18:46:23 -0800 | [diff] [blame] | 807 | /* I2C */ |
| 808 | static struct resource i2c0_resources[] = { |
| 809 | [0] = { |
| 810 | .name = "IIC0", |
| 811 | .start = 0xfff20000, |
| 812 | .end = 0xfff20425 - 1, |
| 813 | .flags = IORESOURCE_MEM, |
| 814 | }, |
| 815 | [1] = { |
Bastian Hecht | 0b7d782 | 2013-03-27 14:54:04 +0100 | [diff] [blame] | 816 | .start = gic_spi(201), |
| 817 | .end = gic_spi(204), |
Kuninori Morimoto | 6831f3a | 2011-11-10 18:46:23 -0800 | [diff] [blame] | 818 | .flags = IORESOURCE_IRQ, |
| 819 | }, |
| 820 | }; |
| 821 | |
| 822 | static struct resource i2c1_resources[] = { |
| 823 | [0] = { |
| 824 | .name = "IIC1", |
| 825 | .start = 0xe6c20000, |
| 826 | .end = 0xe6c20425 - 1, |
| 827 | .flags = IORESOURCE_MEM, |
| 828 | }, |
| 829 | [1] = { |
Bastian Hecht | 0b7d782 | 2013-03-27 14:54:04 +0100 | [diff] [blame] | 830 | .start = gic_spi(70), /* IIC1_ALI1 */ |
| 831 | .end = gic_spi(73), /* IIC1_DTEI1 */ |
Kuninori Morimoto | 6831f3a | 2011-11-10 18:46:23 -0800 | [diff] [blame] | 832 | .flags = IORESOURCE_IRQ, |
| 833 | }, |
| 834 | }; |
| 835 | |
| 836 | static struct platform_device i2c0_device = { |
| 837 | .name = "i2c-sh_mobile", |
| 838 | .id = 0, |
| 839 | .resource = i2c0_resources, |
| 840 | .num_resources = ARRAY_SIZE(i2c0_resources), |
| 841 | }; |
| 842 | |
| 843 | static struct platform_device i2c1_device = { |
| 844 | .name = "i2c-sh_mobile", |
| 845 | .id = 1, |
| 846 | .resource = i2c1_resources, |
| 847 | .num_resources = ARRAY_SIZE(i2c1_resources), |
| 848 | }; |
| 849 | |
Nobuhiro Iwamatsu | 86bc52e | 2012-09-14 13:27:13 +0900 | [diff] [blame] | 850 | static struct resource pmu_resources[] = { |
| 851 | [0] = { |
Bastian Hecht | 0b7d782 | 2013-03-27 14:54:04 +0100 | [diff] [blame] | 852 | .start = gic_spi(83), |
| 853 | .end = gic_spi(83), |
Nobuhiro Iwamatsu | 86bc52e | 2012-09-14 13:27:13 +0900 | [diff] [blame] | 854 | .flags = IORESOURCE_IRQ, |
| 855 | }, |
| 856 | }; |
| 857 | |
| 858 | static struct platform_device pmu_device = { |
| 859 | .name = "arm-pmu", |
| 860 | .id = -1, |
| 861 | .num_resources = ARRAY_SIZE(pmu_resources), |
| 862 | .resource = pmu_resources, |
| 863 | }; |
| 864 | |
Kuninori Morimoto | 6831f3a | 2011-11-10 18:46:23 -0800 | [diff] [blame] | 865 | static struct platform_device *r8a7740_late_devices[] __initdata = { |
| 866 | &i2c0_device, |
| 867 | &i2c1_device, |
Kuninori Morimoto | 643c330 | 2012-06-25 03:36:49 -0700 | [diff] [blame] | 868 | &dma0_device, |
| 869 | &dma1_device, |
| 870 | &dma2_device, |
Kuninori Morimoto | dbf382e | 2012-06-25 03:37:10 -0700 | [diff] [blame] | 871 | &usb_dma_device, |
Nobuhiro Iwamatsu | 86bc52e | 2012-09-14 13:27:13 +0900 | [diff] [blame] | 872 | &pmu_device, |
Kuninori Morimoto | 6831f3a | 2011-11-10 18:46:23 -0800 | [diff] [blame] | 873 | }; |
| 874 | |
Kuninori Morimoto | d49679e | 2012-06-12 02:36:21 -0700 | [diff] [blame] | 875 | /* |
| 876 | * r8a7740 chip has lasting errata on MERAM buffer. |
| 877 | * this is work-around for it. |
| 878 | * see |
| 879 | * "Media RAM (MERAM)" on r8a7740 documentation |
| 880 | */ |
| 881 | #define MEBUFCNTR 0xFE950098 |
| 882 | void r8a7740_meram_workaround(void) |
| 883 | { |
| 884 | void __iomem *reg; |
| 885 | |
| 886 | reg = ioremap_nocache(MEBUFCNTR, 4); |
| 887 | if (reg) { |
| 888 | iowrite32(0x01600164, reg); |
| 889 | iounmap(reg); |
| 890 | } |
| 891 | } |
| 892 | |
Kuninori Morimoto | 6831f3a | 2011-11-10 18:46:23 -0800 | [diff] [blame] | 893 | #define ICCR 0x0004 |
| 894 | #define ICSTART 0x0070 |
| 895 | |
| 896 | #define i2c_read(reg, offset) ioread8(reg + offset) |
| 897 | #define i2c_write(reg, offset, data) iowrite8(data, reg + offset) |
| 898 | |
| 899 | /* |
| 900 | * r8a7740 chip has lasting errata on I2C I/O pad reset. |
| 901 | * this is work-around for it. |
| 902 | */ |
| 903 | static void r8a7740_i2c_workaround(struct platform_device *pdev) |
| 904 | { |
| 905 | struct resource *res; |
| 906 | void __iomem *reg; |
| 907 | |
| 908 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 909 | if (unlikely(!res)) { |
| 910 | pr_err("r8a7740 i2c workaround fail (cannot find resource)\n"); |
| 911 | return; |
| 912 | } |
| 913 | |
| 914 | reg = ioremap(res->start, resource_size(res)); |
| 915 | if (unlikely(!reg)) { |
| 916 | pr_err("r8a7740 i2c workaround fail (cannot map IO)\n"); |
| 917 | return; |
| 918 | } |
| 919 | |
| 920 | i2c_write(reg, ICCR, i2c_read(reg, ICCR) | 0x80); |
| 921 | i2c_read(reg, ICCR); /* dummy read */ |
| 922 | |
| 923 | i2c_write(reg, ICSTART, i2c_read(reg, ICSTART) | 0x10); |
| 924 | i2c_read(reg, ICSTART); /* dummy read */ |
| 925 | |
Kuninori Morimoto | 4228716 | 2012-04-13 02:41:06 -0700 | [diff] [blame] | 926 | udelay(10); |
Kuninori Morimoto | 6831f3a | 2011-11-10 18:46:23 -0800 | [diff] [blame] | 927 | |
| 928 | i2c_write(reg, ICCR, 0x01); |
Kuninori Morimoto | 6831f3a | 2011-11-10 18:46:23 -0800 | [diff] [blame] | 929 | i2c_write(reg, ICSTART, 0x00); |
Kuninori Morimoto | 4228716 | 2012-04-13 02:41:06 -0700 | [diff] [blame] | 930 | |
| 931 | udelay(10); |
Kuninori Morimoto | 6831f3a | 2011-11-10 18:46:23 -0800 | [diff] [blame] | 932 | |
| 933 | i2c_write(reg, ICCR, 0x10); |
Kuninori Morimoto | 4228716 | 2012-04-13 02:41:06 -0700 | [diff] [blame] | 934 | udelay(10); |
Kuninori Morimoto | 6831f3a | 2011-11-10 18:46:23 -0800 | [diff] [blame] | 935 | i2c_write(reg, ICCR, 0x00); |
Kuninori Morimoto | 4228716 | 2012-04-13 02:41:06 -0700 | [diff] [blame] | 936 | udelay(10); |
Kuninori Morimoto | 6831f3a | 2011-11-10 18:46:23 -0800 | [diff] [blame] | 937 | i2c_write(reg, ICCR, 0x10); |
Kuninori Morimoto | 4228716 | 2012-04-13 02:41:06 -0700 | [diff] [blame] | 938 | udelay(10); |
Kuninori Morimoto | 6831f3a | 2011-11-10 18:46:23 -0800 | [diff] [blame] | 939 | |
| 940 | iounmap(reg); |
| 941 | } |
| 942 | |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 943 | void __init r8a7740_add_standard_devices(void) |
| 944 | { |
Kuninori Morimoto | 6831f3a | 2011-11-10 18:46:23 -0800 | [diff] [blame] | 945 | /* I2C work-around */ |
| 946 | r8a7740_i2c_workaround(&i2c0_device); |
| 947 | r8a7740_i2c_workaround(&i2c1_device); |
| 948 | |
Rafael J. Wysocki | 7b56740 | 2012-08-07 01:13:37 +0200 | [diff] [blame] | 949 | r8a7740_init_pm_domains(); |
Kuninori Morimoto | 8459293 | 2012-07-05 01:25:58 -0700 | [diff] [blame] | 950 | |
| 951 | /* add devices */ |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 952 | platform_add_devices(r8a7740_early_devices, |
| 953 | ARRAY_SIZE(r8a7740_early_devices)); |
Kuninori Morimoto | 6831f3a | 2011-11-10 18:46:23 -0800 | [diff] [blame] | 954 | platform_add_devices(r8a7740_late_devices, |
| 955 | ARRAY_SIZE(r8a7740_late_devices)); |
Kuninori Morimoto | 802a563 | 2012-07-05 01:26:31 -0700 | [diff] [blame] | 956 | |
| 957 | /* add devices to PM domain */ |
| 958 | |
Rafael J. Wysocki | 8bdd946 | 2012-08-07 01:07:01 +0200 | [diff] [blame] | 959 | rmobile_add_device_to_domain("A3SP", &scif0_device); |
| 960 | rmobile_add_device_to_domain("A3SP", &scif1_device); |
| 961 | rmobile_add_device_to_domain("A3SP", &scif2_device); |
| 962 | rmobile_add_device_to_domain("A3SP", &scif3_device); |
| 963 | rmobile_add_device_to_domain("A3SP", &scif4_device); |
| 964 | rmobile_add_device_to_domain("A3SP", &scif5_device); |
| 965 | rmobile_add_device_to_domain("A3SP", &scif6_device); |
| 966 | rmobile_add_device_to_domain("A3SP", &scif7_device); |
| 967 | rmobile_add_device_to_domain("A3SP", &scifb_device); |
| 968 | rmobile_add_device_to_domain("A3SP", &i2c1_device); |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 969 | } |
| 970 | |
| 971 | void __init r8a7740_add_early_devices(void) |
| 972 | { |
| 973 | early_platform_add_devices(r8a7740_early_devices, |
| 974 | ARRAY_SIZE(r8a7740_early_devices)); |
Magnus Damm | d3ab722 | 2012-02-29 21:37:35 +0900 | [diff] [blame] | 975 | |
| 976 | /* setup early console here as well */ |
| 977 | shmobile_setup_console(); |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 978 | } |
Magnus Damm | 755d57b | 2012-07-06 17:08:07 +0900 | [diff] [blame] | 979 | |
| 980 | #ifdef CONFIG_USE_OF |
| 981 | |
| 982 | void __init r8a7740_add_early_devices_dt(void) |
| 983 | { |
| 984 | shmobile_setup_delay(800, 1, 3); /* Cortex-A9 @ 800MHz */ |
| 985 | |
| 986 | early_platform_add_devices(r8a7740_early_devices, |
| 987 | ARRAY_SIZE(r8a7740_early_devices)); |
| 988 | |
| 989 | /* setup early console here as well */ |
| 990 | shmobile_setup_console(); |
| 991 | } |
| 992 | |
| 993 | static const struct of_dev_auxdata r8a7740_auxdata_lookup[] __initconst = { |
| 994 | { } |
| 995 | }; |
| 996 | |
| 997 | void __init r8a7740_add_standard_devices_dt(void) |
| 998 | { |
| 999 | /* clocks are setup late during boot in the case of DT */ |
| 1000 | r8a7740_clock_init(0); |
| 1001 | |
| 1002 | platform_add_devices(r8a7740_early_devices, |
| 1003 | ARRAY_SIZE(r8a7740_early_devices)); |
| 1004 | |
| 1005 | of_platform_populate(NULL, of_default_bus_match_table, |
| 1006 | r8a7740_auxdata_lookup, NULL); |
| 1007 | } |
| 1008 | |
| 1009 | static const char *r8a7740_boards_compat_dt[] __initdata = { |
| 1010 | "renesas,r8a7740", |
| 1011 | NULL, |
| 1012 | }; |
| 1013 | |
Kuninori Morimoto | a41acc4 | 2012-10-21 22:15:13 -0700 | [diff] [blame] | 1014 | DT_MACHINE_START(R8A7740_DT, "Generic R8A7740 (Flattened Device Tree)") |
Magnus Damm | 755d57b | 2012-07-06 17:08:07 +0900 | [diff] [blame] | 1015 | .map_io = r8a7740_map_io, |
| 1016 | .init_early = r8a7740_add_early_devices_dt, |
| 1017 | .init_irq = r8a7740_init_irq, |
Magnus Damm | 755d57b | 2012-07-06 17:08:07 +0900 | [diff] [blame] | 1018 | .init_machine = r8a7740_add_standard_devices_dt, |
Magnus Damm | 755d57b | 2012-07-06 17:08:07 +0900 | [diff] [blame] | 1019 | .dt_compat = r8a7740_boards_compat_dt, |
| 1020 | MACHINE_END |
| 1021 | |
| 1022 | #endif /* CONFIG_USE_OF */ |