mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 22:40:53 +07:00
96e46dcfb8
With only 45 non-merge commits, we have a small merge window from the Gadget perspective. The biggest change here is the addition of the Cadence USB3 DRD Driver. All other changes are small, non-critical fixes or smaller new features like the improvement to BESL handling in dwc3. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com> -----BEGIN PGP SIGNATURE----- iQJRBAABCAA7FiEElLzh7wn96CXwjh2IzL64meEamQYFAl1o58UdHGZlbGlwZS5i YWxiaUBsaW51eC5pbnRlbC5jb20ACgkQzL64meEamQaKtxAAvvrwvleA7lZwInU2 FariXyI7+ihPAUDtlEHA+kHclpUw4hyWPc5rg0Mk7CH5gbtqodj9Uo4vbWtM5EaR EN6AJTn90KlygBXlw2pJAb6GBiJ2hMK8K5Gl5gdowRg4LExLYdLZCgCDueAv1p2o 2vg7LSJbHaeC0pv+L97W6/YH7q4fdacGjFm/49ROrChCwNNJygoXchO2+eAcXNlo uMzx2QxF3cHOMeSxSGnXC5VsZYAk6VftXgAiGvVZ5+6EgPIA5b07JovDhn0nAoDR 1aVQTqWDzdcd/tkJKEMBi16mOaeLDzsnGmsr+/2vzPzLJaWKPKwZ/FgGTyBXzDfM qEVrj2zWioH+6oOE3G5Ar3j1dgBqbgWhTfO47UWjgdQww5HeKZJqewJh19h5t/uS hxxSFgwNMVIo4B8DJc5J/vIbDsQbk1LsXkT2b3B/UaNYXQuKBdiv4jVpUgLJX+FF mN46SsfLVBpaYANcBPlgC8zGoOzWJFXgoh0qffxnQ6/Egvh55k0xVL/YPRgHiiw5 FbaGAlnJo9ue9vadzInde0X4SZnpBIQ5WR9fyHYm8fKDT1neB97F3yhZxhJ3apxN 0PM9P7auGtmjYYLAfIIL9687c3BNvDk8YvLehxXI4YqVHUZF3YNAz/DPrnCG2O5D W33pwIhL1swIZCFRtGWpokGiN+o= =KUJN -----END PGP SIGNATURE----- Merge tag 'usb-for-v5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-next Felipe writes: USB: Changes for v5.4 merge window With only 45 non-merge commits, we have a small merge window from the Gadget perspective. The biggest change here is the addition of the Cadence USB3 DRD Driver. All other changes are small, non-critical fixes or smaller new features like the improvement to BESL handling in dwc3. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com> * tag 'usb-for-v5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb: (45 commits) usb: gadget: net2280: Add workaround for AB chip Errata 11 usb: gadget: net2280: Move all "ll" registers in one structure usb: dwc3: gadget: Workaround Mirosoft's BESL check usb:cdns3 Fix for stuck packets in on-chip OUT buffer. usb: cdns3: Add Cadence USB3 DRD Driver usb: common: Simplify usb_decode_get_set_descriptor function. usb: common: Patch simplify usb_decode_set_clear_feature function. usb: common: Separated decoding functions from dwc3 driver. dt-bindings: add binding for USBSS-DRD controller. usb: gadget: composite: Set recommended BESL values usb: dwc3: gadget: Set BESL config parameter usb: dwc3: Separate field holding multiple properties usb: gadget: Export recommended BESL values usb: phy: phy-fsl-usb: Make structure fsl_otg_initdata constant usb: udc: lpc32xx: silence fall-through warning usb: dwc3: meson-g12a: fix suspend resume regulator unbalanced disables usb: udc: lpc32xx: remove set but not used 3 variables usb: gadget: udc: core: Fix segfault if udc_bind_to_driver() for pending driver fails usb: dwc3: st: Add of_dev_put() in probe function usb: dwc3: st: Add of_node_put() before return in probe function ...
193 lines
4.4 KiB
C
193 lines
4.4 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/**
|
|
* dwc3-keystone.c - Keystone Specific Glue layer
|
|
*
|
|
* Copyright (C) 2010-2013 Texas Instruments Incorporated - http://www.ti.com
|
|
*
|
|
* Author: WingMan Kwok <w-kwok2@ti.com>
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/dma-mapping.h>
|
|
#include <linux/io.h>
|
|
#include <linux/of_platform.h>
|
|
#include <linux/pm_runtime.h>
|
|
|
|
/* USBSS register offsets */
|
|
#define USBSS_REVISION 0x0000
|
|
#define USBSS_SYSCONFIG 0x0010
|
|
#define USBSS_IRQ_EOI 0x0018
|
|
#define USBSS_IRQSTATUS_RAW_0 0x0020
|
|
#define USBSS_IRQSTATUS_0 0x0024
|
|
#define USBSS_IRQENABLE_SET_0 0x0028
|
|
#define USBSS_IRQENABLE_CLR_0 0x002c
|
|
|
|
/* IRQ register bits */
|
|
#define USBSS_IRQ_EOI_LINE(n) BIT(n)
|
|
#define USBSS_IRQ_EVENT_ST BIT(0)
|
|
#define USBSS_IRQ_COREIRQ_EN BIT(0)
|
|
#define USBSS_IRQ_COREIRQ_CLR BIT(0)
|
|
|
|
struct dwc3_keystone {
|
|
struct device *dev;
|
|
void __iomem *usbss;
|
|
};
|
|
|
|
static inline u32 kdwc3_readl(void __iomem *base, u32 offset)
|
|
{
|
|
return readl(base + offset);
|
|
}
|
|
|
|
static inline void kdwc3_writel(void __iomem *base, u32 offset, u32 value)
|
|
{
|
|
writel(value, base + offset);
|
|
}
|
|
|
|
static void kdwc3_enable_irqs(struct dwc3_keystone *kdwc)
|
|
{
|
|
u32 val;
|
|
|
|
val = kdwc3_readl(kdwc->usbss, USBSS_IRQENABLE_SET_0);
|
|
val |= USBSS_IRQ_COREIRQ_EN;
|
|
kdwc3_writel(kdwc->usbss, USBSS_IRQENABLE_SET_0, val);
|
|
}
|
|
|
|
static void kdwc3_disable_irqs(struct dwc3_keystone *kdwc)
|
|
{
|
|
u32 val;
|
|
|
|
val = kdwc3_readl(kdwc->usbss, USBSS_IRQENABLE_SET_0);
|
|
val &= ~USBSS_IRQ_COREIRQ_EN;
|
|
kdwc3_writel(kdwc->usbss, USBSS_IRQENABLE_SET_0, val);
|
|
}
|
|
|
|
static irqreturn_t dwc3_keystone_interrupt(int irq, void *_kdwc)
|
|
{
|
|
struct dwc3_keystone *kdwc = _kdwc;
|
|
|
|
kdwc3_writel(kdwc->usbss, USBSS_IRQENABLE_CLR_0, USBSS_IRQ_COREIRQ_CLR);
|
|
kdwc3_writel(kdwc->usbss, USBSS_IRQSTATUS_0, USBSS_IRQ_EVENT_ST);
|
|
kdwc3_writel(kdwc->usbss, USBSS_IRQENABLE_SET_0, USBSS_IRQ_COREIRQ_EN);
|
|
kdwc3_writel(kdwc->usbss, USBSS_IRQ_EOI, USBSS_IRQ_EOI_LINE(0));
|
|
|
|
return IRQ_HANDLED;
|
|
}
|
|
|
|
static int kdwc3_probe(struct platform_device *pdev)
|
|
{
|
|
struct device *dev = &pdev->dev;
|
|
struct device_node *node = pdev->dev.of_node;
|
|
struct dwc3_keystone *kdwc;
|
|
int error, irq;
|
|
|
|
kdwc = devm_kzalloc(dev, sizeof(*kdwc), GFP_KERNEL);
|
|
if (!kdwc)
|
|
return -ENOMEM;
|
|
|
|
platform_set_drvdata(pdev, kdwc);
|
|
|
|
kdwc->dev = dev;
|
|
|
|
kdwc->usbss = devm_platform_ioremap_resource(pdev, 0);
|
|
if (IS_ERR(kdwc->usbss))
|
|
return PTR_ERR(kdwc->usbss);
|
|
|
|
pm_runtime_enable(kdwc->dev);
|
|
|
|
error = pm_runtime_get_sync(kdwc->dev);
|
|
if (error < 0) {
|
|
dev_err(kdwc->dev, "pm_runtime_get_sync failed, error %d\n",
|
|
error);
|
|
goto err_irq;
|
|
}
|
|
|
|
/* IRQ processing not required currently for AM65 */
|
|
if (of_device_is_compatible(node, "ti,am654-dwc3"))
|
|
goto skip_irq;
|
|
|
|
irq = platform_get_irq(pdev, 0);
|
|
if (irq < 0) {
|
|
error = irq;
|
|
goto err_irq;
|
|
}
|
|
|
|
error = devm_request_irq(dev, irq, dwc3_keystone_interrupt, IRQF_SHARED,
|
|
dev_name(dev), kdwc);
|
|
if (error) {
|
|
dev_err(dev, "failed to request IRQ #%d --> %d\n",
|
|
irq, error);
|
|
goto err_irq;
|
|
}
|
|
|
|
kdwc3_enable_irqs(kdwc);
|
|
|
|
skip_irq:
|
|
error = of_platform_populate(node, NULL, NULL, dev);
|
|
if (error) {
|
|
dev_err(&pdev->dev, "failed to create dwc3 core\n");
|
|
goto err_core;
|
|
}
|
|
|
|
return 0;
|
|
|
|
err_core:
|
|
kdwc3_disable_irqs(kdwc);
|
|
err_irq:
|
|
pm_runtime_put_sync(kdwc->dev);
|
|
pm_runtime_disable(kdwc->dev);
|
|
|
|
return error;
|
|
}
|
|
|
|
static int kdwc3_remove_core(struct device *dev, void *c)
|
|
{
|
|
struct platform_device *pdev = to_platform_device(dev);
|
|
|
|
platform_device_unregister(pdev);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int kdwc3_remove(struct platform_device *pdev)
|
|
{
|
|
struct dwc3_keystone *kdwc = platform_get_drvdata(pdev);
|
|
struct device_node *node = pdev->dev.of_node;
|
|
|
|
if (!of_device_is_compatible(node, "ti,am654-dwc3"))
|
|
kdwc3_disable_irqs(kdwc);
|
|
|
|
device_for_each_child(&pdev->dev, NULL, kdwc3_remove_core);
|
|
pm_runtime_put_sync(kdwc->dev);
|
|
pm_runtime_disable(kdwc->dev);
|
|
|
|
platform_set_drvdata(pdev, NULL);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct of_device_id kdwc3_of_match[] = {
|
|
{ .compatible = "ti,keystone-dwc3", },
|
|
{ .compatible = "ti,am654-dwc3" },
|
|
{},
|
|
};
|
|
MODULE_DEVICE_TABLE(of, kdwc3_of_match);
|
|
|
|
static struct platform_driver kdwc3_driver = {
|
|
.probe = kdwc3_probe,
|
|
.remove = kdwc3_remove,
|
|
.driver = {
|
|
.name = "keystone-dwc3",
|
|
.of_match_table = kdwc3_of_match,
|
|
},
|
|
};
|
|
|
|
module_platform_driver(kdwc3_driver);
|
|
|
|
MODULE_ALIAS("platform:keystone-dwc3");
|
|
MODULE_AUTHOR("WingMan Kwok <w-kwok2@ti.com>");
|
|
MODULE_LICENSE("GPL v2");
|
|
MODULE_DESCRIPTION("DesignWare USB3 KEYSTONE Glue Layer");
|