[PATCH] staging/ks7010: formatting updates.

2017-02-20 Thread Matthew Giassa
Please pardon the earlier e-mail which was missing the changelog text.

Wrapping complex macros with parentheses to remove checkpatch errors.
Some additional style changes to appease checkpatch.

---
 drivers/staging/ks7010/ks_wlan_ioctl.h | 80 +-
 1 file changed, 41 insertions(+), 39 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan_ioctl.h 
b/drivers/staging/ks7010/ks_wlan_ioctl.h
index 84554b6..00eec18 100644
--- a/drivers/staging/ks7010/ks_wlan_ioctl.h
+++ b/drivers/staging/ks7010/ks_wlan_ioctl.h
@@ -1,6 +1,6 @@
 /*
  *   Driver for KeyStream 11b/g wireless LAN
- *   
+ *
  *   Copyright (c) 2005-2008 KeyStream Corp.
  *   Copyright (C) 2009 Renesas Technology Corp.
  *
@@ -8,60 +8,62 @@
  *   it under the terms of the GNU General Public License version 2 as
  *   published by the Free Software Foundation.
  */
-
 #ifndef _KS_WLAN_IOCTL_H
 #define _KS_WLAN_IOCTL_H
 
 #include 
-/* The low order bit identify a SET (0) or a GET (1) ioctl.  */
+/* The low order bit identify a SET (0) or a GET (1) ioctl. */
 
-/* SIOCIWFIRSTPRIV+0 */
-/* former KS_WLAN_GET_DRIVER_VERSION   SIOCIWFIRSTPRIV+1 */
-/* SIOCIWFIRSTPRIV+2 */
-#define KS_WLAN_GET_FIRM_VERSION   SIOCIWFIRSTPRIV+3
+/* (SIOCIWFIRSTPRIV + 0) */
+/* Former KS_WLAN_GET_DRIVER_VERSION   (SIOCIWFIRSTPRIV + 1) */
+/* (SIOCIWFIRSTPRIV + 2) */
+#define KS_WLAN_GET_FIRM_VERSION   (SIOCIWFIRSTPRIV + 3)
 #ifdef WPS
-#define KS_WLAN_SET_WPS_ENABLE SIOCIWFIRSTPRIV+4
-#define KS_WLAN_GET_WPS_ENABLE SIOCIWFIRSTPRIV+5
-#define KS_WLAN_SET_WPS_PROBE_REQ  SIOCIWFIRSTPRIV+6
+#define KS_WLAN_SET_WPS_ENABLE (SIOCIWFIRSTPRIV + 4)
+#define KS_WLAN_GET_WPS_ENABLE (SIOCIWFIRSTPRIV + 5)
+#define KS_WLAN_SET_WPS_PROBE_REQ  (SIOCIWFIRSTPRIV + 6)
 #endif
-#define KS_WLAN_GET_EEPROM_CKSUM   SIOCIWFIRSTPRIV+7
-#define KS_WLAN_SET_PREAMBLE   SIOCIWFIRSTPRIV+8
-#define KS_WLAN_GET_PREAMBLE   SIOCIWFIRSTPRIV+9
-#define KS_WLAN_SET_POWER_SAVE SIOCIWFIRSTPRIV+10
-#define KS_WLAN_GET_POWER_SAVE SIOCIWFIRSTPRIV+11
-#define KS_WLAN_SET_SCAN_TYPE  SIOCIWFIRSTPRIV+12
-#define KS_WLAN_GET_SCAN_TYPE  SIOCIWFIRSTPRIV+13
-#define KS_WLAN_SET_RX_GAINSIOCIWFIRSTPRIV+14
-#define KS_WLAN_GET_RX_GAINSIOCIWFIRSTPRIV+15
-#define KS_WLAN_HOSTT  SIOCIWFIRSTPRIV+16  /* unused */
-//#define KS_WLAN_SET_REGIONSIOCIWFIRSTPRIV+17
-#define KS_WLAN_SET_BEACON_LOSTSIOCIWFIRSTPRIV+18
-#define KS_WLAN_GET_BEACON_LOSTSIOCIWFIRSTPRIV+19
+#define KS_WLAN_GET_EEPROM_CKSUM   (SIOCIWFIRSTPRIV + 7)
+#define KS_WLAN_SET_PREAMBLE   (SIOCIWFIRSTPRIV + 8)
+#define KS_WLAN_GET_PREAMBLE   (SIOCIWFIRSTPRIV + 9)
+#define KS_WLAN_SET_POWER_SAVE (SIOCIWFIRSTPRIV + 10)
+#define KS_WLAN_GET_POWER_SAVE (SIOCIWFIRSTPRIV + 11)
+#define KS_WLAN_SET_SCAN_TYPE  (SIOCIWFIRSTPRIV + 12)
+#define KS_WLAN_GET_SCAN_TYPE  (SIOCIWFIRSTPRIV + 13)
+#define KS_WLAN_SET_RX_GAIN(SIOCIWFIRSTPRIV + 14)
+#define KS_WLAN_GET_RX_GAIN(SIOCIWFIRSTPRIV + 15)
+#define KS_WLAN_HOSTT  (SIOCIWFIRSTPRIV + 16)  /* unused */
+/*#define KS_WLAN_SET_REGION(SIOCIWFIRSTPRIV + 17) */
+#define KS_WLAN_SET_BEACON_LOST(SIOCIWFIRSTPRIV + 18)
+#define KS_WLAN_GET_BEACON_LOST(SIOCIWFIRSTPRIV + 19)
 
