2 * Copyright (C) 2008 Google, Inc.
3 * Copyright (c) 2008-2011, Code Aurora Forum. All rights reserved.
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
16 #include <linux/kernel.h>
17 #include <linux/platform_device.h>
18 #include <linux/clkdev.h>
19 #include <linux/dma-mapping.h>
21 #include <mach/irqs.h>
22 #include <mach/msm_iomap.h>
24 #include <mach/board.h>
28 #include <asm/mach/flash.h>
31 #include "clock-pcom.h"
33 static struct resource resources_uart3
[] = {
37 .flags
= IORESOURCE_IRQ
,
40 .start
= MSM_UART3_PHYS
,
41 .end
= MSM_UART3_PHYS
+ MSM_UART3_SIZE
- 1,
42 .flags
= IORESOURCE_MEM
,
43 .name
= "uart_resource"
47 struct platform_device msm_device_uart3
= {
50 .num_resources
= ARRAY_SIZE(resources_uart3
),
51 .resource
= resources_uart3
,
54 struct platform_device msm_device_smd
= {
59 static struct resource resources_otg
[] = {
61 .start
= MSM_HSUSB_PHYS
,
62 .end
= MSM_HSUSB_PHYS
+ MSM_HSUSB_SIZE
,
63 .flags
= IORESOURCE_MEM
,
68 .flags
= IORESOURCE_IRQ
,
72 struct platform_device msm_device_otg
= {
75 .num_resources
= ARRAY_SIZE(resources_otg
),
76 .resource
= resources_otg
,
78 .coherent_dma_mask
= 0xffffffff,
82 static struct resource resources_hsusb
[] = {
84 .start
= MSM_HSUSB_PHYS
,
85 .end
= MSM_HSUSB_PHYS
+ MSM_HSUSB_SIZE
,
86 .flags
= IORESOURCE_MEM
,
91 .flags
= IORESOURCE_IRQ
,
95 struct platform_device msm_device_hsusb
= {
98 .num_resources
= ARRAY_SIZE(resources_hsusb
),
99 .resource
= resources_hsusb
,
101 .coherent_dma_mask
= 0xffffffff,
105 static u64 dma_mask
= 0xffffffffULL
;
106 static struct resource resources_hsusb_host
[] = {
108 .start
= MSM_HSUSB_PHYS
,
109 .end
= MSM_HSUSB_PHYS
+ MSM_HSUSB_SIZE
,
110 .flags
= IORESOURCE_MEM
,
115 .flags
= IORESOURCE_IRQ
,
119 struct platform_device msm_device_hsusb_host
= {
120 .name
= "msm_hsusb_host",
122 .num_resources
= ARRAY_SIZE(resources_hsusb_host
),
123 .resource
= resources_hsusb_host
,
125 .dma_mask
= &dma_mask
,
126 .coherent_dma_mask
= 0xffffffffULL
,
130 static struct resource resources_sdc1
[] = {
132 .start
= MSM_SDC1_PHYS
,
133 .end
= MSM_SDC1_PHYS
+ MSM_SDC1_SIZE
- 1,
134 .flags
= IORESOURCE_MEM
,
139 .flags
= IORESOURCE_IRQ
,
145 .flags
= IORESOURCE_IRQ
,
149 .flags
= IORESOURCE_IRQ
| IORESOURCE_DISABLED
,
155 .flags
= IORESOURCE_DMA
,
159 static struct resource resources_sdc2
[] = {
161 .start
= MSM_SDC2_PHYS
,
162 .end
= MSM_SDC2_PHYS
+ MSM_SDC2_SIZE
- 1,
163 .flags
= IORESOURCE_MEM
,
168 .flags
= IORESOURCE_IRQ
,
174 .flags
= IORESOURCE_IRQ
,
178 .flags
= IORESOURCE_IRQ
| IORESOURCE_DISABLED
,
184 .flags
= IORESOURCE_DMA
,
188 static struct resource resources_sdc3
[] = {
190 .start
= MSM_SDC3_PHYS
,
191 .end
= MSM_SDC3_PHYS
+ MSM_SDC3_SIZE
- 1,
192 .flags
= IORESOURCE_MEM
,
197 .flags
= IORESOURCE_IRQ
,
203 .flags
= IORESOURCE_IRQ
,
207 .flags
= IORESOURCE_IRQ
| IORESOURCE_DISABLED
,
213 .flags
= IORESOURCE_DMA
,
217 static struct resource resources_sdc4
[] = {
219 .start
= MSM_SDC4_PHYS
,
220 .end
= MSM_SDC4_PHYS
+ MSM_SDC4_SIZE
- 1,
221 .flags
= IORESOURCE_MEM
,
226 .flags
= IORESOURCE_IRQ
,
232 .flags
= IORESOURCE_IRQ
,
236 .flags
= IORESOURCE_IRQ
| IORESOURCE_DISABLED
,
242 .flags
= IORESOURCE_DMA
,
246 struct platform_device msm_device_sdc1
= {
249 .num_resources
= ARRAY_SIZE(resources_sdc1
),
250 .resource
= resources_sdc1
,
252 .coherent_dma_mask
= 0xffffffff,
256 struct platform_device msm_device_sdc2
= {
259 .num_resources
= ARRAY_SIZE(resources_sdc2
),
260 .resource
= resources_sdc2
,
262 .coherent_dma_mask
= 0xffffffff,
266 struct platform_device msm_device_sdc3
= {
269 .num_resources
= ARRAY_SIZE(resources_sdc3
),
270 .resource
= resources_sdc3
,
272 .coherent_dma_mask
= 0xffffffff,
276 struct platform_device msm_device_sdc4
= {
279 .num_resources
= ARRAY_SIZE(resources_sdc4
),
280 .resource
= resources_sdc4
,
282 .coherent_dma_mask
= 0xffffffff,
286 static struct platform_device
*msm_sdcc_devices
[] __initdata
= {
293 int __init
msm_add_sdcc(unsigned int controller
,
294 struct msm_mmc_platform_data
*plat
,
295 unsigned int stat_irq
, unsigned long stat_irq_flags
)
297 struct platform_device
*pdev
;
298 struct resource
*res
;
300 if (controller
< 1 || controller
> 4)
303 pdev
= msm_sdcc_devices
[controller
-1];
304 pdev
->dev
.platform_data
= plat
;
306 res
= platform_get_resource_byname(pdev
, IORESOURCE_IRQ
, "status_irq");
310 res
->start
= res
->end
= stat_irq
;
311 res
->flags
&= ~IORESOURCE_DISABLED
;
312 res
->flags
|= stat_irq_flags
;
315 return platform_device_register(pdev
);
318 static struct resource resources_dmov
[] = {
320 .start
= QSD8X50_DMOV_PHYS
,
321 .end
= QSD8X50_DMOV_PHYS
+ QSD8X50_DMOV_SIZE
- 1,
322 .flags
= IORESOURCE_MEM
,
325 .start
= INT_ADM_AARM
,
326 .flags
= IORESOURCE_IRQ
,
330 struct platform_device msm_device_dmov
= {
333 .num_resources
= ARRAY_SIZE(resources_dmov
),
334 .resource
= resources_dmov
,
337 struct clk_lookup msm_clocks_8x50
[] = {
338 CLK_PCOM("adm_clk", ADM_CLK
, "msm_dmov", 0),
339 CLK_PCOM("ce_clk", CE_CLK
, NULL
, 0),
340 CLK_PCOM("ebi1_clk", EBI1_CLK
, NULL
, CLK_MIN
),
341 CLK_PCOM("ebi2_clk", EBI2_CLK
, NULL
, 0),
342 CLK_PCOM("ecodec_clk", ECODEC_CLK
, NULL
, 0),
343 CLK_PCOM("emdh_clk", EMDH_CLK
, NULL
, OFF
| CLK_MINMAX
),
344 CLK_PCOM("gp_clk", GP_CLK
, NULL
, 0),
345 CLK_PCOM("grp_clk", GRP_3D_CLK
, NULL
, 0),
346 CLK_PCOM("i2c_clk", I2C_CLK
, NULL
, 0),
347 CLK_PCOM("icodec_rx_clk", ICODEC_RX_CLK
, NULL
, 0),
348 CLK_PCOM("icodec_tx_clk", ICODEC_TX_CLK
, NULL
, 0),
349 CLK_PCOM("imem_clk", IMEM_CLK
, NULL
, OFF
),
350 CLK_PCOM("mdc_clk", MDC_CLK
, NULL
, 0),
351 CLK_PCOM("mddi_clk", PMDH_CLK
, NULL
, OFF
| CLK_MINMAX
),
352 CLK_PCOM("mdp_clk", MDP_CLK
, NULL
, OFF
),
353 CLK_PCOM("mdp_lcdc_pclk_clk", MDP_LCDC_PCLK_CLK
, NULL
, 0),
354 CLK_PCOM("mdp_lcdc_pad_pclk_clk", MDP_LCDC_PAD_PCLK_CLK
, NULL
, 0),
355 CLK_PCOM("mdp_vsync_clk", MDP_VSYNC_CLK
, NULL
, 0),
356 CLK_PCOM("pbus_clk", PBUS_CLK
, NULL
, CLK_MIN
),
357 CLK_PCOM("pcm_clk", PCM_CLK
, NULL
, 0),
358 CLK_PCOM("sdac_clk", SDAC_CLK
, NULL
, OFF
),
359 CLK_PCOM("sdc_clk", SDC1_CLK
, "msm_sdcc.1", OFF
),
360 CLK_PCOM("sdc_pclk", SDC1_P_CLK
, "msm_sdcc.1", OFF
),
361 CLK_PCOM("sdc_clk", SDC2_CLK
, "msm_sdcc.2", OFF
),
362 CLK_PCOM("sdc_pclk", SDC2_P_CLK
, "msm_sdcc.2", OFF
),
363 CLK_PCOM("sdc_clk", SDC3_CLK
, "msm_sdcc.3", OFF
),
364 CLK_PCOM("sdc_pclk", SDC3_P_CLK
, "msm_sdcc.3", OFF
),
365 CLK_PCOM("sdc_clk", SDC4_CLK
, "msm_sdcc.4", OFF
),
366 CLK_PCOM("sdc_pclk", SDC4_P_CLK
, "msm_sdcc.4", OFF
),
367 CLK_PCOM("spi_clk", SPI_CLK
, NULL
, 0),
368 CLK_PCOM("tsif_clk", TSIF_CLK
, NULL
, 0),
369 CLK_PCOM("tsif_ref_clk", TSIF_REF_CLK
, NULL
, 0),
370 CLK_PCOM("tv_dac_clk", TV_DAC_CLK
, NULL
, 0),
371 CLK_PCOM("tv_enc_clk", TV_ENC_CLK
, NULL
, 0),
372 CLK_PCOM("uart_clk", UART1_CLK
, NULL
, OFF
),
373 CLK_PCOM("uart_clk", UART2_CLK
, NULL
, 0),
374 CLK_PCOM("uart_clk", UART3_CLK
, "msm_serial.2", OFF
),
375 CLK_PCOM("uartdm_clk", UART1DM_CLK
, NULL
, OFF
),
376 CLK_PCOM("uartdm_clk", UART2DM_CLK
, NULL
, 0),
377 CLK_PCOM("usb_hs_clk", USB_HS_CLK
, NULL
, OFF
),
378 CLK_PCOM("usb_hs_pclk", USB_HS_P_CLK
, NULL
, OFF
),
379 CLK_PCOM("usb_otg_clk", USB_OTG_CLK
, NULL
, 0),
380 CLK_PCOM("vdc_clk", VDC_CLK
, NULL
, OFF
| CLK_MIN
),
381 CLK_PCOM("vfe_clk", VFE_CLK
, NULL
, OFF
),
382 CLK_PCOM("vfe_mdc_clk", VFE_MDC_CLK
, NULL
, OFF
),
383 CLK_PCOM("vfe_axi_clk", VFE_AXI_CLK
, NULL
, OFF
),
384 CLK_PCOM("usb_hs2_clk", USB_HS2_CLK
, NULL
, OFF
),
385 CLK_PCOM("usb_hs2_pclk", USB_HS2_P_CLK
, NULL
, OFF
),
386 CLK_PCOM("usb_hs3_clk", USB_HS3_CLK
, NULL
, OFF
),
387 CLK_PCOM("usb_hs3_pclk", USB_HS3_P_CLK
, NULL
, OFF
),
388 CLK_PCOM("usb_phy_clk", USB_PHY_CLK
, NULL
, 0),
391 unsigned msm_num_clocks_8x50
= ARRAY_SIZE(msm_clocks_8x50
);