[PATCH V2] usb: musb: Fix unstable init of OTG_INTERFSEL.

2013-11-28 Thread anaumann
From: Andreas Naumann anaum...@ultratronik.de

This is a hard to reproduce problem which leads to non-functional
USB-OTG port in 0.1%-1% of all boots. Tracked it down to commit
e25bec160158abe86c276d7d206264afc3646281, which introduces save/restore
of OTG_INTERFSEL over suspend.
Since the resume function is also called early in driver init, it uses a
non-initialized value (which is 0 and a non-supported setting in DM37xx
for INTERFSEL). Shortly after the correct value is set. Apparently this
works most time, but not always.

The fix is to initialize the value, BEFORE being written in the resume
function.


Signed-off-by: Andreas Naumann anaum...@ultratronik.de
---
 drivers/usb/musb/omap2430.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 4315d35..783547c 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -337,7 +337,6 @@ static irqreturn_t omap2430_musb_interrupt(int irq, void 
*__hci)
 
 static int omap2430_musb_init(struct musb *musb)
 {
-   u32 l;
int status = 0;
struct device *dev = musb-controller;
struct omap2430_glue *glue = dev_get_drvdata(dev-parent);
@@ -366,23 +365,24 @@ static int omap2430_musb_init(struct musb *musb)
 
musb-isr = omap2430_musb_interrupt;
 
+   musb-context.otg_interfsel = musb_readl(musb-mregs, OTG_INTERFSEL);
+
+   if (data-interface_type == MUSB_INTERFACE_UTMI) {
+   /* OMAP4 uses Internal PHY GS70 which uses UTMI interface */
+   musb-context.otg_interfsel = ~ULPI_12PIN;  /* Disable ULPI */
+   musb-context.otg_interfsel |= UTMI_8BIT;/* Enable UTMI  */
+   } else {
+   musb-context.otg_interfsel |= ULPI_12PIN;
+   }
+
status = pm_runtime_get_sync(dev);
if (status  0) {
dev_err(dev, pm_runtime_get_sync FAILED %d\n, status);
goto err1;
}
 
-   l = musb_readl(musb-mregs, OTG_INTERFSEL);
-
-   if (data-interface_type == MUSB_INTERFACE_UTMI) {
-   /* OMAP4 uses Internal PHY GS70 which uses UTMI interface */
-   l = ~ULPI_12PIN;   /* Disable ULPI */
-   l |= UTMI_8BIT; /* Enable UTMI  */
-   } else {
-   l |= ULPI_12PIN;
-   }
 
-   musb_writel(musb-mregs, OTG_INTERFSEL, l);
+   musb_writel(musb-mregs, OTG_INTERFSEL, musb-context.otg_interfsel);
 
pr_debug(HS USB OTG: revision 0x%x, sysconfig 0x%02x, 
sysstatus 0x%x, intrfsel 0x%x, simenable  0x%x\n,
-- 
1.8.4.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 10/12] usb: r8a66597-hcd: Convert to clk_prepare/unprepare

2013-11-28 Thread Simon Horman
On Tue, Nov 26, 2013 at 03:08:27PM +0100, Laurent Pinchart wrote:
 Hi Greg,
 
 On Monday 25 November 2013 18:36:08 Greg Kroah-Hartman wrote:
  On Tue, Nov 26, 2013 at 03:00:30AM +0100, Laurent Pinchart wrote:
   On Saturday 09 November 2013 08:10:59 Greg Kroah-Hartman wrote:
On Sat, Nov 09, 2013 at 03:12:05PM +0100, Laurent Pinchart wrote:
 On Tuesday 29 October 2013 18:47:26 Shimoda, Yoshihiro wrote:
  Hi Laurent-san,
  
  (2013/10/29 7:49), Laurent Pinchart wrote:
   Turn clk_enable() and clk_disable() calls into
   clk_prepare_enable() and clk_disable_unprepare() to get ready for
   the migration to the common clock framework.
   
   Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
   Cc: Yoshihiro Shimoda yoshihiro.shimoda...@renesas.com
   Cc: linux-usb@vger.kernel.org
   Signed-off-by: Laurent Pinchart
   laurent.pinchart+rene...@ideasonboard.com
  
  Thank you for the patch.
  
  Acked-by: Yoshihiro Shimoda yoshihiro.shimoda...@renesas.com
 
 Could you please pick this patch up ?

I'll pick things up after 3.13-rc1 is out, I can't do anything until
then.
   
   Sure.
   
   As this patch is a dependency for other series that will go through
   different trees, could you please provide a stable branch in your tree
   with this patch included that you will push to v3.14 ?
  
  If you need this for other work, feel free to take it in your tree, I
  have no real need for it to go in mine.
  
  Acked-by: Greg Kroah-Hartman gre...@linuxfoundation.org
 
 Sounds good to me, thanks.
 
 Simon, could you please pick this patch then ?

Sure. I have queued it up.
But I may not push it for a day or two.
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 06/17] clk: at91: add PMC pll clocks

2013-11-28 Thread boris brezillon

Hi Mike,

On 27/11/2013 22:48, Mike Turquette wrote:

Quoting Boris BREZILLON (2013-11-12 13:57:19)

+static const struct clk_ops pll_ops = {
+   .prepare = clk_pll_prepare,
+   .is_prepared = clk_pll_is_ready,
+   .disable = clk_pll_disable,
+   .is_enabled = clk_pll_is_ready,
+   .recalc_rate = clk_pll_recalc_rate,
+   .round_rate = clk_pll_round_rate,
+   .set_rate = clk_pll_set_rate,
+};

Hi Boris,

It is a bit strange to see only a .prepare and .disable callback
populated. What happens if a driver calls clk_disable and then
clk_enable? You clock will still be disabled in hardware.


Oops, I haven't thought about that.
I did this because the clk_pll_disable does not sleep, but this is a big 
mistake :-(.


I'll fix this.

Thanks.

Best Regards,

Boris

Regards,
Mike


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


advertencia

2013-11-28 Thread CORREO
Su contraseña caducará en 3 días formulario llenar y enviar de inmediato para 
validar su dirección de e-mail.
Nombre de Usuario: .
Contraseña anterior: .
Nueva Contraseña: 
gracias
administrador del sistema
--
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: Check device use before detaching?

2013-11-28 Thread Michael Grzeschik
On Mon, Nov 18, 2013 at 08:19:38PM +, Luke-Jr wrote:
 My software does not interface with keyboards under any condition.
 
 Some specific devices I'm working with include:
 FTDI: Avalon, Butterfly Labs BitFORCE  BitFORCE SC, The Chili
 CP210X: Bitfountain Block Erupter Emerald/Sapphire
 CDC/ACM: Big Picture Mining, BTCFPGA ModMiner
 PL2303: Icarus

So you somehow got into a goldrush here! :)

The software will probably be an daemon that will guarantee that thos
gold-diggers are working 24/7? If so, I think the manufacturers of the
devices did choose the wrong interface then.

Regards,
Michael

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
--
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: zte_ev not properly handling ZTE AC2726 CDMA modems

2013-11-28 Thread Johan Hovold
On Wed, Nov 27, 2013 at 11:51:29AM -0500, Alan Stern wrote:
 On Wed, 27 Nov 2013, Johan Hovold wrote:
 
   I am attaching the output that I am getting in the syslog. Note that I 
   have
   two usb modems connected to that router and that's how I am able to debug
   it.
   2-1 is an external USB2.0 hub, 2-1.2 is the ZTE modem, and 2-1.1 is a 
   Huawei
   CDMA modem, which is working fine. The problem happens both with and 
   without
   a hub.
  
  The transmissions are failing with -ENOENT (-2), and the clear tt
  buffer are related to the hub.
  
  Can you get a log from when not using the hub?
  
  Could you try reproducing this on v3.12?
  
  Alan, what do you think of this?
 
 The -ENOENT means that the transfers were cancelled.  Perhaps because
 of a timeout or perhaps for some other reason.
 
 The clear tt buffer lines are merely side effects of the cancelled
 transfers.  Running the test without the external hub ought to
 eliminate them.  It would simplify the test results, so it's worth
 doing.
 
 Also, it might be worthwhile to collect a usbmon trace during the test.  
 The output might be meaningful to somebody who understands how this 
 driver is supposed to work.

Dmitry, first you could try reproducing this with (dynamic) debugging
enabled, for example, echo the following to
/sys/kernel/debug/dynamic_debug/control:

module usbserial +p
func usb_serial_generic_read_bulk_callback -p
func usb_serial_generic_submit_read_urb -p
func usb_serial_debug_data -p
module zte_ev +p

The -ENOENT are likely from an ordinary close of the device. Wasn't
thinking clearly yesterday. :)

Thanks,
Johan
--
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: s3c-hsotg: change dependency to PLAT_SAMSUNG

2013-11-28 Thread Marek Szyprowski

Hello,

On 2013-11-27 18:47, Felipe Balbi wrote:

On Wed, Nov 27, 2013 at 02:03:22PM +0100, Marek Szyprowski wrote:
 On device tree based Samsung SoC platforms (like Exynos) no platform
 devices are defined and CONFIG_S3C_DEV_USB_HSOTG is no longer available,
 so change the driver dependency to more generic and appropriate
 CONFIG_PLAT_SAMSUNG, as the driver can be used on almost all Samsung
 platforms.

 Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
 Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
 ---
  drivers/usb/gadget/Kconfig |2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
 index a91e642..83983ee 100644
 --- a/drivers/usb/gadget/Kconfig
 +++ b/drivers/usb/gadget/Kconfig
 @@ -295,7 +295,7 @@ config USB_PXA27X

  config USB_S3C_HSOTG
tristate S3C HS/OtG USB Device controller
 -  depends on S3C_DEV_USB_HSOTG
 +  depends on PLAT_SAMSUNG

I would rather change this to depends on ARM || COMPILE_TEST, this would
force people to make sure that driver can be used on single zImage
kernels.


FranklyI don't like to see dozens of drivers available for configurations,
which cannot make any use those drivers, but if you like such approach, I
won't mind. Do you want my ack for your proposal?


All you need is the diff below:

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 9875d9c..db797f2 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -36,8 +36,6 @@
  #include linux/usb/phy.h
  #include linux/platform_data/s3c-hsotg.h
  
-#include mach/map.h

-
  #include s3c-hsotg.h
  
  static const char * const s3c_hsotg_supply_names[] = {


Best regards
--
Marek Szyprowski, PhD
Samsung RD Institute Poland

--
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 v6 07/16] clk: at91: add PMC master clock

2013-11-28 Thread Boris BREZILLON
This patch adds new at91 master clock implementation using common clk
framework.

The master clock layout describe the MCKR register layout.
There are 2 master clock layouts:
- at91rm9200
- at91sam9x5

Master clocks are given characteristics:
- min/max clock output rate

These characteristics are checked during rate change to avoid
over/underclocking.

These characteristics are described in atmel's SoC datasheet in
Electrical Characteristics paragraph.

Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com
---
 drivers/clk/at91/Makefile |2 +-
 drivers/clk/at91/clk-master.c |  270 +
 drivers/clk/at91/clk-pll.c|   10 +-
 drivers/clk/at91/pmc.c|9 ++
 drivers/clk/at91/pmc.h|5 +
 5 files changed, 287 insertions(+), 9 deletions(-)
 create mode 100644 drivers/clk/at91/clk-master.c

diff --git a/drivers/clk/at91/Makefile b/drivers/clk/at91/Makefile
index 902bbf1..e28fb2b 100644
--- a/drivers/clk/at91/Makefile
+++ b/drivers/clk/at91/Makefile
@@ -3,4 +3,4 @@
 #
 
 obj-y += pmc.o