-#define KS_WLAN_SET_TX_GAINSIOCIWFIRSTPRIV+20
-#define KS_WLAN_GET_TX_GAINSIOCIWFIRSTPRIV+21
+#define KS_WLAN_SET_TX_GAIN(SIOCIWFIRSTPRIV + 20)
+#define KS_WLAN_GET_TX_GAIN(SIOCIWFIRSTPRIV + 21)
 
-/* for KS7010 */
-#define KS_WLAN_SET_PHY_TYPE   SIOCIWFIRSTPRIV+22
-#define KS_WLAN_GET_PHY_TYPE   SIOCIWFIRSTPRIV+23
-#define KS_WLAN_SET_CTS_MODE   SIOCIWFIRSTPRIV+24
-#define KS_WLAN_GET_CTS_MODE   SIOCIWFIRSTPRIV+25
-/* SIOCIWFIRSTPRIV+26 */
-/* SIOCIWFIRSTPRIV+27 */
-#define KS_WLAN_SET_SLEEP_MODE SIOCIWFIRSTPRIV+28  /* sleep mode */
-#define KS_WLAN_GET_SLEEP_MODE SIOCIWFIRSTPRIV+29  /* sleep mode */
-/* SIOCIWFIRSTPRIV+30 */
-/* SIOCIWFIRSTPRIV+31 */
+/* For KS7010. */
+#define KS_WLAN_SET_PHY_TYPE   (SIOCIWFIRSTPRIV + 22)
+#define KS_WLAN_GET_PHY_TYPE   (SIOCIWFIRSTPRIV + 23)
+#define KS_WLAN_SET_CTS_MODE   (SIOCIWFIRSTPRIV + 24)
+#define KS_WLAN_GET_CTS_MODE   (SIOCIWFIRSTPRIV + 25)
+/* (SIOCIWFIRSTPRIV + 26) */
+/* (SIOCIWFIRSTPRIV + 27) */
+#define KS_WLAN_SET_SLEEP_MODE (SIOCIWFIRSTPRIV + 28)  /* sleep 

Re: [PATCH v2 0/3] r8a7793 Gose video input support

2017-02-20 Thread Laurent Pinchart
Hi Ulrich,

On Thursday 20 Oct 2016 10:49:11 Simon Horman wrote:
> On Tue, Oct 18, 2016 at 05:02:20PM +0200, Ulrich Hecht wrote:
> > Hi!
> > 
> > This is a by-the-datasheet implementation of analog and digital video
> > input on the Gose board.
> > 
> > I have tried to address all concerns raised by reviewers, with the
> > exception of the composite input patch, which has been left as is for
> > now.
> > 
> > CU
> > Uli
> > 
> > 
> > Changes since v1:
> > - r8a7793.dtsi: added VIN2
> > - modeled HDMI decoder input/output and connector
> > - added "renesas,rcar-gen2-vin" compat strings
> > - removed unnecessary "remote" node and aliases
> > - set ADV7612 interrupt to GP4_2
> > 
> > Ulrich Hecht (3):
> >   ARM: dts: r8a7793: Enable VIN0-VIN2
> 
> I have queued up the above patch with Laurent and Geert's tags.
> 
> >   ARM: dts: gose: add HDMI input
> >   ARM: dts: gose: add composite video input
> 
> Please address the review of the above two patches and repost.

Could you please do so ? Feedback on 2/3 should be easy to handle. For 3/3, 
you might need to ping the DT maintainers.

> >  arch/arm/boot/dts/r8a7793-gose.dts | 100 +++
> >  arch/arm/boot/dts/r8a7793.dtsi |  27 ++
> >  2 files changed, 127 insertions(+)

-- 
Regards,

Laurent Pinchart



[PATCH] arm64: dts: r8a7796: add IMR-LX4 support

2017-02-20 Thread Sergei Shtylyov
Describe the IMR-LX4 devices in the R8A7796 device tree.

Signed-off-by: Sergei Shtylyov 

