linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 00/12] usb/mmc/power: Generic power sequence (and fix USB/LAN when TFTP booting)
@ 2016-06-01  8:02 Krzysztof Kozlowski
  2016-06-01  8:02 ` [PATCH v3 01/12] power/mmc: Move pwrseq drivers to power/pwrseq Krzysztof Kozlowski
                   ` (12 more replies)
  0 siblings, 13 replies; 30+ messages in thread
From: Krzysztof Kozlowski @ 2016-06-01  8:02 UTC (permalink / raw)
  To: hzpeterchen, Ulf Hansson, Sebastian Reichel,
	Dmitry Eremin-Solenikov, David Woodhouse, Krzysztof Kozlowski,
	Javier Martinez Canillas, linux-kernel, linux-mmc, linux-pm,
	Alan Stern, linux-usb, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Kukjin Kim, devicetree,
	linux-arm-kernel, linux-samsung-soc
  Cc: Greg Kroah-Hartman, Bartlomiej Zolnierkiewicz

Hi,


My third approach for a USB power sequence which fixes usb3503+lan
on Odroid U3 board if it was initialized by bootloader
(e.g. for TFTP boot).


Changes since v2
================
1. Add Javier's reviewed-by tags. Address some comments.
2. Re-use existing properties for GPIOs etc by pwrseq-simple
   driver.  New property is still added: "power-sequence".
   I tried to address and do according to Rob's comments.

   Please look at patch 6/12 ("power: pwrseq: simple: Add support
   for regulator and generic property") for bindings and the
   new code around matching "power-sequence" property.

3. I marked the usb code as "EXAMPLE" because that part
   is left to Peter Chen.


Problem
=======
When Odroid U3 (usb3503 + smsc95xx + max77686) boots from network (TFTP),
the usb3503 and LAN smsc95xx do not show up in "lsusb". Hard-reset
is required, e.g. by suspend to RAM. The actual TFTP boot does
not have to happen. Just "usb start" from U-Boot is sufficient.

>From the schematics, the regulator is a supply only to LAN, however
without toggling it off/on, the usb3503 hub won appear neither.


Solution
========
This is very similar to the MMC pwrseq behavior so the idea is to:
1. Move MMC pwrseq drivers to generic place,
2. Extend the pwrseq-simple with regulator toggling,
3. Add support to USB hub and port core for pwrseq,
4. Toggle the regulator when needed.

Best regards,
Krzysztof

Krzysztof Kozlowski (12):
  power/mmc: Move pwrseq drivers to power/pwrseq
  MAINTAINERS: Retain Ulf Hansson as the same maintainer of pwrseq
  power: pwrseq: Enable COMPILE_TEST for drivers
  power: pwrseq: Remove mmc prefix from mmc_pwrseq
  power: pwrseq: Generalize mmc_pwrseq operations by removing mmc prefix
  power: pwrseq: simple: Add support for regulator and generic property
  power: pwrseq: Add support for USB hubs with external power
  usb: hub: Handle deferred probe
  EXAMPLE CODE: usb: port: Parse pwrseq phandle from Device Tree
  EXAMPLE CODE: usb: hub: Power sequence the ports on activation
  ARM: dts: exynos: Switch the buck8 to GPIO mode on Odroid U3
  ARM: dts: exynos: Fix LAN and HUB after bootloader initialization on
    Odroid U3

 .../pwrseq/pwrseq-emmc.txt}                        |   0
 .../pwrseq/pwrseq-simple.txt}                      |  29 +++-
 MAINTAINERS                                        |   9 ++
 arch/arm/boot/dts/exynos4412-odroidu3.dts          |   5 +
 drivers/mmc/Kconfig                                |   2 -
 drivers/mmc/core/Makefile                          |   3 -
 drivers/mmc/core/core.c                            |   8 +-
 drivers/mmc/core/host.c                            |   2 +-
 drivers/mmc/core/pwrseq.c                          | 110 ---------------
 drivers/mmc/core/pwrseq.h                          |  52 -------
 drivers/power/Kconfig                              |   1 +
 drivers/power/Makefile                             |   1 +
 drivers/{mmc/core => power/pwrseq}/Kconfig         |  22 ++-
 drivers/power/pwrseq/Makefile                      |   3 +
 drivers/power/pwrseq/pwrseq.c                      | 153 +++++++++++++++++++++
 drivers/{mmc/core => power/pwrseq}/pwrseq_emmc.c   |  17 +--
 drivers/{mmc/core => power/pwrseq}/pwrseq_simple.c | 110 ++++++++++++---
 drivers/usb/core/hub.c                             |  16 ++-
 drivers/usb/core/hub.h                             |   3 +
 drivers/usb/core/port.c                            |  15 ++
 include/linux/mmc/host.h                           |   4 +-
 include/linux/pwrseq.h                             |  63 +++++++++
 22 files changed, 414 insertions(+), 214 deletions(-)
 rename Documentation/devicetree/bindings/{mmc/mmc-pwrseq-emmc.txt => power/pwrseq/pwrseq-emmc.txt} (100%)
 rename Documentation/devicetree/bindings/{mmc/mmc-pwrseq-simple.txt => power/pwrseq/pwrseq-simple.txt} (53%)
 delete mode 100644 drivers/mmc/core/pwrseq.c
 delete mode 100644 drivers/mmc/core/pwrseq.h
 rename drivers/{mmc/core => power/pwrseq}/Kconfig (60%)
 create mode 100644 drivers/power/pwrseq/Makefile
 create mode 100644 drivers/power/pwrseq/pwrseq.c
 rename drivers/{mmc/core => power/pwrseq}/pwrseq_emmc.c (88%)
 rename drivers/{mmc/core => power/pwrseq}/pwrseq_simple.c (52%)
 create mode 100644 include/linux/pwrseq.h

-- 
1.9.1

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH v3 01/12] power/mmc: Move pwrseq drivers to power/pwrseq
  2016-06-01  8:02 [PATCH v3 00/12] usb/mmc/power: Generic power sequence (and fix USB/LAN when TFTP booting) Krzysztof Kozlowski
@ 2016-06-01  8:02 ` Krzysztof Kozlowski
  2016-06-01  8:02 ` [PATCH v3 02/12] MAINTAINERS: Retain Ulf Hansson as the same maintainer of pwrseq Krzysztof Kozlowski
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 30+ messages in thread
From: Krzysztof Kozlowski @ 2016-06-01  8:02 UTC (permalink / raw)
  To: hzpeterchen, Ulf Hansson, Sebastian Reichel,
	Dmitry Eremin-Solenikov, David Woodhouse, Krzysztof Kozlowski,
	Javier Martinez Canillas, linux-kernel, linux-mmc, linux-pm,
	Alan Stern, linux-usb, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Kukjin Kim, devicetree,
	linux-arm-kernel, linux-samsung-soc
  Cc: Greg Kroah-Hartman, Bartlomiej Zolnierkiewicz

The MMC power sequence drivers are useful also outside of MMC world: for
USB devices needed a hard-reset before probing. Before extending and
re-using pwrseq drivers, move them to a new place.

The commit does not introduce significant changes in the pwrseq drivers
code so still all the functions are prefixed with "mmc_pwrseq". However
the MMC-specific pwrseq functions has to be now exported and everything
is hidden not by CONFIG_OF but by new CONFIG_POWER_SEQ option.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com>
---
 .../pwrseq/pwrseq-emmc.txt}                            |  0
 .../pwrseq/pwrseq-simple.txt}                          |  0
 drivers/mmc/Kconfig                                    |  2 --
 drivers/mmc/core/Makefile                              |  3 ---
 drivers/mmc/core/core.c                                |  2 +-
 drivers/mmc/core/host.c                                |  2 +-
 drivers/power/Kconfig                                  |  1 +
 drivers/power/Makefile                                 |  1 +
 drivers/{mmc/core => power/pwrseq}/Kconfig             | 18 +++++++++++++-----
 drivers/power/pwrseq/Makefile                          |  3 +++
 drivers/{mmc/core => power/pwrseq}/pwrseq.c            |  8 ++++++--
 drivers/{mmc/core => power/pwrseq}/pwrseq_emmc.c       |  3 +--
 drivers/{mmc/core => power/pwrseq}/pwrseq_simple.c     |  3 +--
 {drivers/mmc/core => include/linux}/pwrseq.h           |  6 +++---
 14 files changed, 31 insertions(+), 21 deletions(-)
 rename Documentation/devicetree/bindings/{mmc/mmc-pwrseq-emmc.txt => power/pwrseq/pwrseq-emmc.txt} (100%)
 rename Documentation/devicetree/bindings/{mmc/mmc-pwrseq-simple.txt => power/pwrseq/pwrseq-simple.txt} (100%)
 rename drivers/{mmc/core => power/pwrseq}/Kconfig (66%)
 create mode 100644 drivers/power/pwrseq/Makefile
 rename drivers/{mmc/core => power/pwrseq}/pwrseq.c (90%)
 rename drivers/{mmc/core => power/pwrseq}/pwrseq_emmc.c (99%)
 rename drivers/{mmc/core => power/pwrseq}/pwrseq_simple.c (99%)
 rename {drivers/mmc/core => include/linux}/pwrseq.h (94%)

diff --git a/Documentation/devicetree/bindings/mmc/mmc-pwrseq-emmc.txt b/Documentation/devicetree/bindings/power/pwrseq/pwrseq-emmc.txt
similarity index 100%
rename from Documentation/devicetree/bindings/mmc/mmc-pwrseq-emmc.txt
rename to Documentation/devicetree/bindings/power/pwrseq/pwrseq-emmc.txt
diff --git a/Documentation/devicetree/bindings/mmc/mmc-pwrseq-simple.txt b/Documentation/devicetree/bindings/power/pwrseq/pwrseq-simple.txt
similarity index 100%
rename from Documentation/devicetree/bindings/mmc/mmc-pwrseq-simple.txt
rename to Documentation/devicetree/bindings/power/pwrseq/pwrseq-simple.txt
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index f2eeb38efa65..7ade379e0634 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -21,8 +21,6 @@ config MMC_DEBUG
 
 if MMC
 
-source "drivers/mmc/core/Kconfig"
-
 source "drivers/mmc/card/Kconfig"
 
 source "drivers/mmc/host/Kconfig"
diff --git a/drivers/mmc/core/Makefile b/drivers/mmc/core/Makefile
index f007151dfdc6..a901d3cd09d3 100644
--- a/drivers/mmc/core/Makefile
+++ b/drivers/mmc/core/Makefile
@@ -8,7 +8,4 @@ mmc_core-y			:= core.o bus.o host.o \
 				   sdio.o sdio_ops.o sdio_bus.o \
 				   sdio_cis.o sdio_io.o sdio_irq.o \
 				   quirks.o slot-gpio.o
-mmc_core-$(CONFIG_OF)		+= pwrseq.o
-obj-$(CONFIG_PWRSEQ_SIMPLE)	+= pwrseq_simple.o
-obj-$(CONFIG_PWRSEQ_EMMC)	+= pwrseq_emmc.o
 mmc_core-$(CONFIG_DEBUG_FS)	+= debugfs.o
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 8b4dfd45433b..edefc3fbebe6 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -25,6 +25,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/pm_wakeup.h>
 #include <linux/suspend.h>
+#include <linux/pwrseq.h>
 #include <linux/fault-inject.h>
 #include <linux/random.h>
 #include <linux/slab.h>
@@ -43,7 +44,6 @@
 #include "bus.h"
 #include "host.h"
 #include "sdio_bus.h"
-#include "pwrseq.h"
 
 #include "mmc_ops.h"
 #include "sd_ops.h"
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 1be42fab1a30..1db7d5802adc 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -21,6 +21,7 @@
 #include <linux/export.h>
 #include <linux/leds.h>
 #include <linux/slab.h>
+#include <linux/pwrseq.h>
 
 #include <linux/mmc/host.h>
 #include <linux/mmc/card.h>
@@ -29,7 +30,6 @@
 #include "core.h"
 #include "host.h"
 #include "slot-gpio.h"
-#include "pwrseq.h"
 
 #define cls_dev_to_mmc_host(d)	container_of(d, struct mmc_host, class_dev)
 
diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index 421770ddafa3..2702aca6cd2c 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -511,5 +511,6 @@ config AXP20X_POWER
 
 endif # POWER_SUPPLY
 
+source "drivers/power/pwrseq/Kconfig"
 source "drivers/power/reset/Kconfig"
 source "drivers/power/avs/Kconfig"
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index e46b75d448a5..02f9d5da2e76 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -71,6 +71,7 @@ obj-$(CONFIG_POWER_AVS)		+= avs/
 obj-$(CONFIG_CHARGER_SMB347)	+= smb347-charger.o
 obj-$(CONFIG_CHARGER_TPS65090)	+= tps65090-charger.o
 obj-$(CONFIG_CHARGER_TPS65217)	+= tps65217_charger.o
+obj-$(CONFIG_POWER_SEQ)		+= pwrseq/
 obj-$(CONFIG_POWER_RESET)	+= reset/
 obj-$(CONFIG_AXP288_FUEL_GAUGE) += axp288_fuel_gauge.o
 obj-$(CONFIG_AXP288_CHARGER)	+= axp288_charger.o
diff --git a/drivers/mmc/core/Kconfig b/drivers/power/pwrseq/Kconfig
similarity index 66%
rename from drivers/mmc/core/Kconfig
rename to drivers/power/pwrseq/Kconfig
index 250f223aaa80..7ecd66ab61f3 100644
--- a/drivers/mmc/core/Kconfig
+++ b/drivers/power/pwrseq/Kconfig
@@ -1,7 +1,13 @@
-#
-# MMC core configuration
-#
-config PWRSEQ_EMMC
+menuconfig POWER_SEQ
+	default y if OF
+	bool "Hardware reset support for specific devices"
+	help
+	  Provides drivers that implements specific power sequences for chips,
+	  using the generic power sequence management interface.
+
+if POWER_SEQ
+
+config POWER_SEQ_EMMC
 	tristate "HW reset support for eMMC"
 	default y
 	depends on OF
@@ -12,7 +18,7 @@ config PWRSEQ_EMMC
 	  This driver can also be built as a module. If so, the module
 	  will be called pwrseq_emmc.
 
-config PWRSEQ_SIMPLE
+config POWER_SEQ_SIMPLE
 	tristate "Simple HW reset support for MMC"
 	default y
 	depends on OF
@@ -22,3 +28,5 @@ config PWRSEQ_SIMPLE
 
 	  This driver can also be built as a module. If so, the module
 	  will be called pwrseq_simple.
+
+endif
diff --git a/drivers/power/pwrseq/Makefile b/drivers/power/pwrseq/Makefile
new file mode 100644
index 000000000000..9e40e4b9068b
--- /dev/null
+++ b/drivers/power/pwrseq/Makefile
@@ -0,0 +1,3 @@
+obj-$(CONFIG_POWER_SEQ)		+= pwrseq.o
+obj-$(CONFIG_POWER_SEQ_SIMPLE)	+= pwrseq_simple.o
+obj-$(CONFIG_POWER_SEQ_EMMC)	+= pwrseq_emmc.o
diff --git a/drivers/mmc/core/pwrseq.c b/drivers/power/pwrseq/pwrseq.c
similarity index 90%
rename from drivers/mmc/core/pwrseq.c
rename to drivers/power/pwrseq/pwrseq.c
index 9386c4771814..66310d7643cc 100644
--- a/drivers/mmc/core/pwrseq.c
+++ b/drivers/power/pwrseq/pwrseq.c
@@ -11,11 +11,10 @@
 #include <linux/err.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/pwrseq.h>
 
 #include <linux/mmc/host.h>
 
-#include "pwrseq.h"
-
 static DEFINE_MUTEX(pwrseq_list_mutex);
 static LIST_HEAD(pwrseq_list);
 
@@ -51,6 +50,7 @@ int mmc_pwrseq_alloc(struct mmc_host *host)
 
 	return 0;
 }
+EXPORT_SYMBOL_GPL(mmc_pwrseq_alloc);
 
 void mmc_pwrseq_pre_power_on(struct mmc_host *host)
 {
@@ -59,6 +59,7 @@ void mmc_pwrseq_pre_power_on(struct mmc_host *host)
 	if (pwrseq && pwrseq->ops->pre_power_on)
 		pwrseq->ops->pre_power_on(host);
 }
+EXPORT_SYMBOL_GPL(mmc_pwrseq_pre_power_on);
 
 void mmc_pwrseq_post_power_on(struct mmc_host *host)
 {
@@ -67,6 +68,7 @@ void mmc_pwrseq_post_power_on(struct mmc_host *host)
 	if (pwrseq && pwrseq->ops->post_power_on)
 		pwrseq->ops->post_power_on(host);
 }
+EXPORT_SYMBOL_GPL(mmc_pwrseq_post_power_on);
 
 void mmc_pwrseq_power_off(struct mmc_host *host)
 {
@@ -75,6 +77,7 @@ void mmc_pwrseq_power_off(struct mmc_host *host)
 	if (pwrseq && pwrseq->ops->power_off)
 		pwrseq->ops->power_off(host);
 }
+EXPORT_SYMBOL_GPL(mmc_pwrseq_power_off);
 
 void mmc_pwrseq_free(struct mmc_host *host)
 {
@@ -85,6 +88,7 @@ void mmc_pwrseq_free(struct mmc_host *host)
 		host->pwrseq = NULL;
 	}
 }
