Loading...
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * USB
4 */
5#include <linux/init.h>
6#include <linux/platform_device.h>
7#include <linux/dma-mapping.h>
8
9#include <linux/usb/musb.h>
10
11#include <mach/common.h>
12#include <mach/irqs.h>
13#include <mach/cputype.h>
14#include <linux/platform_data/usb-davinci.h>
15
16#define DAVINCI_USB_OTG_BASE 0x01c64000
17
18#if IS_ENABLED(CONFIG_USB_MUSB_HDRC)
19static struct musb_hdrc_config musb_config = {
20 .multipoint = true,
21
22 .num_eps = 5,
23 .ram_bits = 10,
24};
25
26static struct musb_hdrc_platform_data usb_data = {
27 /* OTG requires a Mini-AB connector */
28 .mode = MUSB_OTG,
29 .clock = "usb",
30 .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,
43 .name = "mc"
44 },
45 {
46 /* placeholder for the dedicated CPPI IRQ */
47 .flags = IORESOURCE_IRQ,
48 .name = "dma"
49 },
50};
51
52static u64 usb_dmamask = DMA_BIT_MASK(32);
53
54static struct platform_device usb_dev = {
55 .name = "musb-davinci",
56 .id = -1,
57 .dev = {
58 .platform_data = &usb_data,
59 .dma_mask = &usb_dmamask,
60 .coherent_dma_mask = DMA_BIT_MASK(32),
61 },
62 .resource = usb_resources,
63 .num_resources = ARRAY_SIZE(usb_resources),
64};
65
66void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms)
67{
68 usb_data.power = mA > 510 ? 255 : mA / 2;
69 usb_data.potpgt = (potpgt_ms + 1) / 2;
70
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
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 */
1/*
2 * USB
3 */
4#include <linux/init.h>
5#include <linux/platform_device.h>
6#include <linux/dma-mapping.h>
7
8#include <linux/usb/musb.h>
9
10#include <mach/common.h>
11#include <mach/irqs.h>
12#include <mach/cputype.h>
13#include <mach/usb.h>
14
15#define DAVINCI_USB_OTG_BASE 0x01c64000
16
17#define DA8XX_USB0_BASE 0x01e00000
18#define DA8XX_USB1_BASE 0x01e25000
19
20#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
21static struct musb_hdrc_eps_bits musb_eps[] = {
22 { "ep1_tx", 8, },
23 { "ep1_rx", 8, },
24 { "ep2_tx", 8, },
25 { "ep2_rx", 8, },
26 { "ep3_tx", 5, },
27 { "ep3_rx", 5, },
28 { "ep4_tx", 5, },
29 { "ep4_rx", 5, },
30};
31
32static struct musb_hdrc_config musb_config = {
33 .multipoint = true,
34 .dyn_fifo = true,
35 .soft_con = true,
36 .dma = true,
37
38 .num_eps = 5,
39 .dma_channels = 8,
40 .ram_bits = 10,
41 .eps_bits = musb_eps,
42};
43
44static struct musb_hdrc_platform_data usb_data = {
45#if defined(CONFIG_USB_MUSB_OTG)
46 /* OTG requires a Mini-AB connector */
47 .mode = MUSB_OTG,
48#elif defined(CONFIG_USB_MUSB_PERIPHERAL)
49 .mode = MUSB_PERIPHERAL,
50#elif defined(CONFIG_USB_MUSB_HOST)
51 .mode = MUSB_HOST,
52#endif
53 .clock = "usb",
54 .config = &musb_config,
55};
56
57static struct resource usb_resources[] = {
58 {
59 /* physical address */
60 .start = DAVINCI_USB_OTG_BASE,
61 .end = DAVINCI_USB_OTG_BASE + 0x5ff,
62 .flags = IORESOURCE_MEM,
63 },
64 {
65 .start = IRQ_USBINT,
66 .flags = IORESOURCE_IRQ,
67 .name = "mc"
68 },
69 {
70 /* placeholder for the dedicated CPPI IRQ */
71 .flags = IORESOURCE_IRQ,
72 .name = "dma"
73 },
74};
75
76static u64 usb_dmamask = DMA_BIT_MASK(32);
77
78static struct platform_device usb_dev = {
79 .name = "musb-davinci",
80 .id = -1,
81 .dev = {
82 .platform_data = &usb_data,
83 .dma_mask = &usb_dmamask,
84 .coherent_dma_mask = DMA_BIT_MASK(32),
85 },
86 .resource = usb_resources,
87 .num_resources = ARRAY_SIZE(usb_resources),
88};
89
90void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms)
91{
92 usb_data.power = mA > 510 ? 255 : mA / 2;
93 usb_data.potpgt = (potpgt_ms + 1) / 2;
94
95 if (cpu_is_davinci_dm646x()) {
96 /* Override the defaults as DM6467 uses different IRQs. */
97 usb_dev.resource[1].start = IRQ_DM646X_USBINT;
98 usb_dev.resource[2].start = IRQ_DM646X_USBDMAINT;
99 } else /* other devices don't have dedicated CPPI IRQ */
100 usb_dev.num_resources = 2;
101
102 platform_device_register(&usb_dev);
103}
104
105#ifdef CONFIG_ARCH_DAVINCI_DA8XX
106static struct resource da8xx_usb20_resources[] = {
107 {
108 .start = DA8XX_USB0_BASE,
109 .end = DA8XX_USB0_BASE + SZ_64K - 1,
110 .flags = IORESOURCE_MEM,
111 },
112 {
113 .start = IRQ_DA8XX_USB_INT,
114 .flags = IORESOURCE_IRQ,
115 .name = "mc",
116 },
117};
118
119int __init da8xx_register_usb20(unsigned mA, unsigned potpgt)
120{
121 usb_data.clock = "usb20";
122 usb_data.power = mA > 510 ? 255 : mA / 2;
123 usb_data.potpgt = (potpgt + 1) / 2;
124
125 usb_dev.resource = da8xx_usb20_resources;
126 usb_dev.num_resources = ARRAY_SIZE(da8xx_usb20_resources);
127 usb_dev.name = "musb-da8xx";
128
129 return platform_device_register(&usb_dev);
130}
131#endif /* CONFIG_DAVINCI_DA8XX */
132
133#else
134
135void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms)
136{
137}
138
139#ifdef CONFIG_ARCH_DAVINCI_DA8XX
140int __init da8xx_register_usb20(unsigned mA, unsigned potpgt)
141{
142 return 0;
143}
144#endif
145
146#endif /* CONFIG_USB_MUSB_HDRC */
147
148#ifdef CONFIG_ARCH_DAVINCI_DA8XX
149static struct resource da8xx_usb11_resources[] = {
150 [0] = {
151 .start = DA8XX_USB1_BASE,
152 .end = DA8XX_USB1_BASE + SZ_4K - 1,
153 .flags = IORESOURCE_MEM,
154 },
155 [1] = {
156 .start = IRQ_DA8XX_IRQN,
157 .end = IRQ_DA8XX_IRQN,
158 .flags = IORESOURCE_IRQ,
159 },
160};
161
162static u64 da8xx_usb11_dma_mask = DMA_BIT_MASK(32);
163
164static struct platform_device da8xx_usb11_device = {
165 .name = "ohci",
166 .id = 0,
167 .dev = {
168 .dma_mask = &da8xx_usb11_dma_mask,
169 .coherent_dma_mask = DMA_BIT_MASK(32),
170 },
171 .num_resources = ARRAY_SIZE(da8xx_usb11_resources),
172 .resource = da8xx_usb11_resources,
173};
174
175int __init da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata)
176{
177 da8xx_usb11_device.dev.platform_data = pdata;
178 return platform_device_register(&da8xx_usb11_device);
179}
180#endif /* CONFIG_DAVINCI_DA8XX */