---
This patch is against the 'renesas-devel-20170217-v4.10-rc8' tag of Simon
Horman's 'renesas.git' repo.

The IMR-LX4 binding was documented in the IMR driver patch; I don't expect it
to  change  even if the driver  would be  rewritten  for DRM...

 arch/arm64/boot/dts/renesas/r8a7796.dtsi |   16 
 1 file changed, 16 insertions(+)

Index: renesas/arch/arm64/boot/dts/renesas/r8a7796.dtsi
===
--- renesas.orig/arch/arm64/boot/dts/renesas/r8a7796.dtsi
+++ renesas/arch/arm64/boot/dts/renesas/r8a7796.dtsi
@@ -904,5 +904,21 @@
};
};
};
+
+   imr-lx4@fe86 {
+   compatible = "renesas,imr-lx4";
+   reg = <0 0xfe86 0 0x2000>;
+   interrupts = ;
+   clocks = < CPG_MOD 823>;
+   power-domains = < R8A7796_PD_A3VC>;
+   };
+
+   imr-lx4@fe87 {
+   compatible = "renesas,imr-lx4";
+   reg = <0 0xfe87 0 0x2000>;
+   interrupts = ;
+   clocks = < CPG_MOD 822>;
+   power-domains = < R8A7796_PD_A3VC>;
+   };
};
 };



[PATCH] ASoC: rsnd: check return value of init function

2017-02-20 Thread Wolfram Sang
Currently, this function cannot fail for the ADG case. Still, let's
apply defensive programming techniques to make sure we fail gracefully
whenever rsnd_mod_init() gets extended with another failure case.
Reported by Coverity (CID 1397893).

Signed-off-by: Wolfram Sang 
---
 sound/soc/sh/rcar/adg.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sound/soc/sh/rcar/adg.c b/sound/soc/sh/rcar/adg.c
index 85a33ac0a5c443..54146f66538c18 100644
--- a/sound/soc/sh/rcar/adg.c
+++ b/sound/soc/sh/rcar/adg.c
@@ -564,6 +564,7 @@ int rsnd_adg_probe(struct rsnd_priv *priv)
struct rsnd_adg *adg;
struct device *dev = rsnd_priv_to_dev(priv);
struct device_node *np = dev->of_node;
+   int ret;
 
adg = devm_kzalloc(dev, sizeof(*adg), GFP_KERNEL);
if (!adg) {
@@ -571,8 +572,10 @@ int rsnd_adg_probe(struct rsnd_priv *priv)
return -ENOMEM;
}
 