+EXPORT_SYMBOL_GPL(mmc_pwrseq_free);
 
 int mmc_pwrseq_register(struct mmc_pwrseq *pwrseq)
 {
diff --git a/drivers/mmc/core/pwrseq_emmc.c b/drivers/power/pwrseq/pwrseq_emmc.c
similarity index 99%
rename from drivers/mmc/core/pwrseq_emmc.c
rename to drivers/power/pwrseq/pwrseq_emmc.c
index adc9c0c614fb..a0583ed46d7f 100644
--- a/drivers/mmc/core/pwrseq_emmc.c
+++ b/drivers/power/pwrseq/pwrseq_emmc.c
@@ -17,11 +17,10 @@
 #include <linux/err.h>
 #include <linux/gpio/consumer.h>
 #include <linux/reboot.h>
+#include <linux/pwrseq.h>
 
 #include <linux/mmc/host.h>
 
-#include "pwrseq.h"
-
 struct mmc_pwrseq_emmc {
 	struct mmc_pwrseq pwrseq;
 	struct notifier_block reset_nb;
diff --git a/drivers/mmc/core/pwrseq_simple.c b/drivers/power/pwrseq/pwrseq_simple.c
similarity index 99%
rename from drivers/mmc/core/pwrseq_simple.c
rename to drivers/power/pwrseq/pwrseq_simple.c
index 450d907c6e6c..786f1db53a3f 100644
--- a/drivers/mmc/core/pwrseq_simple.c
+++ b/drivers/power/pwrseq/pwrseq_simple.c
@@ -16,11 +16,10 @@
 #include <linux/device.h>
 #include <linux/err.h>
 #include <linux/gpio/consumer.h>
+#include <linux/pwrseq.h>
 
 #include <linux/mmc/host.h>
 
-#include "pwrseq.h"
-
 struct mmc_pwrseq_simple {
 	struct mmc_pwrseq pwrseq;
 	bool clk_enabled;
diff --git a/drivers/mmc/core/pwrseq.h b/include/linux/pwrseq.h
similarity index 94%
rename from drivers/mmc/core/pwrseq.h
rename to include/linux/pwrseq.h
index d69e751f148b..e230670c1d8d 100644
--- a/drivers/mmc/core/pwrseq.h
+++ b/include/linux/pwrseq.h
@@ -23,7 +23,7 @@ struct mmc_pwrseq {
 	struct module *owner;
 };
 
-#ifdef CONFIG_OF
+#ifdef CONFIG_POWER_SEQ
 
 int mmc_pwrseq_register(struct mmc_pwrseq *pwrseq);
 void mmc_pwrseq_unregister(struct mmc_pwrseq *pwrseq);
@@ -34,7 +34,7 @@ void mmc_pwrseq_post_power_on(struct mmc_host *host);
 void mmc_pwrseq_power_off(struct mmc_host *host);
 void mmc_pwrseq_free(struct mmc_host *host);
 
-#else
+#else /* CONFIG_POWER_SEQ */
 
 static inline int mmc_pwrseq_register(struct mmc_pwrseq *pwrseq)
 {
@@ -47,6 +47,6 @@ static inline void mmc_pwrseq_post_power_on(struct mmc_host *host) {}
 static inline void mmc_pwrseq_power_off(struct mmc_host *host) {}
 static inline void mmc_pwrseq_free(struct mmc_host *host) {}
 
-#endif
+#endif /* CONFIG_POWER_SEQ */
 
 #endif
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 02/12] MAINTAINERS: Retain Ulf Hansson as the same maintainer of pwrseq
  2016-06-01  8:02 [PATCH v3 00/12] usb/mmc/power: Generic power sequence (and fix USB/LAN when TFTP booting) Krzysztof Kozlowski
  2016-06-01  8:02 ` [PATCH v3 01/12] power/mmc: Move pwrseq drivers to power/pwrseq Krzysztof Kozlowski
@ 2016-06-01  8:02 ` Krzysztof Kozlowski
  2016-06-01  8:02 ` [PATCH v3 03/12] power: pwrseq: Enable COMPILE_TEST for drivers Krzysztof Kozlowski
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 30+ messages in thread
From: Krzysztof Kozlowski @ 2016-06-01  8:02 UTC (permalink / raw)
  To: hzpeterchen, Ulf Hansson, Sebastian Reichel,
	Dmitry Eremin-Solenikov, David Woodhouse, Krzysztof Kozlowski,
	Javier Martinez Canillas, linux-kernel, linux-mmc, linux-pm,
	Alan Stern, linux-usb, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Kukjin Kim, devicetree,
	linux-arm-kernel, linux-samsung-soc
  Cc: Greg Kroah-Hartman, Bartlomiej Zolnierkiewicz

Before moving pwrseq drivers from drivers/mmc/core/ to drivers/power/,
they were maintained by Ulf Hansson.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com>
---
 MAINTAINERS | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 4f2a75ce5442..71114607502a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -9083,6 +9083,15 @@ F:	include/linux/power_supply.h
 F:	drivers/power/
 X:	drivers/power/avs/
 
+POWER SEQ CORE and DRIVERS
+M:	Ulf Hansson <ulf.hansson@linaro.org>
+L:	linux-mmc@vger.kernel.org
+T:	git git://git.linaro.org/people/ulf.hansson/mmc.git
+S:	Maintained
+F:	drivers/power/pwrseq/
+F:	include/linux/pwrseq.h
+F:	Documentation/devicetree/bindings/power/pwrseq/
+
 POWER STATE COORDINATION INTERFACE (PSCI)
 M:	Mark Rutland <mark.rutland@arm.com>
 M:	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 03/12] power: pwrseq: Enable COMPILE_TEST for drivers
  2016-06-01  8:02 [PATCH v3 00/12] usb/mmc/power: Generic power sequence (and fix USB/LAN when TFTP booting) Krzysztof Kozlowski
  2016-06-01  8:02 ` [PATCH v3 01/12] power/mmc: Move pwrseq drivers to power/pwrseq Krzysztof Kozlowski
  2016-06-01  8:02 ` [PATCH v3 02/12] MAINTAINERS: Retain Ulf Hansson as the same maintainer of pwrseq Krzysztof Kozlowski
@ 2016-06-01  8:02 ` Krzysztof Kozlowski
  2016-06-01  8:02 ` [PATCH v3 04/12] power: pwrseq: Remove mmc prefix from mmc_pwrseq Krzysztof Kozlowski
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 30+ messages in thread
From: Krzysztof Kozlowski @ 2016-06-01  8:02 UTC (permalink / raw)
  To: hzpeterchen, Ulf Hansson, Sebastian Reichel,
	Dmitry Eremin-Solenikov, David Woodhouse, Krzysztof Kozlowski,
	Javier Martinez Canillas, linux-kernel, linux-mmc, linux-pm,
	Alan Stern, linux-usb, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Kukjin Kim, devicetree,
	linux-arm-kernel, linux-samsung-soc
  Cc: Greg Kroah-Hartman, Bartlomiej Zolnierkiewicz

Allow build testing for power sequence drivers.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com>
---
 drivers/power/pwrseq/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/power/pwrseq/Kconfig b/drivers/power/pwrseq/Kconfig
index 7ecd66ab61f3..c7e9271fd94f 100644
--- a/drivers/power/pwrseq/Kconfig
+++ b/drivers/power/pwrseq/Kconfig
@@ -10,7 +10,7 @@ if POWER_SEQ
 config POWER_SEQ_EMMC
 	tristate "HW reset support for eMMC"
 	default y
-	depends on OF
+	depends on OF || COMPILE_TEST
 	help
 	  This selects Hardware reset support aka pwrseq-emmc for eMMC
 	  devices. By default this option is set to y.
@@ -21,7 +21,7 @@ config POWER_SEQ_EMMC
 config POWER_SEQ_SIMPLE
 	tristate "Simple HW reset support for MMC"
 	default y
-	depends on OF
+	depends on OF || COMPILE_TEST
 	help
 	  This selects simple hardware reset support aka pwrseq-simple for MMC
 	  devices. By default this option is set to y.
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 04/12] power: pwrseq: Remove mmc prefix from mmc_pwrseq
  2016-06-01  8:02 [PATCH v3 00/12] usb/mmc/power: Generic power sequence (and fix USB/LAN when TFTP booting) Krzysztof Kozlowski
                   ` (2 preceding siblings ...)
  2016-06-01  8:02 ` [PATCH v3 03/12] power: pwrseq: Enable COMPILE_TEST for drivers Krzysztof Kozlowski
@ 2016-06-01  8:02 ` Krzysztof Kozlowski
  2016-06-01  8:02 ` [PATCH v3 05/12] power: pwrseq: Generalize mmc_pwrseq operations by removing mmc prefix Krzysztof Kozlowski
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 30+ messages in thread
From: Krzysztof Kozlowski @ 2016-06-01  8:02 UTC (permalink / raw)
  To: hzpeterchen, Ulf Hansson, Sebastian Reichel,
	Dmitry Eremin-Solenikov, David Woodhouse, Krzysztof Kozlowski,
	Javier Martinez Canillas, linux-kernel, linux-mmc, linux-pm,
	Alan Stern, linux-usb, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Kukjin Kim, devicetree,
	linux-arm-kernel, linux-samsung-soc
  Cc: Greg Kroah-Hartman, Bartlomiej Zolnierkiewicz

The "mmc" prefix is no longer needed after moving the pwrseq core code
from mmc/ to power/.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com>
---
 drivers/power/pwrseq/pwrseq.c        | 18 +++++++++---------
 drivers/power/pwrseq/pwrseq_emmc.c   |  8 ++++----
 drivers/power/pwrseq/pwrseq_simple.c |  8 ++++----
 include/linux/mmc/host.h             |  4 ++--
 include/linux/pwrseq.h               | 20 ++++++++++----------
 5 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/drivers/power/pwrseq/pwrseq.c b/drivers/power/pwrseq/pwrseq.c
index 66310d7643cc..9c665821f890 100644
--- a/drivers/power/pwrseq/pwrseq.c
+++ b/drivers/power/pwrseq/pwrseq.c
@@ -21,7 +21,7 @@ static LIST_HEAD(pwrseq_list);
 int mmc_pwrseq_alloc(struct mmc_host *host)
 {
 	struct device_node *np;
-	struct mmc_pwrseq *p;
+	struct pwrseq *p;
 
 	np = of_parse_phandle(host->parent->of_node, "mmc-pwrseq", 0);
 	if (!np)
@@ -54,7 +54,7 @@ EXPORT_SYMBOL_GPL(mmc_pwrseq_alloc);
 
 void mmc_pwrseq_pre_power_on(struct mmc_host *host)
 {
-	struct mmc_pwrseq *pwrseq = host->pwrseq;
+	struct pwrseq *pwrseq = host->pwrseq;
 
 	if (pwrseq && pwrseq->ops->pre_power_on)
 		pwrseq->ops->pre_power_on(host);
@@ -63,7 +63,7 @@ EXPORT_SYMBOL_GPL(mmc_pwrseq_pre_power_on);
 
 void mmc_pwrseq_post_power_on(struct mmc_host *host)
 {
-	struct mmc_pwrseq *pwrseq = host->pwrseq;
+	struct pwrseq *pwrseq = host->pwrseq;
 
 	if (pwrseq && pwrseq->ops->post_power_on)
 		pwrseq->ops->post_power_on(host);
@@ -72,7 +72,7 @@ EXPORT_SYMBOL_GPL(mmc_pwrseq_post_power_on);
 
 void mmc_pwrseq_power_off(struct mmc_host *host)
 {
-	struct mmc_pwrseq *pwrseq = host->pwrseq;
+	struct pwrseq *pwrseq = host->pwrseq;
 
 	if (pwrseq && pwrseq->ops->power_off)
 		pwrseq->ops->power_off(host);
@@ -81,7 +81,7 @@ EXPORT_SYMBOL_GPL(mmc_pwrseq_power_off);
 
 void mmc_pwrseq_free(struct mmc_host *host)
 {
-	struct mmc_pwrseq *pwrseq = host->pwrseq;
+	struct pwrseq *pwrseq = host->pwrseq;
 
 	if (pwrseq) {
 		module_put(pwrseq->owner);
@@ -90,7 +90,7 @@ void mmc_pwrseq_free(struct mmc_host *host)
 }
 EXPORT_SYMBOL_GPL(mmc_pwrseq_free);
 
-int mmc_pwrseq_register(struct mmc_pwrseq *pwrseq)
+int pwrseq_register(struct pwrseq *pwrseq)
 {
 	if (!pwrseq || !pwrseq->ops || !pwrseq->dev)
 		return -EINVAL;
@@ -101,9 +101,9 @@ int mmc_pwrseq_register(struct mmc_pwrseq *pwrseq)
 
 	return 0;
 }
-EXPORT_SYMBOL_GPL(mmc_pwrseq_register);
+EXPORT_SYMBOL_GPL(pwrseq_register);
 
-void mmc_pwrseq_unregister(struct mmc_pwrseq *pwrseq)
+void pwrseq_unregister(struct pwrseq *pwrseq)
 {
 	if (pwrseq) {
 		mutex_lock(&pwrseq_list_mutex);
@@ -111,4 +111,4 @@ void mmc_pwrseq_unregister(struct mmc_pwrseq *pwrseq)
 		mutex_unlock(&pwrseq_list_mutex);
 	}
 }
-EXPORT_SYMBOL_GPL(mmc_pwrseq_unregister);
+EXPORT_SYMBOL_GPL(pwrseq_unregister);
diff --git a/drivers/power/pwrseq/pwrseq_emmc.c b/drivers/power/pwrseq/pwrseq_emmc.c
index a0583ed46d7f..a68ac9a68e04 100644
--- a/drivers/power/pwrseq/pwrseq_emmc.c
+++ b/drivers/power/pwrseq/pwrseq_emmc.c
@@ -22,7 +22,7 @@
 #include <linux/mmc/host.h>
 
 struct mmc_pwrseq_emmc {
-	struct mmc_pwrseq pwrseq;
+	struct pwrseq pwrseq;
 	struct notifier_block reset_nb;
 	struct gpio_desc *reset_gpio;
 };
@@ -54,7 +54,7 @@ static int mmc_pwrseq_emmc_reset_nb(struct notifier_block *this,
 	return NOTIFY_DONE;
 }
 
-static const struct mmc_pwrseq_ops mmc_pwrseq_emmc_ops = {
+static const struct pwrseq_ops mmc_pwrseq_emmc_ops = {
 	.post_power_on = mmc_pwrseq_emmc_reset,
 };
 
@@ -85,7 +85,7 @@ static int mmc_pwrseq_emmc_probe(struct platform_device *pdev)
 	pwrseq->pwrseq.owner = THIS_MODULE;
 	platform_set_drvdata(pdev, pwrseq);
 
-	return mmc_pwrseq_register(&pwrseq->pwrseq);
+	return pwrseq_register(&pwrseq->pwrseq);
 }
 
 static int mmc_pwrseq_emmc_remove(struct platform_device *pdev)
@@ -93,7 +93,7 @@ static int mmc_pwrseq_emmc_remove(struct platform_device *pdev)
 	struct mmc_pwrseq_emmc *pwrseq = platform_get_drvdata(pdev);
 
 	unregister_restart_handler(&pwrseq->reset_nb);
-	mmc_pwrseq_unregister(&pwrseq->pwrseq);
+	pwrseq_unregister(&pwrseq->pwrseq);
 
 	return 0;
 }
diff --git a/drivers/power/pwrseq/pwrseq_simple.c b/drivers/power/pwrseq/pwrseq_simple.c
index 786f1db53a3f..d5fbd653153e 100644
--- a/drivers/power/pwrseq/pwrseq_simple.c
+++ b/drivers/power/pwrseq/pwrseq_simple.c
@@ -21,7 +21,7 @@
 #include <linux/mmc/host.h>
 
 struct mmc_pwrseq_simple {
-	struct mmc_pwrseq pwrseq;
+	struct pwrseq pwrseq;
 	bool clk_enabled;
 	struct clk *ext_clk;
 	struct gpio_descs *reset_gpios;
@@ -77,7 +77,7 @@ static void mmc_pwrseq_simple_power_off(struct mmc_host *host)
 	}
 }
 
-static const struct mmc_pwrseq_ops mmc_pwrseq_simple_ops = {
+static const struct pwrseq_ops mmc_pwrseq_simple_ops = {
 	.pre_power_on = mmc_pwrseq_simple_pre_power_on,
 	.post_power_on = mmc_pwrseq_simple_post_power_on,
 	.power_off = mmc_pwrseq_simple_power_off,
@@ -115,14 +115,14 @@ static int mmc_pwrseq_simple_probe(struct platform_device *pdev)
 	pwrseq->pwrseq.owner = THIS_MODULE;
 	platform_set_drvdata(pdev, pwrseq);
 
-	return mmc_pwrseq_register(&pwrseq->pwrseq);
+	return pwrseq_register(&pwrseq->pwrseq);
 }
 
 static int mmc_pwrseq_simple_remove(struct platform_device *pdev)
 {
 	struct mmc_pwrseq_simple *pwrseq = platform_get_drvdata(pdev);
 
-	mmc_pwrseq_unregister(&pwrseq->pwrseq);
+	pwrseq_unregister(&pwrseq->pwrseq);
 
 	return 0;
 }
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 45cde8cd39f2..f3e29f4b7f30 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -203,7 +203,7 @@ struct mmc_context_info {
 };
 
 struct regulator;
-struct mmc_pwrseq;
+struct pwrseq;
 
 struct mmc_supply {
 	struct regulator *vmmc;		/* Card power supply */
@@ -215,7 +215,7 @@ struct mmc_host {
 	struct device		class_dev;
 	int			index;
 	const struct mmc_host_ops *ops;
-	struct mmc_pwrseq	*pwrseq;
+	struct pwrseq		*pwrseq;
 	unsigned int		f_min;
 	unsigned int		f_max;
 	unsigned int		f_init;
diff --git a/include/linux/pwrseq.h b/include/linux/pwrseq.h
index e230670c1d8d..6d2d2a44ad35 100644
--- a/include/linux/pwrseq.h
+++ b/include/linux/pwrseq.h
@@ -5,19 +5,19 @@
  *
  * License terms: GNU General Public License (GPL) version 2
  */
-#ifndef _MMC_CORE_PWRSEQ_H
-#define _MMC_CORE_PWRSEQ_H
+#ifndef _LINUX_PWRSEQ_H
+#define _LINUX_PWRSEQ_H
 
 #include <linux/mmc/host.h>
 
-struct mmc_pwrseq_ops {
+struct pwrseq_ops {
 	void (*pre_power_on)(struct mmc_host *host);
 	void (*post_power_on)(struct mmc_host *host);
 	void (*power_off)(struct mmc_host *host);
 };
 
-struct mmc_pwrseq {
-	const struct mmc_pwrseq_ops *ops;
+struct pwrseq {
+	const struct pwrseq_ops *ops;
 	struct device *dev;
 	struct list_head pwrseq_node;
 	struct module *owner;
@@ -25,8 +25,8 @@ struct mmc_pwrseq {
 
 #ifdef CONFIG_POWER_SEQ
 
-int mmc_pwrseq_register(struct mmc_pwrseq *pwrseq);
-void mmc_pwrseq_unregister(struct mmc_pwrseq *pwrseq);
+int pwrseq_register(struct pwrseq *pwrseq);
+void pwrseq_unregister(struct pwrseq *pwrseq);
 
 int mmc_pwrseq_alloc(struct mmc_host *host);
 void mmc_pwrseq_pre_power_on(struct mmc_host *host);
@@ -36,11 +36,11 @@ void mmc_pwrseq_free(struct mmc_host *host);
 
 #else /* CONFIG_POWER_SEQ */
 
-static inline int mmc_pwrseq_register(struct mmc_pwrseq *pwrseq)
+static inline int pwrseq_register(struct pwrseq *pwrseq)
 {
 	return -ENOSYS;
 }
-static inline void mmc_pwrseq_unregister(struct mmc_pwrseq *pwrseq) {}
+static inline void pwrseq_unregister(struct pwrseq *pwrseq) {}
 static inline int mmc_pwrseq_alloc(struct mmc_host *host) { return 0; }
 static inline void mmc_pwrseq_pre_power_on(struct mmc_host *host) {}
 static inline void mmc_pwrseq_post_power_on(struct mmc_host *host) {}
@@ -49,4 +49,4 @@ static inline void mmc_pwrseq_free(struct mmc_host *host) {}
 
 #endif /* CONFIG_POWER_SEQ */
 
-#endif
+#endif /* _LINUX_PWRSEQ_H */
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 05/12] power: pwrseq: Generalize mmc_pwrseq operations by removing mmc prefix
  2016-06-01  8:02 [PATCH v3 00/12] usb/mmc/power: Generic power sequence (and fix USB/LAN when TFTP booting) Krzysztof Kozlowski
                   ` (3 preceding siblings ...)
  2016-06-01  8:02 ` [PATCH v3 04/12] power: pwrseq: Remove mmc prefix from mmc_pwrseq Krzysztof Kozlowski
@ 2016-06-01  8:02 ` Krzysztof Kozlowski
  2016-06-01  8:02 ` [PATCH v3 06/12] power: pwrseq: simple: Add support for regulator and generic property Krzysztof Kozlowski
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 30+ messages in thread
From: Krzysztof Kozlowski @ 2016-06-01  8:02 UTC (permalink / raw)
  To: hzpeterchen, Ulf Hansson, Sebastian Reichel,
	Dmitry Eremin-Solenikov, David Woodhouse, Krzysztof Kozlowski,
	Javier Martinez Canillas, linux-kernel, linux-mmc, linux-pm,
	Alan Stern, linux-usb, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Kukjin Kim, devicetree,
	linux-arm-kernel, linux-samsung-soc
  Cc: Greg Kroah-Hartman, Bartlomiej Zolnierkiewicz

The power sequence hooks (mmc_pwrseq_pre_power_on(),
mmc_pwrseq_post_power_on() and mmc_pwrseq_power_off()) can be made more
generic to allow re-use in other subsystems. They do not need to take
pointer to struct mmc_host but instead the struct pwrseq should be
sufficient.

Remove the "mmc" prefix and use the pointer to struct pwrseq as
argument.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com>
---
 drivers/mmc/core/core.c              |  6 +++---
 drivers/power/pwrseq/pwrseq.c        | 24 +++++++++---------------
 drivers/power/pwrseq/pwrseq_emmc.c   |  6 ++----
 drivers/power/pwrseq/pwrseq_simple.c | 14 ++++++--------
 include/linux/pwrseq.h               | 18 +++++++++---------
 5 files changed, 29 insertions(+), 39 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index edefc3fbebe6..09a4722f9037 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1719,7 +1719,7 @@ void mmc_power_up(struct mmc_host *host, u32 ocr)
 	if (host->ios.power_mode == MMC_POWER_ON)
 		return;
 
-	mmc_pwrseq_pre_power_on(host);
+	pwrseq_pre_power_on(host->pwrseq);
 
 	host->ios.vdd = fls(ocr) - 1;
 	host->ios.power_mode = MMC_POWER_UP;
@@ -1740,7 +1740,7 @@ void mmc_power_up(struct mmc_host *host, u32 ocr)
 	 */
 	mmc_delay(10);
 
-	mmc_pwrseq_post_power_on(host);
+	pwrseq_post_power_on(host->pwrseq);
 
 	host->ios.clock = host->f_init;
 
@@ -1759,7 +1759,7 @@ void mmc_power_off(struct mmc_host *host)
 	if (host->ios.power_mode == MMC_POWER_OFF)
 		return;
 
-	mmc_pwrseq_power_off(host);
+	pwrseq_power_off(host->pwrseq);
 
 	host->ios.clock = 0;
 	host->ios.vdd = 0;
diff --git a/drivers/power/pwrseq/pwrseq.c b/drivers/power/pwrseq/pwrseq.c
index 9c665821f890..495a19d3c30b 100644
--- a/drivers/power/pwrseq/pwrseq.c
+++ b/drivers/power/pwrseq/pwrseq.c
@@ -52,32 +52,26 @@ int mmc_pwrseq_alloc(struct mmc_host *host)
 }
 EXPORT_SYMBOL_GPL(mmc_pwrseq_alloc);
 
-void mmc_pwrseq_pre_power_on(struct mmc_host *host)
+void pwrseq_pre_power_on(struct pwrseq *pwrseq)
 {
-	struct pwrseq *pwrseq = host->pwrseq;
-
 	if (pwrseq && pwrseq->ops->pre_power_on)
-		pwrseq->ops->pre_power_on(host);
+		pwrseq->ops->pre_power_on(pwrseq);
 }
-EXPORT_SYMBOL_GPL(mmc_pwrseq_pre_power_on);
+EXPORT_SYMBOL_GPL(pwrseq_pre_power_on);
 
-void mmc_pwrseq_post_power_on(struct mmc_host *host)
+void pwrseq_post_power_on(struct pwrseq *pwrseq)
 {
-	struct pwrseq *pwrseq = host->pwrseq;
-
 	if (pwrseq && pwrseq->ops->post_power_on)
-		pwrseq->ops->post_power_on(host);
+		pwrseq->ops->post_power_on(pwrseq);
 }
-EXPORT_SYMBOL_GPL(mmc_pwrseq_post_power_on);
+EXPORT_SYMBOL_GPL(pwrseq_post_power_on);
 
-void mmc_pwrseq_power_off(struct mmc_host *host)
+void pwrseq_power_off(struct pwrseq *pwrseq)
 {
-	struct pwrseq *pwrseq = host->pwrseq;
-
 	if (pwrseq && pwrseq->ops->power_off)
-		pwrseq->ops->power_off(host);
+		pwrseq->ops->power_off(pwrseq);
 }
-EXPORT_SYMBOL_GPL(mmc_pwrseq_power_off);
+EXPORT_SYMBOL_GPL(pwrseq_power_off);
 
 void mmc_pwrseq_free(struct mmc_host *host)
 {
diff --git a/drivers/power/pwrseq/pwrseq_emmc.c b/drivers/power/pwrseq/pwrseq_emmc.c
index a68ac9a68e04..dbb7e753beb2 100644
--- a/drivers/power/pwrseq/pwrseq_emmc.c
+++ b/drivers/power/pwrseq/pwrseq_emmc.c
@@ -19,8 +19,6 @@
 #include <linux/reboot.h>
 #include <linux/pwrseq.h>
 
-#include <linux/mmc/host.h>
-
 struct mmc_pwrseq_emmc {
 	struct pwrseq pwrseq;
 	struct notifier_block reset_nb;
@@ -37,9 +35,9 @@ static void __mmc_pwrseq_emmc_reset(struct mmc_pwrseq_emmc *pwrseq)
 	udelay(200);
 }
 
-static void mmc_pwrseq_emmc_reset(struct mmc_host *host)
+static void mmc_pwrseq_emmc_reset(struct pwrseq *_pwrseq)
 {
-	struct mmc_pwrseq_emmc *pwrseq =  to_pwrseq_emmc(host->pwrseq);
+	struct mmc_pwrseq_emmc *pwrseq = to_pwrseq_emmc(_pwrseq);
 
 	__mmc_pwrseq_emmc_reset(pwrseq);
 }
diff --git a/drivers/power/pwrseq/pwrseq_simple.c b/drivers/power/pwrseq/pwrseq_simple.c
index d5fbd653153e..93807a6ef162 100644
--- a/drivers/power/pwrseq/pwrseq_simple.c
+++ b/drivers/power/pwrseq/pwrseq_simple.c
@@ -18,8 +18,6 @@
 #include <linux/gpio/consumer.h>
 #include <linux/pwrseq.h>
 
-#include <linux/mmc/host.h>
-
 struct mmc_pwrseq_simple {
 	struct pwrseq pwrseq;
 	bool clk_enabled;
@@ -46,9 +44,9 @@ static void mmc_pwrseq_simple_set_gpios_value(struct mmc_pwrseq_simple *pwrseq,
 	}
 }
 
-static void mmc_pwrseq_simple_pre_power_on(struct mmc_host *host)
+static void mmc_pwrseq_simple_pre_power_on(struct pwrseq *_pwrseq)
 {
-	struct mmc_pwrseq_simple *pwrseq = to_pwrseq_simple(host->pwrseq);
+	struct mmc_pwrseq_simple *pwrseq = to_pwrseq_simple(_pwrseq);
 
 	if (!IS_ERR(pwrseq->ext_clk) && !pwrseq->clk_enabled) {
 		clk_prepare_enable(pwrseq->ext_clk);
@@ -58,16 +56,16 @@ static void mmc_pwrseq_simple_pre_power_on(struct mmc_host *host)
 	mmc_pwrseq_simple_set_gpios_value(pwrseq, 1);
 }
 
-static void mmc_pwrseq_simple_post_power_on(struct mmc_host *host)
+static void mmc_pwrseq_simple_post_power_on(struct pwrseq *_pwrseq)
 {
-	struct mmc_pwrseq_simple *pwrseq = to_pwrseq_simple(host->pwrseq);
+	struct mmc_pwrseq_simple *pwrseq = to_pwrseq_simple(_pwrseq);
 
 	mmc_pwrseq_simple_set_gpios_value(pwrseq, 0);
 }
 
-static void mmc_pwrseq_simple_power_off(struct mmc_host *host)
+static void mmc_pwrseq_simple_power_off(struct pwrseq *_pwrseq)
 {
-	struct mmc_pwrseq_simple *pwrseq = to_pwrseq_simple(host->pwrseq);
+	struct mmc_pwrseq_simple *pwrseq = to_pwrseq_simple(_pwrseq);
 
 	mmc_pwrseq_simple_set_gpios_value(pwrseq, 1);
 
diff --git a/include/linux/pwrseq.h b/include/linux/pwrseq.h
index 6d2d2a44ad35..fcc8fd855d4c 100644
--- a/include/linux/pwrseq.h
+++ b/include/linux/pwrseq.h
@@ -11,9 +11,9 @@
 #include <linux/mmc/host.h>
 
 struct pwrseq_ops {
-	void (*pre_power_on)(struct mmc_host *host);
-	void (*post_power_on)(struct mmc_host *host);
-	void (*power_off)(struct mmc_host *host);
+	void (*pre_power_on)(struct pwrseq *pwrseq);
+	void (*post_power_on)(struct pwrseq *pwrseq);
+	void (*power_off)(struct pwrseq *pwrseq);
 };
 
 struct pwrseq {
@@ -28,10 +28,10 @@ struct pwrseq {
 int pwrseq_register(struct pwrseq *pwrseq);
 void pwrseq_unregister(struct pwrseq *pwrseq);
 
+void pwrseq_pre_power_on(struct pwrseq *pwrseq);
+void pwrseq_post_power_on(struct pwrseq *pwrseq);
+void pwrseq_power_off(struct pwrseq *pwrseq);
 int mmc_pwrseq_alloc(struct mmc_host *host);
-void mmc_pwrseq_pre_power_on(struct mmc_host *host);
-void mmc_pwrseq_post_power_on(struct mmc_host *host);
-void mmc_pwrseq_power_off(struct mmc_host *host);
 void mmc_pwrseq_free(struct mmc_host *host);
 
 #else /* CONFIG_POWER_SEQ */
@@ -41,10 +41,10 @@ static inline int pwrseq_register(struct pwrseq *pwrseq)
 	return -ENOSYS;
 }
 static inline void pwrseq_unregister(struct pwrseq *pwrseq) {}
+static inline void pwrseq_pre_power_on(struct pwrseq *pwrseq) {}
+static inline void pwrseq_post_power_on(struct pwrseq *pwrseq) {}
+static inline void pwrseq_power_off(struct pwrseq *pwrseq) {}
 static inline int mmc_pwrseq_alloc(struct mmc_host *host) { return 0; }
-static inline void mmc_pwrseq_pre_power_on(struct mmc_host *host) {}
-static inline void mmc_pwrseq_post_power_on(struct mmc_host *host) {}
-static inline void mmc_pwrseq_power_off(struct mmc_host *host) {}
 static inline void mmc_pwrseq_free(struct mmc_host *host) {}
 
 #endif /* CONFIG_POWER_SEQ */
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 06/12] power: pwrseq: simple: Add support for regulator and generic property
  2016-06-01  8:02 [PATCH v3 00/12] usb/mmc/power: Generic power sequence (and fix USB/LAN when TFTP booting) Krzysztof Kozlowski
                   ` (4 preceding siblings ...)
  2016-06-01  8:02 ` [PATCH v3 05/12] power: pwrseq: Generalize mmc_pwrseq operations by removing mmc prefix Krzysztof Kozlowski
@ 2016-06-01  8:02 ` Krzysztof Kozlowski
  2016-06-03  2:02   ` Rob Herring
  2016-06-01  8:02 ` [PATCH v3 07/12] power: pwrseq: Add support for USB hubs with external power Krzysztof Kozlowski
                   ` (6 subsequent siblings)
  12 siblings, 1 reply; 30+ messages in thread
From: Krzysztof Kozlowski @ 2016-06-01  8:02 UTC (permalink / raw)
  To: hzpeterchen, Ulf Hansson, Sebastian Reichel,
	Dmitry Eremin-Solenikov, David Woodhouse, Krzysztof Kozlowski,
	Javier Martinez Canillas, linux-kernel, linux-mmc, linux-pm,
	Alan Stern, linux-usb, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Kukjin Kim, devicetree,
	linux-arm-kernel, linux-samsung-soc
  Cc: Greg Kroah-Hartman, Bartlomiej Zolnierkiewicz

Some devices need real hard-reset by cutting the power.  During power
sequence turn off and on the regulator, if it is provided.

Additionally add support for instantiating the pwrseq-simple device on a
generic property 'power-sequence'.  The device will attach itself to the
node containing the property and parse the node's properties like
reset-gpios, ext-supply etc.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
 .../bindings/power/pwrseq/pwrseq-simple.txt        | 29 +++++++-
 drivers/power/pwrseq/pwrseq_simple.c               | 85 +++++++++++++++++++++-
 2 files changed, 107 insertions(+), 7 deletions(-)

diff --git a/Documentation/devicetree/bindings/power/pwrseq/pwrseq-simple.txt b/Documentation/devicetree/bindings/power/pwrseq/pwrseq-simple.txt
index ce0e76749671..a8c3f13ee83f 100644
--- a/Documentation/devicetree/bindings/power/pwrseq/pwrseq-simple.txt
+++ b/Documentation/devicetree/bindings/power/pwrseq/pwrseq-simple.txt
@@ -1,11 +1,17 @@
-* The simple MMC power sequence provider
+* The simple power sequence provider
 
-The purpose of the simple MMC power sequence provider is to supports a set of
+The purpose of the simple power sequence provider is to supports a set of
 common properties between various SOC designs. It thus enables us to use the
 same provider for several SOC designs.
 
-Required properties:
-- compatible : contains "mmc-pwrseq-simple".
+The driver supports two types of bindings:
+1. Separate node
+   Required properties:
+   - compatible : contains "mmc-pwrseq-simple".
+
+2. Property for any node
+   Required properties:
+   - power-sequence
 
 Optional properties:
 - reset-gpios : contains a list of GPIO specifiers. The reset GPIOs are asserted
@@ -16,6 +22,7 @@ Optional properties:
   See ../clocks/clock-bindings.txt for details.
 - clock-names : Must include the following entry:
   "ext_clock" (External clock provided to the card).
+- ext-supply : External regulator supply
 
 Example:
 
@@ -24,4 +31,18 @@ Example:
 		reset-gpios = <&gpio1 12 GPIO_ACTIVE_LOW>;
 		clocks = <&clk_32768_ck>;
 		clock-names = "ext_clock";
+		ext-supply = <&buck8>;
 	}
+
+	usb3503@08 {
+		compatible = "smsc,usb3503";
+		reg = <0x08>;
+
+		intn-gpios = <&gpx3 0 GPIO_ACTIVE_HIGH>;
+		connect-gpios = <&gpx3 4 GPIO_ACTIVE_HIGH>;
+		reset-gpios = <&gpx3 5 GPIO_ACTIVE_HIGH>;
+		initial-mode = <1>;
+
+		power-sequence;
+		ext-supply = <&buck8_reg>;
+	};
diff --git a/drivers/power/pwrseq/pwrseq_simple.c b/drivers/power/pwrseq/pwrseq_simple.c
index 93807a6ef162..4096261b16a4 100644
--- a/drivers/power/pwrseq/pwrseq_simple.c
+++ b/drivers/power/pwrseq/pwrseq_simple.c
@@ -1,12 +1,15 @@
 /*
- *  Copyright (C) 2014 Linaro Ltd
+ * Copyright (C) 2014 Linaro Ltd
+ * Copyright (C) 2016 Samsung Electronics
  *
  * Author: Ulf Hansson <ulf.hansson@linaro.org>
+ *         Krzysztof Kozlowski <k.kozlowski@samsung.com>
  *
  * License terms: GNU General Public License (GPL) version 2
  *
  *  Simple MMC power sequence management
  */
+#include <linux/of.h>
 #include <linux/clk.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
@@ -16,13 +19,16 @@
 #include <linux/device.h>
 #include <linux/err.h>
 #include <linux/gpio/consumer.h>
+#include <linux/regulator/consumer.h>
 #include <linux/pwrseq.h>
+#include <linux/delay.h>
 
 struct mmc_pwrseq_simple {
 	struct pwrseq pwrseq;
 	bool clk_enabled;
 	struct clk *ext_clk;
 	struct gpio_descs *reset_gpios;
+	struct regulator *ext_reg;
 };
 
 #define to_pwrseq_simple(p) container_of(p, struct mmc_pwrseq_simple, pwrseq)
@@ -60,6 +66,13 @@ static void mmc_pwrseq_simple_post_power_on(struct pwrseq *_pwrseq)
 {
 	struct mmc_pwrseq_simple *pwrseq = to_pwrseq_simple(_pwrseq);
 
+	if (pwrseq->ext_reg) {
+		int err;
+
+		err = regulator_enable(pwrseq->ext_reg);
+		WARN_ON_ONCE(err);
+	}
+
 	mmc_pwrseq_simple_set_gpios_value(pwrseq, 0);
 }
 
@@ -73,6 +86,13 @@ static void mmc_pwrseq_simple_power_off(struct pwrseq *_pwrseq)
 		clk_disable_unprepare(pwrseq->ext_clk);
 		pwrseq->clk_enabled = false;
 	}
+
+	if (pwrseq->ext_reg) {
+		int err;
+
+		err = regulator_disable(pwrseq->ext_reg);
+		WARN_ON_ONCE(err);
+	}
 }
 
 static const struct pwrseq_ops mmc_pwrseq_simple_ops = {
@@ -100,12 +120,40 @@ static int mmc_pwrseq_simple_probe(struct platform_device *pdev)
 	if (IS_ERR(pwrseq->ext_clk) && PTR_ERR(pwrseq->ext_clk) != -ENOENT)
 		return PTR_ERR(pwrseq->ext_clk);
 
+	pwrseq->ext_reg = devm_regulator_get_optional(dev, "ext");
+	if (IS_ERR(pwrseq->ext_reg)) {
+		if (PTR_ERR(pwrseq->ext_reg) == -ENODEV)
+			pwrseq->ext_reg = NULL;
+		else
+			return PTR_ERR(pwrseq->ext_reg);
+	} else {
+		int err;
+		/*
+		 * Be sure that regulator is off, before the driver will start
+		 * power sequence. It is likely that regulator is on by default
+		 * and it without toggling it here, it would be disabled much
+		 * later by the core.
+		 */
+
+		err = regulator_enable(pwrseq->ext_reg);
+		WARN_ON_ONCE(err);
+
+		err = regulator_disable(pwrseq->ext_reg);
+		WARN_ON_ONCE(err);
+	}
+
 	pwrseq->reset_gpios = devm_gpiod_get_array(dev, "reset",
 							GPIOD_OUT_HIGH);
 	if (IS_ERR(pwrseq->reset_gpios) &&
 	    PTR_ERR(pwrseq->reset_gpios) != -ENOENT &&
 	    PTR_ERR(pwrseq->reset_gpios) != -ENOSYS) {
-		return PTR_ERR(pwrseq->reset_gpios);
+		/*
+		 * Don't care about errors. If this pwrseq device was added
+		 * to node with existing reset-gpios, then the GPIO reset will
+		 * be handled by other device.
+		 */
+		dev_warn(dev, "Cannot get reset gpio: %ld\n",
+			 PTR_ERR(pwrseq->reset_gpios));
 	}
 
 	pwrseq->pwrseq.dev = dev;
@@ -122,6 +170,13 @@ static int mmc_pwrseq_simple_remove(struct platform_device *pdev)
 
 	pwrseq_unregister(&pwrseq->pwrseq);
 
+	if (pwrseq->ext_reg) {
+		int err;
+
+		err = regulator_disable(pwrseq->ext_reg);
+		WARN_ON_ONCE(err);
+	}
+
 	return 0;
 }
 
@@ -134,5 +189,29 @@ static struct platform_driver mmc_pwrseq_simple_driver = {
 	},
 };
 
-module_platform_driver(mmc_pwrseq_simple_driver);
+static int __init mmc_pwrseq_simple_driver_init(void)
+{
+	struct platform_device *pdev;
+	struct device_node *np;
+
+	for_each_node_with_property(np, "power-sequence") {
+		pdev = platform_device_register_simple("pwrseq_simple",
+						       PLATFORM_DEVID_AUTO,
+						       NULL, 0);
+		if (!IS_ERR(pdev)) {
+			of_node_get(np);
+			pdev->dev.of_node = np;
+		}
+	}
+
+	return platform_driver_register(&mmc_pwrseq_simple_driver);
+}
+module_init(mmc_pwrseq_simple_driver_init);
+
+static void __exit mmc_pwrseq_simple_driver_exit(void)
+{
+	/* FIXME: of_node_put? */
+	platform_driver_unregister(&mmc_pwrseq_simple_driver);
+}
+module_exit(mmc_pwrseq_simple_driver_exit);
 MODULE_LICENSE("GPL v2");
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 07/12] power: pwrseq: Add support for USB hubs with external power
  2016-06-01  8:02 [PATCH v3 00/12] usb/mmc/power: Generic power sequence (and fix USB/LAN when TFTP booting) Krzysztof Kozlowski
                   ` (5 preceding siblings ...)
  2016-06-01  8:02 ` [PATCH v3 06/12] power: pwrseq: simple: Add support for regulator and generic property Krzysztof Kozlowski
@ 2016-06-01  8:02 ` Krzysztof Kozlowski
  2016-06-01  8:02 ` [PATCH v3 08/12] usb: hub: Handle deferred probe Krzysztof Kozlowski
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 30+ messages in thread
From: Krzysztof Kozlowski @ 2016-06-01  8:02 UTC (permalink / raw)
  To: hzpeterchen, Ulf Hansson, Sebastian Reichel,
	Dmitry Eremin-Solenikov, David Woodhouse, Krzysztof Kozlowski,
	Javier Martinez Canillas, linux-kernel, linux-mmc, linux-pm,
	Alan Stern, linux-usb, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Kukjin Kim, devicetree,
	linux-arm-kernel, linux-samsung-soc
  Cc: Greg Kroah-Hartman, Bartlomiej Zolnierkiewicz

Some USB devices on embedded boards have external power supply which has
to be reset in certain conditions. Add pwrseq interface for this.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
 drivers/power/pwrseq/pwrseq.c | 47 ++++++++++++++++++++++++++++++++++++++++++-
 include/linux/pwrseq.h        | 11 ++++++++++
 2 files changed, 57 insertions(+), 1 deletion(-)

diff --git a/drivers/power/pwrseq/pwrseq.c b/drivers/power/pwrseq/pwrseq.c
index 495a19d3c30b..722aff4f740f 100644
--- a/drivers/power/pwrseq/pwrseq.c
+++ b/drivers/power/pwrseq/pwrseq.c
@@ -1,7 +1,9 @@
 /*
- *  Copyright (C) 2014 Linaro Ltd
+ * Copyright (C) 2014 Linaro Ltd
+ * Copyright (C) 2016 Samsung Electronics
  *
  * Author: Ulf Hansson <ulf.hansson@linaro.org>
+ *         Krzysztof Kozlowski <k.kozlowski@samsung.com>
  *
  * License terms: GNU General Public License (GPL) version 2
  *
@@ -52,6 +54,42 @@ int mmc_pwrseq_alloc(struct mmc_host *host)
 }
 EXPORT_SYMBOL_GPL(mmc_pwrseq_alloc);
 
+struct pwrseq *pwrseq_alloc(struct device *dev, const char *phandle_name)
+{
+	struct device_node *np;
+	struct pwrseq *p, *ret = NULL;
+
+	np = of_parse_phandle(dev->of_node, phandle_name, 0);
+	if (!np)
+		return NULL;
+
+	mutex_lock(&pwrseq_list_mutex);
+	list_for_each_entry(p, &pwrseq_list, pwrseq_node) {
+		if (p->dev->of_node == np) {
+			if (!try_module_get(p->owner))
+				dev_err(dev,
+					"increasing module refcount failed\n");
+			else
+				ret = p;
+
+			break;
+		}
+	}
+
+	of_node_put(np);
+	mutex_unlock(&pwrseq_list_mutex);
+
+	if (!ret) {
+		dev_dbg(dev, "%s defer probe\n", phandle_name);
+		return ERR_PTR(-EPROBE_DEFER);
+	}
+
+	dev_info(dev, "allocated usb-pwrseq\n");
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(pwrseq_alloc);
+
 void pwrseq_pre_power_on(struct pwrseq *pwrseq)
 {
 	if (pwrseq && pwrseq->ops->pre_power_on)
@@ -84,6 +122,13 @@ void mmc_pwrseq_free(struct mmc_host *host)
 }
 EXPORT_SYMBOL_GPL(mmc_pwrseq_free);
 
+void pwrseq_free(const struct pwrseq *pwrseq)
+{
+	if (pwrseq)
+		module_put(pwrseq->owner);
+}
+EXPORT_SYMBOL_GPL(pwrseq_free);
+
 int pwrseq_register(struct pwrseq *pwrseq)
 {
 	if (!pwrseq || !pwrseq->ops || !pwrseq->dev)
diff --git a/include/linux/pwrseq.h b/include/linux/pwrseq.h
index fcc8fd855d4c..6215b3d6350d 100644
--- a/include/linux/pwrseq.h
+++ b/include/linux/pwrseq.h
@@ -31,9 +31,13 @@ void pwrseq_unregister(struct pwrseq *pwrseq);
 void pwrseq_pre_power_on(struct pwrseq *pwrseq);
 void pwrseq_post_power_on(struct pwrseq *pwrseq);
 void pwrseq_power_off(struct pwrseq *pwrseq);
+
 int mmc_pwrseq_alloc(struct mmc_host *host);
 void mmc_pwrseq_free(struct mmc_host *host);
 
+struct pwrseq *pwrseq_alloc(struct device *dev, const char *phandle_name);
+void pwrseq_free(const struct pwrseq *pwrseq);
+
 #else /* CONFIG_POWER_SEQ */
 
 static inline int pwrseq_register(struct pwrseq *pwrseq)
@@ -44,9 +48,16 @@ static inline void pwrseq_unregister(struct pwrseq *pwrseq) {}
 static inline void pwrseq_pre_power_on(struct pwrseq *pwrseq) {}
 static inline void pwrseq_post_power_on(struct pwrseq *pwrseq) {}
 static inline void pwrseq_power_off(struct pwrseq *pwrseq) {}
+
 static inline int mmc_pwrseq_alloc(struct mmc_host *host) { return 0; }
 static inline void mmc_pwrseq_free(struct mmc_host *host) {}
 
+static inline struct pwrseq *pwrseq_alloc(struct device *dev, const char *phandle_name)
+{
+	return NULL;
+}
+static inline void pwrseq_free(const struct pwrseq *pwrseq) {}
+
 #endif /* CONFIG_POWER_SEQ */
 
 #endif /* _LINUX_PWRSEQ_H */
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 08/12] usb: hub: Handle deferred probe
  2016-06-01  8:02 [PATCH v3 00/12] usb/mmc/power: Generic power sequence (and fix USB/LAN when TFTP booting) Krzysztof Kozlowski
                   ` (6 preceding siblings ...)
  2016-06-01  8:02 ` [PATCH v3 07/12] power: pwrseq: Add support for USB hubs with external power Krzysztof Kozlowski
@ 2016-06-01  8:02 ` Krzysztof Kozlowski
  2016-06-01  8:02 ` [PATCH v3 09/12] EXAMPLE CODE: usb: port: Parse pwrseq phandle from Device Tree Krzysztof Kozlowski
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 30+ messages in thread
From: Krzysztof Kozlowski @ 2016-06-01  8:02 UTC (permalink / raw)
  To: hzpeterchen, Ulf Hansson, Sebastian Reichel,
	Dmitry Eremin-Solenikov, David Woodhouse, Krzysztof Kozlowski,
	Javier Martinez Canillas, linux-kernel, linux-mmc, linux-pm,
	Alan Stern, linux-usb, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Kukjin Kim, devicetree,
	linux-arm-kernel, linux-samsung-soc
  Cc: Greg Kroah-Hartman, Bartlomiej Zolnierkiewicz

Add support for deferred probing to the usb hub.  Currently EPROBE_DEFER
does not exist in usb hub path but future patches will add it on the
port level.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com>
---
 drivers/usb/core/hub.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index bee13517676f..c421745b84aa 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1733,6 +1733,7 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
 	struct usb_endpoint_descriptor *endpoint;
 	struct usb_device *hdev;
 	struct usb_hub *hub;
+	int ret;
 
 	desc = intf->cur_altsetting;
 	hdev = interface_to_usbdev(intf);
@@ -1852,11 +1853,12 @@ descriptor_error:
 	if (id->driver_info & HUB_QUIRK_CHECK_PORT_AUTOSUSPEND)
 		hub->quirk_check_port_auto_suspend = 1;
 
-	if (hub_configure(hub, endpoint) >= 0)
+	ret = hub_configure(hub, endpoint);
+	if (ret >= 0)
 		return 0;
 
 	hub_disconnect(intf);
-	return -ENODEV;
+	return ret;
 }
 
 static int
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 09/12] EXAMPLE CODE: usb: port: Parse pwrseq phandle from Device Tree
  2016-06-01  8:02 [PATCH v3 00/12] usb/mmc/power: Generic power sequence (and fix USB/LAN when TFTP booting) Krzysztof Kozlowski
                   ` (7 preceding siblings ...)
  2016-06-01  8:02 ` [PATCH v3 08/12] usb: hub: Handle deferred probe Krzysztof Kozlowski
@ 2016-06-01  8:02 ` Krzysztof Kozlowski
  2016-06-01  8:57   ` Stephen Boyd
  2016-06-01  8:02 ` [PATCH v3 10/12] EXAMPLE CODE: usb: hub: Power sequence the ports on activation Krzysztof Kozlowski
                   ` (3 subsequent siblings)
  12 siblings, 1 reply; 30+ messages in thread
From: Krzysztof Kozlowski @ 2016-06-01  8:02 UTC (permalink / raw)
  To: hzpeterchen, Ulf Hansson, Sebastian Reichel,
	Dmitry Eremin-Solenikov, David Woodhouse, Krzysztof Kozlowski,
	Javier Martinez Canillas, linux-kernel, linux-mmc, linux-pm,
	Alan Stern, linux-usb, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Kukjin Kim, devicetree,
	linux-arm-kernel, linux-samsung-soc
  Cc: Greg Kroah-Hartman, Bartlomiej Zolnierkiewicz

Parse usb-pwrseq property from Device Tree to get the phandle to pwrseq
device.  The pwrseq device will be used by USB hub to cycle the power
before activating ports.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
 drivers/usb/core/hub.h  |  3 +++
 drivers/usb/core/port.c | 15 +++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
index 34c1a7e22aae..68ca89780d26 100644
--- a/drivers/usb/core/hub.h
+++ b/drivers/usb/core/hub.h
@@ -24,6 +24,8 @@
 #include <linux/usb/hcd.h>
 #include "usb.h"
 
+struct pwrseq;
+
 struct usb_hub {
 	struct device		*intfdev;	/* the "interface" device */
 	struct usb_device	*hdev;
@@ -101,6 +103,7 @@ struct usb_port {
 	struct usb_dev_state *port_owner;
 	struct usb_port *peer;
 	struct dev_pm_qos_request *req;
+	struct pwrseq *pwrseq;
 	enum usb_port_connect_type connect_type;
 	usb_port_location_t location;
 	struct mutex status_lock;
diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index 460c855be0d0..89b9bdfc7061 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -18,6 +18,8 @@
 
 #include <linux/slab.h>
 #include <linux/pm_qos.h>
+#include <linux/pwrseq.h>
+#include <linux/usb/of.h>
 
 #include "hub.h"
 
@@ -526,6 +528,14 @@ int usb_hub_create_port_device(struct usb_hub *hub, int port1)
 		return retval;
 	}
 
+	port_dev->dev.of_node = usb_of_get_child_node(hdev->dev.parent->of_node,
+						      port1);
+	port_dev->pwrseq = pwrseq_alloc(&port_dev->dev, "usb-pwrseq");
+	if (IS_ERR(port_dev->pwrseq)) {
+		device_unregister(&port_dev->dev);
+		return PTR_ERR(port_dev->pwrseq);
+	}
+
 	find_and_link_peer(hub, port1);
 
 	/*
@@ -567,8 +577,13 @@ void usb_hub_remove_port_device(struct usb_hub *hub, int port1)
 	struct usb_port *port_dev = hub->ports[port1 - 1];
 	struct usb_port *peer;
 
+	pwrseq_power_off(port_dev->pwrseq);
+
 	peer = port_dev->peer;
 	if (peer)
 		unlink_peers(port_dev, peer);
+
+	pwrseq_free(port_dev->pwrseq);
+	port_dev->pwrseq = NULL;
 	device_unregister(&port_dev->dev);
 }
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 10/12] EXAMPLE CODE: usb: hub: Power sequence the ports on activation
  2016-06-01  8:02 [PATCH v3 00/12] usb/mmc/power: Generic power sequence (and fix USB/LAN when TFTP booting) Krzysztof Kozlowski
                   ` (8 preceding siblings ...)
  2016-06-01  8:02 ` [PATCH v3 09/12] EXAMPLE CODE: usb: port: Parse pwrseq phandle from Device Tree Krzysztof Kozlowski
@ 2016-06-01  8:02 ` Krzysztof Kozlowski
  2016-06-01  8:02 ` [PATCH v3 11/12] ARM: dts: exynos: Switch the buck8 to GPIO mode on Odroid U3 Krzysztof Kozlowski
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 30+ messages in thread
From: Krzysztof Kozlowski @ 2016-06-01  8:02 UTC (permalink / raw)
  To: hzpeterchen, Ulf Hansson, Sebastian Reichel,
	Dmitry Eremin-Solenikov, David Woodhouse, Krzysztof Kozlowski,
	Javier Martinez Canillas, linux-kernel, linux-mmc, linux-pm,
	Alan Stern, linux-usb, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Kukjin Kim, devicetree,
	linux-arm-kernel, linux-samsung-soc
  Cc: Greg Kroah-Hartman, Bartlomiej Zolnierkiewicz

The autodetection of attached USB device might not work on certain
boards where the power is delivered externally.  These devices also might
require a hard reset.  Use pwrseq for that in USB hub.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
 drivers/usb/core/hub.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index c421745b84aa..46d9f9aedacc 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -26,6 +26,7 @@
 #include <linux/mutex.h>
 #include <linux/random.h>
 #include <linux/pm_qos.h>
+#include <linux/pwrseq.h>
 
 #include <asm/uaccess.h>
 #include <asm/byteorder.h>
@@ -1663,6 +1664,15 @@ static int hub_configure(struct usb_hub *hub,
 
 	usb_hub_adjust_deviceremovable(hdev, hub->descriptor);
 
+	/* FIXME: When do the pre-power-on? */
+	/*
+	for (i = 0; i < maxchild; i++)
+		pwrseq_pre_power_on(hub->ports[i]->pwrseq);
+	*/
+
+	for (i = 0; i < maxchild; i++)
+		pwrseq_post_power_on(hub->ports[i]->pwrseq);
+
 	hub_activate(hub, HUB_INIT);
 	return 0;
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 11/12] ARM: dts: exynos: Switch the buck8 to GPIO mode on Odroid U3
  2016-06-01  8:02 [PATCH v3 00/12] usb/mmc/power: Generic power sequence (and fix USB/LAN when TFTP booting) Krzysztof Kozlowski
                   ` (9 preceding siblings ...)
  2016-06-01  8:02 ` [PATCH v3 10/12] EXAMPLE CODE: usb: hub: Power sequence the ports on activation Krzysztof Kozlowski
@ 2016-06-01  8:02 ` Krzysztof Kozlowski
  2016-06-01  8:02 ` [PATCH v3 12/12] ARM: dts: exynos: Fix LAN and HUB after bootloader initialization " Krzysztof Kozlowski
  2016-06-06 20:43 ` [PATCH v3 00/12] usb/mmc/power: Generic power sequence (and fix USB/LAN when TFTP booting) Heiko Stübner
  12 siblings, 0 replies; 30+ messages in thread
From: Krzysztof Kozlowski @ 2016-06-01  8:02 UTC (permalink / raw)
  To: hzpeterchen, Ulf Hansson, Sebastian Reichel,
	Dmitry Eremin-Solenikov, David Woodhouse, Krzysztof Kozlowski,
	Javier Martinez Canillas, linux-kernel, linux-mmc, linux-pm,
	Alan Stern, linux-usb, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Kukjin Kim, devicetree,
	linux-arm-kernel, linux-samsung-soc
  Cc: Greg Kroah-Hartman, Bartlomiej Zolnierkiewicz

Switch the control of buck8 to GPIO mode. It is faster than I2C/register
mode and it is the easiest way to disable it (regulator state is a
logical OR state of GPIO and register value).

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com>
---
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index d73aa6c58fe3..31cdc036fda4 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -74,6 +74,7 @@
 	regulator-name = "BUCK8_P3V3";
 	regulator-min-microvolt = <3300000>;
 	regulator-max-microvolt = <3300000>;
+	maxim,ena-gpios = <&gpa1 1 GPIO_ACTIVE_HIGH>;
 };
 
 /* VDDQ for MSHC (eMMC card) */
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v3 12/12] ARM: dts: exynos: Fix LAN and HUB after bootloader initialization on Odroid U3
  2016-06-01  8:02 [PATCH v3 00/12] usb/mmc/power: Generic power sequence (and fix USB/LAN when TFTP booting) Krzysztof Kozlowski
                   ` (10 preceding siblings ...)
  2016-06-01  8:02 ` [PATCH v3 11/12] ARM: dts: exynos: Switch the buck8 to GPIO mode on Odroid U3 Krzysztof Kozlowski
@ 2016-06-01  8:02 ` Krzysztof Kozlowski
  2016-06-01 11:59   ` Peter Chen
  2016-06-06 20:43 ` [PATCH v3 00/12] usb/mmc/power: Generic power sequence (and fix USB/LAN when TFTP booting) Heiko Stübner
  12 siblings, 1 reply; 30+ messages in thread
From: Krzysztof Kozlowski @ 2016-06-01  8:02 UTC (permalink / raw)
  To: hzpeterchen, Ulf Hansson, Sebastian Reichel,
	Dmitry Eremin-Solenikov, David Woodhouse, Krzysztof Kozlowski,
	Javier Martinez Canillas, linux-kernel, linux-mmc, linux-pm,
	Alan Stern, linux-usb, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Kukjin Kim, devicetree,
	linux-arm-kernel, linux-samsung-soc
  Cc: Greg Kroah-Hartman, Bartlomiej Zolnierkiewicz

On Odroid U3 (Exynos4412-based) board if USB was initialized by
bootloader (in U-Boot "usb start" before tftpboot), the HUB (usb3503)
and LAN (smsc95xx) after after successful probing were not visible in the
system ("lsusb").

In such case the devices had to be fully reset before configuring.
Reset by GPIO (called RESET_N pin) and by RESET field in STCD register
in usb3503 HUB are not sufficient. Instead full reset has to be done by
disabling and enabling regulator.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 31cdc036fda4..23e30e4609df 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -99,11 +99,15 @@
 	clock-names = "refclk";
 	clocks = <&pmu_system_controller 0>;
 	refclk-frequency = <24000000>;
+
+	power-sequence;
+	ext-supply = <&buck8_reg>;
 };
 
 &ehci {
 	port@1 {
 		status = "okay";
+		usb-pwrseq = <&usb3503>;
 	};
 	port@2 {
 		status = "okay";
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 09/12] EXAMPLE CODE: usb: port: Parse pwrseq phandle from Device Tree
  2016-06-01  8:02 ` [PATCH v3 09/12] EXAMPLE CODE: usb: port: Parse pwrseq phandle from Device Tree Krzysztof Kozlowski
@ 2016-06-01  8:57   ` Stephen Boyd
  2016-06-01  9:06     ` Krzysztof Kozlowski
  2016-06-01 12:05     ` Peter Chen
  0 siblings, 2 replies; 30+ messages in thread
From: Stephen Boyd @ 2016-06-01  8:57 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Greg Kroah-Hartman, Bartlomiej Zolnierkiewicz, hzpeterchen,
	Ulf Hansson, Sebastian Reichel, Dmitry Eremin-Solenikov,
	David Woodhouse, Krzysztof Kozlowski, Javier Martinez Canillas,
	linux-kernel, linux-mmc, linux-pm, Alan Stern, linux-usb,
	Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Kukjin Kim, devicetree, linux-arm-kernel, linux-samsung-soc

Quoting Krzysztof Kozlowski (2016-06-01 01:02:18)
> Parse usb-pwrseq property from Device Tree to get the phandle to pwrseq
> device.  The pwrseq device will be used by USB hub to cycle the power
> before activating ports.
> 
> Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>

Drive by review comment.

I was hoping this would help me with a problem I'm having where I have a
hub (smsc4604) that needs to be taken out of reset before my HSIC
controller sends a USB reset to it, but it seems this is more about
doing some sort of power on sequence after enumeration?

> diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
> index 460c855be0d0..89b9bdfc7061 100644
> --- a/drivers/usb/core/port.c
> +++ b/drivers/usb/core/port.c
> @@ -18,6 +18,8 @@
>  
>  #include <linux/slab.h>
>  #include <linux/pm_qos.h>
> +#include <linux/pwrseq.h>
> +#include <linux/usb/of.h>
>  
>  #include "hub.h"
>  
> @@ -526,6 +528,14 @@ int usb_hub_create_port_device(struct usb_hub *hub, int port1)
>                 return retval;
>         }
>  
> +       port_dev->dev.of_node = usb_of_get_child_node(hdev->dev.parent->of_node,
> +                                                     port1);
> +       port_dev->pwrseq = pwrseq_alloc(&port_dev->dev, "usb-pwrseq");
> +       if (IS_ERR(port_dev->pwrseq)) {
> +               device_unregister(&port_dev->dev);
> +               return PTR_ERR(port_dev->pwrseq);

Are we certain that port_dev hasn't been freed at this point? We just
called device_unregister() on it, so it seems safer to save away the
return value before calling device_unregister() here.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 09/12] EXAMPLE CODE: usb: port: Parse pwrseq phandle from Device Tree
  2016-06-01  8:57   ` Stephen Boyd
@ 2016-06-01  9:06     ` Krzysztof Kozlowski
  2016-06-01 12:05     ` Peter Chen
  1 sibling, 0 replies; 30+ messages in thread
From: Krzysztof Kozlowski @ 2016-06-01  9:06 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Greg Kroah-Hartman, Bartlomiej Zolnierkiewicz, hzpeterchen,
	Ulf Hansson, Sebastian Reichel, Dmitry Eremin-Solenikov,
	David Woodhouse, Javier Martinez Canillas, linux-kernel,
	linux-mmc, linux-pm, Alan Stern, linux-usb, Rob Herring,
	Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala, Kukjin Kim,
	devicetree, linux-arm-kernel, linux-samsung-soc

On 06/01/2016 10:57 AM, Stephen Boyd wrote:
> Quoting Krzysztof Kozlowski (2016-06-01 01:02:18)
>> Parse usb-pwrseq property from Device Tree to get the phandle to pwrseq
>> device.  The pwrseq device will be used by USB hub to cycle the power
>> before activating ports.
>>
>> Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> 
> Drive by review comment.
> 
> I was hoping this would help me with a problem I'm having where I have a
> hub (smsc4604) that needs to be taken out of reset before my HSIC
> controller sends a USB reset to it, but it seems this is more about
> doing some sort of power on sequence after enumeration?

This example is not finished but from what you wrote, it might suit your
needs as well. The power sequence is done before enumeration because
without it, the device won't enumerate.

The exact power sequence for USB devices has to be still developed.
Comments are welcomed.

>> diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
>> index 460c855be0d0..89b9bdfc7061 100644
>> --- a/drivers/usb/core/port.c
>> +++ b/drivers/usb/core/port.c
>> @@ -18,6 +18,8 @@
>>  
>>  #include <linux/slab.h>
>>  #include <linux/pm_qos.h>
>> +#include <linux/pwrseq.h>
>> +#include <linux/usb/of.h>
>>  
>>  #include "hub.h"
>>  
>> @@ -526,6 +528,14 @@ int usb_hub_create_port_device(struct usb_hub *hub, int port1)
>>                 return retval;
>>         }
>>  
>> +       port_dev->dev.of_node = usb_of_get_child_node(hdev->dev.parent->of_node,
>> +                                                     port1);
>> +       port_dev->pwrseq = pwrseq_alloc(&port_dev->dev, "usb-pwrseq");
>> +       if (IS_ERR(port_dev->pwrseq)) {
>> +               device_unregister(&port_dev->dev);
>> +               return PTR_ERR(port_dev->pwrseq);
> 
> Are we certain that port_dev hasn't been freed at this point? We just
> called device_unregister() on it, so it seems safer to save away the
> return value before calling device_unregister() here.

Right, good point. Thanks for feedback.

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 12/12] ARM: dts: exynos: Fix LAN and HUB after bootloader initialization on Odroid U3
  2016-06-01  8:02 ` [PATCH v3 12/12] ARM: dts: exynos: Fix LAN and HUB after bootloader initialization " Krzysztof Kozlowski
@ 2016-06-01 11:59   ` Peter Chen
  2016-06-02  7:26     ` Krzysztof Kozlowski
  0 siblings, 1 reply; 30+ messages in thread
From: Peter Chen @ 2016-06-01 11:59 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Ulf Hansson, Sebastian Reichel, Dmitry Eremin-Solenikov,
	David Woodhouse, Javier Martinez Canillas, linux-kernel,
	linux-mmc, linux-pm, Alan Stern, linux-usb, Rob Herring,
	Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala, Kukjin Kim,
	devicetree, linux-arm-kernel, linux-samsung-soc,
	Greg Kroah-Hartman, Bartlomiej Zolnierkiewicz

On Wed, Jun 01, 2016 at 10:02:21AM +0200, Krzysztof Kozlowski wrote:
> On Odroid U3 (Exynos4412-based) board if USB was initialized by
> bootloader (in U-Boot "usb start" before tftpboot), the HUB (usb3503)
> and LAN (smsc95xx) after after successful probing were not visible in the
> system ("lsusb").
> 
> In such case the devices had to be fully reset before configuring.
> Reset by GPIO (called RESET_N pin) and by RESET field in STCD register
> in usb3503 HUB are not sufficient. Instead full reset has to be done by
> disabling and enabling regulator.
> 
> Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> ---
>  arch/arm/boot/dts/exynos4412-odroidu3.dts | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> index 31cdc036fda4..23e30e4609df 100644
> --- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
> +++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> @@ -99,11 +99,15 @@
>  	clock-names = "refclk";
>  	clocks = <&pmu_system_controller 0>;
>  	refclk-frequency = <24000000>;
> +
> +	power-sequence;
> +	ext-supply = <&buck8_reg>;
>  };
>  
>  &ehci {
>  	port@1 {
>  		status = "okay";
> +		usb-pwrseq = <&usb3503>;
>  	};
>  	port@2 {
>  		status = "okay";
> -- 
> 1.9.1
> 

The hub is under the port1, you may need to describe it
under the port@1, see below:
Documentation/devicetree/bindings/usb/usb-device.txt

If I get Rob's comments correctly, you may need to consider 
below MMC and USB device tree description together, it seems
hard for USB to use pwrseq driver, sorry for confusing you.

If rob can accept below USB device description, we have to
do it under USB. In future, if there is some suitable framework,
we can move it.

1. MMC device:
	usdhc3_pwrseq: usdhc3_pwrseq {
		compatible = "mmc-pwrseq-simple";
		reset-gpios = <&gpio4 5 GPIO_ACTIVE_LOW>, 	/* WL_REG_ON */
			      <&gpio4 7 GPIO_ACTIVE_LOW>, 	/* WL_HOSTWAKE */
			      <&gpio3 25 GPIO_ACTIVE_LOW>, 	/* BT_REG_ON */
			      <&gpio3 27 GPIO_ACTIVE_LOW>,	/* BT_HOSTWAKE */
			      <&gpio4 4 GPIO_ACTIVE_LOW>, 	/* BT_WAKE */
			      <&gpio4 6 GPIO_ACTIVE_LOW>; 	/* BT_RST_N */
	};

&usdhc3 {
	pinctrl-names = "default", "state_100mhz", "state_200mhz";
	pinctrl-0 = <&pinctrl_usdhc3>;
	pinctrl-1 = <&pinctrl_usdhc3_100mhz>;
	pinctrl-2 = <&pinctrl_usdhc3_200mhz>;
	bus-width = <4>;
	non-removable;
	keep-power-in-suspend;
	wakeup-source;
	mmc-pwrseq = <&usdhc3_pwrseq>;
	status = "okay";
};

2. USB device 

&usbotg1 {
	vbus-supply = <&reg_usb_otg1_vbus>;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_usb_otg1_id>;
	status = "okay";

	#address-cells = <1>;
	#size-cells = <0>;
	hub: genesys@1 {
		compatible = "usb5e3,608";
		reg = <1>;
		reset-gpios = <&gpio4 5 GPIO_ACTIVE_LOW>; /* hub reset pin */
		reset-duration-us = <10>;
		clocks = <&clks IMX6SX_CLK_CKO>;
	};
};

};
-- 

Best Regards,
Peter Chen

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 09/12] EXAMPLE CODE: usb: port: Parse pwrseq phandle from Device Tree
  2016-06-01  8:57   ` Stephen Boyd
  2016-06-01  9:06     ` Krzysztof Kozlowski
@ 2016-06-01 12:05     ` Peter Chen
  2016-06-01 18:16       ` Stephen Boyd
  1 sibling, 1 reply; 30+ messages in thread
From: Peter Chen @ 2016-06-01 12:05 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Krzysztof Kozlowski, Greg Kroah-Hartman,
	Bartlomiej Zolnierkiewicz, Ulf Hansson, Sebastian Reichel,
	Dmitry Eremin-Solenikov, David Woodhouse,
	Javier Martinez Canillas, linux-kernel, linux-mmc, linux-pm,
	Alan Stern, linux-usb, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Kukjin Kim, devicetree,
	linux-arm-kernel, linux-samsung-soc

On Wed, Jun 01, 2016 at 01:57:23AM -0700, Stephen Boyd wrote:
> Quoting Krzysztof Kozlowski (2016-06-01 01:02:18)
> > Parse usb-pwrseq property from Device Tree to get the phandle to pwrseq
> > device.  The pwrseq device will be used by USB hub to cycle the power
> > before activating ports.
> > 
> > Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> 
> Drive by review comment.
> 
> I was hoping this would help me with a problem I'm having where I have a
> hub (smsc4604) that needs to be taken out of reset before my HSIC
> controller sends a USB reset to it, but it seems this is more about
> doing some sort of power on sequence after enumeration?
> 

No, you may need to do reset before enumeration, the general purpose of
reset is eliminate unstable hardware state, and let the controller find
the device.

Try to do it at bootloader to see if it works for you.

-- 

Best Regards,
Peter Chen

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 09/12] EXAMPLE CODE: usb: port: Parse pwrseq phandle from Device Tree
  2016-06-01 12:05     ` Peter Chen
@ 2016-06-01 18:16       ` Stephen Boyd
  2016-06-02  1:24         ` Peter Chen
  0 siblings, 1 reply; 30+ messages in thread
From: Stephen Boyd @ 2016-06-01 18:16 UTC (permalink / raw)
  To: Peter Chen
  Cc: Krzysztof Kozlowski, Greg Kroah-Hartman,
	Bartlomiej Zolnierkiewicz, Ulf Hansson, Sebastian Reichel,
	Dmitry Eremin-Solenikov, David Woodhouse,
	Javier Martinez Canillas, linux-kernel, linux-mmc, linux-pm,
	Alan Stern, linux-usb, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Kukjin Kim, devicetree,
	linux-arm-kernel, linux-samsung-soc

Quoting Peter Chen (2016-06-01 05:05:20)
> On Wed, Jun 01, 2016 at 01:57:23AM -0700, Stephen Boyd wrote:
> > Quoting Krzysztof Kozlowski (2016-06-01 01:02:18)
> > > Parse usb-pwrseq property from Device Tree to get the phandle to pwrseq
> > > device.  The pwrseq device will be used by USB hub to cycle the power
> > > before activating ports.
> > > 
> > > Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> > 
> > Drive by review comment.
> > 
> > I was hoping this would help me with a problem I'm having where I have a
> > hub (smsc4604) that needs to be taken out of reset before my HSIC
> > controller sends a USB reset to it, but it seems this is more about
> > doing some sort of power on sequence after enumeration?
> > 
> 
> No, you may need to do reset before enumeration, the general purpose of
> reset is eliminate unstable hardware state, and let the controller find
> the device.
> 
> Try to do it at bootloader to see if it works for you.
> 

