Re: [PATCH] usb: gadget: atmel: remove pointless retrieval of DT name property

2018-08-30 Thread Nicolas Ferre

On 29/08/2018 at 22:01, Rob Herring wrote:

The name is always non-NULL and then is not used anywhere in this function,
so remove it.


Indeed.


Cc: Nicolas Ferre 


Acked-by: Nicolas Ferre 


Cc: Felipe Balbi 
Cc: Greg Kroah-Hartman 
Cc: Alexandre Belloni 
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-usb@vger.kernel.org
Signed-off-by: Rob Herring 
---
  drivers/usb/gadget/udc/atmel_usba_udc.c | 6 --
  1 file changed, 6 deletions(-)

diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
b/drivers/usb/gadget/udc/atmel_usba_udc.c
index 17147b8c771e..5729935c5eb2 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -2004,7 +2004,6 @@ static struct usba_ep * atmel_udc_of_init(struct 
platform_device *pdev,
struct usba_udc *udc)
  {
u32 val;
-   const char *name;
struct device_node *np = pdev->dev.of_node;
const struct of_device_id *match;
struct device_node *pp;
@@ -2094,11 +2093,6 @@ static struct usba_ep * atmel_udc_of_init(struct 
platform_device *pdev,
ep->can_dma = of_property_read_bool(pp, "atmel,can-dma");
ep->can_isoc = of_property_read_bool(pp, "atmel,can-isoc");
  
-		ret = of_property_read_string(pp, "name", );

-   if (ret) {
-   dev_err(>dev, "of_probe: name error(%d)\n", ret);
-   goto err;
-   }
sprintf(ep->name, "ep%d", ep->index);
ep->ep.name = ep->name;
  




--
Nicolas Ferre


Re: [PATCH 0/3] Fix an Atmel USBA UDC issue introducted in 4.17-rc1

2018-04-17 Thread Nicolas Ferre

On 16/04/2018 at 11:34, Romain Izard wrote:

The use of GPIO descriptors takes care of inversion flags declared in
the device tree. The conversion of the Atmel USBA UDC driver introduced
in 4.17-rc1 missed it, and as a result the inversion will not work.

In addition, cleanup the code to remove an include left behind after
the suppression of the support of platform_data to declare USBA
controllers.

These changes have not been tested on any hardware, as I do not have
a board that needs to use inverted GPIOs.

Romain Izard (3):
   usb: gadget: udc: atmel: GPIO inversion is handled by gpiod
   usb: gadget: udc: atmel: Remove obsolete include
   usb: gadget: udc: atmel: Fix indenting


To the whole series:
Acked-by: Nicolas Ferre <nicolas.fe...@microchip.com>

Thank you Romain.
Best regards,
  Nicolas



  drivers/usb/gadget/udc/atmel_usba_udc.c | 22 ++
  drivers/usb/gadget/udc/atmel_usba_udc.h |  1 -
  include/linux/usb/atmel_usba_udc.h  | 24 
  3 files changed, 10 insertions(+), 37 deletions(-)
  delete mode 100644 include/linux/usb/atmel_usba_udc.h




--
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] usb: gadget: udc: atmel: Use devm_ioremap_resource()

2018-01-22 Thread Nicolas Ferre
On 23/01/2018 at 00:05, Ladislav Michl wrote:
> As devm_ioremap_resource() checks for valid resource,
> make use of it instead of testing ourselves. As a bonus
> memory region is requested.
> 
> Signed-off-by: Ladislav Michl <la...@linux-mips.org>

Acked-by: Nicolas Ferre <nicolas.fe...@microchip.com>

Thanks Ladislav.

Best regards,
  Nicolas

> ---
>  Changes:
>  - v2: Drop uneeded error message
> 
>  drivers/usb/gadget/udc/atmel_usba_udc.c | 34 
> +
>  1 file changed, 13 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
> b/drivers/usb/gadget/udc/atmel_usba_udc.c
> index 075eaaa8a408..f420710abdd7 100644
> --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
> @@ -2272,7 +2272,7 @@ static struct usba_ep * usba_udc_pdata(struct 
> platform_device *pdev,
>  
>  static int usba_udc_probe(struct platform_device *pdev)
>  {
> - struct resource *regs, *fifo;
> + struct resource *res;
>   struct clk *pclk, *hclk;
>   struct usba_udc *udc;
>   int irq, ret, i;
> @@ -2284,10 +2284,18 @@ static int usba_udc_probe(struct platform_device 
> *pdev)
>   udc->gadget = usba_gadget_template;
>   INIT_LIST_HEAD(>gadget.ep_list);
>  
> - regs = platform_get_resource(pdev, IORESOURCE_MEM, CTRL_IOMEM_ID);
> - fifo = platform_get_resource(pdev, IORESOURCE_MEM, FIFO_IOMEM_ID);
> - if (!regs || !fifo)
> - return -ENXIO;
> + res = platform_get_resource(pdev, IORESOURCE_MEM, CTRL_IOMEM_ID);
> + udc->regs = devm_ioremap_resource(>dev, res);
> + if (IS_ERR(udc->regs))
> + return PTR_ERR(udc->regs);
> + dev_info(>dev, "MMIO registers at %pR mapped at %p\n",
> +  res, udc->regs);
> +
> + res = platform_get_resource(pdev, IORESOURCE_MEM, FIFO_IOMEM_ID);
> + udc->fifo = devm_ioremap_resource(>dev, res);
> + if (IS_ERR(udc->fifo))
> + return PTR_ERR(udc->fifo);
> + dev_info(>dev, "FIFO at %pR mapped at %p\n", res, udc->fifo);
>  
>   irq = platform_get_irq(pdev, 0);
>   if (irq < 0)
> @@ -2307,22 +2315,6 @@ static int usba_udc_probe(struct platform_device *pdev)
>   udc->hclk = hclk;
>   udc->vbus_pin = -ENODEV;
>  
> - ret = -ENOMEM;
> - udc->regs = devm_ioremap(>dev, regs->start, resource_size(regs));
> - if (!udc->regs) {
> - dev_err(>dev, "Unable to map I/O memory, aborting.\n");
> - return ret;
> - }
> - dev_info(>dev, "MMIO registers at 0x%08lx mapped at %p\n",
> -  (unsigned long)regs->start, udc->regs);
> - udc->fifo = devm_ioremap(>dev, fifo->start, resource_size(fifo));
> - if (!udc->fifo) {
> - dev_err(>dev, "Unable to map FIFO, aborting.\n");
> - return ret;
> - }
> - dev_info(>dev, "FIFO at 0x%08lx mapped at %p\n",
> -  (unsigned long)fifo->start, udc->fifo);
> -
>   platform_set_drvdata(pdev, udc);
>  
>   /* Make sure we start from a clean slate */
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 22/24] USB: gadget: udc: Remove redundant license text

2017-11-06 Thread Nicolas Ferre
On 06/11/2017 at 15:37, Greg Kroah-Hartman wrote:
> Now that the SPDX tag is in all USB files, that identifies the license
> in a specific and legally-defined manner.  So the extra GPL text wording
> can be removed as it is no longer needed at all.
> 
> This is done on a quest to remove the 700+ different ways that files in
> the kernel describe the GPL license text.  And there's unneeded stuff
> like the address (sometimes incorrect) for the FSF which is never
> needed.
> 
> No copyright headers or other non-license-description text was removed.
> 
> Cc: Felipe Balbi <ba...@kernel.org>
> Cc: Nicolas Ferre <nicolas.fe...@microchip.com>

[..]

>  drivers/usb/gadget/udc/at91_udc.c   |  5 -
>  drivers/usb/gadget/udc/at91_udc.h   |  5 -
>  drivers/usb/gadget/udc/atmel_usba_udc.c |  4 
>  drivers/usb/gadget/udc/atmel_usba_udc.h |  4 

For AT91 files above with modifications hereunder:
Acked-by: Nicolas Ferre <nicolas.fe...@microchip.com>

Thanks, best regards,

[..]

> diff --git a/drivers/usb/gadget/udc/at91_udc.c 
> b/drivers/usb/gadget/udc/at91_udc.c
> index 972f78409df7..bfe278294e88 100644
> --- a/drivers/usb/gadget/udc/at91_udc.c
> +++ b/drivers/usb/gadget/udc/at91_udc.c
> @@ -5,11 +5,6 @@
>   * Copyright (C) 2004 by Thomas Rathbone
>   * Copyright (C) 2005 by HP Labs
>   * Copyright (C) 2005 by David Brownell
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
>   */
>  
>  #undef   VERBOSE_DEBUG
> diff --git a/drivers/usb/gadget/udc/at91_udc.h 
> b/drivers/usb/gadget/udc/at91_udc.h
> index 9581a868032e..fd58c5b81826 100644
> --- a/drivers/usb/gadget/udc/at91_udc.h
> +++ b/drivers/usb/gadget/udc/at91_udc.h
> @@ -3,11 +3,6 @@
>   * Copyright (C) 2004 by Thomas Rathbone, HP Labs
>   * Copyright (C) 2005 by Ivan Kokshaysky
>   * Copyright (C) 2006 by SAN People
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
>   */
>  
>  #ifndef AT91_UDC_H
> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
> b/drivers/usb/gadget/udc/atmel_usba_udc.c
> index 12543decf9ab..075eaaa8a408 100644
> --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
> @@ -3,10 +3,6 @@
>   * Driver for the Atmel USBA high speed USB device controller
>   *
>   * Copyright (C) 2005-2007 Atmel 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.
>   */
>  #include 
>  #include 
> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.h 
> b/drivers/usb/gadget/udc/atmel_usba_udc.h
> index 10df5e4aaeb2..860a00a6fdd0 100644
> --- a/drivers/usb/gadget/udc/atmel_usba_udc.h
> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.h
> @@ -3,10 +3,6 @@
>   * Driver for the Atmel USBA high speed USB device controller
>   *
>   * Copyright (C) 2005-2007 Atmel 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 __LINUX_USB_GADGET_USBA_UDC_H__
>  #define __LINUX_USB_GADGET_USBA_UDC_H__
[..]

-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 7/9] pwm: atmel-tcb: Support backup mode

2017-09-22 Thread Nicolas Ferre
On 15/09/2017 at 16:04, Romain Izard wrote:
> Save and restore registers for the PWM on suspend and resume, which
> makes hibernation and backup modes possible.
> 
> Signed-off-by: Romain Izard <romain.izard@gmail.com>

Seems good to me:
Acked-by: Nicolas Ferre <nicolas.fe...@microchip.com>

> ---
>  drivers/pwm/pwm-atmel-tcb.c | 63 
> +++--
>  1 file changed, 61 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pwm/pwm-atmel-tcb.c b/drivers/pwm/pwm-atmel-tcb.c
> index 75db585a2a94..acd3ce8ecf3f 100644
> --- a/drivers/pwm/pwm-atmel-tcb.c
> +++ b/drivers/pwm/pwm-atmel-tcb.c
> @@ -37,11 +37,20 @@ struct atmel_tcb_pwm_device {
>   unsigned period;/* PWM period expressed in clk cycles */
>  };
>  
> +struct atmel_tcb_channel {
> + u32 enabled;
> + u32 cmr;
> + u32 ra;
> + u32 rb;
> + u32 rc;
> +};
> +
>  struct atmel_tcb_pwm_chip {
>   struct pwm_chip chip;
>   spinlock_t lock;
>   struct atmel_tc *tc;
>   struct atmel_tcb_pwm_device *pwms[NPWM];
> + struct atmel_tcb_channel bkup[NPWM / 2];
>  };
>  
>  static inline struct atmel_tcb_pwm_chip *to_tcb_chip(struct pwm_chip *chip)
> @@ -175,12 +184,15 @@ static void atmel_tcb_pwm_disable(struct pwm_chip 
> *chip, struct pwm_device *pwm)
>* Use software trigger to apply the new setting.
>* If both PWM devices in this group are disabled we stop the clock.
>*/
> - if (!(cmr & (ATMEL_TC_ACPC | ATMEL_TC_BCPC)))
> + if (!(cmr & (ATMEL_TC_ACPC | ATMEL_TC_BCPC))) {
>   __raw_writel(ATMEL_TC_SWTRG | ATMEL_TC_CLKDIS,
>regs + ATMEL_TC_REG(group, CCR));
> - else
> + tcbpwmc->bkup[group].enabled = 1;
> + } else {
>   __raw_writel(ATMEL_TC_SWTRG, regs +
>ATMEL_TC_REG(group, CCR));
> + tcbpwmc->bkup[group].enabled = 0;
> + }
>  
>   spin_unlock(>lock);
>  }
> @@ -263,6 +275,7 @@ static int atmel_tcb_pwm_enable(struct pwm_chip *chip, 
> struct pwm_device *pwm)
>   /* Use software trigger to apply the new setting */
>   __raw_writel(ATMEL_TC_CLKEN | ATMEL_TC_SWTRG,
>regs + ATMEL_TC_REG(group, CCR));
> + tcbpwmc->bkup[group].enabled = 1;
>   spin_unlock(>lock);
>   return 0;
>  }
> @@ -445,10 +458,56 @@ static const struct of_device_id atmel_tcb_pwm_dt_ids[] 
> = {
>  };
>  MODULE_DEVICE_TABLE(of, atmel_tcb_pwm_dt_ids);
>  
> +#ifdef CONFIG_PM_SLEEP
> +static int atmel_tcb_pwm_suspend(struct device *dev)
> +{
> + struct platform_device *pdev = to_platform_device(dev);
> + struct atmel_tcb_pwm_chip *tcbpwm = platform_get_drvdata(pdev);
> + void __iomem *base = tcbpwm->tc->regs;
> + int i;
> +
> + for (i = 0; i < (NPWM / 2); i++) {
> + struct atmel_tcb_channel *chan = >bkup[i];
> +
> + chan->cmr = readl(base + ATMEL_TC_REG(i, CMR));
> + chan->ra = readl(base + ATMEL_TC_REG(i, RA));
> + chan->rb = readl(base + ATMEL_TC_REG(i, RB));
> + chan->rc = readl(base + ATMEL_TC_REG(i, RC));
> + }
> + return 0;
> +}
> +
> +static int atmel_tcb_pwm_resume(struct device *dev)
> +{
> + struct platform_device *pdev = to_platform_device(dev);
> + struct atmel_tcb_pwm_chip *tcbpwm = platform_get_drvdata(pdev);
> + void __iomem *base = tcbpwm->tc->regs;
> + int i;
> +
> + for (i = 0; i < (NPWM / 2); i++) {
> + struct atmel_tcb_channel *chan = >bkup[i];
> +
> + writel(chan->cmr, base + ATMEL_TC_REG(i, CMR));
> + writel(chan->ra, base + ATMEL_TC_REG(i, RA));
> + writel(chan->rb, base + ATMEL_TC_REG(i, RB));
> + writel(chan->rc, base + ATMEL_TC_REG(i, RC));
> + if (chan->enabled) {
> + writel(ATMEL_TC_CLKEN | ATMEL_TC_SWTRG,
> + base + ATMEL_TC_REG(i, CCR));
> + }
> + }
> + return 0;
> +}
> +#endif
> +
> +static SIMPLE_DEV_PM_OPS(atmel_tcb_pwm_pm_ops, atmel_tcb_pwm_suspend,
> +  atmel_tcb_pwm_resume);
> +
>  static struct platform_driver atmel_tcb_pwm_driver = {
>   .driver = {
>   .name = "atmel-tcb-pwm",
>   .of_match_table = atmel_tcb_pwm_dt_ids,
> + .pm = _tcb_pwm_pm_ops,
>   },
>   .probe = atmel_tcb_pwm_probe,
>   .remove = atmel_tcb_pwm_remove,
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 6/9] ehci-atmel: Power down during suspend is normal

2017-09-22 Thread Nicolas Ferre
On 15/09/2017 at 16:04, Romain Izard wrote:
> When an Atmel SoC is suspended with the backup mode, the USB bus will be
> powered down. As this is expected, do not return an error to the driver
> core when ehci_resume detects it.
> 
> Signed-off-by: Romain Izard <romain.izard@gmail.com>
> ---
>  drivers/usb/host/ehci-atmel.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
> index 7440722bfbf0..2a8b9bdc0e57 100644
> --- a/drivers/usb/host/ehci-atmel.c
> +++ b/drivers/usb/host/ehci-atmel.c
> @@ -205,7 +205,8 @@ static int __maybe_unused ehci_atmel_drv_resume(struct 
> device *dev)
>   struct atmel_ehci_priv *atmel_ehci = hcd_to_atmel_ehci_priv(hcd);
>  
>   atmel_start_clock(atmel_ehci);
> - return ehci_resume(hcd, false);
> + ehci_resume(hcd, false);
> + return 0;

Ok, I agree with that as the underlying function takes care about the
controller, in any case (even for !B+S-R case). So we don't have any
added value to propagate this information.

Acked-by: Nicolas Ferre <nicolas.fe...@microchip.com>

>  }
>  
>  #ifdef CONFIG_OF
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 1/9] clk: at91: pmc: Wait for clocks when resuming

2017-09-22 Thread Nicolas Ferre
On 15/09/2017 at 16:04, Romain Izard wrote:
> Wait for the syncronization of all clocks when resuming, not only the
> UPLL clock. Do not use regmap_read_poll_timeout, as it will call BUG()
> when interrupts are masked, which is the case in here.
> 
> Signed-off-by: Romain Izard <romain.izard@gmail.com>

And here is my:
Acked-by: Nicolas Ferre <nicolas.fe...@microchip.com>

> ---
>  drivers/clk/at91/pmc.c | 24 
>  1 file changed, 16 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
> index 775af473fe11..5c2b26de303e 100644
> --- a/drivers/clk/at91/pmc.c
> +++ b/drivers/clk/at91/pmc.c
> @@ -107,10 +107,20 @@ static int pmc_suspend(void)
>   return 0;
>  }
>  
> +static bool pmc_ready(unsigned int mask)
> +{
> + unsigned int status;
> +
> + regmap_read(pmcreg, AT91_PMC_SR, );
> +
> + return ((status & mask) == mask) ? 1 : 0;
> +}
> +
>  static void pmc_resume(void)
>  {
> - int i, ret = 0;
> + int i;
>   u32 tmp;
> + u32 mask = AT91_PMC_MCKRDY | AT91_PMC_LOCKA;
>  
>   regmap_read(pmcreg, AT91_PMC_MCKR, );
>   if (pmc_cache.mckr != tmp)
> @@ -134,13 +144,11 @@ static void pmc_resume(void)
>AT91_PMC_PCR_CMD);
>   }
>  
> - if (pmc_cache.uckr & AT91_PMC_UPLLEN) {
> - ret = regmap_read_poll_timeout(pmcreg, AT91_PMC_SR, tmp,
> -!(tmp & AT91_PMC_LOCKU),
> -10, 5000);
> - if (ret)
> - pr_crit("USB PLL didn't lock when resuming\n");
> - }
> + if (pmc_cache.uckr & AT91_PMC_UPLLEN)
> + mask |= AT91_PMC_LOCKU;
> +
> + while (!pmc_ready(mask))
> + cpu_relax();
>  }
>  
>  static struct syscore_ops pmc_syscore_ops = {
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v1 01/10] clk: at91: pmc: Wait for clocks when resuming

2017-09-22 Thread Nicolas Ferre
On 14/09/2017 at 18:15, Romain Izard wrote:
> 2017-09-13 14:15 GMT+02:00 Nicolas Ferre <nicolas.fe...@microchip.com>:
>> On 08/09/2017 at 17:35, Romain Izard wrote:
>>> Wait for the syncronization of all clocks when resuming, not only the
>>> UPLL clock. Do not use regmap_read_poll_timeout, as it will call BUG()
>>> when interrupts are masked, which is the case in here.
>>>
>>> Signed-off-by: Romain Izard <romain.izard@gmail.com>
>>> ---
>>>  drivers/clk/at91/pmc.c | 24 
>>>  1 file changed, 16 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
>>> index 775af473fe11..5c2b26de303e 100644
>>> --- a/drivers/clk/at91/pmc.c
>>> +++ b/drivers/clk/at91/pmc.c
>>> @@ -107,10 +107,20 @@ static int pmc_suspend(void)
>>>   return 0;
>>>  }
>>>
>>> +static bool pmc_ready(unsigned int mask)
>>> +{
>>> + unsigned int status;
>>> +
>>> + regmap_read(pmcreg, AT91_PMC_SR, );
>>> +
>>> + return ((status & mask) == mask) ? 1 : 0;
>>> +}
>>> +
>>>  static void pmc_resume(void)
>>>  {
>>> - int i, ret = 0;
>>> + int i;
>>>   u32 tmp;
>>> + u32 mask = AT91_PMC_MCKRDY | AT91_PMC_LOCKA;
>>>
>>>   regmap_read(pmcreg, AT91_PMC_MCKR, );
>>>   if (pmc_cache.mckr != tmp)
>>> @@ -134,13 +144,11 @@ static void pmc_resume(void)
>>>AT91_PMC_PCR_CMD);
>>>   }
>>>
>>> - if (pmc_cache.uckr & AT91_PMC_UPLLEN) {
>>> - ret = regmap_read_poll_timeout(pmcreg, AT91_PMC_SR, tmp,
>>> -!(tmp & AT91_PMC_LOCKU),
>>> -10, 5000);
>>> - if (ret)
>>> - pr_crit("USB PLL didn't lock when resuming\n");
>>> - }
>>> + if (pmc_cache.uckr & AT91_PMC_UPLLEN)
>>> + mask |= AT91_PMC_LOCKU;
>>> +
>>> + while (!pmc_ready(mask))
>>> + cpu_relax();
>>
>> Okay, but I would prefer to keep the timeout property in it. So we may
>> need to re-implement a timeout way-out here.
>>
> 
> We need to have a reference clock to measure the timeout delay. If we use
> the kernel's timekeeping, it relies on the clocks that we are configuring in
> this code. Moreover, my experience with the mainline code is that when
> something goes wrong, nothing will work. No oops or panic will be reported,
> the device will just stop working.
> 
> In my case, I had obvious failures (it just stopped working unless I removed
> USB wakeup or activated the console during suspend) but also very rare
> failures, that occurred in the bootloader. Those issues were detected when
> testing repeated suspend cycles for a night: the memory controller would
> never enter the self-refresh mode during the resume sequence.
> 
> This led me to question the bootloader's code first, and I set up 4 boards
> with the backup prototype code on v4.9 to verify that it was stable on
> suspend. I've reached 1.5 million sleep cycles over 3 weeks without
> failure, so this hinted towards the difference between the prototype and the
> backup code provided for v4.12 (which contained the patch that got in
> v4.13). Once I integrated this patch, I've run the v4.12 code for 2 weeks
> without issue as well.
> 
> In the end, I don't want to touch this code if I do not have to, as checking
> that it does not regress is really cumbersome.

The timeout was more for PLL like the one use for USB. I didn't want to
block only for USB PLL failure (which is kind of hypothetical, I admit).
Anyway, I understand your arguments and taking into account the
extensive tests that you've run, I agree with your approach. I'm adding
my Ack to the v2.

Thanks for having take the time to describe your debugging session: it's
valuable information for everybody.

Best regards,
-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 3/9] clk: at91: pmc: Support backup for programmable clocks

2017-09-22 Thread Nicolas Ferre
On 15/09/2017 at 16:04, Romain Izard wrote:
> From: Romain Izard <romain.iz...@mobile-devices.fr>
> 
> When an AT91 programmable clock is declared in the device tree, register
> it into the Power Management Controller driver. On entering suspend mode,
> the driver saves and restores the Programmable Clock registers to support
> the backup mode for these clocks.
> 
> Signed-off-by: Romain Izard <romain.izard@gmail.com>

Romain,

Some nitpicking and one comment. But on the overall patch, here is my:
Acked-by: Nicolas Ferre <nicolas.fe...@microchip.com>

See below:

> ---
> Changes in v2:
> * register PCKs on clock startup
> 
>  drivers/clk/at91/clk-programmable.c |  2 ++
>  drivers/clk/at91/pmc.c  | 27 +++
>  drivers/clk/at91/pmc.h  |  2 ++
>  3 files changed, 31 insertions(+)
> 
> diff --git a/drivers/clk/at91/clk-programmable.c 
> b/drivers/clk/at91/clk-programmable.c
> index 85a449cf61e3..0e6aab1252fc 100644
> --- a/drivers/clk/at91/clk-programmable.c
> +++ b/drivers/clk/at91/clk-programmable.c
> @@ -204,6 +204,8 @@ at91_clk_register_programmable(struct regmap *regmap,
>   if (ret) {
>   kfree(prog);
>   hw = ERR_PTR(ret);

Nit: "else" not needed.

> + } else {
> + pmc_register_pck(id);
>   }
>  
>   return hw;
> diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
> index 07dc2861ad3f..3910b7537152 100644
> --- a/drivers/clk/at91/pmc.c
> +++ b/drivers/clk/at91/pmc.c
> @@ -22,6 +22,7 @@
>  #include "pmc.h"
>  
>  #define PMC_MAX_IDS 128
> +#define PMC_MAX_PCKS 8
>  
>  int of_at91_get_clk_range(struct device_node *np, const char *propname,
> struct clk_range *range)
> @@ -50,6 +51,7 @@ EXPORT_SYMBOL_GPL(of_at91_get_clk_range);
>  static struct regmap *pmcreg;
>  
>  static u8 registered_ids[PMC_MAX_IDS];
> +static u8 registered_pcks[PMC_MAX_PCKS];
>  
>  static struct
>  {
> @@ -66,8 +68,10 @@ static struct
>   u32 pcr[PMC_MAX_IDS];
>   u32 audio_pll0;
>   u32 audio_pll1;
> + u32 pckr[PMC_MAX_PCKS];
>  } pmc_cache;
>  
> +/* Clock ID 0 is invalid */

(read: so we can use the 0 value as an indicator that this place in the
table hasn't been filled, so unused)

>  void pmc_register_id(u8 id)
>  {
>   int i;
> @@ -82,6 +86,21 @@ void pmc_register_id(u8 id)
>   }
>  }
>  
> +/* Programmable Clock 0 is valid */

I understand the rationale behind these ^^ two comments, but I would
like that it's more explicit. Saying that you will store the pck id as
(id + 1) and that you would have to invert this operation while using
the stored id.
Maybe add a comment about this transformation to the struct definition
as well...


> +void pmc_register_pck(u8 pck)
> +{
> + int i;
> +
> + for (i = 0; i < PMC_MAX_PCKS; i++) {
> + if (registered_pcks[i] == 0) {
> + registered_pcks[i] = pck + 1;
> + break;
> + }
> + if (registered_pcks[i] == (pck + 1))
> + break;
> + }
> +}
> +
>  static int pmc_suspend(void)
>  {
>   int i;
> @@ -103,6 +122,10 @@ static int pmc_suspend(void)
>   regmap_read(pmcreg, AT91_PMC_PCR,
>   _cache.pcr[registered_ids[i]]);
>   }
> + for (i = 0; registered_pcks[i]; i++) {
> + u8 num = registered_pcks[i] - 1;

Nit: declaration are better made at the beginning of the function. This
lead to a checkpatch warning:
"WARNING: Missing a blank line after declarations"

> + regmap_read(pmcreg, AT91_PMC_PCKR(num), _cache.pckr[num]);
> + }
>  
>   return 0;
>  }
> @@ -143,6 +166,10 @@ static void pmc_resume(void)
>pmc_cache.pcr[registered_ids[i]] |
>AT91_PMC_PCR_CMD);
>   }
> + for (i = 0; registered_pcks[i]; i++) {
> + u8 num = registered_pcks[i] - 1;

Ditto

> + regmap_write(pmcreg, AT91_PMC_PCKR(num), pmc_cache.pckr[num]);
> + }
>  
>   if (pmc_cache.uckr & AT91_PMC_UPLLEN)
>   mask |= AT91_PMC_LOCKU;
> diff --git a/drivers/clk/at91/pmc.h b/drivers/clk/at91/pmc.h
> index 858e8ef7e8db..d22b1fa9ecdc 100644
> --- a/drivers/clk/at91/pmc.h
> +++ b/drivers/clk/at91/pmc.h
> @@ -31,8 +31,10 @@ int of_at91_get_clk_range(struct device_node *np, const 
> char *propname,
>  
>  #ifdef CONFIG_PM
>  void pmc_register_id(u8 id);
> +void pmc_register_pck(u8 pck);
>  #else
>  static inline void pmc_register_id(u8 id) {}
> +static inline void pmc_register_pck(u8 pck) {}
>  #endif
>  
>  #endif /* __PMC_H_ */
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 9/9] tty/serial: atmel: Prevent a warning on suspend

2017-09-19 Thread Nicolas Ferre
On 15/09/2017 at 16:04, Romain Izard wrote:
> The atmel serial port driver reported the following warning on suspend:
> atmel_usart f802.serial: ttyS1: Unable to drain transmitter
> 
> As the ATMEL_US_TXEMPTY status bit in ATMEL_US_CSR is always cleared
> when the transmitter is disabled, we need to know the transmitter's
> state to return the real fifo state. And as ATMEL_US_CR is write-only,
> it is necessary to save the state of the transmitter in a local
> variable, and update the variable when TXEN and TXDIS is written in
> ATMEL_US_CR.
> 
> After those changes, atmel_tx_empty can return "empty" on suspend, the
> warning in uart_suspend_port disappears, and suspending is 20ms shorter
> for each enabled Atmel serial port.
> 
> Signed-off-by: Romain Izard <romain.izard@gmail.com>

Tested-by: Nicolas Ferre <nicolas.fe...@microchip.com>
on sama5d2 Xplained.

Acked-by: Nicolas Ferre <nicolas.fe...@microchip.com>

