[PATCH 1/1] drm/bridge: anx7625: send DPCD command to downstream

2021-04-08 Thread Xin Ji
Send DPCD command to downstream before anx7625 power down,
tell downstream into standby mode.

Signed-off-by: Xin Ji 
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 75 +++
 1 file changed, 75 insertions(+)

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
b/drivers/gpu/drm/bridge/analogix/anx7625.c
index 65cc05982f82..53d2f0d0ee30 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -124,6 +124,23 @@ static int anx7625_reg_write(struct anx7625_data *ctx,
return ret;
 }
 
+static int anx7625_reg_block_write(struct anx7625_data *ctx,
+  struct i2c_client *client,
+  u8 reg_addr, u8 len, u8 *buf)
+{
+   int ret;
+   struct device *dev = &client->dev;
+
+   i2c_access_workaround(ctx, client);
+
+   ret = i2c_smbus_write_i2c_block_data(client, reg_addr, len, buf);
+   if (ret < 0)
+   DRM_DEV_ERROR(dev, "write i2c block failed id=%x\n:%x",
+ client->addr, reg_addr);
+
+   return ret;
+}
+
 static int anx7625_write_or(struct anx7625_data *ctx,
struct i2c_client *client,
u8 offset, u8 mask)
@@ -195,6 +212,55 @@ static int wait_aux_op_finish(struct anx7625_data *ctx)
return val;
 }
 
+static int anx7625_aux_dpcd_write(struct anx7625_data *ctx,
+ u8 addrh, u8 addrm, u8 addrl,
+ u8 len, u8 *buf)
+{
+   struct device *dev = &ctx->client->dev;
+   int ret;
+   u8 cmd;
+
+   if (len > MAX_DPCD_BUFFER_SIZE) {
+   DRM_DEV_ERROR(dev, "exceed aux buffer len.\n");
+   return -EINVAL;
+   }
+
+   cmd = ((len - 1) << 4) | 0x08;
+
+   /* Set command and length */
+   ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+   AP_AUX_COMMAND, cmd);
+
+   /* Set aux access address */
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+AP_AUX_ADDR_7_0, addrl);
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+AP_AUX_ADDR_15_8, addrm);
+   ret |= anx7625_write_and(ctx, ctx->i2c.rx_p0_client,
+AP_AUX_ADDR_19_16, addrh);
+
+   /* Set write data */
+   ret |= anx7625_reg_block_write(ctx, ctx->i2c.rx_p0_client,
+  AP_AUX_BUFF_START, len, buf);
+   /* Enable aux access */
+   ret |= anx7625_write_or(ctx, ctx->i2c.rx_p0_client,
+   AP_AUX_CTRL_STATUS, AP_AUX_CTRL_OP_EN);
+   if (ret < 0) {
+   DRM_DEV_ERROR(dev, "cannot access aux related register.\n");
+   return -EIO;
+   }
+
+   usleep_range(2000, 2100);
+
+   ret = wait_aux_op_finish(ctx);
+   if (ret) {
+   DRM_DEV_ERROR(dev, "aux IO error: wait aux op finish.\n");
+   return ret;
+   }
+
+   return 0;
+}
+
 static int anx7625_video_mute_control(struct anx7625_data *ctx,
  u8 status)
 {
@@ -617,6 +683,7 @@ static void anx7625_dp_stop(struct anx7625_data *ctx)
 {
struct device *dev = &ctx->client->dev;
int ret;
+   u8 data;
 
DRM_DEV_DEBUG_DRIVER(dev, "stop dp output\n");
 
@@ -628,8 +695,16 @@ static void anx7625_dp_stop(struct anx7625_data *ctx)
ret |= anx7625_write_and(ctx, ctx->i2c.tx_p2_client, 0x08, 0x7f);
 
ret |= anx7625_video_mute_control(ctx, 1);
+
+   DRM_DEV_DEBUG_DRIVER(dev, "notify downstream enter into standby\n");
+
+   /* Downstream monitor enter into standby mode */
+   data = 2;
+   ret |= anx7625_aux_dpcd_write(ctx, 0x00, 0x06, 0x00, 1, &data);
if (ret < 0)
DRM_DEV_ERROR(dev, "IO error : mute video fail\n");
+
+   return;
 }
 
 static int sp_tx_rst_aux(struct anx7625_data *ctx)
-- 
2.25.1



Re: [PATCH v6 4/5] drm/bridge: anx7625: add HDCP support

2021-04-02 Thread Xin Ji
On Fri, Apr 02, 2021 at 11:59:39AM +0300, Laurent Pinchart wrote:
> Hi Xin,
> 
> On Fri, Apr 02, 2021 at 10:27:08AM +0800, Xin Ji wrote:
> > On Mon, Mar 29, 2021 at 02:02:08PM -0400, Sean Paul wrote:
> > > On Mon, Mar 29, 2021 at 6:27 AM Xin Ji  wrote:
> > > >
> > > > On Thu, Mar 25, 2021 at 02:19:23PM -0400, Sean Paul wrote:
> > > > > On Fri, Mar 19, 2021 at 2:35 AM Xin Ji  wrote:
> > > > > >
> > > > > > Add HDCP feature, enable HDCP function through chip internal key
> > > > > > and downstream's capability.
> > > > > >
> > > > > > Signed-off-by: Xin Ji 
> > > > > > ---
> > > 
> > > /snip
> > > 
> > > > > >  static void anx7625_dp_start(struct anx7625_data *ctx)
> > > > > >  {
> > > > > > int ret;
> > > > > > @@ -643,6 +787,9 @@ static void anx7625_dp_start(struct 
> > > > > > anx7625_data *ctx)
> > > > > > return;
> > > > > > }
> > > > > >
> > > > > > +   /* HDCP config */
> > > > > > +   anx7625_hdcp_setting(ctx);
> > > > >
> > > > > You should really use the "Content Protection" property to
> > > > > enable/disable HDCP instead of force-enabling it at all times.
> > > >
> > > > Hi Sean, it's hard to implement "Content Protection" property, we have
> > > > implemented HDCP in firmware, it is not compatible with it. We don't
> > > > have interface to get Downstream Cert.
> > > > Thanks,
> > > > Xin
> > > 
> > > Hi Xin,
> > > I'm sorry, I don't understand what you mean when you say you don't
> > > have an interface to get Downstream Cert.
> > > 
> > > The Content Protection property is just a means through which
> > > userspace can turn on and turn off HDCP when it needs. As far as I can
> > > tell, your patch turns on HDCP when the display is enabled and leaves
> > > it on until it is disabled. This is undesirable since it forces HDCP
> > > on the user.
> > > 
> > > Is it impossible to enable/disable HDCP outside of display
> > > enable/disable on your hardware?
> >
> > Hi Sean, I have commit a test patch on google review site, can you
> > please help to review it? I'll use Connector's ".atomic_check()"
> > interface to detect Content Protection property change.
> > (https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fchromium-review.googlesource.com%2Fc%2Fchromiumos%2Fthird_party%2Fkernel%2F%2B%2F2674580&data=04%7C01%7Cxji%40analogixsemi.com%7Cd778885f3d0d4b4358a908d8f5b5c273%7Cb099b0b4f26c4cf59a0fd5be9acab205%7C0%7C0%7C637529508334886979%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=vo8zP8SAhLrQk0%2FWh1OhXHAZzLU9lJ4NLaYddI6t2ZU%3D&reserved=0)
> 
> Please note that upstream review happens on mailing lists, not in
> gerrit. Internal reviews for Chrome OS development are certainly fine
> there, but that will not mean the patch will then be accepted upstream
> as-is, it will still need to go through the upstream review process,
> without any shortcut. I strongly recommend using an upstream-first
> strategy, with public review.
Hi Laurent Pinchart, OK, got it, thanks for the note.

Thanks,
Xin
> 
> > > > > > +
> > > > > > if (ctx->pdata.is_dpi)
> > > > > > ret = anx7625_dpi_config(ctx);
> > > > > > else
> > > 
> > > /snip
> 
> -- 
> Regards,
> 
> Laurent Pinchart


Re: [PATCH v6 1/5] dt-bindings:drm/bridge:anx7625:add vendor define flags

2021-04-01 Thread Xin Ji
On Thu, Apr 01, 2021 at 02:33:47PM +0200, Robert Foss wrote:
> Hey Xin,
> 
> This series no longer applies to drm-misc/drm-misc-next, please rebase it.
Hi Robert Foss, OK, I'll rebase it on the drm-misc-next after confirmed
HDCP patch with Sean Paul.
Thanks,
Xin
> 
> On Wed, 24 Mar 2021 at 08:52, Xin Ji  wrote:
> >
> > On Sun, Mar 21, 2021 at 02:00:38PM +0200, Laurent Pinchart wrote:
> > > Hi Xin,
> > >
> > > Thank you for the patch.
> > >
> > > On Fri, Mar 19, 2021 at 02:32:39PM +0800, Xin Ji wrote:
> > > > Add 'bus-type' and 'data-lanes' define for port0. Define DP tx lane0,
> > > > lane1 swing register array define, and audio enable flag.
> > > >
> > > > Signed-off-by: Xin Ji 
> > > > ---
> > > >  .../display/bridge/analogix,anx7625.yaml  | 58 ++-
> > > >  1 file changed, 57 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git 
> > > > a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > > >  
> > > > b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > > > index c789784efe30..3f54d5876982 100644
> > > > --- 
> > > > a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > > > +++ 
> > > > b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > > > @@ -34,6 +34,26 @@ properties:
> > > >  description: used for reset chip control, RESET_N pin B7.
> > > >  maxItems: 1
> > > >
> > > > +  analogix,lane0-swing:
> > > > +$ref: /schemas/types.yaml#/definitions/uint32-array
> > > > +minItems: 1
> > > > +maxItems: 20
> > > > +description:
> > > > +  an array of swing register setting for DP tx lane0 PHY, please 
> > > > don't
> > > > +  add this property, or contact vendor.
> > >
> > > DT properties need to be documented. Contacting the vendor doesn't count
> > > as documentation I'm afraid.
> >
> > Hi Laurent Pinchart, thanks for your comment. For the DP phy swing
> > setting, it is hard to describe in here, needs to refer the anx7625
> > datasheet and programming guide. Basically, no need to change the DP phy
> > swing setting.
> >
> 
> Laurent is right. But if the value practically is a constant, you can
> move the swing register into the driver. It should still be documented
> as well as possible, but we can be a little bit more flexible.
> 
> > > > @@ -73,6 +123,10 @@ examples:
> > > >  enable-gpios = <&pio 45 GPIO_ACTIVE_HIGH>;
> > > >  reset-gpios = <&pio 73 GPIO_ACTIVE_HIGH>;
> > > >
> > > > +analogix,audio-enable;
> > > > +analogix,lane0-swing = <0x14 0x54 0x64 0x74 0x29 0x7b 0x77 
> > > > 0x5b>;
> > > > +analogix,lane1-swing = <0x14 0x54 0x64 0x74 0x29 0x7b 0x77 
> > > > 0x5b>;
> > > > +
> > > >  ports {
> > > >  #address-cells = <1>;
> > > >  #size-cells = <0>;


Re: [PATCH v6 4/5] drm/bridge: anx7625: add HDCP support

2021-04-01 Thread Xin Ji
On Mon, Mar 29, 2021 at 02:02:08PM -0400, Sean Paul wrote:
> On Mon, Mar 29, 2021 at 6:27 AM Xin Ji  wrote:
> >
> > On Thu, Mar 25, 2021 at 02:19:23PM -0400, Sean Paul wrote:
> > > On Fri, Mar 19, 2021 at 2:35 AM Xin Ji  wrote:
> > > >
> > > > Add HDCP feature, enable HDCP function through chip internal key
> > > > and downstream's capability.
> > > >
> > > > Signed-off-by: Xin Ji 
> > > > ---
> 
> /snip
> 
> > > >  static void anx7625_dp_start(struct anx7625_data *ctx)
> > > >  {
> > > > int ret;
> > > > @@ -643,6 +787,9 @@ static void anx7625_dp_start(struct anx7625_data 
> > > > *ctx)
> > > > return;
> > > > }
> > > >
> > > > +   /* HDCP config */
> > > > +   anx7625_hdcp_setting(ctx);
> > >
> > > You should really use the "Content Protection" property to
> > > enable/disable HDCP instead of force-enabling it at all times.
> > >
> > > Sean
> > Hi Sean, it's hard to implement "Content Protection" property, we have
> > implemented HDCP in firmware, it is not compatible with it. We don't
> > have interface to get Downstream Cert.
> > Thanks,
> > Xin
> 
> Hi Xin,
> I'm sorry, I don't understand what you mean when you say you don't
> have an interface to get Downstream Cert.
> 
> The Content Protection property is just a means through which
> userspace can turn on and turn off HDCP when it needs. As far as I can
> tell, your patch turns on HDCP when the display is enabled and leaves
> it on until it is disabled. This is undesirable since it forces HDCP
> on the user.
> 
> Is it impossible to enable/disable HDCP outside of display
> enable/disable on your hardware?
> 
> Thanks,
> 
> Sean
Hi Sean, I have commit a test patch on google review site, can you
please help to review it? I'll use Connector's ".atomic_check()"
interface to detect Content Protection property change.
(https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/2674580)
Thanks,
Xin
> 
> > >
> > > > +
> > > > if (ctx->pdata.is_dpi)
> > > > ret = anx7625_dpi_config(ctx);
> > > > else
> 
> /snip


Re: [PATCH v6 4/5] drm/bridge: anx7625: add HDCP support

2021-03-29 Thread Xin Ji
On Thu, Mar 25, 2021 at 02:19:23PM -0400, Sean Paul wrote:
> On Fri, Mar 19, 2021 at 2:35 AM Xin Ji  wrote:
> >
> > Add HDCP feature, enable HDCP function through chip internal key
> > and downstream's capability.
> >
> > Signed-off-by: Xin Ji 
> > ---
> >  drivers/gpu/drm/bridge/analogix/anx7625.c | 147 ++
> >  drivers/gpu/drm/bridge/analogix/anx7625.h |  36 ++
> >  2 files changed, 183 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
> > b/drivers/gpu/drm/bridge/analogix/anx7625.c
> > index 8c514b46d361..b424a570effa 100644
> > --- a/drivers/gpu/drm/bridge/analogix/anx7625.c
> > +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
> > @@ -633,6 +633,150 @@ static int anx7625_dpi_config(struct anx7625_data 
> > *ctx)
> > return ret;
> >  }
> >
> > +static int anx7625_aux_dpcd_read(struct anx7625_data *ctx,
> > +u8 addrh, u8 addrm, u8 addrl,
> > +u8 len, u8 *buf)
> > +{
> > +   struct device *dev = &ctx->client->dev;
> > +   int ret;
> > +   u8 cmd;
> > +
> > +   if (len > MAX_DPCD_BUFFER_SIZE) {
> > +   DRM_DEV_ERROR(dev, "exceed aux buffer len.\n");
> > +   return -E2BIG;
> > +   }
> > +
> > +   cmd = ((len - 1) << 4) | 0x09;
> > +
> > +   /* Set command and length */
> > +   ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
> > +   AP_AUX_COMMAND, cmd);
> > +
> > +   /* Set aux access address */
> > +   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
> > +AP_AUX_ADDR_7_0, addrl);
> > +   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
> > +AP_AUX_ADDR_15_8, addrm);
> > +   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
> > +AP_AUX_ADDR_19_16, addrh);
> > +
> > +   /* Enable aux access */
> > +   ret |= anx7625_write_or(ctx, ctx->i2c.rx_p0_client,
> > +   AP_AUX_CTRL_STATUS, AP_AUX_CTRL_OP_EN);
> > +
> > +   if (ret < 0) {
> > +   DRM_DEV_ERROR(dev, "cannot access aux related register.\n");
> > +   return -EIO;
> > +   }
> > +
> > +   usleep_range(2000, 2100);
> > +
> > +   ret = wait_aux_op_finish(ctx);
> > +   if (ret) {
> > +   DRM_DEV_ERROR(dev, "aux IO error: wait aux op finish.\n");
> > +   return ret;
> > +   }
> > +
> > +   ret = anx7625_reg_block_read(ctx, ctx->i2c.rx_p0_client,
> > +AP_AUX_BUFF_START, len, buf);
> > +   if (ret < 0) {
> > +   DRM_DEV_ERROR(dev, "read dpcd register failed\n");
> > +   return -EIO;
> > +   }
> > +
> > +   return 0;
> > +}
> > +
> > +static int anx7625_read_flash_status(struct anx7625_data *ctx)
> > +{
> > +   return anx7625_reg_read(ctx, ctx->i2c.rx_p0_client, R_RAM_CTRL);
> > +}
> > +
> > +static int anx7625_hdcp_key_probe(struct anx7625_data *ctx)
> > +{
> > +   int ret, val;
> > +   struct device *dev = &ctx->client->dev;
> > +   u8 ident[32];
> > +
> > +   ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
> > +   FLASH_ADDR_HIGH, 0x91);
> > +   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
> > +FLASH_ADDR_LOW, 0xA0);
> > +   if (ret < 0) {
> > +   DRM_DEV_ERROR(dev, "IO error : set key flash address.\n");
> > +   return ret;
> > +   }
> > +
> > +   ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
> > +   FLASH_LEN_HIGH, (FLASH_BUF_LEN - 1) >> 8);
> > +   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
> > +FLASH_LEN_LOW, (FLASH_BUF_LEN - 1) & 0xFF);
> > +   if (ret < 0) {
> > +   DRM_DEV_ERROR(dev, "IO error : set key flash len.\n");
> > +   return ret;
> > +   }
> > +
> > +   ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
> > +   R_FLASH_RW_CTRL, FLASH_READ);
> > +   ret |= readx_poll_timeout(anx76

Re: [PATCH v6 1/5] dt-bindings:drm/bridge:anx7625:add vendor define flags

2021-03-24 Thread Xin Ji
On Sun, Mar 21, 2021 at 02:00:38PM +0200, Laurent Pinchart wrote:
> Hi Xin,
> 
> Thank you for the patch.
> 
> On Fri, Mar 19, 2021 at 02:32:39PM +0800, Xin Ji wrote:
> > Add 'bus-type' and 'data-lanes' define for port0. Define DP tx lane0,
> > lane1 swing register array define, and audio enable flag.
> > 
> > Signed-off-by: Xin Ji 
> > ---
> >  .../display/bridge/analogix,anx7625.yaml  | 58 ++-
> >  1 file changed, 57 insertions(+), 1 deletion(-)
> > 
> > diff --git 
> > a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml 
> > b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > index c789784efe30..3f54d5876982 100644
> > --- a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > +++ b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > @@ -34,6 +34,26 @@ properties:
> >  description: used for reset chip control, RESET_N pin B7.
> >  maxItems: 1
> >  
> > +  analogix,lane0-swing:
> > +$ref: /schemas/types.yaml#/definitions/uint32-array
> > +minItems: 1
> > +maxItems: 20
> > +description:
> > +  an array of swing register setting for DP tx lane0 PHY, please don't
> > +  add this property, or contact vendor.
> 
> DT properties need to be documented. Contacting the vendor doesn't count
> as documentation I'm afraid.
Hi Laurent Pinchart, thanks for your comment. For the DP phy swing
setting, it is hard to describe in here, needs to refer the anx7625
datasheet and programming guide. Basically, no need to change the DP phy
swing setting.

Thanks,
Xin
> 
> > +
> > +  analogix,lane1-swing:
> > +$ref: /schemas/types.yaml#/definitions/uint32-array
> > +minItems: 1
> > +maxItems: 20
> > +description:
> > +  an array of swing register setting for DP tx lane1 PHY, please don't
> > +  add this property, or contact vendor.
> > +
> > +  analogix,audio-enable:
> > +type: boolean
> > +description: let the driver enable audio HDMI codec function or not.
> > +
> >ports:
> >  $ref: /schemas/graph.yaml#/properties/ports
> >  
> > @@ -41,13 +61,43 @@ properties:
> >port@0:
> >  $ref: /schemas/graph.yaml#/properties/port
> >  description:
> > -  Video port for MIPI DSI input.
> > +  MIPI DSI/DPI input.
> > +
> > +properties:
> > +  endpoint:
> > +$ref: /schemas/media/video-interfaces.yaml#
> > +type: object
> > +additionalProperties: false
> > +
> > +properties:
> > +  remote-endpoint: true
> > +  bus-type: true
> > +  data-lanes: true
> > +
> > +required:
> > +  - remote-endpoint
> > +
> > +required:
> > +  - endpoint
> > +
> >  
> >port@1:
> >  $ref: /schemas/graph.yaml#/properties/port
> >  description:
> >Video port for panel or connector.
> >  
> > +properties:
> > +  endpoint:
> > +$ref: /schemas/media/video-interfaces.yaml#
> > +type: object
> > +additionalProperties: false
> > +
> > +properties:
> > +  remote-endpoint: true
> > +
> > +required:
> > +  - remote-endpoint
> > +
> >  required:
> >- port@0
> >- port@1
> > @@ -73,6 +123,10 @@ examples:
> >  enable-gpios = <&pio 45 GPIO_ACTIVE_HIGH>;
> >  reset-gpios = <&pio 73 GPIO_ACTIVE_HIGH>;
> >  
> > +analogix,audio-enable;
> > +analogix,lane0-swing = <0x14 0x54 0x64 0x74 0x29 0x7b 0x77 
> > 0x5b>;
> > +analogix,lane1-swing = <0x14 0x54 0x64 0x74 0x29 0x7b 0x77 
> > 0x5b>;
> > +
> >  ports {
> >  #address-cells = <1>;
> >  #size-cells = <0>;
> > @@ -81,6 +135,8 @@ examples:
> >  reg = <0>;
> >  anx7625_in: endpoint {
> >  remote-endpoint = <&mipi_dsi>;
> > +bus-type = <5>;
> > +data-lanes = <0 1 2 3>;
> >  };
> >  };
> >  
> 
> -- 
> Regards,
> 
> Laurent Pinchart


[PATCH v6 5/5] drm/bridge: anx7625: add HDMI audio function

2021-03-18 Thread Xin Ji
Add audio HDMI codec function support, enable it through device true flag
"analogix,audio-enable".

Reported-by: kernel test robot 
Signed-off-by: Xin Ji 
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 227 ++
 drivers/gpu/drm/bridge/analogix/anx7625.h |   5 +
 2 files changed, 232 insertions(+)

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
b/drivers/gpu/drm/bridge/analogix/anx7625.c
index b424a570effa..02bb169d9c57 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -30,6 +30,8 @@
 #include 
 #include 
 
+#include 
+
 #include 
 
 #include "anx7625.h"
@@ -150,6 +152,20 @@ static int anx7625_write_and(struct anx7625_data *ctx,
return anx7625_reg_write(ctx, client, offset, (val & (mask)));
 }
 
+static int anx7625_write_and_or(struct anx7625_data *ctx,
+   struct i2c_client *client,
+   u8 offset, u8 and_mask, u8 or_mask)
+{
+   int val;
+
+   val = anx7625_reg_read(ctx, client, offset);
+   if (val < 0)
+   return val;
+
+   return anx7625_reg_write(ctx, client,
+offset, (val & and_mask) | (or_mask));
+}
+
 static int anx7625_config_bit_matrix(struct anx7625_data *ctx)
 {
int i, ret;
@@ -1498,6 +1514,9 @@ static int anx7625_parse_dt(struct device *dev,
else
DRM_DEV_DEBUG_DRIVER(dev, "found MIPI DSI host node.\n");
 
+   if (of_property_read_bool(np, "analogix,audio-enable"))
+   pdata->audio_en = 1;
+
ret = drm_of_find_panel_or_bridge(np, 1, 0, &panel, NULL);
if (ret < 0) {
if (ret == -ENODEV)
@@ -1568,6 +1587,208 @@ static enum drm_connector_status 
anx7625_sink_detect(struct anx7625_data *ctx)
 connector_status_disconnected;
 }
 
+static int anx7625_audio_hw_params(struct device *dev, void *data,
+  struct hdmi_codec_daifmt *fmt,
+  struct hdmi_codec_params *params)
+{
+   struct anx7625_data *ctx = dev_get_drvdata(dev);
+   int wl, ch, rate;
+   int ret = 0;
+
+   if (fmt->fmt != HDMI_DSP_A) {
+   DRM_DEV_ERROR(dev, "only supports DSP_A\n");
+   return -EINVAL;
+   }
+
+   DRM_DEV_DEBUG_DRIVER(dev, "setting %d Hz, %d bit, %d channels\n",
+params->sample_rate, params->sample_width,
+params->cea.channels);
+
+   ret |= anx7625_write_and_or(ctx, ctx->i2c.tx_p2_client,
+   AUDIO_CHANNEL_STATUS_6,
+   ~I2S_SLAVE_MODE,
+   TDM_SLAVE_MODE);
+
+   /* Word length */
+   switch (params->sample_width) {
+   case 16:
+   wl = AUDIO_W_LEN_16_20MAX;
+   break;
+   case 18:
+   wl = AUDIO_W_LEN_18_20MAX;
+   break;
+   case 20:
+   wl = AUDIO_W_LEN_20_20MAX;
+   break;
+   case 24:
+   wl = AUDIO_W_LEN_24_24MAX;
+   break;
+   default:
+   DRM_DEV_DEBUG_DRIVER(dev, "wordlength: %d bit not support",
+params->sample_width);
+   return -EINVAL;
+   }
+   ret |= anx7625_write_and_or(ctx, ctx->i2c.tx_p2_client,
+   AUDIO_CHANNEL_STATUS_5,
+   0xf0, wl);
+
+   /* Channel num */
+   switch (params->cea.channels) {
+   case 2:
+   ch = I2S_CH_2;
+   break;
+   case 4:
+   ch = TDM_CH_4;
+   break;
+   case 6:
+   ch = TDM_CH_6;
+   break;
+   case 8:
+   ch = TDM_CH_8;
+   break;
+   default:
+   DRM_DEV_DEBUG_DRIVER(dev, "channel number: %d not support",
+params->cea.channels);
+   return -EINVAL;
+   }
+   ret |= anx7625_write_and_or(ctx, ctx->i2c.tx_p2_client,
+  AUDIO_CHANNEL_STATUS_6, 0x1f, ch << 5);
+   if (ch > I2S_CH_2)
+   ret |= anx7625_write_or(ctx, ctx->i2c.tx_p2_client,
+   AUDIO_CHANNEL_STATUS_6, AUDIO_LAYOUT);
+   else
+   ret |= anx7625_write_and(ctx, ctx->i2c.tx_p2_client,
+   AUDIO_CHANNEL_STATUS_6, ~AUDIO_LAYOUT);
+
+   /* FS */
+   switch (params->sample_rate) {
+   case 32000:
+   rate = AUDIO_FS_32K;
+   break;
+   case 44100:
+   rate = AUDIO_FS_441K;
+   break;
+   case 48000:
+   rate = AUDIO_FS_48K;
+   break;
+  

[PATCH v6 4/5] drm/bridge: anx7625: add HDCP support

2021-03-18 Thread Xin Ji
Add HDCP feature, enable HDCP function through chip internal key
and downstream's capability.

Signed-off-by: Xin Ji 
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 147 ++
 drivers/gpu/drm/bridge/analogix/anx7625.h |  36 ++
 2 files changed, 183 insertions(+)

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
b/drivers/gpu/drm/bridge/analogix/anx7625.c
index 8c514b46d361..b424a570effa 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -633,6 +633,150 @@ static int anx7625_dpi_config(struct anx7625_data *ctx)
return ret;
 }
 
+static int anx7625_aux_dpcd_read(struct anx7625_data *ctx,
+u8 addrh, u8 addrm, u8 addrl,
+u8 len, u8 *buf)
+{
+   struct device *dev = &ctx->client->dev;
+   int ret;
+   u8 cmd;
+
+   if (len > MAX_DPCD_BUFFER_SIZE) {
+   DRM_DEV_ERROR(dev, "exceed aux buffer len.\n");
+   return -E2BIG;
+   }
+
+   cmd = ((len - 1) << 4) | 0x09;
+
+   /* Set command and length */
+   ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+   AP_AUX_COMMAND, cmd);
+
+   /* Set aux access address */
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+AP_AUX_ADDR_7_0, addrl);
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+AP_AUX_ADDR_15_8, addrm);
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+AP_AUX_ADDR_19_16, addrh);
+
+   /* Enable aux access */
+   ret |= anx7625_write_or(ctx, ctx->i2c.rx_p0_client,
+   AP_AUX_CTRL_STATUS, AP_AUX_CTRL_OP_EN);
+
+   if (ret < 0) {
+   DRM_DEV_ERROR(dev, "cannot access aux related register.\n");
+   return -EIO;
+   }
+
+   usleep_range(2000, 2100);
+
+   ret = wait_aux_op_finish(ctx);
+   if (ret) {
+   DRM_DEV_ERROR(dev, "aux IO error: wait aux op finish.\n");
+   return ret;
+   }
+
+   ret = anx7625_reg_block_read(ctx, ctx->i2c.rx_p0_client,
+AP_AUX_BUFF_START, len, buf);
+   if (ret < 0) {
+   DRM_DEV_ERROR(dev, "read dpcd register failed\n");
+   return -EIO;
+   }
+
+   return 0;
+}
+
+static int anx7625_read_flash_status(struct anx7625_data *ctx)
+{
+   return anx7625_reg_read(ctx, ctx->i2c.rx_p0_client, R_RAM_CTRL);
+}
+
+static int anx7625_hdcp_key_probe(struct anx7625_data *ctx)
+{
+   int ret, val;
+   struct device *dev = &ctx->client->dev;
+   u8 ident[32];
+
+   ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+   FLASH_ADDR_HIGH, 0x91);
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+FLASH_ADDR_LOW, 0xA0);
+   if (ret < 0) {
+   DRM_DEV_ERROR(dev, "IO error : set key flash address.\n");
+   return ret;
+   }
+
+   ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+   FLASH_LEN_HIGH, (FLASH_BUF_LEN - 1) >> 8);
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+FLASH_LEN_LOW, (FLASH_BUF_LEN - 1) & 0xFF);
+   if (ret < 0) {
+   DRM_DEV_ERROR(dev, "IO error : set key flash len.\n");
+   return ret;
+   }
+
+   ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+   R_FLASH_RW_CTRL, FLASH_READ);
+   ret |= readx_poll_timeout(anx7625_read_flash_status,
+ ctx, val,
+ ((val & FLASH_DONE) || (val < 0)),
+ 2000,
+ 2000 * 150);
+   if (ret) {
+   DRM_DEV_ERROR(dev, "flash read access fail!\n");
+   return -EIO;
+   }
+
+   ret = anx7625_reg_block_read(ctx, ctx->i2c.rx_p0_client,
+FLASH_BUF_BASE_ADDR,
+FLASH_BUF_LEN, ident);
+   if (ret < 0) {
+   DRM_DEV_ERROR(dev, "read flash data fail!\n");
+   return -EIO;
+   }
+
+   if (ident[29] == 0xFF && ident[30] == 0xFF && ident[31] == 0xFF)
+   return -EINVAL;
+
+   return 0;
+}
+
+static int anx7625_hdcp_setting(struct anx7625_data *ctx)
+{
+   u8 bcap;
+   int ret;
+   struct device *dev = &ctx->client->dev;
+
+   ret = anx7625_hdcp_key_probe(ctx);
+   if (ret) {
+   DRM_DEV_DEBUG_DRIVER(dev, "disable HDCP by config\n");
+  

[PATCH v6 3/5] drm/bridge: anx7625: add MIPI DPI input feature support

2021-03-18 Thread Xin Ji
Add MIPI rx DPI input support.

Reported-by: kernel test robot 
Signed-off-by: Xin Ji 
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 245 --
 drivers/gpu/drm/bridge/analogix/anx7625.h |  18 +-
 2 files changed, 203 insertions(+), 60 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
b/drivers/gpu/drm/bridge/analogix/anx7625.c
index 04536cc7afe7..8c514b46d361 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -150,18 +150,18 @@ static int anx7625_write_and(struct anx7625_data *ctx,
return anx7625_reg_write(ctx, client, offset, (val & (mask)));
 }
 
-static int anx7625_write_and_or(struct anx7625_data *ctx,
-   struct i2c_client *client,
-   u8 offset, u8 and_mask, u8 or_mask)
+static int anx7625_config_bit_matrix(struct anx7625_data *ctx)
 {
-   int val;
+   int i, ret;
 
-   val = anx7625_reg_read(ctx, client, offset);
-   if (val < 0)
-   return val;
+   ret = anx7625_write_or(ctx, ctx->i2c.tx_p2_client,
+  AUDIO_CONTROL_REGISTER, 0x80);
+   for (i = 0; i < 13; i++)
+   ret |= anx7625_reg_write(ctx, ctx->i2c.tx_p2_client,
+VIDEO_BIT_MATRIX_12 + i,
+0x18 + i);
 
-   return anx7625_reg_write(ctx, client,
-offset, (val & and_mask) | (or_mask));
+   return ret;
 }
 
 static int anx7625_read_ctrl_status_p0(struct anx7625_data *ctx)
@@ -219,38 +219,6 @@ static int anx7625_video_mute_control(struct anx7625_data 
*ctx,
return ret;
 }
 
-static int anx7625_config_audio_input(struct anx7625_data *ctx)
-{
-   struct device *dev = &ctx->client->dev;
-   int ret;
-
-   /* Channel num */
-   ret = anx7625_reg_write(ctx, ctx->i2c.tx_p2_client,
-   AUDIO_CHANNEL_STATUS_6, I2S_CH_2 << 5);
-
-   /* FS */
-   ret |= anx7625_write_and_or(ctx, ctx->i2c.tx_p2_client,
-   AUDIO_CHANNEL_STATUS_4,
-   0xf0, AUDIO_FS_48K);
-   /* Word length */
-   ret |= anx7625_write_and_or(ctx, ctx->i2c.tx_p2_client,
-   AUDIO_CHANNEL_STATUS_5,
-   0xf0, AUDIO_W_LEN_24_24MAX);
-   /* I2S */
-   ret |= anx7625_write_or(ctx, ctx->i2c.tx_p2_client,
-   AUDIO_CHANNEL_STATUS_6, I2S_SLAVE_MODE);
-   ret |= anx7625_write_and(ctx, ctx->i2c.tx_p2_client,
-AUDIO_CONTROL_REGISTER, ~TDM_TIMING_MODE);
-   /* Audio change flag */
-   ret |= anx7625_write_or(ctx, ctx->i2c.rx_p0_client,
-   AP_AV_STATUS, AP_AUDIO_CHG);
-
-   if (ret < 0)
-   DRM_DEV_ERROR(dev, "fail to config audio.\n");
-
-   return ret;
-}
-
 /* Reduction of fraction a/b */
 static void anx7625_reduction_of_a_fraction(unsigned long *a, unsigned long *b)
 {
@@ -410,7 +378,7 @@ static int anx7625_dsi_video_timing_config(struct 
anx7625_data *ctx)
ret |= anx7625_write_and(ctx, ctx->i2c.rx_p1_client,
MIPI_LANE_CTRL_0, 0xfc);
ret |= anx7625_write_or(ctx, ctx->i2c.rx_p1_client,
-   MIPI_LANE_CTRL_0, 3);
+   MIPI_LANE_CTRL_0, ctx->pdata.mipi_lanes - 1);
 
/* Htotal */
htotal = ctx->dt.hactive.min + ctx->dt.hfront_porch.min +
@@ -595,6 +563,76 @@ static int anx7625_dsi_config(struct anx7625_data *ctx)
return ret;
 }
 
+static int anx7625_api_dpi_config(struct anx7625_data *ctx)
+{
+   struct device *dev = &ctx->client->dev;
+   u16 freq = ctx->dt.pixelclock.min / 1000;
+   int ret;
+
+   /* configure pixel clock */
+   ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+   PIXEL_CLOCK_L, freq & 0xFF);
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+PIXEL_CLOCK_H, (freq >> 8));
+
+   /* set DPI mode */
+   /* set to DPI PLL module sel */
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client,
+MIPI_DIGITAL_PLL_9, 0x20);
+   /* power down MIPI */
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client,
+MIPI_LANE_CTRL_10, 0x08);
+   /* enable DPI mode */
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client,
+MIPI_DIGITAL_PLL_18, 0x1C);
+   /* set first edge */
+   ret |= anx7625_reg_write(ctx, ctx->i2c.tx_p2_client,
+VIDEO_CONTROL_0, 0x06);
+   if (ret < 0)
+   DRM_DEV_ERROR(dev, "IO error : dpi phy set failed.\n&

[PATCH v6 2/5] drm/bridge: anx7625: fix not correct return value

2021-03-18 Thread Xin Ji
At some time, the original code may return non zero value, force return 0
if operation finished.

Signed-off-by: Xin Ji 
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
b/drivers/gpu/drm/bridge/analogix/anx7625.c
index 65cc05982f82..04536cc7afe7 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -189,10 +189,10 @@ static int wait_aux_op_finish(struct anx7625_data *ctx)
   AP_AUX_CTRL_STATUS);
if (val < 0 || (val & 0x0F)) {
DRM_DEV_ERROR(dev, "aux status %02x\n", val);
-   val = -EIO;
+   return -EIO;
}
 
-   return val;
+   return 0;
 }
 
 static int anx7625_video_mute_control(struct anx7625_data *ctx,
-- 
2.25.1



[PATCH v6 1/5] dt-bindings:drm/bridge:anx7625:add vendor define flags

2021-03-18 Thread Xin Ji
Add 'bus-type' and 'data-lanes' define for port0. Define DP tx lane0,
lane1 swing register array define, and audio enable flag.

Signed-off-by: Xin Ji 
---
 .../display/bridge/analogix,anx7625.yaml  | 58 ++-
 1 file changed, 57 insertions(+), 1 deletion(-)

diff --git 
a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml 
b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
index c789784efe30..3f54d5876982 100644
--- a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
+++ b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
@@ -34,6 +34,26 @@ properties:
 description: used for reset chip control, RESET_N pin B7.
 maxItems: 1
 
+  analogix,lane0-swing:
+$ref: /schemas/types.yaml#/definitions/uint32-array
+minItems: 1
+maxItems: 20
+description:
+  an array of swing register setting for DP tx lane0 PHY, please don't
+  add this property, or contact vendor.
+
+  analogix,lane1-swing:
+$ref: /schemas/types.yaml#/definitions/uint32-array
+minItems: 1
+maxItems: 20
+description:
+  an array of swing register setting for DP tx lane1 PHY, please don't
+  add this property, or contact vendor.
+
+  analogix,audio-enable:
+type: boolean
+description: let the driver enable audio HDMI codec function or not.
+
   ports:
 $ref: /schemas/graph.yaml#/properties/ports
 
@@ -41,13 +61,43 @@ properties:
   port@0:
 $ref: /schemas/graph.yaml#/properties/port
 description:
-  Video port for MIPI DSI input.
+  MIPI DSI/DPI input.
+
+properties:
+  endpoint:
+$ref: /schemas/media/video-interfaces.yaml#
+type: object
+additionalProperties: false
+
+properties:
+  remote-endpoint: true
+  bus-type: true
+  data-lanes: true
+
+required:
+  - remote-endpoint
+
+required:
+  - endpoint
+
 
   port@1:
 $ref: /schemas/graph.yaml#/properties/port
 description:
   Video port for panel or connector.
 
+properties:
+  endpoint:
+$ref: /schemas/media/video-interfaces.yaml#
+type: object
+additionalProperties: false
+
+properties:
+  remote-endpoint: true
+
+required:
+  - remote-endpoint
+
 required:
   - port@0
   - port@1
@@ -73,6 +123,10 @@ examples:
 enable-gpios = <&pio 45 GPIO_ACTIVE_HIGH>;
 reset-gpios = <&pio 73 GPIO_ACTIVE_HIGH>;
 
+analogix,audio-enable;
+analogix,lane0-swing = <0x14 0x54 0x64 0x74 0x29 0x7b 0x77 0x5b>;
+analogix,lane1-swing = <0x14 0x54 0x64 0x74 0x29 0x7b 0x77 0x5b>;
+
 ports {
 #address-cells = <1>;
 #size-cells = <0>;
@@ -81,6 +135,8 @@ examples:
 reg = <0>;
 anx7625_in: endpoint {
 remote-endpoint = <&mipi_dsi>;
+bus-type = <5>;
+data-lanes = <0 1 2 3>;
 };
 };
 
-- 
2.25.1



[PATCH v6 0/5] Add MIPI rx DPI support

2021-03-18 Thread Xin Ji
Hi all, this patch series implement MIPI rx DPI feature. Please help to review.

This is the v6 version, any mistakes, please let me know,
I'll fix it in the next series.

Change history:
v6: Fix kernel robot compile warning

v5: Fix Rob Herring, Hsin-Yi, Robert Foss comments
 - Rebase code on the branch 'drm-misc-next', refer video-interfaces.yaml
 - Seprate HDCP function to a new patch
 - Fix driver not correctly get 'bus-type' 'data-lanes'
 - Add audio HDMI codec function support

v4: Fix Rob Herring comment
 - Rebase code on the branch 'drm-misc-next'
 - Change 'analogix,hdcp-support' type to boolean

v3: Fix Rob Herring, Dan Carpenter, Nicolas comment
 - Split the patch, fix not correct return data
 - Fix several coding format
 - Split DP tx swing register setting to two property
 - Add HDCP support vender flag
 - remove 'analogix,swing-setting' and 'analogix,mipi-dpi-in' property

v2: Fix Rob Herring comment
 - Fix yamllint warnings/errors in analogix,anx7625.yaml
 - Fix kernel robot compile warning

v1: initial MIPI rx DPI feature support


Xin Ji (5):
  dt-bindings:drm/bridge:anx7625:add vendor define flags
  drm/bridge: anx7625: fix not correct return value
  drm/bridge: anx7625: add MIPI DPI input feature support
  drm/bridge: anx7625: add HDCP support
  drm/bridge: anx7625: add HDMI audio function

 .../display/bridge/analogix,anx7625.yaml  |  58 +-
 drivers/gpu/drm/bridge/analogix/anx7625.c | 603 --
 drivers/gpu/drm/bridge/analogix/anx7625.h |  59 +-
 3 files changed, 667 insertions(+), 53 deletions(-)

-- 
2.25.1



Re: [PATCH v4 2/2] drm/bridge: anx7625: disable regulators when power off

2021-03-18 Thread Xin Ji
On Thu, Mar 18, 2021 at 12:26:25PM +0800, Hsin-Yi Wang wrote:
> On Wed, Feb 24, 2021 at 2:14 PM Hsin-Yi Wang  wrote:
> >
> > When suspending the driver, anx7625_power_standby() will be called to
> > turn off reset-gpios and enable-gpios. However, power supplies are not
> > disabled. To save power, the driver can get the power supply regulators
> > and turn off them in anx7625_power_standby().
> >
> > Signed-off-by: Hsin-Yi Wang 
> > Reviewed-by: Robert Foss 
> > ---
Hi Hsin-Yi, it's OK for me, please add my r-b.
Reviewed-by: Xin Ji 

Thanks,
Xin
> 
> Ping on the thread, thanks.
> 
> >  drivers/gpu/drm/bridge/analogix/anx7625.c | 34 +++
> >  drivers/gpu/drm/bridge/analogix/anx7625.h |  1 +
> >  2 files changed, 35 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
> > b/drivers/gpu/drm/bridge/analogix/anx7625.c
> > index 65cc05982f826..23283ba0c4f93 100644
> > --- a/drivers/gpu/drm/bridge/analogix/anx7625.c
> > +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
> > @@ -11,6 +11,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -875,12 +876,25 @@ static int sp_tx_edid_read(struct anx7625_data *ctx,
> >  static void anx7625_power_on(struct anx7625_data *ctx)
> >  {
> > struct device *dev = &ctx->client->dev;
> > +   int ret, i;
> >
> > if (!ctx->pdata.low_power_mode) {
> > DRM_DEV_DEBUG_DRIVER(dev, "not low power mode!\n");
> > return;
> > }
> >
> > +   for (i = 0; i < ARRAY_SIZE(ctx->pdata.supplies); i++) {
> > +   ret = regulator_enable(ctx->pdata.supplies[i].consumer);
> > +   if (ret < 0) {
> > +   DRM_DEV_DEBUG_DRIVER(dev, "cannot enable supply %d: 
> > %d\n",
> > +i, ret);
> > +   goto reg_err;
> > +   }
> > +   usleep_range(2000, 2100);
> > +   }
> > +
> > +   usleep_range(4000, 4100);
> > +
> > /* Power on pin enable */
> > gpiod_set_value(ctx->pdata.gpio_p_on, 1);
> > usleep_range(1, 11000);
> > @@ -889,11 +903,16 @@ static void anx7625_power_on(struct anx7625_data *ctx)
> > usleep_range(1, 11000);
> >
> > DRM_DEV_DEBUG_DRIVER(dev, "power on !\n");
> > +   return;
> > +reg_err:
> > +   for (--i; i >= 0; i--)
> > +   regulator_disable(ctx->pdata.supplies[i].consumer);
> >  }
> >
> >  static void anx7625_power_standby(struct anx7625_data *ctx)
> >  {
> > struct device *dev = &ctx->client->dev;
> > +   int ret;
> >
> > if (!ctx->pdata.low_power_mode) {
> > DRM_DEV_DEBUG_DRIVER(dev, "not low power mode!\n");
> > @@ -904,6 +923,12 @@ static void anx7625_power_standby(struct anx7625_data 
> > *ctx)
> > usleep_range(1000, 1100);
> > gpiod_set_value(ctx->pdata.gpio_p_on, 0);
> > usleep_range(1000, 1100);
> > +
> > +   ret = regulator_bulk_disable(ARRAY_SIZE(ctx->pdata.supplies),
> > +ctx->pdata.supplies);
> > +   if (ret < 0)
> > +   DRM_DEV_DEBUG_DRIVER(dev, "cannot disable supplies %d\n", 
> > ret);
> > +
> > DRM_DEV_DEBUG_DRIVER(dev, "power down\n");
> >  }
> >
> > @@ -1742,6 +1767,15 @@ static int anx7625_i2c_probe(struct i2c_client 
> > *client,
> > platform->client = client;
> > i2c_set_clientdata(client, platform);
> >
> > +   pdata->supplies[0].supply = "vdd10";
> > +   pdata->supplies[1].supply = "vdd18";
> > +   pdata->supplies[2].supply = "vdd33";
> > +   ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(pdata->supplies),
> > + pdata->supplies);
> > +   if (ret) {
> > +   DRM_DEV_ERROR(dev, "fail to get power supplies: %d\n", ret);
> > +   return ret;
> > +   }
> > anx7625_init_gpio(platform);
> >
> > atomic_set(&platform->power_status, 0);
> > diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.h 
> > b/drivers/gpu/drm/bridge/analogix/anx7625.h
> > index 193ad86c54503..e4a086b3a3d7b 100644
> > --- a/drivers/gpu/drm/bridge/analogix/anx7625.h
> > +++ b/drivers/gpu/drm/bridge/analogix/anx7625.h
> > @@ -350,6 +350,7 @@ struct s_edid_data {
> >  struct anx7625_platform_data {
> > struct gpio_desc *gpio_p_on;
> > struct gpio_desc *gpio_reset;
> > +   struct regulator_bulk_data supplies[3];
> > struct drm_bridge *panel_bridge;
> > int intp_irq;
> > u32 low_power_mode;
> > --
> > 2.30.1.766.gb4fecdf3b7-goog
> >


[PATCH v5 5/5] drm/bridge: anx7625: add HDMI audio function

2021-03-18 Thread Xin Ji
Add audio HDMI codec function support, enable it through device true flag
"analogix,audio-enable".

Signed-off-by: Xin Ji 
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 227 ++
 drivers/gpu/drm/bridge/analogix/anx7625.h |   5 +
 2 files changed, 232 insertions(+)

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
b/drivers/gpu/drm/bridge/analogix/anx7625.c
index 5e19170..f4653f2 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -30,6 +30,8 @@
 #include 
 #include 
 
+#include 
+
 #include 
 
 #include "anx7625.h"
@@ -150,6 +152,20 @@ static int anx7625_write_and(struct anx7625_data *ctx,
return anx7625_reg_write(ctx, client, offset, (val & (mask)));
 }
 
+static int anx7625_write_and_or(struct anx7625_data *ctx,
+   struct i2c_client *client,
+   u8 offset, u8 and_mask, u8 or_mask)
+{
+   int val;
+
+   val = anx7625_reg_read(ctx, client, offset);
+   if (val < 0)
+   return val;
+
+   return anx7625_reg_write(ctx, client,
+offset, (val & and_mask) | (or_mask));
+}
+
 static int anx7625_config_bit_matrix(struct anx7625_data *ctx)
 {
int i, ret;
@@ -1496,6 +1512,9 @@ static int anx7625_parse_dt(struct device *dev,
else
DRM_DEV_DEBUG_DRIVER(dev, "found MIPI DSI host node.\n");
 
+   if (of_property_read_bool(np, "analogix,audio-enable"))
+   pdata->audio_en = 1;
+
ret = drm_of_find_panel_or_bridge(np, 1, 0, &panel, NULL);
if (ret < 0) {
if (ret == -ENODEV)
@@ -1566,6 +1585,208 @@ static enum drm_connector_status 
anx7625_sink_detect(struct anx7625_data *ctx)
 connector_status_disconnected;
 }
 
+int anx7625_audio_hw_params(struct device *dev, void *data,
+   struct hdmi_codec_daifmt *fmt,
+   struct hdmi_codec_params *params)
+{
+   struct anx7625_data *ctx = dev_get_drvdata(dev);
+   int wl, ch, rate;
+   int ret = 0;
+
+   if (fmt->fmt != HDMI_DSP_A) {
+   DRM_DEV_ERROR(dev, "only supports DSP_A\n");
+   return -EINVAL;
+   }
+
+   DRM_DEV_DEBUG_DRIVER(dev, "setting %d Hz, %d bit, %d channels\n",
+params->sample_rate, params->sample_width,
+params->cea.channels);
+
+   ret |= anx7625_write_and_or(ctx, ctx->i2c.tx_p2_client,
+   AUDIO_CHANNEL_STATUS_6,
+   ~I2S_SLAVE_MODE,
+   TDM_SLAVE_MODE);
+
+   /* Word length */
+   switch (params->sample_width) {
+   case 16:
+   wl = AUDIO_W_LEN_16_20MAX;
+   break;
+   case 18:
+   wl = AUDIO_W_LEN_18_20MAX;
+   break;
+   case 20:
+   wl = AUDIO_W_LEN_20_20MAX;
+   break;
+   case 24:
+   wl = AUDIO_W_LEN_24_24MAX;
+   break;
+   default:
+   DRM_DEV_DEBUG_DRIVER(dev, "wordlength: %d bit not support",
+params->sample_width);
+   return -EINVAL;
+   }
+   ret |= anx7625_write_and_or(ctx, ctx->i2c.tx_p2_client,
+   AUDIO_CHANNEL_STATUS_5,
+   0xf0, wl);
+
+   /* Channel num */
+   switch (params->cea.channels) {
+   case 2:
+   ch = I2S_CH_2;
+   break;
+   case 4:
+   ch = TDM_CH_4;
+   break;
+   case 6:
+   ch = TDM_CH_6;
+   break;
+   case 8:
+   ch = TDM_CH_8;
+   break;
+   default:
+   DRM_DEV_DEBUG_DRIVER(dev, "channel number: %d not support",
+params->cea.channels);
+   return -EINVAL;
+   }
+   ret |= anx7625_write_and_or(ctx, ctx->i2c.tx_p2_client,
+  AUDIO_CHANNEL_STATUS_6, 0x1f, ch << 5);
+   if (ch > I2S_CH_2)
+   ret |= anx7625_write_or(ctx, ctx->i2c.tx_p2_client,
+   AUDIO_CHANNEL_STATUS_6, AUDIO_LAYOUT);
+   else
+   ret |= anx7625_write_and(ctx, ctx->i2c.tx_p2_client,
+   AUDIO_CHANNEL_STATUS_6, ~AUDIO_LAYOUT);
+
+   /* FS */
+   switch (params->sample_rate) {
+   case 32000:
+   rate = AUDIO_FS_32K;
+   break;
+   case 44100:
+   rate = AUDIO_FS_441K;
+   break;
+   case 48000:
+   rate = AUDIO_FS_48K;
+   break;
+   case 88200:
+   rate = AUDIO_FS_882K;
+

[PATCH v5 4/5] drm/bridge: anx7625: add HDCP support

2021-03-18 Thread Xin Ji
Add HDCP feature, enable HDCP function through chip internal key
and downstream's capability.

Signed-off-by: Xin Ji 
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 147 ++
 drivers/gpu/drm/bridge/analogix/anx7625.h |  36 
 2 files changed, 183 insertions(+)

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
b/drivers/gpu/drm/bridge/analogix/anx7625.c
index 5c9b801..5e19170 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -633,6 +633,150 @@ static int anx7625_dpi_config(struct anx7625_data *ctx)
return ret;
 }
 
+static int anx7625_aux_dpcd_read(struct anx7625_data *ctx,
+u8 addrh, u8 addrm, u8 addrl,
+u8 len, u8 *buf)
+{
+   struct device *dev = &ctx->client->dev;
+   int ret;
+   u8 cmd;
+
+   if (len > MAX_DPCD_BUFFER_SIZE) {
+   DRM_DEV_ERROR(dev, "exceed aux buffer len.\n");
+   return -E2BIG;
+   }
+
+   cmd = ((len - 1) << 4) | 0x09;
+
+   /* Set command and length */
+   ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+   AP_AUX_COMMAND, cmd);
+
+   /* Set aux access address */
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+AP_AUX_ADDR_7_0, addrl);
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+AP_AUX_ADDR_15_8, addrm);
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+AP_AUX_ADDR_19_16, addrh);
+
+   /* Enable aux access */
+   ret |= anx7625_write_or(ctx, ctx->i2c.rx_p0_client,
+   AP_AUX_CTRL_STATUS, AP_AUX_CTRL_OP_EN);
+
+   if (ret < 0) {
+   DRM_DEV_ERROR(dev, "cannot access aux related register.\n");
+   return -EIO;
+   }
+
+   usleep_range(2000, 2100);
+
+   ret = wait_aux_op_finish(ctx);
+   if (ret) {
+   DRM_DEV_ERROR(dev, "aux IO error: wait aux op finish.\n");
+   return ret;
+   }
+
+   ret = anx7625_reg_block_read(ctx, ctx->i2c.rx_p0_client,
+AP_AUX_BUFF_START, len, buf);
+   if (ret < 0) {
+   DRM_DEV_ERROR(dev, "read dpcd register failed\n");
+   return -EIO;
+   }
+
+   return 0;
+}
+
+static int anx7625_read_flash_status(struct anx7625_data *ctx)
+{
+   return anx7625_reg_read(ctx, ctx->i2c.rx_p0_client, R_RAM_CTRL);
+}
+
+static int anx7625_hdcp_key_probe(struct anx7625_data *ctx)
+{
+   int ret, val;
+   struct device *dev = &ctx->client->dev;
+   u8 ident[32];
+
+   ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+   FLASH_ADDR_HIGH, 0x91);
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+FLASH_ADDR_LOW, 0xA0);
+   if (ret < 0) {
+   DRM_DEV_ERROR(dev, "IO error : set key flash address.\n");
+   return ret;
+   }
+
+   ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+   FLASH_LEN_HIGH, (FLASH_BUF_LEN - 1) >> 8);
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+FLASH_LEN_LOW, (FLASH_BUF_LEN - 1) & 0xFF);
+   if (ret < 0) {
+   DRM_DEV_ERROR(dev, "IO error : set key flash len.\n");
+   return ret;
+   }
+
+   ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+   R_FLASH_RW_CTRL, FLASH_READ);
+   ret |= readx_poll_timeout(anx7625_read_flash_status,
+ ctx, val,
+ ((val & FLASH_DONE) || (val < 0)),
+ 2000,
+ 2000 * 150);
+   if (ret) {
+   DRM_DEV_ERROR(dev, "flash read access fail!\n");
+   return -EIO;
+   }
+
+   ret = anx7625_reg_block_read(ctx, ctx->i2c.rx_p0_client,
+FLASH_BUF_BASE_ADDR,
+FLASH_BUF_LEN, ident);
+   if (ret < 0) {
+   DRM_DEV_ERROR(dev, "read flash data fail!\n");
+   return -EIO;
+   }
+
+   if (ident[29] == 0xFF && ident[30] == 0xFF && ident[31] == 0xFF)
+   return -EINVAL;
+
+   return 0;
+}
+
+static int anx7625_hdcp_setting(struct anx7625_data *ctx)
+{
+   u8 bcap;
+   int ret;
+   struct device *dev = &ctx->client->dev;
+
+   ret = anx7625_hdcp_key_probe(ctx);
+   if (ret) {
+   DRM_DEV_DEBUG_DRIVER(dev, "disable HDCP by config\n");
+  

[PATCH v5 3/5] drm/bridge: anx7625: add MIPI DPI input feature support

2021-03-18 Thread Xin Ji
Add MIPI rx DPI input support.

Reported-by: kernel test robot 
Signed-off-by: Xin Ji 
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 243 ++
 drivers/gpu/drm/bridge/analogix/anx7625.h |  18 ++-
 2 files changed, 201 insertions(+), 60 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
b/drivers/gpu/drm/bridge/analogix/anx7625.c
index 04536cc..5c9b801 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -150,18 +150,18 @@ static int anx7625_write_and(struct anx7625_data *ctx,
return anx7625_reg_write(ctx, client, offset, (val & (mask)));
 }
 
-static int anx7625_write_and_or(struct anx7625_data *ctx,
-   struct i2c_client *client,
-   u8 offset, u8 and_mask, u8 or_mask)
+static int anx7625_config_bit_matrix(struct anx7625_data *ctx)
 {
-   int val;
+   int i, ret;
 
-   val = anx7625_reg_read(ctx, client, offset);
-   if (val < 0)
-   return val;
+   ret = anx7625_write_or(ctx, ctx->i2c.tx_p2_client,
+  AUDIO_CONTROL_REGISTER, 0x80);
+   for (i = 0; i < 13; i++)
+   ret |= anx7625_reg_write(ctx, ctx->i2c.tx_p2_client,
+VIDEO_BIT_MATRIX_12 + i,
+0x18 + i);
 
-   return anx7625_reg_write(ctx, client,
-offset, (val & and_mask) | (or_mask));
+   return ret;
 }
 
 static int anx7625_read_ctrl_status_p0(struct anx7625_data *ctx)
@@ -219,38 +219,6 @@ static int anx7625_video_mute_control(struct anx7625_data 
*ctx,
return ret;
 }
 
-static int anx7625_config_audio_input(struct anx7625_data *ctx)
-{
-   struct device *dev = &ctx->client->dev;
-   int ret;
-
-   /* Channel num */
-   ret = anx7625_reg_write(ctx, ctx->i2c.tx_p2_client,
-   AUDIO_CHANNEL_STATUS_6, I2S_CH_2 << 5);
-
-   /* FS */
-   ret |= anx7625_write_and_or(ctx, ctx->i2c.tx_p2_client,
-   AUDIO_CHANNEL_STATUS_4,
-   0xf0, AUDIO_FS_48K);
-   /* Word length */
-   ret |= anx7625_write_and_or(ctx, ctx->i2c.tx_p2_client,
-   AUDIO_CHANNEL_STATUS_5,
-   0xf0, AUDIO_W_LEN_24_24MAX);
-   /* I2S */
-   ret |= anx7625_write_or(ctx, ctx->i2c.tx_p2_client,
-   AUDIO_CHANNEL_STATUS_6, I2S_SLAVE_MODE);
-   ret |= anx7625_write_and(ctx, ctx->i2c.tx_p2_client,
-AUDIO_CONTROL_REGISTER, ~TDM_TIMING_MODE);
-   /* Audio change flag */
-   ret |= anx7625_write_or(ctx, ctx->i2c.rx_p0_client,
-   AP_AV_STATUS, AP_AUDIO_CHG);
-
-   if (ret < 0)
-   DRM_DEV_ERROR(dev, "fail to config audio.\n");
-
-   return ret;
-}
-
 /* Reduction of fraction a/b */
 static void anx7625_reduction_of_a_fraction(unsigned long *a, unsigned long *b)
 {
@@ -410,7 +378,7 @@ static int anx7625_dsi_video_timing_config(struct 
anx7625_data *ctx)
ret |= anx7625_write_and(ctx, ctx->i2c.rx_p1_client,
MIPI_LANE_CTRL_0, 0xfc);
ret |= anx7625_write_or(ctx, ctx->i2c.rx_p1_client,
-   MIPI_LANE_CTRL_0, 3);
+   MIPI_LANE_CTRL_0, ctx->pdata.mipi_lanes - 1);
 
/* Htotal */
htotal = ctx->dt.hactive.min + ctx->dt.hfront_porch.min +
@@ -595,6 +563,76 @@ static int anx7625_dsi_config(struct anx7625_data *ctx)
return ret;
 }
 
+static int anx7625_api_dpi_config(struct anx7625_data *ctx)
+{
+   struct device *dev = &ctx->client->dev;
+   u16 freq = ctx->dt.pixelclock.min / 1000;
+   int ret;
+
+   /* configure pixel clock */
+   ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+   PIXEL_CLOCK_L, freq & 0xFF);
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+PIXEL_CLOCK_H, (freq >> 8));
+
+   /* set DPI mode */
+   /* set to DPI PLL module sel */
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client,
+MIPI_DIGITAL_PLL_9, 0x20);
+   /* power down MIPI */
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client,
+MIPI_LANE_CTRL_10, 0x08);
+   /* enable DPI mode */
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client,
+MIPI_DIGITAL_PLL_18, 0x1C);
+   /* set first edge */
+   ret |= anx7625_reg_write(ctx, ctx->i2c.tx_p2_client,
+VIDEO_CONTROL_0, 0x06);
+   if (ret < 0)
+   DRM_DEV_ERROR(dev, "IO error : dpi phy set failed.\n&

[PATCH v5 2/5] drm/bridge: anx7625: fix not correct return value

2021-03-18 Thread Xin Ji
At some time, the original code may return non zero value, force return 0
if operation finished.

Signed-off-by: Xin Ji 
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
b/drivers/gpu/drm/bridge/analogix/anx7625.c
index 65cc059..04536cc 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -189,10 +189,10 @@ static int wait_aux_op_finish(struct anx7625_data *ctx)
   AP_AUX_CTRL_STATUS);
if (val < 0 || (val & 0x0F)) {
DRM_DEV_ERROR(dev, "aux status %02x\n", val);
-   val = -EIO;
+   return -EIO;
}
 
-   return val;
+   return 0;
 }
 
 static int anx7625_video_mute_control(struct anx7625_data *ctx,
-- 
2.7.4



[PATCH v5 1/5] dt-bindings:drm/bridge:anx7625:add vendor define flags

2021-03-18 Thread Xin Ji
Add 'bus-type' and 'data-lanes' define for port0. Define DP tx lane0,
lane1 swing register array define, and audio enable flag.

Signed-off-by: Xin Ji 
---
 .../bindings/display/bridge/analogix,anx7625.yaml  | 58 +-
 1 file changed, 57 insertions(+), 1 deletion(-)

diff --git 
a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml 
b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
index c789784..3f54d58 100644
--- a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
+++ b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
@@ -34,6 +34,26 @@ properties:
 description: used for reset chip control, RESET_N pin B7.
 maxItems: 1
 
+  analogix,lane0-swing:
+$ref: /schemas/types.yaml#/definitions/uint32-array
+minItems: 1
+maxItems: 20
+description:
+  an array of swing register setting for DP tx lane0 PHY, please don't
+  add this property, or contact vendor.
+
+  analogix,lane1-swing:
+$ref: /schemas/types.yaml#/definitions/uint32-array
+minItems: 1
+maxItems: 20
+description:
+  an array of swing register setting for DP tx lane1 PHY, please don't
+  add this property, or contact vendor.
+
+  analogix,audio-enable:
+type: boolean
+description: let the driver enable audio HDMI codec function or not.
+
   ports:
 $ref: /schemas/graph.yaml#/properties/ports
 
@@ -41,13 +61,43 @@ properties:
   port@0:
 $ref: /schemas/graph.yaml#/properties/port
 description:
-  Video port for MIPI DSI input.
+  MIPI DSI/DPI input.
+
+properties:
+  endpoint:
+$ref: /schemas/media/video-interfaces.yaml#
+type: object
+additionalProperties: false
+
+properties:
+  remote-endpoint: true
+  bus-type: true
+  data-lanes: true
+
+required:
+  - remote-endpoint
+
+required:
+  - endpoint
+
 
   port@1:
 $ref: /schemas/graph.yaml#/properties/port
 description:
   Video port for panel or connector.
 
+properties:
+  endpoint:
+$ref: /schemas/media/video-interfaces.yaml#
+type: object
+additionalProperties: false
+
+properties:
+  remote-endpoint: true
+
+required:
+  - remote-endpoint
+
 required:
   - port@0
   - port@1
@@ -73,6 +123,10 @@ examples:
 enable-gpios = <&pio 45 GPIO_ACTIVE_HIGH>;
 reset-gpios = <&pio 73 GPIO_ACTIVE_HIGH>;
 
+analogix,audio-enable;
+analogix,lane0-swing = <0x14 0x54 0x64 0x74 0x29 0x7b 0x77 0x5b>;
+analogix,lane1-swing = <0x14 0x54 0x64 0x74 0x29 0x7b 0x77 0x5b>;
+
 ports {
 #address-cells = <1>;
 #size-cells = <0>;
@@ -81,6 +135,8 @@ examples:
 reg = <0>;
 anx7625_in: endpoint {
 remote-endpoint = <&mipi_dsi>;
+bus-type = <5>;
+data-lanes = <0 1 2 3>;
 };
 };
 
-- 
2.7.4



[PATCH v5 0/5] Add MIPI rx DPI support

2021-03-18 Thread Xin Ji
Hi all, this patch series implement MIPI rx DPI feature. Please help to review.

This is the v5 version, any mistakes, please let me know,
I'll fix it in the next series.

Change history:
v5: Fix Rob Herring, Hsin-Yi, Robert Foss comments
 - Rebase code on the branch 'drm-misc-next', refer video-interfaces.yaml
 - Seprate HDCP function to a new patch
 - Fix driver not correctly get 'bus-type' 'data-lanes'
 - Add audio HDMI codec function support

v4: Fix Rob Herring comment
 - Rebase code on the branch 'drm-misc-next'
 - Change 'analogix,hdcp-support' type to boolean

v3: Fix Rob Herring, Dan Carpenter, Nicolas comment
 - Split the patch, fix not correct return data
 - Fix several coding format
 - Split DP tx swing register setting to two property
 - Add HDCP support vender flag
 - remove 'analogix,swing-setting' and 'analogix,mipi-dpi-in' property

v2: Fix Rob Herring comment
 - Fix yamllint warnings/errors in analogix,anx7625.yaml
 - Fix kernel robot compile warning

v1: initial MIPI rx DPI feature support


Xin Ji (5):
  dt-bindings:drm/bridge:anx7625:add vendor define flags
  drm/bridge: anx7625: fix not correct return value
  drm/bridge: anx7625: add MIPI DPI input feature support
  drm/bridge: anx7625: add HDCP support
  drm/bridge: anx7625: add HDMI audio function

 .../bindings/display/bridge/analogix,anx7625.yaml  |  58 +-
 drivers/gpu/drm/bridge/analogix/anx7625.c  | 601 +++--
 drivers/gpu/drm/bridge/analogix/anx7625.h  |  59 +-
 3 files changed, 665 insertions(+), 53 deletions(-)

-- 
2.7.4



Re: [PATCH v4 3/3] drm/bridge: anx7625: add MIPI DPI input feature support

2021-02-24 Thread Xin Ji
Hi Hsin-Yi, thanks for the comment, I'll change it in the next serial.

As video-interfaces.yaml not exist in drm-next, I'm waiting for 5.12-rc1 to
apply to drm-misc, then I'll upstream patch v5.

Thanks,
Xin

On Wed, Feb 24, 2021 at 05:55:39PM +0800, Hsin-Yi Wang wrote:
> On Thu, Jan 28, 2021 at 11:10 AM Xin Ji  wrote:
> >
> > Add MIPI rx DPI input support
> >
> > Reported-by: kernel test robot 
> > Signed-off-by: Xin Ji 
> > ---
> >  drivers/gpu/drm/bridge/analogix/anx7625.c | 326 
> > --
> >  drivers/gpu/drm/bridge/analogix/anx7625.h |  20 +-
> >  2 files changed, 285 insertions(+), 61 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
> > b/drivers/gpu/drm/bridge/analogix/anx7625.c
> > index 04536cc..628ae43 100644
> > --- a/drivers/gpu/drm/bridge/analogix/anx7625.c
> > +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
> > @@ -150,18 +150,18 @@ static int anx7625_write_and(struct anx7625_data *ctx,
> > return anx7625_reg_write(ctx, client, offset, (val & (mask)));
> >  }
> >
> > -static int anx7625_write_and_or(struct anx7625_data *ctx,
> > -   struct i2c_client *client,
> > -   u8 offset, u8 and_mask, u8 or_mask)
> > +static int anx7625_config_bit_matrix(struct anx7625_data *ctx)
> >  {
> > -   int val;
> > +   int i, ret;
> >
> > -   val = anx7625_reg_read(ctx, client, offset);
> > -   if (val < 0)
> > -   return val;
> > +   ret = anx7625_write_or(ctx, ctx->i2c.tx_p2_client,
> > +  AUDIO_CONTROL_REGISTER, 0x80);
> > +   for (i = 0; i < 13; i++)
> > +   ret |= anx7625_reg_write(ctx, ctx->i2c.tx_p2_client,
> > +VIDEO_BIT_MATRIX_12 + i,
> > +0x18 + i);
> >
> > -   return anx7625_reg_write(ctx, client,
> > -offset, (val & and_mask) | (or_mask));
> > +   return ret;
> >  }
> >
> >  static int anx7625_read_ctrl_status_p0(struct anx7625_data *ctx)
> > @@ -195,6 +195,60 @@ static int wait_aux_op_finish(struct anx7625_data *ctx)
> > return 0;
> >  }
> >
> > +static int anx7625_aux_dpcd_read(struct anx7625_data *ctx,
> > +u8 addrh, u8 addrm, u8 addrl,
> > +u8 len, u8 *buf)
> > +{
> > +   struct device *dev = &ctx->client->dev;
> > +   int ret;
> > +   u8 cmd;
> > +
> > +   if (len > MAX_DPCD_BUFFER_SIZE) {
> > +   DRM_DEV_ERROR(dev, "exceed aux buffer len.\n");
> > +   return -EINVAL;
> > +   }
> > +
> > +   cmd = ((len - 1) << 4) | 0x09;
> > +
> > +   /* Set command and length */
> > +   ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
> > +   AP_AUX_COMMAND, cmd);
> > +
> > +   /* Set aux access address */
> > +   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
> > +AP_AUX_ADDR_7_0, addrl);
> > +   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
> > +AP_AUX_ADDR_15_8, addrm);
> > +   ret |= anx7625_write_and(ctx, ctx->i2c.rx_p0_client,
> > +AP_AUX_ADDR_19_16, addrh);
> > +
> > +   /* Enable aux access */
> > +   ret |= anx7625_write_or(ctx, ctx->i2c.rx_p0_client,
> > +   AP_AUX_CTRL_STATUS, AP_AUX_CTRL_OP_EN);
> > +
> > +   if (ret < 0) {
> > +   DRM_DEV_ERROR(dev, "cannot access aux related register.\n");
> > +   return -EIO;
> > +   }
> > +
> > +   usleep_range(2000, 2100);
> > +
> > +   ret = wait_aux_op_finish(ctx);
> > +   if (ret) {
> > +   DRM_DEV_ERROR(dev, "aux IO error: wait aux op finish.\n");
> > +   return ret;
> > +   }
> > +
> > +   ret = anx7625_reg_block_read(ctx, ctx->i2c.rx_p0_client,
> > +AP_AUX_BUFF_START, len, buf);
> > +   if (ret < 0) {
> > +   DRM_DEV_ERROR(dev, "read dpcd register failed\n");
> > +   return -EIO;
> > +   }
> > +
> > +   return 0;
> > +}
> > +
> &g

Re: [PATCH] drm/dsi: Add _NO_ to MIPI_DSI_* flags disabling features

2021-02-17 Thread Xin Ji
Hi Nicolas,

On Thu, Feb 11, 2021 at 11:33:55AM +0800, Nicolas Boichat wrote:
> Many of the DSI flags have names opposite to their actual effects,
> e.g. MIPI_DSI_MODE_EOT_PACKET means that EoT packets will actually
> be disabled. Fix this by including _NO_ in the flag names, e.g.
> MIPI_DSI_MODE_NO_EOT_PACKET.

It is OK for anx7625.c part, Please add my r-b.

Reviewed-by: Xin Ji 

> 
> Signed-off-by: Nicolas Boichat 
> ---
> I considered adding _DISABLE_ instead, but that'd make the
> flag names a big too long.
> 
> Generated with:
> flag=MIPI_DSI_MODE_VIDEO_HFP; git grep $flag | cut -f1 -d':' | \
>   xargs -I{} sed -i -e "s/$flag/MIPI_DSI_MODE_VIDEO_NO_HFP/" {}
> flag=MIPI_DSI_MODE_VIDEO_HBP; git grep $flag | cut -f1 -d':' | \
>   xargs -I{} sed -i -e "s/$flag/MIPI_DSI_MODE_VIDEO_NO_HBP/" {}
> flag=MIPI_DSI_MODE_VIDEO_HSA; git grep $flag | cut -f1 -d':' | \
>   xargs -I{} sed -i -e "s/$flag/MIPI_DSI_MODE_VIDEO_NO_HSA/" {}
> flag=MIPI_DSI_MODE_EOT_PACKET; git grep $flag | cut -f1 -d':' | \
>   xargs -I{} sed -i -e "s/$flag/MIPI_DSI_MODE_NO_EOT_PACKET/" {}
> (then minor format changes)
> 
>  drivers/gpu/drm/bridge/adv7511/adv7533.c | 2 +-
>  drivers/gpu/drm/bridge/analogix/anx7625.c| 2 +-
>  drivers/gpu/drm/bridge/cdns-dsi.c| 4 ++--
>  drivers/gpu/drm/bridge/tc358768.c| 2 +-
>  drivers/gpu/drm/exynos/exynos_drm_dsi.c  | 8 
>  drivers/gpu/drm/mcde/mcde_dsi.c  | 2 +-
>  drivers/gpu/drm/mediatek/mtk_dsi.c   | 2 +-
>  drivers/gpu/drm/msm/dsi/dsi_host.c   | 8 
>  drivers/gpu/drm/panel/panel-asus-z00t-tm5p5-n35596.c | 2 +-
>  drivers/gpu/drm/panel/panel-dsi-cm.c | 2 +-
>  drivers/gpu/drm/panel/panel-elida-kd35t133.c | 2 +-
>  drivers/gpu/drm/panel/panel-khadas-ts050.c   | 2 +-
>  drivers/gpu/drm/panel/panel-leadtek-ltk050h3146w.c   | 2 +-
>  drivers/gpu/drm/panel/panel-leadtek-ltk500hd1829.c   | 2 +-
>  drivers/gpu/drm/panel/panel-novatek-nt35510.c| 2 +-
>  drivers/gpu/drm/panel/panel-osd-osd101t2587-53ts.c   | 2 +-
>  drivers/gpu/drm/panel/panel-samsung-s6d16d0.c| 2 +-
>  drivers/gpu/drm/panel/panel-samsung-s6e63j0x03.c | 2 +-
>  drivers/gpu/drm/panel/panel-samsung-s6e63m0-dsi.c| 2 +-
>  drivers/gpu/drm/panel/panel-samsung-s6e8aa0.c| 4 ++--
>  drivers/gpu/drm/panel/panel-sharp-ls043t1le01.c  | 2 +-
>  drivers/gpu/drm/panel/panel-simple.c | 2 +-
>  drivers/gpu/drm/panel/panel-sony-acx424akp.c | 2 +-
>  drivers/gpu/drm/panel/panel-xinpeng-xpp055c272.c | 2 +-
>  include/drm/drm_mipi_dsi.h   | 8 
>  25 files changed, 36 insertions(+), 36 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/adv7511/adv7533.c 
> b/drivers/gpu/drm/bridge/adv7511/adv7533.c
> index aa19d5a40e31..59d718bde8c4 100644
> --- a/drivers/gpu/drm/bridge/adv7511/adv7533.c
> +++ b/drivers/gpu/drm/bridge/adv7511/adv7533.c
> @@ -165,7 +165,7 @@ int adv7533_attach_dsi(struct adv7511 *adv)
>   dsi->lanes = adv->num_dsi_lanes;
>   dsi->format = MIPI_DSI_FMT_RGB888;
>   dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE |
> -   MIPI_DSI_MODE_EOT_PACKET | MIPI_DSI_MODE_VIDEO_HSE;
> +   MIPI_DSI_MODE_NO_EOT_PACKET | MIPI_DSI_MODE_VIDEO_HSE;
>  
>   ret = mipi_dsi_attach(dsi);
>   if (ret < 0) {
> diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
> b/drivers/gpu/drm/bridge/analogix/anx7625.c
> index 65cc05982f82..beecfe6bf359 100644
> --- a/drivers/gpu/drm/bridge/analogix/anx7625.c
> +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
> @@ -1334,7 +1334,7 @@ static int anx7625_attach_dsi(struct anx7625_data *ctx)
>   dsi->format = MIPI_DSI_FMT_RGB888;
>   dsi->mode_flags = MIPI_DSI_MODE_VIDEO   |
>   MIPI_DSI_MODE_VIDEO_SYNC_PULSE  |
> - MIPI_DSI_MODE_EOT_PACKET|
> + MIPI_DSI_MODE_NO_EOT_PACKET |
>   MIPI_DSI_MODE_VIDEO_HSE;
>  
>   if (mipi_dsi_attach(dsi) < 0) {
> diff --git a/drivers/gpu/drm/bridge/cdns-dsi.c 
> b/drivers/gpu/drm/bridge/cdns-dsi.c
> index 76373e31df92..34aa24269a57 100644
> --- a/drivers/gpu/drm/bridge/cdns-dsi.c
> +++ b/drivers/gpu/drm/bridge/cdns-dsi.c
> @@ -829,7 +829,7 @@ static void cdns_dsi_bridge_enable(struct drm_bridge 
> *bridge)
>   tmp = DIV_ROUND_UP(dsi_cfg.htotal, nlanes) -
> DIV_ROUND_UP(dsi_cfg.hsa, nlanes);
>  
> - if (!(output->dev->mode_flags & MIPI_DSI_MODE_EOT_PACKET))
> + if (!(output->

Re: [PATCH v4 3/3] drm/bridge: anx7625: add MIPI DPI input feature support

2021-02-17 Thread Xin Ji
On Fri, Feb 05, 2021 at 01:33:46PM +0100, Robert Foss wrote:
> Hey Xin,
Hi Robert Foss, thanks for the comment, I'll split this patch at this seria.
Thanks,
Xin
> 
> On Thu, 28 Jan 2021 at 04:12, Xin Ji  wrote:
> >
> > Add MIPI rx DPI input support
> >
> > Reported-by: kernel test robot 
> > Signed-off-by: Xin Ji 
> > ---
> >  drivers/gpu/drm/bridge/analogix/anx7625.c | 326 
> > --
> >  drivers/gpu/drm/bridge/analogix/anx7625.h |  20 +-
> >  2 files changed, 285 insertions(+), 61 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
> > b/drivers/gpu/drm/bridge/analogix/anx7625.c
> > index 04536cc..628ae43 100644
> > --- a/drivers/gpu/drm/bridge/analogix/anx7625.c
> > +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
> > @@ -150,18 +150,18 @@ static int anx7625_write_and(struct anx7625_data *ctx,
> > return anx7625_reg_write(ctx, client, offset, (val & (mask)));
> >  }
> >
> > -static int anx7625_write_and_or(struct anx7625_data *ctx,
> > -   struct i2c_client *client,
> > -   u8 offset, u8 and_mask, u8 or_mask)
> > +static int anx7625_config_bit_matrix(struct anx7625_data *ctx)
> >  {
> > -   int val;
> > +   int i, ret;
> >
> > -   val = anx7625_reg_read(ctx, client, offset);
> > -   if (val < 0)
> > -   return val;
> > +   ret = anx7625_write_or(ctx, ctx->i2c.tx_p2_client,
> > +  AUDIO_CONTROL_REGISTER, 0x80);
> > +   for (i = 0; i < 13; i++)
> > +   ret |= anx7625_reg_write(ctx, ctx->i2c.tx_p2_client,
> > +VIDEO_BIT_MATRIX_12 + i,
> > +0x18 + i);
> >
> > -   return anx7625_reg_write(ctx, client,
> > -offset, (val & and_mask) | (or_mask));
> > +   return ret;
> >  }
> >
> >  static int anx7625_read_ctrl_status_p0(struct anx7625_data *ctx)
> > @@ -195,6 +195,60 @@ static int wait_aux_op_finish(struct anx7625_data *ctx)
> > return 0;
> >  }
> >
> > +static int anx7625_aux_dpcd_read(struct anx7625_data *ctx,
> > +u8 addrh, u8 addrm, u8 addrl,
> > +u8 len, u8 *buf)
> > +{
> > +   struct device *dev = &ctx->client->dev;
> > +   int ret;
> > +   u8 cmd;
> > +
> > +   if (len > MAX_DPCD_BUFFER_SIZE) {
> > +   DRM_DEV_ERROR(dev, "exceed aux buffer len.\n");
> > +   return -EINVAL;
> > +   }
> > +
> > +   cmd = ((len - 1) << 4) | 0x09;
> > +
> > +   /* Set command and length */
> > +   ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
> > +   AP_AUX_COMMAND, cmd);
> > +
> > +   /* Set aux access address */
> > +   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
> > +AP_AUX_ADDR_7_0, addrl);
> > +   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
> > +AP_AUX_ADDR_15_8, addrm);
> > +   ret |= anx7625_write_and(ctx, ctx->i2c.rx_p0_client,
> > +AP_AUX_ADDR_19_16, addrh);
> > +
> > +   /* Enable aux access */
> > +   ret |= anx7625_write_or(ctx, ctx->i2c.rx_p0_client,
> > +   AP_AUX_CTRL_STATUS, AP_AUX_CTRL_OP_EN);
> > +
> > +   if (ret < 0) {
> > +   DRM_DEV_ERROR(dev, "cannot access aux related register.\n");
> > +   return -EIO;
> > +   }
> > +
> > +   usleep_range(2000, 2100);
> > +
> > +   ret = wait_aux_op_finish(ctx);
> > +   if (ret) {
> > +   DRM_DEV_ERROR(dev, "aux IO error: wait aux op finish.\n");
> > +   return ret;
> > +   }
> > +
> > +   ret = anx7625_reg_block_read(ctx, ctx->i2c.rx_p0_client,
> > +AP_AUX_BUFF_START, len, buf);
> > +   if (ret < 0) {
> > +   DRM_DEV_ERROR(dev, "read dpcd register failed\n");
> > +   return -EIO;
> > +   }
> > +
> > +   return 0;
> > +}
> > +
> >  static int anx7625_video_mute_control(struct anx7625_data *ctx,
> >   u8 status)
> >  {
> 

Re: [PATCH v4 1/3] dt-bindings:drm/bridge:anx7625:add vendor define flags

2021-02-17 Thread Xin Ji
Hi Rob Herring, thanks for the comments.

On Tue, Feb 09, 2021 at 01:30:10PM -0600, Rob Herring wrote:
> On Thu, Jan 28, 2021 at 11:08:26AM +0800, Xin Ji wrote:
> > Add 'bus-type' and 'data-lanes' define for port0, add HDCP support
> > flag and DP tx lane0 and lane1 swing register array define.
> > 
> > Signed-off-by: Xin Ji 
> > ---
> >  .../bindings/display/bridge/analogix,anx7625.yaml  | 54 
> > +-
> >  1 file changed, 53 insertions(+), 1 deletion(-)
> > 
> > diff --git 
> > a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml 
> > b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > index c789784..048deec 100644
> > --- a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > +++ b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > @@ -34,6 +34,24 @@ properties:
> >  description: used for reset chip control, RESET_N pin B7.
> >  maxItems: 1
> >  
> > +  analogix,lane0-swing:
> > +$ref: /schemas/types.yaml#/definitions/uint32-array
> > +maxItems: 20
> > +description:
> > +  an array of swing register setting for DP tx lane0 PHY, please don't
> > +  add this property, or contact vendor.
> > +
> > +  analogix,lane1-swing:
> > +$ref: /schemas/types.yaml#/definitions/uint32-array
> > +maxItems: 20
> > +description:
> > +  an array of swing register setting for DP tx lane1 PHY, please don't
> > +  add this property, or contact vendor.
> > +
> > +  analogix,hdcp-support:
> > +type: boolean
> > +description: indicate the DP tx HDCP support or not.
> 
> Please show the new properties in the example.
OK, I'll add it in the example.
> 
> > +
> >ports:
> >  $ref: /schemas/graph.yaml#/properties/ports
> >  
> > @@ -41,13 +59,45 @@ properties:
> >port@0:
> >  $ref: /schemas/graph.yaml#/properties/port
> >  description:
> > -  Video port for MIPI DSI input.
> > +  Video port for MIPI input.
> > +
> > +properties:
> > +  endpoint:
> > +type: object
> > +additionalProperties: false
> > +
> > +# Properties described in
> > +# Documentation/devicetree/bindings/media/video-interfaces.txt
> 
> Now video-interfaces.yaml which should have a $ref here. It's currently 
> in media tree and linux-next. Follow the examples there. You'll also 
> have to wait for 5.12-rc1 to apply to drm-misc.
OK.
> 
> > +properties:
> > +  remote-endpoint: true
> > +  bus-type: true
> > +  data-lanes: true
> > +
> > +required:
> > +  - remote-endpoint
> > +
> > +required:
> > +  - endpoint
> > +
> >  
> >port@1:
> >  $ref: /schemas/graph.yaml#/properties/port
> >  description:
> >Video port for panel or connector.
> >  
> > +properties:
> > +  endpoint:
> > +type: object
> > +additionalProperties: false
> > +
> > +# Properties described in
> > +# Documentation/devicetree/bindings/media/video-interfaces.txt
> > +properties:
> > +  remote-endpoint: true
> > +
> > +required:
> > +  - remote-endpoint
> > +
> >  required:
> >- port@0
> >- port@1
> > @@ -81,6 +131,8 @@ examples:
> >  reg = <0>;
> >  anx7625_in: endpoint {
> >  remote-endpoint = <&mipi_dsi>;
> > +bus-type = <5>;
> > +data-lanes = <0 1 2 3>;
> >  };
> >  };
> >  
> > -- 
> > 2.7.4
> > 


Re: [PATCH v4 2/3] drm/bridge: anx7625: fix not correct return value

2021-02-05 Thread Xin Ji
On Thu, Feb 04, 2021 at 01:28:30PM +0100, Robert Foss wrote:
> Hi Xin,
> 
> On Thu, 28 Jan 2021 at 04:12, Xin Ji  wrote:
> >
> > At some time, the original code may return non zero value, force return 0
> > if operation finished
> 
> Missing "." at end of line.
Hi Rob, OK, thanks, I'll add it in the next series.
Thanks,
Xin
> 
> Other than that, this patch looks fine. Feel free to add my r-b.
> Reviewed-by: Robert Foss 
> 
> >
> > Signed-off-by: Xin Ji 
> > ---
> >  drivers/gpu/drm/bridge/analogix/anx7625.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
> > b/drivers/gpu/drm/bridge/analogix/anx7625.c
> > index 65cc059..04536cc 100644
> > --- a/drivers/gpu/drm/bridge/analogix/anx7625.c
> > +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
> > @@ -189,10 +189,10 @@ static int wait_aux_op_finish(struct anx7625_data 
> > *ctx)
> >AP_AUX_CTRL_STATUS);
> > if (val < 0 || (val & 0x0F)) {
> > DRM_DEV_ERROR(dev, "aux status %02x\n", val);
> > -   val = -EIO;
> > +   return -EIO;
> > }
> >
> > -   return val;
> > +   return 0;
> >  }
> >
> >  static int anx7625_video_mute_control(struct anx7625_data *ctx,
> > --
> > 2.7.4
> >


Re: [PATCH v4 1/3] dt-bindings:drm/bridge:anx7625:add vendor define flags

2021-02-05 Thread Xin Ji
On Thu, Feb 04, 2021 at 01:38:36PM +0100, Robert Foss wrote:
> Hey Xin,
> 
> On Thu, 28 Jan 2021 at 04:10, Xin Ji  wrote:
> >
> > Add 'bus-type' and 'data-lanes' define for port0, add HDCP support
> > flag and DP tx lane0 and lane1 swing register array define.
> >
> > Signed-off-by: Xin Ji 
> > ---
> >  .../bindings/display/bridge/analogix,anx7625.yaml  | 54 
> > +-
> >  1 file changed, 53 insertions(+), 1 deletion(-)
> >
> > diff --git 
> > a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml 
> > b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > index c789784..048deec 100644
> > --- a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > +++ b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > @@ -34,6 +34,24 @@ properties:
> >  description: used for reset chip control, RESET_N pin B7.
> >  maxItems: 1
> >
> > +  analogix,lane0-swing:
> > +$ref: /schemas/types.yaml#/definitions/uint32-array
> > +maxItems: 20
> > +description:
> > +  an array of swing register setting for DP tx lane0 PHY, please don't
> > +  add this property, or contact vendor.
> > +
> > +  analogix,lane1-swing:
> > +$ref: /schemas/types.yaml#/definitions/uint32-array
> > +maxItems: 20
> > +description:
> > +  an array of swing register setting for DP tx lane1 PHY, please don't
> > +  add this property, or contact vendor.
> > +
> > +  analogix,hdcp-support:
> > +type: boolean
> > +description: indicate the DP tx HDCP support or not.
> > +
> >ports:
> >  $ref: /schemas/graph.yaml#/properties/ports
> >
> > @@ -41,13 +59,45 @@ properties:
> >port@0:
> >  $ref: /schemas/graph.yaml#/properties/port
> >  description:
> > -  Video port for MIPI DSI input.
> > +  Video port for MIPI input.
> 
> Maybe MIPI DSI/DPI input is more correct, since there are a lot of
> other MIPI standards.
Hi Rob, OK, I'll change it in the next series.
Thanks,
Xin
> 
> > +
> > +properties:
> > +  endpoint:
> > +type: object
> > +additionalProperties: false
> > +
> > +# Properties described in
> > +# Documentation/devicetree/bindings/media/video-interfaces.txt
> > +properties:
> > +  remote-endpoint: true
> > +  bus-type: true
> > +  data-lanes: true
> > +
> > +required:
> > +  - remote-endpoint
> > +
> > +required:
> > +  - endpoint
> > +
> >
> >port@1:
> >  $ref: /schemas/graph.yaml#/properties/port
> >  description:
> >Video port for panel or connector.
> >
> > +properties:
> > +  endpoint:
> > +type: object
> > +additionalProperties: false
> > +
> > +# Properties described in
> > +# Documentation/devicetree/bindings/media/video-interfaces.txt
> > +properties:
> > +  remote-endpoint: true
> > +
> > +required:
> > +  - remote-endpoint
> > +
> >  required:
> >- port@0
> >- port@1
> > @@ -81,6 +131,8 @@ examples:
> >  reg = <0>;
> >  anx7625_in: endpoint {
> >  remote-endpoint = <&mipi_dsi>;
> > +bus-type = <5>;
> > +data-lanes = <0 1 2 3>;
> >  };
> >  };
> >
> > --
> > 2.7.4
> >


Re: [PATCH] drm/bridge: anx7625: enable DSI EOTP

2021-02-05 Thread Xin Ji
On Fri, Feb 05, 2021 at 10:43:14AM +0100, Robert Foss wrote:
> On Thu, 4 Feb 2021 at 23:25, Nicolas Boichat  wrote:
> >
> > On Thu, Feb 4, 2021 at 8:59 PM Andrzej Hajda  wrote:
> > >
> > >
> > > W dniu 04.02.2021 o 13:34, Nicolas Boichat pisze:
> > > > On Thu, Feb 4, 2021 at 8:07 PM Robert Foss  
> > > > wrote:
> > > >> Hi Xin,
> > > >>
> > > >> Thanks for the patch.
> > > >>
> > > >> On Thu, 28 Jan 2021 at 12:17, Xin Ji  wrote:
> > > >>> Enable DSI EOTP feature for fixing some panel screen constance
> > > >>> shift issue.
> > > >>> Removing MIPI flag MIPI_DSI_MODE_EOT_PACKET to enable DSI EOTP.
> 
> Does "constance shift" have a typo? Should it be "constant shift"?
> 
> With that sorted out feel free to add my r-b.
> Reviewed-by: Robert Foss 
Hi Robert Foss, thanks, I'll correct it.
Thanks,
Xin
> 
> > > >> I don't think I quite understand how removing the
> > > >> MIPI_DSI_MODE_EOT_PACKET flag will cause DSI EOTP to be enabled. Could
> > > >> you extrapolate on this in the commit message?
> > > > That confused me as well, but it turns out that's how the flag is 
> > > > defined:
> > > > ```
> > > > /* disable EoT packets in HS mode */
> > > > #define MIPI_DSI_MODE_EOT_PACKET BIT(9)
> > > > ```
> > > > (https://protect2.fireeye.com/v1/url?k=5bd95ebd-044267fb-5bd8d5f2-0cc47a3003e8-ce9db8ea264d6901&q=1&e=900556dc-d199-4c18-9432-5c3465a98eae&u=https%3A%2F%2Felixir.bootlin.com%2Flinux%2Flatest%2Fsource%2Finclude%2Fdrm%2Fdrm_mipi_dsi.h%23L129)
> > > >
> > > > I'm almost tempted to put together a mass patch to rename all of these 
> > > > flags...
> > >
> > >
> > > Yes that would be good, many of these flags were just copy pasted from
> > > some hw datasheet, without good analysis how to adapt them to the 
> > > framework.
> >
> > I'll look into it (but that shouldn't block this patch).
> 
> Thanks for clearing this up Nicolas & Andrzej!


Re: [PATCH] drm/bridge: anx7625: enable DSI EOTP

2021-02-05 Thread Xin Ji
On Fri, Feb 05, 2021 at 12:30:45PM +0100, Robert Foss wrote:
> Hey Xin,
> 
> Thanks for the quick response. I think this is ok.
> 
> But going forward it is easier for maintainers to keep track of
> patches if they're submitted with a version tag. [PATCH] -> [PATCH v2]
> -> [PATCH v3] etc.
> 
> git send-email -v1
> git send-email -v2
> git send-email -v3
> 
> ^^^ does this for you
> 
> 
> Rob.
Hi Rob, thanks, I'll follow the rules in the next upstream.
Thanks,
xin
> 
> On Fri, 5 Feb 2021 at 12:14, Xin Ji  wrote:
> >
> > Enable DSI EOTP feature for fixing some panel screen constant shift issue.
> > Removing MIPI flag MIPI_DSI_MODE_EOT_PACKET to enable DSI EOTP.
> >
> > Reviewed-by: Robert Foss 
> > Signed-off-by: Xin Ji 
> > ---
> >  drivers/gpu/drm/bridge/analogix/anx7625.c | 1 -
> >  1 file changed, 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
> > b/drivers/gpu/drm/bridge/analogix/anx7625.c
> > index 65cc059..e31eeb1b 100644
> > --- a/drivers/gpu/drm/bridge/analogix/anx7625.c
> > +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
> > @@ -1334,7 +1334,6 @@ static int anx7625_attach_dsi(struct anx7625_data 
> > *ctx)
> > dsi->format = MIPI_DSI_FMT_RGB888;
> > dsi->mode_flags = MIPI_DSI_MODE_VIDEO   |
> > MIPI_DSI_MODE_VIDEO_SYNC_PULSE  |
> > -   MIPI_DSI_MODE_EOT_PACKET|
> > MIPI_DSI_MODE_VIDEO_HSE;
> >
> > if (mipi_dsi_attach(dsi) < 0) {
> > --
> > 2.7.4
> >


[PATCH] drm/bridge: anx7625: enable DSI EOTP

2021-02-05 Thread Xin Ji
Enable DSI EOTP feature for fixing some panel screen constant shift issue.
Removing MIPI flag MIPI_DSI_MODE_EOT_PACKET to enable DSI EOTP.

Reviewed-by: Robert Foss 
Signed-off-by: Xin Ji 
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
b/drivers/gpu/drm/bridge/analogix/anx7625.c
index 65cc059..e31eeb1b 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -1334,7 +1334,6 @@ static int anx7625_attach_dsi(struct anx7625_data *ctx)
dsi->format = MIPI_DSI_FMT_RGB888;
dsi->mode_flags = MIPI_DSI_MODE_VIDEO   |
MIPI_DSI_MODE_VIDEO_SYNC_PULSE  |
-   MIPI_DSI_MODE_EOT_PACKET|
MIPI_DSI_MODE_VIDEO_HSE;
 
if (mipi_dsi_attach(dsi) < 0) {
-- 
2.7.4



[PATCH] drm/bridge: anx7625: enable DSI EOTP

2021-01-28 Thread Xin Ji
Enable DSI EOTP feature for fixing some panel screen constance
shift issue.
Removing MIPI flag MIPI_DSI_MODE_EOT_PACKET to enable DSI EOTP.

Signed-off-by: Xin Ji 
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
b/drivers/gpu/drm/bridge/analogix/anx7625.c
index 65cc059..e31eeb1b 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -1334,7 +1334,6 @@ static int anx7625_attach_dsi(struct anx7625_data *ctx)
dsi->format = MIPI_DSI_FMT_RGB888;
dsi->mode_flags = MIPI_DSI_MODE_VIDEO   |
MIPI_DSI_MODE_VIDEO_SYNC_PULSE  |
-   MIPI_DSI_MODE_EOT_PACKET|
MIPI_DSI_MODE_VIDEO_HSE;
 
if (mipi_dsi_attach(dsi) < 0) {
-- 
2.7.4



[PATCH v4 3/3] drm/bridge: anx7625: add MIPI DPI input feature support

2021-01-27 Thread Xin Ji
Add MIPI rx DPI input support

Reported-by: kernel test robot 
Signed-off-by: Xin Ji 
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 326 --
 drivers/gpu/drm/bridge/analogix/anx7625.h |  20 +-
 2 files changed, 285 insertions(+), 61 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
b/drivers/gpu/drm/bridge/analogix/anx7625.c
index 04536cc..628ae43 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -150,18 +150,18 @@ static int anx7625_write_and(struct anx7625_data *ctx,
return anx7625_reg_write(ctx, client, offset, (val & (mask)));
 }
 
-static int anx7625_write_and_or(struct anx7625_data *ctx,
-   struct i2c_client *client,
-   u8 offset, u8 and_mask, u8 or_mask)
+static int anx7625_config_bit_matrix(struct anx7625_data *ctx)
 {
-   int val;
+   int i, ret;
 
-   val = anx7625_reg_read(ctx, client, offset);
-   if (val < 0)
-   return val;
+   ret = anx7625_write_or(ctx, ctx->i2c.tx_p2_client,
+  AUDIO_CONTROL_REGISTER, 0x80);
+   for (i = 0; i < 13; i++)
+   ret |= anx7625_reg_write(ctx, ctx->i2c.tx_p2_client,
+VIDEO_BIT_MATRIX_12 + i,
+0x18 + i);
 
-   return anx7625_reg_write(ctx, client,
-offset, (val & and_mask) | (or_mask));
+   return ret;
 }
 
 static int anx7625_read_ctrl_status_p0(struct anx7625_data *ctx)
@@ -195,6 +195,60 @@ static int wait_aux_op_finish(struct anx7625_data *ctx)
return 0;
 }
 
+static int anx7625_aux_dpcd_read(struct anx7625_data *ctx,
+u8 addrh, u8 addrm, u8 addrl,
+u8 len, u8 *buf)
+{
+   struct device *dev = &ctx->client->dev;
+   int ret;
+   u8 cmd;
+
+   if (len > MAX_DPCD_BUFFER_SIZE) {
+   DRM_DEV_ERROR(dev, "exceed aux buffer len.\n");
+   return -EINVAL;
+   }
+
+   cmd = ((len - 1) << 4) | 0x09;
+
+   /* Set command and length */
+   ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+   AP_AUX_COMMAND, cmd);
+
+   /* Set aux access address */
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+AP_AUX_ADDR_7_0, addrl);
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+AP_AUX_ADDR_15_8, addrm);
+   ret |= anx7625_write_and(ctx, ctx->i2c.rx_p0_client,
+AP_AUX_ADDR_19_16, addrh);
+
+   /* Enable aux access */
+   ret |= anx7625_write_or(ctx, ctx->i2c.rx_p0_client,
+   AP_AUX_CTRL_STATUS, AP_AUX_CTRL_OP_EN);
+
+   if (ret < 0) {
+   DRM_DEV_ERROR(dev, "cannot access aux related register.\n");
+   return -EIO;
+   }
+
+   usleep_range(2000, 2100);
+
+   ret = wait_aux_op_finish(ctx);
+   if (ret) {
+   DRM_DEV_ERROR(dev, "aux IO error: wait aux op finish.\n");
+   return ret;
+   }
+
+   ret = anx7625_reg_block_read(ctx, ctx->i2c.rx_p0_client,
+AP_AUX_BUFF_START, len, buf);
+   if (ret < 0) {
+   DRM_DEV_ERROR(dev, "read dpcd register failed\n");
+   return -EIO;
+   }
+
+   return 0;
+}
+
 static int anx7625_video_mute_control(struct anx7625_data *ctx,
  u8 status)
 {
@@ -219,38 +273,6 @@ static int anx7625_video_mute_control(struct anx7625_data 
*ctx,
return ret;
 }
 
-static int anx7625_config_audio_input(struct anx7625_data *ctx)
-{
-   struct device *dev = &ctx->client->dev;
-   int ret;
-
-   /* Channel num */
-   ret = anx7625_reg_write(ctx, ctx->i2c.tx_p2_client,
-   AUDIO_CHANNEL_STATUS_6, I2S_CH_2 << 5);
-
-   /* FS */
-   ret |= anx7625_write_and_or(ctx, ctx->i2c.tx_p2_client,
-   AUDIO_CHANNEL_STATUS_4,
-   0xf0, AUDIO_FS_48K);
-   /* Word length */
-   ret |= anx7625_write_and_or(ctx, ctx->i2c.tx_p2_client,
-   AUDIO_CHANNEL_STATUS_5,
-   0xf0, AUDIO_W_LEN_24_24MAX);
-   /* I2S */
-   ret |= anx7625_write_or(ctx, ctx->i2c.tx_p2_client,
-   AUDIO_CHANNEL_STATUS_6, I2S_SLAVE_MODE);
-   ret |= anx7625_write_and(ctx, ctx->i2c.tx_p2_client,
-AUDIO_CONTROL_REGISTER, ~TDM_TIMING_MODE);
-   /* Audio change flag */
-   ret |= anx7625_write_or(ctx, ctx->i2c.rx_p0_client,
- 

[PATCH v4 2/3] drm/bridge: anx7625: fix not correct return value

2021-01-27 Thread Xin Ji
At some time, the original code may return non zero value, force return 0
if operation finished

Signed-off-by: Xin Ji 
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
b/drivers/gpu/drm/bridge/analogix/anx7625.c
index 65cc059..04536cc 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -189,10 +189,10 @@ static int wait_aux_op_finish(struct anx7625_data *ctx)
   AP_AUX_CTRL_STATUS);
if (val < 0 || (val & 0x0F)) {
DRM_DEV_ERROR(dev, "aux status %02x\n", val);
-   val = -EIO;
+   return -EIO;
}
 
-   return val;
+   return 0;
 }
 
 static int anx7625_video_mute_control(struct anx7625_data *ctx,
-- 
2.7.4



[PATCH v4 1/3] dt-bindings:drm/bridge:anx7625:add vendor define flags

2021-01-27 Thread Xin Ji
Add 'bus-type' and 'data-lanes' define for port0, add HDCP support
flag and DP tx lane0 and lane1 swing register array define.

Signed-off-by: Xin Ji 
---
 .../bindings/display/bridge/analogix,anx7625.yaml  | 54 +-
 1 file changed, 53 insertions(+), 1 deletion(-)

diff --git 
a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml 
b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
index c789784..048deec 100644
--- a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
+++ b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
@@ -34,6 +34,24 @@ properties:
 description: used for reset chip control, RESET_N pin B7.
 maxItems: 1
 
+  analogix,lane0-swing:
+$ref: /schemas/types.yaml#/definitions/uint32-array
+maxItems: 20
+description:
+  an array of swing register setting for DP tx lane0 PHY, please don't
+  add this property, or contact vendor.
+
+  analogix,lane1-swing:
+$ref: /schemas/types.yaml#/definitions/uint32-array
+maxItems: 20
+description:
+  an array of swing register setting for DP tx lane1 PHY, please don't
+  add this property, or contact vendor.
+
+  analogix,hdcp-support:
+type: boolean
+description: indicate the DP tx HDCP support or not.
+
   ports:
 $ref: /schemas/graph.yaml#/properties/ports
 
@@ -41,13 +59,45 @@ properties:
   port@0:
 $ref: /schemas/graph.yaml#/properties/port
 description:
-  Video port for MIPI DSI input.
+  Video port for MIPI input.
+
+properties:
+  endpoint:
+type: object
+additionalProperties: false
+
+# Properties described in
+# Documentation/devicetree/bindings/media/video-interfaces.txt
+properties:
+  remote-endpoint: true
+  bus-type: true
+  data-lanes: true
+
+required:
+  - remote-endpoint
+
+required:
+  - endpoint
+
 
   port@1:
 $ref: /schemas/graph.yaml#/properties/port
 description:
   Video port for panel or connector.
 
+properties:
+  endpoint:
+type: object
+additionalProperties: false
+
+# Properties described in
+# Documentation/devicetree/bindings/media/video-interfaces.txt
+properties:
+  remote-endpoint: true
+
+required:
+  - remote-endpoint
+
 required:
   - port@0
   - port@1
@@ -81,6 +131,8 @@ examples:
 reg = <0>;
 anx7625_in: endpoint {
 remote-endpoint = <&mipi_dsi>;
+bus-type = <5>;
+data-lanes = <0 1 2 3>;
 };
 };
 
-- 
2.7.4



[PATCH v4 0/3] Add MIPI rx DPI support

2021-01-27 Thread Xin Ji
Hi all, this patch series implement MIPI rx DPI feature. Please help to review.

This is the v4 version, any mistakes, please let me know,
I'll fix it in the next series.

Change history:
v4: Fix Rob Herring comment
 - Rebase code on the branch 'drm-misc-next'
 - Change 'analogix,hdcp-support' type to boolean

v3: Fix Rob Herring, Dan Carpenter, Nicolas comment
 - Split the patch, fix not correct return data
 - Fix several coding format
 - Split DP tx swing register setting to two property
 - Add HDCP support vender flag
 - remove 'analogix,swing-setting' and 'analogix,mipi-dpi-in' property

v2: Fix Rob Herring comment
 - Fix yamllint warnings/errors in analogix,anx7625.yaml
 - Fix kernel robot compile warning

v1: initial MIPI rx DPI feature support

Xin Ji (3):
  dt-bindings:drm/bridge:anx7625:add vendor define flags
  drm/bridge: anx7625: fix not correct return value
  drm/bridge: anx7625: add MIPI DPI input feature support

 .../bindings/display/bridge/analogix,anx7625.yaml  |  54 +++-
 drivers/gpu/drm/bridge/analogix/anx7625.c  | 330 +
 drivers/gpu/drm/bridge/analogix/anx7625.h  |  20 +-
 3 files changed, 340 insertions(+), 64 deletions(-)

-- 
2.7.4



Re: [PATCH v3 1/3] dt-bindings:drm/bridge:anx7625:add HDCP support flag and swing reg

2021-01-26 Thread Xin Ji
Hi Rob, thanks for the comments, I'll fix the issue on the next serial.
Thanks,
Xin

On Mon, Jan 25, 2021 at 09:41:43AM -0600, Rob Herring wrote:
> On Mon, Jan 25, 2021 at 07:12:21PM +0800, Xin Ji wrote:
> > Add 'bus-type' and 'data-lanes' define for port0, add HDCP support
> > flag and DP tx lane0 and lane1 swing register array define.
> > 
> > Signed-off-by: Xin Ji 
> > ---
> >  .../bindings/display/bridge/analogix,anx7625.yaml  | 57 
> > --
> >  1 file changed, 54 insertions(+), 3 deletions(-)
> > 
> > diff --git 
> > a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml 
> > b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > index 60585a4..3b1cbe0 100644
> > --- a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > +++ b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > @@ -34,23 +34,69 @@ properties:
> >  description: used for reset chip control, RESET_N pin B7.
> >  maxItems: 1
> >  
> > +  analogix,lane0-swing:
> > +$ref: /schemas/types.yaml#/definitions/uint32-array
> > +description:
> > +  an array of swing register setting for DP tx lane0 PHY, please don't
> > +  add this property, or contact vendor.
> > +
> > +  analogix,lane1-swing:
> > +$ref: /schemas/types.yaml#/definitions/uint32-array
> > +description:
> > +  an array of swing register setting for DP tx lane1 PHY, please don't
> > +  add this property, or contact vendor.
> > +
> > +  analogix,hdcp-support:
> > +$ref: /schemas/types.yaml#/definitions/uint32
> > +description: indicate the DP tx HDCP support or not.
> 
> Sounds like a boolean.
OK, I'll change it to boolean.
> 
> > +
> >ports:
> >  type: object
> > +additionalProperties: false
> >  
> >  properties:
> >port@0:
> >  type: object
> >  description:
> > -  Video port for MIPI DSI input.
> > +  Video port for MIPI input.
> 
> You're going to need to rebase this one drm-misc-next which uses the 
> graph schema now.
OK, I'll rebase it.
> 
> > +
> > +properties:
> > +  endpoint:
> > +type: object
> > +additionalProperties: false
> > +
> > +# Properties described in
> > +# Documentation/devicetree/bindings/media/video-interfaces.txt
> > +properties:
> > +  remote-endpoint: true
> > +  bus-type: true
> > +  data-lanes: true
> > +
> > +required:
> > +  - remote-endpoint
> > +
> > +required:
> > +  - endpoint
> >  
> >port@1:
> >  type: object
> >  description:
> >Video port for panel or connector.
> >  
> > +properties:
> > +  endpoint:
> > +type: object
> > +additionalProperties: false
> > +
> > +required:
> > +  - remote-endpoint
> > +
> > +required:
> > +  - endpoint
> > +
> >  required:
> > -- port@0
> > -- port@1
> > +  - port@0
> > +  - port@1
> >  
> >  required:
> >- compatible
> > @@ -73,6 +119,10 @@ examples:
> >  enable-gpios = <&pio 45 GPIO_ACTIVE_HIGH>;
> >  reset-gpios = <&pio 73 GPIO_ACTIVE_HIGH>;
> >  
> > +analogix,lane0-swing = <0x14 0x54 0x64 0x74 0x29 0x7b 0x77 
> > 0x5b>;
> > +analogix,lane1-swing = <0x14 0x54 0x64 0x74 0x29 0x7b 0x77 
> > 0x5b>;
> > +analogix,hdcp-support = <0>;
> > +
> >  ports {
> >  #address-cells = <1>;
> >  #size-cells = <0>;
> > @@ -81,6 +131,7 @@ examples:
> >  reg = <0>;
> >  anx7625_in: endpoint {
> >  remote-endpoint = <&mipi_dsi>;
> > +bus-type = <5>;
> >  };
> >  };
> >  
> > -- 
> > 2.7.4
> > 


Re: [PATCH v3 1/3] dt-bindings:drm/bridge:anx7625:add HDCP support flag and swing reg

2021-01-26 Thread Xin Ji
On Mon, Jan 25, 2021 at 08:51:35AM -0600, Rob Herring wrote:
> On Mon, 25 Jan 2021 19:12:21 +0800, Xin Ji wrote:
> > Add 'bus-type' and 'data-lanes' define for port0, add HDCP support
> > flag and DP tx lane0 and lane1 swing register array define.
> > 
> > Signed-off-by: Xin Ji 
> > ---
> >  .../bindings/display/bridge/analogix,anx7625.yaml  | 57 
> > --
> >  1 file changed, 54 insertions(+), 3 deletions(-)
> > 
> 
> My bot found errors running 'make dt_binding_check' on your patch:
Hi Rob, OK, I'll fix it in the next serial.
Thanks,
Xin
> 
> yamllint warnings/errors:
> 
> dtschema/dtc warnings/errors:
> /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.example.dt.yaml:
>  encoder@58: ports: '#address-cells', '#size-cells' do not match any of the 
> regexes: 'pinctrl-[0-9]+'
>   From schema: 
> /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.example.dt.yaml:
>  encoder@58: ports:port@1:endpoint: Additional properties are not allowed 
> ('remote-endpoint' was unexpected)
>   From schema: 
> /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> 
> See https://patchwork.ozlabs.org/patch/1431199
> 
> This check can fail if there are any dependencies. The base for a patch
> series is generally the most recent rc1.
> 
> If you already ran 'make dt_binding_check' and didn't see the above
> error(s), then make sure 'yamllint' is installed and dt-schema is up to
> date:
> 
> pip3 install dtschema --upgrade
> 
> Please check and re-submit.


[PATCH v3 2/3] drm/bridge: anx7625: fix not correct return value

2021-01-25 Thread Xin Ji
At some time, the original code may return non zero value, force return 0
if operation finished

Signed-off-by: Xin Ji 
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
b/drivers/gpu/drm/bridge/analogix/anx7625.c
index 65cc059..04536cc 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -189,10 +189,10 @@ static int wait_aux_op_finish(struct anx7625_data *ctx)
   AP_AUX_CTRL_STATUS);
if (val < 0 || (val & 0x0F)) {
DRM_DEV_ERROR(dev, "aux status %02x\n", val);
-   val = -EIO;
+   return -EIO;
}
 
-   return val;
+   return 0;
 }
 
 static int anx7625_video_mute_control(struct anx7625_data *ctx,
-- 
2.7.4



[PATCH v3 3/3] drm/bridge: anx7625: add MIPI DPI input feature support

2021-01-25 Thread Xin Ji
Add MIPI rx DPI input support

Reported-by: kernel test robot 
Signed-off-by: Xin Ji 
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 326 --
 drivers/gpu/drm/bridge/analogix/anx7625.h |  20 +-
 2 files changed, 285 insertions(+), 61 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
b/drivers/gpu/drm/bridge/analogix/anx7625.c
index 04536cc..c7fc92b 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -150,18 +150,18 @@ static int anx7625_write_and(struct anx7625_data *ctx,
return anx7625_reg_write(ctx, client, offset, (val & (mask)));
 }
 
-static int anx7625_write_and_or(struct anx7625_data *ctx,
-   struct i2c_client *client,
-   u8 offset, u8 and_mask, u8 or_mask)
+static int anx7625_config_bit_matrix(struct anx7625_data *ctx)
 {
-   int val;
+   int i, ret;
 
-   val = anx7625_reg_read(ctx, client, offset);
-   if (val < 0)
-   return val;
+   ret = anx7625_write_or(ctx, ctx->i2c.tx_p2_client,
+  AUDIO_CONTROL_REGISTER, 0x80);
+   for (i = 0; i < 13; i++)
+   ret |= anx7625_reg_write(ctx, ctx->i2c.tx_p2_client,
+VIDEO_BIT_MATRIX_12 + i,
+0x18 + i);
 
-   return anx7625_reg_write(ctx, client,
-offset, (val & and_mask) | (or_mask));
+   return ret;
 }
 
 static int anx7625_read_ctrl_status_p0(struct anx7625_data *ctx)
@@ -195,6 +195,60 @@ static int wait_aux_op_finish(struct anx7625_data *ctx)
return 0;
 }
 
+static int anx7625_aux_dpcd_read(struct anx7625_data *ctx,
+u8 addrh, u8 addrm, u8 addrl,
+u8 len, u8 *buf)
+{
+   struct device *dev = &ctx->client->dev;
+   int ret;
+   u8 cmd;
+
+   if (len > MAX_DPCD_BUFFER_SIZE) {
+   DRM_DEV_ERROR(dev, "exceed aux buffer len.\n");
+   return -EINVAL;
+   }
+
+   cmd = ((len - 1) << 4) | 0x09;
+
+   /* Set command and length */
+   ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+   AP_AUX_COMMAND, cmd);
+
+   /* Set aux access address */
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+AP_AUX_ADDR_7_0, addrl);
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+AP_AUX_ADDR_15_8, addrm);
+   ret |= anx7625_write_and(ctx, ctx->i2c.rx_p0_client,
+AP_AUX_ADDR_19_16, addrh);
+
+   /* Enable aux access */
+   ret |= anx7625_write_or(ctx, ctx->i2c.rx_p0_client,
+   AP_AUX_CTRL_STATUS, AP_AUX_CTRL_OP_EN);
+
+   if (ret < 0) {
+   DRM_DEV_ERROR(dev, "cannot access aux related register.\n");
+   return -EIO;
+   }
+
+   usleep_range(2000, 2100);
+
+   ret = wait_aux_op_finish(ctx);
+   if (ret) {
+   DRM_DEV_ERROR(dev, "aux IO error: wait aux op finish.\n");
+   return ret;
+   }
+
+   ret = anx7625_reg_block_read(ctx, ctx->i2c.rx_p0_client,
+AP_AUX_BUFF_START, len, buf);
+   if (ret < 0) {
+   DRM_DEV_ERROR(dev, "read dpcd register failed\n");
+   return -EIO;
+   }
+
+   return 0;
+}
+
 static int anx7625_video_mute_control(struct anx7625_data *ctx,
  u8 status)
 {
@@ -219,38 +273,6 @@ static int anx7625_video_mute_control(struct anx7625_data 
*ctx,
return ret;
 }
 
-static int anx7625_config_audio_input(struct anx7625_data *ctx)
-{
-   struct device *dev = &ctx->client->dev;
-   int ret;
-
-   /* Channel num */
-   ret = anx7625_reg_write(ctx, ctx->i2c.tx_p2_client,
-   AUDIO_CHANNEL_STATUS_6, I2S_CH_2 << 5);
-
-   /* FS */
-   ret |= anx7625_write_and_or(ctx, ctx->i2c.tx_p2_client,
-   AUDIO_CHANNEL_STATUS_4,
-   0xf0, AUDIO_FS_48K);
-   /* Word length */
-   ret |= anx7625_write_and_or(ctx, ctx->i2c.tx_p2_client,
-   AUDIO_CHANNEL_STATUS_5,
-   0xf0, AUDIO_W_LEN_24_24MAX);
-   /* I2S */
-   ret |= anx7625_write_or(ctx, ctx->i2c.tx_p2_client,
-   AUDIO_CHANNEL_STATUS_6, I2S_SLAVE_MODE);
-   ret |= anx7625_write_and(ctx, ctx->i2c.tx_p2_client,
-AUDIO_CONTROL_REGISTER, ~TDM_TIMING_MODE);
-   /* Audio change flag */
-   ret |= anx7625_write_or(ctx, ctx->i2c.rx_p0_client,
- 

[PATCH v3 1/3] dt-bindings:drm/bridge:anx7625:add HDCP support flag and swing reg

2021-01-25 Thread Xin Ji
Add 'bus-type' and 'data-lanes' define for port0, add HDCP support
flag and DP tx lane0 and lane1 swing register array define.

Signed-off-by: Xin Ji 
---
 .../bindings/display/bridge/analogix,anx7625.yaml  | 57 --
 1 file changed, 54 insertions(+), 3 deletions(-)

diff --git 
a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml 
b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
index 60585a4..3b1cbe0 100644
--- a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
+++ b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
@@ -34,23 +34,69 @@ properties:
 description: used for reset chip control, RESET_N pin B7.
 maxItems: 1
 
+  analogix,lane0-swing:
+$ref: /schemas/types.yaml#/definitions/uint32-array
+description:
+  an array of swing register setting for DP tx lane0 PHY, please don't
+  add this property, or contact vendor.
+
+  analogix,lane1-swing:
+$ref: /schemas/types.yaml#/definitions/uint32-array
+description:
+  an array of swing register setting for DP tx lane1 PHY, please don't
+  add this property, or contact vendor.
+
+  analogix,hdcp-support:
+$ref: /schemas/types.yaml#/definitions/uint32
+description: indicate the DP tx HDCP support or not.
+
   ports:
 type: object
+additionalProperties: false
 
 properties:
   port@0:
 type: object
 description:
-  Video port for MIPI DSI input.
+  Video port for MIPI input.
+
+properties:
+  endpoint:
+type: object
+additionalProperties: false
+
+# Properties described in
+# Documentation/devicetree/bindings/media/video-interfaces.txt
+properties:
+  remote-endpoint: true
+  bus-type: true
+  data-lanes: true
+
+required:
+  - remote-endpoint
+
+required:
+  - endpoint
 
   port@1:
 type: object
 description:
   Video port for panel or connector.
 
+properties:
+  endpoint:
+type: object
+additionalProperties: false
+
+required:
+  - remote-endpoint
+
+required:
+  - endpoint
+
 required:
-- port@0
-- port@1
+  - port@0
+  - port@1
 
 required:
   - compatible
@@ -73,6 +119,10 @@ examples:
 enable-gpios = <&pio 45 GPIO_ACTIVE_HIGH>;
 reset-gpios = <&pio 73 GPIO_ACTIVE_HIGH>;
 
+analogix,lane0-swing = <0x14 0x54 0x64 0x74 0x29 0x7b 0x77 0x5b>;
+analogix,lane1-swing = <0x14 0x54 0x64 0x74 0x29 0x7b 0x77 0x5b>;
+analogix,hdcp-support = <0>;
+
 ports {
 #address-cells = <1>;
 #size-cells = <0>;
@@ -81,6 +131,7 @@ examples:
 reg = <0>;
 anx7625_in: endpoint {
 remote-endpoint = <&mipi_dsi>;
+bus-type = <5>;
 };
 };
 
-- 
2.7.4



[PATCH v3 0/3] Add MIPI rx DPI support

2021-01-25 Thread Xin Ji
Hi all, this patch series implement MIPI rx DPI feature. Please help to review.

This is the v3 version, any mistakes, please let me know,
I'll fix it in the next series.

Change history:
v3: Fix Rob Herring, Dan Carpenter, Nicolas comments
 - Split the patch, fix not correct return data
 - Fix several coding format
 - Split DP tx swing register setting to two property
 - Add HDCP support vender flag
 - remove 'analogix,swing-setting' and 'analogix,mipi-dpi-in' property

v2: Fix Rob Herring comment
 - Fix yamllint warnings/errors in analogix,anx7625.yaml
 - Fix kernel robot compile warning

v1: initial MIPI rx DPI feature support


Xin Ji (3):
  dt-bindings:drm/bridge:anx7625:add HDCP support flag and swing reg
  drm/bridge: anx7625: fix not correct return value
  drm/bridge: anx7625: add MIPI DPI input feature support

 .../bindings/display/bridge/analogix,anx7625.yaml  |  57 +++-
 drivers/gpu/drm/bridge/analogix/anx7625.c  | 330 +
 drivers/gpu/drm/bridge/analogix/anx7625.h  |  20 +-
 3 files changed, 341 insertions(+), 66 deletions(-)

-- 
2.7.4



Re: [PATCH v2 1/2] dt-bindings: drm/bridge: anx7625: add DPI flag and swing setting

2021-01-24 Thread Xin Ji
On Sat, Jan 23, 2021 at 12:16:02AM +0800, Rob Herring wrote:
> On Tue, Jan 12, 2021 at 2:57 AM Xin Ji  wrote:
> >
> > Hi Rob Herring, thanks for the comments.
> >
> > On Mon, Jan 11, 2021 at 04:14:35PM -0600, Rob Herring wrote:
> > > On Thu, Dec 31, 2020 at 10:21:12AM +0800, Xin Ji wrote:
> > > > Add DPI flag for distinguish MIPI input signal type, DSI or DPI. Add
> > > > swing setting for adjusting DP tx PHY swing
> > > >
> > > > Signed-off-by: Xin Ji 
> > > > ---
> > > >  .../bindings/display/bridge/analogix,anx7625.yaml  | 25 
> > > > --
> > > >  1 file changed, 23 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git 
> > > > a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > > >  
> > > > b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > > > index 60585a4..4eb0ea3 100644
> > > > --- 
> > > > a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > > > +++ 
> > > > b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > > > @@ -34,6 +34,16 @@ properties:
> > > >  description: used for reset chip control, RESET_N pin B7.
> > > >  maxItems: 1
> > > >
> > > > +  analogix,swing-setting:
> > > > +type: uint8-array
> > >
> > > Humm, this should have be rejected by the meta-schema.
> > We needs define an array to adjust DP tx PHY swing, the developer hopes 
> > these
> > settings are changeable, so I moved the register data to DT. Can you
> > give me some suggestion if it is rejected by the meta-schema?
> > >
> > > > +$ref: /schemas/types.yaml#/definitions/uint32-array
> > >
> > > This is how types are defined other than boolean or nodes (object).
> > >
> > > > +description: an array of swing register setting for DP tx PHY
> > > > +
> > > > +  analogix,mipi-dpi-in:
> > > > +type: int
> > > > +$ref: /schemas/types.yaml#/definitions/uint32
> > > > +description: indicate the MIPI rx signal type is DPI or DSI
> > >
> > > Why does this need to be in DT, you should be able to determine this
> > > based on what you are connected to.
> > As the anx7625 can receive MIPI DSI and DPI data (depends on hardware
> > implement, we have a project which have two anx7625, one is DSI input,
> > the other is DPI input), we needs to let driver know what kind of MIPI
> > rx signal input. And there is no other way to tell driver the MIPI rx
> > signal type, we needs define this flag.
> 
> That's only true if what's driving the output is a single h/w block
> that can drive either. But typically you have 2 blocks: an LCD
> controller driving parallel signals and a DSI controller in front of
> it doing parallel to DSI conversion. The anx7625 would be connected to
> the LCD controller or DSI controller via the graph binding depending
> on the h/w connection.
> 
> However, if you do need this, then let's extend video-interfaces.yaml
> 'bus-type' to include DSI (it already has parallel).
> 
> Rob
Hi Rob, thanks, I'll add 'bus-type' in the next version.
Thanks,
Xin


Re: [PATCH v2 1/2] dt-bindings: drm/bridge: anx7625: add DPI flag and swing setting

2021-01-22 Thread Xin Ji
On Wed, Jan 20, 2021 at 04:57:56PM +0800, Nicolas Boichat wrote:
> On Tue, Jan 12, 2021 at 4:59 PM Xin Ji  wrote:
> >
> > Hi Rob Herring, thanks for the comments.
> >
> > On Mon, Jan 11, 2021 at 04:14:35PM -0600, Rob Herring wrote:
> > > On Thu, Dec 31, 2020 at 10:21:12AM +0800, Xin Ji wrote:
> > > > Add DPI flag for distinguish MIPI input signal type, DSI or DPI. Add
> > > > swing setting for adjusting DP tx PHY swing
> > > >
> > > > Signed-off-by: Xin Ji 
> > > > ---
> > > >  .../bindings/display/bridge/analogix,anx7625.yaml  | 25 
> > > > --
> > > >  1 file changed, 23 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git 
> > > > a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > > >  
> > > > b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > > > index 60585a4..4eb0ea3 100644
> > > > --- 
> > > > a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > > > +++ 
> > > > b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > > > @@ -34,6 +34,16 @@ properties:
> > > >  description: used for reset chip control, RESET_N pin B7.
> > > >  maxItems: 1
> > > >
> > > > +  analogix,swing-setting:
> > > > +type: uint8-array
> > >
> > > Humm, this should have be rejected by the meta-schema.
> > We needs define an array to adjust DP tx PHY swing, the developer hopes 
> > these
> > settings are changeable, so I moved the register data to DT. Can you
> > give me some suggestion if it is rejected by the meta-schema?
> > >
> > > > +$ref: /schemas/types.yaml#/definitions/uint32-array
> > >
> > > This is how types are defined other than boolean or nodes (object).
> > >
> > > > +description: an array of swing register setting for DP tx PHY
> > > > +
> > > > +  analogix,mipi-dpi-in:
> > > > +type: int
> > > > +$ref: /schemas/types.yaml#/definitions/uint32
> > > > +description: indicate the MIPI rx signal type is DPI or DSI
> > >
> > > Why does this need to be in DT, you should be able to determine this
> > > based on what you are connected to.
> > As the anx7625 can receive MIPI DSI and DPI data (depends on hardware
> > implement, we have a project which have two anx7625, one is DSI input,
> > the other is DPI input), we needs to let driver know what kind of MIPI
> > rx signal input. And there is no other way to tell driver the MIPI rx
> > signal type, we needs define this flag.
> > >
> > > > +
> > > >ports:
> > > >  type: object
> > > >
> > > > @@ -49,8 +59,8 @@ properties:
> > > >Video port for panel or connector.
> > > >
> > > >  required:
> > > > -- port@0
> > > > -- port@1
> > > > +  - port@0
> > > > +  - port@1
> > > >
> > > >  required:
> > > >- compatible
> > > > @@ -72,6 +82,17 @@ examples:
> > > >  reg = <0x58>;
> > > >  enable-gpios = <&pio 45 GPIO_ACTIVE_HIGH>;
> > > >  reset-gpios = <&pio 73 GPIO_ACTIVE_HIGH>;
> > > > +analogix,swing-setting = <0x00 0x14>, <0x01 0x54>,
> > > > +<0x02 0x64>, <0x03 0x74>, <0x04 0x29>,
> > > > +<0x05 0x7b>, <0x06 0x77>, <0x07 0x5b>,
> > > > +<0x08 0x7f>, <0x0c 0x20>, <0x0d 0x60>,
> > > > +<0x10 0x60>, <0x12 0x40>, <0x13 0x60>,
> > > > +<0x14 0x14>, <0x15 0x54>, <0x16 0x64>,
> > > > +<0x17 0x74>, <0x18 0x29>, <0x19 0x7b>,
> > > > +<0x1a 0x77>, <0x1b 0x5b>, <0x1c 0x7f>,
> > > > +<0x20 0x20>, <0x21 0x60>, <0x24 0x60>,
> > > > +<0x26 0x40>, <0x27 0x60>;
> > >
> > > This is a matrix, which is different from an array type.
> > OK, I'll change to array if this vendor define has been accepted.
> 
> I also wonder if we want to split the parameters per lane, and simply
> have a flat array (instead of reg/value pairs like you have now).
> 
> Registers 0x00 to 0x13 have to do with Lane 0 (and 0x14 to 0x27 with
> Lane 1): you can almost tell from the example values, they repeat. I'm
> not sure if there's any value splitting those further (I don't think
> anybody will be able to tune those without ANX's help).
> 
> So, maybe something like:
> anx,swing-setting = <<[reg values for lane 0]>, <[reg values for lane 1]>>
> where <[reg values for lane 0]> would be something like <0x14, 0x54,
> 0x64, ...> (that is, all the values between 0x00 and 0x13).
Hi Nicolas, it is a good way, 0x00 to 0x13 for lane0, 0x14 to 0x27 for lane1.
I'll split the parameters per lane.

Thanks,
Xin
> 
> > >
> > > > +analogix,mipi-dpi-in = <0>;
> > > >
> > > >  ports {
> > > >  #address-cells = <1>;
> > > > --
> > > > 2.7.4
> > > >


Re: [PATCH v2 1/2] dt-bindings: drm/bridge: anx7625: add DPI flag and swing setting

2021-01-12 Thread Xin Ji
Hi Rob Herring, thanks for the comments.

On Mon, Jan 11, 2021 at 04:14:35PM -0600, Rob Herring wrote:
> On Thu, Dec 31, 2020 at 10:21:12AM +0800, Xin Ji wrote:
> > Add DPI flag for distinguish MIPI input signal type, DSI or DPI. Add
> > swing setting for adjusting DP tx PHY swing
> > 
> > Signed-off-by: Xin Ji 
> > ---
> >  .../bindings/display/bridge/analogix,anx7625.yaml  | 25 
> > --
> >  1 file changed, 23 insertions(+), 2 deletions(-)
> > 
> > diff --git 
> > a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml 
> > b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > index 60585a4..4eb0ea3 100644
> > --- a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > +++ b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > @@ -34,6 +34,16 @@ properties:
> >  description: used for reset chip control, RESET_N pin B7.
> >  maxItems: 1
> >  
> > +  analogix,swing-setting:
> > +type: uint8-array
> 
> Humm, this should have be rejected by the meta-schema.
We needs define an array to adjust DP tx PHY swing, the developer hopes these
settings are changeable, so I moved the register data to DT. Can you
give me some suggestion if it is rejected by the meta-schema?
> 
> > +$ref: /schemas/types.yaml#/definitions/uint32-array
> 
> This is how types are defined other than boolean or nodes (object).
> 
> > +description: an array of swing register setting for DP tx PHY
> > +
> > +  analogix,mipi-dpi-in:
> > +type: int
> > +$ref: /schemas/types.yaml#/definitions/uint32
> > +description: indicate the MIPI rx signal type is DPI or DSI
> 
> Why does this need to be in DT, you should be able to determine this 
> based on what you are connected to.
As the anx7625 can receive MIPI DSI and DPI data (depends on hardware
implement, we have a project which have two anx7625, one is DSI input,
the other is DPI input), we needs to let driver know what kind of MIPI
rx signal input. And there is no other way to tell driver the MIPI rx
signal type, we needs define this flag.
> 
> > +
> >ports:
> >  type: object
> >  
> > @@ -49,8 +59,8 @@ properties:
> >Video port for panel or connector.
> >  
> >  required:
> > -- port@0
> > -- port@1
> > +  - port@0
> > +  - port@1
> >  
> >  required:
> >- compatible
> > @@ -72,6 +82,17 @@ examples:
> >  reg = <0x58>;
> >  enable-gpios = <&pio 45 GPIO_ACTIVE_HIGH>;
> >  reset-gpios = <&pio 73 GPIO_ACTIVE_HIGH>;
> > +analogix,swing-setting = <0x00 0x14>, <0x01 0x54>,
> > +<0x02 0x64>, <0x03 0x74>, <0x04 0x29>,
> > +<0x05 0x7b>, <0x06 0x77>, <0x07 0x5b>,
> > +<0x08 0x7f>, <0x0c 0x20>, <0x0d 0x60>,
> > +<0x10 0x60>, <0x12 0x40>, <0x13 0x60>,
> > +<0x14 0x14>, <0x15 0x54>, <0x16 0x64>,
> > +<0x17 0x74>, <0x18 0x29>, <0x19 0x7b>,
> > +<0x1a 0x77>, <0x1b 0x5b>, <0x1c 0x7f>,
> > +<0x20 0x20>, <0x21 0x60>, <0x24 0x60>,
> > +<0x26 0x40>, <0x27 0x60>;
> 
> This is a matrix, which is different from an array type.
OK, I'll change to array if this vendor define has been accepted.
> 
> > +analogix,mipi-dpi-in = <0>;
> >  
> >  ports {
> >  #address-cells = <1>;
> > -- 
> > 2.7.4
> > 


Re: [PATCH v2 2/2] drm/bridge: anx7625: add MIPI DPI input feature support

2021-01-12 Thread Xin Ji
On Tue, Jan 05, 2021 at 05:17:01PM +0300, Dan Carpenter wrote:
> On Thu, Dec 31, 2020 at 10:22:36AM +0800, Xin Ji wrote:
> >  static int anx7625_read_ctrl_status_p0(struct anx7625_data *ctx)
> >  {
> > return anx7625_reg_read(ctx, ctx->i2c.rx_p0_client, AP_AUX_CTRL_STATUS);
> > @@ -189,10 +203,64 @@ static int wait_aux_op_finish(struct anx7625_data 
> > *ctx)
> >AP_AUX_CTRL_STATUS);
> > if (val < 0 || (val & 0x0F)) {
> > DRM_DEV_ERROR(dev, "aux status %02x\n", val);
> > -   val = -EIO;
> > +   return -EIO;
> > }
> >  
> > -   return val;
> > +   return 0;
> 
> This s/val/0/ change seems like a bug fix.  Could you please send that
> as a separate patch at the start of the patch set?
Hi Dan Carpenter, OK, I'll send this as a separate patch.
Thanks,
Xin
> 
> > +}
> 
> regards,
> dan carpenter


Re: [PATCH v1 2/2] drm/bridge: anx7625: add MIPI DPI input feature support

2021-01-12 Thread Xin Ji
Hi Dan Carpenter, thanks for your comments, I'll fix it in the next serial.
Thanks,
Xin

On Mon, Jan 04, 2021 at 05:50:39PM +0300, Dan Carpenter wrote:
> On Fri, Dec 25, 2020 at 07:02:15PM +0800, Xin Ji wrote:
> > +static int anx7625_aux_dpcd_read(struct anx7625_data *ctx,
> > +u8 addrh, u8 addrm, u8 addrl,
> > +u8 len, u8 *buf)
> > +{
> > +   struct device *dev = &ctx->client->dev;
> > +   int ret;
> > +   u8 cmd;
> > +
> > +   if (len > MAX_DPCD_BUFFER_SIZE) {
> > +   DRM_DEV_ERROR(dev, "exceed aux buffer len.\n");
> > +   return -E2BIG;
> 
> s/E2BIG/EINVAL/.  -E2BIG means something else.
OK
> 
> > +   }
> > +
> > +   cmd = ((len - 1) << 4) | 0x09;
> > +
> > +   /* Set command and length */
> > +   ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
> > +   AP_AUX_COMMAND, cmd);
> > +
> > +   /* Set aux access address */
> > +   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
> > +AP_AUX_ADDR_7_0, addrl);
> > +   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
> > +AP_AUX_ADDR_15_8, addrm);
> > +   ret |= anx7625_write_and(ctx, ctx->i2c.rx_p0_client,
> > +AP_AUX_ADDR_19_16, addrh);
> > +
> > +   /* Enable aux access */
> > +   ret |= anx7625_write_or(ctx, ctx->i2c.rx_p0_client,
> > +   AP_AUX_CTRL_STATUS, AP_AUX_CTRL_OP_EN);
> > +
> > +   if (ret < 0) {
> > +   DRM_DEV_ERROR(dev, "cannot access aux related register.\n");
> > +   return -EIO;
> > +   }
> > +
> > +   usleep_range(2000, 2100);
> > +
> > +   ret = wait_aux_op_finish(ctx);
> > +   if (ret) {
> > +   DRM_DEV_ERROR(dev, "aux IO error: wait aux op finish.\n");
> > +   return ret;
> > +   }
> > +
> > +   ret = anx7625_reg_block_read(ctx, ctx->i2c.rx_p0_client,
> > +AP_AUX_BUFF_START, len, buf);
> > +   if (ret < 0) {
> > +   DRM_DEV_ERROR(dev, "read dpcd register failed\n");
> > +   return -EIO;
> > }
> >  
> > -   return val;
> > +   return 0;
> >  }
> >  
> >  static int anx7625_video_mute_control(struct anx7625_data *ctx,
> > @@ -595,6 +663,101 @@ static int anx7625_dsi_config(struct anx7625_data 
> > *ctx)
> > return ret;
> >  }
> >  
> > +static int anx7625_api_dpi_config(struct anx7625_data *ctx)
> > +{
> > +   struct device *dev = &ctx->client->dev;
> > +   u16 freq = ctx->dt.pixelclock.min / 1000;
> > +   int ret;
> > +
> > +   /* configure pixel clock */
> > +   ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
> > +   PIXEL_CLOCK_L, freq & 0xFF);
> > +   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
> > +PIXEL_CLOCK_H, (freq >> 8));
> > +
> > +   /* set DPI mode */
> > +   /* set to DPI PLL module sel */
> > +   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client,
> > +MIPI_DIGITAL_PLL_9, 0x20);
> > +   /* power down MIPI */
> > +   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client,
> > +MIPI_LANE_CTRL_10, 0x08);
> > +   /* enable DPI mode */
> > +   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client,
> > +MIPI_DIGITAL_PLL_18, 0x1C);
> > +   /* set first edge */
> > +   ret |= anx7625_reg_write(ctx, ctx->i2c.tx_p2_client,
> > +VIDEO_CONTROL_0, 0x06);
> > +   if (ret < 0)
> > +   DRM_DEV_ERROR(dev, "IO error : dpi phy set failed.\n");
> > +
> > +   return ret;
> > +}
> > +
> > +static int anx7625_dpi_config(struct anx7625_data *ctx)
> > +{
> > +   struct device *dev = &ctx->client->dev;
> > +   int ret;
> > +
> > +   DRM_DEV_DEBUG_DRIVER(dev, "config dpi\n");
> > +
> > +   /* DSC disable */
> > +   ret = anx7625_write_and(ctx, ctx->i2c.rx_p0_client,
> > +   R_DSC_CTRL_0, ~DSC_EN);
> > +   if (ret < 0) {
> > +   DRM_DEV_ERROR(dev, "IO error : disable dsc failed.\n");
> > +   return ret;
> > +   }
> > +
> > +   ret = anx7625_config_bit_matrix(ctx);
> > +   if (ret < 0) {
> > +   

[PATCH v2 2/2] drm/bridge: anx7625: add MIPI DPI input feature support

2020-12-30 Thread Xin Ji
Add MIPI rx DPI input support

Signed-off-by: Xin Ji 
Reported-by: kernel test robot 
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 344 --
 drivers/gpu/drm/bridge/analogix/anx7625.h |  24 ++-
 2 files changed, 348 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
b/drivers/gpu/drm/bridge/analogix/anx7625.c
index 65cc059..372b356 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -164,6 +164,20 @@ static int anx7625_write_and_or(struct anx7625_data *ctx,
 offset, (val & and_mask) | (or_mask));
 }
 
+static int anx7625_config_bit_matrix(struct anx7625_data *ctx)
+{
+   int i, ret;
+
+   ret = anx7625_reg_write(ctx, ctx->i2c.tx_p2_client,
+   AUDIO_CONTROL_REGISTER, 0x80);
+   for (i = 0; i < 13; i++)
+   ret |= anx7625_reg_write(ctx, ctx->i2c.tx_p2_client,
+VIDEO_BIT_MATRIX_12 + i,
+0x18 + i);
+
+   return ret;
+}
+
 static int anx7625_read_ctrl_status_p0(struct anx7625_data *ctx)
 {
return anx7625_reg_read(ctx, ctx->i2c.rx_p0_client, AP_AUX_CTRL_STATUS);
@@ -189,10 +203,64 @@ static int wait_aux_op_finish(struct anx7625_data *ctx)
   AP_AUX_CTRL_STATUS);
if (val < 0 || (val & 0x0F)) {
DRM_DEV_ERROR(dev, "aux status %02x\n", val);
-   val = -EIO;
+   return -EIO;
}
 
-   return val;
+   return 0;
+}
+
+static int anx7625_aux_dpcd_read(struct anx7625_data *ctx,
+u8 addrh, u8 addrm, u8 addrl,
+u8 len, u8 *buf)
+{
+   struct device *dev = &ctx->client->dev;
+   int ret;
+   u8 cmd;
+
+   if (len > MAX_DPCD_BUFFER_SIZE) {
+   DRM_DEV_ERROR(dev, "exceed aux buffer len.\n");
+   return -E2BIG;
+   }
+
+   cmd = ((len - 1) << 4) | 0x09;
+
+   /* Set command and length */
+   ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+   AP_AUX_COMMAND, cmd);
+
+   /* Set aux access address */
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+AP_AUX_ADDR_7_0, addrl);
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+AP_AUX_ADDR_15_8, addrm);
+   ret |= anx7625_write_and(ctx, ctx->i2c.rx_p0_client,
+AP_AUX_ADDR_19_16, addrh);
+
+   /* Enable aux access */
+   ret |= anx7625_write_or(ctx, ctx->i2c.rx_p0_client,
+   AP_AUX_CTRL_STATUS, AP_AUX_CTRL_OP_EN);
+
+   if (ret < 0) {
+   DRM_DEV_ERROR(dev, "cannot access aux related register.\n");
+   return -EIO;
+   }
+
+   usleep_range(2000, 2100);
+
+   ret = wait_aux_op_finish(ctx);
+   if (ret) {
+   DRM_DEV_ERROR(dev, "aux IO error: wait aux op finish.\n");
+   return ret;
+   }
+
+   ret = anx7625_reg_block_read(ctx, ctx->i2c.rx_p0_client,
+AP_AUX_BUFF_START, len, buf);
+   if (ret < 0) {
+   DRM_DEV_ERROR(dev, "read dpcd register failed\n");
+   return -EIO;
+   }
+
+   return 0;
 }
 
 static int anx7625_video_mute_control(struct anx7625_data *ctx,
@@ -595,6 +663,101 @@ static int anx7625_dsi_config(struct anx7625_data *ctx)
return ret;
 }
 
+static int anx7625_api_dpi_config(struct anx7625_data *ctx)
+{
+   struct device *dev = &ctx->client->dev;
+   u16 freq = ctx->dt.pixelclock.min / 1000;
+   int ret;
+
+   /* configure pixel clock */
+   ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+   PIXEL_CLOCK_L, freq & 0xFF);
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+PIXEL_CLOCK_H, (freq >> 8));
+
+   /* set DPI mode */
+   /* set to DPI PLL module sel */
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client,
+MIPI_DIGITAL_PLL_9, 0x20);
+   /* power down MIPI */
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client,
+MIPI_LANE_CTRL_10, 0x08);
+   /* enable DPI mode */
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client,
+MIPI_DIGITAL_PLL_18, 0x1C);
+   /* set first edge */
+   ret |= anx7625_reg_write(ctx, ctx->i2c.tx_p2_client,
+VIDEO_CONTROL_0, 0x06);
+   if (ret < 0)
+   DRM_DEV_ERROR(dev, "IO error : dpi phy set failed.\n");
+
+   return ret;
+}
+
+static int anx7625_dpi_

[PATCH v2 1/2] dt-bindings: drm/bridge: anx7625: add DPI flag and swing setting

2020-12-30 Thread Xin Ji
Add DPI flag for distinguish MIPI input signal type, DSI or DPI. Add
swing setting for adjusting DP tx PHY swing

Signed-off-by: Xin Ji 
---
 .../bindings/display/bridge/analogix,anx7625.yaml  | 25 --
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git 
a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml 
b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
index 60585a4..4eb0ea3 100644
--- a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
+++ b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
@@ -34,6 +34,16 @@ properties:
 description: used for reset chip control, RESET_N pin B7.
 maxItems: 1
 
+  analogix,swing-setting:
+type: uint8-array
+$ref: /schemas/types.yaml#/definitions/uint32-array
+description: an array of swing register setting for DP tx PHY
+
+  analogix,mipi-dpi-in:
+type: int
+$ref: /schemas/types.yaml#/definitions/uint32
+description: indicate the MIPI rx signal type is DPI or DSI
+
   ports:
 type: object
 
@@ -49,8 +59,8 @@ properties:
   Video port for panel or connector.
 
 required:
-- port@0
-- port@1
+  - port@0
+  - port@1
 
 required:
   - compatible
@@ -72,6 +82,17 @@ examples:
 reg = <0x58>;
 enable-gpios = <&pio 45 GPIO_ACTIVE_HIGH>;
 reset-gpios = <&pio 73 GPIO_ACTIVE_HIGH>;
+analogix,swing-setting = <0x00 0x14>, <0x01 0x54>,
+<0x02 0x64>, <0x03 0x74>, <0x04 0x29>,
+<0x05 0x7b>, <0x06 0x77>, <0x07 0x5b>,
+<0x08 0x7f>, <0x0c 0x20>, <0x0d 0x60>,
+<0x10 0x60>, <0x12 0x40>, <0x13 0x60>,
+<0x14 0x14>, <0x15 0x54>, <0x16 0x64>,
+<0x17 0x74>, <0x18 0x29>, <0x19 0x7b>,
+<0x1a 0x77>, <0x1b 0x5b>, <0x1c 0x7f>,
+<0x20 0x20>, <0x21 0x60>, <0x24 0x60>,
+<0x26 0x40>, <0x27 0x60>;
+analogix,mipi-dpi-in = <0>;
 
 ports {
 #address-cells = <1>;
-- 
2.7.4



[PATCH v2 0/2] Add MIPI rx DPI support

2020-12-30 Thread Xin Ji
Hi all, this patch series implement MIPI rx DPI feature. Please help to review.

This is the v2 version, any mistakes, please let me know,
I'll fix it in the next series.

Change history:
v2: Fix Rob Herring comment
 - Fix yamllint warnings/errors in analogix,anx7625.yaml
 - Fix kernel robot compiling warning

v1: initial MIPI rx DPI feature support

Xin Ji (2):
  dt-bindings: drm/bridge: anx7625: add DPI flag and swing setting
  drm/bridge: anx7625: add MIPI DPI input feature support

 .../bindings/display/bridge/analogix,anx7625.yaml  |  25 +-
 drivers/gpu/drm/bridge/analogix/anx7625.c  | 344 +++--
 drivers/gpu/drm/bridge/analogix/anx7625.h  |  24 +-
 3 files changed, 371 insertions(+), 22 deletions(-)

-- 
2.7.4



Re: [PATCH v1 1/2] dt-bindings: drm/bridge: anx7625: add DPI flag and swing setting

2020-12-29 Thread Xin Ji
On Tue, Dec 29, 2020 at 04:34:20PM +0200, Laurent Pinchart wrote:
> Hi Xin Ji,
> 
> On Tue, Dec 29, 2020 at 02:50:48PM +0800, Xin Ji wrote:
> > On Mon, Dec 28, 2020 at 05:08:56PM +0200, Laurent Pinchart wrote:
> > > On Fri, Dec 25, 2020 at 07:01:09PM +0800, Xin Ji wrote:
> > > > Add DPI flag for distinguish MIPI input signal type, DSI or DPI. Add
> > > > swing setting for adjusting DP tx PHY swing
> > > > 
> > > > Signed-off-by: Xin Ji 
> > > > ---
> > > >  .../bindings/display/bridge/analogix,anx7625.yaml | 19 
> > > > +++
> > > >  1 file changed, 19 insertions(+)
> > > > 
> > > > diff --git 
> > > > a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > > >  
> > > > b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > > > index 60585a4..34a7faf 100644
> > > > --- 
> > > > a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > > > +++ 
> > > > b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > > > @@ -34,6 +34,14 @@ properties:
> > > >  description: used for reset chip control, RESET_N pin B7.
> > > >  maxItems: 1
> > > >  
> > > > +  anx,swing-setting:
> > > > +$ref: /schemas/types.yaml#/definitions/uint32-array
> > > > +description: an array of swing register setting for DP tx PHY
> > > 
> > > Register values in DT are frowned upon.
> >
> > Hi Laurent Pinchart, as the different vendor has the different PCB layout,
> > it effects DP CTS test result, so they may need config DP tx Swing register
> > to adjust signal swing(the default swing setting is not satisfy for
> > every platform). If we move the config code to driver file, it must define
> > swing register setting for each vendor, so the DT is the best way. Do you
> > have any idea for it if you don't agree to add in DT.
> 
> If it depends on the PCB layout then it should indeed be in DT. What I
> wonder is if there would be a better way to specify the data than
> register values. The ANX7625 datasheet isn't public, so there's
> effectively no way for someone to write a device tree compliant with
> this binding only with the information contained here. Reviewing the
> bindings is equally difficult. It would be best if this property instead
> contained information that could be documented clearly.
Hi Laurent Pinchart, the swing register setting is optional. Basically, no need
to care about it if customer PCB layout match our chip requirement. The
property define just in case. So far, we just found one customer encountered
DP tx swing issue. As the datasheet swing register adjusting algorithm
has a little complex, we will help customer to adjust the DP tx swing
case by case.
> 
> > > > +  anx,mipi-dpi-in:
> > > > +$ref: /schemas/types.yaml#/definitions/uint32
> > > > +description: indicate the MIPI rx signal type is DPI or DSI
> > > 
> > > This sounds similar to the bus-type property defined in
> > > Documentation/devicetree/bindings/media/video-interfaces.txt (which is
> > > getting converted to YAML, Rob has posted a patch series, I expect it to
> > > land in v5.13). I think it would make sense to extend bus-type to
> > > support DSI, and use that property.
> >
> > Sorry, I didn't found any define for DPI or DSI flag in Rob's patches.
> > Do you mean I just remove this flag define and call a special function
> > to read the port's type(DSI or DPI)?
> 
> video-interfaces.yaml has initially been written for cameras, so it
> doesn't support DSI. I think it would make sense to extend the bus-type
> property with a DSI type, and use it here instead of a vendor-specific
> property.
> 
> Alternatively, I'm wondering if this isn't information we could query at
> runtime. DRM bridges and panels have a type, so we could look at the
> next bridge or panel to find the type of the connected device instead of
> specifying it in DT.

At anx7625 driver probe stage, for the DSI, driver needs call some special
interface to attach to DSI interface. For the DPI port, there is no such
limitation, so we need to know what kind of MIPI signal type at driver initial
stage.
Maybe we can keep this flag, if the future has defined DSI, I'll submit new
patch to remove this flag.

Thanks,
Xin

> 
> > > > +
> > > >ports:
> > > >  type: object
> > > >  
> > > > @@ -72,6 +80,17 @

Re: [PATCH v1 1/2] dt-bindings: drm/bridge: anx7625: add DPI flag and swing setting

2020-12-28 Thread Xin Ji
On Mon, Dec 28, 2020 at 05:08:56PM +0200, Laurent Pinchart wrote:
> Hi Xin Ji,
> 
> Thank you for the patch.
> 
> On Fri, Dec 25, 2020 at 07:01:09PM +0800, Xin Ji wrote:
> > Add DPI flag for distinguish MIPI input signal type, DSI or DPI. Add
> > swing setting for adjusting DP tx PHY swing
> > 
> > Signed-off-by: Xin Ji 
> > ---
> >  .../bindings/display/bridge/analogix,anx7625.yaml | 19 
> > +++
> >  1 file changed, 19 insertions(+)
> > 
> > diff --git 
> > a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml 
> > b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > index 60585a4..34a7faf 100644
> > --- a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > +++ b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > @@ -34,6 +34,14 @@ properties:
> >  description: used for reset chip control, RESET_N pin B7.
> >  maxItems: 1
> >  
> > +  anx,swing-setting:
> > +$ref: /schemas/types.yaml#/definitions/uint32-array
> > +description: an array of swing register setting for DP tx PHY
> 
> Register values in DT are frowned upon.
Hi Laurent Pinchart, as the different vendor has the different PCB layout,
it effects DP CTS test result, so they may need config DP tx Swing register
to adjust signal swing(the default swing setting is not satisfy for
every platform). If we move the config code to driver file, it must define
swing register setting for each vendor, so the DT is the best way. Do you
have any idea for it if you don't agree to add in DT.
> 
> > +  anx,mipi-dpi-in:
> > +$ref: /schemas/types.yaml#/definitions/uint32
> > +description: indicate the MIPI rx signal type is DPI or DSI
> 
> This sounds similar to the bus-type property defined in
> Documentation/devicetree/bindings/media/video-interfaces.txt (which is
> getting converted to YAML, Rob has posted a patch series, I expect it to
> land in v5.13). I think it would make sense to extend bus-type to
> support DSI, and use that property.
Sorry, I didn't found any define for DPI or DSI flag in Rob's patches.
Do you mean I just remove this flag define and call a special function
to read the port's type(DSI or DPI)?
> 
> > +
> >ports:
> >  type: object
> >  
> > @@ -72,6 +80,17 @@ examples:
> >  reg = <0x58>;
> >  enable-gpios = <&pio 45 GPIO_ACTIVE_HIGH>;
> >  reset-gpios = <&pio 73 GPIO_ACTIVE_HIGH>;
> > +anx,swing-setting = <0x00 0x14>, <0x01 0x54>,
> > +<0x02 0x64>, <0x03 0x74>, <0x04 0x29>,
> > +<0x05 0x7b>, <0x06 0x77>, <0x07 0x5b>,
> > +<0x08 0x7f>, <0x0c 0x20>, <0x0d 0x60>,
> > +<0x10 0x60>, <0x12 0x40>, <0x13 0x60>,
> > +<0x14 0x14>, <0x15 0x54>, <0x16 0x64>,
> > +<0x17 0x74>, <0x18 0x29>, <0x19 0x7b>,
> > +<0x1a 0x77>, <0x1b 0x5b>, <0x1c 0x7f>,
> > +<0x20 0x20>, <0x21 0x60>, <0x24 0x60>,
> > +<0x26 0x40>, <0x27 0x60>;
> > +anx,mipi-dpi-in = <0>;
> >  
> >  ports {
> >  #address-cells = <1>;
> 
> -- 
> Regards,
> 
> Laurent Pinchart


Re: [PATCH v1 1/2] dt-bindings: drm/bridge: anx7625: add DPI flag and swing setting

2020-12-28 Thread Xin Ji
On Sun, Dec 27, 2020 at 09:56:21AM -0700, Rob Herring wrote:
> On Fri, 25 Dec 2020 19:01:09 +0800, Xin Ji wrote:
> > Add DPI flag for distinguish MIPI input signal type, DSI or DPI. Add
> > swing setting for adjusting DP tx PHY swing
> > 
> > Signed-off-by: Xin Ji 
> > ---
> >  .../bindings/display/bridge/analogix,anx7625.yaml | 19 
> > +++
> >  1 file changed, 19 insertions(+)
> > 
> 
> My bot found errors running 'make dt_binding_check' on your patch:
Hi Rob Herring, I'll fix this issue in the next serial, thanks!
> 
> yamllint warnings/errors:
> 
> dtschema/dtc warnings/errors:
> /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.example.dt.yaml:
>  encoder@58: anx,swing-setting: 'anyOf' conditional failed, one must be fixed:
>   [[0, 20], [1, 84], [2, 100], [3, 116], [4, 41], [5, 123], [6, 119], [7, 
> 91], [8, 127], [12, 32], [13, 96], [16, 96], [18, 64], [19, 96], [20, 20], 
> [21, 84], [22, 100], [23, 116], [24, 41], [25, 123], [26, 119], [27, 91], 
> [28, 127], [32, 32], [33, 96], [36, 96], [38, 64], [39, 96]] is too long
>   [0, 20] is too long
>   [1, 84] is too long
>   [2, 100] is too long
>   [3, 116] is too long
>   [4, 41] is too long
>   [5, 123] is too long
>   [6, 119] is too long
>   [7, 91] is too long
>   [8, 127] is too long
>   [12, 32] is too long
>   [13, 96] is too long
>   [16, 96] is too long
>   [18, 64] is too long
>   [19, 96] is too long
>   [20, 20] is too long
>   [21, 84] is too long
>   [22, 100] is too long
>   [23, 116] is too long
>   [24, 41] is too long
>   [25, 123] is too long
>   [26, 119] is too long
>   [27, 91] is too long
>   [28, 127] is too long
>   [32, 32] is too long
>   [33, 96] is too long
>   [36, 96] is too long
>   [38, 64] is too long
>   [39, 96] is too long
>   From schema: 
> /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.example.dt.yaml:
>  encoder@58: 'anx,mipi-dpi-in', 'anx,swing-setting' do not match any of the 
> regexes: '^#.*', 
> '^(at25|bm|devbus|dmacap|dsa|exynos|fsi[ab]|gpio-fan|gpio-key|gpio|gpmc|hdmi|i2c-gpio),.*',
>  '^(keypad|m25p|max8952|max8997|max8998|mpmc),.*', 
> '^(pinctrl-single|#pinctrl-single|PowerPC),.*', 
> '^(pl022|pxa-mmc|rcar_sound|rotary-encoder|s5m8767|sdhci),.*', 
> '^(simple-audio-card|st-plgpio|st-spics|ts),.*', '^70mai,.*', '^GEFanuc,.*', 
> '^ORCL,.*', '^SUNW,.*', '^[a-zA-Z0-9#_][a-zA-Z0-9+\\-._@]{0,63}$', 
> '^[a-zA-Z0-9+\\-._]*@[0-9a-zA-Z,]*$', '^abb,.*', '^abilis,.*', '^abracon,.*', 
> '^abt,.*', '^acer,.*', '^acme,.*', '^actions,.*', '^active-semi,.*', 
> '^ad,.*', '^adafruit,.*', '^adapteva,.*', '^adaptrum,.*', '^adh,.*', 
> '^adi,.*', '^advantech,.*', '^aeroflexgaisler,.*', '^al,.*', '^allegro,.*', 
> '^allo,.*', '^allwinner,.*', '^alphascale,.*', '^alps,.*', '^alt,.*', 
> '^altr,.*', '^amarula,.*', '^amazon,.*', '^amcc,.*', '^amd,.*', 
> '^amediatech,.*', '^amlogic,.*', '^ampere,.*', '^ampire,.*', '^ams,.*', 
> '^amstaos,.*', '^analogix,.*', '^andestech,.*', '^anvo,.*', '^apm,.*', 
> '^aptina,.*', '^arasan,.*', '^archermind,.*', '^arctic,.*', '^arcx,.*', 
> '^aries,.*', '^arm,.*', '^armadeus,.*', '^arrow,.*', '^artesyn,.*', 
> '^asahi-kasei,.*', '^asc,.*', '^aspeed,.*', '^asus,.*', '^atlas,.*', 
> '^atmel,.*', '^auo,.*', '^auvidea,.*', '^avago,.*', '^avia,.*', '^avic,.*', 
> '^avnet,.*', '^awinic,.*', '^axentia,.*', '^axis,.*', '^azoteq,.*', 
> '^azw,.*', '^baikal,.*', '^bananapi,.*', '^beacon,.*', '^beagle,.*', 
> '^bhf,.*', '^bitmain,.*', '^boe,.*', '^bosch,.*', '^boundary,.*', '^brcm,.*', 
> &#x

[PATCH v1 2/2] drm/bridge: anx7625: add MIPI DPI input feature support

2020-12-25 Thread Xin Ji
Add MIPI rx DPI input support

Signed-off-by: Xin Ji 
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 352 --
 drivers/gpu/drm/bridge/analogix/anx7625.h |  24 +-
 2 files changed, 356 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
b/drivers/gpu/drm/bridge/analogix/anx7625.c
index 65cc059..0bb2adc 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -164,6 +164,20 @@ static int anx7625_write_and_or(struct anx7625_data *ctx,
 offset, (val & and_mask) | (or_mask));
 }
 
+static int anx7625_config_bit_matrix(struct anx7625_data *ctx)
+{
+   int i, ret;
+
+   ret = anx7625_reg_write(ctx, ctx->i2c.tx_p2_client,
+   AUDIO_CONTROL_REGISTER, 0x80);
+   for (i = 0; i < 13; i++)
+   ret |= anx7625_reg_write(ctx, ctx->i2c.tx_p2_client,
+VIDEO_BIT_MATRIX_12 + i,
+0x18 + i);
+
+   return ret;
+}
+
 static int anx7625_read_ctrl_status_p0(struct anx7625_data *ctx)
 {
return anx7625_reg_read(ctx, ctx->i2c.rx_p0_client, AP_AUX_CTRL_STATUS);
@@ -189,10 +203,64 @@ static int wait_aux_op_finish(struct anx7625_data *ctx)
   AP_AUX_CTRL_STATUS);
if (val < 0 || (val & 0x0F)) {
DRM_DEV_ERROR(dev, "aux status %02x\n", val);
-   val = -EIO;
+   return -EIO;
+   }
+
+   return 0;
+}
+
+static int anx7625_aux_dpcd_read(struct anx7625_data *ctx,
+u8 addrh, u8 addrm, u8 addrl,
+u8 len, u8 *buf)
+{
+   struct device *dev = &ctx->client->dev;
+   int ret;
+   u8 cmd;
+
+   if (len > MAX_DPCD_BUFFER_SIZE) {
+   DRM_DEV_ERROR(dev, "exceed aux buffer len.\n");
+   return -E2BIG;
+   }
+
+   cmd = ((len - 1) << 4) | 0x09;
+
+   /* Set command and length */
+   ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+   AP_AUX_COMMAND, cmd);
+
+   /* Set aux access address */
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+AP_AUX_ADDR_7_0, addrl);
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+AP_AUX_ADDR_15_8, addrm);
+   ret |= anx7625_write_and(ctx, ctx->i2c.rx_p0_client,
+AP_AUX_ADDR_19_16, addrh);
+
+   /* Enable aux access */
+   ret |= anx7625_write_or(ctx, ctx->i2c.rx_p0_client,
+   AP_AUX_CTRL_STATUS, AP_AUX_CTRL_OP_EN);
+
+   if (ret < 0) {
+   DRM_DEV_ERROR(dev, "cannot access aux related register.\n");
+   return -EIO;
+   }
+
+   usleep_range(2000, 2100);
+
+   ret = wait_aux_op_finish(ctx);
+   if (ret) {
+   DRM_DEV_ERROR(dev, "aux IO error: wait aux op finish.\n");
+   return ret;
+   }
+
+   ret = anx7625_reg_block_read(ctx, ctx->i2c.rx_p0_client,
+AP_AUX_BUFF_START, len, buf);
+   if (ret < 0) {
+   DRM_DEV_ERROR(dev, "read dpcd register failed\n");
+   return -EIO;
}
 
-   return val;
+   return 0;
 }
 
 static int anx7625_video_mute_control(struct anx7625_data *ctx,
@@ -595,6 +663,101 @@ static int anx7625_dsi_config(struct anx7625_data *ctx)
return ret;
 }
 
+static int anx7625_api_dpi_config(struct anx7625_data *ctx)
+{
+   struct device *dev = &ctx->client->dev;
+   u16 freq = ctx->dt.pixelclock.min / 1000;
+   int ret;
+
+   /* configure pixel clock */
+   ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+   PIXEL_CLOCK_L, freq & 0xFF);
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
+PIXEL_CLOCK_H, (freq >> 8));
+
+   /* set DPI mode */
+   /* set to DPI PLL module sel */
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client,
+MIPI_DIGITAL_PLL_9, 0x20);
+   /* power down MIPI */
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client,
+MIPI_LANE_CTRL_10, 0x08);
+   /* enable DPI mode */
+   ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p1_client,
+MIPI_DIGITAL_PLL_18, 0x1C);
+   /* set first edge */
+   ret |= anx7625_reg_write(ctx, ctx->i2c.tx_p2_client,
+VIDEO_CONTROL_0, 0x06);
+   if (ret < 0)
+   DRM_DEV_ERROR(dev, "IO error : dpi phy set failed.\n");
+
+   return ret;
+}
+
+static int anx7625_dpi_config(struct anx7625_d

[PATCH v1 1/2] dt-bindings: drm/bridge: anx7625: add DPI flag and swing setting

2020-12-25 Thread Xin Ji
Add DPI flag for distinguish MIPI input signal type, DSI or DPI. Add
swing setting for adjusting DP tx PHY swing

Signed-off-by: Xin Ji 
---
 .../bindings/display/bridge/analogix,anx7625.yaml | 19 +++
 1 file changed, 19 insertions(+)

diff --git 
a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml 
b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
index 60585a4..34a7faf 100644
--- a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
+++ b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
@@ -34,6 +34,14 @@ properties:
 description: used for reset chip control, RESET_N pin B7.
 maxItems: 1
 
+  anx,swing-setting:
+$ref: /schemas/types.yaml#/definitions/uint32-array
+description: an array of swing register setting for DP tx PHY
+
+  anx,mipi-dpi-in:
+$ref: /schemas/types.yaml#/definitions/uint32
+description: indicate the MIPI rx signal type is DPI or DSI
+
   ports:
 type: object
 
@@ -72,6 +80,17 @@ examples:
 reg = <0x58>;
 enable-gpios = <&pio 45 GPIO_ACTIVE_HIGH>;
 reset-gpios = <&pio 73 GPIO_ACTIVE_HIGH>;
+anx,swing-setting = <0x00 0x14>, <0x01 0x54>,
+<0x02 0x64>, <0x03 0x74>, <0x04 0x29>,
+<0x05 0x7b>, <0x06 0x77>, <0x07 0x5b>,
+<0x08 0x7f>, <0x0c 0x20>, <0x0d 0x60>,
+<0x10 0x60>, <0x12 0x40>, <0x13 0x60>,
+<0x14 0x14>, <0x15 0x54>, <0x16 0x64>,
+<0x17 0x74>, <0x18 0x29>, <0x19 0x7b>,
+<0x1a 0x77>, <0x1b 0x5b>, <0x1c 0x7f>,
+<0x20 0x20>, <0x21 0x60>, <0x24 0x60>,
+<0x26 0x40>, <0x27 0x60>;
+anx,mipi-dpi-in = <0>;
 
 ports {
 #address-cells = <1>;
-- 
2.7.4



[PATCH v1 0/2] Add MIPI rx DPI support

2020-12-25 Thread Xin Ji
Hi all, this patch series implement MIPI rx DPI feature. Please help to review.

This is the v1 version, any mistakes, please let me know,
I'll fix it in the next series.

Change history:
v1: initial MIPI rx DPI feature support

Xin Ji (2):
  dt-bindings: drm/bridge: anx7625: add DPI flag and swing setting
  drm/bridge: anx7625: add MIPI DPI input feature support

 .../bindings/display/bridge/analogix,anx7625.yaml  |  19 ++
 drivers/gpu/drm/bridge/analogix/anx7625.c  | 352 +++--
 drivers/gpu/drm/bridge/analogix/anx7625.h  |  24 +-
 3 files changed, 375 insertions(+), 20 deletions(-)

-- 
2.7.4



Re: [PATCH 1/2] dt-bindings: drm/bridge: anx7625: Add power supplies

2020-11-12 Thread Xin Ji
On Thu, Nov 12, 2020 at 04:37:03PM +0800, Hsin-Yi Wang wrote:
> anx7625 requires 3 power supply regulators.
> 
> Signed-off-by: Hsin-Yi Wang 
> ---
>  .../display/bridge/analogix,anx7625.yaml   | 18 ++
>  1 file changed, 18 insertions(+)
> 

Reviewed-by: Xin Ji 


Re: [PATCH 2/2] drm/bridge: anx7625: disable regulators when power off

2020-11-12 Thread Xin Ji
On Thu, Nov 12, 2020 at 04:37:04PM +0800, Hsin-Yi Wang wrote:
> When suspending the driver, anx7625_power_standby() will be called to
> turn off reset-gpios and enable-gpios. However, power supplies are not
> disabled. To save power, the driver can get the power supply regulators
> and turn off them in anx7625_power_standby().
> 
> Signed-off-by: Hsin-Yi Wang 
> ---
>  drivers/gpu/drm/bridge/analogix/anx7625.c | 25 +++
>  drivers/gpu/drm/bridge/analogix/anx7625.h |  1 +
>  2 files changed, 26 insertions(+)

Reviewed-by: Xin Ji 


Re: [PATCH v17 2/2] drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP

2020-10-12 Thread Xin Ji
Hi all, would you please help to review my latest patch v17, thanks very much!

Best Regards,
Xin


[PATCH v17 2/2] drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP

2020-09-18 Thread Xin Ji
The ANX7625 is an ultra-low power 4K Mobile HD Transmitter designed
for portable device. It converts MIPI DSI/DPI to DisplayPort 1.3 4K.

Signed-off-by: Xin Ji 
Reported-by: kernel test robot 
Reported-by: Dan Carpenter 
---
 drivers/gpu/drm/bridge/analogix/Kconfig   |9 +
 drivers/gpu/drm/bridge/analogix/Makefile  |1 +
 drivers/gpu/drm/bridge/analogix/anx7625.c | 1850 +
 drivers/gpu/drm/bridge/analogix/anx7625.h |  390 ++
 4 files changed, 2250 insertions(+)
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.c
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.h

diff --git a/drivers/gpu/drm/bridge/analogix/Kconfig 
b/drivers/gpu/drm/bridge/analogix/Kconfig
index e1fa7d8..024ea2a 100644
--- a/drivers/gpu/drm/bridge/analogix/Kconfig
+++ b/drivers/gpu/drm/bridge/analogix/Kconfig
@@ -25,3 +25,12 @@ config DRM_ANALOGIX_ANX78XX
 config DRM_ANALOGIX_DP
tristate
depends on DRM
+
+config DRM_ANALOGIX_ANX7625
+   tristate "Analogix Anx7625 MIPI to DP interface support"
+   depends on DRM
+   depends on OF
+   help
+ ANX7625 is an ultra-low power 4K mobile HD transmitter
+ designed for portable devices. It converts MIPI/DPI to
+ DisplayPort1.3 4K.
diff --git a/drivers/gpu/drm/bridge/analogix/Makefile 
b/drivers/gpu/drm/bridge/analogix/Makefile
index 97669b3..44da392 100644
--- a/drivers/gpu/drm/bridge/analogix/Makefile
+++ b/drivers/gpu/drm/bridge/analogix/Makefile
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 analogix_dp-objs := analogix_dp_core.o analogix_dp_reg.o analogix-i2c-dptx.o
 obj-$(CONFIG_DRM_ANALOGIX_ANX6345) += analogix-anx6345.o
+obj-$(CONFIG_DRM_ANALOGIX_ANX7625) += anx7625.o
 obj-$(CONFIG_DRM_ANALOGIX_ANX78XX) += analogix-anx78xx.o
 obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix_dp.o
diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
b/drivers/gpu/drm/bridge/analogix/anx7625.c
new file mode 100644
index 000..65cc059
--- /dev/null
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -0,0 +1,1850 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright(c) 2020, Analogix Semiconductor. All rights reserved.
+ *
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "anx7625.h"
+
+/*
+ * There is a sync issue while access I2C register between AP(CPU) and
+ * internal firmware(OCM), to avoid the race condition, AP should access
+ * the reserved slave address before slave address occurs changes.
+ */
+static int i2c_access_workaround(struct anx7625_data *ctx,
+struct i2c_client *client)
+{
+   u8 offset;
+   struct device *dev = &client->dev;
+   int ret;
+
+   if (client == ctx->last_client)
+   return 0;
+
+   ctx->last_client = client;
+
+   if (client == ctx->i2c.tcpc_client)
+   offset = RSVD_00_ADDR;
+   else if (client == ctx->i2c.tx_p0_client)
+   offset = RSVD_D1_ADDR;
+   else if (client == ctx->i2c.tx_p1_client)
+   offset = RSVD_60_ADDR;
+   else if (client == ctx->i2c.rx_p0_client)
+   offset = RSVD_39_ADDR;
+   else if (client == ctx->i2c.rx_p1_client)
+   offset = RSVD_7F_ADDR;
+   else
+   offset = RSVD_00_ADDR;
+
+   ret = i2c_smbus_write_byte_data(client, offset, 0x00);
+   if (ret < 0)
+   DRM_DEV_ERROR(dev,
+ "fail to access i2c id=%x\n:%x",
+ client->addr, offset);
+
+   return ret;
+}
+
+static int anx7625_reg_read(struct anx7625_data *ctx,
+   struct i2c_client *client, u8 reg_addr)
+{
+   int ret;
+   struct device *dev = &client->dev;
+
+   i2c_access_workaround(ctx, client);
+
+   ret = i2c_smbus_read_byte_data(client, reg_addr);
+   if (ret < 0)
+   DRM_DEV_ERROR(dev, "read i2c fail id=%x:%x\n",
+ client->addr, reg_addr);
+
+   return ret;
+}
+
+static int anx7625_reg_block_read(struct anx7625_data *ctx,
+ struct i2c_client *client,
+ u8 reg_addr, u8 len, u8 *buf)
+{
+   int ret;
+   struct device *dev = &client->dev;
+
+   i2c_access_workaround(ctx, client);
+
+   ret = i2c_smbus_read_i2c_block_data(client, reg_addr, len, buf);
+   if (ret < 0)
+   DRM_DEV_ERROR(dev, "read i2c block fail id=%x:%x\n",
+ client->addr, reg_addr);
+
+   return ret;
+}
+
+static int anx7625_reg_write(struct anx7625_data *ctx,
+struct i2c_client

[PATCH v17 1/2] dt-bindings: drm/bridge: anx7625: MIPI to DP transmitter DT schema

2020-09-18 Thread Xin Ji
anx7625: MIPI to DP transmitter DT schema

Signed-off-by: Xin Ji 
Reviewed-by: Rob Herring 
---
 .../bindings/display/bridge/analogix,anx7625.yaml  | 95 ++
 1 file changed, 95 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml

diff --git 
a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml 
b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
new file mode 100644
index 000..60585a4
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
@@ -0,0 +1,95 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+# Copyright 2019 Analogix Semiconductor, Inc.
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/display/bridge/analogix,anx7625.yaml#";
+$schema: "http://devicetree.org/meta-schemas/core.yaml#";
+
+title: Analogix ANX7625 SlimPort (4K Mobile HD Transmitter)
+
+maintainers:
+  - Xin Ji 
+
+description: |
+  The ANX7625 is an ultra-low power 4K Mobile HD Transmitter
+  designed for portable devices.
+
+properties:
+  compatible:
+items:
+  - const: analogix,anx7625
+
+  reg:
+maxItems: 1
+
+  interrupts:
+description: used for interrupt pin B8.
+maxItems: 1
+
+  enable-gpios:
+description: used for power on chip control, POWER_EN pin D2.
+maxItems: 1
+
+  reset-gpios:
+description: used for reset chip control, RESET_N pin B7.
+maxItems: 1
+
+  ports:
+type: object
+
+properties:
+  port@0:
+type: object
+description:
+  Video port for MIPI DSI input.
+
+  port@1:
+type: object
+description:
+  Video port for panel or connector.
+
+required:
+- port@0
+- port@1
+
+required:
+  - compatible
+  - reg
+  - ports
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+
+i2c0 {
+#address-cells = <1>;
+#size-cells = <0>;
+
+encoder@58 {
+compatible = "analogix,anx7625";
+reg = <0x58>;
+enable-gpios = <&pio 45 GPIO_ACTIVE_HIGH>;
+reset-gpios = <&pio 73 GPIO_ACTIVE_HIGH>;
+
+ports {
+#address-cells = <1>;
+#size-cells = <0>;
+
+mipi2dp_bridge_in: port@0 {
+reg = <0>;
+anx7625_in: endpoint {
+remote-endpoint = <&mipi_dsi>;
+};
+};
+
+mipi2dp_bridge_out: port@1 {
+reg = <1>;
+anx7625_out: endpoint {
+remote-endpoint = <&panel_in>;
+};
+};
+};
+};
+};
-- 
2.7.4



[PATCH v17 0/2] Add initial support for slimport anx7625

2020-09-18 Thread Xin Ji
Hi all,

The following series add support for the Slimport ANX7625 transmitter, a
ultra-low power Full-HD 4K MIPI to DP transmitter designed for portable device.


This is the v17 version, any mistakes, please let me know, I will fix it in
the next series.

Change history:
v17: Fix comments from Dan
 - Fix possible memory leak of 'edid'

v16: Fix compile error
 - Fix compiling error of incompitible interface of ".mode_valid()"

v15: Fix comments from Sam and Hsin-Yi Wang
 - Remove connector
 - Allocate memory for edid at ".get_edid()"

v14: Fix comments from Sam and Nicolas
 - Check flags at drm_bridge_attach
 - Use panel_bridge instead of drm_panel
 - Fix not correct return value

v13: Fix comments from Launrent Pinchart and Rob Herring
 - Picked up Rob's Reviewed-By
 - Add .detect and .get_edid interface in bridge funcs.

v12: Fix comments from Hsin-Yi Wang
 - Rebase the code on kernel 5.7, fix DRM interface not match issue.

v11: Fix comments from Rob Herring
 - Update commit message.
 - Remove unused label.

v10: Fix comments from Rob Herring, Daniel.
 - Fix dt_binding_check warning.
 - Update description.

v9: Fix comments from Sam, Nicolas, Daniel
 - Remove extcon interface.
 - Remove DPI support.
 - Fix dt_binding_check complains.
 - Code clean up and update description.

v8: Fix comments from Nicolas.
 - Fix several coding format.
 - Update description.

v7:
 - Fix critical timing(eg:odd hfp/hbp) in "mode_fixup" interface,
   enhance MIPI RX tolerance by setting register MIPI_DIGITAL_ADJ_1 to 0x3D.


Xin Ji (2):
  dt-bindings: drm/bridge: anx7625: MIPI to DP transmitter DT schema
  drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP

 .../bindings/display/bridge/analogix,anx7625.yaml  |   95 +
 drivers/gpu/drm/bridge/analogix/Kconfig|9 +
 drivers/gpu/drm/bridge/analogix/Makefile   |1 +
 drivers/gpu/drm/bridge/analogix/anx7625.c  | 1850 
 drivers/gpu/drm/bridge/analogix/anx7625.h  |  390 +
 5 files changed, 2345 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.c
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.h

-- 
2.7.4



Re: [PATCH v16 2/2] drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP

2020-09-18 Thread Xin Ji
On Fri, Sep 18, 2020 at 11:45:34AM +0300, Dan Carpenter wrote:
> Hi Xin,
> 
> url:
> https://github.com/0day-ci/linux/commits/Xin-Ji/Add-initial-support-for-slimport-anx7625/20200917-163238
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
> 5925fa68fe8244651b3f78a88c4af99190a88f0d
> config: mips-randconfig-m031-20200917 (attached as .config)
> compiler: mips-linux-gcc (GCC) 9.3.0
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot 
> Reported-by: Dan Carpenter 
Hi Dan, OK, I'll fix it right now.
Thanks,
Xin
> 
> smatch warnings:
> drivers/gpu/drm/bridge/analogix/anx7625.c:1289 anx7625_get_edid() warn: 
> possible memory leak of 'edid'
> 
> # 
> https://github.com/0day-ci/linux/commit/667ee517c70d2bedafe5bfa0dc5f13fc60d5133d
> git remote add linux-review https://github.com/0day-ci/linux
> git fetch --no-tags linux-review 
> Xin-Ji/Add-initial-support-for-slimport-anx7625/20200917-163238
> git checkout 667ee517c70d2bedafe5bfa0dc5f13fc60d5133d
> vim +/edid +1289 drivers/gpu/drm/bridge/analogix/anx7625.c
> 
> 667ee517c70d2be Xin Ji 2020-09-17  1264  static struct edid 
> *anx7625_get_edid(struct anx7625_data *ctx)
> 667ee517c70d2be Xin Ji 2020-09-17  1265  {
> 667ee517c70d2be Xin Ji 2020-09-17  1266   struct device *dev = 
> &ctx->client->dev;
> 667ee517c70d2be Xin Ji 2020-09-17  1267   struct s_edid_data *p_edid = 
> &ctx->slimport_edid_p;
> 667ee517c70d2be Xin Ji 2020-09-17  1268   int edid_num;
> 667ee517c70d2be Xin Ji 2020-09-17  1269   u8 *edid;
> 667ee517c70d2be Xin Ji 2020-09-17  1270  
> 667ee517c70d2be Xin Ji 2020-09-17  1271   edid = kmalloc(FOUR_BLOCK_SIZE, 
> GFP_KERNEL);
> 667ee517c70d2be Xin Ji 2020-09-17  1272       if (!edid) {
> 667ee517c70d2be Xin Ji 2020-09-17  1273       DRM_DEV_ERROR(dev, 
> "Fail to allocate buffer\n");
> 667ee517c70d2be Xin Ji 2020-09-17  1274   return NULL;
> 667ee517c70d2be Xin Ji 2020-09-17  1275       }
> 667ee517c70d2be Xin Ji 2020-09-17  1276  
> 667ee517c70d2be Xin Ji 2020-09-17  1277   if 
> (ctx->slimport_edid_p.edid_block_num > 0) {
> 667ee517c70d2be Xin Ji 2020-09-17  1278   memcpy(edid, 
> ctx->slimport_edid_p.edid_raw_data,
> 667ee517c70d2be Xin Ji 2020-09-17  1279      FOUR_BLOCK_SIZE);
> 667ee517c70d2be Xin Ji 2020-09-17  1280   return (struct edid 
> *)edid;
> 667ee517c70d2be Xin Ji 2020-09-17  1281   }
> 667ee517c70d2be Xin Ji 2020-09-17  1282  
> 667ee517c70d2be Xin Ji 2020-09-17  1283   
> anx7625_low_power_mode_check(ctx, 1);
> 667ee517c70d2be Xin Ji 2020-09-17  1284       edid_num = sp_tx_edid_read(ctx, 
> p_edid->edid_raw_data);
> 667ee517c70d2be Xin Ji 2020-09-17  1285   
> anx7625_low_power_mode_check(ctx, 0);
> 667ee517c70d2be Xin Ji 2020-09-17  1286  
> 667ee517c70d2be Xin Ji 2020-09-17  1287   if (edid_num < 1) {
> 667ee517c70d2be Xin Ji 2020-09-17  1288       DRM_DEV_ERROR(dev, 
> "Fail to read EDID: %d\n", edid_num);
> 667ee517c70d2be Xin Ji 2020-09-17 @1289       return NULL;
> 
> kfree(edid); before returning.
> 
> 667ee517c70d2be Xin Ji 2020-09-17  1290   }
> 667ee517c70d2be Xin Ji 2020-09-17  1291  
> 667ee517c70d2be Xin Ji 2020-09-17  1292   p_edid->edid_block_num = 
> edid_num;
> 667ee517c70d2be Xin Ji 2020-09-17  1293  
> 667ee517c70d2be Xin Ji 2020-09-17  1294   memcpy(edid, 
> ctx->slimport_edid_p.edid_raw_data, FOUR_BLOCK_SIZE);
> 667ee517c70d2be Xin Ji 2020-09-17  1295   return (struct edid *)edid;
> 667ee517c70d2be Xin Ji 2020-09-17  1296  }
> 
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org




[PATCH v16 2/2] drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP

2020-09-17 Thread Xin Ji
The ANX7625 is an ultra-low power 4K Mobile HD Transmitter designed
for portable device. It converts MIPI DSI/DPI to DisplayPort 1.3 4K.

Signed-off-by: Xin Ji 
---
 drivers/gpu/drm/bridge/analogix/Kconfig   |9 +
 drivers/gpu/drm/bridge/analogix/Makefile  |1 +
 drivers/gpu/drm/bridge/analogix/anx7625.c | 1849 +
 drivers/gpu/drm/bridge/analogix/anx7625.h |  390 ++
 4 files changed, 2249 insertions(+)
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.c
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.h

diff --git a/drivers/gpu/drm/bridge/analogix/Kconfig 
b/drivers/gpu/drm/bridge/analogix/Kconfig
index e1fa7d8..024ea2a 100644
--- a/drivers/gpu/drm/bridge/analogix/Kconfig
+++ b/drivers/gpu/drm/bridge/analogix/Kconfig
@@ -25,3 +25,12 @@ config DRM_ANALOGIX_ANX78XX
 config DRM_ANALOGIX_DP
tristate
depends on DRM
+
+config DRM_ANALOGIX_ANX7625
+   tristate "Analogix Anx7625 MIPI to DP interface support"
+   depends on DRM
+   depends on OF
+   help
+ ANX7625 is an ultra-low power 4K mobile HD transmitter
+ designed for portable devices. It converts MIPI/DPI to
+ DisplayPort1.3 4K.
diff --git a/drivers/gpu/drm/bridge/analogix/Makefile 
b/drivers/gpu/drm/bridge/analogix/Makefile
index 97669b3..44da392 100644
--- a/drivers/gpu/drm/bridge/analogix/Makefile
+++ b/drivers/gpu/drm/bridge/analogix/Makefile
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 analogix_dp-objs := analogix_dp_core.o analogix_dp_reg.o analogix-i2c-dptx.o
 obj-$(CONFIG_DRM_ANALOGIX_ANX6345) += analogix-anx6345.o
+obj-$(CONFIG_DRM_ANALOGIX_ANX7625) += anx7625.o
 obj-$(CONFIG_DRM_ANALOGIX_ANX78XX) += analogix-anx78xx.o
 obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix_dp.o
diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
b/drivers/gpu/drm/bridge/analogix/anx7625.c
new file mode 100644
index 000..cec37da
--- /dev/null
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -0,0 +1,1849 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright(c) 2020, Analogix Semiconductor. All rights reserved.
+ *
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "anx7625.h"
+
+/*
+ * There is a sync issue while access I2C register between AP(CPU) and
+ * internal firmware(OCM), to avoid the race condition, AP should access
+ * the reserved slave address before slave address occurs changes.
+ */
+static int i2c_access_workaround(struct anx7625_data *ctx,
+struct i2c_client *client)
+{
+   u8 offset;
+   struct device *dev = &client->dev;
+   int ret;
+
+   if (client == ctx->last_client)
+   return 0;
+
+   ctx->last_client = client;
+
+   if (client == ctx->i2c.tcpc_client)
+   offset = RSVD_00_ADDR;
+   else if (client == ctx->i2c.tx_p0_client)
+   offset = RSVD_D1_ADDR;
+   else if (client == ctx->i2c.tx_p1_client)
+   offset = RSVD_60_ADDR;
+   else if (client == ctx->i2c.rx_p0_client)
+   offset = RSVD_39_ADDR;
+   else if (client == ctx->i2c.rx_p1_client)
+   offset = RSVD_7F_ADDR;
+   else
+   offset = RSVD_00_ADDR;
+
+   ret = i2c_smbus_write_byte_data(client, offset, 0x00);
+   if (ret < 0)
+   DRM_DEV_ERROR(dev,
+ "fail to access i2c id=%x\n:%x",
+ client->addr, offset);
+
+   return ret;
+}
+
+static int anx7625_reg_read(struct anx7625_data *ctx,
+   struct i2c_client *client, u8 reg_addr)
+{
+   int ret;
+   struct device *dev = &client->dev;
+
+   i2c_access_workaround(ctx, client);
+
+   ret = i2c_smbus_read_byte_data(client, reg_addr);
+   if (ret < 0)
+   DRM_DEV_ERROR(dev, "read i2c fail id=%x:%x\n",
+ client->addr, reg_addr);
+
+   return ret;
+}
+
+static int anx7625_reg_block_read(struct anx7625_data *ctx,
+ struct i2c_client *client,
+ u8 reg_addr, u8 len, u8 *buf)
+{
+   int ret;
+   struct device *dev = &client->dev;
+
+   i2c_access_workaround(ctx, client);
+
+   ret = i2c_smbus_read_i2c_block_data(client, reg_addr, len, buf);
+   if (ret < 0)
+   DRM_DEV_ERROR(dev, "read i2c block fail id=%x:%x\n",
+ client->addr, reg_addr);
+
+   return ret;
+}
+
+static int anx7625_reg_write(struct anx7625_data *ctx,
+struct i2c_client *client,
+u8 reg_addr, u8 reg_v

[PATCH v16 1/2] dt-bindings: drm/bridge: anx7625: MIPI to DP transmitter DT schema

2020-09-17 Thread Xin Ji
anx7625: MIPI to DP transmitter DT schema

Signed-off-by: Xin Ji 
Reviewed-by: Rob Herring 
---
 .../bindings/display/bridge/analogix,anx7625.yaml  | 95 ++
 1 file changed, 95 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml

diff --git 
a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml 
b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
new file mode 100644
index 000..60585a4
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
@@ -0,0 +1,95 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+# Copyright 2019 Analogix Semiconductor, Inc.
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/display/bridge/analogix,anx7625.yaml#";
+$schema: "http://devicetree.org/meta-schemas/core.yaml#";
+
+title: Analogix ANX7625 SlimPort (4K Mobile HD Transmitter)
+
+maintainers:
+  - Xin Ji 
+
+description: |
+  The ANX7625 is an ultra-low power 4K Mobile HD Transmitter
+  designed for portable devices.
+
+properties:
+  compatible:
+items:
+  - const: analogix,anx7625
+
+  reg:
+maxItems: 1
+
+  interrupts:
+description: used for interrupt pin B8.
+maxItems: 1
+
+  enable-gpios:
+description: used for power on chip control, POWER_EN pin D2.
+maxItems: 1
+
+  reset-gpios:
+description: used for reset chip control, RESET_N pin B7.
+maxItems: 1
+
+  ports:
+type: object
+
+properties:
+  port@0:
+type: object
+description:
+  Video port for MIPI DSI input.
+
+  port@1:
+type: object
+description:
+  Video port for panel or connector.
+
+required:
+- port@0
+- port@1
+
+required:
+  - compatible
+  - reg
+  - ports
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+
+i2c0 {
+#address-cells = <1>;
+#size-cells = <0>;
+
+encoder@58 {
+compatible = "analogix,anx7625";
+reg = <0x58>;
+enable-gpios = <&pio 45 GPIO_ACTIVE_HIGH>;
+reset-gpios = <&pio 73 GPIO_ACTIVE_HIGH>;
+
+ports {
+#address-cells = <1>;
+#size-cells = <0>;
+
+mipi2dp_bridge_in: port@0 {
+reg = <0>;
+anx7625_in: endpoint {
+remote-endpoint = <&mipi_dsi>;
+};
+};
+
+mipi2dp_bridge_out: port@1 {
+reg = <1>;
+anx7625_out: endpoint {
+remote-endpoint = <&panel_in>;
+};
+};
+};
+};
+};
-- 
2.7.4



[PATCH v16 0/2] Add initial support for slimport anx7625

2020-09-17 Thread Xin Ji
Hi all,

The following series add support for the Slimport ANX7625 transmitter, a
ultra-low power Full-HD 4K MIPI to DP transmitter designed for portable device.


This is the v16 version, any mistakes, please let me know, I will fix it in
the next series.

Change history:
v16: Fix compile error
 - Fix compiling error of incompitible interface of ".mode_valid()"

v15: Fix comments from Sam and Hsin-Yi Wang
 - Remove connector
 - Allocate memory for edid at ".get_edid()"

v14: Fix comments from Sam and Nicolas
 - Check flags at drm_bridge_attach
 - Use panel_bridge instead of drm_panel
 - Fix not correct return value

v13: Fix comments from Launrent Pinchart and Rob Herring
 - Picked up Rob's Reviewed-By
 - Add .detect and .get_edid interface in bridge funcs.

v12: Fix comments from Hsin-Yi Wang
 - Rebase the code on kernel 5.7, fix DRM interface not match issue.

v11: Fix comments from Rob Herring
 - Update commit message.
 - Remove unused label.

v10: Fix comments from Rob Herring, Daniel.
 - Fix dt_binding_check warning.
 - Update description.

v9: Fix comments from Sam, Nicolas, Daniel
 - Remove extcon interface.
 - Remove DPI support.
 - Fix dt_binding_check complains.
 - Code clean up and update description.

v8: Fix comments from Nicolas.
 - Fix several coding format.
 - Update description.

v7:
 - Fix critical timing(eg:odd hfp/hbp) in "mode_fixup" interface,
   enhance MIPI RX tolerance by setting register MIPI_DIGITAL_ADJ_1 to 0x3D.


Xin Ji (2):
  dt-bindings: drm/bridge: anx7625: MIPI to DP transmitter DT schema
  drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP

 .../bindings/display/bridge/analogix,anx7625.yaml  |   95 +
 drivers/gpu/drm/bridge/analogix/Kconfig|9 +
 drivers/gpu/drm/bridge/analogix/Makefile   |1 +
 drivers/gpu/drm/bridge/analogix/anx7625.c  | 1849 
 drivers/gpu/drm/bridge/analogix/anx7625.h  |  390 +
 5 files changed, 2344 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.c
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.h

-- 
2.7.4



[PATCH v15 2/2] drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP

2020-09-16 Thread Xin Ji
The ANX7625 is an ultra-low power 4K Mobile HD Transmitter designed
for portable device. It converts MIPI DSI/DPI to DisplayPort 1.3 4K.

Signed-off-by: Xin Ji 
---
 drivers/gpu/drm/bridge/analogix/Kconfig   |9 +
 drivers/gpu/drm/bridge/analogix/Makefile  |1 +
 drivers/gpu/drm/bridge/analogix/anx7625.c | 1848 +
 drivers/gpu/drm/bridge/analogix/anx7625.h |  390 ++
 4 files changed, 2248 insertions(+)
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.c
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.h

diff --git a/drivers/gpu/drm/bridge/analogix/Kconfig 
b/drivers/gpu/drm/bridge/analogix/Kconfig
index e1fa7d8..024ea2a 100644
--- a/drivers/gpu/drm/bridge/analogix/Kconfig
+++ b/drivers/gpu/drm/bridge/analogix/Kconfig
@@ -25,3 +25,12 @@ config DRM_ANALOGIX_ANX78XX
 config DRM_ANALOGIX_DP
tristate
depends on DRM
+
+config DRM_ANALOGIX_ANX7625
+   tristate "Analogix Anx7625 MIPI to DP interface support"
+   depends on DRM
+   depends on OF
+   help
+ ANX7625 is an ultra-low power 4K mobile HD transmitter
+ designed for portable devices. It converts MIPI/DPI to
+ DisplayPort1.3 4K.
diff --git a/drivers/gpu/drm/bridge/analogix/Makefile 
b/drivers/gpu/drm/bridge/analogix/Makefile
index 97669b3..44da392 100644
--- a/drivers/gpu/drm/bridge/analogix/Makefile
+++ b/drivers/gpu/drm/bridge/analogix/Makefile
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 analogix_dp-objs := analogix_dp_core.o analogix_dp_reg.o analogix-i2c-dptx.o
 obj-$(CONFIG_DRM_ANALOGIX_ANX6345) += analogix-anx6345.o
+obj-$(CONFIG_DRM_ANALOGIX_ANX7625) += anx7625.o
 obj-$(CONFIG_DRM_ANALOGIX_ANX78XX) += analogix-anx78xx.o
 obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix_dp.o
diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
b/drivers/gpu/drm/bridge/analogix/anx7625.c
new file mode 100644
index 000..6e2fe7e
--- /dev/null
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -0,0 +1,1848 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright(c) 2020, Analogix Semiconductor. All rights reserved.
+ *
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "anx7625.h"
+
+/*
+ * There is a sync issue while access I2C register between AP(CPU) and
+ * internal firmware(OCM), to avoid the race condition, AP should access
+ * the reserved slave address before slave address occurs changes.
+ */
+static int i2c_access_workaround(struct anx7625_data *ctx,
+struct i2c_client *client)
+{
+   u8 offset;
+   struct device *dev = &client->dev;
+   int ret;
+
+   if (client == ctx->last_client)
+   return 0;
+
+   ctx->last_client = client;
+
+   if (client == ctx->i2c.tcpc_client)
+   offset = RSVD_00_ADDR;
+   else if (client == ctx->i2c.tx_p0_client)
+   offset = RSVD_D1_ADDR;
+   else if (client == ctx->i2c.tx_p1_client)
+   offset = RSVD_60_ADDR;
+   else if (client == ctx->i2c.rx_p0_client)
+   offset = RSVD_39_ADDR;
+   else if (client == ctx->i2c.rx_p1_client)
+   offset = RSVD_7F_ADDR;
+   else
+   offset = RSVD_00_ADDR;
+
+   ret = i2c_smbus_write_byte_data(client, offset, 0x00);
+   if (ret < 0)
+   DRM_DEV_ERROR(dev,
+ "fail to access i2c id=%x\n:%x",
+ client->addr, offset);
+
+   return ret;
+}
+
+static int anx7625_reg_read(struct anx7625_data *ctx,
+   struct i2c_client *client, u8 reg_addr)
+{
+   int ret;
+   struct device *dev = &client->dev;
+
+   i2c_access_workaround(ctx, client);
+
+   ret = i2c_smbus_read_byte_data(client, reg_addr);
+   if (ret < 0)
+   DRM_DEV_ERROR(dev, "read i2c fail id=%x:%x\n",
+ client->addr, reg_addr);
+
+   return ret;
+}
+
+static int anx7625_reg_block_read(struct anx7625_data *ctx,
+ struct i2c_client *client,
+ u8 reg_addr, u8 len, u8 *buf)
+{
+   int ret;
+   struct device *dev = &client->dev;
+
+   i2c_access_workaround(ctx, client);
+
+   ret = i2c_smbus_read_i2c_block_data(client, reg_addr, len, buf);
+   if (ret < 0)
+   DRM_DEV_ERROR(dev, "read i2c block fail id=%x:%x\n",
+ client->addr, reg_addr);
+
+   return ret;
+}
+
+static int anx7625_reg_write(struct anx7625_data *ctx,
+struct i2c_client *client,
+u8 reg_addr, u8 reg_v

[PATCH v15 1/2] dt-bindings: drm/bridge: anx7625: MIPI to DP transmitter DT schema

2020-09-16 Thread Xin Ji
anx7625: MIPI to DP transmitter DT schema

Signed-off-by: Xin Ji 
Reviewed-by: Rob Herring 
---
 .../bindings/display/bridge/analogix,anx7625.yaml  | 95 ++
 1 file changed, 95 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml

diff --git 
a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml 
b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
new file mode 100644
index 000..60585a4
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
@@ -0,0 +1,95 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+# Copyright 2019 Analogix Semiconductor, Inc.
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/display/bridge/analogix,anx7625.yaml#";
+$schema: "http://devicetree.org/meta-schemas/core.yaml#";
+
+title: Analogix ANX7625 SlimPort (4K Mobile HD Transmitter)
+
+maintainers:
+  - Xin Ji 
+
+description: |
+  The ANX7625 is an ultra-low power 4K Mobile HD Transmitter
+  designed for portable devices.
+
+properties:
+  compatible:
+items:
+  - const: analogix,anx7625
+
+  reg:
+maxItems: 1
+
+  interrupts:
+description: used for interrupt pin B8.
+maxItems: 1
+
+  enable-gpios:
+description: used for power on chip control, POWER_EN pin D2.
+maxItems: 1
+
+  reset-gpios:
+description: used for reset chip control, RESET_N pin B7.
+maxItems: 1
+
+  ports:
+type: object
+
+properties:
+  port@0:
+type: object
+description:
+  Video port for MIPI DSI input.
+
+  port@1:
+type: object
+description:
+  Video port for panel or connector.
+
+required:
+- port@0
+- port@1
+
+required:
+  - compatible
+  - reg
+  - ports
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+
+i2c0 {
+#address-cells = <1>;
+#size-cells = <0>;
+
+encoder@58 {
+compatible = "analogix,anx7625";
+reg = <0x58>;
+enable-gpios = <&pio 45 GPIO_ACTIVE_HIGH>;
+reset-gpios = <&pio 73 GPIO_ACTIVE_HIGH>;
+
+ports {
+#address-cells = <1>;
+#size-cells = <0>;
+
+mipi2dp_bridge_in: port@0 {
+reg = <0>;
+anx7625_in: endpoint {
+remote-endpoint = <&mipi_dsi>;
+};
+};
+
+mipi2dp_bridge_out: port@1 {
+reg = <1>;
+anx7625_out: endpoint {
+remote-endpoint = <&panel_in>;
+};
+};
+};
+};
+};
-- 
2.7.4



[PATCH v15 0/2] Add initial support for slimport anx7625

2020-09-16 Thread Xin Ji
Hi all,

The following series add support for the Slimport ANX7625 transmitter, a
ultra-low power Full-HD 4K MIPI to DP transmitter designed for portable device.


This is the v15 version, any mistakes, please let me know, I will fix it in
the next series.

Change history:
v15: Fix comments from Sam and Hsin-Yi Wang
 - Remove connector
 - Allocate memory for edid at ".get_edid()"

v14: Fix comments from Sam and Nicolas
 - Check flags at drm_bridge_attach
 - Use panel_bridge instead of drm_panel
 - Fix not correct return value

v13: Fix comments from Launrent Pinchart and Rob Herring
 - Picked up Rob's Reviewed-By
 - Add .detect and .get_edid interface in bridge funcs.

v12: Fix comments from Hsin-Yi Wang
 - Rebase the code on kernel 5.7, fix DRM interface not match issue.

v11: Fix comments from Rob Herring
 - Update commit message.
 - Remove unused label.

v10: Fix comments from Rob Herring, Daniel.
 - Fix dt_binding_check warning.
 - Update description.

v9: Fix comments from Sam, Nicolas, Daniel
 - Remove extcon interface.
 - Remove DPI support.
 - Fix dt_binding_check complains.
 - Code clean up and update description.

v8: Fix comments from Nicolas.
 - Fix several coding format.
 - Update description.

v7:
 - Fix critical timing(eg:odd hfp/hbp) in "mode_fixup" interface,
   enhance MIPI RX tolerance by setting register MIPI_DIGITAL_ADJ_1 to 0x3D.



Xin Ji (2):
  dt-bindings: drm/bridge: anx7625: MIPI to DP transmitter DT schema
  drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP

 .../bindings/display/bridge/analogix,anx7625.yaml  |   95 +
 drivers/gpu/drm/bridge/analogix/Kconfig|9 +
 drivers/gpu/drm/bridge/analogix/Makefile   |1 +
 drivers/gpu/drm/bridge/analogix/anx7625.c  | 1848 
 drivers/gpu/drm/bridge/analogix/anx7625.h  |  390 +
 5 files changed, 2343 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.c
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.h

-- 
2.7.4



Re: Fwd: [PATCH v14 0/2] Add initial support for slimport anx7625

2020-08-19 Thread Xin Ji
On Wed, Aug 19, 2020 at 02:57:14PM +0800, Hsin-Yi Wang wrote:
> I think you missed this email :)
> 
> -- Forwarded message -
> From: Sam Ravnborg 
> Date: Tue, Aug 11, 2020 at 4:35 AM
> Subject: Re: [PATCH v14 0/2] Add initial support for slimport anx7625
> To: Xin Ji 
> Cc: , Laurent Pinchart
> , Andrzej Hajda
> , Nicolas Boichat , Jernej
> Skrabec , Nicolas Boichat
> , Pi-Hsun Shih , Jonas
> Karlman , David Airlie , Neil
> Armstrong , ,
> , Sheng Pan ,
> Hsin-Yi Wang , Dan Carpenter
> 
> 
Hi Sam, I missed this email.
> 
> Hi Xin Ji.
> 
> On Thu, Jul 09, 2020 at 04:31:09PM +0800, Xin Ji wrote:
> > Hi all,
> >
> > The following series add support for the Slimport ANX7625 transmitter, a
> > ultra-low power Full-HD 4K MIPI to DP transmitter designed for portable 
> > device.
> >
> >
> > This is the v14 version, any mistakes, please let me know, I will fix it in
> > the next series.
> >
> > Change history:
> > v14: Fix comments from Sam and Nicolas
> >  - Check flags at drm_bridge_attach
> >  - Use panel_bridge instead of drm_panel
> >  - Fix not correct return value
> 
> Sorry for ignoring this for so long time.
> The patch applies but no longer builds.
> 
> I could fix it locally but wanted to know if you have a later version to
> be applied?
> 
> Sam
Hi Sam, there is no new version patch. We have another patch for other
project, so we will upstream new patch after this patch has been merged.

Thanks,
Xin

> 
> 
> >
> > v13: Fix comments from Launrent Pinchart and Rob Herring
> >  - Picked up Rob's Reviewed-By
> >  - Add .detect and .get_edid interface in bridge funcs.
> >
> > v12: Fix comments from Hsin-Yi Wang
> >  - Rebase the code on kernel 5.7, fix DRM interface not match issue.
> >
> > v11: Fix comments from Rob Herring
> >  - Update commit message.
> >  - Remove unused label.
> >
> > v10: Fix comments from Rob Herring, Daniel.
> >  - Fix dt_binding_check warning.
> >  - Update description.
> >
> > v9: Fix comments from Sam, Nicolas, Daniel
> >  - Remove extcon interface.
> >  - Remove DPI support.
> >  - Fix dt_binding_check complains.
> >  - Code clean up and update description.
> >
> > v8: Fix comments from Nicolas.
> >  - Fix several coding format.
> >  - Update description.
> >
> > v7:
> >  - Fix critical timing(eg:odd hfp/hbp) in "mode_fixup" interface,
> >enhance MIPI RX tolerance by setting register MIPI_DIGITAL_ADJ_1 to 0x3D.
> >
> >
> > Xin Ji (2):
> >   dt-bindings: drm/bridge: anx7625: MIPI to DP transmitter DT schema
> >   drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP
> >
> >  .../bindings/display/bridge/analogix,anx7625.yaml  |   95 +
> >  drivers/gpu/drm/bridge/analogix/Kconfig|9 +
> >  drivers/gpu/drm/bridge/analogix/Makefile   |1 +
> >  drivers/gpu/drm/bridge/analogix/anx7625.c  | 1939 
> > 
> >  drivers/gpu/drm/bridge/analogix/anx7625.h  |  391 
> >  5 files changed, 2435 insertions(+)
> >  create mode 100644 
> > Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> >  create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.c
> >  create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.h
> >
> > --
> > 2.7.4
> >
> > ___
> > dri-devel mailing list
> > dri-de...@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v14 2/2] drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP

2020-07-09 Thread Xin Ji
The ANX7625 is an ultra-low power 4K Mobile HD Transmitter designed
for portable device. It converts MIPI DSI/DPI to DisplayPort 1.3 4K.

Signed-off-by: Xin Ji 
---
 drivers/gpu/drm/bridge/analogix/Kconfig   |9 +
 drivers/gpu/drm/bridge/analogix/Makefile  |1 +
 drivers/gpu/drm/bridge/analogix/anx7625.c | 1939 +
 drivers/gpu/drm/bridge/analogix/anx7625.h |  391 ++
 4 files changed, 2340 insertions(+)
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.c
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.h

diff --git a/drivers/gpu/drm/bridge/analogix/Kconfig 
b/drivers/gpu/drm/bridge/analogix/Kconfig
index e1fa7d8..024ea2a 100644
--- a/drivers/gpu/drm/bridge/analogix/Kconfig
+++ b/drivers/gpu/drm/bridge/analogix/Kconfig
@@ -25,3 +25,12 @@ config DRM_ANALOGIX_ANX78XX
 config DRM_ANALOGIX_DP
tristate
depends on DRM
+
+config DRM_ANALOGIX_ANX7625
+   tristate "Analogix Anx7625 MIPI to DP interface support"
+   depends on DRM
+   depends on OF
+   help
+ ANX7625 is an ultra-low power 4K mobile HD transmitter
+ designed for portable devices. It converts MIPI/DPI to
+ DisplayPort1.3 4K.
diff --git a/drivers/gpu/drm/bridge/analogix/Makefile 
b/drivers/gpu/drm/bridge/analogix/Makefile
index 97669b3..44da392 100644
--- a/drivers/gpu/drm/bridge/analogix/Makefile
+++ b/drivers/gpu/drm/bridge/analogix/Makefile
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 analogix_dp-objs := analogix_dp_core.o analogix_dp_reg.o analogix-i2c-dptx.o
 obj-$(CONFIG_DRM_ANALOGIX_ANX6345) += analogix-anx6345.o
+obj-$(CONFIG_DRM_ANALOGIX_ANX7625) += anx7625.o
 obj-$(CONFIG_DRM_ANALOGIX_ANX78XX) += analogix-anx78xx.o
 obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix_dp.o
diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
b/drivers/gpu/drm/bridge/analogix/anx7625.c
new file mode 100644
index 000..0d6be64
--- /dev/null
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -0,0 +1,1939 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright(c) 2020, Analogix Semiconductor. All rights reserved.
+ *
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "anx7625.h"
+
+/*
+ * There is a sync issue while access I2C register between AP(CPU) and
+ * internal firmware(OCM), to avoid the race condition, AP should access
+ * the reserved slave address before slave address occurs changes.
+ */
+static int i2c_access_workaround(struct anx7625_data *ctx,
+struct i2c_client *client)
+{
+   u8 offset;
+   struct device *dev = &client->dev;
+   int ret;
+
+   if (client == ctx->last_client)
+   return 0;
+
+   ctx->last_client = client;
+
+   if (client == ctx->i2c.tcpc_client)
+   offset = RSVD_00_ADDR;
+   else if (client == ctx->i2c.tx_p0_client)
+   offset = RSVD_D1_ADDR;
+   else if (client == ctx->i2c.tx_p1_client)
+   offset = RSVD_60_ADDR;
+   else if (client == ctx->i2c.rx_p0_client)
+   offset = RSVD_39_ADDR;
+   else if (client == ctx->i2c.rx_p1_client)
+   offset = RSVD_7F_ADDR;
+   else
+   offset = RSVD_00_ADDR;
+
+   ret = i2c_smbus_write_byte_data(client, offset, 0x00);
+   if (ret < 0)
+   DRM_DEV_ERROR(dev,
+ "fail to access i2c id=%x\n:%x",
+ client->addr, offset);
+
+   return ret;
+}
+
+static int anx7625_reg_read(struct anx7625_data *ctx,
+   struct i2c_client *client, u8 reg_addr)
+{
+   int ret;
+   struct device *dev = &client->dev;
+
+   i2c_access_workaround(ctx, client);
+
+   ret = i2c_smbus_read_byte_data(client, reg_addr);
+   if (ret < 0)
+   DRM_DEV_ERROR(dev, "read i2c fail id=%x:%x\n",
+ client->addr, reg_addr);
+
+   return ret;
+}
+
+static int anx7625_reg_block_read(struct anx7625_data *ctx,
+ struct i2c_client *client,
+ u8 reg_addr, u8 len, u8 *buf)
+{
+   int ret;
+   struct device *dev = &client->dev;
+
+   i2c_access_workaround(ctx, client);
+
+   ret = i2c_smbus_read_i2c_block_data(client, reg_addr, len, buf);
+   if (ret < 0)
+   DRM_DEV_ERROR(dev, "read i2c block fail id=%x:%x\n",
+ client->addr, reg_addr);
+
+   return ret;
+}
+
+static int anx7625_reg_write(struct anx7625_data *ctx,
+struct i2c_client *client,
+u8 reg_addr, u8 reg_v

[PATCH v14 1/2] dt-bindings: drm/bridge: anx7625: MIPI to DP transmitter DT schema

2020-07-09 Thread Xin Ji
anx7625: MIPI to DP transmitter DT schema

Signed-off-by: Xin Ji 
Reviewed-by: Rob Herring 
---
 .../bindings/display/bridge/analogix,anx7625.yaml  | 95 ++
 1 file changed, 95 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml

diff --git 
a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml 
b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
new file mode 100644
index 000..60585a4
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
@@ -0,0 +1,95 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+# Copyright 2019 Analogix Semiconductor, Inc.
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/display/bridge/analogix,anx7625.yaml#";
+$schema: "http://devicetree.org/meta-schemas/core.yaml#";
+
+title: Analogix ANX7625 SlimPort (4K Mobile HD Transmitter)
+
+maintainers:
+  - Xin Ji 
+
+description: |
+  The ANX7625 is an ultra-low power 4K Mobile HD Transmitter
+  designed for portable devices.
+
+properties:
+  compatible:
+items:
+  - const: analogix,anx7625
+
+  reg:
+maxItems: 1
+
+  interrupts:
+description: used for interrupt pin B8.
+maxItems: 1
+
+  enable-gpios:
+description: used for power on chip control, POWER_EN pin D2.
+maxItems: 1
+
+  reset-gpios:
+description: used for reset chip control, RESET_N pin B7.
+maxItems: 1
+
+  ports:
+type: object
+
+properties:
+  port@0:
+type: object
+description:
+  Video port for MIPI DSI input.
+
+  port@1:
+type: object
+description:
+  Video port for panel or connector.
+
+required:
+- port@0
+- port@1
+
+required:
+  - compatible
+  - reg
+  - ports
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+
+i2c0 {
+#address-cells = <1>;
+#size-cells = <0>;
+
+encoder@58 {
+compatible = "analogix,anx7625";
+reg = <0x58>;
+enable-gpios = <&pio 45 GPIO_ACTIVE_HIGH>;
+reset-gpios = <&pio 73 GPIO_ACTIVE_HIGH>;
+
+ports {
+#address-cells = <1>;
+#size-cells = <0>;
+
+mipi2dp_bridge_in: port@0 {
+reg = <0>;
+anx7625_in: endpoint {
+remote-endpoint = <&mipi_dsi>;
+};
+};
+
+mipi2dp_bridge_out: port@1 {
+reg = <1>;
+anx7625_out: endpoint {
+remote-endpoint = <&panel_in>;
+};
+};
+};
+};
+};
-- 
2.7.4



[PATCH v14 0/2] Add initial support for slimport anx7625

2020-07-09 Thread Xin Ji
Hi all,

The following series add support for the Slimport ANX7625 transmitter, a
ultra-low power Full-HD 4K MIPI to DP transmitter designed for portable device.


This is the v14 version, any mistakes, please let me know, I will fix it in
the next series.

Change history:
v14: Fix comments from Sam and Nicolas
 - Check flags at drm_bridge_attach
 - Use panel_bridge instead of drm_panel
 - Fix not correct return value

v13: Fix comments from Launrent Pinchart and Rob Herring
 - Picked up Rob's Reviewed-By
 - Add .detect and .get_edid interface in bridge funcs.

v12: Fix comments from Hsin-Yi Wang
 - Rebase the code on kernel 5.7, fix DRM interface not match issue.

v11: Fix comments from Rob Herring
 - Update commit message.
 - Remove unused label.

v10: Fix comments from Rob Herring, Daniel.
 - Fix dt_binding_check warning.
 - Update description.

v9: Fix comments from Sam, Nicolas, Daniel
 - Remove extcon interface.
 - Remove DPI support.
 - Fix dt_binding_check complains.
 - Code clean up and update description.

v8: Fix comments from Nicolas.
 - Fix several coding format.
 - Update description.

v7:
 - Fix critical timing(eg:odd hfp/hbp) in "mode_fixup" interface,
   enhance MIPI RX tolerance by setting register MIPI_DIGITAL_ADJ_1 to 0x3D.


Xin Ji (2):
  dt-bindings: drm/bridge: anx7625: MIPI to DP transmitter DT schema
  drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP

 .../bindings/display/bridge/analogix,anx7625.yaml  |   95 +
 drivers/gpu/drm/bridge/analogix/Kconfig|9 +
 drivers/gpu/drm/bridge/analogix/Makefile   |1 +
 drivers/gpu/drm/bridge/analogix/anx7625.c  | 1939 
 drivers/gpu/drm/bridge/analogix/anx7625.h  |  391 
 5 files changed, 2435 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.c
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.h

-- 
2.7.4



Re: [PATCH v13 2/2] drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP

2020-07-08 Thread Xin Ji
On Tue, Jul 07, 2020 at 03:01:25PM +0800, Nicolas Boichat wrote:

Hi Nicolas, thanks for the replay.

> On Tue, Jun 9, 2020 at 3:20 PM Xin Ji  wrote:
> >
> > The ANX7625 is an ultra-low power 4K Mobile HD Transmitter designed
> > for portable device. It converts MIPI DSI/DPI to DisplayPort 1.3 4K.
> >
> > Signed-off-by: Xin Ji 
> > ---
> >  drivers/gpu/drm/bridge/analogix/Kconfig   |9 +
> >  drivers/gpu/drm/bridge/analogix/Makefile  |1 +
> >  drivers/gpu/drm/bridge/analogix/anx7625.c | 1999 
> > +
> >  drivers/gpu/drm/bridge/analogix/anx7625.h |  397 ++
> >  4 files changed, 2406 insertions(+)
> >  create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.c
> >  create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.h
> >
> > [snip]
> > +static int anx7625_parse_dt(struct device *dev,
> > +   struct anx7625_platform_data *pdata)
> > +{
> > +   struct device_node *np = dev->of_node;
> > +   struct device_node *panel_node, *out_ep;
> > +
> > +   pdata->node.mipi_dsi_host_node = of_graph_get_remote_node(np, 0, 0);
> > +   if (!pdata->node.mipi_dsi_host_node) {
> > +   DRM_DEV_ERROR(dev, "fail to get internal panel.\n");
> > +   return -EPROBE_DEFER;
> 
> This does not look correct. I don't think of_graph_get_remote_node
> will ever return NULL if the device tree is configured properly, and
> it's useless to retry later (EPROBE_DEFER). You should just fail (e.g.
> return EINVAL).
OK
> 
> > +   }
> > +
> > +   of_node_put(pdata->node.mipi_dsi_host_node);
> 
> You are using pdata->node.mipi_dsi_host_node in other places in the
> code, so I don't think it's ok to call of_node_put?
I'll move the related code to here.
> 
> > +   DRM_DEV_DEBUG_DRIVER(dev, "found dsi host node.\n");
> > +
> > +   pdata->node.panel_node = of_graph_get_port_by_id(np, 1);
> > +   if (!pdata->node.panel_node) {
> > +   DRM_DEV_ERROR(dev, "fail to get panel node.\n");
> > +   return -EPROBE_DEFER;
> 
> -EINVAL.
OK
> 
> > +   }
> > +
> > +   of_node_put(pdata->node.panel_node);
> > +   out_ep = of_get_child_by_name(pdata->node.panel_node,
> > + "endpoint");
> > +   if (!out_ep) {
> > +   DRM_DEV_DEBUG_DRIVER(dev, "cannot get endpoint.\n");
> 
> DRM_DEV_ERROR seems more appropriate
OK, also I'll remove drm_panel based on Sam comment.
> 
> > +   return -EPROBE_DEFER;
> 
> -EINVAL
OK
> 
> > +   }
> > +
> > +   panel_node = of_graph_get_remote_port_parent(out_ep);
> > +   of_node_put(out_ep);
> > +   pdata->panel = of_drm_find_panel(panel_node);
> > +   DRM_DEV_DEBUG_DRIVER(dev, "get panel node.\n");
> > +
> > +   of_node_put(panel_node);
> > +   if (IS_ERR_OR_NULL(pdata->panel))
> > +   return -EPROBE_DEFER;
> 
> of_drm_find_panel cannot return NULL, so, do this instead:
> 
> if (IS_ERR(pdata->panel))
>return PTR_ERR(pdata->panel);
> 
> (which actually _may_ return EPROBE_DEFER)
I'll remove drm_panel, use panel_bridge.
> 
> > +
> > +   return 0;
> > +}
> > [snip]
> > +static int anx7625_i2c_probe(struct i2c_client *client,
> > +const struct i2c_device_id *id)
> > +{
> > +   struct anx7625_data *platform;
> > +   struct anx7625_platform_data *pdata;
> > +   int ret = 0;
> > +   struct device *dev = &client->dev;
> > +
> > +   if (!i2c_check_functionality(client->adapter,
> > +I2C_FUNC_SMBUS_I2C_BLOCK)) {
> > +   DRM_DEV_ERROR(dev, "anx7625's i2c bus doesn't support\n");
> > +   return -ENODEV;
> > +   }
> > +
> > +   platform = kzalloc(sizeof(*platform), GFP_KERNEL);
> > +   if (!platform) {
> > +   DRM_DEV_ERROR(dev, "fail to allocate driver data\n");
> > +   return -ENOMEM;
> > +   }
> > +
> > +   pdata = &platform->pdata;
> > +
> > +   ret = anx7625_parse_dt(dev, pdata);
> > +   if (ret) {
> > +   DRM_DEV_ERROR(dev, "fail to parse devicetree.\n");
> 
> Please do not print this error (or at least not if err == -EPROBE_DEFER).
OK
> 
> > +   goto free_platform;
> > +   }


Re: [PATCH v13 2/2] drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP

2020-06-22 Thread Xin Ji
On Sun, Jun 21, 2020 at 10:09:25AM +0200, Sam Ravnborg wrote:
> Hi Xin.
> 
> 
> On Tue, Jun 09, 2020 at 03:19:50PM +0800, Xin Ji wrote:
> > The ANX7625 is an ultra-low power 4K Mobile HD Transmitter designed
> > for portable device. It converts MIPI DSI/DPI to DisplayPort 1.3 4K.
> > 
> > Signed-off-by: Xin Ji 
> 
> The bridge driver now implements the bridge functions for get_edid +
> detect which is good.
> But the bridge driver also needs to check the flags argument
> of anx7625_bridge_attach() so the connector creation is optional.
> This is required to prepare the bridge driver to fully support a
> chain of bridges and is mandatory for new bridge drivers.
> 
> Futhermore the bridge driver needs to be converted to use the bridge
> panel. See what other bridge drivers do.
> In short - the drm_panel shall be replaced by a bridge in your
> platform data structure.
> Usual this end up in less code after the conversion.
> 
>   Sam
> 
Hi Sam, thanks for your comments.
1. I'll add flags argument check in anx7625_bridge_attach().
2. Do you mean panel bridge, related interface is
"devm_drm_panel_bridge_add(...)"? If it is, do I still need call
drm_panel_prepare()/drm_panel_unprepare() to enable/disable panel power?

Thanks,
Xin

> > ---
> >  drivers/gpu/drm/bridge/analogix/Kconfig   |9 +
> >  drivers/gpu/drm/bridge/analogix/Makefile  |1 +
> >  drivers/gpu/drm/bridge/analogix/anx7625.c | 1999 
> > +
> >  drivers/gpu/drm/bridge/analogix/anx7625.h |  397 ++
> >  4 files changed, 2406 insertions(+)
> >  create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.c
> >  create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.h
> > 
> > diff --git a/drivers/gpu/drm/bridge/analogix/Kconfig 
> > b/drivers/gpu/drm/bridge/analogix/Kconfig
> > index e1fa7d8..024ea2a 100644
> > --- a/drivers/gpu/drm/bridge/analogix/Kconfig
> > +++ b/drivers/gpu/drm/bridge/analogix/Kconfig
> > @@ -25,3 +25,12 @@ config DRM_ANALOGIX_ANX78XX
> >  config DRM_ANALOGIX_DP
> > tristate
> > depends on DRM
> > +
> > +config DRM_ANALOGIX_ANX7625
> > +   tristate "Analogix Anx7625 MIPI to DP interface support"
> > +   depends on DRM
> > +   depends on OF
> > +   help
> > + ANX7625 is an ultra-low power 4K mobile HD transmitter
> > + designed for portable devices. It converts MIPI/DPI to
> > + DisplayPort1.3 4K.
> > diff --git a/drivers/gpu/drm/bridge/analogix/Makefile 
> > b/drivers/gpu/drm/bridge/analogix/Makefile
> > index 97669b3..44da392 100644
> > --- a/drivers/gpu/drm/bridge/analogix/Makefile
> > +++ b/drivers/gpu/drm/bridge/analogix/Makefile
> > @@ -1,5 +1,6 @@
> >  # SPDX-License-Identifier: GPL-2.0-only
> >  analogix_dp-objs := analogix_dp_core.o analogix_dp_reg.o 
> > analogix-i2c-dptx.o
> >  obj-$(CONFIG_DRM_ANALOGIX_ANX6345) += analogix-anx6345.o
> > +obj-$(CONFIG_DRM_ANALOGIX_ANX7625) += anx7625.o
> >  obj-$(CONFIG_DRM_ANALOGIX_ANX78XX) += analogix-anx78xx.o
> >  obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix_dp.o
> > diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
> > b/drivers/gpu/drm/bridge/analogix/anx7625.c
> > new file mode 100644
> > index 000..db37f68
> > --- /dev/null
> > +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
> > @@ -0,0 +1,1999 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +/*
> > + * Copyright(c) 2020, Analogix Semiconductor. All rights reserved.
> > + *
> > + */
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +
> > +#include "anx7625.h"
> > +
> > +/*
> > + * There is a sync issue while access I2C register between AP(CPU) and
> > + * internal firmware(OCM), to avoid the race condition, AP should access
> > + * the reserved slave address before slave address occurs changes.
> > + */
> > +static int i2c_access_workaround(struct anx7625_data *ctx,
> > +struct i2c_client *client)
> > +{
> > +   u8 offset;
> > +   struct device *dev = &client->dev;
> > +   int ret;
> > +
> > +   if (client == ctx

[PATCH v13 2/2] drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP

2020-06-09 Thread Xin Ji
The ANX7625 is an ultra-low power 4K Mobile HD Transmitter designed
for portable device. It converts MIPI DSI/DPI to DisplayPort 1.3 4K.

Signed-off-by: Xin Ji 
---
 drivers/gpu/drm/bridge/analogix/Kconfig   |9 +
 drivers/gpu/drm/bridge/analogix/Makefile  |1 +
 drivers/gpu/drm/bridge/analogix/anx7625.c | 1999 +
 drivers/gpu/drm/bridge/analogix/anx7625.h |  397 ++
 4 files changed, 2406 insertions(+)
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.c
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.h

diff --git a/drivers/gpu/drm/bridge/analogix/Kconfig 
b/drivers/gpu/drm/bridge/analogix/Kconfig
index e1fa7d8..024ea2a 100644
--- a/drivers/gpu/drm/bridge/analogix/Kconfig
+++ b/drivers/gpu/drm/bridge/analogix/Kconfig
@@ -25,3 +25,12 @@ config DRM_ANALOGIX_ANX78XX
 config DRM_ANALOGIX_DP
tristate
depends on DRM
+
+config DRM_ANALOGIX_ANX7625
+   tristate "Analogix Anx7625 MIPI to DP interface support"
+   depends on DRM
+   depends on OF
+   help
+ ANX7625 is an ultra-low power 4K mobile HD transmitter
+ designed for portable devices. It converts MIPI/DPI to
+ DisplayPort1.3 4K.
diff --git a/drivers/gpu/drm/bridge/analogix/Makefile 
b/drivers/gpu/drm/bridge/analogix/Makefile
index 97669b3..44da392 100644
--- a/drivers/gpu/drm/bridge/analogix/Makefile
+++ b/drivers/gpu/drm/bridge/analogix/Makefile
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 analogix_dp-objs := analogix_dp_core.o analogix_dp_reg.o analogix-i2c-dptx.o
 obj-$(CONFIG_DRM_ANALOGIX_ANX6345) += analogix-anx6345.o
+obj-$(CONFIG_DRM_ANALOGIX_ANX7625) += anx7625.o
 obj-$(CONFIG_DRM_ANALOGIX_ANX78XX) += analogix-anx78xx.o
 obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix_dp.o
diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
b/drivers/gpu/drm/bridge/analogix/anx7625.c
new file mode 100644
index 000..db37f68
--- /dev/null
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -0,0 +1,1999 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright(c) 2020, Analogix Semiconductor. All rights reserved.
+ *
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "anx7625.h"
+
+/*
+ * There is a sync issue while access I2C register between AP(CPU) and
+ * internal firmware(OCM), to avoid the race condition, AP should access
+ * the reserved slave address before slave address occurs changes.
+ */
+static int i2c_access_workaround(struct anx7625_data *ctx,
+struct i2c_client *client)
+{
+   u8 offset;
+   struct device *dev = &client->dev;
+   int ret;
+
+   if (client == ctx->last_client)
+   return 0;
+
+   ctx->last_client = client;
+
+   if (client == ctx->i2c.tcpc_client)
+   offset = RSVD_00_ADDR;
+   else if (client == ctx->i2c.tx_p0_client)
+   offset = RSVD_D1_ADDR;
+   else if (client == ctx->i2c.tx_p1_client)
+   offset = RSVD_60_ADDR;
+   else if (client == ctx->i2c.rx_p0_client)
+   offset = RSVD_39_ADDR;
+   else if (client == ctx->i2c.rx_p1_client)
+   offset = RSVD_7F_ADDR;
+   else
+   offset = RSVD_00_ADDR;
+
+   ret = i2c_smbus_write_byte_data(client, offset, 0x00);
+   if (ret < 0)
+   DRM_DEV_ERROR(dev,
+ "fail to access i2c id=%x\n:%x",
+ client->addr, offset);
+
+   return ret;
+}
+
+static int anx7625_reg_read(struct anx7625_data *ctx,
+   struct i2c_client *client, u8 reg_addr)
+{
+   int ret;
+   struct device *dev = &client->dev;
+
+   i2c_access_workaround(ctx, client);
+
+   ret = i2c_smbus_read_byte_data(client, reg_addr);
+   if (ret < 0)
+   DRM_DEV_ERROR(dev, "read i2c fail id=%x:%x\n",
+ client->addr, reg_addr);
+
+   return ret;
+}
+
+static int anx7625_reg_block_read(struct anx7625_data *ctx,
+ struct i2c_client *client,
+ u8 reg_addr, u8 len, u8 *buf)
+{
+   int ret;
+   struct device *dev = &client->dev;
+
+   i2c_access_workaround(ctx, client);
+
+   ret = i2c_smbus_read_i2c_block_data(client, reg_addr, len, buf);
+   if (ret < 0)
+   DRM_DEV_ERROR(dev, "read i2c block fail id=%x:%x\n",
+ client->addr, reg_addr);
+
+   return ret;
+}
+
+static int anx7625_reg_write(struct anx7625_data *ctx,
+struct i2c_client *client,
+u8 reg_addr, u8 reg_v

[PATCH v13 1/2] dt-bindings: drm/bridge: anx7625: MIPI to DP transmitter DT schema

2020-06-09 Thread Xin Ji
anx7625: MIPI to DP transmitter DT schema

Signed-off-by: Xin Ji 
Reviewed-by: Rob Herring 
---
 .../bindings/display/bridge/analogix,anx7625.yaml  | 95 ++
 1 file changed, 95 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml

diff --git 
a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml 
b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
new file mode 100644
index 000..60585a4
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
@@ -0,0 +1,95 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+# Copyright 2019 Analogix Semiconductor, Inc.
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/display/bridge/analogix,anx7625.yaml#";
+$schema: "http://devicetree.org/meta-schemas/core.yaml#";
+
+title: Analogix ANX7625 SlimPort (4K Mobile HD Transmitter)
+
+maintainers:
+  - Xin Ji 
+
+description: |
+  The ANX7625 is an ultra-low power 4K Mobile HD Transmitter
+  designed for portable devices.
+
+properties:
+  compatible:
+items:
+  - const: analogix,anx7625
+
+  reg:
+maxItems: 1
+
+  interrupts:
+description: used for interrupt pin B8.
+maxItems: 1
+
+  enable-gpios:
+description: used for power on chip control, POWER_EN pin D2.
+maxItems: 1
+
+  reset-gpios:
+description: used for reset chip control, RESET_N pin B7.
+maxItems: 1
+
+  ports:
+type: object
+
+properties:
+  port@0:
+type: object
+description:
+  Video port for MIPI DSI input.
+
+  port@1:
+type: object
+description:
+  Video port for panel or connector.
+
+required:
+- port@0
+- port@1
+
+required:
+  - compatible
+  - reg
+  - ports
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+
+i2c0 {
+#address-cells = <1>;
+#size-cells = <0>;
+
+encoder@58 {
+compatible = "analogix,anx7625";
+reg = <0x58>;
+enable-gpios = <&pio 45 GPIO_ACTIVE_HIGH>;
+reset-gpios = <&pio 73 GPIO_ACTIVE_HIGH>;
+
+ports {
+#address-cells = <1>;
+#size-cells = <0>;
+
+mipi2dp_bridge_in: port@0 {
+reg = <0>;
+anx7625_in: endpoint {
+remote-endpoint = <&mipi_dsi>;
+};
+};
+
+mipi2dp_bridge_out: port@1 {
+reg = <1>;
+anx7625_out: endpoint {
+remote-endpoint = <&panel_in>;
+};
+};
+};
+};
+};
-- 
2.7.4



[PATCH v13 0/2] Add initial support for slimport anx7625

2020-06-09 Thread Xin Ji
Hi all,

The following series add support for the Slimport ANX7625 transmitter, a
ultra-low power Full-HD 4K MIPI to DP transmitter designed for portable device.


This is the v13 version, any mistakes, please let me know, I will fix it in
the next series.

Change history:
v13: Fix comments from Launrent Pinchart and Rob Herring
 - Picked up Rob's Reviewed-By
 - Add .detect and .get_edid interface in bridge funcs.

v12: Fix comments from Hsin-Yi Wang
 - Rebase the code on kernel 5.7, fix DRM interface not match issue.

v11: Fix comments from Rob Herring
 - Update commit message.
 - Remove unused label.

v10: Fix comments from Rob Herring, Daniel.
 - Fix dt_binding_check warning.
 - Update description.

v9: Fix comments from Sam, Nicolas, Daniel
 - Remove extcon interface.
 - Remove DPI support.
 - Fix dt_binding_check complains.
 - Code clean up and update description.

v8: Fix comments from Nicolas.
 - Fix several coding format.
 - Update description.

v7:
 - Fix critical timing(eg:odd hfp/hbp) in "mode_fixup" interface,
   enhance MIPI RX tolerance by setting register MIPI_DIGITAL_ADJ_1 to 0x3D.


Xin Ji (2):
  dt-bindings: drm/bridge: anx7625: MIPI to DP transmitter DT schema
  drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP

 .../bindings/display/bridge/analogix,anx7625.yaml  |   95 +
 drivers/gpu/drm/bridge/analogix/Kconfig|9 +
 drivers/gpu/drm/bridge/analogix/Makefile   |1 +
 drivers/gpu/drm/bridge/analogix/anx7625.c  | 1999 
 drivers/gpu/drm/bridge/analogix/anx7625.h  |  397 
 5 files changed, 2501 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.c
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.h

-- 
2.7.4



Re: [PATCH v12 1/2] dt-bindings: drm/bridge: anx7625: MIPI to DP transmitter DT schema

2020-06-04 Thread Xin Ji
On Thu, Jun 04, 2020 at 04:24:02PM -0600, Rob Herring wrote:
> On Thu, 04 Jun 2020 15:56:36 +0800, Xin Ji wrote:
> > anx7625: MIPI to DP transmitter DT schema
> > 
> > Signed-off-by: Xin Ji 
> > ---
> >  .../bindings/display/bridge/analogix,anx7625.yaml  | 95 
> > ++
> >  1 file changed, 95 insertions(+)
> >  create mode 100644 
> > Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > 
> 
> 
> Please add Acked-by/Reviewed-by tags when posting new versions. However,
> there's no need to repost patches *only* to add the tags. The upstream
> maintainer will do that for acks received on the version they apply.
> 
> If a tag was not added on purpose, please state why and what changed.

Hi Rob Herring, thanks for your comment. I'll add tags in the next
versions.

Thanks,
Xin



Re: [PATCH v12 2/2] drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP

2020-06-04 Thread Xin Ji
On Thu, Jun 04, 2020 at 11:08:05AM +0300, Laurent Pinchart wrote:
> Hello Xin,
> 
> Thank you for the patch.
> 
> On Thu, Jun 04, 2020 at 03:58:05PM +0800, Xin Ji wrote:
> > The ANX7625 is an ultra-low power 4K Mobile HD Transmitter designed
> > for portable device. It converts MIPI DSI/DPI to DisplayPort 1.3 4K.
> > 
> > Signed-off-by: Xin Ji 
> > ---
> >  drivers/gpu/drm/bridge/analogix/Kconfig   |9 +
> >  drivers/gpu/drm/bridge/analogix/Makefile  |1 +
> >  drivers/gpu/drm/bridge/analogix/anx7625.c | 1961 
> > +
> >  drivers/gpu/drm/bridge/analogix/anx7625.h |  397 ++
> >  4 files changed, 2368 insertions(+)
> >  create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.c
> >  create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.h
> > 
> > diff --git a/drivers/gpu/drm/bridge/analogix/Kconfig 
> > b/drivers/gpu/drm/bridge/analogix/Kconfig
> > index e1fa7d8..024ea2a 100644
> > --- a/drivers/gpu/drm/bridge/analogix/Kconfig
> > +++ b/drivers/gpu/drm/bridge/analogix/Kconfig
> > @@ -25,3 +25,12 @@ config DRM_ANALOGIX_ANX78XX
> >  config DRM_ANALOGIX_DP
> > tristate
> > depends on DRM
> > +
> > +config DRM_ANALOGIX_ANX7625
> > +   tristate "Analogix Anx7625 MIPI to DP interface support"
> > +   depends on DRM
> > +   depends on OF
> > +   help
> > + ANX7625 is an ultra-low power 4K mobile HD transmitter
> > + designed for portable devices. It converts MIPI/DPI to
> > + DisplayPort1.3 4K.
> > diff --git a/drivers/gpu/drm/bridge/analogix/Makefile 
> > b/drivers/gpu/drm/bridge/analogix/Makefile
> > index 97669b3..44da392 100644
> > --- a/drivers/gpu/drm/bridge/analogix/Makefile
> > +++ b/drivers/gpu/drm/bridge/analogix/Makefile
> > @@ -1,5 +1,6 @@
> >  # SPDX-License-Identifier: GPL-2.0-only
> >  analogix_dp-objs := analogix_dp_core.o analogix_dp_reg.o 
> > analogix-i2c-dptx.o
> >  obj-$(CONFIG_DRM_ANALOGIX_ANX6345) += analogix-anx6345.o
> > +obj-$(CONFIG_DRM_ANALOGIX_ANX7625) += anx7625.o
> >  obj-$(CONFIG_DRM_ANALOGIX_ANX78XX) += analogix-anx78xx.o
> >  obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix_dp.o
> > diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
> > b/drivers/gpu/drm/bridge/analogix/anx7625.c
> > new file mode 100644
> > index 000..f1cc6bb
> > --- /dev/null
> > +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
> > @@ -0,0 +1,1961 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +/*
> > + * Copyright(c) 2020, Analogix Semiconductor. All rights reserved.
> > + *
> > + */
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +
> > +#include "anx7625.h"
> > +
> > +/*
> > + * There is a sync issue while access I2C register between AP(CPU) and
> > + * internal firmware(OCM), to avoid the race condition, AP should access
> > + * the reserved slave address before slave address occurs changes.
> > + */
> > +static int i2c_access_workaround(struct anx7625_data *ctx,
> > +struct i2c_client *client)
> > +{
> > +   u8 offset;
> > +   struct device *dev = &client->dev;
> > +   int ret;
> > +
> > +   if (client == ctx->last_client)
> > +   return 0;
> > +
> > +   ctx->last_client = client;
> > +
> > +   if (client == ctx->i2c.tcpc_client)
> > +   offset = RSVD_00_ADDR;
> > +   else if (client == ctx->i2c.tx_p0_client)
> > +   offset = RSVD_D1_ADDR;
> > +   else if (client == ctx->i2c.tx_p1_client)
> > +   offset = RSVD_60_ADDR;
> > +   else if (client == ctx->i2c.rx_p0_client)
> > +   offset = RSVD_39_ADDR;
> > +   else if (client == ctx->i2c.rx_p1_client)
> > +   offset = RSVD_7F_ADDR;
> > +   else
> > +   offset = RSVD_00_ADDR;
> > +
> > +   ret = i2c_smbus_write_byte_data(client, offset, 0x00);
> > +   if (ret < 0)
> > +   DRM_DEV_ERROR(dev,
> > + "fail to access i2c id=%x\n:%x",
> > +

[PATCH v12 2/2] drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP

2020-06-04 Thread Xin Ji
The ANX7625 is an ultra-low power 4K Mobile HD Transmitter designed
for portable device. It converts MIPI DSI/DPI to DisplayPort 1.3 4K.

Signed-off-by: Xin Ji 
---
 drivers/gpu/drm/bridge/analogix/Kconfig   |9 +
 drivers/gpu/drm/bridge/analogix/Makefile  |1 +
 drivers/gpu/drm/bridge/analogix/anx7625.c | 1961 +
 drivers/gpu/drm/bridge/analogix/anx7625.h |  397 ++
 4 files changed, 2368 insertions(+)
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.c
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.h

diff --git a/drivers/gpu/drm/bridge/analogix/Kconfig 
b/drivers/gpu/drm/bridge/analogix/Kconfig
index e1fa7d8..024ea2a 100644
--- a/drivers/gpu/drm/bridge/analogix/Kconfig
+++ b/drivers/gpu/drm/bridge/analogix/Kconfig
@@ -25,3 +25,12 @@ config DRM_ANALOGIX_ANX78XX
 config DRM_ANALOGIX_DP
tristate
depends on DRM
+
+config DRM_ANALOGIX_ANX7625
+   tristate "Analogix Anx7625 MIPI to DP interface support"
+   depends on DRM
+   depends on OF
+   help
+ ANX7625 is an ultra-low power 4K mobile HD transmitter
+ designed for portable devices. It converts MIPI/DPI to
+ DisplayPort1.3 4K.
diff --git a/drivers/gpu/drm/bridge/analogix/Makefile 
b/drivers/gpu/drm/bridge/analogix/Makefile
index 97669b3..44da392 100644
--- a/drivers/gpu/drm/bridge/analogix/Makefile
+++ b/drivers/gpu/drm/bridge/analogix/Makefile
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 analogix_dp-objs := analogix_dp_core.o analogix_dp_reg.o analogix-i2c-dptx.o
 obj-$(CONFIG_DRM_ANALOGIX_ANX6345) += analogix-anx6345.o
+obj-$(CONFIG_DRM_ANALOGIX_ANX7625) += anx7625.o
 obj-$(CONFIG_DRM_ANALOGIX_ANX78XX) += analogix-anx78xx.o
 obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix_dp.o
diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
b/drivers/gpu/drm/bridge/analogix/anx7625.c
new file mode 100644
index 000..f1cc6bb
--- /dev/null
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -0,0 +1,1961 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright(c) 2020, Analogix Semiconductor. All rights reserved.
+ *
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "anx7625.h"
+
+/*
+ * There is a sync issue while access I2C register between AP(CPU) and
+ * internal firmware(OCM), to avoid the race condition, AP should access
+ * the reserved slave address before slave address occurs changes.
+ */
+static int i2c_access_workaround(struct anx7625_data *ctx,
+struct i2c_client *client)
+{
+   u8 offset;
+   struct device *dev = &client->dev;
+   int ret;
+
+   if (client == ctx->last_client)
+   return 0;
+
+   ctx->last_client = client;
+
+   if (client == ctx->i2c.tcpc_client)
+   offset = RSVD_00_ADDR;
+   else if (client == ctx->i2c.tx_p0_client)
+   offset = RSVD_D1_ADDR;
+   else if (client == ctx->i2c.tx_p1_client)
+   offset = RSVD_60_ADDR;
+   else if (client == ctx->i2c.rx_p0_client)
+   offset = RSVD_39_ADDR;
+   else if (client == ctx->i2c.rx_p1_client)
+   offset = RSVD_7F_ADDR;
+   else
+   offset = RSVD_00_ADDR;
+
+   ret = i2c_smbus_write_byte_data(client, offset, 0x00);
+   if (ret < 0)
+   DRM_DEV_ERROR(dev,
+ "fail to access i2c id=%x\n:%x",
+ client->addr, offset);
+
+   return ret;
+}
+
+static int anx7625_reg_read(struct anx7625_data *ctx,
+   struct i2c_client *client, u8 reg_addr)
+{
+   int ret;
+   struct device *dev = &client->dev;
+
+   i2c_access_workaround(ctx, client);
+
+   ret = i2c_smbus_read_byte_data(client, reg_addr);
+   if (ret < 0)
+   DRM_DEV_ERROR(dev, "read i2c fail id=%x:%x\n",
+ client->addr, reg_addr);
+
+   return ret;
+}
+
+static int anx7625_reg_block_read(struct anx7625_data *ctx,
+ struct i2c_client *client,
+ u8 reg_addr, u8 len, u8 *buf)
+{
+   int ret;
+   struct device *dev = &client->dev;
+
+   i2c_access_workaround(ctx, client);
+
+   ret = i2c_smbus_read_i2c_block_data(client, reg_addr, len, buf);
+   if (ret < 0)
+   DRM_DEV_ERROR(dev, "read i2c block fail id=%x:%x\n",
+ client->addr, reg_addr);
+
+   return ret;
+}
+
+static int anx7625_reg_write(struct anx7625_data *ctx,
+struct i2c_client *client,
+u8 reg_addr, u8 reg_v

[PATCH v12 1/2] dt-bindings: drm/bridge: anx7625: MIPI to DP transmitter DT schema

2020-06-04 Thread Xin Ji
anx7625: MIPI to DP transmitter DT schema

Signed-off-by: Xin Ji 
---
 .../bindings/display/bridge/analogix,anx7625.yaml  | 95 ++
 1 file changed, 95 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml

diff --git 
a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml 
b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
new file mode 100644
index 000..60585a4
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
@@ -0,0 +1,95 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+# Copyright 2019 Analogix Semiconductor, Inc.
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/display/bridge/analogix,anx7625.yaml#";
+$schema: "http://devicetree.org/meta-schemas/core.yaml#";
+
+title: Analogix ANX7625 SlimPort (4K Mobile HD Transmitter)
+
+maintainers:
+  - Xin Ji 
+
+description: |
+  The ANX7625 is an ultra-low power 4K Mobile HD Transmitter
+  designed for portable devices.
+
+properties:
+  compatible:
+items:
+  - const: analogix,anx7625
+
+  reg:
+maxItems: 1
+
+  interrupts:
+description: used for interrupt pin B8.
+maxItems: 1
+
+  enable-gpios:
+description: used for power on chip control, POWER_EN pin D2.
+maxItems: 1
+
+  reset-gpios:
+description: used for reset chip control, RESET_N pin B7.
+maxItems: 1
+
+  ports:
+type: object
+
+properties:
+  port@0:
+type: object
+description:
+  Video port for MIPI DSI input.
+
+  port@1:
+type: object
+description:
+  Video port for panel or connector.
+
+required:
+- port@0
+- port@1
+
+required:
+  - compatible
+  - reg
+  - ports
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+
+i2c0 {
+#address-cells = <1>;
+#size-cells = <0>;
+
+encoder@58 {
+compatible = "analogix,anx7625";
+reg = <0x58>;
+enable-gpios = <&pio 45 GPIO_ACTIVE_HIGH>;
+reset-gpios = <&pio 73 GPIO_ACTIVE_HIGH>;
+
+ports {
+#address-cells = <1>;
+#size-cells = <0>;
+
+mipi2dp_bridge_in: port@0 {
+reg = <0>;
+anx7625_in: endpoint {
+remote-endpoint = <&mipi_dsi>;
+};
+};
+
+mipi2dp_bridge_out: port@1 {
+reg = <1>;
+anx7625_out: endpoint {
+remote-endpoint = <&panel_in>;
+};
+};
+};
+};
+};
-- 
2.7.4



[PATCH v12 0/2] Add initial support for slimport anx7625

2020-06-04 Thread Xin Ji
Hi all,

The following series add support for the Slimport ANX7625 transmitter, a
ultra-low power Full-HD 4K MIPI to DP transmitter designed for portable device.


This is the v12 version, any mistakes, please let me know, I will fix it in
the next series.

Change history:
v12: Fix comments from Hsin-Yi Wang
 - Rebase the code on kernel 5.7, fix DRM interface not match issue.

v11: Fix comments from Rob Herring
 - Update commit message.
 - Remove unused label.

v10: Fix comments from Rob Herring, Daniel.
 - Fix dt_binding_check warning.
 - Update description.

v9: Fix comments from Sam, Nicolas, Daniel
 - Remove extcon interface.
 - Remove DPI support.
 - Fix dt_binding_check complains.
 - Code clean up and update description.

v8: Fix comments from Nicolas.
 - Fix several coding format.
 - Update description.

v7:
 - Fix critical timing(eg:odd hfp/hbp) in "mode_fixup" interface,
   enhance MIPI RX tolerance by setting register MIPI_DIGITAL_ADJ_1 to 0x3D.

Xin Ji (2):
  dt-bindings: drm/bridge: anx7625: MIPI to DP transmitter DT schema
  drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP

 .../bindings/display/bridge/analogix,anx7625.yaml  |   95 +
 drivers/gpu/drm/bridge/analogix/Kconfig|9 +
 drivers/gpu/drm/bridge/analogix/Makefile   |1 +
 drivers/gpu/drm/bridge/analogix/anx7625.c  | 1961 
 drivers/gpu/drm/bridge/analogix/anx7625.h  |  397 
 5 files changed, 2463 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.c
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.h

-- 
2.7.4



Re: [PATCH v11 2/2] drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP bridge driver

2020-06-04 Thread Xin Ji
On Mon, Jun 01, 2020 at 12:14:09PM +0800, Hsin-Yi Wang wrote:
> On Fri, May 15, 2020 at 2:53 PM Xin Ji  wrote:
> 
> > +
> > +static int anx7625_bridge_attach(struct drm_bridge *bridge)
> 
> Latest drm_bridge api:
> 
> int (*attach)(struct drm_bridge *bridge,
>  enum drm_bridge_attach_flags flags);
> 
> https://elixir.bootlin.com/linux/v5.7-rc7/source/include/drm/drm_bridge.h#L70
> 
> > +{
> > +   struct anx7625_data *ctx = bridge_to_anx7625(bridge);
> > +   int err;
Hi Hsin-Yi, thanks for the comment, I'll fix it in the version v12

Thanks,
Xin


[PATCH v11 2/2] drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP bridge driver

2020-05-14 Thread Xin Ji
The ANX7625 is an ultra-low power 4K Mobile HD Transmitter designed
for portable device. It converts MIPI DSI/DPI to DisplayPort 1.3 4K.

The ANX7625 can support both USB Type-C PD feature and MIPI DSI/DPI
to DP feature. This driver only enabled MIPI DSI/DPI to DP feature.

Signed-off-by: Xin Ji 
---
 drivers/gpu/drm/bridge/Makefile   |2 +-
 drivers/gpu/drm/bridge/analogix/Kconfig   |8 +
 drivers/gpu/drm/bridge/analogix/Makefile  |1 +
 drivers/gpu/drm/bridge/analogix/anx7625.c | 1961 +
 drivers/gpu/drm/bridge/analogix/anx7625.h |  397 ++
 5 files changed, 2368 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.c
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.h

diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile
index 4934fcf..bcd388a 100644
--- a/drivers/gpu/drm/bridge/Makefile
+++ b/drivers/gpu/drm/bridge/Makefile
@@ -12,8 +12,8 @@ obj-$(CONFIG_DRM_SII9234) += sii9234.o
 obj-$(CONFIG_DRM_THINE_THC63LVD1024) += thc63lvd1024.o
 obj-$(CONFIG_DRM_TOSHIBA_TC358764) += tc358764.o
 obj-$(CONFIG_DRM_TOSHIBA_TC358767) += tc358767.o
-obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix/
 obj-$(CONFIG_DRM_I2C_ADV7511) += adv7511/
 obj-$(CONFIG_DRM_TI_SN65DSI86) += ti-sn65dsi86.o
 obj-$(CONFIG_DRM_TI_TFP410) += ti-tfp410.o
+obj-y += analogix/
 obj-y += synopsys/
diff --git a/drivers/gpu/drm/bridge/analogix/Kconfig 
b/drivers/gpu/drm/bridge/analogix/Kconfig
index e930ff9..c772be2 100644
--- a/drivers/gpu/drm/bridge/analogix/Kconfig
+++ b/drivers/gpu/drm/bridge/analogix/Kconfig
@@ -2,3 +2,11 @@
 config DRM_ANALOGIX_DP
tristate
depends on DRM
+
+config DRM_ANALOGIX_ANX7625
+   tristate "Analogix Anx7625 MIPI to DP interface support"
+   depends on DRM
+   depends on OF
+   help
+   ANX7625 is an ultra-low power 4K mobile HD transmitter designed
+   for portable devices. It converts MIPI/DPI to DisplayPort1.3 4K.
diff --git a/drivers/gpu/drm/bridge/analogix/Makefile 
b/drivers/gpu/drm/bridge/analogix/Makefile
index fdbf3fd..b6c4a19 100644
--- a/drivers/gpu/drm/bridge/analogix/Makefile
+++ b/drivers/gpu/drm/bridge/analogix/Makefile
@@ -1,3 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0-only
+obj-$(CONFIG_DRM_ANALOGIX_ANX7625) += anx7625.o
 analogix_dp-objs := analogix_dp_core.o analogix_dp_reg.o
 obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix_dp.o
diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
b/drivers/gpu/drm/bridge/analogix/anx7625.c
new file mode 100644
index 000..2afa869
--- /dev/null
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -0,0 +1,1961 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright(c) 2020, Analogix Semiconductor. All rights reserved.
+ *
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "anx7625.h"
+
+/*
+ * There is a sync issue while access I2C register between AP(CPU) and
+ * internal firmware(OCM), to avoid the race condition, AP should access
+ * the reserved slave address before slave address occurs changes.
+ */
+static int i2c_access_workaround(struct anx7625_data *ctx,
+struct i2c_client *client)
+{
+   u8 offset;
+   struct device *dev = &client->dev;
+   int ret;
+
+   if (client == ctx->last_client)
+   return 0;
+
+   ctx->last_client = client;
+
+   if (client == ctx->i2c.tcpc_client)
+   offset = RSVD_00_ADDR;
+   else if (client == ctx->i2c.tx_p0_client)
+   offset = RSVD_D1_ADDR;
+   else if (client == ctx->i2c.tx_p1_client)
+   offset = RSVD_60_ADDR;
+   else if (client == ctx->i2c.rx_p0_client)
+   offset = RSVD_39_ADDR;
+   else if (client == ctx->i2c.rx_p1_client)
+   offset = RSVD_7F_ADDR;
+   else
+   offset = RSVD_00_ADDR;
+
+   ret = i2c_smbus_write_byte_data(client, offset, 0x00);
+   if (ret < 0)
+   DRM_DEV_ERROR(dev,
+ "fail to access i2c id=%x\n:%x",
+ client->addr, offset);
+
+   return ret;
+}
+
+static int anx7625_reg_read(struct anx7625_data *ctx,
+   struct i2c_client *client, u8 reg_addr)
+{
+   int ret;
+   struct device *dev = &client->dev;
+
+   i2c_access_workaround(ctx, client);
+
+   ret = i2c_smbus_read_byte_data(client, reg_addr);
+   if (ret < 0)
+   DRM_DEV_ERROR(dev, "read i2c fail id=%x:%x\n",
+ client->addr, reg_addr);
+
+   return ret;
+}
+
+static int anx7625_reg_block_read(struct anx7625_data *ctx,
+  

[PATCH v11 1/2] dt-bindings: drm/bridge: anx7625: MIPI to DP transmitter DT schema

2020-05-14 Thread Xin Ji
anx7625: MIPI to DP transmitter DT schema

Signed-off-by: Xin Ji 
---
 .../bindings/display/bridge/analogix,anx7625.yaml  | 95 ++
 1 file changed, 95 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml

diff --git 
a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml 
b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
new file mode 100644
index 000..60585a4
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
@@ -0,0 +1,95 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+# Copyright 2019 Analogix Semiconductor, Inc.
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/display/bridge/analogix,anx7625.yaml#";
+$schema: "http://devicetree.org/meta-schemas/core.yaml#";
+
+title: Analogix ANX7625 SlimPort (4K Mobile HD Transmitter)
+
+maintainers:
+  - Xin Ji 
+
+description: |
+  The ANX7625 is an ultra-low power 4K Mobile HD Transmitter
+  designed for portable devices.
+
+properties:
+  compatible:
+items:
+  - const: analogix,anx7625
+
+  reg:
+maxItems: 1
+
+  interrupts:
+description: used for interrupt pin B8.
+maxItems: 1
+
+  enable-gpios:
+description: used for power on chip control, POWER_EN pin D2.
+maxItems: 1
+
+  reset-gpios:
+description: used for reset chip control, RESET_N pin B7.
+maxItems: 1
+
+  ports:
+type: object
+
+properties:
+  port@0:
+type: object
+description:
+  Video port for MIPI DSI input.
+
+  port@1:
+type: object
+description:
+  Video port for panel or connector.
+
+required:
+- port@0
+- port@1
+
+required:
+  - compatible
+  - reg
+  - ports
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+
+i2c0 {
+#address-cells = <1>;
+#size-cells = <0>;
+
+encoder@58 {
+compatible = "analogix,anx7625";
+reg = <0x58>;
+enable-gpios = <&pio 45 GPIO_ACTIVE_HIGH>;
+reset-gpios = <&pio 73 GPIO_ACTIVE_HIGH>;
+
+ports {
+#address-cells = <1>;
+#size-cells = <0>;
+
+mipi2dp_bridge_in: port@0 {
+reg = <0>;
+anx7625_in: endpoint {
+remote-endpoint = <&mipi_dsi>;
+};
+};
+
+mipi2dp_bridge_out: port@1 {
+reg = <1>;
+anx7625_out: endpoint {
+remote-endpoint = <&panel_in>;
+};
+};
+};
+};
+};
-- 
2.7.4



[PATCH v11 0/2] Add initial support for slimport anx7625

2020-05-14 Thread Xin Ji
Hi all,

The following series add support for the Slimport ANX7625 transmitter, a
ultra-low power Full-HD 4K MIPI to DP transmitter designed for portable device.


This is the v11 version, any mistakes, please let me know, I will fix it in
the next series.

Change history:
v11: Fix comments from Rob Herring
 - Update commit message.
 - Remove unused label.

v10: Fix comments from Rob Herring, Daniel.
 - Fix dt_binding_check warning.
 - Update description.

v9: Fix comments from Sam, Nicolas, Daniel
 - Remove extcon interface.
 - Remove DPI support.
 - Fix dt_binding_check complains.
 - Code clean up and update description.

v8: Fix comments from Nicolas.
 - Fix several coding format.
 - Update description.

v7:
 - Fix critical timing(eg:odd hfp/hbp) in "mode_fixup" interface,
   enhance MIPI RX tolerance by setting register MIPI_DIGITAL_ADJ_1 to 0x3D.


Xin Ji (2):
  dt-bindings: drm/bridge: anx7625: MIPI to DP transmitter DT schema
  drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP bridge driver

 .../bindings/display/bridge/analogix,anx7625.yaml  |   95 +
 drivers/gpu/drm/bridge/Makefile|2 +-
 drivers/gpu/drm/bridge/analogix/Kconfig|8 +
 drivers/gpu/drm/bridge/analogix/Makefile   |1 +
 drivers/gpu/drm/bridge/analogix/anx7625.c  | 1961 
 drivers/gpu/drm/bridge/analogix/anx7625.h  |  397 
 6 files changed, 2463 insertions(+), 1 deletion(-)
 create mode 100644 
Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.c
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.h

-- 
2.7.4



Re: [PATCH v10 1/2] dt-bindings: drm/bridge: anx7625: MIPI to DP transmitter binding

2020-05-14 Thread Xin Ji
Hi Rob Herring,

Thanks for your comments.

On Thu, May 14, 2020 at 09:54:32AM -0500, Rob Herring wrote:
> On Wed, May 06, 2020 at 03:04:20PM +0800, Xin Ji wrote:
> > The ANX7625 is an ultra-low power 4K Mobile HD Transmitter designed
> > for portable device. It converts MIPI to DisplayPort 1.3 4K.
> > 
> > You can add support to your board with binding.
> 
> We have an example in the binding, no reason to also put in the commit 
> msg.
OK
> 
> > 
> > Example:
> > anx7625_bridge: encoder@58 {
> > compatible = "analogix,anx7625";
> > reg = <0x58>;
> > status = "okay";
> > enable-gpios = <&pio 45 GPIO_ACTIVE_HIGH>;
> > reset-gpios = <&pio 73 GPIO_ACTIVE_HIGH>;
> > 
> > ports {
> > #address-cells = <1>;
> > #size-cells = <0>;
> > 
> > mipi2dp_bridge_in: port@0 {
> > reg = <0>;
> > anx7625_in: endpoint {
> > remote-endpoint = <&mipi_dsi>;
> > };
> > };
> > 
> > mipi2dp_bridge_out: port@1 {
> > reg = <1>;
> > anx7625_out: endpoint {
> > remote-endpoint = <&panel_in>;
> > };
> > };
> > };
> > };
> > 
> > Signed-off-by: Xin Ji 
> > ---
> >  .../bindings/display/bridge/analogix,anx7625.yaml  | 98 
> > ++
> >  1 file changed, 98 insertions(+)
> >  create mode 100644 
> > Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > 
> > diff --git 
> > a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml 
> > b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > new file mode 100644
> > index 000..6e54176
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > @@ -0,0 +1,98 @@
> > +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> > +# Copyright 2019 Analogix Semiconductor, Inc.
> > +%YAML 1.2
> > +---
> > +$id: "http://devicetree.org/schemas/display/bridge/analogix,anx7625.yaml#";
> > +$schema: "http://devicetree.org/meta-schemas/core.yaml#";
> > +
> > +title: Analogix ANX7625 SlimPort (4K Mobile HD Transmitter)
> > +
> > +maintainers:
> > +  - Xin Ji 
> > +
> > +description: |
> > +  The ANX7625 is an ultra-low power 4K Mobile HD Transmitter
> > +  designed for portable devices.
> > +
> > +properties:
> > +  "#address-cells": true
> > +  "#size-cells": true
> 
> These don't belong here.
OK
> 
> > +
> > +  compatible:
> > +items:
> > +  - const: analogix,anx7625
> > +
> > +  reg:
> > +maxItems: 1
> > +
> > +  interrupts:
> > +description: used for interrupt pin B8.
> > +maxItems: 1
> > +
> > +  enable-gpios:
> > +description: used for power on chip control, POWER_EN pin D2.
> > +maxItems: 1
> > +
> > +  reset-gpios:
> > +description: used for reset chip control, RESET_N pin B7.
> > +maxItems: 1
> > +
> > +  ports:
> > +type: object
> > +
> > +properties:
> > +  port@0:
> > +type: object
> > +description:
> > +  Video port for MIPI DSI input.
> > +
> > +  port@1:
> > +type: object
> > +description:
> > +  Video port for panel or connector.
> > +
> > +required:
> > +- port@0
> > +- port@1
> > +
> > +required:
> > +  - compatible
> > +  - reg
> > +  - ports
> > +
> > +additionalProperties: false
> > +
> > +examples:
> > +  - |
> > +#include 
> > +
> > +i2c0 {
> > +#address-cells = <1>;
> > +#size-cells = <0>;
> > +
> > +anx7625_bridge: encoder@58 {
> 
> Drop any unused labels.
OK
> 
> > +compatible = "analogix,anx7625";
> > +reg = <0x58>;
> > +enable-gpios = <&pio 45 GPIO_ACTIVE_HIGH>;
> > +reset-gpios = <&pio 73 GPIO_ACTIVE_HIGH>;
> > +
> > +ports {
> > +#address-cells = <1>;
> > +#size-cells = <0>;
> > +
> > +mipi2dp_bridge_in: port@0 {
> > +reg = <0>;
> > +anx7625_in: endpoint {
> > +remote-endpoint = <&mipi_dsi>;
> > +};
> > +};
> > +
> > +mipi2dp_bridge_out: port@1 {
> > +reg = <1>;
> > +anx7625_out: endpoint {
> > +remote-endpoint = <&panel_in>;
> > +};
> > +};
> > +};
> > +};
> > +};
> > -- 
> > 2.7.4
> > 


[PATCH v10 2/2] drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP bridge driver

2020-05-06 Thread Xin Ji
The ANX7625 is an ultra-low power 4K Mobile HD Transmitter designed
for portable device. It converts MIPI DSI/DPI to DisplayPort 1.3 4K.

The ANX7625 can support both USB Type-C PD feature and MIPI DSI/DPI
to DP feature. This driver only enabled MIPI DSI/DPI to DP feature.

Signed-off-by: Xin Ji 
---
 drivers/gpu/drm/bridge/Makefile   |2 +-
 drivers/gpu/drm/bridge/analogix/Kconfig   |8 +
 drivers/gpu/drm/bridge/analogix/Makefile  |1 +
 drivers/gpu/drm/bridge/analogix/anx7625.c | 1961 +
 drivers/gpu/drm/bridge/analogix/anx7625.h |  397 ++
 5 files changed, 2368 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.c
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.h

diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile
index 4934fcf..bcd388a 100644
--- a/drivers/gpu/drm/bridge/Makefile
+++ b/drivers/gpu/drm/bridge/Makefile
@@ -12,8 +12,8 @@ obj-$(CONFIG_DRM_SII9234) += sii9234.o
 obj-$(CONFIG_DRM_THINE_THC63LVD1024) += thc63lvd1024.o
 obj-$(CONFIG_DRM_TOSHIBA_TC358764) += tc358764.o
 obj-$(CONFIG_DRM_TOSHIBA_TC358767) += tc358767.o
-obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix/
 obj-$(CONFIG_DRM_I2C_ADV7511) += adv7511/
 obj-$(CONFIG_DRM_TI_SN65DSI86) += ti-sn65dsi86.o
 obj-$(CONFIG_DRM_TI_TFP410) += ti-tfp410.o
+obj-y += analogix/
 obj-y += synopsys/
diff --git a/drivers/gpu/drm/bridge/analogix/Kconfig 
b/drivers/gpu/drm/bridge/analogix/Kconfig
index e930ff9..c772be2 100644
--- a/drivers/gpu/drm/bridge/analogix/Kconfig
+++ b/drivers/gpu/drm/bridge/analogix/Kconfig
@@ -2,3 +2,11 @@
 config DRM_ANALOGIX_DP
tristate
depends on DRM
+
+config DRM_ANALOGIX_ANX7625
+   tristate "Analogix Anx7625 MIPI to DP interface support"
+   depends on DRM
+   depends on OF
+   help
+   ANX7625 is an ultra-low power 4K mobile HD transmitter designed
+   for portable devices. It converts MIPI/DPI to DisplayPort1.3 4K.
diff --git a/drivers/gpu/drm/bridge/analogix/Makefile 
b/drivers/gpu/drm/bridge/analogix/Makefile
index fdbf3fd..b6c4a19 100644
--- a/drivers/gpu/drm/bridge/analogix/Makefile
+++ b/drivers/gpu/drm/bridge/analogix/Makefile
@@ -1,3 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0-only
+obj-$(CONFIG_DRM_ANALOGIX_ANX7625) += anx7625.o
 analogix_dp-objs := analogix_dp_core.o analogix_dp_reg.o
 obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix_dp.o
diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
b/drivers/gpu/drm/bridge/analogix/anx7625.c
new file mode 100644
index 000..2afa869
--- /dev/null
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -0,0 +1,1961 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright(c) 2020, Analogix Semiconductor. All rights reserved.
+ *
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "anx7625.h"
+
+/*
+ * There is a sync issue while access I2C register between AP(CPU) and
+ * internal firmware(OCM), to avoid the race condition, AP should access
+ * the reserved slave address before slave address occurs changes.
+ */
+static int i2c_access_workaround(struct anx7625_data *ctx,
+struct i2c_client *client)
+{
+   u8 offset;
+   struct device *dev = &client->dev;
+   int ret;
+
+   if (client == ctx->last_client)
+   return 0;
+
+   ctx->last_client = client;
+
+   if (client == ctx->i2c.tcpc_client)
+   offset = RSVD_00_ADDR;
+   else if (client == ctx->i2c.tx_p0_client)
+   offset = RSVD_D1_ADDR;
+   else if (client == ctx->i2c.tx_p1_client)
+   offset = RSVD_60_ADDR;
+   else if (client == ctx->i2c.rx_p0_client)
+   offset = RSVD_39_ADDR;
+   else if (client == ctx->i2c.rx_p1_client)
+   offset = RSVD_7F_ADDR;
+   else
+   offset = RSVD_00_ADDR;
+
+   ret = i2c_smbus_write_byte_data(client, offset, 0x00);
+   if (ret < 0)
+   DRM_DEV_ERROR(dev,
+ "fail to access i2c id=%x\n:%x",
+ client->addr, offset);
+
+   return ret;
+}
+
+static int anx7625_reg_read(struct anx7625_data *ctx,
+   struct i2c_client *client, u8 reg_addr)
+{
+   int ret;
+   struct device *dev = &client->dev;
+
+   i2c_access_workaround(ctx, client);
+
+   ret = i2c_smbus_read_byte_data(client, reg_addr);
+   if (ret < 0)
+   DRM_DEV_ERROR(dev, "read i2c fail id=%x:%x\n",
+ client->addr, reg_addr);
+
+   return ret;
+}
+
+static int anx7625_reg_block_read(struct anx7625_data *ctx,
+  

[PATCH v10 1/2] dt-bindings: drm/bridge: anx7625: MIPI to DP transmitter binding

2020-05-06 Thread Xin Ji
The ANX7625 is an ultra-low power 4K Mobile HD Transmitter designed
for portable device. It converts MIPI to DisplayPort 1.3 4K.

You can add support to your board with binding.

Example:
anx7625_bridge: encoder@58 {
compatible = "analogix,anx7625";
reg = <0x58>;
status = "okay";
enable-gpios = <&pio 45 GPIO_ACTIVE_HIGH>;
reset-gpios = <&pio 73 GPIO_ACTIVE_HIGH>;

ports {
#address-cells = <1>;
#size-cells = <0>;

mipi2dp_bridge_in: port@0 {
reg = <0>;
anx7625_in: endpoint {
remote-endpoint = <&mipi_dsi>;
};
};

mipi2dp_bridge_out: port@1 {
reg = <1>;
anx7625_out: endpoint {
remote-endpoint = <&panel_in>;
        };
};
};
};

Signed-off-by: Xin Ji 
---
 .../bindings/display/bridge/analogix,anx7625.yaml  | 98 ++
 1 file changed, 98 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml

diff --git 
a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml 
b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
new file mode 100644
index 000..6e54176
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
@@ -0,0 +1,98 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+# Copyright 2019 Analogix Semiconductor, Inc.
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/display/bridge/analogix,anx7625.yaml#";
+$schema: "http://devicetree.org/meta-schemas/core.yaml#";
+
+title: Analogix ANX7625 SlimPort (4K Mobile HD Transmitter)
+
+maintainers:
+  - Xin Ji 
+
+description: |
+  The ANX7625 is an ultra-low power 4K Mobile HD Transmitter
+  designed for portable devices.
+
+properties:
+  "#address-cells": true
+  "#size-cells": true
+
+  compatible:
+items:
+  - const: analogix,anx7625
+
+  reg:
+maxItems: 1
+
+  interrupts:
+description: used for interrupt pin B8.
+maxItems: 1
+
+  enable-gpios:
+description: used for power on chip control, POWER_EN pin D2.
+maxItems: 1
+
+  reset-gpios:
+description: used for reset chip control, RESET_N pin B7.
+maxItems: 1
+
+  ports:
+type: object
+
+properties:
+  port@0:
+type: object
+description:
+  Video port for MIPI DSI input.
+
+  port@1:
+type: object
+description:
+  Video port for panel or connector.
+
+required:
+- port@0
+- port@1
+
+required:
+  - compatible
+  - reg
+  - ports
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+
+i2c0 {
+#address-cells = <1>;
+#size-cells = <0>;
+
+anx7625_bridge: encoder@58 {
+compatible = "analogix,anx7625";
+reg = <0x58>;
+enable-gpios = <&pio 45 GPIO_ACTIVE_HIGH>;
+reset-gpios = <&pio 73 GPIO_ACTIVE_HIGH>;
+
+ports {
+#address-cells = <1>;
+#size-cells = <0>;
+
+mipi2dp_bridge_in: port@0 {
+reg = <0>;
+anx7625_in: endpoint {
+remote-endpoint = <&mipi_dsi>;
+};
+};
+
+mipi2dp_bridge_out: port@1 {
+reg = <1>;
+anx7625_out: endpoint {
+remote-endpoint = <&panel_in>;
+};
+};
+};
+};
+};
-- 
2.7.4



[PATCH v10 0/2] Add initial support for slimport anx7625

2020-05-06 Thread Xin Ji
Hi all,

The following series add support for the Slimport ANX7625 transmitter, a
ultra-low power Full-HD 4K MIPI to DP transmitter designed for portable device.


This is the v10 version, any mistakes, please let me know, I will fix it in
the next series.

Change history:
v10: Fix comments from Rob Herring, Daniel.
 - Fix dt_binding_check warning.
 - Update description.

v9: Fix comments from Sam, Nicolas, Daniel
 - Remove extcon interface.
 - Remove DPI support.
 - Fix dt_binding_check complains.
 - Code clean up and update description.

v8: Fix comments from Nicolas.
 - Fix several coding format.
 - Update description.

v7:
 - Fix critical timing(eg:odd hfp/hbp) in "mode_fixup" interface,
   enhance MIPI RX tolerance by setting register MIPI_DIGITAL_ADJ_1 to 0x3D.


Xin Ji (2):
  dt-bindings: drm/bridge: anx7625: MIPI to DP transmitter binding
  drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP bridge driver

 .../bindings/display/bridge/analogix,anx7625.yaml  |   98 +
 drivers/gpu/drm/bridge/Makefile|2 +-
 drivers/gpu/drm/bridge/analogix/Kconfig|8 +
 drivers/gpu/drm/bridge/analogix/Makefile   |1 +
 drivers/gpu/drm/bridge/analogix/anx7625.c  | 1961 
 drivers/gpu/drm/bridge/analogix/anx7625.h  |  397 
 6 files changed, 2466 insertions(+), 1 deletion(-)
 create mode 100644 
Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.c
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.h

-- 
2.7.4



Re: [PATCH v9 1/2] dt-bindings: drm/bridge: anx7625: MIPI to DP transmitter binding

2020-05-05 Thread Xin Ji
On Fri, May 01, 2020 at 04:11:50PM -0500, Rob Herring wrote:
> On Thu, 30 Apr 2020 17:34:11 +0800, Xin Ji wrote:
> > The ANX7625 is an ultra-low power 4K Mobile HD Transmitter designed
> > for portable device. It converts MIPI to DisplayPort 1.3 4K.
> > 
> > You can add support to your board with binding.
> > 
> > Example:
> > anx7625_bridge: encoder@58 {
> > compatible = "analogix,anx7625";
> > reg = <0x58>;
> > status = "okay";
> > enable-gpios = <&pio 45 GPIO_ACTIVE_HIGH>;
> > reset-gpios = <&pio 73 GPIO_ACTIVE_HIGH>;
> > #address-cells = <1>;
> > #size-cells = <0>;
> > 
> > ports {
> > #address-cells = <1>;
> > #size-cells = <0>;
> > 
> > mipi2dp_bridge_in: port@0 {
> > reg = <0>;
> > anx7625_in: endpoint {
> > remote-endpoint = <&mipi_dsi>;
> > };
> > };
> > 
> > mipi2dp_bridge_out: port@1 {
> >     reg = <1>;
> > anx7625_out: endpoint {
> > remote-endpoint = <&panel_in>;
> > };
> > };
> > };
> > };
> > 
> > Signed-off-by: Xin Ji 
> > ---
> >  .../bindings/display/bridge/analogix,anx7625.yaml  | 97 
> > ++
> >  1 file changed, 97 insertions(+)
> >  create mode 100644 
> > Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
> > 
> 
> My bot found errors running 'make dt_binding_check' on your patch:
> 
> Documentation/devicetree/bindings/display/bridge/analogix,anx7625.example.dts:21.13-26:
>  Warning (reg_format): /example-0/encoder@58:reg: property has invalid length 
> (4 bytes) (#address-cells == 1, #size-cells == 1)
> Documentation/devicetree/bindings/display/bridge/analogix,anx7625.example.dt.yaml:
>  Warning (pci_device_reg): Failed prerequisite 'reg_format'
> Documentation/devicetree/bindings/display/bridge/analogix,anx7625.example.dt.yaml:
>  Warning (pci_device_bus_num): Failed prerequisite 'reg_format'
> Documentation/devicetree/bindings/display/bridge/analogix,anx7625.example.dt.yaml:
>  Warning (simple_bus_reg): Failed prerequisite 'reg_format'
> Documentation/devicetree/bindings/display/bridge/analogix,anx7625.example.dt.yaml:
>  Warning (i2c_bus_reg): Failed prerequisite 'reg_format'
> Documentation/devicetree/bindings/display/bridge/analogix,anx7625.example.dt.yaml:
>  Warning (spi_bus_reg): Failed prerequisite 'reg_format'
> 
> See https://patchwork.ozlabs.org/patch/1280084
> 
> If you already ran 'make dt_binding_check' and didn't see the above
> error(s), then make sure dt-schema is up to date:
> 
> pip3 install git+https://github.com/devicetree-org/dt-schema.git@master 
> --upgrade
Hi, thanks, I'll fix the warning in the next serial.

Thanks,
Xin
> 
> Please check and re-submit.


Re: [PATCH v7 2/2] drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP bridge driver

2020-04-30 Thread Xin Ji
On Thu, Apr 30, 2020 at 03:54:38PM +0200, Daniel Vetter wrote:
> On Thu, Apr 30, 2020 at 09:47:46PM +0800, Xin Ji wrote:
> > Hi Daniel,
> > 
> > On Thu, Apr 30, 2020 at 03:38:39PM +0200, Daniel Vetter wrote:
> > > On Thu, Apr 30, 2020 at 03:37:31PM +0200, Daniel Vetter wrote:
> > > > On Thu, Apr 30, 2020 at 11:36:14AM +0800, Xin Ji wrote:
> > > > > On Tue, Apr 28, 2020 at 12:05:08PM +0200, Daniel Vetter wrote:
> > > > > > On Fri, Apr 24, 2020 at 08:12:04PM +0800, Nicolas Boichat wrote:
> > > > > > > On Fri, Apr 24, 2020 at 2:51 PM Xin Ji  
> > > > > > > wrote:
> > > > > > > >
> > > > > > > > On Thu, Apr 23, 2020 at 07:55:15PM +0800, Nicolas Boichat wrote:
> > > > > > > > > Hi,
> > > > > > > > >
> > > > > > > > > Just commenting on the mode_fixup function that was added in 
> > > > > > > > > v7.
> > > > > > > > >
> > > > > > > > [snip]
> > > > > > > > > > +   /*
> > > > > > > > > > +* once illegal timing detected, use default HFP, 
> > > > > > > > > > HSYNC, HBP
> > > > > > > > > > +*/
> > > > > > > > > > +   if (hblanking < HBLANKING_MIN || (hfp < HP_MIN && 
> > > > > > > > > > hbp < HP_MIN)) {
> > > > > > > > >
> > > > > > > > > should this be adj_hblanking/adj_hfp/adj_hbp?
> > > > > > > > NO, need check original HFP and HBP, if they are not legal, 
> > > > > > > > driver need
> > > > > > > > set default value to adj_hsync, adj_hfp, adj_hbp.
> > > > > > > > >
> > > > > > > > > > +   adj_hsync = SYNC_LEN_DEF;
> > > > > > > > > > +   adj_hfp = HFP_HBP_DEF;
> > > > > > > > > > +   adj_hbp = HFP_HBP_DEF;
> > > > > > > > > > +   vref = adj->clock * 1000 / (adj->htotal * 
> > > > > > > > > > adj->vtotal);
> > > > > > > > > > +   if (hblanking < HBLANKING_MIN) {
> > > > > > > > > > +   delta_adj = HBLANKING_MIN - 
> > > > > > > > > > hblanking;
> > > > > > > > > > +   adj_clock = vref * delta_adj * 
> > > > > > > > > > adj->vtotal;
> > > > > > > > > > +   adj->clock += 
> > > > > > > > > > DIV_ROUND_UP(adj_clock, 1000);
> > > > > > > > > > +   } else {
> > > > > > > > > > +   delta_adj = hblanking - 
> > > > > > > > > > HBLANKING_MIN;
> > > > > > > > > > +   adj_clock = vref * delta_adj * 
> > > > > > > > > > adj->vtotal;
> > > > > > > > > > +   adj->clock -= 
> > > > > > > > > > DIV_ROUND_UP(adj_clock, 1000);
> > > > > > > > > > +   }
> > > > > > > > > > +
> > > > > > > > > > +   DRM_WARN("illegal hblanking timing, use 
> > > > > > > > > > default.\n");
> > > > > > > > > > +   DRM_WARN("hfp(%d),hbp(%d),hsync(%d).\n", 
> > > > > > > > > > hfp, hbp, hsync);
> > > > > > > > >
> > > > > > > > > How likely is it that this mode is going to work? Can you 
> > > > > > > > > just return
> > > > > > > > > false here to reject the mode?
> > > > > > > > We want to set the default minimal Hblancking value, then it 
> > > > > > > > may display,
> > > > > > > > otherwise. If we just return false, there is no display for 
> > > > > > > > sure.
> > > > > > > 
> > > > > > > Right, understand your argument. I'm pondering if it's not just 
> > > > > > > better
> > 

Re: [PATCH v7 2/2] drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP bridge driver

2020-04-30 Thread Xin Ji
Hi Daniel,

On Thu, Apr 30, 2020 at 03:38:39PM +0200, Daniel Vetter wrote:
> On Thu, Apr 30, 2020 at 03:37:31PM +0200, Daniel Vetter wrote:
> > On Thu, Apr 30, 2020 at 11:36:14AM +0800, Xin Ji wrote:
> > > On Tue, Apr 28, 2020 at 12:05:08PM +0200, Daniel Vetter wrote:
> > > > On Fri, Apr 24, 2020 at 08:12:04PM +0800, Nicolas Boichat wrote:
> > > > > On Fri, Apr 24, 2020 at 2:51 PM Xin Ji  wrote:
> > > > > >
> > > > > > On Thu, Apr 23, 2020 at 07:55:15PM +0800, Nicolas Boichat wrote:
> > > > > > > Hi,
> > > > > > >
> > > > > > > Just commenting on the mode_fixup function that was added in v7.
> > > > > > >
> > > > > > [snip]
> > > > > > > > +   /*
> > > > > > > > +* once illegal timing detected, use default HFP, 
> > > > > > > > HSYNC, HBP
> > > > > > > > +*/
> > > > > > > > +   if (hblanking < HBLANKING_MIN || (hfp < HP_MIN && hbp < 
> > > > > > > > HP_MIN)) {
> > > > > > >
> > > > > > > should this be adj_hblanking/adj_hfp/adj_hbp?
> > > > > > NO, need check original HFP and HBP, if they are not legal, driver 
> > > > > > need
> > > > > > set default value to adj_hsync, adj_hfp, adj_hbp.
> > > > > > >
> > > > > > > > +   adj_hsync = SYNC_LEN_DEF;
> > > > > > > > +   adj_hfp = HFP_HBP_DEF;
> > > > > > > > +   adj_hbp = HFP_HBP_DEF;
> > > > > > > > +   vref = adj->clock * 1000 / (adj->htotal * 
> > > > > > > > adj->vtotal);
> > > > > > > > +   if (hblanking < HBLANKING_MIN) {
> > > > > > > > +   delta_adj = HBLANKING_MIN - hblanking;
> > > > > > > > +   adj_clock = vref * delta_adj * 
> > > > > > > > adj->vtotal;
> > > > > > > > +   adj->clock += DIV_ROUND_UP(adj_clock, 
> > > > > > > > 1000);
> > > > > > > > +   } else {
> > > > > > > > +   delta_adj = hblanking - HBLANKING_MIN;
> > > > > > > > +   adj_clock = vref * delta_adj * 
> > > > > > > > adj->vtotal;
> > > > > > > > +   adj->clock -= DIV_ROUND_UP(adj_clock, 
> > > > > > > > 1000);
> > > > > > > > +   }
> > > > > > > > +
> > > > > > > > +   DRM_WARN("illegal hblanking timing, use 
> > > > > > > > default.\n");
> > > > > > > > +   DRM_WARN("hfp(%d),hbp(%d),hsync(%d).\n", hfp, 
> > > > > > > > hbp, hsync);
> > > > > > >
> > > > > > > How likely is it that this mode is going to work? Can you just 
> > > > > > > return
> > > > > > > false here to reject the mode?
> > > > > > We want to set the default minimal Hblancking value, then it may 
> > > > > > display,
> > > > > > otherwise. If we just return false, there is no display for sure.
> > > > > 
> > > > > Right, understand your argument. I'm pondering if it's not just better
> > > > > to reject the mode rather than trying a timing that is definitely
> > > > > quite different from what the monitor was asking for. No super strong
> > > > > opinion, I'll let other people on the list weigh in.
> > > > 
> > > > Yeah mode_fixup is supposed to be used to adjust the mode in 
> > > > intermediate
> > > > stages (e.g. if you go from progressive to interlaced only at the end of
> > > > your pipeline or something like that). It's not meant for adjusting the
> > > > mode yout actually put out through a hdmi or dp connector. For fixed
> > > > panels adjusting modes to fit the panel is also fairly common, but not 
> > > > for
> > > > external outputs.
> > > > 
> > > > Since this is a DP bridge I'd say no adjusting, just reject what doesn't
> > > > fit.
> > > We have found some panel which HBP less than 8, if we reject to adjust
> > > video timing, then there is no display. The customer does not accept it,
> > > they push us to fix it, the only resolve way is to adjust timing.
> > 
> > Are we talking about external DP screen here, or some built-in panel? For
> > the later case we do a lot of mode adjusting in many drivers ...
> > 
> > I haven't checked, by if our connector type is eDP then this should be all
> > fine.
> 
> Ok I read the patch now, you seem to support both. Would it work if we
> make this adjustement conditional on it being an internal panel only? I
> think that would be perfect.
> -Daniel
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
Based on comments of V8, only keeped eDP built-in panel in V9 version,
removed external DP screen support.
> http://blog.ffwll.ch


[PATCH v9 2/2] drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP bridge driver

2020-04-30 Thread Xin Ji
The ANX7625 is an ultra-low power 4K Mobile HD Transmitter designed
for portable device. It converts MIPI DSI/DPI to DisplayPort 1.3 4K.

The ANX7625 can support both USB Type-C PD feature and MIPI DSI/DPI
to DP feature. This driver only enabled MIPI DSI/DPI to DP feature.

Signed-off-by: Xin Ji 
---
 drivers/gpu/drm/bridge/Makefile   |2 +-
 drivers/gpu/drm/bridge/analogix/Kconfig   |8 +
 drivers/gpu/drm/bridge/analogix/Makefile  |1 +
 drivers/gpu/drm/bridge/analogix/anx7625.c | 1959 +
 drivers/gpu/drm/bridge/analogix/anx7625.h |  397 ++
 5 files changed, 2366 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.c
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.h

diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile
index 4934fcf..bcd388a 100644
--- a/drivers/gpu/drm/bridge/Makefile
+++ b/drivers/gpu/drm/bridge/Makefile
@@ -12,8 +12,8 @@ obj-$(CONFIG_DRM_SII9234) += sii9234.o
 obj-$(CONFIG_DRM_THINE_THC63LVD1024) += thc63lvd1024.o
 obj-$(CONFIG_DRM_TOSHIBA_TC358764) += tc358764.o
 obj-$(CONFIG_DRM_TOSHIBA_TC358767) += tc358767.o
-obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix/
 obj-$(CONFIG_DRM_I2C_ADV7511) += adv7511/
 obj-$(CONFIG_DRM_TI_SN65DSI86) += ti-sn65dsi86.o
 obj-$(CONFIG_DRM_TI_TFP410) += ti-tfp410.o
+obj-y += analogix/
 obj-y += synopsys/
diff --git a/drivers/gpu/drm/bridge/analogix/Kconfig 
b/drivers/gpu/drm/bridge/analogix/Kconfig
index e930ff9..c772be2 100644
--- a/drivers/gpu/drm/bridge/analogix/Kconfig
+++ b/drivers/gpu/drm/bridge/analogix/Kconfig
@@ -2,3 +2,11 @@
 config DRM_ANALOGIX_DP
tristate
depends on DRM
+
+config DRM_ANALOGIX_ANX7625
+   tristate "Analogix Anx7625 MIPI to DP interface support"
+   depends on DRM
+   depends on OF
+   help
+   ANX7625 is an ultra-low power 4K mobile HD transmitter designed
+   for portable devices. It converts MIPI/DPI to DisplayPort1.3 4K.
diff --git a/drivers/gpu/drm/bridge/analogix/Makefile 
b/drivers/gpu/drm/bridge/analogix/Makefile
index fdbf3fd..b6c4a19 100644
--- a/drivers/gpu/drm/bridge/analogix/Makefile
+++ b/drivers/gpu/drm/bridge/analogix/Makefile
@@ -1,3 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0-only
+obj-$(CONFIG_DRM_ANALOGIX_ANX7625) += anx7625.o
 analogix_dp-objs := analogix_dp_core.o analogix_dp_reg.o
 obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix_dp.o
diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
b/drivers/gpu/drm/bridge/analogix/anx7625.c
new file mode 100644
index 000..eb7162e
--- /dev/null
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -0,0 +1,1959 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright(c) 2020, Analogix Semiconductor. All rights reserved.
+ *
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "anx7625.h"
+
+/*
+ * There is a sync issue while access I2C register between AP(CPU) and
+ * internal firmware(OCM), to avoid the race condition, AP should access
+ * the reserved slave address before slave address occurs changes.
+ */
+static int i2c_access_workaround(struct anx7625_data *ctx,
+struct i2c_client *client)
+{
+   u8 offset;
+   struct device *dev = &client->dev;
+   int ret;
+
+   if (client == ctx->last_client)
+   return 0;
+
+   ctx->last_client = client;
+
+   if (client == ctx->i2c.tcpc_client)
+   offset = RSVD_00_ADDR;
+   else if (client == ctx->i2c.tx_p0_client)
+   offset = RSVD_D1_ADDR;
+   else if (client == ctx->i2c.tx_p1_client)
+   offset = RSVD_60_ADDR;
+   else if (client == ctx->i2c.rx_p0_client)
+   offset = RSVD_39_ADDR;
+   else if (client == ctx->i2c.rx_p1_client)
+   offset = RSVD_7F_ADDR;
+   else
+   offset = RSVD_00_ADDR;
+
+   ret = i2c_smbus_write_byte_data(client, offset, 0x00);
+   if (ret < 0)
+   DRM_DEV_ERROR(dev,
+ "fail to access i2c id=%x\n:%x",
+ client->addr, offset);
+
+   return ret;
+}
+
+static int anx7625_reg_read(struct anx7625_data *ctx,
+   struct i2c_client *client, u8 reg_addr)
+{
+   int ret;
+   struct device *dev = &client->dev;
+
+   i2c_access_workaround(ctx, client);
+
+   ret = i2c_smbus_read_byte_data(client, reg_addr);
+   if (ret < 0)
+   DRM_DEV_ERROR(dev, "read i2c fail id=%x:%x\n",
+ client->addr, reg_addr);
+
+   return ret;
+}
+
+static int anx7625_reg_block_read(struct anx7625_data *ctx,
+  

[PATCH v9 1/2] dt-bindings: drm/bridge: anx7625: MIPI to DP transmitter binding

2020-04-30 Thread Xin Ji
The ANX7625 is an ultra-low power 4K Mobile HD Transmitter designed
for portable device. It converts MIPI to DisplayPort 1.3 4K.

You can add support to your board with binding.

Example:
anx7625_bridge: encoder@58 {
compatible = "analogix,anx7625";
reg = <0x58>;
status = "okay";
enable-gpios = <&pio 45 GPIO_ACTIVE_HIGH>;
reset-gpios = <&pio 73 GPIO_ACTIVE_HIGH>;
#address-cells = <1>;
#size-cells = <0>;

ports {
#address-cells = <1>;
#size-cells = <0>;

mipi2dp_bridge_in: port@0 {
reg = <0>;
anx7625_in: endpoint {
remote-endpoint = <&mipi_dsi>;
};
};

mipi2dp_bridge_out: port@1 {
reg = <1>;
anx7625_out: endpoint {
remote-endpoint = <&panel_in>;
        };
};
};
};

Signed-off-by: Xin Ji 
---
 .../bindings/display/bridge/analogix,anx7625.yaml  | 97 ++
 1 file changed, 97 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml

diff --git 
a/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml 
b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
new file mode 100644
index 000..c2c50b0
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
@@ -0,0 +1,97 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+# Copyright 2019 Analogix Semiconductor, Inc.
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/display/bridge/analogix,anx7625.yaml#";
+$schema: "http://devicetree.org/meta-schemas/core.yaml#";
+
+title: Analogix ANX7625 SlimPort (4K Mobile HD Transmitter)
+
+maintainers:
+  - Xin Ji 
+
+description: |
+  The ANX7625 is an ultra-low power 4K Mobile HD Transmitter
+  designed for portable devices.
+
+properties:
+  "#address-cells": true
+  "#size-cells": true
+
+  compatible:
+items:
+  - const: analogix,anx7625
+
+  reg:
+maxItems: 1
+
+  interrupts:
+description: used for interrupt pin B8.
+maxItems: 1
+
+  enable-gpios:
+description: used for power on chip control, POWER_EN pin D2.
+maxItems: 1
+
+  reset-gpios:
+description: used for reset chip control, RESET_N pin B7.
+maxItems: 1
+
+  ports:
+type: object
+
+properties:
+  port@0:
+type: object
+description:
+  Video port for MIPI DSI input.
+
+  port@1:
+type: object
+description:
+  Video port for panel or connector.
+
+required:
+- port@0
+- port@1
+
+required:
+  - "#address-cells"
+  - "#size-cells"
+  - compatible
+  - reg
+  - ports
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+
+anx7625_bridge: encoder@58 {
+compatible = "analogix,anx7625";
+reg = <0x58>;
+enable-gpios = <&pio 45 GPIO_ACTIVE_HIGH>;
+reset-gpios = <&pio 73 GPIO_ACTIVE_HIGH>;
+#address-cells = <1>;
+#size-cells = <0>;
+
+ports {
+#address-cells = <1>;
+#size-cells = <0>;
+
+mipi2dp_bridge_in: port@0 {
+reg = <0>;
+anx7625_in: endpoint {
+remote-endpoint = <&mipi_dsi>;
+};
+};
+
+mipi2dp_bridge_out: port@1 {
+reg = <1>;
+anx7625_out: endpoint {
+remote-endpoint = <&panel_in>;
+};
+};
+};
+};
-- 
2.7.4



[PATCH v9 0/2] Add initial support for slimport anx7625

2020-04-30 Thread Xin Ji
Hi all,

The following series add support for the Slimport ANX7625 transmitter, a
ultra-low power Full-HD 4K MIPI to DP transmitter designed for portable device.


This is the v9 version, any mistakes, please let me know, I will fix it in
the next series.

Change history:
v9: Fix comments from Sam, Nicolas, Daniel
 - Remove extcon interface.
 - Remove DPI support.
 - Fix dt_binding_check complains.
 - Code clean up and update description.

v8: Fix comments from Nicolas.
 - Fix several coding format.
 - Update description.

v7:
 - Fix critical timing(eg:odd hfp/hbp) in "mode_fixup" interface,
   enhance MIPI RX tolerance by setting register MIPI_DIGITAL_ADJ_1 to 0x3D.


Xin Ji (2):
  dt-bindings: drm/bridge: anx7625: MIPI to DP transmitter binding
  drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP bridge driver

 .../bindings/display/bridge/analogix,anx7625.yaml  |   97 +
 drivers/gpu/drm/bridge/Makefile|2 +-
 drivers/gpu/drm/bridge/analogix/Kconfig|8 +
 drivers/gpu/drm/bridge/analogix/Makefile   |1 +
 drivers/gpu/drm/bridge/analogix/anx7625.c  | 1959 
 drivers/gpu/drm/bridge/analogix/anx7625.h  |  397 
 6 files changed, 2463 insertions(+), 1 deletion(-)
 create mode 100644 
Documentation/devicetree/bindings/display/bridge/analogix,anx7625.yaml
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.c
 create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.h

-- 
2.7.4



Re: [PATCH v8 2/2] drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP bridge driver

2020-04-30 Thread Xin Ji
On Thu, Apr 30, 2020 at 09:03:24AM +0200, Sam Ravnborg wrote:
> Hi Xin Ji.
> 
> > > > +static void anx7625_power_on_init(struct anx7625_data *ctx)
> > > > +{
> > > > +   int retry_count, i;
> > > > +   int ret;
> > > > +   struct device *dev = &ctx->client->dev;
> > > > +
> > > > +   for (retry_count = 0; retry_count < 3; retry_count++) {
> > > > +   anx7625_power_on(ctx);
> > > > +   anx7625_config(ctx);
> > > > +
> > > > +   for (i = 0; i < OCM_LOADING_TIME; i++) {
> > > Code in this for loop is a candidate for a helper function.
> > I didn't find any helper function can be used, so I'll keep it.
> I was not very clear in my way to express this, sorry.
> 
> > > 
> > > > +   /* check interface workable */
> > > > +   ret = anx7625_reg_read(ctx, 
> > > > ctx->i2c.rx_p0_client,
> > > > +  FLASH_LOAD_STA);
> > > > +   if (ret < 0) {
> > > > +   DRM_ERROR("IO error : access flash 
> > > > load.\n");
> > > > +   return;
> > > > +   }
> > > > +   if ((ret & FLASH_LOAD_STA_CHK) == 
> > > > FLASH_LOAD_STA_CHK) {
> > > > +   anx7625_disable_pd_protocol(ctx);
> > > > +   DRM_DEV_DEBUG_DRIVER(dev,
> > > > +"Firmware ver 
> > > > %02x%02x,",
> > > > +   anx7625_reg_read(ctx,
> > > > +
> > > > ctx->i2c.rx_p0_client,
> > > > +
> > > > OCM_FW_VERSION),
> > > > +   anx7625_reg_read(ctx,
> > > > +
> > > > ctx->i2c.rx_p0_client,
> > > > +
> > > > OCM_FW_REVERSION));
> > > > +   DRM_DEV_DEBUG_DRIVER(dev, "Driver 
> > > > version %s\n",
> > > > +
> > > > ANX7625_DRV_VERSION);
> > > > +
> > > > +   return;
> > > > +   }
> > > > +   usleep_range(1000, 1100);
> > > > +   }
> What I wanted to express is that the for loop is heavily indented.
> So create a small function like:
> 
> anx7625_power_on_interface(ctx)
> {
>   /* check interface workable */
>   ret = anx7625_reg_read(ctx, ctx->i2c.rx_p0_client, FLASH_LOAD_STA);
>   if (ret < 0) {
>   DRM_ERROR("IO error : access flash load.\n");
>   return;
>   }
>   if ((ret & FLASH_LOAD_STA_CHK) == FLASH_LOAD_STA_CHK) {
>   anx7625_disable_pd_protocol(ctx);
>   DRM_DEV_DEBUG_DRIVER(dev, "Firmware ver %02x%02x,",
>   anx7625_reg_read(ctx, ctx->i2c.rx_p0_client,
>  OCM_FW_VERSION), 
> anx7625_reg_read(ctx,
>ctx->i2c.rx_p0_client, 
> OCM_FW_REVERSION));
>   DRM_DEV_DEBUG_DRIVER(dev, "Driver version %s\n",
>ANX7625_DRV_VERSION);
>   retunrn 1;
>   }
>   return 0;
> }
> 
> and then
> 
>   for (i = 0; i < OCM_LOADING_TIME; i++) {
>   if (anx7625_power_on_interface(ctx))
>   return;
>   else
>   usleep_range(1000, 1100);
>   }
> 
> Or something like that. To make it more readable.
> I think you get the idea now.
OK, got it, thanks.
> 
> 
> > > > +   container_of(work, struct anx7625_data, extcon_wq);
> > > > +   int state = extcon_get_state(ctx->extcon, EXTCON_DISP_DP);
> > > > +
> > > > +   mutex_lock(&ctx->lock);
> > > > +   anx7625_chip_control(ctx, state);
> > > > +   mutex_unlock(&ctx->lock);
> > > I tried to follow the locking - but failed.
> > &

Re: [PATCH v8 2/2] drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP bridge driver

2020-04-29 Thread Xin Ji
On Wed, Apr 29, 2020 at 10:10:05AM +0800, Nicolas Boichat wrote:
> On Mon, Apr 27, 2020 at 2:18 PM Xin Ji  wrote:
> >
> > The ANX7625 is an ultra-low power 4K Mobile HD Transmitter designed
> > for portable device. It converts MIPI DSI/DPI to DisplayPort 1.3 4K.
> >
> > The ANX7625 can support both USB Type-C PD feature and MIPI DSI/DPI
> > to DP feature. This driver only enabled MIPI DSI/DPI to DP feature.
> >
> > Signed-off-by: Xin Ji 
> > ---
> >  drivers/gpu/drm/bridge/Makefile   |2 +-
> >  drivers/gpu/drm/bridge/analogix/Kconfig   |6 +
> >  drivers/gpu/drm/bridge/analogix/Makefile  |1 +
> >  drivers/gpu/drm/bridge/analogix/anx7625.c | 2158 
> > +
> >  drivers/gpu/drm/bridge/analogix/anx7625.h |  410 ++
> >  5 files changed, 2576 insertions(+), 1 deletion(-)
> >  create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.c
> >  create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.h
> >
> > diff --git a/drivers/gpu/drm/bridge/Makefile 
> > b/drivers/gpu/drm/bridge/Makefile
> > index 4934fcf..bcd388a 100644
> > --- a/drivers/gpu/drm/bridge/Makefile
> > +++ b/drivers/gpu/drm/bridge/Makefile
> > @@ -12,8 +12,8 @@ obj-$(CONFIG_DRM_SII9234) += sii9234.o
> >  obj-$(CONFIG_DRM_THINE_THC63LVD1024) += thc63lvd1024.o
> >  obj-$(CONFIG_DRM_TOSHIBA_TC358764) += tc358764.o
> >  obj-$(CONFIG_DRM_TOSHIBA_TC358767) += tc358767.o
> > -obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix/
> >  obj-$(CONFIG_DRM_I2C_ADV7511) += adv7511/
> >  obj-$(CONFIG_DRM_TI_SN65DSI86) += ti-sn65dsi86.o
> >  obj-$(CONFIG_DRM_TI_TFP410) += ti-tfp410.o
> > +obj-y += analogix/
> >  obj-y += synopsys/
> > diff --git a/drivers/gpu/drm/bridge/analogix/Kconfig 
> > b/drivers/gpu/drm/bridge/analogix/Kconfig
> > index e930ff9..b2f127e 100644
> > --- a/drivers/gpu/drm/bridge/analogix/Kconfig
> > +++ b/drivers/gpu/drm/bridge/analogix/Kconfig
> > @@ -2,3 +2,9 @@
> >  config DRM_ANALOGIX_DP
> > tristate
> > depends on DRM
> > +
> > +config ANALOGIX_ANX7625
> > +   tristate "Analogix MIPI to DP interface support"
> > +   help
> > +   ANX7625 is an ultra-low power 4K mobile HD transmitter 
> > designed
> > +   for portable devices. It converts MIPI/DPI to 
> > DisplayPort1.3 4K.
> > diff --git a/drivers/gpu/drm/bridge/analogix/Makefile 
> > b/drivers/gpu/drm/bridge/analogix/Makefile
> > index fdbf3fd..8a52867 100644
> > --- a/drivers/gpu/drm/bridge/analogix/Makefile
> > +++ b/drivers/gpu/drm/bridge/analogix/Makefile
> > @@ -1,3 +1,4 @@
> >  # SPDX-License-Identifier: GPL-2.0-only
> > +obj-$(CONFIG_ANALOGIX_ANX7625) += anx7625.o
> >  analogix_dp-objs := analogix_dp_core.o analogix_dp_reg.o
> >  obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix_dp.o
> > diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
> > b/drivers/gpu/drm/bridge/analogix/anx7625.c
> > new file mode 100644
> > index 000..fff7a49
> > [snip]
> > +static int anx7625_attach_dsi(struct anx7625_data *ctx)
> > +{
> > +   struct mipi_dsi_host *host;
> > +   struct mipi_dsi_device *dsi;
> > +   struct device_node *mipi_host_node;
> > +   struct device *dev = &ctx->client->dev;
> > +   const struct mipi_dsi_device_info info = {
> > +   .type = "anx7625",
> > +   .channel = 0,
> > +   .node = NULL,
> > +   };
> > +
> > +   DRM_DEV_DEBUG_DRIVER(dev, "attach dsi\n");
> > +
> > +   if (ctx->pdata.dsi_supported)
> > +   mipi_host_node = ctx->pdata.node.mipi_dsi_host_node;
> > +   else
> > +   mipi_host_node = ctx->pdata.node.mipi_dpi_host_node;
> > +
> > +   if (!mipi_host_node) {
> > +   DRM_ERROR("dsi host is not configured.\n");
> > +   return -EINVAL;
> > +   }
> > +
> > +   host = of_find_mipi_dsi_host_by_node(mipi_host_node);
> 
> I tried this driver when connected to a dpi interface, and this fails,
> as of_find_mipi_dsi_host_by_node is not able to find the dpi interface
> from the SoC.
> 
> I'm not too familiar with how dpi bridges are supposed to work in the
> kernel, but should we even call "anx7625_attach_dsi" for DPI
> interface?
DPI needs hardware support, and I don't know how to register DPI interface
in the driver too, I'll remove the DPI support in the next serial.
> 
> > +   if (!h

Re: [PATCH v8 2/2] drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP bridge driver

2020-04-29 Thread Xin Ji
Hi Sam,

On Mon, Apr 27, 2020 at 10:00:44PM +0200, Sam Ravnborg wrote:
> Hi Xin Ji
> 
> On Mon, Apr 27, 2020 at 02:18:44PM +0800, Xin Ji wrote:
> > The ANX7625 is an ultra-low power 4K Mobile HD Transmitter designed
> > for portable device. It converts MIPI DSI/DPI to DisplayPort 1.3 4K.
> > 
> > The ANX7625 can support both USB Type-C PD feature and MIPI DSI/DPI
> > to DP feature. This driver only enabled MIPI DSI/DPI to DP feature.
> 
> You are sending this patch in an interesting time for bridge drivers.
> We are migrating to an approach where the individual brdge drivers
> exposes operations and where the connector creation is now optional.
> 
> Laurent Pinchart is the architect behind it - and the required
> interfaces is well documented.
> You may find inspiration in a patchset I sent today:
> https://lore.kernel.org/dri-devel/20200427081850.17512-1-...@ravnborg.org/T/#t
> This is not reviewed - so keep an eye out for feedback.
> 
> It would be great to base this on top of drm-misc-next, as this is where
> we will apply it eventually.
> As it is now it will not build due to internal API changes.
> 
> The driver looks well structured with nice coding. 
> 
> I am missing an explanation why the current analogix infrastructure
> cannot be used. I have no clue but I just see other
> drivers in same dir that benefits from the infrastructure.
> So the questions seems relevant to be addressed.
> 
> See a few more comments in the following, which you need to decide
> what to follow and what to ignore.
> I will make it obvious when something is a must to change,
> if I find anything such.
> 
> Sorry for providing such massive feedback on v8.
> Please keep up the spirit and submit a v9 soon!
> 
>   Sam
OK
> 
> > 
> > Signed-off-by: Xin Ji 
> > ---
> >  drivers/gpu/drm/bridge/Makefile   |2 +-
> >  drivers/gpu/drm/bridge/analogix/Kconfig   |6 +
> >  drivers/gpu/drm/bridge/analogix/Makefile  |1 +
> >  drivers/gpu/drm/bridge/analogix/anx7625.c | 2158 
> > +
> >  drivers/gpu/drm/bridge/analogix/anx7625.h |  410 ++
> >  5 files changed, 2576 insertions(+), 1 deletion(-)
> >  create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.c
> >  create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.h
> > 
> > diff --git a/drivers/gpu/drm/bridge/Makefile 
> > b/drivers/gpu/drm/bridge/Makefile
> > index 4934fcf..bcd388a 100644
> > --- a/drivers/gpu/drm/bridge/Makefile
> > +++ b/drivers/gpu/drm/bridge/Makefile
> > @@ -12,8 +12,8 @@ obj-$(CONFIG_DRM_SII9234) += sii9234.o
> >  obj-$(CONFIG_DRM_THINE_THC63LVD1024) += thc63lvd1024.o
> >  obj-$(CONFIG_DRM_TOSHIBA_TC358764) += tc358764.o
> >  obj-$(CONFIG_DRM_TOSHIBA_TC358767) += tc358767.o
> > -obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix/
> >  obj-$(CONFIG_DRM_I2C_ADV7511) += adv7511/
> >  obj-$(CONFIG_DRM_TI_SN65DSI86) += ti-sn65dsi86.o
> >  obj-$(CONFIG_DRM_TI_TFP410) += ti-tfp410.o
> > +obj-y += analogix/
> >  obj-y += synopsys/
> With this change we will always visit analogix/
> which will trigger build of too much i think.
> Use:
> obj-$(CONFIG_ANALOGIX_ANX7625) += analogix/
> like the other drivers do, if for nothing else then for consistency.
I noticed that, the latest kernel used "obj-y += analogix/"
> 
> > diff --git a/drivers/gpu/drm/bridge/analogix/Kconfig 
> > b/drivers/gpu/drm/bridge/analogix/Kconfig
> > index e930ff9..b2f127e 100644
> > --- a/drivers/gpu/drm/bridge/analogix/Kconfig
> > +++ b/drivers/gpu/drm/bridge/analogix/Kconfig
> > @@ -2,3 +2,9 @@
> >  config DRM_ANALOGIX_DP
> > tristate
> > depends on DRM
> > +
> > +config ANALOGIX_ANX7625
> > +   tristate "Analogix MIPI to DP interface support"
> > +   help
> > +   ANX7625 is an ultra-low power 4K mobile HD transmitter designed
> > +   for portable devices. It converts MIPI/DPI to DisplayPort1.3 4K.
> > diff --git a/drivers/gpu/drm/bridge/analogix/Makefile 
> > b/drivers/gpu/drm/bridge/analogix/Makefile
> > index fdbf3fd..8a52867 100644
> > --- a/drivers/gpu/drm/bridge/analogix/Makefile
> > +++ b/drivers/gpu/drm/bridge/analogix/Makefile
> > @@ -1,3 +1,4 @@
> >  # SPDX-License-Identifier: GPL-2.0-only
> > +obj-$(CONFIG_ANALOGIX_ANX7625) += anx7625.o
> >  analogix_dp-objs := analogix_dp_core.o analogix_dp_reg.o
> >  obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix_dp.o
> > diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c 
> > b/drivers/gpu/drm/bridge/analogix/anx7625.c
> > new file mode 100644
> > index 000..fff7a49

Re: [PATCH v8 0/2] Add initial support for slimport anx7625

2020-04-29 Thread Xin Ji
Hi Sam,

On Mon, Apr 27, 2020 at 08:53:20PM +0200, Sam Ravnborg wrote:
> Hi Xin Ji
> 
> On Mon, Apr 27, 2020 at 02:16:49PM +0800, Xin Ji wrote:
> > Hi all,
> > 
> > The following series add support for the Slimport ANX7625 transmitter, a
> > ultra-low power Full-HD 4K MIPI to DP transmitter designed for portable 
> > device.
> > 
> > This is the v8 version, any mistakes, please let me know, I will fix it in
> > the next series. This series fix several coding format and description.
> 
> 
> It would be great if you can add a summary of changes like this:
> 
> v8:
>   - fix several coding format
>   - update description
> 
> v7:
>   - Bla bla
> 
> I see no reason to dig out the old changelog, but start from now on.
> The cover letter (this mail) should give a general intro to the changes.
> The individual patches the detailed changelog.
> For each entry is is also a good practice to tell who gave the feedback
> that triggered the changes.
> 
> There are many ways to handle this, take a look at a few submissions 
> to dri-devel to be inspired.
> 
>   Sam
OK.
> 
> > 
> > Thanks,
> > Xin
> > 
> > 
> > 
> > Xin Ji (2):
> >   dt-bindings: drm/bridge: anx7625: MIPI to DP transmitter binding
> >   drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP bridge driver
> > 
> >  .../bindings/display/bridge/anx7625.yaml   |   91 +
> >  drivers/gpu/drm/bridge/Makefile|2 +-
> >  drivers/gpu/drm/bridge/analogix/Kconfig|6 +
> >  drivers/gpu/drm/bridge/analogix/Makefile   |1 +
> >  drivers/gpu/drm/bridge/analogix/anx7625.c  | 2158 
> > 
> >  drivers/gpu/drm/bridge/analogix/anx7625.h  |  410 
> >  6 files changed, 2667 insertions(+), 1 deletion(-)
> >  create mode 100644 
> > Documentation/devicetree/bindings/display/bridge/anx7625.yaml
> >  create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.c
> >  create mode 100644 drivers/gpu/drm/bridge/analogix/anx7625.h
> > 
> > -- 
> > 2.7.4
> > 
> > ___
> > dri-devel mailing list
> > dri-de...@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v8 1/2] dt-bindings: drm/bridge: anx7625: MIPI to DP transmitter binding

2020-04-29 Thread Xin Ji
Hi Sam, thanks for your comments.

On Mon, Apr 27, 2020 at 08:49:09PM +0200, Sam Ravnborg wrote:
> Hi Xin Ji
> 
> On Mon, Apr 27, 2020 at 02:17:46PM +0800, Xin Ji wrote:
> > The ANX7625 is an ultra-low power 4K Mobile HD Transmitter designed
> > for portable device. It converts MIPI to DisplayPort 1.3 4K.
> 
> Thanks for providing this binding.
> When you re-submit please also send to devicet...@vger.kernel.org.
OK
> 
> Running the binding through dt_binding_check gives me:
> 
> /home/sam/drm/linux.git/Documentation/devicetree/bindings/display/bridge/anx7625.yaml:
>  ignoring, error in schema:
> warning: no schema found in file: 
> /home/sam/drm/linux.git/Documentation/devicetree/bindings/display/bridge/anx7625.yaml
> make[2]: *** 
> [/home/sam/drm/linux.git/Documentation/devicetree/bindings/Makefile:42: 
> Documentation/devicetree/bindings/processed-schema.yaml] Error 255
> make[2]: *** Waiting for unfinished jobs
> /home/sam/drm/linux.git/Documentation/devicetree/bindings/display/bridge/anx7625.yaml:
>  Additional properties are not allowed ('example' was unexpected)
> /home/sam/drm/linux.git/Documentation/devicetree/bindings/display/bridge/anx7625.yaml:
>  Additional properties are not allowed ('example' was unexpected)
> 
> See writing-schemas.rst for instruction installing tools etc.
OK
> 
> > 
> > You can add support to your board with binding.
> > 
> > Example:
> > anx7625_bridge: encoder@58 {
> > compatible = "analogix,anx7625";
> > reg = <0x58>;
> > status = "okay";
> > panel-flags = <1>;
> > enable-gpios = <&pio 45 GPIO_ACTIVE_HIGH>;
> > reset-gpios = <&pio 73 GPIO_ACTIVE_HIGH>;
> > #address-cells = <1>;
> > #size-cells = <0>;
> > 
> > port@0 {
> >   reg = <0>;
> >   anx_1_in: endpoint {
> > remote-endpoint = <&mipi_dsi>;
> >   };
> > };
> > 
> > port@2 {
> >   reg = <2>;
> >   anx_1_out: endpoint {
> > remote-endpoint = <&panel_in>;
> >   };
> > };
> > };
> > 
> > Signed-off-by: Xin Ji 
> > ---
> >  .../bindings/display/bridge/anx7625.yaml   | 91 
> > ++
> >  1 file changed, 91 insertions(+)
> >  create mode 100644 
> > Documentation/devicetree/bindings/display/bridge/anx7625.yaml
> > 
> > diff --git a/Documentation/devicetree/bindings/display/bridge/anx7625.yaml 
> > b/Documentation/devicetree/bindings/display/bridge/anx7625.yaml
> > new file mode 100644
> > index 000..1149ebb
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/display/bridge/anx7625.yaml
> 
> Name the file "analogix,anx7625.yaml".
> (We should rename anx6345.yaml, so others do not omit the company name)
OK
> 
> > @@ -0,0 +1,91 @@
> > +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> > +# Copyright 2019 Analogix Semiconductor, Inc.
> > +%YAML 1.2
> > +---
> > +$id: "http://devicetree.org/schemas/display/bridge/anx7625.yaml#";
> > +$schema: "http://devicetree.org/meta-schemas/core.yaml#";
> > +
> > +title: Analogix ANX7625 SlimPort (4K Mobile HD Transmitter)
> > +
> > +maintainers:
> > +  - Xin Ji 
> > +
> > +description: |
> > +  The ANX7625 is an ultra-low power 4K Mobile HD Transmitter
> > +  designed for portable devices.
> > +
> > +properties:
> > +  "#address-cells": true
> > +  "#size-cells": true
> > +
> > +  compatible:
> > +items:
> > +  - const: analogix,anx7625
> > +
> > +  reg:
> > +maxItems: 1
> > +
> > +  panel-flags:
> > +description: indicate the panel is internal or external.
> > +maxItems: 1
> This property hint at something needs to be modelled in a different way.
> I do not recall other bindings need similar info.
I'll change it to vendor,int-property
> 
> > +
> > +  interrupts:
> > +maxItems: 1
> A description would be nice.
OK
> 
> > +
> > +  enable-gpios:
> > +description: used for power on chip control, POWER_EN pin D2.
> > +maxItems: 1
> > +
> > +  reset-gpios:
> > +description: used for reset chip control, RESET_N pin B7.
> > +maxItems: 1
> > +
> > +  port

Re: [PATCH v7 2/2] drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP bridge driver

2020-04-29 Thread Xin Ji
On Tue, Apr 28, 2020 at 12:05:08PM +0200, Daniel Vetter wrote:
> On Fri, Apr 24, 2020 at 08:12:04PM +0800, Nicolas Boichat wrote:
> > On Fri, Apr 24, 2020 at 2:51 PM Xin Ji  wrote:
> > >
> > > On Thu, Apr 23, 2020 at 07:55:15PM +0800, Nicolas Boichat wrote:
> > > > Hi,
> > > >
> > > > Just commenting on the mode_fixup function that was added in v7.
> > > >
> > > [snip]
> > > > > +   /*
> > > > > +* once illegal timing detected, use default HFP, HSYNC, HBP
> > > > > +*/
> > > > > +   if (hblanking < HBLANKING_MIN || (hfp < HP_MIN && hbp < 
> > > > > HP_MIN)) {
> > > >
> > > > should this be adj_hblanking/adj_hfp/adj_hbp?
> > > NO, need check original HFP and HBP, if they are not legal, driver need
> > > set default value to adj_hsync, adj_hfp, adj_hbp.
> > > >
> > > > > +   adj_hsync = SYNC_LEN_DEF;
> > > > > +   adj_hfp = HFP_HBP_DEF;
> > > > > +   adj_hbp = HFP_HBP_DEF;
> > > > > +   vref = adj->clock * 1000 / (adj->htotal * 
> > > > > adj->vtotal);
> > > > > +   if (hblanking < HBLANKING_MIN) {
> > > > > +   delta_adj = HBLANKING_MIN - hblanking;
> > > > > +   adj_clock = vref * delta_adj * adj->vtotal;
> > > > > +   adj->clock += DIV_ROUND_UP(adj_clock, 1000);
> > > > > +   } else {
> > > > > +   delta_adj = hblanking - HBLANKING_MIN;
> > > > > +   adj_clock = vref * delta_adj * adj->vtotal;
> > > > > +   adj->clock -= DIV_ROUND_UP(adj_clock, 1000);
> > > > > +   }
> > > > > +
> > > > > +   DRM_WARN("illegal hblanking timing, use default.\n");
> > > > > +   DRM_WARN("hfp(%d),hbp(%d),hsync(%d).\n", hfp, hbp, 
> > > > > hsync);
> > > >
> > > > How likely is it that this mode is going to work? Can you just return
> > > > false here to reject the mode?
> > > We want to set the default minimal Hblancking value, then it may display,
> > > otherwise. If we just return false, there is no display for sure.
> > 
> > Right, understand your argument. I'm pondering if it's not just better
> > to reject the mode rather than trying a timing that is definitely
> > quite different from what the monitor was asking for. No super strong
> > opinion, I'll let other people on the list weigh in.
> 
> Yeah mode_fixup is supposed to be used to adjust the mode in intermediate
> stages (e.g. if you go from progressive to interlaced only at the end of
> your pipeline or something like that). It's not meant for adjusting the
> mode yout actually put out through a hdmi or dp connector. For fixed
> panels adjusting modes to fit the panel is also fairly common, but not for
> external outputs.
> 
> Since this is a DP bridge I'd say no adjusting, just reject what doesn't
> fit.
We have found some panel which HBP less than 8, if we reject to adjust
video timing, then there is no display. The customer does not accept it,
they push us to fix it, the only resolve way is to adjust timing.
> -Daniel
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch


  1   2   >