All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: linux-media@vger.kernel.org
Cc: Rui Miguel Silva <rmfrfs@gmail.com>,
	Steve Longerbeam <slongerbeam@gmail.com>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Ezequiel Garcia <ezequiel@collabora.com>,
	Fabio Estevam <festevam@gmail.com>
Subject: [PATCH v2 73/77] media: imx: imx7_mipi_csis: Define macros for DPHY_BCTRL_L fields
Date: Mon, 15 Feb 2021 06:27:37 +0200	[thread overview]
Message-ID: <20210215042741.28850-74-laurent.pinchart@ideasonboard.com> (raw)
In-Reply-To: <20210215042741.28850-1-laurent.pinchart@ideasonboard.com>

Define macros for the fields of the MIPI_CSIS_DPHY_BCTRL_L register,
based on the i.MX8MM datasheet. The numerical value written to the
register, taken from the i.MX7D code, is unchanged, and corresponds to a
20.0MHz Tx escape clock frequency according to the documentation of the
register from the i.MX8MM. Whether the other fields are applicable to
the i.MX7D is unknown.

While at it, rename the DPHY[BS]CTRL register names to DPHY_[BS]CTRL to
match the datasheet.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>
---
 drivers/staging/media/imx/imx7-mipi-csis.c | 53 +++++++++++++++++++---
 1 file changed, 47 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c b/drivers/staging/media/imx/imx7-mipi-csis.c
index 26f323bff498..f7dcadb4fab4 100644
--- a/drivers/staging/media/imx/imx7-mipi-csis.c
+++ b/drivers/staging/media/imx/imx7-mipi-csis.c
@@ -120,13 +120,47 @@
 #define MIPI_CSIS_DPHYCTRL_ENABLE		(0x1f << 0)
 
 /* D-PHY Master and Slave Control register Low */
-#define MIPI_CSIS_DPHYBCTRL_L			0x30
+#define MIPI_CSIS_DPHY_BCTRL_L			0x30
+#define MIPI_CSIS_DPHY_BCTRL_L_USER_DATA_PATTERN_LOW(n)		(((n) & 3U) << 30)
+#define MIPI_CSIS_DPHY_BCTRL_L_BIAS_REF_VOLT_715MV		(0 << 28)
+#define MIPI_CSIS_DPHY_BCTRL_L_BIAS_REF_VOLT_724MV		(1 << 28)
+#define MIPI_CSIS_DPHY_BCTRL_L_BIAS_REF_VOLT_733MV		(2 << 28)
+#define MIPI_CSIS_DPHY_BCTRL_L_BIAS_REF_VOLT_706MV		(3 << 28)
+#define MIPI_CSIS_DPHY_BCTRL_L_BGR_CHOPPER_FREQ_3MHZ		(0 << 27)
+#define MIPI_CSIS_DPHY_BCTRL_L_BGR_CHOPPER_FREQ_1_5MHZ		(1 << 27)
+#define MIPI_CSIS_DPHY_BCTRL_L_VREG12_EXTPWR_EN_CTL		BIT(26)
+#define MIPI_CSIS_DPHY_BCTRL_L_REG_12P_LVL_CTL_1_2V		(0 << 24)
+#define MIPI_CSIS_DPHY_BCTRL_L_REG_12P_LVL_CTL_1_23V		(1 << 24)
+#define MIPI_CSIS_DPHY_BCTRL_L_REG_12P_LVL_CTL_1_17V		(2 << 24)
+#define MIPI_CSIS_DPHY_BCTRL_L_REG_12P_LVL_CTL_1_26V		(3 << 24)
+#define MIPI_CSIS_DPHY_BCTRL_L_REG_1P2_LVL_SEL			BIT(23)
+#define MIPI_CSIS_DPHY_BCTRL_L_LP_RX_HYS_LVL_80MV		(0 << 21)
+#define MIPI_CSIS_DPHY_BCTRL_L_LP_RX_HYS_LVL_100MV		(1 << 21)
+#define MIPI_CSIS_DPHY_BCTRL_L_LP_RX_HYS_LVL_120MV		(2 << 21)
+#define MIPI_CSIS_DPHY_BCTRL_L_LP_RX_HYS_LVL_140MV		(3 << 21)
+#define MIPI_CSIS_DPHY_BCTRL_L_VREF_SRC_SEL			BIT(20)
+#define MIPI_CSIS_DPHY_BCTRL_L_LP_RX_VREF_LVL_715MV		(0 << 18)
+#define MIPI_CSIS_DPHY_BCTRL_L_LP_RX_VREF_LVL_743MV		(1 << 18)
+#define MIPI_CSIS_DPHY_BCTRL_L_LP_RX_VREF_LVL_650MV		(2 << 18)
+#define MIPI_CSIS_DPHY_BCTRL_L_LP_RX_VREF_LVL_682MV		(3 << 18)
+#define MIPI_CSIS_DPHY_BCTRL_L_LP_RX_PULSE_REJECT		BIT(17)
+#define MIPI_CSIS_DPHY_BCTRL_L_MSTRCLK_LP_SLEW_RATE_DOWN_0	(0 << 15)
+#define MIPI_CSIS_DPHY_BCTRL_L_MSTRCLK_LP_SLEW_RATE_DOWN_15P	(1 << 15)
+#define MIPI_CSIS_DPHY_BCTRL_L_MSTRCLK_LP_SLEW_RATE_DOWN_30P	(3 << 15)
+#define MIPI_CSIS_DPHY_BCTRL_L_MSTRCLK_LP_SLEW_RATE_UP		BIT(14)
+#define MIPI_CSIS_DPHY_BCTRL_L_LP_CD_HYS_60MV			(0 << 13)
+#define MIPI_CSIS_DPHY_BCTRL_L_LP_CD_HYS_70MV			(1 << 13)
+#define MIPI_CSIS_DPHY_BCTRL_L_BGR_CHOPPER_EN			BIT(12)
+#define MIPI_CSIS_DPHY_BCTRL_L_ERRCONTENTION_LP_EN		BIT(11)
+#define MIPI_CSIS_DPHY_BCTRL_L_TXTRIGGER_CLK_EN			BIT(10)
+#define MIPI_CSIS_DPHY_BCTRL_L_B_DPHYCTRL(n)			(((n) * 25 / 1000000) << 0)
+
 /* D-PHY Master and Slave Control register High */