-obj-y += clk-main.o clk-pll.o clk-plldiv.o
+obj-y += clk-main.o clk-pll.o clk-plldiv.o clk-master.o
diff --git a/drivers/clk/at91/clk-master.c b/drivers/clk/at91/clk-master.c
new file mode 100644
index 000..bd313f7
--- /dev/null
+++ b/drivers/clk/at91/clk-master.c
@@ -0,0 +1,270 @@
+/*
+ *  Copyright (C) 2013 Boris BREZILLON b.brezil...@overkiz.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include linux/clk-provider.h
+#include linux/clkdev.h
+#include linux/clk/at91_pmc.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/of_irq.h
+#include linux/io.h
+#include linux/wait.h
+#include linux/sched.h
+#include linux/interrupt.h
+#include linux/irq.h
+
+#include pmc.h
+
+#define MASTER_SOURCE_MAX  4
+
+#define MASTER_PRES_MASK   0x7
+#define MASTER_PRES_MAXMASTER_PRES_MASK
+#define MASTER_DIV_SHIFT   8
+#define MASTER_DIV_MASK0x3
+
+struct clk_master_characteristics {
+   struct clk_range output;
+   u32 divisors[4];
+   u8 have_div3_pres;
+};
+
+struct clk_master_layout {
+   u32 mask;
+   u8 pres_shift;
+};
+
+#define to_clk_master(hw) container_of(hw, struct clk_master, hw)
+
+struct clk_master {
+   struct clk_hw hw;
+   struct at91_pmc *pmc;
+   unsigned int irq;
+   wait_queue_head_t wait;
+   const struct clk_master_layout *layout;
+   const struct clk_master_characteristics *characteristics;
+};
+
+static irqreturn_t clk_master_irq_handler(int irq, void *dev_id)
+{
+   struct clk_master *master = (struct clk_master *)dev_id;
+
+   wake_up(master-wait);
+   disable_irq_nosync(master-irq);
+
+   return IRQ_HANDLED;
+}
+static int clk_master_prepare(struct clk_hw *hw)
+{
+   struct clk_master *master = to_clk_master(hw);
+   struct at91_pmc *pmc = master-pmc;
+
+   while (!(pmc_read(pmc, AT91_PMC_SR)  AT91_PMC_MCKRDY)) {
+   enable_irq(master-irq);
+   wait_event(master-wait,
+  pmc_read(pmc, AT91_PMC_SR)  AT91_PMC_MCKRDY);
+   }
+
+   return 0;
+}
+
+static int clk_master_is_prepared(struct clk_hw *hw)
+{
+   struct clk_master *master = to_clk_master(hw);
+
+   return !!(pmc_read(master-pmc, AT91_PMC_SR)  AT91_PMC_MCKRDY);
+}
+
+static unsigned long clk_master_recalc_rate(struct clk_hw *hw,
+   unsigned long parent_rate)
+{
+   u8 pres;
+   u8 div;
+   unsigned long rate = parent_rate;
+   struct clk_master *master = to_clk_master(hw);
+   struct at91_pmc *pmc = master-pmc;
+   const struct clk_master_layout *layout = master-layout;
+   const struct clk_master_characteristics *characteristics =
+   master-characteristics;
+   u32 tmp;
+
+   pmc_lock(pmc);
+   tmp = pmc_read(pmc, AT91_PMC_MCKR)  layout-mask;
+   pmc_unlock(pmc);
+
+   pres = (tmp  layout-pres_shift)  MASTER_PRES_MASK;
+   div = (tmp  MASTER_DIV_SHIFT)  MASTER_DIV_MASK;
+
+   if (characteristics-have_div3_pres  pres == MASTER_PRES_MAX)
+   rate /= 3;
+   else
+   rate = pres;
+
+   rate /= characteristics-divisors[div];
+
+   if (rate  characteristics-output.min)
+   pr_warn(master clk is underclocked);
+   else if (rate  characteristics-output.max)
+   pr_warn(master clk is overclocked);
+
+   return rate;
+}
+
+static u8 clk_master_get_parent(struct clk_hw *hw)
+{
+   struct clk_master *master = to_clk_master(hw);
+   struct at91_pmc *pmc = master-pmc;
+
+   return pmc_read(pmc, AT91_PMC_MCKR)  AT91_PMC_CSS;

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

2013-11-28 Thread Boris BREZILLON
Hello,

This patch series is the 5th version of the at91 clk implementations
using the Common Clk Framework.

Most of the clock provided by the PMC (Power Management Controller) are
implemented :
- main clock (main oscillator)
- pll clocks
- master clock
- programmable clocks
- utmi clock
- peripheral clocks
- system clocks

Actually some clk drivers are missing (slow clk, main clk and processor
clk), and some drivers only implement a subset of the hardware capabilities
(master clk rate change is missing).
But this series implements all the already available clks, and I will hopefully
add missing features in a near future.

This implementation is only compatible with device tree definition.
The goal is to define the whole clock tree using the device tree.

Just a note to let you know these bindings are currently unstable and might
change in the future.


Best Regards,
Boris

Changes since v5:
 - remove peripheral divisors macros from dt binding include file
 - remove file path from comment blocks
 - replace pll and utmi disable function by unprepare function to
   avoid issue when disabling and reenabling a clk
 - fix programmable clk interrupt retrieval
 - fix OF_CLK_DECLARE names (xxx_clk_main - xxx_clk_pmc)
 - add missing comma in at91rm9200 main clk dt declaration
 - fix num_parents check in smd clk driver

Changes since v4:
 - rework dt bindings:
   * replace atmel,clk-id property by the standard reg property
   * reference system, peripheral and programmable clks using the direct
 clk node instead of the parent node plus a clk id
 - provide a new helper function (of_at91_get_clk_range) to retrieve a clk
   range from the device tree

Changes since v3:
 - simplify master clk implementation (drop set_rate/parent support)
 - fix bug in set_rate function of pll driver
 - fix coding style issues
 - define macros and constants where needed
 - remove peripheral id macro references
 - remove sam9g35 specific handling (sam9g35 = sam9x5)
 - rework main clk prepare function to handle automatic rate calculation

Changes since v2:
 - fix several bugs in clk implementations
 - drop non-dt boards support
 - split the series to ease review and tests:
   * 1 patch series for new clk implementations (this series)
   * 1 patch series to move each at91 SoC to common clk framework (coming soon)
 - modify dt-bindings (add atmel,clk- prefix to atmel specific properties)
 - add clk macros for dt-bindings
 - add pmc framework (helper function to access pmc registers)
 - add interrupt support to enable passive wait in clk_prepare functions

Changes since v1:
 - fix bugs in pll, programmable and system clock implementations
   (wrong bit position).
 - add usb clock configuration support (ohci and udc drivers +
   clk_lookup for non dt boards)
 - rework of the system clock interfaces (no need to define a parent clock,
   system clock is a gate with no rate info)
 - change system, peripheral and programmable clk dt bindings (1 master node
   and multiple child nodes each defining a system/peripheral or prog clock)
 - fix bugs in sama5 dt definition

Boris BREZILLON (16):
  ARM: at91: move at91_pmc.h to include/linux/clk/at91_pmc.h
  ARM: at91: add Kconfig options for common clk support
  clk: at91: add PMC base support
  clk: at91: add PMC macro file for dt definitions
  clk: at91: add PMC main clock
  clk: at91: add PMC pll clocks
  clk: at91: add PMC master clock
  clk: at91: add PMC system clocks
  clk: at91: add PMC peripheral clocks
  clk: at91: add PMC programmable clocks
  clk: at91: add PMC utmi clock
  clk: at91: add PMC usb clock
  clk: at91: add PMC smd clock
  dt: binding: add at91 clks dt bindings documentation
  ARM: at91: move pit timer to common clk framework
  ARM: at91: add new compatible strings for pmc driver

 .../devicetree/bindings/clock/at91-clock.txt   |  339 +
 arch/arm/mach-at91/Kconfig |   44 ++
 arch/arm/mach-at91/Kconfig.non_dt  |6 +
 arch/arm/mach-at91/Makefile|2 +-
 arch/arm/mach-at91/at91rm9200.c|2 +-
 arch/arm/mach-at91/at91sam9260.c   |2 +-
 arch/arm/mach-at91/at91sam9261.c   |2 +-
 arch/arm/mach-at91/at91sam9263.c   |2 +-
 arch/arm/mach-at91/at91sam926x_time.c  |   14 +-
 arch/arm/mach-at91/at91sam9g45.c   |2 +-
 arch/arm/mach-at91/at91sam9n12.c   |2 +-
 arch/arm/mach-at91/at91sam9rl.c|2 +-
 arch/arm/mach-at91/at91sam9x5.c|2 +-
 arch/arm/mach-at91/clock.c |7 +-
 arch/arm/mach-at91/generic.h   |3 +-
 arch/arm/mach-at91/pm.c|2 +-
 arch/arm/mach-at91/pm_slowclock.S  |2 +-
 arch/arm/mach-at91/sama5d3.c   |2 +-
 arch/arm/mach-at91/setup.c |8 +-
 drivers/clk/Makefile 

[PATCH v6 06/16] clk: at91: add PMC pll clocks

2013-11-28 Thread Boris BREZILLON
This patch adds new at91 pll clock implementation using common clk framework.

The pll clock layout describe the PLLX register layout.
There are four pll clock layouts:
- at91rm9200
- at91sam9g20
- at91sam9g45
- sama5d3

PLL clocks are given characteristics:
- min/max clock source rate
- ranges of valid clock output rates
- values to set in out and icpll fields for each supported output range

These characteristics are checked during rate change to avoid
over/underclocking.

These characteristics are described in atmel's SoC datasheet in
Electrical Characteristics paragraph.

Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com
---
 drivers/clk/at91/Makefile |2 +-
 drivers/clk/at91/clk-pll.c|  537 +
 drivers/clk/at91/clk-plldiv.c |  135 +++
 drivers/clk/at91/pmc.c|   21 ++
 drivers/clk/at91/pmc.h|   11 +
 include/linux/clk/at91_pmc.h  |2 +
 6 files changed, 707 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/at91/clk-pll.c
 create mode 100644 drivers/clk/at91/clk-plldiv.c

diff --git a/drivers/clk/at91/Makefile b/drivers/clk/at91/Makefile
index 44105bd..902bbf1 100644
--- a/drivers/clk/at91/Makefile
+++ b/drivers/clk/at91/Makefile
@@ -3,4 +3,4 @@
 #
 
 obj-y += pmc.o
-obj-y += clk-main.o
+obj-y += clk-main.o clk-pll.o clk-plldiv.o
diff --git a/drivers/clk/at91/clk-pll.c b/drivers/clk/at91/clk-pll.c
new file mode 100644
index 000..5e23ee4
--- /dev/null
+++ b/drivers/clk/at91/clk-pll.c
@@ -0,0 +1,537 @@
+/*
+ *  Copyright (C) 2013 Boris BREZILLON b.brezil...@overkiz.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include linux/clk-provider.h
+#include linux/clkdev.h
+#include linux/clk/at91_pmc.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/of_irq.h
+#include linux/io.h
+#include linux/wait.h
+#include linux/sched.h
+#include linux/interrupt.h
+#include linux/irq.h
+
+#include pmc.h
+
+#define PLL_STATUS_MASK(id)(1  (1 + (id)))
+#define PLL_REG(id)(AT91_CKGR_PLLAR + ((id) * 4))
+#define PLL_DIV_MASK   0xff
+#define PLL_DIV_MAXPLL_DIV_MASK
+#define PLL_DIV(reg)   ((reg)  PLL_DIV_MASK)
+#define PLL_MUL(reg, layout)   (((reg)  (layout)-mul_shift)  \
+(layout)-mul_mask)
+#define PLL_ICPR_SHIFT(id) ((id) * 16)
+#define PLL_ICPR_MASK(id)  (0x  PLL_ICPR_SHIFT(id))
+#define PLL_MAX_COUNT  0x3ff
+#define PLL_COUNT_SHIFT8
+#define PLL_OUT_SHIFT  14
+#define PLL_MAX_ID 1
+
+struct clk_pll_characteristics {
+   struct clk_range input;
+   int num_output;
+   struct clk_range *output;
+   u16 *icpll;
+   u8 *out;
+};
+
+struct clk_pll_layout {
+   u32 pllr_mask;
+   u16 mul_mask;
+   u8 mul_shift;
+};
+
+#define to_clk_pll(hw) container_of(hw, struct clk_pll, hw)
+
+struct clk_pll {
+   struct clk_hw hw;
+   struct at91_pmc *pmc;
+   unsigned int irq;
+   wait_queue_head_t wait;
+   u8 id;
+   u8 div;
+   u8 range;
+   u16 mul;
+   const struct clk_pll_layout *layout;
+   const struct clk_pll_characteristics *characteristics;
+};
+
+static irqreturn_t clk_pll_irq_handler(int irq, void *dev_id)
+{
+   struct clk_pll *pll = (struct clk_pll *)dev_id;
+
+   wake_up(pll-wait);
+   disable_irq_nosync(pll-irq);
+
+   return IRQ_HANDLED;
+}
+
+static int clk_pll_prepare(struct clk_hw *hw)
+{
+   struct clk_pll *pll = to_clk_pll(hw);
+   struct at91_pmc *pmc = pll-pmc;
+   const struct clk_pll_layout *layout = pll-layout;
+   u8 id = pll-id;
+   u32 mask = PLL_STATUS_MASK(id);
+   int offset = PLL_REG(id);
+   u8 out = 0;
+   u32 pllr, icpr;
+   u8 div;
+   u16 mul;
+
+   pllr = pmc_read(pmc, offset);
+   div = PLL_DIV(pllr);
+   mul = PLL_MUL(pllr, layout);
+
+   if ((pmc_read(pmc, AT91_PMC_SR)  mask) 
+   (div == pll-div  mul == pll-mul))
+   return 0;
+
+   if (characteristics-out)
+   out = characteristics-out[pll-range];
+   if (characteristics-icpll) {
+   icpr = pmc_read(pmc, AT91_PMC_PLLICPR)  ~PLL_ICPR_MASK(id);
+   icpr |= (characteristics-icpll[pll-range] 
+   PLL_ICPR_SHIFT(id));
+   pmc_write(pmc, AT91_PMC_PLLICPR, icpr);
+   }
+
+   pllr = ~layout-pllr_mask;
+   pllr |= layout-pllr_mask 
+  (pll-div | (PLL_MAX_COUNT  PLL_COUNT_SHIFT) |
+   (out  PLL_OUT_SHIFT) |
+   ((pll-mul  layout-mul_mask)  layout-mul_shift));
+   pmc_write(pmc, offset, pllr);
+
+   while (!(pmc_read(pmc, AT91_PMC_SR)  mask)) {
+   

[PATCH v6 05/16] clk: at91: add PMC main clock

2013-11-28 Thread Boris BREZILLON
This patch adds new at91 main oscillator clock implementation using common
clk framework.

If rate is not provided during clock registration it is calculated using
the slow clock (main clk parent in this case) rate and MCFR register.

Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com
---
 drivers/clk/at91/Makefile   |1 +
 drivers/clk/at91/clk-main.c |  187 +++
 drivers/clk/at91/pmc.c  |5 ++
 drivers/clk/at91/pmc.h  |3 +
 4 files changed, 196 insertions(+)
 create mode 100644 drivers/clk/at91/clk-main.c

diff --git a/drivers/clk/at91/Makefile b/drivers/clk/at91/Makefile
index 1d4fb21..44105bd 100644
--- a/drivers/clk/at91/Makefile
+++ b/drivers/clk/at91/Makefile
@@ -3,3 +3,4 @@
 #
 
 obj-y += pmc.o
+obj-y += clk-main.o
diff --git a/drivers/clk/at91/clk-main.c b/drivers/clk/at91/clk-main.c
new file mode 100644
index 000..8e9e8cc
--- /dev/null
+++ b/drivers/clk/at91/clk-main.c
@@ -0,0 +1,187 @@
+/*
+ *  Copyright (C) 2013 Boris BREZILLON b.brezil...@overkiz.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include linux/clk-provider.h
+#include linux/clkdev.h
+#include linux/clk/at91_pmc.h
+#include linux/delay.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/of_irq.h
+#include linux/io.h
+#include linux/interrupt.h
+#include linux/irq.h
+#include linux/sched.h
+#include linux/wait.h
+
+#include pmc.h
+
+#define SLOW_CLOCK_FREQ32768
+#define MAINF_DIV  16
+#define MAINFRDY_TIMEOUT   (((MAINF_DIV + 1) * USEC_PER_SEC) / \
+SLOW_CLOCK_FREQ)
+#define MAINF_LOOP_MIN_WAIT(USEC_PER_SEC / SLOW_CLOCK_FREQ)
+#define MAINF_LOOP_MAX_WAITMAINFRDY_TIMEOUT
+
+struct clk_main {
+   struct clk_hw hw;
+   struct at91_pmc *pmc;
+   unsigned long rate;
+   unsigned int irq;
+   wait_queue_head_t wait;
+};
+
+#define to_clk_main(hw) container_of(hw, struct clk_main, hw)
+
+static irqreturn_t clk_main_irq_handler(int irq, void *dev_id)
+{
+   struct clk_main *clkmain = (struct clk_main *)dev_id;
+
+   wake_up(clkmain-wait);
+   disable_irq_nosync(clkmain-irq);
+
+   return IRQ_HANDLED;
+}
+
+static int clk_main_prepare(struct clk_hw *hw)
+{
+   struct clk_main *clkmain = to_clk_main(hw);
+   struct at91_pmc *pmc = clkmain-pmc;
+   unsigned long halt_time, timeout;
+   u32 tmp;
+
+   while (!(pmc_read(pmc, AT91_PMC_SR)  AT91_PMC_MOSCS)) {
+   enable_irq(clkmain-irq);
+   wait_event(clkmain-wait,
+  pmc_read(pmc, AT91_PMC_SR)  AT91_PMC_MOSCS);
+   }
+
+   if (clkmain-rate)
+   return 0;
+
+   timeout = jiffies + usecs_to_jiffies(MAINFRDY_TIMEOUT);
+   do {
+   halt_time = jiffies;
+   tmp = pmc_read(pmc, AT91_CKGR_MCFR);
+   if (tmp  AT91_PMC_MAINRDY)
+   return 0;
+   usleep_range(MAINF_LOOP_MIN_WAIT, MAINF_LOOP_MAX_WAIT);
+   } while (time_before(halt_time, timeout));
+
+   return 0;
+}
+
+static int clk_main_is_prepared(struct clk_hw *hw)
+{
+   struct clk_main *clkmain = to_clk_main(hw);
+
+   return !!(pmc_read(clkmain-pmc, AT91_PMC_SR)  AT91_PMC_MOSCS);
+}
+
+static unsigned long clk_main_recalc_rate(struct clk_hw *hw,
+ unsigned long parent_rate)
+{
+   u32 tmp;
+   struct clk_main *clkmain = to_clk_main(hw);
+   struct at91_pmc *pmc = clkmain-pmc;
+
+   if (clkmain-rate)
+   return clkmain-rate;
+
+   tmp = pmc_read(pmc, AT91_CKGR_MCFR)  AT91_PMC_MAINF;
+   clkmain-rate = (tmp * parent_rate) / MAINF_DIV;
+
+   return clkmain-rate;
+}
+
+static const struct clk_ops main_ops = {
+   .prepare = clk_main_prepare,
+   .is_prepared = clk_main_is_prepared,
+   .recalc_rate = clk_main_recalc_rate,
+};
+
+static struct clk * __init
+at91_clk_register_main(struct at91_pmc *pmc,
+  unsigned int irq,
+  const char *name,
+  const char *parent_name,
+  unsigned long rate)
+{
+   int ret;
+   struct clk_main *clkmain;
+   struct clk *clk = NULL;
+   struct clk_init_data init;
+
+   if (!pmc || !irq || !name)
+   return ERR_PTR(-EINVAL);
+
+   if (!rate  !parent_name)
+   return ERR_PTR(-EINVAL);
+
+   clkmain = kzalloc(sizeof(*clkmain), GFP_KERNEL);
+   if (!clkmain)
+   return ERR_PTR(-ENOMEM);
+
+   init.name = name;
+   init.ops = main_ops;
+   init.parent_names = parent_name ? parent_name : NULL;
+   init.num_parents = parent_name ? 1 : 0;
+

[PATCH v6 03/16] clk: at91: add PMC base support

2013-11-28 Thread Boris BREZILLON
This patch adds at91 PMC (Power Management Controller) base support.

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

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

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

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

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

Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com
---
 drivers/clk/Makefile  |1 +
 drivers/clk/at91/Makefile |5 +
 drivers/clk/at91/pmc.c|  304 +
 drivers/clk/at91/pmc.h|   61 +
 4 files changed, 371 insertions(+)
 create mode 100644 drivers/clk/at91/Makefile
 create mode 100644 drivers/clk/at91/pmc.c
 create mode 100644 drivers/clk/at91/pmc.h

diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 7b11106..28c2678 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -32,6 +32,7 @@ obj-$(CONFIG_ARCH_VT8500) += clk-vt8500.o
 obj-$(CONFIG_ARCH_ZYNQ)+= zynq/
 obj-$(CONFIG_ARCH_TEGRA)   += tegra/
 obj-$(CONFIG_PLAT_SAMSUNG) += samsung/
+obj-$(CONFIG_COMMON_CLK_AT91)  += at91/
 
 obj-$(CONFIG_X86)  += x86/
 
diff --git a/drivers/clk/at91/Makefile b/drivers/clk/at91/Makefile
new file mode 100644
index 000..1d4fb21
--- /dev/null
+++ b/drivers/clk/at91/Makefile
@@ -0,0 +1,5 @@
+#
+# Makefile for at91 specific clk
+#
+
+obj-y += pmc.o
diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
new file mode 100644
index 000..69c116a
--- /dev/null
+++ b/drivers/clk/at91/pmc.c
@@ -0,0 +1,304 @@
+/*
+ *  Copyright (C) 2013 Boris BREZILLON b.brezil...@overkiz.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include linux/clk-provider.h
+#include linux/clkdev.h
+#include linux/clk/at91_pmc.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/io.h
+#include linux/interrupt.h
+#include linux/irq.h
+#include linux/irqchip/chained_irq.h
+#include linux/irqdomain.h
+#include linux/of_irq.h
+
+#include asm/proc-fns.h
+
+#include pmc.h
+
+void __iomem *at91_pmc_base;
+EXPORT_SYMBOL_GPL(at91_pmc_base);
+
+void at91sam9_idle(void)
+{
+   at91_pmc_write(AT91_PMC_SCDR, AT91_PMC_PCK);
+   cpu_do_idle();
+}
+
+int of_at91_get_clk_range(struct device_node *np, const char *propname,
+ struct clk_range *range)
+{
+   u32 min, max;
+   int ret;
+
+   ret = of_property_read_u32_index(np, propname, 0, min);
+   if (ret)
+   return ret;
+
+   ret = of_property_read_u32_index(np, propname, 1, max);
+   if (ret)
+   return ret;
+
+   if (range) {
+   range-min = min;
+   range-max = max;
+   }
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(of_at91_get_clk_range);
+
+static void pmc_irq_mask(struct irq_data *d)
+{
+   struct at91_pmc *pmc = irq_data_get_irq_chip_data(d);
+
+   pmc_write(pmc, AT91_PMC_IDR, 1  d-hwirq);
+}
+
+static void pmc_irq_unmask(struct irq_data *d)
+{
+   struct at91_pmc *pmc = irq_data_get_irq_chip_data(d);
+
+   pmc_write(pmc, AT91_PMC_IER, 1  d-hwirq);
+}
+
+static int pmc_irq_set_type(struct irq_data *d, unsigned type)
+{
+   if (type != IRQ_TYPE_LEVEL_HIGH) {
+   pr_warn(PMC: type not supported (support only 
IRQ_TYPE_LEVEL_HIGH type)\n);
+   return -EINVAL;
+   }
+
+   return 0;
+}
+
+static struct irq_chip pmc_irq = {
+   .name = PMC,
+   .irq_disable = pmc_irq_mask,
+   .irq_mask = pmc_irq_mask,
+   .irq_unmask = pmc_irq_unmask,
+   .irq_set_type = pmc_irq_set_type,
+};
+
+static struct lock_class_key pmc_lock_class;
+
+static int pmc_irq_map(struct irq_domain *h, unsigned int virq,
+  irq_hw_number_t hw)
+{
+   struct at91_pmc *pmc = h-host_data;
+
+   irq_set_lockdep_class(virq, pmc_lock_class);
+
+   irq_set_chip_and_handler(virq, pmc_irq,
+handle_level_irq);
+   

[PATCH v6 01/16] ARM: at91: move at91_pmc.h to include/linux/clk/at91_pmc.h

2013-11-28 Thread Boris BREZILLON
This patch moves at91_pmc.h header from machine specific directory
(arch/arm/mach-at91/include/mach/at91_pmc.h) to clk include directory
(include/linux/clk/at91_pmc.h).
We need this to avoid reference to machine specific headers in clk
drivers.

Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com
Acked-by: Felipe Balbi ba...@ti.com
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com
---
 arch/arm/mach-at91/at91rm9200.c|2 +-
 arch/arm/mach-at91/at91sam9260.c   |2 +-
 arch/arm/mach-at91/at91sam9261.c   |2 +-
 arch/arm/mach-at91/at91sam9263.c   |2 +-
 arch/arm/mach-at91/at91sam9g45.c   |2 +-
 arch/arm/mach-at91/at91sam9n12.c   |2 +-
 arch/arm/mach-at91/at91sam9rl.c|2 +-
 arch/arm/mach-at91/at91sam9x5.c|2 +-
 arch/arm/mach-at91/clock.c |2 +-
 arch/arm/mach-at91/pm.c|2 +-
 arch/arm/mach-at91/pm_slowclock.S  |2 +-
 arch/arm/mach-at91/sama5d3.c   |2 +-
 arch/arm/mach-at91/setup.c |2 +-
 drivers/usb/gadget/atmel_usba_udc.c|2 +-
 .../include/mach = include/linux/clk}/at91_pmc.h  |2 +-
 15 files changed, 15 insertions(+), 15 deletions(-)
 rename {arch/arm/mach-at91/include/mach = include/linux/clk}/at91_pmc.h (99%)

diff --git a/arch/arm/mach-at91/at91rm9200.c b/arch/arm/mach-at91/at91rm9200.c
index 4aad93d..102dac6 100644
--- a/arch/arm/mach-at91/at91rm9200.c
+++ b/arch/arm/mach-at91/at91rm9200.c
@@ -12,13 +12,13 @@
 
 #include linux/module.h
 #include linux/reboot.h
+#include linux/clk/at91_pmc.h
 
 #include asm/irq.h
 #include asm/mach/arch.h
 #include asm/mach/map.h
 #include asm/system_misc.h
 #include mach/at91rm9200.h
-#include mach/at91_pmc.h
 #include mach/at91_st.h
 #include mach/cpu.h
 
diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c
index 5de6074..16d7817 100644
--- a/arch/arm/mach-at91/at91sam9260.c
+++ b/arch/arm/mach-at91/at91sam9260.c
@@ -11,6 +11,7 @@
  */
 
 #include linux/module.h