> ---
>  drivers/tty/serial/atmel_serial.c | 14 ++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/drivers/tty/serial/atmel_serial.c 
> b/drivers/tty/serial/atmel_serial.c
> index 7551cab438ff..783af6648be0 100644
> --- a/drivers/tty/serial/atmel_serial.c
> +++ b/drivers/tty/serial/atmel_serial.c
> @@ -171,6 +171,7 @@ struct atmel_uart_port {
>   boolhas_hw_timer;
>   struct timer_list   uart_timer;
>  
> + booltx_stopped;
>   boolsuspended;
>   unsigned intpending;
>   unsigned intpending_status;
> @@ -380,6 +381,10 @@ static int atmel_config_rs485(struct uart_port *port,
>   */
>  static u_int atmel_tx_empty(struct uart_port *port)
>  {
> + struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
> +
> + if (atmel_port->tx_stopped)
> + return TIOCSER_TEMT;
>   return (atmel_uart_readl(port, ATMEL_US_CSR) & ATMEL_US_TXEMPTY) ?
>   TIOCSER_TEMT :
>   0;
> @@ -485,6 +490,7 @@ static void atmel_stop_tx(struct uart_port *port)
>* is fully transmitted.
>*/
>   atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXDIS);
> + atmel_port->tx_stopped = true;
>  
>   /* Disable interrupts */
>   atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask);
> @@ -492,6 +498,7 @@ static void atmel_stop_tx(struct uart_port *port)
>   if ((port->rs485.flags & SER_RS485_ENABLED) &&
>   !(port->rs485.flags & SER_RS485_RX_DURING_TX))
>   atmel_start_rx(port);
> +
>  }
>  
>  /*
> @@ -521,6 +528,7 @@ static void atmel_start_tx(struct uart_port *port)
>  
>   /* re-enable the transmitter */
>   atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN);
> + atmel_port->tx_stopped = false;
>  }
>  
>  /*
> @@ -1866,6 +1874,7 @@ static int atmel_startup(struct uart_port *port)
>   atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX);
>   /* enable xmit & rcvr */
>   atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN);
> + atmel_port->tx_stopped = false;
>  
>   setup_timer(_port->uart_timer,
>   atmel_uart_timer_callback,
> @@ -2122,6 +2131,7 @@ static void atmel_set_termios(struct uart_port *port, 
> struct ktermios *termios,
>  
>   /* disable receiver and transmitter */
>   atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXDIS | ATMEL_US_RXDIS);
> + atmel_port->tx_stopped = true;
>  
>   /* mode */
>   if (port->rs485.flags & SER_RS485_ENABLED) {
> @@ -2207,6 +2217,7 @@ static void atmel_set_termios(struct uart_port *port, 
> struct ktermios *termios,
>   atmel_uart_writel(port, ATMEL_US_BRGR, quot);
>   atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX);
>   atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN);
> + atmel_port->tx_stopped = false;
>  
>   /* restore interrupts */
>   atmel_uart_writel(port, ATMEL_US_IER, imr);
> @@ -2450,6 +2461,7 @@ static void atmel_console_write(struct console *co, 
> const char *s, u_int count)
>  
>   /* Make sure that tx path is actually able to send characters */
>   atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN);
> + atmel_port->tx_stopped = false;
>  
>   uart_console_write(port, s, count, atmel_console_putchar);
>  
> @@ -2511,6 +2523,7 @@ static int __init atmel_console_setup(struct console 
> *co, char *options)
>  {
>   int ret;
>   struct uart_port *port = _ports[co->index].uart;
> + struct atmel_uart_port *atmel_port = to_atmel

Re: [PATCH v2 8/9] atmel_flexcom: Support backup mode

2017-09-19 Thread Nicolas Ferre
On 15/09/2017 at 16:04, Romain Izard wrote:
> The controller used by a flexcom module is configured at boot, and left
> alone after this. As the configuration will be lost after backup mode,
> restore the state of the flexcom driver on resume.
> 
> Signed-off-by: Romain Izard <romain.izard@gmail.com>

Tested-by: Nicolas Ferre <nicolas.fe...@microchip.com>
On sama5d2 Xplained board (i2c0 from flexcom 4).
and obviously:
Acked-by: Nicolas Ferre <nicolas.fe...@microchip.com>

Thanks Romain!

Regards,

> ---
>  drivers/mfd/atmel-flexcom.c | 65 
> ++---
>  1 file changed, 50 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/mfd/atmel-flexcom.c b/drivers/mfd/atmel-flexcom.c
> index 064bde9cff5a..ef1235c4a179 100644
> --- a/drivers/mfd/atmel-flexcom.c
> +++ b/drivers/mfd/atmel-flexcom.c
> @@ -39,34 +39,44 @@
>  #define FLEX_MR_OPMODE(opmode)   (((opmode) << FLEX_MR_OPMODE_OFFSET) &  
> \
>FLEX_MR_OPMODE_MASK)
>  
> +struct atmel_flexcom {
> + void __iomem *base;
> + u32 opmode;
> + struct clk *clk;
> +};
>  
>  static int atmel_flexcom_probe(struct platform_device *pdev)
>  {
>   struct device_node *np = pdev->dev.of_node;
> - struct clk *clk;
>   struct resource *res;
> - void __iomem *base;
> - u32 opmode;
> + struct atmel_flexcom *afc;
>   int err;
> + u32 val;
> +
> + afc = devm_kzalloc(>dev, sizeof(*afc), GFP_KERNEL);
> + if (!afc)
> + return -ENOMEM;
>  
> - err = of_property_read_u32(np, "atmel,flexcom-mode", );
> + platform_set_drvdata(pdev, afc);
> +
> + err = of_property_read_u32(np, "atmel,flexcom-mode", >opmode);
>   if (err)
>   return err;
>  
> - if (opmode < ATMEL_FLEXCOM_MODE_USART ||
> - opmode > ATMEL_FLEXCOM_MODE_TWI)
> + if (afc->opmode < ATMEL_FLEXCOM_MODE_USART ||
> + afc->opmode > ATMEL_FLEXCOM_MODE_TWI)
>   return -EINVAL;
>  
>   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - base = devm_ioremap_resource(>dev, res);
> - if (IS_ERR(base))
> - return PTR_ERR(base);
> + afc->base = devm_ioremap_resource(>dev, res);
> + if (IS_ERR(afc->base))
> + return PTR_ERR(afc->base);
>  
> - clk = devm_clk_get(>dev, NULL);
> - if (IS_ERR(clk))
> - return PTR_ERR(clk);
> + afc->clk = devm_clk_get(>dev, NULL);
> + if (IS_ERR(afc->clk))
> + return PTR_ERR(afc->clk);
>  
> - err = clk_prepare_enable(clk);
> + err = clk_prepare_enable(afc->clk);
>   if (err)
>   return err;
>  
> @@ -76,9 +86,10 @@ static int atmel_flexcom_probe(struct platform_device 
> *pdev)
>* inaccessible and are read as zero. Also the external I/O lines of the
>* Flexcom are muxed to reach the selected device.
>*/
> - writel(FLEX_MR_OPMODE(opmode), base + FLEX_MR);
> + val = FLEX_MR_OPMODE(afc->opmode);
> + writel(val, afc->base + FLEX_MR);
>  
> - clk_disable_unprepare(clk);
> + clk_disable_unprepare(afc->clk);
>  
>   return devm_of_platform_populate(>dev);
>  }
> @@ -89,10 +100,34 @@ static const struct of_device_id 
> atmel_flexcom_of_match[] = {
>  };
>  MODULE_DEVICE_TABLE(of, atmel_flexcom_of_match);
>  
> +#ifdef CONFIG_PM_SLEEP
> +static int atmel_flexcom_resume(struct device *dev)
> +{
> + struct atmel_flexcom *afc = dev_get_drvdata(dev);
> + int err;
> + u32 val;
> +
> + err = clk_prepare_enable(afc->clk);
> + if (err)
> + return err;
> +
> + val = FLEX_MR_OPMODE(afc->opmode),
> + writel(val, afc->base + FLEX_MR);
> +
> + clk_disable_unprepare(afc->clk);
> +
> + return 0;
> +}
> +#endif
> +
> +static SIMPLE_DEV_PM_OPS(atmel_flexcom_pm_ops, NULL,
> +  atmel_flexcom_resume);
> +
>  static struct platform_driver atmel_flexcom_driver = {
>   .probe  = atmel_flexcom_probe,
>   .driver = {
>   .name   = "atmel_flexcom",
> + .pm = _flexcom_pm_ops,
>   .of_match_table = atmel_flexcom_of_match,
>   },
>  };
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v1 03/10] clk: at91: pmc: Support backup for programmable clocks

2017-09-14 Thread Nicolas Ferre
On 14/09/2017 at 09:41, romain izard wrote:
> 2017-09-13 19:03 GMT+02:00 Alexandre Belloni
> <alexandre.bell...@free-electrons.com>:
>> On 13/09/2017 at 14:29:35 +0200, Nicolas Ferre wrote:
>>> On 08/09/2017 at 17:35, Romain Izard wrote:
>>>> From: Romain Izard <romain.iz...@mobile-devices.fr>
>>>>
>>>> Save and restore the System Clock and Programmable Clock register for
>>>> the backup use case.
>>>
>>> "System Clock" seems to be handled in another patch.
>>>
>>>> Signed-off-by: Romain Izard <romain.izard@gmail.com>
>>>> ---
>>>>  drivers/clk/at91/pmc.c | 5 +
>>>>  1 file changed, 5 insertions(+)
>>>>
>>>> diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
>>>> index 07dc2861ad3f..5421b03553ec 100644
>>>> --- a/drivers/clk/at91/pmc.c
>>>> +++ b/drivers/clk/at91/pmc.c
>>>> @@ -66,6 +66,7 @@ static struct
>>>> u32 pcr[PMC_MAX_IDS];
>>>> u32 audio_pll0;
>>>> u32 audio_pll1;
>>>> +   u32 pckr[3];
>>>
>>> Some products have different numbers of PCK (only 2 on at91sam9x5 for
>>> instance)...
>>>
>>
>> My opinion is that it will be time to change that when multiple SoCs will
>> need to save their registers.
>>
> For the next version, I'll add a #define. But as this code requires a
> device tree node with the compatible string "atmel,sama5d2-pmc", I believe
> that we can ignore other chips for now.

Fair enough, let's go for this.

Bye,
-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v1 03/10] clk: at91: pmc: Support backup for programmable clocks

2017-09-13 Thread Nicolas Ferre
On 08/09/2017 at 17:35, Romain Izard wrote:
> From: Romain Izard <romain.iz...@mobile-devices.fr>
> 
> Save and restore the System Clock and Programmable Clock register for
> the backup use case.

"System Clock" seems to be handled in another patch.

> Signed-off-by: Romain Izard <romain.izard@gmail.com>
> ---
>  drivers/clk/at91/pmc.c | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
> index 07dc2861ad3f..5421b03553ec 100644
> --- a/drivers/clk/at91/pmc.c
> +++ b/drivers/clk/at91/pmc.c
> @@ -66,6 +66,7 @@ static struct
>   u32 pcr[PMC_MAX_IDS];
>   u32 audio_pll0;
>   u32 audio_pll1;
> + u32 pckr[3];

Some products have different numbers of PCK (only 2 on at91sam9x5 for
instance)...

>  } pmc_cache;
>  
>  void pmc_register_id(u8 id)
> @@ -103,6 +104,8 @@ static int pmc_suspend(void)
>   regmap_read(pmcreg, AT91_PMC_PCR,
>   _cache.pcr[registered_ids[i]]);
>   }
> + for (i = 0; i < 3; i++)

And it might be a good practice to have this constant value in a #define.
We have "#define PROG_ID_MAX  7" defined in
drivers/clk/at91/clk-programmable.c.

Regards,


> + regmap_read(pmcreg, AT91_PMC_PCKR(i), _cache.pckr[i]);
>  
>   return 0;
>  }
> @@ -143,6 +146,8 @@ static void pmc_resume(void)
>pmc_cache.pcr[registered_ids[i]] |
>AT91_PMC_PCR_CMD);
>   }
> + for (i = 0; i < 3; i++)
> + regmap_write(pmcreg, AT91_PMC_PCKR(i), pmc_cache.pckr[i]);
>  
>   if (pmc_cache.uckr & AT91_PMC_UPLLEN)
>   mask |= AT91_PMC_LOCKU;
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v1 01/10] clk: at91: pmc: Wait for clocks when resuming

2017-09-13 Thread Nicolas Ferre
On 08/09/2017 at 17:35, Romain Izard wrote:
> Wait for the syncronization of all clocks when resuming, not only the
> UPLL clock. Do not use regmap_read_poll_timeout, as it will call BUG()
> when interrupts are masked, which is the case in here.
> 
> Signed-off-by: Romain Izard <romain.izard@gmail.com>
> ---
>  drivers/clk/at91/pmc.c | 24 
>  1 file changed, 16 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
> index 775af473fe11..5c2b26de303e 100644
> --- a/drivers/clk/at91/pmc.c
> +++ b/drivers/clk/at91/pmc.c
> @@ -107,10 +107,20 @@ static int pmc_suspend(void)
>   return 0;
>  }
>  
> +static bool pmc_ready(unsigned int mask)
> +{
> + unsigned int status;
> +
> + regmap_read(pmcreg, AT91_PMC_SR, );
> +
> + return ((status & mask) == mask) ? 1 : 0;
> +}
> +
>  static void pmc_resume(void)
>  {
> - int i, ret = 0;
> + int i;
>   u32 tmp;
> + u32 mask = AT91_PMC_MCKRDY | AT91_PMC_LOCKA;
>  
>   regmap_read(pmcreg, AT91_PMC_MCKR, );
>   if (pmc_cache.mckr != tmp)
> @@ -134,13 +144,11 @@ static void pmc_resume(void)
>AT91_PMC_PCR_CMD);
>   }
>  
> - if (pmc_cache.uckr & AT91_PMC_UPLLEN) {
> - ret = regmap_read_poll_timeout(pmcreg, AT91_PMC_SR, tmp,
> -!(tmp & AT91_PMC_LOCKU),
> -10, 5000);
> - if (ret)
> - pr_crit("USB PLL didn't lock when resuming\n");
> - }
> + if (pmc_cache.uckr & AT91_PMC_UPLLEN)
> + mask |= AT91_PMC_LOCKU;
> +
> + while (!pmc_ready(mask))
> + cpu_relax();

Okay, but I would prefer to keep the timeout property in it. So we may
need to re-implement a timeout way-out here.

Regards,

>  }
>  
>  static struct syscore_ops pmc_syscore_ops = {
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v1 02/10] clk: at91: pmc: Save SCSR during suspend

2017-09-13 Thread Nicolas Ferre
On 08/09/2017 at 17:35, Romain Izard wrote:
> The contents of the System Clock Status Register (SCSR) needs to be
> restored into the System Clock Enable Register (SCER).
> 
> As the bootloader will restore some clocks by itself, the issue can be
> missed as only the USB controller, the LCD controller, the Image Sensor
> controller and the programmable clocks will be impacted.
> 
> Fix the obvious typo in the suspend/resume code, as the IMR register
> does not need to be saved twice.
> 
> Signed-off-by: Romain Izard <romain.izard@gmail.com>

Yes, it looks like a typo:
Acked-by: Nicolas Ferre <nicolas.fe...@microchip.com>

I didn't experienced the issue with LCD nor USB though.

Regards,

> ---
>  drivers/clk/at91/pmc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
> index 5c2b26de303e..07dc2861ad3f 100644
> --- a/drivers/clk/at91/pmc.c
> +++ b/drivers/clk/at91/pmc.c
> @@ -86,7 +86,7 @@ static int pmc_suspend(void)
>  {
>   int i;
>  
> - regmap_read(pmcreg, AT91_PMC_IMR, _cache.scsr);
> + regmap_read(pmcreg, AT91_PMC_SCSR, _cache.scsr);
>   regmap_read(pmcreg, AT91_PMC_PCSR, _cache.pcsr0);
>   regmap_read(pmcreg, AT91_CKGR_UCKR, _cache.uckr);
>   regmap_read(pmcreg, AT91_CKGR_MOR, _cache.mor);
> @@ -129,7 +129,7 @@ static void pmc_resume(void)
>   if (pmc_cache.pllar != tmp)
>   pr_warn("PLLAR was not configured properly by the firmware\n");
>  
> - regmap_write(pmcreg, AT91_PMC_IMR, pmc_cache.scsr);
> + regmap_write(pmcreg, AT91_PMC_SCER, pmc_cache.scsr);
>   regmap_write(pmcreg, AT91_PMC_PCER, pmc_cache.pcsr0);
>   regmap_write(pmcreg, AT91_CKGR_UCKR, pmc_cache.uckr);
>   regmap_write(pmcreg, AT91_CKGR_MOR, pmc_cache.mor);
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v1 07/10] iio:adc:at91-sama5d2: Support backup mode

2017-09-08 Thread Nicolas Ferre
gt; + if (err)
> + return err;
> +
> + at91_adc_init_hw(st, st->current_rate);
> +
> + err = clk_prepare_enable(st->per_clk);
> + return err;
> +}
> +#endif
> +
> +static SIMPLE_DEV_PM_OPS(at91_adc_pm_ops, at91_adc_suspend, at91_adc_resume);
> +
>  static struct platform_driver at91_adc_driver = {
>   .probe = at91_adc_probe,
>   .remove = at91_adc_remove,
>   .driver = {
>   .name = "at91-sama5d2_adc",
>   .of_match_table = at91_adc_dt_match,
> + .pm = _adc_pm_ops,
>   },
>  };
>  module_platform_driver(at91_adc_driver)
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RESEND new email address] usb: gadget: udc: atmel: set vbus irqflags explicitly

2017-08-31 Thread Nicolas Ferre
The driver triggers actions on both edges of the vbus signal.

The former PIO controller was triggering IRQs on both falling and rising edges
by default. Newer PIO controller don't, so it's better to set it explicitly to
IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING.

Without this patch we may trigger the connection with host but only on some
bouncing signal conditions and thus lose connecting events.

Signed-off-by: Nicolas Ferre <nicolas.fe...@microchip.com>
Cc: stable <sta...@vger.kernel.org> # v4.4+
---
 drivers/usb/gadget/udc/atmel_usba_udc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
b/drivers/usb/gadget/udc/atmel_usba_udc.c
index 98d71400f8a1..a884c022df7a 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -29,6 +29,8 @@
 #include 
 
 #include "atmel_usba_udc.h"
+#define USBA_VBUS_IRQFLAGS (IRQF_ONESHOT \
+  | IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING)
 
 #ifdef CONFIG_USB_GADGET_DEBUG_FS
 #include 
@@ -2361,7 +2363,7 @@ static int usba_udc_probe(struct platform_device *pdev)
IRQ_NOAUTOEN);
ret = devm_request_threaded_irq(>dev,
gpio_to_irq(udc->vbus_pin), NULL,
-   usba_vbus_irq_thread, IRQF_ONESHOT,
+   usba_vbus_irq_thread, 
USBA_VBUS_IRQFLAGS,
"atmel_usba_udc", udc);
if (ret) {
udc->vbus_pin = -ENODEV;
-- 
2.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: gadget: udc: atmel: set vbus irqflags explicitly

2017-08-31 Thread Nicolas Ferre
From: Nicolas Ferre <nicolas.fe...@atmel.com>

The driver triggers actions on both edges of the vbus signal.

The former PIO controller was triggering IRQs on both falling and rising edges
by default. Newer PIO controller don't, so it's better to set it explicitly to
IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING.

Without this patch we may trigger the connection with host but only on some
bouncing signal conditions and thus lose connecting events.

Signed-off-by: Nicolas Ferre <nicolas.fe...@atmel.com>
Cc: stable <sta...@vger.kernel.org> # v4.4+
---
 drivers/usb/gadget/udc/atmel_usba_udc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
b/drivers/usb/gadget/udc/atmel_usba_udc.c
index 98d71400f8a1..a884c022df7a 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -29,6 +29,8 @@
 #include 
 
 #include "atmel_usba_udc.h"
+#define USBA_VBUS_IRQFLAGS (IRQF_ONESHOT \
+  | IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING)
 
 #ifdef CONFIG_USB_GADGET_DEBUG_FS
 #include 
@@ -2361,7 +2363,7 @@ static int usba_udc_probe(struct platform_device *pdev)
IRQ_NOAUTOEN);
ret = devm_request_threaded_irq(>dev,
gpio_to_irq(udc->vbus_pin), NULL,
-   usba_vbus_irq_thread, IRQF_ONESHOT,
+   usba_vbus_irq_thread, 
USBA_VBUS_IRQFLAGS,
"atmel_usba_udc", udc);
if (ret) {
udc->vbus_pin = -ENODEV;
-- 
2.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH linux-next v2 0/4] usb: gadget: udc: atmel: Endpoint allocation scheme fixes

2017-03-29 Thread Nicolas Ferre
Le 28/03/2017 à 18:07, cristian.bir...@microchip.com a écrit :
> From: Cristian Birsan <cristian.bir...@microchip.com>
> 
> This patch series provides fixes, based on the feedback received on the 
> mailing list, for
> the following:
>   - fifo table parameters validation against device tree values
>   - coding style
>   - message display for EP configuration error
>   - Kconfig comments for fifo_mode=0
> 
> Changes since v1:
>   - Removed static for usba_config_fifo_table() function from "Check fifo
>   configuration values against device tree" patch

As for previous revision, the whole series:
Acked-by: Nicolas Ferre <nicolas.fe...@microchip.com>

Regards,

> Cristian Birsan (4):
>   usb: gadget: udc: atmel: Check fifo configuration values against
> device tree
>   usb: gadget: udc: atmel: Minor code cleanup
>   usb: gadget: udc: atmel: Use dev_warn() to display EP configuration
> error
>   usb: gadget: udc: atmel: Update Kconfig help for fifo_mode = 0
> 
>  drivers/usb/gadget/udc/Kconfig  |  5 ++--
>  drivers/usb/gadget/udc/atmel_usba_udc.c | 47 
> ++++++++++---
>  2 files changed, 35 insertions(+), 17 deletions(-)
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: ohci-at91: Do not drop unhandled USB suspend control requests