Sorry the bootloader doesn't do this so that doesn't work for me.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 09/12] EXAMPLE CODE: usb: port: Parse pwrseq phandle from Device Tree
  2016-06-01 18:16       ` Stephen Boyd
@ 2016-06-02  1:24         ` Peter Chen
  0 siblings, 0 replies; 30+ messages in thread
From: Peter Chen @ 2016-06-02  1:24 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Krzysztof Kozlowski, Greg Kroah-Hartman,
	Bartlomiej Zolnierkiewicz, Ulf Hansson, Sebastian Reichel,
	Dmitry Eremin-Solenikov, David Woodhouse,
	Javier Martinez Canillas, linux-kernel, linux-mmc, linux-pm,
	Alan Stern, linux-usb, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Kukjin Kim, devicetree,
	linux-arm-kernel, linux-samsung-soc

On Wed, Jun 01, 2016 at 11:16:34AM -0700, Stephen Boyd wrote:
> Quoting Peter Chen (2016-06-01 05:05:20)
> > On Wed, Jun 01, 2016 at 01:57:23AM -0700, Stephen Boyd wrote:
> > > Quoting Krzysztof Kozlowski (2016-06-01 01:02:18)
> > > > Parse usb-pwrseq property from Device Tree to get the phandle to pwrseq
> > > > device.  The pwrseq device will be used by USB hub to cycle the power
> > > > before activating ports.
> > > > 
> > > > Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> > > 
> > > Drive by review comment.
> > > 
> > > I was hoping this would help me with a problem I'm having where I have a
> > > hub (smsc4604) that needs to be taken out of reset before my HSIC
> > > controller sends a USB reset to it, but it seems this is more about
> > > doing some sort of power on sequence after enumeration?
> > > 
> > 
> > No, you may need to do reset before enumeration, the general purpose of
> > reset is eliminate unstable hardware state, and let the controller find
> > the device.
> > 
> > Try to do it at bootloader to see if it works for you.
> > 
> 
> Sorry the bootloader doesn't do this so that doesn't work for me.

