All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/7] staging: board: armadillo800eva: Board staging for sh_mobile_lcdc_fb
@ 2015-06-17  8:38 ` Geert Uytterhoeven
  0 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-06-17  8:38 UTC (permalink / raw)
  To: linux-arm-kernel

	Hi Greg, Simon, Magnus,

This patch series adds board staging support for the Renesas R-Mobile A1
(r8a7740) based Armadillo-800 EVA board. It allows to support the frame
buffer device for the on-board LCD (which isn't supported by a DT-aware
driver yet) in modern DT-based multi-platform kernels.

The board staging area was introduced last year to allow continuous
upstream in-tree development and integration of platform devices. It
helps developers integrate devices as platform devices for device
drivers that only provide platform device bindings.  This in turn allows
for incremental development of both hardware feature support and DT
binding work in parallel.

The goal is to complete the move to ARM multi-platform kernels for all
shmobile platforms, and drop the existing board files
(arch/arm/mach-shmobile/board-*). Once this series is accepted, more
than 3000 lines of legacy armadillo board code and r8a7740 SoC code can
be removed.

This series consists of 5 parts:
  - Patch 1 re-enables compilation of the board staging area, which was
    disabled after a compile breakage, but has been fixed in the mean
    time,
  - Path 2 moves initialization of staging board code to an earlier
    moment, as currently it happens after unused PM domains are powered
    down,
  - Patches 3 and 4 (hopefully) fix the existing kzm9d board staging
    code, which was presumably "broken" by commit 9a1091ef0017c40a
    ("irqchip: gic: Support hierarchy irq domain."),
  - Patches 5 and 6 add support for registering platform devices with
    complex dependencies (clocks and PM domains), and add armadillo
    board staging code for enabling a frame buffer on the on-board LCD,
  - Patch 7 (new) adds pinctrl and gpio-hog configuration to enable the
    LCD.

The first 6 patches should go in through the staging tree, the last one
through the shmobile tree.

Major changes since v1 (more detailed changelogs in the individual
patches):
  - Add support for low/high edge/level interrupts in hwirq translation,
  - Move pinctrl and GPIO configuration from board staging code to DT,
  - Use clk_add_alias() instead of open coding.

Dependencies:
  - This is against next-20150617,
  - The gpio-hog in patch 7 depends on a bug fix like "[PATCH] [RFC]
    gpio: Retry deferred GPIO hogging on pin range change"
    (https://lkml.org/lkml/2015/6/16/455). It can be applied as-is
    though.

This was tested on r8a7740/armadillo.
This was not tested on emev2/kzm9d, due to lack of hardware.

Thanks for applying!

Geert Uytterhoeven (7):
  Revert "staging: board: disable as it breaks the build"
  staging: board: Initialize staging board code earlier
  staging: board: Add support for translating hwirq to virq numbers
  staging: board: kzm9d: Translate hwirq numbers to virq numbers
  staging: board: Add support for devices with complex dependencies
  staging: board: armadillo800eva: Board staging for sh_mobile_lcdc_fb
  ARM: shmobile: armadillo800eva dts: Add pinctrl and gpio-hog for lcdc0

 arch/arm/boot/dts/r8a7740-armadillo800eva.dts |  13 +++
 drivers/staging/board/Kconfig                 |   1 -
 drivers/staging/board/Makefile                |   3 +-
 drivers/staging/board/armadillo800eva.c       | 105 ++++++++++++++++++++
 drivers/staging/board/board.c                 | 136 ++++++++++++++++++++++++++
 drivers/staging/board/board.h                 |  27 ++++-
 drivers/staging/board/kzm9d.c                 |  10 +-
 7 files changed, 290 insertions(+), 5 deletions(-)
 create mode 100644 drivers/staging/board/armadillo800eva.c

-- 
1.9.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

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

* [PATCH v2 0/7] staging: board: armadillo800eva: Board staging for sh_mobile_lcdc_fb
@ 2015-06-17  8:38 ` Geert Uytterhoeven
  0 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-06-17  8:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Simon Horman, Magnus Damm
  Cc: Arnd Bergmann, Laurent Pinchart, Kuninori Morimoto, Marc Zyngier,
	devel, linux-sh, linux-pm, devicetree, linux-arm-kernel,
	linux-kernel, Geert Uytterhoeven

	Hi Greg, Simon, Magnus,

This patch series adds board staging support for the Renesas R-Mobile A1
(r8a7740) based Armadillo-800 EVA board. It allows to support the frame
buffer device for the on-board LCD (which isn't supported by a DT-aware
driver yet) in modern DT-based multi-platform kernels.

The board staging area was introduced last year to allow continuous
upstream in-tree development and integration of platform devices. It
helps developers integrate devices as platform devices for device
drivers that only provide platform device bindings.  This in turn allows
for incremental development of both hardware feature support and DT
binding work in parallel.

The goal is to complete the move to ARM multi-platform kernels for all
shmobile platforms, and drop the existing board files
(arch/arm/mach-shmobile/board-*). Once this series is accepted, more
than 3000 lines of legacy armadillo board code and r8a7740 SoC code can
be removed.

This series consists of 5 parts:
  - Patch 1 re-enables compilation of the board staging area, which was
    disabled after a compile breakage, but has been fixed in the mean
    time,
  - Path 2 moves initialization of staging board code to an earlier
    moment, as currently it happens after unused PM domains are powered
    down,
  - Patches 3 and 4 (hopefully) fix the existing kzm9d board staging
    code, which was presumably "broken" by commit 9a1091ef0017c40a
    ("irqchip: gic: Support hierarchy irq domain."),
  - Patches 5 and 6 add support for registering platform devices with
    complex dependencies (clocks and PM domains), and add armadillo
    board staging code for enabling a frame buffer on the on-board LCD,
  - Patch 7 (new) adds pinctrl and gpio-hog configuration to enable the
    LCD.

The first 6 patches should go in through the staging tree, the last one
through the shmobile tree.

Major changes since v1 (more detailed changelogs in the individual
patches):
  - Add support for low/high edge/level interrupts in hwirq translation,
  - Move pinctrl and GPIO configuration from board staging code to DT,
  - Use clk_add_alias() instead of open coding.

Dependencies:
  - This is against next-20150617,
  - The gpio-hog in patch 7 depends on a bug fix like "[PATCH] [RFC]
    gpio: Retry deferred GPIO hogging on pin range change"
    (https://lkml.org/lkml/2015/6/16/455). It can be applied as-is
    though.

This was tested on r8a7740/armadillo.
This was not tested on emev2/kzm9d, due to lack of hardware.

Thanks for applying!

Geert Uytterhoeven (7):
  Revert "staging: board: disable as it breaks the build"
  staging: board: Initialize staging board code earlier
  staging: board: Add support for translating hwirq to virq numbers
  staging: board: kzm9d: Translate hwirq numbers to virq numbers
  staging: board: Add support for devices with complex dependencies
  staging: board: armadillo800eva: Board staging for sh_mobile_lcdc_fb
  ARM: shmobile: armadillo800eva dts: Add pinctrl and gpio-hog for lcdc0

 arch/arm/boot/dts/r8a7740-armadillo800eva.dts |  13 +++
 drivers/staging/board/Kconfig                 |   1 -
 drivers/staging/board/Makefile                |   3 +-
 drivers/staging/board/armadillo800eva.c       | 105 ++++++++++++++++++++
 drivers/staging/board/board.c                 | 136 ++++++++++++++++++++++++++
 drivers/staging/board/board.h                 |  27 ++++-
 drivers/staging/board/kzm9d.c                 |  10 +-
 7 files changed, 290 insertions(+), 5 deletions(-)
 create mode 100644 drivers/staging/board/armadillo800eva.c

-- 
1.9.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

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

* [PATCH v2 0/7] staging: board: armadillo800eva: Board staging for sh_mobile_lcdc_fb
@ 2015-06-17  8:38 ` Geert Uytterhoeven
  0 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-06-17  8:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Simon Horman, Magnus Damm
  Cc: devel, devicetree, Arnd Bergmann, Kuninori Morimoto, linux-sh,
	Marc Zyngier, linux-pm, linux-kernel, Laurent Pinchart,
	Geert Uytterhoeven, linux-arm-kernel

	Hi Greg, Simon, Magnus,

This patch series adds board staging support for the Renesas R-Mobile A1
(r8a7740) based Armadillo-800 EVA board. It allows to support the frame
buffer device for the on-board LCD (which isn't supported by a DT-aware
driver yet) in modern DT-based multi-platform kernels.

The board staging area was introduced last year to allow continuous
upstream in-tree development and integration of platform devices. It
helps developers integrate devices as platform devices for device
drivers that only provide platform device bindings.  This in turn allows
for incremental development of both hardware feature support and DT
binding work in parallel.

The goal is to complete the move to ARM multi-platform kernels for all
shmobile platforms, and drop the existing board files
(arch/arm/mach-shmobile/board-*). Once this series is accepted, more
than 3000 lines of legacy armadillo board code and r8a7740 SoC code can
be removed.

This series consists of 5 parts:
  - Patch 1 re-enables compilation of the board staging area, which was
    disabled after a compile breakage, but has been fixed in the mean
    time,
  - Path 2 moves initialization of staging board code to an earlier
    moment, as currently it happens after unused PM domains are powered
    down,
  - Patches 3 and 4 (hopefully) fix the existing kzm9d board staging
    code, which was presumably "broken" by commit 9a1091ef0017c40a
    ("irqchip: gic: Support hierarchy irq domain."),
  - Patches 5 and 6 add support for registering platform devices with
    complex dependencies (clocks and PM domains), and add armadillo
    board staging code for enabling a frame buffer on the on-board LCD,
  - Patch 7 (new) adds pinctrl and gpio-hog configuration to enable the
    LCD.

The first 6 patches should go in through the staging tree, the last one
through the shmobile tree.

Major changes since v1 (more detailed changelogs in the individual
patches):
  - Add support for low/high edge/level interrupts in hwirq translation,
  - Move pinctrl and GPIO configuration from board staging code to DT,
  - Use clk_add_alias() instead of open coding.

Dependencies:
  - This is against next-20150617,
  - The gpio-hog in patch 7 depends on a bug fix like "[PATCH] [RFC]
    gpio: Retry deferred GPIO hogging on pin range change"
    (https://lkml.org/lkml/2015/6/16/455). It can be applied as-is
    though.

This was tested on r8a7740/armadillo.
This was not tested on emev2/kzm9d, due to lack of hardware.

Thanks for applying!

Geert Uytterhoeven (7):
  Revert "staging: board: disable as it breaks the build"
  staging: board: Initialize staging board code earlier
  staging: board: Add support for translating hwirq to virq numbers
  staging: board: kzm9d: Translate hwirq numbers to virq numbers
  staging: board: Add support for devices with complex dependencies
  staging: board: armadillo800eva: Board staging for sh_mobile_lcdc_fb
  ARM: shmobile: armadillo800eva dts: Add pinctrl and gpio-hog for lcdc0

 arch/arm/boot/dts/r8a7740-armadillo800eva.dts |  13 +++
 drivers/staging/board/Kconfig                 |   1 -
 drivers/staging/board/Makefile                |   3 +-
 drivers/staging/board/armadillo800eva.c       | 105 ++++++++++++++++++++
 drivers/staging/board/board.c                 | 136 ++++++++++++++++++++++++++
 drivers/staging/board/board.h                 |  27 ++++-
 drivers/staging/board/kzm9d.c                 |  10 +-
 7 files changed, 290 insertions(+), 5 deletions(-)
 create mode 100644 drivers/staging/board/armadillo800eva.c

-- 
1.9.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

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

* [PATCH v2 0/7] staging: board: armadillo800eva: Board staging for sh_mobile_lcdc_fb
@ 2015-06-17  8:38 ` Geert Uytterhoeven
  0 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-06-17  8:38 UTC (permalink / raw)
  To: linux-arm-kernel

	Hi Greg, Simon, Magnus,

This patch series adds board staging support for the Renesas R-Mobile A1
(r8a7740) based Armadillo-800 EVA board. It allows to support the frame
buffer device for the on-board LCD (which isn't supported by a DT-aware
driver yet) in modern DT-based multi-platform kernels.

The board staging area was introduced last year to allow continuous
upstream in-tree development and integration of platform devices. It
helps developers integrate devices as platform devices for device
drivers that only provide platform device bindings.  This in turn allows
for incremental development of both hardware feature support and DT
binding work in parallel.

The goal is to complete the move to ARM multi-platform kernels for all
shmobile platforms, and drop the existing board files
(arch/arm/mach-shmobile/board-*). Once this series is accepted, more
than 3000 lines of legacy armadillo board code and r8a7740 SoC code can
be removed.

This series consists of 5 parts:
  - Patch 1 re-enables compilation of the board staging area, which was
    disabled after a compile breakage, but has been fixed in the mean
    time,
  - Path 2 moves initialization of staging board code to an earlier
    moment, as currently it happens after unused PM domains are powered
    down,
  - Patches 3 and 4 (hopefully) fix the existing kzm9d board staging
    code, which was presumably "broken" by commit 9a1091ef0017c40a
    ("irqchip: gic: Support hierarchy irq domain."),
  - Patches 5 and 6 add support for registering platform devices with
    complex dependencies (clocks and PM domains), and add armadillo
    board staging code for enabling a frame buffer on the on-board LCD,
  - Patch 7 (new) adds pinctrl and gpio-hog configuration to enable the
    LCD.

The first 6 patches should go in through the staging tree, the last one
through the shmobile tree.

Major changes since v1 (more detailed changelogs in the individual
patches):
  - Add support for low/high edge/level interrupts in hwirq translation,
  - Move pinctrl and GPIO configuration from board staging code to DT,
  - Use clk_add_alias() instead of open coding.

Dependencies:
  - This is against next-20150617,
  - The gpio-hog in patch 7 depends on a bug fix like "[PATCH] [RFC]
    gpio: Retry deferred GPIO hogging on pin range change"
    (https://lkml.org/lkml/2015/6/16/455). It can be applied as-is
    though.

This was tested on r8a7740/armadillo.
This was not tested on emev2/kzm9d, due to lack of hardware.

Thanks for applying!

Geert Uytterhoeven (7):
  Revert "staging: board: disable as it breaks the build"
  staging: board: Initialize staging board code earlier
  staging: board: Add support for translating hwirq to virq numbers
  staging: board: kzm9d: Translate hwirq numbers to virq numbers
  staging: board: Add support for devices with complex dependencies
  staging: board: armadillo800eva: Board staging for sh_mobile_lcdc_fb
  ARM: shmobile: armadillo800eva dts: Add pinctrl and gpio-hog for lcdc0

 arch/arm/boot/dts/r8a7740-armadillo800eva.dts |  13 +++
 drivers/staging/board/Kconfig                 |   1 -
 drivers/staging/board/Makefile                |   3 +-
 drivers/staging/board/armadillo800eva.c       | 105 ++++++++++++++++++++
 drivers/staging/board/board.c                 | 136 ++++++++++++++++++++++++++
 drivers/staging/board/board.h                 |  27 ++++-
 drivers/staging/board/kzm9d.c                 |  10 +-
 7 files changed, 290 insertions(+), 5 deletions(-)
 create mode 100644 drivers/staging/board/armadillo800eva.c

-- 
1.9.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

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

* [PATCH v2 1/7] Revert "staging: board: disable as it breaks the build"
  2015-06-17  8:38 ` Geert Uytterhoeven
  (?)
@ 2015-06-17  8:38   ` Geert Uytterhoeven
  -1 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-06-17  8:38 UTC (permalink / raw)
  To: linux-arm-kernel

This reverts commit d13778d537a0ed6115d2a79a942af999cfb8eec6.

Commit 13c11072536f2613 ("staging:board: remove unnecessary function")
fixed the build of drivers/staging/board/board.c.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
---
v2:
  - Add Reviewed-by.
---
 drivers/staging/board/Kconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/board/Kconfig b/drivers/staging/board/Kconfig
index 0a89ad16371f7ded..b8ee81840666ad35 100644
--- a/drivers/staging/board/Kconfig
+++ b/drivers/staging/board/Kconfig
@@ -1,7 +1,6 @@
 config STAGING_BOARD
 	bool "Staging Board Support"
 	depends on OF_ADDRESS
-	depends on BROKEN
 	help
 	  Select to enable per-board staging support code.
 
-- 
1.9.1


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

* [PATCH v2 1/7] Revert "staging: board: disable as it breaks the build"
@ 2015-06-17  8:38   ` Geert Uytterhoeven
  0 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-06-17  8:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Simon Horman, Magnus Damm
  Cc: Arnd Bergmann, Laurent Pinchart, Kuninori Morimoto, Marc Zyngier,
	devel, linux-sh, linux-pm, devicetree, linux-arm-kernel,
	linux-kernel, Geert Uytterhoeven

This reverts commit d13778d537a0ed6115d2a79a942af999cfb8eec6.

Commit 13c11072536f2613 ("staging:board: remove unnecessary function")
fixed the build of drivers/staging/board/board.c.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
---
v2:
  - Add Reviewed-by.
---
 drivers/staging/board/Kconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/board/Kconfig b/drivers/staging/board/Kconfig
index 0a89ad16371f7ded..b8ee81840666ad35 100644
--- a/drivers/staging/board/Kconfig
+++ b/drivers/staging/board/Kconfig
@@ -1,7 +1,6 @@
 config STAGING_BOARD
 	bool "Staging Board Support"
 	depends on OF_ADDRESS
-	depends on BROKEN
 	help
 	  Select to enable per-board staging support code.
 
-- 
1.9.1


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

* [PATCH v2 1/7] Revert "staging: board: disable as it breaks the build"
@ 2015-06-17  8:38   ` Geert Uytterhoeven
  0 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-06-17  8:38 UTC (permalink / raw)
  To: linux-arm-kernel

This reverts commit d13778d537a0ed6115d2a79a942af999cfb8eec6.

Commit 13c11072536f2613 ("staging:board: remove unnecessary function")
fixed the build of drivers/staging/board/board.c.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
---
v2:
  - Add Reviewed-by.
---
 drivers/staging/board/Kconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/board/Kconfig b/drivers/staging/board/Kconfig
index 0a89ad16371f7ded..b8ee81840666ad35 100644
--- a/drivers/staging/board/Kconfig
+++ b/drivers/staging/board/Kconfig
@@ -1,7 +1,6 @@
 config STAGING_BOARD
 	bool "Staging Board Support"
 	depends on OF_ADDRESS
-	depends on BROKEN
 	help
 	  Select to enable per-board staging support code.
 
-- 
1.9.1

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

* [PATCH v2 2/7] staging: board: Initialize staging board code earlier
  2015-06-17  8:38 ` Geert Uytterhoeven
  (?)
  (?)
@ 2015-06-17  8:38   ` Geert Uytterhoeven
  -1 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-06-17  8:38 UTC (permalink / raw)
  To: linux-arm-kernel

Currently the staging board code is initialized from a late_initcall().
However, unused PM domains are also disabled from a late_initcall(),
which happens before due to link order.

Change the initialization of staging board code from using
late_initcall() to device_initcall() to fix this.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - Drop RFC status.
---
 drivers/staging/board/board.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/board/board.h b/drivers/staging/board/board.h
index 2390ed6c31a42f2f..e9c914985d4acb36 100644
--- a/drivers/staging/board/board.h
+++ b/drivers/staging/board/board.h
@@ -15,6 +15,6 @@ static int __init runtime_board_check(void)	\
 	return 0;				\
 }						\
 						\
-late_initcall(runtime_board_check)
+device_initcall(runtime_board_check)
 
 #endif /* __BOARD_H__ */
-- 
1.9.1


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

* [PATCH v2 2/7] staging: board: Initialize staging board code earlier
@ 2015-06-17  8:38   ` Geert Uytterhoeven
  0 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-06-17  8:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Simon Horman, Magnus Damm
  Cc: Arnd Bergmann, Laurent Pinchart, Kuninori Morimoto, Marc Zyngier,
	devel, linux-sh, linux-pm, devicetree, linux-arm-kernel,
	linux-kernel, Geert Uytterhoeven

Currently the staging board code is initialized from a late_initcall().
However, unused PM domains are also disabled from a late_initcall(),
which happens before due to link order.

Change the initialization of staging board code from using
late_initcall() to device_initcall() to fix this.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - Drop RFC status.
---
 drivers/staging/board/board.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/board/board.h b/drivers/staging/board/board.h
index 2390ed6c31a42f2f..e9c914985d4acb36 100644
--- a/drivers/staging/board/board.h
+++ b/drivers/staging/board/board.h
@@ -15,6 +15,6 @@ static int __init runtime_board_check(void)	\
 	return 0;				\
 }						\
 						\
-late_initcall(runtime_board_check)
+device_initcall(runtime_board_check)
 
 #endif /* __BOARD_H__ */
-- 
1.9.1


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

* [PATCH v2 2/7] staging: board: Initialize staging board code earlier
@ 2015-06-17  8:38   ` Geert Uytterhoeven
  0 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-06-17  8:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Simon Horman, Magnus Damm
  Cc: devel, devicetree, Arnd Bergmann, Kuninori Morimoto, linux-sh,
	Marc Zyngier, linux-pm, linux-kernel, Laurent Pinchart,
	Geert Uytterhoeven, linux-arm-kernel

Currently the staging board code is initialized from a late_initcall().
However, unused PM domains are also disabled from a late_initcall(),
which happens before due to link order.

Change the initialization of staging board code from using
late_initcall() to device_initcall() to fix this.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - Drop RFC status.
---
 drivers/staging/board/board.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/board/board.h b/drivers/staging/board/board.h
index 2390ed6c31a42f2f..e9c914985d4acb36 100644
--- a/drivers/staging/board/board.h
+++ b/drivers/staging/board/board.h
@@ -15,6 +15,6 @@ static int __init runtime_board_check(void)	\
 	return 0;				\
 }						\
 						\
-late_initcall(runtime_board_check)
+device_initcall(runtime_board_check)
 
 #endif /* __BOARD_H__ */
-- 
1.9.1

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

* [PATCH v2 2/7] staging: board: Initialize staging board code earlier
@ 2015-06-17  8:38   ` Geert Uytterhoeven
  0 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-06-17  8:38 UTC (permalink / raw)
  To: linux-arm-kernel

Currently the staging board code is initialized from a late_initcall().
However, unused PM domains are also disabled from a late_initcall(),
which happens before due to link order.

Change the initialization of staging board code from using
late_initcall() to device_initcall() to fix this.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - Drop RFC status.
---
 drivers/staging/board/board.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/board/board.h b/drivers/staging/board/board.h
index 2390ed6c31a42f2f..e9c914985d4acb36 100644
--- a/drivers/staging/board/board.h
+++ b/drivers/staging/board/board.h
@@ -15,6 +15,6 @@ static int __init runtime_board_check(void)	\
 	return 0;				\
 }						\
 						\
-late_initcall(runtime_board_check)
+device_initcall(runtime_board_check)
 
 #endif /* __BOARD_H__ */
-- 
1.9.1

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

* [PATCH v2 3/7] staging: board: Add support for translating hwirq to virq numbers
  2015-06-17  8:38 ` Geert Uytterhoeven
  (?)
  (?)
@ 2015-06-17  8:38   ` Geert Uytterhoeven
  -1 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-06-17  8:38 UTC (permalink / raw)
  To: linux-arm-kernel

As of commit 9a1091ef0017c40a ("irqchip: gic: Support hierarchy irq
domain."), GIC IRQ numbers are virtual, breaking hardcoded hardware IRQ
numbers in platform device resources.

Add support for translating hardware IRQ numbers to virtual IRQ numbers,
and fixing up platform device resources with hardcoded IRQ numbers.

Add a copyright header, including the original author.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - Change the function names to include "gic", as the 3-parameter
    interrupt specifiers are GIC-specific,
  - Warn if board_staging_gic_setup_xlate() is called twice,
  - Add support for low/high edge/level interrupts (the default is still
    high level),
  - Drop RFC status.
---
 drivers/staging/board/board.c | 80 +++++++++++++++++++++++++++++++++++++++++++
 drivers/staging/board/board.h |  5 +++
 2 files changed, 85 insertions(+)

diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
index d5a6abc845191c93..8712f566b31196e0 100644
--- a/drivers/staging/board/board.c
+++ b/drivers/staging/board/board.c
@@ -1,10 +1,27 @@
+/*
+ * Copyright (C) 2014 Magnus Damm
+ * Copyright (C) 2015 Glider bvba
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#define pr_fmt(fmt)	"board_staging: "  fmt
+
 #include <linux/init.h>
+#include <linux/irq.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/of_irq.h>
+
 #include "board.h"
 
+static struct device_node *irqc_node __initdata;
+static unsigned int irqc_base __initdata;
+
 static bool find_by_address(u64 base_address)
 {
 	struct device_node *dn = of_find_all_nodes(NULL);
@@ -38,3 +55,66 @@ bool __init board_staging_dt_node_available(const struct resource *resource,
 
 	return false; /* Nothing found */
 }
+
+int __init board_staging_gic_setup_xlate(const char *gic_match,
+					 unsigned int base)
+{
+	WARN_ON(irqc_node);
+
+	irqc_node = of_find_compatible_node(NULL, NULL, gic_match);
+
+	WARN_ON(!irqc_node);
+	if (!irqc_node)
+		return -ENOENT;
+
+	irqc_base = base;
+	return 0;
+}
+
+static void __init gic_fixup_resource(struct resource *res)
+{
+	struct of_phandle_args irq_data;
+	unsigned int hwirq = res->start;
+	unsigned int virq;
+
+	if (resource_type(res) != IORESOURCE_IRQ || !irqc_node)
+		return;
+
+	irq_data.np = irqc_node;
+	irq_data.args_count = 3;
+	irq_data.args[0] = 0;
+	irq_data.args[1] = hwirq - irqc_base;
+	switch (res->flags &
+		(IORESOURCE_IRQ_LOWEDGE | IORESOURCE_IRQ_HIGHEDGE |
+		 IORESOURCE_IRQ_LOWLEVEL | IORESOURCE_IRQ_HIGHLEVEL)) {
+	case IORESOURCE_IRQ_LOWEDGE:
+		irq_data.args[2] = IRQ_TYPE_EDGE_FALLING;
+		break;
+	case IORESOURCE_IRQ_HIGHEDGE:
+		irq_data.args[2] = IRQ_TYPE_EDGE_RISING;
+		break;
+	case IORESOURCE_IRQ_LOWLEVEL:
+		irq_data.args[2] = IRQ_TYPE_LEVEL_LOW;
+		break;
+	case IORESOURCE_IRQ_HIGHLEVEL:
+	default:
+		irq_data.args[2] = IRQ_TYPE_LEVEL_HIGH;
+		break;
+	}
+
+	virq = irq_create_of_mapping(&irq_data);
+	if (WARN_ON(!virq))
+		return;
+
+	pr_debug("hwirq %u -> virq %u\n", hwirq, virq);
+	res->start = virq;
+}
+
+void __init board_staging_gic_fixup_resources(struct resource *res,
+					      unsigned int nres)
+{
+	unsigned int i;
+
+	for (i = 0; i < nres; i++)
+		gic_fixup_resource(&res[i]);
+}
diff --git a/drivers/staging/board/board.h b/drivers/staging/board/board.h
index e9c914985d4acb36..3af6dbe22f91ebdc 100644
--- a/drivers/staging/board/board.h
+++ b/drivers/staging/board/board.h
@@ -1,10 +1,15 @@
 #ifndef __BOARD_H__
 #define __BOARD_H__
+
 #include <linux/init.h>
 #include <linux/of.h>
 
+struct resource;
+
 bool board_staging_dt_node_available(const struct resource *resource,
 				     unsigned int num_resources);
+int board_staging_gic_setup_xlate(const char *gic_match, unsigned int base);
+void board_staging_gic_fixup_resources(struct resource *res, unsigned int nres);
 
 #define board_staging(str, fn)			\
 static int __init runtime_board_check(void)	\
-- 
1.9.1


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

* [PATCH v2 3/7] staging: board: Add support for translating hwirq to virq numbers
@ 2015-06-17  8:38   ` Geert Uytterhoeven
  0 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-06-17  8:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Simon Horman, Magnus Damm
  Cc: Arnd Bergmann, Laurent Pinchart, Kuninori Morimoto, Marc Zyngier,
	devel, linux-sh, linux-pm, devicetree, linux-arm-kernel,
	linux-kernel, Geert Uytterhoeven

As of commit 9a1091ef0017c40a ("irqchip: gic: Support hierarchy irq
domain."), GIC IRQ numbers are virtual, breaking hardcoded hardware IRQ
numbers in platform device resources.

Add support for translating hardware IRQ numbers to virtual IRQ numbers,
and fixing up platform device resources with hardcoded IRQ numbers.

Add a copyright header, including the original author.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - Change the function names to include "gic", as the 3-parameter
    interrupt specifiers are GIC-specific,
  - Warn if board_staging_gic_setup_xlate() is called twice,
  - Add support for low/high edge/level interrupts (the default is still
    high level),
  - Drop RFC status.
---
 drivers/staging/board/board.c | 80 +++++++++++++++++++++++++++++++++++++++++++
 drivers/staging/board/board.h |  5 +++
 2 files changed, 85 insertions(+)

diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
index d5a6abc845191c93..8712f566b31196e0 100644
--- a/drivers/staging/board/board.c
+++ b/drivers/staging/board/board.c
@@ -1,10 +1,27 @@
+/*
+ * Copyright (C) 2014 Magnus Damm
+ * Copyright (C) 2015 Glider bvba
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#define pr_fmt(fmt)	"board_staging: "  fmt
+
 #include <linux/init.h>
+#include <linux/irq.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/of_irq.h>
+
 #include "board.h"
 
+static struct device_node *irqc_node __initdata;
+static unsigned int irqc_base __initdata;
+
 static bool find_by_address(u64 base_address)
 {
 	struct device_node *dn = of_find_all_nodes(NULL);
@@ -38,3 +55,66 @@ bool __init board_staging_dt_node_available(const struct resource *resource,
 
 	return false; /* Nothing found */
 }