2017-02-21 Thread Nicolas Ferre
Le 21/02/2017 à 12:48, Jelle Martijn Kok a écrit :
> In patch 2e2aa1bc7eff90ecm, USB suspend and wakeup control requests are
> passed to SFR_OHCIICR register. If a processor does not have such a
> register, this hub control request will be dropped.
> 
> If no such a SFR register is available, all USB suspend control requests
> will now be processed using ohci_hub_control()
> (like before patch 2e2aa1bc7eff90ecm.)
> 
> Tested on an Atmel AT91SAM9G20 with an on-board TI TUSB2046B hub chip
> If the last USB device is unplugged from the USB hub, the hub goes into
> sleep and will not wakeup when an USB devices is inserted.
> 
> Fixes: 2e2aa1bc7eff90ec ("usb: ohci-at91: Forcibly suspend ports while USB 
> suspend")
> Signed-off-by: Jelle Martijn Kok <jm...@youcom.nl>
> Tested-by: Wenyou Yang <wenyou.y...@atmel.com>
> Cc: Wenyou Yang <wenyou.y...@atmel.com>
> Cc: Alexandre Belloni <alexandre.bell...@free-electrons.com>
> Cc: Nicolas Ferre <nicolas.fe...@atmel.com>

Acked-by: Nicolas Ferre <nicolas.fe...@microchip.com>

Thanks

> Cc: Alan Stern <st...@rowland.harvard.edu>
> ---
>  drivers/usb/host/ohci-at91.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
> index b38a228..af0566d 100644
> --- a/drivers/usb/host/ohci-at91.c
> +++ b/drivers/usb/host/ohci-at91.c
> @@ -361,7 +361,7 @@ static int ohci_at91_hub_control(struct usb_hcd *hcd, u16 
> typeReq, u16 wValue,
>  
>   case USB_PORT_FEAT_SUSPEND:
>   dev_dbg(hcd->self.controller, "SetPortFeat: SUSPEND\n");
> - if (valid_port(wIndex)) {
> + if (valid_port(wIndex) && ohci_at91->sfr_regmap) {
>   ohci_at91_port_suspend(ohci_at91->sfr_regmap,
>  1);
>   return 0;
> @@ -404,7 +404,7 @@ static int ohci_at91_hub_control(struct usb_hcd *hcd, u16 
> typeReq, u16 wValue,
>  
>   case USB_PORT_FEAT_SUSPEND:
>   dev_dbg(hcd->self.controller, "ClearPortFeature: 
> SUSPEND\n");
> - if (valid_port(wIndex)) {
> + if (valid_port(wIndex) && ohci_at91->sfr_regmap) {
>   ohci_at91_port_suspend(ohci_at91->sfr_regmap,
>  0);
>   return 0;
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/4 linux-next] usb: gadget: udc: atmel: Endpoint allocation scheme fixes

2017-02-15 Thread Nicolas Ferre
Le 14/02/2017 à 17:09, cristian.bir...@microchip.com a écrit :
> From: Cristian Birsan <cristian.bir...@microchip.com>
> 
> This patch series provides fixes, based on the feedback received on the 
> mailing list, for
> the following:
>   - fifo table parameters validation against device tree values
>   - coding style
>   - message display for EP configuration error
>   - Kconfig comments for fifo_mode=0
> 
> Cristian Birsan (4):
>   usb: gadget: udc: atmel: Check fifo configuration values against
> device tree
>   usb: gadget: udc: atmel: Minor code cleanup
>   usb: gadget: udc: atmel: Use dev_warn() to display EP configuration
> error
>   usb: gadget: udc: atmel: Update Kconfig help for fifo_mode = 0
> 
>  drivers/usb/gadget/udc/Kconfig  |  5 ++--
>  drivers/usb/gadget/udc/atmel_usba_udc.c | 47 
> ++---
>  2 files changed, 35 insertions(+), 17 deletions(-)

I'm okay with the whole series:
Acked-by: Nicolas Ferre <nicolas.fe...@microchip.com>

Thanks, regards,
-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: gadget: udc: atmel: fix debug output

2017-02-01 Thread Nicolas Ferre
Le 01/02/2017 à 18:00, Alexandre Belloni a écrit :
> On 01/02/2017 at 17:41:55 +0100, Arnd Bergmann wrote:
>> The debug output now contains the wrong variable, as seen from the compiler
>> warning:
>>
>> drivers/usb/gadget/udc/atmel_usba_udc.c: In function 'usba_ep_enable':
>> drivers/usb/gadget/udc/atmel_usba_udc.c:632:550: error: 'ept_cfg' may be 
>> used uninitialized in this function [-Werror=maybe-uninitialized]
>>   DBG(DBG_ERR, "%s: EPT_CFG = 0x%lx (maxpacket = %lu)\n",
>>
>> This changes the debug output the same way as the other code.
>>
>> Fixes: 741d2558bf0a ("usb: gadget: udc: atmel: Update endpoint allocation 
>> scheme")
>> Signed-off-by: Arnd Bergmann <a...@arndb.de>
> Acked-by: Alexandre Belloni <alexandre.bell...@free-electrons.com>

Acked-by: Nicolas Ferre <nicolas.fe...@microchip.com>

> 
>> ---
>>  drivers/usb/gadget/udc/atmel_usba_udc.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
>> b/drivers/usb/gadget/udc/atmel_usba_udc.c
>> index 11bbce28bc23..2035906b8ced 100644
>> --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
>> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
>> @@ -610,7 +610,7 @@ usba_ep_enable(struct usb_ep *_ep, const struct 
>> usb_endpoint_descriptor *desc)
>>  {
>>  struct usba_ep *ep = to_usba_ep(_ep);
>>  struct usba_udc *udc = ep->udc;
>> -unsigned long flags, ept_cfg, maxpacket;
>> +unsigned long flags, maxpacket;
>>  unsigned int nr_trans;
>>  
>>  DBG(DBG_GADGET, "%s: ep_enable: desc=%p\n", ep->ep.name, desc);
>> @@ -630,7 +630,7 @@ usba_ep_enable(struct usb_ep *_ep, const struct 
>> usb_endpoint_descriptor *desc)
>>  ep->is_in = 0;
>>  
>>  DBG(DBG_ERR, "%s: EPT_CFG = 0x%lx (maxpacket = %lu)\n",
>> -ep->ep.name, ept_cfg, maxpacket);
>> +ep->ep.name, ep->ept_cfg, maxpacket);
>>  
>>  if (usb_endpoint_dir_in(desc)) {
>>  ep->is_in = 1;
>> -- 
>> 2.9.0
>>
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4.10-rc3 03/13] net: macb: fix build errors when linux/phy*.h is removed from net/dsa.h

2017-02-01 Thread Nicolas Ferre
Le 31/01/2017 à 20:18, Russell King a écrit :
> drivers/net/ethernet/cadence/macb.h:862:33: sparse: expected ; at end of 
> declaration
> drivers/net/ethernet/cadence/macb.h:862:33: sparse: Expected } at end of 
> struct-union-enum-specifier
> drivers/net/ethernet/cadence/macb.h:862:33: sparse: got phy_interface
> drivers/net/ethernet/cadence/macb.h:877:1: sparse: Expected ; at the end of 
> type declaration
> drivers/net/ethernet/cadence/macb.h:877:1: sparse: got }
> In file included from drivers/net/ethernet/cadence/macb_pci.c:29:0:
> drivers/net/ethernet/cadence/macb.h:862:2: error: unknown type name 
> 'phy_interface_t'
>  phy_interface_t  phy_interface;
>  ^~~
> 
> Add linux/phy.h to macb.h
> 
> Signed-off-by: Russell King <rmk+ker...@armlinux.org.uk>

Acked-by: Nicolas Ferre <nicolas.fe...@atmel.com>

> ---
>  drivers/net/ethernet/cadence/macb.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/net/ethernet/cadence/macb.h 
> b/drivers/net/ethernet/cadence/macb.h
> index d67adad67be1..383da8cf5f6d 100644
> --- a/drivers/net/ethernet/cadence/macb.h
> +++ b/drivers/net/ethernet/cadence/macb.h
> @@ -10,6 +10,8 @@
>  #ifndef _MACB_H
>  #define _MACB_H
>  
> +#include 
> +
>  #define MACB_GREGS_NBR 16
>  #define MACB_GREGS_VERSION 2
>  #define MACB_MAX_QUEUES 8
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH linux-next v2 1/1] usb: gadget: udc: atmel: Update endpoint allocation scheme

2017-01-27 Thread Nicolas Ferre
Le 27/01/2017 à 14:47, Cristian Birsan a écrit :
> I will send a fixup patch with updates based on the comments received from 
> Nicolas.
> 
> On 01/26/2017 05:02 PM, Nicolas Ferre wrote:
>> Le 23/01/2017 à 15:45, cristian.bir...@microchip.com a écrit :
>>> From: Cristian Birsan <cristian.bir...@microchip.com>
>>>
>>> Update atmel udc driver with a new enpoint allocation scheme. The data
>>> sheet requires that all endpoints are allocated in order.
>>
>> Pieces of information from the cover letter could have been added here.
>>
> 
> Ack. I'll remove the cover letter.
> 
>>> Signed-off-by: Cristian Birsan <cristian.bir...@microchip.com>
>>> ---
>>>  drivers/usb/gadget/udc/Kconfig  |  14 ++
>>>  drivers/usb/gadget/udc/atmel_usba_udc.c | 236 
>>> +++-
>>>  drivers/usb/gadget/udc/atmel_usba_udc.h |  10 +-
>>>  3 files changed, 227 insertions(+), 33 deletions(-)
>>
>> It can be good to run ./scripts/checkpatch.pl --strict as well. It would
>> have told you about some of the alignment and braces issues. I ran it as
>> some the code has looked weird to me once or twice...
>>
>>
> 
> Ack.
> 
>>> diff --git a/drivers/usb/gadget/udc/Kconfig b/drivers/usb/gadget/udc/Kconfig
>>> index 658b8da..4b69f28 100644
>>> --- a/drivers/usb/gadget/udc/Kconfig
>>> +++ b/drivers/usb/gadget/udc/Kconfig
>>> @@ -60,6 +60,20 @@ config USB_ATMEL_USBA
>>>   USBA is the integrated high-speed USB Device controller on
>>>   the AT32AP700x, some AT91SAM9 and AT91CAP9 processors from Atmel.
>>>  
>>> + The fifo_mode parameter is used to select endpoint allocation mode.
>>> + fifo_mode = 0 is used to let the driver autoconfigure the endpoints.
>>> + In this case 2 banks are allocated for isochronous endpoints and
>>
>> You mean that 2 banks can do isochronous xfers if needed, but they can
>> do other types as well, right? So maybe rephrase the sentence.
>>
> 
> For fifo_mode = 0 (autoconfigure case) the driver allocates 2 banks only for
> isochronous endpoints as required by the reference manual. For other endpoints
> it will allocate only 1 bank because it cannot know in advance the number of
> endpoints and the size of them, especially if the configfs is used to create
> the gadget. The idea is to support as many endpoints as we can in this mode.

You know that I know this. It was just a remark about the wording of
your sentence. "are allocated for isochronous" can be turned into "are
allocated so that they could be use as isochronous endpoints". Not a big
deal though.


>>> + only one bank is allocated for the rest of the endpoints.
>>> +
>>> + fifo_mode = 1 is a generic maximum fifo size (1024 bytes) 
>>> configuration
>>> + allowing the usage of ep1 - ep6
>>> +
>>> + fifo_mode = 2 is a generic performance maximum fifo size (1024 bytes)
>>> + configuration allowing the usage of ep1 - ep3
>>> +
>>> + fifo_mode = 3 is a balanced performance configuration allowing the
>>> + the usage of ep1 - ep8
>>> +
>>>  config USB_BCM63XX_UDC
>>> tristate "Broadcom BCM63xx Peripheral Controller"
>>> depends on BCM63XX
>>> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
>>> b/drivers/usb/gadget/udc/atmel_usba_udc.c
>>> index 12c7687..11bbce2 100644
>>> --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
>>> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
>>> @@ -20,6 +20,7 @@
>>>  #include 
>>>  #include 
>>>  #include 
>>> +#include 
>>>  #include 
>>>  #include 
>>>  #include 
>>> @@ -318,6 +319,91 @@ static inline void usba_cleanup_debugfs(struct 
>>> usba_udc *udc)
>>>  }
>>>  #endif
>>>  
>>> +static ushort fifo_mode;
>>> +
>>> +/* "modprobe ... fifo_mode=1" etc */
>>
>> No need for this comment.
>>
>  
> Ack. I'll remove it.
> 
>>> +module_param(fifo_mode, ushort, 0x0);
>>> +MODULE_PARM_DESC(fifo_mode, "Endpoint configuration mode");
>>> +
>>> +/* mode 0 - uses autoconfig */
>>> +
>>> +/* mode 1 - fits in 8KB, generic max fifo configuration */
>>> +static struct usba_fifo_cfg mode_1_cfg[] = {
>>> +{ .hw_ep_num = 0, .fifo_size = 64, .nr_banks = 1, },
>>> +{ .hw_ep_num = 1, .fifo_size = 1024,   .nr_banks = 2, },
>>> +{ .hw_ep_num = 2, .fifo

Re: [PATCH linux-next v2 1/1] usb: gadget: udc: atmel: Update endpoint allocation scheme

2017-01-26 Thread Nicolas Ferre
;driver = NULL;
> @@ -1931,9 +2084,13 @@ static struct usba_ep * atmel_udc_of_init(struct 
> platform_device *pdev,
>   );
>   udc->vbus_pin_inverted = (flags & OF_GPIO_ACTIVE_LOW) ? 1 : 0;
>  
> - pp = NULL;
> - while ((pp = of_get_next_child(np, pp)))
> - udc->num_ep++;
> + if (fifo_mode == 0) {
> + pp = NULL;
> + while ((pp = of_get_next_child(np, pp)))
> + udc->num_ep++;
> + udc->configured_ep = 1;
> + } else

Braces here

> + udc->num_ep = usba_config_fifo_table(udc);
>  
>   eps = devm_kzalloc(>dev, sizeof(struct usba_ep) * udc->num_ep,
>  GFP_KERNEL);
> @@ -1946,7 +2103,7 @@ static struct usba_ep * atmel_udc_of_init(struct 
> platform_device *pdev,
>  
>   pp = NULL;
>   i = 0;
> - while ((pp = of_get_next_child(np, pp))) {
> + while ((pp = of_get_next_child(np, pp)) && i < udc->num_ep) {
>   ep = [i];
>  
>   ret = of_property_read_u32(pp, "reg", );
> @@ -1954,21 +2111,21 @@ static struct usba_ep * atmel_udc_of_init(struct 
> platform_device *pdev,
>   dev_err(>dev, "of_probe: reg error(%d)\n", ret);
>   goto err;
>   }
> - ep->index = val;
> + ep->index = fifo_mode ? udc->fifo_cfg[i].hw_ep_num : val;
>  
>   ret = of_property_read_u32(pp, "atmel,fifo-size", );
>   if (ret) {
>   dev_err(>dev, "of_probe: fifo-size error(%d)\n", 
> ret);
>   goto err;
>   }
> - ep->fifo_size = val;
> + ep->fifo_size = fifo_mode ? udc->fifo_cfg[i].fifo_size : val;

No, this is where I would like to see that the value from the table is
still validated agains the "max value" that is stored in HW description/DT.
I know that all of our product are able to handle 1024 fifo size, but
it's more a savfe check...

>  
>   ret = of_property_read_u32(pp, "atmel,nb-banks", );
>   if (ret) {
>   dev_err(>dev, "of_probe: nb-banks error(%d)\n", 
> ret);
>   goto err;
>   }
> - ep->nr_banks = val;
> + ep->nr_banks = fifo_mode ? udc->fifo_cfg[i].nr_banks : val;

Here however, it is pretty important to check this value. For instance,
notice that the at91sam9x5 cannot fullfil the "mode 2" configuration: we
can't silentely ignore the HW specifications given by DT.

>   ep->can_dma = of_property_read_bool(pp, "atmel,can-dma");
>   ep->can_isoc = of_property_read_bool(pp, "atmel,can-isoc");
> @@ -2000,6 +2157,21 @@ static struct usba_ep * atmel_udc_of_init(struct 
> platform_device *pdev,
>   ep->ep.caps.dir_in = true;
>   ep->ep.caps.dir_out = true;
>  
> + if (fifo_mode != 0) {
> + /*
> +  * Generate ept_cfg based on FIFO size and
> +  * banks number
> +  */
> + if (ep->fifo_size  <= 8)
> + ep->ept_cfg = USBA_BF(EPT_SIZE, 
> USBA_EPT_SIZE_8);
> + else
> +     /* LSB is bit 1, not 0 */
> + ep->ept_cfg =
> +   USBA_BF(EPT_SIZE, fls(ep->fifo_size - 1) - 3);
> +
> + ep->ept_cfg |= USBA_BF(BK_NUMBER, ep->nr_banks);
> + }
> +
>   if (i)
>   list_add_tail(>ep.ep_list, >gadget.ep_list);
>  
> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.h 
> b/drivers/usb/gadget/udc/atmel_usba_udc.h
> index b03b2eb..9551b70 100644
> --- a/drivers/usb/gadget/udc/atmel_usba_udc.h
> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.h
> @@ -275,6 +275,12 @@ struct usba_dma_desc {
>   u32 ctrl;
>  };
>  
> +struct usba_fifo_cfg {
> + u8  hw_ep_num;
> + u16 fifo_size;
> + u8  nr_banks;
> +};
> +
>  struct usba_ep {
>   int state;
>   void __iomem*ep_regs;
> @@ -293,7 +299,7 @@ struct usba_ep {
>   unsigned intcan_isoc:1;
>   unsigned intis_isoc:1;
>   unsigned intis_in:1;
> -
> + unsigned long   ept_cfg;
>  #ifdef CONFIG_USB_GADGET_DEBUG_FS
>   u32 last_dma_status;
>   struct dentry   *debugfs_dir;
> @@ -338,6 +344,8 @@ struct usba_udc {
>   int vbus_pin;
>   int vbus_pin_inverted;
>   int num_ep;
> + int configured_ep;
> + struct usba_fifo_cfg *fifo_cfg;
>   struct clk *pclk;
>   struct clk *hclk;
>   struct usba_ep *usba_ep;
> 

Regards,
-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: gadget: udc: atmel: used managed kasprintf

2016-12-01 Thread Nicolas Ferre
Le 01/12/2016 à 11:26, Alexandre Belloni a écrit :
> Use devm_kasprintf instead of simple kasprintf to free the allocated memory
> when needed.
> 
> Suggested-by: Peter Rosin <p...@axentia.se>
> Signed-off-by: Alexandre Belloni <alexandre.bell...@free-electrons.com>

Acked-by: Nicolas Ferre <nicolas.fe...@atmel.com>

> ---
>  drivers/usb/gadget/udc/atmel_usba_udc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
> b/drivers/usb/gadget/udc/atmel_usba_udc.c
> index 45bc997d0711..aec72fe8273c 100644
> --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
> @@ -1978,7 +1978,8 @@ static struct usba_ep * atmel_udc_of_init(struct 
> platform_device *pdev,
>   dev_err(>dev, "of_probe: name error(%d)\n", ret);
>   goto err;
>   }
> - ep->ep.name = kasprintf(GFP_KERNEL, "ep%d", ep->index);
> + ep->ep.name = devm_kasprintf(>dev, GFP_KERNEL, "ep%d",
> +  ep->index);
>  
>   ep->ep_regs = udc->regs + USBA_EPT_BASE(i);
>   ep->dma_regs = udc->regs + USBA_DMA_BASE(i);
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 36/82] usb: gadget: udc: atmel: remove unnecessary & operation

2016-11-03 Thread Nicolas Ferre
Le 31/10/2016 à 11:48, Felipe Balbi a écrit :
> Now that usb_endpoint_maxp() only returns the lowest
> 11 bits from wMaxPacketSize, we can remove the &
> operation from this driver.
> 
> Cc: Nicolas Ferre <nicolas.fe...@atmel.com>

Acked-by: Nicolas Ferre <nicolas.fe...@atmel.com>

> Cc: <linux-usb@vger.kernel.org>
> Signed-off-by: Felipe Balbi <felipe.ba...@linux.intel.com>
> ---
>  drivers/usb/gadget/udc/atmel_usba_udc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
> b/drivers/usb/gadget/udc/atmel_usba_udc.c
> index c57012b1ddf4..125680db9379 100644
> --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
> @@ -529,7 +529,7 @@ usba_ep_enable(struct usb_ep *_ep, const struct 
> usb_endpoint_descriptor *desc)
>  
>   DBG(DBG_GADGET, "%s: ep_enable: desc=%p\n", ep->ep.name, desc);
>  
> - maxpacket = usb_endpoint_maxp(desc) & 0x7ff;
> + maxpacket = usb_endpoint_maxp(desc);
>  
>   if (((desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK) != ep->index)
>   || ep->index == 0
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 17/82] usb: gadget: udc: atmel: make use of new usb_endpoint_maxp_mult()

2016-11-03 Thread Nicolas Ferre
Le 31/10/2016 à 11:48, Felipe Balbi a écrit :
> We have introduced a helper to calculate multiplier
> value from wMaxPacketSize. Start using it.
> 
> Cc: Nicolas Ferre <nicolas.fe...@atmel.com>
Acked-by: Nicolas Ferre <nicolas.fe...@atmel.com>

> Cc: <linux-usb@vger.kernel.org>
> Signed-off-by: Felipe Balbi <felipe.ba...@linux.intel.com>
> ---
>  drivers/usb/gadget/udc/atmel_usba_udc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
> b/drivers/usb/gadget/udc/atmel_usba_udc.c
> index 45bc997d0711..c57012b1ddf4 100644
> --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
> @@ -573,7 +573,7 @@ usba_ep_enable(struct usb_ep *_ep, const struct 
> usb_endpoint_descriptor *desc)
>* Bits 11:12 specify number of _additional_
>* transactions per microframe.
>*/
> - nr_trans = ((usb_endpoint_maxp(desc) >> 11) & 3) + 1;
> + nr_trans = usb_endpoint_maxp_mult(desc);
>   if (nr_trans > 3)
>   return -EINVAL;
>  
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: gadget: udc: atmel: fix endpoint name

2016-10-24 Thread Nicolas Ferre
Le 26/09/2016 à 09:18, Felipe Balbi a écrit :
> 
> Hi,
> 
> Greg Kroah-Hartman <gre...@linuxfoundation.org> writes:
>> On Fri, Sep 23, 2016 at 04:20:45PM +0200, Nicolas Ferre wrote:
>>> Le 16/09/2016 à 10:36, Nicolas Ferre a écrit :
>>>> Le 15/09/2016 à 17:07, Alexandre Belloni a écrit :
>>>>> Since commit c32b5bcfa3c4 ("ARM: dts: at91: Fix USB endpoint nodes"),
>>>>> atmel_usba_udc fails with:
>>>>>
>>>>> [ cut here ]
>>>>> WARNING: CPU: 0 PID: 0 at include/linux/usb/gadget.h:405
>>>>> ecm_do_notify+0x188/0x1a0
>>>>> Modules linked in:
>>>>> CPU: 0 PID: 0 Comm: swapper Not tainted 4.7.0+ #15
>>>>> Hardware name: Atmel SAMA5
>>>>> [] (unwind_backtrace) from [] (show_stack+0x10/0x14)
>>>>> [] (show_stack) from [] (__warn+0xe4/0xfc)
>>>>> [] (__warn) from [] (warn_slowpath_null+0x20/0x28)
>>>>> [] (warn_slowpath_null) from [] 
>>>>> (ecm_do_notify+0x188/0x1a0)
>>>>> [] (ecm_do_notify) from [] (ecm_set_alt+0x74/0x1ac)
>>>>> [] (ecm_set_alt) from [] 
>>>>> (composite_setup+0xfc0/0x19f8)
>>>>> [] (composite_setup) from [] 
>>>>> (usba_udc_irq+0x8f4/0xd9c)
>>>>> [] (usba_udc_irq) from [] 
>>>>> (handle_irq_event_percpu+0x9c/0x158)
>>>>> [] (handle_irq_event_percpu) from [] 
>>>>> (handle_irq_event+0x28/0x3c)
>>>>> [] (handle_irq_event) from [] 
>>>>> (handle_fasteoi_irq+0xa0/0x168)
>>>>> [] (handle_fasteoi_irq) from [] 
>>>>> (generic_handle_irq+0x24/0x34)
>>>>> [] (generic_handle_irq) from [] 
>>>>> (__handle_domain_irq+0x54/0xa8)
>>>>> [] (__handle_domain_irq) from [] (__irq_svc+0x54/0x70)
>>>>> [] (__irq_svc) from [] (arch_cpu_idle+0x38/0x3c)
>>>>> [] (arch_cpu_idle) from [] 
>>>>> (cpu_startup_entry+0x9c/0xdc)
>>>>> [] (cpu_startup_entry) from [] 
>>>>> (start_kernel+0x354/0x360)
>>>>> [] (start_kernel) from [<20008078>] (0x20008078)
>>>>> ---[ end trace e7cf9dcebf4815a6 ]---
>>>>>
>>>>> Fixes: c32b5bcfa3c4 ("ARM: dts: at91: Fix USB endpoint nodes")
>>>>> Reported-by: Richard Genoud <richard.gen...@gmail.com>
>>>>> Signed-off-by: Alexandre Belloni <alexandre.bell...@free-electrons.com>
>>>>
>>>> Acked-by: Nicolas Ferre <nicolas.fe...@atmel.com>
>>>>
>>>> Felipe, Greg,
>>>> It is clearly a regression and material for 4.8-fixes. But I do know
>>>> that we are very late in the process :-(
>>>> Please do what you can to make it progress before 4.8-final but I'm
>>>> truly aware of the challenge.
>>>
>>> Any chance that we can have it (aka ping)?
>>
>> It's Felipe's area, not mine :)
> 
> Sorry, I had missed this one. Greg, seems like this would be the only
> pending fix. Do you want it in a pull request or would you prefer to
> just pick it up as a patch? Works either way for me. In case you decide
> to pick it up as a patch:
> 
> Acked-by: Felipe Balbi <felipe.ba...@linux.intel.com>
> 
> If you prefer to pick it up as a pull request, I already have the patch
> in my 'fixes' branch, just need to tag it and send it to you.

Felipe,

We agreed to delay this patch after the merge window is closed. But I
feel that it's beginning to be urgent to make this patch go forward:
actual users of our kernel are facing the issue:

https://lkml.org/lkml/2016/10/17/493

We're already at -rc2 and I don't see USB-fixes included...

Best regards,
-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] dt-bindings: usb: atmel: fix a couple of copy-paste style typos

2016-10-18 Thread Nicolas Ferre
Le 18/10/2016 à 13:05, Peter Rosin a écrit :
> Signed-off-by: Peter Rosin <p...@axentia.se>

Acked-by: Nicolas Ferre <nicolas.fe...@atmel.com>

We may take it in a future at91-x.y-dt branch which will go through arm-soc.

Thanks

> ---
>  Documentation/devicetree/bindings/usb/atmel-usb.txt | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/usb/atmel-usb.txt 
> b/Documentation/devicetree/bindings/usb/atmel-usb.txt
> index f4262ed60582..ad8ea56a9ed3 100644
> --- a/Documentation/devicetree/bindings/usb/atmel-usb.txt
> +++ b/Documentation/devicetree/bindings/usb/atmel-usb.txt
> @@ -6,9 +6,9 @@ Required properties:
>   - compatible: Should be "atmel,at91rm9200-ohci" for USB controllers
> used in host mode.
>   - reg: Address and length of the register set for the device
> - - interrupts: Should contain ehci interrupt
> + - interrupts: Should contain ohci interrupt
>   - clocks: Should reference the peripheral, host and system clocks
> - - clock-names: Should contains two strings
> + - clock-names: Should contain three strings
>   "ohci_clk" for the peripheral clock
>   "hclk" for the host clock
>   "uhpck" for the system clock
> @@ -35,7 +35,7 @@ Required properties:
>   - reg: Address and length of the register set for the device
>   - interrupts: Should contain ehci interrupt
>   - clocks: Should reference the peripheral and the UTMI clocks
> - - clock-names: Should contains two strings
> + - clock-names: Should contain two strings
>   "ehci_clk" for the peripheral clock
>   "usb_clk" for the UTMI clock
>  
> @@ -58,7 +58,7 @@ Required properties:
>   - reg: Address and length of the register set for the device
>   - interrupts: Should contain macb interrupt
>   - clocks: Should reference the peripheral and the AHB clocks
> - - clock-names: Should contains two strings
> + - clock-names: Should contain two strings
>   "pclk" for the peripheral clock
>   "hclk" for the AHB clock
>  
> @@ -85,7 +85,7 @@ Required properties:
>   - reg: Address and length of the register set for the device
>   - interrupts: Should contain usba interrupt
>   - clocks: Should reference the peripheral and host clocks
> - - clock-names: Should contains two strings
> + - clock-names: Should contain two strings
>   "pclk" for the peripheral clock
>   "hclk" for the host clock
>   - ep childnode: To specify the number of endpoints and their properties.
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC/PATCH 17/45] usb: gadget: udc: atmel: make use of new usb_endpoint_maxp_mult()

2016-10-03 Thread Nicolas Ferre
Le 28/09/2016 à 15:05, Felipe Balbi a écrit :
> We have introduced a helper to calculate multiplier
> value from wMaxPacketSize. Start using it.
> 
> Cc: Nicolas Ferre <nicolas.fe...@atmel.com>

Acked-by: Nicolas Ferre <nicolas.fe...@atmel.com>

> Cc: <linux-usb@vger.kernel.org>
> Signed-off-by: Felipe Balbi <felipe.ba...@linux.intel.com>
> ---
>  drivers/usb/gadget/udc/atmel_usba_udc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
> b/drivers/usb/gadget/udc/atmel_usba_udc.c
> index 45bc997d0711..c57012b1ddf4 100644
> --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
> @@ -573,7 +573,7 @@ usba_ep_enable(struct usb_ep *_ep, const struct 
> usb_endpoint_descriptor *desc)
>* Bits 11:12 specify number of _additional_
>* transactions per microframe.
>*/
> - nr_trans = ((usb_endpoint_maxp(desc) >> 11) & 3) + 1;
> + nr_trans = usb_endpoint_maxp_mult(desc);
>   if (nr_trans > 3)
>   return -EINVAL;
>  
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC/PATCH 35/45] usb: gadget: udc: atmel: remove unnecessary & operation

2016-10-03 Thread Nicolas Ferre
Le 28/09/2016 à 15:05, Felipe Balbi a écrit :
> Now that usb_endpoint_maxp() only returns the lowest
> 11 bits from wMaxPacketSize, we can remove the &
> operation from this driver.
> 
> Cc: Nicolas Ferre <nicolas.fe...@atmel.com>

Acked-by: Nicolas Ferre <nicolas.fe...@atmel.com>

> Cc: <linux-usb@vger.kernel.org>
> Signed-off-by: Felipe Balbi <felipe.ba...@linux.intel.com>
> ---
>  drivers/usb/gadget/udc/atmel_usba_udc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
> b/drivers/usb/gadget/udc/atmel_usba_udc.c
> index c57012b1ddf4..125680db9379 100644
> --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
> @@ -529,7 +529,7 @@ usba_ep_enable(struct usb_ep *_ep, const struct 
> usb_endpoint_descriptor *desc)
>  
>   DBG(DBG_GADGET, "%s: ep_enable: desc=%p\n", ep->ep.name, desc);
>  
> - maxpacket = usb_endpoint_maxp(desc) & 0x7ff;
> + maxpacket = usb_endpoint_maxp(desc);
>  
>   if (((desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK) != ep->index)
>   || ep->index == 0
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: Convert pr_warning to pr_warn

2016-09-28 Thread Nicolas Ferre
Le 27/09/2016 à 18:16, Joe Perches a écrit :
> Use the more common logging mechanism.
> 
> Miscellanea:
> 
> o Realign multiline statements
> o Coalesce format
> 
> Signed-off-by: Joe Perches <j...@perches.com>
> ---
>  drivers/usb/gadget/function/rndis.c |  9 -
>  drivers/usb/gadget/function/u_serial.c  |  4 ++--
>  drivers/usb/gadget/udc/at91_udc.h   |  2 +-
>  drivers/usb/gadget/udc/atmel_usba_udc.c |  4 ++--

For AT91 and Atmel parts:
Acked-by: Nicolas Ferre <nicolas.fe...@atmel.com>

Thanks

>  drivers/usb/gadget/udc/fsl_usb2_udc.h   |  2 +-
>  drivers/usb/gadget/udc/m66592-udc.c |  4 ++--
>  drivers/usb/gadget/udc/omap_udc.h   |  2 +-
>  drivers/usb/gadget/udc/pxa25x_udc.h |  2 +-
>  drivers/usb/host/isp1362-hcd.c  | 27 ++-
>  drivers/usb/isp1760/isp1760-if.c|  2 +-
>  10 files changed, 29 insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/usb/gadget/function/rndis.c 
> b/drivers/usb/gadget/function/rndis.c
> index ab6ac1b74ac0..766c328c15c0 100644
> --- a/drivers/usb/gadget/function/rndis.c
> +++ b/drivers/usb/gadget/function/rndis.c
> @@ -474,8 +474,7 @@ static int gen_ndis_query_resp(struct rndis_params 
> *params, u32 OID, u8 *buf,
>   break;
>  
>   default:
> - pr_warning("%s: query unknown OID 0x%08X\n",
> -  __func__, OID);
> + pr_warn("%s: query unknown OID 0x%08X\n", __func__, OID);
>   }
>   if (retval < 0)
>   length = 0;
> @@ -546,8 +545,8 @@ static int gen_ndis_set_resp(struct rndis_params *params, 
> u32 OID,
>   break;
>  
>   default:
> - pr_warning("%s: set unknown OID 0x%08X, size %d\n",
> -  __func__, OID, buf_len);
> + pr_warn("%s: set unknown OID 0x%08X, size %d\n",
> + __func__, OID, buf_len);
>   }
>  
>   return retval;
> @@ -854,7 +853,7 @@ int rndis_msg_parser(struct rndis_params *params, u8 *buf)
>* In one case those messages seemed to relate to the host
>* suspending itself.
>*/
> - pr_warning("%s: unknown RNDIS message 0x%08X len %d\n",
> + pr_warn("%s: unknown RNDIS message 0x%08X len %d\n",
>   __func__, MsgType, MsgLength);
>   print_hex_dump_bytes(__func__, DUMP_PREFIX_OFFSET,
>buf, MsgLength);
> diff --git a/drivers/usb/gadget/function/u_serial.c 
> b/drivers/usb/gadget/function/u_serial.c
> index e0cd1e4c8892..62ec842874aa 100644
> --- a/drivers/usb/gadget/function/u_serial.c
> +++ b/drivers/usb/gadget/function/u_serial.c
> @@ -622,8 +622,8 @@ static void gs_write_complete(struct usb_ep *ep, struct 
> usb_request *req)
>   switch (req->status) {
>   default:
>   /* presumably a transient fault */
> - pr_warning("%s: unexpected %s status %d\n",
> - __func__, ep->name, req->status);
> + pr_warn("%s: unexpected %s status %d\n",
> + __func__, ep->name, req->status);
>   /* FALL THROUGH */
>   case 0:
>   /* normal completion */
> diff --git a/drivers/usb/gadget/udc/at91_udc.h 
> b/drivers/usb/gadget/udc/at91_udc.h
> index 0a433e6b346b..9bbe72764f31 100644
> --- a/drivers/usb/gadget/udc/at91_udc.h
> +++ b/drivers/usb/gadget/udc/at91_udc.h
> @@ -175,7 +175,7 @@ struct at91_request {
>  #endif
>  
>  #define ERR(stuff...)pr_err("udc: " stuff)
> -#define WARNING(stuff...)pr_warning("udc: " stuff)
> +#define WARNING(stuff...)pr_warn("udc: " stuff)
>  #define INFO(stuff...)   pr_info("udc: " stuff)
>  #define DBG(stuff...)pr_debug("udc: " stuff)
>  
> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
> b/drivers/usb/gadget/udc/atmel_usba_udc.c
> index 45bc997d0711..1ef7a9a9d7f5 100644
> --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
> @@ -1464,8 +1464,8 @@ static void usba_control_irq(struct usba_udc *udc, 
> struct usba_ep *ep)
>   pkt_len = USBA_BFEXT(BYTE_COUNT, usba_ep_readl(ep, STA));
>   DBG(DBG_HW, "Packet length: %u\n", pkt_len);
>   if (pkt_len != sizeof(crq)) {
> - pr_warning("udc: Invalid packet length %u "
> - "(expected %zu)\n", pkt_len, sizeof(crq));
> + pr_warn("udc: Inva

Re: [PATCH] usb: gadget: udc: atmel: fix endpoint name

2016-09-23 Thread Nicolas Ferre
Le 16/09/2016 à 10:36, Nicolas Ferre a écrit :
> Le 15/09/2016 à 17:07, Alexandre Belloni a écrit :
>> Since commit c32b5bcfa3c4 ("ARM: dts: at91: Fix USB endpoint nodes"),
>> atmel_usba_udc fails with:
>>
>> [ cut here ]
>> WARNING: CPU: 0 PID: 0 at include/linux/usb/gadget.h:405
>> ecm_do_notify+0x188/0x1a0
>> Modules linked in:
>> CPU: 0 PID: 0 Comm: swapper Not tainted 4.7.0+ #15
>> Hardware name: Atmel SAMA5
>> [] (unwind_backtrace) from [] (show_stack+0x10/0x14)
>> [] (show_stack) from [] (__warn+0xe4/0xfc)
>> [] (__warn) from [] (warn_slowpath_null+0x20/0x28)
>> [] (warn_slowpath_null) from [] 
>> (ecm_do_notify+0x188/0x1a0)
>> [] (ecm_do_notify) from [] (ecm_set_alt+0x74/0x1ac)
>> [] (ecm_set_alt) from [] (composite_setup+0xfc0/0x19f8)
>> [] (composite_setup) from [] (usba_udc_irq+0x8f4/0xd9c)
>> [] (usba_udc_irq) from [] 
>> (handle_irq_event_percpu+0x9c/0x158)
>> [] (handle_irq_event_percpu) from [] 
>> (handle_irq_event+0x28/0x3c)
>> [] (handle_irq_event) from [] 
>> (handle_fasteoi_irq+0xa0/0x168)
>> [] (handle_fasteoi_irq) from [] 
>> (generic_handle_irq+0x24/0x34)
>> [] (generic_handle_irq) from [] 
>> (__handle_domain_irq+0x54/0xa8)
>> [] (__handle_domain_irq) from [] (__irq_svc+0x54/0x70)
>> [] (__irq_svc) from [] (arch_cpu_idle+0x38/0x3c)
>> [] (arch_cpu_idle) from [] (cpu_startup_entry+0x9c/0xdc)
>> [] (cpu_startup_entry) from [] (start_kernel+0x354/0x360)
>> [] (start_kernel) from [<20008078>] (0x20008078)
>> ---[ end trace e7cf9dcebf4815a6 ]---
>>
>> Fixes: c32b5bcfa3c4 ("ARM: dts: at91: Fix USB endpoint nodes")
>> Reported-by: Richard Genoud <richard.gen...@gmail.com>
>> Signed-off-by: Alexandre Belloni <alexandre.bell...@free-electrons.com>
> 
> Acked-by: Nicolas Ferre <nicolas.fe...@atmel.com>
> 
> Felipe, Greg,
> It is clearly a regression and material for 4.8-fixes. But I do know
> that we are very late in the process :-(
> Please do what you can to make it progress before 4.8-final but I'm
> truly aware of the challenge.

Any chance that we can have it (aka ping)?

Bye,

> Thanks to Richard for finding this and Alexandre for the quick correction.
> 
> Bye,
> 
>> ---
>>  drivers/usb/gadget/udc/atmel_usba_udc.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
>> b/drivers/usb/gadget/udc/atmel_usba_udc.c
>> index bb1f6c8f0f01..45bc997d0711 100644
>> --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
>> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
>> @@ -1978,7 +1978,7 @@ static struct usba_ep * atmel_udc_of_init(struct 
>> platform_device *pdev,
>>      dev_err(>dev, "of_probe: name error(%d)\n", ret);
>>  goto err;
>>  }
>> -ep->ep.name = name;
>> +ep->ep.name = kasprintf(GFP_KERNEL, "ep%d", ep->index);
>>  
>>  ep->ep_regs = udc->regs + USBA_EPT_BASE(i);
>>  ep->dma_regs = udc->regs + USBA_DMA_BASE(i);
>>
> 
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: gadget: udc: atmel: fix endpoint name

2016-09-16 Thread Nicolas Ferre
Le 15/09/2016 à 17:07, Alexandre Belloni a écrit :
> Since commit c32b5bcfa3c4 ("ARM: dts: at91: Fix USB endpoint nodes"),
> atmel_usba_udc fails with:
> 
> [ cut here ]
> WARNING: CPU: 0 PID: 0 at include/linux/usb/gadget.h:405
> ecm_do_notify+0x188/0x1a0
> Modules linked in:
> CPU: 0 PID: 0 Comm: swapper Not tainted 4.7.0+ #15
> Hardware name: Atmel SAMA5
> [] (unwind_backtrace) from [] (show_stack+0x10/0x14)
> [] (show_stack) from [] (__warn+0xe4/0xfc)
> [] (__warn) from [] (warn_slowpath_null+0x20/0x28)
> [] (warn_slowpath_null) from [] 
> (ecm_do_notify+0x188/0x1a0)
> [] (ecm_do_notify) from [] (ecm_set_alt+0x74/0x1ac)
> [] (ecm_set_alt) from [] (composite_setup+0xfc0/0x19f8)
> [] (composite_setup) from [] (usba_udc_irq+0x8f4/0xd9c)
> [] (usba_udc_irq) from [] 
> (handle_irq_event_percpu+0x9c/0x158)
> [] (handle_irq_event_percpu) from [] 
> (handle_irq_event+0x28/0x3c)
> [] (handle_irq_event) from [] 
> (handle_fasteoi_irq+0xa0/0x168)
> [] (handle_fasteoi_irq) from [] 
> (generic_handle_irq+0x24/0x34)
> [] (generic_handle_irq) from [] 
> (__handle_domain_irq+0x54/0xa8)
> [] (__handle_domain_irq) from [] (__irq_svc+0x54/0x70)
> [] (__irq_svc) from [] (arch_cpu_idle+0x38/0x3c)
> [] (arch_cpu_idle) from [] (cpu_startup_entry+0x9c/0xdc)
> [] (cpu_startup_entry) from [] (start_kernel+0x354/0x360)
> [] (start_kernel) from [<20008078>] (0x20008078)
> ---[ end trace e7cf9dcebf4815a6 ]---
> 
> Fixes: c32b5bcfa3c4 ("ARM: dts: at91: Fix USB endpoint nodes")
> Reported-by: Richard Genoud <richard.gen...@gmail.com>
> Signed-off-by: Alexandre Belloni <alexandre.bell...@free-electrons.com>

Acked-by: Nicolas Ferre <nicolas.fe...@atmel.com>

Felipe, Greg,
It is clearly a regression and material for 4.8-fixes. But I do know
that we are very late in the process :-(
Please do what you can to make it progress before 4.8-final but I'm
truly aware of the challenge.

Thanks to Richard for finding this and Alexandre for the quick correction.

Bye,

> ---
>  drivers/usb/gadget/udc/atmel_usba_udc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
> b/drivers/usb/gadget/udc/atmel_usba_udc.c
> index bb1f6c8f0f01..45bc997d0711 100644
> --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
> @@ -1978,7 +1978,7 @@ static struct usba_ep * atmel_udc_of_init(struct 
> platform_device *pdev,
>   dev_err(>dev, "of_probe: name error(%d)\n", ret);
>   goto err;
>   }
> - ep->ep.name = name;
> + ep->ep.name = kasprintf(GFP_KERNEL, "ep%d", ep->index);
>  
>   ep->ep_regs = udc->regs + USBA_EPT_BASE(i);
>   ep->dma_regs = udc->regs + USBA_DMA_BASE(i);
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4] usb: ohci-at91: Forcibly suspend ports while USB suspend

2016-06-21 Thread Nicolas Ferre
Le 21/06/2016 03:32, Wenyou Yang a écrit :
> In order to save power consumption, as a workaround, forcibly suspend
> the USB PORTA/B/C via setting the SUSPEND_A/B/C bits of OHCI Interrupt
> Configuration Register in the SFR while OHCI USB suspend.
> 
> This suspend operation must be done before the USB clock is disabled,
> resume after the USB clock is enabled.
> 
> Signed-off-by: Wenyou Yang <wenyou.y...@atmel.com>

Acked-by: Nicolas Ferre <nicolas.fe...@atmel.com>

Alan, can you take it as it doesn't have dependency on the at91 material
anymore.

Thanks, bye.

> ---
> 
> Changes in v4:
>  - To check whether the SFR node with "atmel,sama5d2-sfr" compatible
>is present or not to decide if this feature is applied or not
>when USB OHCI suspend/resume, instead of new compatible.
>  - Drop the compatible "atmel,sama5d2-ohci".
>  - Drop [PATCH 2/2] ARM: at91/dt: sama5d2: Use new compatible for
>ohci node.
>  - Drop include/soc/at91/at91_sfr.h, move the macro definitions to
>atmel-sfr.h which already exists.
>  - Change the defines to align the exists.
> 
> Changes in v3:
>  - Change the compatible description for more precise.
> 
> Changes in v2:
>  - Add compatible to support forcibly suspend the ports.
>  - Add soc/at91/at91_sfr.h to accommodate the defines.
>  - Add error checking for .sfr_regmap.
>  - Remove unnecessary regmap_read() statement.
> 
>  drivers/usb/host/ohci-at91.c | 55 
> 
>  include/soc/at91/atmel-sfr.h | 13 +++
>  2 files changed, 68 insertions(+)
> 
> diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
> index d177372..f07c398 100644
> --- a/drivers/usb/host/ohci-at91.c
> +++ b/drivers/usb/host/ohci-at91.c
> @@ -21,8 +21,11 @@
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
>  #include 
>  #include 
> +#include 
>  
>  #include "ohci.h"
>  
> @@ -51,6 +54,7 @@ struct ohci_at91_priv {
>   struct clk *hclk;
>   bool clocked;
>   bool wakeup;/* Saved wake-up state for resume */
> + struct regmap *sfr_regmap;
>  };
>  /* interface and function clocks; sometimes also an AHB clock */
>  
> @@ -132,6 +136,17 @@ static void at91_stop_hc(struct platform_device *pdev)
>  
>  /*-*/
>  
> +struct regmap *at91_dt_syscon_sfr(void)
> +{
> + struct regmap *regmap;
> +
> + regmap = syscon_regmap_lookup_by_compatible("atmel,sama5d2-sfr");
> + if (IS_ERR(regmap))
> + regmap = NULL;
> +
> + return regmap;
> +}
> +
>  static void usb_hcd_at91_remove (struct usb_hcd *, struct platform_device *);
>  
>  /* configure so an HC device and id are always provided */
> @@ -197,6 +212,10 @@ static int usb_hcd_at91_probe(const struct hc_driver 
> *driver,
>   goto err;
>   }
>  
> + ohci_at91->sfr_regmap = at91_dt_syscon_sfr();
> + if (!ohci_at91->sfr_regmap)
> + dev_warn(dev, "failed to find sfr node\n");
> +
>   board = hcd->self.controller->platform_data;
>   ohci = hcd_to_ohci(hcd);
>   ohci->num_ports = board->ports;
> @@ -581,6 +600,38 @@ static int ohci_hcd_at91_drv_remove(struct 
> platform_device *pdev)
>   return 0;
>  }
>  
> +static int ohci_at91_port_ctrl(struct regmap *regmap, bool enable)
> +{
> + u32 regval;
> + int ret;
> +
> + if (!regmap)
> + return 0;
> +
> + ret = regmap_read(regmap, AT91_SFR_OHCIICR, );
> + if (ret)
> + return ret;
> +
> + if (enable)
> + regval &= ~AT91_OHCIICR_USB_SUSPEND;
> + else
> + regval |= AT91_OHCIICR_USB_SUSPEND;
> +
> + regmap_write(regmap, AT91_SFR_OHCIICR, regval);
> +
> + return 0;
> +}
> +
> +static int ohci_at91_port_suspend(struct regmap *regmap)
> +{
> + return ohci_at91_port_ctrl(regmap, false);
> +}
> +
> +static int ohci_at91_port_resume(struct regmap *regmap)
> +{
> + return ohci_at91_port_ctrl(regmap, true);
> +}
> +
>  static int __maybe_unused
>  ohci_hcd_at91_drv_suspend(struct device *dev)
>  {
> @@ -618,6 +669,8 @@ ohci_hcd_at91_drv_suspend(struct device *dev)
>   ohci_writel(ohci, ohci->hc_control, >regs->control);
>   ohci->rh_state = OHCI_RH_HALTED;
>  
> + ohci_at91_port_suspend(ohci_at91->sfr_regmap);
> +
>   /* flush the writes */
>   (void) ohci_readl (ohci, >regs->control);
>   

Re: [PATCH v3 1/2] usb: ohci-at91: Forcibly suspend ports while USB suspend

2016-06-20 Thread Nicolas Ferre
Le 20/06/2016 10:52, Alexandre Belloni a écrit :
> On 20/06/2016 at 08:46:02 +, Yang, Wenyou wrote :
>> Hi Alexandre & Nicolas,
>>
>>> -Original Message-
>>> From: Alexandre Belloni [mailto:alexandre.bell...@free-electrons.com]
>>> Sent: 2016年6月20日 16:04
>>> To: Yang, Wenyou <wenyou.y...@atmel.com>
>>> Cc: Rob Herring <r...@kernel.org>; Alan Stern <st...@rowland.harvard.edu>;
>>> Greg Kroah-Hartman <gre...@linuxfoundation.org>; Ferre, Nicolas
>>> <nicolas.fe...@atmel.com>; Pawel Moll <pawel.m...@arm.com>; Mark Brown
>>> <broo...@kernel.org>; Ian Campbell <ijc+devicet...@hellion.org.uk>; Kumar
>>> Gala <ga...@codeaurora.org>; linux-ker...@vger.kernel.org;
>>> devicet...@vger.kernel.org; linux-arm-ker...@lists.infradead.org; linux-
>>> u...@vger.kernel.org
>>> Subject: Re: [PATCH v3 1/2] usb: ohci-at91: Forcibly suspend ports while USB
>>> suspend
>>>
>>> On 20/06/2016 at 03:16:35 +, Yang, Wenyou wrote :
>>>>> Sure, what I mean is that you can try to get the regmap for the SFR in 
>>>>> every
>>> case.
>>>>> Depending on whether you were able to get it, you can decide to call
>>>>> ohci_at91_port_suspend/resume or not (just test for sfr_regmap != NULL).
>>>>
>>>> I don't think so. The SFR includes a lot of miscellaneous functions, more 
>>>> than
>>> this one.
>>>>
>>>
>>> I know but this is irrelevant to this discussion. If you need to use the 
>>> SFR from
>>> another driver you will simply get it from that other driver.
>>>
>>> I that case, you will try to get "atmel,sama5d2-sfr". It is only present on 
>>> sama5d2
>>> so you have enough information to know whether or not you can use it to
>>> suspend/resume.
>>
>> I understand what your meaning :).
>> Use "atmel,sama5d2-sfr" compatible to distinguish whether forcibly suspend 
>> USB port via SFR or not.
>>
>> I am not sure if it is a better solution.
>>
> 
> It is definitively superior. There is only one lookup in the device tree
> instead of two because whatever happens, you will have to get the SFR
> regmap and you don't need to add a compatible string for an IP that
> didn't change.
> 
>> Nicolas, could you give your opinion?

I'll paraphrase Alexandre but this is what I understood:

Having the information in one place and not having to managed the
synchronization with 2 potential sources of information is clearly an
advantage of Alexandre's solution.

If the next SoC has the same workaround/feature, we will anyway have a
different SFR string to cling to...
So it won't change much and we won't have the confusion of having the
same sama5d2 compatible string on the OHCI side (same behavior) and
different compatible string on the SFR side (probably a new SFR for a
new SoC...).

If the next SoC doesn't have this workaround/feature... well, it's
simple, we don't look for the SFR, we don't use the bits, and we come
back to the situation that we've always experienced ; with the same
compatibility sting for OHCI as the IP never actually changed...

In conclusion: try Alexandre's solution and we'll certainly find that
it's actually simpler.

Bonus point: it voids the discussion on the OHCI compatible string
descriptions!

Bye,

>>> Alexandre Belloni, Free Electrons
>>> Embedded Linux, Kernel and Android engineering http://free-electrons.com
>>
>>
>> Best Regards,
>> Wenyou Yang
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 1/2] usb: ohci-at91: Forcibly suspend ports while USB suspend

2016-06-08 Thread Nicolas Ferre
Le 08/06/2016 12:04, Nicolas Ferre a écrit :
> Le 08/06/2016 06:15, Wenyou Yang a écrit :
>> In order to the save power consumption, as a workaround, suspend
>> forcibly the USB PORTA/B/C via set the SUSPEND_A/B/C bits of OHCI
>> Interrupt Configuration Register in the SFRs while OHCI USB suspend.
>>
>> This suspend operation must be done before the USB clock is disabled,
>> resume after the USB clock is enabled.
>>
>> Signed-off-by: Wenyou Yang <wenyou.y...@atmel.com>
> 
> Little nitpicking below...
> 
>> ---
>>
>> Changes in v3:
>>  - Change the compatible description for more precise.
>>
>> Changes in v2:
>>  - Add compatible to support forcibly suspend the ports.
>>  - Add soc/at91/at91_sfr.h to accommodate the defines.
>>  - Add error checking for .sfr_regmap.
>>  - Remove unnecessary regmap_read() statement.
>>
>>  .../devicetree/bindings/usb/atmel-usb.txt  |  6 +-
>>  drivers/usb/host/ohci-at91.c   | 80 
>> +-
>>  include/soc/at91/at91_sfr.h| 29 

Oops sorry, additional comment which is not nitpicking, this one:

We already have SFR header file in this patch:

Author: Cyrille Pitchen <cyrille.pitc...@atmel.com>
Date:   Thu Mar 17 17:04:00 2016 +0100

ARM: dts: at91: sama5d2: add SFR node

This SFR node is looked up by the I2S controller driver to tune the
SFR_I2SCLKSEL register.

Signed-off-by: Cyrille Pitchen <cyrille.pitc...@atmel.com>
Signed-off-by: Ludovic Desroches <ludovic.desroc...@atmel.com>
Acked-by: Alexandre Belloni <alexandre.bell...@free-electrons.com>
Acked-by: Rob Herring <r...@kernel.org>
Signed-off-by: Nicolas Ferre <nicolas.fe...@atmel.com>

Which is already accepted by arm-soc guys for 4.7... So my ack
transforms into a nack, sorry...

We will have to coordinate the effort and maybe take the whole series
with us. But for sure, you'll have to use the existing
include/soc/at91/atmel-sfr.h file and build on top of it...

Bye,

>>  3 files changed, 112 insertions(+), 3 deletions(-)
>>  create mode 100644 include/soc/at91/at91_sfr.h

[..]

> 
> But you can take my:
> 
> Acked-by: Nicolas Ferre <nicolas.fe...@atmel.com>
> 
> with the little corrections listed.
> 
> Alan, We plan to take the second patch of this series with AT91 git tree
> through arm-soc. Do you agree to take this one through yours?

Alan, forget this request, we'll have to coordinate differently.

Sorry for the noise. Bye,
-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 2/2] ARM: at91/dt: sama5d2: Use new compatible for ohci node

2016-06-08 Thread Nicolas Ferre
Le 08/06/2016 06:15, Wenyou Yang a écrit :
> Use compatible "atmel,sama5d2-ohci" to be capable of suspending
> ports while sleep to save the power consumption.
> 
> Signed-off-by: Wenyou Yang <wenyou.y...@atmel.com>
> ---
> 
> Changes in v3: None
> Changes in v2:
>  - Use the new compatible for ohci-node.
> 
>  arch/arm/boot/dts/sama5d2.dtsi | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/boot/dts/sama5d2.dtsi b/arch/arm/boot/dts/sama5d2.dtsi
> index 78996bd..03d6724 100644
> --- a/arch/arm/boot/dts/sama5d2.dtsi
> +++ b/arch/arm/boot/dts/sama5d2.dtsi
> @@ -232,7 +232,7 @@
>   };
>  
>   usb1: ohci@0040 {
> - compatible = "atmel,at91rm9200-ohci", "usb-ohci";
> + compatible = "atmel,sama5d2-ohci", "usb-ohci";

We must change this to:
+   compatible = "atmel,sama5d2-ohci", 
"atmel,at91rm9200-ohci", "usb-ohci";

To make it independent from the one that may reach Mainline through the USB git 
tree.


>   reg = <0x0040 0x10>;
>   interrupts = <41 IRQ_TYPE_LEVEL_HIGH 2>;
>   clocks = <_clk>, <_clk>, <>;
> 

Bye,
-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 1/2] usb: ohci-at91: Forcibly suspend ports while USB suspend

2016-06-08 Thread Nicolas Ferre
end_ctrl = true,
> +};
> +
>  static const struct of_device_id at91_ohci_dt_ids[] = {
> - { .compatible = "atmel,at91rm9200-ohci" },
> + { .compatible = "atmel,at91rm9200-ohci", .data = _caps },
> + { .compatible = "atmel,sama5d2-ohci", .data = _caps },
>   { /* sentinel */ }
>  };
>  
> @@ -581,6 +621,38 @@ static int ohci_hcd_at91_drv_remove(struct 
> platform_device *pdev)
>   return 0;
>  }
>  
> +static int ohci_at91_port_ctrl(struct regmap *regmap, bool enable)
> +{
> + u32 regval;
> + int ret;
> +
> + if (!regmap)
> + return -EINVAL;
> +
> + ret = regmap_read(regmap, SFR_OHCIICR, );
> + if (ret)
> + return ret;
> +
> + if (enable)
> + regval &= ~SFR_OHCIICR_USB_SUSPEND;
> + else
> + regval |= SFR_OHCIICR_USB_SUSPEND;
> +
> + regmap_write(regmap, SFR_OHCIICR, regval);
> +
> + return 0;
> +}
> +
> +static int ohci_at91_port_suspend(struct regmap *regmap)
> +{
> + return ohci_at91_port_ctrl(regmap, false);
> +}
> +
> +static int ohci_at91_port_resume(struct regmap *regmap)
> +{
> + return ohci_at91_port_ctrl(regmap, true);
> +}
> +
>  static int __maybe_unused
>  ohci_hcd_at91_drv_suspend(struct device *dev)
>  {
> @@ -618,6 +690,9 @@ ohci_hcd_at91_drv_suspend(struct device *dev)
>   ohci_writel(ohci, ohci->hc_control, >regs->control);
>   ohci->rh_state = OHCI_RH_HALTED;
>  
> + if (ohci_at91->caps->suspend_ctrl)
> + ohci_at91_port_suspend(ohci_at91->sfr_regmap);
> +
>   /* flush the writes */
>   (void) ohci_readl (ohci, >regs->control);
>   at91_stop_clock(ohci_at91);
> @@ -637,6 +712,9 @@ ohci_hcd_at91_drv_resume(struct device *dev)
>  
>   at91_start_clock(ohci_at91);
>  
> + if (ohci_at91->caps->suspend_ctrl)
> + ohci_at91_port_resume(ohci_at91->sfr_regmap);
> +
>   ohci_resume(hcd, false);
>   return 0;
>  }
> diff --git a/include/soc/at91/at91_sfr.h b/include/soc/at91/at91_sfr.h
> new file mode 100644
> index 000..04a3a1e
> --- /dev/null
> +++ b/include/soc/at91/at91_sfr.h
> @@ -0,0 +1,29 @@
> +/*
> + * Header file for the Atmel DDR/SDR SDRAM Controller

It's not for DDR controller, isn't it?


> + *
> + * Copyright (C) 2016 Atmel Corporation
> + *
> + * Author: Wenyou Yang <wenyou.y...@atmel.com>
> + *
> + * 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 __AT91_SFR_H__
> +#define __AT91_SFR_H__
> +
> +#define SFR_DDRCFG   0x04/* DDR Configuration Register */
> +/* 0x08 ~ 0x0c: Reserved */
> +#define SFR_OHCIICR  0x10/* OHCI Interrupt Configuration 
> Register */
> +#define SFR_OHCIISR  0x14/* OHCI Interrupt Status Register */
> +
> +#define SFR_OHCIICR_SUSPEND_ABIT(8)
> +#define SFR_OHCIICR_SUSPEND_BBIT(9)
> +#define SFR_OHCIICR_SUSPEND_CBIT(10)
> +
> +#define SFR_OHCIICR_USB_SUSPEND  (SFR_OHCIICR_SUSPEND_A | \
> +  SFR_OHCIICR_SUSPEND_B | \
> +  SFR_OHCIICR_SUSPEND_C)
> +
> +#endif
> 

But you can take my:

Acked-by: Nicolas Ferre <nicolas.fe...@atmel.com>

with the little corrections listed.

Alan, We plan to take the second patch of this series with AT91 git tree
through arm-soc. Do you agree to take this one through yours?

Bye,
-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 1/2] usb: ohci-at91: Forcibly suspend ports while USB suspend

2016-06-03 Thread Nicolas Ferre
Le 03/06/2016 11:22, Yang, Wenyou a écrit :
>> -Original Message-
>> From: Rob Herring [mailto:r...@kernel.org]
>> Sent: 2016年6月3日 9:54
>> To: Yang, Wenyou <wenyou.y...@atmel.com>
>> Cc: Alan Stern <st...@rowland.harvard.edu>; Greg Kroah-Hartman
>> <gre...@linuxfoundation.org>; Ferre, Nicolas <nicolas.fe...@atmel.com>;
>> Pawel Moll <pawel.m...@arm.com>; Mark Brown <broo...@kernel.org>; Ian
>> Campbell <ijc+devicet...@hellion.org.uk>; Kumar Gala <ga...@codeaurora.org>;
>> Alexandre Belloni <alexandre.bell...@free-electrons.com>; linux-
>> ker...@vger.kernel.org; devicet...@vger.kernel.org; linux-arm-
>> ker...@lists.infradead.org; linux-usb@vger.kernel.org
>> Subject: Re: [PATCH v2 1/2] usb: ohci-at91: Forcibly suspend ports while USB
>> suspend
>>
>> On Wed, Jun 01, 2016 at 12:29:59PM +0800, Wenyou Yang wrote:
>>> In order to the save power consumption, as a workaround, suspend
>>> forcibly the USB PORTA/B/C via set the SUSPEND_A/B/C bits of OHCI
>>> Interrupt Configuration Register in the SFRs while OHCI USB suspend.
>>>
>>> This suspend operation must be done before the USB clock is disabled,
>>> resume after the USB clock is enabled.
>>>
>>> Signed-off-by: Wenyou Yang <wenyou.y...@atmel.com>
>>> ---
>>>
>>> Changes in v2:
>>>  - Add compatible to support forcibly suspend the ports.
>>>  - Add soc/at91/at91_sfr.h to accommodate the defines.
>>>  - Add error checking for .sfr_regmap.
>>>  - Remove unnecessary regmap_read() statement.
>>>
>>>  .../devicetree/bindings/usb/atmel-usb.txt  |  5 +-
>>>  drivers/usb/host/ohci-at91.c   | 80 
>>> +-
>>>  include/soc/at91/at91_sfr.h| 29 
>>>  3 files changed, 111 insertions(+), 3 deletions(-)  create mode
>>> 100644 include/soc/at91/at91_sfr.h
>>>
>>> diff --git a/Documentation/devicetree/bindings/usb/atmel-usb.txt
>>> b/Documentation/devicetree/bindings/usb/atmel-usb.txt
>>> index 5883b73..3e3e58a 100644
>>> --- a/Documentation/devicetree/bindings/usb/atmel-usb.txt
>>> +++ b/Documentation/devicetree/bindings/usb/atmel-usb.txt
>>> @@ -3,8 +3,9 @@ Atmel SOC USB controllers  OHCI
>>>
>>>  Required properties:
>>> - - compatible: Should be "atmel,at91rm9200-ohci" for USB controllers
>>> -   used in host mode.
>>> + - compatible: Should be one of the following
>>> +  "atmel,at91rm9200-ohci" for USB controllers used in host mode.
>>> +  "atmel,sama5d2-ohci" for SAMA5D2 which can force to suspend.
>>
>> That may be why you need this now, but that is irrelevant to having a chip 
>> specific
>> compatible string.
> 
> Maybe a property is better.

It seems that it's not an issue to the binding that Rob is talking about
but the description that you used: "for SAMA5D2 which can force
suspend". Don't modify it to use a property for this: a compatible sting
makes a lot of sense.

So just listing the new compatible string is enough. If the "force
suspend" is not needed anymore in next product, we will come back to the
"atmel,at91rm9200-ohci" compatible string or add a new one if needed...

bye,
-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] usb: gadget: udc: at91: use PTR_ERR_OR_ZERO()

2016-03-29 Thread Nicolas Ferre
Le 29/03/2016 11:28, Felipe Balbi a écrit :
> coccicheck found this pattern which could be
> converted to PTR_ERR_OR_ZERO(). No functional
> changes.
> 
> Signed-off-by: Felipe Balbi <felipe.ba...@linux.intel.com>

Acked-by: Nicolas Ferre <nicolas.fe...@atmel.com>

Thanks Felipe for having taken care of this!

Bye,

> ---
>  drivers/usb/gadget/udc/at91_udc.c | 5 +
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/at91_udc.c 
> b/drivers/usb/gadget/udc/at91_udc.c
> index d0d18947f58b..8bc78418d40e 100644
> --- a/drivers/usb/gadget/udc/at91_udc.c
> +++ b/drivers/usb/gadget/udc/at91_udc.c
> @@ -1726,10 +1726,7 @@ static int at91sam9261_udc_init(struct at91_udc *udc)
>  
>   udc->matrix = syscon_regmap_lookup_by_phandle(udc->pdev->dev.of_node,
> "atmel,matrix");
> - if (IS_ERR(udc->matrix))
> - return PTR_ERR(udc->matrix);
> -
> - return 0;
> + return PTR_ERR_OR_ZERO(udc->matrix);
>  }
>  
>  static void at91sam9261_udc_pullup(struct at91_udc *udc, int is_on)
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/6] usb: ehci-atmel: use __maybe_unused to hide pm functions

2016-03-02 Thread Nicolas Ferre
Le 02/03/2016 16:24, Arnd Bergmann a écrit :
> The ehci-atmel driver uses #ifdef to check for CONFIG_PM, but then
> uses SIMPLE_DEV_PM_OPS, which leaves the references out when
> CONFIG_PM_SLEEP is not defined, so we get a warning with
> PM=y && PM_SLEEP=n:
> 
> drivers/usb/host/ehci-atmel.c:189:12: error: 'ehci_atmel_drv_suspend' defined 
> but not used [-Werror=unused-function]
> drivers/usb/host/ehci-atmel.c:203:12: error: 'ehci_atmel_drv_resume' defined 
> but not used [-Werror=unused-function]
> 
> This removes the incorrect #ifdef and instead uses a __maybe_unused
> annotation to let the compiler know it can silently drop
> the function definition.
> 
> Signed-off-by: Arnd Bergmann <a...@arndb.de>

Acked-by: Nicolas Ferre <nicolas.fe...@atmel.com>

> ---
>  drivers/usb/host/ehci-atmel.c | 6 ++
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
> index be0964a801e8..7440722bfbf0 100644
> --- a/drivers/usb/host/ehci-atmel.c
> +++ b/drivers/usb/host/ehci-atmel.c
> @@ -185,8 +185,7 @@ static int ehci_atmel_drv_remove(struct platform_device 
> *pdev)
>   return 0;
>  }
>  
> -#ifdef CONFIG_PM
> -static int ehci_atmel_drv_suspend(struct device *dev)
> +static int __maybe_unused ehci_atmel_drv_suspend(struct device *dev)
>  {
>   struct usb_hcd *hcd = dev_get_drvdata(dev);
>   struct atmel_ehci_priv *atmel_ehci = hcd_to_atmel_ehci_priv(hcd);
> @@ -200,7 +199,7 @@ static int ehci_atmel_drv_suspend(struct device *dev)
>   return 0;
>  }
>  
> -static int ehci_atmel_drv_resume(struct device *dev)
> +static int __maybe_unused ehci_atmel_drv_resume(struct device *dev)
>  {
>   struct usb_hcd *hcd = dev_get_drvdata(dev);
>   struct atmel_ehci_priv *atmel_ehci = hcd_to_atmel_ehci_priv(hcd);
> @@ -208,7 +207,6 @@ static int ehci_atmel_drv_resume(struct device *dev)
>   atmel_start_clock(atmel_ehci);
>   return ehci_resume(hcd, false);
>  }
> -#endif
>  
>  #ifdef CONFIG_OF
>  static const struct of_device_id atmel_ehci_dt_ids[] = {
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/6] usb: ohci-at91: use __maybe_unused to hide pm functions

2016-03-02 Thread Nicolas Ferre
Le 02/03/2016 16:24, Arnd Bergmann a écrit :
> The ohci-at91 driver uses #ifdef to check for CONFIG_PM, but then
> uses SIMPLE_DEV_PM_OPS, which leaves the references out when
> CONFIG_PM_SLEEP is not defined, so we get a warning with
> PM=y && PM_SLEEP=n:
> 
> drivers/usb/host/ohci-at91.c:587:1: error: 'ohci_hcd_at91_drv_suspend' 
> defined but not used [-Werror=unused-function]
> drivers/usb/host/ohci-at91.c:631:12: error: 'ohci_hcd_at91_drv_resume' 
> defined but not used [-Werror=unused-function]
> 
> This removes the incorrect #ifdef and instead uses a __maybe_unused
> annotation to let the compiler know it can silently drop
> the function definition.
> 
> Signed-off-by: Arnd Bergmann <a...@arndb.de>

Acked-by: Nicolas Ferre <nicolas.fe...@atmel.com>

Thanks Arnd, bye.

> ---
>  drivers/usb/host/ohci-at91.c | 8 +++-
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
> index 95c8ddde0725..d177372bb357 100644
> --- a/drivers/usb/host/ohci-at91.c
> +++ b/drivers/usb/host/ohci-at91.c
> @@ -581,9 +581,7 @@ static int ohci_hcd_at91_drv_remove(struct 
> platform_device *pdev)
>   return 0;
>  }
>  
> -#ifdef CONFIG_PM
> -
> -static int
> +static int __maybe_unused
>  ohci_hcd_at91_drv_suspend(struct device *dev)
>  {
>   struct usb_hcd  *hcd = dev_get_drvdata(dev);
> @@ -628,7 +626,8 @@ ohci_hcd_at91_drv_suspend(struct device *dev)
>   return ret;
>  }
>  
> -static int ohci_hcd_at91_drv_resume(struct device *dev)
> +static int __maybe_unused
> +ohci_hcd_at91_drv_resume(struct device *dev)
>  {
>   struct usb_hcd  *hcd = dev_get_drvdata(dev);
>   struct ohci_at91_priv *ohci_at91 = hcd_to_ohci_at91_priv(hcd);
> @@ -641,7 +640,6 @@ static int ohci_hcd_at91_drv_resume(struct device *dev)
>   ohci_resume(hcd, false);
>   return 0;
>  }
> -#endif
>  
>  static SIMPLE_DEV_PM_OPS(ohci_hcd_at91_pm_ops, ohci_hcd_at91_drv_suspend,
>   ohci_hcd_at91_drv_resume);
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] USB: host: ohci-at91: fix a crash in ohci_hcd_at91_overcurrent_irq

2015-12-03 Thread Nicolas Ferre
Le 02/12/2015 20:36, Alexandre Belloni a écrit :
> The interrupt handler, ohci_hcd_at91_overcurrent_irq may be called right
> after registration. At that time, pdev->dev.platform_data is not yet set,
> leading to a NULL pointer dereference.
> 
> Fixes: e4df92279fd9 (USB: host: ohci-at91: merge loops in 
> ohci_hcd_at91_drv_probe)

Yes, with:
Cc: sta...@vger.kernel.org # 4.3+


> Reported-by: Peter Rosin <p...@axentia.se>
> Tested-by: Peter Rosin <p...@axentia.se>
> Signed-off-by: Alexandre Belloni <alexandre.bell...@free-electrons.com>

Acked-by: Nicolas Ferre <nicolas.fe...@atmel.com>

Alan, I think it's a good candidate to enter the 4.4-rcX...

Thanks, bye.

> ---
>  drivers/usb/host/ohci-at91.c | 11 +--
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
> index 342ffd140122..8c6e15bd6ff0 100644
> --- a/drivers/usb/host/ohci-at91.c
> +++ b/drivers/usb/host/ohci-at91.c
> @@ -473,6 +473,8 @@ static int ohci_hcd_at91_drv_probe(struct platform_device 
> *pdev)
>   if (!pdata)
>   return -ENOMEM;
>  
> + pdev->dev.platform_data = pdata;
> +
>   if (!of_property_read_u32(np, "num-ports", ))
>   pdata->ports = ports;
>  
> @@ -483,6 +485,7 @@ static int ohci_hcd_at91_drv_probe(struct platform_device 
> *pdev)
>*/
>   if (i >= pdata->ports) {
>   pdata->vbus_pin[i] = -EINVAL;
> + pdata->overcurrent_pin[i] = -EINVAL;
>   continue;
>   }
>  
> @@ -513,10 +516,8 @@ static int ohci_hcd_at91_drv_probe(struct 
> platform_device *pdev)
>   }
>  
>   at91_for_each_port(i) {
> - if (i >= pdata->ports) {
> - pdata->overcurrent_pin[i] = -EINVAL;
> - continue;
> - }
> + if (i >= pdata->ports)
> + break;
>  
>   pdata->overcurrent_pin[i] =
>   of_get_named_gpio_flags(np, "atmel,oc-gpio", i, );
> @@ -552,8 +553,6 @@ static int ohci_hcd_at91_drv_probe(struct platform_device 
> *pdev)
>   }
>   }
>  
> - pdev->dev.platform_data = pdata;
> -
>   device_init_wakeup(>dev, 1);
>   return usb_hcd_at91_probe(_at91_hc_driver, pdev);
>  }
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] usb: gadget: at91_udc: mention proper dependency