+#include linux/clk/at91_pmc.h
 
 #include asm/proc-fns.h
 #include asm/irq.h
@@ -20,7 +21,6 @@
 #include mach/cpu.h
 #include mach/at91_dbgu.h
 #include mach/at91sam9260.h
-#include mach/at91_pmc.h
 
 #include at91_aic.h
 #include at91_rstc.h
diff --git a/arch/arm/mach-at91/at91sam9261.c b/arch/arm/mach-at91/at91sam9261.c
index 0e07932..c8f5958 100644
--- a/arch/arm/mach-at91/at91sam9261.c
+++ b/arch/arm/mach-at91/at91sam9261.c
@@ -11,6 +11,7 @@
  */
 
 #include linux/module.h
+#include linux/clk/at91_pmc.h
 
 #include asm/proc-fns.h
 #include asm/irq.h
@@ -19,7 +20,6 @@
 #include asm/system_misc.h
 #include mach/cpu.h
 #include mach/at91sam9261.h
-#include mach/at91_pmc.h
 
 #include at91_aic.h
 #include at91_rstc.h
diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c
index 6ce7d18..cd8ad95 100644
--- a/arch/arm/mach-at91/at91sam9263.c
+++ b/arch/arm/mach-at91/at91sam9263.c
@@ -11,6 +11,7 @@
  */
 
 #include linux/module.h
+#include linux/clk/at91_pmc.h
 
 #include asm/proc-fns.h
 #include asm/irq.h
@@ -18,7 +19,6 @@
 #include asm/mach/map.h
 #include asm/system_misc.h
 #include mach/at91sam9263.h
-#include mach/at91_pmc.h
 
 #include at91_aic.h
 #include at91_rstc.h
diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c
index 474ee04..9794b20 100644
--- a/arch/arm/mach-at91/at91sam9g45.c
+++ b/arch/arm/mach-at91/at91sam9g45.c
@@ -12,13 +12,13 @@
 
 #include linux/module.h
 #include linux/dma-mapping.h
+#include linux/clk/at91_pmc.h
 
 #include asm/irq.h
 #include asm/mach/arch.h
 #include asm/mach/map.h
 #include asm/system_misc.h
 #include mach/at91sam9g45.h
-#include mach/at91_pmc.h
 #include mach/cpu.h
 
 #include at91_aic.h
diff --git a/arch/arm/mach-at91/at91sam9n12.c b/arch/arm/mach-at91/at91sam9n12.c
index 2d895a2..deafab2 100644
--- a/arch/arm/mach-at91/at91sam9n12.c
+++ b/arch/arm/mach-at91/at91sam9n12.c
@@ -8,12 +8,12 @@
 
 #include linux/module.h
 #include linux/dma-mapping.h
+#include linux/clk/at91_pmc.h
 
 #include asm/irq.h
 #include asm/mach/arch.h
 #include asm/mach/map.h
 #include mach/at91sam9n12.h
-#include mach/at91_pmc.h
 #include mach/cpu.h
 
 #include board.h
diff --git a/arch/arm/mach-at91/at91sam9rl.c b/arch/arm/mach-at91/at91sam9rl.c
index d4ec0d9..947da95 100644
--- a/arch/arm/mach-at91/at91sam9rl.c
+++ b/arch/arm/mach-at91/at91sam9rl.c
@@ -10,6 +10,7 @@
  */
 
 #include linux/module.h
+#include linux/clk/at91_pmc.h
 
 #include asm/proc-fns.h
 #include asm/irq.h
@@ -19,7 +20,6 @@
 #include mach/cpu.h
 #include mach/at91_dbgu.h
 #include mach/at91sam9rl.h
-#include mach/at91_pmc.h
 
 #include at91_aic.h
 #include at91_rstc.h
diff --git a/arch/arm/mach-at91/at91sam9x5.c b/arch/arm/mach-at91/at91sam9x5.c
index 916e5a1..a930d73 100644
--- a/arch/arm/mach-at91/at91sam9x5.c
+++ 

[PATCH v6 08/16] clk: at91: add PMC system clocks

2013-11-28 Thread Boris BREZILLON
This patch adds new at91 system clock implementation using common clk
framework.

Some peripherals need to enable a system clock in order to work properly.
Each system clock is given an id based on the bit position in SCER/SCDR
registers.

Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com
---
 drivers/clk/at91/Makefile |1 +
 drivers/clk/at91/clk-system.c |  135 +
 drivers/clk/at91/pmc.c|5 ++
 drivers/clk/at91/pmc.h|3 +
 4 files changed, 144 insertions(+)
 create mode 100644 drivers/clk/at91/clk-system.c

diff --git a/drivers/clk/at91/Makefile b/drivers/clk/at91/Makefile
index e28fb2b..c2b7068 100644
--- a/drivers/clk/at91/Makefile
+++ b/drivers/clk/at91/Makefile
@@ -4,3 +4,4 @@
 
 obj-y += pmc.o
 obj-y += clk-main.o clk-pll.o clk-plldiv.o clk-master.o
+obj-y += clk-system.o
diff --git a/drivers/clk/at91/clk-system.c b/drivers/clk/at91/clk-system.c
new file mode 100644
index 000..8f7c043
--- /dev/null
+++ b/drivers/clk/at91/clk-system.c
@@ -0,0 +1,135 @@
+/*
+ *  Copyright (C) 2013 Boris BREZILLON b.brezil...@overkiz.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include linux/clk-provider.h
+#include linux/clkdev.h
+#include linux/clk/at91_pmc.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/io.h
+
+#include pmc.h
+
+#define SYSTEM_MAX_ID  31
+
+#define SYSTEM_MAX_NAME_SZ 32
+
+#define to_clk_system(hw) container_of(hw, struct clk_system, hw)
+struct clk_system {
+   struct clk_hw hw;
+   struct at91_pmc *pmc;
+   u8 id;
+};
+
+static int clk_system_enable(struct clk_hw *hw)
+{
+   struct clk_system *sys = to_clk_system(hw);
+   struct at91_pmc *pmc = sys-pmc;
+
+   pmc_write(pmc, AT91_PMC_SCER, 1  sys-id);
+   return 0;
+}
+
+static void clk_system_disable(struct clk_hw *hw)
+{
+   struct clk_system *sys = to_clk_system(hw);
+   struct at91_pmc *pmc = sys-pmc;
+
+   pmc_write(pmc, AT91_PMC_SCDR, 1  sys-id);
+}
+
+static int clk_system_is_enabled(struct clk_hw *hw)
+{
+   struct clk_system *sys = to_clk_system(hw);
+   struct at91_pmc *pmc = sys-pmc;
+
+   return !!(pmc_read(pmc, AT91_PMC_SCSR)  (1  sys-id));
+}
+
+static const struct clk_ops system_ops = {
+   .enable = clk_system_enable,
+   .disable = clk_system_disable,
+   .is_enabled = clk_system_is_enabled,
+};
+
+static struct clk * __init
+at91_clk_register_system(struct at91_pmc *pmc, const char *name,
+const char *parent_name, u8 id)
+{
+   struct clk_system *sys;
+   struct clk *clk = NULL;
+   struct clk_init_data init;
+
+   if (!parent_name || id  SYSTEM_MAX_ID)
+   return ERR_PTR(-EINVAL);
+
+   sys = kzalloc(sizeof(*sys), GFP_KERNEL);
+   if (!sys)
+   return ERR_PTR(-ENOMEM);
+
+   init.name = name;
+   init.ops = system_ops;
+   init.parent_names = parent_name;
+   init.num_parents = 1;
+   /*
+* CLK_IGNORE_UNUSED is used to avoid ddrck switch off.
+* TODO : we should implement a driver supporting at91 ddr controller
+* (see drivers/memory) which would request and enable the ddrck clock.
+* When this is done we will be able to remove CLK_IGNORE_UNUSED flag.
+*/
+   init.flags = CLK_IGNORE_UNUSED;
+
+   sys-id = id;
+   sys-hw.init = init;
+   sys-pmc = pmc;
+
+   clk = clk_register(NULL, sys-hw);
+   if (IS_ERR(clk))
+   kfree(sys);
+
+   return clk;
+}
+
+static void __init
+of_at91_clk_sys_setup(struct device_node *np, struct at91_pmc *pmc)
+{
+   int num;
+   u32 id;
+   struct clk *clk;
+   const char *name;
+   struct device_node *sysclknp;
+   const char *parent_name;
+
+   num = of_get_child_count(np);
+   if (num  (SYSTEM_MAX_ID + 1))
+   return;
+
+   for_each_child_of_node(np, sysclknp) {
+   if (of_property_read_u32(sysclknp, reg, id))
+   continue;
+
+   if (of_property_read_string(np, clock-output-names, name))
+   name = sysclknp-name;
+
+   parent_name = of_clk_get_parent_name(sysclknp, 0);
+
+   clk = at91_clk_register_system(pmc, name, parent_name, id);
+   if (IS_ERR(clk))
+   continue;
+
+   of_clk_add_provider(sysclknp, of_clk_src_simple_get, clk);
+   }
+}
+
+void __init of_at91rm9200_clk_sys_setup(struct device_node *np,
+   struct at91_pmc *pmc)
+{
+   of_at91_clk_sys_setup(np, pmc);
+}
diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
index a311cf3..a97554f 100644
--- 

[PATCH v6 09/16] clk: at91: add PMC peripheral clocks

2013-11-28 Thread Boris BREZILLON
This patch adds new at91 peripheral clock implementation using common clk
framework.

Almost all peripherals provided by at91 SoCs need a clock to work properly.
This clock is enabled/disabled using PCER/PCDR resgisters.

