2024-03-21 16:21:43 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
/*
|
|
|
|
* Hardware monitoring driver for Analog Devices ADP1050
|
|
|
|
*
|
|
|
|
* Copyright (C) 2024 Analog Devices, Inc.
|
|
|
|
*/
|
|
|
|
#include <linux/bits.h>
|
|
|
|
#include <linux/i2c.h>
|
2024-03-25 14:41:56 +02:00
|
|
|
#include <linux/mod_devicetable.h>
|
2024-03-21 16:21:43 +02:00
|
|
|
#include <linux/module.h>
|
2024-03-25 14:41:56 +02:00
|
|
|
|
2024-03-21 16:21:43 +02:00
|
|
|
#include "pmbus.h"
|
|
|
|
|
2025-07-09 13:43:27 +08:00
|
|
|
#if IS_ENABLED(CONFIG_SENSORS_ADP1050_REGULATOR)
|
|
|
|
static const struct regulator_desc adp1050_reg_desc[] = {
|
|
|
|
PMBUS_REGULATOR_ONE("vout"),
|
|
|
|
};
|
|
|
|
#endif /* CONFIG_SENSORS_ADP1050_REGULATOR */
|
|
|
|
|
2024-03-21 16:21:43 +02:00
|
|
|
static struct pmbus_driver_info adp1050_info = {
|
|
|
|
.pages = 1,
|
|
|
|
.format[PSC_VOLTAGE_IN] = linear,
|
|
|
|
.format[PSC_VOLTAGE_OUT] = linear,
|
|
|
|
.format[PSC_CURRENT_IN] = linear,
|
|
|
|
.format[PSC_TEMPERATURE] = linear,
|
|
|
|
.func[0] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
|
|
|
|
| PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT
|
|
|
|
| PMBUS_HAVE_IIN | PMBUS_HAVE_TEMP
|
|
|
|
| PMBUS_HAVE_STATUS_TEMP,
|
|
|
|
};
|
|
|
|
|
2025-07-09 13:43:26 +08:00
|
|
|
static struct pmbus_driver_info adp1051_info = {
|
|
|
|
.pages = 1,
|
|
|
|
.format[PSC_VOLTAGE_IN] = linear,
|
|
|
|
.format[PSC_VOLTAGE_OUT] = linear,
|
|
|
|
.format[PSC_CURRENT_IN] = linear,
|
|
|
|
.format[PSC_TEMPERATURE] = linear,
|
|
|
|
.func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_IIN
|
|
|
|
| PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT
|
|
|
|
| PMBUS_HAVE_TEMP
|
|
|
|
| PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_STATUS_IOUT
|
|
|
|
| PMBUS_HAVE_STATUS_INPUT
|
|
|
|
| PMBUS_HAVE_STATUS_TEMP,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct pmbus_driver_info adp1055_info = {
|
|
|
|
.pages = 1,
|
|
|
|
.format[PSC_VOLTAGE_IN] = linear,
|
|
|
|
.format[PSC_VOLTAGE_OUT] = linear,
|
|
|
|
.format[PSC_CURRENT_IN] = linear,
|
|
|
|
.format[PSC_TEMPERATURE] = linear,
|
|
|
|
.func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_IIN
|
|
|
|
| PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT
|
|
|
|
| PMBUS_HAVE_TEMP2 | PMBUS_HAVE_TEMP3
|
|
|
|
| PMBUS_HAVE_POUT
|
|
|
|
| PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_STATUS_IOUT
|
|
|
|
| PMBUS_HAVE_STATUS_INPUT
|
|
|
|
| PMBUS_HAVE_STATUS_TEMP,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct pmbus_driver_info ltp8800_info = {
|
|
|
|
.pages = 1,
|
|
|
|
.format[PSC_VOLTAGE_IN] = linear,
|
|
|
|
.format[PSC_VOLTAGE_OUT] = linear,
|
|
|
|
.format[PSC_CURRENT_IN] = linear,
|
|
|
|
.format[PSC_TEMPERATURE] = linear,
|
|
|
|
.func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_IIN
|
|
|
|
| PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT
|
|
|
|
| PMBUS_HAVE_TEMP
|
|
|
|
| PMBUS_HAVE_POUT
|
|
|
|
| PMBUS_HAVE_STATUS_VOUT
|
|
|
|
| PMBUS_HAVE_STATUS_INPUT
|
|
|
|
| PMBUS_HAVE_STATUS_TEMP,
|
2025-07-09 13:43:27 +08:00
|
|
|
#if IS_ENABLED(CONFIG_SENSORS_ADP1050_REGULATOR)
|
|
|
|
.num_regulators = 1,
|
|
|
|
.reg_desc = adp1050_reg_desc,
|
|
|
|
#endif
|
2025-07-09 13:43:26 +08:00
|
|
|
};
|
|
|
|
|
2024-03-21 16:21:43 +02:00
|
|
|
static int adp1050_probe(struct i2c_client *client)
|
|
|
|
{
|
2025-07-09 13:43:26 +08:00
|
|
|
struct pmbus_driver_info *info;
|
|
|
|
|
|
|
|
info = (struct pmbus_driver_info *)i2c_get_match_data(client);
|
|
|
|
if (!info)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
return pmbus_do_probe(client, info);
|
2024-03-21 16:21:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct i2c_device_id adp1050_id[] = {
|
2025-07-09 13:43:26 +08:00
|
|
|
{ .name = "adp1050", .driver_data = (kernel_ulong_t)&adp1050_info },
|
|
|
|
{ .name = "adp1051", .driver_data = (kernel_ulong_t)&adp1051_info },
|
|
|
|
{ .name = "adp1055", .driver_data = (kernel_ulong_t)&adp1055_info },
|
|
|
|
{ .name = "ltp8800", .driver_data = (kernel_ulong_t)<p8800_info },
|
2024-03-21 16:21:43 +02:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(i2c, adp1050_id);
|
|
|
|
|
|
|
|
static const struct of_device_id adp1050_of_match[] = {
|
2025-07-09 13:43:26 +08:00
|
|
|
{ .compatible = "adi,adp1050", .data = &adp1050_info },
|
|
|
|
{ .compatible = "adi,adp1051", .data = &adp1051_info },
|
|
|
|
{ .compatible = "adi,adp1055", .data = &adp1055_info },
|
|
|
|
{ .compatible = "adi,ltp8800", .data = <p8800_info },
|
2024-03-21 16:21:43 +02:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(of, adp1050_of_match);
|
|
|
|
|
|
|
|
static struct i2c_driver adp1050_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "adp1050",
|
|
|
|
.of_match_table = adp1050_of_match,
|
|
|
|
},
|
|
|
|
.probe = adp1050_probe,
|
|
|
|
.id_table = adp1050_id,
|
|
|
|
};
|
|
|
|
module_i2c_driver(adp1050_driver);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Radu Sabau <radu.sabau@analog.com>");
|
|
|
|
MODULE_DESCRIPTION("Analog Devices ADP1050 HWMON PMBus Driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
module: Convert symbol namespace to string literal
Clean up the existing export namespace code along the same lines of
commit 33def8498fdd ("treewide: Convert macro and uses of __section(foo)
to __section("foo")") and for the same reason, it is not desired for the
namespace argument to be a macro expansion itself.
Scripted using
git grep -l -e MODULE_IMPORT_NS -e EXPORT_SYMBOL_NS | while read file;
do
awk -i inplace '
/^#define EXPORT_SYMBOL_NS/ {
gsub(/__stringify\(ns\)/, "ns");
print;
next;
}
/^#define MODULE_IMPORT_NS/ {
gsub(/__stringify\(ns\)/, "ns");
print;
next;
}
/MODULE_IMPORT_NS/ {
$0 = gensub(/MODULE_IMPORT_NS\(([^)]*)\)/, "MODULE_IMPORT_NS(\"\\1\")", "g");
}
/EXPORT_SYMBOL_NS/ {
if ($0 ~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+),/) {
if ($0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/ &&
$0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(\)/ &&
$0 !~ /^my/) {
getline line;
gsub(/[[:space:]]*\\$/, "");
gsub(/[[:space:]]/, "", line);
$0 = $0 " " line;
}
$0 = gensub(/(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/,
"\\1(\\2, \"\\3\")", "g");
}
}
{ print }' $file;
done
Requested-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://mail.google.com/mail/u/2/#inbox/FMfcgzQXKWgMmjdFwwdsfgxzKpVHWPlc
Acked-by: Greg KH <gregkh@linuxfoundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2024-12-02 15:59:47 +01:00
|
|
|
MODULE_IMPORT_NS("PMBUS");
|