[PATCH v2 3/4] dt-bindings: clock: gxbb-aoclk: Add CEC 32k clock

2017-07-28 Thread Neil Armstrong
This patchadds the clock binding entry for the CEC 32K AO Clock.

Signed-off-by: Neil Armstrong 
---
 include/dt-bindings/clock/gxbb-aoclkc.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/dt-bindings/clock/gxbb-aoclkc.h 
b/include/dt-bindings/clock/gxbb-aoclkc.h
index 3175148..9d15e22 100644
--- a/include/dt-bindings/clock/gxbb-aoclkc.h
+++ b/include/dt-bindings/clock/gxbb-aoclkc.h
@@ -62,5 +62,6 @@
 #define CLKID_AO_UART1 3
 #define CLKID_AO_UART2 4
 #define CLKID_AO_IR_BLASTER5
+#define CLKID_AO_CEC_32K   6
 
 #endif
-- 
1.9.1



[PATCH v2 3/4] dt-bindings: clock: gxbb-aoclk: Add CEC 32k clock

2017-07-28 Thread Neil Armstrong
This patchadds the clock binding entry for the CEC 32K AO Clock.

Signed-off-by: Neil Armstrong 
---
 include/dt-bindings/clock/gxbb-aoclkc.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/dt-bindings/clock/gxbb-aoclkc.h 
b/include/dt-bindings/clock/gxbb-aoclkc.h
index 3175148..9d15e22 100644
--- a/include/dt-bindings/clock/gxbb-aoclkc.h
+++ b/include/dt-bindings/clock/gxbb-aoclkc.h
@@ -62,5 +62,6 @@
 #define CLKID_AO_UART1 3
 #define CLKID_AO_UART2 4
 #define CLKID_AO_IR_BLASTER5
+#define CLKID_AO_CEC_32K   6
 
 #endif
-- 
1.9.1



[PATCH v2 2/4] clk: meson: gxbb-aoclk: Switch to regmap for register access

2017-07-28 Thread Neil Armstrong
Switch the aoclk driver to use the new bindings and switch all the
registers access to regmap only.

Signed-off-by: Neil Armstrong 
---
 drivers/clk/meson/Makefile|  2 +-
 drivers/clk/meson/gxbb-aoclk-regmap.c | 46 +++
 drivers/clk/meson/gxbb-aoclk.c| 44 -
 drivers/clk/meson/gxbb-aoclk.h| 26 
 4 files changed, 95 insertions(+), 23 deletions(-)
 create mode 100644 drivers/clk/meson/gxbb-aoclk-regmap.c
 create mode 100644 drivers/clk/meson/gxbb-aoclk.h

diff --git a/drivers/clk/meson/Makefile b/drivers/clk/meson/Makefile
index 83b6d9d..de65427 100644
--- a/drivers/clk/meson/Makefile
+++ b/drivers/clk/meson/Makefile
@@ -4,4 +4,4 @@
 
 obj-$(CONFIG_COMMON_CLK_AMLOGIC) += clk-pll.o clk-cpu.o clk-mpll.o 
clk-audio-divider.o
 obj-$(CONFIG_COMMON_CLK_MESON8B) += meson8b.o
