1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Driver for MPS MPQ8785 Step-Down Converter
7 #include <linux/module.h>
8 #include <linux/of_device.h>
11 static int mpq8785_identify(struct i2c_client
*client
,
12 struct pmbus_driver_info
*info
)
16 vout_mode
= pmbus_read_byte_data(client
, 0, PMBUS_VOUT_MODE
);
17 if (vout_mode
< 0 || vout_mode
== 0xff)
18 return vout_mode
< 0 ? vout_mode
: -ENODEV
;
19 switch (vout_mode
>> 5) {
21 info
->format
[PSC_VOLTAGE_OUT
] = linear
;
25 info
->format
[PSC_VOLTAGE_OUT
] = direct
;
26 info
->m
[PSC_VOLTAGE_OUT
] = 64;
27 info
->b
[PSC_VOLTAGE_OUT
] = 0;
28 info
->R
[PSC_VOLTAGE_OUT
] = 1;
37 static struct pmbus_driver_info mpq8785_info
= {
39 .format
[PSC_VOLTAGE_IN
] = direct
,
40 .format
[PSC_CURRENT_OUT
] = direct
,
41 .format
[PSC_TEMPERATURE
] = direct
,
42 .m
[PSC_VOLTAGE_IN
] = 4,
43 .b
[PSC_VOLTAGE_IN
] = 0,
44 .R
[PSC_VOLTAGE_IN
] = 1,
45 .m
[PSC_CURRENT_OUT
] = 16,
46 .b
[PSC_CURRENT_OUT
] = 0,
47 .R
[PSC_CURRENT_OUT
] = 0,
48 .m
[PSC_TEMPERATURE
] = 1,
49 .b
[PSC_TEMPERATURE
] = 0,
50 .R
[PSC_TEMPERATURE
] = 0,
52 PMBUS_HAVE_VIN
| PMBUS_HAVE_STATUS_INPUT
|
53 PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
|
54 PMBUS_HAVE_IOUT
| PMBUS_HAVE_STATUS_IOUT
|
55 PMBUS_HAVE_TEMP
| PMBUS_HAVE_STATUS_TEMP
,
56 .identify
= mpq8785_identify
,
59 static int mpq8785_probe(struct i2c_client
*client
)
61 return pmbus_do_probe(client
, &mpq8785_info
);
64 static const struct i2c_device_id mpq8785_id
[] = {
68 MODULE_DEVICE_TABLE(i2c
, mpq8785_id
);
70 static const struct of_device_id __maybe_unused mpq8785_of_match
[] = {
71 { .compatible
= "mps,mpq8785" },
74 MODULE_DEVICE_TABLE(of
, mpq8785_of_match
);
76 static struct i2c_driver mpq8785_driver
= {
79 .of_match_table
= of_match_ptr(mpq8785_of_match
),
81 .probe
= mpq8785_probe
,
82 .id_table
= mpq8785_id
,
85 module_i2c_driver(mpq8785_driver
);
87 MODULE_AUTHOR("Charles Hsu <ythsu0511@gmail.com>");
88 MODULE_DESCRIPTION("PMBus driver for MPS MPQ8785");
89 MODULE_LICENSE("GPL");
90 MODULE_IMPORT_NS("PMBUS");