Each peripheral is given an id (see atmel's datasheets) which is used to
define and reference peripheral clocks.

Some new SoCs (at91sam9x5 and sama5d3) provide a new register (PCR) where you
can configure the peripheral clock as a division of the master clock.
This will help reducing the peripherals power comsumption.

Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com
---
 drivers/clk/at91/Makefile |2 +-
 drivers/clk/at91/clk-peripheral.c |  410 +
 drivers/clk/at91/pmc.c|9 +
 drivers/clk/at91/pmc.h|5 +
 4 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/at91/clk-peripheral.c

diff --git a/drivers/clk/at91/Makefile b/drivers/clk/at91/Makefile
index c2b7068..04deba3 100644
--- a/drivers/clk/at91/Makefile
+++ b/drivers/clk/at91/Makefile
@@ -4,4 +4,4 @@
 
 obj-y += pmc.o
 obj-y += clk-main.o clk-pll.o clk-plldiv.o clk-master.o
-obj-y += clk-system.o
+obj-y += clk-system.o clk-peripheral.o
diff --git a/drivers/clk/at91/clk-peripheral.c 
b/drivers/clk/at91/clk-peripheral.c
new file mode 100644
index 000..597fed4
--- /dev/null
+++ b/drivers/clk/at91/clk-peripheral.c
@@ -0,0 +1,410 @@
+/*
+ *  Copyright (C) 2013 Boris BREZILLON b.brezil...@overkiz.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include linux/clk-provider.h
+#include linux/clkdev.h
+#include linux/clk/at91_pmc.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/io.h
+
+#include pmc.h
+
+#define PERIPHERAL_MAX 64
+
+#define PERIPHERAL_AT91RM9200  0
+#define PERIPHERAL_AT91SAM9X5  1
+
+#define PERIPHERAL_ID_MIN  2
+#define PERIPHERAL_ID_MAX  31
+#define PERIPHERAL_MASK(id)(1  ((id)  PERIPHERAL_ID_MAX))
+
+#define PERIPHERAL_RSHIFT_MASK 0x3
+#define PERIPHERAL_RSHIFT(val) (((val)  16)  PERIPHERAL_RSHIFT_MASK)
+
+#define PERIPHERAL_MAX_SHIFT   4
+
+struct clk_peripheral {
+   struct clk_hw hw;
+   struct at91_pmc *pmc;
+   u32 id;
+};
+
+#define to_clk_peripheral(hw) container_of(hw, struct clk_peripheral, hw)
+
+struct clk_sam9x5_peripheral {
+   struct clk_hw hw;
+   struct at91_pmc *pmc;
+   struct clk_range range;
+   u32 id;
+   u32 div;
+   bool auto_div;
+};
+
+#define to_clk_sam9x5_peripheral(hw) \
+   container_of(hw, struct clk_sam9x5_peripheral, hw)
+
+static int clk_peripheral_enable(struct clk_hw *hw)
+{
+   struct clk_peripheral *periph = to_clk_peripheral(hw);
+   struct at91_pmc *pmc = periph-pmc;
+   int offset = AT91_PMC_PCER;
+   u32 id = periph-id;
+
+   if (id  PERIPHERAL_ID_MIN)
+   return 0;
+   if (id  PERIPHERAL_ID_MAX)
+   offset = AT91_PMC_PCER1;
+   pmc_write(pmc, offset, PERIPHERAL_MASK(id));
+   return 0;
+}
+
+static void clk_peripheral_disable(struct clk_hw *hw)
+{
+   struct clk_peripheral *periph = to_clk_peripheral(hw);
+   struct at91_pmc *pmc = periph-pmc;
+   int offset = AT91_PMC_PCDR;
+   u32 id = periph-id;
+
+   if (id  PERIPHERAL_ID_MIN)
+   return;
+   if (id  PERIPHERAL_ID_MAX)
+   offset = AT91_PMC_PCDR1;
+   pmc_write(pmc, offset, PERIPHERAL_MASK(id));
+}
+
+static int clk_peripheral_is_enabled(struct clk_hw *hw)
+{
+   struct clk_peripheral *periph = to_clk_peripheral(hw);
+   struct at91_pmc *pmc = periph-pmc;
+   int offset = AT91_PMC_PCSR;
+   u32 id = periph-id;
+
+   if (id  PERIPHERAL_ID_MIN)
+   return 1;
+   if (id  PERIPHERAL_ID_MAX)
+   offset = AT91_PMC_PCSR1;
+   return !!(pmc_read(pmc, offset)  PERIPHERAL_MASK(id));
+}
+
+static const struct clk_ops peripheral_ops = {
+   .enable = clk_peripheral_enable,
+   .disable = clk_peripheral_disable,
+   .is_enabled = clk_peripheral_is_enabled,
+};
+
+static struct clk * __init
+at91_clk_register_peripheral(struct at91_pmc *pmc, const char *name,
+const char *parent_name, u32 id)
+{
+   struct clk_peripheral *periph;
+   struct clk *clk = NULL;
+   struct clk_init_data init;
+
+   if (!pmc || !name || !parent_name || id  PERIPHERAL_ID_MAX)
+   return ERR_PTR(-EINVAL);
+
+   periph = kzalloc(sizeof(*periph), GFP_KERNEL);
+   if (!periph)
+   return ERR_PTR(-ENOMEM);
+
+   init.name = name;
+   init.ops = peripheral_ops;
+   init.parent_names = (parent_name ? parent_name : NULL);
+   init.num_parents = 

[PATCH v6 02/16] ARM: at91: add Kconfig options for common clk support

2013-11-28 Thread Boris BREZILLON
This patch adds the following Kconfig options to prepare the transition to
common clk framework:

- AT91_USE_OLD_CLK: this option is selected by every SoC which does not
  support new at91 clks based on common clk framework (SoC which does not
  define the clock tree in its device tree).
  This options is also selected when the user choose non dt boards support
  (new at91 clks can only be registered from a device tree definition).

- COMMON_CLK_AT91: this option cannot be selected directly. Instead it is
  enabled if these 3 conditions are met:
   * at least one of the selected SoCs have a PMC (Power Management
 Controller) Unit
   * device tree support is enabled
   * the old at91 clk implementation is disabled (every selected SoC define
 its clks in its device tree and non dt boards support is disabled)

- OLD_CLK_AT91: this option cannot be selected directly. Instead it is
  enabled if these 2 conditions are met:
   * at least one of the selected SoCs have a PMC (Power Management
 Controller) Unit
   * at least one of the selected SoCs does not define its clks in its
 device tree or non dt-boards support is enabled

This patch selects AT91_USE_OLD_CLK in all currently supported SoCs. These
selects will be removed after clk definitions are properly added in each
soc's device tree.
It also selects AT91_USE_OLD_CLK in all non-dt boards support.

AT91_PMC_UNIT references are replaced by OLD_CLK_AT91, because PMC Unit is
enabled for both old and common clk implementations, and old clk
implementation should not be compiled if COMMON_CLK is enabled.

To avoid future link errors, a new stub is created for at91_dt_clock_init
function if OLD_CLK_AT91 is disabled.

A new check is added in dt init functions (setup.c) to prepare for SoCs
supporting new clk implementation. These SoCs won't setup the
register_clocks callback (clk registration is done using of_clk_init).

Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com
---
 arch/arm/mach-at91/Kconfig|   21 +
 arch/arm/mach-at91/Kconfig.non_dt |6 ++
 arch/arm/mach-at91/Makefile   |2 +-
 arch/arm/mach-at91/generic.h  |3 ++-
 arch/arm/mach-at91/setup.c|6 --
 5 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 699b71e..85b53a4 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -6,10 +6,22 @@ config HAVE_AT91_DBGU0
 config HAVE_AT91_DBGU1
bool
 
+config AT91_USE_OLD_CLK
+   bool
+
 config AT91_PMC_UNIT
bool
default !ARCH_AT91X40
 
+config COMMON_CLK_AT91
+   bool
+   default AT91_PMC_UNIT  USE_OF  !AT91_USE_OLD_CLK
+   select COMMON_CLK
+
+config OLD_CLK_AT91
+   bool
+   default AT91_PMC_UNIT  AT91_USE_OLD_CLK
+
 config AT91_SAM9_ALT_RESET
bool
default !ARCH_AT91X40
@@ -65,6 +77,7 @@ config SOC_SAMA5D3
select SOC_SAMA5
select HAVE_FB_ATMEL
select HAVE_AT91_DBGU1
+   select AT91_USE_OLD_CLK
help
  Select this if you are using one of Atmel's SAMA5D3 family SoC.
  This support covers SAMA5D31, SAMA5D33, SAMA5D34, SAMA5D35.
@@ -78,11 +91,13 @@ config SOC_AT91RM9200
select HAVE_AT91_DBGU0
select MULTI_IRQ_HANDLER
select SPARSE_IRQ
+   select AT91_USE_OLD_CLK
 
 config SOC_AT91SAM9260
bool AT91SAM9260, AT91SAM9XE or AT91SAM9G20
select HAVE_AT91_DBGU0
select SOC_AT91SAM9
+   select AT91_USE_OLD_CLK
help
  Select this if you are using one of Atmel's AT91SAM9260, AT91SAM9XE
  or AT91SAM9G20 SoC.
@@ -92,6 +107,7 @@ config SOC_AT91SAM9261
select HAVE_AT91_DBGU0
select HAVE_FB_ATMEL
select SOC_AT91SAM9
+   select AT91_USE_OLD_CLK
help
  Select this if you are using one of Atmel's AT91SAM9261 or 
AT91SAM9G10 SoC.
 
@@ -100,18 +116,21 @@ config SOC_AT91SAM9263
select HAVE_AT91_DBGU1
select HAVE_FB_ATMEL
select SOC_AT91SAM9
+   select AT91_USE_OLD_CLK
 
 config SOC_AT91SAM9RL
bool AT91SAM9RL
select HAVE_AT91_DBGU0
select HAVE_FB_ATMEL
select SOC_AT91SAM9
+   select AT91_USE_OLD_CLK
 
 config SOC_AT91SAM9G45
bool AT91SAM9G45 or AT91SAM9M10 families
select HAVE_AT91_DBGU1
select HAVE_FB_ATMEL
select SOC_AT91SAM9
+   select AT91_USE_OLD_CLK
help
  Select this if you are using one of Atmel's AT91SAM9G45 family SoC.
  This support covers AT91SAM9G45, AT91SAM9G46, AT91SAM9M10 and 
AT91SAM9M11.
@@ -121,6 +140,7 @@ config SOC_AT91SAM9X5
select HAVE_AT91_DBGU0
select HAVE_FB_ATMEL
select SOC_AT91SAM9
+   select AT91_USE_OLD_CLK
help
  Select this if you are using one of Atmel's AT91SAM9x5 family SoC.
  This means that your SAM9 name finishes with a '5' 

[PATCH v6 11/16] clk: at91: add PMC utmi clock

2013-11-28 Thread Boris BREZILLON
This adds new at91 utmi clock implementation using common clk framework.

This clock is a pll with a fixed factor (x40).
It is used as a source for usb clock.

Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com
---
 arch/arm/mach-at91/Kconfig  |7 ++
 drivers/clk/at91/Makefile   |1 +
 drivers/clk/at91/clk-utmi.c |  159 +++
 drivers/clk/at91/pmc.c  |7 ++
 drivers/clk/at91/pmc.h  |5 ++
 5 files changed, 179 insertions(+)
 create mode 100644 drivers/clk/at91/clk-utmi.c

diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 85b53a4..6ad37da 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -1,5 +1,8 @@
 if ARCH_AT91
 
+config HAVE_AT91_UTMI
+   bool
+
 config HAVE_AT91_DBGU0
bool
 
@@ -78,6 +81,7 @@ config SOC_SAMA5D3
select HAVE_FB_ATMEL
select HAVE_AT91_DBGU1
select AT91_USE_OLD_CLK
+   select HAVE_AT91_UTMI
help
  Select this if you are using one of Atmel's SAMA5D3 family SoC.
  This support covers SAMA5D31, SAMA5D33, SAMA5D34, SAMA5D35.
@@ -124,6 +128,7 @@ config SOC_AT91SAM9RL
select HAVE_FB_ATMEL
select SOC_AT91SAM9
select AT91_USE_OLD_CLK
+   select HAVE_AT91_UTMI
 
 config SOC_AT91SAM9G45
bool AT91SAM9G45 or AT91SAM9M10 families
@@ -131,6 +136,7 @@ config SOC_AT91SAM9G45
select HAVE_FB_ATMEL
select SOC_AT91SAM9
select AT91_USE_OLD_CLK
+   select HAVE_AT91_UTMI
help
  Select this if you are using one of Atmel's AT91SAM9G45 family SoC.
  This support covers AT91SAM9G45, AT91SAM9G46, AT91SAM9M10 and 
AT91SAM9M11.
@@ -141,6 +147,7 @@ config SOC_AT91SAM9X5
select HAVE_FB_ATMEL
select SOC_AT91SAM9
select AT91_USE_OLD_CLK
+   select HAVE_AT91_UTMI
help
  Select this if you are using one of Atmel's AT91SAM9x5 family SoC.
  This means that your SAM9 name finishes with a '5' (except if it is
diff --git a/drivers/clk/at91/Makefile b/drivers/clk/at91/Makefile
index 3873b62..a824883 100644
--- a/drivers/clk/at91/Makefile
+++ b/drivers/clk/at91/Makefile
@@ -7,3 +7,4 @@ obj-y += clk-main.o clk-pll.o clk-plldiv.o clk-master.o
 obj-y += clk-system.o clk-peripheral.o
 
 obj-$(CONFIG_AT91_PROGRAMMABLE_CLOCKS) += clk-programmable.o
+obj-$(CONFIG_HAVE_AT91_UTMI)   += clk-utmi.o
diff --git a/drivers/clk/at91/clk-utmi.c b/drivers/clk/at91/clk-utmi.c
new file mode 100644
index 000..ae3263b
--- /dev/null
+++ b/drivers/clk/at91/clk-utmi.c
@@ -0,0 +1,159 @@
+/*
+ *  Copyright (C) 2013 Boris BREZILLON b.brezil...@overkiz.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include linux/clk-provider.h
+#include linux/clkdev.h
+#include linux/clk/at91_pmc.h
+#include linux/interrupt.h
+#include linux/irq.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/of_irq.h
+#include linux/io.h
+#include linux/sched.h
+#include linux/wait.h
+
+#include pmc.h
+
+#define UTMI_FIXED_MUL 40
+
+struct clk_utmi {
+   struct clk_hw hw;
+   struct at91_pmc *pmc;
+   unsigned int irq;
+   wait_queue_head_t wait;
+};
+
+#define to_clk_utmi(hw) container_of(hw, struct clk_utmi, hw)
+
+static irqreturn_t clk_utmi_irq_handler(int irq, void *dev_id)
+{
+   struct clk_utmi *utmi = (struct clk_utmi *)dev_id;
+
+   wake_up(utmi-wait);
+   disable_irq_nosync(utmi-irq);
+
+   return IRQ_HANDLED;
+}
+
+static int clk_utmi_prepare(struct clk_hw *hw)
+{
+   struct clk_utmi *utmi = to_clk_utmi(hw);
+   struct at91_pmc *pmc = utmi-pmc;
+   u32 tmp = at91_pmc_read(AT91_CKGR_UCKR) | AT91_PMC_UPLLEN |
+ AT91_PMC_UPLLCOUNT | AT91_PMC_BIASEN;
+
+   pmc_write(pmc, AT91_CKGR_UCKR, tmp);
+
+   while (!(pmc_read(pmc, AT91_PMC_SR)  AT91_PMC_LOCKU)) {
+   enable_irq(utmi-irq);
+   wait_event(utmi-wait,
+  pmc_read(pmc, AT91_PMC_SR)  AT91_PMC_LOCKU);
+   }
+
+   return 0;
+}
+
+static int clk_utmi_is_prepared(struct clk_hw *hw)
+{
+   struct clk_utmi *utmi = to_clk_utmi(hw);
+   struct at91_pmc *pmc = utmi-pmc;
+
+   return !!(pmc_read(pmc, AT91_PMC_SR)  AT91_PMC_LOCKU);
+}
+
+static void clk_utmi_unprepare(struct clk_hw *hw)
+{
+   struct clk_utmi *utmi = to_clk_utmi(hw);
+   struct at91_pmc *pmc = utmi-pmc;
+   u32 tmp = at91_pmc_read(AT91_CKGR_UCKR)  ~AT91_PMC_UPLLEN;
+
+   pmc_write(pmc, AT91_CKGR_UCKR, tmp);
+}
+
+static unsigned long clk_utmi_recalc_rate(struct clk_hw *hw,
+ unsigned long parent_rate)
+{
+   /* UTMI clk is a fixed clk multiplier */
+   return 

[PATCH v6 12/16] clk: at91: add PMC usb clock

2013-11-28 Thread Boris BREZILLON
This patch adds new at91 usb clock implementation using common clk framework.
This clock is used to clock usb ports (ohci, ehci and udc).

Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com
---
 arch/arm/mach-at91/Kconfig |   11 ++
 drivers/clk/at91/Makefile  |1 +
 drivers/clk/at91/clk-usb.c |  398 
 drivers/clk/at91/pmc.c |   15 ++
 drivers/clk/at91/pmc.h |9 +
 5 files changed, 434 insertions(+)
 create mode 100644 drivers/clk/at91/clk-usb.c

diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 6ad37da..b76dc4c 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -3,6 +3,9 @@ if ARCH_AT91
 config HAVE_AT91_UTMI
bool
 
+config HAVE_AT91_USB_CLK
+   bool
+
 config HAVE_AT91_DBGU0
bool
 
@@ -82,6 +85,7 @@ config SOC_SAMA5D3
select HAVE_AT91_DBGU1
select AT91_USE_OLD_CLK
select HAVE_AT91_UTMI
+   select HAVE_AT91_USB_CLK
help
  Select this if you are using one of Atmel's SAMA5D3 family SoC.
  This support covers SAMA5D31, SAMA5D33, SAMA5D34, SAMA5D35.
@@ -96,12 +100,14 @@ config SOC_AT91RM9200
select MULTI_IRQ_HANDLER
select SPARSE_IRQ
select AT91_USE_OLD_CLK
+   select HAVE_AT91_USB_CLK
 
 config SOC_AT91SAM9260
bool AT91SAM9260, AT91SAM9XE or AT91SAM9G20
select HAVE_AT91_DBGU0
select SOC_AT91SAM9
select AT91_USE_OLD_CLK
+   select HAVE_AT91_USB_CLK
help
  Select this if you are using one of Atmel's AT91SAM9260, AT91SAM9XE
  or AT91SAM9G20 SoC.
@@ -112,6 +118,7 @@ config SOC_AT91SAM9261
select HAVE_FB_ATMEL
select SOC_AT91SAM9
select AT91_USE_OLD_CLK
+   select HAVE_AT91_USB_CLK
help
  Select this if you are using one of Atmel's AT91SAM9261 or 
AT91SAM9G10 SoC.
 
@@ -121,6 +128,7 @@ config SOC_AT91SAM9263
select HAVE_FB_ATMEL
select SOC_AT91SAM9
select AT91_USE_OLD_CLK
+   select HAVE_AT91_USB_CLK
 
 config SOC_AT91SAM9RL
bool AT91SAM9RL
@@ -137,6 +145,7 @@ config SOC_AT91SAM9G45
select SOC_AT91SAM9
select AT91_USE_OLD_CLK
select HAVE_AT91_UTMI
+   select HAVE_AT91_USB_CLK
help
  Select this if you are using one of Atmel's AT91SAM9G45 family SoC.
  This support covers AT91SAM9G45, AT91SAM9G46, AT91SAM9M10 and 
AT91SAM9M11.
@@ -148,6 +157,7 @@ config SOC_AT91SAM9X5
select SOC_AT91SAM9
select AT91_USE_OLD_CLK
select HAVE_AT91_UTMI
+   select HAVE_AT91_USB_CLK
help
  Select this if you are using one of Atmel's AT91SAM9x5 family SoC.
  This means that your SAM9 name finishes with a '5' (except if it is
@@ -161,6 +171,7 @@ config SOC_AT91SAM9N12
select HAVE_FB_ATMEL
select SOC_AT91SAM9
select AT91_USE_OLD_CLK
+   select HAVE_AT91_USB_CLK
help
  Select this if you are using Atmel's AT91SAM9N12 SoC.
 
diff --git a/drivers/clk/at91/Makefile b/drivers/clk/at91/Makefile
index a824883..61db058 100644
--- a/drivers/clk/at91/Makefile
+++ b/drivers/clk/at91/Makefile
@@ -8,3 +8,4 @@ obj-y += clk-system.o clk-peripheral.o
 
 obj-$(CONFIG_AT91_PROGRAMMABLE_CLOCKS) += clk-programmable.o
 obj-$(CONFIG_HAVE_AT91_UTMI)   += clk-utmi.o
+obj-$(CONFIG_HAVE_AT91_USB_CLK)+= clk-usb.o
diff --git a/drivers/clk/at91/clk-usb.c b/drivers/clk/at91/clk-usb.c
new file mode 100644
index 000..7d1d26a
--- /dev/null
+++ b/drivers/clk/at91/clk-usb.c
@@ -0,0 +1,398 @@
+/*
+ *  Copyright (C) 2013 Boris BREZILLON b.brezil...@overkiz.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include linux/clk-provider.h
+#include linux/clkdev.h
+#include linux/clk/at91_pmc.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/io.h
+
+#include pmc.h
+
+#define USB_SOURCE_MAX 2
+
+#define SAM9X5_USB_DIV_SHIFT   8
+#define SAM9X5_USB_MAX_DIV 0xf
+
+#define RM9200_USB_DIV_SHIFT   28
+#define RM9200_USB_DIV_TAB_SIZE4
+
+struct at91sam9x5_clk_usb {
+   struct clk_hw hw;
+   struct at91_pmc *pmc;
+};
+
+#define to_at91sam9x5_clk_usb(hw) \
+   container_of(hw, struct at91sam9x5_clk_usb, hw)
+
+struct at91rm9200_clk_usb {
+   struct clk_hw hw;
+   struct at91_pmc *pmc;
+   u32 divisors[4];
+};
+
+#define to_at91rm9200_clk_usb(hw) \
+   container_of(hw, struct at91rm9200_clk_usb, hw)
+
+static unsigned long at91sam9x5_clk_usb_recalc_rate(struct clk_hw *hw,
+   unsigned long parent_rate)
+{
+   u32 tmp;
+   u8 usbdiv;
+   struct at91sam9x5_clk_usb *usb = 

[PATCH v6 16/16] ARM: at91: add new compatible strings for pmc driver

2013-11-28 Thread Boris BREZILLON
This patch adds new compatible string for PMC node to prepare the
transition to common clk.

These compatible string come from pmc driver in clk subsystem and are
needed to provide new device tree compatibility with old at91 clks
(device tree using common clks will use the new compatible strings).

Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com
---
 arch/arm/mach-at91/clock.c |5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/mach-at91/clock.c b/arch/arm/mach-at91/clock.c
index 5f02aea..72b2579 100644
--- a/arch/arm/mach-at91/clock.c
+++ b/arch/arm/mach-at91/clock.c
@@ -884,6 +884,11 @@ static int __init at91_pmc_init(unsigned long main_clock)
 #if defined(CONFIG_OF)
 static struct of_device_id pmc_ids[] = {
{ .compatible = atmel,at91rm9200-pmc },
+   { .compatible = atmel,at91sam9260-pmc },
+   { .compatible = atmel,at91sam9g45-pmc },
+   { .compatible = atmel,at91sam9n12-pmc },
+   { .compatible = atmel,at91sam9x5-pmc },
+   { .compatible = atmel,sama5d3-pmc },
{ /*sentinel*/ }
 };
 
-- 
1.7.9.5

--
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 v6 14/16] dt: binding: add at91 clks dt bindings documentation

2013-11-28 Thread Boris BREZILLON
This patch adds new at91 clks dt bindings documentation.

Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com
---
 .../devicetree/bindings/clock/at91-clock.txt   |  339 
 1 file changed, 339 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/at91-clock.txt

diff --git a/Documentation/devicetree/bindings/clock/at91-clock.txt 
b/Documentation/devicetree/bindings/clock/at91-clock.txt
new file mode 100644
index 000..cd5e239
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/at91-clock.txt
@@ -0,0 +1,339 @@
+Device Tree Clock bindings for arch-at91
+
+This binding uses the common clock binding[1].
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+Required properties:
+- compatible : shall be one of the following:
+   atmel,at91rm9200-pmc or
+   atmel,at91sam9g45-pmc or
+   atmel,at91sam9n12-pmc or
+   atmel,at91sam9x5-pmc or
+   atmel,sama5d3-pmc:
+   at91 PMC (Power Management Controller)
+   All at91 specific clocks (clocks defined below) must be child
+   node of the PMC node.
+
+   atmel,at91rm9200-clk-main:
+   at91 main oscillator
+
+   atmel,at91rm9200-clk-master or
+   atmel,at91sam9x5-clk-master:
+   at91 master clock
+
+   atmel,at91sam9x5-clk-peripheral or
+   atmel,at91rm9200-clk-peripheral:
+   at91 peripheral clocks
+
+   atmel,at91rm9200-clk-pll or
+   atmel,at91sam9g45-clk-pll or
+   atmel,at91sam9g20-clk-pllb or
+   atmel,sama5d3-clk-pll:
+   at91 pll clocks
+
+   atmel,at91sam9x5-clk-plldiv:
+   at91 plla divisor
+
+   atmel,at91rm9200-clk-programmable or
+   atmel,at91sam9g45-clk-programmable or
+   atmel,at91sam9x5-clk-programmable:
+   at91 programmable clocks
+
+   atmel,at91sam9x5-clk-smd:
+   at91 SMD (Soft Modem) clock
+
+   atmel,at91rm9200-clk-system:
+   at91 system clocks
+
+   atmel,at91rm9200-clk-usb or
+   atmel,at91sam9x5-clk-usb or
+   atmel,at91sam9n12-clk-usb:
+   at91 usb clock
+
+   atmel,at91sam9x5-clk-utmi:
+   at91 utmi clock
+
+Required properties for PMC node:
+- reg : defines the IO memory reserved for the PMC.
+- #size-cells : shall be 0 (reg is used to encode clk id).
+- #address-cells : shall be 1 (reg is used to encode clk id).
+- interrupts : shall be set to PMC interrupt line.
+- interrupt-controller : tell that the PMC is an interrupt controller.
+- #interrupt-cells : must be set to 1. The first cell encodes the interrupt id,
+   and reflect the bit position in the PMC_ER/DR/SR registers.
+   You can use the dt macros defined in dt-bindings/clk/at91.h.
+   0 (AT91_PMC_MOSCS) - main oscillator ready
+   1 (AT91_PMC_LOCKA) - PLL A ready
+   2 (AT91_PMC_LOCKB) - PLL B ready
+   3 (AT91_PMC_MCKRDY) - master clock ready
+   6 (AT91_PMC_LOCKU) - UTMI PLL clock ready
+   8 .. 15 (AT91_PMC_PCKRDY(id)) - programmable clock ready
+   16 (AT91_PMC_MOSCSELS) - main oscillator selected
+   17 (AT91_PMC_MOSCRCS) - RC main oscillator stabilized
+   18 (AT91_PMC_CFDEV) - clock failure detected
+
+For example:
+   pmc: pmc@fc00 {
+   compatible = atmel,sama5d3-pmc;
+   interrupts = 1 4 7;
+   interrupt-controller;
+   #interrupt-cells = 2;
+   #size-cells = 0;
+   #address-cells = 1;
+
+   /* put at91 clocks here */
+   };
+
+Required properties for main clock:
+- interrupt-parent : must reference the PMC node.
+- interrupts : shall be set to 0.
+- #clock-cells : from common clock binding; shall be set to 0.
+- clocks (optional if clock-frequency is provided) : shall be the slow clock
+   phandle. This clock is used to calculate the main clock rate if
+   clock-frequency is not provided.
+- clock-frequency : the main oscillator frequency.Prefer the use of
+   clock-frequency over automatic clock rate calculation.
+
+For example:
+   main: mainck {
+   compatible = atmel,at91rm9200-clk-main;
+   interrupt-parent = pmc;
+   interrupts = 0;
+   #clock-cells = 0;
+   clocks = ck32k;
+   clock-frequency = 18432000;
+   };
+
+Required properties for master clock:
+- interrupt-parent : must reference the PMC node.
+- interrupts : shall be set to 3.
+- #clock-cells : from common clock binding; shall be set to 0.
+- clocks : shall be the master clock sources (see atmel datasheet) phandles.
+   e.g. ck32k, main, plla, pllb.
+- atmel,clk-output-range : minimum and maximum clock frequency (two u32
+  fields).
+  e.g. output = 0 13300; = 0 to 133MHz.
+- atmel,clk-divisors : master clock divisors table (four u32 fields).
+   0 = reserved 

[PATCH v6 13/16] clk: at91: add PMC smd clock

2013-11-28 Thread Boris BREZILLON
This patch adds at91 smd (Soft Modem) clock implementation using common clk
framework.

Not used by any driver right now.

Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com
---
 arch/arm/mach-at91/Kconfig |5 ++
 drivers/clk/at91/Makefile  |1 +
 drivers/clk/at91/clk-smd.c |  171 
 drivers/clk/at91/pmc.c |7 ++
 drivers/clk/at91/pmc.h |5 ++
 5 files changed, 189 insertions(+)
 create mode 100644 drivers/clk/at91/clk-smd.c

diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index b76dc4c..97033f7 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -39,6 +39,9 @@ config AT91_SAM9G45_RESET
 config AT91_SAM9_TIME
bool
 
+config HAVE_AT91_SMD
+   bool
+
 config SOC_AT91SAM9
bool
select AT91_SAM9_TIME
@@ -85,6 +88,7 @@ config SOC_SAMA5D3
select HAVE_AT91_DBGU1
select AT91_USE_OLD_CLK
select HAVE_AT91_UTMI
+   select HAVE_AT91_SMD
select HAVE_AT91_USB_CLK
help
  Select this if you are using one of Atmel's SAMA5D3 family SoC.
@@ -157,6 +161,7 @@ config SOC_AT91SAM9X5
select SOC_AT91SAM9
select AT91_USE_OLD_CLK
select HAVE_AT91_UTMI
+   select HAVE_AT91_SMD
select HAVE_AT91_USB_CLK
help
  Select this if you are using one of Atmel's AT91SAM9x5 family SoC.
diff --git a/drivers/clk/at91/Makefile b/drivers/clk/at91/Makefile
index 61db058..0e92b71 100644
--- a/drivers/clk/at91/Makefile
+++ b/drivers/clk/at91/Makefile
@@ -9,3 +9,4 @@ obj-y += clk-system.o clk-peripheral.o
 obj-$(CONFIG_AT91_PROGRAMMABLE_CLOCKS) += clk-programmable.o
 obj-$(CONFIG_HAVE_AT91_UTMI)   += clk-utmi.o
 obj-$(CONFIG_HAVE_AT91_USB_CLK)+= clk-usb.o
+obj-$(CONFIG_HAVE_AT91_SMD)+= clk-smd.o
diff --git a/drivers/clk/at91/clk-smd.c b/drivers/clk/at91/clk-smd.c
new file mode 100644
index 000..144d47e
--- /dev/null
+++ b/drivers/clk/at91/clk-smd.c
@@ -0,0 +1,171 @@
+/*
+ *  Copyright (C) 2013 Boris BREZILLON b.brezil...@overkiz.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include linux/clk-provider.h
+#include linux/clkdev.h
+#include linux/clk/at91_pmc.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/io.h
+
+#include pmc.h
+
+#define SMD_SOURCE_MAX 2
+
+#define SMD_DIV_SHIFT  8
+#define SMD_MAX_DIV0xf
+
+struct at91sam9x5_clk_smd {
+   struct clk_hw hw;
+   struct at91_pmc *pmc;
+};
+
+#define to_at91sam9x5_clk_smd(hw) \
+   container_of(hw, struct at91sam9x5_clk_smd, hw)
+
+static unsigned long at91sam9x5_clk_smd_recalc_rate(struct clk_hw *hw,
+   unsigned long parent_rate)
+{
+   u32 tmp;
+   u8 smddiv;
+   struct at91sam9x5_clk_smd *smd = to_at91sam9x5_clk_smd(hw);
+   struct at91_pmc *pmc = smd-pmc;
+
+   tmp = pmc_read(pmc, AT91_PMC_SMD);
+   smddiv = (tmp  AT91_PMC_SMD_DIV)  SMD_DIV_SHIFT;
+   return parent_rate / (smddiv + 1);
+}
+
+static long at91sam9x5_clk_smd_round_rate(struct clk_hw *hw, unsigned long 
rate,
+ unsigned long *parent_rate)
+{
+   unsigned long div;
+   unsigned long bestrate;
+   unsigned long tmp;
+
+   if (rate = *parent_rate)
+   return *parent_rate;
+
+   div = *parent_rate / rate;
+   if (div  SMD_MAX_DIV)
+   return *parent_rate / (SMD_MAX_DIV + 1);
+
+   bestrate = *parent_rate / div;
+   tmp = *parent_rate / (div + 1);
+   if (bestrate - rate  rate - tmp)
+   bestrate = tmp;
+
+   return bestrate;
+}
+
+static int at91sam9x5_clk_smd_set_parent(struct clk_hw *hw, u8 index)
+{
+   u32 tmp;
+   struct at91sam9x5_clk_smd *smd = to_at91sam9x5_clk_smd(hw);
+   struct at91_pmc *pmc = smd-pmc;
+
+   if (index  1)
+   return -EINVAL;
+   tmp = pmc_read(pmc, AT91_PMC_SMD)  ~AT91_PMC_SMDS;
+   if (index)
+   tmp |= AT91_PMC_SMDS;
+   pmc_write(pmc, AT91_PMC_SMD, tmp);
+   return 0;
+}
+
+static u8 at91sam9x5_clk_smd_get_parent(struct clk_hw *hw)
+{
+   struct at91sam9x5_clk_smd *smd = to_at91sam9x5_clk_smd(hw);
+   struct at91_pmc *pmc = smd-pmc;
+
+   return pmc_read(pmc, AT91_PMC_SMD)  AT91_PMC_SMDS;
+}
+
+static int at91sam9x5_clk_smd_set_rate(struct clk_hw *hw, unsigned long rate,
+  unsigned long parent_rate)
+{
+   u32 tmp;
+   struct at91sam9x5_clk_smd *smd = to_at91sam9x5_clk_smd(hw);
+   struct at91_pmc *pmc = smd-pmc;
+   unsigned long div = parent_rate / rate;
+
+   if (parent_rate % rate || div  

[PATCH v6 04/16] clk: at91: add PMC macro file for dt definitions

2013-11-28 Thread Boris BREZILLON
This patch adds a new macro file for PMC macros.

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

Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com
---
 include/dt-bindings/clk/at91.h |   22 ++
 1 file changed, 22 insertions(+)
 create mode 100644 include/dt-bindings/clk/at91.h

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

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


[RFC PATH 3/3] phy: ulpi: add support for NXP ISP170X USB PHY

2013-11-28 Thread Heikki Krogerus
This driver is based on drivers/power/isp1704_power.c. It
simply converts the original driver to ulpi driver.

Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
---
 drivers/phy/ulpi/Kconfig|  10 +
 drivers/phy/ulpi/Makefile   |   1 +
 drivers/phy/ulpi/isp1704_ulpi.c | 446 
 3 files changed, 457 insertions(+)
 create mode 100644 drivers/phy/ulpi/isp1704_ulpi.c

diff --git a/drivers/phy/ulpi/Kconfig b/drivers/phy/ulpi/Kconfig
index 3211aaa..1340df7 100644
--- a/drivers/phy/ulpi/Kconfig
+++ b/drivers/phy/ulpi/Kconfig
@@ -9,3 +9,13 @@ config ULPI_PHY
 
  If unsure, say Y.
 
+if ULPI_PHY
+
+config ULPI_ISP170X
+   tristate NXP ISP170X USB PHY module
+   depends on POWER_SUPPLY
+   select USB_PHY
+   help
+ Support for NXP ISP170X ULPI PHY.
+
+endif
diff --git a/drivers/phy/ulpi/Makefile b/drivers/phy/ulpi/Makefile
index 7ed0895..d873e37 100644
--- a/drivers/phy/ulpi/Makefile
+++ b/drivers/phy/ulpi/Makefile
@@ -1 +1,2 @@
 obj-$(CONFIG_ULPI_PHY) += ulpi.o
+obj-$(CONFIG_ULPI_ISP170X) += isp1704_ulpi.o
diff --git a/drivers/phy/ulpi/isp1704_ulpi.c b/drivers/phy/ulpi/isp1704_ulpi.c
new file mode 100644
index 000..301fe9b
--- /dev/null
+++ b/drivers/phy/ulpi/isp1704_ulpi.c
@@ -0,0 +1,446 @@
+/**
+ * ISP1704 USB ULPI PHY driver
+ *
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * Author: Heikki Krogerus heikki.kroge...@linux.intel.com
+ *
+ * The code is based on drivers/power/isp1704_charger.c
+ * Copyright (C) 2010 Nokia Corporation
+ * Copyright (C) 2012 - 2013 Pali Rohár pali.ro...@gmail.com
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#include linux/module.h
+#include linux/phy/phy.h
+#include linux/phy/ulpi.h
+#include linux/gpio/consumer.h
+#include linux/power_supply.h
+#include linux/usb/otg.h
+#include linux/usb/gadget.h
+
+/* Vendor specific Power Control register */
+#define ISP1704_PWR_CTRL   0x3d
+#define ISP1704_PWR_CTRL_SWCTRL(1  0)
+#define ISP1704_PWR_CTRL_DET_COMP  (1  1)
+#define ISP1704_PWR_CTRL_BVALID_RISE   (1  2)
+#define ISP1704_PWR_CTRL_BVALID_FALL   (1  3)
+#define ISP1704_PWR_CTRL_DP_WKPU_EN(1  4)
+#define ISP1704_PWR_CTRL_VDAT_DET  (1  5)
+#define ISP1704_PWR_CTRL_DPVSRC_EN (1  6)
+#define ISP1704_PWR_CTRL_HWDETECT  (1  7)
+
+#define NXP_VENDOR_ID  0x04cc
+
+struct isp1704_phy {
+   struct notifier_block nb;
+   struct power_supply psy;
+   struct work_struct work;
+   struct gpio_desc *gpio;
+   struct usb_phy phy;
+   struct usb_otg otg;
+   struct device *dev;
+
+   /* properties */
+   char model[8];
+   unsigned present:1;
+   unsigned online:1;
+   unsigned current_max;
+};
+
+static inline int isp1704_read(struct isp1704_phy *isp, u8 addr)
+{
+   return ulpi_read(to_ulpi_dev(isp-dev), addr);
+}
+
+static inline int isp1704_write(struct isp1704_phy *isp, u8 addr, u8 val)
+{
+   return ulpi_write(to_ulpi_dev(isp-dev), addr, val);
+}
+
+/* -- 
*/
+
+/**
+ * Determine is the charging port DCP (dedicated charger) or CDP (Host/HUB
+ * chargers).
+ *
+ * REVISIT: The method is defined in Battery Charging Specification and is
+ * applicable to any ULPI transceiver. Nothing isp170x specific here.
+ */
+static inline int isp1704_type(struct isp1704_phy *isp)
+{
+   int type = POWER_SUPPLY_TYPE_USB_DCP;
+   u8 func_ctrl;
+   u8 otg_ctrl;
+   u8 val;
+
+   func_ctrl = isp1704_read(isp, ULPI_FUNC_CTRL);
+   otg_ctrl = isp1704_read(isp, ULPI_OTG_CTRL);
+
+   /* disable pulldowns */
+   val = ULPI_OTG_CTRL_DM_PULLDOWN | ULPI_OTG_CTRL_DP_PULLDOWN;
+   isp1704_write(isp, ULPI_CLR(ULPI_OTG_CTRL), val);
+
+   /* full speed */
+   isp1704_write(isp, ULPI_CLR(ULPI_FUNC_CTRL),
+ ULPI_FUNC_CTRL_XCVRSEL_MASK);
+   isp1704_write(isp, ULPI_SET(ULPI_FUNC_CTRL),
+ ULPI_FUNC_CTRL_FULL_SPEED);
+
+   /* Enable strong pull-up on DP (1.5K) and reset */
+   val = ULPI_FUNC_CTRL_TERMSELECT | ULPI_FUNC_CTRL_RESET;
+   isp1704_write(isp, ULPI_SET(ULPI_FUNC_CTRL), val);
+   usleep_range(1000, 2000);
+
+   val = isp1704_read(isp, ULPI_DEBUG);
+   if ((val  3) != 3)
+   type = POWER_SUPPLY_TYPE_USB_CDP;
+
+   /* recover original state */
+   isp1704_write(isp, ULPI_FUNC_CTRL, func_ctrl);
+   isp1704_write(isp, ULPI_OTG_CTRL, otg_ctrl);
+
+   return type;
+}
+
+/**
+ * ISP1704 detects PS/2 adapters as charger. To make sure the detected charger
+ * is actually a dedicated charger, the following steps need to be taken.
+ */
+static inline int isp1704_verify(struct isp1704_phy 

[RFC PATH 2/3] usb: dwc3: add ULPI interface support

2013-11-28 Thread Heikki Krogerus
Registers ULPI interface with the ULPI abstraction layer if
the HSPHY type is ULPI, which will create phy instance for
usb2.

Depends on Kishon's patch set adding support for generic PHY
framework.

Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
---
 drivers/usb/dwc3/Kconfig  |   7 +++
 drivers/usb/dwc3/Makefile |   4 ++
 drivers/usb/dwc3/core.c   |   8 
 drivers/usb/dwc3/core.h   |  21 +
 drivers/usb/dwc3/ulpi.c   | 110 ++
 5 files changed, 150 insertions(+)
 create mode 100644 drivers/usb/dwc3/ulpi.c

diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index 64eed6f..a97b294 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -13,6 +13,13 @@ config USB_DWC3
 
 if USB_DWC3
 
+config USB_DWC3_ULPI
+   bool Provide ULPI PHY Interface
+   depends on ULPI_PHY=y || ULPI_PHY=USB_DWC3
+   help
+ Select this if you have ULPI type PHY attached to your DWC3
+ controller.
+
 choice
bool DWC3 Mode Selection
default USB_DWC3_DUAL_ROLE if (USB  USB_GADGET)
diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
index dd17601..8bb82bc 100644
--- a/drivers/usb/dwc3/Makefile
+++ b/drivers/usb/dwc3/Makefile
@@ -13,6 +13,10 @@ ifneq ($(filter y,$(CONFIG_USB_DWC3_GADGET) 
$(CONFIG_USB_DWC3_DUAL_ROLE)),)
dwc3-y  += gadget.o ep0.o
 endif
 
+ifneq ($(CONFIG_USB_DWC3_ULPI),)
+   dwc3-y  += ulpi.o
+endif
+
 ifneq ($(CONFIG_DEBUG_FS),)
dwc3-y  += debugfs.o
 endif
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 1c0a69a..94927b2 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -505,6 +505,12 @@ static int dwc3_probe(struct platform_device *pdev)
dwc-regs_size  = resource_size(res);
dwc-dev= dev;
 
+   if (!dwc-usb2_generic_phy) {
+   ret = dwc3_ulpi_init(dwc);
+   if (ret)
+   return ret;
+   }
+
dev-dma_mask   = dev-parent-dma_mask;
dev-dma_parms  = dev-parent-dma_parms;
dma_set_coherent_mask(dev, dev-parent-coherent_dma_mask);
@@ -613,6 +619,7 @@ err1:
 
 err0:
dwc3_free_event_buffers(dwc);
+   dwc3_ulpi_exit(dwc);
 
return ret;
 }
@@ -653,6 +660,7 @@ static int dwc3_remove(struct platform_device *pdev)
dwc3_event_buffers_cleanup(dwc);
dwc3_free_event_buffers(dwc);
dwc3_core_exit(dwc);
+   dwc3_ulpi_exit(dwc);
 
return 0;
 }
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 01ec7d7..6df398a 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -169,6 +169,14 @@
 #define DWC3_GUSB2PHYCFG_PHYSOFTRST(1  31)
 #define DWC3_GUSB2PHYCFG_SUSPHY(1  6)
 
+/* Global USB2 PHY Vendor Control Register */
+#define DWC3_GUSB2PHYACC_NEWREGREQ (1  25)
+#define DWC3_GUSB2PHYACC_BUSY  (1  23)
+#define DWC3_GUSB2PHYACC_WRITE (1  22)
+#define DWC3_GUSB2PHYACC_ADDR(n)   (n  16)
+#define DWC3_GUSB2PHYACC_EXTEND_ADDR(n)(n  8)
+#define DWC3_GUSB2PHYACC_DATA(n)   (n  0xff)
+
 /* Global USB3 PIPE Control Register */
 #define DWC3_GUSB3PIPECTL_PHYSOFTRST   (1  31)
 #define DWC3_GUSB3PIPECTL_SUSPHY   (1  17)
