mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-15 01:24:33 +00:00
2d4d9f35ba
This time, a very pull request with 216 non-merge commits. Most of the commits contained here are sparse or coccinelle fixes ranging from missing 'static' to returning 0 in case of errors. More importantly, we have the removal the now unnecessary 'driver' argument to ->udc_stop(). DWC2 learned about Dual-Role builds. Users of this IP can now have a single driver built for host and device roles. DWC3 got support for two new HW platforms: Exynos7 and AMD. The Broadcom USB 3.0 Device Controller IP is now supported and so is PLX USB338x, which means DWC3 has lost is badge as the only USB 3.0 peripheral IP supported on Linux. Thanks for Tony Lindgren's work, we can now have a distro-like kernel where all MUSB glue layers can be built into the same kernel (statically or dynamically linked) and it'll work in PIO (DMA will come probably on v3.20). Other than these, the usual set of cleanups and non-critical fixes. Signed-off-by: Felipe Balbi <balbi@ti.com> -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAABAgAGBQJUdJoNAAoJEIaOsuA1yqREqDoP/iwVojhk1qb2PQAJvLkl8To4 R34RM8zt8IRhE+yWIW8hm8xvsLiwvujBMgsphUmyu2k0X/NtPl1ElrDvObWwO0N8 ouyLISRw/wLUs8hJwsNVhIX0VjPxDQ6648C3OZYjySTtNtsh0rBw84ALX+IWkDye Thb823xEunGYVwjhq8WrfT94q6LjyPp00XHlA4mf3XgSpXC2tKBFGmIcfmwObzYI LkON7kJTp14XEeIYGYJO+7MBpo8s7YFmnpsDOV2QYlz/i0pRdjLwaKMN5T7D7DO5 YdvcQFQUM53dvq+tiw2k2iW4gmn9ktHHlckn8W5hhQZCs4ujSzYy/vP4GcbNEaTf CuDocJGTr7ieU2IqYiTM+wRYavBoHLq9V5AHZmgsZ/pVF8lvG0hcX0fmd7XXScjv GaKJqyQMaKZ9tRF9RZdMZeOrICp1X1X+KcqdG7yXoOtsVdn0O3zHdxYcZcVa29X/ cXuttoTywQgfrlI/uWWwpkYlqiHeawK1EooZ/6fYQDviLm4lrLPp94vF/5MqGM1j f2tNpG63iOzLUUYJa+YgPqs6RrZLM3soZcf3bFAEt9sA99gc3ExwCYXurBEnTONr XUowTfNKxPaVjNPZ1evGwF5F+WLEK4s88weB9lArd2S3NFP3DQV1cRpWj8rLYE72 lX6aWEWUDqnUHmwJUgIb =WYyZ -----END PGP SIGNATURE----- Merge tag 'usb-for-v3.19' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-next Felipe writes: usb: patches for v3.19 merge window This time, a very pull request with 216 non-merge commits. Most of the commits contained here are sparse or coccinelle fixes ranging from missing 'static' to returning 0 in case of errors. More importantly, we have the removal the now unnecessary 'driver' argument to ->udc_stop(). DWC2 learned about Dual-Role builds. Users of this IP can now have a single driver built for host and device roles. DWC3 got support for two new HW platforms: Exynos7 and AMD. The Broadcom USB 3.0 Device Controller IP is now supported and so is PLX USB338x, which means DWC3 has lost is badge as the only USB 3.0 peripheral IP supported on Linux. Thanks for Tony Lindgren's work, we can now have a distro-like kernel where all MUSB glue layers can be built into the same kernel (statically or dynamically linked) and it'll work in PIO (DMA will come probably on v3.20). Other than these, the usual set of cleanups and non-critical fixes. Signed-off-by: Felipe Balbi <balbi@ti.com>
182 lines
4.0 KiB
C
182 lines
4.0 KiB
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;
|
|
|
|
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 && !ci_otg_is_fsm_mode(ci)) {
|
|
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;
|
|
}
|
|
}
|
|
return 0;
|
|
};
|
|
|
|
static const struct ehci_driver_overrides ehci_ci_overrides = {
|
|
.extra_priv_size = sizeof(struct ehci_ci_priv),
|
|
.port_power = ehci_ci_portpower,
|
|
};
|
|
|
|
static irqreturn_t host_irq(struct ci_hdrc *ci)
|
|
{
|
|
return usb_hcd_irq(ci->irq, ci->hcd);
|
|
}
|
|
|
|
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)
|
|
priv->reg_vbus = ci->platdata->reg_vbus;
|
|
|
|
ret = usb_add_hcd(hcd, 0, 0);
|
|
if (ret) {
|
|
goto put_hcd;
|
|
} 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;
|
|
}
|
|
}
|
|
|
|
if (ci->platdata->flags & CI_HDRC_DISABLE_STREAMING)
|
|
hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, USBMODE_CI_SDIS);
|
|
|
|
return ret;
|
|
|
|
put_hcd:
|
|
usb_put_hcd(hcd);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static void host_stop(struct ci_hdrc *ci)
|
|
{
|
|
struct usb_hcd *hcd = ci->hcd;
|
|
|
|
if (hcd) {
|
|
usb_remove_hcd(hcd);
|
|
usb_put_hcd(hcd);
|
|
}
|
|
}
|
|
|
|
|
|
void ci_hdrc_host_destroy(struct ci_hdrc *ci)
|
|
{
|
|
if (ci->role == CI_ROLE_HOST && ci->hcd)
|
|
host_stop(ci);
|
|
}
|
|
|
|
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;
|
|
|
|
ehci_init_driver(&ci_ehci_hc_driver, &ehci_ci_overrides);
|
|
|
|
return 0;
|
|
}
|