-obj-$(CONFIG_COMMON_CLK_GXBB)   += gxbb.o gxbb-aoclk.o
+obj-$(CONFIG_COMMON_CLK_GXBB)   += gxbb.o gxbb-aoclk.o gxbb-aoclk-regmap.o
diff --git a/drivers/clk/meson/gxbb-aoclk-regmap.c 
b/drivers/clk/meson/gxbb-aoclk-regmap.c
new file mode 100644
index 000..2515fbf
--- /dev/null
+++ b/drivers/clk/meson/gxbb-aoclk-regmap.c
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017 BayLibre, SAS.
+ * Author: Neil Armstrong 
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include "gxbb-aoclk.h"
+
+static int aoclk_gate_regmap_enable(struct clk_hw *hw)
+{
+   struct aoclk_gate_regmap *gate = to_aoclk_gate_regmap(hw);
+
+   return regmap_update_bits(gate->regmap, AO_RTI_GEN_CNTL_REG0,
+ BIT(gate->bit_idx), BIT(gate->bit_idx));
+}
+
+static void aoclk_gate_regmap_disable(struct clk_hw *hw)
+{
+   struct aoclk_gate_regmap *gate = to_aoclk_gate_regmap(hw);
+
+   regmap_update_bits(gate->regmap, AO_RTI_GEN_CNTL_REG0,
+  BIT(gate->bit_idx), 0);
+}
+
+static int aoclk_gate_regmap_is_enabled(struct clk_hw *hw)
+{
+   struct aoclk_gate_regmap *gate = to_aoclk_gate_regmap(hw);
+   unsigned int val;
+   int ret;
+
+   ret = regmap_read(gate->regmap, AO_RTI_GEN_CNTL_REG0, );
+   if (ret)
+   return ret;
+
+   return (val & BIT(gate->bit_idx)) != 0;
+}
+
+const struct clk_ops meson_aoclk_gate_regmap_ops = {
+   .enable = aoclk_gate_regmap_enable,
+   .disable = aoclk_gate_regmap_disable,
+   .is_enabled = aoclk_gate_regmap_is_enabled,
+};
diff --git a/drivers/clk/meson/gxbb-aoclk.c b/drivers/clk/meson/gxbb-aoclk.c
index b45c5fb..f61506c 100644
--- a/drivers/clk/meson/gxbb-aoclk.c
+++ b/drivers/clk/meson/gxbb-aoclk.c
@@ -56,16 +56,19 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
+#include "gxbb-aoclk.h"
 
 static DEFINE_SPINLOCK(gxbb_aoclk_lock);
 
 struct gxbb_aoclk_reset_controller {
struct reset_controller_dev reset;
unsigned int *data;
-   void __iomem *base;
+   struct regmap *regmap;
 };
 
 static int gxbb_aoclk_do_reset(struct reset_controller_dev *rcdev,
@@ -74,9 +77,8 @@ static int gxbb_aoclk_do_reset(struct reset_controller_dev 
*rcdev,
struct gxbb_aoclk_reset_controller *reset =
container_of(rcdev, struct gxbb_aoclk_reset_controller, reset);
 
-   writel(BIT(reset->data[id]), reset->base);
-
-   return 0;
+   return regmap_write(reset->regmap, AO_RTI_GEN_CNTL_REG0,
+   BIT(reset->data[id]));
 }
 
 static const struct reset_control_ops gxbb_aoclk_reset_ops = {
@@ -84,13 +86,12 @@ static int gxbb_aoclk_do_reset(struct reset_controller_dev 
*rcdev,
 };
 
 #define GXBB_AO_GATE(_name, _bit)  \
-static struct clk_gate _name##_ao = {  \
-   .reg = (void __iomem *)0,   \
+static struct aoclk_gate_regmap _name##_ao = { \
.bit_idx = (_bit),  \
.lock = _aoclk_lock,   \
.hw.init = &(struct clk_init_data) {\
.name = #_name "_ao",   \
-   .ops = _gate_ops,   \
+   .ops = _aoclk_gate_regmap_ops,\
.parent_names = (const char *[]){ "clk81" },\
.num_parents = 1,   \
.flags = (CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED), \
@@ -113,7 +114,7 @@ static int gxbb_aoclk_do_reset(struct reset_controller_dev 
*rcdev,
[RESET_AO_IR_BLASTER] = 23,
 };
 
-static struct clk_gate *gxbb_aoclk_gate[] = {
+static struct aoclk_gate_regmap *gxbb_aoclk_gate[] = {
[CLKID_AO_REMOTE] = _ao,
[CLKID_AO_I2C_MASTER] = _master_ao,
[CLKID_AO_I2C_SLAVE] = _slave_ao,

[PATCH v2 2/4] clk: meson: gxbb-aoclk: Switch to regmap for register access

2017-07-28 Thread Neil Armstrong
Switch the aoclk driver to use the new bindings and switch all the
registers access to regmap only.

Signed-off-by: Neil Armstrong 
---
 drivers/clk/meson/Makefile|  2 +-
 drivers/clk/meson/gxbb-aoclk-regmap.c | 46 +++
 drivers/clk/meson/gxbb-aoclk.c| 44 -
 drivers/clk/meson/gxbb-aoclk.h| 26 
 4 files changed, 95 insertions(+), 23 deletions(-)
 create mode 100644 drivers/clk/meson/gxbb-aoclk-regmap.c
 create mode 100644 drivers/clk/meson/gxbb-aoclk.h

diff --git a/drivers/clk/meson/Makefile b/drivers/clk/meson/Makefile
index 83b6d9d..de65427 100644
--- a/drivers/clk/meson/Makefile
+++ b/drivers/clk/meson/Makefile
@@ -4,4 +4,4 @@
 
 obj-$(CONFIG_COMMON_CLK_AMLOGIC) += clk-pll.o clk-cpu.o clk-mpll.o 
clk-audio-divider.o
 obj-$(CONFIG_COMMON_CLK_MESON8B) += meson8b.o
-obj-$(CONFIG_COMMON_CLK_GXBB)   += gxbb.o gxbb-aoclk.o
+obj-$(CONFIG_COMMON_CLK_GXBB)   += gxbb.o gxbb-aoclk.o gxbb-aoclk-regmap.o
diff --git a/drivers/clk/meson/gxbb-aoclk-regmap.c 
b/drivers/clk/meson/gxbb-aoclk-regmap.c
new file mode 100644
index 000..2515fbf
--- /dev/null
+++ b/drivers/clk/meson/gxbb-aoclk-regmap.c
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017 BayLibre, SAS.
+ * Author: Neil Armstrong 
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include "gxbb-aoclk.h"
+
+static int aoclk_gate_regmap_enable(struct clk_hw *hw)
+{
+   struct aoclk_gate_regmap *gate = to_aoclk_gate_regmap(hw);
+
+   return regmap_update_bits(gate->regmap, AO_RTI_GEN_CNTL_REG0,
+ BIT(gate->bit_idx), BIT(gate->bit_idx));
+}
+
+static void aoclk_gate_regmap_disable(struct clk_hw *hw)
+{
+   struct aoclk_gate_regmap *gate = to_aoclk_gate_regmap(hw);
+
+   regmap_update_bits(gate->regmap, AO_RTI_GEN_CNTL_REG0,
+  BIT(gate->bit_idx), 0);
+}
+
+static int aoclk_gate_regmap_is_enabled(struct clk_hw *hw)
+{
+   struct aoclk_gate_regmap *gate = to_aoclk_gate_regmap(hw);
+   unsigned int val;
+   int ret;
+
+   ret = regmap_read(gate->regmap, AO_RTI_GEN_CNTL_REG0, );
+   if (ret)
+   return ret;
+
+   return (val & BIT(gate->bit_idx)) != 0;
+}
+
+const struct clk_ops meson_aoclk_gate_regmap_ops = {
+   .enable = aoclk_gate_regmap_enable,
+   .disable = aoclk_gate_regmap_disable,
+   .is_enabled = aoclk_gate_regmap_is_enabled,
+};
diff --git a/drivers/clk/meson/gxbb-aoclk.c b/drivers/clk/meson/gxbb-aoclk.c
index b45c5fb..f61506c 100644
--- a/drivers/clk/meson/gxbb-aoclk.c
+++ b/drivers/clk/meson/gxbb-aoclk.c
@@ -56,16 +56,19 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
+#include "gxbb-aoclk.h"
 
 static DEFINE_SPINLOCK(gxbb_aoclk_lock);
 
 struct gxbb_aoclk_reset_controller {
struct reset_controller_dev reset;
unsigned int *data;
-   void __iomem *base;
+   struct regmap *regmap;
 };
 
 static int gxbb_aoclk_do_reset(struct reset_controller_dev *rcdev,
@@ -74,9 +77,8 @@ static int gxbb_aoclk_do_reset(struct reset_controller_dev 
*rcdev,
struct gxbb_aoclk_reset_controller *reset =
container_of(rcdev, struct gxbb_aoclk_reset_controller, reset);
 
-   writel(BIT(reset->data[id]), reset->base);
-
-   return 0;
+   return regmap_write(reset->regmap, AO_RTI_GEN_CNTL_REG0,
+   BIT(reset->data[id]));
 }
 
 static const struct reset_control_ops gxbb_aoclk_reset_ops = {
@@ -84,13 +86,12 @@ static int gxbb_aoclk_do_reset(struct reset_controller_dev 
*rcdev,
 };
 
 #define GXBB_AO_GATE(_name, _bit)  \
-static struct clk_gate _name##_ao = {  \
-   .reg = (void __iomem *)0,   \
+static struct aoclk_gate_regmap _name##_ao = { \
.bit_idx = (_bit),  \
.lock = _aoclk_lock,   \
.hw.init = &(struct clk_init_data) {\
.name = #_name "_ao",   \
-   .ops = _gate_ops,   \
+   .ops = _aoclk_gate_regmap_ops,\
.parent_names = (const char *[]){ "clk81" },\
.num_parents = 1,   \
.flags = (CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED), \
@@ -113,7 +114,7 @@ static int gxbb_aoclk_do_reset(struct reset_controller_dev 
*rcdev,
[RESET_AO_IR_BLASTER] = 23,
 };
 
-static struct clk_gate *gxbb_aoclk_gate[] = {
+static struct aoclk_gate_regmap *gxbb_aoclk_gate[] = {
[CLKID_AO_REMOTE] = _ao,
[CLKID_AO_I2C_MASTER] = _master_ao,
[CLKID_AO_I2C_SLAVE] = _slave_ao,
@@ -136,24 +137,23 @@ static int 

[PATCH v4 11/17] pinctrl: madera: Add driver for Cirrus Logic Madera codecs

2017-07-28 Thread Richard Fitzgerald
These codecs have a variable number of I/O lines each of which
is individually selectable to a wide range of possible functions.

The functionality is slightly different from the traditional muxed
GPIO since most of the functions can be mapped to any pin (and even
the same function to multiple pins). Most pins have a dedicated
"alternate" function that is only available on that pin. The
alternate functions are usually a group of signals, though it is
not always necessary to enable the full group, depending on the
alternate function and how it is to be used. The mapping between
alternate functions and GPIO pins varies between codecs depending
on the number of alternate functions and available pins.

Note on the Kconfig options:
The formula "default y if..." is used for PINCTRL_MADERA so that its
select options will be processed, allowing us to group selects for
pinctrl into the pinctrl Kconfig where they logically belong instead
of accumulating under the parent MFD Kconfig.

Signed-off-by: Richard Fitzgerald 
---
No changes since V3
(Kconfig depedency problem was fixed in MFD patch)
 MAINTAINERS  |2 +
 drivers/pinctrl/Kconfig  |1 +
 drivers/pinctrl/Makefile |1 +
 drivers/pinctrl/cirrus/Kconfig   |   15 +
 drivers/pinctrl/cirrus/Makefile  |   11 +
 drivers/pinctrl/cirrus/pinctrl-cs47l35.c |   46 ++
 drivers/pinctrl/cirrus/pinctrl-cs47l85.c |   60 ++
 drivers/pinctrl/cirrus/pinctrl-cs47l90.c |   58 ++
 drivers/pinctrl/cirrus/pinctrl-madera.c  | 1074 ++
 drivers/pinctrl/cirrus/pinctrl-madera.h  |   40 ++
 10 files changed, 1308 insertions(+)
 create mode 100644 drivers/pinctrl/cirrus/Kconfig
 create mode 100644 drivers/pinctrl/cirrus/Makefile
 create mode 100644 drivers/pinctrl/cirrus/pinctrl-cs47l35.c
 create mode 100644 drivers/pinctrl/cirrus/pinctrl-cs47l85.c
 create mode 100644 drivers/pinctrl/cirrus/pinctrl-cs47l90.c
 create mode 100644 drivers/pinctrl/cirrus/pinctrl-madera.c
 create mode 100644 drivers/pinctrl/cirrus/pinctrl-madera.h

diff --git a/MAINTAINERS b/MAINTAINERS
index bc07a32..4dbeaa3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3377,11 +3377,13 @@ T:  git 
https://github.com/CirrusLogic/linux-drivers.git
 W: https://github.com/CirrusLogic/linux-drivers/wiki
 S: Supported
 F: Documentation/devicetree/bindings/mfd/madera.txt
+F: Documentation/devicetree/bindings/pinctrl/cirrus,madera-pinctrl.txt
 F: include/linux/irqchip/irq-madera*
 F: include/linux/mfd/madera/*
 F: drivers/irqchip/irq-madera*
 F: drivers/mfd/madera*
 F: drivers/mfd/cs47l*
+F: drivers/pinctrl/cirrus/*
 
 CLEANCACHE API
 M: Konrad Rzeszutek Wilk 
diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
index e14b46c..165cc23b 100644
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -351,6 +351,7 @@ source "drivers/pinctrl/uniphier/Kconfig"
 source "drivers/pinctrl/vt8500/Kconfig"
 source "drivers/pinctrl/mediatek/Kconfig"
 source "drivers/pinctrl/zte/Kconfig"
+source "drivers/pinctrl/cirrus/Kconfig"
 
 config PINCTRL_XWAY
bool
diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile
index 2bc641d..4455954 100644
--- a/drivers/pinctrl/Makefile
+++ b/drivers/pinctrl/Makefile
@@ -62,3 +62,4 @@ obj-$(CONFIG_PINCTRL_UNIPHIER)+= uniphier/
 obj-$(CONFIG_ARCH_VT8500)  += vt8500/
 obj-$(CONFIG_PINCTRL_MTK)  += mediatek/
 obj-$(CONFIG_PINCTRL_ZX)   += zte/
+obj-y  += cirrus/
diff --git a/drivers/pinctrl/cirrus/Kconfig b/drivers/pinctrl/cirrus/Kconfig
new file mode 100644
index 000..093527ea
--- /dev/null
+++ b/drivers/pinctrl/cirrus/Kconfig
@@ -0,0 +1,15 @@
+config PINCTRL_MADERA
+   bool
+   select PINMUX
+   select GENERIC_PINCONF
+   default y if MFD_MADERA=y
+
+config PINCTRL_CS47L35
+   bool
+
+config PINCTRL_CS47L85
+   bool
+
+config PINCTRL_CS47L90
+   bool
+
diff --git a/drivers/pinctrl/cirrus/Makefile b/drivers/pinctrl/cirrus/Makefile
new file mode 100644
index 000..b34473c
--- /dev/null
+++ b/drivers/pinctrl/cirrus/Makefile
@@ -0,0 +1,11 @@
+# Cirrus Logic pinctrl drivers
+obj-$(CONFIG_PINCTRL_MADERA)   += pinctrl-madera.o
+ifeq ($(CONFIG_PINCTRL_CS47L35),y)
+obj-$(CONFIG_PINCTRL_MADERA)   += pinctrl-cs47l35.o
+endif
+ifeq ($(CONFIG_PINCTRL_CS47L85),y)
+obj-$(CONFIG_PINCTRL_MADERA)   += pinctrl-cs47l85.o
+endif
+ifeq ($(CONFIG_PINCTRL_CS47L90),y)
+obj-$(CONFIG_PINCTRL_MADERA)   += pinctrl-cs47l90.o
+endif
diff --git a/drivers/pinctrl/cirrus/pinctrl-cs47l35.c 
b/drivers/pinctrl/cirrus/pinctrl-cs47l35.c
new file mode 100644
index 000..edf444a
--- /dev/null
+++ b/drivers/pinctrl/cirrus/pinctrl-cs47l35.c
@@ -0,0 +1,46 @@
+/*
+ * Pinctrl for Cirrus Logic CS47L35
+ *
+ * Copyright 2016-2017 Cirrus Logic
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the 

[PATCH v4 11/17] pinctrl: madera: Add driver for Cirrus Logic Madera codecs

2017-07-28 Thread Richard Fitzgerald
These codecs have a variable number of I/O lines each of which
is individually selectable to a wide range of possible functions.

The functionality is slightly different from the traditional muxed
GPIO since most of the functions can be mapped to any pin (and even
the same function to multiple pins). Most pins have a dedicated
"alternate" function that is only available on that pin. The
alternate functions are usually a group of signals, though it is
not always necessary to enable the full group, depending on the
alternate function and how it is to be used. The mapping between
alternate functions and GPIO pins varies between codecs depending
on the number of alternate functions and available pins.

Note on the Kconfig options:
The formula "default y if..." is used for PINCTRL_MADERA so that its
select options will be processed, allowing us to group selects for
pinctrl into the pinctrl Kconfig where they logically belong instead
of accumulating under the parent MFD Kconfig.

Signed-off-by: Richard Fitzgerald 
---
No changes since V3
(Kconfig depedency problem was fixed in MFD patch)
 MAINTAINERS  |2 +
 drivers/pinctrl/Kconfig  |1 +
 drivers/pinctrl/Makefile |1 +
 drivers/pinctrl/cirrus/Kconfig   |   15 +
 drivers/pinctrl/cirrus/Makefile  |   11 +
 drivers/pinctrl/cirrus/pinctrl-cs47l35.c |   46 ++
 drivers/pinctrl/cirrus/pinctrl-cs47l85.c |   60 ++
 drivers/pinctrl/cirrus/pinctrl-cs47l90.c |   58 ++
 drivers/pinctrl/cirrus/pinctrl-madera.c  | 1074 ++
 drivers/pinctrl/cirrus/pinctrl-madera.h  |   40 ++
 10 files changed, 1308 insertions(+)
 create mode 100644 drivers/pinctrl/cirrus/Kconfig
 create mode 100644 drivers/pinctrl/cirrus/Makefile
 create mode 100644 drivers/pinctrl/cirrus/pinctrl-cs47l35.c
 create mode 100644 drivers/pinctrl/cirrus/pinctrl-cs47l85.c
 create mode 100644 drivers/pinctrl/cirrus/pinctrl-cs47l90.c
 create mode 100644 drivers/pinctrl/cirrus/pinctrl-madera.c
 create mode 100644 drivers/pinctrl/cirrus/pinctrl-madera.h

diff --git a/MAINTAINERS b/MAINTAINERS
index bc07a32..4dbeaa3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3377,11 +3377,13 @@ T:  git 
https://github.com/CirrusLogic/linux-drivers.git
 W: https://github.com/CirrusLogic/linux-drivers/wiki
 S: Supported
 F: Documentation/devicetree/bindings/mfd/madera.txt
+F: Documentation/devicetree/bindings/pinctrl/cirrus,madera-pinctrl.txt
 F: include/linux/irqchip/irq-madera*
 F: include/linux/mfd/madera/*
 F: drivers/irqchip/irq-madera*
 F: drivers/mfd/madera*
 F: drivers/mfd/cs47l*
+F: drivers/pinctrl/cirrus/*
 
 CLEANCACHE API
 M: Konrad Rzeszutek Wilk 
diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
index e14b46c..165cc23b 100644
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -351,6 +351,7 @@ source "drivers/pinctrl/uniphier/Kconfig"
 source "drivers/pinctrl/vt8500/Kconfig"
 source "drivers/pinctrl/mediatek/Kconfig"
 source "drivers/pinctrl/zte/Kconfig"
+source "drivers/pinctrl/cirrus/Kconfig"
 
 config PINCTRL_XWAY
bool
diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile
index 2bc641d..4455954 100644
--- a/drivers/pinctrl/Makefile
+++ b/drivers/pinctrl/Makefile
@@ -62,3 +62,4 @@ obj-$(CONFIG_PINCTRL_UNIPHIER)+= uniphier/
 obj-$(CONFIG_ARCH_VT8500)  += vt8500/
 obj-$(CONFIG_PINCTRL_MTK)  += mediatek/
 obj-$(CONFIG_PINCTRL_ZX)   += zte/
+obj-y  += cirrus/
diff --git a/drivers/pinctrl/cirrus/Kconfig b/drivers/pinctrl/cirrus/Kconfig
new file mode 100644
index 000..093527ea
--- /dev/null
+++ b/drivers/pinctrl/cirrus/Kconfig
@@ -0,0 +1,15 @@
+config PINCTRL_MADERA
+   bool
+   select PINMUX
+   select GENERIC_PINCONF
+   default y if MFD_MADERA=y
+
+config PINCTRL_CS47L35
+   bool
+
+config PINCTRL_CS47L85
+   bool
+
+config PINCTRL_CS47L90
+   bool
+
diff --git a/drivers/pinctrl/cirrus/Makefile b/drivers/pinctrl/cirrus/Makefile
new file mode 100644
index 000..b34473c
--- /dev/null
+++ b/drivers/pinctrl/cirrus/Makefile
@@ -0,0 +1,11 @@
+# Cirrus Logic pinctrl drivers
+obj-$(CONFIG_PINCTRL_MADERA)   += pinctrl-madera.o
+ifeq ($(CONFIG_PINCTRL_CS47L35),y)
+obj-$(CONFIG_PINCTRL_MADERA)   += pinctrl-cs47l35.o
+endif
+ifeq ($(CONFIG_PINCTRL_CS47L85),y)
+obj-$(CONFIG_PINCTRL_MADERA)   += pinctrl-cs47l85.o
+endif
+ifeq ($(CONFIG_PINCTRL_CS47L90),y)
+obj-$(CONFIG_PINCTRL_MADERA)   += pinctrl-cs47l90.o
+endif
diff --git a/drivers/pinctrl/cirrus/pinctrl-cs47l35.c 
b/drivers/pinctrl/cirrus/pinctrl-cs47l35.c
new file mode 100644
index 000..edf444a
--- /dev/null
+++ b/drivers/pinctrl/cirrus/pinctrl-cs47l35.c
@@ -0,0 +1,46 @@
+/*
+ * Pinctrl for Cirrus Logic CS47L35
+ *
+ * Copyright 2016-2017 Cirrus Logic
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * 

Re: [RFC PATCH] treewide: remove GFP_TEMPORARY allocation flag

2017-07-28 Thread Mel Gorman
On Fri, Jul 28, 2017 at 11:19:04AM +0200, Michal Hocko wrote:
> From: Michal Hocko 
> 
> GFP_TEMPORARY has been introduced by e12ba74d8ff3 ("Group short-lived
> and reclaimable kernel allocations") along with __GFP_RECLAIMABLE. It's
> primary motivation was to allow users to tell that an allocation is
> short lived and so the allocator can try to place such allocations close
> together and prevent long term fragmentation. As much as this sounds
> like a reasonable semantic it becomes much less clear when to use the
> highlevel GFP_TEMPORARY allocation flag. How long is temporary? Can
> the context holding that memory sleep? Can it take locks? It seems
> there is no good answer for those questions.
> 
> The current implementation of GFP_TEMPORARY is basically
> GFP_KERNEL | __GFP_RECLAIMABLE which in itself is tricky because
> basically none of the existing caller provide a way to reclaim the
> allocated memory. So this is rather misleading and hard to evaluate for
> any benefits.
> 

At the time of the introduction, the users were all very short-lived
where short was for operations such as reading a proc file that discarded
buffers afterwards. However, it does seem to have misused over the last
few years and it was too easy to confuse "temporary" with "short lived"
and too easy to get confused about "how short lived is short lived?". On
that basis;

Acked-by: Mel Gorman 

-- 
Mel Gorman
SUSE Labs


Re: [RFC PATCH] treewide: remove GFP_TEMPORARY allocation flag

2017-07-28 Thread Mel Gorman
On Fri, Jul 28, 2017 at 11:19:04AM +0200, Michal Hocko wrote:
> From: Michal Hocko 
> 
> GFP_TEMPORARY has been introduced by e12ba74d8ff3 ("Group short-lived
> and reclaimable kernel allocations") along with __GFP_RECLAIMABLE. It's
> primary motivation was to allow users to tell that an allocation is
> short lived and so the allocator can try to place such allocations close
> together and prevent long term fragmentation. As much as this sounds
> like a reasonable semantic it becomes much less clear when to use the
> highlevel GFP_TEMPORARY allocation flag. How long is temporary? Can
> the context holding that memory sleep? Can it take locks? It seems
> there is no good answer for those questions.
> 
> The current implementation of GFP_TEMPORARY is basically
> GFP_KERNEL | __GFP_RECLAIMABLE which in itself is tricky because
> basically none of the existing caller provide a way to reclaim the
> allocated memory. So this is rather misleading and hard to evaluate for
> any benefits.
> 

At the time of the introduction, the users were all very short-lived
where short was for operations such as reading a proc file that discarded
buffers afterwards. However, it does seem to have misused over the last
few years and it was too easy to confuse "temporary" with "short lived"
and too easy to get confused about "how short lived is short lived?". On
that basis;

Acked-by: Mel Gorman 

-- 
Mel Gorman
SUSE Labs


[PATCH v4 12/17] gpio: madera: Support Cirrus Logic Madera class codecs

2017-07-28 Thread Richard Fitzgerald
This adds support for the GPIOs on Cirrus Logic Madera class codecs.
Any pins not used for special functions (see the pinctrl driver) can be
used as general single-bit input or output lines. The number of available
GPIOs varies between codecs.

Signed-off-by: Nariman Poushin 
Signed-off-by: Richard Fitzgerald 
Signed-off-by: Charles Keepax 
Acked-by: Linus Walleij 
---
No changes since V3
 MAINTAINERS|   1 +
 drivers/gpio/Kconfig   |   6 ++
 drivers/gpio/Makefile  |   1 +
 drivers/gpio/gpio-madera.c | 196 +
 4 files changed, 204 insertions(+)
 create mode 100644 drivers/gpio/gpio-madera.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 4dbeaa3..22cc961 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3380,6 +3380,7 @@ F:Documentation/devicetree/bindings/mfd/madera.txt
 F: Documentation/devicetree/bindings/pinctrl/cirrus,madera-pinctrl.txt
 F: include/linux/irqchip/irq-madera*
 F: include/linux/mfd/madera/*
+F: drivers/gpio/gpio-madera*
 F: drivers/irqchip/irq-madera*
 F: drivers/mfd/madera*
 F: drivers/mfd/cs47l*
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index f235eae..3679f68 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -975,6 +975,12 @@ config GPIO_LP87565
  This driver can also be built as a module. If so, the module will be
  called gpio-lp87565.
 
+config GPIO_MADERA
+   bool "Cirrus Logic Madera class codecs"
+   depends on PINCTRL_MADERA
+   help
+ Support for GPIOs on Cirrus Logic Madera class codecs.
+
 config GPIO_MAX77620
tristate "GPIO support for PMIC MAX77620 and MAX20024"
depends on MFD_MAX77620
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index a9fda6c..b036899 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -69,6 +69,7 @@ obj-$(CONFIG_ARCH_LPC32XX)+= gpio-lpc32xx.o
 obj-$(CONFIG_GPIO_LP873X)  += gpio-lp873x.o
 obj-$(CONFIG_GPIO_LP87565) += gpio-lp87565.o
 obj-$(CONFIG_GPIO_LYNXPOINT)   += gpio-lynxpoint.o
+obj-$(CONFIG_GPIO_MADERA)  += gpio-madera.o
 obj-$(CONFIG_GPIO_MAX730X) += gpio-max730x.o
 obj-$(CONFIG_GPIO_MAX7300) += gpio-max7300.o
 obj-$(CONFIG_GPIO_MAX7301) += gpio-max7301.o
diff --git a/drivers/gpio/gpio-madera.c b/drivers/gpio/gpio-madera.c
new file mode 100644
index 000..e45905d5
--- /dev/null
+++ b/drivers/gpio/gpio-madera.c
@@ -0,0 +1,196 @@
+/*
+ * GPIO support for Cirrus Logic Madera codecs
+ *
+ * Copyright 2015-2017 Cirrus Logic
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+struct madera_gpio {
+   struct madera *madera;
+   struct gpio_chip gpio_chip;
+};
+
+static int madera_gpio_get_direction(struct gpio_chip *chip,
+unsigned int offset)
+{
+   struct madera_gpio *madera_gpio = gpiochip_get_data(chip);
+   struct madera *madera = madera_gpio->madera;
+   unsigned int val;
+   int ret;
+
+   ret = regmap_read(madera->regmap,
+ MADERA_GPIO1_CTRL_2 + (2 * offset), );
+   if (ret < 0)
+   return ret;
+
+   return (val & MADERA_GP1_DIR_MASK) >> MADERA_GP1_DIR_SHIFT;
+}
+
+static int madera_gpio_direction_in(struct gpio_chip *chip, unsigned int 
offset)
+{
+   struct madera_gpio *madera_gpio = gpiochip_get_data(chip);
+   struct madera *madera = madera_gpio->madera;
+
+   return regmap_update_bits(madera->regmap,
+ MADERA_GPIO1_CTRL_2 + (2 * offset),
+ MADERA_GP1_DIR_MASK, MADERA_GP1_DIR);
+}
+
+static int madera_gpio_get(struct gpio_chip *chip, unsigned int offset)
+{
+   struct madera_gpio *madera_gpio = gpiochip_get_data(chip);
+   struct madera *madera = madera_gpio->madera;
+   unsigned int val;
+   int ret;
+
+   ret = regmap_read(madera->regmap,
+ MADERA_GPIO1_CTRL_1 + (2 * offset), );
+   if (ret < 0)
+   return ret;
+
+   return !!(val & MADERA_GP1_LVL_MASK);
+}
+
+static int madera_gpio_direction_out(struct gpio_chip *chip,
+unsigned int offset, int value)
+{
+   struct madera_gpio *madera_gpio = gpiochip_get_data(chip);
+   struct madera *madera = madera_gpio->madera;
+   unsigned int regval;
+   int ret;
+
+   if (value)
+   regval = MADERA_GP1_LVL;
+   else
+   regval = 0;
+
+   ret = regmap_update_bits(madera->regmap,
+MADERA_GPIO1_CTRL_2 + (2 * offset),
+

[PATCH v4 12/17] gpio: madera: Support Cirrus Logic Madera class codecs

2017-07-28 Thread Richard Fitzgerald
This adds support for the GPIOs on Cirrus Logic Madera class codecs.
Any pins not used for special functions (see the pinctrl driver) can be
used as general single-bit input or output lines. The number of available
GPIOs varies between codecs.

Signed-off-by: Nariman Poushin 
Signed-off-by: Richard Fitzgerald 
Signed-off-by: Charles Keepax 
Acked-by: Linus Walleij 
---
No changes since V3
 MAINTAINERS|   1 +
 drivers/gpio/Kconfig   |   6 ++
 drivers/gpio/Makefile  |   1 +
 drivers/gpio/gpio-madera.c | 196 +
 4 files changed, 204 insertions(+)
 create mode 100644 drivers/gpio/gpio-madera.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 4dbeaa3..22cc961 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3380,6 +3380,7 @@ F:Documentation/devicetree/bindings/mfd/madera.txt
 F: Documentation/devicetree/bindings/pinctrl/cirrus,madera-pinctrl.txt
 F: include/linux/irqchip/irq-madera*
 F: include/linux/mfd/madera/*
+F: drivers/gpio/gpio-madera*
 F: drivers/irqchip/irq-madera*
 F: drivers/mfd/madera*
 F: drivers/mfd/cs47l*
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index f235eae..3679f68 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -975,6 +975,12 @@ config GPIO_LP87565
  This driver can also be built as a module. If so, the module will be
  called gpio-lp87565.
 
+config GPIO_MADERA
+   bool "Cirrus Logic Madera class codecs"
+   depends on PINCTRL_MADERA
+   help
+ Support for GPIOs on Cirrus Logic Madera class codecs.
+
 config GPIO_MAX77620
tristate "GPIO support for PMIC MAX77620 and MAX20024"
depends on MFD_MAX77620
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index a9fda6c..b036899 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -69,6 +69,7 @@ obj-$(CONFIG_ARCH_LPC32XX)+= gpio-lpc32xx.o
 obj-$(CONFIG_GPIO_LP873X)  += gpio-lp873x.o
 obj-$(CONFIG_GPIO_LP87565) += gpio-lp87565.o
 obj-$(CONFIG_GPIO_LYNXPOINT)   += gpio-lynxpoint.o
+obj-$(CONFIG_GPIO_MADERA)  += gpio-madera.o
 obj-$(CONFIG_GPIO_MAX730X) += gpio-max730x.o
 obj-$(CONFIG_GPIO_MAX7300) += gpio-max7300.o
 obj-$(CONFIG_GPIO_MAX7301) += gpio-max7301.o
diff --git a/drivers/gpio/gpio-madera.c b/drivers/gpio/gpio-madera.c
new file mode 100644
index 000..e45905d5
--- /dev/null
+++ b/drivers/gpio/gpio-madera.c
@@ -0,0 +1,196 @@
+/*
+ * GPIO support for Cirrus Logic Madera codecs
+ *
+ * Copyright 2015-2017 Cirrus Logic
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+struct madera_gpio {
+   struct madera *madera;
+   struct gpio_chip gpio_chip;
+};
+
+static int madera_gpio_get_direction(struct gpio_chip *chip,
+unsigned int offset)
+{
+   struct madera_gpio *madera_gpio = gpiochip_get_data(chip);
+   struct madera *madera = madera_gpio->madera;
+   unsigned int val;
+   int ret;
+
+   ret = regmap_read(madera->regmap,
+ MADERA_GPIO1_CTRL_2 + (2 * offset), );
+   if (ret < 0)
+   return ret;
+
+   return (val & MADERA_GP1_DIR_MASK) >> MADERA_GP1_DIR_SHIFT;
+}
+
+static int madera_gpio_direction_in(struct gpio_chip *chip, unsigned int 
offset)
+{
+   struct madera_gpio *madera_gpio = gpiochip_get_data(chip);
+   struct madera *madera = madera_gpio->madera;
+
+   return regmap_update_bits(madera->regmap,
+ MADERA_GPIO1_CTRL_2 + (2 * offset),
+ MADERA_GP1_DIR_MASK, MADERA_GP1_DIR);
+}
+
+static int madera_gpio_get(struct gpio_chip *chip, unsigned int offset)
+{
+   struct madera_gpio *madera_gpio = gpiochip_get_data(chip);
+   struct madera *madera = madera_gpio->madera;
+   unsigned int val;
+   int ret;
+
+   ret = regmap_read(madera->regmap,
+ MADERA_GPIO1_CTRL_1 + (2 * offset), );
+   if (ret < 0)
+   return ret;
+
+   return !!(val & MADERA_GP1_LVL_MASK);
+}
+
+static int madera_gpio_direction_out(struct gpio_chip *chip,
+unsigned int offset, int value)
+{
+   struct madera_gpio *madera_gpio = gpiochip_get_data(chip);
+   struct madera *madera = madera_gpio->madera;
+   unsigned int regval;
+   int ret;
+
+   if (value)
+   regval = MADERA_GP1_LVL;
+   else
+   regval = 0;
+
+   ret = regmap_update_bits(madera->regmap,
+MADERA_GPIO1_CTRL_2 + (2 * offset),
+MADERA_GP1_DIR_MASK, 0);
+   if (ret < 0)
+   return ret;
+
+   return regmap_update_bits(madera->regmap,

[PATCH v4 00/17] Add support for Cirrus Logic CS47L35/L85/L90/L91 codecs

2017-07-28 Thread Richard Fitzgerald
The Cirrus Logic CS47L35, CS47L85, CS47L90/91 codecs are complex audio SoC
devices. In addition to the core audio capability they have onboard GPIO,
regulators, DSPs and interrupt controller and a large register map space
accessed over SPI or I2C. This family of codecs is based around common IP
blocks and they are managed by a set of common drivers referred to as "Madera".

Summary of changes since V3:
- Manually stripped register definitions we're not using right now from 
  registers.h to reduce the size and included some explanation in the
  commit message for why we do it the way we do
- Fixed review comments on MFD code
- Fixed Kconfig dependency error on pinctrl (missing dependency in MFD)
- minor bugfixes to routing in CS47L85 and CS47L90 codec drivers


Richard Fitzgerald (17):
  mfd: madera: Add register definitions for Cirrus Logic Madera codecs
  mfd: madera: Add DT bindings for Cirrus Logic Madera codecs
  mfd: madera: Add common support for Cirrus Logic Madera codecs
  mfd: madera: Register map tables for Cirrus Logic CS47L35
  mfd: madera: Register map tables for Cirrus Logic CS47L85
  mfd: madera: Register map tables for Cirrus Logic CS47L90/91
  regulator: arizona-micsupp: Add support for Cirrus Logic Madera codecs
  regulator: arizona-ldo1: Add support for Cirrus Logic Madera codecs
  irqchip: Add driver for Cirrus Logic Madera codecs
  pinctrl: madera: Add DT bindings for Cirrus Logic Madera codecs
  pinctrl: madera: Add driver for Cirrus Logic Madera codecs
  gpio: madera: Support Cirrus Logic Madera class codecs
  ASoC: madera: Add DT bindings for Cirrus Logic Madera codecs
  ASoC: madera: Add common support for Cirrus Logic Madera codecs
  ASoC: cs47l35: Add codec driver for Cirrus Logic CS47L35
  ASoC: cs47l85: Add codec driver for Cirrus Logic CS47L85
  ASoC: cs47l90: Add codec driver for Cirrus Logic CS47L90

 Documentation/devicetree/bindings/mfd/madera.txt   |  102 +
 .../bindings/pinctrl/cirrus,madera-pinctrl.txt |   99 +
 .../bindings/regulator/arizona-regulator.txt   |3 +-
 Documentation/devicetree/bindings/sound/madera.txt |   67 +
 MAINTAINERS|   23 +
 drivers/gpio/Kconfig   |6 +
 drivers/gpio/Makefile  |1 +
 drivers/gpio/gpio-madera.c |  196 +
 drivers/irqchip/Kconfig|3 +
 drivers/irqchip/Makefile   |1 +
 drivers/irqchip/irq-madera.c   |  301 ++
 drivers/mfd/Kconfig|   48 +
 drivers/mfd/Makefile   |   13 +
 drivers/mfd/cs47l35-tables.c   | 1610 +++
 drivers/mfd/cs47l85-tables.c   | 3010 +
 drivers/mfd/cs47l90-tables.c   | 2675 
 drivers/mfd/madera-core.c  |  617 +++
 drivers/mfd/madera-i2c.c   |  135 +
 drivers/mfd/madera-spi.c   |  135 +
 drivers/mfd/madera.h   |   54 +
 drivers/pinctrl/Kconfig|1 +
 drivers/pinctrl/Makefile   |1 +
 drivers/pinctrl/cirrus/Kconfig |   15 +
 drivers/pinctrl/cirrus/Makefile|   11 +
 drivers/pinctrl/cirrus/pinctrl-cs47l35.c   |   46 +
 drivers/pinctrl/cirrus/pinctrl-cs47l85.c   |   60 +
 drivers/pinctrl/cirrus/pinctrl-cs47l90.c   |   58 +
 drivers/pinctrl/cirrus/pinctrl-madera.c| 1074 +
 drivers/pinctrl/cirrus/pinctrl-madera.h|   40 +
 drivers/regulator/Kconfig  |   15 +-
 drivers/regulator/arizona-ldo1.c   |   82 +-
 drivers/regulator/arizona-micsupp.c|   71 +-
 include/dt-bindings/sound/madera.h |   27 +
 include/linux/irqchip/irq-madera-pdata.h   |   23 +
 include/linux/irqchip/irq-madera.h |   96 +
 include/linux/mfd/madera/core.h|  179 +
 include/linux/mfd/madera/pdata.h   |   61 +
 include/linux/mfd/madera/registers.h   | 3987 ++
 include/sound/madera-pdata.h   |   61 +
 sound/soc/codecs/Kconfig   |   23 +
 sound/soc/codecs/Makefile  |8 +
 sound/soc/codecs/cs47l35.c | 1747 
 sound/soc/codecs/cs47l85.c | 2722 
 sound/soc/codecs/cs47l90.c | 2661 
 sound/soc/codecs/madera.c  | 4438 
 sound/soc/codecs/madera.h  |  470 +++
 46 files changed, 27066 insertions(+), 10 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/madera.txt
 create mode 100644 
Documentation/devicetree/bindings/pinctrl/cirrus,madera-pinctrl.txt
 

[PATCH v4 00/17] Add support for Cirrus Logic CS47L35/L85/L90/L91 codecs

2017-07-28 Thread Richard Fitzgerald
The Cirrus Logic CS47L35, CS47L85, CS47L90/91 codecs are complex audio SoC
devices. In addition to the core audio capability they have onboard GPIO,
regulators, DSPs and interrupt controller and a large register map space
accessed over SPI or I2C. This family of codecs is based around common IP
blocks and they are managed by a set of common drivers referred to as "Madera".

Summary of changes since V3:
- Manually stripped register definitions we're not using right now from 
  registers.h to reduce the size and included some explanation in the
  commit message for why we do it the way we do
- Fixed review comments on MFD code
- Fixed Kconfig dependency error on pinctrl (missing dependency in MFD)
- minor bugfixes to routing in CS47L85 and CS47L90 codec drivers


Richard Fitzgerald (17):
  mfd: madera: Add register definitions for Cirrus Logic Madera codecs
  mfd: madera: Add DT bindings for Cirrus Logic Madera codecs
  mfd: madera: Add common support for Cirrus Logic Madera codecs
  mfd: madera: Register map tables for Cirrus Logic CS47L35
  mfd: madera: Register map tables for Cirrus Logic CS47L85
  mfd: madera: Register map tables for Cirrus Logic CS47L90/91
  regulator: arizona-micsupp: Add support for Cirrus Logic Madera codecs
  regulator: arizona-ldo1: Add support for Cirrus Logic Madera codecs
  irqchip: Add driver for Cirrus Logic Madera codecs
  pinctrl: madera: Add DT bindings for Cirrus Logic Madera codecs
  pinctrl: madera: Add driver for Cirrus Logic Madera codecs
  gpio: madera: Support Cirrus Logic Madera class codecs
  ASoC: madera: Add DT bindings for Cirrus Logic Madera codecs
  ASoC: madera: Add common support for Cirrus Logic Madera codecs
  ASoC: cs47l35: Add codec driver for Cirrus Logic CS47L35
  ASoC: cs47l85: Add codec driver for Cirrus Logic CS47L85
  ASoC: cs47l90: Add codec driver for Cirrus Logic CS47L90

 Documentation/devicetree/bindings/mfd/madera.txt   |  102 +
 .../bindings/pinctrl/cirrus,madera-pinctrl.txt |   99 +
 .../bindings/regulator/arizona-regulator.txt   |3 +-
 Documentation/devicetree/bindings/sound/madera.txt |   67 +
 MAINTAINERS|   23 +
 drivers/gpio/Kconfig   |6 +
 drivers/gpio/Makefile  |1 +
 drivers/gpio/gpio-madera.c |  196 +
 drivers/irqchip/Kconfig|3 +
 drivers/irqchip/Makefile   |1 +
 drivers/irqchip/irq-madera.c   |  301 ++
 drivers/mfd/Kconfig|   48 +
 drivers/mfd/Makefile   |   13 +
 drivers/mfd/cs47l35-tables.c   | 1610 +++
 drivers/mfd/cs47l85-tables.c   | 3010 +
 drivers/mfd/cs47l90-tables.c   | 2675 
 drivers/mfd/madera-core.c  |  617 +++
 drivers/mfd/madera-i2c.c   |  135 +
 drivers/mfd/madera-spi.c   |  135 +
 drivers/mfd/madera.h   |   54 +
 drivers/pinctrl/Kconfig|1 +
 drivers/pinctrl/Makefile   |1 +
 drivers/pinctrl/cirrus/Kconfig |   15 +
 drivers/pinctrl/cirrus/Makefile|   11 +
 drivers/pinctrl/cirrus/pinctrl-cs47l35.c   |   46 +
 drivers/pinctrl/cirrus/pinctrl-cs47l85.c   |   60 +
 drivers/pinctrl/cirrus/pinctrl-cs47l90.c   |   58 +
 drivers/pinctrl/cirrus/pinctrl-madera.c| 1074 +
 drivers/pinctrl/cirrus/pinctrl-madera.h|   40 +
 drivers/regulator/Kconfig  |   15 +-
 drivers/regulator/arizona-ldo1.c   |   82 +-
 drivers/regulator/arizona-micsupp.c|   71 +-
 include/dt-bindings/sound/madera.h |   27 +
 include/linux/irqchip/irq-madera-pdata.h   |   23 +
 include/linux/irqchip/irq-madera.h |   96 +
 include/linux/mfd/madera/core.h|  179 +
 include/linux/mfd/madera/pdata.h   |   61 +
 include/linux/mfd/madera/registers.h   | 3987 ++
 include/sound/madera-pdata.h   |   61 +
 sound/soc/codecs/Kconfig   |   23 +
 sound/soc/codecs/Makefile  |8 +
 sound/soc/codecs/cs47l35.c | 1747 
 sound/soc/codecs/cs47l85.c | 2722 
 sound/soc/codecs/cs47l90.c | 2661 
 sound/soc/codecs/madera.c  | 4438 
 sound/soc/codecs/madera.h  |  470 +++
 46 files changed, 27066 insertions(+), 10 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/madera.txt
 create mode 100644 
Documentation/devicetree/bindings/pinctrl/cirrus,madera-pinctrl.txt
 

[PATCH v4 16/17] ASoC: cs47l85: Add codec driver for Cirrus Logic CS47L85

2017-07-28 Thread Richard Fitzgerald
Adds the codec driver for the CS47L85 SmartCodec. This is a
multi-functional codec based on the Cirrus Logic Madera platform.

Signed-off-by: Nariman Poushin 
Signed-off-by: Charles Keepax 
Signed-off-by: Richard Fitzgerald 
---
Changes since V3:
- Fixed errors in the routing of ISRC3/4 to clock domain widgets
 sound/soc/codecs/Kconfig   |6 +
 sound/soc/codecs/Makefile  |2 +
 sound/soc/codecs/cs47l85.c | 2722 
 3 files changed, 2730 insertions(+)
 create mode 100644 sound/soc/codecs/cs47l85.c

diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index e9f2c2a8..37b17c6 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -63,6 +63,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_CS4349 if I2C
select SND_SOC_CS47L24 if MFD_CS47L24
select SND_SOC_CS47L35 if MFD_CS47L35
+   select SND_SOC_CS47L85 if MFD_CS47L85
select SND_SOC_CS53L30 if I2C
select SND_SOC_CX20442 if TTY
select SND_SOC_DA7210 if SND_SOC_I2C_AND_SPI
@@ -501,6 +502,9 @@ config SND_SOC_CS47L24
 config SND_SOC_CS47L35
tristate
 
+config SND_SOC_CS47L85
+   tristate
+
 # Cirrus Logic Quad-Channel ADC
 config SND_SOC_CS53L30
tristate "Cirrus Logic CS53L30 CODEC"
@@ -593,7 +597,9 @@ config SND_SOC_LM49453
 config SND_SOC_MADERA
tristate
default y if SND_SOC_CS47L35=y
+   default y if SND_SOC_CS47L85=y
default m if SND_SOC_CS47L35=m
+   default m if SND_SOC_CS47L85=m
 
 config SND_SOC_MAX98088
tristate
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index 50e9033..efc7f2e 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -56,6 +56,7 @@ snd-soc-cs42xx8-i2c-objs := cs42xx8-i2c.o
 snd-soc-cs4349-objs := cs4349.o
 snd-soc-cs47l24-objs := cs47l24.o
 snd-soc-cs47l35-objs := cs47l35.o
+snd-soc-cs47l85-objs := cs47l85.o
 snd-soc-cs53l30-objs := cs53l30.o
 snd-soc-cx20442-objs := cx20442.o
 snd-soc-da7210-objs := da7210.o
@@ -296,6 +297,7 @@ obj-$(CONFIG_SND_SOC_CS42XX8_I2C) += snd-soc-cs42xx8-i2c.o
 obj-$(CONFIG_SND_SOC_CS4349)   += snd-soc-cs4349.o
 obj-$(CONFIG_SND_SOC_CS47L24)  += snd-soc-cs47l24.o
 obj-$(CONFIG_SND_SOC_CS47L35)  += snd-soc-cs47l35.o
+obj-$(CONFIG_SND_SOC_CS47L85)  += snd-soc-cs47l85.o
 obj-$(CONFIG_SND_SOC_CS53L30)  += snd-soc-cs53l30.o
 obj-$(CONFIG_SND_SOC_CX20442)  += snd-soc-cx20442.o
 obj-$(CONFIG_SND_SOC_DA7210)   += snd-soc-da7210.o
diff --git a/sound/soc/codecs/cs47l85.c b/sound/soc/codecs/cs47l85.c
new file mode 100644
index 000..72045de
--- /dev/null
+++ b/sound/soc/codecs/cs47l85.c
@@ -0,0 +1,2722 @@
+/*
+ * cs47l85.c  --  ALSA SoC Audio driver for CS47L85 codecs
+ *
+ * Copyright 2015-2017 Cirrus Logic Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "madera.h"
+#include "wm_adsp.h"
+
+#define CS47L85_NUM_ADSP   7
+#define CS47L85_MONO_OUTPUTS   4
+
+struct cs47l85 {
+   struct madera_priv core;
+   struct madera_fll fll[3];
+};
+
+static const struct wm_adsp_region cs47l85_dsp1_regions[] = {
+   { .type = WMFW_ADSP2_PM, .base = 0x08 },
+   { .type = WMFW_ADSP2_ZM, .base = 0x0e },
+   { .type = WMFW_ADSP2_XM, .base = 0x0a },
+   { .type = WMFW_ADSP2_YM, .base = 0x0c },
+};
+
+static const struct wm_adsp_region cs47l85_dsp2_regions[] = {
+   { .type = WMFW_ADSP2_PM, .base = 0x10 },
+   { .type = WMFW_ADSP2_ZM, .base = 0x16 },
+   { .type = WMFW_ADSP2_XM, .base = 0x12 },
+   { .type = WMFW_ADSP2_YM, .base = 0x14 },
+};
+
+static const struct wm_adsp_region cs47l85_dsp3_regions[] = {
+   { .type = WMFW_ADSP2_PM, .base = 0x18 },
+   { .type = WMFW_ADSP2_ZM, .base = 0x1e },
+   { .type = WMFW_ADSP2_XM, .base = 0x1a },
+   { .type = WMFW_ADSP2_YM, .base = 0x1c },
+};
+
+static const struct wm_adsp_region cs47l85_dsp4_regions[] = {
+   { .type = WMFW_ADSP2_PM, .base = 0x20 },
+   { .type = WMFW_ADSP2_ZM, .base = 0x26 },
+   { .type = WMFW_ADSP2_XM, .base = 0x22 },
+   { .type = WMFW_ADSP2_YM, .base = 0x24 },
+};
+
+static const struct wm_adsp_region cs47l85_dsp5_regions[] = {
+   { .type = WMFW_ADSP2_PM, .base = 0x28 },
+   { .type = WMFW_ADSP2_ZM, .base = 0x2e },
+   { .type = WMFW_ADSP2_XM, .base = 0x2a },
+   { .type = WMFW_ADSP2_YM, .base = 0x2c },
+};
+
+static const struct wm_adsp_region cs47l85_dsp6_regions[] = {
+   { .type = WMFW_ADSP2_PM, .base = 0x30 },
+   { .type = 

[PATCH v4 04/17] mfd: madera: Register map tables for Cirrus Logic CS47L35

2017-07-28 Thread Richard Fitzgerald
Regmap configuration tables for Cirrus Logic CS47L35 codecs.

Signed-off-by: Piotr Stankiewicz 
Signed-off-by: Richard Fitzgerald 
Signed-off-by: Charles Keepax 
---
Changes since V3:
- fixed missing FLL1_EFS2 register
- converted EQ registers to a case range because registers.h has been
  stripped to only define the first and last register of each EQ
The rest of the file was
Acked-for-MFD-by: Lee Jones 
 drivers/mfd/Kconfig  |7 +
 drivers/mfd/Makefile |3 +
 drivers/mfd/cs47l35-tables.c | 1610 ++
 3 files changed, 1620 insertions(+)
 create mode 100644 drivers/mfd/cs47l35-tables.c

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 9ca7174..8061ac9 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -235,6 +235,13 @@ config MFD_MADERA_SPI
  Support for the Cirrus Logic Madera platform audio SoC
  core functionality controlled via SPI.
 
+config MFD_CS47L35
+   bool "Cirrus Logic CS47L35"
+   select PINCTRL_CS47L35
+   depends on MFD_MADERA
+   help
+ Support for Cirrus Logic CS47L35 Smart Codec
+
 config MFD_ASIC3
bool "Compaq ASIC3"
depends on GPIOLIB && ARM
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 71c658a..aa18017 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -74,6 +74,9 @@ wm8994-objs   := wm8994-core.o wm8994-irq.o 
wm8994-regmap.o
 obj-$(CONFIG_MFD_WM8994)   += wm8994.o
 
 obj-$(CONFIG_MFD_MADERA)   += madera-core.o
+ifeq ($(CONFIG_MFD_CS47L35),y)
+obj-$(CONFIG_MFD_MADERA)   += cs47l35-tables.o
+endif
 obj-$(CONFIG_MFD_MADERA_I2C)   += madera-i2c.o
 obj-$(CONFIG_MFD_MADERA_SPI)   += madera-spi.o
 
diff --git a/drivers/mfd/cs47l35-tables.c b/drivers/mfd/cs47l35-tables.c
new file mode 100644
index 000..fdaf6de
--- /dev/null
+++ b/drivers/mfd/cs47l35-tables.c
@@ -0,0 +1,1610 @@
+/*
+ * Regmap tables for CS47L35 codec
+ *
+ * Copyright 2015-2016 Cirrus Logic
+ *
+ * Author: Piotr Stankiewicz 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "madera.h"
+
+static const struct reg_sequence cs47l35_reva_16_patch[] = {
+   { 0x460, 0x0c40 },
+   { 0x461, 0xcd1a },
+   { 0x462, 0x0c40 },
+   { 0x463, 0xb53b },
+   { 0x464, 0x0c40 },
+   { 0x465, 0x7503 },
+   { 0x466, 0x0c40 },
+   { 0x467, 0x4a41 },
+   { 0x468, 0x0041 },
+   { 0x469, 0x3491 },
+   { 0x46a, 0x0841 },
+   { 0x46b, 0x1f50 },
+   { 0x46c, 0x0446 },
+   { 0x46d, 0x14ed },
+   { 0x46e, 0x0446 },
+   { 0x46f, 0x1455 },
+   { 0x470, 0x04c6 },
+   { 0x471, 0x1220 },
+   { 0x472, 0x04c6 },
+   { 0x473, 0x040f },
+   { 0x474, 0x04ce },
+   { 0x475, 0x0339 },
+   { 0x476, 0x05df },
+   { 0x477, 0x028f },
+   { 0x478, 0x05df },
+   { 0x479, 0x0209 },
+   { 0x47a, 0x05df },
+   { 0x47b, 0x00cf },
+   { 0x47c, 0x05df },
+   { 0x47d, 0x0001 },
+   { 0x47e, 0x07ff },
+};
+
+int cs47l35_patch(struct madera *madera)
+{
+   int ret;
+
+   ret = regmap_register_patch(madera->regmap, cs47l35_reva_16_patch,
+   ARRAY_SIZE(cs47l35_reva_16_patch));
+   if (ret < 0)
+   dev_err(madera->dev, "Error applying patch: %d\n", ret);
+
+   return ret;
+}
+EXPORT_SYMBOL_GPL(cs47l35_patch);
+
+static const struct reg_default cs47l35_reg_default[] = {
+   { 0x0020, 0x }, /* R32 (0x20) - Tone Generator 1 */
+   { 0x0021, 0x1000 }, /* R33 (0x21) - Tone Generator 2 */
+   { 0x0022, 0x }, /* R34 (0x22) - Tone Generator 3 */
+   { 0x0023, 0x1000 }, /* R35 (0x23) - Tone Generator 4 */
+   { 0x0024, 0x }, /* R36 (0x24) - Tone Generator 5 */
+   { 0x0030, 0x }, /* R48 (0x30) - PWM Drive 1 */
+   { 0x0031, 0x0100 }, /* R49 (0x31) - PWM Drive 2 */
+   { 0x0032, 0x0100 }, /* R50 (0x32) - PWM Drive 3 */
+   { 0x0061, 0x01ff }, /* R97 (0x61) - Sample Rate Sequence Select 1 */
+   { 0x0062, 0x01ff }, /* R98 (0x62) - Sample Rate Sequence Select 2 */
+   { 0x0063, 0x01ff }, /* R99 (0x63) - Sample Rate Sequence Select 3 */
+   { 0x0064, 0x01ff }, /* R100 (0x64) - Sample Rate Sequence Select 4*/
+   { 0x0066, 0x01ff }, /* R102 (0x66) - Always On Triggers Sequence 
Select 1*/
+   { 0x0067, 0x01ff }, /* R103 (0x67) - Always On Triggers Sequence 
Select 2*/
+   { 0x0090, 0x }, /* R144 (0x90) - Haptics Control 1 */
+   { 0x0091, 0x7fff }, /* R145 (0x91) - Haptics Control 2 */
+   

[PATCH v4 16/17] ASoC: cs47l85: Add codec driver for Cirrus Logic CS47L85

2017-07-28 Thread Richard Fitzgerald
Adds the codec driver for the CS47L85 SmartCodec. This is a
multi-functional codec based on the Cirrus Logic Madera platform.

Signed-off-by: Nariman Poushin 
Signed-off-by: Charles Keepax 
Signed-off-by: Richard Fitzgerald 
---
Changes since V3:
- Fixed errors in the routing of ISRC3/4 to clock domain widgets
 sound/soc/codecs/Kconfig   |6 +
 sound/soc/codecs/Makefile  |2 +
 sound/soc/codecs/cs47l85.c | 2722 
 3 files changed, 2730 insertions(+)
 create mode 100644 sound/soc/codecs/cs47l85.c

diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index e9f2c2a8..37b17c6 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -63,6 +63,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_CS4349 if I2C
select SND_SOC_CS47L24 if MFD_CS47L24
select SND_SOC_CS47L35 if MFD_CS47L35
+   select SND_SOC_CS47L85 if MFD_CS47L85
select SND_SOC_CS53L30 if I2C
select SND_SOC_CX20442 if TTY
select SND_SOC_DA7210 if SND_SOC_I2C_AND_SPI
@@ -501,6 +502,9 @@ config SND_SOC_CS47L24
 config SND_SOC_CS47L35
tristate
 
+config SND_SOC_CS47L85
+   tristate
+
 # Cirrus Logic Quad-Channel ADC
 config SND_SOC_CS53L30
tristate "Cirrus Logic CS53L30 CODEC"
@@ -593,7 +597,9 @@ config SND_SOC_LM49453
 config SND_SOC_MADERA
tristate
default y if SND_SOC_CS47L35=y
+   default y if SND_SOC_CS47L85=y
default m if SND_SOC_CS47L35=m
+   default m if SND_SOC_CS47L85=m
 
 config SND_SOC_MAX98088
tristate
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index 50e9033..efc7f2e 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -56,6 +56,7 @@ snd-soc-cs42xx8-i2c-objs := cs42xx8-i2c.o
 snd-soc-cs4349-objs := cs4349.o
 snd-soc-cs47l24-objs := cs47l24.o
 snd-soc-cs47l35-objs := cs47l35.o
+snd-soc-cs47l85-objs := cs47l85.o
 snd-soc-cs53l30-objs := cs53l30.o
 snd-soc-cx20442-objs := cx20442.o
 snd-soc-da7210-objs := da7210.o
@@ -296,6 +297,7 @@ obj-$(CONFIG_SND_SOC_CS42XX8_I2C) += snd-soc-cs42xx8-i2c.o
 obj-$(CONFIG_SND_SOC_CS4349)   += snd-soc-cs4349.o
 obj-$(CONFIG_SND_SOC_CS47L24)  += snd-soc-cs47l24.o
 obj-$(CONFIG_SND_SOC_CS47L35)  += snd-soc-cs47l35.o
+obj-$(CONFIG_SND_SOC_CS47L85)  += snd-soc-cs47l85.o
 obj-$(CONFIG_SND_SOC_CS53L30)  += snd-soc-cs53l30.o
 obj-$(CONFIG_SND_SOC_CX20442)  += snd-soc-cx20442.o
 obj-$(CONFIG_SND_SOC_DA7210)   += snd-soc-da7210.o
diff --git a/sound/soc/codecs/cs47l85.c b/sound/soc/codecs/cs47l85.c
new file mode 100644
index 000..72045de
--- /dev/null
+++ b/sound/soc/codecs/cs47l85.c
@@ -0,0 +1,2722 @@
+/*
+ * cs47l85.c  --  ALSA SoC Audio driver for CS47L85 codecs
+ *
+ * Copyright 2015-2017 Cirrus Logic Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "madera.h"
+#include "wm_adsp.h"
+
+#define CS47L85_NUM_ADSP   7
+#define CS47L85_MONO_OUTPUTS   4
+
+struct cs47l85 {
+   struct madera_priv core;
+   struct madera_fll fll[3];
+};
+
+static const struct wm_adsp_region cs47l85_dsp1_regions[] = {
+   { .type = WMFW_ADSP2_PM, .base = 0x08 },
+   { .type = WMFW_ADSP2_ZM, .base = 0x0e },
+   { .type = WMFW_ADSP2_XM, .base = 0x0a },
+   { .type = WMFW_ADSP2_YM, .base = 0x0c },
+};
+
+static const struct wm_adsp_region cs47l85_dsp2_regions[] = {
+   { .type = WMFW_ADSP2_PM, .base = 0x10 },
+   { .type = WMFW_ADSP2_ZM, .base = 0x16 },
+   { .type = WMFW_ADSP2_XM, .base = 0x12 },
+   { .type = WMFW_ADSP2_YM, .base = 0x14 },
+};
+
+static const struct wm_adsp_region cs47l85_dsp3_regions[] = {
+   { .type = WMFW_ADSP2_PM, .base = 0x18 },
+   { .type = WMFW_ADSP2_ZM, .base = 0x1e },
+   { .type = WMFW_ADSP2_XM, .base = 0x1a },
+   { .type = WMFW_ADSP2_YM, .base = 0x1c },
+};
+
+static const struct wm_adsp_region cs47l85_dsp4_regions[] = {
+   { .type = WMFW_ADSP2_PM, .base = 0x20 },
+   { .type = WMFW_ADSP2_ZM, .base = 0x26 },
+   { .type = WMFW_ADSP2_XM, .base = 0x22 },
+   { .type = WMFW_ADSP2_YM, .base = 0x24 },
+};
+
+static const struct wm_adsp_region cs47l85_dsp5_regions[] = {
+   { .type = WMFW_ADSP2_PM, .base = 0x28 },
+   { .type = WMFW_ADSP2_ZM, .base = 0x2e },
+   { .type = WMFW_ADSP2_XM, .base = 0x2a },
+   { .type = WMFW_ADSP2_YM, .base = 0x2c },
+};
+
+static const struct wm_adsp_region cs47l85_dsp6_regions[] = {
+   { .type = WMFW_ADSP2_PM, .base = 0x30 },
+   { .type = WMFW_ADSP2_ZM, .base = 0x36 },
+   { .type = WMFW_ADSP2_XM, .base = 0x32 },
+   { .type = 

[PATCH v4 04/17] mfd: madera: Register map tables for Cirrus Logic CS47L35

2017-07-28 Thread Richard Fitzgerald
Regmap configuration tables for Cirrus Logic CS47L35 codecs.

Signed-off-by: Piotr Stankiewicz 
Signed-off-by: Richard Fitzgerald 
Signed-off-by: Charles Keepax 
---
Changes since V3:
- fixed missing FLL1_EFS2 register
- converted EQ registers to a case range because registers.h has been
  stripped to only define the first and last register of each EQ
The rest of the file was
Acked-for-MFD-by: Lee Jones 
 drivers/mfd/Kconfig  |7 +
 drivers/mfd/Makefile |3 +
 drivers/mfd/cs47l35-tables.c | 1610 ++
 3 files changed, 1620 insertions(+)
 create mode 100644 drivers/mfd/cs47l35-tables.c

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 9ca7174..8061ac9 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -235,6 +235,13 @@ config MFD_MADERA_SPI
  Support for the Cirrus Logic Madera platform audio SoC
  core functionality controlled via SPI.
 
+config MFD_CS47L35
+   bool "Cirrus Logic CS47L35"
+   select PINCTRL_CS47L35
+   depends on MFD_MADERA
+   help
+ Support for Cirrus Logic CS47L35 Smart Codec
+
 config MFD_ASIC3
bool "Compaq ASIC3"
depends on GPIOLIB && ARM
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 71c658a..aa18017 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -74,6 +74,9 @@ wm8994-objs   := wm8994-core.o wm8994-irq.o 
wm8994-regmap.o
 obj-$(CONFIG_MFD_WM8994)   += wm8994.o
 
 obj-$(CONFIG_MFD_MADERA)   += madera-core.o
+ifeq ($(CONFIG_MFD_CS47L35),y)
+obj-$(CONFIG_MFD_MADERA)   += cs47l35-tables.o
+endif
 obj-$(CONFIG_MFD_MADERA_I2C)   += madera-i2c.o
 obj-$(CONFIG_MFD_MADERA_SPI)   += madera-spi.o
 
diff --git a/drivers/mfd/cs47l35-tables.c b/drivers/mfd/cs47l35-tables.c
new file mode 100644
index 000..fdaf6de
--- /dev/null
+++ b/drivers/mfd/cs47l35-tables.c
@@ -0,0 +1,1610 @@
+/*
+ * Regmap tables for CS47L35 codec
+ *
+ * Copyright 2015-2016 Cirrus Logic
+ *
+ * Author: Piotr Stankiewicz 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "madera.h"
+
+static const struct reg_sequence cs47l35_reva_16_patch[] = {
+   { 0x460, 0x0c40 },
+   { 0x461, 0xcd1a },
+   { 0x462, 0x0c40 },
+   { 0x463, 0xb53b },
+   { 0x464, 0x0c40 },
+   { 0x465, 0x7503 },
+   { 0x466, 0x0c40 },
+   { 0x467, 0x4a41 },
+   { 0x468, 0x0041 },
+   { 0x469, 0x3491 },
+   { 0x46a, 0x0841 },
+   { 0x46b, 0x1f50 },
+   { 0x46c, 0x0446 },
+   { 0x46d, 0x14ed },
+   { 0x46e, 0x0446 },
+   { 0x46f, 0x1455 },
+   { 0x470, 0x04c6 },
+   { 0x471, 0x1220 },
+   { 0x472, 0x04c6 },
+   { 0x473, 0x040f },
+   { 0x474, 0x04ce },
+   { 0x475, 0x0339 },
+   { 0x476, 0x05df },
+   { 0x477, 0x028f },
+   { 0x478, 0x05df },
+   { 0x479, 0x0209 },
+   { 0x47a, 0x05df },
+   { 0x47b, 0x00cf },
+   { 0x47c, 0x05df },
+   { 0x47d, 0x0001 },
+   { 0x47e, 0x07ff },
+};
+
+int cs47l35_patch(struct madera *madera)
+{
+   int ret;
+
+   ret = regmap_register_patch(madera->regmap, cs47l35_reva_16_patch,
+   ARRAY_SIZE(cs47l35_reva_16_patch));
+   if (ret < 0)
+   dev_err(madera->dev, "Error applying patch: %d\n", ret);
+
+   return ret;
+}
+EXPORT_SYMBOL_GPL(cs47l35_patch);
+
+static const struct reg_default cs47l35_reg_default[] = {
+   { 0x0020, 0x }, /* R32 (0x20) - Tone Generator 1 */
+   { 0x0021, 0x1000 }, /* R33 (0x21) - Tone Generator 2 */
+   { 0x0022, 0x }, /* R34 (0x22) - Tone Generator 3 */
+   { 0x0023, 0x1000 }, /* R35 (0x23) - Tone Generator 4 */
+   { 0x0024, 0x }, /* R36 (0x24) - Tone Generator 5 */
+   { 0x0030, 0x }, /* R48 (0x30) - PWM Drive 1 */
+   { 0x0031, 0x0100 }, /* R49 (0x31) - PWM Drive 2 */
+   { 0x0032, 0x0100 }, /* R50 (0x32) - PWM Drive 3 */
+   { 0x0061, 0x01ff }, /* R97 (0x61) - Sample Rate Sequence Select 1 */
+   { 0x0062, 0x01ff }, /* R98 (0x62) - Sample Rate Sequence Select 2 */
+   { 0x0063, 0x01ff }, /* R99 (0x63) - Sample Rate Sequence Select 3 */
+   { 0x0064, 0x01ff }, /* R100 (0x64) - Sample Rate Sequence Select 4*/
+   { 0x0066, 0x01ff }, /* R102 (0x66) - Always On Triggers Sequence 
Select 1*/
+   { 0x0067, 0x01ff }, /* R103 (0x67) - Always On Triggers Sequence 
Select 2*/
+   { 0x0090, 0x }, /* R144 (0x90) - Haptics Control 1 */
+   { 0x0091, 0x7fff }, /* R145 (0x91) - Haptics Control 2 */
+   { 0x0092, 0x }, /* R146 (0x92) - Haptics phase 1 intensity */
+   { 0x0093, 0x }, /* R147 (0x93) - Haptics phase 1 duration */
+   { 

[PATCH v4 15/17] ASoC: cs47l35: Add codec driver for Cirrus Logic CS47L35

2017-07-28 Thread Richard Fitzgerald
Adds the codec driver for the CS47L35 SmartCodec. This is a
multi-functional codec based on the Cirrus Logic Madera platform.

Signed-off-by: Piotr Stankiewicz 
Signed-off-by: Richard Fitzgerald 
Signed-off-by: Charles Keepax 
---
No changes since V3
 sound/soc/codecs/Kconfig   |6 +
 sound/soc/codecs/Makefile  |2 +
 sound/soc/codecs/cs47l35.c | 1747 
 3 files changed, 1755 insertions(+)
 create mode 100644 sound/soc/codecs/cs47l35.c

diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index bea30bf..e9f2c2a8 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -62,6 +62,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_CS42XX8_I2C if I2C
select SND_SOC_CS4349 if I2C
select SND_SOC_CS47L24 if MFD_CS47L24
+   select SND_SOC_CS47L35 if MFD_CS47L35
select SND_SOC_CS53L30 if I2C
select SND_SOC_CX20442 if TTY
select SND_SOC_DA7210 if SND_SOC_I2C_AND_SPI
@@ -497,6 +498,9 @@ config SND_SOC_CS4349
 config SND_SOC_CS47L24
tristate
 
+config SND_SOC_CS47L35
+   tristate
+
 # Cirrus Logic Quad-Channel ADC
 config SND_SOC_CS53L30
tristate "Cirrus Logic CS53L30 CODEC"
@@ -588,6 +592,8 @@ config SND_SOC_LM49453
 
 config SND_SOC_MADERA
tristate
+   default y if SND_SOC_CS47L35=y
+   default m if SND_SOC_CS47L35=m
 
 config SND_SOC_MAX98088
tristate
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index b34e01f..50e9033 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -55,6 +55,7 @@ snd-soc-cs42xx8-objs := cs42xx8.o
 snd-soc-cs42xx8-i2c-objs := cs42xx8-i2c.o
 snd-soc-cs4349-objs := cs4349.o
 snd-soc-cs47l24-objs := cs47l24.o
+snd-soc-cs47l35-objs := cs47l35.o
 snd-soc-cs53l30-objs := cs53l30.o
 snd-soc-cx20442-objs := cx20442.o
 snd-soc-da7210-objs := da7210.o
@@ -294,6 +295,7 @@ obj-$(CONFIG_SND_SOC_CS42XX8)   += snd-soc-cs42xx8.o
 obj-$(CONFIG_SND_SOC_CS42XX8_I2C) += snd-soc-cs42xx8-i2c.o
 obj-$(CONFIG_SND_SOC_CS4349)   += snd-soc-cs4349.o
 obj-$(CONFIG_SND_SOC_CS47L24)  += snd-soc-cs47l24.o
+obj-$(CONFIG_SND_SOC_CS47L35)  += snd-soc-cs47l35.o
 obj-$(CONFIG_SND_SOC_CS53L30)  += snd-soc-cs53l30.o
 obj-$(CONFIG_SND_SOC_CX20442)  += snd-soc-cx20442.o
 obj-$(CONFIG_SND_SOC_DA7210)   += snd-soc-da7210.o
diff --git a/sound/soc/codecs/cs47l35.c b/sound/soc/codecs/cs47l35.c
new file mode 100644
index 000..50ecc44
--- /dev/null
+++ b/sound/soc/codecs/cs47l35.c
@@ -0,0 +1,1747 @@
+/*
+ * cs47l35.c  --  ALSA SoC Audio driver for CS47L35 codecs
+ *
+ * Copyright 2015-2017 Cirrus Logic Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "madera.h"
+#include "wm_adsp.h"
+
+#define CS47L35_NUM_ADSP   3
+#define CS47L35_MONO_OUTPUTS   1
+
+struct cs47l35 {
+   struct madera_priv core;
+   struct madera_fll fll;
+};
+
+static const struct wm_adsp_region cs47l35_dsp1_regions[] = {
+   { .type = WMFW_ADSP2_PM, .base = 0x08 },
+   { .type = WMFW_ADSP2_ZM, .base = 0x0e },
+   { .type = WMFW_ADSP2_XM, .base = 0x0a },
+   { .type = WMFW_ADSP2_YM, .base = 0x0c },
+};
+
+static const struct wm_adsp_region cs47l35_dsp2_regions[] = {
+   { .type = WMFW_ADSP2_PM, .base = 0x10 },
+   { .type = WMFW_ADSP2_ZM, .base = 0x16 },
+   { .type = WMFW_ADSP2_XM, .base = 0x12 },
+   { .type = WMFW_ADSP2_YM, .base = 0x14 },
+};
+
+static const struct wm_adsp_region cs47l35_dsp3_regions[] = {
+   { .type = WMFW_ADSP2_PM, .base = 0x18 },
+   { .type = WMFW_ADSP2_ZM, .base = 0x1e },
+   { .type = WMFW_ADSP2_XM, .base = 0x1a },
+   { .type = WMFW_ADSP2_YM, .base = 0x1c },
+};
+
+static const struct wm_adsp_region *cs47l35_dsp_regions[] = {
+   cs47l35_dsp1_regions,
+   cs47l35_dsp2_regions,
+   cs47l35_dsp3_regions,
+};
+
+static const int wm_adsp2_control_bases[] = {
+   MADERA_DSP1_CONFIG_1,
+   MADERA_DSP2_CONFIG_1,
+   MADERA_DSP3_CONFIG_1,
+};
+
+static const char * const cs47l35_outdemux_texts[] = {
+   "HPOUT",
+   "EPOUT",
+};
+
+static SOC_ENUM_SINGLE_DECL(cs47l35_outdemux_enum, SND_SOC_NOPM, 0,
+   cs47l35_outdemux_texts);
+
+static const struct snd_kcontrol_new cs47l35_outdemux =
+   SOC_DAPM_ENUM_EXT("HPOUT1 Demux", cs47l35_outdemux_enum,
+ snd_soc_dapm_get_enum_double, madera_out1_demux_put);
+
+static int cs47l35_adsp_power_ev(struct snd_soc_dapm_widget *w,
+struct 

[PATCH v4 15/17] ASoC: cs47l35: Add codec driver for Cirrus Logic CS47L35

2017-07-28 Thread Richard Fitzgerald
Adds the codec driver for the CS47L35 SmartCodec. This is a
multi-functional codec based on the Cirrus Logic Madera platform.

Signed-off-by: Piotr Stankiewicz 
Signed-off-by: Richard Fitzgerald 
Signed-off-by: Charles Keepax 
---
No changes since V3
 sound/soc/codecs/Kconfig   |6 +
 sound/soc/codecs/Makefile  |2 +
 sound/soc/codecs/cs47l35.c | 1747 
 3 files changed, 1755 insertions(+)
 create mode 100644 sound/soc/codecs/cs47l35.c

diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index bea30bf..e9f2c2a8 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -62,6 +62,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_CS42XX8_I2C if I2C
select SND_SOC_CS4349 if I2C
select SND_SOC_CS47L24 if MFD_CS47L24
+   select SND_SOC_CS47L35 if MFD_CS47L35
select SND_SOC_CS53L30 if I2C
select SND_SOC_CX20442 if TTY
select SND_SOC_DA7210 if SND_SOC_I2C_AND_SPI
@@ -497,6 +498,9 @@ config SND_SOC_CS4349
 config SND_SOC_CS47L24
tristate
 
+config SND_SOC_CS47L35
+   tristate
+
 # Cirrus Logic Quad-Channel ADC
 config SND_SOC_CS53L30
tristate "Cirrus Logic CS53L30 CODEC"
@@ -588,6 +592,8 @@ config SND_SOC_LM49453
 
 config SND_SOC_MADERA
tristate
+   default y if SND_SOC_CS47L35=y
+   default m if SND_SOC_CS47L35=m
 
 config SND_SOC_MAX98088
tristate
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index b34e01f..50e9033 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -55,6 +55,7 @@ snd-soc-cs42xx8-objs := cs42xx8.o
 snd-soc-cs42xx8-i2c-objs := cs42xx8-i2c.o
 snd-soc-cs4349-objs := cs4349.o
 snd-soc-cs47l24-objs := cs47l24.o
+snd-soc-cs47l35-objs := cs47l35.o
 snd-soc-cs53l30-objs := cs53l30.o
 snd-soc-cx20442-objs := cx20442.o
 snd-soc-da7210-objs := da7210.o
@@ -294,6 +295,7 @@ obj-$(CONFIG_SND_SOC_CS42XX8)   += snd-soc-cs42xx8.o
 obj-$(CONFIG_SND_SOC_CS42XX8_I2C) += snd-soc-cs42xx8-i2c.o
 obj-$(CONFIG_SND_SOC_CS4349)   += snd-soc-cs4349.o
 obj-$(CONFIG_SND_SOC_CS47L24)  += snd-soc-cs47l24.o
+obj-$(CONFIG_SND_SOC_CS47L35)  += snd-soc-cs47l35.o
 obj-$(CONFIG_SND_SOC_CS53L30)  += snd-soc-cs53l30.o
 obj-$(CONFIG_SND_SOC_CX20442)  += snd-soc-cx20442.o
 obj-$(CONFIG_SND_SOC_DA7210)   += snd-soc-da7210.o
diff --git a/sound/soc/codecs/cs47l35.c b/sound/soc/codecs/cs47l35.c
new file mode 100644
index 000..50ecc44
--- /dev/null
+++ b/sound/soc/codecs/cs47l35.c
@@ -0,0 +1,1747 @@
+/*
+ * cs47l35.c  --  ALSA SoC Audio driver for CS47L35 codecs
+ *
+ * Copyright 2015-2017 Cirrus Logic Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "madera.h"
+#include "wm_adsp.h"
+
+#define CS47L35_NUM_ADSP   3
+#define CS47L35_MONO_OUTPUTS   1
+
+struct cs47l35 {
+   struct madera_priv core;
+   struct madera_fll fll;
+};
+
+static const struct wm_adsp_region cs47l35_dsp1_regions[] = {
+   { .type = WMFW_ADSP2_PM, .base = 0x08 },
+   { .type = WMFW_ADSP2_ZM, .base = 0x0e },
+   { .type = WMFW_ADSP2_XM, .base = 0x0a },
+   { .type = WMFW_ADSP2_YM, .base = 0x0c },
+};
+
+static const struct wm_adsp_region cs47l35_dsp2_regions[] = {
+   { .type = WMFW_ADSP2_PM, .base = 0x10 },
+   { .type = WMFW_ADSP2_ZM, .base = 0x16 },
+   { .type = WMFW_ADSP2_XM, .base = 0x12 },
+   { .type = WMFW_ADSP2_YM, .base = 0x14 },
+};
+
+static const struct wm_adsp_region cs47l35_dsp3_regions[] = {
+   { .type = WMFW_ADSP2_PM, .base = 0x18 },
+   { .type = WMFW_ADSP2_ZM, .base = 0x1e },
+   { .type = WMFW_ADSP2_XM, .base = 0x1a },
+   { .type = WMFW_ADSP2_YM, .base = 0x1c },
+};
+
+static const struct wm_adsp_region *cs47l35_dsp_regions[] = {
+   cs47l35_dsp1_regions,
+   cs47l35_dsp2_regions,
+   cs47l35_dsp3_regions,
+};
+
+static const int wm_adsp2_control_bases[] = {
+   MADERA_DSP1_CONFIG_1,
+   MADERA_DSP2_CONFIG_1,
+   MADERA_DSP3_CONFIG_1,
+};
+
+static const char * const cs47l35_outdemux_texts[] = {
+   "HPOUT",
+   "EPOUT",
+};
+
+static SOC_ENUM_SINGLE_DECL(cs47l35_outdemux_enum, SND_SOC_NOPM, 0,
+   cs47l35_outdemux_texts);
+
+static const struct snd_kcontrol_new cs47l35_outdemux =
+   SOC_DAPM_ENUM_EXT("HPOUT1 Demux", cs47l35_outdemux_enum,
+ snd_soc_dapm_get_enum_double, madera_out1_demux_put);
+
+static int cs47l35_adsp_power_ev(struct snd_soc_dapm_widget *w,
+struct snd_kcontrol *kcontrol,
+int event)
+{
+   struct snd_soc_codec *codec 

[PATCH v4 13/17] ASoC: madera: Add DT bindings for Cirrus Logic Madera codecs

2017-07-28 Thread Richard Fitzgerald
The Cirrus Logic Madera codecs are a family of related codecs with
extensive digital and analogue I/O, digital mixing and routing,
signal processing and programmable DSPs.

Signed-off-by: Richard Fitzgerald 
Acked-by: Rob Herring 
---
Changes since V3:
- include-dt-bindings/sound/madera.h moved into this patch from
  patch 14 as requested. Including Rob's ack that was conditional
  on making this change.
 Documentation/devicetree/bindings/sound/madera.txt | 67 ++
 MAINTAINERS|  1 +
 include/dt-bindings/sound/madera.h | 27 +
 3 files changed, 95 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/madera.txt
 create mode 100644 include/dt-bindings/sound/madera.h

diff --git a/Documentation/devicetree/bindings/sound/madera.txt 
b/Documentation/devicetree/bindings/sound/madera.txt
new file mode 100644
index 000..1114fcf
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/madera.txt
@@ -0,0 +1,67 @@
+Cirrus Logic Madera class audio codecs
+
+This describes audio configuration bindings for these codecs.
+
+See also the core bindings for the parent MFD driver:
+See Documentation/devicetree/bindings/mfd/madera.txt
+
+and defines for values used in these bindings:
+include/dt-bindings/sound/madera.h
+
+These properties are all contained in the parent MFD node.
+
+Optional properties:
+  - cirrus,dmic-ref : Indicates how the MICBIAS pins have been externally
+connected to DMICs on each input, one cell per input.
+
+A value of 0 indicates MICVDD and is the default, other values depend on 
the
+codec:
+For CS47L35 one of the CS47L35_DMIC_REF_xxx values
+For all other codecs one of the MADERA_DMIC_REF_xxx values
+Also see the datasheet for a description of the INn_DMIC_SUP field.
+
+  - cirrus,inmode : A list of input mode settings for each input. A maximum of
+16 cells, with four cells per input in the order INnAL, INnAR INnBL INnBR.
+For non-muxed inputs the first two cells for that input set the mode for
+the left and right channel and the second two cells must be 0.
+For muxed inputs the first two cells for that input set the mode of the
+left and right A inputs and the second two cells set the mode of the left
+and right B inputs.
+Valid mode values are one of the MADERA_INMODE_xxx. If the array is shorter
+than the number of inputs the unspecified inputs default to
+MADERA_INMODE_DIFF.
+
+  - cirrus,out-mono : Mono bit for each output, must contain six cells if
+specified. A non-zero value indicates the corresponding output is mono.
+
+  - cirrus,max-channels-clocked : Maximum number of channels that I2S clocks
+will be generated for. Useful when clock master for systems where the I2S
+bus has multiple data lines.
+One cell for each AIF, use a value of zero for AIFs that should be handled
+normally.
+
+  - cirrus,pdm-fmt : PDM speaker data format, must contain 2 cells
+(OUT5 and OUT6). See the PDM_SPKn_FMT field in the datasheet for a
+description of this value.
+The second cell is ignored for codecs that do not have OUT6.
+
+  - cirrus,pdm-mute : PDM mute format, must contain 2 cells
+(OUT5 and OUT6). See the PDM_SPKn_CTRL_1 register in the datasheet for a
+description of this value.
+The second cell is ignored for codecs that do not have OUT6.
+
+Example:
+
+cs47l35@0 {
+   compatible = "cirrus,cs47l35";
+
+   cirrus,dmic-ref = <0 0 CS47L35_DMIC_REF_MICBIAS1B 0>;
+   cirrus,inmode = <
+   MADERA_INMODE_DMIC MADERA_INMODE_DMIC /* IN1A digital */
+   MADERA_INMODE_SE   MADERA_INMODE_SE   /* IN1B single-ended */
+   MADERA_INMODE_DIFF MADERA_INMODE_DIFF /* IN2 differential */
+   0 0 /* not used on this codec */
+   >;
+   cirrus,out-mono = <0 0 0 0 0 0>;
+   cirrus,max-channels-clocked = <2 0 0>;
+};
diff --git a/MAINTAINERS b/MAINTAINERS
index 22cc961..cd2a8e2 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3378,6 +3378,7 @@ W:
https://github.com/CirrusLogic/linux-drivers/wiki
 S: Supported
 F: Documentation/devicetree/bindings/mfd/madera.txt
 F: Documentation/devicetree/bindings/pinctrl/cirrus,madera-pinctrl.txt
+F: include/dt-bindings/sound/madera*
 F: include/linux/irqchip/irq-madera*
 F: include/linux/mfd/madera/*
 F: drivers/gpio/gpio-madera*
diff --git a/include/dt-bindings/sound/madera.h 
b/include/dt-bindings/sound/madera.h
new file mode 100644
index 000..5c05b7a
--- /dev/null
+++ b/include/dt-bindings/sound/madera.h
@@ -0,0 +1,27 @@
+/*
+ * Device Tree defines for Madera codecs
+ *
+ * Copyright 2016-2017 Cirrus Logic
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+

[PATCH v4 13/17] ASoC: madera: Add DT bindings for Cirrus Logic Madera codecs

2017-07-28 Thread Richard Fitzgerald
The Cirrus Logic Madera codecs are a family of related codecs with
extensive digital and analogue I/O, digital mixing and routing,
signal processing and programmable DSPs.

Signed-off-by: Richard Fitzgerald 
Acked-by: Rob Herring 
---
Changes since V3:
- include-dt-bindings/sound/madera.h moved into this patch from
  patch 14 as requested. Including Rob's ack that was conditional
  on making this change.
 Documentation/devicetree/bindings/sound/madera.txt | 67 ++
 MAINTAINERS|  1 +
 include/dt-bindings/sound/madera.h | 27 +
 3 files changed, 95 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/madera.txt
 create mode 100644 include/dt-bindings/sound/madera.h

diff --git a/Documentation/devicetree/bindings/sound/madera.txt 
b/Documentation/devicetree/bindings/sound/madera.txt
new file mode 100644
index 000..1114fcf
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/madera.txt
@@ -0,0 +1,67 @@
+Cirrus Logic Madera class audio codecs
+
+This describes audio configuration bindings for these codecs.
+
+See also the core bindings for the parent MFD driver:
+See Documentation/devicetree/bindings/mfd/madera.txt
+
+and defines for values used in these bindings:
+include/dt-bindings/sound/madera.h
+
+These properties are all contained in the parent MFD node.
+
+Optional properties:
+  - cirrus,dmic-ref : Indicates how the MICBIAS pins have been externally
+connected to DMICs on each input, one cell per input.
+
+A value of 0 indicates MICVDD and is the default, other values depend on 
the
+codec:
+For CS47L35 one of the CS47L35_DMIC_REF_xxx values
+For all other codecs one of the MADERA_DMIC_REF_xxx values
+Also see the datasheet for a description of the INn_DMIC_SUP field.
+
+  - cirrus,inmode : A list of input mode settings for each input. A maximum of
+16 cells, with four cells per input in the order INnAL, INnAR INnBL INnBR.
+For non-muxed inputs the first two cells for that input set the mode for
+the left and right channel and the second two cells must be 0.
+For muxed inputs the first two cells for that input set the mode of the
+left and right A inputs and the second two cells set the mode of the left
+and right B inputs.
+Valid mode values are one of the MADERA_INMODE_xxx. If the array is shorter
+than the number of inputs the unspecified inputs default to
+MADERA_INMODE_DIFF.
+
+  - cirrus,out-mono : Mono bit for each output, must contain six cells if
+specified. A non-zero value indicates the corresponding output is mono.
+
+  - cirrus,max-channels-clocked : Maximum number of channels that I2S clocks
+will be generated for. Useful when clock master for systems where the I2S
+bus has multiple data lines.
+One cell for each AIF, use a value of zero for AIFs that should be handled
+normally.
+
+  - cirrus,pdm-fmt : PDM speaker data format, must contain 2 cells
+(OUT5 and OUT6). See the PDM_SPKn_FMT field in the datasheet for a
+description of this value.
+The second cell is ignored for codecs that do not have OUT6.
+
+  - cirrus,pdm-mute : PDM mute format, must contain 2 cells
+(OUT5 and OUT6). See the PDM_SPKn_CTRL_1 register in the datasheet for a
+description of this value.
+The second cell is ignored for codecs that do not have OUT6.
+
+Example:
+
+cs47l35@0 {
+   compatible = "cirrus,cs47l35";
+
+   cirrus,dmic-ref = <0 0 CS47L35_DMIC_REF_MICBIAS1B 0>;
+   cirrus,inmode = <
+   MADERA_INMODE_DMIC MADERA_INMODE_DMIC /* IN1A digital */
+   MADERA_INMODE_SE   MADERA_INMODE_SE   /* IN1B single-ended */
+   MADERA_INMODE_DIFF MADERA_INMODE_DIFF /* IN2 differential */
+   0 0 /* not used on this codec */
+   >;
+   cirrus,out-mono = <0 0 0 0 0 0>;
+   cirrus,max-channels-clocked = <2 0 0>;
+};
diff --git a/MAINTAINERS b/MAINTAINERS
index 22cc961..cd2a8e2 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3378,6 +3378,7 @@ W:
https://github.com/CirrusLogic/linux-drivers/wiki
 S: Supported
 F: Documentation/devicetree/bindings/mfd/madera.txt
 F: Documentation/devicetree/bindings/pinctrl/cirrus,madera-pinctrl.txt
+F: include/dt-bindings/sound/madera*
 F: include/linux/irqchip/irq-madera*
 F: include/linux/mfd/madera/*
 F: drivers/gpio/gpio-madera*
diff --git a/include/dt-bindings/sound/madera.h 
b/include/dt-bindings/sound/madera.h
new file mode 100644
index 000..5c05b7a
--- /dev/null
+++ b/include/dt-bindings/sound/madera.h
@@ -0,0 +1,27 @@
+/*
+ * Device Tree defines for Madera codecs
+ *
+ * Copyright 2016-2017 Cirrus Logic
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef DT_BINDINGS_SOUND_MADERA_H
+#define 

[PATCH v4 10/17] pinctrl: madera: Add DT bindings for Cirrus Logic Madera codecs

2017-07-28 Thread Richard Fitzgerald
This is the binding description of the pinctrl driver for Cirru Logic
Madera codecs. The binding uses the generic pinctrl binding so  the main
purpose here is to describe the device-specific names for groups and
functions.

Signed-off-by: Richard Fitzgerald 
Acked-by: Rob Herring 
---
No changes since V3
 .../bindings/pinctrl/cirrus,madera-pinctrl.txt | 99 ++
 1 file changed, 99 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/pinctrl/cirrus,madera-pinctrl.txt

diff --git 
a/Documentation/devicetree/bindings/pinctrl/cirrus,madera-pinctrl.txt 
b/Documentation/devicetree/bindings/pinctrl/cirrus,madera-pinctrl.txt
new file mode 100644
index 000..b0e36cf
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/cirrus,madera-pinctrl.txt
@@ -0,0 +1,99 @@
+Cirrus Logic Madera class audio codecs pinctrl driver
+
+The Cirrus Logic Madera codecs provide a number of GPIO functions for
+interfacing to external hardware and to provide logic outputs to other devices.
+Certain groups of GPIO pins also have an alternate function, normally as an
+audio interface.
+
+The set of available GPIOs, functions and alternate function groups differs
+between codecs so refer to the datasheet for the codec for further information
+on what is supported on that device.
+
+The properties for this driver exist within the parent MFD driver node.
+
+See also
+  the core bindings for the parent MFD driver:
+Documentation/devicetree/bindings/mfd/madera.txt
+
+  the generic pinmix bindings:
+Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
+
+Required properties of parent mfd node:
+  - pinctrl-names : must be "default"
+  - pinctrl-0 : a phandle to the node containing the subnodes containing 
default
+  configurations
+
+Required subnodes:
+  One subnode is required to contain the default settings. It contains an
+  arbitrary number of configuration subnodes, one for each group or pin
+  configuration you want to apply as a default.
+
+Required properties of configuration subnodes:
+  - groups : name of one pin group to configure. One of:
+   aif1, aif2, aif3, aif4, mif1, mif2, mif3, pdmspk1, pdmspk2,
+   dmic4, dmic5, dmic6,
+   gpio1, gpio2, ..., gpio40
+The gpioN groups select the single pin of this name for configuration
+
+Optional properties of configuration subnodes:
+  Any configuration option not explicitly listed in the dts will be left at
+  chip default setting.
+
+  - function : name of function to assign to this group. One of:
+   aif1, aif2, aif3, aif4, mif1, mif2, mif3, pdmspk1, pdmspk2,
+   dmic3, dmic4, dmic5, dmic6,
+   io, dsp-gpio, irq1, irq2,
+   fll1-clk, fll1-lock, fll2-clk, fll2-lock, fll3-clk, fll3-lock,
+   fllao-clk, fllao-lock,
+   opclk, opclk-async, pwm1, pwm2, spdif,
+   asrc1-in1-lock, asrc1-in2-lock, asrc2-in1-lock, asrc2-in2-lock,
+   spkl-short-circuit, spkr-short-circuit, spk-shutdown,
+   spk-overheat-shutdown, spk-overheat-warn,
+   timer1-sts, timer2-sts, timer3-sts, timer4-sts, timer5-sts, timer6-sts,
+   timer7-sts, timer8-sts,
+   log1-fifo-ne, log2-fifo-ne, log3-fifo-ne, log4-fifo-ne, log5-fifo-ne,
+   log6-fifo-ne, log7-fifo-ne, log8-fifo-ne,
+
+  - bias-disable : disable pull-up and pull-down
+  - bias-bus-hold : enable buskeeper
+  - bias-pull-up : output is pulled-up
+  - bias-pull-down : output is pulled-down
+  - drive-push-pull : CMOS output
+  - drive-open-drain : open-drain output
+  - drive-strength : drive strength in mA. Valid values are 4 or 8
+  - input-schmitt-enable : enable schmitt-trigger mode
+  - input-schmitt-disable : disable schmitt-trigger mode
+  - input-debounce : A value of 0 disables debounce, a value !=0 enables
+   debounce
+  - output-low : set the pin to output mode with low level
+  - output-high : set the pin to output mode with high level
+
+Example:
+
+cs47l85@0 {
+   compatible = "cirrus,cs47l85";
+
+   pinctrl-names = "default";
+   pinctrl-0 = <_defaults>;
+
+   cs47l85_defaults: cs47l85-gpio-defaults {
+   aif1 {
+   groups = "aif1";
+   function = "aif1";
+   bias-bus-hold;
+   };
+
+   aif2 {
+   groups = "aif2";
+   function = "aif2";
+   bias-bus-hold;
+   };
+
+   opclk {
+   groups = "gpio1";
+   function = "opclk";
+   bias-pull-up;
+   drive-strength = <8>;
+   };
+   };
+};
-- 
1.9.1



Re: [PATCH 3/3] net-next: stmmac: dwmac-sun8i: choose internal PHY via compatible

2017-07-28 Thread Chen-Yu Tsai
On Fri, Jul 28, 2017 at 5:28 PM, Corentin Labbe
 wrote:
> The current way to find if the phy is internal is to compare DT phy-mode
> and emac_variant/internal_phy.
> But it will negate a possible future SoC where an external PHY use the
> same phy mode than the internal one.
>
> This patch adds a new way to find if the PHY is internal, via its
> compatible.
>
> Since the phy_mode of the internal PHY does need to be know, the
> variant internal_phy member is converted to a boolean.
>
> Signed-off-by: Corentin Labbe 
> ---
>  drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 16 ++--
>  1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c 
> b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> index fffd6d5fc907..04f7ddd802b0 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> @@ -48,7 +48,7 @@
>   */
>  struct emac_variant {
> u32 default_syscon_value;
> -   int internal_phy;
> +   bool internal_phy;

Nit: please add a verb to the name, like "has_internal_phy",
or even "soc_has_internal_phy". This makes it clear what this
property represents.

ChenYu


[PATCH v4 10/17] pinctrl: madera: Add DT bindings for Cirrus Logic Madera codecs

2017-07-28 Thread Richard Fitzgerald
This is the binding description of the pinctrl driver for Cirru Logic
Madera codecs. The binding uses the generic pinctrl binding so  the main
purpose here is to describe the device-specific names for groups and
functions.

Signed-off-by: Richard Fitzgerald 
Acked-by: Rob Herring 
---
No changes since V3
 .../bindings/pinctrl/cirrus,madera-pinctrl.txt | 99 ++
 1 file changed, 99 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/pinctrl/cirrus,madera-pinctrl.txt

diff --git 
a/Documentation/devicetree/bindings/pinctrl/cirrus,madera-pinctrl.txt 
b/Documentation/devicetree/bindings/pinctrl/cirrus,madera-pinctrl.txt
new file mode 100644
index 000..b0e36cf
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/cirrus,madera-pinctrl.txt
@@ -0,0 +1,99 @@
+Cirrus Logic Madera class audio codecs pinctrl driver
+
+The Cirrus Logic Madera codecs provide a number of GPIO functions for
+interfacing to external hardware and to provide logic outputs to other devices.
+Certain groups of GPIO pins also have an alternate function, normally as an
+audio interface.
+
+The set of available GPIOs, functions and alternate function groups differs
+between codecs so refer to the datasheet for the codec for further information
+on what is supported on that device.
+
+The properties for this driver exist within the parent MFD driver node.
+
+See also
+  the core bindings for the parent MFD driver:
+Documentation/devicetree/bindings/mfd/madera.txt
+
+  the generic pinmix bindings:
+Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
+
+Required properties of parent mfd node:
+  - pinctrl-names : must be "default"
+  - pinctrl-0 : a phandle to the node containing the subnodes containing 
default
+  configurations
+
+Required subnodes:
+  One subnode is required to contain the default settings. It contains an
+  arbitrary number of configuration subnodes, one for each group or pin
+  configuration you want to apply as a default.
+
+Required properties of configuration subnodes:
+  - groups : name of one pin group to configure. One of:
+   aif1, aif2, aif3, aif4, mif1, mif2, mif3, pdmspk1, pdmspk2,
+   dmic4, dmic5, dmic6,
+   gpio1, gpio2, ..., gpio40
+The gpioN groups select the single pin of this name for configuration
+
+Optional properties of configuration subnodes:
+  Any configuration option not explicitly listed in the dts will be left at
+  chip default setting.
+
+  - function : name of function to assign to this group. One of:
+   aif1, aif2, aif3, aif4, mif1, mif2, mif3, pdmspk1, pdmspk2,
+   dmic3, dmic4, dmic5, dmic6,
+   io, dsp-gpio, irq1, irq2,
+   fll1-clk, fll1-lock, fll2-clk, fll2-lock, fll3-clk, fll3-lock,
+   fllao-clk, fllao-lock,
+   opclk, opclk-async, pwm1, pwm2, spdif,
+   asrc1-in1-lock, asrc1-in2-lock, asrc2-in1-lock, asrc2-in2-lock,
+   spkl-short-circuit, spkr-short-circuit, spk-shutdown,
+   spk-overheat-shutdown, spk-overheat-warn,
+   timer1-sts, timer2-sts, timer3-sts, timer4-sts, timer5-sts, timer6-sts,
+   timer7-sts, timer8-sts,
+   log1-fifo-ne, log2-fifo-ne, log3-fifo-ne, log4-fifo-ne, log5-fifo-ne,
+   log6-fifo-ne, log7-fifo-ne, log8-fifo-ne,
+
+  - bias-disable : disable pull-up and pull-down
+  - bias-bus-hold : enable buskeeper
+  - bias-pull-up : output is pulled-up
+  - bias-pull-down : output is pulled-down
+  - drive-push-pull : CMOS output
+  - drive-open-drain : open-drain output
+  - drive-strength : drive strength in mA. Valid values are 4 or 8
+  - input-schmitt-enable : enable schmitt-trigger mode
+  - input-schmitt-disable : disable schmitt-trigger mode
+  - input-debounce : A value of 0 disables debounce, a value !=0 enables
+   debounce
+  - output-low : set the pin to output mode with low level
+  - output-high : set the pin to output mode with high level
+
+Example:
+
+cs47l85@0 {
+   compatible = "cirrus,cs47l85";
+
+   pinctrl-names = "default";
+   pinctrl-0 = <_defaults>;
+
+   cs47l85_defaults: cs47l85-gpio-defaults {
+   aif1 {
+   groups = "aif1";
+   function = "aif1";
+   bias-bus-hold;
+   };
+
+   aif2 {
+   groups = "aif2";
+   function = "aif2";
+   bias-bus-hold;
+   };
+
+   opclk {
+   groups = "gpio1";
+   function = "opclk";
+   bias-pull-up;
+   drive-strength = <8>;
+   };
+   };
+};
-- 
1.9.1



Re: [PATCH 3/3] net-next: stmmac: dwmac-sun8i: choose internal PHY via compatible

2017-07-28 Thread Chen-Yu Tsai
On Fri, Jul 28, 2017 at 5:28 PM, Corentin Labbe
 wrote:
> The current way to find if the phy is internal is to compare DT phy-mode
> and emac_variant/internal_phy.
> But it will negate a possible future SoC where an external PHY use the
> same phy mode than the internal one.
>
> This patch adds a new way to find if the PHY is internal, via its
> compatible.
>
> Since the phy_mode of the internal PHY does need to be know, the
> variant internal_phy member is converted to a boolean.
>
> Signed-off-by: Corentin Labbe 
> ---
>  drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 16 ++--
>  1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c 
> b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> index fffd6d5fc907..04f7ddd802b0 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> @@ -48,7 +48,7 @@
>   */
>  struct emac_variant {
> u32 default_syscon_value;
> -   int internal_phy;
> +   bool internal_phy;

Nit: please add a verb to the name, like "has_internal_phy",
or even "soc_has_internal_phy". This makes it clear what this
property represents.

ChenYu


[PATCH v4 06/17] mfd: madera: Register map tables for Cirrus Logic CS47L90/91

2017-07-28 Thread Richard Fitzgerald
Regmap configuration tables for Cirrus Logic CS47L90 and CS47L91 codecs.

Signed-off-by: Nikesh Oswal 
Signed-off-by: Richard Fitzgerald 
Signed-off-by: Charles Keepax 
---
Changes since V3:
- converted EQ and GPIO registers to a case range because registers.h
  has been stripped to only define the first and last register of each
- updated copyright year
The rest of the file was
Acked-for-MFD-by: Lee Jones 
 drivers/mfd/Kconfig  |7 +
 drivers/mfd/Makefile |3 +
 drivers/mfd/cs47l90-tables.c | 2675 ++
 3 files changed, 2685 insertions(+)
 create mode 100644 drivers/mfd/cs47l90-tables.c

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index e53c756..441d493 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -249,6 +249,13 @@ config MFD_CS47L85
help
  Support for Cirrus Logic CS47L85 Smart Codec
 
+config MFD_CS47L90
+   bool "Cirrus Logic CS47L90/91"
+   select PINCTRL_CS47L90
+   depends on MFD_MADERA
+   help
+ Support for Cirrus Logic CS47L90 and CS47L91 Smart Codecs
+
 config MFD_ASIC3
bool "Compaq ASIC3"
depends on GPIOLIB && ARM
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 772c2dd..abf497f 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -80,6 +80,9 @@ endif
 ifeq ($(CONFIG_MFD_CS47L85),y)
 obj-$(CONFIG_MFD_MADERA)   += cs47l85-tables.o
 endif
+ifeq ($(CONFIG_MFD_CS47L90),y)
+obj-$(CONFIG_MFD_MADERA)   += cs47l90-tables.o
+endif
 obj-$(CONFIG_MFD_MADERA_I2C)   += madera-i2c.o
 obj-$(CONFIG_MFD_MADERA_SPI)   += madera-spi.o
 
diff --git a/drivers/mfd/cs47l90-tables.c b/drivers/mfd/cs47l90-tables.c
new file mode 100644
index 000..1ab02f7
--- /dev/null
+++ b/drivers/mfd/cs47l90-tables.c
@@ -0,0 +1,2675 @@
+/*
+ * Regmap tables for CS47L90 codec
+ *
+ * Copyright 2015-2017 Cirrus Logic
+ *
+ * Author: Nikesh Oswal 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "madera.h"
+
+static const struct reg_sequence cs47l90_reva_16_patch[] = {
+   { 0x8A,   0x },
+   { 0x8A,   0x },
+   { 0x4CF,  0x0700 },
+   { 0x171,  0x0003 },
+   { 0x101,  0x0444 },
+   { 0x159,  0x0002 },
+   { 0x120,  0x0444 },
+   { 0x1D1,  0x0004 },
+   { 0x1E0,  0xC084 },
+   { 0x159,  0x },
+   { 0x120,  0x0404 },
+   { 0x101,  0x0404 },
+   { 0x171,  0x0002 },
+   { 0x17A,  0x2906 },
+   { 0x19A,  0x2906 },
+   { 0x441,  0xC750 },
+   { 0x340,  0x0001 },
+   { 0x112,  0x0405 },
+   { 0x124,  0x0C49 },
+   { 0x1300, 0x050E },
+   { 0x1302, 0x0101 },
+   { 0x1380, 0x0425 },
+   { 0x1381, 0xF6D8 },
+   { 0x1382, 0x0632 },
+   { 0x1383, 0xFEC8 },
+   { 0x1390, 0x042F },
+   { 0x1391, 0xF6CA },
+   { 0x1392, 0x0637 },
+   { 0x1393, 0xFEC8 },
+   { 0x281,  0x },
+   { 0x282,  0x },
+   { 0x4EA,  0x0100 },
+   { 0x8A,   0x },
+   { 0x8A,   0x },
+};
+
+int cs47l90_patch(struct madera *madera)
+{
+   int ret;
+
+   ret = regmap_register_patch(madera->regmap,
+   cs47l90_reva_16_patch,
+   ARRAY_SIZE(cs47l90_reva_16_patch));
+   if (ret < 0) {
+   dev_err(madera->dev,
+   "Error in applying 16-bit patch: %d\n", ret);
+   return ret;
+   }
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(cs47l90_patch);
+
+static const struct reg_default cs47l90_reg_default[] = {
+   { 0x0020, 0x }, /* R32 (0x20) - Tone Generator 1 */
+   { 0x0021, 0x1000 }, /* R33 (0x21) - Tone Generator 2 */
+   { 0x0022, 0x }, /* R34 (0x22) - Tone Generator 3 */
+   { 0x0023, 0x1000 }, /* R35 (0x23) - Tone Generator 4 */
+   { 0x0024, 0x }, /* R36 (0x24) - Tone Generator 5 */
+   { 0x0030, 0x }, /* R48 (0x30) - PWM Drive 1 */
+   { 0x0031, 0x0100 }, /* R49 (0x31) - PWM Drive 2 */
+   { 0x0032, 0x0100 }, /* R50 (0x32) - PWM Drive 3 */
+   { 0x0061, 0x01ff }, /* R97 (0x61) - Sample Rate Sequence Select 1 */
+   { 0x0062, 0x01ff }, /* R98 (0x62) - Sample Rate Sequence Select 2 */
+   { 0x0063, 0x01ff }, /* R99 (0x63) - Sample Rate Sequence Select 3 */
+   { 0x0064, 0x01ff }, /* R100 (0x64) - Sample Rate Sequence Select 4 
*/
+   { 0x0066, 0x01ff }, /* R102 (0x66) - Always On Triggers Sequence 
Select 1 */
+   { 0x0067, 0x01ff }, /* R103 (0x67) - Always On Triggers Sequence 
Select 2 */
+   { 0x0090, 0x 

[PATCH v4 06/17] mfd: madera: Register map tables for Cirrus Logic CS47L90/91

2017-07-28 Thread Richard Fitzgerald
Regmap configuration tables for Cirrus Logic CS47L90 and CS47L91 codecs.

Signed-off-by: Nikesh Oswal 
Signed-off-by: Richard Fitzgerald 
Signed-off-by: Charles Keepax 
---
Changes since V3:
- converted EQ and GPIO registers to a case range because registers.h
  has been stripped to only define the first and last register of each
- updated copyright year
The rest of the file was
Acked-for-MFD-by: Lee Jones 
 drivers/mfd/Kconfig  |7 +
 drivers/mfd/Makefile |3 +
 drivers/mfd/cs47l90-tables.c | 2675 ++
 3 files changed, 2685 insertions(+)
 create mode 100644 drivers/mfd/cs47l90-tables.c

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index e53c756..441d493 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -249,6 +249,13 @@ config MFD_CS47L85
help
  Support for Cirrus Logic CS47L85 Smart Codec
 
+config MFD_CS47L90
+   bool "Cirrus Logic CS47L90/91"
+   select PINCTRL_CS47L90
+   depends on MFD_MADERA
+   help
+ Support for Cirrus Logic CS47L90 and CS47L91 Smart Codecs
+
 config MFD_ASIC3
bool "Compaq ASIC3"
depends on GPIOLIB && ARM
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 772c2dd..abf497f 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -80,6 +80,9 @@ endif
 ifeq ($(CONFIG_MFD_CS47L85),y)
 obj-$(CONFIG_MFD_MADERA)   += cs47l85-tables.o
 endif
+ifeq ($(CONFIG_MFD_CS47L90),y)
+obj-$(CONFIG_MFD_MADERA)   += cs47l90-tables.o
+endif
 obj-$(CONFIG_MFD_MADERA_I2C)   += madera-i2c.o
 obj-$(CONFIG_MFD_MADERA_SPI)   += madera-spi.o
 
diff --git a/drivers/mfd/cs47l90-tables.c b/drivers/mfd/cs47l90-tables.c
new file mode 100644
index 000..1ab02f7
--- /dev/null
+++ b/drivers/mfd/cs47l90-tables.c
@@ -0,0 +1,2675 @@
+/*
+ * Regmap tables for CS47L90 codec
+ *
+ * Copyright 2015-2017 Cirrus Logic
+ *
+ * Author: Nikesh Oswal 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "madera.h"
+
+static const struct reg_sequence cs47l90_reva_16_patch[] = {
+   { 0x8A,   0x },
+   { 0x8A,   0x },
+   { 0x4CF,  0x0700 },
+   { 0x171,  0x0003 },
+   { 0x101,  0x0444 },
+   { 0x159,  0x0002 },
+   { 0x120,  0x0444 },
+   { 0x1D1,  0x0004 },
+   { 0x1E0,  0xC084 },
+   { 0x159,  0x },
+   { 0x120,  0x0404 },
+   { 0x101,  0x0404 },
+   { 0x171,  0x0002 },
+   { 0x17A,  0x2906 },
+   { 0x19A,  0x2906 },
+   { 0x441,  0xC750 },
+   { 0x340,  0x0001 },
+   { 0x112,  0x0405 },
+   { 0x124,  0x0C49 },
+   { 0x1300, 0x050E },
+   { 0x1302, 0x0101 },
+   { 0x1380, 0x0425 },
+   { 0x1381, 0xF6D8 },
+   { 0x1382, 0x0632 },
+   { 0x1383, 0xFEC8 },
+   { 0x1390, 0x042F },
+   { 0x1391, 0xF6CA },
+   { 0x1392, 0x0637 },
+   { 0x1393, 0xFEC8 },
+   { 0x281,  0x },
+   { 0x282,  0x },
+   { 0x4EA,  0x0100 },
+   { 0x8A,   0x },
+   { 0x8A,   0x },
+};
+
+int cs47l90_patch(struct madera *madera)
+{
+   int ret;
+
+   ret = regmap_register_patch(madera->regmap,
+   cs47l90_reva_16_patch,
+   ARRAY_SIZE(cs47l90_reva_16_patch));
+   if (ret < 0) {
+   dev_err(madera->dev,
+   "Error in applying 16-bit patch: %d\n", ret);
+   return ret;
+   }
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(cs47l90_patch);
+
+static const struct reg_default cs47l90_reg_default[] = {
+   { 0x0020, 0x }, /* R32 (0x20) - Tone Generator 1 */
+   { 0x0021, 0x1000 }, /* R33 (0x21) - Tone Generator 2 */
+   { 0x0022, 0x }, /* R34 (0x22) - Tone Generator 3 */
+   { 0x0023, 0x1000 }, /* R35 (0x23) - Tone Generator 4 */
+   { 0x0024, 0x }, /* R36 (0x24) - Tone Generator 5 */
+   { 0x0030, 0x }, /* R48 (0x30) - PWM Drive 1 */
+   { 0x0031, 0x0100 }, /* R49 (0x31) - PWM Drive 2 */
+   { 0x0032, 0x0100 }, /* R50 (0x32) - PWM Drive 3 */
+   { 0x0061, 0x01ff }, /* R97 (0x61) - Sample Rate Sequence Select 1 */
+   { 0x0062, 0x01ff }, /* R98 (0x62) - Sample Rate Sequence Select 2 */
+   { 0x0063, 0x01ff }, /* R99 (0x63) - Sample Rate Sequence Select 3 */
+   { 0x0064, 0x01ff }, /* R100 (0x64) - Sample Rate Sequence Select 4 
*/
+   { 0x0066, 0x01ff }, /* R102 (0x66) - Always On Triggers Sequence 
Select 1 */
+   { 0x0067, 0x01ff }, /* R103 (0x67) - Always On Triggers Sequence 
Select 2 */
+   { 0x0090, 0x }, /* R144 (0x90) - Haptics Control 1 */
+   { 0x0091, 0x7fff }, /* R145 (0x91) - Haptics Control 2 */
+   { 0x0092, 0x }, /* R146 (0x92) - 

vbox_fb.c:undefined reference to `ttm_bo_add_to_lru'

2017-07-28 Thread kbuild test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   0b5477d9dabd96ded4c5ef7a5f08b00188fc1dec
commit: dd55d44f408419278c00887bfcb2261d0caae350 staging: vboxvideo: Add 
vboxvideo to drivers/staging
date:   11 days ago
config: x86_64-randconfig-ws0-07281558 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
git checkout dd55d44f408419278c00887bfcb2261d0caae350
# save the attached .config to linux build tree
make ARCH=x86_64 

All errors (new ones prefixed by >>):

   drivers/staging/vboxvideo/vbox_fb.o: In function `vbox_dirty_update':
>> vbox_fb.c:(.text+0x2e4): undefined reference to `ttm_bo_add_to_lru'
>> vbox_fb.c:(.text+0x355): undefined reference to `ttm_bo_del_sub_from_lru'
   drivers/staging/vboxvideo/vbox_fb.o: In function `vboxfb_create':
   vbox_fb.c:(.text+0x675): undefined reference to `ttm_bo_del_sub_from_lru'
   vbox_fb.c:(.text+0x6d5): undefined reference to `ttm_bo_add_to_lru'
>> vbox_fb.c:(.text+0x74f): undefined reference to `ttm_bo_kmap'
   vbox_fb.c:(.text+0x78d): undefined reference to `ttm_bo_add_to_lru'
   drivers/staging/vboxvideo/vbox_fb.o: In function `vbox_fbdev_fini':
   vbox_fb.c:(.text+0xb6d): undefined reference to `ttm_bo_del_sub_from_lru'
>> vbox_fb.c:(.text+0xb8f): undefined reference to `ttm_bo_kunmap'
   vbox_fb.c:(.text+0xbeb): undefined reference to `ttm_bo_add_to_lru'
   drivers/staging/vboxvideo/vbox_main.o: In function `vbox_gem_free_object':
>> vbox_main.c:(.text+0xc5d): undefined reference to `ttm_bo_unref'
   drivers/staging/vboxvideo/vbox_mode.o: In function `vbox_cursor_set2':
>> vbox_mode.c:(.text+0x561): undefined reference to `ttm_bo_del_sub_from_lru'
>> vbox_mode.c:(.text+0x60c): undefined reference to `ttm_bo_kmap'
>> vbox_mode.c:(.text+0x73c): undefined reference to `ttm_bo_kunmap'
>> vbox_mode.c:(.text+0x777): undefined reference to `ttm_bo_add_to_lru'
   drivers/staging/vboxvideo/vbox_mode.o: In function `vbox_crtc_mode_set':
   vbox_mode.c:(.text+0x109c): undefined reference to `ttm_bo_del_sub_from_lru'
   vbox_mode.c:(.text+0x10e3): undefined reference to `ttm_bo_add_to_lru'
   vbox_mode.c:(.text+0x11ab): undefined reference to `ttm_bo_del_sub_from_lru'
   vbox_mode.c:(.text+0x1204): undefined reference to `ttm_bo_add_to_lru'
   vbox_mode.c:(.text+0x12be): undefined reference to `ttm_bo_add_to_lru'
   drivers/staging/vboxvideo/vbox_ttm.o: In function `vbox_bo_move':
>> vbox_ttm.c:(.text+0xd4): undefined reference to `ttm_bo_move_memcpy'
   drivers/staging/vboxvideo/vbox_ttm.o: In function `vbox_bo_init_mem_type':
>> vbox_ttm.c:(.text+0x177): undefined reference to `ttm_bo_manager_func'
   drivers/staging/vboxvideo/vbox_ttm.o: In function `vbox_ttm_tt_unpopulate':
>> vbox_ttm.c:(.text+0x19f): undefined reference to `ttm_pool_unpopulate'
   drivers/staging/vboxvideo/vbox_ttm.o: In function `vbox_ttm_tt_populate':
>> vbox_ttm.c:(.text+0x1b8): undefined reference to `ttm_pool_populate'
   drivers/staging/vboxvideo/vbox_ttm.o: In function `vbox_ttm_backend_destroy':
>> vbox_ttm.c:(.text+0x1d5): undefined reference to `ttm_tt_fini'
   drivers/staging/vboxvideo/vbox_ttm.o: In function `vbox_ttm_tt_create':
>> vbox_ttm.c:(.text+0x255): undefined reference to `ttm_tt_init'
   drivers/staging/vboxvideo/vbox_ttm.o: In function 
`vbox_ttm_mem_global_release':
>> vbox_ttm.c:(.text+0x2cb): undefined reference to `ttm_mem_global_release'
   drivers/staging/vboxvideo/vbox_ttm.o: In function `vbox_ttm_mem_global_init':
>> vbox_ttm.c:(.text+0x2e8): undefined reference to `ttm_mem_global_init'
   drivers/staging/vboxvideo/vbox_ttm.o: In function `vbox_mm_init':
>> vbox_ttm.c:(.text+0x38f): undefined reference to `ttm_bo_global_init'
>> vbox_ttm.c:(.text+0x39a): undefined reference to `ttm_bo_global_release'
>> vbox_ttm.c:(.text+0x435): undefined reference to `ttm_bo_device_init'

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


vbox_fb.c:undefined reference to `ttm_bo_add_to_lru'

2017-07-28 Thread kbuild test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   0b5477d9dabd96ded4c5ef7a5f08b00188fc1dec
commit: dd55d44f408419278c00887bfcb2261d0caae350 staging: vboxvideo: Add 
vboxvideo to drivers/staging
date:   11 days ago
config: x86_64-randconfig-ws0-07281558 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
git checkout dd55d44f408419278c00887bfcb2261d0caae350
# save the attached .config to linux build tree
make ARCH=x86_64 

All errors (new ones prefixed by >>):

   drivers/staging/vboxvideo/vbox_fb.o: In function `vbox_dirty_update':
>> vbox_fb.c:(.text+0x2e4): undefined reference to `ttm_bo_add_to_lru'
>> vbox_fb.c:(.text+0x355): undefined reference to `ttm_bo_del_sub_from_lru'
   drivers/staging/vboxvideo/vbox_fb.o: In function `vboxfb_create':
   vbox_fb.c:(.text+0x675): undefined reference to `ttm_bo_del_sub_from_lru'
   vbox_fb.c:(.text+0x6d5): undefined reference to `ttm_bo_add_to_lru'
>> vbox_fb.c:(.text+0x74f): undefined reference to `ttm_bo_kmap'
   vbox_fb.c:(.text+0x78d): undefined reference to `ttm_bo_add_to_lru'
   drivers/staging/vboxvideo/vbox_fb.o: In function `vbox_fbdev_fini':
   vbox_fb.c:(.text+0xb6d): undefined reference to `ttm_bo_del_sub_from_lru'
>> vbox_fb.c:(.text+0xb8f): undefined reference to `ttm_bo_kunmap'
   vbox_fb.c:(.text+0xbeb): undefined reference to `ttm_bo_add_to_lru'
   drivers/staging/vboxvideo/vbox_main.o: In function `vbox_gem_free_object':
>> vbox_main.c:(.text+0xc5d): undefined reference to `ttm_bo_unref'
   drivers/staging/vboxvideo/vbox_mode.o: In function `vbox_cursor_set2':
>> vbox_mode.c:(.text+0x561): undefined reference to `ttm_bo_del_sub_from_lru'
>> vbox_mode.c:(.text+0x60c): undefined reference to `ttm_bo_kmap'
>> vbox_mode.c:(.text+0x73c): undefined reference to `ttm_bo_kunmap'
>> vbox_mode.c:(.text+0x777): undefined reference to `ttm_bo_add_to_lru'
   drivers/staging/vboxvideo/vbox_mode.o: In function `vbox_crtc_mode_set':
   vbox_mode.c:(.text+0x109c): undefined reference to `ttm_bo_del_sub_from_lru'
   vbox_mode.c:(.text+0x10e3): undefined reference to `ttm_bo_add_to_lru'
   vbox_mode.c:(.text+0x11ab): undefined reference to `ttm_bo_del_sub_from_lru'
   vbox_mode.c:(.text+0x1204): undefined reference to `ttm_bo_add_to_lru'
   vbox_mode.c:(.text+0x12be): undefined reference to `ttm_bo_add_to_lru'
   drivers/staging/vboxvideo/vbox_ttm.o: In function `vbox_bo_move':
>> vbox_ttm.c:(.text+0xd4): undefined reference to `ttm_bo_move_memcpy'
   drivers/staging/vboxvideo/vbox_ttm.o: In function `vbox_bo_init_mem_type':
>> vbox_ttm.c:(.text+0x177): undefined reference to `ttm_bo_manager_func'
   drivers/staging/vboxvideo/vbox_ttm.o: In function `vbox_ttm_tt_unpopulate':
>> vbox_ttm.c:(.text+0x19f): undefined reference to `ttm_pool_unpopulate'
   drivers/staging/vboxvideo/vbox_ttm.o: In function `vbox_ttm_tt_populate':
>> vbox_ttm.c:(.text+0x1b8): undefined reference to `ttm_pool_populate'
   drivers/staging/vboxvideo/vbox_ttm.o: In function `vbox_ttm_backend_destroy':
>> vbox_ttm.c:(.text+0x1d5): undefined reference to `ttm_tt_fini'
   drivers/staging/vboxvideo/vbox_ttm.o: In function `vbox_ttm_tt_create':
>> vbox_ttm.c:(.text+0x255): undefined reference to `ttm_tt_init'
   drivers/staging/vboxvideo/vbox_ttm.o: In function 
`vbox_ttm_mem_global_release':
>> vbox_ttm.c:(.text+0x2cb): undefined reference to `ttm_mem_global_release'
   drivers/staging/vboxvideo/vbox_ttm.o: In function `vbox_ttm_mem_global_init':
>> vbox_ttm.c:(.text+0x2e8): undefined reference to `ttm_mem_global_init'
   drivers/staging/vboxvideo/vbox_ttm.o: In function `vbox_mm_init':
>> vbox_ttm.c:(.text+0x38f): undefined reference to `ttm_bo_global_init'
>> vbox_ttm.c:(.text+0x39a): undefined reference to `ttm_bo_global_release'
>> vbox_ttm.c:(.text+0x435): undefined reference to `ttm_bo_device_init'

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


[PATCH v4 17/17] ASoC: cs47l90: Add codec driver for Cirrus Logic CS47L90

2017-07-28 Thread Richard Fitzgerald
Adds the codec driver for the CS47L90 SmartCodec. This is a
multi-functional codec based on the Cirrus Logic Madera platform.

Signed-off-by: Nikesh Oswal 
Signed-off-by: Charles Keepax 
Signed-off-by: Richard Fitzgerald 
---
Changes since V3:
- Fixed errors in the routing of ISRC3/4 to clock domain widgets
 sound/soc/codecs/Kconfig   |6 +
 sound/soc/codecs/Makefile  |2 +
 sound/soc/codecs/cs47l90.c | 2661 
 sound/soc/codecs/madera.c  |   14 +-
 4 files changed, 2676 insertions(+), 7 deletions(-)
 create mode 100644 sound/soc/codecs/cs47l90.c

diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 37b17c6..4f64d99 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -64,6 +64,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_CS47L24 if MFD_CS47L24
select SND_SOC_CS47L35 if MFD_CS47L35
select SND_SOC_CS47L85 if MFD_CS47L85
+   select SND_SOC_CS47L90 if MFD_CS47L90
select SND_SOC_CS53L30 if I2C
select SND_SOC_CX20442 if TTY
select SND_SOC_DA7210 if SND_SOC_I2C_AND_SPI
@@ -505,6 +506,9 @@ config SND_SOC_CS47L35
 config SND_SOC_CS47L85
tristate
 
+config SND_SOC_CS47L90
+   tristate
+
 # Cirrus Logic Quad-Channel ADC
 config SND_SOC_CS53L30
tristate "Cirrus Logic CS53L30 CODEC"
@@ -598,8 +602,10 @@ config SND_SOC_MADERA
tristate
default y if SND_SOC_CS47L35=y
default y if SND_SOC_CS47L85=y
+   default y if SND_SOC_CS47L90=y
default m if SND_SOC_CS47L35=m
default m if SND_SOC_CS47L85=m
+   default m if SND_SOC_CS47L90=m
 
 config SND_SOC_MAX98088
tristate
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index efc7f2e..a9b9ebe 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -57,6 +57,7 @@ snd-soc-cs4349-objs := cs4349.o
 snd-soc-cs47l24-objs := cs47l24.o
 snd-soc-cs47l35-objs := cs47l35.o
 snd-soc-cs47l85-objs := cs47l85.o
+snd-soc-cs47l90-objs := cs47l90.o
 snd-soc-cs53l30-objs := cs53l30.o
 snd-soc-cx20442-objs := cx20442.o
 snd-soc-da7210-objs := da7210.o
@@ -298,6 +299,7 @@ obj-$(CONFIG_SND_SOC_CS4349)+= snd-soc-cs4349.o
 obj-$(CONFIG_SND_SOC_CS47L24)  += snd-soc-cs47l24.o
 obj-$(CONFIG_SND_SOC_CS47L35)  += snd-soc-cs47l35.o
 obj-$(CONFIG_SND_SOC_CS47L85)  += snd-soc-cs47l85.o
+obj-$(CONFIG_SND_SOC_CS47L90)  += snd-soc-cs47l90.o
 obj-$(CONFIG_SND_SOC_CS53L30)  += snd-soc-cs53l30.o
 obj-$(CONFIG_SND_SOC_CX20442)  += snd-soc-cx20442.o
 obj-$(CONFIG_SND_SOC_DA7210)   += snd-soc-da7210.o
diff --git a/sound/soc/codecs/cs47l90.c b/sound/soc/codecs/cs47l90.c
new file mode 100644
index 000..630016c
--- /dev/null
+++ b/sound/soc/codecs/cs47l90.c
@@ -0,0 +1,2661 @@
+/*
+ * cs47l90.c  --  ALSA SoC Audio driver for CS47L90 codecs
+ *
+ * Copyright 2015-2017 Cirrus Logic
+ *
+ * Author: Nikesh Oswal 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "madera.h"
+#include "wm_adsp.h"
+
+#define CS47L90_NUM_ADSP   7
+#define CS47L90_MONO_OUTPUTS   3
+
+struct cs47l90 {
+   struct madera_priv core;
+   struct madera_fll fll[3];
+};
+
+static const struct wm_adsp_region cs47l90_dsp1_regions[] = {
+   { .type = WMFW_ADSP2_PM, .base = 0x08 },
+   { .type = WMFW_ADSP2_ZM, .base = 0x0e },
+   { .type = WMFW_ADSP2_XM, .base = 0x0a },
+   { .type = WMFW_ADSP2_YM, .base = 0x0c },
+};
+
+static const struct wm_adsp_region cs47l90_dsp2_regions[] = {
+   { .type = WMFW_ADSP2_PM, .base = 0x10 },
+   { .type = WMFW_ADSP2_ZM, .base = 0x16 },
+   { .type = WMFW_ADSP2_XM, .base = 0x12 },
+   { .type = WMFW_ADSP2_YM, .base = 0x14 },
+};
+
+static const struct wm_adsp_region cs47l90_dsp3_regions[] = {
+   { .type = WMFW_ADSP2_PM, .base = 0x18 },
+   { .type = WMFW_ADSP2_ZM, .base = 0x1e },
+   { .type = WMFW_ADSP2_XM, .base = 0x1a },
+   { .type = WMFW_ADSP2_YM, .base = 0x1c },
+};
+
+static const struct wm_adsp_region cs47l90_dsp4_regions[] = {
+   { .type = WMFW_ADSP2_PM, .base = 0x20 },
+   { .type = WMFW_ADSP2_ZM, .base = 0x26 },
+   { .type = WMFW_ADSP2_XM, .base = 0x22 },
+   { .type = WMFW_ADSP2_YM, .base = 0x24 },
+};
+
+static const struct wm_adsp_region cs47l90_dsp5_regions[] = {
+   { .type = WMFW_ADSP2_PM, .base = 0x28 },
+   { .type = WMFW_ADSP2_ZM, .base = 0x2e },
+   { .type = WMFW_ADSP2_XM, .base = 0x2a },
+   { .type = WMFW_ADSP2_YM, 

[PATCH v4 17/17] ASoC: cs47l90: Add codec driver for Cirrus Logic CS47L90

2017-07-28 Thread Richard Fitzgerald
Adds the codec driver for the CS47L90 SmartCodec. This is a
multi-functional codec based on the Cirrus Logic Madera platform.

Signed-off-by: Nikesh Oswal 
Signed-off-by: Charles Keepax 
Signed-off-by: Richard Fitzgerald 
---
Changes since V3:
- Fixed errors in the routing of ISRC3/4 to clock domain widgets
 sound/soc/codecs/Kconfig   |6 +
 sound/soc/codecs/Makefile  |2 +
 sound/soc/codecs/cs47l90.c | 2661 
 sound/soc/codecs/madera.c  |   14 +-
 4 files changed, 2676 insertions(+), 7 deletions(-)
 create mode 100644 sound/soc/codecs/cs47l90.c

diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 37b17c6..4f64d99 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -64,6 +64,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_CS47L24 if MFD_CS47L24
select SND_SOC_CS47L35 if MFD_CS47L35
select SND_SOC_CS47L85 if MFD_CS47L85
+   select SND_SOC_CS47L90 if MFD_CS47L90
select SND_SOC_CS53L30 if I2C
select SND_SOC_CX20442 if TTY
select SND_SOC_DA7210 if SND_SOC_I2C_AND_SPI
@@ -505,6 +506,9 @@ config SND_SOC_CS47L35
 config SND_SOC_CS47L85
tristate
 
+config SND_SOC_CS47L90
+   tristate
+
 # Cirrus Logic Quad-Channel ADC
 config SND_SOC_CS53L30
tristate "Cirrus Logic CS53L30 CODEC"
@@ -598,8 +602,10 @@ config SND_SOC_MADERA
tristate
default y if SND_SOC_CS47L35=y
default y if SND_SOC_CS47L85=y
+   default y if SND_SOC_CS47L90=y
default m if SND_SOC_CS47L35=m
default m if SND_SOC_CS47L85=m
+   default m if SND_SOC_CS47L90=m
 
 config SND_SOC_MAX98088
tristate
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index efc7f2e..a9b9ebe 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -57,6 +57,7 @@ snd-soc-cs4349-objs := cs4349.o
 snd-soc-cs47l24-objs := cs47l24.o
 snd-soc-cs47l35-objs := cs47l35.o
 snd-soc-cs47l85-objs := cs47l85.o
+snd-soc-cs47l90-objs := cs47l90.o
 snd-soc-cs53l30-objs := cs53l30.o
 snd-soc-cx20442-objs := cx20442.o
 snd-soc-da7210-objs := da7210.o
@@ -298,6 +299,7 @@ obj-$(CONFIG_SND_SOC_CS4349)+= snd-soc-cs4349.o
 obj-$(CONFIG_SND_SOC_CS47L24)  += snd-soc-cs47l24.o
 obj-$(CONFIG_SND_SOC_CS47L35)  += snd-soc-cs47l35.o
 obj-$(CONFIG_SND_SOC_CS47L85)  += snd-soc-cs47l85.o
+obj-$(CONFIG_SND_SOC_CS47L90)  += snd-soc-cs47l90.o
 obj-$(CONFIG_SND_SOC_CS53L30)  += snd-soc-cs53l30.o
 obj-$(CONFIG_SND_SOC_CX20442)  += snd-soc-cx20442.o
 obj-$(CONFIG_SND_SOC_DA7210)   += snd-soc-da7210.o
diff --git a/sound/soc/codecs/cs47l90.c b/sound/soc/codecs/cs47l90.c
new file mode 100644
index 000..630016c
--- /dev/null
+++ b/sound/soc/codecs/cs47l90.c
@@ -0,0 +1,2661 @@
+/*
+ * cs47l90.c  --  ALSA SoC Audio driver for CS47L90 codecs
+ *
+ * Copyright 2015-2017 Cirrus Logic
+ *
+ * Author: Nikesh Oswal 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "madera.h"
+#include "wm_adsp.h"
+
+#define CS47L90_NUM_ADSP   7
+#define CS47L90_MONO_OUTPUTS   3
+
+struct cs47l90 {
+   struct madera_priv core;
+   struct madera_fll fll[3];
+};
+
+static const struct wm_adsp_region cs47l90_dsp1_regions[] = {
+   { .type = WMFW_ADSP2_PM, .base = 0x08 },
+   { .type = WMFW_ADSP2_ZM, .base = 0x0e },
+   { .type = WMFW_ADSP2_XM, .base = 0x0a },
+   { .type = WMFW_ADSP2_YM, .base = 0x0c },
+};
+
+static const struct wm_adsp_region cs47l90_dsp2_regions[] = {
+   { .type = WMFW_ADSP2_PM, .base = 0x10 },
+   { .type = WMFW_ADSP2_ZM, .base = 0x16 },
+   { .type = WMFW_ADSP2_XM, .base = 0x12 },
+   { .type = WMFW_ADSP2_YM, .base = 0x14 },
+};
+
+static const struct wm_adsp_region cs47l90_dsp3_regions[] = {
+   { .type = WMFW_ADSP2_PM, .base = 0x18 },
+   { .type = WMFW_ADSP2_ZM, .base = 0x1e },
+   { .type = WMFW_ADSP2_XM, .base = 0x1a },
+   { .type = WMFW_ADSP2_YM, .base = 0x1c },
+};
+
+static const struct wm_adsp_region cs47l90_dsp4_regions[] = {
+   { .type = WMFW_ADSP2_PM, .base = 0x20 },
+   { .type = WMFW_ADSP2_ZM, .base = 0x26 },
+   { .type = WMFW_ADSP2_XM, .base = 0x22 },
+   { .type = WMFW_ADSP2_YM, .base = 0x24 },
+};
+
+static const struct wm_adsp_region cs47l90_dsp5_regions[] = {
+   { .type = WMFW_ADSP2_PM, .base = 0x28 },
+   { .type = WMFW_ADSP2_ZM, .base = 0x2e },
+   { .type = WMFW_ADSP2_XM, .base = 0x2a },
+   { .type = WMFW_ADSP2_YM, .base = 0x2c },
+};
+
+static const struct wm_adsp_region cs47l90_dsp6_regions[] = {
+   { .type = WMFW_ADSP2_PM, .base = 0x30 },
+ 

[PATCH v4 03/17] mfd: madera: Add common support for Cirrus Logic Madera codecs

2017-07-28 Thread Richard Fitzgerald
This adds the generic core support for Cirrus Logic "Madera" class codecs.
These are complex audio codec SoCs with a variety of digital and analogue
I/O, onboard audio processing and DSPs, and other features.

These codecs are all based off a common set of hardware IP so can be
supported by a core of common code (with a few minor device-to-device
variations).

Signed-off-by: Charles Keepax 
Signed-off-by: Nikesh Oswal 
Signed-off-by: Richard Fitzgerald 
---
Changes since V3:
- Fixed missing Kconfig dependency on PINCTRL
- commented purpose of madera_name_from_type(), call it earlier
  in probe and store the string in a member of struct madera
- removed the madera_get_num_micbias and madera_get_num_childbias
  exported functions and introduced static madera_set_micbias_info
  to init this information in members of struct madera
- adjusted the commenting on the switch that adds the LDO1 child driver
- squashed the two switches on hardware ID into one (we used to re-read
  the HWID after reset hence the second switch on it but as we don't do
  that now the two switches can be combined)
- pre-init ret to remove the else ret = 0 in madera_get_reset_gpio
  
Changes not made to V3 review comments:
- left the dev_dbg messages in runtime_suspend and runtime_resume,
  they are only _dbg and they've been useful in the past for debugging
 MAINTAINERS  |   3 +
 drivers/mfd/Kconfig  |  27 ++
 drivers/mfd/Makefile |   4 +
 drivers/mfd/madera-core.c| 611 +++
 drivers/mfd/madera-i2c.c | 135 +
 drivers/mfd/madera-spi.c | 135 +
 drivers/mfd/madera.h |  54 
 include/linux/mfd/madera/core.h  | 179 
 include/linux/mfd/madera/pdata.h |  61 
 9 files changed, 1209 insertions(+)
 create mode 100644 drivers/mfd/madera-core.c
 create mode 100644 drivers/mfd/madera-i2c.c
 create mode 100644 drivers/mfd/madera-spi.c
 create mode 100644 drivers/mfd/madera.h
 create mode 100644 include/linux/mfd/madera/core.h
 create mode 100644 include/linux/mfd/madera/pdata.h

diff --git a/MAINTAINERS b/MAINTAINERS
index f70d218..f335b2a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3376,7 +3376,10 @@ L:   patc...@opensource.wolfsonmicro.com
 T: git https://github.com/CirrusLogic/linux-drivers.git
 W: https://github.com/CirrusLogic/linux-drivers/wiki
 S: Supported
+F: Documentation/devicetree/bindings/mfd/madera.txt
 F: include/linux/mfd/madera/*
+F: drivers/mfd/madera*
+F: drivers/mfd/cs47l*
 
 CLEANCACHE API
 M: Konrad Rzeszutek Wilk 
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 94ad2c1..9ca7174 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -208,6 +208,33 @@ config MFD_CROS_EC_SPI
  response time cannot be guaranteed, we support ignoring
  'pre-amble' bytes before the response actually starts.
 
+config MFD_MADERA
+   bool
+   select MFD_CORE
+   select REGMAP
+   select REGMAP_IRQ
+   select MADERA_IRQ
+
+config MFD_MADERA_I2C
+   bool "Cirrus Logic Madera codecs with I2C"
+   select MFD_MADERA
+   select REGMAP_I2C
+   depends on I2C
+   depends on PINCTRL
+   help
+ Support for the Cirrus Logic Madera platform audio SoC
+ core functionality controlled via I2C.
+
+config MFD_MADERA_SPI
+   bool "Cirrus Logic Madera codecs with SPI"
+   select MFD_MADERA
+   select REGMAP_SPI
+   depends on SPI_MASTER
+   depends on PINCTRL
+   help
+ Support for the Cirrus Logic Madera platform audio SoC
+ core functionality controlled via SPI.
+
 config MFD_ASIC3
bool "Compaq ASIC3"
depends on GPIOLIB && ARM
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 080793b..71c658a 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -73,6 +73,10 @@ obj-$(CONFIG_MFD_WM8350_I2C) += wm8350-i2c.o
 wm8994-objs:= wm8994-core.o wm8994-irq.o wm8994-regmap.o
 obj-$(CONFIG_MFD_WM8994)   += wm8994.o
 
+obj-$(CONFIG_MFD_MADERA)   += madera-core.o
+obj-$(CONFIG_MFD_MADERA_I2C)   += madera-i2c.o
+obj-$(CONFIG_MFD_MADERA_SPI)   += madera-spi.o
+
 obj-$(CONFIG_TPS6105X) += tps6105x.o
 obj-$(CONFIG_TPS65010) += tps65010.o
 obj-$(CONFIG_TPS6507X) += tps6507x.o
diff --git a/drivers/mfd/madera-core.c b/drivers/mfd/madera-core.c
new file mode 100644
index 000..2d83a57
--- /dev/null
+++ b/drivers/mfd/madera-core.c
@@ -0,0 +1,611 @@
+/*
+ * Core MFD support for Cirrus Logic Madera codecs
+ *
+ * Copyright 2015-2017 Cirrus Logic
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 

[PATCH v4 03/17] mfd: madera: Add common support for Cirrus Logic Madera codecs

2017-07-28 Thread Richard Fitzgerald
This adds the generic core support for Cirrus Logic "Madera" class codecs.
These are complex audio codec SoCs with a variety of digital and analogue
I/O, onboard audio processing and DSPs, and other features.

These codecs are all based off a common set of hardware IP so can be
supported by a core of common code (with a few minor device-to-device
variations).

Signed-off-by: Charles Keepax 
Signed-off-by: Nikesh Oswal 
Signed-off-by: Richard Fitzgerald 
---
Changes since V3:
- Fixed missing Kconfig dependency on PINCTRL
- commented purpose of madera_name_from_type(), call it earlier
  in probe and store the string in a member of struct madera
- removed the madera_get_num_micbias and madera_get_num_childbias
  exported functions and introduced static madera_set_micbias_info
  to init this information in members of struct madera
- adjusted the commenting on the switch that adds the LDO1 child driver
- squashed the two switches on hardware ID into one (we used to re-read
  the HWID after reset hence the second switch on it but as we don't do
  that now the two switches can be combined)
- pre-init ret to remove the else ret = 0 in madera_get_reset_gpio
  
Changes not made to V3 review comments:
- left the dev_dbg messages in runtime_suspend and runtime_resume,
  they are only _dbg and they've been useful in the past for debugging
 MAINTAINERS  |   3 +
 drivers/mfd/Kconfig  |  27 ++
 drivers/mfd/Makefile |   4 +
 drivers/mfd/madera-core.c| 611 +++
 drivers/mfd/madera-i2c.c | 135 +
 drivers/mfd/madera-spi.c | 135 +
 drivers/mfd/madera.h |  54 
 include/linux/mfd/madera/core.h  | 179 
 include/linux/mfd/madera/pdata.h |  61 
 9 files changed, 1209 insertions(+)
 create mode 100644 drivers/mfd/madera-core.c
 create mode 100644 drivers/mfd/madera-i2c.c
 create mode 100644 drivers/mfd/madera-spi.c
 create mode 100644 drivers/mfd/madera.h
 create mode 100644 include/linux/mfd/madera/core.h
 create mode 100644 include/linux/mfd/madera/pdata.h

diff --git a/MAINTAINERS b/MAINTAINERS
index f70d218..f335b2a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3376,7 +3376,10 @@ L:   patc...@opensource.wolfsonmicro.com
 T: git https://github.com/CirrusLogic/linux-drivers.git
 W: https://github.com/CirrusLogic/linux-drivers/wiki
 S: Supported
+F: Documentation/devicetree/bindings/mfd/madera.txt
 F: include/linux/mfd/madera/*
+F: drivers/mfd/madera*
+F: drivers/mfd/cs47l*
 
 CLEANCACHE API
 M: Konrad Rzeszutek Wilk 
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 94ad2c1..9ca7174 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -208,6 +208,33 @@ config MFD_CROS_EC_SPI
  response time cannot be guaranteed, we support ignoring
  'pre-amble' bytes before the response actually starts.
 
+config MFD_MADERA
+   bool
+   select MFD_CORE
+   select REGMAP
+   select REGMAP_IRQ
+   select MADERA_IRQ
+
+config MFD_MADERA_I2C
+   bool "Cirrus Logic Madera codecs with I2C"
+   select MFD_MADERA
+   select REGMAP_I2C
+   depends on I2C
+   depends on PINCTRL
+   help
+ Support for the Cirrus Logic Madera platform audio SoC
+ core functionality controlled via I2C.
+
+config MFD_MADERA_SPI
+   bool "Cirrus Logic Madera codecs with SPI"
+   select MFD_MADERA
+   select REGMAP_SPI
+   depends on SPI_MASTER
+   depends on PINCTRL
+   help
+ Support for the Cirrus Logic Madera platform audio SoC
+ core functionality controlled via SPI.
+
 config MFD_ASIC3
bool "Compaq ASIC3"
depends on GPIOLIB && ARM
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 080793b..71c658a 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -73,6 +73,10 @@ obj-$(CONFIG_MFD_WM8350_I2C) += wm8350-i2c.o
 wm8994-objs:= wm8994-core.o wm8994-irq.o wm8994-regmap.o
 obj-$(CONFIG_MFD_WM8994)   += wm8994.o
 
+obj-$(CONFIG_MFD_MADERA)   += madera-core.o
+obj-$(CONFIG_MFD_MADERA_I2C)   += madera-i2c.o
+obj-$(CONFIG_MFD_MADERA_SPI)   += madera-spi.o
+
 obj-$(CONFIG_TPS6105X) += tps6105x.o
 obj-$(CONFIG_TPS65010) += tps65010.o
 obj-$(CONFIG_TPS6507X) += tps6507x.o
diff --git a/drivers/mfd/madera-core.c b/drivers/mfd/madera-core.c
new file mode 100644
index 000..2d83a57
--- /dev/null
+++ b/drivers/mfd/madera-core.c
@@ -0,0 +1,611 @@
+/*
+ * Core MFD support for Cirrus Logic Madera codecs
+ *
+ * Copyright 2015-2017 Cirrus Logic
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 

[PATCH v4 14/17] ASoC: madera: Add common support for Cirrus Logic Madera codecs

2017-07-28 Thread Richard Fitzgerald
The Cirrus Logic Madera codecs are a family of related codecs with
extensive digital and analogue I/O, digital mixing and routing,
signal processing and programmable DSPs.

This patch adds common support code shared by all Madera codecs.

Signed-off-by: Charles Keepax 
Signed-off-by: Nariman Poushin 
Signed-off-by: Nikesh Oswal 
Signed-off-by: Piotr Stankiewicz 
Signed-off-by: Ajit Pandey 
Signed-off-by: Richard Fitzgerald 
---
Changes since V3:
- include/dt-bindings/sound/madera.h was moved into previous patch (#13)
- fixed bug in madera_inmux_put where the DMIC mode wasn't being updated
  in the register for unganged inputs
 MAINTAINERS  |4 +
 include/sound/madera-pdata.h |   61 +
 sound/soc/codecs/Kconfig |5 +
 sound/soc/codecs/Makefile|2 +
 sound/soc/codecs/madera.c| 4438 ++
 sound/soc/codecs/madera.h|  470 +
 6 files changed, 4980 insertions(+)
 create mode 100644 include/sound/madera-pdata.h
 create mode 100644 sound/soc/codecs/madera.c
 create mode 100644 sound/soc/codecs/madera.h

diff --git a/MAINTAINERS b/MAINTAINERS
index cd2a8e2..57b52a0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3378,14 +3378,18 @@ W:  
https://github.com/CirrusLogic/linux-drivers/wiki
 S: Supported
 F: Documentation/devicetree/bindings/mfd/madera.txt
 F: Documentation/devicetree/bindings/pinctrl/cirrus,madera-pinctrl.txt
+F: Documentation/devicetree/bindings/sound/madera.txt
 F: include/dt-bindings/sound/madera*
 F: include/linux/irqchip/irq-madera*
 F: include/linux/mfd/madera/*
+F: include/sound/madera*
 F: drivers/gpio/gpio-madera*
 F: drivers/irqchip/irq-madera*
 F: drivers/mfd/madera*
 F: drivers/mfd/cs47l*
 F: drivers/pinctrl/cirrus/*
+F: sound/soc/codecs/cs47l*
+F: sound/soc/codecs/madera*
 
 CLEANCACHE API
 M: Konrad Rzeszutek Wilk 
diff --git a/include/sound/madera-pdata.h b/include/sound/madera-pdata.h
new file mode 100644
index 000..47f6b44
--- /dev/null
+++ b/include/sound/madera-pdata.h
@@ -0,0 +1,61 @@
+/*
+ * Platform data for Madera codec driver
+ *
+ * Copyright 2016-2017 Cirrus Logic
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef MADERA_CODEC_PDATA_H
+#define MADERA_CODEC_PDATA_H
+
+#include 
+
+#define MADERA_MAX_INPUT   6
+#define MADERA_MAX_MUXED_CHANNELS  4
+#define MADERA_MAX_OUTPUT  6
+#define MADERA_MAX_AIF 4
+#define MADERA_MAX_PDM_SPK 2
+#define MADERA_MAX_DSP 7
+
+/**
+ * struct madera_codec_pdata
+ *
+ * @max_channels_clocked: Maximum number of channels that I2S clocks will be
+ *   generated for. Useful when clock master for systems
+ *   where the I2S bus has multiple data lines.
+ * @dmic_ref:Indicates how the MICBIAS pins have been externally
+ *   connected to DMICs on each input. A value of 0
+ *   indicates MICVDD and is the default. Other values are:
+ *   For CS47L35 one of the CS47L35_DMIC_REF_xxx values
+ *   For all other codecs one of the MADERA_DMIC_REF_xxx
+ *   Also see the datasheet for a description of the
+ *   INn_DMIC_SUP field.
+ * @inmode:  Mode for the ADC inputs. One of the MADERA_INMODE_xxx
+ *   values. Two-dimensional array
+ *   [input_number][channel number], with four slots per
+ *   input in the order
+ *   [n][0]=INnAL [n][1]=INnAR [n][2]=INnBL [n][3]=INnBR
+ * @out_mono:For each output set the value to TRUE to indicate that
+ *   the output is mono. [0]=OUT1, [1]=OUT2, ...
+ * @pdm_fmt: PDM speaker data format. See the PDM_SPKn_FMT field in
+ *   the datasheet for a description of this value.
+ * @pdm_mute:PDM mute format. See the PDM_SPKn_CTRL_1 register
+ *   in the datasheet for a description of this value.
+ */
+struct madera_codec_pdata {
+   u32 max_channels_clocked[MADERA_MAX_AIF];
+
+   u32 dmic_ref[MADERA_MAX_INPUT];
+
+   u32 inmode[MADERA_MAX_INPUT][MADERA_MAX_MUXED_CHANNELS];
+
+   bool out_mono[MADERA_MAX_OUTPUT];
+
+   u32 pdm_fmt[MADERA_MAX_PDM_SPK];
+   u32 pdm_mute[MADERA_MAX_PDM_SPK];
+};
+
+#endif
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 024ddc9..bea30bf 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ 

[PATCH v4 14/17] ASoC: madera: Add common support for Cirrus Logic Madera codecs

2017-07-28 Thread Richard Fitzgerald
The Cirrus Logic Madera codecs are a family of related codecs with
extensive digital and analogue I/O, digital mixing and routing,
signal processing and programmable DSPs.

This patch adds common support code shared by all Madera codecs.

Signed-off-by: Charles Keepax 
Signed-off-by: Nariman Poushin 
Signed-off-by: Nikesh Oswal 
Signed-off-by: Piotr Stankiewicz 
Signed-off-by: Ajit Pandey 
Signed-off-by: Richard Fitzgerald 
---
Changes since V3:
- include/dt-bindings/sound/madera.h was moved into previous patch (#13)
- fixed bug in madera_inmux_put where the DMIC mode wasn't being updated
  in the register for unganged inputs
 MAINTAINERS  |4 +
 include/sound/madera-pdata.h |   61 +
 sound/soc/codecs/Kconfig |5 +
 sound/soc/codecs/Makefile|2 +
 sound/soc/codecs/madera.c| 4438 ++
 sound/soc/codecs/madera.h|  470 +
 6 files changed, 4980 insertions(+)
 create mode 100644 include/sound/madera-pdata.h
 create mode 100644 sound/soc/codecs/madera.c
 create mode 100644 sound/soc/codecs/madera.h

diff --git a/MAINTAINERS b/MAINTAINERS
index cd2a8e2..57b52a0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3378,14 +3378,18 @@ W:  
https://github.com/CirrusLogic/linux-drivers/wiki
 S: Supported
 F: Documentation/devicetree/bindings/mfd/madera.txt
 F: Documentation/devicetree/bindings/pinctrl/cirrus,madera-pinctrl.txt
+F: Documentation/devicetree/bindings/sound/madera.txt
 F: include/dt-bindings/sound/madera*
 F: include/linux/irqchip/irq-madera*
 F: include/linux/mfd/madera/*
+F: include/sound/madera*
 F: drivers/gpio/gpio-madera*
 F: drivers/irqchip/irq-madera*
 F: drivers/mfd/madera*
 F: drivers/mfd/cs47l*
 F: drivers/pinctrl/cirrus/*
+F: sound/soc/codecs/cs47l*
+F: sound/soc/codecs/madera*
 
 CLEANCACHE API
 M: Konrad Rzeszutek Wilk 
diff --git a/include/sound/madera-pdata.h b/include/sound/madera-pdata.h
new file mode 100644
index 000..47f6b44
--- /dev/null
+++ b/include/sound/madera-pdata.h
@@ -0,0 +1,61 @@
+/*
+ * Platform data for Madera codec driver
+ *
+ * Copyright 2016-2017 Cirrus Logic
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef MADERA_CODEC_PDATA_H
+#define MADERA_CODEC_PDATA_H
+
+#include 
+
+#define MADERA_MAX_INPUT   6
+#define MADERA_MAX_MUXED_CHANNELS  4
+#define MADERA_MAX_OUTPUT  6
+#define MADERA_MAX_AIF 4
+#define MADERA_MAX_PDM_SPK 2
+#define MADERA_MAX_DSP 7
+
+/**
+ * struct madera_codec_pdata
+ *
+ * @max_channels_clocked: Maximum number of channels that I2S clocks will be
+ *   generated for. Useful when clock master for systems
+ *   where the I2S bus has multiple data lines.
+ * @dmic_ref:Indicates how the MICBIAS pins have been externally
+ *   connected to DMICs on each input. A value of 0
+ *   indicates MICVDD and is the default. Other values are:
+ *   For CS47L35 one of the CS47L35_DMIC_REF_xxx values
+ *   For all other codecs one of the MADERA_DMIC_REF_xxx
+ *   Also see the datasheet for a description of the
+ *   INn_DMIC_SUP field.
+ * @inmode:  Mode for the ADC inputs. One of the MADERA_INMODE_xxx
+ *   values. Two-dimensional array
+ *   [input_number][channel number], with four slots per
+ *   input in the order
+ *   [n][0]=INnAL [n][1]=INnAR [n][2]=INnBL [n][3]=INnBR
+ * @out_mono:For each output set the value to TRUE to indicate that
+ *   the output is mono. [0]=OUT1, [1]=OUT2, ...
+ * @pdm_fmt: PDM speaker data format. See the PDM_SPKn_FMT field in
+ *   the datasheet for a description of this value.
+ * @pdm_mute:PDM mute format. See the PDM_SPKn_CTRL_1 register
+ *   in the datasheet for a description of this value.
+ */
+struct madera_codec_pdata {
+   u32 max_channels_clocked[MADERA_MAX_AIF];
+
+   u32 dmic_ref[MADERA_MAX_INPUT];
+
+   u32 inmode[MADERA_MAX_INPUT][MADERA_MAX_MUXED_CHANNELS];
+
+   bool out_mono[MADERA_MAX_OUTPUT];
+
+   u32 pdm_fmt[MADERA_MAX_PDM_SPK];
+   u32 pdm_mute[MADERA_MAX_PDM_SPK];
+};
+
+#endif
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 024ddc9..bea30bf 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -250,10 +250,12 @@ config SND_SOC_WM_HUBS
 config SND_SOC_WM_ADSP
tristate
select SND_SOC_COMPRESS
+   default y if SND_SOC_MADERA=y
default y if SND_SOC_CS47L24=y
default y if 

Re: [PATCH v2 6/7] mailbox: bcm-flexrm-mailbox: Set msg_queue_len for each channel

2017-07-28 Thread Anup Patel
On Fri, Jul 28, 2017 at 2:34 PM, Jassi Brar  wrote:
> On Fri, Jul 28, 2017 at 2:19 PM, Anup Patel  wrote:
>> On Thu, Jul 27, 2017 at 5:23 PM, Jassi Brar  wrote:
>>> On Thu, Jul 27, 2017 at 11:20 AM, Anup Patel  
>>> wrote:
 On Thu, Jul 27, 2017 at 10:29 AM, Jassi Brar  
 wrote:
>>>
>> Sorry for the delayed response...
>>
>> On Fri, Jul 21, 2017 at 9:16 PM, Jassi Brar 
>>  wrote:
>>> Hi Anup,
>>>
>>> On Fri, Jul 21, 2017 at 12:25 PM, Anup Patel 
>>>  wrote:
 The Broadcom FlexRM ring (i.e. mailbox channel) can handle
 larger number of messages queued in one FlexRM ring hence
 this patch sets msg_queue_len for each mailbox channel to
 be same as RING_MAX_REQ_COUNT.

 Signed-off-by: Anup Patel 
 Reviewed-by: Scott Branden 
 ---
  drivers/mailbox/bcm-flexrm-mailbox.c | 5 -
  1 file changed, 4 insertions(+), 1 deletion(-)

 diff --git a/drivers/mailbox/bcm-flexrm-mailbox.c 
 b/drivers/mailbox/bcm-flexrm-mailbox.c
 index 9873818..20055a0 100644
 --- a/drivers/mailbox/bcm-flexrm-mailbox.c
 +++ b/drivers/mailbox/bcm-flexrm-mailbox.c
 @@ -1683,8 +1683,11 @@ static int flexrm_mbox_probe(struct 
 platform_device *pdev)
 ret = -ENOMEM;
 goto fail_free_debugfs_root;
 }
 -   for (index = 0; index < mbox->num_rings; index++)
 +   for (index = 0; index < mbox->num_rings; index++) {
 +   mbox->controller.chans[index].msg_queue_len =
 +   RING_MAX_REQ_COUNT;
 mbox->controller.chans[index].con_priv = 
 >rings[index];
 +   }

>>> While writing mailbox.c I wasn't unaware that there is the option to
>>> choose the queue length at runtime.
>>> The idea was to keep the code as simple as possible. I am open to
>>> making it a runtime thing, but first, please help me understand how
>>> that is useful here.
>>>
>>> I understand FlexRm has a ring buffer of RING_MAX_REQ_COUNT(1024)
>>> elements. Any message submitted to mailbox api can be immediately
>>> written onto the ringbuffer if there is some space.
>>> Is there any mechanism to report back to a client driver, if its
>>> message in ringbuffer failed "to be sent"?
>>> If there isn't any, then I think, in flexrm_last_tx_done() you 
>>> should
>>> simply return true if there is some space left in the rung-buffer,
>>> false otherwise.
>>
>> Yes, we have error code in "struct brcm_message" to report back
>> errors from send_message. In our mailbox clients, we check
>> return value of mbox_send_message() and also the error code
>> in "struct brcm_message".
>>
> I meant after the message has been accepted in the ringbuffer but the
> remote failed to receive it.

 Yes, even this case is handled.

 In case of IO errors after message has been put in ring buffer, we get
 completion message with error code and mailbox client drivers will
 receive back "struct brcm_message" with error set.

 You can refer flexrm_process_completions() for more details.

> It doesn't seem to be what I suggest. I see two issues in
> flexrm_process_completions()
> 1) It calls mbox_send_message(), which is a big NO for a controller
> driver. Why should you have one more message stored outside of
> ringbuffer?

 The "last_pending_msg" in each FlexRM ring was added to fit FlexRM
 in Mailbox framework.

 We don't have any IRQ for TX done so "txdone_irq" out of the question for
 FlexRM. We only have completions for both success or failures (IO errors).

 This means we have to use "txdone_poll" for FlexRM. For "txdone_poll",
 we have to provide last_tx_done() callback. The last_tx_done() callback
 is supposed to return true if last send_data() call succeeded.

 To implement last_tx_done() in FlexRM driver, we added "last_pending_msg".

 When "last_pending_msg" is NULL it means last call to send_data() succeeded
 and when "last_pending_msg" is != NULL it means last call to send_data()
 did not go through due to lack of space in FlexRM ring.

>>> It could be simpler.
>>> Since flexrm_send_data() is essentially about 

Re: [PATCH v2 6/7] mailbox: bcm-flexrm-mailbox: Set msg_queue_len for each channel

2017-07-28 Thread Anup Patel
On Fri, Jul 28, 2017 at 2:34 PM, Jassi Brar  wrote:
> On Fri, Jul 28, 2017 at 2:19 PM, Anup Patel  wrote:
>> On Thu, Jul 27, 2017 at 5:23 PM, Jassi Brar  wrote:
>>> On Thu, Jul 27, 2017 at 11:20 AM, Anup Patel  
>>> wrote:
 On Thu, Jul 27, 2017 at 10:29 AM, Jassi Brar  
 wrote:
>>>
>> Sorry for the delayed response...
>>
>> On Fri, Jul 21, 2017 at 9:16 PM, Jassi Brar 
>>  wrote:
>>> Hi Anup,
>>>
>>> On Fri, Jul 21, 2017 at 12:25 PM, Anup Patel 
>>>  wrote:
 The Broadcom FlexRM ring (i.e. mailbox channel) can handle
 larger number of messages queued in one FlexRM ring hence
 this patch sets msg_queue_len for each mailbox channel to
 be same as RING_MAX_REQ_COUNT.

 Signed-off-by: Anup Patel 
 Reviewed-by: Scott Branden 
 ---
  drivers/mailbox/bcm-flexrm-mailbox.c | 5 -
  1 file changed, 4 insertions(+), 1 deletion(-)

 diff --git a/drivers/mailbox/bcm-flexrm-mailbox.c 
 b/drivers/mailbox/bcm-flexrm-mailbox.c
 index 9873818..20055a0 100644
 --- a/drivers/mailbox/bcm-flexrm-mailbox.c
 +++ b/drivers/mailbox/bcm-flexrm-mailbox.c
 @@ -1683,8 +1683,11 @@ static int flexrm_mbox_probe(struct 
 platform_device *pdev)
 ret = -ENOMEM;
 goto fail_free_debugfs_root;
 }
 -   for (index = 0; index < mbox->num_rings; index++)
 +   for (index = 0; index < mbox->num_rings; index++) {
 +   mbox->controller.chans[index].msg_queue_len =
 +   RING_MAX_REQ_COUNT;
 mbox->controller.chans[index].con_priv = 
 >rings[index];
 +   }

>>> While writing mailbox.c I wasn't unaware that there is the option to
>>> choose the queue length at runtime.
>>> The idea was to keep the code as simple as possible. I am open to
>>> making it a runtime thing, but first, please help me understand how
>>> that is useful here.
>>>
>>> I understand FlexRm has a ring buffer of RING_MAX_REQ_COUNT(1024)
>>> elements. Any message submitted to mailbox api can be immediately
>>> written onto the ringbuffer if there is some space.
>>> Is there any mechanism to report back to a client driver, if its
>>> message in ringbuffer failed "to be sent"?
>>> If there isn't any, then I think, in flexrm_last_tx_done() you 
>>> should
>>> simply return true if there is some space left in the rung-buffer,
>>> false otherwise.
>>
>> Yes, we have error code in "struct brcm_message" to report back
>> errors from send_message. In our mailbox clients, we check
>> return value of mbox_send_message() and also the error code
>> in "struct brcm_message".
>>
> I meant after the message has been accepted in the ringbuffer but the
> remote failed to receive it.

 Yes, even this case is handled.

 In case of IO errors after message has been put in ring buffer, we get
 completion message with error code and mailbox client drivers will
 receive back "struct brcm_message" with error set.

 You can refer flexrm_process_completions() for more details.

> It doesn't seem to be what I suggest. I see two issues in
> flexrm_process_completions()
> 1) It calls mbox_send_message(), which is a big NO for a controller
> driver. Why should you have one more message stored outside of
> ringbuffer?

 The "last_pending_msg" in each FlexRM ring was added to fit FlexRM
 in Mailbox framework.

 We don't have any IRQ for TX done so "txdone_irq" out of the question for
 FlexRM. We only have completions for both success or failures (IO errors).

 This means we have to use "txdone_poll" for FlexRM. For "txdone_poll",
 we have to provide last_tx_done() callback. The last_tx_done() callback
 is supposed to return true if last send_data() call succeeded.

 To implement last_tx_done() in FlexRM driver, we added "last_pending_msg".

 When "last_pending_msg" is NULL it means last call to send_data() succeeded
 and when "last_pending_msg" is != NULL it means last call to send_data()
 did not go through due to lack of space in FlexRM ring.

>>> It could be simpler.
>>> Since flexrm_send_data() is essentially about putting the message in
>>> the ring-buffer (and not about _transmission_ failures), the
>>> last_tx_done() should simply return true if requests_ida has not all
>>> ids allocated. False otherwise.
>>
>> It's not that simple because 

Re: [PATCH 2/3] ARM: sunxi: h3/h5: Add sun8i-h3-ephy compatible

2017-07-28 Thread Icenowy Zheng


于 2017年7月28日 GMT+08:00 下午5:44:51, Chen-Yu Tsai  写到:
>On Fri, Jul 28, 2017 at 5:28 PM, Corentin Labbe
> wrote:
>> This patch adds the sun8i-h3-ephy compatible to the internal PHY.
>>
>> Signed-off-by: Corentin Labbe 
>> ---
>>  arch/arm/boot/dts/sunxi-h3-h5.dtsi | 3 ++-
>
>To avoid repeating the past, this patch, if approved, will be merged
>through the sunxi tree, not netdev nor net-next.
>
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm/boot/dts/sunxi-h3-h5.dtsi
>b/arch/arm/boot/dts/sunxi-h3-h5.dtsi
>> index 4b599b5d26f6..7aaa837c2388 100644
>> --- a/arch/arm/boot/dts/sunxi-h3-h5.dtsi
>> +++ b/arch/arm/boot/dts/sunxi-h3-h5.dtsi
>> @@ -421,7 +421,8 @@
>> #address-cells = <1>;
>> #size-cells = <0>;
>> int_mii_phy: ethernet-phy@1 {
>> -   compatible =
>"ethernet-phy-ieee802.3-c22";
>> +   compatible =
>"allwinner,sun8i-h3-ephy",
>> +  
>"ethernet-phy-ieee802.3-c22";
>
>Are you expecting people to override this properly?
>
>As it currently is, any external phy at address 1 will simply
>reuse the same device node. And if they don't override the
>property correctly, the driver will end up trying to use
>the internal phy, while the user is expecting the external
>one to be used.
>
>Maybe you could move this to some other address, maybe the last
>valid one, or second last valid one?

Some board designers may use other address.

For example, on Nano Pi NEO2 the PHY is attached at address 0x7.

>
>ChenYu
>
>> reg = <1>;
>> clocks = < CLK_BUS_EPHY>;
>> resets = < RST_BUS_EPHY>;
>> --
>> 2.13.0
>>


Re: [PATCH 2/3] ARM: sunxi: h3/h5: Add sun8i-h3-ephy compatible

2017-07-28 Thread Icenowy Zheng


于 2017年7月28日 GMT+08:00 下午5:44:51, Chen-Yu Tsai  写到:
>On Fri, Jul 28, 2017 at 5:28 PM, Corentin Labbe
> wrote:
>> This patch adds the sun8i-h3-ephy compatible to the internal PHY.
>>
>> Signed-off-by: Corentin Labbe 
>> ---
>>  arch/arm/boot/dts/sunxi-h3-h5.dtsi | 3 ++-
>
>To avoid repeating the past, this patch, if approved, will be merged
>through the sunxi tree, not netdev nor net-next.
>
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm/boot/dts/sunxi-h3-h5.dtsi
>b/arch/arm/boot/dts/sunxi-h3-h5.dtsi
>> index 4b599b5d26f6..7aaa837c2388 100644
>> --- a/arch/arm/boot/dts/sunxi-h3-h5.dtsi
>> +++ b/arch/arm/boot/dts/sunxi-h3-h5.dtsi
>> @@ -421,7 +421,8 @@
>> #address-cells = <1>;
>> #size-cells = <0>;
>> int_mii_phy: ethernet-phy@1 {
>> -   compatible =
>"ethernet-phy-ieee802.3-c22";
>> +   compatible =
>"allwinner,sun8i-h3-ephy",
>> +  
>"ethernet-phy-ieee802.3-c22";
>
>Are you expecting people to override this properly?
>
>As it currently is, any external phy at address 1 will simply
>reuse the same device node. And if they don't override the
>property correctly, the driver will end up trying to use
>the internal phy, while the user is expecting the external
>one to be used.
>
>Maybe you could move this to some other address, maybe the last
>valid one, or second last valid one?

Some board designers may use other address.

For example, on Nano Pi NEO2 the PHY is attached at address 0x7.

>
>ChenYu
>
>> reg = <1>;
>> clocks = < CLK_BUS_EPHY>;
>> resets = < RST_BUS_EPHY>;
>> --
>> 2.13.0
>>


[PATCH v4 08/17] regulator: arizona-ldo1: Add support for Cirrus Logic Madera codecs

2017-07-28 Thread Richard Fitzgerald
This adds a new driver identity "madera-ldo1" and probe function
so that this driver can be used to control the LDO1 regulator on
some Cirrus Logic Madera codecs.

Signed-off-by: Richard Fitzgerald 
---
No changes since V3

 drivers/regulator/Kconfig|  8 ++--
 drivers/regulator/arizona-ldo1.c | 82 +++-
 2 files changed, 85 insertions(+), 5 deletions(-)

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index ed5679f..85c5f7a 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -126,12 +126,12 @@ config REGULATOR_AB8500
  signal AB8500 PMIC
 
 config REGULATOR_ARIZONA_LDO1
-   tristate "Wolfson Arizona class devices LDO1"
-   depends on MFD_ARIZONA
+   tristate "Cirrus Madera and Wolfson Arizona class devices LDO1"
+   depends on MFD_ARIZONA || MFD_MADERA
depends on SND_SOC
help
- Support for the LDO1 regulators found on Wolfson Arizona class
- devices.
+ Support for the LDO1 regulators found on Cirrus Logic Madera codecs
+ and Wolfson Arizona codecs.
 
 config REGULATOR_ARIZONA_MICSUPP
tristate "Cirrus Madera and Wolfson Arizona class devices MICSUPP"
diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c
index 96fddff..c64625e 100644
--- a/drivers/regulator/arizona-ldo1.c
+++ b/drivers/regulator/arizona-ldo1.c
@@ -31,6 +31,10 @@
 #include 
 #include 
 
+#include 
+#include 
+#include 
+
 struct arizona_ldo1 {
struct regulator_dev *regulator;
struct regmap *regmap;
@@ -188,6 +192,31 @@ static int arizona_ldo1_hc_get_voltage_sel(struct 
regulator_dev *rdev)
.num_consumer_supplies = 1,
 };
 
+static const struct regulator_desc madera_ldo1 = {
+   .name = "LDO1",
+   .supply_name = "LDOVDD",
+   .type = REGULATOR_VOLTAGE,
+   .ops = _ldo1_ops,
+
+   .vsel_reg = MADERA_LDO1_CONTROL_1,
+   .vsel_mask = MADERA_LDO1_VSEL_MASK,
+   .min_uV = 90,
+   .uV_step = 25000,
+   .n_voltages = 13,
+   .enable_time = 3000,
+
+   .owner = THIS_MODULE,
+};
+
+static const struct regulator_init_data madera_ldo1_default = {
+   .constraints = {
+   .min_uV = 120,
+   .max_uV = 120,
+   .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+   },
+   .num_consumer_supplies = 1,
+};
+
 static int arizona_ldo1_of_get_pdata(struct arizona_ldo1_pdata *pdata,
 struct regulator_config *config,
 const struct regulator_desc *desc,
@@ -341,6 +370,32 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
return ret;
 }
 
+static int madera_ldo1_probe(struct platform_device *pdev)
+{
+   struct madera *madera = dev_get_drvdata(pdev->dev.parent);
+   struct arizona_ldo1 *ldo1;
+   bool external_dcvdd;
+   int ret;
+
+   ldo1 = devm_kzalloc(>dev, sizeof(*ldo1), GFP_KERNEL);
+   if (!ldo1)
+   return -ENOMEM;
+
+   ldo1->regmap = madera->regmap;
+
+   ldo1->init_data = madera_ldo1_default;
+
+   ret = arizona_ldo1_common_init(pdev, ldo1, _ldo1,
+  >pdata.ldo1,
+  _dcvdd);
+   if (ret)
+   return ret;
+
+   madera->internal_dcvdd = !external_dcvdd;
+
+   return 0;
+}
+
 static struct platform_driver arizona_ldo1_driver = {
.probe = arizona_ldo1_probe,
.driver = {
@@ -348,10 +403,35 @@ static int arizona_ldo1_probe(struct platform_device 
*pdev)
},
 };
 
-module_platform_driver(arizona_ldo1_driver);
+static struct platform_driver madera_ldo1_driver = {
+   .probe = madera_ldo1_probe,
+   .driver = {
+   .name   = "madera-ldo1",
+   },
+};
+
+static struct platform_driver * const madera_ldo1_drivers[] = {
+   _ldo1_driver,
+   _ldo1_driver,
+};
+
+static int __init arizona_ldo1_init(void)
+{
+   return platform_register_drivers(madera_ldo1_drivers,
+ARRAY_SIZE(madera_ldo1_drivers));
+}
+module_init(arizona_ldo1_init);
+
+static void __exit madera_ldo1_exit(void)
+{
+   platform_unregister_drivers(madera_ldo1_drivers,
+   ARRAY_SIZE(madera_ldo1_drivers));
+}
+module_exit(madera_ldo1_exit);
 
 /* Module information */
 MODULE_AUTHOR("Mark Brown ");
 MODULE_DESCRIPTION("Arizona LDO1 driver");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS("platform:arizona-ldo1");
+MODULE_ALIAS("platform:madera-ldo1");
-- 
1.9.1



[PATCH v4 08/17] regulator: arizona-ldo1: Add support for Cirrus Logic Madera codecs

2017-07-28 Thread Richard Fitzgerald
This adds a new driver identity "madera-ldo1" and probe function
so that this driver can be used to control the LDO1 regulator on
some Cirrus Logic Madera codecs.

Signed-off-by: Richard Fitzgerald 
---
No changes since V3

 drivers/regulator/Kconfig|  8 ++--
 drivers/regulator/arizona-ldo1.c | 82 +++-
 2 files changed, 85 insertions(+), 5 deletions(-)

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index ed5679f..85c5f7a 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -126,12 +126,12 @@ config REGULATOR_AB8500
  signal AB8500 PMIC
 
 config REGULATOR_ARIZONA_LDO1
-   tristate "Wolfson Arizona class devices LDO1"
-   depends on MFD_ARIZONA
+   tristate "Cirrus Madera and Wolfson Arizona class devices LDO1"
+   depends on MFD_ARIZONA || MFD_MADERA
depends on SND_SOC
help
- Support for the LDO1 regulators found on Wolfson Arizona class
- devices.
+ Support for the LDO1 regulators found on Cirrus Logic Madera codecs
+ and Wolfson Arizona codecs.
 
 config REGULATOR_ARIZONA_MICSUPP
tristate "Cirrus Madera and Wolfson Arizona class devices MICSUPP"
diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c
index 96fddff..c64625e 100644
--- a/drivers/regulator/arizona-ldo1.c
+++ b/drivers/regulator/arizona-ldo1.c
@@ -31,6 +31,10 @@
 #include 
 #include 
 
+#include 
+#include 
+#include 
+
 struct arizona_ldo1 {
struct regulator_dev *regulator;
struct regmap *regmap;
@@ -188,6 +192,31 @@ static int arizona_ldo1_hc_get_voltage_sel(struct 
regulator_dev *rdev)
.num_consumer_supplies = 1,
 };
 
+static const struct regulator_desc madera_ldo1 = {
+   .name = "LDO1",
+   .supply_name = "LDOVDD",
+   .type = REGULATOR_VOLTAGE,
+   .ops = _ldo1_ops,
+
+   .vsel_reg = MADERA_LDO1_CONTROL_1,
+   .vsel_mask = MADERA_LDO1_VSEL_MASK,
+   .min_uV = 90,
+   .uV_step = 25000,
+   .n_voltages = 13,
+   .enable_time = 3000,
+
+   .owner = THIS_MODULE,
+};
+
+static const struct regulator_init_data madera_ldo1_default = {
+   .constraints = {
+   .min_uV = 120,
+   .max_uV = 120,
+   .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+   },
+   .num_consumer_supplies = 1,
+};
+
 static int arizona_ldo1_of_get_pdata(struct arizona_ldo1_pdata *pdata,
 struct regulator_config *config,
 const struct regulator_desc *desc,
@@ -341,6 +370,32 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
return ret;
 }
 
+static int madera_ldo1_probe(struct platform_device *pdev)
+{
+   struct madera *madera = dev_get_drvdata(pdev->dev.parent);
+   struct arizona_ldo1 *ldo1;
+   bool external_dcvdd;
+   int ret;
+
+   ldo1 = devm_kzalloc(>dev, sizeof(*ldo1), GFP_KERNEL);
+   if (!ldo1)
+   return -ENOMEM;
+
+   ldo1->regmap = madera->regmap;
+
+   ldo1->init_data = madera_ldo1_default;
+
+   ret = arizona_ldo1_common_init(pdev, ldo1, _ldo1,
+  >pdata.ldo1,
+  _dcvdd);
+   if (ret)
+   return ret;
+
+   madera->internal_dcvdd = !external_dcvdd;
+
+   return 0;
+}
+
 static struct platform_driver arizona_ldo1_driver = {
.probe = arizona_ldo1_probe,
.driver = {
@@ -348,10 +403,35 @@ static int arizona_ldo1_probe(struct platform_device 
*pdev)
},
 };
 
-module_platform_driver(arizona_ldo1_driver);
+static struct platform_driver madera_ldo1_driver = {
+   .probe = madera_ldo1_probe,
+   .driver = {
+   .name   = "madera-ldo1",
+   },
+};
+
+static struct platform_driver * const madera_ldo1_drivers[] = {
+   _ldo1_driver,
+   _ldo1_driver,
+};
+
+static int __init arizona_ldo1_init(void)
+{
+   return platform_register_drivers(madera_ldo1_drivers,
+ARRAY_SIZE(madera_ldo1_drivers));
+}
+module_init(arizona_ldo1_init);
+
+static void __exit madera_ldo1_exit(void)
+{
+   platform_unregister_drivers(madera_ldo1_drivers,
+   ARRAY_SIZE(madera_ldo1_drivers));
+}
+module_exit(madera_ldo1_exit);
 
 /* Module information */
 MODULE_AUTHOR("Mark Brown ");
 MODULE_DESCRIPTION("Arizona LDO1 driver");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS("platform:arizona-ldo1");
+MODULE_ALIAS("platform:madera-ldo1");
-- 
1.9.1



Re: [PATCH 2/3] ARM: sunxi: h3/h5: Add sun8i-h3-ephy compatible

2017-07-28 Thread Chen-Yu Tsai
On Fri, Jul 28, 2017 at 5:28 PM, Corentin Labbe
 wrote:
> This patch adds the sun8i-h3-ephy compatible to the internal PHY.
>
> Signed-off-by: Corentin Labbe 
> ---
>  arch/arm/boot/dts/sunxi-h3-h5.dtsi | 3 ++-

To avoid repeating the past, this patch, if approved, will be merged
through the sunxi tree, not netdev nor net-next.

>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/boot/dts/sunxi-h3-h5.dtsi 
> b/arch/arm/boot/dts/sunxi-h3-h5.dtsi
> index 4b599b5d26f6..7aaa837c2388 100644
> --- a/arch/arm/boot/dts/sunxi-h3-h5.dtsi
> +++ b/arch/arm/boot/dts/sunxi-h3-h5.dtsi
> @@ -421,7 +421,8 @@
> #address-cells = <1>;
> #size-cells = <0>;
> int_mii_phy: ethernet-phy@1 {
> -   compatible = 
> "ethernet-phy-ieee802.3-c22";
> +   compatible = 
> "allwinner,sun8i-h3-ephy",
> +   
> "ethernet-phy-ieee802.3-c22";

Are you expecting people to override this properly?

As it currently is, any external phy at address 1 will simply
reuse the same device node. And if they don't override the
property correctly, the driver will end up trying to use
the internal phy, while the user is expecting the external
one to be used.

Maybe you could move this to some other address, maybe the last
valid one, or second last valid one?

ChenYu

> reg = <1>;
> clocks = < CLK_BUS_EPHY>;
> resets = < RST_BUS_EPHY>;
> --
> 2.13.0
>


Re: [PATCH 2/3] ARM: sunxi: h3/h5: Add sun8i-h3-ephy compatible

2017-07-28 Thread Chen-Yu Tsai
On Fri, Jul 28, 2017 at 5:28 PM, Corentin Labbe
 wrote:
> This patch adds the sun8i-h3-ephy compatible to the internal PHY.
>
> Signed-off-by: Corentin Labbe 
> ---
>  arch/arm/boot/dts/sunxi-h3-h5.dtsi | 3 ++-

To avoid repeating the past, this patch, if approved, will be merged
through the sunxi tree, not netdev nor net-next.

>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/boot/dts/sunxi-h3-h5.dtsi 
> b/arch/arm/boot/dts/sunxi-h3-h5.dtsi
> index 4b599b5d26f6..7aaa837c2388 100644
> --- a/arch/arm/boot/dts/sunxi-h3-h5.dtsi
> +++ b/arch/arm/boot/dts/sunxi-h3-h5.dtsi
> @@ -421,7 +421,8 @@
> #address-cells = <1>;
> #size-cells = <0>;
> int_mii_phy: ethernet-phy@1 {
> -   compatible = 
> "ethernet-phy-ieee802.3-c22";
> +   compatible = 
> "allwinner,sun8i-h3-ephy",
> +   
> "ethernet-phy-ieee802.3-c22";

Are you expecting people to override this properly?

As it currently is, any external phy at address 1 will simply
reuse the same device node. And if they don't override the
property correctly, the driver will end up trying to use
the internal phy, while the user is expecting the external
one to be used.

Maybe you could move this to some other address, maybe the last
valid one, or second last valid one?

ChenYu

> reg = <1>;
> clocks = < CLK_BUS_EPHY>;
> resets = < RST_BUS_EPHY>;
> --
> 2.13.0
>


[PATCH] mtd: spi-nor: add support for Microchip sst26vf064b QSPI memory

2017-07-28 Thread Claudiu Beznea
Add support for Microchip sst26vf064b QSPI memory.

Signed-off-by: Claudiu Beznea 
---
 drivers/mtd/spi-nor/spi-nor.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 196b52f..796aac4 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -1081,6 +1081,7 @@ static const struct flash_info spi_nor_ids[] = {
{ "sst25wf040b", INFO(0x621613, 0, 64 * 1024,  8, SECT_4K) },
{ "sst25wf040",  INFO(0xbf2504, 0, 64 * 1024,  8, SECT_4K | SST_WRITE) 
},
{ "sst25wf080",  INFO(0xbf2505, 0, 64 * 1024, 16, SECT_4K | SST_WRITE) 
},
+   { "sst26vf064b", INFO(0xbf2643, 0,  4 * 1024, 2048, SECT_4K | 
SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
 
/* ST Microelectronics -- newer production may have feature updates */
{ "m25p05",  INFO(0x202010,  0,  32 * 1024,   2, 0) },
-- 
2.7.4



[PATCH] mtd: spi-nor: add support for Microchip sst26vf064b QSPI memory

2017-07-28 Thread Claudiu Beznea
Add support for Microchip sst26vf064b QSPI memory.

Signed-off-by: Claudiu Beznea 
---
 drivers/mtd/spi-nor/spi-nor.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 196b52f..796aac4 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -1081,6 +1081,7 @@ static const struct flash_info spi_nor_ids[] = {
{ "sst25wf040b", INFO(0x621613, 0, 64 * 1024,  8, SECT_4K) },
{ "sst25wf040",  INFO(0xbf2504, 0, 64 * 1024,  8, SECT_4K | SST_WRITE) 
},
{ "sst25wf080",  INFO(0xbf2505, 0, 64 * 1024, 16, SECT_4K | SST_WRITE) 
},
+   { "sst26vf064b", INFO(0xbf2643, 0,  4 * 1024, 2048, SECT_4K | 
SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
 
/* ST Microelectronics -- newer production may have feature updates */
{ "m25p05",  INFO(0x202010,  0,  32 * 1024,   2, 0) },
-- 
2.7.4



Re: [kbuild-all] [rcu:rcu/next 4/4] frv-linux-ld: Warning: size of symbol `sys_membarrier' changed from 8 in kernel/sys_ni.o to 44 in kernel/sched/membarrier.o

2017-07-28 Thread Fengguang Wu

On Fri, Jul 28, 2017 at 11:19:33AM +0200, Peter Zijlstra wrote:

On Fri, Jul 28, 2017 at 12:46:40AM +, Mathieu Desnoyers wrote:


> This is a new one on me.  What do we do to fix it?


Apparently (see below) the answer is, we ignore this.


I would suspect this might be caused by moving membarrier.c from kernel/
to kernel/sched/. Perhaps Peter knows ?


 dhowells: hey, I know you don't care about FRV anymore, but suppose 
the 0-day thing says things like:
 >>frv-linux-ld: Warning: size of symbol `sys_setuid' changed from 
272 in
 >>kernel/sys.o to 8 in kernel/sys_ni.o
 dhowells: do you have any clue wth went wrong?
 peterz: it's been saying that for a long time, but I've no idea why
 didn't seem to stop it working
 I suspect it might not be handing weak symbol elimination correctly 
or something
 fair enough, I'll ignore it then


OK, I'll teach the robot to ignore all such warnings:

   frv-linux-ld: Warning: size of symbol `sys_setuid' changed from 272 in 
kernel/sys.o to 8 in kernel/sys_ni.o

I'll use blacklist pattern:

   frv-linux-ld: Warning: size of symbol .* changed from

Thanks,
Fengguang


Re: [kbuild-all] [rcu:rcu/next 4/4] frv-linux-ld: Warning: size of symbol `sys_membarrier' changed from 8 in kernel/sys_ni.o to 44 in kernel/sched/membarrier.o

2017-07-28 Thread Fengguang Wu

On Fri, Jul 28, 2017 at 11:19:33AM +0200, Peter Zijlstra wrote:

On Fri, Jul 28, 2017 at 12:46:40AM +, Mathieu Desnoyers wrote:


> This is a new one on me.  What do we do to fix it?


Apparently (see below) the answer is, we ignore this.


I would suspect this might be caused by moving membarrier.c from kernel/
to kernel/sched/. Perhaps Peter knows ?


 dhowells: hey, I know you don't care about FRV anymore, but suppose 
the 0-day thing says things like:
 >>frv-linux-ld: Warning: size of symbol `sys_setuid' changed from 
272 in
 >>kernel/sys.o to 8 in kernel/sys_ni.o
 dhowells: do you have any clue wth went wrong?
 peterz: it's been saying that for a long time, but I've no idea why
 didn't seem to stop it working
 I suspect it might not be handing weak symbol elimination correctly 
or something
 fair enough, I'll ignore it then


OK, I'll teach the robot to ignore all such warnings:

   frv-linux-ld: Warning: size of symbol `sys_setuid' changed from 272 in 
kernel/sys.o to 8 in kernel/sys_ni.o

I'll use blacklist pattern:

   frv-linux-ld: Warning: size of symbol .* changed from

Thanks,
Fengguang


Re: [RFC 01/12] clk: qcom: support for register offsets from rcg2 clock node

2017-07-28 Thread Abhishek Sahu

On 2017-07-28 00:14, Stephen Boyd wrote:

On 07/27/2017 04:10 AM, Abhishek Sahu wrote:

The current driver hardcodes the RCG2 register offsets. Some of
the RCG2’s use different offsets from the default one.

This patch adds the support to provide the register offsets array in
RCG2 clock node. If RCG2 clock node contains the register offsets
then this will be used instead of default one.



 


@@ -43,22 +41,34 @@
 #define CFG_MODE_MASK  (0x3 << CFG_MODE_SHIFT)
 #define CFG_MODE_DUAL_EDGE (0x2 << CFG_MODE_SHIFT)

-#define M_REG  0x8
-#define N_REG  0xc
-#define D_REG  0x10
+#define rcg2_cmd(rcg, offsets) (rcg->cmd_rcgr)
+#define rcg2_cfg(rcg, offsets)	(rcg->cmd_rcgr + 
offsets[CLK_RCG2_CFG])

+#define rcg2_m(rcg, offsets)   (rcg->cmd_rcgr + offsets[CLK_RCG2_M])
+#define rcg2_n(rcg, offsets)   (rcg->cmd_rcgr + offsets[CLK_RCG2_N])
+#define rcg2_d(rcg, offsets)   (rcg->cmd_rcgr + offsets[CLK_RCG2_D])
+
+#define to_rcg2_offsets(rcg)   (rcg->offsets ?  \
+rcg->offsets : rcg2_default_offsets)

 enum freq_policy {
FLOOR,
CEIL,
 };

+static const u8 rcg2_default_offsets[] = {
+   [CLK_RCG2_CFG] = 0x4,
+   [CLK_RCG2_M] = 0x8,
+   [CLK_RCG2_N] = 0xc,
+   [CLK_RCG2_D] = 0x10,
+};


It looks like the two UBI clks that messed this up don't have an MN
counter, so instead of doing this maddness, just add a flag like


 I have given example for one of the RCG. IPQ8074 have more clocks for
 which the offsets are not continuous and some of the clocks have
 mn counter also (NSS Crypto and PCIE AUX)

 GCC_NSS_UBI0_CMD_RCGR 0x1868100
 GCC_NSS_UBI0_CFG_RCGR 0x1868108
 GCC_NSS_UBI1_CMD_RCGR 0x1868120
 GCC_NSS_UBI1_CFG_RCGR 0x1868128

 GCC_NSS_CRYPTO_CMD_RCGR 0x1868140
 GCC_NSS_CRYPTO_CFG_RCGR 0x1868148
 GCC_NSS_CRYPTO_M 0x186814C
 GCC_NSS_CRYPTO_N 0x1868150
 GCC_NSS_CRYPTO_D 0x1868154

 GCC_PCIE0_AUX_CMD_RCGR 0x1875020
 GCC_PCIE0_AUX_CFG_RCGR 0x1875028
 GCC_PCIE0_AUX_M 0x187502C
 GCC_PCIE0_AUX_N 0x1875030
 GCC_PCIE0_AUX_D 0x1875034

 GCC_PCIE0_AXI_CMD_RCGR 0x1875050
 GCC_PCIE0_AXI_CFG_RCGR 0x1875058

 Similarly for PCIE1 also.


m_is_cfg and then make a rcg2_crmd() function that checks this flag and
returns cmd_rcg + CFG_REG or cmd_rgcr + M_REG depending on the flag. We


 The original idea was to make this generic so in future for all the 
cases

 it will work. If we can make function and since some clocks have MN
 counter, so could we make function for CMD reg itself instead of CFG 
reg.
 For this, pass cmd_rcgr as + 4 from GCC driver and when this flag is 
set

 then do minus 4 for all CMD_REG


can also optimize further, and ifdef this whole branch out unless the
specific IPQ GCC driver is enabled. Also only update the generic RCG
code, and not the display/gpu specific ones. Then the diff is much
smaller, and we can go yell at hardware team to never do this again.


--
Abhishek Sahu


Re: [RFC 01/12] clk: qcom: support for register offsets from rcg2 clock node

2017-07-28 Thread Abhishek Sahu

On 2017-07-28 00:14, Stephen Boyd wrote:

On 07/27/2017 04:10 AM, Abhishek Sahu wrote:

The current driver hardcodes the RCG2 register offsets. Some of
the RCG2’s use different offsets from the default one.

This patch adds the support to provide the register offsets array in
RCG2 clock node. If RCG2 clock node contains the register offsets
then this will be used instead of default one.



 


@@ -43,22 +41,34 @@
 #define CFG_MODE_MASK  (0x3 << CFG_MODE_SHIFT)
 #define CFG_MODE_DUAL_EDGE (0x2 << CFG_MODE_SHIFT)

-#define M_REG  0x8
-#define N_REG  0xc
-#define D_REG  0x10
+#define rcg2_cmd(rcg, offsets) (rcg->cmd_rcgr)
+#define rcg2_cfg(rcg, offsets)	(rcg->cmd_rcgr + 
offsets[CLK_RCG2_CFG])

+#define rcg2_m(rcg, offsets)   (rcg->cmd_rcgr + offsets[CLK_RCG2_M])
+#define rcg2_n(rcg, offsets)   (rcg->cmd_rcgr + offsets[CLK_RCG2_N])
+#define rcg2_d(rcg, offsets)   (rcg->cmd_rcgr + offsets[CLK_RCG2_D])
+
+#define to_rcg2_offsets(rcg)   (rcg->offsets ?  \
+rcg->offsets : rcg2_default_offsets)

 enum freq_policy {
FLOOR,
CEIL,
 };

+static const u8 rcg2_default_offsets[] = {
+   [CLK_RCG2_CFG] = 0x4,
+   [CLK_RCG2_M] = 0x8,
+   [CLK_RCG2_N] = 0xc,
+   [CLK_RCG2_D] = 0x10,
+};


It looks like the two UBI clks that messed this up don't have an MN
counter, so instead of doing this maddness, just add a flag like


 I have given example for one of the RCG. IPQ8074 have more clocks for
 which the offsets are not continuous and some of the clocks have
 mn counter also (NSS Crypto and PCIE AUX)

 GCC_NSS_UBI0_CMD_RCGR 0x1868100
 GCC_NSS_UBI0_CFG_RCGR 0x1868108
 GCC_NSS_UBI1_CMD_RCGR 0x1868120
 GCC_NSS_UBI1_CFG_RCGR 0x1868128

 GCC_NSS_CRYPTO_CMD_RCGR 0x1868140
 GCC_NSS_CRYPTO_CFG_RCGR 0x1868148
 GCC_NSS_CRYPTO_M 0x186814C
 GCC_NSS_CRYPTO_N 0x1868150
 GCC_NSS_CRYPTO_D 0x1868154

 GCC_PCIE0_AUX_CMD_RCGR 0x1875020
 GCC_PCIE0_AUX_CFG_RCGR 0x1875028
 GCC_PCIE0_AUX_M 0x187502C
 GCC_PCIE0_AUX_N 0x1875030
 GCC_PCIE0_AUX_D 0x1875034

 GCC_PCIE0_AXI_CMD_RCGR 0x1875050
 GCC_PCIE0_AXI_CFG_RCGR 0x1875058

 Similarly for PCIE1 also.


m_is_cfg and then make a rcg2_crmd() function that checks this flag and
returns cmd_rcg + CFG_REG or cmd_rgcr + M_REG depending on the flag. We


 The original idea was to make this generic so in future for all the 
cases

 it will work. If we can make function and since some clocks have MN
 counter, so could we make function for CMD reg itself instead of CFG 
reg.
 For this, pass cmd_rcgr as + 4 from GCC driver and when this flag is 
set

 then do minus 4 for all CMD_REG


can also optimize further, and ifdef this whole branch out unless the
specific IPQ GCC driver is enabled. Also only update the generic RCG
code, and not the display/gpu specific ones. Then the diff is much
smaller, and we can go yell at hardware team to never do this again.


--
Abhishek Sahu


Re: [PATCH v4 2/2] x86/amd: Fixup cpu_core_id for family17h downcore configuration

2017-07-28 Thread Andreas Herrmann
On Mon, Jul 24, 2017 at 04:44:45PM +0200, Borislav Petkov wrote:
> On Mon, Jul 24, 2017 at 09:14:18PM +0700, Suravee Suthikulpanit wrote:
> > Actually, this is not totally accurate. My apology. This patch is
> > mainly fix to incorrect core ID in /proc/cpuinfo.
> 
> So you're "fixing" only some numbering thing. Because core_id doesn't
> have any influence on anything. Here's on an Intel box I have here:
> 
> processor :  0 physical id : 0 core id : 0
> processor :  1 physical id : 1 core id : 0

  ---8<---

> processor : 62 physical id : 2 core id : 11
> processor : 63 physical id : 3 core id : 11
> 
> So those core id numbers can be anything as long as the cpumasks used by
> the scheduler are correct.

And as long as the user is able to find consistent topology
information.  (Ie. via /proc/cpuinfo and/or
/sys/bus/cpu/devices/cpuX/topology/)

> > This is due to the cpu_core_id fixup in amd_get_topology() below:
> > 
> > /* fixup multi-node processor information */
> > if (nodes_per_socket > 1) {
> > u32 cus_per_node;
> > 
> > set_cpu_cap(c, X86_FEATURE_AMD_DCM);
> > cus_per_node = c->x86_max_cores / nodes_per_socket;
> > 
> > /* core id has to be in the [0 .. cores_per_node - 1] range 
> > */
> > c->cpu_core_id %= cus_per_node;
> > }
> 
> AFAICT, Andreas did this for MC at the time:
> 
> 4a376ec3a259 ("x86: Fix CPU llc_shared_map information for AMD Magny-Cours")
> 
> but I don't think we need to care about core_ids fitting into the node
> range anymore. For the above reason - topology doesn't use core ids.

IIRC this was the way to fix llc_shared_map as CPUID functions could
not be used to figure which cores belong to the same compute unit.

> So you can just as well let ->cpu_core_id be derived from the
> ->initial_apicid as it is being done now in amd_detect_cmp().
> 
> In order not to cause any more confusion, you can limit the above fixup
> to anything below F17h so that we don't upset existing users and add a
> big fat comment as to why we're doing this. But if it is only a silly
> numbering thing, I don't see the need for doing that jumping through
> hoops.
> 
> -- 
> Regards/Gruss,
> Boris.

Regards,

Andreas


Re: [PATCH v4 2/2] x86/amd: Fixup cpu_core_id for family17h downcore configuration

2017-07-28 Thread Andreas Herrmann
On Mon, Jul 24, 2017 at 04:44:45PM +0200, Borislav Petkov wrote:
> On Mon, Jul 24, 2017 at 09:14:18PM +0700, Suravee Suthikulpanit wrote:
> > Actually, this is not totally accurate. My apology. This patch is
> > mainly fix to incorrect core ID in /proc/cpuinfo.
> 
> So you're "fixing" only some numbering thing. Because core_id doesn't
> have any influence on anything. Here's on an Intel box I have here:
> 
> processor :  0 physical id : 0 core id : 0
> processor :  1 physical id : 1 core id : 0

  ---8<---

> processor : 62 physical id : 2 core id : 11
> processor : 63 physical id : 3 core id : 11
> 
> So those core id numbers can be anything as long as the cpumasks used by
> the scheduler are correct.

And as long as the user is able to find consistent topology
information.  (Ie. via /proc/cpuinfo and/or
/sys/bus/cpu/devices/cpuX/topology/)

> > This is due to the cpu_core_id fixup in amd_get_topology() below:
> > 
> > /* fixup multi-node processor information */
> > if (nodes_per_socket > 1) {
> > u32 cus_per_node;
> > 
> > set_cpu_cap(c, X86_FEATURE_AMD_DCM);
> > cus_per_node = c->x86_max_cores / nodes_per_socket;
> > 
> > /* core id has to be in the [0 .. cores_per_node - 1] range 
> > */
> > c->cpu_core_id %= cus_per_node;
> > }
> 
> AFAICT, Andreas did this for MC at the time:
> 
> 4a376ec3a259 ("x86: Fix CPU llc_shared_map information for AMD Magny-Cours")
> 
> but I don't think we need to care about core_ids fitting into the node
> range anymore. For the above reason - topology doesn't use core ids.

IIRC this was the way to fix llc_shared_map as CPUID functions could
not be used to figure which cores belong to the same compute unit.

> So you can just as well let ->cpu_core_id be derived from the
> ->initial_apicid as it is being done now in amd_detect_cmp().
> 
> In order not to cause any more confusion, you can limit the above fixup
> to anything below F17h so that we don't upset existing users and add a
> big fat comment as to why we're doing this. But if it is only a silly
> numbering thing, I don't see the need for doing that jumping through
> hoops.
> 
> -- 
> Regards/Gruss,
> Boris.

Regards,

Andreas


Re: [PATCH 4/4] xen: Drop un-informative message during boot

2017-07-28 Thread Juergen Gross
On 20/07/17 13:04, Punit Agrawal wrote:
> On systems that are not booted as a Xen domain, the xenfs driver prints
> the following message during boot.
> 
> [3.460595] xenfs: not registering filesystem on non-xen platform
> 
> As the user chose not to boot a Xen domain, this message does not
> provide useful information. Drop this message.
> 
> Signed-off-by: Punit Agrawal 
> Cc: Boris Ostrovsky 
> Cc: Juergen Gross 

Committed to: xen/tip.git for-linus-4.13b


Thanks,

Juergen



Re: [PATCH 4/4] xen: Drop un-informative message during boot

2017-07-28 Thread Juergen Gross
On 20/07/17 13:04, Punit Agrawal wrote:
> On systems that are not booted as a Xen domain, the xenfs driver prints
> the following message during boot.
> 
> [3.460595] xenfs: not registering filesystem on non-xen platform
> 
> As the user chose not to boot a Xen domain, this message does not
> provide useful information. Drop this message.
> 
> Signed-off-by: Punit Agrawal 
> Cc: Boris Ostrovsky 
> Cc: Juergen Gross 

Committed to: xen/tip.git for-linus-4.13b


Thanks,

Juergen



Re: [PATCH] xen: selfballoon: remove unnecessary static in frontswap_selfshrink()

2017-07-28 Thread Juergen Gross
On 04/07/17 20:34, Gustavo A. R. Silva wrote:
> Remove unnecessary static on local variables last_frontswap_pages and
> tgt_frontswap_pages. Such variables are initialized before being used,
> on every execution path throughout the function. The statics have no
> benefit and, removing them reduce the code size.
> 
> This issue was detected using Coccinelle and the following semantic patch:
> 
> @bad exists@
> position p;
> identifier x;
> type T;
> @@
> 
> static T x@p;
> ...
> x = <+...x...+>
> 
> @@
> identifier x;
> expression e;
> type T;
> position p != bad.p;
> @@
> 
> -static
>  T x@p;
>  ... when != x
>  when strict
> ?x = e;
> 
> You can see a significant difference in the code size after executing
> the size command, before and after the code change:
> 
> before:
>text  data bss dec hex filename
>5633  3452 384946924fd drivers/xen/xen-selfballoon.o
> 
> after:
>text  data bss dec hex filename
>5576  3308 256914023b4 drivers/xen/xen-selfballoon.o
> 
> Signed-off-by: Gustavo A. R. Silva 

Committed to xen/tip.git for-linus-4.13b


Thanks,

Juergen



Re: [PATCH] xen: selfballoon: remove unnecessary static in frontswap_selfshrink()

2017-07-28 Thread Juergen Gross
On 04/07/17 20:34, Gustavo A. R. Silva wrote:
> Remove unnecessary static on local variables last_frontswap_pages and
> tgt_frontswap_pages. Such variables are initialized before being used,
> on every execution path throughout the function. The statics have no
> benefit and, removing them reduce the code size.
> 
> This issue was detected using Coccinelle and the following semantic patch:
> 
> @bad exists@
> position p;
> identifier x;
> type T;
> @@
> 
> static T x@p;
> ...
> x = <+...x...+>
> 
> @@
> identifier x;
> expression e;
> type T;
> position p != bad.p;
> @@
> 
> -static
>  T x@p;
>  ... when != x
>  when strict
> ?x = e;
> 
> You can see a significant difference in the code size after executing
> the size command, before and after the code change:
> 
> before:
>text  data bss dec hex filename
>5633  3452 384946924fd drivers/xen/xen-selfballoon.o
> 
> after:
>text  data bss dec hex filename
>5576  3308 256914023b4 drivers/xen/xen-selfballoon.o
> 
> Signed-off-by: Gustavo A. R. Silva 

Committed to xen/tip.git for-linus-4.13b


Thanks,

Juergen



[PATCH 0/3] net-next: stmmac: support future possible different internal phy mode

2017-07-28 Thread Corentin Labbe
Hello

The current way to find if the phy is internal is to compare DT phy-mode
and emac_variant/internal_phy.
But it will negate a possible future SoC where an external PHY use the
same phy mode than the internal one.

This patchs series adds a new way to find if the PHY is internal, via its
compatible.

Corentin Labbe (3):
  dt-bindings: net: add compatible for internal sun8i-h3/sun8i-v3s PHYs
  ARM: sunxi: h3/h5: Add sun8i-h3-ephy compatible
  net-next: stmmac: dwmac-sun8i: choose internal PHY via compatible

 Documentation/devicetree/bindings/net/dwmac-sun8i.txt |  4 ++--
 arch/arm/boot/dts/sunxi-h3-h5.dtsi|  3 ++-
 drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 16 ++--
 3 files changed, 14 insertions(+), 9 deletions(-)

-- 
2.13.0



[PATCH 0/3] net-next: stmmac: support future possible different internal phy mode

2017-07-28 Thread Corentin Labbe
Hello

The current way to find if the phy is internal is to compare DT phy-mode
and emac_variant/internal_phy.
But it will negate a possible future SoC where an external PHY use the
same phy mode than the internal one.

This patchs series adds a new way to find if the PHY is internal, via its
compatible.

Corentin Labbe (3):
  dt-bindings: net: add compatible for internal sun8i-h3/sun8i-v3s PHYs
  ARM: sunxi: h3/h5: Add sun8i-h3-ephy compatible
  net-next: stmmac: dwmac-sun8i: choose internal PHY via compatible

 Documentation/devicetree/bindings/net/dwmac-sun8i.txt |  4 ++--
 arch/arm/boot/dts/sunxi-h3-h5.dtsi|  3 ++-
 drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 16 ++--
 3 files changed, 14 insertions(+), 9 deletions(-)

-- 
2.13.0



[PATCH 2/3] ARM: sunxi: h3/h5: Add sun8i-h3-ephy compatible

2017-07-28 Thread Corentin Labbe
This patch adds the sun8i-h3-ephy compatible to the internal PHY.

Signed-off-by: Corentin Labbe 
---
 arch/arm/boot/dts/sunxi-h3-h5.dtsi | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/sunxi-h3-h5.dtsi 
b/arch/arm/boot/dts/sunxi-h3-h5.dtsi
index 4b599b5d26f6..7aaa837c2388 100644
--- a/arch/arm/boot/dts/sunxi-h3-h5.dtsi
+++ b/arch/arm/boot/dts/sunxi-h3-h5.dtsi
@@ -421,7 +421,8 @@
#address-cells = <1>;
#size-cells = <0>;
int_mii_phy: ethernet-phy@1 {
-   compatible = 
"ethernet-phy-ieee802.3-c22";
+   compatible = "allwinner,sun8i-h3-ephy",
+   
"ethernet-phy-ieee802.3-c22";
reg = <1>;
clocks = < CLK_BUS_EPHY>;
resets = < RST_BUS_EPHY>;
-- 
2.13.0



[PATCH 1/3] dt-bindings: net: add compatible for internal sun8i-h3/sun8i-v3s PHYs

2017-07-28 Thread Corentin Labbe
The internal PHYs for H3 ans V3S now need to have their own compatible.
This patch rename them in the binding documentation.

Signed-off-by: Corentin Labbe 
---
 Documentation/devicetree/bindings/net/dwmac-sun8i.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/dwmac-sun8i.txt 
b/Documentation/devicetree/bindings/net/dwmac-sun8i.txt
index 725f3b187886..851e89052424 100644
--- a/Documentation/devicetree/bindings/net/dwmac-sun8i.txt
+++ b/Documentation/devicetree/bindings/net/dwmac-sun8i.txt
@@ -49,8 +49,8 @@ The device node referenced by "phy" or "phy-handle" should be 
a child node
 of the mdio node. See phy.txt for the generic PHY bindings.
 
 Required properties of the phy node with the following compatibles:
-  - "allwinner,sun8i-h3-emac",
-  - "allwinner,sun8i-v3s-emac":
+  - "allwinner,sun8i-h3-ephy",
+  - "allwinner,sun8i-v3s-ephy":
 - clocks: a phandle to the reference clock for the EPHY
 - resets: a phandle to the reset control for the EPHY
 
-- 
2.13.0



[PATCH 2/3] ARM: sunxi: h3/h5: Add sun8i-h3-ephy compatible

2017-07-28 Thread Corentin Labbe
This patch adds the sun8i-h3-ephy compatible to the internal PHY.

Signed-off-by: Corentin Labbe 
---
 arch/arm/boot/dts/sunxi-h3-h5.dtsi | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/sunxi-h3-h5.dtsi 
b/arch/arm/boot/dts/sunxi-h3-h5.dtsi
index 4b599b5d26f6..7aaa837c2388 100644
--- a/arch/arm/boot/dts/sunxi-h3-h5.dtsi
+++ b/arch/arm/boot/dts/sunxi-h3-h5.dtsi
@@ -421,7 +421,8 @@
#address-cells = <1>;
#size-cells = <0>;
int_mii_phy: ethernet-phy@1 {
-   compatible = 
"ethernet-phy-ieee802.3-c22";
+   compatible = "allwinner,sun8i-h3-ephy",
+   
"ethernet-phy-ieee802.3-c22";
reg = <1>;
clocks = < CLK_BUS_EPHY>;
resets = < RST_BUS_EPHY>;
-- 
2.13.0



[PATCH 1/3] dt-bindings: net: add compatible for internal sun8i-h3/sun8i-v3s PHYs

2017-07-28 Thread Corentin Labbe
The internal PHYs for H3 ans V3S now need to have their own compatible.
This patch rename them in the binding documentation.

Signed-off-by: Corentin Labbe 
---
 Documentation/devicetree/bindings/net/dwmac-sun8i.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/dwmac-sun8i.txt 
b/Documentation/devicetree/bindings/net/dwmac-sun8i.txt
index 725f3b187886..851e89052424 100644
--- a/Documentation/devicetree/bindings/net/dwmac-sun8i.txt
+++ b/Documentation/devicetree/bindings/net/dwmac-sun8i.txt
@@ -49,8 +49,8 @@ The device node referenced by "phy" or "phy-handle" should be 
a child node
 of the mdio node. See phy.txt for the generic PHY bindings.
 
 Required properties of the phy node with the following compatibles:
-  - "allwinner,sun8i-h3-emac",
-  - "allwinner,sun8i-v3s-emac":
+  - "allwinner,sun8i-h3-ephy",
+  - "allwinner,sun8i-v3s-ephy":
 - clocks: a phandle to the reference clock for the EPHY
 - resets: a phandle to the reset control for the EPHY
 
-- 
2.13.0



[PATCH 3/3] net-next: stmmac: dwmac-sun8i: choose internal PHY via compatible

2017-07-28 Thread Corentin Labbe
The current way to find if the phy is internal is to compare DT phy-mode
and emac_variant/internal_phy.
But it will negate a possible future SoC where an external PHY use the
same phy mode than the internal one.

This patch adds a new way to find if the PHY is internal, via its
compatible.

Since the phy_mode of the internal PHY does need to be know, the
variant internal_phy member is converted to a boolean.

Signed-off-by: Corentin Labbe 
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c 
b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index fffd6d5fc907..04f7ddd802b0 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -48,7 +48,7 @@
  */
 struct emac_variant {
u32 default_syscon_value;
-   int internal_phy;
+   bool internal_phy;
bool support_mii;
bool support_rmii;
bool support_rgmii;
@@ -75,7 +75,7 @@ struct sunxi_priv_data {
 
 static const struct emac_variant emac_variant_h3 = {
.default_syscon_value = 0x58000,
-   .internal_phy = PHY_INTERFACE_MODE_MII,
+   .internal_phy = true,
.support_mii = true,
.support_rmii = true,
.support_rgmii = true
@@ -83,20 +83,20 @@ static const struct emac_variant emac_variant_h3 = {
 
 static const struct emac_variant emac_variant_v3s = {
.default_syscon_value = 0x38000,
-   .internal_phy = PHY_INTERFACE_MODE_MII,
+   .internal_phy = true,
.support_mii = true
 };
 
 static const struct emac_variant emac_variant_a83t = {
.default_syscon_value = 0,
-   .internal_phy = 0,
+   .internal_phy = false,
.support_mii = true,
.support_rgmii = true
 };
 
 static const struct emac_variant emac_variant_a64 = {
.default_syscon_value = 0,
-   .internal_phy = 0,
+   .internal_phy = false,
.support_mii = true,
.support_rmii = true,
.support_rgmii = true
@@ -889,6 +889,10 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
struct sunxi_priv_data *gmac;
struct device *dev = >dev;
int ret;
+   static const struct of_device_id internal_phys[] = {
+   { .compatible = "allwinner,sun8i-h3-ephy" },
+   { .compatible = "allwinner,sun8i-v3s-ephy" },
+   };
 
ret = stmmac_get_platform_resources(pdev, _res);
if (ret)
@@ -932,7 +936,7 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
}
 
plat_dat->interface = of_get_phy_mode(dev->of_node);
-   if (plat_dat->interface == gmac->variant->internal_phy) {
+   if (of_match_node(internal_phys, plat_dat->phy_node)) {
dev_info(>dev, "Will use internal PHY\n");
gmac->use_internal_phy = true;
gmac->ephy_clk = of_clk_get(plat_dat->phy_node, 0);
-- 
2.13.0



[PATCH 3/3] net-next: stmmac: dwmac-sun8i: choose internal PHY via compatible

2017-07-28 Thread Corentin Labbe
The current way to find if the phy is internal is to compare DT phy-mode
and emac_variant/internal_phy.
But it will negate a possible future SoC where an external PHY use the
same phy mode than the internal one.

This patch adds a new way to find if the PHY is internal, via its
compatible.

Since the phy_mode of the internal PHY does need to be know, the
variant internal_phy member is converted to a boolean.

Signed-off-by: Corentin Labbe 
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c 
b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index fffd6d5fc907..04f7ddd802b0 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -48,7 +48,7 @@
  */
 struct emac_variant {
u32 default_syscon_value;
-   int internal_phy;
+   bool internal_phy;
bool support_mii;
bool support_rmii;
bool support_rgmii;
@@ -75,7 +75,7 @@ struct sunxi_priv_data {
 
 static const struct emac_variant emac_variant_h3 = {
.default_syscon_value = 0x58000,
-   .internal_phy = PHY_INTERFACE_MODE_MII,
+   .internal_phy = true,
.support_mii = true,
.support_rmii = true,
.support_rgmii = true
@@ -83,20 +83,20 @@ static const struct emac_variant emac_variant_h3 = {
 
 static const struct emac_variant emac_variant_v3s = {
.default_syscon_value = 0x38000,
-   .internal_phy = PHY_INTERFACE_MODE_MII,
+   .internal_phy = true,
.support_mii = true
 };
 
 static const struct emac_variant emac_variant_a83t = {
.default_syscon_value = 0,
-   .internal_phy = 0,
+   .internal_phy = false,
.support_mii = true,
.support_rgmii = true
 };
 
 static const struct emac_variant emac_variant_a64 = {
.default_syscon_value = 0,
-   .internal_phy = 0,
+   .internal_phy = false,
.support_mii = true,
.support_rmii = true,
.support_rgmii = true
@@ -889,6 +889,10 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
struct sunxi_priv_data *gmac;
struct device *dev = >dev;
int ret;
+   static const struct of_device_id internal_phys[] = {
+   { .compatible = "allwinner,sun8i-h3-ephy" },
+   { .compatible = "allwinner,sun8i-v3s-ephy" },
+   };
 
ret = stmmac_get_platform_resources(pdev, _res);
if (ret)
@@ -932,7 +936,7 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
}
 
plat_dat->interface = of_get_phy_mode(dev->of_node);
-   if (plat_dat->interface == gmac->variant->internal_phy) {
+   if (of_match_node(internal_phys, plat_dat->phy_node)) {
dev_info(>dev, "Will use internal PHY\n");
gmac->use_internal_phy = true;
gmac->ephy_clk = of_clk_get(plat_dat->phy_node, 0);
-- 
2.13.0



Re: [PATCH v2] cpuset: fix a deadlock due to incomplete patching of cpusets_enabled()

2017-07-28 Thread Peter Zijlstra
On Fri, Jul 28, 2017 at 09:45:16AM +0200, Vlastimil Babka wrote:
> [+CC PeterZ]
> 
> On 07/27/2017 06:46 PM, Dima Zavin wrote:
> > In codepaths that use the begin/retry interface for reading
> > mems_allowed_seq with irqs disabled, there exists a race condition that
> > stalls the patch process after only modifying a subset of the
> > static_branch call sites.
> > 
> > This problem manifested itself as a dead lock in the slub
> > allocator, inside get_any_partial. The loop reads
> > mems_allowed_seq value (via read_mems_allowed_begin),
> > performs the defrag operation, and then verifies the consistency
> > of mem_allowed via the read_mems_allowed_retry and the cookie
> > returned by xxx_begin. The issue here is that both begin and retry
> > first check if cpusets are enabled via cpusets_enabled() static branch.
> > This branch can be rewritted dynamically (via cpuset_inc) if a new
> > cpuset is created. The x86 jump label code fully synchronizes across
> > all CPUs for every entry it rewrites. If it rewrites only one of the
> > callsites (specifically the one in read_mems_allowed_retry) and then
> > waits for the smp_call_function(do_sync_core) to complete while a CPU is
> > inside the begin/retry section with IRQs off and the mems_allowed value
> > is changed, we can hang. This is because begin() will always return 0
> > (since it wasn't patched yet) while retry() will test the 0 against
> > the actual value of the seq counter.
> 
> Hm I wonder if there are other static branch users potentially having
> similar problem. Then it would be best to fix this at static branch
> level. Any idea, Peter? An inelegant solution would be to have indicate
> static_branch_(un)likely() callsites ordering for the patching. I.e.
> here we would make sure that read_mems_allowed_begin() callsites are
> patched before read_mems_allowed_retry() when enabling the static key,
> and the opposite order when disabling the static key.

I'm not aware of any other sure ordering requirements. But you can
manually create this order by using 2 static keys. Then flip them in the
desired order.


Re: [PATCH v2] cpuset: fix a deadlock due to incomplete patching of cpusets_enabled()

2017-07-28 Thread Peter Zijlstra
On Fri, Jul 28, 2017 at 09:45:16AM +0200, Vlastimil Babka wrote:
> [+CC PeterZ]
> 
> On 07/27/2017 06:46 PM, Dima Zavin wrote:
> > In codepaths that use the begin/retry interface for reading
> > mems_allowed_seq with irqs disabled, there exists a race condition that
> > stalls the patch process after only modifying a subset of the
> > static_branch call sites.
> > 
> > This problem manifested itself as a dead lock in the slub
> > allocator, inside get_any_partial. The loop reads
> > mems_allowed_seq value (via read_mems_allowed_begin),
> > performs the defrag operation, and then verifies the consistency
> > of mem_allowed via the read_mems_allowed_retry and the cookie
> > returned by xxx_begin. The issue here is that both begin and retry
> > first check if cpusets are enabled via cpusets_enabled() static branch.
> > This branch can be rewritted dynamically (via cpuset_inc) if a new
> > cpuset is created. The x86 jump label code fully synchronizes across
> > all CPUs for every entry it rewrites. If it rewrites only one of the
> > callsites (specifically the one in read_mems_allowed_retry) and then
> > waits for the smp_call_function(do_sync_core) to complete while a CPU is
> > inside the begin/retry section with IRQs off and the mems_allowed value
> > is changed, we can hang. This is because begin() will always return 0
> > (since it wasn't patched yet) while retry() will test the 0 against
> > the actual value of the seq counter.
> 
> Hm I wonder if there are other static branch users potentially having
> similar problem. Then it would be best to fix this at static branch
> level. Any idea, Peter? An inelegant solution would be to have indicate
> static_branch_(un)likely() callsites ordering for the patching. I.e.
> here we would make sure that read_mems_allowed_begin() callsites are
> patched before read_mems_allowed_retry() when enabling the static key,
> and the opposite order when disabling the static key.

I'm not aware of any other sure ordering requirements. But you can
manually create this order by using 2 static keys. Then flip them in the
desired order.


Re: [Question]: try to fix contention between expire_timers and try_to_del_timer_sync

2017-07-28 Thread Will Deacon
On Thu, Jul 27, 2017 at 06:10:34PM -0700, Vikram Mulukutla wrote:
> On 2017-07-26 18:29, qiaozhou wrote:
> >On 2017年07月26日 22:16, Thomas Gleixner wrote:
> >>On Wed, 26 Jul 2017, qiaozhou wrote:
> >>For that particular timer case we can clear base->running_timer w/o the
> >>lock held (see patch below), but this kind of
> >>
> >>  lock -> test -> unlock -> retry
> >>
> >>loops are all over the place in the kernel, so this is going to hurt you
> >>sooner than later in some other place.
> >It's true. This is the way spinlock is used normally and widely in
> >kernel. I'll also ask ARM experts whether we can do something to avoid
> >or reduce the chance of such issue. ARMv8.1 has one single
> >instruction(ldadda) to replace the ldaxr/stxr loop. Hope it can
> >improve and reduce the chance.
> 
> I think we should have this discussion now - I brought this up earlier [1]
> and I promised a test case that I completely forgot about - but here it
> is (attached). Essentially a Big CPU in an acquire-check-release loop
> will have an unfair advantage over a little CPU concurrently attempting
> to acquire the same lock, in spite of the ticket implementation. If the Big
> CPU needs the little CPU to make forward progress : livelock.
> 
> We've run into the same loop construct in other spots in the kernel and
> the reason that a real  symptom is so rare is that the retry-loop on the
> 'Big'
> CPU needs to be interrupted just once by say an IRQ/FIQ and the live-lock
> is broken. If the entire retry loop is within an interrupt-disabled critical
> section then the odds of live-locking are much higher.
> 
> An example of the problem on a previous kernel is here [2]. Changes to the
> workqueue code since may have fixed this particular instance.
> 
> One solution was to use udelay(1) in such loops instead of cpu_relax(), but
> that's not very 'relaxing'. I'm not sure if there's something we could do
> within the ticket spin-lock implementation to deal with this.

Does bodging cpu_relax to back-off to wfe after a while help? The event
stream will wake it up if nothing else does. Nasty patch below, but I'd be
interested to know whether or not it helps.

Will

--->8

diff --git a/arch/arm64/include/asm/processor.h 
b/arch/arm64/include/asm/processor.h
index 64c9e78f9882..1f5a29c8612e 100644
--- a/arch/arm64/include/asm/processor.h
+++ b/arch/arm64/include/asm/processor.h
@@ -149,9 +149,11 @@ extern void release_thread(struct task_struct *);
 
 unsigned long get_wchan(struct task_struct *p);
 
+void __cpu_relax(unsigned long pc);
+
 static inline void cpu_relax(void)
 {
-   asm volatile("yield" ::: "memory");
+   __cpu_relax(_THIS_IP_);
 }
 
 /* Thread switching */
diff --git a/arch/arm64/kernel/arm64ksyms.c b/arch/arm64/kernel/arm64ksyms.c
index 67368c7329c0..be8a698ea680 100644
--- a/arch/arm64/kernel/arm64ksyms.c
+++ b/arch/arm64/kernel/arm64ksyms.c
@@ -72,6 +72,8 @@ EXPORT_SYMBOL(_mcount);
 NOKPROBE_SYMBOL(_mcount);
 #endif
 
+EXPORT_SYMBOL(__cpu_relax);
+
/* arm-smccc */
 EXPORT_SYMBOL(__arm_smccc_smc);
 EXPORT_SYMBOL(__arm_smccc_hvc);
diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index 659ae8094ed5..c394c3704b7f 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -403,6 +403,31 @@ unsigned long get_wchan(struct task_struct *p)
return ret;
 }
 
+static DEFINE_PER_CPU(u64, __cpu_relax_data);
+
+#define CPU_RELAX_WFE_THRESHOLD1
+void __cpu_relax(unsigned long pc)
+{
+   u64 new, old = raw_cpu_read(__cpu_relax_data);
+   u32 old_pc, new_pc;
+   bool wfe = false;
+
+   old_pc = (u32)old;
+   new = new_pc = (u32)pc;
+
+   if (old_pc == new_pc) {
+   if ((old >> 32) > CPU_RELAX_WFE_THRESHOLD) {
+   asm volatile("sevl; wfe; wfe\n" ::: "memory");
+   wfe = true;
+   } else {
+   new = old + (1UL << 32);
+   }
+   }
+
+   if (this_cpu_cmpxchg(__cpu_relax_data, old, new) == old && !wfe)
+   asm volatile("yield" ::: "memory");
+}
+
 unsigned long arch_align_stack(unsigned long sp)
 {
if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)


Re: [Question]: try to fix contention between expire_timers and try_to_del_timer_sync

2017-07-28 Thread Peter Zijlstra
On Thu, Jul 27, 2017 at 06:10:34PM -0700, Vikram Mulukutla wrote:

> I think we should have this discussion now - I brought this up earlier [1]
> and I promised a test case that I completely forgot about - but here it
> is (attached). Essentially a Big CPU in an acquire-check-release loop
> will have an unfair advantage over a little CPU concurrently attempting
> to acquire the same lock, in spite of the ticket implementation. If the Big
> CPU needs the little CPU to make forward progress : livelock.

This needs to be fixed in hardware. There really isn't anything the
software can sanely do about it.

It also doesn't have anything to do with the spinlock implementation.
Ticket or not, its a fundamental problem of LL/SC. Any situation where
we use atomics for fwd progress guarantees this can happen.

The little core (or really any core) should hold on to the locked
cacheline for a while and not insta relinquish it. Giving it a chance to
reach the SC.


Re: [Question]: try to fix contention between expire_timers and try_to_del_timer_sync

2017-07-28 Thread Will Deacon
On Thu, Jul 27, 2017 at 06:10:34PM -0700, Vikram Mulukutla wrote:
> On 2017-07-26 18:29, qiaozhou wrote:
> >On 2017年07月26日 22:16, Thomas Gleixner wrote:
> >>On Wed, 26 Jul 2017, qiaozhou wrote:
> >>For that particular timer case we can clear base->running_timer w/o the
> >>lock held (see patch below), but this kind of
> >>
> >>  lock -> test -> unlock -> retry
> >>
> >>loops are all over the place in the kernel, so this is going to hurt you
> >>sooner than later in some other place.
> >It's true. This is the way spinlock is used normally and widely in
> >kernel. I'll also ask ARM experts whether we can do something to avoid
> >or reduce the chance of such issue. ARMv8.1 has one single
> >instruction(ldadda) to replace the ldaxr/stxr loop. Hope it can
> >improve and reduce the chance.
> 
> I think we should have this discussion now - I brought this up earlier [1]
> and I promised a test case that I completely forgot about - but here it
> is (attached). Essentially a Big CPU in an acquire-check-release loop
> will have an unfair advantage over a little CPU concurrently attempting
> to acquire the same lock, in spite of the ticket implementation. If the Big
> CPU needs the little CPU to make forward progress : livelock.
> 
> We've run into the same loop construct in other spots in the kernel and
> the reason that a real  symptom is so rare is that the retry-loop on the
> 'Big'
> CPU needs to be interrupted just once by say an IRQ/FIQ and the live-lock
> is broken. If the entire retry loop is within an interrupt-disabled critical
> section then the odds of live-locking are much higher.
> 
> An example of the problem on a previous kernel is here [2]. Changes to the
> workqueue code since may have fixed this particular instance.
> 
> One solution was to use udelay(1) in such loops instead of cpu_relax(), but
> that's not very 'relaxing'. I'm not sure if there's something we could do
> within the ticket spin-lock implementation to deal with this.

Does bodging cpu_relax to back-off to wfe after a while help? The event
stream will wake it up if nothing else does. Nasty patch below, but I'd be
interested to know whether or not it helps.

Will

--->8

diff --git a/arch/arm64/include/asm/processor.h 
b/arch/arm64/include/asm/processor.h
index 64c9e78f9882..1f5a29c8612e 100644
--- a/arch/arm64/include/asm/processor.h
+++ b/arch/arm64/include/asm/processor.h
@@ -149,9 +149,11 @@ extern void release_thread(struct task_struct *);
 
 unsigned long get_wchan(struct task_struct *p);
 
+void __cpu_relax(unsigned long pc);
+
 static inline void cpu_relax(void)
 {
-   asm volatile("yield" ::: "memory");
+   __cpu_relax(_THIS_IP_);
 }
 
 /* Thread switching */
diff --git a/arch/arm64/kernel/arm64ksyms.c b/arch/arm64/kernel/arm64ksyms.c
index 67368c7329c0..be8a698ea680 100644
--- a/arch/arm64/kernel/arm64ksyms.c
+++ b/arch/arm64/kernel/arm64ksyms.c
@@ -72,6 +72,8 @@ EXPORT_SYMBOL(_mcount);
 NOKPROBE_SYMBOL(_mcount);
 #endif
 
+EXPORT_SYMBOL(__cpu_relax);
+
/* arm-smccc */
 EXPORT_SYMBOL(__arm_smccc_smc);
 EXPORT_SYMBOL(__arm_smccc_hvc);
diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index 659ae8094ed5..c394c3704b7f 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -403,6 +403,31 @@ unsigned long get_wchan(struct task_struct *p)
return ret;
 }
 
+static DEFINE_PER_CPU(u64, __cpu_relax_data);
+
+#define CPU_RELAX_WFE_THRESHOLD1
+void __cpu_relax(unsigned long pc)
+{
+   u64 new, old = raw_cpu_read(__cpu_relax_data);
+   u32 old_pc, new_pc;
+   bool wfe = false;
+
+   old_pc = (u32)old;
+   new = new_pc = (u32)pc;
+
+   if (old_pc == new_pc) {
+   if ((old >> 32) > CPU_RELAX_WFE_THRESHOLD) {
+   asm volatile("sevl; wfe; wfe\n" ::: "memory");
+   wfe = true;
+   } else {
+   new = old + (1UL << 32);
+   }
+   }
+
+   if (this_cpu_cmpxchg(__cpu_relax_data, old, new) == old && !wfe)
+   asm volatile("yield" ::: "memory");
+}
+
 unsigned long arch_align_stack(unsigned long sp)
 {
if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)


Re: [Question]: try to fix contention between expire_timers and try_to_del_timer_sync

2017-07-28 Thread Peter Zijlstra
On Thu, Jul 27, 2017 at 06:10:34PM -0700, Vikram Mulukutla wrote:

> I think we should have this discussion now - I brought this up earlier [1]
> and I promised a test case that I completely forgot about - but here it
> is (attached). Essentially a Big CPU in an acquire-check-release loop
> will have an unfair advantage over a little CPU concurrently attempting
> to acquire the same lock, in spite of the ticket implementation. If the Big
> CPU needs the little CPU to make forward progress : livelock.

This needs to be fixed in hardware. There really isn't anything the
software can sanely do about it.

It also doesn't have anything to do with the spinlock implementation.
Ticket or not, its a fundamental problem of LL/SC. Any situation where
we use atomics for fwd progress guarantees this can happen.

The little core (or really any core) should hold on to the locked
cacheline for a while and not insta relinquish it. Giving it a chance to
reach the SC.


RE: [PATCH] drm: adding SDI to drm_connector_enum_list

2017-07-28 Thread Saurabh Singh
Hi Daniel,

Thanks for your reply.
Currently I am using connector type 'Unknown' , and functionally it serves my 
need.
Intention for sending this patch is that userspace tools should recognize SDI 
drivers as SDI only.
Also, I see there are number of 'SDI' drivers getting developed 'under the 
hood' in linux kernel.
This patch will benefit all of them.

It will be great if you could consider it.

Regards,
Saurabh

-Original Message-
From: Daniel Vetter [mailto:daniel.vet...@ffwll.ch] On Behalf Of Daniel Vetter
Sent: Wednesday, July 26, 2017 8:08 PM
To: Saurabh Singh 
Cc: linux-kernel@vger.kernel.org; dri-de...@lists.freedesktop.org; 
airl...@linux.ie; Saurabh Singh ; Dinesh Kumar 

Subject: Re: [PATCH] drm: adding SDI to drm_connector_enum_list

On Wed, Jul 26, 2017 at 10:22:49AM +0530, Saurabh Sengar wrote:
> adding SDI to drm connector list
>
> Signed-off-by: Saurabh Sengar 

This is an uapi change, i.e. userspace needs to be updated. Do you _really_ 
need this? I'd recommend to just use something existing (go with VIRTUAL maybe, 
not sure).

Either way, needs to come together with the actual users and userspace side 
patches. If you really want this.
-Daniel
> ---
>  drivers/gpu/drm/drm_connector.c | 1 +
>  include/uapi/drm/drm_mode.h | 1 +
>  2 files changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_connector.c
> b/drivers/gpu/drm/drm_connector.c index 2db7fb5..ea48ddb 100644
> --- a/drivers/gpu/drm/drm_connector.c
> +++ b/drivers/gpu/drm/drm_connector.c
> @@ -86,6 +86,7 @@ static struct drm_conn_prop_enum_list 
> drm_connector_enum_list[] = {
>   { DRM_MODE_CONNECTOR_VIRTUAL, "Virtual" },
>   { DRM_MODE_CONNECTOR_DSI, "DSI" },
>   { DRM_MODE_CONNECTOR_DPI, "DPI" },
> + { DRM_MODE_CONNECTOR_SDI, "SDI" },
>  };
>
>  void drm_connector_ida_init(void)
> diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> index df0e350..9b8d204 100644
> --- a/include/uapi/drm/drm_mode.h
> +++ b/include/uapi/drm/drm_mode.h
> @@ -247,6 +247,7 @@ struct drm_mode_get_encoder {
>  #define DRM_MODE_CONNECTOR_VIRTUAL  15
>  #define DRM_MODE_CONNECTOR_DSI   16
>  #define DRM_MODE_CONNECTOR_DPI   17
> +#define DRM_MODE_CONNECTOR_SDI   18
>
>  struct drm_mode_get_connector {
>
> --
> 2.7.4
>
> ___
> dri-devel mailing list
> dri-de...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


This email and any attachments are intended for the sole use of the named 
recipient(s) and contain(s) confidential information that may be proprietary, 
privileged or copyrighted under applicable law. If you are not the intended 
recipient, do not read, copy, or forward this email message or any attachments. 
Delete this email message and any attachments immediately.



RE: [PATCH] drm: adding SDI to drm_connector_enum_list

2017-07-28 Thread Saurabh Singh
Hi Daniel,

Thanks for your reply.
Currently I am using connector type 'Unknown' , and functionally it serves my 
need.
Intention for sending this patch is that userspace tools should recognize SDI 
drivers as SDI only.
Also, I see there are number of 'SDI' drivers getting developed 'under the 
hood' in linux kernel.
This patch will benefit all of them.

It will be great if you could consider it.

Regards,
Saurabh

-Original Message-
From: Daniel Vetter [mailto:daniel.vet...@ffwll.ch] On Behalf Of Daniel Vetter
Sent: Wednesday, July 26, 2017 8:08 PM
To: Saurabh Singh 
Cc: linux-kernel@vger.kernel.org; dri-de...@lists.freedesktop.org; 
airl...@linux.ie; Saurabh Singh ; Dinesh Kumar 

Subject: Re: [PATCH] drm: adding SDI to drm_connector_enum_list

On Wed, Jul 26, 2017 at 10:22:49AM +0530, Saurabh Sengar wrote:
> adding SDI to drm connector list
>
> Signed-off-by: Saurabh Sengar 

This is an uapi change, i.e. userspace needs to be updated. Do you _really_ 
need this? I'd recommend to just use something existing (go with VIRTUAL maybe, 
not sure).

Either way, needs to come together with the actual users and userspace side 
patches. If you really want this.
-Daniel
> ---
>  drivers/gpu/drm/drm_connector.c | 1 +
>  include/uapi/drm/drm_mode.h | 1 +
>  2 files changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_connector.c
> b/drivers/gpu/drm/drm_connector.c index 2db7fb5..ea48ddb 100644
> --- a/drivers/gpu/drm/drm_connector.c
> +++ b/drivers/gpu/drm/drm_connector.c
> @@ -86,6 +86,7 @@ static struct drm_conn_prop_enum_list 
> drm_connector_enum_list[] = {
>   { DRM_MODE_CONNECTOR_VIRTUAL, "Virtual" },
>   { DRM_MODE_CONNECTOR_DSI, "DSI" },
>   { DRM_MODE_CONNECTOR_DPI, "DPI" },
> + { DRM_MODE_CONNECTOR_SDI, "SDI" },
>  };
>
>  void drm_connector_ida_init(void)
> diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> index df0e350..9b8d204 100644
> --- a/include/uapi/drm/drm_mode.h
> +++ b/include/uapi/drm/drm_mode.h
> @@ -247,6 +247,7 @@ struct drm_mode_get_encoder {
>  #define DRM_MODE_CONNECTOR_VIRTUAL  15
>  #define DRM_MODE_CONNECTOR_DSI   16
>  #define DRM_MODE_CONNECTOR_DPI   17
> +#define DRM_MODE_CONNECTOR_SDI   18
>
>  struct drm_mode_get_connector {
>
> --
> 2.7.4
>
> ___
> dri-devel mailing list
> dri-de...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


This email and any attachments are intended for the sole use of the named 
recipient(s) and contain(s) confidential information that may be proprietary, 
privileged or copyrighted under applicable law. If you are not the intended 
recipient, do not read, copy, or forward this email message or any attachments. 
Delete this email message and any attachments immediately.



[RFC] printk: add warning while drop partial text in msg

2017-07-28 Thread pierre Kuo
If the buffer pass to msg_print_text is not big enough to put both all
prefixes and log_text(msg), kernel will quietly break.
That means the user may not have the chance to know whether the
log_text(msg) is fully printed into buffer or not.

In this patch, once above case happened, we try to calculate how many
characters of log_text(msg) are dropped and add waring for debugging
purpose.

Signed-off-by: pierre Kuo 
---
 kernel/printk/printk.c | 23 ++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index fc47863..6cbb3699 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -558,6 +558,12 @@ static u32 msg_used_size(u16 text_len, u16 dict_len, u32 
*pad_len)
 #define MAX_LOG_TAKE_PART 4
 static const char trunc_msg[] = "";
 
+/*
+ * Define max drop msg length that we put in next msg
+ */
+#define MAX_DROP_MSG_LENGTH 32
+static char drop_msg[MAX_DROP_MSG_LENGTH];
+
 static u32 truncate_msg(u16 *text_len, u16 *trunc_msg_len,
u16 *dict_len, u32 *pad_len)
 {
@@ -1264,8 +1270,23 @@ static size_t msg_print_text(const struct printk_log 
*msg, bool syslog, char *bu
 
if (buf) {
if (print_prefix(msg, syslog, NULL) +
-   text_len + 1 >= size - len)
+   text_len + 1 >= size - len) {
+   /* below stores dropped characters
+* related information in next msg
+*/
+   size_t drop_len;
+
+   drop_len = scnprintf(drop_msg,
+   MAX_DROP_MSG_LENGTH,
+   "<%u characters dropped>",
+   (next) ?
+   (unsigned int)(text_size + next - text) 
:
+   (unsigned int)text_size);
+   drop_msg[drop_len] = 0;
+   log_store(msg->facility, msg->level, msg->flags,
+   0, NULL, 0, drop_msg, strlen(drop_msg));
break;
+   }
 
len += print_prefix(msg, syslog, buf + len);
memcpy(buf + len, text, text_len);
-- 
1.9.1



[RFC] printk: add warning while drop partial text in msg

2017-07-28 Thread pierre Kuo
If the buffer pass to msg_print_text is not big enough to put both all
prefixes and log_text(msg), kernel will quietly break.
That means the user may not have the chance to know whether the
log_text(msg) is fully printed into buffer or not.

In this patch, once above case happened, we try to calculate how many
characters of log_text(msg) are dropped and add waring for debugging
purpose.

Signed-off-by: pierre Kuo 
---
 kernel/printk/printk.c | 23 ++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index fc47863..6cbb3699 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -558,6 +558,12 @@ static u32 msg_used_size(u16 text_len, u16 dict_len, u32 
*pad_len)
 #define MAX_LOG_TAKE_PART 4
 static const char trunc_msg[] = "";
 
+/*
+ * Define max drop msg length that we put in next msg
+ */
+#define MAX_DROP_MSG_LENGTH 32
+static char drop_msg[MAX_DROP_MSG_LENGTH];
+
 static u32 truncate_msg(u16 *text_len, u16 *trunc_msg_len,
u16 *dict_len, u32 *pad_len)
 {
@@ -1264,8 +1270,23 @@ static size_t msg_print_text(const struct printk_log 
*msg, bool syslog, char *bu
 
if (buf) {
if (print_prefix(msg, syslog, NULL) +
-   text_len + 1 >= size - len)
+   text_len + 1 >= size - len) {
+   /* below stores dropped characters
+* related information in next msg
+*/
+   size_t drop_len;
+
+   drop_len = scnprintf(drop_msg,
+   MAX_DROP_MSG_LENGTH,
+   "<%u characters dropped>",
+   (next) ?
+   (unsigned int)(text_size + next - text) 
:
+   (unsigned int)text_size);
+   drop_msg[drop_len] = 0;
+   log_store(msg->facility, msg->level, msg->flags,
+   0, NULL, 0, drop_msg, strlen(drop_msg));
break;
+   }
 
len += print_prefix(msg, syslog, buf + len);
memcpy(buf + len, text, text_len);
-- 
1.9.1



Re: [PATCH v6 6/7] dt-bindings: display: rockchip: fill Documents for vop series

2017-07-28 Thread Heiko Stuebner
Hi Mark,

Am Mittwoch, 26. Juli 2017, 14:19:35 CEST schrieb Mark Yao:
> Signed-off-by: Mark Yao 
> Acked-by: Rob Herring 
> ---
> Changes in v5:
> - clean document commit title
> - move changes description out of docummit commit msg
> 
> Changes in v2:
> - rename rk322x to rk3228
> - correct some vop registers define
> 
>  Documentation/devicetree/bindings/display/rockchip/rockchip-vop.txt | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git 
> a/Documentation/devicetree/bindings/display/rockchip/rockchip-vop.txt 
> b/Documentation/devicetree/bindings/display/rockchip/rockchip-vop.txt
> index 9eb3f0a..5d835d9 100644
> --- a/Documentation/devicetree/bindings/display/rockchip/rockchip-vop.txt
> +++ b/Documentation/devicetree/bindings/display/rockchip/rockchip-vop.txt
> @@ -8,8 +8,12 @@ Required properties:
>  - compatible: value should be one of the following
>   "rockchip,rk3036-vop";
>   "rockchip,rk3288-vop";
> + "rockchip,rk3368-vop";
> + "rockchip,rk3366-vop";
>   "rockchip,rk3399-vop-big";
>   "rockchip,rk3399-vop-lit";
> + "rockchip,rk3228-vop";
> + "rockchip,rk3328-vop";

what is your ordering scheme here?
As the number of rk socs will very likely increase in the future
ordering alphanumerical might make everything more manageable when
the list grows.

So maybe swap rk3368 and rk3366 and move rk3228+rk3328 to sorted
positions?


Heiko


Re: [PATCH 1/3] perf tools: Add callchain to ctf conversion

2017-07-28 Thread Jiri Olsa
On Thu, Jul 27, 2017 at 02:12:03PM -0400, Geneviève Bastien wrote:
> The field perf_callchain, if available, is added to the sampling
> events during the CTF conversion. It is an array of u64 values.
> The perf_callchain_size field contains the size of the array.
> 
> It will allow the analysis of sampling data in trace visualization tools
> like Trace Compass. Possible analyses with those data: dynamic
> flamegraphs, correlation with other tracing data like a userspace trace.
> 
> Here follows a babeltrace CTF output of a trace with callchain:
> 
>  $ babeltrace ./myctftrace
>  [17:38:45.672760285] (+?.?) cycles:ppp: { cpu_id = 0 }, { perf_ip = 
> 0x81063EE4, perf_tid = 25841, perf_pid = 25774, perf_period = 1, 
> perf_callchain_size = 7, perf_callchain = [ [0] = 0xFF80, [1] = 
> 0x81063EE4, [2] = 0x8100C770, [3] = 0x81006EC6, [4] = 
> 0x8118245E, [5] = 0x810A9224, [6] = 0x8164A4C6 ] }
>  [17:38:45.672777672] (+0.17387) cycles:ppp: { cpu_id = 0 }, { perf_ip = 
> 0x81063EE4, perf_tid = 25841, perf_pid = 25774, perf_period = 1, 
> perf_callchain_size = 8, perf_callchain = [ [0] = 0xFF80, [1] = 
> 0x81063EE4, [2] = 0x8100C770, [3] = 0x81006EC6, [4] = 
> 0x8118245E, [5] = 0x810A9224, [6] = 0x8164A4C6, [7] = 
> 0x8164ABAD ] }
>  [17:38:45.672786700] (+0.09028) cycles:ppp: { cpu_id = 0 }, { perf_ip = 
> 0x81063EE4, perf_tid = 25841, perf_pid = 25774, perf_period = 70, 
> perf_callchain_size = 3, perf_callchain = [ [0] = 0xFF80, [1] = 
> 0x81063EE4, [2] = 0x8100C770 ] }

missing one more hunk (attached) ;-)

I guess there's no need to resend, Arnaldo could remove it,
anyway for patchset:

Acked-by: Jiri Olsa 

Is there already tracecompas change to display callchains and mmaps?

thanks,
jirka


---
diff --git a/tools/perf/util/data-convert-bt.c 
b/tools/perf/util/data-convert-bt.c
index c47b0943ef88..2346cecb8ea2 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -596,7 +596,6 @@ static int add_generic_values(struct ctf_writer *cw,
 *   PERF_SAMPLE_TIME - not needed as we have it in
 *  ctf event header
 *   PERF_SAMPLE_READ - TODO
-*   PERF_SAMPLE_CALLCHAIN- TODO
 *   PERF_SAMPLE_RAW  - tracepoint fields are handled separately
 *   PERF_SAMPLE_BRANCH_STACK - TODO
 *   PERF_SAMPLE_REGS_USER- TODO


Re: [PATCH v6 6/7] dt-bindings: display: rockchip: fill Documents for vop series

2017-07-28 Thread Heiko Stuebner
Hi Mark,

Am Mittwoch, 26. Juli 2017, 14:19:35 CEST schrieb Mark Yao:
> Signed-off-by: Mark Yao 
> Acked-by: Rob Herring 
> ---
> Changes in v5:
> - clean document commit title
> - move changes description out of docummit commit msg
> 
> Changes in v2:
> - rename rk322x to rk3228
> - correct some vop registers define
> 
>  Documentation/devicetree/bindings/display/rockchip/rockchip-vop.txt | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git 
> a/Documentation/devicetree/bindings/display/rockchip/rockchip-vop.txt 
> b/Documentation/devicetree/bindings/display/rockchip/rockchip-vop.txt
> index 9eb3f0a..5d835d9 100644
> --- a/Documentation/devicetree/bindings/display/rockchip/rockchip-vop.txt
> +++ b/Documentation/devicetree/bindings/display/rockchip/rockchip-vop.txt
> @@ -8,8 +8,12 @@ Required properties:
>  - compatible: value should be one of the following
>   "rockchip,rk3036-vop";
>   "rockchip,rk3288-vop";
> + "rockchip,rk3368-vop";
> + "rockchip,rk3366-vop";
>   "rockchip,rk3399-vop-big";
>   "rockchip,rk3399-vop-lit";
> + "rockchip,rk3228-vop";
> + "rockchip,rk3328-vop";

what is your ordering scheme here?
As the number of rk socs will very likely increase in the future
ordering alphanumerical might make everything more manageable when
the list grows.

So maybe swap rk3368 and rk3366 and move rk3228+rk3328 to sorted
positions?


Heiko


Re: [PATCH 1/3] perf tools: Add callchain to ctf conversion

2017-07-28 Thread Jiri Olsa
On Thu, Jul 27, 2017 at 02:12:03PM -0400, Geneviève Bastien wrote:
> The field perf_callchain, if available, is added to the sampling
> events during the CTF conversion. It is an array of u64 values.
> The perf_callchain_size field contains the size of the array.
> 
> It will allow the analysis of sampling data in trace visualization tools
> like Trace Compass. Possible analyses with those data: dynamic
> flamegraphs, correlation with other tracing data like a userspace trace.
> 
> Here follows a babeltrace CTF output of a trace with callchain:
> 
>  $ babeltrace ./myctftrace
>  [17:38:45.672760285] (+?.?) cycles:ppp: { cpu_id = 0 }, { perf_ip = 
> 0x81063EE4, perf_tid = 25841, perf_pid = 25774, perf_period = 1, 
> perf_callchain_size = 7, perf_callchain = [ [0] = 0xFF80, [1] = 
> 0x81063EE4, [2] = 0x8100C770, [3] = 0x81006EC6, [4] = 
> 0x8118245E, [5] = 0x810A9224, [6] = 0x8164A4C6 ] }
>  [17:38:45.672777672] (+0.17387) cycles:ppp: { cpu_id = 0 }, { perf_ip = 
> 0x81063EE4, perf_tid = 25841, perf_pid = 25774, perf_period = 1, 
> perf_callchain_size = 8, perf_callchain = [ [0] = 0xFF80, [1] = 
> 0x81063EE4, [2] = 0x8100C770, [3] = 0x81006EC6, [4] = 
> 0x8118245E, [5] = 0x810A9224, [6] = 0x8164A4C6, [7] = 
> 0x8164ABAD ] }
>  [17:38:45.672786700] (+0.09028) cycles:ppp: { cpu_id = 0 }, { perf_ip = 
> 0x81063EE4, perf_tid = 25841, perf_pid = 25774, perf_period = 70, 
> perf_callchain_size = 3, perf_callchain = [ [0] = 0xFF80, [1] = 
> 0x81063EE4, [2] = 0x8100C770 ] }

missing one more hunk (attached) ;-)

I guess there's no need to resend, Arnaldo could remove it,
anyway for patchset:

Acked-by: Jiri Olsa 

Is there already tracecompas change to display callchains and mmaps?

thanks,
jirka


---
diff --git a/tools/perf/util/data-convert-bt.c 
b/tools/perf/util/data-convert-bt.c
index c47b0943ef88..2346cecb8ea2 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -596,7 +596,6 @@ static int add_generic_values(struct ctf_writer *cw,
 *   PERF_SAMPLE_TIME - not needed as we have it in
 *  ctf event header
 *   PERF_SAMPLE_READ - TODO
-*   PERF_SAMPLE_CALLCHAIN- TODO
 *   PERF_SAMPLE_RAW  - tracepoint fields are handled separately
 *   PERF_SAMPLE_BRANCH_STACK - TODO
 *   PERF_SAMPLE_REGS_USER- TODO


Re: [PATCH v6.1 4/7] drm/rockchip: vop: group vop registers

2017-07-28 Thread Heiko Stuebner
Am Freitag, 28. Juli 2017, 14:06:25 CEST schrieb Mark Yao:
> Grouping the vop registers facilitates make register
> definition clearer, and also is useful for different vop
> reuse the same group register.
> 
> Signed-off-by: Mark Yao 
> Reviewed-by: Jeffy Chen 

on rk3036 and rk3288
Tested-by: Heiko Stuebner 


Re: [PATCH v6.1 4/7] drm/rockchip: vop: group vop registers

2017-07-28 Thread Heiko Stuebner
Am Freitag, 28. Juli 2017, 14:06:25 CEST schrieb Mark Yao:
> Grouping the vop registers facilitates make register
> definition clearer, and also is useful for different vop
> reuse the same group register.
> 
> Signed-off-by: Mark Yao 
> Reviewed-by: Jeffy Chen 

on rk3036 and rk3288
Tested-by: Heiko Stuebner 


Re: [PATCH 2/2] dt-bindings: ata: add DT bindings for MediaTek SATA controller

2017-07-28 Thread Sergei Shtylyov

Hello!

On 7/27/2017 9:38 AM, Ryder Lee wrote:


Add DT bindings for the onboard SATA controller present on the MediaTek
SoCs.

Signed-off-by: Ryder Lee 
---
  Documentation/devicetree/bindings/ata/ahci-mtk.txt | 48 ++
  1 file changed, 48 insertions(+)
  create mode 100644 Documentation/devicetree/bindings/ata/ahci-mtk.txt

diff --git a/Documentation/devicetree/bindings/ata/ahci-mtk.txt 
b/Documentation/devicetree/bindings/ata/ahci-mtk.txt
new file mode 100644
index 000..a8d11db
--- /dev/null
+++ b/Documentation/devicetree/bindings/ata/ahci-mtk.txt
@@ -0,0 +1,48 @@
+MediaTek Seria ATA controller
+
+Required properties:
+ - compatible : Must be "mediatek,ahci".
+ - reg: Physical base addresses and length of register sets.
+ - interrupts : Interrupt associated with the SATA device.
+ - interrupt-names : Associated name must be: "hostc".
+ - clocks : The phandle for the clock.


   Your example shows that you need both phandle and specifier (afetr phandle).


+ - clock-names: Associated name must be: "ahb", "axi", "asic", "rbc", "pm"
+ - phys   : The phandle for the PHY port.


Likewise.


+ - phy-names  : Associated name must be: "sata-phy".
+ - ports-implemented : Mask that indicates which ports that the HBA supports
+  are available for software to use. Useful if PORTS_IMPL
+  is not programmed by the BIOS, which is true with some
+  embedded SOC's.


   An empty line wouldn't hurt here...


+Optional properties:
+ - power-domains   : A phandle and power domain specifier pair to the power
+domain which is responsible for collapsing and restoring
+power to the peripheral.
+ - resets : Must contain an entry for each entry in reset-names.
+See ../reset/reset.txt for details.
+ - reset-names: Associated names must be: "axi-rst", "sw-rst", "reg-rst".
+ - mediatek,phy-mode : A phandle to the system controller, used to enable
+  SATA function.
+
+Example:
+
+   sata: sata@1a20 {
+   compatible = "mediatek,ahci";
+   reg = <0 0x1a20 0 0x1100>;
+   interrupts = ;
+   interrupt-names = "hostc";
+   clocks = < CLK_SATA_AHB_EN>,
+< CLK_SATA_AXI_EN>,
+< CLK_SATA_ASIC_EN>,
+< CLK_SATA_RBC_EN>,
+< CLK_SATA_PM_EN>;
+   clock-names = "ahb", "axi", "asic", "rbc", "pm";
+   phys = < PHY_TYPE_SATA>;
+   phy-names = "sata-phy";
+   ports-implemented = <0x1>;
+   power-domains = < MT7622_POWER_DOMAIN_HIF0>;
+   resets = < MT7622_SATA_AXI_BUS_RST>,
+< MT7622_SATA_PHY_SW_RST>,
+< MT7622_SATA_PHY_REG_RST>;
+   reset-names = "axi-rst", "sw-rst", "reg-rst";
+   mediatek,phy-mode = <>;
+   };


MBR, Sergei


Re: [PATCH 2/2] dt-bindings: ata: add DT bindings for MediaTek SATA controller

2017-07-28 Thread Sergei Shtylyov

Hello!

On 7/27/2017 9:38 AM, Ryder Lee wrote:


Add DT bindings for the onboard SATA controller present on the MediaTek
SoCs.

Signed-off-by: Ryder Lee 
---
  Documentation/devicetree/bindings/ata/ahci-mtk.txt | 48 ++
  1 file changed, 48 insertions(+)
  create mode 100644 Documentation/devicetree/bindings/ata/ahci-mtk.txt

diff --git a/Documentation/devicetree/bindings/ata/ahci-mtk.txt 
b/Documentation/devicetree/bindings/ata/ahci-mtk.txt
new file mode 100644
index 000..a8d11db
--- /dev/null
+++ b/Documentation/devicetree/bindings/ata/ahci-mtk.txt
@@ -0,0 +1,48 @@
+MediaTek Seria ATA controller
+
+Required properties:
+ - compatible : Must be "mediatek,ahci".
+ - reg: Physical base addresses and length of register sets.
+ - interrupts : Interrupt associated with the SATA device.
+ - interrupt-names : Associated name must be: "hostc".
+ - clocks : The phandle for the clock.


   Your example shows that you need both phandle and specifier (afetr phandle).


+ - clock-names: Associated name must be: "ahb", "axi", "asic", "rbc", "pm"
+ - phys   : The phandle for the PHY port.


Likewise.


+ - phy-names  : Associated name must be: "sata-phy".
+ - ports-implemented : Mask that indicates which ports that the HBA supports
+  are available for software to use. Useful if PORTS_IMPL
+  is not programmed by the BIOS, which is true with some
+  embedded SOC's.


   An empty line wouldn't hurt here...


+Optional properties:
+ - power-domains   : A phandle and power domain specifier pair to the power
+domain which is responsible for collapsing and restoring
+power to the peripheral.
+ - resets : Must contain an entry for each entry in reset-names.
+See ../reset/reset.txt for details.
+ - reset-names: Associated names must be: "axi-rst", "sw-rst", "reg-rst".
+ - mediatek,phy-mode : A phandle to the system controller, used to enable
+  SATA function.
+
+Example:
+
+   sata: sata@1a20 {
+   compatible = "mediatek,ahci";
+   reg = <0 0x1a20 0 0x1100>;
+   interrupts = ;
+   interrupt-names = "hostc";
+   clocks = < CLK_SATA_AHB_EN>,
+< CLK_SATA_AXI_EN>,
+< CLK_SATA_ASIC_EN>,
+< CLK_SATA_RBC_EN>,
+< CLK_SATA_PM_EN>;
+   clock-names = "ahb", "axi", "asic", "rbc", "pm";
+   phys = < PHY_TYPE_SATA>;
+   phy-names = "sata-phy";
+   ports-implemented = <0x1>;
+   power-domains = < MT7622_POWER_DOMAIN_HIF0>;
+   resets = < MT7622_SATA_AXI_BUS_RST>,
+< MT7622_SATA_PHY_SW_RST>,
+< MT7622_SATA_PHY_REG_RST>;
+   reset-names = "axi-rst", "sw-rst", "reg-rst";
+   mediatek,phy-mode = <>;
+   };


MBR, Sergei


Re: [rcu:rcu/next 4/4] frv-linux-ld: Warning: size of symbol `sys_membarrier' changed from 8 in kernel/sys_ni.o to 44 in kernel/sched/membarrier.o

2017-07-28 Thread Peter Zijlstra
On Fri, Jul 28, 2017 at 12:46:40AM +, Mathieu Desnoyers wrote:

> > This is a new one on me.  What do we do to fix it?

Apparently (see below) the answer is, we ignore this.

> I would suspect this might be caused by moving membarrier.c from kernel/
> to kernel/sched/. Perhaps Peter knows ?

 dhowells: hey, I know you don't care about FRV anymore, but suppose 
the 0-day thing says things like:
 >>frv-linux-ld: Warning: size of symbol `sys_setuid' changed from 
272 in
 >>kernel/sys.o to 8 in kernel/sys_ni.o
 dhowells: do you have any clue wth went wrong?
 peterz: it's been saying that for a long time, but I've no idea why
 didn't seem to stop it working
 I suspect it might not be handing weak symbol elimination correctly 
or something
 fair enough, I'll ignore it then


Re: [rcu:rcu/next 4/4] frv-linux-ld: Warning: size of symbol `sys_membarrier' changed from 8 in kernel/sys_ni.o to 44 in kernel/sched/membarrier.o

2017-07-28 Thread Peter Zijlstra
On Fri, Jul 28, 2017 at 12:46:40AM +, Mathieu Desnoyers wrote:

> > This is a new one on me.  What do we do to fix it?

Apparently (see below) the answer is, we ignore this.

> I would suspect this might be caused by moving membarrier.c from kernel/
> to kernel/sched/. Perhaps Peter knows ?

 dhowells: hey, I know you don't care about FRV anymore, but suppose 
the 0-day thing says things like:
 >>frv-linux-ld: Warning: size of symbol `sys_setuid' changed from 
272 in
 >>kernel/sys.o to 8 in kernel/sys_ni.o
 dhowells: do you have any clue wth went wrong?
 peterz: it's been saying that for a long time, but I've no idea why
 didn't seem to stop it working
 I suspect it might not be handing weak symbol elimination correctly 
or something
 fair enough, I'll ignore it then


[RFC PATCH] treewide: remove GFP_TEMPORARY allocation flag

2017-07-28 Thread Michal Hocko
From: Michal Hocko 

GFP_TEMPORARY has been introduced by e12ba74d8ff3 ("Group short-lived
and reclaimable kernel allocations") along with __GFP_RECLAIMABLE. It's
primary motivation was to allow users to tell that an allocation is
short lived and so the allocator can try to place such allocations close
together and prevent long term fragmentation. As much as this sounds
like a reasonable semantic it becomes much less clear when to use the
highlevel GFP_TEMPORARY allocation flag. How long is temporary? Can
the context holding that memory sleep? Can it take locks? It seems
there is no good answer for those questions.

The current implementation of GFP_TEMPORARY is basically
GFP_KERNEL | __GFP_RECLAIMABLE which in itself is tricky because
basically none of the existing caller provide a way to reclaim the
allocated memory. So this is rather misleading and hard to evaluate for
any benefits.

I have checked some random users and none of them has added the flag
with a specific justification. I suspect most of them just copied from
other existing users and others just thought it might be a good idea
to use without any measuring. This suggests that GFP_TEMPORARY just
motivates for cargo cult usage without any reasoning.

I believe that our gfp flags are quite complex already and especially
those with highlevel semantic should be clearly defined to prevent from
confusion and abuse. Therefore I propose dropping GFP_TEMPORARY and
replace all existing users to simply use GFP_KERNEL. Please note that
SLAB users with shrinkers will still get __GFP_RECLAIMABLE heuristic
and so they will be placed properly for memory fragmentation prevention.

I can see reasons we might want some gfp flag to reflect shorterm
allocations but I propose starting from a clear semantic definition and
only then add users with proper justification.

Signed-off-by: Michal Hocko 
---
Hi,
this has been brought up before LSF this year by Matthew [1] and it
turned out that GFP_TEMPORARY really doesn't have a clear semantic.  It
seems to be a heuristic without any measured advantage for most (if
not all) its current users. The follow up discussion has revealed that
opinions on what might be temporary allocation differ a lot between
developers. So rather than trying to tweak existing users into a
semantic which they haven't expected I propose to simply remove the
flag and start from scratch if we really need a semantic for short term
allocations.

[1] http://lkml.kernel.org/r/20170118054945.gd18...@bombadil.infradead.org

 arch/arc/kernel/setup.c|  2 +-
 arch/arc/kernel/troubleshoot.c |  2 +-
 arch/powerpc/kernel/rtas.c |  4 ++--
 arch/powerpc/platforms/pseries/suspend.c   |  2 +-
 drivers/gpu/drm/drm_blend.c|  2 +-
 drivers/gpu/drm/drm_dp_dual_mode_helper.c  |  2 +-
 drivers/gpu/drm/drm_scdc_helper.c  |  2 +-
 drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c   |  2 +-
 drivers/gpu/drm/i915/i915_gem.c|  2 +-
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |  6 +++---
 drivers/gpu/drm/i915/i915_gem_gtt.c|  2 +-
 drivers/gpu/drm/i915/i915_gem_userptr.c|  4 ++--
 drivers/gpu/drm/i915/i915_gpu_error.c  |  6 +++---
 drivers/gpu/drm/i915/selftests/i915_random.c   |  2 +-
 drivers/gpu/drm/i915/selftests/intel_breadcrumbs.c | 10 +-
 drivers/gpu/drm/i915/selftests/intel_uncore.c  |  2 +-
 drivers/gpu/drm/lib/drm_random.c   |  2 +-
 drivers/gpu/drm/msm/msm_gem_submit.c   |  2 +-
 drivers/gpu/drm/selftests/test-drm_mm.c|  4 ++--
 drivers/misc/cxl/pci.c |  2 +-
 drivers/xen/gntalloc.c |  2 +-
 fs/coredump.c  |  2 +-
 fs/exec.c  |  4 ++--
 fs/overlayfs/copy_up.c |  2 +-
 fs/overlayfs/dir.c |  2 +-
 fs/overlayfs/namei.c   |  8 
 fs/proc/base.c |  8 
 fs/proc/task_mmu.c |  2 +-
 include/linux/gfp.h|  2 --
 include/trace/events/mmflags.h |  1 -
 kernel/locking/test-ww_mutex.c |  2 +-
 kernel/trace/trace_events_filter.c |  2 +-
 lib/string_helpers.c   |  4 ++--
 mm/shmem.c |  2 +-
 mm/slub.c  |  2 +-
 tools/perf/builtin-kmem.c  |  1 -
 36 files changed, 52 insertions(+), 56 deletions(-)

diff --git a/arch/arc/kernel/setup.c b/arch/arc/kernel/setup.c
index fc8211f338ad..8e80cc2b1efb 100644
--- a/arch/arc/kernel/setup.c
+++ b/arch/arc/kernel/setup.c
@@ -510,7 +510,7 @@ static int 

[RFC PATCH] treewide: remove GFP_TEMPORARY allocation flag

2017-07-28 Thread Michal Hocko
From: Michal Hocko 

GFP_TEMPORARY has been introduced by e12ba74d8ff3 ("Group short-lived
and reclaimable kernel allocations") along with __GFP_RECLAIMABLE. It's
primary motivation was to allow users to tell that an allocation is
short lived and so the allocator can try to place such allocations close
together and prevent long term fragmentation. As much as this sounds
like a reasonable semantic it becomes much less clear when to use the
highlevel GFP_TEMPORARY allocation flag. How long is temporary? Can
the context holding that memory sleep? Can it take locks? It seems
there is no good answer for those questions.

The current implementation of GFP_TEMPORARY is basically
GFP_KERNEL | __GFP_RECLAIMABLE which in itself is tricky because
basically none of the existing caller provide a way to reclaim the
allocated memory. So this is rather misleading and hard to evaluate for
any benefits.

I have checked some random users and none of them has added the flag
with a specific justification. I suspect most of them just copied from
other existing users and others just thought it might be a good idea
to use without any measuring. This suggests that GFP_TEMPORARY just
motivates for cargo cult usage without any reasoning.

I believe that our gfp flags are quite complex already and especially
those with highlevel semantic should be clearly defined to prevent from
confusion and abuse. Therefore I propose dropping GFP_TEMPORARY and
replace all existing users to simply use GFP_KERNEL. Please note that
SLAB users with shrinkers will still get __GFP_RECLAIMABLE heuristic
and so they will be placed properly for memory fragmentation prevention.

I can see reasons we might want some gfp flag to reflect shorterm
allocations but I propose starting from a clear semantic definition and
only then add users with proper justification.

Signed-off-by: Michal Hocko 
---
Hi,
this has been brought up before LSF this year by Matthew [1] and it
turned out that GFP_TEMPORARY really doesn't have a clear semantic.  It
seems to be a heuristic without any measured advantage for most (if
not all) its current users. The follow up discussion has revealed that
opinions on what might be temporary allocation differ a lot between
developers. So rather than trying to tweak existing users into a
semantic which they haven't expected I propose to simply remove the
flag and start from scratch if we really need a semantic for short term
allocations.

[1] http://lkml.kernel.org/r/20170118054945.gd18...@bombadil.infradead.org

 arch/arc/kernel/setup.c|  2 +-
 arch/arc/kernel/troubleshoot.c |  2 +-
 arch/powerpc/kernel/rtas.c |  4 ++--
 arch/powerpc/platforms/pseries/suspend.c   |  2 +-
 drivers/gpu/drm/drm_blend.c|  2 +-
 drivers/gpu/drm/drm_dp_dual_mode_helper.c  |  2 +-
 drivers/gpu/drm/drm_scdc_helper.c  |  2 +-
 drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c   |  2 +-
 drivers/gpu/drm/i915/i915_gem.c|  2 +-
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |  6 +++---
 drivers/gpu/drm/i915/i915_gem_gtt.c|  2 +-
 drivers/gpu/drm/i915/i915_gem_userptr.c|  4 ++--
 drivers/gpu/drm/i915/i915_gpu_error.c  |  6 +++---
 drivers/gpu/drm/i915/selftests/i915_random.c   |  2 +-
 drivers/gpu/drm/i915/selftests/intel_breadcrumbs.c | 10 +-
 drivers/gpu/drm/i915/selftests/intel_uncore.c  |  2 +-
 drivers/gpu/drm/lib/drm_random.c   |  2 +-
 drivers/gpu/drm/msm/msm_gem_submit.c   |  2 +-
 drivers/gpu/drm/selftests/test-drm_mm.c|  4 ++--
 drivers/misc/cxl/pci.c |  2 +-
 drivers/xen/gntalloc.c |  2 +-
 fs/coredump.c  |  2 +-
 fs/exec.c  |  4 ++--
 fs/overlayfs/copy_up.c |  2 +-
 fs/overlayfs/dir.c |  2 +-
 fs/overlayfs/namei.c   |  8 
 fs/proc/base.c |  8 
 fs/proc/task_mmu.c |  2 +-
 include/linux/gfp.h|  2 --
 include/trace/events/mmflags.h |  1 -
 kernel/locking/test-ww_mutex.c |  2 +-
 kernel/trace/trace_events_filter.c |  2 +-
 lib/string_helpers.c   |  4 ++--
 mm/shmem.c |  2 +-
 mm/slub.c  |  2 +-
 tools/perf/builtin-kmem.c  |  1 -
 36 files changed, 52 insertions(+), 56 deletions(-)

diff --git a/arch/arc/kernel/setup.c b/arch/arc/kernel/setup.c
index fc8211f338ad..8e80cc2b1efb 100644
--- a/arch/arc/kernel/setup.c
+++ b/arch/arc/kernel/setup.c
@@ -510,7 +510,7 @@ static int show_cpuinfo(struct seq_file *m, 

Re: [PATCH] thread_info: suppress sparse warning in check_copy_size()

2017-07-28 Thread Luc Van Oostenryck
On Thu, Jul 27, 2017 at 12:41 AM, Linus Torvalds
 wrote:
> This is wrong. The sparse version of __compiletime_object_size()
> should just be fixed to take a 'const' pointer without complaints.

The underlying __builtin_object_size() has been fixed in the sparse tree
6 months ago or so.

-- Luc


Re: [PATCH] thread_info: suppress sparse warning in check_copy_size()

2017-07-28 Thread Luc Van Oostenryck
On Thu, Jul 27, 2017 at 12:41 AM, Linus Torvalds
 wrote:
> This is wrong. The sparse version of __compiletime_object_size()
> should just be fixed to take a 'const' pointer without complaints.

The underlying __builtin_object_size() has been fixed in the sparse tree
6 months ago or so.

-- Luc


Re: [PATCH v4 1/3] mfd: Add new mfd device TPS68470

2017-07-28 Thread Andy Shevchenko
On Fri, Jul 28, 2017 at 3:30 AM, Mani, Rajmohan  wrote:
>> On Wed, Jul 26, 2017 at 11:23 AM, Lee Jones  wrote:
>> > On Tue, 25 Jul 2017, Andy Shevchenko wrote:
>> >> On Tue, Jul 25, 2017 at 12:10 PM, Lee Jones  wrote:
>>
>> >> I briefly checked few ->read() and ->write() implementations and
>> >> didn't find any evidence of positive numbers that can be returned.
>> >> Documentation (kernel doc) doesn't shed a light on that. So, to me it
>> >> sounds unspecified.
>> >>
>> >> So, for now (until documentation will be fixed) I would rely on if
>> >> (ret < 0)
>> >
>> > It's not unspecified.  The regmap methods call into regcache_write(),
>> > where the kerneldoc is clear.
>>
>
> Since, we are interested in the regmap for the I2C bus here, I looked into 
> the implementation of
>  __devm_regmap_init()
> __regmap_init()
> regcache_init()
> for I2C bus.
>
> At the end of __devm_regmap_init() call from devm_regmap_init_i2c() inside 
> tps68470_probe(), I see that both cache_bypass and defer_caching flags of i2c 
> regmap struct are set. So, it looks regcache_write/read calls do not come 
> into play here.
>
> So, regmap_write()
> _regmap_write()
> map->reg_write (drivers/base/regmap/regmap.c:1665) translates 
> to
> regmap_i2c_write(drivers/base/regmap/regmap-i2c.c:128)
>
> These checks in regmap_i2c_write() ensure all return values from 
> i2c_master_send() other than the requested number of bytes to write, are 
> converted into negative values.
>
> if (ret == count)
> return 0;
> else if (ret < 0)
> return ret;
> else
> return -EIO;
>
> Similar argument goes for regmap_read() as well.
> With that, for regmap over I2C bus, it sounds like 'if (ret < 0)' looks to be 
> a better choice. Please see if I missed anything here.

It prooves exactly the Lee's point.

So, perhaps the best approach is to move to
if (ret)
 return ret;

...if it will be a problem in the future, fix it accordingly.

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH v4 1/3] mfd: Add new mfd device TPS68470

2017-07-28 Thread Andy Shevchenko
On Fri, Jul 28, 2017 at 3:30 AM, Mani, Rajmohan  wrote:
>> On Wed, Jul 26, 2017 at 11:23 AM, Lee Jones  wrote:
>> > On Tue, 25 Jul 2017, Andy Shevchenko wrote:
>> >> On Tue, Jul 25, 2017 at 12:10 PM, Lee Jones  wrote:
>>
>> >> I briefly checked few ->read() and ->write() implementations and
>> >> didn't find any evidence of positive numbers that can be returned.
>> >> Documentation (kernel doc) doesn't shed a light on that. So, to me it
>> >> sounds unspecified.
>> >>
>> >> So, for now (until documentation will be fixed) I would rely on if
>> >> (ret < 0)
>> >
>> > It's not unspecified.  The regmap methods call into regcache_write(),
>> > where the kerneldoc is clear.
>>
>
> Since, we are interested in the regmap for the I2C bus here, I looked into 
> the implementation of
>  __devm_regmap_init()
> __regmap_init()
> regcache_init()
> for I2C bus.
>
> At the end of __devm_regmap_init() call from devm_regmap_init_i2c() inside 
> tps68470_probe(), I see that both cache_bypass and defer_caching flags of i2c 
> regmap struct are set. So, it looks regcache_write/read calls do not come 
> into play here.
>
> So, regmap_write()
> _regmap_write()
> map->reg_write (drivers/base/regmap/regmap.c:1665) translates 
> to
> regmap_i2c_write(drivers/base/regmap/regmap-i2c.c:128)
>
> These checks in regmap_i2c_write() ensure all return values from 
> i2c_master_send() other than the requested number of bytes to write, are 
> converted into negative values.
>
> if (ret == count)
> return 0;
> else if (ret < 0)
> return ret;
> else
> return -EIO;
>
> Similar argument goes for regmap_read() as well.
> With that, for regmap over I2C bus, it sounds like 'if (ret < 0)' looks to be 
> a better choice. Please see if I missed anything here.

It prooves exactly the Lee's point.

So, perhaps the best approach is to move to
if (ret)
 return ret;

...if it will be a problem in the future, fix it accordingly.

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH] drm/amd/powerplay: rv: Use designated initializers

2017-07-28 Thread Christian König

Am 28.07.2017 um 03:43 schrieb Alex Deucher:

On Tue, Jul 25, 2017 at 5:47 PM, Kees Cook  wrote:

As done for vega10 in commit 3ddd396f6b57 ("drm/amd/powerplay: Use
designated initializers") mark other tableFunction entries with designated
initializers. The randstruct plugin requires designated initializers for
structures that are entirely function pointers.

Cc: Rex Zhu 
Cc: Hawking Zhang 
Cc: Alex Deucher 
Signed-off-by: Kees Cook 
---
If I can get an Ack for this, I'll carry it in the gcc-plugins tree, unless
you think this is worth landing for v4.13, in which case, please take it
now. :)


Acked-by: Alex Deucher 

I'm happy to take this through my tree if that is ok with you.


I'm wondering a bit how the plugin detects that it can randomize a 
structure layout?


We have a couple of structs where this would be fatal.

Christian.



Alex


Thanks!
---
  drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.c | 8 
  1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.c 
b/drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.c
index 4c7f430b36eb..8e6cfd89c7e0 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.c
@@ -308,8 +308,8 @@ static int rv_tf_set_num_active_display(struct pp_hwmgr 
*hwmgr, void *input,
  }

  static const struct phm_master_table_item rv_set_power_state_list[] = {
-   { NULL, rv_tf_set_clock_limit },
-   { NULL, rv_tf_set_num_active_display },
+   { .tableFunction = rv_tf_set_clock_limit },
+   { .tableFunction = rv_tf_set_num_active_display },
 { }
  };

@@ -382,7 +382,7 @@ static int rv_tf_disable_gfx_off(struct pp_hwmgr *hwmgr,
  }

  static const struct phm_master_table_item rv_disable_dpm_list[] = {
-   {NULL, rv_tf_disable_gfx_off},
+   { .tableFunction = rv_tf_disable_gfx_off },
 { },
  };

@@ -407,7 +407,7 @@ static int rv_tf_enable_gfx_off(struct pp_hwmgr *hwmgr,
  }

  static const struct phm_master_table_item rv_enable_dpm_list[] = {
-   {NULL, rv_tf_enable_gfx_off},
+   { .tableFunction = rv_tf_enable_gfx_off },
 { },
  };

--
2.7.4


--
Kees Cook
Pixel Security
___
amd-gfx mailing list
amd-...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

___
amd-gfx mailing list
amd-...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx





Re: [PATCH] drm/amd/powerplay: rv: Use designated initializers

2017-07-28 Thread Christian König

Am 28.07.2017 um 03:43 schrieb Alex Deucher:

On Tue, Jul 25, 2017 at 5:47 PM, Kees Cook  wrote:

As done for vega10 in commit 3ddd396f6b57 ("drm/amd/powerplay: Use
designated initializers") mark other tableFunction entries with designated
initializers. The randstruct plugin requires designated initializers for
structures that are entirely function pointers.

Cc: Rex Zhu 
Cc: Hawking Zhang 
Cc: Alex Deucher 
Signed-off-by: Kees Cook 
---
If I can get an Ack for this, I'll carry it in the gcc-plugins tree, unless
you think this is worth landing for v4.13, in which case, please take it
now. :)


Acked-by: Alex Deucher 

I'm happy to take this through my tree if that is ok with you.


I'm wondering a bit how the plugin detects that it can randomize a 
structure layout?


We have a couple of structs where this would be fatal.

Christian.



Alex


Thanks!
---
  drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.c | 8 
  1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.c 
b/drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.c
index 4c7f430b36eb..8e6cfd89c7e0 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.c
@@ -308,8 +308,8 @@ static int rv_tf_set_num_active_display(struct pp_hwmgr 
*hwmgr, void *input,
  }

  static const struct phm_master_table_item rv_set_power_state_list[] = {
-   { NULL, rv_tf_set_clock_limit },
-   { NULL, rv_tf_set_num_active_display },
+   { .tableFunction = rv_tf_set_clock_limit },
+   { .tableFunction = rv_tf_set_num_active_display },
 { }
  };

@@ -382,7 +382,7 @@ static int rv_tf_disable_gfx_off(struct pp_hwmgr *hwmgr,
  }

  static const struct phm_master_table_item rv_disable_dpm_list[] = {
-   {NULL, rv_tf_disable_gfx_off},
+   { .tableFunction = rv_tf_disable_gfx_off },
 { },
  };

@@ -407,7 +407,7 @@ static int rv_tf_enable_gfx_off(struct pp_hwmgr *hwmgr,
  }

  static const struct phm_master_table_item rv_enable_dpm_list[] = {
-   {NULL, rv_tf_enable_gfx_off},
+   { .tableFunction = rv_tf_enable_gfx_off },
 { },
  };

--
2.7.4


--
Kees Cook
Pixel Security
___
amd-gfx mailing list
amd-...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

___
amd-gfx mailing list
amd-...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx





[PATCH 1/1] cpufreq: imx6q: imx6ull: use PLL1 for frequency higher than 528MHz

2017-07-28 Thread Sébastien Szymanski
Setting the frequency higher than 528Mhz actually sets the ARM
clock to 528MHz. That's because PLL2 is used as the root clock when the
frequency is higher than 396MHz.

cpupower frequency-set -f 792000

arm_clk_root on the CCM_CLKO2 signal is 528MHz instead of 792MHz.

[   61.606383] cpu cpu0: 396 MHz, 1025 mV --> 792 MHz, 1225 mV

pll2 1  1  52800 0 0
   pll2_bypass   1  1  52800 0 0
  pll2_bus   3  3  52800 0 0
 ca7_secondary_sel   1  1  52800 0 0
step 1  1  52800 0 0
   pll1_sw   1  1  52800 0 0
  arm1  1  52800 0 0

Fixes this by using the PLL1 as the root clock when the frequency is
higher than 528MHz.

cpupower frequency-set -f 792000

arm_clk_root on the CCM_CLKO2 signal is now 792MHz as expected.

[   69.717987] cpu cpu0: 198 MHz, 950 mV --> 792 MHz, 1225 mV

pll1   1 1 79200 0 0
   pll1_bypass 1 1 79200 0 0
  pll1_sys 1 1 79200 0 0
 pll1_sw   1 1 79200 0 0
arm1 1 79200 0 0

Signed-off-by: Sébastien Szymanski 
---
 drivers/cpufreq/imx6q-cpufreq.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c
index b6edd3c..e5fba50 100644
--- a/drivers/cpufreq/imx6q-cpufreq.c
+++ b/drivers/cpufreq/imx6q-cpufreq.c
@@ -18,6 +18,7 @@
 
 #define PU_SOC_VOLTAGE_NORMAL  125
 #define PU_SOC_VOLTAGE_HIGH1275000
+#define FREQ_528_MHZ   52800
 #define FREQ_1P2_GHZ   12
 
 static struct regulator *arm_reg;
@@ -110,14 +111,20 @@ static int imx6q_set_target(struct cpufreq_policy 
*policy, unsigned int index)
 * voltage of 528MHz, so lower the CPU frequency to one
 * half before changing CPU frequency.
 */
-   clk_set_rate(arm_clk, (old_freq >> 1) * 1000);
-   clk_set_parent(pll1_sw_clk, pll1_sys_clk);
+   if ((old_freq * 1000) <= FREQ_528_MHZ) {
+   clk_set_rate(arm_clk, (old_freq >> 1) * 1000);
+   clk_set_parent(pll1_sw_clk, pll1_sys_clk);
+   }
if (freq_hz > clk_get_rate(pll2_pfd2_396m_clk))
clk_set_parent(secondary_sel_clk, pll2_bus_clk);
else
clk_set_parent(secondary_sel_clk, pll2_pfd2_396m_clk);
clk_set_parent(step_clk, secondary_sel_clk);
clk_set_parent(pll1_sw_clk, step_clk);
+   if (freq_hz > FREQ_528_MHZ) {
+   clk_set_rate(pll1_sys_clk, freq_hz);
+   clk_set_parent(pll1_sw_clk, pll1_sys_clk);
+   }
} else {
clk_set_parent(step_clk, pll2_pfd2_396m_clk);
clk_set_parent(pll1_sw_clk, step_clk);
-- 
2.7.3



[PATCH 1/1] cpufreq: imx6q: imx6ull: use PLL1 for frequency higher than 528MHz

2017-07-28 Thread Sébastien Szymanski
Setting the frequency higher than 528Mhz actually sets the ARM
clock to 528MHz. That's because PLL2 is used as the root clock when the
frequency is higher than 396MHz.

cpupower frequency-set -f 792000

arm_clk_root on the CCM_CLKO2 signal is 528MHz instead of 792MHz.

[   61.606383] cpu cpu0: 396 MHz, 1025 mV --> 792 MHz, 1225 mV

pll2 1  1  52800 0 0
   pll2_bypass   1  1  52800 0 0
  pll2_bus   3  3  52800 0 0
 ca7_secondary_sel   1  1  52800 0 0
step 1  1  52800 0 0
   pll1_sw   1  1  52800 0 0
  arm1  1  52800 0 0

Fixes this by using the PLL1 as the root clock when the frequency is
higher than 528MHz.

cpupower frequency-set -f 792000

arm_clk_root on the CCM_CLKO2 signal is now 792MHz as expected.

[   69.717987] cpu cpu0: 198 MHz, 950 mV --> 792 MHz, 1225 mV

pll1   1 1 79200 0 0
   pll1_bypass 1 1 79200 0 0
  pll1_sys 1 1 79200 0 0
 pll1_sw   1 1 79200 0 0
arm1 1 79200 0 0

Signed-off-by: Sébastien Szymanski 
---
 drivers/cpufreq/imx6q-cpufreq.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c
index b6edd3c..e5fba50 100644
--- a/drivers/cpufreq/imx6q-cpufreq.c
+++ b/drivers/cpufreq/imx6q-cpufreq.c
@@ -18,6 +18,7 @@
 
 #define PU_SOC_VOLTAGE_NORMAL  125
 #define PU_SOC_VOLTAGE_HIGH1275000
+#define FREQ_528_MHZ   52800
 #define FREQ_1P2_GHZ   12
 
 static struct regulator *arm_reg;
@@ -110,14 +111,20 @@ static int imx6q_set_target(struct cpufreq_policy 
*policy, unsigned int index)
 * voltage of 528MHz, so lower the CPU frequency to one
 * half before changing CPU frequency.
 */
-   clk_set_rate(arm_clk, (old_freq >> 1) * 1000);
-   clk_set_parent(pll1_sw_clk, pll1_sys_clk);
+   if ((old_freq * 1000) <= FREQ_528_MHZ) {
+   clk_set_rate(arm_clk, (old_freq >> 1) * 1000);
+   clk_set_parent(pll1_sw_clk, pll1_sys_clk);
+   }
if (freq_hz > clk_get_rate(pll2_pfd2_396m_clk))
clk_set_parent(secondary_sel_clk, pll2_bus_clk);
else
clk_set_parent(secondary_sel_clk, pll2_pfd2_396m_clk);
clk_set_parent(step_clk, secondary_sel_clk);
clk_set_parent(pll1_sw_clk, step_clk);
+   if (freq_hz > FREQ_528_MHZ) {
+   clk_set_rate(pll1_sys_clk, freq_hz);
+   clk_set_parent(pll1_sw_clk, pll1_sys_clk);
+   }
} else {
clk_set_parent(step_clk, pll2_pfd2_396m_clk);
clk_set_parent(pll1_sw_clk, step_clk);
-- 
2.7.3



Re: [PATCH v8 13/13] iommu/amd: Disable iommu only if amd_iommu=off is specified

2017-07-28 Thread Baoquan He
On 07/27/17 at 05:58pm, Joerg Roedel wrote:
> On Fri, Jul 21, 2017 at 04:59:11PM +0800, Baoquan He wrote:
> > From: root 
> 
> You probaly need to reset the author on this one.

Oops, sorry. I made this patch on a testing machine. Will correct it.

Thanks a lot for all these comments and great suggestions.

> 
> > 
> > It's ok to disable iommu in normal kernel. While there's no need
> > to disable it in kdump kernel after the on-flight dma issue has
> > heen fixed.
> > 
> > Signed-off-by: Baoquan He 
> > ---
> >  drivers/iommu/amd_iommu_init.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
> > index 8b4bac978062..880f693c809b 100644
> > --- a/drivers/iommu/amd_iommu_init.c
> > +++ b/drivers/iommu/amd_iommu_init.c
> > @@ -2494,7 +2494,8 @@ static int __init early_amd_iommu_init(void)
> > goto out;
> >  
> > /* Disable any previously enabled IOMMUs */
> > -   disable_iommus();
> > +   if (amd_iommu_disabled)
> > +   disable_iommus();
> >  
> > if (amd_iommu_irq_remap)
> > amd_iommu_irq_remap = check_ioapic_information();
> > -- 
> > 2.5.5


Re: [PATCH v8 13/13] iommu/amd: Disable iommu only if amd_iommu=off is specified

2017-07-28 Thread Baoquan He
On 07/27/17 at 05:58pm, Joerg Roedel wrote:
> On Fri, Jul 21, 2017 at 04:59:11PM +0800, Baoquan He wrote:
> > From: root 
> 
> You probaly need to reset the author on this one.

Oops, sorry. I made this patch on a testing machine. Will correct it.

Thanks a lot for all these comments and great suggestions.

> 
> > 
> > It's ok to disable iommu in normal kernel. While there's no need
> > to disable it in kdump kernel after the on-flight dma issue has
> > heen fixed.
> > 
> > Signed-off-by: Baoquan He 
> > ---
> >  drivers/iommu/amd_iommu_init.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
> > index 8b4bac978062..880f693c809b 100644
> > --- a/drivers/iommu/amd_iommu_init.c
> > +++ b/drivers/iommu/amd_iommu_init.c
> > @@ -2494,7 +2494,8 @@ static int __init early_amd_iommu_init(void)
> > goto out;
> >  
> > /* Disable any previously enabled IOMMUs */
> > -   disable_iommus();
> > +   if (amd_iommu_disabled)
> > +   disable_iommus();
> >  
> > if (amd_iommu_irq_remap)
> > amd_iommu_irq_remap = check_ioapic_information();
> > -- 
> > 2.5.5


Re: [PATCH -tip v5 1/2] irq: Introduce CONFIG_IRQENTRY kconfig

2017-07-28 Thread Masami Hiramatsu
On Fri, 28 Jul 2017 08:36:03 +0200
Ingo Molnar  wrote:

> 
> * Masami Hiramatsu  wrote:
> 
> > Introduce CONFIG_IRQENTRY to simplify generating
> > irqentry and softirqentry text sections.
> > Currently generating those sections depends on
> > CONFIG_FUNCTION_GRAPH_TRACER and/or CONFIG_KASAN, in
> > each source code. This moves those #ifdef dependencies
> > into Kconfig, instead of the actual code. This makes
> > it scalable for other user of irqentry section.
> 
> Please just make it unconditional. That would remove a number of messy 
> #ifdefs, 
> and extra sections/symbols don't have much if any cost.

OK, I'll fix that and resend soon.

Thanks!

> 
> Thanks,
> 
>   Ingo


-- 
Masami Hiramatsu 


Re: [PATCH -tip v5 1/2] irq: Introduce CONFIG_IRQENTRY kconfig

2017-07-28 Thread Masami Hiramatsu
On Fri, 28 Jul 2017 08:36:03 +0200
Ingo Molnar  wrote:

> 
> * Masami Hiramatsu  wrote:
> 
> > Introduce CONFIG_IRQENTRY to simplify generating
> > irqentry and softirqentry text sections.
> > Currently generating those sections depends on
> > CONFIG_FUNCTION_GRAPH_TRACER and/or CONFIG_KASAN, in
> > each source code. This moves those #ifdef dependencies
> > into Kconfig, instead of the actual code. This makes
> > it scalable for other user of irqentry section.
> 
> Please just make it unconditional. That would remove a number of messy 
> #ifdefs, 
> and extra sections/symbols don't have much if any cost.

OK, I'll fix that and resend soon.

Thanks!

> 
> Thanks,
> 
>   Ingo


-- 
Masami Hiramatsu 


Re: [PATCH 0/2] KVM: nVMX: fixes to nested virt interrupt injection

2017-07-28 Thread Wanpeng Li
2017-07-28 16:24 GMT+08:00 Mike Galbraith :
> On Fri, 2017-07-28 at 09:03 +0200, Paolo Bonzini wrote:
>> With these two patches, KVM does not blindly pass the exit interruption
>> info and exit qualification from the vmcs02 and vmcs12 when injecting
>> an exception.  There were two spots where this was done, namely
>> nested_vmx_check_exception and vmx_inject_page_fault_nested.
>>
>> Patch 1 avoids writing the vmcs02's VM_EXIT_INTR_ERROR_CODE field,
>> which as Jim noticed isn't possible on pre-Haswell machines, but
>> otherwise has no semantic effect.
>>
>> Patch 2 is the actual bugfix.
>
> I was looking into oodles of lapic_timer.hv_timer_in_use warnings in
> RT, introduced by KVM: LAPIC: Fix lapic timer injection delay, when I
> noticed this post.  Happily, I can report that they are history.

Yeah, it is fixed in the kvm/queue.
https://git.kernel.org/pub/scm/virt/kvm/kvm.git/commit/?h=queue=1d518c6820daf4e00d29adfba980aee05f605f0f

Regards,
Wanpeng Li


Re: [PATCH 0/2] KVM: nVMX: fixes to nested virt interrupt injection

2017-07-28 Thread Wanpeng Li
2017-07-28 16:24 GMT+08:00 Mike Galbraith :
> On Fri, 2017-07-28 at 09:03 +0200, Paolo Bonzini wrote:
>> With these two patches, KVM does not blindly pass the exit interruption
>> info and exit qualification from the vmcs02 and vmcs12 when injecting
>> an exception.  There were two spots where this was done, namely
>> nested_vmx_check_exception and vmx_inject_page_fault_nested.
>>
>> Patch 1 avoids writing the vmcs02's VM_EXIT_INTR_ERROR_CODE field,
>> which as Jim noticed isn't possible on pre-Haswell machines, but
>> otherwise has no semantic effect.
>>
>> Patch 2 is the actual bugfix.
>
> I was looking into oodles of lapic_timer.hv_timer_in_use warnings in
> RT, introduced by KVM: LAPIC: Fix lapic timer injection delay, when I
> noticed this post.  Happily, I can report that they are history.

Yeah, it is fixed in the kvm/queue.
https://git.kernel.org/pub/scm/virt/kvm/kvm.git/commit/?h=queue=1d518c6820daf4e00d29adfba980aee05f605f0f

Regards,
Wanpeng Li


Re: [PATCH v8 11/13] iommu/amd: Don't copy GCR3 table root pointer

2017-07-28 Thread Baoquan He
On 07/27/17 at 05:57pm, Joerg Roedel wrote:
> On Fri, Jul 21, 2017 at 04:59:09PM +0800, Baoquan He wrote:
> > When iommu is pre_enabled in kdump kernel, if a device is set up with
> > guest translations (DTE.GV=1), then don't copy GCR3 table root pointer
> > but move the device over to an empty guest-cr3 table and handle the
> > faults in the PPR log (which answer them with INVALID). After all these
> > PPR faults are recoverable for the device and we should not allow the
> > device to change old-kernels data when we don't have to.
> 
> Okay, forget my previous comment about disabling IOMMUv2 features while
> copying. Its done in this patch.

Yeah, as you said. Thanks.

> 


Re: [PATCH v8 11/13] iommu/amd: Don't copy GCR3 table root pointer

2017-07-28 Thread Baoquan He
On 07/27/17 at 05:57pm, Joerg Roedel wrote:
> On Fri, Jul 21, 2017 at 04:59:09PM +0800, Baoquan He wrote:
> > When iommu is pre_enabled in kdump kernel, if a device is set up with
> > guest translations (DTE.GV=1), then don't copy GCR3 table root pointer
> > but move the device over to an empty guest-cr3 table and handle the
> > faults in the PPR log (which answer them with INVALID). After all these
> > PPR faults are recoverable for the device and we should not allow the
> > device to change old-kernels data when we don't have to.
> 
> Okay, forget my previous comment about disabling IOMMUv2 features while
> copying. Its done in this patch.

Yeah, as you said. Thanks.

> 


<    8   9   10   11   12   13   14   15   16   >