arch/arm/mach-pxa/mfp-pxa2xx.c
Source file repositories/reference/linux-study-clean/arch/arm/mach-pxa/mfp-pxa2xx.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arm/mach-pxa/mfp-pxa2xx.c- Extension
.c- Size
- 10013 bytes
- Lines
- 439
- Domain
- Architecture Layer
- Bucket
- arch/arm
- 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/gpio.hlinux/gpio-pxa.hlinux/module.hlinux/kernel.hlinux/init.hlinux/io.hlinux/syscore_ops.hlinux/soc/pxa/cpu.hpxa2xx-regs.hmfp-pxa2xx.hmfp-pxa27x.hgeneric.h
Detected Declarations
struct gpio_descfunction __mfp_config_gpiofunction __mfp_validatefunction pxa2xx_mfp_configfunction pxa2xx_mfp_set_lpmfunction gpio_set_wakefunction pxa25x_mfp_initfunction pxa25x_mfp_initfunction keypad_set_wakefunction pxa27x_mfp_initfunction pxa27x_mfp_initfunction pxa2xx_mfp_suspendfunction pxa2xx_mfp_resumefunction pxa2xx_mfp_init
Annotated Snippet
struct gpio_desc {
unsigned valid : 1;
unsigned can_wakeup : 1;
unsigned keypad_gpio : 1;
unsigned dir_inverted : 1;
unsigned int mask; /* bit mask in PWER or PKWR */
unsigned int mux_mask; /* bit mask of muxed gpio bits, 0 if no mux */
unsigned long config;
};
static struct gpio_desc gpio_desc[MFP_PIN_GPIO127 + 1];
static unsigned long gpdr_lpm[4];
static int __mfp_config_gpio(unsigned gpio, unsigned long c)
{
unsigned long gafr, mask = GPIO_bit(gpio);
int bank = gpio_to_bank(gpio);
int uorl = !!(gpio & 0x10); /* GAFRx_U or GAFRx_L ? */
int shft = (gpio & 0xf) << 1;
int fn = MFP_AF(c);
int is_out = (c & MFP_DIR_OUT) ? 1 : 0;
if (fn > 3)
return -EINVAL;
/* alternate function and direction at run-time */
gafr = (uorl == 0) ? GAFR_L(bank) : GAFR_U(bank);
gafr = (gafr & ~(0x3 << shft)) | (fn << shft);
if (uorl == 0)
GAFR_L(bank) = gafr;
else
GAFR_U(bank) = gafr;
if (is_out ^ gpio_desc[gpio].dir_inverted)
GPDR(gpio) |= mask;
else
GPDR(gpio) &= ~mask;
/* alternate function and direction at low power mode */
switch (c & MFP_LPM_STATE_MASK) {
case MFP_LPM_DRIVE_HIGH:
PGSR(bank) |= mask;
is_out = 1;
break;
case MFP_LPM_DRIVE_LOW:
PGSR(bank) &= ~mask;
is_out = 1;
break;
case MFP_LPM_INPUT:
case MFP_LPM_DEFAULT:
break;
default:
/* warning and fall through, treat as MFP_LPM_DEFAULT */
pr_warn("%s: GPIO%d: unsupported low power mode\n",
__func__, gpio);
break;
}
if (is_out ^ gpio_desc[gpio].dir_inverted)
gpdr_lpm[bank] |= mask;
else
gpdr_lpm[bank] &= ~mask;
/* give early warning if MFP_LPM_CAN_WAKEUP is set on the
* configurations of those pins not able to wakeup
*/
if ((c & MFP_LPM_CAN_WAKEUP) && !gpio_desc[gpio].can_wakeup) {
pr_warn("%s: GPIO%d unable to wakeup\n", __func__, gpio);
return -EINVAL;
}
if ((c & MFP_LPM_CAN_WAKEUP) && is_out) {
pr_warn("%s: output GPIO%d unable to wakeup\n", __func__, gpio);
return -EINVAL;
}
return 0;
}
static inline int __mfp_validate(int mfp)
{
int gpio = mfp_to_gpio(mfp);
if ((mfp > MFP_PIN_GPIO127) || !gpio_desc[gpio].valid) {
pr_warn("%s: GPIO%d is invalid pin\n", __func__, gpio);
return -1;
}
Annotation
- Immediate include surface: `linux/gpio.h`, `linux/gpio-pxa.h`, `linux/module.h`, `linux/kernel.h`, `linux/init.h`, `linux/io.h`, `linux/syscore_ops.h`, `linux/soc/pxa/cpu.h`.
- Detected declarations: `struct gpio_desc`, `function __mfp_config_gpio`, `function __mfp_validate`, `function pxa2xx_mfp_config`, `function pxa2xx_mfp_set_lpm`, `function gpio_set_wake`, `function pxa25x_mfp_init`, `function pxa25x_mfp_init`, `function keypad_set_wake`, `function pxa27x_mfp_init`.
- Atlas domain: Architecture Layer / arch/arm.
- 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.