From nobody Tue Jun 16 17:07:23 2026 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 E17323FE37B for ; Thu, 30 Apr 2026 08:48:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777538933; cv=none; b=VgzmtbdvE0q3Y6YVxWCNCRSyLQVOMdZujVQcl0zYciQLtf08H6jNJiDdFtHgALi4fpC/zHKxbc/JLBZ61AHu4IMvAxmPhV9m4TEvzqrcoEVj0F+DWTJGgX5WGfB1+YnN1f0EWCw04y00E1clwsmE3ct64ZP9xm/gAuLyXPZNbFw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777538933; c=relaxed/simple; bh=KprnOnjsttWQiEb9apl8DCvxQ43ss1PmqfDfKIM+Iac=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SKo9XrglDqSJBZssdbIRwrKgBsVJhTHgng6o+CV71CavrgllFEu+t0VXpjc/nCo1dTqCJWetSZ5ie7/2CRYNWoXpS7r866fXo1NqWEyzWpKxfF1C6enkrDBrJ8OaS38ZBdyEVUEvYPYlKebKDqwFyByFYPMdW3PsbjuX0QH+Pc0= 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=UPRO+k+0; arc=none smtp.client-ip=209.85.128.49 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="UPRO+k+0" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-488ad135063so5483925e9.0 for ; Thu, 30 Apr 2026 01:48:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1777538930; x=1778143730; 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=Q6V0mcknKMb0dSYnK05FcavK9ZSRQpZJ3ISebg/MFpc=; b=UPRO+k+05qDtg9rlYb1Qcd+H9qaG2R1t6xjnx0+kYspmkaTFIv7tCVYaZDhUP6GLo0 XtkiEZPrFSquwPZIU+Rbx50R8/sip8OA558GHQH0vby43gC0KvAERXYsohBsX+t2oT2Q BNPdk8y7QWv4Ss/wrbEHVw+2MZc03FiqiGY90dhWyG9hTWgfNYeF5qweFiparpXYwPut DBUo8ezOuTe4LEjTV43Ym1UyPaAoazCDy8/QDp3Q91q4l9Fbz5k+XA91PeWeaN6Y/l5K ubwXNKT1ck4uL6UyD/t++p8z25pVgf44ArwfuJHqOW2ePIN4jbeyXxPF4ismZPcIgL7B oRuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777538930; x=1778143730; 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=Q6V0mcknKMb0dSYnK05FcavK9ZSRQpZJ3ISebg/MFpc=; b=Jgxjo9+owS2n6u4byZt+1m4vL/D4sFo6pRF1yLVL0+NgFXj+nQ+e23Aq42xG9T5Gtq /m6MqMoFRCOne5qmXFi3eIVcvd8k6b1wM3tOYkgbNrSA5S1WAnAYm4B7esvXG004A8Th 80QRJFoQCGPnlAYBeQpMMIT4BINo8/wMJP5AAZ/7CQOdW9WXxRfFQS7sSgw2VJe2rgqC /rG8y10QnMVWTDzlr73m8z7ylfKgg+VIseiwgOCeRUPbaKP4GqC+w960QVWFHa60KHO8 2LSqOnNlEuSNkW5rUQeykfo8HNW2Vb4a+7hUPRxpQn71HlrP/fGeyF/IGlpVZVqcED0G E9Wg== X-Gm-Message-State: AOJu0Yyz8Z242aPMhzbsUbju5kOzbG/H5/gdqpAr4NzNCAH8d0XEOadQ u5LRJBilOYTwNLNHbMo0FyWpDDUXsgMmEFmiLeYIgeHNOxQ/207Z6J1TXoAG6THCXBs= X-Gm-Gg: AeBDiet8epQcVHgZjivS3h1FVKLFDTbT7qek3Ek1gIhFKMAb8AQPzEXJ1wkt8XmDsiB 0lJcyu1gX6l3eCpAnyOU3dEa7gR1bFH1y9+oyW1hb9EXnQ/8Zi3hYy5S+/AmELI6nzwlWG1ZAGy p5dHf/NAG+BG/mTyeMn6X5lIoYvJvHCAMr4+2lYtSzFxeFOstuCxl75Ebed5fEkEJhXiV2Un9Ta CbrjzrZTPKsHKJQf1F3JsKPXbAr8GE1ODRsubzzs9D6k0iTnGiscY1aJ6SuRDaFDPe/sGh1qeGU 2G09KuTojvhFUGcjgwYFXp8FaQzr5PUkNcjymgQlDrhMDMrTrMQ4zH6cQ7A6v2J550Al1w4rbh+ 6ZLR/puzPE4fqbcjHH0IWrrG1a4uj/t+8QOcKXOSt7aZBDJMUv6O4iu1c7N89ujIC8qpWqjIiEq 1u/dhR63DACAd5LvWtZVNE9UsjP/yntG3BpEDI3piITzNP3a0hZLVH1Hc= X-Received: by 2002:a05:600c:a14:b0:486:f634:ef1 with SMTP id 5b1f17b1804b1-48a844525c5mr30979545e9.17.1777538930298; Thu, 30 Apr 2026 01:48:50 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:106d:1080:52eb:f6ff:feb3:451a]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48a7c1d0228sm137328025e9.2.2026.04.30.01.48.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2026 01:48:49 -0700 (PDT) From: Neil Armstrong Date: Thu, 30 Apr 2026 10:48:46 +0200 Subject: [PATCH v2 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: <20260430-topic-sm8650-ayaneo-pocket-s2-sgm3804-v2-1-76108c65a560@linaro.org> References: <20260430-topic-sm8650-ayaneo-pocket-s2-sgm3804-v2-0-76108c65a560@linaro.org> In-Reply-To: <20260430-topic-sm8650-ayaneo-pocket-s2-sgm3804-v2-0-76108c65a560@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=2641; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=KprnOnjsttWQiEb9apl8DCvxQ43ss1PmqfDfKIM+Iac=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBp8xdw160JlujIr+2XFrEhGYVYMSCwAbqSSEBkHLdh 17qCB0CJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCafMXcAAKCRB33NvayMhJ0d47D/ wL6EaNfWY2Z+pf3kaF7qwLQSnj4DA2Fbqa41+6V8y0bWKA3ds6kT6PdxbjrAvA0gIlMCdOrRFQCV5t Uq0gAegZqUgIKcIj/7r96kINyP17dqdkAIM6LGDc6i8cW/CZnGhoIvDIedxu6tdMWJXBE+h4Jc4GKP 6v9J+3mEtKSabNCzvT8YlSphQ7aUY9miP8O9zotd0+y2qBMhidvZisB9QU9OLeFnT0jDgxpuuDY4GX Vuk8qEmoXFElV3HlkkMEb/n36oLtX3BSUOP/sz1kw0hfK3TfS66xX6l6EwjuYLOuvrhmAKhsKRO/az FMgJFWZpF8SruTibxmCr/yEYCf1r1jhfmoiMZl4/rnnQ8WGiT/QQ6vW6r/QXR2KhvlEb8AVsNcKjBY fDqDWWJ+VDwyVnKkG99XTAVxlyO0u+prMZcdykkhngrJuDTPuOX25QFoDWqFJaiNtxjT/UbOGuW2IR q2FNVNuuZQp6jgzjjwpsBE5DrLYjlVtC5m9Gg4NiOEW4o1hub3a2fAM9/oTlUPvSvrEjB1ysuves/K RrNLX0ryTsRsVE7L23A9O6qCvmzdnpvaYMRiBXrqyNeEq/a7TOVPw6NOstX/iEVZiLfNZztRoRg/PR bHMfiMp8EDbm8Z98vVwK4v9EHmv6id5JCJQeWp93RjALzeV5bjR3Fy6Rzqcw== 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. 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..fbed911434e2 --- /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 + + enable-gpios: + minItems: 2 + description: + GPIO specifiers to enable the positive and negative outputs. + + vin-supply: true + +patternProperties: + "^(pos|neg)$": + type: object + $ref: regulator.yaml# + unevaluatedProperties: false + +required: + - compatible + - reg + - enable-gpios + - 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>; + + enable-gpios =3D <&gpio 17 GPIO_ACTIVE_LOW>, + <&gpio 18 GPIO_ACTIVE_LOW>; + + pos { + regulator-name =3D "outpos"; + regulator-min-microvolt =3D <5000000>; + regulator-max-microvolt =3D <5000000>; + }; + + neg { + regulator-name =3D "outneg"; + regulator-min-microvolt =3D <5000000>; + regulator-max-microvolt =3D <5000000>; + }; + }; + }; +... + --=20 2.34.1 From nobody Tue Jun 16 17:07:23 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 A06F33FE653 for ; Thu, 30 Apr 2026 08:48:52 +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=1777538934; cv=none; b=pEkf7Ij4Oc0Ne1O8obD1JcKmzcrO4DvfE0RJsrHMmCzVTTwWQD0XMngSqIgkOZpXSqEgtRhTWkK5waUKnrerrlTvWc41I/ioij6f71omyLAKjYWwBAdx/CaFiKiCGVQ105NzqFNRZqLwU2e4OHKU6G5L/hlANDNslyvZJ0jEirY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777538934; c=relaxed/simple; bh=L1ADRSEKiHkrZ90LVIlez9Z2sRlYLND+yG4NKRBA0hE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dXErpP8M5yWAaPOLBcSyTET8OHfO/xSl+JXUqHr/WP1sjOXoPV0B7g9S99ib8jP/82b8OFl5G0OcnIDLokfP3iI8UCoKW/n8z3LiaB7Otpy7fJ5XRaEU22LFAjGUR3JM+sCEAhMYsPypyep456mzVwBeiMG7+Ch3NgdZYdfyNA0= 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=NLjAvYK8; 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="NLjAvYK8" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4891c0620bcso4287545e9.1 for ; Thu, 30 Apr 2026 01:48:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1777538931; x=1778143731; 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=4kXLCkoCz9qlwf2uhnklfCrtj7yA2s9uCD0vIq7Tqgw=; b=NLjAvYK8cMiugjVdpEiGsxnLsyD/m+udXb5Jpj24surXxAeK6k+wP5YKK89CJTpzo7 1aOI6gUfqGBWsHRvNO8JyMJuDdaxuj02PThMufNVGJqFg9aRktsWstl0nkTgmbBWxJfB FyNkXq5PcYuIth8+NY2dkxhiDj3m3+Xa/t5z4vFDCeRBBaxWOGL/DJoam5WEySvTT/rU 2Tye6VdgZ0KnqxSt9TE1R2uggtv5DjhT0xbJhaR0mMhx0q5hArCGQ5n7QMt1Q3FENW6q UdcuOcrYmTLlrJLwfeWdLAp09iFq6jJPMCaWzwjIVh+HiuHr18n3GL1yXi/KpLpL4NyX 0W9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777538931; x=1778143731; 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=4kXLCkoCz9qlwf2uhnklfCrtj7yA2s9uCD0vIq7Tqgw=; b=BUI1WeO82gnRGjjz42jRuD4iKyZfbBPTIWqRz/w2ANVWBb7RLIng64W5ZWgBj72V83 rlDMdE5U/KoHYaQw2bavs/yvUEz4fxDA0zzpmdMtcIHuoKe1dpktlM9Tod6eLm+JcEib lzbcm/qlbNBplG0xzWh2RUxKajinEAwz+TuOKGJTwHEfl38QIpEJJ4xKR3wWn/rIjCxz 58DXVqZM9r7NgbQ0M9rcPyIeooTsXKlnrLpOFDPzx9Fw+xKWelyz4QNIdgWkaZHOJp2O +CgNYo1wgUjo3rH+Q13m1YoptcARkrjoAB/7SpOmbwaBxcwhJtq/APsi+m1SBJ05M3mo NJww== X-Gm-Message-State: AOJu0YxTwhXFwuRt2wYtlm6+HCP7TMy4MPm63wG/bBKBdww6VjJoBmjy 1Qw5ABrlna4w9E9+auw/4wpNmEhM4zxsV7veKCgkXJ9n3SE68TgbzdRC728FHYN74Nw= X-Gm-Gg: AeBDievNmJ78+z6gzKS2SBdSlF0MZx9ltww6rCkN3NKVmRrNTMlu+GDvbdrBCNAmX07 t4CXl3Ao3ori0S3nmkNs3fRN9Abk7Uqqh9h9FzA2maMVXtu45wbXlWXmLBrH8WvAvxhCdmfwc1i MeLVP9gr+4E/A6iZUs7IpAKdekiuXGM0gnYa1pkJb3V4W1eXQPndadaBvYTeVq1hAQdCSRB5Dvc xib97MCxGrvgAO3yfScz3NYncOMnOsycXwbIZe7hRF4N5t+YKcar7wfioetfgdKKcf/uiBLyfe4 p9XwMoPEictqG6Td3AbZVSBDJHryDI+KIzC1F1vaOjvxHlfixg7mmgKayzyFUOjuL760aCLTY8V UtFzgT/xU9paSwK/R5OYnZrftStPgq5wIproLK4jtRq2WrPR5zA7sbtzquQvD858F32YWZ2jOPX KAjbQq3R0HLU6Fa259Gk0iji/RngnLarzkZZd/XSH1nlDGjS1OHjy24YxHzRkTmnhy8g== X-Received: by 2002:a05:600c:8708:b0:48a:5970:2003 with SMTP id 5b1f17b1804b1-48a844e4a83mr31227695e9.3.1777538931036; Thu, 30 Apr 2026 01:48:51 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:106d:1080:52eb:f6ff:feb3:451a]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48a7c1d0228sm137328025e9.2.2026.04.30.01.48.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2026 01:48:50 -0700 (PDT) From: Neil Armstrong Date: Thu, 30 Apr 2026 10:48:47 +0200 Subject: [PATCH v2 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: <20260430-topic-sm8650-ayaneo-pocket-s2-sgm3804-v2-2-76108c65a560@linaro.org> References: <20260430-topic-sm8650-ayaneo-pocket-s2-sgm3804-v2-0-76108c65a560@linaro.org> In-Reply-To: <20260430-topic-sm8650-ayaneo-pocket-s2-sgm3804-v2-0-76108c65a560@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=10710; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=+i0RMuPTBhqEnTknFmfhVd7hvPYNqSPW7+dUEk1keLg=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBp8xdw4rarX+7ocva6BMFIQ600uAfT8TAXmxzWhHLA afutd9qJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCafMXcAAKCRB33NvayMhJ0XzWD/ wMUSBgNmNmeEX812VWxcBk82afSrWAfVP20uGGHEO15r7F9EoHbQRSBB1sLErpIcliMS1PWcQUVU4B YwIRfJ9l+gIS4bCREeqCi7waX6ZyTzhs4fDEkXHD2b65yxmtw/93rgrPW6ci1xFF/aXKjjCfzuGVef bVggQ41U+qmGLMmV7VR5HZ1rZ5JeYUZGQxEwtOuykdt7Inpn/9s9JHjBDx7cZUxwwp8pB0Q/tyjT5x htQ7ljFHNhCDTk7f10jrjbAR0g704TqQ0J7OVqum7zGfKRxkyiPvvL0KZCrjXeTq67ZQs27yja8Yza mctwwcVpPmRhD4vz61ZweyFErHY7QjNs30qNC1pi5ETJ+j2t8wovYRZA5XRZJv/K8uhFcdt04dKC4a 6rpowUVh1ffAk4PUs3H0U/Aos8yQ6pzmrIXwQhKLXsr3csZ9MBOzGmwQ8Mx2dxXbxK/eBa+PVUGBvD J2OaH7oHPRtRD4aky1Va7SBYiOqKCsWlFU5qOgoIJoOyBJ/BQDnMnouMfaDbBNm9wXISwYjaU0r2mi THgGCYfjP37PMWisZw7dUkEzU24h2thBNR5RofVTe34/y5+FgKikson9W5Ih3hrqsn3vt3CQlUK62K pFZz0zhC/OU4vm4iPP7L/Bprkowuk4pQ2ne/BfGtda5SJQ7l3iym6xCR+WjA== 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. Thus we can't use the regmap helpers directly and we need to cache the selector and rail discharge state then setup the rails once the gpio is enabled. In order to add flexibility and simplify the driver, the regmap cache is enabled and populated with default values. Signed-off-by: KancyJoe Signed-off-by: Neil Armstrong --- drivers/regulator/Kconfig | 6 + drivers/regulator/Makefile | 1 + drivers/regulator/sgm3804-regulator.c | 290 ++++++++++++++++++++++++++++++= ++++ 3 files changed, 297 insertions(+) diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index e8002526cfb0..7a2ba22716a8 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -1590,6 +1590,12 @@ config REGULATOR_SUN20I help This driver supports the internal LDOs in the Allwinner D1 SoC. =20 +config REGULATOR_SGM3804 + tristate "SGMicro SGM3804 voltage regulator" + depends on I2C && OF + help + This driver supports SGMicro SGM3804 dual-output voltage regulator. + config REGULATOR_SY7636A tristate "Silergy SY7636A voltage regulator" depends on MFD_SY7636A diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 35639f3115fd..7c345c7caee7 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -181,6 +181,7 @@ obj-$(CONFIG_REGULATOR_STM32_PWR) +=3D stm32-pwr.o obj-$(CONFIG_REGULATOR_STPMIC1) +=3D stpmic1_regulator.o obj-$(CONFIG_REGULATOR_STW481X_VMMC) +=3D stw481x-vmmc.o obj-$(CONFIG_REGULATOR_SUN20I) +=3D sun20i-regulator.o +obj-$(CONFIG_REGULATOR_SGM3804) +=3D sgm3804-regulator.o obj-$(CONFIG_REGULATOR_SY7636A) +=3D sy7636a-regulator.o obj-$(CONFIG_REGULATOR_SY8106A) +=3D sy8106a-regulator.o obj-$(CONFIG_REGULATOR_SY8824X) +=3D sy8824x.o diff --git a/drivers/regulator/sgm3804-regulator.c b/drivers/regulator/sgm3= 804-regulator.c new file mode 100644 index 000000000000..0a1203c4ab16 --- /dev/null +++ b/drivers/regulator/sgm3804-regulator.c @@ -0,0 +1,290 @@ +// 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_COUNT 40 + +enum { + SGM3804_POS_RAIL =3D 0, + SGM3804_NEG_RAIL, + SGM3804_RAIL_COUNT, +}; + +/* + * The registers are only writable when the gpio is enabled, so we + * can't use the regulator regmap helpers & internal gpio handling + * so we need to track the state and apply the state at enable time. + */ +struct sgm3804_data { + struct regmap *regmap; + bool active_discharge[SGM3804_RAIL_COUNT]; + unsigned int sel[SGM3804_RAIL_COUNT]; + 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. + */ +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 writable & volatile */ +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 & volatile, + * 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, + .volatile_reg =3D sgm3804_writeable_reg, + .cache_type =3D REGCACHE_MAPLE, + .reg_defaults =3D sgm3804_reg_defaults, + .num_reg_defaults =3D ARRAY_SIZE(sgm3804_reg_defaults), +}; + +static int sgm3804_set_voltage_sel(struct regulator_dev *rdev, unsigned in= t sel) +{ + struct sgm3804_data *ctx =3D rdev->reg_data; + + ctx->sel[rdev_get_id(rdev)] =3D sel; + + return 0; +} + +static int sgm3804_get_voltage_sel(struct regulator_dev *rdev) +{ + struct sgm3804_data *ctx =3D rdev->reg_data; + + /* Force setting a voltage on probe */ + if (ctx->sel[rdev_get_id(rdev)] =3D=3D RAIL_VOLTAGE_INVALID) + return -ENOTRECOVERABLE; + + return ctx->sel[rdev_get_id(rdev)]; +} + +static int sgm3804_set_active_discharge(struct regulator_dev *rdev, bool e= nable) +{ + struct sgm3804_data *ctx =3D rdev->reg_data; + + ctx->active_discharge[rdev_get_id(rdev)] =3D enable; + + return 0; +} + +static int sgm3804_enable(struct regulator_dev *rdev) +{ + struct sgm3804_data *ctx =3D rdev->reg_data; + int ret; + + ret =3D gpiod_set_value(ctx->gpios[rdev_get_id(rdev)], 1); + if (ret) + return ret; + + ret =3D regmap_write(ctx->regmap, rdev->desc->vsel_reg, + ctx->sel[rdev_get_id(rdev)]); + if (ret) + goto err; + + ret =3D regulator_set_active_discharge_regmap(rdev, + ctx->active_discharge[rdev_get_id(rdev)]); + if (ret) + goto err; + + return 0; + +err: + gpiod_set_value(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; + + return gpiod_set_value(ctx->gpios[rdev_get_id(rdev)], 0); +} + +static int sgm3804_is_enabled(struct regulator_dev *rdev) +{ + struct sgm3804_data *ctx =3D rdev->reg_data; + + return gpiod_get_value(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 sgm3804_set_voltage_sel, + .get_voltage_sel =3D sgm3804_get_voltage_sel, + .set_active_discharge =3D sgm3804_set_active_discharge, + .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_COUNT, + .vsel_reg =3D SGM3804_POS_RAIL_VOLTAGE_REG, + .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_COUNT, + .vsel_reg =3D SGM3804_NEG_RAIL_VOLTAGE_REG, + .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 i; + + ctx =3D devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); + if (!ctx) + return -ENOMEM; + + 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"); + + /* Set default values */ + for (i =3D 0; i < ARRAY_SIZE(sgm3804_regulator_desc); i++) { + ctx->active_discharge[i] =3D true; + ctx->sel[i] =3D RAIL_VOLTAGE_INVALID; + + ctx->gpios[i] =3D devm_gpiod_get_index(dev, "enable", + i, GPIOD_OUT_LOW); + if (IS_ERR(ctx->gpios[i])) + return dev_err_probe(dev, PTR_ERR(ctx->gpios[i]), + "failed to get enable GPIO %d\n", i); + } + + 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; + 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