drivers/mfd/khadas-mcu.c
Source file repositories/reference/linux-study-clean/drivers/mfd/khadas-mcu.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mfd/khadas-mcu.c- Extension
.c- Size
- 3629 bytes
- Lines
- 144
- 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.
- 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/bitfield.hlinux/i2c.hlinux/mfd/core.hlinux/mfd/khadas-mcu.hlinux/module.hlinux/regmap.h
Detected Declarations
function Copyrightfunction khadas_mcu_reg_writeablefunction khadas_mcu_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Driver for Khadas System control Microcontroller
*
* Copyright (C) 2020 BayLibre SAS
*
* Author(s): Neil Armstrong <narmstrong@baylibre.com>
*/
#include <linux/bitfield.h>
#include <linux/i2c.h>
#include <linux/mfd/core.h>
#include <linux/mfd/khadas-mcu.h>
#include <linux/module.h>
#include <linux/regmap.h>
static bool khadas_mcu_reg_volatile(struct device *dev, unsigned int reg)
{
if (reg >= KHADAS_MCU_USER_DATA_0_REG &&
reg < KHADAS_MCU_PWR_OFF_CMD_REG)
return true;
switch (reg) {
case KHADAS_MCU_PWR_OFF_CMD_REG:
case KHADAS_MCU_PASSWD_START_REG:
case KHADAS_MCU_CHECK_VEN_PASSWD_REG:
case KHADAS_MCU_CHECK_USER_PASSWD_REG:
case KHADAS_MCU_WOL_INIT_START_REG:
case KHADAS_MCU_CMD_FAN_STATUS_CTRL_REG:
return true;
default:
return false;
}
}
static bool khadas_mcu_reg_writeable(struct device *dev, unsigned int reg)
{
switch (reg) {
case KHADAS_MCU_PASSWD_VEN_0_REG:
case KHADAS_MCU_PASSWD_VEN_1_REG:
case KHADAS_MCU_PASSWD_VEN_2_REG:
case KHADAS_MCU_PASSWD_VEN_3_REG:
case KHADAS_MCU_PASSWD_VEN_4_REG:
case KHADAS_MCU_PASSWD_VEN_5_REG:
case KHADAS_MCU_MAC_0_REG:
case KHADAS_MCU_MAC_1_REG:
case KHADAS_MCU_MAC_2_REG:
case KHADAS_MCU_MAC_3_REG:
case KHADAS_MCU_MAC_4_REG:
case KHADAS_MCU_MAC_5_REG:
case KHADAS_MCU_USID_0_REG:
case KHADAS_MCU_USID_1_REG:
case KHADAS_MCU_USID_2_REG:
case KHADAS_MCU_USID_3_REG:
case KHADAS_MCU_USID_4_REG:
case KHADAS_MCU_USID_5_REG:
case KHADAS_MCU_VERSION_0_REG:
case KHADAS_MCU_VERSION_1_REG:
case KHADAS_MCU_DEVICE_NO_0_REG:
case KHADAS_MCU_DEVICE_NO_1_REG:
case KHADAS_MCU_FACTORY_TEST_REG:
case KHADAS_MCU_SHUTDOWN_NORMAL_STATUS_REG:
return false;
default:
return true;
}
}
static const struct regmap_config khadas_mcu_regmap_config = {
.reg_bits = 8,
.reg_stride = 1,
.val_bits = 8,
.max_register = KHADAS_MCU_CMD_FAN_STATUS_CTRL_REG,
.volatile_reg = khadas_mcu_reg_volatile,
.writeable_reg = khadas_mcu_reg_writeable,
.cache_type = REGCACHE_MAPLE,
};
static struct mfd_cell khadas_mcu_fan_cells[] = {
/* VIM1/2 Rev13+ and VIM3 only */
{ .name = "khadas-mcu-fan-ctrl", },
};
static struct mfd_cell khadas_mcu_cells[] = {
{ .name = "khadas-mcu-user-mem", },
};
static int khadas_mcu_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct khadas_mcu *ddata;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/i2c.h`, `linux/mfd/core.h`, `linux/mfd/khadas-mcu.h`, `linux/module.h`, `linux/regmap.h`.
- Detected declarations: `function Copyright`, `function khadas_mcu_reg_writeable`, `function khadas_mcu_probe`.
- Atlas domain: Driver Families / drivers/mfd.
- 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.