arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
Source file repositories/reference/linux-study-clean/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c- Extension
.c- Size
- 4942 bytes
- Lines
- 231
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/kernel.hlinux/mod_devicetable.hlinux/module.hlinux/device.hlinux/mutex.hlinux/i2c.hlinux/gpio/driver.hlinux/slab.hlinux/sysfs.hlinux/kthread.hlinux/property.hlinux/reboot.hasm/machdep.h
Detected Declarations
struct mcufunction shutdown_thread_fnfunction show_statusfunction mcu_power_offfunction mcu_gpio_setfunction mcu_gpio_dir_outfunction mcu_gpiochip_addfunction mcu_gpiochip_removefunction mcu_probefunction mcu_remove
Annotated Snippet
struct mcu {
struct mutex lock;
struct i2c_client *client;
struct gpio_chip gc;
u8 reg_ctrl;
};
static struct mcu *glob_mcu;
struct task_struct *shutdown_thread;
static int shutdown_thread_fn(void *data)
{
int ret;
struct mcu *mcu = glob_mcu;
while (!kthread_should_stop()) {
ret = i2c_smbus_read_byte_data(mcu->client, MCU_REG_CTRL);
if (ret < 0)
pr_err("MCU status reg read failed.\n");
mcu->reg_ctrl = ret;
if (mcu->reg_ctrl & MCU_CTRL_BTN) {
i2c_smbus_write_byte_data(mcu->client, MCU_REG_CTRL,
mcu->reg_ctrl & ~MCU_CTRL_BTN);
ctrl_alt_del();
}
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(HZ);
}
return 0;
}
static ssize_t show_status(struct device *d,
struct device_attribute *attr, char *buf)
{
int ret;
struct mcu *mcu = glob_mcu;
ret = i2c_smbus_read_byte_data(mcu->client, MCU_REG_CTRL);
if (ret < 0)
return -ENODEV;
mcu->reg_ctrl = ret;
return sysfs_emit(buf, "%02x\n", ret);
}
static DEVICE_ATTR(status, 0444, show_status, NULL);
static void mcu_power_off(void)
{
struct mcu *mcu = glob_mcu;
pr_info("Sending power-off request to the MCU...\n");
mutex_lock(&mcu->lock);
i2c_smbus_write_byte_data(mcu->client, MCU_REG_CTRL,
mcu->reg_ctrl | MCU_CTRL_POFF);
mutex_unlock(&mcu->lock);
}
static int mcu_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
{
struct mcu *mcu = gpiochip_get_data(gc);
u8 bit = 1 << (4 + gpio);
int ret;
mutex_lock(&mcu->lock);
if (val)
mcu->reg_ctrl &= ~bit;
else
mcu->reg_ctrl |= bit;
ret = i2c_smbus_write_byte_data(mcu->client, MCU_REG_CTRL,
mcu->reg_ctrl);
mutex_unlock(&mcu->lock);
return ret;
}
static int mcu_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
{
return mcu_gpio_set(gc, gpio, val);
}
static int mcu_gpiochip_add(struct mcu *mcu)
{
struct device *dev = &mcu->client->dev;
struct gpio_chip *gc = &mcu->gc;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/device.h`, `linux/mutex.h`, `linux/i2c.h`, `linux/gpio/driver.h`, `linux/slab.h`.
- Detected declarations: `struct mcu`, `function shutdown_thread_fn`, `function show_status`, `function mcu_power_off`, `function mcu_gpio_set`, `function mcu_gpio_dir_out`, `function mcu_gpiochip_add`, `function mcu_gpiochip_remove`, `function mcu_probe`, `function mcu_remove`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.