RE: [PATCH 0/4] arm64: defconfig: Enable PWM and USB for R-Car

2018-02-20 Thread Yoshihiro Shimoda
Hi Simon-san,

> From: Simon Horman, Sent: Friday, February 16, 2018 3:34 AM
> To: Yoshihiro Shimoda 
> Cc: magnus.d...@gmail.com; robh...@kernel.org; mark.rutl...@arm.com; 
> devicet...@vger.kernel.org;
> linux-renesas-soc@vger.kernel.org
> Subject: Re: [PATCH 0/4] arm64: defconfig: Enable PWM and USB for R-Car
> 
> On Wed, Feb 14, 2018 at 03:23:28PM +0900, Yoshihiro Shimoda wrote:
> > This patch set is based on the renesas.git / 
> > renesas-devel-20180213v2-v4.16-rc1
> > tag.
> 
> Hi Shimoda-san,
> 
> these changes look fine to me but I believe that upstream
> prefers such patches to be consolidated. Could you consider
> reposting with these four patches squashed into one?

Sure! I will submit v2 patch soon.

Best regards,
Yoshihiro Shimoda



[PATCH v2] arm64: defconfig: Enable PWM and USB for R-Car

2018-02-20 Thread Yoshihiro Shimoda
Enables PWM controller, USB-DMAC that is used by HS-USB, USB 3.0
peripheral controller and USB 3.0 PHY for R-Car SoCs.

Signed-off-by: Yoshihiro Shimoda 
Acked-by: Geert Uytterhoeven 
---
 Changes from v1:
  - Add Acked-by Geert (thanks!).
  - Consolidate four patches into one.

 arch/arm64/configs/defconfig | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index a850bc5..ceafd26 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -445,6 +445,7 @@ CONFIG_NOP_USB_XCEIV=y
 CONFIG_USB_ULPI=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_RENESAS_USBHS_UDC=m
+CONFIG_USB_RENESAS_USB3=m
 CONFIG_USB_ULPI_BUS=y
 CONFIG_MMC=y
 CONFIG_MMC_BLOCK_MINORS=32
@@ -501,6 +502,7 @@ CONFIG_QCOM_BAM_DMA=y
 CONFIG_QCOM_HIDMA_MGMT=y
 CONFIG_QCOM_HIDMA=y
 CONFIG_RCAR_DMAC=y
+CONFIG_RENESAS_USB_DMAC=m
 CONFIG_VFIO=y
 CONFIG_VFIO_PCI=y
 CONFIG_VIRTIO_PCI=y
@@ -548,10 +550,12 @@ CONFIG_PWM=y
 CONFIG_PWM_BCM2835=m
 CONFIG_PWM_CROS_EC=m
 CONFIG_PWM_MESON=m
+CONFIG_PWM_RCAR=m
 CONFIG_PWM_ROCKCHIP=y
 CONFIG_PWM_SAMSUNG=y
 CONFIG_PWM_TEGRA=m
 CONFIG_PHY_RCAR_GEN3_USB2=y
+CONFIG_PHY_RCAR_GEN3_USB3=m
 CONFIG_PHY_HI6220_USB=y
 CONFIG_PHY_QCOM_USB_HS=y
 CONFIG_PHY_SUN4I_USB=y
-- 
1.9.1



[PATCH v4 03/16] of: dynamic: Add __of_node_dupv()

2018-02-20 Thread Laurent Pinchart
From: Pantelis Antoniou 

Add an __of_node_dupv() private method and make __of_node_dup() use it.
This is required for the subsequent changeset accessors which will
make use of it.

Signed-off-by: Pantelis Antoniou 
Signed-off-by: Laurent Pinchart 
---
 drivers/of/dynamic.c | 29 +++--
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
index 7bb33d22b4e2..4ffd04925fdf 100644
--- a/drivers/of/dynamic.c
+++ b/drivers/of/dynamic.c
@@ -382,8 +382,9 @@ struct property *__of_prop_dup(const struct property *prop, 
gfp_t allocflags)
 }
 
 /**
- * __of_node_dup() - Duplicate or create an empty device node dynamically.
- * @fmt: Format string (plus vargs) for new full name of the device node
+ * __of_node_dupv() - Duplicate or create an empty device node dynamically.
+ * @fmt: Format string for new full name of the device node
+ * @vargs: va_list containing the arugments for the node full name
  *
  * Create an device tree node, either by duplicating an empty node or by 
allocating
  * an empty one suitable for further modification.  The node data are
@@ -391,17 +392,15 @@ struct property *__of_prop_dup(const struct property 
*prop, gfp_t allocflags)
  * OF_DETACHED bits set. Returns the newly allocated node or NULL on out of
  * memory error.
  */
