Commit 4efb2f69 authored by Yoshihiro Shimoda's avatar Yoshihiro Shimoda Committed by Greg Kroah-Hartman

usb: host: xhci-plat: add struct xhci_plat_priv

This patch adds struct xhci_plat_priv to simplify the code to match
platform specific variables. For now, this patch adds a member "type"
in the structure.
Signed-off-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 79a17ddf
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <linux/acpi.h> #include <linux/acpi.h>
#include "xhci.h" #include "xhci.h"
#include "xhci-plat.h"
#include "xhci-mvebu.h" #include "xhci-mvebu.h"
#include "xhci-rcar.h" #include "xhci-rcar.h"
...@@ -31,6 +32,7 @@ static int xhci_plat_setup(struct usb_hcd *hcd); ...@@ -31,6 +32,7 @@ static int xhci_plat_setup(struct usb_hcd *hcd);
static int xhci_plat_start(struct usb_hcd *hcd); static int xhci_plat_start(struct usb_hcd *hcd);
static const struct xhci_driver_overrides xhci_plat_overrides __initconst = { static const struct xhci_driver_overrides xhci_plat_overrides __initconst = {
.extra_priv_size = sizeof(struct xhci_plat_priv),
.reset = xhci_plat_setup, .reset = xhci_plat_setup,
.start = xhci_plat_start, .start = xhci_plat_start,
}; };
...@@ -48,11 +50,9 @@ static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci) ...@@ -48,11 +50,9 @@ static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci)
/* called during probe() after chip reset completes */ /* called during probe() after chip reset completes */
static int xhci_plat_setup(struct usb_hcd *hcd) static int xhci_plat_setup(struct usb_hcd *hcd)
{ {
struct device_node *of_node = hcd->self.controller->of_node;
int ret; int ret;
if (of_device_is_compatible(of_node, "renesas,xhci-r8a7790") || if (xhci_plat_type_is(hcd, XHCI_PLAT_TYPE_RENESAS_RCAR_GEN2)) {
of_device_is_compatible(of_node, "renesas,xhci-r8a7791")) {
ret = xhci_rcar_init_quirk(hcd); ret = xhci_rcar_init_quirk(hcd);
if (ret) if (ret)
return ret; return ret;
...@@ -63,19 +63,49 @@ static int xhci_plat_setup(struct usb_hcd *hcd) ...@@ -63,19 +63,49 @@ static int xhci_plat_setup(struct usb_hcd *hcd)
static int xhci_plat_start(struct usb_hcd *hcd) static int xhci_plat_start(struct usb_hcd *hcd)
{ {
struct device_node *of_node = hcd->self.controller->of_node; if (xhci_plat_type_is(hcd, XHCI_PLAT_TYPE_RENESAS_RCAR_GEN2))
if (of_device_is_compatible(of_node, "renesas,xhci-r8a7790") ||
of_device_is_compatible(of_node, "renesas,xhci-r8a7791"))
xhci_rcar_start(hcd); xhci_rcar_start(hcd);
return xhci_run(hcd); return xhci_run(hcd);
} }
#ifdef CONFIG_OF
static const struct xhci_plat_priv xhci_plat_marvell_armada = {
.type = XHCI_PLAT_TYPE_MARVELL_ARMADA,
};
static const struct xhci_plat_priv xhci_plat_renesas_rcar_gen2 = {
.type = XHCI_PLAT_TYPE_RENESAS_RCAR_GEN2,
};
static const struct of_device_id usb_xhci_of_match[] = {
{
.compatible = "generic-xhci",
}, {
.compatible = "xhci-platform",
}, {
.compatible = "marvell,armada-375-xhci",
.data = &xhci_plat_marvell_armada,
}, {
.compatible = "marvell,armada-380-xhci",
.data = &xhci_plat_marvell_armada,
}, {
.compatible = "renesas,xhci-r8a7790",
.data = &xhci_plat_renesas_rcar_gen2,
}, {
.compatible = "renesas,xhci-r8a7791",
.data = &xhci_plat_renesas_rcar_gen2,
}, {
},
};
MODULE_DEVICE_TABLE(of, usb_xhci_of_match);
#endif
static int xhci_plat_probe(struct platform_device *pdev) static int xhci_plat_probe(struct platform_device *pdev)
{ {
struct device_node *node = pdev->dev.of_node; struct device_node *node = pdev->dev.of_node;
struct usb_xhci_pdata *pdata = dev_get_platdata(&pdev->dev); struct usb_xhci_pdata *pdata = dev_get_platdata(&pdev->dev);
const struct of_device_id *match;
const struct hc_driver *driver; const struct hc_driver *driver;
struct xhci_hcd *xhci; struct xhci_hcd *xhci;
struct resource *res; struct resource *res;
...@@ -133,10 +163,17 @@ static int xhci_plat_probe(struct platform_device *pdev) ...@@ -133,10 +163,17 @@ static int xhci_plat_probe(struct platform_device *pdev)
goto put_hcd; goto put_hcd;
} }
if (of_device_is_compatible(pdev->dev.of_node, xhci = hcd_to_xhci(hcd);
"marvell,armada-375-xhci") || match = of_match_node(usb_xhci_of_match, node);
of_device_is_compatible(pdev->dev.of_node, if (match) {
"marvell,armada-380-xhci")) { const struct xhci_plat_priv *priv_match = match->data;
struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd);
/* Just copy data for now */
*priv = *priv_match;
}
if (xhci_plat_type_is(hcd, XHCI_PLAT_TYPE_MARVELL_ARMADA)) {
ret = xhci_mvebu_mbus_init_quirk(pdev); ret = xhci_mvebu_mbus_init_quirk(pdev);
if (ret) if (ret)
goto disable_clk; goto disable_clk;
...@@ -144,7 +181,6 @@ static int xhci_plat_probe(struct platform_device *pdev) ...@@ -144,7 +181,6 @@ static int xhci_plat_probe(struct platform_device *pdev)
device_wakeup_enable(hcd->self.controller); device_wakeup_enable(hcd->self.controller);
xhci = hcd_to_xhci(hcd);
xhci->clk = clk; xhci->clk = clk;
xhci->main_hcd = hcd; xhci->main_hcd = hcd;
xhci->shared_hcd = usb_create_shared_hcd(driver, &pdev->dev, xhci->shared_hcd = usb_create_shared_hcd(driver, &pdev->dev,
...@@ -255,19 +291,6 @@ static const struct dev_pm_ops xhci_plat_pm_ops = { ...@@ -255,19 +291,6 @@ static const struct dev_pm_ops xhci_plat_pm_ops = {
#define DEV_PM_OPS NULL #define DEV_PM_OPS NULL
#endif /* CONFIG_PM */ #endif /* CONFIG_PM */
#ifdef CONFIG_OF
static const struct of_device_id usb_xhci_of_match[] = {
{ .compatible = "generic-xhci" },
{ .compatible = "xhci-platform" },
{ .compatible = "marvell,armada-375-xhci"},
{ .compatible = "marvell,armada-380-xhci"},
{ .compatible = "renesas,xhci-r8a7790"},
{ .compatible = "renesas,xhci-r8a7791"},
{ },
};
MODULE_DEVICE_TABLE(of, usb_xhci_of_match);
#endif
static const struct acpi_device_id usb_xhci_acpi_match[] = { static const struct acpi_device_id usb_xhci_acpi_match[] = {
/* XHCI-compliant USB Controller */ /* XHCI-compliant USB Controller */
{ "PNP0D10", }, { "PNP0D10", },
......
/*
* xhci-plat.h - xHCI host controller driver platform Bus Glue.
*
* Copyright (C) 2015 Renesas Electronics Corporation
*
* 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.
*/
#ifndef _XHCI_PLAT_H
#define _XHCI_PLAT_H
#include "xhci.h" /* for hcd_to_xhci() */
enum xhci_plat_type {
XHCI_PLAT_TYPE_MARVELL_ARMADA,
XHCI_PLAT_TYPE_RENESAS_RCAR_GEN2,
};
struct xhci_plat_priv {
enum xhci_plat_type type;
};
#define hcd_to_xhci_priv(h) ((struct xhci_plat_priv *)hcd_to_xhci(h)->priv)
static inline bool xhci_plat_type_is(struct usb_hcd *hcd,
enum xhci_plat_type type)
{
struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd);
if (priv && priv->type == type)
return true;
else
return false;
}
#endif /* _XHCI_PLAT_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment