blob: 31ed7aa4722730f9b50656dfb629c8bd48f66117 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
David Brownellcece6e52008-09-07 23:41:57 -07002/*
3 * USB
4 */
David Brownellcece6e52008-09-07 23:41:57 -07005#include <linux/init.h>
6#include <linux/platform_device.h>
7#include <linux/dma-mapping.h>
8
9#include <linux/usb/musb.h>
David Brownellcece6e52008-09-07 23:41:57 -070010
11#include <mach/common.h>
David Brownelld0e58ae2009-01-18 17:29:10 +010012#include <mach/irqs.h>
Sergei Shtylyovefd91182009-07-16 19:58:53 +040013#include <mach/cputype.h>
Arnd Bergmannec2a0832012-08-24 15:11:34 +020014#include <linux/platform_data/usb-davinci.h>
David Brownellcece6e52008-09-07 23:41:57 -070015
Sergei Shtylyove5d3d252009-09-25 23:14:02 +040016#define DAVINCI_USB_OTG_BASE 0x01c64000
Sergei Shtylyovb0ea26e2009-10-30 23:49:44 +040017
Lad, Prabhakara0a56db2013-04-01 12:43:44 +053018#if IS_ENABLED(CONFIG_USB_MUSB_HDRC)
David Brownellcece6e52008-09-07 23:41:57 -070019static struct musb_hdrc_config musb_config = {
20 .multipoint = true,
David Brownellcece6e52008-09-07 23:41:57 -070021
22 .num_eps = 5,
David Brownellcece6e52008-09-07 23:41:57 -070023 .ram_bits = 10,
David Brownellcece6e52008-09-07 23:41:57 -070024};
25
26static struct musb_hdrc_platform_data usb_data = {
David Brownellcece6e52008-09-07 23:41:57 -070027 /* OTG requires a Mini-AB connector */
28 .mode = MUSB_OTG,
David Brownell34f32c92009-02-20 13:45:17 -080029 .clock = "usb",
David Brownellcece6e52008-09-07 23:41:57 -070030 .config = &musb_config,
31};
32
33static struct resource usb_resources[] = {
34 {
35 /* physical address */
36 .start = DAVINCI_USB_OTG_BASE,
37 .end = DAVINCI_USB_OTG_BASE + 0x5ff,
38 .flags = IORESOURCE_MEM,
39 },
40 {
41 .start = IRQ_USBINT,
42 .flags = IORESOURCE_IRQ,
Hema Kalliguddifcf173e2010-09-29 11:26:39 -050043 .name = "mc"
David Brownellcece6e52008-09-07 23:41:57 -070044 },
Sergei Shtylyovefd91182009-07-16 19:58:53 +040045 {
46 /* placeholder for the dedicated CPPI IRQ */
47 .flags = IORESOURCE_IRQ,
Hema Kalliguddifcf173e2010-09-29 11:26:39 -050048 .name = "dma"
Sergei Shtylyovefd91182009-07-16 19:58:53 +040049 },
David Brownellcece6e52008-09-07 23:41:57 -070050};
51
Yang Hongyang284901a2009-04-06 19:01:15 -070052static u64 usb_dmamask = DMA_BIT_MASK(32);
David Brownellcece6e52008-09-07 23:41:57 -070053
54static struct platform_device usb_dev = {
Felipe Balbi73b089b2010-12-02 09:16:55 +020055 .name = "musb-davinci",
David Brownellcece6e52008-09-07 23:41:57 -070056 .id = -1,
57 .dev = {
58 .platform_data = &usb_data,
59 .dma_mask = &usb_dmamask,
Yang Hongyang284901a2009-04-06 19:01:15 -070060 .coherent_dma_mask = DMA_BIT_MASK(32),
David Brownellcece6e52008-09-07 23:41:57 -070061 },
62 .resource = usb_resources,
63 .num_resources = ARRAY_SIZE(usb_resources),
64};
65
Sergei Shtylyov355fb4e2009-10-30 23:46:14 +040066void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms)
David Brownellcece6e52008-09-07 23:41:57 -070067{
Sergei Shtylyov355fb4e2009-10-30 23:46:14 +040068 usb_data.power = mA > 510 ? 255 : mA / 2;
69 usb_data.potpgt = (potpgt_ms + 1) / 2;
Sergei Shtylyovefd91182009-07-16 19:58:53 +040070
71 if (cpu_is_davinci_dm646x()) {
72 /* Override the defaults as DM6467 uses different IRQs. */
73 usb_dev.resource[1].start = IRQ_DM646X_USBINT;
74 usb_dev.resource[2].start = IRQ_DM646X_USBDMAINT;
75 } else /* other devices don't have dedicated CPPI IRQ */
76 usb_dev.num_resources = 2;
77
David Brownellcece6e52008-09-07 23:41:57 -070078 platform_device_register(&usb_dev);
79}
80
81#else
82
Sergei Shtylyov355fb4e2009-10-30 23:46:14 +040083void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms)
David Brownellcece6e52008-09-07 23:41:57 -070084{
85}
86
87#endif /* CONFIG_USB_MUSB_HDRC */