I mean try to see if the HUB can work if you reset it at bootloader.
If it works, it means you need to do reset before enumeration, and you
don't need to do anything after enumeration.

-- 

Best Regards,
Peter Chen

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 12/12] ARM: dts: exynos: Fix LAN and HUB after bootloader initialization on Odroid U3
  2016-06-01 11:59   ` Peter Chen
@ 2016-06-02  7:26     ` Krzysztof Kozlowski
  2016-06-02  7:58       ` Peter Chen
  0 siblings, 1 reply; 30+ messages in thread
From: Krzysztof Kozlowski @ 2016-06-02  7:26 UTC (permalink / raw)
  To: Peter Chen
  Cc: Ulf Hansson, Sebastian Reichel, Dmitry Eremin-Solenikov,
	David Woodhouse, Javier Martinez Canillas, linux-kernel,
	linux-mmc, linux-pm, Alan Stern, linux-usb, Rob Herring,
	Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala, Kukjin Kim,
	devicetree, linux-arm-kernel, linux-samsung-soc,
	Greg Kroah-Hartman, Bartlomiej Zolnierkiewicz

On 06/01/2016 01:59 PM, Peter Chen wrote:
> On Wed, Jun 01, 2016 at 10:02:21AM +0200, Krzysztof Kozlowski wrote:
>> On Odroid U3 (Exynos4412-based) board if USB was initialized by
>> bootloader (in U-Boot "usb start" before tftpboot), the HUB (usb3503)
>> and LAN (smsc95xx) after after successful probing were not visible in the
>> system ("lsusb").
>>
>> In such case the devices had to be fully reset before configuring.
>> Reset by GPIO (called RESET_N pin) and by RESET field in STCD register
>> in usb3503 HUB are not sufficient. Instead full reset has to be done by
>> disabling and enabling regulator.
>>
>> Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
>> ---
>>  arch/arm/boot/dts/exynos4412-odroidu3.dts | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
>> index 31cdc036fda4..23e30e4609df 100644
>> --- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
>> +++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
>> @@ -99,11 +99,15 @@
>>  	clock-names = "refclk";
>>  	clocks = <&pmu_system_controller 0>;
>>  	refclk-frequency = <24000000>;
>> +
>> +	power-sequence;
>> +	ext-supply = <&buck8_reg>;
>>  };
>>  
>>  &ehci {
>>  	port@1 {
>>  		status = "okay";
>> +		usb-pwrseq = <&usb3503>;
>>  	};
>>  	port@2 {
>>  		status = "okay";
>> -- 
>> 1.9.1
>>
> 
> The hub is under the port1, you may need to describe it
> under the port@1, see below:
> Documentation/devicetree/bindings/usb/usb-device.txt

My configuration is a little bit different than yours.

In my case I have a USB hub (usb3503) which is also a a i2c device
because it has to be configured through I2C.

I can add the power-sequence properties to the I2C node or as you
pointed under port using the vendor-product-id compatible. In the first
option: not many USB changes are needed. It works for me, at least as a
proof of concept.

The second solution: currently it does not work because the USB device
does not get enumerated before the power sequence begins. It would be
great if you could implement this on USB side.

> 
> If I get Rob's comments correctly, you may need to consider 
> below MMC and USB device tree description together, it seems
> hard for USB to use pwrseq driver, sorry for confusing you.
> 
> If rob can accept below USB device description, we have to
> do it under USB. In future, if there is some suitable framework,
> we can move it.
> 
> 1. MMC device:
> 	usdhc3_pwrseq: usdhc3_pwrseq {
> 		compatible = "mmc-pwrseq-simple";
> 		reset-gpios = <&gpio4 5 GPIO_ACTIVE_LOW>, 	/* WL_REG_ON */
> 			      <&gpio4 7 GPIO_ACTIVE_LOW>, 	/* WL_HOSTWAKE */
> 			      <&gpio3 25 GPIO_ACTIVE_LOW>, 	/* BT_REG_ON */
> 			      <&gpio3 27 GPIO_ACTIVE_LOW>,	/* BT_HOSTWAKE */
> 			      <&gpio4 4 GPIO_ACTIVE_LOW>, 	/* BT_WAKE */
> 			      <&gpio4 6 GPIO_ACTIVE_LOW>; 	/* BT_RST_N */
> 	};
> 
> &usdhc3 {
> 	pinctrl-names = "default", "state_100mhz", "state_200mhz";
> 	pinctrl-0 = <&pinctrl_usdhc3>;
> 	pinctrl-1 = <&pinctrl_usdhc3_100mhz>;
> 	pinctrl-2 = <&pinctrl_usdhc3_200mhz>;
> 	bus-width = <4>;
> 	non-removable;
> 	keep-power-in-suspend;
> 	wakeup-source;
> 	mmc-pwrseq = <&usdhc3_pwrseq>;
> 	status = "okay";
> };
> 
> 2. USB device 
> 
> &usbotg1 {
> 	vbus-supply = <&reg_usb_otg1_vbus>;
> 	pinctrl-names = "default";
> 	pinctrl-0 = <&pinctrl_usb_otg1_id>;
> 	status = "okay";
> 
> 	#address-cells = <1>;
> 	#size-cells = <0>;
> 	hub: genesys@1 {
> 		compatible = "usb5e3,608";
> 		reg = <1>;
> 		reset-gpios = <&gpio4 5 GPIO_ACTIVE_LOW>; /* hub reset pin */
> 		reset-duration-us = <10>;
> 		clocks = <&clks IMX6SX_CLK_CKO>;
> 	};

Yes, that looks like what Rob wanted... Do you plan to work on it? The
power sequence is needed before device is enumerated.

BTW, if you would like to play with the patchset, it is here:
repo:   https://github.com/krzk/linux
branch: for-next/odroid-u3-usb3503-lan-boot-fixes-v3

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 12/12] ARM: dts: exynos: Fix LAN and HUB after bootloader initialization on Odroid U3
  2016-06-02  7:26     ` Krzysztof Kozlowski
