Commit af54b4f4 authored by Paul Kocialkowski's avatar Paul Kocialkowski Committed by Mauro Carvalho Chehab

media: sunxi: Add support for the A31 MIPI CSI-2 controller

The 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.
Signed-off-by: default avatarPaul Kocialkowski <paul.kocialkowski@bootlin.com>
Acked-by: default avatarMaxime Ripard <mripard@kernel.org>
Reported-by: default avatarkernel test robot <lkp@intel.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent 787d6946
......@@ -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"
......@@ -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/
# 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.
# 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
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright 2020-2022 Bootlin
* Author: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
*/
#ifndef _SUN6I_MIPI_CSI2_H_
#define _SUN6I_MIPI_CSI2_H_
#include <linux/phy/phy.h>
#include <linux/regmap.h>
#include <linux/reset.h>
#include <media/v4l2-device.h>
#include <media/v4l2-fwnode.h>
#define SUN6I_MIPI_CSI2_NAME "sun6i-mipi-csi2"
enum sun6i_mipi_csi2_pad {
SUN6I_MIPI_CSI2_PAD_SINK = 0,
SUN6I_MIPI_CSI2_PAD_SOURCE = 1,
SUN6I_MIPI_CSI2_PAD_COUNT = 2,
};
struct sun6i_mipi_csi2_format {
u32 mbus_code;
u8 data_type;
u32 bpp;
};
struct sun6i_mipi_csi2_bridge {
struct v4l2_subdev subdev;
struct media_pad pads[SUN6I_MIPI_CSI2_PAD_COUNT];
struct v4l2_fwnode_endpoint endpoint;
struct v4l2_async_notifier notifier;
struct v4l2_mbus_framefmt mbus_format;
struct mutex lock; /* Mbus format lock. */
struct v4l2_subdev *source_subdev;
};
struct sun6i_mipi_csi2_device {
struct device *dev;
struct regmap *regmap;
struct clk *clock_mod;
struct reset_control *reset;
struct phy *dphy;
struct sun6i_mipi_csi2_bridge bridge;
};
#endif
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright 2020-2022 Bootlin
* Author: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
*/
#ifndef _SUN6I_MIPI_CSI2_REG_H_
#define _SUN6I_MIPI_CSI2_REG_H_
#define SUN6I_MIPI_CSI2_CTL_REG 0x0
#define SUN6I_MIPI_CSI2_CTL_RESET_N BIT(31)
#define SUN6I_MIPI_CSI2_CTL_VERSION_EN BIT(30)
#define SUN6I_MIPI_CSI2_CTL_UNPK_EN BIT(1)
#define SUN6I_MIPI_CSI2_CTL_EN BIT(0)
#define SUN6I_MIPI_CSI2_CFG_REG 0x4
#define SUN6I_MIPI_CSI2_CFG_CHANNEL_MODE(v) ((((v) - 1) << 8) & \
GENMASK(9, 8))
#define SUN6I_MIPI_CSI2_CFG_LANE_COUNT(v) (((v) - 1) & GENMASK(1, 0))
#define SUN6I_MIPI_CSI2_VCDT_RX_REG 0x8
#define SUN6I_MIPI_CSI2_VCDT_RX_CH_VC(ch, vc) (((vc) & GENMASK(1, 0)) << \
((ch) * 8 + 6))
#define SUN6I_MIPI_CSI2_VCDT_RX_CH_DT(ch, t) (((t) & GENMASK(5, 0)) << \
((ch) * 8))
#define SUN6I_MIPI_CSI2_RX_PKT_NUM_REG 0xc
#define SUN6I_MIPI_CSI2_VERSION_REG 0x3c
#define SUN6I_MIPI_CSI2_CH_CFG_REG 0x40
#define SUN6I_MIPI_CSI2_CH_INT_EN_REG 0x50
#define SUN6I_MIPI_CSI2_CH_INT_EN_EOT_ERR BIT(29)
#define SUN6I_MIPI_CSI2_CH_INT_EN_CHKSUM_ERR BIT(28)
#define SUN6I_MIPI_CSI2_CH_INT_EN_ECC_WRN BIT(27)
#define SUN6I_MIPI_CSI2_CH_INT_EN_ECC_ERR BIT(26)
#define SUN6I_MIPI_CSI2_CH_INT_EN_LINE_SYNC_ERR BIT(25)
#define SUN6I_MIPI_CSI2_CH_INT_EN_FRAME_SYNC_ERR BIT(24)
#define SUN6I_MIPI_CSI2_CH_INT_EN_EMB_DATA BIT(18)
#define SUN6I_MIPI_CSI2_CH_INT_EN_PF BIT(17)
#define SUN6I_MIPI_CSI2_CH_INT_EN_PH_UPDATE BIT(16)
#define SUN6I_MIPI_CSI2_CH_INT_EN_LINE_START_SYNC BIT(11)
#define SUN6I_MIPI_CSI2_CH_INT_EN_LINE_END_SYNC BIT(10)
#define SUN6I_MIPI_CSI2_CH_INT_EN_FRAME_START_SYNC BIT(9)
#define SUN6I_MIPI_CSI2_CH_INT_EN_FRAME_END_SYNC BIT(8)
#define SUN6I_MIPI_CSI2_CH_INT_EN_FIFO_OVER BIT(0)
#define SUN6I_MIPI_CSI2_CH_INT_PD_REG 0x58
#define SUN6I_MIPI_CSI2_CH_INT_PD_CLEAR 0xff
#define SUN6I_MIPI_CSI2_CH_INT_PD_EOT_ERR BIT(29)
#define SUN6I_MIPI_CSI2_CH_INT_PD_CHKSUM_ERR BIT(28)
#define SUN6I_MIPI_CSI2_CH_INT_PD_ECC_WRN BIT(27)
#define SUN6I_MIPI_CSI2_CH_INT_PD_ECC_ERR BIT(26)
#define SUN6I_MIPI_CSI2_CH_INT_PD_LINE_SYNC_ERR BIT(25)
#define SUN6I_MIPI_CSI2_CH_INT_PD_FRAME_SYNC_ERR BIT(24)
#define SUN6I_MIPI_CSI2_CH_INT_PD_EMB_DATA BIT(18)
#define SUN6I_MIPI_CSI2_CH_INT_PD_PF BIT(17)
#define SUN6I_MIPI_CSI2_CH_INT_PD_PH_UPDATE BIT(16)
#define SUN6I_MIPI_CSI2_CH_INT_PD_LINE_START_SYNC BIT(11)
#define SUN6I_MIPI_CSI2_CH_INT_PD_LINE_END_SYNC BIT(10)
#define SUN6I_MIPI_CSI2_CH_INT_PD_FRAME_START_SYNC BIT(9)
#define SUN6I_MIPI_CSI2_CH_INT_PD_FRAME_END_SYNC BIT(8)
#define SUN6I_MIPI_CSI2_CH_INT_PD_FIFO_OVER BIT(0)
#define SUN6I_MIPI_CSI2_CH_DT_TRIGGER_REG 0x60
#define SUN6I_MIPI_CSI2_CH_CUR_PH_REG 0x70
#define SUN6I_MIPI_CSI2_CH_ECC_REG 0x74
#define SUN6I_MIPI_CSI2_CH_CKS_REG 0x78
#define SUN6I_MIPI_CSI2_CH_FRAME_NUM_REG 0x7c
#define SUN6I_MIPI_CSI2_CH_LINE_NUM_REG 0x80
#define SUN6I_MIPI_CSI2_CH_OFFSET 0x100
#define SUN6I_MIPI_CSI2_CH_REG(reg, ch) \
(SUN6I_MIPI_CSI2_CH_OFFSET * (ch) + (reg))
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment