/** * dwc3-keystone.c - Keystone Specific Glue layer * * Copyright (C) 2010-2013 Texas Instruments Incorporated - http://www.ti.com * * Author: WingMan Kwok * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 of * the License 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. */ #include #include #include #include #include #include #include #include /* 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; struct clk *clk; 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; struct resource *res; int error, irq; kdwc = devm_kzalloc(dev, sizeof(*kdwc), GFP_KERNEL); if (!kdwc) return -ENOMEM; platform_set_drvdata(pdev, kdwc); kdwc->dev = dev; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); kdwc->usbss = devm_ioremap_resource(dev, res); if (IS_ERR(kdwc->usbss)) return PTR_ERR(kdwc->usbss); kdwc->clk = devm_clk_get(kdwc->dev, "usb"); error = clk_prepare_enable(kdwc->clk); if (error < 0) { dev_err(kdwc->dev, "unable to enable usb clock, error %d\n", error); return error; } irq = platform_get_irq(pdev, 0); if (irq < 0) { dev_err(&pdev->dev, "missing irq\n"); 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); 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: clk_disable_unprepare(kdwc->clk); 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); kdwc3_disable_irqs(kdwc); device_for_each_child(&pdev->dev, NULL, kdwc3_remove_core); clk_disable_unprepare(kdwc->clk); platform_set_drvdata(pdev, NULL); return 0; } static const struct of_device_id kdwc3_of_match[] = { { .compatible = "ti,keystone-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 "); MODULE_LICENSE("GPL v2"); MODULE_DESCRIPTION("DesignWare USB3 KEYSTONE Glue Layer"); /th>Marc Zyngier <marc.zyngier@arm.com>2017-01-17 16:00:48 +0000 committerThomas Gleixner <tglx@linutronix.de>2017-01-30 15:18:56 +0100 commit08d85f3ea99f1eeafc4e8507936190e86a16ee8c (patch) tree410bb1acd0cd7dcfaad37ae7b63ff243b7fa4bee /sound/soc/blackfin/bf5xx-sport.h parent566cf877a1fcb6d6dc0126b076aad062054c2637 (diff)
irqdomain: Avoid activating interrupts more than once
Since commit f3b0946d629c ("genirq/msi: Make sure PCI MSIs are activated early"), we can end-up activating a PCI/MSI twice (once at allocation time, and once at startup time). This is normally of no consequences, except that there is some HW out there that may misbehave if activate is used more than once (the GICv3 ITS, for example, uses the activate callback to issue the MAPVI command, and the architecture spec says that "If there is an existing mapping for the EventID-DeviceID combination, behavior is UNPREDICTABLE"). While this could be worked around in each individual driver, it may make more sense to tackle the issue at the core level. In order to avoid getting in that situation, let's have a per-interrupt flag to remember if we have already activated that interrupt or not. Fixes: f3b0946d629c ("genirq/msi: Make sure PCI MSIs are activated early") Reported-and-tested-by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Cc: stable@vger.kernel.org Link: http://lkml.kernel.org/r/1484668848-24361-1-git-send-email-marc.zyngier@arm.com Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'sound/soc/blackfin/bf5xx-sport.h')