Release 4.11 drivers/usb/chipidea/host.c
/*
* host.c - ChipIdea USB host controller driver
*
* Copyright (c) 2012 Intel Corporation
*
* Author: Alexander Shishkin
*
* 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, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <linux/kernel.h>
#include <linux/io.h>
#include <linux/usb.h>
#include <linux/usb/hcd.h>
#include <linux/usb/chipidea.h>
#include <linux/regulator/consumer.h>
#include "../host/ehci.h"
#include "ci.h"
#include "bits.h"
#include "host.h"
static struct hc_driver __read_mostly ci_ehci_hc_driver;
static int (*orig_bus_suspend)(struct usb_hcd *hcd);
struct ehci_ci_priv {
struct regulator *reg_vbus;
};
static int ehci_ci_portpower(struct usb_hcd *hcd, int portnum, bool enable)
{
struct ehci_hcd *ehci = hcd_to_ehci(hcd);
struct ehci_ci_priv *priv = (struct ehci_ci_priv *)ehci->priv;
struct device *dev = hcd->self.controller;
struct ci_hdrc *ci = dev_get_drvdata(dev);
int ret = 0;
int port = HCS_N_PORTS(ehci->hcs_params);
if (priv->reg_vbus) {
if (port > 1) {
dev_warn(dev,
"Not support multi-port regulator control\n");
return 0;
}
if (enable)
ret = regulator_enable(priv->reg_vbus);
else
ret = regulator_disable(priv->reg_vbus);
if (ret) {
dev_err(dev,
"Failed to %s vbus regulator, ret=%d\n",
enable ? "enable" : "disable", ret);
return ret;
}
}
if (enable && (ci->platdata->phy_mode == USBPHY_INTERFACE_MODE_HSIC)) {
/*
* Marvell 28nm HSIC PHY requires forcing the port to HS mode.
* As HSIC is always HS, this should be safe for others.
*/
hw_port_test_set(ci, 5);
hw_port_test_set(ci, 0);
}
return 0;
}Contributors
Person | Tokens | Prop | Commits | CommitProp |
Michael Grzeschik | 143 | 77.72% | 1 | 33.33% |
Rob Herring | 31 | 16.85% | 1 | 33.33% |
Peter Chen | 10 | 5.43% | 1 | 33.33% |
Total | 184 | 100.00% | 3 | 100.00% |
;
static int ehci_ci_reset(struct usb_hcd *hcd)
{
struct device *dev = hcd->self.controller;
struct ci_hdrc *ci = dev_get_drvdata(dev);
struct ehci_hcd *ehci = hcd_to_ehci(hcd);
int ret;
ret = ehci_setup(hcd);
if (ret)
return ret;
ehci->need_io_watchdog = 0;
if (ci->platdata->notify_event) {
ret = ci->platdata->notify_event(ci,
CI_HDRC_CONTROLLER_RESET_EVENT);
if (ret)
return ret;
}
ci_platform_configure(ci);
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Peter Chen | 57 | 55.34% | 1 | 25.00% |
Stephen Boyd | 30 | 29.13% | 2 | 50.00% |
Lucas Stach | 16 | 15.53% | 1 | 25.00% |
Total | 103 | 100.00% | 4 | 100.00% |
static const struct ehci_driver_overrides ehci_ci_overrides = {
.extra_priv_size = sizeof(struct ehci_ci_priv),
.port_power = ehci_ci_portpower,
.reset = ehci_ci_reset,
};
static irqreturn_t host_irq(struct ci_hdrc *ci)
{
return usb_hcd_irq(ci->irq, ci->hcd);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Alexander Shishkin | 23 | 100.00% | 2 | 100.00% |
Total | 23 | 100.00% | 2 | 100.00% |
static int host_start(struct ci_hdrc *ci)
{
struct usb_hcd *hcd;
struct ehci_hcd *ehci;
struct ehci_ci_priv *priv;
int ret;
if (usb_disabled())
return -ENODEV;
hcd = usb_create_hcd(&ci_ehci_hc_driver, ci->dev, dev_name(ci->dev));
if (!hcd)
return -ENOMEM;
dev_set_drvdata(ci->dev, ci);
hcd->rsrc_start = ci->hw_bank.phys;
hcd->rsrc_len = ci->hw_bank.size;
hcd->regs = ci->hw_bank.abs;
hcd->has_tt = 1;
hcd->power_budget = ci->platdata->power_budget;
hcd->tpl_support = ci->platdata->tpl_support;
if (ci->phy)
hcd->phy = ci->phy;
else
hcd->usb_phy = ci->usb_phy;
ehci = hcd_to_ehci(hcd);
ehci->caps = ci->hw_bank.cap;
ehci->has_hostpc = ci->hw_bank.lpm;
ehci->has_tdi_phy_lpm = ci->hw_bank.lpm;
ehci->imx28_write_fix = ci->imx28_write_fix;
priv = (struct ehci_ci_priv *)ehci->priv;
priv->reg_vbus = NULL;
if (ci->platdata->reg_vbus && !ci_otg_is_fsm_mode(ci)) {
if (ci->platdata->flags & CI_HDRC_TURN_VBUS_EARLY_ON) {
ret = regulator_enable(ci->platdata->reg_vbus);
if (ret) {
dev_err(ci->dev,
"Failed to enable vbus regulator, ret=%d\n",
ret);
goto put_hcd;
}
} else {
priv->reg_vbus = ci->platdata->reg_vbus;
}
}
ret = usb_add_hcd(hcd, 0, 0);
if (ret) {
goto disable_reg;
} else {
struct usb_otg *otg = &ci->otg;
ci->hcd = hcd;
if (ci_otg_is_fsm_mode(ci)) {
otg->host = &hcd->self;
hcd->self.otg_port = 1;
}
}
return ret;
disable_reg:
if (ci->platdata->reg_vbus && !ci_otg_is_fsm_mode(ci) &&
(ci->platdata->flags & CI_HDRC_TURN_VBUS_EARLY_ON))
regulator_disable(ci->platdata->reg_vbus);
put_hcd:
usb_put_hcd(hcd);
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Alexander Shishkin | 158 | 39.40% | 3 | 18.75% |
Li Jun | 123 | 30.67% | 2 | 12.50% |
Peter Chen | 51 | 12.72% | 4 | 25.00% |
Antoine Ténart | 25 | 6.23% | 2 | 12.50% |
Michael Grzeschik | 25 | 6.23% | 1 | 6.25% |
Tuomas Tynkkynen | 10 | 2.49% | 1 | 6.25% |
Richard Zhao | 7 | 1.75% | 2 | 12.50% |
Fabio Estevam | 2 | 0.50% | 1 | 6.25% |
Total | 401 | 100.00% | 16 | 100.00% |
static void host_stop(struct ci_hdrc *ci)
{
struct usb_hcd *hcd = ci->hcd;
if (hcd) {
if (ci->platdata->notify_event)
ci->platdata->notify_event(ci,
CI_HDRC_CONTROLLER_STOPPED_EVENT);
usb_remove_hcd(hcd);
ci->role = CI_ROLE_END;
synchronize_irq(ci->irq);
usb_put_hcd(hcd);
if (ci->platdata->reg_vbus && !ci_otg_is_fsm_mode(ci) &&
(ci->platdata->flags & CI_HDRC_TURN_VBUS_EARLY_ON))
regulator_disable(ci->platdata->reg_vbus);
}
ci->hcd = NULL;
ci->otg.host = NULL;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Li Jun | 47 | 40.87% | 2 | 25.00% |
Alexander Shishkin | 30 | 26.09% | 2 | 25.00% |
Stephen Boyd | 19 | 16.52% | 1 | 12.50% |
Stefan Wahren | 13 | 11.30% | 1 | 12.50% |
Russell King | 5 | 4.35% | 1 | 12.50% |
Peter Chen | 1 | 0.87% | 1 | 12.50% |
Total | 115 | 100.00% | 8 | 100.00% |
void ci_hdrc_host_destroy(struct ci_hdrc *ci)
{
if (ci->role == CI_ROLE_HOST && ci->hcd)
host_stop(ci);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Peter Chen | 27 | 100.00% | 2 | 100.00% |
Total | 27 | 100.00% | 2 | 100.00% |
static int ci_ehci_bus_suspend(struct usb_hcd *hcd)
{
struct ehci_hcd *ehci = hcd_to_ehci(hcd);
int port;
u32 tmp;
int ret = orig_bus_suspend(hcd);
if (ret)
return ret;
port = HCS_N_PORTS(ehci->hcs_params);
while (port--) {
u32 __iomem *reg = &ehci->regs->port_status[port];
u32 portsc = ehci_readl(ehci, reg);
if (portsc & PORT_CONNECT) {
/*
* For chipidea, the resume signal will be ended
* automatically, so for remote wakeup case, the
* usbcmd.rs may not be set before the resume has
* ended if other resume paths consumes too much
* time (~24ms), in that case, the SOF will not
* send out within 3ms after resume ends, then the
* high speed device will enter full speed mode.
*/
tmp = ehci_readl(ehci, &ehci->regs->command);
tmp |= CMD_RUN;
ehci_writel(ehci, tmp, &ehci->regs->command);
/*
* It needs a short delay between set RS bit and PHCD.
*/
usleep_range(150, 200);
break;
}
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Peter Chen | 136 | 100.00% | 1 | 100.00% |
Total | 136 | 100.00% | 1 | 100.00% |
int ci_hdrc_host_init(struct ci_hdrc *ci)
{
struct ci_role_driver *rdrv;
if (!hw_read(ci, CAP_DCCPARAMS, DCCPARAMS_HC))
return -ENXIO;
rdrv = devm_kzalloc(ci->dev, sizeof(struct ci_role_driver), GFP_KERNEL);
if (!rdrv)
return -ENOMEM;
rdrv->start = host_start;
rdrv->stop = host_stop;
rdrv->irq = host_irq;
rdrv->name = "host";
ci->roles[CI_ROLE_HOST] = rdrv;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Alexander Shishkin | 89 | 95.70% | 2 | 66.67% |
Peter Chen | 4 | 4.30% | 1 | 33.33% |
Total | 93 | 100.00% | 3 | 100.00% |
void ci_hdrc_host_driver_init(void)
{
ehci_init_driver(&ci_ehci_hc_driver, &ehci_ci_overrides);
orig_bus_suspend = ci_ehci_hc_driver.bus_suspend;
ci_ehci_hc_driver.bus_suspend = ci_ehci_bus_suspend;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Peter Chen | 18 | 64.29% | 2 | 40.00% |
Alan Stern | 7 | 25.00% | 1 | 20.00% |
Michael Grzeschik | 2 | 7.14% | 1 | 20.00% |
Alexander Shishkin | 1 | 3.57% | 1 | 20.00% |
Total | 28 | 100.00% | 5 | 100.00% |
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Alexander Shishkin | 325 | 27.13% | 3 | 9.68% |
Peter Chen | 325 | 27.13% | 10 | 32.26% |
Michael Grzeschik | 203 | 16.94% | 1 | 3.23% |
Li Jun | 170 | 14.19% | 3 | 9.68% |
Stephen Boyd | 49 | 4.09% | 2 | 6.45% |
Rob Herring | 31 | 2.59% | 1 | 3.23% |
Antoine Ténart | 25 | 2.09% | 2 | 6.45% |
Alan Stern | 17 | 1.42% | 2 | 6.45% |
Lucas Stach | 16 | 1.34% | 1 | 3.23% |
Stefan Wahren | 13 | 1.09% | 1 | 3.23% |
Tuomas Tynkkynen | 10 | 0.83% | 1 | 3.23% |
Richard Zhao | 7 | 0.58% | 2 | 6.45% |
Russell King | 5 | 0.42% | 1 | 3.23% |
Fabio Estevam | 2 | 0.17% | 1 | 3.23% |
Total | 1198 | 100.00% | 31 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.