linux/drivers/media/platform/nxp/imx8mq-mipi-csi2.c

// SPDX-License-Identifier: GPL-2.0
/*
 * NXP i.MX8MQ SoC series MIPI-CSI2 receiver driver
 *
 * Copyright (C) 2021 Purism SPC
 */

#include <linux/clk.h>
#include <linux/clk-provider.h>
#include <linux/delay.h>
#include <linux/errno.h>
#include <linux/interconnect.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/mfd/syscon.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/reset.h>
#include <linux/spinlock.h>

#include <media/v4l2-common.h>
#include <media/v4l2-device.h>
#include <media/v4l2-fwnode.h>
#include <media/v4l2-mc.h>
#include <media/v4l2-subdev.h>

#define MIPI_CSI2_DRIVER_NAME
#define MIPI_CSI2_SUBDEV_NAME

#define MIPI_CSI2_PAD_SINK
#define MIPI_CSI2_PAD_SOURCE
#define MIPI_CSI2_PADS_NUM

#define MIPI_CSI2_DEF_PIX_WIDTH
#define MIPI_CSI2_DEF_PIX_HEIGHT

/* Register map definition */

/* i.MX8MQ CSI-2 controller CSR */
#define CSI2RX_CFG_NUM_LANES
#define CSI2RX_CFG_DISABLE_DATA_LANES
#define CSI2RX_BIT_ERR
#define CSI2RX_IRQ_STATUS
#define CSI2RX_IRQ_MASK
#define CSI2RX_IRQ_MASK_ALL
#define CSI2RX_IRQ_MASK_ULPS_STATUS_CHANGE
#define CSI2RX_ULPS_STATUS
#define CSI2RX_PPI_ERRSOT_HS
#define CSI2RX_PPI_ERRSOTSYNC_HS
#define CSI2RX_PPI_ERRESC
#define CSI2RX_PPI_ERRSYNCESC
#define CSI2RX_PPI_ERRCONTROL
#define CSI2RX_CFG_DISABLE_PAYLOAD_0
#define CSI2RX_CFG_VID_VC_IGNORE
#define CSI2RX_CFG_VID_VC
#define CSI2RX_CFG_VID_P_FIFO_SEND_LEVEL
#define CSI2RX_CFG_DISABLE_PAYLOAD_1

enum {};

enum imx8mq_mipi_csi_clk {};

static const char * const imx8mq_mipi_csi_clk_id[CSI2_NUM_CLKS] =;

#define CSI2_NUM_CLKS

#define GPR_CSI2_1_RX_ENABLE
#define GPR_CSI2_1_VID_INTFC_ENB
#define GPR_CSI2_1_HSEL
#define GPR_CSI2_1_CONT_CLK_MODE
#define GPR_CSI2_1_S_PRG_RXHS_SETTLE(x)

/*
 * The send level configures the number of entries that must accumulate in
 * the Pixel FIFO before the data will be transferred to the video output.
 * The exact value needed for this configuration is dependent on the rate at
 * which the sensor transfers data to the CSI-2 Controller and the user
 * video clock.
 *
 * The calculation is the classical rate-in rate-out type of problem: If the
 * video bandwidth is 10% faster than the incoming mipi data and the video
 * line length is 500 pixels, then the fifo should be allowed to fill
 * 10% of the line length or 50 pixels. If the gap data is ok, then the level
 * can be set to 16 and ignored.
 */
#define CSI2RX_SEND_LEVEL

struct csi_state {};

/* -----------------------------------------------------------------------------
 * Format helpers
 */

struct csi2_pix_format {};

static const struct csi2_pix_format imx8mq_mipi_csi_formats[] =;

static const struct csi2_pix_format *find_csi2_format(u32 code)
{}

/* -----------------------------------------------------------------------------
 * Hardware configuration
 */

static inline void imx8mq_mipi_csi_write(struct csi_state *state, u32 reg, u32 val)
{}

static int imx8mq_mipi_csi_sw_reset(struct csi_state *state)
{}

static void imx8mq_mipi_csi_set_params(struct csi_state *state)
{}

static int imx8mq_mipi_csi_clk_enable(struct csi_state *state)
{}

