Re: [PATCH v2 04/19] media: camss: Add CSIPHY files

2017-06-30 Thread Sakari Ailus
Hi Todor,

On Fri, Jun 30, 2017 at 10:00:25AM +0300, Todor Tomov wrote:
> Hi Sakari,
> 
> On 06/30/2017 02:53 AM, Sakari Ailus wrote:
> > Hi Todor,
> > 
> > On Thu, Jun 29, 2017 at 07:36:47PM +0300, Todor Tomov wrote:
>  +/*
>  + * csiphy_link_setup - Setup CSIPHY connections
>  + * @entity: Pointer to media entity structure
>  + * @local: Pointer to local pad
>  + * @remote: Pointer to remote pad
>  + * @flags: Link flags
>  + *
>  + * Rreturn 0 on success
>  + */
>  +static int csiphy_link_setup(struct media_entity *entity,
>  + const struct media_pad *local,
>  + const struct media_pad *remote, u32 flags)
>  +{
>  +if ((local->flags & MEDIA_PAD_FL_SOURCE) &&
>  +(flags & MEDIA_LNK_FL_ENABLED)) {
>  +struct v4l2_subdev *sd;
>  +struct csiphy_device *csiphy;
>  +struct csid_device *csid;
>  +
>  +if (media_entity_remote_pad((struct media_pad *)local))
> >>>
> >>> This is ugly.
> >>>
> >>> What do you intend to find with media_entity_remote_pad()? The pad flags
> >>> haven't been assigned to the pad yet, so media_entity_remote_pad() could
> >>> give you something else than remote.
> >>
> >> This is an attempt to check whether the pad is already linked - to refuse
> >> a second active connection from the same src pad. As far as I can say, it
> >> was a successful attempt. Do you see any problem with it?
> > 
> > Ah. So you have multiple links here only one of which may be active?
> 
> Exactly. Below I'm adding the output of media-ctl --print-dot as you have
> requested. I can add it in the driver document as well.

Hmm. I think it could be useful there as an example. I wonder what others
think.

> 
> > 
> > I guess you can well use media_entity_remote_pad(), but then
> > media_entity_remote_pad() argument needs to be made const. Feel free to
> > spin a patch. I don't think it'd have further implications elsewhere.
> > 
> 
> Well media_entity_remote_pad() accepts struct media_pad *pad, not a
> const and trying to pass a const triggers a warning. This is why I had
> to cast. Or did I misunderstand you?

No, you don't cast to non-const. Instead, you change the function to accept
a const argument.

-- 
Sakari Ailus
e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk


Re: [PATCH v2 04/19] media: camss: Add CSIPHY files

2017-06-30 Thread Todor Tomov
Hi Sakari,

On 06/30/2017 02:53 AM, Sakari Ailus wrote:
> Hi Todor,
> 
> On Thu, Jun 29, 2017 at 07:36:47PM +0300, Todor Tomov wrote:
 +/*
 + * csiphy_link_setup - Setup CSIPHY connections
 + * @entity: Pointer to media entity structure
 + * @local: Pointer to local pad
 + * @remote: Pointer to remote pad
 + * @flags: Link flags
 + *
 + * Rreturn 0 on success
 + */
 +static int csiphy_link_setup(struct media_entity *entity,
 +   const struct media_pad *local,
 +   const struct media_pad *remote, u32 flags)
 +{
 +  if ((local->flags & MEDIA_PAD_FL_SOURCE) &&
 +  (flags & MEDIA_LNK_FL_ENABLED)) {
 +  struct v4l2_subdev *sd;
 +  struct csiphy_device *csiphy;
 +  struct csid_device *csid;
 +
 +  if (media_entity_remote_pad((struct media_pad *)local))
>>>
>>> This is ugly.
>>>
>>> What do you intend to find with media_entity_remote_pad()? The pad flags
>>> haven't been assigned to the pad yet, so media_entity_remote_pad() could
>>> give you something else than remote.
>>
>> This is an attempt to check whether the pad is already linked - to refuse
>> a second active connection from the same src pad. As far as I can say, it
>> was a successful attempt. Do you see any problem with it?
> 
> Ah. So you have multiple links here only one of which may be active?

Exactly. Below I'm adding the output of media-ctl --print-dot as you have
requested. I can add it in the driver document as well.

> 
> I guess you can well use media_entity_remote_pad(), but then
> media_entity_remote_pad() argument needs to be made const. Feel free to
> spin a patch. I don't think it'd have further implications elsewhere.
> 

Well media_entity_remote_pad() accepts struct media_pad *pad, not a
const and trying to pass a const triggers a warning. This is why I had
to cast. Or did I misunderstand you?


# media-ctl -d /dev/media1 --print-dot
digraph board {
rankdir=TB
n0001 [label="msm_csiphy0\n/dev/v4l-subdev0", shape=box, 
style=filled, fillcolor=yellow]
n0001 -> n0007 [style=dashed]
n0001 -> n000a [style=dashed]
n0004 [label="msm_csiphy1\n/dev/v4l-subdev1", shape=box, 
style=filled, fillcolor=yellow]
n0004 -> n0007 [style=dashed]
n0004 -> n000a [style=dashed]
n0007 [label="msm_csid0\n/dev/v4l-subdev2", shape=box, 
style=filled, fillcolor=yellow]
n0007 -> n000d [style=dashed]
n0007 -> n0010 [style=dashed]
n000a [label="msm_csid1\n/dev/v4l-subdev3", shape=box, 
style=filled, fillcolor=yellow]
n000a -> n000d [style=dashed]
n000a -> n0010 [style=dashed]
n000d [label="msm_ispif0\n/dev/v4l-subdev4", shape=box, 
style=filled, fillcolor=yellow]
n000d -> n0013:port0 [style=dashed]
n000d -> n001c:port0 [style=dashed]
n000d -> n0025:port0 [style=dashed]
n000d -> n002e:port0 [style=dashed]
n0010 [label="msm_ispif1\n/dev/v4l-subdev5", shape=box, 
style=filled, fillcolor=yellow]
n0010 -> n0013:port0 [style=dashed]
n0010 -> n001c:port0 [style=dashed]
n0010 -> n0025:port0 [style=dashed]
n0010 -> n002e:port0 [style=dashed]
n0013 [label="{{ 0} | msm_vfe0_rdi0\n/dev/v4l-subdev6 | 
{ 1}}", shape=Mrecord, style=filled, fillcolor=green]
n0013:port1 -> n0016 [style=bold]
n0016 [label="msm_vfe0_video0\n/dev/video0", shape=box, 
style=filled, fillcolor=yellow]
n001c [label="{{ 0} | msm_vfe0_rdi1\n/dev/v4l-subdev7 | 
{ 1}}", shape=Mrecord, style=filled, fillcolor=green]
n001c:port1 -> n001f [style=bold]
n001f [label="msm_vfe0_video1\n/dev/video1", shape=box, 
style=filled, fillcolor=yellow]
n0025 [label="{{ 0} | msm_vfe0_rdi2\n/dev/v4l-subdev8 | 
{ 1}}", shape=Mrecord, style=filled, fillcolor=green]
n0025:port1 -> n0028 [style=bold]
n0028 [label="msm_vfe0_video2\n/dev/video2", shape=box, 
style=filled, fillcolor=yellow]
n002e [label="{{ 0} | msm_vfe0_pix\n/dev/v4l-subdev9 | 
{ 1}}", shape=Mrecord, style=filled, fillcolor=green]
n002e:port1 -> n0031 [style=bold]
n0031 [label="msm_vfe0_video3\n/dev/video3", shape=box, 
style=filled, fillcolor=yellow]
n0057 [label="{{} | ov5645 1-0076\n/dev/v4l-subdev10 | { 
0}}", shape=Mrecord, style=filled, fillcolor=green]
n0057:port0 -> n0001 [style=bold]
n0059 [label="{{} | ov5645 1-0074\n/dev/v4l-subdev11 | { 
0}}", shape=Mrecord, style=filled, fillcolor=green]
n0059:port0 -> n0004 [style=bold]
}


--
Best regards,
Todor Tomov



Re: [PATCH v2 04/19] media: camss: Add CSIPHY files

2017-06-29 Thread Sakari Ailus
Hi Todor,

On Thu, Jun 29, 2017 at 07:36:47PM +0300, Todor Tomov wrote:
> >> +/*
> >> + * csiphy_link_setup - Setup CSIPHY connections
> >> + * @entity: Pointer to media entity structure
> >> + * @local: Pointer to local pad
> >> + * @remote: Pointer to remote pad
> >> + * @flags: Link flags
> >> + *
> >> + * Rreturn 0 on success
> >> + */
> >> +static int csiphy_link_setup(struct media_entity *entity,
> >> +   const struct media_pad *local,
> >> +   const struct media_pad *remote, u32 flags)
> >> +{
> >> +  if ((local->flags & MEDIA_PAD_FL_SOURCE) &&
> >> +  (flags & MEDIA_LNK_FL_ENABLED)) {
> >> +  struct v4l2_subdev *sd;
> >> +  struct csiphy_device *csiphy;
> >> +  struct csid_device *csid;
> >> +
> >> +  if (media_entity_remote_pad((struct media_pad *)local))
> > 
> > This is ugly.
> > 
> > What do you intend to find with media_entity_remote_pad()? The pad flags
> > haven't been assigned to the pad yet, so media_entity_remote_pad() could
> > give you something else than remote.
> 
> This is an attempt to check whether the pad is already linked - to refuse
> a second active connection from the same src pad. As far as I can say, it
> was a successful attempt. Do you see any problem with it?

Ah. So you have multiple links here only one of which may be active?

I guess you can well use media_entity_remote_pad(), but then
media_entity_remote_pad() argument needs to be made const. Feel free to
spin a patch. I don't think it'd have further implications elsewhere.

-- 
Regards,

Sakari Ailus
e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk


Re: [PATCH v2 04/19] media: camss: Add CSIPHY files

2017-06-29 Thread Todor Tomov
Hi Sakari,

On 06/29/2017 12:34 AM, Sakari Ailus wrote:
> Hi Todor,
> 
> It's been a while --- how do you do?
> 
> Thanks for the patchset!

Thank you for the review. I'll focus more on this now, so let's see :)

> 
> On Mon, Jun 19, 2017 at 05:48:24PM +0300, Todor Tomov wrote:
>> These files control the CSIPHY modules which are responsible for the physical
>> layer of the CSI2 receivers.
>>
>> Signed-off-by: Todor Tomov 
>> ---
>>  drivers/media/platform/qcom/camss-8x16/csiphy.c | 686 
>> 
>>  drivers/media/platform/qcom/camss-8x16/csiphy.h |  77 +++
>>  2 files changed, 763 insertions(+)
>>  create mode 100644 drivers/media/platform/qcom/camss-8x16/csiphy.c
>>  create mode 100644 drivers/media/platform/qcom/camss-8x16/csiphy.h
>>
>> diff --git a/drivers/media/platform/qcom/camss-8x16/csiphy.c 
>> b/drivers/media/platform/qcom/camss-8x16/csiphy.c
>> new file mode 100644
>> index 000..b9d47ca
>> --- /dev/null
>> +++ b/drivers/media/platform/qcom/camss-8x16/csiphy.c
>> @@ -0,0 +1,686 @@
>> +/*
>> + * csiphy.c
>> + *
>> + * Qualcomm MSM Camera Subsystem - CSIPHY Module
>> + *
>> + * Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
>> + * Copyright (C) 2016 Linaro Ltd.
> 
> How about 2017?

How time flies...

> 
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License version 2 and
>> + * only version 2 as published by the Free Software Foundation.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + */
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
> 
> ...
> 
>> +/*
>> + * csiphy_init_formats - Initialize formats on all pads
>> + * @sd: CSIPHY V4L2 subdevice
>> + * @fh: V4L2 subdev file handle
>> + *
>> + * Initialize all pad formats with default values.
>> + *
>> + * Return 0 on success or a negative error code otherwise
>> + */
>> +static int csiphy_init_formats(struct v4l2_subdev *sd,
>> +   struct v4l2_subdev_fh *fh)
>> +{
>> +struct v4l2_subdev_format format;
> 
> You can do:
> 
> struct v4l2_subdev_format format = { 0 };
> 
> And drop the memset. Or even better, assign the fields in declaration.

Yes. I'll do so for all memsets in the driver.

> 
>> +
>> +memset(, 0, sizeof(format));
>> +format.pad = MSM_CSIPHY_PAD_SINK;
>> +format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE;
>> +format.format.code = MEDIA_BUS_FMT_UYVY8_2X8;
>> +format.format.width = 1920;
>> +format.format.height = 1080;
>> +
>> +return csiphy_set_format(sd, fh ? fh->pad : NULL, );
>> +}
>> +
>> +/*
>> + * msm_csiphy_subdev_init - Initialize CSIPHY device structure and resources
>> + * @csiphy: CSIPHY device
>> + * @res: CSIPHY module resources table
>> + * @id: CSIPHY module id
>> + *
>> + * Return 0 on success or a negative error code otherwise
>> + */
>> +int msm_csiphy_subdev_init(struct csiphy_device *csiphy,
>> +   struct resources *res, u8 id)
>> +{
>> +struct device *dev = to_device_index(csiphy, id);
>> +struct platform_device *pdev = container_of(dev,
>> +struct platform_device, dev);
> 
> to_platform_device()?

Yes, thanks.

> 
>> +struct resource *r;
>> +int i;
>> +int ret;
>> +
>> +csiphy->id = id;
>> +csiphy->cfg.combo_mode = 0;
>> +
>> +/* Memory */
>> +
>> +r = platform_get_resource_byname(pdev, IORESOURCE_MEM, res->reg[0]);
>> +csiphy->base = devm_ioremap_resource(dev, r);
>> +if (IS_ERR(csiphy->base)) {
>> +dev_err(dev, "could not map memory\n");
>> +return PTR_ERR(csiphy->base);
>> +}
>> +
>> +r = platform_get_resource_byname(pdev, IORESOURCE_MEM, res->reg[1]);
>> +csiphy->base_clk_mux = devm_ioremap_resource(dev, r);
>> +if (IS_ERR(csiphy->base_clk_mux)) {
>> +dev_err(dev, "could not map memory\n");
>> +return PTR_ERR(csiphy->base_clk_mux);
>> +}
>> +
>> +/* Interrupt */
>> +
>> +r = platform_get_resource_byname(pdev, IORESOURCE_IRQ,
>> + res->interrupt[0]);
>> +if (!r) {
>> +dev_err(dev, "missing IRQ\n");
>> +return -EINVAL;
>> +}
>> +
>> +csiphy->irq = r->start;
>> +snprintf(csiphy->irq_name, sizeof(csiphy->irq_name), "%s_%s%d",
>> + dev_name(dev), MSM_CSIPHY_NAME, csiphy->id);
>> +ret = devm_request_irq(dev, csiphy->irq, csiphy_isr,
>> +   IRQF_TRIGGER_RISING, csiphy->irq_name, csiphy);
>> +if (ret < 0) {
>> +dev_err(dev, "request_irq failed\n");
> 
> Printing the error 

Re: [PATCH v2 04/19] media: camss: Add CSIPHY files

2017-06-28 Thread Sakari Ailus
Hi Todor,

It's been a while --- how do you do?

Thanks for the patchset!

On Mon, Jun 19, 2017 at 05:48:24PM +0300, Todor Tomov wrote:
> These files control the CSIPHY modules which are responsible for the physical
> layer of the CSI2 receivers.
> 
> Signed-off-by: Todor Tomov 
> ---
>  drivers/media/platform/qcom/camss-8x16/csiphy.c | 686 
> 
>  drivers/media/platform/qcom/camss-8x16/csiphy.h |  77 +++
>  2 files changed, 763 insertions(+)
>  create mode 100644 drivers/media/platform/qcom/camss-8x16/csiphy.c
>  create mode 100644 drivers/media/platform/qcom/camss-8x16/csiphy.h
> 
> diff --git a/drivers/media/platform/qcom/camss-8x16/csiphy.c 
> b/drivers/media/platform/qcom/camss-8x16/csiphy.c
> new file mode 100644
> index 000..b9d47ca
> --- /dev/null
> +++ b/drivers/media/platform/qcom/camss-8x16/csiphy.c
> @@ -0,0 +1,686 @@
> +/*
> + * csiphy.c
> + *
> + * Qualcomm MSM Camera Subsystem - CSIPHY Module
> + *
> + * Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
> + * Copyright (C) 2016 Linaro Ltd.

How about 2017?

> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 and
> + * only version 2 as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +

...

> +/*
> + * csiphy_init_formats - Initialize formats on all pads
> + * @sd: CSIPHY V4L2 subdevice
> + * @fh: V4L2 subdev file handle
> + *
> + * Initialize all pad formats with default values.
> + *
> + * Return 0 on success or a negative error code otherwise
> + */
> +static int csiphy_init_formats(struct v4l2_subdev *sd,
> +struct v4l2_subdev_fh *fh)
> +{
> + struct v4l2_subdev_format format;

You can do:

struct v4l2_subdev_format format = { 0 };

And drop the memset. Or even better, assign the fields in declaration.

> +
> + memset(, 0, sizeof(format));
> + format.pad = MSM_CSIPHY_PAD_SINK;
> + format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE;
> + format.format.code = MEDIA_BUS_FMT_UYVY8_2X8;
> + format.format.width = 1920;
> + format.format.height = 1080;
> +
> + return csiphy_set_format(sd, fh ? fh->pad : NULL, );
> +}
> +
> +/*
> + * msm_csiphy_subdev_init - Initialize CSIPHY device structure and resources
> + * @csiphy: CSIPHY device
> + * @res: CSIPHY module resources table
> + * @id: CSIPHY module id
> + *
> + * Return 0 on success or a negative error code otherwise
> + */
> +int msm_csiphy_subdev_init(struct csiphy_device *csiphy,
> +struct resources *res, u8 id)
> +{
> + struct device *dev = to_device_index(csiphy, id);
> + struct platform_device *pdev = container_of(dev,
> + struct platform_device, dev);

to_platform_device()?

> + struct resource *r;
> + int i;
> + int ret;
> +
> + csiphy->id = id;
> + csiphy->cfg.combo_mode = 0;
> +
> + /* Memory */
> +
> + r = platform_get_resource_byname(pdev, IORESOURCE_MEM, res->reg[0]);
> + csiphy->base = devm_ioremap_resource(dev, r);
> + if (IS_ERR(csiphy->base)) {
> + dev_err(dev, "could not map memory\n");
> + return PTR_ERR(csiphy->base);
> + }
> +
> + r = platform_get_resource_byname(pdev, IORESOURCE_MEM, res->reg[1]);
> + csiphy->base_clk_mux = devm_ioremap_resource(dev, r);
> + if (IS_ERR(csiphy->base_clk_mux)) {
> + dev_err(dev, "could not map memory\n");
> + return PTR_ERR(csiphy->base_clk_mux);
> + }
> +
> + /* Interrupt */
> +
> + r = platform_get_resource_byname(pdev, IORESOURCE_IRQ,
> +  res->interrupt[0]);
> + if (!r) {
> + dev_err(dev, "missing IRQ\n");
> + return -EINVAL;
> + }
> +
> + csiphy->irq = r->start;
> + snprintf(csiphy->irq_name, sizeof(csiphy->irq_name), "%s_%s%d",
> +  dev_name(dev), MSM_CSIPHY_NAME, csiphy->id);
> + ret = devm_request_irq(dev, csiphy->irq, csiphy_isr,
> +IRQF_TRIGGER_RISING, csiphy->irq_name, csiphy);
> + if (ret < 0) {
> + dev_err(dev, "request_irq failed\n");

Printing the error code as well might be nice for debugging if ever needed.

> + return ret;
> + }
> +
> + disable_irq(csiphy->irq);
> +
> + /* Clocks */
> +
> + csiphy->nclocks = 0;
> + while (res->clock[csiphy->nclocks])
> + csiphy->nclocks++;
> +
> + csiphy->clock = devm_kzalloc(dev, csiphy->nclocks *
> +

[PATCH v2 04/19] media: camss: Add CSIPHY files

2017-06-19 Thread Todor Tomov
These files control the CSIPHY modules which are responsible for the physical
layer of the CSI2 receivers.

Signed-off-by: Todor Tomov 
---
 drivers/media/platform/qcom/camss-8x16/csiphy.c | 686 
 drivers/media/platform/qcom/camss-8x16/csiphy.h |  77 +++
 2 files changed, 763 insertions(+)
 create mode 100644 drivers/media/platform/qcom/camss-8x16/csiphy.c
 create mode 100644 drivers/media/platform/qcom/camss-8x16/csiphy.h

diff --git a/drivers/media/platform/qcom/camss-8x16/csiphy.c 
b/drivers/media/platform/qcom/camss-8x16/csiphy.c
new file mode 100644
index 000..b9d47ca
--- /dev/null
+++ b/drivers/media/platform/qcom/camss-8x16/csiphy.c
@@ -0,0 +1,686 @@
+/*
+ * csiphy.c
+ *
+ * Qualcomm MSM Camera Subsystem - CSIPHY Module
+ *
+ * Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
+ * Copyright (C) 2016 Linaro Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "csiphy.h"
+#include "camss.h"
+
+#define MSM_CSIPHY_NAME "msm_csiphy"
+
+#define CAMSS_CSI_PHY_LNn_CFG2(n)  (0x004 + 0x40 * (n))
+#define CAMSS_CSI_PHY_LNn_CFG3(n)  (0x008 + 0x40 * (n))
+#define CAMSS_CSI_PHY_GLBL_RESET   0x140
+#define CAMSS_CSI_PHY_GLBL_PWR_CFG 0x144
+#define CAMSS_CSI_PHY_GLBL_IRQ_CMD 0x164
+#define CAMSS_CSI_PHY_HW_VERSION   0x188
+#define CAMSS_CSI_PHY_INTERRUPT_STATUSn(n) (0x18c + 0x4 * (n))
+#define CAMSS_CSI_PHY_INTERRUPT_MASKn(n)   (0x1ac + 0x4 * (n))
+#define CAMSS_CSI_PHY_INTERRUPT_CLEARn(n)  (0x1cc + 0x4 * (n))
+#define CAMSS_CSI_PHY_GLBL_T_INIT_CFG0 0x1ec
+#define CAMSS_CSI_PHY_T_WAKEUP_CFG00x1f4
+
+static const u32 csiphy_formats[] = {
+   MEDIA_BUS_FMT_UYVY8_2X8,
+   MEDIA_BUS_FMT_VYUY8_2X8,
+   MEDIA_BUS_FMT_YUYV8_2X8,
+   MEDIA_BUS_FMT_YVYU8_2X8,
+   MEDIA_BUS_FMT_SBGGR8_1X8,
+   MEDIA_BUS_FMT_SGBRG8_1X8,
+   MEDIA_BUS_FMT_SGRBG8_1X8,
+   MEDIA_BUS_FMT_SRGGB8_1X8,
+   MEDIA_BUS_FMT_SBGGR10_1X10,
+   MEDIA_BUS_FMT_SGBRG10_1X10,
+   MEDIA_BUS_FMT_SGRBG10_1X10,
+   MEDIA_BUS_FMT_SRGGB10_1X10,
+   MEDIA_BUS_FMT_SBGGR12_1X12,
+   MEDIA_BUS_FMT_SGBRG12_1X12,
+   MEDIA_BUS_FMT_SGRBG12_1X12,
+   MEDIA_BUS_FMT_SRGGB12_1X12,
+};
+
+/*
+ * csiphy_isr - CSIPHY module interrupt handler
+ * @irq: Interrupt line
+ * @dev: CSIPHY device
+ *
+ * Return IRQ_HANDLED on success
+ */
+static irqreturn_t csiphy_isr(int irq, void *dev)
+{
+   struct csiphy_device *csiphy = dev;
+   u8 i;
+
+   for (i = 0; i < 8; i++) {
+   u8 val = readl_relaxed(csiphy->base +
+  CAMSS_CSI_PHY_INTERRUPT_STATUSn(i));
+   writel_relaxed(val, csiphy->base +
+  CAMSS_CSI_PHY_INTERRUPT_CLEARn(i));
+   writel_relaxed(0x1, csiphy->base + CAMSS_CSI_PHY_GLBL_IRQ_CMD);
+   writel_relaxed(0x0, csiphy->base + CAMSS_CSI_PHY_GLBL_IRQ_CMD);
+   writel_relaxed(0x0, csiphy->base +
+  CAMSS_CSI_PHY_INTERRUPT_CLEARn(i));
+   }
+
+   return IRQ_HANDLED;
+}
+
+/*
+ * csiphy_reset - Perform software reset on CSIPHY module
+ * @csiphy: CSIPHY device
+ */
+static void csiphy_reset(struct csiphy_device *csiphy)
+{
+   writel_relaxed(0x1, csiphy->base + CAMSS_CSI_PHY_GLBL_RESET);
+   usleep_range(5000, 8000);
+   writel_relaxed(0x0, csiphy->base + CAMSS_CSI_PHY_GLBL_RESET);
+}
+
+/*
+ * csiphy_set_power - Power on/off CSIPHY module
+ * @sd: CSIPHY V4L2 subdevice
+ * @on: Requested power state
+ *
+ * Return 0 on success or a negative error code otherwise
+ */
+static int csiphy_set_power(struct v4l2_subdev *sd, int on)
+{
+   struct csiphy_device *csiphy = v4l2_get_subdevdata(sd);
+   struct device *dev = to_device_index(csiphy, csiphy->id);
+   int ret;
+
+   if (on) {
+   u8 hw_version;
+
+   ret = camss_enable_clocks(csiphy->nclocks, csiphy->clock, dev);
+   if (ret < 0)
+   return ret;
+
+   enable_irq(csiphy->irq);
+
+   csiphy_reset(csiphy);
+
+   hw_version = readl_relaxed(csiphy->base +
+  CAMSS_CSI_PHY_HW_VERSION);
+   dev_dbg(dev, "CSIPHY HW Version = 0x%02x\n", hw_version);
+   } else {
+   disable_irq(csiphy->irq);
+
+