From patchwork Mon Oct 7 14:49:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 833816 Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (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 797D41D7E3D; Mon, 7 Oct 2024 14:50:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728312614; cv=none; b=BAKZXn9tJZE7EWdQmnUlSt/TnJ5OlhLRjKH9ijzvs2hhrANqYLBazDI82lCPJKzp2YqzKXnUbPWtdm3xkqqmJ8HQvyUeteP1wzsER/0tGPLPSYAy1faWcZTm4/ajzFIPp+zKiTM4mEsSYt6zH+HrWOoPfO2D1B/KR9IAejonqgE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728312614; c=relaxed/simple; bh=xaOvS2+nFbFXgLVWGRgfJSXilelrhfer00Wh/eYX/Zw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=L2gK0hrNAK/+Wf3N3U/Nx0L0KpLp5eB6U4oBexElvC6FOzVR60wsNqFgvCibXYbblMLb/9iJPYIwp2Oj5mgs/ORTgWB3umSGvlXw9eAr9Rm+Vh/O0uBzUy7W5qcsJaFDaY35vm2rCX8VQxb4uz8qMUnUvQ/dLl+EARqzCYcFspU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=j/ck+pfl; arc=none smtp.client-ip=209.85.208.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="j/ck+pfl" Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-2fac49b17ebso34417231fa.0; Mon, 07 Oct 2024 07:50:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728312610; x=1728917410; 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=bKqa5VofnGcmBjBaWkd+jJmfVqq2+bq+aGP5sPNNSbg=; b=j/ck+pflRsMcXI8GS+wTgkp4zsY8GNt/K0Ibx2XOMu7rpDBsEbmQWIxRiiQ1DLdwgv hXFhGh1lXHKMItOxEuYakSkZAz5tIfGDQwD0MFU4PG5qQLgNDC0jZqwnrfM/WLTjG+d9 0/E4mK2j+baMFqGVVLoEjUOxL6RAh4xxPE4N0uh/MC5qFo5xxK6yyJ0XS5MeDPN4l/0P J0ZHlKb8lBIiQmmFH9esdkidhIfCY/9zHflIVEiHUxhhtknjCyVpyDP7B/loOq+Z5ea+ AFCcDvJApHZrJKYIL2Eq3I0MZYkI6dpRIStUuKlNZ1anjQDdqzsHvlJ3WtVdTmJo0jlv sohQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728312610; x=1728917410; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bKqa5VofnGcmBjBaWkd+jJmfVqq2+bq+aGP5sPNNSbg=; b=RMm6ktB0IqYZyv3NTS15IzpAWPp+KPm+Q7wRuilg3QDWlUx00JicTiAptUfSynKIsm sVVFfS4pv012JPkzLEjs9CcgA59ZkAlP0fTgHp7YuhOq3kmyP2rUPYeYT+7m1s1R9Jk3 rRbez5rK5zsY4ijdiQNujd2SITF42jV8DQAsffWvrpvemsQZ3RIGkM8I62JYPW40AhIT ZyOVAnCaeGoDtqOR6MYpnuzOgi5dZa0S8iv75xi1JXtVP1gYCankGMqzzLbLPKmQI1vR dBfFbTJIQRUGUiYMkLQ3k6W6Do+KFhmlY/bWj/nshV4XDhyneL92FWPpfWqhFjkTZpYy PspA== X-Forwarded-Encrypted: i=1; AJvYcCVX2Fe72RdSWMNYQ0q+XSqImy4I3mCl2pHjKmj+oNt5YH5DyeuF5V7Ig86Fd8rXyLemJvbna1hOHaQsqROsRIMEOi8=@vger.kernel.org, AJvYcCVqR6j2v+whsoDbbCDg3j/zb7S/olo2UPfiK4Vl+Fe5lkN6cWEt9lVuJUs3fTzkQ5mnB8+vZ65APvv9@vger.kernel.org X-Gm-Message-State: AOJu0YzXRbRY9tWea94LqqVcJQGit/Biv/K7T6bfk7WOGtzyxhGacbiL 7mvkjc+Vkpl2Z4twxM6+HFAF9t+Ng4NQXDGJs4dehcVgnCni/38o X-Google-Smtp-Source: AGHT+IFJ9n5L/hLCUECObP7MCrTMBXkI/9LWg/yjwQjx4XP4KcNdnAxkRYHDYTXN+wbc+8aKrGlzyQ== X-Received: by 2002:a2e:bc1a:0:b0:2fa:e4d0:eb61 with SMTP id 38308e7fff4ca-2faf3d74dbcmr63548711fa.32.1728312610316; Mon, 07 Oct 2024 07:50:10 -0700 (PDT) Received: from [127.0.1.1] (nat6-minsk-pool-46-53-210-75.telecom.by. [46.53.210.75]) by smtp.googlemail.com with ESMTPSA id 38308e7fff4ca-2faf9ac43efsm8253791fa.45.2024.10.07.07.50.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2024 07:50:09 -0700 (PDT) From: Dzmitry Sankouski Date: Mon, 07 Oct 2024 17:49:59 +0300 Subject: [PATCH v6 1/3] dt-bindings: mfd: add samsung,s2dos05 Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241007-starqltechn_integration_upstream-v6-1-264309aa66de@gmail.com> References: <20241007-starqltechn_integration_upstream-v6-0-264309aa66de@gmail.com> In-Reply-To: <20241007-starqltechn_integration_upstream-v6-0-264309aa66de@gmail.com> To: Krzysztof Kozlowski , Lee Jones , Rob Herring , Conor Dooley , Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, devicetree@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1728312606; l=4538; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=xaOvS2+nFbFXgLVWGRgfJSXilelrhfer00Wh/eYX/Zw=; b=OPPE07j0Vdd6AbbC7QwIPKaGBRLk1axz4cCK3c8k4QMlytP4sSCb2hZs2AbsWVfygyMM7H1Nj zvJiLcp/DqtA9DePD6RfvjAp71yDfNBa5VGxOwklpUlL4gCVT4UJE9d X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Add samsung,s2dos05 MFD module binding. Reviewed-by: Krzysztof Kozlowski Signed-off-by: Dzmitry Sankouski --- Changes in v4: - split long(>80) lines - fix indentation - merge with regulators binding - drop pmic suffix - drop unused labels in example - correct description Changes in v5: - simplify regulator-name in examples - remove index from single buck regulator - fix example indentation - replace example hex numbers to decimal --- Documentation/devicetree/bindings/mfd/samsung,s2dos05.yaml | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 2 +- 2 files changed, 100 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/mfd/samsung,s2dos05.yaml b/Documentation/devicetree/bindings/mfd/samsung,s2dos05.yaml new file mode 100644 index 000000000000..b85285720c16 --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/samsung,s2dos05.yaml @@ -0,0 +1,99 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/samsung,s2dos05.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Samsung S2DOS05 Power Management IC + +maintainers: + - Dzmitry Sankouski + +description: + This is a device tree bindings for S2DOS family of Power Management IC (PMIC). + + The S2DOS05 is a companion power management IC for the panel and touchscreen + in smart phones. Provides voltage regulators and + ADC for power/current measurements. + + Regulator section has 4 LDO and 1 BUCK regulators and also + provides ELVDD, ELVSS, AVDD lines. + +properties: + compatible: + const: samsung,s2dos05 + + reg: + maxItems: 1 + + regulators: + patternProperties: + "^buck|ldo[1-4]$": + type: object + $ref: /schemas/regulator/regulator.yaml# + unevaluatedProperties: false + + required: + - regulator-name + + additionalProperties: false + +required: + - compatible + - reg + - regulators + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + pmic@60 { + compatible = "samsung,s2dos05"; + reg = <0x60>; + + regulators { + ldo1 { + regulator-active-discharge = <1>; + regulator-min-microvolt = <1500000>; + regulator-max-microvolt = <2000000>; + regulator-name = "ldo1"; + }; + + ldo2 { + regulator-active-discharge = <1>; + regulator-boot-on; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-name = "ldo2"; + }; + + ldo3 { + regulator-active-discharge = <1>; + regulator-boot-on; + regulator-min-microvolt = <3000000>; + regulator-max-microvolt = <3000000>; + regulator-name = "ldo3"; + }; + + ldo4 { + regulator-active-discharge = <1>; + regulator-min-microvolt = <2700000>; + regulator-max-microvolt = <3775000>; + regulator-name = "ldo4"; + }; + + buck { + regulator-active-discharge = <1>; + regulator-min-microvolt = <850000>; + regulator-max-microvolt = <2100000>; + regulator-name = "buck"; + }; + }; + }; + }; + +... diff --git a/MAINTAINERS b/MAINTAINERS index 84086d47db69..ae6564d98caa 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20475,7 +20475,7 @@ L: linux-samsung-soc@vger.kernel.org S: Maintained B: mailto:linux-samsung-soc@vger.kernel.org F: Documentation/devicetree/bindings/clock/samsung,s2mps11.yaml -F: Documentation/devicetree/bindings/mfd/samsung,s2m*.yaml +F: Documentation/devicetree/bindings/mfd/samsung,s2*.yaml F: Documentation/devicetree/bindings/mfd/samsung,s5m*.yaml F: Documentation/devicetree/bindings/regulator/samsung,s2m*.yaml F: Documentation/devicetree/bindings/regulator/samsung,s5m*.yaml From patchwork Mon Oct 7 14:50:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 833505 Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (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 7B7C51D89F2; Mon, 7 Oct 2024 14:50:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728312617; cv=none; b=pwwCNFfo6gsKIVSVO2itbBkMVzxbJQsbOTrTkC0vreFYazs7QdJNCcS4eysEqBCb2rorUQByWzKJFFBbJQYYRQhfWUTuFPGdl37wn7/GjXuQA76GoQgR5uj9SifvyNhESlt8NegFg3mnFw6VV4aqFD6B+wZiLufuS6p1aLFTO7I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728312617; c=relaxed/simple; bh=+y5dIaEAV6sUyjaV2E2BF1doVtTB4Tk8i4VgnMDtrGQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EDRxwFesX3sr7L0bsbTCbVxrkyckNM/1xbiC9XeeyYiQhLS6LxzNUiYCfoWOTPEjfXEGukiIxpqQET2RbdUXklC5gqbfNWZ4dfzxYQN0JKPP1VhWNqe5HdN4YsFtU4wlRQ8zEPF//Us17UW8y1iEUxJNq4b7n4l/2cvIYpBr+O0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LlVIeZZl; arc=none smtp.client-ip=209.85.208.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LlVIeZZl" Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-2fadc95ccfcso48832071fa.1; Mon, 07 Oct 2024 07:50:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728312613; x=1728917413; 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=lDocX/tVZKzpPZS+CkRFcDMxBjoP9yU3G0DgObObyyM=; b=LlVIeZZljbUoghUs0xD1VRPwvygB13CA25JOocGS3H1nfhU6k+qEDqYvc//GkU4l/j opZ3stnDtzc49kmyg6YsIvnfUKlPYiBhcyappQODGl510mtsG2VAD4V6US5OaID5SFWu mBChn1/sFYsHG+sYGyJrcq3EfaK1l97AJY5jYDNw8j8YoOFoGL94vXgfZos8FKKmn2O4 /EtP4CWF53J6aBwSb0UL1t00OOdlQaeEbJi5qLqM2jxwKjTdGDbHvHVZtzLJ8lbDH1QS Etlkc1p44SmzikvGO/I8iGq6quT2ZlbD0nSHE5V8AE83Y5diZ1J+cuhJzu8SyrzYTK6p dCAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728312613; x=1728917413; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lDocX/tVZKzpPZS+CkRFcDMxBjoP9yU3G0DgObObyyM=; b=K4QhQHrMcu/wdkLRvUeMSpj/XnnMkaGudIUqJ8sRAtxqYo31PYm8Kx8nTmO/msYk8i XzC7nHlVOVNzMo4Vy/sgZ+8qdHX6ZEtBCXkujfLaMwq5EC0SdRW/6Tl/6vK2paVBKXas IhxyRCrKqsl7dUnzWG0Ac9EOjuY+edqNa7IxRzFWqx1RLOz3tvUSBzm7XSrUY+f5mn+U xx8INU35VSs4K6X29llaNyr1YB0n+Xy4YLqN5MWUFl14oXt4rb1YzBFG60kM6YuSba43 CKfGGrIoiWgzTsaYV9RQRUHJJwRZpEExDJDGeCEa54KvIlwJn/H1y8cnrNRK4d8aroYG FA+A== X-Forwarded-Encrypted: i=1; AJvYcCUPMhmUMsr1euKdyTBQ4ruxr9A4REZvo8L/fNxvO5IRR82PJmFsA70/XuPMBloZqGIkGnsWJSY/qsO4@vger.kernel.org, AJvYcCXD37eHKao3qQcL59JaaYz2W/eBx22PcKhImu8XlSY01ydaXaL+9WZQBeBQTq0sHePLSoGcKCzp6eg2uOsLwPRfVKY=@vger.kernel.org X-Gm-Message-State: AOJu0Ywuv3XXUywFEGknGZm69hj1p0W/n/Eqkb9cnLmck9ltP43XBJup TJd8YrY2hv8wC4sx/yRpyeqO7QCwOil4ziAXiWtaYgLbQ8uKRwYx X-Google-Smtp-Source: AGHT+IE1wTun3BlEhls/HrIoAEc5IykdXHZX8OtwtecW1hVoMo0D7nqzRnC9vqdvyTiSlyGcIikjqw== X-Received: by 2002:a2e:be8e:0:b0:2fa:bc65:f91a with SMTP id 38308e7fff4ca-2faf3c50826mr56643581fa.8.1728312613337; Mon, 07 Oct 2024 07:50:13 -0700 (PDT) Received: from [127.0.1.1] (nat6-minsk-pool-46-53-210-75.telecom.by. [46.53.210.75]) by smtp.googlemail.com with ESMTPSA id 38308e7fff4ca-2faf9ac43efsm8253791fa.45.2024.10.07.07.50.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2024 07:50:12 -0700 (PDT) From: Dzmitry Sankouski Date: Mon, 07 Oct 2024 17:50:00 +0300 Subject: [PATCH v6 2/3] mfd: sec-core: add s2dos05 support Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241007-starqltechn_integration_upstream-v6-2-264309aa66de@gmail.com> References: <20241007-starqltechn_integration_upstream-v6-0-264309aa66de@gmail.com> In-Reply-To: <20241007-starqltechn_integration_upstream-v6-0-264309aa66de@gmail.com> To: Krzysztof Kozlowski , Lee Jones , Rob Herring , Conor Dooley , Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, devicetree@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1728312606; l=2079; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=+y5dIaEAV6sUyjaV2E2BF1doVtTB4Tk8i4VgnMDtrGQ=; b=QW8hGmEnQreU4wFU+ny2CCfPxHvP71oOmBXjZSdciCpqm8c+V4d6Kxk5QwQ4iqIjATiMN4h5n nSqI8LsR0tiCVcGSj8MedSMVYjtcUSHKeX5DtR9Jun6FnQX5BAz61Sf X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= S2DOS05 is a panel/touchscreen PMIC, often found in Samsung phones. We define regulator sub-device for which driver will be added in subsequent patch. The device also has ADC for power and current measurements. Reviewed-by: Krzysztof Kozlowski Signed-off-by: Dzmitry Sankouski --- Changes in v5: - fix commit description: S2DOS05 in capital letters - fix commit description: only 1 sub device will be added in subsequent patches. --- drivers/mfd/sec-core.c | 11 +++++++++++ include/linux/mfd/samsung/core.h | 1 + 2 files changed, 12 insertions(+) diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c index a6b0d7300b2d..cdfe738e1d76 100644 --- a/drivers/mfd/sec-core.c +++ b/drivers/mfd/sec-core.c @@ -34,6 +34,10 @@ static const struct mfd_cell s5m8767_devs[] = { }, }; +static const struct mfd_cell s2dos05_devs[] = { + { .name = "s2dos05-regulator", }, +}; + static const struct mfd_cell s2mps11_devs[] = { { .name = "s2mps11-regulator", }, { .name = "s2mps14-rtc", }, @@ -83,6 +87,9 @@ static const struct of_device_id sec_dt_match[] = { { .compatible = "samsung,s5m8767-pmic", .data = (void *)S5M8767X, + }, { + .compatible = "samsung,s2dos05", + .data = (void *)S2DOS05, }, { .compatible = "samsung,s2mps11-pmic", .data = (void *)S2MPS11X, @@ -339,6 +346,10 @@ static int sec_pmic_probe(struct i2c_client *i2c) sec_devs = s5m8767_devs; num_sec_devs = ARRAY_SIZE(s5m8767_devs); break; + case S2DOS05: + sec_devs = s2dos05_devs; + num_sec_devs = ARRAY_SIZE(s2dos05_devs); + break; case S2MPA01: sec_devs = s2mpa01_devs; num_sec_devs = ARRAY_SIZE(s2mpa01_devs); diff --git a/include/linux/mfd/samsung/core.h b/include/linux/mfd/samsung/core.h index a212b9f72bc9..750274d41fc0 100644 --- a/include/linux/mfd/samsung/core.h +++ b/include/linux/mfd/samsung/core.h @@ -37,6 +37,7 @@ struct gpio_desc; enum sec_device_type { S5M8767X, + S2DOS05, S2MPA01, S2MPS11X, S2MPS13X, From patchwork Mon Oct 7 14:50:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 833815 Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) (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 CB3E01D8E01; Mon, 7 Oct 2024 14:50:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728312620; cv=none; b=FQGqMTQntNeBD5SQRrM2h42XuSaH+P7tvmDcPomGY/XXaBPgl63fXPU+UxqiD7K7Skonpl+bJ+i4mqOvqwFQgjsf9fX2vV26VKfuAuhN6OYWa1GcSkJqHDbaJH7aVKoVboAfVvI0EHriCZfZXD331KGPXtfxBcvO8cheksKRVuE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728312620; c=relaxed/simple; bh=NhxgGjeNcsW6P39YuGAJn7dDa+ATHQifvvojjoLeFfo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=p0z96bXMa+/6dxdoWQuvF+/GllLv3f24uORQYpMvVdSGGAB4LhjxCX9QLRCj9+Yoln4bGH3XzLa034Th8Y3yQdyFIjQEkcAX28u6kaW7lYI+ojlYpX3HX08d10lvZFRwEMq1V3h+o7Jg1vbGTjVEp3o6VI28spvXP6T8UjByv/M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dZ1TNp8w; arc=none smtp.client-ip=209.85.208.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dZ1TNp8w" Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-2fac275471dso44664071fa.0; Mon, 07 Oct 2024 07:50:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728312616; x=1728917416; 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=Hibd9kAJI10LdRWZFxNvdTKm1ULS6Gq+SCUdqm8ZQYs=; b=dZ1TNp8wqjGlkdlrgZkhVPQ/fm8eW31nu1Y3Bkh6Mq1jG9xbgeKpj7lIkbKV8gj5Y3 mo4dudrCGJQWVrbVgkSEeFgGXMXf8gVE3B1zlMdylsCJr7rdx3+Nj7uU4R2ui+AEvyUj 5YbWePF5io8MCPd+/QtFFA4KopJFtXIhBMCZHu0vziwGzhgU69J1plWWlxRcFMfI2J3x Bh6vdc2qcDL/gcEw24ABXw4gFAOBRTJhx2xMcGX4TgHqgnUrflvtQS84o13hEG6Wm+No YlrKMkTNQ2saHEE48CmnZ/aE4xVU6Z3eewiye+T14+RNCv+h6U/tJBdo9VZvhd5yGd4l KNSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728312616; x=1728917416; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Hibd9kAJI10LdRWZFxNvdTKm1ULS6Gq+SCUdqm8ZQYs=; b=q+9TST/y15oiP2CpRTSpTOUo9KKpkyJLhwqSnG3bJ26ydiYylxWjza5KMPOba2CkhY D2sCaKVDZ0tY63mLBqEo+3hUKJK3HPIwrJxSrHOpqkdV0J3pqRMK8cnHSaTB04EPHV84 gp/9dP8MZ3fY40O69F5suK59AuOQnp1r0MNV0YicozoOSrtV2jbFNjGLvp0W+9MNlqQC np4lnjhaJ5FyR2tJhvV8uLgv6kgNq3smL/fv9BL/m2z5ODi5f2fd780UhBN4X6vhNagB AJIU91DfDRkQC/zuj6pxKjxVU/u5HghoWCZP+MV0ksgNVNoMSV9AD8S69RC4oUUqfEeS KnkQ== X-Forwarded-Encrypted: i=1; AJvYcCUc+4ODM4LTMaH0nOBzdClrBPp5oDc+FumK/3lMyiZ8GJNkkMTLrLPel9wvXMzqex8wJf9iumD1Ca1s@vger.kernel.org, AJvYcCWmwqhUEMksIZBPEdw/KhFJNnmJcph4cU4jazs/Wsvg9Pzp0o9sgb0DEc5lCADYPw6CM95gBZqL9EE3ipdQoR562Pc=@vger.kernel.org X-Gm-Message-State: AOJu0YzR/NEH1BDVfztGFnenqit7gvZj/UtEzuETIEa3N3wVFZMdccXb LvX8CxSI+BpBfZ1iXXu4pFnKWbXl2mYgDYIWh7jLCEsvEnNdopxG X-Google-Smtp-Source: AGHT+IE56th218ihJFVz0w3AiIk9rGOQwcIPdWC5mqHmQYKh6WMNrZFC6qVX25dBxEauKiVEDt2HCA== X-Received: by 2002:a05:651c:508:b0:2fa:f3b6:a05a with SMTP id 38308e7fff4ca-2faf3b6a147mr44645101fa.14.1728312615534; Mon, 07 Oct 2024 07:50:15 -0700 (PDT) Received: from [127.0.1.1] (nat6-minsk-pool-46-53-210-75.telecom.by. [46.53.210.75]) by smtp.googlemail.com with ESMTPSA id 38308e7fff4ca-2faf9ac43efsm8253791fa.45.2024.10.07.07.50.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2024 07:50:15 -0700 (PDT) From: Dzmitry Sankouski Date: Mon, 07 Oct 2024 17:50:01 +0300 Subject: [PATCH v6 3/3] regulator: add s2dos05 regulator support Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241007-starqltechn_integration_upstream-v6-3-264309aa66de@gmail.com> References: <20241007-starqltechn_integration_upstream-v6-0-264309aa66de@gmail.com> In-Reply-To: <20241007-starqltechn_integration_upstream-v6-0-264309aa66de@gmail.com> To: Krzysztof Kozlowski , Lee Jones , Rob Herring , Conor Dooley , Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, devicetree@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1728312606; l=11137; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=NhxgGjeNcsW6P39YuGAJn7dDa+ATHQifvvojjoLeFfo=; b=zMgL7RTQIfNUjHFucpRwbPflXZnxbtzs1IalgMkVBathiiu28TL/j/MwvcsHKinsxhK1lYc4v RA8V5yYMqr1AT9Q74+PVG7k9/phJka7xGkhlrEcLgasYjLft1vkBuvs X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= S2DOS05 has 1 buck and 4 LDO regulators, used for powering panel/touchscreen. Signed-off-by: Dzmitry Sankouski Reviewed-by: Mark Brown --- Changes in v6: - run sparse and smatch - initialize ret variable Changes in v5: - fix Kconfig and module description to be the same - make regulators const - code refactoring - replace s2m* pattern on s2* to include s2dos05 Changes in v4: - remove excessive linux/module.h import - use generic regulator helpers - use of_match - use devm_* for mem allocations - use // style comment - drop all junk Samsung code - adjust to depend on sec-core --- MAINTAINERS | 2 +- drivers/regulator/Kconfig | 8 +++++ drivers/regulator/Makefile | 1 + drivers/regulator/s2dos05-regulator.c | 176 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/regulator/s2dos05.h | 73 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 259 insertions(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index ae6564d98caa..ae9c62ff3027 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20481,7 +20481,7 @@ F: Documentation/devicetree/bindings/regulator/samsung,s2m*.yaml F: Documentation/devicetree/bindings/regulator/samsung,s5m*.yaml F: drivers/clk/clk-s2mps11.c F: drivers/mfd/sec*.c -F: drivers/regulator/s2m*.c +F: drivers/regulator/s2*.c F: drivers/regulator/s5m*.c F: drivers/rtc/rtc-s5m.c F: include/linux/mfd/samsung/ diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 39297f7d8177..249933d6388d 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -1322,6 +1322,14 @@ config REGULATOR_RTQ2208 and two ldos. It features wide output voltage range from 0.4V to 2.05V and the capability to configure the corresponding power stages. +config REGULATOR_S2DOS05 + tristate "Samsung S2DOS05 voltage regulator" + depends on MFD_SEC_CORE || COMPILE_TEST + help + This driver provides support for the voltage regulators of the S2DOS05. + The S2DOS05 is a companion power management IC for the smart phones. + The S2DOS05 has 4 LDOs and 1 BUCK outputs. + config REGULATOR_S2MPA01 tristate "Samsung S2MPA01 voltage regulator" depends on MFD_SEC_CORE || COMPILE_TEST diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 3d5a803dce8a..9b69546fb3f6 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -154,6 +154,7 @@ obj-$(CONFIG_REGULATOR_RTMV20) += rtmv20-regulator.o obj-$(CONFIG_REGULATOR_RTQ2134) += rtq2134-regulator.o obj-$(CONFIG_REGULATOR_RTQ6752) += rtq6752-regulator.o obj-$(CONFIG_REGULATOR_RTQ2208) += rtq2208-regulator.o +obj-$(CONFIG_REGULATOR_S2DOS05) += s2dos05-regulator.o obj-$(CONFIG_REGULATOR_S2MPA01) += s2mpa01.o obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o diff --git a/drivers/regulator/s2dos05-regulator.c b/drivers/regulator/s2dos05-regulator.c new file mode 100644 index 000000000000..db304f2988cf --- /dev/null +++ b/drivers/regulator/s2dos05-regulator.c @@ -0,0 +1,176 @@ +// SPDX-License-Identifier: GPL-2.0+ +// +// s2dos05.c - Regulator driver for the Samsung s2dos05 +// +// Copyright (C) 2024 Dzmitry Sankouski + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct s2dos05_data { + struct regmap *regmap; + struct device *dev; +}; + +#define _BUCK(macro) S2DOS05_BUCK##macro +#define _buck_ops(num) s2dos05_ops##num +#define _LDO(macro) S2DOS05_LDO##macro +#define _REG(ctrl) S2DOS05_REG##ctrl +#define _ldo_ops(num) s2dos05_ops##num +#define _MASK(macro) S2DOS05_ENABLE_MASK##macro +#define _TIME(macro) S2DOS05_ENABLE_TIME##macro + +#define BUCK_DESC(_name, _id, _ops, m, s, v, e, em, t, a) { \ + .name = _name, \ + .id = _id, \ + .ops = _ops, \ + .of_match = of_match_ptr(_name), \ + .of_match_full_name = true, \ + .regulators_node = of_match_ptr("regulators"), \ + .type = REGULATOR_VOLTAGE, \ + .owner = THIS_MODULE, \ + .min_uV = m, \ + .uV_step = s, \ + .n_voltages = S2DOS05_BUCK_N_VOLTAGES, \ + .vsel_reg = v, \ + .vsel_mask = S2DOS05_BUCK_VSEL_MASK, \ + .enable_reg = e, \ + .enable_mask = em, \ + .enable_time = t, \ + .active_discharge_off = 0, \ + .active_discharge_on = S2DOS05_BUCK_FD_MASK, \ + .active_discharge_reg = a, \ + .active_discharge_mask = S2DOS05_BUCK_FD_MASK \ +} + +#define LDO_DESC(_name, _id, _ops, m, s, v, e, em, t, a) { \ + .name = _name, \ + .id = _id, \ + .ops = _ops, \ + .of_match = of_match_ptr(_name), \ + .of_match_full_name = true, \ + .regulators_node = of_match_ptr("regulators"), \ + .type = REGULATOR_VOLTAGE, \ + .owner = THIS_MODULE, \ + .min_uV = m, \ + .uV_step = s, \ + .n_voltages = S2DOS05_LDO_N_VOLTAGES, \ + .vsel_reg = v, \ + .vsel_mask = S2DOS05_LDO_VSEL_MASK, \ + .enable_reg = e, \ + .enable_mask = em, \ + .enable_time = t, \ + .active_discharge_off = 0, \ + .active_discharge_on = S2DOS05_LDO_FD_MASK, \ + .active_discharge_reg = a, \ + .active_discharge_mask = S2DOS05_LDO_FD_MASK \ +} + +static const struct regulator_ops s2dos05_ops = { + .list_voltage = regulator_list_voltage_linear, + .map_voltage = regulator_map_voltage_linear, + .is_enabled = regulator_is_enabled_regmap, + .enable = regulator_enable_regmap, + .disable = regulator_disable_regmap, + .get_voltage_sel = regulator_get_voltage_sel_regmap, + .set_voltage_sel = regulator_set_voltage_sel_regmap, + .set_voltage_time_sel = regulator_set_voltage_time_sel, + .set_active_discharge = regulator_set_active_discharge_regmap, +}; + +static const struct regulator_desc regulators[S2DOS05_REGULATOR_MAX] = { + // name, id, ops, min_uv, uV_step, vsel_reg, enable_reg + LDO_DESC("ldo1", _LDO(1), &_ldo_ops(), _LDO(_MIN1), + _LDO(_STEP1), _REG(_LDO1_CFG), + _REG(_EN), _MASK(_L1), _TIME(_LDO), _REG(_LDO1_CFG)), + LDO_DESC("ldo2", _LDO(2), &_ldo_ops(), _LDO(_MIN1), + _LDO(_STEP1), _REG(_LDO2_CFG), + _REG(_EN), _MASK(_L2), _TIME(_LDO), _REG(_LDO2_CFG)), + LDO_DESC("ldo3", _LDO(3), &_ldo_ops(), _LDO(_MIN2), + _LDO(_STEP1), _REG(_LDO3_CFG), + _REG(_EN), _MASK(_L3), _TIME(_LDO), _REG(_LDO3_CFG)), + LDO_DESC("ldo4", _LDO(4), &_ldo_ops(), _LDO(_MIN2), + _LDO(_STEP1), _REG(_LDO4_CFG), + _REG(_EN), _MASK(_L4), _TIME(_LDO), _REG(_LDO4_CFG)), + BUCK_DESC("buck", _BUCK(1), &_buck_ops(), _BUCK(_MIN1), + _BUCK(_STEP1), _REG(_BUCK_VOUT), + _REG(_EN), _MASK(_B1), _TIME(_BUCK), _REG(_BUCK_CFG)), +}; + +static int s2dos05_pmic_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent); + struct of_regulator_match *rdata = NULL; + struct s2dos05_data *s2dos05; + struct regulator_config config = { }; + unsigned int rdev_num = ARRAY_SIZE(regulators); + int i, ret = 0; + + s2dos05 = devm_kzalloc(dev, sizeof(*s2dos05), GFP_KERNEL); + if (!s2dos05) + return -ENOMEM; + + platform_set_drvdata(pdev, s2dos05); + + rdata = devm_kcalloc(dev, rdev_num, sizeof(*rdata), GFP_KERNEL); + if (!rdata) + return -ENOMEM; + + for (i = 0; i < rdev_num; i++) + rdata[i].name = regulators[i].name; + + s2dos05->regmap = iodev->regmap_pmic; + s2dos05->dev = dev; + if (!dev->of_node) + dev->of_node = dev->parent->of_node; + + for (i = 0; i < rdev_num; i++) { + struct regulator_dev *regulator; + + config.init_data = rdata[i].init_data; + config.of_node = rdata[i].of_node; + config.dev = dev; + config.driver_data = s2dos05; + regulator = devm_regulator_register(&pdev->dev, + ®ulators[i], &config); + if (IS_ERR(regulator)) { + ret = PTR_ERR(regulator); + dev_err(&pdev->dev, "regulator init failed for %d\n", + i); + } + } + + return ret; +} + +static const struct platform_device_id s2dos05_pmic_id[] = { + { "s2dos05-regulator" }, + { }, +}; +MODULE_DEVICE_TABLE(platform, s2dos05_pmic_id); + +static struct platform_driver s2dos05_platform_driver = { + .driver = { + .name = "s2dos05", + }, + .probe = s2dos05_pmic_probe, + .id_table = s2dos05_pmic_id, +}; +module_platform_driver(s2dos05_platform_driver); + +MODULE_AUTHOR("Dzmitry Sankouski "); +MODULE_DESCRIPTION("Samsung S2DOS05 Regulator Driver"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/regulator/s2dos05.h b/include/linux/regulator/s2dos05.h new file mode 100644 index 000000000000..2e89fcbce769 --- /dev/null +++ b/include/linux/regulator/s2dos05.h @@ -0,0 +1,73 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +// s2dos05.h +// +// Copyright (c) 2016 Samsung Electronics Co., Ltd +// http://www.samsung.com +// Copyright (C) 2024 Dzmitry Sankouski + +#ifndef __LINUX_S2DOS05_H +#define __LINUX_S2DOS05_H + +// S2DOS05 registers +// Slave Addr : 0xC0 +enum S2DOS05_reg { + S2DOS05_REG_DEV_ID, + S2DOS05_REG_TOPSYS_STAT, + S2DOS05_REG_STAT, + S2DOS05_REG_EN, + S2DOS05_REG_LDO1_CFG, + S2DOS05_REG_LDO2_CFG, + S2DOS05_REG_LDO3_CFG, + S2DOS05_REG_LDO4_CFG, + S2DOS05_REG_BUCK_CFG, + S2DOS05_REG_BUCK_VOUT, + S2DOS05_REG_IRQ_MASK = 0x0D, + S2DOS05_REG_SSD_TSD = 0x0E, + S2DOS05_REG_OCL = 0x10, + S2DOS05_REG_IRQ = 0x11 +}; + +// S2DOS05 regulator ids +enum S2DOS05_regulators { + S2DOS05_LDO1, + S2DOS05_LDO2, + S2DOS05_LDO3, + S2DOS05_LDO4, + S2DOS05_BUCK1, + S2DOS05_REG_MAX, +}; + +#define S2DOS05_IRQ_PWRMT_MASK BIT(5) +#define S2DOS05_IRQ_TSD_MASK BIT(4) +#define S2DOS05_IRQ_SSD_MASK BIT(3) +#define S2DOS05_IRQ_SCP_MASK BIT(2) +#define S2DOS05_IRQ_UVLO_MASK BIT(1) +#define S2DOS05_IRQ_OCD_MASK BIT(0) + +#define S2DOS05_BUCK_MIN1 506250 +#define S2DOS05_LDO_MIN1 1500000 +#define S2DOS05_LDO_MIN2 2700000 +#define S2DOS05_BUCK_STEP1 6250 +#define S2DOS05_LDO_STEP1 25000 +#define S2DOS05_LDO_VSEL_MASK 0x7F +#define S2DOS05_LDO_FD_MASK 0x80 +#define S2DOS05_BUCK_VSEL_MASK 0xFF +#define S2DOS05_BUCK_FD_MASK 0x08 + +#define S2DOS05_ENABLE_MASK_L1 BIT(0) +#define S2DOS05_ENABLE_MASK_L2 BIT(1) +#define S2DOS05_ENABLE_MASK_L3 BIT(2) +#define S2DOS05_ENABLE_MASK_L4 BIT(3) +#define S2DOS05_ENABLE_MASK_B1 BIT(4) + +#define S2DOS05_RAMP_DELAY 12000 + +#define S2DOS05_ENABLE_TIME_LDO 50 +#define S2DOS05_ENABLE_TIME_BUCK 350 + +#define S2DOS05_LDO_N_VOLTAGES (S2DOS05_LDO_VSEL_MASK + 1) +#define S2DOS05_BUCK_N_VOLTAGES (S2DOS05_BUCK_VSEL_MASK + 1) + +#define S2DOS05_REGULATOR_MAX (S2DOS05_REG_MAX) + +#endif // __LINUX_S2DOS05_H