drivers/hwmon/pmbus/tps25990.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/pmbus/tps25990.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/pmbus/tps25990.c- Extension
.c- Size
- 11344 bytes
- Lines
- 443
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/debugfs.hlinux/err.hlinux/hwmon-sysfs.hlinux/i2c.hlinux/init.hlinux/kernel.hlinux/module.hpmbus.h
Detected Declarations
function tps25990_set_mfunction tps25990_mfr_write_protect_setfunction tps25990_mfr_write_protect_getfunction tps25990_read_word_datafunction tps25990_write_word_datafunction tps25990_read_byte_datafunction tps25990_write_byte_datafunction tps25990_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
//
// Copyright (c) 2024 BayLibre, SAS.
// Author: Jerome Brunet <jbrunet@baylibre.com>
#include <linux/bitfield.h>
#include <linux/debugfs.h>
#include <linux/err.h>
#include <linux/hwmon-sysfs.h>
#include <linux/i2c.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include "pmbus.h"
#define TPS25990_READ_VAUX 0xd0
#define TPS25990_READ_VIN_MIN 0xd1
#define TPS25990_READ_VIN_PEAK 0xd2
#define TPS25990_READ_IIN_PEAK 0xd4
#define TPS25990_READ_PIN_PEAK 0xd5
#define TPS25990_READ_TEMP_AVG 0xd6
#define TPS25990_READ_TEMP_PEAK 0xd7
#define TPS25990_READ_VOUT_MIN 0xda
#define TPS25990_READ_VIN_AVG 0xdc
#define TPS25990_READ_VOUT_AVG 0xdd
#define TPS25990_READ_IIN_AVG 0xde
#define TPS25990_READ_PIN_AVG 0xdf
#define TPS25990_VIREF 0xe0
#define TPS25990_PK_MIN_AVG 0xea
#define PK_MIN_AVG_RST_PEAK BIT(7)
#define PK_MIN_AVG_RST_AVG BIT(6)
#define PK_MIN_AVG_RST_MIN BIT(5)
#define PK_MIN_AVG_AVG_CNT GENMASK(2, 0)
#define TPS25990_MFR_WRITE_PROTECT 0xf8
#define TPS25990_UNLOCKED BIT(7)
#define TPS25990_8B_SHIFT 2
#define TPS25990_VIN_OVF_NUM 525100
#define TPS25990_VIN_OVF_DIV 10163
#define TPS25990_VIN_OVF_OFF 155
#define TPS25990_IIN_OCF_NUM 953800
#define TPS25990_IIN_OCF_DIV 129278
#define TPS25990_IIN_OCF_OFF 157
#define PK_MIN_AVG_RST_MASK (PK_MIN_AVG_RST_PEAK | \
PK_MIN_AVG_RST_AVG | \
PK_MIN_AVG_RST_MIN)
/*
* Arbitrary default Rimon value: 1kOhm
* This correspond to an overcurrent limit of 55A, close to the specified limit
* of un-stacked TPS25990 and makes further calculation easier to setup in
* sensor.conf, if necessary
*/
#define TPS25990_DEFAULT_RIMON 1000000000
static void tps25990_set_m(int *m, u32 rimon)
{
u64 val = ((u64)*m) * rimon;
/* Make sure m fits the s32 type */
*m = DIV_ROUND_CLOSEST_ULL(val, 1000000);
}
static int tps25990_mfr_write_protect_set(struct i2c_client *client,
u8 protect)
{
u8 val;
switch (protect) {
case 0:
val = 0xa2;
break;
case PB_WP_ALL:
val = 0x0;
break;
default:
return -EINVAL;
}
return pmbus_write_byte_data(client, -1, TPS25990_MFR_WRITE_PROTECT,
val);
}
static int tps25990_mfr_write_protect_get(struct i2c_client *client)
{
int ret = pmbus_read_byte_data(client, -1, TPS25990_MFR_WRITE_PROTECT);
if (ret < 0)
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/debugfs.h`, `linux/err.h`, `linux/hwmon-sysfs.h`, `linux/i2c.h`, `linux/init.h`, `linux/kernel.h`, `linux/module.h`.
- Detected declarations: `function tps25990_set_m`, `function tps25990_mfr_write_protect_set`, `function tps25990_mfr_write_protect_get`, `function tps25990_read_word_data`, `function tps25990_write_word_data`, `function tps25990_read_byte_data`, `function tps25990_write_byte_data`, `function tps25990_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.