2015-09-30 Thread Nicolas Ferre
Le 30/09/2015 18:24, Sudip Mukherjee a écrit :
> On Wed, Sep 30, 2015 at 11:04:54AM -0500, Felipe Balbi wrote:
>> On Wed, Sep 23, 2015 at 09:22:48PM +0530, Sudip Mukherjee wrote:
>>> On Mon, Sep 21, 2015 at 04:40:57PM +0530, Sudip Mukherjee wrote:
>>>> On Sun, Sep 20, 2015 at 11:15:28AM -0500, Felipe Balbi wrote:
>>>>> On Sat, Sep 19, 2015 at 10:42:58PM +0530, Sudip Mukherjee wrote:
>>>>>> While building allmodconfig on avr32 the build failed with the error:
>>>>>> "at91_pmc_base" [drivers/usb/gadget/udc/atmel_usba_udc.ko] undefined!
>>>>>>
>>>>>> On checking the code it turned out that if CONFIG_OF is defined then it
>>>>>> is using at91_pmc_read() which is using at91_pmc_base. And unless
>>>>>> COMMON_CLK_AT91 is defined we donot have at91_pmc_base. And
>>>>>> COMMON_CLK_AT91 is available with AT91 architecture.
>>>>>> Mention the dependency such that this driver builds with avr32 only if
>>>>>> OF is not enabled.
>>>>>>
>>>>>> Signed-off-by: Sudip Mukherjee <su...@vectorindia.org>
>>>>>> ---
>>>>>>
>>>>>> Tested build with at91_dt_defconfig and allmodconfig of avr32. Build log
>>>>>> at:
>>>>>> https://travis-ci.org/sudipm-mukherjee/parport/builds/81168845
>>>>>>
>>>>>>  drivers/usb/gadget/udc/Kconfig | 2 +-
>>>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>>
>>>>>> diff --git a/drivers/usb/gadget/udc/Kconfig 
>>>>>> b/drivers/usb/gadget/udc/Kconfig
>>>>>> index 9a3a6b0..cdbff54 100644
>>>>>> --- a/drivers/usb/gadget/udc/Kconfig
>>>>>> +++ b/drivers/usb/gadget/udc/Kconfig
>>>>>> @@ -55,7 +55,7 @@ config USB_LPC32XX
>>>>>>  
>>>>>>  config USB_ATMEL_USBA
>>>>>>  tristate "Atmel USBA"
>>>>>> -depends on AVR32 || ARCH_AT91
>>>>>> +depends on ((AVR32 && !OF) || ARCH_AT91)
>>>>>
>>>>> any chance you can add || COMPILE_TEST here ? I'd like to make
>>>>> sure this builds on my end too.
>>>> With "depends on ((AVR32 && !OF) || ARCH_AT91 || COMPILE_TEST)"
>>>> normal allmodconfig builiding for x86_64 failed with:
>>>>
>>>> drivers/usb/gadget/udc/atmel_usba_udc.c: In function ‘usba_start’:
>>>> drivers/usb/gadget/udc/atmel_usba_udc.c:1783:25: error: ‘USBA_ENABLE_MASK’ 
>>>> undeclared (first use in this function)
>>>>   usba_writel(udc, CTRL, USBA_ENABLE_MASK);
>>>>  ^
>>>> drivers/usb/gadget/udc/atmel_usba_udc.c: In function ‘usba_stop’:
>>>> drivers/usb/gadget/udc/atmel_usba_udc.c:1800:25: error: 
>>>> ‘USBA_DISABLE_MASK’ undeclared (first use in this function)
>>>>   usba_writel(udc, CTRL, USBA_DISABLE_MASK);
>>>>  ^
>>>>
>>>> Looks like USBA_DISABLE_MASK and USBA_ENABLE_MASK is defined under
>>>> #if defined(CONFIG_AVR32). :(
>>> Can i check anything else here? Like I said with COMPILE_TEST
>>> allmodconfig on x86_64 is failing.
>>
>> then keep it as is, but it would be nice to get that sorted out
>> so I can do compile tests on my end too.
> 
> Maybe Nicolas can give some idea. Adding Nicolas Ferre to CC.

Hi,

I'm thinking about something like this:

8<--
--- a/drivers/usb/gadget/udc/atmel_usba_udc.h
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.h
@@ -46,10 +46,10 @@
 #if defined(CONFIG_AVR32)
 #define USBA_ENABLE_MASK   USBA_EN_USBA
 #define USBA_DISABLE_MASK  0
-#elif defined(CONFIG_ARCH_AT91)
+#else
 #define USBA_ENABLE_MASK   (USBA_EN_USBA | USBA_PULLD_DIS)
 #define USBA_DISABLE_MASK  USBA_DETACH
-#endif /* CONFIG_ARCH_AT91 */
+#endif
 
 /* Bitfields in FNUM */
 #define USBA_MICRO_FRAME_NUM_OFFSET0

it can be sensible and will all to compile with the COMPILE_TEST directive.

Bye,
-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 15/16] usb: gadget: atmel: access the PMC using regmap

2015-09-30 Thread Nicolas Ferre
Le 30/09/2015 18:31, Felipe Balbi a écrit :
> On Wed, Sep 30, 2015 at 06:11:08PM +0200, Alexandre Belloni wrote:
>> Use regmap to access the PMC to avoid using at91_pmc_read and
>> at91_pmc_write.
>>
>> Signed-off-by: Alexandre Belloni <alexandre.bell...@free-electrons.com>
> 
> can I take this through my tree or does it have any dependences with the rest 
> of
> the series ?

Hi Felipe,

Well, I have the feeling that these changes would require the regmap to
be in place before using it. So yes, it has a strong dependency with the
rest of the series (and DT modifications like the 06/16 patch actually).

