ohci-omap.c
来自「Linux Kernel 2.6.9 for OMAP1710」· C语言 代码 · 共 640 行 · 第 1/2 页
C
640 行
/* * OHCI HCD (Host Controller Driver) for USB. * * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at> * (C) Copyright 2000-2004 David Brownell <dbrownell@users.sourceforge.net> * (C) Copyright 2002 Hewlett-Packard Company * * OMAP Bus Glue * * Written by Christopher Hoover <ch@hpl.hp.com> * Based on fragments of previous driver by Russell King et al. * * Modified for OMAP from ohci-sa1111.c by Tony Lindgren <tony@atomide.com> * Based on the 2.4 OMAP OHCI driver originally done by MontaVista Software Inc. * * This file is licenced under the GPL. */#include <asm/hardware.h>#include <asm/io.h>#include <asm/mach-types.h>#include <asm/arch/hardware.h>#include <asm/arch/mux.h>#include <asm/arch/irqs.h>#include <asm/arch/gpio.h>#ifndef CONFIG_ARCH_OMAP24XX#include <asm/arch/fpga.h>#include <asm/hardware/clock.h>#endif#include <asm/arch/usb.h>#include "ohci-omap.h"#if !(defined(CONFIG_ARCH_OMAP) || defined(CONFIG_ARCH_OMAP24XX))#error "This file is OMAP bus glue. CONFIG_OMAP must be defined."#endifextern int usb_disabled(void);extern int ocpi_enable(void);/* * OHCI clock initialization for OMAP-1510 and 1610 */static int omap_ohci_clock_power(int on){#ifdef CONFIG_ARCH_OMAP24XX // TO DO#else struct clk *usb_ck; struct clk *usb_host_ck; usb_ck = clk_get(0, "usb_ck"); if (IS_ERR(usb_ck)) return PTR_ERR(usb_ck); usb_host_ck = clk_get(0, "usb_hhc_ck"); if (IS_ERR(usb_host_ck)) { clk_put(usb_ck); return PTR_ERR(usb_host_ck); } if (on) { clk_enable(usb_ck); clk_enable(usb_host_ck); } else { clk_disable(usb_ck); clk_disable(usb_host_ck); } clk_put(usb_host_ck); clk_put(usb_ck);#endif return 0;}/* * Hardware specific transceiver power on/off */static int omap_ohci_transceiver_power(int on){#ifdef CONFIG_ARCH_OMAP24XX // TO DO#else if (on) { if (machine_is_omap_innovator() && cpu_is_omap1510()) fpga_write(fpga_read(INNOVATOR_FPGA_CAM_USB_CONTROL) | ((1 << 5/*usb1*/) | (1 << 3/*usb2*/)), INNOVATOR_FPGA_CAM_USB_CONTROL); else if (machine_is_omap_osk()) { /* FIXME: GPIO1 -> 1 on the TPS65010 I2C chip */ } } else { if (machine_is_omap_innovator() && cpu_is_omap1510()) fpga_write(fpga_read(INNOVATOR_FPGA_CAM_USB_CONTROL) & ~((1 << 5/*usb1*/) | (1 << 3/*usb2*/)), INNOVATOR_FPGA_CAM_USB_CONTROL); else if (machine_is_omap_osk()) { /* FIXME: GPIO1 -> 0 on the TPS65010 I2C chip */ } }#endif return 0;}/* * OMAP-1510 specific Local Bus clock on/off */static int omap_1510_local_bus_power(int on){#ifdef CONFIG_ARCH_OMAP24XX // TO DO#else if (on) { omap_writel((1 << 1) | (1 << 0), OMAP1510_LB_MMU_CTL); udelay(200); } else { omap_writel(0, OMAP1510_LB_MMU_CTL); }#endif return 0;}/* * OMAP-1510 specific Local Bus initialization * NOTE: This assumes 32MB memory size in OMAP1510LB_MEMSIZE. * See also arch/mach-omap/memory.h for __virt_to_dma() and * __dma_to_virt() which need to match with the physical * Local Bus address below. */static int omap_1510_local_bus_init(void){#ifndef CONFIG_ARCH_OMAP24XX unsigned int tlb; unsigned long lbaddr, physaddr; omap_writel((omap_readl(OMAP1510_LB_CLOCK_DIV) & 0xfffffff8) | 0x4, OMAP1510_LB_CLOCK_DIV); /* Configure the Local Bus MMU table */ for (tlb = 0; tlb < OMAP1510_LB_MEMSIZE; tlb++) { lbaddr = tlb * 0x00100000 + OMAP1510_LB_OFFSET; physaddr = tlb * 0x00100000 + PHYS_OFFSET; omap_writel((lbaddr & 0x0fffffff) >> 22, OMAP1510_LB_MMU_CAM_H); omap_writel(((lbaddr & 0x003ffc00) >> 6) | 0xc, OMAP1510_LB_MMU_CAM_L); omap_writel(physaddr >> 16, OMAP1510_LB_MMU_RAM_H); omap_writel((physaddr & 0x0000fc00) | 0x300, OMAP1510_LB_MMU_RAM_L); omap_writel(tlb << 4, OMAP1510_LB_MMU_LCK); omap_writel(0x1, OMAP1510_LB_MMU_LD_TLB); } /* Enable the walking table */ omap_writel(omap_readl(OMAP1510_LB_MMU_CTL) | (1 << 3), OMAP1510_LB_MMU_CTL); udelay(200);#endif return 0;}#ifdef CONFIG_USB_OTGstatic void start_hnp(struct ohci_hcd *ohci){ const unsigned port = ohci->hcd.self.otg_port - 1; unsigned long flags; otg_start_hnp(ohci->transceiver); local_irq_save(flags); ohci->transceiver->state = OTG_STATE_A_SUSPEND; writel (RH_PS_PSS, &ohci->regs->roothub.portstatus [port]); OTG_CTRL_REG &= ~OTG_A_BUSREQ; local_irq_restore(flags);}#endif/*-------------------------------------------------------------------------*/static int omap_start_hc(struct ohci_hcd *ohci, struct platform_device *pdev){ struct omap_usb_config *config = pdev->dev.platform_data; int need_transceiver = (config->otg != 0); dev_dbg(&pdev->dev, "starting USB Controller\n"); if (config->otg) { ohci->hcd.self.otg_port = config->otg; /* default/minimum OTG power budget: 8 mA */ ohci->power_budget = 8; } /* boards can use OTG transceivers in non-OTG modes */ need_transceiver = need_transceiver || machine_is_omap_h2() || machine_is_omap_h3() || machine_is_omap_h4(); if (cpu_is_omap16xx()) ocpi_enable();#ifdef CONFIG_ARCH_OMAP_OTG if (need_transceiver) { ohci->transceiver = otg_get_transceiver(); if (ohci->transceiver) { int status = otg_set_host(ohci->transceiver, &ohci->hcd.self); dev_dbg(&pdev->dev, "init %s transceiver, status %d\n", ohci->transceiver->label, status); if (status) { if (ohci->transceiver) put_device(ohci->transceiver->dev); return status; } } else { dev_err(&pdev->dev, "can't find transceiver\n"); return -ENODEV; } }#endif if (machine_is_omap_osk()) { omap_request_gpio(9); omap_set_gpio_direction(9, 1); omap_set_gpio_dataout(9, 1); } omap_ohci_clock_power(1); omap_ohci_transceiver_power(1); if (cpu_is_omap1510()) { omap_1510_local_bus_power(1); omap_1510_local_bus_init(); } /* board init will have already handled HMC and mux setup. * any external transceiver should already be initialized * too, so all configured ports use the right signaling now. */ return 0;}static void omap_stop_hc(struct platform_device *pdev){ dev_dbg(&pdev->dev, "stopping USB Controller\n"); /* * FIXME: Put the USB host controller into reset. */ /* * FIXME: Stop the USB clock. */ //omap_disable_device(dev);}/*-------------------------------------------------------------------------*/void usb_hcd_omap_remove (struct usb_hcd *, struct platform_device *);/* configure so an HC device and id are always provided *//* always called with process context; sleeping is OK *//** * usb_hcd_omap_probe - initialize OMAP-based HCDs * Context: !in_interrupt() * * Allocates basic resources for this USB host controller, and * then invokes the start() method for the HCD associated with it * through the hotplug entry's driver_data. */int usb_hcd_omap_probe (const struct hc_driver *driver, struct platform_device *pdev){ int retval; struct usb_hcd *hcd = 0; struct ohci_hcd *ohci; int num_resources = 2; if(cpu_is_omap2420()) num_resources = 3; if (pdev->num_resources != num_resources) { printk(KERN_ERR "hcd probe: invalid num_resources: %i\n", pdev->num_resources); return -ENODEV; } if (pdev->resource[0].flags != IORESOURCE_MEM || pdev->resource[1].flags != IORESOURCE_IRQ) { printk(KERN_ERR "hcd probe: invalid resource type\n"); return -ENODEV; } if (!request_mem_region(pdev->resource[0].start, pdev->resource[0].end - pdev->resource[0].start + 1, hcd_name)) { dev_dbg(&pdev->dev, "request_mem_region failed\n"); return -EBUSY; } hcd = driver->hcd_alloc (); if (hcd == NULL){ dev_dbg(&pdev->dev, "hcd_alloc failed\n"); retval = -ENOMEM; goto err1; } dev_set_drvdata(&pdev->dev, hcd); ohci = hcd_to_ohci(hcd); hcd->driver = (struct hc_driver *) driver; hcd->description = driver->description; hcd->irq = pdev->resource[1].start; hcd->regs = (void *)pdev->resource[0].start;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?