+
+int __init board_staging_gic_setup_xlate(const char *gic_match,
+					 unsigned int base)
+{
+	WARN_ON(irqc_node);
+
+	irqc_node = of_find_compatible_node(NULL, NULL, gic_match);
+
+	WARN_ON(!irqc_node);
+	if (!irqc_node)
+		return -ENOENT;
+
+	irqc_base = base;
+	return 0;
+}
+
+static void __init gic_fixup_resource(struct resource *res)
+{
+	struct of_phandle_args irq_data;
+	unsigned int hwirq = res->start;
+	unsigned int virq;
+
+	if (resource_type(res) != IORESOURCE_IRQ || !irqc_node)
+		return;
+
+	irq_data.np = irqc_node;
+	irq_data.args_count = 3;
+	irq_data.args[0] = 0;
+	irq_data.args[1] = hwirq - irqc_base;
+	switch (res->flags &
+		(IORESOURCE_IRQ_LOWEDGE | IORESOURCE_IRQ_HIGHEDGE |
+		 IORESOURCE_IRQ_LOWLEVEL | IORESOURCE_IRQ_HIGHLEVEL)) {
+	case IORESOURCE_IRQ_LOWEDGE:
+		irq_data.args[2] = IRQ_TYPE_EDGE_FALLING;
+		break;
+	case IORESOURCE_IRQ_HIGHEDGE:
+		irq_data.args[2] = IRQ_TYPE_EDGE_RISING;
+		break;
+	case IORESOURCE_IRQ_LOWLEVEL:
+		irq_data.args[2] = IRQ_TYPE_LEVEL_LOW;
+		break;
+	case IORESOURCE_IRQ_HIGHLEVEL:
+	default:
+		irq_data.args[2] = IRQ_TYPE_LEVEL_HIGH;
+		break;
+	}
+
+	virq = irq_create_of_mapping(&irq_data);
+	if (WARN_ON(!virq))
+		return;
+
+	pr_debug("hwirq %u -> virq %u\n", hwirq, virq);
+	res->start = virq;
+}
+
+void __init board_staging_gic_fixup_resources(struct resource *res,
+					      unsigned int nres)
+{
+	unsigned int i;
+
+	for (i = 0; i < nres; i++)
+		gic_fixup_resource(&res[i]);
+}
diff --git a/drivers/staging/board/board.h b/drivers/staging/board/board.h
index e9c914985d4acb36..3af6dbe22f91ebdc 100644
--- a/drivers/staging/board/board.h
+++ b/drivers/staging/board/board.h
@@ -1,10 +1,15 @@
 #ifndef __BOARD_H__
 #define __BOARD_H__
+
 #include <linux/init.h>
 #include <linux/of.h>
 
+struct resource;
+
 bool board_staging_dt_node_available(const struct resource *resource,
 				     unsigned int num_resources);
+int board_staging_gic_setup_xlate(const char *gic_match, unsigned int base);
+void board_staging_gic_fixup_resources(struct resource *res, unsigned int nres);
 
 #define board_staging(str, fn)			\
 static int __init runtime_board_check(void)	\
-- 
1.9.1


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

* [PATCH v2 3/7] staging: board: Add support for translating hwirq to virq numbers
@ 2015-06-17  8:38   ` Geert Uytterhoeven
  0 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-06-17  8:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Simon Horman, Magnus Damm
  Cc: devel, devicetree, Arnd Bergmann, Kuninori Morimoto, linux-sh,
	Marc Zyngier, linux-pm, linux-kernel, Laurent Pinchart,
	Geert Uytterhoeven, linux-arm-kernel

As of commit 9a1091ef0017c40a ("irqchip: gic: Support hierarchy irq
domain."), GIC IRQ numbers are virtual, breaking hardcoded hardware IRQ
numbers in platform device resources.

Add support for translating hardware IRQ numbers to virtual IRQ numbers,
and fixing up platform device resources with hardcoded IRQ numbers.

Add a copyright header, including the original author.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - Change the function names to include "gic", as the 3-parameter
    interrupt specifiers are GIC-specific,
  - Warn if board_staging_gic_setup_xlate() is called twice,
  - Add support for low/high edge/level interrupts (the default is still
    high level),
  - Drop RFC status.
---
 drivers/staging/board/board.c | 80 +++++++++++++++++++++++++++++++++++++++++++
 drivers/staging/board/board.h |  5 +++
 2 files changed, 85 insertions(+)

diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
index d5a6abc845191c93..8712f566b31196e0 100644
--- a/drivers/staging/board/board.c
+++ b/drivers/staging/board/board.c
@@ -1,10 +1,27 @@
+/*
+ * Copyright (C) 2014 Magnus Damm
+ * Copyright (C) 2015 Glider bvba
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#define pr_fmt(fmt)	"board_staging: "  fmt
+
 #include <linux/init.h>
+#include <linux/irq.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/of_irq.h>
+
 #include "board.h"
 
+static struct device_node *irqc_node __initdata;
+static unsigned int irqc_base __initdata;
+
 static bool find_by_address(u64 base_address)
 {
 	struct device_node *dn = of_find_all_nodes(NULL);
@@ -38,3 +55,66 @@ bool __init board_staging_dt_node_available(const struct resource *resource,
 
 	return false; /* Nothing found */
 }
+
+int __init board_staging_gic_setup_xlate(const char *gic_match,
+					 unsigned int base)
+{
+	WARN_ON(irqc_node);
+
+	irqc_node = of_find_compatible_node(NULL, NULL, gic_match);
+
+	WARN_ON(!irqc_node);
+	if (!irqc_node)
+		return -ENOENT;
+
+	irqc_base = base;
+	return 0;
+}
+
+static void __init gic_fixup_resource(struct resource *res)
+{
+	struct of_phandle_args irq_data;
+	unsigned int hwirq = res->start;
+	unsigned int virq;
+
+	if (resource_type(res) != IORESOURCE_IRQ || !irqc_node)
+		return;
+
+	irq_data.np = irqc_node;
+	irq_data.args_count = 3;
+	irq_data.args[0] = 0;
+	irq_data.args[1] = hwirq - irqc_base;
+	switch (res->flags &
+		(IORESOURCE_IRQ_LOWEDGE | IORESOURCE_IRQ_HIGHEDGE |
+		 IORESOURCE_IRQ_LOWLEVEL | IORESOURCE_IRQ_HIGHLEVEL)) {
+	case IORESOURCE_IRQ_LOWEDGE:
+		irq_data.args[2] = IRQ_TYPE_EDGE_FALLING;
+		break;
+	case IORESOURCE_IRQ_HIGHEDGE:
+		irq_data.args[2] = IRQ_TYPE_EDGE_RISING;
+		break;
+	case IORESOURCE_IRQ_LOWLEVEL:
+		irq_data.args[2] = IRQ_TYPE_LEVEL_LOW;
+		break;
+	case IORESOURCE_IRQ_HIGHLEVEL:
+	default:
+		irq_data.args[2] = IRQ_TYPE_LEVEL_HIGH;
+		break;
+	}
+
+	virq = irq_create_of_mapping(&irq_data);
+	if (WARN_ON(!virq))
+		return;
+
+	pr_debug("hwirq %u -> virq %u\n", hwirq, virq);
+	res->start = virq;
+}
+
+void __init board_staging_gic_fixup_resources(struct resource *res,
+					      unsigned int nres)
+{
+	unsigned int i;
+
+	for (i = 0; i < nres; i++)
+		gic_fixup_resource(&res[i]);
+}
diff --git a/drivers/staging/board/board.h b/drivers/staging/board/board.h
index e9c914985d4acb36..3af6dbe22f91ebdc 100644
--- a/drivers/staging/board/board.h
+++ b/drivers/staging/board/board.h
@@ -1,10 +1,15 @@
 #ifndef __BOARD_H__
 #define __BOARD_H__
+
 #include <linux/init.h>
 #include <linux/of.h>
 
+struct resource;
+
 bool board_staging_dt_node_available(const struct resource *resource,
 				     unsigned int num_resources);
+int board_staging_gic_setup_xlate(const char *gic_match, unsigned int base);
+void board_staging_gic_fixup_resources(struct resource *res, unsigned int nres);
 
 #define board_staging(str, fn)			\
 static int __init runtime_board_check(void)	\
-- 
1.9.1

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

* [PATCH v2 3/7] staging: board: Add support for translating hwirq to virq numbers
@ 2015-06-17  8:38   ` Geert Uytterhoeven
  0 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-06-17  8:38 UTC (permalink / raw)
  To: linux-arm-kernel

As of commit 9a1091ef0017c40a ("irqchip: gic: Support hierarchy irq
domain."), GIC IRQ numbers are virtual, breaking hardcoded hardware IRQ
numbers in platform device resources.

Add support for translating hardware IRQ numbers to virtual IRQ numbers,
and fixing up platform device resources with hardcoded IRQ numbers.

Add a copyright header, including the original author.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - Change the function names to include "gic", as the 3-parameter
    interrupt specifiers are GIC-specific,
  - Warn if board_staging_gic_setup_xlate() is called twice,
  - Add support for low/high edge/level interrupts (the default is still
    high level),
  - Drop RFC status.
---
 drivers/staging/board/board.c | 80 +++++++++++++++++++++++++++++++++++++++++++
 drivers/staging/board/board.h |  5 +++
 2 files changed, 85 insertions(+)

diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
index d5a6abc845191c93..8712f566b31196e0 100644
--- a/drivers/staging/board/board.c
+++ b/drivers/staging/board/board.c
@@ -1,10 +1,27 @@
+/*
+ * Copyright (C) 2014 Magnus Damm
+ * Copyright (C) 2015 Glider bvba
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#define pr_fmt(fmt)	"board_staging: "  fmt
+
 #include <linux/init.h>
+#include <linux/irq.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/of_irq.h>
+
 #include "board.h"
 
+static struct device_node *irqc_node __initdata;
+static unsigned int irqc_base __initdata;
+
 static bool find_by_address(u64 base_address)
 {
 	struct device_node *dn = of_find_all_nodes(NULL);
@@ -38,3 +55,66 @@ bool __init board_staging_dt_node_available(const struct resource *resource,
 
 	return false; /* Nothing found */
 }
+
+int __init board_staging_gic_setup_xlate(const char *gic_match,
+					 unsigned int base)
+{
+	WARN_ON(irqc_node);
+
+	irqc_node = of_find_compatible_node(NULL, NULL, gic_match);
+
+	WARN_ON(!irqc_node);
+	if (!irqc_node)
+		return -ENOENT;
+
+	irqc_base = base;
+	return 0;
+}
+
+static void __init gic_fixup_resource(struct resource *res)
+{
+	struct of_phandle_args irq_data;
+	unsigned int hwirq = res->start;
+	unsigned int virq;
+
+	if (resource_type(res) != IORESOURCE_IRQ || !irqc_node)
+		return;
+
+	irq_data.np = irqc_node;
+	irq_data.args_count = 3;
+	irq_data.args[0] = 0;
+	irq_data.args[1] = hwirq - irqc_base;
+	switch (res->flags &
+		(IORESOURCE_IRQ_LOWEDGE | IORESOURCE_IRQ_HIGHEDGE |
+		 IORESOURCE_IRQ_LOWLEVEL | IORESOURCE_IRQ_HIGHLEVEL)) {
+	case IORESOURCE_IRQ_LOWEDGE:
+		irq_data.args[2] = IRQ_TYPE_EDGE_FALLING;
+		break;
+	case IORESOURCE_IRQ_HIGHEDGE:
+		irq_data.args[2] = IRQ_TYPE_EDGE_RISING;
+		break;
+	case IORESOURCE_IRQ_LOWLEVEL:
+		irq_data.args[2] = IRQ_TYPE_LEVEL_LOW;
+		break;
+	case IORESOURCE_IRQ_HIGHLEVEL:
+	default:
+		irq_data.args[2] = IRQ_TYPE_LEVEL_HIGH;
+		break;
+	}
+
+	virq = irq_create_of_mapping(&irq_data);
+	if (WARN_ON(!virq))
+		return;
+
+	pr_debug("hwirq %u -> virq %u\n", hwirq, virq);
+	res->start = virq;
+}
+
+void __init board_staging_gic_fixup_resources(struct resource *res,
+					      unsigned int nres)
+{
+	unsigned int i;
+
+	for (i = 0; i < nres; i++)
+		gic_fixup_resource(&res[i]);
+}
diff --git a/drivers/staging/board/board.h b/drivers/staging/board/board.h
index e9c914985d4acb36..3af6dbe22f91ebdc 100644
--- a/drivers/staging/board/board.h
+++ b/drivers/staging/board/board.h
@@ -1,10 +1,15 @@
 #ifndef __BOARD_H__
 #define __BOARD_H__
+
 #include <linux/init.h>
 #include <linux/of.h>
 
+struct resource;
+
 bool board_staging_dt_node_available(const struct resource *resource,
 				     unsigned int num_resources);
+int board_staging_gic_setup_xlate(const char *gic_match, unsigned int base);
+void board_staging_gic_fixup_resources(struct resource *res, unsigned int nres);
 
 #define board_staging(str, fn)			\
 static int __init runtime_board_check(void)	\
-- 
1.9.1

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

* [PATCH v2 4/7] staging: board: kzm9d: Translate hwirq numbers to virq numbers
  2015-06-17  8:38 ` Geert Uytterhoeven
  (?)
  (?)
@ 2015-06-17  8:38   ` Geert Uytterhoeven
  -1 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-06-17  8:38 UTC (permalink / raw)
  To: linux-arm-kernel

