18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0+ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Hardware monitoring driver for the Infineon IRPS5401M PMIC. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (c) 2019 SED Systems, a division of Calian Ltd. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * The device supports VOUT_PEAK, IOUT_PEAK, and TEMPERATURE_PEAK, however 88c2ecf20Sopenharmony_ci * this driver does not currently support them. 98c2ecf20Sopenharmony_ci */ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <linux/err.h> 128c2ecf20Sopenharmony_ci#include <linux/i2c.h> 138c2ecf20Sopenharmony_ci#include <linux/init.h> 148c2ecf20Sopenharmony_ci#include <linux/kernel.h> 158c2ecf20Sopenharmony_ci#include <linux/module.h> 168c2ecf20Sopenharmony_ci#include "pmbus.h" 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#define IRPS5401_SW_FUNC (PMBUS_HAVE_VIN | PMBUS_HAVE_IIN | \ 198c2ecf20Sopenharmony_ci PMBUS_HAVE_STATUS_INPUT | \ 208c2ecf20Sopenharmony_ci PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | \ 218c2ecf20Sopenharmony_ci PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | \ 228c2ecf20Sopenharmony_ci PMBUS_HAVE_PIN | PMBUS_HAVE_POUT | \ 238c2ecf20Sopenharmony_ci PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP) 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci#define IRPS5401_LDO_FUNC (PMBUS_HAVE_VIN | \ 268c2ecf20Sopenharmony_ci PMBUS_HAVE_STATUS_INPUT | \ 278c2ecf20Sopenharmony_ci PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | \ 288c2ecf20Sopenharmony_ci PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | \ 298c2ecf20Sopenharmony_ci PMBUS_HAVE_PIN | PMBUS_HAVE_POUT | \ 308c2ecf20Sopenharmony_ci PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP) 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_cistatic struct pmbus_driver_info irps5401_info = { 338c2ecf20Sopenharmony_ci .pages = 5, 348c2ecf20Sopenharmony_ci .func[0] = IRPS5401_SW_FUNC, 358c2ecf20Sopenharmony_ci .func[1] = IRPS5401_SW_FUNC, 368c2ecf20Sopenharmony_ci .func[2] = IRPS5401_SW_FUNC, 378c2ecf20Sopenharmony_ci .func[3] = IRPS5401_SW_FUNC, 388c2ecf20Sopenharmony_ci .func[4] = IRPS5401_LDO_FUNC, 398c2ecf20Sopenharmony_ci}; 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_cistatic int irps5401_probe(struct i2c_client *client) 428c2ecf20Sopenharmony_ci{ 438c2ecf20Sopenharmony_ci return pmbus_do_probe(client, &irps5401_info); 448c2ecf20Sopenharmony_ci} 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_cistatic const struct i2c_device_id irps5401_id[] = { 478c2ecf20Sopenharmony_ci {"irps5401", 0}, 488c2ecf20Sopenharmony_ci {} 498c2ecf20Sopenharmony_ci}; 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(i2c, irps5401_id); 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_cistatic struct i2c_driver irps5401_driver = { 548c2ecf20Sopenharmony_ci .driver = { 558c2ecf20Sopenharmony_ci .name = "irps5401", 568c2ecf20Sopenharmony_ci }, 578c2ecf20Sopenharmony_ci .probe_new = irps5401_probe, 588c2ecf20Sopenharmony_ci .remove = pmbus_do_remove, 598c2ecf20Sopenharmony_ci .id_table = irps5401_id, 608c2ecf20Sopenharmony_ci}; 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_cimodule_i2c_driver(irps5401_driver); 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ciMODULE_AUTHOR("Robert Hancock"); 658c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("PMBus driver for Infineon IRPS5401"); 668c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL"); 67