mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
To: Fenglin Wu <fenglin.wu@oss.qualcomm.com>,
	linux-arm-msm@vger.kernel.org,
	Bjorn Andersson <andersson@kernel.org>,
	Konrad Dybcio <konradybcio@kernel.org>,
	Abel Vesa <abelvesa@kernel.org>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: David Collins <david.collins@oss.qualcomm.com>,
	Subbaraman Narayanamurthy
	<subbaraman.narayanamurthy@oss.qualcomm.com>,
	Kamal Wadhwa <kamal.wadhwa@oss.qualcomm.com>,
	linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org
Subject: Re: [PATCH v3 1/3] soc: qcom: Add pmic-gio GIO framework driver
Date: Thu, 3 Dec 2026 13:54:54 +0100	[thread overview]
Message-ID: <33925458-dca5-4bd8-bd2d-0663cd18b11d@oss.qualcomm.com> (raw)
In-Reply-To: <20261118-gio-framework-rtc-driver-2026-10-12-v3-1-52d78a8f43ee@oss.qualcomm.com>

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@oss.qualcomm.com>
> ---

[...]

> +#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

  reply	other threads:[~2026-12-03 12:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19  6:55 [PATCH v3 0/3] soc: qcom: Add Qualcomm PMIC GIO framework and RTC driver using it Fenglin Wu
2026-11-19  6:55 ` [PATCH v3 1/3] soc: qcom: Add pmic-gio GIO framework driver Fenglin Wu
2026-12-03 12:54   ` Konrad Dybcio [this message]
2026-12-03 12:56   ` Konrad Dybcio
2026-12-03 12:57   ` Konrad Dybcio
2026-11-19  6:55 ` [PATCH v3 2/3] soc: qcom: pmic_glink: Add GIO pmic_glink instance Fenglin Wu
2026-12-03 12:59   ` Konrad Dybcio
2026-12-03 13:01   ` Konrad Dybcio
2026-11-19  6:55 ` [PATCH v3 3/3] rtc: Add Qualcomm GIO RTC driver Fenglin Wu
2026-12-03 13:07   ` Konrad Dybcio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=33925458-dca5-4bd8-bd2d-0663cd18b11d@oss.qualcomm.com \
    --to=konrad.dybcio@oss.qualcomm.com \
    --cc=abelvesa@kernel.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=andersson@kernel.org \
    --cc=david.collins@oss.qualcomm.com \
    --cc=fenglin.wu@oss.qualcomm.com \
    --cc=kamal.wadhwa@oss.qualcomm.com \
    --cc=konradybcio@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=subbaraman.narayanamurthy@oss.qualcomm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®