As of commit 9a1091ef0017c40a ("irqchip: gic: Support hierarchy irq
domain."), GIC IRQ numbers are virtual, breaking hardcoded hardware IRQ
numbers in platform device resources.

Translate the hardware IRQ numbers to virtual IRQ numbers to fix this.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Untested due to lack of hardware

v2:
  - Update for changed function names,
  - Drop RFC status.
---
 drivers/staging/board/kzm9d.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/board/kzm9d.c b/drivers/staging/board/kzm9d.c
index 533f3026e17aa723..8d1eb09bc66ef413 100644
--- a/drivers/staging/board/kzm9d.c
+++ b/drivers/staging/board/kzm9d.c
@@ -4,16 +4,22 @@
 #include <linux/platform_device.h>
 #include "board.h"
 
-static const struct resource usbs1_res[] __initconst = {
+static struct resource usbs1_res[] __initdata = {
 	DEFINE_RES_MEM(0xe2800000, 0x2000),
 	DEFINE_RES_IRQ(159),
 };
 
 static void __init kzm9d_init(void)
 {
-	if (!board_staging_dt_node_available(usbs1_res, ARRAY_SIZE(usbs1_res)))
+	board_staging_gic_setup_xlate("arm,cortex-a9-gic", 32);
+
+	if (!board_staging_dt_node_available(usbs1_res,
+					     ARRAY_SIZE(usbs1_res))) {
+		board_staging_gic_fixup_resources(usbs1_res,
+						  ARRAY_SIZE(usbs1_res));
 		platform_device_register_simple("emxx_udc", -1, usbs1_res,
 						ARRAY_SIZE(usbs1_res));
+	}
 }
 
 board_staging("renesas,kzm9d", kzm9d_init);
-- 
1.9.1


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

* [PATCH v2 4/7] staging: board: kzm9d: Translate hwirq numbers to virq numbers
@ 2015-06-17  8:38   ` Geert Uytterhoeven
  0 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-06-17  8:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Simon Horman, Magnus Damm
  Cc: Arnd Bergmann, Laurent Pinchart, Kuninori Morimoto, Marc Zyngier,
	devel, linux-sh, linux-pm, devicetree, linux-arm-kernel,
	linux-kernel, Geert Uytterhoeven

As of commit 9a1091ef0017c40a ("irqchip: gic: Support hierarchy irq
domain."), GIC IRQ numbers are virtual, breaking hardcoded hardware IRQ
numbers in platform device resources.

Translate the hardware IRQ numbers to virtual IRQ numbers to fix this.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Untested due to lack of hardware

v2:
  - Update for changed function names,
  - Drop RFC status.
---
 drivers/staging/board/kzm9d.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/board/kzm9d.c b/drivers/staging/board/kzm9d.c
index 533f3026e17aa723..8d1eb09bc66ef413 100644
--- a/drivers/staging/board/kzm9d.c
+++ b/drivers/staging/board/kzm9d.c
@@ -4,16 +4,22 @@
 #include <linux/platform_device.h>
 #include "board.h"
 
-static const struct resource usbs1_res[] __initconst = {
+static struct resource usbs1_res[] __initdata = {
 	DEFINE_RES_MEM(0xe2800000, 0x2000),
 	DEFINE_RES_IRQ(159),
 };
 
 static void __init kzm9d_init(void)
 {
-	if (!board_staging_dt_node_available(usbs1_res, ARRAY_SIZE(usbs1_res)))
+	board_staging_gic_setup_xlate("arm,cortex-a9-gic", 32);
+
+	if (!board_staging_dt_node_available(usbs1_res,
+					     ARRAY_SIZE(usbs1_res))) {
+		board_staging_gic_fixup_resources(usbs1_res,
+						  ARRAY_SIZE(usbs1_res));
 		platform_device_register_simple("emxx_udc", -1, usbs1_res,
 						ARRAY_SIZE(usbs1_res));
+	}
 }
 
 board_staging("renesas,kzm9d", kzm9d_init);
-- 
1.9.1


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

* [PATCH v2 4/7] staging: board: kzm9d: Translate hwirq numbers to virq numbers
@ 2015-06-17  8:38   ` Geert Uytterhoeven
  0 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-06-17  8:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Simon Horman, Magnus Damm
  Cc: devel, devicetree, Arnd Bergmann, Kuninori Morimoto, linux-sh,
	Marc Zyngier, linux-pm, linux-kernel, Laurent Pinchart,
	Geert Uytterhoeven, linux-arm-kernel

As of commit 9a1091ef0017c40a ("irqchip: gic: Support hierarchy irq
domain."), GIC IRQ numbers are virtual, breaking hardcoded hardware IRQ
numbers in platform device resources.

Translate the hardware IRQ numbers to virtual IRQ numbers to fix this.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Untested due to lack of hardware

v2:
  - Update for changed function names,
  - Drop RFC status.
---
 drivers/staging/board/kzm9d.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/board/kzm9d.c b/drivers/staging/board/kzm9d.c
index 533f3026e17aa723..8d1eb09bc66ef413 100644
--- a/drivers/staging/board/kzm9d.c
+++ b/drivers/staging/board/kzm9d.c
@@ -4,16 +4,22 @@
 #include <linux/platform_device.h>
 #include "board.h"
 
-static const struct resource usbs1_res[] __initconst = {
+static struct resource usbs1_res[] __initdata = {
 	DEFINE_RES_MEM(0xe2800000, 0x2000),
 	DEFINE_RES_IRQ(159),
 };
 
 static void __init kzm9d_init(void)
 {
-	if (!board_staging_dt_node_available(usbs1_res, ARRAY_SIZE(usbs1_res)))
+	board_staging_gic_setup_xlate("arm,cortex-a9-gic", 32);
+
+	if (!board_staging_dt_node_available(usbs1_res,
+					     ARRAY_SIZE(usbs1_res))) {
+		board_staging_gic_fixup_resources(usbs1_res,
+						  ARRAY_SIZE(usbs1_res));
 		platform_device_register_simple("emxx_udc", -1, usbs1_res,
 						ARRAY_SIZE(usbs1_res));
+	}
 }
 
 board_staging("renesas,kzm9d", kzm9d_init);
-- 
1.9.1

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

* [PATCH v2 4/7] staging: board: kzm9d: Translate hwirq numbers to virq numbers
@ 2015-06-17  8:38   ` Geert Uytterhoeven
  0 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-06-17  8:38 UTC (permalink / raw)
  To: linux-arm-kernel

As of commit 9a1091ef0017c40a ("irqchip: gic: Support hierarchy irq
domain."), GIC IRQ numbers are virtual, breaking hardcoded hardware IRQ
numbers in platform device resources.

Translate the hardware IRQ numbers to virtual IRQ numbers to fix this.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Untested due to lack of hardware

v2:
  - Update for changed function names,
  - Drop RFC status.
---
 drivers/staging/board/kzm9d.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/board/kzm9d.c b/drivers/staging/board/kzm9d.c
index 533f3026e17aa723..8d1eb09bc66ef413 100644
--- a/drivers/staging/board/kzm9d.c
+++ b/drivers/staging/board/kzm9d.c
@@ -4,16 +4,22 @@
 #include <linux/platform_device.h>
 #include "board.h"
 
-static const struct resource usbs1_res[] __initconst = {
+static struct resource usbs1_res[] __initdata = {
 	DEFINE_RES_MEM(0xe2800000, 0x2000),
 	DEFINE_RES_IRQ(159),
 };
 
 static void __init kzm9d_init(void)
 {
-	if (!board_staging_dt_node_available(usbs1_res, ARRAY_SIZE(usbs1_res)))
+	board_staging_gic_setup_xlate("arm,cortex-a9-gic", 32);
+
+	if (!board_staging_dt_node_available(usbs1_res,
+					     ARRAY_SIZE(usbs1_res))) {
+		board_staging_gic_fixup_resources(usbs1_res,
+						  ARRAY_SIZE(usbs1_res));
 		platform_device_register_simple("emxx_udc", -1, usbs1_res,
 						ARRAY_SIZE(usbs1_res));
+	}
 }
 
 board_staging("renesas,kzm9d", kzm9d_init);
-- 
1.9.1

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

* [PATCH v2 5/7] staging: board: Add support for devices with complex dependencies
  2015-06-17  8:38 ` Geert Uytterhoeven
  (?)
  (?)
@ 2015-06-17  8:38   ` Geert Uytterhoeven
  -1 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-06-17  8:38 UTC (permalink / raw)
  To: linux-arm-kernel

Add support for easy registering of one ore more platform devices that
may:
  - need clocks that are described in DT,
  - be part of a PM Domain.

All these dependencies are optional.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - Drop support for pinctrl, use standard pinctrl in DT instead,
  - Drop support for configured GPIOs, use "gpio-hog" in DT instead,
  - Use clk_add_alias() instead of open coding,
  - Update for changed function names,
  - Drop RFC status.
---
 drivers/staging/board/board.c | 56 +++++++++++++++++++++++++++++++++++++++++++
 drivers/staging/board/board.h | 20 ++++++++++++++++
 2 files changed, 76 insertions(+)

diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
index 8712f566b31196e0..29d456e29f38feac 100644
--- a/drivers/staging/board/board.c
+++ b/drivers/staging/board/board.c
@@ -9,6 +9,7 @@
 
 #define pr_fmt(fmt)	"board_staging: "  fmt
 
+#include <linux/clkdev.h>
 #include <linux/init.h>
 #include <linux/irq.h>
 #include <linux/device.h>
@@ -16,6 +17,8 @@
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
+#include <linux/platform_device.h>
+#include <linux/pm_domain.h>
 
 #include "board.h"
 
@@ -118,3 +121,56 @@ void __init board_staging_gic_fixup_resources(struct resource *res,
 	for (i = 0; i < nres; i++)
 		gic_fixup_resource(&res[i]);
 }
+
+int __init board_staging_register_clock(const struct board_staging_clk *bsc)
+{
+	int error;
+
+	pr_debug("Aliasing clock %s for con_id %s dev_id %s\n", bsc->clk,
+		 bsc->con_id, bsc->dev_id);
+	error = clk_add_alias(bsc->con_id, bsc->dev_id, bsc->clk, NULL);
+	if (error)
+		pr_err("Failed to alias clock %s (%d)\n", bsc->clk, error);
+
+	return error;
+}
+
+int __init board_staging_register_device(const struct board_staging_dev *dev)
+{
+	struct platform_device *pdev = dev->pdev;
+	unsigned int i;
+	int error;
+
+	pr_debug("Trying to register device %s\n", pdev->name);
+	if (board_staging_dt_node_available(pdev->resource,
+					    pdev->num_resources)) {
+		pr_warn("Skipping %s, already in DT\n", pdev->name);
+		return -EEXIST;
+	}
+
+	board_staging_gic_fixup_resources(pdev->resource, pdev->num_resources);
+
+	for (i = 0; i < dev->nclocks; i++)
+		board_staging_register_clock(&dev->clocks[i]);
+
+	error = platform_device_register(pdev);
+	if (error) {
+		pr_err("Failed to register device %s (%d)\n", pdev->name,
+		       error);
+		return error;
+	}
+
+	if (dev->domain)
+		__pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
+
+	return error;
+}
+
+void __init board_staging_register_devices(const struct board_staging_dev *devs,
+					   unsigned int ndevs)
+{
+	unsigned int i;
+
+	for (i = 0; i < ndevs; i++)
+		board_staging_register_device(&devs[i]);
+}
diff --git a/drivers/staging/board/board.h b/drivers/staging/board/board.h
index 3af6dbe22f91ebdc..42ed125132201327 100644
--- a/drivers/staging/board/board.h
+++ b/drivers/staging/board/board.h
@@ -4,12 +4,32 @@
 #include <linux/init.h>
 #include <linux/of.h>
 
+struct board_staging_clk {
+	const char *clk;
+	const char *con_id;
+	const char *dev_id;
+};
+
+struct board_staging_dev {
+	/* Platform Device */
+	struct platform_device *pdev;
+	/* Clocks (optional) */
+	const struct board_staging_clk *clocks;
+	unsigned int nclocks;
+	/* Generic PM Domain (optional) */
+	const char *domain;
+};
+
 struct resource;
 
 bool board_staging_dt_node_available(const struct resource *resource,
 				     unsigned int num_resources);
 int board_staging_gic_setup_xlate(const char *gic_match, unsigned int base);
 void board_staging_gic_fixup_resources(struct resource *res, unsigned int nres);
+int board_staging_register_clock(const struct board_staging_clk *bsc);
+int board_staging_register_device(const struct board_staging_dev *dev);
+void board_staging_register_devices(const struct board_staging_dev *devs,
+				    unsigned int ndevs);
 
 #define board_staging(str, fn)			\
 static int __init runtime_board_check(void)	\
-- 
1.9.1


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

* [PATCH v2 5/7] staging: board: Add support for devices with complex dependencies
@ 2015-06-17  8:38   ` Geert Uytterhoeven
  0 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-06-17  8:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Simon Horman, Magnus Damm
  Cc: Arnd Bergmann, Laurent Pinchart, Kuninori Morimoto, Marc Zyngier,
	devel, linux-sh, linux-pm, devicetree, linux-arm-kernel,
	linux-kernel, Geert Uytterhoeven

Add support for easy registering of one ore more platform devices that
may:
  - need clocks that are described in DT,
  - be part of a PM Domain.

All these dependencies are optional.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - Drop support for pinctrl, use standard pinctrl in DT instead,
  - Drop support for configured GPIOs, use "gpio-hog" in DT instead,
  - Use clk_add_alias() instead of open coding,
  - Update for changed function names,
  - Drop RFC status.
---
 drivers/staging/board/board.c | 56 +++++++++++++++++++++++++++++++++++++++++++
 drivers/staging/board/board.h | 20 ++++++++++++++++
 2 files changed, 76 insertions(+)

diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
index 8712f566b31196e0..29d456e29f38feac 100644
--- a/drivers/staging/board/board.c
+++ b/drivers/staging/board/board.c
@@ -9,6 +9,7 @@
 
 #define pr_fmt(fmt)	"board_staging: "  fmt
 
+#include <linux/clkdev.h>
 #include <linux/init.h>
 #include <linux/irq.h>
 #include <linux/device.h>
@@ -16,6 +17,8 @@
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
+#include <linux/platform_device.h>
+#include <linux/pm_domain.h>
 
 #include "board.h"
 
@@ -118,3 +121,56 @@ void __init board_staging_gic_fixup_resources(struct resource *res,
 	for (i = 0; i < nres; i++)
 		gic_fixup_resource(&res[i]);
 }
+
+int __init board_staging_register_clock(const struct board_staging_clk *bsc)
+{
+	int error;
+
+	pr_debug("Aliasing clock %s for con_id %s dev_id %s\n", bsc->clk,
+		 bsc->con_id, bsc->dev_id);
+	error = clk_add_alias(bsc->con_id, bsc->dev_id, bsc->clk, NULL);
+	if (error)
+		pr_err("Failed to alias clock %s (%d)\n", bsc->clk, error);
+
+	return error;
+}
+
+int __init board_staging_register_device(const struct board_staging_dev *dev)
+{
+	struct platform_device *pdev = dev->pdev;
+	unsigned int i;
+	int error;
+
+	pr_debug("Trying to register device %s\n", pdev->name);
+	if (board_staging_dt_node_available(pdev->resource,
+					    pdev->num_resources)) {
+		pr_warn("Skipping %s, already in DT\n", pdev->name);
+		return -EEXIST;
+	}
+
+	board_staging_gic_fixup_resources(pdev->resource, pdev->num_resources);
+
+	for (i = 0; i < dev->nclocks; i++)
+		board_staging_register_clock(&dev->clocks[i]);
+
+	error = platform_device_register(pdev);
+	if (error) {
+		pr_err("Failed to register device %s (%d)\n", pdev->name,
+		       error);
+		return error;
+	}
+
+	if (dev->domain)
+		__pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
+
+	return error;
+}
+
+void __init board_staging_register_devices(const struct board_staging_dev *devs,
+					   unsigned int ndevs)
+{
+	unsigned int i;
+
+	for (i = 0; i < ndevs; i++)
+		board_staging_register_device(&devs[i]);
+}
diff --git a/drivers/staging/board/board.h b/drivers/staging/board/board.h
index 3af6dbe22f91ebdc..42ed125132201327 100644
--- a/drivers/staging/board/board.h
+++ b/drivers/staging/board/board.h
@@ -4,12 +4,32 @@
 #include <linux/init.h>
 #include <linux/of.h>
 
+struct board_staging_clk {
+	const char *clk;
+	const char *con_id;
+	const char *dev_id;
+};
+
+struct board_staging_dev {
+	/* Platform Device */
+	struct platform_device *pdev;
+	/* Clocks (optional) */
+	const struct board_staging_clk *clocks;
+	unsigned int nclocks;
+	/* Generic PM Domain (optional) */
+	const char *domain;
+};
+
 struct resource;
 
 bool board_staging_dt_node_available(const struct resource *resource,
 				     unsigned int num_resources);
 int board_staging_gic_setup_xlate(const char *gic_match, unsigned int base);
 void board_staging_gic_fixup_resources(struct resource *res, unsigned int nres);
+int board_staging_register_clock(const struct board_staging_clk *bsc);
+int board_staging_register_device(const struct board_staging_dev *dev);
+void board_staging_register_devices(const struct board_staging_dev *devs,
+				    unsigned int ndevs);
 
 #define board_staging(str, fn)			\
 static int __init runtime_board_check(void)	\
-- 
1.9.1


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

* [PATCH v2 5/7] staging: board: Add support for devices with complex dependencies
@ 2015-06-17  8:38   ` Geert Uytterhoeven
  0 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-06-17  8:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Simon Horman, Magnus Damm
  Cc: Arnd Bergmann, Laurent Pinchart, Kuninori Morimoto, Marc Zyngier,
	devel-gWbeCf7V1WCQmaza687I9mD2FQJk+8+b,
	linux-sh-u79uwXL29TY76Z2rM5mHXA, linux-pm-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Geert Uytterhoeven

Add support for easy registering of one ore more platform devices that
may:
  - need clocks that are described in DT,
  - be part of a PM Domain.

All these dependencies are optional.

Signed-off-by: Geert Uytterhoeven <geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
---
v2:
  - Drop support for pinctrl, use standard pinctrl in DT instead,
  - Drop support for configured GPIOs, use "gpio-hog" in DT instead,
  - Use clk_add_alias() instead of open coding,
  - Update for changed function names,
  - Drop RFC status.
---
 drivers/staging/board/board.c | 56 +++++++++++++++++++++++++++++++++++++++++++
 drivers/staging/board/board.h | 20 ++++++++++++++++
 2 files changed, 76 insertions(+)

diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
index 8712f566b31196e0..29d456e29f38feac 100644
--- a/drivers/staging/board/board.c
+++ b/drivers/staging/board/board.c
@@ -9,6 +9,7 @@
 
 #define pr_fmt(fmt)	"board_staging: "  fmt
 
+#include <linux/clkdev.h>
 #include <linux/init.h>
 #include <linux/irq.h>
 #include <linux/device.h>
@@ -16,6 +17,8 @@
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
+#include <linux/platform_device.h>
+#include <linux/pm_domain.h>
 
 #include "board.h"
 
@@ -118,3 +121,56 @@ void __init board_staging_gic_fixup_resources(struct resource *res,
 	for (i = 0; i < nres; i++)
 		gic_fixup_resource(&res[i]);
 }
+
+int __init board_staging_register_clock(const struct board_staging_clk *bsc)
+{
+	int error;
+
+	pr_debug("Aliasing clock %s for con_id %s dev_id %s\n", bsc->clk,
+		 bsc->con_id, bsc->dev_id);
+	error = clk_add_alias(bsc->con_id, bsc->dev_id, bsc->clk, NULL);
+	if (error)
+		pr_err("Failed to alias clock %s (%d)\n", bsc->clk, error);
+
+	return error;
+}
+
+int __init board_staging_register_device(const struct board_staging_dev *dev)
+{
+	struct platform_device *pdev = dev->pdev;
+	unsigned int i;
+	int error;
+
+	pr_debug("Trying to register device %s\n", pdev->name);
+	if (board_staging_dt_node_available(pdev->resource,
+					    pdev->num_resources)) {
+		pr_warn("Skipping %s, already in DT\n", pdev->name);
+		return -EEXIST;
+	}
+
+	board_staging_gic_fixup_resources(pdev->resource, pdev->num_resources);
+
+	for (i = 0; i < dev->nclocks; i++)
+		board_staging_register_clock(&dev->clocks[i]);
+
+	error = platform_device_register(pdev);
+	if (error) {
+		pr_err("Failed to register device %s (%d)\n", pdev->name,
+		       error);
+		return error;
+	}
+
+	if (dev->domain)
+		__pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
+
+	return error;
+}
+
+void __init board_staging_register_devices(const struct board_staging_dev *devs,
+					   unsigned int ndevs)
+{
+	unsigned int i;
+
+	for (i = 0; i < ndevs; i++)
+		board_staging_register_device(&devs[i]);
+}
diff --git a/drivers/staging/board/board.h b/drivers/staging/board/board.h
index 3af6dbe22f91ebdc..42ed125132201327 100644
--- a/drivers/staging/board/board.h
+++ b/drivers/staging/board/board.h
@@ -4,12 +4,32 @@
 #include <linux/init.h>
 #include <linux/of.h>
 
+struct board_staging_clk {
+	const char *clk;
+	const char *con_id;
+	const char *dev_id;
+};
+
+struct board_staging_dev {
+	/* Platform Device */
+	struct platform_device *pdev;
+	/* Clocks (optional) */
+	const struct board_staging_clk *clocks;
+	unsigned int nclocks;
+	/* Generic PM Domain (optional) */
+	const char *domain;
+};
+
 struct resource;
 
 bool board_staging_dt_node_available(const struct resource *resource,
 				     unsigned int num_resources);
 int board_staging_gic_setup_xlate(const char *gic_match, unsigned int base);
 void board_staging_gic_fixup_resources(struct resource *res, unsigned int nres);
+int board_staging_register_clock(const struct board_staging_clk *bsc);
+int board_staging_register_device(const struct board_staging_dev *dev);
+void board_staging_register_devices(const struct board_staging_dev *devs,
+				    unsigned int ndevs);
 
 #define board_staging(str, fn)			\
 static int __init runtime_board_check(void)	\
-- 
1.9.1

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

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

* [PATCH v2 5/7] staging: board: Add support for devices with complex dependencies
@ 2015-06-17  8:38   ` Geert Uytterhoeven
  0 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-06-17  8:38 UTC (permalink / raw)
  To: linux-arm-kernel

Add support for easy registering of one ore more platform devices that
may:
  - need clocks that are described in DT,
  - be part of a PM Domain.

All these dependencies are optional.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - Drop support for pinctrl, use standard pinctrl in DT instead,
  - Drop support for configured GPIOs, use "gpio-hog" in DT instead,
  - Use clk_add_alias() instead of open coding,
  - Update for changed function names,
  - Drop RFC status.
---
 drivers/staging/board/board.c | 56 +++++++++++++++++++++++++++++++++++++++++++
 drivers/staging/board/board.h | 20 ++++++++++++++++
 2 files changed, 76 insertions(+)

diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
index 8712f566b31196e0..29d456e29f38feac 100644
--- a/drivers/staging/board/board.c
+++ b/drivers/staging/board/board.c
@@ -9,6 +9,7 @@
 
 #define pr_fmt(fmt)	"board_staging: "  fmt
 
+#include <linux/clkdev.h>
 #include <linux/init.h>
 #include <linux/irq.h>
 #include <linux/device.h>
@@ -16,6 +17,8 @@
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
+#include <linux/platform_device.h>
+#include <linux/pm_domain.h>
 
 #include "board.h"
 
@@ -118,3 +121,56 @@ void __init board_staging_gic_fixup_resources(struct resource *res,
 	for (i = 0; i < nres; i++)
 		gic_fixup_resource(&res[i]);
 }
+
+int __init board_staging_register_clock(const struct board_staging_clk *bsc)
+{
+	int error;
+
+	pr_debug("Aliasing clock %s for con_id %s dev_id %s\n", bsc->clk,
+		 bsc->con_id, bsc->dev_id);
+	error = clk_add_alias(bsc->con_id, bsc->dev_id, bsc->clk, NULL);
+	if (error)
+		pr_err("Failed to alias clock %s (%d)\n", bsc->clk, error);
+
+	return error;
+}
+
+int __init board_staging_register_device(const struct board_staging_dev *dev)
+{
+	struct platform_device *pdev = dev->pdev;
+	unsigned int i;
+	int error;
+
+	pr_debug("Trying to register device %s\n", pdev->name);
+	if (board_staging_dt_node_available(pdev->resource,
+					    pdev->num_resources)) {
+		pr_warn("Skipping %s, already in DT\n", pdev->name);
+		return -EEXIST;
+	}
+
+	board_staging_gic_fixup_resources(pdev->resource, pdev->num_resources);
+
+	for (i = 0; i < dev->nclocks; i++)
+		board_staging_register_clock(&dev->clocks[i]);
+
+	error = platform_device_register(pdev);
+	if (error) {
+		pr_err("Failed to register device %s (%d)\n", pdev->name,
+		       error);
+		return error;
+	}
+
+	if (dev->domain)
+		__pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
+
+	return error;
+}
+
+void __init board_staging_register_devices(const struct board_staging_dev *devs,
+					   unsigned int ndevs)
+{
+	unsigned int i;
+
+	for (i = 0; i < ndevs; i++)
+		board_staging_register_device(&devs[i]);
+}
diff --git a/drivers/staging/board/board.h b/drivers/staging/board/board.h
index 3af6dbe22f91ebdc..42ed125132201327 100644
--- a/drivers/staging/board/board.h
+++ b/drivers/staging/board/board.h
@@ -4,12 +4,32 @@
 #include <linux/init.h>
 #include <linux/of.h>
 
+struct board_staging_clk {
+	const char *clk;
+	const char *con_id;
+	const char *dev_id;
+};
+
+struct board_staging_dev {
+	/* Platform Device */
+	struct platform_device *pdev;
+	/* Clocks (optional) */
+	const struct board_staging_clk *clocks;
+	unsigned int nclocks;
+	/* Generic PM Domain (optional) */
+	const char *domain;
+};
+
 struct resource;
 
 bool board_staging_dt_node_available(const struct resource *resource,
 				     unsigned int num_resources);
 int board_staging_gic_setup_xlate(const char *gic_match, unsigned int base);
 void board_staging_gic_fixup_resources(struct resource *res, unsigned int nres);
+int board_staging_register_clock(const struct board_staging_clk *bsc);
+int board_staging_register_device(const struct board_staging_dev *dev);
+void board_staging_register_devices(const struct board_staging_dev *devs,
+				    unsigned int ndevs);
 
 #define board_staging(str, fn)			\
 static int __init runtime_board_check(void)	\
-- 
1.9.1

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

* [PATCH v2 6/7] staging: board: armadillo800eva: Board staging for sh_mobile_lcdc_fb
  2015-06-17  8:38 ` Geert Uytterhoeven
  (?)
  (?)
@ 2015-06-17  8:38   ` Geert Uytterhoeven
  -1 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-06-17  8:38 UTC (permalink / raw)
  To: linux-arm-kernel

Add staging board support for the r8a7740-based armadillo800eva board
and add platform devices to allow in-tree continuous development of the
drivers on the armadillo800eva board.

When DT bindings are ready for theses drivers then the platform devices
in the armadillo800eva staging board code can easily be removed. Until
then we use platform devices to continuously improve the driver and
integrate code.

Added platform devices:
  - sh_mobile_lcdc_fb for the on-board LCD.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - Drop pinctrl and configured GPIOs, these are now configured from DT,
  - Update for changed function names,
  - Drop RFC status.
---
 drivers/staging/board/Makefile          |   3 +-
 drivers/staging/board/armadillo800eva.c | 105 ++++++++++++++++++++++++++++++++
 2 files changed, 107 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/board/armadillo800eva.c

diff --git a/drivers/staging/board/Makefile b/drivers/staging/board/Makefile
index 65d39ecfad63bbf4..6842745feb9404f8 100644
--- a/drivers/staging/board/Makefile
+++ b/drivers/staging/board/Makefile
@@ -1,2 +1,3 @@
 obj-y	:= board.o
-obj-$(CONFIG_ARCH_EMEV2)      += kzm9d.o
+obj-$(CONFIG_ARCH_EMEV2)	+= kzm9d.o
+obj-$(CONFIG_ARCH_R8A7740)	+= armadillo800eva.o
diff --git a/drivers/staging/board/armadillo800eva.c b/drivers/staging/board/armadillo800eva.c
new file mode 100644
index 0000000000000000..81df77bd55cc9868
--- /dev/null
+++ b/drivers/staging/board/armadillo800eva.c
@@ -0,0 +1,105 @@
+/*
+ * Staging board support for Armadillo 800 eva.
+ * Enable not-yet-DT-capable devices here.
+ *
+ * Based on board-armadillo800eva.c
+ *
+ * Copyright (C) 2012 Renesas Solutions Corp.
+ * Copyright (C) 2012 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/dma-mapping.h>
+#include <linux/fb.h>
+#include <linux/kernel.h>
+#include <linux/platform_device.h>
+#include <linux/videodev2.h>
+
+#include <video/sh_mobile_lcdc.h>
+
+#include "board.h"
+
+
+static struct fb_videomode lcdc0_mode = {
+	.name		= "AMPIER/AM-800480",
+	.xres		= 800,
+	.yres		= 480,
+	.left_margin	= 88,
+	.right_margin	= 40,
+	.hsync_len	= 128,
+	.upper_margin	= 20,
+	.lower_margin	= 5,
+	.vsync_len	= 5,
+	.sync		= 0,
+};
+
+static struct sh_mobile_lcdc_info lcdc0_info = {
+	.clock_source	= LCDC_CLK_BUS,
+	.ch[0] = {
+		.chan		= LCDC_CHAN_MAINLCD,
+		.fourcc		= V4L2_PIX_FMT_RGB565,
+		.interface_type	= RGB24,
+		.clock_divider	= 5,
+		.flags		= 0,
+		.lcd_modes	= &lcdc0_mode,
+		.num_modes	= 1,
+		.panel_cfg = {
+			.width	= 111,
+			.height = 68,
+		},
+	},
+};
+
+static struct resource lcdc0_resources[] = {
+	[0] = {
+		.name	= "LCD0",
+		.start	= 0xfe940000,
+		.end	= 0xfe943fff,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {
+		.start	= 177 + 32,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device lcdc0_device = {
+	.name		= "sh_mobile_lcdc_fb",
+	.num_resources	= ARRAY_SIZE(lcdc0_resources),
+	.resource	= lcdc0_resources,
+	.id		= 0,
+	.dev	= {
+		.platform_data	= &lcdc0_info,
+		.coherent_dma_mask = DMA_BIT_MASK(32),
+	},
+};
+
+static const struct board_staging_clk lcdc0_clocks[] __initconst = {
+	{ "lcdc0", NULL, "sh_mobile_lcdc_fb.0" },
+};
+
+static const struct board_staging_dev armadillo800eva_devices[] __initconst = {
+	{
+		.pdev		= &lcdc0_device,
+		.clocks		= lcdc0_clocks,
+		.nclocks	= ARRAY_SIZE(lcdc0_clocks),
+		.domain		= "a4lc",
+	},
+};
+
+static void __init armadillo800eva_init(void)
+{
+	board_staging_gic_setup_xlate("arm,cortex-a9-gic", 32);
+	board_staging_register_devices(armadillo800eva_devices,
+				       ARRAY_SIZE(armadillo800eva_devices));
+}
+
+board_staging("renesas,armadillo800eva", armadillo800eva_init);
-- 
1.9.1


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

* [PATCH v2 6/7] staging: board: armadillo800eva: Board staging for sh_mobile_lcdc_fb
@ 2015-06-17  8:38   ` Geert Uytterhoeven
  0 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-06-17  8:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Simon Horman, Magnus Damm
  Cc: Arnd Bergmann, Laurent Pinchart, Kuninori Morimoto, Marc Zyngier,
	devel, linux-sh, linux-pm, devicetree, linux-arm-kernel,
	linux-kernel, Geert Uytterhoeven

Add staging board support for the r8a7740-based armadillo800eva board
and add platform devices to allow in-tree continuous development of the
drivers on the armadillo800eva board.

When DT bindings are ready for theses drivers then the platform devices
in the armadillo800eva staging board code can easily be removed. Until
then we use platform devices to continuously improve the driver and
integrate code.

Added platform devices:
  - sh_mobile_lcdc_fb for the on-board LCD.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - Drop pinctrl and configured GPIOs, these are now configured from DT,
  - Update for changed function names,
  - Drop RFC status.
---
 drivers/staging/board/Makefile          |   3 +-
 drivers/staging/board/armadillo800eva.c | 105 ++++++++++++++++++++++++++++++++
 2 files changed, 107 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/board/armadillo800eva.c

diff --git a/drivers/staging/board/Makefile b/drivers/staging/board/Makefile
index 65d39ecfad63bbf4..6842745feb9404f8 100644
--- a/drivers/staging/board/Makefile
+++ b/drivers/staging/board/Makefile
@@ -1,2 +1,3 @@
 obj-y	:= board.o
-obj-$(CONFIG_ARCH_EMEV2)      += kzm9d.o
+obj-$(CONFIG_ARCH_EMEV2)	+= kzm9d.o
+obj-$(CONFIG_ARCH_R8A7740)	+= armadillo800eva.o
diff --git a/drivers/staging/board/armadillo800eva.c b/drivers/staging/board/armadillo800eva.c
new file mode 100644
index 0000000000000000..81df77bd55cc9868
--- /dev/null
+++ b/drivers/staging/board/armadillo800eva.c
@@ -0,0 +1,105 @@
+/*
+ * Staging board support for Armadillo 800 eva.
+ * Enable not-yet-DT-capable devices here.
+ *
+ * Based on board-armadillo800eva.c
+ *
+ * Copyright (C) 2012 Renesas Solutions Corp.
+ * Copyright (C) 2012 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/dma-mapping.h>
+#include <linux/fb.h>
+#include <linux/kernel.h>
+#include <linux/platform_device.h>
+#include <linux/videodev2.h>
+
+#include <video/sh_mobile_lcdc.h>
+
+#include "board.h"
+
+
+static struct fb_videomode lcdc0_mode = {
+	.name		= "AMPIER/AM-800480",
+	.xres		= 800,
+	.yres		= 480,
+	.left_margin	= 88,
+	.right_margin	= 40,
+	.hsync_len	= 128,
+	.upper_margin	= 20,
+	.lower_margin	= 5,
+	.vsync_len	= 5,
+	.sync		= 0,
+};
+
+static struct sh_mobile_lcdc_info lcdc0_info = {
+	.clock_source	= LCDC_CLK_BUS,
+	.ch[0] = {
+		.chan		= LCDC_CHAN_MAINLCD,
+		.fourcc		= V4L2_PIX_FMT_RGB565,
+		.interface_type	= RGB24,
+		.clock_divider	= 5,
+		.flags		= 0,
+		.lcd_modes	= &lcdc0_mode,
+		.num_modes	= 1,
+		.panel_cfg = {
+			.width	= 111,
+			.height = 68,
+		},
+	},
+};
+
+static struct resource lcdc0_resources[] = {
+	[0] = {
+		.name	= "LCD0",
+		.start	= 0xfe940000,
+		.end	= 0xfe943fff,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {
+		.start	= 177 + 32,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device lcdc0_device = {
+	.name		= "sh_mobile_lcdc_fb",
+	.num_resources	= ARRAY_SIZE(lcdc0_resources),
+	.resource	= lcdc0_resources,
+	.id		= 0,
+	.dev	= {
+		.platform_data	= &lcdc0_info,
+		.coherent_dma_mask = DMA_BIT_MASK(32),
+	},
+};
+
+static const struct board_staging_clk lcdc0_clocks[] __initconst = {
+	{ "lcdc0", NULL, "sh_mobile_lcdc_fb.0" },
+};
+
+static const struct board_staging_dev armadillo800eva_devices[] __initconst = {
+	{
+		.pdev		= &lcdc0_device,
+		.clocks		= lcdc0_clocks,
+		.nclocks	= ARRAY_SIZE(lcdc0_clocks),
+		.domain		= "a4lc",
+	},
+};
+
+static void __init armadillo800eva_init(void)
+{
+	board_staging_gic_setup_xlate("arm,cortex-a9-gic", 32);
+	board_staging_register_devices(armadillo800eva_devices,
+				       ARRAY_SIZE(armadillo800eva_devices));
+}
+
+board_staging("renesas,armadillo800eva", armadillo800eva_init);
-- 
1.9.1


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

* [PATCH v2 6/7] staging: board: armadillo800eva: Board staging for sh_mobile_lcdc_fb
@ 2015-06-17  8:38   ` Geert Uytterhoeven
  0 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-06-17  8:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Simon Horman, Magnus Damm
  Cc: devel, devicetree, Arnd Bergmann, Kuninori Morimoto, linux-sh,
	Marc Zyngier, linux-pm, linux-kernel, Laurent Pinchart,
	Geert Uytterhoeven, linux-arm-kernel

Add staging board support for the r8a7740-based armadillo800eva board
and add platform devices to allow in-tree continuous development of the
drivers on the armadillo800eva board.

When DT bindings are ready for theses drivers then the platform devices
in the armadillo800eva staging board code can easily be removed. Until
then we use platform devices to continuously improve the driver and
integrate code.

Added platform devices:
  - sh_mobile_lcdc_fb for the on-board LCD.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - Drop pinctrl and configured GPIOs, these are now configured from DT,
  - Update for changed function names,
  - Drop RFC status.
---
 drivers/staging/board/Makefile          |   3 +-
 drivers/staging/board/armadillo800eva.c | 105 ++++++++++++++++++++++++++++++++
 2 files changed, 107 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/board/armadillo800eva.c

diff --git a/drivers/staging/board/Makefile b/drivers/staging/board/Makefile
index 65d39ecfad63bbf4..6842745feb9404f8 100644
--- a/drivers/staging/board/Makefile
+++ b/drivers/staging/board/Makefile
@@ -1,2 +1,3 @@
 obj-y	:= board.o
-obj-$(CONFIG_ARCH_EMEV2)      += kzm9d.o
+obj-$(CONFIG_ARCH_EMEV2)	+= kzm9d.o
+obj-$(CONFIG_ARCH_R8A7740)	+= armadillo800eva.o
diff --git a/drivers/staging/board/armadillo800eva.c b/drivers/staging/board/armadillo800eva.c
new file mode 100644
index 0000000000000000..81df77bd55cc9868
--- /dev/null
+++ b/drivers/staging/board/armadillo800eva.c
@@ -0,0 +1,105 @@
+/*
+ * Staging board support for Armadillo 800 eva.
+ * Enable not-yet-DT-capable devices here.
+ *
+ * Based on board-armadillo800eva.c
+ *
+ * Copyright (C) 2012 Renesas Solutions Corp.
+ * Copyright (C) 2012 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/dma-mapping.h>
+#include <linux/fb.h>
+#include <linux/kernel.h>
+#include <linux/platform_device.h>
+#include <linux/videodev2.h>
+
+#include <video/sh_mobile_lcdc.h>
+
+#include "board.h"
+
+
+static struct fb_videomode lcdc0_mode = {
+	.name		= "AMPIER/AM-800480",
+	.xres		= 800,
+	.yres		= 480,
+	.left_margin	= 88,
+	.right_margin	= 40,
+	.hsync_len	= 128,
+	.upper_margin	= 20,
+	.lower_margin	= 5,
+	.vsync_len	= 5,
+	.sync		= 0,
+};
+
+static struct sh_mobile_lcdc_info lcdc0_info = {
+	.clock_source	= LCDC_CLK_BUS,
+	.ch[0] = {
+		.chan		= LCDC_CHAN_MAINLCD,
+		.fourcc		= V4L2_PIX_FMT_RGB565,
+		.interface_type	= RGB24,
+		.clock_divider	= 5,
+		.flags		= 0,
+		.lcd_modes	= &lcdc0_mode,
+		.num_modes	= 1,
+		.panel_cfg = {
+			.width	= 111,
+			.height = 68,
+		},
+	},
+};
+
+static struct resource lcdc0_resources[] = {
+	[0] = {
+		.name	= "LCD0",
+		.start	= 0xfe940000,
+		.end	= 0xfe943fff,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {
+		.start	= 177 + 32,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device lcdc0_device = {
+	.name		= "sh_mobile_lcdc_fb",
+	.num_resources	= ARRAY_SIZE(lcdc0_resources),
+	.resource	= lcdc0_resources,
+	.id		= 0,
+	.dev	= {
+		.platform_data	= &lcdc0_info,
+		.coherent_dma_mask = DMA_BIT_MASK(32),
+	},
+};
+
+static const struct board_staging_clk lcdc0_clocks[] __initconst = {
+	{ "lcdc0", NULL, "sh_mobile_lcdc_fb.0" },
+};
+
+static const struct board_staging_dev armadillo800eva_devices[] __initconst = {
+	{
+		.pdev		= &lcdc0_device,
+		.clocks		= lcdc0_clocks,
+		.nclocks	= ARRAY_SIZE(lcdc0_clocks),
+		.domain		= "a4lc",
+	},
+};
+
+static void __init armadillo800eva_init(void)
+{
+	board_staging_gic_setup_xlate("arm,cortex-a9-gic", 32);
+	board_staging_register_devices(armadillo800eva_devices,
+				       ARRAY_SIZE(armadillo800eva_devices));
+}
+
+board_staging("renesas,armadillo800eva", armadillo800eva_init);
-- 
1.9.1

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

* [PATCH v2 6/7] staging: board: armadillo800eva: Board staging for sh_mobile_lcdc_fb
@ 2015-06-17  8:38   ` Geert Uytterhoeven
  0 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-06-17  8:38 UTC (permalink / raw)
  To: linux-arm-kernel

Add staging board support for the r8a7740-based armadillo800eva board
and add platform devices to allow in-tree continuous development of the
drivers on the armadillo800eva board.

When DT bindings are ready for theses drivers then the platform devices
in the armadillo800eva staging board code can easily be removed. Until
then we use platform devices to continuously improve the driver and
integrate code.

Added platform devices:
  - sh_mobile_lcdc_fb for the on-board LCD.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - Drop pinctrl and configured GPIOs, these are now configured from DT,
  - Update for changed function names,
  - Drop RFC status.
---
 drivers/staging/board/Makefile          |   3 +-
 drivers/staging/board/armadillo800eva.c | 105 ++++++++++++++++++++++++++++++++
 2 files changed, 107 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/board/armadillo800eva.c

diff --git a/drivers/staging/board/Makefile b/drivers/staging/board/Makefile
index 65d39ecfad63bbf4..6842745feb9404f8 100644
--- a/drivers/staging/board/Makefile
+++ b/drivers/staging/board/Makefile
@@ -1,2 +1,3 @@
 obj-y	:= board.o
-obj-$(CONFIG_ARCH_EMEV2)      += kzm9d.o
+obj-$(CONFIG_ARCH_EMEV2)	+= kzm9d.o
+obj-$(CONFIG_ARCH_R8A7740)	+= armadillo800eva.o
diff --git a/drivers/staging/board/armadillo800eva.c b/drivers/staging/board/armadillo800eva.c
new file mode 100644
index 0000000000000000..81df77bd55cc9868
--- /dev/null
+++ b/drivers/staging/board/armadillo800eva.c
@@ -0,0 +1,105 @@
+/*
+ * Staging board support for Armadillo 800 eva.
+ * Enable not-yet-DT-capable devices here.
+ *
+ * Based on board-armadillo800eva.c
+ *
+ * Copyright (C) 2012 Renesas Solutions Corp.
+ * Copyright (C) 2012 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/dma-mapping.h>
+#include <linux/fb.h>
+#include <linux/kernel.h>
+#include <linux/platform_device.h>
+#include <linux/videodev2.h>
+
+#include <video/sh_mobile_lcdc.h>
+
+#include "board.h"
+
+
+static struct fb_videomode lcdc0_mode = {
+	.name		= "AMPIER/AM-800480",
+	.xres		= 800,
+	.yres		= 480,
+	.left_margin	= 88,
+	.right_margin	= 40,
+	.hsync_len	= 128,
+	.upper_margin	= 20,
+	.lower_margin	= 5,
+	.vsync_len	= 5,
+	.sync		= 0,
+};
+
+static struct sh_mobile_lcdc_info lcdc0_info = {
+	.clock_source	= LCDC_CLK_BUS,
+	.ch[0] = {
+		.chan		= LCDC_CHAN_MAINLCD,
+		.fourcc		= V4L2_PIX_FMT_RGB565,
+		.interface_type	= RGB24,
+		.clock_divider	= 5,
+		.flags		= 0,
+		.lcd_modes	= &lcdc0_mode,
+		.num_modes	= 1,
+		.panel_cfg = {
+			.width	= 111,
+			.height = 68,
+		},
+	},
+};
+
+static struct resource lcdc0_resources[] = {
+	[0] = {
+		.name	= "LCD0",
+		.start	= 0xfe940000,
+		.end	= 0xfe943fff,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {
+		.start	= 177 + 32,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device lcdc0_device = {
+	.name		= "sh_mobile_lcdc_fb",
+	.num_resources	= ARRAY_SIZE(lcdc0_resources),
+	.resource	= lcdc0_resources,
+	.id		= 0,
+	.dev	= {
+		.platform_data	= &lcdc0_info,
+		.coherent_dma_mask = DMA_BIT_MASK(32),
+	},
+};
+
+static const struct board_staging_clk lcdc0_clocks[] __initconst = {
+	{ "lcdc0", NULL, "sh_mobile_lcdc_fb.0" },
+};
+
+static const struct board_staging_dev armadillo800eva_devices[] __initconst = {
+	{
+		.pdev		= &lcdc0_device,
+		.clocks		= lcdc0_clocks,
+		.nclocks	= ARRAY_SIZE(lcdc0_clocks),
+		.domain		= "a4lc",
+	},
+};
+
+static void __init armadillo800eva_init(void)
+{
+	board_staging_gic_setup_xlate("arm,cortex-a9-gic", 32);
+	board_staging_register_devices(armadillo800eva_devices,
+				       ARRAY_SIZE(armadillo800eva_devices));
+}
+
+board_staging("renesas,armadillo800eva", armadillo800eva_init);
-- 
1.9.1

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

* [PATCH v2 7/7] ARM: shmobile: armadillo800eva dts: Add pinctrl and gpio-hog for lcdc0
  2015-06-17  8:38 ` Geert Uytterhoeven
  (?)
  (?)
@ 2015-06-17  8:38   ` Geert Uytterhoeven
  -1 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-06-17  8:38 UTC (permalink / raw)
  To: linux-arm-kernel

Configure pinctrl and a GPIO-controller board mux for LCD use.
This allows the armadillo800eva board staging code to enable lcdc0.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.
---
 arch/arm/boot/dts/r8a7740-armadillo800eva.dts | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/arch/arm/boot/dts/r8a7740-armadillo800eva.dts b/arch/arm/boot/dts/r8a7740-armadillo800eva.dts
index 2e31d8c01cbf6a74..105d9c95de4af611 100644
--- a/arch/arm/boot/dts/r8a7740-armadillo800eva.dts
+++ b/arch/arm/boot/dts/r8a7740-armadillo800eva.dts
@@ -224,6 +224,9 @@
 };
 
 &pfc {
+	pinctrl-0 = <&lcd0_pins>;
+	pinctrl-names = "default";
+
 	ether_pins: ether {
 		renesas,groups = "gether_mii", "gether_int";
 		renesas,function = "gether";
@@ -259,6 +262,16 @@
 				 "fsia_data_in_1", "fsia_data_out_0";
 		renesas,function = "fsia";
 	};
+
+	lcd0_pins: lcd0 {
+		renesas,groups = "lcd0_data24_0", "lcd0_lclk_1", "lcd0_sync";
+		renesas,function = "lcd0";
+
+		/* DBGMD/LCDC0/FSIA MUX */
+		gpio-hog;
+		gpios = <176 0>;
+		output-high;
+	};
 };
 
 &tpu {
-- 
1.9.1


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

* [PATCH v2 7/7] ARM: shmobile: armadillo800eva dts: Add pinctrl and gpio-hog for lcdc0
@ 2015-06-17  8:38   ` Geert Uytterhoeven
  0 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-06-17  8:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Simon Horman, Magnus Damm
  Cc: Arnd Bergmann, Laurent Pinchart, Kuninori Morimoto, Marc Zyngier,
	devel, linux-sh, linux-pm, devicetree, linux-arm-kernel,
	linux-kernel, Geert Uytterhoeven

Configure pinctrl and a GPIO-controller board mux for LCD use.
This allows the armadillo800eva board staging code to enable lcdc0.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.
---
 arch/arm/boot/dts/r8a7740-armadillo800eva.dts | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/arch/arm/boot/dts/r8a7740-armadillo800eva.dts b/arch/arm/boot/dts/r8a7740-armadillo800eva.dts
index 2e31d8c01cbf6a74..105d9c95de4af611 100644
--- a/arch/arm/boot/dts/r8a7740-armadillo800eva.dts
+++ b/arch/arm/boot/dts/r8a7740-armadillo800eva.dts
@@ -224,6 +224,9 @@
 };
 
 &pfc {
+	pinctrl-0 = <&lcd0_pins>;
+	pinctrl-names = "default";
+
 	ether_pins: ether {
 		renesas,groups = "gether_mii", "gether_int";
 		renesas,function = "gether";
@@ -259,6 +262,16 @@
 				 "fsia_data_in_1", "fsia_data_out_0";
 		renesas,function = "fsia";
 	};
+
+	lcd0_pins: lcd0 {
+		renesas,groups = "lcd0_data24_0", "lcd0_lclk_1", "lcd0_sync";
+		renesas,function = "lcd0";
+
+		/* DBGMD/LCDC0/FSIA MUX */
+		gpio-hog;
+		gpios = <176 0>;
+		output-high;
+	};
 };
 
 &tpu {
-- 
1.9.1


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

* [PATCH v2 7/7] ARM: shmobile: armadillo800eva dts: Add pinctrl and gpio-hog for lcdc0
@ 2015-06-17  8:38   ` Geert Uytterhoeven
  0 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-06-17  8:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Simon Horman, Magnus Damm
  Cc: devel, devicetree, Arnd Bergmann, Kuninori Morimoto, linux-sh,
	Marc Zyngier, linux-pm, linux-kernel, Laurent Pinchart,
	Geert Uytterhoeven, linux-arm-kernel

Configure pinctrl and a GPIO-controller board mux for LCD use.
This allows the armadillo800eva board staging code to enable lcdc0.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.
---
 arch/arm/boot/dts/r8a7740-armadillo800eva.dts | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/arch/arm/boot/dts/r8a7740-armadillo800eva.dts b/arch/arm/boot/dts/r8a7740-armadillo800eva.dts
index 2e31d8c01cbf6a74..105d9c95de4af611 100644
--- a/arch/arm/boot/dts/r8a7740-armadillo800eva.dts
+++ b/arch/arm/boot/dts/r8a7740-armadillo800eva.dts
@@ -224,6 +224,9 @@
 };
 
 &pfc {
+	pinctrl-0 = <&lcd0_pins>;
+	pinctrl-names = "default";
+
 	ether_pins: ether {
 		renesas,groups = "gether_mii", "gether_int";
 		renesas,function = "gether";
@@ -259,6 +262,16 @@
 				 "fsia_data_in_1", "fsia_data_out_0";
 		renesas,function = "fsia";
 	};
+
+	lcd0_pins: lcd0 {
+		renesas,groups = "lcd0_data24_0", "lcd0_lclk_1", "lcd0_sync";
+		renesas,function = "lcd0";
+
+		/* DBGMD/LCDC0/FSIA MUX */
+		gpio-hog;
+		gpios = <176 0>;
+		output-high;
+	};
 };
 
 &tpu {
-- 
1.9.1

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

* [PATCH v2 7/7] ARM: shmobile: armadillo800eva dts: Add pinctrl and gpio-hog for lcdc0
@ 2015-06-17  8:38   ` Geert Uytterhoeven
  0 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-06-17  8:38 UTC (permalink / raw)
  To: linux-arm-kernel

Configure pinctrl and a GPIO-controller board mux for LCD use.
This allows the armadillo800eva board staging code to enable lcdc0.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.
---
 arch/arm/boot/dts/r8a7740-armadillo800eva.dts | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/arch/arm/boot/dts/r8a7740-armadillo800eva.dts b/arch/arm/boot/dts/r8a7740-armadillo800eva.dts
index 2e31d8c01cbf6a74..105d9c95de4af611 100644
--- a/arch/arm/boot/dts/r8a7740-armadillo800eva.dts
+++ b/arch/arm/boot/dts/r8a7740-armadillo800eva.dts
@@ -224,6 +224,9 @@
 };
 
 &pfc {
+	pinctrl-0 = <&lcd0_pins>;
+	pinctrl-names = "default";
+
 	ether_pins: ether {
 		renesas,groups = "gether_mii", "gether_int";
 		renesas,function = "gether";
@@ -259,6 +262,16 @@
 				 "fsia_data_in_1", "fsia_data_out_0";
 		renesas,function = "fsia";
 	};
+
+	lcd0_pins: lcd0 {
+		renesas,groups = "lcd0_data24_0", "lcd0_lclk_1", "lcd0_sync";
+		renesas,function = "lcd0";
+
+		/* DBGMD/LCDC0/FSIA MUX */
+		gpio-hog;
+		gpios = <176 0>;
+		output-high;
+	};
 };
 
 &tpu {
-- 
1.9.1

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

* Re: [PATCH v2 0/7] staging: board: armadillo800eva: Board staging for sh_mobile_lcdc_fb
  2015-06-17  8:38 ` Geert Uytterhoeven
  (?)
@ 2015-06-18  4:08   ` Simon Horman
  -1 siblings, 0 replies; 61+ messages in thread
From: Simon Horman @ 2015-06-18  4:08 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jun 17, 2015 at 10:38:49AM +0200, Geert Uytterhoeven wrote:
> 	Hi Greg, Simon, Magnus,
> 
> This patch series adds board staging support for the Renesas R-Mobile A1
> (r8a7740) based Armadillo-800 EVA board. It allows to support the frame
> buffer device for the on-board LCD (which isn't supported by a DT-aware
> driver yet) in modern DT-based multi-platform kernels.
> 
> The board staging area was introduced last year to allow continuous
> upstream in-tree development and integration of platform devices. It
> helps developers integrate devices as platform devices for device
> drivers that only provide platform device bindings.  This in turn allows
> for incremental development of both hardware feature support and DT
> binding work in parallel.
> 
> The goal is to complete the move to ARM multi-platform kernels for all
> shmobile platforms, and drop the existing board files
> (arch/arm/mach-shmobile/board-*). Once this series is accepted, more
> than 3000 lines of legacy armadillo board code and r8a7740 SoC code can
> be removed.
> 
> This series consists of 5 parts:
>   - Patch 1 re-enables compilation of the board staging area, which was
>     disabled after a compile breakage, but has been fixed in the mean
>     time,
>   - Path 2 moves initialization of staging board code to an earlier
>     moment, as currently it happens after unused PM domains are powered
>     down,
>   - Patches 3 and 4 (hopefully) fix the existing kzm9d board staging
>     code, which was presumably "broken" by commit 9a1091ef0017c40a
>     ("irqchip: gic: Support hierarchy irq domain."),
>   - Patches 5 and 6 add support for registering platform devices with
>     complex dependencies (clocks and PM domains), and add armadillo
>     board staging code for enabling a frame buffer on the on-board LCD,
>   - Patch 7 (new) adds pinctrl and gpio-hog configuration to enable the
>     LCD.
> 
> The first 6 patches should go in through the staging tree, the last one
> through the shmobile tree.
> 
> Major changes since v1 (more detailed changelogs in the individual
> patches):
>   - Add support for low/high edge/level interrupts in hwirq translation,
>   - Move pinctrl and GPIO configuration from board staging code to DT,
>   - Use clk_add_alias() instead of open coding.
> 
> Dependencies:
>   - This is against next-20150617,
>   - The gpio-hog in patch 7 depends on a bug fix like "[PATCH] [RFC]
>     gpio: Retry deferred GPIO hogging on pin range change"
>     (https://lkml.org/lkml/2015/6/16/455). It can be applied as-is
>     though.
> 
> This was tested on r8a7740/armadillo.
> This was not tested on emev2/kzm9d, due to lack of hardware.

I have verified that kzm9d still boots with your patches applied on top
of renesas-devel-20150617-v4.1-rc8. I used shmobile_defconfig and
then enabled CONFIG_STAGING and in turn CONFIG_STAGING_BOARD.

Let me know if you think further testing is appropriate.

> Thanks for applying!
> 
> Geert Uytterhoeven (7):
>   Revert "staging: board: disable as it breaks the build"
>   staging: board: Initialize staging board code earlier
>   staging: board: Add support for translating hwirq to virq numbers
>   staging: board: kzm9d: Translate hwirq numbers to virq numbers
>   staging: board: Add support for devices with complex dependencies
>   staging: board: armadillo800eva: Board staging for sh_mobile_lcdc_fb

Feel free to add:

Acked-by: Simon Horman <horms+renesas@verge.net.au>

to the above.

>   ARM: shmobile: armadillo800eva dts: Add pinctrl and gpio-hog for lcdc0
> 
>  arch/arm/boot/dts/r8a7740-armadillo800eva.dts |  13 +++
>  drivers/staging/board/Kconfig                 |   1 -
>  drivers/staging/board/Makefile                |   3 +-
>  drivers/staging/board/armadillo800eva.c       | 105 ++++++++++++++++++++
>  drivers/staging/board/board.c                 | 136 ++++++++++++++++++++++++++
>  drivers/staging/board/board.h                 |  27 ++++-
>  drivers/staging/board/kzm9d.c                 |  10 +-
>  7 files changed, 290 insertions(+), 5 deletions(-)
>  create mode 100644 drivers/staging/board/armadillo800eva.c
> 
> -- 
> 1.9.1
> 
> Gr{oetje,eeting}s,
> 
> 						Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
> 							    -- Linus Torvalds
> 

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

* Re: [PATCH v2 0/7] staging: board: armadillo800eva: Board staging for sh_mobile_lcdc_fb
@ 2015-06-18  4:08   ` Simon Horman
  0 siblings, 0 replies; 61+ messages in thread
From: Simon Horman @ 2015-06-18  4:08 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Greg Kroah-Hartman, Magnus Damm, Arnd Bergmann, Laurent Pinchart,
	Kuninori Morimoto, Marc Zyngier, devel, linux-sh, linux-pm,
	devicetree, linux-arm-kernel, linux-kernel

On Wed, Jun 17, 2015 at 10:38:49AM +0200, Geert Uytterhoeven wrote:
> 	Hi Greg, Simon, Magnus,
> 
> This patch series adds board staging support for the Renesas R-Mobile A1
> (r8a7740) based Armadillo-800 EVA board. It allows to support the frame
> buffer device for the on-board LCD (which isn't supported by a DT-aware
> driver yet) in modern DT-based multi-platform kernels.
> 
> The board staging area was introduced last year to allow continuous
> upstream in-tree development and integration of platform devices. It
> helps developers integrate devices as platform devices for device
> drivers that only provide platform device bindings.  This in turn allows
> for incremental development of both hardware feature support and DT
> binding work in parallel.
> 
> The goal is to complete the move to ARM multi-platform kernels for all
> shmobile platforms, and drop the existing board files
> (arch/arm/mach-shmobile/board-*). Once this series is accepted, more
> than 3000 lines of legacy armadillo board code and r8a7740 SoC code can
> be removed.
> 
> This series consists of 5 parts:
>   - Patch 1 re-enables compilation of the board staging area, which was
>     disabled after a compile breakage, but has been fixed in the mean
>     time,
>   - Path 2 moves initialization of staging board code to an earlier
>     moment, as currently it happens after unused PM domains are powered
>     down,
>   - Patches 3 and 4 (hopefully) fix the existing kzm9d board staging
>     code, which was presumably "broken" by commit 9a1091ef0017c40a
>     ("irqchip: gic: Support hierarchy irq domain."),
>   - Patches 5 and 6 add support for registering platform devices with
>     complex dependencies (clocks and PM domains), and add armadillo
>     board staging code for enabling a frame buffer on the on-board LCD,
>   - Patch 7 (new) adds pinctrl and gpio-hog configuration to enable the
>     LCD.
> 
> The first 6 patches should go in through the staging tree, the last one
> through the shmobile tree.
> 
> Major changes since v1 (more detailed changelogs in the individual
> patches):
>   - Add support for low/high edge/level interrupts in hwirq translation,
>   - Move pinctrl and GPIO configuration from board staging code to DT,
>   - Use clk_add_alias() instead of open coding.
> 
> Dependencies:
>   - This is against next-20150617,
>   - The gpio-hog in patch 7 depends on a bug fix like "[PATCH] [RFC]
>     gpio: Retry deferred GPIO hogging on pin range change"
>     (https://lkml.org/lkml/2015/6/16/455). It can be applied as-is
>     though.
> 
> This was tested on r8a7740/armadillo.
> This was not tested on emev2/kzm9d, due to lack of hardware.

I have verified that kzm9d still boots with your patches applied on top
of renesas-devel-20150617-v4.1-rc8. I used shmobile_defconfig and
then enabled CONFIG_STAGING and in turn CONFIG_STAGING_BOARD.

Let me know if you think further testing is appropriate.

> Thanks for applying!
> 
> Geert Uytterhoeven (7):
>   Revert "staging: board: disable as it breaks the build"
>   staging: board: Initialize staging board code earlier
>   staging: board: Add support for translating hwirq to virq numbers
>   staging: board: kzm9d: Translate hwirq numbers to virq numbers
>   staging: board: Add support for devices with complex dependencies
>   staging: board: armadillo800eva: Board staging for sh_mobile_lcdc_fb

Feel free to add:

Acked-by: Simon Horman <horms+renesas@verge.net.au>

to the above.

>   ARM: shmobile: armadillo800eva dts: Add pinctrl and gpio-hog for lcdc0
> 
>  arch/arm/boot/dts/r8a7740-armadillo800eva.dts |  13 +++
>  drivers/staging/board/Kconfig                 |   1 -
>  drivers/staging/board/Makefile                |   3 +-
>  drivers/staging/board/armadillo800eva.c       | 105 ++++++++++++++++++++
>  drivers/staging/board/board.c                 | 136 ++++++++++++++++++++++++++
>  drivers/staging/board/board.h                 |  27 ++++-
>  drivers/staging/board/kzm9d.c                 |  10 +-
>  7 files changed, 290 insertions(+), 5 deletions(-)
>  create mode 100644 drivers/staging/board/armadillo800eva.c
> 
> -- 
> 1.9.1
> 
> Gr{oetje,eeting}s,
> 
> 						Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
> 							    -- Linus Torvalds
> 

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

* [PATCH v2 0/7] staging: board: armadillo800eva: Board staging for sh_mobile_lcdc_fb
@ 2015-06-18  4:08   ` Simon Horman
  0 siblings, 0 replies; 61+ messages in thread
From: Simon Horman @ 2015-06-18  4:08 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jun 17, 2015 at 10:38:49AM +0200, Geert Uytterhoeven wrote:
> 	Hi Greg, Simon, Magnus,
> 
> This patch series adds board staging support for the Renesas R-Mobile A1
> (r8a7740) based Armadillo-800 EVA board. It allows to support the frame
> buffer device for the on-board LCD (which isn't supported by a DT-aware
> driver yet) in modern DT-based multi-platform kernels.
> 
> The board staging area was introduced last year to allow continuous
> upstream in-tree development and integration of platform devices. It
> helps developers integrate devices as platform devices for device
> drivers that only provide platform device bindings.  This in turn allows
> for incremental development of both hardware feature support and DT
> binding work in parallel.
> 
> The goal is to complete the move to ARM multi-platform kernels for all
> shmobile platforms, and drop the existing board files
> (arch/arm/mach-shmobile/board-*). Once this series is accepted, more
> than 3000 lines of legacy armadillo board code and r8a7740 SoC code can
> be removed.
> 
> This series consists of 5 parts:
>   - Patch 1 re-enables compilation of the board staging area, which was
>     disabled after a compile breakage, but has been fixed in the mean
>     time,
>   - Path 2 moves initialization of staging board code to an earlier
>     moment, as currently it happens after unused PM domains are powered
>     down,
>   - Patches 3 and 4 (hopefully) fix the existing kzm9d board staging
>     code, which was presumably "broken" by commit 9a1091ef0017c40a
>     ("irqchip: gic: Support hierarchy irq domain."),
>   - Patches 5 and 6 add support for registering platform devices with
>     complex dependencies (clocks and PM domains), and add armadillo
>     board staging code for enabling a frame buffer on the on-board LCD,
>   - Patch 7 (new) adds pinctrl and gpio-hog configuration to enable the
>     LCD.
> 
> The first 6 patches should go in through the staging tree, the last one
> through the shmobile tree.
> 
> Major changes since v1 (more detailed changelogs in the individual
> patches):
>   - Add support for low/high edge/level interrupts in hwirq translation,
>   - Move pinctrl and GPIO configuration from board staging code to DT,
>   - Use clk_add_alias() instead of open coding.
> 
> Dependencies:
>   - This is against next-20150617,
>   - The gpio-hog in patch 7 depends on a bug fix like "[PATCH] [RFC]
>     gpio: Retry deferred GPIO hogging on pin range change"
>     (https://lkml.org/lkml/2015/6/16/455). It can be applied as-is
>     though.
> 
> This was tested on r8a7740/armadillo.
> This was not tested on emev2/kzm9d, due to lack of hardware.

I have verified that kzm9d still boots with your patches applied on top
of renesas-devel-20150617-v4.1-rc8. I used shmobile_defconfig and
then enabled CONFIG_STAGING and in turn CONFIG_STAGING_BOARD.

Let me know if you think further testing is appropriate.

> Thanks for applying!
> 
> Geert Uytterhoeven (7):
>   Revert "staging: board: disable as it breaks the build"
>   staging: board: Initialize staging board code earlier
>   staging: board: Add support for translating hwirq to virq numbers
>   staging: board: kzm9d: Translate hwirq numbers to virq numbers
>   staging: board: Add support for devices with complex dependencies
>   staging: board: armadillo800eva: Board staging for sh_mobile_lcdc_fb

Feel free to add:

Acked-by: Simon Horman <horms+renesas@verge.net.au>

to the above.

>   ARM: shmobile: armadillo800eva dts: Add pinctrl and gpio-hog for lcdc0
> 
>  arch/arm/boot/dts/r8a7740-armadillo800eva.dts |  13 +++
>  drivers/staging/board/Kconfig                 |   1 -
>  drivers/staging/board/Makefile                |   3 +-
>  drivers/staging/board/armadillo800eva.c       | 105 ++++++++++++++++++++
>  drivers/staging/board/board.c                 | 136 ++++++++++++++++++++++++++
>  drivers/staging/board/board.h                 |  27 ++++-
>  drivers/staging/board/kzm9d.c                 |  10 +-
>  7 files changed, 290 insertions(+), 5 deletions(-)
>  create mode 100644 drivers/staging/board/armadillo800eva.c
> 
> -- 
> 1.9.1
> 
> Gr{oetje,eeting}s,
> 
> 						Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
> 							    -- Linus Torvalds
> 

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

* Re: [PATCH v2 7/7] ARM: shmobile: armadillo800eva dts: Add pinctrl and gpio-hog for lcdc0
  2015-06-17  8:38   ` Geert Uytterhoeven
  (?)
@ 2015-06-19  0:27     ` Simon Horman
  -1 siblings, 0 replies; 61+ messages in thread
From: Simon Horman @ 2015-06-19  0:27 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jun 17, 2015 at 10:38:56AM +0200, Geert Uytterhoeven wrote:
> Configure pinctrl and a GPIO-controller board mux for LCD use.
> This allows the armadillo800eva board staging code to enable lcdc0.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Thanks Geert,

As Greg has now taken patches 1 - 6 I have queued this up.

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

* Re: [PATCH v2 7/7] ARM: shmobile: armadillo800eva dts: Add pinctrl and gpio-hog for lcdc0
@ 2015-06-19  0:27     ` Simon Horman
  0 siblings, 0 replies; 61+ messages in thread
From: Simon Horman @ 2015-06-19  0:27 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Greg Kroah-Hartman, Magnus Damm, Arnd Bergmann, Laurent Pinchart,
	Kuninori Morimoto, Marc Zyngier, devel, linux-sh, linux-pm,
	devicetree, linux-arm-kernel, linux-kernel

On Wed, Jun 17, 2015 at 10:38:56AM +0200, Geert Uytterhoeven wrote:
> Configure pinctrl and a GPIO-controller board mux for LCD use.
> This allows the armadillo800eva board staging code to enable lcdc0.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Thanks Geert,

As Greg has now taken patches 1 - 6 I have queued this up.

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

* [PATCH v2 7/7] ARM: shmobile: armadillo800eva dts: Add pinctrl and gpio-hog for lcdc0
@ 2015-06-19  0:27     ` Simon Horman
  0 siblings, 0 replies; 61+ messages in thread
From: Simon Horman @ 2015-06-19  0:27 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jun 17, 2015 at 10:38:56AM +0200, Geert Uytterhoeven wrote:
> Configure pinctrl and a GPIO-controller board mux for LCD use.
> This allows the armadillo800eva board staging code to enable lcdc0.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Thanks Geert,

As Greg has now taken patches 1 - 6 I have queued this up.

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

* Re: [PATCH v2 5/7] staging: board: Add support for devices with complex dependencies
  2015-06-17  8:38   ` Geert Uytterhoeven
  (?)
  (?)
@ 2015-09-03 12:53     ` Ulf Hansson
  -1 siblings, 0 replies; 61+ messages in thread
From: Ulf Hansson @ 2015-09-03 12:53 UTC (permalink / raw)
  To: linux-arm-kernel

On 17 June 2015 at 10:38, Geert Uytterhoeven <geert+renesas@glider.be> wrote:
> Add support for easy registering of one ore more platform devices that
> may:
>   - need clocks that are described in DT,
>   - be part of a PM Domain.
>
> All these dependencies are optional.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> v2:
>   - Drop support for pinctrl, use standard pinctrl in DT instead,
>   - Drop support for configured GPIOs, use "gpio-hog" in DT instead,
>   - Use clk_add_alias() instead of open coding,
>   - Update for changed function names,
>   - Drop RFC status.
> ---
>  drivers/staging/board/board.c | 56 +++++++++++++++++++++++++++++++++++++++++++
>  drivers/staging/board/board.h | 20 ++++++++++++++++
>  2 files changed, 76 insertions(+)
>
> diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
> index 8712f566b31196e0..29d456e29f38feac 100644
> --- a/drivers/staging/board/board.c
> +++ b/drivers/staging/board/board.c
> @@ -9,6 +9,7 @@
>
>  #define pr_fmt(fmt)    "board_staging: "  fmt
>
> +#include <linux/clkdev.h>
>  #include <linux/init.h>
>  #include <linux/irq.h>
>  #include <linux/device.h>
> @@ -16,6 +17,8 @@
>  #include <linux/of.h>
>  #include <linux/of_address.h>
>  #include <linux/of_irq.h>
> +#include <linux/platform_device.h>
> +#include <linux/pm_domain.h>
>
>  #include "board.h"
>
> @@ -118,3 +121,56 @@ void __init board_staging_gic_fixup_resources(struct resource *res,
>         for (i = 0; i < nres; i++)
>                 gic_fixup_resource(&res[i]);
>  }
> +
> +int __init board_staging_register_clock(const struct board_staging_clk *bsc)
> +{
> +       int error;
> +
> +       pr_debug("Aliasing clock %s for con_id %s dev_id %s\n", bsc->clk,
> +                bsc->con_id, bsc->dev_id);
> +       error = clk_add_alias(bsc->con_id, bsc->dev_id, bsc->clk, NULL);
> +       if (error)
> +               pr_err("Failed to alias clock %s (%d)\n", bsc->clk, error);
> +
> +       return error;
> +}
> +
> +int __init board_staging_register_device(const struct board_staging_dev *dev)
> +{
> +       struct platform_device *pdev = dev->pdev;
> +       unsigned int i;
> +       int error;
> +
> +       pr_debug("Trying to register device %s\n", pdev->name);
> +       if (board_staging_dt_node_available(pdev->resource,
> +                                           pdev->num_resources)) {
> +               pr_warn("Skipping %s, already in DT\n", pdev->name);
> +               return -EEXIST;
> +       }
> +
> +       board_staging_gic_fixup_resources(pdev->resource, pdev->num_resources);
> +
> +       for (i = 0; i < dev->nclocks; i++)
> +               board_staging_register_clock(&dev->clocks[i]);
> +
> +       error = platform_device_register(pdev);
> +       if (error) {
> +               pr_err("Failed to register device %s (%d)\n", pdev->name,
> +                      error);
> +               return error;
> +       }
> +
> +       if (dev->domain)
> +               __pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);

Urgh, this managed to slip through my filters.

It seems like we almost managed to remove all users of the
"..._name_add..." APIs for genpd. If hasn't been for $subject patch.
:-)

Now, I realize this is already too late here, but let's try to fix
this before it turns into a bigger issue.

Geert, do you think it's possible to convert into using the non-named
bases APIs?

Kind regards
Uffe

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

* Re: [PATCH v2 5/7] staging: board: Add support for devices with complex dependencies
@ 2015-09-03 12:53     ` Ulf Hansson
  0 siblings, 0 replies; 61+ messages in thread
From: Ulf Hansson @ 2015-09-03 12:53 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Greg Kroah-Hartman, Simon Horman, Magnus Damm, Arnd Bergmann,
	Laurent Pinchart, Kuninori Morimoto, Marc Zyngier, devel,
	Linux-sh list, linux-pm, devicetree, linux-arm-kernel,
	linux-kernel

On 17 June 2015 at 10:38, Geert Uytterhoeven <geert+renesas@glider.be> wrote:
> Add support for easy registering of one ore more platform devices that
> may:
>   - need clocks that are described in DT,
>   - be part of a PM Domain.
>
> All these dependencies are optional.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> v2:
>   - Drop support for pinctrl, use standard pinctrl in DT instead,
>   - Drop support for configured GPIOs, use "gpio-hog" in DT instead,
>   - Use clk_add_alias() instead of open coding,
>   - Update for changed function names,
>   - Drop RFC status.
> ---
>  drivers/staging/board/board.c | 56 +++++++++++++++++++++++++++++++++++++++++++
>  drivers/staging/board/board.h | 20 ++++++++++++++++
>  2 files changed, 76 insertions(+)
>
> diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
> index 8712f566b31196e0..29d456e29f38feac 100644
> --- a/drivers/staging/board/board.c
> +++ b/drivers/staging/board/board.c
> @@ -9,6 +9,7 @@
>
>  #define pr_fmt(fmt)    "board_staging: "  fmt
>
> +#include <linux/clkdev.h>
>  #include <linux/init.h>
>  #include <linux/irq.h>
>  #include <linux/device.h>
> @@ -16,6 +17,8 @@
>  #include <linux/of.h>
>  #include <linux/of_address.h>
>  #include <linux/of_irq.h>
> +#include <linux/platform_device.h>
> +#include <linux/pm_domain.h>
>
>  #include "board.h"
>
> @@ -118,3 +121,56 @@ void __init board_staging_gic_fixup_resources(struct resource *res,
>         for (i = 0; i < nres; i++)
>                 gic_fixup_resource(&res[i]);
>  }
> +
> +int __init board_staging_register_clock(const struct board_staging_clk *bsc)
> +{
> +       int error;
> +
> +       pr_debug("Aliasing clock %s for con_id %s dev_id %s\n", bsc->clk,
> +                bsc->con_id, bsc->dev_id);
> +       error = clk_add_alias(bsc->con_id, bsc->dev_id, bsc->clk, NULL);
> +       if (error)
> +               pr_err("Failed to alias clock %s (%d)\n", bsc->clk, error);
> +
> +       return error;
> +}
> +
> +int __init board_staging_register_device(const struct board_staging_dev *dev)
> +{
> +       struct platform_device *pdev = dev->pdev;
> +       unsigned int i;
> +       int error;
> +
> +       pr_debug("Trying to register device %s\n", pdev->name);
> +       if (board_staging_dt_node_available(pdev->resource,
> +                                           pdev->num_resources)) {
> +               pr_warn("Skipping %s, already in DT\n", pdev->name);
> +               return -EEXIST;
> +       }
> +
> +       board_staging_gic_fixup_resources(pdev->resource, pdev->num_resources);
> +
> +       for (i = 0; i < dev->nclocks; i++)
> +               board_staging_register_clock(&dev->clocks[i]);
> +
> +       error = platform_device_register(pdev);
> +       if (error) {
> +               pr_err("Failed to register device %s (%d)\n", pdev->name,
> +                      error);
> +               return error;
> +       }
> +
> +       if (dev->domain)
> +               __pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);

Urgh, this managed to slip through my filters.

It seems like we almost managed to remove all users of the
"..._name_add..." APIs for genpd. If hasn't been for $subject patch.
:-)

Now, I realize this is already too late here, but let's try to fix
this before it turns into a bigger issue.

Geert, do you think it's possible to convert into using the non-named
bases APIs?

Kind regards
Uffe

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

* Re: [PATCH v2 5/7] staging: board: Add support for devices with complex dependencies
@ 2015-09-03 12:53     ` Ulf Hansson
  0 siblings, 0 replies; 61+ messages in thread
From: Ulf Hansson @ 2015-09-03 12:53 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Greg Kroah-Hartman, Simon Horman, Magnus Damm, Arnd Bergmann,
	Laurent Pinchart, Kuninori Morimoto, Marc Zyngier, devel,
	Linux-sh list, linux-pm, devicetree, linux-arm-kernel,
	linux-kernel

On 17 June 2015 at 10:38, Geert Uytterhoeven <geert+renesas@glider.be> wrote:
> Add support for easy registering of one ore more platform devices that
> may:
>   - need clocks that are described in DT,
>   - be part of a PM Domain.
>
> All these dependencies are optional.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> v2:
>   - Drop support for pinctrl, use standard pinctrl in DT instead,
>   - Drop support for configured GPIOs, use "gpio-hog" in DT instead,
>   - Use clk_add_alias() instead of open coding,
>   - Update for changed function names,
>   - Drop RFC status.
> ---
>  drivers/staging/board/board.c | 56 +++++++++++++++++++++++++++++++++++++++++++
>  drivers/staging/board/board.h | 20 ++++++++++++++++
>  2 files changed, 76 insertions(+)
>
> diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
> index 8712f566b31196e0..29d456e29f38feac 100644
> --- a/drivers/staging/board/board.c
> +++ b/drivers/staging/board/board.c
> @@ -9,6 +9,7 @@
>
>  #define pr_fmt(fmt)    "board_staging: "  fmt
>
> +#include <linux/clkdev.h>
>  #include <linux/init.h>
>  #include <linux/irq.h>
>  #include <linux/device.h>
> @@ -16,6 +17,8 @@
>  #include <linux/of.h>
>  #include <linux/of_address.h>
>  #include <linux/of_irq.h>
> +#include <linux/platform_device.h>
> +#include <linux/pm_domain.h>
>
>  #include "board.h"
>
> @@ -118,3 +121,56 @@ void __init board_staging_gic_fixup_resources(struct resource *res,
>         for (i = 0; i < nres; i++)
>                 gic_fixup_resource(&res[i]);
>  }
> +
> +int __init board_staging_register_clock(const struct board_staging_clk *bsc)
> +{
> +       int error;
> +
> +       pr_debug("Aliasing clock %s for con_id %s dev_id %s\n", bsc->clk,
> +                bsc->con_id, bsc->dev_id);
> +       error = clk_add_alias(bsc->con_id, bsc->dev_id, bsc->clk, NULL);
> +       if (error)
> +               pr_err("Failed to alias clock %s (%d)\n", bsc->clk, error);
> +
> +       return error;
> +}
> +
> +int __init board_staging_register_device(const struct board_staging_dev *dev)
> +{
> +       struct platform_device *pdev = dev->pdev;
> +       unsigned int i;
> +       int error;
> +
> +       pr_debug("Trying to register device %s\n", pdev->name);
> +       if (board_staging_dt_node_available(pdev->resource,
> +                                           pdev->num_resources)) {
> +               pr_warn("Skipping %s, already in DT\n", pdev->name);
> +               return -EEXIST;
> +       }
> +
> +       board_staging_gic_fixup_resources(pdev->resource, pdev->num_resources);
> +
> +       for (i = 0; i < dev->nclocks; i++)
> +               board_staging_register_clock(&dev->clocks[i]);
> +
> +       error = platform_device_register(pdev);
> +       if (error) {
> +               pr_err("Failed to register device %s (%d)\n", pdev->name,
> +                      error);
> +               return error;
> +       }
> +
> +       if (dev->domain)
> +               __pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);

Urgh, this managed to slip through my filters.

It seems like we almost managed to remove all users of the
"..._name_add..." APIs for genpd. If hasn't been for $subject patch.
:-)

Now, I realize this is already too late here, but let's try to fix
this before it turns into a bigger issue.

Geert, do you think it's possible to convert into using the non-named
bases APIs?

Kind regards
Uffe

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

* [PATCH v2 5/7] staging: board: Add support for devices with complex dependencies
@ 2015-09-03 12:53     ` Ulf Hansson
  0 siblings, 0 replies; 61+ messages in thread
From: Ulf Hansson @ 2015-09-03 12:53 UTC (permalink / raw)
  To: linux-arm-kernel

On 17 June 2015 at 10:38, Geert Uytterhoeven <geert+renesas@glider.be> wrote:
> Add support for easy registering of one ore more platform devices that
> may:
>   - need clocks that are described in DT,
>   - be part of a PM Domain.
>
> All these dependencies are optional.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> v2:
>   - Drop support for pinctrl, use standard pinctrl in DT instead,
>   - Drop support for configured GPIOs, use "gpio-hog" in DT instead,
>   - Use clk_add_alias() instead of open coding,
>   - Update for changed function names,
>   - Drop RFC status.
> ---
>  drivers/staging/board/board.c | 56 +++++++++++++++++++++++++++++++++++++++++++
>  drivers/staging/board/board.h | 20 ++++++++++++++++
>  2 files changed, 76 insertions(+)
>
> diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
> index 8712f566b31196e0..29d456e29f38feac 100644
> --- a/drivers/staging/board/board.c
> +++ b/drivers/staging/board/board.c
> @@ -9,6 +9,7 @@
>
>  #define pr_fmt(fmt)    "board_staging: "  fmt
>
> +#include <linux/clkdev.h>
>  #include <linux/init.h>
>  #include <linux/irq.h>
>  #include <linux/device.h>
> @@ -16,6 +17,8 @@
>  #include <linux/of.h>
>  #include <linux/of_address.h>
>  #include <linux/of_irq.h>
> +#include <linux/platform_device.h>
> +#include <linux/pm_domain.h>
>
>  #include "board.h"
>
> @@ -118,3 +121,56 @@ void __init board_staging_gic_fixup_resources(struct resource *res,
>         for (i = 0; i < nres; i++)
>                 gic_fixup_resource(&res[i]);
>  }
> +
> +int __init board_staging_register_clock(const struct board_staging_clk *bsc)
> +{
> +       int error;
> +
> +       pr_debug("Aliasing clock %s for con_id %s dev_id %s\n", bsc->clk,
> +                bsc->con_id, bsc->dev_id);
> +       error = clk_add_alias(bsc->con_id, bsc->dev_id, bsc->clk, NULL);
> +       if (error)
> +               pr_err("Failed to alias clock %s (%d)\n", bsc->clk, error);
> +
> +       return error;
> +}
> +
> +int __init board_staging_register_device(const struct board_staging_dev *dev)
> +{
> +       struct platform_device *pdev = dev->pdev;
> +       unsigned int i;
> +       int error;
> +
> +       pr_debug("Trying to register device %s\n", pdev->name);
> +       if (board_staging_dt_node_available(pdev->resource,
> +                                           pdev->num_resources)) {
> +               pr_warn("Skipping %s, already in DT\n", pdev->name);
> +               return -EEXIST;
> +       }
> +
> +       board_staging_gic_fixup_resources(pdev->resource, pdev->num_resources);
> +
> +       for (i = 0; i < dev->nclocks; i++)
> +               board_staging_register_clock(&dev->clocks[i]);
> +
> +       error = platform_device_register(pdev);
> +       if (error) {
> +               pr_err("Failed to register device %s (%d)\n", pdev->name,
> +                      error);
> +               return error;
> +       }
> +
> +       if (dev->domain)
> +               __pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);

Urgh, this managed to slip through my filters.

It seems like we almost managed to remove all users of the
"..._name_add..." APIs for genpd. If hasn't been for $subject patch.
:-)

Now, I realize this is already too late here, but let's try to fix
this before it turns into a bigger issue.

Geert, do you think it's possible to convert into using the non-named
bases APIs?

Kind regards
Uffe

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

* Re: [PATCH v2 5/7] staging: board: Add support for devices with complex dependencies
  2015-09-03 12:53     ` Ulf Hansson
  (?)
  (?)
@ 2015-09-03 13:35       ` Geert Uytterhoeven
  -1 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-09-03 13:35 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Ulf,

On Thu, Sep 3, 2015 at 2:53 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> On 17 June 2015 at 10:38, Geert Uytterhoeven <geert+renesas@glider.be> wrote:
>> Add support for easy registering of one ore more platform devices that
>> may:
>>   - need clocks that are described in DT,
>>   - be part of a PM Domain.

>> diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
>> index 8712f566b31196e0..29d456e29f38feac 100644
>> --- a/drivers/staging/board/board.c
>> +++ b/drivers/staging/board/board.c

>> +int __init board_staging_register_device(const struct board_staging_dev *dev)
>> +{
>> +       struct platform_device *pdev = dev->pdev;
>> +       unsigned int i;
>> +       int error;
>> +
>> +       pr_debug("Trying to register device %s\n", pdev->name);
>> +       if (board_staging_dt_node_available(pdev->resource,
>> +                                           pdev->num_resources)) {
>> +               pr_warn("Skipping %s, already in DT\n", pdev->name);
>> +               return -EEXIST;
>> +       }
>> +
>> +       board_staging_gic_fixup_resources(pdev->resource, pdev->num_resources);
>> +
>> +       for (i = 0; i < dev->nclocks; i++)
>> +               board_staging_register_clock(&dev->clocks[i]);
>> +
>> +       error = platform_device_register(pdev);
>> +       if (error) {
>> +               pr_err("Failed to register device %s (%d)\n", pdev->name,
>> +                      error);
>> +               return error;
>> +       }
>> +
>> +       if (dev->domain)
>> +               __pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
>
> Urgh, this managed to slip through my filters.
>
> It seems like we almost managed to remove all users of the
> "..._name_add..." APIs for genpd. If hasn't been for $subject patch.
> :-)
>
> Now, I realize this is already too late here, but let's try to fix
> this before it turns into a bigger issue.
>
> Geert, do you think it's possible to convert into using the non-named
> bases APIs?

That will be difficult. This code is meant to use drivers that are not yet
DT-aware on DT-based systems. Hence it uses platform devices with named PM
domains, while the PM domains are described in DT.
I don't think there's another way to look up a PM domain by name, is there?

This code is meant to go away, once all drivers are converted to DT, or
considered obsolete.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH v2 5/7] staging: board: Add support for devices with complex dependencies
@ 2015-09-03 13:35       ` Geert Uytterhoeven
  0 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-09-03 13:35 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Geert Uytterhoeven, Greg Kroah-Hartman, Simon Horman,
	Magnus Damm, Arnd Bergmann, Laurent Pinchart, Kuninori Morimoto,
	Marc Zyngier, driverdevel, Linux-sh list, linux-pm, devicetree,
	linux-arm-kernel, linux-kernel

Hi Ulf,

On Thu, Sep 3, 2015 at 2:53 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> On 17 June 2015 at 10:38, Geert Uytterhoeven <geert+renesas@glider.be> wrote:
>> Add support for easy registering of one ore more platform devices that
>> may:
>>   - need clocks that are described in DT,
>>   - be part of a PM Domain.

>> diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
>> index 8712f566b31196e0..29d456e29f38feac 100644
>> --- a/drivers/staging/board/board.c
>> +++ b/drivers/staging/board/board.c

>> +int __init board_staging_register_device(const struct board_staging_dev *dev)
>> +{
>> +       struct platform_device *pdev = dev->pdev;
>> +       unsigned int i;
>> +       int error;
>> +
>> +       pr_debug("Trying to register device %s\n", pdev->name);
>> +       if (board_staging_dt_node_available(pdev->resource,
>> +                                           pdev->num_resources)) {
>> +               pr_warn("Skipping %s, already in DT\n", pdev->name);
>> +               return -EEXIST;
>> +       }
>> +
>> +       board_staging_gic_fixup_resources(pdev->resource, pdev->num_resources);
>> +
>> +       for (i = 0; i < dev->nclocks; i++)
>> +               board_staging_register_clock(&dev->clocks[i]);
>> +
>> +       error = platform_device_register(pdev);
>> +       if (error) {
>> +               pr_err("Failed to register device %s (%d)\n", pdev->name,
>> +                      error);
>> +               return error;
>> +       }
>> +
>> +       if (dev->domain)
>> +               __pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
>
> Urgh, this managed to slip through my filters.
>
> It seems like we almost managed to remove all users of the
> "..._name_add..." APIs for genpd. If hasn't been for $subject patch.
> :-)
>
> Now, I realize this is already too late here, but let's try to fix
> this before it turns into a bigger issue.
>
> Geert, do you think it's possible to convert into using the non-named
> bases APIs?

That will be difficult. This code is meant to use drivers that are not yet
DT-aware on DT-based systems. Hence it uses platform devices with named PM
domains, while the PM domains are described in DT.
I don't think there's another way to look up a PM domain by name, is there?

This code is meant to go away, once all drivers are converted to DT, or
considered obsolete.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH v2 5/7] staging: board: Add support for devices with complex dependencies
@ 2015-09-03 13:35       ` Geert Uytterhoeven
  0 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-09-03 13:35 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Geert Uytterhoeven, Greg Kroah-Hartman, Simon Horman,
	Magnus Damm, Arnd Bergmann, Laurent Pinchart, Kuninori Morimoto,
	Marc Zyngier, driverdevel, Linux-sh list,
	linux-pm-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

Hi Ulf,

On Thu, Sep 3, 2015 at 2:53 PM, Ulf Hansson <ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> wrote:
> On 17 June 2015 at 10:38, Geert Uytterhoeven <geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org> wrote:
>> Add support for easy registering of one ore more platform devices that
>> may:
>>   - need clocks that are described in DT,
>>   - be part of a PM Domain.

>> diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
>> index 8712f566b31196e0..29d456e29f38feac 100644
>> --- a/drivers/staging/board/board.c
>> +++ b/drivers/staging/board/board.c

>> +int __init board_staging_register_device(const struct board_staging_dev *dev)
>> +{
>> +       struct platform_device *pdev = dev->pdev;
>> +       unsigned int i;
>> +       int error;
>> +
>> +       pr_debug("Trying to register device %s\n", pdev->name);
>> +       if (board_staging_dt_node_available(pdev->resource,
>> +                                           pdev->num_resources)) {
>> +               pr_warn("Skipping %s, already in DT\n", pdev->name);
>> +               return -EEXIST;
>> +       }
>> +
>> +       board_staging_gic_fixup_resources(pdev->resource, pdev->num_resources);
>> +
>> +       for (i = 0; i < dev->nclocks; i++)
>> +               board_staging_register_clock(&dev->clocks[i]);
>> +
>> +       error = platform_device_register(pdev);
>> +       if (error) {
>> +               pr_err("Failed to register device %s (%d)\n", pdev->name,
>> +                      error);
>> +               return error;
>> +       }
>> +
>> +       if (dev->domain)
>> +               __pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
>
> Urgh, this managed to slip through my filters.
>
> It seems like we almost managed to remove all users of the
> "..._name_add..." APIs for genpd. If hasn't been for $subject patch.
> :-)
>
> Now, I realize this is already too late here, but let's try to fix
> this before it turns into a bigger issue.
>
> Geert, do you think it's possible to convert into using the non-named
> bases APIs?

That will be difficult. This code is meant to use drivers that are not yet
DT-aware on DT-based systems. Hence it uses platform devices with named PM
domains, while the PM domains are described in DT.
I don't think there's another way to look up a PM domain by name, is there?

This code is meant to go away, once all drivers are converted to DT, or
considered obsolete.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v2 5/7] staging: board: Add support for devices with complex dependencies
@ 2015-09-03 13:35       ` Geert Uytterhoeven
  0 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-09-03 13:35 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Ulf,

On Thu, Sep 3, 2015 at 2:53 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> On 17 June 2015 at 10:38, Geert Uytterhoeven <geert+renesas@glider.be> wrote:
>> Add support for easy registering of one ore more platform devices that
>> may:
>>   - need clocks that are described in DT,
>>   - be part of a PM Domain.

>> diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
>> index 8712f566b31196e0..29d456e29f38feac 100644
>> --- a/drivers/staging/board/board.c
>> +++ b/drivers/staging/board/board.c

>> +int __init board_staging_register_device(const struct board_staging_dev *dev)
>> +{
>> +       struct platform_device *pdev = dev->pdev;
>> +       unsigned int i;
>> +       int error;
>> +
>> +       pr_debug("Trying to register device %s\n", pdev->name);
>> +       if (board_staging_dt_node_available(pdev->resource,
>> +                                           pdev->num_resources)) {
>> +               pr_warn("Skipping %s, already in DT\n", pdev->name);
>> +               return -EEXIST;
>> +       }
>> +
>> +       board_staging_gic_fixup_resources(pdev->resource, pdev->num_resources);
>> +
>> +       for (i = 0; i < dev->nclocks; i++)
>> +               board_staging_register_clock(&dev->clocks[i]);
>> +
>> +       error = platform_device_register(pdev);
>> +       if (error) {
>> +               pr_err("Failed to register device %s (%d)\n", pdev->name,
>> +                      error);
>> +               return error;
>> +       }
>> +
>> +       if (dev->domain)
>> +               __pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
>
> Urgh, this managed to slip through my filters.
>
> It seems like we almost managed to remove all users of the
> "..._name_add..." APIs for genpd. If hasn't been for $subject patch.
> :-)
>
> Now, I realize this is already too late here, but let's try to fix
> this before it turns into a bigger issue.
>
> Geert, do you think it's possible to convert into using the non-named
> bases APIs?

That will be difficult. This code is meant to use drivers that are not yet
DT-aware on DT-based systems. Hence it uses platform devices with named PM
domains, while the PM domains are described in DT.
I don't think there's another way to look up a PM domain by name, is there?

This code is meant to go away, once all drivers are converted to DT, or
considered obsolete.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH v2 5/7] staging: board: Add support for devices with complex dependencies
  2015-09-03 13:35       ` Geert Uytterhoeven
  (?)
  (?)
