From nobody Fri Dec 19 19:17:45 2025 Received: from lelvem-ot01.ext.ti.com (lelvem-ot01.ext.ti.com [198.47.23.234]) (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 15BF01F4C92; Thu, 5 Jun 2025 06:34:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.234 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749105284; cv=none; b=GMdj4/nXR6P9huZilt1AxchqoOS55z357fHFGY1fLZqzwit9ue4c0Do0g6rmjXvnQ5gOOPRmQBmzP2hoif0AxFCtl8VWQc/6YsQGCujJq7HowUyvcRLD/9+mx1STPO5uFAjZpk84o2mcqXkiSDcXtwZ9GXp1V/0tBGI5pKY731s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749105284; c=relaxed/simple; bh=K3vXgO1zlgvYeORcvU/rVn72uCLkgct3vUie0/EZOlk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Q4qMU3dXran8ZeRoIPfBNurn1/W6ViDCSaZqop3SILHcF56OA87Bko8jenA9Ww9NOL56n5rgk86TLVBW+nZY0TSf38F83Cr/UzwUAJj7N/SnKRqBqbFKpvSit63rk190OFQTNq8GdBDBf6yYqWvY8pBU3mKxw4CHdHfGcZ8UEJ4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=xzPsG4NP; arc=none smtp.client-ip=198.47.23.234 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="xzPsG4NP" Received: from fllvem-sh04.itg.ti.com ([10.64.41.54]) by lelvem-ot01.ext.ti.com (8.15.2/8.15.2) with ESMTP id 5556YQ1V985073; Thu, 5 Jun 2025 01:34:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1749105266; bh=0g43eBPoit6Jtatj+4t9Bz21BhQHusi4cw3INLI08SM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=xzPsG4NPhHGGZh6VOAsaOPC5kuBSyLayiKf/oO2v4n3t/+wshW6p93ap5MFMubh9R QE5CM6eGzL5V9Inp2dvObJOnTn3GgGsu7HxWFPVJGdSCXfFHbSeVn/E8PHw4a/n/yL 9vq8LxYGkg2enRWBrNckd77OeGk8uPc32fWe62OI= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by fllvem-sh04.itg.ti.com (8.18.1/8.18.1) with ESMTPS id 5556YQIn705750 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA256 bits=128 verify=FAIL); Thu, 5 Jun 2025 01:34:26 -0500 Received: from DLEE113.ent.ti.com (157.170.170.24) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Thu, 5 Jun 2025 01:34:26 -0500 Received: from lelvem-mr06.itg.ti.com (10.180.75.8) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Thu, 5 Jun 2025 01:34:26 -0500 Received: from localhost (chintan-thinkstation-p360-tower.dhcp.ti.com [172.24.227.220]) by lelvem-mr06.itg.ti.com (8.18.1/8.18.1) with ESMTP id 5556YPlk3167878; Thu, 5 Jun 2025 01:34:25 -0500 From: Chintan Vankar To: Thorsten Blum , Andrew Davis , Chintan Vankar , Conor Dooley , Krzysztof Kozlowski , Rob Herring , Peter Rosin CC: , , , , , Subject: [PATCH 1/2] devicetree: bindings: mux: reg-mux: Add support for new property 'mux-reg-masks-state' Date: Thu, 5 Jun 2025 12:04:21 +0530 Message-ID: <20250605063422.3813260-2-c-vankar@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250605063422.3813260-1-c-vankar@ti.com> References: <20250605063422.3813260-1-c-vankar@ti.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 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea Content-Type: text/plain; charset="utf-8" The DT binding for reg-mux currenly requires specifying register offset and masks in the "mux-reg-masks" property, while corresponding register values are defined in the "idle-states" property. This approach imposes a constraint where "mux-reg-masks" and "idle-states" must remain synchroniszed, adding complexity when configuring specific registers or a set of registers with large memory spaces. Add support of a new property "mux-reg-masks-state" to remove this constraint, allowing offset, mask and value to be specified together as a tuple. Signed-off-by: Chintan Vankar --- .../devicetree/bindings/mux/reg-mux.yaml | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/mux/reg-mux.yaml b/Documenta= tion/devicetree/bindings/mux/reg-mux.yaml index dc4be092fc2f..b029e2f28df0 100644 --- a/Documentation/devicetree/bindings/mux/reg-mux.yaml +++ b/Documentation/devicetree/bindings/mux/reg-mux.yaml @@ -32,11 +32,39 @@ properties: - description: pre-shifted bitfield mask description: Each entry pair describes a single mux control. =20 - idle-states: true + idle-states: + description: Each entry describes mux register state. + + mux-reg-masks-state: + $ref: /schemas/types.yaml#/definitions/uint32-matrix + items: + items: + - description: register offset + - description: pre-shifted bitfield mask + - description: register value to be set + description: This property is an extension of mux-reg-masks which + allows specifying register offset, mask and register + value to be set. + +allOf: + - oneOf: + - required: [mux-reg-masks] + - required: [mux-reg-masks-state] + + - if: + required: [mux-reg-masks-state] + then: + not: + required: [idle-states] + + - if: + required: [mux-reg-masks] + then: + properties: + idle-states: true =20 required: - compatible - - mux-reg-masks - '#mux-control-cells' =20 additionalProperties: false --=20 2.34.1 From nobody Fri Dec 19 19:17:45 2025 Received: from lelvem-ot02.ext.ti.com (lelvem-ot02.ext.ti.com [198.47.23.235]) (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 2974F1F5851; Thu, 5 Jun 2025 06:34:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.235 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749105284; cv=none; b=An1oC490Rq29K7g/ECJmfn/RcNZGXrBGUt2xpVLwOzloIVWlW3m44I24JQMRW/w01uCyeYOHJchYMX1wEhQzNNG7Fn6Dxbmwgh+si2UqgtG1NJqjYsets7GFjZYOeiGDpJH7IlC2OKQ8d5R3kvcbtuXH9xhqFLvYW4QbFLZJh5E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749105284; c=relaxed/simple; bh=ErRqqOpxwfW0w7fNXw2IiWrQLMr6NeAPAay0w6kuoGI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=omY/TQacF8Dj3FI8sszVR+swBjoK0jF2b/ZB5eFFbDG9b5713eT0I7DOM5rtmcbte4M+vhnBJFH13vDCaJg4DnV8w2q767ulbKG8H3Q3JN8LlweE1CVCtHB3lgh35c2fEvsVxSh4855EP7OiX8V8t0F/hj04nTWjCTKQpTa2fYE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=UFJEjFg/; arc=none smtp.client-ip=198.47.23.235 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="UFJEjFg/" Received: from lelvem-sh02.itg.ti.com ([10.180.78.226]) by lelvem-ot02.ext.ti.com (8.15.2/8.15.2) with ESMTP id 5556YS3U4007522; Thu, 5 Jun 2025 01:34:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1749105268; bh=IPhBSTGoRyJcgG/sdbW/2eUB7XpXWt8lVYIybtfRXgo=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=UFJEjFg/FjLdTVgfPr1hFvHe/u3v/ijr/APoEXTeEUNc7WtO5fAud9aIyEeR46/iU EfODxF304M94H87/t/nLdJo73EjoZFydi4XV4511wZWVOqLuuHIjNyL0cAkrqG2B/b QzoAPiZwihvk98OrUjRDZJrj1sLiraM/2JgUGbPw= Received: from DLEE106.ent.ti.com (dlee106.ent.ti.com [157.170.170.36]) by lelvem-sh02.itg.ti.com (8.18.1/8.18.1) with ESMTPS id 5556YSC82575129 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA256 bits=128 verify=FAIL); Thu, 5 Jun 2025 01:34:28 -0500 Received: from DLEE114.ent.ti.com (157.170.170.25) by DLEE106.ent.ti.com (157.170.170.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Thu, 5 Jun 2025 01:34:27 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Thu, 5 Jun 2025 01:34:27 -0500 Received: from localhost (chintan-thinkstation-p360-tower.dhcp.ti.com [172.24.227.220]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 5556YQUu3267438; Thu, 5 Jun 2025 01:34:27 -0500 From: Chintan Vankar To: Thorsten Blum , Andrew Davis , Chintan Vankar , Conor Dooley , Krzysztof Kozlowski , Rob Herring , Peter Rosin CC: , , , , , Subject: [PATCH 2/2] mux: mmio: Extend mmio-mux driver to configure mux with mux-reg-masks-state Date: Thu, 5 Jun 2025 12:04:22 +0530 Message-ID: <20250605063422.3813260-3-c-vankar@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250605063422.3813260-1-c-vankar@ti.com> References: <20250605063422.3813260-1-c-vankar@ti.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 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea Content-Type: text/plain; charset="utf-8" MMIO mux driver is designed to parse "mux-reg-masks" and "idle-states" property independently to configure mux. The current design is complex for the devices with larger memory space, which requires synchronization between the two properties. Extend mmio-mux driver to support a single property, "mux-reg-masks-state" which configures mux registers without above constraint. Signed-off-by: Chintan Vankar --- drivers/mux/mmio.c | 144 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 118 insertions(+), 26 deletions(-) diff --git a/drivers/mux/mmio.c b/drivers/mux/mmio.c index 9993ce38a818..5ce9c16fd431 100644 --- a/drivers/mux/mmio.c +++ b/drivers/mux/mmio.c @@ -2,7 +2,7 @@ /* * MMIO register bitfield-controlled multiplexer driver * - * Copyright (C) 2017 Pengutronix, Philipp Zabel + * Copyright (C) 2017-2025 Pengutronix, Philipp Zabel */ =20 #include @@ -39,10 +39,83 @@ static const struct regmap_config mux_mmio_regmap_cfg = =3D { .reg_stride =3D 4, }; =20 +static int reg_mux_get_controllers(const struct device_node *np, char *pro= p_name) +{ + int ret; + + ret =3D of_property_count_u32_elems(np, prop_name); + if (ret =3D=3D 0 || ret % 2) + ret =3D -EINVAL; + + return ret; +} + +static int reg_mux_get_controllers_extended(const struct device_node *np, = char *prop_name) +{ + int ret; + + ret =3D of_property_count_u32_elems(np, prop_name); + if (ret =3D=3D 0 || ret % 3) + ret =3D -EINVAL; + + return ret; +} + +static int reg_mux_parse_dt(const struct device_node *np, bool *mux_reg_ma= sks_state, + int *num_fields) +{ + int ret; + + if (of_property_present(np, "mux-reg-masks-state")) { + *mux_reg_masks_state =3D true; + ret =3D reg_mux_get_controllers_extended(np, "mux-reg-masks-state"); + if (ret < 0) + return ret; + *num_fields =3D ret / 3; + } else { + ret =3D reg_mux_get_controllers(np, "mux-reg-masks"); + if (ret < 0) + return ret; + *num_fields =3D ret / 2; + } + return ret; +} + +static int mux_reg_set_parameters(const struct device_node *np, char *prop= _name, u32 *reg, + u32 *mask, int index) +{ + int ret; + + ret =3D of_property_read_u32_index(np, prop_name, 2 * index, reg); + if (!ret) + ret =3D of_property_read_u32_index(np, prop_name, 2 * index + 1, mask); + + return ret; +} + +static int mux_reg_set_parameters_extended(const struct device_node *np, c= har *prop_name, u32 *reg, + u32 *mask, u32 *state, int index) +{ + int ret; + + ret =3D of_property_read_u32_index(np, prop_name, 3 * index, reg); + if (ret < 0) + return ret; + + ret =3D of_property_read_u32_index(np, prop_name, 3 * index + 1, mask); + if (ret < 0) + return ret; + + ret =3D of_property_read_u32_index(np, prop_name, 3 * index + 2, state); + + return ret; +} + static int mux_mmio_probe(struct platform_device *pdev) { struct device *dev =3D &pdev->dev; struct device_node *np =3D dev->of_node; + bool mux_reg_masks_state =3D false; struct regmap_field **fields; struct mux_chip *mux_chip; struct regmap *regmap; @@ -70,15 +143,16 @@ static int mux_mmio_probe(struct platform_device *pdev) return dev_err_probe(dev, PTR_ERR(regmap), "failed to get regmap\n"); =20 - ret =3D of_property_count_u32_elems(np, "mux-reg-masks"); - if (ret =3D=3D 0 || ret % 2) - ret =3D -EINVAL; + ret =3D reg_mux_parse_dt(np, &mux_reg_masks_state, &num_fields); if (ret < 0) { - dev_err(dev, "mux-reg-masks property missing or invalid: %d\n", - ret); + if (mux_reg_masks_state) + dev_err(dev, "mux-reg-masks-state property missing or invalid: %d\n", + ret); + else + dev_err(dev, "mux-reg-masks property missing or invalid: %d\n", + ret); return ret; } - num_fields =3D ret / 2; =20 mux_chip =3D devm_mux_chip_alloc(dev, num_fields, num_fields * sizeof(*fields)); @@ -90,19 +164,25 @@ static int mux_mmio_probe(struct platform_device *pdev) for (i =3D 0; i < num_fields; i++) { struct mux_control *mux =3D &mux_chip->mux[i]; struct reg_field field; - s32 idle_state =3D MUX_IDLE_AS_IS; + s32 state, idle_state =3D MUX_IDLE_AS_IS; u32 reg, mask; int bits; =20 - ret =3D of_property_read_u32_index(np, "mux-reg-masks", - 2 * i, ®); - if (!ret) - ret =3D of_property_read_u32_index(np, "mux-reg-masks", - 2 * i + 1, &mask); - if (ret < 0) { - dev_err(dev, "bitfield %d: failed to read mux-reg-masks property: %d\n", - i, ret); - return ret; + if (!mux_reg_masks_state) { + ret =3D mux_reg_set_parameters(np, "mux-reg-masks", ®, &mask, i); + if (ret < 0) { + dev_err(dev, "bitfield %d: failed to read mux-reg-masks property: %d\n= ", + i, ret); + return ret; + } + } else { + ret =3D mux_reg_set_parameters_extended(np, "mux-reg-masks-state", ®, + &mask, &state, i); + if (ret < 0) { + dev_err(dev, "bitfield %d: failed to read custom-states property: %d\n= ", + i, ret); + return ret; + } } =20 field.reg =3D reg; @@ -126,16 +206,28 @@ static int mux_mmio_probe(struct platform_device *pde= v) bits =3D 1 + field.msb - field.lsb; mux->states =3D 1 << bits; =20 - of_property_read_u32_index(np, "idle-states", i, - (u32 *)&idle_state); - if (idle_state !=3D MUX_IDLE_AS_IS) { - if (idle_state < 0 || idle_state >=3D mux->states) { - dev_err(dev, "bitfield: %d: out of range idle state %d\n", - i, idle_state); - return -EINVAL; + if (!mux_reg_masks_state) { + of_property_read_u32_index(np, "idle-states", i, + (u32 *)&idle_state); + if (idle_state !=3D MUX_IDLE_AS_IS) { + if (idle_state < 0 || idle_state >=3D mux->states) { + dev_err(dev, "bitfield: %d: out of range idle state %d\n", + i, idle_state); + return -EINVAL; + } + + mux->idle_state =3D idle_state; + } + } else { + if (state !=3D MUX_IDLE_AS_IS) { + if (state < 0 || state >=3D mux->states) { + dev_err(dev, "bitfield: %d: out of range idle state %d\n", + i, state); + return -EINVAL; + } + + mux->idle_state =3D state; } - - mux->idle_state =3D idle_state; } } =20 --=20 2.34.1