-   rsnd_mod_init(priv, >mod, _ops,
+   ret = rsnd_mod_init(priv, >mod, _ops,
  NULL, NULL, 0, 0);
+   if (ret)
+   return ret;
 
rsnd_adg_get_clkin(priv, adg);
rsnd_adg_get_clkout(priv, adg);
-- 
2.11.0



[PATCH] ASoC: rsnd: drop useles self-assignments

2017-02-20 Thread Wolfram Sang
Coverity reported (CID 1397992) this self-assignment. I think the code
stays readable even with the assignments removed.

Signed-off-by: Wolfram Sang 
---
 sound/soc/sh/rcar/core.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
index 47b370cb2d3b3a..24adb3cc17aa63 100644
--- a/sound/soc/sh/rcar/core.c
+++ b/sound/soc/sh/rcar/core.c
@@ -674,12 +674,10 @@ static int rsnd_soc_dai_set_fmt(struct snd_soc_dai *dai, 
unsigned int fmt)
/* set clock inversion */
switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
case SND_SOC_DAIFMT_NB_IF:
-   rdai->bit_clk_inv =  rdai->bit_clk_inv;
rdai->frm_clk_inv = !rdai->frm_clk_inv;
break;
case SND_SOC_DAIFMT_IB_NF:
rdai->bit_clk_inv = !rdai->bit_clk_inv;
-   rdai->frm_clk_inv =  rdai->frm_clk_inv;
break;
case SND_SOC_DAIFMT_IB_IF:
rdai->bit_clk_inv = !rdai->bit_clk_inv;
-- 
2.11.0



Re: [PATCHv2 2/5] scripts: Provide bin2png.sh helper

2017-02-20 Thread Geert Uytterhoeven
Hi Kieran,

On Mon, Feb 20, 2017 at 6:47 PM, Kieran Bingham
 wrote:
> This change breaks POSIX SH compliance, as reported by shellcheck:
>
> In scripts/bin2png.sh line 7:
> local pnm=${file/%bin/pnm}
>   ^-- SC2039: In POSIX sh, string replacement is not 
> supported.
>
>
> In scripts/bin2png.sh line 8:
> local png=${file/%bin/png}
>   ^-- SC2039: In POSIX sh, string replacement is not 
> supported.
>
> It also breaks on my system which uses a strict posix compliant shell :D

Does "local pnm=${file%bin}pnm" work?

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@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


[PATCH/RFC 5/6] arm64: dts: r8a7795: Fix non-PMIC wake-up sources

2017-02-20 Thread Geert Uytterhoeven
The PSCI firmware on boards equipped with an R-Car H3 SoC implements the
PSCI SYSTEM_SUSPEND operation by cutting power to the SoC.  Hence the
only possibly wake-up sources are the ones connected to the PMIC, unless
the "arm,psci-system-suspend-is-power-down" property is specified.

Signed-off-by: Geert Uytterhoeven 
---
 arch/arm64/boot/dts/renesas/r8a7795.dtsi | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/boot/dts/renesas/r8a7795.dtsi 
b/arch/arm64/boot/dts/renesas/r8a7795.dtsi
index f05a9c4dd3b60c82..cf43e9c7cab224b2 100644
--- a/arch/arm64/boot/dts/renesas/r8a7795.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a7795.dtsi
@@ -31,6 +31,7 @@
psci {
compatible = "arm,psci-0.2";
method = "smc";
+   arm,psci-system-suspend-is-power-down;
};
 
cpus {
-- 
2.7.4



[PATCH/RFC 0/6] PSCI: Fix non-PMIC wake-up if SYSTEM_SUSPEND cuts power

2017-02-20 Thread Geert Uytterhoeven
Hi all,

This patch series adds support for using non-PMIC wake-up sources on the
Renesas R-Car Gen3 (H3 or M3-W) Salvator-X development boards.

Nothing in the PSCI specification requires the SoC to remain powered and
to support wake-up sources when suspended using SYSTEM_SUSPEND.
If the firmware implements the PSCI SYSTEM_SUSPEND operation by cutting
power to the SoC, the only possibly wake-up sources are thus the ones
connected to the PMIC.

To allow other wake-up sources, this patch series documents and adds
support for an "arm,psci-system-suspend-is-power-down" DT property, so
Linux uses a different suspend method when other wake-up sources (e.g.
wake on LAN, UART or GPIO) are enabled.  Hence the user no longer has to
manually restrict "mem" suspend to "s2idle" or "shallow" states using:

$ echo s2idle > /sys/power/mem_sleep # or "shallow"

Contents:
  - Patch 1 prevents the alarmtimer from showing up as a wake-up source
when no wake-up capable RTC device is present in the system,
  - Patch 2 provides an API to check if any wake-up sources have been
registered,
  - Patch 3 implements "shallow" suspend mode on systems using PSCI,
in addition to the existing "s2idle" and "deep" suspend modes,
  - Patch 4 makes the system use "shallow" instead of "deep" suspend
mode on systems where this is needed to support non-PMIC wake-up
sources,
  - Patches 5 and 6 enable the above on Renesas R-Car H3 and M3-W
systems.

Dependencies:
  - The three first patches are independent,
  - The fourth patch depends on the first three patches,
  - The DTS patches depend on acceptance of the DT bindings in patch 4.

This has been tested on both the Renesas R-Car H3 (quad A57*)
and M3-W (dual A57*) Salvator-X development boards
(*A53 cores are unused).

Power consumption:

H3  M3-W
--  
  - idle:   9.2 W   7.6 W
  - s2idle: 8.6 W   6.3 W
  - shallow:8.4 W   6.2 W   (secondary CPU cores off)
  - deep:   1.4 W   1.2 W   (PSCI_SYSTEM_SUSPEND)
  - shutdown:   7.7 W   5.6 W   (PSCI SYSTEM_OFF: needs improvement)
  - poweroff:   1.3 W   1.1 W   (fan running)

Thanks for your comments!

Geert Uytterhoeven (6):
  alarmtimer: Postpone wake-up source registration until really
available
  PM / Wakeup: Add wakeup_source_available()
  drivers: firmware: psci: Implement shallow suspend mode
  drivers: firmware: psci: Fix non-PMIC wake-up if SYSTEM_SUSPEND cuts
power
  arm64: dts: r8a7795: Fix non-PMIC wake-up sources
  arm64: dts: r8a7796: Fix non-PMIC wake-up sources

 Documentation/devicetree/bindings/arm/psci.txt | 11 
 arch/arm64/boot/dts/renesas/r8a7795.dtsi   |  1 +
 arch/arm64/boot/dts/renesas/r8a7796.dtsi   |  1 +
 drivers/base/power/wakeup.c|  8 ++
 drivers/firmware/psci.c| 39 --
 include/linux/pm_wakeup.h  |  3 ++
 kernel/time/alarmtimer.c   |  9 +-
 7 files changed, 68 insertions(+), 4 deletions(-)

-- 
2.7.4

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@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


[PATCH/RFC 1/6] alarmtimer: Postpone wake-up source registration until really available

2017-02-20 Thread Geert Uytterhoeven
Currently the alarmtimer registers a wake-up source unconditionally,
regardless of the system having a (wake-up capable) RTC or not.
To fix this, postpone registration until a wake-up capable RTC device is
added.

After this, the alarmtimer no longer shows up in
/sys/kernel/debug/wakeup_sources, unless it is available for real.

Signed-off-by: Geert Uytterhoeven 
---
 kernel/time/alarmtimer.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index e6dc9a538efa2116..5e0ce78607da5b5d 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -82,6 +82,7 @@ static int alarmtimer_rtc_add_device(struct device *dev,
 {
unsigned long flags;
struct rtc_device *rtc = to_rtc_device(dev);
+   struct wakeup_source *__ws;
 
if (rtcdev)
return -EBUSY;
@@ -91,13 +92,20 @@ static int alarmtimer_rtc_add_device(struct device *dev,
if (!device_may_wakeup(rtc->dev.parent))
return -1;
 
+   __ws = wakeup_source_register("alarmtimer");
+
spin_lock_irqsave(_lock, flags);
if (!rtcdev) {
rtcdev = rtc;
/* hold a reference so it doesn't go away */
get_device(dev);
+   ws = __ws;
+   __ws = NULL;
}
spin_unlock_irqrestore(_lock, flags);
+
+   wakeup_source_unregister(__ws);
+
return 0;
 }
 
@@ -908,7 +916,6 @@ static int __init alarmtimer_init(void)
error = PTR_ERR(pdev);
goto out_drv;
}
-   ws = wakeup_source_register("alarmtimer");
return 0;
 
 out_drv:
-- 
2.7.4



[PATCH/RFC 3/6] drivers: firmware: psci: Implement shallow suspend mode

2017-02-20 Thread Geert Uytterhoeven
Enable support for "shallow" suspend mode, also known as "Standby" or
"Power-On Suspend".

As secondary CPU cores are taken offline, "shallow" suspend mode saves
slightly more power than "s2idle", but less than "deep" suspend mode.
However, unlike "deep" suspend mode, "shallow" suspend mode can be used
regardless of the presence of support for PSCI_SYSTEM_SUSPEND, which is
an optional API in PSCI v1.0.

List the available system suspend modes:

$ cat /sys/power/mem_sleep
s2idle shallow [deep]

Suspend to "shallow" mode:

$ echo shallow > /sys/power/mem_sleep
$ echo mem > /sys/power/state

Signed-off-by: Geert Uytterhoeven 
---
 drivers/firmware/psci.c | 32 +---
 1 file changed, 29 insertions(+), 3 deletions(-)

diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c
index 493a56a4cfc4a836..13b4d50bb3577384 100644
--- a/drivers/firmware/psci.c
+++ b/drivers/firmware/psci.c
@@ -85,6 +85,7 @@ static u32 psci_function_id[PSCI_FN_MAX];
PSCI_1_0_EXT_POWER_STATE_TYPE_MASK)
 
 static u32 psci_cpu_suspend_feature;
+static bool psci_suspend_mem_supported;
 
 static inline bool psci_has_ext_power_state(void)
 {
@@ -422,13 +423,36 @@ static int psci_system_suspend(unsigned long unused)
  __pa_symbol(cpu_resume), 0, 0);
 }
 
+static int psci_system_suspend_valid(suspend_state_t state)
+{
+   switch (state) {
+   case PM_SUSPEND_STANDBY:
+   return true;
+
+   case PM_SUSPEND_MEM:
+   return psci_suspend_mem_supported;
+
+   default:
+   return false;
+   }
+}
+
 static int psci_system_suspend_enter(suspend_state_t state)
 {
-   return cpu_suspend(0, psci_system_suspend);
+   switch (state) {
+   case PM_SUSPEND_STANDBY:
+   cpu_do_idle();
+   break;
+
+   case PM_SUSPEND_MEM:
+   return cpu_suspend(0, psci_system_suspend);
+   }
+
+   return 0;
 }
 
 static const struct platform_suspend_ops psci_suspend_ops = {
-   .valid  = suspend_valid_only_mem,
+   .valid  = psci_system_suspend_valid,
.enter  = psci_system_suspend_enter,
 };
 
@@ -442,7 +466,9 @@ static void __init psci_init_system_suspend(void)
ret = psci_features(PSCI_FN_NATIVE(1_0, SYSTEM_SUSPEND));
 
if (ret != PSCI_RET_NOT_SUPPORTED)
-   suspend_set_ops(_suspend_ops);
+   psci_suspend_mem_supported = true;
+
+   suspend_set_ops(_suspend_ops);
 }
 
 static void __init psci_init_cpu_suspend(void)
