All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Sakari Ailus <sakari.ailus@iki.fi>
Cc: linux-media@vger.kernel.org, devicetree@vger.kernel.org,
	pali.rohar@gmail.com
Subject: Re: [RFC 10/18] omap3isp: Move the syscon register out of the ISP register maps
Date: Mon, 16 Mar 2015 02:19:04 +0200	[thread overview]
Message-ID: <5344778.cfsY6SCB4g@avalon> (raw)
In-Reply-To: <1425764475-27691-11-git-send-email-sakari.ailus@iki.fi>

Hi Sakari,

On Saturday 07 March 2015 23:41:07 Sakari Ailus wrote:
> The syscon register isn't part of the ISP, use it through the syscom driver
> regmap instead. The syscom block is considered to be from 343x on ISP
> revision 2.0 whereas 15.0 is assumed to have 3630 syscon.
> 
> Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
> ---
>  arch/arm/boot/dts/omap3.dtsi                |    2 +-
>  arch/arm/mach-omap2/devices.c               |   10 ----------
>  drivers/media/platform/omap3isp/isp.c       |   19 +++++++++++++++----
>  drivers/media/platform/omap3isp/isp.h       |   19 +++++++++++++++++--
>  drivers/media/platform/omap3isp/ispcsiphy.c |   20 +++++++++-----------

I've noticed another issue, you need a "select MFD_SYSCON" in Kconfig.

