From nobody Wed Jun 17 02:56:35 2026 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (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 AA8922580F2 for ; Tue, 28 Apr 2026 13:52:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777384335; cv=none; b=gHk1JSEClg+mOkVBS3hb22+otExthEoIXdNmg46caUoig036xHuo9GiElu5TPoO77oxy9PbaR0BiXxXsiRfNlcPoj304Y36D2+AppmCVJwdh4Tji5aCR5iCb5aoHI6F0s6Z7ZZMELwM2Hmh0w1R582XcdiU4xqG1iie8pA+AeO4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777384335; c=relaxed/simple; bh=ugiJkWptIeimKlAU8w6wgZisMEUkwI1xsKmQ/d7RXmc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tb3H7kvuqieQEnTANx1J2RVr4oim4vosoHgE2skUeI0Jz/106hDIMXlrA8SUe2too+pMZTC2BniCDs4VJ9UR8H71h0pzLpQ5oseoLd5yPTjeTC0+YPnsb5VoeNrEfZ5XN7I0kyUmaW/AJpwb9ivOqfh4asipu3FV8U1gJLTTGLM= 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=dfDpu3sx; arc=none smtp.client-ip=209.85.221.41 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="dfDpu3sx" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-44261378651so2152503f8f.0 for ; Tue, 28 Apr 2026 06:52:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1777384332; x=1777989132; 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=GRMqGE72Xv3+URdBdrUbDo5jbpuPsn6CvKxz6Jp6b0o=; b=dfDpu3sxIAHk205pwXj2n2PYzVt/Znw+ULpSEYwMzpnhxYOMh53r0vwKCEksQ/ZhUv Dt2X6nUNhq57Pfi8btsKUGI/myK9tZKAI9QXgBl882Mihyhh7P686vXf30vxQOnd7hrC BGGX71OjQhPCb65b+PqigBaHOodAz7N9sjaOSrMhfHHB63kjzwz+XThnTgaNXc68VES0 cshWlPfpIeKLkqbykdJ9Khmpt5EpP3TP7DXpH/x27RU9R6VdZRKJnM5bneZph6Ab9mAP Clwck1jEw/4altWiovIsxmNAU53DmAY9jpMYshSyl36pQyfkL5yTInI82PysoCGayEVu XDgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777384332; x=1777989132; 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=GRMqGE72Xv3+URdBdrUbDo5jbpuPsn6CvKxz6Jp6b0o=; b=Lds0319PCzVxcm5kMeUEle3ujpSqLeA6ACji5p1yl+sLTaVDwvS2C2Gso+usrkmbxN qogloVO0DGFFrosAyJbt/cHLn6T83Ynx/U4jhgoo1XU9TFFPX+f+kkJKi3gtXYW6VxZQ rLoPS7LTx3Ti40K0KdLq+lVX+BLWYsexogE3PcTDDJ44Exl+R0XwI5D39FhvcX3qn9AZ MPupbyf/HVAlhbshGs46/LH82lge9dCzFdvnqfxNgPrX/PeA/aw72c8rsjn6wQbxVQuO P9TQDVDzcfPkNrPUkQ38RwGq9ixI/eqFzA4goybI/1mCuBwaN920hJU18iWOmZpDUG7j v6Rw== X-Gm-Message-State: AOJu0YzC76aPS3N2kOsZ7WmpElD8VQtDtD+WdLVwHz9VVEpsmekxzh0E J0blVczhLRZS7tOxrNne8maejJl7oGxGtnayY19h4UanJwwJ6gboOOvVjjHKfyv9fSIrvL/Psi6 YvdEoEvM= X-Gm-Gg: AeBDietT/D24qvtofMi60iX5jxfIfNzTM9cplQxEILwNMKsbfQE2yjBbx6xbcuDNhmS mrC6WJgj4zv6Q7BLjrfWMo7z32E+GnR8J1L1WL3IB6WlbPuhO7owOQqzOBuKuKomSOx3+VwT63r mfF5mHP6/KVdETMYWWW8F/ypIlMRxSCCK7fIf6Irei7UId1Wy0PTGUkNGFttLQ/TIDjMAIsRpN/ bQekgjyq023hCQxBBH1sfVDmKWmseyUyL4doi+4Mji9uVk4GKippSI8y0S4/zdGhkNkY22mQFbs j7LqhjLTFMLqDgPNM7x4M5u4ViXPsLEE/0kpN9xKZEYAR+QZVKZPHKcEiiN8XBAECccgEfDM8cU dRNx1PGcJcQAOt3Lc6+yMNLYs8nf2oTrztuyFlhOsJS+dH5OUEETIO0oeSvfhmi/2CzKAII4A7b 2hFBpaBLgekbe8BqaiM7bltZ4owZbzGZtyiwjeEA/cRYZjC8BLf/Pt/ZI= X-Received: by 2002:a05:6000:2b01:b0:43d:7a5e:8162 with SMTP id ffacd0b85a97d-446516638d6mr3497650f8f.15.1777384332034; Tue, 28 Apr 2026 06:52:12 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:106d:1080:8261:5fff:fe11:bdda]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4463f4c07a2sm6773044f8f.20.2026.04.28.06.52.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2026 06:52:11 -0700 (PDT) From: Neil Armstrong Date: Tue, 28 Apr 2026 15:52:05 +0200 Subject: [PATCH 1/2] dt-bindings: regulator: 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: <20260428-topic-sm8650-ayaneo-pocket-s2-sgm3804-v1-1-1d8dc7620256@linaro.org> References: <20260428-topic-sm8650-ayaneo-pocket-s2-sgm3804-v1-0-1d8dc7620256@linaro.org> In-Reply-To: <20260428-topic-sm8650-ayaneo-pocket-s2-sgm3804-v1-0-1d8dc7620256@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=ugiJkWptIeimKlAU8w6wgZisMEUkwI1xsKmQ/d7RXmc=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBp8LuJbRwBh0ek5dTDespIfXm6eJMJmPMESII8XR5n lteeGmCJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCafC7iQAKCRB33NvayMhJ0asdD/ 4kG/eALu93zuwu+NGc6QIj0pbGCTI9AYkppPMmMaGw4HmgbnSbLemh4MC4cadRWyqhbnuShNkUIQdq FN1JzH0tJya4rOyCkHlRRHM6AsoL1K7oafn/bQT+2vrMgo+q95+esd0Zhoa9JeGjXQFiNZCzOK3Cp2 R7WTDf1Jd0UlhEvaygWmkd2CUh+QidI2BnKOL5C3Cn+0LZEJZR+itGGf9LyvwaOdU032y6fYz+ZBR8 Y38jBpoC6DsKxQqbXTj3L2CMY54+O8kWdctYYSVC8Jnqv1Gx6xq7jB/9JBU4shIbkjGiACI47YSy0E miRkiVlNAadXFQocyEe4vBp1M6098E5n49O2LVASeuhT44Dow9OlrKueMm911saHXhG7cNQfGQrQgG +eFrgOfcJ2LrYeHYn+QoZlbYQJ6UjwVgcfhDSLOeIoXejc+WhjP0iaR0n3PvCSh4GfWml077AsmP5g lSB3v+GBeA4f1BXo2ZCvFBDnL/p65MbSq3wtWOoudkKvCiWJ49FxcjjmockF/atp/QvEhhk/P9aUNt +77TZaUOIz2IVb8fhX3uIp4kNZsR62M7EXvW6BoaQwgSO0ryT5c2rGIE1HkmN+V9xk2f9Z7+JgDFv1 7K3KgbIGsb/1/sMAyqbl7calG9f2jTKcIyNc1igOCVhgr3mSXEuvtZ+7p8Ag== 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..e75684e910ff --- /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: + maxItems: 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 Wed Jun 17 02:56:35 2026 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (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 AE7A1406268 for ; Tue, 28 Apr 2026 13:52:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777384336; cv=none; b=j/pWWgjYSBelRmjnt6Z9I6RRxBqjTOZdxavnpxYlgw1ddTq3LRSb4zgpy1c6i4Bge1S1a4GrJ3EIvZN8g8D1h0Inrkj6tFVRZ5X8ALocfK14xBSBi5phbxaVPYXCsGMUOkH91u5cpriQhK5AAWYt3raZgD4TWz2eQl3TLLdoJZ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777384336; c=relaxed/simple; bh=/fqAkdyrLaisATfPWFL25iMhF4oyrS6qJz2IaP7APT8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jhMRY4NNb2Enka+EuX2RvPswN+sSL0U3GX8SpCCEOrsRND5F7hkEFzH9L/da5k2oWa6tyHOoIlCTx7dpNtpapD7fiU99+aGEMQKZdknolNpoB7h+6mkTWWnnui3V5ZUzAsvzB2QqMIHY1jwaAaQ7rt40qVZsAv1gCmjvtkMnxxY= 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=iCd7go7Q; arc=none smtp.client-ip=209.85.221.52 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="iCd7go7Q" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-43d7e23defbso6714360f8f.0 for ; Tue, 28 Apr 2026 06:52:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1777384333; x=1777989133; 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=zD1RrLk38fWrR9Bubp6Ekaq6ndaJfkS2ygjcj1Qfki0=; b=iCd7go7QX80AdIt5sKIXDfw6JUMumW4EEGkQeHz92C6yBigkCV47mum9Se7XzD3n4w 7n04sRe9ViSBtWgbk/h86AbcallLSffCriys/JgV/Oriqqf9siphNKNXBJrp3zYGlzx6 xW2WVZOosAs89m33l2eTE9d8C+o/p0KCgNfigYiiAKWTR0YltjH5gpAyWPW9vbOiQAy6 AgTMDwRcYESPUYnWL7klXTy4aTw+5T5tuoJAQu3ROjuN6iIcqnQ2pRiGB0GfIGio7Ka5 Q1aP1H7DYU3RXkiNydgWMYIUM4qPGVbU17LL9MrdW2KqmWaoFmjtIo9s41KPhkDuWGpj AQ4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777384333; x=1777989133; 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=zD1RrLk38fWrR9Bubp6Ekaq6ndaJfkS2ygjcj1Qfki0=; b=rQhLDP8lPhEUKhbtKWatvppJnG9RRShRaH/hl+VSilC61pJHNhXCPwj44MYlL84GrB HbirJG/8oZ9qG3cskJATIUN7NNKQOIdKKTeJlgEfx3IrpbMJZaYuyBHT3KUXDwcuHHfo CAtOySrU3XXJ+SnQfGbpiAMa+LXeHdfHeSQctHSg3NapiNPmu9lUlIXc3bjKRhJbKlQK kPmKRKK7kCZbeyZxx89WP8yseG4zmoSG/O6g6rJUt7rWE8Pf/ttFHUAMn266dcCQ1cDc rBfvL4DUsxAoedMMnBhDLc5DVuPTTB5hTnQSKv8rryG6ZUj0ms4RIGgMHnXeawAb+ikS IjIg== X-Gm-Message-State: AOJu0Ywz7Xze3nXb36LbjK5JGkSoQuZPLU37GBSyXb5RH4MR4IZOVEYx OV5YWXMhm4FBHkpVHeZYSWVw+5Dga1uCFongSF5TOo6uswbbfwepujOYzllCb2jvjoE= X-Gm-Gg: AeBDiethMmA/ZHR3lEpXlib3J+qU+mCAKulQbs+30igvMuQe2fem8+qToZ0doFsJbfS RwSHezgUOEd3FkJRl5hDmpGM4PLuyKxU/63BGjQlaXrBlBE5CesSoiOJdsKk2iSeVOSG8M2Huen q+rTwSryFzoSYNC1gT0Ti7gbquqg2CO7Y9MFFZAKNiHkMF4LHxiQPreCTqwtR341GD9At9ub9se SN8RIcZRwtX3B7fn2n1LGpNAVc96Hx98uYuRItqMNOpBd8VqjirIXJZLw19C0WRKsSk7RQE/i8U jwoeLnPMijB62+NHVbUBglqpsieNXIYujXujtiWBNYD6uqh+LiDvXhvjyoWKw+L1J7SAWtPuRTh x9ls1QVCnjvMQ5En2Ua+493nuFBoBBnVYN7Sut0wVQGIm1RzUZPnc+No4jXpw3L9sPhS+6CxqCX MArlhbKrmlFnmXwDTBpAMHdiPB4HEdwMveUUBy28nVPYMZut/gneEM+KI= X-Received: by 2002:a05:6000:604:b0:43d:68ad:3b7f with SMTP id ffacd0b85a97d-4464901eac2mr6205515f8f.21.1777384332925; Tue, 28 Apr 2026 06:52:12 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:106d:1080:8261:5fff:fe11:bdda]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4463f4c07a2sm6773044f8f.20.2026.04.28.06.52.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2026 06:52:12 -0700 (PDT) From: Neil Armstrong Date: Tue, 28 Apr 2026 15:52:06 +0200 Subject: [PATCH 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: <20260428-topic-sm8650-ayaneo-pocket-s2-sgm3804-v1-2-1d8dc7620256@linaro.org> References: <20260428-topic-sm8650-ayaneo-pocket-s2-sgm3804-v1-0-1d8dc7620256@linaro.org> In-Reply-To: <20260428-topic-sm8650-ayaneo-pocket-s2-sgm3804-v1-0-1d8dc7620256@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=10280; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=HQIVJlEIZXjuGioJW+siBTJFNBkM8oe/nBonjij1PAw=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBp8LuJyDVaHOPx/RxSsD+e5bKLCbKcef9qdtVCypUG ULr6C5eJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCafC7iQAKCRB33NvayMhJ0d41EA CivqRuEaSbVLbTHf2E8sKLLxfx2EMX3Ywsoi2hHYQANjmayZBiFWs1FJoMHylMrgbbbRMYMV2b3f1d ApCiDcLmZXL0Srbrg62bPL855l09P3Eystn/3gj0OGqSnsE3jPI5FvmGjZzH7nWy36oGpFYUAFV3cg BFnll6eXoT0WG8GZD0PvZpFpzH+Tnx2RcOtMl/buePUqgyi3Jad96xHxFbTNDXuXHp3J90+tHUreEk lBz3NzGWGJbo9/n0fL/BmmdmmUpvZCaRBnqz5m4+XdBixbzF4D9OKZZVoaa8HN0ro0RYNw47A1yo4O tDwVvFesBWUT0DyggCf62uO5j9lkf7LRgLrFLMI7eHDdl8g2K+XZRWccGGJySA1cgNapyqtps7/B9G yPZoUwJeH3gPJ1Uq6VP6IPk4228Lvja8I63AVwyz5HfYvTQH1pHffOOHd1kkes1zej64V2sUoE+KY1 /EsltOct17HdnrvhZCLPKBsrDyeFNAFjS/IsQsArk7fLXuZhCsG95ksEK72wM1bcUzjZ4KeRHrgN5X vWL2OfQ+YU71mVQ2xK0tOc8moPzQl1Vkngc1HWjIhnL6uqJeP8EeCAJyQ8SXML93PxFpv+GuoPUGnu eFYPzw/U1DJtDnnNcC+WL7COlgpRcdryls1Je6zV5ojLnWz0j+0nnpZJkSDg== 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 add flexibility, the regmap cache is enabled. Signed-off-by: Neil Armstrong Signed-off-by: KancyJoe --- drivers/regulator/Kconfig | 6 + drivers/regulator/Makefile | 1 + drivers/regulator/sgm3804-regulator.c | 280 ++++++++++++++++++++++++++++++= ++++ 3 files changed, 287 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..5d496e32eaf1 --- /dev/null +++ b/drivers/regulator/sgm3804-regulator.c @@ -0,0 +1,280 @@ +// 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), +}; + +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; + } +} + +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_LICENSE("GPL"); --=20 2.34.1