-#define MIPI_CSIS_DPHYBCTRL_H			0x34
+#define MIPI_CSIS_DPHY_BCTRL_H			0x34
 /* D-PHY Slave Control register Low */
-#define MIPI_CSIS_DPHYSCTRL_L			0x38
+#define MIPI_CSIS_DPHY_SCTRL_L			0x38
 /* D-PHY Slave Control register High */
-#define MIPI_CSIS_DPHYSCTRL_H			0x3c
+#define MIPI_CSIS_DPHY_SCTRL_H			0x3c
 
 /* ISP Configuration register */
 #define MIPI_CSIS_ISPCONFIG_CH0			0x40
@@ -550,8 +584,15 @@ static void mipi_csis_set_params(struct csi_state *state)
 	val &= ~MIPI_CSIS_CLK_CTRL_CLKGATE_EN_MSK;
 	mipi_csis_write(state, MIPI_CSIS_CLK_CTRL, val);
 
-	mipi_csis_write(state, MIPI_CSIS_DPHYBCTRL_L, 0x1f4);
-	mipi_csis_write(state, MIPI_CSIS_DPHYBCTRL_H, 0);
+	mipi_csis_write(state, MIPI_CSIS_DPHY_BCTRL_L,
+			MIPI_CSIS_DPHY_BCTRL_L_BIAS_REF_VOLT_715MV |
+			MIPI_CSIS_DPHY_BCTRL_L_BGR_CHOPPER_FREQ_3MHZ |
+			MIPI_CSIS_DPHY_BCTRL_L_REG_12P_LVL_CTL_1_2V |
+			MIPI_CSIS_DPHY_BCTRL_L_LP_RX_HYS_LVL_80MV |
+			MIPI_CSIS_DPHY_BCTRL_L_LP_RX_VREF_LVL_715MV |
+			MIPI_CSIS_DPHY_BCTRL_L_LP_CD_HYS_60MV |
+			MIPI_CSIS_DPHY_BCTRL_L_B_DPHYCTRL(20000000));
+	mipi_csis_write(state, MIPI_CSIS_DPHY_BCTRL_H, 0);
 
 	/* Update the shadow register. */
 	val = mipi_csis_read(state, MIPI_CSIS_CMN_CTRL);
-- 
Regards,

Laurent Pinchart


  parent reply	other threads:[~2021-02-15  4:40 UTC|newest]

