From nobody Sun May 24 18:45:52 2026 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42E5D399899 for ; Fri, 22 May 2026 13:09:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779455359; cv=none; b=WYtYomruIZO/t6Qd7PB7qgOMDGWi9tmEjJVyuyS0m0pEH2dqexMucJefIFdAg0+xUGkVCLtIeIL5RIAkUMlg1EAstmPxORiSLqIyZkhspL+WeDGYYy4mhXlWWS8DuaO2w5TLtbss/BtY1GC66vTsyrzTMvCHMzqPYG7qFS9NGpc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779455359; c=relaxed/simple; bh=XH9ZkSLlZXi4Q3xxOdKdClWcWnK/2QO56yV0PVRrX6s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NTEHyAuRb3pf7FiGvaqQYNu86z6+PrzwS9vEt8bkeqQqx4vqJic7PE+7SJxbNKpLzhmuJEogQyTHt4uQaxkdsiEdtNQBhdhDH6oBLqa2aK8McyTEcm3XsimzjFhX81wDSGyhO7GuRVztQHFFFUa2cYUcOCiupgaNR1K1R0Tedek= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=q2ter51Q; arc=none smtp.client-ip=209.85.221.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="q2ter51Q" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-43d75312379so6157740f8f.1 for ; Fri, 22 May 2026 06:09:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1779455356; x=1780060156; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=MRieD+RAjUYcMpIS7S33Q3GLSc1bkdYTe6Jma832hh0=; b=q2ter51QTxi/HuVNxPoQk2xkHcWQl/PJDr9Lsu9SQuOYF8/ov4UZZES3puXDLrrW22 BAtUZ/z1Rd5B3VXqzf3B4NWwux/Q+HhetSx6QLVikLCech/Ijew4KOk4aipG8cQ+l0j1 fc1mCG2WdBhen7WltH1spkanqbM6EpLZVmz560w6cD/ETrG7CKlsa4gIZd9elb8TI+Gu mHWsXvN52CqRELZHIWIpxL2Lthf2ENzUppjc98qqiqrKtsfcF6keF8ujjn5f3NO3HYC6 1RYctpGjFb6gV+vhErVmiZ/KH9CFzSaOjHlyn1n/AIOTj+QNPAn9RP1pAYSum9BOBnZs aUaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779455356; x=1780060156; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=MRieD+RAjUYcMpIS7S33Q3GLSc1bkdYTe6Jma832hh0=; b=Qo0qqGsiznHyci5reiI1whJ2dCETK49RFeCh+ro1Gc5zr95tc22IRC0Xt/8mhJcOo6 ZkL8in4hm1rVQnqRynqsh1jfIG8+jKBHu5isMQtymdE9rd1RA7prS3RhizHXg+1Sc62E rEwb4fd+Ea2yiwj+kz43XmwDVA5rf/l5kndvQ+0UrZzzcNvQRWeGtTaFgLdugpqpHSjV UjTCdEOgGw06nSKJCr7Atig2+0aamO2GeV4u+tV/DuMsCXL0QOrIkDvWfBKGxDMSBM0c aDBfPM/MYoXfFevO/DR8A344Eo2Fy2G6/paly0HZwi782oyN+LnH+EqXikAh4yT5nEnP Ic4A== X-Gm-Message-State: AOJu0YyKSgb5tybVTmd0ZnuZ8D/3e4H090epi734GYI4zL3qQEQP3yiV GB9AIV63yPW8+cCM5tY5OlS64F97xi4jfVa2XxqeTvXxTOiYQ0L4MJ2SA1YphUBL+8E= X-Gm-Gg: Acq92OG03jF4tM++5Y5owR+8EAw5Vt/+1bvZEUVVRxQr86qVI3dQv/Sg+yCJJT2AlJM lJ5s5Qm+GQPqnBoLOD8l/r/U+g1BQgmofKlXdk1p2Ox02R6DSUhdmfkN8/sFvqiv8+5/Ix4vSwR N0ForJ/sP/B2ufY2Rc9rnTGOPsHdsXeiUHyEb+cZ0H9QiwzPIhiVYQuzrZIwhbMWIYsaQv4Dhdd KOGYljvyfPOwiyR2kEei4prE4f3citp9ZKiODy39c3Ei2SGtU5EHVYH2s/fN7hWN22WP26xnvri PK+9a2nr5e7jYhxfVN99GRiynD7/6f21ocYbEmonDakV4CYAGCnSOQsB8wTHxTLz5xNoIrN4SkM BR7orzCzZa5AmKXYSJ4uhzz1eONtzcveZzjY4gGJyj+gLKG//ksotA4f9dm2bwXDNm91aqjlsgi iry7+qZQ3x+VkVnuzvoXn843b1jqHO7oqSkgkLAP9toX4xlgmY2tQvVkY= X-Received: by 2002:a05:600d:6446:20b0:486:faa8:9e4 with SMTP id 5b1f17b1804b1-4904249da29mr30890835e9.12.1779455355576; Fri, 22 May 2026 06:09:15 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:106d:1080:8261:5fff:fe11:bdda]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490454a0b82sm45413615e9.9.2026.05.22.06.09.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2026 06:09:15 -0700 (PDT) From: Neil Armstrong Date: Fri, 22 May 2026 15:09:12 +0200 Subject: [PATCH v5 1/2] regulator: dt-bindings: document the SGM3804 Dual Output regulator Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260522-topic-sm8650-ayaneo-pocket-s2-sgm3804-v5-1-bd6b1c300ecc@linaro.org> References: <20260522-topic-sm8650-ayaneo-pocket-s2-sgm3804-v5-0-bd6b1c300ecc@linaro.org> In-Reply-To: <20260522-topic-sm8650-ayaneo-pocket-s2-sgm3804-v5-0-bd6b1c300ecc@linaro.org> To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, KancyJoe , Neil Armstrong X-Mailer: b4 0.15.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2645; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=XH9ZkSLlZXi4Q3xxOdKdClWcWnK/2QO56yV0PVRrX6s=; b=owEBbAKT/ZANAwAKAXfc29rIyEnRAcsmYgBqEFV5/clXRdSP9+NKvtANaAm8ILY+Me0htq7PmuBk miLfG3WJAjIEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCahBVeQAKCRB33NvayMhJ0RHnD/ icDI1LRTXMAVx2p0nh5Wr2xcncG88/gkStB7uP5sEsQr5uflOqHG8Lk2czlc/eOlfTnZQjbiCXt2Mq VOBdr47rzghLszl85c2pG59WK5ZLsBJEdbwLd21G8nEF1+SEAwNvhjKj+q+NiS+RDqP9sB+XHNHF2I XDqdbMlj0UVOPoOV+UCvtUn64M25j0W7Zh3HiC3ccjSPl+npbjRM3WXpYZk84ZZUeZKChacs0dkirg m+IsHHCsa/kk0m1GLUC/AbC6eMyOQ4XdLYLCpZpgd4LFg/nuKlS9p0IycUZnOMYxp2Cb6WgN3m7JQQ YrscaYdLKS0r1w08WsQ7RoCrNsdMJWwg2cpISVRuoXyfROxsQHLnYnfN9SVM6Kbabq5d3RMYYWB5w4 f2ndIldMh0HxDZ60ix8zjYgBmsUp9hwbxX16s8Zw1KbaAe9yJQ8gzmUiENrB9B3IUL/5Am/UKwQXAZ YSG55znsevy3JCOyH9DG1aHdroqPa5jzkmLAVhHXUm0UZqHKxL2iHSzT6Qe+Cy1FzjR9LOOkJDuWn2 tkMX+836h0dULOOAch34z/r040Fwih6LmBRUJpoYzIYZ5JMG6fodZw7SB4RxxD9IqtxJkq51QU8BOF aTJyky+d2hDT9qLS8nh22i8TleB+BkyfrdulAqSl4ATxB3vg+EaMVV/ioK X-Developer-Key: i=neil.armstrong@linaro.org; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE Document the SG Micro SGM3804 Single Inductor Dual Output Buck/Boost Converter used to power LCD panels a provide positive and negative power rails with configurable voltage and active discharge function for each output. Reviewed-by: Rob Herring (Arm) Signed-off-by: Neil Armstrong --- .../bindings/regulator/sgmicro,sgm3804.yaml | 77 ++++++++++++++++++= ++++ 1 file changed, 77 insertions(+) diff --git a/Documentation/devicetree/bindings/regulator/sgmicro,sgm3804.ya= ml b/Documentation/devicetree/bindings/regulator/sgmicro,sgm3804.yaml new file mode 100644 index 000000000000..3716eaf81aa9 --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/sgmicro,sgm3804.yaml @@ -0,0 +1,77 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/sgmicro,sgm3804.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: SG Micro SGM3804 Single Inductor Dual Output Buck/Boost Converter + +maintainers: + - Neil Armstrong + +description: + The SGM3804 is a dual voltage regulator, designed to support positive/ne= gative + supply for driving LCD panels. It support software-configurable output + switching. The output voltages can be programmed via an I2C compatible i= nterface. + +properties: + compatible: + const: sgmicro,sgm3804 + + reg: + maxItems: 1 + + vin-supply: true + +patternProperties: + "^(pos|neg)$": + type: object + $ref: regulator.yaml# + + properties: + enable-gpios: true + + unevaluatedProperties: false + + required: + - enable-gpios + +required: + - compatible + - reg + - pos + - neg + +additionalProperties: false + +examples: + - | + #include + + i2c { + #address-cells =3D <1>; + #size-cells =3D <0>; + + regulator@3e { + compatible =3D "sgmicro,sgm3804"; + reg =3D <0x3e>; + + vin-supply =3D <&vin_reg>; + + pos { + regulator-name =3D "outpos"; + regulator-min-microvolt =3D <5000000>; + regulator-max-microvolt =3D <5000000>; + enable-gpios =3D <&gpio 17 GPIO_ACTIVE_HIGH>; + }; + + neg { + regulator-name =3D "outneg"; + regulator-min-microvolt =3D <5000000>; + regulator-max-microvolt =3D <5000000>; + enable-gpios =3D <&gpio 18 GPIO_ACTIVE_HIGH>; + }; + }; + }; +... + --=20 2.34.1 From nobody Sun May 24 18:45:52 2026 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B246535675E for ; Fri, 22 May 2026 13:09:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779455362; cv=none; b=QnNJEbZUr04b+kduN0A9W24dWwrpiX8BllH8med616KcqSvlZDUWzSL+pSL4FNTq3jIEHgVADwcg67nW11xq3pGLzqACo46EI/OMYOCdiNocGfCMgZNKAInaVmvc6J7aQxq+FR55SZvvBNXMppTxpW++2Nk47HfMfc3vos29ogY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779455362; c=relaxed/simple; bh=aWp4jSGV301SVIRZ6/VL/0twGqRHgJWikmRBN4qq7z0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eVm4YRV4KWb73t1BdhupExU9GwlvqnVy6HFghxCXa2qWMW2OiPWqBuWCJkosBcZyd4K2eivlhUyVCfo8uQSmmpLhgQyJmIzx3Q+Mn8zpOW8ZRwK5j4L45hWeasOuawsmootmoa6745Be/79Kd8VUfSoeNJMhB2Q2BS/cbFfKsOE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=OwXRlt6t; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="OwXRlt6t" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4891c00e7aeso53178065e9.2 for ; Fri, 22 May 2026 06:09:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1779455358; x=1780060158; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=+kAl1EoIKEurpHX2I5k3rnTe5SSNKGGLuS7IVOoxc3c=; b=OwXRlt6t7zbFnOOjKf0twpWlR0V70E8fGwqZktuLGDlXyFpXSRUjYJvJ2aSgp2JsKv x/vZ9dQt+sPP+VPw3ljx8wQfGpfeqkv0RHUSl6FUfCMRLfSIc5SExY4+KKG2XuQKfgSo xu87LApyV/jOwOZhPErl8tKldr768lgkDlTI2x2Pqig0gbPUSqliuUKuI4yOnmvvIZgY 5P95qGEpDd9DWWYlHu0O3Xb3noxURtDguFHWofUK4fSPJ6rqSoMM58jCrM+7zVS7LU4p WfaLebsRCV0eKrjq3USfNtP2Hts1OZRGVZYosThwMUi901e1CPAtoE0h6J2UCgklIYq0 th1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779455358; x=1780060158; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=+kAl1EoIKEurpHX2I5k3rnTe5SSNKGGLuS7IVOoxc3c=; b=j0jnU3d8LUmKQEUopjz2XzDVXn0x0k5PW24pz1tfwcAMom2qPepXwSjtW8yVgMcUIX bDvIGsgRZiqd8BJUgf4Xa0plxzbUzXjAnZSwEONpkvXNiWQzaSp3m/HSgb0Ufnh0fI/h eIkw5S0GvdE5aFfOajiNkNlcqfYcjJZK4b/UbwnLYfVlFuXzCYr6hZxLf6tq6IUEJk4D 4uAFkR1Xe8hM7ZSQtXYI28pmDHn94odw/IeeqhdvmS/VB73FGpYCB6yP9kP0tpxwlLLU iWk03O+ycf9vCsTbTdpE1MNpUYCQGIxOz0grbOnr8OoUxXuDKEXgludcGtU6MCcagzOs J0Qg== X-Gm-Message-State: AOJu0YxG3Mc2OZqiUxHdKSPuYpBVT94QDLBI0dU3WV6y2ZoAFEJW8R/U vvh8ehS5RZdeM084W6m8BW28ddqTwi3GRe3SAFaWhVqYAqphLjrMca+VWZxRnC6FO1s= X-Gm-Gg: Acq92OEhhArUvSRibDT2mzCGKfiIGzHybLaHdFmSCswtwUQa+mG1SBZauWv/V86IM/p m7MqYHKHDEndnLu8P9xqghQ2djd4Hf8SBZD8cYXqGRtVcJ9eycEH+ADaaDWVVu8bFaK3McDu7bc ki2MAf5B6rFb9HBziRBchTb1OZNsoaPnBb+HdtRRawsIKiThiLsWbiDKj9OzKjezUsXtCyKsorF 32aYumpAw2X/HT6Z8LkWpCgaoJcgs3XQIf/lHdIamzDS7wySU9hpOGVd9js7MM27aLfLr2CtGbZ 7xRd0txFiztU6QHQSY02QfjVZO2o++l/CMjCbywXNvV/hin3KpKXr8acgnnBvj6snAG2qzam8T+ U3qmzUYZyPsviGmD0u1md0kio26IigYRz0Esvofr5g8mF86ghIE7PsT1B5TdMKGpzmzEiYQgAFI AYStLFhj+UBHYx0uZMJ74pN9PEEiKZYECGxrBwBp/BzNcO X-Received: by 2002:a05:600c:468f:b0:490:47e0:e131 with SMTP id 5b1f17b1804b1-49047e0e229mr30752695e9.16.1779455356401; Fri, 22 May 2026 06:09:16 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:106d:1080:8261:5fff:fe11:bdda]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490454a0b82sm45413615e9.9.2026.05.22.06.09.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2026 06:09:16 -0700 (PDT) From: Neil Armstrong Date: Fri, 22 May 2026 15:09:13 +0200 Subject: [PATCH v5 2/2] regulator: add SGM3804 Dual Output driver Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260522-topic-sm8650-ayaneo-pocket-s2-sgm3804-v5-2-bd6b1c300ecc@linaro.org> References: <20260522-topic-sm8650-ayaneo-pocket-s2-sgm3804-v5-0-bd6b1c300ecc@linaro.org> In-Reply-To: <20260522-topic-sm8650-ayaneo-pocket-s2-sgm3804-v5-0-bd6b1c300ecc@linaro.org> To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, KancyJoe , Neil Armstrong X-Mailer: b4 0.15.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=11268; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=kpEEWcM85gI8g14G5k4E2QHhkCgE+znYMB7xUHeKbRk=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBqEFV5C/mzYijJQbRhBClQTxIWNZTrM95OuZH4JvKk HTVTiVCJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCahBVeQAKCRB33NvayMhJ0T1jD/ 47n4qAj76lxjnItViVuiqp4KoQUkNvy/is2XdMsiVyEmSaRZpIizJ+kKssbRdTB0vu5vBuE9ZEI3kX DhauC2i2fLzdhg736Po9X0eAub+Qdlsb4fPC91FX+uuDsAbQX/ELxkIqlrijGusYnZwC6c0216c0RK OcFsOWFxbIztPUezwu9WBB6oH8xK2W4rqMn6cRaJPEnQpkwWz65LURygeU0alnsjItZ9Buoudk79W/ 2sPVGmOB8F5EMtBz20OHHYeSNiQP6fuYw00y7aiAGTB4FLU+UOXOB0T50KX23n78aJ9vqMUDSwRJGj JQ2Nw9ghKvBRFg28I/+pLfOsHJWfSOo+rNokq5KpRE86Is2S3XNZRki3uqB39e+6wJpL5+TMNE9KNC gvZDfTK07EzCm9jUy5WJ0hU3XRA4EAbvqY20qOoLyDysGgoKp36qgrLSY7WrBTrFS1/dAsv/PrDPgV twhr5G6joCZEq5WIjIrCfzDZuD2aZsGFE22Lse40JH0WILj+pQaNovpDQNOnDkIFkrb7+VvnnqhbEW U9nx6IJqS0J/eCSOISaciZxDu0uX2CGjOQxPU5cJ7zEkyFtw5bf3271At8zo+JB1E5xlAuXZbBUpHE 09x56EC3X42K7kmSrvPZ5/Wo1SEjA/BajUV6AxStclFNSCKJQsdeIFddzdWw== X-Developer-Key: i=neil.armstrong@linaro.org; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE From: KancyJoe Add support for the SG Micro SGM3804 Single Inductor Dual Output Buck/Boost Converter used to power LCD panels a provide positive and negative power rails with configurable voltage and active discharge function for each output. The SGM3804 is powered by the enable GPIO pins inputs and only supports I2C write messages. In order to add flexibility and simplify the driver, the regmap cache is enabled and populated with default values since we can't write registers when the 2 GPIOs are down. Signed-off-by: KancyJoe Signed-off-by: Neil Armstrong --- drivers/regulator/Kconfig | 8 + drivers/regulator/Makefile | 1 + drivers/regulator/sgm3804-regulator.c | 314 ++++++++++++++++++++++++++++++= ++++ 3 files changed, 323 insertions(+) diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index e8002526cfb0..b79ad8852033 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -1489,6 +1489,14 @@ config REGULATOR_SC2731 This driver provides support for the voltage regulators on the SC2731 PMIC. =20 +config REGULATOR_SGM3804 + tristate "SGMicro SGM3804 voltage regulator" + depends on I2C && OF + depends on GPIOLIB + select REGMAP_I2C + help + This driver supports SGMicro SGM3804 dual-output voltage regulator. + config REGULATOR_SKY81452 tristate "Skyworks Solutions SKY81452 voltage regulator" depends on MFD_SKY81452 diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 35639f3115fd..98ecbbc3c6b7 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -172,6 +172,7 @@ obj-$(CONFIG_REGULATOR_S2MPA01) +=3D s2mpa01.o obj-$(CONFIG_REGULATOR_S2MPS11) +=3D s2mps11.o obj-$(CONFIG_REGULATOR_S5M8767) +=3D s5m8767.o obj-$(CONFIG_REGULATOR_SC2731) +=3D sc2731-regulator.o +obj-$(CONFIG_REGULATOR_SGM3804) +=3D sgm3804-regulator.o obj-$(CONFIG_REGULATOR_SKY81452) +=3D sky81452-regulator.o obj-$(CONFIG_REGULATOR_SLG51000) +=3D slg51000-regulator.o obj-$(CONFIG_REGULATOR_SPACEMIT_P1) +=3D spacemit-p1.o diff --git a/drivers/regulator/sgm3804-regulator.c b/drivers/regulator/sgm3= 804-regulator.c new file mode 100644 index 000000000000..c3406cfb73d0 --- /dev/null +++ b/drivers/regulator/sgm3804-regulator.c @@ -0,0 +1,314 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// SGMicro SGM3804 regulator Driver +// +// Copyright (C) 2025 Kancy Joe +// Copyright (C) 2026 Linaro Limited +// Author: Neil Armstrong + +#include +#include +#include +#include +#include +#include +#include + +#define SGM3804_POS_RAIL_VOLTAGE_REG 0x0 +#define SGM3804_NEG_RAIL_VOLTAGE_REG 0x1 +#define SGM3804_RAIL_DISCHARGE_REG 0x3 + +#define RAIL_VOLTAGE_MASK GENMASK(5, 0) + +#define POS_RAIL_DISCHARGE_EN BIT(1) +#define NEG_RAIL_DISCHARGE_EN BIT(0) + +#define RAIL_VOLTAGE_INVALID RAIL_VOLTAGE_MASK +#define RAIL_DISCHARGE_REG_DEFAULT (POS_RAIL_DISCHARGE_EN | NEG_RAIL_DISCH= ARGE_EN) + +#define SGM3804_VOLTAGES_MAX_SELECTOR 0x2f + +enum { + SGM3804_POS_RAIL =3D 0, + SGM3804_NEG_RAIL, + SGM3804_RAIL_COUNT, +}; + +/* + * The registers are only writable when the gpio is enabled, so + * we need to use the cache for read operations and set the regmap + * as cache_only when both GPIOs are down. + */ +struct sgm3804_data { + struct regmap *regmap; + /* Protects the regcache state update */ + struct mutex lock; + struct gpio_desc *gpios[SGM3804_RAIL_COUNT]; +}; + +static const struct linear_range sgm3804_voltages[] =3D { + REGULATOR_LINEAR_RANGE(2400000, 0x20, 0x2f, 100000), + REGULATOR_LINEAR_RANGE(4000000, 0x00, 0x17, 100000), +}; + +/* + * The cache is populated with those hardware default values + * so the regmap_update_bits operation will use the cached + * value to build a new register value and write it when GPIOs + * are enabled. + */ +static const struct reg_default sgm3804_reg_defaults[] =3D { + { SGM3804_POS_RAIL_VOLTAGE_REG, RAIL_VOLTAGE_INVALID }, + { SGM3804_NEG_RAIL_VOLTAGE_REG, RAIL_VOLTAGE_INVALID }, + { SGM3804_RAIL_DISCHARGE_REG, RAIL_DISCHARGE_REG_DEFAULT }, +}; + +/* Registers are only writable */ +static bool sgm3804_writeable_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case SGM3804_POS_RAIL_VOLTAGE_REG: + case SGM3804_NEG_RAIL_VOLTAGE_REG: + case SGM3804_RAIL_DISCHARGE_REG: + return true; + default: + return false; + } +} + +/* + * Since all registers are only writeable, regmap will only read from the = cache data. + */ +static bool sgm3804_readable_reg(struct device *dev, unsigned int reg) +{ + return false; +} + +static const struct regmap_config sgm3804_regmap_config =3D { + .reg_bits =3D 8, + .val_bits =3D 8, + .max_register =3D 0x03, + .writeable_reg =3D sgm3804_writeable_reg, + .readable_reg =3D sgm3804_readable_reg, + .cache_type =3D REGCACHE_MAPLE, + .reg_defaults =3D sgm3804_reg_defaults, + .num_reg_defaults =3D ARRAY_SIZE(sgm3804_reg_defaults), +}; + +static int sgm3804_sync_regcache_state(struct sgm3804_data *ctx) +{ + guard(mutex)(&ctx->lock); + + /* If both GPIOs are down, IC is powered down and I2C writes will fail */ + if (!gpiod_get_value_cansleep(ctx->gpios[SGM3804_POS_RAIL]) && + !gpiod_get_value_cansleep(ctx->gpios[SGM3804_NEG_RAIL])) { + regcache_cache_only(ctx->regmap, true); + regcache_mark_dirty(ctx->regmap); + } else { + int ret; + + /* At least a GPIO is up, we can write registers */ + regcache_cache_only(ctx->regmap, false); + ret =3D regcache_sync(ctx->regmap); + if (ret) { + regcache_cache_only(ctx->regmap, true); + return ret; + } + } + + return 0; +} + +static int sgm3804_get_voltage_sel(struct regulator_dev *rdev) +{ + int ret; + + ret =3D regulator_get_voltage_sel_regmap(rdev); + if (ret < 0) + return ret; + + /* Force setting a voltage on probe */ + if (ret =3D=3D RAIL_VOLTAGE_INVALID) + return -ENOTRECOVERABLE; + + return ret; +} + +static int sgm3804_enable(struct regulator_dev *rdev) +{ + struct sgm3804_data *ctx =3D rdev->reg_data; + int ret; + + ret =3D gpiod_set_value_cansleep(ctx->gpios[rdev_get_id(rdev)], 1); + if (ret) + return ret; + + ret =3D sgm3804_sync_regcache_state(ctx); + if (ret) + goto err; + + return 0; + +err: + gpiod_set_value_cansleep(ctx->gpios[rdev_get_id(rdev)], 0); + return ret; +} + +static int sgm3804_disable(struct regulator_dev *rdev) +{ + struct sgm3804_data *ctx =3D rdev->reg_data; + int ret; + + ret =3D gpiod_set_value_cansleep(ctx->gpios[rdev_get_id(rdev)], 0); + if (ret) + return ret; + + return sgm3804_sync_regcache_state(ctx); +} + +static int sgm3804_is_enabled(struct regulator_dev *rdev) +{ + struct sgm3804_data *ctx =3D rdev->reg_data; + + return gpiod_get_value_cansleep(ctx->gpios[rdev_get_id(rdev)]); +} + +static const struct regulator_ops sgm3804_ops =3D { + .list_voltage =3D regulator_list_voltage_linear_range, + .map_voltage =3D regulator_map_voltage_linear_range, + .set_voltage_sel =3D regulator_set_voltage_sel_regmap, + .get_voltage_sel =3D sgm3804_get_voltage_sel, + .set_active_discharge =3D regulator_set_active_discharge_regmap, + .enable =3D sgm3804_enable, + .disable =3D sgm3804_disable, + .is_enabled =3D sgm3804_is_enabled, +}; + +static const struct regulator_desc sgm3804_regulator_desc[] =3D { + /* Positive Output */ + { + .name =3D "pos", + .of_match =3D "pos", + .supply_name =3D "vin", + .id =3D SGM3804_POS_RAIL, + .ops =3D &sgm3804_ops, + .type =3D REGULATOR_VOLTAGE, + .linear_ranges =3D sgm3804_voltages, + .n_linear_ranges =3D ARRAY_SIZE(sgm3804_voltages), + .n_voltages =3D SGM3804_VOLTAGES_MAX_SELECTOR + 1, + .vsel_reg =3D SGM3804_POS_RAIL_VOLTAGE_REG, + .vsel_mask =3D RAIL_VOLTAGE_MASK, + .active_discharge_on =3D POS_RAIL_DISCHARGE_EN, + .active_discharge_mask =3D POS_RAIL_DISCHARGE_EN, + .active_discharge_reg =3D SGM3804_RAIL_DISCHARGE_REG, + .enable_time =3D 40000, + .owner =3D THIS_MODULE, + }, + /* Negative Output */ + { + .name =3D "neg", + .of_match =3D "neg", + .supply_name =3D "vin", + .id =3D SGM3804_NEG_RAIL, + .ops =3D &sgm3804_ops, + .type =3D REGULATOR_VOLTAGE, + .linear_ranges =3D sgm3804_voltages, + .n_linear_ranges =3D ARRAY_SIZE(sgm3804_voltages), + .n_voltages =3D SGM3804_VOLTAGES_MAX_SELECTOR + 1, + .vsel_reg =3D SGM3804_NEG_RAIL_VOLTAGE_REG, + .vsel_mask =3D RAIL_VOLTAGE_MASK, + .active_discharge_on =3D NEG_RAIL_DISCHARGE_EN, + .active_discharge_mask =3D NEG_RAIL_DISCHARGE_EN, + .active_discharge_reg =3D SGM3804_RAIL_DISCHARGE_REG, + .enable_time =3D 40000, + .owner =3D THIS_MODULE, + }, +}; + +static int sgm3804_probe(struct i2c_client *i2c) +{ + struct device *dev =3D &i2c->dev; + struct sgm3804_data *ctx; + int ret, i; + + ctx =3D devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); + if (!ctx) + return -ENOMEM; + + mutex_init(&ctx->lock); + + ctx->regmap =3D devm_regmap_init_i2c(i2c, &sgm3804_regmap_config); + if (IS_ERR(ctx->regmap)) + return dev_err_probe(dev, PTR_ERR(ctx->regmap), + "failed to init regmap\n"); + + /* Get enable GPIOs */ + for (i =3D 0; i < ARRAY_SIZE(sgm3804_regulator_desc); i++) { + const struct regulator_desc *reg =3D &sgm3804_regulator_desc[i]; + struct fwnode_handle *child; + + child =3D device_get_named_child_node(dev, reg->of_match); + if (!child) { + dev_err(dev, "missing child '%s'\n", reg->of_match); + return -EINVAL; + } + + ctx->gpios[i] =3D devm_fwnode_gpiod_get(dev, child, "enable", + GPIOD_ASIS, reg->name); + fwnode_handle_put(child); + if (IS_ERR(ctx->gpios[i])) + return dev_err_probe(dev, PTR_ERR(ctx->gpios[i]), + "failed to get '%s' enable GPIO\n", + reg->name); + } + + ret =3D sgm3804_sync_regcache_state(ctx); + if (ret) + return ret; + + for (i =3D 0; i < ARRAY_SIZE(sgm3804_regulator_desc); i++) { + struct regulator_config config =3D { }; + struct regulator_dev *rdev; + + config.dev =3D dev; + config.regmap =3D ctx->regmap; + config.of_node =3D dev_of_node(dev); + config.driver_data =3D ctx; + rdev =3D devm_regulator_register(dev, &sgm3804_regulator_desc[i], + &config); + if (IS_ERR(rdev)) + return dev_err_probe(dev, PTR_ERR(rdev), + "failed to register regulator %d\n", i); + } + + return 0; +} + +static const struct i2c_device_id sgm3804_id[] =3D { + { "sgm3804" }, + { } +}; +MODULE_DEVICE_TABLE(i2c, sgm3804_id); + +static const struct of_device_id sgm3804_of_match[] =3D { + { .compatible =3D "sgmicro,sgm3804" }, + { } +}; +MODULE_DEVICE_TABLE(of, sgm3804_of_match); + +static struct i2c_driver sgm3804_regulator_driver =3D { + .driver =3D { + .name =3D "sgm3804", + .probe_type =3D PROBE_PREFER_ASYNCHRONOUS, + .of_match_table =3D sgm3804_of_match, + }, + .probe =3D sgm3804_probe, + .id_table =3D sgm3804_id, +}; + +module_i2c_driver(sgm3804_regulator_driver); + +MODULE_DESCRIPTION("SGMicro SGM3804 regulator Driver"); +MODULE_AUTHOR("Kancy Joe "); +MODULE_AUTHOR("Neil Armstrong "); +MODULE_LICENSE("GPL"); --=20 2.34.1