usb.c (2021B)
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * USB 4 */ 5#include <linux/dma-mapping.h> 6#include <linux/init.h> 7#include <linux/platform_device.h> 8#include <linux/platform_data/usb-davinci.h> 9#include <linux/usb/musb.h> 10 11#include "common.h" 12#include "cputype.h" 13#include "irqs.h" 14 15#define DAVINCI_USB_OTG_BASE 0x01c64000 16 17#if IS_ENABLED(CONFIG_USB_MUSB_HDRC) 18static struct musb_hdrc_config musb_config = { 19 .multipoint = true, 20 21 .num_eps = 5, 22 .ram_bits = 10, 23}; 24 25static struct musb_hdrc_platform_data usb_data = { 26 /* OTG requires a Mini-AB connector */ 27 .mode = MUSB_OTG, 28 .clock = "usb", 29 .config = &musb_config, 30}; 31 32static struct resource usb_resources[] = { 33 { 34 /* physical address */ 35 .start = DAVINCI_USB_OTG_BASE, 36 .end = DAVINCI_USB_OTG_BASE + 0x5ff, 37 .flags = IORESOURCE_MEM, 38 }, 39 { 40 .start = DAVINCI_INTC_IRQ(IRQ_USBINT), 41 .flags = IORESOURCE_IRQ, 42 .name = "mc" 43 }, 44 { 45 /* placeholder for the dedicated CPPI IRQ */ 46 .flags = IORESOURCE_IRQ, 47 .name = "dma" 48 }, 49}; 50 51static u64 usb_dmamask = DMA_BIT_MASK(32); 52 53static struct platform_device usb_dev = { 54 .name = "musb-davinci", 55 .id = -1, 56 .dev = { 57 .platform_data = &usb_data, 58 .dma_mask = &usb_dmamask, 59 .coherent_dma_mask = DMA_BIT_MASK(32), 60 }, 61 .resource = usb_resources, 62 .num_resources = ARRAY_SIZE(usb_resources), 63}; 64 65void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms) 66{ 67 usb_data.power = mA > 510 ? 255 : mA / 2; 68 usb_data.potpgt = (potpgt_ms + 1) / 2; 69 70 if (cpu_is_davinci_dm646x()) { 71 /* Override the defaults as DM6467 uses different IRQs. */ 72 usb_dev.resource[1].start = DAVINCI_INTC_IRQ(IRQ_DM646X_USBINT); 73 usb_dev.resource[2].start = DAVINCI_INTC_IRQ( 74 IRQ_DM646X_USBDMAINT); 75 } else /* other devices don't have dedicated CPPI IRQ */ 76 usb_dev.num_resources = 2; 77 78 platform_device_register(&usb_dev); 79} 80 81#else 82 83void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms) 84{ 85} 86 87#endif /* CONFIG_USB_MUSB_HDRC */