Allwinner A31/A83T MIPI CSI-2 and A31 ISP / MIPI CSI-2 Support
Subsystems (6)
v4 cover Allwinner A31/A83T MIPI CSI-2 and A31 ISP / MIPI CSI-2 Support
This new version is an offspring from the big "Allwinner A31/A83T MIPI CSI-2 Support and A31 ISP Support" series, which was split into individual series for better clarity and handling.
This part only concerns the MIPI CSI-2 controllers support changes.
Changes since v3:
- Updated Kconfig to follow the latest media-wide changes;
- Switched to clock-managed regmap mmio;
- Various cosmetic cleanups;
- Used endpoint-base instead of video-interface for "internal" endpoints in device-tree schema;
- Removed clock-lanes property in device-tree schema since lane reordering is not possible;
Changes since all-in-one v2:
- Use the newly-introduced media/mipi-csi2.h header instead of local definitions;
- Introduce a use a mutex for format access serialization;
- Make both port@0 and port@1 as well as ports required in the binding;
- Made one of the two CSI input ports required;
Paul Kocialkowski (8):
dt-bindings: sun6i-a31-mipi-dphy: Add optional direction property
phy: allwinner: phy-sun6i-mipi-dphy: Support D-PHY Rx mode for MIPI
CSI-2
dt-bindings: media: sun6i-a31-csi: Add MIPI CSI-2 input port
dt-bindings: media: Add Allwinner A31 MIPI CSI-2 bindings
documentation
media: sunxi: Add support for the A31 MIPI CSI-2 controller
MAINTAINERS: Add entry for the Allwinner A31 MIPI CSI-2 bridge driver
dt-bindings: media: Add Allwinner A83T MIPI CSI-2 bindings
documentation
media: sunxi: Add support for the A83T MIPI CSI-2 controller
.../media/allwinner,sun6i-a31-csi.yaml | 72 +- .../media/allwinner,sun6i-a31-mipi-csi2.yaml | 147 ++++ .../media/allwinner,sun8i-a83t-mipi-csi2.yaml | 135 +++ .../phy/allwinner,sun6i-a31-mipi-dphy.yaml | 12 + MAINTAINERS | 8 + drivers/media/platform/sunxi/Kconfig | 2 + drivers/media/platform/sunxi/Makefile | 2 + .../platform/sunxi/sun6i-mipi-csi2/Kconfig | 14 + .../platform/sunxi/sun6i-mipi-csi2/Makefile | 4 + .../sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c | 749 ++++++++++++++++ .../sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.h | 52 ++ .../sun6i-mipi-csi2/sun6i_mipi_csi2_reg.h | 76 ++ .../sunxi/sun8i-a83t-mipi-csi2/Kconfig | 12 + .../sunxi/sun8i-a83t-mipi-csi2/Makefile | 4 + .../sun8i-a83t-mipi-csi2/sun8i_a83t_dphy.c | 72 ++ .../sun8i-a83t-mipi-csi2/sun8i_a83t_dphy.h | 39 + .../sun8i_a83t_mipi_csi2.c | 815 ++++++++++++++++++ .../sun8i_a83t_mipi_csi2.h | 55 ++ .../sun8i_a83t_mipi_csi2_reg.h | 151 ++++ drivers/phy/allwinner/phy-sun6i-mipi-dphy.c | 166 +++- 20 files changed, 2569 insertions(+), 18 deletions(-) create mode 100644 Documentation/devicetree/bindings/media/allwinner,sun6i-a31-mipi-csi2.yaml create mode 100644 Documentation/devicetree/bindings/media/allwinner,sun8i-a83t-mipi-csi2.yaml create mode 100644 drivers/media/platform/sunxi/sun6i-mipi-csi2/Kconfig create mode 100644 drivers/media/platform/sunxi/sun6i-mipi-csi2/Makefile create mode 100644 drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c create mode 100644 drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.h create mode 100644 drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2_reg.h create mode 100644 drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/Kconfig create mode 100644 drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/Makefile create mode 100644 drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_dphy.c create mode 100644 drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_dphy.h create mode 100644 drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c create mode 100644 drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.h create mode 100644 drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2_reg.h
Signature · 1 line
2.35.2
PATCH v4 1/8 dt-bindings: sun6i-a31-mipi-dphy: Add optional direction property
The Allwinner A31 MIPI D-PHY block supports both tx and rx directions, although each instance of the block is meant to be used in one direction only. There will typically be one instance for MIPI DSI and one for MIPI CSI-2 (it seems unlikely to ever see a shared instance).
Describe the direction with a new allwinner,direction property. For backwards compatibility, the property is optional and tx mode should be assumed by default.
--- .../bindings/phy/allwinner,sun6i-a31-mipi-dphy.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+)
Documentation/devicetree/bindings/phy/allwinner,sun6i-a31-mipi-dphy.yaml +12 -0
@@ -37,6 +37,18 @@ properties: resets: maxItems: 1 + allwinner,direction: + $ref: '/schemas/types.yaml#/definitions/string' + description: | + Direction of the D-PHY: + - "rx" for receiving (e.g. when used with MIPI CSI-2); + - "tx" for transmitting (e.g. when used with MIPI DSI). + + enum: + - tx + - rx + default: tx + required: - "#phy-cells" - compatible
Signature · 1 line
2.35.2
Re: [PATCH v4 1/8] dt-bindings: sun6i-a31-mipi-dphy: Add optional direction property
Quoted 8 lines · Paul Kocialkowski
The Allwinner A31 MIPI D-PHY block supports both tx and rx directions, although each instance of the block is meant to be used in one direction only. There will typically be one instance for MIPI DSI and one for MIPI CSI-2 (it seems unlikely to ever see a shared instance).
Describe the direction with a new allwinner,direction property. For backwards compatibility, the property is optional and tx mode should be assumed by default.
Applied to phy-next, thanks
Signature · 1 line
~Vinod
PATCH v4 2/8 phy: allwinner: phy-sun6i-mipi-dphy: Support D-PHY Rx mode for MIPI CSI-2
In reply to Paul KocialkowskiThe Allwinner A31 D-PHY supports both Rx and Tx modes. While the latter is already supported and used for MIPI DSI this adds support for the former, to be used with MIPI CSI-2.
This implementation is inspired by Allwinner's V3s Linux SDK implementation, which was used as a documentation base.
It uses the direction dt property to distinguish between tx and rx directions.
--- drivers/phy/allwinner/phy-sun6i-mipi-dphy.c | 166 +++++++++++++++++++- 1 file changed, 162 insertions(+), 4 deletions(-)
drivers/phy/allwinner/phy-sun6i-mipi-dphy.c +162 -4
@@ -24,6 +24,14 @@#define SUN6I_DPHY_TX_CTL_REG 0x04#define SUN6I_DPHY_TX_CTL_HS_TX_CLK_CONT BIT(28) +#define SUN6I_DPHY_RX_CTL_REG 0x08 +#define SUN6I_DPHY_RX_CTL_EN_DBC BIT(31) +#define SUN6I_DPHY_RX_CTL_RX_CLK_FORCE BIT(24) +#define SUN6I_DPHY_RX_CTL_RX_D3_FORCE BIT(23) +#define SUN6I_DPHY_RX_CTL_RX_D2_FORCE BIT(22) +#define SUN6I_DPHY_RX_CTL_RX_D1_FORCE BIT(21) +#define SUN6I_DPHY_RX_CTL_RX_D0_FORCE BIT(20) +#define SUN6I_DPHY_TX_TIME0_REG 0x10#define SUN6I_DPHY_TX_TIME0_HS_TRAIL (n) (((n) & 0xff) << 24)#define SUN6I_DPHY_TX_TIME0_HS_PREPARE (n) (((n) & 0xff) << 16)
@@ -44,12 +52,29 @@#define SUN6I_DPHY_TX_TIME4_HS_TX_ANA1 (n) (((n) & 0xff) << 8)#define SUN6I_DPHY_TX_TIME4_HS_TX_ANA0 (n) ((n) & 0xff) +#define SUN6I_DPHY_RX_TIME0_REG 0x30 +#define SUN6I_DPHY_RX_TIME0_HS_RX_SYNC (n) (((n) & 0xff) << 24) +#define SUN6I_DPHY_RX_TIME0_HS_RX_CLK_MISS (n) (((n) & 0xff) << 16) +#define SUN6I_DPHY_RX_TIME0_LP_RX (n) (((n) & 0xff) << 8) + +#define SUN6I_DPHY_RX_TIME1_REG 0x34 +#define SUN6I_DPHY_RX_TIME1_RX_DLY (n) (((n) & 0xfff) << 20) +#define SUN6I_DPHY_RX_TIME1_LP_RX_ULPS_WP (n) ((n) & 0xfffff) + +#define SUN6I_DPHY_RX_TIME2_REG 0x38 +#define SUN6I_DPHY_RX_TIME2_HS_RX_ANA1 (n) (((n) & 0xff) << 8) +#define SUN6I_DPHY_RX_TIME2_HS_RX_ANA0 (n) ((n) & 0xff) + +#define SUN6I_DPHY_RX_TIME3_REG 0x40 +#define SUN6I_DPHY_RX_TIME3_LPRST_DLY (n) (((n) & 0xffff) << 16) +#define SUN6I_DPHY_ANA0_REG 0x4c#define SUN6I_DPHY_ANA0_REG_PWS BIT(31)#define SUN6I_DPHY_ANA0_REG_DMPC BIT(28)#define SUN6I_DPHY_ANA0_REG_DMPD (n) (((n) & 0xf) << 24)#define SUN6I_DPHY_ANA0_REG_SLV (n) (((n) & 7) << 12)#define SUN6I_DPHY_ANA0_REG_DEN (n) (((n) & 0xf) << 8) +#define SUN6I_DPHY_ANA0_REG_SFB (n) (((n) & 3) << 2)#define SUN6I_DPHY_ANA1_REG 0x50#define SUN6I_DPHY_ANA1_REG_VTTMODE BIT(31)
@@ -84,6 +109,11 @@#define SUN6I_DPHY_DBG5_REG 0xf4 +enum sun6i_dphy_direction { +SUN6I_DPHY_DIRECTION_TX , +SUN6I_DPHY_DIRECTION_RX , +}; +struct sun6i_dphy {struct clk *bus_clk;struct clk *mod_clk;
@@ -92,6 +122,8 @@ struct sun6i_dphy {struct phy *phy;struct phy_configure_opts_mipi_dphy config; + +enum sun6i_dphy_direction direction; };static int sun6i_dphy_init (struct phy *phy)
@@ -119,9 +151,8 @@ static int sun6i_dphy_configure(struct phy *phy, union phy_configure_opts *opts)return 0 ; } -static int sun6i_dphy_power_on (struct phy *phy) +static int sun6i_dphy_tx_power_on (struct sun6i_dphy *dphy) { -struct sun6i_dphy *dphy =phy_get_drvdata (phy);u8 lanes_mask =GENMASK (dphy->config.lanes -1 ,0 ); regmap_write(dphy->regs, SUN6I_DPHY_TX_CTL_REG,
@@ -211,12 +242,129 @@ static int sun6i_dphy_power_on(struct phy *phy)return 0 ; } +static int sun6i_dphy_rx_power_on (struct sun6i_dphy *dphy) +{ +/* Physical clock rate is actually half of symbol rate with DDR. */ +unsigned long mipi_symbol_rate = dphy->config.hs_clk_rate; +unsigned long dphy_clk_rate; +unsigned int rx_dly; +unsigned int lprst_dly; +u32 value; + + dphy_clk_rate =clk_get_rate (dphy->mod_clk); +if (!dphy_clk_rate) +return -EINVAL ; + +/* Hardcoded timing parameters from the Allwinner BSP. */ +regmap_write (dphy->regs,SUN6I_DPHY_RX_TIME0_REG , +SUN6I_DPHY_RX_TIME0_HS_RX_SYNC (255 ) | +SUN6I_DPHY_RX_TIME0_HS_RX_CLK_MISS (255 ) | +SUN6I_DPHY_RX_TIME0_LP_RX (255 )); + +/* +* Formula from the Allwinner BSP, with hardcoded coefficients +* (probably internal divider/multiplier). +*/ + rx_dly =8 * (unsigned int )(dphy_clk_rate / (mipi_symbol_rate /8 )); + +/* +* The Allwinner BSP has an alternative formula for LP_RX_ULPS_WP: +* lp_ulps_wp_cnt = lp_ulps_wp_ms * lp_clk / 1000 +* but does not use it and hardcodes 255 instead. +*/ +regmap_write (dphy->regs,SUN6I_DPHY_RX_TIME1_REG , +SUN6I_DPHY_RX_TIME1_RX_DLY (rx_dly) | +SUN6I_DPHY_RX_TIME1_LP_RX_ULPS_WP (255 )); + +/* HS_RX_ANA0 value is hardcoded in the Allwinner BSP. */ +regmap_write (dphy->regs,SUN6I_DPHY_RX_TIME2_REG , +SUN6I_DPHY_RX_TIME2_HS_RX_ANA0 (4 )); + +/* +* Formula from the Allwinner BSP, with hardcoded coefficients +* (probably internal divider/multiplier). +*/ + lprst_dly =4 * (unsigned int )(dphy_clk_rate / (mipi_symbol_rate /2 )); + +regmap_write (dphy->regs,SUN6I_DPHY_RX_TIME3_REG , +SUN6I_DPHY_RX_TIME3_LPRST_DLY (lprst_dly)); + +/* Analog parameters are hardcoded in the Allwinner BSP. */ +regmap_write (dphy->regs,SUN6I_DPHY_ANA0_REG , +SUN6I_DPHY_ANA0_REG_PWS | +SUN6I_DPHY_ANA0_REG_SLV (7 ) | +SUN6I_DPHY_ANA0_REG_SFB (2 )); + +regmap_write (dphy->regs,SUN6I_DPHY_ANA1_REG , +SUN6I_DPHY_ANA1_REG_SVTT (4 )); + +regmap_write (dphy->regs,SUN6I_DPHY_ANA4_REG , +SUN6I_DPHY_ANA4_REG_DMPLVC | +SUN6I_DPHY_ANA4_REG_DMPLVD (1 )); + +regmap_write (dphy->regs,SUN6I_DPHY_ANA2_REG , +SUN6I_DPHY_ANA2_REG_ENIB ); + +regmap_write (dphy->regs,SUN6I_DPHY_ANA3_REG , +SUN6I_DPHY_ANA3_EN_LDOR | +SUN6I_DPHY_ANA3_EN_LDOC | +SUN6I_DPHY_ANA3_EN_LDOD ); + +/* +* Delay comes from the Allwinner BSP, likely for internal regulator +* ramp-up. +*/ +udelay (3 ); + + value =SUN6I_DPHY_RX_CTL_EN_DBC |SUN6I_DPHY_RX_CTL_RX_CLK_FORCE ; + +/* +* Rx data lane force-enable bits are used as regular RX enable by the +* Allwinner BSP. +*/ +if (dphy->config.lanes >=1 ) + value |=SUN6I_DPHY_RX_CTL_RX_D0_FORCE ; +if (dphy->config.lanes >=2 ) + value |=SUN6I_DPHY_RX_CTL_RX_D1_FORCE ; +if (dphy->config.lanes >=3 ) + value |=SUN6I_DPHY_RX_CTL_RX_D2_FORCE ; +if (dphy->config.lanes ==4 ) + value |=SUN6I_DPHY_RX_CTL_RX_D3_FORCE ; + +regmap_write (dphy->regs,SUN6I_DPHY_RX_CTL_REG , value); + +regmap_write (dphy->regs,SUN6I_DPHY_GCTL_REG , +SUN6I_DPHY_GCTL_LANE_NUM (dphy->config.lanes) | +SUN6I_DPHY_GCTL_EN ); + +return 0 ; +} + +static int sun6i_dphy_power_on (struct phy *phy) +{ +struct sun6i_dphy *dphy =phy_get_drvdata (phy); + +switch (dphy->direction) { +case SUN6I_DPHY_DIRECTION_TX : +return sun6i_dphy_tx_power_on (dphy); +case SUN6I_DPHY_DIRECTION_RX : +return sun6i_dphy_rx_power_on (dphy); +default : +return -EINVAL ; + } +} +static int sun6i_dphy_power_off (struct phy *phy) {struct sun6i_dphy *dphy =phy_get_drvdata (phy); -regmap_update_bits (dphy->regs,SUN6I_DPHY_ANA1_REG , -SUN6I_DPHY_ANA1_REG_VTTMODE ,0 ); +regmap_write (dphy->regs,SUN6I_DPHY_GCTL_REG ,0 ); + +regmap_write (dphy->regs,SUN6I_DPHY_ANA0_REG ,0 ); +regmap_write (dphy->regs,SUN6I_DPHY_ANA1_REG ,0 ); +regmap_write (dphy->regs,SUN6I_DPHY_ANA2_REG ,0 ); +regmap_write (dphy->regs,SUN6I_DPHY_ANA3_REG ,0 ); +regmap_write (dphy->regs,SUN6I_DPHY_ANA4_REG ,0 );return 0 ; }
@@ -253,7 +401,9 @@ static int sun6i_dphy_probe(struct platform_device *pdev) {struct phy_provider *phy_provider;struct sun6i_dphy *dphy; +const char *direction;void __iomem *regs; +int ret; dphy =devm_kzalloc (&pdev->dev,sizeof (*dphy),GFP_KERNEL );if (!dphy)
@@ -290,6 +440,14 @@ static int sun6i_dphy_probe(struct platform_device *pdev)return PTR_ERR (dphy->phy); } + dphy->direction =SUN6I_DPHY_DIRECTION_TX ; + + ret =of_property_read_string (pdev->dev.of_node,"allwinner,direction" , + &direction); + +if (!ret && !strncmp (direction,"rx" ,2 )) + dphy->direction =SUN6I_DPHY_DIRECTION_RX ; +phy_set_drvdata (dphy->phy, dphy); phy_provider =devm_of_phy_provider_register (&pdev->dev, of_phy_simple_xlate);
Signature · 1 line
2.35.2
Re: [PATCH v4 2/8] phy: allwinner: phy-sun6i-mipi-dphy: Support D-PHY Rx mode for MIPI CSI-2
Quoted 9 lines · Paul Kocialkowski
The Allwinner A31 D-PHY supports both Rx and Tx modes. While the latter is already supported and used for MIPI DSI this adds support for the former, to be used with MIPI CSI-2.
This implementation is inspired by Allwinner's V3s Linux SDK implementation, which was used as a documentation base.
It uses the direction dt property to distinguish between tx and rx directions.
Applied to phy-next, thanks
Signature · 1 line
~Vinod
PATCH v4 3/8 dt-bindings: media: sun6i-a31-csi: Add MIPI CSI-2 input port
In reply to Paul KocialkowskiThe A31 CSI controller supports two distinct input interfaces:
parallel and an external MIPI CSI-2 bridge. The parallel interface is often connected to a set of hardware pins while the MIPI CSI-2 bridge is an internal FIFO-ish link. As a result, these two inputs are distinguished as two different ports.
Note that only one of the two may be present on a controller instance. For example, the V3s has one controller dedicated to MIPI-CSI2 and one dedicated to parallel.
Update the binding with an explicit ports node that holds two distinct port nodes: one for parallel input and one for MIPI CSI-2.
This is backward-compatible with the single-port approach that was previously taken for representing the parallel interface port, which stays enumerated as fwnode port 0.
Note that additional ports may be added in the future, especially to support feeding the CSI controller's output to the ISP.
--- .../media/allwinner,sun6i-a31-csi.yaml | 72 +++++++++++++++---- 1 file changed, 58 insertions(+), 14 deletions(-)
Documentation/devicetree/bindings/media/allwinner,sun6i-a31-csi.yaml +58 -14
@@ -42,6 +42,7 @@ properties: port: $ref: /schemas/graph.yaml#/$defs/port-base + description: Parallel input port, connect to a parallel sensor properties: endpoint:
@@ -59,7 +60,38 @@ properties: required: - bus-width - additionalProperties: false + unevaluatedProperties: false + + ports: + $ref: /schemas/graph.yaml#/properties/ports + + properties: + port@0: + $ref: "#/properties/port" + + properties: + reg: + const: 0 + + port@1: + $ref: /schemas/graph.yaml#/$defs/port-base + description: MIPI CSI-2 bridge input port + + properties: + reg: + const: 1 + + endpoint: + $ref: /schemas/graph.yaml#/$defs/endpoint-base + unevaluatedProperties: false + + additionalProperties: false + + anyOf: + - required: + - port@0 + - required: + - port@1 required: - compatible
@@ -69,6 +101,12 @@ required: - clock-names - resets +oneOf: + - required: + - ports + - required: + - port + additionalProperties: false examples:
@@ -89,19 +127,25 @@ examples: "ram"; resets = <&ccu RST_BUS_CSI>; - port { - /* Parallel bus endpoint */ - csi1_ep: endpoint { - remote-endpoint = <&adv7611_ep>; - bus-width = <16>; - - /* - * If hsync-active/vsync-active are missing, - * embedded BT.656 sync is used. - */ - hsync-active = <0>; /* Active low */ - vsync-active = <0>; /* Active low */ - pclk-sample = <1>; /* Rising */ + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + /* Parallel bus endpoint */ + csi1_ep: endpoint { + remote-endpoint = <&adv7611_ep>; + bus-width = <16>; + + /* + * If hsync-active/vsync-active are missing, + * embedded BT.656 sync is used. + */ + hsync-active = <0>; /* Active low */ + vsync-active = <0>; /* Active low */ + pclk-sample = <1>; /* Rising */ + }; }; }; };
Signature · 1 line
2.35.2
PATCH v4 4/8 dt-bindings: media: Add Allwinner A31 MIPI CSI-2 bindings documentation
In reply to Paul KocialkowskiThis introduces YAML bindings documentation for the Allwinner A31 MIPI CSI-2 controller.
--- .../media/allwinner,sun6i-a31-mipi-csi2.yaml | 147 ++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/allwinner,sun6i-a31-mipi-csi2.yaml
Documentation/devicetree/bindings/media/allwinner,sun6i-a31-mipi-csi2.yaml new file +147 -0
@@ -0,0 +1,147 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/allwinner,sun6i-a31-mipi-csi2.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Allwinner A31 MIPI CSI-2 Device Tree Bindings + +maintainers: + - Paul Kocialkowski <[email protected]> + +properties: + compatible: + oneOf: + - const: allwinner,sun6i-a31-mipi-csi2 + - items: + - const: allwinner,sun8i-v3s-mipi-csi2 + - const: allwinner,sun6i-a31-mipi-csi2 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + items: + - description: Bus Clock + - description: Module Clock + + clock-names: + items: + - const: bus + - const: mod + + phys: + maxItems: 1 + description: MIPI D-PHY + + phy-names: + items: + - const: dphy + + resets: + maxItems: 1 + + ports: + $ref: /schemas/graph.yaml#/properties/ports + + properties: + port@0: + $ref: /schemas/graph.yaml#/$defs/port-base + description: Input port, connect to a MIPI CSI-2 sensor + + properties: + reg: + const: 0 + + endpoint: + $ref: video-interfaces.yaml# + unevaluatedProperties: false + + properties: + data-lanes: + minItems: 1 + maxItems: 4 + + required: + - data-lanes + + additionalProperties: false + + port@1: + $ref: /schemas/graph.yaml#/$defs/port-base + description: Output port, connect to a CSI controller + + properties: + reg: + const: 1 + + endpoint: + $ref: /schemas/graph.yaml#/$defs/endpoint-base + unevaluatedProperties: false + + additionalProperties: false + + required: + - port@0 + - port@1 + +required: + - compatible + - reg + - interrupts + - clocks + - clock-names + - phys + - phy-names + - resets + - ports + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/clock/sun8i-v3s-ccu.h> + #include <dt-bindings/reset/sun8i-v3s-ccu.h> + + mipi_csi2: csi@1cb1000 { + compatible = "allwinner,sun8i-v3s-mipi-csi2", + "allwinner,sun6i-a31-mipi-csi2"; + reg = <0x01cb1000 0x1000>; + interrupts = <GIC_SPI 90 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&ccu CLK_BUS_CSI>, + <&ccu CLK_CSI1_SCLK>; + clock-names = "bus", "mod"; + resets = <&ccu RST_BUS_CSI>; + + phys = <&dphy>; + phy-names = "dphy"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + mipi_csi2_in: port@0 { + reg = <0>; + + mipi_csi2_in_ov5648: endpoint { + data-lanes = <1 2 3 4>; + + remote-endpoint = <&ov5648_out_mipi_csi2>; + }; + }; + + mipi_csi2_out: port@1 { + reg = <1>; + + mipi_csi2_out_csi0: endpoint { + remote-endpoint = <&csi0_in_mipi_csi2>; + }; + }; + }; + }; + +...
Signature · 1 line
2.35.2
PATCH v4 5/8 media: sunxi: Add support for the A31 MIPI CSI-2 controller
In reply to Paul KocialkowskiThe A31 MIPI CSI-2 controller is a dedicated MIPI CSI-2 bridge found on Allwinner SoCs such as the A31 and V3/V3s.
It is a standalone block, connected to the CSI controller on one side and to the MIPI D-PHY block on the other. It has a dedicated address space, interrupt line and clock.
It is represented as a V4L2 subdev to the CSI controller and takes a MIPI CSI-2 sensor as its own subdev, all using the fwnode graph and media controller API.
Only 8-bit and 10-bit Bayer formats are currently supported. While up to 4 internal channels to the CSI controller exist, only one is currently supported by this implementation.
--- drivers/media/platform/sunxi/Kconfig | 1 + drivers/media/platform/sunxi/Makefile | 1 + .../platform/sunxi/sun6i-mipi-csi2/Kconfig | 14 + .../platform/sunxi/sun6i-mipi-csi2/Makefile | 4 + .../sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c | 749 ++++++++++++++++++ .../sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.h | 52 ++ .../sun6i-mipi-csi2/sun6i_mipi_csi2_reg.h | 76 ++ 7 files changed, 897 insertions(+) create mode 100644 drivers/media/platform/sunxi/sun6i-mipi-csi2/Kconfig create mode 100644 drivers/media/platform/sunxi/sun6i-mipi-csi2/Makefile create mode 100644 drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c create mode 100644 drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.h create mode 100644 drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2_reg.h
drivers/media/platform/sunxi/Kconfig +1 -0
@@ -4,5 +4,6 @@ comment "Sunxi media platform drivers" source "drivers/media/platform/sunxi/sun4i-csi/Kconfig" source "drivers/media/platform/sunxi/sun6i-csi/Kconfig" +source "drivers/media/platform/sunxi/sun6i-mipi-csi2/Kconfig" source "drivers/media/platform/sunxi/sun8i-di/Kconfig" source "drivers/media/platform/sunxi/sun8i-rotate/Kconfig"
drivers/media/platform/sunxi/Makefile +1 -0
@@ -2,5 +2,6 @@ obj-y += sun4i-csi/ obj-y += sun6i-csi/ +obj-y += sun6i-mipi-csi2/ obj-y += sun8i-di/ obj-y += sun8i-rotate/
drivers/media/platform/sunxi/sun6i-mipi-csi2/Kconfig new file +14 -0
@@ -0,0 +1,14 @@ +# SPDX-License-Identifier: GPL-2.0-only +config VIDEO_SUN6I_MIPI_CSI2 + tristate "Allwinner A31 MIPI CSI-2 Controller Driver" + depends on V4L_PLATFORM_DRIVERS && VIDEO_DEV + depends on ARCH_SUNXI || COMPILE_TEST + depends on PM && COMMON_CLK + select MEDIA_CONTROLLER + select VIDEO_V4L2_SUBDEV_API + select V4L2_FWNODE + select PHY_SUN6I_MIPI_DPHY + select REGMAP_MMIO + help + Support for the Allwinner A31 MIPI CSI-2 controller, also found on + other platforms such as the V3/V3s.
drivers/media/platform/sunxi/sun6i-mipi-csi2/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0-only +sun6i-mipi-csi2-y += sun6i_mipi_csi2.o + +obj-$(CONFIG_VIDEO_SUN6I_MIPI_CSI2) += sun6i-mipi-csi2.o
drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c new file +749 -0
749 lines not on this page · raw message
drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.h new file +52 -0
52 lines not on this page · raw message
drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2_reg.h new file +76 -0
76 lines not on this page · raw message
Signature · 1 line
2.35.2
PATCH v4 6/8 MAINTAINERS: Add entry for the Allwinner A31 MIPI CSI-2 bridge driver
In reply to Paul KocialkowskiAdd myself as maintainer of the Allwinner A31 MIPI CSI-2 bridge media driver.
--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)
MAINTAINERS +8 -0
@@ -761,6 +761,14 @@ T: git git://linuxtv.org/media_tree.git F: Documentation/devicetree/bindings/media/allwinner,sun4i-a10-csi.yaml F: drivers/media/platform/sunxi/sun4i-csi/ +ALLWINNER A31 MIPI CSI-2 BRIDGE DRIVER +M: Paul Kocialkowski <[email protected]> +L: [email protected] +S: Maintained +T: git git://linuxtv.org/media_tree.git +F: Documentation/devicetree/bindings/media/allwinner,sun6i-a31-mipi-csi2.yaml +F: drivers/media/platform/sunxi/sun6i-mipi-csi2/ + ALLWINNER CPUFREQ DRIVER M: Yangtao Li <[email protected]> L: [email protected]
Signature · 1 line
2.35.2
Re: [PATCH v4 6/8] MAINTAINERS: Add entry for the Allwinner A31 MIPI CSI-2 bridge driver
Dne petek, 15. april 2022 ob 17:21:36 CEST je Paul Kocialkowski napisal(a):
Quoted 4 lines
Add myself as maintainer of the Allwinner A31 MIPI CSI-2 bridge media driver.
Signed-off-by Paul Kocialkowski <[email protected]>
Best regards,
Jernej
MAINTAINERS T: git git://linuxtv.org/media_tree.git · line 761
Quoted 10 lines
--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)MAINTAINERS +0
-0@@ -761,6 +761,14 @@ T: git git://linuxtv.org/media_tree.git F: Documentation/devicetree/bindings/media/allwinner,sun4i-a10-
csi.yaml
MAINTAINERS T: git git://linuxtv.org/media_tree.git
Quoted 8 lines
MAINTAINERS +6
-0F: drivers/media/platform/sunxi/sun4i-csi/ +ALLWINNER A31 MIPI CSI-2 BRIDGE DRIVER +M: Paul Kocialkowski <[email protected]> +L: [email protected] +S: Maintained +T: git git://linuxtv.org/media_tree.git +F: Documentation/devicetree/bindings/media/allwinner,sun6i-a31-mipi-
csi2.ya
Quoted 5 lines
ml +F:
drivers/media/platform/sunxi/sun6i-mipi-csi2/
+
ALLWINNER CPUFREQ DRIVER
M: Yangtao Li <[email protected]>
L: [email protected]
PATCH v4 7/8 dt-bindings: media: Add Allwinner A83T MIPI CSI-2 bindings documentation
In reply to Paul KocialkowskiThis introduces YAML bindings documentation for the Allwinner A83T MIPI CSI-2 controller.
--- .../media/allwinner,sun8i-a83t-mipi-csi2.yaml | 135 ++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/allwinner,sun8i-a83t-mipi-csi2.yaml
Documentation/devicetree/bindings/media/allwinner,sun8i-a83t-mipi-csi2.yaml new file +135 -0
@@ -0,0 +1,135 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/allwinner,sun8i-a83t-mipi-csi2.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Allwinner A83T MIPI CSI-2 Device Tree Bindings + +maintainers: + - Paul Kocialkowski <[email protected]> + +properties: + compatible: + const: allwinner,sun8i-a83t-mipi-csi2 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + items: + - description: Bus Clock + - description: Module Clock + - description: MIPI-specific Clock + - description: Misc CSI Clock + + clock-names: + items: + - const: bus + - const: mod + - const: mipi + - const: misc + + resets: + maxItems: 1 + + ports: + $ref: /schemas/graph.yaml#/properties/ports + + properties: + port@0: + $ref: /schemas/graph.yaml#/$defs/port-base + description: Input port, connect to a MIPI CSI-2 sensor + + properties: + reg: + const: 0 + + endpoint: + $ref: video-interfaces.yaml# + unevaluatedProperties: false + + properties: + data-lanes: + minItems: 1 + maxItems: 4 + + required: + - data-lanes + + additionalProperties: false + + port@1: + $ref: /schemas/graph.yaml#/$defs/port-base + description: Output port, connect to a CSI controller + + properties: + reg: + const: 1 + + endpoint: + $ref: /schemas/graph.yaml#/$defs/endpoint-base + unevaluatedProperties: false + + additionalProperties: false + + required: + - port@0 + - port@1 + +required: + - compatible + - reg + - interrupts + - clocks + - clock-names + - resets + - ports + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/clock/sun8i-a83t-ccu.h> + #include <dt-bindings/reset/sun8i-a83t-ccu.h> + + mipi_csi2: csi@1cb1000 { + compatible = "allwinner,sun8i-a83t-mipi-csi2"; + reg = <0x01cb1000 0x1000>; + interrupts = <GIC_SPI 83 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&ccu CLK_BUS_CSI>, + <&ccu CLK_CSI_SCLK>, + <&ccu CLK_MIPI_CSI>, + <&ccu CLK_CSI_MISC>; + clock-names = "bus", "mod", "mipi", "misc"; + resets = <&ccu RST_BUS_CSI>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + mipi_csi2_in: port@0 { + reg = <0>; + + mipi_csi2_in_ov8865: endpoint { + data-lanes = <1 2 3 4>; + + remote-endpoint = <&ov8865_out_mipi_csi2>; + }; + }; + + mipi_csi2_out: port@1 { + reg = <1>; + + mipi_csi2_out_csi: endpoint { + remote-endpoint = <&csi_in_mipi_csi2>; + }; + }; + }; + }; + +...
Signature · 1 line
2.35.2
PATCH v4 8/8 media: sunxi: Add support for the A83T MIPI CSI-2 controller
In reply to Paul KocialkowskiThe A83T supports MIPI CSI-2 with a composite controller, covering both the protocol logic and the D-PHY implementation. This controller seems to be found on the A83T only and probably was abandoned since.
This implementation splits the protocol and D-PHY registers and uses the PHY framework internally. The D-PHY is not registered as a standalone PHY driver since it cannot be used with any other controller.
There are a few notable points about the controller:
- The initialisation sequence involes writing specific magic init values that do not seem to make any particular sense given the concerned register fields;
- Interrupts appear to be hitting regardless of the interrupt mask registers, which can cause a serious flood when transmission errors occur.
Only 8-bit and 10-bit Bayer formats are currently supported. While up to 4 internal channels to the CSI controller exist, only one is currently supported by this implementation.
This work is based on the first version of the driver submitted by Kévin L'hôpital, which was adapted to mainline from the Allwinner BSP. This version integrates MIPI CSI-2 support as a standalone V4L2 subdev instead of merging it in the sun6i-csi driver.
It was tested on a Banana Pi M3 board with an OV8865 sensor in a 4-lane configuration.
--- drivers/media/platform/sunxi/Kconfig | 1 + drivers/media/platform/sunxi/Makefile | 1 + .../sunxi/sun8i-a83t-mipi-csi2/Kconfig | 12 + .../sunxi/sun8i-a83t-mipi-csi2/Makefile | 4 + .../sun8i-a83t-mipi-csi2/sun8i_a83t_dphy.c | 72 ++ .../sun8i-a83t-mipi-csi2/sun8i_a83t_dphy.h | 39 + .../sun8i_a83t_mipi_csi2.c | 815 ++++++++++++++++++ .../sun8i_a83t_mipi_csi2.h | 55 ++ .../sun8i_a83t_mipi_csi2_reg.h | 151 ++++ 9 files changed, 1150 insertions(+) create mode 100644 drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/Kconfig create mode 100644 drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/Makefile create mode 100644 drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_dphy.c create mode 100644 drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_dphy.h create mode 100644 drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c create mode 100644 drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.h create mode 100644 drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2_reg.h
drivers/media/platform/sunxi/Kconfig +1 -0
@@ -5,5 +5,6 @@ comment "Sunxi media platform drivers" source "drivers/media/platform/sunxi/sun4i-csi/Kconfig" source "drivers/media/platform/sunxi/sun6i-csi/Kconfig" source "drivers/media/platform/sunxi/sun6i-mipi-csi2/Kconfig" +source "drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/Kconfig" source "drivers/media/platform/sunxi/sun8i-di/Kconfig" source "drivers/media/platform/sunxi/sun8i-rotate/Kconfig"
drivers/media/platform/sunxi/Makefile +1 -0
@@ -3,5 +3,6 @@ obj-y += sun4i-csi/ obj-y += sun6i-csi/ obj-y += sun6i-mipi-csi2/ +obj-y += sun8i-a83t-mipi-csi2/ obj-y += sun8i-di/ obj-y += sun8i-rotate/
drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/Kconfig new file +12 -0
@@ -0,0 +1,12 @@ +# SPDX-License-Identifier: GPL-2.0-only +config VIDEO_SUN8I_A83T_MIPI_CSI2 + tristate "Allwinner A83T MIPI CSI-2 Controller and D-PHY Driver" + depends on V4L_PLATFORM_DRIVERS && VIDEO_DEV + depends on ARCH_SUNXI || COMPILE_TEST + depends on PM && COMMON_CLK + select MEDIA_CONTROLLER + select VIDEO_V4L2_SUBDEV_API + select V4L2_FWNODE + select REGMAP_MMIO + help + Support for the Allwinner A83T MIPI CSI-2 controller and D-PHY.
drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0-only +sun8i-a83t-mipi-csi2-y += sun8i_a83t_mipi_csi2.o sun8i_a83t_dphy.o + +obj-$(CONFIG_VIDEO_SUN8I_A83T_MIPI_CSI2) += sun8i-a83t-mipi-csi2.o
drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_dphy.c new file +72 -0
72 lines not on this page · raw message
drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_dphy.h new file +39 -0
@@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright 2020 Kévin L'hôpital <[email protected]> +* Copyright 2020-2022 Bootlin +* Author: Paul Kocialkowski <[email protected]> +*/ + +#ifndef _SUN8I_A83T_DPHY_H_ +#define _SUN8I_A83T_DPHY_H_ + +#include "sun8i_a83t_mipi_csi2.h" + +#define SUN8I_A83T_DPHY_CTRL_REG 0x10 +#define SUN8I_A83T_DPHY_CTRL_INIT_VALUE 0xb8df698e +#define SUN8I_A83T_DPHY_CTRL_RESET_N BIT(31) +#define SUN8I_A83T_DPHY_CTRL_SHUTDOWN_N BIT(15) +#define SUN8I_A83T_DPHY_CTRL_DEBUG BIT(8) +#define SUN8I_A83T_DPHY_STATUS_REG 0x14 +#define SUN8I_A83T_DPHY_STATUS_CLK_STOP BIT(10) +#define SUN8I_A83T_DPHY_STATUS_CLK_ULPS BIT(9) +#define SUN8I_A83T_DPHY_STATUS_HSCLK BIT(8) +#define SUN8I_A83T_DPHY_STATUS_D3_STOP BIT(7) +#define SUN8I_A83T_DPHY_STATUS_D2_STOP BIT(6) +#define SUN8I_A83T_DPHY_STATUS_D1_STOP BIT(5) +#define SUN8I_A83T_DPHY_STATUS_D0_STOP BIT(4) +#define SUN8I_A83T_DPHY_STATUS_D3_ULPS BIT(3) +#define SUN8I_A83T_DPHY_STATUS_D2_ULPS BIT(2) +#define SUN8I_A83T_DPHY_STATUS_D1_ULPS BIT(1) +#define SUN8I_A83T_DPHY_STATUS_D0_ULPS BIT(0) + +#define SUN8I_A83T_DPHY_ANA0_REG 0x30 +#define SUN8I_A83T_DPHY_ANA0_REXT_EN BIT(31) +#define SUN8I_A83T_DPHY_ANA0_REXT BIT(30) +#define SUN8I_A83T_DPHY_ANA0_RINT (v) (((v) << 28) & GENMASK(29, 28)) +#define SUN8I_A83T_DPHY_ANA0_SNK (v) (((v) << 20) & GENMASK(22, 20)) + +int sun8i_a83t_dphy_register (struct sun8i_a83t_mipi_csi2_device *csi2_dev); + +#endif
drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c new file +815 -0
815 lines not on this page · raw message
drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.h new file +55 -0
55 lines not on this page · raw message
drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2_reg.h new file +151 -0
151 lines not on this page · raw message
Signature · 1 line
2.35.2