drivers/soc/renesas/pwc-rzv2m.c
Source file repositories/reference/linux-study-clean/drivers/soc/renesas/pwc-rzv2m.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/soc/renesas/pwc-rzv2m.c- Extension
.c- Size
- 3492 bytes
- Lines
- 144
- Domain
- Driver Families
- Bucket
- drivers/soc
- 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/delay.hlinux/gpio/driver.hlinux/platform_device.hlinux/reboot.h
Detected Declarations
struct rzv2m_pwc_privfunction rzv2m_pwc_gpio_setfunction rzv2m_pwc_gpio_getfunction rzv2m_pwc_gpio_direction_outputfunction rzv2m_pwc_powerofffunction rzv2m_pwc_probe
Annotated Snippet
struct rzv2m_pwc_priv {
void __iomem *base;
struct device *dev;
struct gpio_chip gp;
DECLARE_BITMAP(ch_en_bits, 2);
};
static int rzv2m_pwc_gpio_set(struct gpio_chip *chip, unsigned int offset,
int value)
{
struct rzv2m_pwc_priv *priv = gpiochip_get_data(chip);
u32 reg;
/* BIT 16 enables write to BIT 0, and BIT 17 enables write to BIT 1 */
reg = BIT(offset + 16);
if (value)
reg |= BIT(offset);
writel(reg, priv->base + PWC_GPIO);
assign_bit(offset, priv->ch_en_bits, value);
return 0;
}
static int rzv2m_pwc_gpio_get(struct gpio_chip *chip, unsigned int offset)
{
struct rzv2m_pwc_priv *priv = gpiochip_get_data(chip);
return test_bit(offset, priv->ch_en_bits);
}
static int rzv2m_pwc_gpio_direction_output(struct gpio_chip *gc,
unsigned int nr, int value)
{
if (nr > 1)
return -EINVAL;
rzv2m_pwc_gpio_set(gc, nr, value);
return 0;
}
static const struct gpio_chip rzv2m_pwc_gc = {
.label = "gpio_rzv2m_pwc",
.owner = THIS_MODULE,
.get = rzv2m_pwc_gpio_get,
.set = rzv2m_pwc_gpio_set,
.direction_output = rzv2m_pwc_gpio_direction_output,
.can_sleep = false,
.ngpio = 2,
.base = -1,
};
static int rzv2m_pwc_poweroff(struct sys_off_data *data)
{
struct rzv2m_pwc_priv *priv = data->cb_data;
writel(PWC_PWCRST_RSTSOFTAX, priv->base + PWC_PWCRST);
writel(PWC_PWCCKEN_ENGCKMAIN, priv->base + PWC_PWCCKEN);
writel(PWC_PWCCTL_PWOFF, priv->base + PWC_PWCCTL);
mdelay(150);
dev_err(priv->dev, "Failed to power off the system");
return NOTIFY_DONE;
}
static int rzv2m_pwc_probe(struct platform_device *pdev)
{
struct rzv2m_pwc_priv *priv;
int ret;
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
priv->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(priv->base))
return PTR_ERR(priv->base);
/*
* The register used by this driver cannot be read, therefore set the
* outputs to their default values and initialize priv->ch_en_bits
* accordingly. BIT 16 enables write to BIT 0, BIT 17 enables write to
* BIT 1, and the default value of both BIT 0 and BIT 1 is 0.
*/
writel(BIT(17) | BIT(16), priv->base + PWC_GPIO);
bitmap_zero(priv->ch_en_bits, 2);
Annotation
- Immediate include surface: `linux/delay.h`, `linux/gpio/driver.h`, `linux/platform_device.h`, `linux/reboot.h`.
- Detected declarations: `struct rzv2m_pwc_priv`, `function rzv2m_pwc_gpio_set`, `function rzv2m_pwc_gpio_get`, `function rzv2m_pwc_gpio_direction_output`, `function rzv2m_pwc_poweroff`, `function rzv2m_pwc_probe`.
- Atlas domain: Driver Families / drivers/soc.
- 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.