arch/mips/pic32/pic32mzda/config.c
Source file repositories/reference/linux-study-clean/arch/mips/pic32/pic32mzda/config.c
File Facts
- System
- Linux kernel
- Corpus path
arch/mips/pic32/pic32mzda/config.c- Extension
.c- Size
- 2646 bytes
- Lines
- 118
- Domain
- Architecture Layer
- Bucket
- arch/mips
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
Dependency Surface
linux/init.hlinux/io.hlinux/platform_data/pic32.hlinux/spinlock.hpic32mzda.h
Detected Declarations
function pic32_conf_get_reg_fieldfunction pic32_conf_modify_atomicfunction pic32_enable_lcdfunction pic32_disable_lcdfunction pic32_set_lcd_modefunction pic32_set_sdhci_adma_fifo_thresholdfunction pic32_syskey_unlock_debugfunction pic32_get_device_idfunction pic32_get_device_versionfunction pic32_get_boot_statusfunction pic32_config_initexport pic32_get_boot_status
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Purna Chandra Mandal, purna.mandal@microchip.com
* Copyright (C) 2015 Microchip Technology Inc. All rights reserved.
*/
#include <linux/init.h>
#include <linux/io.h>
#include <linux/platform_data/pic32.h>
#include <linux/spinlock.h>
#include "pic32mzda.h"
#define PIC32_CFGCON 0x0000
#define PIC32_DEVID 0x0020
#define PIC32_SYSKEY 0x0030
#define PIC32_CFGEBIA 0x00c0
#define PIC32_CFGEBIC 0x00d0
#define PIC32_CFGCON2 0x00f0
#define PIC32_RCON 0x1240
static void __iomem *pic32_conf_base;
static DEFINE_SPINLOCK(config_lock);
static u32 pic32_reset_status;
static u32 pic32_conf_get_reg_field(u32 offset, u32 rshift, u32 mask)
{
u32 v;
v = readl(pic32_conf_base + offset);
v >>= rshift;
v &= mask;
return v;
}
static u32 pic32_conf_modify_atomic(u32 offset, u32 mask, u32 set)
{
u32 v;
unsigned long flags;
spin_lock_irqsave(&config_lock, flags);
v = readl(pic32_conf_base + offset);
v &= ~mask;
v |= (set & mask);
writel(v, pic32_conf_base + offset);
spin_unlock_irqrestore(&config_lock, flags);
return 0;
}
int pic32_enable_lcd(void)
{
return pic32_conf_modify_atomic(PIC32_CFGCON2, BIT(31), BIT(31));
}
int pic32_disable_lcd(void)
{
return pic32_conf_modify_atomic(PIC32_CFGCON2, BIT(31), 0);
}
int pic32_set_lcd_mode(int mode)
{
u32 mask = mode ? BIT(30) : 0;
return pic32_conf_modify_atomic(PIC32_CFGCON2, BIT(30), mask);
}
int pic32_set_sdhci_adma_fifo_threshold(u32 rthrsh, u32 wthrsh)
{
u32 clr, set;
clr = (0x3ff << 4) | (0x3ff << 16);
set = (rthrsh << 4) | (wthrsh << 16);
return pic32_conf_modify_atomic(PIC32_CFGCON2, clr, set);
}
void pic32_syskey_unlock_debug(const char *func, const ulong line)
{
void __iomem *syskey = pic32_conf_base + PIC32_SYSKEY;
pr_debug("%s: called from %s:%lu\n", __func__, func, line);
writel(0x00000000, syskey);
writel(0xAA996655, syskey);
writel(0x556699AA, syskey);
}
static u32 pic32_get_device_id(void)
{
return pic32_conf_get_reg_field(PIC32_DEVID, 0, 0x0fffffff);
}
Annotation
- Immediate include surface: `linux/init.h`, `linux/io.h`, `linux/platform_data/pic32.h`, `linux/spinlock.h`, `pic32mzda.h`.
- Detected declarations: `function pic32_conf_get_reg_field`, `function pic32_conf_modify_atomic`, `function pic32_enable_lcd`, `function pic32_disable_lcd`, `function pic32_set_lcd_mode`, `function pic32_set_sdhci_adma_fifo_threshold`, `function pic32_syskey_unlock_debug`, `function pic32_get_device_id`, `function pic32_get_device_version`, `function pic32_get_boot_status`.
- Atlas domain: Architecture Layer / arch/mips.
- Implementation status: integration 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.