So, I think that Alexandre would agree with me that we should take the
whole series with us through the arm-soc tree. An alternative would be
to delay the inclusion of the USB part a little bit...

Thanks for the heads-up Felipe, Bye,
-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] usb: gadget: at91_udc: mention proper dependency

2015-09-30 Thread Nicolas Ferre
Le 30/09/2015 18:53, Sudip Mukherjee a écrit :
> On Wed, Sep 30, 2015 at 06:34:28PM +0200, Nicolas Ferre wrote:
>> Le 30/09/2015 18:24, Sudip Mukherjee a écrit :
>>> On Wed, Sep 30, 2015 at 11:04:54AM -0500, Felipe Balbi wrote:
>>>> On Wed, Sep 23, 2015 at 09:22:48PM +0530, Sudip Mukherjee wrote:
>>>>> On Mon, Sep 21, 2015 at 04:40:57PM +0530, Sudip Mukherjee wrote:
>>>>>> On Sun, Sep 20, 2015 at 11:15:28AM -0500, Felipe Balbi wrote:
>>>>>>> On Sat, Sep 19, 2015 at 10:42:58PM +0530, Sudip Mukherjee wrote:
>>>>>>>> While building allmodconfig on avr32 the build failed with the error:
>>>>>>>> "at91_pmc_base" [drivers/usb/gadget/udc/atmel_usba_udc.ko] undefined!
>>>>>>>>
>>>>>>>> On checking the code it turned out that if CONFIG_OF is defined then it
>>>>>>>> is using at91_pmc_read() which is using at91_pmc_base. And unless
>>>>>>>> COMMON_CLK_AT91 is defined we donot have at91_pmc_base. And
>>>>>>>> COMMON_CLK_AT91 is available with AT91 architecture.
>>>>>>>> Mention the dependency such that this driver builds with avr32 only if
>>>>>>>> OF is not enabled.
>>>>>>>>
>>>>>>>> Signed-off-by: Sudip Mukherjee <su...@vectorindia.org>
>>>>>>>> ---
>>>>>>>>
>>>>>>>> Tested build with at91_dt_defconfig and allmodconfig of avr32. Build 
>>>>>>>> log
>>>>>>>> at:
>>>>>>>> https://travis-ci.org/sudipm-mukherjee/parport/builds/81168845
>>>>>>>>
>>>>>>>>  drivers/usb/gadget/udc/Kconfig | 2 +-
>>>>>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>>>>
>>>>>>>> diff --git a/drivers/usb/gadget/udc/Kconfig 
>>>>>>>> b/drivers/usb/gadget/udc/Kconfig
>>>>>>>> index 9a3a6b0..cdbff54 100644
>>>>>>>> --- a/drivers/usb/gadget/udc/Kconfig
>>>>>>>> +++ b/drivers/usb/gadget/udc/Kconfig
>>>>>>>> @@ -55,7 +55,7 @@ config USB_LPC32XX
>>>>>>>>  
>>>>>>>>  config USB_ATMEL_USBA
>>>>>>>>tristate "Atmel USBA"
>>>>>>>> -  depends on AVR32 || ARCH_AT91
>>>>>>>> +  depends on ((AVR32 && !OF) || ARCH_AT91)
>>>>>>>
>>>>>>> any chance you can add || COMPILE_TEST here ? I'd like to make
>>>>>>> sure this builds on my end too.
>>>>>> With "depends on ((AVR32 && !OF) || ARCH_AT91 || COMPILE_TEST)"
>>>>>> normal allmodconfig builiding for x86_64 failed with:
>>>>>>
>>>>>> drivers/usb/gadget/udc/atmel_usba_udc.c: In function ‘usba_start’:
>>>>>> drivers/usb/gadget/udc/atmel_usba_udc.c:1783:25: error: 
>>>>>> ‘USBA_ENABLE_MASK’ undeclared (first use in this function)
>>>>>>   usba_writel(udc, CTRL, USBA_ENABLE_MASK);
>>>>>>  ^
>>>>>> drivers/usb/gadget/udc/atmel_usba_udc.c: In function ‘usba_stop’:
>>>>>> drivers/usb/gadget/udc/atmel_usba_udc.c:1800:25: error: 
>>>>>> ‘USBA_DISABLE_MASK’ undeclared (first use in this function)
>>>>>>   usba_writel(udc, CTRL, USBA_DISABLE_MASK);
>>>>>>  ^
>>>>>>
>>>>>> Looks like USBA_DISABLE_MASK and USBA_ENABLE_MASK is defined under
>>>>>> #if defined(CONFIG_AVR32). :(
>>>>> Can i check anything else here? Like I said with COMPILE_TEST
>>>>> allmodconfig on x86_64 is failing.
>>>>
>>>> then keep it as is, but it would be nice to get that sorted out
>>>> so I can do compile tests on my end too.
>>>
>>> Maybe Nicolas can give some idea. Adding Nicolas Ferre to CC.
>>
>> Hi,
>>
>> I'm thinking about something like this:
>>
>> 8<--
>> --- a/drivers/usb/gadget/udc/atmel_usba_udc.h
>> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.h
>> @@ -46,10 +46,10 @@
>>  #if defined(CONFIG_AVR32)
>>  #define USBA_ENABLE_MASK   USBA_EN_USBA
>>  #define USBA_DISABLE_MASK  0
>> -#elif defined(CONFIG_ARCH_AT91)
>> +#else
>>  #define USBA_ENABLE_MASK   (USBA_EN_USBA | 
>> USBA_PULLD_DIS)
>>  #define USBA_DISABLE_MASK  USBA_DETACH
>> -#endif /* CONFIG_ARCH_AT91 */
>> +#endif
>>  
>>  /* Bitfields in FNUM */
>>  #define USBA_MICRO_FRAME_NUM_OFFSET0
>>
>> it can be sensible and will all to compile with the COMPILE_TEST directive.
> 
> Thanks. Will test tomorrow. And my original patch of depending on
> ((AVR32 && !OF) || ARCH_AT91), is that correct?

Sounds good to me.

> Sorry that I missed ccing you while sending the patch. We should not
> always depend on getmaintainer.pl.

Well, I'm marked as maintainer for this drivers actually and
get_maintainer.pl shouldn't lie this time...

Bye,
-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: gadget: atmel: remove useless include

2015-09-18 Thread Nicolas Ferre
Le 10/08/2015 16:29, Alexandre Belloni a écrit :
> Definitions from linux/platform_data/atmel.h are not used, remove the
> include.
> 
> Signed-off-by: Alexandre Belloni <alexandre.bell...@free-electrons.com>

Acked-by: Nicolas Ferre <nicolas.fe...@atmel.com>

> ---
>  drivers/usb/gadget/udc/atmel_usba_udc.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
> b/drivers/usb/gadget/udc/atmel_usba_udc.c
> index 4095cce05e6a..548192f77dcb 100644
> --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
> @@ -22,7 +22,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: gadget: at91_udc: move at91_udc_data in at91_udc.h

2015-09-18 Thread Nicolas Ferre
Le 10/08/2015 16:46, Alexandre Belloni a écrit :
> struct at91_udc_data is now only used inside the driver, move it to its
> include.
> 
> Signed-off-by: Alexandre Belloni <alexandre.bell...@free-electrons.com>

Acked-by: Nicolas Ferre <nicolas.fe...@atmel.com>

Thanks.

> ---
>  drivers/usb/gadget/udc/at91_udc.h   | 8 
>  include/linux/platform_data/atmel.h | 9 -
>  2 files changed, 8 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/at91_udc.h 
> b/drivers/usb/gadget/udc/at91_udc.h
> index 2679c8b217cc..0a433e6b346b 100644
> --- a/drivers/usb/gadget/udc/at91_udc.h
> +++ b/drivers/usb/gadget/udc/at91_udc.h
> @@ -112,6 +112,14 @@ struct at91_udc_caps {
>   void (*pullup)(struct at91_udc *udc, int is_on);
>  };
>  
> +struct at91_udc_data {
> + int vbus_pin;   /* high == host powering us */
> + u8  vbus_active_low;/* vbus polarity */
> + u8  vbus_polled;/* Use polling, not interrupt */
> + int pullup_pin; /* active == D+ pulled up */
> + u8  pullup_active_low;  /* true == pullup_pin is active low */
> +};
> +
>  /*
>   * driver is non-SMP, and just blocks IRQs whenever it needs
>   * access protection for chip registers or driver state
> diff --git a/include/linux/platform_data/atmel.h 
> b/include/linux/platform_data/atmel.h
> index 4b452c6a2f7b..2d67e466c51b 100644
> --- a/include/linux/platform_data/atmel.h
> +++ b/include/linux/platform_data/atmel.h
> @@ -25,15 +25,6 @@
>   */
>  #define ATMEL_MAX_UART   7
>  
> - /* USB Device */
> -struct at91_udc_data {
> - int vbus_pin;   /* high == host powering us */
> - u8  vbus_active_low;/* vbus polarity */
> - u8  vbus_polled;/* Use polling, not interrupt */
> - int pullup_pin; /* active == D+ pulled up */
> - u8  pullup_active_low;  /* true == pullup_pin is active low */
> -};
> -
>   /* Compact Flash */
>  struct at91_cf_data {
>   int irq_pin;/* I/O IRQ */
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: gadget: atmel_usba_udc: add ep capabilities support on device tree binding

2015-09-18 Thread Nicolas Ferre
From: Sylvain Rochet <sylvain.roc...@finsecur.com>

The recently added endpoint capabilities flags verification breaks Atmel
USBA because the endpoint configuration was only added when the driver
is bound using the legacy pdata interface.

Convert endpoint configuration to new capabilities model when driver is
bound to a device tree as well.

Signed-off-by: Sylvain Rochet <sylvain.roc...@finsecur.com>
Fixes: 47bef3865115 ("usb: gadget: atmel_usba_udc: add ep capabilities support")
Signed-off-by: Nicolas Ferre <nicolas.fe...@atmel.com>
---
Felipe,

As you've just requested, here is the same patch sent to linux-usb ml. I had
added the "Fixes" and my SoB tags.

For the record:
It is considered as a fix for 4.3. Can you please queue it for the "4.3-rc"
phase?

Bye,


 drivers/usb/gadget/udc/atmel_usba_udc.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
b/drivers/usb/gadget/udc/atmel_usba_udc.c
index 3dfada8d6061..f0f2b066ac08 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -2002,6 +2002,17 @@ static struct usba_ep * atmel_udc_of_init(struct 
platform_device *pdev,
ep->udc = udc;
INIT_LIST_HEAD(>queue);
 
+   if (ep->index == 0) {
+   ep->ep.caps.type_control = true;
+   } else {
+   ep->ep.caps.type_iso = ep->can_isoc;
+   ep->ep.caps.type_bulk = true;
+   ep->ep.caps.type_int = true;
+   }
+
+   ep->ep.caps.dir_in = true;
+   ep->ep.caps.dir_out = true;
+
if (i)
list_add_tail(>ep.ep_list, >gadget.ep_list);
 
-- 
2.1.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 5/5] usb: gadget: atmel_usba_udc: add missing ret value check

2015-07-08 Thread Nicolas Ferre
Le 07/07/2015 16:02, Robert Baldyga a écrit :
 Add missing return value check. In case of error print debug message
 and return error code.
 
 Signed-off-by: Robert Baldyga r.bald...@samsung.com

Yes, it's indeed missing:
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com

Thanks, bye.

 ---
  drivers/usb/gadget/udc/atmel_usba_udc.c | 4 
  1 file changed, 4 insertions(+)
 
 diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
 b/drivers/usb/gadget/udc/atmel_usba_udc.c
 index 4095cce0..37d414e 100644
 --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
 +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
 @@ -1989,6 +1989,10 @@ static struct usba_ep * atmel_udc_of_init(struct 
 platform_device *pdev,
   ep-can_isoc = of_property_read_bool(pp, atmel,can-isoc);
  
   ret = of_property_read_string(pp, name, name);
 + if (ret) {
 + dev_err(pdev-dev, of_probe: name error(%d)\n, ret);
 + goto err;
 + }
   ep-ep.name = name;
  
   ep-ep_regs = udc-regs + USBA_EPT_BASE(i);
 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RESEND PATCH 2/2] ARM: at91/dt: update udc compatible strings

2015-07-02 Thread Nicolas Ferre
Le 01/07/2015 22:35, Kevin Hilman a écrit :
 Nicolas Ferre nicolas.fe...@atmel.com writes:
 
 From: Boris Brezillon boris.brezil...@free-electrons.com

 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.brezil...@free-electrons.com
 Acked-by: Alexandre Belloni alexandre.bell...@free-electrons.com
 Tested-by: Bo Shen voice.s...@atmel.com
 Acked-by: Nicolas Ferre nicolas.fe...@atmel.com
 Cc: sta...@vger.kernel.org  #4.0+
 ---
 Hi,

 This patch was forgotten while dealing with the series usb: atmel_usba_udc:
 Rework errata handling. This patch and the previous one should be added to
 mainline as fixes, the soonest. In fact, the errata handling is now broken
 because of this desynchronization.

 We'll try to queue it during 4.2-rc phase for inclusion in arm-soc tree.
 
 I've picked both of these up for the arm-soc/late branch which I'll try
 to get in before -rc1, if not it will make it for -rc2.

Brilliant! Thanks a lot Kevin.

Bye,
-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RESEND PATCH 1/2] ARM: at91/dt: trivial: fix USB udc compatible string

2015-06-17 Thread Nicolas Ferre
To please checkpatch and the tiresome reader, add the atmel, prefix to the
USB udc compatible string.

Signed-off-by: Nicolas Ferre nicolas.fe...@atmel.com
Cc: sta...@vger.kernel.org  #4.0+
---
 Documentation/devicetree/bindings/usb/atmel-usb.txt | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/atmel-usb.txt 
b/Documentation/devicetree/bindings/usb/atmel-usb.txt
index 1be8d7a26c15..5883b73ea1b5 100644
--- a/Documentation/devicetree/bindings/usb/atmel-usb.txt
+++ b/Documentation/devicetree/bindings/usb/atmel-usb.txt
@@ -79,9 +79,9 @@ Atmel High-Speed USB device controller
 
 Required properties:
  - compatible: Should be one of the following
-  at91sam9rl-udc
-  at91sam9g45-udc
-  sama5d3-udc
+  atmel,at91sam9rl-udc
+  atmel,at91sam9g45-udc
+  atmel,sama5d3-udc
  - reg: Address and length of the register set for the device
  - interrupts: Should contain usba interrupt
  - clocks: Should reference the peripheral and host clocks
-- 
2.1.3

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RESEND PATCH 2/2] ARM: at91/dt: update udc compatible strings

2015-06-17 Thread Nicolas Ferre
From: Boris Brezillon boris.brezil...@free-electrons.com

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.brezil...@free-electrons.com
Acked-by: Alexandre Belloni alexandre.bell...@free-electrons.com
Tested-by: Bo Shen voice.s...@atmel.com
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com
Cc: sta...@vger.kernel.org  #4.0+
---
Hi,

This patch was forgotten while dealing with the series usb: atmel_usba_udc:
Rework errata handling. This patch and the previous one should be added to
mainline as fixes, the soonest. In fact, the errata handling is now broken
because of this desynchronization.

We'll try to queue it during 4.2-rc phase for inclusion in arm-soc tree.

Bye,

 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 d260ba779ae5..18177f5a7464 100644
--- a/arch/arm/boot/dts/at91sam9g45.dtsi
+++ b/arch/arm/boot/dts/at91sam9g45.dtsi
@@ -1148,7 +1148,7 @@
usb2: gadget@fff78000 {
#address-cells = 1;
#size-cells = 0;
-   compatible = atmel,at91sam9rl-udc;
+   compatible = atmel,at91sam9g45-udc;
reg = 0x0060 0x8
   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 7521bdf17ef2..b6c8df8d380e 100644
--- a/arch/arm/boot/dts/at91sam9x5.dtsi
+++ b/arch/arm/boot/dts/at91sam9x5.dtsi
@@ -1108,7 +1108,7 @@
usb2: gadget@f803c000 {
#address-cells = 1;
#size-cells = 0;
-   compatible = atmel,at91sam9rl-udc;
+   compatible = atmel,at91sam9g45-udc;
reg = 0x0050 0x8
   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 5ab7548e04e1..9e2444b07bce 100644
--- a/arch/arm/boot/dts/sama5d3.dtsi
+++ b/arch/arm/boot/dts/sama5d3.dtsi
@@ -1321,7 +1321,7 @@
usb0: gadget@0050 {
#address-cells = 1;
#size-cells = 0;
-   compatible = atmel,at91sam9rl-udc;
+   compatible = atmel,sama5d3-udc;
reg = 0x0050 0x10
   0xf803 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 653a1f851f2b..3ee22ee13c5a 100644
--- a/arch/arm/boot/dts/sama5d4.dtsi
+++ b/arch/arm/boot/dts/sama5d4.dtsi
@@ -127,7 +127,7 @@
usb0: gadget@0040 {
#address-cells = 1;
#size-cells = 0;
-   compatible = atmel,at91sam9rl-udc;
+   compatible = atmel,sama5d3-udc;
reg = 0x0040 0x10
   0xfc02c000 0x4000;
interrupts = 47 IRQ_TYPE_LEVEL_HIGH 2;
-- 
2.1.3

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: gadget: atmel: fix build warning

2015-05-28 Thread Nicolas Ferre
Le 26/05/2015 22:38, Felipe Balbi a écrit :
 This patch fixes the following build warning:
 
 drivers/usb/gadget/udc/atmel_usba_udc.c:707:2: warning: format ‘%x’
 expects argument of type ‘unsigned int’, but argument 4 has type
 ‘dma_addr_t’ [-Wformat=]
 
 Signed-off-by: Felipe Balbi ba...@ti.com

Acked-by: Nicolas Ferre nicolas.fe...@atmel.com
Thanks Felipe!

Bye,

 ---
  drivers/usb/gadget/udc/atmel_usba_udc.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
 b/drivers/usb/gadget/udc/atmel_usba_udc.c
 index 4c01953a0869..5437346908e7 100644
 --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
 +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
 @@ -704,8 +704,8 @@ static int queue_dma(struct usba_udc *udc, struct usba_ep 
 *ep,
   unsigned long flags;
   int ret;
  
 - DBG(DBG_DMA, %s: req l/%u d/%08x %c%c%c\n,
 - ep-ep.name, req-req.length, req-req.dma,
 + DBG(DBG_DMA, %s: req l/%u d/%pad %c%c%c\n,
 + ep-ep.name, req-req.length, req-req.dma,
   req-req.zero ? 'Z' : 'z',
   req-req.short_not_ok ? 'S' : 's',
   req-req.no_interrupt ? 'I' : 'i');
 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/5] USB: atmel: rework clock handling

2015-05-22 Thread Nicolas Ferre
Le 17/03/2015 17:15, Boris Brezillon a écrit :
 Hello,
 
 This series reworks clock handling in atmel USB host drivers, and while
 doing so fixes a regression introduced by 3440ef1 (ARM: at91/dt: fix USB
 high-speed clock to select UTMI).
 
 Best Regards,
 
 Boris
 
 Boris Brezillon (5):
   USB: ehci-atmel: rework clk handling
   USB: host: ohci-at91: remove useless uclk clock

Now that these ones  are in Linus' tree...

...these patches vvv

   USB: atmel: update DT bindings documentation
   ARM: at91/dt: remove useless uhpck clock references from ehci
 defintions
   ARM: at91/dt: remove useless usb clock

^ can be queued in at91-4.2-dt. They will go through the arm-soc route.

And BTW:
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com


Thanks Boris, bye.

  .../devicetree/bindings/usb/atmel-usb.txt  | 25 ++
  arch/arm/boot/dts/at91rm9200.dtsi  |  4 +--
  arch/arm/boot/dts/at91sam9260.dtsi |  4 +--
  arch/arm/boot/dts/at91sam9261.dtsi |  4 +--
  arch/arm/boot/dts/at91sam9263.dtsi |  4 +--
  arch/arm/boot/dts/at91sam9g45.dtsi |  8 +++---
  arch/arm/boot/dts/at91sam9n12.dtsi |  5 ++--
  arch/arm/boot/dts/at91sam9x5.dtsi  |  8 +++---
  arch/arm/boot/dts/sama5d3.dtsi |  9 +++
  arch/arm/boot/dts/sama5d4.dtsi |  9 +++
  drivers/usb/host/ehci-atmel.c  | 30 
 +++---
  drivers/usb/host/ohci-at91.c   | 18 +++--
  12 files changed, 63 insertions(+), 65 deletions(-)
 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC 5/6] usb: gadget: atmel_usba: use atmel_io.h to provide on-chip IO

2015-04-28 Thread Nicolas Ferre
Le 28/04/2015 17:40, Ben Dooks a écrit :
 

 /* Register access macros */ -#ifdef CONFIG_AVR32 -#define
 usba_io_readl  __raw_readl -#define usba_io_writel __raw_writel 
 -#define usba_io_writew__raw_writew -#else -#define
 usba_io_readl  readl_relaxed -#define usba_io_writel
 writel_relaxed -#define usba_io_writew writew_relaxed -#endif 
 +#define usba_io_readl atmel_oc_readl +#define usba_io_writel
 atmel_oc_writel +#define usba_io_writewatmel_oc_writew

 Same comment as earlier patch, it would be nice to remove the
 define usba_io_{read,write}{l,w} defines in a follow-up patch.
 
 I'm fine with this too. Is this targetted at v4.2 ?
 
 Yes, although we may move it to the soc specific include directories
 to avoid adding more to linux/

BTW, Ben, what _oc_ stands for in the new macro name?

Bye,
-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/5] USB: host: ohci-at91: remove useless uclk clock

2015-03-23 Thread Nicolas Ferre
Le 17/03/2015 20:02, Alan Stern a écrit :
 On Tue, 17 Mar 2015, Boris Brezillon wrote:
 
 Now that the system clock driver is forwarding set_rate request to the
 parent clock, we can safely call clk_set_rate on the system clk and get
 rid of the uclk field.

 Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
 
 Acked-by: Alan Stern st...@rowland.harvard.edu

Acked-by: Nicolas Ferre nicolas.fe...@atmel.com

Hi Alan,

As I don't have any other drivers patch for 4.1, would you mind taking
this patch with your tree?
I'll take care of the remaining ones dealing with Device Tree: they are
independent anyway.

Thanks, bye.
-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/5] USB: ehci-atmel: rework clk handling

2015-03-18 Thread Nicolas Ferre
Le 17/03/2015 20:01, Alan Stern a écrit :
 On Tue, 17 Mar 2015, Boris Brezillon wrote:
 
 The EHCI IP only needs the UTMI/UPLL (uclk) and the peripheral (iclk)
 clocks to work properly. Remove the useless system clock (fclk).

 Avoid calling set_rate on the fixed rate UTMI/IPLL clock and remove
 useless IS_ENABLED(CONFIG_COMMON_CLK) tests (all at91 platforms have been
 moved to the CCF).

 This patch also fixes a bug introduced by 3440ef1 (ARM: at91/dt: fix USB
 high-speed clock to select UTMI), which was leaving the usb clock
 uninitialized and preventing the OHCI driver from setting the usb clock
 rate to 48MHz.
 This bug was caused by several things:
 1/ usb clock drivers set the CLK_SET_RATE_GATE flag, which means the rate
cannot be changed once the clock is prepared
 2/ The EHCI driver was retrieving and preparing/enabling the uhpck
clock which was in turn preparing its parent clock (the usb clock),
thus preventing any rate change because of 1/

 Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
 
 Acked-by: Alan Stern st...@rowland.harvard.edu

Acked-by: Nicolas Ferre nicolas.fe...@atmel.com
and:
Fixes: 3440ef169100 (ARM: at91/dt: fix USB high-speed clock to select UTMI)

Alan, Greg,

Can you please take this patch (only this patch 1/5 of the series) as a fix 
for the 4.0-rc? It would solve the issue that we see on at91sam9x5/at91sam9n12.
I'll take care of the rest of the series for 4.1.

If you want me to take it of to re-send the patch, tell me.

Thanks, bye,
-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv7 0/4] USB: gadget: atmel_usba_udc: PM driver improvements

2015-03-04 Thread Nicolas Ferre
Le 12/02/2015 18:54, Sylvain Rochet a écrit :
 Start clocks on rising edge of the Vbus signal, stop clocks on falling
 edge of the Vbus signal.
 
 Add suspend/resume with wakeup support.

Hi Felipe,

I think this series by Sylvain is ready for inclusion. Are you able to
take it for the next cycle?

Thank, bye,


 Changes since v6:
   * Removed single IRQ edge support, which was used to wake up only on 
 device connection. We don't have yet a clean solution to handle IRQ
 controller with (at91sam9x5) and without (at91rm9200) single edge 
 support. Rework PATCH v6 4/5 removed, we don't need this one anymore.
 
 Changes since v5:
   * Some boards does not support configuring a GPIO interrupt on a specific
 edge (rising only or falling only). As suggested added a config boolean
 to distinguish between boards with and without support
   * Added a missing mutex_lock()/unlock() in usba_udc_suspend(), we need to
 protect usba_stop() because usba_start() and usba_stop() can still
 be called by Vbus IRQ handler.
   * Rebased the full series on linux-next
   * Patch cleaning with the help of checkpatch.pl
 
 Changes since v4:
   * Now using IRQ_NOAUTOEN flag to remove the unused check for
 udc-driver is not NULL in the Vbus IRQ.
   * Reworked the start/stop of clocks on Vbus edges to prepare for
 suspend/resume support, factorised start and stop procedures
   * New patch, suspend/resume for USBA with wakeup support
 
 Changes since v3:
   * Added stable tag for the first patch
   * As suggested, removed the unused check for udc-driver is NULL in
 Vbus IRQ by requesting IRQ after udc-driver is set and by releasing
 IRQ before udc-driver is cleared
   * Rebased the core patch of this series against the just explained changes
 
 Changes since v2:
   * Use spin_lock_irqsave/unlock_irqrestore instead of spin_lock/unlock in
 threaded interrupt because we are not in irq context anymore
   * Removed useless and probably harmful IRQF_NO_SUSPEND from
 devm_request_threaded_irq() flags
 
 Changes since v1:
   * Using a threaded irq and mutex instead of spinclock as suggested
   * Moved a silently fixed bug in a separate patch (1/2)
 
 Sylvain Rochet (4):
   USB: gadget: atmel_usba_udc: Fixed vbus_prev initial state
   USB: gadget: atmel_usba_udc: Request an auto disabled Vbus signal IRQ
 instead of an auto enabled IRQ request followed by IRQ disable
   USB: gadget: atmel_usba_udc: Start clocks on rising edge of the Vbus
 signal, stop clocks on falling edge of the Vbus signal
   USB: gadget: atmel_usba_udc: Add suspend/resume with wakeup support
 
  drivers/usb/gadget/udc/atmel_usba_udc.c | 208 
 
  drivers/usb/gadget/udc/atmel_usba_udc.h |   4 +
  2 files changed, 159 insertions(+), 53 deletions(-)
 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 0/2] ARM: at91: dt: at91sam9n12ek: enable udp device

2015-03-04 Thread Nicolas Ferre
Le 02/03/2015 10:32, Bo Shen a écrit :
 Hi Nicolas,
 
 On 02/10/2015 09:55 AM, Bo Shen wrote:
 This patch series enable usb device support on at91sam9n12ek board.

 Changes in v2:
- Base on next-20150209 (so, remove the modification of udc driver).
- Add pinctrl for usb1 vbus sense.

 Bo Shen (2):
ARM: at91: dt: at91sam9n12: add udp device node
ARM: at91: dt: at91sam9n12ek: enable udp
 
 Any comments for this patch series? (aka ping?)

Hi,

For the 2 patches:
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com

And I've just taken these 2 patches on top of the at91-4.1-dt branch.

Thanks for the heads up !

Bye,

   arch/arm/boot/dts/at91sam9n12.dtsi  |  9 +
   arch/arm/boot/dts/at91sam9n12ek.dts | 14 ++
   2 files changed, 23 insertions(+)

 
 Best Regards,
 Bo Shen
 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv7 4/4] USB: gadget: atmel_usba_udc: Add suspend/resume with wakeup support

2015-03-04 Thread Nicolas Ferre
Le 12/02/2015 18:54, Sylvain Rochet a écrit :
 This patch add suspend/resume with wakeup support for Atmel USBA.
 
 On suspend: We stay continuously clocked if Vbus signal is not
 available. If Vbus signal is available we set the Vbus signal as a wake
 up source then we stop the USBA itself and all clocks used by USBA.
 
 On resume: We recover clocks and USBA if we stopped them. If a device is
 currently connected at resume time we enable the controller.
 
 Signed-off-by: Sylvain Rochet sylvain.roc...@finsecur.com
 Acked-by: Boris Brezillon boris.brezil...@free-electrons.com

Acked-by: Nicolas Ferre nicolas.fe...@atmel.com

 ---
  drivers/usb/gadget/udc/atmel_usba_udc.c | 57 
 +
  1 file changed, 57 insertions(+)
 
 diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
 b/drivers/usb/gadget/udc/atmel_usba_udc.c
 index 999e2f2..d019b6c 100644
 --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
 +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
 @@ -2177,6 +2177,7 @@ static int usba_udc_probe(struct platform_device *pdev)
   ret = usb_add_gadget_udc(pdev-dev, udc-gadget);
   if (ret)
   return ret;
 + device_init_wakeup(pdev-dev, 1);
  
   usba_init_debugfs(udc);
   for (i = 1; i  udc-num_ep; i++)
 @@ -2192,6 +2193,7 @@ static int __exit usba_udc_remove(struct 
 platform_device *pdev)
  
   udc = platform_get_drvdata(pdev);
  
 + device_init_wakeup(pdev-dev, 0);
   usb_del_gadget_udc(udc-gadget);
  
   for (i = 1; i  udc-num_ep; i++)
 @@ -2201,10 +2203,65 @@ static int __exit usba_udc_remove(struct 
 platform_device *pdev)
   return 0;
  }
  
 +#ifdef CONFIG_PM
 +static int usba_udc_suspend(struct device *dev)
 +{
 + struct usba_udc *udc = dev_get_drvdata(dev);
 +
 + /* Not started */
 + if (!udc-driver)
 + return 0;
 +
 + mutex_lock(udc-vbus_mutex);
 +
 + if (!device_may_wakeup(dev)) {
 + usba_stop(udc);
 + goto out;
 + }
 +
 + /*
 +  * Device may wake up. We stay clocked if we failed
 +  * to request vbus irq, assuming always on.
 +  */
 + if (gpio_is_valid(udc-vbus_pin)) {
 + usba_stop(udc);
 + enable_irq_wake(gpio_to_irq(udc-vbus_pin));
 + }
 +
 +out:
 + mutex_unlock(udc-vbus_mutex);
 + return 0;
 +}
 +
 +static int usba_udc_resume(struct device *dev)
 +{
 + struct usba_udc *udc = dev_get_drvdata(dev);
 +
 + /* Not started */
 + if (!udc-driver)
 + return 0;
 +
 + if (device_may_wakeup(dev)  gpio_is_valid(udc-vbus_pin))
 + disable_irq_wake(gpio_to_irq(udc-vbus_pin));
 +
 + /* If Vbus is present, enable the controller and wait for reset */
 + mutex_lock(udc-vbus_mutex);
 + udc-vbus_prev = vbus_is_present(udc);
 + if (udc-vbus_prev)
 + usba_start(udc);
 + mutex_unlock(udc-vbus_mutex);
 +
 + return 0;
 +}
 +#endif
 +
 +static SIMPLE_DEV_PM_OPS(usba_udc_pm_ops, usba_udc_suspend, usba_udc_resume);
 +
  static struct platform_driver udc_driver = {
   .remove = __exit_p(usba_udc_remove),
   .driver = {
   .name   = atmel_usba_udc,
 + .pm = usba_udc_pm_ops,
   .of_match_table = of_match_ptr(atmel_udc_dt_ids),
   },
  };
 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv6 5/5] USB: gadget: atmel_usba_udc: Add suspend/resume with wakeup support

