Lines Matching +full:pse +full:- +full:pi

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Driver for the TI TPS23881 PoE PSE Controller driver (I2C bus)
16 #include <linux/pse-pd/pse.h>
74 * @param chan: The channel number (0-7).
94 * @param chan: The channel number (0-7).
121 struct i2c_client *client = priv->client; in tps23881_pi_set_pw_pol_limit()
126 chan = priv->port[id].chan[0]; in tps23881_pi_set_pw_pol_limit()
130 /* One chan is enough to configure the 4p PI power limit */ in tps23881_pi_set_pw_pol_limit()
147 struct i2c_client *client = priv->client; in tps23881_pi_enable_manual_pol()
160 chan = priv->port[id].chan[0]; in tps23881_pi_enable_manual_pol()
168 struct i2c_client *client = priv->client; in tps23881_pi_enable()
173 return -ERANGE; in tps23881_pi_enable()
175 chan = priv->port[id].chan[0]; in tps23881_pi_enable()
178 if (priv->port[id].is_4p) { in tps23881_pi_enable()
179 chan = priv->port[id].chan[1]; in tps23881_pi_enable()
190 struct i2c_client *client = priv->client; in tps23881_pi_disable()
196 return -ERANGE; in tps23881_pi_disable()
198 chan = priv->port[id].chan[0]; in tps23881_pi_disable()
201 if (priv->port[id].is_4p) { in tps23881_pi_disable()
202 chan = priv->port[id].chan[1]; in tps23881_pi_disable()
222 chan = priv->port[id].chan[0]; in tps23881_pi_disable()
226 if (priv->port[id].is_4p) { in tps23881_pi_disable()
227 chan = priv->port[id].chan[1]; in tps23881_pi_disable()
239 if (priv->port[id].pw_pol < 0) in tps23881_pi_disable()
247 return tps23881_pi_set_pw_pol_limit(priv, id, priv->port[id].pw_pol, in tps23881_pi_disable()
248 priv->port[id].is_4p); in tps23881_pi_disable()
256 struct i2c_client *client = priv->client; in tps23881_pi_get_admin_state()
266 chan = priv->port[id].chan[0]; in tps23881_pi_get_admin_state()
270 if (priv->port[id].is_4p) { in tps23881_pi_get_admin_state()
271 chan = priv->port[id].chan[1]; in tps23881_pi_get_admin_state()
278 admin_state->c33_admin_state = in tps23881_pi_get_admin_state()
281 admin_state->c33_admin_state = in tps23881_pi_get_admin_state()
292 struct i2c_client *client = priv->client; in tps23881_pi_get_pw_status()
302 chan = priv->port[id].chan[0]; in tps23881_pi_get_pw_status()
306 if (priv->port[id].is_4p) { in tps23881_pi_get_pw_status()
307 chan = priv->port[id].chan[1]; in tps23881_pi_get_pw_status()
314 pw_status->c33_pw_status = in tps23881_pi_get_pw_status()
317 pw_status->c33_pw_status = in tps23881_pi_get_pw_status()
326 struct i2c_client *client = priv->client; in tps23881_pi_get_voltage()
343 struct i2c_client *client = priv->client; in tps23881_pi_get_chan_current()
364 struct i2c_client *client = priv->client; in tps23881_pi_get_pw_class()
368 chan = priv->port[id].chan[0]; in tps23881_pi_get_pw_class()
385 ret = tps23881_pi_get_voltage(&priv->pcdev, id); in tps23881_pi_get_actual_pw()
390 chan = priv->port[id].chan[0]; in tps23881_pi_get_actual_pw()
396 if (priv->port[id].is_4p) { in tps23881_pi_get_actual_pw()
397 chan = priv->port[id].chan[1]; in tps23881_pi_get_actual_pw()
413 struct i2c_client *client = priv->client; in tps23881_pi_get_pw_limit_chan()
432 chan = priv->port[id].chan[0]; in tps23881_pi_get_pw_limit()
438 if (priv->port[id].is_4p) { in tps23881_pi_get_pw_limit()
439 chan = priv->port[id].chan[1]; in tps23881_pi_get_pw_limit()
457 dev_err(&priv->client->dev, in tps23881_pi_set_pw_limit()
460 return -ERANGE; in tps23881_pi_set_pw_limit()
470 priv->port[id].pw_pol = pw_pol; in tps23881_pi_set_pw_limit()
472 priv->port[id].is_4p); in tps23881_pi_set_pw_limit()
484 return -ENOMEM; in tps23881_pi_get_pw_limit_ranges()
486 c33_pw_limit_ranges->min = TPS23881_MIN_PI_PW_LIMIT_MW; in tps23881_pi_get_pw_limit_ranges()
487 c33_pw_limit_ranges->max = MAX_PI_PW; in tps23881_pi_get_pw_limit_ranges()
488 pw_limit_ranges->c33_pw_limit_ranges = c33_pw_limit_ranges; in tps23881_pi_get_pw_limit_ranges()
502 if (!priv->np) in tps23881_get_of_channels()
503 return -EINVAL; in tps23881_get_of_channels()
505 channels_node = of_find_node_by_name(priv->np, "channels"); in tps23881_get_of_channels()
507 return -EINVAL; in tps23881_get_of_channels()
517 ret = -EINVAL; in tps23881_get_of_channels()
522 dev_err(&priv->client->dev, in tps23881_get_of_channels()
524 ret = -EINVAL; in tps23881_get_of_channels()
562 if (pairset->np == chan_node[i]) in tps23881_match_channel()
566 return -ENODEV; in tps23881_match_channel()
587 tps23881_match_port_matrix(struct pse_pi *pi, int pi_id, in tps23881_match_port_matrix() argument
593 if (!pi->pairset[0].np) in tps23881_match_port_matrix()
596 ret = tps23881_match_channel(&pi->pairset[0], chan_node); in tps23881_match_port_matrix()
602 return -ENODEV; in tps23881_match_port_matrix()
608 if (!pi->pairset[1].np) in tps23881_match_port_matrix()
611 ret = tps23881_match_channel(&pi->pairset[1], chan_node); in tps23881_match_port_matrix()
617 return -ENODEV; in tps23881_match_port_matrix()
621 pr_err("tps23881: 4-pair PSE can only be set within the same 4 ports group"); in tps23881_match_port_matrix()
622 return -ENODEV; in tps23881_match_port_matrix()
658 return -ENODEV; in tps23881_get_unused_chan()
662 * specification of the tps23881. The device has two 4-ports groups and
663 * each 4-pair powered device has to be configured to use two consecutive
692 /* 4-pair ports have to be configured with consecutive in tps23881_sort_port_matrix()
733 return -ENODEV; in tps23881_sort_port_matrix()
748 return -ENODEV; in tps23881_sort_port_matrix()
753 return -ENODEV; in tps23881_sort_port_matrix()
774 struct i2c_client *client = priv->client; in tps23881_write_port_matrix()
786 priv->port[pi_id].chan[0] = lgcl_chan; in tps23881_write_port_matrix()
789 priv->port[pi_id].pw_pol = -1; in tps23881_write_port_matrix()
802 priv->port[pi_id].is_4p = true; in tps23881_write_port_matrix()
803 priv->port[pi_id].chan[1] = lgcl_chan; in tps23881_write_port_matrix()
818 struct i2c_client *client = priv->client; in tps23881_set_ports_conf()
870 /* Update with values for every PSE PIs */ in tps23881_set_ports_matrix()
872 ret = tps23881_match_port_matrix(&priv->pcdev.pi[i], i, in tps23881_set_ports_matrix()
897 dev_warn(&priv->client->dev, in tps23881_setup_pi_matrix()
898 "Unable to parse port-matrix, default matrix will be used\n"); in tps23881_setup_pi_matrix()
924 static const char fw_parity_name[] = "ti/tps23881/tps23881-parity-14.bin";
925 static const char fw_sram_name[] = "ti/tps23881/tps23881-sram-14.bin";
967 ret = request_firmware(&fw, fw_name, &client->dev); in tps23881_flash_sram_fw_part()
971 dev_dbg(&client->dev, "Flashing %s\n", fw_name); in tps23881_flash_sram_fw_part()
974 while (fw_conf->reg) { in tps23881_flash_sram_fw_part()
975 ret = i2c_smbus_write_byte_data(client, fw_conf->reg, in tps23881_flash_sram_fw_part()
976 fw_conf->val); in tps23881_flash_sram_fw_part()
984 for (i = 0; i < fw->size; i++) { in tps23881_flash_sram_fw_part()
987 fw->data[i]); in tps23881_flash_sram_fw_part()
1022 struct device *dev = &client->dev; in tps23881_i2c_probe()
1028 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { in tps23881_i2c_probe()
1030 return -ENXIO; in tps23881_i2c_probe()
1035 return -ENOMEM; in tps23881_i2c_probe()
1039 return dev_err_probe(&client->dev, PTR_ERR(reset), "Failed to get reset GPIO\n"); in tps23881_i2c_probe()
1044 gpiod_set_value_cansleep(reset, 0); /* De-assert reset */ in tps23881_i2c_probe()
1062 return -ENXIO; in tps23881_i2c_probe()
1073 dev_info(&client->dev, "Firmware revision 0x%x\n", ret); in tps23881_i2c_probe()
1085 priv->client = client; in tps23881_i2c_probe()
1087 priv->np = dev->of_node; in tps23881_i2c_probe()
1089 priv->pcdev.owner = THIS_MODULE; in tps23881_i2c_probe()
1090 priv->pcdev.ops = &tps23881_ops; in tps23881_i2c_probe()
1091 priv->pcdev.dev = dev; in tps23881_i2c_probe()
1092 priv->pcdev.types = ETHTOOL_PSE_C33; in tps23881_i2c_probe()
1093 priv->pcdev.nr_lines = TPS23881_MAX_CHANS; in tps23881_i2c_probe()
1094 ret = devm_pse_controller_register(dev, &priv->pcdev); in tps23881_i2c_probe()
1097 "failed to register PSE controller\n"); in tps23881_i2c_probe()
1126 MODULE_DESCRIPTION("TI TPS23881 PoE PSE Controller driver");