[PATCH v2] ASoC: rsnd: adg :: AUDIO-CLKOUTn asynchronizes support

2016-06-08 Thread Kuninori Morimoto
From: Kuninori Morimoto 

AUDIO-CLKOUTn can asynchronizes with L/R clock.
AUDIO-CLKOUTn synchronizes with L/R clock is now default behavior.

Signed-off-by: Kuninori Morimoto 
---
v1 -> v2

 - default is synchronizes, asynchronizes is option

 .../devicetree/bindings/sound/renesas,rsnd.txt |  2 ++
 sound/soc/sh/rcar/adg.c| 18 ++
 2 files changed, 20 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/renesas,rsnd.txt 
b/Documentation/devicetree/bindings/sound/renesas,rsnd.txt
index c7b29df..15a7316 100644
--- a/Documentation/devicetree/bindings/sound/renesas,rsnd.txt
+++ b/Documentation/devicetree/bindings/sound/renesas,rsnd.txt
@@ -373,6 +373,8 @@ Optional properties:
 - #clock-cells : it must be 0 if your system has audio_clkout
  it must be 1 if your system has 
audio_clkout0/1/2/3
 - clock-frequency  : for all audio_clkout0/1/2/3
+- clkout-lr-asynchronous   : boolean property. it indicates that 
audio_clkoutn
+ is asynchronizes with lr-clock.
 
 SSI subnode properties:
 - interrupts   : Should contain SSI interrupt for PIO transfer
diff --git a/sound/soc/sh/rcar/adg.c b/sound/soc/sh/rcar/adg.c
index 49354d1..7d3e0e4 100644
--- a/sound/soc/sh/rcar/adg.c
+++ b/sound/soc/sh/rcar/adg.c
@@ -33,11 +33,15 @@ struct rsnd_adg {
struct clk *clkout[CLKOUTMAX];
struct clk_onecell_data onecell;
struct rsnd_mod mod;
+   u32 flags;
 
int rbga_rate_for_441khz; /* RBGA */
int rbgb_rate_for_48khz;  /* RBGB */
 };
 
+#define LRCLK_ASYNC(1 << 0)
+#define adg_mode_flags(adg)(adg->flags)
+
 #define for_each_rsnd_clk(pos, adg, i) \
