From nobody Thu Jun 18 15:45:35 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 32094C433F5 for ; Tue, 19 Apr 2022 16:01:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354230AbiDSQEG (ORCPT ); Tue, 19 Apr 2022 12:04:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354214AbiDSQD5 (ORCPT ); Tue, 19 Apr 2022 12:03:57 -0400 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D14A62E9F5; Tue, 19 Apr 2022 09:01:14 -0700 (PDT) Received: by mail-lj1-x236.google.com with SMTP id 17so21143454lji.1; Tue, 19 Apr 2022 09:01: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=nFBsyQuHqlU/CZm7xcPsaJCJaO+7JVo6gg5hMfRKx4g=; b=hMxCBENOG8jL5pwFSK9fq0Z5vVD+/HwafWo+uqg9BoG1Ivt/Qf7Upub2jcngs+ufYw ys9QYpEWsrDc29GuuschUSNt5GquNx0ONSd0yO5HD66qYMzVW6K38nHYt5FPX5h29lMC MDB+fwkMVgUygK4CSkbC9siu8E0mDLg3gzItTxC2dH/q6CgA4Tfpi07K1v9N5hinn6gH s9mz2DEkpCON/DaRxySeG6D0Bp3ivbaqVOSvly3Xl0w1Y6iwkyX281Hm7FPDgft0Fha8 k8ZhrClk4jwrQlLgM7SKRu0BCT7nWn0Ckcqhj0+m25UnfoJY+SyEyWI/1ornxzkASANa oDmw== 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=nFBsyQuHqlU/CZm7xcPsaJCJaO+7JVo6gg5hMfRKx4g=; b=hG7Df0luViBZWhHdM3D1N+BuzzCECdm7FKf32I0bnBkO5dGQVz9PzVlogmnkn0umur /I0nWf4rBJha+KU1XnWJ0EECU9LaEF6WF3Q4lVjyNUOcwUhB6iFaOAvOYbCLtnJPBZb+ V6rp6ucQK46eS7rYaQVra3AoSVbctHh0DgXcYj5PkaQIinK9lHHPrSxmkQqns0bBcGl5 wRuy08NU7ov5aEhZKEkYtNzLBDGp0yJxf0mFp4x/QxM6LjDC73PrGPn+VlvGyLNQwraK P/jpq/SW70ZEC2+lafEvsYCMgd2HKqq+CPdOgPpAOuGh4YaKdUH5DQs4+tBAS7oMTLED tijQ== X-Gm-Message-State: AOAM530OcwGhJp3XNk55M8wP5hDCmr8qL0XKwMxF6WvrD98ofEvfEwv1 ztzA8Peq8QRc+GEoWpMfoQFI3vmJWvw= X-Google-Smtp-Source: ABdhPJzbiC75qP9ddf47DsjMflKY7gME8Bhgq6eUO+O5Guo3Ytvn61Kx0k3nGTbtuz+yIin4XqC6GQ== X-Received: by 2002:a2e:7f05:0:b0:24b:b6a:4e41 with SMTP id a5-20020a2e7f05000000b0024b0b6a4e41mr10377469ljd.210.1650384072887; Tue, 19 Apr 2022 09:01:12 -0700 (PDT) Received: from nergzd-desktop.localdomain ([194.39.226.133]) by smtp.gmail.com with ESMTPSA id m5-20020a194345000000b0046e951e34b3sm1506663lfj.24.2022.04.19.09.01.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 09:01: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 , Lee Jones , Rob Herring , Krzysztof Kozlowski , Liam Girdwood , Mark Brown , devicetree@vger.kernel.org Subject: [PATCH v4 1/4] dt-bindings: regulator: Add bindings for Silicon Mitus SM5703 regulators Date: Tue, 19 Apr 2022 19:00:54 +0300 Message-Id: <20220419160058.9998-2-markuss.broks@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220419160058.9998-1-markuss.broks@gmail.com> References: <20220419160058.9998-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 --- .../siliconmitus,sm5703-regulator.yaml | 52 +++++++++++++++++++ 1 file changed, 52 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..a8ffd3ecf3a5 --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/siliconmitus,sm5703-regul= ator.yaml @@ -0,0 +1,52 @@ +# 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: + compatible: + const: siliconmitus,sm5703-regulator + + buck: + type: object + $ref: regulator.yaml# + unevaluatedProperties: false + description: + Properties for the BUCK regulator. + + vbus: + type: object + $ref: regulator.yaml# + unevaluatedProperties: false + description: + Properties for the VBUS regulator. + +patternProperties: + "^ldo[1-3]$": + type: object + $ref: regulator.yaml# + unevaluatedProperties: false + description: + Properties for single LDO regulator. + + "^usbldo[1-2]$": + type: object + $ref: regulator.yaml# + unevaluatedProperties: false + description: + Properties for a single USBLDO regulator. + +additionalProperties: false --=20 2.35.1 From nobody Thu Jun 18 15:45:35 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 E4443C43217 for ; Tue, 19 Apr 2022 16:01:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354253AbiDSQEL (ORCPT ); Tue, 19 Apr 2022 12:04:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354210AbiDSQEC (ORCPT ); Tue, 19 Apr 2022 12:04:02 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF6BE329B9; Tue, 19 Apr 2022 09:01:17 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id x17so30195439lfa.10; Tue, 19 Apr 2022 09:01:17 -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=ehqNT/5oR3HuyIGR5JQZQmSZyCh8KRJVy0SP+2tgcek=; b=ktv9S+AC1qbbzGaNa/H0W3WNyE1ztLbef1s9HRlW/ZOei6J9xYTUCF5OYnZ3JPD9Q3 8lfQbwlLe4QkLTzjZgQ0b6zzRpgBupUKA5y8uQocF2Vi5bp3k350CD2TuUDCVa4rlxdP tYVHe/xtzvC5hRYOXdqBa+K8igOJaRdV5YuIbbyCZjDmOsZ8zAwan8ogd1pSjKhmrTPS Q+yvq04qgWvl6W2q6l5ctjcUu631ZeKxQYAUYRk7mH425MiNOsZnxUFCuTlurpSA+mQo vfvfZ38L9SJ/OH1X+HV/e8AzM0E6yIx7jNIbs19X0AHonlMrmjv66Bs6SwzIYHpfOq3z GqmA== 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=ehqNT/5oR3HuyIGR5JQZQmSZyCh8KRJVy0SP+2tgcek=; b=LcZaY24dv2bm2K3LizeSNV98lwkkrT40idI8Y9YuxHEdp0+UsmB4iRwXsaOTgWhjyq GfFchyAy4rnclcALkU3Wv+Yxi+4qlCNt9c/6ZVzPAjelqZsmL+D7KhwXW4tbPhWOc1UN Z5CsBJ0zbFZ6c3sw3x8ayWRjrA7IshtHXBtTlR0FoXhq7n4IHL87FBvT5R2sTo89bntX J8YCUT8fM5/ALSWwtqLjATT9hxIUACcls9MxR0eHVSjOFtrOPsK52kgPkmB0i/2AxUin ZvehMcdMfbEr6lyWKXPso1Pceu7yyxCkZ8V/qj5VBNz5ry73uszWe5EPBPtRLP4J74sb /KSg== X-Gm-Message-State: AOAM532FPUGXyOrG0qLLCcRuAtugL1VrCfHX9oyUxLbPpTiGyWOdIXHS +inlz/B2lDDmIJ4iMrIKfXfMYNxJx4U= X-Google-Smtp-Source: ABdhPJzwBapTROi0PkpUXr3uI4pW+2BLxbg8H5YAgnpuZZ7d0BpkyONRn5EkA7yGf9dMoUDVdJj4uA== X-Received: by 2002:ac2:4107:0:b0:44a:3084:39f8 with SMTP id b7-20020ac24107000000b0044a308439f8mr11380730lfi.209.1650384075957; Tue, 19 Apr 2022 09:01:15 -0700 (PDT) Received: from nergzd-desktop.localdomain ([194.39.226.133]) by smtp.gmail.com with ESMTPSA id m5-20020a194345000000b0046e951e34b3sm1506663lfj.24.2022.04.19.09.01.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 09:01:15 -0700 (PDT) From: Markuss Broks To: linux-kernel@vger.kernel.org Cc: phone-devel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Markuss Broks , Lee Jones , Rob Herring , Krzysztof Kozlowski , Liam Girdwood , Mark Brown , devicetree@vger.kernel.org Subject: [PATCH v4 2/4] dt-bindings: mfd: Add bindings for Silicon Mitus SM5703 MFD Date: Tue, 19 Apr 2022 19:00:55 +0300 Message-Id: <20220419160058.9998-3-markuss.broks@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220419160058.9998-1-markuss.broks@gmail.com> References: <20220419160058.9998-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 --- .../bindings/mfd/siliconmitus,sm5703.yaml | 96 +++++++++++++++++++ 1 file changed, 96 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..0d9de057a63b --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/siliconmitus,sm5703.yaml @@ -0,0 +1,96 @@ +# 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: + - | + 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>; + + regulator { + compatible =3D "siliconmitus,sm5703-regulator"; + + 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 { + regulator-min-microvolt =3D <4800000>; + regulator-max-microvolt =3D <4800000>; + }; + + sm5703_usbldo2: usbldo2 { + regulator-min-microvolt =3D <4800000>; + regulator-max-microvolt =3D <4800000>; + }; + + sm5703_vbus: vbus { + regulator-min-microvolt =3D <5000000>; + regulator-max-microvolt =3D <5000000>; + }; + }; + }; + }; + }; +... --=20 2.35.1 From nobody Thu Jun 18 15:45:35 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 B1B36C433F5 for ; Tue, 19 Apr 2022 16:01:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354249AbiDSQEO (ORCPT ); Tue, 19 Apr 2022 12:04:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354227AbiDSQED (ORCPT ); Tue, 19 Apr 2022 12:04:03 -0400 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E7102B18A; Tue, 19 Apr 2022 09:01:20 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id d6so12516511lfv.9; Tue, 19 Apr 2022 09:01:20 -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=Zu1iv2slDEmPJIqcluQVGAP7gHAtNvDuvYomfYWCtOo=; b=q0NtdYBfLAIIKf85yFs/Ci+NN8LumR5SSSMDzHe3owEE+SCV0UdJl4zaABGMFtMwjj uceXMI463bGHde+UJ5WWr2Ynv3kjdcplAfHU5UWIe+gI7Vv8GEV5+MoqJTKVP+TWFtqD e15xT+IfUCssNvKxG0mBWtRtjgD2u2Zw6ws7IgtUDnKmzfrsP75YVy7ajCFTedcRrfKi 6gsNTJdlVFa7GWzj4gx1+lD4lUMeN1TrZ+6eOZeNrUXK/Bxmu64HW22zzY3jmOqHh8NL kwYEv5VsRDrlK4D1dq4g/a2z4m6QSeFxLcTVZIm1GUgwqbIa77TFz8Xw4zpDFRutGW3l 9L0g== 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=Zu1iv2slDEmPJIqcluQVGAP7gHAtNvDuvYomfYWCtOo=; b=UzjW8I0fP/kLIzQLa5AHcFptHf8svrO3wko6DHoGpO9Vo/3V83Rokipjgp+nCvPm7t wYUUdylQJcU9qbYlyFkXsFUeP5T70RWmHvHDsZaYMVjt3OaW0QDHZIYulpcj8oD4WLw1 aHqIxVK24cYRPdQMfG9Yk6eyPb/jHZtZBlyeDLkYSM9UgUbvm7+ybsZxcnlylMWDQ3+O I6uJ3YGRK/+rcV6B/tXf8J2bBBYIOn15GfVumItrByDZU0gDCD+SYufYjb2nwYQuace3 eahWnZkOURHcJQLVjRcDn2LWFoIBEJ9ISMgL0lByHTi1qsUXagJfKa4Tx+M9IM8/qZpU f5Ow== X-Gm-Message-State: AOAM531GAqriLJY+Wr6eKzmw9MQSzm7ectE21enU3sTY0c2Ihd/ZbjE9 neUI2piVLYvjJ5AmTgpOA16jTy8iYW4= X-Google-Smtp-Source: ABdhPJzEp0NM8H3RasxFQRuD1D49myrkiJzljbjsoQNRmuACvwNfk1iD5lJa3JmIpyXn9LaWiKw5bA== X-Received: by 2002:ac2:4f03:0:b0:443:5d9d:819d with SMTP id k3-20020ac24f03000000b004435d9d819dmr11526394lfr.165.1650384078655; Tue, 19 Apr 2022 09:01:18 -0700 (PDT) Received: from nergzd-desktop.localdomain ([194.39.226.133]) by smtp.gmail.com with ESMTPSA id m5-20020a194345000000b0046e951e34b3sm1506663lfj.24.2022.04.19.09.01.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 09:01:18 -0700 (PDT) From: Markuss Broks To: linux-kernel@vger.kernel.org Cc: phone-devel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Markuss Broks , Lee Jones , Rob Herring , Krzysztof Kozlowski , Liam Girdwood , Mark Brown , devicetree@vger.kernel.org Subject: [PATCH v4 3/4] mfd: sm5703: Add support for SM5703 MFD Date: Tue, 19 Apr 2022 19:00:56 +0300 Message-Id: <20220419160058.9998-4-markuss.broks@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220419160058.9998-1-markuss.broks@gmail.com> References: <20220419160058.9998-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 | 12 +++++ drivers/mfd/Makefile | 1 + drivers/mfd/sm5703.c | 81 ++++++++++++++++++++++++++++ include/linux/mfd/sm5703.h | 105 +++++++++++++++++++++++++++++++++++++ 5 files changed, 207 insertions(+) create mode 100644 drivers/mfd/sm5703.c create mode 100644 include/linux/mfd/sm5703.h diff --git a/MAINTAINERS b/MAINTAINERS index 2a83ac6bfa4d..d3eef171eb8c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -17886,6 +17886,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 e0d2fcb10a0c..e553a8db24c2 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -1223,6 +1223,18 @@ 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 + 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 df1ecc4a4c95..3278069d3461 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..0eb6f257f109 --- /dev/null +++ b/drivers/mfd/sm5703.c @@ -0,0 +1,81 @@ +// 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", + .of_compatible =3D "siliconmitus,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-mfd", }, + { } +}; +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 Thu Jun 18 15:45:35 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 D2AF5C433F5 for ; Tue, 19 Apr 2022 16:01:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354263AbiDSQET (ORCPT ); Tue, 19 Apr 2022 12:04:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354239AbiDSQEH (ORCPT ); Tue, 19 Apr 2022 12:04:07 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3061C2ED59; Tue, 19 Apr 2022 09:01:23 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id w1so6821724lfa.4; Tue, 19 Apr 2022 09:01:23 -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=L/y6S893+XO+0gZ9aLfl1F/TXOKs2SRk/NNOfS2VZWA=; b=L6Xrcws7mv5iWGzTcwQt1oy4YLbU8Nz20TyX/ZAUlrbWOVriHNvSMp0U3uCsEWCgGI oljWmVv5a7O2HWKzQO7sUAHre0yA4xsoZNPJqAn5kd3BwgRwF54EjQiW2DOR+hDxYrXu S+rysK5UYrig2DcGdhxIvnAGmj6Kx2i1jsmInJgtgPWSZ1E6fv9oOICvcchUAnycwA5v PS0zoFlzIgQdENDMcIxIzyxPLKovYRc9+UR6sdbV+8+uOAjoNoJdDAUPyVSgUBfbP50O bvGpJPovzHSzqrcgS7XyX10rtmLD4TMO2HDBdT4RaOai6ICWsMgCzcdr0+3vLYutu7lW n7Fw== 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=L/y6S893+XO+0gZ9aLfl1F/TXOKs2SRk/NNOfS2VZWA=; b=S7TVTHXN4rDAQfY2G8DkmOBOPZYzJcKev0bfLn5nuSw70HGh47hxx8/Xghk75yDrk9 z3ZtIe8HtwvyD/BDONeyDYR5wAYHwa7fl2reQeqBrQk72VOMwnbUKtQKhzbqnPThAU7G XNtczKnHHK3B7Q5/oQZpDxHpPkcGn0UNEgCw5M6fFFoRYaDgT9U3aXcCV7nNkGytVojn w1iCM9AlX3xJsOMcGGdXn7SS0VgHrYOtKdJxF0T0rnSCMVBs/EinSVcl66xnD44x3A0o y6RmZp2M0ileTZSqW/otDJbJNwfakGTrZi2zEm8uvURDjANB11F15eCVsfrIx57QdsEz HYmA== X-Gm-Message-State: AOAM530Nu4Zdy9sd2TDBgrAJbcZDipHe+i7zWc7ATpgE4rzsfzxmSEBV OXe6u4aGf2j4lCOg11Zero1MWrN2+wQ= X-Google-Smtp-Source: ABdhPJzvpqny8HulxrTSWCGLhi86vsmekYQaRbaz9XUtUO4ADQsdDbofYZBGxVy6mZHzrqsH7+9TgQ== X-Received: by 2002:a05:6512:1290:b0:471:90ee:b265 with SMTP id u16-20020a056512129000b0047190eeb265mr7391662lfs.668.1650384081544; Tue, 19 Apr 2022 09:01:21 -0700 (PDT) Received: from nergzd-desktop.localdomain ([194.39.226.133]) by smtp.gmail.com with ESMTPSA id m5-20020a194345000000b0046e951e34b3sm1506663lfj.24.2022.04.19.09.01.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 09:01:21 -0700 (PDT) From: Markuss Broks To: linux-kernel@vger.kernel.org Cc: phone-devel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Markuss Broks , Lee Jones , Rob Herring , Krzysztof Kozlowski , Liam Girdwood , Mark Brown , devicetree@vger.kernel.org Subject: [PATCH v4 4/4] regulator: sm5703-regulator: Add regulators support for SM5703 MFD Date: Tue, 19 Apr 2022 19:00:57 +0300 Message-Id: <20220419160058.9998-5-markuss.broks@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220419160058.9998-1-markuss.broks@gmail.com> References: <20220419160058.9998-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 | 162 +++++++++++++++++++++++++++ 3 files changed, 170 insertions(+) create mode 100644 drivers/regulator/sm5703-regulator.c diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 5d0a360d7244..318bbdc27ae4 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -1147,6 +1147,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 SM5703_MFD + 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 4b8794a73e17..c491fe528ba4 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -137,6 +137,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..41004de69887 --- /dev/null +++ b/drivers/regulator/sm5703-regulator.c @@ -0,0 +1,162 @@ +// 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_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_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 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; + config.of_node =3D dev->of_node; + 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