@ 2016-06-02  7:58       ` Peter Chen
  0 siblings, 0 replies; 30+ messages in thread
From: Peter Chen @ 2016-06-02  7:58 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Ulf Hansson, Sebastian Reichel, Dmitry Eremin-Solenikov,
	David Woodhouse, Javier Martinez Canillas, linux-kernel,
	linux-mmc, linux-pm, Alan Stern, linux-usb, Rob Herring,
	Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala, Kukjin Kim,
	devicetree, linux-arm-kernel, linux-samsung-soc,
	Greg Kroah-Hartman, Bartlomiej Zolnierkiewicz

On Thu, Jun 02, 2016 at 09:26:57AM +0200, Krzysztof Kozlowski wrote:
> On 06/01/2016 01:59 PM, Peter Chen wrote:
> > On Wed, Jun 01, 2016 at 10:02:21AM +0200, Krzysztof Kozlowski wrote:
> >> On Odroid U3 (Exynos4412-based) board if USB was initialized by
> >> bootloader (in U-Boot "usb start" before tftpboot), the HUB (usb3503)
> >> and LAN (smsc95xx) after after successful probing were not visible in the
> >> system ("lsusb").
> >>
> >> In such case the devices had to be fully reset before configuring.
> >> Reset by GPIO (called RESET_N pin) and by RESET field in STCD register
> >> in usb3503 HUB are not sufficient. Instead full reset has to be done by
> >> disabling and enabling regulator.
> >>
> >> Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> >> ---
> >>  arch/arm/boot/dts/exynos4412-odroidu3.dts | 4 ++++
> >>  1 file changed, 4 insertions(+)
> >>
> >> diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> >> index 31cdc036fda4..23e30e4609df 100644
> >> --- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
> >> +++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> >> @@ -99,11 +99,15 @@
> >>  	clock-names = "refclk";
> >>  	clocks = <&pmu_system_controller 0>;
> >>  	refclk-frequency = <24000000>;
> >> +
> >> +	power-sequence;
> >> +	ext-supply = <&buck8_reg>;
> >>  };
> >>  
> >>  &ehci {
> >>  	port@1 {
> >>  		status = "okay";
> >> +		usb-pwrseq = <&usb3503>;
> >>  	};
> >>  	port@2 {
> >>  		status = "okay";
> >> -- 
> >> 1.9.1
> >>
> > 
> > The hub is under the port1, you may need to describe it
> > under the port@1, see below:
> > Documentation/devicetree/bindings/usb/usb-device.txt
> 
> My configuration is a little bit different than yours.
> 
> In my case I have a USB hub (usb3503) which is also a a i2c device
> because it has to be configured through I2C.
> 
> I can add the power-sequence properties to the I2C node or as you
> pointed under port using the vendor-product-id compatible. In the first
> option: not many USB changes are needed. It works for me, at least as a
> proof of concept.
> 
> The second solution: currently it does not work because the USB device
> does not get enumerated before the power sequence begins. It would be
> great if you could implement this on USB side.

Well, not matter which solution, the USB device can't be enumerated
without power sequence. For the #2 solution, it just handles all
gpios under dts before the enumeration at USB code.

> 
> > 
> > If I get Rob's comments correctly, you may need to consider 
> > below MMC and USB device tree description together, it seems
> > hard for USB to use pwrseq driver, sorry for confusing you.
> > 
> > If rob can accept below USB device description, we have to
> > do it under USB. In future, if there is some suitable framework,
> > we can move it.
> > 
> > 1. MMC device:
> > 	usdhc3_pwrseq: usdhc3_pwrseq {
> > 		compatible = "mmc-pwrseq-simple";
> > 		reset-gpios = <&gpio4 5 GPIO_ACTIVE_LOW>, 	/* WL_REG_ON */
> > 			      <&gpio4 7 GPIO_ACTIVE_LOW>, 	/* WL_HOSTWAKE */
> > 			      <&gpio3 25 GPIO_ACTIVE_LOW>, 	/* BT_REG_ON */
> > 			      <&gpio3 27 GPIO_ACTIVE_LOW>,	/* BT_HOSTWAKE */
> > 			      <&gpio4 4 GPIO_ACTIVE_LOW>, 	/* BT_WAKE */
> > 			      <&gpio4 6 GPIO_ACTIVE_LOW>; 	/* BT_RST_N */
> > 	};
> > 
> > &usdhc3 {
> > 	pinctrl-names = "default", "state_100mhz", "state_200mhz";
> > 	pinctrl-0 = <&pinctrl_usdhc3>;
> > 	pinctrl-1 = <&pinctrl_usdhc3_100mhz>;
> > 	pinctrl-2 = <&pinctrl_usdhc3_200mhz>;
> > 	bus-width = <4>;
> > 	non-removable;
> > 	keep-power-in-suspend;
> > 	wakeup-source;
> > 	mmc-pwrseq = <&usdhc3_pwrseq>;
> > 	status = "okay";
> > };
> > 
> > 2. USB device 
> > 
> > &usbotg1 {
> > 	vbus-supply = <&reg_usb_otg1_vbus>;
> > 	pinctrl-names = "default";
> > 	pinctrl-0 = <&pinctrl_usb_otg1_id>;
> > 	status = "okay";
> > 
> > 	#address-cells = <1>;
> > 	#size-cells = <0>;
> > 	hub: genesys@1 {
> > 		compatible = "usb5e3,608";
> > 		reg = <1>;
> > 		reset-gpios = <&gpio4 5 GPIO_ACTIVE_LOW>; /* hub reset pin */
> > 		reset-duration-us = <10>;
> > 		clocks = <&clks IMX6SX_CLK_CKO>;
> > 	};
> 
> Yes, that looks like what Rob wanted... Do you plan to work on it? The
> power sequence is needed before device is enumerated.
> 

Ok, I will work on it.

-- 

Best Regards,
Peter Chen

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 06/12] power: pwrseq: simple: Add support for regulator and generic property
  2016-06-01  8:02 ` [PATCH v3 06/12] power: pwrseq: simple: Add support for regulator and generic property Krzysztof Kozlowski
