Re: [PATCH 17/22] USB: udc: atmel_usba_udc: no need to check return value of debugfs_create functions

2018-05-30 Thread Alexandre Belloni
On 29/05/2018 17:31:02+0200, Greg Kroah-Hartman wrote:
> When calling debugfs functions, there is no need to ever check the
> return value.  The function can work or not, but the code logic should
> never do something different based on this.
> 
> There is also no need to keep the file dentries around at all, so remove
> those variables from the device structure.
> 
> Cc: Nicolas Ferre 
> Cc: Felipe Balbi 
> Cc: Alexandre Belloni 
> Signed-off-by: Greg Kroah-Hartman 

Reviewed-by: Alexandre Belloni 

> ---
>  drivers/usb/gadget/udc/atmel_usba_udc.c | 71 -
>  drivers/usb/gadget/udc/atmel_usba_udc.h |  4 --
>  2 files changed, 11 insertions(+), 64 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
> b/drivers/usb/gadget/udc/atmel_usba_udc.c
> index 2f586f2bda7e..a4d99bf50f2f 100644
> --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
> @@ -206,94 +206,45 @@ static void usba_ep_init_debugfs(struct usba_udc *udc,
>   struct dentry *ep_root;
>  
>   ep_root = debugfs_create_dir(ep->ep.name, udc->debugfs_root);
> - if (!ep_root)
> - goto err_root;
>   ep->debugfs_dir = ep_root;
>  
> - ep->debugfs_queue = debugfs_create_file("queue", 0400, ep_root,
> - ep, _dbg_fops);
> - if (!ep->debugfs_queue)
> - goto err_queue;
> -
> - if (ep->can_dma) {
> - ep->debugfs_dma_status
> - = debugfs_create_u32("dma_status", 0400, ep_root,
> - >last_dma_status);
> - if (!ep->debugfs_dma_status)
> - goto err_dma_status;
> - }
> - if (ep_is_control(ep)) {
> - ep->debugfs_state
> - = debugfs_create_u32("state", 0400, ep_root,
> - >state);
> - if (!ep->debugfs_state)
> - goto err_state;
> - }
> -
> - return;
> -
> -err_state:
> + debugfs_create_file("queue", 0400, ep_root, ep, _dbg_fops);
>   if (ep->can_dma)
> - debugfs_remove(ep->debugfs_dma_status);
> -err_dma_status:
> - debugfs_remove(ep->debugfs_queue);
> -err_queue:
> - debugfs_remove(ep_root);
> -err_root:
> - dev_err(>udc->pdev->dev,
> - "failed to create debugfs directory for %s\n", ep->ep.name);
> + debugfs_create_u32("dma_status", 0400, ep_root,
> +>last_dma_status);
> + if (ep_is_control(ep))
> + debugfs_create_u32("state", 0400, ep_root, >state);
>  }
>  
>  static void usba_ep_cleanup_debugfs(struct usba_ep *ep)
>  {
> - debugfs_remove(ep->debugfs_queue);
> - debugfs_remove(ep->debugfs_dma_status);
> - debugfs_remove(ep->debugfs_state);
> - debugfs_remove(ep->debugfs_dir);
> - ep->debugfs_dma_status = NULL;
> - ep->debugfs_dir = NULL;
> + debugfs_remove_recursive(ep->debugfs_dir);
>  }
>  
>  static void usba_init_debugfs(struct usba_udc *udc)
>  {
> - struct dentry *root, *regs;
> + struct dentry *root;
>   struct resource *regs_resource;
>  
>   root = debugfs_create_dir(udc->gadget.name, NULL);
> - if (IS_ERR(root) || !root)
> - goto err_root;
>   udc->debugfs_root = root;
>  
>   regs_resource = platform_get_resource(udc->pdev, IORESOURCE_MEM,
>   CTRL_IOMEM_ID);
>  
>   if (regs_resource) {
> - regs = debugfs_create_file_size("regs", 0400, root, udc,
> - _dbg_fops,
> - resource_size(regs_resource));
> - if (!regs)
> - goto err_regs;
> - udc->debugfs_regs = regs;
> + debugfs_create_file_size("regs", 0400, root, udc,
> +  _dbg_fops,
> +  resource_size(regs_resource));
>   }
>  
>   usba_ep_init_debugfs(udc, to_usba_ep(udc->gadget.ep0));
> -
> - return;
> -
> -err_regs:
> - debugfs_remove(root);
> -err_root:
> - udc->debugfs_root = NULL;
> - dev_err(>pdev->dev, "debugfs is not available\n");
>  }
>  
>  static void usba_cleanup_debugfs(struct usba_udc *udc)
>  {
>   usba_ep_cleanup_debugfs(to_usba_ep(udc->gadget.ep0));
> - debugfs_remove(udc->debugfs_r

Re: [PATCH 17/22] USB: udc: atmel_usba_udc: no need to check return value of debugfs_create functions

2018-05-30 Thread Alexandre Belloni
Hi,

On 29/05/2018 17:31:02+0200, Greg Kroah-Hartman wrote:
> When calling debugfs functions, there is no need to ever check the
> return value.  The function can work or not, but the code logic should
> never do something different based on this.
> 
> There is also no need to keep the file dentries around at all, so remove
> those variables from the device structure.
> 
> Cc: Nicolas Ferre 
> Cc: Felipe Balbi 
> Cc: Alexandre Belloni 
> Signed-off-by: Greg Kroah-Hartman 
> ---
>  drivers/usb/gadget/udc/atmel_usba_udc.c | 71 -
>  drivers/usb/gadget/udc/atmel_usba_udc.h |  4 --
>  2 files changed, 11 insertions(+), 64 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
> b/drivers/usb/gadget/udc/atmel_usba_udc.c
> index 2f586f2bda7e..a4d99bf50f2f 100644
> --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
> @@ -206,94 +206,45 @@ static void usba_ep_init_debugfs(struct usba_udc *udc,
>   struct dentry *ep_root;
>  
>   ep_root = debugfs_create_dir(ep->ep.name, udc->debugfs_root);
> - if (!ep_root)
> - goto err_root;
>   ep->debugfs_dir = ep_root;
>  
> - ep->debugfs_queue = debugfs_create_file("queue", 0400, ep_root,
> - ep, _dbg_fops);
> - if (!ep->debugfs_queue)
> - goto err_queue;
> -
> - if (ep->can_dma) {
> - ep->debugfs_dma_status
> - = debugfs_create_u32("dma_status", 0400, ep_root,
> - >last_dma_status);
> - if (!ep->debugfs_dma_status)
> - goto err_dma_status;
> - }
> - if (ep_is_control(ep)) {
> - ep->debugfs_state
> - = debugfs_create_u32("state", 0400, ep_root,
> - >state);
> - if (!ep->debugfs_state)
> - goto err_state;
> - }
> -
> - return;
> -
> -err_state:
> + debugfs_create_file("queue", 0400, ep_root, ep, _dbg_fops);

What happens here if debugfs_create_dir returned NULL? I guess the file
will be placed at the root of the debugfs filesystem which is not great.

Should we stop caring about that and assume that if debugfs_create_dir,
the following debugfs_create_* calls will fail?



-- 
Alexandre Belloni, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
--
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] clk: at91: Added more information logging.

2018-04-10 Thread Alexandre Belloni
 fclk\n");
>   clk_disable_unprepare(ohci_at91->fclk);
>   clk_disable_unprepare(ohci_at91->iclk);
>   clk_disable_unprepare(ohci_at91->hclk);
> @@ -104,7 +108,7 @@ static void at91_start_hc(struct platform_device *pdev)
>   /*
>* Start the USB clocks.
>*/
> - at91_start_clock(ohci_at91);
> + at91_start_clock(ohci_at91, >dev);
>  
>   /*
>* The USB host controller must remain in reset.
> @@ -128,7 +132,7 @@ static void at91_stop_hc(struct platform_device *pdev)
>   /*
>* Stop the USB clocks.
>*/
> - at91_stop_clock(ohci_at91);
> + at91_stop_clock(ohci_at91, >dev);
>  }
>  
>  
> @@ -623,7 +627,7 @@ ohci_hcd_at91_drv_suspend(struct device *dev)
>  
>   /* flush the writes */
>   (void) ohci_readl (ohci, >regs->control);
> - at91_stop_clock(ohci_at91);
> + at91_stop_clock(ohci_at91, dev);
>   }
>  
>   return ret;
> @@ -638,7 +642,7 @@ ohci_hcd_at91_drv_resume(struct device *dev)
>   if (ohci_at91->wakeup)
>   disable_irq_wake(hcd->irq);
>  
> - at91_start_clock(ohci_at91);
> + at91_start_clock(ohci_at91, dev);
>  
>   ohci_resume(hcd, false);
>  
> -- 
> 2.17.0
> 
> 

-- 
Alexandre Belloni, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
--
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 11/16] treewide: simplify Kconfig dependencies for removed archs

2018-03-19 Thread Alexandre Belloni
On 14/03/2018 at 15:43:46 +0100, Arnd Bergmann wrote:
> A lot of Kconfig symbols have architecture specific dependencies.
> In those cases that depend on architectures we have already removed,
> they can be omitted.
> 
> Signed-off-by: Arnd Bergmann <a...@arndb.de>
> ---
>  block/bounce.c   |  2 +-
>  drivers/ide/Kconfig  |  2 +-
>  drivers/ide/ide-generic.c| 12 +---
>  drivers/input/joystick/analog.c  |  2 +-
>  drivers/isdn/hisax/Kconfig   | 10 +-
>  drivers/net/ethernet/davicom/Kconfig |  2 +-
>  drivers/net/ethernet/smsc/Kconfig|  6 +++---
>  drivers/net/wireless/cisco/Kconfig   |  2 +-
>  drivers/pwm/Kconfig  |  2 +-
>  drivers/rtc/Kconfig  |  2 +-

Acked-by: Alexandre Belloni <alexandre.bell...@bootlin.com>

