* [PATCH v3 1/5] usb: atmel_usba_udc: Rework at91sam9rl errata handling
2015-01-12 10:57 [PATCH v3 0/5] usb: atmel_usba_udc: Rework errata handling Boris Brezillon
@ 2015-01-12 10:57 ` Boris Brezillon
2015-01-12 12:15 ` Paul Bolle
2015-01-12 10:57 ` [PATCH v3 2/5] usb: atmel_usba_udc: Add at91sam9g45 and at91sam9x5 " Boris Brezillon
` (6 subsequent siblings)
7 siblings, 1 reply; 15+ messages in thread
From: Boris Brezillon @ 2015-01-12 10:57 UTC (permalink / raw)
To: linux-arm-kernel
at91sam9rl SoC has an erratum forcing us to toggle the BIAS on USB
suspend/resume events.
This specific handling is only activated when CONFIG_ARCH_AT91SAM9RL is
set and this option is only set when building a non-DT kernel, which is
problematic since non-DT support for at91sam9rl SoC has been removed.
Rework the toggle_bias implementation to attach it to the "at91sam9rl-udc"
compatible string.
Add new compatible strings to avoid executing at91sam9rl erratum handling
on other SoCs.
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
.../devicetree/bindings/usb/atmel-usb.txt | 5 +-
drivers/usb/gadget/udc/atmel_usba_udc.c | 78 ++++++++++++----------
drivers/usb/gadget/udc/atmel_usba_udc.h | 5 ++
3 files changed, 52 insertions(+), 36 deletions(-)
diff --git a/Documentation/devicetree/bindings/usb/atmel-usb.txt b/Documentation/devicetree/bindings/usb/atmel-usb.txt
index bc2222c..38fee0f 100644
--- a/Documentation/devicetree/bindings/usb/atmel-usb.txt
+++ b/Documentation/devicetree/bindings/usb/atmel-usb.txt
@@ -51,7 +51,10 @@ usb1: gadget at fffa4000 {
Atmel High-Speed USB device controller
Required properties:
- - compatible: Should be "atmel,at91sam9rl-udc"
+ - compatible: Should be one of the following
+ "at91sam9rl-udc"
+ "at91sam9g45-udc"
+ "sama5d3-udc"
- reg: Address and length of the register set for the device
- interrupts: Should contain usba interrupt
- ep childnode: To specify the number of endpoints and their properties.
diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
index ce88237..36fd34b 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -8,6 +8,7 @@
* published by the Free Software Foundation.
*/
#include <linux/clk.h>
+#include <linux/clk/at91_pmc.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/interrupt.h>
@@ -324,28 +325,12 @@ static int vbus_is_present(struct usba_udc *udc)
return 1;
}
-#if defined(CONFIG_ARCH_AT91SAM9RL)
-
-#include <linux/clk/at91_pmc.h>
-
-static void toggle_bias(int is_on)
-{
- unsigned int uckr = at91_pmc_read(AT91_CKGR_UCKR);
-
- if (is_on)
- at91_pmc_write(AT91_CKGR_UCKR, uckr | AT91_PMC_BIASEN);
- else
- at91_pmc_write(AT91_CKGR_UCKR, uckr & ~(AT91_PMC_BIASEN));
-}
-
-#else
-
-static void toggle_bias(int is_on)
+static void toggle_bias(struct usba_udc *udc, int is_on)
{
+ if (udc->errata && udc->errata->toggle_bias)
+ udc->errata->toggle_bias(udc, is_on);
}
-#endif /* CONFIG_ARCH_AT91SAM9RL */
-
static void next_fifo_transaction(struct usba_ep *ep, struct usba_request *req)
{
unsigned int transaction_len;
@@ -1620,7 +1605,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
DBG(DBG_INT, "irq, status=%#08x\n", status);
if (status & USBA_DET_SUSPEND) {
- toggle_bias(0);
+ toggle_bias(udc, 0);
usba_writel(udc, INT_CLR, USBA_DET_SUSPEND);
DBG(DBG_BUS, "Suspend detected\n");
if (udc->gadget.speed != USB_SPEED_UNKNOWN
@@ -1632,7 +1617,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
}
if (status & USBA_WAKE_UP) {
- toggle_bias(1);
+ toggle_bias(udc, 1);
usba_writel(udc, INT_CLR, USBA_WAKE_UP);
DBG(DBG_BUS, "Wake Up CPU detected\n");
}
@@ -1736,13 +1721,13 @@ static irqreturn_t usba_vbus_irq(int irq, void *devid)
vbus = vbus_is_present(udc);
if (vbus != udc->vbus_prev) {
if (vbus) {
- toggle_bias(1);
+ toggle_bias(udc, 1);
usba_writel(udc, CTRL, USBA_ENABLE_MASK);
usba_writel(udc, INT_ENB, USBA_END_OF_RESET);
} else {
udc->gadget.speed = USB_SPEED_UNKNOWN;
reset_all_endpoints(udc);
- toggle_bias(0);
+ toggle_bias(udc, 0);
usba_writel(udc, CTRL, USBA_DISABLE_MASK);
if (udc->driver->disconnect) {
spin_unlock(&udc->lock);
@@ -1788,7 +1773,7 @@ static int atmel_usba_start(struct usb_gadget *gadget,
/* If Vbus is present, enable the controller and wait for reset */
spin_lock_irqsave(&udc->lock, flags);
if (vbus_is_present(udc) && udc->vbus_prev == 0) {
- toggle_bias(1);
+ toggle_bias(udc, 1);
usba_writel(udc, CTRL, USBA_ENABLE_MASK);
usba_writel(udc, INT_ENB, USBA_END_OF_RESET);
}
@@ -1811,7 +1796,7 @@ static int atmel_usba_stop(struct usb_gadget *gadget)
spin_unlock_irqrestore(&udc->lock, flags);
/* This will also disable the DP pullup */
- toggle_bias(0);
+ toggle_bias(udc, 0);
usba_writel(udc, CTRL, USBA_DISABLE_MASK);
clk_disable_unprepare(udc->hclk);
@@ -1823,6 +1808,29 @@ static int atmel_usba_stop(struct usb_gadget *gadget)
}
#ifdef CONFIG_OF
+static void at91sam9rl_toggle_bias(struct usba_udc *udc, int is_on)
+{
+ unsigned int uckr = at91_pmc_read(AT91_CKGR_UCKR);
+
+ if (is_on)
+ at91_pmc_write(AT91_CKGR_UCKR, uckr | AT91_PMC_BIASEN);
+ else
+ at91_pmc_write(AT91_CKGR_UCKR, uckr & ~(AT91_PMC_BIASEN));
+}
+
+static const struct usba_udc_errata at91sam9rl_errata = {
+ .toggle_bias = at91sam9rl_toggle_bias,
+};
+
+static const struct of_device_id atmel_udc_dt_ids[] = {
+ { .compatible = "atmel,at91sam9rl-udc", .data = &at91sam9rl_errata },
+ { .compatible = "atmel,at91sam9g45-udc" },
+ { .compatible = "atmel,sama5d3-udc" },
+ { /* sentinel */ }
+};
+
+MODULE_DEVICE_TABLE(of, atmel_udc_dt_ids);
+
static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev,
struct usba_udc *udc)
{
@@ -1830,10 +1838,17 @@ static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev,
const char *name;
enum of_gpio_flags flags;
struct device_node *np = pdev->dev.of_node;
+ const struct of_device_id *match;
struct device_node *pp;
int i, ret;
struct usba_ep *eps, *ep;
+ match = of_match_node(atmel_udc_dt_ids, np);
+ if (!match)
+ return ERR_PTR(-EINVAL);
+
+ udc->errata = match->data;
+
udc->num_ep = 0;
udc->vbus_pin = of_get_named_gpio_flags(np, "atmel,vbus-gpio", 0,
@@ -2024,7 +2039,7 @@ static int usba_udc_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "Unable to enable pclk, aborting.\n");
return ret;
}
- toggle_bias(0);
+
usba_writel(udc, CTRL, USBA_DISABLE_MASK);
clk_disable_unprepare(pclk);
@@ -2033,6 +2048,8 @@ static int usba_udc_probe(struct platform_device *pdev)
else
udc->usba_ep = usba_udc_pdata(pdev, udc);
+ toggle_bias(udc, 0);
+
if (IS_ERR(udc->usba_ep))
return PTR_ERR(udc->usba_ep);
@@ -2092,15 +2109,6 @@ static int __exit usba_udc_remove(struct platform_device *pdev)
return 0;
}
-#if defined(CONFIG_OF)
-static const struct of_device_id atmel_udc_dt_ids[] = {
- { .compatible = "atmel,at91sam9rl-udc" },
- { /* sentinel */ }
-};
-
-MODULE_DEVICE_TABLE(of, atmel_udc_dt_ids);
-#endif
-
static struct platform_driver udc_driver = {
.remove = __exit_p(usba_udc_remove),
.driver = {
diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.h b/drivers/usb/gadget/udc/atmel_usba_udc.h
index a70706e..456899e 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.h
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.h
@@ -304,6 +304,10 @@ struct usba_request {
unsigned int mapped:1;
};
+struct usba_udc_errata {
+ void (*toggle_bias)(struct usba_udc *udc, int is_on);
+};
+
struct usba_udc {
/* Protect hw registers from concurrent modifications */
spinlock_t lock;
@@ -314,6 +318,7 @@ struct usba_udc {
struct usb_gadget gadget;
struct usb_gadget_driver *driver;
struct platform_device *pdev;
+ const struct usba_udc_errata *errata;
int irq;
int vbus_pin;
int vbus_pin_inverted;
--
1.9.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v3 1/5] usb: atmel_usba_udc: Rework at91sam9rl errata handling
2015-01-12 10:57 ` [PATCH v3 1/5] usb: atmel_usba_udc: Rework at91sam9rl " Boris Brezillon
@ 2015-01-12 12:15 ` Paul Bolle
2015-01-12 12:54 ` Boris Brezillon
0 siblings, 1 reply; 15+ messages in thread
From: Paul Bolle @ 2015-01-12 12:15 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, 2015-01-12 at 11:57 +0100, Boris Brezillon wrote:
> at91sam9rl SoC has an erratum forcing us to toggle the BIAS on USB
> suspend/resume events.
>
> This specific handling is only activated when CONFIG_ARCH_AT91SAM9RL is
> set and this option is only set when building a non-DT kernel, which is
> problematic since non-DT support for at91sam9rl SoC has been removed.
This sentence is not entirely correct. Commit bcf8c7e7703b ("ARM: at91:
remove at91sam9rl legacy board support") actually removed the Kconfig
symbol ARCH_AT91SAM9RL entirely. So the check for CONFIG_ARCH_AT91SAM9RL
has been pointless since (next-20141110 and) v3.19-rc1. See my report at
https://lkml.org/lkml/2014/11/10/232 .
(I stumbled on this patch because I contemplated sending a patch to
simply remove the check for CONFIG_ARCH_AT91SAM9RL and the currently
useless function toggle_bias.)
> Rework the toggle_bias implementation to attach it to the "at91sam9rl-udc"
> compatible string.
>
> Add new compatible strings to avoid executing at91sam9rl erratum handling
> on other SoCs.
>
> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Paul Bolle
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v3 1/5] usb: atmel_usba_udc: Rework at91sam9rl errata handling
2015-01-12 12:15 ` Paul Bolle
@ 2015-01-12 12:54 ` Boris Brezillon
0 siblings, 0 replies; 15+ messages in thread
From: Boris Brezillon @ 2015-01-12 12:54 UTC (permalink / raw)
To: linux-arm-kernel
Hi Paul,
On Mon, 12 Jan 2015 13:15:58 +0100
Paul Bolle <pebolle@tiscali.nl> wrote:
> On Mon, 2015-01-12 at 11:57 +0100, Boris Brezillon wrote:
> > at91sam9rl SoC has an erratum forcing us to toggle the BIAS on USB
> > suspend/resume events.
> >
> > This specific handling is only activated when CONFIG_ARCH_AT91SAM9RL is
> > set and this option is only set when building a non-DT kernel, which is
> > problematic since non-DT support for at91sam9rl SoC has been removed.
>
> This sentence is not entirely correct. Commit bcf8c7e7703b ("ARM: at91:
> remove at91sam9rl legacy board support") actually removed the Kconfig
> symbol ARCH_AT91SAM9RL entirely. So the check for CONFIG_ARCH_AT91SAM9RL
> has been pointless since (next-20141110 and) v3.19-rc1. See my report at
> https://lkml.org/lkml/2014/11/10/232 .
I'll rework my commit message.
>
> (I stumbled on this patch because I contemplated sending a patch to
> simply remove the check for CONFIG_ARCH_AT91SAM9RL and the currently
> useless function toggle_bias.)
Sorry, I forgot to add you in Cc of this series :-(, I'll do it it for
the future iterations.
Best Regards,
Boris
--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v3 2/5] usb: atmel_usba_udc: Add at91sam9g45 and at91sam9x5 errata handling
2015-01-12 10:57 [PATCH v3 0/5] usb: atmel_usba_udc: Rework errata handling Boris Brezillon
2015-01-12 10:57 ` [PATCH v3 1/5] usb: atmel_usba_udc: Rework at91sam9rl " Boris Brezillon
@ 2015-01-12 10:57 ` Boris Brezillon
2015-01-12 10:57 ` [PATCH v3 3/5] ARM: at91/dt: update udc compatible strings Boris Brezillon
` (5 subsequent siblings)
7 siblings, 0 replies; 15+ messages in thread
From: Boris Brezillon @ 2015-01-12 10:57 UTC (permalink / raw)
To: linux-arm-kernel
at91sam9g45 and at91sam9x5 SoCs have an hardware bug forcing us to
generate a pulse on the BIAS signal on "USB end of reset" and
"USB end of resume" events.
Reported-by: Patrice VILCHEZ <patrice.vilchez@atmel.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
drivers/usb/gadget/udc/atmel_usba_udc.c | 28 +++++++++++++++++++++++++++-
drivers/usb/gadget/udc/atmel_usba_udc.h | 2 ++
2 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
index 36fd34b..55c8dde 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -331,6 +331,17 @@ static void toggle_bias(struct usba_udc *udc, int is_on)
udc->errata->toggle_bias(udc, is_on);
}
+static void generate_bias_pulse(struct usba_udc *udc)
+{
+ if (!udc->bias_pulse_needed)
+ return;
+
+ if (udc->errata && udc->errata->pulse_bias)
+ udc->errata->pulse_bias(udc);
+
+ udc->bias_pulse_needed = false;
+}
+
static void next_fifo_transaction(struct usba_ep *ep, struct usba_request *req)
{
unsigned int transaction_len;
@@ -1607,6 +1618,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
if (status & USBA_DET_SUSPEND) {
toggle_bias(udc, 0);
usba_writel(udc, INT_CLR, USBA_DET_SUSPEND);
+ udc->bias_pulse_needed = true;
DBG(DBG_BUS, "Suspend detected\n");
if (udc->gadget.speed != USB_SPEED_UNKNOWN
&& udc->driver && udc->driver->suspend) {
@@ -1624,6 +1636,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
if (status & USBA_END_OF_RESUME) {
usba_writel(udc, INT_CLR, USBA_END_OF_RESUME);
+ generate_bias_pulse(udc);
DBG(DBG_BUS, "Resume detected\n");
if (udc->gadget.speed != USB_SPEED_UNKNOWN
&& udc->driver && udc->driver->resume) {
@@ -1659,6 +1672,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
struct usba_ep *ep0;
usba_writel(udc, INT_CLR, USBA_END_OF_RESET);
+ generate_bias_pulse(udc);
reset_all_endpoints(udc);
if (udc->gadget.speed != USB_SPEED_UNKNOWN && udc->driver) {
@@ -1818,13 +1832,25 @@ static void at91sam9rl_toggle_bias(struct usba_udc *udc, int is_on)
at91_pmc_write(AT91_CKGR_UCKR, uckr & ~(AT91_PMC_BIASEN));
}
+static void at91sam9g45_pulse_bias(struct usba_udc *udc)
+{
+ unsigned int uckr = at91_pmc_read(AT91_CKGR_UCKR);
+
+ at91_pmc_write(AT91_CKGR_UCKR, uckr & ~(AT91_PMC_BIASEN));
+ at91_pmc_write(AT91_CKGR_UCKR, uckr | AT91_PMC_BIASEN);
+}
+
static const struct usba_udc_errata at91sam9rl_errata = {
.toggle_bias = at91sam9rl_toggle_bias,
};
+static const struct usba_udc_errata at91sam9g45_errata = {
+ .pulse_bias = at91sam9g45_pulse_bias,
+};
+
static const struct of_device_id atmel_udc_dt_ids[] = {
{ .compatible = "atmel,at91sam9rl-udc", .data = &at91sam9rl_errata },
- { .compatible = "atmel,at91sam9g45-udc" },
+ { .compatible = "atmel,at91sam9g45-udc", .data = &at91sam9g45_errata },
{ .compatible = "atmel,sama5d3-udc" },
{ /* sentinel */ }
};
diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.h b/drivers/usb/gadget/udc/atmel_usba_udc.h
index 456899e..72b3537 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.h
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.h
@@ -306,6 +306,7 @@ struct usba_request {
struct usba_udc_errata {
void (*toggle_bias)(struct usba_udc *udc, int is_on);
+ void (*pulse_bias)(struct usba_udc *udc);
};
struct usba_udc {
@@ -326,6 +327,7 @@ struct usba_udc {
struct clk *pclk;
struct clk *hclk;
struct usba_ep *usba_ep;
+ bool bias_pulse_needed;
u16 devstatus;
--
1.9.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v3 3/5] ARM: at91/dt: update udc compatible strings
2015-01-12 10:57 [PATCH v3 0/5] usb: atmel_usba_udc: Rework errata handling Boris Brezillon
2015-01-12 10:57 ` [PATCH v3 1/5] usb: atmel_usba_udc: Rework at91sam9rl " Boris Brezillon
2015-01-12 10:57 ` [PATCH v3 2/5] usb: atmel_usba_udc: Add at91sam9g45 and at91sam9x5 " Boris Brezillon
@ 2015-01-12 10:57 ` Boris Brezillon
2015-01-12 18:23 ` Felipe Balbi
2015-01-12 10:57 ` [PATCH v3 4/5] usb: atmel_usba_udc: Mask status with enabled irqs Boris Brezillon
` (4 subsequent siblings)
7 siblings, 1 reply; 15+ messages in thread
From: Boris Brezillon @ 2015-01-12 10:57 UTC (permalink / raw)
To: linux-arm-kernel
at91sam9g45, at91sam9x5 and sama5 SoCs should not use
"atmel,at91sam9rl-udc" for their USB device compatible property since
this compatible is attached to a specific hardware bug fix.
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
arch/arm/boot/dts/at91sam9g45.dtsi | 2 +-
arch/arm/boot/dts/at91sam9x5.dtsi | 2 +-
arch/arm/boot/dts/sama5d3.dtsi | 2 +-
arch/arm/boot/dts/sama5d4.dtsi | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi b/arch/arm/boot/dts/at91sam9g45.dtsi
index 2a8da8a..acd90eb 100644
--- a/arch/arm/boot/dts/at91sam9g45.dtsi
+++ b/arch/arm/boot/dts/at91sam9g45.dtsi
@@ -1144,7 +1144,7 @@
usb2: gadget at fff78000 {
#address-cells = <1>;
#size-cells = <0>;
- compatible = "atmel,at91sam9rl-udc";
+ compatible = "atmel,at91sam9g45-udc";
reg = <0x00600000 0x80000
0xfff78000 0x400>;
interrupts = <27 IRQ_TYPE_LEVEL_HIGH 0>;
diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi
index bbb3ba6..d213147 100644
--- a/arch/arm/boot/dts/at91sam9x5.dtsi
+++ b/arch/arm/boot/dts/at91sam9x5.dtsi
@@ -1057,7 +1057,7 @@
usb2: gadget at f803c000 {
#address-cells = <1>;
#size-cells = <0>;
- compatible = "atmel,at91sam9rl-udc";
+ compatible = "atmel,at91sam9g45-udc";
reg = <0x00500000 0x80000
0xf803c000 0x400>;
interrupts = <23 IRQ_TYPE_LEVEL_HIGH 0>;
diff --git a/arch/arm/boot/dts/sama5d3.dtsi b/arch/arm/boot/dts/sama5d3.dtsi
index 5f4144d..2b407a4 100644
--- a/arch/arm/boot/dts/sama5d3.dtsi
+++ b/arch/arm/boot/dts/sama5d3.dtsi
@@ -1264,7 +1264,7 @@
usb0: gadget at 00500000 {
#address-cells = <1>;
#size-cells = <0>;
- compatible = "atmel,at91sam9rl-udc";
+ compatible = "atmel,sama5d3-udc";
reg = <0x00500000 0x100000
0xf8030000 0x4000>;
interrupts = <33 IRQ_TYPE_LEVEL_HIGH 2>;
diff --git a/arch/arm/boot/dts/sama5d4.dtsi b/arch/arm/boot/dts/sama5d4.dtsi
index 1b0f30c..52dce24 100644
--- a/arch/arm/boot/dts/sama5d4.dtsi
+++ b/arch/arm/boot/dts/sama5d4.dtsi
@@ -112,7 +112,7 @@
usb0: gadget at 00400000 {
#address-cells = <1>;
#size-cells = <0>;
- compatible = "atmel,at91sam9rl-udc";
+ compatible = "atmel,sama5d3-udc";
reg = <0x00400000 0x100000
0xfc02c000 0x4000>;
interrupts = <47 IRQ_TYPE_LEVEL_HIGH 2>;
--
1.9.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v3 3/5] ARM: at91/dt: update udc compatible strings
2015-01-12 10:57 ` [PATCH v3 3/5] ARM: at91/dt: update udc compatible strings Boris Brezillon
@ 2015-01-12 18:23 ` Felipe Balbi
2015-01-12 19:18 ` Boris Brezillon
0 siblings, 1 reply; 15+ messages in thread
From: Felipe Balbi @ 2015-01-12 18:23 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Jan 12, 2015 at 11:57:56AM +0100, Boris Brezillon wrote:
> at91sam9g45, at91sam9x5 and sama5 SoCs should not use
> "atmel,at91sam9rl-udc" for their USB device compatible property since
> this compatible is attached to a specific hardware bug fix.
>
> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
WARNING: DT compatible string "atmel,at91sam9g45-udc" appears un-documented -- check ./Documentation/devicetree/bindings/
#177: FILE: drivers/usb/gadget/udc/atmel_usba_udc.c:1827:
+ { .compatible = "atmel,at91sam9g45-udc" },
WARNING: DT compatible string "atmel,sama5d3-udc" appears un-documented -- check ./Documentation/devicetree/bindings/
#178: FILE: drivers/usb/gadget/udc/atmel_usba_udc.c:1828:
+ { .compatible = "atmel,sama5d3-udc" },
please fix and resend. Also, when resending, could you add Nicolas'
Acked-by since he's already given it ?
Thanks
--
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150112/b2cccec7/attachment-0001.sig>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v3 3/5] ARM: at91/dt: update udc compatible strings
2015-01-12 18:23 ` Felipe Balbi
@ 2015-01-12 19:18 ` Boris Brezillon
2015-01-12 19:31 ` Felipe Balbi
0 siblings, 1 reply; 15+ messages in thread
From: Boris Brezillon @ 2015-01-12 19:18 UTC (permalink / raw)
To: linux-arm-kernel
Hi Felipe,
On Mon, 12 Jan 2015 12:23:49 -0600
Felipe Balbi <balbi@ti.com> wrote:
> On Mon, Jan 12, 2015 at 11:57:56AM +0100, Boris Brezillon wrote:
> > at91sam9g45, at91sam9x5 and sama5 SoCs should not use
> > "atmel,at91sam9rl-udc" for their USB device compatible property since
> > this compatible is attached to a specific hardware bug fix.
> >
> > Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> > Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
>
> WARNING: DT compatible string "atmel,at91sam9g45-udc" appears un-documented -- check ./Documentation/devicetree/bindings/
> #177: FILE: drivers/usb/gadget/udc/atmel_usba_udc.c:1827:
> + { .compatible = "atmel,at91sam9g45-udc" },
>
> WARNING: DT compatible string "atmel,sama5d3-udc" appears un-documented -- check ./Documentation/devicetree/bindings/
> #178: FILE: drivers/usb/gadget/udc/atmel_usba_udc.c:1828:
> + { .compatible = "atmel,sama5d3-udc" },
>
> please fix and resend. Also, when resending, could you add Nicolas'
> Acked-by since he's already given it ?
Actually these compatible strings are documented in the first patch
(where they were introduced), but I'll send a v4 with Nicolas' ack.
Thanks,
Boris
--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v3 3/5] ARM: at91/dt: update udc compatible strings
2015-01-12 19:18 ` Boris Brezillon
@ 2015-01-12 19:31 ` Felipe Balbi
2015-01-12 19:42 ` Boris Brezillon
0 siblings, 1 reply; 15+ messages in thread
From: Felipe Balbi @ 2015-01-12 19:31 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Jan 12, 2015 at 08:18:16PM +0100, Boris Brezillon wrote:
> Hi Felipe,
>
> On Mon, 12 Jan 2015 12:23:49 -0600
> Felipe Balbi <balbi@ti.com> wrote:
>
> > On Mon, Jan 12, 2015 at 11:57:56AM +0100, Boris Brezillon wrote:
> > > at91sam9g45, at91sam9x5 and sama5 SoCs should not use
> > > "atmel,at91sam9rl-udc" for their USB device compatible property since
> > > this compatible is attached to a specific hardware bug fix.
> > >
> > > Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> > > Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> >
> > WARNING: DT compatible string "atmel,at91sam9g45-udc" appears un-documented -- check ./Documentation/devicetree/bindings/
> > #177: FILE: drivers/usb/gadget/udc/atmel_usba_udc.c:1827:
> > + { .compatible = "atmel,at91sam9g45-udc" },
> >
> > WARNING: DT compatible string "atmel,sama5d3-udc" appears un-documented -- check ./Documentation/devicetree/bindings/
> > #178: FILE: drivers/usb/gadget/udc/atmel_usba_udc.c:1828:
> > + { .compatible = "atmel,sama5d3-udc" },
> >
> > please fix and resend. Also, when resending, could you add Nicolas'
> > Acked-by since he's already given it ?
>
> Actually these compatible strings are documented in the first patch
> (where they were introduced), but I'll send a v4 with Nicolas' ack.
heh, checkpatch stupidity :-) My bad.
--
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150112/36f2cc6c/attachment.sig>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v3 3/5] ARM: at91/dt: update udc compatible strings
2015-01-12 19:31 ` Felipe Balbi
@ 2015-01-12 19:42 ` Boris Brezillon
0 siblings, 0 replies; 15+ messages in thread
From: Boris Brezillon @ 2015-01-12 19:42 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, 12 Jan 2015 13:31:26 -0600
Felipe Balbi <balbi@ti.com> wrote:
> On Mon, Jan 12, 2015 at 08:18:16PM +0100, Boris Brezillon wrote:
> > Hi Felipe,
> >
> > On Mon, 12 Jan 2015 12:23:49 -0600
> > Felipe Balbi <balbi@ti.com> wrote:
> >
> > > On Mon, Jan 12, 2015 at 11:57:56AM +0100, Boris Brezillon wrote:
> > > > at91sam9g45, at91sam9x5 and sama5 SoCs should not use
> > > > "atmel,at91sam9rl-udc" for their USB device compatible property since
> > > > this compatible is attached to a specific hardware bug fix.
> > > >
> > > > Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> > > > Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> > >
> > > WARNING: DT compatible string "atmel,at91sam9g45-udc" appears un-documented -- check ./Documentation/devicetree/bindings/
> > > #177: FILE: drivers/usb/gadget/udc/atmel_usba_udc.c:1827:
> > > + { .compatible = "atmel,at91sam9g45-udc" },
> > >
> > > WARNING: DT compatible string "atmel,sama5d3-udc" appears un-documented -- check ./Documentation/devicetree/bindings/
> > > #178: FILE: drivers/usb/gadget/udc/atmel_usba_udc.c:1828:
> > > + { .compatible = "atmel,sama5d3-udc" },
> > >
> > > please fix and resend. Also, when resending, could you add Nicolas'
> > > Acked-by since he's already given it ?
> >
> > Actually these compatible strings are documented in the first patch
> > (where they were introduced), but I'll send a v4 with Nicolas' ack.
>
> heh, checkpatch stupidity :-) My bad.
>
You took v3 of the first patch instead of v4.
Don't know if you can replace it (anyway, that's not such a big deal
since the only change is the commit message)...
--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v3 4/5] usb: atmel_usba_udc: Mask status with enabled irqs
2015-01-12 10:57 [PATCH v3 0/5] usb: atmel_usba_udc: Rework errata handling Boris Brezillon
` (2 preceding siblings ...)
2015-01-12 10:57 ` [PATCH v3 3/5] ARM: at91/dt: update udc compatible strings Boris Brezillon
@ 2015-01-12 10:57 ` Boris Brezillon
2015-01-12 10:57 ` [PATCH v3 5/5] usb: gadget: atmel_usba: Cache INT_ENB register value Boris Brezillon
` (3 subsequent siblings)
7 siblings, 0 replies; 15+ messages in thread
From: Boris Brezillon @ 2015-01-12 10:57 UTC (permalink / raw)
To: linux-arm-kernel
Avoid interpreting useless status flags when we're not waiting for such
events by masking the status variable with the interrupt enabled register
value.
Reported-by: Patrice VILCHEZ <patrice.vilchez@atmel.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
drivers/usb/gadget/udc/atmel_usba_udc.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
index 55c8dde..bc3a532 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -1612,12 +1612,14 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
spin_lock(&udc->lock);
- status = usba_readl(udc, INT_STA);
+ status = usba_readl(udc, INT_STA) & usba_readl(udc, INT_ENB);
DBG(DBG_INT, "irq, status=%#08x\n", status);
if (status & USBA_DET_SUSPEND) {
toggle_bias(udc, 0);
usba_writel(udc, INT_CLR, USBA_DET_SUSPEND);
+ usba_writel(udc, INT_ENB,
+ usba_readl(udc, INT_ENB) | USBA_WAKE_UP);
udc->bias_pulse_needed = true;
DBG(DBG_BUS, "Suspend detected\n");
if (udc->gadget.speed != USB_SPEED_UNKNOWN
@@ -1631,6 +1633,8 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
if (status & USBA_WAKE_UP) {
toggle_bias(udc, 1);
usba_writel(udc, INT_CLR, USBA_WAKE_UP);
+ usba_writel(udc, INT_ENB,
+ usba_readl(udc, INT_ENB) & ~USBA_WAKE_UP);
DBG(DBG_BUS, "Wake Up CPU detected\n");
}
--
1.9.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v3 5/5] usb: gadget: atmel_usba: Cache INT_ENB register value
2015-01-12 10:57 [PATCH v3 0/5] usb: atmel_usba_udc: Rework errata handling Boris Brezillon
` (3 preceding siblings ...)
2015-01-12 10:57 ` [PATCH v3 4/5] usb: atmel_usba_udc: Mask status with enabled irqs Boris Brezillon
@ 2015-01-12 10:57 ` Boris Brezillon
2015-01-12 11:08 ` [PATCH v3 0/5] usb: atmel_usba_udc: Rework errata handling Nicolas Ferre
` (2 subsequent siblings)
7 siblings, 0 replies; 15+ messages in thread
From: Boris Brezillon @ 2015-01-12 10:57 UTC (permalink / raw)
To: linux-arm-kernel
Cache INT_ENB register value in order to avoid uncached iomem access, and
thus improve access time to INT_ENB value.
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
drivers/usb/gadget/udc/atmel_usba_udc.c | 52 ++++++++++++++++++---------------
drivers/usb/gadget/udc/atmel_usba_udc.h | 2 ++
2 files changed, 30 insertions(+), 24 deletions(-)
diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
index bc3a532..6dfe17b 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -316,6 +316,17 @@ static inline void usba_cleanup_debugfs(struct usba_udc *udc)
}
#endif
+static inline u32 usba_int_enb_get(struct usba_udc *udc)
+{
+ return udc->int_enb_cache;
+}
+
+static inline void usba_int_enb_set(struct usba_udc *udc, u32 val)
+{
+ usba_writel(udc, INT_ENB, val);
+ udc->int_enb_cache = val;
+}
+
static int vbus_is_present(struct usba_udc *udc)
{
if (gpio_is_valid(udc->vbus_pin))
@@ -597,16 +608,14 @@ usba_ep_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
if (ep->can_dma) {
u32 ctrl;
- usba_writel(udc, INT_ENB,
- (usba_readl(udc, INT_ENB)
- | USBA_BF(EPT_INT, 1 << ep->index)
- | USBA_BF(DMA_INT, 1 << ep->index)));
+ usba_int_enb_set(udc, usba_int_enb_get(udc) |
+ USBA_BF(EPT_INT, 1 << ep->index) |
+ USBA_BF(DMA_INT, 1 << ep->index));
ctrl = USBA_AUTO_VALID | USBA_INTDIS_DMA;
usba_ep_writel(ep, CTL_ENB, ctrl);
} else {
- usba_writel(udc, INT_ENB,
- (usba_readl(udc, INT_ENB)
- | USBA_BF(EPT_INT, 1 << ep->index)));
+ usba_int_enb_set(udc, usba_int_enb_get(udc) |
+ USBA_BF(EPT_INT, 1 << ep->index));
}
spin_unlock_irqrestore(&udc->lock, flags);
@@ -614,7 +623,7 @@ usba_ep_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
DBG(DBG_HW, "EPT_CFG%d after init: %#08lx\n", ep->index,
(unsigned long)usba_ep_readl(ep, CFG));
DBG(DBG_HW, "INT_ENB after init: %#08lx\n",
- (unsigned long)usba_readl(udc, INT_ENB));
+ (unsigned long)usba_int_enb_get(udc));
return 0;
}
@@ -650,9 +659,8 @@ static int usba_ep_disable(struct usb_ep *_ep)
usba_dma_readl(ep, STATUS);
}
usba_ep_writel(ep, CTL_DIS, USBA_EPT_ENABLE);
- usba_writel(udc, INT_ENB,
- usba_readl(udc, INT_ENB)
- & ~USBA_BF(EPT_INT, 1 << ep->index));
+ usba_int_enb_set(udc, usba_int_enb_get(udc) &
+ ~USBA_BF(EPT_INT, 1 << ep->index));
request_complete_list(ep, &req_list, -ESHUTDOWN);
@@ -1606,20 +1614,20 @@ static void usba_dma_irq(struct usba_udc *udc, struct usba_ep *ep)
static irqreturn_t usba_udc_irq(int irq, void *devid)
{
struct usba_udc *udc = devid;
- u32 status;
+ u32 status, int_enb;
u32 dma_status;
u32 ep_status;
spin_lock(&udc->lock);
- status = usba_readl(udc, INT_STA) & usba_readl(udc, INT_ENB);
+ int_enb = usba_int_enb_get(udc);
+ status = usba_readl(udc, INT_STA) & int_enb;
DBG(DBG_INT, "irq, status=%#08x\n", status);
if (status & USBA_DET_SUSPEND) {
toggle_bias(udc, 0);
usba_writel(udc, INT_CLR, USBA_DET_SUSPEND);
- usba_writel(udc, INT_ENB,
- usba_readl(udc, INT_ENB) | USBA_WAKE_UP);
+ usba_int_enb_set(udc, int_enb | USBA_WAKE_UP);
udc->bias_pulse_needed = true;
DBG(DBG_BUS, "Suspend detected\n");
if (udc->gadget.speed != USB_SPEED_UNKNOWN
@@ -1633,8 +1641,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
if (status & USBA_WAKE_UP) {
toggle_bias(udc, 1);
usba_writel(udc, INT_CLR, USBA_WAKE_UP);
- usba_writel(udc, INT_ENB,
- usba_readl(udc, INT_ENB) & ~USBA_WAKE_UP);
+ usba_int_enb_set(udc, int_enb & ~USBA_WAKE_UP);
DBG(DBG_BUS, "Wake Up CPU detected\n");
}
@@ -1702,11 +1709,8 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
| USBA_BF(BK_NUMBER, USBA_BK_NUMBER_ONE)));
usba_ep_writel(ep0, CTL_ENB,
USBA_EPT_ENABLE | USBA_RX_SETUP);
- usba_writel(udc, INT_ENB,
- (usba_readl(udc, INT_ENB)
- | USBA_BF(EPT_INT, 1)
- | USBA_DET_SUSPEND
- | USBA_END_OF_RESUME));
+ usba_int_enb_set(udc, int_enb | USBA_BF(EPT_INT, 1) |
+ USBA_DET_SUSPEND | USBA_END_OF_RESUME);
/*
* Unclear why we hit this irregularly, e.g. in usbtest,
@@ -1741,7 +1745,7 @@ static irqreturn_t usba_vbus_irq(int irq, void *devid)
if (vbus) {
toggle_bias(udc, 1);
usba_writel(udc, CTRL, USBA_ENABLE_MASK);
- usba_writel(udc, INT_ENB, USBA_END_OF_RESET);
+ usba_int_enb_set(udc, USBA_END_OF_RESET);
} else {
udc->gadget.speed = USB_SPEED_UNKNOWN;
reset_all_endpoints(udc);
@@ -1793,7 +1797,7 @@ static int atmel_usba_start(struct usb_gadget *gadget,
if (vbus_is_present(udc) && udc->vbus_prev == 0) {
toggle_bias(udc, 1);
usba_writel(udc, CTRL, USBA_ENABLE_MASK);
- usba_writel(udc, INT_ENB, USBA_END_OF_RESET);
+ usba_int_enb_set(udc, USBA_END_OF_RESET);
}
spin_unlock_irqrestore(&udc->lock, flags);
diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.h b/drivers/usb/gadget/udc/atmel_usba_udc.h
index 72b3537..497cd18 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.h
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.h
@@ -334,6 +334,8 @@ struct usba_udc {
u16 test_mode;
int vbus_prev;
+ u32 int_enb_cache;
+
#ifdef CONFIG_USB_GADGET_DEBUG_FS
struct dentry *debugfs_root;
struct dentry *debugfs_regs;
--
1.9.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v3 0/5] usb: atmel_usba_udc: Rework errata handling
2015-01-12 10:57 [PATCH v3 0/5] usb: atmel_usba_udc: Rework errata handling Boris Brezillon
` (4 preceding siblings ...)
2015-01-12 10:57 ` [PATCH v3 5/5] usb: gadget: atmel_usba: Cache INT_ENB register value Boris Brezillon
@ 2015-01-12 11:08 ` Nicolas Ferre
2015-01-12 13:08 ` [PATCH v4 1/5] usb: atmel_usba_udc: Rework at91sam9rl " Boris Brezillon
2015-01-13 2:15 ` [PATCH v3 0/5] usb: atmel_usba_udc: Rework " Bo Shen
7 siblings, 0 replies; 15+ messages in thread
From: Nicolas Ferre @ 2015-01-12 11:08 UTC (permalink / raw)
To: linux-arm-kernel
Le 12/01/2015 11:57, Boris Brezillon a ?crit :
> Hello,
>
> Here is a set of patches porting existing at91sam9rl erratum handling to
> DT and adding new code to handle at91sam9g45/9x5 erratum.
> It also adds several compatible strings to differentiate those errata.
>
> These patches should be backported to 3.17 and 3.18 stable releases but
> they do not apply cleanly on those stable branches.
> I'll send a backport of this series once it is merged in mainline.
>
> Regards,
>
> Boris
>
> Changes since v2:
> - remove UTF8 character in commit message of patch 2
>
> Changes since v1:
> - cache INT_ENB value to speedup INT_ENB read operations
To the whole series:
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Thanks.
> Boris Brezillon (5):
> usb: atmel_usba_udc: Rework at91sam9rl errata handling
> usb: atmel_usba_udc: Add at91sam9g45 and at91sam9x5 errata handling
> ARM: at91/dt: update udc compatible strings
> usb: atmel_usba_udc: Mask status with enabled irqs
> usb: gadget: atmel_usba: Cache INT_ENB register value
>
> .../devicetree/bindings/usb/atmel-usb.txt | 5 +-
> arch/arm/boot/dts/at91sam9g45.dtsi | 2 +-
> arch/arm/boot/dts/at91sam9x5.dtsi | 2 +-
> arch/arm/boot/dts/sama5d3.dtsi | 2 +-
> arch/arm/boot/dts/sama5d4.dtsi | 2 +-
> drivers/usb/gadget/udc/atmel_usba_udc.c | 146 +++++++++++++--------
> drivers/usb/gadget/udc/atmel_usba_udc.h | 9 ++
> 7 files changed, 111 insertions(+), 57 deletions(-)
>
--
Nicolas Ferre
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v4 1/5] usb: atmel_usba_udc: Rework at91sam9rl errata handling
2015-01-12 10:57 [PATCH v3 0/5] usb: atmel_usba_udc: Rework errata handling Boris Brezillon
` (5 preceding siblings ...)
2015-01-12 11:08 ` [PATCH v3 0/5] usb: atmel_usba_udc: Rework errata handling Nicolas Ferre
@ 2015-01-12 13:08 ` Boris Brezillon
2015-01-13 2:15 ` [PATCH v3 0/5] usb: atmel_usba_udc: Rework " Bo Shen
7 siblings, 0 replies; 15+ messages in thread
From: Boris Brezillon @ 2015-01-12 13:08 UTC (permalink / raw)
To: linux-arm-kernel
at91sam9rl SoC has an erratum forcing us to toggle the BIAS on USB
suspend/resume events.
This specific handling was only activated when CONFIG_ARCH_AT91SAM9RL
was set, but commit bcf8c7e7703b ("ARM: at91: remove at91sam9rl legacy
board support") removed this option.
Rework the toggle_bias implementation to attach it to the "at91sam9rl-udc"
compatible string.
Add new compatible strings to avoid executing at91sam9rl erratum handling
on other SoCs.
Reported-by: Paul Bolle <pebolle@tiscali.nl>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
---
Changes since v3:
- rework commit message
.../devicetree/bindings/usb/atmel-usb.txt | 5 +-
drivers/usb/gadget/udc/atmel_usba_udc.c | 78 ++++++++++++----------
drivers/usb/gadget/udc/atmel_usba_udc.h | 5 ++
3 files changed, 52 insertions(+), 36 deletions(-)
diff --git a/Documentation/devicetree/bindings/usb/atmel-usb.txt b/Documentation/devicetree/bindings/usb/atmel-usb.txt
index bc2222c..38fee0f 100644
--- a/Documentation/devicetree/bindings/usb/atmel-usb.txt
+++ b/Documentation/devicetree/bindings/usb/atmel-usb.txt
@@ -51,7 +51,10 @@ usb1: gadget at fffa4000 {
Atmel High-Speed USB device controller
Required properties:
- - compatible: Should be "atmel,at91sam9rl-udc"
+ - compatible: Should be one of the following
+ "at91sam9rl-udc"
+ "at91sam9g45-udc"
+ "sama5d3-udc"
- reg: Address and length of the register set for the device
- interrupts: Should contain usba interrupt
- ep childnode: To specify the number of endpoints and their properties.
diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
index ce88237..36fd34b 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -8,6 +8,7 @@
* published by the Free Software Foundation.
*/
#include <linux/clk.h>
+#include <linux/clk/at91_pmc.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/interrupt.h>
@@ -324,28 +325,12 @@ static int vbus_is_present(struct usba_udc *udc)
return 1;
}
-#if defined(CONFIG_ARCH_AT91SAM9RL)
-
-#include <linux/clk/at91_pmc.h>
-
-static void toggle_bias(int is_on)
-{
- unsigned int uckr = at91_pmc_read(AT91_CKGR_UCKR);
-
- if (is_on)
- at91_pmc_write(AT91_CKGR_UCKR, uckr | AT91_PMC_BIASEN);
- else
- at91_pmc_write(AT91_CKGR_UCKR, uckr & ~(AT91_PMC_BIASEN));
-}
-
-#else
-
-static void toggle_bias(int is_on)
+static void toggle_bias(struct usba_udc *udc, int is_on)
{
+ if (udc->errata && udc->errata->toggle_bias)
+ udc->errata->toggle_bias(udc, is_on);
}
-#endif /* CONFIG_ARCH_AT91SAM9RL */
-
static void next_fifo_transaction(struct usba_ep *ep, struct usba_request *req)
{
unsigned int transaction_len;
@@ -1620,7 +1605,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
DBG(DBG_INT, "irq, status=%#08x\n", status);
if (status & USBA_DET_SUSPEND) {
- toggle_bias(0);
+ toggle_bias(udc, 0);
usba_writel(udc, INT_CLR, USBA_DET_SUSPEND);
DBG(DBG_BUS, "Suspend detected\n");
if (udc->gadget.speed != USB_SPEED_UNKNOWN
@@ -1632,7 +1617,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
}
if (status & USBA_WAKE_UP) {
- toggle_bias(1);
+ toggle_bias(udc, 1);
usba_writel(udc, INT_CLR, USBA_WAKE_UP);
DBG(DBG_BUS, "Wake Up CPU detected\n");
}
@@ -1736,13 +1721,13 @@ static irqreturn_t usba_vbus_irq(int irq, void *devid)
vbus = vbus_is_present(udc);
if (vbus != udc->vbus_prev) {
if (vbus) {
- toggle_bias(1);
+ toggle_bias(udc, 1);
usba_writel(udc, CTRL, USBA_ENABLE_MASK);
usba_writel(udc, INT_ENB, USBA_END_OF_RESET);
} else {
udc->gadget.speed = USB_SPEED_UNKNOWN;
reset_all_endpoints(udc);
- toggle_bias(0);
+ toggle_bias(udc, 0);
usba_writel(udc, CTRL, USBA_DISABLE_MASK);
if (udc->driver->disconnect) {
spin_unlock(&udc->lock);
@@ -1788,7 +1773,7 @@ static int atmel_usba_start(struct usb_gadget *gadget,
/* If Vbus is present, enable the controller and wait for reset */
spin_lock_irqsave(&udc->lock, flags);
if (vbus_is_present(udc) && udc->vbus_prev == 0) {
- toggle_bias(1);
+ toggle_bias(udc, 1);
usba_writel(udc, CTRL, USBA_ENABLE_MASK);
usba_writel(udc, INT_ENB, USBA_END_OF_RESET);
}
@@ -1811,7 +1796,7 @@ static int atmel_usba_stop(struct usb_gadget *gadget)
spin_unlock_irqrestore(&udc->lock, flags);
/* This will also disable the DP pullup */
- toggle_bias(0);
+ toggle_bias(udc, 0);
usba_writel(udc, CTRL, USBA_DISABLE_MASK);
clk_disable_unprepare(udc->hclk);
@@ -1823,6 +1808,29 @@ static int atmel_usba_stop(struct usb_gadget *gadget)
}
#ifdef CONFIG_OF
+static void at91sam9rl_toggle_bias(struct usba_udc *udc, int is_on)
+{
+ unsigned int uckr = at91_pmc_read(AT91_CKGR_UCKR);
+
+ if (is_on)
+ at91_pmc_write(AT91_CKGR_UCKR, uckr | AT91_PMC_BIASEN);
+ else
+ at91_pmc_write(AT91_CKGR_UCKR, uckr & ~(AT91_PMC_BIASEN));
+}
+
+static const struct usba_udc_errata at91sam9rl_errata = {
+ .toggle_bias = at91sam9rl_toggle_bias,
+};
+
+static const struct of_device_id atmel_udc_dt_ids[] = {
+ { .compatible = "atmel,at91sam9rl-udc", .data = &at91sam9rl_errata },
+ { .compatible = "atmel,at91sam9g45-udc" },
+ { .compatible = "atmel,sama5d3-udc" },
+ { /* sentinel */ }
+};
+
+MODULE_DEVICE_TABLE(of, atmel_udc_dt_ids);
+
static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev,
struct usba_udc *udc)
{
@@ -1830,10 +1838,17 @@ static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev,
const char *name;
enum of_gpio_flags flags;
struct device_node *np = pdev->dev.of_node;
+ const struct of_device_id *match;
struct device_node *pp;
int i, ret;
struct usba_ep *eps, *ep;
+ match = of_match_node(atmel_udc_dt_ids, np);
+ if (!match)
+ return ERR_PTR(-EINVAL);
+
+ udc->errata = match->data;
+
udc->num_ep = 0;
udc->vbus_pin = of_get_named_gpio_flags(np, "atmel,vbus-gpio", 0,
@@ -2024,7 +2039,7 @@ static int usba_udc_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "Unable to enable pclk, aborting.\n");
return ret;
}
- toggle_bias(0);
+
usba_writel(udc, CTRL, USBA_DISABLE_MASK);
clk_disable_unprepare(pclk);
@@ -2033,6 +2048,8 @@ static int usba_udc_probe(struct platform_device *pdev)
else
udc->usba_ep = usba_udc_pdata(pdev, udc);
+ toggle_bias(udc, 0);
+
if (IS_ERR(udc->usba_ep))
return PTR_ERR(udc->usba_ep);
@@ -2092,15 +2109,6 @@ static int __exit usba_udc_remove(struct platform_device *pdev)
return 0;
}
-#if defined(CONFIG_OF)
-static const struct of_device_id atmel_udc_dt_ids[] = {
- { .compatible = "atmel,at91sam9rl-udc" },
- { /* sentinel */ }
-};
-
-MODULE_DEVICE_TABLE(of, atmel_udc_dt_ids);
-#endif
-
static struct platform_driver udc_driver = {
.remove = __exit_p(usba_udc_remove),
.driver = {
diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.h b/drivers/usb/gadget/udc/atmel_usba_udc.h
index a70706e..456899e 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.h
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.h
@@ -304,6 +304,10 @@ struct usba_request {
unsigned int mapped:1;
};
+struct usba_udc_errata {
+ void (*toggle_bias)(struct usba_udc *udc, int is_on);
+};
+
struct usba_udc {
/* Protect hw registers from concurrent modifications */
spinlock_t lock;
@@ -314,6 +318,7 @@ struct usba_udc {
struct usb_gadget gadget;
struct usb_gadget_driver *driver;
struct platform_device *pdev;
+ const struct usba_udc_errata *errata;
int irq;
int vbus_pin;
int vbus_pin_inverted;
--
1.9.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v3 0/5] usb: atmel_usba_udc: Rework errata handling
2015-01-12 10:57 [PATCH v3 0/5] usb: atmel_usba_udc: Rework errata handling Boris Brezillon
` (6 preceding siblings ...)
2015-01-12 13:08 ` [PATCH v4 1/5] usb: atmel_usba_udc: Rework at91sam9rl " Boris Brezillon
@ 2015-01-13 2:15 ` Bo Shen
7 siblings, 0 replies; 15+ messages in thread
From: Bo Shen @ 2015-01-13 2:15 UTC (permalink / raw)
To: linux-arm-kernel
Hi Boris,
On 01/12/2015 06:57 PM, Boris Brezillon wrote:
> Hello,
>
> Here is a set of patches porting existing at91sam9rl erratum handling to
> DT and adding new code to handle at91sam9g45/9x5 erratum.
> It also adds several compatible strings to differentiate those errata.
>
> These patches should be backported to 3.17 and 3.18 stable releases but
> they do not apply cleanly on those stable branches.
> I'll send a backport of this series once it is merged in mainline.
>
> Regards,
>
> Boris
>
> Changes since v2:
> - remove UTF8 character in commit message of patch 2
>
> Changes since v1:
> - cache INT_ENB value to speedup INT_ENB read operations
For the whole series, test OK on at91sam9m10g45ek board with mass
storage gadget, test OK on sama5d36ek with serial gadget.
Tested-by: Bo Shen <voice.shen@atmel.com>
> Boris Brezillon (5):
> usb: atmel_usba_udc: Rework at91sam9rl errata handling
> usb: atmel_usba_udc: Add at91sam9g45 and at91sam9x5 errata handling
> ARM: at91/dt: update udc compatible strings
> usb: atmel_usba_udc: Mask status with enabled irqs
> usb: gadget: atmel_usba: Cache INT_ENB register value
>
> .../devicetree/bindings/usb/atmel-usb.txt | 5 +-
> arch/arm/boot/dts/at91sam9g45.dtsi | 2 +-
> arch/arm/boot/dts/at91sam9x5.dtsi | 2 +-
> arch/arm/boot/dts/sama5d3.dtsi | 2 +-
> arch/arm/boot/dts/sama5d4.dtsi | 2 +-
> drivers/usb/gadget/udc/atmel_usba_udc.c | 146 +++++++++++++--------
> drivers/usb/gadget/udc/atmel_usba_udc.h | 9 ++
> 7 files changed, 111 insertions(+), 57 deletions(-)
>
Best Regards,
Bo Shen
^ permalink raw reply [flat|nested] 15+ messages in thread