@ 2015-09-04  8:30         ` Ulf Hansson
  -1 siblings, 0 replies; 61+ messages in thread
From: Ulf Hansson @ 2015-09-04  8:30 UTC (permalink / raw)
  To: linux-arm-kernel

On 3 September 2015 at 15:35, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> Hi Ulf,
>
> On Thu, Sep 3, 2015 at 2:53 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>> On 17 June 2015 at 10:38, Geert Uytterhoeven <geert+renesas@glider.be> wrote:
>>> Add support for easy registering of one ore more platform devices that
>>> may:
>>>   - need clocks that are described in DT,
>>>   - be part of a PM Domain.
>
>>> diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
>>> index 8712f566b31196e0..29d456e29f38feac 100644
>>> --- a/drivers/staging/board/board.c
>>> +++ b/drivers/staging/board/board.c
>
>>> +int __init board_staging_register_device(const struct board_staging_dev *dev)
>>> +{
>>> +       struct platform_device *pdev = dev->pdev;
>>> +       unsigned int i;
>>> +       int error;
>>> +
>>> +       pr_debug("Trying to register device %s\n", pdev->name);
>>> +       if (board_staging_dt_node_available(pdev->resource,
>>> +                                           pdev->num_resources)) {
>>> +               pr_warn("Skipping %s, already in DT\n", pdev->name);
>>> +               return -EEXIST;
>>> +       }
>>> +
>>> +       board_staging_gic_fixup_resources(pdev->resource, pdev->num_resources);
>>> +
>>> +       for (i = 0; i < dev->nclocks; i++)
>>> +               board_staging_register_clock(&dev->clocks[i]);
>>> +
>>> +       error = platform_device_register(pdev);
>>> +       if (error) {
>>> +               pr_err("Failed to register device %s (%d)\n", pdev->name,
>>> +                      error);
>>> +               return error;
>>> +       }
>>> +
>>> +       if (dev->domain)
>>> +               __pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
>>
>> Urgh, this managed to slip through my filters.
>>
>> It seems like we almost managed to remove all users of the
>> "..._name_add..." APIs for genpd. If hasn't been for $subject patch.
>> :-)
>>
>> Now, I realize this is already too late here, but let's try to fix
>> this before it turns into a bigger issue.
>>
>> Geert, do you think it's possible to convert into using the non-named
>> bases APIs?
>
> That will be difficult. This code is meant to use drivers that are not yet
> DT-aware on DT-based systems. Hence it uses platform devices with named PM
> domains, while the PM domains are described in DT.
> I don't think there's another way to look up a PM domain by name, is there?

As a matter of fact there are, especially for those genpds that has
been created through DT as in this case. The API to use is
of_genpd_get_from_provider() to find the struct generic_pm_domain.

Yes, I do realize that you need to manage the parsing of the domain
name to make sure it's the one you want, but I would rather keep that
"hack" in this driver than in the generic API.

>
> This code is meant to go away, once all drivers are converted to DT, or
> considered obsolete.

Well, who knows *when* that is going to happen. :-)

Kind regards
Uffe

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

* Re: [PATCH v2 5/7] staging: board: Add support for devices with complex dependencies
@ 2015-09-04  8:30         ` Ulf Hansson
  0 siblings, 0 replies; 61+ messages in thread
