Lines Matching +full:client +full:- +full:id

1 // SPDX-License-Identifier: GPL-2.0-or-later
105 #define LTC_POLL_TIMEOUT 100 /* in milli-seconds */
119 enum chips id; member
135 #define has_clear_peaks(d) ((d)->features & FEAT_CLEAR_PEAKS)
136 #define needs_polling(d) ((d)->features & FEAT_NEEDS_POLLING)
138 static int ltc_wait_ready(struct i2c_client *client) in ltc_wait_ready() argument
141 const struct pmbus_driver_info *info = pmbus_get_driver_info(client); in ltc_wait_ready()
154 if (data->id != ltc3883) in ltc_wait_ready()
158 status = pmbus_read_byte_data(client, 0, LTC2978_MFR_COMMON); in ltc_wait_ready()
159 if (status == -EBADMSG || status == -ENXIO) { in ltc_wait_ready()
173 return -ETIMEDOUT; in ltc_wait_ready()
176 static int ltc_read_word_data(struct i2c_client *client, int page, int phase, in ltc_read_word_data() argument
181 ret = ltc_wait_ready(client); in ltc_read_word_data()
185 return pmbus_read_word_data(client, page, 0xff, reg); in ltc_read_word_data()
188 static int ltc_read_byte_data(struct i2c_client *client, int page, int reg) in ltc_read_byte_data() argument
192 ret = ltc_wait_ready(client); in ltc_read_byte_data()
196 return pmbus_read_byte_data(client, page, reg); in ltc_read_byte_data()
199 static int ltc_write_byte_data(struct i2c_client *client, int page, int reg, u8 value) in ltc_write_byte_data() argument
203 ret = ltc_wait_ready(client); in ltc_write_byte_data()
207 return pmbus_write_byte_data(client, page, reg, value); in ltc_write_byte_data()
210 static int ltc_write_byte(struct i2c_client *client, int page, u8 byte) in ltc_write_byte() argument
214 ret = ltc_wait_ready(client); in ltc_write_byte()
218 return pmbus_write_byte(client, page, byte); in ltc_write_byte()
231 return (e < 0 ? m >> -e : m << e); in lin11_to_val()
234 static int ltc_get_max(struct ltc2978_data *data, struct i2c_client *client, in ltc_get_max() argument
239 ret = ltc_read_word_data(client, page, 0xff, reg); in ltc_get_max()
248 static int ltc_get_min(struct ltc2978_data *data, struct i2c_client *client, in ltc_get_min() argument
253 ret = ltc_read_word_data(client, page, 0xff, reg); in ltc_get_min()
262 static int ltc2978_read_word_data_common(struct i2c_client *client, int page, in ltc2978_read_word_data_common() argument
265 const struct pmbus_driver_info *info = pmbus_get_driver_info(client); in ltc2978_read_word_data_common()
271 ret = ltc_get_max(data, client, page, LTC2978_MFR_VIN_PEAK, in ltc2978_read_word_data_common()
272 &data->vin_max); in ltc2978_read_word_data_common()
275 ret = ltc_read_word_data(client, page, 0xff, in ltc2978_read_word_data_common()
282 if (ret > data->vout_max[page]) in ltc2978_read_word_data_common()
283 data->vout_max[page] = ret; in ltc2978_read_word_data_common()
284 ret = data->vout_max[page]; in ltc2978_read_word_data_common()
288 ret = ltc_get_max(data, client, page, in ltc2978_read_word_data_common()
290 &data->temp_max[page]); in ltc2978_read_word_data_common()
298 ret = ltc_wait_ready(client); in ltc2978_read_word_data_common()
301 ret = -ENODATA; in ltc2978_read_word_data_common()
307 static int ltc2978_read_word_data(struct i2c_client *client, int page, in ltc2978_read_word_data() argument
310 const struct pmbus_driver_info *info = pmbus_get_driver_info(client); in ltc2978_read_word_data()
316 ret = ltc_get_min(data, client, page, LTC2978_MFR_VIN_MIN, in ltc2978_read_word_data()
317 &data->vin_min); in ltc2978_read_word_data()
320 ret = ltc_read_word_data(client, page, phase, in ltc2978_read_word_data()
329 if (data->vout_max[page] && ret > data->vout_max[page]) in ltc2978_read_word_data()
330 ret = data->vout_max[page]; in ltc2978_read_word_data()
331 if (ret < data->vout_min[page]) in ltc2978_read_word_data()
332 data->vout_min[page] = ret; in ltc2978_read_word_data()
333 ret = data->vout_min[page]; in ltc2978_read_word_data()
337 ret = ltc_get_min(data, client, page, in ltc2978_read_word_data()
339 &data->temp_min[page]); in ltc2978_read_word_data()
345 ret = -ENXIO; in ltc2978_read_word_data()
348 ret = ltc2978_read_word_data_common(client, page, reg); in ltc2978_read_word_data()
354 static int ltc2974_read_word_data(struct i2c_client *client, int page, in ltc2974_read_word_data() argument
357 const struct pmbus_driver_info *info = pmbus_get_driver_info(client); in ltc2974_read_word_data()
363 ret = ltc_get_max(data, client, page, LTC2974_MFR_IOUT_PEAK, in ltc2974_read_word_data()
364 &data->iout_max[page]); in ltc2974_read_word_data()
367 ret = ltc_get_min(data, client, page, LTC2974_MFR_IOUT_MIN, in ltc2974_read_word_data()
368 &data->iout_min[page]); in ltc2974_read_word_data()
374 ret = ltc2978_read_word_data(client, page, phase, reg); in ltc2974_read_word_data()
380 static int ltc2975_read_word_data(struct i2c_client *client, int page, in ltc2975_read_word_data() argument
383 const struct pmbus_driver_info *info = pmbus_get_driver_info(client); in ltc2975_read_word_data()
389 ret = ltc_get_max(data, client, page, LTC2975_MFR_IIN_PEAK, in ltc2975_read_word_data()
390 &data->iin_max); in ltc2975_read_word_data()
393 ret = ltc_get_min(data, client, page, LTC2975_MFR_IIN_MIN, in ltc2975_read_word_data()
394 &data->iin_min); in ltc2975_read_word_data()
397 ret = ltc_get_max(data, client, page, LTC2975_MFR_PIN_PEAK, in ltc2975_read_word_data()
398 &data->pin_max); in ltc2975_read_word_data()
401 ret = ltc_get_min(data, client, page, LTC2975_MFR_PIN_MIN, in ltc2975_read_word_data()
402 &data->pin_min); in ltc2975_read_word_data()
409 ret = ltc2978_read_word_data(client, page, phase, reg); in ltc2975_read_word_data()
415 static int ltc3880_read_word_data(struct i2c_client *client, int page, in ltc3880_read_word_data() argument
418 const struct pmbus_driver_info *info = pmbus_get_driver_info(client); in ltc3880_read_word_data()
424 ret = ltc_get_max(data, client, page, LTC3880_MFR_IOUT_PEAK, in ltc3880_read_word_data()
425 &data->iout_max[page]); in ltc3880_read_word_data()
428 ret = ltc_get_max(data, client, page, in ltc3880_read_word_data()
430 &data->temp2_max); in ltc3880_read_word_data()
435 ret = -ENXIO; in ltc3880_read_word_data()
442 ret = ltc2978_read_word_data_common(client, page, reg); in ltc3880_read_word_data()
448 static int ltc3883_read_word_data(struct i2c_client *client, int page, in ltc3883_read_word_data() argument
451 const struct pmbus_driver_info *info = pmbus_get_driver_info(client); in ltc3883_read_word_data()
457 ret = ltc_get_max(data, client, page, LTC3883_MFR_IIN_PEAK, in ltc3883_read_word_data()
458 &data->iin_max); in ltc3883_read_word_data()
464 ret = ltc3880_read_word_data(client, page, phase, reg); in ltc3883_read_word_data()
471 struct i2c_client *client, int page) in ltc2978_clear_peaks() argument
476 ret = ltc_write_byte(client, 0, LTC3880_MFR_CLEAR_PEAKS); in ltc2978_clear_peaks()
478 ret = ltc_write_byte(client, page, PMBUS_CLEAR_FAULTS); in ltc2978_clear_peaks()
483 static int ltc2978_write_word_data(struct i2c_client *client, int page, in ltc2978_write_word_data() argument
486 const struct pmbus_driver_info *info = pmbus_get_driver_info(client); in ltc2978_write_word_data()
492 data->iin_max = 0x7c00; in ltc2978_write_word_data()
493 data->iin_min = 0x7bff; in ltc2978_write_word_data()
494 ret = ltc2978_clear_peaks(data, client, 0); in ltc2978_write_word_data()
497 data->pin_max = 0x7c00; in ltc2978_write_word_data()
498 data->pin_min = 0x7bff; in ltc2978_write_word_data()
499 ret = ltc2978_clear_peaks(data, client, 0); in ltc2978_write_word_data()
502 data->iout_max[page] = 0x7c00; in ltc2978_write_word_data()
503 data->iout_min[page] = 0xfbff; in ltc2978_write_word_data()
504 ret = ltc2978_clear_peaks(data, client, page); in ltc2978_write_word_data()
507 data->temp2_max = 0x7c00; in ltc2978_write_word_data()
508 ret = ltc2978_clear_peaks(data, client, page); in ltc2978_write_word_data()
511 data->vout_min[page] = 0xffff; in ltc2978_write_word_data()
512 data->vout_max[page] = 0; in ltc2978_write_word_data()
513 ret = ltc2978_clear_peaks(data, client, page); in ltc2978_write_word_data()
516 data->vin_min = 0x7bff; in ltc2978_write_word_data()
517 data->vin_max = 0x7c00; in ltc2978_write_word_data()
518 ret = ltc2978_clear_peaks(data, client, page); in ltc2978_write_word_data()
521 data->temp_min[page] = 0x7bff; in ltc2978_write_word_data()
522 data->temp_max[page] = 0x7c00; in ltc2978_write_word_data()
523 ret = ltc2978_clear_peaks(data, client, page); in ltc2978_write_word_data()
526 ret = ltc_wait_ready(client); in ltc2978_write_word_data()
529 ret = -ENODATA; in ltc2978_write_word_data()
594 static int ltc2978_get_id(struct i2c_client *client) in ltc2978_get_id() argument
598 chip_id = i2c_smbus_read_word_data(client, LTC2978_MFR_SPECIAL_ID); in ltc2978_get_id()
600 const struct i2c_device_id *id; in ltc2978_get_id() local
604 if (!i2c_check_functionality(client->adapter, in ltc2978_get_id()
606 return -ENODEV; in ltc2978_get_id()
608 ret = i2c_smbus_read_block_data(client, PMBUS_MFR_ID, buf); in ltc2978_get_id()
612 return -ENODEV; in ltc2978_get_id()
614 ret = i2c_smbus_read_block_data(client, PMBUS_MFR_MODEL, buf); in ltc2978_get_id()
617 for (id = &ltc2978_id[0]; strlen(id->name); id++) { in ltc2978_get_id()
618 if (!strncasecmp(id->name, buf, strlen(id->name))) in ltc2978_get_id()
619 return (int)id->driver_data; in ltc2978_get_id()
621 return -ENODEV; in ltc2978_get_id()
676 dev_err(&client->dev, "Unsupported chip ID 0x%x\n", chip_id); in ltc2978_get_id()
677 return -ENODEV; in ltc2978_get_id()
680 static int ltc2978_probe(struct i2c_client *client) in ltc2978_probe() argument
685 const struct i2c_device_id *id; in ltc2978_probe() local
687 if (!i2c_check_functionality(client->adapter, in ltc2978_probe()
689 return -ENODEV; in ltc2978_probe()
691 data = devm_kzalloc(&client->dev, sizeof(struct ltc2978_data), in ltc2978_probe()
694 return -ENOMEM; in ltc2978_probe()
696 chip_id = ltc2978_get_id(client); in ltc2978_probe()
700 data->id = chip_id; in ltc2978_probe()
701 id = i2c_match_id(ltc2978_id, client); in ltc2978_probe()
702 if (data->id != id->driver_data) in ltc2978_probe()
703 dev_warn(&client->dev, in ltc2978_probe()
705 id->name, in ltc2978_probe()
706 (int) id->driver_data, in ltc2978_probe()
709 info = &data->info; in ltc2978_probe()
710 info->write_word_data = ltc2978_write_word_data; in ltc2978_probe()
711 info->write_byte = ltc_write_byte; in ltc2978_probe()
712 info->write_byte_data = ltc_write_byte_data; in ltc2978_probe()
713 info->read_word_data = ltc_read_word_data; in ltc2978_probe()
714 info->read_byte_data = ltc_read_byte_data; in ltc2978_probe()
716 data->vin_min = 0x7bff; in ltc2978_probe()
717 data->vin_max = 0x7c00; in ltc2978_probe()
718 for (i = 0; i < ARRAY_SIZE(data->vout_min); i++) in ltc2978_probe()
719 data->vout_min[i] = 0xffff; in ltc2978_probe()
720 for (i = 0; i < ARRAY_SIZE(data->iout_min); i++) in ltc2978_probe()
721 data->iout_min[i] = 0xfbff; in ltc2978_probe()
722 for (i = 0; i < ARRAY_SIZE(data->iout_max); i++) in ltc2978_probe()
723 data->iout_max[i] = 0x7c00; in ltc2978_probe()
724 for (i = 0; i < ARRAY_SIZE(data->temp_min); i++) in ltc2978_probe()
725 data->temp_min[i] = 0x7bff; in ltc2978_probe()
726 for (i = 0; i < ARRAY_SIZE(data->temp_max); i++) in ltc2978_probe()
727 data->temp_max[i] = 0x7c00; in ltc2978_probe()
728 data->temp2_max = 0x7c00; in ltc2978_probe()
730 switch (data->id) { in ltc2978_probe()
732 info->read_word_data = ltc2975_read_word_data; in ltc2978_probe()
733 info->pages = LTC2972_NUM_PAGES; in ltc2978_probe()
734 info->func[0] = PMBUS_HAVE_IIN | PMBUS_HAVE_PIN in ltc2978_probe()
737 for (i = 0; i < info->pages; i++) { in ltc2978_probe()
738 info->func[i] |= PMBUS_HAVE_VOUT in ltc2978_probe()
745 info->read_word_data = ltc2974_read_word_data; in ltc2978_probe()
746 info->pages = LTC2974_NUM_PAGES; in ltc2978_probe()
747 info->func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT in ltc2978_probe()
749 for (i = 0; i < info->pages; i++) { in ltc2978_probe()
750 info->func[i] |= PMBUS_HAVE_VOUT in ltc2978_probe()
757 info->read_word_data = ltc2975_read_word_data; in ltc2978_probe()
758 info->pages = LTC2974_NUM_PAGES; in ltc2978_probe()
759 info->func[0] = PMBUS_HAVE_IIN | PMBUS_HAVE_PIN in ltc2978_probe()
762 for (i = 0; i < info->pages; i++) { in ltc2978_probe()
763 info->func[i] |= PMBUS_HAVE_VOUT in ltc2978_probe()
775 info->read_word_data = ltc2978_read_word_data; in ltc2978_probe()
776 info->pages = LTC2978_NUM_PAGES; in ltc2978_probe()
777 info->func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT in ltc2978_probe()
781 info->func[i] = PMBUS_HAVE_VOUT in ltc2978_probe()
791 data->features |= FEAT_CLEAR_PEAKS | FEAT_NEEDS_POLLING; in ltc2978_probe()
792 info->read_word_data = ltc3880_read_word_data; in ltc2978_probe()
793 info->pages = LTC3880_NUM_PAGES; in ltc2978_probe()
794 info->func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_IIN in ltc2978_probe()
800 info->func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT in ltc2978_probe()
806 data->features |= FEAT_CLEAR_PEAKS | FEAT_NEEDS_POLLING; in ltc2978_probe()
807 info->read_word_data = ltc3880_read_word_data; in ltc2978_probe()
808 info->pages = LTC3880_NUM_PAGES; in ltc2978_probe()
809 info->func[0] = PMBUS_HAVE_VIN in ltc2978_probe()
815 info->func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT in ltc2978_probe()
821 data->features |= FEAT_CLEAR_PEAKS | FEAT_NEEDS_POLLING; in ltc2978_probe()
822 info->read_word_data = ltc3883_read_word_data; in ltc2978_probe()
823 info->pages = LTC3883_NUM_PAGES; in ltc2978_probe()
824 info->func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_IIN in ltc2978_probe()
839 data->features |= FEAT_CLEAR_PEAKS | FEAT_NEEDS_POLLING; in ltc2978_probe()
840 info->read_word_data = ltc3883_read_word_data; in ltc2978_probe()
841 info->pages = LTC3880_NUM_PAGES; in ltc2978_probe()
842 info->func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_IIN in ltc2978_probe()
848 info->func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT in ltc2978_probe()
854 return -ENODEV; in ltc2978_probe()
858 info->num_regulators = info->pages; in ltc2978_probe()
859 switch (data->id) { in ltc2978_probe()
868 info->reg_desc = ltc2978_reg_desc; in ltc2978_probe()
869 if (info->num_regulators > ARRAY_SIZE(ltc2978_reg_desc)) { in ltc2978_probe()
870 dev_warn(&client->dev, "num_regulators too large!"); in ltc2978_probe()
871 info->num_regulators = ARRAY_SIZE(ltc2978_reg_desc); in ltc2978_probe()
875 info->reg_desc = ltc2978_reg_desc_default; in ltc2978_probe()
876 if (info->num_regulators > ARRAY_SIZE(ltc2978_reg_desc_default)) { in ltc2978_probe()
877 dev_warn(&client->dev, "num_regulators too large!"); in ltc2978_probe()
878 info->num_regulators = in ltc2978_probe()
885 return pmbus_do_probe(client, info); in ltc2978_probe()