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
392 #define UB960_MIN_AEQ_STROBE_POS -7
397 #define UB960_MIN_MANUAL_STROBE_POS -(7 + UB960_MANUAL_STROBE_EXTRA_DELAY)
399 #define UB960_NUM_MANUAL_STROBE_POS (UB960_MAX_MANUAL_STROBE_POS - UB960_MIN_MANUAL_STROBE_POS + 1)
403 #define UB960_NUM_EQ_LEVELS (UB960_MAX_EQ_LEVEL - UB960_MIN_EQ_LEVEL + 1)
430 u8 nport; /* RX port number, and index in priv->rxport[] */
486 u8 nport; /* TX port number, and index in priv->txport[] */
548 return pad < priv->hw_data->num_rxports; in ub960_pad_is_sink()
553 return pad >= priv->hw_data->num_rxports; in ub960_pad_is_source()
561 return pad - priv->hw_data->num_rxports; in ub960_pad_to_port()
595 /* -----------------------------------------------------------------------------
601 struct device *dev = &priv->client->dev; in ub960_read()
605 mutex_lock(&priv->reg_lock); in ub960_read()
607 ret = regmap_read(priv->regmap, reg, &v); in ub960_read()
617 mutex_unlock(&priv->reg_lock); in ub960_read()
624 struct device *dev = &priv->client->dev; in ub960_write()
627 mutex_lock(&priv->reg_lock); in ub960_write()
629 ret = regmap_write(priv->regmap, reg, val); in ub960_write()
634 mutex_unlock(&priv->reg_lock); in ub960_write()
641 struct device *dev = &priv->client->dev; in ub960_update_bits()
644 mutex_lock(&priv->reg_lock); in ub960_update_bits()
646 ret = regmap_update_bits(priv->regmap, reg, mask, val); in ub960_update_bits()
651 mutex_unlock(&priv->reg_lock); in ub960_update_bits()
658 struct device *dev = &priv->client->dev; in ub960_read16()
662 mutex_lock(&priv->reg_lock); in ub960_read16()
664 ret = regmap_bulk_read(priv->regmap, reg, &__v, sizeof(__v)); in ub960_read16()
674 mutex_unlock(&priv->reg_lock); in ub960_read16()
681 struct device *dev = &priv->client->dev; in ub960_rxport_select()
684 lockdep_assert_held(&priv->reg_lock); in ub960_rxport_select()
686 if (priv->reg_current.rxport == nport) in ub960_rxport_select()
689 ret = regmap_write(priv->regmap, UB960_SR_FPD3_PORT_SEL, in ub960_rxport_select()
697 priv->reg_current.rxport = nport; in ub960_rxport_select()
704 struct device *dev = &priv->client->dev; in ub960_rxport_read()
708 mutex_lock(&priv->reg_lock); in ub960_rxport_read()
714 ret = regmap_read(priv->regmap, reg, &v); in ub960_rxport_read()
724 mutex_unlock(&priv->reg_lock); in ub960_rxport_read()
731 struct device *dev = &priv->client->dev; in ub960_rxport_write()
734 mutex_lock(&priv->reg_lock); in ub960_rxport_write()
740 ret = regmap_write(priv->regmap, reg, val); in ub960_rxport_write()
746 mutex_unlock(&priv->reg_lock); in ub960_rxport_write()
754 struct device *dev = &priv->client->dev; in ub960_rxport_update_bits()
757 mutex_lock(&priv->reg_lock); in ub960_rxport_update_bits()
763 ret = regmap_update_bits(priv->regmap, reg, mask, val); in ub960_rxport_update_bits()
769 mutex_unlock(&priv->reg_lock); in ub960_rxport_update_bits()
777 struct device *dev = &priv->client->dev; in ub960_rxport_read16()
781 mutex_lock(&priv->reg_lock); in ub960_rxport_read16()
787 ret = regmap_bulk_read(priv->regmap, reg, &__v, sizeof(__v)); in ub960_rxport_read16()
797 mutex_unlock(&priv->reg_lock); in ub960_rxport_read16()
804 struct device *dev = &priv->client->dev; in ub960_txport_select()
807 lockdep_assert_held(&priv->reg_lock); in ub960_txport_select()
809 if (priv->reg_current.txport == nport) in ub960_txport_select()
812 ret = regmap_write(priv->regmap, UB960_SR_CSI_PORT_SEL, in ub960_txport_select()
820 priv->reg_current.txport = nport; in ub960_txport_select()
827 struct device *dev = &priv->client->dev; in ub960_txport_read()
831 mutex_lock(&priv->reg_lock); in ub960_txport_read()
837 ret = regmap_read(priv->regmap, reg, &v); in ub960_txport_read()
847 mutex_unlock(&priv->reg_lock); in ub960_txport_read()
854 struct device *dev = &priv->client->dev; in ub960_txport_write()
857 mutex_lock(&priv->reg_lock); in ub960_txport_write()
863 ret = regmap_write(priv->regmap, reg, val); in ub960_txport_write()
869 mutex_unlock(&priv->reg_lock); in ub960_txport_write()
877 struct device *dev = &priv->client->dev; in ub960_txport_update_bits()
880 mutex_lock(&priv->reg_lock); in ub960_txport_update_bits()
886 ret = regmap_update_bits(priv->regmap, reg, mask, val); in ub960_txport_update_bits()
892 mutex_unlock(&priv->reg_lock); in ub960_txport_update_bits()
899 struct device *dev = &priv->client->dev; in ub960_select_ind_reg_block()
902 lockdep_assert_held(&priv->reg_lock); in ub960_select_ind_reg_block()
904 if (priv->reg_current.indirect_target == block) in ub960_select_ind_reg_block()
907 ret = regmap_write(priv->regmap, UB960_SR_IND_ACC_CTL, block << 2); in ub960_select_ind_reg_block()
914 priv->reg_current.indirect_target = block; in ub960_select_ind_reg_block()
921 struct device *dev = &priv->client->dev; in ub960_read_ind()
925 mutex_lock(&priv->reg_lock); in ub960_read_ind()
931 ret = regmap_write(priv->regmap, UB960_SR_IND_ACC_ADDR, reg); in ub960_read_ind()
939 ret = regmap_read(priv->regmap, UB960_SR_IND_ACC_DATA, &v); in ub960_read_ind()
950 mutex_unlock(&priv->reg_lock); in ub960_read_ind()
957 struct device *dev = &priv->client->dev; in ub960_write_ind()
960 mutex_lock(&priv->reg_lock); in ub960_write_ind()
966 ret = regmap_write(priv->regmap, UB960_SR_IND_ACC_ADDR, reg); in ub960_write_ind()
974 ret = regmap_write(priv->regmap, UB960_SR_IND_ACC_DATA, val); in ub960_write_ind()
983 mutex_unlock(&priv->reg_lock); in ub960_write_ind()
991 struct device *dev = &priv->client->dev; in ub960_ind_update_bits()
994 mutex_lock(&priv->reg_lock); in ub960_ind_update_bits()
1000 ret = regmap_write(priv->regmap, UB960_SR_IND_ACC_ADDR, reg); in ub960_ind_update_bits()
1008 ret = regmap_update_bits(priv->regmap, UB960_SR_IND_ACC_DATA, mask, in ub960_ind_update_bits()
1018 mutex_unlock(&priv->reg_lock); in ub960_ind_update_bits()
1023 /* -----------------------------------------------------------------------------
1024 * I2C-ATR (address translator)
1031 struct ub960_rxport *rxport = priv->rxports[chan_id]; in ub960_atr_attach_client()
1032 struct device *dev = &priv->client->dev; in ub960_atr_attach_client()
1035 for (reg_idx = 0; reg_idx < ARRAY_SIZE(rxport->aliased_clients); reg_idx++) { in ub960_atr_attach_client()
1036 if (!rxport->aliased_clients[reg_idx]) in ub960_atr_attach_client()
1040 if (reg_idx == ARRAY_SIZE(rxport->aliased_clients)) { in ub960_atr_attach_client()
1041 dev_err(dev, "rx%u: alias pool exhausted\n", rxport->nport); in ub960_atr_attach_client()
1042 return -EADDRNOTAVAIL; in ub960_atr_attach_client()
1045 rxport->aliased_clients[reg_idx] = client; in ub960_atr_attach_client()
1048 client->addr << 1); in ub960_atr_attach_client()
1053 rxport->nport, client->addr, alias, reg_idx); in ub960_atr_attach_client()
1062 struct ub960_rxport *rxport = priv->rxports[chan_id]; in ub960_atr_detach_client()
1063 struct device *dev = &priv->client->dev; in ub960_atr_detach_client()
1066 for (reg_idx = 0; reg_idx < ARRAY_SIZE(rxport->aliased_clients); reg_idx++) { in ub960_atr_detach_client()
1067 if (rxport->aliased_clients[reg_idx] == client) in ub960_atr_detach_client()
1071 if (reg_idx == ARRAY_SIZE(rxport->aliased_clients)) { in ub960_atr_detach_client()
1073 rxport->nport, client->addr); in ub960_atr_detach_client()
1077 rxport->aliased_clients[reg_idx] = NULL; in ub960_atr_detach_client()
1081 dev_dbg(dev, "rx%u: client 0x%02x released at slot %u\n", rxport->nport, in ub960_atr_detach_client()
1082 client->addr, reg_idx); in ub960_atr_detach_client()
1092 struct device *dev = &priv->client->dev; in ub960_init_atr()
1093 struct i2c_adapter *parent_adap = priv->client->adapter; in ub960_init_atr()
1095 priv->atr = i2c_atr_new(parent_adap, dev, &ub960_atr_ops, in ub960_init_atr()
1096 priv->hw_data->num_rxports); in ub960_init_atr()
1097 if (IS_ERR(priv->atr)) in ub960_init_atr()
1098 return PTR_ERR(priv->atr); in ub960_init_atr()
1100 i2c_atr_set_driver_data(priv->atr, priv); in ub960_init_atr()
1107 i2c_atr_delete(priv->atr); in ub960_uninit_atr()
1108 priv->atr = NULL; in ub960_uninit_atr()
1111 /* -----------------------------------------------------------------------------
1119 struct device *dev = &priv->client->dev; in ub960_parse_dt_txport()
1126 return -ENOMEM; in ub960_parse_dt_txport()
1128 txport->priv = priv; in ub960_parse_dt_txport()
1129 txport->nport = nport; in ub960_parse_dt_txport()
1138 txport->non_continous_clk = vep.bus.mipi_csi2.flags & in ub960_parse_dt_txport()
1141 txport->num_data_lanes = vep.bus.mipi_csi2.num_data_lanes; in ub960_parse_dt_txport()
1144 ret = -EINVAL; in ub960_parse_dt_txport()
1148 priv->tx_link_freq[0] = vep.link_frequencies[0]; in ub960_parse_dt_txport()
1149 priv->tx_data_rate = priv->tx_link_freq[0] * 2; in ub960_parse_dt_txport()
1151 if (priv->tx_data_rate != MHZ(1600) && in ub960_parse_dt_txport()
1152 priv->tx_data_rate != MHZ(1200) && in ub960_parse_dt_txport()
1153 priv->tx_data_rate != MHZ(800) && in ub960_parse_dt_txport()
1154 priv->tx_data_rate != MHZ(400)) { in ub960_parse_dt_txport()
1155 dev_err(dev, "tx%u: invalid 'link-frequencies' value\n", nport); in ub960_parse_dt_txport()
1156 ret = -EINVAL; in ub960_parse_dt_txport()
1162 priv->txports[nport] = txport; in ub960_parse_dt_txport()
1176 struct device *dev = &priv->client->dev; in ub960_csi_handle_events()
1191 /* -----------------------------------------------------------------------------
1200 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { in ub960_rxport_enable_vpocs()
1201 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_rxport_enable_vpocs()
1203 if (!rxport || !rxport->vpoc) in ub960_rxport_enable_vpocs()
1206 ret = regulator_enable(rxport->vpoc); in ub960_rxport_enable_vpocs()
1214 while (nport--) { in ub960_rxport_enable_vpocs()
1215 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_rxport_enable_vpocs()
1217 if (!rxport || !rxport->vpoc) in ub960_rxport_enable_vpocs()
1220 regulator_disable(rxport->vpoc); in ub960_rxport_enable_vpocs()
1230 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { in ub960_rxport_disable_vpocs()
1231 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_rxport_disable_vpocs()
1233 if (!rxport || !rxport->vpoc) in ub960_rxport_disable_vpocs()
1236 regulator_disable(rxport->vpoc); in ub960_rxport_disable_vpocs()
1260 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) in ub960_clear_rx_errors()
1295 *strobe_pos = data_delay - clk_delay; in ub960_rxport_get_strobe_pos()
1309 clk_delay = abs(strobe_pos) - UB960_MANUAL_STROBE_EXTRA_DELAY; in ub960_rxport_set_strobe_pos()
1311 data_delay = strobe_pos - UB960_MANUAL_STROBE_EXTRA_DELAY; in ub960_rxport_set_strobe_pos()
1328 strobe_min -= UB960_MIN_AEQ_STROBE_POS; in ub960_rxport_set_strobe_range()
1329 strobe_max -= UB960_MIN_AEQ_STROBE_POS; in ub960_rxport_set_strobe_range()
1364 eq_stage_2_select_value = eq_level - eq_stage_max; in ub960_rxport_set_eq_level()
1393 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_rxport_config_eq()
1397 if (priv->strobe.manual) { in ub960_rxport_config_eq()
1408 ub960_rxport_set_strobe_range(priv, priv->strobe.min, in ub960_rxport_config_eq()
1409 priv->strobe.max); in ub960_rxport_config_eq()
1414 if (priv->strobe.manual) in ub960_rxport_config_eq()
1415 ub960_rxport_set_strobe_pos(priv, nport, rxport->eq.strobe_pos); in ub960_rxport_config_eq()
1419 if (rxport->eq.manual_eq) { in ub960_rxport_config_eq()
1421 rxport->eq.manual.eq_level); in ub960_rxport_config_eq()
1429 rxport->eq.aeq.eq_level_min, in ub960_rxport_config_eq()
1430 rxport->eq.aeq.eq_level_max); in ub960_rxport_config_eq()
1501 struct device *dev = &priv->client->dev; in ub960_rxport_wait_locks()
1515 if (port_mask >= BIT(priv->hw_data->num_rxports)) in ub960_rxport_wait_locks()
1516 return -EINVAL; in ub960_rxport_wait_locks()
1526 priv->hw_data->num_rxports) { in ub960_rxport_wait_locks()
1527 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_rxport_wait_locks()
1563 for_each_set_bit(nport, &port_mask, priv->hw_data->num_rxports) { in ub960_rxport_wait_locks()
1564 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_rxport_wait_locks()
1599 switch (rxport->rx_mode) { in ub960_calc_bc_clk_rate_ub960()
1621 return clk_get_rate(priv->refclk) * mult / div; in ub960_calc_bc_clk_rate_ub960()
1627 switch (rxport->rx_mode) { in ub960_calc_bc_clk_rate_ub9702()
1646 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_rxport_add_serializer()
1647 struct device *dev = &priv->client->dev; in ub960_rxport_add_serializer()
1648 struct ds90ub9xx_platform_data *ser_pdata = &rxport->ser.pdata; in ub960_rxport_add_serializer()
1650 .of_node = to_of_node(rxport->ser.fwnode), in ub960_rxport_add_serializer()
1651 .fwnode = rxport->ser.fwnode, in ub960_rxport_add_serializer()
1655 ser_pdata->port = nport; in ub960_rxport_add_serializer()
1656 ser_pdata->atr = priv->atr; in ub960_rxport_add_serializer()
1657 if (priv->hw_data->is_ub9702) in ub960_rxport_add_serializer()
1658 ser_pdata->bc_rate = ub960_calc_bc_clk_rate_ub9702(priv, rxport); in ub960_rxport_add_serializer()
1660 ser_pdata->bc_rate = ub960_calc_bc_clk_rate_ub960(priv, rxport); in ub960_rxport_add_serializer()
1665 * the FPD-Link. in ub960_rxport_add_serializer()
1667 ser_info.addr = rxport->ser.alias; in ub960_rxport_add_serializer()
1668 rxport->ser.client = in ub960_rxport_add_serializer()
1669 i2c_new_client_device(priv->client->adapter, &ser_info); in ub960_rxport_add_serializer()
1670 if (IS_ERR(rxport->ser.client)) { in ub960_rxport_add_serializer()
1673 return PTR_ERR(rxport->ser.client); in ub960_rxport_add_serializer()
1676 dev_dbg(dev, "rx%u: remote serializer at alias 0x%02x (%u-%04x)\n", in ub960_rxport_add_serializer()
1677 nport, rxport->ser.client->addr, in ub960_rxport_add_serializer()
1678 rxport->ser.client->adapter->nr, rxport->ser.client->addr); in ub960_rxport_add_serializer()
1685 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_rxport_remove_serializer()
1687 i2c_unregister_device(rxport->ser.client); in ub960_rxport_remove_serializer()
1688 rxport->ser.client = NULL; in ub960_rxport_remove_serializer()
1697 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { in ub960_rxport_add_serializers()
1698 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_rxport_add_serializers()
1711 while (nport--) { in ub960_rxport_add_serializers()
1712 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_rxport_add_serializers()
1727 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { in ub960_rxport_remove_serializers()
1728 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_rxport_remove_serializers()
1740 unsigned int nport = txport->nport; in ub960_init_tx_port()
1744 * From the datasheet: "initial CSI Skew-Calibration in ub960_init_tx_port()
1747 if (priv->tx_data_rate == MHZ(1600)) in ub960_init_tx_port()
1750 csi_ctl |= (4 - txport->num_data_lanes) << 4; in ub960_init_tx_port()
1752 if (!txport->non_continous_clk) in ub960_init_tx_port()
1766 switch (priv->tx_data_rate) { in ub960_init_tx_ports()
1788 if (priv->hw_data->is_ub9702) { in ub960_init_tx_ports()
1791 switch (priv->tx_data_rate) { in ub960_init_tx_ports()
1808 for (nport = 0; nport < priv->hw_data->num_txports; nport++) { in ub960_init_tx_ports()
1809 struct ub960_txport *txport = priv->txports[nport]; in ub960_init_tx_ports()
1823 unsigned int nport = rxport->nport; in ub960_init_rx_port_ub960()
1829 * 0 - 2.5 Mbps (DS90UB913A-Q1 / DS90UB933-Q1) in ub960_init_rx_port_ub960()
1830 * 2 - 10 Mbps in ub960_init_rx_port_ub960()
1831 * 6 - 50 Mbps (DS90UB953-Q1) in ub960_init_rx_port_ub960()
1837 switch (rxport->rx_mode) { in ub960_init_rx_port_ub960()
1860 switch (rxport->rx_mode) { in ub960_init_rx_port_ub960()
1862 /* FPD3_MODE = RAW10 Mode (DS90UB913A-Q1 / DS90UB933-Q1 compatible) */ in ub960_init_rx_port_ub960()
1868 * RAW10_8BIT_CTL = 0b10 : 8-bit processing using upper 8 bits in ub960_init_rx_port_ub960()
1883 /* CSI-2 Mode (DS90UB953-Q1 compatible) */ in ub960_init_rx_port_ub960()
1892 rxport->lv_fv_pol); in ub960_init_rx_port_ub960()
1905 rxport->ser.alias << 1); in ub960_init_rx_port_ub960()
1917 unsigned int nport = rxport->nport; in ub960_init_rx_port_ub9702_fpd3()
1921 switch (rxport->rx_mode) { in ub960_init_rx_port_ub9702_fpd3()
1970 /* serdes_driver_ctl2 control: DS90UB953-Q1/DS90UB933-Q1/DS90UB913A-Q1 */ in ub960_init_rx_port_ub9702_fpd3()
1974 /* RX port to half-rate */ in ub960_init_rx_port_ub9702_fpd3()
1982 unsigned int nport = rxport->nport; in ub960_init_rx_port_ub9702_fpd4_aeq()
2016 unsigned int nport = rxport->nport; in ub960_init_rx_port_ub9702_fpd4()
2019 switch (rxport->rx_mode) { in ub960_init_rx_port_ub9702_fpd4()
2078 unsigned int nport = rxport->nport; in ub960_init_rx_port_ub9702()
2080 if (rxport->cdr_mode == RXPORT_CDR_FPD3) in ub960_init_rx_port_ub9702()
2085 switch (rxport->rx_mode) { in ub960_init_rx_port_ub9702()
2088 * RAW10_8BIT_CTL = 0b11 : 8-bit processing using lower 8 bits in ub960_init_rx_port_ub9702()
2089 * 0b10 : 8-bit processing using upper 8 bits in ub960_init_rx_port_ub9702()
2109 rxport->lv_fv_pol); in ub960_init_rx_port_ub9702()
2122 rxport->ser.alias << 1); in ub960_init_rx_port_ub9702()
2127 if (rxport->cdr_mode == RXPORT_CDR_FPD4) { in ub960_init_rx_port_ub9702()
2137 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { in ub960_init_rx_ports()
2138 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_init_rx_ports()
2143 if (priv->hw_data->is_ub9702) in ub960_init_rx_ports()
2154 struct device *dev = &priv->client->dev; in ub960_rxport_handle_events()
2272 /* -----------------------------------------------------------------------------
2300 for_each_active_route(&state->routing, route) { in ub960_get_vc_maps()
2303 rx = ub960_pad_to_port(priv, route->sink_pad); in ub960_get_vc_maps()
2307 tx = ub960_pad_to_port(priv, route->source_pad); in ub960_get_vc_maps()
2316 struct device *dev = &priv->client->dev; in ub960_enable_tx_port()
2327 struct device *dev = &priv->client->dev; in ub960_disable_tx_port()
2337 struct device *dev = &priv->client->dev; in ub960_enable_rx_port()
2348 struct device *dev = &priv->client->dev; in ub960_disable_rx_port()
2367 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { in ub960_validate_stream_vcs()
2368 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_validate_stream_vcs()
2376 ret = v4l2_subdev_call(rxport->source.sd, pad, get_frame_desc, in ub960_validate_stream_vcs()
2377 rxport->source.pad, &desc); in ub960_validate_stream_vcs()
2393 dev_err(&priv->client->dev, in ub960_validate_stream_vcs()
2394 "rx%u: source with multiple virtual-channels is not supported\n", in ub960_validate_stream_vcs()
2396 return -ENODEV; in ub960_validate_stream_vcs()
2425 for_each_active_route(&state->routing, route) { in ub960_configure_ports_for_streaming()
2432 nport = ub960_pad_to_port(priv, route->sink_pad); in ub960_configure_ports_for_streaming()
2434 rxport = priv->rxports[nport]; in ub960_configure_ports_for_streaming()
2436 return -EINVAL; in ub960_configure_ports_for_streaming()
2438 txport = priv->txports[ub960_pad_to_port(priv, route->source_pad)]; in ub960_configure_ports_for_streaming()
2440 return -EINVAL; in ub960_configure_ports_for_streaming()
2442 rx_data[nport].tx_port = ub960_pad_to_port(priv, route->source_pad); in ub960_configure_ports_for_streaming()
2447 if (rxport->rx_mode == RXPORT_MODE_CSI2_SYNC || in ub960_configure_ports_for_streaming()
2448 rxport->rx_mode == RXPORT_MODE_CSI2_NONSYNC) in ub960_configure_ports_for_streaming()
2452 return -EPIPE; in ub960_configure_ports_for_streaming()
2454 fmt = v4l2_subdev_state_get_format(state, route->sink_pad, in ub960_configure_ports_for_streaming()
2455 route->sink_stream); in ub960_configure_ports_for_streaming()
2457 return -EPIPE; in ub960_configure_ports_for_streaming()
2459 ub960_fmt = ub960_find_format(fmt->code); in ub960_configure_ports_for_streaming()
2461 return -EPIPE; in ub960_configure_ports_for_streaming()
2463 if (ub960_fmt->meta) { in ub960_configure_ports_for_streaming()
2464 if (fmt->height > 3) { in ub960_configure_ports_for_streaming()
2465 dev_err(&priv->client->dev, in ub960_configure_ports_for_streaming()
2467 nport, fmt->height); in ub960_configure_ports_for_streaming()
2468 return -EPIPE; in ub960_configure_ports_for_streaming()
2471 rx_data[nport].meta_dt = ub960_fmt->datatype; in ub960_configure_ports_for_streaming()
2472 rx_data[nport].meta_lines = fmt->height; in ub960_configure_ports_for_streaming()
2474 rx_data[nport].pixel_dt = ub960_fmt->datatype; in ub960_configure_ports_for_streaming()
2486 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { in ub960_configure_ports_for_streaming()
2487 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_configure_ports_for_streaming()
2493 switch (rxport->rx_mode) { in ub960_configure_ports_for_streaming()
2498 ub960_rxport_write(priv, rxport->nport, in ub960_configure_ports_for_streaming()
2512 if (!priv->hw_data->is_ub9702) { in ub960_configure_ports_for_streaming()
2548 if (priv->stream_enable_mask[i]) in ub960_update_streaming_status()
2552 priv->streaming = i < UB960_MAX_NPORTS; in ub960_update_streaming_status()
2560 struct device *dev = &priv->client->dev; in ub960_enable_streams()
2567 if (!priv->streaming) { in ub960_enable_streams()
2575 if (!priv->stream_enable_mask[source_pad]) { in ub960_enable_streams()
2582 priv->stream_enable_mask[source_pad] |= source_streams_mask; in ub960_enable_streams()
2585 for_each_active_route(&state->routing, route) { in ub960_enable_streams()
2586 if (route->source_pad != source_pad) in ub960_enable_streams()
2589 if (!(source_streams_mask & BIT_ULL(route->source_stream))) in ub960_enable_streams()
2592 nport = ub960_pad_to_port(priv, route->sink_pad); in ub960_enable_streams()
2594 sink_streams[nport] |= BIT_ULL(route->sink_stream); in ub960_enable_streams()
2597 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { in ub960_enable_streams()
2602 if (!priv->stream_enable_mask[nport]) { in ub960_enable_streams()
2610 priv->stream_enable_mask[nport] |= sink_streams[nport]; in ub960_enable_streams()
2616 priv->rxports[nport]->source.sd, in ub960_enable_streams()
2617 priv->rxports[nport]->source.pad, in ub960_enable_streams()
2620 priv->stream_enable_mask[nport] &= ~sink_streams[nport]; in ub960_enable_streams()
2622 if (!priv->stream_enable_mask[nport]) in ub960_enable_streams()
2630 priv->streaming = true; in ub960_enable_streams()
2643 priv->rxports[nport]->source.sd, in ub960_enable_streams()
2644 priv->rxports[nport]->source.pad, in ub960_enable_streams()
2649 priv->stream_enable_mask[nport] &= ~sink_streams[nport]; in ub960_enable_streams()
2652 if (!priv->stream_enable_mask[nport]) in ub960_enable_streams()
2656 priv->stream_enable_mask[source_pad] &= ~source_streams_mask; in ub960_enable_streams()
2658 if (!priv->stream_enable_mask[source_pad]) in ub960_enable_streams()
2672 struct device *dev = &priv->client->dev; in ub960_disable_streams()
2679 for_each_active_route(&state->routing, route) { in ub960_disable_streams()
2680 if (route->source_pad != source_pad) in ub960_disable_streams()
2683 if (!(source_streams_mask & BIT_ULL(route->source_stream))) in ub960_disable_streams()
2686 nport = ub960_pad_to_port(priv, route->sink_pad); in ub960_disable_streams()
2688 sink_streams[nport] |= BIT_ULL(route->sink_stream); in ub960_disable_streams()
2691 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { in ub960_disable_streams()
2699 priv->rxports[nport]->source.sd, in ub960_disable_streams()
2700 priv->rxports[nport]->source.pad, in ub960_disable_streams()
2705 priv->stream_enable_mask[nport] &= ~sink_streams[nport]; in ub960_disable_streams()
2708 if (!priv->stream_enable_mask[nport]) in ub960_disable_streams()
2714 priv->stream_enable_mask[source_pad] &= ~source_streams_mask; in ub960_disable_streams()
2716 if (!priv->stream_enable_mask[source_pad]) in ub960_disable_streams()
2746 if (routing->num_routes > V4L2_FRAME_DESC_ENTRY_MAX) in _ub960_set_routing()
2747 return -E2BIG; in _ub960_set_routing()
2769 if (which == V4L2_SUBDEV_FORMAT_ACTIVE && priv->streaming) in ub960_set_routing()
2770 return -EBUSY; in ub960_set_routing()
2782 struct device *dev = &priv->client->dev; in ub960_get_frame_desc()
2786 return -EINVAL; in ub960_get_frame_desc()
2788 fd->type = V4L2_MBUS_FRAME_DESC_TYPE_CSI2; in ub960_get_frame_desc()
2790 state = v4l2_subdev_lock_and_get_active_state(&priv->sd); in ub960_get_frame_desc()
2794 for_each_active_route(&state->routing, route) { in ub960_get_frame_desc()
2800 if (route->source_pad != pad) in ub960_get_frame_desc()
2803 nport = ub960_pad_to_port(priv, route->sink_pad); in ub960_get_frame_desc()
2805 ret = v4l2_subdev_call(priv->rxports[nport]->source.sd, pad, in ub960_get_frame_desc()
2807 priv->rxports[nport]->source.pad, in ub960_get_frame_desc()
2812 route->sink_pad); in ub960_get_frame_desc()
2817 if (source_fd.entry[i].stream == route->sink_stream) { in ub960_get_frame_desc()
2826 ret = -EPIPE; in ub960_get_frame_desc()
2830 fd->entry[fd->num_entries].stream = route->source_stream; in ub960_get_frame_desc()
2831 fd->entry[fd->num_entries].flags = source_entry->flags; in ub960_get_frame_desc()
2832 fd->entry[fd->num_entries].length = source_entry->length; in ub960_get_frame_desc()
2833 fd->entry[fd->num_entries].pixelcode = source_entry->pixelcode; in ub960_get_frame_desc()
2835 fd->entry[fd->num_entries].bus.csi2.vc = vc_map[nport]; in ub960_get_frame_desc()
2838 fd->entry[fd->num_entries].bus.csi2.dt = in ub960_get_frame_desc()
2839 source_entry->bus.csi2.dt; in ub960_get_frame_desc()
2845 route->source_stream); in ub960_get_frame_desc()
2848 ret = -EINVAL; in ub960_get_frame_desc()
2852 ub960_fmt = ub960_find_format(fmt->code); in ub960_get_frame_desc()
2855 ret = -EINVAL; in ub960_get_frame_desc()
2859 fd->entry[fd->num_entries].bus.csi2.dt = in ub960_get_frame_desc()
2860 ub960_fmt->datatype; in ub960_get_frame_desc()
2863 fd->num_entries++; in ub960_get_frame_desc()
2879 if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE && priv->streaming) in ub960_set_fmt()
2880 return -EBUSY; in ub960_set_fmt()
2883 if (ub960_pad_is_source(priv, format->pad)) in ub960_set_fmt()
2890 if (!ub960_find_format(format->format.code)) in ub960_set_fmt()
2891 format->format.code = ub960_formats[0].code; in ub960_set_fmt()
2893 fmt = v4l2_subdev_state_get_format(state, format->pad, format->stream); in ub960_set_fmt()
2895 return -EINVAL; in ub960_set_fmt()
2897 *fmt = format->format; in ub960_set_fmt()
2899 fmt = v4l2_subdev_state_get_opposite_stream_format(state, format->pad, in ub960_set_fmt()
2900 format->stream); in ub960_set_fmt()
2902 return -EINVAL; in ub960_set_fmt()
2904 *fmt = format->format; in ub960_set_fmt()
2918 .source_pad = priv->hw_data->num_rxports, in ub960_init_state()
2946 struct device *dev = &priv->client->dev; in ub960_log_status()
2961 for (nport = 0; nport < priv->hw_data->num_txports; nport++) { in ub960_log_status()
2962 struct ub960_txport *txport = priv->txports[nport]; in ub960_log_status()
2988 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { in ub960_log_status()
2989 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_log_status()
3039 ((v >> UB960_XR_SFILTER_CFG_SFILTER_MIN_SHIFT) & 0xf) - 7, in ub960_log_status()
3040 ((v >> UB960_XR_SFILTER_CFG_SFILTER_MAX_SHIFT) & 0xf) - 7); in ub960_log_status()
3107 /* -----------------------------------------------------------------------------
3123 dev_dbg(&priv->client->dev, "INTERRUPT_STS %x\n", int_sts); in ub960_handle_events()
3129 dev_dbg(&priv->client->dev, "FWD_STS %#02x\n", fwd_sts); in ub960_handle_events()
3131 for (i = 0; i < priv->hw_data->num_txports; i++) { in ub960_handle_events()
3136 for (i = 0; i < priv->hw_data->num_rxports; i++) { in ub960_handle_events()
3137 if (!priv->rxports[i]) in ub960_handle_events()
3155 schedule_delayed_work(&priv->poll_work, in ub960_handler_work()
3163 for (nport = 0; nport < priv->hw_data->num_txports; nport++) { in ub960_txport_free_ports()
3164 struct ub960_txport *txport = priv->txports[nport]; in ub960_txport_free_ports()
3170 priv->txports[nport] = NULL; in ub960_txport_free_ports()
3178 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { in ub960_rxport_free_ports()
3179 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_rxport_free_ports()
3184 fwnode_handle_put(rxport->source.ep_fwnode); in ub960_rxport_free_ports()
3185 fwnode_handle_put(rxport->ser.fwnode); in ub960_rxport_free_ports()
3188 priv->rxports[nport] = NULL; in ub960_rxport_free_ports()
3197 struct device *dev = &priv->client->dev; in ub960_parse_dt_rxport_link_properties()
3198 unsigned int nport = rxport->nport; in ub960_parse_dt_rxport_link_properties()
3208 ret = fwnode_property_read_u32(link_fwnode, "ti,cdr-mode", &cdr_mode); in ub960_parse_dt_rxport_link_properties()
3209 if (ret < 0 && ret != -EINVAL) { in ub960_parse_dt_rxport_link_properties()
3211 "ti,cdr-mode", ret); in ub960_parse_dt_rxport_link_properties()
3216 dev_err(dev, "rx%u: bad 'ti,cdr-mode' %u\n", nport, cdr_mode); in ub960_parse_dt_rxport_link_properties()
3217 return -EINVAL; in ub960_parse_dt_rxport_link_properties()
3220 if (!priv->hw_data->is_fpdlink4 && cdr_mode == RXPORT_CDR_FPD4) { in ub960_parse_dt_rxport_link_properties()
3221 dev_err(dev, "rx%u: FPD-Link 4 CDR not supported\n", nport); in ub960_parse_dt_rxport_link_properties()
3222 return -EINVAL; in ub960_parse_dt_rxport_link_properties()
3225 rxport->cdr_mode = cdr_mode; in ub960_parse_dt_rxport_link_properties()
3227 ret = fwnode_property_read_u32(link_fwnode, "ti,rx-mode", &rx_mode); in ub960_parse_dt_rxport_link_properties()
3230 "ti,rx-mode", ret); in ub960_parse_dt_rxport_link_properties()
3235 dev_err(dev, "rx%u: bad 'ti,rx-mode' %u\n", nport, rx_mode); in ub960_parse_dt_rxport_link_properties()
3236 return -EINVAL; in ub960_parse_dt_rxport_link_properties()
3242 dev_err(dev, "rx%u: unsupported 'ti,rx-mode' %u\n", nport, in ub960_parse_dt_rxport_link_properties()
3244 return -EINVAL; in ub960_parse_dt_rxport_link_properties()
3249 rxport->rx_mode = rx_mode; in ub960_parse_dt_rxport_link_properties()
3254 rxport->eq.manual_eq = false; in ub960_parse_dt_rxport_link_properties()
3255 rxport->eq.aeq.eq_level_min = UB960_MIN_EQ_LEVEL; in ub960_parse_dt_rxport_link_properties()
3256 rxport->eq.aeq.eq_level_max = UB960_MAX_EQ_LEVEL; in ub960_parse_dt_rxport_link_properties()
3258 ret = fwnode_property_read_u32(link_fwnode, "ti,strobe-pos", in ub960_parse_dt_rxport_link_properties()
3261 if (ret != -EINVAL) { in ub960_parse_dt_rxport_link_properties()
3263 "ti,strobe-pos", ret); in ub960_parse_dt_rxport_link_properties()
3269 dev_err(dev, "rx%u: illegal 'strobe-pos' value: %d\n", in ub960_parse_dt_rxport_link_properties()
3271 return -EINVAL; in ub960_parse_dt_rxport_link_properties()
3275 rxport->eq.strobe_pos = strobe_pos; in ub960_parse_dt_rxport_link_properties()
3276 if (!priv->strobe.manual) in ub960_parse_dt_rxport_link_properties()
3278 "rx%u: 'ti,strobe-pos' ignored as 'ti,manual-strobe' not set\n", in ub960_parse_dt_rxport_link_properties()
3282 ret = fwnode_property_read_u32(link_fwnode, "ti,eq-level", &eq_level); in ub960_parse_dt_rxport_link_properties()
3284 if (ret != -EINVAL) { in ub960_parse_dt_rxport_link_properties()
3286 "ti,eq-level", ret); in ub960_parse_dt_rxport_link_properties()
3291 dev_err(dev, "rx%u: illegal 'ti,eq-level' value: %d\n", in ub960_parse_dt_rxport_link_properties()
3293 return -EINVAL; in ub960_parse_dt_rxport_link_properties()
3296 rxport->eq.manual_eq = true; in ub960_parse_dt_rxport_link_properties()
3297 rxport->eq.manual.eq_level = eq_level; in ub960_parse_dt_rxport_link_properties()
3300 ret = fwnode_property_read_u32(link_fwnode, "i2c-alias", in ub960_parse_dt_rxport_link_properties()
3304 "i2c-alias", ret); in ub960_parse_dt_rxport_link_properties()
3307 rxport->ser.alias = ser_i2c_alias; in ub960_parse_dt_rxport_link_properties()
3309 rxport->ser.fwnode = fwnode_get_named_child_node(link_fwnode, "serializer"); in ub960_parse_dt_rxport_link_properties()
3310 if (!rxport->ser.fwnode) { in ub960_parse_dt_rxport_link_properties()
3312 return -EINVAL; in ub960_parse_dt_rxport_link_properties()
3322 struct device *dev = &priv->client->dev; in ub960_parse_dt_rxport_ep_properties()
3324 unsigned int nport = rxport->nport; in ub960_parse_dt_rxport_ep_properties()
3329 rxport->source.ep_fwnode = fwnode_graph_get_remote_endpoint(ep_fwnode); in ub960_parse_dt_rxport_ep_properties()
3330 if (!rxport->source.ep_fwnode) { in ub960_parse_dt_rxport_ep_properties()
3332 return -ENODEV; in ub960_parse_dt_rxport_ep_properties()
3337 switch (rxport->rx_mode) { in ub960_parse_dt_rxport_ep_properties()
3357 rxport->lv_fv_pol = (hsync_hi ? UB960_RR_PORT_CONFIG2_LV_POL_LOW : 0) | in ub960_parse_dt_rxport_ep_properties()
3363 fwnode_handle_put(rxport->source.ep_fwnode); in ub960_parse_dt_rxport_ep_properties()
3374 struct device *dev = &priv->client->dev; in ub960_parse_dt_rxport()
3380 return -ENOMEM; in ub960_parse_dt_rxport()
3382 priv->rxports[nport] = rxport; in ub960_parse_dt_rxport()
3384 rxport->nport = nport; in ub960_parse_dt_rxport()
3385 rxport->priv = priv; in ub960_parse_dt_rxport()
3391 rxport->vpoc = devm_regulator_get_optional(dev, vpoc_names[nport]); in ub960_parse_dt_rxport()
3392 if (IS_ERR(rxport->vpoc)) { in ub960_parse_dt_rxport()
3393 ret = PTR_ERR(rxport->vpoc); in ub960_parse_dt_rxport()
3394 if (ret == -ENODEV) { in ub960_parse_dt_rxport()
3395 rxport->vpoc = NULL; in ub960_parse_dt_rxport()
3410 fwnode_handle_put(rxport->ser.fwnode); in ub960_parse_dt_rxport()
3412 priv->rxports[nport] = NULL; in ub960_parse_dt_rxport()
3445 struct device *dev = &priv->client->dev; in ub960_parse_dt_rxports()
3453 return -ENODEV; in ub960_parse_dt_rxports()
3457 priv->strobe.min = 2; in ub960_parse_dt_rxports()
3458 priv->strobe.max = 3; in ub960_parse_dt_rxports()
3460 priv->strobe.manual = fwnode_property_read_bool(links_fwnode, "ti,manual-strobe"); in ub960_parse_dt_rxports()
3462 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { in ub960_parse_dt_rxports()
3501 struct device *dev = &priv->client->dev; in ub960_parse_dt_txports()
3505 for (nport = 0; nport < priv->hw_data->num_txports; nport++) { in ub960_parse_dt_txports()
3506 unsigned int port = nport + priv->hw_data->num_rxports; in ub960_parse_dt_txports()
3549 struct ub960_data *priv = sd_to_ub960(notifier->sd); in ub960_notify_bound()
3550 struct ub960_rxport *rxport = to_ub960_asd(asd)->rxport; in ub960_notify_bound()
3551 struct device *dev = &priv->client->dev; in ub960_notify_bound()
3552 u8 nport = rxport->nport; in ub960_notify_bound()
3556 ret = media_entity_get_fwnode_pad(&subdev->entity, in ub960_notify_bound()
3557 rxport->source.ep_fwnode, in ub960_notify_bound()
3560 dev_err(dev, "Failed to find pad for %s\n", subdev->name); in ub960_notify_bound()
3564 rxport->source.sd = subdev; in ub960_notify_bound()
3565 rxport->source.pad = ret; in ub960_notify_bound()
3567 ret = media_create_pad_link(&rxport->source.sd->entity, in ub960_notify_bound()
3568 rxport->source.pad, &priv->sd.entity, nport, in ub960_notify_bound()
3572 dev_err(dev, "Unable to link %s:%u -> %s:%u\n", in ub960_notify_bound()
3573 rxport->source.sd->name, rxport->source.pad, in ub960_notify_bound()
3574 priv->sd.name, nport); in ub960_notify_bound()
3578 for (i = 0; i < priv->hw_data->num_rxports; i++) { in ub960_notify_bound()
3579 if (priv->rxports[i] && !priv->rxports[i]->source.sd) { in ub960_notify_bound()
3592 struct ub960_rxport *rxport = to_ub960_asd(asd)->rxport; in ub960_notify_unbind()
3594 rxport->source.sd = NULL; in ub960_notify_unbind()
3604 struct device *dev = &priv->client->dev; in ub960_v4l2_notifier_register()
3608 v4l2_async_subdev_nf_init(&priv->notifier, &priv->sd); in ub960_v4l2_notifier_register()
3610 for (i = 0; i < priv->hw_data->num_rxports; i++) { in ub960_v4l2_notifier_register()
3611 struct ub960_rxport *rxport = priv->rxports[i]; in ub960_v4l2_notifier_register()
3617 asd = v4l2_async_nf_add_fwnode(&priv->notifier, in ub960_v4l2_notifier_register()
3618 rxport->source.ep_fwnode, in ub960_v4l2_notifier_register()
3623 v4l2_async_nf_cleanup(&priv->notifier); in ub960_v4l2_notifier_register()
3627 asd->rxport = rxport; in ub960_v4l2_notifier_register()
3630 priv->notifier.ops = &ub960_notify_ops; in ub960_v4l2_notifier_register()
3632 ret = v4l2_async_nf_register(&priv->notifier); in ub960_v4l2_notifier_register()
3635 v4l2_async_nf_cleanup(&priv->notifier); in ub960_v4l2_notifier_register()
3644 v4l2_async_nf_unregister(&priv->notifier); in ub960_v4l2_notifier_unregister()
3645 v4l2_async_nf_cleanup(&priv->notifier); in ub960_v4l2_notifier_unregister()
3650 struct device *dev = &priv->client->dev; in ub960_create_subdev()
3654 v4l2_i2c_subdev_init(&priv->sd, priv->client, &ub960_subdev_ops); in ub960_create_subdev()
3655 priv->sd.internal_ops = &ub960_internal_ops; in ub960_create_subdev()
3657 v4l2_ctrl_handler_init(&priv->ctrl_handler, 1); in ub960_create_subdev()
3658 priv->sd.ctrl_handler = &priv->ctrl_handler; in ub960_create_subdev()
3660 v4l2_ctrl_new_int_menu(&priv->ctrl_handler, NULL, V4L2_CID_LINK_FREQ, in ub960_create_subdev()
3661 ARRAY_SIZE(priv->tx_link_freq) - 1, 0, in ub960_create_subdev()
3662 priv->tx_link_freq); in ub960_create_subdev()
3664 if (priv->ctrl_handler.error) { in ub960_create_subdev()
3665 ret = priv->ctrl_handler.error; in ub960_create_subdev()
3669 priv->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | in ub960_create_subdev()
3671 priv->sd.entity.function = MEDIA_ENT_F_VID_IF_BRIDGE; in ub960_create_subdev()
3672 priv->sd.entity.ops = &ub960_entity_ops; in ub960_create_subdev()
3674 for (i = 0; i < priv->hw_data->num_rxports + priv->hw_data->num_txports; i++) { in ub960_create_subdev()
3675 priv->pads[i].flags = ub960_pad_is_sink(priv, i) ? in ub960_create_subdev()
3680 ret = media_entity_pads_init(&priv->sd.entity, in ub960_create_subdev()
3681 priv->hw_data->num_rxports + in ub960_create_subdev()
3682 priv->hw_data->num_txports, in ub960_create_subdev()
3683 priv->pads); in ub960_create_subdev()
3687 priv->sd.state_lock = priv->sd.ctrl_handler->lock; in ub960_create_subdev()
3689 ret = v4l2_subdev_init_finalize(&priv->sd); in ub960_create_subdev()
3699 ret = v4l2_async_register_subdev(&priv->sd); in ub960_create_subdev()
3710 v4l2_subdev_cleanup(&priv->sd); in ub960_create_subdev()
3712 media_entity_cleanup(&priv->sd.entity); in ub960_create_subdev()
3714 v4l2_ctrl_handler_free(&priv->ctrl_handler); in ub960_create_subdev()
3722 v4l2_async_unregister_subdev(&priv->sd); in ub960_destroy_subdev()
3724 v4l2_subdev_cleanup(&priv->sd); in ub960_destroy_subdev()
3726 media_entity_cleanup(&priv->sd.entity); in ub960_destroy_subdev()
3727 v4l2_ctrl_handler_free(&priv->ctrl_handler); in ub960_destroy_subdev()
3747 struct device *dev = &priv->client->dev; in ub960_reset()
3757 mutex_lock(&priv->reg_lock); in ub960_reset()
3759 ret = regmap_read_poll_timeout(priv->regmap, UB960_SR_RESET, v, in ub960_reset()
3762 mutex_unlock(&priv->reg_lock); in ub960_reset()
3770 struct device *dev = &priv->client->dev; in ub960_get_hw_resources()
3772 priv->regmap = devm_regmap_init_i2c(priv->client, &ub960_regmap_config); in ub960_get_hw_resources()
3773 if (IS_ERR(priv->regmap)) in ub960_get_hw_resources()
3774 return PTR_ERR(priv->regmap); in ub960_get_hw_resources()
3776 priv->vddio = devm_regulator_get(dev, "vddio"); in ub960_get_hw_resources()
3777 if (IS_ERR(priv->vddio)) in ub960_get_hw_resources()
3778 return dev_err_probe(dev, PTR_ERR(priv->vddio), in ub960_get_hw_resources()
3781 /* get power-down pin from DT */ in ub960_get_hw_resources()
3782 priv->pd_gpio = in ub960_get_hw_resources()
3784 if (IS_ERR(priv->pd_gpio)) in ub960_get_hw_resources()
3785 return dev_err_probe(dev, PTR_ERR(priv->pd_gpio), in ub960_get_hw_resources()
3788 priv->refclk = devm_clk_get(dev, "refclk"); in ub960_get_hw_resources()
3789 if (IS_ERR(priv->refclk)) in ub960_get_hw_resources()
3790 return dev_err_probe(dev, PTR_ERR(priv->refclk), in ub960_get_hw_resources()
3798 struct device *dev = &priv->client->dev; in ub960_enable_core_hw()
3804 ret = regulator_enable(priv->vddio); in ub960_enable_core_hw()
3809 ret = clk_prepare_enable(priv->refclk); in ub960_enable_core_hw()
3815 if (priv->pd_gpio) { in ub960_enable_core_hw()
3816 gpiod_set_value_cansleep(priv->pd_gpio, 1); in ub960_enable_core_hw()
3819 gpiod_set_value_cansleep(priv->pd_gpio, 0); in ub960_enable_core_hw()
3833 dev_dbg(dev, "Found %s (rev/mask %#04x)\n", priv->hw_data->model, in ub960_enable_core_hw()
3846 clk_get_rate(priv->refclk) / 1000000); in ub960_enable_core_hw()
3854 if (priv->hw_data->is_ub9702) { in ub960_enable_core_hw()
3865 gpiod_set_value_cansleep(priv->pd_gpio, 1); in ub960_enable_core_hw()
3866 clk_disable_unprepare(priv->refclk); in ub960_enable_core_hw()
3868 regulator_disable(priv->vddio); in ub960_enable_core_hw()
3875 gpiod_set_value_cansleep(priv->pd_gpio, 1); in ub960_disable_core_hw()
3876 clk_disable_unprepare(priv->refclk); in ub960_disable_core_hw()
3877 regulator_disable(priv->vddio); in ub960_disable_core_hw()
3882 struct device *dev = &client->dev; in ub960_probe()
3891 return -ENOMEM; in ub960_probe()
3893 priv->client = client; in ub960_probe()
3895 priv->hw_data = device_get_match_data(dev); in ub960_probe()
3897 mutex_init(&priv->reg_lock); in ub960_probe()
3899 INIT_DELAYED_WORK(&priv->poll_work, ub960_handler_work); in ub960_probe()
3905 priv->reg_current.indirect_target = 0xff; in ub960_probe()
3906 priv->reg_current.rxport = 0xff; in ub960_probe()
3907 priv->reg_current.txport = 0xff; in ub960_probe()
3937 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { in ub960_probe()
3938 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_probe()
3951 ret = -EIO; in ub960_probe()
3974 if (client->irq) in ub960_probe()
3977 schedule_delayed_work(&priv->poll_work, in ub960_probe()
3994 mutex_destroy(&priv->reg_lock); in ub960_probe()
4003 cancel_delayed_work_sync(&priv->poll_work); in ub960_remove()
4012 mutex_destroy(&priv->reg_lock); in ub960_remove()
4030 { "ds90ub960-q1", (kernel_ulong_t)&ds90ub960_hw },
4031 { "ds90ub9702-q1", (kernel_ulong_t)&ds90ub9702_hw },
4037 { .compatible = "ti,ds90ub960-q1", .data = &ds90ub960_hw },
4038 { .compatible = "ti,ds90ub9702-q1", .data = &ds90ub9702_hw },
4055 MODULE_DESCRIPTION("Texas Instruments FPD-Link III/IV Deserializers Driver");