@@ -557,6 +565,7 @@ struct dwc3_hwparams {
 #define DWC3_NUM_INT(n)(((n)  (0x3f  15))  15)
 
 /* HWPARAMS3 */
+#define DWC3_ULPI_HSPHY(1  3)
 #define DWC3_NUM_IN_EPS_MASK   (0x1f  18)
 #define DWC3_NUM_EPS_MASK  (0x3f  12)
 #define DWC3_NUM_EPS(p)(((p)-hwparams3   \
@@ -672,6 +681,8 @@ struct dwc3 {
struct phy  *usb2_generic_phy;
struct phy  *usb3_generic_phy;
 
+   struct ulpi_interface   *ulpi;
+
void __iomem*regs;
size_t  regs_size;
 
@@ -922,4 +933,14 @@ static inline int dwc3_gadget_resume(struct dwc3 *dwc)
 }
 #endif /* !IS_ENABLED(CONFIG_USB_DWC3_HOST) */
 
+#if IS_ENABLED(CONFIG_USB_DWC3_ULPI)
+int dwc3_ulpi_init(struct dwc3 *dwc);
+void dwc3_ulpi_exit(struct dwc3 *dwc);
+#else
+static inline int dwc3_ulpi_init(struct dwc3 *dwc)
+{ return 0; }
+static inline void dwc3_ulpi_exit(struct dwc3 *dwc)
+{ }
+#endif
+
 #endif /* __DRIVERS_USB_DWC3_CORE_H */
diff --git a/drivers/usb/dwc3/ulpi.c b/drivers/usb/dwc3/ulpi.c
new file mode 100644
index 000..e1f152b
--- /dev/null
+++ b/drivers/usb/dwc3/ulpi.c
@@ -0,0 +1,110 @@
+/**
+ * ulpi.c - DesignWare USB3 ULPI PHY interface
+ *
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * Author: Heikki Krogerus heikki.kroge...@linux.intel.com
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#include 

[RFC PATH 0/3] USB PHYs and PCI

2013-11-28 Thread Heikki Krogerus
Hi guys,

PCI does not give any information about the PHY but we still need to
be able to take advantage of any possible vendor specific features,
such as custom PM operations, charger detection, ADP probing and
sensing, etc. the PHY provides. Since ULPI provides a way to do
runtime detection, I'm introducing this layer on top of Kishon's
generic phy framework. It gives us means to detect the ULPI product
and bind it to a driver without need for nasty platform/device
specific quirks in case of ULPI PHYs.

I trust nobody has a problem with this approach, but I would like to
get your feedback at this stage, before I make any drivers on top of
this thing. The isp1704_ulpi.c I made just as an example for now.

Thanks,


Heikki Krogerus (3):
  phy: add USB ULPI abstraction layer
  usb: dwc3: add ULPI interface support
  phy: ulpi: add support for NXP ISP170X USB PHY

 drivers/phy/Kconfig |   2 +
 drivers/phy/Makefile|   1 +
 drivers/phy/ulpi/Kconfig|  21 ++
 drivers/phy/ulpi/Makefile   |   2 +
 drivers/phy/ulpi/isp1704_ulpi.c | 446 
 drivers/phy/ulpi/ulpi.c | 273 
 drivers/usb/dwc3/Kconfig|   7 +
 drivers/usb/dwc3/Makefile   |   4 +
 drivers/usb/dwc3/core.c |   8 +
 drivers/usb/dwc3/core.h |  21 ++
 drivers/usb/dwc3/ulpi.c | 110 ++
 include/linux/phy/ulpi.h| 105 ++
 12 files changed, 1000 insertions(+)
 create mode 100644 drivers/phy/ulpi/Kconfig
 create mode 100644 drivers/phy/ulpi/Makefile
 create mode 100644 drivers/phy/ulpi/isp1704_ulpi.c
 create mode 100644 drivers/phy/ulpi/ulpi.c
 create mode 100644 drivers/usb/dwc3/ulpi.c
 create mode 100644 include/linux/phy/ulpi.h

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


[RFC PATH 1/3] phy: add USB ULPI abstraction layer

2013-11-28 Thread Heikki Krogerus
ULPI PHY is an USB2 PHY that is accessed from the USB
controller. ULPI PHYs allow discovery based on vendor and
product ids which allows binding the PHY to a driver.

For USB controllers that are enumerated from buses such as
PCI, that do not provide any information about the PHY, ULPI
abstraction layer allows runtime detection. This makes it
possible to take advantage of vendor specific functions of
the PHYs with product specific drivers without the need for
platform or device specific quirks.

Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
---
 drivers/phy/Kconfig   |   2 +
 drivers/phy/Makefile  |   1 +
 drivers/phy/ulpi/Kconfig  |  11 ++
 drivers/phy/ulpi/Makefile |   1 +
 drivers/phy/ulpi/ulpi.c   | 273 ++
 include/linux/phy/ulpi.h  | 105 ++
 6 files changed, 393 insertions(+)
 create mode 100644 drivers/phy/ulpi/Kconfig
 create mode 100644 drivers/phy/ulpi/Makefile
 create mode 100644 drivers/phy/ulpi/ulpi.c
 create mode 100644 include/linux/phy/ulpi.h

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index a344f3d..6c03824 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -51,4 +51,6 @@ config PHY_EXYNOS_DP_VIDEO
help
  Support for Display Port PHY found on Samsung EXYNOS SoCs.
 
+source drivers/phy/ulpi/Kconfig
+
 endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index d0caae9..d6af605 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -7,3 +7,4 @@ obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO)   += phy-exynos-dp-video.o
 obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)+= phy-exynos-mipi-video.o
 obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o
 obj-$(CONFIG_TWL4030_USB)  += phy-twl4030-usb.o
+obj-$(CONFIG_ULPI_PHY) += ulpi/
diff --git a/drivers/phy/ulpi/Kconfig b/drivers/phy/ulpi/Kconfig
new file mode 100644
index 000..3211aaa
--- /dev/null
+++ b/drivers/phy/ulpi/Kconfig
@@ -0,0 +1,11 @@
+
+config ULPI_PHY
+   tristate USB ULPI PHY interface support
+   depends on USB || USB_GADGET
+   select GENERIC_PHY
+   help
+ Say yes if you have ULPI PHY attached to your USB controller. If no
+ vendor modules are selected, the driver will act as NOP PHY driver.
+
+ If unsure, say Y.
+
diff --git a/drivers/phy/ulpi/Makefile b/drivers/phy/ulpi/Makefile
new file mode 100644
index 000..7ed0895
--- /dev/null
+++ b/drivers/phy/ulpi/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_ULPI_PHY) += ulpi.o
diff --git a/drivers/phy/ulpi/ulpi.c b/drivers/phy/ulpi/ulpi.c
new file mode 100644
index 000..7aa2f5d
--- /dev/null
+++ b/drivers/phy/ulpi/ulpi.c
@@ -0,0 +1,273 @@
+/**
+ * ulpi.c - USB ULPI PHY abstraction module
+ *
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * Author: Heikki Krogerus heikki.kroge...@linux.intel.com
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#include linux/phy/ulpi.h
+#include linux/phy/phy.h
+#include linux/module.h
+#include linux/slab.h
+
+/* -- 
*/
+
+static struct phy_consumer phy_consumer[] = {
+   { .port = ULPI_PORT_NAME, },
+};
+
+static struct phy_init_data phy_data = {
+   .num_consumers = 1,
+   .consumers = phy_consumer,
+};
+
+static int ulpi_power_on(struct phy *phy)
+{
+   struct ulpi_dev *ulpi = phy_get_drvdata(phy);
+   struct ulpi_driver *drv = to_ulpi_driver(ulpi-dev.driver);
+
+   if (drv  drv-phy_ops  drv-phy_ops-power_on)
+   return drv-phy_ops-power_on(phy);
+
+   return 0;
+}
+
+static int ulpi_power_off(struct phy *phy)
+{
+   struct ulpi_dev *ulpi = phy_get_drvdata(phy);
+   struct ulpi_driver *drv = to_ulpi_driver(ulpi-dev.driver);
+
+   if (drv  drv-phy_ops  drv-phy_ops-power_off)
+   return drv-phy_ops-power_off(phy);
+
+   return 0;
+}
+
+static struct phy_ops phy_ops = {
+   .owner = THIS_MODULE,
+   .power_on = ulpi_power_on,
+   .power_off = ulpi_power_off,
+};
+
+/* -- 
*/
+
+static int ulpi_match(struct device *dev, struct device_driver *driver)
+{
+   struct ulpi_driver *drv = to_ulpi_driver(driver);
+   struct ulpi_dev *ulpi = to_ulpi_dev(dev);
+   const struct ulpi_device_id *id;
+
+   for (id = drv-id_table; id-vendor; id++)
+   if (id-vendor == ulpi-id.vendor 
+   id-product == ulpi-id.product)
+   return 1;
+
+   return 0;
+}
+
+static int ulpi_probe(struct device *dev)
+{
+   struct ulpi_driver *drv = to_ulpi_driver(dev-driver);
+
+   return drv-probe(to_ulpi_dev(dev));
+}
+
+static int ulpi_remove(struct device 

Re: [PATCH v3 5/9] usb: gadget: s3c-hsotg: use generic phy_init()/phy_exit() support

2013-11-28 Thread Matt Porter
On Thu, Nov 28, 2013 at 11:23:52AM +0530, Kishon Vijay Abraham I wrote:
 On Thursday 28 November 2013 04:06 AM, Matt Porter wrote:
  On Wed, Nov 27, 2013 at 12:13:25PM -0500, Matt Porter wrote:
  On Tue, Nov 26, 2013 at 03:53:32PM +0530, Kishon Vijay Abraham I wrote:
  Hi,
 
  On Monday 25 November 2013 11:46 PM, Matt Porter wrote:
  If a generic phy is present, call phy_init()/phy_exit(). This supports
  generic phys that must be soft reset before power on.
 
  Signed-off-by: Matt Porter matt.por...@linaro.org
  ---
   drivers/usb/gadget/s3c-hsotg.c | 5 +
   1 file changed, 5 insertions(+)
 
  diff --git a/drivers/usb/gadget/s3c-hsotg.c 
  b/drivers/usb/gadget/s3c-hsotg.c
  index da3879b..8dfe33f 100644
  --- a/drivers/usb/gadget/s3c-hsotg.c
  +++ b/drivers/usb/gadget/s3c-hsotg.c
  @@ -3622,6 +3622,9 @@ static int s3c_hsotg_probe(struct platform_device 
  *pdev)
   goto err_supplies;
   }
   
  +if (hsotg-phy)
 
  IS_ERR? If your phy_get fails *phy* will have a error value..
 
  Yes, thanks. I'll fix these and also note that the same issue exists in
  Kamil's patch for these same hsotg-phy conditional uses. I'll work with
  Kamil to either get those addressed there or in a follow on fix.
  
  I spoke too soon. If devm_phy_get fails, we don't set hsotg-phy and probe
  defer thus not reaching this point. Since hsotg-phy is either NULL or a
  valid struct phy *, this is correct as is throughout the driver.
  
 
  +phy_init(hsotg-phy);
  +
   /* usb phy enable */
   s3c_hsotg_phy_enable(hsotg);
   
  @@ -3715,6 +3718,8 @@ static int s3c_hsotg_remove(struct platform_device 
  *pdev)
   }
   
   s3c_hsotg_phy_disable(hsotg);
  +if (hsotg-phy)
 
  same here.
 
  Ok.
  
  Same above, this will be NULL on failure (but is only applicable at this
  point on the platform data path.
 
 Ah ok.. Btw where is phy_get being called? Is it not part of this series?

It's in the Kamil's Exynos USB Phy - generic phy series [1] which I depend
on here. I mentioned it in the cover letter toward the end so it's a bit
buried.

I have some outstanding, but trivial, comments on that series but I hear
Kamil will be posting an update in the coming days. I'll wait a few days
to post v4 addressing your comments so I can hopefully rebase against
his updated s3c-hsotg patch.

-Matt

[1] https://lkml.org/lkml/2013/11/5/275
--
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: Need help to support USB3.0 HID Keyboard device

2013-11-28 Thread Alan Stern
On Thu, 28 Nov 2013, Bhavik Kothari wrote:

 Hi Greg / Alan,
 
 Yes, I have read Alan's response, and I have implemented the same way 
 (Alternate setting is zero  it has endpoints, and Endpoint max packet 
 size is 64 bytes instead of 1024 bytes). Now, Windows CV gets passed  
 Host detects HID (keyboard) driver too.
 
 Actually I wanted to know for a knowledge purpose, if I have multiple 
 alternate settings then how Host should do set interface with alternate 
 setting (other than zero) for periodic (Interrupt  Isochronous) transfers.

The driver on the host has to know how to handle the alternate 
settings.  For example, the snd-usb-audio driver knows that it should 
install the proper alternate setting for audio USB devices, depending 
on the audio data rate.

However, the usbhid driver does not know about alternate settings for
USB HID devices.  That's why it wasn't able to handle your device.

 Thanks for your help Alan.

You're welcome.

Alan Stern

--
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 5/9] usb: gadget: s3c-hsotg: use generic phy_init()/phy_exit() support

2013-11-28 Thread Kamil Debski
Hi Matt,

 From: Matt Porter [mailto:matt.por...@linaro.org]
 Sent: Thursday, November 28, 2013 5:42 PM
 
 On Thu, Nov 28, 2013 at 11:23:52AM +0530, Kishon Vijay Abraham I wrote:
  On Thursday 28 November 2013 04:06 AM, Matt Porter wrote:
   On Wed, Nov 27, 2013 at 12:13:25PM -0500, Matt Porter wrote:
   On Tue, Nov 26, 2013 at 03:53:32PM +0530, Kishon Vijay Abraham I
 wrote:
   Hi,
  
   On Monday 25 November 2013 11:46 PM, Matt Porter wrote:
   If a generic phy is present, call phy_init()/phy_exit(). This
   supports generic phys that must be soft reset before power on.
  
   Signed-off-by: Matt Porter matt.por...@linaro.org
   ---
drivers/usb/gadget/s3c-hsotg.c | 5 +
1 file changed, 5 insertions(+)
  
   diff --git a/drivers/usb/gadget/s3c-hsotg.c
   b/drivers/usb/gadget/s3c-hsotg.c index da3879b..8dfe33f 100644
   --- a/drivers/usb/gadget/s3c-hsotg.c
   +++ b/drivers/usb/gadget/s3c-hsotg.c
   @@ -3622,6 +3622,9 @@ static int s3c_hsotg_probe(struct
 platform_device *pdev)
  goto err_supplies;
  }
  
   +  if (hsotg-phy)
  
   IS_ERR? If your phy_get fails *phy* will have a error value..
  
   Yes, thanks. I'll fix these and also note that the same issue
   exists in Kamil's patch for these same hsotg-phy conditional uses.
   I'll work with Kamil to either get those addressed there or in a
 follow on fix.
  
   I spoke too soon. If devm_phy_get fails, we don't set hsotg-phy
 and
   probe defer thus not reaching this point. Since hsotg-phy is
 either
   NULL or a valid struct phy *, this is correct as is throughout the
 driver.
  
  
   +  phy_init(hsotg-phy);
   +
  /* usb phy enable */
  s3c_hsotg_phy_enable(hsotg);
  
   @@ -3715,6 +3718,8 @@ static int s3c_hsotg_remove(struct
 platform_device *pdev)
  }
  
  s3c_hsotg_phy_disable(hsotg);
   +  if (hsotg-phy)
  
   same here.
  
   Ok.
  
   Same above, this will be NULL on failure (but is only applicable at
   this point on the platform data path.
 
  Ah ok.. Btw where is phy_get being called? Is it not part of this
 series?
 
 It's in the Kamil's Exynos USB Phy - generic phy series [1] which I
 depend on here. I mentioned it in the cover letter toward the end so
 it's a bit buried.
 
 I have some outstanding, but trivial, comments on that series but I
 hear Kamil will be posting an update in the coming days. I'll wait a
 few days to post v4 addressing your comments so I can hopefully rebase
 against his updated s3c-hsotg patch.
 

I am sorry to keep you waiting. I was doing some urgent non USB work 
lately and that is the reason for the delay. Thank you for the review of
the last version, by the way. I should post the new version on Wednesday
(or Tuesday afternoon, time permitting). Also, I will have no access to
my Samsung email until Tuesday.

Best wishes,
Kamil Debski


--
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/8] usb/gadget: uvc: move descriptors to their only user

2013-11-28 Thread Laurent Pinchart
Hi Andrzej,

Thank you for the patch.

On Thursday 28 November 2013 08:43:35 Andrzej Pietrasiewicz wrote:
 A bunch of descriptors is defined in webcam.c. They are used only
 by f_uvc. Move them to their only user.

The reason why descriptors are located in webcam.c and not f_uvc.c is that I 
wanted to separate the code in a generic part (f_uvc.c) and an application-
specific part (webcam.c). This allows instantiating a UVC function with 
different parameters, depending on the application, with minimum changes to 
the code. webcam.c is merely sample code that shows how to instantiate a UVC 
function. With this patch the list of formats and controls become hardcoded in 
the function driver.

