From nobody Fri Dec 19 06:27:27 2025 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76AF925C6E7 for ; Mon, 24 Feb 2025 14:32:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.188.123 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740407533; cv=none; b=OQFg1s0iH8YSkFquH/irUrVfMIQC9IfAiO3J3RAnPE99tfvVCzQ0vgPb2yGalvzvtrxblEw7bb/PgAmugcUw4XnRUp3HCB6XIYBIvFsU2eZrj0r16mOV0tq8TN4we0FuDMZbk5eQbsDxIfEfdpgNSs8nzuzp87d04XC6gzTTPpU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740407533; c=relaxed/simple; bh=5z75klJulPBK3euVFo5jCw9QXY35/qZ4NCunDCR/9Jo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TAyPjtj7VoHvY6bLdssUxCO74MaLjUZ/43vRE2DB+Sk00t45CPCAyj+aJHl2RRrgNeqEesqXEtHsSRLQ1hf/4ztnoRFY3BEEM4t4s08Da/LPkjzFzoM8DX1SGsYUfRzf+MM9o3LudP1bcL/eiOZYG4e9aoiKsFOXxHh6kUvthLU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com; spf=pass smtp.mailfrom=canonical.com; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b=X5sk5TFm; arc=none smtp.client-ip=185.125.188.123 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canonical.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b="X5sk5TFm" Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 21FA43F869 for ; Mon, 24 Feb 2025 14:32:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1740407528; bh=VbN0B6Oenuw6+py3+N6wdefqtqSm9CuUWAW6b8DJ97M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X5sk5TFmTopWRUURxS3AisP1L4ZqBngZoeRafiP9zjRzKwMtLaRZvZN3WxkRkVuNV UpGE+LQ8DUuPA4nBPSno+/+ucCujOjI3US2Xs1l1F/buxiNPpTkvxrocEzAozPexbo 4xvr/RlNcPGIsEeIoIS8gYf+eEyMb2SFTgO37gARWjR0tg9IIXnD/mm7eeK/GvzAp6 vfQTrnEzQQatpHCAT5zmsQQ2P5U8JkXWs8btEp/rNseH1fUFNUMkYl9qHXcslCQCr9 jLGFHI8MygER0aQ3G8BEck26GKlBmyY06zGnvW6fScwZflsom0LVyrIljvt+tWmOkw +36A/b1dqrGsQ== Received: by mail-pl1-f199.google.com with SMTP id d9443c01a7336-220c86e46ebso72242195ad.0 for ; Mon, 24 Feb 2025 06:32:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740407527; x=1741012327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VbN0B6Oenuw6+py3+N6wdefqtqSm9CuUWAW6b8DJ97M=; b=jJstnJXocB42ETd3ySOX4PwAZYPsjgvXZbek/qclLaBtBpQDxKZZnzygzPSHuOwZGy NfrkOroTmYY5TedN36AU5axEcq2yCV1SyoWlAu/wXejzJD+WF1aQUjSOtX5/SBNtNrKH K2FW/1COnFpAR2UCxbVZrsrxcWoExrPvIZYUmv/IgtGqVl1hMvU4DrgAzLaUcAKkgPwb n/siPff6qNMcTb+MAbqMnpbsEVoazh9MunRpqGAVJ7xvrnMqYfao8sx8KyDvSV5UZvQA /ebwWzL73OByLryi9xSaIYXlMIfcnPPBeioht8uINUKKYygONqr86R3op/u3g/uzIhdV jADA== X-Forwarded-Encrypted: i=1; AJvYcCVizln9ewiq6IdS3rVC+jG5hwf59JAy97bnAdmFqykc7aTVGUqrpfT0KcQ1SE6XNnCOHBGBUQxQe2vM6HM=@vger.kernel.org X-Gm-Message-State: AOJu0YxMJC8kY6LGAYwO7eu6X7RdC1NVJ+B96v1I3Co5Y9zFhSiKpZhw F8bJdVFfdccbKyVYNgdExFmLy/hGeAWwtFSEjX7We6tN1cLslYvtv0fNdu/baXAzhqTmgNaGU0W SPuNmgRMjmotB7AyXxG28B6SvjB59BzcOTQUveLvv3+C5LXmVaESTRkXPJqmChHrUffyyH+EE57 bs6A== X-Gm-Gg: ASbGncuip9C0xafijycBnldjAjp2UFRpek4dfbuBhSjTDamrJrg4+RdRSTGeItOo6KD cq6eZj2fw6ECH0bmuM8EE/MkhqPKWaz4YgU8yigHxwAoFr1CwCHT7AUxchISSDkNqLZPW2Bz9zh UwMrYGYZMEQaVwNk60unyNRc7+hNOglfgf5D2FdLAI2ep2lql/510Yj+vvzZXcUHTqlQV8IJZxA qZnsu1e1pNa2A3UciXC9+gLcqncTLMm0UvAJbxcK6CadDWaDXNuwPD7rxaFGYchK2woklYkqtWg AztQrREECYpG5SAy X-Received: by 2002:a17:902:ce8c:b0:21f:522b:690f with SMTP id d9443c01a7336-221a11b9bfdmr221006845ad.46.1740407526684; Mon, 24 Feb 2025 06:32:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IHSZQwlljMmmYRCC7Y9lX6+uL/BcL5sVp/WVmnDYsqhnw8DVA1aShXde+2Ht/xNGnXwOQ2afA== X-Received: by 2002:a17:902:ce8c:b0:21f:522b:690f with SMTP id d9443c01a7336-221a11b9bfdmr221006465ad.46.1740407526306; Mon, 24 Feb 2025 06:32:06 -0800 (PST) Received: from z790sl.. ([240f:74:7be:1:de7b:58db:ab85:24ee]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-220d545d067sm177613895ad.109.2025.02.24.06.32.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Feb 2025 06:32:06 -0800 (PST) From: Koichiro Den To: linux-gpio@vger.kernel.org Cc: brgl@bgdev.pl, geert+renesas@glider.be, linus.walleij@linaro.org, maciej.borzecki@canonical.com, linux-kernel@vger.kernel.org Subject: [PATCH v5 9/9] Documentation: gpio: document configfs interface for gpio-aggregator Date: Mon, 24 Feb 2025 23:31:34 +0900 Message-ID: <20250224143134.3024598-10-koichiro.den@canonical.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250224143134.3024598-1-koichiro.den@canonical.com> References: <20250224143134.3024598-1-koichiro.den@canonical.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add documentation for the newly added configfs-based interface for GPIO aggregator. Signed-off-by: Koichiro Den --- .../admin-guide/gpio/gpio-aggregator.rst | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) diff --git a/Documentation/admin-guide/gpio/gpio-aggregator.rst b/Documenta= tion/admin-guide/gpio/gpio-aggregator.rst index 5cd1e7221756..8374a9df9105 100644 --- a/Documentation/admin-guide/gpio/gpio-aggregator.rst +++ b/Documentation/admin-guide/gpio/gpio-aggregator.rst @@ -69,6 +69,113 @@ write-only attribute files in sysfs. $ echo gpio-aggregator.0 > delete_device =20 =20 +Aggregating GPIOs using Configfs +-------------------------------- + +**Group:** ``/config/gpio-aggregator`` + + This is the root directory of the gpio-aggregator configfs tree. + +**Group:** ``/config/gpio-aggregator/`` + + This directory represents a GPIO aggregator device. You can assign any + name to ```` (e.g. ``agg0``), except names starting with + ``_sysfs`` prefix, which are reserved for auto-generated configfs + entries corresponding to devices created via Sysfs. + +**Attribute:** ``/config/gpio-aggregator//live`` + + The ``live`` attribute allows to trigger the actual creation of the de= vice + once it's fully configured. Accepted values are: + + * ``1``, ``yes``, ``true`` : enable the virtual device + * ``0``, ``no``, ``false`` : disable the virtual device + +**Attribute:** ``/config/gpio-aggregator//dev_name`` + + The read-only ``dev_name`` attribute exposes the name of the device as= it + will appear in the system on the platform bus (e.g. ``gpio-aggregator.= 0``). + This is useful for identifying a character device for the newly created + aggregator. If it's ``gpio-aggregator.0``, + ``/sys/devices/platform/gpio-aggregator.0/gpiochipX`` path tells you t= hat the + GPIO device id is ``X``. + +You must create subdirectories for each virtual line you want to +instantiate, named exactly as ``line0``, ``line1``, ..., ``lineY``, when +you want to instantiate ``Y+1`` (Y >=3D 0) lines. Configure all lines bef= ore +activating the device by setting ``live`` to 1. + +**Group:** ``/config/gpio-aggregator///`` + + This directory represents a GPIO line to include in the aggregator. + +**Attribute:** ``/config/gpio-aggregator///key`` + +**Attribute:** ``/config/gpio-aggregator///offset`` + + The default values after creating the ```` directory are: + + * ``key`` : + * ``offset`` : -1 + + ``key`` must always be explicitly configured, while ``offset`` depends. + Two configuration patterns exist for each ````: + + (a). For lookup by GPIO line name: + + * Set ``key`` to the line name. + * Ensure ``offset`` remains -1 (the default). + + (b). For lookup by GPIO chip name and the line offset within the chip: + + * Set ``key`` to the chip name. + * Set ``offset`` to the line offset (0 <=3D ``offset`` < 65535). + +**Attribute:** ``/config/gpio-aggregator///name`` + + The ``name`` attribute sets a custom name for lineY. If left unset, the + line will remain unnamed. + +Once the configuration is done, the ``'live'`` attribute must be set to 1 +in order to instantiate the aggregator device. It can be set back to 0 to +destroy the virtual device. The module will synchronously wait for the new +aggregator device to be successfully probed and if this doesn't happen, wr= iting +to ``'live'`` will result in an error. This is a different behaviour from = the +case when you create it using sysfs ``new_device`` interface. + +.. note:: + + For aggregators created via Sysfs, the configfs entries are + auto-generated and appear as ``/config/gpio-aggregator/_sysfs./``. Y= ou + cannot add or remove line directories with mkdir(2)/rmdir(2). To modify + lines, you must use the "delete_device" interface to tear down the + existing device and reconfigure it from scratch. However, you can still + toggle the aggregator with the ``live`` attribute and adjust the + ``key``, ``offset``, and ``name`` attributes for each line when ``live`` + is set to 0 by hand (i.e. it's not waiting for deferred probe). + +Sample configuration commands +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: sh + + # Create a directory for an aggregator device + $ mkdir /sys/kernel/config/gpio-aggregator/agg0 + + # Configure each line + $ mkdir /sys/kernel/config/gpio-aggregator/agg0/line0 + $ echo gpiochip0 > /sys/kernel/config/gpio-aggregator/agg0/line0/key + $ echo 6 > /sys/kernel/config/gpio-aggregator/agg0/line0/offset + $ echo test0 > /sys/kernel/config/gpio-aggregator/agg0/line0/name + $ mkdir /sys/kernel/config/gpio-aggregator/agg0/line1 + $ echo gpiochip0 > /sys/kernel/config/gpio-aggregator/agg0/line1/key + $ echo 7 > /sys/kernel/config/gpio-aggregator/agg0/line1/offset + $ echo test1 > /sys/kernel/config/gpio-aggregator/agg0/line1/name + + # Activate the aggregator device + $ echo 1 > /sys/kernel/config/gpio-aggregator/agg0/live + + Generic GPIO Driver ------------------- =20 --=20 2.45.2