>  drivers/spi/Kconfig  |  4 ++--
>  drivers/usb/musb/Kconfig |  2 +-
>  drivers/video/console/Kconfig|  3 +--
>  drivers/watchdog/Kconfig |  6 --
>  drivers/watchdog/Makefile|  6 --
>  fs/Kconfig.binfmt|  5 ++---
>  fs/minix/Kconfig |  2 +-
>  include/linux/ide.h  |  7 +--
>  init/Kconfig |  5 ++---
>  lib/Kconfig.debug| 13 +
>  lib/test_user_copy.c |  2 --
>  mm/Kconfig   |  7 ---
>  mm/percpu.c  |  4 
>  23 files changed, 31 insertions(+), 77 deletions(-)
> 
> diff --git a/block/bounce.c b/block/bounce.c
> index 6a3e68292273..dd0b93f2a871 100644
> --- a/block/bounce.c
> +++ b/block/bounce.c
> @@ -31,7 +31,7 @@
>  static struct bio_set *bounce_bio_set, *bounce_bio_split;
>  static mempool_t *page_pool, *isa_page_pool;
>  
> -#if defined(CONFIG_HIGHMEM) || defined(CONFIG_NEED_BOUNCE_POOL)
> +#if defined(CONFIG_HIGHMEM)
>  static __init int init_emergency_pool(void)
>  {
>  #if defined(CONFIG_HIGHMEM) && !defined(CONFIG_MEMORY_HOTPLUG)
> diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
> index cf1fb3fb5d26..901b8833847f 100644
> --- a/drivers/ide/Kconfig
> +++ b/drivers/ide/Kconfig
> @@ -200,7 +200,7 @@ comment "IDE chipset support/bugfixes"
>  
>  config IDE_GENERIC
>   tristate "generic/default IDE chipset support"
> - depends on ALPHA || X86 || IA64 || M32R || MIPS || ARCH_RPC
> + depends on ALPHA || X86 || IA64 || MIPS || ARCH_RPC
>   default ARM && ARCH_RPC
>   help
> This is the generic IDE driver.  This driver attaches to the
> diff --git a/drivers/ide/ide-generic.c b/drivers/ide/ide-generic.c
> index 54d7c4685d23..80c0d69b83ac 100644
> --- a/drivers/ide/ide-generic.c
> +++ b/drivers/ide/ide-generic.c
> @@ -13,13 +13,10 @@
>  #include 
>  #include 
>  
> -/* FIXME: convert arm and m32r to use ide_platform host driver */
> +/* FIXME: convert arm to use ide_platform host driver */
>  #ifdef CONFIG_ARM
>  #include 
>  #endif
> -#ifdef CONFIG_M32R
> -#include 
> -#endif
>  
>  #define DRV_NAME "ide_generic"
>  
> @@ -35,13 +32,6 @@ static const struct ide_port_info ide_generic_port_info = {
>  #ifdef CONFIG_ARM
>  static const u16 legacy_bases[] = { 0x1f0 };
>  static const int legacy_irqs[]  = { IRQ_HARDDISK };
> -#elif defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_MAPPI2) || \
> -  defined(CONFIG_PLAT_OPSPUT)
> -static const u16 legacy_bases[] = { 0x1f0 };
> -static const int legacy_irqs[]  = { PLD_IRQ_CFIREQ };
> -#elif defined(CONFIG_PLAT_MAPPI3)
> -static const u16 legacy_bases[] = { 0x1f0, 0x170 };
> -static const int legacy_irqs[]  = { PLD_IRQ_CFIREQ, PLD_IRQ_IDEIREQ };
>  #elif defined(CONFIG_ALPHA)
>  static const u16 legacy_bases[] = { 0x1f0, 0x170, 0x1e8, 0x168 };
>  static const int legacy_irqs[]  = { 14, 15, 11, 10 };
> diff --git a/drivers/input/joystick/analog.c b/drivers/input/joystick/analog.c
> index be1b4921f22a..eefac7978f93 100644
> --- a/drivers/input/joystick/analog.c
> +++ b/drivers/input/joystick/analog.c
> @@ -163,7 +163,7 @@ static unsigned int get_time_pit(void)
>  #define GET_TIME(x)  do { x = (unsigned int)rdtsc(); } while (0)
>  #define DELTA(x,y)   ((y)-(x))
>  #define TIME_NAME"TSC"
> -#elif defined(__alpha__) || defined(CONFIG_ARM) || defined(CONFIG_ARM64) || 
> defined(CONFIG_RISCV) || defined(CONFIG_TILE)
> +#elif defined(__alpha__) || defined(CONFIG_ARM) || defined(CONFIG_ARM64) || 
> defined(CONFIG_RISCV)
>  #define GET_TIME(x)  do { x = get_cycles(); } while (0)
>  #define DELTA(x,y)   ((y)-(x))
>  #define TIME_NAME"get_cycles"
> d

Re: [PATCH v4 0/8] Various patches for SAMA5D2 backup mode

2017-09-28 Thread Alexandre Belloni
Hi,

On 28/09/2017 at 11:46:19 +0200, Romain Izard wrote:
> While the core of the backup mode for SAMA5D2 has been integrated in
> v4.13, it is far from complete. Individual controllers in the chip have
> drivers that do not support the reset of the registers during suspend,
> and they need to be adapted to handle it.
> 
> The first patch uses the clock wakeup code from the prototype backup
> mode instead of the version integrated in the mainline, as the mainline
> version is not stable. During a test loop with two-second backup
> suspend, the mainline version will hang in less than one day, whereas
> the prototype version has been running the same test for more than a
> week without hanging.
> 
> While all these patches are provided in a series, the clock, mtd,
> usb, pwm and mfd patch do not depend on each other.
> 
> Changes in v2:
> * drop the IIO patch duplicating existing code
> * determine the number of programmable clocks to save dynamically
> * declare a required local variable in the tty/serial patch
> 
> Changes in v3:
> * drop dev_printk changes for PMECC
> * rework the resume code for PMECC
> * improve comments on PMC clock handling
> 
> Changes in v4:
> * fix a bug in the PMECC resume code
> 
> Romain Izard (8):
>   clk: at91: pmc: Wait for clocks when resuming
>   clk: at91: pmc: Save SCSR during suspend
>   clk: at91: pmc: Support backup for programmable clocks
>   mtd: nand: atmel: Avoid ECC errors when leaving backup mode
>   ehci-atmel: Power down during suspend is normal
>   pwm: atmel-tcb: Support backup mode
>   atmel_flexcom: Support backup mode
>   tty/serial: atmel: Prevent a warning on suspend
> 

Really, you have to stop sending those independent patches as a series
if you want to have a chance to see them being merged.

>  drivers/clk/at91/clk-programmable.c  |  2 +
>  drivers/clk/at91/pmc.c   | 63 ++-
>  drivers/clk/at91/pmc.h   |  2 +
>  drivers/mfd/atmel-flexcom.c  | 65 
> 
>  drivers/mtd/nand/atmel/nand-controller.c |  3 ++
>  drivers/mtd/nand/atmel/pmecc.c   | 17 +
>  drivers/mtd/nand/atmel/pmecc.h   |  1 +
>  drivers/pwm/pwm-atmel-tcb.c  | 63 ++-
>  drivers/tty/serial/atmel_serial.c| 13 +++
>  drivers/usb/host/ehci-atmel.c|  3 +-
>  10 files changed, 196 insertions(+), 36 deletions(-)
> 
> -- 
> 2.11.0
> 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
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 8/9] atmel_flexcom: Support backup mode

2017-09-20 Thread Alexandre Belloni
On 20/09/2017 at 10:30:31 +0200, Romain Izard wrote:
> 2017-09-19 17:25 GMT+02:00 Lee Jones <lee.jo...@linaro.org>:
> > On Tue, 19 Sep 2017, Nicolas Ferre wrote:
> >
> >> 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(-)
> >
> > This is the first time I've seen this patch.  Why's that?
> >
> 
> As the patchset covers many subsystems, get_maintainers.pl provided a
> very long list of both developpers and mailing lists (28). I thought it
> was a good idea to shorten it a little. Bad idea. Sorry.
> 

I think the correct way of handling that would have been to send each
patch to the proper subsystem as there are no dependency here.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
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 Alexandre Belloni
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.


-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
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: Remove unnecessary macros

2017-06-16 Thread Alexandre Belloni
commit 46ddd79e893b ("usb: gadget: udc: atmel: Remove AVR32 bits from the
driver") left the accessor macros introduced by commit a3dd3befd7cb ("usb:
gadget: atmel_usba: use endian agnostic IO on ARM"). They can now be
removed.

Signed-off-by: Alexandre Belloni <alexandre.bell...@free-electrons.com>
---
 drivers/usb/gadget/udc/atmel_usba_udc.c |  4 ++--
 drivers/usb/gadget/udc/atmel_usba_udc.h | 16 ++--
 2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
b/drivers/usb/gadget/udc/atmel_usba_udc.c
index 3ccc34176a5a..98d71400f8a1 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -152,7 +152,7 @@ static int regs_dbg_open(struct inode *inode, struct file 
*file)
 
spin_lock_irq(>lock);
for (i = 0; i < inode->i_size / 4; i++)
-   data[i] = usba_io_readl(udc->regs + i * 4);
+   data[i] = readl_relaxed(udc->regs + i * 4);
spin_unlock_irq(>lock);
 
file->private_data = data;
@@ -1369,7 +1369,7 @@ static int handle_ep0_setup(struct usba_udc *udc, struct 
usba_ep *ep,
if (crq->wLength != cpu_to_le16(sizeof(status)))
goto stall;
ep->state = DATA_STAGE_IN;
-   usba_io_writew(status, ep->fifo);
+   writew_relaxed(status, ep->fifo);
usba_ep_writel(ep, SET_STA, USBA_TX_PK_RDY);
break;
}
diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.h 
b/drivers/usb/gadget/udc/atmel_usba_udc.h
index 433bed0c481e..f8ebe0389bd4 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.h
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.h
@@ -186,22 +186,18 @@
 | USBA_BF(name, value))
 
 /* Register access macros */
-#define usba_io_readl  readl_relaxed
-#define usba_io_writel writel_relaxed
-#define usba_io_writew writew_relaxed
-
 #define usba_readl(udc, reg)   \
-   usba_io_readl((udc)->regs + USBA_##reg)
+   readl_relaxed((udc)->regs + USBA_##reg)
 #define usba_writel(udc, reg, value)   \
-   usba_io_writel((value), (udc)->regs + USBA_##reg)
+   writel_relaxed((value), (udc)->regs + USBA_##reg)
 #define usba_ep_readl(ep, reg) \
-   usba_io_readl((ep)->ep_regs + USBA_EPT_##reg)
+   readl_relaxed((ep)->ep_regs + USBA_EPT_##reg)
 #define usba_ep_writel(ep, reg, value) \
-   usba_io_writel((value), (ep)->ep_regs + USBA_EPT_##reg)
+   writel_relaxed((value), (ep)->ep_regs + USBA_EPT_##reg)
 #define usba_dma_readl(ep, reg)\
-   usba_io_readl((ep)->dma_regs + USBA_DMA_##reg)
+   readl_relaxed((ep)->dma_regs + USBA_DMA_##reg)
 #define usba_dma_writel(ep, reg, value)\
-   usba_io_writel((value), (ep)->dma_regs + USBA_DMA_##reg)
+   writel_relaxed((value), (ep)->dma_regs + USBA_DMA_##reg)
 
 /* Calculate base address for a given endpoint or DMA controller */
 #define USBA_EPT_BASE(x)   (0x100 + (x) * 0x20)
-- 
2.11.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 3/3] mfd: twl: move header file out of I2C realm

2017-05-22 Thread Alexandre Belloni
On 22/05/2017 at 00:02:10 +0200, Wolfram Sang wrote:
> include/linux/i2c is not for client devices. Move the header file to a
> more appropriate location.
> 
> Signed-off-by: Wolfram Sang <w...@the-dreams.de>
Acked-by: Alexandre Belloni <alexandre.bell...@free-electrons.com>

> ---
>  arch/arm/mach-omap2/common.h| 2 +-
>  arch/arm/mach-omap2/omap_twl.c  | 2 +-
>  drivers/gpio/gpio-twl4030.c | 2 +-
>  drivers/iio/adc/twl4030-madc.c  | 2 +-
>  drivers/iio/adc/twl6030-gpadc.c | 2 +-
>  drivers/input/keyboard/twl4030_keypad.c | 2 +-
>  drivers/input/misc/twl4030-pwrbutton.c  | 2 +-
>  drivers/input/misc/twl4030-vibra.c  | 2 +-
>  drivers/mfd/twl-core.c  | 6 +++---
>  drivers/mfd/twl4030-audio.c | 2 +-
>  drivers/mfd/twl4030-irq.c   | 2 +-
>  drivers/mfd/twl4030-power.c | 2 +-
>  drivers/mfd/twl6030-irq.c   | 2 +-
>  drivers/phy/phy-twl4030-usb.c   | 2 +-
>  drivers/power/supply/twl4030_charger.c  | 2 +-
>  drivers/pwm/pwm-twl-led.c   | 2 +-
>  drivers/pwm/pwm-twl.c   | 2 +-
>  drivers/regulator/twl-regulator.c   | 2 +-
>  drivers/regulator/twl6030-regulator.c   | 2 +-
>  drivers/rtc/rtc-twl.c   | 2 +-
>  drivers/usb/phy/phy-twl6030-usb.c   | 2 +-
>  drivers/video/backlight/pandora_bl.c| 2 +-
>  drivers/watchdog/twl4030_wdt.c  | 2 +-
>  include/linux/{i2c => mfd}/twl.h| 0
>  sound/soc/codecs/twl4030.c  | 2 +-
>  25 files changed, 26 insertions(+), 26 deletions(-)
>  rename include/linux/{i2c => mfd}/twl.h (100%)
> 
> diff --git a/arch/arm/mach-omap2/common.h b/arch/arm/mach-omap2/common.h
> index 8cc6338fcb1288..b5ad7fcb80ed24 100644
> --- a/arch/arm/mach-omap2/common.h
> +++ b/arch/arm/mach-omap2/common.h
> @@ -29,7 +29,7 @@
>  #include 
>  #include 
>  #include 
> -#include 
> +#include 
>  #include 
>  #include 
>  #include 
> diff --git a/arch/arm/mach-omap2/omap_twl.c b/arch/arm/mach-omap2/omap_twl.c
> index 1346b3ab34a5e3..295124b248ae3f 100644
> --- a/arch/arm/mach-omap2/omap_twl.c
> +++ b/arch/arm/mach-omap2/omap_twl.c
> @@ -16,7 +16,7 @@
>  #include 
>  #include 
>  #include 
> -#include 
> +#include 
>  
>  #include "soc.h"
>  #include "voltage.h"
> diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c
> index 24f388ed46d4c4..9b511df5450eb6 100644
> --- a/drivers/gpio/gpio-twl4030.c
> +++ b/drivers/gpio/gpio-twl4030.c
> @@ -35,7 +35,7 @@
>  #include 
>  #include 
>  
> -#include 
> +#include 
>  
>  /*
>   * The GPIO "subchip" supports 18 GPIOs which can be configured as
> diff --git a/drivers/iio/adc/twl4030-madc.c b/drivers/iio/adc/twl4030-madc.c
> index 0c74869a540ad3..5a64eda1652061 100644
> --- a/drivers/iio/adc/twl4030-madc.c
> +++ b/drivers/iio/adc/twl4030-madc.c
> @@ -35,7 +35,7 @@
>  #include 
>  #include 
>  #include 
> -#include 
> +#include 
>  #include 
>  #include 
>  #include 
> diff --git a/drivers/iio/adc/twl6030-gpadc.c b/drivers/iio/adc/twl6030-gpadc.c
> index becbb0aef232b9..bc0e60b9da452e 100644
> --- a/drivers/iio/adc/twl6030-gpadc.c
> +++ b/drivers/iio/adc/twl6030-gpadc.c
> @@ -33,7 +33,7 @@
>  #include 
>  #include 
>  #include 
> -#include 
> +#include 
>  #include 
>  #include 
>  
> diff --git a/drivers/input/keyboard/twl4030_keypad.c 
> b/drivers/input/keyboard/twl4030_keypad.c
> index 39e72b3219d8a4..f9f98ef1d98e3f 100644
> --- a/drivers/input/keyboard/twl4030_keypad.c
> +++ b/drivers/input/keyboard/twl4030_keypad.c
> @@ -30,7 +30,7 @@
>  #include 
>  #include 
>  #include 
> -#include 
> +#include 
>  #include 
>  #include 
>  
> diff --git a/drivers/input/misc/twl4030-pwrbutton.c 
> b/drivers/input/misc/twl4030-pwrbutton.c
> index 1c13005b228fa7..b307cca1702226 100644
> --- a/drivers/input/misc/twl4030-pwrbutton.c
> +++ b/drivers/input/misc/twl4030-pwrbutton.c
> @@ -27,7 +27,7 @@
>  #include 
>  #include 
>  #include 
> -#include 
> +#include 
>  
>  #define PWR_PWRON_IRQ (1 << 0)
>  
> diff --git a/drivers/input/misc/twl4030-vibra.c 
> b/drivers/input/misc/twl4030-vibra.c
> index caa5a62c42fbe0..6c51d404874bbd 100644
> --- a/drivers/input/misc/twl4030-vibra.c
> +++ b/drivers/input/misc/twl4030-vibra.c
> @@ -28,7 +28,7 @@
>  #include 
>  #include 
>  #include 
> -#include 
> +#include 
>  #include 
>  #include 
>  #include 
> diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
> index c64615dca2bd33..2a09dde4ca6efc 100644
> --- a/drivers/mfd/twl-core.c
>

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

2017-03-05 Thread Alexandre Belloni
On 17/02/2017 at 16:12:50 +0100, Romain Izard wrote:
> This reverts commit cab43282682e ("ARM: at91/dt: sama5d2: Use new
> compatible for ohci node")
> 
> It depends from commit 7150bc9b4d43 ("usb: ohci-at91: Forcibly suspend
> ports while USB suspend") which was reverted and implemented
> differently. With the new implementation, the compatible string must
> remain the same.
> 
> The compatible string introduced by this commit has been used in the
> default SAMA5D2 dtsi starting from Linux 4.8. As it has never been
> working correctly in an official release, removing it should not be
> breaking the stability rules.
> 
> Fixes: cab43282682e ("ARM: at91/dt: sama5d2: Use new compatible for ohci 
> node")
> Signed-off-by: Romain Izard <romain.izard@gmail.com>
> cc: <sta...@vger.kernel.org>
> ---
>  arch/arm/boot/dts/sama5d2.dtsi | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
Applied, thanks.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
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 Alexandre Belloni
On 21/02/2017 at 12:48:18 +0100, Jelle Martijn Kok wrote:
> 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>
Reviewed-by: Alexandre Belloni <alexandre.bell...@free-electrons.com>

> Cc: Wenyou Yang <wenyou.y...@atmel.com>
> Cc: Alexandre Belloni <alexandre.bell...@free-electrons.com>
> Cc: Nicolas Ferre <nicolas.fe...@atmel.com>
> 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;
> -- 
> 2.1.4
> 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
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] Revert "ARM: at91/dt: sama5d2: Use new compatible for ohci node"

2017-02-17 Thread Alexandre Belloni
On 17/02/2017 at 16:12:50 +0100, Romain Izard wrote:
> This reverts commit cab43282682e ("ARM: at91/dt: sama5d2: Use new
> compatible for ohci node")
> 
> It depends from commit 7150bc9b4d43 ("usb: ohci-at91: Forcibly suspend
> ports while USB suspend") which was reverted and implemented
> differently. With the new implementation, the compatible string must
> remain the same.
> 
> The compatible string introduced by this commit has been used in the
> default SAMA5D2 dtsi starting from Linux 4.8. As it has never been
> working correctly in an official release, removing it should not be
> breaking the stability rules.
> 
> Fixes: cab43282682e ("ARM: at91/dt: sama5d2: Use new compatible for ohci 
> node")
> Signed-off-by: Romain Izard <romain.izard@gmail.com>
> cc: <sta...@vger.kernel.org>
> ---
>  arch/arm/boot/dts/sama5d2.dtsi | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

Sure, I'll take it as a fix once 4.11-rc1 is released.

> diff --git a/arch/arm/boot/dts/sama5d2.dtsi b/arch/arm/boot/dts/sama5d2.dtsi
> index ceb9783ff7e1..ff7eae833a6d 100644
> --- a/arch/arm/boot/dts/sama5d2.dtsi
> +++ b/arch/arm/boot/dts/sama5d2.dtsi
> @@ -266,7 +266,7 @@
>   };
>  
>   usb1: ohci@0040 {
> - compatible = "atmel,sama5d2-ohci", "usb-ohci";
> + compatible = "atmel,at91rm9200-ohci", "usb-ohci";
>   reg = <0x0040 0x10>;
>   interrupts = <41 IRQ_TYPE_LEVEL_HIGH 2>;
>   clocks = <_clk>, <_clk>, <>;
> -- 
> 2.9.3
> 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
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 Alexandre Belloni
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>

> ---
>  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
> 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
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

2017-01-16 Thread Alexandre Belloni
On 16/01/2017 at 12:27:04 +0200, Felipe Balbi wrote :
> 
> Hi,
> 
> David Laight <david.lai...@aculab.com> writes:
> > From: Alexandre Belloni
> >> Sent: 02 December 2016 16:19
> >> On 02/12/2016 at 15:59:57 +, David Laight wrote :
> >> > From: Alexandre Belloni
> >> > > Sent: 01 December 2016 10:27
> >> > > Use devm_kasprintf instead of simple kasprintf to free the allocated 
> >> > > memory
> >> > > when needed.
> >> >
> >> > s/when needed/when the device is freed/
> >> >
> >> > > Suggested-by: Peter Rosin <p...@axentia.se>
> >> > > Signed-off-by: Alexandre Belloni <alexandre.bell...@free-electrons.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);
> >> >
> >> > Acually why bother mallocing such a small string at all.
> >> > The maximum length is 12 bytes even if 'index' are unrestricted.
> >> >
> >> 
> >> IIRC, using statically allocated string is failing somewhere is the USB
> >> core but I don't remember all the details.
> >
> > I can't imagine that changing ep->ep.name from 'char *' to 'char [12]' would
> > make any difference.
> 
> the actual name is managed by the UDC. Meaning, ep->ep.name should be a
> pointer, but it could very well just point to ep->name which would be
> char [12].
> 

Yeah, I sent a patch that did just that.
http://lists.infradead.org/pipermail/linux-arm-kernel/2017-January/478602.html

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
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: remove memory leak

2017-01-11 Thread Alexandre Belloni
Commit bbe097f092b0 ("usb: gadget: udc: atmel: fix endpoint name")
introduced a memory leak when unbinding the driver. The endpoint names
would not be freed. Solve that by including the name as a string in struct
usba_ep so it is freed when the endpoint is.

Signed-off-by: Alexandre Belloni <alexandre.bell...@free-electrons.com>
---
 drivers/usb/gadget/udc/atmel_usba_udc.c | 3 ++-
 drivers/usb/gadget/udc/atmel_usba_udc.h | 1 +
 2 files 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 f3212db9bc37..12c7687216e6 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);
+   sprintf(ep->name, "ep%d", ep->index);
+   ep->ep.name = ep->name;
 
ep->ep_regs = udc->regs + USBA_EPT_BASE(i);
ep->dma_regs = udc->regs + USBA_DMA_BASE(i);
diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.h 
b/drivers/usb/gadget/udc/atmel_usba_udc.h
index 3e1c9d589dfa..b03b2ebfc53a 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.h
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.h
@@ -280,6 +280,7 @@ struct usba_ep {
void __iomem*ep_regs;
void __iomem*dma_regs;
void __iomem*fifo;
+   charname[8];
struct usb_ep   ep;
struct usba_udc *udc;
 
-- 
2.11.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] usb: gadget: udc: atmel: used managed kasprintf

2016-12-02 Thread Alexandre Belloni
On 02/12/2016 at 15:59:57 +, David Laight wrote :
> From: Alexandre Belloni
> > Sent: 01 December 2016 10:27
> > Use devm_kasprintf instead of simple kasprintf to free the allocated memory
> > when needed.
> 
> s/when needed/when the device is freed/
> 
> > Suggested-by: Peter Rosin <p...@axentia.se>
> > Signed-off-by: Alexandre Belloni <alexandre.bell...@free-electrons.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);
> 
> Acually why bother mallocing such a small string at all.
> The maximum length is 12 bytes even if 'index' are unrestricted.
>  

IIRC, using statically allocated string is failing somewhere is the USB
core but I don't remember all the details.


-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
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: used managed kasprintf

2016-12-01 Thread Alexandre Belloni
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>
---
 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);
-- 
2.10.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: udc: atmel: fix endpoint name

2016-10-24 Thread Alexandre Belloni
On 24/10/2016 at 13:59:47 +0200, Nicolas Ferre wrote :
> > 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...
> 

It is in Greg's branch:
http://git.kernel.org/cgit/linux/kernel/git/gregkh/usb.git/log/?h=usb-linus

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
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-20 Thread Alexandre Belloni
On 18/10/2016 at 13:58:44 +0200, Nicolas Ferre wrote :
> 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(-)
> > 
Applied, thanks.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
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: fix endpoint name

2016-09-15 Thread Alexandre Belloni
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>
---
 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);
-- 
2.9.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: ohci-at91: make at91_dt_syscon_sfr static

2016-06-27 Thread Alexandre Belloni
On 27/06/2016 at 10:24:59 +0100, Ben Dooks wrote :
> On 26/06/16 19:48, Greg Kroah-Hartman wrote:
> > On Fri, Jun 17, 2016 at 04:11:55PM +0100, Ben Dooks wrote:
> >> Make at91_dt_syscon_sfr() static as it is not used or declared
> >> outside the drivers/usb/host/ohci-at91.c file.
> >>
> >> drivers/usb/host/ohci-at91.c:144:15: warning: symbol 'at91_dt_syscon_sfr' 
> >> was not declared. Should it be static?
> >>
> >> Signed-off-by: Ben Dooks <ben.do...@codethink.co.uk>
> >> Acked-by: Nicolas Ferre <nicolas.fe...@atmel.com>
> >> Acked-by: Alexandre Belloni <alexandre.bell...@free-electrons.com>
> >> ---
> >> Cc: Alan Stern <st...@rowland.harvard.edu>
> >> Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org>
> >> Cc: linux-usb@vger.kernel.org
> >> Cc: Alexandre Belloni <alexandre.bell...@free-electrons.com>
> >> Cc: Jean-Christophe Plagniol-Villard <plagn...@jcrosoft.com>
> >> ---
> >>  drivers/usb/host/ohci-at91.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > Doesn't apply properly to my tree :(
> 
> I think the function has now been removed, but I'd need to check.
> 

Or rather, it is not in yet. I'm not sure which tree you compiled to get
it.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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 Alexandre Belloni
On 21/06/2016 at 09:32:44 +0800, Wenyou Yang wrote :
> 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>
Reviewed-by: Alexandre Belloni <alexandre.bell...@free-electrons.com>

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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-20 Thread Alexandre Belloni
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?
> 
> > 
> > --
> > Alexandre Belloni, Free Electrons
> > Embedded Linux, Kernel and Android engineering http://free-electrons.com
> 
> 
> Best Regards,
> Wenyou Yang

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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-20 Thread Alexandre Belloni
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.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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: make at91_dt_syscon_sfr static

2016-06-17 Thread Alexandre Belloni
On 17/06/2016 at 16:11:55 +0100, Ben Dooks wrote :
> Make at91_dt_syscon_sfr() static as it is not used or declared
> outside the drivers/usb/host/ohci-at91.c file.
> 
> drivers/usb/host/ohci-at91.c:144:15: warning: symbol 'at91_dt_syscon_sfr' was 
> not declared. Should it be static?
> 
> Signed-off-by: Ben Dooks <ben.do...@codethink.co.uk>
Acked-by: Alexandre Belloni <alexandre.bell...@free-electrons.com>

> ---
> Cc: Alan Stern <st...@rowland.harvard.edu>
> Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org>
> Cc: linux-usb@vger.kernel.org
> Cc: Nicolas Ferre <nicolas.fe...@atmel.com>
> Cc: Alexandre Belloni <alexandre.bell...@free-electrons.com>
> Cc: Jean-Christophe Plagniol-Villard <plagn...@jcrosoft.com>
> ---
>  drivers/usb/host/ohci-at91.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
> index 54e8feb..a69b421 100644
> --- a/drivers/usb/host/ohci-at91.c
> +++ b/drivers/usb/host/ohci-at91.c
> @@ -141,7 +141,7 @@ static void at91_stop_hc(struct platform_device *pdev)
>  
>  /*-*/
>  
> -struct regmap *at91_dt_syscon_sfr(void)
> +static struct regmap *at91_dt_syscon_sfr(void)
>  {
>   struct regmap *regmap;
>  
> -- 
> 2.8.1
> 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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-17 Thread Alexandre Belloni
On 17/06/2016 at 13:44:22 +, Yang, Wenyou wrote :
> Hi Alexandre,
> 
> > -Original Message-
> > From: Alexandre Belloni [mailto:alexandre.bell...@free-electrons.com]
> > Sent: 2016年6月9日 4:38
> > To: Rob Herring <r...@kernel.org>
> > Cc: Yang, Wenyou <wenyou.y...@atmel.com>; 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-usb@vger.kernel.org
> > Subject: Re: [PATCH v3 1/2] usb: ohci-at91: Forcibly suspend ports while USB
> > suspend
> > 
> > On 08/06/2016 at 15:26:51 -0500, Rob Herring wrote :
> > > On Wed, Jun 08, 2016 at 12:15:10PM +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 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 
> > > >  3 files changed, 112 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..888deaa 100644
> > > > --- a/Documentation/devicetree/bindings/usb/atmel-usb.txt
> > > > +++ b/Documentation/devicetree/bindings/usb/atmel-usb.txt
> > > > @@ -3,8 +3,10 @@ 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 USB controllers used in host 
> > > > mode
> > > > +  on SAMA5D2 which can force to suspend.
> > >
> > > Guess I wasn't clear enough before. Drop "which can force to suspend".
> > >
> > 
> > Well, my point is that we don't need a new compatible anyway.
> 
> Could you give some advice?.
> 

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).

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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: Also get regmap for at91sam9x5-pmc

2016-06-13 Thread Alexandre Belloni
On 13/06/2016 at 10:56:08 +0200, Uwe Kleine-König wrote :
> Hello,
> 
> On Mon, Jun 13, 2016 at 10:47:30AM +0200, Alexandre Belloni wrote:
> > The "atmel,at91sam9g45-udc" compatible UDC is also used on at91sam9x5 so it
> > is also necessary to try to get the syscon for at91sam9x5-pmc.
> > 
> > Fixes: 4747639f01c9 ("usb: gadget: atmel: access the PMC using regmap")
> > Reported-by: Uwe Kleine-König <u.kleine-koe...@pengutronix.de>
> 
> I played with the AT91 during my non-work time, so please use
> u...@kleine-koenig.org as my email address.
> 
> > Signed-off-by: Alexandre Belloni <alexandre.bell...@free-electrons.com>
> > ---
> >  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 18569de06b04..bb1f6c8f0f01 100644
> > --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
> > +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
> > @@ -1920,6 +1920,8 @@ static struct usba_ep * atmel_udc_of_init(struct 
> > platform_device *pdev,
> >  
> > udc->errata = match->data;
> > udc->pmc = syscon_regmap_lookup_by_compatible("atmel,at91sam9g45-pmc");
> > +   if (IS_ERR(udc->pmc))
> > +   udc->pmc = 
> > syscon_regmap_lookup_by_compatible("atmel,at91sam9x5-pmc");
> > if (udc->errata && IS_ERR(udc->pmc))
> > return ERR_CAST(udc->pmc);
> 
> I didn't retest but I'm sure this makes usb gadget work on my AT91.
> Still I'm unsure if the patch is correct. Can
> 
>   syscon_regmap_lookup_by_compatible("atmel,at91sam9g45-pmc")
> 
> return -EPROBE_DEFER? Are there other error codes that should be fatal
> enough to not try to look for a sam9x5-pmc?
> 

Well, if finding the PMC fails, you are probably not far enough in the
boot process to care about USB :)

Also, looking up the syscon will never return -EPROBE_DEFER because it
will create the regmap on first lookup, it doesn't matter where it is
coming from.

> Nearly orthogonal to the issue: An error message on failure would be
> nice. When I saw usb gadget broken I first had to add messages to this
> driver to see where it failed.
> 

Good point, this can probably go in a separate, less urgent patch.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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: Also get regmap for at91sam9x5-pmc

2016-06-13 Thread Alexandre Belloni
The "atmel,at91sam9g45-udc" compatible UDC is also used on at91sam9x5 so it
is also necessary to try to get the syscon for at91sam9x5-pmc.

Fixes: 4747639f01c9 ("usb: gadget: atmel: access the PMC using regmap")
Reported-by: Uwe Kleine-König <u.kleine-koe...@pengutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.bell...@free-electrons.com>
---
 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 18569de06b04..bb1f6c8f0f01 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -1920,6 +1920,8 @@ static struct usba_ep * atmel_udc_of_init(struct 
platform_device *pdev,
 
udc->errata = match->data;
udc->pmc = syscon_regmap_lookup_by_compatible("atmel,at91sam9g45-pmc");
+   if (IS_ERR(udc->pmc))
+   udc->pmc = 
syscon_regmap_lookup_by_compatible("atmel,at91sam9x5-pmc");
if (udc->errata && IS_ERR(udc->pmc))
return ERR_CAST(udc->pmc);
 
-- 
2.8.1

--
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 Alexandre Belloni
On 08/06/2016 at 15:26:51 -0500, Rob Herring wrote :
> On Wed, Jun 08, 2016 at 12:15:10PM +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 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 
> >  3 files changed, 112 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..888deaa 100644
> > --- a/Documentation/devicetree/bindings/usb/atmel-usb.txt
> > +++ b/Documentation/devicetree/bindings/usb/atmel-usb.txt
> > @@ -3,8 +3,10 @@ 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 USB controllers used in host mode
> > +  on SAMA5D2 which can force to suspend.
> 
> Guess I wasn't clear enough before. Drop "which can force to suspend".
> 

Well, my point is that we don't need a new compatible anyway.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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 Alexandre Belloni
On 08/06/2016 at 12:06:11 +0200, Nicolas Ferre wrote :
> 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.
> 

Well, like discussed, I'd say that a new compatible is not needed as we
already know on which chip we are running depending on the SFR that we
can lookup. My concern was only to avoid calling a function
unnecessarily on !sama5d2 platforms.
> 
> > reg = <0x0040 0x10>;
> > interrupts = <41 IRQ_TYPE_LEVEL_HIGH 2>;
> > clocks = <_clk>, <_clk>, <>;
> > 
> 
> Bye,
> -- 
> Nicolas Ferre

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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: Suspend the ports while USB suspending

2016-05-11 Thread Alexandre Belloni
Hi,

On 12/05/2016 at 09:05:34 +0800, Wenyou Yang wrote :
> In order to get lower consumption, as a workaround, suspend
> the USB PORTA/B/C via set the SUSPEND_A/B/C bits of OHCI Interrupt
> Configuration Register while OHCI USB suspending.
> 

Why is that a workaround?

> This suspend operation must be done before stopping the USB clock,
> resume after the USB clock enabled.
> 
> Signed-off-by: Wenyou Yang <wenyou.y...@atmel.com>
> ---
> 
>  drivers/usb/host/ohci-at91.c | 63 
> 
>  1 file changed, 63 insertions(+)
> 
> diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
> index d177372..ce898e0 100644
> --- a/drivers/usb/host/ohci-at91.c
> +++ b/drivers/usb/host/ohci-at91.c
> @@ -21,6 +21,8 @@
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
>  #include 
>  #include 
>  
> @@ -51,6 +53,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 +135,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))
> + return 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 +211,8 @@ static int usb_hcd_at91_probe(const struct hc_driver 
> *driver,
>   goto err;
>   }
>  
> + ohci_at91->sfr_regmap = at91_dt_syscon_sfr();
> +
>   board = hcd->self.controller->platform_data;
>   ohci = hcd_to_ohci(hcd);
>   ohci->num_ports = board->ports;
> @@ -581,6 +597,49 @@ static int ohci_hcd_at91_drv_remove(struct 
> platform_device *pdev)
>   return 0;
>  }
>  
> +#define SFR_OHCIICR  0x10
> +#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)
> +

Those defines should go in a header file either in include/soc/at91 or
in include/linux/mfd

> +static int ohci_at91_port_ctrl(struct regmap *regmap, bool enable)
> +{
> + u32 regval;
> + int ret;
> +
> + if (IS_ERR(regmap))
> + return PTR_ERR(regmap);
> +
> + 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);
> +
> + regmap_read(regmap, SFR_OHCIICR, );
> +
> + 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 +677,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);
> +

The main issue I see here is that you will call that function for all
SoCs and it will always fail unless it is running on a sama5d2. Maybe we
could be smarter about that.


-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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: Regression, was [PATCH 4/4] USB: host: ohci-at91: merge loops in ohci_hcd_at91_drv_probe

2015-12-02 Thread Alexandre Belloni
Hi Peter,

On 01/12/2015 at 18:17:16 +0100, Peter Rosin wrote :
> [] (ohci_hcd_at91_overcurrent_irq) from [] 
> (handle_irq_event_percpu+0x78/0x140)
> [] (handle_irq_event_percpu) from [] 
> (handle_irq_event+0x2c/0x40)
> [] (handle_irq_event) from [] 
> (handle_simple_irq+0x6c/0x80)
> [] (handle_simple_irq) from [] 
> (generic_handle_irq+0x2c/0x3c)
> [] (generic_handle_irq) from [] 
> (gpio_irq_handler+0xa4/0x12c)
> [] (gpio_irq_handler) from [] 
> (generic_handle_irq+0x2c/0x3c)
> [] (generic_handle_irq) from [] 
> (__handle_domain_irq+0x54/0xa8)
> [] (__handle_domain_irq) from [] (__irq_svc+0x40/0x54)
> [] (__irq_svc) from [] (__setup_irq+0x248/0x530)
> [] (__setup_irq) from [] (request_threaded_irq+0xc4/0x144)
> [] (request_threaded_irq) from [] 
> (ohci_hcd_at91_drv_probe+0x460/0x518)
> [] (ohci_hcd_at91_drv_probe) from [] 
> (platform_drv_probe+0x44/0xa4)
> [] (platform_drv_probe) from [] 
> (driver_probe_device+0x1fc/0x43c)
> [] (driver_probe_device) from [] 
> (__driver_attach+0x8c/0x90)
> [] (__driver_attach) from [] (bus_for_each_dev+0x6c/0xa0)
> [] (bus_for_each_dev) from [] (bus_add_driver+0x1d0/0x268)
> [] (bus_add_driver) from [] (driver_register+0x78/0xf8)
> [] (driver_register) from [] (do_one_initcall+0xb8/0x1f0)
> [] (do_one_initcall) from [] 
> (kernel_init_freeable+0x138/0x1d8)
> [] (kernel_init_freeable) from [] (kernel_init+0x8/0xe8)
> [] (kernel_init) from [] (ret_from_fork+0x14/0x2c)
> Code: e5916058 e1a08000 e3a04000 e2865008 (e5b50004)
> ---[ end trace e66fbc480972ac43 ]---
> Kernel panic - not syncing: Fatal exception in interrupt
> ---[ end Kernel panic - not syncing: Fatal exception in interrupt

I think I understood what happens. Can you try the following patch?

8<--
>From 402f8444bc92d218edc63dcc3c87459981a56c31 Mon Sep 17 00:00:00 2001
From: Alexandre Belloni <alexandre.bell...@free-electrons.com>
Date: Wed, 2 Dec 2015 18:49:34 +0100
Subject: [PATCH] USB: host: ohci-at91: fix a crash in
 ohci_hcd_at91_overcurrent_irq

Signed-off-by: Alexandre Belloni <alexandre.bell...@free-electrons.com>
---
 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);
 }
-- 
2.5.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: host: ohci-at91: fix a crash in ohci_hcd_at91_overcurrent_irq

2015-12-02 Thread Alexandre Belloni
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)
Reported-by: Peter Rosin <p...@axentia.se>
Tested-by: Peter Rosin <p...@axentia.se>
Signed-off-by: Alexandre Belloni <alexandre.bell...@free-electrons.com>
---
 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);
 }
-- 
2.5.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 00/16] ARM: at91: PMC driver rework

2015-09-30 Thread Alexandre Belloni
Stephen, all,

Please disregard 01/16 and 02/16 as they are already in clk-next.

On 30/09/2015 at 18:10:53 +0200, Alexandre Belloni wrote :
> Hi,
> 
> This patch set is a cleanup that properly separate drivers needing to access 
> the
> PMC (PM and USB) from the clock driver by exposing the PMC as a syscon.
> 
> This also allows to implement a fix for preempt-rt. Currently, at91 platform 
> are
> crashing when using preempt-rt because the irq handler are transformed in
> threaded irq handler but at the time the pmc registers its clocks, it is not
> possible to creat threads, leading to a NULL pointer dereference in the 
> kernel.
> 
> The new infrastructure uses polling until it is late enough to register 
> threaded
> irqs.
> 
> :w
> Cc: Felipe Balbi <ba...@ti.com>
> Cc: linux-usb@vger.kernel.org
> 
> Alexandre Belloni (13):
>   clk: at91: utmi: use pmc_read when the at91_pmc is available
>   clk: at91: system: don't try to free_irq when there is no IRQ
>   ARM: at91/dt: use syscon for PMC
>   clk: at91: clk-main: factorize irq handling
>   clk: at91: make IRQ optional and register them later
>   clk: at91: pmc: merge at91_pmc_init in atmel_pmc_probe
>   clk: at91: pmc: move pmc structures to C file
>   ARM: at91: pm: simply call at91_pm_init
>   ARM: at91: pm: find and remap the pmc
>   ARM: at91: pm: move idle functions to pm.c
>   ARM: at91: remove useless includes and function prototypes
>   usb: gadget: atmel: access the PMC using regmap
>   clk: at91: pmc: drop at91_pmc_base
> 
> Boris Brezillon (3):
>   clk: at91: make use of syscon to share PMC registers in several
> drivers
>   clk: at91: make use of syscon/regmap internally
>   clk: at91: only enable available IRQs
> 
>  arch/arm/boot/dts/at91rm9200.dtsi   |   2 +-
>  arch/arm/boot/dts/at91sam9260.dtsi  |   2 +-
>  arch/arm/boot/dts/at91sam9261.dtsi  |   2 +-
>  arch/arm/boot/dts/at91sam9263.dtsi  |   2 +-
>  arch/arm/boot/dts/at91sam9g45.dtsi  |   2 +-
>  arch/arm/boot/dts/at91sam9n12.dtsi  |   2 +-
>  arch/arm/boot/dts/at91sam9rl.dtsi   |   2 +-
>  arch/arm/boot/dts/at91sam9x5.dtsi   |   2 +-
>  arch/arm/boot/dts/sama5d2.dtsi  |   2 +-
>  arch/arm/boot/dts/sama5d3.dtsi  |   2 +-
>  arch/arm/boot/dts/sama5d4.dtsi  |   2 +-
>  arch/arm/mach-at91/Kconfig  |   1 +
>  arch/arm/mach-at91/at91rm9200.c |   2 -
>  arch/arm/mach-at91/at91sam9.c   |   2 -
>  arch/arm/mach-at91/generic.h|  13 +-
>  arch/arm/mach-at91/pm.c |  69 +-
>  arch/arm/mach-at91/sama5.c  |   2 +-
>  drivers/clk/at91/clk-h32mx.c|  33 ++-
>  drivers/clk/at91/clk-main.c | 403 
> +++-
>  drivers/clk/at91/clk-master.c   | 134 +++
>  drivers/clk/at91/clk-peripheral.c   | 131 +++
>  drivers/clk/at91/clk-pll.c  | 190 +--
>  drivers/clk/at91/clk-plldiv.c   |  42 ++--
>  drivers/clk/at91/clk-programmable.c |  92 
>  drivers/clk/at91/clk-slow.c |  27 ++-
>  drivers/clk/at91/clk-smd.c  |  54 +++--
>  drivers/clk/at91/clk-system.c   | 128 ++
>  drivers/clk/at91/clk-usb.c  | 121 +-
>  drivers/clk/at91/clk-utmi.c | 116 +
>  drivers/clk/at91/pmc.c  | 300 ++--
>  drivers/clk/at91/pmc.h  |  93 +---
>  drivers/usb/gadget/udc/atmel_usba_udc.c |  20 +-
>  drivers/usb/gadget/udc/atmel_usba_udc.h |   2 +
>  include/linux/clk/at91_pmc.h|  12 -
>  34 files changed, 1059 insertions(+), 950 deletions(-)
> 
> -- 
> 2.1.4
> 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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 00/16] ARM: at91: PMC driver rework

2015-09-30 Thread Alexandre Belloni
Hi,

This patch set is a cleanup that properly separate drivers needing to access the
PMC (PM and USB) from the clock driver by exposing the PMC as a syscon.

This also allows to implement a fix for preempt-rt. Currently, at91 platform are
crashing when using preempt-rt because the irq handler are transformed in
threaded irq handler but at the time the pmc registers its clocks, it is not
possible to creat threads, leading to a NULL pointer dereference in the kernel.

The new infrastructure uses polling until it is late enough to register threaded
irqs.

:w
Cc: Felipe Balbi <ba...@ti.com>
Cc: linux-usb@vger.kernel.org

Alexandre Belloni (13):
  clk: at91: utmi: use pmc_read when the at91_pmc is available
  clk: at91: system: don't try to free_irq when there is no IRQ
  ARM: at91/dt: use syscon for PMC
  clk: at91: clk-main: factorize irq handling
  clk: at91: make IRQ optional and register them later
  clk: at91: pmc: merge at91_pmc_init in atmel_pmc_probe
  clk: at91: pmc: move pmc structures to C file
  ARM: at91: pm: simply call at91_pm_init
  ARM: at91: pm: find and remap the pmc
  ARM: at91: pm: move idle functions to pm.c
  ARM: at91: remove useless includes and function prototypes
  usb: gadget: atmel: access the PMC using regmap
  clk: at91: pmc: drop at91_pmc_base

Boris Brezillon (3):
  clk: at91: make use of syscon to share PMC registers in several
drivers
  clk: at91: make use of syscon/regmap internally
  clk: at91: only enable available IRQs

 arch/arm/boot/dts/at91rm9200.dtsi   |   2 +-
 arch/arm/boot/dts/at91sam9260.dtsi  |   2 +-
 arch/arm/boot/dts/at91sam9261.dtsi  |   2 +-
 arch/arm/boot/dts/at91sam9263.dtsi  |   2 +-
 arch/arm/boot/dts/at91sam9g45.dtsi  |   2 +-
 arch/arm/boot/dts/at91sam9n12.dtsi  |   2 +-
 arch/arm/boot/dts/at91sam9rl.dtsi   |   2 +-
 arch/arm/boot/dts/at91sam9x5.dtsi   |   2 +-
 arch/arm/boot/dts/sama5d2.dtsi  |   2 +-
 arch/arm/boot/dts/sama5d3.dtsi  |   2 +-
 arch/arm/boot/dts/sama5d4.dtsi  |   2 +-
 arch/arm/mach-at91/Kconfig  |   1 +
 arch/arm/mach-at91/at91rm9200.c |   2 -
 arch/arm/mach-at91/at91sam9.c   |   2 -
 arch/arm/mach-at91/generic.h|  13 +-
 arch/arm/mach-at91/pm.c |  69 +-
 arch/arm/mach-at91/sama5.c  |   2 +-
 drivers/clk/at91/clk-h32mx.c|  33 ++-
 drivers/clk/at91/clk-main.c | 403 +++-
 drivers/clk/at91/clk-master.c   | 134 +++
 drivers/clk/at91/clk-peripheral.c   | 131 +++
 drivers/clk/at91/clk-pll.c  | 190 +--
 drivers/clk/at91/clk-plldiv.c   |  42 ++--
 drivers/clk/at91/clk-programmable.c |  92 
 drivers/clk/at91/clk-slow.c |  27 ++-
 drivers/clk/at91/clk-smd.c  |  54 +++--
 drivers/clk/at91/clk-system.c   | 128 ++
 drivers/clk/at91/clk-usb.c  | 121 +-
 drivers/clk/at91/clk-utmi.c | 116 +
 drivers/clk/at91/pmc.c  | 300 ++--
 drivers/clk/at91/pmc.h  |  93 +---
 drivers/usb/gadget/udc/atmel_usba_udc.c |  20 +-
 drivers/usb/gadget/udc/atmel_usba_udc.h |   2 +
 include/linux/clk/at91_pmc.h|  12 -
 34 files changed, 1059 insertions(+), 950 deletions(-)

-- 
2.1.4

--
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 15/16] usb: gadget: atmel: access the PMC using regmap

2015-09-30 Thread Alexandre Belloni
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>
---
Cc: Felipe Balbi <ba...@ti.com>
Cc: linux-usb@vger.kernel.org
 drivers/usb/gadget/udc/atmel_usba_udc.c | 20 ++--
 drivers/usb/gadget/udc/atmel_usba_udc.h |  2 ++
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
b/drivers/usb/gadget/udc/atmel_usba_udc.c
index 3dfada8d6061..40977cd832af 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -17,7 +17,9 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1888,20 +1890,15 @@ static int atmel_usba_stop(struct usb_gadget *gadget)
 #ifdef CONFIG_OF
 static void at91sam9rl_toggle_bias(struct usba_udc *udc, int is_on)
 {
-   unsigned int uckr = at91_pmc_read(AT91_CKGR_UCKR);
-
-   if (is_on)
-   at91_pmc_write(AT91_CKGR_UCKR, uckr | AT91_PMC_BIASEN);
-   else
-   at91_pmc_write(AT91_CKGR_UCKR, uckr & ~(AT91_PMC_BIASEN));
+   regmap_update_bits(udc->pmc, AT91_CKGR_UCKR, AT91_PMC_BIASEN,
+  is_on ? AT91_PMC_BIASEN : 0);
 }
 
 static void at91sam9g45_pulse_bias(struct usba_udc *udc)
 {
-   unsigned int uckr = at91_pmc_read(AT91_CKGR_UCKR);
-
-   at91_pmc_write(AT91_CKGR_UCKR, uckr & ~(AT91_PMC_BIASEN));
-   at91_pmc_write(AT91_CKGR_UCKR, uckr | AT91_PMC_BIASEN);
+   regmap_update_bits(udc->pmc, AT91_CKGR_UCKR, AT91_PMC_BIASEN, 0);
+   regmap_update_bits(udc->pmc, AT91_CKGR_UCKR, AT91_PMC_BIASEN,
+  AT91_PMC_BIASEN);
 }
 
 static const struct usba_udc_errata at91sam9rl_errata = {
@@ -1938,6 +1935,9 @@ static struct usba_ep * atmel_udc_of_init(struct 
platform_device *pdev,
return ERR_PTR(-EINVAL);
 
udc->errata = match->data;
+   udc->pmc = syscon_regmap_lookup_by_compatible("atmel,at91sam9g45-pmc");
+   if (udc->errata && IS_ERR(udc->pmc))
+   return ERR_CAST(udc->pmc);
 
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 ea448a344767..3e1c9d589dfa 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.h
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.h
@@ -354,6 +354,8 @@ struct usba_udc {
struct dentry *debugfs_root;
struct dentry *debugfs_regs;
 #endif
+
+   struct regmap *pmc;
 };
 
 static inline struct usba_ep *to_usba_ep(struct usb_ep *ep)
-- 
2.1.4

--
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 Alexandre Belloni
Hi,

On 30/09/2015 at 11:31:02 -0500, Felipe Balbi wrote :
> 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 ?
> 

This actually depend on the DT change. I'd say that we can safely assume
that the DT change will land in the next kernel version so you could
take that patch in your tree.

Nicolas, what is your opinion?

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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 Alexandre Belloni
On 30/09/2015 at 18:59:17 +0200, Alexandre Belloni wrote :
> Hi,
> 
> On 30/09/2015 at 11:31:02 -0500, Felipe Balbi wrote :
> > 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 ?
> > 
> 
> This actually depend on the DT change. I'd say that we can safely assume
> that the DT change will land in the next kernel version so you could
> take that patch in your tree.
> 
> Nicolas, what is your opinion?
> 

Ok, I'm late to the battle :)

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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: remove useless include

2015-08-10 Thread Alexandre Belloni
Definitions from linux/platform_data/atmel.h are not used, remove the
include.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.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 linux/usb/gadget.h
 #include linux/usb/atmel_usba_udc.h
 #include linux/delay.h
-#include linux/platform_data/atmel.h
 #include linux/of.h
 #include linux/of_gpio.h
 
-- 
2.1.4

--
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: at91_udc: move at91_udc_data in at91_udc.h

2015-08-10 Thread Alexandre Belloni
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
---
 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 */
-- 
2.1.4

--
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 1/4] USB: host: ohci-at91: move at91_usbh_data definition in c file

2015-08-10 Thread Alexandre Belloni
Move struct at91_usbh_data back in ohci-at91.c as this is the only user
left after switching all at91 platforms to DT only.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 drivers/usb/host/ohci-at91.c| 11 +++
 include/linux/platform_data/atmel.h | 12 
 2 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 15df00cceed9..72dc4f9e2a0f 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -36,6 +36,17 @@
 #define hcd_to_ohci_at91_priv(h) \
((struct ohci_at91_priv *)hcd_to_ohci(h)-priv)
 
+#define AT91_MAX_USBH_PORTS3
+struct at91_usbh_data {
+   int vbus_pin[AT91_MAX_USBH_PORTS];  /* port power-control pin */
+   int overcurrent_pin[AT91_MAX_USBH_PORTS];
+   u8 ports;   /* number of ports on root hub 
*/
+   u8 overcurrent_supported;
+   u8 vbus_pin_active_low[AT91_MAX_USBH_PORTS];
+   u8 overcurrent_status[AT91_MAX_USBH_PORTS];
+   u8 overcurrent_changed[AT91_MAX_USBH_PORTS];
+};
+
 struct ohci_at91_priv {
struct clk *iclk;
struct clk *fclk;
diff --git a/include/linux/platform_data/atmel.h 
b/include/linux/platform_data/atmel.h
index 4b452c6a2f7b..527a85c61924 100644
--- a/include/linux/platform_data/atmel.h
+++ b/include/linux/platform_data/atmel.h
@@ -46,18 +46,6 @@ struct at91_cf_data {
 #define AT91_IDE_SWAP_A0_A20x02
 };
 
- /* USB Host */
-#define AT91_MAX_USBH_PORTS3
-struct at91_usbh_data {
-   int vbus_pin[AT91_MAX_USBH_PORTS];  /* port power-control 
pin */
-   int overcurrent_pin[AT91_MAX_USBH_PORTS];
-   u8  ports;  /* number of ports on 
root hub */
-   u8  overcurrent_supported;
-   u8  vbus_pin_active_low[AT91_MAX_USBH_PORTS];
-   u8  overcurrent_status[AT91_MAX_USBH_PORTS];
-   u8  overcurrent_changed[AT91_MAX_USBH_PORTS];
-};
-
  /* NAND / SmartMedia */
 struct atmel_nand_data {
int enable_pin; /* chip enable */
-- 
2.1.4

--
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 3/4] USB: host: ohci-at91: merge ohci_at91_of_init in ohci_hcd_at91_drv_probe

2015-08-10 Thread Alexandre Belloni
As device tree support is now mandatory, merge ohci_at91_of_init() in
ohci_hcd_at91_drv_probe().

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 drivers/usb/host/ohci-at91.c | 145 +++
 1 file changed, 63 insertions(+), 82 deletions(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 8e17d5ba26c6..cdd91c551c7b 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -449,16 +449,17 @@ static const struct of_device_id at91_ohci_dt_ids[] = {
 
 MODULE_DEVICE_TABLE(of, at91_ohci_dt_ids);
 
-static int ohci_at91_of_init(struct platform_device *pdev)
+/*-*/
+
+static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
 {
struct device_node *np = pdev-dev.of_node;
-   int i, gpio, ret;
-   enum of_gpio_flags flags;
struct at91_usbh_data   *pdata;
-   u32 ports;
-
-   if (!np)
-   return 0;
+   int i;
+   int gpio;
+   int ret;
+   enum of_gpio_flags  flags;
+   u32 ports;
 
/* Right now device-tree probed devices don't get dma_mask set.
 * Since shared usb code relies on it, set it here for now.
@@ -489,89 +490,69 @@ static int ohci_at91_of_init(struct platform_device *pdev)
 
pdev-dev.platform_data = pdata;
 
-   return 0;
-}
-
-/*-*/
-
-static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
-{
-   struct at91_usbh_data   *pdata;
-   int i;
-   int gpio;
-   int ret;
-
-   ret = ohci_at91_of_init(pdev);
-   if (ret)
-   return ret;
+   at91_for_each_port(i) {
+   /*
+* do not configure PIO if not in relation with
+* real USB port on board
+*/
+   if (i = pdata-ports) {
+   pdata-vbus_pin[i] = -EINVAL;
+   pdata-overcurrent_pin[i] = -EINVAL;
+   break;
+   }
 
-   pdata = dev_get_platdata(pdev-dev);
+   if (!gpio_is_valid(pdata-vbus_pin[i]))
+   continue;
+   gpio = pdata-vbus_pin[i];
 
-   if (pdata) {
-   at91_for_each_port(i) {
-   /*
-* do not configure PIO if not in relation with
-* real USB port on board
-*/
-   if (i = pdata-ports) {
-   pdata-vbus_pin[i] = -EINVAL;
-   pdata-overcurrent_pin[i] = -EINVAL;
-   break;
-   }
+   ret = gpio_request(gpio, ohci_vbus);
+   if (ret) {
+   dev_err(pdev-dev,
+   can't request vbus gpio %d\n, gpio);
+   continue;
+   }
+   ret = gpio_direction_output(gpio,
+   !pdata-vbus_pin_active_low[i]);
+   if (ret) {
+   dev_err(pdev-dev,
+   can't put vbus gpio %d as output %d\n,
+   gpio, !pdata-vbus_pin_active_low[i]);
+   gpio_free(gpio);
+   continue;
+   }
 
-   if (!gpio_is_valid(pdata-vbus_pin[i]))
-   continue;
-   gpio = pdata-vbus_pin[i];
+   ohci_at91_usb_set_power(pdata, i, 1);
+   }
 
-   ret = gpio_request(gpio, ohci_vbus);
-   if (ret) {
-   dev_err(pdev-dev,
-   can't request vbus gpio %d\n, gpio);
-   continue;
-   }
-   ret = gpio_direction_output(gpio,
-   !pdata-vbus_pin_active_low[i]);
-   if (ret) {
-   dev_err(pdev-dev,
-   can't put vbus gpio %d as output %d\n,
-   gpio, !pdata-vbus_pin_active_low[i]);
-   gpio_free(gpio);
-   continue;
-   }
+   at91_for_each_port(i) {
+   if (!gpio_is_valid(pdata-overcurrent_pin[i]))
+   continue;
+   gpio = pdata-overcurrent_pin[i];
 
-   ohci_at91_usb_set_power(pdata, i, 1);
+   ret = gpio_request(gpio, ohci_overcurrent);
+   if (ret) {
+   dev_err(pdev-dev

[PATCH 0/4] USB: host: ohci-at91: cleanups

2015-08-10 Thread Alexandre Belloni
Hi,

Here are a few cleanups for ohci-at91. This is the fallout of AT91 now being DT
only.

Alexandre Belloni (4):
  USB: host: ohci-at91: move at91_usbh_data definition in c file
  USB: host: ohci-at91: depend on OF
  USB: host: ohci-at91: merge ohci_at91_of_init in
ohci_hcd_at91_drv_probe
  USB: host: ohci-at91: merge loops in ohci_hcd_at91_drv_probe

 drivers/usb/host/Kconfig|   8 +-
 drivers/usb/host/ohci-at91.c| 179 
 include/linux/platform_data/atmel.h |  12 ---
 3 files changed, 85 insertions(+), 114 deletions(-)

-- 
2.1.4

--
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 4/4] USB: host: ohci-at91: merge loops in ohci_hcd_at91_drv_probe

2015-08-10 Thread Alexandre Belloni
ohci_hcd_at91_drv_probe() has four at91_for_each_port. They can be merged
into two loops without changing the driver behaviour.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 drivers/usb/host/ohci-at91.c | 34 --
 1 file changed, 16 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index cdd91c551c7b..342ffd140122 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -477,33 +477,21 @@ static int ohci_hcd_at91_drv_probe(struct platform_device 
*pdev)
pdata-ports = ports;
 
at91_for_each_port(i) {
-   gpio = of_get_named_gpio_flags(np, atmel,vbus-gpio, i, 
flags);
-   pdata-vbus_pin[i] = gpio;
-   if (!gpio_is_valid(gpio))
-   continue;
-   pdata-vbus_pin_active_low[i] = flags  OF_GPIO_ACTIVE_LOW;
-   }
-
-   at91_for_each_port(i)
-   pdata-overcurrent_pin[i] =
-   of_get_named_gpio_flags(np, atmel,oc-gpio, i, flags);
-
-   pdev-dev.platform_data = pdata;
-
-   at91_for_each_port(i) {
/*
 * do not configure PIO if not in relation with
 * real USB port on board
 */
if (i = pdata-ports) {
pdata-vbus_pin[i] = -EINVAL;
-   pdata-overcurrent_pin[i] = -EINVAL;
-   break;
+   continue;
}
 
-   if (!gpio_is_valid(pdata-vbus_pin[i]))
+   gpio = of_get_named_gpio_flags(np, atmel,vbus-gpio, i,
+  flags);
+   pdata-vbus_pin[i] = gpio;
+   if (!gpio_is_valid(gpio))
continue;
-   gpio = pdata-vbus_pin[i];
+   pdata-vbus_pin_active_low[i] = flags  OF_GPIO_ACTIVE_LOW;
 
ret = gpio_request(gpio, ohci_vbus);
if (ret) {
@@ -525,6 +513,14 @@ 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;
+   }
+
+   pdata-overcurrent_pin[i] =
+   of_get_named_gpio_flags(np, atmel,oc-gpio, i, flags);
+
if (!gpio_is_valid(pdata-overcurrent_pin[i]))
continue;
gpio = pdata-overcurrent_pin[i];
@@ -556,6 +552,8 @@ static int ohci_hcd_at91_drv_probe(struct platform_device 
*pdev)
}
}
 
+   pdev-dev.platform_data = pdata;
+
device_init_wakeup(pdev-dev, 1);
return usb_hcd_at91_probe(ohci_at91_hc_driver, pdev);
 }
-- 
2.1.4

--
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 2/4] USB: host: ohci-at91: depend on OF

2015-08-10 Thread Alexandre Belloni
Make the driver depend on CONFIG_OF and remove the now useless #ifdef

Also, fix the Kconfig indentation.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 drivers/usb/host/Kconfig | 8 
 drivers/usb/host/ohci-at91.c | 9 +
 2 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 8afc3c1efdab..7ef56faf09bb 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -441,10 +441,10 @@ config USB_OHCI_HCD_PXA27X
  PXA27x/PXA3xx chips.
 
 config USB_OHCI_HCD_AT91
-tristate Support for Atmel on-chip OHCI USB controller
-depends on USB_OHCI_HCD  ARCH_AT91
-default y
----help---
+   tristate Support for Atmel on-chip OHCI USB controller
+   depends on USB_OHCI_HCD  ARCH_AT91  OF
+   default y
+   ---help---
   Enables support for the on-chip OHCI controller on
   Atmel chips.
 
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 72dc4f9e2a0f..8e17d5ba26c6 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -442,7 +442,6 @@ static irqreturn_t ohci_hcd_at91_overcurrent_irq(int irq, 
void *data)
return IRQ_HANDLED;
 }
 
-#ifdef CONFIG_OF
 static const struct of_device_id at91_ohci_dt_ids[] = {
{ .compatible = atmel,at91rm9200-ohci },
{ /* sentinel */ }
@@ -492,12 +491,6 @@ static int ohci_at91_of_init(struct platform_device *pdev)
 
return 0;
 }
-#else
-static int ohci_at91_of_init(struct platform_device *pdev)
-{
-   return 0;
-}
-#endif
 
 /*-*/
 
@@ -684,7 +677,7 @@ static struct platform_driver ohci_hcd_at91_driver = {
.driver = {
.name   = at91_ohci,
.pm = ohci_hcd_at91_pm_ops,
-   .of_match_table = of_match_ptr(at91_ohci_dt_ids),
+   .of_match_table = at91_ohci_dt_ids,
},
 };
 
-- 
2.1.4

--
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:Simplify the error checking of the function,at91sam9261_udc_init

2015-06-18 Thread Alexandre Belloni
On 03/05/2015 at 23:25:02 -0400, Nicholas Krause wrote :
 This simplifies the error checking of the function,at91sam9261_udc_init
 by using PTR_ERR_OR_ZERO in the return statement rather then a unnessary
 if statement to check the return value of a call to the function,
 syscon_regmap_lookup_by_phandle by checking with a call to the function,
 IS_ERR and returning a error pointer if there is one for the function,
 at91sam9261_udc_init. Furthermore this was found by running coccinelle
 against the lastest kernel tree.
 
 Signed-off-by: Nicholas Krause xerofo...@gmail.com
Acked-by: Alexandre Belloni alexandre.bell...@free-electrons.com

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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:Simplify the error checking of the function,at91sam9261_udc_init

2015-06-18 Thread Alexandre Belloni
On 18/06/2015 at 18:41:14 +0200, Alexandre Belloni wrote :
 On 03/05/2015 at 23:25:02 -0400, Nicholas Krause wrote :
  This simplifies the error checking of the function,at91sam9261_udc_init
  by using PTR_ERR_OR_ZERO in the return statement rather then a unnessary
  if statement to check the return value of a call to the function,
  syscon_regmap_lookup_by_phandle by checking with a call to the function,
  IS_ERR and returning a error pointer if there is one for the function,
  at91sam9261_udc_init. Furthermore this was found by running coccinelle
  against the lastest kernel tree.
  
  Signed-off-by: Nicholas Krause xerofo...@gmail.com
 Acked-by: Alexandre Belloni alexandre.bell...@free-electrons.com
 

OK, it seems the original patch got ignored by all the mailing lists. To
bad, that one was actually applicable :)

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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: MUSB dual-role on AM335x behaving weirdly

2015-05-27 Thread Alexandre Belloni
Hi,

On 26/05/2015 at 09:51:18 -0500, Felipe Balbi wrote :
 On Thu, May 14, 2015 at 04:36:33PM -0500, Bin Liu wrote:
  Alexandre,
  
  On Thu, May 14, 2015 at 4:26 PM, Alexandre Belloni
  alexandre.bell...@free-electrons.com wrote:
   On 14/05/2015 at 16:16:12 -0500, Bin Liu wrote :
   I think I found the root cause of the problem: board design issue - I
   bet the custom board has too much cap on VBUS line. It should be 
   10uF.
  
  
   We have a custom board that exhibits the issue but it only has a 100nF
   cap on VBUS.
  
  Have you measured the VBUS discharging? Is there any way to share your
  schematics?
 
 Alexandre, any further comments ?
 

Yeah, I have just got more info.

This is the relevant part of the schematic:
http://free-electrons.com/~alexandre/usb.png

The total VBUS capacitance is 200nF and the USB0 pins are connected
directly to the AM3358 pins. U1 is actually not fitted.

We didn't measure VBUS discharging but we observe the OTG pin sensing
stops when plugging an OTG cable without any device.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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] udc: gadget: atmel_usba_udc: depend on COMMON_CLK_AT91

2015-03-12 Thread Alexandre Belloni
On 10/03/2015 at 16:23:53 -0500, Felipe Balbi wrote :
  Yeah, let's drop it for now but I have the feeling that this will
  break (I actually broke it when switching at91 to multiplatform).
 
 aha, that changes it. So you already have something which makes this
 break ? Are you planning on sending that upstream any time soon ?
 

It has been sent but not merge and I need to send another version.

 We could very well use that same series to merge this patch. Only when
 it's needed ;-)
 

Like said, this is not an issue for now, I fixed it by simply having all
the AT91 platform selecting COMMON_CLK_AT91. I just have the feeling
that this is not quite future proof.
So this is not urgent at all and I'll try to remember to resend when
needed.


-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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] udc: gadget: atmel_usba_udc: depend on COMMON_CLK_AT91

2015-03-10 Thread Alexandre Belloni
On 10/03/2015 at 15:53:12 -0500, Felipe Balbi wrote :
 On Tue, Mar 03, 2015 at 10:41:38AM +0100, Alexandre Belloni wrote:
  On 03/03/2015 at 09:26:20 +0100, Boris Brezillon wrote :
 config USB_ATMEL_USBA
tristate Atmel USBA
-   depends on AVR32 || ARCH_AT91
+   depends on AVR32 || ARCH_AT91  COMMON_CLK_AT91
   
   I guess you should add parenthesis to make it clearer ?
   
 depends on AVR32 || (ARCH_AT91  COMMON_CLK_AT91)
   
   And I wonder why you need that. I though this option was selected by all
   at91 platforms ?
   
  
  That is currently the case but maybe, one day, one of the AT91 platform
  will not use the same clock driver.
 
 then, maybe, one day, you send this patch.

Yeah, let's drop it for now but I have the feeling that this will
break (I actually broke it when switching at91 to multiplatform).


-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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] udc: gadget: atmel_usba_udc: depend on COMMON_CLK_AT91

2015-03-03 Thread Alexandre Belloni
On 03/03/2015 at 09:26:20 +0100, Boris Brezillon wrote :
   config USB_ATMEL_USBA
  tristate Atmel USBA
  -   depends on AVR32 || ARCH_AT91
  +   depends on AVR32 || ARCH_AT91  COMMON_CLK_AT91
 
 I guess you should add parenthesis to make it clearer ?
 
   depends on AVR32 || (ARCH_AT91  COMMON_CLK_AT91)
 
 And I wonder why you need that. I though this option was selected by all
 at91 platforms ?
 

That is currently the case but maybe, one day, one of the AT91 platform
will not use the same clock driver.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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] udc: gadget: atmel_usba_udc: depend on COMMON_CLK_AT91

2015-03-02 Thread Alexandre Belloni
Since the addition of the errata handling for at91sam9rl and at91sam9g45, the
atmel_usba_udc depends on the pmc driver being present. Explicitly set that
dependency.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 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 9a3a6b00391a..b04206fdba11 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 || ARCH_AT91  COMMON_CLK_AT91
help
  USBA is the integrated high-speed USB Device controller on
  the AT32AP700x, some AT91SAM9 and AT91CAP9 processors from Atmel.
-- 
2.1.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 1/3] USB: gadget: at91_udc: add at91sam9n12 support

2015-02-09 Thread Alexandre Belloni
Hi Bo,

On 09/02/2015 at 17:02:50 +0800, Bo Shen wrote :
 Add at91sam9n12 SoC support.
 
 Signed-off-by: Bo Shen voice.s...@atmel.com
 ---
 
  drivers/usb/gadget/udc/at91_udc.c | 9 ++---
  1 file changed, 6 insertions(+), 3 deletions(-)
 
 diff --git a/drivers/usb/gadget/udc/at91_udc.c 
 b/drivers/usb/gadget/udc/at91_udc.c
 index c862656..f4c785f 100644
 --- a/drivers/usb/gadget/udc/at91_udc.c
 +++ b/drivers/usb/gadget/udc/at91_udc.c
 @@ -931,7 +931,8 @@ static void pullup(struct at91_udc *udc, int is_on)
   at91_udp_write(udc, AT91_UDP_TXVC, 0);
   if (cpu_is_at91rm9200())
   gpio_set_value(udc-board.pullup_pin, active);
 - else if (cpu_is_at91sam9260() || cpu_is_at91sam9263() || 
 cpu_is_at91sam9g20()) {
 + else if (cpu_is_at91sam9260() || cpu_is_at91sam9263() ||
 +  cpu_is_at91sam9g20() || cpu_is_at91sam9n12()) {

cpu_is_at91xx have been removed from the kernel, using the correct
compatible should be enough, see
http://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/drivers/usb/gadget/udc/at91_udc.c?id=f0bceab4e3b528e799aba8fda8d2936fcfd41f1f


   u32 txvc = at91_udp_read(udc, AT91_UDP_TXVC);
  
   txvc |= AT91_UDP_TXVC_PUON;
 @@ -949,7 +950,8 @@ static void pullup(struct at91_udc *udc, int is_on)
   at91_udp_write(udc, AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS);
   if (cpu_is_at91rm9200())
   gpio_set_value(udc-board.pullup_pin, !active);
 - else if (cpu_is_at91sam9260() || cpu_is_at91sam9263() || 
 cpu_is_at91sam9g20()) {
 + else if (cpu_is_at91sam9260() || cpu_is_at91sam9263() ||
 +  cpu_is_at91sam9g20() || cpu_is_at91sam9n12()) {
   u32 txvc = at91_udp_read(udc, AT91_UDP_TXVC);
  
   txvc = ~AT91_UDP_TXVC_PUON;
 @@ -1758,7 +1760,8 @@ static int at91udc_probe(struct platform_device *pdev)
   }
  
   /* newer chips have more FIFO memory than rm9200 */
 - if (cpu_is_at91sam9260() || cpu_is_at91sam9g20()) {
 + if (cpu_is_at91sam9260() || cpu_is_at91sam9g20() ||
 + cpu_is_at91sam9n12()) {
   udc-ep[0].maxpacket = 64;
   udc-ep[3].maxpacket = 64;
   udc-ep[4].maxpacket = 512;
 -- 
 2.3.0.rc0
 
 
 ___
 linux-arm-kernel mailing list
 linux-arm-ker...@lists.infradead.org
 http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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: [PATCHv2 2/2] USB: host: ohci_at91: Stop/start USB PLL for all sleep modes

2015-01-18 Thread Alexandre Belloni
On 17/01/2015 at 16:36:35 +0100, Sylvain Rochet wrote :
 Disable/unprepare clocks without testing the sleep target_state, removed
 the at91_suspend_entering_slow_clock() call (which is only a
 target_state == PM_SUSPEND_MEM).
 
 Other kind of suspend now benefit from the power save induced by this
 PLL deactivation. The resume penalty is about 500 us, which is not
 negligible but acceptable considering the amount of power we are saving.
 
 Signed-off-by: Sylvain Rochet sylvain.roc...@finsecur.com
 Reported-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Alexandre Belloni alexandre.bell...@free-electrons.com

 ---
  drivers/usb/host/ohci-at91.c | 25 +
  1 file changed, 13 insertions(+), 12 deletions(-)
 
 diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
 index dc9e4e6..f0da734 100644
 --- a/drivers/usb/host/ohci-at91.c
 +++ b/drivers/usb/host/ohci-at91.c
 @@ -49,6 +49,8 @@ extern int usb_disabled(void);
  
  static void at91_start_clock(void)
  {
 + if (clocked)
 + return;
   if (IS_ENABLED(CONFIG_COMMON_CLK)) {
   clk_set_rate(uclk, 4800);
   clk_prepare_enable(uclk);
 @@ -61,6 +63,8 @@ static void at91_start_clock(void)
  
  static void at91_stop_clock(void)
  {
 + if (!clocked)
 + return;
   clk_disable_unprepare(fclk);
   clk_disable_unprepare(iclk);
   clk_disable_unprepare(hclk);
 @@ -615,16 +619,14 @@ ohci_hcd_at91_drv_suspend(struct platform_device *pdev, 
 pm_message_t mesg)
*
* REVISIT: some boards will be able to turn VBUS off...
*/
 - if (at91_suspend_entering_slow_clock()) {
 - ohci-hc_control = ohci_readl(ohci, ohci-regs-control);
 - ohci-hc_control = OHCI_CTRL_RWC;
 - ohci_writel(ohci, ohci-hc_control, ohci-regs-control);
 - ohci-rh_state = OHCI_RH_HALTED;
 -
 - /* flush the writes */
 - (void) ohci_readl (ohci, ohci-regs-control);
 - at91_stop_clock();
 - }
 + ohci-hc_control = ohci_readl(ohci, ohci-regs-control);
 + ohci-hc_control = OHCI_CTRL_RWC;
 + ohci_writel(ohci, ohci-hc_control, ohci-regs-control);
 + ohci-rh_state = OHCI_RH_HALTED;
 +
 + /* flush the writes */
 + (void) ohci_readl (ohci, ohci-regs-control);
 + at91_stop_clock();
  
   return ret;
  }
 @@ -636,8 +638,7 @@ static int ohci_hcd_at91_drv_resume(struct 
 platform_device *pdev)
   if (device_may_wakeup(pdev-dev))
   disable_irq_wake(hcd-irq);
  
 - if (!clocked)
 - at91_start_clock();
 + at91_start_clock();
  
   ohci_resume(hcd, false);
   return 0;
 -- 
 2.1.4
 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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 05/12] usb: gadget: at91_udc: Fix clock names

2015-01-14 Thread Alexandre Belloni
From: Boris Brezillon boris.brezil...@free-electrons.com

The driver is requesting clock by their global name (those declared in the
clk_lookup list), but this only works with !CCF kernels.

Now that all SoCs have moved to CCF, fix the driver to use local names
(hclk and pclk).

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 drivers/usb/gadget/udc/at91_udc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/udc/at91_udc.c 
b/drivers/usb/gadget/udc/at91_udc.c
index c862656d18b8..9ff2f7e5c6a7 100644
--- a/drivers/usb/gadget/udc/at91_udc.c
+++ b/drivers/usb/gadget/udc/at91_udc.c
@@ -1779,8 +1779,8 @@ static int at91udc_probe(struct platform_device *pdev)
udc_reinit(udc);
 
/* get interface and function clocks */
-   udc-iclk = clk_get(dev, udc_clk);
-   udc-fclk = clk_get(dev, udpck);
+   udc-iclk = clk_get(dev, pclk);
+   udc-fclk = clk_get(dev, hclk);
if (IS_ENABLED(CONFIG_COMMON_CLK))
udc-uclk = clk_get(dev, usb_clk);
if (IS_ERR(udc-iclk) || IS_ERR(udc-fclk) ||
-- 
2.1.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 01/12] mfd: syscon: Add atmel-matrix registers definition

2015-01-14 Thread Alexandre Belloni
From: Boris Brezillon boris.brezil...@free-electrons.com

AT91 SoCs have a memory range reserved for internal bus configuration.
Expose those registers so that drivers can make use of the matrix syscon
declared in at91 DTs.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Lee Jones lee.jo...@linaro.org
---
 include/linux/mfd/syscon/atmel-matrix.h | 117 
 1 file changed, 117 insertions(+)
 create mode 100644 include/linux/mfd/syscon/atmel-matrix.h

diff --git a/include/linux/mfd/syscon/atmel-matrix.h 
b/include/linux/mfd/syscon/atmel-matrix.h
new file mode 100644
index ..8293c3e2a82a
--- /dev/null
+++ b/include/linux/mfd/syscon/atmel-matrix.h
@@ -0,0 +1,117 @@
+/*
+ *  Copyright (C) 2014 Atmel Corporation.
+ *
+ * Memory Controllers (MATRIX, EBI) - System peripherals registers.
+ *
+ * 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 _LINUX_MFD_SYSCON_ATMEL_MATRIX_H
+#define _LINUX_MFD_SYSCON_ATMEL_MATRIX_H
+
+#define AT91SAM9260_MATRIX_MCFG0x00
+#define AT91SAM9260_MATRIX_SCFG0x40
+#define AT91SAM9260_MATRIX_PRS 0x80
+#define AT91SAM9260_MATRIX_MRCR0x100
+#define AT91SAM9260_MATRIX_EBICSA  0x11c
+
+#define AT91SAM9261_MATRIX_MRCR0x0
+#define AT91SAM9261_MATRIX_SCFG0x4
+#define AT91SAM9261_MATRIX_TCR 0x24
+#define AT91SAM9261_MATRIX_EBICSA  0x30
+#define AT91SAM9261_MATRIX_USBPUCR 0x34
+
+#define AT91SAM9263_MATRIX_MCFG0x00
+#define AT91SAM9263_MATRIX_SCFG0x40
+#define AT91SAM9263_MATRIX_PRS 0x80
+#define AT91SAM9263_MATRIX_MRCR0x100
+#define AT91SAM9263_MATRIX_TCR 0x114
+#define AT91SAM9263_MATRIX_EBI0CSA 0x120
+#define AT91SAM9263_MATRIX_EBI1CSA 0x124
+
+#define AT91SAM9RL_MATRIX_MCFG 0x00
+#define AT91SAM9RL_MATRIX_SCFG 0x40
+#define AT91SAM9RL_MATRIX_PRS  0x80
+#define AT91SAM9RL_MATRIX_MRCR 0x100
+#define AT91SAM9RL_MATRIX_TCR  0x114
+#define AT91SAM9RL_MATRIX_EBICSA   0x120
+
+#define AT91SAM9G45_MATRIX_MCFG0x00
+#define AT91SAM9G45_MATRIX_SCFG0x40
+#define AT91SAM9G45_MATRIX_PRS 0x80
+#define AT91SAM9G45_MATRIX_MRCR0x100
+#define AT91SAM9G45_MATRIX_TCR 0x110
+#define AT91SAM9G45_MATRIX_DDRMPR  0x118
+#define AT91SAM9G45_MATRIX_EBICSA  0x128
+
+#define AT91SAM9N12_MATRIX_MCFG0x00
+#define AT91SAM9N12_MATRIX_SCFG0x40
+#define AT91SAM9N12_MATRIX_PRS 0x80
+#define AT91SAM9N12_MATRIX_MRCR0x100
+#define AT91SAM9N12_MATRIX_EBICSA  0x118
+
+#define AT91SAM9X5_MATRIX_MCFG 0x00
+#define AT91SAM9X5_MATRIX_SCFG 0x40
+#define AT91SAM9X5_MATRIX_PRS  0x80
+#define AT91SAM9X5_MATRIX_MRCR 0x100
+#define AT91SAM9X5_MATRIX_EBICSA   0x120
+
+#define SAMA5D3_MATRIX_MCFG0x00
+#define SAMA5D3_MATRIX_SCFG0x40
+#define SAMA5D3_MATRIX_PRS 0x80
+#define SAMA5D3_MATRIX_MRCR0x100
+
+#define AT91_MATRIX_MCFG(o, x) ((o) + ((x) * 0x4))
+#define AT91_MATRIX_ULBT   GENMASK(2, 0)
+#define AT91_MATRIX_ULBT_INFINITE  (0  0)
+#define AT91_MATRIX_ULBT_SINGLE(1  0)
+#define AT91_MATRIX_ULBT_FOUR  (2  0)
+#define AT91_MATRIX_ULBT_EIGHT (3  0)
+#define AT91_MATRIX_ULBT_SIXTEEN   (4  0)
+
+#define AT91_MATRIX_SCFG(o, x) ((o) + ((x) * 0x4))
+#define AT91_MATRIX_SLOT_CYCLE GENMASK(7,  0)
+#define AT91_MATRIX_DEFMSTR_TYPE   GENMASK(17, 16)
+#define AT91_MATRIX_DEFMSTR_TYPE_NONE  (0  16)
+#define AT91_MATRIX_DEFMSTR_TYPE_LAST  (1  16)
+#define AT91_MATRIX_DEFMSTR_TYPE_FIXED (2  16)
+#define AT91_MATRIX_FIXED_DEFMSTR  GENMASK(20, 18)
+#define AT91_MATRIX_ARBT   GENMASK(25, 24)
+#define AT91_MATRIX_ARBT_ROUND_ROBIN   (0  24)
+#define AT91_MATRIX_ARBT_FIXED_PRIORITY(1  24)
+
+#define AT91_MATRIX_ITCM_SIZE  GENMASK(3, 0)
+#define AT91_MATRIX_ITCM_0 (0  0)
+#define AT91_MATRIX_ITCM_16(5  0)
+#define AT91_MATRIX_ITCM_32(6  0)
+#define AT91_MATRIX_ITCM_64(7  0)

[PATCH 04/12] mfd: syscon: Add Atmel SMC binding doc

2015-01-14 Thread Alexandre Belloni
From: Boris Brezillon boris.brezil...@free-electrons.com

The SMC registers are used to configure Atmel EBI (External Bus Interface)
to interface with standard memory devices (NAND, NOR, SRAM or specialized
devices like FPGAs).

Declare this memory region as a syscon, so that different drivers can
configure the SMC interface (mostly timing configuration) according to
their need.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Lee Jones lee.jo...@linaro.org
---
 Documentation/devicetree/bindings/mfd/atmel-smc.txt | 19 +++
 1 file changed, 19 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/atmel-smc.txt

diff --git a/Documentation/devicetree/bindings/mfd/atmel-smc.txt 
b/Documentation/devicetree/bindings/mfd/atmel-smc.txt
new file mode 100644
index ..26eeed373934
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/atmel-smc.txt
@@ -0,0 +1,19 @@
+* Device tree bindings for Atmel SMC (Static Memory Controller)
+
+The SMC registers are used to configure Atmel EBI (External Bus Interface)
+to interface with standard memory devices (NAND, NOR, SRAM or specialized
+devices like FPGAs).
+
+Required properties:
+- compatible:  Should be one of the following
+   atmel,at91sam9260-smc, syscon
+   atmel,sama5d3-smc, syscon
+- reg: Contains offset/length value of the SMC memory
+   region.
+
+Example:
+
+smc: smc@c000 {
+   compatible = atmel,sama5d3-smc, syscon;
+   reg = 0xc000 0x1000;
+};
-- 
2.1.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 08/12] usb: gadget: at91_udc: Remove non-DT handling code

2015-01-14 Thread Alexandre Belloni
From: Boris Brezillon boris.brezil...@free-electrons.com

Since non-DT board support has been removed from the at91 architecture we
can safely remove non-DT handling code.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 drivers/usb/gadget/udc/Kconfig|  1 +
 drivers/usb/gadget/udc/at91_udc.c | 16 ++--
 2 files changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/gadget/udc/Kconfig b/drivers/usb/gadget/udc/Kconfig
index b8e213eb36cc..366e551aeff0 100644
--- a/drivers/usb/gadget/udc/Kconfig
+++ b/drivers/usb/gadget/udc/Kconfig
@@ -32,6 +32,7 @@ menu USB Peripheral Controller
 config USB_AT91
tristate Atmel AT91 USB Device Port
depends on ARCH_AT91
+   depends on OF || COMPILE_TEST
help
   Many Atmel AT91 processors (such as the AT91RM2000) have a
   full speed USB Device Port with support for five configurable
diff --git a/drivers/usb/gadget/udc/at91_udc.c 
b/drivers/usb/gadget/udc/at91_udc.c
index d33f2994b7c4..be7e16037ac4 100644
--- a/drivers/usb/gadget/udc/at91_udc.c
+++ b/drivers/usb/gadget/udc/at91_udc.c
@@ -1710,12 +1710,6 @@ static int at91udc_probe(struct platform_device *pdev)
int retval;
struct resource *res;
 
-   if (!dev_get_platdata(dev)  !pdev-dev.of_node) {
-   /* small (so we copy it) but critical! */
-   DBG(missing platform_data\n);
-   return -ENODEV;
-   }
-
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res)
return -ENXIO;
@@ -1728,11 +1722,7 @@ static int at91udc_probe(struct platform_device *pdev)
/* init software state */
udc = controller;
udc-gadget.dev.parent = dev;
-   if (IS_ENABLED(CONFIG_OF)  pdev-dev.of_node)
-   at91udc_of_init(udc, pdev-dev.of_node);
-   else
-   memcpy(udc-board, dev_get_platdata(dev),
-  sizeof(struct at91_udc_data));
+   at91udc_of_init(udc, pdev-dev.of_node);
udc-pdev = pdev;
udc-enabled = 0;
spin_lock_init(udc-lock);
@@ -1968,14 +1958,12 @@ static int at91udc_resume(struct platform_device *pdev)
 #defineat91udc_resume  NULL
 #endif
 
-#if defined(CONFIG_OF)
 static const struct of_device_id at91_udc_dt_ids[] = {
{ .compatible = atmel,at91rm9200-udc },
{ /* sentinel */ }
 };
 
 MODULE_DEVICE_TABLE(of, at91_udc_dt_ids);
-#endif
 
 static struct platform_driver at91_udc_driver = {
.remove = __exit_p(at91udc_remove),
@@ -1984,7 +1972,7 @@ static struct platform_driver at91_udc_driver = {
.resume = at91udc_resume,
.driver = {
.name   = (char *) driver_name,
-   .of_match_table = of_match_ptr(at91_udc_dt_ids),
+   .of_match_table = at91_udc_dt_ids,
},
 };
 
-- 
2.1.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 02/12] mfd: syscon: Add Atmel Matrix bus DT binding documentation

2015-01-14 Thread Alexandre Belloni
From: Boris Brezillon boris.brezil...@free-electrons.com

The Matrix registers are provided to configure internal bus behavior on
at91 SoCs.
Some registers might be accessed by several drivers (e.g. to configure
external memory bus timings), hence we declare this register set as a
syscon device.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Lee Jones lee.jo...@linaro.org
---
 .../devicetree/bindings/mfd/atmel-matrix.txt   | 24 ++
 1 file changed, 24 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/atmel-matrix.txt

diff --git a/Documentation/devicetree/bindings/mfd/atmel-matrix.txt 
b/Documentation/devicetree/bindings/mfd/atmel-matrix.txt
new file mode 100644
index ..e3ef50ca02a5
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/atmel-matrix.txt
@@ -0,0 +1,24 @@
+* Device tree bindings for Atmel Bus Matrix
+
+The Bus Matrix registers are used to configure Atmel SoCs internal bus
+behavior (master/slave priorities, undefined burst length type, ...)
+
+Required properties:
+- compatible:  Should be one of the following
+   atmel,at91sam9260-matrix, syscon
+   atmel,at91sam9261-matrix, syscon
+   atmel,at91sam9263-matrix, syscon
+   atmel,at91sam9rl-matrix, syscon
+   atmel,at91sam9g45-matrix, syscon
+   atmel,at91sam9n12-matrix, syscon
+   atmel,at91sam9x5-matrix, syscon
+   atmel,sama5d3-matrix, syscon
+- reg: Contains offset/length value of the Bus Matrix
+   memory region.
+
+Example:
+
+matrix: matrix@ec00 {
+   compatible = atmel,sama5d3-matrix, syscon;
+   reg = 0xec00 0x200;
+};
-- 
2.1.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 06/12] usb: gadget: at91_udc: Drop uclk clock

2015-01-14 Thread Alexandre Belloni
From: Boris Brezillon boris.brezil...@free-electrons.com

Now that at91 system clocks forward set_rate request to their parent we
can remove the uclk clock and directly call clk_set_rate on fclk.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 drivers/usb/gadget/udc/at91_udc.c | 27 +++
 drivers/usb/gadget/udc/at91_udc.h |  2 +-
 2 files changed, 4 insertions(+), 25 deletions(-)

diff --git a/drivers/usb/gadget/udc/at91_udc.c 
b/drivers/usb/gadget/udc/at91_udc.c
index 9ff2f7e5c6a7..d33f2994b7c4 100644
--- a/drivers/usb/gadget/udc/at91_udc.c
+++ b/drivers/usb/gadget/udc/at91_udc.c
@@ -895,8 +895,6 @@ static void clk_on(struct at91_udc *udc)
return;
udc-clocked = 1;
 
-   if (IS_ENABLED(CONFIG_COMMON_CLK))
-   clk_enable(udc-uclk);
clk_enable(udc-iclk);
clk_enable(udc-fclk);
 }
@@ -909,8 +907,6 @@ static void clk_off(struct at91_udc *udc)
udc-gadget.speed = USB_SPEED_UNKNOWN;
clk_disable(udc-fclk);
clk_disable(udc-iclk);
-   if (IS_ENABLED(CONFIG_COMMON_CLK))
-   clk_disable(udc-uclk);
 }
 
 /*
@@ -1781,25 +1777,17 @@ static int at91udc_probe(struct platform_device *pdev)
/* get interface and function clocks */
udc-iclk = clk_get(dev, pclk);
udc-fclk = clk_get(dev, hclk);
-   if (IS_ENABLED(CONFIG_COMMON_CLK))
-   udc-uclk = clk_get(dev, usb_clk);
-   if (IS_ERR(udc-iclk) || IS_ERR(udc-fclk) ||
-   (IS_ENABLED(CONFIG_COMMON_CLK)  IS_ERR(udc-uclk))) {
+   if (IS_ERR(udc-iclk) || IS_ERR(udc-fclk)) {
DBG(clocks missing\n);
retval = -ENODEV;
goto fail1;
}
 
/* 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;
-   }
+   clk_set_rate(udc-fclk, 4800);
retval = clk_prepare(udc-fclk);
if (retval)
-   goto fail1a;
+   goto fail1;
 
retval = clk_prepare_enable(udc-iclk);
if (retval)
@@ -1873,12 +1861,7 @@ 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);
if (!IS_ERR(udc-fclk))
clk_put(udc-fclk);
if (!IS_ERR(udc-iclk))
@@ -1924,15 +1907,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))
-   clk_put(udc-uclk);
 
return 0;
 }
diff --git a/drivers/usb/gadget/udc/at91_udc.h 
b/drivers/usb/gadget/udc/at91_udc.h
index 017524663381..e647d1c2ada4 100644
--- a/drivers/usb/gadget/udc/at91_udc.h
+++ b/drivers/usb/gadget/udc/at91_udc.h
@@ -126,7 +126,7 @@ struct at91_udc {
unsignedactive_suspend:1;
u8  addr;
struct at91_udc_databoard;
-   struct clk  *iclk, *fclk, *uclk;
+   struct clk  *iclk, *fclk;
struct platform_device  *pdev;
struct proc_dir_entry   *pde;
void __iomem*udp_baseaddr;
-- 
2.1.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 07/12] usb: gadget: at91_udc: Document DT clocks and clock-names property

2015-01-14 Thread Alexandre Belloni
From: Boris Brezillon boris.brezil...@free-electrons.com

The at91_udc driver request 2 clocks, and thus need them to be defined in
the device tree.
Document the clocks and clock-names properties so that everybody use the
correct names.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 Documentation/devicetree/bindings/usb/atmel-usb.txt | 4 
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/atmel-usb.txt 
b/Documentation/devicetree/bindings/usb/atmel-usb.txt
index bcca3f2a..6007231e0adc 100644
--- a/Documentation/devicetree/bindings/usb/atmel-usb.txt
+++ b/Documentation/devicetree/bindings/usb/atmel-usb.txt
@@ -36,6 +36,10 @@ Required properties:
  - compatible: Should be atmel,at91rm9200-udc
  - 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
+   pclk for the peripheral clock
+   hclk for the AHB clock
 
 Optional properties:
  - atmel,vbus-gpio: If present, specifies a gpio that needs to be
-- 
2.1.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 10/12] usb: gadget: at91_udc: Rework for multi-platform kernel support

2015-01-14 Thread Alexandre Belloni
From: Boris Brezillon boris.brezil...@free-electrons.com

cpu_is_at91xxx are a set of macros defined in mach/cpu.h and are here used
to detect the SoC we are booting on.
Use compatible string + a caps structure to replace those cpu_is_xxx tests.

Remove all mach and asm headers (which are now unused).

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 drivers/usb/gadget/udc/at91_udc.c | 288 --
 drivers/usb/gadget/udc/at91_udc.h |   7 +
 2 files changed, 218 insertions(+), 77 deletions(-)

diff --git a/drivers/usb/gadget/udc/at91_udc.c 
b/drivers/usb/gadget/udc/at91_udc.c
index 4dba2c65dfd4..c0abb9bc76a9 100644
--- a/drivers/usb/gadget/udc/at91_udc.c
+++ b/drivers/usb/gadget/udc/at91_udc.c
@@ -31,16 +31,9 @@
 #include linux/of.h
 #include linux/of_gpio.h
 #include linux/platform_data/atmel.h
-
-#include asm/byteorder.h
-#include mach/hardware.h
-#include asm/io.h
-#include asm/irq.h
-#include asm/gpio.h
-
-#include mach/cpu.h
-#include mach/at91sam9261_matrix.h
-#include mach/at91_matrix.h
+#include linux/regmap.h
+#include linux/mfd/syscon.h
+#include linux/mfd/syscon/atmel-matrix.h
 
 #include at91_udc.h
 
@@ -915,8 +908,6 @@ static void clk_off(struct at91_udc *udc)
  */
 static void pullup(struct at91_udc *udc, int is_on)
 {
-   int active = !udc-board.pullup_active_low;
-
if (!udc-enabled || !udc-vbus)
is_on = 0;
DBG(%sactive\n, is_on ?  : in);
@@ -925,40 +916,15 @@ static void pullup(struct at91_udc *udc, int is_on)
clk_on(udc);
at91_udp_write(udc, AT91_UDP_ICR, AT91_UDP_RXRSM);
at91_udp_write(udc, AT91_UDP_TXVC, 0);
-   if (cpu_is_at91rm9200())
-   gpio_set_value(udc-board.pullup_pin, active);
-   else if (cpu_is_at91sam9260() || cpu_is_at91sam9263() || 
cpu_is_at91sam9g20()) {
-   u32 txvc = at91_udp_read(udc, AT91_UDP_TXVC);
-
-   txvc |= AT91_UDP_TXVC_PUON;
-   at91_udp_write(udc, AT91_UDP_TXVC, txvc);
-   } else if (cpu_is_at91sam9261() || cpu_is_at91sam9g10()) {
-   u32 usbpucr;
-
-   usbpucr = at91_matrix_read(AT91_MATRIX_USBPUCR);
-   usbpucr |= AT91_MATRIX_USBPUCR_PUON;
-   at91_matrix_write(AT91_MATRIX_USBPUCR, usbpucr);
-   }
} else {
stop_activity(udc);
at91_udp_write(udc, AT91_UDP_IDR, AT91_UDP_RXRSM);
at91_udp_write(udc, AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS);
-   if (cpu_is_at91rm9200())
-   gpio_set_value(udc-board.pullup_pin, !active);
-   else if (cpu_is_at91sam9260() || cpu_is_at91sam9263() || 
cpu_is_at91sam9g20()) {
-   u32 txvc = at91_udp_read(udc, AT91_UDP_TXVC);
-
-   txvc = ~AT91_UDP_TXVC_PUON;
-   at91_udp_write(udc, AT91_UDP_TXVC, txvc);
-   } else if (cpu_is_at91sam9261() || cpu_is_at91sam9g10()) {
-   u32 usbpucr;
-
-   usbpucr = at91_matrix_read(AT91_MATRIX_USBPUCR);
-   usbpucr = ~AT91_MATRIX_USBPUCR_PUON;
-   at91_matrix_write(AT91_MATRIX_USBPUCR, usbpucr);
-   }
clk_off(udc);
}
+
+   if (udc-caps  udc-caps-pullup)
+   udc-caps-pullup(udc, is_on);
 }
 
 /* vbus is here!  turn everything on that's ready */
@@ -1683,12 +1649,202 @@ static void at91udc_shutdown(struct platform_device 
*dev)
spin_unlock_irqrestore(udc-lock, flags);
 }
 
-static void at91udc_of_init(struct at91_udc *udc,
-struct device_node *np)
+static int at91rm9200_udc_init(struct at91_udc *udc)
+{
+   struct at91_ep *ep;
+   int ret;
+   int i;
+
+   for (i = 0; i  NUM_ENDPOINTS; i++) {
+   ep = udc-ep[i];
+
+   switch (i) {
+   case 0:
+   case 3:
+   ep-maxpacket = 8;
+   break;
+   case 1 ... 2:
+   ep-maxpacket = 64;
+   break;
+   case 4 ... 5:
+   ep-maxpacket = 256;
+   break;
+   }
+   }
+
+   if (!gpio_is_valid(udc-board.pullup_pin)) {
+   DBG(no D+ pullup?\n);
+   return -ENODEV;
+   }
+
+   ret = devm_gpio_request(udc-pdev-dev, udc-board.pullup_pin,
+   udc_pullup);
+   if (ret) {
+   DBG(D+ pullup is busy\n);
+   return ret;
+   }
+
+   gpio_direction_output(udc-board.pullup_pin,
+ udc-board.pullup_active_low);
+
+   return 0;
+}
+
+static void at91rm9200_udc_pullup(struct at91_udc *udc, int is_on)
+{
+   int active = 

[PATCH 09/12] usb: gadget: at91_udc: Simplify probe and remove functions

2015-01-14 Thread Alexandre Belloni
From: Boris Brezillon boris.brezil...@free-electrons.com

Make use of devm_ functions to simplify probe and remove code.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 drivers/usb/gadget/udc/at91_udc.c | 116 +-
 1 file changed, 39 insertions(+), 77 deletions(-)

diff --git a/drivers/usb/gadget/udc/at91_udc.c 
b/drivers/usb/gadget/udc/at91_udc.c
index be7e16037ac4..4dba2c65dfd4 100644
--- a/drivers/usb/gadget/udc/at91_udc.c
+++ b/drivers/usb/gadget/udc/at91_udc.c
@@ -1710,15 +1710,6 @@ static int at91udc_probe(struct platform_device *pdev)
int retval;
struct resource *res;
 
-   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   if (!res)
-   return -ENXIO;
-
-   if (!request_mem_region(res-start, resource_size(res), driver_name)) {
-   DBG(someone's using UDC memory\n);
-   return -EBUSY;
-   }
-
/* init software state */
udc = controller;
udc-gadget.dev.parent = dev;
@@ -1731,13 +1722,13 @@ static int at91udc_probe(struct platform_device *pdev)
if (cpu_is_at91rm9200()) {
if (!gpio_is_valid(udc-board.pullup_pin)) {
DBG(no D+ pullup?\n);
-   retval = -ENODEV;
-   goto fail0;
+   return -ENODEV;
}
-   retval = gpio_request(udc-board.pullup_pin, udc_pullup);
+   retval = devm_gpio_request(dev, udc-board.pullup_pin,
+  udc_pullup);
if (retval) {
DBG(D+ pullup is busy\n);
-   goto fail0;
+   return retval;
}
gpio_direction_output(udc-board.pullup_pin,
udc-board.pullup_active_low);
@@ -1756,32 +1747,32 @@ static int at91udc_probe(struct platform_device *pdev)
udc-ep[3].maxpacket = 64;
}
 
-   udc-udp_baseaddr = ioremap(res-start, resource_size(res));
-   if (!udc-udp_baseaddr) {
-   retval = -ENOMEM;
-   goto fail0a;
-   }
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   udc-udp_baseaddr = devm_ioremap_resource(dev, res);
+   if (IS_ERR(udc-udp_baseaddr))
+   return PTR_ERR(udc-udp_baseaddr);
 
udc_reinit(udc);
 
/* get interface and function clocks */
-   udc-iclk = clk_get(dev, pclk);
-   udc-fclk = clk_get(dev, hclk);
-   if (IS_ERR(udc-iclk) || IS_ERR(udc-fclk)) {
-   DBG(clocks missing\n);
-   retval = -ENODEV;
-   goto fail1;
-   }
+   udc-iclk = devm_clk_get(dev, pclk);
+   if (IS_ERR(udc-iclk))
+   return PTR_ERR(udc-iclk);
+
+   udc-fclk = devm_clk_get(dev, hclk);
+   if (IS_ERR(udc-fclk))
+   return PTR_ERR(udc-fclk);
 
/* don't do anything until we have both gadget driver and VBUS */
clk_set_rate(udc-fclk, 4800);
retval = clk_prepare(udc-fclk);
if (retval)
-   goto fail1;
+   return retval;
 
retval = clk_prepare_enable(udc-iclk);
if (retval)
-   goto fail1b;
+   goto err_unprepare_fclk;
+
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. */
@@ -1790,18 +1781,21 @@ static int at91udc_probe(struct platform_device *pdev)
 
/* request UDC and maybe VBUS irqs */
udc-udp_irq = platform_get_irq(pdev, 0);
-   retval = request_irq(udc-udp_irq, at91_udc_irq,
-   0, driver_name, udc);
-   if (retval  0) {
+   retval = devm_request_irq(dev, udc-udp_irq, at91_udc_irq, 0,
+ driver_name, udc);
+   if (retval) {
DBG(request irq %d failed\n, udc-udp_irq);
-   goto fail1c;
+   goto err_unprepare_iclk;
}
+
if (gpio_is_valid(udc-board.vbus_pin)) {
-   retval = gpio_request(udc-board.vbus_pin, udc_vbus);
-   if (retval  0) {
+   retval = devm_gpio_request(dev, udc-board.vbus_pin,
+  udc_vbus);
+   if (retval) {
DBG(request vbus pin failed\n);
-   goto fail2;
+   goto err_unprepare_iclk;
}
+
gpio_direction_input(udc-board.vbus_pin);
 
/*
@@ -1818,12 +1812,13 @@ static int at91udc_probe(struct platform_device *pdev)
mod_timer(udc-vbus_timer,
  jiffies + VBUS_POLL_TIMEOUT);
} else {
-   if (request_irq(gpio_to_irq(udc-board.vbus_pin),
-  

[PATCH 03/12] mfd: syscon: Add atmel-smc registers definition

2015-01-14 Thread Alexandre Belloni
From: Boris Brezillon boris.brezil...@free-electrons.com

Atmel AT91 SoCs have a memory range reserved for SMC (Static Memory
Controller) configuration.
Expose those registers so that drivers can make use of the smc syscon
declared in at91 DTs.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Lee Jones lee.jo...@linaro.org
---
 include/linux/mfd/syscon/atmel-smc.h | 173 +++
 1 file changed, 173 insertions(+)
 create mode 100644 include/linux/mfd/syscon/atmel-smc.h

diff --git a/include/linux/mfd/syscon/atmel-smc.h 
b/include/linux/mfd/syscon/atmel-smc.h
new file mode 100644
index ..be6ebe64eebe
--- /dev/null
+++ b/include/linux/mfd/syscon/atmel-smc.h
@@ -0,0 +1,173 @@
+/*
+ * Atmel SMC (Static Memory Controller) register offsets and bit definitions.
+ *
+ * Copyright (C) 2014 Atmel
+ * Copyright (C) 2014 Free Electrons
+ *
+ * Author: Boris Brezillon boris.brezil...@free-electrons.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 _LINUX_MFD_SYSCON_ATMEL_SMC_H_
+#define _LINUX_MFD_SYSCON_ATMEL_SMC_H_
+
+#include linux/kernel.h
+#include linux/regmap.h
+
+#define AT91SAM9_SMC_GENERIC   0x00
+#define AT91SAM9_SMC_GENERIC_BLK_SZ0x10
+
+#define SAMA5_SMC_GENERIC  0x600
+#define SAMA5_SMC_GENERIC_BLK_SZ   0x14
+
+#define AT91SAM9_SMC_SETUP(o)  ((o) + 0x00)
+#define AT91SAM9_SMC_NWESETUP(x)   (x)
+#define AT91SAM9_SMC_NCS_WRSETUP(x)((x)  8)
+#define AT91SAM9_SMC_NRDSETUP(x)   ((x)  16)
+#define AT91SAM9_SMC_NCS_NRDSETUP(x)   ((x)  24)
+
+#define AT91SAM9_SMC_PULSE(o)  ((o) + 0x04)
+#define AT91SAM9_SMC_NWEPULSE(x)   (x)
+#define AT91SAM9_SMC_NCS_WRPULSE(x)((x)  8)
+#define AT91SAM9_SMC_NRDPULSE(x)   ((x)  16)
+#define AT91SAM9_SMC_NCS_NRDPULSE(x)   ((x)  24)
+
+#define AT91SAM9_SMC_CYCLE(o)  ((o) + 0x08)
+#define AT91SAM9_SMC_NWECYCLE(x)   (x)
+#define AT91SAM9_SMC_NRDCYCLE(x)   ((x)  16)
+
+#define AT91SAM9_SMC_MODE(o)   ((o) + 0x0c)
+#define SAMA5_SMC_MODE(o)  ((o) + 0x10)
+#define AT91_SMC_READMODE  BIT(0)
+#define AT91_SMC_READMODE_NCS  (0  0)
+#define AT91_SMC_READMODE_NRD  (1  0)
+#define AT91_SMC_WRITEMODE BIT(1)
+#define AT91_SMC_WRITEMODE_NCS (0  1)
+#define AT91_SMC_WRITEMODE_NWE (1  1)
+#define AT91_SMC_EXNWMODE  GENMASK(5, 4)
+#define AT91_SMC_EXNWMODE_DISABLE  (0  4)
+#define AT91_SMC_EXNWMODE_FROZEN   (2  4)
+#define AT91_SMC_EXNWMODE_READY(3  4)
+#define AT91_SMC_BAT   BIT(8)
+#define AT91_SMC_BAT_SELECT(0  8)
+#define AT91_SMC_BAT_WRITE (1  8)
+#define AT91_SMC_DBW   GENMASK(13, 12)
+#define AT91_SMC_DBW_8 (0  12)
+#define AT91_SMC_DBW_16(1  12)
+#define AT91_SMC_DBW_32(2  12)
+#define AT91_SMC_TDF   GENMASK(19, 16)
+#define AT91_SMC_TDF_(x)   x) - 1)  16)  AT91_SMC_TDF)
+#define AT91_SMC_TDF_MAX   16
+#define AT91_SMC_TDFMODE_OPTIMIZED BIT(20)
+#define AT91_SMC_PMEN  BIT(24)
+#define AT91_SMC_PSGENMASK(29, 28)
+#define AT91_SMC_PS_4  (0  28)
+#define AT91_SMC_PS_8  (1  28)
+#define AT91_SMC_PS_16 (2  28)
+#define AT91_SMC_PS_32 (3  28)
+
+
+/*
+ * This function converts a setup timing expressed in nanoseconds into an
+ * encoded value that can be written in the SMC_SETUP register.
+ *
+ * The following formula is described in atmel datasheets (section
+ * SMC Setup Register):
+ *
+ * setup length = (128* SETUP[5] + SETUP[4:0])
+ *
+ * where setup length is the timing expressed in cycles.
+ */
+static inline u32 at91sam9_smc_setup_ns_to_cycles(unsigned int clk_rate,
+ u32 timing_ns)
+{
+   u32 clk_period = DIV_ROUND_UP(NSEC_PER_SEC, clk_rate);
+   u32 coded_cycles = 0;
+   u32 cycles;
+
+   cycles = DIV_ROUND_UP(timing_ns, clk_period);
+   if (cycles / 32) {
+   coded_cycles |= 1  5;
+   if (cycles  128)
+   cycles = 0;
+   }
+
+   coded_cycles |= cycles % 32;
+
+   return coded_cycles;
+}
+
+/*
+ * This function converts a pulse timing expressed in nanoseconds into an
+ * encoded value that can be written in the SMC_PULSE register.
+ *
+ * The following formula is described in atmel datasheets (section
+ * SMC Pulse Register):
+ *
+ * pulse length = (256* PULSE[6] + PULSE[5:0])
+ *
+ * where pulse length is the timing expressed in cycles.
+ */
+static inline u32 at91sam9_smc_pulse_ns_to_cycles(unsigned int clk_rate,
+ u32 timing_ns)
+{
+

[PATCH 12/12] usb: gadget: at91_udc: Allocate udc instance

2015-01-14 Thread Alexandre Belloni
From: Boris Brezillon boris.brezil...@free-electrons.com

Allocate udc structure instead of relying on the statically declared
object.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 drivers/usb/gadget/udc/at91_udc.c | 96 +++
 1 file changed, 26 insertions(+), 70 deletions(-)

diff --git a/drivers/usb/gadget/udc/at91_udc.c 
b/drivers/usb/gadget/udc/at91_udc.c
index c0abb9bc76a9..6d285226ab94 100644
--- a/drivers/usb/gadget/udc/at91_udc.c
+++ b/drivers/usb/gadget/udc/at91_udc.c
@@ -59,7 +59,15 @@
 #defineDRIVER_VERSION  3 May 2006
 
 static const char driver_name [] = at91_udc;
-static const char ep0name[] = ep0;
+static const char * const ep_names[] = {
+   ep0,
+   ep1,
+   ep2,
+   ep3-int,
+   ep4,
+   ep5,
+};
+#define ep0nameep_names[0]
 
 #define VBUS_POLL_TIMEOUT  msecs_to_jiffies(1000)
 
@@ -1497,74 +1505,6 @@ static irqreturn_t at91_udc_irq (int irq, void *_udc)
 
 /*-*/
 
-static struct at91_udc controller = {
-   .gadget = {
-   .ops= at91_udc_ops,
-   .ep0= controller.ep[0].ep,
-   .name   = driver_name,
-   },
-   .ep[0] = {
-   .ep = {
-   .name   = ep0name,
-   .ops= at91_ep_ops,
-   },
-   .udc= controller,
-   .maxpacket  = 8,
-   .int_mask   = 1  0,
-   },
-   .ep[1] = {
-   .ep = {
-   .name   = ep1,
-   .ops= at91_ep_ops,
-   },
-   .udc= controller,
-   .is_pingpong= 1,
-   .maxpacket  = 64,
-   .int_mask   = 1  1,
-   },
-   .ep[2] = {
-   .ep = {
-   .name   = ep2,
-   .ops= at91_ep_ops,
-   },
-   .udc= controller,
-   .is_pingpong= 1,
-   .maxpacket  = 64,
-   .int_mask   = 1  2,
-   },
-   .ep[3] = {
-   .ep = {
-   /* could actually do bulk too */
-   .name   = ep3-int,
-   .ops= at91_ep_ops,
-   },
-   .udc= controller,
-   .maxpacket  = 8,
-   .int_mask   = 1  3,
-   },
-   .ep[4] = {
-   .ep = {
-   .name   = ep4,
-   .ops= at91_ep_ops,
-   },
-   .udc= controller,
-   .is_pingpong= 1,
-   .maxpacket  = 256,
-   .int_mask   = 1  4,
-   },
-   .ep[5] = {
-   .ep = {
-   .name   = ep5,
-   .ops= at91_ep_ops,
-   },
-   .udc= controller,
-   .is_pingpong= 1,
-   .maxpacket  = 256,
-   .int_mask   = 1  5,
-   },
-   /* ep6 and ep7 are also reserved (custom silicon might use them) */
-};
-
 static void at91_vbus_update(struct at91_udc *udc, unsigned value)
 {
value ^= udc-board.vbus_active_low;
@@ -1872,15 +1812,31 @@ static int at91udc_probe(struct platform_device *pdev)
struct at91_ep  *ep;
int i;
 
+   udc = devm_kzalloc(dev, sizeof(*udc), GFP_KERNEL);
+   if (!udc)
+   return -ENOMEM;
+
/* init software state */
-   udc = controller;
udc-gadget.dev.parent = dev;
at91udc_of_init(udc, pdev-dev.of_node);
udc-pdev = pdev;
udc-enabled = 0;
spin_lock_init(udc-lock);
 
+   udc-gadget.ops = at91_udc_ops;
+   udc-gadget.ep0 = udc-ep[0].ep;
+   udc-gadget.name = driver_name;
+   udc-gadget.dev.init_name = gadget;
 
+   for (i = 0; i  NUM_ENDPOINTS; i++) {
+   ep = udc-ep[i];
+   ep-ep.name = ep_names[i];
+   ep-ep.ops = at91_ep_ops;
+   ep-udc = udc;
+   ep-int_mask = BIT(i);
+   if (i != 0  i != 3)
+   ep-is_pingpong = 1;
+   }
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
udc-udp_baseaddr = devm_ioremap_resource(dev, res);
-- 
2.1.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 11/12] usb: gadget: at91_udc: Update DT binding documentation

2015-01-14 Thread Alexandre Belloni
From: Boris Brezillon boris.brezil...@free-electrons.com

Three compatible strings have been added to the at91_udc driver.
Update the documentation accordingly.

Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
---
 Documentation/devicetree/bindings/usb/atmel-usb.txt | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/usb/atmel-usb.txt 
b/Documentation/devicetree/bindings/usb/atmel-usb.txt
index 6007231e0adc..54a81219caae 100644
--- a/Documentation/devicetree/bindings/usb/atmel-usb.txt
+++ b/Documentation/devicetree/bindings/usb/atmel-usb.txt
@@ -33,7 +33,11 @@ usb1: ehci@0080 {
 AT91 USB device controller
 
 Required properties:
- - compatible: Should be atmel,at91rm9200-udc
+ - compatible: Should be one of the following
+  atmel,at91rm9200-udc
+  atmel,at91sam9260-udc
+  atmel,at91sam9261-udc
+  atmel,at91sam9263-udc
  - 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
-- 
2.1.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 00/12] Atmel matrix, SMC and UDC rework

2015-01-14 Thread Alexandre Belloni
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
  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

 .../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

-- 
2.1.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 08/12] usb: gadget: at91_udc: Remove non-DT handling code

2015-01-14 Thread Alexandre Belloni
On 14/01/2015 at 11:38:12 -0600, Felipe Balbi wrote :
 On Wed, Jan 14, 2015 at 05:22:00PM +0100, Alexandre Belloni wrote:
  From: Boris Brezillon boris.brezil...@free-electrons.com
  
  Since non-DT board support has been removed from the at91 architecture we
  can safely remove non-DT handling code.
  
  Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
  ---
   drivers/usb/gadget/udc/Kconfig|  1 +
   drivers/usb/gadget/udc/at91_udc.c | 16 ++--
   2 files changed, 3 insertions(+), 14 deletions(-)
  
  diff --git a/drivers/usb/gadget/udc/Kconfig b/drivers/usb/gadget/udc/Kconfig
  index b8e213eb36cc..366e551aeff0 100644
  --- a/drivers/usb/gadget/udc/Kconfig
  +++ b/drivers/usb/gadget/udc/Kconfig
  @@ -32,6 +32,7 @@ menu USB Peripheral Controller
   config USB_AT91
  tristate Atmel AT91 USB Device Port
  depends on ARCH_AT91
  +   depends on OF || COMPILE_TEST
 
 will this build with !OF builds ?
 

It should, I'll check but it doesn't matter because it depends on
ARCH_AT91 which selects OF.


-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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/11] usb: gadget: at91_udc: Remove non-DT handling code

2015-01-13 Thread Alexandre Belloni
Hi,

On 13/01/2015 at 10:36:54 -0600, Felipe Balbi wrote :
  I've rebased that patch series but it depends on another one (the mfd:
  syscon: part of memory: add Atmel EBI (External Bus Interface)
  driver) that is not taken yet so applying it now will break the
  build. I still hope to get it merged for 3.20 and I'll resend it as
  soon as possible.
 
 In that case, we either take the entire series through MFD (including
 the gadget patches) or we delay the gadget patches until all
 dependencies have been sorted out.

I would prefer not to miss 3.20, can I resend the patches now so you can
review and ack them? Then they could go through the mfd tree.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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/11] usb: gadget: at91_udc: Remove non-DT handling code

2015-01-12 Thread Alexandre Belloni
Hi Felipe,

I've rebased that patch series but it depends on another one (the mfd:
syscon: part of memory: add Atmel EBI (External Bus Interface) driver)
that is not taken yet so applying it now will break the build. I still
hope to get it merged for 3.20 and I'll resend it as soon as possible.


On 12/01/2015 at 15:39:05 -0600, Felipe Balbi wrote :
 On Wed, Dec 03, 2014 at 12:32:04PM +0100, Boris Brezillon wrote:
  Since non-DT board support has been removed from the at91 architecture we
  can safely remove non-DT handling code.
  
  Signed-off-by: Boris Brezillon boris.brezil...@free-electrons.com
 
 doesn't apply cleanly:
 
 checking file drivers/usb/gadget/udc/Kconfig
 checking file drivers/usb/gadget/udc/at91_udc.c
 Hunk #1 succeeded at 1710 (offset 13 lines).
 Hunk #2 succeeded at 1722 (offset 13 lines).
 Hunk #3 succeeded at 1958 (offset 13 lines).
 Hunk #4 FAILED at 1960.
 1 out of 4 hunks FAILED
 
 please rebase on testing/next which I just pushed.
 
 -- 
 balbi



-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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/5] usb: atmel_usba_udc: Rework errata handling

2015-01-07 Thread Alexandre Belloni
Hi,

The whole series looks good to me, you can add my
Acked-by: Alexandre Belloni alexandre.bell...@free-electrons.com



On 06/01/2015 at 14:46:57 +0100, Boris Brezillon wrote :
 Hello,
 
 Here is a set of patches porting existing at91sam9rl erratum handling to
 DT and adding new code to handle at91sam9g45/9x5 erratum.
 It also adds several compatible strings to differentiate those errata.
 
 These patches should be backported to 3.17 and 3.18 stable releases but
 they do not apply cleanly on those stable branches.
 I'll send a backport of this series once it is merged in mainline.
 
 Regards,
 
 Boris
 
 Changes since v1:
 - cache INT_ENB value to speedup INT_ENB read operations
 
 Boris Brezillon (5):
   usb: atmel_usba_udc: Rework at91sam9rl errata handling
   usb: atmel_usba_udc: Add at91sam9g45 and at91sam9x5 errata handling
   ARM: at91/dt: update udc compatible strings
   usb: atmel_usba_udc: Mask status with enabled irqs
   usb: gadget: atmel_usba: Cache INT_ENB register value
 
  .../devicetree/bindings/usb/atmel-usb.txt  |   5 +-
  arch/arm/boot/dts/at91sam9g45.dtsi |   2 +-
  arch/arm/boot/dts/at91sam9x5.dtsi  |   2 +-
  arch/arm/boot/dts/sama5d3.dtsi |   2 +-
  arch/arm/boot/dts/sama5d4.dtsi |   2 +-
  drivers/usb/gadget/udc/atmel_usba_udc.c| 146 
 +
  drivers/usb/gadget/udc/atmel_usba_udc.h|   9 ++
  7 files changed, 111 insertions(+), 57 deletions(-)
 
 -- 
 1.9.1
 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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: OHCI: ohci-at91: remove unnecessary headers

2014-10-16 Thread Alexandre Belloni
Remove unnecessary mach/* headers to be able to converge to a multiplatform
kernel.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 drivers/usb/host/ohci-at91.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index e49eb4f90f5d..6181549883af 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -24,12 +24,8 @@
 #include linux/usb.h
 #include linux/usb/hcd.h
 
-#include mach/hardware.h
 #include asm/gpio.h
 
-#include mach/cpu.h
-
-
 #include ohci.h
 
 #define valid_port(index)  ((index) = 0  (index)  AT91_MAX_USBH_PORTS)
-- 
1.9.1

--
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-08 Thread Alexandre Belloni
On 08/08/2014 at 11:42:42 +0200, Ronald Wahl wrote :
 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

 ---
 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))
 -- 
 1.9.3
 
 
 ___
 linux-arm-kernel mailing list
 linux-arm-ker...@lists.infradead.org
 http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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: at91_udc: move prepare clk into process context

2014-08-07 Thread Alexandre Belloni
Hi,

For the next revision, please include the changelog after the --- marker
and before the diffstat. Else, this looks good to me, with the same
comment as Boris on the PLLB gating. We will take care of that later.

Regards

On 07/08/2014 at 17:23:58 +0200, Ronald Wahl wrote :
 Hi,
 
 actually this should have been patch v3 and not v2. Anyway, the
 major difference is that I moved setting the clock rate into process
 context as well as it may also sleep.
 
 - ron
 
 On 07.08.2014 17:11, Ronald Wahl wrote:
 Commit 7628083227b6bc4a7e33d7c381d7a4e558424b6b added clock preparation in
 interrupt context. This is not allowed as it might sleep. Move clock
 preparation and setting clock rate into process context (at91udc_probe).
 
 Signed-off-by: Ronald Wahl ronald.w...@raritan.com
 ---
   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))
 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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 07/12] usb: chipidea: add a generic driver

2014-07-01 Thread Alexandre Belloni
On 01/07/2014 at 16:30:08 +0800, Peter Chen wrote :
  Well, there is nothing specific about the Berlin CI. Some subsystems
  use the 'generic' keyword in these cases. Do you see a particular reason
  I should use some Berlin related compatible here?
  
  Not must, one suggestion is: can you change the compatible string
  to chipidea-usb-generic?
  
  I don't know about ChipIdea/ARC/DW's product portfolio but I guess
  the compatible should also carry '2.0' or 'usb2' in it. Or we just
  use some version number like 'chipidea,ci13000' or 'chipidea,ci13xxx'.
  
 
 The recommended format for compatible string is: manufacturer,model,
 I agree with chipidea,ci13xxx, thanks.
 

I think we should probably avoid using wildcards in the compatible
string.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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/9] usb: phy: add the Berlin USB PHY driver

2014-06-09 Thread Alexandre Belloni
On 09/06/2014 at 12:11:57 +0200, Sebastian Hesselbarth wrote :
  Some BG2Q boards hardwired the vbus to be always powered on, we should 
  continue
  the probe if vbus gpio is missing.
 
 Yeah, the same applies for regulators. But with the comments above, it
 should move to the controller stub instead.
 

We should use a regulator and in the case it is hardwired, use a fixed
regulator. Then, we can stop if it is missing.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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: always test udc-driver

2014-05-06 Thread 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
---
 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);
-- 
1.9.1

--
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-03-03 Thread Alexandre Belloni
Hi Felipe,

On 28/02/2014 at 15:35:42 +0100, Nicolas Ferre wrote :
 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/
 

Do you want me to send a v2 with that typo corrected or could you
correct it when applying ?


-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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: atmel_usba: Fix crashed during stopping when DEBUG is enabled

2014-03-03 Thread Alexandre Belloni
On 03/03/2014 at 17:48:34 +0100, Gregory CLEMENT wrote :
 The debug trace in the atmel_usba_stop function made the assumption
 that the driver pointer passed in parameter was not NULL. Since the
 commit usb: gadget: udc-core: fix a regression during gadget driver
 unbinding, it was no more always true. This lead to a kernel crash.
 
 This commit now use the driver pointer stored in udc which fixes this
 issue.
 
 Since the commit which have triggered this issue was backported to the
 3.2 stable branch, then this one should also be backported to the same
 kernel.
 
 Fixes: 511f3c5326ea (usb: gadget: udc-core: fix a regression during gadget 
 driver unbinding)
 Cc: sta...@vger.kernel.org # v3.2+
 Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com

Acked-by: Alexandre Belloni alexandre.bell...@free-electrons.com

 ---
 Changelog:
 v1 - v2
 Fixed the signature block in the commit log
 
  drivers/usb/gadget/atmel_usba_udc.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
 
 diff --git a/drivers/usb/gadget/atmel_usba_udc.c 
 b/drivers/usb/gadget/atmel_usba_udc.c
 index 52771d4c44bc..167843de2d8a 100644
 --- a/drivers/usb/gadget/atmel_usba_udc.c
 +++ b/drivers/usb/gadget/atmel_usba_udc.c
 @@ -1827,12 +1827,12 @@ static int atmel_usba_stop(struct usb_gadget *gadget,
   toggle_bias(0);
   usba_writel(udc, CTRL, USBA_DISABLE_MASK);
  
 - udc-driver = NULL;
 -
   clk_disable_unprepare(udc-hclk);
   clk_disable_unprepare(udc-pclk);
  
 - DBG(DBG_GADGET, unregistered driver `%s'\n, driver-driver.name);
 + DBG(DBG_GADGET, unregistered driver `%s'\n, udc-driver-driver.name);
 +
 + udc-driver = NULL;
  
   return 0;
  }
 -- 
 1.8.1.2
 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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 crashed during stopping when DEBUG is enabled

2014-02-28 Thread Alexandre Belloni
Hi Gregory,

On 28/02/2014 at 15:34:01 +0100, Gregory CLEMENT wrote :
 The debug trace in the atmel_usba_stop function made the assumption
 that the driver pointer passed in parameter was not NULL. Since the
 commit usb: gadget: udc-core: fix a regression during gadget driver
 unbinding, it was no more always true. This lead to a kernel crash.
 
 This commit now use the driver pointer stored in udc which fixes this
 issue.
 
 Since the commit which have triggered this issue was backported to the
 3.2 stable branch, then this one should also be backported to the same
 kernel.
 
 Cc: sta...@vger.kernel.org # v3.2+
 Fixes: 511f3c5326ea (usb: gadget: udc-core: fix a regression during gadget 
 driver unbinding)
 ---
  drivers/usb/gadget/atmel_usba_udc.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
 
 diff --git a/drivers/usb/gadget/atmel_usba_udc.c 
 b/drivers/usb/gadget/atmel_usba_udc.c
 index 52771d4c44bc..167843de2d8a 100644
 --- a/drivers/usb/gadget/atmel_usba_udc.c
 +++ b/drivers/usb/gadget/atmel_usba_udc.c
 @@ -1827,12 +1827,12 @@ static int atmel_usba_stop(struct usb_gadget *gadget,
   toggle_bias(0);
   usba_writel(udc, CTRL, USBA_DISABLE_MASK);
  
 - udc-driver = NULL;
 -
   clk_disable_unprepare(udc-hclk);
   clk_disable_unprepare(udc-pclk);
  
 - DBG(DBG_GADGET, unregistered driver `%s'\n, driver-driver.name);
 + DBG(DBG_GADGET, unregistered driver `%s'\n, udc-driver-driver.name);
 +
 + udc-driver = NULL;

Shouldn't we get rid of that assignment as it is done in
usb_gadget_remove_driver() anyway ?

  
   return 0;
  }
 -- 
 1.8.1.2
 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com


signature.asc
Description: Digital signature


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

2014-02-27 Thread Alexandre Belloni
If no endpoints are present in the device tree, the kernel will cras hwith the
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;
+   }
+
return eps;
 err:
return ERR_PTR(ret);
-- 
1.8.3.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