Re: [PATCH v2 04/11] media: rkisp1: add Rockchip MIPI Synopsys DPHY driver

2017-11-29 Thread Jacob Chen
Hi Hans,

2017-11-27 22:15 GMT+08:00 Jose Abreu :
> ++ Joao, ++ Luis
>
> Hi Hans,
>
> We will take a look into this. Thanks for pointing this out!
>
> Best Regards,
> Jose Miguel Abreu
>
> On 27-11-2017 12:01, Hans Verkuil wrote:
>> I'm CC-ing Jose Abreu from Synopsys to this. Jose, can you or a colleague 
>> take
>> a look at this as well?
>>
>> Jacob, I have some high-level questions first:
>>
>> 1) to what extend is this code rockchip-specific as opposed to be more 
>> synopsys-generic?

See below.

>>
>> 2) I don't quite see how this works when there are two sensors. Is only one 
>> active at a
>>time? Or are they multiplexed somehow?
>>

For one mipi-rx-phy and one isp, only one sensor is active at a
time(selected by enabled media-link).
For example, a tablet with a front sensor and a rear sensor.


>> 3) Same as for the previous patch: some more comments would be welcome.
>>
>> On 11/24/2017 03:36 AM, Jacob Chen wrote:
>>> From: Jacob Chen 
>>>
>>> This commit adds a subdev driver for Rockchip MIPI Synopsys DPHY driver.
>>>
>>> The phy driver is kind of independent compare to the other parts, but i'd 
>>> like
>>> to keep it in rkisp1 driver, unless people want to generalize it
>>>
>>> Signed-off-by: Jacob Chen 
>>> Signed-off-by: Shunqian Zheng 
>>> Signed-off-by: Tomasz Figa 
>>> ---
>>>  drivers/media/platform/rockchip/isp1/Makefile  |   1 +
>>>  .../media/platform/rockchip/isp1/mipi_dphy_sy.c| 805 
>>> +
>>>  2 files changed, 806 insertions(+)
>>>  create mode 100644 drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c
>>>
>>> diff --git a/drivers/media/platform/rockchip/isp1/Makefile 
>>> b/drivers/media/platform/rockchip/isp1/Makefile
>>> index 8f52f959398e..18af64853734 100644
>>> --- a/drivers/media/platform/rockchip/isp1/Makefile
>>> +++ b/drivers/media/platform/rockchip/isp1/Makefile
>>> @@ -4,4 +4,5 @@ video_rkisp1-objs   +=   rkisp1.o \
>>>  regs.o \
>>>  isp_stats.o \
>>>  isp_params.o \
>>> +mipi_dphy_sy.o \
>>>  capture.o
>>> diff --git a/drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c 
>>> b/drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c
>>> new file mode 100644
>>> index ..56deff2be6fd
>>> --- /dev/null
>>> +++ b/drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c
>>> @@ -0,0 +1,805 @@
>>> +/*
>>> + * Rockchip MIPI Synopsys DPHY driver
>>> + *
>>> + * Copyright (C) 2017 Fuzhou Rockchip Electronics Co., Ltd.
>>> + *
>>> + * This software is available to you under a choice of one of two
>>> + * licenses.  You may choose to be licensed under the terms of the GNU
>>> + * General Public License (GPL) Version 2, available from the file
>>> + * COPYING in the main directory of this source tree, or the
>>> + * OpenIB.org BSD license below:
>>> + *
>>> + * Redistribution and use in source and binary forms, with or
>>> + * without modification, are permitted provided that the following
>>> + * conditions are met:
>>> + *
>>> + *  - Redistributions of source code must retain the above
>>> + *copyright notice, this list of conditions and the following
>>> + *disclaimer.
>>> + *
>>> + *  - Redistributions in binary form must reproduce the above
>>> + *copyright notice, this list of conditions and the following
>>> + *disclaimer in the documentation and/or other materials
>>> + *provided with the distribution.
>>> + *
>>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
>>> + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
>>> + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
>>> + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
>>> + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
>>> + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
>>> + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
>>> + * SOFTWARE.
>>> + */
>>> +
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +
>>> +#define RK3288_GRF_SOC_CON6 0x025c
>>> +#define RK3288_GRF_SOC_CON8 0x0264
>>> +#define RK3288_GRF_SOC_CON9 0x0268
>>> +#define RK3288_GRF_SOC_CON100x026c
>>> +#define RK3288_GRF_SOC_CON140x027c
>>> +#define RK3288_GRF_SOC_STATUS21 0x02d4
>>> +#define RK3288_GRF_IO_VSEL  0x0380
>>> +#define RK3288_GRF_SOC_CON150x03a4
>>> +
>>> +#define RK3399_GRF_SOC_CON9 0x6224
>>> +#define RK3399_GRF_SOC_CON210x6254
>>> +#define RK3399_GRF_SOC_CON220x6258
>>> +#define RK3399_GRF_SOC_CON230x625c
>>> +#define RK3399_GRF_SOC_CON240x6260
>>> +#define RK3399_GRF_SOC_CON250x6264
>>> +#define RK3399_GRF_SOC_STATUS1  0xe2a4
>>> +
>>> +#define CLOCK_LANE

