linux/drivers/media/i2c/ds90ub953.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Driver for the Texas Instruments DS90UB953 video serializer
 *
 * Based on a driver from Luca Ceresoli <[email protected]>
 *
 * Copyright (c) 2019 Luca Ceresoli <[email protected]>
 * Copyright (c) 2023 Tomi Valkeinen <[email protected]>
 */

#include <linux/clk-provider.h>
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/fwnode.h>
#include <linux/gpio/driver.h>
#include <linux/i2c-atr.h>
#include <linux/i2c.h>
#include <linux/kernel.h>
#include <linux/math64.h>
#include <linux/module.h>
#include <linux/property.h>
#include <linux/rational.h>
#include <linux/regmap.h>

#include <media/i2c/ds90ub9xx.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-event.h>
#include <media/v4l2-fwnode.h>
#include <media/v4l2-mediabus.h>
#include <media/v4l2-subdev.h>

#define UB953_PAD_SINK
#define UB953_PAD_SOURCE

#define UB953_NUM_GPIOS

#define UB953_DEFAULT_CLKOUT_RATE

#define UB953_REG_RESET_CTL
#define UB953_REG_RESET_CTL_DIGITAL_RESET_1
#define UB953_REG_RESET_CTL_DIGITAL_RESET_0

#define UB953_REG_GENERAL_CFG
#define UB953_REG_GENERAL_CFG_CONT_CLK
#define UB953_REG_GENERAL_CFG_CSI_LANE_SEL_SHIFT
#define UB953_REG_GENERAL_CFG_CSI_LANE_SEL_MASK
#define UB953_REG_GENERAL_CFG_CRC_TX_GEN_ENABLE
#define UB953_REG_GENERAL_CFG_I2C_STRAP_MODE

#define UB953_REG_MODE_SEL
#define UB953_REG_MODE_SEL_MODE_DONE
#define UB953_REG_MODE_SEL_MODE_OVERRIDE
#define UB953_REG_MODE_SEL_MODE_MASK

#define UB953_REG_CLKOUT_CTRL0
#define UB953_REG_CLKOUT_CTRL1

#define UB953_REG_SCL_HIGH_TIME
#define UB953_REG_SCL_LOW_TIME

#define UB953_REG_LOCAL_GPIO_DATA
#define UB953_REG_LOCAL_GPIO_DATA_GPIO_RMTEN(n)
#define UB953_REG_LOCAL_GPIO_DATA_GPIO_OUT_SRC(n)

#define UB953_REG_GPIO_INPUT_CTRL
#define UB953_REG_GPIO_INPUT_CTRL_OUT_EN(n)
#define UB953_REG_GPIO_INPUT_CTRL_INPUT_EN(n)

#define UB953_REG_REV_MASK_ID
#define UB953_REG_GENERAL_STATUS

#define UB953_REG_GPIO_PIN_STS
#define UB953_REG_GPIO_PIN_STS_GPIO_STS(n)

#define UB953_REG_BIST_ERR_CNT
#define UB953_REG_CRC_ERR_CNT1
#define UB953_REG_CRC_ERR_CNT2

#define UB953_REG_CSI_ERR_CNT
#define UB953_REG_CSI_ERR_STATUS
#define UB953_REG_CSI_ERR_DLANE01
#define UB953_REG_CSI_ERR_DLANE23
#define UB953_REG_CSI_ERR_CLK_LANE
#define UB953_REG_CSI_PKT_HDR_VC_ID
#define UB953_REG_PKT_HDR_WC_LSB
#define UB953_REG_PKT_HDR_WC_MSB
#define UB953_REG_CSI_ECC

#define UB953_REG_IND_ACC_CTL
#define UB953_REG_IND_ACC_ADDR
#define UB953_REG_IND_ACC_DATA

#define UB953_REG_FPD3_RX_ID(n)
#define UB953_REG_FPD3_RX_ID_LEN

/* Indirect register blocks */
#define UB953_IND_TARGET_PAT_GEN
#define UB953_IND_TARGET_FPD3_TX
#define UB953_IND_TARGET_DIE_ID

#define UB953_IND_PGEN_CTL
#define UB953_IND_PGEN_CTL_PGEN_ENABLE
#define UB953_IND_PGEN_CFG
#define UB953_IND_PGEN_CSI_DI
#define UB953_IND_PGEN_LINE_SIZE1
#define UB953_IND_PGEN_LINE_SIZE0
#define UB953_IND_PGEN_BAR_SIZE1
#define UB953_IND_PGEN_BAR_SIZE0
#define UB953_IND_PGEN_ACT_LPF1
#define UB953_IND_PGEN_ACT_LPF0
#define UB953_IND_PGEN_TOT_LPF1
#define UB953_IND_PGEN_TOT_LPF0
#define UB953_IND_PGEN_LINE_PD1
#define UB953_IND_PGEN_LINE_PD0
#define UB953_IND_PGEN_VBP
#define UB953_IND_PGEN_VFP
#define UB953_IND_PGEN_COLOR(n)

/* Note: Only sync mode supported for now */
enum ub953_mode {};

struct ub953_hw_data {};

struct ub953_clkout_data {};

struct ub953_data {};

static inline struct ub953_data *sd_to_ub953(struct v4l2_subdev *sd)
{}

/*
 * HW Access
 */

static int ub953_read(struct ub953_data *priv, u8 reg, u8 *val)
{}

