Merge tag 'clk-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux
[linux-2.6-block.git] / arch / mips / jz4740 / platform.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  *  Copyright (C) 2009-2010, Lars-Peter Clausen <lars@metafoo.de>
4  *  JZ4740 platform devices
5  */
6
7 #include <linux/clk.h>
8 #include <linux/device.h>
9 #include <linux/kernel.h>
10 #include <linux/platform_device.h>
11 #include <linux/resource.h>
12
13 #include <linux/dma-mapping.h>
14
15 #include <linux/usb/musb.h>
16
17 #include <asm/mach-jz4740/platform.h>
18 #include <asm/mach-jz4740/base.h>
19 #include <asm/mach-jz4740/irq.h>
20
21 #include <linux/serial_core.h>
22 #include <linux/serial_8250.h>
23
24 /* USB Device Controller */
25 struct platform_device jz4740_udc_xceiv_device = {
26         .name = "usb_phy_generic",
27         .id   = 0,
28 };
29
30 static struct resource jz4740_udc_resources[] = {
31         [0] = {
32                 .start = JZ4740_UDC_BASE_ADDR,
33                 .end   = JZ4740_UDC_BASE_ADDR + 0x10000 - 1,
34                 .flags = IORESOURCE_MEM,
35         },
36         [1] = {
37                 .start = JZ4740_IRQ_UDC,
38                 .end   = JZ4740_IRQ_UDC,
39                 .flags = IORESOURCE_IRQ,
40                 .name  = "mc",
41         },
42 };
43
44 struct platform_device jz4740_udc_device = {
45         .name = "musb-jz4740",
46         .id   = -1,
47         .dev  = {
48                 .dma_mask          = &jz4740_udc_device.dev.coherent_dma_mask,
49                 .coherent_dma_mask = DMA_BIT_MASK(32),
50         },
51         .num_resources = ARRAY_SIZE(jz4740_udc_resources),
52         .resource      = jz4740_udc_resources,
53 };
54
55 /* MMC/SD controller */
56 static struct resource jz4740_mmc_resources[] = {
57         {
58                 .start  = JZ4740_MSC_BASE_ADDR,
59                 .end    = JZ4740_MSC_BASE_ADDR + 0x1000 - 1,
60                 .flags  = IORESOURCE_MEM,
61         },
62         {
63                 .start  = JZ4740_IRQ_MSC,
64                 .end    = JZ4740_IRQ_MSC,
65                 .flags  = IORESOURCE_IRQ,
66         }
67 };
68
69 struct platform_device jz4740_mmc_device = {
70         .name           = "jz4740-mmc",
71         .id             = 0,
72         .dev = {
73                 .dma_mask = &jz4740_mmc_device.dev.coherent_dma_mask,
74                 .coherent_dma_mask = DMA_BIT_MASK(32),
75         },
76         .num_resources  = ARRAY_SIZE(jz4740_mmc_resources),
77         .resource       = jz4740_mmc_resources,
78 };
79
80 /* I2C controller */
81 static struct resource jz4740_i2c_resources[] = {
82         {
83                 .start  = JZ4740_I2C_BASE_ADDR,
84                 .end    = JZ4740_I2C_BASE_ADDR + 0x1000 - 1,
85                 .flags  = IORESOURCE_MEM,
86         },
87         {
88                 .start  = JZ4740_IRQ_I2C,
89                 .end    = JZ4740_IRQ_I2C,
90                 .flags  = IORESOURCE_IRQ,
91         }
92 };
93
94 struct platform_device jz4740_i2c_device = {
95         .name           = "jz4740-i2c",
96         .id             = 0,
97         .num_resources  = ARRAY_SIZE(jz4740_i2c_resources),
98         .resource       = jz4740_i2c_resources,
99 };
100
101 /* NAND controller */
102 static struct resource jz4740_nand_resources[] = {
103         {
104                 .name   = "mmio",
105                 .start  = JZ4740_EMC_BASE_ADDR,
106                 .end    = JZ4740_EMC_BASE_ADDR + 0x1000 - 1,
107                 .flags  = IORESOURCE_MEM,
108         },
109         {
110                 .name   = "bank1",
111                 .start  = 0x18000000,
112                 .end    = 0x180C0000 - 1,
113                 .flags = IORESOURCE_MEM,
114         },
115         {
116                 .name   = "bank2",
117                 .start  = 0x14000000,
118                 .end    = 0x140C0000 - 1,
119                 .flags = IORESOURCE_MEM,
120         },
121         {
122                 .name   = "bank3",
123                 .start  = 0x0C000000,
124                 .end    = 0x0C0C0000 - 1,
125                 .flags = IORESOURCE_MEM,
126         },
127         {
128                 .name   = "bank4",
129                 .start  = 0x08000000,
130                 .end    = 0x080C0000 - 1,
131                 .flags = IORESOURCE_MEM,
132         },
133 };
134
135 struct platform_device jz4740_nand_device = {
136         .name = "jz4740-nand",
137         .num_resources = ARRAY_SIZE(jz4740_nand_resources),
138         .resource = jz4740_nand_resources,
139 };
140
141 /* LCD controller */
142 static struct resource jz4740_framebuffer_resources[] = {
143         {
144                 .start  = JZ4740_LCD_BASE_ADDR,
145                 .end    = JZ4740_LCD_BASE_ADDR + 0x1000 - 1,
146                 .flags  = IORESOURCE_MEM,
147         },
148 };
149
150 struct platform_device jz4740_framebuffer_device = {
151         .name           = "jz4740-fb",
152         .id             = -1,
153         .num_resources  = ARRAY_SIZE(jz4740_framebuffer_resources),
154         .resource       = jz4740_framebuffer_resources,
155         .dev = {
156                 .dma_mask = &jz4740_framebuffer_device.dev.coherent_dma_mask,
157                 .coherent_dma_mask = DMA_BIT_MASK(32),
158         },
159 };
160
161 /* I2S controller */
162 static struct resource jz4740_i2s_resources[] = {
163         {
164                 .start  = JZ4740_AIC_BASE_ADDR,
165                 .end    = JZ4740_AIC_BASE_ADDR + 0x38 - 1,
166                 .flags  = IORESOURCE_MEM,
167         },
168 };
169
170 struct platform_device jz4740_i2s_device = {
171         .name           = "jz4740-i2s",
172         .id             = -1,
173         .num_resources  = ARRAY_SIZE(jz4740_i2s_resources),
174         .resource       = jz4740_i2s_resources,
175 };
176
177 /* PCM */
178 struct platform_device jz4740_pcm_device = {
179         .name           = "jz4740-pcm-audio",
180         .id             = -1,
181 };
182
183 /* Codec */
184 static struct resource jz4740_codec_resources[] = {
185         {
186                 .start  = JZ4740_AIC_BASE_ADDR + 0x80,
187                 .end    = JZ4740_AIC_BASE_ADDR + 0x88 - 1,
188                 .flags  = IORESOURCE_MEM,
189         },
190 };
191
192 struct platform_device jz4740_codec_device = {
193         .name           = "jz4740-codec",
194         .id             = -1,
195         .num_resources  = ARRAY_SIZE(jz4740_codec_resources),
196         .resource       = jz4740_codec_resources,
197 };
198
199 /* ADC controller */
200 static struct resource jz4740_adc_resources[] = {
201         {
202                 .start  = JZ4740_SADC_BASE_ADDR,
203                 .end    = JZ4740_SADC_BASE_ADDR + 0x30,
204                 .flags  = IORESOURCE_MEM,
205         },
206         {
207                 .start  = JZ4740_IRQ_SADC,
208                 .end    = JZ4740_IRQ_SADC,
209                 .flags  = IORESOURCE_IRQ,
210         },
211         {
212                 .start  = JZ4740_IRQ_ADC_BASE,
213                 .end    = JZ4740_IRQ_ADC_BASE,
214                 .flags  = IORESOURCE_IRQ,
215         },
216 };
217
218 struct platform_device jz4740_adc_device = {
219         .name           = "jz4740-adc",
220         .id             = -1,
221         .num_resources  = ARRAY_SIZE(jz4740_adc_resources),
222         .resource       = jz4740_adc_resources,
223 };
224
225 /* PWM */
226 struct platform_device jz4740_pwm_device = {
227         .name = "jz4740-pwm",
228         .id   = -1,
229 };
230
231 /* DMA */
232 static struct resource jz4740_dma_resources[] = {
233         {
234                 .start  = JZ4740_DMAC_BASE_ADDR,
235                 .end    = JZ4740_DMAC_BASE_ADDR + 0x400 - 1,
236                 .flags  = IORESOURCE_MEM,
237         },
238         {
239                 .start  = JZ4740_IRQ_DMAC,
240                 .end    = JZ4740_IRQ_DMAC,
241                 .flags  = IORESOURCE_IRQ,
242         },
243 };
244
245 struct platform_device jz4740_dma_device = {
246         .name           = "jz4740-dma",
247         .id             = -1,
248         .num_resources  = ARRAY_SIZE(jz4740_dma_resources),
249         .resource       = jz4740_dma_resources,
250 };