forked from luck/tmp_suning_uos_patched
8c68e84f3a
Separate the Qualcomm QSD/MSM on-chip host controller driver from
ehci-hcd host code so that it can be built as a separate driver module.
This work is part of enabling multi-platform kernels on ARM;
however, note that other changes are still needed before Qualcomm QSD/MSM
can be booted with a multi-platform kernel, which is not expected before
3.11.
With the infrastructure added by Alan Stern in patch 3e0232039
"USB: EHCI: prepare to make ehci-hcd a library module", we can
avoid this problem by turning a bus glue into a separate
module, as we do here for the msm bus glue.
In V5 (arnd):
- add FIXME about missing usb_add_hcd() or usb_remove_hcd() calls
In V3:
- Detailed commit message added here describing why this patch is required.
- Arranged #include's in alphabetical order.
- driver.name initialized hcd_name[] = "ehci-msm" in platform_driver
structure initialization instead of "msm-ehci", which was the reason
why it broke in EHCI USB testing
In V2:
Tegra patch related changes removed from this patch.
Signed-off-by: Manjunath Goudar <manjunath.goudar@linaro.org>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: David Brown <davidb@codeaurora.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
222 lines
5.2 KiB
C
222 lines
5.2 KiB
C
/* ehci-msm.c - HSUSB Host Controller Driver Implementation
|
|
*
|
|
* Copyright (c) 2008-2011, Code Aurora Forum. All rights reserved.
|
|
*
|
|
* Partly derived from ehci-fsl.c and ehci-hcd.c
|
|
* Copyright (c) 2000-2004 by David Brownell
|
|
* Copyright (c) 2005 MontaVista Software
|
|
*
|
|
* All source code in this file is licensed under the following license except
|
|
* where indicated.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License version 2 as published
|
|
* by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
*
|
|
* See the GNU General Public License for more details.
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, you can find it at http://www.fsf.org
|
|
*/
|
|
|
|
#include <linux/clk.h>
|
|
#include <linux/err.h>
|
|
#include <linux/io.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/module.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/pm_runtime.h>
|
|
#include <linux/usb/otg.h>
|
|
#include <linux/usb/msm_hsusb_hw.h>
|
|
#include <linux/usb.h>
|
|
#include <linux/usb/hcd.h>
|
|
|
|
#include "ehci.h"
|
|
|
|
#define MSM_USB_BASE (hcd->regs)
|
|
|
|
#define DRIVER_DESC "Qualcomm On-Chip EHCI Host Controller"
|
|
|
|
static const char hcd_name[] = "ehci-msm";
|
|
static struct hc_driver __read_mostly msm_hc_driver;
|
|
static struct usb_phy *phy;
|
|
|
|
static int ehci_msm_reset(struct usb_hcd *hcd)
|
|
{
|
|
struct ehci_hcd *ehci = hcd_to_ehci(hcd);
|
|
int retval;
|
|
|
|
ehci->caps = USB_CAPLENGTH;
|
|
hcd->has_tt = 1;
|
|
|
|
retval = ehci_setup(hcd);
|
|
if (retval)
|
|
return retval;
|
|
|
|
/* bursts of unspecified length. */
|
|
writel(0, USB_AHBBURST);
|
|
/* Use the AHB transactor */
|
|
writel(0, USB_AHBMODE);
|
|
/* Disable streaming mode and select host mode */
|
|
writel(0x13, USB_USBMODE);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int ehci_msm_probe(struct platform_device *pdev)
|
|
{
|
|
struct usb_hcd *hcd;
|
|
struct resource *res;
|
|
int ret;
|
|
|
|
dev_dbg(&pdev->dev, "ehci_msm proble\n");
|
|
|
|
hcd = usb_create_hcd(&msm_hc_driver, &pdev->dev, dev_name(&pdev->dev));
|
|
if (!hcd) {
|
|
dev_err(&pdev->dev, "Unable to create HCD\n");
|
|
return -ENOMEM;
|
|
}
|
|
|
|
hcd->irq = platform_get_irq(pdev, 0);
|
|
if (hcd->irq < 0) {
|
|
dev_err(&pdev->dev, "Unable to get IRQ resource\n");
|
|
ret = hcd->irq;
|
|
goto put_hcd;
|
|
}
|
|
|
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
if (!res) {
|
|
dev_err(&pdev->dev, "Unable to get memory resource\n");
|
|
ret = -ENODEV;
|
|
goto put_hcd;
|
|
}
|
|
|
|
hcd->rsrc_start = res->start;
|
|
hcd->rsrc_len = resource_size(res);
|
|
hcd->regs = devm_ioremap(&pdev->dev, hcd->rsrc_start, hcd->rsrc_len);
|
|
if (!hcd->regs) {
|
|
dev_err(&pdev->dev, "ioremap failed\n");
|
|
ret = -ENOMEM;
|
|
goto put_hcd;
|
|
}
|
|
|
|
/*
|
|
* OTG driver takes care of PHY initialization, clock management,
|
|
* powering up VBUS, mapping of registers address space and power
|
|
* management.
|
|
*/
|
|
phy = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2);
|
|
if (IS_ERR(phy)) {
|
|
dev_err(&pdev->dev, "unable to find transceiver\n");
|
|
ret = -ENODEV;
|
|
goto put_hcd;
|
|
}
|
|
|
|
ret = otg_set_host(phy->otg, &hcd->self);
|
|
if (ret < 0) {
|
|
dev_err(&pdev->dev, "unable to register with transceiver\n");
|
|
goto put_hcd;
|
|
}
|
|
|
|
device_init_wakeup(&pdev->dev, 1);
|
|
/*
|
|
* OTG device parent of HCD takes care of putting
|
|
* hardware into low power mode.
|
|
*/
|
|
pm_runtime_no_callbacks(&pdev->dev);
|
|
pm_runtime_enable(&pdev->dev);
|
|
|
|
/* FIXME: need to call usb_add_hcd() here? */
|
|
|
|
return 0;
|
|
|
|
put_hcd:
|
|
usb_put_hcd(hcd);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static int ehci_msm_remove(struct platform_device *pdev)
|
|
{
|
|
struct usb_hcd *hcd = platform_get_drvdata(pdev);
|
|
|
|
device_init_wakeup(&pdev->dev, 0);
|
|
pm_runtime_disable(&pdev->dev);
|
|
pm_runtime_set_suspended(&pdev->dev);
|
|
|
|
otg_set_host(phy->otg, NULL);
|
|
|
|
/* FIXME: need to call usb_remove_hcd() here? */
|
|
|
|
usb_put_hcd(hcd);
|
|
|
|
return 0;
|
|
}
|
|
|
|
#ifdef CONFIG_PM
|
|
static int ehci_msm_pm_suspend(struct device *dev)
|
|
{
|
|
struct usb_hcd *hcd = dev_get_drvdata(dev);
|
|
bool do_wakeup = device_may_wakeup(dev);
|
|
|
|
dev_dbg(dev, "ehci-msm PM suspend\n");
|
|
|
|
return ehci_suspend(hcd, do_wakeup);
|
|
}
|
|
|
|
static int ehci_msm_pm_resume(struct device *dev)
|
|
{
|
|
struct usb_hcd *hcd = dev_get_drvdata(dev);
|
|
|
|
dev_dbg(dev, "ehci-msm PM resume\n");
|
|
ehci_resume(hcd, false);
|
|
|
|
return 0;
|
|
}
|
|
#else
|
|
#define ehci_msm_pm_suspend NULL
|
|
#define ehci_msm_pm_resume NULL
|
|
#endif
|
|
|
|
static const struct dev_pm_ops ehci_msm_dev_pm_ops = {
|
|
.suspend = ehci_msm_pm_suspend,
|
|
.resume = ehci_msm_pm_resume,
|
|
};
|
|
|
|
static struct platform_driver ehci_msm_driver = {
|
|
.probe = ehci_msm_probe,
|
|
.remove = ehci_msm_remove,
|
|
.driver = {
|
|
.name = "msm_hsusb_host",
|
|
.pm = &ehci_msm_dev_pm_ops,
|
|
},
|
|
};
|
|
|
|
static const struct ehci_driver_overrides msm_overrides __initdata = {
|
|
.reset = ehci_msm_reset,
|
|
};
|
|
|
|
static int __init ehci_msm_init(void)
|
|
{
|
|
if (usb_disabled())
|
|
return -ENODEV;
|
|
|
|
pr_info("%s: " DRIVER_DESC "\n", hcd_name);
|
|
ehci_init_driver(&msm_hc_driver, &msm_overrides);
|
|
return platform_driver_register(&ehci_msm_driver);
|
|
}
|
|
module_init(ehci_msm_init);
|
|
|
|
static void __exit ehci_msm_cleanup(void)
|
|
{
|
|
platform_driver_unregister(&ehci_msm_driver);
|
|
}
|
|
module_exit(ehci_msm_cleanup);
|
|
|
|
MODULE_DESCRIPTION(DRIVER_DESC);
|
|
MODULE_ALIAS("platform:msm-ehci");
|
|
MODULE_LICENSE("GPL");
|