static void imx8mq_mipi_csi_clk_disable(struct csi_state *state)
{}

static int imx8mq_mipi_csi_clk_get(struct csi_state *state)
{}

static int imx8mq_mipi_csi_calc_hs_settle(struct csi_state *state,
					  struct v4l2_subdev_state *sd_state,
					  u32 *hs_settle)
{}

static int imx8mq_mipi_csi_start_stream(struct csi_state *state,
					struct v4l2_subdev_state *sd_state)
{}

static void imx8mq_mipi_csi_stop_stream(struct csi_state *state)
{}

/* -----------------------------------------------------------------------------
 * V4L2 subdev operations
 */

static struct csi_state *mipi_sd_to_csi2_state(struct v4l2_subdev *sdev)
{}

static int imx8mq_mipi_csi_s_stream(struct v4l2_subdev *sd, int enable)
{}

static int imx8mq_mipi_csi_init_state(struct v4l2_subdev *sd,
				      struct v4l2_subdev_state *sd_state)
{}

static int imx8mq_mipi_csi_enum_mbus_code(struct v4l2_subdev *sd,
					  struct v4l2_subdev_state *sd_state,
					  struct v4l2_subdev_mbus_code_enum *code)
{}

static int imx8mq_mipi_csi_set_fmt(struct v4l2_subdev *sd,
				   struct v4l2_subdev_state *sd_state,
				   struct v4l2_subdev_format *sdformat)
{}

static const struct v4l2_subdev_video_ops imx8mq_mipi_csi_video_ops =;

static const struct v4l2_subdev_pad_ops imx8mq_mipi_csi_pad_ops =;

static const struct v4l2_subdev_ops imx8mq_mipi_csi_subdev_ops =;

static const struct v4l2_subdev_internal_ops imx8mq_mipi_csi_internal_ops =;

/* -----------------------------------------------------------------------------
 * Media entity operations
 */

static const struct media_entity_operations imx8mq_mipi_csi_entity_ops =;

/* -----------------------------------------------------------------------------
 * Async subdev notifier
 */

static struct csi_state *
mipi_notifier_to_csi2_state(struct v4l2_async_notifier *n)
{}

static int imx8mq_mipi_csi_notify_bound(struct v4l2_async_notifier *notifier,
					struct v4l2_subdev *sd,
					struct v4l2_async_connection *asd)
{}

static const struct v4l2_async_notifier_operations imx8mq_mipi_csi_notify_ops =;

static int imx8mq_mipi_csi_async_register(struct csi_state *state)
{}

/* -----------------------------------------------------------------------------
 * Suspend/resume
 */

static void imx8mq_mipi_csi_pm_suspend(struct device *dev)
{}

static int imx8mq_mipi_csi_pm_resume(struct device *dev)
{}

static int __maybe_unused imx8mq_mipi_csi_suspend(struct device *dev)
{}

static int __maybe_unused imx8mq_mipi_csi_resume(struct device *dev)
{}

static int __maybe_unused imx8mq_mipi_csi_runtime_suspend(struct device *dev)
{}

static int __maybe_unused imx8mq_mipi_csi_runtime_resume(struct device *dev)
{}

static const struct dev_pm_ops imx8mq_mipi_csi_pm_ops =;

/* -----------------------------------------------------------------------------
 * Probe/remove & platform driver
 */

static int imx8mq_mipi_csi_subdev_init(struct csi_state *state)
{}

static void imx8mq_mipi_csi_release_icc(struct platform_device *pdev)
{}

static int imx8mq_mipi_csi_init_icc(struct platform_device *pdev)
{}

static int imx8mq_mipi_csi_parse_dt(struct csi_state *state)
{}

static int imx8mq_mipi_csi_probe(struct platform_device *pdev)
{}

static void imx8mq_mipi_csi_remove(struct platform_device *pdev)
{}

static const struct of_device_id imx8mq_mipi_csi_of_match[] =;
MODULE_DEVICE_TABLE(of, imx8mq_mipi_csi_of_match);

static struct platform_driver imx8mq_mipi_csi_driver =;

module_platform_driver();

MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_LICENSE();
MODULE_ALIAS();