From: Ulf Hansson @ 2015-09-04  8:30 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Geert Uytterhoeven, Greg Kroah-Hartman, Simon Horman,
	Magnus Damm, Arnd Bergmann, Laurent Pinchart, Kuninori Morimoto,
	Marc Zyngier, driverdevel, Linux-sh list, linux-pm, devicetree,
	linux-arm-kernel, linux-kernel

On 3 September 2015 at 15:35, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> Hi Ulf,
>
> On Thu, Sep 3, 2015 at 2:53 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>> On 17 June 2015 at 10:38, Geert Uytterhoeven <geert+renesas@glider.be> wrote:
>>> Add support for easy registering of one ore more platform devices that
>>> may:
>>>   - need clocks that are described in DT,
>>>   - be part of a PM Domain.
>
>>> diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
>>> index 8712f566b31196e0..29d456e29f38feac 100644
>>> --- a/drivers/staging/board/board.c
>>> +++ b/drivers/staging/board/board.c
>
>>> +int __init board_staging_register_device(const struct board_staging_dev *dev)
>>> +{
>>> +       struct platform_device *pdev = dev->pdev;
>>> +       unsigned int i;
>>> +       int error;
>>> +
>>> +       pr_debug("Trying to register device %s\n", pdev->name);
>>> +       if (board_staging_dt_node_available(pdev->resource,
>>> +                                           pdev->num_resources)) {
>>> +               pr_warn("Skipping %s, already in DT\n", pdev->name);
>>> +               return -EEXIST;
>>> +       }
>>> +
>>> +       board_staging_gic_fixup_resources(pdev->resource, pdev->num_resources);
>>> +
>>> +       for (i = 0; i < dev->nclocks; i++)
>>> +               board_staging_register_clock(&dev->clocks[i]);
>>> +
>>> +       error = platform_device_register(pdev);
>>> +       if (error) {
>>> +               pr_err("Failed to register device %s (%d)\n", pdev->name,
>>> +                      error);
>>> +               return error;
>>> +       }
>>> +
>>> +       if (dev->domain)
>>> +               __pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
>>
>> Urgh, this managed to slip through my filters.
>>
>> It seems like we almost managed to remove all users of the
>> "..._name_add..." APIs for genpd. If hasn't been for $subject patch.
>> :-)
>>
>> Now, I realize this is already too late here, but let's try to fix
>> this before it turns into a bigger issue.
>>
>> Geert, do you think it's possible to convert into using the non-named
>> bases APIs?
>
> That will be difficult. This code is meant to use drivers that are not yet
> DT-aware on DT-based systems. Hence it uses platform devices with named PM
> domains, while the PM domains are described in DT.
> I don't think there's another way to look up a PM domain by name, is there?

As a matter of fact there are, especially for those genpds that has
been created through DT as in this case. The API to use is
of_genpd_get_from_provider() to find the struct generic_pm_domain.

Yes, I do realize that you need to manage the parsing of the domain
name to make sure it's the one you want, but I would rather keep that
"hack" in this driver than in the generic API.

>
> This code is meant to go away, once all drivers are converted to DT, or
> considered obsolete.

Well, who knows *when* that is going to happen. :-)

Kind regards
Uffe

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

* Re: [PATCH v2 5/7] staging: board: Add support for devices with complex dependencies
@ 2015-09-04  8:30         ` Ulf Hansson
  0 siblings, 0 replies; 61+ messages in thread
From: Ulf Hansson @ 2015-09-04  8:30 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: driverdevel, devicetree, Kuninori Morimoto, Geert Uytterhoeven,
	Arnd Bergmann, Linux-sh list, Marc Zyngier, Greg Kroah-Hartman,
	linux-pm, Magnus Damm, linux-kernel, Laurent Pinchart,
	Simon Horman, linux-arm-kernel

On 3 September 2015 at 15:35, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> Hi Ulf,
>
> On Thu, Sep 3, 2015 at 2:53 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>> On 17 June 2015 at 10:38, Geert Uytterhoeven <geert+renesas@glider.be> wrote:
>>> Add support for easy registering of one ore more platform devices that
>>> may:
>>>   - need clocks that are described in DT,
>>>   - be part of a PM Domain.
>
>>> diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
>>> index 8712f566b31196e0..29d456e29f38feac 100644
>>> --- a/drivers/staging/board/board.c
>>> +++ b/drivers/staging/board/board.c
>
>>> +int __init board_staging_register_device(const struct board_staging_dev *dev)
>>> +{
>>> +       struct platform_device *pdev = dev->pdev;
>>> +       unsigned int i;
>>> +       int error;
>>> +
>>> +       pr_debug("Trying to register device %s\n", pdev->name);
>>> +       if (board_staging_dt_node_available(pdev->resource,
>>> +                                           pdev->num_resources)) {
>>> +               pr_warn("Skipping %s, already in DT\n", pdev->name);
>>> +               return -EEXIST;
>>> +       }
>>> +
>>> +       board_staging_gic_fixup_resources(pdev->resource, pdev->num_resources);
>>> +
>>> +       for (i = 0; i < dev->nclocks; i++)
>>> +               board_staging_register_clock(&dev->clocks[i]);
>>> +
>>> +       error = platform_device_register(pdev);
>>> +       if (error) {
>>> +               pr_err("Failed to register device %s (%d)\n", pdev->name,
>>> +                      error);
>>> +               return error;
>>> +       }
>>> +
>>> +       if (dev->domain)
>>> +               __pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
>>
>> Urgh, this managed to slip through my filters.
>>
>> It seems like we almost managed to remove all users of the
>> "..._name_add..." APIs for genpd. If hasn't been for $subject patch.
>> :-)
>>
>> Now, I realize this is already too late here, but let's try to fix
>> this before it turns into a bigger issue.
>>
>> Geert, do you think it's possible to convert into using the non-named
>> bases APIs?
>
> That will be difficult. This code is meant to use drivers that are not yet
> DT-aware on DT-based systems. Hence it uses platform devices with named PM
> domains, while the PM domains are described in DT.
> I don't think there's another way to look up a PM domain by name, is there?

As a matter of fact there are, especially for those genpds that has
been created through DT as in this case. The API to use is
of_genpd_get_from_provider() to find the struct generic_pm_domain.

Yes, I do realize that you need to manage the parsing of the domain
name to make sure it's the one you want, but I would rather keep that
"hack" in this driver than in the generic API.

>
> This code is meant to go away, once all drivers are converted to DT, or
> considered obsolete.

Well, who knows *when* that is going to happen. :-)

Kind regards
Uffe

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

* [PATCH v2 5/7] staging: board: Add support for devices with complex dependencies
@ 2015-09-04  8:30         ` Ulf Hansson
  0 siblings, 0 replies; 61+ messages in thread
From: Ulf Hansson @ 2015-09-04  8:30 UTC (permalink / raw)
  To: linux-arm-kernel

On 3 September 2015 at 15:35, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> Hi Ulf,
>
> On Thu, Sep 3, 2015 at 2:53 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>> On 17 June 2015 at 10:38, Geert Uytterhoeven <geert+renesas@glider.be> wrote:
>>> Add support for easy registering of one ore more platform devices that
>>> may:
>>>   - need clocks that are described in DT,
>>>   - be part of a PM Domain.
>
>>> diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
>>> index 8712f566b31196e0..29d456e29f38feac 100644
>>> --- a/drivers/staging/board/board.c
>>> +++ b/drivers/staging/board/board.c
>
>>> +int __init board_staging_register_device(const struct board_staging_dev *dev)
>>> +{
>>> +       struct platform_device *pdev = dev->pdev;
>>> +       unsigned int i;
>>> +       int error;
>>> +
>>> +       pr_debug("Trying to register device %s\n", pdev->name);
>>> +       if (board_staging_dt_node_available(pdev->resource,
>>> +                                           pdev->num_resources)) {
>>> +               pr_warn("Skipping %s, already in DT\n", pdev->name);
>>> +               return -EEXIST;
>>> +       }
>>> +
>>> +       board_staging_gic_fixup_resources(pdev->resource, pdev->num_resources);
>>> +
>>> +       for (i = 0; i < dev->nclocks; i++)
>>> +               board_staging_register_clock(&dev->clocks[i]);
>>> +
>>> +       error = platform_device_register(pdev);
>>> +       if (error) {
>>> +               pr_err("Failed to register device %s (%d)\n", pdev->name,
>>> +                      error);
>>> +               return error;
>>> +       }
>>> +
>>> +       if (dev->domain)
>>> +               __pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
>>
>> Urgh, this managed to slip through my filters.
>>
>> It seems like we almost managed to remove all users of the
>> "..._name_add..." APIs for genpd. If hasn't been for $subject patch.
>> :-)
>>
>> Now, I realize this is already too late here, but let's try to fix
>> this before it turns into a bigger issue.
>>
>> Geert, do you think it's possible to convert into using the non-named
>> bases APIs?
>
> That will be difficult. This code is meant to use drivers that are not yet
> DT-aware on DT-based systems. Hence it uses platform devices with named PM
> domains, while the PM domains are described in DT.
> I don't think there's another way to look up a PM domain by name, is there?

As a matter of fact there are, especially for those genpds that has
been created through DT as in this case. The API to use is
of_genpd_get_from_provider() to find the struct generic_pm_domain.

Yes, I do realize that you need to manage the parsing of the domain
name to make sure it's the one you want, but I would rather keep that
"hack" in this driver than in the generic API.

>
> This code is meant to go away, once all drivers are converted to DT, or
> considered obsolete.

Well, who knows *when* that is going to happen. :-)

Kind regards
Uffe

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

* Re: [PATCH v2 5/7] staging: board: Add support for devices with complex dependencies
  2015-09-04  8:30         ` Ulf Hansson
  (?)
  (?)
@ 2015-09-04 15:03           ` Geert Uytterhoeven
  -1 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-09-04 15:03 UTC (permalink / raw)
  To: linux-arm-kernel

	Hi Ulf,

On Fri, 4 Sep 2015, Ulf Hansson wrote:
> On 3 September 2015 at 15:35, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > On Thu, Sep 3, 2015 at 2:53 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> >> On 17 June 2015 at 10:38, Geert Uytterhoeven <geert+renesas@glider.be> wrote:
> >>> Add support for easy registering of one ore more platform devices that
> >>> may:
> >>>   - need clocks that are described in DT,
> >>>   - be part of a PM Domain.
> >
> >>> diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
> >>> index 8712f566b31196e0..29d456e29f38feac 100644
> >>> --- a/drivers/staging/board/board.c
> >>> +++ b/drivers/staging/board/board.c
> >
> >>> +int __init board_staging_register_device(const struct board_staging_dev *dev)
> >>> +{
> >>> +       struct platform_device *pdev = dev->pdev;
> >>> +       unsigned int i;
> >>> +       int error;
> >>> +
> >>> +       pr_debug("Trying to register device %s\n", pdev->name);
> >>> +       if (board_staging_dt_node_available(pdev->resource,
> >>> +                                           pdev->num_resources)) {
> >>> +               pr_warn("Skipping %s, already in DT\n", pdev->name);
> >>> +               return -EEXIST;
> >>> +       }
> >>> +
> >>> +       board_staging_gic_fixup_resources(pdev->resource, pdev->num_resources);
> >>> +
> >>> +       for (i = 0; i < dev->nclocks; i++)
> >>> +               board_staging_register_clock(&dev->clocks[i]);
> >>> +
> >>> +       error = platform_device_register(pdev);
> >>> +       if (error) {
> >>> +               pr_err("Failed to register device %s (%d)\n", pdev->name,
> >>> +                      error);
> >>> +               return error;
> >>> +       }
> >>> +
> >>> +       if (dev->domain)
> >>> +               __pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
> >>
> >> Urgh, this managed to slip through my filters.
> >>
> >> It seems like we almost managed to remove all users of the
> >> "..._name_add..." APIs for genpd. If hasn't been for $subject patch.
> >> :-)
> >>
> >> Now, I realize this is already too late here, but let's try to fix
> >> this before it turns into a bigger issue.
> >>
> >> Geert, do you think it's possible to convert into using the non-named
> >> bases APIs?
> >
> > That will be difficult. This code is meant to use drivers that are not yet
> > DT-aware on DT-based systems. Hence it uses platform devices with named PM
> > domains, while the PM domains are described in DT.
> > I don't think there's another way to look up a PM domain by name, is there?
> 
> As a matter of fact there are, especially for those genpds that has
> been created through DT as in this case. The API to use is
> of_genpd_get_from_provider() to find the struct generic_pm_domain.