-struct device_node *__of_node_dup(const struct device_node *np, const char 
*fmt, ...)
+struct device_node *__of_node_dupv(const struct device_node *np,
+   const char *fmt, va_list vargs)
 {
-   va_list vargs;
struct device_node *node;
 
node = kzalloc(sizeof(*node), GFP_KERNEL);
if (!node)
return NULL;
-   va_start(vargs, fmt);
node->full_name = kvasprintf(GFP_KERNEL, fmt, vargs);
-   va_end(vargs);
if (!node->full_name) {
kfree(node);
return NULL;
@@ -433,6 +432,24 @@ struct device_node *__of_node_dup(const struct device_node 
*np, const char *fmt,
return NULL;
 }
 
+/**
+ * __of_node_dup() - Duplicate or create an empty device node dynamically.
+ * @fmt: Format string (plus vargs) for new full name of the device node
+ *
+ * See: __of_node_dupv()
+ */
+struct device_node *__of_node_dup(const struct device_node *np,
+   const char *fmt, ...)
+{
+   va_list vargs;
+   struct device_node *node;
+
+   va_start(vargs, fmt);
+   node = __of_node_dupv(np, fmt, vargs);
+   va_end(vargs);
+   return node;
+}
+
 static void __of_changeset_entry_destroy(struct of_changeset_entry *ce)
 {
of_node_put(ce->np);
-- 
Regards,

Laurent Pinchart



[PATCH v4 02/16] dt-bindings: display: renesas: Deprecate LVDS support in the DU bindings

2018-02-20 Thread Laurent Pinchart
The internal LVDS encoders now have their own DT bindings, representing
them as part of the DU is deprecated.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Rob Herring 
---
Changes since v1:

- Remove the LVDS reg range from the example
- Remove the reg-names property
---
 .../devicetree/bindings/display/renesas,du.txt | 31 --
 1 file changed, 11 insertions(+), 20 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/renesas,du.txt 
b/Documentation/devicetree/bindings/display/renesas,du.txt
index cd48aba3bc8c..e79cf9b0ad38 100644
--- a/Documentation/devicetree/bindings/display/renesas,du.txt
+++ b/Documentation/devicetree/bindings/display/renesas,du.txt
@@ -14,12 +14,7 @@ Required Properties:
 - "renesas,du-r8a7795" for R8A7795 (R-Car H3) compatible DU
 - "renesas,du-r8a7796" for R8A7796 (R-Car M3-W) compatible DU
 
-  - reg: A list of base address and length of each memory resource, one for
-each entry in the reg-names property.
-  - reg-names: Name of the memory resources. The DU requires one memory
-resource for the DU core (named "du") and one memory resource for each
-LVDS encoder (named "lvds.x" with "x" being the LVDS controller numerical
-index).
+  - reg: the memory-mapped I/O registers base address and length
 
   - interrupt-parent: phandle of the parent interrupt controller.
   - interrupts: Interrupt specifiers for the DU interrupts.
@@ -29,14 +24,13 @@ Required Properties:
   - clock-names: Name of the clocks. This property is model-dependent.
 - R8A7779 uses a single functional clock. The clock doesn't need to be
   named.
-- All other DU instances use one functional clock per channel and one
-  clock per LVDS encoder (if available). The functional clocks must be
-  named "du.x" with "x" being the channel numerical index. The LVDS clocks
-  must be named "lvds.x" with "x" being the LVDS encoder numerical index.
-- In addition to the functional and encoder clocks, all DU versions also
-  support externally supplied pixel clocks. Those clocks are optional.
-  When supplied they must be named "dclkin.x" with "x" being the input
-  clock numerical index.
+- All other DU instances use one functional clock per channel The
+  functional clocks must be named "du.x" with "x" being the channel
+  numerical index.
+- In addition to the functional clocks, all DU versions also support
+  externally supplied pixel clocks. Those clocks are optional. When
+  supplied they must be named "dclkin.x" with "x" being the input clock
+  numerical index.
 
   - vsps: A list of phandle and channel index tuples to the VSPs that handle
 the memory interfaces for the DU channels. The phandle identifies the VSP
@@ -69,9 +63,7 @@ Example: R8A7795 (R-Car H3) ES2.0 DU
 
du: display@feb0 {
compatible = "renesas,du-r8a7795";
-   reg = <0 0xfeb0 0 0x8>,
- <0 0xfeb9 0 0x14>;
-   reg-names = "du", "lvds.0";
+   reg = <0 0xfeb0 0 0x8>;
interrupts = ,
 ,
 ,
@@ -79,9 +71,8 @@ Example: R8A7795 (R-Car H3) ES2.0 DU
clocks = < CPG_MOD 724>,
 < CPG_MOD 723>,
 < CPG_MOD 722>,
-< CPG_MOD 721>,
-< CPG_MOD 727>;
-   clock-names = "du.0", "du.1", "du.2", "du.3", "lvds.0";
+< CPG_MOD 721>;
+   clock-names = "du.0", "du.1", "du.2", "du.3";
vsps = < 0>, < 0>, < 0>, < 1>;
 
ports {
-- 
Regards,

Laurent Pinchart



[PATCH v4 06/16] of: unittest: changeset helpers

2018-02-20 Thread Laurent Pinchart
From: Pantelis Antoniou 

Add a unitest specific for the new changeset helpers.

Signed-off-by: Pantelis Antoniou 
Signed-off-by: Laurent Pinchart 
---
 drivers/of/unittest.c | 54 +++
 1 file changed, 54 insertions(+)

diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index 7a9abaae874d..1b21d2c549a8 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -609,6 +609,59 @@ static void __init of_unittest_changeset(void)
 #endif
 }
 
+static void __init of_unittest_changeset_helper(void)
+{
+#ifdef CONFIG_OF_DYNAMIC
+   struct device_node *n1, *n2, *n21, *parent, *np;
+   struct of_changeset chgset;
+
+   of_changeset_init();
+
+   parent = of_find_node_by_path("/testcase-data/changeset");
+
+   unittest(parent, "testcase setup failure\n");
+   n1 = of_changeset_create_device_node(,
+   parent, "/testcase-data/changeset/n1");
+   unittest(n1, "testcase setup failure\n");
+   n2 = of_changeset_create_device_node(,
+   parent, "/testcase-data/changeset/n2");
+   unittest(n2, "testcase setup failure\n");
+   n21 = of_changeset_create_device_node(, n2, "%s/%s",
+   "/testcase-data/changeset/n2", "n21");
+   unittest(n21, "testcase setup failure\n");
+
+   unittest(!of_changeset_add_property_string(, parent,
+   "prop-add", "foo"), "fail add prop\n");
+
+   unittest(!of_changeset_attach_node(, n1), "fail n1 attach\n");
+   unittest(!of_changeset_attach_node(, n2), "fail n2 attach\n");
+   unittest(!of_changeset_attach_node(, n21), "fail n21 attach\n");
+
+   unittest(!of_changeset_apply(), "apply failed\n");
+
+   /* Make sure node names are constructed correctly */
+   np = of_find_node_by_path("/testcase-data/changeset/n1");
+   unittest(np, "'%s' not added\n", n1->full_name);
+   of_node_put(np);
+
+   /* Make sure node names are constructed correctly */
+   np = of_find_node_by_path("/testcase-data/changeset/n2");
+   unittest(np, "'%s' not added\n", n2->full_name);
+   of_node_put(np);
+
+   np = of_find_node_by_path("/testcase-data/changeset/n2/n21");
+   unittest(np, "'%s' not added\n", n21->full_name);
+   of_node_put(np);
+
+   unittest(!of_changeset_revert(), "revert failed\n");
+
+   of_changeset_destroy();
+
+   of_node_put(parent);
+#endif
+}
+
+
 static void __init of_unittest_parse_interrupts(void)
 {
struct device_node *np;
@@ -2363,6 +2416,7 @@ static int __init of_unittest(void)
of_unittest_property_string();
of_unittest_property_copy();
of_unittest_changeset();
+   of_unittest_changeset_helper();
of_unittest_parse_interrupts();
of_unittest_parse_interrupts_extended();
of_unittest_match_node();
-- 
Regards,

Laurent Pinchart



[PATCH v4 05/16] of: changeset: Add of_changeset_node_move method

2018-02-20 Thread Laurent Pinchart
From: Pantelis Antoniou 

Adds a changeset helper for moving a subtree to a different place
in the running tree. This is useful in advances cases of dynamic
device tree construction.

Signed-off-by: Pantelis Antoniou 
Signed-off-by: Laurent Pinchart 
---
 drivers/of/dynamic.c | 66 
 include/linux/of.h   |  9 +++
 2 files changed, 75 insertions(+)

diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
index 85e722ed8631..27d9057ef360 100644
--- a/drivers/of/dynamic.c
+++ b/drivers/of/dynamic.c
@@ -1132,3 +1132,69 @@ int __of_changeset_add_update_property_string_list(
return ret;
 }
 EXPORT_SYMBOL_GPL(__of_changeset_add_update_property_string_list);
+
+static struct device_node *
+__of_changeset_node_move_one(struct of_changeset *ocs,
+   struct device_node *np, struct device_node *new_parent)
+{
+   struct device_node *np2;
+   const char *unitname;
+   int err;
+
+   err = of_changeset_detach_node(ocs, np);
+   if (err)
+   return ERR_PTR(err);
+
+   unitname = strrchr(np->full_name, '/');
+   if (!unitname)
+   unitname = np->full_name;
+
+   np2 = __of_node_dup(np, "%s/%s",
+   new_parent->full_name, unitname);
+   if (!np2)
+   return ERR_PTR(-ENOMEM);
+   np2->parent = new_parent;
+
+   err = of_changeset_attach_node(ocs, np2);
+   if (err)
+   return ERR_PTR(err);
+
+   return np2;
+}
+
+/**
+ * of_changeset_node_move_to - Moves a subtree to a new place in
+ * the tree
+ *
+ * @ocs:   changeset pointer
+ * @np:device node pointer to be moved
+ * @to:device node of the new parent
+ *
+ * Moves a subtree to a new place in the tree.
+ * Note that a move is a safe operation because the phandles
+ * remain valid.
+ *
+ * Returns zero on success, a negative error value otherwise.
+ */
+int of_changeset_node_move(struct of_changeset *ocs,
+   struct device_node *np, struct device_node *new_parent)
+{
+   struct device_node *npc, *nppc;
+
+   /* move the root first */
+   nppc = __of_changeset_node_move_one(ocs, np, new_parent);
+   if (IS_ERR(nppc))
+   return PTR_ERR(nppc);
+
+   /* move the subtrees next */
+   for_each_child_of_node(np, npc) {
+   nppc = __of_changeset_node_move_one(ocs, npc, nppc);
+   if (IS_ERR(nppc)) {
+   of_node_put(npc);
+   return PTR_ERR(nppc);
+   }
+   }
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(of_changeset_node_move);
diff --git a/include/linux/of.h b/include/linux/of.h
index 7aef555f9bc2..76197bc75346 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -1328,6 +1328,9 @@ int __of_changeset_add_update_property_string_list(
struct of_changeset *ocs, struct device_node *np,
const char *name, const char **strs, int count, bool update);
 
+int of_changeset_node_move(struct of_changeset *ocs,
+   struct device_node *np, struct device_node *new_parent);
+
 #else /* CONFIG_OF_DYNAMIC */
 static inline int of_reconfig_notifier_register(struct notifier_block *nb)
 {
@@ -1390,6 +1393,12 @@ static inline int 
__of_changeset_add_update_property_string_list(
return -EINVAL;
 }
 
+static inline int of_changeset_node_move(struct of_changeset *ocs,
+   struct device_node *np, struct device_node *new_parent)
+{
+   return -EINVAL;
+}
+
 #endif /* CONFIG_OF_DYNAMIC */
 
 /**
-- 
Regards,

Laurent Pinchart



[PATCH v4 07/16] i2c: demux: Use changeset helpers for clarity

2018-02-20 Thread Laurent Pinchart
From: Pantelis Antoniou 

The changeset helpers are easier to use, use them instead of
using the static property.

Signed-off-by: Pantelis Antoniou 
Acked-by: Wolfram Sang 
["okay" -> "ok"]
Signed-off-by: Laurent Pinchart 
---
 drivers/i2c/muxes/i2c-demux-pinctrl.c | 12 +++-
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/i2c/muxes/i2c-demux-pinctrl.c 
b/drivers/i2c/muxes/i2c-demux-pinctrl.c
index 33ce032cb701..0f0046831492 100644
--- a/drivers/i2c/muxes/i2c-demux-pinctrl.c
+++ b/drivers/i2c/muxes/i2c-demux-pinctrl.c
@@ -220,10 +220,7 @@ static int i2c_demux_pinctrl_probe(struct platform_device 
*pdev)
 
priv = devm_kzalloc(>dev, sizeof(*priv)
   + num_chan * sizeof(struct i2c_demux_pinctrl_chan), 
GFP_KERNEL);
-
-   props = devm_kcalloc(>dev, num_chan, sizeof(*props), GFP_KERNEL);
-
-   if (!priv || !props)
+   if (!priv)
return -ENOMEM;
 
err = of_property_read_string(np, "i2c-bus-name", >bus_name);
@@ -241,12 +238,9 @@ static int i2c_demux_pinctrl_probe(struct platform_device 
*pdev)
}
priv->chan[i].parent_np = adap_np;
 
-   props[i].name = devm_kstrdup(>dev, "status", GFP_KERNEL);
-   props[i].value = devm_kstrdup(>dev, "ok", GFP_KERNEL);
-   props[i].length = 3;
-
of_changeset_init(>chan[i].chgset);
-   of_changeset_update_property(>chan[i].chgset, adap_np, 
[i]);
+   of_changeset_update_property_string(>chan[i].chgset,
+   adap_np, "status", "ok");
}
 
priv->num_chan = num_chan;
-- 
Regards,

Laurent Pinchart



[PATCH v4 04/16] of: changesets: Introduce changeset helper methods

2018-02-20 Thread Laurent Pinchart
From: Pantelis Antoniou 

Changesets are very powerful, but the lack of a helper API
makes using them cumbersome. Introduce a simple copy based
API that makes things considerably easier.

To wit, adding a property using the raw API.

struct property *prop;
prop = kzalloc(sizeof(*prop)), GFP_KERNEL);
prop->name = kstrdup("compatible");
prop->value = kstrdup("foo,bar");
prop->length = strlen(prop->value) + 1;
of_changeset_add_property(ocs, np, prop);

while using the helper API

of_changeset_add_property_string(ocs, np, "compatible",
"foo,bar");

Signed-off-by: Pantelis Antoniou 
[Fixed memory leak in __of_changeset_add_update_property_copy()]
Signed-off-by: Laurent Pinchart 
---
 drivers/of/dynamic.c | 222 ++
 include/linux/of.h   | 328 +++
 2 files changed, 550 insertions(+)

diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
index 4ffd04925fdf..85e722ed8631 100644
--- a/drivers/of/dynamic.c
+++ b/drivers/of/dynamic.c
@@ -910,3 +910,225 @@ int of_changeset_action(struct of_changeset *ocs, 
unsigned long action,
return 0;
 }
 EXPORT_SYMBOL_GPL(of_changeset_action);
+
+/* changeset helpers */
+
+/**
+ * of_changeset_create_device_node - Create an empty device node
+ *
+ * @ocs:   changeset pointer
+ * @parent:parent device node
+ * @fmt:   format string for the node's full_name
+ * @args:  argument list for the format string
+ *
+ * Create an empty device node, marking it as detached and allocated.
+ *
+ * Returns a device node on success, an error encoded pointer otherwise
+ */
+struct device_node *of_changeset_create_device_nodev(
+   struct of_changeset *ocs, struct device_node *parent,
+   const char *fmt, va_list vargs)
+{
+   struct device_node *node;
+
+   node = __of_node_dupv(NULL, fmt, vargs);
+   if (!node)
+   return ERR_PTR(-ENOMEM);
+
+   node->parent = parent;
+   return node;
+}
+EXPORT_SYMBOL_GPL(of_changeset_create_device_nodev);
+
+/**
+ * of_changeset_create_device_node - Create an empty device node
+ *
+ * @ocs:   changeset pointer
+ * @parent:parent device node
+ * @fmt:   Format string for the node's full_name
+ * ... Arguments
+ *
+ * Create an empty device node, marking it as detached and allocated.
+ *
+ * Returns a device node on success, an error encoded pointer otherwise
+ */
+__printf(3, 4) struct device_node *
+of_changeset_create_device_node(struct of_changeset *ocs,
+   struct device_node *parent, const char *fmt, ...)
+{
+   va_list vargs;
+   struct device_node *node;
+
+   va_start(vargs, fmt);
+   node = of_changeset_create_device_nodev(ocs, parent, fmt, vargs);
+   va_end(vargs);
+   return node;
+}
+EXPORT_SYMBOL_GPL(of_changeset_create_device_node);
+
+/**
+ * __of_changeset_add_property_copy - Create/update a new property copying
+ *name & value
+ *
+ * @ocs:   changeset pointer
+ * @np:device node pointer
+ * @name:  name of the property
+ * @value: pointer to the value data
+ * @length:length of the value in bytes
+ * @update:True on update operation
+ *
+ * Adds/updates a property to the changeset by making copies of the name & 
value
+ * entries. The @update parameter controls whether an add or update takes 
place.
+ *
+ * Returns zero on success, a negative error value otherwise.
+ */
+int __of_changeset_add_update_property_copy(struct of_changeset *ocs,
+   struct device_node *np, const char *name, const void *value,
+   int length, bool update)
+{
+   struct property *prop;
+   int ret = -ENOMEM;
+
+   prop = kzalloc(sizeof(*prop), GFP_KERNEL);
+   if (!prop)
+   return -ENOMEM;
+
+   prop->name = kstrdup(name, GFP_KERNEL);
+   if (!prop->name)
+   goto out_err;
+
+   /*
+* NOTE: There is no check for zero length value.
+* In case of a boolean property, this will allocate a value
+* of zero bytes. We do this to work around the use
+* of of_get_property() calls on boolean values.
+*/
+   prop->value = kmemdup(value, length, GFP_KERNEL);
+   if (!prop->value)
+   goto out_err;
+
+   of_property_set_flag(prop, OF_DYNAMIC);
+
+   prop->length = length;
+
+   if (!update)
+   ret = of_changeset_add_property(ocs, np, prop);
+   else
+   ret = of_changeset_update_property(ocs, np, prop);
+
+   if (!ret)
+   return 0;
+
+out_err:
+   kfree(prop->value);
+   kfree(prop->name);
+   kfree(prop);
+   return ret;
+}
+EXPORT_SYMBOL_GPL(__of_changeset_add_update_property_copy);
+
+/**
+ * of_changeset_add_property_stringf 

[PATCH v4 08/16] drm: rcar-du: Fix legacy DT to create LVDS encoder nodes

2018-02-20 Thread Laurent Pinchart
The internal LVDS encoders now have their own DT bindings. Before
switching the driver infrastructure to those new bindings, implement
backward-compatibility through live DT patching.

Patching is disabled and will be enabled along with support for the new
DT bindings in the DU driver.

Signed-off-by: Laurent Pinchart 
---
Changes since v3:

- Use the OF changeset API
- Use of_graph_get_endpoint_by_regs()
- Replace hardcoded constants by sizeof()

Changes since v2:

- Update the SPDX headers to use C-style comments in header files
- Removed the manually created __local_fixups__ node
- Perform manual fixups on live DT instead of overlay

Changes since v1:

- Select OF_FLATTREE
- Compile LVDS DT bindings patch code when DRM_RCAR_LVDS is selected
- Update the SPDX headers to use GPL-2.0 instead of GPL-2.0-only
- Turn __dtb_rcar_du_of_lvds_(begin|end) from u8 to char
- Pass void begin and end pointers to rcar_du_of_get_overlay()
- Use of_get_parent() instead of accessing the parent pointer directly
- Find the LVDS endpoints nodes based on the LVDS node instead of the
  root of the overlay
- Update to the -lvds compatible string format
---
 drivers/gpu/drm/rcar-du/Kconfig|   2 +
 drivers/gpu/drm/rcar-du/Makefile   |   7 +-
 drivers/gpu/drm/rcar-du/rcar_du_of.c   | 307 +
 drivers/gpu/drm/rcar-du/rcar_du_of.h   |  20 ++
 .../gpu/drm/rcar-du/rcar_du_of_lvds_r8a7790.dts|  81 ++
 .../gpu/drm/rcar-du/rcar_du_of_lvds_r8a7791.dts|  55 
 .../gpu/drm/rcar-du/rcar_du_of_lvds_r8a7793.dts|  55 
 .../gpu/drm/rcar-du/rcar_du_of_lvds_r8a7795.dts|  55 
 .../gpu/drm/rcar-du/rcar_du_of_lvds_r8a7796.dts|  55 
 9 files changed, 636 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_of.c
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_of.h
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7790.dts
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7791.dts
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7793.dts
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7795.dts
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7796.dts

diff --git a/drivers/gpu/drm/rcar-du/Kconfig b/drivers/gpu/drm/rcar-du/Kconfig
index 5d0b4b7119af..3f83352a7313 100644
--- a/drivers/gpu/drm/rcar-du/Kconfig
+++ b/drivers/gpu/drm/rcar-du/Kconfig
@@ -22,6 +22,8 @@ config DRM_RCAR_LVDS
bool "R-Car DU LVDS Encoder Support"
depends on DRM_RCAR_DU
select DRM_PANEL
+   select OF_FLATTREE
+   select OF_OVERLAY
help
  Enable support for the R-Car Display Unit embedded LVDS encoders.
 
diff --git a/drivers/gpu/drm/rcar-du/Makefile b/drivers/gpu/drm/rcar-du/Makefile
index 0cf5c11030e8..86b337b4be5d 100644
--- a/drivers/gpu/drm/rcar-du/Makefile
+++ b/drivers/gpu/drm/rcar-du/Makefile
@@ -8,7 +8,12 @@ rcar-du-drm-y := rcar_du_crtc.o \
 rcar_du_plane.o
 
 rcar-du-drm-$(CONFIG_DRM_RCAR_LVDS)+= rcar_du_lvdsenc.o
-
+rcar-du-drm-$(CONFIG_DRM_RCAR_LVDS)+= rcar_du_of.o \
+  rcar_du_of_lvds_r8a7790.dtb.o \
+  rcar_du_of_lvds_r8a7791.dtb.o \
+  rcar_du_of_lvds_r8a7793.dtb.o \
+  rcar_du_of_lvds_r8a7795.dtb.o \
+  rcar_du_of_lvds_r8a7796.dtb.o
 rcar-du-drm-$(CONFIG_DRM_RCAR_VSP) += rcar_du_vsp.o
 
 obj-$(CONFIG_DRM_RCAR_DU)  += rcar-du-drm.o
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_of.c 
b/drivers/gpu/drm/rcar-du/rcar_du_of.c
new file mode 100644
index ..12fae8814309
--- /dev/null
+++ b/drivers/gpu/drm/rcar-du/rcar_du_of.c
@@ -0,0 +1,307 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * rcar_du_of.c - Legacy DT bindings compatibility
+ *
+ * Copyright (C) 2018 Laurent Pinchart 
+ *
+ * Based on work from Jyri Sarha 
+ * Copyright (C) 2015 Texas Instruments
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "rcar_du_crtc.h"
+#include "rcar_du_drv.h"
+
+/* 
-
+ * Generic Overlay Handling
+ */
+
+struct rcar_du_of_overlay {
+   const char *compatible;
+   void *begin;
+   void *end;
+};
+
+#define RCAR_DU_OF_DTB(type, soc)  \
+   extern char __dtb_rcar_du_of_##type##_##soc##_begin[];  \
+   extern char __dtb_rcar_du_of_##type##_##soc##_end[]
+
+#define RCAR_DU_OF_OVERLAY(type, soc)  \
+   {   \
+   .compatible = "renesas,du-" #soc,   \
+   .begin = 

[PATCH v4 09/16] drm: rcar-du: Convert LVDS encoder code to bridge driver

2018-02-20 Thread Laurent Pinchart
The LVDS encoders used to be described in DT as part of the DU. They now
have their own DT node, linked to the DU using the OF graph bindings.
This allows moving internal LVDS encoder support to a separate driver
modelled as a DRM bridge. Backward compatibility is retained as legacy
DT is patched live to move to the new bindings.

Signed-off-by: Laurent Pinchart 
---
Changes since v1:

- Update the SPDX headers to use GPL-2.0 instead of GPL-2.0-only
- Update to the -lvds compatible string format
---
 drivers/gpu/drm/rcar-du/Kconfig   |   4 +-
 drivers/gpu/drm/rcar-du/Makefile  |   3 +-
 drivers/gpu/drm/rcar-du/rcar_du_drv.c |  21 +-
 drivers/gpu/drm/rcar-du/rcar_du_drv.h |   5 -
 drivers/gpu/drm/rcar-du/rcar_du_encoder.c | 175 +-
 drivers/gpu/drm/rcar-du/rcar_du_encoder.h |  12 -
 drivers/gpu/drm/rcar-du/rcar_du_kms.c |  14 +-
 drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c |  93 --
 drivers/gpu/drm/rcar-du/rcar_du_lvdscon.h |  24 --
 drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c | 238 --
 drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.h |  64 
 drivers/gpu/drm/rcar-du/rcar_lvds.c   | 524 ++
 12 files changed, 561 insertions(+), 616 deletions(-)
 delete mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c
 delete mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvdscon.h
 delete mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c
 delete mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.h
 create mode 100644 drivers/gpu/drm/rcar-du/rcar_lvds.c

diff --git a/drivers/gpu/drm/rcar-du/Kconfig b/drivers/gpu/drm/rcar-du/Kconfig
index 3f83352a7313..edde8d4b87a3 100644
--- a/drivers/gpu/drm/rcar-du/Kconfig
+++ b/drivers/gpu/drm/rcar-du/Kconfig
@@ -19,8 +19,8 @@ config DRM_RCAR_DW_HDMI
  Enable support for R-Car Gen3 internal HDMI encoder.
 
 config DRM_RCAR_LVDS
-   bool "R-Car DU LVDS Encoder Support"
-   depends on DRM_RCAR_DU
+   tristate "R-Car DU LVDS Encoder Support"
+   depends on DRM && DRM_BRIDGE && OF
select DRM_PANEL
select OF_FLATTREE
select OF_OVERLAY
diff --git a/drivers/gpu/drm/rcar-du/Makefile b/drivers/gpu/drm/rcar-du/Makefile
index 86b337b4be5d..3e58ed93d5b1 100644
--- a/drivers/gpu/drm/rcar-du/Makefile
+++ b/drivers/gpu/drm/rcar-du/Makefile
@@ -4,10 +4,8 @@ rcar-du-drm-y := rcar_du_crtc.o \
 rcar_du_encoder.o \
 rcar_du_group.o \
 rcar_du_kms.o \
-rcar_du_lvdscon.o \
 rcar_du_plane.o
 
-rcar-du-drm-$(CONFIG_DRM_RCAR_LVDS)+= rcar_du_lvdsenc.o
 rcar-du-drm-$(CONFIG_DRM_RCAR_LVDS)+= rcar_du_of.o \
   rcar_du_of_lvds_r8a7790.dtb.o \
   rcar_du_of_lvds_r8a7791.dtb.o \
@@ -18,3 +16,4 @@ rcar-du-drm-$(CONFIG_DRM_RCAR_VSP)+= rcar_du_vsp.o
 
 obj-$(CONFIG_DRM_RCAR_DU)  += rcar-du-drm.o
 obj-$(CONFIG_DRM_RCAR_DW_HDMI) += rcar_dw_hdmi.o
+obj-$(CONFIG_DRM_RCAR_LVDS)+= rcar_lvds.o
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index 6e02c762a557..06a3fbdd728a 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -29,6 +29,7 @@
 
 #include "rcar_du_drv.h"
 #include "rcar_du_kms.h"
+#include "rcar_du_of.h"
 #include "rcar_du_regs.h"
 
 /* 
-
@@ -74,7 +75,6 @@ static const struct rcar_du_device_info rzg1_du_r8a7745_info 
= {
.port = 1,
},
},
-   .num_lvds = 0,
 };
 
 static const struct rcar_du_device_info rcar_du_r8a7779_info = {
@@ -95,14 +95,13 @@ static const struct rcar_du_device_info 
rcar_du_r8a7779_info = {
.port = 1,
},
},
-   .num_lvds = 0,
 };
 
 static const struct rcar_du_device_info rcar_du_r8a7790_info = {
.gen = 2,
.features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK
  | RCAR_DU_FEATURE_EXT_CTRL_REGS,
-   .quirks = RCAR_DU_QUIRK_ALIGN_128B | RCAR_DU_QUIRK_LVDS_LANES,
+   .quirks = RCAR_DU_QUIRK_ALIGN_128B,
.num_crtcs = 3,
.routes = {
/*
@@ -164,7 +163,6 @@ static const struct rcar_du_device_info 
rcar_du_r8a7792_info = {
.port = 1,
},
},
-   .num_lvds = 0,
 };
 
 static const struct rcar_du_device_info rcar_du_r8a7794_info = {
@@ -186,7 +184,6 @@ static const struct rcar_du_device_info 
rcar_du_r8a7794_info = {
.port = 1,
},
},
-   .num_lvds = 0,
 };
 
 static const struct rcar_du_device_info rcar_du_r8a7795_info = {
@@ -434,7 +431,19 @@ static struct platform_driver rcar_du_platform_driver = {
},
 };
 
-module_platform_driver(rcar_du_platform_driver);
+static int __init rcar_du_init(void)
+{
+   

[PATCH v4 10/16] ARM: dts: r8a7790: Convert to new LVDS DT bindings

2018-02-20 Thread Laurent Pinchart
The internal LVDS encoder now has DT bindings separate from the DU. Port
the device tree over to the new model.

Signed-off-by: Laurent Pinchart 
---
Changes since v3:

- Added power-domains and resets properties to LVDS nodes

Changes since v2:

- Fixed LVDS compatible string

Changes since v1:

- Remove the DU reg-names property
---
 arch/arm/boot/dts/r8a7790-lager.dts | 22 ++---
 arch/arm/boot/dts/r8a7790.dtsi  | 64 +
 2 files changed, 74 insertions(+), 12 deletions(-)

diff --git a/arch/arm/boot/dts/r8a7790-lager.dts 
b/arch/arm/boot/dts/r8a7790-lager.dts
index 169da676c4ba..b51ee84309bf 100644
--- a/arch/arm/boot/dts/r8a7790-lager.dts
+++ b/arch/arm/boot/dts/r8a7790-lager.dts
@@ -316,10 +316,8 @@
status = "okay";
 
clocks = < CPG_MOD 724>, < CPG_MOD 723>, < CPG_MOD 722>,
-< CPG_MOD 726>, < CPG_MOD 725>,
 <_clk>, <_clk>;
-   clock-names = "du.0", "du.1", "du.2", "lvds.0", "lvds.1",
- "dclkin.0", "dclkin.1";
+   clock-names = "du.0", "du.1", "du.2", "dclkin.0", "dclkin.1";
 
ports {
port@0 {
@@ -327,12 +325,26 @@
remote-endpoint = <_in>;
};
};
+   };
+};
+
+ {
+   status = "okay";
+
+   ports {
port@1 {
endpoint {
remote-endpoint = <_in>;
};
};
-   port@2 {
+   };
+};
+
+ {
+   status = "okay";
+
+   ports {
+   port@1 {
lvds_connector: endpoint {
};
};
@@ -688,7 +700,7 @@
port@0 {
reg = <0>;
adv7511_in: endpoint {
-   remote-endpoint = <_out_lvds0>;
+   remote-endpoint = <_out>;
};
};
 
diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi
index ed9a68538a55..e688dd831e4e 100644
--- a/arch/arm/boot/dts/r8a7790.dtsi
+++ b/arch/arm/boot/dts/r8a7790.dtsi
@@ -1068,17 +1068,13 @@
 
du: display@feb0 {
compatible = "renesas,du-r8a7790";
-   reg = <0 0xfeb0 0 0x7>,
- <0 0xfeb9 0 0x1c>,
- <0 0xfeb94000 0 0x1c>;
-   reg-names = "du", "lvds.0", "lvds.1";
+   reg = <0 0xfeb0 0 0x7>;
interrupts = ,
 ,
 ;
clocks = < CPG_MOD 724>, < CPG_MOD 723>,
-< CPG_MOD 722>, < CPG_MOD 726>,
-< CPG_MOD 725>;
-   clock-names = "du.0", "du.1", "du.2", "lvds.0", "lvds.1";
+< CPG_MOD 722>;
+   clock-names = "du.0", "du.1", "du.2";
status = "disabled";
 
ports {
@@ -1093,11 +1089,65 @@
port@1 {
reg = <1>;
du_out_lvds0: endpoint {
+   remote-endpoint = <_in>;
};
};
port@2 {
reg = <2>;
du_out_lvds1: endpoint {
+   remote-endpoint = <_in>;
+   };
+   };
+   };
+   };
+
+   lvds0: lvds@feb9 {
+   compatible = "renesas,r8a7790-lvds";
+   reg = <0 0xfeb9 0 0x1c>;
+   clocks = < CPG_MOD 726>;
+   power-domains = < R8A7790_PD_ALWAYS_ON>;
+   resets = < 726>;
+   status = "disabled";
+
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port@0 {
+   reg = <0>;
+   lvds0_in: endpoint {
+   remote-endpoint = <_out_lvds0>;
+   };
+   };
+   port@1 {
+   reg = <1>;
+   lvds0_out: endpoint {
+   };
+   };
+   };
+   };
+
+   lvds1: lvds@feb94000 {
+   compatible = "renesas,r8a7790-lvds";
+   reg = <0 0xfeb94000 0 0x1c>;
+   clocks = < CPG_MOD 725>;
+   power-domains = < R8A7790_PD_ALWAYS_ON>;
+   resets = < 725>;
+   status = "disabled";
+
+   ports {
+   #address-cells = <1>;
+

[PATCH v4 14/16] ARM: dts: r8a7794: Convert to new DU DT bindings

2018-02-20 Thread Laurent Pinchart
The DU DT bindings have been updated to drop the reg-names property.
Update the r8a7792 device tree accordingly.

Signed-off-by: Laurent Pinchart 
---
 arch/arm/boot/dts/r8a7794.dtsi | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/arm/boot/dts/r8a7794.dtsi b/arch/arm/boot/dts/r8a7794.dtsi
index 106b4e1649ff..7d9da744a01d 100644
--- a/arch/arm/boot/dts/r8a7794.dtsi
+++ b/arch/arm/boot/dts/r8a7794.dtsi
@@ -999,7 +999,6 @@
du: display@feb0 {
compatible = "renesas,du-r8a7794";
reg = <0 0xfeb0 0 0x4>;
-   reg-names = "du";
interrupts = ,
 ;
clocks = < CPG_MOD 724>, < CPG_MOD 723>;
-- 
Regards,

Laurent Pinchart



[PATCH v4 16/16] arm64: dts: renesas: r8a7796: Convert to new LVDS DT bindings

2018-02-20 Thread Laurent Pinchart
The internal LVDS encoder now has DT bindings separate from the DU. Port
the device tree over to the new model.

Signed-off-by: Laurent Pinchart 
---
Changes since v3:

- Added power-domains and resets properties to LVDS nodes
- Dropped bogus changes from the rcar-du driver

Changes since v2:

- Fixed LVDS compatible string

Changes since v1:

- Remove the DU reg-names property
---
 arch/arm64/boot/dts/renesas/r8a7796-m3ulcb.dts |  3 +-
 arch/arm64/boot/dts/renesas/r8a7796-salvator-x.dts |  3 +-
 arch/arm64/boot/dts/renesas/r8a7796.dtsi   | 36 ++
 3 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/arch/arm64/boot/dts/renesas/r8a7796-m3ulcb.dts 
b/arch/arm64/boot/dts/renesas/r8a7796-m3ulcb.dts
index daee1f1a3f68..21bd679062f3 100644
--- a/arch/arm64/boot/dts/renesas/r8a7796-m3ulcb.dts
+++ b/arch/arm64/boot/dts/renesas/r8a7796-m3ulcb.dts
@@ -33,10 +33,9 @@
clocks = < CPG_MOD 724>,
 < CPG_MOD 723>,
 < CPG_MOD 722>,
-< CPG_MOD 727>,
 < 1>,
 < 3>,
 < 2>;
-   clock-names = "du.0", "du.1", "du.2", "lvds.0",
+   clock-names = "du.0", "du.1", "du.2",
  "dclkin.0", "dclkin.1", "dclkin.2";
 };
diff --git a/arch/arm64/boot/dts/renesas/r8a7796-salvator-x.dts 
b/arch/arm64/boot/dts/renesas/r8a7796-salvator-x.dts
index 2ba992946c50..9524fcb6bc5c 100644
--- a/arch/arm64/boot/dts/renesas/r8a7796-salvator-x.dts
+++ b/arch/arm64/boot/dts/renesas/r8a7796-salvator-x.dts
@@ -32,11 +32,10 @@
clocks = < CPG_MOD 724>,
 < CPG_MOD 723>,
 < CPG_MOD 722>,
-< CPG_MOD 727>,
 < 1>,
 <_clk>,
 < 2>;
-   clock-names = "du.0", "du.1", "du.2", "lvds.0",
+   clock-names = "du.0", "du.1", "du.2",
  "dclkin.0", "dclkin.1", "dclkin.2";
 };
 
diff --git a/arch/arm64/boot/dts/renesas/r8a7796.dtsi 
b/arch/arm64/boot/dts/renesas/r8a7796.dtsi
index c5192d513d7d..c1506c5e27b1 100644
--- a/arch/arm64/boot/dts/renesas/r8a7796.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a7796.dtsi
@@ -1924,17 +1924,14 @@
 
du: display@feb0 {
compatible = "renesas,du-r8a7796";
-   reg = <0 0xfeb0 0 0x7>,
- <0 0xfeb9 0 0x14>;
-   reg-names = "du", "lvds.0";
+   reg = <0 0xfeb0 0 0x7>;
interrupts = ,
 ,
 ;
clocks = < CPG_MOD 724>,
 < CPG_MOD 723>,
-< CPG_MOD 722>,
-< CPG_MOD 727>;
-   clock-names = "du.0", "du.1", "du.2", "lvds.0";
+< CPG_MOD 722>;
+   clock-names = "du.0", "du.1", "du.2";
status = "disabled";
 
vsps = <  >;
@@ -1957,6 +1954,33 @@
port@2 {
reg = <2>;
du_out_lvds0: endpoint {
+   remote-endpoint = <_in>;
+   };
+   };
+   };
+   };
+
+   lvds0: lvds@feb9 {
+   compatible = "renesas,r8a7796-lvds";
+   reg = <0 0xfeb9 0 0x14>;
+   clocks = < CPG_MOD 727>;
+   power-domains = < R8A7796_PD_ALWAYS_ON>;
+   resets = < 727>;
+   status = "disabled";
+
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port@0 {
+   reg = <0>;
+   lvds0_in: endpoint {
+   remote-endpoint = 
<_out_lvds0>;
+   };
+   };
+   port@1 {
+   reg = <1>;
+   lvds0_out: endpoint {
};
};
};
-- 
Regards,

Laurent Pinchart



[PATCH v4 11/16] ARM: dts: r8a7791: Convert to new LVDS DT bindings

2018-02-20 Thread Laurent Pinchart
The internal LVDS encoder now has DT bindings separate from the DU. Port
the device tree over to the new model.

Signed-off-by: Laurent Pinchart 
---
Changes since v3:

- Added power-domains and resets properties to LVDS nodes

Changes since v2:

- Fixed LVDS compatible string

Changes since v1:

- Remove the DU reg-names property
---
 arch/arm/boot/dts/r8a7791-koelsch.dts | 10 --
 arch/arm/boot/dts/r8a7791-porter.dts  | 16 +---
 arch/arm/boot/dts/r8a7791.dtsi| 36 +--
 3 files changed, 51 insertions(+), 11 deletions(-)

diff --git a/arch/arm/boot/dts/r8a7791-koelsch.dts 
b/arch/arm/boot/dts/r8a7791-koelsch.dts
index a50924d12b6f..c42ff25e3aa3 100644
--- a/arch/arm/boot/dts/r8a7791-koelsch.dts
+++ b/arch/arm/boot/dts/r8a7791-koelsch.dts
@@ -337,8 +337,7 @@
 
clocks = < CPG_MOD 724>, < CPG_MOD 723>, < CPG_MOD 726>,
 <_clk>, <_clk>;
-   clock-names = "du.0", "du.1", "lvds.0",
- "dclkin.0", "dclkin.1";
+   clock-names = "du.0", "du.1", "dclkin.0", "dclkin.1";
 
ports {
port@0 {
@@ -346,6 +345,13 @@
remote-endpoint = <_in>;
};
};
+   };
+};
+
+ {
+   status = "okay";
+
+   ports {
port@1 {
lvds_connector: endpoint {
};
diff --git a/arch/arm/boot/dts/r8a7791-porter.dts 
b/arch/arm/boot/dts/r8a7791-porter.dts
index 9a02d03b23c2..e6d02839d636 100644
--- a/arch/arm/boot/dts/r8a7791-porter.dts
+++ b/arch/arm/boot/dts/r8a7791-porter.dts
@@ -419,10 +419,9 @@
pinctrl-names = "default";
status = "okay";
 
-   clocks = < CPG_MOD 724>, < CPG_MOD 723>, < CPG_MOD 726>,
+   clocks = < CPG_MOD 724>, < CPG_MOD 723>,
 <_clk>, <_clk>;
-   clock-names = "du.0", "du.1", "lvds.0",
- "dclkin.0", "dclkin.1";
+   clock-names = "du.0", "du.1", "dclkin.0", "dclkin.1";
 
ports {
port@0 {
@@ -433,6 +432,17 @@
};
 };
 
+ {
+   status = "okay";
+
+   ports {
+   port@1 {
+   lvds_connector: endpoint {
+   };
+   };
+   };
+};
+
 _sound {
pinctrl-0 = <_pins _clk_pins>;
pinctrl-names = "default";
diff --git a/arch/arm/boot/dts/r8a7791.dtsi b/arch/arm/boot/dts/r8a7791.dtsi
index 008a260f86a5..8660f8a329c7 100644
--- a/arch/arm/boot/dts/r8a7791.dtsi
+++ b/arch/arm/boot/dts/r8a7791.dtsi
@@ -1103,15 +1103,12 @@
 
du: display@feb0 {
compatible = "renesas,du-r8a7791";
-   reg = <0 0xfeb0 0 0x4>,
- <0 0xfeb9 0 0x1c>;
-   reg-names = "du", "lvds.0";
+   reg = <0 0xfeb0 0 0x4>;
interrupts = ,
 ;
clocks = < CPG_MOD 724>,
-< CPG_MOD 723>,
-< CPG_MOD 726>;
-   clock-names = "du.0", "du.1", "lvds.0";
+< CPG_MOD 723>;
+   clock-names = "du.0", "du.1";
status = "disabled";
 
ports {
@@ -1126,6 +1123,33 @@
port@1 {
reg = <1>;
du_out_lvds0: endpoint {
+   remote-endpoint = <_in>;
+   };
+   };
+   };
+   };
+
+   lvds0: lvds@feb9 {
+   compatible = "renesas,r8a7791-lvds";
+   reg = <0 0xfeb9 0 0x1c>;
+   clocks = < CPG_MOD 726>;
+   power-domains = < R8A7791_PD_ALWAYS_ON>;
+   resets = < 726>;
+   status = "disabled";
+
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port@0 {
+   reg = <0>;
+   lvds0_in: endpoint {
+   remote-endpoint = <_out_lvds0>;
+   };
+   };
+   port@1 {
+   reg = <1>;
+   lvds0_out: endpoint {
};
};
};
-- 
Regards,

Laurent Pinchart



[PATCH v4 12/16] ARM: dts: r8a7792: Convert to new DU DT bindings

2018-02-20 Thread Laurent Pinchart
The DU DT bindings have been updated to drop the reg-names property.
Update the r8a7792 device tree accordingly.

Signed-off-by: Laurent Pinchart 
---
 arch/arm/boot/dts/r8a7792.dtsi | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/arm/boot/dts/r8a7792.dtsi b/arch/arm/boot/dts/r8a7792.dtsi
index 3be15a158bad..c4a36a18f505 100644
--- a/arch/arm/boot/dts/r8a7792.dtsi
+++ b/arch/arm/boot/dts/r8a7792.dtsi
@@ -691,7 +691,6 @@
du: display@feb0 {
compatible = "renesas,du-r8a7792";
reg = <0 0xfeb0 0 0x4>;
-   reg-names = "du";
interrupts = ,
 ;
clocks = < CPG_MOD 724>,
-- 
Regards,

Laurent Pinchart



[PATCH v4 13/16] ARM: dts: r8a7793: Convert to new LVDS DT bindings

2018-02-20 Thread Laurent Pinchart
The internal LVDS encoder now has DT bindings separate from the DU. Port
the device tree over to the new model.

Signed-off-by: Laurent Pinchart 
---
Changes since v3:

- Added power-domains and resets properties to LVDS nodes

Changes since v2:

- Fixed LVDS compatible string

Changes since v1:

- Remove the DU reg-names property
---
 arch/arm/boot/dts/r8a7793-gose.dts | 10 +++---
 arch/arm/boot/dts/r8a7793.dtsi | 37 +++--
 2 files changed, 38 insertions(+), 9 deletions(-)

diff --git a/arch/arm/boot/dts/r8a7793-gose.dts 
b/arch/arm/boot/dts/r8a7793-gose.dts
index 51b3ffac8efa..c6121f9b72a8 100644
--- a/arch/arm/boot/dts/r8a7793-gose.dts
+++ b/arch/arm/boot/dts/r8a7793-gose.dts
@@ -303,10 +303,9 @@
pinctrl-names = "default";
status = "okay";
 
-   clocks = < CPG_MOD 724>, < CPG_MOD 723>, < CPG_MOD 726>,
+   clocks = < CPG_MOD 724>, < CPG_MOD 723>,
 <_clk>, <_clk>;
-   clock-names = "du.0", "du.1", "lvds.0",
- "dclkin.0", "dclkin.1";
+   clock-names = "du.0", "du.1", "dclkin.0", "dclkin.1";
 
ports {
port@0 {
@@ -314,6 +313,11 @@
remote-endpoint = <_in>;
};
};
+   };
+};
+
+ {
+   ports {
port@1 {
lvds_connector: endpoint {
};
diff --git a/arch/arm/boot/dts/r8a7793.dtsi b/arch/arm/boot/dts/r8a7793.dtsi
index 039b22517526..d3dc3e4a694b 100644
--- a/arch/arm/boot/dts/r8a7793.dtsi
+++ b/arch/arm/boot/dts/r8a7793.dtsi
@@ -976,15 +976,12 @@
 
du: display@feb0 {
compatible = "renesas,du-r8a7793";
-   reg = <0 0xfeb0 0 0x4>,
- <0 0xfeb9 0 0x1c>;
-   reg-names = "du", "lvds.0";
+   reg = <0 0xfeb0 0 0x4>;
interrupts = ,
 ;
clocks = < CPG_MOD 724>,
-< CPG_MOD 723>,
-< CPG_MOD 726>;
-   clock-names = "du.0", "du.1", "lvds.0";
+< CPG_MOD 723>;
+   clock-names = "du.0", "du.1";
status = "disabled";
 
ports {
@@ -999,6 +996,34 @@
port@1 {
reg = <1>;
du_out_lvds0: endpoint {
+   remote-endpoint = <_in>;
+   };
+   };
+   };
+   };
+
+   lvds0: lvds@feb9 {
+   compatible = "renesas,r8a7793-lvds";
+   reg = <0 0xfeb9 0 0x1c>;
+   clocks = < CPG_MOD 726>;
+   power-domains = < R8A7793_PD_ALWAYS_ON>;
+   resets = < 726>;
+
+   status = "disabled";
+
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port@0 {
+   reg = <0>;
+   lvds0_in: endpoint {
+   remote-endpoint = <_out_lvds0>;
+   };
+   };
+   port@1 {
+   reg = <1>;
+   lvds0_out: endpoint {
};
};
};
-- 
Regards,

Laurent Pinchart



[PATCH v4 15/16] arm64: dts: renesas: r8a7795: Convert to new LVDS DT bindings

2018-02-20 Thread Laurent Pinchart
The internal LVDS encoder now has DT bindings separate from the DU. Port
the device tree over to the new model.

Signed-off-by: Laurent Pinchart 
---
Changes since v3:

- Added power-domains and resets properties to LVDS nodes

Changes since v2:

- Fixed LVDS compatible string

Changes since v1:

- Remove the DU reg-names property
---
 .../boot/dts/renesas/r8a7795-es1-salvator-x.dts|  3 +-
 arch/arm64/boot/dts/renesas/r8a7795-h3ulcb.dts |  3 +-
 arch/arm64/boot/dts/renesas/r8a7795-salvator-x.dts |  3 +-
 .../arm64/boot/dts/renesas/r8a7795-salvator-xs.dts |  3 +-
 arch/arm64/boot/dts/renesas/r8a7795.dtsi   | 36 ++
 5 files changed, 34 insertions(+), 14 deletions(-)

diff --git a/arch/arm64/boot/dts/renesas/r8a7795-es1-salvator-x.dts 
b/arch/arm64/boot/dts/renesas/r8a7795-es1-salvator-x.dts
index 4af9504489ee..c0faef1be32d 100644
--- a/arch/arm64/boot/dts/renesas/r8a7795-es1-salvator-x.dts
+++ b/arch/arm64/boot/dts/renesas/r8a7795-es1-salvator-x.dts
@@ -43,12 +43,11 @@
 < CPG_MOD 723>,
 < CPG_MOD 722>,
 < CPG_MOD 721>,
-< CPG_MOD 727>,
 < 1>,
 <_clk>,
 <_clk>,
 < 2>;
-   clock-names = "du.0", "du.1", "du.2", "du.3", "lvds.0",
+   clock-names = "du.0", "du.1", "du.2", "du.3",
  "dclkin.0", "dclkin.1", "dclkin.2", "dclkin.3";
 };
 
diff --git a/arch/arm64/boot/dts/renesas/r8a7795-h3ulcb.dts 
b/arch/arm64/boot/dts/renesas/r8a7795-h3ulcb.dts
index 0afe777973de..f0d6528c05eb 100644
--- a/arch/arm64/boot/dts/renesas/r8a7795-h3ulcb.dts
+++ b/arch/arm64/boot/dts/renesas/r8a7795-h3ulcb.dts
@@ -44,11 +44,10 @@
 < CPG_MOD 723>,
 < CPG_MOD 722>,
 < CPG_MOD 721>,
-< CPG_MOD 727>,
 < 1>,
 < 3>,
 < 4>,
 < 2>;
-   clock-names = "du.0", "du.1", "du.2", "du.3", "lvds.0",
+   clock-names = "du.0", "du.1", "du.2", "du.3",
  "dclkin.0", "dclkin.1", "dclkin.2", "dclkin.3";
 };
diff --git a/arch/arm64/boot/dts/renesas/r8a7795-salvator-x.dts 
b/arch/arm64/boot/dts/renesas/r8a7795-salvator-x.dts
index cd9587ef90f4..eb2a9f3e4f28 100644
--- a/arch/arm64/boot/dts/renesas/r8a7795-salvator-x.dts
+++ b/arch/arm64/boot/dts/renesas/r8a7795-salvator-x.dts
@@ -43,12 +43,11 @@
 < CPG_MOD 723>,
 < CPG_MOD 722>,
 < CPG_MOD 721>,
-< CPG_MOD 727>,
 < 1>,
 <_clk>,
 <_clk>,
 < 2>;
-   clock-names = "du.0", "du.1", "du.2", "du.3", "lvds.0",
+   clock-names = "du.0", "du.1", "du.2", "du.3",
  "dclkin.0", "dclkin.1", "dclkin.2", "dclkin.3";
 };
 
diff --git a/arch/arm64/boot/dts/renesas/r8a7795-salvator-xs.dts 
b/arch/arm64/boot/dts/renesas/r8a7795-salvator-xs.dts
index 15617e30356a..db3afa438543 100644
--- a/arch/arm64/boot/dts/renesas/r8a7795-salvator-xs.dts
+++ b/arch/arm64/boot/dts/renesas/r8a7795-salvator-xs.dts
@@ -43,12 +43,11 @@
 < CPG_MOD 723>,
 < CPG_MOD 722>,
 < CPG_MOD 721>,
-< CPG_MOD 727>,
 < 1>,
 <_clk>,
 <_clk>,
 < 2>;
-   clock-names = "du.0", "du.1", "du.2", "du.3", "lvds.0",
+   clock-names = "du.0", "du.1", "du.2", "du.3",
  "dclkin.0", "dclkin.1", "dclkin.2", "dclkin.3";
 };
 
diff --git a/arch/arm64/boot/dts/renesas/r8a7795.dtsi 
b/arch/arm64/boot/dts/renesas/r8a7795.dtsi
index d12df6f2ff09..86ac1e4d3b5e 100644
--- a/arch/arm64/boot/dts/renesas/r8a7795.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a7795.dtsi
@@ -2273,9 +2273,7 @@
 
du: display@feb0 {
compatible = "renesas,du-r8a7795";
-   reg = <0 0xfeb0 0 0x8>,
- <0 0xfeb9 0 0x14>;
-   reg-names = "du", "lvds.0";
+   reg = <0 0xfeb0 0 0x8>;
interrupts = ,
 ,
 ,
@@ -2283,9 +2281,8 @@
clocks = < CPG_MOD 724>,
 < CPG_MOD 723>,
 < CPG_MOD 722>,
-< CPG_MOD 721>,
-< CPG_MOD 727>;
-   clock-names = "du.0", "du.1", "du.2", "du.3", "lvds.0";
+< CPG_MOD 721>;
+   clock-names = "du.0", "du.1", "du.2", "du.3";
vsps = < 0  0  0  1>;
status = "disabled";
 
@@ -2313,6 +2310,33 @@
port@3 {
reg = <3>;
  

[PATCH v4 01/16] dt-bindings: display: renesas: Add R-Car LVDS encoder DT bindings

2018-02-20 Thread Laurent Pinchart
The Renesas R-Car Gen2 and Gen3 SoCs have internal LVDS encoders. Add
corresponding device tree bindings.

Signed-off-by: Laurent Pinchart 
Reviewed-by: Rob Herring 
---
Changes since v1:

- Move the SoC name before the IP name in compatible strings
- Rename parallel input to parallel RGB input
- Fixed "renesas,r8a7743-lvds" description
- Document the resets property
- Fixed typo
---
 .../bindings/display/bridge/renesas,lvds.txt   | 56 ++
 MAINTAINERS|  1 +
 2 files changed, 57 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/bridge/renesas,lvds.txt

diff --git a/Documentation/devicetree/bindings/display/bridge/renesas,lvds.txt 
b/Documentation/devicetree/bindings/display/bridge/renesas,lvds.txt
new file mode 100644
index ..2b19ce51ec07
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/bridge/renesas,lvds.txt
@@ -0,0 +1,56 @@
+Renesas R-Car LVDS Encoder
+==
+
+These DT bindings describe the LVDS encoder embedded in the Renesas R-Car
+Gen2, R-Car Gen3 and RZ/G SoCs.
+
+Required properties:
+
+- compatible : Shall contain one of
+  - "renesas,r8a7743-lvds" for R8A7743 (RZ/G1M) compatible LVDS encoders
+  - "renesas,r8a7790-lvds" for R8A7790 (R-Car H2) compatible LVDS encoders
+  - "renesas,r8a7791-lvds" for R8A7791 (R-Car M2-W) compatible LVDS encoders
+  - "renesas,r8a7793-lvds" for R8A7791 (R-Car M2-N) compatible LVDS encoders
+  - "renesas,r8a7795-lvds" for R8A7795 (R-Car H3) compatible LVDS encoders
+  - "renesas,r8a7796-lvds" for R8A7796 (R-Car M3-W) compatible LVDS encoders
+
+- reg: Base address and length for the memory-mapped registers
+- clocks: A phandle + clock-specifier pair for the functional clock
+- resets: A phandle + reset specifier for the module reset
+
+Required nodes:
+
+The LVDS encoder has two video ports. Their connections are modelled using the
+OF graph bindings specified in Documentation/devicetree/bindings/graph.txt.
+
+- Video port 0 corresponds to the parallel RGB input
+- Video port 1 corresponds to the LVDS output
+
+Each port shall have a single endpoint.
+
+
+Example:
+
+   lvds0: lvds@feb9 {
+   compatible = "renesas,r8a7790-lvds";
+   reg = <0 0xfeb9 0 0x1c>;
+   clocks = < CPG_MOD 726>;
+   resets = < 726>;
+
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port@0 {
+   reg = <0>;
+   lvds0_in: endpoint {
+   remote-endpoint = <_out_lvds0>;
+   };
+   };
+   port@1 {
+   reg = <1>;
+   lvds0_out: endpoint {
+   };
+   };
+   };
+   };
diff --git a/MAINTAINERS b/MAINTAINERS
index 2afba909724c..13c8ec11135a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4744,6 +4744,7 @@ F:drivers/gpu/drm/rcar-du/
 F: drivers/gpu/drm/shmobile/
 F: include/linux/platform_data/shmob_drm.h
 F: Documentation/devicetree/bindings/display/bridge/renesas,dw-hdmi.txt
+F: Documentation/devicetree/bindings/display/bridge/renesas,lvds.txt
 F: Documentation/devicetree/bindings/display/renesas,du.txt
 
 DRM DRIVERS FOR ROCKCHIP
-- 
Regards,

Laurent Pinchart



[PATCH v4 00/16] R-Car DU: Convert LVDS code to bridge driver

2018-02-20 Thread Laurent Pinchart
Hello,

This patch series addresses a design mistake that dates back from the initial
DU support. Support for the LVDS encoders, which are IP cores separate from
the DU, was bundled in the DU driver. Worse, both the DU and LVDS were
described through a single DT node.

To fix the, patches 01/16 and 02/16 define new DT bindings for the LVDS
encoders, and deprecate their description inside the DU bindings. To retain
backward compatibility with existing DT, patches 03/16 to 08/16 then patch the
device tree at runtime to convert the legacy bindings to the new ones.

With the DT side addressed, patch 09/16 converts the LVDS support code to a
separate bridge driver. Patches 11/16 to 16/16 then update all the device tree
sources to the new DU and LVDS encoders bindings.

I decided to go for live DT patching in patch 08/16 because implementing
support for both the legacy and new bindings in the driver would have been
very intrusive, and prevented further cleanups. This version relies more
heavily on overlays to avoid touching the internals of the OF core compared to
v2, even if manual fixes to the device tree are still needed.

Compared to v3, this series uses the OF changeset API to update properties
instead of accessing the internals of the property structure. This removes the
local implementation of functions to look up nodes by path and update
properties. In order to do this, I pulled in Pantelis' patch series titled
"[PATCH v2 0/5] of: dynamic: Changesets helpers & fixes" at Rob's request, and
rebased it while taking two small review comments into account.

Rob, I'd like this series to be merged in v4.17. As the changeset helpers are
now a dependency, I'd need you to merge them early (ideally on top of
v4.16-rc1) and provide a stable branch, or get your ack to merge them through
Dave's tree if they don't conflict with what you have and will queue for
v4.17.

This version also drops the small fix to the Porter board device tree that has
been queued for v4.17 already.

Compared to v2, the biggest change is in patch 03/16. Following Rob's and
Frank's reviews it was clear that modifying the unflattened DT structure of
the overlay before applying it wasn't popular. I have thus decided to use one
overlay source per SoC to move as much of the DT changes to the overlay as
possible, and only perform manual modifications (that are still needed as some
of the information is board-specific) on the system DT after applying the
overlay. As a result the overlay is parsed and applied without being modified.

Compared to v1, this series update the r8a7792 and r8a7794 device tree sources
and incorporate review feedback as described by the changelogs of individual
patches.


Laurent Pinchart (11):
  dt-bindings: display: renesas: Add R-Car LVDS encoder DT bindings
  dt-bindings: display: renesas: Deprecate LVDS support in the DU
bindings
  drm: rcar-du: Fix legacy DT to create LVDS encoder nodes
  drm: rcar-du: Convert LVDS encoder code to bridge driver
  ARM: dts: r8a7790: Convert to new LVDS DT bindings
  ARM: dts: r8a7791: Convert to new LVDS DT bindings
  ARM: dts: r8a7792: Convert to new DU DT bindings
  ARM: dts: r8a7793: Convert to new LVDS DT bindings
  ARM: dts: r8a7794: Convert to new DU DT bindings
  arm64: dts: renesas: r8a7795: Convert to new LVDS DT bindings
  arm64: dts: renesas: r8a7796: Convert to new LVDS DT bindings

Pantelis Antoniou (5):
  of: dynamic: Add __of_node_dupv()
  of: changesets: Introduce changeset helper methods
  of: changeset: Add of_changeset_node_move method
  of: unittest: changeset helpers
  i2c: demux: Use changeset helpers for clarity

 .../bindings/display/bridge/renesas,lvds.txt   |  56 +++
 .../devicetree/bindings/display/renesas,du.txt |  31 +-
 MAINTAINERS|   1 +
 arch/arm/boot/dts/r8a7790-lager.dts|  22 +-
 arch/arm/boot/dts/r8a7790.dtsi |  64 ++-
 arch/arm/boot/dts/r8a7791-koelsch.dts  |  10 +-
 arch/arm/boot/dts/r8a7791-porter.dts   |  16 +-
 arch/arm/boot/dts/r8a7791.dtsi |  36 +-
 arch/arm/boot/dts/r8a7792.dtsi |   1 -
 arch/arm/boot/dts/r8a7793-gose.dts |  10 +-
 arch/arm/boot/dts/r8a7793.dtsi |  37 +-
 arch/arm/boot/dts/r8a7794.dtsi |   1 -
 .../boot/dts/renesas/r8a7795-es1-salvator-x.dts|   3 +-
 arch/arm64/boot/dts/renesas/r8a7795-h3ulcb.dts |   3 +-
 arch/arm64/boot/dts/renesas/r8a7795-salvator-x.dts |   3 +-
 .../arm64/boot/dts/renesas/r8a7795-salvator-xs.dts |   3 +-
 arch/arm64/boot/dts/renesas/r8a7795.dtsi   |  36 +-
 arch/arm64/boot/dts/renesas/r8a7796-m3ulcb.dts |   3 +-
 arch/arm64/boot/dts/renesas/r8a7796-salvator-x.dts |   3 +-
 arch/arm64/boot/dts/renesas/r8a7796.dtsi   |  36 +-
 drivers/gpu/drm/rcar-du/Kconfig|   6 +-
 drivers/gpu/drm/rcar-du/Makefile   |  10 +-
 

Re: [PATCH v2 01/19] clk: renesas: cpg-mssr: Add support for R-Car M3-N

2018-02-20 Thread Geert Uytterhoeven
On Tue, Feb 20, 2018 at 4:12 PM, Jacopo Mondi  wrote:
> Initial support for R-Car M3-N (r8a77965), including core and module
> clocks.
>
> Based on Table 8.2d of "R-Car Series, 3rd Generation User's Manual:
> Hardware (Rev. 0.80, Oct 31, 2017)".
>
> Signed-off-by: Jacopo Mondi 
> Reviewed-by: Geert Uytterhoeven 

Queued in clk-renesas-for-v4.17.

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH v2 18/19] pinctrl: sh-pfc: r8a77965: Add EtherAVB groups/functions

2018-02-20 Thread Geert Uytterhoeven
On Tue, Feb 20, 2018 at 4:12 PM, Jacopo Mondi  wrote:
> Add EtherAVB groups and functions definitions for R-Car M3-N.
>
> Signed-off-by: Jacopo Mondi 
> Reviewed-by: Geert Uytterhoeven 

Queueing in sh-pfc-for-v4.17.

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH v2 13/19] pinctrl: sh-pfc: r8a77965: Add SCIFs groups/functions

2018-02-20 Thread Geert Uytterhoeven
On Tue, Feb 20, 2018 at 4:12 PM, Jacopo Mondi  wrote:
> Add SCIF[0-5] groups and pin function definitions for R-Car M3-N.
>
> Signed-off-by: Jacopo Mondi 
> Reviewed-by: Geert Uytterhoeven 

Queueing in sh-pfc-for-v4.17.

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH v2 05/19] pinctrl: sh-pfc: Initial R-Car M3-N support

2018-02-20 Thread Geert Uytterhoeven
Hi Jacopo,

On Tue, Feb 20, 2018 at 4:12 PM, Jacopo Mondi  wrote:
> Add initial PFC support for R-Car M3-N (r8a77965) SoC.
> No groups or functions defined, just pin and registers enumeration.
>
> Signed-off-by: Jacopo Mondi 
> Reviewed-by: Rob Herring 
>
> ---
> v1 -> v2:
>
> Applied the following patches for r8a7796 on r8a77965:
>
> commit 0f4713d71f22d3b0ec3de6ae4a126cceecdea82b
> Author: Takeshi Kihara 
> Date:   Thu Nov 16 23:59:21 2017 +0900
> pinctrl: sh-pfc: r8a7796: Rename RTS{0,1,3,4}# pin function definitions
>
> commit fbd81e345c9393b96e8ad252eef390f8c6f9cf60
> Author: Takeshi Kihara 
> Date:   Thu Nov 16 12:17:18 2017 +0900
> pinctrl: sh-pfc: r8a7796: Fix to delete A20..A25 pins function definitions

Thanks for the update!

Reviewed-by: Geert Uytterhoeven 
and queueing in sh-pfc-for-v4.17, with the following recent fixes for
r8a7796 that are also applicable to r8a77965 folded in:

pinctrl: sh-pfc: r8a7796: Fix IPSR and MOD_SEL register pin
assignment for NDFC pins group
pinctrl: sh-pfc: r8a7796: Fix MOD_SEL register pin assignment for
SSI pins group

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH 3/3] pinctrl: sh-pfc: r8a7796: Add TMU pins, groups and functions

2018-02-20 Thread Geert Uytterhoeven
On Fri, Feb 16, 2018 at 3:26 PM, Ulrich Hecht
 wrote:
> From: Takeshi Kihara 
>
> This patch adds TMU TCLK{1,2} pins, groups and functions to
> the R8A7796 SoC.
>
> Signed-off-by: Takeshi Kihara 
> Signed-off-by: Ulrich Hecht 

Reviewed-by: Geert Uytterhoeven 
and queueing in sh-pfc-for-v4.17.

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH 1/3] pinctrl: sh-pfc: r8a7795: Add TMU pins, groups and functions

2018-02-20 Thread Geert Uytterhoeven
On Fri, Feb 16, 2018 at 3:26 PM, Ulrich Hecht
 wrote:
> From: Takeshi Kihara 
>
> This patch adds TMU TCLK{1,2} pins, groups and functions to
> the R8A7795 SoC.
>
> Signed-off-by: Takeshi Kihara 
> Signed-off-by: Ulrich Hecht 

Reviewed-by: Geert Uytterhoeven 
and queueing in sh-pfc-for-v4.17.

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH 2/3] pinctrl: sh-pfc: r8a7795-es1: Add TMU pins, groups and functions

2018-02-20 Thread Geert Uytterhoeven
On Fri, Feb 16, 2018 at 3:26 PM, Ulrich Hecht
 wrote:
> From: Takeshi Kihara 
>
> This patch adds TMU TCLK{1,2} pins, groups and functions to
> the R8A7795 ES1.x SoC.
>
> Signed-off-by: Takeshi Kihara 
> Signed-off-by: Ulrich Hecht 

Reviewed-by: Geert Uytterhoeven 
and queueing in sh-pfc-for-v4.17.

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH 2/3] pinctrl: sh-pfc: r8a7795-es1: Add HDMI pins, groups and functions

2018-02-20 Thread Geert Uytterhoeven
On Fri, Feb 16, 2018 at 3:25 PM, Ulrich Hecht
 wrote:
> From: Takeshi Kihara 
>
> This patch adds HDMI0 CEC pin, group and function to
> the R8A7795 ES1.x SoC.
>
> Signed-off-by: Takeshi Kihara 
> [uli: fixed typo in comment]
> Signed-off-by: Ulrich Hecht 

Reviewed-by: Geert Uytterhoeven 
and queueing in sh-pfc-for-v4.17.

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH 3/3] pinctrl: sh-pfc: r8a7796: Add HDMI pins, groups and functions

2018-02-20 Thread Geert Uytterhoeven
On Fri, Feb 16, 2018 at 3:25 PM, Ulrich Hecht
 wrote:
> From: Takeshi Kihara 
>
> This patch adds HDMI0 CEC pin, group and function to the R8A7796 SoC.
>
> Signed-off-by: Takeshi Kihara 
> Signed-off-by: Ulrich Hecht 

Reviewed-by: Geert Uytterhoeven 
and queueing in sh-pfc-for-v4.17.

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH 3/3] pinctrl: sh-pfc: r8a7796: Fix IPSR and MOD_SEL register pin assignment for NDFC pins group

2018-02-20 Thread Geert Uytterhoeven
On Fri, Feb 16, 2018 at 3:25 PM, Ulrich Hecht
 wrote:
> From: Takeshi Kihara 
>
> This patch fixes to set IPSR and MOD_SEL when using NFDATA{14,15}_A and
> NF{RB,WP}_N_A pin function is selected. And renamess MOD_SEL2 bit22 value
> definition name to SEL_NDFC.
>
> This is a correction to the incorrect implementation of MOD_SEL register
> pin assignment for R8A7796 SoC specification of R-Car Gen3 Hardware
> User's Manual Rev.0.53E.
>
> Fixes: f9aece7344bd ("pinctrl: sh-pfc: Initial R8A7796 PFC support")
> Signed-off-by: Takeshi Kihara 
> Signed-off-by: Ulrich Hecht 

Reviewed-by: Geert Uytterhoeven 
and queueing in sh-pfc-for-v4.17.

I guess this applies to M3-N, too?

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH 2/3] pinctrl: sh-pfc: r8a7796: Fix MOD_SEL register pin assignment for SSI pins group

2018-02-20 Thread Geert Uytterhoeven
On Fri, Feb 16, 2018 at 3:25 PM, Ulrich Hecht
 wrote:
> From: Takeshi Kihara 
>
> This patch fixes MOD_SEL1 bit20 and MOD_SEL2 bit20, bit21 pin assignment
> for SSI pins group.
>
> This is a correction to the incorrect implementation of MOD_SEL register
> pin assignment for R8A7796 SoC specification of R-Car Gen3 Hardware
> User's Manual Rev.0.51E or later.
>
> Fixes: f9aece7344bd ("pinctrl: sh-pfc: Initial R8A7796 PFC support")
> Signed-off-by: Takeshi Kihara 
> Signed-off-by: Ulrich Hecht 

Reviewed-by: Geert Uytterhoeven 
and queueing in sh-pfc-for-v4.17.

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH 1/3] pinctrl: sh-pfc: r8a7795: Fix MOD_SEL register pin assignment for SSI pins group

2018-02-20 Thread Geert Uytterhoeven
On Fri, Feb 16, 2018 at 3:25 PM, Ulrich Hecht
 wrote:
> From: Takeshi Kihara 
>
> This patch fixes MOD_SEL1 bit20 and MOD_SEL2 bit20, bit21 pin assignment
> for SSI pins group.
>
> This is a correction because MOD_SEL register specification for R8A7795
> ES2.0 SoC was changed in R-Car Gen3 Hardware User's Manual Rev.0.53E.
>
> Fixes: b205914c8f82 ("pinctrl: sh-pfc: r8a7795: Add support for R-Car H3 
> ES2.0")
> Signed-off-by: Takeshi Kihara 
> Signed-off-by: Ulrich Hecht 

Reviewed-by: Geert Uytterhoeven 
and queueing in sh-pfc-for-v4.17.

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH v2 12/19] dt-bindings: serial: sh-sci: Add support for r8a77965 (H)SCIF

2018-02-20 Thread Geert Uytterhoeven
On Tue, Feb 20, 2018 at 4:12 PM, Jacopo Mondi  wrote:
> Add documentation for r8a77965 compatible string to Renesas sci-serial
> device tree bindings documentation.
>
> Signed-off-by: Jacopo Mondi 

Reviewed-by: Geert Uytterhoeven 

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH v2 08/19] ARM64: dts: Add Renesas R8A77965 SoC support

2018-02-20 Thread Geert Uytterhoeven
On Tue, Feb 20, 2018 at 4:12 PM, Jacopo Mondi  wrote:
> Basic support for the Gen 3 R-Car M3-N SoC.
>
> Based on original work from:
> Takeshi Kihara 
> Magnus Damm 
>
> Signed-off-by: Jacopo Mondi 

Reviewed-by: Geert Uytterhoeven 

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH v2 09/19] ARM64: dts: Add R-Car Salvator-x M3-N support

2018-02-20 Thread Geert Uytterhoeven
On Tue, Feb 20, 2018 at 4:12 PM, Jacopo Mondi  wrote:
> Add basic support for R-Car Salvator-X M3-N (R8A77965) board.
>
> Based on original work from:
> Takeshi Kihara 
> Magnus Damm 
>
> Signed-off-by: Jacopo Mondi 

Reviewed-by: Geert Uytterhoeven 

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH v2 07/19] ARM64: Add Renesas R-Car M3-N config symbol

2018-02-20 Thread Geert Uytterhoeven
On Tue, Feb 20, 2018 at 4:12 PM, Jacopo Mondi  wrote:
> Add configuration option for the R-Car M3-N (R8A77965) SoC.
>
> Signed-off-by: Jacopo Mondi 

Reviewed-by: Geert Uytterhoeven 

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH v2 04/19] soc: renesas: rcar-sysc: Add R-Car M3-N support

2018-02-20 Thread Geert Uytterhoeven
On Tue, Feb 20, 2018 at 4:12 PM, Jacopo Mondi  wrote:
> Add support for R-Car M3-N (R8A77965) power areas.
>
> Signed-off-by: Jacopo Mondi 

Reviewed-by: Geert Uytterhoeven 

We'll sort out the remaining issues later.

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH v2 03/19] soc: renesas: Identify R-Car M3-N

2018-02-20 Thread Geert Uytterhoeven
Hi Jacopo,

On Tue, Feb 20, 2018 at 4:12 PM, Jacopo Mondi  wrote:
> Add support for indentifying R-Car M3-N (R8A77965) SoC.
>
> Signed-off-by: Jacopo Mondi 

Reviewed-by: Geert Uytterhoeven 

> --- a/drivers/soc/renesas/renesas-soc.c
> +++ b/drivers/soc/renesas/renesas-soc.c
> @@ -149,6 +149,11 @@ static const struct renesas_soc soc_rcar_v3m __initconst 
> __maybe_unused = {
> .id = 0x54,
>  };
>
> +static const struct renesas_soc soc_rcar_m3_n __initconst __maybe_unused = {
> +   .family = _rcar_gen3,
> +   .id = 0x55,
> +};

Note that the list was sorted by SoC part number.

> +
>  static const struct renesas_soc soc_rcar_v3h __initconst __maybe_unused = {
> .family = _rcar_gen3,
> .id = 0x56,
> @@ -214,6 +219,9 @@ static const struct of_device_id renesas_socs[] 
> __initconst = {
>  #ifdef CONFIG_ARCH_R8A7796
> { .compatible = "renesas,r8a7796",  .data = _rcar_m3_w },
>  #endif
> +#ifdef CONFIG_ARCH_R8A77965
> +   { .compatible = "renesas,r8a77965", .data = _rcar_m3_n },
> +#endif
>  #ifdef CONFIG_ARCH_R8A77970
> { .compatible = "renesas,r8a77970", .data = _rcar_v3m },
>  #endif

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH v2 19/19] ARM64: dts: r8a77965: Add EtherAVB device node

2018-02-20 Thread Sergei Shtylyov
On 02/20/2018 06:12 PM, Jacopo Mondi wrote:

> Populate the ethernet@e680 device node to enable Ethernet interface
> for R-Car M3-N (r8a77965) SoC.
> 
> Signed-off-by: Jacopo Mondi 
> Reviewed-by: Geert Uytterhoeven 
> 
> ---
> v1 -> v2:
> - Replace ALWAYS_ON power area identifier with numeric constant
> ---
>  arch/arm64/boot/dts/renesas/r8a77965.dtsi | 43 
> ++-
>  1 file changed, 42 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/boot/dts/renesas/r8a77965.dtsi 
> b/arch/arm64/boot/dts/renesas/r8a77965.dtsi
> index 55f05f7..c249895 100644
> --- a/arch/arm64/boot/dts/renesas/r8a77965.dtsi
> +++ b/arch/arm64/boot/dts/renesas/r8a77965.dtsi
> @@ -520,7 +520,48 @@
>   };
>  
>   avb: ethernet@e680 {
> - /* placeholder */
> + compatible = "renesas,etheravb-r8a77965",
> +  "renesas,etheravb-rcar-gen3";
> + reg = <0 0xe680 0 0x800>, <0 0xe6a0 0 0x1>;
> + interrupts = ,
> +  ,
> +  ,
> +  ,
> +  ,
> +  ,
> +  ,
> +  ,
> +  ,
> +  ,
> +  ,
> +  ,
> +  ,
> +  ,
> +  ,
> +  ,
> +  ,
> +  ,
> +  ,
> +  ,
> +  ,
> +  ,
> +  ,
> +  ,
> +  ;
> + interrupt-names = "ch0", "ch1", "ch2", "ch3",
> +   "ch4", "ch5", "ch6", "ch7",
> +   "ch8", "ch9", "ch10", "ch11",
> +   "ch12", "ch13", "ch14", "ch15",
> +   "ch16", "ch17", "ch18", "ch19",
> +   "ch20", "ch21", "ch22", "ch23",
> +   "ch24";
> + clocks = < CPG_MOD 812>;
> + power-domains = < 32>;
> + resets = < 812>;
> + phy-mode = "rgmii-txid";

   Why not just "rgmii"? TX delay is a board specific detail, no?

> + #address-cells = <1>;
> + #size-cells = <0>;
> + status = "disabled";
>   };
>  
>   csi20: csi2@fea8 {
> 

MBR, Sergei


Re: [PATCH v2 02/19] soc: renesas: rcar-rst: Add support for R-Car M3-N

2018-02-20 Thread Geert Uytterhoeven
On Tue, Feb 20, 2018 at 4:12 PM, Jacopo Mondi  wrote:
> Signed-off-by: Jacopo Mondi 

Reviewed-by: Geert Uytterhoeven 

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH 4/4] pinctrl: sh-pfc: r8a77995: Add DU pins, groups and function

2018-02-20 Thread Geert Uytterhoeven
On Thu, Feb 15, 2018 at 1:38 PM, Kieran Bingham
 wrote:
> On 15/02/18 12:01, Ulrich Hecht wrote:
>> This patch adds DU pins, groups and function for the R8A77995 (D3) SoC.
>>
>> Signed-off-by: Ulrich Hecht 
>
> All of your pin values check out.
> (And it highlights that I may have left a copy/paste/fail-to-update on the
> du_disp in my version)
>
> Generic question below regarding DOTCLK naming, but it's not a blocker to this
> patch, so:
>
> Reviewed-by: Kieran Bingham 

Reviewed-by: Geert Uytterhoeven 
and queueing in sh-pfc-for-v4.17.

>> --- a/drivers/pinctrl/sh-pfc/pfc-r8a77995.c
>> +++ b/drivers/pinctrl/sh-pfc/pfc-r8a77995.c

>> +static const unsigned int du_clk_in_1_pins[] = {
>> + /* CLKIN */
>> + RCAR_GP_PIN(1, 28),
>> +};
>> +static const unsigned int du_clk_in_1_mux[] = {
>> + DU_DOTCLKIN1_MARK
>> +};
>> +static const unsigned int du_clk_out_0_pins[] = {
>> + /* CLKOUT */
>> + RCAR_GP_PIN(1, 24),
>> +};
>> +static const unsigned int du_clk_out_0_mux[] = {
>> + DU_DOTCLKOUT0_MARK
>> +};
>
> Why do the DOTCLKOUT and DOTCLKIN pins get named clk_out_ and clk_in_ ?
>
> All of the other pins seem to entirely follow the pin name as per the 
> datasheet,
> except for these.

Historical reasons, I guess. It's the case on all older SoCs.

Gr{oetje,eeting}s,

Geert

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

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


[PATCH v2 02/19] soc: renesas: rcar-rst: Add support for R-Car M3-N

2018-02-20 Thread Jacopo Mondi
Signed-off-by: Jacopo Mondi 
---
 Documentation/devicetree/bindings/reset/renesas,rst.txt | 1 +
 drivers/soc/renesas/Kconfig | 4 ++--
 drivers/soc/renesas/rcar-rst.c  | 1 +
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/reset/renesas,rst.txt 
b/Documentation/devicetree/bindings/reset/renesas,rst.txt
index a55b886..294a0da 100644
--- a/Documentation/devicetree/bindings/reset/renesas,rst.txt
+++ b/Documentation/devicetree/bindings/reset/renesas,rst.txt
@@ -26,6 +26,7 @@ Required properties:
  - "renesas,r8a7794-rst" (R-Car E2)
  - "renesas,r8a7795-rst" (R-Car H3)
  - "renesas,r8a7796-rst" (R-Car M3-W)
+ - "renesas,r8a77965-rst" (R-Car M3-N)
  - "renesas,r8a77970-rst" (R-Car V3M)
  - "renesas,r8a77980-rst" (R-Car V3H)
  - "renesas,r8a77995-rst" (R-Car D3)
diff --git a/drivers/soc/renesas/Kconfig b/drivers/soc/renesas/Kconfig
index 6efd7be..741b7cd 100644
--- a/drivers/soc/renesas/Kconfig
+++ b/drivers/soc/renesas/Kconfig
@@ -3,8 +3,8 @@ config SOC_RENESAS
default y if ARCH_RENESAS
select SOC_BUS
select RST_RCAR if ARCH_RCAR_GEN1 || ARCH_RCAR_GEN2 || \
-  ARCH_R8A7795 || ARCH_R8A7796 || ARCH_R8A77970 || \
-  ARCH_R8A77980 || ARCH_R8A77995
+  ARCH_R8A7795 || ARCH_R8A7796 || ARCH_R8A77965 || \
+  ARCH_R8A77970 || ARCH_R8A77980 || ARCH_R8A77995
select SYSC_R8A7743 if ARCH_R8A7743
select SYSC_R8A7745 if ARCH_R8A7745
select SYSC_R8A7779 if ARCH_R8A7779
diff --git a/drivers/soc/renesas/rcar-rst.c b/drivers/soc/renesas/rcar-rst.c
index e2340eb..33060f2 100644
--- a/drivers/soc/renesas/rcar-rst.c
+++ b/drivers/soc/renesas/rcar-rst.c
@@ -41,6 +41,7 @@ static const struct of_device_id rcar_rst_matches[] 
__initconst = {
/* R-Car Gen3 is handled like R-Car Gen2 */
{ .compatible = "renesas,r8a7795-rst", .data = _rst_gen2 },
{ .compatible = "renesas,r8a7796-rst", .data = _rst_gen2 },
+   { .compatible = "renesas,r8a77965-rst", .data = _rst_gen2 },
{ .compatible = "renesas,r8a77970-rst", .data = _rst_gen2 },
{ .compatible = "renesas,r8a77980-rst", .data = _rst_gen2 },
{ .compatible = "renesas,r8a77995-rst", .data = _rst_gen2 },
-- 
2.7.4



[PATCH v2 03/19] soc: renesas: Identify R-Car M3-N

2018-02-20 Thread Jacopo Mondi
Add support for indentifying R-Car M3-N (R8A77965) SoC.

Signed-off-by: Jacopo Mondi 
---
 drivers/soc/renesas/renesas-soc.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/soc/renesas/renesas-soc.c 
b/drivers/soc/renesas/renesas-soc.c
index 0008343..7161983 100644
--- a/drivers/soc/renesas/renesas-soc.c
+++ b/drivers/soc/renesas/renesas-soc.c
@@ -149,6 +149,11 @@ static const struct renesas_soc soc_rcar_v3m __initconst 
__maybe_unused = {
.id = 0x54,
 };
 
+static const struct renesas_soc soc_rcar_m3_n __initconst __maybe_unused = {
+   .family = _rcar_gen3,
+   .id = 0x55,
+};
+
 static const struct renesas_soc soc_rcar_v3h __initconst __maybe_unused = {
.family = _rcar_gen3,
.id = 0x56,
@@ -214,6 +219,9 @@ static const struct of_device_id renesas_socs[] __initconst 
= {
 #ifdef CONFIG_ARCH_R8A7796
{ .compatible = "renesas,r8a7796",  .data = _rcar_m3_w },
 #endif
+#ifdef CONFIG_ARCH_R8A77965
+   { .compatible = "renesas,r8a77965", .data = _rcar_m3_n },
+#endif
 #ifdef CONFIG_ARCH_R8A77970
{ .compatible = "renesas,r8a77970", .data = _rcar_v3m },
 #endif
-- 
2.7.4



[PATCH v2 04/19] soc: renesas: rcar-sysc: Add R-Car M3-N support

2018-02-20 Thread Jacopo Mondi
Add support for R-Car M3-N (R8A77965) power areas.

Signed-off-by: Jacopo Mondi 

---
v1->v2:
- Remove A2VC0 power area
- Add A3VP power area
---
 .../bindings/power/renesas,rcar-sysc.txt   |  1 +
 drivers/soc/renesas/Kconfig|  5 +++
 drivers/soc/renesas/Makefile   |  1 +
 drivers/soc/renesas/r8a77965-sysc.c| 37 ++
 drivers/soc/renesas/rcar-sysc.c|  3 ++
 drivers/soc/renesas/rcar-sysc.h|  1 +
 include/dt-bindings/power/r8a77965-sysc.h  | 30 ++
 7 files changed, 78 insertions(+)
 create mode 100644 drivers/soc/renesas/r8a77965-sysc.c
 create mode 100644 include/dt-bindings/power/r8a77965-sysc.h

diff --git a/Documentation/devicetree/bindings/power/renesas,rcar-sysc.txt 
b/Documentation/devicetree/bindings/power/renesas,rcar-sysc.txt
index 8690f10..b9c9e28 100644
--- a/Documentation/devicetree/bindings/power/renesas,rcar-sysc.txt
+++ b/Documentation/devicetree/bindings/power/renesas,rcar-sysc.txt
@@ -17,6 +17,7 @@ Required properties:
   - "renesas,r8a7794-sysc" (R-Car E2)
   - "renesas,r8a7795-sysc" (R-Car H3)
   - "renesas,r8a7796-sysc" (R-Car M3-W)
+  - "renesas,r8a77965-sysc" (R-Car M3-N)
   - "renesas,r8a77970-sysc" (R-Car V3M)
   - "renesas,r8a77995-sysc" (R-Car D3)
   - reg: Address start and address range for the device.
diff --git a/drivers/soc/renesas/Kconfig b/drivers/soc/renesas/Kconfig
index 741b7cd..c262a4b 100644
--- a/drivers/soc/renesas/Kconfig
+++ b/drivers/soc/renesas/Kconfig
@@ -14,6 +14,7 @@ config SOC_RENESAS
select SYSC_R8A7794 if ARCH_R8A7794
select SYSC_R8A7795 if ARCH_R8A7795
select SYSC_R8A7796 if ARCH_R8A7796
+   select SYSC_R8A77965 if ARCH_R8A77965
select SYSC_R8A77970 if ARCH_R8A77970
select SYSC_R8A77995 if ARCH_R8A77995
 
@@ -56,6 +57,10 @@ config SYSC_R8A7796
bool "R-Car M3-W System Controller support" if COMPILE_TEST
select SYSC_RCAR
 
+config SYSC_R8A77965
+   bool "R-Car M3-N System Controller support" if COMPILE_TEST
+   select SYSC_RCAR
+
 config SYSC_R8A77970
bool "R-Car V3M System Controller support" if COMPILE_TEST
select SYSC_RCAR
diff --git a/drivers/soc/renesas/Makefile b/drivers/soc/renesas/Makefile
index 845d62a..9f360b8 100644
--- a/drivers/soc/renesas/Makefile
+++ b/drivers/soc/renesas/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_SYSC_R8A7792)+= r8a7792-sysc.o
 obj-$(CONFIG_SYSC_R8A7794) += r8a7794-sysc.o
 obj-$(CONFIG_SYSC_R8A7795) += r8a7795-sysc.o
 obj-$(CONFIG_SYSC_R8A7796) += r8a7796-sysc.o
+obj-$(CONFIG_SYSC_R8A77965)+= r8a77965-sysc.o
 obj-$(CONFIG_SYSC_R8A77970)+= r8a77970-sysc.o
 obj-$(CONFIG_SYSC_R8A77995)+= r8a77995-sysc.o
 
diff --git a/drivers/soc/renesas/r8a77965-sysc.c 
b/drivers/soc/renesas/r8a77965-sysc.c
new file mode 100644
index 000..d7f7928
--- /dev/null
+++ b/drivers/soc/renesas/r8a77965-sysc.c
@@ -0,0 +1,37 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Renesas R-Car M3-N System Controller
+ * Copyright (C) 2018 Jacopo Mondi 
+ *
+ * Based on Renesas R-Car M3-W System Controller
+ * Copyright (C) 2016 Glider bvba
+ */
+
+#include 
+#include 
+
+#include 
+
+#include "rcar-sysc.h"
+
+static const struct rcar_sysc_area r8a77965_areas[] __initconst = {
+   { "always-on",  0, 0, R8A77965_PD_ALWAYS_ON, -1, PD_ALWAYS_ON },
+   { "ca57-scu",   0x1c0, 0, R8A77965_PD_CA57_SCU, R8A77965_PD_ALWAYS_ON,
+ PD_SCU },
+   { "ca57-cpu0",   0x80, 0, R8A77965_PD_CA57_CPU0, R8A77965_PD_CA57_SCU,
+ PD_CPU_NOCR },
+   { "ca57-cpu1",   0x80, 1, R8A77965_PD_CA57_CPU1, R8A77965_PD_CA57_SCU,
+ PD_CPU_NOCR },
+   { "cr7",0x240, 0, R8A77965_PD_CR7,  R8A77965_PD_ALWAYS_ON },
+   { "a3vc",   0x380, 0, R8A77965_PD_A3VC, R8A77965_PD_ALWAYS_ON },
+   { "a3vp",   0x340, 0, R8A77965_PD_A3VP, R8A77965_PD_ALWAYS_ON },
+   { "a2vc1",  0x3c0, 1, R8A77965_PD_A2VC1,R8A77965_PD_A3VC },
+   { "3dg-a",  0x100, 0, R8A77965_PD_3DG_A,R8A77965_PD_ALWAYS_ON },
+   { "3dg-b",  0x100, 1, R8A77965_PD_3DG_B,R8A77965_PD_3DG_A },
+   { "a3ir",   0x180, 0, R8A77965_PD_A3IR, R8A77965_PD_ALWAYS_ON },
+};
+
+const struct rcar_sysc_info r8a77965_sysc_info __initconst = {
+   .areas = r8a77965_areas,
+   .num_areas = ARRAY_SIZE(r8a77965_areas),
+};
diff --git a/drivers/soc/renesas/rcar-sysc.c b/drivers/soc/renesas/rcar-sysc.c
index 636872b..d87f83a 100644
--- a/drivers/soc/renesas/rcar-sysc.c
+++ b/drivers/soc/renesas/rcar-sysc.c
@@ -284,6 +284,9 @@ static const struct of_device_id rcar_sysc_matches[] 
__initconst = {
 #ifdef CONFIG_SYSC_R8A7796
{ .compatible = "renesas,r8a7796-sysc", .data = _sysc_info },
 #endif
+#ifdef CONFIG_SYSC_R8A77965
+   { .compatible = "renesas,r8a77965-sysc", .data = _sysc_info },

[PATCH v2 06/19] dt-bindings: arm: Document R-Car M3-N SoC DT bindings

2018-02-20 Thread Jacopo Mondi
Add device tree bindings documentation for Renesas R-Car M3-N (r8a77965)
SoC.

Signed-off-by: Jacopo Mondi 
Reviewed-by: Geert Uytterhoeven 
Reviewed-by: Rob Herring 
---
 Documentation/devicetree/bindings/arm/shmobile.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/arm/shmobile.txt 
b/Documentation/devicetree/bindings/arm/shmobile.txt
index 41d3920..67889a9 100644
--- a/Documentation/devicetree/bindings/arm/shmobile.txt
+++ b/Documentation/devicetree/bindings/arm/shmobile.txt
@@ -39,6 +39,8 @@ SoCs:
 compatible = "renesas,r8a7795"
   - R-Car M3-W (R8A77960)
 compatible = "renesas,r8a7796"
+  - R-Car M3-N (R8A77965)
+compatible = "renesas,r8a77965"
   - R-Car V3M (R8A77970)
 compatible = "renesas,r8a77970"
   - R-Car V3H (R8A77980)
-- 
2.7.4



[PATCH v2 08/19] ARM64: dts: Add Renesas R8A77965 SoC support

2018-02-20 Thread Jacopo Mondi
Basic support for the Gen 3 R-Car M3-N SoC.

Based on original work from:
Takeshi Kihara 
Magnus Damm 

Signed-off-by: Jacopo Mondi 

---
v1 -> v2:
- Split r8a77965.dtsi from patch v1 [5/15]
- Replace all PD_ and CLK_ defines with numeric entries
- Move timer and pmu nodes outside of soc node and replace their
  "interrupt" property with "interrupt-extended" one
- Fix license header
---
 arch/arm64/boot/dts/renesas/r8a77965.dtsi | 490 ++
 1 file changed, 490 insertions(+)
 create mode 100644 arch/arm64/boot/dts/renesas/r8a77965.dtsi

diff --git a/arch/arm64/boot/dts/renesas/r8a77965.dtsi 
b/arch/arm64/boot/dts/renesas/r8a77965.dtsi
new file mode 100644
index 000..6b6ec65
--- /dev/null
+++ b/arch/arm64/boot/dts/renesas/r8a77965.dtsi
@@ -0,0 +1,490 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Device Tree Source for the r8a77965 SoC
+ *
+ * Copyright (C) 2018 Jacopo Mondi 
+ *
+ * Based on r8a7796.dtsi
+ * Copyright (C) 2016 Renesas Electronics Corp.
+ */
+
+#include 
+#include 
+
+#define CPG_AUDIO_CLK_I10
+
+/ {
+   compatible = "renesas,r8a77965";
+   #address-cells = <2>;
+   #size-cells = <2>;
+
+   psci {
+   compatible = "arm,psci-1.0", "arm,psci-0.2";
+   method = "smc";
+   };
+
+   cpus {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   a57_0: cpu@0 {
+   compatible = "arm,cortex-a57", "arm,armv8";
+   reg = <0x0>;
+   device_type = "cpu";
+   power-domains = < 0>;
+   next-level-cache = <_CA57>;
+   enable-method = "psci";
+   };
+
+   a57_1: cpu@1 {
+   compatible = "arm,cortex-a57","arm,armv8";
+   reg = <0x1>;
+   device_type = "cpu";
+   power-domains = < 1>;
+   next-level-cache = <_CA57>;
+   enable-method = "psci";
+   };
+
+   L2_CA57: cache-controller-0 {
+   compatible = "cache";
+   reg = <0>;
+   power-domains = < 12>;
+   cache-unified;
+   cache-level = <2>;
+   };
+   };
+
+   extal_clk: extal {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   /* This value must be overridden by the board */
+   clock-frequency = <0>;
+   };
+
+   extalr_clk: extalr {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   /* This value must be overridden by the board */
+   clock-frequency = <0>;
+   };
+
+   /*
+* The external audio clocks are configured as 0 Hz fixed frequency
+* clocks by default.
+* Boards that provide audio clocks should override them.
+*/
+   audio_clk_a: audio_clk_a {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <0>;
+   };
+
+   audio_clk_b: audio_clk_b {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <0>;
+   };
+
+   audio_clk_c: audio_clk_c {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <0>;
+   };
+
+   /* External CAN clock - to be overridden by boards that provide it */
+   can_clk: can {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <0>;
+   };
+
+   /* External SCIF clock - to be overridden by boards that provide it */
+   scif_clk: scif {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <0>;
+   };
+
+   /* External PCIe clock - can be overridden by the board */
+   pcie_bus_clk: pcie_bus {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <0>;
+   };
+
+   /* External USB clocks - can be overridden by the board */
+   usb3s0_clk: usb3s0 {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <0>;
+   };
+
+   usb_extal_clk: usb_extal {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <0>;
+   };
+
+   timer {
+   compatible = "arm,armv8-timer";
+   interrupts-extended = < GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(2) 
| IRQ_TYPE_LEVEL_LOW)>,
+ < GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(2) 
| IRQ_TYPE_LEVEL_LOW)>,
+   

[PATCH v2 10/19] dt-bindings: dmaengine: rcar-dmac: document R8A77965 support

2018-02-20 Thread Jacopo Mondi
Add documentation for r8a77965 compatible string to rcar-dmac device
tree bindings documentation.

Signed-off-by: Jacopo Mondi 
Reviewed-by: Geert Uytterhoeven 
Reviewed-by: Simon Horman 
---
 Documentation/devicetree/bindings/dma/renesas,rcar-dmac.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/dma/renesas,rcar-dmac.txt 
b/Documentation/devicetree/bindings/dma/renesas,rcar-dmac.txt
index 2f5167d..b7f3e60 100644
--- a/Documentation/devicetree/bindings/dma/renesas,rcar-dmac.txt
+++ b/Documentation/devicetree/bindings/dma/renesas,rcar-dmac.txt
@@ -25,6 +25,7 @@ Required Properties:
- "renesas,dmac-r8a7794" (R-Car E2)
- "renesas,dmac-r8a7795" (R-Car H3)
- "renesas,dmac-r8a7796" (R-Car M3-W)
+   - "renesas,dmac-r8a77965" (R-Car M3-N)
- "renesas,dmac-r8a77970" (R-Car V3M)
- "renesas,dmac-r8a77980" (R-Car V3H)
 
-- 
2.7.4



[PATCH v2 07/19] ARM64: Add Renesas R-Car M3-N config symbol

2018-02-20 Thread Jacopo Mondi
Add configuration option for the R-Car M3-N (R8A77965) SoC.

Signed-off-by: Jacopo Mondi 
---
 arch/arm64/Kconfig.platforms | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms
index b51db26..2b1535c 100644
--- a/arch/arm64/Kconfig.platforms
+++ b/arch/arm64/Kconfig.platforms
@@ -190,6 +190,12 @@ config ARCH_R8A7796
help
  This enables support for the Renesas R-Car M3-W SoC.
 
+config ARCH_R8A77965
+   bool "Renesas R-Car M3-N SoC Platform"
+   depends on ARCH_RENESAS
+   help
+ This enables support for the Renesas R-Car M3-N SoC.
+
 config ARCH_R8A77970
bool "Renesas R-Car V3M SoC Platform"
depends on ARCH_RENESAS
-- 
2.7.4



[PATCH v2 09/19] ARM64: dts: Add R-Car Salvator-x M3-N support

2018-02-20 Thread Jacopo Mondi
Add basic support for R-Car Salvator-X M3-N (R8A77965) board.

Based on original work from:
Takeshi Kihara 
Magnus Damm 

Signed-off-by: Jacopo Mondi 

---
v1 -> v2:
- split from patch v1 [05/15]
- Remove "aliases" and "chosen" as they are defined already
- Fix license header
---
 arch/arm64/boot/dts/renesas/Makefile|  1 +
 arch/arm64/boot/dts/renesas/r8a77965-salvator-x.dts | 21 +
 2 files changed, 22 insertions(+)
 create mode 100644 arch/arm64/boot/dts/renesas/r8a77965-salvator-x.dts

diff --git a/arch/arm64/boot/dts/renesas/Makefile 
b/arch/arm64/boot/dts/renesas/Makefile
index 2186d01..3680ecd 100644
--- a/arch/arm64/boot/dts/renesas/Makefile
+++ b/arch/arm64/boot/dts/renesas/Makefile
@@ -7,5 +7,6 @@ dtb-$(CONFIG_ARCH_R8A7795) += r8a7795-es1-h3ulcb-kf.dtb
 dtb-$(CONFIG_ARCH_R8A7796) += r8a7796-salvator-x.dtb r8a7796-m3ulcb.dtb
 dtb-$(CONFIG_ARCH_R8A7796) += r8a7796-m3ulcb-kf.dtb
 dtb-$(CONFIG_ARCH_R8A7796) += r8a7796-salvator-xs.dtb
+dtb-$(CONFIG_ARCH_R8A77965) += r8a77965-salvator-x.dtb
 dtb-$(CONFIG_ARCH_R8A77970) += r8a77970-eagle.dtb r8a77970-v3msk.dtb
 dtb-$(CONFIG_ARCH_R8A77995) += r8a77995-draak.dtb
diff --git a/arch/arm64/boot/dts/renesas/r8a77965-salvator-x.dts 
b/arch/arm64/boot/dts/renesas/r8a77965-salvator-x.dts
new file mode 100644
index 000..75d890d
--- /dev/null
+++ b/arch/arm64/boot/dts/renesas/r8a77965-salvator-x.dts
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Device Tree Source for the Salvator-X board with R-Car M3-N
+ *
+ * Copyright (C) 2018 Jacopo Mondi 
+ */
+
+/dts-v1/;
+#include "r8a77965.dtsi"
+#include "salvator-x.dtsi"
+
+/ {
+   model = "Renesas Salvator-X board based on r8a77965";
+   compatible = "renesas,salvator-x", "renesas,r8a77965";
+
+   memory@4800 {
+   device_type = "memory";
+   /* first 128MB is reserved for secure area. */
+   reg = <0x0 0x4800 0x0 0x7800>;
+   };
+};
-- 
2.7.4



[PATCH v2 12/19] dt-bindings: serial: sh-sci: Add support for r8a77965 (H)SCIF

2018-02-20 Thread Jacopo Mondi
Add documentation for r8a77965 compatible string to Renesas sci-serial
device tree bindings documentation.

Signed-off-by: Jacopo Mondi 
---
 Documentation/devicetree/bindings/serial/renesas,sci-serial.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/serial/renesas,sci-serial.txt 
b/Documentation/devicetree/bindings/serial/renesas,sci-serial.txt
index cf504d0..88f947c 100644
--- a/Documentation/devicetree/bindings/serial/renesas,sci-serial.txt
+++ b/Documentation/devicetree/bindings/serial/renesas,sci-serial.txt
@@ -41,6 +41,8 @@ Required properties:
 - "renesas,hscif-r8a7795" for R8A7795 (R-Car H3) HSCIF compatible UART.
 - "renesas,scif-r8a7796" for R8A7796 (R-Car M3-W) SCIF compatible UART.
 - "renesas,hscif-r8a7796" for R8A7796 (R-Car M3-W) HSCIF compatible UART.
+- "renesas,scif-r8a77965" for R8A77965 (R-Car M3-N) SCIF compatible UART.
+- "renesas,hscif-r8a77965" for R8A77965 (R-Car M3-N) HSCIF compatible UART.
 - "renesas,scif-r8a77970" for R8A77970 (R-Car V3M) SCIF compatible UART.
 - "renesas,hscif-r8a77970" for R8A77970 (R-Car V3M) HSCIF compatible UART.
 - "renesas,scif-r8a77995" for R8A77995 (R-Car D3) SCIF compatible UART.
-- 
2.7.4



[PATCH v2 11/19] ARM64: dts: r8a77965: Add dmac device nods

2018-02-20 Thread Jacopo Mondi
Add dmac[0-2] device nodes for R-Car M3-N (r8a77965) SoC.

Signed-off-by: Jacopo Mondi 
Reviewed-by: Geert Uytterhoeven 
---
 arch/arm64/boot/dts/renesas/r8a77965.dtsi | 96 ++-
 1 file changed, 93 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/boot/dts/renesas/r8a77965.dtsi 
b/arch/arm64/boot/dts/renesas/r8a77965.dtsi
index 6b6ec65..b83dafc 100644
--- a/arch/arm64/boot/dts/renesas/r8a77965.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a77965.dtsi
@@ -233,15 +233,105 @@
};
 
dmac0: dma-controller@e670 {
-   /* placeholder */
+   compatible = "renesas,dmac-r8a77965",
+"renesas,rcar-dmac";
+   reg = <0 0xe670 0 0x1>;
+   interrupts = ;
+   interrupt-names = "error",
+   "ch0", "ch1", "ch2", "ch3",
+   "ch4", "ch5", "ch6", "ch7",
+   "ch8", "ch9", "ch10", "ch11",
+   "ch12", "ch13", "ch14", "ch15";
+   clocks = < CPG_MOD 219>;
+   clock-names = "fck";
+   power-domains = < 32>;
+   resets = < 219>;
+   #dma-cells = <1>;
+   dma-channels = <16>;
};
 
dmac1: dma-controller@e730 {
-   /* placeholder */
+   compatible = "renesas,dmac-r8a77965",
+"renesas,rcar-dmac";
+   reg = <0 0xe730 0 0x1>;
+   interrupts = ;
+   interrupt-names = "error",
+   "ch0", "ch1", "ch2", "ch3",
+   "ch4", "ch5", "ch6", "ch7",
+   "ch8", "ch9", "ch10", "ch11",
+   "ch12", "ch13", "ch14", "ch15";
+   clocks = < CPG_MOD 218>;
+   clock-names = "fck";
+   power-domains = < 32>;
+   resets = < 218>;
+   #dma-cells = <1>;
+   dma-channels = <16>;
};
 
dmac2: dma-controller@e731 {
-   /* placeholder */
+   compatible = "renesas,dmac-r8a77965",
+"renesas,rcar-dmac";
+   reg = <0 0xe731 0 0x1>;
+   interrupts = ;
+   interrupt-names = "error",
+   "ch0", "ch1", "ch2", "ch3",
+   "ch4", "ch5", "ch6", "ch7",
+   "ch8", "ch9", "ch10", "ch11",
+   "ch12", "ch13", "ch14", "ch15";
+   clocks = < CPG_MOD 217>;
+   clock-names = "fck";
+   power-domains = < 32>;
+   resets = < 217>;
+   #dma-cells = <1>;
+   dma-channels = <16>;
};
 
scif0: serial@e6e6 {
-- 
2.7.4



[PATCH v2 13/19] pinctrl: sh-pfc: r8a77965: Add SCIFs groups/functions

2018-02-20 Thread Jacopo Mondi
Add SCIF[0-5] groups and pin function definitions for R-Car M3-N.

Signed-off-by: Jacopo Mondi 
Reviewed-by: Geert Uytterhoeven 

---
v1 -> v2:
- Remove _TANS
---
 drivers/pinctrl/sh-pfc/pfc-r8a77965.c | 296 ++
 1 file changed, 296 insertions(+)

diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a77965.c 
b/drivers/pinctrl/sh-pfc/pfc-r8a77965.c
index 53fe4ec..43ffd63 100644
--- a/drivers/pinctrl/sh-pfc/pfc-r8a77965.c
+++ b/drivers/pinctrl/sh-pfc/pfc-r8a77965.c
@@ -1571,10 +1571,306 @@ static const struct sh_pfc_pin pinmux_pins[] = {
SH_PFC_PIN_NAMED_CFG(ROW_GROUP_A('T'), 30, ASEBRK, CFG_FLAGS),
 };
 
+/* - SCIF0 -- 
*/
+static const unsigned int scif0_data_pins[] = {
+   /* RX, TX */
+   RCAR_GP_PIN(5, 1), RCAR_GP_PIN(5, 2),
+};
+static const unsigned int scif0_data_mux[] = {
+   RX0_MARK, TX0_MARK,
+};
+static const unsigned int scif0_clk_pins[] = {
+   /* SCK */
+   RCAR_GP_PIN(5, 0),
+};
+static const unsigned int scif0_clk_mux[] = {
+   SCK0_MARK,
+};
+static const unsigned int scif0_ctrl_pins[] = {
+   /* RTS, CTS */
+   RCAR_GP_PIN(5, 4), RCAR_GP_PIN(5, 3),
+};
+static const unsigned int scif0_ctrl_mux[] = {
+   RTS0_N_MARK, CTS0_N_MARK,
+};
+/* - SCIF1 -- 
*/
+static const unsigned int scif1_data_a_pins[] = {
+   /* RX, TX */
+   RCAR_GP_PIN(5, 5), RCAR_GP_PIN(5, 6),
+};
+static const unsigned int scif1_data_a_mux[] = {
+   RX1_A_MARK, TX1_A_MARK,
+};
+static const unsigned int scif1_clk_pins[] = {
+   /* SCK */
+   RCAR_GP_PIN(6, 21),
+};
+static const unsigned int scif1_clk_mux[] = {
+   SCK1_MARK,
+};
+static const unsigned int scif1_ctrl_pins[] = {
+   /* RTS, CTS */
+   RCAR_GP_PIN(5, 8), RCAR_GP_PIN(5, 7),
+};
+static const unsigned int scif1_ctrl_mux[] = {
+   RTS1_N_MARK, CTS1_N_MARK,
+};
+static const unsigned int scif1_data_b_pins[] = {
+   /* RX, TX */
+   RCAR_GP_PIN(5, 24), RCAR_GP_PIN(5, 25),
+};
+static const unsigned int scif1_data_b_mux[] = {
+   RX1_B_MARK, TX1_B_MARK,
+};
+/* - SCIF2 -- 
*/
+static const unsigned int scif2_data_a_pins[] = {
+   /* RX, TX */
+   RCAR_GP_PIN(5, 11), RCAR_GP_PIN(5, 10),
+};
+static const unsigned int scif2_data_a_mux[] = {
+   RX2_A_MARK, TX2_A_MARK,
+};
+static const unsigned int scif2_clk_pins[] = {
+   /* SCK */
+   RCAR_GP_PIN(5, 9),
+};
+static const unsigned int scif2_clk_mux[] = {
+   SCK2_MARK,
+};
+static const unsigned int scif2_data_b_pins[] = {
+   /* RX, TX */
+   RCAR_GP_PIN(5, 15), RCAR_GP_PIN(5, 16),
+};
+static const unsigned int scif2_data_b_mux[] = {
+   RX2_B_MARK, TX2_B_MARK,
+};
+/* - SCIF3 -- 
*/
+static const unsigned int scif3_data_a_pins[] = {
+   /* RX, TX */
+   RCAR_GP_PIN(1, 23), RCAR_GP_PIN(1, 24),
+};
+static const unsigned int scif3_data_a_mux[] = {
+   RX3_A_MARK, TX3_A_MARK,
+};
+static const unsigned int scif3_clk_pins[] = {
+   /* SCK */
+   RCAR_GP_PIN(1, 22),
+};
+static const unsigned int scif3_clk_mux[] = {
+   SCK3_MARK,
+};
+static const unsigned int scif3_ctrl_pins[] = {
+   /* RTS, CTS */
+   RCAR_GP_PIN(1, 26), RCAR_GP_PIN(1, 25),
+};
+static const unsigned int scif3_ctrl_mux[] = {
+   RTS3_N_MARK, CTS3_N_MARK,
+};
+static const unsigned int scif3_data_b_pins[] = {
+   /* RX, TX */
+   RCAR_GP_PIN(1, 8), RCAR_GP_PIN(1, 11),
+};
+static const unsigned int scif3_data_b_mux[] = {
+   RX3_B_MARK, TX3_B_MARK,
+};
+/* - SCIF4 -- 
*/
+static const unsigned int scif4_data_a_pins[] = {
+   /* RX, TX */
+   RCAR_GP_PIN(2, 11), RCAR_GP_PIN(2, 12),
+};
+static const unsigned int scif4_data_a_mux[] = {
+   RX4_A_MARK, TX4_A_MARK,
+};
+static const unsigned int scif4_clk_a_pins[] = {
+   /* SCK */
+   RCAR_GP_PIN(2, 10),
+};
+static const unsigned int scif4_clk_a_mux[] = {
+   SCK4_A_MARK,
+};
+static const unsigned int scif4_ctrl_a_pins[] = {
+   /* RTS, CTS */
+   RCAR_GP_PIN(2, 14), RCAR_GP_PIN(2, 13),
+};
+static const unsigned int scif4_ctrl_a_mux[] = {
+   RTS4_N_A_MARK, CTS4_N_A_MARK,
+};
+static const unsigned int scif4_data_b_pins[] = {
+   /* RX, TX */
+   RCAR_GP_PIN(1, 6), RCAR_GP_PIN(1, 7),
+};
+static const unsigned int scif4_data_b_mux[] = {
+   RX4_B_MARK, TX4_B_MARK,
+};
+static const unsigned int scif4_clk_b_pins[] = {
+   /* SCK */
+   RCAR_GP_PIN(1, 5),
+};
+static const unsigned int scif4_clk_b_mux[] = {
+   SCK4_B_MARK,
+};
+static const unsigned int scif4_ctrl_b_pins[] = {
+   /* RTS, CTS */
+   RCAR_GP_PIN(1, 10), RCAR_GP_PIN(1, 9),
+};
+static const unsigned int 

[PATCH v2 14/19] ARM64: dts: r8a77965: Add SCIF device nodes

2018-02-20 Thread Jacopo Mondi
Add SCIF[0-5] device nodes for M3-N (r8a77965) SoC.

Signed-off-by: Jacopo Mondi 
Reviewed-by: Geert Uytterhoeven 

---
v1 -> v2:
- Replace clock and power areas definition with raw numbers
- Fix compatible strings s/r8a7796/r8a77965/
---
 arch/arm64/boot/dts/renesas/r8a77965.dtsi | 85 ---
 1 file changed, 79 insertions(+), 6 deletions(-)

diff --git a/arch/arm64/boot/dts/renesas/r8a77965.dtsi 
b/arch/arm64/boot/dts/renesas/r8a77965.dtsi
index b83dafc..3cb1a33 100644
--- a/arch/arm64/boot/dts/renesas/r8a77965.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a77965.dtsi
@@ -335,27 +335,100 @@
};
 
scif0: serial@e6e6 {
-   /* placeholder */
+   compatible = "renesas,scif-r8a77965",
+"renesas,rcar-gen3-scif", "renesas,scif";
+   reg = <0 0xe6e6 0 64>;
+   interrupts = ;
+   clocks = < CPG_MOD 207>,
+< CPG_CORE 20>,
+<_clk>;
+   clock-names = "fck", "brg_int", "scif_clk";
+   dmas = < 0x51>, < 0x50>,
+  < 0x51>, < 0x50>;
+   dma-names = "tx", "rx", "tx", "rx";
+   power-domains = < 32>;
+   resets = < 207>;
+   status = "disabled";
};
 
scif1: serial@e6e68000 {
-   /* placeholder */
+   compatible = "renesas,scif-r8a77965",
+"renesas,rcar-gen3-scif", "renesas,scif";
+   reg = <0 0xe6e68000 0 64>;
+   interrupts = ;
+   clocks = < CPG_MOD 206>,
+< CPG_CORE 20>,
+<_clk>;
+   clock-names = "fck", "brg_int", "scif_clk";
+   dmas = < 0x53>, < 0x52>,
+  < 0x53>, < 0x52>;
+   dma-names = "tx", "rx", "tx", "rx";
+   power-domains = < 32>;
+   resets = < 206>;
+   status = "disabled";
};
 
scif2: serial@e6e88000 {
-   /* placeholder */
+   compatible = "renesas,scif-r8a77965",
+"renesas,rcar-gen3-scif", "renesas,scif";
+   reg = <0 0xe6e88000 0 64>;
+   interrupts = ;
+   clocks = < CPG_MOD 310>,
+< CPG_CORE 20>,
+<_clk>;
+   clock-names = "fck", "brg_int", "scif_clk";
+   power-domains = < 32>;
+   resets = < 310>;
+   status = "disabled";
};
 
scif3: serial@e6c5 {
-   /* placeholder */
+   compatible = "renesas,scif-r8a77965",
+"renesas,rcar-gen3-scif", "renesas,scif";
+   reg = <0 0xe6c5 0 64>;
+   interrupts = ;
+   clocks = < CPG_MOD 204>,
+< CPG_CORE 20>,
+<_clk>;
+   clock-names = "fck", "brg_int", "scif_clk";
+   dmas = < 0x57>, < 0x56>;
+   dma-names = "tx", "rx";
+   power-domains = < 32>;
+   resets = < 204>;
+   status = "disabled";
};
 
scif4: serial@e6c4 {
-   /* placeholder */
+   compatible = "renesas,scif-r8a77965",
+"renesas,rcar-gen3-scif", "renesas,scif";
+   reg = <0 0xe6c4 0 64>;
+   interrupts = ;
+   clocks = < CPG_MOD 203>,
+< CPG_CORE 20>,
+<_clk>;
+   clock-names = "fck", "brg_int", "scif_clk";
+   dmas = < 0x59>, < 0x58>;
+   dma-names = "tx", "rx";
+   power-domains = < 32>;
+   resets = < 203>;
+   status = "disabled";
};
 
scif5: serial@e6f3 {
-   /* placeholder */
+   compatible = "renesas,scif-r8a77965",
+"renesas,rcar-gen3-scif", "renesas,scif";
+   reg = <0 0xe6f3 0 64>;
+   interrupts = ;
+   clocks = < CPG_MOD 202>,
+< CPG_CORE 20>,
+ 

[PATCH v2 15/19] dt-bindings: gpio: Add support for r8a77965

2018-02-20 Thread Jacopo Mondi
Add compatible string for R-Car M3-N (r8a77965) in gpio-rcar.

Signed-off-by: Jacopo Mondi 
Reviewed-by: Geert Uytterhoeven 

---
v1 -> v2:
- Drop SoC-specific compatible string from drivers/gpio/gpio-rcar.c
- Change patch subject to reflect it only changes dt bindings
---
 Documentation/devicetree/bindings/gpio/renesas,gpio-rcar.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/gpio/renesas,gpio-rcar.txt 
b/Documentation/devicetree/bindings/gpio/renesas,gpio-rcar.txt
index 9474138..f2af897 100644
--- a/Documentation/devicetree/bindings/gpio/renesas,gpio-rcar.txt
+++ b/Documentation/devicetree/bindings/gpio/renesas,gpio-rcar.txt
@@ -14,6 +14,7 @@ Required Properties:
 - "renesas,gpio-r8a7794": for R8A7794 (R-Car E2) compatible GPIO 
controller.
 - "renesas,gpio-r8a7795": for R8A7795 (R-Car H3) compatible GPIO 
controller.
 - "renesas,gpio-r8a7796": for R8A7796 (R-Car M3-W) compatible GPIO 
controller.
+- "renesas,gpio-r8a77965": for R8A77965 (R-Car M3-N) compatible GPIO 
controller.
 - "renesas,gpio-r8a77970": for R8A77970 (R-Car V3M) compatible GPIO 
controller.
 - "renesas,gpio-r8a77995": for R8A77995 (R-Car D3) compatible GPIO 
controller.
 - "renesas,rcar-gen1-gpio": for a generic R-Car Gen1 GPIO controller.
-- 
2.7.4



[PATCH v2 16/19] ARM64: dts: r8a77965: Add GPIO nodes

2018-02-20 Thread Jacopo Mondi
Add GPIO nodes to r8a77965 SoC device tree file.

Signed-off-by: Jacopo Mondi 
Reviewed-by: Geert Uytterhoeven 

---
v1 -> v2:
- Replace ALWAYS_ON power area define with numeric constant
- Do not move gpio nodes
---
 arch/arm64/boot/dts/renesas/r8a77965.dtsi | 104 +++---
 1 file changed, 96 insertions(+), 8 deletions(-)

diff --git a/arch/arm64/boot/dts/renesas/r8a77965.dtsi 
b/arch/arm64/boot/dts/renesas/r8a77965.dtsi
index 3cb1a33..55f05f7 100644
--- a/arch/arm64/boot/dts/renesas/r8a77965.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a77965.dtsi
@@ -197,35 +197,123 @@
};
 
gpio0: gpio@e605 {
-   /* placeholder */
+   compatible = "renesas,gpio-r8a77965",
+"renesas,rcar-gen3-gpio";
+   reg = <0 0xe605 0 0x50>;
+   interrupts = ;
+   #gpio-cells = <2>;
+   gpio-controller;
+   gpio-ranges = < 0 0 16>;
+   #interrupt-cells = <2>;
+   interrupt-controller;
+   clocks = < CPG_MOD 912>;
+   power-domains = < 32>;
+   resets = < 912>;
};
 
gpio1: gpio@e6051000 {
-   /* placeholder */
+   compatible = "renesas,gpio-r8a77965",
+"renesas,rcar-gen3-gpio";
+   reg = <0 0xe6051000 0 0x50>;
+   interrupts = ;
+   #gpio-cells = <2>;
+   gpio-controller;
+   gpio-ranges = < 0 32 29>;
+   #interrupt-cells = <2>;
+   interrupt-controller;
+   clocks = < CPG_MOD 911>;
+   power-domains = < 32>;
+   resets = < 911>;
};
 
gpio2: gpio@e6052000 {
-   /* placeholder */
+   compatible = "renesas,gpio-r8a77965",
+"renesas,rcar-gen3-gpio";
+   reg = <0 0xe6052000 0 0x50>;
+   interrupts = ;
+   #gpio-cells = <2>;
+   gpio-controller;
+   gpio-ranges = < 0 64 15>;
+   #interrupt-cells = <2>;
+   interrupt-controller;
+   clocks = < CPG_MOD 910>;
+   power-domains = < 32>;
+   resets = < 910>;
};
 
gpio3: gpio@e6053000 {
-   /* placeholder */
+   compatible = "renesas,gpio-r8a77965",
+"renesas,rcar-gen3-gpio";
+   reg = <0 0xe6053000 0 0x50>;
+   interrupts = ;
+   #gpio-cells = <2>;
+   gpio-controller;
+   gpio-ranges = < 0 96 16>;
+   #interrupt-cells = <2>;
+   interrupt-controller;
+   clocks = < CPG_MOD 909>;
+   power-domains = < 32>;
+   resets = < 909>;
};
 
gpio4: gpio@e6054000 {
-   /* placeholder */
+   compatible = "renesas,gpio-r8a77965",
+"renesas,rcar-gen3-gpio";
+   reg = <0 0xe6054000 0 0x50>;
+   interrupts = ;
+   #gpio-cells = <2>;
+   gpio-controller;
+   gpio-ranges = < 0 128 18>;
+   #interrupt-cells = <2>;
+   interrupt-controller;
+   clocks = < CPG_MOD 908>;
+   power-domains = < 32>;
+   resets = < 908>;
};
 
gpio5: gpio@e6055000 {
-   /* placeholder */
+   compatible = "renesas,gpio-r8a77965",
+"renesas,rcar-gen3-gpio";
+   reg = <0 0xe6055000 0 0x50>;
+   interrupts = ;
+   #gpio-cells = <2>;
+   gpio-controller;
+   gpio-ranges = < 0 160 26>;
+   #interrupt-cells = <2>;
+   interrupt-controller;
+   clocks = < CPG_MOD 907>;
+   power-domains = < 32>;
+   resets = < 907>;
};
 
gpio6: gpio@e6055400 {
-   /* placeholder */
+   compatible = "renesas,gpio-r8a77965",
+"renesas,rcar-gen3-gpio";
+  

[PATCH v2 18/19] pinctrl: sh-pfc: r8a77965: Add EtherAVB groups/functions

2018-02-20 Thread Jacopo Mondi
Add EtherAVB groups and functions definitions for R-Car M3-N.

Signed-off-by: Jacopo Mondi 
Reviewed-by: Geert Uytterhoeven 
---
 drivers/pinctrl/sh-pfc/pfc-r8a77965.c | 110 ++
 1 file changed, 110 insertions(+)

diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a77965.c 
b/drivers/pinctrl/sh-pfc/pfc-r8a77965.c
index 43ffd63..7b9fea9 100644
--- a/drivers/pinctrl/sh-pfc/pfc-r8a77965.c
+++ b/drivers/pinctrl/sh-pfc/pfc-r8a77965.c
@@ -1571,6 +1571,92 @@ static const struct sh_pfc_pin pinmux_pins[] = {
SH_PFC_PIN_NAMED_CFG(ROW_GROUP_A('T'), 30, ASEBRK, CFG_FLAGS),
 };
 
+/* - EtherAVB --- 
*/
+static const unsigned int avb_link_pins[] = {
+   /* AVB_LINK */
+   RCAR_GP_PIN(2, 12),
+};
+static const unsigned int avb_link_mux[] = {
+   AVB_LINK_MARK,
+};
+static const unsigned int avb_magic_pins[] = {
+   /* AVB_MAGIC_ */
+   RCAR_GP_PIN(2, 10),
+};
+static const unsigned int avb_magic_mux[] = {
+   AVB_MAGIC_MARK,
+};
+static const unsigned int avb_phy_int_pins[] = {
+   /* AVB_PHY_INT */
+   RCAR_GP_PIN(2, 11),
+};
+static const unsigned int avb_phy_int_mux[] = {
+   AVB_PHY_INT_MARK,
+};
+static const unsigned int avb_mdc_pins[] = {
+   /* AVB_MDC, AVB_MDIO */
+   RCAR_GP_PIN(2, 9), PIN_NUMBER('A', 9),
+};
+static const unsigned int avb_mdc_mux[] = {
+   AVB_MDC_MARK, AVB_MDIO_MARK,
+};
+static const unsigned int avb_mii_pins[] = {
+   /*
+* AVB_TX_CTL, AVB_TXC, AVB_TD0,
+* AVB_TD1, AVB_TD2, AVB_TD3,
+* AVB_RX_CTL, AVB_RXC, AVB_RD0,
+* AVB_RD1, AVB_RD2, AVB_RD3,
+* AVB_TXCREFCLK
+*/
+   PIN_NUMBER('A', 8), PIN_NUMBER('A', 19), PIN_NUMBER('A', 18),
+   PIN_NUMBER('B', 18), PIN_NUMBER('A', 17), PIN_NUMBER('B', 17),
+   PIN_NUMBER('A', 16), PIN_NUMBER('B', 19), PIN_NUMBER('A', 13),
+   PIN_NUMBER('B', 13), PIN_NUMBER('A', 14), PIN_NUMBER('B', 14),
+   PIN_NUMBER('A', 12),
+
+};
+static const unsigned int avb_mii_mux[] = {
+   AVB_TX_CTL_MARK, AVB_TXC_MARK, AVB_TD0_MARK,
+   AVB_TD1_MARK, AVB_TD2_MARK, AVB_TD3_MARK,
+   AVB_RX_CTL_MARK, AVB_RXC_MARK, AVB_RD0_MARK,
+   AVB_RD1_MARK, AVB_RD2_MARK, AVB_RD3_MARK,
+   AVB_TXCREFCLK_MARK,
+};
+static const unsigned int avb_avtp_pps_pins[] = {
+   /* AVB_AVTP_PPS */
+   RCAR_GP_PIN(2, 6),
+};
+static const unsigned int avb_avtp_pps_mux[] = {
+   AVB_AVTP_PPS_MARK,
+};
+static const unsigned int avb_avtp_match_a_pins[] = {
+   /* AVB_AVTP_MATCH_A */
+   RCAR_GP_PIN(2, 13),
+};
+static const unsigned int avb_avtp_match_a_mux[] = {
+   AVB_AVTP_MATCH_A_MARK,
+};
+static const unsigned int avb_avtp_capture_a_pins[] = {
+   /* AVB_AVTP_CAPTURE_A */
+   RCAR_GP_PIN(2, 14),
+};
+static const unsigned int avb_avtp_capture_a_mux[] = {
+   AVB_AVTP_CAPTURE_A_MARK,
+};
+static const unsigned int avb_avtp_match_b_pins[] = {
+   /*  AVB_AVTP_MATCH_B */
+   RCAR_GP_PIN(1, 8),
+};
+static const unsigned int avb_avtp_match_b_mux[] = {
+   AVB_AVTP_MATCH_B_MARK,
+};
+static const unsigned int avb_avtp_capture_b_pins[] = {
+   /* AVB_AVTP_CAPTURE_B */
+   RCAR_GP_PIN(1, 11),
+};
+static const unsigned int avb_avtp_capture_b_mux[] = {
+   AVB_AVTP_CAPTURE_B_MARK,
+};
 /* - SCIF0 -- 
*/
 static const unsigned int scif0_data_pins[] = {
/* RX, TX */
@@ -1783,6 +1869,16 @@ static const unsigned int scif_clk_b_mux[] = {
 };
 
 static const struct sh_pfc_pin_group pinmux_groups[] = {
+   SH_PFC_PIN_GROUP(avb_link),
+   SH_PFC_PIN_GROUP(avb_magic),
+   SH_PFC_PIN_GROUP(avb_phy_int),
+   SH_PFC_PIN_GROUP(avb_mdc),
+   SH_PFC_PIN_GROUP(avb_mii),
+   SH_PFC_PIN_GROUP(avb_avtp_pps),
+   SH_PFC_PIN_GROUP(avb_avtp_match_a),
+   SH_PFC_PIN_GROUP(avb_avtp_capture_a),
+   SH_PFC_PIN_GROUP(avb_avtp_match_b),
+   SH_PFC_PIN_GROUP(avb_avtp_capture_b),
SH_PFC_PIN_GROUP(scif0_data),
SH_PFC_PIN_GROUP(scif0_clk),
SH_PFC_PIN_GROUP(scif0_ctrl),
@@ -1814,6 +1910,19 @@ static const struct sh_pfc_pin_group pinmux_groups[] = {
SH_PFC_PIN_GROUP(scif_clk_b),
 };
 
+static const char * const avb_groups[] = {
+   "avb_link",
+   "avb_magic",
+   "avb_phy_int",
+   "avb_mdc",
+   "avb_mii",
+   "avb_avtp_pps",
+   "avb_avtp_match_a",
+   "avb_avtp_capture_a",
+   "avb_avtp_match_b",
+   "avb_avtp_capture_b",
+};
+
 static const char * const scif0_groups[] = {
"scif0_data",
"scif0_clk",
@@ -1864,6 +1973,7 @@ static const char * const scif_clk_groups[] = {
 };
 
 static const struct sh_pfc_function pinmux_functions[] = {
+   SH_PFC_FUNCTION(avb),
SH_PFC_FUNCTION(scif0),
SH_PFC_FUNCTION(scif1),
SH_PFC_FUNCTION(scif2),
-- 
2.7.4



[PATCH v2 17/19] dt-bindings: net: ravb: Add support for r8a77965 SoC

2018-02-20 Thread Jacopo Mondi
Add documentation for r8a77965 compatible string to renesas ravb device
tree bindings documentation.

Signed-off-by: Jacopo Mondi 
Reviewed-by: Geert Uytterhoeven 
Reviewed-by: Simon Horman 
Acked-by: Sergei Shtylyov 

Cc: sergei.shtyl...@cogentembedded.com, net...@vger.kernel.org
---
 Documentation/devicetree/bindings/net/renesas,ravb.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/net/renesas,ravb.txt 
b/Documentation/devicetree/bindings/net/renesas,ravb.txt
index c902261..bf071a5 100644
--- a/Documentation/devicetree/bindings/net/renesas,ravb.txt
+++ b/Documentation/devicetree/bindings/net/renesas,ravb.txt
@@ -17,6 +17,7 @@ Required properties:
 
   - "renesas,etheravb-r8a7795" for the R8A7795 SoC.
   - "renesas,etheravb-r8a7796" for the R8A7796 SoC.
+  - "renesas,etheravb-r8a77965" for the R8A77965 SoC.
   - "renesas,etheravb-r8a77970" for the R8A77970 SoC.
   - "renesas,etheravb-r8a77995" for the R8A77995 SoC.
   - "renesas,etheravb-rcar-gen3" as a fallback for the above
-- 
2.7.4



[PATCH v2 19/19] ARM64: dts: r8a77965: Add EtherAVB device node

2018-02-20 Thread Jacopo Mondi
Populate the ethernet@e680 device node to enable Ethernet interface
for R-Car M3-N (r8a77965) SoC.

Signed-off-by: Jacopo Mondi 
Reviewed-by: Geert Uytterhoeven 

---
v1 -> v2:
- Replace ALWAYS_ON power area identifier with numeric constant
---
 arch/arm64/boot/dts/renesas/r8a77965.dtsi | 43 ++-
 1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/renesas/r8a77965.dtsi 
b/arch/arm64/boot/dts/renesas/r8a77965.dtsi
index 55f05f7..c249895 100644
--- a/arch/arm64/boot/dts/renesas/r8a77965.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a77965.dtsi
@@ -520,7 +520,48 @@
};
 
avb: ethernet@e680 {
-   /* placeholder */
+   compatible = "renesas,etheravb-r8a77965",
+"renesas,etheravb-rcar-gen3";
+   reg = <0 0xe680 0 0x800>, <0 0xe6a0 0 0x1>;
+   interrupts = ,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+;
+   interrupt-names = "ch0", "ch1", "ch2", "ch3",
+ "ch4", "ch5", "ch6", "ch7",
+ "ch8", "ch9", "ch10", "ch11",
+ "ch12", "ch13", "ch14", "ch15",
+ "ch16", "ch17", "ch18", "ch19",
+ "ch20", "ch21", "ch22", "ch23",
+ "ch24";
+   clocks = < CPG_MOD 812>;
+   power-domains = < 32>;
+   resets = < 812>;
+   phy-mode = "rgmii-txid";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   status = "disabled";
};
 
csi20: csi2@fea8 {
-- 
2.7.4



[PATCH v2 01/19] clk: renesas: cpg-mssr: Add support for R-Car M3-N

2018-02-20 Thread Jacopo Mondi
Initial support for R-Car M3-N (r8a77965), including core and module
clocks.

Based on Table 8.2d of "R-Car Series, 3rd Generation User's Manual:
Hardware (Rev. 0.80, Oct 31, 2017)".

Signed-off-by: Jacopo Mondi 
Reviewed-by: Geert Uytterhoeven 

---
v1->v2:
- Add 'z' clock
- Change "intc-ap" parent clock to S0D3
---
 .../devicetree/bindings/clock/renesas,cpg-mssr.txt |   1 +
 drivers/clk/renesas/Kconfig|   5 +
 drivers/clk/renesas/Makefile   |   1 +
 drivers/clk/renesas/r8a77965-cpg-mssr.c| 334 +
 drivers/clk/renesas/renesas-cpg-mssr.c |   6 +
 drivers/clk/renesas/renesas-cpg-mssr.h |   1 +
 include/dt-bindings/clock/r8a77965-cpg-mssr.h  |  62 
 7 files changed, 410 insertions(+)
 create mode 100644 drivers/clk/renesas/r8a77965-cpg-mssr.c
 create mode 100644 include/dt-bindings/clock/r8a77965-cpg-mssr.h

diff --git a/Documentation/devicetree/bindings/clock/renesas,cpg-mssr.txt 
b/Documentation/devicetree/bindings/clock/renesas,cpg-mssr.txt
index f1890d0..246ab63 100644
--- a/Documentation/devicetree/bindings/clock/renesas,cpg-mssr.txt
+++ b/Documentation/devicetree/bindings/clock/renesas,cpg-mssr.txt
@@ -22,6 +22,7 @@ Required Properties:
   - "renesas,r8a7794-cpg-mssr" for the r8a7794 SoC (R-Car E2)
   - "renesas,r8a7795-cpg-mssr" for the r8a7795 SoC (R-Car H3)
   - "renesas,r8a7796-cpg-mssr" for the r8a7796 SoC (R-Car M3-W)
+  - "renesas,r8a77965-cpg-mssr" for the r8a77965 SoC (R-Car M3-N)
   - "renesas,r8a77970-cpg-mssr" for the r8a77970 SoC (R-Car V3M)
   - "renesas,r8a77995-cpg-mssr" for the r8a77995 SoC (R-Car D3)
 
diff --git a/drivers/clk/renesas/Kconfig b/drivers/clk/renesas/Kconfig
index 84b40b9..047d6b5 100644
--- a/drivers/clk/renesas/Kconfig
+++ b/drivers/clk/renesas/Kconfig
@@ -15,6 +15,7 @@ config CLK_RENESAS
select CLK_R8A7794 if ARCH_R8A7794
select CLK_R8A7795 if ARCH_R8A7795
select CLK_R8A7796 if ARCH_R8A7796
+   select CLK_R8A77965 if ARCH_R8A77965
select CLK_R8A77970 if ARCH_R8A77970
select CLK_R8A77995 if ARCH_R8A77995
select CLK_SH73A0 if ARCH_SH73A0
@@ -97,6 +98,10 @@ config CLK_R8A7796
bool "R-Car M3-W clock support" if COMPILE_TEST
select CLK_RCAR_GEN3_CPG
 
+config CLK_R8A77965
+   bool "R-Car M3-N clock support" if COMPILE_TEST
+   select CLK_RCAR_GEN3_CPG
+
 config CLK_R8A77970
bool "R-Car V3M clock support" if COMPILE_TEST
select CLK_RCAR_GEN3_CPG
diff --git a/drivers/clk/renesas/Makefile b/drivers/clk/renesas/Makefile
index 34c4e0b..2e0982f 100644
--- a/drivers/clk/renesas/Makefile
+++ b/drivers/clk/renesas/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_CLK_R8A7792) += r8a7792-cpg-mssr.o
 obj-$(CONFIG_CLK_R8A7794)  += r8a7794-cpg-mssr.o
 obj-$(CONFIG_CLK_R8A7795)  += r8a7795-cpg-mssr.o
 obj-$(CONFIG_CLK_R8A7796)  += r8a7796-cpg-mssr.o
+obj-$(CONFIG_CLK_R8A77965) += r8a77965-cpg-mssr.o
 obj-$(CONFIG_CLK_R8A77970) += r8a77970-cpg-mssr.o
 obj-$(CONFIG_CLK_R8A77995) += r8a77995-cpg-mssr.o
 obj-$(CONFIG_CLK_SH73A0)   += clk-sh73a0.o
diff --git a/drivers/clk/renesas/r8a77965-cpg-mssr.c 
b/drivers/clk/renesas/r8a77965-cpg-mssr.c
new file mode 100644
index 000..41e506a
--- /dev/null
+++ b/drivers/clk/renesas/r8a77965-cpg-mssr.c
@@ -0,0 +1,334 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * r8a77965 Clock Pulse Generator / Module Standby and Software Reset
+ *
+ * Copyright (C) 2018 Jacopo Mondi 
+ *
+ * Based on r8a7795-cpg-mssr.c
+ *
+ * Copyright (C) 2015 Glider bvba
+ * Copyright (C) 2015 Renesas Electronics Corp.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "renesas-cpg-mssr.h"
+#include "rcar-gen3-cpg.h"
+
+enum clk_ids {
+   /* Core Clock Outputs exported to DT */
+   LAST_DT_CORE_CLK = R8A77965_CLK_OSC,
+
+   /* External Input Clocks */
+   CLK_EXTAL,
+   CLK_EXTALR,
+
+   /* Internal Core Clocks */
+   CLK_MAIN,
+   CLK_PLL0,
+   CLK_PLL1,
+   CLK_PLL3,
+   CLK_PLL4,
+   CLK_PLL1_DIV2,
+   CLK_PLL1_DIV4,
+   CLK_S0,
+   CLK_S1,
+   CLK_S2,
+   CLK_S3,
+   CLK_SDSRC,
+   CLK_SSPSRC,
+   CLK_RINT,
+
+   /* Module Clocks */
+   MOD_CLK_BASE
+};
+
+static const struct cpg_core_clk r8a77965_core_clks[] __initconst = {
+   /* External Clock Inputs */
+   DEF_INPUT("extal",  CLK_EXTAL),
+   DEF_INPUT("extalr", CLK_EXTALR),
+
+   /* Internal Core Clocks */
+   DEF_BASE(".main",   CLK_MAIN, CLK_TYPE_GEN3_MAIN, CLK_EXTAL),
+   DEF_BASE(".pll0",   CLK_PLL0, CLK_TYPE_GEN3_PLL0, CLK_MAIN),
+   DEF_BASE(".pll1",   CLK_PLL1, CLK_TYPE_GEN3_PLL1, CLK_MAIN),
+   DEF_BASE(".pll3",   CLK_PLL3, CLK_TYPE_GEN3_PLL3, CLK_MAIN),
+   

[PATCH v2 00/19] R-Car M3-N initial support

2018-02-20 Thread Jacopo Mondi
Hello, second round for R-Car M3-N SoC and M3-N based Salvator-X board.

I have fixed all comments I have received and re-based on latest Geert's
renesas-drivers-2018-02-13-v4.16-rc1

I have applied requested changes, and updated PFC tables to comply with
last patches applied to r8a7796 that were not part of v4.15 which v1 was
based on.

I have added a per-patch change log as summarizing all little changes here
had not real benefit imho, being them mostly tiny changes specific to each
patch.

As a general note, I have split patches and bindings where requested and split
single patches in multiple ones where opportune (mostly when adding components
to drivers/soc/ and when introducing board and SoC DT files).

Tested serial console output and Ethernet interface.

Thanks
   j

v1 -> v2:
- Rebased on renesas-drivers-2018-02-13-v4.16-rc1
- Split patches when introducing rst, sysc in drivers/soc/
- Split patches when adding device tree file for Salvator-X board and
  r8a77965 SoC.
- Single change logs are reported per-patch

Jacopo Mondi (19):
  clk: renesas: cpg-mssr: Add support for R-Car M3-N
  soc: renesas: rcar-rst: Add support for R-Car M3-N
  soc: renesas: Identify R-Car M3-N
  soc: renesas: rcar-sysc: Add R-Car M3-N support
  pinctrl: sh-pfc: Initial R-Car M3-N support
  dt-bindings: arm: Document R-Car M3-N SoC DT bindings
  ARM64: Add Renesas R-Car M3-N config symbol
  ARM64: dts: Add Renesas R8A77965 SoC support
  ARM64: dts: Add R-Car Salvator-x M3-N support
  dt-bindings: dmaengine: rcar-dmac: document R8A77965 support
  ARM64: dts: r8a77965: Add dmac device nods
  dt-bindings: serial: sh-sci: Add support for r8a77965 (H)SCIF
  pinctrl: sh-pfc: r8a77965: Add SCIFs groups/functions
  ARM64: dts: r8a77965: Add SCIF device nodes
  dt-bindings: gpio: Add support for r8a77965
  ARM64: dts: r8a77965: Add GPIO nodes
  dt-bindings: net: ravb: Add support for r8a77965 SoC
  pinctrl: sh-pfc: r8a77965: Add EtherAVB groups/functions
  ARM64: dts: r8a77965: Add EtherAVB device node

 Documentation/devicetree/bindings/arm/shmobile.txt |2 +
 .../devicetree/bindings/clock/renesas,cpg-mssr.txt |1 +
 .../devicetree/bindings/dma/renesas,rcar-dmac.txt  |1 +
 .../devicetree/bindings/gpio/renesas,gpio-rcar.txt |1 +
 .../devicetree/bindings/net/renesas,ravb.txt   |1 +
 .../bindings/pinctrl/renesas,pfc-pinctrl.txt   |1 +
 .../bindings/power/renesas,rcar-sysc.txt   |1 +
 .../devicetree/bindings/reset/renesas,rst.txt  |1 +
 .../bindings/serial/renesas,sci-serial.txt |2 +
 arch/arm64/Kconfig.platforms   |6 +
 arch/arm64/boot/dts/renesas/Makefile   |1 +
 .../arm64/boot/dts/renesas/r8a77965-salvator-x.dts |   21 +
 arch/arm64/boot/dts/renesas/r8a77965.dtsi  |  782 +
 drivers/clk/renesas/Kconfig|5 +
 drivers/clk/renesas/Makefile   |1 +
 drivers/clk/renesas/r8a77965-cpg-mssr.c|  334 +++
 drivers/clk/renesas/renesas-cpg-mssr.c |6 +
 drivers/clk/renesas/renesas-cpg-mssr.h |1 +
 drivers/pinctrl/sh-pfc/Kconfig |5 +
 drivers/pinctrl/sh-pfc/Makefile|1 +
 drivers/pinctrl/sh-pfc/core.c  |6 +
 drivers/pinctrl/sh-pfc/pfc-r8a77965.c  | 3128 
 drivers/pinctrl/sh-pfc/sh_pfc.h|1 +
 drivers/soc/renesas/Kconfig|9 +-
 drivers/soc/renesas/Makefile   |1 +
 drivers/soc/renesas/r8a77965-sysc.c|   37 +
 drivers/soc/renesas/rcar-rst.c |1 +
 drivers/soc/renesas/rcar-sysc.c|3 +
 drivers/soc/renesas/rcar-sysc.h|1 +
 drivers/soc/renesas/renesas-soc.c  |8 +
 include/dt-bindings/clock/r8a77965-cpg-mssr.h  |   62 +
 include/dt-bindings/power/r8a77965-sysc.h  |   30 +
 32 files changed, 4459 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm64/boot/dts/renesas/r8a77965-salvator-x.dts
 create mode 100644 arch/arm64/boot/dts/renesas/r8a77965.dtsi
 create mode 100644 drivers/clk/renesas/r8a77965-cpg-mssr.c
 create mode 100644 drivers/pinctrl/sh-pfc/pfc-r8a77965.c
 create mode 100644 drivers/soc/renesas/r8a77965-sysc.c
 create mode 100644 include/dt-bindings/clock/r8a77965-cpg-mssr.h
 create mode 100644 include/dt-bindings/power/r8a77965-sysc.h

--
2.7.4



Re: [PATCH 3/4] pinctrl: sh-pfc: r8a77995: Add VIN4 pins, groups and function

2018-02-20 Thread Geert Uytterhoeven
On Thu, Feb 15, 2018 at 1:01 PM, Ulrich Hecht
 wrote:
> This patch adds VIN4 pins, groups and function for the
> R8A77995 (D3) SoC.
>
> Signed-off-by: Ulrich Hecht 

Reviewed-by: Geert Uytterhoeven 

But same comments as for r8a779[56].

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH v3 03/12] drm: rcar-du: Fix legacy DT to create LVDS encoder nodes

2018-02-20 Thread Rob Herring
On Tue, Feb 20, 2018 at 3:15 AM, Laurent Pinchart
 wrote:
> Hi Rob,
>
> On Tuesday, 20 February 2018 02:54:00 EET Rob Herring wrote:
>> On Wed, Feb 14, 2018 at 6:04 PM, Laurent Pinchart wrote:
>> > The internal LVDS encoders now have their own DT bindings. Before
>> > switching the driver infrastructure to those new bindings, implement
>> > backward-compatibility through live DT patching.
>> >
>> > Patching is disabled and will be enabled along with support for the new
>> > DT bindings in the DU driver.
>> >
>> > Signed-off-by: Laurent Pinchart
>> > 

>> > +static int __init rcar_du_of_add_property(struct device_node *np,
>> > + const char *name, const void
>> > *value,
>> > + size_t length)
>>
>> So, were you going to revive Pantelis' patch or move this to the core?
>
> Do you have a pointer to that patch ?

https://patchwork.kernel.org/patch/9104571/
https://patchwork.kernel.org/patch/9104591/
https://patchwork.kernel.org/patch/9104611/
https://patchwork.kernel.org/patch/9104581/
https://patchwork.kernel.org/patch/9104601/


Re: [PATCH 2/4] pinctrl: sh-pfc: r8a7795: Add VIN4, VIN5 pins, groups and functions

2018-02-20 Thread Geert Uytterhoeven
On Thu, Feb 15, 2018 at 1:01 PM, Ulrich Hecht
 wrote:
> This patch adds VIN4 and VIN5 pins, groups and functions for the
> R8A7795 SoC.
>
> Signed-off-by: Ulrich Hecht 

Reviewed-by: Geert Uytterhoeven 

But same comments as for r8a7796.

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH 1/4] pinctrl: sh-pfc: r8a7796: Add VIN4, VIN5 pins, groups and functions

2018-02-20 Thread Geert Uytterhoeven
Hi Uli,

On Thu, Feb 15, 2018 at 1:01 PM, Ulrich Hecht
 wrote:
> This patch adds VIN4 and VIN5 pins, groups and functions for the
> R8A7796 SoC.
>
> Signed-off-by: Ulrich Hecht 

Thanks for your patch!

Reviewed-by: Geert Uytterhoeven 

However, I guess you can use union vin_data and VIN_DATA_PIN_GROUP() to
reduce duplication, like on R-Car Gen2?

Would there be a use case for vin4_data4 and vin5_data4, or is that
mode only supported on R-Car H2?

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH 11/15] gpio: rcar: Add R-Car M3-N compatible string

2018-02-20 Thread Geert Uytterhoeven
Hi Jacopo,

On Tue, Feb 20, 2018 at 2:35 PM, jacopo mondi  wrote:
> On Wed, Feb 14, 2018 at 03:05:05PM +0100, Geert Uytterhoeven wrote:
>> On Tue, Feb 13, 2018 at 10:45 AM, Jacopo Mondi
>>  wrote:
>> > Add compatible string for R-Car M3-N (r8a77965) in gpio-rcar.
>> >
>> > Signed-off-by: Jacopo Mondi 
>>
>> > --- a/drivers/gpio/gpio-rcar.c
>> > +++ b/drivers/gpio/gpio-rcar.c
>> > @@ -360,6 +360,10 @@ static const struct of_device_id gpio_rcar_of_table[] 
>> > = {
>> > /* Gen3 GPIO is identical to Gen2. */
>> > .data = _rcar_info_gen2,
>> > }, {
>> > +   .compatible = "renesas,gpio-r8a77965",
>> > +   /* Gen3 GPIO is identical to Gen2. */
>> > +   .data = _rcar_info_gen2,
>> > +   }, {
>>
>> This part is not needed, as the driver already matches agains the generic
>> "renesas,rcar-gen3-gpio".
>
> Just to point out that the compatible string is there for M3-W and H3.
> Anyway, if that's not good practice to add per-SoC strings here, I'll
> drop this bit.

That's correct. Initially, we added the H3 string first, and the M3-W later.
After that we learned about new future Gen3 members, and we started using
the family-specific one.

Note that we cannot drop the strings for H3 and M3-W from the driver, as
old DTBs do not have the family-specific strings.

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH 11/15] gpio: rcar: Add R-Car M3-N compatible string

2018-02-20 Thread jacopo mondi
Hi Geert,

On Wed, Feb 14, 2018 at 03:05:05PM +0100, Geert Uytterhoeven wrote:
> On Tue, Feb 13, 2018 at 10:45 AM, Jacopo Mondi
>  wrote:
> > Add compatible string for R-Car M3-N (r8a77965) in gpio-rcar.
> >
> > Signed-off-by: Jacopo Mondi 
>
> > --- a/drivers/gpio/gpio-rcar.c
> > +++ b/drivers/gpio/gpio-rcar.c
> > @@ -360,6 +360,10 @@ static const struct of_device_id gpio_rcar_of_table[] 
> > = {
> > /* Gen3 GPIO is identical to Gen2. */
> > .data = _rcar_info_gen2,
> > }, {
> > +   .compatible = "renesas,gpio-r8a77965",
> > +   /* Gen3 GPIO is identical to Gen2. */
> > +   .data = _rcar_info_gen2,
> > +   }, {
>
> This part is not needed, as the driver already matches agains the generic
> "renesas,rcar-gen3-gpio".

Just to point out that the compatible string is there for M3-W and H3.
Anyway, if that's not good practice to add per-SoC strings here, I'll
drop this bit.

Thanks
   j

>
> > .compatible = "renesas,rcar-gen1-gpio",
> > .data = _rcar_info_gen1,
> > }, {
>
> With the above fixed:
> Reviewed-by: Geert Uytterhoeven 
>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- 
> ge...@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like 
> that.
> -- Linus Torvalds


Re: [PATCH/RFC 01/11] clk: renesas: r8a7792: Add rwdt clock

2018-02-20 Thread Geert Uytterhoeven
On Mon, Feb 12, 2018 at 6:50 PM, Fabrizio Castro
 wrote:
>> Subject: [PATCH/RFC 01/11] clk: renesas: r8a7792: Add rwdt clock
>>
>> Add "rwdt" clock to r8a7792_mod_clks. Also, since we may need to access
>> the watchdog registers at any time, declare the clock as critical.
>>
>> Signed-off-by: Geert Uytterhoeven 
>
> Acked-by: Fabrizio Castro 

Thanks, queued in clk-renesas-for-v4.17.

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH v5 00/26] Fix watchdog on Renesas R-Car Gen2 and RZ/G1

2018-02-20 Thread Geert Uytterhoeven
On Mon, Feb 12, 2018 at 6:44 PM, Fabrizio Castro
 wrote:
> this series has been around for some time as RFC, and it has collected
> useful comments from the community along the way.
> The solution proposed by this patch set works for most R-Car Gen2 and
> RZ/G1 devices, but not all of them. We now know that for some R-Car
> Gen2 early revisions there is no proper software fix. Anyway, no
> product has been built around early revisions, but development boards
> mounting early revisions (basically prototypes) are still out there.
> As a result, this series isn't enabling the internal watchdog on R-Car
> Gen2 boards, developers may enable it in board specific device trees
> if needed.
> This series has been tested by me on the iwg20d, iwg22d, Lager, Alt,
> and Koelsch boards.
>
> The problem
> ===
> To deal with SMP on R-Car Gen2 and RZ/G1, we install a reset vector
> to ICRAM1 and we program the [S]BAR registers so that when we turn ON
> the non-boot CPUs they are redirected to the reset vector installed by
> Linux in ICRAM1, and eventually they continue the execution to RAM,
> where the SMP bring-up code will take care of the rest.
> The content of the [S]BAR registers survives a watchdog triggered reset,
> and as such after the watchdog fires the boot core will try and execute
> the SMP bring-up code instead of jumping to the bootrom code.
>
> The fix
> ===
> The main strategy for the solution is to let the reset vector decide
> if it needs to jump to shmobile_boot_fn or to the bootrom code.
> In a watchdog triggered reset scenario, since the [S]BAR registers keep
> their values, the boot CPU will jump into the newly designed reset
> vector, the assembly routine will eventually test WOVF (a bit in register
> RWTCSRA that indicates if the watchdog counter has overflown, the value
> of this bit gets retained in this scenario), and jump to the bootrom code
> which will in turn load up the bootloader, etc.
> When bringing up SMP or using CPU hotplug, the reset vector will jump
> to shmobile_boot_fn instead.
>
> Thank you All for your help.
>
> Best regards,
>
> Fabrizio Castro (26):
>   ARM: shmobile: Add watchdog support
>   ARM: dts: r8a7743: Adjust SMP routine size
>   ARM: dts: r8a7745: Adjust SMP routine size
>   ARM: dts: r8a7790: Adjust SMP routine size
>   ARM: dts: r8a7791: Adjust SMP routine size
>   ARM: dts: r8a7792: Adjust SMP routine size
>   ARM: dts: r8a7793: Adjust SMP routine size
>   ARM: dts: r8a7794: Adjust SMP routine size
>   soc: renesas: rcar-rst: Enable watchdog as reset trigger for Gen2
>   ARM: shmobile: rcar-gen2: Add watchdog support
>   dt-bindings: watchdog: renesas-wdt: Add R-Car Gen2 support
>   watchdog: renesas_wdt: Add R-Car Gen2 support
>   watchdog: renesas_wdt: Add restart handler
>   ARM: shmobile: defconfig: Enable RENESAS_WDT_GEN
>   clk: renesas: r8a7743: Add rwdt clock
>   clk: renesas: r8a7745: Add rwdt clock
>   clk: renesas: r8a7790: Add rwdt clock
>   clk: renesas: r8a7791/r8a7793: Add rwdt clock
>   clk: renesas: r8a7794: Add rwdt clock
>   ARM: dts: r8a7743: Add watchdog support to SoC dtsi
>   ARM: dts: r8a7745: Add watchdog support to SoC dtsi
>   ARM: dts: r8a7790: Add watchdog support to SoC dtsi
>   ARM: dts: r8a7791: Add watchdog support to SoC dtsi
>   ARM: dts: r8a7794: Add watchdog support to SoC dtsi
>   ARM: dts: iwg20m: Add watchdog support to SoM dtsi
>   ARM: dts: iwg22m: Add watchdog support to SoM dtsi
>
>  .../devicetree/bindings/watchdog/renesas-wdt.txt   | 19 ++--
>  arch/arm/boot/dts/r8a7743-iwg20m.dtsi  |  5 ++
>  arch/arm/boot/dts/r8a7743.dtsi | 12 -
>  arch/arm/boot/dts/r8a7745-iwg22m.dtsi  |  5 ++
>  arch/arm/boot/dts/r8a7745.dtsi | 12 -
>  arch/arm/boot/dts/r8a7790.dtsi | 12 -
>  arch/arm/boot/dts/r8a7791.dtsi | 12 -
>  arch/arm/boot/dts/r8a7792.dtsi |  2 +-
>  arch/arm/boot/dts/r8a7793.dtsi |  2 +-
>  arch/arm/boot/dts/r8a7794.dtsi | 12 -
>  arch/arm/configs/shmobile_defconfig|  1 +
>  arch/arm/mach-shmobile/common.h|  6 +++
>  arch/arm/mach-shmobile/headsmp.S   | 55 
> ++
>  arch/arm/mach-shmobile/platsmp-apmu.c  |  1 +
>  arch/arm/mach-shmobile/pm-rcar-gen2.c  | 15 --
>  drivers/clk/renesas/r8a7743-cpg-mssr.c |  2 +
>  drivers/clk/renesas/r8a7745-cpg-mssr.c |  2 +
>  drivers/clk/renesas/r8a7790-cpg-mssr.c |  2 +
>  drivers/clk/renesas/r8a7791-cpg-mssr.c |  2 +
>  drivers/clk/renesas/r8a7794-cpg-mssr.c |  2 +
>  drivers/soc/renesas/rcar-rst.c | 35 +++---
>  drivers/watchdog/renesas_wdt.c | 39 +--

Thanks, I've queued the clock patches in clk-renesas-for-v4.17, as they are
a hard dependency 

Re: [PATCH v2 0/2] Renesas R8A77980 CPG/MSSR clock support

2018-02-20 Thread Geert Uytterhoeven
On Thu, Feb 15, 2018 at 12:54 PM, Sergei Shtylyov
 wrote:
> Here's the set of 2 patches against the 'clk-renesas' branch of Geert 
> Uytterhoeven's
> 'renesas-drivers.git' repo. We're adding the CPG/MSSR driver support for 
> R8A77980...
>
> [1/2] dt-bindings: clock: add R8A77980 CPG core clock definitions
> [2/2] clk: renesas: cpg-mssr: add R8A77980 support

Thanks, queued in clk-renesas-for-v4.17.

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH 9/9] serial: xuartps: Fix out-of-bounds access through DT alias

2018-02-20 Thread Michal Simek
On 20.2.2018 13:27, Geert Uytterhoeven wrote:
> Hi Michal,
> 
> On Tue, Feb 20, 2018 at 12:27 PM, Michal Simek  
> wrote:
>> On 20.2.2018 11:38, Geert Uytterhoeven wrote:
>>> On Tue, Feb 20, 2018 at 11:22 AM, Michal Simek  
>>> wrote:
 On 20.2.2018 10:40, Geert Uytterhoeven wrote:
> The cdns_uart_port[] array is indexed using a value derived from the
> "serialN" alias in DT, which may lead to an out-of-bounds access.
>
> Fix this by adding a range check.
> 
>> I have checked 4 patches I have sent in past which didn't reach mainline
>> (probably because of RFC)
>> Take a look at
>> https://www.spinics.net/lists/linux-serial/msg27106.html
>>
>> I have removed cdns_uart_port array completely there.
> 
> Nice! I'd love to get rid of fixed arrays in serial...
> 
> However, IMHO it's still worthwhile to fix the out-of-bounds access first,
> as that fix can be backported to stable kernels easily.

I agree with you. Not a problem with your patch and for me it won't be
problem to rebase.

I would love to get rid of CDNS_UART_NR_PORTS but unfortunately this is
passed to core via .nr.

Thanks,
Michal




Applied "regulator: Fix resume from suspend to idle" to the regulator tree

2018-02-20 Thread Mark Brown
The patch

   regulator: Fix resume from suspend to idle

has been applied to the regulator tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 35b5f14ec6dab281346a2d0ceb34abe2dba94190 Mon Sep 17 00:00:00 2001
From: Geert Uytterhoeven 
Date: Tue, 13 Feb 2018 10:37:59 +0100
Subject: [PATCH] regulator: Fix resume from suspend to idle

When resuming from idle with the new suspend mode configuration support
we go through the resume callbacks with a state of PM_SUSPEND_TO_IDLE
which we don't have regulator constraints for, causing an error:

dpm_run_callback(): regulator_resume_early+0x0/0x64 returns -22
PM: Device regulator.0 failed to resume early: error -22

Avoid this and similar errors by treating missing constraints as a noop.

See also commit 57a0dd187956ea04 ("regulator: Fix suspend to idle"),
which fixed the suspend part.

Signed-off-by: Geert Uytterhoeven 
Signed-off-by: Mark Brown 
---
 drivers/regulator/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index dd4708c58480..1fc0c0811da4 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -4310,7 +4310,7 @@ static int _regulator_resume_early(struct device *dev, 
void *data)
 
rstate = regulator_get_suspend_state(rdev, *state);
if (rstate == NULL)
-   return -EINVAL;
+   return 0;
 
mutex_lock(>mutex);
 
-- 
2.16.1



Re: [PATCH 9/9] serial: xuartps: Fix out-of-bounds access through DT alias

2018-02-20 Thread Geert Uytterhoeven
Hi Michal,

On Tue, Feb 20, 2018 at 12:27 PM, Michal Simek  wrote:
> On 20.2.2018 11:38, Geert Uytterhoeven wrote:
>> On Tue, Feb 20, 2018 at 11:22 AM, Michal Simek  
>> wrote:
>>> On 20.2.2018 10:40, Geert Uytterhoeven wrote:
 The cdns_uart_port[] array is indexed using a value derived from the
 "serialN" alias in DT, which may lead to an out-of-bounds access.

 Fix this by adding a range check.

> I have checked 4 patches I have sent in past which didn't reach mainline
> (probably because of RFC)
> Take a look at
> https://www.spinics.net/lists/linux-serial/msg27106.html
>
> I have removed cdns_uart_port array completely there.

Nice! I'd love to get rid of fixed arrays in serial...

However, IMHO it's still worthwhile to fix the out-of-bounds access first,
as that fix can be backported to stable kernels easily.

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH 9/9] serial: xuartps: Fix out-of-bounds access through DT alias

2018-02-20 Thread Michal Simek
On 20.2.2018 11:38, Geert Uytterhoeven wrote:
> Hi Michal,
> 
> On Tue, Feb 20, 2018 at 11:22 AM, Michal Simek  
> wrote:
>> On 20.2.2018 10:40, Geert Uytterhoeven wrote:
>>> The cdns_uart_port[] array is indexed using a value derived from the
>>> "serialN" alias in DT, which may lead to an out-of-bounds access.
>>>
>>> Fix this by adding a range check.
>>>
>>> Fixes: 1f118c02a1819856 ("serial: xuartps: Fix out-of-bounds access through 
>>> DT alias")
>>
>> I didn't find this sha1 - patch name is this one.
> 
> Bummer, I totally screwed up my scripting...
> 
> Fixes: 928e9263492069ee ("tty: xuartps: Initialize ports according to 
> aliases")
> 
>>> Signed-off-by: Geert Uytterhoeven 
>>> ---
>>>  drivers/tty/serial/xilinx_uartps.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/tty/serial/xilinx_uartps.c 
>>> b/drivers/tty/serial/xilinx_uartps.c
>>> index b9b2bc76bcac606c..abcb4d09a2d866d0 100644
>>> --- a/drivers/tty/serial/xilinx_uartps.c
>>> +++ b/drivers/tty/serial/xilinx_uartps.c
>>> @@ -1110,7 +1110,7 @@ static struct uart_port *cdns_uart_get_port(int id)
>>>   struct uart_port *port;
>>>
>>>   /* Try the given port id if failed use default method */
>>> - if (cdns_uart_port[id].mapbase != 0) {
>>> + if (id < CDNS_UART_NR_PORTS && cdns_uart_port[id].mapbase != 0) {
>>>   /* Find the next unused port */
>>>   for (id = 0; id < CDNS_UART_NR_PORTS; id++)
>>>   if (cdns_uart_port[id].mapbase == 0)
>>>
>>
>> Below should be better fix for this driver.
> 
> I considered that, too, but...
> 
>> --- a/drivers/tty/serial/xilinx_uartps.c
>> +++ b/drivers/tty/serial/xilinx_uartps.c
>> @@ -1109,6 +1109,9 @@ static struct uart_port *cdns_uart_get_port(int id)
>>  {
>> struct uart_port *port;
>>
>> +   if (id >= CDNS_UART_NR_PORTS)
>> +   return NULL;
>> +
>> /* Try the given port id if failed use default method */
>> if (cdns_uart_port[id].mapbase != 0) {
>> /* Find the next unused port */
>> @@ -1117,9 +1120,6 @@ static struct uart_port *cdns_uart_get_port(int id)
>> break;
>> }
>>
>> -   if (id >= CDNS_UART_NR_PORTS)
>> -   return NULL;
>> -
> 
> ... the above check cannot be removed, as it is needed to support the loop
> above to find an unused port.

You are right.
I have checked 4 patches I have sent in past which didn't reach mainline
(probably because of RFC)
Take a look at
https://www.spinics.net/lists/linux-serial/msg27106.html

I have removed cdns_uart_port array completely there.

Thanks,
Michal


Re: [PATCH 8/9] serial: sirf: Fix out-of-bounds access through DT alias

2018-02-20 Thread Geert Uytterhoeven
On Tue, Feb 20, 2018 at 10:40 AM, Geert Uytterhoeven
 wrote:
> The sirf_ports[] array is indexed using a value derived from the
> "serialN" alias in DT, which may lead to an out-of-bounds access.
>
> Fix this by adding a range check.
>
> Fixes: 66c7ab1120585d18 ("serial: sirf: Fix out-of-bounds access through DT 
> alias")
> Signed-off-by: Geert Uytterhoeven 

Fixes: a6ffe8966acbb66b ("serial: sirf: use dynamic method allocate
uart structure")

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH 7/9] serial: sh-sci: Fix out-of-bounds access through DT alias

2018-02-20 Thread Geert Uytterhoeven
On Tue, Feb 20, 2018 at 10:40 AM, Geert Uytterhoeven
 wrote:
> The sci_ports[] array is indexed using a value derived from the
> "serialN" alias in DT, which may lead to an out-of-bounds access.
>
> Fix this by adding a range check.
>
> Note that the array size is defined by a Kconfig symbol
> (CONFIG_SERIAL_SH_SCI_NR_UARTS), so this can even be triggered using a
> legitimate DTB.
>
> Fixes: f650cdf1c115498e ("serial: sh-sci: Fix out-of-bounds access through DT 
> alias")

Fixes: 97ed9790c514066b ("serial: sh-sci: Remove unused platform data
capabilities field")

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH 5/9] serial: pxa: Fix out-of-bounds access through DT alias

2018-02-20 Thread Geert Uytterhoeven
On Tue, Feb 20, 2018 at 10:40 AM, Geert Uytterhoeven
 wrote:
> The serial_pxa_ports[] array is indexed using a value derived from the
> "serialN" alias in DT, which may lead to an out-of-bounds access.
>
> Fix this by adding a range check.
>
> Fixes: c8dcdc77298dde67 ("serial: pxa: Fix out-of-bounds access through DT 
> alias")

Fixes: 699c20f3e6310aa2 ("serial: pxa: add OF support")

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH 6/9] serial: samsung: Fix out-of-bounds access through DT alias

2018-02-20 Thread Geert Uytterhoeven
On Tue, Feb 20, 2018 at 10:40 AM, Geert Uytterhoeven
 wrote:
> The s3c24xx_serial_ports[] array is indexed using a value derived from
> the "serialN" alias in DT, which may lead to an out-of-bounds access.
>
> Fix this by adding a range check.
>
> Note that the array size is defined by a Kconfig symbol
> (CONFIG_SERIAL_SAMSUNG_UARTS), so this can even be triggered using a
> legitimate DTB.
>
> Fixes: 3ac337e76a1c637b ("serial: samsung: Fix out-of-bounds access through 
> DT alias")

Fixes: 13a9f6c64fdc55eb ("serial: samsung: Consider DT alias when probing po
rts")

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH 4/9] serial: mxs-auart: Fix out-of-bounds access through DT alias

2018-02-20 Thread Geert Uytterhoeven
On Tue, Feb 20, 2018 at 10:40 AM, Geert Uytterhoeven
 wrote:
> The auart_port[] array is indexed using a value derived from the
> "serialN" alias in DT, which may lead to an out-of-bounds access.
>
> Fix this by adding a range check.
>
> Fixes: cabf23e7aa00b145 ("serial: mxs-auart: Fix out-of-bounds access through 
> DT alias")

Fixes: 1ea6607d4cdc9179 ("serial: mxs-auart: Allow device tree probing")

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH 2/9] serial: fsl_lpuart: Fix out-of-bounds access through DT alias

2018-02-20 Thread Geert Uytterhoeven
On Tue, Feb 20, 2018 at 10:40 AM, Geert Uytterhoeven
 wrote:
> The lpuart_ports[] array is indexed using a value derived from the
> "serialN" alias in DT, which may lead to an out-of-bounds access.
>
> Fix this by adding a range check.
>
> Fixes: 970416c691dc68b5 ("serial: fsl_lpuart: Fix out-of-bounds access 
> through DT alias")
> Signed-off-by: Geert Uytterhoeven 

Fixes: c9e2e946fb0ba5d2 ("tty: serial: add Freescale lpuart driver support")

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH 3/9] serial: imx: Fix out-of-bounds access through DT alias

2018-02-20 Thread Geert Uytterhoeven
Hi Uwe,

On Tue, Feb 20, 2018 at 11:31 AM, Uwe Kleine-König
 wrote:
> On Tue, Feb 20, 2018 at 10:40:18AM +0100, Geert Uytterhoeven wrote:
>> The imx_ports[] array is indexed using a value derived from the
>> "serialN" alias in DT, which may lead to an out-of-bounds access.
>>
>> Fix this by adding a range check.
>>
>> Fixes: 9206ab8a0350c3da ("serial: imx: Fix out-of-bounds access through DT 
>> alias")
>
> huh, this patch fixes itself?

Oops

Fixes: ff05967a07225ab6 ("serial/imx: add of_alias_get_id() reference back")

>
>> Signed-off-by: Geert Uytterhoeven 
>> ---
>>  drivers/tty/serial/imx.c | 5 +
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
>> index 1d7ca382bc12b238..e89e90ad87d8245c 100644
>> --- a/drivers/tty/serial/imx.c
>> +++ b/drivers/tty/serial/imx.c
>> @@ -2041,6 +2041,11 @@ static int serial_imx_probe(struct platform_device 
>> *pdev)
>>   serial_imx_probe_pdata(sport, pdev);
>>   else if (ret < 0)
>>   return ret;
>
> I'd prefer an empty line here.

OK

>> + if (sport->port.line >= UART_NR) {
>
> I would have used:
>
> if (sport->port.line >= ARRAY_SIZE(imx_ports))
>
> which IMHO is better understandable

OK.

>> + dev_err(>dev, "serial%d out of range\n",
>> + sport->port.line);
>
> Note that the same overflow can happen when a device is probed using
> platform data (and your commit fixes that, too). Maybe worth to point
> out in the commit log?

That's correct. But board code is tied more intimate to the kernel.
Will update.

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH 1/9] serial: arc_uart: Fix out-of-bounds access through DT alias

2018-02-20 Thread Geert Uytterhoeven
On Tue, Feb 20, 2018 at 10:40 AM, Geert Uytterhoeven
 wrote:
> The arc_uart_ports[] array is indexed using a value derived from the
> "serialN" alias in DT, which may lead to an out-of-bounds access.
>
> Fix this by adding a range check.
>
> Note that the array size is defined by a Kconfig symbol
> (CONFIG_SERIAL_ARC_NR_PORTS), so this can even be triggered using a
> legitimate DTB.
>
> Fixes: 10640deb04b7949a ("serial: arc_uart: Fix out-of-bounds access through 
> DT alias")

Fixes: ea28fd56fcde69af ("serial/arc-uart: switch to devicetree based probing")

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH 9/9] serial: xuartps: Fix out-of-bounds access through DT alias

2018-02-20 Thread Geert Uytterhoeven
Hi Michal,

On Tue, Feb 20, 2018 at 11:22 AM, Michal Simek  wrote:
> On 20.2.2018 10:40, Geert Uytterhoeven wrote:
>> The cdns_uart_port[] array is indexed using a value derived from the
>> "serialN" alias in DT, which may lead to an out-of-bounds access.
>>
>> Fix this by adding a range check.
>>
>> Fixes: 1f118c02a1819856 ("serial: xuartps: Fix out-of-bounds access through 
>> DT alias")
>
> I didn't find this sha1 - patch name is this one.

Bummer, I totally screwed up my scripting...

Fixes: 928e9263492069ee ("tty: xuartps: Initialize ports according to aliases")

>> Signed-off-by: Geert Uytterhoeven 
>> ---
>>  drivers/tty/serial/xilinx_uartps.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/tty/serial/xilinx_uartps.c 
>> b/drivers/tty/serial/xilinx_uartps.c
>> index b9b2bc76bcac606c..abcb4d09a2d866d0 100644
>> --- a/drivers/tty/serial/xilinx_uartps.c
>> +++ b/drivers/tty/serial/xilinx_uartps.c
>> @@ -1110,7 +1110,7 @@ static struct uart_port *cdns_uart_get_port(int id)
>>   struct uart_port *port;
>>
>>   /* Try the given port id if failed use default method */
>> - if (cdns_uart_port[id].mapbase != 0) {
>> + if (id < CDNS_UART_NR_PORTS && cdns_uart_port[id].mapbase != 0) {
>>   /* Find the next unused port */
>>   for (id = 0; id < CDNS_UART_NR_PORTS; id++)
>>   if (cdns_uart_port[id].mapbase == 0)
>>
>
> Below should be better fix for this driver.

I considered that, too, but...

> --- a/drivers/tty/serial/xilinx_uartps.c
> +++ b/drivers/tty/serial/xilinx_uartps.c
> @@ -1109,6 +1109,9 @@ static struct uart_port *cdns_uart_get_port(int id)
>  {
> struct uart_port *port;
>
> +   if (id >= CDNS_UART_NR_PORTS)
> +   return NULL;
> +
> /* Try the given port id if failed use default method */
> if (cdns_uart_port[id].mapbase != 0) {
> /* Find the next unused port */
> @@ -1117,9 +1120,6 @@ static struct uart_port *cdns_uart_get_port(int id)
> break;
> }
>
> -   if (id >= CDNS_UART_NR_PORTS)
> -   return NULL;
> -

... the above check cannot be removed, as it is needed to support the loop
above to find an unused port.

> port = _uart_port[id];
>
> /* At this point, we've got an empty uart_port struct,
> initialize it */

Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH 3/9] serial: imx: Fix out-of-bounds access through DT alias

2018-02-20 Thread Uwe Kleine-König
Hello Geert,

On Tue, Feb 20, 2018 at 10:40:18AM +0100, Geert Uytterhoeven wrote:
> The imx_ports[] array is indexed using a value derived from the
> "serialN" alias in DT, which may lead to an out-of-bounds access.
> 
> Fix this by adding a range check.
> 
> Fixes: 9206ab8a0350c3da ("serial: imx: Fix out-of-bounds access through DT 
> alias")

huh, this patch fixes itself?

> Signed-off-by: Geert Uytterhoeven 
> ---
>  drivers/tty/serial/imx.c | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> index 1d7ca382bc12b238..e89e90ad87d8245c 100644
> --- a/drivers/tty/serial/imx.c
> +++ b/drivers/tty/serial/imx.c
> @@ -2041,6 +2041,11 @@ static int serial_imx_probe(struct platform_device 
> *pdev)
>   serial_imx_probe_pdata(sport, pdev);
>   else if (ret < 0)
>   return ret;

I'd prefer an empty line here.

> + if (sport->port.line >= UART_NR) {

I would have used:

if (sport->port.line >= ARRAY_SIZE(imx_ports))

which IMHO is better understandable
> + dev_err(>dev, "serial%d out of range\n",
> + sport->port.line);

Note that the same overflow can happen when a device is probed using
platform data (and your commit fixes that, too). Maybe worth to point
out in the commit log?

Other than that: Good catch, thanks for your patch.

Best regards
Uwe

-- 
Pengutronix e.K.   | Uwe Kleine-König|
Industrial Linux Solutions | http://www.pengutronix.de/  |


[PATCH 5/9] serial: pxa: Fix out-of-bounds access through DT alias

2018-02-20 Thread Geert Uytterhoeven
The serial_pxa_ports[] array is indexed using a value derived from the
"serialN" alias in DT, which may lead to an out-of-bounds access.

Fix this by adding a range check.

Fixes: c8dcdc77298dde67 ("serial: pxa: Fix out-of-bounds access through DT 
alias")
Signed-off-by: Geert Uytterhoeven 
---
 drivers/tty/serial/pxa.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/tty/serial/pxa.c b/drivers/tty/serial/pxa.c
index baf552944d5686e8..ac25faa95baaad0e 100644
--- a/drivers/tty/serial/pxa.c
+++ b/drivers/tty/serial/pxa.c
@@ -885,6 +885,10 @@ static int serial_pxa_probe(struct platform_device *dev)
sport->port.line = dev->id;
else if (ret < 0)
goto err_clk;
+   if (sport->port.line > ARRAY_SIZE(serial_pxa_ports)) {
+   dev_err(>dev, "serial%d out of range\n", sport->port.line);
+   return -EINVAL;
+   }
snprintf(sport->name, PXA_NAME_LEN - 1, "UART%d", sport->port.line + 1);
 
sport->port.membase = ioremap(mmres->start, resource_size(mmres));
-- 
2.7.4



Re: [PATCH 9/9] serial: xuartps: Fix out-of-bounds access through DT alias

2018-02-20 Thread Michal Simek
On 20.2.2018 10:40, Geert Uytterhoeven wrote:
> The cdns_uart_port[] array is indexed using a value derived from the
> "serialN" alias in DT, which may lead to an out-of-bounds access.
> 
> Fix this by adding a range check.
> 
> Fixes: 1f118c02a1819856 ("serial: xuartps: Fix out-of-bounds access through 
> DT alias")

I didn't find this sha1 - patch name is this one.

> Signed-off-by: Geert Uytterhoeven 
> ---
>  drivers/tty/serial/xilinx_uartps.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/xilinx_uartps.c 
> b/drivers/tty/serial/xilinx_uartps.c
> index b9b2bc76bcac606c..abcb4d09a2d866d0 100644
> --- a/drivers/tty/serial/xilinx_uartps.c
> +++ b/drivers/tty/serial/xilinx_uartps.c
> @@ -1110,7 +1110,7 @@ static struct uart_port *cdns_uart_get_port(int id)
>   struct uart_port *port;
>  
>   /* Try the given port id if failed use default method */
> - if (cdns_uart_port[id].mapbase != 0) {
> + if (id < CDNS_UART_NR_PORTS && cdns_uart_port[id].mapbase != 0) {
>   /* Find the next unused port */
>   for (id = 0; id < CDNS_UART_NR_PORTS; id++)
>   if (cdns_uart_port[id].mapbase == 0)
> 

Below should be better fix for this driver.

Thanks,
Michal

diff --git a/drivers/tty/serial/xilinx_uartps.c
b/drivers/tty/serial/xilinx_uartps.c
index b9b2bc76bcac..b77c6477ed93 100644
--- a/drivers/tty/serial/xilinx_uartps.c
+++ b/drivers/tty/serial/xilinx_uartps.c
@@ -1109,6 +1109,9 @@ static struct uart_port *cdns_uart_get_port(int id)
 {
struct uart_port *port;

+   if (id >= CDNS_UART_NR_PORTS)
+   return NULL;
+
/* Try the given port id if failed use default method */
if (cdns_uart_port[id].mapbase != 0) {
/* Find the next unused port */
@@ -1117,9 +1120,6 @@ static struct uart_port *cdns_uart_get_port(int id)
break;
}

-   if (id >= CDNS_UART_NR_PORTS)
-   return NULL;
-
port = _uart_port[id];

/* At this point, we've got an empty uart_port struct,
initialize it */


Re: [PATCH 03/15] soc: renesas: Add R-Car M3-N support

2018-02-20 Thread jacopo mondi
Hi Geert,

On Wed, Feb 14, 2018 at 01:48:27PM +0100, Geert Uytterhoeven wrote:
> Hi Jacopo,
>
> Thanks for your patch!
>
> On Tue, Feb 13, 2018 at 10:45 AM, Jacopo Mondi
>  wrote:
> > Add support for R-Car M3-N (r8a77965) power areas and reset.
> > M3-N power areas are identical to M3-W ones, so just copy and rename
> > them.
>
> They are not identical:
>   - M3-N does not have the CA53-related areas,
>   - M3-W does not have A3VP,
>   - M3-N does not have A2VC0 (M3-W also doesn't, according to latest
> datasheet?).
>
> The datasheet also mentions A3SH, without further info about the register
> block. I think we need to bring this up with Renesas.
>
> >  .../bindings/power/renesas,rcar-sysc.txt   |  1 +
> >  .../devicetree/bindings/reset/renesas,rst.txt  |  1 +
> >  drivers/soc/renesas/Kconfig|  9 --
> >  drivers/soc/renesas/Makefile   |  1 +
> >  drivers/soc/renesas/r8a77965-sysc.c| 37 
> > ++
> >  drivers/soc/renesas/rcar-rst.c |  1 +
> >  drivers/soc/renesas/rcar-sysc.c|  3 ++
> >  drivers/soc/renesas/rcar-sysc.h|  1 +
> >  drivers/soc/renesas/renesas-soc.c  |  8 +
> >  include/dt-bindings/power/r8a77965-sysc.h  | 31 ++
> >  10 files changed, 91 insertions(+), 2 deletions(-)
> >  create mode 100644 drivers/soc/renesas/r8a77965-sysc.c
> >  create mode 100644 include/dt-bindings/power/r8a77965-sysc.h
>
> The maintainer may ask you to split this patch by functionality...
>
> > --- /dev/null
> > +++ b/drivers/soc/renesas/r8a77965-sysc.c
> > @@ -0,0 +1,37 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Renesas R-Car M3-N System Controller
> > + * Copyright (C) 2018 Jacopo Mondi 
> > + *
> > + * Based on Renesas R-Car M3-W System Controller
> > + * Copyright (C) 2016 Glider bvba
> > + */
> > +
> > +#include 
> > +#include 
> > +
> > +#include 
> > +
> > +#include "rcar-sysc.h"
> > +
> > +static const struct rcar_sysc_area r8a77965_areas[] __initconst = {
> > +   { "always-on",  0, 0, R8A77965_PD_ALWAYS_ON, -1, PD_ALWAYS_ON },
> > +   { "ca57-scu",   0x1c0, 0, R8A77965_PD_CA57_SCU, 
> > R8A77965_PD_ALWAYS_ON,
> > + PD_SCU },
> > +   { "ca57-cpu0",   0x80, 0, R8A77965_PD_CA57_CPU0, 
> > R8A77965_PD_CA57_SCU,
> > + PD_CPU_NOCR },
> > +   { "ca57-cpu1",   0x80, 1, R8A77965_PD_CA57_CPU1, 
> > R8A77965_PD_CA57_SCU,
> > + PD_CPU_NOCR },
> > +   { "cr7",0x240, 0, R8A77965_PD_CR7,  
> > R8A77965_PD_ALWAYS_ON },
> > +   { "a3vc",   0x380, 0, R8A77965_PD_A3VC, 
> > R8A77965_PD_ALWAYS_ON },
> > +   { "a2vc0",  0x3c0, 0, R8A77965_PD_A2VC0,R8A77965_PD_A3VC },
>
> M3-N (and M3-W) does not have A2VC0?

Why do I still see that power area listed in latest renesas-drivers for
M3-W? Are there patch pendings for that?

I'll remove it anyway for M3-N.

Thanks
   j

>
> > +   { "a2vc1",  0x3c0, 1, R8A77965_PD_A2VC1,R8A77965_PD_A3VC },
> > +   { "3dg-a",  0x100, 0, R8A77965_PD_3DG_A,
> > R8A77965_PD_ALWAYS_ON },
> > +   { "3dg-b",  0x100, 1, R8A77965_PD_3DG_B,R8A77965_PD_3DG_A },
> > +   { "a3ir",   0x180, 0, R8A77965_PD_A3IR, 
> > R8A77965_PD_ALWAYS_ON },
>
> A3VP is missing?
>
> > +};
> > +
> > +const struct rcar_sysc_info r8a77965_sysc_info __initconst = {
> > +   .areas = r8a77965_areas,
> > +   .num_areas = ARRAY_SIZE(r8a77965_areas),
> > +};
>
> > --- /dev/null
> > +++ b/include/dt-bindings/power/r8a77965-sysc.h
> > @@ -0,0 +1,31 @@
> > +/* SPDX-License-Identifier: GPL-2.0 */
> > +/*
> > + * Copyright (C) 2018 Jacopo Mondi 
> > + * Copyright (C) 2016 Glider bvba
> > + */
> > +
> > +#ifndef __DT_BINDINGS_POWER_R8A77965_SYSC_H__
> > +#define __DT_BINDINGS_POWER_R8A77965_SYSC_H__
> > +
> > +/*
> > + * These power domain indices match the numbers of the interrupt bits
> > + * representing the power areas in the various Interrupt Registers
> > + * (e.g. SYSCISR, Interrupt Status Register)
> > + */
> > +
> > +#define R8A77965_PD_CA57_CPU0   0
> > +#define R8A77965_PD_CA57_CPU1   1
> > +#define R8A77965_PD_A3VP9
> > +#define R8A77965_PD_CA57_SCU   12
> > +#define R8A77965_PD_CR713
> > +#define R8A77965_PD_A3VC   14
> > +#define R8A77965_PD_3DG_A  17
> > +#define R8A77965_PD_3DG_B  18
> > +#define R8A77965_PD_A3IR   24
> > +#define R8A77965_PD_A2VC0  25
>
> M3-N (and M3-W) does not have A2VC0?
>
> > +#define R8A77965_PD_A2VC1  26
> > +
> > +/* Always-on power area */
> > +#define R8A77965_PD_ALWAYS_ON  32
> > +
> > +#endif /* __DT_BINDINGS_POWER_R8A77965_SYSC_H__ */
>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of 

[PATCH 8/9] serial: sirf: Fix out-of-bounds access through DT alias

2018-02-20 Thread Geert Uytterhoeven
The sirf_ports[] array is indexed using a value derived from the
"serialN" alias in DT, which may lead to an out-of-bounds access.

Fix this by adding a range check.

Fixes: 66c7ab1120585d18 ("serial: sirf: Fix out-of-bounds access through DT 
alias")
Signed-off-by: Geert Uytterhoeven 
---
 drivers/tty/serial/sirfsoc_uart.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/tty/serial/sirfsoc_uart.c 
b/drivers/tty/serial/sirfsoc_uart.c
index 9925b00a97772a1b..701df3319ff7579d 100644
--- a/drivers/tty/serial/sirfsoc_uart.c
+++ b/drivers/tty/serial/sirfsoc_uart.c
@@ -1283,6 +1283,11 @@ static int sirfsoc_uart_probe(struct platform_device 
*pdev)
goto err;
}
sirfport->port.line = of_alias_get_id(np, "serial");
+   if (sirfport->port.line >= SIRFSOC_UART_NR) {
+   dev_err(>dev, "serial%d out of range\n",
+   sirfport->port.line);
+   return -EINVAL;
+   }
sirf_ports[sirfport->port.line] = sirfport;
sirfport->port.iotype = UPIO_MEM;
sirfport->port.flags = UPF_BOOT_AUTOCONF;
-- 
2.7.4



[PATCH 9/9] serial: xuartps: Fix out-of-bounds access through DT alias

2018-02-20 Thread Geert Uytterhoeven
The cdns_uart_port[] array is indexed using a value derived from the
"serialN" alias in DT, which may lead to an out-of-bounds access.

Fix this by adding a range check.

Fixes: 1f118c02a1819856 ("serial: xuartps: Fix out-of-bounds access through DT 
alias")
Signed-off-by: Geert Uytterhoeven 
---
 drivers/tty/serial/xilinx_uartps.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/xilinx_uartps.c 
b/drivers/tty/serial/xilinx_uartps.c
index b9b2bc76bcac606c..abcb4d09a2d866d0 100644
--- a/drivers/tty/serial/xilinx_uartps.c
+++ b/drivers/tty/serial/xilinx_uartps.c
@@ -1110,7 +1110,7 @@ static struct uart_port *cdns_uart_get_port(int id)
struct uart_port *port;
 
/* Try the given port id if failed use default method */
-   if (cdns_uart_port[id].mapbase != 0) {
+   if (id < CDNS_UART_NR_PORTS && cdns_uart_port[id].mapbase != 0) {
/* Find the next unused port */
for (id = 0; id < CDNS_UART_NR_PORTS; id++)
if (cdns_uart_port[id].mapbase == 0)
-- 
2.7.4



[PATCH 0/9] serial: Fix out-of-bounds accesses through DT aliases

2018-02-20 Thread Geert Uytterhoeven
Hi all,

Serial drivers used on DT platforms use the "serialN" alias in DT to
obtain the serial port index for a specific port.  Drivers typically use
a fixed-size array for keeping track of all available serial ports.
However, several drivers do not perform any validation on the index
obtained from DT, which may lead to out-of-bounds accesses of these
fixed-size arrays.

While the DTB passed to the kernel might be considered trusted, some of
these out-of-bounds accesses can be triggered by a legitimate DTB:
  - In some drivers the size of the array is defined by a Kconfig
symbol, so a user who doesn't need all serial ports may lower this
value rightfully,
  - Tomorrow's new SoC may have more serial ports than the fixed-size
array in today's driver can accommodate, which the user may forget
to enlarge.

Hence this series fixes that by adding checks for out-of-range aliases,
logging an error message when triggered.

Tested on r8a7791/koelsch (sh-sci), all other drivers were
compile-tested only.

Thanks for your comments!

Geert Uytterhoeven (9):
  serial: arc_uart: Fix out-of-bounds access through DT alias
  serial: fsl_lpuart: Fix out-of-bounds access through DT alias
  serial: imx: Fix out-of-bounds access through DT alias
  serial: mxs-auart: Fix out-of-bounds access through DT alias
  serial: pxa: Fix out-of-bounds access through DT alias
  serial: samsung: Fix out-of-bounds access through DT alias
  serial: sh-sci: Fix out-of-bounds access through DT alias
  serial: sirf: Fix out-of-bounds access through DT alias
  serial: xuartps: Fix out-of-bounds access through DT alias

 drivers/tty/serial/arc_uart.c  | 5 +
 drivers/tty/serial/fsl_lpuart.c| 4 
 drivers/tty/serial/imx.c   | 5 +
 drivers/tty/serial/mxs-auart.c | 4 
 drivers/tty/serial/pxa.c   | 4 
 drivers/tty/serial/samsung.c   | 4 
 drivers/tty/serial/sh-sci.c| 4 
 drivers/tty/serial/sirfsoc_uart.c  | 5 +
 drivers/tty/serial/xilinx_uartps.c | 2 +-
 9 files changed, 36 insertions(+), 1 deletion(-)

-- 
2.7.4

Gr{oetje,eeting}s,

Geert

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

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


[PATCH 4/9] serial: mxs-auart: Fix out-of-bounds access through DT alias

2018-02-20 Thread Geert Uytterhoeven
The auart_port[] array is indexed using a value derived from the
"serialN" alias in DT, which may lead to an out-of-bounds access.

Fix this by adding a range check.

Fixes: cabf23e7aa00b145 ("serial: mxs-auart: Fix out-of-bounds access through 
DT alias")
Signed-off-by: Geert Uytterhoeven 
---
 drivers/tty/serial/mxs-auart.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index 079dc47aa142d8e1..7ec1298512facfc8 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -1663,6 +1663,10 @@ static int mxs_auart_probe(struct platform_device *pdev)
s->port.line = pdev->id < 0 ? 0 : pdev->id;
else if (ret < 0)
return ret;
+   if (s->port.line >= MXS_AUART_PORTS) {
+   dev_err(>dev, "serial%d out of range\n", s->port.line);
+   return -EINVAL;
+   }
 
if (of_id) {
pdev->id_entry = of_id->data;
-- 
2.7.4



[PATCH 3/9] serial: imx: Fix out-of-bounds access through DT alias

2018-02-20 Thread Geert Uytterhoeven
The imx_ports[] array is indexed using a value derived from the
"serialN" alias in DT, which may lead to an out-of-bounds access.

Fix this by adding a range check.

Fixes: 9206ab8a0350c3da ("serial: imx: Fix out-of-bounds access through DT 
alias")
Signed-off-by: Geert Uytterhoeven 
---
 drivers/tty/serial/imx.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 1d7ca382bc12b238..e89e90ad87d8245c 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -2041,6 +2041,11 @@ static int serial_imx_probe(struct platform_device *pdev)
serial_imx_probe_pdata(sport, pdev);
else if (ret < 0)
return ret;
+   if (sport->port.line >= UART_NR) {
+   dev_err(>dev, "serial%d out of range\n",
+   sport->port.line);
+   return -EINVAL;
+   }
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
base = devm_ioremap_resource(>dev, res);
-- 
2.7.4



[PATCH 1/9] serial: arc_uart: Fix out-of-bounds access through DT alias

2018-02-20 Thread Geert Uytterhoeven
The arc_uart_ports[] array is indexed using a value derived from the
"serialN" alias in DT, which may lead to an out-of-bounds access.

Fix this by adding a range check.

Note that the array size is defined by a Kconfig symbol
(CONFIG_SERIAL_ARC_NR_PORTS), so this can even be triggered using a
legitimate DTB.

Fixes: 10640deb04b7949a ("serial: arc_uart: Fix out-of-bounds access through DT 
alias")
Signed-off-by: Geert Uytterhoeven 
---
 drivers/tty/serial/arc_uart.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c
index 2599f9ecccfe7769..1cb827a6b836d0dd 100644
--- a/drivers/tty/serial/arc_uart.c
+++ b/drivers/tty/serial/arc_uart.c
@@ -593,6 +593,11 @@ static int arc_serial_probe(struct platform_device *pdev)
if (dev_id < 0)
dev_id = 0;
 
+   if (dev_id >= CONFIG_SERIAL_ARC_NR_PORTS) {
+   dev_err(>dev, "serial%d out of range\n", dev_id);
+   return -EINVAL;
+   }
+
uart = _uart_ports[dev_id];
port = >port;
 
-- 
2.7.4



[PATCH 2/9] serial: fsl_lpuart: Fix out-of-bounds access through DT alias

2018-02-20 Thread Geert Uytterhoeven
The lpuart_ports[] array is indexed using a value derived from the
"serialN" alias in DT, which may lead to an out-of-bounds access.

Fix this by adding a range check.

Fixes: 970416c691dc68b5 ("serial: fsl_lpuart: Fix out-of-bounds access through 
DT alias")
Signed-off-by: Geert Uytterhoeven 
---
 drivers/tty/serial/fsl_lpuart.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index 8cf112f2efc30707..5218e2ed1ba90a5b 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -2145,6 +2145,10 @@ static int lpuart_probe(struct platform_device *pdev)
dev_err(>dev, "failed to get alias id, errno %d\n", ret);
return ret;
}
+   if (ret >= UART_NR) {
+   dev_err(>dev, "serial%d out of range\n", ret);
+   return -EINVAL;
+   }
sport->port.line = ret;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
sport->port.membase = devm_ioremap_resource(>dev, res);
-- 
2.7.4



[PATCH 7/9] serial: sh-sci: Fix out-of-bounds access through DT alias

2018-02-20 Thread Geert Uytterhoeven
The sci_ports[] array is indexed using a value derived from the
"serialN" alias in DT, which may lead to an out-of-bounds access.

Fix this by adding a range check.

Note that the array size is defined by a Kconfig symbol
(CONFIG_SERIAL_SH_SCI_NR_UARTS), so this can even be triggered using a
legitimate DTB.

Fixes: f650cdf1c115498e ("serial: sh-sci: Fix out-of-bounds access through DT 
alias")
Signed-off-by: Geert Uytterhoeven 
---
 drivers/tty/serial/sh-sci.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 4d14f321cbec95e0..0fb4784860da6188 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -3620,6 +3620,10 @@ static struct plat_sci_port *sci_parse_dt(struct 
platform_device *pdev,
dev_err(>dev, "failed to get alias id (%d)\n", id);
return NULL;
}
+   if (id >= SCI_NPORTS) {
+   dev_err(>dev, "serial%d out of range\n", id);
+   return NULL;
+   }
 
sp = _ports[id];
*dev_id = id;
-- 
2.7.4



[PATCH 6/9] serial: samsung: Fix out-of-bounds access through DT alias

2018-02-20 Thread Geert Uytterhoeven
The s3c24xx_serial_ports[] array is indexed using a value derived from
the "serialN" alias in DT, which may lead to an out-of-bounds access.

Fix this by adding a range check.

Note that the array size is defined by a Kconfig symbol
(CONFIG_SERIAL_SAMSUNG_UARTS), so this can even be triggered using a
legitimate DTB.

Fixes: 3ac337e76a1c637b ("serial: samsung: Fix out-of-bounds access through DT 
alias")
Signed-off-by: Geert Uytterhoeven 
---
 drivers/tty/serial/samsung.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
index f9fecc5ed0cee826..9ea42197ceefabba 100644
--- a/drivers/tty/serial/samsung.c
+++ b/drivers/tty/serial/samsung.c
@@ -1818,6 +1818,10 @@ static int s3c24xx_serial_probe(struct platform_device 
*pdev)
 
dbg("s3c24xx_serial_probe(%p) %d\n", pdev, index);
 
+   if (index >= CONFIG_SERIAL_SAMSUNG_UARTS) {
+   dev_err(>dev, "serial%d out of range\n", index);
+   return -EINVAL;
+   }
ourport = _serial_ports[index];
 
ourport->drv_data = s3c24xx_get_driver_data(pdev);
-- 
2.7.4



Re: [PATCH v3 03/12] drm: rcar-du: Fix legacy DT to create LVDS encoder nodes

2018-02-20 Thread Laurent Pinchart
Hi Rob,

On Tuesday, 20 February 2018 02:54:00 EET Rob Herring wrote:
> On Wed, Feb 14, 2018 at 6:04 PM, Laurent Pinchart wrote:
> > The internal LVDS encoders now have their own DT bindings. Before
> > switching the driver infrastructure to those new bindings, implement
> > backward-compatibility through live DT patching.
> > 
> > Patching is disabled and will be enabled along with support for the new
> > DT bindings in the DU driver.
> > 
> > Signed-off-by: Laurent Pinchart
> > 
> > ---
> > Changes since v2:
> > 
> > - Update the SPDX headers to use C-style comments in header files
> > - Removed the manually created __local_fixups__ node
> > - Perform manual fixups on live DT instead of overlay
> 
> Generally looks fine to me. A few things below.
> 
> > Changes since v1:
> > 
> > - Select OF_FLATTREE
> > - Compile LVDS DT bindings patch code when DRM_RCAR_LVDS is selected
> > - Update the SPDX headers to use GPL-2.0 instead of GPL-2.0-only
> > - Turn __dtb_rcar_du_of_lvds_(begin|end) from u8 to char
> > - Pass void begin and end pointers to rcar_du_of_get_overlay()
> > - Use of_get_parent() instead of accessing the parent pointer directly
> > - Find the LVDS endpoints nodes based on the LVDS node instead of the
> > 
> >   root of the overlay
> > 
> > - Update to the -lvds compatible string format
> > ---
> > 
> >  drivers/gpu/drm/rcar-du/Kconfig|   2 +
> >  drivers/gpu/drm/rcar-du/Makefile   |   7 +-
> >  drivers/gpu/drm/rcar-du/rcar_du_of.c   | 374
> >  + drivers/gpu/drm/rcar-du/rcar_du_of.h  
> >  |  20 ++
> >  .../gpu/drm/rcar-du/rcar_du_of_lvds_r8a7790.dts|  81 +
> >  .../gpu/drm/rcar-du/rcar_du_of_lvds_r8a7791.dts|  55 +++
> >  .../gpu/drm/rcar-du/rcar_du_of_lvds_r8a7793.dts|  55 +++
> >  .../gpu/drm/rcar-du/rcar_du_of_lvds_r8a7795.dts|  55 +++
> >  .../gpu/drm/rcar-du/rcar_du_of_lvds_r8a7796.dts|  55 +++
> >  9 files changed, 703 insertions(+), 1 deletion(-)
> >  create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_of.c
> >  create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_of.h
> >  create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7790.dts
> >  create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7791.dts
> >  create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7793.dts
> >  create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7795.dts
> >  create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7796.dts
> > 
> > diff --git a/drivers/gpu/drm/rcar-du/Kconfig
> > b/drivers/gpu/drm/rcar-du/Kconfig index 5d0b4b7119af..3f83352a7313 100644
> > --- a/drivers/gpu/drm/rcar-du/Kconfig
> > +++ b/drivers/gpu/drm/rcar-du/Kconfig
> > @@ -22,6 +22,8 @@ config DRM_RCAR_LVDS
> > 
> > bool "R-Car DU LVDS Encoder Support"
> > depends on DRM_RCAR_DU
> > select DRM_PANEL
> > 
> > +   select OF_FLATTREE
> > +   select OF_OVERLAY
> > 
> > help
> > 
> >   Enable support for the R-Car Display Unit embedded LVDS
> >   encoders.
> > 
> > diff --git a/drivers/gpu/drm/rcar-du/Makefile
> > b/drivers/gpu/drm/rcar-du/Makefile index 0cf5c11030e8..86b337b4be5d
> > 100644
> > --- a/drivers/gpu/drm/rcar-du/Makefile
> > +++ b/drivers/gpu/drm/rcar-du/Makefile
> > @@ -8,7 +8,12 @@ rcar-du-drm-y := rcar_du_crtc.o \
> > 
> >  rcar_du_plane.o
> >  
> >  rcar-du-drm-$(CONFIG_DRM_RCAR_LVDS)+= rcar_du_lvdsenc.o
> > 
> > -
> > +rcar-du-drm-$(CONFIG_DRM_RCAR_LVDS)+= rcar_du_of.o \
> > +  rcar_du_of_lvds_r8a7790.dtb.o \
> > +  rcar_du_of_lvds_r8a7791.dtb.o \
> > +  rcar_du_of_lvds_r8a7793.dtb.o \
> > +  rcar_du_of_lvds_r8a7795.dtb.o \
> > +  rcar_du_of_lvds_r8a7796.dtb.o
> > 
> >  rcar-du-drm-$(CONFIG_DRM_RCAR_VSP) += rcar_du_vsp.o
> >  
> >  obj-$(CONFIG_DRM_RCAR_DU)  += rcar-du-drm.o
> > 
> > diff --git a/drivers/gpu/drm/rcar-du/rcar_du_of.c
> > b/drivers/gpu/drm/rcar-du/rcar_du_of.c new file mode 100644
> > index ..141f6eda6e98
> > --- /dev/null
> > +++ b/drivers/gpu/drm/rcar-du/rcar_du_of.c

[snip]

> > +static struct device_node __init *
> > +rcar_du_of_find_node_by_path(struct device_node *parent, const char
> > *path)
> > +{
> 
> I guess I never followed up on the last version. I think a wrapper
> around __of_find_node_by_path would work for you here. It can start at
> any level. Though maybe it is not needed. See below.

You're right, I won't need this function anymore, so I'll drop it. I think 
looking up a node by path starting at a given parent would still be useful, 
but there's no need to add a function without a user.

> > +   parent = of_node_get(parent);
> > +   if (!parent)
> > +   return NULL;
> > +
> > +   

Re: [PATCH v9 11/11] media: i2c: ov7670: Fully set mbus frame fmt

2018-02-20 Thread jacopo mondi
Hi Laurent,

On Mon, Feb 19, 2018 at 09:19:32PM +0200, Laurent Pinchart wrote:
> Hi Jacopo,
>
> Thank you for the patch.
>
> On Monday, 19 February 2018 18:59:44 EET Jacopo Mondi wrote:
> > The sensor driver sets mbus format colorspace information and sizes,
> > but not ycbcr encoding, quantization and xfer function. When supplied
> > with an badly initialized mbus frame format structure, those fields
> > need to be set explicitly not to leave them uninitialized. This is
> > tested by v4l2-compliance, which supplies a mbus format description
> > structure and checks for all fields to be properly set.
> >
> > Without this commit, v4l2-compliance fails when testing formats with:
> > fail: v4l2-test-formats.cpp(335): ycbcr_enc >= 0xff
> >
> > Signed-off-by: Jacopo Mondi 
> > ---
> >  drivers/media/i2c/ov7670.c | 4 
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c
> > index 25b26d4..61c472e 100644
> > --- a/drivers/media/i2c/ov7670.c
> > +++ b/drivers/media/i2c/ov7670.c
> > @@ -996,6 +996,10 @@ static int ov7670_try_fmt_internal(struct v4l2_subdev
> > *sd, fmt->height = wsize->height;
> > fmt->colorspace = ov7670_formats[index].colorspace;
>
> On a side note, if I'm not mistaken the colorspace field is set to SRGB for
> all entries. Shouldn't you hardcode it here and remove the field ?
>
> > +   fmt->ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT;
> > +   fmt->quantization = V4L2_QUANTIZATION_DEFAULT;
> > +   fmt->xfer_func = V4L2_XFER_FUNC_DEFAULT;
>
> How about setting the values explicitly instead of relying on defaults ? That
> would be V4L2_YCBCR_ENC_601, V4L2_QUANTIZATION_LIM_RANGE and
> V4L2_XFER_FUNC_SRGB. And could you then check a captured frame to see if the
> sensor outputs limited or full range ?
>

This actually makes me wonder if those informations (ycbcb_enc,
quantization and xfer_func) shouldn't actually be part of the
supported format list... I blindly added those default fields in the
try_fmt function, but I doubt they applies to all supported formats.

Eg. the sensor supports YUYV as well as 2 RGB encodings (RGB444 and
RGB 565) and 1 raw format (BGGR). I now have a question here:

1) ycbcr_enc transforms non-linear R'G'B' to Y'CbCr: does this
applies to RGB and raw formats? I don't think so, and what value is
the correct one for the ycbcr_enc field in this case? I assume
xfer_func and quantization applies to all formats instead..

Thanks
   j

> > info->format = *fmt;
> >
> > return 0;
>
> --
> Regards,
>
> Laurent Pinchart
>


Re: [PATCH v2] videodev2.h: add helper to validate colorspace

2018-02-20 Thread Hans Verkuil
Hi Niklas,

On 02/19/2018 11:28 PM, Niklas Söderlund wrote:
> Hi Hans,
> 
> Thanks for your feedback.
> 
> [snip]
> 
>> Can you then fix v4l2-compliance to stop testing colorspace 
>> against 0xff
>> ?
>
> For now I can simply relax this test for subdevs with sources and sinks.

 You also need to relax it for video nodes with MC drivers, as the DMA
 engines don't care about colorspaces.
>>>
>>> Yes, they do. Many DMA engines can at least do RGB <-> YUV conversions, so
>>> they should get the colorspace info from their source and pass it on to
>>> userspace (after correcting for any conversions done by the DMA engine).
>>
>> Not in the MC case. Video nodes there only model the DMA engine, and are 
>> thus 
>> not aware of colorspaces. What MC drivers do is check at stream on time when 
>> validating the pipeline that the colorspace set by userspace on the video 
>> node 
>> corresponds to the colorspace on the source pad of the connected subdev, but 
>> that's only to ensure that userspace gets a coherent view of colorspace 
>> across 
>> the pipeline, not to program the hardware. There could be exceptions, but in 
>> the general case, the video node implementation of an MC driver will accept 
>> any colorspace and only validate it at stream on time, similarly to how it 
>> does for the frame size format instance (and in the frame size case it will 
>> usually enforce min/max limits when the DMA engine limits the frame size).
> 
> I'm afraid the issue described above by Laurent is what sparked me to 
> write this commit to begin with. In my never ending VIN Gen3 patch-set I 
> currency need to carry a patch [1] to implement a hack to make sure 
> v4l2-compliance do not fail for the VIN Gen3 MC-centric use-case. This 
> patch was an attempt to be able to validate the colorspace using the 
> magic value 0xff.

This is NOT a magic value. The test that's done here is to memset the
format structure with 0xff, then call the ioctl. Afterwards it checks
if there are any remaining 0xff bytes left in the struct since it expects
the driver to have overwritten it by something else. That's where the 0xff
comes from.

> 
> I don't feel strongly for this patch in particular and I'm happy to drop 
> it.  But I would like to receive some guidance on how to then properly 
> be able to handle this problem for the MC-centric VIN driver use-case.  
> One option is as you suggested to relax the test in v4l-compliance to 
> not check colorspace, but commit [2] is not enough to resolve the issue 
> for my MC use-case.
> 
> As Laurent stated above, the use-case is that the video device shall 
> accept any colorspace set from user-space. This colorspace is then only 
> used as stream on time to validate the MC pipeline. The VIN driver do 
> not care about colorspace, but I care about not breaking v4l2-compliance 
> as I find it's a very useful tool :-)

I think part of my confusion here is that there are two places where you
deal with colorspaces in a DMA engine: first there is a input pad of the
DMA engine entity, secondly there is the v4l2_pix_format for the memory
description.

The second is set by the driver based on what userspace specified for the
input pad, together with any changes due to additional conversions such
as quantization range and RGB <-> YUV by the DMA engine.

So any colorspace validation is done for the input pad. The question is
what that validation should be. It's never been defined.

Also the handling of COLORSPACE_DEFAULT for pad formats needs to be defined.

This is not the first time this cropped up, see e.g. this RFC patch:

https://patchwork.linuxtv.org/patch/41734/

> I'm basing the following on the latest v4l-utils master 
> (4665ab1fbab1ddaa)  which contains commit [2]. The core issue is that if 
> I do not have a patch like [1] the v4l2-compliance run fails for format 
> ioctls:
> 
> Format ioctls (Input 0):
>   test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
>   test VIDIOC_G/S_PARM: OK (Not Supported)
>   test VIDIOC_G_FBUF: OK (Not Supported)
>   fail: v4l2-test-formats.cpp(330): !colorspace
>   fail: v4l2-test-formats.cpp(439): 
> testColorspace(pix.pixelformat, pix.colorspace, pix.ycbcr_enc, 
> pix.quantization)
>   test VIDIOC_G_FMT: FAIL
>   test VIDIOC_TRY_FMT: OK (Not Supported)
>   test VIDIOC_S_FMT: OK (Not Supported)
>   test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
>   test Cropping: OK (Not Supported)
>   test Composing: OK (Not Supported)
>   test Scaling: OK
> 
> Well that is OK as that fails when colorspace is V4L2_COLORSPACE_DEFAULT 
> and that is not valid. If I instead of reverting [1] only test for 
> V4L2_COLORSPACE_DEFAULT which would not require this patch to implement:
> 
> -   if (!pix->colorspace || pix->colorspace >= 0xff)
> +   if (pix->colorspace == V4L2_COLORSPACE_DEFAULT)
> 
> I still fail for the format ioctls:
> 
> Format ioctls (Input 0):
>   test