Allwinner A31/A83T MIPI CSI-2 and A31 ISP / MIPI CSI-2 Support
Subsystems (6)
v3 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 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 (9):
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
MAINTAINERS: Add entry for the Allwinner A83T MIPI CSI-2 bridge
.../media/allwinner,sun6i-a31-csi.yaml | 66 +- .../media/allwinner,sun6i-a31-mipi-csi2.yaml | 147 ++++ .../media/allwinner,sun8i-a83t-mipi-csi2.yaml | 138 +++ .../phy/allwinner,sun6i-a31-mipi-dphy.yaml | 12 + MAINTAINERS | 16 + drivers/media/platform/sunxi/Kconfig | 2 + drivers/media/platform/sunxi/Makefile | 2 + .../platform/sunxi/sun6i-mipi-csi2/Kconfig | 12 + .../platform/sunxi/sun6i-mipi-csi2/Makefile | 4 + .../sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c | 766 ++++++++++++++++ .../sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.h | 53 ++ .../sun6i-mipi-csi2/sun6i_mipi_csi2_reg.h | 76 ++ .../sunxi/sun8i-a83t-mipi-csi2/Kconfig | 11 + .../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 | 833 ++++++++++++++++++ .../sun8i_a83t_mipi_csi2.h | 56 ++ .../sun8i_a83t_mipi_csi2_reg.h | 151 ++++ drivers/phy/allwinner/phy-sun6i-mipi-dphy.c | 166 +++- 20 files changed, 2609 insertions(+), 17 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.1
PATCH v3 1/9 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.1
Re: [PATCH v3 1/9] dt-bindings: sun6i-a31-mipi-dphy: Add optional direction property
Quoted 5 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).
Quoted 9 lines
Describe the direction with a new allwinner,direction property. For backwards compatibility, the property is optional and tx mode should be assumed by default.
Signed-off-by Paul Kocialkowski <[email protected]>--- .../bindings/phy/allwinner,sun6i-a31-mipi-dphy.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+)
PATCH v3 2/9 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.1
PATCH v3 3/9 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 | 66 +++++++++++++++---- 1 file changed, 53 insertions(+), 13 deletions(-)
Documentation/devicetree/bindings/media/allwinner,sun6i-a31-csi.yaml +53 -13
@@ -61,6 +61,34 @@ properties: additionalProperties: false + ports: + $ref: /schemas/graph.yaml#/properties/ports + + properties: + port@0: + $ref: "#/properties/port" + unevaluatedProperties: false + + port@1: + $ref: /schemas/graph.yaml#/$defs/port-base + description: MIPI CSI-2 bridge input port + + properties: + reg: + const: 1 + + endpoint: + $ref: video-interfaces.yaml# + unevaluatedProperties: false + + additionalProperties: false + + anyOf: + - required: + - port@0 + - required: + - port@1 + required: - compatible - reg
@@ -69,6 +97,12 @@ required: - clock-names - resets +oneOf: + - required: + - ports + - required: + - port + additionalProperties: false examples:
@@ -89,19 +123,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.1
Rob Herring
maintainerRe: [PATCH v3 3/9] dt-bindings: media: sun6i-a31-csi: Add MIPI CSI-2 input port
Quoted 20 lines · Paul Kocialkowski
The 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.
Quoted 7 lines
Signed-off-by Paul Kocialkowski <[email protected]>Reviewed-by Rob Herring <[email protected]>Acked-by Maxime Ripard <[email protected]>--- .../media/allwinner,sun6i-a31-csi.yaml | 66 +++++++++++++++---- 1 file changed, 53 insertions(+), 13 deletions(-)
My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):
yamllint warnings/errors:./Documentation/devicetree/bindings/media/allwinner,sun6i-a31-csi.yaml:88:9: [warning] wrong indentation: expected 10 but found 8 (indentation) ./Documentation/devicetree/bindings/media/allwinner,sun6i-a31-csi.yaml:90:9: [warning] wrong indentation: expected 10 but found 8 (indentation) ./Documentation/devicetree/bindings/media/allwinner,sun6i-a31-csi.yaml:102:5: [warning] wrong indentation: expected 6 but found 4 (indentation) ./Documentation/devicetree/bindings/media/allwinner,sun6i-a31-csi.yaml:104:5: [warning] wrong indentation: expected 6 but found 4 (indentation)
dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/media/allwinner,sun6i-a31-csi.example.dt.yaml: csi@1cb4000: ports:port@0: 'reg' does not match any of the regexes: 'pinctrl-[0-9]+'
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/media/allwinner,sun6i-a31-csi.yaml
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/patch/1600105
This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit.
PATCH v3 4/9 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: video-interfaces.yaml# + 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.1
PATCH v3 5/9 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 | 12 + .../platform/sunxi/sun6i-mipi-csi2/Makefile | 4 + .../sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c | 766 ++++++++++++++++++ .../sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.h | 53 ++ .../sun6i-mipi-csi2/sun6i_mipi_csi2_reg.h | 76 ++ 7 files changed, 913 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
@@ -2,3 +2,4 @@ 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"
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 +12 -0
@@ -0,0 +1,12 @@ +# SPDX-License-Identifier: GPL-2.0-only +config VIDEO_SUN6I_MIPI_CSI2 + tristate "Allwinner A31 MIPI CSI-2 Controller Driver" + depends on ARCH_SUNXI || COMPILE_TEST + depends on PM && COMMON_CLK && VIDEO_V4L2 + select REGMAP_MMIO + select PHY_SUN6I_MIPI_DPHY + select MEDIA_CONTROLLER + select VIDEO_V4L2_SUBDEV_API + select V4L2_FWNODE + help + Support for the Allwinner A31 MIPI CSI-2 Controller.
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 +766 -0
766 lines not on this page · raw message
drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.h new file +53 -0
53 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.1
Re: [PATCH v3 5/9] media: sunxi: Add support for the A31 MIPI CSI-2 controller
Hi Paul,
Thanks for the set.
On Wed, Mar 02, 2022 at 11:07:35PM +0100, Paul Kocialkowski wrote:
...
Quoted 40 lines
drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c new file +40
-0+static int sun6i_mipi_csi2_s_stream (struct v4l2_subdev *subdev,int on) +{ +struct sun6i_mipi_csi2_device *csi2_dev =v4l2_get_subdevdata (subdev); +struct v4l2_subdev *source_subdev = csi2_dev->bridge.source_subdev; +union phy_configure_opts dphy_opts = {0 }; +struct phy_configure_opts_mipi_dphy *dphy_cfg = &dphy_opts.mipi_dphy; +struct v4l2_mbus_framefmt *mbus_format = &csi2_dev->bridge.mbus_format; +const struct sun6i_mipi_csi2_format *format; +struct phy *dphy = csi2_dev->dphy; +struct device *dev = csi2_dev->dev; +struct v4l2_ctrl *ctrl; +unsigned int lanes_count = + csi2_dev->bridge.endpoint.bus.mipi_csi2.num_data_lanes; +unsigned long pixel_rate; +/* Initialize to 0 to use both in disable label (ret != 0) and off. */ +int ret =0 ; + +if (!source_subdev) +return -ENODEV ; + +if (!on) { +v4l2_subdev_call (source_subdev, video, s_stream,0 ); + goto disable; + } + +/* Runtime PM */ + + ret =pm_runtime_resume_and_get (dev); +if (ret <0 ) +return ret; + +/* Sensor Pixel Rate */ + + ctrl =v4l2_ctrl_find (source_subdev->ctrl_handler,V4L2_CID_PIXEL_RATE ); +if (!ctrl) { +dev_err (dev,"missing sensor pixel rate\n" ); + ret = -ENODEV ; + goto error_pm; + } +
drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c line 220
Quoted 10 lines
drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c new file +10
-0+ pixel_rate = (unsigned long )v4l2_ctrl_g_ctrl_int64 (ctrl); +if (!pixel_rate) { +dev_err (dev,"missing (zero) sensor pixel rate\n" ); + ret = -ENODEV ; + goto error_pm; + } + +/* D-PHY */ + +if (!lanes_count) {
I first thought this check could be moved to the beginning, but it's also redundant. v4l2_fwnode_endpoint_parse() will check the configuration is valid, i.e. the number of lanes is not zero.
But should you add checks to make sure the hardware supports what has been configured? I'd do that right after parsing the endpoint.
And you only seem to be using the number of data lanes, nothing more. So I'd store that, instead of the entire parsed v4l2_fwnode_endpoint.
The same applies to patch 8.
I think these could be done on top of this set after it is merged. Up to you.
...
Quoted 31 lines
drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c new file +31
-0+static int +sun6i_mipi_csi2_bridge_source_setup (struct sun6i_mipi_csi2_device *csi2_dev) +{ +struct v4l2_async_notifier *notifier = &csi2_dev->bridge.notifier; +struct v4l2_fwnode_endpoint *endpoint = &csi2_dev->bridge.endpoint; +struct v4l2_async_subdev *subdev_async; +struct fwnode_handle *handle; +struct device *dev = csi2_dev->dev; +int ret; + + handle =fwnode_graph_get_endpoint_by_id (dev_fwnode (dev),0 ,0 , +FWNODE_GRAPH_ENDPOINT_NEXT ); +if (!handle) +return -ENODEV ; + + endpoint->bus_type =V4L2_MBUS_CSI2_DPHY ; + + ret =v4l2_fwnode_endpoint_parse (handle, endpoint); +if (ret) + goto complete; + + subdev_async =v4l2_async_nf_add_fwnode_remote (notifier, handle, + struct v4l2_async_subdev); +if (IS_ERR (subdev_async)) + ret =PTR_ERR (subdev_async); + +complete: +fwnode_handle_put (handle); + +return ret; +}
Signature · 3 lines
Kind regards, Sakari Ailus
Re: [PATCH v3 5/9] media: sunxi: Add support for the A31 MIPI CSI-2 controller
Hi Sakari,
Quoted 52 lines · Sakari Ailus
Hi Paul,
Thanks for the set.
On Wed, Mar 02, 2022 at 11:07:35PM +0100, Paul Kocialkowski wrote:
...Quoted 46 lines
drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c new file +46
-0+static int sun6i_mipi_csi2_s_stream (struct v4l2_subdev *subdev,int on) +{ +struct sun6i_mipi_csi2_device *csi2_dev =v4l2_get_subdevdata (subdev); +struct v4l2_subdev *source_subdev = csi2_dev->bridge.source_subdev; +union phy_configure_opts dphy_opts = {0 }; +struct phy_configure_opts_mipi_dphy *dphy_cfg = &dphy_opts.mipi_dphy; +struct v4l2_mbus_framefmt *mbus_format = &csi2_dev->bridge.mbus_format; +const struct sun6i_mipi_csi2_format *format; +struct phy *dphy = csi2_dev->dphy; +struct device *dev = csi2_dev->dev; +struct v4l2_ctrl *ctrl; +unsigned int lanes_count = + csi2_dev->bridge.endpoint.bus.mipi_csi2.num_data_lanes; +unsigned long pixel_rate; +/* Initialize to 0 to use both in disable label (ret != 0) and off. */ +int ret =0 ; + +if (!source_subdev) +return -ENODEV ; + +if (!on) { +v4l2_subdev_call (source_subdev, video, s_stream,0 ); + goto disable; + } + +/* Runtime PM */ + + ret =pm_runtime_resume_and_get (dev); +if (ret <0 ) +return ret; + +/* Sensor Pixel Rate */ + + ctrl =v4l2_ctrl_find (source_subdev->ctrl_handler,V4L2_CID_PIXEL_RATE ); +if (!ctrl) { +dev_err (dev,"missing sensor pixel rate\n" ); + ret = -ENODEV ; + goto error_pm; + } + + pixel_rate = (unsigned long )v4l2_ctrl_g_ctrl_int64 (ctrl); +if (!pixel_rate) { +dev_err (dev,"missing (zero) sensor pixel rate\n" ); + ret = -ENODEV ; + goto error_pm; + }
Quoted 8 lines
drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c line 220
Quoted 4 lines
drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c new file +4
-0+ +/* D-PHY */ + +if (!lanes_count) {I first thought this check could be moved to the beginning, but it's also redundant.
v4l2_fwnode_endpoint_parse()will check the configuration is valid, i.e. the number of lanes is not zero.
Good to know, thanks!
Quoted 2 lines
But should you add checks to make sure the hardware supports what has been configured? I'd do that right after parsing the endpoint.
I guess you mean checking that we don't get more than 4 lanes? And maybe something related to lane ordering too?
Quoted 2 lines
And you only seem to be using the number of data lanes, nothing more. So I'd store that, instead of the entire parsed
v4l2_fwnode_endpoint.
That's correct, why not.
Quoted 4 lines
The same applies to patch 8.
I think these could be done on top of this set after it is merged. Up to you.
I'll go for another iteration.
Thanks!
Paul
Quoted 38 lines
...
Quoted 31 lines
drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c new file +31
-0+static int +sun6i_mipi_csi2_bridge_source_setup (struct sun6i_mipi_csi2_device *csi2_dev) +{ +struct v4l2_async_notifier *notifier = &csi2_dev->bridge.notifier; +struct v4l2_fwnode_endpoint *endpoint = &csi2_dev->bridge.endpoint; +struct v4l2_async_subdev *subdev_async; +struct fwnode_handle *handle; +struct device *dev = csi2_dev->dev; +int ret; + + handle =fwnode_graph_get_endpoint_by_id (dev_fwnode (dev),0 ,0 , +FWNODE_GRAPH_ENDPOINT_NEXT ); +if (!handle) +return -ENODEV ; + + endpoint->bus_type =V4L2_MBUS_CSI2_DPHY ; + + ret =v4l2_fwnode_endpoint_parse (handle, endpoint); +if (ret) + goto complete; + + subdev_async =v4l2_async_nf_add_fwnode_remote (notifier, handle, + struct v4l2_async_subdev); +if (IS_ERR (subdev_async)) + ret =PTR_ERR (subdev_async); + +complete: +fwnode_handle_put (handle); + +return ret; +}Signature · 3 lines
Kind regards, Sakari Ailus
Signature · 3 lines
Paul Kocialkowski, Bootlin Embedded Linux and kernel engineering https://bootlin.com
PATCH v3 6/9 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
@@ -752,6 +752,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.1
PATCH v3 7/9 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 | 138 ++++++++++++++++++ 1 file changed, 138 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 +138 -0
@@ -0,0 +1,138 @@ +# 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: + clock-lanes: + maxItems: 1 + + 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: video-interfaces.yaml# + 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.1
Re: [PATCH v3 7/9] dt-bindings: media: Add Allwinner A83T MIPI CSI-2 bindings documentation
Hi Paul,
Thanks for the patch.
Quoted 63 lines · Paul Kocialkowski
This introduces YAML bindings documentation for the Allwinner A83T MIPI CSI-2 controller.
Signed-off-by Paul Kocialkowski <[email protected]>Reviewed-by Rob Herring <[email protected]>--- .../media/allwinner,sun8i-a83t-mipi-csi2.yaml | 138 ++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/allwinner,sun8i-a83t-mipi-csi2.yamlDocumentation/devicetree/bindings/media/allwinner,sun8i-a83t-mipi-csi2.yaml new file +47
-0@@ -0,0 +1,138 @@ +# 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:
Documentation/devicetree/bindings/media/allwinner,sun8i-a83t-mipi-csi2.yaml line 57
Quoted 10 lines
Documentation/devicetree/bindings/media/allwinner,sun8i-a83t-mipi-csi2.yaml new file +10
-0+ reg: + const: 0 + + endpoint: + $ref: video-interfaces.yaml# + unevaluatedProperties: false + + properties: + clock-lanes: + maxItems: 1
Does the hardware support lane reordering? If not, the property should be omitted here.
I can also remove the three lines here while applying the patches.
Quoted 81 lines
Documentation/devicetree/bindings/media/allwinner,sun8i-a83t-mipi-csi2.yaml new file +81
-0+ + 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: video-interfaces.yaml# + 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 · 3 lines
Kind regards, Sakari Ailus
Re: [PATCH v3 7/9] dt-bindings: media: Add Allwinner A83T MIPI CSI-2 bindings documentation
Hi Sakari,
Quoted 3 lines · Sakari Ailus
Hi Paul,
Thanks for the patch.
And thanks for the review!
Quoted 69 lines · Paul Kocialkowski
Quoted 68 lines
This introduces YAML bindings documentation for the Allwinner A83T MIPI CSI-2 controller.
Signed-off-by Paul Kocialkowski <[email protected]>Reviewed-by Rob Herring <[email protected]>--- .../media/allwinner,sun8i-a83t-mipi-csi2.yaml | 138 ++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/allwinner,sun8i-a83t-mipi-csi2.yamlDocumentation/devicetree/bindings/media/allwinner,sun8i-a83t-mipi-csi2.yaml new file +52
-0@@ -0,0 +1,138 @@ +# 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#
Quoted 8 lines
Documentation/devicetree/bindings/media/allwinner,sun8i-a83t-mipi-csi2.yaml line 57
Quoted 5 lines
Documentation/devicetree/bindings/media/allwinner,sun8i-a83t-mipi-csi2.yaml new file +5
-0+ unevaluatedProperties: false + + properties: + clock-lanes: + maxItems: 1Does the hardware support lane reordering? If not, the property should be omitted here.
I'm not sure what this relates to. Is it about inverting the clock lane with a data lane? I'm a bit confused about logical vs physical lane in the context of MIPI CSI-2.
The controller has dedicated pins for the clock and data lanes and supports filtering packets based on virtual channel or data type.
Are the clock-lanes and data-lanes only relevant for reordering? IIRC they are also necessary to get the lanes count in the driver.
Quoted 1 line
I can also remove the three lines here while applying the patches.
I think this series will need another iteration anyway, so let's wait.
Paul
Quoted 86 lines
Quoted 81 lines
Documentation/devicetree/bindings/media/allwinner,sun8i-a83t-mipi-csi2.yaml new file +81
-0+ + 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: video-interfaces.yaml# + 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 · 3 lines
Kind regards, Sakari Ailus
Signature · 3 lines
Paul Kocialkowski, Bootlin Embedded Linux and kernel engineering https://bootlin.com
PATCH v3 8/9 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 | 11 + .../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 | 833 ++++++++++++++++++ .../sun8i_a83t_mipi_csi2.h | 56 ++ .../sun8i_a83t_mipi_csi2_reg.h | 151 ++++ 9 files changed, 1168 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
@@ -3,3 +3,4 @@ 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"
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 +11 -0
@@ -0,0 +1,11 @@ +# 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 ARCH_SUNXI || COMPILE_TEST + depends on PM && COMMON_CLK && VIDEO_V4L2 + select REGMAP_MMIO + select MEDIA_CONTROLLER + select VIDEO_V4L2_SUBDEV_API + select V4L2_FWNODE + 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-2021 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 +833 -0
833 lines not on this page · raw message
drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.h new file +56 -0
56 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.1
PATCH v3 9/9 MAINTAINERS: Add entry for the Allwinner A83T MIPI CSI-2 bridge
In reply to Paul KocialkowskiAdd myself as maintainer of the Allwinner A83T MIPI CSI-2 bridge media driver.
--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)
MAINTAINERS +8 -0
@@ -760,6 +760,14 @@ 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 A83T 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,sun8i-a83t-mipi-csi2.yaml +F: drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/ + ALLWINNER CPUFREQ DRIVER M: Yangtao Li <[email protected]> L: [email protected]
Signature · 1 line
2.35.1