Thread overview: 100+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-15  4:26 [PATCH v2 00/77] media: imx: Miscellaneous fixes and cleanups for i.MX7 Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 01/77] media: imx: Drop dependency on I2C Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 02/77] media: imx: Move dependency on VIDEO_DEV to common Kconfig symbol Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 03/77] media: imx: Drop manual dependency on VIDEO_IMX_MEDIA Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 04/77] media: imx: Compile imx6-media-objs only for CONFIG_VIDEO_IMX_CSI Laurent Pinchart
2021-02-26 15:45   ` Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 05/77] media: imx: Set default sizes through macros in all drivers Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 06/77] media: imx: utils: Add ability to filter pixel formats by mbus code Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 07/77] media: imx: capture: Use dev_* instead of v4l2_* to log messages Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 08/77] media: imx: capture: Use device name to construct bus_info Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 09/77] media: imx: capture: Remove forward declaration of capture_qops Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 10/77] media: imx: capture: Handle errors from v4l2_fh_open() Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 11/77] media: imx: capture: Clean up capture_priv structure Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 12/77] media: imx: capture: Remove capture_priv stop field Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 13/77] media: imx: capture: Move queue and ctrl handler init to init function Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 14/77] media: imx: capture: Initialize video_device programmatically Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 15/77] media: imx: capture: Register the video device after completing init Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 16/77] media: imx: capture: Store v4l2_pix_format in imx_media_video_dev Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 17/77] media: imx: capture: Move default format init to a separate function Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 18/77] media: imx: capture: Rename querycap handler to capture_querycap Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 19/77] media: imx: capture: Rename ioctl operations with legacy prefix Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 20/77] media: imx: capture: Add a mechanism to disable control inheritance Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 21/77] media: imx: capture: Remove unneeded variable in __capture_legacy_try_fmt Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 22/77] media: imx: capture: Pass v4l2_pix_format to __capture_legacy_try_fmt() Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 23/77] media: imx: capture: Return -EPIPE from __capture_legacy_try_fmt() Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 24/77] media: imx: capture: Extract format lookup from __capture_legacy_try_fmt Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 25/77] media: imx: capture: Simplify capture_validate_fmt() implementation Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 26/77] media: imx: capture: Simplify __capture_legacy_try_fmt() Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 27/77] media: imx: capture: Decouple video node from source with MC-centric API Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 28/77] media: imx: capture: Expose V4L2_CAP_IO_MC for the " Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 29/77] media: imx: imx7-media-csi: Disable legacy video node API Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 30/77] media: imx: capture: Support creating immutable link to capture device Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 31/77] media: imx: imx7-media-csi: Remove control handler Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 32/77] media: imx: imx7-media-csi: Move (de)init from link setup to .s_stream() Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 33/77] media: imx: imx7-media-csi: Create immutable link to capture device Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 34/77] media: imx: imx7-media-csi: Replace CSICR*_RESET_VAL with values Laurent Pinchart
2021-02-15  4:26 ` [PATCH v2 35/77] media: imx: imx7-media-csi: Tidy up register fields macros Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 36/77] media: imx: imx7-media-csi: Reorganize code in sections Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 37/77] media: imx: imx7-media-csi: Validate capture format in .link_validate() Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 38/77] media: imx: imx7-media-csi: Fix source type identification Laurent Pinchart
2021-03-01  9:30   ` Rui Miguel Silva
2021-02-15  4:27 ` [PATCH v2 39/77] media: imx: imx7-media-csi: Don't lock access to is_csi2 Laurent Pinchart
2021-03-01  9:31   ` Rui Miguel Silva
2021-02-15  4:27 ` [PATCH v2 40/77] media: imx: imx7-media-csi: Rename imx7_csi_dma_start() to *_setup() Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 41/77] media: imx: imx7-media-csi: Split imx7_csi_dma_stop() Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 42/77] media: imx: imx7-media-csi: Move CSI configuration before source start Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 43/77] media: imx: imx7-media-csi: Merge streaming_start() with csi_enable() Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 44/77] media: imx: imx7-media-csi: Merge hw_reset() with init_interface() Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 45/77] media: imx: imx7-media-csi: Set the MIPI data type based on the bus code Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 46/77] media: imx: imx7-media-csi: Don't set the buffer stride when disabling Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 47/77] media: imx: imx7-media-csi: Merge all config in imx7_csi_configure() Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 48/77] media: imx: imx7-media-csi: Clear all configurable CSICR18 fields Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 49/77] media: imx: imx7-media-csi: Set RFF burst type in imx7_csi_configure() Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 50/77] media: imx: imx7-media-csi: Simplify imx7_csi_rx_fifo_clear() Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 51/77] media: imx: imx7-media-csi: Don't double-enable the CSI Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 52/77] media: imx: imx7-media-csi: Don't double-enable the RxFIFO Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 53/77] media: imx: imx7-media-csi: Remove double reflash of DMA controller Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 54/77] media: imx: imx7-media-csi: Don't enable SOF and EOF interrupts Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 55/77] media: imx: imx7_media-csi: Add support for additional Bayer patterns Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 56/77] media: v4l2-mc: Add link flags to v4l2_create_fwnode_links_to_pad() Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 57/77] media: imx: imx7_media-csi: Create immutable link to source device Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 58/77] dt-bindings: media: nxp,imx7-mipi-csi2: Drop the reset-names property Laurent Pinchart
2021-03-05 21:41   ` Rob Herring
2021-02-15  4:27 ` [PATCH v2 59/77] dt-bindings: media: nxp,imx7-mipi-csi2: Drop fsl,csis-hs-settle property Laurent Pinchart
2021-03-05 21:42   ` Rob Herring
2021-02-15  4:27 ` [PATCH v2 60/77] dt-bindings: media: nxp,imx7-mipi-csi2: Indent example with 4 spaces Laurent Pinchart
2021-03-01  9:33   ` Rui Miguel Silva
2021-03-05 21:42   ` Rob Herring
2021-02-15  4:27 ` [PATCH v2 61/77] dt-bindings: media: nxp,imx7-mipi-csi2: Expand descriptions Laurent Pinchart
2021-03-01  9:35   ` Rui Miguel Silva
2021-03-05 21:43   ` Rob Herring
2021-02-15  4:27 ` [PATCH v2 62/77] media: imx: imx7_mipi_csis: Acquire reset control without naming it Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 63/77] media: imx: imx7_mipi_csis: Fix input size alignment Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 64/77] media: imx: imx7_mipi_csis: Make source .s_power() optional Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 65/77] media: imx: imx7_mipi_csis: Avoid double get of wrap clock Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 66/77] media: imx: imx7_mipi_csis: Drop 10-bit YUV support Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 67/77] media: imx: imx7_mipi_csis: Fix UYVY8 media bus format Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 68/77] media: imx: imx7_mipi_csis: Inline mipi_csis_set_hsync_settle() Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 69/77] media: imx: imx7_mipi_csis: Move link setup check out of locked section Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 70/77] media: imx: imx7_mipi_csis: Calculate Ths_settle from source lane rate Laurent Pinchart
2021-03-01 16:40   ` [PATCH v2.1 " Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 71/77] media: imx: imx7_mipi_csis: Turn register access macros into functions Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 72/77] media: imx: imx7_mipi_csis: Fully initialize MIPI_CSIS_DPHYCTRL register Laurent Pinchart
2021-02-15  4:27 ` Laurent Pinchart [this message]
2021-02-15  4:27 ` [PATCH v2 74/77] media: imx: imx7_mipi_csis: Make ISP registers macros take channel ID Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 75/77] media: imx: imx7_mipi_csis: Rename register macros to match datasheet Laurent Pinchart
2021-03-01 16:41   ` [PATCH v2.1 " Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 76/77] media: imx: imx7_mipi_csis: Use register macros in mipi_csis_dump_regs() Laurent Pinchart
2021-02-15  4:27 ` [PATCH v2 77/77] media: imx: imx7_mipi_csis: Print shadow registers " Laurent Pinchart
2021-03-16 11:56 ` [PATCH] imx7-media-csi: csi2 only Martin Kepplinger
2021-03-16 18:05   ` Laurent Pinchart
2021-03-17 10:08     ` Martin Kepplinger
2021-03-17 10:19       ` Laurent Pinchart
2021-03-28 14:25         ` Martin Kepplinger
2021-03-28 16:43           ` Laurent Pinchart
2021-03-17 18:04 ` [PATCH v2 00/77] media: imx: Miscellaneous fixes and cleanups for i.MX7 Frieder Schrempf
2021-03-19  1:27   ` Laurent Pinchart
2021-04-15  9:00     ` Frieder Schrempf
2021-04-15 16:04       ` Frieder Schrempf
2021-04-26  8:06         ` Frieder Schrempf

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=20210215042741.28850-74-laurent.pinchart@ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=ezequiel@collabora.com \
    --cc=festevam@gmail.com \
    --cc=linux-media@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=rmfrfs@gmail.com \
    --cc=slongerbeam@gmail.com \
    /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.