@ 2016-06-03  2:02   ` Rob Herring
  2016-06-03 12:35     ` Krzysztof Kozlowski
  2016-06-07  9:29     ` Krzysztof Kozlowski
  0 siblings, 2 replies; 30+ messages in thread
From: Rob Herring @ 2016-06-03  2:02 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: hzpeterchen, Ulf Hansson, Sebastian Reichel,
	Dmitry Eremin-Solenikov, David Woodhouse,
	Javier Martinez Canillas, linux-kernel, linux-mmc, linux-pm,
	Alan Stern, linux-usb, Pawel Moll, Mark Rutland, Ian Campbell,
	Kumar Gala, Kukjin Kim, devicetree, linux-arm-kernel,
	linux-samsung-soc, Greg Kroah-Hartman, Bartlomiej Zolnierkiewicz

On Wed, Jun 01, 2016 at 10:02:15AM +0200, Krzysztof Kozlowski wrote:
> Some devices need real hard-reset by cutting the power.  During power
> sequence turn off and on the regulator, if it is provided.
> 
> Additionally add support for instantiating the pwrseq-simple device on a
> generic property 'power-sequence'.  The device will attach itself to the
> node containing the property and parse the node's properties like
> reset-gpios, ext-supply etc.
> 
> Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> ---
>  .../bindings/power/pwrseq/pwrseq-simple.txt        | 29 +++++++-
>  drivers/power/pwrseq/pwrseq_simple.c               | 85 +++++++++++++++++++++-
>  2 files changed, 107 insertions(+), 7 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/power/pwrseq/pwrseq-simple.txt b/Documentation/devicetree/bindings/power/pwrseq/pwrseq-simple.txt
> index ce0e76749671..a8c3f13ee83f 100644
> --- a/Documentation/devicetree/bindings/power/pwrseq/pwrseq-simple.txt
> +++ b/Documentation/devicetree/bindings/power/pwrseq/pwrseq-simple.txt
> @@ -1,11 +1,17 @@
> -* The simple MMC power sequence provider
> +* The simple power sequence provider
>  
> -The purpose of the simple MMC power sequence provider is to supports a set of
> +The purpose of the simple power sequence provider is to supports a set of
>  common properties between various SOC designs. It thus enables us to use the
>  same provider for several SOC designs.
>  
> -Required properties:
> -- compatible : contains "mmc-pwrseq-simple".
> +The driver supports two types of bindings:
> +1. Separate node
> +   Required properties:
> +   - compatible : contains "mmc-pwrseq-simple".

Please note that this is not recommended for new users.

> +
> +2. Property for any node
> +   Required properties:
> +   - power-sequence
>  
>  Optional properties:
>  - reset-gpios : contains a list of GPIO specifiers. The reset GPIOs are asserted
> @@ -16,6 +22,7 @@ Optional properties:
>    See ../clocks/clock-bindings.txt for details.
>  - clock-names : Must include the following entry:
>    "ext_clock" (External clock provided to the card).
> +- ext-supply : External regulator supply

What happens when there are 2 supplies?

I'd prefer the name not be genericish and use the real supply names. 
Then the power seq code should just turn on all supplies it finds. If 
the order or timing to turn on matters, then sorry, no generic sequence.

>  
>  Example:
>  
> @@ -24,4 +31,18 @@ Example:
>  		reset-gpios = <&gpio1 12 GPIO_ACTIVE_LOW>;
>  		clocks = <&clk_32768_ck>;
>  		clock-names = "ext_clock";
> +		ext-supply = <&buck8>;
>  	}
> +
> +	usb3503@08 {
> +		compatible = "smsc,usb3503";
> +		reg = <0x08>;
> +
> +		intn-gpios = <&gpx3 0 GPIO_ACTIVE_HIGH>;
> +		connect-gpios = <&gpx3 4 GPIO_ACTIVE_HIGH>;
> +		reset-gpios = <&gpx3 5 GPIO_ACTIVE_HIGH>;
> +		initial-mode = <1>;
> +
> +		power-sequence;
> +		ext-supply = <&buck8_reg>;
> +	};

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 06/12] power: pwrseq: simple: Add support for regulator and generic property
  2016-06-03  2:02   ` Rob Herring
@ 2016-06-03 12:35     ` Krzysztof Kozlowski
  2016-06-06  3:22       ` Peter Chen
  2016-06-07  9:29     ` Krzysztof Kozlowski
  1 sibling, 1 reply; 30+ messages in thread
From: Krzysztof Kozlowski @ 2016-06-03 12:35 UTC (permalink / raw)
  To: Rob Herring
  Cc: hzpeterchen, Ulf Hansson, Sebastian Reichel,
	Dmitry Eremin-Solenikov, David Woodhouse,
	Javier Martinez Canillas, linux-kernel, linux-mmc, linux-pm,
	Alan Stern, linux-usb, Pawel Moll, Mark Rutland, Ian Campbell,
	Kumar Gala, Kukjin Kim, devicetree, linux-arm-kernel,
	linux-samsung-soc, Greg Kroah-Hartman, Bartlomiej Zolnierkiewicz

On 06/03/2016 04:02 AM, Rob Herring wrote:
> On Wed, Jun 01, 2016 at 10:02:15AM +0200, Krzysztof Kozlowski wrote:
>> Some devices need real hard-reset by cutting the power.  During power
>> sequence turn off and on the regulator, if it is provided.
>>
>> Additionally add support for instantiating the pwrseq-simple device on a
>> generic property 'power-sequence'.  The device will attach itself to the
>> node containing the property and parse the node's properties like
>> reset-gpios, ext-supply etc.
>>
>> Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
>> ---
>>  .../bindings/power/pwrseq/pwrseq-simple.txt        | 29 +++++++-
>>  drivers/power/pwrseq/pwrseq_simple.c               | 85 +++++++++++++++++++++-
>>  2 files changed, 107 insertions(+), 7 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/power/pwrseq/pwrseq-simple.txt b/Documentation/devicetree/bindings/power/pwrseq/pwrseq-simple.txt
>> index ce0e76749671..a8c3f13ee83f 100644
>> --- a/Documentation/devicetree/bindings/power/pwrseq/pwrseq-simple.txt
>> +++ b/Documentation/devicetree/bindings/power/pwrseq/pwrseq-simple.txt
>> @@ -1,11 +1,17 @@
>> -* The simple MMC power sequence provider
>> +* The simple power sequence provider
>>  
>> -The purpose of the simple MMC power sequence provider is to supports a set of
>> +The purpose of the simple power sequence provider is to supports a set of
>>  common properties between various SOC designs. It thus enables us to use the
>>  same provider for several SOC designs.
>>  
>> -Required properties:
>> -- compatible : contains "mmc-pwrseq-simple".
>> +The driver supports two types of bindings:
>> +1. Separate node
>> +   Required properties:
>> +   - compatible : contains "mmc-pwrseq-simple".
> 
> Please note that this is not recommended for new users.

Sure.

> 
>> +
>> +2. Property for any node
>> +   Required properties:
>> +   - power-sequence
>>  
>>  Optional properties:
>>  - reset-gpios : contains a list of GPIO specifiers. The reset GPIOs are asserted
>> @@ -16,6 +22,7 @@ Optional properties:
>>    See ../clocks/clock-bindings.txt for details.
>>  - clock-names : Must include the following entry:
>>    "ext_clock" (External clock provided to the card).
>> +- ext-supply : External regulator supply
> 
> What happens when there are 2 supplies?
> 
> I'd prefer the name not be genericish and use the real supply names. 
> Then the power seq code should just turn on all supplies it finds. If 
> the order or timing to turn on matters, then sorry, no generic sequence.

Understood. I'll change the code to use any supply.

As for the genericness of this approach, Sylwester Nawrocki pointed an
old thread:
[PATCH v6 0/4] Runtime Interpreted Power Sequences
https://lkml.org/lkml/2012/9/12/127

How do you like that approach?

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 06/12] power: pwrseq: simple: Add support for regulator and generic property
  2016-06-03 12:35     ` Krzysztof Kozlowski
@ 2016-06-06  3:22       ` Peter Chen
  0 siblings, 0 replies; 30+ messages in thread
From: Peter Chen @ 2016-06-06  3:22 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Rob Herring, Ulf Hansson, Sebastian Reichel,
	Dmitry Eremin-Solenikov, David Woodhouse,
	Javier Martinez Canillas, linux-kernel, linux-mmc, linux-pm,
	Alan Stern, linux-usb, Pawel Moll, Mark Rutland, Ian Campbell,
	Kumar Gala, Kukjin Kim, devicetree, linux-arm-kernel,
	linux-samsung-soc, Greg Kroah-Hartman, Bartlomiej Zolnierkiewicz

On Fri, Jun 03, 2016 at 02:35:08PM +0200, Krzysztof Kozlowski wrote:
> On 06/03/2016 04:02 AM, Rob Herring wrote:
> > On Wed, Jun 01, 2016 at 10:02:15AM +0200, Krzysztof Kozlowski wrote:
> >> Some devices need real hard-reset by cutting the power.  During power
> >> sequence turn off and on the regulator, if it is provided.
> >>
> >> Additionally add support for instantiating the pwrseq-simple device on a
> >> generic property 'power-sequence'.  The device will attach itself to the
> >> node containing the property and parse the node's properties like
> >> reset-gpios, ext-supply etc.
> >>
> >> Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> >> ---
> >>  .../bindings/power/pwrseq/pwrseq-simple.txt        | 29 +++++++-
> >>  drivers/power/pwrseq/pwrseq_simple.c               | 85 +++++++++++++++++++++-
> >>  2 files changed, 107 insertions(+), 7 deletions(-)
> >>
> >> diff --git a/Documentation/devicetree/bindings/power/pwrseq/pwrseq-simple.txt b/Documentation/devicetree/bindings/power/pwrseq/pwrseq-simple.txt
> >> index ce0e76749671..a8c3f13ee83f 100644
> >> --- a/Documentation/devicetree/bindings/power/pwrseq/pwrseq-simple.txt
> >> +++ b/Documentation/devicetree/bindings/power/pwrseq/pwrseq-simple.txt
> >> @@ -1,11 +1,17 @@
> >> -* The simple MMC power sequence provider
> >> +* The simple power sequence provider
> >>  
> >> -The purpose of the simple MMC power sequence provider is to supports a set of
> >> +The purpose of the simple power sequence provider is to supports a set of
> >>  common properties between various SOC designs. It thus enables us to use the
> >>  same provider for several SOC designs.
> >>  
> >> -Required properties:
> >> -- compatible : contains "mmc-pwrseq-simple".
> >> +The driver supports two types of bindings:
> >> +1. Separate node
> >> +   Required properties:
> >> +   - compatible : contains "mmc-pwrseq-simple".
> > 
> > Please note that this is not recommended for new users.
> 
> Sure.
> 
> > 
> >> +
> >> +2. Property for any node
> >> +   Required properties:
> >> +   - power-sequence
> >>  
> >>  Optional properties:
> >>  - reset-gpios : contains a list of GPIO specifiers. The reset GPIOs are asserted
> >> @@ -16,6 +22,7 @@ Optional properties:
> >>    See ../clocks/clock-bindings.txt for details.
> >>  - clock-names : Must include the following entry:
> >>    "ext_clock" (External clock provided to the card).
> >> +- ext-supply : External regulator supply
> > 
> > What happens when there are 2 supplies?
> > 
> > I'd prefer the name not be genericish and use the real supply names. 
> > Then the power seq code should just turn on all supplies it finds. If 
> > the order or timing to turn on matters, then sorry, no generic sequence.
> 
> Understood. I'll change the code to use any supply.
> 
> As for the genericness of this approach, Sylwester Nawrocki pointed an
> old thread:
> [PATCH v6 0/4] Runtime Interpreted Power Sequences
> https://lkml.org/lkml/2012/9/12/127
> 
> How do you like that approach?
> 

Rob, I am trying to implement the dts layout you suggested (see below),
but I find it is very hard to it due to the device is still not created,
without device, it is hard to manage the resources under this device (
Eg, de-initialization for probe deferral case). So, a common driver
is suitable for this power sequence case.

&usbotg1 {
        vbus-supply = <&reg_usb_otg1_vbus>;
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_usb_otg1_id>;
        status = "okay";

        #address-cells = <1>;
        #size-cells = <0>;
        hub: genesys@1 {
                compatible = "usb5e3,608";
                reg = <1>;
                reset-gpios = <&gpio4 5 GPIO_ACTIVE_LOW>; /* hub reset pin */
                reset-duration-us = <10>;
                clocks = <&clks IMX6SX_CLK_CKO>;
        };
};

-- 

Best Regards,
Peter Chen

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 00/12] usb/mmc/power: Generic power sequence (and fix USB/LAN when TFTP booting)
  2016-06-01  8:02 [PATCH v3 00/12] usb/mmc/power: Generic power sequence (and fix USB/LAN when TFTP booting) Krzysztof Kozlowski
                   ` (11 preceding siblings ...)
  2016-06-01  8:02 ` [PATCH v3 12/12] ARM: dts: exynos: Fix LAN and HUB after bootloader initialization " Krzysztof Kozlowski
@ 2016-06-06 20:43 ` Heiko Stübner
  2016-06-07  6:03   ` Krzysztof Kozlowski
  12 siblings, 1 reply; 30+ messages in thread
From: Heiko Stübner @ 2016-06-06 20:43 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: hzpeterchen, Ulf Hansson, Sebastian Reichel,
	Dmitry Eremin-Solenikov, David Woodhouse,
	Javier Martinez Canillas, linux-kernel, linux-mmc, linux-pm,
	Alan Stern, linux-usb, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Kukjin Kim, devicetree,
	linux-arm-kernel, linux-samsung-soc, Greg Kroah-Hartman,
	Bartlomiej Zolnierkiewicz

Hi,

Am Mittwoch, 1. Juni 2016, 10:02:09 schrieb Krzysztof Kozlowski:
> My third approach for a USB power sequence which fixes usb3503+lan
> on Odroid U3 board if it was initialized by bootloader
> (e.g. for TFTP boot).

I was just tackling a similar bringup problem regarding an embedded usb hub 
and usb-sata bridge and stumbled upon this series.

While on my (rockchip-)boards it's always "just" a reset pin that needs 
handling, this series looks like it would solve exactly that problem in a very 
nice way.

So while I cannot provide any meaningful insight right now, it would be cool 
if you could keep me in the loop, as I'm really looking forward to this series 
progressing.


Thanks
Heiko


> Changes since v2
> ================
> 1. Add Javier's reviewed-by tags. Address some comments.
> 2. Re-use existing properties for GPIOs etc by pwrseq-simple
>    driver.  New property is still added: "power-sequence".
>    I tried to address and do according to Rob's comments.
> 
>    Please look at patch 6/12 ("power: pwrseq: simple: Add support
>    for regulator and generic property") for bindings and the
>    new code around matching "power-sequence" property.
> 
> 3. I marked the usb code as "EXAMPLE" because that part
>    is left to Peter Chen.
> 
> 
> Problem
> =======
> When Odroid U3 (usb3503 + smsc95xx + max77686) boots from network (TFTP),
> the usb3503 and LAN smsc95xx do not show up in "lsusb". Hard-reset
> is required, e.g. by suspend to RAM. The actual TFTP boot does
> not have to happen. Just "usb start" from U-Boot is sufficient.
> 
> From the schematics, the regulator is a supply only to LAN, however
> without toggling it off/on, the usb3503 hub won appear neither.
> 
> 
> Solution
> ========
> This is very similar to the MMC pwrseq behavior so the idea is to:
> 1. Move MMC pwrseq drivers to generic place,
> 2. Extend the pwrseq-simple with regulator toggling,
> 3. Add support to USB hub and port core for pwrseq,
> 4. Toggle the regulator when needed.
> 
> Best regards,
> Krzysztof
> 
> Krzysztof Kozlowski (12):
>   power/mmc: Move pwrseq drivers to power/pwrseq
>   MAINTAINERS: Retain Ulf Hansson as the same maintainer of pwrseq
>   power: pwrseq: Enable COMPILE_TEST for drivers
>   power: pwrseq: Remove mmc prefix from mmc_pwrseq
>   power: pwrseq: Generalize mmc_pwrseq operations by removing mmc prefix
>   power: pwrseq: simple: Add support for regulator and generic property
>   power: pwrseq: Add support for USB hubs with external power
>   usb: hub: Handle deferred probe
>   EXAMPLE CODE: usb: port: Parse pwrseq phandle from Device Tree
>   EXAMPLE CODE: usb: hub: Power sequence the ports on activation
>   ARM: dts: exynos: Switch the buck8 to GPIO mode on Odroid U3
>   ARM: dts: exynos: Fix LAN and HUB after bootloader initialization on
>     Odroid U3
> 
>  .../pwrseq/pwrseq-emmc.txt}                        |   0
>  .../pwrseq/pwrseq-simple.txt}                      |  29 +++-
>  MAINTAINERS                                        |   9 ++
>  arch/arm/boot/dts/exynos4412-odroidu3.dts          |   5 +
>  drivers/mmc/Kconfig                                |   2 -
>  drivers/mmc/core/Makefile                          |   3 -
>  drivers/mmc/core/core.c                            |   8 +-
>  drivers/mmc/core/host.c                            |   2 +-
>  drivers/mmc/core/pwrseq.c                          | 110 ---------------
>  drivers/mmc/core/pwrseq.h                          |  52 -------
>  drivers/power/Kconfig                              |   1 +
>  drivers/power/Makefile                             |   1 +
>  drivers/{mmc/core => power/pwrseq}/Kconfig         |  22 ++-
>  drivers/power/pwrseq/Makefile                      |   3 +
>  drivers/power/pwrseq/pwrseq.c                      | 153
> +++++++++++++++++++++ drivers/{mmc/core => power/pwrseq}/pwrseq_emmc.c   | 
> 17 +--
>  drivers/{mmc/core => power/pwrseq}/pwrseq_simple.c | 110 ++++++++++++---
>  drivers/usb/core/hub.c                             |  16 ++-
>  drivers/usb/core/hub.h                             |   3 +
>  drivers/usb/core/port.c                            |  15 ++
>  include/linux/mmc/host.h                           |   4 +-
>  include/linux/pwrseq.h                             |  63 +++++++++
>  22 files changed, 414 insertions(+), 214 deletions(-)
>  rename Documentation/devicetree/bindings/{mmc/mmc-pwrseq-emmc.txt =>
> power/pwrseq/pwrseq-emmc.txt} (100%) rename
> Documentation/devicetree/bindings/{mmc/mmc-pwrseq-simple.txt =>
> power/pwrseq/pwrseq-simple.txt} (53%) delete mode 100644
> drivers/mmc/core/pwrseq.c
>  delete mode 100644 drivers/mmc/core/pwrseq.h
>  rename drivers/{mmc/core => power/pwrseq}/Kconfig (60%)
>  create mode 100644 drivers/power/pwrseq/Makefile
>  create mode 100644 drivers/power/pwrseq/pwrseq.c
>  rename drivers/{mmc/core => power/pwrseq}/pwrseq_emmc.c (88%)
>  rename drivers/{mmc/core => power/pwrseq}/pwrseq_simple.c (52%)
>  create mode 100644 include/linux/pwrseq.h

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 00/12] usb/mmc/power: Generic power sequence (and fix USB/LAN when TFTP booting)
  2016-06-06 20:43 ` [PATCH v3 00/12] usb/mmc/power: Generic power sequence (and fix USB/LAN when TFTP booting) Heiko Stübner
