2019-04-12 13:37:56 -07:00
// SPDX-License-Identifier: GPL-2.0+
/*
* Hardware monitoring driver for Infineon IR38064
*
* Copyright ( c ) 2017 Google Inc
*
* VOUT_MODE is not supported by the device . The driver fakes VOUT linear16
* mode with exponent value - 8 as direct mode with m = 256 / b = 0 / R = 0.
*
* The device supports VOUT_PEAK , IOUT_PEAK , and TEMPERATURE_PEAK , however
* this driver does not currently support them .
*/
# include <linux/err.h>
# include <linux/i2c.h>
# include <linux/init.h>
# include <linux/kernel.h>
# include <linux/module.h>
2021-12-13 15:28:13 +01:00
# include <linux/of_device.h>
2021-12-13 15:28:14 +01:00
# include <linux/regulator/driver.h>
2019-04-12 13:37:56 -07:00
# include "pmbus.h"
2021-12-13 15:28:14 +01:00
# if IS_ENABLED(CONFIG_SENSORS_IR38064_REGULATOR)
static const struct regulator_desc ir38064_reg_desc [ ] = {
PMBUS_REGULATOR ( " vout " , 0 ) ,
} ;
# endif /* CONFIG_SENSORS_IR38064_REGULATOR */
2019-04-12 13:37:56 -07:00
static struct pmbus_driver_info ir38064_info = {
. pages = 1 ,
. format [ PSC_VOLTAGE_IN ] = linear ,
. format [ PSC_VOLTAGE_OUT ] = direct ,
. format [ PSC_CURRENT_OUT ] = linear ,
. format [ PSC_POWER ] = linear ,
. format [ PSC_TEMPERATURE ] = linear ,
. m [ PSC_VOLTAGE_OUT ] = 256 ,
. b [ PSC_VOLTAGE_OUT ] = 0 ,
. R [ PSC_VOLTAGE_OUT ] = 0 ,
. func [ 0 ] = PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT
| PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP
| PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
| PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT
| PMBUS_HAVE_POUT ,
2021-12-13 15:28:14 +01:00
# if IS_ENABLED(CONFIG_SENSORS_IR38064_REGULATOR)
. num_regulators = 1 ,
. reg_desc = ir38064_reg_desc ,
# endif
2019-04-12 13:37:56 -07:00
} ;
2020-08-08 23:00:04 +02:00
static int ir38064_probe ( struct i2c_client * client )
2019-04-12 13:37:56 -07:00
{
2020-08-08 23:00:04 +02:00
return pmbus_do_probe ( client , & ir38064_info ) ;
2019-04-12 13:37:56 -07:00
}
static const struct i2c_device_id ir38064_id [ ] = {
2021-12-13 15:28:12 +01:00
{ " ir38060 " , 0 } ,
2019-04-12 13:37:56 -07:00
{ " ir38064 " , 0 } ,
2021-12-13 15:28:12 +01:00
{ " ir38164 " , 0 } ,
{ " ir38263 " , 0 } ,
2019-04-12 13:37:56 -07:00
{ }
} ;
MODULE_DEVICE_TABLE ( i2c , ir38064_id ) ;
2022-01-18 07:53:19 -08:00
static const struct of_device_id __maybe_unused ir38064_of_match [ ] = {
2021-12-13 15:28:13 +01:00
{ . compatible = " infineon,ir38060 " } ,
{ . compatible = " infineon,ir38064 " } ,
{ . compatible = " infineon,ir38164 " } ,
{ . compatible = " infineon,ir38263 " } ,
{ }
} ;
MODULE_DEVICE_TABLE ( of , ir38064_of_match ) ;
2019-04-12 13:37:56 -07:00
/* This is the driver that will be inserted */
static struct i2c_driver ir38064_driver = {
. driver = {
. name = " ir38064 " ,
2021-12-13 15:28:13 +01:00
. of_match_table = of_match_ptr ( ir38064_of_match ) ,
2019-04-12 13:37:56 -07:00
} ,
2020-08-08 23:00:04 +02:00
. probe_new = ir38064_probe ,
2019-04-12 13:37:56 -07:00
. id_table = ir38064_id ,
} ;
module_i2c_driver ( ir38064_driver ) ;
MODULE_AUTHOR ( " Maxim Sloyko <maxims@google.com> " ) ;
2021-12-20 15:55:27 +00:00
MODULE_DESCRIPTION ( " PMBus driver for Infineon IR38064 and compatible chips " ) ;
2019-04-12 13:37:56 -07:00
MODULE_LICENSE ( " GPL " ) ;
2021-04-19 23:07:07 -07:00
MODULE_IMPORT_NS ( PMBUS ) ;