0001
0002
0003
0004
0005 #include <linux/dma-mapping.h>
0006 #include <linux/init.h>
0007 #include <linux/platform_device.h>
0008 #include <linux/platform_data/usb-davinci.h>
0009 #include <linux/usb/musb.h>
0010
0011 #include "common.h"
0012 #include "cputype.h"
0013 #include "irqs.h"
0014
0015 #define DAVINCI_USB_OTG_BASE 0x01c64000
0016
0017 #if IS_ENABLED(CONFIG_USB_MUSB_HDRC)
0018 static struct musb_hdrc_config musb_config = {
0019 .multipoint = true,
0020
0021 .num_eps = 5,
0022 .ram_bits = 10,
0023 };
0024
0025 static struct musb_hdrc_platform_data usb_data = {
0026
0027 .mode = MUSB_OTG,
0028 .clock = "usb",
0029 .config = &musb_config,
0030 };
0031
0032 static struct resource usb_resources[] = {
0033 {
0034
0035 .start = DAVINCI_USB_OTG_BASE,
0036 .end = DAVINCI_USB_OTG_BASE + 0x5ff,
0037 .flags = IORESOURCE_MEM,
0038 },
0039 {
0040 .start = DAVINCI_INTC_IRQ(IRQ_USBINT),
0041 .flags = IORESOURCE_IRQ,
0042 .name = "mc"
0043 },
0044 {
0045
0046 .flags = IORESOURCE_IRQ,
0047 .name = "dma"
0048 },
0049 };
0050
0051 static u64 usb_dmamask = DMA_BIT_MASK(32);
0052
0053 static struct platform_device usb_dev = {
0054 .name = "musb-davinci",
0055 .id = -1,
0056 .dev = {
0057 .platform_data = &usb_data,
0058 .dma_mask = &usb_dmamask,
0059 .coherent_dma_mask = DMA_BIT_MASK(32),
0060 },
0061 .resource = usb_resources,
0062 .num_resources = ARRAY_SIZE(usb_resources),
0063 };
0064
0065 void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms)
0066 {
0067 usb_data.power = mA > 510 ? 255 : mA / 2;
0068 usb_data.potpgt = (potpgt_ms + 1) / 2;
0069
0070 if (cpu_is_davinci_dm646x()) {
0071
0072 usb_dev.resource[1].start = DAVINCI_INTC_IRQ(IRQ_DM646X_USBINT);
0073 usb_dev.resource[2].start = DAVINCI_INTC_IRQ(
0074 IRQ_DM646X_USBDMAINT);
0075 } else
0076 usb_dev.num_resources = 2;
0077
0078 platform_device_register(&usb_dev);
0079 }
0080
0081 #else
0082
0083 void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms)
0084 {
0085 }
0086
0087 #endif