static int ub953_write(struct ub953_data *priv, u8 reg, u8 val)
{}

static int ub953_select_ind_reg_block(struct ub953_data *priv, u8 block)
{}

__maybe_unused
static int ub953_read_ind(struct ub953_data *priv, u8 block, u8 reg, u8 *val)
{}

__maybe_unused
static int ub953_write_ind(struct ub953_data *priv, u8 block, u8 reg, u8 val)
{}

/*
 * GPIO chip
 */
static int ub953_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
{}

static int ub953_gpio_direction_in(struct gpio_chip *gc, unsigned int offset)
{}

static int ub953_gpio_direction_out(struct gpio_chip *gc, unsigned int offset,
				    int value)
{}

static int ub953_gpio_get(struct gpio_chip *gc, unsigned int offset)
{}

static void ub953_gpio_set(struct gpio_chip *gc, unsigned int offset, int value)
{}

static int ub953_gpio_of_xlate(struct gpio_chip *gc,
			       const struct of_phandle_args *gpiospec,
			       u32 *flags)
{}

static int ub953_gpiochip_probe(struct ub953_data *priv)
{}

static void ub953_gpiochip_remove(struct ub953_data *priv)
{}

/*
 * V4L2
 */

static int _ub953_set_routing(struct v4l2_subdev *sd,
			      struct v4l2_subdev_state *state,
			      struct v4l2_subdev_krouting *routing)
{}

static int ub953_set_routing(struct v4l2_subdev *sd,
			     struct v4l2_subdev_state *state,
			     enum v4l2_subdev_format_whence which,
			     struct v4l2_subdev_krouting *routing)
{}

static int ub953_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
				struct v4l2_mbus_frame_desc *fd)
{}

static int ub953_set_fmt(struct v4l2_subdev *sd,
			 struct v4l2_subdev_state *state,
			 struct v4l2_subdev_format *format)
{}

static int ub953_init_state(struct v4l2_subdev *sd,
			    struct v4l2_subdev_state *state)
{}

static int ub953_log_status(struct v4l2_subdev *sd)
{}

static int ub953_enable_streams(struct v4l2_subdev *sd,
				struct v4l2_subdev_state *state, u32 pad,
				u64 streams_mask)
{}

static int ub953_disable_streams(struct v4l2_subdev *sd,
				 struct v4l2_subdev_state *state, u32 pad,
				 u64 streams_mask)
{}

static const struct v4l2_subdev_pad_ops ub953_pad_ops =;

static const struct v4l2_subdev_core_ops ub953_subdev_core_ops =;

static const struct v4l2_subdev_ops ub953_subdev_ops =;

static const struct v4l2_subdev_internal_ops ub953_internal_ops =;

static const struct media_entity_operations ub953_entity_ops =;

static int ub953_notify_bound(struct v4l2_async_notifier *notifier,
			      struct v4l2_subdev *source_subdev,
			      struct v4l2_async_connection *asd)
{}

static const struct v4l2_async_notifier_operations ub953_notify_ops =;

static int ub953_v4l2_notifier_register(struct ub953_data *priv)
{}

static void ub953_v4l2_notifier_unregister(struct ub953_data *priv)
{}

/*
 * Probing
 */

static int ub953_i2c_master_init(struct ub953_data *priv)
{}

static u64 ub953_get_fc_rate(struct ub953_data *priv)
{}

static unsigned long ub953_calc_clkout_ub953(struct ub953_data *priv,
					     unsigned long target, u64 fc,
					     u8 *hs_div, u8 *m, u8 *n)
{}

static unsigned long ub953_calc_clkout_ub971(struct ub953_data *priv,
					     unsigned long target, u64 fc,
					     u8 *m, u8 *n)
{}

static void ub953_calc_clkout_params(struct ub953_data *priv,
				     unsigned long target_rate,
				     struct ub953_clkout_data *clkout_data)
{}

static void ub953_write_clkout_regs(struct ub953_data *priv,
				    const struct ub953_clkout_data *clkout_data)
{}

static unsigned long ub953_clkout_recalc_rate(struct clk_hw *hw,
					      unsigned long parent_rate)
{}

static long ub953_clkout_round_rate(struct clk_hw *hw, unsigned long rate,
				    unsigned long *parent_rate)
{}

static int ub953_clkout_set_rate(struct clk_hw *hw, unsigned long rate,
				 unsigned long parent_rate)
{}

static const struct clk_ops ub953_clkout_ops =;

static int ub953_register_clkout(struct ub953_data *priv)
{}

static int ub953_add_i2c_adapter(struct ub953_data *priv)
{}

static const struct regmap_config ub953_regmap_config =;

static int ub953_parse_dt(struct ub953_data *priv)
{}

static int ub953_hw_init(struct ub953_data *priv)
{}

static int ub953_subdev_init(struct ub953_data *priv)
{}

static void ub953_subdev_uninit(struct ub953_data *priv)
{}

static int ub953_probe(struct i2c_client *client)
{}

static void ub953_remove(struct i2c_client *client)
{}

static const struct ub953_hw_data ds90ub953_hw =;

static const struct ub953_hw_data ds90ub971_hw =;

static const struct i2c_device_id ub953_id[] =;
MODULE_DEVICE_TABLE(i2c, ub953_id);

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

static struct i2c_driver ds90ub953_driver =;
module_i2c_driver();

MODULE_LICENSE();
MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_AUTHOR();
MODULE_IMPORT_NS();