-- 
2.7.4



[PATCH/RFC 4/6] drivers: firmware: psci: Fix non-PMIC wake-up if SYSTEM_SUSPEND cuts power

2017-02-20 Thread Geert Uytterhoeven
Nothing in the PSCI specification requires the SoC to remain powered and
to support wake-up sources when suspended using SYSTEM_SUSPEND.
If the firmware implements the PSCI SYSTEM_SUSPEND operation by cutting
power to the SoC, the only possibly wake-up sources are thus the ones
connected to the PMIC.

Document and add support for an "arm,psci-system-suspend-is-power-down"
DT property, so Linux uses a different suspend method when other wake-up
sources (e.g. wake on LAN, UART or GPIO) are enabled.

Signed-off-by: Geert Uytterhoeven 
---
 Documentation/devicetree/bindings/arm/psci.txt | 11 +++
 drivers/firmware/psci.c| 13 ++---
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/arm/psci.txt 
b/Documentation/devicetree/bindings/arm/psci.txt
index a2c4f1d524929bb7..16e390ecb7531028 100644
--- a/Documentation/devicetree/bindings/arm/psci.txt
+++ b/Documentation/devicetree/bindings/arm/psci.txt
@@ -68,6 +68,17 @@ state nodes, as per bindings in [1]) must specify the 
following properties:
Definition: power_state parameter to pass to the PSCI
suspend call.
 
+ - arm,psci-system-suspend-is-power-down
+   Nothing in the PSCI specification requires the SoC to remain
+   powered and to support wake-up sources when suspended using
+   SYSTEM_SUSPEND.
+   If your firmware implements the PSCI SYSTEM_SUSPEND operation
+   by cutting power to the SoC, the only possibly wake-up sources
+   are thus the ones connected to the PMIC.  In such case you
+   should specify this property, so the operating system is aware
+   it should use a different suspend method when other wake-up
+   sources (e.g. wake on LAN, UART or GPIO) are enabled.
+
 Example:
 
 Case 1: PSCI v0.1 only.
diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c
index 13b4d50bb3577384..0a74c23fd5fe043e 100644
--- a/drivers/firmware/psci.c
+++ b/drivers/firmware/psci.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -86,6 +87,7 @@ static u32 psci_function_id[PSCI_FN_MAX];
 
 static u32 psci_cpu_suspend_feature;
 static bool psci_suspend_mem_supported;
+static bool psci_system_suspend_is_power_down;
 
 static inline bool psci_has_ext_power_state(void)
 {
@@ -440,12 +442,14 @@ static int psci_system_suspend_valid(suspend_state_t 
state)
 static int psci_system_suspend_enter(suspend_state_t state)
 {
switch (state) {
+   case PM_SUSPEND_MEM:
+   if (!psci_system_suspend_is_power_down ||
+   !wakeup_source_available())
+   return cpu_suspend(0, psci_system_suspend);
+   /* fall through */
case PM_SUSPEND_STANDBY:
cpu_do_idle();
break;
-
-   case PM_SUSPEND_MEM:
-   return cpu_suspend(0, psci_system_suspend);
}
 
return 0;
@@ -596,6 +600,9 @@ static int __init psci_0_2_init(struct device_node *np)
 */
err = psci_probe();
 
+   psci_system_suspend_is_power_down = of_property_read_bool(np,
+   "arm,psci-system-suspend-is-power-down");
+
 out_put_node:
of_node_put(np);
return err;
-- 
2.7.4



[PATCH/RFC 6/6] arm64: dts: r8a7796: Fix non-PMIC wake-up sources

2017-02-20 Thread Geert Uytterhoeven
The PSCI firmware on boards equipped with an R-Car M3-W SoC implements
the PSCI SYSTEM_SUSPEND operation by cutting power to the SoC.  Hence
the only possibly wake-up sources are the ones connected to the PMIC,
unless the "arm,psci-system-suspend-is-power-down" property is
specified.

Signed-off-by: Geert Uytterhoeven 
---
 arch/arm64/boot/dts/renesas/r8a7796.dtsi | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/boot/dts/renesas/r8a7796.dtsi 
b/arch/arm64/boot/dts/renesas/r8a7796.dtsi
index 02febb434d1ca028..a11f030e97902e1c 100644
--- a/arch/arm64/boot/dts/renesas/r8a7796.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a7796.dtsi
@@ -31,6 +31,7 @@
psci {
compatible = "arm,psci-0.2";
method = "smc";
+   arm,psci-system-suspend-is-power-down;
};
 
cpus {
-- 
2.7.4



[PATCH/RFC 2/6] PM / Wakeup: Add wakeup_source_available()

2017-02-20 Thread Geert Uytterhoeven
Add a helper function to find out if any wake-up sources have been
registered.

Signed-off-by: Geert Uytterhoeven 
---
 drivers/base/power/wakeup.c | 8 
 include/linux/pm_wakeup.h   | 3 +++
 2 files changed, 11 insertions(+)

diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
index f546f8f107b06a45..1cf8320ed1a67dc4 100644
--- a/drivers/base/power/wakeup.c
+++ b/drivers/base/power/wakeup.c
@@ -232,6 +232,14 @@ void wakeup_source_unregister(struct wakeup_source *ws)
 EXPORT_SYMBOL_GPL(wakeup_source_unregister);
 
 /**
+ * wakeup_source_available - Check if any wakeup sources have been registered
+ */
+bool wakeup_source_available(void)
+{
+   return !list_empty(_sources);
+}
+
+/**
  * device_wakeup_attach - Attach a wakeup source object to a device object.
  * @dev: Device to handle.
  * @ws: Wakeup source object to attach to @dev.
diff --git a/include/linux/pm_wakeup.h b/include/linux/pm_wakeup.h
index a3447932df1ff0a0..c5eaa8dbf27033df 100644
--- a/include/linux/pm_wakeup.h
+++ b/include/linux/pm_wakeup.h
@@ -97,6 +97,7 @@ extern void wakeup_source_add(struct wakeup_source *ws);
 extern void wakeup_source_remove(struct wakeup_source *ws);
 extern struct wakeup_source *wakeup_source_register(const char *name);
 extern void wakeup_source_unregister(struct wakeup_source *ws);
+extern bool wakeup_source_available(void);
 extern int device_wakeup_enable(struct device *dev);
 extern int device_wakeup_disable(struct device *dev);
 extern void device_set_wakeup_capable(struct device *dev, bool capable);
@@ -144,6 +145,8 @@ static inline struct wakeup_source 
*wakeup_source_register(const char *name)
 
 static inline void wakeup_source_unregister(struct wakeup_source *ws) {}
 
+static inline bool wakeup_source_available(void) { return false; }
+
 static inline int device_wakeup_enable(struct device *dev)
 {
dev->power.should_wakeup = true;
-- 
2.7.4



Re: [PATCH 1/1] clk: renesas: cpg-mssr: r8a7796: add IMR clocks

2017-02-20 Thread Sergei Shtylyov

On 02/20/2017 11:38 AM, Geert Uytterhoeven wrote:


Add the IMR[0-1] clocks to the R8A7796 CPG/MSSR driver.

Signed-off-by: Sergei Shtylyov 


Reviewed-by: Geert Uytterhoeven 


--- linux.orig/drivers/clk/renesas/r8a7796-cpg-mssr.c
+++ linux/drivers/clk/renesas/r8a7796-cpg-mssr.c
@@ -179,6 +179,8 @@ static const struct mssr_mod_clk r8a7796
DEF_MOD("vin1",  810,   R8A7796_CLK_S0D2),
DEF_MOD("vin0",  811,   R8A7796_CLK_S0D2),
DEF_MOD("etheravb",  812,   R8A7796_CLK_S0D6),
+   DEF_MOD("imr1",  822,   R8A7796_CLK_S2D1),
+   DEF_MOD("imr0",  823,   R8A7796_CLK_S2D1),


According to R-Car Gen3 Hardware Users Manual Rev.0.53E, the parent
clock is S0D2, like on H3 ES2.0.


   I only have 0.51E here, doesn't seem to contain much of the clock info...


Will queue in clk-renesas-for-v4.12 with corrected parent clock.


   Thank you!


Gr{oetje,eeting}s,

Geert


MBR, Sergei



[PATCH 6/7] arm: dts: genmai: Add RIIC2 pin group

2017-02-20 Thread Jacopo Mondi
Add pin configuration subnode for RIIC2 interface.

Signed-off-by: Jacopo Mondi 
---
 arch/arm/boot/dts/r7s72100-genmai.dts | 9 +
 1 file changed, 9 insertions(+)

diff --git a/arch/arm/boot/dts/r7s72100-genmai.dts 
b/arch/arm/boot/dts/r7s72100-genmai.dts
index f7be440..467a8a1 100644
--- a/arch/arm/boot/dts/r7s72100-genmai.dts
+++ b/arch/arm/boot/dts/r7s72100-genmai.dts
@@ -43,6 +43,12 @@
renesas,pins = ,
   ;
};
+
+   i2c2_pins: i2c2 {
+   /* RIIC2: P1_4 as SCL, P1_5 as SDA */
+   renesas,pins = ,
+  ;
+   };
 };
 
 _clk {
@@ -61,6 +67,9 @@
status = "okay";
clock-frequency = <40>;
 
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins>;
+
eeprom@50 {
compatible = "renesas,24c128";
reg = <0x50>;
-- 
2.7.4



[PATCH 3/7] arm: dts: dt-bindings: Add Renesas RZ pinctrl header

2017-02-20 Thread Jacopo Mondi
Add dt-bindings for Renesas r7s72100 pin controller header file.

Signed-off-by: Jacopo Mondi 
---
 include/dt-bindings/pinctrl/r7s72100-pinctrl.h | 30 ++
 1 file changed, 30 insertions(+)
 create mode 100644 include/dt-bindings/pinctrl/r7s72100-pinctrl.h

diff --git a/include/dt-bindings/pinctrl/r7s72100-pinctrl.h 
b/include/dt-bindings/pinctrl/r7s72100-pinctrl.h
new file mode 100644
index 000..24759bf
--- /dev/null
+++ b/include/dt-bindings/pinctrl/r7s72100-pinctrl.h
@@ -0,0 +1,30 @@
+/*
+ * Defines macros and constants for Renesas RZ/A1 pin controller pin
+ * muxing functions.
+ */
+#ifndef __DT_BINDINGS_PINCTRL_RENESAS_RZA1_H
+#define __DT_BINDINGS_PINCTRL_RENESAS_RZA1_H
+
+#define RZA1_PINS_PER_PORT 16
+
+/* Create the pin index from it's bank and position numbers */
+#define PIN(b, p)  ((b) * RZA1_PINS_PER_PORT + (p))
+
+/* Flags to apply to alternate function configuration */
+/*
+ * Pin needs input buffer enabled.
+ * This applies to pin which alternate function requires input capabilities.
+ * Eg: RX pin on a serial interface needs this flag to be set.
+ */
+#define INPUT_EN   (1 << 3)
+
+/*
+ * Let software drive the pin I/O direction overriding the alternate function
+ * configuration.
+ * Some alternate function requires software to force I/O direction of a pin,
+ * ovverriding the designated one.
+ * Reference to the HW manual to know when this flag shall be used.
+ */
+#define SWIO   (1 << 4)
+
+#endif
-- 
2.7.4



Re: [PATCH] vsp-lib: Fix reference frame generation for HSV input formats

2017-02-20 Thread Kieran Bingham
Hi Laurent,

On 13/02/17 15:46, Laurent Pinchart wrote:
> gen-image doesn't support processing HSV input frames. Fortunately the
> HSV tests don't require it either, when they take an HSV input frame
> they just pass it straight to the WPF. We can thus set the input format
> to RGB for reference frame generation.
> 
> Signed-off-by: Laurent Pinchart 
> ---
>  scripts/vsp-lib.sh | 10 ++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/scripts/vsp-lib.sh b/scripts/vsp-lib.sh
> index ae9683cffab6..695e081bf34d 100755
> --- a/scripts/vsp-lib.sh
> +++ b/scripts/vsp-lib.sh
> @@ -103,6 +103,16 @@ reference_frame() {
>   local alpha=
>   local options=
>  
> + # gen-image doesn't support processing HSV input images. The good news
> + # is that the HSV tests that take HSV images as inputs don't need to
> + # perform any processing. We can set the input format to RGB for HSB

s/HSB/HSV/

> + # reference frame generation.
> + case $in_format in
> + HSV24 | HSV32)
> + in_format=ARGB32
> + ;;
> + esac
> +
>   # Start with the input format to compute the alpha value being used by
>   # the RPF after unpacking. Keep in sync with generate_input_frame.
>   case $in_format in

With that,

Reviewed-by: Kieran Bingham 



Re: [PATCH 1/1] clk: renesas: cpg-mssr: r8a7796: add IMR clocks

2017-02-20 Thread Geert Uytterhoeven
Hi Sergei,

On Sat, Feb 18, 2017 at 10:39 PM, Sergei Shtylyov
 wrote:
> Add the IMR[0-1] clocks to the R8A7796 CPG/MSSR driver.
>
> Signed-off-by: Sergei Shtylyov 

Reviewed-by: Geert Uytterhoeven 

> --- linux.orig/drivers/clk/renesas/r8a7796-cpg-mssr.c
> +++ linux/drivers/clk/renesas/r8a7796-cpg-mssr.c
> @@ -179,6 +179,8 @@ static const struct mssr_mod_clk r8a7796
> DEF_MOD("vin1",  810,   R8A7796_CLK_S0D2),
> DEF_MOD("vin0",  811,   R8A7796_CLK_S0D2),
> DEF_MOD("etheravb",  812,   R8A7796_CLK_S0D6),
> +   DEF_MOD("imr1",  822,   R8A7796_CLK_S2D1),
> +   DEF_MOD("imr0",  823,   R8A7796_CLK_S2D1),

According to R-Car Gen3 Hardware Users Manual Rev.0.53E, the parent
clock is S0D2, like on H3 ES2.0.

Will queue in clk-renesas-for-v4.12 with corrected parent clock.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@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