for (i = 0; \
 (i < CLKMAX) &&\
@@ -355,6 +359,16 @@ found_clock:
 
rsnd_adg_set_ssi_clk(ssi_mod, data);
 
+   if (!(adg_mode_flags(adg) & LRCLK_ASYNC)) {
+   struct rsnd_mod *adg_mod = rsnd_mod_get(adg);
+   u32 ckr = 0;
+
+   if (0 == (rate % 8000))
+   ckr = 0x8000;
+
+   rsnd_mod_bset(adg_mod, SSICKR, 0x8000, ckr);
+   }
+
dev_dbg(dev, "ADG: %s[%d] selects 0x%x for %d\n",
rsnd_mod_name(ssi_mod), rsnd_mod_id(ssi_mod),
data, rate);
@@ -532,6 +546,7 @@ int rsnd_adg_probe(struct rsnd_priv *priv)
 {
struct rsnd_adg *adg;
struct device *dev = rsnd_priv_to_dev(priv);
+   struct device_node *np = dev->of_node;
 
adg = devm_kzalloc(dev, sizeof(*adg), GFP_KERNEL);
if (!adg) {
@@ -545,6 +560,9 @@ int rsnd_adg_probe(struct rsnd_priv *priv)
rsnd_adg_get_clkin(priv, adg);
rsnd_adg_get_clkout(priv, adg);
 
+   if (of_get_property(np, "clkout-lr-asynchronous", NULL))
+   adg->flags = LRCLK_ASYNC;
+
priv->adg = adg;
 
return 0;
-- 
1.9.1



Re: lm-senser can't detect thermal on thermal_zone

2016-06-08 Thread Kuninori Morimoto

Hi Zhang

Can you check this email ?

> > Thank you for your help
> > 
> > > > non thermal-zon
> > > >   sensor command: OK
> > > >   read from /sys/class/thermal/thermal_zone0 : OK
> > > > 
> > > > thermal-zon
> > > >   sensor command: NG
> > > >   read from /sys/class/thermal/thermal_zone0 : OK
> > > 
> > > config THERMAL_HWMON
> > > bool
> > > prompt "Expose thermal sensors as hwmon device"
> > > depends on HWMON=y || HWMON=THERMAL
> > > default y
> > > 
> > > please check if the thermal subsystem is built in, while hwmon subsystem
> > > is built as module.
> > > you should either set CONFIG_HWMON=y, or set both CONFIG_HWMON and
> > > CONFIG_THERMAL as module.
> > 
> > Thanks. but it seems our system has it.
> > 
> > I noticed that thermal_zone case uses of_parse_thermal_zones()
> > and it has this.
> > 
> > /* No hwmon because there might be hwmon drivers registering */
> > tzp->no_hwmon = true;
> > 
> > and on thermal_zone_device_register() check this for hwmon
> > 
> > struct thermal_zone_device *thermal_zone_device_register()
> > {
> > ...
> > if (!tz->tzp || !tz->tzp->no_hwmon) {
> > result = thermal_add_hwmon_sysfs(tz);
> > ...
> > }
> > ...
> > }
> > 
> > Does this mean "thermal_zone doesn't use lm-senser" ?
> 
> 
> Best regards
> ---
> Kuninori Morimoto


Re: [PATCH 0/2 v2] drm: rcar-du: EPROBE_DEFER case doesn't need error message

2016-06-08 Thread Kuninori Morimoto

Hi David

ping ?

> These removes unneeded error message from Renesas DU driver.
> Current this unneeded error message makes user confuse.
> 
> Kuninori Morimoto (2):
>   drm: rcar-du: error message is not needed for drm_vblank_init()
>   drm: rcar-du: error message is not needed for EPROBE_DEFER
> 
>  drivers/gpu/drm/rcar-du/rcar_du_drv.c | 7 +++
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 


Re: [PATCH v2 4/4] ARM: dts: r8a7790: lager: use demuxer for IIC3/I2C3

2016-06-08 Thread Simon Horman
On Wed, Jun 08, 2016 at 10:05:16AM +0200, Wolfram Sang wrote:
> On Wed, Jun 08, 2016 at 04:14:26PM +0900, Simon Horman wrote:
> > Create a separate bus for dla98063 PMIC and da9210 regulator
> > related I2C slaves.
> > 
> > Based on similar work for HDMI by Wolfram Sang.
> > 
> > Cc: Wolfram Sang 
> > Signed-off-by: Simon Horman 
> 
> Maybe add a word that PFC doesn't allow I2C0/I2C3 to be muxed as GPIO?

Sure, will do.


[PATCH 3/5] v4l: vsp1: lut: Initialize the mutex

2016-06-08 Thread Laurent Pinchart
The LUT mutex isn't initialized when creating the LUT, fix it.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/platform/vsp1/vsp1_lut.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/platform/vsp1/vsp1_lut.c 
b/drivers/media/platform/vsp1/vsp1_lut.c
index 2c367cb9755c..9a2c55b3570a 100644
--- a/drivers/media/platform/vsp1/vsp1_lut.c
+++ b/drivers/media/platform/vsp1/vsp1_lut.c
@@ -201,6 +201,8 @@ struct vsp1_lut *vsp1_lut_create(struct vsp1_device *vsp1)
if (lut == NULL)
return ERR_PTR(-ENOMEM);
 
+   mutex_init(>lock);
+
lut->entity.ops = _entity_ops;
lut->entity.type = VSP1_ENTITY_LUT;
 
-- 
Regards,

Laurent Pinchart



[PATCH 5/5] v4l: vsp1: Add Cubic Look Up Table (CLU) support

2016-06-08 Thread Laurent Pinchart
The CLU processing block is a 2D/3D lookup table that converts the input
three color component data into desired three color components using a
lookup table.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/platform/vsp1/Makefile  |   2 +-
 drivers/media/platform/vsp1/vsp1.h|   3 +
 drivers/media/platform/vsp1/vsp1_clu.c| 276 ++
 drivers/media/platform/vsp1/vsp1_clu.h|  44 +
 drivers/media/platform/vsp1/vsp1_drv.c|  25 ++-
 drivers/media/platform/vsp1/vsp1_entity.c |   1 +
 drivers/media/platform/vsp1/vsp1_entity.h |   1 +
 drivers/media/platform/vsp1/vsp1_regs.h   |   9 +
 8 files changed, 354 insertions(+), 7 deletions(-)
 create mode 100644 drivers/media/platform/vsp1/vsp1_clu.c
 create mode 100644 drivers/media/platform/vsp1/vsp1_clu.h

diff --git a/drivers/media/platform/vsp1/Makefile 
b/drivers/media/platform/vsp1/Makefile
index a12356bf2135..8ab6a063569e 100644
--- a/drivers/media/platform/vsp1/Makefile
+++ b/drivers/media/platform/vsp1/Makefile
@@ -1,7 +1,7 @@
 vsp1-y := vsp1_drv.o vsp1_entity.o vsp1_pipe.o
 vsp1-y += vsp1_dl.o vsp1_drm.o vsp1_video.o
 vsp1-y += vsp1_rpf.o vsp1_rwpf.o vsp1_wpf.o
-vsp1-y += vsp1_hsit.o vsp1_lif.o vsp1_lut.o
+vsp1-y += vsp1_clu.o vsp1_hsit.o vsp1_lut.o
 vsp1-y += vsp1_bru.o vsp1_sru.o vsp1_uds.o
 vsp1-y += vsp1_hgo.o vsp1_histo.o
 vsp1-y += vsp1_lif.o
diff --git a/drivers/media/platform/vsp1/vsp1.h 
b/drivers/media/platform/vsp1/vsp1.h
index 6bf6d54c0ae4..f5e58cea36cc 100644
--- a/drivers/media/platform/vsp1/vsp1.h
+++ b/drivers/media/platform/vsp1/vsp1.h
@@ -31,6 +31,7 @@ struct vsp1_drm;
 struct vsp1_entity;
 struct vsp1_platform_data;
 struct vsp1_bru;
+struct vsp1_clu;
 struct vsp1_hgo;
 struct vsp1_hsit;
 struct vsp1_lif;
@@ -48,6 +49,7 @@ struct vsp1_uds;
 #define VSP1_HAS_SRU   (1 << 2)
 #define VSP1_HAS_BRU   (1 << 3)
 #define VSP1_HAS_HGO   (1 << 4)
+#define VSP1_HAS_CLU   (1 << 5)
 
 struct vsp1_device_info {
u32 version;
@@ -68,6 +70,7 @@ struct vsp1_device {
struct rcar_fcp_device *fcp;
 
struct vsp1_bru *bru;
+   struct vsp1_clu *clu;
struct vsp1_hgo *hgo;
struct vsp1_hsit *hsi;
struct vsp1_hsit *hst;
diff --git a/drivers/media/platform/vsp1/vsp1_clu.c 
b/drivers/media/platform/vsp1/vsp1_clu.c
new file mode 100644
index ..5f56b3f14495
--- /dev/null
+++ b/drivers/media/platform/vsp1/vsp1_clu.c
@@ -0,0 +1,276 @@
+/*
+ * vsp1_clu.c  --  R-Car VSP1 Cubic Look-Up Table
+ *
+ * Copyright (C) 2015-2016 Renesas Electronics Corporation
+ *
+ * Contact: Laurent Pinchart (laurent.pinch...@ideasonboard.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+
+#include 
+
+#include "vsp1.h"
+#include "vsp1_clu.h"
+#include "vsp1_dl.h"
+
+#define CLU_MIN_SIZE   4U
+#define CLU_MAX_SIZE   8190U
+
+/* 
-
+ * Device Access
+ */
+
+static inline void vsp1_clu_write(struct vsp1_clu *clu, struct vsp1_dl_list 
*dl,
+ u32 reg, u32 data)
+{
+   vsp1_dl_list_write(dl, reg, data);
+}
+
+/* 
-
+ * Controls
+ */
+
+#define V4L2_CID_VSP1_CLU_TABLE(V4L2_CID_USER_BASE + 1)
+#define V4L2_CID_VSP1_CLU_MODE (V4L2_CID_USER_BASE + 2)
+#define V4L2_CID_VSP1_CLU_MODE_2D  0
+#define V4L2_CID_VSP1_CLU_MODE_3D  1
+
+static int clu_set_table(struct vsp1_clu *clu, struct v4l2_ctrl *ctrl)
+{
+   struct vsp1_dl_body *dlb;
+   unsigned int i;
+
+   dlb = vsp1_dl_fragment_alloc(clu->entity.vsp1, 1 + 17 * 17 * 17);
+   if (!dlb)
+   return -ENOMEM;
+
+   vsp1_dl_fragment_write(dlb, VI6_CLU_ADDR, 0);
+   for (i = 0; i < 17 * 17 * 17; ++i)
+   vsp1_dl_fragment_write(dlb, VI6_CLU_DATA, ctrl->p_new.p_u32[i]);
+
+   swap(clu->clu, dlb);
+
+   vsp1_dl_fragment_free(dlb);
+   return 0;
+}
+
+static int clu_s_ctrl(struct v4l2_ctrl *ctrl)
+{
+   struct vsp1_clu *clu =
+   container_of(ctrl->handler, struct vsp1_clu, ctrls);
+
+   switch (ctrl->id) {
+   case V4L2_CID_VSP1_CLU_TABLE:
+   clu_set_table(clu, ctrl);
+   break;
+
+   case V4L2_CID_VSP1_CLU_MODE:
+   clu->mode = ctrl->val;
+   break;
+ 

[PATCH 4/5] v4l: vsp1: lut: Expose configuration through a control

2016-06-08 Thread Laurent Pinchart
Replace the custom ioctl with a V4L2 control in order to standardize the
API.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/platform/vsp1/vsp1_lut.c | 74 ++
 drivers/media/platform/vsp1/vsp1_lut.h |  6 +--
 include/uapi/linux/vsp1.h  | 34 
 3 files changed, 52 insertions(+), 62 deletions(-)
 delete mode 100644 include/uapi/linux/vsp1.h

diff --git a/drivers/media/platform/vsp1/vsp1_lut.c 
b/drivers/media/platform/vsp1/vsp1_lut.c
index 9a2c55b3570a..4c2d1e3ddaf0 100644
--- a/drivers/media/platform/vsp1/vsp1_lut.c
+++ b/drivers/media/platform/vsp1/vsp1_lut.c
@@ -13,7 +13,6 @@
 
 #include 
 #include 
-#include 
 
 #include 
 
@@ -35,43 +34,60 @@ static inline void vsp1_lut_write(struct vsp1_lut *lut, 
struct vsp1_dl_list *dl,
 }
 
 /* 
-
- * V4L2 Subdevice Core Operations
+ * Controls
  */
 
-static int lut_set_table(struct vsp1_lut *lut, struct vsp1_lut_config *config)
+#define V4L2_CID_VSP1_LUT_TABLE(V4L2_CID_USER_BASE + 1)
+
+static int lut_set_table(struct vsp1_lut *lut, struct v4l2_ctrl *ctrl)
 {
struct vsp1_dl_body *dlb;
unsigned int i;
 
-   dlb = vsp1_dl_fragment_alloc(lut->entity.vsp1, ARRAY_SIZE(config->lut));
+   dlb = vsp1_dl_fragment_alloc(lut->entity.vsp1, 256);
if (!dlb)
return -ENOMEM;
 
-   for (i = 0; i < ARRAY_SIZE(config->lut); ++i)
+   for (i = 0; i < 256; ++i)
vsp1_dl_fragment_write(dlb, VI6_LUT_TABLE + 4 * i,
-  config->lut[i]);
+  ctrl->p_new.p_u32[i]);
 
-   mutex_lock(>lock);
swap(lut->lut, dlb);
-   mutex_unlock(>lock);
 
vsp1_dl_fragment_free(dlb);
return 0;
 }
 
-static long lut_ioctl(struct v4l2_subdev *subdev, unsigned int cmd, void *arg)
+static int lut_s_ctrl(struct v4l2_ctrl *ctrl)
 {
-   struct vsp1_lut *lut = to_lut(subdev);
-
-   switch (cmd) {
-   case VIDIOC_VSP1_LUT_CONFIG:
-   return lut_set_table(lut, arg);
+   struct vsp1_lut *lut =
+   container_of(ctrl->handler, struct vsp1_lut, ctrls);
 
-   default:
-   return -ENOIOCTLCMD;
+   switch (ctrl->id) {
+   case V4L2_CID_VSP1_LUT_TABLE:
+   lut_set_table(lut, ctrl);
+   break;
}
+
+   return 0;
 }
 
+static const struct v4l2_ctrl_ops lut_ctrl_ops = {
+   .s_ctrl = lut_s_ctrl,
+};
+
+static const struct v4l2_ctrl_config lut_table_control = {
+   .ops = _ctrl_ops,
+   .id = V4L2_CID_VSP1_LUT_TABLE,
+   .name = "Look-Up Table",
+   .type = V4L2_CTRL_TYPE_U32,
+   .min = 0x,
+   .max = 0x00ff,
+   .step = 1,
+   .def = 0,
+   .dims = { 256},
+};
+
 /* 
-
  * V4L2 Subdevice Pad Operations
  */
@@ -147,10 +163,6 @@ static int lut_set_format(struct v4l2_subdev *subdev,
  * V4L2 Subdevice Operations
  */
 
-static struct v4l2_subdev_core_ops lut_core_ops = {
-   .ioctl = lut_ioctl,
-};
-
 static struct v4l2_subdev_pad_ops lut_pad_ops = {
.init_cfg = vsp1_entity_init_cfg,
.enum_mbus_code = lut_enum_mbus_code,
@@ -160,7 +172,6 @@ static struct v4l2_subdev_pad_ops lut_pad_ops = {
 };
 
 static struct v4l2_subdev_ops lut_ops = {
-   .core   = _core_ops,
.pad= _pad_ops,
 };
 
@@ -176,12 +187,14 @@ static void lut_configure(struct vsp1_entity *entity,
 
vsp1_lut_write(lut, dl, VI6_LUT_CTRL, VI6_LUT_CTRL_EN);
 
-   mutex_lock(>lock);
+   mutex_lock(lut->ctrls.lock);
+
if (lut->lut) {
vsp1_dl_list_add_fragment(dl, lut->lut);
lut->lut = NULL;
}
-   mutex_unlock(>lock);
+
+   mutex_unlock(lut->ctrls.lock);
 }
 
 static const struct vsp1_entity_operations lut_entity_ops = {
@@ -201,8 +214,6 @@ struct vsp1_lut *vsp1_lut_create(struct vsp1_device *vsp1)
if (lut == NULL)
return ERR_PTR(-ENOMEM);
 
-   mutex_init(>lock);
-
lut->entity.ops = _entity_ops;
lut->entity.type = VSP1_ENTITY_LUT;
 
@@ -211,5 +222,18 @@ struct vsp1_lut *vsp1_lut_create(struct vsp1_device *vsp1)
if (ret < 0)
return ERR_PTR(ret);
 
+   /* Initialize the control handler. */
+   v4l2_ctrl_handler_init(>ctrls, 1);
+   v4l2_ctrl_new_custom(>ctrls, _table_control, NULL);
+
+   lut->entity.subdev.ctrl_handler = >ctrls;
+
+   if (lut->ctrls.error) {
+   dev_err(vsp1->dev, "lut: failed to initialize controls\n");
+   ret = lut->ctrls.error;
+   vsp1_entity_destroy(>entity);
+   return ERR_PTR(ret);
+   }
+
return lut;
 }
diff --git a/drivers/media/platform/vsp1/vsp1_lut.h 
b/drivers/media/platform/vsp1/vsp1_lut.h
index 

[PATCH 1/5] v4l: vsp1: pipe: Fix typo in comment

2016-06-08 Thread Laurent Pinchart
The vsp1_pipeline wq field is a wait queue, not a work queue. Fix the
comment accordingly.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/platform/vsp1/vsp1_pipe.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/vsp1/vsp1_pipe.h 
b/drivers/media/platform/vsp1/vsp1_pipe.h
index 3ecd3c1794a9..2cbf1a5ea1fb 100644
--- a/drivers/media/platform/vsp1/vsp1_pipe.h
+++ b/drivers/media/platform/vsp1/vsp1_pipe.h
@@ -61,7 +61,7 @@ enum vsp1_pipeline_state {
  * @pipe: the media pipeline
  * @irqlock: protects the pipeline state
  * @state: current state
- * @wq: work queue to wait for state change completion
+ * @wq: wait queue to wait for state change completion
  * @frame_end: frame end interrupt handler
  * @lock: protects the pipeline use count and stream count
  * @kref: pipeline reference count
-- 
Regards,

Laurent Pinchart



[PATCH 2/5] v4l: vsp1: dl: Don't free fragments with interrupts disabled

2016-06-08 Thread Laurent Pinchart
Freeing a fragment requires freeing DMA coherent memory, which can't be
performed with interrupts disabled as per the DMA mapping API contract.
The fragments can't thus be freed synchronously when a display list is
recycled. Instead, move the fragments to a garbage list and use a work
queue to run the garbage collection.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/platform/vsp1/vsp1_dl.c | 72 ---
 1 file changed, 58 insertions(+), 14 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1_dl.c 
b/drivers/media/platform/vsp1/vsp1_dl.c
index e238d9b9376b..37c3518aa2a8 100644
--- a/drivers/media/platform/vsp1/vsp1_dl.c
+++ b/drivers/media/platform/vsp1/vsp1_dl.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "vsp1.h"
 #include "vsp1_dl.h"
@@ -92,11 +93,13 @@ enum vsp1_dl_mode {
  * @index: index of the related WPF
  * @mode: display list operation mode (header or headerless)
  * @vsp1: the VSP1 device
- * @lock: protects the active, queued and pending lists
+ * @lock: protects the free, active, queued, pending and gc_fragments lists
  * @free: array of all free display lists
  * @active: list currently being processed (loaded) by hardware
  * @queued: list queued to the hardware (written to the DL registers)
  * @pending: list waiting to be queued to the hardware
+ * @gc_work: fragments garbage collector work struct
+ * @gc_fragments: array of display list fragments waiting to be freed
  */
 struct vsp1_dl_manager {
unsigned int index;
@@ -108,6 +111,9 @@ struct vsp1_dl_manager {
struct vsp1_dl_list *active;
struct vsp1_dl_list *queued;
struct vsp1_dl_list *pending;
+
+   struct work_struct gc_work;
+   struct list_head gc_fragments;
 };
 
 /* 
-
@@ -262,21 +268,10 @@ static struct vsp1_dl_list *vsp1_dl_list_alloc(struct 
vsp1_dl_manager *dlm)
return dl;
 }
 
-static void vsp1_dl_list_free_fragments(struct vsp1_dl_list *dl)
-{
-   struct vsp1_dl_body *dlb, *next;
-
-   list_for_each_entry_safe(dlb, next, >fragments, list) {
-   list_del(>list);
-   vsp1_dl_body_cleanup(dlb);
-   kfree(dlb);
-   }
-}
-
 static void vsp1_dl_list_free(struct vsp1_dl_list *dl)
 {
vsp1_dl_body_cleanup(>body0);
-   vsp1_dl_list_free_fragments(dl);
+   list_splice_init(>fragments, >dlm->gc_fragments);
kfree(dl);
 }
 
@@ -311,7 +306,16 @@ static void __vsp1_dl_list_put(struct vsp1_dl_list *dl)
if (!dl)
return;
 
-   vsp1_dl_list_free_fragments(dl);
+   /* We can't free fragments here as DMA memory can only be freed in
+* interruptible context. Move all fragments to the display list
+* manager's list of fragments to be freed, they will be
+* garbage-collected by the work queue.
+*/
+   if (!list_empty(>fragments)) {
+   list_splice_init(>fragments, >dlm->gc_fragments);
+   schedule_work(>dlm->gc_work);
+   }
+
dl->body0.num_entries = 0;
 
list_add_tail(>list, >dlm->free);
@@ -550,6 +554,40 @@ void vsp1_dlm_reset(struct vsp1_dl_manager *dlm)
dlm->pending = NULL;
 }
 
+/*
+ * Free all fragments awaiting to be garbage-collected.
+ *
+ * This function must be called without the display list manager lock held.
+ */
+static void vsp1_dlm_fragments_free(struct vsp1_dl_manager *dlm)
+{
+   unsigned long flags;
+
+   spin_lock_irqsave(>lock, flags);
+
+   while (!list_empty(>gc_fragments)) {
+   struct vsp1_dl_body *dlb;
+
+   dlb = list_first_entry(>gc_fragments, struct vsp1_dl_body,
+  list);
+   list_del(>list);
+
+   spin_unlock_irqrestore(>lock, flags);
+   vsp1_dl_fragment_free(dlb);
+   spin_lock_irqsave(>lock, flags);
+   }
+
+   spin_unlock_irqrestore(>lock, flags);
+}
+
+static void vsp1_dlm_garbage_collect(struct work_struct *work)
+{
+   struct vsp1_dl_manager *dlm =
+   container_of(work, struct vsp1_dl_manager, gc_work);
+
+   vsp1_dlm_fragments_free(dlm);
+}
+
 struct vsp1_dl_manager *vsp1_dlm_create(struct vsp1_device *vsp1,
unsigned int index,
unsigned int prealloc)
@@ -568,6 +606,8 @@ struct vsp1_dl_manager *vsp1_dlm_create(struct vsp1_device 
*vsp1,
 
spin_lock_init(>lock);
INIT_LIST_HEAD(>free);
+   INIT_LIST_HEAD(>gc_fragments);
+   INIT_WORK(>gc_work, vsp1_dlm_garbage_collect);
 
for (i = 0; i < prealloc; ++i) {
struct vsp1_dl_list *dl;
@@ -589,8 +629,12 @@ void vsp1_dlm_destroy(struct vsp1_dl_manager *dlm)
if (!dlm)
return;
 
+   cancel_work_sync(>gc_work);
+
list_for_each_entry_safe(dl, 

Re: [PATCH] ASoC: rsnd: adg :: AUDIO-CLKOUTn can synchronizes with L/R clock.

2016-06-08 Thread Kuninori Morimoto

Hi Mark

Thank you for your explanation

> > I'm now confusing. We can set system clock on audio card, for example
> > simple-card case, it is called as "system-clock-frequency".
> > In my understanding, this "system clock" and above "master clock" are same 
> > clock.
> > but "system clock" is fixed rate (= not related to audio clock in many 
> > cases).
> > Because of this, some codec doesn't request synchronous between
> > master clock <-> audio clock, but, some codec requests synchronous it.
> > Am I wrong ??
> 
> A lot of CODECs can to varying degrees tolerate this but it will tend to
> show up in performance numbers, it's often not immediately obvious just
> from a listening test.  Usually those that don't mind have a FLL or PLL
> they're using to generate the actual audio master clock at a useful rate
> for dividing down, or sometimes fancy digital logic to match things
> up.
> 
> It's not a problem to have this configurable, I'm just thinking it might
> be better to have the default be the other way around so that we default
> to synchronous but can turn that off if it's required.

OK, I see.
I checked existing DT, and default synchronous <-> asynchronous
exchange seems no problem.
So, synchronous will be default in v2


[PATCH v3 12/12] ARM: dts: blanche: add Ethernet support

2016-06-08 Thread Sergei Shtylyov
R8A7792  SoC  doesn't have the EtherMAC core, so SMSC  LAN89218  Ethernet
chip was used instead on the Blanche board; this chip  is compatible with
SMSC LAN9115  for  which there's a (device tree aware) driver. Describe
the  chip in  the  Blanche device tree;  enable DHCP and NFS root in the
kernel command line for the kernel booting.

Signed-off-by: Sergei Shtylyov 
Acked-by: Simon Horman 

---
Changes in version 3:
- refreshed the patch.

Changes in version 2:
- added Simon's ACK.

 arch/arm/boot/dts/r8a7792-blanche.dts |   23 ++-
 1 file changed, 22 insertions(+), 1 deletion(-)

Index: renesas/arch/arm/boot/dts/r8a7792-blanche.dts
===
--- renesas.orig/arch/arm/boot/dts/r8a7792-blanche.dts
+++ renesas/arch/arm/boot/dts/r8a7792-blanche.dts
@@ -22,7 +22,7 @@
};
 
chosen {
-   bootargs = "ignore_loglevel";
+   bootargs = "ignore_loglevel rw root=/dev/nfs ip=dhcp";
stdout-path = "serial0:115200n8";
};
 
@@ -30,6 +30,27 @@
device_type = "memory";
reg = <0 0x4000 0 0x4000>;
};
+
+   d3_3v: regulator-3v3 {
+   compatible = "regulator-fixed";
+   regulator-name = "D3.3V";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-boot-on;
+   regulator-always-on;
+   };
+
+   ethernet@1800 {
+   compatible = "smsc,lan89218", "smsc,lan9115";
+   reg = <0 0x1800 0 0x100>;
+   phy-mode = "mii";
+   interrupt-parent = <>;
+   interrupts = <0 IRQ_TYPE_EDGE_FALLING>;
+   smsc,irq-push-pull;
+   reg-io-width = <4>;
+   vddvario-supply = <_3v>;
+   vdd33a-supply = <_3v>;
+   };
 };
 
 _clk {



[PATCH v3 11/12] ARM: dts: blanche: initial device tree

2016-06-08 Thread Sergei Shtylyov
Add the initial device  tree for the R8A7792 SoC based Blanche board.
The board has 2 debug serial ports: SCIF0 and SCIF3; include support for
them,  so that  the serial console  can  work.

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

---
Changes in version 3:
- added Renesas Electronics' copyright.

Changes in version 2:
- added Simon's ACK and Geert's tag too.

 arch/arm/boot/dts/Makefile|1 
 arch/arm/boot/dts/r8a7792-blanche.dts |   45 ++
 2 files changed, 46 insertions(+)

Index: renesas/arch/arm/boot/dts/Makefile
===
--- renesas.orig/arch/arm/boot/dts/Makefile
+++ renesas/arch/arm/boot/dts/Makefile
@@ -638,6 +638,7 @@ dtb-$(CONFIG_ARCH_SHMOBILE_MULTI) += \
r8a7790-lager.dtb \
r8a7791-koelsch.dtb \
r8a7791-porter.dtb \
+   r8a7792-blanche.dtb \
r8a7793-gose.dtb \
r8a7794-alt.dtb \
r8a7794-silk.dtb \
Index: renesas/arch/arm/boot/dts/r8a7792-blanche.dts
===
--- /dev/null
+++ renesas/arch/arm/boot/dts/r8a7792-blanche.dts
@@ -0,0 +1,45 @@
+/*
+ * Device Tree Source for the Blanche board
+ *
+ * Copyright (C) 2014 Renesas Electronics Corporation
+ * Copyright (C) 2016 Cogent  Embedded, Inc.
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2.  This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+/dts-v1/;
+#include "r8a7792.dtsi"
+
+/ {
+   model = "Blanche";
+   compatible = "renesas,blanche", "renesas,r8a7792";
+
+   aliases {
+   serial0 = 
+   serial1 = 
+   };
+
+   chosen {
+   bootargs = "ignore_loglevel";
+   stdout-path = "serial0:115200n8";
+   };
+
+   memory@4000 {
+   device_type = "memory";
+   reg = <0 0x4000 0 0x4000>;
+   };
+};
+
+_clk {
+   clock-frequency = <2000>;
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};



[PATCH v3 09/12] ARM: dts: r8a7792: add IRQC support

2016-06-08 Thread Sergei Shtylyov
Describe the IRQC interrupt controller in the R8A7792 device tree.

Signed-off-by: Sergei Shtylyov 
Reviewed-by: Geert Uytterhoeven 

---
Changes in version 3:
- refreshed the patch.

Changes in version 2:
- resolved reject, indenting the IRQC node that is now under the "soc" node;
- added Geert's tag.

 arch/arm/boot/dts/r8a7792.dtsi |   13 +
 1 file changed, 13 insertions(+)

Index: renesas/arch/arm/boot/dts/r8a7792.dtsi
===
--- renesas.orig/arch/arm/boot/dts/r8a7792.dtsi
+++ renesas/arch/arm/boot/dts/r8a7792.dtsi
@@ -70,6 +70,19 @@
  IRQ_TYPE_LEVEL_HIGH)>;
};
 
+   irqc: interrupt-controller@e61c {
+   compatible = "renesas,irqc-r8a7792", "renesas,irqc";
+   #interrupt-cells = <2>;
+   interrupt-controller;
+   reg = <0 0xe61c 0 0x200>;
+   interrupts = ,
+,
+,
+;
+   clocks = <_clks R8A7792_CLK_IRQC>;
+   power-domains = < R8A7792_PD_ALWAYS_ON>;
+   };
+
timer {
compatible = "arm,armv7-timer";
interrupts = 

[PATCH v3 08/12] ARM: dts: r8a7792: add [H]SCIF support

2016-06-08 Thread Sergei Shtylyov
Describe [H]SCIFs in the R8A7792 device tree.

Signed-off-by: Sergei Shtylyov 
Reviewed-by: Geert Uytterhoeven 

---
Changes in version 3:
- refreshed the patch.

Changes in version 2:
- resolved reject, indenting the device nodes that are now under the "soc" node;
- added Geert's tag.

 arch/arm/boot/dts/r8a7792.dtsi |   90 +
 1 file changed, 90 insertions(+)

Index: renesas/arch/arm/boot/dts/r8a7792.dtsi
===
--- renesas.orig/arch/arm/boot/dts/r8a7792.dtsi
+++ renesas/arch/arm/boot/dts/r8a7792.dtsi
@@ -152,6 +152,96 @@
dma-channels = <15>;
};
 
+   scif0: serial@e6e6 {
+   compatible = "renesas,scif-r8a7792",
+"renesas,rcar-gen2-scif", "renesas,scif";
+   reg = <0 0xe6e6 0 64>;
+   interrupts = ;
+   clocks = <_clks R8A7792_CLK_SCIF0>, <_clk>,
+<_clk>;
+   clock-names = "fck", "brg_int", "scif_clk";
+   dmas = < 0x29>, < 0x2a>,
+  < 0x29>, < 0x2a>;
+   dma-names = "tx", "rx", "tx", "rx";
+   power-domains = < R8A7792_PD_ALWAYS_ON>;
+   status = "disabled";
+   };
+
+   scif1: serial@e6e68000 {
+   compatible = "renesas,scif-r8a7792",
+"renesas,rcar-gen2-scif", "renesas,scif";
+   reg = <0 0xe6e68000 0 64>;
+   interrupts = ;
+   clocks = <_clks R8A7792_CLK_SCIF1>, <_clk>,
+<_clk>;
+   clock-names = "fck", "brg_int", "scif_clk";
+   dmas = < 0x2d>, < 0x2e>,
+  < 0x2d>, < 0x2e>;
+   dma-names = "tx", "rx", "tx", "rx";
+   power-domains = < R8A7792_PD_ALWAYS_ON>;
+   status = "disabled";
+   };
+
+   scif2: serial@e6e58000 {
+   compatible = "renesas,scif-r8a7792",
+"renesas,rcar-gen2-scif", "renesas,scif";
+   reg = <0 0xe6e58000 0 64>;
+   interrupts = ;
+   clocks = <_clks R8A7792_CLK_SCIF2>, <_clk>,
+<_clk>;
+   clock-names = "fck", "brg_int", "scif_clk";
+   dmas = < 0x2b>, < 0x2c>,
+  < 0x2b>, < 0x2c>;
+   dma-names = "tx", "rx", "tx", "rx";
+   power-domains = < R8A7792_PD_ALWAYS_ON>;
+   status = "disabled";
+   };
+
+   scif3: serial@e6ea8000 {
+   compatible = "renesas,scif-r8a7792",
+"renesas,rcar-gen2-scif", "renesas,scif";
+   reg = <0 0xe6ea8000 0 64>;
+   interrupts = ;
+   clocks = <_clks R8A7792_CLK_SCIF3>, <_clk>,
+<_clk>;
+   clock-names = "fck", "brg_int", "scif_clk";
+   dmas = < 0x2f>, < 0x30>,
+  < 0x2f>, < 0x30>;
+   dma-names = "tx", "rx", "tx", "rx";
+   power-domains = < R8A7792_PD_ALWAYS_ON>;
+   status = "disabled";
+   };
+
+   hscif0: serial@e62c {
+   compatible = "renesas,hscif-r8a7792",
+"renesas,rcar-gen2-hscif", "renesas,hscif";
+   reg = <0 0xe62c 0 96>;
+   interrupts = ;
+   clocks = <_clks R8A7792_CLK_HSCIF0>, <_clk>,
+<_clk>;
+   clock-names = "fck", "brg_int", "scif_clk";
+   dmas = < 0x39>, < 0x3a>,
+  < 0x39>, < 0x3a>;
+   dma-names = "tx", "rx", "tx", "rx";
+   power-domains = < R8A7792_PD_ALWAYS_ON>;
+   status = "disabled";
+   };
+
+   hscif1: serial@e62c8000 {
+   compatible = "renesas,hscif-r8a7792",
+"renesas,rcar-gen2-hscif", "renesas,hscif";
+   reg = <0 0xe62c8000 0 96>;
+   interrupts = ;
+   clocks = <_clks R8A7792_CLK_HSCIF1>, <_clk>,
+<_clk>;
+   clock-names = "fck", "brg_int", "scif_clk";
+   dmas = < 0x4d>, < 0x4e>,
+  < 0x4d>, < 0x4e>;

[PATCH v3 07/12] ARM: dts: r8a7792: add SYS-DMAC support

2016-06-08 Thread Sergei Shtylyov
Describe SYS-DMAC0/1 in the R8A7792 device tree.

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

---
Changes in version 3:
- refreshed the patch.

Changes in version 2:
- resolved reject, indenting the device nodes that are now under the "soc" node;
- added Simon's ACK and Geert's tag too.

 arch/arm/boot/dts/r8a7792.dtsi |   64 +
 1 file changed, 64 insertions(+)

Index: renesas/arch/arm/boot/dts/r8a7792.dtsi
===
--- renesas.orig/arch/arm/boot/dts/r8a7792.dtsi
+++ renesas/arch/arm/boot/dts/r8a7792.dtsi
@@ -88,6 +88,70 @@
#power-domain-cells = <1>;
};
 
+   dmac0: dma-controller@e670 {
+   compatible = "renesas,dmac-r8a7792",
+"renesas,rcar-dmac";
+   reg = <0 0xe670 0 0x2>;
+   interrupts = ;
+   interrupt-names = "error",
+ "ch0", "ch1", "ch2", "ch3",
+ "ch4", "ch5", "ch6", "ch7",
+ "ch8", "ch9", "ch10", "ch11",
+ "ch12", "ch13", "ch14";
+   clocks = <_clks R8A7792_CLK_SYS_DMAC0>;
+   clock-names = "fck";
+   power-domains = < R8A7792_PD_ALWAYS_ON>;
+   #dma-cells = <1>;
+   dma-channels = <15>;
+   };
+
+   dmac1: dma-controller@e672 {
+   compatible = "renesas,dmac-r8a7792",
+"renesas,rcar-dmac";
+   reg = <0 0xe672 0 0x2>;
+   interrupts = ;
+   interrupt-names = "error",
+ "ch0", "ch1", "ch2", "ch3",
+ "ch4", "ch5", "ch6", "ch7",
+ "ch8", "ch9", "ch10", "ch11",
+ "ch12", "ch13", "ch14";
+   clocks = <_clks R8A7792_CLK_SYS_DMAC1>;
+   clock-names = "fck";
+   power-domains = < R8A7792_PD_ALWAYS_ON>;
+   #dma-cells = <1>;
+   dma-channels = <15>;
+   };
+
/* Special CPG clocks */
cpg_clocks: cpg_clocks@e615 {
compatible = "renesas,r8a7792-cpg-clocks",



[PATCH v3 06/12] ARM: dts: r8a7792: initial SoC device tree

2016-06-08 Thread Sergei Shtylyov
The initial R8A7792 SoC device tree including CPU cores, GIC, timer, SYSC,
and the required  clock descriptions.

Signed-off-by: Sergei Shtylyov 

---
Changes in version 3:
- moved the fixed factor clocks under the "soc" node;
- added back the CPU1 node, adjusted the changelog.

Changes in version 2:
- explicitly included the IRQ header;
- removed the CPU1 node;
- removed the audio and PCIe bus clocks;
- removed the SDH, SD0, and SD1 CPG clocks;
- added RCAN and ADSP CPG clocks;
- removed the PLL1/2, Z2, ZS, I, B, P, CL, M2, RCLK, OSCCLK, ZB3, ZB3D2, DDR,
  and MP fixed factor clocks;
- fixed up the parent and divisor for the CP fixed factor clock;
- swapped  the SYS-DMAC0/1 clocks;
- removed  all gated clocks except the [H]SCIF, IRQC, and SYS-DMAC ones;
- created  the "soc" subnode, moving the SoC  device  nodes there;
- removed  the "clocks" node, moving its fixed clock  subnodes to the root and
  the MSTP subnodes into the "soc" node.

 arch/arm/boot/dts/r8a7792.dtsi |  180 +
 1 file changed, 180 insertions(+)

Index: renesas/arch/arm/boot/dts/r8a7792.dtsi
===
--- /dev/null
+++ renesas/arch/arm/boot/dts/r8a7792.dtsi
@@ -0,0 +1,180 @@
+/*
+ * Device Tree Source for the r8a7792 SoC
+ *
+ * Copyright (C) 2016 Cogent Embedded Inc.
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2.  This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+/ {
+   compatible = "renesas,r8a7792";
+   #address-cells = <2>;
+   #size-cells = <2>;
+
+   cpus {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   cpu0: cpu@0 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a15";
+   reg = <0>;
+   clock-frequency = <10>;
+   clocks = <_clocks R8A7792_CLK_Z>;
+   power-domains = < R8A7792_PD_CA15_CPU0>;
+   next-level-cache = <_CA15>;
+   };
+
+   cpu1: cpu@1 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a15";
+   reg = <1>;
+   clock-frequency = <10>;
+   power-domains = < R8A7792_PD_CA15_CPU1>;
+   next-level-cache = <_CA15>;
+   };
+
+   L2_CA15: cache-controller@0 {
+   compatible = "cache";
+   reg = <0>;
+   cache-unified;
+   cache-level = <2>;
+   power-domains = < R8A7792_PD_CA15_SCU>;
+   };
+   };
+
+   soc {
+   compatible = "simple-bus";
+   interrupt-parent = <>;
+
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+
+   gic: interrupt-controller@f1001000 {
+   compatible = "arm,gic-400";
+   #interrupt-cells = <3>;
+   interrupt-controller;
+   reg = <0 0xf1001000 0 0x1000>,
+ <0 0xf1002000 0 0x1000>,
+ <0 0xf1004000 0 0x2000>,
+ <0 0xf1006000 0 0x2000>;
+   interrupts = ;
+   };
+
+   timer {
+   compatible = "arm,armv7-timer";
+   interrupts = ,
+,
+,
+;
+   };
+
+   sysc: system-controller@e618 {
+   compatible = "renesas,r8a7792-sysc";
+   reg = <0 0xe618 0 0x0200>;
+   #power-domain-cells = <1>;
+   };
+
+   /* Special CPG clocks */
+   cpg_clocks: cpg_clocks@e615 {
+   compatible = "renesas,r8a7792-cpg-clocks",
+"renesas,rcar-gen2-cpg-clocks";
+   reg = <0 0xe615 0 0x1000>;
+   clocks = <_clk>;
+   #clock-cells = <1>;
+   clock-output-names = "main", "pll0", "pll1", "pll3",
+"lb", "qspi", "z", "rcan", "adsp";
+   #power-domain-cells = <0>;
+   };
+
+   /* Fixed factor clocks */
+   zs_clk: zs {
+   compatible = "fixed-factor-clock";
+   clocks = <_clocks R8A7792_CLK_PLL1>;
+   #clock-cells = <0>;
+   clock-div = <6>;
+   clock-mult = <1>;

[PATCH v3 04/12] ARM: shmobile: r8a7792: basic SoC support

2016-06-08 Thread Sergei Shtylyov
Add minimal support for the R-Car V2H (R8A7792) SoC.

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

---
Changes in version 3:
- added Cogent Embedded's copyright;
- removed a supefluous space in Renesas Electronics' copyright.

Changes in version 2:
- removed 'select I2C';
- added Simon's ACK and Geert's tag too.

 arch/arm/mach-shmobile/Kconfig |4 +++
 arch/arm/mach-shmobile/Makefile|1 
 arch/arm/mach-shmobile/setup-r8a7792.c |   35 +
 3 files changed, 40 insertions(+)

Index: renesas/arch/arm/mach-shmobile/Kconfig
===
--- renesas.orig/arch/arm/mach-shmobile/Kconfig
+++ renesas/arch/arm/mach-shmobile/Kconfig
@@ -86,6 +86,10 @@ config ARCH_R8A7791
select ARCH_RCAR_GEN2
select I2C
 
+config ARCH_R8A7792
+   bool "R-Car V2H (R8A77920)"
+   select ARCH_RCAR_GEN2
+
 config ARCH_R8A7793
bool "R-Car M2-N (R8A7793)"
select ARCH_RCAR_GEN2
Index: renesas/arch/arm/mach-shmobile/Makefile
===
--- renesas.orig/arch/arm/mach-shmobile/Makefile
+++ renesas/arch/arm/mach-shmobile/Makefile
@@ -13,6 +13,7 @@ obj-$(CONFIG_ARCH_R8A7778)+= setup-r8a7
 obj-$(CONFIG_ARCH_R8A7779) += setup-r8a7779.o pm-r8a7779.o
 obj-$(CONFIG_ARCH_R8A7790) += setup-r8a7790.o
 obj-$(CONFIG_ARCH_R8A7791) += setup-r8a7791.o
+obj-$(CONFIG_ARCH_R8A7792) += setup-r8a7792.o
 obj-$(CONFIG_ARCH_R8A7793) += setup-r8a7793.o
 obj-$(CONFIG_ARCH_R8A7794) += setup-r8a7794.o
 obj-$(CONFIG_ARCH_EMEV2)   += setup-emev2.o
Index: renesas/arch/arm/mach-shmobile/setup-r8a7792.c
===
--- /dev/null
+++ renesas/arch/arm/mach-shmobile/setup-r8a7792.c
@@ -0,0 +1,35 @@
+/*
+ * r8a7792 processor support
+ *
+ * Copyright (C) 2014 Renesas Electronics Corporation
+ * Copyright (C) 2016 Cogent  Embedded, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+
+#include 
+
+#include "common.h"
+#include "rcar-gen2.h"
+
+static const char * const r8a7792_boards_compat_dt[] __initconst = {
+   "renesas,r8a7792",
+   NULL,
+};
+
+DT_MACHINE_START(R8A7792_DT, "Generic R8A7792 (Flattened Device Tree)")
+   .init_early = shmobile_init_delay,
+   .init_late  = shmobile_init_late,
+   .init_time  = rcar_gen2_timer_init,
+   .reserve= rcar_gen2_reserve,
+   .dt_compat  = r8a7792_boards_compat_dt,
+MACHINE_END



[PATCH v3 03/12] soc: renesas: rcar-sysc: add R8A7792 support

2016-06-08 Thread Sergei Shtylyov
Add support for R-Car V2H (R8A7792) SoC power areas to the SYSC driver.

Signed-off-by: Sergei Shtylyov 
Reviewed-by: Geert Uytterhoeven 

---
Changes in version 2:
- added Geert's tag.

 drivers/soc/renesas/Makefile   |1 +
 drivers/soc/renesas/r8a7792-sysc.c |   34 ++
 drivers/soc/renesas/rcar-sysc.c|3 +++
 drivers/soc/renesas/rcar-sysc.h|1 +
 4 files changed, 39 insertions(+)

Index: renesas/drivers/soc/renesas/Makefile
===
--- renesas.orig/drivers/soc/renesas/Makefile
+++ renesas/drivers/soc/renesas/Makefile
@@ -1,6 +1,7 @@
 obj-$(CONFIG_ARCH_R8A7779) += rcar-sysc.o r8a7779-sysc.o
 obj-$(CONFIG_ARCH_R8A7790) += rcar-sysc.o r8a7790-sysc.o
 obj-$(CONFIG_ARCH_R8A7791) += rcar-sysc.o r8a7791-sysc.o
+obj-$(CONFIG_ARCH_R8A7792) += rcar-sysc.o r8a7792-sysc.o
 # R-Car M2-N is identical to R-Car M2-W w.r.t. power domains.
 obj-$(CONFIG_ARCH_R8A7793) += rcar-sysc.o r8a7791-sysc.o
 obj-$(CONFIG_ARCH_R8A7794) += rcar-sysc.o r8a7794-sysc.o
Index: renesas/drivers/soc/renesas/r8a7792-sysc.c
===
--- /dev/null
+++ renesas/drivers/soc/renesas/r8a7792-sysc.c
@@ -0,0 +1,34 @@
+/*
+ * Renesas R-Car V2H (R8A7792) System Controller
+ *
+ * Copyright (C) 2016 Cogent Embedded Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+
+#include "rcar-sysc.h"
+
+static const struct rcar_sysc_area r8a7792_areas[] __initconst = {
+   { "always-on",  0, 0, R8A7792_PD_ALWAYS_ON, -1, PD_ALWAYS_ON },
+   { "ca15-scu",   0x180, 0, R8A7792_PD_CA15_SCU,  R8A7792_PD_ALWAYS_ON,
+ PD_SCU },
+   { "ca15-cpu0",   0x40, 0, R8A7792_PD_CA15_CPU0, R8A7792_PD_CA15_SCU,
+ PD_CPU_NOCR },
+   { "ca15-cpu1",   0x40, 1, R8A7792_PD_CA15_CPU1, R8A7792_PD_CA15_SCU,
+ PD_CPU_NOCR },
+   { "sgx", 0xc0, 0, R8A7792_PD_SGX,   R8A7792_PD_ALWAYS_ON },
+   { "imp",0x140, 0, R8A7792_PD_IMP,   R8A7792_PD_ALWAYS_ON },
+};
+
+const struct rcar_sysc_info r8a7792_sysc_info __initconst = {
+   .areas = r8a7792_areas,
+   .num_areas = ARRAY_SIZE(r8a7792_areas),
+};
Index: renesas/drivers/soc/renesas/rcar-sysc.c
===
--- renesas.orig/drivers/soc/renesas/rcar-sysc.c
+++ renesas/drivers/soc/renesas/rcar-sysc.c
@@ -293,6 +293,9 @@ static const struct of_device_id rcar_sy
 #ifdef CONFIG_ARCH_R8A7791
{ .compatible = "renesas,r8a7791-sysc", .data = _sysc_info },
 #endif
+#ifdef CONFIG_ARCH_R8A7792
+   { .compatible = "renesas,r8a7792-sysc", .data = _sysc_info },
+#endif
 #ifdef CONFIG_ARCH_R8A7793
/* R-Car M2-N is identical to R-Car M2-W w.r.t. power domains. */
{ .compatible = "renesas,r8a7793-sysc", .data = _sysc_info },
Index: renesas/drivers/soc/renesas/rcar-sysc.h
===
--- renesas.orig/drivers/soc/renesas/rcar-sysc.h
+++ renesas/drivers/soc/renesas/rcar-sysc.h
@@ -53,6 +53,7 @@ struct rcar_sysc_info {
 extern const struct rcar_sysc_info r8a7779_sysc_info;
 extern const struct rcar_sysc_info r8a7790_sysc_info;
 extern const struct rcar_sysc_info r8a7791_sysc_info;
+extern const struct rcar_sysc_info r8a7792_sysc_info;
 extern const struct rcar_sysc_info r8a7794_sysc_info;
 extern const struct rcar_sysc_info r8a7795_sysc_info;
 #endif /* __SOC_RENESAS_RCAR_SYSC_H__ */



[PATCH v3 02/12] ARM: shmobile: r8a7792: add power domain index macros

2016-06-08 Thread Sergei Shtylyov
Add macros usable by the device tree sources to reference R8A7792 SYSC power
domains by index.

Signed-off-by: Sergei Shtylyov 
Reviewed-by: Geert Uytterhoeven 

---
Changes in version 2:
- added Geert's tag.

 include/dt-bindings/power/r8a7792-sysc.h |   26 ++
 1 file changed, 26 insertions(+)

Index: renesas/include/dt-bindings/power/r8a7792-sysc.h
===
--- /dev/null
+++ renesas/include/dt-bindings/power/r8a7792-sysc.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2016 Cogent Embedded Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ */
+#ifndef __DT_BINDINGS_POWER_R8A7792_SYSC_H__
+#define __DT_BINDINGS_POWER_R8A7792_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 R8A7792_PD_CA15_CPU0   0
+#define R8A7792_PD_CA15_CPU1   1
+#define R8A7792_PD_CA15_SCU12
+#define R8A7792_PD_SGX 20
+#define R8A7792_PD_IMP 24
+
+/* Always-on power area */
+#define R8A7792_PD_ALWAYS_ON   32
+
+#endif /* __DT_BINDINGS_POWER_R8A7792_SYSC_H__ */



Re: [PATCH] i2c: mux: refer to i2c-mux.txt

2016-06-08 Thread Peter Rosin
Hi!

On 2016-06-08 08:21, Simon Horman wrote:
> Correct references to i2c-mux.txt which was previously mux.txt.
> 
> Also correct the spelling of relevant.
> 
> Signed-off-by: Simon Horman 
> ---
>  Documentation/devicetree/bindings/i2c/i2c-arb-gpio-challenge.txt | 4 ++--
>  Documentation/devicetree/bindings/i2c/i2c-demux-pinctrl.txt  | 3 ++-
>  Documentation/devicetree/bindings/i2c/i2c-mux-gpio.txt   | 6 +++---
>  Documentation/devicetree/bindings/i2c/i2c-mux-pinctrl.txt| 4 ++--
>  Documentation/devicetree/bindings/i2c/i2c-mux-reg.txt| 6 +++---
>  5 files changed, 12 insertions(+), 11 deletions(-)
> 

Acked-by: Peter Rosin 

Thanks,
Peter


[PATCH v3 01/12] ARM: shmobile: r8a7792: add clock index macros

2016-06-08 Thread Sergei Shtylyov
Add macros usable by the device tree sources to reference the R8A7792
clocks  by index.

Signed-off-by: Sergei Shtylyov 

---
Changes in version 2:
- removed the SDH, SD0, and SD1 clocks;
- added RCAN and ADSP clock indeces;
- fixed SYS-DMAC0/1 clock indeces.

 include/dt-bindings/clock/r8a7792-clock.h |  103 ++
 1 file changed, 103 insertions(+)

Index: renesas/include/dt-bindings/clock/r8a7792-clock.h
===
--- /dev/null
+++ renesas/include/dt-bindings/clock/r8a7792-clock.h
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2016 Cogent Embedded, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef __DT_BINDINGS_CLOCK_R8A7792_H__
+#define __DT_BINDINGS_CLOCK_R8A7792_H__
+
+/* CPG */
+#define R8A7792_CLK_MAIN   0
+#define R8A7792_CLK_PLL0   1
+#define R8A7792_CLK_PLL1   2
+#define R8A7792_CLK_PLL3   3
+#define R8A7792_CLK_LB 4
+#define R8A7792_CLK_QSPI   5
+#define R8A7792_CLK_Z  6
+#define R8A7792_CLK_RCAN   7
+#define R8A7792_CLK_ADSP   8
+
+/* MSTP0 */
+#define R8A7792_CLK_MSIOF0 0
+
+/* MSTP1 */
+#define R8A7792_CLK_TMU1   11
+#define R8A7792_CLK_TMU3   21
+#define R8A7792_CLK_TMU2   22
+#define R8A7792_CLK_CMT0   24
+#define R8A7792_CLK_TMU0   25
+#define R8A7792_CLK_VSP1DU127
+#define R8A7792_CLK_VSP1DU028
+#define R8A7792_CLK_VSP1_SY31
+
+/* MSTP2 */
+#define R8A7792_CLK_MSIOF1 8
+#define R8A7792_CLK_SYS_DMAC1  18
+#define R8A7792_CLK_SYS_DMAC0  19
+
+/* MSTP3 */
+#define R8A7792_CLK_TPU0   4
+#define R8A7792_CLK_SDHI0  14
+#define R8A7792_CLK_CMT1   29
+
+/* MSTP4 */
+#define R8A7792_CLK_IRQC   7
+
+/* MSTP5 */
+#define R8A7792_CLK_AUDIO_DMAC02
+#define R8A7792_CLK_THERMAL22
+#define R8A7792_CLK_PWM23
+
+/* MSTP7 */
+#define R8A7792_CLK_HSCIF1 16
+#define R8A7792_CLK_HSCIF0 17
+#define R8A7792_CLK_SCIF3  18
+#define R8A7792_CLK_SCIF2  19
+#define R8A7792_CLK_SCIF1  20
+#define R8A7792_CLK_SCIF0  21
+#define R8A7792_CLK_DU123
+#define R8A7792_CLK_DU024
+
+/* MSTP8 */
+#define R8A7792_CLK_VIN5   4
+#define R8A7792_CLK_VIN4   5
+#define R8A7792_CLK_VIN3   8
+#define R8A7792_CLK_VIN2   9
+#define R8A7792_CLK_VIN1   10
+#define R8A7792_CLK_VIN0   11
+#define R8A7792_CLK_ETHERAVB   12
+
+/* MSTP9 */
+#define R8A7792_CLK_GPIO7  4
+#define R8A7792_CLK_GPIO6  5
+#define R8A7792_CLK_GPIO5  7
+#define R8A7792_CLK_GPIO4  8
+#define R8A7792_CLK_GPIO3  9
+#define R8A7792_CLK_GPIO2  10
+#define R8A7792_CLK_GPIO1  11
+#define R8A7792_CLK_GPIO0  12
+#define R8A7792_CLK_GPIO11 13
+#define R8A7792_CLK_GPIO10 14
+#define R8A7792_CLK_CAN1   15
+#define R8A7792_CLK_CAN0   16
+#define R8A7792_CLK_QSPI_MOD   17
+#define R8A7792_CLK_GPIO9  19
+#define R8A7792_CLK_GPIO8  21
+#define R8A7792_CLK_I2C5   25
+#define R8A7792_CLK_IICDVFS26
+#define R8A7792_CLK_I2C4   27
+#define R8A7792_CLK_I2C3   28
+#define R8A7792_CLK_I2C2   29
+#define R8A7792_CLK_I2C1   30
+#define R8A7792_CLK_I2C0   31
+
+/* MSTP10 */
+#define R8A7792_CLK_SSI_ALL5
+#define R8A7792_CLK_SSI4   11
+#define R8A7792_CLK_SSI3   12
+
+#endif /* __DT_BINDINGS_CLOCK_R8A7792_H__ */



[PATCH v3 00/12] Add R8A7792/Blanche board support

2016-06-08 Thread Sergei Shtylyov
Hello.

   Here's the set of 12 patches against Simon Horman's 'renesas.git' repo,
'renesas-devel-20160606-v4.7-rc2' tag. We add the device tree support for
the R8A7792-based Blanche board. Added in this version is the SMP support.
The R-Car 'clk' driver patch was posted separately and 2 'clk' binding patches
were split from this series...

[01/12] ARM: shmobile: r8a7792: add clock index macros
[02/12] ARM: shmobile: r8a7792: add power domain index macros
[03/12] soc: renesas: rcar-sysc: add R8A7792 support
[04/12] ARM: shmobile: r8a7792: basic SoC support
[05/12] ARM: shmobile: r8a7792: add SMP support
[06/12] ARM: dts: r8a7792: initial SoC device tree
[07/12] ARM: dts: r8a7792: add SYS-DMAC support
[08/12] ARM: dts: r8a7792: add [H]SCIF support
[09/12] ARM dts: r8a7792: add IRQC support
[10/12] DT: arm: shmobile: document Blanche board
[11/12] ARM: dts: blanche: initial device tree
[12/12] ARM: dts: blanche: add Ethernet support

WBR, Sergei



Re: [PATCH] ASoC: rsnd: adg :: AUDIO-CLKOUTn can synchronizes with L/R clock.

2016-06-08 Thread Mark Brown
On Wed, Jun 08, 2016 at 12:27:48AM +, Kuninori Morimoto wrote:

> > Why would a user not want these clocks to be synchronous?  A lot of
> > CODECs will at least have better performance if their master clock is
> > synchronous to the audio clocks so it'd be a better default, is there an
> > advantage to not doing it?

> I'm now confusing. We can set system clock on audio card, for example
> simple-card case, it is called as "system-clock-frequency".
> In my understanding, this "system clock" and above "master clock" are same 
> clock.
> but "system clock" is fixed rate (= not related to audio clock in many cases).
> Because of this, some codec doesn't request synchronous between
> master clock <-> audio clock, but, some codec requests synchronous it.
> Am I wrong ??

A lot of CODECs can to varying degrees tolerate this but it will tend to
show up in performance numbers, it's often not immediately obvious just
from a listening test.  Usually those that don't mind have a FLL or PLL
they're using to generate the actual audio master clock at a useful rate
for dividing down, or sometimes fancy digital logic to match things
up.

It's not a problem to have this configurable, I'm just thinking it might
be better to have the default be the other way around so that we default
to synchronous but can turn that off if it's required.


signature.asc
Description: PGP signature


Re: [PATCH 0/9] clocksource/drivers/clksrc-of: Improve error handling

2016-06-08 Thread Daniel Lezcano

On 06/07/2016 11:54 AM, Geert Uytterhoeven wrote:

[ ... ]


in clockevents/clockevents/next breaks the boot on e.g. r8a7791/koelsch
(arm32) and r8a7795/salvator-x (arm64).

Using "earlycon keep_bootcon" on koelsch (this doesn't help on arm64)
reveals it's stuck at:

 clocksource_probe: no matching clocksources found
 sched_clock: 32 bits at 100 Hz, resolution 1000ns, wraps every
2147483647500ns
 Calibrating delay loop...

With the above commit reverted, it works again:

 Architected cp15 timer(s) running at 10.00MHz (virt).
 clocksource: arch_sys_counter: mask: 0xff max_cycles:
0x24e6a1710, max_idle_ns: 440795202120 ns
 sched_clock: 56 bits at 10MHz, resolution 100ns, wraps every 
4398046511100ns
 Switching to timer-based delay loop, resolution 100ns
 Calibrating delay loop (skipped), value calculated using timer
frequency.. 20.00 BogoMIPS (lpj=10)


I think it is fixed now and pushed on my tree. Is it possible to confirm 
your boards are working correctly again after the linux-next is updated 
with my latest changes ?


Thanks for the report.

  -- Daniel


--
  Linaro.org │ Open source software for ARM SoCs

Follow Linaro:   Facebook |
 Twitter |
 Blog



Re: [PATCH] pinctrl: sh-pfc: fix warnings by include core.h

2016-06-08 Thread Linus Walleij
On Tue, Jun 7, 2016 at 7:33 PM, Ben Dooks  wrote:

> Fix warnings about emev2_pinmux_info and r8a7779_pinmux_info
> by using core.h instead of sh_pfc.h in these files. This gives
> the declarations of the two structures and removes the following
> warnings:
>
> drivers/pinctrl/sh-pfc/pfc-emev2.c:1695:30: warning: symbol 
> 'emev2_pinmux_info' was not declared. Should it be static?
> drivers/pinctrl/sh-pfc/pfc-r8a7779.c:3888:30: warning: symbol 
> 'r8a7779_pinmux_info' was not declared. Should it be static?
>
> Signed-off-by: Ben Dooks 

Geert/Laurent:

- take a look at this patch
- shall I apply this directly?

Yours,
Linus Walleij


Re: [PATCH v2 07/20] drm: mediatek: Rely on the default ->best_encoder() behavior

2016-06-08 Thread Matthias Brugger



On 07/06/16 13:48, Boris Brezillon wrote:

We have a 1:1 relationship between connectors and encoders and the
driver is relying on the atomic helpers: we can drop the custom
->best_encoder() implementation and let the core call
drm_atomic_helper_best_encoder() for us.

Signed-off-by: Boris Brezillon 


Reviewed-by: Matthias Brugger 


---
  drivers/gpu/drm/mediatek/mtk_dsi.c | 9 -
  1 file changed, 9 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c 
b/drivers/gpu/drm/mediatek/mtk_dsi.c
index 2d808e5..7343ffc 100644
--- a/drivers/gpu/drm/mediatek/mtk_dsi.c
+++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
@@ -575,14 +575,6 @@ static int mtk_dsi_connector_get_modes(struct 
drm_connector *connector)
return drm_panel_get_modes(dsi->panel);
  }

-static struct drm_encoder *mtk_dsi_connector_best_encoder(
-   struct drm_connector *connector)
-{
-   struct mtk_dsi *dsi = connector_to_dsi(connector);
-
-   return >encoder;
-}
-
  static const struct drm_encoder_helper_funcs mtk_dsi_encoder_helper_funcs = {
.mode_fixup = mtk_dsi_encoder_mode_fixup,
.mode_set = mtk_dsi_encoder_mode_set,
@@ -603,7 +595,6 @@ static const struct drm_connector_funcs 
mtk_dsi_connector_funcs = {
  static const struct drm_connector_helper_funcs
mtk_dsi_connector_helper_funcs = {
.get_modes = mtk_dsi_connector_get_modes,
-   .best_encoder = mtk_dsi_connector_best_encoder,
  };

  static int mtk_drm_attach_bridge(struct drm_bridge *bridge,



Re: [PATCH v2 08/20] drm: msm: Rely on the default ->best_encoder() behavior where appropriate

2016-06-08 Thread Archit Taneja

Hi,

On 06/07/2016 05:18 PM, Boris Brezillon wrote:

For all outputs except DSI we have a 1:1 relationship between connectors
and encoders and the driver is relying on the atomic helpers: we can
drop the custom ->best_encoder() and let the core call
drm_atomic_helper_best_encoder() for us.


Works fine with msm.

Tested-by: Archit Taneja 

Thanks,
Archit



Signed-off-by: Boris Brezillon 
---
  drivers/gpu/drm/msm/edp/edp_connector.c| 10 --
  drivers/gpu/drm/msm/hdmi/hdmi_connector.c  |  8 
  drivers/gpu/drm/msm/mdp/mdp4/mdp4_lvds_connector.c |  9 -
  3 files changed, 27 deletions(-)

diff --git a/drivers/gpu/drm/msm/edp/edp_connector.c 
b/drivers/gpu/drm/msm/edp/edp_connector.c
index 72360cd..5960628 100644
--- a/drivers/gpu/drm/msm/edp/edp_connector.c
+++ b/drivers/gpu/drm/msm/edp/edp_connector.c
@@ -91,15 +91,6 @@ static int edp_connector_mode_valid(struct drm_connector 
*connector,
return MODE_OK;
  }

-static struct drm_encoder *
-edp_connector_best_encoder(struct drm_connector *connector)
-{
-   struct edp_connector *edp_connector = to_edp_connector(connector);
-
-   DBG("");
-   return edp_connector->edp->encoder;
-}
-
  static const struct drm_connector_funcs edp_connector_funcs = {
.dpms = drm_atomic_helper_connector_dpms,
.detect = edp_connector_detect,
@@ -113,7 +104,6 @@ static const struct drm_connector_funcs edp_connector_funcs 
= {
  static const struct drm_connector_helper_funcs edp_connector_helper_funcs = {
.get_modes = edp_connector_get_modes,
.mode_valid = edp_connector_mode_valid,
-   .best_encoder = edp_connector_best_encoder,
  };

  /* initialize connector */
diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_connector.c 
b/drivers/gpu/drm/msm/hdmi/hdmi_connector.c
index b15d726..a2515b4 100644
--- a/drivers/gpu/drm/msm/hdmi/hdmi_connector.c
+++ b/drivers/gpu/drm/msm/hdmi/hdmi_connector.c
@@ -406,13 +406,6 @@ static int msm_hdmi_connector_mode_valid(struct 
drm_connector *connector,
return 0;
  }

-static struct drm_encoder *
-msm_hdmi_connector_best_encoder(struct drm_connector *connector)
-{
-   struct hdmi_connector *hdmi_connector = to_hdmi_connector(connector);
-   return hdmi_connector->hdmi->encoder;
-}
-
  static const struct drm_connector_funcs hdmi_connector_funcs = {
.dpms = drm_atomic_helper_connector_dpms,
.detect = hdmi_connector_detect,
@@ -426,7 +419,6 @@ static const struct drm_connector_funcs 
hdmi_connector_funcs = {
  static const struct drm_connector_helper_funcs 
msm_hdmi_connector_helper_funcs = {
.get_modes = msm_hdmi_connector_get_modes,
.mode_valid = msm_hdmi_connector_mode_valid,
-   .best_encoder = msm_hdmi_connector_best_encoder,
  };

  /* initialize connector */
diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_lvds_connector.c 
b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_lvds_connector.c
index 2648cd7..353429b 100644
--- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_lvds_connector.c
+++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_lvds_connector.c
@@ -90,14 +90,6 @@ static int mdp4_lvds_connector_mode_valid(struct 
drm_connector *connector,
return MODE_OK;
  }

-static struct drm_encoder *
-mdp4_lvds_connector_best_encoder(struct drm_connector *connector)
-{
-   struct mdp4_lvds_connector *mdp4_lvds_connector =
-   to_mdp4_lvds_connector(connector);
-   return mdp4_lvds_connector->encoder;
-}
-
  static const struct drm_connector_funcs mdp4_lvds_connector_funcs = {
.dpms = drm_atomic_helper_connector_dpms,
.detect = mdp4_lvds_connector_detect,
@@ -111,7 +103,6 @@ static const struct drm_connector_funcs 
mdp4_lvds_connector_funcs = {
  static const struct drm_connector_helper_funcs 
mdp4_lvds_connector_helper_funcs = {
.get_modes = mdp4_lvds_connector_get_modes,
.mode_valid = mdp4_lvds_connector_mode_valid,
-   .best_encoder = mdp4_lvds_connector_best_encoder,
  };

  /* initialize connector */



--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora 
Forum, hosted by The Linux Foundation


Re: [PATCH v2 11/20] drm: sti: Rely on the default ->best_encoder() behavior

2016-06-08 Thread Vincent ABRIOU
Hi Boris,

Thanks for the patch.

Acked-by: Vincent Abriou 

Vincent

On 06/07/2016 01:48 PM, Boris Brezillon wrote:
> All outputs have a 1:1 relationship between connectors and encoders
> and the driver is relying on the atomic helpers: we can drop the custom
> ->best_encoder() implementations and let the core call
> drm_atomic_helper_best_encoder() for us.
>
> Signed-off-by: Boris Brezillon 
> ---
>   drivers/gpu/drm/sti/sti_dvo.c  | 10 --
>   drivers/gpu/drm/sti/sti_hda.c  | 10 --
>   drivers/gpu/drm/sti/sti_hdmi.c | 10 --
>   3 files changed, 30 deletions(-)
>
> diff --git a/drivers/gpu/drm/sti/sti_dvo.c b/drivers/gpu/drm/sti/sti_dvo.c
> index 25f7663..d5627d1 100644
> --- a/drivers/gpu/drm/sti/sti_dvo.c
> +++ b/drivers/gpu/drm/sti/sti_dvo.c
> @@ -384,20 +384,10 @@ static int sti_dvo_connector_mode_valid(struct 
> drm_connector *connector,
>   return MODE_OK;
>   }
>
> -struct drm_encoder *sti_dvo_best_encoder(struct drm_connector *connector)
> -{
> - struct sti_dvo_connector *dvo_connector
> - = to_sti_dvo_connector(connector);
> -
> - /* Best encoder is the one associated during connector creation */
> - return dvo_connector->encoder;
> -}
> -
>   static const
>   struct drm_connector_helper_funcs sti_dvo_connector_helper_funcs = {
>   .get_modes = sti_dvo_connector_get_modes,
>   .mode_valid = sti_dvo_connector_mode_valid,
> - .best_encoder = sti_dvo_best_encoder,
>   };
>
>   static enum drm_connector_status
> diff --git a/drivers/gpu/drm/sti/sti_hda.c b/drivers/gpu/drm/sti/sti_hda.c
> index f7d3464..c4649f5 100644
> --- a/drivers/gpu/drm/sti/sti_hda.c
> +++ b/drivers/gpu/drm/sti/sti_hda.c
> @@ -676,20 +676,10 @@ static int sti_hda_connector_mode_valid(struct 
> drm_connector *connector,
>   return MODE_OK;
>   }
>
> -struct drm_encoder *sti_hda_best_encoder(struct drm_connector *connector)
> -{
> - struct sti_hda_connector *hda_connector
> - = to_sti_hda_connector(connector);
> -
> - /* Best encoder is the one associated during connector creation */
> - return hda_connector->encoder;
> -}
> -
>   static const
>   struct drm_connector_helper_funcs sti_hda_connector_helper_funcs = {
>   .get_modes = sti_hda_connector_get_modes,
>   .mode_valid = sti_hda_connector_mode_valid,
> - .best_encoder = sti_hda_best_encoder,
>   };
>
>   static enum drm_connector_status
> diff --git a/drivers/gpu/drm/sti/sti_hdmi.c b/drivers/gpu/drm/sti/sti_hdmi.c
> index 6ef0715..dc9ab6e 100644
> --- a/drivers/gpu/drm/sti/sti_hdmi.c
> +++ b/drivers/gpu/drm/sti/sti_hdmi.c
> @@ -897,20 +897,10 @@ static int sti_hdmi_connector_mode_valid(struct 
> drm_connector *connector,
>   return MODE_OK;
>   }
>
> -struct drm_encoder *sti_hdmi_best_encoder(struct drm_connector *connector)
> -{
> - struct sti_hdmi_connector *hdmi_connector
> - = to_sti_hdmi_connector(connector);
> -
> - /* Best encoder is the one associated during connector creation */
> - return hdmi_connector->encoder;
> -}
> -
>   static const
>   struct drm_connector_helper_funcs sti_hdmi_connector_helper_funcs = {
>   .get_modes = sti_hdmi_connector_get_modes,
>   .mode_valid = sti_hdmi_connector_mode_valid,
> - .best_encoder = sti_hdmi_best_encoder,
>   };
>
>   /* get detection status of display device */
>


Re: [PATCH 3/3] iommu/ipmmu-vmsa: Hook up r8a7796 DT matching code

2016-06-08 Thread Magnus Damm
Hi Laurent,

On Wed, Jun 8, 2016 at 5:48 PM, Laurent Pinchart
 wrote:
> Hi Geert,
>
> On Wednesday 08 Jun 2016 09:04:17 Geert Uytterhoeven wrote:
>> On Wed, Jun 8, 2016 at 2:18 AM, Laurent Pinchart wrote:
>> >> --- 0031/drivers/iommu/ipmmu-vmsa.c
>> >> +++ work/drivers/iommu/ipmmu-vmsa.c   2016-06-06 11:19:40.210607110 +0900
>> >> @@ -1074,7 +1074,7 @@ static const struct ipmmu_features ipmmu
>> >>   .twobit_imttbcr_sl0 = false,
>  >>  };
>> >>
>> >> -static const struct ipmmu_features ipmmu_features_r8a7795 = {
>> >> +static const struct ipmmu_features ipmmu_features_rcar_gen3 = {
>> >>   .use_ns_alias_offset = false,
>> >>   .has_cache_leaf_nodes = true,
>> >>   .has_eight_ctx = true,
>> >> @@ -1088,7 +1088,10 @@ static const struct of_device_id ipmmu_o
>> >>   .data = _features_default,
>> >>   }, {
>> >>   .compatible = "renesas,ipmmu-r8a7795",
>> >> - .data = _features_r8a7795,
>> >> + .data = _features_rcar_gen3,
>> >> + }, {
>> >> + .compatible = "renesas,ipmmu-r8a7796",
>> >> + .data = _features_rcar_gen3,
>> >>   }, {
>> >>   /* Terminator */
>> >>   },
>> >> @@ -1268,6 +1271,8 @@ IOMMU_OF_DECLARE(ipmmu_vmsa_iommu_of, "r
>> >>ipmmu_vmsa_iommu_of_setup);
>> >>  IOMMU_OF_DECLARE(ipmmu_r8a7795_iommu_of, "renesas,ipmmu-r8a7795",
>> >>ipmmu_vmsa_iommu_of_setup);
>> >> +IOMMU_OF_DECLARE(ipmmu_r8a7796_iommu_of, "renesas,ipmmu-r8a7796",
>> >> +  ipmmu_vmsa_iommu_of_setup);
>> >
>> > How about a Gen3 generic compatible string in addition to the SoC-specific
>> > ones ?
>>
>> Do we want to specify the number of utlbs here?
>> Does it differ between r8a7795, r8a7796, and future members?
>
> It differs between IPMMU instances on a given SoC, so if we want to specify it
> it should be a DT property.

Can you please point out which documentation that says it varies with
IPMMU instance?

Based on IMUCTRn register description "H3-ES1" has 0-31 range while
"Others" have 0-47.

Thanks,

/ magnus


Re: [PATCH 3/3] iommu/ipmmu-vmsa: Hook up r8a7796 DT matching code

2016-06-08 Thread Laurent Pinchart
Hi Geert,

On Wednesday 08 Jun 2016 09:04:17 Geert Uytterhoeven wrote:
> On Wed, Jun 8, 2016 at 2:18 AM, Laurent Pinchart wrote:
> >> --- 0031/drivers/iommu/ipmmu-vmsa.c
> >> +++ work/drivers/iommu/ipmmu-vmsa.c   2016-06-06 11:19:40.210607110 +0900
> >> @@ -1074,7 +1074,7 @@ static const struct ipmmu_features ipmmu
> >>   .twobit_imttbcr_sl0 = false,
 >>  };
> >> 
> >> -static const struct ipmmu_features ipmmu_features_r8a7795 = {
> >> +static const struct ipmmu_features ipmmu_features_rcar_gen3 = {
> >>   .use_ns_alias_offset = false,
> >>   .has_cache_leaf_nodes = true,
> >>   .has_eight_ctx = true,
> >> @@ -1088,7 +1088,10 @@ static const struct of_device_id ipmmu_o
> >>   .data = _features_default,
> >>   }, {
> >>   .compatible = "renesas,ipmmu-r8a7795",
> >> - .data = _features_r8a7795,
> >> + .data = _features_rcar_gen3,
> >> + }, {
> >> + .compatible = "renesas,ipmmu-r8a7796",
> >> + .data = _features_rcar_gen3,
> >>   }, {
> >>   /* Terminator */
> >>   },
> >> @@ -1268,6 +1271,8 @@ IOMMU_OF_DECLARE(ipmmu_vmsa_iommu_of, "r
> >>ipmmu_vmsa_iommu_of_setup);
> >>  IOMMU_OF_DECLARE(ipmmu_r8a7795_iommu_of, "renesas,ipmmu-r8a7795",
> >>ipmmu_vmsa_iommu_of_setup);
> >> +IOMMU_OF_DECLARE(ipmmu_r8a7796_iommu_of, "renesas,ipmmu-r8a7796",
> >> +  ipmmu_vmsa_iommu_of_setup);
> > 
> > How about a Gen3 generic compatible string in addition to the SoC-specific
> > ones ?
> 
> Do we want to specify the number of utlbs here?
> Does it differ between r8a7795, r8a7796, and future members?

It differs between IPMMU instances on a given SoC, so if we want to specify it 
it should be a DT property.

-- 
Regards,

Laurent Pinchart



Re: [PATCH 3/3] iommu/ipmmu-vmsa: Hook up r8a7796 DT matching code

2016-06-08 Thread Magnus Damm
Hi Geert,

On Wed, Jun 8, 2016 at 4:04 PM, Geert Uytterhoeven  wrote:
> Hi Laurent,
>
> On Wed, Jun 8, 2016 at 2:18 AM, Laurent Pinchart
>  wrote:
>>> --- 0031/drivers/iommu/ipmmu-vmsa.c
>>> +++ work/drivers/iommu/ipmmu-vmsa.c   2016-06-06 11:19:40.210607110 +0900
>>> @@ -1074,7 +1074,7 @@ static const struct ipmmu_features ipmmu
>>>   .twobit_imttbcr_sl0 = false,
>>>  };
>>>
>>> -static const struct ipmmu_features ipmmu_features_r8a7795 = {
>>> +static const struct ipmmu_features ipmmu_features_rcar_gen3 = {
>>>   .use_ns_alias_offset = false,
>>>   .has_cache_leaf_nodes = true,
>>>   .has_eight_ctx = true,
>>> @@ -1088,7 +1088,10 @@ static const struct of_device_id ipmmu_o
>>>   .data = _features_default,
>>>   }, {
>>>   .compatible = "renesas,ipmmu-r8a7795",
>>> - .data = _features_r8a7795,
>>> + .data = _features_rcar_gen3,
>>> + }, {
>>> + .compatible = "renesas,ipmmu-r8a7796",
>>> + .data = _features_rcar_gen3,
>>>   }, {
>>>   /* Terminator */
>>>   },
>>> @@ -1268,6 +1271,8 @@ IOMMU_OF_DECLARE(ipmmu_vmsa_iommu_of, "r
>>>ipmmu_vmsa_iommu_of_setup);
>>>  IOMMU_OF_DECLARE(ipmmu_r8a7795_iommu_of, "renesas,ipmmu-r8a7795",
>>>ipmmu_vmsa_iommu_of_setup);
>>> +IOMMU_OF_DECLARE(ipmmu_r8a7796_iommu_of, "renesas,ipmmu-r8a7796",
>>> +  ipmmu_vmsa_iommu_of_setup);
>>
>> How about a Gen3 generic compatible string in addition to the SoC-specific
>> ones ?
>
> Do we want to specify the number of utlbs here?
> Does it differ between r8a7795, r8a7796, and future members?

The utlb number is already a property of the SoC part number. So I
don't see why we want to encode this as a separate DT property instead
of going with an in-driver feature flag.

Thanks,

/ magnus


Re: [PATCH 3/3] iommu/ipmmu-vmsa: Hook up r8a7796 DT matching code

2016-06-08 Thread Magnus Damm
Hi Laurent,

On Wed, Jun 8, 2016 at 9:18 AM, Laurent Pinchart
 wrote:
> Hi Magnus,
>
> Thank you for the patch.
>
> On Tuesday 07 Jun 2016 12:39:45 Magnus Damm wrote:
>> From: Magnus Damm 
>>
>> Support the r8a7796 IPMMU by sharing feature flags between
>> r8a7795 and r8a7796. Also update IOMMU_OF_DECLARE to hook
>> up the updated compat string.
>>
>> Signed-off-by: Magnus Damm 
>> ---
>>
>>  drivers/iommu/ipmmu-vmsa.c |9 +++--
>>  1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> --- 0031/drivers/iommu/ipmmu-vmsa.c
>> +++ work/drivers/iommu/ipmmu-vmsa.c   2016-06-06 11:19:40.210607110 +0900
>> @@ -1074,7 +1074,7 @@ static const struct ipmmu_features ipmmu
>>   .twobit_imttbcr_sl0 = false,
>>  };
>>
>> -static const struct ipmmu_features ipmmu_features_r8a7795 = {
>> +static const struct ipmmu_features ipmmu_features_rcar_gen3 = {
>>   .use_ns_alias_offset = false,
>>   .has_cache_leaf_nodes = true,
>>   .has_eight_ctx = true,
>> @@ -1088,7 +1088,10 @@ static const struct of_device_id ipmmu_o
>>   .data = _features_default,
>>   }, {
>>   .compatible = "renesas,ipmmu-r8a7795",
>> - .data = _features_r8a7795,
>> + .data = _features_rcar_gen3,
>> + }, {
>> + .compatible = "renesas,ipmmu-r8a7796",
>> + .data = _features_rcar_gen3,
>>   }, {
>>   /* Terminator */
>>   },
>> @@ -1268,6 +1271,8 @@ IOMMU_OF_DECLARE(ipmmu_vmsa_iommu_of, "r
>>ipmmu_vmsa_iommu_of_setup);
>>  IOMMU_OF_DECLARE(ipmmu_r8a7795_iommu_of, "renesas,ipmmu-r8a7795",
>>ipmmu_vmsa_iommu_of_setup);
>> +IOMMU_OF_DECLARE(ipmmu_r8a7796_iommu_of, "renesas,ipmmu-r8a7796",
>> +  ipmmu_vmsa_iommu_of_setup);
>
> How about a Gen3 generic compatible string in addition to the SoC-specific
> ones ?

As you probably know, neither R-Car Gen2 nor R-Car Gen3 families are
finished evolving. Because of that I find speculating with DT compat
strings just potentially confusing with no apparent upside. Just going
with what we know (ie the part number) is more than good enough IMO.

Thanks,

/ magnus


Re: [PATCH v2 4/4] ARM: dts: r8a7790: lager: use demuxer for IIC3/I2C3

2016-06-08 Thread Wolfram Sang
On Wed, Jun 08, 2016 at 04:14:26PM +0900, Simon Horman wrote:
> Create a separate bus for dla98063 PMIC and da9210 regulator
> related I2C slaves.
> 
> Based on similar work for HDMI by Wolfram Sang.
> 
> Cc: Wolfram Sang 
> Signed-off-by: Simon Horman 

Maybe add a word that PFC doesn't allow I2C0/I2C3 to be muxed as GPIO?



signature.asc
Description: PGP signature


Re: [PATCH v2 1/4] ARM: dts: r8a7790: lager: rename i2cexio as i2cexio0

2016-06-08 Thread Wolfram Sang
On Wed, Jun 08, 2016 at 04:14:23PM +0900, Simon Horman wrote:
> This is in preparation for adding i2cexio1 which will use the
> dmuxer for IIC1/I2C0.

I2C1



signature.asc
Description: PGP signature


[PATCH 1/2] usb: renesas_usbhs: fix NULL pointer dereference in xfer_work()

2016-06-08 Thread Yoshihiro Shimoda
This patch fixes an issue that the xfer_work() is possible to cause
NULL pointer dereference if the usb cable is disconnected while data
transfer is running.

In such case, a gadget driver may call usb_ep_disable()) before
xfer_work() is actually called. In this case, the usbhs_pkt_pop()
will call usbhsf_fifo_unselect(), and then usbhs_pipe_to_fifo()
in xfer_work() will return NULL.

Fixes: e73a989 ("usb: renesas_usbhs: add DMAEngine support")
Cc:  # v3.1+
Signed-off-by: Yoshihiro Shimoda 
---
 drivers/usb/renesas_usbhs/fifo.c | 18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c
index 7be4e7d..280ed5f 100644
--- a/drivers/usb/renesas_usbhs/fifo.c
+++ b/drivers/usb/renesas_usbhs/fifo.c
@@ -810,20 +810,27 @@ static void xfer_work(struct work_struct *work)
 {
struct usbhs_pkt *pkt = container_of(work, struct usbhs_pkt, work);
struct usbhs_pipe *pipe = pkt->pipe;
-   struct usbhs_fifo *fifo = usbhs_pipe_to_fifo(pipe);
+   struct usbhs_fifo *fifo;
struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
struct dma_async_tx_descriptor *desc;
-   struct dma_chan *chan = usbhsf_dma_chan_get(fifo, pkt);
+   struct dma_chan *chan;
struct device *dev = usbhs_priv_to_dev(priv);
enum dma_transfer_direction dir;
+   unsigned long flags;
 
+   usbhs_lock(priv, flags);
+   fifo = usbhs_pipe_to_fifo(pipe);
+   if (!fifo)
+   goto xfer_work_end;
+
+   chan = usbhsf_dma_chan_get(fifo, pkt);
dir = usbhs_pipe_is_dir_in(pipe) ? DMA_DEV_TO_MEM : DMA_MEM_TO_DEV;
 
desc = dmaengine_prep_slave_single(chan, pkt->dma + pkt->actual,
pkt->trans, dir,
DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
if (!desc)
-   return;
+   goto xfer_work_end;
 
desc->callback  = usbhsf_dma_complete;
desc->callback_param= pipe;
@@ -831,7 +838,7 @@ static void xfer_work(struct work_struct *work)
pkt->cookie = dmaengine_submit(desc);
if (pkt->cookie < 0) {
dev_err(dev, "Failed to submit dma descriptor\n");
-   return;
+   goto xfer_work_end;
}
 
dev_dbg(dev, "  %s %d (%d/ %d)\n",
@@ -842,6 +849,9 @@ static void xfer_work(struct work_struct *work)
usbhs_pipe_set_trans_count_if_bulk(pipe, pkt->trans);
dma_async_issue_pending(chan);
usbhs_pipe_enable(pipe);
+
+xfer_work_end:
+   usbhs_unlock(priv, flags);
 }
 
 /*
-- 
1.9.1



[PATCH v4 00/07] iommu/ipmmu-vmsa: IPMMU multi-arch update V4

2016-06-08 Thread Magnus Damm
iommu/ipmmu-vmsa: IPMMU multi-arch update V4

[PATCH v4 01/07] iommu/ipmmu-vmsa: Remove platform data handling
[PATCH v4 02/07] iommu/ipmmu-vmsa: Rework interrupt code and use bitmap for 
context
[PATCH v4 03/07] iommu/ipmmu-vmsa: Break out utlb parsing code
[PATCH v4 04/07] iommu/ipmmu-vmsa: Break out domain allocation code
[PATCH v4 05/07] iommu/ipmmu-vmsa: Add new IOMMU_DOMAIN_DMA ops
[PATCH v4 06/07] iommu/ipmmu-vmsa: ARM and ARM64 archdata access
[PATCH v4 07/07] iommu/ipmmu-vmsa: Drop LPAE Kconfig dependency

These patches update the IPMMU driver with a couple of changes
to support build on multiple architectures. In the process of
doing so the interrupt code gets reworked and the foundation
for supporting multiple contexts are added.

Changes since V3:
 - Updated patch 3/7 to fix hang-on-boot issue on 32-bit ARM - thanks Geert!
 - Reworked group parameter handling in patch 3/7 and 5/7.
 - Added patch 6/7 to fix build of the driver on s390/tile/um architectures

Changes since V2:
 - Got rid of patch 3 from the V2 however patch 1, 2 and 4 are kept.
 - V3 patch 3, 4 and 5 come from
   [PATCH 00/04] iommu/ipmmu-vmsa: IPMMU CONFIG_IOMMU_DMA update
 - Patch 5 has been reworked to include patch 3 of the V1 of this series 

Changes since V1:
 - Got rid of patch 2 and 3 from initial series
 - Updated bitmap code locking and also used lighter bitop functions
 - Updated the Kconfig bits to apply on top of ARCH_RENESAS

Signed-off-by: Magnus Damm 
---

 drivers/iommu/Kconfig  |1 
 drivers/iommu/ipmmu-vmsa.c |  302 +++-
 2 files changed, 243 insertions(+), 60 deletions(-)



[PATCH v4 03/07] iommu/ipmmu-vmsa: Break out utlb parsing code

2016-06-08 Thread Magnus Damm
From: Magnus Damm 

Break out the utlb parsing code and dev_data allocation into a
separate function. This is preparation for future code sharing.

Signed-off-by: Magnus Damm 
---

 Changes since V3:
 - Initialize "mmu" to NULL, check before accessing
 - Removed group parameter from ipmmu_init_platform_device()

 Changes since V2:
 - Included this new patch from the following series:
   [PATCH 00/04] iommu/ipmmu-vmsa: IPMMU CONFIG_IOMMU_DMA update
 - Reworked code to fit on top on previous two patches in current series.

 drivers/iommu/ipmmu-vmsa.c |   60 +++-
 1 file changed, 38 insertions(+), 22 deletions(-)

--- 0004/drivers/iommu/ipmmu-vmsa.c
+++ work/drivers/iommu/ipmmu-vmsa.c 2016-06-08 14:59:34.470607110 +0900
@@ -647,22 +647,15 @@ static int ipmmu_find_utlbs(struct ipmmu
return 0;
 }
 
-static int ipmmu_add_device(struct device *dev)
+static int ipmmu_init_platform_device(struct device *dev)
 {
struct ipmmu_vmsa_archdata *archdata;
struct ipmmu_vmsa_device *mmu;
-   struct iommu_group *group = NULL;
unsigned int *utlbs;
unsigned int i;
int num_utlbs;
int ret = -ENODEV;
 
-   if (dev->archdata.iommu) {
-   dev_warn(dev, "IOMMU driver already assigned to device %s\n",
-dev_name(dev));
-   return -EINVAL;
-   }
-
/* Find the master corresponding to the device. */
 
num_utlbs = of_count_phandle_with_args(dev->of_node, "iommus",
@@ -690,7 +683,7 @@ static int ipmmu_add_device(struct devic
spin_unlock(_devices_lock);
 
if (ret < 0)
-   return -ENODEV;
+   goto error;
 
for (i = 0; i < num_utlbs; ++i) {
if (utlbs[i] >= mmu->num_utlbs) {
@@ -699,6 +692,36 @@ static int ipmmu_add_device(struct devic
}
}
 
+   archdata = kzalloc(sizeof(*archdata), GFP_KERNEL);
+   if (!archdata) {
+   ret = -ENOMEM;
+   goto error;
+   }
+
+   archdata->mmu = mmu;
+   archdata->utlbs = utlbs;
+   archdata->num_utlbs = num_utlbs;
+   dev->archdata.iommu = archdata;
+   return 0;
+
+error:
+   kfree(utlbs);
+   return ret;
+}
+
+static int ipmmu_add_device(struct device *dev)
+{
+   struct ipmmu_vmsa_archdata *archdata;
+   struct ipmmu_vmsa_device *mmu = NULL;
+   struct iommu_group *group;
+   int ret;
+
+   if (dev->archdata.iommu) {
+   dev_warn(dev, "IOMMU driver already assigned to device %s\n",
+dev_name(dev));
+   return -EINVAL;
+   }
+
/* Create a device group and add the device to it. */
group = iommu_group_alloc();
if (IS_ERR(group)) {
@@ -716,16 +739,9 @@ static int ipmmu_add_device(struct devic
goto error;
}
 
-   archdata = kzalloc(sizeof(*archdata), GFP_KERNEL);
-   if (!archdata) {
-   ret = -ENOMEM;
+   ret = ipmmu_init_platform_device(dev);
+   if (ret < 0)
goto error;
-   }
-
-   archdata->mmu = mmu;
-   archdata->utlbs = utlbs;
-   archdata->num_utlbs = num_utlbs;
-   dev->archdata.iommu = archdata;
 
/*
 * Create the ARM mapping, used by the ARM DMA mapping core to allocate
@@ -736,6 +752,8 @@ static int ipmmu_add_device(struct devic
 * - Make the mapping size configurable ? We currently use a 2GB mapping
 *   at a 1GB offset to ensure that NULL VAs will fault.
 */
+   archdata = dev->archdata.iommu;
+   mmu = archdata->mmu;
if (!mmu->mapping) {
struct dma_iommu_mapping *mapping;
 
@@ -760,10 +778,8 @@ static int ipmmu_add_device(struct devic
return 0;
 
 error:
-   arm_iommu_release_mapping(mmu->mapping);
-
-   kfree(dev->archdata.iommu);
-   kfree(utlbs);
+   if (mmu)
+   arm_iommu_release_mapping(mmu->mapping);
 
dev->archdata.iommu = NULL;
 


[PATCH v4 05/07] iommu/ipmmu-vmsa: Add new IOMMU_DOMAIN_DMA ops

2016-06-08 Thread Magnus Damm
From: Magnus Damm 

Introduce an alternative set of iommu_ops suitable for 64-bit ARM
as well as 32-bit ARM when CONFIG_IOMMU_DMA=y.

Signed-off-by: Magnus Damm 
---

 Changes since V3:
 - Removed group parameter from ipmmu_init_platform_device()

 Changes since V2:
 - Included this new patch from the following series:
   [PATCH 00/04] iommu/ipmmu-vmsa: IPMMU CONFIG_IOMMU_DMA update
 - Use only a single iommu_ops structure with #ifdef CONFIG_IOMMU_DMA
 - Folded in #ifdefs to handle CONFIG_ARM and CONFIG_IOMMU_DMA
 - of_xlate() is now used without #ifdefs
 - Made sure code compiles on both 32-bit and 64-bit ARM.

 drivers/iommu/ipmmu-vmsa.c |  111 
 1 file changed, 103 insertions(+), 8 deletions(-)

--- 0008/drivers/iommu/ipmmu-vmsa.c
+++ work/drivers/iommu/ipmmu-vmsa.c 2016-06-08 15:08:39.950607110 +0900
@@ -10,6 +10,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -22,8 +23,10 @@
 #include 
 #include 
 
+#if defined(CONFIG_ARM) && !defined(CONFIG_IOMMU_DMA)
 #include 
 #include 
+#endif
 
 #include "io-pgtable.h"
 
@@ -520,14 +523,6 @@ static struct iommu_domain *__ipmmu_doma
return >io_domain;
 }
 
-static struct iommu_domain *ipmmu_domain_alloc(unsigned type)
-{
-   if (type != IOMMU_DOMAIN_UNMANAGED)
-   return NULL;
-
-   return __ipmmu_domain_alloc(type);
-}
-
 static void ipmmu_domain_free(struct iommu_domain *io_domain)
 {
struct ipmmu_vmsa_domain *domain = to_vmsa_domain(io_domain);
@@ -714,6 +709,8 @@ error:
return ret;
 }
 
+#if defined(CONFIG_ARM) && !defined(CONFIG_IOMMU_DMA)
+
 static int ipmmu_add_device(struct device *dev)
 {
struct ipmmu_vmsa_archdata *archdata;
@@ -807,6 +804,14 @@ static void ipmmu_remove_device(struct d
dev->archdata.iommu = NULL;
 }
 
+static struct iommu_domain *ipmmu_domain_alloc(unsigned type)
+{
+   if (type != IOMMU_DOMAIN_UNMANAGED)
+   return NULL;
+
+   return __ipmmu_domain_alloc(type);
+}
+
 static const struct iommu_ops ipmmu_ops = {
.domain_alloc = ipmmu_domain_alloc,
.domain_free = ipmmu_domain_free,
@@ -821,6 +826,94 @@ static const struct iommu_ops ipmmu_ops
.pgsize_bitmap = SZ_1G | SZ_2M | SZ_4K,
 };
 
+#endif /* !CONFIG_ARM && CONFIG_IOMMU_DMA */
+
+#ifdef CONFIG_IOMMU_DMA
+
+static struct iommu_domain *ipmmu_domain_alloc_dma(unsigned type)
+{
+   struct iommu_domain *io_domain;
+
+   if (type != IOMMU_DOMAIN_DMA)
+   return NULL;
+
+   io_domain = __ipmmu_domain_alloc(type);
+   if (io_domain)
+   iommu_get_dma_cookie(io_domain);
+
+   return io_domain;
+}
+
+static void ipmmu_domain_free_dma(struct iommu_domain *io_domain)
+{
+   iommu_put_dma_cookie(io_domain);
+   ipmmu_domain_free(io_domain);
+}
+
+static int ipmmu_add_device_dma(struct device *dev)
+{
+   struct iommu_group *group;
+
+   /* only accept devices with iommus property */
+   if (of_count_phandle_with_args(dev->of_node, "iommus",
+  "#iommu-cells") < 0)
+   return -ENODEV;
+
+   group = iommu_group_get_for_dev(dev);
+   if (IS_ERR(group))
+   return PTR_ERR(group);
+
+   return 0;
+}
+
+static void ipmmu_remove_device_dma(struct device *dev)
+{
+   iommu_group_remove_device(dev);
+}
+
+static struct iommu_group *ipmmu_device_group_dma(struct device *dev)
+{
+   struct iommu_group *group;
+   int ret;
+
+   group = generic_device_group(dev);
+   if (IS_ERR(group))
+   return group;
+
+   ret = ipmmu_init_platform_device(dev);
+   if (ret) {
+   iommu_group_put(group);
+   group = ERR_PTR(ret);
+   }
+
+   return group;
+}
+
+static int ipmmu_of_xlate_dma(struct device *dev,
+ struct of_phandle_args *spec)
+{
+   /* dummy callback to satisfy of_iommu_configure() */
+   return 0;
+}
+
+static const struct iommu_ops ipmmu_ops = {
+   .domain_alloc = ipmmu_domain_alloc_dma,
+   .domain_free = ipmmu_domain_free_dma,
+   .attach_dev = ipmmu_attach_device,
+   .detach_dev = ipmmu_detach_device,
+   .map = ipmmu_map,
+   .unmap = ipmmu_unmap,
+   .map_sg = default_iommu_map_sg,
+   .iova_to_phys = ipmmu_iova_to_phys,
+   .add_device = ipmmu_add_device_dma,
+   .remove_device = ipmmu_remove_device_dma,
+   .device_group = ipmmu_device_group_dma,
+   .pgsize_bitmap = SZ_1G | SZ_2M | SZ_4K,
+   .of_xlate = ipmmu_of_xlate_dma,
+};
+
+#endif /* CONFIG_IOMMU_DMA */
+
 /* 
-
  * Probe/remove and init
  */
@@ -910,7 +1003,9 @@ static int ipmmu_remove(struct platform_
list_del(>list);
spin_unlock(_devices_lock);
 
+#if defined(CONFIG_ARM) && !defined(CONFIG_IOMMU_DMA)

[PATCH v4 07/07] iommu/ipmmu-vmsa: Drop LPAE Kconfig dependency

2016-06-08 Thread Magnus Damm
From: Magnus Damm 

Neither the ARM page table code enabled by IOMMU_IO_PGTABLE_LPAE
nor the IPMMU_VMSA driver actually depends on ARM_LPAE, so get
rid of the dependency.

Tested with ipmmu-vmsa on r8a7794 ALT and a kernel config using:
 # CONFIG_ARM_LPAE is not set

Signed-off-by: Magnus Damm 
Acked-by: Laurent Pinchart 
---

 Changes since V3:
 - None

 Changes since V2:
 - None

 Changes since V1:
 - Rebased on top of ARCH_RENESAS change
 - Added Acked-by from Laurent

 drivers/iommu/Kconfig |1 -
 1 file changed, 1 deletion(-)

--- 0001/drivers/iommu/Kconfig
+++ work/drivers/iommu/Kconfig  2016-06-02 22:17:14.950607110 +0900
@@ -273,7 +273,6 @@ config EXYNOS_IOMMU_DEBUG
 
 config IPMMU_VMSA
bool "Renesas VMSA-compatible IPMMU"
-   depends on ARM_LPAE
depends on ARCH_RENESAS || COMPILE_TEST
select IOMMU_API
select IOMMU_IO_PGTABLE_LPAE


[PATCH v4 06/07] iommu/ipmmu-vmsa: ARM and ARM64 archdata access

2016-06-08 Thread Magnus Damm
From: Magnus Damm 

Not all architectures have an iommu member in their archdata, so
use #ifdefs support build wit COMPILE_TEST on any architecture.

Signed-off-by: Magnus Damm 
---

 Changes since V3:
 - New patch

 drivers/iommu/ipmmu-vmsa.c |   37 +++--
 1 file changed, 27 insertions(+), 10 deletions(-)

--- 0009/drivers/iommu/ipmmu-vmsa.c
+++ work/drivers/iommu/ipmmu-vmsa.c 2016-06-08 15:01:40.970607110 +0900
@@ -70,6 +70,25 @@ static struct ipmmu_vmsa_domain *to_vmsa
return container_of(dom, struct ipmmu_vmsa_domain, io_domain);
 }
 
+#if defined(CONFIG_ARM) || defined(CONFIG_ARM64)
+static struct ipmmu_vmsa_archdata *to_archdata(struct device *dev)
+{
+   return dev->archdata.iommu;
+}
+static void set_archdata(struct device *dev, struct ipmmu_vmsa_archdata *p)
+{
+   dev->archdata.iommu = p;
+}
+#else
+static struct ipmmu_vmsa_archdata *to_archdata(struct device *dev)
+{
+   return NULL;
+}
+static void set_archdata(struct device *dev, struct ipmmu_vmsa_archdata *p)
+{
+}
+#endif
+
 #define TLB_LOOP_TIMEOUT   100 /* 100us */
 
 /* 
-
@@ -539,7 +558,7 @@ static void ipmmu_domain_free(struct iom
 static int ipmmu_attach_device(struct iommu_domain *io_domain,
   struct device *dev)
 {
-   struct ipmmu_vmsa_archdata *archdata = dev->archdata.iommu;
+   struct ipmmu_vmsa_archdata *archdata = to_archdata(dev);
struct ipmmu_vmsa_device *mmu = archdata->mmu;
struct ipmmu_vmsa_domain *domain = to_vmsa_domain(io_domain);
unsigned long flags;
@@ -581,7 +600,7 @@ static int ipmmu_attach_device(struct io
 static void ipmmu_detach_device(struct iommu_domain *io_domain,
struct device *dev)
 {
-   struct ipmmu_vmsa_archdata *archdata = dev->archdata.iommu;
+   struct ipmmu_vmsa_archdata *archdata = to_archdata(dev);
struct ipmmu_vmsa_domain *domain = to_vmsa_domain(io_domain);
unsigned int i;
 
@@ -701,7 +720,7 @@ static int ipmmu_init_platform_device(st
archdata->mmu = mmu;
archdata->utlbs = utlbs;
archdata->num_utlbs = num_utlbs;
-   dev->archdata.iommu = archdata;
+   set_archdata(dev, archdata);
return 0;
 
 error:
@@ -713,12 +732,11 @@ error:
 
 static int ipmmu_add_device(struct device *dev)
 {
-   struct ipmmu_vmsa_archdata *archdata;
struct ipmmu_vmsa_device *mmu = NULL;
struct iommu_group *group;
int ret;
 
-   if (dev->archdata.iommu) {
+   if (to_archdata(dev)) {
dev_warn(dev, "IOMMU driver already assigned to device %s\n",
 dev_name(dev));
return -EINVAL;
@@ -754,8 +772,7 @@ static int ipmmu_add_device(struct devic
 * - Make the mapping size configurable ? We currently use a 2GB mapping
 *   at a 1GB offset to ensure that NULL VAs will fault.
 */
-   archdata = dev->archdata.iommu;
-   mmu = archdata->mmu;
+   mmu = to_archdata(dev)->mmu;
if (!mmu->mapping) {
struct dma_iommu_mapping *mapping;
 
@@ -783,7 +800,7 @@ error:
if (mmu)
arm_iommu_release_mapping(mmu->mapping);
 
-   dev->archdata.iommu = NULL;
+   set_archdata(dev, NULL);
 
if (!IS_ERR_OR_NULL(group))
iommu_group_remove_device(dev);
@@ -793,7 +810,7 @@ error:
 
 static void ipmmu_remove_device(struct device *dev)
 {
-   struct ipmmu_vmsa_archdata *archdata = dev->archdata.iommu;
+   struct ipmmu_vmsa_archdata *archdata = to_archdata(dev);
 
arm_iommu_detach_device(dev);
iommu_group_remove_device(dev);
@@ -801,7 +818,7 @@ static void ipmmu_remove_device(struct d
kfree(archdata->utlbs);
kfree(archdata);
 
-   dev->archdata.iommu = NULL;
+   set_archdata(dev, NULL);
 }
 
 static struct iommu_domain *ipmmu_domain_alloc(unsigned type)


[PATCH v4 04/07] iommu/ipmmu-vmsa: Break out domain allocation code

2016-06-08 Thread Magnus Damm
From: Magnus Damm 

Break out the domain allocation code into a separate function.
This is preparation for future code sharing.

Signed-off-by: Magnus Damm 
---

 Changes since V3:
 - None

 Changes since V2:
 - Included this new patch as-is from the following series:
   [PATCH 00/04] iommu/ipmmu-vmsa: IPMMU CONFIG_IOMMU_DMA update

 drivers/iommu/ipmmu-vmsa.c |   13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

--- 0005/drivers/iommu/ipmmu-vmsa.c
+++ work/drivers/iommu/ipmmu-vmsa.c 2016-06-08 15:00:20.760607110 +0900
@@ -507,13 +507,10 @@ static irqreturn_t ipmmu_irq(int irq, vo
  * IOMMU Operations
  */
 
-static struct iommu_domain *ipmmu_domain_alloc(unsigned type)
+static struct iommu_domain *__ipmmu_domain_alloc(unsigned type)
 {
struct ipmmu_vmsa_domain *domain;
 
-   if (type != IOMMU_DOMAIN_UNMANAGED)
-   return NULL;
-
domain = kzalloc(sizeof(*domain), GFP_KERNEL);
if (!domain)
return NULL;
@@ -523,6 +520,14 @@ static struct iommu_domain *ipmmu_domain
return >io_domain;
 }
 
+static struct iommu_domain *ipmmu_domain_alloc(unsigned type)
+{
+   if (type != IOMMU_DOMAIN_UNMANAGED)
+   return NULL;
+
+   return __ipmmu_domain_alloc(type);
+}
+
 static void ipmmu_domain_free(struct iommu_domain *io_domain)
 {
struct ipmmu_vmsa_domain *domain = to_vmsa_domain(io_domain);


[PATCH v2 3/4] ARM: dts: r8a7790: lager: use demuxer for IIC2/I2C2

2016-06-08 Thread Simon Horman
Create a separate bus for HDMI related I2C slaves.

Based on work by Wolfram Sang.

Cc: Wolfram Sang 
Signed-off-by: Simon Horman 
---
v2
* Include GPIO fallback
---
 arch/arm/boot/dts/r8a7790-lager.dts | 138 ++--
 1 file changed, 85 insertions(+), 53 deletions(-)

diff --git a/arch/arm/boot/dts/r8a7790-lager.dts 
b/arch/arm/boot/dts/r8a7790-lager.dts
index 20abb1470f91..80b0eaa93607 100644
--- a/arch/arm/boot/dts/r8a7790-lager.dts
+++ b/arch/arm/boot/dts/r8a7790-lager.dts
@@ -52,6 +52,8 @@
serial1 = 
i2c8 = "i2cexio0";
i2c9 = "i2cexio1";
+   i2c10 = "i2chdmi";
+   i2c11 = "gpioi2c";
};
 
chosen {
@@ -283,6 +285,76 @@
#address-cells = <1>;
#size-cells = <0>;
};
+
+   i2chdmi: i2c-10 {
+   compatible = "i2c-demux-pinctrl";
+   i2c-parent = <>, <>, <>;
+   i2c-bus-name = "i2c-hdmi";
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   ak4643: codec@12 {
+   compatible = "asahi-kasei,ak4643";
+   #sound-dai-cells = <0>;
+   reg = <0x12>;
+   };
+
+   composite-in@20 {
+   compatible = "adi,adv7180";
+   reg = <0x20>;
+   remote = <>;
+
+   port {
+   adv7180: endpoint {
+   bus-width = <8>;
+   remote-endpoint = <>;
+   };
+   };
+   };
+
+   hdmi@39 {
+   compatible = "adi,adv7511w";
+   reg = <0x39>;
+   interrupt-parent = <>;
+   interrupts = <15 IRQ_TYPE_LEVEL_LOW>;
+
+   adi,input-depth = <8>;
+   adi,input-colorspace = "rgb";
+   adi,input-clock = "1x";
+   adi,input-style = <1>;
+   adi,input-justification = "evenly";
+
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port@0 {
+   reg = <0>;
+   adv7511_in: endpoint {
+   remote-endpoint = 
<_out_lvds0>;
+   };
+   };
+
+   port@1 {
+   reg = <1>;
+   adv7511_out: endpoint {
+   remote-endpoint = <_con>;
+   };
+   };
+   };
+   };
+   };
+
+   gpioi2c: i2c-11 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   compatible = "i2c-gpio";
+   status = "disabled";
+   gpios = < 6 GPIO_ACTIVE_HIGH /* sda */
+ 5 GPIO_ACTIVE_HIGH /* scl */
+   >;
+   i2c-gpio,delay-us = <5>;
+   };
 };
 
  {
@@ -415,6 +487,11 @@
function = "iic1";
};
 
+   i2c2_pins: i2c2 {
+   groups = "i2c2";
+   function = "i2c2";
+   };
+
iic2_pins: iic2 {
groups = "iic2";
function = "iic2";
@@ -616,63 +693,18 @@
pinctrl-names = "i2c-exio1";
 };
 
-  {
-   status = "okay";
-   pinctrl-0 = <_pins>;
-   pinctrl-names = "default";
+  {
+   pinctrl-0 = <_pins>;
+   pinctrl-names = "i2c-hdmi";
 
clock-frequency = <10>;
+};
 
-   ak4643: codec@12 {
-   compatible = "asahi-kasei,ak4643";
-   #sound-dai-cells = <0>;
-   reg = <0x12>;
-   };
-
-   composite-in@20 {
-   compatible = "adi,adv7180";
-   reg = <0x20>;
-   remote = <>;
-
-   port {
-   adv7180: endpoint {
-   bus-width = <8>;
-   remote-endpoint = <>;
-   };
-   };
-   };
-
-   hdmi@39 {
-   compatible = "adi,adv7511w";
-   reg = <0x39>;
-   interrupt-parent = <>;
-   interrupts = <15 IRQ_TYPE_LEVEL_LOW>;
-
-   adi,input-depth = <8>;
-   adi,input-colorspace = "rgb";
-   adi,input-clock = "1x";
-   adi,input-style = <1>;
-   adi,input-justification = "evenly";
-
-   ports {
-   #address-cells = 

[PATCH v2 2/4] ARM: dts: r8a7790: lager: use demuxer for IIC1/I2C1

2016-06-08 Thread Simon Horman
Make it possible to select which I2C1 IP core you want to run on the
EXIO-A connector.

This is based on reference work for the I2C0 core of the lager by Wolfram Sang.

Cc: Wolfram Sang 
Signed-off-by: Simon Horman 
---
 arch/arm/boot/dts/r8a7790-lager.dts | 26 --
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/r8a7790-lager.dts 
b/arch/arm/boot/dts/r8a7790-lager.dts
index 71d62ca282ea..20abb1470f91 100644
--- a/arch/arm/boot/dts/r8a7790-lager.dts
+++ b/arch/arm/boot/dts/r8a7790-lager.dts
@@ -51,6 +51,7 @@
serial0 = 
serial1 = 
i2c8 = "i2cexio0";
+   i2c9 = "i2cexio1";
};
 
chosen {
@@ -270,6 +271,18 @@
#address-cells = <1>;
#size-cells = <0>;
};
+
+   /*
+* IIC1/I2C1 is routed to EXIO connector A, pins 78 (SCL) + 80 (SDA).
+* For further notes see i2cexio0.
+*/
+   i2cexio1: i2c-9 {
+   compatible = "i2c-demux-pinctrl";
+   i2c-parent = <>, <>;
+   i2c-bus-name = "i2c-exio1";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   };
 };
 
  {
@@ -392,6 +405,11 @@
function = "iic0";
};
 
+   i2c1_pins: i2c1 {
+   groups = "i2c1";
+   function = "i2c1";
+   };
+
iic1_pins: iic1 {
groups = "iic1";
function = "iic1";
@@ -588,10 +606,14 @@
pinctrl-names = "i2c-exio0";
 };
 
+  {
+   pinctrl-0 = <_pins>;
+   pinctrl-names = "i2c-exio1";
+};
+
   {
-   status = "okay";
pinctrl-0 = <_pins>;
-   pinctrl-names = "default";
+   pinctrl-names = "i2c-exio1";
 };
 
   {
-- 
2.1.4



[PATCH v2 1/4] ARM: dts: r8a7790: lager: rename i2cexio as i2cexio0

2016-06-08 Thread Simon Horman
This is in preparation for adding i2cexio1 which will use the
dmuxer for IIC1/I2C0.

Signed-off-by: Simon Horman 
---
 arch/arm/boot/dts/r8a7790-lager.dts | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/arm/boot/dts/r8a7790-lager.dts 
b/arch/arm/boot/dts/r8a7790-lager.dts
index 9d20ace33b01..71d62ca282ea 100644
--- a/arch/arm/boot/dts/r8a7790-lager.dts
+++ b/arch/arm/boot/dts/r8a7790-lager.dts
@@ -50,7 +50,7 @@
aliases {
serial0 = 
serial1 = 
-   i2c8 = "i2cexio";
+   i2c8 = "i2cexio0";
};
 
chosen {
@@ -263,10 +263,10 @@
 * instantiate the slave device at runtime according to the 
documentation.
 * You can then communicate with the slave via IIC3.
 */
-   i2cexio: i2c-8 {
+   i2cexio0: i2c-8 {
compatible = "i2c-demux-pinctrl";
i2c-parent = <>, <>;
-   i2c-bus-name = "i2c-exio";
+   i2c-bus-name = "i2c-exio0";
#address-cells = <1>;
#size-cells = <0>;
};
@@ -580,12 +580,12 @@
 
   {
pinctrl-0 = <_pins>;
-   pinctrl-names = "i2c-exio";
+   pinctrl-names = "i2c-exio0";
 };
 
   {
pinctrl-0 = <_pins>;
-   pinctrl-names = "i2c-exio";
+   pinctrl-names = "i2c-exio0";
 };
 
   {
-- 
2.1.4



[PATCH v2 0/4] ARM: dts: r8a7790: lager: use demuxer for I2C

2016-06-08 Thread Simon Horman
Hi,

the intention of this series is to extend use of the demuxer for I2C
on the lager/r8a7790 to cover all I2C IP blocks.

* This is based on work by Wolfram Sang.
* Testing is discussed below
* This series is based on renesas-devel-20160530-v4.7-rc1.
* To aid review it is provided in git at:
  git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas.git 
topic/i2c-demux-v2 
* I also intend to add demux for I2C to other R-Car Gen2 boards as a follow-up.

Changes since v1
* Provide GPIO fallback for I2C2,
  this does not seem appropriate for other I2C blocks on the lager board

Simon Horman (4):
  ARM: dts: r8a7790: lager: rename i2cexio as i2cexio0
  ARM: dts: r8a7790: lager: use demuxer for IIC1/I2C1
  ARM: dts: r8a7790: lager: use demuxer for IIC2/I2C2
  ARM: dts: r8a7790: lager: use demuxer for IIC3/I2C3

 arch/arm/boot/dts/r8a7790-lager.dts | 252 +++-
 1 file changed, 162 insertions(+), 90 deletions(-)

-- 
2.1.4

Discussion of Testing
=

My test case iterates through each available master of each demux that
is available and tries to select the masters in reverse. All relevant
drivers are present as per the shmobile_defconfig. The test fails when
the first error occurs. If there are no errors, that is all masters can
be initialises for all demuxes then the test passes.

My test script, which implements the above, is as follows:

--- begin ---
#!/bin/sh

set -e

cd /sys/devices/platform/

sleep 5 

for i in i2c-*; do
[ "$i" != 'i2c-*' ] || break
[ -e "$i/current_master" -a -e "$i/available_masters" ] || continue
echo "I2C Demux: $i"
for j in $(< "$i/available_masters" tr ' ' '\n' | tac); do
idx=${j%:*}
echo "  Master: $j ($idx)"
echo "$idx" > "$i/current_master"
sleep 5
done
done
--- end ---


Results
---

1. With no patches applied - that is only the demux for I2C0 present -
   the test passes. Excellent!

   # .  /exercise-i2c-demux.sh
   I2C Demux: i2c-8
 Master: 1:/i2c@e6508000 (1)
   [   22.532192] i2c-rcar e6508000.i2c: probed
 Master: 0:/i2c@e650 (0)
   [   27.549555] i2c-sh_mobile e650.i2c: I2C adapter 4, bus speed 10 Hz

   Unfortunately from there things are a little less rosy.

2. In general it seems that if more than one demux is present then the
   test fails when iterating through the masters for the first demux
   (that of I2C). E.g. with the first two patches of this series applied
   there is a demux present for I2C0 and I2C1 and the test run is as
   follows. Logs are from the kernel, displayed on the system console where
   the test is also run.

   # ./exercise-i2c-demux.sh
   I2C Demux: i2c-8
 Master: 1:/i2c@e650800
   [   97.694487] i2c-rcar e6508000.i2c: probed 0 (1)
 Master: 0:/i2c@e65
   [  102.706365] i2c-demux-pinctrl i2c-8: failed to setup demux-adapter 0 
(-19) 0 (0)

3. With some manual hacks so that only one demux is present in DT the test
   pasts for the I2C0 (as per 1, above) and I2C2 demux.

   For the I2C2 demux the result is as follows:
   # ./exercise-i2c-demux.sh
   I2C Demux: i2c-9
 Master: 1:/i2c@e6518000 (1)
   [   22.430321] i2c-rcar e6518000.i2c: probed
 Master: 0:/i2c@e651 (0)
   [   27.447884] i2c-sh_mobile e651.i2c: I2C adapter 5, bus speed 10 Hz

   3.1 Unfortunately it fails for the I2C2 dmux if the GPIO fallback is
   present.

   # ./exercise-i2c-demux.sh
   I2C Demux: i2c-10
 Master: 2:/i2c-11 (2)
   [   22.347864] i2c-gpio i2c-11: using pins 842 (SDA) and 841 (SCL)
   [   22.358210] i2c-demux-pinctrl i2c-10: failed to setup demux-adapter 2 
(-19)
   With gpio fallback removed the test passes:

   # ./exercise-i2c-demux.sh
   I2C Demux: i2c-10
 Master: 1:/i2c@e653 (1)
   [  120.307738] i2c-rcar e653.i2c: probed
   [  120.313186] adv7180 8-0020: chip found @ 0x20 (i2c-demux (master 
i2c-2))
   [  120.337700] soc-camera-pdrv soc-camera-pdrv.0: Probing 
soc-camera-pdrv.0
 Master: 0:/i2c@e652 (0)
   [  125.359197] i2c-sh_mobile e652.i2c: I2C adapter 6, bus speed 
10 Hz
   [  125.367702] adv7180 8-0020: chip found @ 0x20 (i2c-demux (master 
i2c-6))
   [  125.387803] soc-camera-pdrv soc-camera-pdrv.0: Probing 
soc-camera-pdrv.0

   3.2 The test also fails for the I2C3 demux but that appears to be due
   to a shortcoming in the voltage regulator code which does not
   appear to like being reinitialised. The kernel complains as follows:

   [   22.365156] [ cut here ]
   [   22.374061] WARNING: CPU: 2 PID: 1959 at 
drivers/regulator/core.c:4099 regulator_unregister+0x6c/0xb8
   [   22.387730] CPU: 2 PID: 1959 Comm: exercise-i2c-de Not tainted 
4.7.0-rc1-6-g05ba3a31af73-dirty #200
   [   22.401620] Hardware name: Generic R8A7790 (Flattened Device Tree)
   [   22.412295] Backtrace:
   [   

[PATCH v2 4/4] ARM: dts: r8a7790: lager: use demuxer for IIC3/I2C3

2016-06-08 Thread Simon Horman
Create a separate bus for dla98063 PMIC and da9210 regulator
related I2C slaves.

Based on similar work for HDMI by Wolfram Sang.

Cc: Wolfram Sang 
Signed-off-by: Simon Horman 
---
 arch/arm/boot/dts/r8a7790-lager.dts | 80 +++--
 1 file changed, 49 insertions(+), 31 deletions(-)

diff --git a/arch/arm/boot/dts/r8a7790-lager.dts 
b/arch/arm/boot/dts/r8a7790-lager.dts
index 80b0eaa93607..b75501e4c56d 100644
--- a/arch/arm/boot/dts/r8a7790-lager.dts
+++ b/arch/arm/boot/dts/r8a7790-lager.dts
@@ -54,6 +54,7 @@
i2c9 = "i2cexio1";
i2c10 = "i2chdmi";
i2c11 = "gpioi2c";
+   i2c12 = "i2cpwr";
};
 
chosen {
@@ -355,6 +356,42 @@
>;
i2c-gpio,delay-us = <5>;
};
+
+   i2cpwr: i2c-12 {
+   compatible = "i2c-demux-pinctrl";
+   i2c-parent = <>, <>;
+   i2c-bus-name = "i2c-pwr";
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   pmic@58 {
+   compatible = "dlg,da9063";
+   reg = <0x58>;
+   interrupt-parent = <>;
+   interrupts = <2 IRQ_TYPE_LEVEL_LOW>;
+   interrupt-controller;
+
+   rtc {
+   compatible = "dlg,da9063-rtc";
+   };
+
+   wdt {
+   compatible = "dlg,da9063-watchdog";
+   };
+   };
+
+   vdd_dvfs: regulator@68 {
+   compatible = "dlg,da9210";
+   reg = <0x68>;
+   interrupt-parent = <>;
+   interrupts = <2 IRQ_TYPE_LEVEL_LOW>;
+
+   regulator-min-microvolt = <100>;
+   regulator-max-microvolt = <100>;
+   regulator-boot-on;
+   regulator-always-on;
+   };
+   };
 };
 
  {
@@ -497,6 +534,11 @@
function = "iic2";
};
 
+   i2c3_pins: i2c3 {
+   groups = "i2c3";
+   function = "i2c3";
+   };
+
iic3_pins: iic3 {
groups = "iic3";
function = "iic3";
@@ -707,38 +749,14 @@
clock-frequency = <10>;
 };
 
- {
-   pinctrl-names = "default";
-   pinctrl-0 = <_pins>;
-   status = "okay";
-
-   pmic@58 {
-   compatible = "dlg,da9063";
-   reg = <0x58>;
-   interrupt-parent = <>;
-   interrupts = <2 IRQ_TYPE_LEVEL_LOW>;
-   interrupt-controller;
-
-   rtc {
-   compatible = "dlg,da9063-rtc";
-   };
-
-   wdt {
-   compatible = "dlg,da9063-watchdog";
-   };
-   };
-
-   vdd_dvfs: regulator@68 {
-   compatible = "dlg,da9210";
-   reg = <0x68>;
-   interrupt-parent = <>;
-   interrupts = <2 IRQ_TYPE_LEVEL_LOW>;
+  {
+   pinctrl-0 = <_pins>;
+   pinctrl-names = "i2c-pwr";
+};
 
-   regulator-min-microvolt = <100>;
-   regulator-max-microvolt = <100>;
-   regulator-boot-on;
-   regulator-always-on;
-   };
+  {
+   pinctrl-0 = <_pins>;
+   pinctrl-names = "i2c-pwr";
 };
 
  {
-- 
2.1.4



Re: [PATCH 14/30] ARM: dts: r8a7790: Fix W=1 dtc warnings

2016-06-08 Thread Kuninori Morimoto

Hi Simon

> From: Geert Uytterhoeven 
> 
> Warning (unit_address_vs_reg): Node /cache-controller@0 has a unit name, but 
> no reg property
> Warning (unit_address_vs_reg): Node /cache-controller@1 has a unit name, but 
> no reg property
> Warning (unit_address_vs_reg): Node /sound@ec50/rcar_sound,dvc/dvc@0 has 
> a unit name, but no reg property
> Warning (unit_address_vs_reg): Node /sound@ec50/rcar_sound,dvc/dvc@1 has 
> a unit name, but no reg property
> Warning (unit_address_vs_reg): Node /sound@ec50/rcar_sound,mix/mix@0 has 
> a unit name, but no reg property
> Warning (unit_address_vs_reg): Node /sound@ec50/rcar_sound,mix/mix@1 has 
> a unit name, but no reg property
> Warning (unit_address_vs_reg): Node /sound@ec50/rcar_sound,ctu/ctu@0 has 
> a unit name, but no reg property
> Warning (unit_address_vs_reg): Node /sound@ec50/rcar_sound,ctu/ctu@1 has 
> a unit name, but no reg property
> Warning (unit_address_vs_reg): Node /sound@ec50/rcar_sound,ctu/ctu@2 has 
> a unit name, but no reg property
> Warning (unit_address_vs_reg): Node /sound@ec50/rcar_sound,ctu/ctu@3 has 
> a unit name, but no reg property
> Warning (unit_address_vs_reg): Node /sound@ec50/rcar_sound,ctu/ctu@4 has 
> a unit name, but no reg property
> Warning (unit_address_vs_reg): Node /sound@ec50/rcar_sound,ctu/ctu@5 has 
> a unit name, but no reg property
> Warning (unit_address_vs_reg): Node /sound@ec50/rcar_sound,ctu/ctu@6 has 
> a unit name, but no reg property
> Warning (unit_address_vs_reg): Node /sound@ec50/rcar_sound,ctu/ctu@7 has 
> a unit name, but no reg property
> Warning (unit_address_vs_reg): Node /sound@ec50/rcar_sound,src/src@0 has 
> a unit name, but no reg property
> Warning (unit_address_vs_reg): Node /sound@ec50/rcar_sound,src/src@1 has 
> a unit name, but no reg property
> Warning (unit_address_vs_reg): Node /sound@ec50/rcar_sound,src/src@2 has 
> a unit name, but no reg property
> Warning (unit_address_vs_reg): Node /sound@ec50/rcar_sound,src/src@3 has 
> a unit name, but no reg property
> Warning (unit_address_vs_reg): Node /sound@ec50/rcar_sound,src/src@4 has 
> a unit name, but no reg property
> Warning (unit_address_vs_reg): Node /sound@ec50/rcar_sound,src/src@5 has 
> a unit name, but no reg property
> Warning (unit_address_vs_reg): Node /sound@ec50/rcar_sound,src/src@6 has 
> a unit name, but no reg property
> Warning (unit_address_vs_reg): Node /sound@ec50/rcar_sound,src/src@7 has 
> a unit name, but no reg property
> Warning (unit_address_vs_reg): Node /sound@ec50/rcar_sound,src/src@8 has 
> a unit name, but no reg property
> Warning (unit_address_vs_reg): Node /sound@ec50/rcar_sound,src/src@9 has 
> a unit name, but no reg property
> Warning (unit_address_vs_reg): Node /sound@ec50/rcar_sound,ssi/ssi@0 has 
> a unit name, but no reg property
> Warning (unit_address_vs_reg): Node /sound@ec50/rcar_sound,ssi/ssi@1 has 
> a unit name, but no reg property
> Warning (unit_address_vs_reg): Node /sound@ec50/rcar_sound,ssi/ssi@2 has 
> a unit name, but no reg property
> Warning (unit_address_vs_reg): Node /sound@ec50/rcar_sound,ssi/ssi@3 has 
> a unit name, but no reg property
> Warning (unit_address_vs_reg): Node /sound@ec50/rcar_sound,ssi/ssi@4 has 
> a unit name, but no reg property
> Warning (unit_address_vs_reg): Node /sound@ec50/rcar_sound,ssi/ssi@5 has 
> a unit name, but no reg property
> Warning (unit_address_vs_reg): Node /sound@ec50/rcar_sound,ssi/ssi@6 has 
> a unit name, but no reg property
> Warning (unit_address_vs_reg): Node /sound@ec50/rcar_sound,ssi/ssi@7 has 
> a unit name, but no reg property
> Warning (unit_address_vs_reg): Node /sound@ec50/rcar_sound,ssi/ssi@8 has 
> a unit name, but no reg property
> Warning (unit_address_vs_reg): Node /sound@ec50/rcar_sound,ssi/ssi@9 has 
> a unit name, but no reg property
> 
> Move the cache-controller nodes under the cpus node, and make their unit
> names and reg properties match the MPIDR values.
> 
> Signed-off-by: Geert Uytterhoeven 
> Signed-off-by: Simon Horman 
> ---

For sound portion.

Acked-by: Kuninori Morimoto 



Re: [PATCH v2 05/11] ARM: dts: r8a7792: initial SoC device tree

2016-06-08 Thread Geert Uytterhoeven
Hi Sergei,

On Fri, Jun 3, 2016 at 11:26 PM, Sergei Shtylyov
 wrote:
> The initial R8A7792 SoC device tree including CPU core, GIC, timer, SYSC,
> and the required  clock descriptions.
>
> Signed-off-by: Sergei Shtylyov 
>
> ---
> Changes in version 2:

> - created  the "soc" subnode, moving the SoC  device  nodes there;
> - removed  the "clocks" node, moving its fixed clock  subnodes to the root and
>   the MSTP subnodes into the "soc" node.
>
>  arch/arm/boot/dts/r8a7792.dtsi |  171 
> +
>  1 file changed, 171 insertions(+)
>
> Index: renesas/arch/arm/boot/dts/r8a7792.dtsi
> ===
> --- /dev/null
> +++ renesas/arch/arm/boot/dts/r8a7792.dtsi

> +   /* Fixed factor clocks */
> +   zs_clk: zs {
> +   compatible = "fixed-factor-clock";
> +   clocks = <_clocks R8A7792_CLK_PLL1>;
> +   #clock-cells = <0>;
> +   clock-div = <6>;
> +   clock-mult = <1>;
> +   };
> +   p_clk: p {
> +   compatible = "fixed-factor-clock";
> +   clocks = <_clocks R8A7792_CLK_PLL1>;
> +   #clock-cells = <0>;
> +   clock-div = <24>;
> +   clock-mult = <1>;
> +   };
> +   cp_clk: cp {
> +   compatible = "fixed-factor-clock";
> +   clocks = <_clocks R8A7792_CLK_PLL1>;
> +   #clock-cells = <0>;
> +   clock-div = <3>;
> +   clock-mult = <1>;
> +   };

I think the above 3 fixed factor clocks should be children of the "soc" node,
as they're generated on-SoC.

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] iommu/ipmmu-vmsa: Hook up r8a7796 DT matching code

2016-06-08 Thread Geert Uytterhoeven
Hi Laurent,

On Wed, Jun 8, 2016 at 2:18 AM, Laurent Pinchart
 wrote:
>> --- 0031/drivers/iommu/ipmmu-vmsa.c
>> +++ work/drivers/iommu/ipmmu-vmsa.c   2016-06-06 11:19:40.210607110 +0900
>> @@ -1074,7 +1074,7 @@ static const struct ipmmu_features ipmmu
>>   .twobit_imttbcr_sl0 = false,
>>  };
>>
>> -static const struct ipmmu_features ipmmu_features_r8a7795 = {
>> +static const struct ipmmu_features ipmmu_features_rcar_gen3 = {
>>   .use_ns_alias_offset = false,
>>   .has_cache_leaf_nodes = true,
>>   .has_eight_ctx = true,
>> @@ -1088,7 +1088,10 @@ static const struct of_device_id ipmmu_o
>>   .data = _features_default,
>>   }, {
>>   .compatible = "renesas,ipmmu-r8a7795",
>> - .data = _features_r8a7795,
>> + .data = _features_rcar_gen3,
>> + }, {
>> + .compatible = "renesas,ipmmu-r8a7796",
>> + .data = _features_rcar_gen3,
>>   }, {
>>   /* Terminator */
>>   },
>> @@ -1268,6 +1271,8 @@ IOMMU_OF_DECLARE(ipmmu_vmsa_iommu_of, "r
>>ipmmu_vmsa_iommu_of_setup);
>>  IOMMU_OF_DECLARE(ipmmu_r8a7795_iommu_of, "renesas,ipmmu-r8a7795",
>>ipmmu_vmsa_iommu_of_setup);
>> +IOMMU_OF_DECLARE(ipmmu_r8a7796_iommu_of, "renesas,ipmmu-r8a7796",
>> +  ipmmu_vmsa_iommu_of_setup);
>
> How about a Gen3 generic compatible string in addition to the SoC-specific
> ones ?

Do we want to specify the number of utlbs here?
Does it differ between r8a7795, r8a7796, and future members?

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] i2c: mux: refer to i2c-mux.txt

2016-06-08 Thread Simon Horman
Correct references to i2c-mux.txt which was previously mux.txt.

Also correct the spelling of relevant.

Signed-off-by: Simon Horman 
---
 Documentation/devicetree/bindings/i2c/i2c-arb-gpio-challenge.txt | 4 ++--
 Documentation/devicetree/bindings/i2c/i2c-demux-pinctrl.txt  | 3 ++-
 Documentation/devicetree/bindings/i2c/i2c-mux-gpio.txt   | 6 +++---
 Documentation/devicetree/bindings/i2c/i2c-mux-pinctrl.txt| 4 ++--
 Documentation/devicetree/bindings/i2c/i2c-mux-reg.txt| 6 +++---
 5 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/Documentation/devicetree/bindings/i2c/i2c-arb-gpio-challenge.txt 
b/Documentation/devicetree/bindings/i2c/i2c-arb-gpio-challenge.txt
index bfeabb843941..71191ff0e781 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-arb-gpio-challenge.txt
+++ b/Documentation/devicetree/bindings/i2c/i2c-arb-gpio-challenge.txt
@@ -44,8 +44,8 @@ Required properties:
 - our-claim-gpio: The GPIO that we use to claim the bus.
 - their-claim-gpios: The GPIOs that the other sides use to claim the bus.
   Note that some implementations may only support a single other master.
-- Standard I2C mux properties. See mux.txt in this directory.
-- Single I2C child bus node at reg 0. See mux.txt in this directory.
+- Standard I2C mux properties. See i2c-mux.txt in this directory.
+- Single I2C child bus node at reg 0. See i2c-mux.txt in this directory.
 
 Optional properties:
 - slew-delay-us: microseconds to wait for a GPIO to go high. Default is 10 us.
diff --git a/Documentation/devicetree/bindings/i2c/i2c-demux-pinctrl.txt 
b/Documentation/devicetree/bindings/i2c/i2c-demux-pinctrl.txt
index 6078aefe7ed4..7ce23ac61308 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-demux-pinctrl.txt
+++ b/Documentation/devicetree/bindings/i2c/i2c-demux-pinctrl.txt
@@ -27,7 +27,8 @@ Required properties:
 - i2c-bus-name: The name of this bus. Also needed as pinctrl-name for the I2C
parents.
 
-Furthermore, I2C mux properties and child nodes. See mux.txt in this directory.
+Furthermore, I2C mux properties and child nodes. See i2c-mux.txt in this
+directory.
 
 Example:
 
diff --git a/Documentation/devicetree/bindings/i2c/i2c-mux-gpio.txt 
b/Documentation/devicetree/bindings/i2c/i2c-mux-gpio.txt
index 66709a825541..21da3ecbb370 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-mux-gpio.txt
+++ b/Documentation/devicetree/bindings/i2c/i2c-mux-gpio.txt
@@ -22,8 +22,8 @@ Required properties:
 - i2c-parent: The phandle of the I2C bus that this multiplexer's master-side
   port is connected to.
 - mux-gpios: list of gpios used to control the muxer
-* Standard I2C mux properties. See mux.txt in this directory.
-* I2C child bus nodes. See mux.txt in this directory.
+* Standard I2C mux properties. See i2c-mux.txt in this directory.
+* I2C child bus nodes. See i2c-mux.txt in this directory.
 
 Optional properties:
 - idle-state: value to set the muxer to when idle. When no value is
@@ -33,7 +33,7 @@ For each i2c child node, an I2C child bus will be created. 
They will
 be numbered based on their order in the device tree.
 
 Whenever an access is made to a device on a child bus, the value set
-in the revelant node's reg property will be output using the list of
+in the relevant node's reg property will be output using the list of
 GPIOs, the first in the list holding the least-significant value.
 
 If an idle state is defined, using the idle-state (optional) property,
diff --git a/Documentation/devicetree/bindings/i2c/i2c-mux-pinctrl.txt 
b/Documentation/devicetree/bindings/i2c/i2c-mux-pinctrl.txt
index ae8af1694e95..33119a98e144 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-mux-pinctrl.txt
+++ b/Documentation/devicetree/bindings/i2c/i2c-mux-pinctrl.txt
@@ -28,9 +28,9 @@ Also required are:
 * Standard pinctrl properties that specify the pin mux state for each child
   bus. See ../pinctrl/pinctrl-bindings.txt.
 
-* Standard I2C mux properties. See mux.txt in this directory.
+* Standard I2C mux properties. See i2c-mux.txt in this directory.
 
-* I2C child bus nodes. See mux.txt in this directory.
+* I2C child bus nodes. See i2c-mux.txt in this directory.
 
 For each named state defined in the pinctrl-names property, an I2C child bus
 will be created. I2C child bus numbers are assigned based on the index into
diff --git a/Documentation/devicetree/bindings/i2c/i2c-mux-reg.txt 
b/Documentation/devicetree/bindings/i2c/i2c-mux-reg.txt
index 688783fbe696..de00d7fc450b 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-mux-reg.txt
+++ b/Documentation/devicetree/bindings/i2c/i2c-mux-reg.txt
@@ -7,8 +7,8 @@ Required properties:
 - compatible: i2c-mux-reg
 - i2c-parent: The phandle of the I2C bus that this multiplexer's master-side
   port is connected to.
-* Standard I2C mux properties. See mux.txt in this directory.
-* I2C child bus nodes. See mux.txt in this directory.
+* Standard I2C mux properties. See i2c-mux.txt in this directory.