2015-02-05 Thread Nicolas Ferre
Le 22/01/2015 17:56, Sylvain Rochet a écrit :
 This patch add suspend/resume with wakeup support for Atmel USBA.
 
 On suspend: We stay continuously clocked if Vbus signal is not
 available. If Vbus signal is available we set the Vbus signal as a wake
 up source then we stop the USBA itself and all clocks used by USBA.
 
 On resume: We recover clocks and USBA if we stopped them. If a device is
 currently connected at resume time we enable the controller.
 
 Signed-off-by: Sylvain Rochet sylvain.roc...@finsecur.com
 Acked-by: Boris Brezillon boris.brezil...@free-electrons.com
 ---
  drivers/usb/gadget/udc/atmel_usba_udc.c | 68 
 +
  1 file changed, 68 insertions(+)
 
 diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
 b/drivers/usb/gadget/udc/atmel_usba_udc.c
 index 361f740..7942c2f 100644
 --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
 +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
 @@ -2178,6 +2178,7 @@ static int usba_udc_probe(struct platform_device *pdev)
   ret = usb_add_gadget_udc(pdev-dev, udc-gadget);
   if (ret)
   return ret;
 + device_init_wakeup(pdev-dev, 1);
  
   usba_init_debugfs(udc);
   for (i = 1; i  udc-num_ep; i++)
 @@ -2193,6 +2194,7 @@ static int __exit usba_udc_remove(struct 
 platform_device *pdev)
  
   udc = platform_get_drvdata(pdev);
  
 + device_init_wakeup(pdev-dev, 0);
   usb_del_gadget_udc(udc-gadget);
  
   for (i = 1; i  udc-num_ep; i++)
 @@ -2202,10 +2204,76 @@ static int __exit usba_udc_remove(struct 
 platform_device *pdev)
   return 0;
  }
  
 +#ifdef CONFIG_PM
 +static int usba_udc_suspend(struct device *dev)
 +{
 + struct usba_udc *udc = dev_get_drvdata(dev);
 +
 + /* Not started */
 + if (!udc-driver)
 + return 0;
 +
 + mutex_lock(udc-vbus_mutex);
 +
 + if (!device_may_wakeup(dev)) {
 + usba_stop(udc);
 + goto out;
 + }
 +
 + /*
 +  * Device may wake up. We stay clocked if we failed
 +  * to request vbus irq, assuming always on.
 +  */
 + if (gpio_is_valid(udc-vbus_pin)) {
 + usba_stop(udc);
 + /* Only wake up on device connection */
 + if (udc-caps  udc-caps-irq_single_edge_support)
 + irq_set_irq_type(gpio_to_irq(udc-vbus_pin),
 + udc-vbus_pin_inverted ?
 + IRQ_TYPE_EDGE_FALLING : IRQ_TYPE_EDGE_RISING);

As said earlier, let's try another approach for this.

Bye,

 +
 + enable_irq_wake(gpio_to_irq(udc-vbus_pin));
 + }
 +
 +out:
 + mutex_unlock(udc-vbus_mutex);
 + return 0;
 +}
 +
 +static int usba_udc_resume(struct device *dev)
 +{
 + struct usba_udc *udc = dev_get_drvdata(dev);
 +
 + /* Not started */
 + if (!udc-driver)
 + return 0;
 +
 + if (device_may_wakeup(dev)  gpio_is_valid(udc-vbus_pin)) {
 + disable_irq_wake(gpio_to_irq(udc-vbus_pin));
 +
 + if (udc-caps  udc-caps-irq_single_edge_support)
 + irq_set_irq_type(gpio_to_irq(udc-vbus_pin),
 + IRQ_TYPE_EDGE_BOTH);
 + }
 +
 + /* If Vbus is present, enable the controller and wait for reset */
 + mutex_lock(udc-vbus_mutex);
 + udc-vbus_prev = vbus_is_present(udc);
 + if (udc-vbus_prev)
 + usba_start(udc);
 + mutex_unlock(udc-vbus_mutex);
 +
 + return 0;
 +}
 +#endif
 +
 +static SIMPLE_DEV_PM_OPS(usba_udc_pm_ops, usba_udc_suspend, usba_udc_resume);
 +
  static struct platform_driver udc_driver = {
   .remove = __exit_p(usba_udc_remove),
   .driver = {
   .name   = atmel_usba_udc,
 + .pm = usba_udc_pm_ops,
   .of_match_table = of_match_ptr(atmel_udc_dt_ids),
   },
  };
 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv6 4/5] USB: gadget: atmel_usba_udc: Prepare for IRQ single edge support

2015-02-05 Thread Nicolas Ferre
Le 22/01/2015 18:14, Boris Brezillon a écrit :
 On Thu, 22 Jan 2015 17:56:44 +0100
 Sylvain Rochet sylvain.roc...@finsecur.com wrote:
 
 Renamed struct usba_udc_errata to struct usba_udc_caps, we are adding a
 new property which is not about errata, this way the struct is not
 misnamed.

 New struct usba_udc_caps property: irq_single_edge_support, boolean,
 set to true if the board supports IRQ_TYPE_EDGE_FALLING and
 IRQ_TYPE_EDGE_RISING, otherwise set to false.

 Signed-off-by: Sylvain Rochet sylvain.roc...@finsecur.com
 
 Acked-by: Boris Brezillon boris.brezil...@free-electrons.com

Some comments:

 ---
  drivers/usb/gadget/udc/atmel_usba_udc.c | 25 +++--
  drivers/usb/gadget/udc/atmel_usba_udc.h |  5 +++--
  2 files changed, 18 insertions(+), 12 deletions(-)

 diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
 b/drivers/usb/gadget/udc/atmel_usba_udc.c
 index d554106..361f740 100644
 --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
 +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
 @@ -338,8 +338,8 @@ static int vbus_is_present(struct usba_udc *udc)
  
  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);
 +if (udc-caps  udc-caps-toggle_bias)
 +udc-caps-toggle_bias(udc, is_on);
  }
  
  static void generate_bias_pulse(struct usba_udc *udc)
 @@ -347,8 +347,8 @@ 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);
 +if (udc-caps  udc-caps-pulse_bias)
 +udc-caps-pulse_bias(udc);
  
  udc-bias_pulse_needed = false;
  }
 @@ -1901,18 +1901,23 @@ static void at91sam9g45_pulse_bias(struct usba_udc 
 *udc)
  at91_pmc_write(AT91_CKGR_UCKR, uckr | AT91_PMC_BIASEN);
  }
  
 -static const struct usba_udc_errata at91sam9rl_errata = {
 +static const struct usba_udc_caps at91sam9rl_caps = {
  .toggle_bias = at91sam9rl_toggle_bias,
  };
  
 -static const struct usba_udc_errata at91sam9g45_errata = {
 +static const struct usba_udc_caps at91sam9g45_caps = {
  .pulse_bias = at91sam9g45_pulse_bias,
 +.irq_single_edge_support = true,

Nope! at91sam9g45 doesn't have this property. You'll have to create
another compatible string and capabilities structure
(atmel,at91sam9x5-udc)

But still, I don't know if it's the proper approach. The possibility tro
trigger an IRQ on both edges or a single edge is a capacity of the gpio
controller, not the USBA IP. So, it's a little bit strange to have this
capability here.

I don't know if it's actually feasible but trying to configure the IRQ
on a single edge, testing if it's accepted by the GPIO irq controller
and if not, falling back to a both edge pattern. Doesn't it look like
a way to workaround this issue nicely? Can you give it a try?

Bye,

 +};
 +
 +static const struct usba_udc_caps sama5d3_caps = {
 +.irq_single_edge_support = true,
  };
  
  static const struct of_device_id atmel_udc_dt_ids[] = {
 -{ .compatible = atmel,at91sam9rl-udc, .data = at91sam9rl_errata },
 -{ .compatible = atmel,at91sam9g45-udc, .data = at91sam9g45_errata },
 -{ .compatible = atmel,sama5d3-udc },
 +{ .compatible = atmel,at91sam9rl-udc, .data = at91sam9rl_caps },
 +{ .compatible = atmel,at91sam9g45-udc, .data = at91sam9g45_caps },
 +{ .compatible = atmel,sama5d3-udc, .data = sama5d3_caps },
  { /* sentinel */ }
  };
  
 @@ -1934,7 +1939,7 @@ static struct usba_ep * atmel_udc_of_init(struct 
 platform_device *pdev,
  if (!match)
  return ERR_PTR(-EINVAL);
  
 -udc-errata = match-data;
 +udc-caps = match-data;
  
  udc-num_ep = 0;
  
 diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.h 
 b/drivers/usb/gadget/udc/atmel_usba_udc.h
 index 085749a..4fe4c87 100644
 --- a/drivers/usb/gadget/udc/atmel_usba_udc.h
 +++ b/drivers/usb/gadget/udc/atmel_usba_udc.h
 @@ -304,9 +304,10 @@ struct usba_request {
  unsigned intmapped:1;
  };
  
 -struct usba_udc_errata {
 +struct usba_udc_caps {
  void (*toggle_bias)(struct usba_udc *udc, int is_on);
  void (*pulse_bias)(struct usba_udc *udc);
 +bool irq_single_edge_support;
  };
  
  struct usba_udc {
 @@ -322,7 +323,7 @@ struct usba_udc {
  struct usb_gadget gadget;
  struct usb_gadget_driver *driver;
  struct platform_device *pdev;
 -const struct usba_udc_errata *errata;
 +const struct usba_udc_caps *caps;
  int irq;
  int vbus_pin;
  int vbus_pin_inverted;
 
 
 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv6 2/5] USB: gadget: atmel_usba_udc: Request an auto disabled Vbus signal IRQ instead of an auto enabled IRQ request followed by IRQ disable

2015-02-05 Thread Nicolas Ferre
Le 22/01/2015 17:56, Sylvain Rochet a écrit :
 Vbus IRQ handler needs a started UDC driver to work because it uses
 udc-driver, which is set by the UDC start handler. The previous way
 chosen was to return from interrupt if udc-driver is NULL using a
 spinlock around the check.
 
 We now request an auto disabled (IRQ_NOAUTOEN) Vbus signal IRQ instead
 of an auto enabled IRQ followed by disable_irq(). This way we remove the
 very small timeslot of enabled IRQ which existed previously between
 request() and disable(). We don't need anymore to check if udc-driver
 is NULL in IRQ handler.
 
 Signed-off-by: Sylvain Rochet sylvain.roc...@finsecur.com
 Suggested-by: Boris Brezillon boris.brezil...@free-electrons.com
 Acked-by: Boris Brezillon boris.brezil...@free-electrons.com

Acked-by: Nicolas Ferre nicolas.fe...@atmel.com

 ---
  drivers/usb/gadget/udc/atmel_usba_udc.c | 9 ++---
  1 file changed, 2 insertions(+), 7 deletions(-)
 
 diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
 b/drivers/usb/gadget/udc/atmel_usba_udc.c
 index 40e5fc7..f9f305f 100644
 --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
 +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
 @@ -1745,10 +1745,6 @@ static irqreturn_t usba_vbus_irq(int irq, void *devid)
  
   spin_lock(udc-lock);
  
 - /* May happen if Vbus pin toggles during probe() */
 - if (!udc-driver)
 - goto out;
 -
   vbus = vbus_is_present(udc);
   if (vbus != udc-vbus_prev) {
   if (vbus) {
 @@ -1769,7 +1765,6 @@ static irqreturn_t usba_vbus_irq(int irq, void *devid)
   udc-vbus_prev = vbus;
   }
  
 -out:
   spin_unlock(udc-lock);
  
   return IRQ_HANDLED;
 @@ -2109,6 +2104,8 @@ static int usba_udc_probe(struct platform_device *pdev)
  
   if (gpio_is_valid(udc-vbus_pin)) {
   if (!devm_gpio_request(pdev-dev, udc-vbus_pin, 
 atmel_usba_udc)) {
 + irq_set_status_flags(gpio_to_irq(udc-vbus_pin),
 + IRQ_NOAUTOEN);
   ret = devm_request_irq(pdev-dev,
   gpio_to_irq(udc-vbus_pin),
   usba_vbus_irq, 0,
 @@ -2118,8 +2115,6 @@ static int usba_udc_probe(struct platform_device *pdev)
   dev_warn(udc-pdev-dev,
failed to request vbus irq; 
assuming always on\n);
 - } else {
 - disable_irq(gpio_to_irq(udc-vbus_pin));
   }
   } else {
   /* gpio_request fail so use -EINVAL for gpio_is_valid */
 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv6 2/5] USB: gadget: atmel_usba_udc: Request an auto disabled Vbus signal IRQ instead of an auto enabled IRQ request followed by IRQ disable

2015-01-23 Thread Nicolas Ferre
Le 23/01/2015 08:43, Jean-Christophe PLAGNIOL-VILLARD a écrit :
 
 On Jan 23, 2015, at 12:56 AM, Sylvain Rochet sylvain.roc...@finsecur.com 
 wrote:

 Vbus IRQ handler needs a started UDC driver to work because it uses
 udc-driver, which is set by the UDC start handler. The previous way
 chosen was to return from interrupt if udc-driver is NULL using a
 spinlock around the check.

 We now request an auto disabled (IRQ_NOAUTOEN) Vbus signal IRQ instead
 of an auto enabled IRQ followed by disable_irq(). This way we remove the
 very small timeslot of enabled IRQ which existed previously between
 request() and disable(). We don't need anymore to check if udc-driver
 is NULL in IRQ handler.

 Signed-off-by: Sylvain Rochet sylvain.roc...@finsecur.com
 Suggested-by: Boris Brezillon boris.brezil...@free-electrons.com
 Acked-by: Boris Brezillon boris.brezil...@free-electrons.com
 ---
 drivers/usb/gadget/udc/atmel_usba_udc.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

 diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
 b/drivers/usb/gadget/udc/atmel_usba_udc.c
 index 40e5fc7..f9f305f 100644
 --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
 +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
 @@ -1745,10 +1745,6 @@ static irqreturn_t usba_vbus_irq(int irq, void *devid)

  spin_lock(udc-lock);

 -/* May happen if Vbus pin toggles during probe() */
 -if (!udc-driver)
 -goto out;
 -
  vbus = vbus_is_present(udc);
  if (vbus != udc-vbus_prev) {
  if (vbus) {
 @@ -1769,7 +1765,6 @@ static irqreturn_t usba_vbus_irq(int irq, void *devid)
  udc-vbus_prev = vbus;
  }

 -out:
  spin_unlock(udc-lock);

  return IRQ_HANDLED;
 @@ -2109,6 +2104,8 @@ static int usba_udc_probe(struct platform_device *pdev)

  if (gpio_is_valid(udc-vbus_pin)) {
  if (!devm_gpio_request(pdev-dev, udc-vbus_pin, 
 atmel_usba_udc)) {
 +irq_set_status_flags(gpio_to_irq(udc-vbus_pin),
 +IRQ_NOAUTOEN);
 
 not happy about still using the broken gpio_to_irq API
 
 Linus can pass the IRQ via board file?
 
 and via DT we can use IRQ directly

Absolutely not the topic of this patch series.
Maybe the subject of another patch later?

Best regards,


  ret = devm_request_irq(pdev-dev,
  gpio_to_irq(udc-vbus_pin),
  usba_vbus_irq, 0,
 @@ -2118,8 +2115,6 @@ static int usba_udc_probe(struct platform_device *pdev)
  dev_warn(udc-pdev-dev,
   failed to request vbus irq; 
   assuming always on\n);
 -} else {
 -disable_irq(gpio_to_irq(udc-vbus_pin));
  }
  } else {
  /* gpio_request fail so use -EINVAL for gpio_is_valid */
 -- 
 2.1.4


 ___
 linux-arm-kernel mailing list
 linux-arm-ker...@lists.infradead.org
 http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
 
 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv3 1/2] USB: gadget: atmel_usba_udc: Fixed vbus_prev initial state

2015-01-20 Thread Nicolas Ferre
Le 20/01/2015 12:02, Sylvain Rochet a écrit :
 Hello,
 
 On Mon, Jan 19, 2015 at 12:55:47PM -0600, Felipe Balbi wrote:
 On Mon, Jan 19, 2015 at 03:09:44PM +0100, Nicolas Ferre wrote:
 Le 18/01/2015 18:24, Sylvain Rochet a écrit :
 If vbus gpio is high at init, we should set vbus_prev to true
 accordingly to the current vbus state. Without that, we skip the first
 vbus interrupt because the saved vbus state is not consistent.

 Signed-off-by: Sylvain Rochet sylvain.roc...@finsecur.com

 Indeed:
 Acked-by: Nicolas Ferre nicolas.fe...@atmel.com

 We can also add the following tags:
 Fixes: 914a3f3b3754 (USB: add atmel_usba_udc driver)
 Cc: sta...@vger.kernel.org # 2.6.x-ish

 Please resend with the proper stable format. Also, this 2.6.x-ish should
 be 2.6.24+, git describe helps a lot figuring these out.
 
 Unfortunately I failed to understand what I should do. The Also 
 keyword means for me that there are two differents things to fix:
 
 1. proper stable format
 2. 2.6.x-ish → 2.6.24+
 
   2. does not imply fixing 1., isn'it ?

Well, I think it does. My understanding is that fixing '2' is the solution.


 I read SubmittingPatches thoroughly and I can't find a reference to 
 stable format.
 
 Sylvain

Bye,
-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv6 0/6] USB: host: Atmel OHCI and EHCI drivers improvements

2015-01-20 Thread Nicolas Ferre
Le 19/01/2015 12:06, Sylvain Rochet a écrit :
 USB: host: Atmel OHCI and EHCI drivers improvements
 
 Suspend/resume support for EHCI.
 struct dev_pm_ops for OHCI.
 Removed global variables from both.
 Fixed OHCI wake up support for STANDBY(wake-up enabled) and MEM(wake-up
 disabled) sleep targets.
 
 Changes since v5:
   * Don't overwrite device wakeup flag with device_init_wakeup(),
 now using a private wakeup bool instead.
 
 Changes since v4:
   * Re-add at91_suspend_entering_slow_clock() to OHCI, we can't naively
 remove this one, this device needs to be continuously clocked to
 provide wake up support.
 The removal of at91_suspend_entering_slow_clock() actually lighted up
 an issue on wake up support, which is now fixed.
 
 Changes since v3:
   * Using struct dev_pm_ops instead of static struct platform_driver
 resume and suspend bindings for both EHCI and OHCI
   * Fixed inconsistency in patch subjects, _ intead of - for file names
   * Patch cleaning with the help of checkpatch.pl, fixed lines over
 80 characters
 
 Changes since v2:
   * Added patchs from an other submission, because this series
 depended on this one
 * EHCI: Move global variables to private struct
 * OHCI: Move global variables to private struct
   * Using ohci-priv and ehci-priv instead of hcd-hcd_priv,
 which were not the right way to do that
 
 Changes since v1:
   * Don't use at91_suspend_entering_slow_clock() on EHCI,
 we are trying to get read of this of this function
   * Removed at91_suspend_entering_slow_clock() from OHCI
 
 Sylvain Rochet (6):
   USB: host: ehci-atmel: Add suspend/resume support
   USB: host: ohci-at91: Use struct dev_pm_ops instead of struct
 platform_driver
   USB: host: ehci-atmel: Move global variables to private struct
   USB: host: ohci-at91: Move global variables to private struct
   USB: host: ohci-at91: usb_hcd_at91_probe(), remove useless stack
 initialisation
   USB: host: ohci-at91: Fix wake-up support
 
  drivers/usb/host/ehci-atmel.c | 102 +-
  drivers/usb/host/ohci-at91.c  | 126 
 ++
  2 files changed, 154 insertions(+), 74 deletions(-)

As already mentioned for the v5, I'm okay with the whole series:
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com

So Sylvain, as said by Alan, I think you can now collect all the
Acked-by tags (Alex had also sent some if I recall well) and re-send a
clean v7 series to Greg KH.

BTW, for rewriting this series' logs, I suggest you to use:
git filter-branch -f --msg-filter ... ;-)

Bye,
-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv3 1/2] USB: gadget: atmel_usba_udc: Fixed vbus_prev initial state

2015-01-19 Thread Nicolas Ferre
Le 18/01/2015 18:24, Sylvain Rochet a écrit :
 If vbus gpio is high at init, we should set vbus_prev to true
 accordingly to the current vbus state. Without that, we skip the first
 vbus interrupt because the saved vbus state is not consistent.
 
 Signed-off-by: Sylvain Rochet sylvain.roc...@finsecur.com

Indeed:
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com

We can also add the following tags:
Fixes: 914a3f3b3754 (USB: add atmel_usba_udc driver)
Cc: sta...@vger.kernel.org # 2.6.x-ish

Bye,


 ---
  drivers/usb/gadget/udc/atmel_usba_udc.c | 2 ++
  1 file changed, 2 insertions(+)
 
 diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
 b/drivers/usb/gadget/udc/atmel_usba_udc.c
 index ce88237..e207d75 100644
 --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
 +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
 @@ -1791,6 +1791,8 @@ static int atmel_usba_start(struct usb_gadget *gadget,
   toggle_bias(1);
   usba_writel(udc, CTRL, USBA_ENABLE_MASK);
   usba_writel(udc, INT_ENB, USBA_END_OF_RESET);
 +
 + udc-vbus_prev = 1;
   }
   spin_unlock_irqrestore(udc-lock, flags);
  
 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv3 2/2] USB: gadget: atmel_usba_udc: Enable/disable USB PLL on Vbus change

2015-01-19 Thread Nicolas Ferre
(udc-vbus_pin))
   enable_irq(gpio_to_irq(udc-vbus_pin));
  
   /* 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) {
 + ret = start_clock(udc);
 + if (ret)
 + goto out;
 +
 + spin_lock_irqsave(udc-lock, flags);
   toggle_bias(1);
   usba_writel(udc, CTRL, USBA_ENABLE_MASK);
   usba_writel(udc, INT_ENB, USBA_END_OF_RESET);
 + spin_unlock_irqrestore(udc-lock, flags);
  
   udc-vbus_prev = 1;
   }
 - spin_unlock_irqrestore(udc-lock, flags);
  
 - return 0;
 +out:
 + mutex_unlock(udc-vbus_mutex);
 + return ret;
  }
  
  static int atmel_usba_stop(struct usb_gadget *gadget)
 @@ -1816,8 +1860,7 @@ static int atmel_usba_stop(struct usb_gadget *gadget)
   toggle_bias(0);
   usba_writel(udc, CTRL, USBA_DISABLE_MASK);
  
 - clk_disable_unprepare(udc-hclk);
 - clk_disable_unprepare(udc-pclk);
 + stop_clock(udc);
  
   udc-driver = NULL;
  
 @@ -1997,6 +2040,7 @@ static int usba_udc_probe(struct platform_device *pdev)
   return PTR_ERR(hclk);
  
   spin_lock_init(udc-lock);
 + mutex_init(udc-vbus_mutex);
   udc-pdev = pdev;
   udc-pclk = pclk;
   udc-hclk = hclk;
 @@ -2049,9 +2093,9 @@ static int usba_udc_probe(struct platform_device *pdev)
  
   if (gpio_is_valid(udc-vbus_pin)) {
   if (!devm_gpio_request(pdev-dev, udc-vbus_pin, 
 atmel_usba_udc)) {
 - ret = devm_request_irq(pdev-dev,
 - gpio_to_irq(udc-vbus_pin),
 - usba_vbus_irq, 0,
 + ret = devm_request_threaded_irq(pdev-dev,
 + gpio_to_irq(udc-vbus_pin), NULL,
 + usba_vbus_irq_thread, IRQF_ONESHOT,
   atmel_usba_udc, udc);
   if (ret) {
   udc-vbus_pin = -ENODEV;
 diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.h 
 b/drivers/usb/gadget/udc/atmel_usba_udc.h
 index a70706e..3ceed76 100644
 --- a/drivers/usb/gadget/udc/atmel_usba_udc.h
 +++ b/drivers/usb/gadget/udc/atmel_usba_udc.h
 @@ -308,6 +308,9 @@ struct usba_udc {
   /* Protect hw registers from concurrent modifications */
   spinlock_t lock;
  
 + /* Mutex to prevent concurrent start or stop */
 + struct mutex vbus_mutex;
 +
   void __iomem *regs;
   void __iomem *fifo;
  
 @@ -321,6 +324,7 @@ struct usba_udc {
   struct clk *pclk;
   struct clk *hclk;
   struct usba_ep *usba_ep;
 + bool clocked;
  
   u16 devstatus;

Otherwise, it looks okay, so once little corrections done, you can add my:
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com

Thanks, bye,
-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 00/12] Atmel matrix, SMC and UDC rework

2015-01-15 Thread Nicolas Ferre
Le 14/01/2015 17:21, Alexandre Belloni a écrit :
 Hi Felipe,
 
 The following series replace the previous series sent by Boris named:
  - [PATCH v5 00/11] memory: add Atmel EBI (External Bus Interface) driver
  - [PATCH 00/11] usb: gadget: at91_udc: Rework for multi-platform support
 
 The patches I left out are less urgent and will be resent later, probably for
 3.21.
 
 Because of the dependancy between the syscon addition and the at91_udc series,
 this can go through the AT91 tree if you giv your ack on the udc patches.
 
 The first 4 patches introduce 2 syscon devices needed to configure the
 matrix and SMC.
 The following patches rework the at91_udc driver to prepare at91 for
 multi-platform support.
 
 It also include several fixes:
  - fix clock names to be consistent with other USB drivers
  - document clocks and clock-names properties in atmel-usb DT bindings doc
 
 and some cleanup changes:
  - remove useless usb_clk
  - allocate at91_udc instance instead of using the statically defined one
  - simplify the probe and remove functions by using devm_ helpers
  - remove !DT specific code
 
 Changes from the previous series:
  - rebased on 3.19-rc1

 Boris Brezillon (12):
   mfd: syscon: Add atmel-matrix registers definition
   mfd: syscon: Add Atmel Matrix bus DT binding documentation
   mfd: syscon: Add atmel-smc registers definition
   mfd: syscon: Add Atmel SMC binding doc

I already acknowledged these 4 patches as part of another series.

   usb: gadget: at91_udc: Fix clock names
   usb: gadget: at91_udc: Drop uclk clock
   usb: gadget: at91_udc: Document DT clocks and clock-names property
   usb: gadget: at91_udc: Remove non-DT handling code
   usb: gadget: at91_udc: Simplify probe and remove functions
   usb: gadget: at91_udc: Rework for multi-platform kernel support
   usb: gadget: at91_udc: Update DT binding documentation
   usb: gadget: at91_udc: Allocate udc instance

I'm fine with all this:
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com

Great, I plan to add them all to the at91-3.20-drivers branch now.

Thanks, best regards.


  .../devicetree/bindings/mfd/atmel-matrix.txt   |  24 +
  .../devicetree/bindings/mfd/atmel-smc.txt  |  19 +
  .../devicetree/bindings/usb/atmel-usb.txt  |  10 +-
  drivers/usb/gadget/udc/Kconfig |   1 +
  drivers/usb/gadget/udc/at91_udc.c  | 525 
 +++--
  drivers/usb/gadget/udc/at91_udc.h  |   9 +-
  include/linux/mfd/syscon/atmel-matrix.h| 117 +
  include/linux/mfd/syscon/atmel-smc.h   | 173 +++
  8 files changed, 623 insertions(+), 255 deletions(-)
  create mode 100644 Documentation/devicetree/bindings/mfd/atmel-matrix.txt
  create mode 100644 Documentation/devicetree/bindings/mfd/atmel-smc.txt
  create mode 100644 include/linux/mfd/syscon/atmel-matrix.h
  create mode 100644 include/linux/mfd/syscon/atmel-smc.h
 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RESEND PATCH] USB: gadget: udc: atmel: fix possible oops when unloading module

2015-01-09 Thread Nicolas Ferre
From: Songjun Wu songjun...@atmel.com

When unloading the module 'g_hid.ko', the urb request will be dequeued and the
completion routine will be excuted. If there is no urb packet, the urb request
will not be added to the endpoint queue and the completion routine pointer in
urb request is NULL.
Accessing to this NULL function pointer will cause the Oops issue reported
below.
Add the code to check if the urb request is in the endpoint queue
or not. If the urb request is not in the endpoint queue, a negative
error code will be returned.

Here is the Oops log:

Unable to handle kernel NULL pointer dereference at virtual address 
pgd = dedf
[] *pgd=3ede5831, *pte=, *ppte=
Internal error: Oops: 8007 [#1] ARM
Modules linked in: g_hid(-) usb_f_hid libcomposite
CPU: 0 PID: 923 Comm: rmmod Not tainted 3.18.0+ #2
Hardware name: Atmel SAMA5 (Device Tree)
task: df6b1100 ti: dedf6000 task.ti: dedf6000
PC is at 0x0
LR is at usb_gadget_giveback_request+0xc/0x10
pc : []lr : [c02ace88]psr: 6093
sp : dedf7eb0  ip : df572634  fp : 
r10:   r9 : df52e210  r8 : 6013
r7 : df6a9858  r6 : df52e210  r5 : df6a9858  r4 : df572600
r3 :   r2 : ff98  r1 : df572600  r0 : df6a9868
Flags: nZCv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment user
Control: 10c53c7d  Table: 3edf0059  DAC: 0015
Process rmmod (pid: 923, stack limit = 0xdedf6230)
Stack: (0xdedf7eb0 to 0xdedf8000)
7ea0:  c02adbbc df572580 deced608
7ec0: df572600 df6a9868 df572634 c02aed3c df577c00 c01b8608  df6be27c
7ee0: 00200200 00100100 bf0162f4 c000e544 dedf6000   bf010c00
7f00: bf0162cc bf00159c  df572980 df52e218 0001 df5729b8 bf0031d0
[..]
[c02ace88] (usb_gadget_giveback_request) from [c02adbbc] 
(request_complete+0x64/0x88)
[c02adbbc] (request_complete) from [c02aed3c] (usba_ep_dequeue+0x70/0x128)
[c02aed3c] (usba_ep_dequeue) from [bf010c00] (hidg_unbind+0x50/0x7c 
[usb_f_hid])
[bf010c00] (hidg_unbind [usb_f_hid]) from [bf00159c] 
(remove_config.isra.6+0x98/0x9c [libcomposite])
[bf00159c] (remove_config.isra.6 [libcomposite]) from [bf0031d0] 
(__composite_unbind+0x34/0x98 [libcomposite])
[bf0031d0] (__composite_unbind [libcomposite]) from [c02acee0] 
(usb_gadget_remove_driver+0x50/0x78)
[c02acee0] (usb_gadget_remove_driver) from [c02ad570] 
(usb_gadget_unregister_driver+0x64/0x94)
[c02ad570] (usb_gadget_unregister_driver) from [bf0160c0] 
(hidg_cleanup+0x10/0x34 [g_hid])
[bf0160c0] (hidg_cleanup [g_hid]) from [c0056748] 
(SyS_delete_module+0x118/0x19c)
[c0056748] (SyS_delete_module) from [c000e3c0] (ret_fast_syscall+0x0/0x30)
Code: bad PC value

Signed-off-by: Songjun Wu songjun...@atmel.com
[nicolas.fe...@atmel.com: reworked the commit message]
Signed-off-by: Nicolas Ferre nicolas.fe...@atmel.com
Fixes: 914a3f3b3754 (USB: add atmel_usba_udc driver)
Cc: sta...@vger.kernel.org # 2.6.x-ish
---
Felipe,

I tried to collect all the information needed. Please tell me if it's what you
expect from us.

Songjun,

I took a summary of your previous emails + the Oops log without breaking lines.
The Fixes tag goes into the last part of the email. Thanks a lot for your
fix.

Bye,


 drivers/usb/gadget/udc/atmel_usba_udc.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
b/drivers/usb/gadget/udc/atmel_usba_udc.c
index ce882371786b..48629cc3d6f8 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -828,7 +828,7 @@ static int usba_ep_dequeue(struct usb_ep *_ep, struct 
usb_request *_req)
 {
struct usba_ep *ep = to_usba_ep(_ep);
struct usba_udc *udc = ep-udc;
-   struct usba_request *req = to_usba_req(_req);
+   struct usba_request *req;
unsigned long flags;
u32 status;
 
@@ -837,6 +837,16 @@ static int usba_ep_dequeue(struct usb_ep *_ep, struct 
usb_request *_req)
 
spin_lock_irqsave(udc-lock, flags);
 
+   list_for_each_entry(req, ep-queue, queue) {
+   if (req-req == _req)
+   break;
+   }
+
+   if (req-req != _req) {
+   spin_unlock_irqrestore(udc-lock, flags);
+   return -EINVAL;
+   }
+
if (req-using_dma) {
/*
 * If this request is currently being transferred,
-- 
2.1.3

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RESEND PATCH] usb: gadget: at91_udc: move prepare clk into process context

2014-12-19 Thread Nicolas Ferre
Le 19/12/2014 15:02, Ronald Wahl a écrit :
 On 19.12.2014 14:51, Luis Henriques wrote:
 Hi Felipe,

 On Thu, Nov 20, 2014 at 01:50:49PM -0600, Felipe Balbi wrote:
 On Wed, Nov 19, 2014 at 04:37:27PM +0100, Nicolas Ferre wrote:
 From: Ronald Wahl ronald.w...@raritan.com

 Commit 7628083227b6bc4a7e33d7c381d7a4e558424b6b (usb: gadget: at91_udc:
 prepare clk before calling enable) added clock preparation in interrupt
 context. This is not allowed as it might sleep. Also setting the clock
 rate is unsafe to call from there for the same reason. Move clock
 preparation and setting clock rate into process context (at91udc_probe).

 Signed-off-by: Ronald Wahl ronald.w...@raritan.com
 Acked-by: Alexandre Belloni alexandre.bell...@free-electrons.com
 Acked-by: Boris Brezillon boris.brezil...@free-electrons.com
 Acked-by: Nicolas Ferre nicolas.fe...@atmel.com
 Cc: Felipe Balbi ba...@ti.com
 Cc: sta...@vger.kernel.org # v3.17+
 ---
 Hi Felipe,

 I forgot to answer you on this patch. So I resend it now with the proper
 stable tag. You can also queue it during this -rc phase if you feel it is
 still possible.

 I think it's late for v3.18, so it'll go on v3.19 and get backported to
 3.17 and 3.18. Sorry :-s


 Although this commit (b2ba27a5c56f usb: gadget: at91_udc: move
 prepare clk into process context) is tagged for stable v3.17+, it
 seems like it could be applied to earlier kernels.

 3.16, 3.13 and 3.12 seem to be affected by the same issue (and they
 all include commit 7628083227b6 usb: gadget: at91_udc: prepare clk
 before calling enable).  Is there any reason for not applying it in
 these trees?
 
 Not to forget 3.14 (LTS) which was the branch where I primarily found 
 the issue...

Well it's maybe an issue with the re-naming of the directory to
drivers/usb/gadget/udc/ introduced by patch:
90fccb529d24 (usb: gadget: Gadget directory cleanup - group UDC drivers)

The patch doesn't apply out of the box but it surely can be applied in
those earlier kernels.


Thanks, bye.
-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] USB: gadget: udc: atmel: change setting for DMA

2014-12-18 Thread Nicolas Ferre
Le 17/12/2014 10:18, Bo Shen a écrit :
 According to the datasheet, when transfer using DMA, the control
 setting for IN packet only need END_BUF_EN, END_BUF_IE, CH_EN,
 while for OUT packet, need more two bits END_TR_EN and END_TR_IE
 to be configured.
 
 Signed-off-by: Bo Shen voice.s...@atmel.com

Seems okay, even if I am not used to these aspects:
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com

I would also add a stable tag to these patches, something like this:

Fixes: 914a3f3b3754 (USB: add atmel_usba_udc driver)
Cc: sta...@vger.kernel.org # always been there...


Felipe,

Can you take both of these patches as fixes?

 ---
 
  drivers/usb/gadget/udc/atmel_usba_udc.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
 
 diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
 b/drivers/usb/gadget/udc/atmel_usba_udc.c
 index ce88237..63e90f5 100644
 --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
 +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
 @@ -716,10 +716,10 @@ static int queue_dma(struct usba_udc *udc, struct 
 usba_ep *ep,
   req-using_dma = 1;
   req-ctrl = USBA_BF(DMA_BUF_LEN, req-req.length)
   | USBA_DMA_CH_EN | USBA_DMA_END_BUF_IE
 - | USBA_DMA_END_TR_EN | USBA_DMA_END_TR_IE;
 + | USBA_DMA_END_BUF_EN;
  
 - if (ep-is_in)
 - req-ctrl |= USBA_DMA_END_BUF_EN;
 + if (!ep-is_in)
 + req-ctrl |= USBA_DMA_END_TR_EN | USBA_DMA_END_TR_IE;
  
   /*
* Add this request to the queue and submit for DMA if
 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] USB: gadget: udc: atmel: fix possible IN hang issue

2014-12-18 Thread Nicolas Ferre
Le 17/12/2014 10:18, Bo Shen a écrit :
 When receive data, the RXRDY in status register set by hardware
 after a new packet has been stored in the endpoint FIFO. When it
 is copied from FIFO, this bit is cleared which make the FIFO can
 be accessed again.
 
 In the receive_data() function, this bit RXRDY has been cleared.
 So, after the receive_data() function return, this bit should
 not be cleared again, or else it may cause the accessing FIFO
 corrupt, which will make the data loss.
 
 Signed-off-by: Bo Shen voice.s...@atmel.com


Seems okay:
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com

Like the former one:

Fixes: 914a3f3b3754 (USB: add atmel_usba_udc driver)
Cc: sta...@vger.kernel.org # always been there...

 ---
 
  drivers/usb/gadget/udc/atmel_usba_udc.c | 1 -
  1 file changed, 1 deletion(-)
 
 diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
 b/drivers/usb/gadget/udc/atmel_usba_udc.c
 index 63e90f5..93328ea 100644
 --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
 +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
 @@ -1563,7 +1563,6 @@ static void usba_ep_irq(struct usba_udc *udc, struct 
 usba_ep *ep)
   if ((epstatus  epctrl)  USBA_RX_BK_RDY) {
   DBG(DBG_BUS, %s: RX data ready\n, ep-ep.name);
   receive_data(ep);
 - usba_ep_writel(ep, CLR_STA, USBA_RX_BK_RDY);
   }
  }
  
 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RESEND PATCH] usb: gadget: at91_udc: move prepare clk into process context

2014-11-19 Thread Nicolas Ferre
From: Ronald Wahl ronald.w...@raritan.com

Commit 7628083227b6bc4a7e33d7c381d7a4e558424b6b (usb: gadget: at91_udc:
prepare clk before calling enable) added clock preparation in interrupt
context. This is not allowed as it might sleep. Also setting the clock
rate is unsafe to call from there for the same reason. Move clock
preparation and setting clock rate into process context (at91udc_probe).

Signed-off-by: Ronald Wahl ronald.w...@raritan.com
Acked-by: Alexandre Belloni alexandre.bell...@free-electrons.com
Acked-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com
Cc: Felipe Balbi ba...@ti.com
Cc: sta...@vger.kernel.org # v3.17+
---
Hi Felipe,

I forgot to answer you on this patch. So I resend it now with the proper
stable tag. You can also queue it during this -rc phase if you feel it is
still possible.

Thanks, bye.

 drivers/usb/gadget/udc/at91_udc.c | 44 ---
 1 file changed, 32 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/gadget/udc/at91_udc.c 
b/drivers/usb/gadget/udc/at91_udc.c
index 9968f5331fe4..0716c1994e28 100644
--- a/drivers/usb/gadget/udc/at91_udc.c
+++ b/drivers/usb/gadget/udc/at91_udc.c
@@ -870,12 +870,10 @@ static void clk_on(struct at91_udc *udc)
return;
udc-clocked = 1;
 
-   if (IS_ENABLED(CONFIG_COMMON_CLK)) {
-   clk_set_rate(udc-uclk, 4800);
-   clk_prepare_enable(udc-uclk);
-   }
-   clk_prepare_enable(udc-iclk);
-   clk_prepare_enable(udc-fclk);
+   if (IS_ENABLED(CONFIG_COMMON_CLK))
+   clk_enable(udc-uclk);
+   clk_enable(udc-iclk);
+   clk_enable(udc-fclk);
 }
 
 static void clk_off(struct at91_udc *udc)
@@ -884,10 +882,10 @@ static void clk_off(struct at91_udc *udc)
return;
udc-clocked = 0;
udc-gadget.speed = USB_SPEED_UNKNOWN;
-   clk_disable_unprepare(udc-fclk);
-   clk_disable_unprepare(udc-iclk);
+   clk_disable(udc-fclk);
+   clk_disable(udc-iclk);
if (IS_ENABLED(CONFIG_COMMON_CLK))
-   clk_disable_unprepare(udc-uclk);
+   clk_disable(udc-uclk);
 }
 
 /*
@@ -1780,14 +1778,24 @@ static int at91udc_probe(struct platform_device *pdev)
}
 
/* don't do anything until we have both gadget driver and VBUS */
+   if (IS_ENABLED(CONFIG_COMMON_CLK)) {
+   clk_set_rate(udc-uclk, 4800);
+   retval = clk_prepare(udc-uclk);
+   if (retval)
+   goto fail1;
+   }
+   retval = clk_prepare(udc-fclk);
+   if (retval)
+   goto fail1a;
+
retval = clk_prepare_enable(udc-iclk);
if (retval)
-   goto fail1;
+   goto fail1b;
at91_udp_write(udc, AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS);
at91_udp_write(udc, AT91_UDP_IDR, 0x);
/* Clear all pending interrupts - UDP may be used by bootloader. */
at91_udp_write(udc, AT91_UDP_ICR, 0x);
-   clk_disable_unprepare(udc-iclk);
+   clk_disable(udc-iclk);
 
/* request UDC and maybe VBUS irqs */
udc-udp_irq = platform_get_irq(pdev, 0);
@@ -1795,7 +1803,7 @@ static int at91udc_probe(struct platform_device *pdev)
0, driver_name, udc);
if (retval  0) {
DBG(request irq %d failed\n, udc-udp_irq);
-   goto fail1;
+   goto fail1c;
}
if (gpio_is_valid(udc-board.vbus_pin)) {
retval = gpio_request(udc-board.vbus_pin, udc_vbus);
@@ -1848,6 +1856,13 @@ fail3:
gpio_free(udc-board.vbus_pin);
 fail2:
free_irq(udc-udp_irq, udc);
+fail1c:
+   clk_unprepare(udc-iclk);
+fail1b:
+   clk_unprepare(udc-fclk);
+fail1a:
+   if (IS_ENABLED(CONFIG_COMMON_CLK))
+   clk_unprepare(udc-uclk);
 fail1:
if (IS_ENABLED(CONFIG_COMMON_CLK)  !IS_ERR(udc-uclk))
clk_put(udc-uclk);
@@ -1896,6 +1911,11 @@ static int __exit at91udc_remove(struct platform_device 
*pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
release_mem_region(res-start, resource_size(res));
 
+   if (IS_ENABLED(CONFIG_COMMON_CLK))
+   clk_unprepare(udc-uclk);
+   clk_unprepare(udc-fclk);
+   clk_unprepare(udc-iclk);
+
clk_put(udc-iclk);
clk_put(udc-fclk);
if (IS_ENABLED(CONFIG_COMMON_CLK))
-- 
2.1.3

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4] usb: gadget: at91_udc: move prepare clk into process context

2014-08-13 Thread Nicolas Ferre
On 08/08/2014 11:42, Ronald Wahl :
 Commit 7628083227b6bc4a7e33d7c381d7a4e558424b6b (usb: gadget: at91_udc:
 prepare clk before calling enable) added clock preparation in interrupt
 context. This is not allowed as it might sleep. Also setting the clock
 rate is unsafe to call from there for the same reason. Move clock
 preparation and setting clock rate into process context (at91udc_probe).
 
 Signed-off-by: Ronald Wahl ronald.w...@raritan.com

Acked-by: Nicolas Ferre nicolas.fe...@atmel.com

 ---
 v3 - v4:
 - no code changes
 - update commit message
 - add changelog
 
 v2 - v3: (NOTE: this patch was also send with the v2 tag)
 - moved setting the clock rate into process context as well as it may
   also sleep
 - update commit message
 
 v1 - v2:
 - no changes (first v2 got out accidently)
 
  drivers/usb/gadget/udc/at91_udc.c | 44 
 ---
  1 file changed, 32 insertions(+), 12 deletions(-)
 
 diff --git a/drivers/usb/gadget/udc/at91_udc.c 
 b/drivers/usb/gadget/udc/at91_udc.c
 index cfd18bc..0d685d0 100644
 --- a/drivers/usb/gadget/udc/at91_udc.c
 +++ b/drivers/usb/gadget/udc/at91_udc.c
 @@ -870,12 +870,10 @@ static void clk_on(struct at91_udc *udc)
   return;
   udc-clocked = 1;
  
 - if (IS_ENABLED(CONFIG_COMMON_CLK)) {
 - clk_set_rate(udc-uclk, 4800);
 - clk_prepare_enable(udc-uclk);
 - }
 - clk_prepare_enable(udc-iclk);
 - clk_prepare_enable(udc-fclk);
 + if (IS_ENABLED(CONFIG_COMMON_CLK))
 + clk_enable(udc-uclk);
 + clk_enable(udc-iclk);
 + clk_enable(udc-fclk);
  }
  
  static void clk_off(struct at91_udc *udc)
 @@ -884,10 +882,10 @@ static void clk_off(struct at91_udc *udc)
   return;
   udc-clocked = 0;
   udc-gadget.speed = USB_SPEED_UNKNOWN;
 - clk_disable_unprepare(udc-fclk);
 - clk_disable_unprepare(udc-iclk);
 + clk_disable(udc-fclk);
 + clk_disable(udc-iclk);
   if (IS_ENABLED(CONFIG_COMMON_CLK))
 - clk_disable_unprepare(udc-uclk);
 + clk_disable(udc-uclk);
  }
  
  /*
 @@ -1780,14 +1778,24 @@ static int at91udc_probe(struct platform_device *pdev)
   }
  
   /* don't do anything until we have both gadget driver and VBUS */
 + if (IS_ENABLED(CONFIG_COMMON_CLK)) {
 + clk_set_rate(udc-uclk, 4800);
 + retval = clk_prepare(udc-uclk);
 + if (retval)
 + goto fail1;
 + }
 + retval = clk_prepare(udc-fclk);
 + if (retval)
 + goto fail1a;
 +
   retval = clk_prepare_enable(udc-iclk);
   if (retval)
 - goto fail1;
 + goto fail1b;
   at91_udp_write(udc, AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS);
   at91_udp_write(udc, AT91_UDP_IDR, 0x);
   /* Clear all pending interrupts - UDP may be used by bootloader. */
   at91_udp_write(udc, AT91_UDP_ICR, 0x);
 - clk_disable_unprepare(udc-iclk);
 + clk_disable(udc-iclk);
  
   /* request UDC and maybe VBUS irqs */
   udc-udp_irq = platform_get_irq(pdev, 0);
 @@ -1795,7 +1803,7 @@ static int at91udc_probe(struct platform_device *pdev)
   0, driver_name, udc);
   if (retval  0) {
   DBG(request irq %d failed\n, udc-udp_irq);
 - goto fail1;
 + goto fail1c;
   }
   if (gpio_is_valid(udc-board.vbus_pin)) {
   retval = gpio_request(udc-board.vbus_pin, udc_vbus);
 @@ -1848,6 +1856,13 @@ fail3:
   gpio_free(udc-board.vbus_pin);
  fail2:
   free_irq(udc-udp_irq, udc);
 +fail1c:
 + clk_unprepare(udc-iclk);
 +fail1b:
 + clk_unprepare(udc-fclk);
 +fail1a:
 + if (IS_ENABLED(CONFIG_COMMON_CLK))
 + clk_unprepare(udc-uclk);
  fail1:
   if (IS_ENABLED(CONFIG_COMMON_CLK)  !IS_ERR(udc-uclk))
   clk_put(udc-uclk);
 @@ -1896,6 +1911,11 @@ static int __exit at91udc_remove(struct 
 platform_device *pdev)
   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
   release_mem_region(res-start, resource_size(res));
  
 + if (IS_ENABLED(CONFIG_COMMON_CLK))
 + clk_unprepare(udc-uclk);
 + clk_unprepare(udc-fclk);
 + clk_unprepare(udc-iclk);
 +
   clk_put(udc-iclk);
   clk_put(udc-fclk);
   if (IS_ENABLED(CONFIG_COMMON_CLK))
 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: gadget: atmel_usba: always test udc-driver

2014-05-09 Thread Nicolas Ferre
On 06/05/2014 17:16, Alexandre Belloni :
 Found using smatch: drivers/usb/gadget/atmel_usba_udc.c:1689 usba_udc_irq()
 error: we previously assumed 'udc-driver' could be null (see line 1636)
 
 Always test udc-driver before using its members.
 
 Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com


Acked-by: Nicolas Ferre nicolas.fe...@atmel.com

Thanks,

 ---
  drivers/usb/gadget/atmel_usba_udc.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/usb/gadget/atmel_usba_udc.c 
 b/drivers/usb/gadget/atmel_usba_udc.c
 index 9f65324f9ae0..76023ce449a3 100644
 --- a/drivers/usb/gadget/atmel_usba_udc.c
 +++ b/drivers/usb/gadget/atmel_usba_udc.c
 @@ -1686,7 +1686,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
   reset_all_endpoints(udc);
  
   if (udc-gadget.speed != USB_SPEED_UNKNOWN
 -  udc-driver-disconnect) {
 +  udc-driver  udc-driver-disconnect) {
   udc-gadget.speed = USB_SPEED_UNKNOWN;
   spin_unlock(udc-lock);
   udc-driver-disconnect(udc-gadget);
 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH RESEND] usb: at91-udc: fix irq and iomem resource retrieval

2014-03-12 Thread Nicolas Ferre
On 12/02/2014 14:03, Nicolas Ferre :
 From: Jean-Jacques Hiblot jjhib...@traphandler.com
 
 When using dt resources retrieval (interrupts and reg properties) there is
 no predefined order for these resources in the platform dev resource
 table. Also don't expect the number of resource to be always 2.
 
 Signed-off-by: Jean-Jacques Hiblot jjhib...@traphandler.com
 Acked-by: Boris BREZILLON b.brezil...@overkiz.com
 Acked-by: Nicolas Ferre nicolas.fe...@atmel.com
 Cc: stable sta...@vger.kernel.org # 3.4

Gentle ping, after having resent the patch itself.

 ---
  drivers/usb/gadget/at91_udc.c | 10 --
  1 file changed, 10 deletions(-)
 
 diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
 index cea8c20a1425..1926925a52a9 100644
 --- a/drivers/usb/gadget/at91_udc.c
 +++ b/drivers/usb/gadget/at91_udc.c
 @@ -1709,16 +1709,6 @@ static int at91udc_probe(struct platform_device *pdev)
   return -ENODEV;
   }
  
 - if (pdev-num_resources != 2) {
 - DBG(invalid num_resources\n);
 - return -ENODEV;
 - }
 - if ((pdev-resource[0].flags != IORESOURCE_MEM)
 - || (pdev-resource[1].flags != IORESOURCE_IRQ)) {
 - DBG(invalid resource type\n);
 - return -ENODEV;
 - }
 -
   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
   if (!res)
   return -ENXIO;
 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH RESEND] usb: at91-udc: fix irq and iomem resource retrieval

2014-03-12 Thread Nicolas Ferre
On 12/03/2014 16:31, Greg Kroah-Hartman :
 On Wed, Mar 12, 2014 at 03:57:48PM +0100, Nicolas Ferre wrote:
 On 12/02/2014 14:03, Nicolas Ferre :
 From: Jean-Jacques Hiblot jjhib...@traphandler.com

 When using dt resources retrieval (interrupts and reg properties) there is
 no predefined order for these resources in the platform dev resource
 table. Also don't expect the number of resource to be always 2.

 Signed-off-by: Jean-Jacques Hiblot jjhib...@traphandler.com
 Acked-by: Boris BREZILLON b.brezil...@overkiz.com
 Acked-by: Nicolas Ferre nicolas.fe...@atmel.com
 Cc: stable sta...@vger.kernel.org # 3.4

 Gentle ping, after having resent the patch itself.
 
 It helps if you send it to the correct maintainer, remember,
 scripts/get_maintainer.pl is your friend...

Indeed. I add Felipe to my next attempt: sorry for the (repeated) noise.

Bye,
-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RESEND] usb: at91-udc: fix irq and iomem resource retrieval

2014-03-12 Thread Nicolas Ferre
From: Jean-Jacques Hiblot jjhib...@traphandler.com

When using dt resources retrieval (interrupts and reg properties) there is
no predefined order for these resources in the platform dev resource
table. Also don't expect the number of resource to be always 2.

Signed-off-by: Jean-Jacques Hiblot jjhib...@traphandler.com
Acked-by: Boris BREZILLON b.brezil...@overkiz.com
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com
Cc: stable sta...@vger.kernel.org # 3.4
---
 drivers/usb/gadget/at91_udc.c | 10 --
 1 file changed, 10 deletions(-)

diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index cea8c20a1425..1926925a52a9 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -1709,16 +1709,6 @@ static int at91udc_probe(struct platform_device *pdev)
return -ENODEV;
}
 
