blob: 036139fe0d0f5e2b0c7d67d63af0a4982c0e3d48 [file] [log] [blame]
Mark A. Greer55c79a42009-06-03 18:36:54 -07001/*
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 */
David Lechneraa1da332018-05-18 11:48:14 -050013#include <linux/ahci_platform.h>
14#include <linux/clk-provider.h>
15#include <linux/clk.h>
16#include <linux/clkdev.h>
17#include <linux/dma-contiguous.h>
18#include <linux/dmaengine.h>
Mark A. Greer55c79a42009-06-03 18:36:54 -070019#include <linux/init.h>
Stephen Boyd62e59c42019-04-18 15:20:22 -070020#include <linux/io.h>
Mark A. Greer55c79a42009-06-03 18:36:54 -070021#include <linux/platform_device.h>
Robin Holt7b6d8642013-07-08 16:01:40 -070022#include <linux/reboot.h>
David Lechneraa1da332018-05-18 11:48:14 -050023#include <linux/serial_8250.h>
Mark A. Greer55c79a42009-06-03 18:36:54 -070024
Mark A. Greer55c79a42009-06-03 18:36:54 -070025#include <mach/common.h>
David Lechneraa1da332018-05-18 11:48:14 -050026#include <mach/cputype.h>
Mark A. Greer55c79a42009-06-03 18:36:54 -070027#include <mach/da8xx.h>
David Lechneraa1da332018-05-18 11:48:14 -050028#include <mach/time.h>
29
30#include "asp.h"
Arnd Bergmann3acf7312015-01-30 10:45:33 +010031#include "cpuidle.h"
Bartosz Golaszewski544ca0b2019-02-14 15:52:03 +010032#include "irqs.h"
Arnd Bergmann3acf7312015-01-30 10:45:33 +010033#include "sram.h"
Mark A. Greer55c79a42009-06-03 18:36:54 -070034
Mark A. Greer55c79a42009-06-03 18:36:54 -070035#define DA8XX_TPCC_BASE 0x01c00000
36#define DA8XX_TPTC0_BASE 0x01c08000
37#define DA8XX_TPTC1_BASE 0x01c08400
38#define DA8XX_WDOG_BASE 0x01c21000 /* DA8XX_TIMER64P1_BASE */
39#define DA8XX_I2C0_BASE 0x01c22000
Sergei Shtylyov8ac764e2011-04-06 17:29:24 +000040#define DA8XX_RTC_BASE 0x01c23000
Matt Porter8e0d72d2012-10-08 09:53:08 -040041#define DA8XX_PRUSS_MEM_BASE 0x01c30000
Sergei Shtylyov8ac764e2011-04-06 17:29:24 +000042#define DA8XX_MMCSD0_BASE 0x01c40000
43#define DA8XX_SPI0_BASE 0x01c41000
44#define DA830_SPI1_BASE 0x01e12000
45#define DA8XX_LCD_CNTRL_BASE 0x01e13000
Sekhar Noricbb2c962011-07-06 06:01:23 +000046#define DA850_SATA_BASE 0x01e18000
Sergei Shtylyov8ac764e2011-04-06 17:29:24 +000047#define DA850_MMCSD1_BASE 0x01e1b000
Mark A. Greer55c79a42009-06-03 18:36:54 -070048#define DA8XX_EMAC_CPPI_PORT_BASE 0x01e20000
49#define DA8XX_EMAC_CPGMACSS_BASE 0x01e22000
50#define DA8XX_EMAC_CPGMAC_BASE 0x01e23000
51#define DA8XX_EMAC_MDIO_BASE 0x01e24000
Mark A. Greer55c79a42009-06-03 18:36:54 -070052#define DA8XX_I2C1_BASE 0x01e28000
Sergei Shtylyov8ac764e2011-04-06 17:29:24 +000053#define DA850_TPCC1_BASE 0x01e30000
54#define DA850_TPTC2_BASE 0x01e38000
Sergei Shtylyov9e7d24f2011-04-06 17:17:21 +000055#define DA850_SPI1_BASE 0x01f0e000
Sergei Shtylyov8ac764e2011-04-06 17:29:24 +000056#define DA8XX_DDR2_CTL_BASE 0xb0000000
Mark A. Greer55c79a42009-06-03 18:36:54 -070057
58#define DA8XX_EMAC_CTRL_REG_OFFSET 0x3000
59#define DA8XX_EMAC_MOD_REG_OFFSET 0x2000
60#define DA8XX_EMAC_RAM_OFFSET 0x0000
Mark A. Greer55c79a42009-06-03 18:36:54 -070061#define DA8XX_EMAC_CTRL_RAM_SIZE SZ_8K
62
Sekhar Norid2de0582009-11-16 17:21:32 +053063void __iomem *da8xx_syscfg0_base;
64void __iomem *da8xx_syscfg1_base;
Sekhar Nori6a28adef2009-08-31 15:47:59 +053065
Manjunathappa, Prakash19955c32013-06-19 14:45:38 +053066static struct plat_serial8250_port da8xx_serial0_pdata[] = {
Mark A. Greer55c79a42009-06-03 18:36:54 -070067 {
68 .mapbase = DA8XX_UART0_BASE,
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +010069 .irq = DAVINCI_INTC_IRQ(IRQ_DA8XX_UARTINT0),
Mark A. Greer55c79a42009-06-03 18:36:54 -070070 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
71 UPF_IOREMAP,
72 .iotype = UPIO_MEM,
73 .regshift = 2,
74 },
75 {
Manjunathappa, Prakash19955c32013-06-19 14:45:38 +053076 .flags = 0,
77 }
78};
79static struct plat_serial8250_port da8xx_serial1_pdata[] = {
80 {
Mark A. Greer55c79a42009-06-03 18:36:54 -070081 .mapbase = DA8XX_UART1_BASE,
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +010082 .irq = DAVINCI_INTC_IRQ(IRQ_DA8XX_UARTINT1),
Mark A. Greer55c79a42009-06-03 18:36:54 -070083 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
84 UPF_IOREMAP,
85 .iotype = UPIO_MEM,
86 .regshift = 2,
87 },
88 {
Manjunathappa, Prakash19955c32013-06-19 14:45:38 +053089 .flags = 0,
90 }
91};
92static struct plat_serial8250_port da8xx_serial2_pdata[] = {
93 {
Mark A. Greer55c79a42009-06-03 18:36:54 -070094 .mapbase = DA8XX_UART2_BASE,
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +010095 .irq = DAVINCI_INTC_IRQ(IRQ_DA8XX_UARTINT2),
Mark A. Greer55c79a42009-06-03 18:36:54 -070096 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
97 UPF_IOREMAP,
98 .iotype = UPIO_MEM,
99 .regshift = 2,
100 },
101 {
102 .flags = 0,
Manjunathappa, Prakash19955c32013-06-19 14:45:38 +0530103 }
Mark A. Greer55c79a42009-06-03 18:36:54 -0700104};
105
Manjunathappa, Prakash19955c32013-06-19 14:45:38 +0530106struct platform_device da8xx_serial_device[] = {
107 {
108 .name = "serial8250",
109 .id = PLAT8250_DEV_PLATFORM,
110 .dev = {
111 .platform_data = da8xx_serial0_pdata,
112 }
Mark A. Greer55c79a42009-06-03 18:36:54 -0700113 },
Manjunathappa, Prakash19955c32013-06-19 14:45:38 +0530114 {
115 .name = "serial8250",
116 .id = PLAT8250_DEV_PLATFORM1,
117 .dev = {
118 .platform_data = da8xx_serial1_pdata,
119 }
120 },
121 {
122 .name = "serial8250",
123 .id = PLAT8250_DEV_PLATFORM2,
124 .dev = {
125 .platform_data = da8xx_serial2_pdata,
126 }
127 },
128 {
129 }
Mark A. Greer55c79a42009-06-03 18:36:54 -0700130};
131
Matt Porter6cba4352013-06-20 16:06:38 -0500132static s8 da8xx_queue_priority_mapping[][2] = {
Mark A. Greer55c79a42009-06-03 18:36:54 -0700133 /* {event queue no, Priority} */
134 {0, 3},
135 {1, 7},
136 {-1, -1}
137};
138
Matt Porter6cba4352013-06-20 16:06:38 -0500139static s8 da850_queue_priority_mapping[][2] = {
Sudhakar Rajashekhara3f995f22010-01-06 17:30:06 +0530140 /* {event queue no, Priority} */
141 {0, 3},
142 {-1, -1}
143};
144
Peter Ujfalusid4cb7f42015-10-14 14:42:46 +0300145static struct edma_soc_info da8xx_edma0_pdata = {
Sekhar Noribc3ac9f2010-06-29 11:35:12 +0530146 .queue_priority_mapping = da8xx_queue_priority_mapping,
Ido Yarivf23fe852011-07-10 16:14:35 +0300147 .default_queue = EVENTQ_1,
Mark A. Greer55c79a42009-06-03 18:36:54 -0700148};
149
Peter Ujfalusid4cb7f42015-10-14 14:42:46 +0300150static struct edma_soc_info da850_edma1_pdata = {
151 .queue_priority_mapping = da850_queue_priority_mapping,
152 .default_queue = EVENTQ_0,
Sekhar Noribc3ac9f2010-06-29 11:35:12 +0530153};
154
Peter Ujfalusid4cb7f42015-10-14 14:42:46 +0300155static struct resource da8xx_edma0_resources[] = {
Sudhakar Rajashekhara3f995f22010-01-06 17:30:06 +0530156 {
Peter Ujfalusid4cb7f42015-10-14 14:42:46 +0300157 .name = "edma3_cc",
Mark A. Greer55c79a42009-06-03 18:36:54 -0700158 .start = DA8XX_TPCC_BASE,
159 .end = DA8XX_TPCC_BASE + SZ_32K - 1,
160 .flags = IORESOURCE_MEM,
161 },
162 {
Peter Ujfalusid4cb7f42015-10-14 14:42:46 +0300163 .name = "edma3_tc0",
Mark A. Greer55c79a42009-06-03 18:36:54 -0700164 .start = DA8XX_TPTC0_BASE,
165 .end = DA8XX_TPTC0_BASE + SZ_1K - 1,
166 .flags = IORESOURCE_MEM,
167 },
168 {
Peter Ujfalusid4cb7f42015-10-14 14:42:46 +0300169 .name = "edma3_tc1",
Mark A. Greer55c79a42009-06-03 18:36:54 -0700170 .start = DA8XX_TPTC1_BASE,
171 .end = DA8XX_TPTC1_BASE + SZ_1K - 1,
172 .flags = IORESOURCE_MEM,
173 },
174 {
Peter Ujfalusid4cb7f42015-10-14 14:42:46 +0300175 .name = "edma3_ccint",
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100176 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_CCINT0),
Mark A. Greer55c79a42009-06-03 18:36:54 -0700177 .flags = IORESOURCE_IRQ,
178 },
179 {
Peter Ujfalusid4cb7f42015-10-14 14:42:46 +0300180 .name = "edma3_ccerrint",
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100181 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_CCERRINT),
Mark A. Greer55c79a42009-06-03 18:36:54 -0700182 .flags = IORESOURCE_IRQ,
183 },
184};
185
Peter Ujfalusid4cb7f42015-10-14 14:42:46 +0300186static struct resource da850_edma1_resources[] = {
Sudhakar Rajashekhara3f995f22010-01-06 17:30:06 +0530187 {
Peter Ujfalusid4cb7f42015-10-14 14:42:46 +0300188 .name = "edma3_cc",
Sudhakar Rajashekhara3f995f22010-01-06 17:30:06 +0530189 .start = DA850_TPCC1_BASE,
190 .end = DA850_TPCC1_BASE + SZ_32K - 1,
191 .flags = IORESOURCE_MEM,
192 },
193 {
Peter Ujfalusid4cb7f42015-10-14 14:42:46 +0300194 .name = "edma3_tc0",
Sudhakar Rajashekhara3f995f22010-01-06 17:30:06 +0530195 .start = DA850_TPTC2_BASE,
196 .end = DA850_TPTC2_BASE + SZ_1K - 1,
197 .flags = IORESOURCE_MEM,
198 },
199 {
Peter Ujfalusid4cb7f42015-10-14 14:42:46 +0300200 .name = "edma3_ccint",
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100201 .start = DAVINCI_INTC_IRQ(IRQ_DA850_CCINT1),
Sudhakar Rajashekhara3f995f22010-01-06 17:30:06 +0530202 .flags = IORESOURCE_IRQ,
203 },
204 {
Peter Ujfalusid4cb7f42015-10-14 14:42:46 +0300205 .name = "edma3_ccerrint",
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100206 .start = DAVINCI_INTC_IRQ(IRQ_DA850_CCERRINT1),
Sudhakar Rajashekhara3f995f22010-01-06 17:30:06 +0530207 .flags = IORESOURCE_IRQ,
208 },
209};
210
Peter Ujfalusi7ab388e2015-10-14 14:42:51 +0300211static const struct platform_device_info da8xx_edma0_device __initconst = {
Mark A. Greer55c79a42009-06-03 18:36:54 -0700212 .name = "edma",
Peter Ujfalusid4cb7f42015-10-14 14:42:46 +0300213 .id = 0,
Peter Ujfalusicef5b0d2015-10-14 14:42:52 +0300214 .dma_mask = DMA_BIT_MASK(32),
Peter Ujfalusi7ab388e2015-10-14 14:42:51 +0300215 .res = da8xx_edma0_resources,
216 .num_res = ARRAY_SIZE(da8xx_edma0_resources),
217 .data = &da8xx_edma0_pdata,
218 .size_data = sizeof(da8xx_edma0_pdata),
Sudhakar Rajashekhara3f995f22010-01-06 17:30:06 +0530219};
220
Peter Ujfalusi7ab388e2015-10-14 14:42:51 +0300221static const struct platform_device_info da850_edma1_device __initconst = {
Sudhakar Rajashekhara3f995f22010-01-06 17:30:06 +0530222 .name = "edma",
Peter Ujfalusid4cb7f42015-10-14 14:42:46 +0300223 .id = 1,
Peter Ujfalusicef5b0d2015-10-14 14:42:52 +0300224 .dma_mask = DMA_BIT_MASK(32),
Peter Ujfalusi7ab388e2015-10-14 14:42:51 +0300225 .res = da850_edma1_resources,
226 .num_res = ARRAY_SIZE(da850_edma1_resources),
227 .data = &da850_edma1_pdata,
228 .size_data = sizeof(da850_edma1_pdata),
Mark A. Greer55c79a42009-06-03 18:36:54 -0700229};
230
Peter Ujfalusi1ce93002016-02-02 14:43:13 +0200231static const struct dma_slave_map da830_edma_map[] = {
232 { "davinci-mcasp.0", "rx", EDMA_FILTER_PARAM(0, 0) },
233 { "davinci-mcasp.0", "tx", EDMA_FILTER_PARAM(0, 1) },
234 { "davinci-mcasp.1", "rx", EDMA_FILTER_PARAM(0, 2) },
235 { "davinci-mcasp.1", "tx", EDMA_FILTER_PARAM(0, 3) },
236 { "davinci-mcasp.2", "rx", EDMA_FILTER_PARAM(0, 4) },
237 { "davinci-mcasp.2", "tx", EDMA_FILTER_PARAM(0, 5) },
238 { "spi_davinci.0", "rx", EDMA_FILTER_PARAM(0, 14) },
239 { "spi_davinci.0", "tx", EDMA_FILTER_PARAM(0, 15) },
240 { "da830-mmc.0", "rx", EDMA_FILTER_PARAM(0, 16) },
241 { "da830-mmc.0", "tx", EDMA_FILTER_PARAM(0, 17) },
242 { "spi_davinci.1", "rx", EDMA_FILTER_PARAM(0, 18) },
243 { "spi_davinci.1", "tx", EDMA_FILTER_PARAM(0, 19) },
244};
245
Rajashekhara, Sudhakara941c502010-06-29 11:35:14 +0530246int __init da830_register_edma(struct edma_rsv_info *rsv)
Mark A. Greer55c79a42009-06-03 18:36:54 -0700247{
Peter Ujfalusi7ab388e2015-10-14 14:42:51 +0300248 struct platform_device *edma_pdev;
249
Peter Ujfalusid4cb7f42015-10-14 14:42:46 +0300250 da8xx_edma0_pdata.rsv = rsv;
Sudhakar Rajashekhara3f995f22010-01-06 17:30:06 +0530251
Peter Ujfalusi1ce93002016-02-02 14:43:13 +0200252 da8xx_edma0_pdata.slave_map = da830_edma_map;
253 da8xx_edma0_pdata.slavecnt = ARRAY_SIZE(da830_edma_map);
254
Peter Ujfalusi7ab388e2015-10-14 14:42:51 +0300255 edma_pdev = platform_device_register_full(&da8xx_edma0_device);
Vasyl Gomonovycha8bc4f02017-11-28 00:03:33 +0100256 return PTR_ERR_OR_ZERO(edma_pdev);
Rajashekhara, Sudhakara941c502010-06-29 11:35:14 +0530257}
Sudhakar Rajashekhara3f995f22010-01-06 17:30:06 +0530258
Peter Ujfalusi1ce93002016-02-02 14:43:13 +0200259static const struct dma_slave_map da850_edma0_map[] = {
260 { "davinci-mcasp.0", "rx", EDMA_FILTER_PARAM(0, 0) },
261 { "davinci-mcasp.0", "tx", EDMA_FILTER_PARAM(0, 1) },
262 { "davinci-mcbsp.0", "rx", EDMA_FILTER_PARAM(0, 2) },
263 { "davinci-mcbsp.0", "tx", EDMA_FILTER_PARAM(0, 3) },
264 { "davinci-mcbsp.1", "rx", EDMA_FILTER_PARAM(0, 4) },
265 { "davinci-mcbsp.1", "tx", EDMA_FILTER_PARAM(0, 5) },
266 { "spi_davinci.0", "rx", EDMA_FILTER_PARAM(0, 14) },
267 { "spi_davinci.0", "tx", EDMA_FILTER_PARAM(0, 15) },
268 { "da830-mmc.0", "rx", EDMA_FILTER_PARAM(0, 16) },
269 { "da830-mmc.0", "tx", EDMA_FILTER_PARAM(0, 17) },
270 { "spi_davinci.1", "rx", EDMA_FILTER_PARAM(0, 18) },
271 { "spi_davinci.1", "tx", EDMA_FILTER_PARAM(0, 19) },
272};
273
274static const struct dma_slave_map da850_edma1_map[] = {
275 { "da830-mmc.1", "rx", EDMA_FILTER_PARAM(1, 28) },
276 { "da830-mmc.1", "tx", EDMA_FILTER_PARAM(1, 29) },
277};
278
Rajashekhara, Sudhakara941c502010-06-29 11:35:14 +0530279int __init da850_register_edma(struct edma_rsv_info *rsv[2])
280{
Peter Ujfalusi7ab388e2015-10-14 14:42:51 +0300281 struct platform_device *edma_pdev;
Peter Ujfalusid4cb7f42015-10-14 14:42:46 +0300282
Rajashekhara, Sudhakara941c502010-06-29 11:35:14 +0530283 if (rsv) {
Peter Ujfalusid4cb7f42015-10-14 14:42:46 +0300284 da8xx_edma0_pdata.rsv = rsv[0];
285 da850_edma1_pdata.rsv = rsv[1];
Rajashekhara, Sudhakara941c502010-06-29 11:35:14 +0530286 }
287
Peter Ujfalusi1ce93002016-02-02 14:43:13 +0200288 da8xx_edma0_pdata.slave_map = da850_edma0_map;
289 da8xx_edma0_pdata.slavecnt = ARRAY_SIZE(da850_edma0_map);
290
Peter Ujfalusi7ab388e2015-10-14 14:42:51 +0300291 edma_pdev = platform_device_register_full(&da8xx_edma0_device);
292 if (IS_ERR(edma_pdev)) {
Peter Ujfalusid4cb7f42015-10-14 14:42:46 +0300293 pr_warn("%s: Failed to register eDMA0\n", __func__);
Peter Ujfalusi7ab388e2015-10-14 14:42:51 +0300294 return PTR_ERR(edma_pdev);
Peter Ujfalusid4cb7f42015-10-14 14:42:46 +0300295 }
Peter Ujfalusi1ce93002016-02-02 14:43:13 +0200296
297 da850_edma1_pdata.slave_map = da850_edma1_map;
298 da850_edma1_pdata.slavecnt = ARRAY_SIZE(da850_edma1_map);
299
Peter Ujfalusi7ab388e2015-10-14 14:42:51 +0300300 edma_pdev = platform_device_register_full(&da850_edma1_device);
Vasyl Gomonovycha8bc4f02017-11-28 00:03:33 +0100301 return PTR_ERR_OR_ZERO(edma_pdev);
Mark A. Greer55c79a42009-06-03 18:36:54 -0700302}
303
304static struct resource da8xx_i2c_resources0[] = {
305 {
306 .start = DA8XX_I2C0_BASE,
307 .end = DA8XX_I2C0_BASE + SZ_4K - 1,
308 .flags = IORESOURCE_MEM,
309 },
310 {
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100311 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_I2CINT0),
312 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_I2CINT0),
Mark A. Greer55c79a42009-06-03 18:36:54 -0700313 .flags = IORESOURCE_IRQ,
314 },
315};
316
317static struct platform_device da8xx_i2c_device0 = {
318 .name = "i2c_davinci",
319 .id = 1,
320 .num_resources = ARRAY_SIZE(da8xx_i2c_resources0),
321 .resource = da8xx_i2c_resources0,
322};
323
324static struct resource da8xx_i2c_resources1[] = {
325 {
326 .start = DA8XX_I2C1_BASE,
327 .end = DA8XX_I2C1_BASE + SZ_4K - 1,
328 .flags = IORESOURCE_MEM,
329 },
330 {
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100331 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_I2CINT1),
332 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_I2CINT1),
Mark A. Greer55c79a42009-06-03 18:36:54 -0700333 .flags = IORESOURCE_IRQ,
334 },
335};
336
337static struct platform_device da8xx_i2c_device1 = {
338 .name = "i2c_davinci",
339 .id = 2,
340 .num_resources = ARRAY_SIZE(da8xx_i2c_resources1),
341 .resource = da8xx_i2c_resources1,
342};
343
344int __init da8xx_register_i2c(int instance,
345 struct davinci_i2c_platform_data *pdata)
346{
347 struct platform_device *pdev;
348
349 if (instance == 0)
350 pdev = &da8xx_i2c_device0;
351 else if (instance == 1)
352 pdev = &da8xx_i2c_device1;
353 else
354 return -EINVAL;
355
356 pdev->dev.platform_data = pdata;
357 return platform_device_register(pdev);
358}
359
360static struct resource da8xx_watchdog_resources[] = {
361 {
362 .start = DA8XX_WDOG_BASE,
363 .end = DA8XX_WDOG_BASE + SZ_4K - 1,
364 .flags = IORESOURCE_MEM,
365 },
366};
367
Kumar, Anil19c7c0d2013-02-06 09:30:04 +0530368static struct platform_device da8xx_wdt_device = {
Ivan Khoronzhuk84374812013-11-27 15:31:53 +0200369 .name = "davinci-wdt",
Mark A. Greer55c79a42009-06-03 18:36:54 -0700370 .id = -1,
371 .num_resources = ARRAY_SIZE(da8xx_watchdog_resources),
372 .resource = da8xx_watchdog_resources,
373};
374
375int __init da8xx_register_watchdog(void)
376{
Cyril Chemparathyc78a5bc2010-05-01 18:38:28 -0400377 return platform_device_register(&da8xx_wdt_device);
Mark A. Greer55c79a42009-06-03 18:36:54 -0700378}
379
380static struct resource da8xx_emac_resources[] = {
381 {
382 .start = DA8XX_EMAC_CPPI_PORT_BASE,
Cyril Chemparathyd22960c2010-09-15 10:11:22 -0400383 .end = DA8XX_EMAC_CPPI_PORT_BASE + SZ_16K - 1,
Mark A. Greer55c79a42009-06-03 18:36:54 -0700384 .flags = IORESOURCE_MEM,
385 },
386 {
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100387 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_C0_RX_THRESH_PULSE),
388 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_C0_RX_THRESH_PULSE),
Mark A. Greer55c79a42009-06-03 18:36:54 -0700389 .flags = IORESOURCE_IRQ,
390 },
391 {
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100392 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_C0_RX_PULSE),
393 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_C0_RX_PULSE),
Mark A. Greer55c79a42009-06-03 18:36:54 -0700394 .flags = IORESOURCE_IRQ,
395 },
396 {
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100397 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_C0_TX_PULSE),
398 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_C0_TX_PULSE),
Mark A. Greer55c79a42009-06-03 18:36:54 -0700399 .flags = IORESOURCE_IRQ,
400 },
401 {
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100402 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_C0_MISC_PULSE),
403 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_C0_MISC_PULSE),
Mark A. Greer55c79a42009-06-03 18:36:54 -0700404 .flags = IORESOURCE_IRQ,
405 },
406};
407
408struct emac_platform_data da8xx_emac_pdata = {
409 .ctrl_reg_offset = DA8XX_EMAC_CTRL_REG_OFFSET,
410 .ctrl_mod_reg_offset = DA8XX_EMAC_MOD_REG_OFFSET,
411 .ctrl_ram_offset = DA8XX_EMAC_RAM_OFFSET,
Mark A. Greer55c79a42009-06-03 18:36:54 -0700412 .ctrl_ram_size = DA8XX_EMAC_CTRL_RAM_SIZE,
413 .version = EMAC_VERSION_2,
414};
415
416static struct platform_device da8xx_emac_device = {
417 .name = "davinci_emac",
418 .id = 1,
419 .dev = {
420 .platform_data = &da8xx_emac_pdata,
421 },
422 .num_resources = ARRAY_SIZE(da8xx_emac_resources),
423 .resource = da8xx_emac_resources,
424};
425
Cyril Chemparathyd22960c2010-09-15 10:11:22 -0400426static struct resource da8xx_mdio_resources[] = {
427 {
428 .start = DA8XX_EMAC_MDIO_BASE,
429 .end = DA8XX_EMAC_MDIO_BASE + SZ_4K - 1,
430 .flags = IORESOURCE_MEM,
431 },
432};
433
434static struct platform_device da8xx_mdio_device = {
435 .name = "davinci_mdio",
436 .id = 0,
437 .num_resources = ARRAY_SIZE(da8xx_mdio_resources),
438 .resource = da8xx_mdio_resources,
439};
440
Mark A. Greer31f53cf2009-08-28 15:02:54 -0700441int __init da8xx_register_emac(void)
442{
Cyril Chemparathyd22960c2010-09-15 10:11:22 -0400443 int ret;
444
445 ret = platform_device_register(&da8xx_mdio_device);
446 if (ret < 0)
447 return ret;
Lad, Prabhakar46c18332013-08-15 11:31:33 +0530448
449 return platform_device_register(&da8xx_emac_device);
Mark A. Greer31f53cf2009-08-28 15:02:54 -0700450}
451
Chaithrika U Se33ef5e2009-08-11 17:01:59 -0400452static struct resource da830_mcasp1_resources[] = {
453 {
Peter Ujfalusiee880db2013-11-13 16:48:17 +0200454 .name = "mpu",
Chaithrika U Se33ef5e2009-08-11 17:01:59 -0400455 .start = DAVINCI_DA830_MCASP1_REG_BASE,
456 .end = DAVINCI_DA830_MCASP1_REG_BASE + (SZ_1K * 12) - 1,
457 .flags = IORESOURCE_MEM,
458 },
459 /* TX event */
460 {
Peter Ujfalusi184981d2015-03-12 10:06:25 +0200461 .name = "tx",
Chaithrika U Se33ef5e2009-08-11 17:01:59 -0400462 .start = DAVINCI_DA830_DMA_MCASP1_AXEVT,
463 .end = DAVINCI_DA830_DMA_MCASP1_AXEVT,
464 .flags = IORESOURCE_DMA,
465 },
466 /* RX event */
467 {
Peter Ujfalusi184981d2015-03-12 10:06:25 +0200468 .name = "rx",
Chaithrika U Se33ef5e2009-08-11 17:01:59 -0400469 .start = DAVINCI_DA830_DMA_MCASP1_AREVT,
470 .end = DAVINCI_DA830_DMA_MCASP1_AREVT,
471 .flags = IORESOURCE_DMA,
472 },
Peter Ujfalusi80f7d0e2015-03-12 10:06:26 +0200473 {
474 .name = "common",
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100475 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_MCASPINT),
Peter Ujfalusi80f7d0e2015-03-12 10:06:26 +0200476 .flags = IORESOURCE_IRQ,
477 },
Chaithrika U Se33ef5e2009-08-11 17:01:59 -0400478};
479
480static struct platform_device da830_mcasp1_device = {
481 .name = "davinci-mcasp",
482 .id = 1,
483 .num_resources = ARRAY_SIZE(da830_mcasp1_resources),
484 .resource = da830_mcasp1_resources,
485};
486
Peter Ujfalusi3775c312015-03-12 10:06:28 +0200487static struct resource da830_mcasp2_resources[] = {
488 {
489 .name = "mpu",
490 .start = DAVINCI_DA830_MCASP2_REG_BASE,
491 .end = DAVINCI_DA830_MCASP2_REG_BASE + (SZ_1K * 12) - 1,
492 .flags = IORESOURCE_MEM,
493 },
494 /* TX event */
495 {
496 .name = "tx",
497 .start = DAVINCI_DA830_DMA_MCASP2_AXEVT,
498 .end = DAVINCI_DA830_DMA_MCASP2_AXEVT,
499 .flags = IORESOURCE_DMA,
500 },
501 /* RX event */
502 {
503 .name = "rx",
504 .start = DAVINCI_DA830_DMA_MCASP2_AREVT,
505 .end = DAVINCI_DA830_DMA_MCASP2_AREVT,
506 .flags = IORESOURCE_DMA,
507 },
508 {
509 .name = "common",
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100510 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_MCASPINT),
Peter Ujfalusi3775c312015-03-12 10:06:28 +0200511 .flags = IORESOURCE_IRQ,
512 },
513};
514
515static struct platform_device da830_mcasp2_device = {
516 .name = "davinci-mcasp",
517 .id = 2,
518 .num_resources = ARRAY_SIZE(da830_mcasp2_resources),
519 .resource = da830_mcasp2_resources,
520};
521
Chaithrika U S491214e2009-08-11 17:03:25 -0400522static struct resource da850_mcasp_resources[] = {
523 {
Peter Ujfalusiee880db2013-11-13 16:48:17 +0200524 .name = "mpu",
Chaithrika U S491214e2009-08-11 17:03:25 -0400525 .start = DAVINCI_DA8XX_MCASP0_REG_BASE,
526 .end = DAVINCI_DA8XX_MCASP0_REG_BASE + (SZ_1K * 12) - 1,
527 .flags = IORESOURCE_MEM,
528 },
529 /* TX event */
530 {
Peter Ujfalusi184981d2015-03-12 10:06:25 +0200531 .name = "tx",
Chaithrika U S491214e2009-08-11 17:03:25 -0400532 .start = DAVINCI_DA8XX_DMA_MCASP0_AXEVT,
533 .end = DAVINCI_DA8XX_DMA_MCASP0_AXEVT,
534 .flags = IORESOURCE_DMA,
535 },
536 /* RX event */
537 {
Peter Ujfalusi184981d2015-03-12 10:06:25 +0200538 .name = "rx",
Chaithrika U S491214e2009-08-11 17:03:25 -0400539 .start = DAVINCI_DA8XX_DMA_MCASP0_AREVT,
540 .end = DAVINCI_DA8XX_DMA_MCASP0_AREVT,
541 .flags = IORESOURCE_DMA,
542 },
Peter Ujfalusi80f7d0e2015-03-12 10:06:26 +0200543 {
544 .name = "common",
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100545 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_MCASPINT),
Peter Ujfalusi80f7d0e2015-03-12 10:06:26 +0200546 .flags = IORESOURCE_IRQ,
547 },
Chaithrika U S491214e2009-08-11 17:03:25 -0400548};
549
550static struct platform_device da850_mcasp_device = {
551 .name = "davinci-mcasp",
552 .id = 0,
553 .num_resources = ARRAY_SIZE(da850_mcasp_resources),
554 .resource = da850_mcasp_resources,
555};
556
Mark A. Greerb8864aa2009-08-28 15:05:02 -0700557void __init da8xx_register_mcasp(int id, struct snd_platform_data *pdata)
Chaithrika U Se33ef5e2009-08-11 17:01:59 -0400558{
Peter Ujfalusic96aacb2015-03-12 10:06:27 +0200559 struct platform_device *pdev;
560
561 switch (id) {
562 case 0:
563 /* Valid for DA830/OMAP-L137 or DA850/OMAP-L138 */
564 pdev = &da850_mcasp_device;
565 break;
566 case 1:
567 /* Valid for DA830/OMAP-L137 only */
568 if (!cpu_is_davinci_da830())
569 return;
570 pdev = &da830_mcasp1_device;
571 break;
Peter Ujfalusi3775c312015-03-12 10:06:28 +0200572 case 2:
573 /* Valid for DA830/OMAP-L137 only */
574 if (!cpu_is_davinci_da830())
575 return;
576 pdev = &da830_mcasp2_device;
577 break;
Peter Ujfalusic96aacb2015-03-12 10:06:27 +0200578 default:
579 return;
Chaithrika U Se33ef5e2009-08-11 17:01:59 -0400580 }
Peter Ujfalusic96aacb2015-03-12 10:06:27 +0200581
582 pdev->dev.platform_data = pdata;
583 platform_device_register(pdev);
Chaithrika U Se33ef5e2009-08-11 17:01:59 -0400584}
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400585
Matt Porter8e0d72d2012-10-08 09:53:08 -0400586static struct resource da8xx_pruss_resources[] = {
587 {
588 .start = DA8XX_PRUSS_MEM_BASE,
589 .end = DA8XX_PRUSS_MEM_BASE + 0xFFFF,
590 .flags = IORESOURCE_MEM,
591 },
592 {
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100593 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT0),
594 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT0),
Matt Porter8e0d72d2012-10-08 09:53:08 -0400595 .flags = IORESOURCE_IRQ,
596 },
597 {
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100598 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT1),
599 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT1),
Matt Porter8e0d72d2012-10-08 09:53:08 -0400600 .flags = IORESOURCE_IRQ,
601 },
602 {
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100603 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT2),
604 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT2),
Matt Porter8e0d72d2012-10-08 09:53:08 -0400605 .flags = IORESOURCE_IRQ,
606 },
607 {
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100608 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT3),
609 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT3),
Matt Porter8e0d72d2012-10-08 09:53:08 -0400610 .flags = IORESOURCE_IRQ,
611 },
612 {
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100613 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT4),
614 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT4),
Matt Porter8e0d72d2012-10-08 09:53:08 -0400615 .flags = IORESOURCE_IRQ,
616 },
617 {
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100618 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT5),
619 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT5),
Matt Porter8e0d72d2012-10-08 09:53:08 -0400620 .flags = IORESOURCE_IRQ,
621 },
622 {
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100623 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT6),
624 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT6),
Matt Porter8e0d72d2012-10-08 09:53:08 -0400625 .flags = IORESOURCE_IRQ,
626 },
627 {
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100628 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT7),
629 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT7),
Matt Porter8e0d72d2012-10-08 09:53:08 -0400630 .flags = IORESOURCE_IRQ,
631 },
632};
633
634static struct uio_pruss_pdata da8xx_uio_pruss_pdata = {
635 .pintc_base = 0x4000,
636};
637
638static struct platform_device da8xx_uio_pruss_dev = {
639 .name = "pruss_uio",
640 .id = -1,
641 .num_resources = ARRAY_SIZE(da8xx_pruss_resources),
642 .resource = da8xx_pruss_resources,
643 .dev = {
644 .coherent_dma_mask = DMA_BIT_MASK(32),
645 .platform_data = &da8xx_uio_pruss_pdata,
646 }
647};
648
649int __init da8xx_register_uio_pruss(void)
650{
651 da8xx_uio_pruss_pdata.sram_pool = sram_get_gen_pool();
652 return platform_device_register(&da8xx_uio_pruss_dev);
653}
654
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400655static struct lcd_ctrl_config lcd_cfg = {
Manjunathappa, Prakash3b43ad22012-10-16 10:23:16 +0530656 .panel_shade = COLOR_ACTIVE,
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400657 .bpp = 16,
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400658};
659
Mark A. Greerb9e63422009-09-15 18:14:19 -0700660struct da8xx_lcdc_platform_data sharp_lcd035q3dg01_pdata = {
661 .manu_name = "sharp",
662 .controller_data = &lcd_cfg,
663 .type = "Sharp_LCD035Q3DG01",
664};
665
666struct da8xx_lcdc_platform_data sharp_lk043t1dg01_pdata = {
667 .manu_name = "sharp",
668 .controller_data = &lcd_cfg,
669 .type = "Sharp_LK043T1DG01",
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400670};
671
672static struct resource da8xx_lcdc_resources[] = {
673 [0] = { /* registers */
674 .start = DA8XX_LCD_CNTRL_BASE,
675 .end = DA8XX_LCD_CNTRL_BASE + SZ_4K - 1,
676 .flags = IORESOURCE_MEM,
677 },
678 [1] = { /* interrupt */
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100679 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_LCDINT),
680 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_LCDINT),
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400681 .flags = IORESOURCE_IRQ,
682 },
683};
684
Mark A. Greerb9e63422009-09-15 18:14:19 -0700685static struct platform_device da8xx_lcdc_device = {
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400686 .name = "da8xx_lcdc",
687 .id = 0,
688 .num_resources = ARRAY_SIZE(da8xx_lcdc_resources),
689 .resource = da8xx_lcdc_resources,
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400690};
691
Mark A. Greerb9e63422009-09-15 18:14:19 -0700692int __init da8xx_register_lcdc(struct da8xx_lcdc_platform_data *pdata)
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400693{
Mark A. Greerb9e63422009-09-15 18:14:19 -0700694 da8xx_lcdc_device.dev.platform_data = pdata;
695 return platform_device_register(&da8xx_lcdc_device);
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400696}
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -0400697
KV Sujithf606d382013-08-18 10:48:59 +0530698static struct resource da8xx_gpio_resources[] = {
699 { /* registers */
700 .start = DA8XX_GPIO_BASE,
701 .end = DA8XX_GPIO_BASE + SZ_4K - 1,
702 .flags = IORESOURCE_MEM,
703 },
704 { /* interrupt */
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100705 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO0),
706 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO0),
Bartosz Golaszewski58a0afb2018-11-21 10:35:12 +0100707 .flags = IORESOURCE_IRQ,
708 },
709 {
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100710 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO1),
711 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO1),
Bartosz Golaszewski58a0afb2018-11-21 10:35:12 +0100712 .flags = IORESOURCE_IRQ,
713 },
714 {
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100715 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO2),
716 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO2),
Bartosz Golaszewski58a0afb2018-11-21 10:35:12 +0100717 .flags = IORESOURCE_IRQ,
718 },
719 {
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100720 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO3),
721 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO3),
Bartosz Golaszewski58a0afb2018-11-21 10:35:12 +0100722 .flags = IORESOURCE_IRQ,
723 },
724 {
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100725 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO4),
726 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO4),
Bartosz Golaszewski58a0afb2018-11-21 10:35:12 +0100727 .flags = IORESOURCE_IRQ,
728 },
729 {
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100730 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO5),
731 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO5),
Bartosz Golaszewski58a0afb2018-11-21 10:35:12 +0100732 .flags = IORESOURCE_IRQ,
733 },
734 {
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100735 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO6),
736 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO6),
Bartosz Golaszewski58a0afb2018-11-21 10:35:12 +0100737 .flags = IORESOURCE_IRQ,
738 },
739 {
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100740 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO7),
741 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO7),
Bartosz Golaszewski58a0afb2018-11-21 10:35:12 +0100742 .flags = IORESOURCE_IRQ,
743 },
744 {
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100745 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO8),
746 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO8),
KV Sujithf606d382013-08-18 10:48:59 +0530747 .flags = IORESOURCE_IRQ,
748 },
749};
750
751static struct platform_device da8xx_gpio_device = {
752 .name = "davinci_gpio",
753 .id = -1,
754 .num_resources = ARRAY_SIZE(da8xx_gpio_resources),
755 .resource = da8xx_gpio_resources,
756};
757
758int __init da8xx_register_gpio(void *pdata)
759{
760 da8xx_gpio_device.dev.platform_data = pdata;
761 return platform_device_register(&da8xx_gpio_device);
762}
763
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -0400764static struct resource da8xx_mmcsd0_resources[] = {
765 { /* registers */
766 .start = DA8XX_MMCSD0_BASE,
767 .end = DA8XX_MMCSD0_BASE + SZ_4K - 1,
768 .flags = IORESOURCE_MEM,
769 },
770 { /* interrupt */
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100771 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_MMCSDINT0),
772 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_MMCSDINT0),
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -0400773 .flags = IORESOURCE_IRQ,
774 },
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -0400775};
776
777static struct platform_device da8xx_mmcsd0_device = {
Manjunathappa, Prakashd7ca4c72013-03-28 18:41:59 +0530778 .name = "da830-mmc",
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -0400779 .id = 0,
780 .num_resources = ARRAY_SIZE(da8xx_mmcsd0_resources),
781 .resource = da8xx_mmcsd0_resources,
782};
783
784int __init da8xx_register_mmcsd0(struct davinci_mmc_config *config)
785{
786 da8xx_mmcsd0_device.dev.platform_data = config;
787 return platform_device_register(&da8xx_mmcsd0_device);
788}
Mark A. Greerc51df702009-09-15 18:15:54 -0700789
Juha Kuikkab8241ae2010-08-26 12:40:47 -0700790#ifdef CONFIG_ARCH_DAVINCI_DA850
791static struct resource da850_mmcsd1_resources[] = {
792 { /* registers */
793 .start = DA850_MMCSD1_BASE,
794 .end = DA850_MMCSD1_BASE + SZ_4K - 1,
795 .flags = IORESOURCE_MEM,
796 },
797 { /* interrupt */
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100798 .start = DAVINCI_INTC_IRQ(IRQ_DA850_MMCSDINT0_1),
799 .end = DAVINCI_INTC_IRQ(IRQ_DA850_MMCSDINT0_1),
Juha Kuikkab8241ae2010-08-26 12:40:47 -0700800 .flags = IORESOURCE_IRQ,
801 },
Juha Kuikkab8241ae2010-08-26 12:40:47 -0700802};
803
804static struct platform_device da850_mmcsd1_device = {
Manjunathappa, Prakashd7ca4c72013-03-28 18:41:59 +0530805 .name = "da830-mmc",
Juha Kuikkab8241ae2010-08-26 12:40:47 -0700806 .id = 1,
807 .num_resources = ARRAY_SIZE(da850_mmcsd1_resources),
808 .resource = da850_mmcsd1_resources,
809};
810
811int __init da850_register_mmcsd1(struct davinci_mmc_config *config)
812{
813 da850_mmcsd1_device.dev.platform_data = config;
814 return platform_device_register(&da850_mmcsd1_device);
815}
816#endif
817
Robert Tivy5c71d612013-03-28 18:41:46 -0700818static struct resource da8xx_rproc_resources[] = {
819 { /* DSP boot address */
Suman Anna6724a052017-05-16 17:13:46 -0500820 .name = "host1cfg",
Robert Tivy5c71d612013-03-28 18:41:46 -0700821 .start = DA8XX_SYSCFG0_BASE + DA8XX_HOST1CFG_REG,
822 .end = DA8XX_SYSCFG0_BASE + DA8XX_HOST1CFG_REG + 3,
823 .flags = IORESOURCE_MEM,
824 },
825 { /* DSP interrupt registers */
Suman Anna6724a052017-05-16 17:13:46 -0500826 .name = "chipsig",
Robert Tivy5c71d612013-03-28 18:41:46 -0700827 .start = DA8XX_SYSCFG0_BASE + DA8XX_CHIPSIG_REG,
828 .end = DA8XX_SYSCFG0_BASE + DA8XX_CHIPSIG_REG + 7,
829 .flags = IORESOURCE_MEM,
830 },
Suman Anna14ff86b2017-05-16 17:13:47 -0500831 { /* DSP L2 RAM */
832 .name = "l2sram",
833 .start = DA8XX_DSP_L2_RAM_BASE,
834 .end = DA8XX_DSP_L2_RAM_BASE + SZ_256K - 1,
835 .flags = IORESOURCE_MEM,
836 },
837 { /* DSP L1P RAM */
838 .name = "l1pram",
839 .start = DA8XX_DSP_L1P_RAM_BASE,
840 .end = DA8XX_DSP_L1P_RAM_BASE + SZ_32K - 1,
841 .flags = IORESOURCE_MEM,
842 },
843 { /* DSP L1D RAM */
844 .name = "l1dram",
845 .start = DA8XX_DSP_L1D_RAM_BASE,
846 .end = DA8XX_DSP_L1D_RAM_BASE + SZ_32K - 1,
847 .flags = IORESOURCE_MEM,
848 },
Robert Tivy5c71d612013-03-28 18:41:46 -0700849 { /* dsp irq */
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100850 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_CHIPINT0),
851 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_CHIPINT0),
Robert Tivy5c71d612013-03-28 18:41:46 -0700852 .flags = IORESOURCE_IRQ,
853 },
854};
855
856static struct platform_device da8xx_dsp = {
857 .name = "davinci-rproc",
858 .dev = {
859 .coherent_dma_mask = DMA_BIT_MASK(32),
860 },
861 .num_resources = ARRAY_SIZE(da8xx_rproc_resources),
862 .resource = da8xx_rproc_resources,
863};
864
Suman Annaf97f0352017-05-16 17:13:45 -0500865static bool rproc_mem_inited __initdata;
866
Robert Tivy5c71d612013-03-28 18:41:46 -0700867#if IS_ENABLED(CONFIG_DA8XX_REMOTEPROC)
868
869static phys_addr_t rproc_base __initdata;
870static unsigned long rproc_size __initdata;
871
872static int __init early_rproc_mem(char *p)
873{
874 char *endp;
875
876 if (p == NULL)
877 return 0;
878
879 rproc_size = memparse(p, &endp);
880 if (*endp == '@')
881 rproc_base = memparse(endp + 1, NULL);
882
883 return 0;
884}
885early_param("rproc_mem", early_rproc_mem);
886
887void __init da8xx_rproc_reserve_cma(void)
888{
889 int ret;
890
891 if (!rproc_base || !rproc_size) {
892 pr_err("%s: 'rproc_mem=nn@address' badly specified\n"
893 " 'nn' and 'address' must both be non-zero\n",
894 __func__);
895
896 return;
897 }
898
899 pr_info("%s: reserving 0x%lx @ 0x%lx...\n",
900 __func__, rproc_size, (unsigned long)rproc_base);
901
902 ret = dma_declare_contiguous(&da8xx_dsp.dev, rproc_size, rproc_base, 0);
903 if (ret)
904 pr_err("%s: dma_declare_contiguous failed %d\n", __func__, ret);
Suman Annaf97f0352017-05-16 17:13:45 -0500905 else
906 rproc_mem_inited = true;
Robert Tivy5c71d612013-03-28 18:41:46 -0700907}
908
909#else
910
911void __init da8xx_rproc_reserve_cma(void)
912{
913}
914
915#endif
916
917int __init da8xx_register_rproc(void)
918{
919 int ret;
920
Suman Annaf97f0352017-05-16 17:13:45 -0500921 if (!rproc_mem_inited) {
922 pr_warn("%s: memory not reserved for DSP, not registering DSP device\n",
923 __func__);
924 return -ENOMEM;
925 }
926
Robert Tivy5c71d612013-03-28 18:41:46 -0700927 ret = platform_device_register(&da8xx_dsp);
928 if (ret)
929 pr_err("%s: can't register DSP device: %d\n", __func__, ret);
930
931 return ret;
932};
933
Mark A. Greerc51df702009-09-15 18:15:54 -0700934static struct resource da8xx_rtc_resources[] = {
935 {
936 .start = DA8XX_RTC_BASE,
937 .end = DA8XX_RTC_BASE + SZ_4K - 1,
938 .flags = IORESOURCE_MEM,
939 },
940 { /* timer irq */
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100941 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_RTC),
942 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_RTC),
Mark A. Greerc51df702009-09-15 18:15:54 -0700943 .flags = IORESOURCE_IRQ,
944 },
945 { /* alarm irq */
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +0100946 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_RTC),
947 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_RTC),
Mark A. Greerc51df702009-09-15 18:15:54 -0700948 .flags = IORESOURCE_IRQ,
949 },
950};
951
952static struct platform_device da8xx_rtc_device = {
Afzal Mohammed852168c2012-12-17 16:02:13 -0800953 .name = "da830-rtc",
Mark A. Greerc51df702009-09-15 18:15:54 -0700954 .id = -1,
955 .num_resources = ARRAY_SIZE(da8xx_rtc_resources),
956 .resource = da8xx_rtc_resources,
957};
958
959int da8xx_register_rtc(void)
960{
Hebbar Gururaja79eb1632013-07-03 14:17:03 +0530961 return platform_device_register(&da8xx_rtc_device);
Mark A. Greerc51df702009-09-15 18:15:54 -0700962}
Sekhar Nori1960e692009-10-22 15:12:14 +0530963
Sekhar Nori948c66d2009-11-16 17:21:37 +0530964static void __iomem *da8xx_ddr2_ctlr_base;
965void __iomem * __init da8xx_get_mem_ctlr(void)
966{
967 if (da8xx_ddr2_ctlr_base)
968 return da8xx_ddr2_ctlr_base;
969
970 da8xx_ddr2_ctlr_base = ioremap(DA8XX_DDR2_CTL_BASE, SZ_32K);
971 if (!da8xx_ddr2_ctlr_base)
Robert Tivyd2e0c182013-01-10 16:23:20 -0800972 pr_warn("%s: Unable to map DDR2 controller", __func__);
Sekhar Nori948c66d2009-11-16 17:21:37 +0530973
974 return da8xx_ddr2_ctlr_base;
975}
976
Sekhar Nori1960e692009-10-22 15:12:14 +0530977static struct resource da8xx_cpuidle_resources[] = {
978 {
979 .start = DA8XX_DDR2_CTL_BASE,
980 .end = DA8XX_DDR2_CTL_BASE + SZ_32K - 1,
981 .flags = IORESOURCE_MEM,
982 },
983};
984
985/* DA8XX devices support DDR2 power down */
986static struct davinci_cpuidle_config da8xx_cpuidle_pdata = {
987 .ddr2_pdown = 1,
988};
989
990
991static struct platform_device da8xx_cpuidle_device = {
992 .name = "cpuidle-davinci",
993 .num_resources = ARRAY_SIZE(da8xx_cpuidle_resources),
994 .resource = da8xx_cpuidle_resources,
995 .dev = {
996 .platform_data = &da8xx_cpuidle_pdata,
997 },
998};
999
1000int __init da8xx_register_cpuidle(void)
1001{
Sekhar Nori948c66d2009-11-16 17:21:37 +05301002 da8xx_cpuidle_pdata.ddr2_ctlr_base = da8xx_get_mem_ctlr();
1003
Sekhar Nori1960e692009-10-22 15:12:14 +05301004 return platform_device_register(&da8xx_cpuidle_device);
1005}
Michael Williamson54ce6882011-02-24 10:18:28 +05301006
1007static struct resource da8xx_spi0_resources[] = {
1008 [0] = {
1009 .start = DA8XX_SPI0_BASE,
1010 .end = DA8XX_SPI0_BASE + SZ_4K - 1,
1011 .flags = IORESOURCE_MEM,
1012 },
1013 [1] = {
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +01001014 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_SPINT0),
1015 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_SPINT0),
Michael Williamson54ce6882011-02-24 10:18:28 +05301016 .flags = IORESOURCE_IRQ,
1017 },
Michael Williamson54ce6882011-02-24 10:18:28 +05301018};
1019
1020static struct resource da8xx_spi1_resources[] = {
1021 [0] = {
Sergei Shtylyov9e7d24f2011-04-06 17:17:21 +00001022 .start = DA830_SPI1_BASE,
1023 .end = DA830_SPI1_BASE + SZ_4K - 1,
Michael Williamson54ce6882011-02-24 10:18:28 +05301024 .flags = IORESOURCE_MEM,
1025 },
1026 [1] = {
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +01001027 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_SPINT1),
1028 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_SPINT1),
Michael Williamson54ce6882011-02-24 10:18:28 +05301029 .flags = IORESOURCE_IRQ,
1030 },
Michael Williamson54ce6882011-02-24 10:18:28 +05301031};
1032
Vivien Didelot02736122012-09-10 20:29:13 -04001033static struct davinci_spi_platform_data da8xx_spi_pdata[] = {
Michael Williamson54ce6882011-02-24 10:18:28 +05301034 [0] = {
1035 .version = SPI_VERSION_2,
1036 .intr_line = 1,
1037 .dma_event_q = EVENTQ_0,
Franklin S Cooper Jr1b0838b2015-08-12 08:26:19 -05001038 .prescaler_limit = 2,
Michael Williamson54ce6882011-02-24 10:18:28 +05301039 },
1040 [1] = {
1041 .version = SPI_VERSION_2,
1042 .intr_line = 1,
1043 .dma_event_q = EVENTQ_0,
Franklin S Cooper Jr1b0838b2015-08-12 08:26:19 -05001044 .prescaler_limit = 2,
Michael Williamson54ce6882011-02-24 10:18:28 +05301045 },
1046};
1047
1048static struct platform_device da8xx_spi_device[] = {
1049 [0] = {
1050 .name = "spi_davinci",
1051 .id = 0,
1052 .num_resources = ARRAY_SIZE(da8xx_spi0_resources),
1053 .resource = da8xx_spi0_resources,
1054 .dev = {
1055 .platform_data = &da8xx_spi_pdata[0],
1056 },
1057 },
1058 [1] = {
1059 .name = "spi_davinci",
1060 .id = 1,
1061 .num_resources = ARRAY_SIZE(da8xx_spi1_resources),
1062 .resource = da8xx_spi1_resources,
1063 .dev = {
1064 .platform_data = &da8xx_spi_pdata[1],
1065 },
1066 },
1067};
1068
Vivien Didelot02736122012-09-10 20:29:13 -04001069int __init da8xx_register_spi_bus(int instance, unsigned num_chipselect)
Michael Williamson54ce6882011-02-24 10:18:28 +05301070{
Michael Williamson54ce6882011-02-24 10:18:28 +05301071 if (instance < 0 || instance > 1)
1072 return -EINVAL;
1073
Vivien Didelot02736122012-09-10 20:29:13 -04001074 da8xx_spi_pdata[instance].num_chipselect = num_chipselect;
Michael Williamson54ce6882011-02-24 10:18:28 +05301075
Sergei Shtylyov9e7d24f2011-04-06 17:17:21 +00001076 if (instance == 1 && cpu_is_davinci_da850()) {
1077 da8xx_spi1_resources[0].start = DA850_SPI1_BASE;
1078 da8xx_spi1_resources[0].end = DA850_SPI1_BASE + SZ_4K - 1;
1079 }
1080
Michael Williamson54ce6882011-02-24 10:18:28 +05301081 return platform_device_register(&da8xx_spi_device[instance]);
1082}
Sekhar Noricbb2c962011-07-06 06:01:23 +00001083
1084#ifdef CONFIG_ARCH_DAVINCI_DA850
David Lechneraa1da332018-05-18 11:48:14 -05001085int __init da850_register_sata_refclk(int rate)
1086{
1087 struct clk *clk;
1088
1089 clk = clk_register_fixed_rate(NULL, "sata_refclk", NULL, 0, rate);
1090 if (IS_ERR(clk))
1091 return PTR_ERR(clk);
1092
1093 return clk_register_clkdev(clk, "refclk", "ahci_da850");
1094}
Bartosz Golaszewski00bacfb2017-01-30 11:02:03 +01001095
Sekhar Noricbb2c962011-07-06 06:01:23 +00001096static struct resource da850_sata_resources[] = {
1097 {
1098 .start = DA850_SATA_BASE,
1099 .end = DA850_SATA_BASE + 0x1fff,
1100 .flags = IORESOURCE_MEM,
1101 },
1102 {
Bartlomiej Zolnierkiewicz080c4922014-03-25 19:51:41 +01001103 .start = DA8XX_SYSCFG1_BASE + DA8XX_PWRDN_REG,
1104 .end = DA8XX_SYSCFG1_BASE + DA8XX_PWRDN_REG + 0x3,
1105 .flags = IORESOURCE_MEM,
1106 },
1107 {
Bartosz Golaszewskia98ca732019-02-14 15:52:01 +01001108 .start = DAVINCI_INTC_IRQ(IRQ_DA850_SATAINT),
Sekhar Noricbb2c962011-07-06 06:01:23 +00001109 .flags = IORESOURCE_IRQ,
1110 },
1111};
1112
Sekhar Noricbb2c962011-07-06 06:01:23 +00001113static u64 da850_sata_dmamask = DMA_BIT_MASK(32);
1114
1115static struct platform_device da850_sata_device = {
Bartlomiej Zolnierkiewicz080c4922014-03-25 19:51:41 +01001116 .name = "ahci_da850",
Sekhar Noricbb2c962011-07-06 06:01:23 +00001117 .id = -1,
1118 .dev = {
Sekhar Noricbb2c962011-07-06 06:01:23 +00001119 .dma_mask = &da850_sata_dmamask,
1120 .coherent_dma_mask = DMA_BIT_MASK(32),
1121 },
1122 .num_resources = ARRAY_SIZE(da850_sata_resources),
1123 .resource = da850_sata_resources,
1124};
1125
1126int __init da850_register_sata(unsigned long refclkpn)
1127{
Bartosz Golaszewski00bacfb2017-01-30 11:02:03 +01001128 int ret;
1129
Bartosz Golaszewski00bacfb2017-01-30 11:02:03 +01001130 ret = da850_register_sata_refclk(refclkpn);
1131 if (ret)
1132 return ret;
1133
Sekhar Noricbb2c962011-07-06 06:01:23 +00001134 return platform_device_register(&da850_sata_device);
1135}
1136#endif
David Lechner0fcd5412016-10-25 22:06:48 -05001137
David Lechnerbdec5a62018-02-17 21:22:24 -06001138static struct regmap *da8xx_cfgchip;
1139
David Lechnerbdec5a62018-02-17 21:22:24 -06001140static const struct regmap_config da8xx_cfgchip_config __initconst = {
David Lechnerf6adc9f2018-03-15 13:13:41 -05001141 .name = "cfgchip",
David Lechnerbdec5a62018-02-17 21:22:24 -06001142 .reg_bits = 32,
1143 .val_bits = 32,
1144 .reg_stride = 4,
1145 .max_register = DA8XX_CFGCHIP4_REG - DA8XX_CFGCHIP0_REG,
David Lechner0fcd5412016-10-25 22:06:48 -05001146};
1147
David Lechnerbdec5a62018-02-17 21:22:24 -06001148/**
1149 * da8xx_get_cfgchip - Lazy gets CFGCHIP as regmap
1150 *
1151 * This is for use on non-DT boards only. For DT boards, use
1152 * syscon_regmap_lookup_by_compatible("ti,da830-cfgchip")
1153 *
1154 * Returns: Pointer to the CFGCHIP regmap or negative error code.
1155 */
1156struct regmap * __init da8xx_get_cfgchip(void)
David Lechner0fcd5412016-10-25 22:06:48 -05001157{
David Lechnerbdec5a62018-02-17 21:22:24 -06001158 if (IS_ERR_OR_NULL(da8xx_cfgchip))
1159 da8xx_cfgchip = regmap_init_mmio(NULL,
1160 DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP0_REG),
1161 &da8xx_cfgchip_config);
1162
1163 return da8xx_cfgchip;
David Lechner0fcd5412016-10-25 22:06:48 -05001164}