Linux Audio

Check our new training course

Loading...
v4.17
 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 */
v5.9
 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 <mach/common.h>
 
12#include <mach/cputype.h>
13
14#include "irqs.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          = DAVINCI_INTC_IRQ(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 = DAVINCI_INTC_IRQ(IRQ_DM646X_USBINT);
74		usb_dev.resource[2].start = DAVINCI_INTC_IRQ(
75							IRQ_DM646X_USBDMAINT);
76	} else	/* other devices don't have dedicated CPPI IRQ */
77		usb_dev.num_resources = 2;
78
79	platform_device_register(&usb_dev);
80}
81
82#else
83
84void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms)
85{
86}
87
88#endif  /* CONFIG_USB_MUSB_HDRC */