Magnus Damm | c793c1b | 2010-02-05 11:14:49 +0000 | [diff] [blame] | 1 | /* |
| 2 | * sh7367 processor support |
| 3 | * |
| 4 | * Copyright (C) 2010 Magnus Damm |
| 5 | * Copyright (C) 2008 Yoshihiro Shimoda |
| 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 | */ |
| 20 | #include <linux/kernel.h> |
| 21 | #include <linux/init.h> |
| 22 | #include <linux/interrupt.h> |
| 23 | #include <linux/irq.h> |
| 24 | #include <linux/platform_device.h> |
Magnus Damm | de32835 | 2011-04-28 03:16:32 +0000 | [diff] [blame] | 25 | #include <linux/uio_driver.h> |
Magnus Damm | c793c1b | 2010-02-05 11:14:49 +0000 | [diff] [blame] | 26 | #include <linux/delay.h> |
| 27 | #include <linux/input.h> |
| 28 | #include <linux/io.h> |
| 29 | #include <linux/serial_sci.h> |
Magnus Damm | c793c1b | 2010-02-05 11:14:49 +0000 | [diff] [blame] | 30 | #include <linux/sh_timer.h> |
| 31 | #include <mach/hardware.h> |
Rob Herring | 250a272 | 2012-01-03 16:57:33 -0600 | [diff] [blame^] | 32 | #include <mach/irqs.h> |
Magnus Damm | c793c1b | 2010-02-05 11:14:49 +0000 | [diff] [blame] | 33 | #include <asm/mach-types.h> |
| 34 | #include <asm/mach/arch.h> |
| 35 | |
Magnus Damm | 7490509 | 2010-05-20 14:35:30 +0000 | [diff] [blame] | 36 | /* SCIFA0 */ |
Magnus Damm | c793c1b | 2010-02-05 11:14:49 +0000 | [diff] [blame] | 37 | static struct plat_sci_port scif0_platform_data = { |
| 38 | .mapbase = 0xe6c40000, |
| 39 | .flags = UPF_BOOT_AUTOCONF, |
Paul Mundt | f43dc23 | 2011-01-13 15:06:28 +0900 | [diff] [blame] | 40 | .scscr = SCSCR_RE | SCSCR_TE, |
| 41 | .scbrr_algo_id = SCBRR_ALGO_4, |
Paul Mundt | 3110572 | 2011-06-14 15:07:06 +0900 | [diff] [blame] | 42 | .type = PORT_SCIFA, |
Magnus Damm | 7490509 | 2010-05-20 14:35:30 +0000 | [diff] [blame] | 43 | .irqs = { evt2irq(0xc00), evt2irq(0xc00), |
| 44 | evt2irq(0xc00), evt2irq(0xc00) }, |
Magnus Damm | c793c1b | 2010-02-05 11:14:49 +0000 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | static struct platform_device scif0_device = { |
| 48 | .name = "sh-sci", |
| 49 | .id = 0, |
| 50 | .dev = { |
| 51 | .platform_data = &scif0_platform_data, |
| 52 | }, |
| 53 | }; |
| 54 | |
Magnus Damm | 7490509 | 2010-05-20 14:35:30 +0000 | [diff] [blame] | 55 | /* SCIFA1 */ |
Magnus Damm | c793c1b | 2010-02-05 11:14:49 +0000 | [diff] [blame] | 56 | static struct plat_sci_port scif1_platform_data = { |
| 57 | .mapbase = 0xe6c50000, |
| 58 | .flags = UPF_BOOT_AUTOCONF, |
Paul Mundt | f43dc23 | 2011-01-13 15:06:28 +0900 | [diff] [blame] | 59 | .scscr = SCSCR_RE | SCSCR_TE, |
| 60 | .scbrr_algo_id = SCBRR_ALGO_4, |
Paul Mundt | 3110572 | 2011-06-14 15:07:06 +0900 | [diff] [blame] | 61 | .type = PORT_SCIFA, |
Magnus Damm | 7490509 | 2010-05-20 14:35:30 +0000 | [diff] [blame] | 62 | .irqs = { evt2irq(0xc20), evt2irq(0xc20), |
| 63 | evt2irq(0xc20), evt2irq(0xc20) }, |
Magnus Damm | c793c1b | 2010-02-05 11:14:49 +0000 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | static struct platform_device scif1_device = { |
| 67 | .name = "sh-sci", |
| 68 | .id = 1, |
| 69 | .dev = { |
| 70 | .platform_data = &scif1_platform_data, |
| 71 | }, |
| 72 | }; |
| 73 | |
Magnus Damm | 7490509 | 2010-05-20 14:35:30 +0000 | [diff] [blame] | 74 | /* SCIFA2 */ |
Magnus Damm | c793c1b | 2010-02-05 11:14:49 +0000 | [diff] [blame] | 75 | static struct plat_sci_port scif2_platform_data = { |
| 76 | .mapbase = 0xe6c60000, |
| 77 | .flags = UPF_BOOT_AUTOCONF, |
Paul Mundt | f43dc23 | 2011-01-13 15:06:28 +0900 | [diff] [blame] | 78 | .scscr = SCSCR_RE | SCSCR_TE, |
| 79 | .scbrr_algo_id = SCBRR_ALGO_4, |
Paul Mundt | 3110572 | 2011-06-14 15:07:06 +0900 | [diff] [blame] | 80 | .type = PORT_SCIFA, |
Magnus Damm | 7490509 | 2010-05-20 14:35:30 +0000 | [diff] [blame] | 81 | .irqs = { evt2irq(0xc40), evt2irq(0xc40), |
| 82 | evt2irq(0xc40), evt2irq(0xc40) }, |
Magnus Damm | c793c1b | 2010-02-05 11:14:49 +0000 | [diff] [blame] | 83 | }; |
| 84 | |
| 85 | static struct platform_device scif2_device = { |
| 86 | .name = "sh-sci", |
| 87 | .id = 2, |
| 88 | .dev = { |
| 89 | .platform_data = &scif2_platform_data, |
| 90 | }, |
| 91 | }; |
| 92 | |
Magnus Damm | 7490509 | 2010-05-20 14:35:30 +0000 | [diff] [blame] | 93 | /* SCIFA3 */ |
Magnus Damm | c793c1b | 2010-02-05 11:14:49 +0000 | [diff] [blame] | 94 | static struct plat_sci_port scif3_platform_data = { |
| 95 | .mapbase = 0xe6c70000, |
| 96 | .flags = UPF_BOOT_AUTOCONF, |
Paul Mundt | f43dc23 | 2011-01-13 15:06:28 +0900 | [diff] [blame] | 97 | .scscr = SCSCR_RE | SCSCR_TE, |
| 98 | .scbrr_algo_id = SCBRR_ALGO_4, |
Paul Mundt | 3110572 | 2011-06-14 15:07:06 +0900 | [diff] [blame] | 99 | .type = PORT_SCIFA, |
Magnus Damm | 7490509 | 2010-05-20 14:35:30 +0000 | [diff] [blame] | 100 | .irqs = { evt2irq(0xc60), evt2irq(0xc60), |
| 101 | evt2irq(0xc60), evt2irq(0xc60) }, |
Magnus Damm | c793c1b | 2010-02-05 11:14:49 +0000 | [diff] [blame] | 102 | }; |
| 103 | |
| 104 | static struct platform_device scif3_device = { |
| 105 | .name = "sh-sci", |
| 106 | .id = 3, |
| 107 | .dev = { |
| 108 | .platform_data = &scif3_platform_data, |
| 109 | }, |
| 110 | }; |
| 111 | |
Magnus Damm | 7490509 | 2010-05-20 14:35:30 +0000 | [diff] [blame] | 112 | /* SCIFA4 */ |
Magnus Damm | c793c1b | 2010-02-05 11:14:49 +0000 | [diff] [blame] | 113 | static struct plat_sci_port scif4_platform_data = { |
| 114 | .mapbase = 0xe6c80000, |
| 115 | .flags = UPF_BOOT_AUTOCONF, |
Paul Mundt | f43dc23 | 2011-01-13 15:06:28 +0900 | [diff] [blame] | 116 | .scscr = SCSCR_RE | SCSCR_TE, |
| 117 | .scbrr_algo_id = SCBRR_ALGO_4, |
Paul Mundt | 3110572 | 2011-06-14 15:07:06 +0900 | [diff] [blame] | 118 | .type = PORT_SCIFA, |
Magnus Damm | 7490509 | 2010-05-20 14:35:30 +0000 | [diff] [blame] | 119 | .irqs = { evt2irq(0xd20), evt2irq(0xd20), |
| 120 | evt2irq(0xd20), evt2irq(0xd20) }, |
Magnus Damm | c793c1b | 2010-02-05 11:14:49 +0000 | [diff] [blame] | 121 | }; |
| 122 | |
| 123 | static struct platform_device scif4_device = { |
| 124 | .name = "sh-sci", |
| 125 | .id = 4, |
| 126 | .dev = { |
| 127 | .platform_data = &scif4_platform_data, |
| 128 | }, |
| 129 | }; |
| 130 | |
Magnus Damm | 7490509 | 2010-05-20 14:35:30 +0000 | [diff] [blame] | 131 | /* SCIFA5 */ |
Magnus Damm | c793c1b | 2010-02-05 11:14:49 +0000 | [diff] [blame] | 132 | static struct plat_sci_port scif5_platform_data = { |
| 133 | .mapbase = 0xe6cb0000, |
| 134 | .flags = UPF_BOOT_AUTOCONF, |
Paul Mundt | f43dc23 | 2011-01-13 15:06:28 +0900 | [diff] [blame] | 135 | .scscr = SCSCR_RE | SCSCR_TE, |
| 136 | .scbrr_algo_id = SCBRR_ALGO_4, |
Paul Mundt | 3110572 | 2011-06-14 15:07:06 +0900 | [diff] [blame] | 137 | .type = PORT_SCIFA, |
Magnus Damm | 7490509 | 2010-05-20 14:35:30 +0000 | [diff] [blame] | 138 | .irqs = { evt2irq(0xd40), evt2irq(0xd40), |
| 139 | evt2irq(0xd40), evt2irq(0xd40) }, |
Magnus Damm | c793c1b | 2010-02-05 11:14:49 +0000 | [diff] [blame] | 140 | }; |
| 141 | |
| 142 | static struct platform_device scif5_device = { |
| 143 | .name = "sh-sci", |
| 144 | .id = 5, |
| 145 | .dev = { |
| 146 | .platform_data = &scif5_platform_data, |
| 147 | }, |
| 148 | }; |
| 149 | |
Magnus Damm | 7490509 | 2010-05-20 14:35:30 +0000 | [diff] [blame] | 150 | /* SCIFB */ |
Magnus Damm | c793c1b | 2010-02-05 11:14:49 +0000 | [diff] [blame] | 151 | static struct plat_sci_port scif6_platform_data = { |
| 152 | .mapbase = 0xe6c30000, |
| 153 | .flags = UPF_BOOT_AUTOCONF, |
Paul Mundt | f43dc23 | 2011-01-13 15:06:28 +0900 | [diff] [blame] | 154 | .scscr = SCSCR_RE | SCSCR_TE, |
| 155 | .scbrr_algo_id = SCBRR_ALGO_4, |
Paul Mundt | 3110572 | 2011-06-14 15:07:06 +0900 | [diff] [blame] | 156 | .type = PORT_SCIFB, |
Magnus Damm | 7490509 | 2010-05-20 14:35:30 +0000 | [diff] [blame] | 157 | .irqs = { evt2irq(0xd60), evt2irq(0xd60), |
| 158 | evt2irq(0xd60), evt2irq(0xd60) }, |
Magnus Damm | c793c1b | 2010-02-05 11:14:49 +0000 | [diff] [blame] | 159 | }; |
| 160 | |
| 161 | static struct platform_device scif6_device = { |
| 162 | .name = "sh-sci", |
| 163 | .id = 6, |
| 164 | .dev = { |
| 165 | .platform_data = &scif6_platform_data, |
| 166 | }, |
| 167 | }; |
| 168 | |
| 169 | static struct sh_timer_config cmt10_platform_data = { |
| 170 | .name = "CMT10", |
| 171 | .channel_offset = 0x10, |
| 172 | .timer_bit = 0, |
Magnus Damm | c793c1b | 2010-02-05 11:14:49 +0000 | [diff] [blame] | 173 | .clockevent_rating = 125, |
| 174 | .clocksource_rating = 125, |
| 175 | }; |
| 176 | |
| 177 | static struct resource cmt10_resources[] = { |
| 178 | [0] = { |
| 179 | .name = "CMT10", |
| 180 | .start = 0xe6138010, |
| 181 | .end = 0xe613801b, |
| 182 | .flags = IORESOURCE_MEM, |
| 183 | }, |
| 184 | [1] = { |
Magnus Damm | 7490509 | 2010-05-20 14:35:30 +0000 | [diff] [blame] | 185 | .start = evt2irq(0xb00), /* CMT1_CMT10 */ |
Magnus Damm | c793c1b | 2010-02-05 11:14:49 +0000 | [diff] [blame] | 186 | .flags = IORESOURCE_IRQ, |
| 187 | }, |
| 188 | }; |
| 189 | |
| 190 | static struct platform_device cmt10_device = { |
| 191 | .name = "sh_cmt", |
| 192 | .id = 10, |
| 193 | .dev = { |
| 194 | .platform_data = &cmt10_platform_data, |
| 195 | }, |
| 196 | .resource = cmt10_resources, |
| 197 | .num_resources = ARRAY_SIZE(cmt10_resources), |
| 198 | }; |
| 199 | |
Magnus Damm | de32835 | 2011-04-28 03:16:32 +0000 | [diff] [blame] | 200 | /* VPU */ |
| 201 | static struct uio_info vpu_platform_data = { |
| 202 | .name = "VPU5", |
| 203 | .version = "0", |
| 204 | .irq = intcs_evt2irq(0x980), |
| 205 | }; |
| 206 | |
| 207 | static struct resource vpu_resources[] = { |
| 208 | [0] = { |
| 209 | .name = "VPU", |
| 210 | .start = 0xfe900000, |
| 211 | .end = 0xfe902807, |
| 212 | .flags = IORESOURCE_MEM, |
| 213 | }, |
| 214 | }; |
| 215 | |
| 216 | static struct platform_device vpu_device = { |
| 217 | .name = "uio_pdrv_genirq", |
| 218 | .id = 0, |
| 219 | .dev = { |
| 220 | .platform_data = &vpu_platform_data, |
| 221 | }, |
| 222 | .resource = vpu_resources, |
| 223 | .num_resources = ARRAY_SIZE(vpu_resources), |
| 224 | }; |
| 225 | |
| 226 | /* VEU0 */ |
| 227 | static struct uio_info veu0_platform_data = { |
| 228 | .name = "VEU0", |
| 229 | .version = "0", |
| 230 | .irq = intcs_evt2irq(0x700), |
| 231 | }; |
| 232 | |
| 233 | static struct resource veu0_resources[] = { |
| 234 | [0] = { |
| 235 | .name = "VEU0", |
| 236 | .start = 0xfe920000, |
| 237 | .end = 0xfe9200b7, |
| 238 | .flags = IORESOURCE_MEM, |
| 239 | }, |
| 240 | }; |
| 241 | |
| 242 | static struct platform_device veu0_device = { |
| 243 | .name = "uio_pdrv_genirq", |
| 244 | .id = 1, |
| 245 | .dev = { |
| 246 | .platform_data = &veu0_platform_data, |
| 247 | }, |
| 248 | .resource = veu0_resources, |
| 249 | .num_resources = ARRAY_SIZE(veu0_resources), |
| 250 | }; |
| 251 | |
| 252 | /* VEU1 */ |
| 253 | static struct uio_info veu1_platform_data = { |
| 254 | .name = "VEU1", |
| 255 | .version = "0", |
| 256 | .irq = intcs_evt2irq(0x720), |
| 257 | }; |
| 258 | |
| 259 | static struct resource veu1_resources[] = { |
| 260 | [0] = { |
| 261 | .name = "VEU1", |
| 262 | .start = 0xfe924000, |
| 263 | .end = 0xfe9240b7, |
| 264 | .flags = IORESOURCE_MEM, |
| 265 | }, |
| 266 | }; |
| 267 | |
| 268 | static struct platform_device veu1_device = { |
| 269 | .name = "uio_pdrv_genirq", |
| 270 | .id = 2, |
| 271 | .dev = { |
| 272 | .platform_data = &veu1_platform_data, |
| 273 | }, |
| 274 | .resource = veu1_resources, |
| 275 | .num_resources = ARRAY_SIZE(veu1_resources), |
| 276 | }; |
| 277 | |
| 278 | /* VEU2 */ |
| 279 | static struct uio_info veu2_platform_data = { |
| 280 | .name = "VEU2", |
| 281 | .version = "0", |
| 282 | .irq = intcs_evt2irq(0x740), |
| 283 | }; |
| 284 | |
| 285 | static struct resource veu2_resources[] = { |
| 286 | [0] = { |
| 287 | .name = "VEU2", |
| 288 | .start = 0xfe928000, |
| 289 | .end = 0xfe9280b7, |
| 290 | .flags = IORESOURCE_MEM, |
| 291 | }, |
| 292 | }; |
| 293 | |
| 294 | static struct platform_device veu2_device = { |
| 295 | .name = "uio_pdrv_genirq", |
| 296 | .id = 3, |
| 297 | .dev = { |
| 298 | .platform_data = &veu2_platform_data, |
| 299 | }, |
| 300 | .resource = veu2_resources, |
| 301 | .num_resources = ARRAY_SIZE(veu2_resources), |
| 302 | }; |
| 303 | |
| 304 | /* VEU3 */ |
| 305 | static struct uio_info veu3_platform_data = { |
| 306 | .name = "VEU3", |
| 307 | .version = "0", |
| 308 | .irq = intcs_evt2irq(0x760), |
| 309 | }; |
| 310 | |
| 311 | static struct resource veu3_resources[] = { |
| 312 | [0] = { |
| 313 | .name = "VEU3", |
| 314 | .start = 0xfe92c000, |
| 315 | .end = 0xfe92c0b7, |
| 316 | .flags = IORESOURCE_MEM, |
| 317 | }, |
| 318 | }; |
| 319 | |
| 320 | static struct platform_device veu3_device = { |
| 321 | .name = "uio_pdrv_genirq", |
| 322 | .id = 4, |
| 323 | .dev = { |
| 324 | .platform_data = &veu3_platform_data, |
| 325 | }, |
| 326 | .resource = veu3_resources, |
| 327 | .num_resources = ARRAY_SIZE(veu3_resources), |
| 328 | }; |
| 329 | |
| 330 | /* VEU2H */ |
| 331 | static struct uio_info veu2h_platform_data = { |
| 332 | .name = "VEU2H", |
| 333 | .version = "0", |
| 334 | .irq = intcs_evt2irq(0x520), |
| 335 | }; |
| 336 | |
| 337 | static struct resource veu2h_resources[] = { |
| 338 | [0] = { |
| 339 | .name = "VEU2H", |
| 340 | .start = 0xfe93c000, |
| 341 | .end = 0xfe93c27b, |
| 342 | .flags = IORESOURCE_MEM, |
| 343 | }, |
| 344 | }; |
| 345 | |
| 346 | static struct platform_device veu2h_device = { |
| 347 | .name = "uio_pdrv_genirq", |
| 348 | .id = 5, |
| 349 | .dev = { |
| 350 | .platform_data = &veu2h_platform_data, |
| 351 | }, |
| 352 | .resource = veu2h_resources, |
| 353 | .num_resources = ARRAY_SIZE(veu2h_resources), |
| 354 | }; |
| 355 | |
| 356 | /* JPU */ |
| 357 | static struct uio_info jpu_platform_data = { |
| 358 | .name = "JPU", |
| 359 | .version = "0", |
| 360 | .irq = intcs_evt2irq(0x560), |
| 361 | }; |
| 362 | |
| 363 | static struct resource jpu_resources[] = { |
| 364 | [0] = { |
| 365 | .name = "JPU", |
| 366 | .start = 0xfe980000, |
| 367 | .end = 0xfe9902d3, |
| 368 | .flags = IORESOURCE_MEM, |
| 369 | }, |
| 370 | }; |
| 371 | |
| 372 | static struct platform_device jpu_device = { |
| 373 | .name = "uio_pdrv_genirq", |
| 374 | .id = 6, |
| 375 | .dev = { |
| 376 | .platform_data = &jpu_platform_data, |
| 377 | }, |
| 378 | .resource = jpu_resources, |
| 379 | .num_resources = ARRAY_SIZE(jpu_resources), |
| 380 | }; |
| 381 | |
| 382 | /* SPU1 */ |
| 383 | static struct uio_info spu1_platform_data = { |
| 384 | .name = "SPU1", |
| 385 | .version = "0", |
| 386 | .irq = evt2irq(0xfc0), |
| 387 | }; |
| 388 | |
| 389 | static struct resource spu1_resources[] = { |
| 390 | [0] = { |
| 391 | .name = "SPU1", |
| 392 | .start = 0xfe300000, |
| 393 | .end = 0xfe3fffff, |
| 394 | .flags = IORESOURCE_MEM, |
| 395 | }, |
| 396 | }; |
| 397 | |
| 398 | static struct platform_device spu1_device = { |
| 399 | .name = "uio_pdrv_genirq", |
| 400 | .id = 7, |
| 401 | .dev = { |
| 402 | .platform_data = &spu1_platform_data, |
| 403 | }, |
| 404 | .resource = spu1_resources, |
| 405 | .num_resources = ARRAY_SIZE(spu1_resources), |
| 406 | }; |
| 407 | |
Magnus Damm | c793c1b | 2010-02-05 11:14:49 +0000 | [diff] [blame] | 408 | static struct platform_device *sh7367_early_devices[] __initdata = { |
| 409 | &scif0_device, |
| 410 | &scif1_device, |
| 411 | &scif2_device, |
| 412 | &scif3_device, |
| 413 | &scif4_device, |
| 414 | &scif5_device, |
| 415 | &scif6_device, |
| 416 | &cmt10_device, |
| 417 | }; |
| 418 | |
Magnus Damm | de32835 | 2011-04-28 03:16:32 +0000 | [diff] [blame] | 419 | static struct platform_device *sh7367_devices[] __initdata = { |
| 420 | &vpu_device, |
| 421 | &veu0_device, |
| 422 | &veu1_device, |
| 423 | &veu2_device, |
| 424 | &veu3_device, |
| 425 | &veu2h_device, |
| 426 | &jpu_device, |
| 427 | &spu1_device, |
| 428 | }; |
| 429 | |
Magnus Damm | c793c1b | 2010-02-05 11:14:49 +0000 | [diff] [blame] | 430 | void __init sh7367_add_standard_devices(void) |
| 431 | { |
| 432 | platform_add_devices(sh7367_early_devices, |
| 433 | ARRAY_SIZE(sh7367_early_devices)); |
Magnus Damm | de32835 | 2011-04-28 03:16:32 +0000 | [diff] [blame] | 434 | |
| 435 | platform_add_devices(sh7367_devices, |
| 436 | ARRAY_SIZE(sh7367_devices)); |
Magnus Damm | c793c1b | 2010-02-05 11:14:49 +0000 | [diff] [blame] | 437 | } |
| 438 | |
| 439 | #define SYMSTPCR2 0xe6158048 |
| 440 | #define SYMSTPCR2_CMT1 (1 << 29) |
| 441 | |
| 442 | void __init sh7367_add_early_devices(void) |
| 443 | { |
| 444 | /* enable clock to CMT1 */ |
| 445 | __raw_writel(__raw_readl(SYMSTPCR2) & ~SYMSTPCR2_CMT1, SYMSTPCR2); |
| 446 | |
| 447 | early_platform_add_devices(sh7367_early_devices, |
| 448 | ARRAY_SIZE(sh7367_early_devices)); |
| 449 | } |