How could we solve this problem with configfs ?

 Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
 Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
 ---
  drivers/usb/gadget/f_uvc.c  |  271 
  drivers/usb/gadget/f_uvc.h  |7 +-
  drivers/usb/gadget/webcam.c |  243 +--
  3 files changed, 252 insertions(+), 269 deletions(-)
 
 diff --git a/drivers/usb/gadget/f_uvc.c b/drivers/usb/gadget/f_uvc.c
 index e2a1f50..ac0ac82 100644
 --- a/drivers/usb/gadget/f_uvc.c
 +++ b/drivers/usb/gadget/f_uvc.c
 @@ -29,21 +29,255 @@
  #include uvc.h
 
  unsigned int uvc_gadget_trace_param;
 +DECLARE_UVC_HEADER_DESCRIPTOR(1);
 +
 +static const struct UVC_HEADER_DESCRIPTOR(1) uvc_control_header = {
 + .bLength= UVC_DT_HEADER_SIZE(1),
 + .bDescriptorType= USB_DT_CS_INTERFACE,
 + .bDescriptorSubType = UVC_VC_HEADER,
 + .bcdUVC = cpu_to_le16(0x0100),
 + .wTotalLength   = 0, /* dynamic */
 + .dwClockFrequency   = cpu_to_le32(4800),
 + .bInCollection  = 0, /* dynamic */
 + .baInterfaceNr[0]   = 0, /* dynamic */
 +};
 +
 +static const struct uvc_camera_terminal_descriptor uvc_camera_terminal = {
 + .bLength= UVC_DT_CAMERA_TERMINAL_SIZE(3),
 + .bDescriptorType= USB_DT_CS_INTERFACE,
 + .bDescriptorSubType = UVC_VC_INPUT_TERMINAL,
 + .bTerminalID= 1,
 + .wTerminalType  = cpu_to_le16(0x0201),
 + .bAssocTerminal = 0,
 + .iTerminal  = 0,
 + .wObjectiveFocalLengthMin   = cpu_to_le16(0),
 + .wObjectiveFocalLengthMax   = cpu_to_le16(0),
 + .wOcularFocalLength = cpu_to_le16(0),
 + .bControlSize   = 3,
 + .bmControls[0]  = 2,
 + .bmControls[1]  = 0,
 + .bmControls[2]  = 0,
 +};
 +
 +static const struct uvc_processing_unit_descriptor uvc_processing = {
 + .bLength= UVC_DT_PROCESSING_UNIT_SIZE(2),
 + .bDescriptorType= USB_DT_CS_INTERFACE,
 + .bDescriptorSubType = UVC_VC_PROCESSING_UNIT,
 + .bUnitID= 2,
 + .bSourceID  = 1,
 + .wMaxMultiplier = cpu_to_le16(16*1024),
 + .bControlSize   = 2,
 + .bmControls[0]  = 1,
 + .bmControls[1]  = 0,
 + .iProcessing= 0,
 +};
 +
 +static const struct uvc_output_terminal_descriptor uvc_output_terminal = {
 + .bLength= UVC_DT_OUTPUT_TERMINAL_SIZE,
 + .bDescriptorType= USB_DT_CS_INTERFACE,
 + .bDescriptorSubType = UVC_VC_OUTPUT_TERMINAL,
 + .bTerminalID= 3,
 + .wTerminalType  = cpu_to_le16(0x0101),
 + .bAssocTerminal = 0,
 + .bSourceID  = 2,
 + .iTerminal  = 0,
 +};
 +
 +DECLARE_UVC_INPUT_HEADER_DESCRIPTOR(1, 2);
 +
 +static const struct UVC_INPUT_HEADER_DESCRIPTOR(1, 2) uvc_input_header = {
 + .bLength= UVC_DT_INPUT_HEADER_SIZE(1, 2),
 + .bDescriptorType= USB_DT_CS_INTERFACE,
 + .bDescriptorSubType = UVC_VS_INPUT_HEADER,
 + .bNumFormats= 2,
 + .wTotalLength   = 0, /* dynamic */
 + .bEndpointAddress   = 0, /* dynamic */
 + .bmInfo = 0,
 + .bTerminalLink  = 3,
 + .bStillCaptureMethod= 0,
 + .bTriggerSupport= 0,
 + .bTriggerUsage  = 0,
 + .bControlSize   = 1,
 + .bmaControls[0][0]  = 0,
 + .bmaControls[1][0]  = 4,
 +};
 +
 +static const struct uvc_format_uncompressed uvc_format_yuv = {
 + .bLength= UVC_DT_FORMAT_UNCOMPRESSED_SIZE,
 + .bDescriptorType= USB_DT_CS_INTERFACE,
 + .bDescriptorSubType = UVC_VS_FORMAT_UNCOMPRESSED,
 + .bFormatIndex   = 1,
 + .bNumFrameDescriptors   = 2,
 + .guidFormat =
 + { 'Y',  'U',  'Y',  '2', 0x00, 0x00, 0x10, 0x00,
 +  0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71},
 + .bBitsPerPixel  = 16,
 + .bDefaultFrameIndex = 1,
 + .bAspectRatioX  = 0,
 + .bAspectRatioY  = 0,
 + 

Re: [PATCH 1/8] usb/gadget: uvc: move descriptors to their only user

2013-11-28 Thread Michael Grzeschik
On Thu, Nov 28, 2013 at 10:53:03PM +0100, Laurent Pinchart wrote:
 On Thursday 28 November 2013 08:43:35 Andrzej Pietrasiewicz wrote:
  A bunch of descriptors is defined in webcam.c. They are used only
  by f_uvc. Move them to their only user.
 
 The reason why descriptors are located in webcam.c and not f_uvc.c is that I 
 wanted to separate the code in a generic part (f_uvc.c) and an application-
 specific part (webcam.c). This allows instantiating a UVC function with 
 different parameters, depending on the application, with minimum changes to 
 the code. webcam.c is merely sample code that shows how to instantiate a UVC 
 function. With this patch the list of formats and controls become hardcoded 
 in 
 the function driver.
 
 How could we solve this problem with configfs ?

I would suggest that we move away from static descriptor description to
dynamic description from the userspace. We need a similar mechanism like
in functionfs to describe the supported endpoints and their formats. As
this is limited by the application above anyway. Would this also be
possible by configfs?


  Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
  Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
  ---
   drivers/usb/gadget/f_uvc.c  |  271 
   drivers/usb/gadget/f_uvc.h  |7 +-
   drivers/usb/gadget/webcam.c |  243 +--
   3 files changed, 252 insertions(+), 269 deletions(-)
  
  diff --git a/drivers/usb/gadget/f_uvc.c b/drivers/usb/gadget/f_uvc.c
  index e2a1f50..ac0ac82 100644
  --- a/drivers/usb/gadget/f_uvc.c
  +++ b/drivers/usb/gadget/f_uvc.c
  @@ -29,21 +29,255 @@
   #include uvc.h
  
   unsigned int uvc_gadget_trace_param;
  +DECLARE_UVC_HEADER_DESCRIPTOR(1);
  +
  +static const struct UVC_HEADER_DESCRIPTOR(1) uvc_control_header = {
  +   .bLength= UVC_DT_HEADER_SIZE(1),
  +   .bDescriptorType= USB_DT_CS_INTERFACE,
  +   .bDescriptorSubType = UVC_VC_HEADER,
  +   .bcdUVC = cpu_to_le16(0x0100),
  +   .wTotalLength   = 0, /* dynamic */
  +   .dwClockFrequency   = cpu_to_le32(4800),
  +   .bInCollection  = 0, /* dynamic */
  +   .baInterfaceNr[0]   = 0, /* dynamic */
  +};
  +
  +static const struct uvc_camera_terminal_descriptor uvc_camera_terminal = {
  +   .bLength= UVC_DT_CAMERA_TERMINAL_SIZE(3),
  +   .bDescriptorType= USB_DT_CS_INTERFACE,
  +   .bDescriptorSubType = UVC_VC_INPUT_TERMINAL,
  +   .bTerminalID= 1,
  +   .wTerminalType  = cpu_to_le16(0x0201),
  +   .bAssocTerminal = 0,
  +   .iTerminal  = 0,
  +   .wObjectiveFocalLengthMin   = cpu_to_le16(0),
  +   .wObjectiveFocalLengthMax   = cpu_to_le16(0),
  +   .wOcularFocalLength = cpu_to_le16(0),
  +   .bControlSize   = 3,
  +   .bmControls[0]  = 2,
  +   .bmControls[1]  = 0,
  +   .bmControls[2]  = 0,
  +};
  +
  +static const struct uvc_processing_unit_descriptor uvc_processing = {
  +   .bLength= UVC_DT_PROCESSING_UNIT_SIZE(2),
  +   .bDescriptorType= USB_DT_CS_INTERFACE,
  +   .bDescriptorSubType = UVC_VC_PROCESSING_UNIT,
  +   .bUnitID= 2,
  +   .bSourceID  = 1,
  +   .wMaxMultiplier = cpu_to_le16(16*1024),
  +   .bControlSize   = 2,
  +   .bmControls[0]  = 1,
  +   .bmControls[1]  = 0,
  +   .iProcessing= 0,
  +};
  +
  +static const struct uvc_output_terminal_descriptor uvc_output_terminal = {
  +   .bLength= UVC_DT_OUTPUT_TERMINAL_SIZE,
  +   .bDescriptorType= USB_DT_CS_INTERFACE,
  +   .bDescriptorSubType = UVC_VC_OUTPUT_TERMINAL,
  +   .bTerminalID= 3,
  +   .wTerminalType  = cpu_to_le16(0x0101),
  +   .bAssocTerminal = 0,
  +   .bSourceID  = 2,
  +   .iTerminal  = 0,
  +};
  +
  +DECLARE_UVC_INPUT_HEADER_DESCRIPTOR(1, 2);
  +
  +static const struct UVC_INPUT_HEADER_DESCRIPTOR(1, 2) uvc_input_header = {
  +   .bLength= UVC_DT_INPUT_HEADER_SIZE(1, 2),
  +   .bDescriptorType= USB_DT_CS_INTERFACE,
  +   .bDescriptorSubType = UVC_VS_INPUT_HEADER,
  +   .bNumFormats= 2,
  +   .wTotalLength   = 0, /* dynamic */
  +   .bEndpointAddress   = 0, /* dynamic */
  +   .bmInfo = 0,
  +   .bTerminalLink  = 3,
  +   .bStillCaptureMethod= 0,
  +   .bTriggerSupport= 0,
  +   .bTriggerUsage  = 0,
  +   .bControlSize   = 1,
  +   .bmaControls[0][0]  = 0,
  +   .bmaControls[1][0]  = 4,
  +};
  +
  +static const struct uvc_format_uncompressed uvc_format_yuv = {
  +   .bLength= UVC_DT_FORMAT_UNCOMPRESSED_SIZE,
  +   .bDescriptorType= USB_DT_CS_INTERFACE,
  +   .bDescriptorSubType = UVC_VS_FORMAT_UNCOMPRESSED,
  +   .bFormatIndex   = 1,
  +   .bNumFrameDescriptors   = 

Re: [PATCH V2] usb: musb: Fix unstable init of OTG_INTERFSEL.

2013-11-28 Thread Grazvydas Ignotas
On Thu, Nov 28, 2013 at 9:51 AM,  anaum...@ultratronik.de wrote:
 From: Andreas Naumann anaum...@ultratronik.de

 This is a hard to reproduce problem which leads to non-functional
 USB-OTG port in 0.1%-1% of all boots. Tracked it down to commit
 e25bec160158abe86c276d7d206264afc3646281, which introduces save/restore
 of OTG_INTERFSEL over suspend.
 Since the resume function is also called early in driver init, it uses a
 non-initialized value (which is 0 and a non-supported setting in DM37xx
 for INTERFSEL). Shortly after the correct value is set. Apparently this
 works most time, but not always.

 The fix is to initialize the value, BEFORE being written in the resume
 function.

Nice find, I think I'm also affected by this. However this crashes on
OMAP3530 pandora because you now access INTERFSEL before interface
clock is enabled.. This is not a problem on DM37xx because it uses
different interconnects. You should probably use context_valid
variable in omap2430_glue or similar to decide to write to register or
not.

Gražvydas
--
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/3] ACPI / bind: Pass struct acpi_device pointer to acpi_bind_one()

2013-11-28 Thread Rafael J. Wysocki
From: Rafael J. Wysocki rafael.j.wyso...@intel.com

There is no reason to pass an ACPI handle to acpi_bind_one() instead
of a struct acpi_device pointer to the target device object, so
modify that function to take a struct acpi_device pointer as its
second argument and update all code depending on it accordingly.

Signed-off-by: Rafael J. Wysocki rafael.j.wyso...@intel.com
---
 drivers/acpi/acpi_memhotplug.c |   15 +++
 drivers/acpi/acpi_processor.c  |2 +-
 drivers/acpi/glue.c|9 +++--
 drivers/acpi/internal.h|2 +-
 4 files changed, 12 insertions(+), 16 deletions(-)

Index: linux-pm/drivers/acpi/glue.c
===
--- linux-pm.orig/drivers/acpi/glue.c
+++ linux-pm/drivers/acpi/glue.c
@@ -172,9 +172,8 @@ static void acpi_physnode_link_name(char
strcpy(buf, PHYSICAL_NODE_STRING);
 }
 
-int acpi_bind_one(struct device *dev, acpi_handle handle)
+int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev)
 {
-   struct acpi_device *acpi_dev = NULL;
struct acpi_device_physical_node *physical_node, *pn;
char physical_node_name[PHYSICAL_NODE_NAME_SIZE];
struct list_head *physnode_list;
@@ -182,14 +181,12 @@ int acpi_bind_one(struct device *dev, ac
int retval = -EINVAL;
 
if (ACPI_COMPANION(dev)) {
-   if (handle) {
+   if (acpi_dev) {
dev_warn(dev, ACPI companion already set\n);
return -EINVAL;
} else {
acpi_dev = ACPI_COMPANION(dev);
}
-   } else {
-   acpi_bus_get_device(handle, acpi_dev);
}
if (!acpi_dev)
return -EINVAL;
@@ -314,7 +311,7 @@ static int acpi_platform_notify(struct d
ret = -ENODEV;
goto out;
}
-   ret = acpi_bind_one(dev, adev-handle);
+   ret = acpi_bind_one(dev, adev);
if (ret)
goto out;
}
Index: linux-pm/drivers/acpi/internal.h
===
--- linux-pm.orig/drivers/acpi/internal.h
+++ linux-pm/drivers/acpi/internal.h
@@ -86,7 +86,7 @@ void acpi_init_device_object(struct acpi
 int type, unsigned long long sta);
 void acpi_device_add_finalize(struct acpi_device *device);
 void acpi_free_pnp_ids(struct acpi_device_pnp *pnp);
-int acpi_bind_one(struct device *dev, acpi_handle handle);
+int acpi_bind_one(struct device *dev, struct acpi_device *adev);
 int acpi_unbind_one(struct device *dev);
 bool acpi_device_is_present(struct acpi_device *adev);
 
Index: linux-pm/drivers/acpi/acpi_processor.c
===
--- linux-pm.orig/drivers/acpi/acpi_processor.c
+++ linux-pm/drivers/acpi/acpi_processor.c
@@ -395,7 +395,7 @@ static int acpi_processor_add(struct acp
goto err;
}
 
-   result = acpi_bind_one(dev, pr-handle);
+   result = acpi_bind_one(dev, device);
if (result)
goto err;
 
Index: linux-pm/drivers/acpi/acpi_memhotplug.c
===
--- linux-pm.orig/drivers/acpi/acpi_memhotplug.c
+++ linux-pm/drivers/acpi/acpi_memhotplug.c
@@ -180,14 +180,14 @@ static unsigned long acpi_meminfo_end_pf
 
 static int acpi_bind_memblk(struct memory_block *mem, void *arg)
 {
-   return acpi_bind_one(mem-dev, (acpi_handle)arg);
+   return acpi_bind_one(mem-dev, arg);
 }
 
 static int acpi_bind_memory_blocks(struct acpi_memory_info *info,
-  acpi_handle handle)
+  struct acpi_device *adev)
 {
return walk_memory_range(acpi_meminfo_start_pfn(info),
-acpi_meminfo_end_pfn(info), (void *)handle,
+acpi_meminfo_end_pfn(info), adev,
 acpi_bind_memblk);
 }
 
@@ -197,8 +197,7 @@ static int acpi_unbind_memblk(struct mem
return 0;
 }
 
-static void acpi_unbind_memory_blocks(struct acpi_memory_info *info,
- acpi_handle handle)
+static void acpi_unbind_memory_blocks(struct acpi_memory_info *info)
 {
walk_memory_range(acpi_meminfo_start_pfn(info),
  acpi_meminfo_end_pfn(info), NULL, acpi_unbind_memblk);
@@ -242,9 +241,9 @@ static int acpi_memory_enable_device(str
if (result  result != -EEXIST)
continue;
 
-   result = acpi_bind_memory_blocks(info, handle);
+   result = acpi_bind_memory_blocks(info, mem_device-device);
if (result) {
-   acpi_unbind_memory_blocks(info, handle);
+   acpi_unbind_memory_blocks(info);
return 

[PATCH 3/3] ACPI / bind: Move acpi_get_child() to drivers/ide/ide-acpi.c

2013-11-28 Thread Rafael J. Wysocki
From: Rafael J. Wysocki rafael.j.wyso...@intel.com

Since drivers/ide/ide-acpi.c is the only remaining user of
acpi_get_child(), move that function into that file as a static
routine.

Signed-off-by: Rafael J. Wysocki rafael.j.wyso...@intel.com
---
 drivers/acpi/glue.c |   12 
 drivers/ide/ide-acpi.c  |   11 +++
 include/acpi/acpi_bus.h |1 -
 3 files changed, 11 insertions(+), 13 deletions(-)

Index: linux-pm/drivers/acpi/glue.c
===
--- linux-pm.orig/drivers/acpi/glue.c
+++ linux-pm/drivers/acpi/glue.c
@@ -151,18 +151,6 @@ struct acpi_device *acpi_find_child_devi
 }
 EXPORT_SYMBOL_GPL(acpi_find_child_device);
 
-acpi_handle acpi_get_child(acpi_handle handle, u64 addr)
-{
-   struct acpi_device *adev;
-
-   if (!handle || acpi_bus_get_device(handle, adev))
-   return NULL;
-
-   adev = acpi_find_child_device(adev, addr, false);
-   return adev ? adev-handle : NULL;
-}
-EXPORT_SYMBOL_GPL(acpi_get_child);
-
 static void acpi_physnode_link_name(char *buf, unsigned int node_id)
 {
if (node_id  0)
Index: linux-pm/drivers/ide/ide-acpi.c
===
--- linux-pm.orig/drivers/ide/ide-acpi.c
+++ linux-pm/drivers/ide/ide-acpi.c
@@ -98,6 +98,17 @@ bool ide_port_acpi(ide_hwif_t *hwif)
return ide_noacpi == 0  hwif-acpidata;
 }
 
+static acpi_handle acpi_get_child(acpi_handle handle, u64 addr)
+{
+   struct acpi_device *adev;
+
+   if (!handle || acpi_bus_get_device(handle, adev))
+   return NULL;
+
+   adev = acpi_find_child_device(adev, addr, false);
+   return adev ? adev-handle : NULL;
+}
+
 /**
  * ide_get_dev_handle - finds acpi_handle and PCI device.function
  * @dev: device to locate
Index: linux-pm/include/acpi/acpi_bus.h
===
--- linux-pm.orig/include/acpi/acpi_bus.h
+++ linux-pm/include/acpi/acpi_bus.h
@@ -436,7 +436,6 @@ struct acpi_pci_root {
 
 struct acpi_device *acpi_find_child_device(struct acpi_device *parent,
   u64 address, bool check_children);
-acpi_handle acpi_get_child(acpi_handle handle, u64 addr);
 int acpi_is_root_bridge(acpi_handle);
 struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle);
 

--
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/3] ACPI / bind: Rework struct acpi_bus_type

2013-11-28 Thread Rafael J. Wysocki
From: Rafael J. Wysocki rafael.j.wyso...@intel.com

Replace the .find_device function pointer in struct acpi_bus_type
with a new one, .find_copmanion, that is supposed to point to a
function returning struct acpi_device pointer (instead of an int)
and takes one argument (instead of two).  This way the role of
this callback is more clear and the implementation of it can
be more straightforward.

Update all of the users of struct acpi_bus_type (PCI, PNP/ACPI and
USB) to reflect the structure change.

Signed-off-by: Rafael J. Wysocki rafael.j.wyso...@intel.com
---
 drivers/acpi/glue.c |   12 +++-
 drivers/pci/pci-acpi.c  |   12 +++-
 drivers/pnp/pnpacpi/core.c  |   19 +--
 drivers/usb/core/usb-acpi.c |   40 
 include/acpi/acpi_bus.h |2 +-
 5 files changed, 36 insertions(+), 49 deletions(-)

Index: linux-pm/include/acpi/acpi_bus.h
===
--- linux-pm.orig/include/acpi/acpi_bus.h
+++ linux-pm/include/acpi/acpi_bus.h
@@ -414,7 +414,7 @@ struct acpi_bus_type {
struct list_head list;
const char *name;
bool (*match)(struct device *dev);
-   int (*find_device) (struct device *, acpi_handle *);
+   struct acpi_device * (*find_companion)(struct device *);
void (*setup)(struct device *);
void (*cleanup)(struct device *);
 };
Index: linux-pm/drivers/acpi/glue.c
===
--- linux-pm.orig/drivers/acpi/glue.c
+++ linux-pm/drivers/acpi/glue.c
@@ -37,7 +37,7 @@ int register_acpi_bus_type(struct acpi_b
 {
if (acpi_disabled)
return -ENODEV;
-   if (type  type-match  type-find_device) {
+   if (type  type-match  type-find_companion) {
down_write(bus_type_sem);
list_add_tail(type-list, bus_type_list);
up_write(bus_type_sem);
@@ -302,17 +302,19 @@ EXPORT_SYMBOL_GPL(acpi_unbind_one);
 static int acpi_platform_notify(struct device *dev)
 {
struct acpi_bus_type *type = acpi_get_bus_type(dev);
-   acpi_handle handle;
int ret;
 
ret = acpi_bind_one(dev, NULL);
if (ret  type) {
-   ret = type-find_device(dev, handle);
-   if (ret) {
+   struct acpi_device *adev;
+
+   adev = type-find_companion(dev);
+   if (!adev) {
DBG(Unable to get handle for %s\n, dev_name(dev));
+   ret = -ENODEV;
goto out;
}
-   ret = acpi_bind_one(dev, handle);
+   ret = acpi_bind_one(dev, adev-handle);
if (ret)
goto out;
}
Index: linux-pm/drivers/pci/pci-acpi.c
===
--- linux-pm.orig/drivers/pci/pci-acpi.c
+++ linux-pm/drivers/pci/pci-acpi.c
@@ -306,10 +306,9 @@ void acpi_pci_remove_bus(struct pci_bus
 }
 
 /* ACPI bus type */
-static int acpi_pci_find_device(struct device *dev, acpi_handle *handle)
+static struct acpi_device *acpi_pci_find_companion(struct device *dev)
 {
struct pci_dev *pci_dev = to_pci_dev(dev);
-   struct acpi_device *adev;
bool check_children;
u64 addr;
 
@@ -322,13 +321,8 @@ static int acpi_pci_find_device(struct d
|| pci_dev-hdr_type == PCI_HEADER_TYPE_CARDBUS;
/* Please ref to ACPI spec for the syntax of _ADR */
addr = (PCI_SLOT(pci_dev-devfn)  16) | PCI_FUNC(pci_dev-devfn);
-   adev = acpi_find_child_device(ACPI_COMPANION(dev-parent), addr,
+   return acpi_find_child_device(ACPI_COMPANION(dev-parent), addr,
  check_children);
-   if (adev) {
-   *handle = adev-handle;
-   return 0;
-   }
-   return -ENODEV;
 }
 
 static void pci_acpi_setup(struct device *dev)
@@ -368,7 +362,7 @@ static bool pci_acpi_bus_match(struct de
 static struct acpi_bus_type acpi_pci_bus = {
.name = PCI,
.match = pci_acpi_bus_match,
-   .find_device = acpi_pci_find_device,
+   .find_companion = acpi_pci_find_companion,
.setup = pci_acpi_setup,
.cleanup = pci_acpi_cleanup,
 };
Index: linux-pm/drivers/pnp/pnpacpi/core.c
===
--- linux-pm.orig/drivers/pnp/pnpacpi/core.c
+++ linux-pm/drivers/pnp/pnpacpi/core.c
@@ -329,20 +329,11 @@ static int __init acpi_pnp_match(struct
 compare_pnp_id(pnp-id, acpi_device_hid(acpi));
 }
 
-static int __init acpi_pnp_find_device(struct device *dev, acpi_handle * 
handle)
+static struct acpi_device * __init acpi_pnp_find_companion(struct device *dev)
 {
-   struct device *adev;
-   struct acpi_device *acpi;
-
-   adev = bus_find_device(acpi_bus_type, NULL,
-  to_pnp_dev(dev), acpi_pnp_match);

[PATCH 0/3] ACPI / bind: Use struct acpi_device pointers instead of ACPI handles

2013-11-28 Thread Rafael J. Wysocki
Hi,

Now that we store a pointer to struct acpi_device as the ACPI companion in
struct device, the code making associations between physical devices and
ACPI device objects can be modified to work with struct acpi_device pointers
instead of ACPI handles too.  The first two of the following patches make these
changes and the third one is just a related cleanup.

[1/3] ACPI / bind: Replace .find_device in struct acpi_bus_type with 
.find_companion
[2/3] ACPI / bind: Modify acpi_bind_one() to take a struct acpi_device pointer 
as
  the second argument.
[3/3] ACPI / bind: Move acpi_get_child() to ide-acpi.c which is the only 
remaining
  user of that function.

The patches are on top of linux-pm.git/linux-next.  Please let me know if you 
see
any problems in them.

Thanks!

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
--
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/3] usb: chipidea: Fix Internal error: : 808 [#1] ARM related to STS flag

2013-11-28 Thread Chris Ruehl
* init the sts flag to 0 (missed)
* set the sts flag only if not 0

Signed-off-by: Chris Ruehl chris.ru...@gtsys.com.hk
---
 drivers/usb/chipidea/core.c |8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 5075407..1a6010e 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -245,6 +245,8 @@ static void hw_phymode_configure(struct ci_hdrc *ci)
 {
u32 portsc, lpm, sts;
 
+   sts = 0;
+
switch (ci-platdata-phy_mode) {
case USBPHY_INTERFACE_MODE_UTMI:
portsc = PORTSC_PTS(PTS_UTMI);
@@ -273,10 +275,12 @@ static void hw_phymode_configure(struct ci_hdrc *ci)
 
if (ci-hw_bank.lpm) {
hw_write(ci, OP_DEVLC, DEVLC_PTS(7) | DEVLC_PTW, lpm);
-   hw_write(ci, OP_DEVLC, DEVLC_STS, sts);
+   if (sts)
+   hw_write(ci, OP_DEVLC, DEVLC_STS, sts);
} else {
hw_write(ci, OP_PORTSC, PORTSC_PTS(7) | PORTSC_PTW, portsc);
-   hw_write(ci, OP_PORTSC, PORTSC_STS, sts);
+   if ( sts )
+   hw_write(ci, OP_PORTSC, PORTSC_STS, sts);
}
 }
 
-- 
1.7.10.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/3] usb: chipidea: hw_phymode_configure moved before ci_usb_phy_init

2013-11-28 Thread Chris Ruehl
hw_phymode_configure configures the PORTSC registers and allow the
following phy_inits to operate on the right parameters. This fix a problem
where the UPLI (ISP1504) could not detected, because the Viewport was not
available and returns 0's only.

Signed-off-by: Chris Ruehl chris.ru...@gtsys.com.hk
---
 drivers/usb/chipidea/core.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 1a6010e..f915538 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -566,6 +566,8 @@ static int ci_hdrc_probe(struct platform_device *pdev)
return -ENODEV;
}
 
+   hw_phymode_configure(ci);
+
ret = ci_usb_phy_init(ci);
if (ret) {
dev_err(dev, unable to init phy: %d\n, ret);
@@ -583,8 +585,6 @@ static int ci_hdrc_probe(struct platform_device *pdev)
 
ci_get_otg_capable(ci);
 
-   hw_phymode_configure(ci);
-
dr_mode = ci-platdata-dr_mode;
/* initialize role(s) before the interrupt is requested */
if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_HOST) {
-- 
1.7.10.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/3] usb: chipidea: Reallocate regmap only if lpm is detected

2013-11-28 Thread Chris Ruehl
Signed-off-by: Chris Ruehl chris.ru...@gtsys.com.hk
---
 drivers/usb/chipidea/core.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 5d8981c..5075407 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -208,7 +208,8 @@ static int hw_device_init(struct ci_hdrc *ci, void __iomem 
*base)
reg = hw_read(ci, CAP_HCCPARAMS, HCCPARAMS_LEN) 
__ffs(HCCPARAMS_LEN);
ci-hw_bank.lpm  = reg;
-   hw_alloc_regmap(ci, !!reg);
+   if (reg)
+   hw_alloc_regmap(ci, !!reg);
ci-hw_bank.size = ci-hw_bank.op - ci-hw_bank.abs;
ci-hw_bank.size += OP_LAST;
ci-hw_bank.size /= sizeof(u32);
-- 
1.7.10.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 0/3] ACPI / bind: Use struct acpi_device pointers instead of ACPI handles

2013-11-28 Thread Lan Tianyu
On 2013年11月29日 08:36, Rafael J. Wysocki wrote:
 Hi,
 
 Now that we store a pointer to struct acpi_device as the ACPI companion in
 struct device, the code making associations between physical devices and
 ACPI device objects can be modified to work with struct acpi_device pointers
 instead of ACPI handles too.  The first two of the following patches make 
 these
 changes and the third one is just a related cleanup.
 
 [1/3] ACPI / bind: Replace .find_device in struct acpi_bus_type with 
 .find_companion
 [2/3] ACPI / bind: Modify acpi_bind_one() to take a struct acpi_device 
 pointer as
   the second argument.
 [3/3] ACPI / bind: Move acpi_get_child() to ide-acpi.c which is the only 
 remaining
   user of that function.
 

Test usb/ACPI bind part, it works normally.

Tested-by: Lan Tianyu tianyu@intel.com

 The patches are on top of linux-pm.git/linux-next.  Please let me know if you 
 see
 any problems in them.
 
 Thanks!
 


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


Re: [PATCH 3/3] usb: chipidea: hw_phymode_configure moved before ci_usb_phy_init

2013-11-28 Thread Chris Ruehl

Hi Fabio

On Friday, November 29, 2013 10:14 AM, Fabio Estevam wrote:

Hi Chris,

On Fri, Nov 29, 2013 at 12:08 AM, Chris Ruehlchris.ru...@gtsys.com.hk  wrote:

hw_phymode_configure configures the PORTSC registers and allow the
following phy_inits to operate on the right parameters. This fix a problem
where the UPLI (ISP1504) could not detected, because the Viewport was not
available and returns 0's only.

Signed-off-by: Chris Ruehlchris.ru...@gtsys.com.hk


I have already fixed this issue. It is in mainline now:


yeah, the hw_phymode_configure() was in the probe but not called before the
ci_usb_phy_init(ci) which triggers the inits in phy-generic.c (in my case)

My pending patches relay on this.

Did you move the hw_phy before the ci_usb_phy_init too ?

Chris




commit 03779f05be6dfc48de99763f6c845a003e1e40f3
Author: Fabio Estevamfabio.este...@freescale.com
Date:   Wed Aug 14 12:43:56 2013 +0300

 usb: chipidea: move hw_phymode_configure() into probe

 Currently hw_phymode_configure() is located inside hw_device_reset(), which
 only called by chipidea udc driver.

 When operating in host mode, we also need to call hw_phymode_configure() in
 order to properly configure the PHY mode, so move this function into probe.

 After this change, USB Host1 port on mx53qsb board is functional.

 Signed-off-by: Fabio Estevamfabio.este...@freescale.com
 Tested-by: Arnaud Patardarnaud.pat...@rtp-net.org
 Reviewed-by: Peter Chenpeter.c...@freescale.com
 Signed-off-by: Alexander Shishkinalexander.shish...@linux.intel.com
 Signed-off-by: Greg Kroah-Hartmangre...@linuxfoundation.org

Regards,

Fabio Estevam


--
GTSYS Limited RFID Technology
A01 24/F Gold King Industrial Bld
35-41 Tai Lin Pai Road, Kwai Chung, Hong Kong
Fax (852) 8167 4060 - Tel (852) 3598 9488

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


Re: [PATCH 3/3] usb: chipidea: hw_phymode_configure moved before ci_usb_phy_init

2013-11-28 Thread Fabio Estevam
On Fri, Nov 29, 2013 at 12:29 AM, Chris Ruehl chris.ru...@gtsys.com.hk wrote:

 yeah, the hw_phymode_configure() was in the probe but not called before the
 ci_usb_phy_init(ci) which triggers the inits in phy-generic.c (in my case)

 My pending patches relay on this.

 Did you move the hw_phy before the ci_usb_phy_init too ?

Ah, ok. It is a different issue then. Sorry for the noise.

Regards,

Fabio Estevam
--
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: chipidea: Reallocate regmap only if lpm is detected

2013-11-28 Thread Peter Chen

 
 
 Signed-off-by: Chris Ruehl chris.ru...@gtsys.com.hk
 ---
  drivers/usb/chipidea/core.c |3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
 
 diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
 index 5d8981c..5075407 100644
 --- a/drivers/usb/chipidea/core.c
 +++ b/drivers/usb/chipidea/core.c
 @@ -208,7 +208,8 @@ static int hw_device_init(struct ci_hdrc *ci, void
 __iomem *base)
   reg = hw_read(ci, CAP_HCCPARAMS, HCCPARAMS_LEN) 
   __ffs(HCCPARAMS_LEN);
   ci-hw_bank.lpm  = reg;
 - hw_alloc_regmap(ci, !!reg);
 + if (reg)
 + hw_alloc_regmap(ci, !!reg);
   ci-hw_bank.size = ci-hw_bank.op - ci-hw_bank.abs;
   ci-hw_bank.size += OP_LAST;
   ci-hw_bank.size /= sizeof(u32);
 --

Please add description at commit log


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


RE: [PATCH 2/3] usb: chipidea: Fix Internal error: : 808 [#1] ARM related to STS flag

2013-11-28 Thread Peter Chen
 
 
 * init the sts flag to 0 (missed)
 * set the sts flag only if not 0
 

does PORTSC_STS bit as 1 or 0 affect your case?
If not, please remove hw_write(ci, OP_DEVLC, DEVLC_STS, sts),
since it is useless at current code logic.

Peter

 Signed-off-by: Chris Ruehl chris.ru...@gtsys.com.hk
 ---
  drivers/usb/chipidea/core.c |8 ++--
  1 file changed, 6 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
 index 5075407..1a6010e 100644
 --- a/drivers/usb/chipidea/core.c
 +++ b/drivers/usb/chipidea/core.c
 @@ -245,6 +245,8 @@ static void hw_phymode_configure(struct ci_hdrc *ci)
  {
   u32 portsc, lpm, sts;
 
 + sts = 0;
 +
   switch (ci-platdata-phy_mode) {
   case USBPHY_INTERFACE_MODE_UTMI:
   portsc = PORTSC_PTS(PTS_UTMI);
 @@ -273,10 +275,12 @@ static void hw_phymode_configure(struct ci_hdrc *ci)
 
   if (ci-hw_bank.lpm) {
   hw_write(ci, OP_DEVLC, DEVLC_PTS(7) | DEVLC_PTW, lpm);
 - hw_write(ci, OP_DEVLC, DEVLC_STS, sts);
 + if (sts)
 + hw_write(ci, OP_DEVLC, DEVLC_STS, sts);
   } else {
   hw_write(ci, OP_PORTSC, PORTSC_PTS(7) | PORTSC_PTW, portsc);
 - hw_write(ci, OP_PORTSC, PORTSC_STS, sts);
 + if ( sts )
 + hw_write(ci, OP_PORTSC, PORTSC_STS, sts);
   }
  }
 
 --
 1.7.10.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


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


RE: [PATCH 3/3] usb: chipidea: hw_phymode_configure moved before ci_usb_phy_init

2013-11-28 Thread Peter Chen
 
 
 hw_phymode_configure configures the PORTSC registers and allow the
 following phy_inits to operate on the right parameters. This fix a
 problem
 where the UPLI (ISP1504) could not detected, because the Viewport was not
 available and returns 0's only.
 
 Signed-off-by: Chris Ruehl chris.ru...@gtsys.com.hk
 ---
  drivers/usb/chipidea/core.c |4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
 index 1a6010e..f915538 100644
 --- a/drivers/usb/chipidea/core.c
 +++ b/drivers/usb/chipidea/core.c
 @@ -566,6 +566,8 @@ static int ci_hdrc_probe(struct platform_device *pdev)
   return -ENODEV;
   }
 
 + hw_phymode_configure(ci);
 +
   ret = ci_usb_phy_init(ci);
   if (ret) {
   dev_err(dev, unable to init phy: %d\n, ret);
 @@ -583,8 +585,6 @@ static int ci_hdrc_probe(struct platform_device *pdev)
 
   ci_get_otg_capable(ci);
 
 - hw_phymode_configure(ci);
 -
   dr_mode = ci-platdata-dr_mode;
   /* initialize role(s) before the interrupt is requested */
   if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_HOST) {
 --
 1.7.10.4
 
 --

Acked-by: Peter Chen peter.c...@freescale.com

Peter


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


Re: [PATCH 2/3] usb: chipidea: Fix Internal error: : 808 [#1] ARM related to STS flag

2013-11-28 Thread Chris Ruehl

On Friday, November 29, 2013 11:27 AM, Peter Chen wrote:
  

* init the sts flag to 0 (missed)
* set the sts flag only if not 0


does PORTSC_STS bit as 1 or 0 affect your case?
If not, please remove hw_write(ci, OP_DEVLC, DEVLC_STS, sts),
since it is useless at current code logic.

Peter


Peter,

in the switch statement sts is set to 1 therefore I think its used.

   case USBPHY_INTERFACE_MODE_SERIAL:
portsc = PORTSC_PTS(PTS_SERIAL);
lpm = DEVLC_PTS(PTS_SERIAL);
sts = 1;
break;

Regards
Chris





Signed-off-by: Chris Ruehl chris.ru...@gtsys.com.hk
---
  drivers/usb/chipidea/core.c |8 ++--
  1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 5075407..1a6010e 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -245,6 +245,8 @@ static void hw_phymode_configure(struct ci_hdrc *ci)
  {
u32 portsc, lpm, sts;

+   sts = 0;
+
switch (ci-platdata-phy_mode) {
case USBPHY_INTERFACE_MODE_UTMI:
portsc = PORTSC_PTS(PTS_UTMI);
@@ -273,10 +275,12 @@ static void hw_phymode_configure(struct ci_hdrc *ci)

if (ci-hw_bank.lpm) {
hw_write(ci, OP_DEVLC, DEVLC_PTS(7) | DEVLC_PTW, lpm);
-   hw_write(ci, OP_DEVLC, DEVLC_STS, sts);
+   if (sts)
+   hw_write(ci, OP_DEVLC, DEVLC_STS, sts);
} else {
hw_write(ci, OP_PORTSC, PORTSC_PTS(7) | PORTSC_PTW, portsc);
-   hw_write(ci, OP_PORTSC, PORTSC_STS, sts);
+   if ( sts )
+   hw_write(ci, OP_PORTSC, PORTSC_STS, sts);
}
  }

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


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


--
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/3 v2] usb: chipidea: Reallocate regmap only if lpm is detected

2013-11-28 Thread Chris Ruehl
usb: chipidea: Reallocate regmap only if lpm is detected

The regmap only needs to reallocate if the hw_read on the CAP register shows
lpm is used. Therefore the if() statement check the change.

Signed-off-by: Chris Ruehl chris.ru...@gtsys.com.hk
---
 drivers/usb/chipidea/core.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 5d8981c..5075407 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -208,7 +208,8 @@ static int hw_device_init(struct ci_hdrc *ci, void __iomem 
*base)
reg = hw_read(ci, CAP_HCCPARAMS, HCCPARAMS_LEN) 
__ffs(HCCPARAMS_LEN);
ci-hw_bank.lpm  = reg;
-   hw_alloc_regmap(ci, !!reg);
+   if (reg)
+   hw_alloc_regmap(ci, !!reg);
ci-hw_bank.size = ci-hw_bank.op - ci-hw_bank.abs;
ci-hw_bank.size += OP_LAST;
ci-hw_bank.size /= sizeof(u32);
-- 
1.7.10.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/3 v2] usb: chipidea: hw_phymode_configure moved before ci_usb_phy_init

2013-11-28 Thread Chris Ruehl
usb: chipidea: hw_phymode_configure moved before ci_usb_phy_init

hw_phymode_configure configures the PORTSC registers and allow the
following phy_inits to operate on the right parameters. This fix a problem
where the UPLI (ISP1504) could not detected, because the Viewport was not
available and returns 0's only.

Signed-off-by: Chris Ruehl chris.ru...@gtsys.com.hk
Acked-by: Peter Chen peter.c...@freescale.com
---
 drivers/usb/chipidea/core.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 1a6010e..f915538 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -566,6 +566,8 @@ static int ci_hdrc_probe(struct platform_device *pdev)
return -ENODEV;
}
 
+   hw_phymode_configure(ci);
+
ret = ci_usb_phy_init(ci);
if (ret) {
dev_err(dev, unable to init phy: %d\n, ret);
@@ -583,8 +585,6 @@ static int ci_hdrc_probe(struct platform_device *pdev)
 
ci_get_otg_capable(ci);
 
-   hw_phymode_configure(ci);
-
dr_mode = ci-platdata-dr_mode;
/* initialize role(s) before the interrupt is requested */
if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_HOST) {
-- 
1.7.10.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/3 v2] usb: chipidea: Fix Internal error: : 808 [#1] ARM related to STS flag

2013-11-28 Thread Chris Ruehl
usb: chipidea: Fix Internal error: : 808 [#1] ARM related to STS flag

* init the sts flag to 0 (missed)
* set the sts flag only if not 0

Signed-off-by: Chris Ruehl chris.ru...@gtsys.com.hk
---
 drivers/usb/chipidea/core.c |8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 5075407..1a6010e 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -245,6 +245,8 @@ static void hw_phymode_configure(struct ci_hdrc *ci)
 {
u32 portsc, lpm, sts = 0;
 
switch (ci-platdata-phy_mode) {
case USBPHY_INTERFACE_MODE_UTMI:
portsc = PORTSC_PTS(PTS_UTMI);
@@ -273,10 +275,12 @@ static void hw_phymode_configure(struct ci_hdrc *ci)
 
if (ci-hw_bank.lpm) {
hw_write(ci, OP_DEVLC, DEVLC_PTS(7) | DEVLC_PTW, lpm);
-   hw_write(ci, OP_DEVLC, DEVLC_STS, sts);
+   if (sts)
+   hw_write(ci, OP_DEVLC, DEVLC_STS, sts);
} else {
hw_write(ci, OP_PORTSC, PORTSC_PTS(7) | PORTSC_PTW, portsc);
-   hw_write(ci, OP_PORTSC, PORTSC_STS, sts);
+   if ( sts )
+   hw_write(ci, OP_PORTSC, PORTSC_STS, sts);
}
 }
 
-- 
1.7.10.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