@ 2016-06-07  6:03   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 30+ messages in thread
From: Krzysztof Kozlowski @ 2016-06-07  6:03 UTC (permalink / raw)
  To: Heiko Stübner
  Cc: hzpeterchen, Ulf Hansson, Sebastian Reichel,
	Dmitry Eremin-Solenikov, David Woodhouse,
	Javier Martinez Canillas, linux-kernel, linux-mmc, linux-pm,
	Alan Stern, linux-usb, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Kukjin Kim, devicetree,
	linux-arm-kernel, linux-samsung-soc, Greg Kroah-Hartman,
	Bartlomiej Zolnierkiewicz

On 06/06/2016 10:43 PM, Heiko Stübner wrote:
> Hi,
> 
> Am Mittwoch, 1. Juni 2016, 10:02:09 schrieb Krzysztof Kozlowski:
>> My third approach for a USB power sequence which fixes usb3503+lan
>> on Odroid U3 board if it was initialized by bootloader
>> (e.g. for TFTP boot).
> 
> I was just tackling a similar bringup problem regarding an embedded usb hub 
> and usb-sata bridge and stumbled upon this series.
> 
> While on my (rockchip-)boards it's always "just" a reset pin that needs 
> handling, this series looks like it would solve exactly that problem in a very 
> nice way.
> 
> So while I cannot provide any meaningful insight right now, it would be cool 
> if you could keep me in the loop, as I'm really looking forward to this series 
> progressing.
> 

Sure, good to know that this problem affects more people. I do not feel
such alone anymore. ;)

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 06/12] power: pwrseq: simple: Add support for regulator and generic property
  2016-06-03  2:02   ` Rob Herring
  2016-06-03 12:35     ` Krzysztof Kozlowski
@ 2016-06-07  9:29     ` Krzysztof Kozlowski
  2016-06-08 19:03       ` Rob Herring
  1 sibling, 1 reply; 30+ messages in thread
From: Krzysztof Kozlowski @ 2016-06-07  9:29 UTC (permalink / raw)
  To: Rob Herring
  Cc: hzpeterchen, Ulf Hansson, Sebastian Reichel,
	Dmitry Eremin-Solenikov, David Woodhouse,
	Javier Martinez Canillas, linux-kernel, linux-mmc, linux-pm,
	Alan Stern, linux-usb, Pawel Moll, Mark Rutland, Ian Campbell,
	Kumar Gala, Kukjin Kim, devicetree, linux-arm-kernel,
	linux-samsung-soc, Greg Kroah-Hartman, Bartlomiej Zolnierkiewicz

On 06/03/2016 04:02 AM, Rob Herring wrote:
>>  Optional properties:
>>  - reset-gpios : contains a list of GPIO specifiers. The reset GPIOs are asserted
>> @@ -16,6 +22,7 @@ Optional properties:
>>    See ../clocks/clock-bindings.txt for details.
>>  - clock-names : Must include the following entry:
>>    "ext_clock" (External clock provided to the card).
>> +- ext-supply : External regulator supply
> 
> What happens when there are 2 supplies?
> 
> I'd prefer the name not be genericish and use the real supply names. 
> Then the power seq code should just turn on all supplies it finds. If 
> the order or timing to turn on matters, then sorry, no generic sequence.

I think the generic part for regulators might be a problem. Regulator
API requires a name for the supply... it cannot get "something" or
"everything".

The driver could attach itself to any kind of node (where power-sequence
property exists) so the supply name depends on the bindings of device
(not bindings of power sequence driver).

The power sequence driver could however iterate over child properties
and get the names of all supplies. It is a little bit ugly...

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 06/12] power: pwrseq: simple: Add support for regulator and generic property
  2016-06-07  9:29     ` Krzysztof Kozlowski
@ 2016-06-08 19:03       ` Rob Herring
  2016-06-09  2:34         ` Chen-Yu Tsai
  0 siblings, 1 reply; 30+ messages in thread
From: Rob Herring @ 2016-06-08 19:03 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: hzpeterchen, Ulf Hansson, Sebastian Reichel,
	Dmitry Eremin-Solenikov, David Woodhouse,
	Javier Martinez Canillas, linux-kernel, linux-mmc, linux-pm,
	Alan Stern, linux-usb, Pawel Moll, Mark Rutland, Ian Campbell,
	Kumar Gala, Kukjin Kim, devicetree, linux-arm-kernel,
	linux-samsung-soc, Greg Kroah-Hartman, Bartlomiej Zolnierkiewicz

On Tue, Jun 07, 2016 at 11:29:02AM +0200, Krzysztof Kozlowski wrote:
> On 06/03/2016 04:02 AM, Rob Herring wrote:
> >>  Optional properties:
> >>  - reset-gpios : contains a list of GPIO specifiers. The reset GPIOs are asserted
> >> @@ -16,6 +22,7 @@ Optional properties:
> >>    See ../clocks/clock-bindings.txt for details.
> >>  - clock-names : Must include the following entry:
> >>    "ext_clock" (External clock provided to the card).
> >> +- ext-supply : External regulator supply
> > 
> > What happens when there are 2 supplies?
> > 
> > I'd prefer the name not be genericish and use the real supply names. 
> > Then the power seq code should just turn on all supplies it finds. If 
> > the order or timing to turn on matters, then sorry, no generic sequence.
> 
> I think the generic part for regulators might be a problem. Regulator
> API requires a name for the supply... it cannot get "something" or
> "everything".

That's the downside of variable property names...

> The driver could attach itself to any kind of node (where power-sequence
> property exists) so the supply name depends on the bindings of device
> (not bindings of power sequence driver).
> 
> The power sequence driver could however iterate over child properties
> and get the names of all supplies. It is a little bit ugly...

Yes. Like this, right?

for_each_property_of_node(np, pp) {
	if (!strstr(pp->name, "-supply"))
		continue;
	// found supply
}

The uglyness can always be improved with a function to do this parsing.

Rob

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 06/12] power: pwrseq: simple: Add support for regulator and generic property
  2016-06-08 19:03       ` Rob Herring
@ 2016-06-09  2:34         ` Chen-Yu Tsai
  2016-06-09  5:11           ` Krzysztof Kozlowski
  0 siblings, 1 reply; 30+ messages in thread
From: Chen-Yu Tsai @ 2016-06-09  2:34 UTC (permalink / raw)
  To: Rob Herring
  Cc: Krzysztof Kozlowski, Mark Rutland, devicetree, Ulf Hansson,
	linux-samsung-soc, Pawel Moll, Ian Campbell,
	Dmitry Eremin-Solenikov, Greg Kroah-Hartman, linux-usb,
	linux-mmc, Sebastian Reichel, linux-kernel,
	Javier Martinez Canillas, Bartlomiej Zolnierkiewicz, Kukjin Kim,
	Alan Stern, linux-arm-kernel, Kumar Gala, David Woodhouse,
	hzpeterchen, linux-pm

Hi

On Thu, Jun 9, 2016 at 3:03 AM, Rob Herring <robh@kernel.org> wrote:
> On Tue, Jun 07, 2016 at 11:29:02AM +0200, Krzysztof Kozlowski wrote:
>> On 06/03/2016 04:02 AM, Rob Herring wrote:
>> >>  Optional properties:
>> >>  - reset-gpios : contains a list of GPIO specifiers. The reset GPIOs are asserted
>> >> @@ -16,6 +22,7 @@ Optional properties:
>> >>    See ../clocks/clock-bindings.txt for details.
>> >>  - clock-names : Must include the following entry:
>> >>    "ext_clock" (External clock provided to the card).
>> >> +- ext-supply : External regulator supply
>> >
>> > What happens when there are 2 supplies?
>> >
>> > I'd prefer the name not be genericish and use the real supply names.
>> > Then the power seq code should just turn on all supplies it finds. If
>> > the order or timing to turn on matters, then sorry, no generic sequence.
>>
>> I think the generic part for regulators might be a problem. Regulator
>> API requires a name for the supply... it cannot get "something" or
>> "everything".
>
> That's the downside of variable property names...
>
>> The driver could attach itself to any kind of node (where power-sequence
>> property exists) so the supply name depends on the bindings of device
>> (not bindings of power sequence driver).
>>
>> The power sequence driver could however iterate over child properties
>> and get the names of all supplies. It is a little bit ugly...
>
> Yes. Like this, right?
>
> for_each_property_of_node(np, pp) {
>         if (!strstr(pp->name, "-supply"))
>                 continue;
>         // found supply
> }
>
> The uglyness can always be improved with a function to do this parsing.

There's already a version of this in simplefb. Maybe it's time to move
this to a common function?

ChenYu

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v3 06/12] power: pwrseq: simple: Add support for regulator and generic property
  2016-06-09  2:34         ` Chen-Yu Tsai
@ 2016-06-09  5:11           ` Krzysztof Kozlowski
  0 siblings, 0 replies; 30+ messages in thread
From: Krzysztof Kozlowski @ 2016-06-09  5:11 UTC (permalink / raw)
  To: Chen-Yu Tsai, Rob Herring
  Cc: Mark Rutland, devicetree, Ulf Hansson, linux-samsung-soc,
	Pawel Moll, Ian Campbell, Dmitry Eremin-Solenikov,
	Greg Kroah-Hartman, linux-usb, linux-mmc, Sebastian Reichel,
	linux-kernel, Javier Martinez Canillas,
	Bartlomiej Zolnierkiewicz, Kukjin Kim, Alan Stern,
	linux-arm-kernel, Kumar Gala, David Woodhouse, hzpeterchen,
	linux-pm

On 06/09/2016 04:34 AM, Chen-Yu Tsai wrote:
> Hi
> 
> On Thu, Jun 9, 2016 at 3:03 AM, Rob Herring <robh@kernel.org> wrote:
>> On Tue, Jun 07, 2016 at 11:29:02AM +0200, Krzysztof Kozlowski wrote:
>>> On 06/03/2016 04:02 AM, Rob Herring wrote:
>>>>>  Optional properties:
>>>>>  - reset-gpios : contains a list of GPIO specifiers. The reset GPIOs are asserted
>>>>> @@ -16,6 +22,7 @@ Optional properties:
>>>>>    See ../clocks/clock-bindings.txt for details.
>>>>>  - clock-names : Must include the following entry:
>>>>>    "ext_clock" (External clock provided to the card).
>>>>> +- ext-supply : External regulator supply
>>>>
>>>> What happens when there are 2 supplies?
>>>>
>>>> I'd prefer the name not be genericish and use the real supply names.
>>>> Then the power seq code should just turn on all supplies it finds. If
>>>> the order or timing to turn on matters, then sorry, no generic sequence.
>>>
>>> I think the generic part for regulators might be a problem. Regulator
>>> API requires a name for the supply... it cannot get "something" or
>>> "everything".
>>
>> That's the downside of variable property names...
>>
>>> The driver could attach itself to any kind of node (where power-sequence
>>> property exists) so the supply name depends on the bindings of device
>>> (not bindings of power sequence driver).
>>>
>>> The power sequence driver could however iterate over child properties
>>> and get the names of all supplies. It is a little bit ugly...
>>
>> Yes. Like this, right?
>>
>> for_each_property_of_node(np, pp) {
>>         if (!strstr(pp->name, "-supply"))
>>                 continue;
>>         // found supply
>> }
>>
>> The uglyness can always be improved with a function to do this parsing.
> 
> There's already a version of this in simplefb. Maybe it's time to move
> this to a common function?

Thanks, I'll make a generic one and let's see how Mark will respond to it.

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2016-06-09  5:11 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-01  8:02 [PATCH v3 00/12] usb/mmc/power: Generic power sequence (and fix USB/LAN when TFTP booting) Krzysztof Kozlowski
2016-06-01  8:02 ` [PATCH v3 01/12] power/mmc: Move pwrseq drivers to power/pwrseq Krzysztof Kozlowski
2016-06-01  8:02 ` [PATCH v3 02/12] MAINTAINERS: Retain Ulf Hansson as the same maintainer of pwrseq Krzysztof Kozlowski
2016-06-01  8:02 ` [PATCH v3 03/12] power: pwrseq: Enable COMPILE_TEST for drivers Krzysztof Kozlowski
2016-06-01  8:02 ` [PATCH v3 04/12] power: pwrseq: Remove mmc prefix from mmc_pwrseq Krzysztof Kozlowski
2016-06-01  8:02 ` [PATCH v3 05/12] power: pwrseq: Generalize mmc_pwrseq operations by removing mmc prefix Krzysztof Kozlowski
2016-06-01  8:02 ` [PATCH v3 06/12] power: pwrseq: simple: Add support for regulator and generic property Krzysztof Kozlowski
2016-06-03  2:02   ` Rob Herring
2016-06-03 12:35     ` Krzysztof Kozlowski
2016-06-06  3:22       ` Peter Chen
2016-06-07  9:29     ` Krzysztof Kozlowski
2016-06-08 19:03       ` Rob Herring
2016-06-09  2:34         ` Chen-Yu Tsai
2016-06-09  5:11           ` Krzysztof Kozlowski
2016-06-01  8:02 ` [PATCH v3 07/12] power: pwrseq: Add support for USB hubs with external power Krzysztof Kozlowski
2016-06-01  8:02 ` [PATCH v3 08/12] usb: hub: Handle deferred probe Krzysztof Kozlowski
2016-06-01  8:02 ` [PATCH v3 09/12] EXAMPLE CODE: usb: port: Parse pwrseq phandle from Device Tree Krzysztof Kozlowski
2016-06-01  8:57   ` Stephen Boyd
2016-06-01  9:06     ` Krzysztof Kozlowski
2016-06-01 12:05     ` Peter Chen
2016-06-01 18:16       ` Stephen Boyd
2016-06-02  1:24         ` Peter Chen
2016-06-01  8:02 ` [PATCH v3 10/12] EXAMPLE CODE: usb: hub: Power sequence the ports on activation Krzysztof Kozlowski
2016-06-01  8:02 ` [PATCH v3 11/12] ARM: dts: exynos: Switch the buck8 to GPIO mode on Odroid U3 Krzysztof Kozlowski
2016-06-01  8:02 ` [PATCH v3 12/12] ARM: dts: exynos: Fix LAN and HUB after bootloader initialization " Krzysztof Kozlowski
2016-06-01 11:59   ` Peter Chen
2016-06-02  7:26     ` Krzysztof Kozlowski
2016-06-02  7:58       ` Peter Chen
2016-06-06 20:43 ` [PATCH v3 00/12] usb/mmc/power: Generic power sequence (and fix USB/LAN when TFTP booting) Heiko Stübner
2016-06-07  6:03   ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).