Mark A. Greer | 55c79a4 | 2009-06-03 18:36:54 -0700 | [diff] [blame] | 1 | /* |
| 2 | * DA8XX/OMAP L1XX platform device data |
| 3 | * |
| 4 | * Copyright (c) 2007-2009, MontaVista Software, Inc. <source@mvista.com> |
| 5 | * Derived from code that was: |
| 6 | * Copyright (C) 2006 Komal Shah <komal_shah802003@yahoo.com> |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | */ |
Mark A. Greer | 55c79a4 | 2009-06-03 18:36:54 -0700 | [diff] [blame] | 13 | #include <linux/init.h> |
| 14 | #include <linux/platform_device.h> |
| 15 | #include <linux/dma-mapping.h> |
| 16 | #include <linux/serial_8250.h> |
Sekhar Nori | cbb2c96 | 2011-07-06 06:01:23 +0000 | [diff] [blame] | 17 | #include <linux/ahci_platform.h> |
| 18 | #include <linux/clk.h> |
Mark A. Greer | 55c79a4 | 2009-06-03 18:36:54 -0700 | [diff] [blame] | 19 | |
| 20 | #include <mach/cputype.h> |
| 21 | #include <mach/common.h> |
| 22 | #include <mach/time.h> |
| 23 | #include <mach/da8xx.h> |
Sekhar Nori | 1960e69 | 2009-10-22 15:12:14 +0530 | [diff] [blame] | 24 | #include <mach/cpuidle.h> |
Mark A. Greer | 55c79a4 | 2009-06-03 18:36:54 -0700 | [diff] [blame] | 25 | |
| 26 | #include "clock.h" |
Hebbar, Gururaja | 896f66b | 2012-08-27 18:56:41 +0530 | [diff] [blame] | 27 | #include "asp.h" |
Mark A. Greer | 55c79a4 | 2009-06-03 18:36:54 -0700 | [diff] [blame] | 28 | |
| 29 | #define DA8XX_TPCC_BASE 0x01c00000 |
| 30 | #define DA8XX_TPTC0_BASE 0x01c08000 |
| 31 | #define DA8XX_TPTC1_BASE 0x01c08400 |
| 32 | #define DA8XX_WDOG_BASE 0x01c21000 /* DA8XX_TIMER64P1_BASE */ |
| 33 | #define DA8XX_I2C0_BASE 0x01c22000 |
Sergei Shtylyov | 8ac764e | 2011-04-06 17:29:24 +0000 | [diff] [blame] | 34 | #define DA8XX_RTC_BASE 0x01c23000 |
| 35 | #define DA8XX_MMCSD0_BASE 0x01c40000 |
| 36 | #define DA8XX_SPI0_BASE 0x01c41000 |
| 37 | #define DA830_SPI1_BASE 0x01e12000 |
| 38 | #define DA8XX_LCD_CNTRL_BASE 0x01e13000 |
Sekhar Nori | cbb2c96 | 2011-07-06 06:01:23 +0000 | [diff] [blame] | 39 | #define DA850_SATA_BASE 0x01e18000 |
Sergei Shtylyov | 8ac764e | 2011-04-06 17:29:24 +0000 | [diff] [blame] | 40 | #define DA850_MMCSD1_BASE 0x01e1b000 |
Mark A. Greer | 55c79a4 | 2009-06-03 18:36:54 -0700 | [diff] [blame] | 41 | #define DA8XX_EMAC_CPPI_PORT_BASE 0x01e20000 |
| 42 | #define DA8XX_EMAC_CPGMACSS_BASE 0x01e22000 |
| 43 | #define DA8XX_EMAC_CPGMAC_BASE 0x01e23000 |
| 44 | #define DA8XX_EMAC_MDIO_BASE 0x01e24000 |
Mark A. Greer | 55c79a4 | 2009-06-03 18:36:54 -0700 | [diff] [blame] | 45 | #define DA8XX_I2C1_BASE 0x01e28000 |
Sergei Shtylyov | 8ac764e | 2011-04-06 17:29:24 +0000 | [diff] [blame] | 46 | #define DA850_TPCC1_BASE 0x01e30000 |
| 47 | #define DA850_TPTC2_BASE 0x01e38000 |
Sergei Shtylyov | 9e7d24f | 2011-04-06 17:17:21 +0000 | [diff] [blame] | 48 | #define DA850_SPI1_BASE 0x01f0e000 |
Sergei Shtylyov | 8ac764e | 2011-04-06 17:29:24 +0000 | [diff] [blame] | 49 | #define DA8XX_DDR2_CTL_BASE 0xb0000000 |
Mark A. Greer | 55c79a4 | 2009-06-03 18:36:54 -0700 | [diff] [blame] | 50 | |
| 51 | #define DA8XX_EMAC_CTRL_REG_OFFSET 0x3000 |
| 52 | #define DA8XX_EMAC_MOD_REG_OFFSET 0x2000 |
| 53 | #define DA8XX_EMAC_RAM_OFFSET 0x0000 |
Mark A. Greer | 55c79a4 | 2009-06-03 18:36:54 -0700 | [diff] [blame] | 54 | #define DA8XX_EMAC_CTRL_RAM_SIZE SZ_8K |
| 55 | |
Michael Williamson | 54ce688 | 2011-02-24 10:18:28 +0530 | [diff] [blame] | 56 | #define DA8XX_DMA_SPI0_RX EDMA_CTLR_CHAN(0, 14) |
| 57 | #define DA8XX_DMA_SPI0_TX EDMA_CTLR_CHAN(0, 15) |
Michael Williamson | e38c2b2 | 2011-02-22 13:36:57 +0000 | [diff] [blame] | 58 | #define DA8XX_DMA_MMCSD0_RX EDMA_CTLR_CHAN(0, 16) |
| 59 | #define DA8XX_DMA_MMCSD0_TX EDMA_CTLR_CHAN(0, 17) |
Michael Williamson | 54ce688 | 2011-02-24 10:18:28 +0530 | [diff] [blame] | 60 | #define DA8XX_DMA_SPI1_RX EDMA_CTLR_CHAN(0, 18) |
| 61 | #define DA8XX_DMA_SPI1_TX EDMA_CTLR_CHAN(0, 19) |
Michael Williamson | e38c2b2 | 2011-02-22 13:36:57 +0000 | [diff] [blame] | 62 | #define DA850_DMA_MMCSD1_RX EDMA_CTLR_CHAN(1, 28) |
| 63 | #define DA850_DMA_MMCSD1_TX EDMA_CTLR_CHAN(1, 29) |
| 64 | |
Sekhar Nori | d2de058 | 2009-11-16 17:21:32 +0530 | [diff] [blame] | 65 | void __iomem *da8xx_syscfg0_base; |
| 66 | void __iomem *da8xx_syscfg1_base; |
Sekhar Nori | 6a28adef | 2009-08-31 15:47:59 +0530 | [diff] [blame] | 67 | |
Mark A. Greer | 55c79a4 | 2009-06-03 18:36:54 -0700 | [diff] [blame] | 68 | static struct plat_serial8250_port da8xx_serial_pdata[] = { |
| 69 | { |
| 70 | .mapbase = DA8XX_UART0_BASE, |
| 71 | .irq = IRQ_DA8XX_UARTINT0, |
| 72 | .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | |
| 73 | UPF_IOREMAP, |
| 74 | .iotype = UPIO_MEM, |
| 75 | .regshift = 2, |
| 76 | }, |
| 77 | { |
| 78 | .mapbase = DA8XX_UART1_BASE, |
| 79 | .irq = IRQ_DA8XX_UARTINT1, |
| 80 | .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | |
| 81 | UPF_IOREMAP, |
| 82 | .iotype = UPIO_MEM, |
| 83 | .regshift = 2, |
| 84 | }, |
| 85 | { |
| 86 | .mapbase = DA8XX_UART2_BASE, |
| 87 | .irq = IRQ_DA8XX_UARTINT2, |
| 88 | .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | |
| 89 | UPF_IOREMAP, |
| 90 | .iotype = UPIO_MEM, |
| 91 | .regshift = 2, |
| 92 | }, |
| 93 | { |
| 94 | .flags = 0, |
| 95 | }, |
| 96 | }; |
| 97 | |
| 98 | struct platform_device da8xx_serial_device = { |
| 99 | .name = "serial8250", |
| 100 | .id = PLAT8250_DEV_PLATFORM, |
| 101 | .dev = { |
| 102 | .platform_data = da8xx_serial_pdata, |
| 103 | }, |
| 104 | }; |
| 105 | |
Mark A. Greer | 55c79a4 | 2009-06-03 18:36:54 -0700 | [diff] [blame] | 106 | static const s8 da8xx_queue_tc_mapping[][2] = { |
| 107 | /* {event queue no, TC no} */ |
| 108 | {0, 0}, |
| 109 | {1, 1}, |
| 110 | {-1, -1} |
| 111 | }; |
| 112 | |
| 113 | static const s8 da8xx_queue_priority_mapping[][2] = { |
| 114 | /* {event queue no, Priority} */ |
| 115 | {0, 3}, |
| 116 | {1, 7}, |
| 117 | {-1, -1} |
| 118 | }; |
| 119 | |
Sudhakar Rajashekhara | 3f995f2 | 2010-01-06 17:30:06 +0530 | [diff] [blame] | 120 | static const s8 da850_queue_tc_mapping[][2] = { |
| 121 | /* {event queue no, TC no} */ |
| 122 | {0, 0}, |
| 123 | {-1, -1} |
| 124 | }; |
| 125 | |
| 126 | static const s8 da850_queue_priority_mapping[][2] = { |
| 127 | /* {event queue no, Priority} */ |
| 128 | {0, 3}, |
| 129 | {-1, -1} |
| 130 | }; |
| 131 | |
Sekhar Nori | bc3ac9f | 2010-06-29 11:35:12 +0530 | [diff] [blame] | 132 | static struct edma_soc_info da830_edma_cc0_info = { |
| 133 | .n_channel = 32, |
| 134 | .n_region = 4, |
| 135 | .n_slot = 128, |
| 136 | .n_tc = 2, |
| 137 | .n_cc = 1, |
| 138 | .queue_tc_mapping = da8xx_queue_tc_mapping, |
| 139 | .queue_priority_mapping = da8xx_queue_priority_mapping, |
Ido Yariv | f23fe85 | 2011-07-10 16:14:35 +0300 | [diff] [blame] | 140 | .default_queue = EVENTQ_1, |
Mark A. Greer | 55c79a4 | 2009-06-03 18:36:54 -0700 | [diff] [blame] | 141 | }; |
| 142 | |
Sekhar Nori | bc3ac9f | 2010-06-29 11:35:12 +0530 | [diff] [blame] | 143 | static struct edma_soc_info *da830_edma_info[EDMA_MAX_CC] = { |
| 144 | &da830_edma_cc0_info, |
| 145 | }; |
| 146 | |
| 147 | static struct edma_soc_info da850_edma_cc_info[] = { |
Sudhakar Rajashekhara | 3f995f2 | 2010-01-06 17:30:06 +0530 | [diff] [blame] | 148 | { |
| 149 | .n_channel = 32, |
| 150 | .n_region = 4, |
| 151 | .n_slot = 128, |
| 152 | .n_tc = 2, |
| 153 | .n_cc = 1, |
| 154 | .queue_tc_mapping = da8xx_queue_tc_mapping, |
| 155 | .queue_priority_mapping = da8xx_queue_priority_mapping, |
Ido Yariv | f23fe85 | 2011-07-10 16:14:35 +0300 | [diff] [blame] | 156 | .default_queue = EVENTQ_1, |
Sudhakar Rajashekhara | 3f995f2 | 2010-01-06 17:30:06 +0530 | [diff] [blame] | 157 | }, |
| 158 | { |
| 159 | .n_channel = 32, |
| 160 | .n_region = 4, |
| 161 | .n_slot = 128, |
| 162 | .n_tc = 1, |
| 163 | .n_cc = 1, |
| 164 | .queue_tc_mapping = da850_queue_tc_mapping, |
| 165 | .queue_priority_mapping = da850_queue_priority_mapping, |
Ido Yariv | f23fe85 | 2011-07-10 16:14:35 +0300 | [diff] [blame] | 166 | .default_queue = EVENTQ_0, |
Sudhakar Rajashekhara | 3f995f2 | 2010-01-06 17:30:06 +0530 | [diff] [blame] | 167 | }, |
| 168 | }; |
| 169 | |
Sekhar Nori | bc3ac9f | 2010-06-29 11:35:12 +0530 | [diff] [blame] | 170 | static struct edma_soc_info *da850_edma_info[EDMA_MAX_CC] = { |
| 171 | &da850_edma_cc_info[0], |
| 172 | &da850_edma_cc_info[1], |
| 173 | }; |
| 174 | |
Sudhakar Rajashekhara | 3f995f2 | 2010-01-06 17:30:06 +0530 | [diff] [blame] | 175 | static struct resource da830_edma_resources[] = { |
Mark A. Greer | 55c79a4 | 2009-06-03 18:36:54 -0700 | [diff] [blame] | 176 | { |
| 177 | .name = "edma_cc0", |
| 178 | .start = DA8XX_TPCC_BASE, |
| 179 | .end = DA8XX_TPCC_BASE + SZ_32K - 1, |
| 180 | .flags = IORESOURCE_MEM, |
| 181 | }, |
| 182 | { |
| 183 | .name = "edma_tc0", |
| 184 | .start = DA8XX_TPTC0_BASE, |
| 185 | .end = DA8XX_TPTC0_BASE + SZ_1K - 1, |
| 186 | .flags = IORESOURCE_MEM, |
| 187 | }, |
| 188 | { |
| 189 | .name = "edma_tc1", |
| 190 | .start = DA8XX_TPTC1_BASE, |
| 191 | .end = DA8XX_TPTC1_BASE + SZ_1K - 1, |
| 192 | .flags = IORESOURCE_MEM, |
| 193 | }, |
| 194 | { |
| 195 | .name = "edma0", |
Sudhakar Rajashekhara | 2259bbd | 2009-07-10 06:28:52 -0400 | [diff] [blame] | 196 | .start = IRQ_DA8XX_CCINT0, |
Mark A. Greer | 55c79a4 | 2009-06-03 18:36:54 -0700 | [diff] [blame] | 197 | .flags = IORESOURCE_IRQ, |
| 198 | }, |
| 199 | { |
| 200 | .name = "edma0_err", |
| 201 | .start = IRQ_DA8XX_CCERRINT, |
| 202 | .flags = IORESOURCE_IRQ, |
| 203 | }, |
| 204 | }; |
| 205 | |
Sudhakar Rajashekhara | 3f995f2 | 2010-01-06 17:30:06 +0530 | [diff] [blame] | 206 | static struct resource da850_edma_resources[] = { |
| 207 | { |
| 208 | .name = "edma_cc0", |
| 209 | .start = DA8XX_TPCC_BASE, |
| 210 | .end = DA8XX_TPCC_BASE + SZ_32K - 1, |
| 211 | .flags = IORESOURCE_MEM, |
| 212 | }, |
| 213 | { |
| 214 | .name = "edma_tc0", |
| 215 | .start = DA8XX_TPTC0_BASE, |
| 216 | .end = DA8XX_TPTC0_BASE + SZ_1K - 1, |
| 217 | .flags = IORESOURCE_MEM, |
| 218 | }, |
| 219 | { |
| 220 | .name = "edma_tc1", |
| 221 | .start = DA8XX_TPTC1_BASE, |
| 222 | .end = DA8XX_TPTC1_BASE + SZ_1K - 1, |
| 223 | .flags = IORESOURCE_MEM, |
| 224 | }, |
| 225 | { |
| 226 | .name = "edma_cc1", |
| 227 | .start = DA850_TPCC1_BASE, |
| 228 | .end = DA850_TPCC1_BASE + SZ_32K - 1, |
| 229 | .flags = IORESOURCE_MEM, |
| 230 | }, |
| 231 | { |
| 232 | .name = "edma_tc2", |
| 233 | .start = DA850_TPTC2_BASE, |
| 234 | .end = DA850_TPTC2_BASE + SZ_1K - 1, |
| 235 | .flags = IORESOURCE_MEM, |
| 236 | }, |
| 237 | { |
| 238 | .name = "edma0", |
| 239 | .start = IRQ_DA8XX_CCINT0, |
| 240 | .flags = IORESOURCE_IRQ, |
| 241 | }, |
| 242 | { |
| 243 | .name = "edma0_err", |
| 244 | .start = IRQ_DA8XX_CCERRINT, |
| 245 | .flags = IORESOURCE_IRQ, |
| 246 | }, |
| 247 | { |
| 248 | .name = "edma1", |
| 249 | .start = IRQ_DA850_CCINT1, |
| 250 | .flags = IORESOURCE_IRQ, |
| 251 | }, |
| 252 | { |
| 253 | .name = "edma1_err", |
| 254 | .start = IRQ_DA850_CCERRINT1, |
| 255 | .flags = IORESOURCE_IRQ, |
| 256 | }, |
| 257 | }; |
| 258 | |
| 259 | static struct platform_device da830_edma_device = { |
Mark A. Greer | 55c79a4 | 2009-06-03 18:36:54 -0700 | [diff] [blame] | 260 | .name = "edma", |
| 261 | .id = -1, |
| 262 | .dev = { |
Sudhakar Rajashekhara | 3f995f2 | 2010-01-06 17:30:06 +0530 | [diff] [blame] | 263 | .platform_data = da830_edma_info, |
Mark A. Greer | 55c79a4 | 2009-06-03 18:36:54 -0700 | [diff] [blame] | 264 | }, |
Sudhakar Rajashekhara | 3f995f2 | 2010-01-06 17:30:06 +0530 | [diff] [blame] | 265 | .num_resources = ARRAY_SIZE(da830_edma_resources), |
| 266 | .resource = da830_edma_resources, |
| 267 | }; |
| 268 | |
| 269 | static struct platform_device da850_edma_device = { |
| 270 | .name = "edma", |
| 271 | .id = -1, |
| 272 | .dev = { |
| 273 | .platform_data = da850_edma_info, |
| 274 | }, |
| 275 | .num_resources = ARRAY_SIZE(da850_edma_resources), |
| 276 | .resource = da850_edma_resources, |
Mark A. Greer | 55c79a4 | 2009-06-03 18:36:54 -0700 | [diff] [blame] | 277 | }; |
| 278 | |
Rajashekhara, Sudhakar | a941c50 | 2010-06-29 11:35:14 +0530 | [diff] [blame] | 279 | int __init da830_register_edma(struct edma_rsv_info *rsv) |
Mark A. Greer | 55c79a4 | 2009-06-03 18:36:54 -0700 | [diff] [blame] | 280 | { |
Rajashekhara, Sudhakar | a941c50 | 2010-06-29 11:35:14 +0530 | [diff] [blame] | 281 | da830_edma_cc0_info.rsv = rsv; |
Sudhakar Rajashekhara | 3f995f2 | 2010-01-06 17:30:06 +0530 | [diff] [blame] | 282 | |
Rajashekhara, Sudhakar | a941c50 | 2010-06-29 11:35:14 +0530 | [diff] [blame] | 283 | return platform_device_register(&da830_edma_device); |
| 284 | } |
Sudhakar Rajashekhara | 3f995f2 | 2010-01-06 17:30:06 +0530 | [diff] [blame] | 285 | |
Rajashekhara, Sudhakar | a941c50 | 2010-06-29 11:35:14 +0530 | [diff] [blame] | 286 | int __init da850_register_edma(struct edma_rsv_info *rsv[2]) |
| 287 | { |
| 288 | if (rsv) { |
| 289 | da850_edma_cc_info[0].rsv = rsv[0]; |
| 290 | da850_edma_cc_info[1].rsv = rsv[1]; |
| 291 | } |
| 292 | |
| 293 | return platform_device_register(&da850_edma_device); |
Mark A. Greer | 55c79a4 | 2009-06-03 18:36:54 -0700 | [diff] [blame] | 294 | } |
| 295 | |
| 296 | static struct resource da8xx_i2c_resources0[] = { |
| 297 | { |
| 298 | .start = DA8XX_I2C0_BASE, |
| 299 | .end = DA8XX_I2C0_BASE + SZ_4K - 1, |
| 300 | .flags = IORESOURCE_MEM, |
| 301 | }, |
| 302 | { |
| 303 | .start = IRQ_DA8XX_I2CINT0, |
| 304 | .end = IRQ_DA8XX_I2CINT0, |
| 305 | .flags = IORESOURCE_IRQ, |
| 306 | }, |
| 307 | }; |
| 308 | |
| 309 | static struct platform_device da8xx_i2c_device0 = { |
| 310 | .name = "i2c_davinci", |
| 311 | .id = 1, |
| 312 | .num_resources = ARRAY_SIZE(da8xx_i2c_resources0), |
| 313 | .resource = da8xx_i2c_resources0, |
| 314 | }; |
| 315 | |
| 316 | static struct resource da8xx_i2c_resources1[] = { |
| 317 | { |
| 318 | .start = DA8XX_I2C1_BASE, |
| 319 | .end = DA8XX_I2C1_BASE + SZ_4K - 1, |
| 320 | .flags = IORESOURCE_MEM, |
| 321 | }, |
| 322 | { |
| 323 | .start = IRQ_DA8XX_I2CINT1, |
| 324 | .end = IRQ_DA8XX_I2CINT1, |
| 325 | .flags = IORESOURCE_IRQ, |
| 326 | }, |
| 327 | }; |
| 328 | |
| 329 | static struct platform_device da8xx_i2c_device1 = { |
| 330 | .name = "i2c_davinci", |
| 331 | .id = 2, |
| 332 | .num_resources = ARRAY_SIZE(da8xx_i2c_resources1), |
| 333 | .resource = da8xx_i2c_resources1, |
| 334 | }; |
| 335 | |
| 336 | int __init da8xx_register_i2c(int instance, |
| 337 | struct davinci_i2c_platform_data *pdata) |
| 338 | { |
| 339 | struct platform_device *pdev; |
| 340 | |
| 341 | if (instance == 0) |
| 342 | pdev = &da8xx_i2c_device0; |
| 343 | else if (instance == 1) |
| 344 | pdev = &da8xx_i2c_device1; |
| 345 | else |
| 346 | return -EINVAL; |
| 347 | |
| 348 | pdev->dev.platform_data = pdata; |
| 349 | return platform_device_register(pdev); |
| 350 | } |
| 351 | |
| 352 | static struct resource da8xx_watchdog_resources[] = { |
| 353 | { |
| 354 | .start = DA8XX_WDOG_BASE, |
| 355 | .end = DA8XX_WDOG_BASE + SZ_4K - 1, |
| 356 | .flags = IORESOURCE_MEM, |
| 357 | }, |
| 358 | }; |
| 359 | |
Cyril Chemparathy | c78a5bc | 2010-05-01 18:38:28 -0400 | [diff] [blame] | 360 | struct platform_device da8xx_wdt_device = { |
Mark A. Greer | 55c79a4 | 2009-06-03 18:36:54 -0700 | [diff] [blame] | 361 | .name = "watchdog", |
| 362 | .id = -1, |
| 363 | .num_resources = ARRAY_SIZE(da8xx_watchdog_resources), |
| 364 | .resource = da8xx_watchdog_resources, |
| 365 | }; |
| 366 | |
Sekhar Nori | c6121dd | 2011-12-05 11:29:46 +0100 | [diff] [blame] | 367 | void da8xx_restart(char mode, const char *cmd) |
| 368 | { |
| 369 | davinci_watchdog_reset(&da8xx_wdt_device); |
| 370 | } |
| 371 | |
Mark A. Greer | 55c79a4 | 2009-06-03 18:36:54 -0700 | [diff] [blame] | 372 | int __init da8xx_register_watchdog(void) |
| 373 | { |
Cyril Chemparathy | c78a5bc | 2010-05-01 18:38:28 -0400 | [diff] [blame] | 374 | return platform_device_register(&da8xx_wdt_device); |
Mark A. Greer | 55c79a4 | 2009-06-03 18:36:54 -0700 | [diff] [blame] | 375 | } |
| 376 | |
| 377 | static struct resource da8xx_emac_resources[] = { |
| 378 | { |
| 379 | .start = DA8XX_EMAC_CPPI_PORT_BASE, |
Cyril Chemparathy | d22960c | 2010-09-15 10:11:22 -0400 | [diff] [blame] | 380 | .end = DA8XX_EMAC_CPPI_PORT_BASE + SZ_16K - 1, |
Mark A. Greer | 55c79a4 | 2009-06-03 18:36:54 -0700 | [diff] [blame] | 381 | .flags = IORESOURCE_MEM, |
| 382 | }, |
| 383 | { |
| 384 | .start = IRQ_DA8XX_C0_RX_THRESH_PULSE, |
| 385 | .end = IRQ_DA8XX_C0_RX_THRESH_PULSE, |
| 386 | .flags = IORESOURCE_IRQ, |
| 387 | }, |
| 388 | { |
| 389 | .start = IRQ_DA8XX_C0_RX_PULSE, |
| 390 | .end = IRQ_DA8XX_C0_RX_PULSE, |
| 391 | .flags = IORESOURCE_IRQ, |
| 392 | }, |
| 393 | { |
| 394 | .start = IRQ_DA8XX_C0_TX_PULSE, |
| 395 | .end = IRQ_DA8XX_C0_TX_PULSE, |
| 396 | .flags = IORESOURCE_IRQ, |
| 397 | }, |
| 398 | { |
| 399 | .start = IRQ_DA8XX_C0_MISC_PULSE, |
| 400 | .end = IRQ_DA8XX_C0_MISC_PULSE, |
| 401 | .flags = IORESOURCE_IRQ, |
| 402 | }, |
| 403 | }; |
| 404 | |
| 405 | struct emac_platform_data da8xx_emac_pdata = { |
| 406 | .ctrl_reg_offset = DA8XX_EMAC_CTRL_REG_OFFSET, |
| 407 | .ctrl_mod_reg_offset = DA8XX_EMAC_MOD_REG_OFFSET, |
| 408 | .ctrl_ram_offset = DA8XX_EMAC_RAM_OFFSET, |
Mark A. Greer | 55c79a4 | 2009-06-03 18:36:54 -0700 | [diff] [blame] | 409 | .ctrl_ram_size = DA8XX_EMAC_CTRL_RAM_SIZE, |
| 410 | .version = EMAC_VERSION_2, |
| 411 | }; |
| 412 | |
| 413 | static struct platform_device da8xx_emac_device = { |
| 414 | .name = "davinci_emac", |
| 415 | .id = 1, |
| 416 | .dev = { |
| 417 | .platform_data = &da8xx_emac_pdata, |
| 418 | }, |
| 419 | .num_resources = ARRAY_SIZE(da8xx_emac_resources), |
| 420 | .resource = da8xx_emac_resources, |
| 421 | }; |
| 422 | |
Cyril Chemparathy | d22960c | 2010-09-15 10:11:22 -0400 | [diff] [blame] | 423 | static struct resource da8xx_mdio_resources[] = { |
| 424 | { |
| 425 | .start = DA8XX_EMAC_MDIO_BASE, |
| 426 | .end = DA8XX_EMAC_MDIO_BASE + SZ_4K - 1, |
| 427 | .flags = IORESOURCE_MEM, |
| 428 | }, |
| 429 | }; |
| 430 | |
| 431 | static struct platform_device da8xx_mdio_device = { |
| 432 | .name = "davinci_mdio", |
| 433 | .id = 0, |
| 434 | .num_resources = ARRAY_SIZE(da8xx_mdio_resources), |
| 435 | .resource = da8xx_mdio_resources, |
| 436 | }; |
| 437 | |
Mark A. Greer | 31f53cf | 2009-08-28 15:02:54 -0700 | [diff] [blame] | 438 | int __init da8xx_register_emac(void) |
| 439 | { |
Cyril Chemparathy | d22960c | 2010-09-15 10:11:22 -0400 | [diff] [blame] | 440 | int ret; |
| 441 | |
| 442 | ret = platform_device_register(&da8xx_mdio_device); |
| 443 | if (ret < 0) |
| 444 | return ret; |
| 445 | ret = platform_device_register(&da8xx_emac_device); |
| 446 | if (ret < 0) |
| 447 | return ret; |
| 448 | ret = clk_add_alias(NULL, dev_name(&da8xx_mdio_device.dev), |
| 449 | NULL, &da8xx_emac_device.dev); |
| 450 | return ret; |
Mark A. Greer | 31f53cf | 2009-08-28 15:02:54 -0700 | [diff] [blame] | 451 | } |
| 452 | |
Chaithrika U S | e33ef5e | 2009-08-11 17:01:59 -0400 | [diff] [blame] | 453 | static struct resource da830_mcasp1_resources[] = { |
| 454 | { |
| 455 | .name = "mcasp1", |
| 456 | .start = DAVINCI_DA830_MCASP1_REG_BASE, |
| 457 | .end = DAVINCI_DA830_MCASP1_REG_BASE + (SZ_1K * 12) - 1, |
| 458 | .flags = IORESOURCE_MEM, |
| 459 | }, |
| 460 | /* TX event */ |
| 461 | { |
| 462 | .start = DAVINCI_DA830_DMA_MCASP1_AXEVT, |
| 463 | .end = DAVINCI_DA830_DMA_MCASP1_AXEVT, |
| 464 | .flags = IORESOURCE_DMA, |
| 465 | }, |
| 466 | /* RX event */ |
| 467 | { |
| 468 | .start = DAVINCI_DA830_DMA_MCASP1_AREVT, |
| 469 | .end = DAVINCI_DA830_DMA_MCASP1_AREVT, |
| 470 | .flags = IORESOURCE_DMA, |
| 471 | }, |
| 472 | }; |
| 473 | |
| 474 | static struct platform_device da830_mcasp1_device = { |
| 475 | .name = "davinci-mcasp", |
| 476 | .id = 1, |
| 477 | .num_resources = ARRAY_SIZE(da830_mcasp1_resources), |
| 478 | .resource = da830_mcasp1_resources, |
| 479 | }; |
| 480 | |
Chaithrika U S | 491214e | 2009-08-11 17:03:25 -0400 | [diff] [blame] | 481 | static struct resource da850_mcasp_resources[] = { |
| 482 | { |
| 483 | .name = "mcasp", |
| 484 | .start = DAVINCI_DA8XX_MCASP0_REG_BASE, |
| 485 | .end = DAVINCI_DA8XX_MCASP0_REG_BASE + (SZ_1K * 12) - 1, |
| 486 | .flags = IORESOURCE_MEM, |
| 487 | }, |
| 488 | /* TX event */ |
| 489 | { |
| 490 | .start = DAVINCI_DA8XX_DMA_MCASP0_AXEVT, |
| 491 | .end = DAVINCI_DA8XX_DMA_MCASP0_AXEVT, |
| 492 | .flags = IORESOURCE_DMA, |
| 493 | }, |
| 494 | /* RX event */ |
| 495 | { |
| 496 | .start = DAVINCI_DA8XX_DMA_MCASP0_AREVT, |
| 497 | .end = DAVINCI_DA8XX_DMA_MCASP0_AREVT, |
| 498 | .flags = IORESOURCE_DMA, |
| 499 | }, |
| 500 | }; |
| 501 | |
| 502 | static struct platform_device da850_mcasp_device = { |
| 503 | .name = "davinci-mcasp", |
| 504 | .id = 0, |
| 505 | .num_resources = ARRAY_SIZE(da850_mcasp_resources), |
| 506 | .resource = da850_mcasp_resources, |
| 507 | }; |
| 508 | |
Mark A. Greer | b8864aa | 2009-08-28 15:05:02 -0700 | [diff] [blame] | 509 | void __init da8xx_register_mcasp(int id, struct snd_platform_data *pdata) |
Chaithrika U S | e33ef5e | 2009-08-11 17:01:59 -0400 | [diff] [blame] | 510 | { |
Chaithrika U S | 491214e | 2009-08-11 17:03:25 -0400 | [diff] [blame] | 511 | /* DA830/OMAP-L137 has 3 instances of McASP */ |
| 512 | if (cpu_is_davinci_da830() && id == 1) { |
Chaithrika U S | e33ef5e | 2009-08-11 17:01:59 -0400 | [diff] [blame] | 513 | da830_mcasp1_device.dev.platform_data = pdata; |
| 514 | platform_device_register(&da830_mcasp1_device); |
Chaithrika U S | 491214e | 2009-08-11 17:03:25 -0400 | [diff] [blame] | 515 | } else if (cpu_is_davinci_da850()) { |
| 516 | da850_mcasp_device.dev.platform_data = pdata; |
| 517 | platform_device_register(&da850_mcasp_device); |
Chaithrika U S | e33ef5e | 2009-08-11 17:01:59 -0400 | [diff] [blame] | 518 | } |
| 519 | } |
Sudhakar Rajashekhara | 5cbdf27 | 2009-08-13 14:33:14 -0400 | [diff] [blame] | 520 | |
Sudhakar Rajashekhara | 5cbdf27 | 2009-08-13 14:33:14 -0400 | [diff] [blame] | 521 | static struct lcd_ctrl_config lcd_cfg = { |
Manjunathappa, Prakash | 3b43ad2 | 2012-10-16 10:23:16 +0530 | [diff] [blame^] | 522 | .panel_shade = COLOR_ACTIVE, |
Sudhakar Rajashekhara | 5cbdf27 | 2009-08-13 14:33:14 -0400 | [diff] [blame] | 523 | .bpp = 16, |
Sudhakar Rajashekhara | 5cbdf27 | 2009-08-13 14:33:14 -0400 | [diff] [blame] | 524 | }; |
| 525 | |
Mark A. Greer | b9e6342 | 2009-09-15 18:14:19 -0700 | [diff] [blame] | 526 | struct da8xx_lcdc_platform_data sharp_lcd035q3dg01_pdata = { |
| 527 | .manu_name = "sharp", |
| 528 | .controller_data = &lcd_cfg, |
| 529 | .type = "Sharp_LCD035Q3DG01", |
| 530 | }; |
| 531 | |
| 532 | struct da8xx_lcdc_platform_data sharp_lk043t1dg01_pdata = { |
| 533 | .manu_name = "sharp", |
| 534 | .controller_data = &lcd_cfg, |
| 535 | .type = "Sharp_LK043T1DG01", |
Sudhakar Rajashekhara | 5cbdf27 | 2009-08-13 14:33:14 -0400 | [diff] [blame] | 536 | }; |
| 537 | |
| 538 | static struct resource da8xx_lcdc_resources[] = { |
| 539 | [0] = { /* registers */ |
| 540 | .start = DA8XX_LCD_CNTRL_BASE, |
| 541 | .end = DA8XX_LCD_CNTRL_BASE + SZ_4K - 1, |
| 542 | .flags = IORESOURCE_MEM, |
| 543 | }, |
| 544 | [1] = { /* interrupt */ |
| 545 | .start = IRQ_DA8XX_LCDINT, |
| 546 | .end = IRQ_DA8XX_LCDINT, |
| 547 | .flags = IORESOURCE_IRQ, |
| 548 | }, |
| 549 | }; |
| 550 | |
Mark A. Greer | b9e6342 | 2009-09-15 18:14:19 -0700 | [diff] [blame] | 551 | static struct platform_device da8xx_lcdc_device = { |
Sudhakar Rajashekhara | 5cbdf27 | 2009-08-13 14:33:14 -0400 | [diff] [blame] | 552 | .name = "da8xx_lcdc", |
| 553 | .id = 0, |
| 554 | .num_resources = ARRAY_SIZE(da8xx_lcdc_resources), |
| 555 | .resource = da8xx_lcdc_resources, |
Sudhakar Rajashekhara | 5cbdf27 | 2009-08-13 14:33:14 -0400 | [diff] [blame] | 556 | }; |
| 557 | |
Mark A. Greer | b9e6342 | 2009-09-15 18:14:19 -0700 | [diff] [blame] | 558 | int __init da8xx_register_lcdc(struct da8xx_lcdc_platform_data *pdata) |
Sudhakar Rajashekhara | 5cbdf27 | 2009-08-13 14:33:14 -0400 | [diff] [blame] | 559 | { |
Mark A. Greer | b9e6342 | 2009-09-15 18:14:19 -0700 | [diff] [blame] | 560 | da8xx_lcdc_device.dev.platform_data = pdata; |
| 561 | return platform_device_register(&da8xx_lcdc_device); |
Sudhakar Rajashekhara | 5cbdf27 | 2009-08-13 14:33:14 -0400 | [diff] [blame] | 562 | } |
Sudhakar Rajashekhara | 700691f | 2009-08-13 15:16:23 -0400 | [diff] [blame] | 563 | |
| 564 | static struct resource da8xx_mmcsd0_resources[] = { |
| 565 | { /* registers */ |
| 566 | .start = DA8XX_MMCSD0_BASE, |
| 567 | .end = DA8XX_MMCSD0_BASE + SZ_4K - 1, |
| 568 | .flags = IORESOURCE_MEM, |
| 569 | }, |
| 570 | { /* interrupt */ |
| 571 | .start = IRQ_DA8XX_MMCSDINT0, |
| 572 | .end = IRQ_DA8XX_MMCSDINT0, |
| 573 | .flags = IORESOURCE_IRQ, |
| 574 | }, |
| 575 | { /* DMA RX */ |
Michael Williamson | e38c2b2 | 2011-02-22 13:36:57 +0000 | [diff] [blame] | 576 | .start = DA8XX_DMA_MMCSD0_RX, |
| 577 | .end = DA8XX_DMA_MMCSD0_RX, |
Sudhakar Rajashekhara | 700691f | 2009-08-13 15:16:23 -0400 | [diff] [blame] | 578 | .flags = IORESOURCE_DMA, |
| 579 | }, |
| 580 | { /* DMA TX */ |
Michael Williamson | e38c2b2 | 2011-02-22 13:36:57 +0000 | [diff] [blame] | 581 | .start = DA8XX_DMA_MMCSD0_TX, |
| 582 | .end = DA8XX_DMA_MMCSD0_TX, |
Sudhakar Rajashekhara | 700691f | 2009-08-13 15:16:23 -0400 | [diff] [blame] | 583 | .flags = IORESOURCE_DMA, |
| 584 | }, |
| 585 | }; |
| 586 | |
| 587 | static struct platform_device da8xx_mmcsd0_device = { |
| 588 | .name = "davinci_mmc", |
| 589 | .id = 0, |
| 590 | .num_resources = ARRAY_SIZE(da8xx_mmcsd0_resources), |
| 591 | .resource = da8xx_mmcsd0_resources, |
| 592 | }; |
| 593 | |
| 594 | int __init da8xx_register_mmcsd0(struct davinci_mmc_config *config) |
| 595 | { |
| 596 | da8xx_mmcsd0_device.dev.platform_data = config; |
| 597 | return platform_device_register(&da8xx_mmcsd0_device); |
| 598 | } |
Mark A. Greer | c51df70 | 2009-09-15 18:15:54 -0700 | [diff] [blame] | 599 | |
Juha Kuikka | b8241ae | 2010-08-26 12:40:47 -0700 | [diff] [blame] | 600 | #ifdef CONFIG_ARCH_DAVINCI_DA850 |
| 601 | static struct resource da850_mmcsd1_resources[] = { |
| 602 | { /* registers */ |
| 603 | .start = DA850_MMCSD1_BASE, |
| 604 | .end = DA850_MMCSD1_BASE + SZ_4K - 1, |
| 605 | .flags = IORESOURCE_MEM, |
| 606 | }, |
| 607 | { /* interrupt */ |
| 608 | .start = IRQ_DA850_MMCSDINT0_1, |
| 609 | .end = IRQ_DA850_MMCSDINT0_1, |
| 610 | .flags = IORESOURCE_IRQ, |
| 611 | }, |
| 612 | { /* DMA RX */ |
Michael Williamson | e38c2b2 | 2011-02-22 13:36:57 +0000 | [diff] [blame] | 613 | .start = DA850_DMA_MMCSD1_RX, |
| 614 | .end = DA850_DMA_MMCSD1_RX, |
Juha Kuikka | b8241ae | 2010-08-26 12:40:47 -0700 | [diff] [blame] | 615 | .flags = IORESOURCE_DMA, |
| 616 | }, |
| 617 | { /* DMA TX */ |
Michael Williamson | e38c2b2 | 2011-02-22 13:36:57 +0000 | [diff] [blame] | 618 | .start = DA850_DMA_MMCSD1_TX, |
| 619 | .end = DA850_DMA_MMCSD1_TX, |
Juha Kuikka | b8241ae | 2010-08-26 12:40:47 -0700 | [diff] [blame] | 620 | .flags = IORESOURCE_DMA, |
| 621 | }, |
| 622 | }; |
| 623 | |
| 624 | static struct platform_device da850_mmcsd1_device = { |
| 625 | .name = "davinci_mmc", |
| 626 | .id = 1, |
| 627 | .num_resources = ARRAY_SIZE(da850_mmcsd1_resources), |
| 628 | .resource = da850_mmcsd1_resources, |
| 629 | }; |
| 630 | |
| 631 | int __init da850_register_mmcsd1(struct davinci_mmc_config *config) |
| 632 | { |
| 633 | da850_mmcsd1_device.dev.platform_data = config; |
| 634 | return platform_device_register(&da850_mmcsd1_device); |
| 635 | } |
| 636 | #endif |
| 637 | |
Mark A. Greer | c51df70 | 2009-09-15 18:15:54 -0700 | [diff] [blame] | 638 | static struct resource da8xx_rtc_resources[] = { |
| 639 | { |
| 640 | .start = DA8XX_RTC_BASE, |
| 641 | .end = DA8XX_RTC_BASE + SZ_4K - 1, |
| 642 | .flags = IORESOURCE_MEM, |
| 643 | }, |
| 644 | { /* timer irq */ |
| 645 | .start = IRQ_DA8XX_RTC, |
| 646 | .end = IRQ_DA8XX_RTC, |
| 647 | .flags = IORESOURCE_IRQ, |
| 648 | }, |
| 649 | { /* alarm irq */ |
| 650 | .start = IRQ_DA8XX_RTC, |
| 651 | .end = IRQ_DA8XX_RTC, |
| 652 | .flags = IORESOURCE_IRQ, |
| 653 | }, |
| 654 | }; |
| 655 | |
| 656 | static struct platform_device da8xx_rtc_device = { |
| 657 | .name = "omap_rtc", |
| 658 | .id = -1, |
| 659 | .num_resources = ARRAY_SIZE(da8xx_rtc_resources), |
| 660 | .resource = da8xx_rtc_resources, |
| 661 | }; |
| 662 | |
| 663 | int da8xx_register_rtc(void) |
| 664 | { |
Sekhar Nori | 75c99bb | 2009-11-16 17:21:31 +0530 | [diff] [blame] | 665 | int ret; |
Cyril Chemparathy | db6db5d | 2010-05-07 17:06:33 -0400 | [diff] [blame] | 666 | void __iomem *base; |
| 667 | |
| 668 | base = ioremap(DA8XX_RTC_BASE, SZ_4K); |
| 669 | if (WARN_ON(!base)) |
| 670 | return -ENOMEM; |
Sekhar Nori | 75c99bb | 2009-11-16 17:21:31 +0530 | [diff] [blame] | 671 | |
Mark A. Greer | c51df70 | 2009-09-15 18:15:54 -0700 | [diff] [blame] | 672 | /* Unlock the rtc's registers */ |
Cyril Chemparathy | db6db5d | 2010-05-07 17:06:33 -0400 | [diff] [blame] | 673 | __raw_writel(0x83e70b13, base + 0x6c); |
| 674 | __raw_writel(0x95a4f1e0, base + 0x70); |
| 675 | |
| 676 | iounmap(base); |
Mark A. Greer | c51df70 | 2009-09-15 18:15:54 -0700 | [diff] [blame] | 677 | |
Sekhar Nori | 75c99bb | 2009-11-16 17:21:31 +0530 | [diff] [blame] | 678 | ret = platform_device_register(&da8xx_rtc_device); |
| 679 | if (!ret) |
| 680 | /* Atleast on DA850, RTC is a wakeup source */ |
| 681 | device_init_wakeup(&da8xx_rtc_device.dev, true); |
| 682 | |
| 683 | return ret; |
Mark A. Greer | c51df70 | 2009-09-15 18:15:54 -0700 | [diff] [blame] | 684 | } |
Sekhar Nori | 1960e69 | 2009-10-22 15:12:14 +0530 | [diff] [blame] | 685 | |
Sekhar Nori | 948c66d | 2009-11-16 17:21:37 +0530 | [diff] [blame] | 686 | static void __iomem *da8xx_ddr2_ctlr_base; |
| 687 | void __iomem * __init da8xx_get_mem_ctlr(void) |
| 688 | { |
| 689 | if (da8xx_ddr2_ctlr_base) |
| 690 | return da8xx_ddr2_ctlr_base; |
| 691 | |
| 692 | da8xx_ddr2_ctlr_base = ioremap(DA8XX_DDR2_CTL_BASE, SZ_32K); |
| 693 | if (!da8xx_ddr2_ctlr_base) |
| 694 | pr_warning("%s: Unable to map DDR2 controller", __func__); |
| 695 | |
| 696 | return da8xx_ddr2_ctlr_base; |
| 697 | } |
| 698 | |
Sekhar Nori | 1960e69 | 2009-10-22 15:12:14 +0530 | [diff] [blame] | 699 | static struct resource da8xx_cpuidle_resources[] = { |
| 700 | { |
| 701 | .start = DA8XX_DDR2_CTL_BASE, |
| 702 | .end = DA8XX_DDR2_CTL_BASE + SZ_32K - 1, |
| 703 | .flags = IORESOURCE_MEM, |
| 704 | }, |
| 705 | }; |
| 706 | |
| 707 | /* DA8XX devices support DDR2 power down */ |
| 708 | static struct davinci_cpuidle_config da8xx_cpuidle_pdata = { |
| 709 | .ddr2_pdown = 1, |
| 710 | }; |
| 711 | |
| 712 | |
| 713 | static struct platform_device da8xx_cpuidle_device = { |
| 714 | .name = "cpuidle-davinci", |
| 715 | .num_resources = ARRAY_SIZE(da8xx_cpuidle_resources), |
| 716 | .resource = da8xx_cpuidle_resources, |
| 717 | .dev = { |
| 718 | .platform_data = &da8xx_cpuidle_pdata, |
| 719 | }, |
| 720 | }; |
| 721 | |
| 722 | int __init da8xx_register_cpuidle(void) |
| 723 | { |
Sekhar Nori | 948c66d | 2009-11-16 17:21:37 +0530 | [diff] [blame] | 724 | da8xx_cpuidle_pdata.ddr2_ctlr_base = da8xx_get_mem_ctlr(); |
| 725 | |
Sekhar Nori | 1960e69 | 2009-10-22 15:12:14 +0530 | [diff] [blame] | 726 | return platform_device_register(&da8xx_cpuidle_device); |
| 727 | } |
Michael Williamson | 54ce688 | 2011-02-24 10:18:28 +0530 | [diff] [blame] | 728 | |
| 729 | static struct resource da8xx_spi0_resources[] = { |
| 730 | [0] = { |
| 731 | .start = DA8XX_SPI0_BASE, |
| 732 | .end = DA8XX_SPI0_BASE + SZ_4K - 1, |
| 733 | .flags = IORESOURCE_MEM, |
| 734 | }, |
| 735 | [1] = { |
| 736 | .start = IRQ_DA8XX_SPINT0, |
| 737 | .end = IRQ_DA8XX_SPINT0, |
| 738 | .flags = IORESOURCE_IRQ, |
| 739 | }, |
| 740 | [2] = { |
| 741 | .start = DA8XX_DMA_SPI0_RX, |
| 742 | .end = DA8XX_DMA_SPI0_RX, |
| 743 | .flags = IORESOURCE_DMA, |
| 744 | }, |
| 745 | [3] = { |
| 746 | .start = DA8XX_DMA_SPI0_TX, |
| 747 | .end = DA8XX_DMA_SPI0_TX, |
| 748 | .flags = IORESOURCE_DMA, |
| 749 | }, |
| 750 | }; |
| 751 | |
| 752 | static struct resource da8xx_spi1_resources[] = { |
| 753 | [0] = { |
Sergei Shtylyov | 9e7d24f | 2011-04-06 17:17:21 +0000 | [diff] [blame] | 754 | .start = DA830_SPI1_BASE, |
| 755 | .end = DA830_SPI1_BASE + SZ_4K - 1, |
Michael Williamson | 54ce688 | 2011-02-24 10:18:28 +0530 | [diff] [blame] | 756 | .flags = IORESOURCE_MEM, |
| 757 | }, |
| 758 | [1] = { |
| 759 | .start = IRQ_DA8XX_SPINT1, |
| 760 | .end = IRQ_DA8XX_SPINT1, |
| 761 | .flags = IORESOURCE_IRQ, |
| 762 | }, |
| 763 | [2] = { |
| 764 | .start = DA8XX_DMA_SPI1_RX, |
| 765 | .end = DA8XX_DMA_SPI1_RX, |
| 766 | .flags = IORESOURCE_DMA, |
| 767 | }, |
| 768 | [3] = { |
| 769 | .start = DA8XX_DMA_SPI1_TX, |
| 770 | .end = DA8XX_DMA_SPI1_TX, |
| 771 | .flags = IORESOURCE_DMA, |
| 772 | }, |
| 773 | }; |
| 774 | |
| 775 | struct davinci_spi_platform_data da8xx_spi_pdata[] = { |
| 776 | [0] = { |
| 777 | .version = SPI_VERSION_2, |
| 778 | .intr_line = 1, |
| 779 | .dma_event_q = EVENTQ_0, |
| 780 | }, |
| 781 | [1] = { |
| 782 | .version = SPI_VERSION_2, |
| 783 | .intr_line = 1, |
| 784 | .dma_event_q = EVENTQ_0, |
| 785 | }, |
| 786 | }; |
| 787 | |
| 788 | static struct platform_device da8xx_spi_device[] = { |
| 789 | [0] = { |
| 790 | .name = "spi_davinci", |
| 791 | .id = 0, |
| 792 | .num_resources = ARRAY_SIZE(da8xx_spi0_resources), |
| 793 | .resource = da8xx_spi0_resources, |
| 794 | .dev = { |
| 795 | .platform_data = &da8xx_spi_pdata[0], |
| 796 | }, |
| 797 | }, |
| 798 | [1] = { |
| 799 | .name = "spi_davinci", |
| 800 | .id = 1, |
| 801 | .num_resources = ARRAY_SIZE(da8xx_spi1_resources), |
| 802 | .resource = da8xx_spi1_resources, |
| 803 | .dev = { |
| 804 | .platform_data = &da8xx_spi_pdata[1], |
| 805 | }, |
| 806 | }, |
| 807 | }; |
| 808 | |
Uwe Kleine-König | d65566e | 2012-03-30 22:13:53 +0200 | [diff] [blame] | 809 | int __init da8xx_register_spi(int instance, const struct spi_board_info *info, |
Michael Williamson | 54ce688 | 2011-02-24 10:18:28 +0530 | [diff] [blame] | 810 | unsigned len) |
| 811 | { |
| 812 | int ret; |
| 813 | |
| 814 | if (instance < 0 || instance > 1) |
| 815 | return -EINVAL; |
| 816 | |
| 817 | ret = spi_register_board_info(info, len); |
| 818 | if (ret) |
| 819 | pr_warning("%s: failed to register board info for spi %d :" |
| 820 | " %d\n", __func__, instance, ret); |
| 821 | |
| 822 | da8xx_spi_pdata[instance].num_chipselect = len; |
| 823 | |
Sergei Shtylyov | 9e7d24f | 2011-04-06 17:17:21 +0000 | [diff] [blame] | 824 | if (instance == 1 && cpu_is_davinci_da850()) { |
| 825 | da8xx_spi1_resources[0].start = DA850_SPI1_BASE; |
| 826 | da8xx_spi1_resources[0].end = DA850_SPI1_BASE + SZ_4K - 1; |
| 827 | } |
| 828 | |
Michael Williamson | 54ce688 | 2011-02-24 10:18:28 +0530 | [diff] [blame] | 829 | return platform_device_register(&da8xx_spi_device[instance]); |
| 830 | } |
Sekhar Nori | cbb2c96 | 2011-07-06 06:01:23 +0000 | [diff] [blame] | 831 | |
| 832 | #ifdef CONFIG_ARCH_DAVINCI_DA850 |
| 833 | |
| 834 | static struct resource da850_sata_resources[] = { |
| 835 | { |
| 836 | .start = DA850_SATA_BASE, |
| 837 | .end = DA850_SATA_BASE + 0x1fff, |
| 838 | .flags = IORESOURCE_MEM, |
| 839 | }, |
| 840 | { |
| 841 | .start = IRQ_DA850_SATAINT, |
| 842 | .flags = IORESOURCE_IRQ, |
| 843 | }, |
| 844 | }; |
| 845 | |
| 846 | /* SATA PHY Control Register offset from AHCI base */ |
| 847 | #define SATA_P0PHYCR_REG 0x178 |
| 848 | |
| 849 | #define SATA_PHY_MPY(x) ((x) << 0) |
| 850 | #define SATA_PHY_LOS(x) ((x) << 6) |
| 851 | #define SATA_PHY_RXCDR(x) ((x) << 10) |
| 852 | #define SATA_PHY_RXEQ(x) ((x) << 13) |
| 853 | #define SATA_PHY_TXSWING(x) ((x) << 19) |
| 854 | #define SATA_PHY_ENPLL(x) ((x) << 31) |
| 855 | |
| 856 | static struct clk *da850_sata_clk; |
| 857 | static unsigned long da850_sata_refclkpn; |
| 858 | |
| 859 | /* Supported DA850 SATA crystal frequencies */ |
| 860 | #define KHZ_TO_HZ(freq) ((freq) * 1000) |
| 861 | static unsigned long da850_sata_xtal[] = { |
| 862 | KHZ_TO_HZ(300000), |
| 863 | KHZ_TO_HZ(250000), |
| 864 | 0, /* Reserved */ |
| 865 | KHZ_TO_HZ(187500), |
| 866 | KHZ_TO_HZ(150000), |
| 867 | KHZ_TO_HZ(125000), |
| 868 | KHZ_TO_HZ(120000), |
| 869 | KHZ_TO_HZ(100000), |
| 870 | KHZ_TO_HZ(75000), |
| 871 | KHZ_TO_HZ(60000), |
| 872 | }; |
| 873 | |
| 874 | static int da850_sata_init(struct device *dev, void __iomem *addr) |
| 875 | { |
| 876 | int i, ret; |
| 877 | unsigned int val; |
| 878 | |
| 879 | da850_sata_clk = clk_get(dev, NULL); |
| 880 | if (IS_ERR(da850_sata_clk)) |
| 881 | return PTR_ERR(da850_sata_clk); |
| 882 | |
| 883 | ret = clk_enable(da850_sata_clk); |
| 884 | if (ret) |
| 885 | goto err0; |
| 886 | |
| 887 | /* Enable SATA clock receiver */ |
| 888 | val = __raw_readl(DA8XX_SYSCFG1_VIRT(DA8XX_PWRDN_REG)); |
| 889 | val &= ~BIT(0); |
| 890 | __raw_writel(val, DA8XX_SYSCFG1_VIRT(DA8XX_PWRDN_REG)); |
| 891 | |
| 892 | /* Get the multiplier needed for 1.5GHz PLL output */ |
| 893 | for (i = 0; i < ARRAY_SIZE(da850_sata_xtal); i++) |
| 894 | if (da850_sata_xtal[i] == da850_sata_refclkpn) |
| 895 | break; |
| 896 | |
| 897 | if (i == ARRAY_SIZE(da850_sata_xtal)) { |
| 898 | ret = -EINVAL; |
| 899 | goto err1; |
| 900 | } |
| 901 | |
| 902 | val = SATA_PHY_MPY(i + 1) | |
| 903 | SATA_PHY_LOS(1) | |
| 904 | SATA_PHY_RXCDR(4) | |
| 905 | SATA_PHY_RXEQ(1) | |
| 906 | SATA_PHY_TXSWING(3) | |
| 907 | SATA_PHY_ENPLL(1); |
| 908 | |
| 909 | __raw_writel(val, addr + SATA_P0PHYCR_REG); |
| 910 | |
| 911 | return 0; |
| 912 | |
| 913 | err1: |
| 914 | clk_disable(da850_sata_clk); |
| 915 | err0: |
| 916 | clk_put(da850_sata_clk); |
| 917 | return ret; |
| 918 | } |
| 919 | |
| 920 | static void da850_sata_exit(struct device *dev) |
| 921 | { |
| 922 | clk_disable(da850_sata_clk); |
| 923 | clk_put(da850_sata_clk); |
| 924 | } |
| 925 | |
| 926 | static struct ahci_platform_data da850_sata_pdata = { |
| 927 | .init = da850_sata_init, |
| 928 | .exit = da850_sata_exit, |
| 929 | }; |
| 930 | |
| 931 | static u64 da850_sata_dmamask = DMA_BIT_MASK(32); |
| 932 | |
| 933 | static struct platform_device da850_sata_device = { |
| 934 | .name = "ahci", |
| 935 | .id = -1, |
| 936 | .dev = { |
| 937 | .platform_data = &da850_sata_pdata, |
| 938 | .dma_mask = &da850_sata_dmamask, |
| 939 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 940 | }, |
| 941 | .num_resources = ARRAY_SIZE(da850_sata_resources), |
| 942 | .resource = da850_sata_resources, |
| 943 | }; |
| 944 | |
| 945 | int __init da850_register_sata(unsigned long refclkpn) |
| 946 | { |
| 947 | da850_sata_refclkpn = refclkpn; |
| 948 | if (!da850_sata_refclkpn) |
| 949 | return -EINVAL; |
| 950 | |
| 951 | return platform_device_register(&da850_sata_device); |
| 952 | } |
| 953 | #endif |