>  5 files changed, 42 insertions(+), 28 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
> index 01b7111..fe0b293 100644
> --- a/arch/arm/boot/dts/omap3.dtsi
> +++ b/arch/arm/boot/dts/omap3.dtsi
> @@ -183,7 +183,7 @@
> 
>  		omap3_scm_general: tisyscon@48002270 {
>  			compatible = "syscon";
> -			reg = <0x48002270 0x2f0>;
> +			reg = <0x48002270 0x2f4>;
>  		};
> 
>  		pbias_regulator: pbias_regulator {
> diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
> index 1afb50d..e945957 100644
> --- a/arch/arm/mach-omap2/devices.c
> +++ b/arch/arm/mach-omap2/devices.c
> @@ -143,16 +143,6 @@ static struct resource omap3isp_resources[] = {
>  		.flags		= IORESOURCE_MEM,
>  	},
>  	{
> -		.start		= OMAP343X_CTRL_BASE + OMAP343X_CONTROL_CSIRXFE,
> -		.end		= OMAP343X_CTRL_BASE + OMAP343X_CONTROL_CSIRXFE + 3,
> -		.flags		= IORESOURCE_MEM,
> -	},
> -	{
> -		.start		= OMAP343X_CTRL_BASE + OMAP3630_CONTROL_CAMERA_PHY_CTRL,
> -		.end		= OMAP343X_CTRL_BASE + OMAP3630_CONTROL_CAMERA_PHY_CTRL + 3,
> -		.flags		= IORESOURCE_MEM,
> -	},
> -	{
>  		.start		= 24 + OMAP_INTC_START,
>  		.flags		= IORESOURCE_IRQ,
>  	}
> diff --git a/drivers/media/platform/omap3isp/isp.c
> b/drivers/media/platform/omap3isp/isp.c index 68d7edfc..4ff4bbd 100644
> --- a/drivers/media/platform/omap3isp/isp.c
> +++ b/drivers/media/platform/omap3isp/isp.c
> @@ -51,6 +51,7 @@
>  #include <linux/dma-mapping.h>
>  #include <linux/i2c.h>
>  #include <linux/interrupt.h>
> +#include <linux/mfd/syscon.h>
>  #include <linux/module.h>
>  #include <linux/omap-iommu.h>
>  #include <linux/platform_device.h>
> @@ -94,8 +95,9 @@ static const struct isp_res_mapping isp_res_maps[] = {
>  		       1 << OMAP3_ISP_IOMEM_RESZ |
>  		       1 << OMAP3_ISP_IOMEM_SBL |
>  		       1 << OMAP3_ISP_IOMEM_CSI2A_REGS1 |
> -		       1 << OMAP3_ISP_IOMEM_CSIPHY2 |
> -		       1 << OMAP3_ISP_IOMEM_343X_CONTROL_CSIRXFE,
> +		       1 << OMAP3_ISP_IOMEM_CSIPHY2,
> +		.syscon_offset = 0xdc,
> +		.phy_type = ISP_PHY_TYPE_3430,
>  	},
>  	{
>  		.isp_rev = ISP_REVISION_15_0,
> @@ -112,8 +114,9 @@ static const struct isp_res_mapping isp_res_maps[] = {
>  		       1 << OMAP3_ISP_IOMEM_CSI2A_REGS2 |
>  		       1 << OMAP3_ISP_IOMEM_CSI2C_REGS1 |
>  		       1 << OMAP3_ISP_IOMEM_CSIPHY1 |
> -		       1 << OMAP3_ISP_IOMEM_CSI2C_REGS2 |
> -		       1 << OMAP3_ISP_IOMEM_3630_CONTROL_CAMERA_PHY_CTRL,
> +		       1 << OMAP3_ISP_IOMEM_CSI2C_REGS2,
> +		.syscon_offset = 0x2f0,
> +		.phy_type = ISP_PHY_TYPE_3630,
>  	},
>  };
> 
> @@ -2352,6 +2355,14 @@ static int isp_probe(struct platform_device *pdev)
>  		}
>  	}
> 
> +	isp->syscon = syscon_regmap_lookup_by_pdevname("syscon.0");
> +	isp->syscon_offset = isp_res_maps[m].syscon_offset;
> +	isp->phy_type = isp_res_maps[m].phy_type;
> +	if (IS_ERR(isp->syscon)) {
> +		ret = PTR_ERR(isp->syscon);
> +		goto error_isp;
> +	}
> +
>  	/* IOMMU */
>  	ret = isp_attach_iommu(isp);
>  	if (ret < 0) {
> diff --git a/drivers/media/platform/omap3isp/isp.h
> b/drivers/media/platform/omap3isp/isp.h index 9535524..03d2129 100644
> --- a/drivers/media/platform/omap3isp/isp.h
> +++ b/drivers/media/platform/omap3isp/isp.h
> @@ -59,8 +59,6 @@ enum isp_mem_resources {
>  	OMAP3_ISP_IOMEM_CSI2C_REGS1,
>  	OMAP3_ISP_IOMEM_CSIPHY1,
>  	OMAP3_ISP_IOMEM_CSI2C_REGS2,
> -	OMAP3_ISP_IOMEM_343X_CONTROL_CSIRXFE,
> -	OMAP3_ISP_IOMEM_3630_CONTROL_CAMERA_PHY_CTRL,
>  	OMAP3_ISP_IOMEM_LAST
>  };
> 
> @@ -93,14 +91,25 @@ enum isp_subclk_resource {
>  /* ISP2P: OMAP 36xx */
>  #define ISP_REVISION_15_0		0xF0
> 
> +#define ISP_PHY_TYPE_3430		0
> +#define ISP_PHY_TYPE_3630		1
> +
> +struct regmap;
> +
>  /*
>   * struct isp_res_mapping - Map ISP io resources to ISP revision.
>   * @isp_rev: ISP_REVISION_x_x
>   * @map: bitmap for enum isp_mem_resources
> + * @syscon_offset: offset of the syscon register for 343x / 3630
> + *	    (CONTROL_CSIRXFE / CONTROL_CAMERA_PHY_CTRL, respectively)
> + *	    from the syscon base address
> + * @phy_type: ISP_PHY_TYPE_{3430,3630}
>   */
>  struct isp_res_mapping {
>  	u32 isp_rev;
>  	u32 map;
> +	u32 syscon_offset;
> +	u32 phy_type;
>  };
> 
>  /*
> @@ -140,6 +149,9 @@ struct isp_xclk {
>   *             regions.
>   * @mmio_hist_base_phys: Physical L4 bus address for ISP hist block
> register *			 region.
> + * @syscon: Regmap for the syscon register space
> + * @syscon_offset: Offset of the CSIPHY control register in syscon
> + * @phy_type: ISP_PHY_TYPE_{3430,3630}
>   * @mapping: IOMMU mapping
>   * @stat_lock: Spinlock for handling statistics
>   * @isp_mutex: Mutex for serializing requests to ISP.
> @@ -176,6 +188,9 @@ struct isp_device {
> 
>  	void __iomem *mmio_base[OMAP3_ISP_IOMEM_LAST];
>  	unsigned long mmio_hist_base_phys;
> +	struct regmap *syscon;
> +	u32 syscon_offset;
> +	u32 phy_type;
> 
>  	struct dma_iommu_mapping *mapping;
> 
> diff --git a/drivers/media/platform/omap3isp/ispcsiphy.c
> b/drivers/media/platform/omap3isp/ispcsiphy.c index 4486e9f..d91dde1 100644
> --- a/drivers/media/platform/omap3isp/ispcsiphy.c
> +++ b/drivers/media/platform/omap3isp/ispcsiphy.c
> @@ -16,6 +16,7 @@
> 
>  #include <linux/delay.h>
>  #include <linux/device.h>
> +#include <linux/regmap.h>
>  #include <linux/regulator/consumer.h>
> 
>  #include "isp.h"
> @@ -26,10 +27,11 @@ static void csiphy_routing_cfg_3630(struct isp_csiphy
> *phy, enum isp_interface_type iface,
>  				    bool ccp2_strobe)
>  {
> -	u32 reg = isp_reg_readl(
> -		phy->isp, OMAP3_ISP_IOMEM_3630_CONTROL_CAMERA_PHY_CTRL, 0);
> +	u32 reg;
>  	u32 shift, mode;
> 
> +	regmap_read(phy->isp->syscon, phy->isp->syscon_offset, &reg);
> +
>  	switch (iface) {
>  	default:
>  	/* Should not happen in practice, but let's keep the compiler happy. */
> @@ -63,8 +65,7 @@ static void csiphy_routing_cfg_3630(struct isp_csiphy
> *phy, reg &= ~(OMAP3630_CONTROL_CAMERA_PHY_CTRL_CAMMODE_MASK << shift); reg
> |= mode << shift;
> 
> -	isp_reg_writel(phy->isp, reg,
> -		       OMAP3_ISP_IOMEM_3630_CONTROL_CAMERA_PHY_CTRL, 0);
> +	regmap_write(phy->isp->syscon, phy->isp->syscon_offset, reg);
>  }
> 
>  static void csiphy_routing_cfg_3430(struct isp_csiphy *phy, u32 iface, bool
> on, @@ -78,16 +79,14 @@ static void csiphy_routing_cfg_3430(struct
> isp_csiphy *phy, u32 iface, bool on, return;
> 
>  	if (!on) {
> -		isp_reg_writel(phy->isp, 0,
> -			       OMAP3_ISP_IOMEM_343X_CONTROL_CSIRXFE, 0);
> +		regmap_write(phy->isp->syscon, phy->isp->syscon_offset, 0);
>  		return;
>  	}
> 
>  	if (ccp2_strobe)
>  		csirxfe |= OMAP343X_CONTROL_CSIRXFE_SELFORM;
> 
> -	isp_reg_writel(phy->isp, csirxfe,
> -		       OMAP3_ISP_IOMEM_343X_CONTROL_CSIRXFE, 0);
> +	regmap_write(phy->isp->syscon, phy->isp->syscon_offset, csirxfe);
>  }
> 
>  /*
> @@ -106,10 +105,9 @@ static void csiphy_routing_cfg(struct isp_csiphy *phy,
>  			       enum isp_interface_type iface, bool on,
>  			       bool ccp2_strobe)
>  {
> -	if (phy->isp->mmio_base[OMAP3_ISP_IOMEM_3630_CONTROL_CAMERA_PHY_CTRL]
> -	    && on)
> +	if (phy->isp->phy_type == ISP_PHY_TYPE_3630 && on)
>  		return csiphy_routing_cfg_3630(phy, iface, ccp2_strobe);
> -	if (phy->isp->mmio_base[OMAP3_ISP_IOMEM_343X_CONTROL_CSIRXFE])
> +	if (phy->isp->phy_type == ISP_PHY_TYPE_3430)
>  		return csiphy_routing_cfg_3430(phy, iface, on, ccp2_strobe);
>  }

-- 
Regards,

Laurent Pinchart

  parent reply	other threads:[~2015-03-16  0:19 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-07 21:40 [RFC 00/18] Device tree support for omap3isp, N9[50] primary camera Sakari Ailus
     [not found] ` <1425764475-27691-1-git-send-email-sakari.ailus-X3B1VOXEql0@public.gmane.org>
2015-03-07 21:40   ` [RFC 01/18] omap3isp: Fix error handling in probe Sakari Ailus
2015-03-07 21:40     ` Sakari Ailus
2015-03-07 23:17     ` Laurent Pinchart
2015-03-07 21:41   ` [RFC 03/18] omap3isp: Separate external link creation from platform data parsing Sakari Ailus
2015-03-07 21:41     ` Sakari Ailus
2015-03-07 23:23     ` Laurent Pinchart
2015-03-07 21:41   ` [RFC 04/18] omap3isp: DT support for clocks Sakari Ailus
2015-03-07 21:41     ` Sakari Ailus
2015-03-07 21:41   ` [RFC 05/18] omap3isp: Platform data could be NULL Sakari Ailus
2015-03-07 21:41     ` Sakari Ailus
2015-03-07 23:50     ` Laurent Pinchart
2015-03-07 21:41   ` [RFC 06/18] omap3isp: Refactor device configuration structs for Device Tree Sakari Ailus
2015-03-07 21:41     ` Sakari Ailus
2015-03-11 23:07     ` Laurent Pinchart
2015-03-07 21:41   ` [RFC 09/18] omap3isp: Replace mmio_base_phys array with the histogram block base Sakari Ailus
2015-03-07 21:41     ` Sakari Ailus
2015-03-07 23:28     ` Laurent Pinchart
2015-03-07 21:41   ` [RFC 10/18] omap3isp: Move the syscon register out of the ISP register maps Sakari Ailus
2015-03-07 21:41     ` Sakari Ailus
2015-03-07 23:34     ` Laurent Pinchart
2015-03-07 23:43       ` Sakari Ailus
2015-03-07 23:43         ` Sakari Ailus
2015-03-09 15:20         ` Tony Lindgren
2015-03-14 15:00           ` Sakari Ailus
2015-03-16  0:19     ` Laurent Pinchart [this message]
2015-03-16 23:21       ` Sakari Ailus
2015-03-16 23:21         ` Sakari Ailus
2015-03-07 21:41   ` [RFC 13/18] v4l: of: Read lane-polarity endpoint property Sakari Ailus
2015-03-07 21:41     ` Sakari Ailus
2015-03-07 23:49     ` Laurent Pinchart
2015-03-12 22:23       ` Sakari Ailus
     [not found]         ` <20150312222327.GM11954-S+BSfZ9RZZmRSg0ZkenSGLdO1Tsj/99ntUK59QYPAWc@public.gmane.org>
2015-03-12 22:25           ` Sakari Ailus
2015-03-12 22:25             ` Sakari Ailus
2015-03-07 21:41   ` [RFC 17/18] arm: dts: n950, n9: Add primary camera support Sakari Ailus
2015-03-07 21:41     ` Sakari Ailus
     [not found]     ` <1425764475-27691-18-git-send-email-sakari.ailus-X3B1VOXEql0@public.gmane.org>
2015-03-07 23:56       ` Laurent Pinchart
2015-03-07 23:56         ` Laurent Pinchart
2015-03-08  0:03         ` Sakari Ailus
2015-03-08  0:03           ` Sakari Ailus
2015-03-07 21:41   ` [RFC 18/18] omap3isp: Deprecate platform data support Sakari Ailus
2015-03-07 21:41     ` Sakari Ailus
2015-03-07 23:35     ` Laurent Pinchart
     [not found]     ` <1425764475-27691-19-git-send-email-sakari.ailus-X3B1VOXEql0@public.gmane.org>
2015-03-13  9:40       ` Sebastian Reichel
2015-03-13  9:40         ` Sebastian Reichel
2015-03-13 16:43         ` Tony Lindgren
2015-03-13 16:43           ` Tony Lindgren
2015-03-07 21:40 ` [RFC 02/18] omap3isp: Avoid a BUG_ON() in media_entity_create_link() Sakari Ailus
2015-03-07 23:19   ` Laurent Pinchart
2015-03-07 21:41 ` [RFC 07/18] omap3isp: Rename regulators to better suit the Device Tree Sakari Ailus
2015-03-07 23:26   ` Laurent Pinchart
2015-03-07 21:41 ` [RFC 08/18] omap3isp: Calculate vpclk_div for CSI-2 Sakari Ailus
2015-03-07 23:27   ` Laurent Pinchart
2015-03-07 21:41 ` [RFC 11/18] omap3isp: Replace many MMIO regions by two Sakari Ailus
2015-03-07 23:43   ` Laurent Pinchart
2015-03-09 15:22     ` Tony Lindgren
2015-03-07 21:41 ` [RFC 12/18] dt: bindings: Add lane-polarity property to endpoint nodes Sakari Ailus
2015-03-07 23:46   ` Laurent Pinchart
2015-03-07 23:57     ` Sakari Ailus
2015-03-07 21:41 ` [RFC 14/18] dt: bindings: Add bindings for omap3isp Sakari Ailus
2015-03-11 23:39   ` Laurent Pinchart
2015-03-12 23:03     ` Sakari Ailus
2015-03-12 23:03       ` Sakari Ailus
2015-03-12 23:11       ` Laurent Pinchart
2015-03-12 23:43         ` Sakari Ailus
2015-03-12 23:43           ` Sakari Ailus
     [not found]       ` <20150312230320.GO11954-S+BSfZ9RZZmRSg0ZkenSGLdO1Tsj/99ntUK59QYPAWc@public.gmane.org>
2015-03-13  9:34         ` Sebastian Reichel
2015-03-13  9:34           ` Sebastian Reichel
2015-03-14  0:33           ` Laurent Pinchart
2015-03-14 14:10           ` Sakari Ailus
2015-03-07 21:41 ` [RFC 15/18] omap3isp: Add support for the Device Tree Sakari Ailus
     [not found]   ` <1425764475-27691-16-git-send-email-sakari.ailus-X3B1VOXEql0@public.gmane.org>
2015-03-11 23:48     ` Laurent Pinchart
2015-03-11 23:48       ` Laurent Pinchart
2015-03-14 14:12       ` Sakari Ailus
2015-03-07 21:41 ` [RFC 16/18] arm: dts: omap3: Add DT entries for OMAP 3 Sakari Ailus
     [not found]   ` <1425764475-27691-17-git-send-email-sakari.ailus-X3B1VOXEql0@public.gmane.org>
2015-03-07 23:51     ` Laurent Pinchart
2015-03-07 23:51       ` Laurent Pinchart
2015-03-14 14:43       ` Sakari Ailus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5344778.cfsY6SCB4g@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=pali.rohar@gmail.com \
    --cc=sakari.ailus@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.