drivers/mfd/stpmic1.c

Source file repositories/reference/linux-study-clean/drivers/mfd/stpmic1.c

File Facts

System
Linux kernel
Corpus path
drivers/mfd/stpmic1.c
Extension
.c
Size
7063 bytes
Lines
245
Domain
Driver Families
Bucket
drivers/mfd
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.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0
// Copyright (C) STMicroelectronics 2018
// Author: Pascal Paillet <p.paillet@st.com>

#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/mfd/core.h>
#include <linux/mfd/stpmic1.h>
#include <linux/module.h>
#include <linux/reboot.h>
#include <linux/of.h>
#include <linux/of_irq.h>
#include <linux/of_platform.h>
#include <linux/pm_wakeirq.h>
#include <linux/regmap.h>

#include <dt-bindings/mfd/st,stpmic1.h>

#define STPMIC1_MAX_RETRIES 2

#define STPMIC1_MAIN_IRQ 0

static const struct regmap_range stpmic1_readable_ranges[] = {
	regmap_reg_range(TURN_ON_SR, VERSION_SR),
	regmap_reg_range(MAIN_CR, LDO6_STDBY_CR),
	regmap_reg_range(BST_SW_CR, BST_SW_CR),
	regmap_reg_range(INT_PENDING_R1, INT_PENDING_R4),
	regmap_reg_range(INT_CLEAR_R1, INT_CLEAR_R4),
	regmap_reg_range(INT_MASK_R1, INT_MASK_R4),
	regmap_reg_range(INT_SET_MASK_R1, INT_SET_MASK_R4),
	regmap_reg_range(INT_CLEAR_MASK_R1, INT_CLEAR_MASK_R4),
	regmap_reg_range(INT_SRC_R1, INT_SRC_R1),
};

static const struct regmap_range stpmic1_writeable_ranges[] = {
	regmap_reg_range(MAIN_CR, LDO6_STDBY_CR),
	regmap_reg_range(BST_SW_CR, BST_SW_CR),
	regmap_reg_range(INT_CLEAR_R1, INT_CLEAR_R4),
	regmap_reg_range(INT_SET_MASK_R1, INT_SET_MASK_R4),
	regmap_reg_range(INT_CLEAR_MASK_R1, INT_CLEAR_MASK_R4),
};

static const struct regmap_range stpmic1_volatile_ranges[] = {
	regmap_reg_range(TURN_ON_SR, VERSION_SR),
	regmap_reg_range(WCHDG_CR, WCHDG_CR),
	regmap_reg_range(INT_PENDING_R1, INT_PENDING_R4),
	regmap_reg_range(INT_SRC_R1, INT_SRC_R4),
};

static const struct regmap_access_table stpmic1_readable_table = {
	.yes_ranges = stpmic1_readable_ranges,
	.n_yes_ranges = ARRAY_SIZE(stpmic1_readable_ranges),
};

static const struct regmap_access_table stpmic1_writeable_table = {
	.yes_ranges = stpmic1_writeable_ranges,
	.n_yes_ranges = ARRAY_SIZE(stpmic1_writeable_ranges),
};

static const struct regmap_access_table stpmic1_volatile_table = {
	.yes_ranges = stpmic1_volatile_ranges,
	.n_yes_ranges = ARRAY_SIZE(stpmic1_volatile_ranges),
};

static const struct regmap_config stpmic1_regmap_config = {
	.reg_bits = 8,
	.val_bits = 8,
	.cache_type = REGCACHE_MAPLE,
	.max_register = PMIC_MAX_REGISTER_ADDRESS,
	.rd_table = &stpmic1_readable_table,
	.wr_table = &stpmic1_writeable_table,
	.volatile_table = &stpmic1_volatile_table,
};

static const struct regmap_irq stpmic1_irqs[] = {
	REGMAP_IRQ_REG(IT_PONKEY_F, 0, 0x01),
	REGMAP_IRQ_REG(IT_PONKEY_R, 0, 0x02),
	REGMAP_IRQ_REG(IT_WAKEUP_F, 0, 0x04),
	REGMAP_IRQ_REG(IT_WAKEUP_R, 0, 0x08),
	REGMAP_IRQ_REG(IT_VBUS_OTG_F, 0, 0x10),
	REGMAP_IRQ_REG(IT_VBUS_OTG_R, 0, 0x20),
	REGMAP_IRQ_REG(IT_SWOUT_F, 0, 0x40),
	REGMAP_IRQ_REG(IT_SWOUT_R, 0, 0x80),

	REGMAP_IRQ_REG(IT_CURLIM_BUCK1, 1, 0x01),
	REGMAP_IRQ_REG(IT_CURLIM_BUCK2, 1, 0x02),
	REGMAP_IRQ_REG(IT_CURLIM_BUCK3, 1, 0x04),
	REGMAP_IRQ_REG(IT_CURLIM_BUCK4, 1, 0x08),
	REGMAP_IRQ_REG(IT_OCP_OTG, 1, 0x10),
	REGMAP_IRQ_REG(IT_OCP_SWOUT, 1, 0x20),

Annotation

Implementation Notes