Re: [PATCH v3 1/3] soc: qcom: Add pmic-gio GIO framework driver
From: Konrad Dybcio
Date: Thu Dec 03 2026 - 07:55:16 EST
On 11/19/26 7:55 AM, Fenglin Wu wrote:
> Qualcomm SoCCP battery-management firmware on Glymur platform
> introduces a new interface which is called General I/O (GIO).
> It exposes functions through fixed-size register blocks grouped
> into virtual peripherals such as core, battery, USB-C, service,
> settings, debug, and OEM, etc. The data blocks must be accessed
> using block-aligned transactions. It also generates alert
> notifications which could be identified by a pair of peripheral
> and alert ID.
>
> Add a transport-agnostic PMIC GIO framework that validates register
> accesses against the common GIO register definitions, and exposes the
> firmware register space through regmap using transport-provided read
> and write operations. The framework tracks transport availability
> and notify consumers when its state changes, and route alerts through
> a virtual IRQ domain while retaining their payload data. It also
> provides a group of managed helpers for registering GIO transports,
> state notifiers, IRQ mappings, and auxiliary consumer devices required
> by the transport and the consumer drivers.
>
> Signed-off-by: Fenglin Wu <fenglin.wu@xxxxxxxxxxxxxxxx>
> ---
[...]
> +#include <linux/auxiliary_bus.h>
> +#include <linux/device.h>
Also need cleanup.h
[...]
> +static const struct pmic_gio_reg_block *pmic_gio_validate_access(unsigned int reg,
> + size_t len)
> +{
> + const struct pmic_gio_reg_block *block = pmic_gio_find_reg_block(reg);
> +
> + if (!block || !len)
> + return NULL;
> +
> + if (reg != block->base || len != block->size)
> + return NULL;
The reg != block->base check will never hit since _reg_block()
returning non-null already guarantees that
> +
> + return block;
> +}
> +
> +static bool pmic_gio_readable_reg(struct device *dev, unsigned int reg)
> +{
> + const struct pmic_gio_reg_block *block = pmic_gio_find_reg_block(reg);
> +
> + return block ? true : false;
> +}
This could be just `return !!pmic_gio_find_reg_block(reg);`
[...]
> +++ b/include/linux/soc/qcom/pmic_gio.h
> @@ -0,0 +1,153 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
> + */
> +#ifndef __SOC_QCOM_PMIC_GIO_H__
> +#define __SOC_QCOM_PMIC_GIO_H__
> +
> +#include <linux/auxiliary_bus.h>
> +#include <linux/err.h>
> +#include <linux/kconfig.h>
> +#include <linux/notifier.h>
> +#include <linux/types.h>
> +
> +/* Native access granularity of the GIO regmap: bytes per register. */
> +#define PMIC_GIO_REG_GRANULARITY 4
> +#define PMIC_GIO_ALERT_PAYLOAD_SIZE 16
> +
> +/* GIO peripherals id */
> +#define GIO_CORE_PERIPHERAL_ID 0x00
> +#define GIO_BATT_PERIPHERAL_ID 0x01
> +#define GIO_USBC_PERIPHERAL_ID 0x02
> +#define GIO_SVC_PERIPHERAL_ID 0x03
> +#define GIO_OEM_PERIPHERAL_ID 0x0C
nit: lowercase hex is preferred
> +
> +/* GIO Alert IDs in each peripherals */
> +#define GIO_ALERT_BATT_STATUS_CHANGE 0x80
> +#define GIO_ALERT_BATT_INFO_CHANGE 0x81
> +#define GIO_ALERT_BATT_MAINTENANCE_STATUS_CHANGE 0x82
> +#define GIO_ALERT_BATT_POWER_STATE_CHANGE 0x83
> +#define GIO_ALERT_BATT_POWER_SOURCE_INFO_CHANGE 0x90
> +
> +#define GIO_ALERT_USBC_UCSI_CCI 0x80
> +#define GIO_ALERT_USBC_PAN 0x40
> +
> +#define GIO_ALERT_SVC_POWER_OK_CHANGED 0x01
> +#define GIO_ALERT_SVC_SHUTDOWN 0x02
> +#define GIO_ALERT_SVC_RESET 0x03
> +
> +#define GIO_ALERT_OEM_OP_NOTIFY 0x80
> +
> +struct device;
> +struct regmap;
> +
> +struct pmic_gio_device;
Don't need these, we only have pointers to these, and the sizes of
pointers are always known, regardless of type
[...]
> +/* USBC */
> +#define GIO_USBC_IF_VERSION_ADDR 0x20000
> +#define GIO_USBC_IF_VERSION_SIZE 4
> +#define GIO_USBC_ALERT_STATUS_ADDR 0x20010
> +#define GIO_USBC_ALERT_STATUS_SIZE 4
> +#define GIO_USBC_LAST_ALERT_ADDR 0x20014
> +#define GIO_USBC_LAST_ALERT_SIZE 20
> +#define GIO_USBC_UCSI_VERSION_REG 0x20100
> +#define GIO_USBC_UCSI_VERSION_SIZE 4
> +#define GIO_USBC_UCSI_CCI_REG 0x20104
> +#define GIO_USBC_UCSI_CCI_SIZE 4
> +#define GIO_USBC_UCSI_CONTROL_REG 0x20108
> +#define GIO_USBC_UCSI_CONTROL_SIZE 8
> +#define GIO_USBC_UCSI_MESSAGE_IN_REG 0x20200
> +#define GIO_USBC_UCSI_MESSAGE_IN_SIZE 64
> +#define GIO_USBC_UCSI_MSGINX_REG 0x20240
> +#define GIO_USBC_UCSI_MSGINX_SIZE 192
> +#define GIO_USBC_UCSI_MESSAGE_OUT_REG 0x20300
> +#define GIO_USBC_UCSI_MESSAGE_OUT_SIZE 64
> +#define GIO_USBC_UCSI_MSGOUTX_ADDR 0x20340
> +#define GIO_USBC_UCSI_MSGOUTX_SIZE 192
> +#define GIO_USBC_UCSI_PAN_ADDR 0x20400
> +#define GIO_USBC_UCSI_PAN_SIZE 64
> +#define GIO_USBC_PAN_CMD_ADDR 0x20440
> +#define GIO_USBC_PAN_CMD_SIZE 0x08
Sizes should be dec
Konrad