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 | 3841e6f5 | 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> |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 25 | #include <linux/platform_device.h> |
Magnus Damm | 755d57b | 2012-07-06 17:08:07 +0900 | [diff] [blame] | 26 | #include <linux/of_platform.h> |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 27 | #include <linux/serial_sci.h> |
Kuninori Morimoto | 643c330 | 2012-06-25 03:36:49 -0700 | [diff] [blame] | 28 | #include <linux/sh_dma.h> |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 29 | #include <linux/sh_timer.h> |
Kuninori Morimoto | d7de938 | 2012-06-25 03:43:10 -0700 | [diff] [blame] | 30 | #include <mach/dma-register.h> |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 31 | #include <mach/r8a7740.h> |
Kuninori Morimoto | 8459293 | 2012-07-05 01:25:58 -0700 | [diff] [blame] | 32 | #include <mach/pm-rmobile.h> |
Magnus Damm | d3ab722 | 2012-02-29 21:37:35 +0900 | [diff] [blame] | 33 | #include <mach/common.h> |
Rob Herring | 250a272 | 2012-01-03 16:57:33 -0600 | [diff] [blame] | 34 | #include <mach/irqs.h> |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 35 | #include <asm/mach-types.h> |
Magnus Damm | d3ab722 | 2012-02-29 21:37:35 +0900 | [diff] [blame] | 36 | #include <asm/mach/map.h> |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 37 | #include <asm/mach/arch.h> |
Magnus Damm | 23e5bc0 | 2012-03-06 17:36:53 +0900 | [diff] [blame] | 38 | #include <asm/mach/time.h> |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 39 | |
Magnus Damm | d3ab722 | 2012-02-29 21:37:35 +0900 | [diff] [blame] | 40 | static struct map_desc r8a7740_io_desc[] __initdata = { |
| 41 | /* |
| 42 | * for CPGA/INTC/PFC |
| 43 | * 0xe6000000-0xefffffff -> 0xe6000000-0xefffffff |
| 44 | */ |
| 45 | { |
| 46 | .virtual = 0xe6000000, |
| 47 | .pfn = __phys_to_pfn(0xe6000000), |
| 48 | .length = 160 << 20, |
| 49 | .type = MT_DEVICE_NONSHARED |
| 50 | }, |
| 51 | #ifdef CONFIG_CACHE_L2X0 |
| 52 | /* |
| 53 | * for l2x0_init() |
| 54 | * 0xf0100000-0xf0101000 -> 0xf0002000-0xf0003000 |
| 55 | */ |
| 56 | { |
| 57 | .virtual = 0xf0002000, |
| 58 | .pfn = __phys_to_pfn(0xf0100000), |
| 59 | .length = PAGE_SIZE, |
| 60 | .type = MT_DEVICE_NONSHARED |
| 61 | }, |
| 62 | #endif |
| 63 | }; |
| 64 | |
| 65 | void __init r8a7740_map_io(void) |
| 66 | { |
| 67 | iotable_init(r8a7740_io_desc, ARRAY_SIZE(r8a7740_io_desc)); |
| 68 | } |
| 69 | |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 70 | /* SCIFA0 */ |
| 71 | static struct plat_sci_port scif0_platform_data = { |
| 72 | .mapbase = 0xe6c40000, |
| 73 | .flags = UPF_BOOT_AUTOCONF, |
| 74 | .scscr = SCSCR_RE | SCSCR_TE, |
| 75 | .scbrr_algo_id = SCBRR_ALGO_4, |
| 76 | .type = PORT_SCIFA, |
Kuninori Morimoto | 215d6cc | 2011-11-10 18:46:35 -0800 | [diff] [blame] | 77 | .irqs = SCIx_IRQ_MUXED(evt2irq(0x0c00)), |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 78 | }; |
| 79 | |
| 80 | static struct platform_device scif0_device = { |
| 81 | .name = "sh-sci", |
| 82 | .id = 0, |
| 83 | .dev = { |
| 84 | .platform_data = &scif0_platform_data, |
| 85 | }, |
| 86 | }; |
| 87 | |
| 88 | /* SCIFA1 */ |
| 89 | static struct plat_sci_port scif1_platform_data = { |
| 90 | .mapbase = 0xe6c50000, |
| 91 | .flags = UPF_BOOT_AUTOCONF, |
| 92 | .scscr = SCSCR_RE | SCSCR_TE, |
| 93 | .scbrr_algo_id = SCBRR_ALGO_4, |
| 94 | .type = PORT_SCIFA, |
Kuninori Morimoto | 215d6cc | 2011-11-10 18:46:35 -0800 | [diff] [blame] | 95 | .irqs = SCIx_IRQ_MUXED(evt2irq(0x0c20)), |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 96 | }; |
| 97 | |
| 98 | static struct platform_device scif1_device = { |
| 99 | .name = "sh-sci", |
| 100 | .id = 1, |
| 101 | .dev = { |
| 102 | .platform_data = &scif1_platform_data, |
| 103 | }, |
| 104 | }; |
| 105 | |
| 106 | /* SCIFA2 */ |
| 107 | static struct plat_sci_port scif2_platform_data = { |
| 108 | .mapbase = 0xe6c60000, |
| 109 | .flags = UPF_BOOT_AUTOCONF, |
| 110 | .scscr = SCSCR_RE | SCSCR_TE, |
| 111 | .scbrr_algo_id = SCBRR_ALGO_4, |
| 112 | .type = PORT_SCIFA, |
Kuninori Morimoto | 215d6cc | 2011-11-10 18:46:35 -0800 | [diff] [blame] | 113 | .irqs = SCIx_IRQ_MUXED(evt2irq(0x0c40)), |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 114 | }; |
| 115 | |
| 116 | static struct platform_device scif2_device = { |
| 117 | .name = "sh-sci", |
| 118 | .id = 2, |
| 119 | .dev = { |
| 120 | .platform_data = &scif2_platform_data, |
| 121 | }, |
| 122 | }; |
| 123 | |
| 124 | /* SCIFA3 */ |
| 125 | static struct plat_sci_port scif3_platform_data = { |
| 126 | .mapbase = 0xe6c70000, |
| 127 | .flags = UPF_BOOT_AUTOCONF, |
| 128 | .scscr = SCSCR_RE | SCSCR_TE, |
| 129 | .scbrr_algo_id = SCBRR_ALGO_4, |
| 130 | .type = PORT_SCIFA, |
Kuninori Morimoto | 215d6cc | 2011-11-10 18:46:35 -0800 | [diff] [blame] | 131 | .irqs = SCIx_IRQ_MUXED(evt2irq(0x0c60)), |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 132 | }; |
| 133 | |
| 134 | static struct platform_device scif3_device = { |
| 135 | .name = "sh-sci", |
| 136 | .id = 3, |
| 137 | .dev = { |
| 138 | .platform_data = &scif3_platform_data, |
| 139 | }, |
| 140 | }; |
| 141 | |
| 142 | /* SCIFA4 */ |
| 143 | static struct plat_sci_port scif4_platform_data = { |
| 144 | .mapbase = 0xe6c80000, |
| 145 | .flags = UPF_BOOT_AUTOCONF, |
| 146 | .scscr = SCSCR_RE | SCSCR_TE, |
| 147 | .scbrr_algo_id = SCBRR_ALGO_4, |
| 148 | .type = PORT_SCIFA, |
Kuninori Morimoto | 215d6cc | 2011-11-10 18:46:35 -0800 | [diff] [blame] | 149 | .irqs = SCIx_IRQ_MUXED(evt2irq(0x0d20)), |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 150 | }; |
| 151 | |
| 152 | static struct platform_device scif4_device = { |
| 153 | .name = "sh-sci", |
| 154 | .id = 4, |
| 155 | .dev = { |
| 156 | .platform_data = &scif4_platform_data, |
| 157 | }, |
| 158 | }; |
| 159 | |
| 160 | /* SCIFA5 */ |
| 161 | static struct plat_sci_port scif5_platform_data = { |
| 162 | .mapbase = 0xe6cb0000, |
| 163 | .flags = UPF_BOOT_AUTOCONF, |
| 164 | .scscr = SCSCR_RE | SCSCR_TE, |
| 165 | .scbrr_algo_id = SCBRR_ALGO_4, |
| 166 | .type = PORT_SCIFA, |
Kuninori Morimoto | 215d6cc | 2011-11-10 18:46:35 -0800 | [diff] [blame] | 167 | .irqs = SCIx_IRQ_MUXED(evt2irq(0x0d40)), |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 168 | }; |
| 169 | |
| 170 | static struct platform_device scif5_device = { |
| 171 | .name = "sh-sci", |
| 172 | .id = 5, |
| 173 | .dev = { |
| 174 | .platform_data = &scif5_platform_data, |
| 175 | }, |
| 176 | }; |
| 177 | |
| 178 | /* SCIFA6 */ |
| 179 | static struct plat_sci_port scif6_platform_data = { |
| 180 | .mapbase = 0xe6cc0000, |
| 181 | .flags = UPF_BOOT_AUTOCONF, |
| 182 | .scscr = SCSCR_RE | SCSCR_TE, |
| 183 | .scbrr_algo_id = SCBRR_ALGO_4, |
| 184 | .type = PORT_SCIFA, |
Kuninori Morimoto | 215d6cc | 2011-11-10 18:46:35 -0800 | [diff] [blame] | 185 | .irqs = SCIx_IRQ_MUXED(evt2irq(0x04c0)), |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 186 | }; |
| 187 | |
| 188 | static struct platform_device scif6_device = { |
| 189 | .name = "sh-sci", |
| 190 | .id = 6, |
| 191 | .dev = { |
| 192 | .platform_data = &scif6_platform_data, |
| 193 | }, |
| 194 | }; |
| 195 | |
| 196 | /* SCIFA7 */ |
| 197 | static struct plat_sci_port scif7_platform_data = { |
| 198 | .mapbase = 0xe6cd0000, |
| 199 | .flags = UPF_BOOT_AUTOCONF, |
| 200 | .scscr = SCSCR_RE | SCSCR_TE, |
| 201 | .scbrr_algo_id = SCBRR_ALGO_4, |
| 202 | .type = PORT_SCIFA, |
Kuninori Morimoto | 215d6cc | 2011-11-10 18:46:35 -0800 | [diff] [blame] | 203 | .irqs = SCIx_IRQ_MUXED(evt2irq(0x04e0)), |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 204 | }; |
| 205 | |
| 206 | static struct platform_device scif7_device = { |
| 207 | .name = "sh-sci", |
| 208 | .id = 7, |
| 209 | .dev = { |
| 210 | .platform_data = &scif7_platform_data, |
| 211 | }, |
| 212 | }; |
| 213 | |
| 214 | /* SCIFB */ |
| 215 | static struct plat_sci_port scifb_platform_data = { |
| 216 | .mapbase = 0xe6c30000, |
| 217 | .flags = UPF_BOOT_AUTOCONF, |
| 218 | .scscr = SCSCR_RE | SCSCR_TE, |
| 219 | .scbrr_algo_id = SCBRR_ALGO_4, |
| 220 | .type = PORT_SCIFB, |
Kuninori Morimoto | 215d6cc | 2011-11-10 18:46:35 -0800 | [diff] [blame] | 221 | .irqs = SCIx_IRQ_MUXED(evt2irq(0x0d60)), |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 222 | }; |
| 223 | |
| 224 | static struct platform_device scifb_device = { |
| 225 | .name = "sh-sci", |
| 226 | .id = 8, |
| 227 | .dev = { |
| 228 | .platform_data = &scifb_platform_data, |
| 229 | }, |
| 230 | }; |
| 231 | |
| 232 | /* CMT */ |
| 233 | static struct sh_timer_config cmt10_platform_data = { |
| 234 | .name = "CMT10", |
| 235 | .channel_offset = 0x10, |
| 236 | .timer_bit = 0, |
| 237 | .clockevent_rating = 125, |
| 238 | .clocksource_rating = 125, |
| 239 | }; |
| 240 | |
| 241 | static struct resource cmt10_resources[] = { |
| 242 | [0] = { |
| 243 | .name = "CMT10", |
| 244 | .start = 0xe6138010, |
| 245 | .end = 0xe613801b, |
| 246 | .flags = IORESOURCE_MEM, |
| 247 | }, |
| 248 | [1] = { |
Kuninori Morimoto | 215d6cc | 2011-11-10 18:46:35 -0800 | [diff] [blame] | 249 | .start = evt2irq(0x0b00), |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 250 | .flags = IORESOURCE_IRQ, |
| 251 | }, |
| 252 | }; |
| 253 | |
| 254 | static struct platform_device cmt10_device = { |
| 255 | .name = "sh_cmt", |
| 256 | .id = 10, |
| 257 | .dev = { |
| 258 | .platform_data = &cmt10_platform_data, |
| 259 | }, |
| 260 | .resource = cmt10_resources, |
| 261 | .num_resources = ARRAY_SIZE(cmt10_resources), |
| 262 | }; |
| 263 | |
Kuninori Morimoto | e67d7af | 2012-12-12 02:08:09 -0800 | [diff] [blame^] | 264 | /* TMU */ |
| 265 | static struct sh_timer_config tmu00_platform_data = { |
| 266 | .name = "TMU00", |
| 267 | .channel_offset = 0x4, |
| 268 | .timer_bit = 0, |
| 269 | .clockevent_rating = 200, |
| 270 | }; |
| 271 | |
| 272 | static struct resource tmu00_resources[] = { |
| 273 | [0] = { |
| 274 | .name = "TMU00", |
| 275 | .start = 0xfff80008, |
| 276 | .end = 0xfff80014 - 1, |
| 277 | .flags = IORESOURCE_MEM, |
| 278 | }, |
| 279 | [1] = { |
| 280 | .start = intcs_evt2irq(0xe80), |
| 281 | .flags = IORESOURCE_IRQ, |
| 282 | }, |
| 283 | }; |
| 284 | |
| 285 | static struct platform_device tmu00_device = { |
| 286 | .name = "sh_tmu", |
| 287 | .id = 0, |
| 288 | .dev = { |
| 289 | .platform_data = &tmu00_platform_data, |
| 290 | }, |
| 291 | .resource = tmu00_resources, |
| 292 | .num_resources = ARRAY_SIZE(tmu00_resources), |
| 293 | }; |
| 294 | |
| 295 | static struct sh_timer_config tmu01_platform_data = { |
| 296 | .name = "TMU01", |
| 297 | .channel_offset = 0x10, |
| 298 | .timer_bit = 1, |
| 299 | .clocksource_rating = 200, |
| 300 | }; |
| 301 | |
| 302 | static struct resource tmu01_resources[] = { |
| 303 | [0] = { |
| 304 | .name = "TMU01", |
| 305 | .start = 0xfff80014, |
| 306 | .end = 0xfff80020 - 1, |
| 307 | .flags = IORESOURCE_MEM, |
| 308 | }, |
| 309 | [1] = { |
| 310 | .start = intcs_evt2irq(0xea0), |
| 311 | .flags = IORESOURCE_IRQ, |
| 312 | }, |
| 313 | }; |
| 314 | |
| 315 | static struct platform_device tmu01_device = { |
| 316 | .name = "sh_tmu", |
| 317 | .id = 1, |
| 318 | .dev = { |
| 319 | .platform_data = &tmu01_platform_data, |
| 320 | }, |
| 321 | .resource = tmu01_resources, |
| 322 | .num_resources = ARRAY_SIZE(tmu01_resources), |
| 323 | }; |
| 324 | |
| 325 | static struct sh_timer_config tmu02_platform_data = { |
| 326 | .name = "TMU02", |
| 327 | .channel_offset = 0x1C, |
| 328 | .timer_bit = 2, |
| 329 | .clocksource_rating = 200, |
| 330 | }; |
| 331 | |
| 332 | static struct resource tmu02_resources[] = { |
| 333 | [0] = { |
| 334 | .name = "TMU02", |
| 335 | .start = 0xfff80020, |
| 336 | .end = 0xfff8002C - 1, |
| 337 | .flags = IORESOURCE_MEM, |
| 338 | }, |
| 339 | [1] = { |
| 340 | .start = intcs_evt2irq(0xec0), |
| 341 | .flags = IORESOURCE_IRQ, |
| 342 | }, |
| 343 | }; |
| 344 | |
| 345 | static struct platform_device tmu02_device = { |
| 346 | .name = "sh_tmu", |
| 347 | .id = 2, |
| 348 | .dev = { |
| 349 | .platform_data = &tmu02_platform_data, |
| 350 | }, |
| 351 | .resource = tmu02_resources, |
| 352 | .num_resources = ARRAY_SIZE(tmu02_resources), |
| 353 | }; |
| 354 | |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 355 | static struct platform_device *r8a7740_early_devices[] __initdata = { |
| 356 | &scif0_device, |
| 357 | &scif1_device, |
| 358 | &scif2_device, |
| 359 | &scif3_device, |
| 360 | &scif4_device, |
| 361 | &scif5_device, |
| 362 | &scif6_device, |
| 363 | &scif7_device, |
| 364 | &scifb_device, |
| 365 | &cmt10_device, |
Kuninori Morimoto | e67d7af | 2012-12-12 02:08:09 -0800 | [diff] [blame^] | 366 | &tmu00_device, |
| 367 | &tmu01_device, |
| 368 | &tmu02_device, |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 369 | }; |
| 370 | |
Kuninori Morimoto | 643c330 | 2012-06-25 03:36:49 -0700 | [diff] [blame] | 371 | /* DMA */ |
Kuninori Morimoto | 643c330 | 2012-06-25 03:36:49 -0700 | [diff] [blame] | 372 | static const struct sh_dmae_slave_config r8a7740_dmae_slaves[] = { |
| 373 | { |
Kuninori Morimoto | cb76eb8 | 2012-06-25 03:37:00 -0700 | [diff] [blame] | 374 | .slave_id = SHDMA_SLAVE_SDHI0_TX, |
| 375 | .addr = 0xe6850030, |
| 376 | .chcr = CHCR_TX(XMIT_SZ_16BIT), |
| 377 | .mid_rid = 0xc1, |
| 378 | }, { |
| 379 | .slave_id = SHDMA_SLAVE_SDHI0_RX, |
| 380 | .addr = 0xe6850030, |
| 381 | .chcr = CHCR_RX(XMIT_SZ_16BIT), |
| 382 | .mid_rid = 0xc2, |
| 383 | }, { |
| 384 | .slave_id = SHDMA_SLAVE_SDHI1_TX, |
| 385 | .addr = 0xe6860030, |
| 386 | .chcr = CHCR_TX(XMIT_SZ_16BIT), |
| 387 | .mid_rid = 0xc9, |
| 388 | }, { |
| 389 | .slave_id = SHDMA_SLAVE_SDHI1_RX, |
| 390 | .addr = 0xe6860030, |
| 391 | .chcr = CHCR_RX(XMIT_SZ_16BIT), |
| 392 | .mid_rid = 0xca, |
| 393 | }, { |
| 394 | .slave_id = SHDMA_SLAVE_SDHI2_TX, |
| 395 | .addr = 0xe6870030, |
| 396 | .chcr = CHCR_TX(XMIT_SZ_16BIT), |
| 397 | .mid_rid = 0xcd, |
| 398 | }, { |
| 399 | .slave_id = SHDMA_SLAVE_SDHI2_RX, |
| 400 | .addr = 0xe6870030, |
| 401 | .chcr = CHCR_RX(XMIT_SZ_16BIT), |
| 402 | .mid_rid = 0xce, |
| 403 | }, { |
Kuninori Morimoto | 643c330 | 2012-06-25 03:36:49 -0700 | [diff] [blame] | 404 | .slave_id = SHDMA_SLAVE_FSIA_TX, |
| 405 | .addr = 0xfe1f0024, |
| 406 | .chcr = CHCR_TX(XMIT_SZ_32BIT), |
| 407 | .mid_rid = 0xb1, |
| 408 | }, { |
| 409 | .slave_id = SHDMA_SLAVE_FSIA_RX, |
| 410 | .addr = 0xfe1f0020, |
| 411 | .chcr = CHCR_RX(XMIT_SZ_32BIT), |
| 412 | .mid_rid = 0xb2, |
| 413 | }, { |
| 414 | .slave_id = SHDMA_SLAVE_FSIB_TX, |
| 415 | .addr = 0xfe1f0064, |
| 416 | .chcr = CHCR_TX(XMIT_SZ_32BIT), |
| 417 | .mid_rid = 0xb5, |
| 418 | }, |
| 419 | }; |
| 420 | |
| 421 | #define DMA_CHANNEL(a, b, c) \ |
| 422 | { \ |
| 423 | .offset = a, \ |
| 424 | .dmars = b, \ |
| 425 | .dmars_bit = c, \ |
| 426 | .chclr_offset = (0x220 - 0x20) + a \ |
| 427 | } |
| 428 | |
| 429 | static const struct sh_dmae_channel r8a7740_dmae_channels[] = { |
| 430 | DMA_CHANNEL(0x00, 0, 0), |
| 431 | DMA_CHANNEL(0x10, 0, 8), |
| 432 | DMA_CHANNEL(0x20, 4, 0), |
| 433 | DMA_CHANNEL(0x30, 4, 8), |
| 434 | DMA_CHANNEL(0x50, 8, 0), |
| 435 | DMA_CHANNEL(0x60, 8, 8), |
| 436 | }; |
| 437 | |
Kuninori Morimoto | 643c330 | 2012-06-25 03:36:49 -0700 | [diff] [blame] | 438 | static struct sh_dmae_pdata dma_platform_data = { |
| 439 | .slave = r8a7740_dmae_slaves, |
| 440 | .slave_num = ARRAY_SIZE(r8a7740_dmae_slaves), |
| 441 | .channel = r8a7740_dmae_channels, |
| 442 | .channel_num = ARRAY_SIZE(r8a7740_dmae_channels), |
Kuninori Morimoto | d7de938 | 2012-06-25 03:43:10 -0700 | [diff] [blame] | 443 | .ts_low_shift = TS_LOW_SHIFT, |
| 444 | .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT, |
| 445 | .ts_high_shift = TS_HI_SHIFT, |
| 446 | .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT, |
| 447 | .ts_shift = dma_ts_shift, |
| 448 | .ts_shift_num = ARRAY_SIZE(dma_ts_shift), |
Kuninori Morimoto | 643c330 | 2012-06-25 03:36:49 -0700 | [diff] [blame] | 449 | .dmaor_init = DMAOR_DME, |
| 450 | .chclr_present = 1, |
| 451 | }; |
| 452 | |
| 453 | /* Resource order important! */ |
| 454 | static struct resource r8a7740_dmae0_resources[] = { |
| 455 | { |
| 456 | /* Channel registers and DMAOR */ |
| 457 | .start = 0xfe008020, |
| 458 | .end = 0xfe00828f, |
| 459 | .flags = IORESOURCE_MEM, |
| 460 | }, |
| 461 | { |
| 462 | /* DMARSx */ |
| 463 | .start = 0xfe009000, |
| 464 | .end = 0xfe00900b, |
| 465 | .flags = IORESOURCE_MEM, |
| 466 | }, |
| 467 | { |
| 468 | .name = "error_irq", |
| 469 | .start = evt2irq(0x20c0), |
| 470 | .end = evt2irq(0x20c0), |
| 471 | .flags = IORESOURCE_IRQ, |
| 472 | }, |
| 473 | { |
| 474 | /* IRQ for channels 0-5 */ |
| 475 | .start = evt2irq(0x2000), |
| 476 | .end = evt2irq(0x20a0), |
| 477 | .flags = IORESOURCE_IRQ, |
| 478 | }, |
| 479 | }; |
| 480 | |
| 481 | /* Resource order important! */ |
| 482 | static struct resource r8a7740_dmae1_resources[] = { |
| 483 | { |
| 484 | /* Channel registers and DMAOR */ |
| 485 | .start = 0xfe018020, |
| 486 | .end = 0xfe01828f, |
| 487 | .flags = IORESOURCE_MEM, |
| 488 | }, |
| 489 | { |
| 490 | /* DMARSx */ |
| 491 | .start = 0xfe019000, |
| 492 | .end = 0xfe01900b, |
| 493 | .flags = IORESOURCE_MEM, |
| 494 | }, |
| 495 | { |
| 496 | .name = "error_irq", |
| 497 | .start = evt2irq(0x21c0), |
| 498 | .end = evt2irq(0x21c0), |
| 499 | .flags = IORESOURCE_IRQ, |
| 500 | }, |
| 501 | { |
| 502 | /* IRQ for channels 0-5 */ |
| 503 | .start = evt2irq(0x2100), |
| 504 | .end = evt2irq(0x21a0), |
| 505 | .flags = IORESOURCE_IRQ, |
| 506 | }, |
| 507 | }; |
| 508 | |
| 509 | /* Resource order important! */ |
| 510 | static struct resource r8a7740_dmae2_resources[] = { |
| 511 | { |
| 512 | /* Channel registers and DMAOR */ |
| 513 | .start = 0xfe028020, |
| 514 | .end = 0xfe02828f, |
| 515 | .flags = IORESOURCE_MEM, |
| 516 | }, |
| 517 | { |
| 518 | /* DMARSx */ |
| 519 | .start = 0xfe029000, |
| 520 | .end = 0xfe02900b, |
| 521 | .flags = IORESOURCE_MEM, |
| 522 | }, |
| 523 | { |
| 524 | .name = "error_irq", |
| 525 | .start = evt2irq(0x22c0), |
| 526 | .end = evt2irq(0x22c0), |
| 527 | .flags = IORESOURCE_IRQ, |
| 528 | }, |
| 529 | { |
| 530 | /* IRQ for channels 0-5 */ |
| 531 | .start = evt2irq(0x2200), |
| 532 | .end = evt2irq(0x22a0), |
| 533 | .flags = IORESOURCE_IRQ, |
| 534 | }, |
| 535 | }; |
| 536 | |
| 537 | static struct platform_device dma0_device = { |
| 538 | .name = "sh-dma-engine", |
| 539 | .id = 0, |
| 540 | .resource = r8a7740_dmae0_resources, |
| 541 | .num_resources = ARRAY_SIZE(r8a7740_dmae0_resources), |
| 542 | .dev = { |
| 543 | .platform_data = &dma_platform_data, |
| 544 | }, |
| 545 | }; |
| 546 | |
| 547 | static struct platform_device dma1_device = { |
| 548 | .name = "sh-dma-engine", |
| 549 | .id = 1, |
| 550 | .resource = r8a7740_dmae1_resources, |
| 551 | .num_resources = ARRAY_SIZE(r8a7740_dmae1_resources), |
| 552 | .dev = { |
| 553 | .platform_data = &dma_platform_data, |
| 554 | }, |
| 555 | }; |
| 556 | |
| 557 | static struct platform_device dma2_device = { |
| 558 | .name = "sh-dma-engine", |
| 559 | .id = 2, |
| 560 | .resource = r8a7740_dmae2_resources, |
| 561 | .num_resources = ARRAY_SIZE(r8a7740_dmae2_resources), |
| 562 | .dev = { |
| 563 | .platform_data = &dma_platform_data, |
| 564 | }, |
| 565 | }; |
| 566 | |
Kuninori Morimoto | dbf382e | 2012-06-25 03:37:10 -0700 | [diff] [blame] | 567 | /* USB-DMAC */ |
Kuninori Morimoto | dbf382e | 2012-06-25 03:37:10 -0700 | [diff] [blame] | 568 | static const struct sh_dmae_channel r8a7740_usb_dma_channels[] = { |
| 569 | { |
| 570 | .offset = 0, |
| 571 | }, { |
| 572 | .offset = 0x20, |
| 573 | }, |
| 574 | }; |
| 575 | |
Kuninori Morimoto | dbf382e | 2012-06-25 03:37:10 -0700 | [diff] [blame] | 576 | static const struct sh_dmae_slave_config r8a7740_usb_dma_slaves[] = { |
| 577 | { |
| 578 | .slave_id = SHDMA_SLAVE_USBHS_TX, |
| 579 | .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE), |
| 580 | }, { |
| 581 | .slave_id = SHDMA_SLAVE_USBHS_RX, |
| 582 | .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE), |
| 583 | }, |
| 584 | }; |
| 585 | |
| 586 | static struct sh_dmae_pdata usb_dma_platform_data = { |
| 587 | .slave = r8a7740_usb_dma_slaves, |
| 588 | .slave_num = ARRAY_SIZE(r8a7740_usb_dma_slaves), |
| 589 | .channel = r8a7740_usb_dma_channels, |
| 590 | .channel_num = ARRAY_SIZE(r8a7740_usb_dma_channels), |
Kuninori Morimoto | d7de938 | 2012-06-25 03:43:10 -0700 | [diff] [blame] | 591 | .ts_low_shift = USBTS_LOW_SHIFT, |
| 592 | .ts_low_mask = USBTS_LOW_BIT << USBTS_LOW_SHIFT, |
| 593 | .ts_high_shift = USBTS_HI_SHIFT, |
| 594 | .ts_high_mask = USBTS_HI_BIT << USBTS_HI_SHIFT, |
Kuninori Morimoto | dbf382e | 2012-06-25 03:37:10 -0700 | [diff] [blame] | 595 | .ts_shift = dma_usbts_shift, |
| 596 | .ts_shift_num = ARRAY_SIZE(dma_usbts_shift), |
| 597 | .dmaor_init = DMAOR_DME, |
| 598 | .chcr_offset = 0x14, |
| 599 | .chcr_ie_bit = 1 << 5, |
| 600 | .dmaor_is_32bit = 1, |
| 601 | .needs_tend_set = 1, |
| 602 | .no_dmars = 1, |
| 603 | .slave_only = 1, |
| 604 | }; |
| 605 | |
| 606 | static struct resource r8a7740_usb_dma_resources[] = { |
| 607 | { |
| 608 | /* Channel registers and DMAOR */ |
| 609 | .start = 0xe68a0020, |
| 610 | .end = 0xe68a0064 - 1, |
| 611 | .flags = IORESOURCE_MEM, |
| 612 | }, |
| 613 | { |
| 614 | /* VCR/SWR/DMICR */ |
| 615 | .start = 0xe68a0000, |
| 616 | .end = 0xe68a0014 - 1, |
| 617 | .flags = IORESOURCE_MEM, |
| 618 | }, |
| 619 | { |
| 620 | /* IRQ for channels */ |
| 621 | .start = evt2irq(0x0a00), |
| 622 | .end = evt2irq(0x0a00), |
| 623 | .flags = IORESOURCE_IRQ, |
| 624 | }, |
| 625 | }; |
| 626 | |
| 627 | static struct platform_device usb_dma_device = { |
| 628 | .name = "sh-dma-engine", |
| 629 | .id = 3, |
| 630 | .resource = r8a7740_usb_dma_resources, |
| 631 | .num_resources = ARRAY_SIZE(r8a7740_usb_dma_resources), |
| 632 | .dev = { |
| 633 | .platform_data = &usb_dma_platform_data, |
| 634 | }, |
| 635 | }; |
| 636 | |
Kuninori Morimoto | 6831f3a | 2011-11-10 18:46:23 -0800 | [diff] [blame] | 637 | /* I2C */ |
| 638 | static struct resource i2c0_resources[] = { |
| 639 | [0] = { |
| 640 | .name = "IIC0", |
| 641 | .start = 0xfff20000, |
| 642 | .end = 0xfff20425 - 1, |
| 643 | .flags = IORESOURCE_MEM, |
| 644 | }, |
| 645 | [1] = { |
Kuninori Morimoto | 215d6cc | 2011-11-10 18:46:35 -0800 | [diff] [blame] | 646 | .start = intcs_evt2irq(0xe00), |
| 647 | .end = intcs_evt2irq(0xe60), |
Kuninori Morimoto | 6831f3a | 2011-11-10 18:46:23 -0800 | [diff] [blame] | 648 | .flags = IORESOURCE_IRQ, |
| 649 | }, |
| 650 | }; |
| 651 | |
| 652 | static struct resource i2c1_resources[] = { |
| 653 | [0] = { |
| 654 | .name = "IIC1", |
| 655 | .start = 0xe6c20000, |
| 656 | .end = 0xe6c20425 - 1, |
| 657 | .flags = IORESOURCE_MEM, |
| 658 | }, |
| 659 | [1] = { |
Kuninori Morimoto | 215d6cc | 2011-11-10 18:46:35 -0800 | [diff] [blame] | 660 | .start = evt2irq(0x780), /* IIC1_ALI1 */ |
| 661 | .end = evt2irq(0x7e0), /* IIC1_DTEI1 */ |
Kuninori Morimoto | 6831f3a | 2011-11-10 18:46:23 -0800 | [diff] [blame] | 662 | .flags = IORESOURCE_IRQ, |
| 663 | }, |
| 664 | }; |
| 665 | |
| 666 | static struct platform_device i2c0_device = { |
| 667 | .name = "i2c-sh_mobile", |
| 668 | .id = 0, |
| 669 | .resource = i2c0_resources, |
| 670 | .num_resources = ARRAY_SIZE(i2c0_resources), |
| 671 | }; |
| 672 | |
| 673 | static struct platform_device i2c1_device = { |
| 674 | .name = "i2c-sh_mobile", |
| 675 | .id = 1, |
| 676 | .resource = i2c1_resources, |
| 677 | .num_resources = ARRAY_SIZE(i2c1_resources), |
| 678 | }; |
| 679 | |
Nobuhiro Iwamatsu | 86bc52e | 2012-09-14 13:27:13 +0900 | [diff] [blame] | 680 | static struct resource pmu_resources[] = { |
| 681 | [0] = { |
| 682 | .start = evt2irq(0x19a0), |
| 683 | .end = evt2irq(0x19a0), |
| 684 | .flags = IORESOURCE_IRQ, |
| 685 | }, |
| 686 | }; |
| 687 | |
| 688 | static struct platform_device pmu_device = { |
| 689 | .name = "arm-pmu", |
| 690 | .id = -1, |
| 691 | .num_resources = ARRAY_SIZE(pmu_resources), |
| 692 | .resource = pmu_resources, |
| 693 | }; |
| 694 | |
Kuninori Morimoto | 6831f3a | 2011-11-10 18:46:23 -0800 | [diff] [blame] | 695 | static struct platform_device *r8a7740_late_devices[] __initdata = { |
| 696 | &i2c0_device, |
| 697 | &i2c1_device, |
Kuninori Morimoto | 643c330 | 2012-06-25 03:36:49 -0700 | [diff] [blame] | 698 | &dma0_device, |
| 699 | &dma1_device, |
| 700 | &dma2_device, |
Kuninori Morimoto | dbf382e | 2012-06-25 03:37:10 -0700 | [diff] [blame] | 701 | &usb_dma_device, |
Nobuhiro Iwamatsu | 86bc52e | 2012-09-14 13:27:13 +0900 | [diff] [blame] | 702 | &pmu_device, |
Kuninori Morimoto | 6831f3a | 2011-11-10 18:46:23 -0800 | [diff] [blame] | 703 | }; |
| 704 | |
Kuninori Morimoto | d49679e | 2012-06-12 02:36:21 -0700 | [diff] [blame] | 705 | /* |
| 706 | * r8a7740 chip has lasting errata on MERAM buffer. |
| 707 | * this is work-around for it. |
| 708 | * see |
| 709 | * "Media RAM (MERAM)" on r8a7740 documentation |
| 710 | */ |
| 711 | #define MEBUFCNTR 0xFE950098 |
| 712 | void r8a7740_meram_workaround(void) |
| 713 | { |
| 714 | void __iomem *reg; |
| 715 | |
| 716 | reg = ioremap_nocache(MEBUFCNTR, 4); |
| 717 | if (reg) { |
| 718 | iowrite32(0x01600164, reg); |
| 719 | iounmap(reg); |
| 720 | } |
| 721 | } |
| 722 | |
Kuninori Morimoto | 6831f3a | 2011-11-10 18:46:23 -0800 | [diff] [blame] | 723 | #define ICCR 0x0004 |
| 724 | #define ICSTART 0x0070 |
| 725 | |
| 726 | #define i2c_read(reg, offset) ioread8(reg + offset) |
| 727 | #define i2c_write(reg, offset, data) iowrite8(data, reg + offset) |
| 728 | |
| 729 | /* |
| 730 | * r8a7740 chip has lasting errata on I2C I/O pad reset. |
| 731 | * this is work-around for it. |
| 732 | */ |
| 733 | static void r8a7740_i2c_workaround(struct platform_device *pdev) |
| 734 | { |
| 735 | struct resource *res; |
| 736 | void __iomem *reg; |
| 737 | |
| 738 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 739 | if (unlikely(!res)) { |
| 740 | pr_err("r8a7740 i2c workaround fail (cannot find resource)\n"); |
| 741 | return; |
| 742 | } |
| 743 | |
| 744 | reg = ioremap(res->start, resource_size(res)); |
| 745 | if (unlikely(!reg)) { |
| 746 | pr_err("r8a7740 i2c workaround fail (cannot map IO)\n"); |
| 747 | return; |
| 748 | } |
| 749 | |
| 750 | i2c_write(reg, ICCR, i2c_read(reg, ICCR) | 0x80); |
| 751 | i2c_read(reg, ICCR); /* dummy read */ |
| 752 | |
| 753 | i2c_write(reg, ICSTART, i2c_read(reg, ICSTART) | 0x10); |
| 754 | i2c_read(reg, ICSTART); /* dummy read */ |
| 755 | |
Kuninori Morimoto | 4228716 | 2012-04-13 02:41:06 -0700 | [diff] [blame] | 756 | udelay(10); |
Kuninori Morimoto | 6831f3a | 2011-11-10 18:46:23 -0800 | [diff] [blame] | 757 | |
| 758 | i2c_write(reg, ICCR, 0x01); |
Kuninori Morimoto | 6831f3a | 2011-11-10 18:46:23 -0800 | [diff] [blame] | 759 | i2c_write(reg, ICSTART, 0x00); |
Kuninori Morimoto | 4228716 | 2012-04-13 02:41:06 -0700 | [diff] [blame] | 760 | |
| 761 | udelay(10); |
Kuninori Morimoto | 6831f3a | 2011-11-10 18:46:23 -0800 | [diff] [blame] | 762 | |
| 763 | i2c_write(reg, ICCR, 0x10); |
Kuninori Morimoto | 4228716 | 2012-04-13 02:41:06 -0700 | [diff] [blame] | 764 | udelay(10); |
Kuninori Morimoto | 6831f3a | 2011-11-10 18:46:23 -0800 | [diff] [blame] | 765 | i2c_write(reg, ICCR, 0x00); |
Kuninori Morimoto | 4228716 | 2012-04-13 02:41:06 -0700 | [diff] [blame] | 766 | udelay(10); |
Kuninori Morimoto | 6831f3a | 2011-11-10 18:46:23 -0800 | [diff] [blame] | 767 | i2c_write(reg, ICCR, 0x10); |
Kuninori Morimoto | 4228716 | 2012-04-13 02:41:06 -0700 | [diff] [blame] | 768 | udelay(10); |
Kuninori Morimoto | 6831f3a | 2011-11-10 18:46:23 -0800 | [diff] [blame] | 769 | |
| 770 | iounmap(reg); |
| 771 | } |
| 772 | |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 773 | void __init r8a7740_add_standard_devices(void) |
| 774 | { |
Kuninori Morimoto | 6831f3a | 2011-11-10 18:46:23 -0800 | [diff] [blame] | 775 | /* I2C work-around */ |
| 776 | r8a7740_i2c_workaround(&i2c0_device); |
| 777 | r8a7740_i2c_workaround(&i2c1_device); |
| 778 | |
Rafael J. Wysocki | 7b56740 | 2012-08-07 01:13:37 +0200 | [diff] [blame] | 779 | r8a7740_init_pm_domains(); |
Kuninori Morimoto | 8459293 | 2012-07-05 01:25:58 -0700 | [diff] [blame] | 780 | |
| 781 | /* add devices */ |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 782 | platform_add_devices(r8a7740_early_devices, |
| 783 | ARRAY_SIZE(r8a7740_early_devices)); |
Kuninori Morimoto | 6831f3a | 2011-11-10 18:46:23 -0800 | [diff] [blame] | 784 | platform_add_devices(r8a7740_late_devices, |
| 785 | ARRAY_SIZE(r8a7740_late_devices)); |
Kuninori Morimoto | 802a563 | 2012-07-05 01:26:31 -0700 | [diff] [blame] | 786 | |
| 787 | /* add devices to PM domain */ |
| 788 | |
Rafael J. Wysocki | 8bdd946 | 2012-08-07 01:07:01 +0200 | [diff] [blame] | 789 | rmobile_add_device_to_domain("A3SP", &scif0_device); |
| 790 | rmobile_add_device_to_domain("A3SP", &scif1_device); |
| 791 | rmobile_add_device_to_domain("A3SP", &scif2_device); |
| 792 | rmobile_add_device_to_domain("A3SP", &scif3_device); |
| 793 | rmobile_add_device_to_domain("A3SP", &scif4_device); |
| 794 | rmobile_add_device_to_domain("A3SP", &scif5_device); |
| 795 | rmobile_add_device_to_domain("A3SP", &scif6_device); |
| 796 | rmobile_add_device_to_domain("A3SP", &scif7_device); |
| 797 | rmobile_add_device_to_domain("A3SP", &scifb_device); |
| 798 | rmobile_add_device_to_domain("A3SP", &i2c1_device); |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 799 | } |
| 800 | |
| 801 | void __init r8a7740_add_early_devices(void) |
| 802 | { |
| 803 | early_platform_add_devices(r8a7740_early_devices, |
| 804 | ARRAY_SIZE(r8a7740_early_devices)); |
Magnus Damm | d3ab722 | 2012-02-29 21:37:35 +0900 | [diff] [blame] | 805 | |
| 806 | /* setup early console here as well */ |
| 807 | shmobile_setup_console(); |
Kuninori Morimoto | 6c01ba4 | 2011-11-10 18:45:52 -0800 | [diff] [blame] | 808 | } |
Magnus Damm | 755d57b | 2012-07-06 17:08:07 +0900 | [diff] [blame] | 809 | |
| 810 | #ifdef CONFIG_USE_OF |
| 811 | |
| 812 | void __init r8a7740_add_early_devices_dt(void) |
| 813 | { |
| 814 | shmobile_setup_delay(800, 1, 3); /* Cortex-A9 @ 800MHz */ |
| 815 | |
| 816 | early_platform_add_devices(r8a7740_early_devices, |
| 817 | ARRAY_SIZE(r8a7740_early_devices)); |
| 818 | |
| 819 | /* setup early console here as well */ |
| 820 | shmobile_setup_console(); |
| 821 | } |
| 822 | |
| 823 | static const struct of_dev_auxdata r8a7740_auxdata_lookup[] __initconst = { |
| 824 | { } |
| 825 | }; |
| 826 | |
| 827 | void __init r8a7740_add_standard_devices_dt(void) |
| 828 | { |
| 829 | /* clocks are setup late during boot in the case of DT */ |
| 830 | r8a7740_clock_init(0); |
| 831 | |
| 832 | platform_add_devices(r8a7740_early_devices, |
| 833 | ARRAY_SIZE(r8a7740_early_devices)); |
| 834 | |
| 835 | of_platform_populate(NULL, of_default_bus_match_table, |
| 836 | r8a7740_auxdata_lookup, NULL); |
| 837 | } |
| 838 | |
| 839 | static const char *r8a7740_boards_compat_dt[] __initdata = { |
| 840 | "renesas,r8a7740", |
| 841 | NULL, |
| 842 | }; |
| 843 | |
Kuninori Morimoto | a41acc4 | 2012-10-21 22:15:13 -0700 | [diff] [blame] | 844 | DT_MACHINE_START(R8A7740_DT, "Generic R8A7740 (Flattened Device Tree)") |
Magnus Damm | 755d57b | 2012-07-06 17:08:07 +0900 | [diff] [blame] | 845 | .map_io = r8a7740_map_io, |
| 846 | .init_early = r8a7740_add_early_devices_dt, |
| 847 | .init_irq = r8a7740_init_irq, |
| 848 | .handle_irq = shmobile_handle_irq_intc, |
| 849 | .init_machine = r8a7740_add_standard_devices_dt, |
Stephen Warren | 6bb27d7 | 2012-11-08 12:40:59 -0700 | [diff] [blame] | 850 | .init_time = shmobile_timer_init, |
Magnus Damm | 755d57b | 2012-07-06 17:08:07 +0900 | [diff] [blame] | 851 | .dt_compat = r8a7740_boards_compat_dt, |
| 852 | MACHINE_END |
| 853 | |
| 854 | #endif /* CONFIG_USE_OF */ |