drivers/hwmon/pmbus/xdp720.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/pmbus/xdp720.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/pmbus/xdp720.c- Extension
.c- Size
- 4500 bytes
- Lines
- 161
- Domain
- Driver Families
- Bucket
- drivers/hwmon
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/i2c.hlinux/module.hlinux/init.hlinux/kernel.hlinux/of_device.hlinux/bitops.hlinux/math64.hlinux/property.hlinux/regulator/consumer.hpmbus.h
Detected Declarations
struct xdp720_dataenum xdp720_chip_idfunction xdp720_probe
Annotated Snippet
struct xdp720_data {
enum xdp720_chip_id id;
struct pmbus_driver_info info;
};
static const struct pmbus_driver_info xdp720_info = {
.pages = 1,
.format[PSC_VOLTAGE_IN] = direct,
.format[PSC_VOLTAGE_OUT] = direct,
.format[PSC_CURRENT_OUT] = direct,
.format[PSC_POWER] = direct,
.format[PSC_TEMPERATURE] = direct,
.m[PSC_VOLTAGE_IN] = 4653,
.b[PSC_VOLTAGE_IN] = 0,
.R[PSC_VOLTAGE_IN] = -2,
.m[PSC_VOLTAGE_OUT] = 4653,
.b[PSC_VOLTAGE_OUT] = 0,
.R[PSC_VOLTAGE_OUT] = -2,
/*
* Current and Power measurement depends on the RIMON (kOhm) and
* GIMON(microA/A) values.
*/
.m[PSC_CURRENT_OUT] = 24668,
.b[PSC_CURRENT_OUT] = 0,
.R[PSC_CURRENT_OUT] = -4,
.m[PSC_POWER] = 4486,
.b[PSC_POWER] = 0,
.R[PSC_POWER] = -1,
.m[PSC_TEMPERATURE] = 54,
.b[PSC_TEMPERATURE] = 22521,
.R[PSC_TEMPERATURE] = -1,
.func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_PIN |
PMBUS_HAVE_TEMP | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_INPUT |
PMBUS_HAVE_STATUS_TEMP,
};
static int xdp720_probe(struct i2c_client *client)
{
struct xdp720_data *data;
int ret;
u32 rimon;
int gimon;
data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
data->id = (enum xdp720_chip_id)(uintptr_t)i2c_get_match_data(client);
data->info = xdp720_info;
ret = devm_regulator_get_enable(&client->dev, "vdd-vin");
if (ret)
return dev_err_probe(&client->dev, ret,
"failed to enable vdd-vin supply\n");
ret = i2c_smbus_read_word_data(client, XDP720_TELEMETRY_AVG);
if (ret < 0) {
dev_err(&client->dev, "Can't get TELEMETRY_AVG\n");
return ret;
}
/* Bit 10 of TELEMETRY_AVG selects the GIMON gain step in microA/A */
switch (data->id) {
case CHIP_XDP720:
gimon = (ret & XDP720_TELEMETRY_AVG_GIMON) ? 18200 : 9100;
dev_info(&client->dev, "Initialised XDP720 instance\n");
break;
case CHIP_XDP730:
gimon = (ret & XDP720_TELEMETRY_AVG_GIMON) ? 20000 : 10000;
dev_info(&client->dev, "Initialised XDP730 instance\n");
break;
default:
return -EINVAL;
}
if (device_property_read_u32(&client->dev,
"infineon,rimon-micro-ohms", &rimon))
rimon = XDP720_DEFAULT_RIMON; /* Default if not in FW */
if (rimon == 0)
return -EINVAL;
/* Adapt the current and power scale for each instance */
data->info.m[PSC_CURRENT_OUT] = DIV64_U64_ROUND_CLOSEST((u64)
data->info.m[PSC_CURRENT_OUT] * rimon * gimon,
1000000000000ULL);
data->info.m[PSC_POWER] = DIV64_U64_ROUND_CLOSEST((u64)
data->info.m[PSC_POWER] * rimon * gimon,
1000000000000000ULL);
Annotation
- Immediate include surface: `linux/i2c.h`, `linux/module.h`, `linux/init.h`, `linux/kernel.h`, `linux/of_device.h`, `linux/bitops.h`, `linux/math64.h`, `linux/property.h`.
- Detected declarations: `struct xdp720_data`, `enum xdp720_chip_id`, `function xdp720_probe`.
- Atlas domain: Driver Families / drivers/hwmon.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.