drivers/gpio/gpio-tps68470.c
Source file repositories/reference/linux-study-clean/drivers/gpio/gpio-tps68470.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpio/gpio-tps68470.c- Extension
.c- Size
- 5060 bytes
- Lines
- 185
- Domain
- Driver Families
- Bucket
- drivers/gpio
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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/gpio/driver.hlinux/mfd/tps68470.hlinux/module.hlinux/platform_device.hlinux/regmap.h
Detected Declarations
struct tps68470_gpio_datafunction tps68470_gpio_getfunction tps68470_gpio_get_directionfunction tps68470_gpio_setfunction tps68470_gpio_outputfunction tps68470_gpio_inputfunction tps68470_enable_i2c_daisy_chainfunction tps68470_gpio_probe
Annotated Snippet
struct tps68470_gpio_data {
struct regmap *tps68470_regmap;
struct gpio_chip gc;
};
static int tps68470_gpio_get(struct gpio_chip *gc, unsigned int offset)
{
struct tps68470_gpio_data *tps68470_gpio = gpiochip_get_data(gc);
struct regmap *regmap = tps68470_gpio->tps68470_regmap;
unsigned int reg = TPS68470_REG_GPDO;
int val, ret;
if (offset >= TPS68470_N_REGULAR_GPIO) {
offset -= TPS68470_N_REGULAR_GPIO;
reg = TPS68470_REG_SGPO;
}
ret = regmap_read(regmap, reg, &val);
if (ret) {
dev_err(tps68470_gpio->gc.parent, "reg 0x%x read failed\n",
TPS68470_REG_SGPO);
return ret;
}
return !!(val & BIT(offset));
}
static int tps68470_gpio_get_direction(struct gpio_chip *gc,
unsigned int offset)
{
struct tps68470_gpio_data *tps68470_gpio = gpiochip_get_data(gc);
struct regmap *regmap = tps68470_gpio->tps68470_regmap;
int val, ret;
/* rest are always outputs */
if (offset >= TPS68470_N_REGULAR_GPIO)
return GPIO_LINE_DIRECTION_OUT;
ret = regmap_read(regmap, TPS68470_GPIO_CTL_REG_A(offset), &val);
if (ret) {
dev_err(tps68470_gpio->gc.parent, "reg 0x%x read failed\n",
TPS68470_GPIO_CTL_REG_A(offset));
return ret;
}
val &= TPS68470_GPIO_MODE_MASK;
return val >= TPS68470_GPIO_MODE_OUT_CMOS ? GPIO_LINE_DIRECTION_OUT :
GPIO_LINE_DIRECTION_IN;
}
static int tps68470_gpio_set(struct gpio_chip *gc, unsigned int offset,
int value)
{
struct tps68470_gpio_data *tps68470_gpio = gpiochip_get_data(gc);
struct regmap *regmap = tps68470_gpio->tps68470_regmap;
unsigned int reg = TPS68470_REG_GPDO;
if (offset >= TPS68470_N_REGULAR_GPIO) {
reg = TPS68470_REG_SGPO;
offset -= TPS68470_N_REGULAR_GPIO;
}
return regmap_update_bits(regmap, reg, BIT(offset),
value ? BIT(offset) : 0);
}
static int tps68470_gpio_output(struct gpio_chip *gc, unsigned int offset,
int value)
{
struct tps68470_gpio_data *tps68470_gpio = gpiochip_get_data(gc);
struct regmap *regmap = tps68470_gpio->tps68470_regmap;
int ret;
/* Set the initial value */
ret = tps68470_gpio_set(gc, offset, value);
if (ret)
return ret;
/* rest are always outputs */
if (offset >= TPS68470_N_REGULAR_GPIO)
return 0;
return regmap_update_bits(regmap, TPS68470_GPIO_CTL_REG_A(offset),
TPS68470_GPIO_MODE_MASK,
TPS68470_GPIO_MODE_OUT_CMOS);
}
static int tps68470_gpio_input(struct gpio_chip *gc, unsigned int offset)
{
struct tps68470_gpio_data *tps68470_gpio = gpiochip_get_data(gc);
struct regmap *regmap = tps68470_gpio->tps68470_regmap;
Annotation
- Immediate include surface: `linux/gpio/driver.h`, `linux/mfd/tps68470.h`, `linux/module.h`, `linux/platform_device.h`, `linux/regmap.h`.
- Detected declarations: `struct tps68470_gpio_data`, `function tps68470_gpio_get`, `function tps68470_gpio_get_direction`, `function tps68470_gpio_set`, `function tps68470_gpio_output`, `function tps68470_gpio_input`, `function tps68470_enable_i2c_daisy_chain`, `function tps68470_gpio_probe`.
- Atlas domain: Driver Families / drivers/gpio.
- Implementation status: source 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.