media: i2c: ds90ub960: Use enums for chip type and chip family

Replace chip-specific boolean flags with chip_type and chip_family enums.
This simplifies the process of adding support for newer devices and also
improves code readability.

Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Jai Luthra <jai.luthra@ideasonboard.com>
Signed-off-by: Yemike Abhilash Chandra <y-abhilashchandra@ti.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
Yemike Abhilash Chandra 2026-02-24 17:09:22 +05:30 committed by Mauro Carvalho Chehab
parent 76c101e2e0
commit 8bc79ab270

View File

@ -454,12 +454,22 @@
#define UB960_MAX_EQ_LEVEL 14
#define UB960_NUM_EQ_LEVELS (UB960_MAX_EQ_LEVEL - UB960_MIN_EQ_LEVEL + 1)
enum chip_type {
UB960,
UB9702,
};
enum chip_family {
FAMILY_FPD3,
FAMILY_FPD4,
};
struct ub960_hw_data {
const char *model;
enum chip_type chip_type;
enum chip_family chip_family;
u8 num_rxports;
u8 num_txports;
bool is_ub9702;
bool is_fpdlink4;
};
enum ub960_rxport_mode {
@ -1924,7 +1934,7 @@ static int ub960_rxport_wait_locks(struct ub960_data *priv,
if (ret)
return ret;
if (priv->hw_data->is_ub9702) {
if (priv->hw_data->chip_type == UB9702) {
dev_dbg(dev, "\trx%u: locked, freq %llu Hz\n",
nport, ((u64)v * HZ_PER_MHZ) >> 8);
} else {
@ -2186,7 +2196,7 @@ static int ub960_rxport_add_serializer(struct ub960_data *priv, u8 nport)
ser_pdata->port = nport;
ser_pdata->atr = priv->atr;
if (priv->hw_data->is_ub9702)
if (priv->hw_data->chip_type == UB9702)
ser_pdata->bc_rate = ub960_calc_bc_clk_rate_ub9702(priv, rxport);
else
ser_pdata->bc_rate = ub960_calc_bc_clk_rate_ub960(priv, rxport);
@ -2352,7 +2362,7 @@ static int ub960_init_tx_ports(struct ub960_data *priv)
{
int ret;
if (priv->hw_data->is_ub9702)
if (priv->hw_data->chip_type == UB9702)
ret = ub960_init_tx_ports_ub9702(priv);
else
ret = ub960_init_tx_ports_ub960(priv);
@ -3624,7 +3634,7 @@ static int ub960_configure_ports_for_streaming(struct ub960_data *priv,
case RXPORT_MODE_CSI2_SYNC:
case RXPORT_MODE_CSI2_NONSYNC:
if (!priv->hw_data->is_ub9702) {
if (priv->hw_data->chip_type == UB960) {
/* Map all VCs from this port to the same VC */
ub960_rxport_write(priv, nport, UB960_RR_CSI_VC_MAP,
(vc << UB960_RR_CSI_VC_MAP_SHIFT(3)) |
@ -4250,7 +4260,7 @@ static int ub960_log_status(struct v4l2_subdev *sd)
dev_info(dev, "\tcsi_err_counter %u\n", v);
if (!priv->hw_data->is_ub9702) {
if (priv->hw_data->chip_type == UB960) {
ret = ub960_log_status_ub960_sp_eq(priv, nport);
if (ret)
return ret;
@ -4408,7 +4418,7 @@ ub960_parse_dt_rxport_link_properties(struct ub960_data *priv,
return -EINVAL;
}
if (!priv->hw_data->is_fpdlink4 && cdr_mode == RXPORT_CDR_FPD4) {
if (priv->hw_data->chip_family != FAMILY_FPD4 && cdr_mode == RXPORT_CDR_FPD4) {
dev_err(dev, "rx%u: FPD-Link 4 CDR not supported\n", nport);
return -EINVAL;
}
@ -5010,7 +5020,7 @@ static int ub960_enable_core_hw(struct ub960_data *priv)
if (ret)
goto err_pd_gpio;
if (priv->hw_data->is_ub9702)
if (priv->hw_data->chip_type == UB9702)
ret = ub960_read(priv, UB9702_SR_REFCLK_FREQ, &refclk_freq,
NULL);
else
@ -5029,7 +5039,7 @@ static int ub960_enable_core_hw(struct ub960_data *priv)
goto err_pd_gpio;
/* release GPIO lock */
if (priv->hw_data->is_ub9702) {
if (priv->hw_data->chip_type == UB9702) {
ret = ub960_update_bits(priv, UB960_SR_RESET,
UB960_SR_RESET_GPIO_LOCK_RELEASE,
UB960_SR_RESET_GPIO_LOCK_RELEASE,
@ -5102,7 +5112,7 @@ static int ub960_probe(struct i2c_client *client)
if (ret)
goto err_free_ports;
if (priv->hw_data->is_ub9702)
if (priv->hw_data->chip_type == UB9702)
ret = ub960_init_rx_ports_ub9702(priv);
else
ret = ub960_init_rx_ports_ub960(priv);
@ -5171,16 +5181,18 @@ static void ub960_remove(struct i2c_client *client)
static const struct ub960_hw_data ds90ub960_hw = {
.model = "ub960",
.chip_type = UB960,
.chip_family = FAMILY_FPD3,
.num_rxports = 4,
.num_txports = 2,
};
static const struct ub960_hw_data ds90ub9702_hw = {
.model = "ub9702",
.chip_type = UB9702,
.chip_family = FAMILY_FPD4,
.num_rxports = 4,
.num_txports = 2,
.is_ub9702 = true,
.is_fpdlink4 = true,
};
static const struct i2c_device_id ub960_id[] = {