sound/aoa/core/gpio-feature.c
Source file repositories/reference/linux-study-clean/sound/aoa/core/gpio-feature.c
File Facts
- System
- Linux kernel
- Corpus path
sound/aoa/core/gpio-feature.c- Extension
.c- Size
- 10861 bytes
- Lines
- 420
- Domain
- Driver Families
- Bucket
- sound/aoa
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/of_irq.hlinux/interrupt.hasm/pmac_feature.h../aoa.h
Detected Declarations
function get_irqfunction ftr_gpio_set_hw_resetfunction ftr_gpio_all_amps_offfunction ftr_gpio_all_amps_restorefunction ftr_handle_notifyfunction gpio_enable_dual_edgefunction ftr_gpio_initfunction ftr_gpio_exitfunction ftr_handle_notify_irqfunction ftr_set_notifyfunction ftr_get_detectexport ftr_gpio_methods
Annotated Snippet
while ((np = of_get_next_child(gpio, np))) {
audio_gpio = of_get_property(np, "audio-gpio", NULL);
if (!audio_gpio)
continue;
if (strcmp(audio_gpio, name) == 0)
break;
if (altname && (strcmp(audio_gpio, altname) == 0))
break;
}
of_node_put(gpio);
/* still not found, assume not there */
if (!np)
return NULL;
}
reg = of_get_property(np, "reg", NULL);
if (!reg) {
of_node_put(np);
return NULL;
}
*gpioptr = *reg;
/* this is a hack, usually the GPIOs 'reg' property
* should have the offset based from the GPIO space
* which is at 0x50, but apparently not always... */
if (*gpioptr < 0x50)
*gpioptr += 0x50;
reg = of_get_property(np, "audio-gpio-active-state", NULL);
if (!reg)
/* Apple seems to default to 1, but
* that doesn't seem right at least on most
* machines. So until proven that the opposite
* is necessary, we default to 0
* (which, incidentally, snd-powermac also does...) */
*gpioactiveptr = 0;
else
*gpioactiveptr = *reg;
return np;
}
static void get_irq(struct device_node * np, int *irqptr)
{
if (np)
*irqptr = irq_of_parse_and_map(np, 0);
else
*irqptr = 0;
}
/* 0x4 is outenable, 0x1 is out, thus 4 or 5 */
#define SWITCH_GPIO(name, v, on) \
(((v)&~1) | ((on)? \
(name##_gpio_activestate==0?4:5): \
(name##_gpio_activestate==0?5:4)))
#define FTR_GPIO(name, bit) \
static void ftr_gpio_set_##name(struct gpio_runtime *rt, int on)\
{ \
int v; \
\
if (unlikely(!rt)) return; \
\
if (name##_mute_gpio < 0) \
return; \
\
v = pmac_call_feature(PMAC_FTR_READ_GPIO, NULL, \
name##_mute_gpio, \
0); \
\
/* muted = !on... */ \
v = SWITCH_GPIO(name##_mute, v, !on); \
\
pmac_call_feature(PMAC_FTR_WRITE_GPIO, NULL, \
name##_mute_gpio, v); \
\
rt->implementation_private &= ~(1<<bit); \
rt->implementation_private |= (!!on << bit); \
} \
static int ftr_gpio_get_##name(struct gpio_runtime *rt) \
{ \
if (unlikely(!rt)) return 0; \
return (rt->implementation_private>>bit)&1; \
}
FTR_GPIO(headphone, 0);
FTR_GPIO(amp, 1);
FTR_GPIO(lineout, 2);
FTR_GPIO(master, 3);
Annotation
- Immediate include surface: `linux/of_irq.h`, `linux/interrupt.h`, `asm/pmac_feature.h`, `../aoa.h`.
- Detected declarations: `function get_irq`, `function ftr_gpio_set_hw_reset`, `function ftr_gpio_all_amps_off`, `function ftr_gpio_all_amps_restore`, `function ftr_handle_notify`, `function gpio_enable_dual_edge`, `function ftr_gpio_init`, `function ftr_gpio_exit`, `function ftr_handle_notify_irq`, `function ftr_set_notify`.
- Atlas domain: Driver Families / sound/aoa.
- Implementation status: integration implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.