Lines Matching +full:fpd +full:- +full:link

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
18 * and then enable the link.
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()
1538 * We want the link to be ok for two consecutive loops, in ub960_rxport_wait_locks()
1539 * as a link could get established just before our test 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()
2058 /* set serdes_driver_mode into FPD IV mode */ in ub960_init_rx_port_ub9702_fpd4()
2060 /* set FPD PBC drv into FPD IV 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()
2455 route->sink_pad, in ub960_configure_ports_for_streaming()
2456 route->sink_stream); in ub960_configure_ports_for_streaming()
2458 return -EPIPE; in ub960_configure_ports_for_streaming()
2460 ub960_fmt = ub960_find_format(fmt->code); in ub960_configure_ports_for_streaming()
2462 return -EPIPE; in ub960_configure_ports_for_streaming()
2464 if (ub960_fmt->meta) { in ub960_configure_ports_for_streaming()
2465 if (fmt->height > 3) { in ub960_configure_ports_for_streaming()
2466 dev_err(&priv->client->dev, in ub960_configure_ports_for_streaming()
2468 nport, fmt->height); in ub960_configure_ports_for_streaming()
2469 return -EPIPE; in ub960_configure_ports_for_streaming()
2472 rx_data[nport].meta_dt = ub960_fmt->datatype; in ub960_configure_ports_for_streaming()
2473 rx_data[nport].meta_lines = fmt->height; in ub960_configure_ports_for_streaming()
2475 rx_data[nport].pixel_dt = ub960_fmt->datatype; in ub960_configure_ports_for_streaming()
2487 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { in ub960_configure_ports_for_streaming()
2488 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_configure_ports_for_streaming()
2494 switch (rxport->rx_mode) { in ub960_configure_ports_for_streaming()
2499 ub960_rxport_write(priv, rxport->nport, in ub960_configure_ports_for_streaming()
2513 if (!priv->hw_data->is_ub9702) { in ub960_configure_ports_for_streaming()
2549 if (priv->stream_enable_mask[i]) in ub960_update_streaming_status()
2553 priv->streaming = i < UB960_MAX_NPORTS; in ub960_update_streaming_status()
2561 struct device *dev = &priv->client->dev; in ub960_enable_streams()
2568 if (!priv->streaming) { in ub960_enable_streams()
2576 if (!priv->stream_enable_mask[source_pad]) { in ub960_enable_streams()
2583 priv->stream_enable_mask[source_pad] |= source_streams_mask; in ub960_enable_streams()
2586 for_each_active_route(&state->routing, route) { in ub960_enable_streams()
2587 if (route->source_pad != source_pad) in ub960_enable_streams()
2590 if (!(source_streams_mask & BIT_ULL(route->source_stream))) in ub960_enable_streams()
2593 nport = ub960_pad_to_port(priv, route->sink_pad); in ub960_enable_streams()
2595 sink_streams[nport] |= BIT_ULL(route->sink_stream); in ub960_enable_streams()
2598 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { in ub960_enable_streams()
2603 if (!priv->stream_enable_mask[nport]) { in ub960_enable_streams()
2611 priv->stream_enable_mask[nport] |= sink_streams[nport]; in ub960_enable_streams()
2617 priv->rxports[nport]->source.sd, in ub960_enable_streams()
2618 priv->rxports[nport]->source.pad, in ub960_enable_streams()
2621 priv->stream_enable_mask[nport] &= ~sink_streams[nport]; in ub960_enable_streams()
2623 if (!priv->stream_enable_mask[nport]) in ub960_enable_streams()
2631 priv->streaming = true; in ub960_enable_streams()
2644 priv->rxports[nport]->source.sd, in ub960_enable_streams()
2645 priv->rxports[nport]->source.pad, in ub960_enable_streams()
2650 priv->stream_enable_mask[nport] &= ~sink_streams[nport]; in ub960_enable_streams()
2653 if (!priv->stream_enable_mask[nport]) in ub960_enable_streams()
2657 priv->stream_enable_mask[source_pad] &= ~source_streams_mask; in ub960_enable_streams()
2659 if (!priv->stream_enable_mask[source_pad]) in ub960_enable_streams()
2673 struct device *dev = &priv->client->dev; in ub960_disable_streams()
2680 for_each_active_route(&state->routing, route) { in ub960_disable_streams()
2681 if (route->source_pad != source_pad) in ub960_disable_streams()
2684 if (!(source_streams_mask & BIT_ULL(route->source_stream))) in ub960_disable_streams()
2687 nport = ub960_pad_to_port(priv, route->sink_pad); in ub960_disable_streams()
2689 sink_streams[nport] |= BIT_ULL(route->sink_stream); in ub960_disable_streams()
2692 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { in ub960_disable_streams()
2700 priv->rxports[nport]->source.sd, in ub960_disable_streams()
2701 priv->rxports[nport]->source.pad, in ub960_disable_streams()
2706 priv->stream_enable_mask[nport] &= ~sink_streams[nport]; in ub960_disable_streams()
2709 if (!priv->stream_enable_mask[nport]) in ub960_disable_streams()
2715 priv->stream_enable_mask[source_pad] &= ~source_streams_mask; in ub960_disable_streams()
2717 if (!priv->stream_enable_mask[source_pad]) in ub960_disable_streams()
2747 if (routing->num_routes > V4L2_FRAME_DESC_ENTRY_MAX) in _ub960_set_routing()
2748 return -E2BIG; in _ub960_set_routing()
2770 if (which == V4L2_SUBDEV_FORMAT_ACTIVE && priv->streaming) in ub960_set_routing()
2771 return -EBUSY; in ub960_set_routing()
2783 struct device *dev = &priv->client->dev; in ub960_get_frame_desc()
2787 return -EINVAL; in ub960_get_frame_desc()
2791 fd->type = V4L2_MBUS_FRAME_DESC_TYPE_CSI2; in ub960_get_frame_desc()
2793 state = v4l2_subdev_lock_and_get_active_state(&priv->sd); in ub960_get_frame_desc()
2797 for_each_active_route(&state->routing, route) { in ub960_get_frame_desc()
2803 if (route->source_pad != pad) in ub960_get_frame_desc()
2806 nport = ub960_pad_to_port(priv, route->sink_pad); in ub960_get_frame_desc()
2808 ret = v4l2_subdev_call(priv->rxports[nport]->source.sd, pad, in ub960_get_frame_desc()
2810 priv->rxports[nport]->source.pad, in ub960_get_frame_desc()
2815 route->sink_pad); in ub960_get_frame_desc()
2820 if (source_fd.entry[i].stream == route->sink_stream) { in ub960_get_frame_desc()
2829 ret = -EPIPE; in ub960_get_frame_desc()
2833 fd->entry[fd->num_entries].stream = route->source_stream; in ub960_get_frame_desc()
2834 fd->entry[fd->num_entries].flags = source_entry->flags; in ub960_get_frame_desc()
2835 fd->entry[fd->num_entries].length = source_entry->length; in ub960_get_frame_desc()
2836 fd->entry[fd->num_entries].pixelcode = source_entry->pixelcode; in ub960_get_frame_desc()
2838 fd->entry[fd->num_entries].bus.csi2.vc = vc_map[nport]; in ub960_get_frame_desc()
2841 fd->entry[fd->num_entries].bus.csi2.dt = in ub960_get_frame_desc()
2842 source_entry->bus.csi2.dt; in ub960_get_frame_desc()
2848 route->source_stream); in ub960_get_frame_desc()
2851 ret = -EINVAL; in ub960_get_frame_desc()
2855 ub960_fmt = ub960_find_format(fmt->code); in ub960_get_frame_desc()
2858 ret = -EINVAL; in ub960_get_frame_desc()
2862 fd->entry[fd->num_entries].bus.csi2.dt = in ub960_get_frame_desc()
2863 ub960_fmt->datatype; in ub960_get_frame_desc()
2866 fd->num_entries++; in ub960_get_frame_desc()
2882 if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE && priv->streaming) in ub960_set_fmt()
2883 return -EBUSY; in ub960_set_fmt()
2886 if (ub960_pad_is_source(priv, format->pad)) in ub960_set_fmt()
2893 if (!ub960_find_format(format->format.code)) in ub960_set_fmt()
2894 format->format.code = ub960_formats[0].code; in ub960_set_fmt()
2896 fmt = v4l2_subdev_state_get_stream_format(state, format->pad, in ub960_set_fmt()
2897 format->stream); in ub960_set_fmt()
2899 return -EINVAL; in ub960_set_fmt()
2901 *fmt = format->format; in ub960_set_fmt()
2903 fmt = v4l2_subdev_state_get_opposite_stream_format(state, format->pad, in ub960_set_fmt()
2904 format->stream); in ub960_set_fmt()
2906 return -EINVAL; in ub960_set_fmt()
2908 *fmt = format->format; in ub960_set_fmt()
2922 .source_pad = priv->hw_data->num_rxports, in ub960_init_cfg()
2952 struct device *dev = &priv->client->dev; in ub960_log_status()
2967 for (nport = 0; nport < priv->hw_data->num_txports; nport++) { in ub960_log_status()
2968 struct ub960_txport *txport = priv->txports[nport]; in ub960_log_status()
2994 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { in ub960_log_status()
2995 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_log_status()
3045 ((v >> UB960_XR_SFILTER_CFG_SFILTER_MIN_SHIFT) & 0xf) - 7, in ub960_log_status()
3046 ((v >> UB960_XR_SFILTER_CFG_SFILTER_MAX_SHIFT) & 0xf) - 7); in ub960_log_status()
3109 /* -----------------------------------------------------------------------------
3125 dev_dbg(&priv->client->dev, "INTERRUPT_STS %x\n", int_sts); in ub960_handle_events()
3131 dev_dbg(&priv->client->dev, "FWD_STS %#02x\n", fwd_sts); in ub960_handle_events()
3133 for (i = 0; i < priv->hw_data->num_txports; i++) { in ub960_handle_events()
3138 for (i = 0; i < priv->hw_data->num_rxports; i++) { in ub960_handle_events()
3139 if (!priv->rxports[i]) in ub960_handle_events()
3157 schedule_delayed_work(&priv->poll_work, in ub960_handler_work()
3165 for (nport = 0; nport < priv->hw_data->num_txports; nport++) { in ub960_txport_free_ports()
3166 struct ub960_txport *txport = priv->txports[nport]; in ub960_txport_free_ports()
3172 priv->txports[nport] = NULL; in ub960_txport_free_ports()
3180 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { in ub960_rxport_free_ports()
3181 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_rxport_free_ports()
3186 fwnode_handle_put(rxport->source.ep_fwnode); in ub960_rxport_free_ports()
3187 fwnode_handle_put(rxport->ser.fwnode); in ub960_rxport_free_ports()
3190 priv->rxports[nport] = NULL; in ub960_rxport_free_ports()
3199 struct device *dev = &priv->client->dev; in ub960_parse_dt_rxport_link_properties()
3200 unsigned int nport = rxport->nport; in ub960_parse_dt_rxport_link_properties()
3210 ret = fwnode_property_read_u32(link_fwnode, "ti,cdr-mode", &cdr_mode); in ub960_parse_dt_rxport_link_properties()
3211 if (ret < 0 && ret != -EINVAL) { in ub960_parse_dt_rxport_link_properties()
3213 "ti,cdr-mode", ret); in ub960_parse_dt_rxport_link_properties()
3218 dev_err(dev, "rx%u: bad 'ti,cdr-mode' %u\n", nport, cdr_mode); in ub960_parse_dt_rxport_link_properties()
3219 return -EINVAL; in ub960_parse_dt_rxport_link_properties()
3222 if (!priv->hw_data->is_fpdlink4 && cdr_mode == RXPORT_CDR_FPD4) { in ub960_parse_dt_rxport_link_properties()
3223 dev_err(dev, "rx%u: FPD-Link 4 CDR not supported\n", nport); in ub960_parse_dt_rxport_link_properties()
3224 return -EINVAL; in ub960_parse_dt_rxport_link_properties()
3227 rxport->cdr_mode = cdr_mode; in ub960_parse_dt_rxport_link_properties()
3229 ret = fwnode_property_read_u32(link_fwnode, "ti,rx-mode", &rx_mode); in ub960_parse_dt_rxport_link_properties()
3232 "ti,rx-mode", ret); in ub960_parse_dt_rxport_link_properties()
3237 dev_err(dev, "rx%u: bad 'ti,rx-mode' %u\n", nport, rx_mode); in ub960_parse_dt_rxport_link_properties()
3238 return -EINVAL; in ub960_parse_dt_rxport_link_properties()
3244 dev_err(dev, "rx%u: unsupported 'ti,rx-mode' %u\n", nport, in ub960_parse_dt_rxport_link_properties()
3246 return -EINVAL; in ub960_parse_dt_rxport_link_properties()
3251 rxport->rx_mode = rx_mode; in ub960_parse_dt_rxport_link_properties()
3256 rxport->eq.manual_eq = false; in ub960_parse_dt_rxport_link_properties()
3257 rxport->eq.aeq.eq_level_min = UB960_MIN_EQ_LEVEL; in ub960_parse_dt_rxport_link_properties()
3258 rxport->eq.aeq.eq_level_max = UB960_MAX_EQ_LEVEL; in ub960_parse_dt_rxport_link_properties()
3260 ret = fwnode_property_read_u32(link_fwnode, "ti,strobe-pos", in ub960_parse_dt_rxport_link_properties()
3263 if (ret != -EINVAL) { in ub960_parse_dt_rxport_link_properties()
3265 "ti,strobe-pos", ret); in ub960_parse_dt_rxport_link_properties()
3271 dev_err(dev, "rx%u: illegal 'strobe-pos' value: %d\n", in ub960_parse_dt_rxport_link_properties()
3273 return -EINVAL; in ub960_parse_dt_rxport_link_properties()
3277 rxport->eq.strobe_pos = strobe_pos; in ub960_parse_dt_rxport_link_properties()
3278 if (!priv->strobe.manual) in ub960_parse_dt_rxport_link_properties()
3280 "rx%u: 'ti,strobe-pos' ignored as 'ti,manual-strobe' not set\n", in ub960_parse_dt_rxport_link_properties()
3284 ret = fwnode_property_read_u32(link_fwnode, "ti,eq-level", &eq_level); in ub960_parse_dt_rxport_link_properties()
3286 if (ret != -EINVAL) { in ub960_parse_dt_rxport_link_properties()
3288 "ti,eq-level", ret); in ub960_parse_dt_rxport_link_properties()
3293 dev_err(dev, "rx%u: illegal 'ti,eq-level' value: %d\n", in ub960_parse_dt_rxport_link_properties()
3295 return -EINVAL; in ub960_parse_dt_rxport_link_properties()
3298 rxport->eq.manual_eq = true; in ub960_parse_dt_rxport_link_properties()
3299 rxport->eq.manual.eq_level = eq_level; in ub960_parse_dt_rxport_link_properties()
3302 ret = fwnode_property_read_u32(link_fwnode, "i2c-alias", in ub960_parse_dt_rxport_link_properties()
3306 "i2c-alias", ret); in ub960_parse_dt_rxport_link_properties()
3309 rxport->ser.alias = ser_i2c_alias; in ub960_parse_dt_rxport_link_properties()
3311 rxport->ser.fwnode = fwnode_get_named_child_node(link_fwnode, "serializer"); in ub960_parse_dt_rxport_link_properties()
3312 if (!rxport->ser.fwnode) { in ub960_parse_dt_rxport_link_properties()
3314 return -EINVAL; in ub960_parse_dt_rxport_link_properties()
3324 struct device *dev = &priv->client->dev; in ub960_parse_dt_rxport_ep_properties()
3326 unsigned int nport = rxport->nport; in ub960_parse_dt_rxport_ep_properties()
3331 rxport->source.ep_fwnode = fwnode_graph_get_remote_endpoint(ep_fwnode); in ub960_parse_dt_rxport_ep_properties()
3332 if (!rxport->source.ep_fwnode) { in ub960_parse_dt_rxport_ep_properties()
3334 return -ENODEV; in ub960_parse_dt_rxport_ep_properties()
3339 switch (rxport->rx_mode) { in ub960_parse_dt_rxport_ep_properties()
3359 rxport->lv_fv_pol = (hsync_hi ? UB960_RR_PORT_CONFIG2_LV_POL_LOW : 0) | in ub960_parse_dt_rxport_ep_properties()
3365 fwnode_handle_put(rxport->source.ep_fwnode); in ub960_parse_dt_rxport_ep_properties()
3376 struct device *dev = &priv->client->dev; in ub960_parse_dt_rxport()
3382 return -ENOMEM; in ub960_parse_dt_rxport()
3384 priv->rxports[nport] = rxport; in ub960_parse_dt_rxport()
3386 rxport->nport = nport; in ub960_parse_dt_rxport()
3387 rxport->priv = priv; in ub960_parse_dt_rxport()
3393 rxport->vpoc = devm_regulator_get_optional(dev, vpoc_names[nport]); in ub960_parse_dt_rxport()
3394 if (IS_ERR(rxport->vpoc)) { in ub960_parse_dt_rxport()
3395 ret = PTR_ERR(rxport->vpoc); in ub960_parse_dt_rxport()
3396 if (ret == -ENODEV) { in ub960_parse_dt_rxport()
3397 rxport->vpoc = NULL; in ub960_parse_dt_rxport()
3412 fwnode_handle_put(rxport->ser.fwnode); in ub960_parse_dt_rxport()
3414 priv->rxports[nport] = NULL; in ub960_parse_dt_rxport()
3429 if (!str_has_prefix(fwnode_get_name(link_fwnode), "link@")) in ub960_fwnode_get_link_by_regs()
3447 struct device *dev = &priv->client->dev; in ub960_parse_dt_rxports()
3455 return -ENODEV; in ub960_parse_dt_rxports()
3459 priv->strobe.min = 2; in ub960_parse_dt_rxports()
3460 priv->strobe.max = 3; in ub960_parse_dt_rxports()
3462 priv->strobe.manual = fwnode_property_read_bool(links_fwnode, "ti,manual-strobe"); in ub960_parse_dt_rxports()
3464 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { in ub960_parse_dt_rxports()
3503 struct device *dev = &priv->client->dev; in ub960_parse_dt_txports()
3507 for (nport = 0; nport < priv->hw_data->num_txports; nport++) { in ub960_parse_dt_txports()
3508 unsigned int port = nport + priv->hw_data->num_rxports; in ub960_parse_dt_txports()
3551 struct ub960_data *priv = sd_to_ub960(notifier->sd); in ub960_notify_bound()
3552 struct ub960_rxport *rxport = to_ub960_asd(asd)->rxport; in ub960_notify_bound()
3553 struct device *dev = &priv->client->dev; in ub960_notify_bound()
3554 u8 nport = rxport->nport; in ub960_notify_bound()
3558 ret = media_entity_get_fwnode_pad(&subdev->entity, in ub960_notify_bound()
3559 rxport->source.ep_fwnode, in ub960_notify_bound()
3562 dev_err(dev, "Failed to find pad for %s\n", subdev->name); in ub960_notify_bound()
3566 rxport->source.sd = subdev; in ub960_notify_bound()
3567 rxport->source.pad = ret; in ub960_notify_bound()
3569 ret = media_create_pad_link(&rxport->source.sd->entity, in ub960_notify_bound()
3570 rxport->source.pad, &priv->sd.entity, nport, in ub960_notify_bound()
3574 dev_err(dev, "Unable to link %s:%u -> %s:%u\n", in ub960_notify_bound()
3575 rxport->source.sd->name, rxport->source.pad, in ub960_notify_bound()
3576 priv->sd.name, nport); in ub960_notify_bound()
3580 for (i = 0; i < priv->hw_data->num_rxports; i++) { in ub960_notify_bound()
3581 if (priv->rxports[i] && !priv->rxports[i]->source.sd) { in ub960_notify_bound()
3594 struct ub960_rxport *rxport = to_ub960_asd(asd)->rxport; in ub960_notify_unbind()
3596 rxport->source.sd = NULL; in ub960_notify_unbind()
3606 struct device *dev = &priv->client->dev; in ub960_v4l2_notifier_register()
3610 v4l2_async_subdev_nf_init(&priv->notifier, &priv->sd); in ub960_v4l2_notifier_register()
3612 for (i = 0; i < priv->hw_data->num_rxports; i++) { in ub960_v4l2_notifier_register()
3613 struct ub960_rxport *rxport = priv->rxports[i]; in ub960_v4l2_notifier_register()
3619 asd = v4l2_async_nf_add_fwnode(&priv->notifier, in ub960_v4l2_notifier_register()
3620 rxport->source.ep_fwnode, in ub960_v4l2_notifier_register()
3625 v4l2_async_nf_cleanup(&priv->notifier); in ub960_v4l2_notifier_register()
3629 asd->rxport = rxport; in ub960_v4l2_notifier_register()
3632 priv->notifier.ops = &ub960_notify_ops; in ub960_v4l2_notifier_register()
3634 ret = v4l2_async_nf_register(&priv->notifier); in ub960_v4l2_notifier_register()
3637 v4l2_async_nf_cleanup(&priv->notifier); in ub960_v4l2_notifier_register()
3646 v4l2_async_nf_unregister(&priv->notifier); in ub960_v4l2_notifier_unregister()
3647 v4l2_async_nf_cleanup(&priv->notifier); in ub960_v4l2_notifier_unregister()
3652 struct device *dev = &priv->client->dev; in ub960_create_subdev()
3656 v4l2_i2c_subdev_init(&priv->sd, priv->client, &ub960_subdev_ops); in ub960_create_subdev()
3658 v4l2_ctrl_handler_init(&priv->ctrl_handler, 1); in ub960_create_subdev()
3659 priv->sd.ctrl_handler = &priv->ctrl_handler; in ub960_create_subdev()
3661 v4l2_ctrl_new_int_menu(&priv->ctrl_handler, NULL, V4L2_CID_LINK_FREQ, in ub960_create_subdev()
3662 ARRAY_SIZE(priv->tx_link_freq) - 1, 0, in ub960_create_subdev()
3663 priv->tx_link_freq); in ub960_create_subdev()
3665 if (priv->ctrl_handler.error) { in ub960_create_subdev()
3666 ret = priv->ctrl_handler.error; in ub960_create_subdev()
3670 priv->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | in ub960_create_subdev()
3672 priv->sd.entity.function = MEDIA_ENT_F_VID_IF_BRIDGE; in ub960_create_subdev()
3673 priv->sd.entity.ops = &ub960_entity_ops; in ub960_create_subdev()
3675 for (i = 0; i < priv->hw_data->num_rxports + priv->hw_data->num_txports; i++) { in ub960_create_subdev()
3676 priv->pads[i].flags = ub960_pad_is_sink(priv, i) ? in ub960_create_subdev()
3681 ret = media_entity_pads_init(&priv->sd.entity, in ub960_create_subdev()
3682 priv->hw_data->num_rxports + in ub960_create_subdev()
3683 priv->hw_data->num_txports, in ub960_create_subdev()
3684 priv->pads); in ub960_create_subdev()
3688 priv->sd.state_lock = priv->sd.ctrl_handler->lock; in ub960_create_subdev()
3690 ret = v4l2_subdev_init_finalize(&priv->sd); in ub960_create_subdev()
3700 ret = v4l2_async_register_subdev(&priv->sd); in ub960_create_subdev()
3711 v4l2_subdev_cleanup(&priv->sd); in ub960_create_subdev()
3713 media_entity_cleanup(&priv->sd.entity); in ub960_create_subdev()
3715 v4l2_ctrl_handler_free(&priv->ctrl_handler); in ub960_create_subdev()
3723 v4l2_async_unregister_subdev(&priv->sd); in ub960_destroy_subdev()
3725 v4l2_subdev_cleanup(&priv->sd); in ub960_destroy_subdev()
3727 media_entity_cleanup(&priv->sd.entity); in ub960_destroy_subdev()
3728 v4l2_ctrl_handler_free(&priv->ctrl_handler); in ub960_destroy_subdev()
3748 struct device *dev = &priv->client->dev; in ub960_reset()
3758 mutex_lock(&priv->reg_lock); in ub960_reset()
3760 ret = regmap_read_poll_timeout(priv->regmap, UB960_SR_RESET, v, in ub960_reset()
3763 mutex_unlock(&priv->reg_lock); in ub960_reset()
3771 struct device *dev = &priv->client->dev; in ub960_get_hw_resources()
3773 priv->regmap = devm_regmap_init_i2c(priv->client, &ub960_regmap_config); in ub960_get_hw_resources()
3774 if (IS_ERR(priv->regmap)) in ub960_get_hw_resources()
3775 return PTR_ERR(priv->regmap); in ub960_get_hw_resources()
3777 priv->vddio = devm_regulator_get(dev, "vddio"); in ub960_get_hw_resources()
3778 if (IS_ERR(priv->vddio)) in ub960_get_hw_resources()
3779 return dev_err_probe(dev, PTR_ERR(priv->vddio), in ub960_get_hw_resources()
3782 /* get power-down pin from DT */ in ub960_get_hw_resources()
3783 priv->pd_gpio = in ub960_get_hw_resources()
3785 if (IS_ERR(priv->pd_gpio)) in ub960_get_hw_resources()
3786 return dev_err_probe(dev, PTR_ERR(priv->pd_gpio), in ub960_get_hw_resources()
3789 priv->refclk = devm_clk_get(dev, "refclk"); in ub960_get_hw_resources()
3790 if (IS_ERR(priv->refclk)) in ub960_get_hw_resources()
3791 return dev_err_probe(dev, PTR_ERR(priv->refclk), in ub960_get_hw_resources()
3799 struct device *dev = &priv->client->dev; in ub960_enable_core_hw()
3805 ret = regulator_enable(priv->vddio); in ub960_enable_core_hw()
3810 ret = clk_prepare_enable(priv->refclk); in ub960_enable_core_hw()
3816 if (priv->pd_gpio) { in ub960_enable_core_hw()
3817 gpiod_set_value_cansleep(priv->pd_gpio, 1); in ub960_enable_core_hw()
3820 gpiod_set_value_cansleep(priv->pd_gpio, 0); in ub960_enable_core_hw()
3834 dev_dbg(dev, "Found %s (rev/mask %#04x)\n", priv->hw_data->model, in ub960_enable_core_hw()
3847 clk_get_rate(priv->refclk) / 1000000); in ub960_enable_core_hw()
3855 if (priv->hw_data->is_ub9702) { in ub960_enable_core_hw()
3866 gpiod_set_value_cansleep(priv->pd_gpio, 1); in ub960_enable_core_hw()
3867 clk_disable_unprepare(priv->refclk); in ub960_enable_core_hw()
3869 regulator_disable(priv->vddio); in ub960_enable_core_hw()
3876 gpiod_set_value_cansleep(priv->pd_gpio, 1); in ub960_disable_core_hw()
3877 clk_disable_unprepare(priv->refclk); in ub960_disable_core_hw()
3878 regulator_disable(priv->vddio); in ub960_disable_core_hw()
3883 struct device *dev = &client->dev; in ub960_probe()
3892 return -ENOMEM; in ub960_probe()
3894 priv->client = client; in ub960_probe()
3896 priv->hw_data = device_get_match_data(dev); in ub960_probe()
3898 mutex_init(&priv->reg_lock); in ub960_probe()
3900 INIT_DELAYED_WORK(&priv->poll_work, ub960_handler_work); in ub960_probe()
3906 priv->reg_current.indirect_target = 0xff; in ub960_probe()
3907 priv->reg_current.rxport = 0xff; in ub960_probe()
3908 priv->reg_current.txport = 0xff; in ub960_probe()
3938 for (nport = 0; nport < priv->hw_data->num_rxports; nport++) { in ub960_probe()
3939 struct ub960_rxport *rxport = priv->rxports[nport]; in ub960_probe()
3952 ret = -EIO; in ub960_probe()
3975 if (client->irq) in ub960_probe()
3978 schedule_delayed_work(&priv->poll_work, in ub960_probe()
3995 mutex_destroy(&priv->reg_lock); in ub960_probe()
4004 cancel_delayed_work_sync(&priv->poll_work); in ub960_remove()
4013 mutex_destroy(&priv->reg_lock); in ub960_remove()
4031 { "ds90ub960-q1", (kernel_ulong_t)&ds90ub960_hw },
4032 { "ds90ub9702-q1", (kernel_ulong_t)&ds90ub9702_hw },
4038 { .compatible = "ti,ds90ub960-q1", .data = &ds90ub960_hw },
4039 { .compatible = "ti,ds90ub9702-q1", .data = &ds90ub9702_hw },
4056 MODULE_DESCRIPTION("Texas Instruments FPD-Link III/IV Deserializers Driver");