Thanks!

> Yes, I do realize that you need to manage the parsing of the domain
> name to make sure it's the one you want, but I would rather keep that
> "hack" in this driver than in the generic API.

OK. It turned out not to be that complex, cfr. the patch below.
For now this supports PM domains with "#power-domain-cells = <0>" only,
but of course it can be extended if the need arises.

I've also tried:

    np = of_find_compatible_node(NULL, NULL, "renesas,sysc-rmobile");
    np = of_find_node_by_name(np, "a4lc");

(the second step is needed because of the domain hierarchy in DT), but that
would require adding the compatible string to struct board_staging_dev,
and doesn't work if you have multiple identical power providers.

I hope you like it?

From 5fb11904845eb929a5b3382a9d5153c151cde1cf Mon Sep 17 00:00:00 2001
From: Geert Uytterhoeven <geert+renesas@glider.be>
Date: Fri, 4 Sep 2015 16:52:33 +0200
Subject: [PATCH/RFC] staging: board: Migrate away from
 __pm_genpd_name_add_device()

The named genpd APIs are deprecated. Hence convert the board staging
code from using genpd names to DT node paths.

For now this supports PM domains with "#power-domain-cells = <0>" only.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/staging/board/armadillo800eva.c |  2 +-
 drivers/staging/board/board.c           | 36 ++++++++++++++++++++++++++++++++-
 2 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/board/armadillo800eva.c b/drivers/staging/board/armadillo800eva.c
index 0165591a52443c46..912c96b0536def7c 100644
--- a/drivers/staging/board/armadillo800eva.c
+++ b/drivers/staging/board/armadillo800eva.c
@@ -91,7 +91,7 @@ static const struct board_staging_dev armadillo800eva_devices[] __initconst = {
 		.pdev		= &lcdc0_device,
 		.clocks		= lcdc0_clocks,
 		.nclocks	= ARRAY_SIZE(lcdc0_clocks),
-		.domain		= "a4lc",
+		.domain		= "/system-controller@e6180000/pm-domains/c5/a4lc@1"
 	},
 };
 
diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
index 29d456e29f38feac..3eb5eb8f069c236d 100644
--- a/drivers/staging/board/board.c
+++ b/drivers/staging/board/board.c
@@ -135,6 +135,40 @@ int __init board_staging_register_clock(const struct board_staging_clk *bsc)
 	return error;
 }
 
+#ifdef CONFIG_PM_GENERIC_DOMAINS_OF
+static int board_staging_add_dev_domain(struct platform_device *pdev,
+					const char *domain)
+{
+	struct of_phandle_args pd_args;
+	struct generic_pm_domain *pd;
+	struct device_node *np;
+
+	np = of_find_node_by_path(domain);
+	if (!np) {
+		pr_err("Cannot find domain node %s\n", domain);
+		return -ENOENT;
+	}
+
+	pd_args.np = np;
+	pd_args.args_count = 0;
+	pd = of_genpd_get_from_provider(&pd_args);
+	if (IS_ERR(pd)) {
+		pr_err("Cannot find genpd %s (%ld)\n", domain, PTR_ERR(pd));
+		return PTR_ERR(pd);
+
+	}
+	pr_debug("Found genpd %s for device %s\n", pd->name, pdev->name);
+
+	return pm_genpd_add_device(pd, &pdev->dev);
+}
+#else
+static inline int board_staging_add_dev_domain(struct platform_device *pdev,
+					       const char *domain)
+{
+	return 0;
+}
+#endif
+
 int __init board_staging_register_device(const struct board_staging_dev *dev)
 {
 	struct platform_device *pdev = dev->pdev;
@@ -161,7 +195,7 @@ int __init board_staging_register_device(const struct board_staging_dev *dev)
 	}
 
 	if (dev->domain)
-		__pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
+		board_staging_add_dev_domain(pdev, dev->domain);
 
 	return error;
 }
-- 
1.9.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

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

* Re: [PATCH v2 5/7] staging: board: Add support for devices with complex dependencies
@ 2015-09-04 15:03           ` Geert Uytterhoeven
  0 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-09-04 15:03 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Geert Uytterhoeven, Greg Kroah-Hartman, Simon Horman,
	Magnus Damm, Arnd Bergmann, Laurent Pinchart, Kuninori Morimoto,
	Marc Zyngier, driverdevel, Linux-sh list, linux-pm, devicetree,
	linux-arm-kernel, linux-kernel

	Hi Ulf,

On Fri, 4 Sep 2015, Ulf Hansson wrote:
> On 3 September 2015 at 15:35, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > On Thu, Sep 3, 2015 at 2:53 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> >> On 17 June 2015 at 10:38, Geert Uytterhoeven <geert+renesas@glider.be> wrote:
> >>> Add support for easy registering of one ore more platform devices that
> >>> may:
> >>>   - need clocks that are described in DT,
> >>>   - be part of a PM Domain.
> >
> >>> diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
> >>> index 8712f566b31196e0..29d456e29f38feac 100644
> >>> --- a/drivers/staging/board/board.c
> >>> +++ b/drivers/staging/board/board.c
> >
> >>> +int __init board_staging_register_device(const struct board_staging_dev *dev)
> >>> +{
> >>> +       struct platform_device *pdev = dev->pdev;
> >>> +       unsigned int i;
> >>> +       int error;
> >>> +
> >>> +       pr_debug("Trying to register device %s\n", pdev->name);
> >>> +       if (board_staging_dt_node_available(pdev->resource,
> >>> +                                           pdev->num_resources)) {
> >>> +               pr_warn("Skipping %s, already in DT\n", pdev->name);
> >>> +               return -EEXIST;
> >>> +       }
> >>> +
> >>> +       board_staging_gic_fixup_resources(pdev->resource, pdev->num_resources);
> >>> +
> >>> +       for (i = 0; i < dev->nclocks; i++)
> >>> +               board_staging_register_clock(&dev->clocks[i]);
> >>> +
> >>> +       error = platform_device_register(pdev);
> >>> +       if (error) {
> >>> +               pr_err("Failed to register device %s (%d)\n", pdev->name,
> >>> +                      error);
> >>> +               return error;
> >>> +       }
> >>> +
> >>> +       if (dev->domain)
> >>> +               __pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
> >>
> >> Urgh, this managed to slip through my filters.
> >>
> >> It seems like we almost managed to remove all users of the
> >> "..._name_add..." APIs for genpd. If hasn't been for $subject patch.
> >> :-)
> >>
> >> Now, I realize this is already too late here, but let's try to fix
> >> this before it turns into a bigger issue.
> >>
> >> Geert, do you think it's possible to convert into using the non-named
> >> bases APIs?
> >
> > That will be difficult. This code is meant to use drivers that are not yet
> > DT-aware on DT-based systems. Hence it uses platform devices with named PM
> > domains, while the PM domains are described in DT.
> > I don't think there's another way to look up a PM domain by name, is there?
> 
> As a matter of fact there are, especially for those genpds that has
> been created through DT as in this case. The API to use is
> of_genpd_get_from_provider() to find the struct generic_pm_domain.

Thanks!

> Yes, I do realize that you need to manage the parsing of the domain
> name to make sure it's the one you want, but I would rather keep that
> "hack" in this driver than in the generic API.

OK. It turned out not to be that complex, cfr. the patch below.
For now this supports PM domains with "#power-domain-cells = <0>" only,
but of course it can be extended if the need arises.

I've also tried:

    np = of_find_compatible_node(NULL, NULL, "renesas,sysc-rmobile");
    np = of_find_node_by_name(np, "a4lc");

(the second step is needed because of the domain hierarchy in DT), but that
would require adding the compatible string to struct board_staging_dev,
and doesn't work if you have multiple identical power providers.

I hope you like it?

>From 5fb11904845eb929a5b3382a9d5153c151cde1cf Mon Sep 17 00:00:00 2001
From: Geert Uytterhoeven <geert+renesas@glider.be>
Date: Fri, 4 Sep 2015 16:52:33 +0200
Subject: [PATCH/RFC] staging: board: Migrate away from
 __pm_genpd_name_add_device()

The named genpd APIs are deprecated. Hence convert the board staging
code from using genpd names to DT node paths.

For now this supports PM domains with "#power-domain-cells = <0>" only.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/staging/board/armadillo800eva.c |  2 +-
 drivers/staging/board/board.c           | 36 ++++++++++++++++++++++++++++++++-
 2 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/board/armadillo800eva.c b/drivers/staging/board/armadillo800eva.c
index 0165591a52443c46..912c96b0536def7c 100644
--- a/drivers/staging/board/armadillo800eva.c
+++ b/drivers/staging/board/armadillo800eva.c
@@ -91,7 +91,7 @@ static const struct board_staging_dev armadillo800eva_devices[] __initconst = {
 		.pdev		= &lcdc0_device,
 		.clocks		= lcdc0_clocks,
 		.nclocks	= ARRAY_SIZE(lcdc0_clocks),
-		.domain		= "a4lc",
+		.domain		= "/system-controller@e6180000/pm-domains/c5/a4lc@1"
 	},
 };
 
diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
index 29d456e29f38feac..3eb5eb8f069c236d 100644
--- a/drivers/staging/board/board.c
+++ b/drivers/staging/board/board.c
@@ -135,6 +135,40 @@ int __init board_staging_register_clock(const struct board_staging_clk *bsc)
 	return error;
 }
 
+#ifdef CONFIG_PM_GENERIC_DOMAINS_OF
+static int board_staging_add_dev_domain(struct platform_device *pdev,
+					const char *domain)
+{
+	struct of_phandle_args pd_args;
+	struct generic_pm_domain *pd;
+	struct device_node *np;
+
+	np = of_find_node_by_path(domain);
+	if (!np) {
+		pr_err("Cannot find domain node %s\n", domain);
+		return -ENOENT;
+	}
+
+	pd_args.np = np;
+	pd_args.args_count = 0;
+	pd = of_genpd_get_from_provider(&pd_args);
+	if (IS_ERR(pd)) {
+		pr_err("Cannot find genpd %s (%ld)\n", domain, PTR_ERR(pd));
+		return PTR_ERR(pd);
+
+	}
+	pr_debug("Found genpd %s for device %s\n", pd->name, pdev->name);
+
+	return pm_genpd_add_device(pd, &pdev->dev);
+}
+#else
+static inline int board_staging_add_dev_domain(struct platform_device *pdev,
+					       const char *domain)
+{
+	return 0;
+}
+#endif
+
 int __init board_staging_register_device(const struct board_staging_dev *dev)
 {
 	struct platform_device *pdev = dev->pdev;
@@ -161,7 +195,7 @@ int __init board_staging_register_device(const struct board_staging_dev *dev)
 	}
 
 	if (dev->domain)
-		__pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
+		board_staging_add_dev_domain(pdev, dev->domain);
 
 	return error;
 }
-- 
1.9.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

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

* Re: [PATCH v2 5/7] staging: board: Add support for devices with complex dependencies
@ 2015-09-04 15:03           ` Geert Uytterhoeven
  0 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-09-04 15:03 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Geert Uytterhoeven, Greg Kroah-Hartman, Simon Horman,
	Magnus Damm, Arnd Bergmann, Laurent Pinchart, Kuninori Morimoto,
	Marc Zyngier, driverdevel, Linux-sh list, linux-pm, devicetree,
	linux-arm-kernel, linux-kernel

	Hi Ulf,

On Fri, 4 Sep 2015, Ulf Hansson wrote:
> On 3 September 2015 at 15:35, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > On Thu, Sep 3, 2015 at 2:53 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> >> On 17 June 2015 at 10:38, Geert Uytterhoeven <geert+renesas@glider.be> wrote:
> >>> Add support for easy registering of one ore more platform devices that
> >>> may:
> >>>   - need clocks that are described in DT,
> >>>   - be part of a PM Domain.
> >
> >>> diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
> >>> index 8712f566b31196e0..29d456e29f38feac 100644
> >>> --- a/drivers/staging/board/board.c
> >>> +++ b/drivers/staging/board/board.c
> >
> >>> +int __init board_staging_register_device(const struct board_staging_dev *dev)
> >>> +{
> >>> +       struct platform_device *pdev = dev->pdev;
> >>> +       unsigned int i;
> >>> +       int error;
> >>> +
> >>> +       pr_debug("Trying to register device %s\n", pdev->name);
> >>> +       if (board_staging_dt_node_available(pdev->resource,
> >>> +                                           pdev->num_resources)) {
> >>> +               pr_warn("Skipping %s, already in DT\n", pdev->name);
> >>> +               return -EEXIST;
> >>> +       }
> >>> +
> >>> +       board_staging_gic_fixup_resources(pdev->resource, pdev->num_resources);
> >>> +
> >>> +       for (i = 0; i < dev->nclocks; i++)
> >>> +               board_staging_register_clock(&dev->clocks[i]);
> >>> +
> >>> +       error = platform_device_register(pdev);
> >>> +       if (error) {
> >>> +               pr_err("Failed to register device %s (%d)\n", pdev->name,
> >>> +                      error);
> >>> +               return error;
> >>> +       }
> >>> +
> >>> +       if (dev->domain)
> >>> +               __pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
> >>
> >> Urgh, this managed to slip through my filters.
> >>
> >> It seems like we almost managed to remove all users of the
> >> "..._name_add..." APIs for genpd. If hasn't been for $subject patch.
> >> :-)
> >>
> >> Now, I realize this is already too late here, but let's try to fix
> >> this before it turns into a bigger issue.
> >>
> >> Geert, do you think it's possible to convert into using the non-named
> >> bases APIs?
> >
> > That will be difficult. This code is meant to use drivers that are not yet
> > DT-aware on DT-based systems. Hence it uses platform devices with named PM
> > domains, while the PM domains are described in DT.
> > I don't think there's another way to look up a PM domain by name, is there?
> 
> As a matter of fact there are, especially for those genpds that has
> been created through DT as in this case. The API to use is
> of_genpd_get_from_provider() to find the struct generic_pm_domain.

Thanks!

> Yes, I do realize that you need to manage the parsing of the domain
> name to make sure it's the one you want, but I would rather keep that
> "hack" in this driver than in the generic API.

OK. It turned out not to be that complex, cfr. the patch below.
For now this supports PM domains with "#power-domain-cells = <0>" only,
but of course it can be extended if the need arises.

I've also tried:

    np = of_find_compatible_node(NULL, NULL, "renesas,sysc-rmobile");
    np = of_find_node_by_name(np, "a4lc");

(the second step is needed because of the domain hierarchy in DT), but that
would require adding the compatible string to struct board_staging_dev,
and doesn't work if you have multiple identical power providers.

I hope you like it?

>From 5fb11904845eb929a5b3382a9d5153c151cde1cf Mon Sep 17 00:00:00 2001
From: Geert Uytterhoeven <geert+renesas@glider.be>
Date: Fri, 4 Sep 2015 16:52:33 +0200
Subject: [PATCH/RFC] staging: board: Migrate away from
 __pm_genpd_name_add_device()

The named genpd APIs are deprecated. Hence convert the board staging
code from using genpd names to DT node paths.

For now this supports PM domains with "#power-domain-cells = <0>" only.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/staging/board/armadillo800eva.c |  2 +-
 drivers/staging/board/board.c           | 36 ++++++++++++++++++++++++++++++++-
 2 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/board/armadillo800eva.c b/drivers/staging/board/armadillo800eva.c
index 0165591a52443c46..912c96b0536def7c 100644
--- a/drivers/staging/board/armadillo800eva.c
+++ b/drivers/staging/board/armadillo800eva.c
@@ -91,7 +91,7 @@ static const struct board_staging_dev armadillo800eva_devices[] __initconst = {
 		.pdev		= &lcdc0_device,
 		.clocks		= lcdc0_clocks,
 		.nclocks	= ARRAY_SIZE(lcdc0_clocks),
-		.domain		= "a4lc",
+		.domain		= "/system-controller@e6180000/pm-domains/c5/a4lc@1"
 	},
 };
 
diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
index 29d456e29f38feac..3eb5eb8f069c236d 100644
--- a/drivers/staging/board/board.c
+++ b/drivers/staging/board/board.c
@@ -135,6 +135,40 @@ int __init board_staging_register_clock(const struct board_staging_clk *bsc)
 	return error;
 }
 
+#ifdef CONFIG_PM_GENERIC_DOMAINS_OF
+static int board_staging_add_dev_domain(struct platform_device *pdev,
+					const char *domain)
+{
+	struct of_phandle_args pd_args;
+	struct generic_pm_domain *pd;
+	struct device_node *np;
+
+	np = of_find_node_by_path(domain);
+	if (!np) {
+		pr_err("Cannot find domain node %s\n", domain);
+		return -ENOENT;
+	}
+
+	pd_args.np = np;
+	pd_args.args_count = 0;
+	pd = of_genpd_get_from_provider(&pd_args);
+	if (IS_ERR(pd)) {
+		pr_err("Cannot find genpd %s (%ld)\n", domain, PTR_ERR(pd));
+		return PTR_ERR(pd);
+
+	}
+	pr_debug("Found genpd %s for device %s\n", pd->name, pdev->name);
+
+	return pm_genpd_add_device(pd, &pdev->dev);
+}
+#else
+static inline int board_staging_add_dev_domain(struct platform_device *pdev,
+					       const char *domain)
+{
+	return 0;
+}
+#endif
+
 int __init board_staging_register_device(const struct board_staging_dev *dev)
 {
 	struct platform_device *pdev = dev->pdev;
@@ -161,7 +195,7 @@ int __init board_staging_register_device(const struct board_staging_dev *dev)
 	}
 
 	if (dev->domain)
-		__pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
+		board_staging_add_dev_domain(pdev, dev->domain);
 
 	return error;
 }
-- 
1.9.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

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

* [PATCH v2 5/7] staging: board: Add support for devices with complex dependencies
@ 2015-09-04 15:03           ` Geert Uytterhoeven
  0 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-09-04 15:03 UTC (permalink / raw)
  To: linux-arm-kernel

	Hi Ulf,

On Fri, 4 Sep 2015, Ulf Hansson wrote:
> On 3 September 2015 at 15:35, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > On Thu, Sep 3, 2015 at 2:53 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> >> On 17 June 2015 at 10:38, Geert Uytterhoeven <geert+renesas@glider.be> wrote:
> >>> Add support for easy registering of one ore more platform devices that
> >>> may:
> >>>   - need clocks that are described in DT,
> >>>   - be part of a PM Domain.
> >
> >>> diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
> >>> index 8712f566b31196e0..29d456e29f38feac 100644
> >>> --- a/drivers/staging/board/board.c
> >>> +++ b/drivers/staging/board/board.c
> >
> >>> +int __init board_staging_register_device(const struct board_staging_dev *dev)
> >>> +{
> >>> +       struct platform_device *pdev = dev->pdev;
> >>> +       unsigned int i;
> >>> +       int error;
> >>> +
> >>> +       pr_debug("Trying to register device %s\n", pdev->name);
> >>> +       if (board_staging_dt_node_available(pdev->resource,
> >>> +                                           pdev->num_resources)) {
> >>> +               pr_warn("Skipping %s, already in DT\n", pdev->name);
> >>> +               return -EEXIST;
> >>> +       }
> >>> +
> >>> +       board_staging_gic_fixup_resources(pdev->resource, pdev->num_resources);
> >>> +
> >>> +       for (i = 0; i < dev->nclocks; i++)
> >>> +               board_staging_register_clock(&dev->clocks[i]);
> >>> +
> >>> +       error = platform_device_register(pdev);
> >>> +       if (error) {
> >>> +               pr_err("Failed to register device %s (%d)\n", pdev->name,
> >>> +                      error);
> >>> +               return error;
> >>> +       }
> >>> +
> >>> +       if (dev->domain)
> >>> +               __pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
> >>
> >> Urgh, this managed to slip through my filters.
> >>
> >> It seems like we almost managed to remove all users of the
> >> "..._name_add..." APIs for genpd. If hasn't been for $subject patch.
> >> :-)
> >>
> >> Now, I realize this is already too late here, but let's try to fix
> >> this before it turns into a bigger issue.
> >>
> >> Geert, do you think it's possible to convert into using the non-named
> >> bases APIs?
> >
> > That will be difficult. This code is meant to use drivers that are not yet
> > DT-aware on DT-based systems. Hence it uses platform devices with named PM
> > domains, while the PM domains are described in DT.
> > I don't think there's another way to look up a PM domain by name, is there?
> 
> As a matter of fact there are, especially for those genpds that has
> been created through DT as in this case. The API to use is
> of_genpd_get_from_provider() to find the struct generic_pm_domain.

Thanks!

> Yes, I do realize that you need to manage the parsing of the domain
> name to make sure it's the one you want, but I would rather keep that
> "hack" in this driver than in the generic API.

OK. It turned out not to be that complex, cfr. the patch below.
For now this supports PM domains with "#power-domain-cells = <0>" only,
but of course it can be extended if the need arises.

I've also tried:

    np = of_find_compatible_node(NULL, NULL, "renesas,sysc-rmobile");
    np = of_find_node_by_name(np, "a4lc");

(the second step is needed because of the domain hierarchy in DT), but that
would require adding the compatible string to struct board_staging_dev,
and doesn't work if you have multiple identical power providers.

I hope you like it?

>From 5fb11904845eb929a5b3382a9d5153c151cde1cf Mon Sep 17 00:00:00 2001
From: Geert Uytterhoeven <geert+renesas@glider.be>
Date: Fri, 4 Sep 2015 16:52:33 +0200
Subject: [PATCH/RFC] staging: board: Migrate away from
 __pm_genpd_name_add_device()

The named genpd APIs are deprecated. Hence convert the board staging
code from using genpd names to DT node paths.

For now this supports PM domains with "#power-domain-cells = <0>" only.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/staging/board/armadillo800eva.c |  2 +-
 drivers/staging/board/board.c           | 36 ++++++++++++++++++++++++++++++++-
 2 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/board/armadillo800eva.c b/drivers/staging/board/armadillo800eva.c
index 0165591a52443c46..912c96b0536def7c 100644
--- a/drivers/staging/board/armadillo800eva.c
+++ b/drivers/staging/board/armadillo800eva.c
@@ -91,7 +91,7 @@ static const struct board_staging_dev armadillo800eva_devices[] __initconst = {
 		.pdev		= &lcdc0_device,
 		.clocks		= lcdc0_clocks,
 		.nclocks	= ARRAY_SIZE(lcdc0_clocks),
-		.domain		= "a4lc",
+		.domain		= "/system-controller at e6180000/pm-domains/c5/a4lc at 1"
 	},
 };
 
diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
index 29d456e29f38feac..3eb5eb8f069c236d 100644
--- a/drivers/staging/board/board.c
+++ b/drivers/staging/board/board.c
@@ -135,6 +135,40 @@ int __init board_staging_register_clock(const struct board_staging_clk *bsc)
 	return error;
 }
 
+#ifdef CONFIG_PM_GENERIC_DOMAINS_OF
+static int board_staging_add_dev_domain(struct platform_device *pdev,
+					const char *domain)
+{
+	struct of_phandle_args pd_args;
+	struct generic_pm_domain *pd;
+	struct device_node *np;
+
+	np = of_find_node_by_path(domain);
+	if (!np) {
+		pr_err("Cannot find domain node %s\n", domain);
+		return -ENOENT;
+	}
+
+	pd_args.np = np;
+	pd_args.args_count = 0;
+	pd = of_genpd_get_from_provider(&pd_args);
+	if (IS_ERR(pd)) {
+		pr_err("Cannot find genpd %s (%ld)\n", domain, PTR_ERR(pd));
+		return PTR_ERR(pd);
+
+	}
+	pr_debug("Found genpd %s for device %s\n", pd->name, pdev->name);
+
+	return pm_genpd_add_device(pd, &pdev->dev);
+}
+#else
+static inline int board_staging_add_dev_domain(struct platform_device *pdev,
+					       const char *domain)
+{
+	return 0;
+}
+#endif
+
 int __init board_staging_register_device(const struct board_staging_dev *dev)
 {
 	struct platform_device *pdev = dev->pdev;
@@ -161,7 +195,7 @@ int __init board_staging_register_device(const struct board_staging_dev *dev)
 	}
 
 	if (dev->domain)
-		__pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
+		board_staging_add_dev_domain(pdev, dev->domain);
 
 	return error;
 }
-- 
1.9.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

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

* Re: [PATCH v2 5/7] staging: board: Add support for devices with complex dependencies
  2015-09-04 15:03           ` Geert Uytterhoeven
  (?)
  (?)
@ 2015-09-07 11:45             ` Ulf Hansson
  -1 siblings, 0 replies; 61+ messages in thread
From: Ulf Hansson @ 2015-09-07 11:45 UTC (permalink / raw)
  To: linux-arm-kernel

On 4 September 2015 at 17:03, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>         Hi Ulf,
>
> On Fri, 4 Sep 2015, Ulf Hansson wrote:
>> On 3 September 2015 at 15:35, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>> > On Thu, Sep 3, 2015 at 2:53 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>> >> On 17 June 2015 at 10:38, Geert Uytterhoeven <geert+renesas@glider.be> wrote:
>> >>> Add support for easy registering of one ore more platform devices that
>> >>> may:
>> >>>   - need clocks that are described in DT,
>> >>>   - be part of a PM Domain.
>> >
>> >>> diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
>> >>> index 8712f566b31196e0..29d456e29f38feac 100644
>> >>> --- a/drivers/staging/board/board.c
>> >>> +++ b/drivers/staging/board/board.c
>> >
>> >>> +int __init board_staging_register_device(const struct board_staging_dev *dev)
>> >>> +{
>> >>> +       struct platform_device *pdev = dev->pdev;
>> >>> +       unsigned int i;
>> >>> +       int error;
>> >>> +
>> >>> +       pr_debug("Trying to register device %s\n", pdev->name);
>> >>> +       if (board_staging_dt_node_available(pdev->resource,
>> >>> +                                           pdev->num_resources)) {
>> >>> +               pr_warn("Skipping %s, already in DT\n", pdev->name);
>> >>> +               return -EEXIST;
>> >>> +       }
>> >>> +
>> >>> +       board_staging_gic_fixup_resources(pdev->resource, pdev->num_resources);
>> >>> +
>> >>> +       for (i = 0; i < dev->nclocks; i++)
>> >>> +               board_staging_register_clock(&dev->clocks[i]);
>> >>> +
>> >>> +       error = platform_device_register(pdev);
>> >>> +       if (error) {
>> >>> +               pr_err("Failed to register device %s (%d)\n", pdev->name,
>> >>> +                      error);
>> >>> +               return error;
>> >>> +       }
>> >>> +
>> >>> +       if (dev->domain)
>> >>> +               __pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
>> >>
>> >> Urgh, this managed to slip through my filters.
>> >>
>> >> It seems like we almost managed to remove all users of the
>> >> "..._name_add..." APIs for genpd. If hasn't been for $subject patch.
>> >> :-)
>> >>
>> >> Now, I realize this is already too late here, but let's try to fix
>> >> this before it turns into a bigger issue.
>> >>
>> >> Geert, do you think it's possible to convert into using the non-named
>> >> bases APIs?
>> >
>> > That will be difficult. This code is meant to use drivers that are not yet
>> > DT-aware on DT-based systems. Hence it uses platform devices with named PM
>> > domains, while the PM domains are described in DT.
>> > I don't think there's another way to look up a PM domain by name, is there?
>>
>> As a matter of fact there are, especially for those genpds that has
>> been created through DT as in this case. The API to use is
>> of_genpd_get_from_provider() to find the struct generic_pm_domain.
>
> Thanks!
>
>> Yes, I do realize that you need to manage the parsing of the domain
>> name to make sure it's the one you want, but I would rather keep that
>> "hack" in this driver than in the generic API.
>
> OK. It turned out not to be that complex, cfr. the patch below.
> For now this supports PM domains with "#power-domain-cells = <0>" only,
> but of course it can be extended if the need arises.
>
> I've also tried:
>
>     np = of_find_compatible_node(NULL, NULL, "renesas,sysc-rmobile");
>     np = of_find_node_by_name(np, "a4lc");
>
> (the second step is needed because of the domain hierarchy in DT), but that
> would require adding the compatible string to struct board_staging_dev,
> and doesn't work if you have multiple identical power providers.
>
> I hope you like it?
>
> From 5fb11904845eb929a5b3382a9d5153c151cde1cf Mon Sep 17 00:00:00 2001
> From: Geert Uytterhoeven <geert+renesas@glider.be>
> Date: Fri, 4 Sep 2015 16:52:33 +0200
> Subject: [PATCH/RFC] staging: board: Migrate away from
>  __pm_genpd_name_add_device()
>
> The named genpd APIs are deprecated. Hence convert the board staging
> code from using genpd names to DT node paths.
>
> For now this supports PM domains with "#power-domain-cells = <0>" only.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Geert, thanks for posting this patch!

I wonder whether we could get this sent for the 4.3 rc[n], since that
would enable us to remove some of the named based API for genpd
through Rafael's linux-pm tree during this release cycle.

Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>

Kind regards
Uffe

> ---
>  drivers/staging/board/armadillo800eva.c |  2 +-
>  drivers/staging/board/board.c           | 36 ++++++++++++++++++++++++++++++++-
>  2 files changed, 36 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/board/armadillo800eva.c b/drivers/staging/board/armadillo800eva.c
> index 0165591a52443c46..912c96b0536def7c 100644
> --- a/drivers/staging/board/armadillo800eva.c
> +++ b/drivers/staging/board/armadillo800eva.c
> @@ -91,7 +91,7 @@ static const struct board_staging_dev armadillo800eva_devices[] __initconst = {
>                 .pdev           = &lcdc0_device,
>                 .clocks         = lcdc0_clocks,
>                 .nclocks        = ARRAY_SIZE(lcdc0_clocks),
> -               .domain         = "a4lc",
> +               .domain         = "/system-controller@e6180000/pm-domains/c5/a4lc@1"
>         },
>  };
>
> diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
> index 29d456e29f38feac..3eb5eb8f069c236d 100644
> --- a/drivers/staging/board/board.c
> +++ b/drivers/staging/board/board.c
> @@ -135,6 +135,40 @@ int __init board_staging_register_clock(const struct board_staging_clk *bsc)
>         return error;
>  }
>
> +#ifdef CONFIG_PM_GENERIC_DOMAINS_OF
> +static int board_staging_add_dev_domain(struct platform_device *pdev,
> +                                       const char *domain)
> +{
> +       struct of_phandle_args pd_args;
> +       struct generic_pm_domain *pd;
> +       struct device_node *np;
> +
> +       np = of_find_node_by_path(domain);
> +       if (!np) {
> +               pr_err("Cannot find domain node %s\n", domain);
> +               return -ENOENT;
> +       }
> +
> +       pd_args.np = np;
> +       pd_args.args_count = 0;
> +       pd = of_genpd_get_from_provider(&pd_args);
> +       if (IS_ERR(pd)) {
> +               pr_err("Cannot find genpd %s (%ld)\n", domain, PTR_ERR(pd));
> +               return PTR_ERR(pd);
> +
> +       }
> +       pr_debug("Found genpd %s for device %s\n", pd->name, pdev->name);
> +
> +       return pm_genpd_add_device(pd, &pdev->dev);
> +}
> +#else
> +static inline int board_staging_add_dev_domain(struct platform_device *pdev,
> +                                              const char *domain)
> +{
> +       return 0;
> +}
> +#endif
> +
>  int __init board_staging_register_device(const struct board_staging_dev *dev)
>  {
>         struct platform_device *pdev = dev->pdev;
> @@ -161,7 +195,7 @@ int __init board_staging_register_device(const struct board_staging_dev *dev)
>         }
>
>         if (dev->domain)
> -               __pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
> +               board_staging_add_dev_domain(pdev, dev->domain);
>
>         return error;
>  }
> --
> 1.9.1
>
> Gr{oetje,eeting}s,
>
>                                                 Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                                             -- Linus Torvalds

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

* Re: [PATCH v2 5/7] staging: board: Add support for devices with complex dependencies
@ 2015-09-07 11:45             ` Ulf Hansson
  0 siblings, 0 replies; 61+ messages in thread
