From patchwork Thu Sep 26 09:47:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13813132 Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (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 A8EA61AC441; Thu, 26 Sep 2024 09:47:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727344074; cv=none; b=R3xSatgZrteB6SeKyQPPfhwhI7LOE+Ex57terIziQzFmU+a7ozRLSGOBFMPGiMdWKuu6vOIhsdHr2o/+3Kw2glqkxcLChbY6rUoOXnYXRiaMQZpPqeNtn0o8X0C29Gv2e9yqu06wemRGnYREFvOpHeoR/tNCeDWtPq5HZWON5eI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727344074; c=relaxed/simple; bh=fgn53cgjo7oCyIWaru75fu5gGxwR1HUplPMF2u7z1c0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=m/MYrZhNNEcyiHRZxS4qF70jduKrBVmAQzDFcYE/vhVIMpxfImgcIRx61z6OGDc6q1bxCLxvgbbYWxQwKj5yfxigWcuOJwe2qGU7DpNVw1ryEk+CVszI0j53TviYjiIw7F0b9iTTBi+zf7ceNxhSPlAXTcYyL+2AkY0yW5dzkIU= 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=I9xzEa6J; arc=none smtp.client-ip=209.85.167.42 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="I9xzEa6J" Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-53654e2ed93so1007304e87.0; Thu, 26 Sep 2024 02:47:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727344071; x=1727948871; 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=lsTYuGlxrhKxiHfQk8/AidAyypQojxBx32/1wunnGHw=; b=I9xzEa6JuSMRfHrmRXGO1Xth6X+fHf8mOKo2rAXDFlVfjq0rYGIEUCzPe0zDAT3NH1 839e2MpGmpK8OqfsdZUUG3OJUFcL+6viJjIKi6JRhfuXLkPjtSumRaYLSHnZEBGG9qPm nq7qOcAEVO7CCWrhADO10gidtfqrX5/q2MVf8xQctTpRpsPKSdvZvxheOVVVwlAmLcMl QiwOnuSyjnaY/X0NSJDG7jwngxph9CxtvFBC2ySzG5G7Lcm8dp2GMUsIl8wiLEVkAt3t NBrUao1/KZbI1BMYrsZN3+xhIhUBTHuoPEYdn4e7iLBnxYetsRQWB8aknOKpQ0e/li0L qEZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727344071; x=1727948871; 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=lsTYuGlxrhKxiHfQk8/AidAyypQojxBx32/1wunnGHw=; b=LFcWUPWnYgzAjOEHHqzNdHhO9jH0/KR2iMdfUijsNCiDG3I2trQKs7AvJrI49RrV/W v7DdS480aa51+SxETkT3D0FLbmd/g9gPQaKB7uJdoWBnwf0lH2lUoGnzSss4FzsJ2NBX dNtvgiT4ncek4TQCV3GKFSo0Wb2x06kGOrcajBNe1NcgEBkDsKxohmVrIxw3y1w0iSeJ jzSdQLlxUO9JIB1yGsh5QapapLgJr7d0SGaSKYBpZdblsRy0b5iZGXKrDyhlDmWFajKx znZ/JCMo+NyZ8kVjqm/ovq4OxIjSkbNhl6kNafjVA1TtuUYp+Zqd0wAv/7TUQ2iqfZBe mdmg== X-Forwarded-Encrypted: i=1; AJvYcCV8wJNWngxhKhCGV9aitJbmnMLXpgfz9gjftZ+CTmcTYmPRe/XgO8OhP+pq87PEy9GDT7xwRRAuNxc2oncHFQCr6/A=@vger.kernel.org, AJvYcCWeNXmIhLxIwFVC85aTCUR6upSIdQNWDwP1S33Z8qQnnInWsPEUSBswrocFSB57ib1UaRYyXAgJhitA@vger.kernel.org X-Gm-Message-State: AOJu0Yx6oHYfgaXZvCrsD3JUalPthh7757wk5TylIYp1EY5vkGZKK+/s KjtILf8QpJJDJTZ62eu6kmTjIZgwx1FBF4ZURvLLxRcnG/2CrO4v X-Google-Smtp-Source: AGHT+IFCLTGyAs9CivJacP027VtGlWbk3TGkau2AsoGtLu3wYDxxmyEFsE4tqWQiDDXt2yKy5+22Gw== X-Received: by 2002:ac2:568c:0:b0:536:9ef0:d854 with SMTP id 2adb3069b0e04-53877530b7emr3455906e87.32.1727344070389; Thu, 26 Sep 2024 02:47:50 -0700 (PDT) Received: from [127.0.1.1] (mm-20-1-84-93.mgts.dynamic.pppoe.byfly.by. [93.84.1.20]) by smtp.googlemail.com with ESMTPSA id 2adb3069b0e04-537a8648a60sm750311e87.199.2024.09.26.02.47.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 02:47:49 -0700 (PDT) From: Dzmitry Sankouski Date: Thu, 26 Sep 2024 12:47:30 +0300 Subject: [PATCH v5 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: <20240617-starqltechn_integration_upstream-v5-1-ea1109029ba5@gmail.com> References: <20240617-starqltechn_integration_upstream-v5-0-ea1109029ba5@gmail.com> In-Reply-To: <20240617-starqltechn_integration_upstream-v5-0-ea1109029ba5@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.12.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1727344064; l=4482; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=fgn53cgjo7oCyIWaru75fu5gGxwR1HUplPMF2u7z1c0=; b=E67BzRTMx000M4UGeqkGFg5iUysW87cYybYD0JSzIpKkOy619SQHZPbx6QkzWi7vTpdya+psp OQac6af13+dCNzoezIpN73Up8oq0vQa6+Yrp3MCXYhpKneRRDjQzhUd X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Add samsung,s2dos05 MFD module binding. Signed-off-by: Dzmitry Sankouski Reviewed-by: Krzysztof Kozlowski --- 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 5e467ba71e3b..6a6c769a341a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20468,7 +20468,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 Thu Sep 26 09:47:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13813133 Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (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 77E961AC8BB; Thu, 26 Sep 2024 09:47:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727344077; cv=none; b=KUK3OTgSV0kLOuKZfpZUfiq+Shia3vyhJsAJ+YEQhFq3JWWlVIEChiZwvkAfx/4R/fP951ZAGHDmCQxBPmfqwiR4XQe6QBJOdtPuj6dg3+i5C/cvEu8nT6crkO2r55g2Hm5q9KnkCTV8oz6O/5yd9FSB83G8Z04vkunLHQdEPUI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727344077; c=relaxed/simple; bh=+y5dIaEAV6sUyjaV2E2BF1doVtTB4Tk8i4VgnMDtrGQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sNesNzNotqgVIU98likFRi3O2/8chBEvr2KDa7OaKWjh8jUcMTbHQ53Xq60aGr+yWfWy0bR2c1egjHeNsk/gDhS8IGDWDnz1N/AGCuO3CA0xj0S3OlRp27QBWO8NB8kRWVm+GrjtvL7STFPrzvxg/JZr8cESlVdDvpswXnHAKw0= 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=JZXPygB3; arc=none smtp.client-ip=209.85.167.43 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="JZXPygB3" Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-535dc4ec181so885628e87.3; Thu, 26 Sep 2024 02:47:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727344074; x=1727948874; 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=JZXPygB3uKhkN4GMtYZo3ZYCaLFnFXVUImrvW+OG1EFtcAoK1huavbGz87h/N9TwF2 8poa0Pm35kVl8HfYLbAwDwVXcfGk7AjywsMWRQ4HgVB7RbXaRvyt9UxVd532NL1H7pvi ptocZU/B8Us6kFFu5z4Hs63bSvck+1FAMsK4ejx+v6ezsO/pM7CPlEH85gvASC+scHnm aR/anlTBXIMszJumQ67IpZP6EsEMdwKub2SLZ5RuuEs2Od1IJaVBrzMwh87XdnLyV7Rl bENvjR5TURuxti36x4ftNKA/aCeQdX9kKMSgjDPLxL936IpHwwQKt2+pQkOH0AYgDM8O MgYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727344074; x=1727948874; 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=bwLerJL6r7fcvJzaqiUBJb+lSGt1+tD0IM1QE451oIIBBj8xoAWeuYbzNV+Bsw/0oe QceM3GcgjGYKj7iRWrVOWKlHaIVWX4qGtII2wCd/LhZIxLxTrOnImL5aBY3+amkA2XyC tEYLGBCRalGFf90cEQjcoaxuOK++iWh1jOlGrrEmpW85KyNFGATStQ02pYbd/vDBAd6G tVO73MbrM/xdykJ/Spp4huLdGtFdAA4cSYA92XS7MA6QKydVa3jTj08t1rjaJQYhC8Px aDoy60myCSO69SxCeoaWLz14xO4I3g7WNN5anCdTInn6CWUO60uWV5NDePT/4Zn92APK DpDQ== X-Forwarded-Encrypted: i=1; AJvYcCVYEbZqCAA9rlnVOJf7/nKfi2wai3R3d1giDmqwonIf6Clk/UoMEcAHTRlcShZCBJFpQkWhMBJd8idp@vger.kernel.org, AJvYcCX2ku6kMr2HIwNl0zXM0WY0gEGf6N/YS9zx86hNjdAnqTbVkxN684E4ZQ6qXAi9sRwDmn2PcF3kVgKLNU1hQ1SEOjc=@vger.kernel.org X-Gm-Message-State: AOJu0YzSJ2e165O7nJs2x7agEvcr0t3Yaf31XLIn1qBwYyXFOc2YmXIT amZ82KHMJdYuvT7Rumu15VZTFj1ysVXwiEwW5tqegnHGX284TDNC X-Google-Smtp-Source: AGHT+IFLac8oKPcjIKzN66vLATjMOcvWhvWIMVJxNVu1Bl1MqnCcQlu3Ie6U/g3N+xLKosf8tds8yA== X-Received: by 2002:a05:6512:239a:b0:52f:df:db40 with SMTP id 2adb3069b0e04-53877566141mr3799681e87.56.1727344073350; Thu, 26 Sep 2024 02:47:53 -0700 (PDT) Received: from [127.0.1.1] (mm-20-1-84-93.mgts.dynamic.pppoe.byfly.by. [93.84.1.20]) by smtp.googlemail.com with ESMTPSA id 2adb3069b0e04-537a8648a60sm750311e87.199.2024.09.26.02.47.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 02:47:52 -0700 (PDT) From: Dzmitry Sankouski Date: Thu, 26 Sep 2024 12:47:31 +0300 Subject: [PATCH v5 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: <20240617-starqltechn_integration_upstream-v5-2-ea1109029ba5@gmail.com> References: <20240617-starqltechn_integration_upstream-v5-0-ea1109029ba5@gmail.com> In-Reply-To: <20240617-starqltechn_integration_upstream-v5-0-ea1109029ba5@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.12.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1727344064; l=2079; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=+y5dIaEAV6sUyjaV2E2BF1doVtTB4Tk8i4VgnMDtrGQ=; b=9FI3Ue8VpjtURJG8/hNPG/Ureilw30Fr4AIqE8d/7GajkKeQLkcxnmxhMObcLN037hxdInUSA q+Hg4azkMZKAeZp5xSguqDuLnRFo+WuE+LA3QhPpUrL7ZFraMjW3X4A 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 Thu Sep 26 09:47:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13813134 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 A507C1AD3E0; Thu, 26 Sep 2024 09:47:58 +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=1727344080; cv=none; b=T5YH9yjJO15iytOmSNSg77KO5E/v2eXn2N6g9pKsULY1ofnLL+/DSfXFL2lVZkiFUBn4bg2UmrUkzbQVzgWt3T4hV4MJoUqYoLGOHfudRHHaZrtz3u2gHzgxfPEcFsslX1yRFnzEgnZZHtIsEZl5kHFSJQr5/i20MteamdeJWEE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727344080; c=relaxed/simple; bh=7tvyRSoiVW9Vd9Xo4AFHrbZVdsgsyPs3cLRSVav5XeI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IuA0o7bdBAI0sH+rWnWCZzyk3Sn2XO3dZJHAPGMc8dVKDS4Be2wjzhHpWbDR71TZuF5aOFbXrYY2HdMdsM21lPIIFpyG1/lasnJZB7LpGUToFELninHgWC3skeXVeXUYo8jgMCQjrh82ktBbiybhrRGZDYk2h5f+iClD6ohjvi0= 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=ES+0mglE; 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="ES+0mglE" Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-2f77be8ffecso8198341fa.1; Thu, 26 Sep 2024 02:47:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727344077; x=1727948877; 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=kf8yQGwPrApDBkAfb1N9SlgkZVc57+N8INC8rjiS+dQ=; b=ES+0mglEVsuWwtPqWr/vwFFX16UF2oc9NNOyKkHTwaW2MZ/0dZMHv9LCDmPUlhhfXA sADdTXrWo5ungQAp8CjFZYCmNjIXwETQBGcfUJ4pThZO2jYH4jI1d/i4pd1jG0Eutz6j 80O8GJjhcHuqhDI0n/S1S2IVT2GfQWElwVhNWmk1eF4NiD2CoRfXAtBzu15Zmgb5GKD1 ZStjxod49eEkx+8aTD8MlIDsdIC6G3b7dTUABKk5dODCXzqGd+DTZ5KBdF8NI/Orud+P XBzH7SnDEvt2qYXfL7iRJiBAf9S9z4Q8yRiI26D3SxSOGiE3K1YMjC5RxS+HqNyu/mio g+iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727344077; x=1727948877; 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=kf8yQGwPrApDBkAfb1N9SlgkZVc57+N8INC8rjiS+dQ=; b=VppNh2doWNAcCh8jWxeuuBI9PG/ZNn7V4D586+pytIy5wo52z4N7FmRYBCzKpTzrU2 14bB8Ju0zREYHdUOoexB8joO4pSRmF4LlL7MiMlQk1dY9R2/TpYxSs5f3mLGHqtC/XEG UUIuc2guBedckhTQiGjhycf6G+06WmYmoW32ExAC09+BvgIoY4pz4BXoqRdOzO/yQwcn b+4hQddYRTC2qWKagZz4D3M1Fqyv0kSnuoZk8rt7z5PbMCqBNCR//iMJUdraeSUUwek5 fnvPGLDzlJPDPKKMESKJryq60Bda9lfCI9k7o9hKVuBup0lET3Lup7176DcZRpt2R/Wb ixLw== X-Forwarded-Encrypted: i=1; AJvYcCUZUCY3l8ihEKyyF2z41xB7mejf59lvnaw1w8nShBdugttm64Qcjmd9540I8fPOG3Kw3mGabjl131/Z+5I6otMK8eA=@vger.kernel.org, AJvYcCWXAwnb2FKuf3KM8FGJxDT791TNvGQunTTFZZqO+NmjnFu6esFo37Z5++9HGNCwNXYNsGnLIumJe6i2@vger.kernel.org X-Gm-Message-State: AOJu0YzAzXPbrtJzPOYpAxCnqre+asx3i4JczX4t2EOE6S++yj53pT6E bVajvhDLJiGXTVynll2z33G//cO5cr79PHz4tfs0hSfPYqumnJDs X-Google-Smtp-Source: AGHT+IHLQfBYi/8zLKZo4q8n1VyHrmonJqJzPwgjkmLbWd8cy9FHV7ZE+0jodxPjvghdxLLQ6xT8uw== X-Received: by 2002:a05:6512:3b1e:b0:52e:7f6b:5786 with SMTP id 2adb3069b0e04-538804ae40bmr3138266e87.61.1727344076252; Thu, 26 Sep 2024 02:47:56 -0700 (PDT) Received: from [127.0.1.1] (mm-20-1-84-93.mgts.dynamic.pppoe.byfly.by. [93.84.1.20]) by smtp.googlemail.com with ESMTPSA id 2adb3069b0e04-537a8648a60sm750311e87.199.2024.09.26.02.47.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 02:47:55 -0700 (PDT) From: Dzmitry Sankouski Date: Thu, 26 Sep 2024 12:47:32 +0300 Subject: [PATCH v5 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: <20240617-starqltechn_integration_upstream-v5-3-ea1109029ba5@gmail.com> References: <20240617-starqltechn_integration_upstream-v5-0-ea1109029ba5@gmail.com> In-Reply-To: <20240617-starqltechn_integration_upstream-v5-0-ea1109029ba5@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.12.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1727344064; l=11054; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=7tvyRSoiVW9Vd9Xo4AFHrbZVdsgsyPs3cLRSVav5XeI=; b=ssImRc1hdDZasqH2bWuToC9BgbrTLhlTb060Lgnm4AtGck8cNWIwTHu+sNHitCWCmf3sETHoH 7TsvjTzLuGpAlC7oYBvRx8OTLLyz3B3U+UylWob3JL0ZoYVOPyvH49g 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 --- 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 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 --- 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 6a6c769a341a..0b9fca1030a8 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20474,7 +20474,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..258cabf104ce --- /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; + + 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