⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usb.c

📁 linux 内核源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
		omap_cfg_reg(AA4_24XX_USB2_TLLSE0);		/* NOTE: board-specific code must override this setting if		 * this TLL link is not using DP/DM.  Something must also		 * set up OTG_SYSCON2.HMC_TLL{ATTACH,SPEED}		 */		syscon1 = 3;		CONTROL_DEVCONF_REG |= USBT2WRMODEI(USB_UNIDIR_TLL)					| USBT2TLL5PI;		break;	case 6:		if (cpu_is_omap24xx())			goto bad;		syscon1 = 3;		if (cpu_is_omap15xx()) {			omap_cfg_reg(USB2_VP);			omap_cfg_reg(USB2_VM);		} else {			omap_cfg_reg(AA9_USB2_VP);			omap_cfg_reg(R9_USB2_VM);			USB_TRANSCEIVER_CTRL_REG |= CONF_USB2_UNI_R;		}		break;	default:bad:		printk(KERN_ERR "illegal usb%d %d-wire transceiver\n",			2, nwires);	}	return syscon1 << 24;}#endif/*-------------------------------------------------------------------------*/#if	defined(CONFIG_USB_GADGET_OMAP) || \	defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) || \	(defined(CONFIG_USB_OTG) && defined(CONFIG_ARCH_OMAP_OTG))static void usb_release(struct device *dev){	/* normally not freed */}#endif#ifdef	CONFIG_USB_GADGET_OMAPstatic struct resource udc_resources[] = {	/* order is significant! */	{		/* registers */		.start		= UDC_BASE,		.end		= UDC_BASE + 0xff,		.flags		= IORESOURCE_MEM,	}, {		/* general IRQ */		.start		= INT_USB_IRQ_GEN,		.flags		= IORESOURCE_IRQ,	}, {		/* PIO IRQ */		.start		= INT_USB_IRQ_NISO,		.flags		= IORESOURCE_IRQ,	}, {		/* SOF IRQ */		.start		= INT_USB_IRQ_ISO,		.flags		= IORESOURCE_IRQ,	},};static u64 udc_dmamask = ~(u32)0;static struct platform_device udc_device = {	.name		= "omap_udc",	.id		= -1,	.dev = {		.release		= usb_release,		.dma_mask		= &udc_dmamask,		.coherent_dma_mask	= 0xffffffff,	},	.num_resources	= ARRAY_SIZE(udc_resources),	.resource	= udc_resources,};#endif#if	defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)/* The dmamask must be set for OHCI to work */static u64 ohci_dmamask = ~(u32)0;static struct resource ohci_resources[] = {	{		.start	= OMAP_OHCI_BASE,		.end	= OMAP_OHCI_BASE + 0xff,		.flags	= IORESOURCE_MEM,	},	{		.start	= INT_USB_IRQ_HGEN,		.flags	= IORESOURCE_IRQ,	},};static struct platform_device ohci_device = {	.name			= "ohci",	.id			= -1,	.dev = {		.release		= usb_release,		.dma_mask		= &ohci_dmamask,		.coherent_dma_mask	= 0xffffffff,	},	.num_resources	= ARRAY_SIZE(ohci_resources),	.resource		= ohci_resources,};#endif#if	defined(CONFIG_USB_OTG) && defined(CONFIG_ARCH_OMAP_OTG)static struct resource otg_resources[] = {	/* order is significant! */	{		.start		= OTG_BASE,		.end		= OTG_BASE + 0xff,		.flags		= IORESOURCE_MEM,	}, {		.start		= INT_USB_IRQ_OTG,		.flags		= IORESOURCE_IRQ,	},};static struct platform_device otg_device = {	.name		= "omap_otg",	.id		= -1,	.dev = {		.release		= usb_release,	},	.num_resources	= ARRAY_SIZE(otg_resources),	.resource	= otg_resources,};#endif/*-------------------------------------------------------------------------*/#define ULPD_CLOCK_CTRL_REG	__REG16(ULPD_CLOCK_CTRL)#define ULPD_SOFT_REQ_REG	__REG16(ULPD_SOFT_REQ)// FIXME correct answer depends on hmc_mode,// as does (on omap1) any nonzero value for config->otg port number#ifdef	CONFIG_USB_GADGET_OMAP#define	is_usb0_device(config)	1#else#define	is_usb0_device(config)	0#endif/*-------------------------------------------------------------------------*/#ifdef	CONFIG_ARCH_OMAP_OTGvoid __initomap_otg_init(struct omap_usb_config *config){	u32		syscon = OTG_SYSCON_1_REG & 0xffff;	int		status;	int		alt_pingroup = 0;	/* NOTE:  no bus or clock setup (yet?) */	syscon = OTG_SYSCON_1_REG & 0xffff;	if (!(syscon & OTG_RESET_DONE))		pr_debug("USB resets not complete?\n");	// OTG_IRQ_EN_REG = 0;	/* pin muxing and transceiver pinouts */	if (config->pins[0] > 2)	/* alt pingroup 2 */		alt_pingroup = 1;	syscon |= omap_usb0_init(config->pins[0], is_usb0_device(config));	syscon |= omap_usb1_init(config->pins[1]);	syscon |= omap_usb2_init(config->pins[2], alt_pingroup);	pr_debug("OTG_SYSCON_1_REG = %08x\n", syscon);	OTG_SYSCON_1_REG = syscon;	syscon = config->hmc_mode;	syscon |= USBX_SYNCHRO | (4 << 16) /* B_ASE0_BRST */;#ifdef	CONFIG_USB_OTG	if (config->otg)		syscon |= OTG_EN;#endif	if (cpu_class_is_omap1())		pr_debug("USB_TRANSCEIVER_CTRL_REG = %03x\n", USB_TRANSCEIVER_CTRL_REG);	pr_debug("OTG_SYSCON_2_REG = %08x\n", syscon);	OTG_SYSCON_2_REG = syscon;	printk("USB: hmc %d", config->hmc_mode);	if (!alt_pingroup)		printk(", usb2 alt %d wires", config->pins[2]);	else if (config->pins[0])		printk(", usb0 %d wires%s", config->pins[0],			is_usb0_device(config) ? " (dev)" : "");	if (config->pins[1])		printk(", usb1 %d wires", config->pins[1]);	if (!alt_pingroup && config->pins[2])		printk(", usb2 %d wires", config->pins[2]);	if (config->otg)		printk(", Mini-AB on usb%d", config->otg - 1);	printk("\n");	if (cpu_class_is_omap1()) {		/* leave USB clocks/controllers off until needed */		ULPD_SOFT_REQ_REG &= ~SOFT_USB_CLK_REQ;		ULPD_CLOCK_CTRL_REG &= ~USB_MCLK_EN;		ULPD_CLOCK_CTRL_REG |= DIS_USB_PVCI_CLK;	}	syscon = OTG_SYSCON_1_REG;	syscon |= HST_IDLE_EN|DEV_IDLE_EN|OTG_IDLE_EN;#ifdef	CONFIG_USB_GADGET_OMAP	if (config->otg || config->register_dev) {		syscon &= ~DEV_IDLE_EN;		udc_device.dev.platform_data = config;		/* FIXME patch IRQ numbers for omap730 */		status = platform_device_register(&udc_device);		if (status)			pr_debug("can't register UDC device, %d\n", status);	}#endif#if	defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)	if (config->otg || config->register_host) {		syscon &= ~HST_IDLE_EN;		ohci_device.dev.platform_data = config;		if (cpu_is_omap730())			ohci_resources[1].start = INT_730_USB_HHC_1;		status = platform_device_register(&ohci_device);		if (status)			pr_debug("can't register OHCI device, %d\n", status);	}#endif#ifdef	CONFIG_USB_OTG	if (config->otg) {		syscon &= ~OTG_IDLE_EN;		otg_device.dev.platform_data = config;		if (cpu_is_omap730())			otg_resources[1].start = INT_730_USB_OTG;		status = platform_device_register(&otg_device);		if (status)			pr_debug("can't register OTG device, %d\n", status);	}#endif	pr_debug("OTG_SYSCON_1_REG = %08x\n", syscon);	OTG_SYSCON_1_REG = syscon;	status = 0;}#elsestatic inline void omap_otg_init(struct omap_usb_config *config) {}#endif/*-------------------------------------------------------------------------*/#ifdef	CONFIG_ARCH_OMAP15XX#define ULPD_DPLL_CTRL_REG	__REG16(ULPD_DPLL_CTRL)#define DPLL_IOB		(1 << 13)#define DPLL_PLL_ENABLE		(1 << 4)#define DPLL_LOCK		(1 << 0)#define ULPD_APLL_CTRL_REG	__REG16(ULPD_APLL_CTRL)#define APLL_NDPLL_SWITCH	(1 << 0)static void __init omap_1510_usb_init(struct omap_usb_config *config){	unsigned int val;	omap_usb0_init(config->pins[0], is_usb0_device(config));	omap_usb1_init(config->pins[1]);	omap_usb2_init(config->pins[2], 0);	val = omap_readl(MOD_CONF_CTRL_0) & ~(0x3f << 1);	val |= (config->hmc_mode << 1);	omap_writel(val, MOD_CONF_CTRL_0);	printk("USB: hmc %d", config->hmc_mode);	if (config->pins[0])		printk(", usb0 %d wires%s", config->pins[0],			is_usb0_device(config) ? " (dev)" : "");	if (config->pins[1])		printk(", usb1 %d wires", config->pins[1]);	if (config->pins[2])		printk(", usb2 %d wires", config->pins[2]);	printk("\n");	/* use DPLL for 48 MHz function clock */	pr_debug("APLL %04x DPLL %04x REQ %04x\n", ULPD_APLL_CTRL_REG,			ULPD_DPLL_CTRL_REG, ULPD_SOFT_REQ_REG);	ULPD_APLL_CTRL_REG &= ~APLL_NDPLL_SWITCH;	ULPD_DPLL_CTRL_REG |= DPLL_IOB | DPLL_PLL_ENABLE;	ULPD_SOFT_REQ_REG |= SOFT_UDC_REQ | SOFT_DPLL_REQ;	while (!(ULPD_DPLL_CTRL_REG & DPLL_LOCK))		cpu_relax();#ifdef	CONFIG_USB_GADGET_OMAP	if (config->register_dev) {		int status;		udc_device.dev.platform_data = config;		status = platform_device_register(&udc_device);		if (status)			pr_debug("can't register UDC device, %d\n", status);		/* udc driver gates 48MHz by D+ pullup */	}#endif#if	defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)	if (config->register_host) {		int status;		ohci_device.dev.platform_data = config;		status = platform_device_register(&ohci_device);		if (status)			pr_debug("can't register OHCI device, %d\n", status);		/* hcd explicitly gates 48MHz */	}#endif}#elsestatic inline void omap_1510_usb_init(struct omap_usb_config *config) {}#endif/*-------------------------------------------------------------------------*/static struct omap_usb_config platform_data;static int __initomap_usb_init(void){	const struct omap_usb_config *config;	config = omap_get_config(OMAP_TAG_USB, struct omap_usb_config);	if (config == NULL) {		printk(KERN_ERR "USB: No board-specific "				"platform config found\n");		return -ENODEV;	}	platform_data = *config;	if (cpu_is_omap730() || cpu_is_omap16xx() || cpu_is_omap24xx())		omap_otg_init(&platform_data);	else if (cpu_is_omap15xx())		omap_1510_usb_init(&platform_data);	else {		printk(KERN_ERR "USB: No init for your chip yet\n");		return -ENODEV;	}	return 0;}subsys_initcall(omap_usb_init);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -