arch/mips/rb532/gpio.c
Source file repositories/reference/linux-study-clean/arch/mips/rb532/gpio.c
File Facts
- System
- Linux kernel
- Corpus path
arch/mips/rb532/gpio.c- Extension
.c- Size
- 5736 bytes
- Lines
- 221
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/init.hlinux/types.hlinux/export.hlinux/spinlock.hlinux/platform_device.hlinux/gpio/driver.hasm/mach-rc32434/rb.hasm/mach-rc32434/gpio.h
Detected Declarations
struct rb532_gpio_chipfunction rb532_set_bitfunction rb532_get_bitfunction rb532_gpio_getfunction rb532_gpio_setfunction rb532_gpio_direction_inputfunction rb532_gpio_direction_outputfunction rb532_gpio_to_irqfunction rb532_gpio_set_ilevelfunction rb532_gpio_set_istatfunction rb532_gpio_set_funcfunction rb532_gpio_probefunction rb532_gpio_initexport rb532_gpio_set_ilevelexport rb532_gpio_set_istatexport rb532_gpio_set_func
Annotated Snippet
struct rb532_gpio_chip {
struct gpio_chip chip;
void __iomem *regbase;
};
/* rb532_set_bit - sanely set a bit
*
* bitval: new value for the bit
* offset: bit index in the 4 byte address range
* ioaddr: 4 byte aligned address being altered
*/
static inline void rb532_set_bit(unsigned bitval,
unsigned offset, void __iomem *ioaddr)
{
unsigned long flags;
u32 val;
local_irq_save(flags);
val = readl(ioaddr);
val &= ~(!bitval << offset); /* unset bit if bitval == 0 */
val |= (!!bitval << offset); /* set bit if bitval == 1 */
writel(val, ioaddr);
local_irq_restore(flags);
}
/* rb532_get_bit - read a bit
*
* returns the boolean state of the bit, which may be > 1
*/
static inline int rb532_get_bit(unsigned offset, void __iomem *ioaddr)
{
return readl(ioaddr) & (1 << offset);
}
/*
* Return GPIO level */
static int rb532_gpio_get(struct gpio_chip *chip, unsigned offset)
{
struct rb532_gpio_chip *gpch;
gpch = gpiochip_get_data(chip);
return !!rb532_get_bit(offset, gpch->regbase + GPIOD);
}
/*
* Set output GPIO level
*/
static int rb532_gpio_set(struct gpio_chip *chip, unsigned int offset,
int value)
{
struct rb532_gpio_chip *gpch;
gpch = gpiochip_get_data(chip);
rb532_set_bit(value, offset, gpch->regbase + GPIOD);
return 0;
}
/*
* Set GPIO direction to input
*/
static int rb532_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
{
struct rb532_gpio_chip *gpch;
gpch = gpiochip_get_data(chip);
/* disable alternate function in case it's set */
rb532_set_bit(0, offset, gpch->regbase + GPIOFUNC);
rb532_set_bit(0, offset, gpch->regbase + GPIOCFG);
return 0;
}
/*
* Set GPIO direction to output
*/
static int rb532_gpio_direction_output(struct gpio_chip *chip,
unsigned offset, int value)
{
struct rb532_gpio_chip *gpch;
gpch = gpiochip_get_data(chip);
/* disable alternate function in case it's set */
rb532_set_bit(0, offset, gpch->regbase + GPIOFUNC);
/* set the initial output value */
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/init.h`, `linux/types.h`, `linux/export.h`, `linux/spinlock.h`, `linux/platform_device.h`, `linux/gpio/driver.h`, `asm/mach-rc32434/rb.h`.
- Detected declarations: `struct rb532_gpio_chip`, `function rb532_set_bit`, `function rb532_get_bit`, `function rb532_gpio_get`, `function rb532_gpio_set`, `function rb532_gpio_direction_input`, `function rb532_gpio_direction_output`, `function rb532_gpio_to_irq`, `function rb532_gpio_set_ilevel`, `function rb532_gpio_set_istat`.
- Atlas domain: Architecture Layer / arch/mips.
- Implementation status: integration 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.