Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * DA8xx USB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #include <linux/clk-provider.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include <linux/dma-mapping.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/mfd/da8xx-cfgchip.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/mfd/syscon.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/phy/phy.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/platform_data/clk-da8xx-cfgchip.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/platform_data/phy-da8xx-usb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/platform_data/usb-davinci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/usb/musb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <mach/common.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <mach/cputype.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <mach/da8xx.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include "irqs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #define DA8XX_USB0_BASE		0x01e00000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #define DA8XX_USB1_BASE		0x01e25000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #ifndef CONFIG_COMMON_CLK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) static struct clk *usb20_clk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) static struct da8xx_usb_phy_platform_data da8xx_usb_phy_pdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) static struct platform_device da8xx_usb_phy = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	.name		= "da8xx-usb-phy",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	.id		= -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	.dev		= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 		 * Setting init_name so that clock lookup will work in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 		 * da8xx_register_usb11_phy_clk() even if this device is not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 		 * registered yet.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 		.init_name	= "da8xx-usb-phy",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 		.platform_data	= &da8xx_usb_phy_pdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) int __init da8xx_register_usb_phy(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	da8xx_usb_phy_pdata.cfgchip = da8xx_get_cfgchip();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	return platform_device_register(&da8xx_usb_phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) static struct musb_hdrc_config musb_config = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	.multipoint	= true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	.num_eps	= 5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	.ram_bits	= 10,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) static struct musb_hdrc_platform_data usb_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	/* OTG requires a Mini-AB connector */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	.mode           = MUSB_OTG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	.clock		= "usb20",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	.config		= &musb_config,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) static struct resource da8xx_usb20_resources[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		.start		= DA8XX_USB0_BASE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 		.end		= DA8XX_USB0_BASE + SZ_64K - 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		.flags		= IORESOURCE_MEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		.start		= DAVINCI_INTC_IRQ(IRQ_DA8XX_USB_INT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		.flags		= IORESOURCE_IRQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		.name		= "mc",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) static u64 usb_dmamask = DMA_BIT_MASK(32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) static struct platform_device da8xx_usb20_dev = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	.name		= "musb-da8xx",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	.id             = -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	.dev = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		.platform_data		= &usb_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		.dma_mask		= &usb_dmamask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		.coherent_dma_mask      = DMA_BIT_MASK(32),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	.resource	= da8xx_usb20_resources,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	.num_resources	= ARRAY_SIZE(da8xx_usb20_resources),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) int __init da8xx_register_usb20(unsigned int mA, unsigned int potpgt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	usb_data.power	= mA > 510 ? 255 : mA / 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	usb_data.potpgt = (potpgt + 1) / 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	return platform_device_register(&da8xx_usb20_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) static struct resource da8xx_usb11_resources[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	[0] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		.start	= DA8XX_USB1_BASE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		.end	= DA8XX_USB1_BASE + SZ_4K - 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 		.flags	= IORESOURCE_MEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	[1] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		.start	= DAVINCI_INTC_IRQ(IRQ_DA8XX_IRQN),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		.end	= DAVINCI_INTC_IRQ(IRQ_DA8XX_IRQN),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		.flags	= IORESOURCE_IRQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) static u64 da8xx_usb11_dma_mask = DMA_BIT_MASK(32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) static struct platform_device da8xx_usb11_device = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	.name		= "ohci-da8xx",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	.id		= -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	.dev = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		.dma_mask		= &da8xx_usb11_dma_mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		.coherent_dma_mask	= DMA_BIT_MASK(32),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	.num_resources	= ARRAY_SIZE(da8xx_usb11_resources),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	.resource	= da8xx_usb11_resources,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) int __init da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	da8xx_usb11_device.dev.platform_data = pdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	return platform_device_register(&da8xx_usb11_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) static struct platform_device da8xx_usb_phy_clks_device = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	.name		= "da830-usb-phy-clks",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	.id		= -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) int __init da8xx_register_usb_phy_clocks(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	struct da8xx_cfgchip_clk_platform_data pdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	pdata.cfgchip = da8xx_get_cfgchip();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	da8xx_usb_phy_clks_device.dev.platform_data = &pdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	return platform_device_register(&da8xx_usb_phy_clks_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) }