1 // SPDX-License-Identifier: GPL-2.0
5 #include <linux/clk-provider.h>
6 #include <linux/delay.h>
7 #include <linux/dma-mapping.h>
8 #include <linux/init.h>
9 #include <linux/mfd/da8xx-cfgchip.h>
10 #include <linux/mfd/syscon.h>
11 #include <linux/phy/phy.h>
12 #include <linux/platform_data/clk-da8xx-cfgchip.h>
13 #include <linux/platform_data/phy-da8xx-usb.h>
14 #include <linux/platform_data/usb-davinci.h>
15 #include <linux/platform_device.h>
16 #include <linux/usb/musb.h>
23 #define DA8XX_USB0_BASE 0x01e00000
24 #define DA8XX_USB1_BASE 0x01e25000
26 #ifndef CONFIG_COMMON_CLK
27 static struct clk *usb20_clk;
30 static struct da8xx_usb_phy_platform_data da8xx_usb_phy_pdata;
32 static struct platform_device da8xx_usb_phy = {
33 .name = "da8xx-usb-phy",
37 * Setting init_name so that clock lookup will work in
38 * da8xx_register_usb11_phy_clk() even if this device is not
41 .init_name = "da8xx-usb-phy",
42 .platform_data = &da8xx_usb_phy_pdata,
46 int __init da8xx_register_usb_phy(void)
48 da8xx_usb_phy_pdata.cfgchip = da8xx_get_cfgchip();
50 return platform_device_register(&da8xx_usb_phy);
53 static struct musb_hdrc_config musb_config = {
59 static struct musb_hdrc_platform_data usb_data = {
60 /* OTG requires a Mini-AB connector */
63 .config = &musb_config,
66 static struct resource da8xx_usb20_resources[] = {
68 .start = DA8XX_USB0_BASE,
69 .end = DA8XX_USB0_BASE + SZ_64K - 1,
70 .flags = IORESOURCE_MEM,
73 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_USB_INT),
74 .flags = IORESOURCE_IRQ,
79 static u64 usb_dmamask = DMA_BIT_MASK(32);
81 static struct platform_device da8xx_usb20_dev = {
85 .platform_data = &usb_data,
86 .dma_mask = &usb_dmamask,
87 .coherent_dma_mask = DMA_BIT_MASK(32),
89 .resource = da8xx_usb20_resources,
90 .num_resources = ARRAY_SIZE(da8xx_usb20_resources),
93 int __init da8xx_register_usb20(unsigned int mA, unsigned int potpgt)
95 usb_data.power = mA > 510 ? 255 : mA / 2;
96 usb_data.potpgt = (potpgt + 1) / 2;
98 return platform_device_register(&da8xx_usb20_dev);
101 static struct resource da8xx_usb11_resources[] = {
103 .start = DA8XX_USB1_BASE,
104 .end = DA8XX_USB1_BASE + SZ_4K - 1,
105 .flags = IORESOURCE_MEM,
108 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_IRQN),
109 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_IRQN),
110 .flags = IORESOURCE_IRQ,
114 static u64 da8xx_usb11_dma_mask = DMA_BIT_MASK(32);
116 static struct platform_device da8xx_usb11_device = {
117 .name = "ohci-da8xx",
120 .dma_mask = &da8xx_usb11_dma_mask,
121 .coherent_dma_mask = DMA_BIT_MASK(32),
123 .num_resources = ARRAY_SIZE(da8xx_usb11_resources),
124 .resource = da8xx_usb11_resources,
127 int __init da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata)
129 da8xx_usb11_device.dev.platform_data = pdata;
130 return platform_device_register(&da8xx_usb11_device);
133 static struct platform_device da8xx_usb_phy_clks_device = {
134 .name = "da830-usb-phy-clks",
138 int __init da8xx_register_usb_phy_clocks(void)
140 struct da8xx_cfgchip_clk_platform_data pdata;
142 pdata.cfgchip = da8xx_get_cfgchip();
143 da8xx_usb_phy_clks_device.dev.platform_data = &pdata;
145 return platform_device_register(&da8xx_usb_phy_clks_device);