Lines Matching +full:pse +full:- +full:pis

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>
94 * @param chan: The channel number (0-7).
114 * @param chan: The channel number (0-7).
141 struct i2c_client *client = priv->client; in tps23881_pi_set_pw_pol_limit()
146 chan = priv->port[id].chan[0]; in tps23881_pi_set_pw_pol_limit()
167 struct i2c_client *client = priv->client; in tps23881_pi_enable_manual_pol()
180 chan = priv->port[id].chan[0]; in tps23881_pi_enable_manual_pol()
188 struct i2c_client *client = priv->client; in tps23881_pi_enable()
194 return -ERANGE; in tps23881_pi_enable()
196 chan = priv->port[id].chan[0]; in tps23881_pi_enable()
199 if (priv->port[id].is_4p) { in tps23881_pi_enable()
200 chan = priv->port[id].chan[1]; in tps23881_pi_enable()
210 chan = priv->port[id].chan[0]; in tps23881_pi_enable()
226 struct i2c_client *client = priv->client; in tps23881_pi_disable()
232 return -ERANGE; in tps23881_pi_disable()
234 chan = priv->port[id].chan[0]; in tps23881_pi_disable()
237 if (priv->port[id].is_4p) { in tps23881_pi_disable()
238 chan = priv->port[id].chan[1]; in tps23881_pi_disable()
254 chan = priv->port[id].chan[0]; in tps23881_pi_disable()
269 chan = priv->port[id].chan[0]; in tps23881_pi_disable()
273 if (priv->port[id].is_4p) { in tps23881_pi_disable()
274 chan = priv->port[id].chan[1]; in tps23881_pi_disable()
286 if (priv->port[id].pw_pol < 0) in tps23881_pi_disable()
294 return tps23881_pi_set_pw_pol_limit(priv, id, priv->port[id].pw_pol, in tps23881_pi_disable()
295 priv->port[id].is_4p); in tps23881_pi_disable()
303 struct i2c_client *client = priv->client; in tps23881_pi_get_admin_state()
313 chan = priv->port[id].chan[0]; in tps23881_pi_get_admin_state()
317 if (priv->port[id].is_4p) { in tps23881_pi_get_admin_state()
318 chan = priv->port[id].chan[1]; in tps23881_pi_get_admin_state()
325 admin_state->c33_admin_state = in tps23881_pi_get_admin_state()
328 admin_state->c33_admin_state = in tps23881_pi_get_admin_state()
339 struct i2c_client *client = priv->client; in tps23881_pi_get_pw_status()
349 chan = priv->port[id].chan[0]; in tps23881_pi_get_pw_status()
353 if (priv->port[id].is_4p) { in tps23881_pi_get_pw_status()
354 chan = priv->port[id].chan[1]; in tps23881_pi_get_pw_status()
361 pw_status->c33_pw_status = in tps23881_pi_get_pw_status()
364 pw_status->c33_pw_status = in tps23881_pi_get_pw_status()
373 struct i2c_client *client = priv->client; in tps23881_pi_get_voltage()
390 struct i2c_client *client = priv->client; in tps23881_pi_get_chan_current()
411 struct i2c_client *client = priv->client; in tps23881_pi_get_pw_class()
415 chan = priv->port[id].chan[0]; in tps23881_pi_get_pw_class()
432 ret = tps23881_pi_get_voltage(&priv->pcdev, id); in tps23881_pi_get_actual_pw()
437 chan = priv->port[id].chan[0]; in tps23881_pi_get_actual_pw()
443 if (priv->port[id].is_4p) { in tps23881_pi_get_actual_pw()
444 chan = priv->port[id].chan[1]; in tps23881_pi_get_actual_pw()
460 struct i2c_client *client = priv->client; in tps23881_pi_get_pw_limit_chan()
479 chan = priv->port[id].chan[0]; in tps23881_pi_get_pw_limit()
485 if (priv->port[id].is_4p) { in tps23881_pi_get_pw_limit()
486 chan = priv->port[id].chan[1]; in tps23881_pi_get_pw_limit()
504 dev_err(&priv->client->dev, in tps23881_pi_set_pw_limit()
507 return -ERANGE; in tps23881_pi_set_pw_limit()
517 priv->port[id].pw_pol = pw_pol; in tps23881_pi_set_pw_limit()
519 priv->port[id].is_4p); in tps23881_pi_set_pw_limit()
531 return -ENOMEM; in tps23881_pi_get_pw_limit_ranges()
533 c33_pw_limit_ranges->min = TPS23881_MIN_PI_PW_LIMIT_MW; in tps23881_pi_get_pw_limit_ranges()
534 c33_pw_limit_ranges->max = MAX_PI_PW; in tps23881_pi_get_pw_limit_ranges()
535 pw_limit_ranges->c33_pw_limit_ranges = c33_pw_limit_ranges; in tps23881_pi_get_pw_limit_ranges()
549 if (!priv->np) in tps23881_get_of_channels()
550 return -EINVAL; in tps23881_get_of_channels()
552 channels_node = of_find_node_by_name(priv->np, "channels"); in tps23881_get_of_channels()
554 return -EINVAL; in tps23881_get_of_channels()
564 ret = -EINVAL; in tps23881_get_of_channels()
569 dev_err(&priv->client->dev, in tps23881_get_of_channels()
571 ret = -EINVAL; in tps23881_get_of_channels()
609 if (pairset->np == chan_node[i]) in tps23881_match_channel()
613 return -ENODEV; in tps23881_match_channel()
640 if (!pi->pairset[0].np) in tps23881_match_port_matrix()
643 ret = tps23881_match_channel(&pi->pairset[0], chan_node); in tps23881_match_port_matrix()
649 return -ENODEV; in tps23881_match_port_matrix()
655 if (!pi->pairset[1].np) in tps23881_match_port_matrix()
658 ret = tps23881_match_channel(&pi->pairset[1], chan_node); in tps23881_match_port_matrix()
664 return -ENODEV; in tps23881_match_port_matrix()
668 pr_err("tps23881: 4-pair PSE can only be set within the same 4 ports group"); in tps23881_match_port_matrix()
669 return -ENODEV; in tps23881_match_port_matrix()
705 return -ENODEV; in tps23881_get_unused_chan()
709 * specification of the tps23881. The device has two 4-ports groups and
710 * each 4-pair powered device has to be configured to use two consecutive
739 /* 4-pair ports have to be configured with consecutive in tps23881_sort_port_matrix()
780 return -ENODEV; in tps23881_sort_port_matrix()
795 return -ENODEV; in tps23881_sort_port_matrix()
800 return -ENODEV; in tps23881_sort_port_matrix()
821 struct i2c_client *client = priv->client; in tps23881_write_port_matrix()
833 priv->port[pi_id].chan[0] = lgcl_chan; in tps23881_write_port_matrix()
834 priv->port[pi_id].exist = true; in tps23881_write_port_matrix()
838 priv->port[pi_id].pw_pol = -1; in tps23881_write_port_matrix()
851 priv->port[pi_id].is_4p = true; in tps23881_write_port_matrix()
852 priv->port[pi_id].chan[1] = lgcl_chan; in tps23881_write_port_matrix()
867 struct i2c_client *client = priv->client; in tps23881_set_ports_conf()
919 /* Update with values for every PSE PIs */ in tps23881_set_ports_matrix()
921 ret = tps23881_match_port_matrix(&priv->pcdev.pi[i], i, in tps23881_set_ports_matrix()
946 dev_warn(&priv->client->dev, in tps23881_setup_pi_matrix()
947 "Unable to parse port-matrix, default matrix will be used\n"); in tps23881_setup_pi_matrix()
960 -ERANGE,
967 -ERANGE,
974 -ERANGE,
975 -ERANGE,
981 struct i2c_client *client = priv->client; in tps23881_pi_get_pw_req()
986 /* For a 4-pair the classification need 5ms to be completed */ in tps23881_pi_get_pw_req()
987 if (priv->port[id].is_4p) in tps23881_pi_get_pw_req()
990 chan = priv->port[id].chan[0]; in tps23881_pi_get_pw_req()
1015 static const char fw_parity_name[] = "ti/tps23881/tps23881-parity-14.bin";
1016 static const char fw_sram_name[] = "ti/tps23881/tps23881-sram-14.bin";
1058 ret = request_firmware(&fw, fw_name, &client->dev); in tps23881_flash_sram_fw_part()
1062 dev_dbg(&client->dev, "Flashing %s\n", fw_name); in tps23881_flash_sram_fw_part()
1065 while (fw_conf->reg) { in tps23881_flash_sram_fw_part()
1066 ret = i2c_smbus_write_byte_data(client, fw_conf->reg, in tps23881_flash_sram_fw_part()
1067 fw_conf->val); in tps23881_flash_sram_fw_part()
1075 for (i = 0; i < fw->size; i++) { in tps23881_flash_sram_fw_part()
1078 fw->data[i]); in tps23881_flash_sram_fw_part()
1138 if (!priv->port[i].exist) in tps23881_set_notifs_helper()
1143 chan = priv->port[i].chan[0]; in tps23881_set_notifs_helper()
1161 if (!priv->port[i].exist) in tps23881_irq_event_over_temp()
1189 for_each_set_bit(i, notifs_mask, priv->pcdev.nr_lines) { in tps23881_irq_event_over_current()
1190 if (priv->port[i].pw_pol < 0) in tps23881_irq_event_over_current()
1199 priv->port[i].pw_pol, in tps23881_irq_event_over_current()
1200 priv->port[i].is_4p); in tps23881_irq_event_over_current()
1233 ret = i2c_smbus_read_word_data(priv->client, reg); in tps23881_irq_event_detection()
1262 ret = i2c_smbus_read_word_data(priv->client, reg); in tps23881_irq_event_classification()
1283 struct i2c_client *client = priv->client; in tps23881_irq_event_handler()
1334 struct i2c_client *client = priv->client; in tps23881_irq_handler()
1347 dev_err(&client->dev, "interrupt never freed"); in tps23881_irq_handler()
1348 return -ETIMEDOUT; in tps23881_irq_handler()
1371 struct i2c_client *client = priv->client; in tps23881_setup_irq()
1373 .name = "tps23881-irq", in tps23881_setup_irq()
1380 dev_err(&client->dev, "interrupt is missing"); in tps23881_setup_irq()
1381 return -EINVAL; in tps23881_setup_irq()
1409 return devm_pse_irq_helper(&priv->pcdev, irq, 0, &irq_desc); in tps23881_setup_irq()
1414 struct device *dev = &client->dev; in tps23881_i2c_probe()
1420 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { in tps23881_i2c_probe()
1422 return -ENXIO; in tps23881_i2c_probe()
1427 return -ENOMEM; in tps23881_i2c_probe()
1431 return dev_err_probe(&client->dev, PTR_ERR(reset), "Failed to get reset GPIO\n"); in tps23881_i2c_probe()
1436 gpiod_set_value_cansleep(reset, 0); /* De-assert reset */ in tps23881_i2c_probe()
1454 return -ENXIO; in tps23881_i2c_probe()
1465 dev_info(&client->dev, "Firmware revision 0x%x\n", ret); in tps23881_i2c_probe()
1477 priv->client = client; in tps23881_i2c_probe()
1479 priv->np = dev->of_node; in tps23881_i2c_probe()
1481 priv->pcdev.owner = THIS_MODULE; in tps23881_i2c_probe()
1482 priv->pcdev.ops = &tps23881_ops; in tps23881_i2c_probe()
1483 priv->pcdev.dev = dev; in tps23881_i2c_probe()
1484 priv->pcdev.types = ETHTOOL_PSE_C33; in tps23881_i2c_probe()
1485 priv->pcdev.nr_lines = TPS23881_MAX_CHANS; in tps23881_i2c_probe()
1486 priv->pcdev.supp_budget_eval_strategies = PSE_BUDGET_EVAL_STRAT_STATIC; in tps23881_i2c_probe()
1487 ret = devm_pse_controller_register(dev, &priv->pcdev); in tps23881_i2c_probe()
1490 "failed to register PSE controller\n"); in tps23881_i2c_probe()
1493 ret = tps23881_setup_irq(priv, client->irq); in tps23881_i2c_probe()
1523 MODULE_DESCRIPTION("TI TPS23881 PoE PSE Controller driver");