From: Ulf Hansson @ 2015-09-07 11:45 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Geert Uytterhoeven, Greg Kroah-Hartman, Simon Horman,
	Magnus Damm, Arnd Bergmann, Laurent Pinchart, Kuninori Morimoto,
	Marc Zyngier, driverdevel, Linux-sh list, linux-pm, devicetree,
	linux-arm-kernel, linux-kernel

On 4 September 2015 at 17:03, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>         Hi Ulf,
>
> On Fri, 4 Sep 2015, Ulf Hansson wrote:
>> On 3 September 2015 at 15:35, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>> > On Thu, Sep 3, 2015 at 2:53 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>> >> On 17 June 2015 at 10:38, Geert Uytterhoeven <geert+renesas@glider.be> wrote:
>> >>> Add support for easy registering of one ore more platform devices that
>> >>> may:
>> >>>   - need clocks that are described in DT,
>> >>>   - be part of a PM Domain.
>> >
>> >>> diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
>> >>> index 8712f566b31196e0..29d456e29f38feac 100644
>> >>> --- a/drivers/staging/board/board.c
>> >>> +++ b/drivers/staging/board/board.c
>> >
>> >>> +int __init board_staging_register_device(const struct board_staging_dev *dev)
>> >>> +{
>> >>> +       struct platform_device *pdev = dev->pdev;
>> >>> +       unsigned int i;
>> >>> +       int error;
>> >>> +
>> >>> +       pr_debug("Trying to register device %s\n", pdev->name);
>> >>> +       if (board_staging_dt_node_available(pdev->resource,
>> >>> +                                           pdev->num_resources)) {
>> >>> +               pr_warn("Skipping %s, already in DT\n", pdev->name);
>> >>> +               return -EEXIST;
>> >>> +       }
>> >>> +
>> >>> +       board_staging_gic_fixup_resources(pdev->resource, pdev->num_resources);
>> >>> +
>> >>> +       for (i = 0; i < dev->nclocks; i++)
>> >>> +               board_staging_register_clock(&dev->clocks[i]);
>> >>> +
>> >>> +       error = platform_device_register(pdev);
>> >>> +       if (error) {
>> >>> +               pr_err("Failed to register device %s (%d)\n", pdev->name,
>> >>> +                      error);
>> >>> +               return error;
>> >>> +       }
>> >>> +
>> >>> +       if (dev->domain)
>> >>> +               __pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
>> >>
>> >> Urgh, this managed to slip through my filters.
>> >>
>> >> It seems like we almost managed to remove all users of the
>> >> "..._name_add..." APIs for genpd. If hasn't been for $subject patch.
>> >> :-)
>> >>
>> >> Now, I realize this is already too late here, but let's try to fix
>> >> this before it turns into a bigger issue.
>> >>
>> >> Geert, do you think it's possible to convert into using the non-named
>> >> bases APIs?
>> >
>> > That will be difficult. This code is meant to use drivers that are not yet
>> > DT-aware on DT-based systems. Hence it uses platform devices with named PM
>> > domains, while the PM domains are described in DT.
>> > I don't think there's another way to look up a PM domain by name, is there?
>>
>> As a matter of fact there are, especially for those genpds that has
>> been created through DT as in this case. The API to use is
>> of_genpd_get_from_provider() to find the struct generic_pm_domain.
>
> Thanks!
>
>> Yes, I do realize that you need to manage the parsing of the domain
>> name to make sure it's the one you want, but I would rather keep that
>> "hack" in this driver than in the generic API.
>
> OK. It turned out not to be that complex, cfr. the patch below.
> For now this supports PM domains with "#power-domain-cells = <0>" only,
> but of course it can be extended if the need arises.
>
> I've also tried:
>
>     np = of_find_compatible_node(NULL, NULL, "renesas,sysc-rmobile");
>     np = of_find_node_by_name(np, "a4lc");
>
> (the second step is needed because of the domain hierarchy in DT), but that
> would require adding the compatible string to struct board_staging_dev,
> and doesn't work if you have multiple identical power providers.
>
> I hope you like it?
>
> From 5fb11904845eb929a5b3382a9d5153c151cde1cf Mon Sep 17 00:00:00 2001
> From: Geert Uytterhoeven <geert+renesas@glider.be>
> Date: Fri, 4 Sep 2015 16:52:33 +0200
> Subject: [PATCH/RFC] staging: board: Migrate away from
>  __pm_genpd_name_add_device()
>
> The named genpd APIs are deprecated. Hence convert the board staging
> code from using genpd names to DT node paths.
>
> For now this supports PM domains with "#power-domain-cells = <0>" only.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Geert, thanks for posting this patch!

I wonder whether we could get this sent for the 4.3 rc[n], since that
would enable us to remove some of the named based API for genpd
through Rafael's linux-pm tree during this release cycle.

Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>

Kind regards
Uffe

> ---
>  drivers/staging/board/armadillo800eva.c |  2 +-
>  drivers/staging/board/board.c           | 36 ++++++++++++++++++++++++++++++++-
>  2 files changed, 36 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/board/armadillo800eva.c b/drivers/staging/board/armadillo800eva.c
> index 0165591a52443c46..912c96b0536def7c 100644
> --- a/drivers/staging/board/armadillo800eva.c
> +++ b/drivers/staging/board/armadillo800eva.c
> @@ -91,7 +91,7 @@ static const struct board_staging_dev armadillo800eva_devices[] __initconst = {
>                 .pdev           = &lcdc0_device,
>                 .clocks         = lcdc0_clocks,
>                 .nclocks        = ARRAY_SIZE(lcdc0_clocks),
> -               .domain         = "a4lc",
> +               .domain         = "/system-controller@e6180000/pm-domains/c5/a4lc@1"
>         },
>  };
>
> diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
> index 29d456e29f38feac..3eb5eb8f069c236d 100644
> --- a/drivers/staging/board/board.c
> +++ b/drivers/staging/board/board.c
> @@ -135,6 +135,40 @@ int __init board_staging_register_clock(const struct board_staging_clk *bsc)
>         return error;
>  }
>
> +#ifdef CONFIG_PM_GENERIC_DOMAINS_OF
> +static int board_staging_add_dev_domain(struct platform_device *pdev,
> +                                       const char *domain)
> +{
> +       struct of_phandle_args pd_args;
> +       struct generic_pm_domain *pd;
> +       struct device_node *np;
> +
> +       np = of_find_node_by_path(domain);
> +       if (!np) {
> +               pr_err("Cannot find domain node %s\n", domain);
> +               return -ENOENT;
> +       }
> +
> +       pd_args.np = np;
> +       pd_args.args_count = 0;
> +       pd = of_genpd_get_from_provider(&pd_args);
> +       if (IS_ERR(pd)) {
> +               pr_err("Cannot find genpd %s (%ld)\n", domain, PTR_ERR(pd));
> +               return PTR_ERR(pd);
> +
> +       }
> +       pr_debug("Found genpd %s for device %s\n", pd->name, pdev->name);
> +
> +       return pm_genpd_add_device(pd, &pdev->dev);
> +}
> +#else
> +static inline int board_staging_add_dev_domain(struct platform_device *pdev,
> +                                              const char *domain)
> +{
> +       return 0;
> +}
> +#endif
> +
>  int __init board_staging_register_device(const struct board_staging_dev *dev)
>  {
>         struct platform_device *pdev = dev->pdev;
> @@ -161,7 +195,7 @@ int __init board_staging_register_device(const struct board_staging_dev *dev)
>         }
>
>         if (dev->domain)
> -               __pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
> +               board_staging_add_dev_domain(pdev, dev->domain);
>
>         return error;
>  }
> --
> 1.9.1
>
> Gr{oetje,eeting}s,
>
>                                                 Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                                             -- Linus Torvalds

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

* Re: [PATCH v2 5/7] staging: board: Add support for devices with complex dependencies
@ 2015-09-07 11:45             ` Ulf Hansson
  0 siblings, 0 replies; 61+ messages in thread
From: Ulf Hansson @ 2015-09-07 11:45 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Geert Uytterhoeven, Greg Kroah-Hartman, Simon Horman,
	Magnus Damm, Arnd Bergmann, Laurent Pinchart, Kuninori Morimoto,
	Marc Zyngier, driverdevel, Linux-sh list, linux-pm, devicetree,
	linux-arm-kernel, linux-kernel

On 4 September 2015 at 17:03, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>         Hi Ulf,
>
> On Fri, 4 Sep 2015, Ulf Hansson wrote:
>> On 3 September 2015 at 15:35, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>> > On Thu, Sep 3, 2015 at 2:53 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>> >> On 17 June 2015 at 10:38, Geert Uytterhoeven <geert+renesas@glider.be> wrote:
>> >>> Add support for easy registering of one ore more platform devices that
>> >>> may:
>> >>>   - need clocks that are described in DT,
>> >>>   - be part of a PM Domain.
>> >
>> >>> diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
>> >>> index 8712f566b31196e0..29d456e29f38feac 100644
>> >>> --- a/drivers/staging/board/board.c
>> >>> +++ b/drivers/staging/board/board.c
>> >
>> >>> +int __init board_staging_register_device(const struct board_staging_dev *dev)
>> >>> +{
>> >>> +       struct platform_device *pdev = dev->pdev;
>> >>> +       unsigned int i;
>> >>> +       int error;
>> >>> +
>> >>> +       pr_debug("Trying to register device %s\n", pdev->name);
>> >>> +       if (board_staging_dt_node_available(pdev->resource,
>> >>> +                                           pdev->num_resources)) {
>> >>> +               pr_warn("Skipping %s, already in DT\n", pdev->name);
>> >>> +               return -EEXIST;
>> >>> +       }
>> >>> +
>> >>> +       board_staging_gic_fixup_resources(pdev->resource, pdev->num_resources);
>> >>> +
>> >>> +       for (i = 0; i < dev->nclocks; i++)
>> >>> +               board_staging_register_clock(&dev->clocks[i]);
>> >>> +
>> >>> +       error = platform_device_register(pdev);
>> >>> +       if (error) {
>> >>> +               pr_err("Failed to register device %s (%d)\n", pdev->name,
>> >>> +                      error);
>> >>> +               return error;
>> >>> +       }
>> >>> +
>> >>> +       if (dev->domain)
>> >>> +               __pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
>> >>
>> >> Urgh, this managed to slip through my filters.
>> >>
>> >> It seems like we almost managed to remove all users of the
>> >> "..._name_add..." APIs for genpd. If hasn't been for $subject patch.
>> >> :-)
>> >>
>> >> Now, I realize this is already too late here, but let's try to fix
>> >> this before it turns into a bigger issue.
>> >>
>> >> Geert, do you think it's possible to convert into using the non-named
>> >> bases APIs?
>> >
>> > That will be difficult. This code is meant to use drivers that are not yet
>> > DT-aware on DT-based systems. Hence it uses platform devices with named PM
>> > domains, while the PM domains are described in DT.
>> > I don't think there's another way to look up a PM domain by name, is there?
>>
>> As a matter of fact there are, especially for those genpds that has
>> been created through DT as in this case. The API to use is
>> of_genpd_get_from_provider() to find the struct generic_pm_domain.
>
> Thanks!
>
>> Yes, I do realize that you need to manage the parsing of the domain
>> name to make sure it's the one you want, but I would rather keep that
>> "hack" in this driver than in the generic API.
>
> OK. It turned out not to be that complex, cfr. the patch below.
> For now this supports PM domains with "#power-domain-cells = <0>" only,
> but of course it can be extended if the need arises.
>
> I've also tried:
>
>     np = of_find_compatible_node(NULL, NULL, "renesas,sysc-rmobile");
>     np = of_find_node_by_name(np, "a4lc");
>
> (the second step is needed because of the domain hierarchy in DT), but that
> would require adding the compatible string to struct board_staging_dev,
> and doesn't work if you have multiple identical power providers.
>
> I hope you like it?
>
> From 5fb11904845eb929a5b3382a9d5153c151cde1cf Mon Sep 17 00:00:00 2001
> From: Geert Uytterhoeven <geert+renesas@glider.be>
> Date: Fri, 4 Sep 2015 16:52:33 +0200
> Subject: [PATCH/RFC] staging: board: Migrate away from
>  __pm_genpd_name_add_device()
>
> The named genpd APIs are deprecated. Hence convert the board staging
> code from using genpd names to DT node paths.
>
> For now this supports PM domains with "#power-domain-cells = <0>" only.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Geert, thanks for posting this patch!

I wonder whether we could get this sent for the 4.3 rc[n], since that
would enable us to remove some of the named based API for genpd
through Rafael's linux-pm tree during this release cycle.

Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>

Kind regards
Uffe

> ---
>  drivers/staging/board/armadillo800eva.c |  2 +-
>  drivers/staging/board/board.c           | 36 ++++++++++++++++++++++++++++++++-
>  2 files changed, 36 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/board/armadillo800eva.c b/drivers/staging/board/armadillo800eva.c
> index 0165591a52443c46..912c96b0536def7c 100644
> --- a/drivers/staging/board/armadillo800eva.c
> +++ b/drivers/staging/board/armadillo800eva.c
> @@ -91,7 +91,7 @@ static const struct board_staging_dev armadillo800eva_devices[] __initconst = {
>                 .pdev           = &lcdc0_device,
>                 .clocks         = lcdc0_clocks,
>                 .nclocks        = ARRAY_SIZE(lcdc0_clocks),
> -               .domain         = "a4lc",
> +               .domain         = "/system-controller@e6180000/pm-domains/c5/a4lc@1"
>         },
>  };
>
> diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
> index 29d456e29f38feac..3eb5eb8f069c236d 100644
> --- a/drivers/staging/board/board.c
> +++ b/drivers/staging/board/board.c
> @@ -135,6 +135,40 @@ int __init board_staging_register_clock(const struct board_staging_clk *bsc)
>         return error;
>  }
>
> +#ifdef CONFIG_PM_GENERIC_DOMAINS_OF
> +static int board_staging_add_dev_domain(struct platform_device *pdev,
> +                                       const char *domain)
> +{
> +       struct of_phandle_args pd_args;
> +       struct generic_pm_domain *pd;
> +       struct device_node *np;
> +
> +       np = of_find_node_by_path(domain);
> +       if (!np) {
> +               pr_err("Cannot find domain node %s\n", domain);
> +               return -ENOENT;
> +       }
> +
> +       pd_args.np = np;
> +       pd_args.args_count = 0;
> +       pd = of_genpd_get_from_provider(&pd_args);
> +       if (IS_ERR(pd)) {
> +               pr_err("Cannot find genpd %s (%ld)\n", domain, PTR_ERR(pd));
> +               return PTR_ERR(pd);
> +
> +       }
> +       pr_debug("Found genpd %s for device %s\n", pd->name, pdev->name);
> +
> +       return pm_genpd_add_device(pd, &pdev->dev);
> +}
> +#else
> +static inline int board_staging_add_dev_domain(struct platform_device *pdev,
> +                                              const char *domain)
> +{
> +       return 0;
> +}
> +#endif
> +
>  int __init board_staging_register_device(const struct board_staging_dev *dev)
>  {
>         struct platform_device *pdev = dev->pdev;
> @@ -161,7 +195,7 @@ int __init board_staging_register_device(const struct board_staging_dev *dev)
>         }
>
>         if (dev->domain)
> -               __pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
> +               board_staging_add_dev_domain(pdev, dev->domain);
>
>         return error;
>  }
> --
> 1.9.1
>
> Gr{oetje,eeting}s,
>
>                                                 Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                                             -- Linus Torvalds

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

* [PATCH v2 5/7] staging: board: Add support for devices with complex dependencies
@ 2015-09-07 11:45             ` Ulf Hansson
  0 siblings, 0 replies; 61+ messages in thread
From: Ulf Hansson @ 2015-09-07 11:45 UTC (permalink / raw)
  To: linux-arm-kernel

On 4 September 2015 at 17:03, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>         Hi Ulf,
>
> On Fri, 4 Sep 2015, Ulf Hansson wrote:
>> On 3 September 2015 at 15:35, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>> > On Thu, Sep 3, 2015 at 2:53 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>> >> On 17 June 2015 at 10:38, Geert Uytterhoeven <geert+renesas@glider.be> wrote:
>> >>> Add support for easy registering of one ore more platform devices that
>> >>> may:
>> >>>   - need clocks that are described in DT,
>> >>>   - be part of a PM Domain.
>> >
>> >>> diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
>> >>> index 8712f566b31196e0..29d456e29f38feac 100644
>> >>> --- a/drivers/staging/board/board.c
>> >>> +++ b/drivers/staging/board/board.c
>> >
>> >>> +int __init board_staging_register_device(const struct board_staging_dev *dev)
>> >>> +{
>> >>> +       struct platform_device *pdev = dev->pdev;
>> >>> +       unsigned int i;
>> >>> +       int error;
>> >>> +
>> >>> +       pr_debug("Trying to register device %s\n", pdev->name);
>> >>> +       if (board_staging_dt_node_available(pdev->resource,
>> >>> +                                           pdev->num_resources)) {
>> >>> +               pr_warn("Skipping %s, already in DT\n", pdev->name);
>> >>> +               return -EEXIST;
>> >>> +       }
>> >>> +
>> >>> +       board_staging_gic_fixup_resources(pdev->resource, pdev->num_resources);
>> >>> +
>> >>> +       for (i = 0; i < dev->nclocks; i++)
>> >>> +               board_staging_register_clock(&dev->clocks[i]);
>> >>> +
>> >>> +       error = platform_device_register(pdev);
>> >>> +       if (error) {
>> >>> +               pr_err("Failed to register device %s (%d)\n", pdev->name,
>> >>> +                      error);
>> >>> +               return error;
>> >>> +       }
>> >>> +
>> >>> +       if (dev->domain)
>> >>> +               __pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
>> >>
>> >> Urgh, this managed to slip through my filters.
>> >>
>> >> It seems like we almost managed to remove all users of the
>> >> "..._name_add..." APIs for genpd. If hasn't been for $subject patch.
>> >> :-)
>> >>
>> >> Now, I realize this is already too late here, but let's try to fix
>> >> this before it turns into a bigger issue.
>> >>
>> >> Geert, do you think it's possible to convert into using the non-named
>> >> bases APIs?
>> >
>> > That will be difficult. This code is meant to use drivers that are not yet
>> > DT-aware on DT-based systems. Hence it uses platform devices with named PM
>> > domains, while the PM domains are described in DT.
>> > I don't think there's another way to look up a PM domain by name, is there?
>>
>> As a matter of fact there are, especially for those genpds that has
>> been created through DT as in this case. The API to use is
>> of_genpd_get_from_provider() to find the struct generic_pm_domain.
>
> Thanks!
>
>> Yes, I do realize that you need to manage the parsing of the domain
>> name to make sure it's the one you want, but I would rather keep that
>> "hack" in this driver than in the generic API.
>
> OK. It turned out not to be that complex, cfr. the patch below.
> For now this supports PM domains with "#power-domain-cells = <0>" only,
> but of course it can be extended if the need arises.
>
> I've also tried:
>
>     np = of_find_compatible_node(NULL, NULL, "renesas,sysc-rmobile");
>     np = of_find_node_by_name(np, "a4lc");
>
> (the second step is needed because of the domain hierarchy in DT), but that
> would require adding the compatible string to struct board_staging_dev,
> and doesn't work if you have multiple identical power providers.
>
> I hope you like it?
>
> From 5fb11904845eb929a5b3382a9d5153c151cde1cf Mon Sep 17 00:00:00 2001
> From: Geert Uytterhoeven <geert+renesas@glider.be>
> Date: Fri, 4 Sep 2015 16:52:33 +0200
> Subject: [PATCH/RFC] staging: board: Migrate away from
>  __pm_genpd_name_add_device()
>
> The named genpd APIs are deprecated. Hence convert the board staging
> code from using genpd names to DT node paths.
>
> For now this supports PM domains with "#power-domain-cells = <0>" only.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Geert, thanks for posting this patch!

I wonder whether we could get this sent for the 4.3 rc[n], since that
would enable us to remove some of the named based API for genpd
through Rafael's linux-pm tree during this release cycle.

Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>

Kind regards
Uffe

> ---
>  drivers/staging/board/armadillo800eva.c |  2 +-
>  drivers/staging/board/board.c           | 36 ++++++++++++++++++++++++++++++++-
>  2 files changed, 36 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/board/armadillo800eva.c b/drivers/staging/board/armadillo800eva.c
> index 0165591a52443c46..912c96b0536def7c 100644
> --- a/drivers/staging/board/armadillo800eva.c
> +++ b/drivers/staging/board/armadillo800eva.c
> @@ -91,7 +91,7 @@ static const struct board_staging_dev armadillo800eva_devices[] __initconst = {
>                 .pdev           = &lcdc0_device,
>                 .clocks         = lcdc0_clocks,
>                 .nclocks        = ARRAY_SIZE(lcdc0_clocks),
> -               .domain         = "a4lc",
> +               .domain         = "/system-controller at e6180000/pm-domains/c5/a4lc at 1"
>         },
>  };
>
> diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
> index 29d456e29f38feac..3eb5eb8f069c236d 100644
> --- a/drivers/staging/board/board.c
> +++ b/drivers/staging/board/board.c
> @@ -135,6 +135,40 @@ int __init board_staging_register_clock(const struct board_staging_clk *bsc)
>         return error;
>  }
>
> +#ifdef CONFIG_PM_GENERIC_DOMAINS_OF
> +static int board_staging_add_dev_domain(struct platform_device *pdev,
> +                                       const char *domain)
> +{
> +       struct of_phandle_args pd_args;
> +       struct generic_pm_domain *pd;
> +       struct device_node *np;
> +
> +       np = of_find_node_by_path(domain);
> +       if (!np) {
> +               pr_err("Cannot find domain node %s\n", domain);
> +               return -ENOENT;
> +       }
> +
> +       pd_args.np = np;
> +       pd_args.args_count = 0;
> +       pd = of_genpd_get_from_provider(&pd_args);
> +       if (IS_ERR(pd)) {
> +               pr_err("Cannot find genpd %s (%ld)\n", domain, PTR_ERR(pd));
> +               return PTR_ERR(pd);
> +
> +       }
> +       pr_debug("Found genpd %s for device %s\n", pd->name, pdev->name);
> +
> +       return pm_genpd_add_device(pd, &pdev->dev);
> +}
> +#else
> +static inline int board_staging_add_dev_domain(struct platform_device *pdev,
> +                                              const char *domain)
> +{
> +       return 0;
> +}
> +#endif
> +
>  int __init board_staging_register_device(const struct board_staging_dev *dev)
>  {
>         struct platform_device *pdev = dev->pdev;
> @@ -161,7 +195,7 @@ int __init board_staging_register_device(const struct board_staging_dev *dev)
>         }
>
>         if (dev->domain)
> -               __pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
> +               board_staging_add_dev_domain(pdev, dev->domain);
>
>         return error;
>  }
> --
> 1.9.1
>
> Gr{oetje,eeting}s,
>
>                                                 Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                                             -- Linus Torvalds

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

* Re: [PATCH v2 5/7] staging: board: Add support for devices with complex dependencies
  2015-09-07 11:45             ` Ulf Hansson
  (?)
  (?)
@ 2015-09-07 12:08               ` Geert Uytterhoeven
  -1 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-09-07 12:08 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Ulf,

On Mon, Sep 7, 2015 at 1:45 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> On 4 September 2015 at 17:03, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>> On Fri, 4 Sep 2015, Ulf Hansson wrote:
>>> On 3 September 2015 at 15:35, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>>> > On Thu, Sep 3, 2015 at 2:53 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>>> >> On 17 June 2015 at 10:38, Geert Uytterhoeven <geert+renesas@glider.be> wrote:
>>> >>> Add support for easy registering of one ore more platform devices that
>>> >>> may:
>>> >>>   - need clocks that are described in DT,
>>> >>>   - be part of a PM Domain.
>>> >
>>> >>> diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
>>> >>> index 8712f566b31196e0..29d456e29f38feac 100644
>>> >>> --- a/drivers/staging/board/board.c
>>> >>> +++ b/drivers/staging/board/board.c
>>> >
>>> >>> +int __init board_staging_register_device(const struct board_staging_dev *dev)
>>> >>> +{
>>> >>> +       struct platform_device *pdev = dev->pdev;
>>> >>> +       unsigned int i;
>>> >>> +       int error;
>>> >>> +
>>> >>> +       pr_debug("Trying to register device %s\n", pdev->name);
>>> >>> +       if (board_staging_dt_node_available(pdev->resource,
>>> >>> +                                           pdev->num_resources)) {
>>> >>> +               pr_warn("Skipping %s, already in DT\n", pdev->name);
>>> >>> +               return -EEXIST;
>>> >>> +       }
>>> >>> +
>>> >>> +       board_staging_gic_fixup_resources(pdev->resource, pdev->num_resources);
>>> >>> +
>>> >>> +       for (i = 0; i < dev->nclocks; i++)
>>> >>> +               board_staging_register_clock(&dev->clocks[i]);
>>> >>> +
>>> >>> +       error = platform_device_register(pdev);
>>> >>> +       if (error) {
>>> >>> +               pr_err("Failed to register device %s (%d)\n", pdev->name,
>>> >>> +                      error);
>>> >>> +               return error;
>>> >>> +       }
>>> >>> +
>>> >>> +       if (dev->domain)
>>> >>> +               __pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
>>> >>
>>> >> Urgh, this managed to slip through my filters.
>>> >>
>>> >> It seems like we almost managed to remove all users of the
>>> >> "..._name_add..." APIs for genpd. If hasn't been for $subject patch.
>>> >> :-)
>>> >>
>>> >> Now, I realize this is already too late here, but let's try to fix
>>> >> this before it turns into a bigger issue.
>>> >>
>>> >> Geert, do you think it's possible to convert into using the non-named
>>> >> bases APIs?
>>> >
>>> > That will be difficult. This code is meant to use drivers that are not yet
>>> > DT-aware on DT-based systems. Hence it uses platform devices with named PM
>>> > domains, while the PM domains are described in DT.
>>> > I don't think there's another way to look up a PM domain by name, is there?
>>>
>>> As a matter of fact there are, especially for those genpds that has
>>> been created through DT as in this case. The API to use is
>>> of_genpd_get_from_provider() to find the struct generic_pm_domain.
>>
>> Thanks!
>>
>>> Yes, I do realize that you need to manage the parsing of the domain
>>> name to make sure it's the one you want, but I would rather keep that
>>> "hack" in this driver than in the generic API.
>>
>> OK. It turned out not to be that complex, cfr. the patch below.
>> For now this supports PM domains with "#power-domain-cells = <0>" only,
>> but of course it can be extended if the need arises.
>>
>> I've also tried:
>>
>>     np = of_find_compatible_node(NULL, NULL, "renesas,sysc-rmobile");
>>     np = of_find_node_by_name(np, "a4lc");
>>
>> (the second step is needed because of the domain hierarchy in DT), but that
>> would require adding the compatible string to struct board_staging_dev,
>> and doesn't work if you have multiple identical power providers.
>>
>> I hope you like it?
>>
>> From 5fb11904845eb929a5b3382a9d5153c151cde1cf Mon Sep 17 00:00:00 2001
>> From: Geert Uytterhoeven <geert+renesas@glider.be>
>> Date: Fri, 4 Sep 2015 16:52:33 +0200
>> Subject: [PATCH/RFC] staging: board: Migrate away from
>>  __pm_genpd_name_add_device()
>>
>> The named genpd APIs are deprecated. Hence convert the board staging
>> code from using genpd names to DT node paths.
>>
>> For now this supports PM domains with "#power-domain-cells = <0>" only.
>>
>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
>
> Geert, thanks for posting this patch!
>
> I wonder whether we could get this sent for the 4.3 rc[n], since that
> would enable us to remove some of the named based API for genpd
> through Rafael's linux-pm tree during this release cycle.
>
> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>

Thanks!

If GregKH provides his ack, Rafael can take it with your named genpd API
removal series? Shall I resend with an official request?

