0001
0002
0003
0004
0005 #include <linux/clk-provider.h>
0006 #include <linux/delay.h>
0007 #include <linux/dma-mapping.h>
0008 #include <linux/init.h>
0009 #include <linux/mfd/da8xx-cfgchip.h>
0010 #include <linux/mfd/syscon.h>
0011 #include <linux/phy/phy.h>
0012 #include <linux/platform_data/clk-da8xx-cfgchip.h>
0013 #include <linux/platform_data/phy-da8xx-usb.h>
0014 #include <linux/platform_data/usb-davinci.h>
0015 #include <linux/platform_device.h>
0016 #include <linux/usb/musb.h>
0017
0018 #include "common.h"
0019 #include "cputype.h"
0020 #include "da8xx.h"
0021 #include "irqs.h"
0022
0023 #define DA8XX_USB0_BASE 0x01e00000
0024 #define DA8XX_USB1_BASE 0x01e25000
0025
0026 #ifndef CONFIG_COMMON_CLK
0027 static struct clk *usb20_clk;
0028 #endif
0029
0030 static struct da8xx_usb_phy_platform_data da8xx_usb_phy_pdata;
0031
0032 static struct platform_device da8xx_usb_phy = {
0033 .name = "da8xx-usb-phy",
0034 .id = -1,
0035 .dev = {
0036
0037
0038
0039
0040
0041 .init_name = "da8xx-usb-phy",
0042 .platform_data = &da8xx_usb_phy_pdata,
0043 },
0044 };
0045
0046 int __init da8xx_register_usb_phy(void)
0047 {
0048 da8xx_usb_phy_pdata.cfgchip = da8xx_get_cfgchip();
0049
0050 return platform_device_register(&da8xx_usb_phy);
0051 }
0052
0053 static struct musb_hdrc_config musb_config = {
0054 .multipoint = true,
0055 .num_eps = 5,
0056 .ram_bits = 10,
0057 };
0058
0059 static struct musb_hdrc_platform_data usb_data = {
0060
0061 .mode = MUSB_OTG,
0062 .clock = "usb20",
0063 .config = &musb_config,
0064 };
0065
0066 static struct resource da8xx_usb20_resources[] = {
0067 {
0068 .start = DA8XX_USB0_BASE,
0069 .end = DA8XX_USB0_BASE + SZ_64K - 1,
0070 .flags = IORESOURCE_MEM,
0071 },
0072 {
0073 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_USB_INT),
0074 .flags = IORESOURCE_IRQ,
0075 .name = "mc",
0076 },
0077 };
0078
0079 static u64 usb_dmamask = DMA_BIT_MASK(32);
0080
0081 static struct platform_device da8xx_usb20_dev = {
0082 .name = "musb-da8xx",
0083 .id = -1,
0084 .dev = {
0085 .platform_data = &usb_data,
0086 .dma_mask = &usb_dmamask,
0087 .coherent_dma_mask = DMA_BIT_MASK(32),
0088 },
0089 .resource = da8xx_usb20_resources,
0090 .num_resources = ARRAY_SIZE(da8xx_usb20_resources),
0091 };
0092
0093 int __init da8xx_register_usb20(unsigned int mA, unsigned int potpgt)
0094 {
0095 usb_data.power = mA > 510 ? 255 : mA / 2;
0096 usb_data.potpgt = (potpgt + 1) / 2;
0097
0098 return platform_device_register(&da8xx_usb20_dev);
0099 }
0100
0101 static struct resource da8xx_usb11_resources[] = {
0102 [0] = {
0103 .start = DA8XX_USB1_BASE,
0104 .end = DA8XX_USB1_BASE + SZ_4K - 1,
0105 .flags = IORESOURCE_MEM,
0106 },
0107 [1] = {
0108 .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_IRQN),
0109 .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_IRQN),
0110 .flags = IORESOURCE_IRQ,
0111 },
0112 };
0113
0114 static u64 da8xx_usb11_dma_mask = DMA_BIT_MASK(32);
0115
0116 static struct platform_device da8xx_usb11_device = {
0117 .name = "ohci-da8xx",
0118 .id = -1,
0119 .dev = {
0120 .dma_mask = &da8xx_usb11_dma_mask,
0121 .coherent_dma_mask = DMA_BIT_MASK(32),
0122 },
0123 .num_resources = ARRAY_SIZE(da8xx_usb11_resources),
0124 .resource = da8xx_usb11_resources,
0125 };
0126
0127 int __init da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata)
0128 {
0129 da8xx_usb11_device.dev.platform_data = pdata;
0130 return platform_device_register(&da8xx_usb11_device);
0131 }
0132
0133 static struct platform_device da8xx_usb_phy_clks_device = {
0134 .name = "da830-usb-phy-clks",
0135 .id = -1,
0136 };
0137
0138 int __init da8xx_register_usb_phy_clocks(void)
0139 {
0140 struct da8xx_cfgchip_clk_platform_data pdata;
0141
0142 pdata.cfgchip = da8xx_get_cfgchip();
0143 da8xx_usb_phy_clks_device.dev.platform_data = &pdata;
0144
0145 return platform_device_register(&da8xx_usb_phy_clks_device);
0146 }