void usb_host_hsic_power_init() { int retval; struct regulator *usb_hsic_reg; usb_hsic_reg = regulator_get(NULL, "vhsic"); if (IS_ERR(usb_hsic_reg)) { retval = PTR_ERR(usb_hsic_reg); //dev_err(&pdev->dev, "No VHSIC_1.2V regualtor: %d\n", // retval); usb_hsic_reg = NULL; } if (usb_hsic_reg) retval=regulator_enable(usb_hsic_reg); if (s5pv210_onoff_flag == 0) { s5pv210_start_ehc(); #if defined(CONFIG_ARCH_S5PV310) writel(0x03C00000, s5pv210_hcd->regs + 0x90); #endif retval = usb_add_hcd(s5pv210_hcd, IRQ_UHOST, IRQF_DISABLED | IRQF_SHARED); if (retval < 0) { //dev_err(dev, "Power On Fail\n"); //goto exit; } s5pv210_onoff_flag = 1; } }
static int s5pv210_ehci_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct usb_hcd *hcd = platform_get_drvdata(pdev); struct ehci_hcd *ehci = hcd_to_ehci(hcd); usb_host_phy_power_init(pdev); if (s5pv210_hcd == NULL) { dev_info(dev, "Nothing to do for the device (power off)\n"); return 0; } ehci_info(ehci, "resume\n"); pm_runtime_resume(&pdev->dev); s5pv210_start_ehc(); #if defined(CONFIG_ARCH_S5PV310) writel(0x03C00000, hcd->regs + 0x90); #endif if (time_before(jiffies, ehci->next_statechange)) msleep(10); /* Mark hardware accessible again as we are out of D3 state by now */ set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); if (ehci_readl(ehci, &ehci->regs->configured_flag) == FLAG_CF) { int mask = INTR_MASK; if (!hcd->self.root_hub->do_remote_wakeup) mask &= ~STS_PCD; ehci_writel(ehci, mask, &ehci->regs->intr_enable); ehci_readl(ehci, &ehci->regs->intr_enable); return 0; } ehci_info(ehci, "lost power, restarting\n"); usb_root_hub_lost_power(hcd->self.root_hub); (void) ehci_halt(ehci); (void) ehci_reset(ehci); /* emptying the schedule aborts any urbs */ spin_lock_irq(&ehci->lock); if (ehci->reclaim) end_unlink_async(ehci); ehci_work(ehci); spin_unlock_irq(&ehci->lock); ehci_writel(ehci, ehci->command, &ehci->regs->command); ehci_writel(ehci, FLAG_CF, &ehci->regs->configured_flag); ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */ /* here we "know" root ports should always stay powered */ ehci_port_power(ehci, 1); hcd->state = HC_STATE_SUSPENDED; return 0; }
static ssize_t store_ehci_power(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct usb_hcd *hcd = bus_to_hcd(dev_get_drvdata(dev)); int power_on; int retval; if (sscanf(buf, "%d", &power_on) != 1) return -EINVAL; device_lock(dev); if (power_on == 0 && s5pv210_hcd != NULL) { printk(KERN_DEBUG "%s: EHCI turns off\n", __func__); usb_remove_hcd(hcd); s5pv210_stop_ehc(); s5pv210_hcd = NULL; /*HSIC IPC control the ACTIVE_STATE*/ #ifdef CONFIG_SAMSUNG_PHONE_SVNET mc_control_active_state(0); #endif } else if (power_on == 1) { printk(KERN_DEBUG "%s: EHCI turns on\n", __func__); if (s5pv210_hcd != NULL) { usb_remove_hcd(hcd); /*HSIC IPC control the ACTIVE_STATE*/ #ifdef CONFIG_SAMSUNG_PHONE_SVNET mc_control_active_state(0); #endif } s5pv210_start_ehc(); #if defined(CONFIG_ARCH_S5PV310) writel(0x03C00000, hcd->regs + 0x90); #endif retval = usb_add_hcd(hcd, IRQ_UHOST, IRQF_DISABLED | IRQF_SHARED); if (retval < 0) { dev_err(dev, "Power On Fail\n"); goto exit; } /*HSIC IPC control the ACTIVE_STATE*/ #ifdef CONFIG_SAMSUNG_PHONE_SVNET mc_control_active_state(1); #endif s5pv210_hcd = hcd; } exit: device_unlock(dev); return count; }
static int ehci_hcd_s5pv210_drv_probe(struct platform_device *pdev) { struct usb_hcd *hcd = NULL; struct ehci_hcd *ehci = NULL; int retval = 0; if (usb_disabled()) return -ENODEV; usb_host_phy_off(); if (pdev->resource[1].flags != IORESOURCE_IRQ) { dev_err(&pdev->dev, "resource[1] is not IORESOURCE_IRQ.\n"); return -ENODEV; } hcd = usb_create_hcd(&ehci_s5pv210_hc_driver, &pdev->dev, "s5pv210"); if (!hcd) { dev_err(&pdev->dev, "usb_create_hcd failed!\n"); return -ENODEV; } hcd->rsrc_start = pdev->resource[0].start; hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1; if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { dev_err(&pdev->dev, "request_mem_region failed!\n"); retval = -EBUSY; goto err1; } usb_clk = clk_get(&pdev->dev, "usbhost"); if (IS_ERR(usb_clk)) { dev_err(&pdev->dev, "cannot get usb-host clock\n"); retval = -ENODEV; goto err2; } s5pv210_start_ehc(); hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); if (!hcd->regs) { dev_err(&pdev->dev, "ioremap failed!\n"); retval = -ENOMEM; goto err2; } ehci = hcd_to_ehci(hcd); ehci->caps = hcd->regs; ehci->regs = hcd->regs + HC_LENGTH(readl(&ehci->caps->hc_capbase)); /* cache this readonly data; minimize chip reads */ ehci->hcs_params = readl(&ehci->caps->hcs_params); writel(0x00600040, hcd->regs + 0x94); retval = usb_add_hcd(hcd, pdev->resource[1].start, IRQF_DISABLED | IRQF_SHARED); if (retval == 0) { platform_set_drvdata(pdev, hcd); return retval; } s5pv210_stop_ehc(); iounmap(hcd->regs); err2: release_mem_region(hcd->rsrc_start, hcd->rsrc_len); err1: clk_put(usb_clk); usb_put_hcd(hcd); return retval; }
static int ehci_hcd_s5pv210_drv_probe(struct platform_device *pdev) { struct usb_hcd *hcd = NULL; struct ehci_hcd *ehci = NULL; int retval = 0; if (usb_disabled()) return -ENODEV; if (pdev->resource[1].flags != IORESOURCE_IRQ) { dev_err(&pdev->dev, "resource[1] is not IORESOURCE_IRQ.\n"); return -ENODEV; } hcd = usb_create_hcd(&ehci_s5pv210_hc_driver, &pdev->dev, "s5pv210"); if (!hcd) { dev_err(&pdev->dev, "usb_create_hcd failed!\n"); return -ENODEV; } hcd->rsrc_start = pdev->resource[0].start; hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1; if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { dev_err(&pdev->dev, "request_mem_region failed!\n"); retval = -EBUSY; goto err1; } usb_host_phy_power_init(pdev); s5pv210_start_ehc(); hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); if (!hcd->regs) { dev_err(&pdev->dev, "ioremap failed!\n"); retval = -ENOMEM; goto err2; } ehci = hcd_to_ehci(hcd); ehci->caps = hcd->regs; ehci->regs = hcd->regs + HC_LENGTH(readl(&ehci->caps->hc_capbase)); /* cache this readonly data; minimize chip reads */ ehci->hcs_params = readl(&ehci->caps->hcs_params); #if defined(CONFIG_ARCH_S5PV210) || defined(CONFIG_ARCH_S5P6450) writel(0x000F0000, hcd->regs + 0x90); #endif #if defined(CONFIG_ARCH_S5PV310) writel(0x03C00000, hcd->regs + 0x90); #endif if (create_ehci_sys_file(ehci) < 0) { dev_err(&pdev->dev, "Failed to create ehci sysfs\n"); } retval = usb_add_hcd(hcd, pdev->resource[1].start, IRQF_DISABLED | IRQF_SHARED); if (retval == 0) { platform_set_drvdata(pdev, hcd); s5pv210_hcd = hcd; #ifdef CONFIG_USB_SUSPEND pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev); pm_runtime_forbid(&pdev->dev); #endif /*HSIC IPC control the ACTIVE_STATE*/ #ifdef CONFIG_SAMSUNG_PHONE_SVNET mc_control_active_state(1); #endif return retval; } remove_ehci_sys_file(ehci); s5pv210_stop_ehc(); iounmap(hcd->regs); err2: release_mem_region(hcd->rsrc_start, hcd->rsrc_len); err1: usb_put_hcd(hcd); return retval; }