Re: [PATCH v2 04/11] media: rkisp1: add Rockchip MIPI Synopsys DPHY driver

2017-11-27 Thread Jose Abreu
++ Joao, ++ Luis

Hi Hans,

We will take a look into this. Thanks for pointing this out!

Best Regards,
Jose Miguel Abreu

On 27-11-2017 12:01, Hans Verkuil wrote:
> I'm CC-ing Jose Abreu from Synopsys to this. Jose, can you or a colleague take
> a look at this as well?
>
> Jacob, I have some high-level questions first:
>
> 1) to what extend is this code rockchip-specific as opposed to be more 
> synopsys-generic?
>
> 2) I don't quite see how this works when there are two sensors. Is only one 
> active at a
>time? Or are they multiplexed somehow?
>
> 3) Same as for the previous patch: some more comments would be welcome.
>
> On 11/24/2017 03:36 AM, Jacob Chen wrote:
>> From: Jacob Chen 
>>
>> This commit adds a subdev driver for Rockchip MIPI Synopsys DPHY driver.
>>
>> The phy driver is kind of independent compare to the other parts, but i'd 
>> like
>> to keep it in rkisp1 driver, unless people want to generalize it
>>
>> Signed-off-by: Jacob Chen 
>> Signed-off-by: Shunqian Zheng 
>> Signed-off-by: Tomasz Figa 
>> ---
>>  drivers/media/platform/rockchip/isp1/Makefile  |   1 +
>>  .../media/platform/rockchip/isp1/mipi_dphy_sy.c| 805 
>> +
>>  2 files changed, 806 insertions(+)
>>  create mode 100644 drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c
>>
>> diff --git a/drivers/media/platform/rockchip/isp1/Makefile 
>> b/drivers/media/platform/rockchip/isp1/Makefile
>> index 8f52f959398e..18af64853734 100644
>> --- a/drivers/media/platform/rockchip/isp1/Makefile
>> +++ b/drivers/media/platform/rockchip/isp1/Makefile
>> @@ -4,4 +4,5 @@ video_rkisp1-objs   +=   rkisp1.o \
>>  regs.o \
>>  isp_stats.o \
>>  isp_params.o \
>> +mipi_dphy_sy.o \
>>  capture.o
>> diff --git a/drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c 
>> b/drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c
>> new file mode 100644
>> index ..56deff2be6fd
>> --- /dev/null
>> +++ b/drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c
>> @@ -0,0 +1,805 @@
>> +/*
>> + * Rockchip MIPI Synopsys DPHY driver
>> + *
>> + * Copyright (C) 2017 Fuzhou Rockchip Electronics Co., Ltd.
>> + *
>> + * This software is available to you under a choice of one of two
>> + * licenses.  You may choose to be licensed under the terms of the GNU
>> + * General Public License (GPL) Version 2, available from the file
>> + * COPYING in the main directory of this source tree, or the
>> + * OpenIB.org BSD license below:
>> + *
>> + * Redistribution and use in source and binary forms, with or
>> + * without modification, are permitted provided that the following
>> + * conditions are met:
>> + *
>> + *  - Redistributions of source code must retain the above
>> + *copyright notice, this list of conditions and the following
>> + *disclaimer.
>> + *
>> + *  - Redistributions in binary form must reproduce the above
>> + *copyright notice, this list of conditions and the following
>> + *disclaimer in the documentation and/or other materials
>> + *provided with the distribution.
>> + *
>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
>> + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
>> + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
>> + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
>> + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
>> + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
>> + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
>> + * SOFTWARE.
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#define RK3288_GRF_SOC_CON6 0x025c
>> +#define RK3288_GRF_SOC_CON8 0x0264
>> +#define RK3288_GRF_SOC_CON9 0x0268
>> +#define RK3288_GRF_SOC_CON100x026c
>> +#define RK3288_GRF_SOC_CON140x027c
>> +#define RK3288_GRF_SOC_STATUS21 0x02d4
>> +#define RK3288_GRF_IO_VSEL  0x0380
>> +#define RK3288_GRF_SOC_CON150x03a4
>> +
>> +#define RK3399_GRF_SOC_CON9 0x6224
>> +#define RK3399_GRF_SOC_CON210x6254
>> +#define RK3399_GRF_SOC_CON220x6258
>> +#define RK3399_GRF_SOC_CON230x625c
>> +#define RK3399_GRF_SOC_CON240x6260
>> +#define RK3399_GRF_SOC_CON250x6264
>> +#define RK3399_GRF_SOC_STATUS1  0xe2a4
>> +
>> +#define CLOCK_LANE_HS_RX_CONTROL0x34
>> +#define LANE0_HS_RX_CONTROL 0x44
>> +#define LANE1_HS_RX_CONTROL 0x54
>> +#define LANE2_HS_RX_CONTROL 0x84
>> +#define LANE3_HS_RX_CONTROL 0x94
>> +#define HS_RX_DATA_LANES_THS_SETTLE__CONTROL0x75
>> +
>> +#define HIWORD_UPDATE(val, mask, shift) \
>> +((v

Re: [PATCH v2 04/11] media: rkisp1: add Rockchip MIPI Synopsys DPHY driver

2017-11-27 Thread Hans Verkuil
I'm CC-ing Jose Abreu from Synopsys to this. Jose, can you or a colleague take
a look at this as well?

Jacob, I have some high-level questions first:

1) to what extend is this code rockchip-specific as opposed to be more 
synopsys-generic?

2) I don't quite see how this works when there are two sensors. Is only one 
active at a
   time? Or are they multiplexed somehow?

3) Same as for the previous patch: some more comments would be welcome.

On 11/24/2017 03:36 AM, Jacob Chen wrote:
> From: Jacob Chen 
> 
> This commit adds a subdev driver for Rockchip MIPI Synopsys DPHY driver.
> 
> The phy driver is kind of independent compare to the other parts, but i'd like
> to keep it in rkisp1 driver, unless people want to generalize it
> 
> Signed-off-by: Jacob Chen 
> Signed-off-by: Shunqian Zheng 
> Signed-off-by: Tomasz Figa 
> ---
>  drivers/media/platform/rockchip/isp1/Makefile  |   1 +
>  .../media/platform/rockchip/isp1/mipi_dphy_sy.c| 805 
> +
>  2 files changed, 806 insertions(+)
>  create mode 100644 drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c
> 
> diff --git a/drivers/media/platform/rockchip/isp1/Makefile 
> b/drivers/media/platform/rockchip/isp1/Makefile
> index 8f52f959398e..18af64853734 100644
> --- a/drivers/media/platform/rockchip/isp1/Makefile
> +++ b/drivers/media/platform/rockchip/isp1/Makefile
> @@ -4,4 +4,5 @@ video_rkisp1-objs+=   rkisp1.o \
>   regs.o \
>   isp_stats.o \
>   isp_params.o \
> + mipi_dphy_sy.o \
>   capture.o
> diff --git a/drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c 
> b/drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c
> new file mode 100644
> index ..56deff2be6fd
> --- /dev/null
> +++ b/drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c
> @@ -0,0 +1,805 @@
> +/*
> + * Rockchip MIPI Synopsys DPHY driver
> + *
> + * Copyright (C) 2017 Fuzhou Rockchip Electronics Co., Ltd.
> + *
> + * This software is available to you under a choice of one of two
> + * licenses.  You may choose to be licensed under the terms of the GNU
> + * General Public License (GPL) Version 2, available from the file
> + * COPYING in the main directory of this source tree, or the
> + * OpenIB.org BSD license below:
> + *
> + * Redistribution and use in source and binary forms, with or
> + * without modification, are permitted provided that the following
> + * conditions are met:
> + *
> + *  - Redistributions of source code must retain the above
> + *copyright notice, this list of conditions and the following
> + *disclaimer.
> + *
> + *  - Redistributions in binary form must reproduce the above
> + *copyright notice, this list of conditions and the following
> + *disclaimer in the documentation and/or other materials
> + *provided with the distribution.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
> + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
> + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
> + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
> + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> + * SOFTWARE.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define RK3288_GRF_SOC_CON6  0x025c
> +#define RK3288_GRF_SOC_CON8  0x0264
> +#define RK3288_GRF_SOC_CON9  0x0268
> +#define RK3288_GRF_SOC_CON10 0x026c
> +#define RK3288_GRF_SOC_CON14 0x027c
> +#define RK3288_GRF_SOC_STATUS21  0x02d4
> +#define RK3288_GRF_IO_VSEL   0x0380
> +#define RK3288_GRF_SOC_CON15 0x03a4
> +
> +#define RK3399_GRF_SOC_CON9  0x6224
> +#define RK3399_GRF_SOC_CON21 0x6254
> +#define RK3399_GRF_SOC_CON22 0x6258
> +#define RK3399_GRF_SOC_CON23 0x625c
> +#define RK3399_GRF_SOC_CON24 0x6260
> +#define RK3399_GRF_SOC_CON25 0x6264
> +#define RK3399_GRF_SOC_STATUS1   0xe2a4
> +
> +#define CLOCK_LANE_HS_RX_CONTROL 0x34
> +#define LANE0_HS_RX_CONTROL  0x44
> +#define LANE1_HS_RX_CONTROL  0x54
> +#define LANE2_HS_RX_CONTROL  0x84
> +#define LANE3_HS_RX_CONTROL  0x94
> +#define HS_RX_DATA_LANES_THS_SETTLE__CONTROL 0x75
> +
> +#define HIWORD_UPDATE(val, mask, shift) \
> + ((val) << (shift) | (mask) << ((shift) + 16))
> +
> +enum mipi_dphy_sy_pads {
> + MIPI_DPHY_SY_PAD_SINK = 0,
> + MIPI_DPHY_SY_PAD_SOURCE,
> + MIPI_DPHY_SY_PADS_NUM,
> +};
> +
> +enum dphy_reg_id {
> + GRF_DPHY_RX0_TURNDISABLE = 0,
> + GRF_DPHY_RX0_FORCERXMODE,
> + GRF_DPHY_RX0_FORCETXSTOPMODE,
> + GRF_DPHY_RX0_ENABL

Re: [PATCH v2 04/11] media: rkisp1: add Rockchip MIPI Synopsys DPHY driver

2017-11-26 Thread kbuild test robot
Hi Jacob,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linuxtv-media/master]
[also build test ERROR on next-20171124]
[cannot apply to rockchip/for-next v4.14]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Jacob-Chen/Rockchip-ISP1-Driver/20171126-224713
base:   git://linuxtv.org/media_tree.git master
config: mips-allmodconfig (attached as .config)
compiler: mips-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=mips 

All errors (new ones prefixed by >>):

   drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c:634:66: error: expected 
identifier or '(' before '=' token
struct v4l2_async_notifier_operationsrockchip_mipidphy_async_ops = {
 ^
   drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c: In function 
'rockchip_mipidphy_media_init':
>> drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c:707:24: error: 
>> 'rockchip_mipidphy_async_ops' undeclared (first use in this function); did 
>> you mean 'rockchip_mipidphy_match_id'?
 priv->notifier.ops = &rockchip_mipidphy_async_ops;
   ^~~
   rockchip_mipidphy_match_id
   drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c:707:24: note: each 
undeclared identifier is reported only once for each function it appears in
   At top level:
   drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c:593:1: warning: 
'rockchip_mipidphy_notifier_complete' defined but not used [-Wunused-function]
rockchip_mipidphy_notifier_complete(struct v4l2_async_notifier *notifier)
^~~
   drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c:579:1: warning: 
'rockchip_mipidphy_notifier_unbind' defined but not used [-Wunused-function]
rockchip_mipidphy_notifier_unbind(struct v4l2_async_notifier *notifier,
^
   drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c:555:1: warning: 
'rockchip_mipidphy_notifier_bound' defined but not used [-Wunused-function]
rockchip_mipidphy_notifier_bound(struct v4l2_async_notifier *notifier,
^~~~

vim +707 drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c

   632  
   633  static const
 > 634  struct v4l2_async_notifier_operationsrockchip_mipidphy_async_ops = {
   635  .bound = rockchip_mipidphy_notifier_bound,
   636  .unbind = rockchip_mipidphy_notifier_unbind,
   637  .complete = rockchip_mipidphy_notifier_complete,
   638  };
   639  
   640  static int rockchip_mipidphy_fwnode_parse(struct device *dev,
   641   struct v4l2_fwnode_endpoint *vep,
   642   struct v4l2_async_subdev *asd)
   643  {
   644  struct sensor_async_subdev *s_asd =
   645  container_of(asd, struct sensor_async_subdev, 
asd);
   646  struct v4l2_mbus_config *config = &s_asd->mbus;
   647  
   648  if (vep->bus_type != V4L2_MBUS_CSI2) {
   649  dev_err(dev, "Only CSI2 bus type is currently 
supported\n");
   650  return -EINVAL;
   651  }
   652  
   653  if (vep->base.port != 0) {
   654  dev_err(dev, "The PHY has only port 0\n");
   655  return -EINVAL;
   656  }
   657  
   658  config->type = V4L2_MBUS_CSI2;
   659  config->flags = vep->bus.mipi_csi2.flags;
   660  s_asd->lanes = vep->bus.mipi_csi2.num_data_lanes;
   661  
   662  switch (vep->bus.mipi_csi2.num_data_lanes) {
   663  case 1:
   664  config->flags |= V4L2_MBUS_CSI2_1_LANE;
   665  break;
   666  case 2:
   667  config->flags |= V4L2_MBUS_CSI2_2_LANE;
   668  break;
   669  case 3:
   670  config->flags |= V4L2_MBUS_CSI2_3_LANE;
   671  break;
   672  case 4:
   673  config->flags |= V4L2_MBUS_CSI2_4_LANE;
   674  break;
   675  default:
   676  return -EINVAL;
   677  }
   678  
   679  return 0;
   680  }
   681  
   682  static int rockchip_mipidphy_media_init(struct mipidphy_priv *priv)
   683  {
   684  int ret;
   685  
   686  priv->pads[MIPI_DPHY_SY_PAD_SOURCE].flags =
   687  MEDIA_PAD_FL_SOURCE | MEDIA_PAD_FL_MUST_CONNECT;
   688  priv->pads[MIPI_DPHY_SY_PAD_SINK].flags =
   689  MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_MUST_CONNECT;
   690  
   691  ret = media_entity_pads_init(&priv->sd.entity,
   6

Re: [PATCH v2 04/11] media: rkisp1: add Rockchip MIPI Synopsys DPHY driver

2017-11-26 Thread kbuild test robot
Hi Jacob,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linuxtv-media/master]
[also build test ERROR on next-20171124]
[cannot apply to rockchip/for-next v4.14]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Jacob-Chen/Rockchip-ISP1-Driver/20171126-224713
base:   git://linuxtv.org/media_tree.git master
config: blackfin-allmodconfig (attached as .config)
compiler: bfin-uclinux-gcc (GCC) 6.2.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=blackfin 

All errors (new ones prefixed by >>):

>> drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c:634:66: error: expected 
>> identifier or '(' before '=' token
struct v4l2_async_notifier_operationsrockchip_mipidphy_async_ops = {
 ^
   drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c: In function 
'rockchip_mipidphy_media_init':
>> drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c:707:24: error: 
>> 'rockchip_mipidphy_async_ops' undeclared (first use in this function)
 priv->notifier.ops = &rockchip_mipidphy_async_ops;
   ^~~
   drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c:707:24: note: each 
undeclared identifier is reported only once for each function it appears in
   At top level:
   drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c:593:1: warning: 
'rockchip_mipidphy_notifier_complete' defined but not used [-Wunused-function]
rockchip_mipidphy_notifier_complete(struct v4l2_async_notifier *notifier)
^~~
   drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c:579:1: warning: 
'rockchip_mipidphy_notifier_unbind' defined but not used [-Wunused-function]
rockchip_mipidphy_notifier_unbind(struct v4l2_async_notifier *notifier,
^
   drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c:555:1: warning: 
'rockchip_mipidphy_notifier_bound' defined but not used [-Wunused-function]
rockchip_mipidphy_notifier_bound(struct v4l2_async_notifier *notifier,
^~~~

vim +634 drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c

   632  
   633  static const
 > 634  struct v4l2_async_notifier_operationsrockchip_mipidphy_async_ops = {
   635  .bound = rockchip_mipidphy_notifier_bound,
   636  .unbind = rockchip_mipidphy_notifier_unbind,
   637  .complete = rockchip_mipidphy_notifier_complete,
   638  };
   639  
   640  static int rockchip_mipidphy_fwnode_parse(struct device *dev,
   641   struct v4l2_fwnode_endpoint *vep,
   642   struct v4l2_async_subdev *asd)
   643  {
   644  struct sensor_async_subdev *s_asd =
   645  container_of(asd, struct sensor_async_subdev, 
asd);
   646  struct v4l2_mbus_config *config = &s_asd->mbus;
   647  
   648  if (vep->bus_type != V4L2_MBUS_CSI2) {
   649  dev_err(dev, "Only CSI2 bus type is currently 
supported\n");
   650  return -EINVAL;
   651  }
   652  
   653  if (vep->base.port != 0) {
   654  dev_err(dev, "The PHY has only port 0\n");
   655  return -EINVAL;
   656  }
   657  
   658  config->type = V4L2_MBUS_CSI2;
   659  config->flags = vep->bus.mipi_csi2.flags;
   660  s_asd->lanes = vep->bus.mipi_csi2.num_data_lanes;
   661  
   662  switch (vep->bus.mipi_csi2.num_data_lanes) {
   663  case 1:
   664  config->flags |= V4L2_MBUS_CSI2_1_LANE;
   665  break;
   666  case 2:
   667  config->flags |= V4L2_MBUS_CSI2_2_LANE;
   668  break;
   669  case 3:
   670  config->flags |= V4L2_MBUS_CSI2_3_LANE;
   671  break;
   672  case 4:
   673  config->flags |= V4L2_MBUS_CSI2_4_LANE;
   674  break;
   675  default:
   676  return -EINVAL;
   677  }
   678  
   679  return 0;
   680  }
   681  
   682  static int rockchip_mipidphy_media_init(struct mipidphy_priv *priv)
   683  {
   684  int ret;
   685  
   686  priv->pads[MIPI_DPHY_SY_PAD_SOURCE].flags =
   687  MEDIA_PAD_FL_SOURCE | MEDIA_PAD_FL_MUST_CONNECT;
   688  priv->pads[MIPI_DPHY_SY_PAD_SINK].flags =
   689  MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_MUST_CONNECT;
   690  
   691  ret = media_entity_pads_init(&priv->sd.entity,
   692   MIPI_DPHY_SY_PADS_NUM, priv->pads);
   693  if (ret < 0)
   

[PATCH v2 04/11] media: rkisp1: add Rockchip MIPI Synopsys DPHY driver

2017-11-23 Thread Jacob Chen
From: Jacob Chen 

This commit adds a subdev driver for Rockchip MIPI Synopsys DPHY driver.

The phy driver is kind of independent compare to the other parts, but i'd like
to keep it in rkisp1 driver, unless people want to generalize it

Signed-off-by: Jacob Chen 
Signed-off-by: Shunqian Zheng 
Signed-off-by: Tomasz Figa 
---
 drivers/media/platform/rockchip/isp1/Makefile  |   1 +
 .../media/platform/rockchip/isp1/mipi_dphy_sy.c| 806 +
 2 files changed, 807 insertions(+)
 create mode 100644 drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c

diff --git a/drivers/media/platform/rockchip/isp1/Makefile 
b/drivers/media/platform/rockchip/isp1/Makefile
index 8f52f959398e..18af64853734 100644
--- a/drivers/media/platform/rockchip/isp1/Makefile
+++ b/drivers/media/platform/rockchip/isp1/Makefile
@@ -4,4 +4,5 @@ video_rkisp1-objs  +=   rkisp1.o \
regs.o \
isp_stats.o \
isp_params.o \
+   mipi_dphy_sy.o \
capture.o
diff --git a/drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c 
b/drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c
new file mode 100644
index ..a2df34b931e7
--- /dev/null
+++ b/drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c
@@ -0,0 +1,806 @@
+/*
+ * Rockchip MIPI Synopsys DPHY driver
+ *
+ * Copyright (C) 2017 Fuzhou Rockchip Electronics Co., Ltd.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ *  - Redistributions of source code must retain the above
+ *copyright notice, this list of conditions and the following
+ *disclaimer.
+ *
+ *  - Redistributions in binary form must reproduce the above
+ *copyright notice, this list of conditions and the following
+ *disclaimer in the documentation and/or other materials
+ *provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define RK3288_GRF_SOC_CON60x025c
+#define RK3288_GRF_SOC_CON80x0264
+#define RK3288_GRF_SOC_CON90x0268
+#define RK3288_GRF_SOC_CON10   0x026c
+#define RK3288_GRF_SOC_CON14   0x027c
+#define RK3288_GRF_SOC_STATUS210x02d4
+#define RK3288_GRF_IO_VSEL 0x0380
+#define RK3288_GRF_SOC_CON15   0x03a4
+
+#define RK3399_GRF_SOC_CON90x6224
+#define RK3399_GRF_SOC_CON21   0x6254
+#define RK3399_GRF_SOC_CON22   0x6258
+#define RK3399_GRF_SOC_CON23   0x625c
+#define RK3399_GRF_SOC_CON24   0x6260
+#define RK3399_GRF_SOC_CON25   0x6264
+#define RK3399_GRF_SOC_STATUS1 0xe2a4
+
+#define CLOCK_LANE_HS_RX_CONTROL   0x34
+#define LANE0_HS_RX_CONTROL0x44
+#define LANE1_HS_RX_CONTROL0x54
+#define LANE2_HS_RX_CONTROL0x84
+#define LANE3_HS_RX_CONTROL0x94
+#define HS_RX_DATA_LANES_THS_SETTLE__CONTROL   0x75
+
+#define HIWORD_UPDATE(val, mask, shift) \
+   ((val) << (shift) | (mask) << ((shift) + 16))
+
+enum mipi_dphy_sy_pads {
+   MIPI_DPHY_SY_PAD_SINK = 0,
+   MIPI_DPHY_SY_PAD_SOURCE,
+   MIPI_DPHY_SY_PADS_NUM,
+};
+
+enum dphy_reg_id {
+   GRF_DPHY_RX0_TURNDISABLE = 0,
+   GRF_DPHY_RX0_FORCERXMODE,
+   GRF_DPHY_RX0_FORCETXSTOPMODE,
+   GRF_DPHY_RX0_ENABLE,
+   GRF_DPHY_RX0_TESTCLR,
+   GRF_DPHY_RX0_TESTCLK,
+   GRF_DPHY_RX0_TESTEN,
+   GRF_DPHY_RX0_TESTDIN,
+   GRF_DPHY_RX0_TURNREQUEST,
+   GRF_DPHY_RX0_TESTDOUT,
+   GRF_DPHY_TX0_TURNDISABLE,
+   GRF_DPHY_TX0_FORCERXMODE,
+   GRF_DPHY_TX0_FORCETXSTOPMODE,
+   GRF_DPHY_TX0_TURNREQUEST,
+   GRF_DPHY_TX1RX1_TURNDISABLE,
+   GRF_DPHY_TX1RX1_FORCERXMODE,
+   GRF_DPHY_TX1RX1_FORCETXSTOPMODE,
+   GRF_DPHY_TX1RX1_ENABLE,
+   GRF_DPHY_TX1RX1_MASTERSLAVEZ,
+   GRF_DPHY_TX1RX1_BASEDIR,
+   GRF_DPHY_TX1RX1_ENABLECLK,
+   GRF_DPHY_TX1RX1_TURNREQUEST,
+   GRF_DPHY_RX1_SRC_SEL,
+   /* rk3288 only *

[PATCH v2 04/11] media: rkisp1: add Rockchip MIPI Synopsys DPHY driver

2017-11-23 Thread Jacob Chen
From: Jacob Chen 

This commit adds a subdev driver for Rockchip MIPI Synopsys DPHY driver.

The phy driver is kind of independent compare to the other parts, but i'd like
to keep it in rkisp1 driver, unless people want to generalize it

Signed-off-by: Jacob Chen 
Signed-off-by: Shunqian Zheng 
Signed-off-by: Tomasz Figa 
---
 drivers/media/platform/rockchip/isp1/Makefile  |   1 +
 .../media/platform/rockchip/isp1/mipi_dphy_sy.c| 805 +
 2 files changed, 806 insertions(+)
 create mode 100644 drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c

diff --git a/drivers/media/platform/rockchip/isp1/Makefile 
b/drivers/media/platform/rockchip/isp1/Makefile
index 8f52f959398e..18af64853734 100644
--- a/drivers/media/platform/rockchip/isp1/Makefile
+++ b/drivers/media/platform/rockchip/isp1/Makefile
@@ -4,4 +4,5 @@ video_rkisp1-objs  +=   rkisp1.o \
regs.o \
isp_stats.o \
isp_params.o \
+   mipi_dphy_sy.o \
capture.o
diff --git a/drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c 
b/drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c
new file mode 100644
index ..56deff2be6fd
--- /dev/null
+++ b/drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c
@@ -0,0 +1,805 @@
+/*
+ * Rockchip MIPI Synopsys DPHY driver
+ *
+ * Copyright (C) 2017 Fuzhou Rockchip Electronics Co., Ltd.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ *  - Redistributions of source code must retain the above
+ *copyright notice, this list of conditions and the following
+ *disclaimer.
+ *
+ *  - Redistributions in binary form must reproduce the above
+ *copyright notice, this list of conditions and the following
+ *disclaimer in the documentation and/or other materials
+ *provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define RK3288_GRF_SOC_CON60x025c
+#define RK3288_GRF_SOC_CON80x0264
+#define RK3288_GRF_SOC_CON90x0268
+#define RK3288_GRF_SOC_CON10   0x026c
+#define RK3288_GRF_SOC_CON14   0x027c
+#define RK3288_GRF_SOC_STATUS210x02d4
+#define RK3288_GRF_IO_VSEL 0x0380
+#define RK3288_GRF_SOC_CON15   0x03a4
+
+#define RK3399_GRF_SOC_CON90x6224
+#define RK3399_GRF_SOC_CON21   0x6254
+#define RK3399_GRF_SOC_CON22   0x6258
+#define RK3399_GRF_SOC_CON23   0x625c
+#define RK3399_GRF_SOC_CON24   0x6260
+#define RK3399_GRF_SOC_CON25   0x6264
+#define RK3399_GRF_SOC_STATUS1 0xe2a4
+
+#define CLOCK_LANE_HS_RX_CONTROL   0x34
+#define LANE0_HS_RX_CONTROL0x44
+#define LANE1_HS_RX_CONTROL0x54
+#define LANE2_HS_RX_CONTROL0x84
+#define LANE3_HS_RX_CONTROL0x94
+#define HS_RX_DATA_LANES_THS_SETTLE__CONTROL   0x75
+
+#define HIWORD_UPDATE(val, mask, shift) \
+   ((val) << (shift) | (mask) << ((shift) + 16))
+
+enum mipi_dphy_sy_pads {
+   MIPI_DPHY_SY_PAD_SINK = 0,
+   MIPI_DPHY_SY_PAD_SOURCE,
+   MIPI_DPHY_SY_PADS_NUM,
+};
+
+enum dphy_reg_id {
+   GRF_DPHY_RX0_TURNDISABLE = 0,
+   GRF_DPHY_RX0_FORCERXMODE,
+   GRF_DPHY_RX0_FORCETXSTOPMODE,
+   GRF_DPHY_RX0_ENABLE,
+   GRF_DPHY_RX0_TESTCLR,
+   GRF_DPHY_RX0_TESTCLK,
+   GRF_DPHY_RX0_TESTEN,
+   GRF_DPHY_RX0_TESTDIN,
+   GRF_DPHY_RX0_TURNREQUEST,
+   GRF_DPHY_RX0_TESTDOUT,
+   GRF_DPHY_TX0_TURNDISABLE,
+   GRF_DPHY_TX0_FORCERXMODE,
+   GRF_DPHY_TX0_FORCETXSTOPMODE,
+   GRF_DPHY_TX0_TURNREQUEST,
+   GRF_DPHY_TX1RX1_TURNDISABLE,
+   GRF_DPHY_TX1RX1_FORCERXMODE,
+   GRF_DPHY_TX1RX1_FORCETXSTOPMODE,
+   GRF_DPHY_TX1RX1_ENABLE,
+   GRF_DPHY_TX1RX1_MASTERSLAVEZ,
+   GRF_DPHY_TX1RX1_BASEDIR,
+   GRF_DPHY_TX1RX1_ENABLECLK,
+   GRF_DPHY_TX1RX1_TURNREQUEST,
+   GRF_DPHY_RX1_SRC_SEL,
+   /* rk3288 only *