-   if (pdev-num_resources != 2) {
-   DBG(invalid num_resources\n);
-   return -ENODEV;
-   }
-   if ((pdev-resource[0].flags != IORESOURCE_MEM)
-   || (pdev-resource[1].flags != IORESOURCE_IRQ)) {
-   DBG(invalid resource type\n);
-   return -ENODEV;
-   }
-
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res)
return -ENXIO;
-- 
1.8.2.2

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: gadget: atmel_usba: fix crash when no endpoint are specified

2014-02-28 Thread Nicolas Ferre
On 27/02/2014 16:42, Alexandre Belloni :
 If no endpoints are present in the device tree, the kernel will cras hwith the

s/cras hwith/crash with/

 following error:
 
 Unable to handle kernel paging request at virtual address 00101008
 [...]
 [c0222ff4] (composite_dev_prepare) from [c022326c] 
 (composite_bind+0x5c/0x190)
 [c022326c] (composite_bind) from [c021ff8c] (udc_bind_to_driver+0x48/0xf0)
 [c021ff8c] (udc_bind_to_driver) from [c02208e0] 
 (usb_gadget_probe_driver+0x7c/0xa0)
 [c02208e0] (usb_gadget_probe_driver) from [c0008970] 
 (do_one_initcall+0x94/0x140)
 [c0008970] (do_one_initcall) from [c04b4b50] 
 (kernel_init_freeable+0xec/0x1b4)
 [c04b4b50] (kernel_init_freeable) from [c0376cc4] (kernel_init+0x8/0xe4)
 [c0376cc4] (kernel_init) from [c0009590] (ret_from_fork+0x14/0x24)
 Code: e5950014 e1a04001 e5902008 e3a010d0 (e5922008)
 ---[ end trace 35c74bdd89b373d0 ]---
 Kernel panic - not syncing: Attempted to kill init! exitcode=0x000b
 
 This checks for that case and returns an error, not allowing the driver to be
 loaded with no endpoints.
 
 Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
 ---
  drivers/usb/gadget/atmel_usba_udc.c | 6 ++
  1 file changed, 6 insertions(+)
 
 diff --git a/drivers/usb/gadget/atmel_usba_udc.c 
 b/drivers/usb/gadget/atmel_usba_udc.c
 index 52771d4c44bc..e3e0c8ff242e 100644
 --- a/drivers/usb/gadget/atmel_usba_udc.c
 +++ b/drivers/usb/gadget/atmel_usba_udc.c
 @@ -1914,6 +1914,12 @@ static struct usba_ep * atmel_udc_of_init(struct 
 platform_device *pdev,
   i++;
   }
  
 + if (i == 0) {
 + dev_err(pdev-dev, of_probe: no endpoint specified\n);
 + ret = -EINVAL;
 + goto err;
 + }
 +

It is better for debugging when creating a DT for a new SoC. So, okay.

Acked-by: Nicolas Ferre nicolas.fe...@atmel.com

   return eps;
  err:
   return ERR_PTR(ret);
 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 1/2] USB: at91: fix the number of endpoint parameter

2014-02-19 Thread Nicolas Ferre
On 19/02/2014 03:07, Bo Shen :
 In sama5d3 SoC, there are 16 endpoints, which is different with
 earlier SoCs (only have 7 endpoints). The USBA_NR_ENDPOINTS micro

you should read macro.

 is not suitable for sama5d3. So, get the endpoints number through
 the udc-num_ep, which get from platform data for non-dt kernel,
 or parse from dt node.
 
 Signed-off-by: Bo Shen voice.s...@atmel.com

Acked-by: Nicolas Ferre nicolas.fe...@atmel.com

 ---
 Changes in v2:
   - Make the commit message more clearer.
 
  drivers/usb/gadget/atmel_usba_udc.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/usb/gadget/atmel_usba_udc.c 
 b/drivers/usb/gadget/atmel_usba_udc.c
 index 2cb52e0..7e67a81 100644
 --- a/drivers/usb/gadget/atmel_usba_udc.c
 +++ b/drivers/usb/gadget/atmel_usba_udc.c
 @@ -1670,7 +1670,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
   if (ep_status) {
   int i;
  
 - for (i = 0; i  USBA_NR_ENDPOINTS; i++)
 + for (i = 0; i  udc-num_ep; i++)
   if (ep_status  (1  i)) {
   if (ep_is_control(udc-usba_ep[i]))
   usba_control_irq(udc, udc-usba_ep[i]);
 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 2/2] USB: at91: using USBA_NR_DMAS for DMA channels

2014-02-19 Thread Nicolas Ferre
On 19/02/2014 03:07, Bo Shen :
 The SoCs earlier than sama5d3, they have the same number endpoints
 and DMA channels. In driver code, they use the same definition
 USBA_NR_ENDPOINTS for both endpoints and dma channels. However,
 in sama5d3, it has different number for endpoints and DMA channels.
 So, define a new micro USBA_NR_DMAs for DMA channels. And the

s/micro/macro/

 USBA_NR_ENDPOINS is not used anymore, remove it at the same time.
 
 Signed-off-by: Bo Shen voice.s...@atmel.com

Acked-by: Nicolas Ferre nicolas.fe...@atmel.com

 ---
 Changes in v2:
   - Make the commit message more clearer.
 
  drivers/usb/gadget/atmel_usba_udc.c | 2 +-
  drivers/usb/gadget/atmel_usba_udc.h | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/usb/gadget/atmel_usba_udc.c 
 b/drivers/usb/gadget/atmel_usba_udc.c
 index 7e67a81..5cded1c 100644
 --- a/drivers/usb/gadget/atmel_usba_udc.c
 +++ b/drivers/usb/gadget/atmel_usba_udc.c
 @@ -1661,7 +1661,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
   if (dma_status) {
   int i;
  
 - for (i = 1; i  USBA_NR_ENDPOINTS; i++)
 + for (i = 1; i  USBA_NR_DMAS; i++)
   if (dma_status  (1  i))
   usba_dma_irq(udc, udc-usba_ep[i]);
   }
 diff --git a/drivers/usb/gadget/atmel_usba_udc.h 
 b/drivers/usb/gadget/atmel_usba_udc.h
 index 2922db5..a70706e 100644
 --- a/drivers/usb/gadget/atmel_usba_udc.h
 +++ b/drivers/usb/gadget/atmel_usba_udc.h
 @@ -210,7 +210,7 @@
  #define USBA_FIFO_BASE(x)((x)  16)
  
  /* Synth parameters */
 -#define USBA_NR_ENDPOINTS7
 +#define USBA_NR_DMAS 7
  
  #define EP0_FIFO_SIZE64
  #define EP0_EPT_SIZE USBA_EPT_SIZE_64
 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RESEND] usb: at91-udc: fix irq and iomem resource retrieval

2014-02-12 Thread Nicolas Ferre
From: Jean-Jacques Hiblot jjhib...@traphandler.com

When using dt resources retrieval (interrupts and reg properties) there is
no predefined order for these resources in the platform dev resource
table. Also don't expect the number of resource to be always 2.

Signed-off-by: Jean-Jacques Hiblot jjhib...@traphandler.com
Acked-by: Boris BREZILLON b.brezil...@overkiz.com
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com
Cc: stable sta...@vger.kernel.org # 3.4
---
 drivers/usb/gadget/at91_udc.c | 10 --
 1 file changed, 10 deletions(-)

diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index cea8c20a1425..1926925a52a9 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -1709,16 +1709,6 @@ static int at91udc_probe(struct platform_device *pdev)
return -ENODEV;
}
 
-   if (pdev-num_resources != 2) {
-   DBG(invalid num_resources\n);
-   return -ENODEV;
-   }
-   if ((pdev-resource[0].flags != IORESOURCE_MEM)
-   || (pdev-resource[1].flags != IORESOURCE_IRQ)) {
-   DBG(invalid resource type\n);
-   return -ENODEV;
-   }
-
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res)
return -ENXIO;
-- 
1.8.2.2

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] USB: at91: fix the number of endpoint parameter

