Lines Matching +full:ds90ub953 +full:- +full:q1

1 // SPDX-License-Identifier: GPL-2.0
3 * Driver for the Texas Instruments DS90UB960-Q1 video deserializer
12 * - PM for serializer and remote peripherals. We need to manage:
13 * - VPOC
14 * - Power domain? Regulator? Somehow any remote device should be able to
16 * - Link between the deserializer and the serializer
17 * - Related to VPOC management. We probably always want to turn on the VPOC
19 * - Serializer's services: i2c, gpios, power
20 * - The serializer needs to resume before the remote peripherals can
22 * - How to handle gpios? Reserving a gpio essentially keeps the provider
24 * - Do we need a new bus for the FPD-Link? At the moment the serializers
25 * are children of the same i2c-adapter where the deserializer resides.
26 * - i2c-atr could be made embeddable instead of allocatable.
34 #include <linux/i2c-atr.h>
49 #include <media/mipi-csi2.h>
50 #include <media/v4l2-ctrls.h>
51 #include <media/v4l2-event.h>
52 #include <media/v4l2-fwnode.h>
53 #include <media/v4l2-subdev.h>
70 * 0x00-0x32 Shared (UB960_SR)
71 * 0x33-0x3a CSI-2 TX (per-port paged on DS90UB960, shared on 954) (UB960_TR)
73 * 0x4d-0x7f FPD-Link RX, per-port paged (UB960_RR)
74 * 0xb0-0xbf Shared (UB960_SR)
75 * 0xd0-0xdf FPD-Link RX, per-port paged (UB960_RR)
76 * 0xf0-0xf5 Shared (UB960_SR)
77 * 0xf8-0xfb Shared (UB960_SR)
82 * UB960_RR_* = FPD-Link RX, per-port paged register
83 * UB960_TR_* = CSI-2 TX, per-port paged register
394 #define UB960_MIN_AEQ_STROBE_POS -7
399 #define UB960_MIN_MANUAL_STROBE_POS -(7 + UB960_MANUAL_STROBE_EXTRA_DELAY)
401 #define UB960_NUM_MANUAL_STROBE_POS (UB960_MAX_MANUAL_STROBE_POS - UB960_MIN_MANUAL_STROBE_POS + 1)
405 #define UB960_NUM_EQ_LEVELS (UB960_MAX_EQ_LEVEL - UB960_MIN_EQ_LEVEL + 1)
432 u8 nport; /* RX port number, and index in priv->rxport[] */
488 u8 nport; /* TX port number, and index in priv->txport[] */
550 return pad < priv->hw_data->num_rxports; in ub960_pad_is_sink()
555 return pad >= priv->hw_data->num_rxports; in ub960_pad_is_source()
563 return pad - priv->hw_data->num_rxports; in ub960_pad_to_port()
597 /* -----------------------------------------------------------------------------
603 struct device *dev = &priv->client->dev; in ub960_read()
607 mutex_lock(&priv->reg_lock); in ub960_read()
609 ret = regmap_read(priv->regmap, reg, &v); in ub960_read()
619 mutex_unlock(&priv->reg_lock); in ub960_read()
626 struct device *dev = &priv->client->dev; in ub960_write()
629 mutex_lock(&priv->reg_lock); in ub960_write()
631 ret = regmap_write(priv->regmap, reg, val); in ub960_write()
636 mutex_unlock(&priv->reg_lock); in ub960_write()
643 struct device *dev = &priv->client->dev; in ub960_update_bits()
646 mutex_lock(&priv->reg_lock); in ub960_update_bits()
648 ret = regmap_update_bits(priv->regmap, reg, mask, val); in ub960_update_bits()
653 mutex_unlock(&priv->reg_lock); in ub960_update_bits()
660 struct device *dev = &priv->client->dev; in ub960_read16()
664 mutex_lock(&priv->reg_lock); in ub960_read16()
666 ret = regmap_bulk_read(priv->regmap, reg, &__v, sizeof(__v)); in ub960_read16()
676 mutex_unlock(&priv->reg_lock); in ub960_read16()
683 struct device *dev = &priv->client->dev; in ub960_rxport_select()
686 lockdep_assert_held(&priv->reg_lock); in ub960_rxport_select()
688 if (priv->reg_current.rxport == nport) in ub960_rxport_select()
691 ret = regmap_write(priv->regmap, UB960_SR_FPD3_PORT_SEL, in ub960_rxport_select()
699 priv->reg_current.rxport = nport; in ub960_rxport_select()
706 struct device *dev = &priv->client->dev; in ub960_rxport_read()
710 mutex_lock(&priv->reg_lock); in ub960_rxport_read()
716 ret = regmap_read(priv->regmap, reg, &v); in ub960_rxport_read()
726 mutex_unlock(&priv->reg_lock); in ub960_rxport_read()
733 struct device *dev = &priv->client->dev; in ub960_rxport_write()
736 mutex_lock(&priv->reg_lock); in ub960_rxport_write()
742 ret = regmap_write(priv->regmap, reg, val); in ub960_rxport_write()
748 mutex_unlock(&priv->reg_lock); in ub960_rxport_write()
756 struct device *dev = &priv->client->dev; in ub960_rxport_update_bits()
759 mutex_lock(&priv->reg_lock); in ub960_rxport_update_bits()
765 ret = regmap_update_bits(priv->regmap, reg, mask, val); in ub960_rxport_update_bits()
771 mutex_unlock(&priv->reg_lock); in ub960_rxport_update_bits()
779 struct device *dev = &priv->client->dev; in ub960_rxport_read16()
783 mutex_lock(&priv->reg_lock); in ub960_rxport_read16()
789 ret = regmap_bulk_read(priv->regmap, reg, &__v, sizeof(__v)); in ub960_rxport_read16()
799 mutex_unlock(&priv->reg_lock); in ub960_rxport_read16()
806 struct device *dev = &priv->client->dev; in ub960_txport_select()
809 lockdep_assert_held(&priv->reg_lock); in ub960_txport_select()
811 if (priv->reg_current.txport == nport) in ub960_txport_select()
814 ret = regmap_write(priv->regmap, UB960_SR_CSI_PORT_SEL, in ub960_txport_select()
822 priv->reg_current.txport = nport; in ub960_txport_select()
829 struct device *dev = &priv->client->dev; in ub960_txport_read()
833 mutex_lock(&priv->reg_lock); in ub960_txport_read()
839 ret = regmap_read(priv->regmap, reg, &v); in ub960_txport_read()
849 mutex_unlock(&priv->reg_lock); in ub960_txport_read()
856 struct device *dev = &priv->client->dev; in ub960_txport_write()
859 mutex_lock(&priv->reg_lock); in ub960_txport_write()
865 ret = regmap_write(priv->regmap, reg, val); in ub960_txport_write()
871 mutex_unlock(&priv->reg_lock); in ub960_txport_write()
879 struct device *dev = &priv->client->dev; in ub960_txport_update_bits()
882 mutex_lock(&priv->reg_lock); in ub960_txport_update_bits()
888 ret = regmap_update_bits(priv->regmap, reg, mask, val); in ub960_txport_update_bits()
894 mutex_unlock(&priv->reg_lock); in ub960_txport_update_bits()
901 struct device *dev = &priv->client->dev; in ub960_select_ind_reg_block()
904 lockdep_assert_held(&priv->reg_lock); in ub960_select_ind_reg_block()
906 if (priv->reg_current.indirect_target == block) in ub960_select_ind_reg_block()
909 ret = regmap_write(priv->regmap, UB960_SR_IND_ACC_CTL, block << 2); in ub960_select_ind_reg_block()
916 priv->reg_current.indirect_target = block; in ub960_select_ind_reg_block()
923 struct device *dev = &priv->client->dev; in ub960_read_ind()
927 mutex_lock(&priv->reg_lock); in ub960_read_ind()
933 ret = regmap_write(priv->regmap, UB960_SR_IND_ACC_ADDR, reg); in ub960_read_ind()
941 ret = regmap_read(priv->regmap, UB960_SR_IND_ACC_DATA, &v); in ub960_read_ind()
952 mutex_unlock(&priv->reg_lock); in ub960_read_ind()
959 struct device *dev = &priv->client->dev; in ub960_write_ind()
962 mutex_lock(&priv->reg_lock); in ub960_write_ind()
968 ret = regmap_write(priv->regmap, UB960_SR_IND_ACC_ADDR, reg); in ub960_write_ind()
976 ret = regmap_write(priv->regmap, UB960_SR_IND_ACC_DATA, val); in ub960_write_ind()
985 mutex_unlock(&priv->reg_lock); in ub960_write_ind()
993 struct device *dev = &priv->client->dev; in ub960_ind_update_bits()
996 mutex_lock(&priv->reg_lock); in ub960_ind_update_bits()
1002 ret = regmap_write(priv->regmap, UB960_SR_IND_ACC_ADDR, reg); in ub960_ind_update_bits()
1010 ret = regmap_update_bits(priv->regmap, UB960_SR_IND_ACC_DATA, mask, in ub960_ind_update_bits()
1020 mutex_unlock(&priv->reg_lock); in ub960_ind_update_bits()
1025 /* -----------------------------------------------------------------------------
1026 * I2C-ATR (address translator)
1033 struct ub960_rxport *rxport = priv->rxports[chan_id]; in ub960_atr_attach_client()
1034 struct device *dev = &priv->client->dev; in ub960_atr_attach_client()
1037 for (reg_idx = 0; reg_idx < ARRAY_SIZE(rxport->aliased_clients); reg_idx++) { in ub960_atr_attach_client()
1038 if (!rxport->aliased_clients[reg_idx]) in ub960_atr_attach_client()
1042 if (reg_idx == ARRAY_SIZE(rxport->aliased_clients)) { in ub960_atr_attach_client()
1043 dev_err(dev, "rx%u: alias pool exhausted\n", rxport->nport); in ub960_atr_attach_client()
1044 return -EADDRNOTAVAIL; in ub960_atr_attach_client()
1047 rxport->aliased_clients[reg_idx] = client; in ub960_atr_attach_client()
1050 client->addr << 1); in ub960_atr_attach_client()
1055 rxport->nport, client->addr, alias, reg_idx); in ub960_atr_attach_client()
1064 struct ub960_rxport *rxport = priv->rxports[chan_id]; in ub960_atr_detach_client()
1065 struct device *dev = &priv->client->dev; in ub960_atr_detach_client()
1068 for (reg_idx = 0; reg_idx < ARRAY_SIZE(rxport->aliased_clients); reg_idx++) { in ub960_atr_detach_client()
1069 if (rxport->aliased_clients[reg_idx] == client) in ub960_atr_detach_client()
1073 if (reg_idx == ARRAY_SIZE(rxport->aliased_clients)) { in ub960_atr_detach_client()
1075 rxport->nport, client->addr); in ub960_atr_detach_client()
1079 rxport->aliased_clients[reg_idx] = NULL; in ub960_atr_detach_client()
1083 dev_dbg(dev, "rx%u: client 0x%02x released at slot %u\n", rxport->nport, in ub960_atr_detach_client()
1084 client->addr, reg_idx); in ub960_atr_detach_client()
1094 struct device *dev = &priv->client->dev; in ub960_init_atr()
1095 struct i2c_adapter *parent_adap = priv->client->adapter; in ub960_init_atr()
1097 priv->atr = i2c_atr_new(parent_adap, dev, &ub960_atr_ops, in ub960_init_atr()
1098 priv->hw_data->num_rxports); in ub960_init_atr()
1099 if (IS_ERR(priv->atr)) in ub960_init_atr()
1100 return PTR_ERR(priv->atr); in ub960_init_atr()
1102 i2c_atr_set_driver_data(priv->atr, priv); in ub960_init_atr()
1109 i2c_atr_delete(priv->atr); in ub960_uninit_atr()
1110 priv->atr = NULL; in ub960_uninit_atr()
1113 /* -----------------------------------------------------------------------------
1121 struct device *dev = &priv->client->dev; in ub960_parse_dt_txport()
1128 return -ENOMEM; in ub960_parse_dt_txport()
1130 txport->priv = priv; in ub960_parse_dt_txport()
1131 txport->nport = nport; in ub960_parse_dt_txport()
1140 txport->non_continous_clk = vep.bus.mipi_csi2.flags & in ub960_parse_dt_txport()
1143 txport->num_data_lanes = vep.bus.mipi_csi2.num_data_lanes; in ub960_parse_dt_txport()
1146 ret = -EINVAL; in ub960_parse_dt_txport()
1150 priv->tx_link_freq[0] = vep.link_frequencies[0]; in ub960_parse_dt_txport()
1151 priv->tx_data_rate = priv->tx_link_freq[0] * 2; in ub960_parse_dt_txport()
1153 if (priv->tx_data_rate != MHZ(1600) && in ub960_parse_dt_txport()
1154 priv->tx_data_rate != MHZ(1200) && in ub960_parse_dt_txport()
1155 priv->tx_data_rate != MHZ(800) && in ub960_parse_dt_txport()
1156 priv->tx_data_rate != MHZ(400)) { in ub960_parse_dt_txport()
1157 dev_err(dev, "tx%u: invalid 'link-frequencies' value\n", nport); in ub960_parse_dt_txport()
1158 ret = -EINVAL; in ub960_parse_dt_txport()
1164 priv->txports[nport] = txport; in ub960_parse_dt_txport()
1178 struct device *dev = &priv->client->dev; in ub960_csi_handle_events()
1193 /* -----------------------------------------------------------------------------
1202 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { in ub960_rxport_enable_vpocs()
1203 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_rxport_enable_vpocs()
1205 if (!rxport || !rxport->vpoc) in ub960_rxport_enable_vpocs()
1208 ret = regulator_enable(rxport->vpoc); in ub960_rxport_enable_vpocs()
1216 while (nport--) { in ub960_rxport_enable_vpocs()
1217 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_rxport_enable_vpocs()
1219 if (!rxport || !rxport->vpoc) in ub960_rxport_enable_vpocs()
1222 regulator_disable(rxport->vpoc); in ub960_rxport_enable_vpocs()
1232 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { in ub960_rxport_disable_vpocs()
1233 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_rxport_disable_vpocs()
1235 if (!rxport || !rxport->vpoc) in ub960_rxport_disable_vpocs()
1238 regulator_disable(rxport->vpoc); in ub960_rxport_disable_vpocs()
1262 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) in ub960_clear_rx_errors()
1297 *strobe_pos = data_delay - clk_delay; in ub960_rxport_get_strobe_pos()
1311 clk_delay = abs(strobe_pos) - UB960_MANUAL_STROBE_EXTRA_DELAY; in ub960_rxport_set_strobe_pos()
1313 data_delay = strobe_pos - UB960_MANUAL_STROBE_EXTRA_DELAY; in ub960_rxport_set_strobe_pos()
1330 strobe_min -= UB960_MIN_AEQ_STROBE_POS; in ub960_rxport_set_strobe_range()
1331 strobe_max -= UB960_MIN_AEQ_STROBE_POS; in ub960_rxport_set_strobe_range()
1366 eq_stage_2_select_value = eq_level - eq_stage_max; in ub960_rxport_set_eq_level()
1395 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_rxport_config_eq()
1399 if (priv->strobe.manual) { in ub960_rxport_config_eq()
1410 ub960_rxport_set_strobe_range(priv, priv->strobe.min, in ub960_rxport_config_eq()
1411 priv->strobe.max); in ub960_rxport_config_eq()
1416 if (priv->strobe.manual) in ub960_rxport_config_eq()
1417 ub960_rxport_set_strobe_pos(priv, nport, rxport->eq.strobe_pos); in ub960_rxport_config_eq()
1421 if (rxport->eq.manual_eq) { in ub960_rxport_config_eq()
1423 rxport->eq.manual.eq_level); in ub960_rxport_config_eq()
1431 rxport->eq.aeq.eq_level_min, in ub960_rxport_config_eq()
1432 rxport->eq.aeq.eq_level_max); in ub960_rxport_config_eq()
1503 struct device *dev = &priv->client->dev; in ub960_rxport_wait_locks()
1517 if (port_mask >= BIT(priv->hw_data->num_rxports)) in ub960_rxport_wait_locks()
1518 return -EINVAL; in ub960_rxport_wait_locks()
1528 priv->hw_data->num_rxports) { in ub960_rxport_wait_locks()
1529 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_rxport_wait_locks()
1565 for_each_set_bit(nport, &port_mask, priv->hw_data->num_rxports) { in ub960_rxport_wait_locks()
1566 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_rxport_wait_locks()
1580 if (priv->hw_data->is_ub9702) { in ub960_rxport_wait_locks()
1609 switch (rxport->rx_mode) { in ub960_calc_bc_clk_rate_ub960()
1631 return clk_get_rate(priv->refclk) * mult / div; in ub960_calc_bc_clk_rate_ub960()
1637 switch (rxport->rx_mode) { in ub960_calc_bc_clk_rate_ub9702()
1656 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_rxport_add_serializer()
1657 struct device *dev = &priv->client->dev; in ub960_rxport_add_serializer()
1658 struct ds90ub9xx_platform_data *ser_pdata = &rxport->ser.pdata; in ub960_rxport_add_serializer()
1660 .of_node = to_of_node(rxport->ser.fwnode), in ub960_rxport_add_serializer()
1661 .fwnode = rxport->ser.fwnode, in ub960_rxport_add_serializer()
1665 ser_pdata->port = nport; in ub960_rxport_add_serializer()
1666 ser_pdata->atr = priv->atr; in ub960_rxport_add_serializer()
1667 if (priv->hw_data->is_ub9702) in ub960_rxport_add_serializer()
1668 ser_pdata->bc_rate = ub960_calc_bc_clk_rate_ub9702(priv, rxport); in ub960_rxport_add_serializer()
1670 ser_pdata->bc_rate = ub960_calc_bc_clk_rate_ub960(priv, rxport); in ub960_rxport_add_serializer()
1675 * the FPD-Link. in ub960_rxport_add_serializer()
1677 ser_info.addr = rxport->ser.alias; in ub960_rxport_add_serializer()
1678 rxport->ser.client = in ub960_rxport_add_serializer()
1679 i2c_new_client_device(priv->client->adapter, &ser_info); in ub960_rxport_add_serializer()
1680 if (IS_ERR(rxport->ser.client)) { in ub960_rxport_add_serializer()
1683 return PTR_ERR(rxport->ser.client); in ub960_rxport_add_serializer()
1686 dev_dbg(dev, "rx%u: remote serializer at alias 0x%02x (%u-%04x)\n", in ub960_rxport_add_serializer()
1687 nport, rxport->ser.client->addr, in ub960_rxport_add_serializer()
1688 rxport->ser.client->adapter->nr, rxport->ser.client->addr); in ub960_rxport_add_serializer()
1695 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_rxport_remove_serializer()
1697 i2c_unregister_device(rxport->ser.client); in ub960_rxport_remove_serializer()
1698 rxport->ser.client = NULL; in ub960_rxport_remove_serializer()
1707 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { in ub960_rxport_add_serializers()
1708 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_rxport_add_serializers()
1721 while (nport--) { in ub960_rxport_add_serializers()
1722 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_rxport_add_serializers()
1737 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { in ub960_rxport_remove_serializers()
1738 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_rxport_remove_serializers()
1750 unsigned int nport = txport->nport; in ub960_init_tx_port()
1754 * From the datasheet: "initial CSI Skew-Calibration in ub960_init_tx_port()
1757 if (priv->tx_data_rate == MHZ(1600)) in ub960_init_tx_port()
1760 csi_ctl |= (4 - txport->num_data_lanes) << 4; in ub960_init_tx_port()
1762 if (!txport->non_continous_clk) in ub960_init_tx_port()
1776 switch (priv->tx_data_rate) { in ub960_init_tx_ports()
1798 if (priv->hw_data->is_ub9702) { in ub960_init_tx_ports()
1801 switch (priv->tx_data_rate) { in ub960_init_tx_ports()
1818 for (nport = 0; nport < priv->hw_data->num_txports; nport++) { in ub960_init_tx_ports()
1819 struct ub960_txport *txport = priv->txports[nport]; in ub960_init_tx_ports()
1833 unsigned int nport = rxport->nport; in ub960_init_rx_port_ub960()
1839 * 0 - 2.5 Mbps (DS90UB913A-Q1 / DS90UB933-Q1) in ub960_init_rx_port_ub960()
1840 * 2 - 10 Mbps in ub960_init_rx_port_ub960()
1841 * 6 - 50 Mbps (DS90UB953-Q1) in ub960_init_rx_port_ub960()
1847 switch (rxport->rx_mode) { in ub960_init_rx_port_ub960()
1870 switch (rxport->rx_mode) { in ub960_init_rx_port_ub960()
1872 /* FPD3_MODE = RAW10 Mode (DS90UB913A-Q1 / DS90UB933-Q1 compatible) */ in ub960_init_rx_port_ub960()
1878 * RAW10_8BIT_CTL = 0b10 : 8-bit processing using upper 8 bits in ub960_init_rx_port_ub960()
1893 /* CSI-2 Mode (DS90UB953-Q1 compatible) */ in ub960_init_rx_port_ub960()
1902 rxport->lv_fv_pol); in ub960_init_rx_port_ub960()
1915 rxport->ser.alias << 1); in ub960_init_rx_port_ub960()
1927 unsigned int nport = rxport->nport; in ub960_init_rx_port_ub9702_fpd3()
1931 switch (rxport->rx_mode) { in ub960_init_rx_port_ub9702_fpd3()
1980 /* serdes_driver_ctl2 control: DS90UB953-Q1/DS90UB933-Q1/DS90UB913A-Q1 */ in ub960_init_rx_port_ub9702_fpd3()
1984 /* RX port to half-rate */ in ub960_init_rx_port_ub9702_fpd3()
1992 unsigned int nport = rxport->nport; in ub960_init_rx_port_ub9702_fpd4_aeq()
2026 unsigned int nport = rxport->nport; in ub960_init_rx_port_ub9702_fpd4()
2029 switch (rxport->rx_mode) { in ub960_init_rx_port_ub9702_fpd4()
2088 unsigned int nport = rxport->nport; in ub960_init_rx_port_ub9702()
2090 if (rxport->cdr_mode == RXPORT_CDR_FPD3) in ub960_init_rx_port_ub9702()
2095 switch (rxport->rx_mode) { in ub960_init_rx_port_ub9702()
2098 * RAW10_8BIT_CTL = 0b11 : 8-bit processing using lower 8 bits in ub960_init_rx_port_ub9702()
2099 * 0b10 : 8-bit processing using upper 8 bits in ub960_init_rx_port_ub9702()
2119 rxport->lv_fv_pol); in ub960_init_rx_port_ub9702()
2132 rxport->ser.alias << 1); in ub960_init_rx_port_ub9702()
2137 if (rxport->cdr_mode == RXPORT_CDR_FPD4) { in ub960_init_rx_port_ub9702()
2147 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { in ub960_init_rx_ports()
2148 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_init_rx_ports()
2153 if (priv->hw_data->is_ub9702) in ub960_init_rx_ports()
2164 struct device *dev = &priv->client->dev; in ub960_rxport_handle_events()
2282 /* -----------------------------------------------------------------------------
2310 for_each_active_route(&state->routing, route) { in ub960_get_vc_maps()
2313 rx = ub960_pad_to_port(priv, route->sink_pad); in ub960_get_vc_maps()
2317 tx = ub960_pad_to_port(priv, route->source_pad); in ub960_get_vc_maps()
2326 struct device *dev = &priv->client->dev; in ub960_enable_tx_port()
2337 struct device *dev = &priv->client->dev; in ub960_disable_tx_port()
2347 struct device *dev = &priv->client->dev; in ub960_enable_rx_port()
2358 struct device *dev = &priv->client->dev; in ub960_disable_rx_port()
2377 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { in ub960_validate_stream_vcs()
2378 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_validate_stream_vcs()
2386 ret = v4l2_subdev_call(rxport->source.sd, pad, get_frame_desc, in ub960_validate_stream_vcs()
2387 rxport->source.pad, &desc); in ub960_validate_stream_vcs()
2403 dev_err(&priv->client->dev, in ub960_validate_stream_vcs()
2404 "rx%u: source with multiple virtual-channels is not supported\n", in ub960_validate_stream_vcs()
2406 return -ENODEV; in ub960_validate_stream_vcs()
2435 for_each_active_route(&state->routing, route) { in ub960_configure_ports_for_streaming()
2442 nport = ub960_pad_to_port(priv, route->sink_pad); in ub960_configure_ports_for_streaming()
2444 rxport = priv->rxports[nport]; in ub960_configure_ports_for_streaming()
2446 return -EINVAL; in ub960_configure_ports_for_streaming()
2448 txport = priv->txports[ub960_pad_to_port(priv, route->source_pad)]; in ub960_configure_ports_for_streaming()
2450 return -EINVAL; in ub960_configure_ports_for_streaming()
2452 rx_data[nport].tx_port = ub960_pad_to_port(priv, route->source_pad); in ub960_configure_ports_for_streaming()
2457 if (rxport->rx_mode == RXPORT_MODE_CSI2_SYNC || in ub960_configure_ports_for_streaming()
2458 rxport->rx_mode == RXPORT_MODE_CSI2_NONSYNC) in ub960_configure_ports_for_streaming()
2462 return -EPIPE; in ub960_configure_ports_for_streaming()
2465 route->sink_pad, in ub960_configure_ports_for_streaming()
2466 route->sink_stream); in ub960_configure_ports_for_streaming()
2468 return -EPIPE; in ub960_configure_ports_for_streaming()
2470 ub960_fmt = ub960_find_format(fmt->code); in ub960_configure_ports_for_streaming()
2472 return -EPIPE; in ub960_configure_ports_for_streaming()
2474 if (ub960_fmt->meta) { in ub960_configure_ports_for_streaming()
2475 if (fmt->height > 3) { in ub960_configure_ports_for_streaming()
2476 dev_err(&priv->client->dev, in ub960_configure_ports_for_streaming()
2478 nport, fmt->height); in ub960_configure_ports_for_streaming()
2479 return -EPIPE; in ub960_configure_ports_for_streaming()
2482 rx_data[nport].meta_dt = ub960_fmt->datatype; in ub960_configure_ports_for_streaming()
2483 rx_data[nport].meta_lines = fmt->height; in ub960_configure_ports_for_streaming()
2485 rx_data[nport].pixel_dt = ub960_fmt->datatype; in ub960_configure_ports_for_streaming()
2497 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { in ub960_configure_ports_for_streaming()
2498 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_configure_ports_for_streaming()
2504 switch (rxport->rx_mode) { in ub960_configure_ports_for_streaming()
2509 ub960_rxport_write(priv, rxport->nport, in ub960_configure_ports_for_streaming()
2523 if (!priv->hw_data->is_ub9702) { in ub960_configure_ports_for_streaming()
2559 if (priv->stream_enable_mask[i]) in ub960_update_streaming_status()
2563 priv->streaming = i < UB960_MAX_NPORTS; in ub960_update_streaming_status()
2571 struct device *dev = &priv->client->dev; in ub960_enable_streams()
2578 if (!priv->streaming) { in ub960_enable_streams()
2586 if (!priv->stream_enable_mask[source_pad]) { in ub960_enable_streams()
2593 priv->stream_enable_mask[source_pad] |= source_streams_mask; in ub960_enable_streams()
2596 for_each_active_route(&state->routing, route) { in ub960_enable_streams()
2597 if (route->source_pad != source_pad) in ub960_enable_streams()
2600 if (!(source_streams_mask & BIT_ULL(route->source_stream))) in ub960_enable_streams()
2603 nport = ub960_pad_to_port(priv, route->sink_pad); in ub960_enable_streams()
2605 sink_streams[nport] |= BIT_ULL(route->sink_stream); in ub960_enable_streams()
2608 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { in ub960_enable_streams()
2613 if (!priv->stream_enable_mask[nport]) { in ub960_enable_streams()
2621 priv->stream_enable_mask[nport] |= sink_streams[nport]; in ub960_enable_streams()
2627 priv->rxports[nport]->source.sd, in ub960_enable_streams()
2628 priv->rxports[nport]->source.pad, in ub960_enable_streams()
2631 priv->stream_enable_mask[nport] &= ~sink_streams[nport]; in ub960_enable_streams()
2633 if (!priv->stream_enable_mask[nport]) in ub960_enable_streams()
2641 priv->streaming = true; in ub960_enable_streams()
2654 priv->rxports[nport]->source.sd, in ub960_enable_streams()
2655 priv->rxports[nport]->source.pad, in ub960_enable_streams()
2660 priv->stream_enable_mask[nport] &= ~sink_streams[nport]; in ub960_enable_streams()
2663 if (!priv->stream_enable_mask[nport]) in ub960_enable_streams()
2667 priv->stream_enable_mask[source_pad] &= ~source_streams_mask; in ub960_enable_streams()
2669 if (!priv->stream_enable_mask[source_pad]) in ub960_enable_streams()
2683 struct device *dev = &priv->client->dev; in ub960_disable_streams()
2690 for_each_active_route(&state->routing, route) { in ub960_disable_streams()
2691 if (route->source_pad != source_pad) in ub960_disable_streams()
2694 if (!(source_streams_mask & BIT_ULL(route->source_stream))) in ub960_disable_streams()
2697 nport = ub960_pad_to_port(priv, route->sink_pad); in ub960_disable_streams()
2699 sink_streams[nport] |= BIT_ULL(route->sink_stream); in ub960_disable_streams()
2702 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { in ub960_disable_streams()
2710 priv->rxports[nport]->source.sd, in ub960_disable_streams()
2711 priv->rxports[nport]->source.pad, in ub960_disable_streams()
2716 priv->stream_enable_mask[nport] &= ~sink_streams[nport]; in ub960_disable_streams()
2719 if (!priv->stream_enable_mask[nport]) in ub960_disable_streams()
2725 priv->stream_enable_mask[source_pad] &= ~source_streams_mask; in ub960_disable_streams()
2727 if (!priv->stream_enable_mask[source_pad]) in ub960_disable_streams()
2757 if (routing->num_routes > V4L2_FRAME_DESC_ENTRY_MAX) in _ub960_set_routing()
2758 return -E2BIG; in _ub960_set_routing()
2780 if (which == V4L2_SUBDEV_FORMAT_ACTIVE && priv->streaming) in ub960_set_routing()
2781 return -EBUSY; in ub960_set_routing()
2793 struct device *dev = &priv->client->dev; in ub960_get_frame_desc()
2797 return -EINVAL; in ub960_get_frame_desc()
2801 fd->type = V4L2_MBUS_FRAME_DESC_TYPE_CSI2; in ub960_get_frame_desc()
2803 state = v4l2_subdev_lock_and_get_active_state(&priv->sd); in ub960_get_frame_desc()
2807 for_each_active_route(&state->routing, route) { in ub960_get_frame_desc()
2813 if (route->source_pad != pad) in ub960_get_frame_desc()
2816 nport = ub960_pad_to_port(priv, route->sink_pad); in ub960_get_frame_desc()
2818 ret = v4l2_subdev_call(priv->rxports[nport]->source.sd, pad, in ub960_get_frame_desc()
2820 priv->rxports[nport]->source.pad, in ub960_get_frame_desc()
2825 route->sink_pad); in ub960_get_frame_desc()
2830 if (source_fd.entry[i].stream == route->sink_stream) { in ub960_get_frame_desc()
2839 ret = -EPIPE; in ub960_get_frame_desc()
2843 fd->entry[fd->num_entries].stream = route->source_stream; in ub960_get_frame_desc()
2844 fd->entry[fd->num_entries].flags = source_entry->flags; in ub960_get_frame_desc()
2845 fd->entry[fd->num_entries].length = source_entry->length; in ub960_get_frame_desc()
2846 fd->entry[fd->num_entries].pixelcode = source_entry->pixelcode; in ub960_get_frame_desc()
2848 fd->entry[fd->num_entries].bus.csi2.vc = vc_map[nport]; in ub960_get_frame_desc()
2851 fd->entry[fd->num_entries].bus.csi2.dt = in ub960_get_frame_desc()
2852 source_entry->bus.csi2.dt; in ub960_get_frame_desc()
2858 route->source_stream); in ub960_get_frame_desc()
2861 ret = -EINVAL; in ub960_get_frame_desc()
2865 ub960_fmt = ub960_find_format(fmt->code); in ub960_get_frame_desc()
2868 ret = -EINVAL; in ub960_get_frame_desc()
2872 fd->entry[fd->num_entries].bus.csi2.dt = in ub960_get_frame_desc()
2873 ub960_fmt->datatype; in ub960_get_frame_desc()
2876 fd->num_entries++; in ub960_get_frame_desc()
2892 if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE && priv->streaming) in ub960_set_fmt()
2893 return -EBUSY; in ub960_set_fmt()
2896 if (ub960_pad_is_source(priv, format->pad)) in ub960_set_fmt()
2903 if (!ub960_find_format(format->format.code)) in ub960_set_fmt()
2904 format->format.code = ub960_formats[0].code; in ub960_set_fmt()
2906 fmt = v4l2_subdev_state_get_stream_format(state, format->pad, in ub960_set_fmt()
2907 format->stream); in ub960_set_fmt()
2909 return -EINVAL; in ub960_set_fmt()
2911 *fmt = format->format; in ub960_set_fmt()
2913 fmt = v4l2_subdev_state_get_opposite_stream_format(state, format->pad, in ub960_set_fmt()
2914 format->stream); in ub960_set_fmt()
2916 return -EINVAL; in ub960_set_fmt()
2918 *fmt = format->format; in ub960_set_fmt()
2932 .source_pad = priv->hw_data->num_rxports, in ub960_init_cfg()
2962 struct device *dev = &priv->client->dev; in ub960_log_status_ub960_sp_eq()
2979 ((v >> UB960_XR_SFILTER_CFG_SFILTER_MIN_SHIFT) & 0xf) - 7, in ub960_log_status_ub960_sp_eq()
2980 ((v >> UB960_XR_SFILTER_CFG_SFILTER_MAX_SHIFT) & 0xf) - 7); in ub960_log_status_ub960_sp_eq()
3010 struct device *dev = &priv->client->dev; in ub960_log_status()
3025 for (nport = 0; nport < priv->hw_data->num_txports; nport++) { in ub960_log_status()
3026 struct ub960_txport *txport = priv->txports[nport]; in ub960_log_status()
3052 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { in ub960_log_status()
3053 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_log_status()
3089 if (!priv->hw_data->is_ub9702) in ub960_log_status()
3129 /* -----------------------------------------------------------------------------
3145 dev_dbg(&priv->client->dev, "INTERRUPT_STS %x\n", int_sts); in ub960_handle_events()
3151 dev_dbg(&priv->client->dev, "FWD_STS %#02x\n", fwd_sts); in ub960_handle_events()
3153 for (i = 0; i < priv->hw_data->num_txports; i++) { in ub960_handle_events()
3158 for (i = 0; i < priv->hw_data->num_rxports; i++) { in ub960_handle_events()
3159 if (!priv->rxports[i]) in ub960_handle_events()
3177 schedule_delayed_work(&priv->poll_work, in ub960_handler_work()
3185 for (nport = 0; nport < priv->hw_data->num_txports; nport++) { in ub960_txport_free_ports()
3186 struct ub960_txport *txport = priv->txports[nport]; in ub960_txport_free_ports()
3192 priv->txports[nport] = NULL; in ub960_txport_free_ports()
3200 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { in ub960_rxport_free_ports()
3201 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_rxport_free_ports()
3206 fwnode_handle_put(rxport->source.ep_fwnode); in ub960_rxport_free_ports()
3207 fwnode_handle_put(rxport->ser.fwnode); in ub960_rxport_free_ports()
3210 priv->rxports[nport] = NULL; in ub960_rxport_free_ports()
3219 struct device *dev = &priv->client->dev; in ub960_parse_dt_rxport_link_properties()
3220 unsigned int nport = rxport->nport; in ub960_parse_dt_rxport_link_properties()
3230 ret = fwnode_property_read_u32(link_fwnode, "ti,cdr-mode", &cdr_mode); in ub960_parse_dt_rxport_link_properties()
3231 if (ret < 0 && ret != -EINVAL) { in ub960_parse_dt_rxport_link_properties()
3233 "ti,cdr-mode", ret); in ub960_parse_dt_rxport_link_properties()
3238 dev_err(dev, "rx%u: bad 'ti,cdr-mode' %u\n", nport, cdr_mode); in ub960_parse_dt_rxport_link_properties()
3239 return -EINVAL; in ub960_parse_dt_rxport_link_properties()
3242 if (!priv->hw_data->is_fpdlink4 && cdr_mode == RXPORT_CDR_FPD4) { in ub960_parse_dt_rxport_link_properties()
3243 dev_err(dev, "rx%u: FPD-Link 4 CDR not supported\n", nport); in ub960_parse_dt_rxport_link_properties()
3244 return -EINVAL; in ub960_parse_dt_rxport_link_properties()
3247 rxport->cdr_mode = cdr_mode; in ub960_parse_dt_rxport_link_properties()
3249 ret = fwnode_property_read_u32(link_fwnode, "ti,rx-mode", &rx_mode); in ub960_parse_dt_rxport_link_properties()
3252 "ti,rx-mode", ret); in ub960_parse_dt_rxport_link_properties()
3257 dev_err(dev, "rx%u: bad 'ti,rx-mode' %u\n", nport, rx_mode); in ub960_parse_dt_rxport_link_properties()
3258 return -EINVAL; in ub960_parse_dt_rxport_link_properties()
3264 dev_err(dev, "rx%u: unsupported 'ti,rx-mode' %u\n", nport, in ub960_parse_dt_rxport_link_properties()
3266 return -EINVAL; in ub960_parse_dt_rxport_link_properties()
3271 rxport->rx_mode = rx_mode; in ub960_parse_dt_rxport_link_properties()
3276 rxport->eq.manual_eq = false; in ub960_parse_dt_rxport_link_properties()
3277 rxport->eq.aeq.eq_level_min = UB960_MIN_EQ_LEVEL; in ub960_parse_dt_rxport_link_properties()
3278 rxport->eq.aeq.eq_level_max = UB960_MAX_EQ_LEVEL; in ub960_parse_dt_rxport_link_properties()
3280 ret = fwnode_property_read_u32(link_fwnode, "ti,strobe-pos", in ub960_parse_dt_rxport_link_properties()
3283 if (ret != -EINVAL) { in ub960_parse_dt_rxport_link_properties()
3285 "ti,strobe-pos", ret); in ub960_parse_dt_rxport_link_properties()
3291 dev_err(dev, "rx%u: illegal 'strobe-pos' value: %d\n", in ub960_parse_dt_rxport_link_properties()
3293 return -EINVAL; in ub960_parse_dt_rxport_link_properties()
3297 rxport->eq.strobe_pos = strobe_pos; in ub960_parse_dt_rxport_link_properties()
3298 if (!priv->strobe.manual) in ub960_parse_dt_rxport_link_properties()
3300 "rx%u: 'ti,strobe-pos' ignored as 'ti,manual-strobe' not set\n", in ub960_parse_dt_rxport_link_properties()
3304 ret = fwnode_property_read_u32(link_fwnode, "ti,eq-level", &eq_level); in ub960_parse_dt_rxport_link_properties()
3306 if (ret != -EINVAL) { in ub960_parse_dt_rxport_link_properties()
3308 "ti,eq-level", ret); in ub960_parse_dt_rxport_link_properties()
3313 dev_err(dev, "rx%u: illegal 'ti,eq-level' value: %d\n", in ub960_parse_dt_rxport_link_properties()
3315 return -EINVAL; in ub960_parse_dt_rxport_link_properties()
3318 rxport->eq.manual_eq = true; in ub960_parse_dt_rxport_link_properties()
3319 rxport->eq.manual.eq_level = eq_level; in ub960_parse_dt_rxport_link_properties()
3322 ret = fwnode_property_read_u32(link_fwnode, "i2c-alias", in ub960_parse_dt_rxport_link_properties()
3326 "i2c-alias", ret); in ub960_parse_dt_rxport_link_properties()
3329 rxport->ser.alias = ser_i2c_alias; in ub960_parse_dt_rxport_link_properties()
3331 rxport->ser.fwnode = fwnode_get_named_child_node(link_fwnode, "serializer"); in ub960_parse_dt_rxport_link_properties()
3332 if (!rxport->ser.fwnode) { in ub960_parse_dt_rxport_link_properties()
3334 return -EINVAL; in ub960_parse_dt_rxport_link_properties()
3344 struct device *dev = &priv->client->dev; in ub960_parse_dt_rxport_ep_properties()
3346 unsigned int nport = rxport->nport; in ub960_parse_dt_rxport_ep_properties()
3351 rxport->source.ep_fwnode = fwnode_graph_get_remote_endpoint(ep_fwnode); in ub960_parse_dt_rxport_ep_properties()
3352 if (!rxport->source.ep_fwnode) { in ub960_parse_dt_rxport_ep_properties()
3354 return -ENODEV; in ub960_parse_dt_rxport_ep_properties()
3359 switch (rxport->rx_mode) { in ub960_parse_dt_rxport_ep_properties()
3379 rxport->lv_fv_pol = (hsync_hi ? UB960_RR_PORT_CONFIG2_LV_POL_LOW : 0) | in ub960_parse_dt_rxport_ep_properties()
3385 fwnode_handle_put(rxport->source.ep_fwnode); in ub960_parse_dt_rxport_ep_properties()
3396 struct device *dev = &priv->client->dev; in ub960_parse_dt_rxport()
3402 return -ENOMEM; in ub960_parse_dt_rxport()
3404 priv->rxports[nport] = rxport; in ub960_parse_dt_rxport()
3406 rxport->nport = nport; in ub960_parse_dt_rxport()
3407 rxport->priv = priv; in ub960_parse_dt_rxport()
3413 rxport->vpoc = devm_regulator_get_optional(dev, vpoc_names[nport]); in ub960_parse_dt_rxport()
3414 if (IS_ERR(rxport->vpoc)) { in ub960_parse_dt_rxport()
3415 ret = PTR_ERR(rxport->vpoc); in ub960_parse_dt_rxport()
3416 if (ret == -ENODEV) { in ub960_parse_dt_rxport()
3417 rxport->vpoc = NULL; in ub960_parse_dt_rxport()
3432 fwnode_handle_put(rxport->ser.fwnode); in ub960_parse_dt_rxport()
3434 priv->rxports[nport] = NULL; in ub960_parse_dt_rxport()
3467 struct device *dev = &priv->client->dev; in ub960_parse_dt_rxports()
3475 return -ENODEV; in ub960_parse_dt_rxports()
3479 priv->strobe.min = 2; in ub960_parse_dt_rxports()
3480 priv->strobe.max = 3; in ub960_parse_dt_rxports()
3482 priv->strobe.manual = fwnode_property_read_bool(links_fwnode, "ti,manual-strobe"); in ub960_parse_dt_rxports()
3484 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { in ub960_parse_dt_rxports()
3523 struct device *dev = &priv->client->dev; in ub960_parse_dt_txports()
3527 for (nport = 0; nport < priv->hw_data->num_txports; nport++) { in ub960_parse_dt_txports()
3528 unsigned int port = nport + priv->hw_data->num_rxports; in ub960_parse_dt_txports()
3571 struct ub960_data *priv = sd_to_ub960(notifier->sd); in ub960_notify_bound()
3572 struct ub960_rxport *rxport = to_ub960_asd(asd)->rxport; in ub960_notify_bound()
3573 struct device *dev = &priv->client->dev; in ub960_notify_bound()
3574 u8 nport = rxport->nport; in ub960_notify_bound()
3578 ret = media_entity_get_fwnode_pad(&subdev->entity, in ub960_notify_bound()
3579 rxport->source.ep_fwnode, in ub960_notify_bound()
3582 dev_err(dev, "Failed to find pad for %s\n", subdev->name); in ub960_notify_bound()
3586 rxport->source.sd = subdev; in ub960_notify_bound()
3587 rxport->source.pad = ret; in ub960_notify_bound()
3589 ret = media_create_pad_link(&rxport->source.sd->entity, in ub960_notify_bound()
3590 rxport->source.pad, &priv->sd.entity, nport, in ub960_notify_bound()
3594 dev_err(dev, "Unable to link %s:%u -> %s:%u\n", in ub960_notify_bound()
3595 rxport->source.sd->name, rxport->source.pad, in ub960_notify_bound()
3596 priv->sd.name, nport); in ub960_notify_bound()
3600 for (i = 0; i < priv->hw_data->num_rxports; i++) { in ub960_notify_bound()
3601 if (priv->rxports[i] && !priv->rxports[i]->source.sd) { in ub960_notify_bound()
3614 struct ub960_rxport *rxport = to_ub960_asd(asd)->rxport; in ub960_notify_unbind()
3616 rxport->source.sd = NULL; in ub960_notify_unbind()
3626 struct device *dev = &priv->client->dev; in ub960_v4l2_notifier_register()
3630 v4l2_async_subdev_nf_init(&priv->notifier, &priv->sd); in ub960_v4l2_notifier_register()
3632 for (i = 0; i < priv->hw_data->num_rxports; i++) { in ub960_v4l2_notifier_register()
3633 struct ub960_rxport *rxport = priv->rxports[i]; in ub960_v4l2_notifier_register()
3639 asd = v4l2_async_nf_add_fwnode(&priv->notifier, in ub960_v4l2_notifier_register()
3640 rxport->source.ep_fwnode, in ub960_v4l2_notifier_register()
3645 v4l2_async_nf_cleanup(&priv->notifier); in ub960_v4l2_notifier_register()
3649 asd->rxport = rxport; in ub960_v4l2_notifier_register()
3652 priv->notifier.ops = &ub960_notify_ops; in ub960_v4l2_notifier_register()
3654 ret = v4l2_async_nf_register(&priv->notifier); in ub960_v4l2_notifier_register()
3657 v4l2_async_nf_cleanup(&priv->notifier); in ub960_v4l2_notifier_register()
3666 v4l2_async_nf_unregister(&priv->notifier); in ub960_v4l2_notifier_unregister()
3667 v4l2_async_nf_cleanup(&priv->notifier); in ub960_v4l2_notifier_unregister()
3672 struct device *dev = &priv->client->dev; in ub960_create_subdev()
3676 v4l2_i2c_subdev_init(&priv->sd, priv->client, &ub960_subdev_ops); in ub960_create_subdev()
3678 v4l2_ctrl_handler_init(&priv->ctrl_handler, 1); in ub960_create_subdev()
3679 priv->sd.ctrl_handler = &priv->ctrl_handler; in ub960_create_subdev()
3681 v4l2_ctrl_new_int_menu(&priv->ctrl_handler, NULL, V4L2_CID_LINK_FREQ, in ub960_create_subdev()
3682 ARRAY_SIZE(priv->tx_link_freq) - 1, 0, in ub960_create_subdev()
3683 priv->tx_link_freq); in ub960_create_subdev()
3685 if (priv->ctrl_handler.error) { in ub960_create_subdev()
3686 ret = priv->ctrl_handler.error; in ub960_create_subdev()
3690 priv->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | in ub960_create_subdev()
3692 priv->sd.entity.function = MEDIA_ENT_F_VID_IF_BRIDGE; in ub960_create_subdev()
3693 priv->sd.entity.ops = &ub960_entity_ops; in ub960_create_subdev()
3695 for (i = 0; i < priv->hw_data->num_rxports + priv->hw_data->num_txports; i++) { in ub960_create_subdev()
3696 priv->pads[i].flags = ub960_pad_is_sink(priv, i) ? in ub960_create_subdev()
3701 ret = media_entity_pads_init(&priv->sd.entity, in ub960_create_subdev()
3702 priv->hw_data->num_rxports + in ub960_create_subdev()
3703 priv->hw_data->num_txports, in ub960_create_subdev()
3704 priv->pads); in ub960_create_subdev()
3708 priv->sd.state_lock = priv->sd.ctrl_handler->lock; in ub960_create_subdev()
3710 ret = v4l2_subdev_init_finalize(&priv->sd); in ub960_create_subdev()
3720 ret = v4l2_async_register_subdev(&priv->sd); in ub960_create_subdev()
3731 v4l2_subdev_cleanup(&priv->sd); in ub960_create_subdev()
3733 media_entity_cleanup(&priv->sd.entity); in ub960_create_subdev()
3735 v4l2_ctrl_handler_free(&priv->ctrl_handler); in ub960_create_subdev()
3743 v4l2_async_unregister_subdev(&priv->sd); in ub960_destroy_subdev()
3745 v4l2_subdev_cleanup(&priv->sd); in ub960_destroy_subdev()
3747 media_entity_cleanup(&priv->sd.entity); in ub960_destroy_subdev()
3748 v4l2_ctrl_handler_free(&priv->ctrl_handler); in ub960_destroy_subdev()
3768 struct device *dev = &priv->client->dev; in ub960_reset()
3778 mutex_lock(&priv->reg_lock); in ub960_reset()
3780 ret = regmap_read_poll_timeout(priv->regmap, UB960_SR_RESET, v, in ub960_reset()
3783 mutex_unlock(&priv->reg_lock); in ub960_reset()
3791 struct device *dev = &priv->client->dev; in ub960_get_hw_resources()
3793 priv->regmap = devm_regmap_init_i2c(priv->client, &ub960_regmap_config); in ub960_get_hw_resources()
3794 if (IS_ERR(priv->regmap)) in ub960_get_hw_resources()
3795 return PTR_ERR(priv->regmap); in ub960_get_hw_resources()
3797 priv->vddio = devm_regulator_get(dev, "vddio"); in ub960_get_hw_resources()
3798 if (IS_ERR(priv->vddio)) in ub960_get_hw_resources()
3799 return dev_err_probe(dev, PTR_ERR(priv->vddio), in ub960_get_hw_resources()
3802 /* get power-down pin from DT */ in ub960_get_hw_resources()
3803 priv->pd_gpio = in ub960_get_hw_resources()
3805 if (IS_ERR(priv->pd_gpio)) in ub960_get_hw_resources()
3806 return dev_err_probe(dev, PTR_ERR(priv->pd_gpio), in ub960_get_hw_resources()
3809 priv->refclk = devm_clk_get(dev, "refclk"); in ub960_get_hw_resources()
3810 if (IS_ERR(priv->refclk)) in ub960_get_hw_resources()
3811 return dev_err_probe(dev, PTR_ERR(priv->refclk), in ub960_get_hw_resources()
3819 struct device *dev = &priv->client->dev; in ub960_enable_core_hw()
3825 ret = regulator_enable(priv->vddio); in ub960_enable_core_hw()
3830 ret = clk_prepare_enable(priv->refclk); in ub960_enable_core_hw()
3836 if (priv->pd_gpio) { in ub960_enable_core_hw()
3837 gpiod_set_value_cansleep(priv->pd_gpio, 1); in ub960_enable_core_hw()
3840 gpiod_set_value_cansleep(priv->pd_gpio, 0); in ub960_enable_core_hw()
3854 dev_dbg(dev, "Found %s (rev/mask %#04x)\n", priv->hw_data->model, in ub960_enable_core_hw()
3861 if (priv->hw_data->is_ub9702) in ub960_enable_core_hw()
3870 clk_get_rate(priv->refclk) / 1000000); in ub960_enable_core_hw()
3878 if (priv->hw_data->is_ub9702) { in ub960_enable_core_hw()
3889 gpiod_set_value_cansleep(priv->pd_gpio, 1); in ub960_enable_core_hw()
3890 clk_disable_unprepare(priv->refclk); in ub960_enable_core_hw()
3892 regulator_disable(priv->vddio); in ub960_enable_core_hw()
3899 gpiod_set_value_cansleep(priv->pd_gpio, 1); in ub960_disable_core_hw()
3900 clk_disable_unprepare(priv->refclk); in ub960_disable_core_hw()
3901 regulator_disable(priv->vddio); in ub960_disable_core_hw()
3906 struct device *dev = &client->dev; in ub960_probe()
3915 return -ENOMEM; in ub960_probe()
3917 priv->client = client; in ub960_probe()
3919 priv->hw_data = device_get_match_data(dev); in ub960_probe()
3921 mutex_init(&priv->reg_lock); in ub960_probe()
3923 INIT_DELAYED_WORK(&priv->poll_work, ub960_handler_work); in ub960_probe()
3929 priv->reg_current.indirect_target = 0xff; in ub960_probe()
3930 priv->reg_current.rxport = 0xff; in ub960_probe()
3931 priv->reg_current.txport = 0xff; in ub960_probe()
3961 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { in ub960_probe()
3962 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_probe()
3975 ret = -EIO; in ub960_probe()
3998 if (client->irq) in ub960_probe()
4001 schedule_delayed_work(&priv->poll_work, in ub960_probe()
4018 mutex_destroy(&priv->reg_lock); in ub960_probe()
4027 cancel_delayed_work_sync(&priv->poll_work); in ub960_remove()
4036 mutex_destroy(&priv->reg_lock); in ub960_remove()
4054 { "ds90ub960-q1", (kernel_ulong_t)&ds90ub960_hw },
4055 { "ds90ub9702-q1", (kernel_ulong_t)&ds90ub9702_hw },
4061 { .compatible = "ti,ds90ub960-q1", .data = &ds90ub960_hw },
4062 { .compatible = "ti,ds90ub9702-q1", .data = &ds90ub9702_hw },
4079 MODULE_DESCRIPTION("Texas Instruments FPD-Link III/IV Deserializers Driver");