> Kind regards
> Uffe
>
>> ---
>>  drivers/staging/board/armadillo800eva.c |  2 +-
>>  drivers/staging/board/board.c           | 36 ++++++++++++++++++++++++++++++++-
>>  2 files changed, 36 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/staging/board/armadillo800eva.c b/drivers/staging/board/armadillo800eva.c
>> index 0165591a52443c46..912c96b0536def7c 100644
>> --- a/drivers/staging/board/armadillo800eva.c
>> +++ b/drivers/staging/board/armadillo800eva.c
>> @@ -91,7 +91,7 @@ static const struct board_staging_dev armadillo800eva_devices[] __initconst = {
>>                 .pdev           = &lcdc0_device,
>>                 .clocks         = lcdc0_clocks,
>>                 .nclocks        = ARRAY_SIZE(lcdc0_clocks),
>> -               .domain         = "a4lc",
>> +               .domain         = "/system-controller@e6180000/pm-domains/c5/a4lc@1"
>>         },
>>  };
>>
>> diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
>> index 29d456e29f38feac..3eb5eb8f069c236d 100644
>> --- a/drivers/staging/board/board.c
>> +++ b/drivers/staging/board/board.c
>> @@ -135,6 +135,40 @@ int __init board_staging_register_clock(const struct board_staging_clk *bsc)
>>         return error;
>>  }
>>
>> +#ifdef CONFIG_PM_GENERIC_DOMAINS_OF
>> +static int board_staging_add_dev_domain(struct platform_device *pdev,
>> +                                       const char *domain)
>> +{
>> +       struct of_phandle_args pd_args;
>> +       struct generic_pm_domain *pd;
>> +       struct device_node *np;
>> +
>> +       np = of_find_node_by_path(domain);
>> +       if (!np) {
>> +               pr_err("Cannot find domain node %s\n", domain);
>> +               return -ENOENT;
>> +       }
>> +
>> +       pd_args.np = np;
>> +       pd_args.args_count = 0;
>> +       pd = of_genpd_get_from_provider(&pd_args);
>> +       if (IS_ERR(pd)) {
>> +               pr_err("Cannot find genpd %s (%ld)\n", domain, PTR_ERR(pd));
>> +               return PTR_ERR(pd);
>> +
>> +       }
>> +       pr_debug("Found genpd %s for device %s\n", pd->name, pdev->name);
>> +
>> +       return pm_genpd_add_device(pd, &pdev->dev);
>> +}
>> +#else
>> +static inline int board_staging_add_dev_domain(struct platform_device *pdev,
>> +                                              const char *domain)
>> +{
>> +       return 0;
>> +}
>> +#endif
>> +
>>  int __init board_staging_register_device(const struct board_staging_dev *dev)
>>  {
>>         struct platform_device *pdev = dev->pdev;
>> @@ -161,7 +195,7 @@ int __init board_staging_register_device(const struct board_staging_dev *dev)
>>         }
>>
>>         if (dev->domain)
>> -               __pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
>> +               board_staging_add_dev_domain(pdev, dev->domain);
>>
>>         return error;
>>  }
>> --
>> 1.9.1

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH v2 5/7] staging: board: Add support for devices with complex dependencies
@ 2015-09-07 12:08               ` Geert Uytterhoeven
  0 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-09-07 12:08 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Geert Uytterhoeven, Greg Kroah-Hartman, Simon Horman,
	Magnus Damm, Arnd Bergmann, Laurent Pinchart, Kuninori Morimoto,
	Marc Zyngier, driverdevel, Linux-sh list, linux-pm, devicetree,
	linux-arm-kernel, linux-kernel

Hi Ulf,

On Mon, Sep 7, 2015 at 1:45 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> On 4 September 2015 at 17:03, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>> On Fri, 4 Sep 2015, Ulf Hansson wrote:
>>> On 3 September 2015 at 15:35, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>>> > On Thu, Sep 3, 2015 at 2:53 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>>> >> On 17 June 2015 at 10:38, Geert Uytterhoeven <geert+renesas@glider.be> wrote:
>>> >>> Add support for easy registering of one ore more platform devices that
>>> >>> may:
>>> >>>   - need clocks that are described in DT,
>>> >>>   - be part of a PM Domain.
>>> >
>>> >>> diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
>>> >>> index 8712f566b31196e0..29d456e29f38feac 100644
>>> >>> --- a/drivers/staging/board/board.c
>>> >>> +++ b/drivers/staging/board/board.c
>>> >
>>> >>> +int __init board_staging_register_device(const struct board_staging_dev *dev)
>>> >>> +{
>>> >>> +       struct platform_device *pdev = dev->pdev;
>>> >>> +       unsigned int i;
>>> >>> +       int error;
>>> >>> +
>>> >>> +       pr_debug("Trying to register device %s\n", pdev->name);
>>> >>> +       if (board_staging_dt_node_available(pdev->resource,
>>> >>> +                                           pdev->num_resources)) {
>>> >>> +               pr_warn("Skipping %s, already in DT\n", pdev->name);
>>> >>> +               return -EEXIST;
>>> >>> +       }
>>> >>> +
>>> >>> +       board_staging_gic_fixup_resources(pdev->resource, pdev->num_resources);
>>> >>> +
>>> >>> +       for (i = 0; i < dev->nclocks; i++)
>>> >>> +               board_staging_register_clock(&dev->clocks[i]);
>>> >>> +
>>> >>> +       error = platform_device_register(pdev);
>>> >>> +       if (error) {
>>> >>> +               pr_err("Failed to register device %s (%d)\n", pdev->name,
>>> >>> +                      error);
>>> >>> +               return error;
>>> >>> +       }
>>> >>> +
>>> >>> +       if (dev->domain)
>>> >>> +               __pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
>>> >>
>>> >> Urgh, this managed to slip through my filters.
>>> >>
>>> >> It seems like we almost managed to remove all users of the
>>> >> "..._name_add..." APIs for genpd. If hasn't been for $subject patch.
>>> >> :-)
>>> >>
>>> >> Now, I realize this is already too late here, but let's try to fix
>>> >> this before it turns into a bigger issue.
>>> >>
>>> >> Geert, do you think it's possible to convert into using the non-named
>>> >> bases APIs?
>>> >
>>> > That will be difficult. This code is meant to use drivers that are not yet
>>> > DT-aware on DT-based systems. Hence it uses platform devices with named PM
>>> > domains, while the PM domains are described in DT.
>>> > I don't think there's another way to look up a PM domain by name, is there?
>>>
>>> As a matter of fact there are, especially for those genpds that has
>>> been created through DT as in this case. The API to use is
>>> of_genpd_get_from_provider() to find the struct generic_pm_domain.
>>
>> Thanks!
>>
>>> Yes, I do realize that you need to manage the parsing of the domain
>>> name to make sure it's the one you want, but I would rather keep that
>>> "hack" in this driver than in the generic API.
>>
>> OK. It turned out not to be that complex, cfr. the patch below.
>> For now this supports PM domains with "#power-domain-cells = <0>" only,
>> but of course it can be extended if the need arises.
>>
>> I've also tried:
>>
>>     np = of_find_compatible_node(NULL, NULL, "renesas,sysc-rmobile");
>>     np = of_find_node_by_name(np, "a4lc");
>>
>> (the second step is needed because of the domain hierarchy in DT), but that
>> would require adding the compatible string to struct board_staging_dev,
>> and doesn't work if you have multiple identical power providers.
>>
>> I hope you like it?
>>
>> From 5fb11904845eb929a5b3382a9d5153c151cde1cf Mon Sep 17 00:00:00 2001
>> From: Geert Uytterhoeven <geert+renesas@glider.be>
>> Date: Fri, 4 Sep 2015 16:52:33 +0200
>> Subject: [PATCH/RFC] staging: board: Migrate away from
>>  __pm_genpd_name_add_device()
>>
>> The named genpd APIs are deprecated. Hence convert the board staging
>> code from using genpd names to DT node paths.
>>
>> For now this supports PM domains with "#power-domain-cells = <0>" only.
>>
>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
>
> Geert, thanks for posting this patch!
>
> I wonder whether we could get this sent for the 4.3 rc[n], since that
> would enable us to remove some of the named based API for genpd
> through Rafael's linux-pm tree during this release cycle.
>
> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>

Thanks!

If GregKH provides his ack, Rafael can take it with your named genpd API
removal series? Shall I resend with an official request?

> Kind regards
> Uffe
>
>> ---
>>  drivers/staging/board/armadillo800eva.c |  2 +-
>>  drivers/staging/board/board.c           | 36 ++++++++++++++++++++++++++++++++-
>>  2 files changed, 36 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/staging/board/armadillo800eva.c b/drivers/staging/board/armadillo800eva.c
>> index 0165591a52443c46..912c96b0536def7c 100644
>> --- a/drivers/staging/board/armadillo800eva.c
>> +++ b/drivers/staging/board/armadillo800eva.c
>> @@ -91,7 +91,7 @@ static const struct board_staging_dev armadillo800eva_devices[] __initconst = {
>>                 .pdev           = &lcdc0_device,
>>                 .clocks         = lcdc0_clocks,
>>                 .nclocks        = ARRAY_SIZE(lcdc0_clocks),
>> -               .domain         = "a4lc",
>> +               .domain         = "/system-controller@e6180000/pm-domains/c5/a4lc@1"
>>         },
>>  };
>>
>> diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
>> index 29d456e29f38feac..3eb5eb8f069c236d 100644
>> --- a/drivers/staging/board/board.c
>> +++ b/drivers/staging/board/board.c
>> @@ -135,6 +135,40 @@ int __init board_staging_register_clock(const struct board_staging_clk *bsc)
>>         return error;
>>  }
>>
>> +#ifdef CONFIG_PM_GENERIC_DOMAINS_OF
>> +static int board_staging_add_dev_domain(struct platform_device *pdev,
>> +                                       const char *domain)
>> +{
>> +       struct of_phandle_args pd_args;
>> +       struct generic_pm_domain *pd;
>> +       struct device_node *np;
>> +
>> +       np = of_find_node_by_path(domain);
>> +       if (!np) {
>> +               pr_err("Cannot find domain node %s\n", domain);
>> +               return -ENOENT;
>> +       }
>> +
>> +       pd_args.np = np;
>> +       pd_args.args_count = 0;
>> +       pd = of_genpd_get_from_provider(&pd_args);
>> +       if (IS_ERR(pd)) {
>> +               pr_err("Cannot find genpd %s (%ld)\n", domain, PTR_ERR(pd));
>> +               return PTR_ERR(pd);
>> +
>> +       }
>> +       pr_debug("Found genpd %s for device %s\n", pd->name, pdev->name);
>> +
>> +       return pm_genpd_add_device(pd, &pdev->dev);
>> +}
>> +#else
>> +static inline int board_staging_add_dev_domain(struct platform_device *pdev,
>> +                                              const char *domain)
>> +{
>> +       return 0;
>> +}
>> +#endif
>> +
>>  int __init board_staging_register_device(const struct board_staging_dev *dev)
>>  {
>>         struct platform_device *pdev = dev->pdev;
>> @@ -161,7 +195,7 @@ int __init board_staging_register_device(const struct board_staging_dev *dev)
>>         }
>>
>>         if (dev->domain)
>> -               __pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
>> +               board_staging_add_dev_domain(pdev, dev->domain);
>>
>>         return error;
>>  }
>> --
>> 1.9.1

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH v2 5/7] staging: board: Add support for devices with complex dependencies
@ 2015-09-07 12:08               ` Geert Uytterhoeven
  0 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-09-07 12:08 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Geert Uytterhoeven, Greg Kroah-Hartman, Simon Horman,
	Magnus Damm, Arnd Bergmann, Laurent Pinchart, Kuninori Morimoto,
	Marc Zyngier, driverdevel, Linux-sh list, linux-pm, devicetree,
	linux-arm-kernel, linux-kernel

Hi Ulf,

On Mon, Sep 7, 2015 at 1:45 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> On 4 September 2015 at 17:03, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>> On Fri, 4 Sep 2015, Ulf Hansson wrote:
>>> On 3 September 2015 at 15:35, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>>> > On Thu, Sep 3, 2015 at 2:53 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>>> >> On 17 June 2015 at 10:38, Geert Uytterhoeven <geert+renesas@glider.be> wrote:
>>> >>> Add support for easy registering of one ore more platform devices that
>>> >>> may:
>>> >>>   - need clocks that are described in DT,
>>> >>>   - be part of a PM Domain.
>>> >
>>> >>> diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
>>> >>> index 8712f566b31196e0..29d456e29f38feac 100644
>>> >>> --- a/drivers/staging/board/board.c
>>> >>> +++ b/drivers/staging/board/board.c
>>> >
>>> >>> +int __init board_staging_register_device(const struct board_staging_dev *dev)
>>> >>> +{
>>> >>> +       struct platform_device *pdev = dev->pdev;
>>> >>> +       unsigned int i;
>>> >>> +       int error;
>>> >>> +
>>> >>> +       pr_debug("Trying to register device %s\n", pdev->name);
>>> >>> +       if (board_staging_dt_node_available(pdev->resource,
>>> >>> +                                           pdev->num_resources)) {
>>> >>> +               pr_warn("Skipping %s, already in DT\n", pdev->name);
>>> >>> +               return -EEXIST;
>>> >>> +       }
>>> >>> +
>>> >>> +       board_staging_gic_fixup_resources(pdev->resource, pdev->num_resources);
>>> >>> +
>>> >>> +       for (i = 0; i < dev->nclocks; i++)
>>> >>> +               board_staging_register_clock(&dev->clocks[i]);
>>> >>> +
>>> >>> +       error = platform_device_register(pdev);
>>> >>> +       if (error) {
>>> >>> +               pr_err("Failed to register device %s (%d)\n", pdev->name,
>>> >>> +                      error);
>>> >>> +               return error;
>>> >>> +       }
>>> >>> +
>>> >>> +       if (dev->domain)
>>> >>> +               __pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
>>> >>
>>> >> Urgh, this managed to slip through my filters.
>>> >>
>>> >> It seems like we almost managed to remove all users of the
>>> >> "..._name_add..." APIs for genpd. If hasn't been for $subject patch.
>>> >> :-)
>>> >>
>>> >> Now, I realize this is already too late here, but let's try to fix
>>> >> this before it turns into a bigger issue.
>>> >>
>>> >> Geert, do you think it's possible to convert into using the non-named
>>> >> bases APIs?
>>> >
>>> > That will be difficult. This code is meant to use drivers that are not yet
>>> > DT-aware on DT-based systems. Hence it uses platform devices with named PM
>>> > domains, while the PM domains are described in DT.
>>> > I don't think there's another way to look up a PM domain by name, is there?
>>>
>>> As a matter of fact there are, especially for those genpds that has
>>> been created through DT as in this case. The API to use is
>>> of_genpd_get_from_provider() to find the struct generic_pm_domain.
>>
>> Thanks!
>>
>>> Yes, I do realize that you need to manage the parsing of the domain
>>> name to make sure it's the one you want, but I would rather keep that
>>> "hack" in this driver than in the generic API.
>>
>> OK. It turned out not to be that complex, cfr. the patch below.
>> For now this supports PM domains with "#power-domain-cells = <0>" only,
>> but of course it can be extended if the need arises.
>>
>> I've also tried:
>>
>>     np = of_find_compatible_node(NULL, NULL, "renesas,sysc-rmobile");
>>     np = of_find_node_by_name(np, "a4lc");
>>
>> (the second step is needed because of the domain hierarchy in DT), but that
>> would require adding the compatible string to struct board_staging_dev,
>> and doesn't work if you have multiple identical power providers.
>>
>> I hope you like it?
>>
>> From 5fb11904845eb929a5b3382a9d5153c151cde1cf Mon Sep 17 00:00:00 2001
>> From: Geert Uytterhoeven <geert+renesas@glider.be>
>> Date: Fri, 4 Sep 2015 16:52:33 +0200
>> Subject: [PATCH/RFC] staging: board: Migrate away from
>>  __pm_genpd_name_add_device()
>>
>> The named genpd APIs are deprecated. Hence convert the board staging
>> code from using genpd names to DT node paths.
>>
>> For now this supports PM domains with "#power-domain-cells = <0>" only.
>>
>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
>
> Geert, thanks for posting this patch!
>
> I wonder whether we could get this sent for the 4.3 rc[n], since that
> would enable us to remove some of the named based API for genpd
> through Rafael's linux-pm tree during this release cycle.
>
> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>

Thanks!

If GregKH provides his ack, Rafael can take it with your named genpd API
removal series? Shall I resend with an official request?

> Kind regards
> Uffe
>
>> ---
>>  drivers/staging/board/armadillo800eva.c |  2 +-
>>  drivers/staging/board/board.c           | 36 ++++++++++++++++++++++++++++++++-
>>  2 files changed, 36 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/staging/board/armadillo800eva.c b/drivers/staging/board/armadillo800eva.c
>> index 0165591a52443c46..912c96b0536def7c 100644
>> --- a/drivers/staging/board/armadillo800eva.c
>> +++ b/drivers/staging/board/armadillo800eva.c
>> @@ -91,7 +91,7 @@ static const struct board_staging_dev armadillo800eva_devices[] __initconst = {
>>                 .pdev           = &lcdc0_device,
>>                 .clocks         = lcdc0_clocks,
>>                 .nclocks        = ARRAY_SIZE(lcdc0_clocks),
>> -               .domain         = "a4lc",
>> +               .domain         = "/system-controller@e6180000/pm-domains/c5/a4lc@1"
>>         },
>>  };
>>
>> diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
>> index 29d456e29f38feac..3eb5eb8f069c236d 100644
>> --- a/drivers/staging/board/board.c
>> +++ b/drivers/staging/board/board.c
>> @@ -135,6 +135,40 @@ int __init board_staging_register_clock(const struct board_staging_clk *bsc)
>>         return error;
>>  }
>>
>> +#ifdef CONFIG_PM_GENERIC_DOMAINS_OF
>> +static int board_staging_add_dev_domain(struct platform_device *pdev,
>> +                                       const char *domain)
>> +{
>> +       struct of_phandle_args pd_args;
>> +       struct generic_pm_domain *pd;
>> +       struct device_node *np;
>> +
>> +       np = of_find_node_by_path(domain);
>> +       if (!np) {
>> +               pr_err("Cannot find domain node %s\n", domain);
>> +               return -ENOENT;
>> +       }
>> +
>> +       pd_args.np = np;
>> +       pd_args.args_count = 0;
>> +       pd = of_genpd_get_from_provider(&pd_args);
>> +       if (IS_ERR(pd)) {
>> +               pr_err("Cannot find genpd %s (%ld)\n", domain, PTR_ERR(pd));
>> +               return PTR_ERR(pd);
>> +
>> +       }
>> +       pr_debug("Found genpd %s for device %s\n", pd->name, pdev->name);
>> +
>> +       return pm_genpd_add_device(pd, &pdev->dev);
>> +}
>> +#else
>> +static inline int board_staging_add_dev_domain(struct platform_device *pdev,
>> +                                              const char *domain)
>> +{
>> +       return 0;
>> +}
>> +#endif
>> +
>>  int __init board_staging_register_device(const struct board_staging_dev *dev)
>>  {
>>         struct platform_device *pdev = dev->pdev;
>> @@ -161,7 +195,7 @@ int __init board_staging_register_device(const struct board_staging_dev *dev)
>>         }
>>
>>         if (dev->domain)
>> -               __pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
>> +               board_staging_add_dev_domain(pdev, dev->domain);
>>
>>         return error;
>>  }
>> --
>> 1.9.1

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* [PATCH v2 5/7] staging: board: Add support for devices with complex dependencies
@ 2015-09-07 12:08               ` Geert Uytterhoeven
  0 siblings, 0 replies; 61+ messages in thread
From: Geert Uytterhoeven @ 2015-09-07 12:08 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Ulf,

On Mon, Sep 7, 2015 at 1:45 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> On 4 September 2015 at 17:03, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>> On Fri, 4 Sep 2015, Ulf Hansson wrote:
>>> On 3 September 2015 at 15:35, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>>> > On Thu, Sep 3, 2015 at 2:53 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>>> >> On 17 June 2015 at 10:38, Geert Uytterhoeven <geert+renesas@glider.be> wrote:
>>> >>> Add support for easy registering of one ore more platform devices that
>>> >>> may:
>>> >>>   - need clocks that are described in DT,
>>> >>>   - be part of a PM Domain.
>>> >
>>> >>> diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
>>> >>> index 8712f566b31196e0..29d456e29f38feac 100644
>>> >>> --- a/drivers/staging/board/board.c
>>> >>> +++ b/drivers/staging/board/board.c
>>> >
>>> >>> +int __init board_staging_register_device(const struct board_staging_dev *dev)
>>> >>> +{
>>> >>> +       struct platform_device *pdev = dev->pdev;
>>> >>> +       unsigned int i;
>>> >>> +       int error;
>>> >>> +
>>> >>> +       pr_debug("Trying to register device %s\n", pdev->name);
>>> >>> +       if (board_staging_dt_node_available(pdev->resource,
>>> >>> +                                           pdev->num_resources)) {
>>> >>> +               pr_warn("Skipping %s, already in DT\n", pdev->name);
>>> >>> +               return -EEXIST;
>>> >>> +       }
>>> >>> +
>>> >>> +       board_staging_gic_fixup_resources(pdev->resource, pdev->num_resources);
>>> >>> +
>>> >>> +       for (i = 0; i < dev->nclocks; i++)
>>> >>> +               board_staging_register_clock(&dev->clocks[i]);
>>> >>> +
>>> >>> +       error = platform_device_register(pdev);
>>> >>> +       if (error) {
>>> >>> +               pr_err("Failed to register device %s (%d)\n", pdev->name,
>>> >>> +                      error);
>>> >>> +               return error;
>>> >>> +       }
>>> >>> +
>>> >>> +       if (dev->domain)
>>> >>> +               __pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
>>> >>
>>> >> Urgh, this managed to slip through my filters.
>>> >>
>>> >> It seems like we almost managed to remove all users of the
>>> >> "..._name_add..." APIs for genpd. If hasn't been for $subject patch.
>>> >> :-)
>>> >>
>>> >> Now, I realize this is already too late here, but let's try to fix
>>> >> this before it turns into a bigger issue.
>>> >>
>>> >> Geert, do you think it's possible to convert into using the non-named
>>> >> bases APIs?
>>> >
>>> > That will be difficult. This code is meant to use drivers that are not yet
>>> > DT-aware on DT-based systems. Hence it uses platform devices with named PM
>>> > domains, while the PM domains are described in DT.
>>> > I don't think there's another way to look up a PM domain by name, is there?
>>>
>>> As a matter of fact there are, especially for those genpds that has
>>> been created through DT as in this case. The API to use is
>>> of_genpd_get_from_provider() to find the struct generic_pm_domain.
>>
>> Thanks!
>>
>>> Yes, I do realize that you need to manage the parsing of the domain
>>> name to make sure it's the one you want, but I would rather keep that
>>> "hack" in this driver than in the generic API.
>>
>> OK. It turned out not to be that complex, cfr. the patch below.
>> For now this supports PM domains with "#power-domain-cells = <0>" only,
>> but of course it can be extended if the need arises.
>>
>> I've also tried:
>>
>>     np = of_find_compatible_node(NULL, NULL, "renesas,sysc-rmobile");
>>     np = of_find_node_by_name(np, "a4lc");
>>
>> (the second step is needed because of the domain hierarchy in DT), but that
>> would require adding the compatible string to struct board_staging_dev,
>> and doesn't work if you have multiple identical power providers.
>>
>> I hope you like it?
>>
>> From 5fb11904845eb929a5b3382a9d5153c151cde1cf Mon Sep 17 00:00:00 2001
>> From: Geert Uytterhoeven <geert+renesas@glider.be>
>> Date: Fri, 4 Sep 2015 16:52:33 +0200
>> Subject: [PATCH/RFC] staging: board: Migrate away from
>>  __pm_genpd_name_add_device()
>>
>> The named genpd APIs are deprecated. Hence convert the board staging
>> code from using genpd names to DT node paths.
>>
>> For now this supports PM domains with "#power-domain-cells = <0>" only.
>>
>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
>
> Geert, thanks for posting this patch!
>
> I wonder whether we could get this sent for the 4.3 rc[n], since that
> would enable us to remove some of the named based API for genpd
> through Rafael's linux-pm tree during this release cycle.
>
> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>

Thanks!

If GregKH provides his ack, Rafael can take it with your named genpd API
removal series? Shall I resend with an official request?

> Kind regards
> Uffe
>
>> ---
>>  drivers/staging/board/armadillo800eva.c |  2 +-
>>  drivers/staging/board/board.c           | 36 ++++++++++++++++++++++++++++++++-
>>  2 files changed, 36 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/staging/board/armadillo800eva.c b/drivers/staging/board/armadillo800eva.c
>> index 0165591a52443c46..912c96b0536def7c 100644
>> --- a/drivers/staging/board/armadillo800eva.c
>> +++ b/drivers/staging/board/armadillo800eva.c
>> @@ -91,7 +91,7 @@ static const struct board_staging_dev armadillo800eva_devices[] __initconst = {
>>                 .pdev           = &lcdc0_device,
>>                 .clocks         = lcdc0_clocks,
>>                 .nclocks        = ARRAY_SIZE(lcdc0_clocks),
>> -               .domain         = "a4lc",
>> +               .domain         = "/system-controller at e6180000/pm-domains/c5/a4lc at 1"
>>         },
>>  };
>>
>> diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
>> index 29d456e29f38feac..3eb5eb8f069c236d 100644
>> --- a/drivers/staging/board/board.c
>> +++ b/drivers/staging/board/board.c
>> @@ -135,6 +135,40 @@ int __init board_staging_register_clock(const struct board_staging_clk *bsc)
>>         return error;
>>  }
>>
>> +#ifdef CONFIG_PM_GENERIC_DOMAINS_OF
>> +static int board_staging_add_dev_domain(struct platform_device *pdev,
>> +                                       const char *domain)
>> +{
>> +       struct of_phandle_args pd_args;
>> +       struct generic_pm_domain *pd;
>> +       struct device_node *np;
>> +
>> +       np = of_find_node_by_path(domain);
>> +       if (!np) {
>> +               pr_err("Cannot find domain node %s\n", domain);
>> +               return -ENOENT;
>> +       }
>> +
>> +       pd_args.np = np;
>> +       pd_args.args_count = 0;
>> +       pd = of_genpd_get_from_provider(&pd_args);
>> +       if (IS_ERR(pd)) {
>> +               pr_err("Cannot find genpd %s (%ld)\n", domain, PTR_ERR(pd));
>> +               return PTR_ERR(pd);
>> +
>> +       }
>> +       pr_debug("Found genpd %s for device %s\n", pd->name, pdev->name);
>> +
>> +       return pm_genpd_add_device(pd, &pdev->dev);
>> +}
>> +#else
>> +static inline int board_staging_add_dev_domain(struct platform_device *pdev,
>> +                                              const char *domain)
>> +{
>> +       return 0;
>> +}
>> +#endif
>> +
>>  int __init board_staging_register_device(const struct board_staging_dev *dev)
>>  {
>>         struct platform_device *pdev = dev->pdev;
>> @@ -161,7 +195,7 @@ int __init board_staging_register_device(const struct board_staging_dev *dev)
>>         }
>>
>>         if (dev->domain)
>> -               __pm_genpd_name_add_device(dev->domain, &pdev->dev, NULL);
>> +               board_staging_add_dev_domain(pdev, dev->domain);
>>
>>         return error;
>>  }
>> --
>> 1.9.1

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

end of thread, other threads:[~2015-09-07 12:08 UTC | newest]

Thread overview: 61+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-17  8:38 [PATCH v2 0/7] staging: board: armadillo800eva: Board staging for sh_mobile_lcdc_fb Geert Uytterhoeven
2015-06-17  8:38 ` Geert Uytterhoeven
2015-06-17  8:38 ` Geert Uytterhoeven
2015-06-17  8:38 ` Geert Uytterhoeven
2015-06-17  8:38 ` [PATCH v2 1/7] Revert "staging: board: disable as it breaks the build" Geert Uytterhoeven
2015-06-17  8:38   ` Geert Uytterhoeven
2015-06-17  8:38   ` Geert Uytterhoeven
2015-06-17  8:38 ` [PATCH v2 2/7] staging: board: Initialize staging board code earlier Geert Uytterhoeven
2015-06-17  8:38   ` Geert Uytterhoeven
2015-06-17  8:38   ` Geert Uytterhoeven
2015-06-17  8:38   ` Geert Uytterhoeven
2015-06-17  8:38 ` [PATCH v2 3/7] staging: board: Add support for translating hwirq to virq numbers Geert Uytterhoeven
2015-06-17  8:38   ` Geert Uytterhoeven
2015-06-17  8:38   ` Geert Uytterhoeven
2015-06-17  8:38   ` Geert Uytterhoeven
2015-06-17  8:38 ` [PATCH v2 4/7] staging: board: kzm9d: Translate hwirq numbers " Geert Uytterhoeven
2015-06-17  8:38   ` Geert Uytterhoeven
2015-06-17  8:38   ` Geert Uytterhoeven
2015-06-17  8:38   ` Geert Uytterhoeven
2015-06-17  8:38 ` [PATCH v2 5/7] staging: board: Add support for devices with complex dependencies Geert Uytterhoeven
2015-06-17  8:38   ` Geert Uytterhoeven
2015-06-17  8:38   ` Geert Uytterhoeven
2015-06-17  8:38   ` Geert Uytterhoeven
2015-09-03 12:53   ` Ulf Hansson
2015-09-03 12:53     ` Ulf Hansson
2015-09-03 12:53     ` Ulf Hansson
2015-09-03 12:53     ` Ulf Hansson
2015-09-03 13:35     ` Geert Uytterhoeven
2015-09-03 13:35       ` Geert Uytterhoeven
2015-09-03 13:35       ` Geert Uytterhoeven
2015-09-03 13:35       ` Geert Uytterhoeven
2015-09-04  8:30       ` Ulf Hansson
2015-09-04  8:30         ` Ulf Hansson
2015-09-04  8:30         ` Ulf Hansson
2015-09-04  8:30         ` Ulf Hansson
2015-09-04 15:03         ` Geert Uytterhoeven
2015-09-04 15:03           ` Geert Uytterhoeven
2015-09-04 15:03           ` Geert Uytterhoeven
2015-09-04 15:03           ` Geert Uytterhoeven
2015-09-07 11:45           ` Ulf Hansson
2015-09-07 11:45             ` Ulf Hansson
2015-09-07 11:45             ` Ulf Hansson
2015-09-07 11:45             ` Ulf Hansson
2015-09-07 12:08             ` Geert Uytterhoeven
2015-09-07 12:08               ` Geert Uytterhoeven
2015-09-07 12:08               ` Geert Uytterhoeven
2015-09-07 12:08               ` Geert Uytterhoeven
2015-06-17  8:38 ` [PATCH v2 6/7] staging: board: armadillo800eva: Board staging for sh_mobile_lcdc_fb Geert Uytterhoeven
2015-06-17  8:38   ` Geert Uytterhoeven
2015-06-17  8:38   ` Geert Uytterhoeven
2015-06-17  8:38   ` Geert Uytterhoeven
2015-06-17  8:38 ` [PATCH v2 7/7] ARM: shmobile: armadillo800eva dts: Add pinctrl and gpio-hog for lcdc0 Geert Uytterhoeven
2015-06-17  8:38   ` Geert Uytterhoeven
2015-06-17  8:38   ` Geert Uytterhoeven
2015-06-17  8:38   ` Geert Uytterhoeven
2015-06-19  0:27   ` Simon Horman
2015-06-19  0:27     ` Simon Horman
2015-06-19  0:27     ` Simon Horman
2015-06-18  4:08 ` [PATCH v2 0/7] staging: board: armadillo800eva: Board staging for sh_mobile_lcdc_fb Simon Horman
2015-06-18  4:08   ` Simon Horman
2015-06-18  4:08   ` Simon Horman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.