2014-01-21 Thread Nicolas Ferre
On 21/01/2014 09:12, Bo Shen :
 Hi J,
 
 On 01/21/2014 01:49 PM, Jean-Christophe PLAGNIOL-VILLARD wrote:
 On 11:39 Mon 20 Jan , Bo Shen wrote:
 Hi J,

 On 01/18/2014 01:20 PM, Jean-Christophe PLAGNIOL-VILLARD wrote:
 On 10:59 Fri 17 Jan , Bo Shen wrote:
 In sama5d3 SoC, there are 16 endpoints. As the USBA_NR_ENDPOINTS
 is only 7. So, fix it for sama5d3 SoC using the udc-num_ep.

 Signed-off-by: Bo Shen voice.s...@atmel.com
 ---

   drivers/usb/gadget/atmel_usba_udc.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/drivers/usb/gadget/atmel_usba_udc.c 
 b/drivers/usb/gadget/atmel_usba_udc.c
 index 2cb52e0..7e67a81 100644
 --- a/drivers/usb/gadget/atmel_usba_udc.c
 +++ b/drivers/usb/gadget/atmel_usba_udc.c
 @@ -1670,7 +1670,7 @@ static irqreturn_t usba_udc_irq(int irq, void 
 *devid)
   if (ep_status) {
   int i;

 - for (i = 0; i  USBA_NR_ENDPOINTS; i++)
 + for (i = 0; i  udc-num_ep; i++)

 no the limit need to specified in the driver as a checkpoint by the 
 compatible
 or platform driver id

 You mean, we should not trust the data passed from dt node or
 platform data? Or do you think we should do double confirm?

 no base on the driver name or the compatible you will known the MAX EP

 not based on the dt ep description

 as we do on pinctrl-at91
 
 I am sorry, I am not fully get it after reading the code of 
 pinctrl-at91.c, can you give the example code in pinctrl-at91.c?
 
 Btw, the udc-num_ep is get from the following code.
 for dt
 ---8---
   while ((pp = of_get_next_child(np, pp)))
   udc-num_ep++;
 ---8---
 
 for non-dt
 ---8---
   udc-num_ep = pdata-num_ep;
 ---8---

It seems to me pretty valid to use num_ep in this driver and not have to
rely on another compatibility string just for this.
The information is here, it is retrieved pretty cleanly so I vote for a
simple use of it: if we introduce another information we will have to
double check the cross errors that would happen...

Bye,

   if (ep_status  (1  i)) {
   if (ep_is_control(udc-usba_ep[i]))
   usba_control_irq(udc, 
 udc-usba_ep[i]);
 --
 1.8.5.2


 Best Regards,
 Bo Shen
 
 Best Regards,
 Bo Shen
 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] USB: at91: fix the number of endpoint parameter

2014-01-17 Thread Nicolas Ferre
On 17/01/2014 03:59, Bo Shen :
 In sama5d3 SoC, there are 16 endpoints. As the USBA_NR_ENDPOINTS
 is only 7. So, fix it for sama5d3 SoC using the udc-num_ep.
 
 Signed-off-by: Bo Shen voice.s...@atmel.com

Acked-by: Nicolas Ferre nicolas.fe...@atmel.com

 ---
 
  drivers/usb/gadget/atmel_usba_udc.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/usb/gadget/atmel_usba_udc.c 
 b/drivers/usb/gadget/atmel_usba_udc.c
 index 2cb52e0..7e67a81 100644
 --- a/drivers/usb/gadget/atmel_usba_udc.c
 +++ b/drivers/usb/gadget/atmel_usba_udc.c
 @@ -1670,7 +1670,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
   if (ep_status) {
   int i;
  
 - for (i = 0; i  USBA_NR_ENDPOINTS; i++)
 + for (i = 0; i  udc-num_ep; i++)
   if (ep_status  (1  i)) {
   if (ep_is_control(udc-usba_ep[i]))
   usba_control_irq(udc, udc-usba_ep[i]);
 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] USB: at91: using USBA_NR_DMAS for DMA channels

2014-01-17 Thread Nicolas Ferre
On 17/01/2014 03:59, Bo Shen :
 When the SoC is earlier than sama5d3 SoC, which have the same number
 endpoints and DMAs. However for sama5d3 SoC, it has different number
 for endpoints and DMAs. So, define USBA_NR_DMAs for DMA channels
 
 Signed-off-by: Bo Shen voice.s...@atmel.com

Acked-by: Nicolas Ferre nicolas.fe...@atmel.com

 ---
 
  drivers/usb/gadget/atmel_usba_udc.c | 2 +-
  drivers/usb/gadget/atmel_usba_udc.h | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/usb/gadget/atmel_usba_udc.c 
 b/drivers/usb/gadget/atmel_usba_udc.c
 index 7e67a81..5cded1c 100644
 --- a/drivers/usb/gadget/atmel_usba_udc.c
 +++ b/drivers/usb/gadget/atmel_usba_udc.c
 @@ -1661,7 +1661,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
   if (dma_status) {
   int i;
  
 - for (i = 1; i  USBA_NR_ENDPOINTS; i++)
 + for (i = 1; i  USBA_NR_DMAS; i++)
   if (dma_status  (1  i))
   usba_dma_irq(udc, udc-usba_ep[i]);
   }
 diff --git a/drivers/usb/gadget/atmel_usba_udc.h 
 b/drivers/usb/gadget/atmel_usba_udc.h
 index 2922db5..a70706e 100644
 --- a/drivers/usb/gadget/atmel_usba_udc.h
 +++ b/drivers/usb/gadget/atmel_usba_udc.h
 @@ -210,7 +210,7 @@
  #define USBA_FIFO_BASE(x)((x)  16)
  
  /* Synth parameters */
 -#define USBA_NR_ENDPOINTS7
 +#define USBA_NR_DMAS 7
  
  #define EP0_FIFO_SIZE64
  #define EP0_EPT_SIZE USBA_EPT_SIZE_64
 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] usb: gadget: atmel_usba: Fix sparse warning

2013-12-16 Thread Nicolas Ferre
On 16/12/2013 07:14, Jingoo Han :
 'usba_gadget_template' is used only in this file. Thus, make
 'usba_gadget_template' static, in order to fix the following
 sparse warning.
 
 warning: symbol 'usba_gadget_template' was not declared. Should it be static?
 
 Signed-off-by: Jingoo Han jg1@samsung.com

Acked-by: Nicolas Ferre nicolas.fe...@atmel.com

Thanks.

 ---
  drivers/usb/gadget/atmel_usba_udc.c |2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/usb/gadget/atmel_usba_udc.c 
 b/drivers/usb/gadget/atmel_usba_udc.c
 index 409a055..55ae5ef 100644
 --- a/drivers/usb/gadget/atmel_usba_udc.c
 +++ b/drivers/usb/gadget/atmel_usba_udc.c
 @@ -1012,7 +1012,7 @@ static void nop_release(struct device *dev)
  
  }
  
 -struct usb_gadget usba_gadget_template = {
 +static struct usb_gadget usba_gadget_template = {
   .ops= usba_udc_ops,
   .max_speed  = USB_SPEED_HIGH,
   .name   = atmel_usba_udc,
 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 05/12] USB: ohci-at91: Use devm_*() functions

2013-12-11 Thread Nicolas Ferre

On 11/12/2013 08:31, Jingoo Han :

Use devm_*() functions to make cleanup paths simpler.

Signed-off-by: Jingoo Han jg1@samsung.com


Jingoo,

Well, these modifications are already addressed by a series written by 
Boris.

[PATCH v5 0/3] usb: ohci-at91: various improvements

Thanks for your patch anyway.


Best regards.



---
  drivers/usb/host/ohci-at91.c |   52 +-
  1 file changed, 11 insertions(+), 41 deletions(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 29d2093..8fb80b2 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -154,43 +154,36 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
hcd-rsrc_start = pdev-resource[0].start;
hcd-rsrc_len = resource_size(pdev-resource[0]);

-   if (!request_mem_region(hcd-rsrc_start, hcd-rsrc_len, hcd_name)) {
-   pr_debug(request_mem_region failed\n);
-   retval = -EBUSY;
+   hcd-regs = devm_ioremap_resource(pdev-dev, pdev-resource[0]);
+   if (IS_ERR(hcd-regs)) {
+   retval = PTR_ERR(hcd-regs);
goto err1;
}

-   hcd-regs = ioremap(hcd-rsrc_start, hcd-rsrc_len);
-   if (!hcd-regs) {
-   pr_debug(ioremap failed\n);
-   retval = -EIO;
-   goto err2;
-   }
-
-   iclk = clk_get(pdev-dev, ohci_clk);
+   iclk = devm_clk_get(pdev-dev, ohci_clk);
if (IS_ERR(iclk)) {
dev_err(pdev-dev, failed to get ohci_clk\n);
retval = PTR_ERR(iclk);
-   goto err3;
+   goto err1;
}
-   fclk = clk_get(pdev-dev, uhpck);
+   fclk = devm_clk_get(pdev-dev, uhpck);
if (IS_ERR(fclk)) {
dev_err(pdev-dev, failed to get uhpck\n);
retval = PTR_ERR(fclk);
-   goto err4;
+   goto err1;
}
-   hclk = clk_get(pdev-dev, hclk);
+   hclk = devm_clk_get(pdev-dev, hclk);
if (IS_ERR(hclk)) {
dev_err(pdev-dev, failed to get hclk\n);
retval = PTR_ERR(hclk);
-   goto err5;
+   goto err1;
}
if (IS_ENABLED(CONFIG_COMMON_CLK)) {
-   uclk = clk_get(pdev-dev, usb_clk);
+   uclk = devm_clk_get(pdev-dev, usb_clk);
if (IS_ERR(uclk)) {
dev_err(pdev-dev, failed to get uclk\n);
retval = PTR_ERR(uclk);
-   goto err6;
+   goto err1;
}
}

@@ -208,21 +201,6 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
/* Error handling */
at91_stop_hc(pdev);

-   if (IS_ENABLED(CONFIG_COMMON_CLK))
-   clk_put(uclk);
- err6:
-   clk_put(hclk);
- err5:
-   clk_put(fclk);
- err4:
-   clk_put(iclk);
-
- err3:
-   iounmap(hcd-regs);
-
- err2:
-   release_mem_region(hcd-rsrc_start, hcd-rsrc_len);
-
   err1:
usb_put_hcd(hcd);
return retval;
@@ -246,15 +224,7 @@ static void usb_hcd_at91_remove(struct usb_hcd *hcd,
  {
usb_remove_hcd(hcd);
at91_stop_hc(pdev);
-   iounmap(hcd-regs);
-   release_mem_region(hcd-rsrc_start, hcd-rsrc_len);
usb_put_hcd(hcd);
-
-   if (IS_ENABLED(CONFIG_COMMON_CLK))
-   clk_put(uclk);
-   clk_put(hclk);
-   clk_put(fclk);
-   clk_put(iclk);
fclk = iclk = hclk = NULL;
  }





--
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] usb: ohci-at91: replace request_mem_region + ioremap by devm_request_and_ioremap

2013-12-03 Thread Nicolas Ferre

On 03/12/2013 15:07, Boris BREZILLON :

Replace the request_mem_region + ioremap calls by the
devm_request_and_ioremap call which does the same things but with device
managed resources.

Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com
Tested-by: Robert Nelson robertcnel...@gmail.com


Acked-by: Nicolas Ferre nicolas.fe...@atmel.com


---
  drivers/usb/host/ohci-at91.c |   24 +---
  1 file changed, 5 insertions(+), 19 deletions(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 7aec6ca..c406f1e 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -157,24 +157,18 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
hcd-rsrc_start = mem_r-start;
hcd-rsrc_len = resource_size(mem_r);

-   if (!request_mem_region(hcd-rsrc_start, hcd-rsrc_len, hcd_name)) {
-   pr_debug(request_mem_region failed\n);
-   retval = -EBUSY;
-   goto err1;
-   }
-
-   hcd-regs = ioremap(hcd-rsrc_start, hcd-rsrc_len);
+   hcd-regs = devm_request_and_ioremap(pdev-dev, mem_r);
if (!hcd-regs) {
-   pr_debug(ioremap failed\n);
+   dev_dbg(dev, devm_request_and_ioremap failed\n);
retval = -EIO;
-   goto err2;
+   goto err;
}

iclk = clk_get(pdev-dev, ohci_clk);
if (IS_ERR(iclk)) {
dev_err(pdev-dev, failed to get ohci_clk\n);
retval = PTR_ERR(iclk);
-   goto err3;
+   goto err;
}
fclk = clk_get(pdev-dev, uhpck);
if (IS_ERR(fclk)) {
@@ -218,13 +212,7 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
   err4:
clk_put(iclk);

- err3:
-   iounmap(hcd-regs);
-
- err2:
-   release_mem_region(hcd-rsrc_start, hcd-rsrc_len);
-
- err1:
+ err:
usb_put_hcd(hcd);
return retval;
  }
@@ -247,8 +235,6 @@ static void usb_hcd_at91_remove(struct usb_hcd *hcd,
  {
usb_remove_hcd(hcd);
at91_stop_hc(pdev);
-   iounmap(hcd-regs);
-   release_mem_region(hcd-rsrc_start, hcd-rsrc_len);
usb_put_hcd(hcd);

if (IS_ENABLED(CONFIG_COMMON_CLK))




--
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] usb: ohci-at91: fix irq and iomem resource retrieval

2013-12-03 Thread Nicolas Ferre

On 03/12/2013 15:07, Boris BREZILLON :

When using dt resources retrieval (interrupts and reg properties) there is
no predefined order for these resources in the platform dev resource
table.

Retrieve resources using the platform_get_resource function instead of
direct resource table entries to avoid resource type mismatch.

Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com
Tested-by: Robert Nelson robertcnel...@gmail.com


Acked-by: Nicolas Ferre nicolas.fe...@atmel.com


---
  drivers/usb/host/ohci-at91.c |   19 +++
  1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 418444e..7aec6ca 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -136,23 +136,26 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
struct ohci_hcd *ohci;
int retval;
struct usb_hcd *hcd = NULL;
+   struct device *dev = pdev-dev;
+   struct resource *mem_r, *irq_r;

-   if (pdev-num_resources != 2) {
-   pr_debug(hcd probe: invalid num_resources);
+   mem_r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   if (!mem_r) {
+   dev_dbg(dev, hcd probe: missing memory resource\n);
return -ENODEV;
}

-   if ((pdev-resource[0].flags != IORESOURCE_MEM)
-   || (pdev-resource[1].flags != IORESOURCE_IRQ)) {
-   pr_debug(hcd probe: invalid resource type\n);
+   irq_r = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+   if (!irq_r) {
+   dev_dbg(dev, hcd probe: missing irq resource\n);
return -ENODEV;
}

hcd = usb_create_hcd(driver, pdev-dev, at91);
if (!hcd)
return -ENOMEM;
-   hcd-rsrc_start = pdev-resource[0].start;
-   hcd-rsrc_len = resource_size(pdev-resource[0]);
+   hcd-rsrc_start = mem_r-start;
+   hcd-rsrc_len = resource_size(mem_r);

if (!request_mem_region(hcd-rsrc_start, hcd-rsrc_len, hcd_name)) {
pr_debug(request_mem_region failed\n);
@@ -199,7 +202,7 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
ohci-num_ports = board-ports;
at91_start_hc(pdev);

-   retval = usb_add_hcd(hcd, pdev-resource[1].start, IRQF_SHARED);
+   retval = usb_add_hcd(hcd, irq_r-start, IRQF_SHARED);
if (retval == 0)
return retval;





--
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/3] usb: ohci-at91: use device managed clk retrieval

2013-12-03 Thread Nicolas Ferre

On 03/12/2013 15:07, Boris BREZILLON :

Replace clk_get calls by devm_clk_get calls.

Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com
Tested-by: Robert Nelson robertcnel...@gmail.com


Acked-by: Nicolas Ferre nicolas.fe...@atmel.com

Thanks Boris for these fixes.

Alan, Greg, can you take the whole series as fixes for 3.13?

Thanks, best regards,


---
  drivers/usb/host/ohci-at91.c |   32 
  1 file changed, 8 insertions(+), 24 deletions(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index c406f1e..3652962 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -164,30 +164,30 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
goto err;
}

-   iclk = clk_get(pdev-dev, ohci_clk);
+   iclk = devm_clk_get(dev, ohci_clk);
if (IS_ERR(iclk)) {
-   dev_err(pdev-dev, failed to get ohci_clk\n);
+   dev_err(dev, failed to get ohci_clk\n);
retval = PTR_ERR(iclk);
goto err;
}
-   fclk = clk_get(pdev-dev, uhpck);
+   fclk = devm_clk_get(dev, uhpck);
if (IS_ERR(fclk)) {
dev_err(pdev-dev, failed to get uhpck\n);
retval = PTR_ERR(fclk);
-   goto err4;
+   goto err;
}
-   hclk = clk_get(pdev-dev, hclk);
+   hclk = devm_clk_get(dev, hclk);
if (IS_ERR(hclk)) {
dev_err(pdev-dev, failed to get hclk\n);
retval = PTR_ERR(hclk);
-   goto err5;
+   goto err;
}
if (IS_ENABLED(CONFIG_COMMON_CLK)) {
-   uclk = clk_get(pdev-dev, usb_clk);
+   uclk = devm_clk_get(pdev-dev, usb_clk);
if (IS_ERR(uclk)) {
dev_err(pdev-dev, failed to get uclk\n);
retval = PTR_ERR(uclk);
-   goto err6;
+   goto err;
}
}

@@ -203,15 +203,6 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
/* Error handling */
at91_stop_hc(pdev);

-   if (IS_ENABLED(CONFIG_COMMON_CLK))
-   clk_put(uclk);
- err6:
-   clk_put(hclk);
- err5:
-   clk_put(fclk);
- err4:
-   clk_put(iclk);
-
   err:
usb_put_hcd(hcd);
return retval;
@@ -236,13 +227,6 @@ static void usb_hcd_at91_remove(struct usb_hcd *hcd,
usb_remove_hcd(hcd);
at91_stop_hc(pdev);
usb_put_hcd(hcd);
-
-   if (IS_ENABLED(CONFIG_COMMON_CLK))
-   clk_put(uclk);
-   clk_put(hclk);
-   clk_put(fclk);
-   clk_put(iclk);
-   fclk = iclk = hclk = NULL;
  }

  /*-*/




--
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6 00/16] ARM: at91: move to common clk framework

2013-12-02 Thread Nicolas Ferre
/mach-at91/at91sam9n12.c   |2 +-
  arch/arm/mach-at91/at91sam9rl.c|2 +-
  arch/arm/mach-at91/at91sam9x5.c|2 +-
  arch/arm/mach-at91/clock.c |7 +-
  arch/arm/mach-at91/generic.h   |3 +-
  arch/arm/mach-at91/pm.c|2 +-
  arch/arm/mach-at91/pm_slowclock.S  |2 +-
  arch/arm/mach-at91/sama5d3.c   |2 +-
  arch/arm/mach-at91/setup.c |8 +-
  drivers/clk/Makefile   |1 +
  drivers/clk/at91/Makefile  |   12 +
  drivers/clk/at91/clk-main.c|  187 +++
  drivers/clk/at91/clk-master.c  |  270 ++
  drivers/clk/at91/clk-peripheral.c  |  410 +++
  drivers/clk/at91/clk-pll.c |  531 
  drivers/clk/at91/clk-plldiv.c  |  135 +
  drivers/clk/at91/clk-programmable.c|  366 ++
  drivers/clk/at91/clk-smd.c |  171 +++
  drivers/clk/at91/clk-system.c  |  135 +
  drivers/clk/at91/clk-usb.c |  398 +++
  drivers/clk/at91/clk-utmi.c|  159 ++
  drivers/clk/at91/pmc.c |  397 +++
  drivers/clk/at91/pmc.h |  116 +
  drivers/usb/gadget/atmel_usba_udc.c|2 +-
  include/dt-bindings/clk/at91.h |   22 +
  .../include/mach = include/linux/clk}/at91_pmc.h  |4 +-
  36 files changed, 3741 insertions(+), 20 deletions(-)
  create mode 100644 Documentation/devicetree/bindings/clock/at91-clock.txt
  create mode 100644 drivers/clk/at91/Makefile
  create mode 100644 drivers/clk/at91/clk-main.c
  create mode 100644 drivers/clk/at91/clk-master.c
  create mode 100644 drivers/clk/at91/clk-peripheral.c
  create mode 100644 drivers/clk/at91/clk-pll.c
  create mode 100644 drivers/clk/at91/clk-plldiv.c
  create mode 100644 drivers/clk/at91/clk-programmable.c
  create mode 100644 drivers/clk/at91/clk-smd.c
  create mode 100644 drivers/clk/at91/clk-system.c
  create mode 100644 drivers/clk/at91/clk-usb.c
  create mode 100644 drivers/clk/at91/clk-utmi.c
  create mode 100644 drivers/clk/at91/pmc.c
  create mode 100644 drivers/clk/at91/pmc.h
  create mode 100644 include/dt-bindings/clk/at91.h
  rename {arch/arm/mach-at91/include/mach = include/linux/clk}/at91_pmc.h (98%)

--
1.7.9.5





--
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] USB: ehci-atmel: add usb_clk for transition to CCF

2013-11-04 Thread Nicolas Ferre

On 18/10/2013 21:26, Boris BREZILLON :

The AT91 PMC (Power Management Controller) provides a USB clock used by
the different USB controllers (ehci, ohci and udc).
The atmel-ehci driver must configure the usb clock rate to 48Mhz in order
to get a fully functionnal USB host controller.
This configuration was formely done in mach-at91/clock.c, but will be
bypassed when moving to common clk framework.

This patch adds support for usb clock retrieval and configuration only if
CCF is enabled (CONFIG_COMMON_CLK).

Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com


Acked-by: Nicolas Ferre nicolas.fe...@atmel.com

Greg, as this patch is already in your tree, it is only for the record. 
I have tested it and it works now.


Thanks Boris, bye.



---
  drivers/usb/host/ehci-atmel.c |   16 +++-
  1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
index 3b645ff..f417526 100644
--- a/drivers/usb/host/ehci-atmel.c
+++ b/drivers/usb/host/ehci-atmel.c
@@ -30,13 +30,17 @@ static const char hcd_name[] = ehci-atmel;
  static struct hc_driver __read_mostly ehci_atmel_hc_driver;

  /* interface and function clocks */
-static struct clk *iclk, *fclk;
+static struct clk *iclk, *fclk, *uclk;
  static int clocked;

  /*-*/

  static void atmel_start_clock(void)
  {
+   if (IS_ENABLED(CONFIG_COMMON_CLK)) {
+   clk_set_rate(uclk, 4800);
+   clk_prepare_enable(uclk);
+   }
clk_prepare_enable(iclk);
clk_prepare_enable(fclk);
clocked = 1;
@@ -46,6 +50,8 @@ static void atmel_stop_clock(void)
  {
clk_disable_unprepare(fclk);
clk_disable_unprepare(iclk);
+   if (IS_ENABLED(CONFIG_COMMON_CLK))
+   clk_disable_unprepare(uclk);
clocked = 0;
  }

@@ -130,6 +136,14 @@ static int ehci_atmel_drv_probe(struct platform_device 
*pdev)
retval = -ENOENT;
goto fail_request_resource;
}
+   if (IS_ENABLED(CONFIG_COMMON_CLK)) {
+   uclk = devm_clk_get(pdev-dev, usb_clk);
+   if (IS_ERR(uclk)) {
+   dev_err(pdev-dev, failed to get uclk\n);
+   retval = PTR_ERR(uclk);
+   goto fail_request_resource;
+   }
+   }

ehci = hcd_to_ehci(hcd);
/* registers start at offset 0x0 */




--
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 13/17] clk: at91: add PMC usb clock

2013-10-18 Thread Nicolas Ferre

On 17/10/2013 18:55, Boris BREZILLON :

This patch adds new at91 usb clock implementation using common clk framework.
This clock is used to clock usb ports (ohci, ehci and udc).

Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com


Ok, this one is now replacing the older 13/17.

Thanks Boris.

Bye,


---
  arch/arm/mach-at91/Kconfig |   11 ++
  drivers/clk/at91/Makefile  |1 +
  drivers/clk/at91/clk-usb.c |  400 
  drivers/clk/at91/pmc.c |   15 ++
  drivers/clk/at91/pmc.h |9 +
  5 files changed, 436 insertions(+)
  create mode 100644 drivers/clk/at91/clk-usb.c

diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 6ad37da..b76dc4c 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -3,6 +3,9 @@ if ARCH_AT91
  config HAVE_AT91_UTMI
bool

+config HAVE_AT91_USB_CLK
+   bool
+
  config HAVE_AT91_DBGU0
bool

@@ -82,6 +85,7 @@ config SOC_SAMA5D3
select HAVE_AT91_DBGU1
select AT91_USE_OLD_CLK
select HAVE_AT91_UTMI
+   select HAVE_AT91_USB_CLK
help
  Select this if you are using one of Atmel's SAMA5D3 family SoC.
  This support covers SAMA5D31, SAMA5D33, SAMA5D34, SAMA5D35.
@@ -96,12 +100,14 @@ config SOC_AT91RM9200
select MULTI_IRQ_HANDLER
select SPARSE_IRQ
select AT91_USE_OLD_CLK
+   select HAVE_AT91_USB_CLK

  config SOC_AT91SAM9260
bool AT91SAM9260, AT91SAM9XE or AT91SAM9G20
select HAVE_AT91_DBGU0
select SOC_AT91SAM9
select AT91_USE_OLD_CLK
+   select HAVE_AT91_USB_CLK
help
  Select this if you are using one of Atmel's AT91SAM9260, AT91SAM9XE
  or AT91SAM9G20 SoC.
@@ -112,6 +118,7 @@ config SOC_AT91SAM9261
select HAVE_FB_ATMEL
select SOC_AT91SAM9
select AT91_USE_OLD_CLK
+   select HAVE_AT91_USB_CLK
help
  Select this if you are using one of Atmel's AT91SAM9261 or 
AT91SAM9G10 SoC.

@@ -121,6 +128,7 @@ config SOC_AT91SAM9263
select HAVE_FB_ATMEL
select SOC_AT91SAM9
select AT91_USE_OLD_CLK
+   select HAVE_AT91_USB_CLK

  config SOC_AT91SAM9RL
bool AT91SAM9RL
@@ -137,6 +145,7 @@ config SOC_AT91SAM9G45
select SOC_AT91SAM9
select AT91_USE_OLD_CLK
select HAVE_AT91_UTMI
+   select HAVE_AT91_USB_CLK
help
  Select this if you are using one of Atmel's AT91SAM9G45 family SoC.
  This support covers AT91SAM9G45, AT91SAM9G46, AT91SAM9M10 and 
AT91SAM9M11.
@@ -148,6 +157,7 @@ config SOC_AT91SAM9X5
select SOC_AT91SAM9
select AT91_USE_OLD_CLK
select HAVE_AT91_UTMI
+   select HAVE_AT91_USB_CLK
help
  Select this if you are using one of Atmel's AT91SAM9x5 family SoC.
  This means that your SAM9 name finishes with a '5' (except if it is
@@ -161,6 +171,7 @@ config SOC_AT91SAM9N12
select HAVE_FB_ATMEL
select SOC_AT91SAM9
select AT91_USE_OLD_CLK
+   select HAVE_AT91_USB_CLK
help
  Select this if you are using Atmel's AT91SAM9N12 SoC.

diff --git a/drivers/clk/at91/Makefile b/drivers/clk/at91/Makefile
index a824883..61db058 100644
--- a/drivers/clk/at91/Makefile
+++ b/drivers/clk/at91/Makefile
@@ -8,3 +8,4 @@ obj-y += clk-system.o clk-peripheral.o

  obj-$(CONFIG_AT91_PROGRAMMABLE_CLOCKS)+= clk-programmable.o
  obj-$(CONFIG_HAVE_AT91_UTMI)  += clk-utmi.o
+obj-$(CONFIG_HAVE_AT91_USB_CLK)+= clk-usb.o
diff --git a/drivers/clk/at91/clk-usb.c b/drivers/clk/at91/clk-usb.c
new file mode 100644
index 000..0454555
--- /dev/null
+++ b/drivers/clk/at91/clk-usb.c
@@ -0,0 +1,400 @@
+/*
+ * drivers/clk/at91/clk-usb.c
+ *
+ *  Copyright (C) 2013 Boris BREZILLON b.brezil...@overkiz.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include linux/clk-provider.h
+#include linux/clkdev.h
+#include linux/clk/at91_pmc.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/io.h
+
+#include pmc.h
+
+#define USB_SOURCE_MAX 2
+
+#define SAM9X5_USB_DIV_SHIFT   8
+#define SAM9X5_USB_MAX_DIV 0xf
+
+#define RM9200_USB_DIV_SHIFT   28
+#define RM9200_USB_DIV_TAB_SIZE4
+
+struct at91sam9x5_clk_usb {
+   struct clk_hw hw;
+   struct at91_pmc *pmc;
+};
+
+#define to_at91sam9x5_clk_usb(hw) \
+   container_of(hw, struct at91sam9x5_clk_usb, hw)
+
+struct at91rm9200_clk_usb {
+   struct clk_hw hw;
+   struct at91_pmc *pmc;
+   u32 divisors[4];
+};
+
+#define to_at91rm9200_clk_usb(hw) \
+   container_of(hw, struct at91rm9200_clk_usb, hw)
+
+static unsigned long at91sam9x5_clk_usb_recalc_rate(struct clk_hw *hw

Re: [PATCH v4 00/17] ARM: at91: move to common clk framework

2013-10-18 Thread Nicolas Ferre
 |  539 
  drivers/clk/at91/clk-plldiv.c  |  137 +
  drivers/clk/at91/clk-programmable.c|  423 +++
  drivers/clk/at91/clk-smd.c |  173 +++
  drivers/clk/at91/clk-system.c  |  193 +++
  drivers/clk/at91/clk-usb.c |  400 +++
  drivers/clk/at91/clk-utmi.c|  162 ++
  drivers/clk/at91/pmc.c |  372 ++
  drivers/clk/at91/pmc.h |  113 
  drivers/usb/gadget/atmel_usba_udc.c|2 +-
  include/dt-bindings/clk/at91.h |   28 +
  .../include/mach = include/linux/clk}/at91_pmc.h  |4 +-
  36 files changed, 3847 insertions(+), 20 deletions(-)
  create mode 100644 Documentation/devicetree/bindings/clock/at91-clock.txt
  create mode 100644 drivers/clk/at91/Makefile
  create mode 100644 drivers/clk/at91/clk-main.c
  create mode 100644 drivers/clk/at91/clk-master.c
  create mode 100644 drivers/clk/at91/clk-peripheral.c
  create mode 100644 drivers/clk/at91/clk-pll.c
  create mode 100644 drivers/clk/at91/clk-plldiv.c
  create mode 100644 drivers/clk/at91/clk-programmable.c
  create mode 100644 drivers/clk/at91/clk-smd.c
  create mode 100644 drivers/clk/at91/clk-system.c
  create mode 100644 drivers/clk/at91/clk-usb.c
  create mode 100644 drivers/clk/at91/clk-utmi.c
  create mode 100644 drivers/clk/at91/pmc.c
  create mode 100644 drivers/clk/at91/pmc.h
  create mode 100644 include/dt-bindings/clk/at91.h
  rename {arch/arm/mach-at91/include/mach = include/linux/clk}/at91_pmc.h (98%)




--
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 03/17] clk: at91: add PMC base support

2013-10-17 Thread Nicolas Ferre

On 11/10/2013 09:37, Boris BREZILLON :

This patch adds at91 PMC (Power Management Controller) base support.

All at91 clocks managed by the PMC unit will use this framework.

This framework provides the following fonctionalities:
- define a new struct at91_pmc to hide PMC internals (lock, PMC memory
   mapping, irq domain, ...)
- read/write helper functions (pmc_read/write) to access PMC registers
- lock/unlock helper functions (pmc_lock/unlock) to lock/unlock access to
   pmc registers
- a new irq domain and its associated irq chip to request PMC specific
   interrupts (useful for clk prepare callbacks)

The PMC unit is declared as a dt clk provider (CLK_OF_DECLARE), and every
clk using this framework will declare a table of of_at91_clk_init_cb_t
and add it to the pmc_clk_ids table.

When the pmc dt clock setup function is called (by of_clk_init function),
it triggers the registration of every supported child clk (those matching
the definitions in pmc_clk_ids).

This patch copies at91_pmc_base (memory mapping) and at91sam9_idle
(function) from arch/arm/mach-at91/clock.c (which is not compiled if
COMMON_CLK_AT91 is enabled).

Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com


Acked-by: Nicolas Ferre nicolas.fe...@atmel.com


---
  drivers/clk/Makefile  |1 +
  drivers/clk/at91/Makefile |5 +
  drivers/clk/at91/pmc.c|  283 +
  drivers/clk/at91/pmc.h|   58 ++
  4 files changed, 347 insertions(+)
  create mode 100644 drivers/clk/at91/Makefile
  create mode 100644 drivers/clk/at91/pmc.c
  create mode 100644 drivers/clk/at91/pmc.h

diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 7b11106..28c2678 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -32,6 +32,7 @@ obj-$(CONFIG_ARCH_VT8500) += clk-vt8500.o
  obj-$(CONFIG_ARCH_ZYNQ)   += zynq/
  obj-$(CONFIG_ARCH_TEGRA)  += tegra/
  obj-$(CONFIG_PLAT_SAMSUNG)+= samsung/
+obj-$(CONFIG_COMMON_CLK_AT91)  += at91/

  obj-$(CONFIG_X86) += x86/

diff --git a/drivers/clk/at91/Makefile b/drivers/clk/at91/Makefile
new file mode 100644
index 000..1d4fb21
--- /dev/null
+++ b/drivers/clk/at91/Makefile
@@ -0,0 +1,5 @@
+#
+# Makefile for at91 specific clk
+#
+
+obj-y += pmc.o
diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
new file mode 100644
index 000..d92e46c
--- /dev/null
+++ b/drivers/clk/at91/pmc.c
@@ -0,0 +1,283 @@
+/*
+ * drivers/clk/at91/pmc.c
+ *
+ *  Copyright (C) 2013 Boris BREZILLON b.brezil...@overkiz.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include linux/clk-provider.h
+#include linux/clkdev.h
+#include linux/clk/at91_pmc.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/io.h
+#include linux/interrupt.h
+#include linux/irq.h
+#include linux/irqchip/chained_irq.h
+#include linux/irqdomain.h
+#include linux/of_irq.h
+
+#include asm/proc-fns.h
+
+#include pmc.h
+
+void __iomem *at91_pmc_base;
+EXPORT_SYMBOL_GPL(at91_pmc_base);
+
+void at91sam9_idle(void)
+{
+   at91_pmc_write(AT91_PMC_SCDR, AT91_PMC_PCK);
+   cpu_do_idle();
+}
+
+static void pmc_irq_mask(struct irq_data *d)
+{
+   struct at91_pmc *pmc = irq_data_get_irq_chip_data(d);
+
+   pmc_write(pmc, AT91_PMC_IDR, 1  d-hwirq);
+}
+
+static void pmc_irq_unmask(struct irq_data *d)
+{
+   struct at91_pmc *pmc = irq_data_get_irq_chip_data(d);
+
+   pmc_write(pmc, AT91_PMC_IER, 1  d-hwirq);
+}
+
+static int pmc_irq_set_type(struct irq_data *d, unsigned type)
+{
+   if (type != IRQ_TYPE_LEVEL_HIGH) {
+   pr_warn(PMC: type not supported (support only IRQ_TYPE_LEVEL_HIGH 
type)\n);
+   return -EINVAL;
+   }
+
+   return 0;
+}
+
+static struct irq_chip pmc_irq = {
+   .name = PMC,
+   .irq_disable = pmc_irq_mask,
+   .irq_mask = pmc_irq_mask,
+   .irq_unmask = pmc_irq_unmask,
+   .irq_set_type = pmc_irq_set_type,
+};
+
+static struct lock_class_key pmc_lock_class;
+
+static int pmc_irq_map(struct irq_domain *h, unsigned int virq,
+  irq_hw_number_t hw)
+{
+   struct at91_pmc *pmc = h-host_data;
+
+   irq_set_lockdep_class(virq, pmc_lock_class);
+
+   irq_set_chip_and_handler(virq, pmc_irq,
+handle_level_irq);
+   set_irq_flags(virq, IRQF_VALID);
+   irq_set_chip_data(virq, pmc);
+
+   return 0;
+}
+
+static int pmc_irq_domain_xlate(struct irq_domain *d,
+   struct device_node *ctrlr,
+   const u32 *intspec, unsigned int intsize,
+   irq_hw_number_t *out_hwirq,
+   unsigned int *out_type)
+{
+   struct at91_pmc *pmc = d-host_data;
+   const

Re: [PATCH v4 04/17] clk: at91: add PMC macro file for dt definitions

2013-10-17 Thread Nicolas Ferre

On 11/10/2013 10:41, Boris BREZILLON :

This patch adds a new macro file for PMC macros.

This macro file includes the definitions of SR (status register) bit
offsets and will be use to reference PMC irqs.

Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com


Acked-by: Nicolas Ferre nicolas.fe...@atmel.com


---
  include/dt-bindings/clk/at91.h |   22 ++
  1 file changed, 22 insertions(+)
  create mode 100644 include/dt-bindings/clk/at91.h

diff --git a/include/dt-bindings/clk/at91.h b/include/dt-bindings/clk/at91.h
new file mode 100644
index 000..0b4cb99
--- /dev/null
+++ b/include/dt-bindings/clk/at91.h
@@ -0,0 +1,22 @@
+/*
+ * This header provides constants for AT91 pmc status.
+ *
+ * The constants defined in this header are being used in dts.
+ *
+ * Licensed under GPLv2 or later.
+ */
+
+#ifndef _DT_BINDINGS_CLK_AT91_H
+#define _DT_BINDINGS_CLK_AT91_H
+
+#define AT91_PMC_MOSCS 0   /* MOSCS Flag */
+#define AT91_PMC_LOCKA 1   /* PLLA Lock */
+#define AT91_PMC_LOCKB 2   /* PLLB Lock */
+#define AT91_PMC_MCKRDY3   /* Master Clock */
+#define AT91_PMC_LOCKU 6   /* UPLL Lock */
+#define AT91_PMC_PCKRDY(id)(8 + (id))  /* Programmable Clock */
+#define AT91_PMC_MOSCSELS  16  /* Main Oscillator Selection */
+#define AT91_PMC_MOSCRCS   17  /* Main On-Chip RC */
+#define AT91_PMC_CFDEV 18  /* Clock Failure Detector Event 
*/
+
+#endif




--
Nicolas Ferre
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


  1   2   >