From nobody Fri May 15 08:28:38 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C988C433EF for ; Sat, 23 Apr 2022 08:54:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234149AbiDWI5E (ORCPT ); Sat, 23 Apr 2022 04:57:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230383AbiDWI45 (ORCPT ); Sat, 23 Apr 2022 04:56:57 -0400 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28767203F67; Sat, 23 Apr 2022 01:54:01 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id h11so12237183ljb.2; Sat, 23 Apr 2022 01:54:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KL+1rLs6IeZIDUEirIkSF1eye+etiWXqoXEgr8jLdh4=; b=nU2jsDFjt0G4SgxxUcRbkQLR3psE2wMl2sh2AOByKRH5XuigWBxbAUFCT+CW7mFH54 ES115CsxEAHz6kYPnX2ObYrLa9gBSWXTqn9/Km9gzL/kltvG0PsxL8j91gVzmV3Yh2na MgiuNEYeca/B22PjkMu7+gL2na6qqU9H2sf7Im6cIJuFDbyw/S/GgFwv/1WJ3HvAne6r kzaUa4Om1y0xsRoeEhJ3Xr3nlG2F8dDNEWnqMQEmVPt17EeNpVNiH2XiKcAsLAzawEhU sgVJhp+cJmpZUd+oq/+u2hxbl1LLxwp7Z2VfwLl2onZiG2761VRlj/oPGq42wS3IAaYl /cMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KL+1rLs6IeZIDUEirIkSF1eye+etiWXqoXEgr8jLdh4=; b=AXhflYfpNYwlpTm8S2GeQ6IWwhQvphtKCaQhT9Y18QQDCaVYZwLV/NCaw7ksTweqpn z8ruTJ5w6vpVVmFgfvXX44pvMEoPcVu7IzgNR7yr8thb2ICGri9uBhmSBRAou2HoA+dR +xlnAWbc1nslAo8m0MJmN/wGk0uMLVDHFidcBp45cZ43BAdq/rWB90WyPvMQYoqcLIGc /Jyi+sgJNAOGP2VGn3ZAMI4T40a6cAZ9bOwF0ISXNB6fIWtfFFag1j6/Z6s68K9KvEgb WFWlQHHenesAWEzZg6dbuSHsSOB8Pq23DV2fMi2eAZkSFLrxVOHq0SNXvmdIUFo2pK6b AX5Q== X-Gm-Message-State: AOAM530cA+RAcQV1rDVQP+FHV7hH+sBzhCwvs1yQ0ynVWX+eS2A4rn+W p7dcVO9ukBqSOlxMbjFXfEZtAwEhlwk= X-Google-Smtp-Source: ABdhPJwBjfH9QrWr+q+iXFYWN2I8Bv5K282QJnG2IE3D5WwijVQ5HlRXoqj7yErDrNzUEF1Ihh6tMg== X-Received: by 2002:a2e:9583:0:b0:24f:482:e1cd with SMTP id w3-20020a2e9583000000b0024f0482e1cdmr1389648ljh.22.1650704039247; Sat, 23 Apr 2022 01:53:59 -0700 (PDT) Received: from nergzd-desktop.localdomain ([194.39.226.133]) by smtp.gmail.com with ESMTPSA id p25-20020a2e9a99000000b0024dc3ccff47sm493677lji.32.2022.04.23.01.53.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Apr 2022 01:53:58 -0700 (PDT) From: Markuss Broks To: linux-kernel@vger.kernel.org Cc: phone-devel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Markuss Broks , Matti Vaittinen , Lee Jones , Rob Herring , Krzysztof Kozlowski , Liam Girdwood , Mark Brown , MyungJoo Ham , Chanwoo Choi , devicetree@vger.kernel.org Subject: [PATCH v5 1/5] extcon: sm5502: Clarify SM5703's i2c device ID Date: Sat, 23 Apr 2022 11:53:14 +0300 Message-Id: <20220423085319.483524-2-markuss.broks@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220423085319.483524-1-markuss.broks@gmail.com> References: <20220423085319.483524-1-markuss.broks@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" While SM5502 and SM5504 are purely micro USB switching circuits, SM5703 is a multi-function device which has multiple modules in it. Change the i2c_device_id of it to avoid conflict with MFD driver. Signed-off-by: Markuss Broks --- drivers/extcon/extcon-sm5502.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/extcon/extcon-sm5502.c b/drivers/extcon/extcon-sm5502.c index 17a40c3782ee..f706f5288257 100644 --- a/drivers/extcon/extcon-sm5502.c +++ b/drivers/extcon/extcon-sm5502.c @@ -831,7 +831,7 @@ static SIMPLE_DEV_PM_OPS(sm5502_muic_pm_ops, static const struct i2c_device_id sm5502_i2c_id[] =3D { { "sm5502", (kernel_ulong_t)&sm5502_data }, { "sm5504", (kernel_ulong_t)&sm5504_data }, - { "sm5703", (kernel_ulong_t)&sm5502_data }, + { "sm5703-muic", (kernel_ulong_t)&sm5502_data }, { } }; MODULE_DEVICE_TABLE(i2c, sm5502_i2c_id); --=20 2.35.1 From nobody Fri May 15 08:28:38 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C823C433EF for ; Sat, 23 Apr 2022 08:54:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234305AbiDWI5I (ORCPT ); Sat, 23 Apr 2022 04:57:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234281AbiDWI5B (ORCPT ); Sat, 23 Apr 2022 04:57:01 -0400 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4163203F7E; Sat, 23 Apr 2022 01:54:04 -0700 (PDT) Received: by mail-lj1-x230.google.com with SMTP id v4so65936ljd.10; Sat, 23 Apr 2022 01:54:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=U+PN+GS0JECobt4d/ZN0bjvHqce0oNxs21CYm6No/tg=; b=j6BV+kWRL50dp4o5PLZRatbctyGekm6+QIrvMrBeksJYLLBx7OLhNmZYGDQsXsZ7mI B0UmHvIt2QSs7TyNZs4QkMGr6K2Pame2tQZtJBje2ZLYA8jUCph7OTP+nJc6g3zt0Dfg RmD3I3rs83kO9KIQn2ywUpTJpFeLdKtzjrQHc7og3aelNmgRmzxTMwrXO2aPr+vXc45K rDv/kGI316B+Qb2M4kI9CSpSNsrus73rDbr8KyWLj1w6kKM8RKNFRwbeowE7XWowSQVL p0doE1/b45THAJ1cs+l/k+NvP64cJISv6jdG4f4u/12gObntYtHPbIGRSLEb0BpbHchb m2AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=U+PN+GS0JECobt4d/ZN0bjvHqce0oNxs21CYm6No/tg=; b=1Gotm+NCnh0dfhFYyVhMDJGhGxtc7NzTrfNJCpS8MXspeTUD7z10NsZ1OHFj4xLdov t9SwXWeNE+SHowLbDKLZgLj9ImyZChJVt9u5oyvhqC/vrakSrNJh4SS0lsAkBxSwajTa QgNS6gnI8AIckbEylbeupZAvvuVzr1iOxV4rKVWhIQ1Q/X0hYHVClZqHoijMvspVGSM8 x7BcelBzBEQ2Lb7tLUF3g5x6/+FDs0fgrJsjXcisx4QJiJm4AzUYGlw/BeO+YbTP4jc4 hVXVMFvQnPYfNfpVPXT2vwNIsWILhD3ZwalCOUiNF+IAWQl5rjL2t+l+UvILPHF8TEds tYDA== X-Gm-Message-State: AOAM533njiL6YUa8jSS/1QZSP4pf6PXcW3SjSmOqvimlqqCdskRcR4eF sQdz0Kh1Jn/yJvd+TWrBOLWARcFo4Dg= X-Google-Smtp-Source: ABdhPJzeA3FiRVvgK9aiKYPHx0tcuKZk8FzerCkkas+mLlgkeL/JUhxTfXkGPOskNODXkVeX9HVexQ== X-Received: by 2002:a2e:bc05:0:b0:24b:212d:7521 with SMTP id b5-20020a2ebc05000000b0024b212d7521mr5083134ljf.243.1650704042927; Sat, 23 Apr 2022 01:54:02 -0700 (PDT) Received: from nergzd-desktop.localdomain ([194.39.226.133]) by smtp.gmail.com with ESMTPSA id p25-20020a2e9a99000000b0024dc3ccff47sm493677lji.32.2022.04.23.01.54.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Apr 2022 01:54:02 -0700 (PDT) From: Markuss Broks To: linux-kernel@vger.kernel.org Cc: phone-devel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Markuss Broks , Matti Vaittinen , Lee Jones , Rob Herring , Krzysztof Kozlowski , Liam Girdwood , Mark Brown , MyungJoo Ham , Chanwoo Choi , devicetree@vger.kernel.org Subject: [PATCH v5 2/5] dt-bindings: regulator: Add bindings for Silicon Mitus SM5703 regulators Date: Sat, 23 Apr 2022 11:53:15 +0300 Message-Id: <20220423085319.483524-3-markuss.broks@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220423085319.483524-1-markuss.broks@gmail.com> References: <20220423085319.483524-1-markuss.broks@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This patch adds device-tree bindings for regulators on Silicon Mitus SM5703 MFD. Signed-off-by: Markuss Broks Reviewed-by: Rob Herring --- .../siliconmitus,sm5703-regulator.yaml | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/siliconmitu= s,sm5703-regulator.yaml diff --git a/Documentation/devicetree/bindings/regulator/siliconmitus,sm570= 3-regulator.yaml b/Documentation/devicetree/bindings/regulator/siliconmitus= ,sm5703-regulator.yaml new file mode 100644 index 000000000000..75ff16b58000 --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/siliconmitus,sm5703-regul= ator.yaml @@ -0,0 +1,49 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/siliconmitus,sm5703-regulator= .yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Silicon Mitus SM5703 multi function device regulators + +maintainers: + - Markuss Broks + +description: | + SM5703 regulators node should be a sub node of the SM5703 MFD node. See = SM5703 MFD + bindings at Documentation/devicetree/bindings/mfd/siliconmitus,sm5703.ya= ml + Regulator nodes should be named as USBLDO_, BUCK, VBUS, LDO_. + The definition for each of these nodes is defined using the standard + binding for regulators at Documentation/devicetree/bindings/regulator/re= gulator.txt. + +properties: + buck: + type: object + $ref: regulators.yaml# + unevaluatedProperties: false + description: + Properties for the BUCK regulator. + + vbus: + type: object + $ref: regulators.yaml# + unevaluatedProperties: false + description: + Properties for the VBUS regulator. + +patternProperties: + "^ldo[1-3]$": + type: object + $ref: regulators.yaml# + unevaluatedProperties: false + description: + Properties for single LDO regulator. + + "^usbldo[1-2]$": + type: object + $ref: regulators.yaml# + unevaluatedProperties: false + description: + Properties for a single USBLDO regulator. + +additionalProperties: false --=20 2.35.1 From nobody Fri May 15 08:28:38 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BD25C433EF for ; Sat, 23 Apr 2022 08:54:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234328AbiDWI5M (ORCPT ); Sat, 23 Apr 2022 04:57:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234285AbiDWI5E (ORCPT ); Sat, 23 Apr 2022 04:57:04 -0400 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8E95203F7C; Sat, 23 Apr 2022 01:54:07 -0700 (PDT) Received: by mail-lf1-x133.google.com with SMTP id x33so18109915lfu.1; Sat, 23 Apr 2022 01:54:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=slEgsUhcpTsk6NTAyDsCJUv5IgUxOVRWBoNa+XCmx3I=; b=ZwJdeXcocc6D1JyXbcHLDqjWpcp+bA/N3hvB66GOHRE0JpLY/N8Mz7ZzM7jXDhcy3q zAOvMjl76rYYCRi6Ta/ONKiCKnxjzQsaIjk0Lj7LLGPFQw72TQAq3ocfnYkiaU2wAchX R00FDTmEx0dXWjRGwSr6BB6o+kJLt2cX8G/YOUCKFAoxdUS9oqyl8iez4CCadu8yo9gy HZMl8uF1hbR99bg4ZZuXny7ZZ4BfWLhkUn4G5GRDPAT9vdG/t0wCCT2WEpAurxa9l8Yu uFsVk00vTDeFhH1BZtf9f/TawQPQeQX7UQPZNbaSnnQ4Vo/hyLVluE4VsHlBweCWhLcm bdMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=slEgsUhcpTsk6NTAyDsCJUv5IgUxOVRWBoNa+XCmx3I=; b=KKPfd8OS2EwG4zmdEV5kOKqFSJJkEISx5l6tKxeH/huCTVBDLMhq1Q0PiY33n8cU59 jAFNf9EVkdqFTFqY1FPFOkEHYvflxUAu8YRFmoF3hXRse4C2uWmM63kEhaTSzd6kqgG5 TPcAEPRNIKKlTdbvKjEC9O8Ir8ObGcgm4AkRm0hXFA+nZkWB9hwbU40COIPHEUue5VAj NEq49CCaPd7VBimBPcET2cl8IHXmDWv9LiTy3s77gpKkETmcyAMNg0m4fUCiTjKGwQse IHKmRNO4qPh8X+68RxPNfYIOsTFPrjuxWjqHNncO+R7b87zw9mBVU53LRwUvZLFTRqxL NqKA== X-Gm-Message-State: AOAM531ivp6XSXt8BKbDrtpWWBGdvhx/CK7/5CoOxQfJK2CC/GmfMDSa B71Jif8L8qii+0xQANAE2RUVoOFOZvc= X-Google-Smtp-Source: ABdhPJwNhSN8/A9voPImEH0IkdCMBwsRTvFzmBnEB9GYBgpyngFstSVA7OvT8xMSOeIx1KxALpRJZg== X-Received: by 2002:a05:6512:39c1:b0:44a:e25d:47fd with SMTP id k1-20020a05651239c100b0044ae25d47fdmr6049463lfu.580.1650704045893; Sat, 23 Apr 2022 01:54:05 -0700 (PDT) Received: from nergzd-desktop.localdomain ([194.39.226.133]) by smtp.gmail.com with ESMTPSA id p25-20020a2e9a99000000b0024dc3ccff47sm493677lji.32.2022.04.23.01.54.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Apr 2022 01:54:05 -0700 (PDT) From: Markuss Broks To: linux-kernel@vger.kernel.org Cc: phone-devel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Markuss Broks , Matti Vaittinen , Lee Jones , Rob Herring , Krzysztof Kozlowski , Liam Girdwood , Mark Brown , MyungJoo Ham , Chanwoo Choi , devicetree@vger.kernel.org Subject: [PATCH v5 3/5] dt-bindings: mfd: Add bindings for Silicon Mitus SM5703 MFD Date: Sat, 23 Apr 2022 11:53:16 +0300 Message-Id: <20220423085319.483524-4-markuss.broks@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220423085319.483524-1-markuss.broks@gmail.com> References: <20220423085319.483524-1-markuss.broks@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This patch adds device-tree bindings for the Silicon Mitus SM5703 MFD. Signed-off-by: Markuss Broks Reviewed-by: Rob Herring --- .../bindings/mfd/siliconmitus,sm5703.yaml | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/siliconmitus,sm57= 03.yaml diff --git a/Documentation/devicetree/bindings/mfd/siliconmitus,sm5703.yaml= b/Documentation/devicetree/bindings/mfd/siliconmitus,sm5703.yaml new file mode 100644 index 000000000000..32197be57cce --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/siliconmitus,sm5703.yaml @@ -0,0 +1,84 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/siliconmitus,sm5703.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Silicon Mitus SM5703 multi-function device bindings + +maintainers: + - Markuss Broks + +description: | + Silicon Mitus SM5703 is a multi-function device, that consists of several + modules, designed for a mobile phone use. It consists of + LDO, Buck, USBLDO and VBUS regulators, a flash LED driver, a MUIC unit, + a fuel gauge and a battery charger circuit. The MUIC and Fuel-Gauge units + are separate from the main MFD, having their own i2c lines, while the + LED driver, regulators and charger are sharing the main i2c bus of the M= FD. + +properties: + compatible: + const: siliconmitus,sm5703 + + reg: + description: + I2C slave address. + maxItems: 1 + + regulators: + $ref: /schemas/regulator/siliconmitus,sm5703-regulator.yaml + description: + List of child nodes that specify the regulators. + + reset-gpios: + description: + GPIO which is connected to the MRSTB pin. + maxItems: 1 + +required: + - compatible + - reg + - regulators + - reset-gpios + +additionalProperties: false + +examples: + - | + #include + i2c { + #address-cells =3D <1>; + #size-cells =3D <0>; + pmic@49 { + compatible =3D "siliconmitus,sm5703"; + reg =3D <0x49>; + + reset-gpios =3D <&msmgpio 24 GPIO_ACTIVE_HIGH>; + pinctrl-0 =3D <&mrstb_default>; + + regulators { + sm5703_ldo1: ldo1 { + regulator-min-microvolt =3D <2800000>; + regulator-max-microvolt =3D <2800000>; + }; + + sm5703_ldo2: ldo2 { + regulator-min-microvolt =3D <1500000>; + regulator-max-microvolt =3D <3300000>; + }; + + sm5703_ldo3: ldo3 { + regulator-min-microvolt =3D <3300000>; + regulator-max-microvolt =3D <3300000>; + }; + + sm5703_usbldo1: usbldo1 { }; + + sm5703_usbldo2: usbldo2 { }; + + sm5703_vbus: vbus { }; + }; + }; + }; +... --=20 2.35.1 From nobody Fri May 15 08:28:38 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50608C433EF for ; Sat, 23 Apr 2022 08:54:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234337AbiDWI5P (ORCPT ); Sat, 23 Apr 2022 04:57:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234298AbiDWI5H (ORCPT ); Sat, 23 Apr 2022 04:57:07 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7146203F67; Sat, 23 Apr 2022 01:54:10 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id w1so18086144lfa.4; Sat, 23 Apr 2022 01:54:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=W6qCuitPyLRFBnKkAymetwVz/Zn3TWaD12IaOdxnPYw=; b=HaODXceUTqfkGe8AMJhIrEafalet+iDr/umX5kLoYL/RuK/hUsoVUoMlY1VErul5OH LQP/hDC3OhCRigrFJLEYSqhy8YrL3WcfqcJv6dtbZyqHP4DtJ5GNufv+0aYn5oiGMYpN iErEjSX8rf2VO/LeFiqb1umxyGFmLHwKOMpl0NAWVn3nJnUJ1i0yrbTr/HZI695AnriH slSmxnwfhYQka03rh9kvDPoDfgsKCIoI1PZ1kW+APBobjBd4edDQTp3z2101/K+A4vZP 3JoNUmAEgKeioEq/IkM/edY9LE2/ouARxS2n53QAWdbq470Uq3jqnF52PFfR7dvHuX3t IvuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=W6qCuitPyLRFBnKkAymetwVz/Zn3TWaD12IaOdxnPYw=; b=kleLcWwGlfBh9m40THsdhS5DJpFjQTAmpgeH4NHTXJDQxKu7s2ZKKHI1jZflkGwt3m K8cLYdfG1XDS8Qm4eKeCYEf11K1pHMcVzXRR+BEHIhyfBvuGu2ubNEZPwfKh6XcVcFv7 dXHKHQ0+4J0e+q+HrjDwWWl6qN1Nk1U+LPA2T5zc6x3QaSXfd2GTqO4GKZesuU81CA0o 4COoQTFAcKp06RkLNUrKb3WVnX0K33+r8umRbW0gD8fJpOFdA/ZClsUBSZ1qv7vBRhV3 nrJyWfe/vhMZdPLZA5bGS5sJfzAHpy+DkMvShWc5cdygVROxGvkDWl2i0mdzte93KlaM Kk0w== X-Gm-Message-State: AOAM5303DZUqe6oHPgtTojA+UsM/0s+k2i4y3IgpArdoR1QkOH4R67oV i0H2pl8aAz02rCsh7pGl5Tg+VJoCvZI= X-Google-Smtp-Source: ABdhPJxhfUvLh3ifqJqQFrXHCkmDsgHJD4DIe0WXzwTpSlD2MfhqLWfZv/yTA8tpHgt134BUHMjeTQ== X-Received: by 2002:a05:6512:1104:b0:471:8a5e:9981 with SMTP id l4-20020a056512110400b004718a5e9981mr6158518lfg.314.1650704048786; Sat, 23 Apr 2022 01:54:08 -0700 (PDT) Received: from nergzd-desktop.localdomain ([194.39.226.133]) by smtp.gmail.com with ESMTPSA id p25-20020a2e9a99000000b0024dc3ccff47sm493677lji.32.2022.04.23.01.54.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Apr 2022 01:54:08 -0700 (PDT) From: Markuss Broks To: linux-kernel@vger.kernel.org Cc: phone-devel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Markuss Broks , Matti Vaittinen , Lee Jones , Rob Herring , Krzysztof Kozlowski , Liam Girdwood , Mark Brown , MyungJoo Ham , Chanwoo Choi , devicetree@vger.kernel.org Subject: [PATCH v5 4/5] mfd: sm5703: Add support for SM5703 MFD Date: Sat, 23 Apr 2022 11:53:17 +0300 Message-Id: <20220423085319.483524-5-markuss.broks@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220423085319.483524-1-markuss.broks@gmail.com> References: <20220423085319.483524-1-markuss.broks@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Silicon Mitus SM5703 is a multi-function device, meant to be used in mobile devices. It has several modules: LDO, BUCK regulators, charger circuit, flash LED driver, a fuel gauge for monitoring the battery and a MUIC USB switcher. The MUIC and fuel gauge parts are separate in that they use separate i2c lines to communicate with the device, while charger circuit, LED driver and regulators are on the main i2c line the device is controlled with. Signed-off-by: Markuss Broks --- MAINTAINERS | 8 +++ drivers/mfd/Kconfig | 13 +++++ drivers/mfd/Makefile | 1 + drivers/mfd/sm5703.c | 78 +++++++++++++++++++++++++++ include/linux/mfd/sm5703.h | 105 +++++++++++++++++++++++++++++++++++++ 5 files changed, 205 insertions(+) create mode 100644 drivers/mfd/sm5703.c create mode 100644 include/linux/mfd/sm5703.h diff --git a/MAINTAINERS b/MAINTAINERS index 6157e706ed02..6125ed1a3be4 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -18172,6 +18172,14 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/g= it/paulmck/linux-rcu.git dev F: include/linux/srcu*.h F: kernel/rcu/srcu*.c =20 +SM5703 MFD DRIVER +M: Markuss Broks +S: Maintained +F: Documentation/devicetree/bindings/mfd/siliconmitus,sm5703.yaml +F: Documentation/devicetree/bindings/regulator/siliconmitus,sm5703-regulat= or.yaml +F: drivers/mfd/sm5703.c +F: drivers/regulator/sm5703-regulator.c + SMACK SECURITY MODULE M: Casey Schaufler L: linux-security-module@vger.kernel.org diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 3b59456f5545..c13a99ceae99 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -1237,6 +1237,19 @@ config MFD_SM501 interface. The device may be connected by PCI or local bus with varying functions enabled. =20 +config MFD_SM5703 + tristate "Silicon Mitus SM5703 MFD" + depends on I2C + depends on OF + select MFD_CORE + select REGMAP_I2C + help + This is the core driver for the Silicon Mitus SM5703 multi-function + device. This device is meant to be used in phones and it has numerous + modules, including LED controller, regulators, fuel gauge, MUIC and + charger circuit. It also support muxing a serial interface over USB + data lines. + config MFD_SM501_GPIO bool "Export GPIO via GPIO layer" depends on MFD_SM501 && GPIOLIB diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 858cacf659d6..ca8b86736a36 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -275,3 +275,4 @@ rsmu-i2c-objs :=3D rsmu_core.o rsmu_i2c.o rsmu-spi-objs :=3D rsmu_core.o rsmu_spi.o obj-$(CONFIG_MFD_RSMU_I2C) +=3D rsmu-i2c.o obj-$(CONFIG_MFD_RSMU_SPI) +=3D rsmu-spi.o +obj-$(CONFIG_MFD_SM5703) +=3D sm5703.o diff --git a/drivers/mfd/sm5703.c b/drivers/mfd/sm5703.c new file mode 100644 index 000000000000..7f9838149051 --- /dev/null +++ b/drivers/mfd/sm5703.c @@ -0,0 +1,78 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static const struct mfd_cell sm5703_devs[] =3D { + { .name =3D "sm5703-regulator", }, +}; + +static const struct regmap_config sm5703_regmap_config =3D { + .reg_bits =3D 8, + .val_bits =3D 8, +}; + +static int sm5703_i2c_probe(struct i2c_client *i2c, + const struct i2c_device_id *id) +{ + struct sm5703_dev *sm5703; + struct device *dev =3D &i2c->dev; + unsigned int dev_id; + int ret; + + sm5703 =3D devm_kzalloc(dev, sizeof(*sm5703), GFP_KERNEL); + if (!sm5703) + return -ENOMEM; + + i2c_set_clientdata(i2c, sm5703); + sm5703->dev =3D dev; + + sm5703->regmap =3D devm_regmap_init_i2c(i2c, &sm5703_regmap_config); + if (IS_ERR(sm5703->regmap)) + return dev_err_probe(dev, PTR_ERR(sm5703->regmap), + "Failed to allocate the register map\n"); + + sm5703->reset_gpio =3D devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(sm5703->reset_gpio)) + return dev_err_probe(dev, PTR_ERR(sm5703->reset_gpio), "Cannot get reset= GPIO\n"); + + gpiod_set_value_cansleep(sm5703->reset_gpio, 1); + msleep(20); + + ret =3D regmap_read(sm5703->regmap, SM5703_DEVICE_ID, &dev_id); + if (ret) + return dev_err_probe(dev, -ENODEV, "Device not found\n"); + + ret =3D devm_mfd_add_devices(sm5703->dev, -1, sm5703_devs, + ARRAY_SIZE(sm5703_devs), NULL, 0, NULL); + if (ret) + return dev_err_probe(dev, ret, "Failed to add child devices\n"); + + return 0; +} + +static const struct of_device_id sm5703_of_match[] =3D { + { .compatible =3D "siliconmitus,sm5703", }, + { } +}; +MODULE_DEVICE_TABLE(of, sm5703_of_match); + +static struct i2c_driver sm5703_driver =3D { + .driver =3D { + .name =3D "sm5703", + .of_match_table =3D sm5703_of_match, + }, + .probe =3D sm5703_i2c_probe, +}; +module_i2c_driver(sm5703_driver); + +MODULE_DESCRIPTION("Silicon Mitus SM5703 multi-function device driver"); +MODULE_AUTHOR("Markuss Broks "); +MODULE_LICENSE("GPL"); diff --git a/include/linux/mfd/sm5703.h b/include/linux/mfd/sm5703.h new file mode 100644 index 000000000000..c62affa0d3f1 --- /dev/null +++ b/include/linux/mfd/sm5703.h @@ -0,0 +1,105 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef _SM5703_H +#define _SM5703_H + +struct sm5703_dev { + struct device *dev; + struct regmap *regmap; + struct gpio_desc *reset_gpio; +}; + +// Regulator-related defines + +#define SM5703_REG_LDO1 0x1A +#define SM5703_REG_LDO2 0x1B +#define SM5703_REG_LDO3 0x1C +#define SM5703_LDO_EN BIT(3) +#define SM5703_LDO_VOLT_MASK 0x7 +#define SM5703_BUCK_VOLT_MASK 0x1F +#define SM5703_REG_USBLDO12 0x1C +#define SM5703_REG_EN_USBLDO1 BIT(6) +#define SM5703_REG_EN_USBLDO2 BIT(7) +#define SM5703_REG_BUCK 0x1D +#define SM5703_REG_EN_BUCK BIT(6) +#define SM5703_USBLDO_MICROVOLT 4800000 +#define SM5703_VBUS_MICROVOLT 5000000 + +// Fuel-Gauge-related defines + +#define SM5703_FG_REG_DEVICE_ID 0x00 +#define SM5703_FG_REG_CNTL 0x01 +#define SM5703_FG_REG_INTFG 0x02 +#define SM5703_FG_REG_INTFG_MASK 0x03 +#define SM5703_FG_REG_STATUS 0x04 +#define SM5703_FG_REG_SOC 0x05 +#define SM5703_FG_REG_OCV 0x06 +#define SM5703_FG_REG_VOLTAGE 0x07 +#define SM5703_FG_REG_CURRENT 0x08 +#define SM5703_FG_REG_TEMPERATURE 0x09 +#define SM5703_FG_REG_CURRENT_EST 0x85 +#define SM5703_FG_REG_FG_OP_STATUS 0x10 + +// Flash LED driver-related defines + +#define SM5703_FLEDCNTL1 0x14 +#define SM5703_FLEDCNTL2 0x15 +#define SM5703_FLEDCNTL3 0x16 +#define SM5703_FLEDCNTL4 0x17 +#define SM5703_FLEDCNTL5 0x18 +#define SM5703_FLEDCNTL6 0x19 + +#define SM5703_FLEDEN_MASK 0x03 +#define SM5703_FLEDEN_DISABLE 0x00 +#define SM5703_FLEDEN_MOVIE_MODE 0x01 +#define SM5703_FLEDEN_FLASH_MODE 0x02 +#define SM5703_FLEDEN_EXTERNAL 0x03 + +#define SM5703_IFLED_MASK 0x1F +#define SM5703_IMLED_MASK 0x1F + +// Charger-related, IRQ and device ID defines + +#define SM5703_REG_CNTL 0x0C +#define SM5703_VBUSCNTL 0x0D +#define SM5703_CHGCNTL1 0x0E +#define SM5703_CHGCNTL2 0x0F +#define SM5703_CHGCNTL3 0x10 +#define SM5703_CHGCNTL4 0x11 +#define SM5703_CHGCNTL5 0x12 +#define SM5703_CHGCNTL6 0x13 +#define SM5703_OTGCURRENTCNTL 0x60 +#define SM5703_Q3LIMITCNTL 0x66 +#define SM5703_DEVICE_ID 0x1E +#define SM5703_OPERATION_MODE 0x07 +#define SM5703_OPERATION_MODE_MASK 0x07 + +#define SM5703_OPERATION_MODE_SUSPEND 0x00 +#define SM5703_OPERATION_MODE_CHARGING_OFF 0x04 +#define SM5703_OPERATION_MODE_CHARGING_ON 0x05 +#define SM5703_OPERATION_MODE_FLASH_BOOST_MODE 0x06 +#define SM5703_OPERATION_MODE_USB_OTG_MODE 0x07 + +#define SM5703_BSTOUT 0x0F +#define SM5703_BSTOUT_MASK 0x0F +#define SM5703_BSTOUT_SHIFT 0 + +#define SM5703_BSTOUT_4P5 0x05 +#define SM5703_BSTOUT_5P0 0x0A +#define SM5703_BSTOUT_5P1 0x0B + +#define SM5703_IRQ_STATUS1 0x08 +#define SM5703_IRQ_STATUS2 0x09 +#define SM5703_IRQ_STATUS3 0x0A +#define SM5703_IRQ_STATUS4 0x0B +#define SM5703_IRQ_STATUS5 0x6B + +#define SM5703_STATUS1_OTGFAIL 0x80 +#define SM5703_STATUS3_DONE 0x08 +#define SM5703_STATUS3_TOPOFF 0x04 +#define SM5703_STATUS3_CHGON 0x01 +#define SM5703_STATUS5_VBUSOVP 0x80 +#define SM5703_STATUS5_VBUSUVLO 0x40 +#define SM5703_STATUS5_VBUSOK 0x20 + +#endif --=20 2.35.1 From nobody Fri May 15 08:28:38 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C689C433EF for ; Sat, 23 Apr 2022 08:54:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234342AbiDWI5T (ORCPT ); Sat, 23 Apr 2022 04:57:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234314AbiDWI5K (ORCPT ); Sat, 23 Apr 2022 04:57:10 -0400 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A63F203F7C; Sat, 23 Apr 2022 01:54:14 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id q14so12206835ljc.12; Sat, 23 Apr 2022 01:54:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KZJ4HXnnIxTILvPz6/GIc8z3KbhjSst2R2LjpPG4E2o=; b=P7IyKXk5NP7XMI0yDGvcibFg3bRkeidDhHJxpQyc6Qii1AznT5nUCZhsxcUDzZUwq7 yUNqk6qJVcUFVHWuNXS//qeR5GxXcMIccOKH0fW3NqiI3TTx5ocwTxhW4m9pxEo8INMz 3xrQ67RL1RH+f8ikQNj0hB570qIK+aRPOOm6K7OfMIxq9VoVTRmPw6hSi3/ckMO3J9a3 9F5rPMzSu7quCeKSSwtwp2bXwd6ICd9YKwHiLjwigYbOBqsSnxQKZ1JHqhkOA/Brqde+ uqiXRCyFS2EFFDwFVl/ByDZ7LcT7DACYXrLni3ctKmktdzcSf7tttcACRIb8Bes0ldny AbtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KZJ4HXnnIxTILvPz6/GIc8z3KbhjSst2R2LjpPG4E2o=; b=EEgqIP2QGYBDazwXiUMk2lcUmVfIv/Lf22Y1RbZ/cN88+YoBg5KKMLwh5YN5RWdhxU G3SCgBqg5dVHyte8JXywEQs3Djqi+XF1iSNoIoV3nhyCXFfz49oKf0lBtbnwfM7wyT3b 6VaMvqLJ/QIvpdDw1l0Tkbs7rMP7KmjhkBrzVsWRc7HbMNQPtlaxrcQ+F80ie1uIUMFZ t7cIuCeNjCH0wObfGxor7HeKkCccRlvHpqSRNmnNYu/yP+1GINl1vE9Gw91UF9UVXDiR HCWMv/K/8tJ7tUTfNZ+vg5p/BD0Nj1MIycV3hrmMMttpa3OVVy2gw5IMgx5Qfcb93GwE /I7g== X-Gm-Message-State: AOAM531uDstB+88tz2knPOL90rc+T8scQx4B3RyWHoONRAsi0bvRoivU GuKbEx7B+SSfAoQeV2tD4hyk1wgOo38= X-Google-Smtp-Source: ABdhPJzXwSEBT5cmAWstKOUWegjsaqN0jqe3LHTb9gOGGGKquET+O6BmqVBE2bjB5MIM1x13tOYIyQ== X-Received: by 2002:a2e:864d:0:b0:24d:bb90:153 with SMTP id i13-20020a2e864d000000b0024dbb900153mr5009063ljj.61.1650704052367; Sat, 23 Apr 2022 01:54:12 -0700 (PDT) Received: from nergzd-desktop.localdomain ([194.39.226.133]) by smtp.gmail.com with ESMTPSA id p25-20020a2e9a99000000b0024dc3ccff47sm493677lji.32.2022.04.23.01.54.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Apr 2022 01:54:12 -0700 (PDT) From: Markuss Broks To: linux-kernel@vger.kernel.org Cc: phone-devel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Markuss Broks , Matti Vaittinen , Lee Jones , Rob Herring , Krzysztof Kozlowski , Liam Girdwood , Mark Brown , MyungJoo Ham , Chanwoo Choi , devicetree@vger.kernel.org Subject: [PATCH v5 5/5] regulator: sm5703-regulator: Add regulators support for SM5703 MFD Date: Sat, 23 Apr 2022 11:53:18 +0300 Message-Id: <20220423085319.483524-6-markuss.broks@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220423085319.483524-1-markuss.broks@gmail.com> References: <20220423085319.483524-1-markuss.broks@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Regulators block of SM5703 controls several voltage regulators which are used to power various components. There are 3 LDO outputs ranging from 1.5 to 3.3V, a buck regulator ranging from 1V to 3V, two fixed voltage LDO regulators for powering the USB devices and one high-power fixed voltage LDO line (actually two lines) meant to power high-power USB devices. Signed-off-by: Markuss Broks --- drivers/regulator/Kconfig | 7 ++ drivers/regulator/Makefile | 1 + drivers/regulator/sm5703-regulator.c | 167 +++++++++++++++++++++++++++ 3 files changed, 175 insertions(+) create mode 100644 drivers/regulator/sm5703-regulator.c diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index a7effc57bbdb..cbe0f96ca342 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -1167,6 +1167,13 @@ config REGULATOR_SLG51000 The SLG51000 is seven compact and customizable low dropout regulators. =20 +config REGULATOR_SM5703 + tristate "Silicon Mitus SM5703 regulators" + depends on MFD_SM5703 + help + This driver provides support for voltage regulators of SM5703 + multi-function device. + config REGULATOR_STM32_BOOSTER tristate "STMicroelectronics STM32 BOOSTER" depends on ARCH_STM32 || COMPILE_TEST diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 69b5a196acd2..8d3ee8b6d41d 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -139,6 +139,7 @@ obj-$(CONFIG_REGULATOR_S5M8767) +=3D s5m8767.o obj-$(CONFIG_REGULATOR_SC2731) +=3D sc2731-regulator.o obj-$(CONFIG_REGULATOR_SKY81452) +=3D sky81452-regulator.o obj-$(CONFIG_REGULATOR_SLG51000) +=3D slg51000-regulator.o +obj-$(CONFIG_REGULATOR_SM5703) +=3D sm5703-regulator.o obj-$(CONFIG_REGULATOR_STM32_BOOSTER) +=3D stm32-booster.o obj-$(CONFIG_REGULATOR_STM32_VREFBUF) +=3D stm32-vrefbuf.o obj-$(CONFIG_REGULATOR_STM32_PWR) +=3D stm32-pwr.o diff --git a/drivers/regulator/sm5703-regulator.c b/drivers/regulator/sm570= 3-regulator.c new file mode 100644 index 000000000000..05ad28fc4da8 --- /dev/null +++ b/drivers/regulator/sm5703-regulator.c @@ -0,0 +1,167 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include +#include +#include +#include +#include +#include + +enum sm5703_regulators { + SM5703_BUCK, + SM5703_LDO1, + SM5703_LDO2, + SM5703_LDO3, + SM5703_USBLDO1, + SM5703_USBLDO2, + SM5703_VBUS, + SM5703_MAX_REGULATORS, +}; + +static const int sm5703_ldo_voltagemap[] =3D { + 1500000, 1800000, 2600000, 2800000, 3000000, 3300000, +}; + +static const int sm5703_buck_voltagemap[] =3D { + 1000000, 1000000, 1000000, 1000000, + 1000000, 1000000, 1000000, 1000000, + 1000000, 1000000, 1000000, 1100000, + 1200000, 1300000, 1400000, 1500000, + 1600000, 1700000, 1800000, 1900000, + 2000000, 2100000, 2200000, 2300000, + 2400000, 2500000, 2600000, 2700000, + 2800000, 2900000, 3000000, 3000000, +}; + +#define SM5703USBLDO(_name, _id) \ + [SM5703_USBLDO ## _id] =3D { \ + .name =3D _name, \ + .of_match =3D _name, \ + .regulators_node =3D "regulators", \ + .type =3D REGULATOR_VOLTAGE, \ + .id =3D SM5703_USBLDO ## _id, \ + .ops =3D &sm5703_regulator_ops_fixed, \ + .fixed_uV =3D SM5703_USBLDO_MICROVOLT, \ + .enable_reg =3D SM5703_REG_USBLDO12, \ + .enable_mask =3D SM5703_REG_EN_USBLDO ##_id, \ + .owner =3D THIS_MODULE, \ + } + +#define SM5703VBUS(_name) \ + [SM5703_VBUS] =3D { \ + .name =3D _name, \ + .of_match =3D _name, \ + .regulators_node =3D "regulators", \ + .type =3D REGULATOR_VOLTAGE, \ + .id =3D SM5703_VBUS, \ + .ops =3D &sm5703_regulator_ops_fixed, \ + .fixed_uV =3D SM5703_VBUS_MICROVOLT, \ + .enable_reg =3D SM5703_REG_CNTL, \ + .enable_mask =3D SM5703_OPERATION_MODE_MASK, \ + .enable_val =3D SM5703_OPERATION_MODE_USB_OTG_MODE, \ + .disable_val =3D SM5703_OPERATION_MODE_CHARGING_ON, \ + .owner =3D THIS_MODULE, \ + } + +#define SM5703BUCK(_name) \ + [SM5703_BUCK] =3D { \ + .name =3D _name, \ + .of_match =3D _name, \ + .regulators_node =3D "regulators", \ + .type =3D REGULATOR_VOLTAGE, \ + .id =3D SM5703_BUCK, \ + .ops =3D &sm5703_regulator_ops, \ + .n_voltages =3D ARRAY_SIZE(sm5703_buck_voltagemap), \ + .volt_table =3D sm5703_buck_voltagemap, \ + .vsel_reg =3D SM5703_REG_BUCK, \ + .vsel_mask =3D SM5703_BUCK_VOLT_MASK, \ + .enable_reg =3D SM5703_REG_BUCK, \ + .enable_mask =3D SM5703_REG_EN_BUCK, \ + .owner =3D THIS_MODULE, \ + } + +#define SM5703LDO(_name, _id) \ + [SM5703_LDO ## _id] =3D { \ + .name =3D _name, \ + .of_match =3D _name, \ + .regulators_node =3D "regulators", \ + .type =3D REGULATOR_VOLTAGE, \ + .id =3D SM5703_LDO ## _id, \ + .ops =3D &sm5703_regulator_ops, \ + .n_voltages =3D ARRAY_SIZE(sm5703_ldo_voltagemap), \ + .volt_table =3D sm5703_ldo_voltagemap, \ + .vsel_reg =3D SM5703_REG_LDO ##_id, \ + .vsel_mask =3D SM5703_LDO_VOLT_MASK, \ + .enable_reg =3D SM5703_REG_LDO ##_id, \ + .enable_mask =3D SM5703_LDO_EN, \ + .owner =3D THIS_MODULE, \ + } + +static const struct regulator_ops sm5703_regulator_ops =3D { + .enable =3D regulator_enable_regmap, + .disable =3D regulator_disable_regmap, + .is_enabled =3D regulator_is_enabled_regmap, + .list_voltage =3D regulator_list_voltage_table, + .get_voltage_sel =3D regulator_get_voltage_sel_regmap, + .set_voltage_sel =3D regulator_set_voltage_sel_regmap, +}; + +static const struct regulator_ops sm5703_regulator_ops_fixed =3D { + .enable =3D regulator_enable_regmap, + .disable =3D regulator_disable_regmap, + .is_enabled =3D regulator_is_enabled_regmap, +}; + +static struct regulator_desc sm5703_regulators_desc[SM5703_MAX_REGULATORS]= =3D { + SM5703BUCK("buck"), + SM5703LDO("ldo1", 1), + SM5703LDO("ldo2", 2), + SM5703LDO("ldo3", 3), + SM5703USBLDO("usbldo1", 1), + SM5703USBLDO("usbldo2", 2), + SM5703VBUS("vbus"), +}; + +static int sm5703_regulator_probe(struct platform_device *pdev) +{ + struct device *dev =3D &pdev->dev; + struct regulator_config config =3D { NULL, }; + struct regulator_dev *rdev; + struct sm5703_dev *sm5703 =3D dev_get_drvdata(pdev->dev.parent); + int i; + + config.dev =3D dev->parent; + config.regmap =3D sm5703->regmap; + + for (i =3D 0; i < SM5703_MAX_REGULATORS; i++) { + rdev =3D devm_regulator_register(dev, + &sm5703_regulators_desc[i], + &config); + if (IS_ERR(rdev)) + return dev_err_probe(dev, PTR_ERR(rdev), + "Failed to register a regulator\n"); + } + + return 0; +} + +static const struct platform_device_id sm5703_regulator_id[] =3D { + { "sm5703-regulator", 0 }, + {} +}; +MODULE_DEVICE_TABLE(platform, sm5703_regulator_id); + +static struct platform_driver sm5703_regulator_driver =3D { + .driver =3D { + .name =3D "sm5703-regulator", + }, + .probe =3D sm5703_regulator_probe, + .id_table =3D sm5703_regulator_id, +}; + +module_platform_driver(sm5703_regulator_driver); + +MODULE_DESCRIPTION("Silicon Mitus SM5703 LDO/Buck/USB regulator driver"); +MODULE_AUTHOR("Markuss Broks "); +MODULE_LICENSE("GPL"); --=20 2.35.1