From patchwork Tue Jun 18 13:59:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13702394 Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.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 4E5BF155CAE; Tue, 18 Jun 2024 13:59:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719193; cv=none; b=cAM4Ysz918iOdjSHLTGTLSEkz2GLZyYQxvxGgPH8A2i+B8ucjuWUDmIo14SaqontV64XmnNKlOvDPMopO2niC/GOa6Xw8rR7Wpi/fMy1B/5B3x/+e0p+WFHZrxFxwQUGgv/EqqgM/A7oC7fJFdgZUpCliVKGkmYcseboPgSfQ8c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719193; c=relaxed/simple; bh=MYDk+LYjEzzvLPDU6mjzpg2IX7z/HKPNPkCElkRcQ+w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KH7vc6RyxUGooCkgEmbeZZ7qKfAJVV9kj65sgPDglB5zS8K5w9PUGDqHZ4weQbR4fynU3c41w/kgMRVMFBxY3mw7du+bq/6naZ2OaTtm+rwd56akgcnKdmP1TawWRiRkjfHlxgKZyspoGN701qStkvsVTodz6Py/nZsfAQY4P/0= 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=i34RMu67; arc=none smtp.client-ip=209.85.208.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="i34RMu67" Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-57c83100c5fso5996215a12.3; Tue, 18 Jun 2024 06:59:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719189; x=1719323989; 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=CSe0urafDT2z1+HpSSV03N11tNgqTMkBCf6I1SbHXSY=; b=i34RMu67dIPdpECRsvigUcKKEInnayN4bROVrpvKxESQSuSyBc1W+pPJB4YDfvsFrc +FvBXhLsgjGxco2v77LNkUqXbJZ5gGA2RahB+dDCqbijU8Jgh0wt2Mjc3c2YUPXlS2Rx K3cf+ZvaAXrjlu2iiLijVHSl9pauv7hyOEqKyn1GpvqVoBrBiMewrZxK3jluF4Mky8bT Hh7V2Do8pUhZEuiSTw/21c5c2ueA7oyqTOAQ5EQlod2zFlPKTs9ziGaDz1YIsGPQ/8og +AVzMgEQnXNkoZZR+o5yH9D3+TQAuxBJK+WLytDvj6EKMI1InixOOeep7ILea4YDvoRc /5dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718719189; x=1719323989; 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=CSe0urafDT2z1+HpSSV03N11tNgqTMkBCf6I1SbHXSY=; b=uwsaVzi52GsO99Kgddd1qzyHSZIEPHQgppruJc33/5SEvqbrnqqnWR4ZoHl6A4G5i6 2z1yIe2EVUQq2rBYCnGBhAX71OqaUnap9RJy4aNuS4/U4+bDcY3JQBmrHcSWLGf51xa2 ZoXAjmndPrh1l/DgAGtQJ81PxjACEYPkkWRhHwf0Cp65k1CEoYI44e3Gv5zHaxxxpZHU amZD3e/W+jYlbqw6Rz+NmMiIknCyIgkrP+O9GfphiWxz860VUPpz5dzAG6w4oPf35WQi JK9E0a3vmFOotntuk7vO3Np9YPMaspaAxVTzKs422vPvR/mryhWj9oU8GU8sFn/uSkqe et9Q== X-Forwarded-Encrypted: i=1; AJvYcCUP7N/Leyy0VCxAHYbacNpdD+Q7KJC0D1xzXeOoAIa6WGpDHfeMKf7Sag2A3zTrAObpkvKW0cpnsHXDorBwlra1IMj5ZYUrIrzgv7idYQ9EI9XK2C6zNAs2IcEQ1/bebxw0SzMDFmZiD0J5j7SZykVN4M0q6/XMJWhMgViGqx2yBxrD+wBIWuWi8kpGG1k26WRkQ7KJ9VERUcLaxfAALL0HVRWbZIuazoQ270bbMmihTvfoGhDwVWoR7a+icf4hbFd+eGMG/CV5Js9Wc2GO4uP4IumoNA5NKwFGlM74k0cJx83wRd2rNa+6g2j83O4q4GQJqkU+2o1g1Fgf7e1cy8aHpCSSTxv/he0SLLIrmhxCIBMy2/qf9kjBnKoCcnHendV4ex6YKWKxqowMvm1C/YkaYU1eLsUg X-Gm-Message-State: AOJu0YxhvBmFutbCmsJlIpPwLWx1y7MsJq57Q+6Z4uVUc+ufk0mPJ6Cl e66+p22vpdhn2eJJHe63A1LdnF9oelMih/0srnJZl7/f7zAbJWsb X-Google-Smtp-Source: AGHT+IGvN7W/J9F3YIuria+CV3PGWcs1VK3Ax+ln3/ipL9AA6AsOYEJMmxSCCBizSSU6Q6We2LB81g== X-Received: by 2002:aa7:c253:0:b0:57c:ce20:152b with SMTP id 4fb4d7f45d1cf-57cce20164dmr5541095a12.26.1718719189451; Tue, 18 Jun 2024 06:59:49 -0700 (PDT) Received: from [127.0.1.1] (mm-167-232-122-178.mgts.dynamic.pppoe.byfly.by. [178.122.232.167]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-57cb72da156sm7731278a12.22.2024.06.18.06.59.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 06:59:49 -0700 (PDT) From: Dzmitry Sankouski Date: Tue, 18 Jun 2024 16:59:35 +0300 Subject: [PATCH v3 01/23] power: supply: add undervoltage health status property Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240618-starqltechn_integration_upstream-v3-1-e3f6662017ac@gmail.com> References: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> In-Reply-To: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> To: Sebastian Reichel , Bjorn Andersson , Michael Turquette , Stephen Boyd , Neil Armstrong , Jessica Zhang , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lee Jones , Dmitry Torokhov , Pavel Machek , Liam Girdwood , Mark Brown , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Krzysztof Kozlowski , Konrad Dybcio , Chanwoo Choi , phone-devel@vger.kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, linux-pwm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1718719184; l=718; i=dsankouski@gmail.com; s=20240618; h=from:subject:message-id; bh=MYDk+LYjEzzvLPDU6mjzpg2IX7z/HKPNPkCElkRcQ+w=; b=6osR5sQb3KfAqZxw/zABeeghkZzuowKR+l9GQi+0gqppa+51FZOCldCtLrCOr+cODyhyepNtO Beikk3e7TQ8CKJCAPvaKcz8UpsfsQfaQyB+QH3eRgK0LKT1K32tsI9K X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=6pMMVVDDReSiRgPCbMOUauN5nS3ty4Sf5b7a2gi4x0M= Add POWER_SUPPLY_HEALTH_UNDERVOLTAGE status for power supply to report under voltage lockout failures. Signed-off-by: Dzmitry Sankouski --- include/linux/power_supply.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index 65082ef75692..0f82a5c0ccf4 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -58,6 +58,7 @@ enum { POWER_SUPPLY_HEALTH_OVERHEAT, POWER_SUPPLY_HEALTH_DEAD, POWER_SUPPLY_HEALTH_OVERVOLTAGE, + POWER_SUPPLY_HEALTH_UNDERVOLTAGE, POWER_SUPPLY_HEALTH_UNSPEC_FAILURE, POWER_SUPPLY_HEALTH_COLD, POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE, From patchwork Tue Jun 18 13:59:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13702395 Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.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 675AC156C70; Tue, 18 Jun 2024 13:59:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719195; cv=none; b=Bc54u71HAuPuShg+172HhqAJMkLCC8KQEyKpRBNozuUgNsVd8MbzEInq+ZDIq9a0kebQlvjpXeJbXzX7Rc0fh/fTgQYaJOg3/m0ynJj9cNGWHmvX60X6HC2qiX/rvO5Pt+mzcdt3boNJL+0EWW2HR6KEJh43CHJoxXpedBY7O+4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719195; c=relaxed/simple; bh=3HcxN0k0ztF3vxPnK9xWSo9UBEsozU7BSPW6y11+ONM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uwNQlUxhkaBhM4I5TNW+DqwGYdsSZZxX8aZ4nGcVN77LqjTTR0sYhYHscEcS1MF/Pka8fF27kYZbcF+LiJJTq1nrHxUzWUFoXZS07LXnFpxGpWaqTSqhVV6+5ggz3U1uwSEdLgu1i7vw0H4JE86+6TgyJATYU43hrVDRCRa2mMw= 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=HNVyyMl2; arc=none smtp.client-ip=209.85.208.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="HNVyyMl2" Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-57cad4475e0so9142765a12.1; Tue, 18 Jun 2024 06:59:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719192; x=1719323992; 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=R7M7fPS8zpDvWWWq0XONmDDcbsza5hIcH9aw/hhjckE=; b=HNVyyMl2CMBVwursNQlmfCzTeNwcNFLOn7d7IcXXBxVwR5W6oAHUwOPS6O44wm3FML P8RGG8X6VFZaY65pf02sh3MOMBwnCyNUrLFI/VL+lReNjqzzeDI02963AZZyGCgpz//P CS6W+oZB8mCPploFBUXCzM4Ck1TXUsXriW4Ty7i+194tExvmtmv3TEU1og8KKsJWC2Yz QvDq+ghHydh5UQ9/DzsNoZr921xepG8tdM5iccejbYoCVN/jkU/I11suUCfX+HZaMJfJ BNzEp2JgbB3x/HaMAaBSzsvkKIkFtPzydWPOz1fvvMZ5XQl6qL80K245Jbqom4DmqgRB dwUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718719192; x=1719323992; 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=R7M7fPS8zpDvWWWq0XONmDDcbsza5hIcH9aw/hhjckE=; b=J1nTehkzQ5oIpAJ1oVN1ugbr/Wv+JMT/0issE6VFa6wR9qrPjLG8/YrOWBYHeOv4fb vIZH2XoP4Z6yE8zaK0eChB6/rlRnpJQDMMmQayHNSqaDYylXFQJKxvzKmtabdWUJA2na UlqW/sxwvbYSPgqyLP/KYdXJ/baKOuaEB+bDokAkURyhNatdV8Tu2AEt6hkfrl+HifRn Rm4G+5VoxpeD7JAkXeavW3jOVfrTc4HBzxcwE4MDGfDGmvpdKfg/y5AKMo9gsmmnOM0i YYMknAOJAx3YZBg7U+P74TxH/dA74tQIJoyz/Vat2hVpcPCmeI54XgdgTjtfbPq/qAoV a1fQ== X-Forwarded-Encrypted: i=1; AJvYcCVvxeIf6Sy8uCW/9Oc4sn5n6CB7AJgMC+bdiSiO6fx7yFQMl6dAJTe7dU6lFrfyKSqNVg6mWTnn37JNO0irWBmobXgOtuoW2cFq4dH32gLaplSQepKjUJ7XikZJ7M0fbiR8wmD3XVD1wMt/f4KAkFVwIFJZljR7YfCVTf2Bcocy2wIkNikrqxvgOULx/12hqVe8SV9WZ28oEiVCwy8NU9PoZgTSdEsBJAkyr7dY1526ip9ppFRmc/wDAZzA8nvd8wRQB9D77K5iAgyXXqAfZ2xJbxCMiAQhcy5c3Jr+vI5Z+nx2VOaId3aWNzvVCAZFVKEJ9MJY95Y+KmV0kkAeK0cXP3vkrPLARb2q/ImDA5TgbbXKHCdedD7OdUSrSDUVoOlWHB1m6qaca2b4+eQ2uftjvdDDXYko X-Gm-Message-State: AOJu0YxycwLmNmR+8gUsTfGi8XMJ2tPysPLXt6Ph21PfG1sJ3QXynwqI jx+JLrtvxIEEBJRJr6s4bM/xOIBhOUz4pv/7Ou11OkabyQjISMbu X-Google-Smtp-Source: AGHT+IFxrH/zkhSdk1MaRK4E+l+p5JQYX08C4NcBilAVk0Op8+DaFkNWiaIzFFcE4tvs1PLeBwnIkA== X-Received: by 2002:a50:cd1e:0:b0:57c:a4a3:f1fe with SMTP id 4fb4d7f45d1cf-57cf7a926e9mr1837021a12.17.1718719191602; Tue, 18 Jun 2024 06:59:51 -0700 (PDT) Received: from [127.0.1.1] (mm-167-232-122-178.mgts.dynamic.pppoe.byfly.by. [178.122.232.167]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-57cb72da156sm7731278a12.22.2024.06.18.06.59.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 06:59:51 -0700 (PDT) From: Dzmitry Sankouski Date: Tue, 18 Jun 2024 16:59:36 +0300 Subject: [PATCH v3 02/23] gcc-sdm845: Add rates to the GP clocks Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240618-starqltechn_integration_upstream-v3-2-e3f6662017ac@gmail.com> References: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> In-Reply-To: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> To: Sebastian Reichel , Bjorn Andersson , Michael Turquette , Stephen Boyd , Neil Armstrong , Jessica Zhang , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lee Jones , Dmitry Torokhov , Pavel Machek , Liam Girdwood , Mark Brown , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Krzysztof Kozlowski , Konrad Dybcio , Chanwoo Choi , phone-devel@vger.kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, linux-pwm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1718719184; l=1529; i=dsankouski@gmail.com; s=20240618; h=from:subject:message-id; bh=3HcxN0k0ztF3vxPnK9xWSo9UBEsozU7BSPW6y11+ONM=; b=FrDsj3ETUaVVQUOm6LFM6D0nBF+hdet963cj5SLvZ7Hei+IvuV6/EU9kWQmVy5U92Zb8ZIbV0 dOFifsD41gAC/4qNSbNS6FuI5+bBgsoWvtPrvXOm97raYLyZG5Ds/10 X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=6pMMVVDDReSiRgPCbMOUauN5nS3ty4Sf5b7a2gi4x0M= sdm845 has "General Purpose" clocks that can be muxed to SoC pins. Those clocks may be used as e.g. PWM sources for external peripherals. Add more frequencies to the table for those clocks so it's possible for arbitrary peripherals to make use of them. See also: bf8bb8eaccf(clk: qcom: gcc-msm8916: Add rates to the GP clocks) Signed-off-by: Dzmitry Sankouski --- drivers/clk/qcom/gcc-sdm845.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/clk/qcom/gcc-sdm845.c b/drivers/clk/qcom/gcc-sdm845.c index ea4c3bf4fb9b..0efd3364e8f5 100644 --- a/drivers/clk/qcom/gcc-sdm845.c +++ b/drivers/clk/qcom/gcc-sdm845.c @@ -283,7 +283,21 @@ static struct clk_rcg2 gcc_sdm670_cpuss_rbcpr_clk_src = { }, }; +/* + * This is a frequency table for "General Purpose" clocks. + * These clocks can be muxed to the SoC pins and may be used by + * external devices. They're often used as PWM source. + * + * See comment in gcc-mam8916.c at ftbl_gcc_gp1_3_clk. + */ static const struct freq_tbl ftbl_gcc_gp1_clk_src[] = { + F(10000, P_BI_TCXO, 16, 1, 120), + F(20000, P_BI_TCXO, 16, 1, 60), + F(100000, P_BI_TCXO, 16, 1, 12), + F(500000, P_GPLL0_OUT_EVEN, 12, 1, 100), + F(1000000, P_GPLL0_OUT_EVEN, 12, 1, 50), + F(2500000, P_GPLL0_OUT_EVEN, 12, 1, 10), + F(5000000, P_GPLL0_OUT_EVEN, 12, 1, 5), F(19200000, P_BI_TCXO, 1, 0, 0), F(25000000, P_GPLL0_OUT_EVEN, 12, 0, 0), F(50000000, P_GPLL0_OUT_EVEN, 6, 0, 0), From patchwork Tue Jun 18 13:59:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13702396 Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A11BA13BC3F; Tue, 18 Jun 2024 13:59:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719197; cv=none; b=EjOrotgHX8j5LewE0hfg3Qe5bkI1kxRtaIhFRF3SppgCosPNQ3xHSNqa81I0hoDiyqAPuD5hzYs0ET6Vea8UXK0zNA+tsh7QiTK+mxIOCtkk0++ixVhZxIncnmgqxmnv7Ar46rdJKwFCnw68gPJc5TjGtx1R+yJSDKN0QRqOJSE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719197; c=relaxed/simple; bh=u/o9BG9AqKYLWAUPHxzLUOD2JYdWbpPwReHpmt6QtHE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=A50dHY1/5+UT9zPrBN7FP4x1hB5lQ1ZKRDTqTc0RKi6Y892o43S4QFnSOuyBuldTLHosJfsEpTNchZo4XB1ZUA0l5gdrR48nDfbTIUwa7KJewz4n8mBzxN3jrEuj4GfkQe1dCk6YW8/mKAHndOr64f2o/XgcuobGqWGol1FKTQY= 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=KrwJ/pwR; arc=none smtp.client-ip=209.85.218.41 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="KrwJ/pwR" Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a6f51660223so328313766b.0; Tue, 18 Jun 2024 06:59:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719194; x=1719323994; 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=hjTOnao2jgs0TbPexQcL6nA3LicQJeUCbeGc7Ge6OXc=; b=KrwJ/pwR8Vtomprnh32p4KwSpFYbigm6FUoffQN2anSjXsOHco+oSCqeGqepD9wTkA /eXn3TiCLOy1hl3+l7ibrSS+sZaIMb9TVOOpgDA38w+WAbvdBDXCo9859zgn2KnIF98A G83bq9PlUEli0ND1fmSfeGBruRzq3YWzzgvGZPDSblAqW2PWpSA9hmuAw2u/SPg8li9U BRwczZB9+c6eE3KO/I833dQZcv+448yDo7iVeDFdCvZqpUWa1bqtNcX1XccPRn/Vbt4M l2io48PhY3Q/DJ4KxdaFr7mXxYbjhPiX1XTyfn+BTdxfXR/RVcL4LWpfbbMk1s0mluAg iwlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718719194; x=1719323994; 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=hjTOnao2jgs0TbPexQcL6nA3LicQJeUCbeGc7Ge6OXc=; b=usqN8PvhlgP8w6uX2MAfPgD4qRVTbOyb4eWG44qAbhs01VWNZ6LrnPa147ecbj/Fhb pDYNpwM4iRyAKO+nEETjvBdfJUwwVXuNULCSt7wekxH7QR55hyS83MaBDv92jiz7zfQN zdfQRssAC9uqUixOdqvmBXate2rAKTunfp1tdL7emZk6XQ2rEdVCOUrbVvNjqk359ir2 nNoTg9X/6E4MlfUhht34vftD3X4YkDaQJNjRsQfYr2a0B4Y7srP+ImXYL920TZbCrjq+ AIcmcU6+MTemyHtiUhA0KPhZcCIHK8OlxpJqB+5EXWTaR034Oc2pmwvporOl/W9Yvlkm 4Saw== X-Forwarded-Encrypted: i=1; AJvYcCVlAk6KyzeWGHlwaD5JDW3ndzKJEg17Tp8XcF9sJc13QLezaZ8F1UnJ466wBMh19enVGQrESU/M99DD/sj6eVZhZW08eurZtc7+w/LWudwmBfM0ckDvabkT4MbsW7dFATH3f4xvGty5KYbj9bhh40rvYlR8MF2RE3/0LZ1PJWrwkP8OqQ4lOospO6WUty/5rT9z8iMs0EPAeepOW0eouDAeuIvt1THPJuM2CBHiLmTtv+dLkcbNPxD0CiHKu7+M/qtnOhaLhpi4MSC2fYpzgeL/34jkD7uT0Uc/3LP8ejYRgrlZ0IgvrKUop116xl8iOQT0utD+AIpNNsJ85l0g20eEewV7cFqhejtV08rzIkoFwdExVcbCyoJqt/A91YP3M4Mh6YCt2GXZ1Pntw+nj2A5CtHJXBp3u X-Gm-Message-State: AOJu0Yw9YAllEd5Z0eHnFsOtlNML5jhvNb44D0dyV818Dvv1Oe7mlF0l snG+CJA37hCe3IOYngKnlQ3TJISyxar7L5tA6a37W/2Y3RSlq9wz X-Google-Smtp-Source: AGHT+IFEcN8FjKFZhcaPR3K37rXFvtBAVhD0dgg++WL+CT9QX+9G7TKsgbcNessmzcPjrqqULcHuug== X-Received: by 2002:a50:96cf:0:b0:57c:6861:d731 with SMTP id 4fb4d7f45d1cf-57cbd6c7457mr9478897a12.28.1718719193759; Tue, 18 Jun 2024 06:59:53 -0700 (PDT) Received: from [127.0.1.1] (mm-167-232-122-178.mgts.dynamic.pppoe.byfly.by. [178.122.232.167]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-57cb72da156sm7731278a12.22.2024.06.18.06.59.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 06:59:53 -0700 (PDT) From: Dzmitry Sankouski Date: Tue, 18 Jun 2024 16:59:37 +0300 Subject: [PATCH v3 03/23] dt-bindings: panel: add Samsung s6e3ha8 Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240618-starqltechn_integration_upstream-v3-3-e3f6662017ac@gmail.com> References: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> In-Reply-To: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> To: Sebastian Reichel , Bjorn Andersson , Michael Turquette , Stephen Boyd , Neil Armstrong , Jessica Zhang , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lee Jones , Dmitry Torokhov , Pavel Machek , Liam Girdwood , Mark Brown , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Krzysztof Kozlowski , Konrad Dybcio , Chanwoo Choi , phone-devel@vger.kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, linux-pwm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1718719184; l=2883; i=dsankouski@gmail.com; s=20240618; h=from:subject:message-id; bh=u/o9BG9AqKYLWAUPHxzLUOD2JYdWbpPwReHpmt6QtHE=; b=g50eS59XNhy8Hz/rQYUxaUeykF5WKEEvQYvtP+VPrwrvnuKg4KD3zx6UKrGwX1D8tekXKo86t ocpTGcK5tVDAVNDxhWjwlgaYobX1nnwFwmG4bfa4toG4sAnckh+ziPk X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=6pMMVVDDReSiRgPCbMOUauN5nS3ty4Sf5b7a2gi4x0M= Add binding for the Samsung s6e3ha8 panel found in the Samsung S9. Signed-off-by: Dzmitry Sankouski --- .../bindings/display/panel/samsung,s6e3ha8.yaml | 76 ++++++++++++++++++++++ MAINTAINERS | 5 ++ 2 files changed, 81 insertions(+) diff --git a/Documentation/devicetree/bindings/display/panel/samsung,s6e3ha8.yaml b/Documentation/devicetree/bindings/display/panel/samsung,s6e3ha8.yaml new file mode 100644 index 000000000000..9d7d747264dd --- /dev/null +++ b/Documentation/devicetree/bindings/display/panel/samsung,s6e3ha8.yaml @@ -0,0 +1,76 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/panel/samsung,s6e3ha8.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Samsung s6e3ha8 AMOLED DSI panel + +description: The s6e3ha8 is a 1440x2960 DPI display panel from Samsung Mobile + Displays (SMD). + +maintainers: + - Dzmitry Sankouski + +allOf: + - $ref: panel-common.yaml# + +properties: + compatible: + const: samsung,s6e3ha8 + + reg: + maxItems: 1 + + reset-gpios: + description: reset gpio + + port: true + + vdd3-supply: + description: VDD regulator + + vci-supply: + description: VCI regulator + + vddr-supply: + description: VDDR regulator + +required: + - compatible + - reset-gpios + - vdd3-supply + - vddr-supply + - vci-supply + +unevaluatedProperties: false + +examples: + - | + #include + + dsi { + #address-cells = <1>; + #size-cells = <0>; + + panel@0 { + compatible = "samsung,s6e3ha8"; + reg = <0>; + vci-supply = <&s2dos05_ldo4>; + vddr-supply = <&s2dos05_buck1>; + vdd3-supply = <&s2dos05_ldo1>; + te-gpios = <&tlmm 10 GPIO_ACTIVE_HIGH>; + reset-gpios = <&tlmm 6 GPIO_ACTIVE_HIGH>; + pinctrl-0 = <&sde_dsi_active &sde_te_active_sleep>; + pinctrl-1 = <&sde_dsi_suspend &sde_te_active_sleep>; + pinctrl-names = "default", "sleep"; + + port { + panel_in: endpoint { + remote-endpoint = <&mdss_dsi0_out>; + }; + }; + }; + }; + +... diff --git a/MAINTAINERS b/MAINTAINERS index a2f416e4a7c6..fddbd50f7685 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7150,6 +7150,11 @@ S: Maintained F: Documentation/devicetree/bindings/display/panel/samsung,s6d7aa0.yaml F: drivers/gpu/drm/panel/panel-samsung-s6d7aa0.c +DRM DRIVER FOR SAMSUNG S6E3HA8 PANELS +M: Dzmitry Sankouski +S: Maintained +F: Documentation/devicetree/bindings/display/panel/samsung,s6e3ha8.yaml + DRM DRIVER FOR SITRONIX ST7586 PANELS M: David Lechner S: Maintained From patchwork Tue Jun 18 13:59:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13702397 Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) (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 C1AB215B152; Tue, 18 Jun 2024 13:59:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719199; cv=none; b=o3r0SUnuY5NFFHJqM5Bwpi8FlAtMEc4v8XgnBFzpjM9B8HiVvdcDDNSq8s9EWi/byfGp59/+dw37/sKV7alJeRF/hzMq8pgf5qKNePp12HcIrJUGkgvo2H34a4yJhv0mTrx8qtJOcIL7XIJPIzL7EBh7xL1OoVNkI1rA/s/cSrs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719199; c=relaxed/simple; bh=MaUBYzY2WY/OtOBoG9JKcNCjTiDo6fotvBHEhgKFVL8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PDejvRhLfm/nlwaY1MfynmqeepRClh1Sux4zpla799NuofVos0Bw+jj5ZFYjdeefrpPpelzFGVmdXStlMXtETFg8Tj59vNZ8VL/39GinF8p5n1u14OdCro6LwMAXkbrAnYtKr3/Q5D7SmUKNEyiAZe3RaKIORGrFFOk7QX//ks8= 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=AewqKV2P; arc=none smtp.client-ip=209.85.208.48 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="AewqKV2P" Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-57c75464e77so6757767a12.0; Tue, 18 Jun 2024 06:59:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719196; x=1719323996; 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=ZQdkm8+F4B6bFBNQodaWJBcqC8R3HTo/EbqUkgw994Y=; b=AewqKV2PIpS/cVWFbSH+XU5qdBS5mCadumK6XVbAt2dHuAYSX3LEdjyd8DBcZoeZxf 2t4eC/HUzOGuI+qNbP/Ey0SfM7izt0iHbYJH4GaZmg24DqQdDAQRsj9ewc14Hkf5afsl m36Bp0zkreR7/wx7ZTSHu41URAUDOWsjpaoj+drWgSd7ncdJIhjR/u4xE7UwCMGhburY 5T2pbLTzKY7V7wFulgIaBsM/pJMVQexIjb4lr1tA0oXExABnl2hjQOcCul4hHNb0+rJt 1QWL1zg0goHE2trUbCeLwkAf98ViDPT/I8+XdLLYaqWkN4Ahm/Ng8Q32UvIlmy8djSi+ BTrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718719196; x=1719323996; 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=ZQdkm8+F4B6bFBNQodaWJBcqC8R3HTo/EbqUkgw994Y=; b=ZJJVizBpogeB+9BI92wLLQgSYXJGhw2Ma8ZpVCN+i6dxQI03zwlVUSBj+n6Ry1YulM UkEX63Z7nzlxDx2thVEg1jND7ofADjbUGSWHpD5lJbX4M8jV5w1ZPAS3oOrZs8OnipB3 lyhygwE6UGx5YrQyhcgQLzlHGDxbYTROOgHvk9qdLrxTyQbgHcgG6vshm6RrbOJFh87h glePn+HWXUZUIE3cV8CrhYSxMOPeDlSMTTfcKqnlx+LkpMKXxqI0w/eWskgRD0yOj5UI DZu98FNbI5aZhMdQb/n4qjzOEc2V/mrpxK6S6DIZdeX2GImShROXwgYVBvX3IEG1LRrJ g9xA== X-Forwarded-Encrypted: i=1; AJvYcCUEZVMzE29cd2kCGBW7+DJTl5UuFr91Nnp+N6rlpBiOblULuvtigsenDkIQ8r3a+XlBAW7kQTEfEHVELN/N6uvZNbbBQwwAk/JGT5rF61iKfZzhUX8n/4YhuyjEeI5RylFx09ZfIrrEsTVGzG7RtMX7evUAVFnpjNEwlrd0FuXn1/DbihJoBoV0Xesxo6/C3A0o+7/0gKjxr8s/5KGCDOxrw6gM3ZQhwJxnwQ9KATj45XhHcOTIFKtmfEVOFAMl5mvQdZbOu4CNXxWsKgJRY/9DFAliylRiIUxdcrCDVPTOEyr3c4JJ/eHdVXhv/gIvFoAdDuj+aIKvtL1M96TPm1ANiowZHDepfMaugG810SKTpmDG3sKlry54zwpTjTA+yrIY+j2j1lUsRVu3Mk633QIgKlC/SxC+ X-Gm-Message-State: AOJu0Ywu+6JRYd1Pwt0+lksf9hAIQktxcm/MxcZDVTiNDKjcMek4P1Jy Vwf5mnXqO/iPfQP6cIaA7vIfeFh4iNrg6xmcWYkEtTIGIuP74WdAROqMxtYc X-Google-Smtp-Source: AGHT+IF6kH0YtvSPT4MaBaZOV0LLPUManxnMgMPB/xjZSsumWnmHYW99B3fvD3yZot9inNzwJ3g4tA== X-Received: by 2002:a05:6402:28cc:b0:57c:d237:4fd with SMTP id 4fb4d7f45d1cf-57cd237059bmr6070351a12.4.1718719195988; Tue, 18 Jun 2024 06:59:55 -0700 (PDT) Received: from [127.0.1.1] (mm-167-232-122-178.mgts.dynamic.pppoe.byfly.by. [178.122.232.167]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-57cb72da156sm7731278a12.22.2024.06.18.06.59.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 06:59:55 -0700 (PDT) From: Dzmitry Sankouski Date: Tue, 18 Jun 2024 16:59:38 +0300 Subject: [PATCH v3 04/23] dt-bindings: mfd: add maxim,max77705 Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240618-starqltechn_integration_upstream-v3-4-e3f6662017ac@gmail.com> References: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> In-Reply-To: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> To: Sebastian Reichel , Bjorn Andersson , Michael Turquette , Stephen Boyd , Neil Armstrong , Jessica Zhang , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lee Jones , Dmitry Torokhov , Pavel Machek , Liam Girdwood , Mark Brown , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Krzysztof Kozlowski , Konrad Dybcio , Chanwoo Choi , phone-devel@vger.kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, linux-pwm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1718719184; l=3812; i=dsankouski@gmail.com; s=20240618; h=from:subject:message-id; bh=MaUBYzY2WY/OtOBoG9JKcNCjTiDo6fotvBHEhgKFVL8=; b=kBr0hfj63DNZCcoJMRp3NdqL4vLs5OVhqtP9nRhL8IZsExqfYiNg80mksKZ6ciNZZYi+7gDBQ aTZ8nXPx505AJOdyQUWKd9jlnAdtRzTSiAiIVOCd6RVGxncdwXI0/M5 X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=6pMMVVDDReSiRgPCbMOUauN5nS3ty4Sf5b7a2gi4x0M= maxim,max77705 is MAX77705 pmic binding part Signed-off-by: Dzmitry Sankouski --- .../devicetree/bindings/mfd/maxim,max77705.yaml | 112 +++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 113 insertions(+) diff --git a/Documentation/devicetree/bindings/mfd/maxim,max77705.yaml b/Documentation/devicetree/bindings/mfd/maxim,max77705.yaml new file mode 100644 index 000000000000..b54408e3d792 --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/maxim,max77705.yaml @@ -0,0 +1,112 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/maxim,max77705.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim MAX77705 Companion Power Management IC and USB Type-C interface IC + +maintainers: + - Dzmitry Sankouski + +description: | + This is a part of device tree bindings for Maxim MAX77705 multi functional device. + + The Maxim MAX77705 is a Companion Power Management and Type-C interface IC which + includes charger, fuelgauge, LED, haptic motor driver and Type-C management IC. + +properties: + compatible: + const: maxim,max77705 + + reg: + description: + I2C device address. + maxItems: 1 + + interrupts: + maxItems: 1 + + interrupt-names: + description: + MAX77705 shared irq. + items: + - const: max77705_irq + + charger: + $ref: /schemas/power/supply/maxim,max77705-charger.yaml + + fuelgauge: + $ref: /schemas/power/supply/maxim,max77705-fg.yaml + + haptic: + $ref: /schemas/input/maxim,max77705.yaml + + leds: + $ref: /schemas/leds/maxim,max77705.yaml + + +required: + - compatible + +additionalProperties: false + +examples: + - | + #include + #include + + i2c14 { + #address-cells = <1>; + #size-cells = <0>; + + pmic@66 { + compatible = "maxim,max77705"; + reg = <0x66>; + interrupt-parent = <&pm8998_gpios>; + interrupts = <11 IRQ_TYPE_LEVEL_LOW>; + interrupt-names = "max77705_irq"; + pinctrl-0 = <&chg_int_default>; + pinctrl-names = "default"; + + leds { + compatible = "maxim,max77705-led"; + #address-cells = <1>; + #size-cells = <0>; + + led@1 { + reg = <1>; + label = "red:usr1"; + }; + + led@2 { + reg = <2>; + label = "green:usr2"; + }; + + led@3 { + reg = <3>; + label = "blue:usr3"; + }; + }; + + max77705_charger: charger { + compatible = "maxim,max77705-charger"; + monitored-battery = <&battery>; + }; + + fuelgauge { + compatible = "maxim,max77705-fg"; + monitored-battery = <&battery>; + power-supplies = <&max77705_charger>; + rsense = <5>; + }; + + + haptic { + compatible = "maxim,max77705-haptic"; + haptic-supply = <&vib_regulator>; + pwms = <&vib_pwm 0 50000>; + }; + }; + }; diff --git a/MAINTAINERS b/MAINTAINERS index fddbd50f7685..f008429033c9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -13682,6 +13682,7 @@ B: mailto:linux-samsung-soc@vger.kernel.org F: Documentation/devicetree/bindings/*/maxim,max14577.yaml F: Documentation/devicetree/bindings/*/maxim,max77686.yaml F: Documentation/devicetree/bindings/*/maxim,max77693.yaml +F: Documentation/devicetree/bindings/*/maxim,max77705*.yaml F: Documentation/devicetree/bindings/*/maxim,max77843.yaml F: Documentation/devicetree/bindings/clock/maxim,max77686.txt F: drivers/*/*max77843.c From patchwork Tue Jun 18 13:59:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13702398 Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E592915B57B; Tue, 18 Jun 2024 13:59:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719201; cv=none; b=mbZw/eUTmZMZ8MkYl3JBqEeEsXh9A3kU84xaJJwtATMd2C+7oyvYoecQzAqAAC+eU9NYiIE2L+AuyPz8JpcQzBANyo8/ha28G9Z83bPsxATZ0qxgn0J6bqLAGu+w49OnmknPlSQbfFW8uiRV+fLoeLiZb5s6mekO731V2yyU6c4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719201; c=relaxed/simple; bh=qthIpOYuUqEKsnF/WfU6OBlZPhcwRZUIhgo+lk7uE+8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QQ4D6l88F9L82lis5HryKjmqpG7T/+YnqF/w/Yy5Hv3TL9L2FldJAGEL+2/EMzw0iNFsnd38H/eYh109lVBxKa+JsY4SmLLWV18WkGpdrxhWFEF0f/2uQogAmlsSwkWK4rkbyXdU2H2hvFNELJPpoBA7kPjgblU/KLP3NrQ8Lcg= 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=ThSVVksV; arc=none smtp.client-ip=209.85.208.41 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="ThSVVksV" Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-57a4d7ba501so6833205a12.2; Tue, 18 Jun 2024 06:59:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719198; x=1719323998; 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=Upy6fBZOR1H2GEGfXG5Z3nttQhCGYdXb6UIkk48wC28=; b=ThSVVksVQGJZAq+UH9hyafuc9P0hkGXrkPTDjCSHZzGgwWR7cVb1mX92bUuwMI5d5d m7JAa9kwEd3T8IdI+WyEjlDAHaY0sly9i+ijE1NCHp0NNFqk713p7wFwv74tduK9sajR 9ZlROKtieOd6sHQ7Zpf+h9dkFR5bvF/neXcMojxeV0ClYK29qMxHJk3gf1ZIOOKvTLmh 2CPD+v5h4C0kAlTrWP3NKrLkxzPm6sNiTQrPLiQcUh7LMc4tsAvndl9lPRKDgUiNfiKr 7dzbXQg86MXH7+DFBdd1x/bvfXcJ3UDS68E389xPl7rkenCtp0E+zR8/P19iiPJsCzQz UgWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718719198; x=1719323998; 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=Upy6fBZOR1H2GEGfXG5Z3nttQhCGYdXb6UIkk48wC28=; b=lK2KAWteDjFw/d1Jyxe0fn/RJ0Tfb54CXomheJLxmyO8LxV5viF1z4VuTBjG+dgT7i KKKYg7DJqaBruwRX+QSTlsKRkwNMxBLUf9Sdm3Igvfk7gs6JR0oz5Yqfq1ga8zx/ypNR nk6YW8DzT7jlq75gQlvxzH65aTty2STRTbFVhtfjQkZB7DFgwrlLnEUOsGtbSm8MsrA0 eY8Kfnxq/ECXoNG/ItGlNxYbwQ7f8o7QrowDEqUlLaYlO6A4kV48BCrcepnCWFnqqcD5 DsN6/RhcIR7GIeKB/Mir4mRc8OEo8dr/Ldx/H7slo+/FuYo1aJcQcWpbnS8qfaNBYDFp FeHw== X-Forwarded-Encrypted: i=1; AJvYcCUS8A9K/FHkFifdy/2Dc7rftqllfk+frb0XDvdTV/gRlgy3jisINxST4wu/ZbwiE1f3GBBCv49oPWE3Xlwq6LetT7npjGQwVCDDOyCDVCChJS8ytfXNsO3hVbfr980gfW9XR1FFhYYkRCdXFqdS+x07apjRdAkSi49vwMYzywxcUyrHRcs9VR0EPJq2kLwWLy+58EwLGgLiPXT9Fe3k1XCd5D6M9AG39McqQjy8dSKU+M5Nvzy0TuUQltWZTs2syW35A4Uje5dqr+3tDbPWmoojWpbLSvFiwe0P+9q+JRZoW0nNNvkpM+g978+Ug1neZgV3g/G2e+SQjuhRkps7FNonev3bfugmPB9Yk1TVJ59c2DXt99jMYYJF0bluzZWydch3aIkfhLByJfjuD4jq/XIhPfr/LF3G X-Gm-Message-State: AOJu0Yxo3wHNEQON2DN23Xr4xuuKsDV7JAAesO4AP/TVNOIsqbq14gN4 xHWtoflC45rbQB2b1/4MpZkN+qGvhb6xWdCgvjsi5xpJCjnPBy8e X-Google-Smtp-Source: AGHT+IHMqfIH2/+QaLV+rotp1RiZdfhBoayjQhqdenR5458icQCIvicX3Uj89frks5W/jGab9ZLt+Q== X-Received: by 2002:a50:c31b:0:b0:57c:ad11:e755 with SMTP id 4fb4d7f45d1cf-57cbd69c382mr9094793a12.33.1718719198162; Tue, 18 Jun 2024 06:59:58 -0700 (PDT) Received: from [127.0.1.1] (mm-167-232-122-178.mgts.dynamic.pppoe.byfly.by. [178.122.232.167]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-57cb72da156sm7731278a12.22.2024.06.18.06.59.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 06:59:57 -0700 (PDT) From: Dzmitry Sankouski Date: Tue, 18 Jun 2024 16:59:39 +0300 Subject: [PATCH v3 05/23] dt-bindings: input: add maxim,max77705-haptic Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240618-starqltechn_integration_upstream-v3-5-e3f6662017ac@gmail.com> References: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> In-Reply-To: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> To: Sebastian Reichel , Bjorn Andersson , Michael Turquette , Stephen Boyd , Neil Armstrong , Jessica Zhang , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lee Jones , Dmitry Torokhov , Pavel Machek , Liam Girdwood , Mark Brown , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Krzysztof Kozlowski , Konrad Dybcio , Chanwoo Choi , phone-devel@vger.kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, linux-pwm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1718719184; l=1304; i=dsankouski@gmail.com; s=20240618; h=from:subject:message-id; bh=qthIpOYuUqEKsnF/WfU6OBlZPhcwRZUIhgo+lk7uE+8=; b=wssyoJ3JsY7QOzBApfw3BG68MDFIQFbKUYMtNH4F4598qUtec5ADE8WPLKSmTw5VIE9HxgqOW mZhnDxDmJLQBIDXpX/vHZ8MCzqNHjA8MVN4AIUp8pKkFz6LyoXbwdZX X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=6pMMVVDDReSiRgPCbMOUauN5nS3ty4Sf5b7a2gi4x0M= maxim,max77705-haptic is MAX77705 pmic binding part Signed-off-by: Dzmitry Sankouski --- .../devicetree/bindings/input/maxim,max77705.yaml | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Documentation/devicetree/bindings/input/maxim,max77705.yaml b/Documentation/devicetree/bindings/input/maxim,max77705.yaml new file mode 100644 index 000000000000..8f065a2fe7bd --- /dev/null +++ b/Documentation/devicetree/bindings/input/maxim,max77705.yaml @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/input/maxim,max77705.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim MAX77705 Companion Power Management IC haptic + +maintainers: + - Dzmitry Sankouski + +description: | + This is a part of device tree bindings for Maxim MAX77705 multi functional device. + + See also Documentation/devicetree/bindings/mfd/maxim,max77705.yaml for + additional information and example. + +properties: + compatible: + const: maxim,max77705-haptic + + haptic-supply: true + + pwms: true + +required: + - compatible + - haptic-supply + - pwms + +additionalProperties: false From patchwork Tue Jun 18 13:59:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13702399 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 ACA1E15CD6D; Tue, 18 Jun 2024 14:00:02 +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=1718719204; cv=none; b=a1xdWSel15jOP6buTqZJfX6Zdd6M+WRbUSpW5E9KlR8+l8wKpLaMWahKiEthRUWKMNBB8jTPQA4pYJExO1+ejMnc0v8i06kn/+gTYHd/TxklHRKHCZTvhG+WNh0KRYhkTHw+pm2Aftp7hxV9o4nXNWfFbE5dCVawAOeLk1ahBMA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719204; c=relaxed/simple; bh=dgJy+BucY6KOgzZn5R8UqVuWZVsOdC8WyvzpCfw1lYE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VaF6sxutMk20Ys8t6zFraN3MOQhns6YSjT7Hf5GSA/RiD9HbdOjxhp7LrM8r9LP2g9GtCz2663rXgeRfrL7pXMulD6+/F4PrAG/pRrHnSZLisqQ/qcMyKjDo8QOY99SNYxv0zeFXpSCGcctswX4HyJjcL8XjcQ+PU4QO2hgCpvo= 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=GTuzwGtm; 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="GTuzwGtm" Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-2ebe3bac6c6so60712291fa.1; Tue, 18 Jun 2024 07:00:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719201; x=1719324001; 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=6A3+2iwaC1/XVmavDthDLZ4K+/3BScbJzSpnb3NVRSs=; b=GTuzwGtm1X2zQmLnQ775UkuIrEbeNs1VFnkVM3eYShGexDPtkq1KLikd+a/fFOdLme mrWoovsmXl10X7+VHYU3gQ7f6CJhXbRLLvb45tnqrfrqz7vSW6EC87Cvzs46WBtPTTSL IfEjgwEcgxnHF5moQr625vVHHhEzDoGvepEe+LtbiDC/d1OkNu61VUPzEAm02JfLIgaS 0tsEs8oU0m4DSrmP0FtPHjYvCre5R9NQsQVND75du8yyzFrZ3wSHKVv+6//ZcSZa13WJ +no1puNddh1xPvG8Yi9e/15vTkU5Qc0itONgoAx9vulPLEH5Li0LdK+6is8X6qYWc062 nDQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718719201; x=1719324001; 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=6A3+2iwaC1/XVmavDthDLZ4K+/3BScbJzSpnb3NVRSs=; b=U1ntsd/Qm/ZWPtGV1lGeNY2aRJyMIGIoGFE5OTKYxMIzGK6PXD9G5uPgjI9CKUdDCM ibWBCF/jqoCw7UbG21H8bBY3y3Vb00nfBe6dbxkwPbqSk9EsXPngsVe6UqjMyW+rsVhv n5QcEFH3TeGa0GwVcNyMlxZ58fXbNNWpmY/je3GEJNIW7fDu17dZDNnlFQVT5CHrA/Se fpjVoQ9GQg0ARk80rvZKB7D0Hz/JO0Q89lN4jPjcZFnrOHwWeZPuDtdnrXI0etSnjVdR CjGXZDfiLQBXAeJD96YrDVMCoVxvOlwisxIQhVDfuW8A7nm/hFLYb7Ve6Ac197O4sa8K fzgg== X-Forwarded-Encrypted: i=1; AJvYcCWraS62uFkmwUIJaoS/ftS+4+iwVpMg6h1jckEKVANUCba7J1uKq8rtcmsvf4djhWbp2ZfWhlPWANPy6gWitEPYGGf3JHeQrjvLPknLllyE0nfIMmGbEm7MBPC5SM/O0Rs4mznMJyNE+lHV4PvbwB80Le31/45loWiSHIXMMHQgNs9l+LB/Sy8XYnZ4r9xDRVb8ScwW3Nv0A91j5OTwHS4cAb51FAZ3giO/SvLwu+DrfgE7huYdOOdC18VPure07YJz8mp8+sOzURFbhY+RlL8n1fWdqT99lK6wjL2MVQsULcekezfVMaNRgThrRsLUjMMcxkX419z7V9yuXAzoubxpl1269KGL0eZWU1dz4ODyxTvoe9tEOffEVdd8X/NrfBZImfKOia4/RwmD8mnqRy0D+phF2KSM X-Gm-Message-State: AOJu0YzacK5IvE06AQKEhxD8c+izTObSuSF6FxJgNTtAsFNnycSFrC58 Sior/iwSN0UgmIjwg6cRym7/eJ8rWQF57I9qbHJgXB8p/rCuxFjb X-Google-Smtp-Source: AGHT+IFlmX/c4ZFv+qoeEd0Kwe0J+as2CgfWHsxDLcBiN6HGFbLvve0i3HX+10AQGoM9rdBOnoEHpA== X-Received: by 2002:a05:651c:10c4:b0:2eb:d4a4:42a1 with SMTP id 38308e7fff4ca-2ec0e60e835mr100649901fa.43.1718719200637; Tue, 18 Jun 2024 07:00:00 -0700 (PDT) Received: from [127.0.1.1] (mm-167-232-122-178.mgts.dynamic.pppoe.byfly.by. [178.122.232.167]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-57cb72da156sm7731278a12.22.2024.06.18.06.59.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 07:00:00 -0700 (PDT) From: Dzmitry Sankouski Date: Tue, 18 Jun 2024 16:59:40 +0300 Subject: [PATCH v3 06/23] dt-bindings: power: supply: add maxim,max77705 charger Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240618-starqltechn_integration_upstream-v3-6-e3f6662017ac@gmail.com> References: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> In-Reply-To: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> To: Sebastian Reichel , Bjorn Andersson , Michael Turquette , Stephen Boyd , Neil Armstrong , Jessica Zhang , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lee Jones , Dmitry Torokhov , Pavel Machek , Liam Girdwood , Mark Brown , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Krzysztof Kozlowski , Konrad Dybcio , Chanwoo Choi , phone-devel@vger.kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, linux-pwm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1718719184; l=1332; i=dsankouski@gmail.com; s=20240618; h=from:subject:message-id; bh=dgJy+BucY6KOgzZn5R8UqVuWZVsOdC8WyvzpCfw1lYE=; b=ZwEhTU12BEK6xZcNcocP5DTvk5amgaqarmU36A5zA3ClN0GV0Z6ITAzUiQWgH2ylIrVpipKEi es6j/VVP+FPBYMiD8HDlU4v3vRWPnI/6v5pYPLRLup43GxlOqtUOW5+ X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=6pMMVVDDReSiRgPCbMOUauN5nS3ty4Sf5b7a2gi4x0M= add maxim,max77705 charger binding part Signed-off-by: Dzmitry Sankouski --- .../power/supply/maxim,max77705-charger.yaml | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Documentation/devicetree/bindings/power/supply/maxim,max77705-charger.yaml b/Documentation/devicetree/bindings/power/supply/maxim,max77705-charger.yaml new file mode 100644 index 000000000000..2b805da2a328 --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/maxim,max77705-charger.yaml @@ -0,0 +1,30 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/power/supply/maxim,max77705-charger.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim MAX77705 and Companion Power Management IC charger + +maintainers: + - Dzmitry Sankouski + +description: | + This is a part of device tree bindings for Maxim MAX77705 multi functional device. + + See also Documentation/devicetree/bindings/mfd/maxim,max77705.yaml for + additional information and example. + +allOf: + - $ref: power-supply.yaml# + +properties: + compatible: + const: maxim,max77705-charger + +required: + - compatible + +additionalProperties: false + +... From patchwork Tue Jun 18 13:59:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13702400 Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) (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 26E4015DBAF; Tue, 18 Jun 2024 14:00:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719206; cv=none; b=pimzDSjoxa+vn+lJrFWQJY1TTkwSzFJ4kzMCWf/Ib9xo72DznzZd1m+tP/YE2qA60cOfrVLrD4RbmAAatttBV+Rtsn2qLJGNM3lN+mJ2BGPUQ2NiQfsUOoGGPvWEBXeaCJghVPn7CKwmqb/8aHIy9fJtMbTyO8GpClVWA7qN/h0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719206; c=relaxed/simple; bh=kcP4CRKDseKYJTmDRkTK1Kkwp1UjhNtI1X6qAeNdmFk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PWviC1dXG+kUn0uNSLiZRKe1L5N64wYJx4krYoWc1eCw/i0p3L0HgZvDKWRBfsDYWT5RHGX9JllcBqlV9Hlzey8iC78s/sfVDwiZ2d6sghFlsSpjWta0wdnqmelGlzrl+CBruZIots8tneB8kP7BRt4wOO0SxvGn7pMFKAYp7Bg= 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=XZ/cRBIw; arc=none smtp.client-ip=209.85.208.44 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="XZ/cRBIw" Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-57c714a1e24so6223120a12.2; Tue, 18 Jun 2024 07:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719203; x=1719324003; 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=DAPyRIfn0zoFYR6H5DZfvZ7lLQ098EkhxsFz4D8wcf4=; b=XZ/cRBIwH/nW8ieZhABkNJQJDbiZ3xfORQdCkem+Fnm3ZYdzJQJCdRX0Vzog0AXpbb XDUMibdz3gi05FSN8UNJZBl4ZR9Y8RHUL4S+5xhyi0SGh6PSzZbQanacmYdeklV9EAAB 92yWXSMdqjqEgjNA0qdlda9I/RWM4Fh4zovZ213ppdzWa495hDMAQIPYH2A5VACMlm24 eqXcsI4avA6bJrQTKlhb1ViC5Sd3sUG8mBsaYNKPgSU6bm9bAbuPPwg78wYmtHMlF3IO CgMjYzpnvshVgHboRCrZ3ELyREuREW93LmJ0NV4bAE0NzrMqLNKzVUXKKWwRDu8MwR3q 5/WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718719203; x=1719324003; 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=DAPyRIfn0zoFYR6H5DZfvZ7lLQ098EkhxsFz4D8wcf4=; b=e3kCusskxE25UWoReVS76cBfVcYLyWlt7l5xgD64rHh+XVVGTgXbf2mvpd1gY5HYzq DuK0CdHk4K+O4DX9ls6H5Y0ASW3ZISSt8Ld/uo0FflOc/WSJvic4vJskYmf4s93GmrGO g0NchBkgTr0wD3tQlkHSU4bgGvTqG6NieXyVvvuJXLVTYr5evu/UD9oyGGJBoMPcASRV K7RgLekcx6WVpK23pDpCv07XI/gR0x9cpGeCBH3BZWiMQ1gwSRGD1A0OTFXf51CBe5Fc mQ4fH+foVB6plYcyRz06LYL2uJ9ac5kihZqmD7COcBVU7oaqQkP54zYqqKVlBN+62+iU QagQ== X-Forwarded-Encrypted: i=1; AJvYcCWNhNOqC3Eou/SGvCR+4gNRrWV3cny2aDGpuiURPPCsVzon1XHxshZYqsP2c2seUu3UONCV2OnBOvClb0z9NQjrFC0YB6NO0x8IKLpqPfKXh7yeWj3uUpO9sshAeK9ZJSMFl8i5M+NvWBPJMjbD6mrG+RfHTopnfXw06ha2Yax0LbSxZKF+5eiyCiNIlkn9V+kE6fIir8RMlJz3wmQn877SsYMskuCor/d0wqOupk7IqMqdKrlWFMaPsmMCOcHcPCK63QnrslP2LzRmp8KU0wa5xNyhvBCeD1nOg892bvfB/qoZwSrXJs7s8RlIdfvFSEbT50PEi5s1unwJrULBI/Ly1PeXfqpanbfFJxo5zxcSn1BFVLCSA1UTjUzhvO9zioNViThNoi/kleuaemqQ2v5n2nqZDb5J X-Gm-Message-State: AOJu0Yz0NY6jU9kSaH6BgscA4jgya53UtzFZoen66RUYyZyW4hdwqZNV G7uSw3yrza98jXW7/0Ou65y1el+HMWYChhbCqZNMrSLqQFIpMlJc X-Google-Smtp-Source: AGHT+IG+4lLZCtVPgURwIdcirf4nRr/hvjtf29y9VmITCHT3oab1SqgnU6wHrBAh8A/Xff1ksbBLsA== X-Received: by 2002:a50:9f8c:0:b0:57c:73ff:d13e with SMTP id 4fb4d7f45d1cf-57cbd8b9c60mr7324128a12.31.1718719202882; Tue, 18 Jun 2024 07:00:02 -0700 (PDT) Received: from [127.0.1.1] (mm-167-232-122-178.mgts.dynamic.pppoe.byfly.by. [178.122.232.167]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-57cb72da156sm7731278a12.22.2024.06.18.07.00.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 07:00:02 -0700 (PDT) From: Dzmitry Sankouski Date: Tue, 18 Jun 2024 16:59:41 +0300 Subject: [PATCH v3 07/23] dt-bindings: power: supply: add maxim,max77705 Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240618-starqltechn_integration_upstream-v3-7-e3f6662017ac@gmail.com> References: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> In-Reply-To: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> To: Sebastian Reichel , Bjorn Andersson , Michael Turquette , Stephen Boyd , Neil Armstrong , Jessica Zhang , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lee Jones , Dmitry Torokhov , Pavel Machek , Liam Girdwood , Mark Brown , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Krzysztof Kozlowski , Konrad Dybcio , Chanwoo Choi , phone-devel@vger.kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, linux-pwm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1718719184; l=1491; i=dsankouski@gmail.com; s=20240618; h=from:subject:message-id; bh=kcP4CRKDseKYJTmDRkTK1Kkwp1UjhNtI1X6qAeNdmFk=; b=/cukwzpYHF5iN3FfFAFfgniEdjw64YdmmzDzpAuzFjD3j6+McSzPALs9l5MdhIDFnxkIqnEyv 8YlqGe2NodRB8QMkSwE+giD0jR5APPEnJte16G5TK7KUZcHwrklY4zl X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=6pMMVVDDReSiRgPCbMOUauN5nS3ty4Sf5b7a2gi4x0M= add maxim,max77705 fuel gauge binding part Signed-off-by: Dzmitry Sankouski --- .../bindings/power/supply/maxim,max77705-fg.yaml | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Documentation/devicetree/bindings/power/supply/maxim,max77705-fg.yaml b/Documentation/devicetree/bindings/power/supply/maxim,max77705-fg.yaml new file mode 100644 index 000000000000..b24db0aba0d7 --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/maxim,max77705-fg.yaml @@ -0,0 +1,35 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/power/supply/maxim,max77705-fg.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim MAX77705 Companion Power Management IC fuelgauge + +maintainers: + - Dzmitry Sankouski + +description: | + This is a part of device tree bindings for Maxim MAX77705 multi functional device. + + MAX77705 fuelgauge with ModelGauge m5 EZ algorithm support. + + See also Documentation/devicetree/bindings/mfd/maxim,max77705.yaml for + additional information and example. + +allOf: + - $ref: power-supply.yaml# + +properties: + compatible: + const: maxim,max77705-fg + + rsense: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Sense resistor value in mOhm + +required: + - compatible + +additionalProperties: false From patchwork Tue Jun 18 13:59:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13702401 Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.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 C2D4215DBD5; Tue, 18 Jun 2024 14:00:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719208; cv=none; b=aD+RospM9yJl+EY0ARgqsYVocuU5e30TARvcsRzL5rqtEZUFzKcz4+jaymeYFf9kcORdw6iT8dDZcUj8YiecnP9s1r7lMhW1v4j43jrOgCYnK63EO27IVn0DXvFLBixy4jd8+JfdcAkeumTOjUXzPJrBIJ6R3GCvyz0Y5x7nf/E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719208; c=relaxed/simple; bh=7GuLNZWYidLfySwdnHMlO3cKyzwike5F0Axou4kYDbM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sj6hHiJ2fCzT+Ld1r3iJ+dnxaXjtYJ1EzlGK7KzAkzcU7p3SLq0y1tNJ1FpuJWNPZ9AeZlmn4nQirKfhY8VNizoWXfbEO24/5/pvbMEYt0A3+BYkf5xYpNCJSkf5bmQrhcWtwXJ3QO8UKyb6l331SWNMl2bZs9siTUQp0AgdN0Y= 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=fvpY7Ypc; arc=none smtp.client-ip=209.85.208.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="fvpY7Ypc" Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-57a1fe6392eso7346558a12.0; Tue, 18 Jun 2024 07:00:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719205; x=1719324005; 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=amtZh6cok3kVxxh2UoadCf51Ge+lbZ422aIWYrzWULU=; b=fvpY7YpczSg8xf034VDQ73Ulz/AYfNLcRsj6ViByhg5Mzs8fGdJfnsNYlatzWKuAWb RjhebBRLNgU6sU1YN27C0H6BJ6bgcgPq2ojkbe4KnL/gPspe91gyJQgkUrHFC+8QFusT JpFIeSE5VKP6XPcwBjVBRpFaaNTmdFh5TUu6jpqUMD9WEyHQX8No+rdJASdvngJjO2vB ICaS7yvVHK2LkpJzEgj665UDgw9Zz/Urlnr2TUeClAwwIXuTJzSbwXX3ePJ93uYbfvUV Hsa0s36NW2D/sQwZ7wEUTG2Oqgmf/pL6qom6zqhpt+SIH6YlOgc0E3XsSHkuaMPxgDL3 BvpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718719205; x=1719324005; 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=amtZh6cok3kVxxh2UoadCf51Ge+lbZ422aIWYrzWULU=; b=nEI+Yo2gMKqnA9agMuGzFzTMAmv87msNYPIaqzXy7joQnN6FNeFnCm6BkhRihBVEyq dadd/HJ2h4PzB1ZJ/CkWdODbcw8Z9IbFTIBie8CHQBYRQfVjcDkNQmXKDHKyh4d/663a kwCymOXghoUd7Ii+BAtKuXY5cQONy/XRfhD1+f1M7uwbabIqpvNm1vb3ZIwlXo6/OQ2n k6eZpJzB1HWmVL5His8XioOk+4RjmKCPhpXOVM3yieAzBBDw9vD34mtxcPDfi73zEX9F OsYAVXOP5w+GRwovpSd6bwuNTGfvdT3TqMMxX13OP2XX19gFlHjo2QkyG5XDIlq6T683 vQeg== X-Forwarded-Encrypted: i=1; AJvYcCU7D1LJdAv1/5SqcgBYe5kBA10LBzV+D23pia0eD4kTvV56vE78kjS6Jl0r9JWM55vwVnqdo+XHI6rAErHXgx/3TB7KEhvR2LpicOK1qaR/d+7kfLYnvEjbFTLttoRpJOFxYSASn1ofZadAS0jHXbZhCQzcFyyuY39Kq43NugUY0PtbFV+YI6Cqck1kIdy3LyfPqYjHgynIbAGQEl/P70ThQ+A6DDPN/cvXj0MIDhL5cs8xyJA98lGCZ/mJflSKXGA+OAMxvzi4CzEL20mnMhfCI07CzM0rwAGixyPBUMQQ7tqRAG63B1kq4REDD/Enb+uB6JAk23DQKIcmMtPsJ5yGdLTbwUSvdI8MS0P9e0x/2MZ3LEnEm/PduAgH9AKc8Li5/29OAhxKwaUZuJO+xLG8JK9NOpsq X-Gm-Message-State: AOJu0Yx9aDWib11lOHpPdCQIgCwTedY+XYP/fB/FSb4Zu4pZNFqTbj/4 ded59l6MIeeEIWY71C17T7jPFBnnVhw9rzlnG7vmfjJ8qP6Us+r3Y972BlKT X-Google-Smtp-Source: AGHT+IFacU/UFpIwaTa6wZ4f7sRQWphBmkbeBykRZgSzZFVXbMNWcd77zosms23rqaQYfYGh0AnbgA== X-Received: by 2002:a50:bb44:0:b0:57d:57c:ce99 with SMTP id 4fb4d7f45d1cf-57d057cd44fmr206656a12.2.1718719205082; Tue, 18 Jun 2024 07:00:05 -0700 (PDT) Received: from [127.0.1.1] (mm-167-232-122-178.mgts.dynamic.pppoe.byfly.by. [178.122.232.167]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-57cb72da156sm7731278a12.22.2024.06.18.07.00.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 07:00:04 -0700 (PDT) From: Dzmitry Sankouski Date: Tue, 18 Jun 2024 16:59:42 +0300 Subject: [PATCH v3 08/23] dt-bindings: led: add maxim,max77705-leds Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240618-starqltechn_integration_upstream-v3-8-e3f6662017ac@gmail.com> References: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> In-Reply-To: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> To: Sebastian Reichel , Bjorn Andersson , Michael Turquette , Stephen Boyd , Neil Armstrong , Jessica Zhang , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lee Jones , Dmitry Torokhov , Pavel Machek , Liam Girdwood , Mark Brown , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Krzysztof Kozlowski , Konrad Dybcio , Chanwoo Choi , phone-devel@vger.kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, linux-pwm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1718719184; l=1609; i=dsankouski@gmail.com; s=20240618; h=from:subject:message-id; bh=7GuLNZWYidLfySwdnHMlO3cKyzwike5F0Axou4kYDbM=; b=wXF+V0LgvlhWhOUO8mOS/t/tdcu8fI/3fxi/NQRj3GlXy4qHn3uq8gHX7IrZD2ooIQihcNAZe 045YHR9yMxgCijG6bla4uPQq0zI6T5wO2cJU1U6TcVPhCbOH+3UPBUG X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=6pMMVVDDReSiRgPCbMOUauN5nS3ty4Sf5b7a2gi4x0M= add maxim,max77705 leds binding part Signed-off-by: Dzmitry Sankouski --- .../devicetree/bindings/leds/maxim,max77705.yaml | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/Documentation/devicetree/bindings/leds/maxim,max77705.yaml b/Documentation/devicetree/bindings/leds/maxim,max77705.yaml new file mode 100644 index 000000000000..7c512545788a --- /dev/null +++ b/Documentation/devicetree/bindings/leds/maxim,max77705.yaml @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/leds/maxim,max77705.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim MAX77705 Companion Power Management IC and USB Type-C interface IC LEDs + +maintainers: + - Dzmitry Sankouski + +description: | + This is a part of device tree bindings for Maxim MAX77705 multi functional device. + + Up to 4 LEDs supported. One LED is represented by one child node. + + See also Documentation/devicetree/bindings/mfd/maxim,max77705.yaml for + additional information and example. + +properties: + compatible: + const: maxim,max77705-led + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + +patternProperties: + "^led@[0-3]$": + type: object + $ref: common.yaml# + properties: + reg: + description: + LED index. + unevaluatedProperties: false + required: + - reg + +required: + - compatible + +additionalProperties: false From patchwork Tue Jun 18 13:59:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13702402 Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.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 1912815ECF9; Tue, 18 Jun 2024 14:00:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719210; cv=none; b=BJsnc0JU1vf5OOBmIUpddwsRGx322QMdy8fGItwp112rg+onYLoVErtqSx8TQPofqHI2Iu5NwksMQKzq2PFYBfQreXddGFlv5RfZHyhyyfUZVp7N08vKgKcFybbVzodjJ0C9iESzYVHZ4DdtyIAjUbMvWb3zw8tyzzAa95Bgm+k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719210; c=relaxed/simple; bh=GeSjdBMrPx5/NgT7rDPKCihsvNHSXF0w4Z/AktYQJMg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZbakU9RhvT8plVKz/tF1MxBboj7uqqmWFLZQTNnqZ9+F0CoaNNzi81TuvtZZ8tJc2p7evceWtumGuD4yLVrdBSyU4lmGikw1/detSh0U0ktGIqForSSu5W53Op/Gba8tApDiTfN36jjXFBoEd5KqWjDYRQkt9kdFrnr2B7sHRU0= 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=HVuYx68U; arc=none smtp.client-ip=209.85.208.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="HVuYx68U" Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-57c75464e77so6758003a12.0; Tue, 18 Jun 2024 07:00:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719207; x=1719324007; 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=evq88jlvU8RulgmUy64jbhNijl81dqHkwYkJ8InB99k=; b=HVuYx68UIYBqOvBHiK7st63eHkHDVCbdXNh5qVZiAO9qYbdiCzSJ3cUbQZJ3rUWP22 AouRSei1OjHsvJlV7aRv254ROq1CpS7L/63TSRJcMhSN1RMop0oPUqbfIijpVFaw8kIa 3iaxELgv0OM0jl0izVvua4mHi6/rI5ZDv24NlGfEQcfVXbV36VACBed/OaUhKOC2tzVd FotEtmX0R7r2Bwi+CPRogyjnjxThK4ktPIcivp6ql0UHXByszkxuvQEcVsTscbbCfoMm 0C+PpCk2P92lcJsVirMwsSQSk7iQ8QPgZgZqGgKyD2CRvTROuHqpPHSPn/VsZo+qaJNV PHig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718719207; x=1719324007; 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=evq88jlvU8RulgmUy64jbhNijl81dqHkwYkJ8InB99k=; b=SWP1zma0XJYCPFI5laLnYrb9WLMLJX1au4yF8B4ZapI7JWCy65IA0q91O83ENQgCzO 3ZSMsRFWkcmHBv+fzqxemRWHXhv3mS+kgYk0RogCxh2/tCy9QCSA7SqqJNRqutMmyTgT ox8oUB0YEt5+CgE1LGb3Hi38zzGo4wQzcwvYqZYPjPoFh74HrKB/PaiFZRZYU9RuOzrB pWgAoJ+y7zEuR8bKwojkBWbVCinsysGRf0goElt/NB8rOyAZsTAkYS239MGlKl5/IIF+ hLOvVrEjBaRbvhkGFpXiE/C3iNsbEX/ZDLTdmNU6WwpPdc2cKz77pNWOZqAHEak93EFr t6KQ== X-Forwarded-Encrypted: i=1; AJvYcCW+6pcXnNXnWNxAuEFRqjSylG/WSetk8RtaVnvrO+a24OB5cuP0MsICI7u1dGcLVpNnXWC+V1cCixKXSbqXXQ98vJs9fD9tFXExFsDB4jlOiDfHMDhqtaljITAhluWDAEmudu4nITY897rEBqg55NpyPPNembZyK1jLqf7ND7ZHeAWbgap18kDj7YG/TvsOk0ZC5ZllrncciNIOw0AbckhlHgyPhoKHsqklQAQG/0PvzdyadmzniQPPs62h8Khq25H4LcQtD7zqe3KRlZAaXhUWWEeXbqtTbueDbka/fqfpTAS87t2J4DFVSOOBIk96ko9XTOKTtVfmxL2Je2PStIxAtyqhcXy4kP+7tG7+dDhfoi/N65qgB0hZ8TU+N79pRUoSegJlAX99yY2mG5r5LF31vQZlrRDx X-Gm-Message-State: AOJu0YxMHojX3xqlzG59AUj3Hi+oE+8AyTg1LHVhP0/wik2KqvATzHB7 O8ThCJNlgyJvjkHOjcwvYBsu5BPGva1zCNnphNG5SStIEyyAuXNd X-Google-Smtp-Source: AGHT+IFilio5qKRl+cSnK8IQn5IAVmutaHGtgF17QZrcOlUnZe/40B0j5GGoC7IbWTgHhNsL8k7V6w== X-Received: by 2002:a50:c19a:0:b0:57c:5f8a:26f8 with SMTP id 4fb4d7f45d1cf-57cbd6c6de0mr9000377a12.27.1718719207284; Tue, 18 Jun 2024 07:00:07 -0700 (PDT) Received: from [127.0.1.1] (mm-167-232-122-178.mgts.dynamic.pppoe.byfly.by. [178.122.232.167]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-57cb72da156sm7731278a12.22.2024.06.18.07.00.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 07:00:07 -0700 (PDT) From: Dzmitry Sankouski Date: Tue, 18 Jun 2024 16:59:43 +0300 Subject: [PATCH v3 09/23] 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: <20240618-starqltechn_integration_upstream-v3-9-e3f6662017ac@gmail.com> References: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> In-Reply-To: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> To: Sebastian Reichel , Bjorn Andersson , Michael Turquette , Stephen Boyd , Neil Armstrong , Jessica Zhang , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lee Jones , Dmitry Torokhov , Pavel Machek , Liam Girdwood , Mark Brown , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Krzysztof Kozlowski , Konrad Dybcio , Chanwoo Choi , phone-devel@vger.kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, linux-pwm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1718719184; l=3596; i=dsankouski@gmail.com; s=20240618; h=from:subject:message-id; bh=GeSjdBMrPx5/NgT7rDPKCihsvNHSXF0w4Z/AktYQJMg=; b=SVRUeOlS2AnrVfvyQsE3+BYBfIEGACx1n7IrRdkctMOEdEgjj8rJD4eKceXUvtg1WRJSqgDNd jDU4o7csfmMCaF/woZolPqcOjzIaWS6mIu9Mc9Zuqq3a6UrHbBnN4LU X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=6pMMVVDDReSiRgPCbMOUauN5nS3ty4Sf5b7a2gi4x0M= add samsung,s2dos05 core MFD module binding Signed-off-by: Dzmitry Sankouski --- .../devicetree/bindings/mfd/samsung,s2dos05.yaml | 89 ++++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 90 insertions(+) diff --git a/Documentation/devicetree/bindings/mfd/samsung,s2dos05.yaml b/Documentation/devicetree/bindings/mfd/samsung,s2dos05.yaml new file mode 100644 index 000000000000..f2ef5171cc40 --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/samsung,s2dos05.yaml @@ -0,0 +1,89 @@ +# 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 part of device tree bindings for S2M and S5M family of Power + Management IC (PMIC). + + The S2DOS05 is a companion power management IC for the panel and touchscreen + in smart phones. Provides voltage and current regulators and adc for power/current + measurements. + +properties: + compatible: + const: samsung,s2dos05-pmic + + reg: + maxItems: 1 + + regulators: + $ref: /schemas/regulator/samsung,s2dos05.yaml + description: List of regulators and its properties + +required: + - compatible + - reg + - regulators + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + pmic@60 { + compatible = "samsung,s2dos05"; + reg = <0x60>; + + regulators { + s2dos05_ldo1: s2dos05-ldo1 { + regulator-name = "s2dos05-ldo1"; + regulator-min-microvolt = <1500000>; + regulator-max-microvolt = <2000000>; + regulator-active-discharge = <0x1>; + }; + + s2dos05_ldo2: s2dos05-ldo2 { + regulator-name = "s2dos05-ldo2"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-active-discharge = <0x1>; + regulator-boot-on; + }; + + s2dos05_ldo3: s2dos05-ldo3 { + regulator-name = "s2dos05-ldo3"; + regulator-min-microvolt = <3000000>; + regulator-max-microvolt = <3000000>; + regulator-active-discharge = <0x1>; + regulator-boot-on; + }; + + s2dos05_ldo4: s2dos05-ldo4 { + regulator-name = "s2dos05-ldo4"; + regulator-min-microvolt = <2700000>; + regulator-max-microvolt = <3775000>; + regulator-active-discharge = <0x1>; + }; + + s2dos05_buck1: s2dos05-buck1 { + regulator-name = "s2dos05-buck1"; + regulator-min-microvolt = <850000>; + regulator-max-microvolt = <2100000>; + regulator-active-discharge = <0x1>; + }; + }; + }; + }; + +... diff --git a/MAINTAINERS b/MAINTAINERS index f008429033c9..3ab41e53c9fc 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19897,6 +19897,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,s2dos*.yaml F: Documentation/devicetree/bindings/mfd/samsung,s2m*.yaml F: Documentation/devicetree/bindings/mfd/samsung,s5m*.yaml F: Documentation/devicetree/bindings/regulator/samsung,s2m*.yaml From patchwork Tue Jun 18 13:59:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13702403 Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) (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 0A77115F336; Tue, 18 Jun 2024 14:00:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719213; cv=none; b=JzsX2C0bCBqTcWxvOD37rnbeCv7Lp02/Twt5vUuwuzB/77QCSpt2ivBA12G3Rb1lgaWT/9pMhs9cllYACYyVzZgSm6PFYr8iHVWReTzKihSX5FAifIsNs7e69gjbEJRr1gMLCkjcCEOmkO0vGTMUdi6FZiRakD2wo77TX6d2nRE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719213; c=relaxed/simple; bh=Y66wFEa+/wlFCoNMgoH3Eo5OCF3K3Yn5Lu+5vfjCL2I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QudtxTNmsvvWzeXgnVHMRXtpateNCVkJVMWkEBbkUNMxTCJFLgMZDg3thRw3Cf4i25QVYotHXcEVoWf+xrBjUiW7drduaDalxmhoO8uW0PMeIwTxfVTjrCraQRY2vnD85qfBCVPTKo03qGigHwGBXJeRHJ52ZNIrzT8IZt4/Nhg= 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=BpbcLNvO; arc=none smtp.client-ip=209.85.208.47 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="BpbcLNvO" Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-57a30dbdb7fso9710136a12.3; Tue, 18 Jun 2024 07:00:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719210; x=1719324010; 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=VgQaqPAPGb+bVEVj1pLBF0jCvf+qjPwOAsG6IyI58go=; b=BpbcLNvOPB3FuXBQJdrjG7cWEXlOLvamb2MR2CUsPxfZuUEEOLQ8pilmHrzp4bH9Fb fnSLSrpR4LOxpZpbDKLmKKw6jEWKTEtUXOGNiwnGQAYzZSY0tzNBBNV2n68oQyOlPWE8 kp0ws6kqAMeyIEzQKU3/SwL5UtbDg3VqEC37JuUyvotmlCC2ZaGa/tFQkJXoxe68vN9V DHk/O9KZk2Slf/TBeItPK1kIHPUFTgiFgz0BjGW3zV0VChv0QoK0u1kxxTyTDnRn0XXf JQevMFWvUbjqwhDvAVXjYPpdPk03wXTR/GpXBz7Fz3km2JSfZqBZ0llUFrggyPw/cSHz 0J4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718719210; x=1719324010; 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=VgQaqPAPGb+bVEVj1pLBF0jCvf+qjPwOAsG6IyI58go=; b=dIT6q5XdHu5aNrO4py7as+l+ov3TshDnxq6hvi3C7OUJtruH9BYCXtSFa/M+6O6IQO I7gS1q2EzH/5kfUA5Tq0SBlJOWIaGF1oI1KiEEUtORIuJBYKjDSfTFF0fAZ6BVVb49WM zltfPDNNZM0bgNoYc0Ie61kwCq3ox1hXcNc6BrKiJ9kr1LUv22C6S+sCymonJmF05OQY 7IO5tuwcxCiwSU6d/vqnxrZYxayHItSNBmcOZ/tWKtHlUcS2vtqdwlO8GrMWcPvrBDKR RVJu0lCEeQFYZnLZ5HlP6GJTJsu3m0pFj6JKQgKWvbtibknX1TrhpYivHesa4QugBV4P b4mA== X-Forwarded-Encrypted: i=1; AJvYcCVhFYIBHPRknQ18jitSaj6a2ye1A2gkaI0zStoYQQCoA6VmZWh18dROFA+KI4/0+mmlWoSujYVvDdsS92k6wOEOqdCGquS2pvWQbFw8DjRz0NuJM+DZQiKBsGRE+jwr4LBNatevIbXmQemLFeWrWKEQ8cqKJQJNsg1OSUsqvTuya9WP0gHphQKndS3kkFPJJFZ4drJ9JBFYEx/mvoT/qPRbNjhezr+tuBMReaKeebToEMQJ0TNBE7DquHReS7w5LjhOzyb8A8CvTp5+ZInIFbWT2Nkv4TH7h8p5v3W7mKBrUKnrVY7eCa89Io8KMJGM3fYcWD9L8i5TzNJhmX9X3DPDtRTA8njT3vf/mhEWuQU6DPVeaooPvjMgePPOS1TCejAJ0LpVrwLQlpCYwUiblVZ6/9dMxAZz X-Gm-Message-State: AOJu0YwTsbCA0jzqPrQ1/4UDwSOggcncPNmD+uMJjjp72Q2xXQYvQmc1 +CGK/9hNFdq7Dh1ZKH6r5elU5YQqCqtkDoYGwV/nJUwwqNJYnpNk X-Google-Smtp-Source: AGHT+IFsZidUuDC83rllt43NgpoJnd8N6/Hume+DefHGadiO2zxz9M/+d8rv7TFSqTnMWzBCuPFhMQ== X-Received: by 2002:a50:bb23:0:b0:57a:858d:20ca with SMTP id 4fb4d7f45d1cf-57cbd69c599mr8823023a12.28.1718719210215; Tue, 18 Jun 2024 07:00:10 -0700 (PDT) Received: from [127.0.1.1] (mm-167-232-122-178.mgts.dynamic.pppoe.byfly.by. [178.122.232.167]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-57cb72da156sm7731278a12.22.2024.06.18.07.00.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 07:00:09 -0700 (PDT) From: Dzmitry Sankouski Date: Tue, 18 Jun 2024 16:59:44 +0300 Subject: [PATCH v3 10/23] dt-bindings: regulator: 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: <20240618-starqltechn_integration_upstream-v3-10-e3f6662017ac@gmail.com> References: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> In-Reply-To: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> To: Sebastian Reichel , Bjorn Andersson , Michael Turquette , Stephen Boyd , Neil Armstrong , Jessica Zhang , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lee Jones , Dmitry Torokhov , Pavel Machek , Liam Girdwood , Mark Brown , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Krzysztof Kozlowski , Konrad Dybcio , Chanwoo Choi , phone-devel@vger.kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, linux-pwm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1718719184; l=2160; i=dsankouski@gmail.com; s=20240618; h=from:subject:message-id; bh=Y66wFEa+/wlFCoNMgoH3Eo5OCF3K3Yn5Lu+5vfjCL2I=; b=MmAiVvvAM9kzhQvdhIh8BbDA1BIDVVPqgbidWXVZE2dtgE/cQvJDFpkqRG+X9UEIjnWkq+0i0 EOqftdFX7nDAxqiKqhazJW3wsRUQmc2W+ttaYnbp0zIj8+YQVSN8guB X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=6pMMVVDDReSiRgPCbMOUauN5nS3ty4Sf5b7a2gi4x0M= add samsung,s2dos05 regulator binding part Signed-off-by: Dzmitry Sankouski --- .../bindings/regulator/samsung,s2dos05.yaml | 36 ++++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 37 insertions(+) diff --git a/Documentation/devicetree/bindings/regulator/samsung,s2dos05.yaml b/Documentation/devicetree/bindings/regulator/samsung,s2dos05.yaml new file mode 100644 index 000000000000..4b8e4389329c --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/samsung,s2dos05.yaml @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/samsung,s2dos05.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Samsung S2DOS05 Power Management IC Regulators + +maintainers: + - Dzmitry Sankouski + +description: + This is a part of device tree bindings for S2M and S5M family of Power + Management IC (PMIC). + + Has 4 LDO and 1 BUCK regulators, provides ELVDD, ELVSS, AVDD lines. + + See also Documentation/devicetree/bindings/mfd/samsung,s2dos05.yaml for + additional information and example. + +properties: + compatible: + const: samsung,s2dos05-regulator + +patternProperties: + "^buck1|ldo[1-4]$": + type: object + $ref: regulator.yaml# + unevaluatedProperties: false + + required: + - regulator-name + +additionalProperties: false + +... diff --git a/MAINTAINERS b/MAINTAINERS index 3ab41e53c9fc..92a5d0a56353 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19900,6 +19900,7 @@ F: Documentation/devicetree/bindings/clock/samsung,s2mps11.yaml F: Documentation/devicetree/bindings/mfd/samsung,s2dos*.yaml F: Documentation/devicetree/bindings/mfd/samsung,s2m*.yaml F: Documentation/devicetree/bindings/mfd/samsung,s5m*.yaml +F: Documentation/devicetree/bindings/regulator/samsung,s2dos*.yaml F: Documentation/devicetree/bindings/regulator/samsung,s2m*.yaml F: Documentation/devicetree/bindings/regulator/samsung,s5m*.yaml F: drivers/clk/clk-s2mps11.c From patchwork Tue Jun 18 13:59:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13702404 Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (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 8AD3D156F55; Tue, 18 Jun 2024 14:00:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719216; cv=none; b=AAnxqRCGlti6RSb50cBLtoN/setJFX8THDn8YgFjVIM7geT4L5PjPbkeaC8HHAxo8i3sS8SoEIqG6Tu24qQMWSg3iexLNcwq2d6t5zVUsV0LA1+VZ60ntIf0RwEEcPW9WwR+uhUpmARpr5M6ocMeBdvepYX7qv+OykExt+cBwbQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719216; c=relaxed/simple; bh=ue3MHT37XXyjNHrxkEj2M0Jd6XrwxyplbB2podMmaEI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YjTTJw2R4kLi7sYKTXEzFiSZ74bPmLO8ME6UMdVNR4NBxStSlXOPtifJvDNpZpSEK8tMnRk6vTFUIpcgJ10c9DeS0MjCjYDAdwzvogcDntsEmU6DGbdSHvLLwwe+5X+kCoxWF5cz0euCV1DY/ZNNt/zxyBC7GBY6OBFdgmsEKvc= 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=mLEfz7/0; arc=none smtp.client-ip=209.85.208.177 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="mLEfz7/0" Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2ebe785b234so54404021fa.1; Tue, 18 Jun 2024 07:00:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719213; x=1719324013; 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=id8Hhvq/bt2h6K3B8/2c/eaipM1A6Vdbe4bbmJMwPG4=; b=mLEfz7/0zeymZ25fXYENu1S6DJpAEKHnqxPkyGkP7R5efYz7ou8/RxNFsvfAZwsRCs st48CKtHpDisUep98tR8PJ6+cxu54GpzBOviZ6G73qK5CxuTWzBsEpLrUSW54j7jMCGR ZcmEdEZaEr+0+sIt3YiSiuHR5RtetDR7hX+ZFd1rIRdoHK0Cx/azutbezYKpNqxzPUgZ 6sx6pN3pWIeRzL7N+b1BvvW6iuYUmK4t8lmzGGJkjroPoLQQf15tlBj3w4hId2blOVku Iuf+LII10Lb6N7I+kCXfMRbhM47kCNbU1FL+z+ll09zfgnSFpzNG+gINU2XE/U8Ox/vG o0Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718719213; x=1719324013; 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=id8Hhvq/bt2h6K3B8/2c/eaipM1A6Vdbe4bbmJMwPG4=; b=iGQwYHEE6lKg5raGZfg2PRwyYhUEUd2QQuy1kzRSotljzLD7uIyZ2MGgnNJI5j7T36 XROXdAjL1ioaADxbIkngypPzw/+UR9y/8sjBUjUYnMUWJlWhXnYdsbEGMfW5g7nw7WXW xdHRuzW4U1CVhDpI6jCayHpsHxtU8UFhx3FxIUwsioNWgA+6QuCyzRSdLp+rgqubQUdF V38OQtUa3H+icHlmcn7bRN/88KlEpCEV4RWYvWBt5Zsk18H642JZ8DhQ4rSYkE5aWpQk JhNWDNgcJWZc7O8bbq+lV+fi/gab+Rk+TK4SVHZ1ucukV1zoCQPlDYeJXfvP3TtYLXqU TcGg== X-Forwarded-Encrypted: i=1; AJvYcCUrNp/He9YupVom4hrAHJvLodmtM22xG2Ml1evLT2UVD34gmFh26hQ7VdWuTfMHme+uTmFtvIpDFdy9Fz+WaOsDjANWsbhIL1J26c5cd5IoH7KHKy+WKlr9sqqoAOufcPcBXz41iBJsTdpQxoaX6zusL/YnUwllfToGX5d0ak4YN7pT50Jah/CD1j2tJcRQsZ+0s/JeaMJ03hY9r1eTbHVyIshBmtMzAdga64Ufg2lxyBVmloSVNWdgzEi5DIM+dhI7BhNfi8dRoHEz4pwio/mckGwSGOyhyDAPX3Gb5JsY+HG7csSde19LHqd5aE/Mgh8IPeNCh0WLthB4JNJkJACyXFQ6Ta92xunbYyFcZcYIEzpaIyOV6FIStYZKAhSQ+JwoKWI6vb2CxbUGEQ00+YkktDz3nmSx X-Gm-Message-State: AOJu0YzTcEj162wRKwGlUBOb26fH368VVvPoerHiUj7JY0j3y+HNGmYz uYB8qyTM2Wy/gwhkx5iPqLMOWtMT4WpVKNdFTR2warTCbeXxgNKkKRGaN2nM X-Google-Smtp-Source: AGHT+IFGWxNTJWKfvtYtwaUhf5eCQI0VCQBJSAVikp2hNnHlatQzSXBxjfytMltsZ1/pvjUqZscsTQ== X-Received: by 2002:a2e:3519:0:b0:2ec:30ee:6972 with SMTP id 38308e7fff4ca-2ec30ee69b1mr28595351fa.24.1718719212474; Tue, 18 Jun 2024 07:00:12 -0700 (PDT) Received: from [127.0.1.1] (mm-167-232-122-178.mgts.dynamic.pppoe.byfly.by. [178.122.232.167]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-57cb72da156sm7731278a12.22.2024.06.18.07.00.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 07:00:12 -0700 (PDT) From: Dzmitry Sankouski Date: Tue, 18 Jun 2024 16:59:45 +0300 Subject: [PATCH v3 11/23] drm/panel: Add support for S6E3HA8 panel driver Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240618-starqltechn_integration_upstream-v3-11-e3f6662017ac@gmail.com> References: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> In-Reply-To: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> To: Sebastian Reichel , Bjorn Andersson , Michael Turquette , Stephen Boyd , Neil Armstrong , Jessica Zhang , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lee Jones , Dmitry Torokhov , Pavel Machek , Liam Girdwood , Mark Brown , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Krzysztof Kozlowski , Konrad Dybcio , Chanwoo Choi , phone-devel@vger.kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, linux-pwm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1718719184; l=15491; i=dsankouski@gmail.com; s=20240618; h=from:subject:message-id; bh=ue3MHT37XXyjNHrxkEj2M0Jd6XrwxyplbB2podMmaEI=; b=jhF8wZ+oXwUHKCr1cjS4cFqpVzhkjkOtp0p6gy65qFozWvPJJ4ZFnD1XBs+P424Y43p0ESGFP XNz3UQCUSTOCQ2MjR042xoIzVbaIvVzVnWtz5BDQCJjsLvwB805bP6R X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=6pMMVVDDReSiRgPCbMOUauN5nS3ty4Sf5b7a2gi4x0M= Add support for MIPI-DSI based S6E3HA8 AMOLED panel driver. This panel has 1440x2960 resolution, 5.8-inch physical size, and can be found in starqltechn device. Brightness regulation is not yet supported. Signed-off-by: Dzmitry Sankouski --- MAINTAINERS | 1 + drivers/gpu/drm/panel/Kconfig | 7 + drivers/gpu/drm/panel/Makefile | 1 + drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c | 426 ++++++++++++++++++++++++++ 4 files changed, 435 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 92a5d0a56353..fae3b8ea9ce4 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7154,6 +7154,7 @@ DRM DRIVER FOR SAMSUNG S6E3HA8 PANELS M: Dzmitry Sankouski S: Maintained F: Documentation/devicetree/bindings/display/panel/samsung,s6e3ha8.yaml +F: drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c DRM DRIVER FOR SITRONIX ST7586 PANELS M: David Lechner diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig index 2ae0eb0638f3..903fc8c155c0 100644 --- a/drivers/gpu/drm/panel/Kconfig +++ b/drivers/gpu/drm/panel/Kconfig @@ -651,6 +651,13 @@ config DRM_PANEL_SAMSUNG_S6E3HA2 depends on BACKLIGHT_CLASS_DEVICE select VIDEOMODE_HELPERS +config DRM_PANEL_SAMSUNG_S6E3HA8 + tristate "Samsung S6E3HA8 DSI video mode panel" + depends on OF + depends on DRM_MIPI_DSI + depends on BACKLIGHT_CLASS_DEVICE + select VIDEOMODE_HELPERS + config DRM_PANEL_SAMSUNG_S6E63J0X03 tristate "Samsung S6E63J0X03 DSI command mode panel" depends on OF diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile index f0203f6e02f4..71774cc5820a 100644 --- a/drivers/gpu/drm/panel/Makefile +++ b/drivers/gpu/drm/panel/Makefile @@ -66,6 +66,7 @@ obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6D27A1) += panel-samsung-s6d27a1.o obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6D7AA0) += panel-samsung-s6d7aa0.o obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E3FA7) += panel-samsung-s6e3fa7.o obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E3HA2) += panel-samsung-s6e3ha2.o +obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E3HA8) += panel-samsung-s6e3ha8.o obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63J0X03) += panel-samsung-s6e63j0x03.o obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63M0) += panel-samsung-s6e63m0.o obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63M0_SPI) += panel-samsung-s6e63m0-spi.o diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c b/drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c new file mode 100644 index 000000000000..49d629643171 --- /dev/null +++ b/drivers/gpu/drm/panel/panel-samsung-s6e3ha8.c @@ -0,0 +1,426 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Generated with linux-mdss-dsi-panel-driver-generator from vendor device tree: + * Copyright (c) 2013, The Linux Foundation. All rights reserved. + * Copyright (c) 2024 Dzmitry Sankouski + */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +struct s6e3ha8 { + struct drm_panel panel; + struct mipi_dsi_device *dsi; + struct drm_dsc_config dsc; + struct gpio_desc *reset_gpio; + struct regulator_bulk_data supplies[3]; +}; + +static inline +struct s6e3ha8 *to_s6e3ha8_amb577px01_wqhd(struct drm_panel *panel) +{ + return container_of(panel, struct s6e3ha8, panel); +} + +#define s6e3ha8_call_write_func(ret, func) do { \ + ret = (func); \ + if (ret < 0) \ + return ret; \ +} while (0) + +static int s6e3ha8_test_key_on_lvl1(struct mipi_dsi_device *dsi) +{ + static const u8 d[] = { 0x9f, 0xa5, 0xa5 }; + + return mipi_dsi_dcs_write_buffer(dsi, d, ARRAY_SIZE(d)); + return 0; +} + +static int s6e3ha8_test_key_off_lvl1(struct mipi_dsi_device *dsi) +{ + static const u8 d[] = { 0x9f, 0x5a, 0x5a }; + + return mipi_dsi_dcs_write_buffer(dsi, d, ARRAY_SIZE(d)); + return 0; +} + +static int s6e3ha8_test_key_on_lvl2(struct mipi_dsi_device *dsi) +{ + static const u8 d[] = { 0xf0, 0x5a, 0x5a }; + + return mipi_dsi_dcs_write_buffer(dsi, d, ARRAY_SIZE(d)); +} + +static int s6e3ha8_test_key_off_lvl2(struct mipi_dsi_device *dsi) +{ + static const u8 d[] = { 0xf0, 0xa5, 0xa5 }; + + return mipi_dsi_dcs_write_buffer(dsi, d, ARRAY_SIZE(d)); +} + +static int s6e3ha8_test_key_on_lvl3(struct mipi_dsi_device *dsi) +{ + static const u8 d[] = { 0xfc, 0x5a, 0x5a }; + + return mipi_dsi_dcs_write_buffer(dsi, d, ARRAY_SIZE(d)); +} + +static int s6e3ha8_test_key_off_lvl3(struct mipi_dsi_device *dsi) +{ + static const u8 d[] = { 0xfc, 0xa5, 0xa5 }; + + return mipi_dsi_dcs_write_buffer(dsi, d, ARRAY_SIZE(d)); +} + +static int s6e3ha8_afc_off(struct mipi_dsi_device *dsi) +{ + static const u8 d[] = { 0xe2, 0x00, 0x00 }; + + return mipi_dsi_dcs_write_buffer(dsi, d, ARRAY_SIZE(d)); + return 0; +} + +static int s6e3ha8_power_on(struct s6e3ha8 *ctx) +{ + int ret; + + ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies); + if (ret < 0) + return ret; + + return 0; +} + +static int s6e3ha8_power_off(struct s6e3ha8 *ctx) +{ + return regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies); +} + +static void s6e3ha8_amb577px01_wqhd_reset(struct s6e3ha8 *ctx) +{ + gpiod_set_value_cansleep(ctx->reset_gpio, 1); + usleep_range(5000, 6000); + gpiod_set_value_cansleep(ctx->reset_gpio, 0); + usleep_range(5000, 6000); + gpiod_set_value_cansleep(ctx->reset_gpio, 1); + usleep_range(5000, 6000); +} + +static int s6e3ha8_amb577px01_wqhd_on(struct s6e3ha8 *ctx) +{ + struct mipi_dsi_device *dsi = ctx->dsi; + struct device *dev = &dsi->dev; + int ret; + + dsi->mode_flags |= MIPI_DSI_MODE_LPM; + + s6e3ha8_test_key_on_lvl1(dsi); + s6e3ha8_test_key_on_lvl2(dsi); + + ret = mipi_dsi_compression_mode(dsi, true); + if (ret < 0) { + dev_err(dev, "Failed to set compression mode: %d\n", ret); + return ret; + } + + s6e3ha8_test_key_off_lvl2(dsi); + + ret = mipi_dsi_dcs_exit_sleep_mode(dsi); + if (ret < 0) { + dev_err(dev, "Failed to exit sleep mode: %d\n", ret); + return ret; + } + usleep_range(5000, 6000); + + s6e3ha8_test_key_on_lvl2(dsi); + mipi_dsi_generic_write_seq(dsi, 0xf2, 0x13); + s6e3ha8_test_key_off_lvl2(dsi); + + usleep_range(10000, 11000); + + s6e3ha8_test_key_on_lvl2(dsi); + mipi_dsi_generic_write_seq(dsi, 0xf2, 0x13); + s6e3ha8_test_key_off_lvl2(dsi); + + /* OMOK setting 1 (Initial setting) - Scaler Latch Setting Guide */ + s6e3ha8_test_key_on_lvl2(dsi); + mipi_dsi_generic_write_seq(dsi, 0xb0, 0x07); + /* latch setting 1 : Scaler on/off & address setting & PPS setting -> Image update latch */ + mipi_dsi_generic_write_seq(dsi, 0xf2, 0x3c, 0x10); + mipi_dsi_generic_write_seq(dsi, 0xb0, 0x0b); + /* latch setting 2 : Ratio change mode -> Image update latch */ + mipi_dsi_generic_write_seq(dsi, 0xf2, 0x30); + /* OMOK setting 2 - Seamless setting guide : WQHD */ + mipi_dsi_generic_write_seq(dsi, 0x2a, 0x00, 0x00, 0x05, 0x9f); /* CASET */ + mipi_dsi_generic_write_seq(dsi, 0x2b, 0x00, 0x00, 0x0b, 0x8f); /* PASET */ + mipi_dsi_generic_write_seq(dsi, 0xba, 0x01); /* scaler setup : scaler off */ + s6e3ha8_test_key_off_lvl2(dsi); + mipi_dsi_generic_write_seq(dsi, 0x35, 0x00); /* TE Vsync ON */ + s6e3ha8_test_key_on_lvl2(dsi); + mipi_dsi_generic_write_seq(dsi, 0xed, 0x4c); /* ERR_FG */ + s6e3ha8_test_key_off_lvl2(dsi); + s6e3ha8_test_key_on_lvl3(dsi); + /* FFC Setting 897.6Mbps */ + mipi_dsi_generic_write_seq(dsi, 0xc5, 0x0d, 0x10, 0xb4, 0x3e, 0x01); + s6e3ha8_test_key_off_lvl3(dsi); + s6e3ha8_test_key_on_lvl2(dsi); + mipi_dsi_generic_write_seq(dsi, 0xb9, + 0x00, 0xb0, 0x81, 0x09, 0x00, 0x00, 0x00, + 0x11, 0x03); /* TSP HSYNC Setting */ + s6e3ha8_test_key_off_lvl2(dsi); + s6e3ha8_test_key_on_lvl2(dsi); + mipi_dsi_generic_write_seq(dsi, 0xb0, 0x03); + mipi_dsi_generic_write_seq(dsi, 0xf6, 0x43); + s6e3ha8_test_key_off_lvl2(dsi); + s6e3ha8_test_key_on_lvl2(dsi); + /* Brightness condition set */ + mipi_dsi_generic_write_seq(dsi, 0xca, + 0x07, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x00, 0x00, 0x00); + mipi_dsi_generic_write_seq(dsi, 0xb1, 0x00, 0x0c); /* AID Set : 0% */ + mipi_dsi_generic_write_seq(dsi, 0xb5, + 0x19, 0xdc, 0x16, 0x01, 0x34, 0x67, 0x9a, + 0xcd, 0x01, 0x22, 0x33, 0x44, 0x00, 0x00, + 0x05, 0x55, 0xcc, 0x0c, 0x01, 0x11, 0x11, + 0x10); /* MPS/ELVSS Setting */ + mipi_dsi_generic_write_seq(dsi, 0xf4, 0xeb, 0x28); /* VINT */ + mipi_dsi_generic_write_seq(dsi, 0xf7, 0x03); /* Gamma, LTPS(AID) update */ + s6e3ha8_test_key_off_lvl2(dsi); + s6e3ha8_test_key_off_lvl1(dsi); + + return 0; +} + +static int s6e3ha8_enable(struct drm_panel *panel) +{ + struct s6e3ha8 *ctx = to_s6e3ha8_amb577px01_wqhd(panel); + struct mipi_dsi_device *dsi = ctx->dsi; + int ret; + + s6e3ha8_call_write_func(ret, s6e3ha8_test_key_on_lvl1(dsi)); + s6e3ha8_call_write_func(ret, mipi_dsi_dcs_set_display_on(dsi)); + s6e3ha8_call_write_func(ret, s6e3ha8_test_key_off_lvl1(dsi)); + + return 0; +} + +static int s6e3ha8_disable(struct drm_panel *panel) +{ + struct s6e3ha8 *ctx = to_s6e3ha8_amb577px01_wqhd(panel); + struct mipi_dsi_device *dsi = ctx->dsi; + int ret; + + s6e3ha8_call_write_func(ret, s6e3ha8_test_key_on_lvl1(dsi)); + s6e3ha8_call_write_func(ret, mipi_dsi_dcs_set_display_off(dsi)); + s6e3ha8_call_write_func(ret, s6e3ha8_test_key_off_lvl1(dsi)); + msleep(20); + + s6e3ha8_call_write_func(ret, s6e3ha8_test_key_on_lvl2(dsi)); + s6e3ha8_call_write_func(ret, s6e3ha8_afc_off(dsi)); + s6e3ha8_call_write_func(ret, s6e3ha8_test_key_off_lvl2(dsi)); + + msleep(160); + + return 0; +} + +static int s6e3ha8_amb577px01_wqhd_prepare(struct drm_panel *panel) +{ + struct s6e3ha8 *ctx = to_s6e3ha8_amb577px01_wqhd(panel); + struct mipi_dsi_device *dsi = ctx->dsi; + struct device *dev = &dsi->dev; + struct drm_dsc_picture_parameter_set pps; + int ret; + + s6e3ha8_power_on(ctx); + msleep(120); + s6e3ha8_amb577px01_wqhd_reset(ctx); + ret = s6e3ha8_amb577px01_wqhd_on(ctx); + + if (ret < 0) { + dev_err(dev, "Failed to initialize panel: %d\n", ret); + gpiod_set_value_cansleep(ctx->reset_gpio, 1); + goto err; + } + + drm_dsc_pps_payload_pack(&pps, &ctx->dsc); + + s6e3ha8_test_key_on_lvl1(dsi); + ret = mipi_dsi_picture_parameter_set(ctx->dsi, &pps); + if (ret < 0) { + dev_err(panel->dev, "failed to transmit PPS: %d\n", ret); + return ret; + } + s6e3ha8_test_key_off_lvl1(dsi); + + ret = mipi_dsi_compression_mode(ctx->dsi, true); + if (ret < 0) { + dev_err(dev, "failed to enable compression mode: %d\n", ret); + return ret; + } + + + msleep(28); + + return 0; +err: + s6e3ha8_power_off(ctx); + return ret; +} + +static int s6e3ha8_amb577px01_wqhd_unprepare(struct drm_panel *panel) +{ + struct s6e3ha8 *ctx = to_s6e3ha8_amb577px01_wqhd(panel); + + return s6e3ha8_power_off(ctx); +} + +static const struct drm_display_mode s6e3ha8_amb577px01_wqhd_mode = { + .clock = (1440 + 116 + 44 + 120) * (2960 + 120 + 80 + 124) * 60 / 1000, + .hdisplay = 1440, + .hsync_start = 1440 + 116, + .hsync_end = 1440 + 116 + 44, + .htotal = 1440 + 116 + 44 + 120, + .vdisplay = 2960, + .vsync_start = 2960 + 120, + .vsync_end = 2960 + 120 + 80, + .vtotal = 2960 + 120 + 80 + 124, + .width_mm = 64, + .height_mm = 132, +}; + +static int s6e3ha8_amb577px01_wqhd_get_modes(struct drm_panel *panel, + struct drm_connector *connector) +{ + struct drm_display_mode *mode; + + mode = drm_mode_duplicate(connector->dev, &s6e3ha8_amb577px01_wqhd_mode); + if (!mode) + return -ENOMEM; + + drm_mode_set_name(mode); + + mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; + connector->display_info.width_mm = mode->width_mm; + connector->display_info.height_mm = mode->height_mm; + drm_mode_probed_add(connector, mode); + + return 1; +} + +static const struct drm_panel_funcs s6e3ha8_amb577px01_wqhd_panel_funcs = { + .prepare = s6e3ha8_amb577px01_wqhd_prepare, + .unprepare = s6e3ha8_amb577px01_wqhd_unprepare, + .get_modes = s6e3ha8_amb577px01_wqhd_get_modes, + .enable = s6e3ha8_enable, + .disable = s6e3ha8_disable, +}; + +static int s6e3ha8_amb577px01_wqhd_probe(struct mipi_dsi_device *dsi) +{ + struct device *dev = &dsi->dev; + struct s6e3ha8 *ctx; + int ret; + + ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); + if (!ctx) + return -ENOMEM; + + ctx->supplies[0].supply = "vdd3"; + ctx->supplies[1].supply = "vci"; + ctx->supplies[2].supply = "vddr"; + + ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(ctx->supplies), + ctx->supplies); + if (ret < 0) { + dev_err(dev, "failed to get regulators: %d\n", ret); + return ret; + } + + ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(ctx->reset_gpio)) + return dev_err_probe(dev, PTR_ERR(ctx->reset_gpio), + "Failed to get reset-gpios\n"); + + ctx->dsi = dsi; + mipi_dsi_set_drvdata(dsi, ctx); + + dsi->lanes = 4; + dsi->format = MIPI_DSI_FMT_RGB888; + dsi->mode_flags = MIPI_DSI_CLOCK_NON_CONTINUOUS | + MIPI_DSI_MODE_VIDEO_NO_HFP | MIPI_DSI_MODE_VIDEO_NO_HBP | + MIPI_DSI_MODE_VIDEO_NO_HSA | MIPI_DSI_MODE_NO_EOT_PACKET; + + drm_panel_init(&ctx->panel, dev, &s6e3ha8_amb577px01_wqhd_panel_funcs, + DRM_MODE_CONNECTOR_DSI); + ctx->panel.prepare_prev_first = true; + + drm_panel_add(&ctx->panel); + + /* This panel only supports DSC; unconditionally enable it */ + dsi->dsc = &ctx->dsc; + + ctx->dsc.dsc_version_major = 1; + ctx->dsc.dsc_version_minor = 1; + + ctx->dsc.slice_height = 40; + ctx->dsc.slice_width = 720; + WARN_ON(1440 % ctx->dsc.slice_width); + ctx->dsc.slice_count = 1440 / ctx->dsc.slice_width; + ctx->dsc.bits_per_component = 8; + ctx->dsc.bits_per_pixel = 8 << 4; /* 4 fractional bits */ + ctx->dsc.block_pred_enable = true; + + ret = mipi_dsi_attach(dsi); + if (ret < 0) { + dev_err(dev, "Failed to attach to DSI host: %d\n", ret); + drm_panel_remove(&ctx->panel); + return ret; + } + + return 0; +} + +static void s6e3ha8_amb577px01_wqhd_remove(struct mipi_dsi_device *dsi) +{ + struct s6e3ha8 *ctx = mipi_dsi_get_drvdata(dsi); + int ret; + + ret = mipi_dsi_detach(dsi); + if (ret < 0) + dev_err(&dsi->dev, "Failed to detach from DSI host: %d\n", ret); + + drm_panel_remove(&ctx->panel); +} + +static const struct of_device_id s6e3ha8_amb577px01_wqhd_of_match[] = { + { .compatible = "samsung,s6e3ha8" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, s6e3ha8_amb577px01_wqhd_of_match); + +static struct mipi_dsi_driver s6e3ha8_amb577px01_wqhd_driver = { + .probe = s6e3ha8_amb577px01_wqhd_probe, + .remove = s6e3ha8_amb577px01_wqhd_remove, + .driver = { + .name = "panel-s6e3ha8", + .of_match_table = s6e3ha8_amb577px01_wqhd_of_match, + }, +}; +module_mipi_dsi_driver(s6e3ha8_amb577px01_wqhd_driver); + +MODULE_AUTHOR("Dzmitry Sankouski "); +MODULE_DESCRIPTION("DRM driver for S6E3HA8 panel"); +MODULE_LICENSE("GPL"); From patchwork Tue Jun 18 13:59:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13702405 Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) (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 D0264157478; Tue, 18 Jun 2024 14:00:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719219; cv=none; b=o6NPLx2Et5WGty6MzitPHpAOIU8jhj6V2pCUuNzL7SCuWNHyuwm/fshRqg8skc1OYxJCJC4qnJRoJQzMo0t+24N/pCXXv5zrd09oNVF4SiD1ijc8CT/Izna9SfxoLG29FbZIWJCK1fx6Y8TWjLl2STf+mPukUGQStor12JYv4jQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719219; c=relaxed/simple; bh=B1lA/Gc2Dl8Wk4SsWnJx6fkj18H3BhQFhk0y5dNlehE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=apnDy0KdilZVfwENtgkV1BJi5Oy48rr8RjiWsHdVBr6vJXAlIzLEA3vMP3d7B7j1yDE3v5BzOuW3hTPnWiNXD3y4g4AdVII5YUWZUNhEnLjEZSpztb7emyl2Hahx7OJ71Z4JHOyozzB/EFV1rSxXJPFvOQ9LJieZMFace2QJDz0= 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=hG8Od84C; arc=none smtp.client-ip=209.85.208.44 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="hG8Od84C" Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-57cad452f8bso6207800a12.2; Tue, 18 Jun 2024 07:00:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719215; x=1719324015; 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=lLO6JQTUDUiwTtdmLYnaDKzuAgvre8uTKnhhOLvppR0=; b=hG8Od84CmvLO9zyfdqrL7of+pXMR0oU5tYmfvidz9rCtwc7KwbzxJxIlNnTlBtDRk2 lwcr6OIvBKNsvu4J+HBVLq7U7MeqKxhrJFtv7+47PrDFbVd23oKtcmLuWXFQ8hC2L9uX 4Ep/zZARnjB/TMd97idcCWWkQWW6TRiiyisZzWLkGl96VAms6emM7TPzh0w3y8jSMiIl G06ujihhNkiFD9aqmrS1Ovlt2+0Qj2iuAkRiYCP4fm+Y9QAilhjQxEj3FfNGRlquloXz vjvgTUuoFujh7DiQbOnBCuwlBog3NeCYKa1s2zxzAQTHU8NAEzlaWCy85y2KBHPB2Xap yScQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718719215; x=1719324015; 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=lLO6JQTUDUiwTtdmLYnaDKzuAgvre8uTKnhhOLvppR0=; b=LedF4+AA363ajSZuffQjvE1SXAkOgedYLiR9KHf0uX/0VmK6YOd97EWMAT8FQDTJou baHu54xvrpS860lJMZQWjjfqQnVgMsQnInEA/wiMpfeaxJd+Ny4IZEncyXIV5ynwQT8x fPcW8DX1/q8r6SkJhEe567fnbgoJLciZkLgmRx4qT70LIz8oIzW2Yw3qzVjsOmPqEY5x eAozdrKEji0HdSb/fUKqh93HN+a1vicn6s9rbgJfeXCTq9PxBiBTXJ1V8+BRx42Ewx8O 6T1TUyeKysjdmiJiBwD6wgpcOGlqz2jCxWcVw4W/LzINXn7fApqdFvL38FHV/KwwNY+C sNbg== X-Forwarded-Encrypted: i=1; AJvYcCWKfiuuybN8z4SGH2Uukiwt3gB2Su0myjSuR0slBJG+31zDFVsB/UkdRmwtmoSh9ImR1vGItcXYtCFpV1T3f4ixKFyyj+WvOnhBnmDcaQUtqQfWGy2AhkAlL3byfTYYiUz82LkAfAeqzHGqLzQuGSikdEzQiHmCtX98N7KbhNMioRWX/yhd2S0axFdHtVBk3x15UOIIkDZ/U4vkA1U3L1KR9F9PGpJ1FSwsjrGEL3LCZl8sLxdtVPMa4CXPukKJ8py/PbrXBG7CUDOzeKchAH1h2wGVzcYRC9TqaJ3wRLD/OXPoP1fMw7RZwnynSBpD5R0LtIcs8Wyg9wpeh7JkB0X0CjMYzqUDJyBmsw+aqSEK7mNAheYTacbplNDNwxJsxxE1UHaDpd9BEPGa5Zh1AknVUxZMXSHH X-Gm-Message-State: AOJu0Yyz0kHrFUqAOhuI9cyqoUoEbCQANcZzJmWCD/bJ/01ZmuPg/fuw Jh6Vdit4OgS2jhfoSVfmvSMr4zPfBZ+46AjuhNXfHfCqLGEN93mU X-Google-Smtp-Source: AGHT+IG8F54EN9ZsZzLwwzz6jnEUOnhvhk6d6nAeqIs3gJ5a91heFass+KAkwkGBVlZZE2e6l8v3lQ== X-Received: by 2002:a50:9b45:0:b0:57c:74ed:88c5 with SMTP id 4fb4d7f45d1cf-57cbd665244mr8105891a12.13.1718719214864; Tue, 18 Jun 2024 07:00:14 -0700 (PDT) Received: from [127.0.1.1] (mm-167-232-122-178.mgts.dynamic.pppoe.byfly.by. [178.122.232.167]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-57cb72da156sm7731278a12.22.2024.06.18.07.00.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 07:00:14 -0700 (PDT) From: Dzmitry Sankouski Date: Tue, 18 Jun 2024 16:59:46 +0300 Subject: [PATCH v3 12/23] mfd: Add new driver for MAX77705 PMIC Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240618-starqltechn_integration_upstream-v3-12-e3f6662017ac@gmail.com> References: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> In-Reply-To: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> To: Sebastian Reichel , Bjorn Andersson , Michael Turquette , Stephen Boyd , Neil Armstrong , Jessica Zhang , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lee Jones , Dmitry Torokhov , Pavel Machek , Liam Girdwood , Mark Brown , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Krzysztof Kozlowski , Konrad Dybcio , Chanwoo Choi , phone-devel@vger.kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, linux-pwm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Dzmitry Sankouski , Rose Hudson X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1718719184; l=29057; i=dsankouski@gmail.com; s=20240618; h=from:subject:message-id; bh=B1lA/Gc2Dl8Wk4SsWnJx6fkj18H3BhQFhk0y5dNlehE=; b=VrQOGho78Detw4YGoUazfrViU0atCSCbuOT49p7DjXujGtg8bWdeliNr4KIw23EIwEIax4u+W TY9bdwEhAeSC8TmtcVdjzgDNk/yC0sJVlKpcJAgQIHVkwu3Zr1gZxac X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=6pMMVVDDReSiRgPCbMOUauN5nS3ty4Sf5b7a2gi4x0M= Add the core MFD driver for max77705 PMIC. We define five sub-devices for which the drivers will be added in subsequent patches. Signed-off-by: Dzmitry Sankouski Co-authored-by: Rose Hudson --- MAINTAINERS | 2 + drivers/mfd/Kconfig | 12 ++ drivers/mfd/Makefile | 3 + drivers/mfd/max77705-core.c | 278 ++++++++++++++++++++++++++++++++ drivers/mfd/max77705-irq.c | 299 +++++++++++++++++++++++++++++++++++ include/linux/mfd/max77705-private.h | 281 ++++++++++++++++++++++++++++++++ include/linux/mfd/max77705.h | 20 +++ 7 files changed, 895 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index fae3b8ea9ce4..f66f08825db9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -13690,6 +13690,7 @@ F: drivers/*/*max77843.c F: drivers/*/max14577*.c F: drivers/*/max77686*.c F: drivers/*/max77693*.c +F: drivers/*/max77705*.c F: drivers/clk/clk-max77686.c F: drivers/extcon/extcon-max14577.c F: drivers/extcon/extcon-max77693.c @@ -13697,6 +13698,7 @@ F: drivers/rtc/rtc-max77686.c F: include/linux/mfd/max14577*.h F: include/linux/mfd/max77686*.h F: include/linux/mfd/max77693*.h +F: include/linux/mfd/max77705*.h MAXIRADIO FM RADIO RECEIVER DRIVER M: Hans Verkuil diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 266b4f54af60..c4eb8ff2dcad 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -880,6 +880,18 @@ config MFD_MAX77693 additional drivers must be enabled in order to use the functionality of the device. +config MFD_MAX77705 + tristate "Maxim Semiconductor MAX77705 PMIC Support" + depends on I2C + select MFD_CORE + help + Say yes here to add support for Maxim Semiconductor MAX77705. + This is a Power Management IC with Charger, safe LDOs, Flash, Haptic + and MUIC controls on chip. + This driver provides common support for accessing the device; + additional drivers must be enabled in order to use the functionality + of the device. + config MFD_MAX77714 tristate "Maxim Semiconductor MAX77714 PMIC Support" depends on I2C diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index db1ba39de3b5..bf65cc36d59c 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -162,6 +162,8 @@ obj-$(CONFIG_MFD_MAX77620) += max77620.o obj-$(CONFIG_MFD_MAX77650) += max77650.o obj-$(CONFIG_MFD_MAX77686) += max77686.o obj-$(CONFIG_MFD_MAX77693) += max77693.o +max77705-objs := max77705-core.o max77705-irq.o +obj-$(CONFIG_MFD_MAX77705) += max77705.o obj-$(CONFIG_MFD_MAX77714) += max77714.o obj-$(CONFIG_MFD_MAX77843) += max77843.o obj-$(CONFIG_MFD_MAX8907) += max8907.o @@ -226,6 +228,7 @@ obj-$(CONFIG_MFD_RK8XX_I2C) += rk8xx-i2c.o obj-$(CONFIG_MFD_RK8XX_SPI) += rk8xx-spi.o obj-$(CONFIG_MFD_RN5T618) += rn5t618.o obj-$(CONFIG_MFD_SEC_CORE) += sec-core.o sec-irq.o +obj-$(CONFIG_MFD_S2DOS05) += s2dos05.o obj-$(CONFIG_MFD_SYSCON) += syscon.o obj-$(CONFIG_MFD_LM3533) += lm3533-core.o lm3533-ctrlbank.o obj-$(CONFIG_MFD_VEXPRESS_SYSREG) += vexpress-sysreg.o diff --git a/drivers/mfd/max77705-core.c b/drivers/mfd/max77705-core.c new file mode 100644 index 000000000000..7cb71a0a9688 --- /dev/null +++ b/drivers/mfd/max77705-core.c @@ -0,0 +1,278 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * max77705.c - mfd core driver for the Maxim 77705 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Copyright (C) 2024 Dzmitry Sankouski + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define I2C_ADDR_PMIC (0xCC >> 1) /* Top sys, Haptic */ +#define I2C_ADDR_MUIC (0x4A >> 1) +#define I2C_ADDR_CHG (0xD2 >> 1) +#define I2C_ADDR_FG (0x6C >> 1) +#define I2C_ADDR_DEBUG (0xC4 >> 1) + +static struct dentry *debugfs_file; + +static int max77705_debugfs_show(struct seq_file *s, void *data) +{ + struct max77705_dev *max77705 = s->private; + struct regmap *regmap = max77705->regmap; + unsigned int i, reg, reg_data, pmic_id, pmic_rev; + int regs[] = { + MAX77705_PMIC_REG_MAINCTRL1, + MAX77705_PMIC_REG_MCONFIG, + MAX77705_PMIC_REG_MCONFIG2, + MAX77705_PMIC_REG_INTSRC, + MAX77705_PMIC_REG_INTSRC_MASK, + MAX77705_PMIC_REG_SYSTEM_INT, + MAX77705_PMIC_REG_SYSTEM_INT_MASK, + MAX77705_RGBLED_REG_LEDEN, + MAX77705_RGBLED_REG_LED0BRT, + MAX77705_RGBLED_REG_LED1BRT, + MAX77705_RGBLED_REG_LED2BRT, + MAX77705_RGBLED_REG_LED3BRT, + MAX77705_RGBLED_REG_LEDBLNK + }; + + regmap_read(regmap, MAX77705_PMIC_REG_PMICID1, &pmic_id); + regmap_read(regmap, MAX77705_PMIC_REG_PMICREV, &pmic_rev); + seq_printf(s, "MAX77705, pmic id: %d, pmic rev: %d\n", + pmic_id, pmic_rev); + seq_puts(s, "===================\n"); + for (i = 0; i < ARRAY_SIZE(regs); i++) { + reg = regs[i]; + regmap_read(regmap, reg, ®_data); + seq_printf(s, "0x%02x:\t0x%02x\n", reg, reg_data); + } + + seq_puts(s, "\n"); + return 0; +} + +DEFINE_SHOW_ATTRIBUTE(max77705_debugfs); + +static const struct regmap_config max77705_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .max_register = MAX77705_PMIC_REG_END, +}; + +static const struct regmap_config max77705_leds_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .max_register = MAX77705_LED_REG_END, +}; + +static const struct regmap_config max77705_fg_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .max_register = MAX77705_FG_END, +}; + +static struct mfd_cell max77705_devs[] = { + { + .name = "leds-max77705-rgb", + .of_compatible = "maxim,max77705-led", + }, + { + .name = "max77705-fuelgauge", + .of_compatible = "maxim,max77705-fg", + }, + { + .name = "max77705-charger", + .of_compatible = "maxim,max77705-charger", + }, + { + .name = "max77705-haptic", + .of_compatible = "maxim,max77705-haptic", + }, +}; + +static int max77705_i2c_probe(struct i2c_client *i2c) +{ + struct max77705_dev *max77705; + struct max77705_platform_data *pdata = i2c->dev.platform_data; + + unsigned int reg_data; + int ret = 0; + + max77705 = kzalloc(sizeof(struct max77705_dev), GFP_KERNEL); + if (!max77705) + return -ENOMEM; + + max77705->pdata = pdata; + max77705->dev = &i2c->dev; + max77705->i2c = i2c; + max77705->irq = i2c->irq; + + max77705->regmap = devm_regmap_init_i2c(max77705->i2c, &max77705_regmap_config); + if (IS_ERR(max77705->regmap)) { + ret = PTR_ERR(max77705->regmap); + dev_err(max77705->dev, "failed to allocate register map: %d\n", + ret); + return ret; + } + + max77705->regmap_leds = devm_regmap_init_i2c(max77705->i2c, &max77705_leds_regmap_config); + if (IS_ERR(max77705->regmap_leds)) { + ret = PTR_ERR(max77705->regmap_leds); + dev_err(max77705->dev, "failed to allocate register map: %d\n", + ret); + return ret; + } + + i2c_set_clientdata(i2c, max77705); + + if (regmap_read(max77705->regmap, MAX77705_PMIC_REG_PMICREV, ®_data) < 0) { + dev_err(max77705->dev, + "device not found on this channel (this is not an error)\n"); + ret = -ENODEV; + goto err; + } else { + /* print rev */ + max77705->pmic_rev = (reg_data & MAX77705_REVISION_MASK); + max77705->pmic_ver = ((reg_data & MAX77705_VERSION_MASK) >> MAX77705_VERSION_SHIFT); + dev_info(max77705->dev, "%s device found: rev.0x%x, ver.0x%x\n", + __func__, max77705->pmic_rev, max77705->pmic_ver); + } + + max77705->charger = devm_i2c_new_dummy_device(max77705->dev, i2c->adapter, I2C_ADDR_CHG); + i2c_set_clientdata(max77705->charger, max77705); + max77705->regmap_charger = devm_regmap_init_i2c(max77705->charger, &max77705_regmap_config); + if (IS_ERR(max77705->regmap)) { + ret = PTR_ERR(max77705->regmap); + dev_err(max77705->dev, "failed to allocate register map: %d\n", + ret); + return ret; + } + + max77705->fuelgauge = devm_i2c_new_dummy_device(max77705->dev, i2c->adapter, I2C_ADDR_FG); + i2c_set_clientdata(max77705->fuelgauge, max77705); + max77705->regmap_fg = devm_regmap_init_i2c(max77705->fuelgauge, &max77705_fg_regmap_config); + if (IS_ERR(max77705->regmap_fg)) { + ret = PTR_ERR(max77705->regmap_fg); + dev_err(max77705->dev, "failed to allocate register map: %d\n", + ret); + return ret; + } + + if (likely(i2c->irq > 0)) + max77705->irq = i2c->irq; + else { + dev_err(max77705->dev, "failed to get irq number\n"); + return -EINVAL; + } + + max77705->irq_base = irq_alloc_descs(-1, 0, MAX77705_IRQ_NR, -1); + if (unlikely(max77705->irq_base < 0)) { + dev_err(max77705->dev, "irq_alloc_descs fail: %d\n", max77705->irq_base); + ret = -EINVAL; + goto err; + } + + disable_irq(max77705->irq); + ret = max77705_irq_init(max77705); + if (ret) { + dev_err(max77705->dev, "failed to init irq system: %d\n", ret); + return ret; + } + + ret = mfd_add_devices(max77705->dev, -1, max77705_devs, + ARRAY_SIZE(max77705_devs), NULL, 0, NULL); + if (ret < 0) + goto err_mfd; + + debugfs_file = debugfs_create_file("max77705-regs", + 0664, NULL, (void *)max77705, + &max77705_debugfs_fops); + if (!debugfs_file) + dev_err(max77705->dev, "Failed to create debugfs file\n"); + + device_init_wakeup(max77705->dev, true); + + return ret; + +err_mfd: + mfd_remove_devices(max77705->dev); +err: + kfree(max77705); + return ret; +} + +static void max77705_i2c_remove(struct i2c_client *i2c) +{ + struct max77705_dev *max77705 = i2c_get_clientdata(i2c); + + if (debugfs_file) + debugfs_remove(debugfs_file); + + device_init_wakeup(max77705->dev, 0); + mfd_remove_devices(max77705->dev); +} + +static int __maybe_unused max77705_suspend(struct device *dev) +{ + struct i2c_client *i2c = to_i2c_client(dev); + struct max77705_dev *max77705 = i2c_get_clientdata(i2c); + + disable_irq(max77705->irq); + if (device_may_wakeup(dev)) + enable_irq_wake(max77705->irq); + + return 0; +} + +static int __maybe_unused max77705_resume(struct device *dev) +{ + struct i2c_client *i2c = to_i2c_client(dev); + struct max77705_dev *max77705 = i2c_get_clientdata(i2c); + + if (device_may_wakeup(dev)) + disable_irq_wake(max77705->irq); + enable_irq(max77705->irq); + + return 0; +} + +static SIMPLE_DEV_PM_OPS(max77705_pm, max77705_suspend, max77705_resume); + +static const struct of_device_id max77705_i2c_dt_ids[] = { + { .compatible = "maxim,max77705" }, + { }, +}; +MODULE_DEVICE_TABLE(of, max77705_i2c_dt_ids); + +static struct i2c_driver max77705_i2c_driver = { + .driver = { + .name = MFD_DEV_NAME, + .pm = &max77705_pm, + .of_match_table = max77705_i2c_dt_ids, + .suppress_bind_attrs = true, + }, + .probe = max77705_i2c_probe, + .remove = max77705_i2c_remove, +}; +module_i2c_driver(max77705_i2c_driver); + +MODULE_DESCRIPTION("MAXIM 77705 multi-function core driver"); +MODULE_AUTHOR("Dzmitry Sankouski "); +MODULE_LICENSE("GPL"); diff --git a/drivers/mfd/max77705-irq.c b/drivers/mfd/max77705-irq.c new file mode 100644 index 000000000000..0da17fc95e18 --- /dev/null +++ b/drivers/mfd/max77705-irq.c @@ -0,0 +1,299 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * max77705-irq.c - Interrupt controller support for MAX77705 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Copyright (C) 2024 Dzmitry Sankouski + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +static const u8 max77705_mask_reg[] = { + [SYS_INT] = MAX77705_PMIC_REG_SYSTEM_INT_MASK, + [CHG_INT] = MAX77705_CHG_REG_INT_MASK, + [FUEL_INT] = MAX77705_REG_INVALID, +}; + +static struct regmap *get_i2c(struct max77705_dev *max77705, + enum max77705_irq_source src) +{ + switch (src) { + case SYS_INT: + return max77705->regmap; + case FUEL_INT: + return max77705->regmap_fg; + case CHG_INT: + return max77705->regmap_charger; + default: + return ERR_PTR(-EINVAL); + } +} + +struct max77705_irq_data { + int mask; + enum max77705_irq_source group; +}; + +static const struct max77705_irq_data max77705_irqs[] = { + [MAX77705_SYSTEM_IRQ_BSTEN_INT] = { .group = SYS_INT, .mask = BIT(3) }, + [MAX77705_SYSTEM_IRQ_SYSUVLO_INT] = { .group = SYS_INT, .mask = BIT(4) }, + [MAX77705_SYSTEM_IRQ_SYSOVLO_INT] = { .group = SYS_INT, .mask = BIT(5) }, + [MAX77705_SYSTEM_IRQ_TSHDN_INT] = { .group = SYS_INT, .mask = BIT(6) }, + [MAX77705_SYSTEM_IRQ_TM_INT] = { .group = SYS_INT, .mask = BIT(7) }, + + [MAX77705_CHG_IRQ_BYP_I] = { .group = CHG_INT, .mask = BIT(0) }, + [MAX77705_CHG_IRQ_BAT_I] = { .group = CHG_INT, .mask = BIT(3) }, + [MAX77705_CHG_IRQ_CHG_I] = { .group = CHG_INT, .mask = BIT(4) }, + [MAX77705_CHG_IRQ_WCIN_I] = { .group = CHG_INT, .mask = BIT(5) }, + [MAX77705_CHG_IRQ_CHGIN_I] = { .group = CHG_INT, .mask = BIT(6) }, + [MAX77705_CHG_IRQ_AICL_I] = { .group = CHG_INT, .mask = BIT(7) }, + + [MAX77705_FG_IRQ_ALERT] = { .group = FUEL_INT, .mask = BIT(1) }, +}; + +static void max77705_irq_lock(struct irq_data *data) +{ + struct max77705_dev *max77705 = irq_get_chip_data(data->irq); + + mutex_lock(&max77705->irqlock); +} + +static void max77705_irq_sync_unlock(struct irq_data *data) +{ + struct max77705_dev *max77705 = irq_get_chip_data(data->irq); + int i; + + for (i = 0; i < MAX77705_IRQ_GROUP_NR; i++) { + u8 mask_reg = max77705_mask_reg[i]; + struct regmap *i2c = get_i2c(max77705, i); + + if (mask_reg == MAX77705_REG_INVALID || + IS_ERR_OR_NULL(i2c)) + continue; + max77705->irq_masks_cache[i] = max77705->irq_masks_cur[i]; + + regmap_write(i2c, max77705_mask_reg[i], + max77705->irq_masks_cur[i]); + } + + mutex_unlock(&max77705->irqlock); +} + +static inline void max77705_read_irq_reg(struct regmap *regmap, unsigned int pmic_rev, + unsigned int reg, unsigned int *irq_src) { + u8 dummy[2] = {0, }; /* for pass1 intr reg clear issue */ + + switch (pmic_rev) { + case MAX77705_PASS1: + regmap_noinc_read(regmap, reg - 1, + dummy, sizeof(dummy)); + *irq_src = (unsigned int) dummy[1]; + break; + case MAX77705_PASS2: + case MAX77705_PASS3: + regmap_read(regmap, reg, + irq_src); + break; + default: + pr_err("%s: PMIC_REVISION(SRC_CHG) isn't valid\n", __func__); + break; + } +} + +static inline const struct max77705_irq_data * +irq_to_max77705_irq(struct max77705_dev *max77705, int irq) +{ + return &max77705_irqs[irq - max77705->irq_base]; +} + +static void max77705_irq_mask(struct irq_data *data) +{ + struct max77705_dev *max77705 = irq_get_chip_data(data->irq); + const struct max77705_irq_data *irq_data = + irq_to_max77705_irq(max77705, data->irq); + + if (irq_data->group >= MAX77705_IRQ_GROUP_NR) + return; + + max77705->irq_masks_cur[irq_data->group] |= irq_data->mask; +} + +static void max77705_irq_unmask(struct irq_data *data) +{ + struct max77705_dev *max77705 = irq_get_chip_data(data->irq); + const struct max77705_irq_data *irq_data = + irq_to_max77705_irq(max77705, data->irq); + + if (irq_data->group >= MAX77705_IRQ_GROUP_NR) + return; + + max77705->irq_masks_cur[irq_data->group] &= ~irq_data->mask; +} + +inline int max77705_irq_mask_subdevice(struct max77705_dev *max77705, unsigned int mask) +{ + int ret; + unsigned int data; + + ret = regmap_read(max77705->regmap, MAX77705_PMIC_REG_INTSRC_MASK, + &data); + if (ret) { + dev_err(max77705->dev, "fail to read MAX77705_PMIC_REG_INTSRC_MASK reg\n"); + return ret; + } + data |= mask; + + regmap_write(max77705->regmap, MAX77705_PMIC_REG_INTSRC_MASK, + data); + return 0; +} +EXPORT_SYMBOL_GPL(max77705_irq_mask_subdevice); + +inline int max77705_irq_unmask_subdevice(struct max77705_dev *max77705, unsigned int mask) +{ + int ret; + unsigned int data; + + ret = regmap_read(max77705->regmap, MAX77705_PMIC_REG_INTSRC_MASK, + &data); + if (ret) { + dev_err(max77705->dev, "fail to read MAX77705_PMIC_REG_INTSRC_MASK reg\n"); + return ret; + } + data &= ~(mask); + + regmap_write(max77705->regmap, MAX77705_PMIC_REG_INTSRC_MASK, + data); + return 0; +} +EXPORT_SYMBOL_GPL(max77705_irq_unmask_subdevice); + +static void max77705_irq_disable(struct irq_data *data) +{ + max77705_irq_mask(data); +} + +static struct irq_chip max77705_irq_chip = { + .name = MFD_DEV_NAME, + .irq_bus_lock = max77705_irq_lock, + .irq_bus_sync_unlock = max77705_irq_sync_unlock, + .irq_mask = max77705_irq_mask, + .irq_unmask = max77705_irq_unmask, + .irq_disable = max77705_irq_disable, +}; + +static irqreturn_t max77705_irq_thread(int irq, void *data) +{ + struct max77705_dev *max77705 = data; + unsigned int irq_reg[MAX77705_IRQ_GROUP_NR] = {0}; + unsigned int irq_src; + int i, ret; + u8 pmic_rev = max77705->pmic_rev; + + max77705->doing_irq = 1; + + ret = regmap_read(max77705->regmap, + MAX77705_PMIC_REG_INTSRC, &irq_src); + if (ret) { + pr_err("%s:%s Failed to read interrupt source: %d\n", + MFD_DEV_NAME, __func__, ret); + + max77705->doing_irq = 0; + return IRQ_NONE; + } + + if (irq_src & MAX77705_IRQSRC_CHG) { + max77705_read_irq_reg(max77705->regmap_charger, pmic_rev, + MAX77705_CHG_REG_INT, &irq_reg[CHG_INT]); + pr_info("%s: charger interrupt(0x%02x)\n", + __func__, irq_reg[CHG_INT]); + } + + /* Apply masking */ + for (i = 0; i < MAX77705_IRQ_GROUP_NR; i++) + irq_reg[i] &= ~max77705->irq_masks_cur[i]; + + /* Report */ + for (i = 0; i < MAX77705_IRQ_NR; i++) { + if (irq_reg[max77705_irqs[i].group] & max77705_irqs[i].mask) + handle_nested_irq(max77705->irq_base + i); + } + + max77705->doing_irq = 0; + + return IRQ_HANDLED; +} + +int max77705_irq_init(struct max77705_dev *max77705) +{ + int i; + int ret = 0; + int cur_irq; + + if (!max77705->irq_base) { + dev_err(max77705->dev, "No interrupt base specified.\n"); + return 0; + } + + mutex_init(&max77705->irqlock); + + /* Mask individual interrupt sources */ + for (i = 0; i < MAX77705_IRQ_GROUP_NR; i++) { + struct regmap *i2c; + /* MUIC IRQ 0:MASK 1:NOT MASK => NOT USE */ + /* Other IRQ 1:MASK 0:NOT MASK */ + max77705->irq_masks_cur[i] = 0xff; + max77705->irq_masks_cache[i] = 0xff; + + i2c = get_i2c(max77705, i); + + if (IS_ERR_OR_NULL(i2c)) + continue; + if (max77705_mask_reg[i] == MAX77705_REG_INVALID) + continue; + regmap_write(i2c, max77705_mask_reg[i], 0xff); + } + + /* Register with genirq */ + for (i = 0; i < MAX77705_IRQ_NR; i++) { + cur_irq = i + max77705->irq_base; + irq_set_chip_data(cur_irq, max77705); + irq_set_chip_and_handler(cur_irq, &max77705_irq_chip, + handle_level_irq); + irq_set_nested_thread(cur_irq, 1); +#ifdef CONFIG_ARM + set_irq_flags(cur_irq, IRQF_VALID); +#else + irq_set_noprobe(cur_irq); +#endif + } + + ret = max77705_irq_mask_subdevice(max77705, MAX77705_IRQSRC_CHG | MAX77705_IRQSRC_TOP | + MAX77705_IRQSRC_FG | MAX77705_IRQSRC_USBC); + if (ret) { + dev_err(max77705->dev, "Failed to mask subdevice irqs\n"); + return ret; + } + + ret = devm_request_threaded_irq(max77705->dev, max77705->irq, NULL, max77705_irq_thread, + IRQF_TRIGGER_LOW | IRQF_ONESHOT, + "max77705-irq", max77705); + if (ret) { + dev_err(max77705->dev, "Failed to request IRQ %d: %d\n", + max77705->irq, ret); + } + + return ret; +} + +MODULE_LICENSE("GPL"); diff --git a/include/linux/mfd/max77705-private.h b/include/linux/mfd/max77705-private.h new file mode 100644 index 000000000000..bd6ab9c582b8 --- /dev/null +++ b/include/linux/mfd/max77705-private.h @@ -0,0 +1,281 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * max77705-private.h + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __LINUX_MFD_MAX77705_PRIV_H +#define __LINUX_MFD_MAX77705_PRIV_H + +#include +#include +#include +#include +#include +#include + +#define MAX77705_REG_INVALID (0xff) +#define MAX77705_IRQSRC_CHG BIT(0) +#define MAX77705_IRQSRC_TOP BIT(1) +#define MAX77705_IRQSRC_FG BIT(2) +#define MAX77705_IRQSRC_USBC BIT(3) + +/* STATUS_REG */ +#define MAX77705_BAT_ABSENT_MASK BIT(3) +/* MAX77705 MAINCTRL1 register */ +#define MAX77705_MAINCTRL1_BIASEN_SHIFT 7 +#define MAX77705_MAINCTRL1_BIASEN_MASK BIT(MAX77705_MAINCTRL1_BIASEN_SHIFT) + +/* max77705-haptic configuration register */ +#define MAX77705_CONFIG2_MEN_SHIFT 6 +#define MAX77705_CONFIG2_MODE_SHIFT 7 +#define MAX77705_CONFIG2_HTYP_SHIFT 5 + +#define MAX77705_REVISION_MASK 7 +#define MAX77705_VERSION_MASK 0xF8 +#define MAX77705_VERSION_SHIFT 3 + +enum max77705_hw_rev { + MAX77705_PASS1 = 1, + MAX77705_PASS2, + MAX77705_PASS3, +}; + +enum max77705_reg { + /* Slave addr = 0xCC */ + /* PMIC Top-Level Registers */ + MAX77705_PMIC_REG_PMICID1 = 0x00, + MAX77705_PMIC_REG_PMICREV = 0x01, + MAX77705_PMIC_REG_MAINCTRL1 = 0x02, + MAX77705_PMIC_REG_INTSRC = 0x22, + MAX77705_PMIC_REG_INTSRC_MASK = 0x23, + MAX77705_PMIC_REG_SYSTEM_INT = 0x24, + MAX77705_PMIC_REG_RESERVED_25 = 0x25, + MAX77705_PMIC_REG_SYSTEM_INT_MASK = 0x26, + MAX77705_PMIC_REG_RESERVED_27 = 0x27, + MAX77705_PMIC_REG_RESERVED_28 = 0x28, + MAX77705_PMIC_REG_RESERVED_29 = 0x29, + MAX77705_PMIC_REG_BOOSTCONTROL1 = 0x4C, + MAX77705_PMIC_REG_BSTOUT_MASK = 0x03, + MAX77705_PMIC_REG_BOOSTCONTROL2 = 0x4F, + MAX77705_PMIC_REG_FORCE_EN_MASK = 0x08, + MAX77705_PMIC_REG_SW_RESET = 0x50, + MAX77705_PMIC_REG_USBC_RESET = 0x51, + + /* Haptic motor driver Registers */ + MAX77705_PMIC_REG_MCONFIG = 0x10, + MAX77705_PMIC_REG_MCONFIG2 = 0x11, + + MAX77705_CHG_REG_INT = 0xB0, + MAX77705_CHG_REG_INT_MASK = 0xB1, + MAX77705_CHG_REG_INT_OK = 0xB2, + MAX77705_CHG_REG_DETAILS_00 = 0xB3, + MAX77705_CHG_REG_DETAILS_01 = 0xB4, + MAX77705_CHG_REG_DETAILS_02 = 0xB5, + MAX77705_CHG_REG_DTLS_03 = 0xB6, + MAX77705_CHG_REG_CNFG_00 = 0xB7, + MAX77705_CHG_REG_CNFG_01 = 0xB8, + MAX77705_CHG_REG_CNFG_02 = 0xB9, + MAX77705_CHG_REG_CNFG_03 = 0xBA, + MAX77705_CHG_REG_CNFG_04 = 0xBB, + MAX77705_CHG_REG_CNFG_05 = 0xBC, + MAX77705_CHG_REG_CNFG_06 = 0xBD, + MAX77705_CHG_REG_CNFG_07 = 0xBE, + MAX77705_CHG_REG_CNFG_08 = 0xBF, + MAX77705_CHG_REG_CNFG_09 = 0xC0, + MAX77705_CHG_REG_CNFG_10 = 0xC1, + MAX77705_CHG_REG_CNFG_11 = 0xC2, + MAX77705_CHG_REG_CNFG_12 = 0xC3, + MAX77705_CHG_REG_CNFG_13 = 0xC4, + MAX77705_CHG_REG_CNFG_14 = 0xC5, + MAX77705_CHG_REG_SAFEOUT_CTRL = 0xC6, + + MAX77705_PMIC_REG_END, +}; + +enum max77705_charger_battery_state { + MAX77705_BATTERY_NOBAT, + MAX77705_BATTERY_PREQUALIFICATION, + MAX77705_BATTERY_DEAD, + MAX77705_BATTERY_GOOD, + MAX77705_BATTERY_LOWVOLTAGE, + MAX77705_BATTERY_OVERVOLTAGE, + MAX77705_BATTERY_RESERVED, +}; + +enum max77705_charger_charge_type { + MAX77705_CHARGER_CONSTANT_CURRENT = 1, + MAX77705_CHARGER_CONSTANT_VOLTAGE, + MAX77705_CHARGER_END_OF_CHARGE, + MAX77705_CHARGER_DONE, +}; + +/* Slave addr = 0x6C : Fuelgauge */ +enum max77705_fuelgauge_reg { + STATUS_REG = 0x00, + VALRT_THRESHOLD_REG = 0x01, + TALRT_THRESHOLD_REG = 0x02, + SALRT_THRESHOLD_REG = 0x03, + REMCAP_REP_REG = 0x05, + SOCREP_REG = 0x06, + TEMPERATURE_REG = 0x08, + VCELL_REG = 0x09, + TIME_TO_EMPTY_REG = 0x11, + FULLSOCTHR_REG = 0x13, + CURRENT_REG = 0x0A, + AVG_CURRENT_REG = 0x0B, + SOCMIX_REG = 0x0D, + SOCAV_REG = 0x0E, + REMCAP_MIX_REG = 0x0F, + FULLCAP_REG = 0x10, + RFAST_REG = 0x15, + AVR_TEMPERATURE_REG = 0x16, + CYCLES_REG = 0x17, + DESIGNCAP_REG = 0x18, + AVR_VCELL_REG = 0x19, + TIME_TO_FULL_REG = 0x20, + CONFIG_REG = 0x1D, + ICHGTERM_REG = 0x1E, + REMCAP_AV_REG = 0x1F, + FULLCAP_NOM_REG = 0x23, + LEARN_CFG_REG = 0x28, + FILTER_CFG_REG = 0x29, + MISCCFG_REG = 0x2B, + QRTABLE20_REG = 0x32, + FULLCAP_REP_REG = 0x35, + RCOMP_REG = 0x38, + VEMPTY_REG = 0x3A, + FSTAT_REG = 0x3D, + DISCHARGE_THRESHOLD_REG = 0x40, + QRTABLE30_REG = 0x42, + ISYS_REG = 0x43, + DQACC_REG = 0x45, + DPACC_REG = 0x46, + AVGISYS_REG = 0x4B, + QH_REG = 0x4D, + VSYS_REG = 0xB1, + TALRTTH2_REG = 0xB2, + /* "not used REG(0xB2)" is for checking fuelgague init result. */ + FG_INIT_RESULT_REG = TALRTTH2_REG, + VBYP_REG = 0xB3, + CONFIG2_REG = 0xBB, + IIN_REG = 0xD0, + OCV_REG = 0xEE, + VFOCV_REG = 0xFB, + VFSOC_REG = 0xFF, + + MAX77705_FG_END, +}; + +enum max77705_irq_source { + SYS_INT = 0, + CHG_INT, + FUEL_INT, + MAX77705_IRQ_GROUP_NR, +}; + + +#define MAX77705_REG_MAINCTRL1_BIASEN BIT(7) + +/* Slave addr = 0x94: RGB LED */ +enum max77705_led_reg { + MAX77705_RGBLED_REG_LEDEN = 0x30, + MAX77705_RGBLED_REG_LED0BRT = 0x31, + MAX77705_RGBLED_REG_LED1BRT = 0x32, + MAX77705_RGBLED_REG_LED2BRT = 0x33, + MAX77705_RGBLED_REG_LED3BRT = 0x34, + MAX77705_RGBLED_REG_LEDRMP = 0x36, + MAX77705_RGBLED_REG_LEDBLNK = 0x38, + MAX77705_LED_REG_END, +}; + +enum max77705_irq { + /* PMIC; TOPSYS */ + MAX77705_SYSTEM_IRQ_BSTEN_INT, + MAX77705_SYSTEM_IRQ_SYSUVLO_INT, + MAX77705_SYSTEM_IRQ_SYSOVLO_INT, + MAX77705_SYSTEM_IRQ_TSHDN_INT, + MAX77705_SYSTEM_IRQ_TM_INT, + + /* PMIC; Charger */ + MAX77705_CHG_IRQ_BYP_I, + MAX77705_CHG_IRQ_BAT_I, + MAX77705_CHG_IRQ_CHG_I, + MAX77705_CHG_IRQ_WCIN_I, + MAX77705_CHG_IRQ_CHGIN_I, + MAX77705_CHG_IRQ_AICL_I, + + /* Fuelgauge */ + MAX77705_FG_IRQ_ALERT, + + MAX77705_IRQ_NR, +}; + +struct max77705_dev { + struct device *dev; + struct i2c_client *i2c; /* 0xCC; Haptic, PMIC */ + struct i2c_client *charger; /* 0xD2; Charger */ + struct i2c_client *fuelgauge; /* 0x6C; Fuelgauge */ + struct i2c_client *muic; /* 0x4A; MUIC */ + struct i2c_client *debug; /* 0xC4; Debug */ + struct mutex i2c_lock; + + struct regmap *regmap; + struct regmap *regmap_fg; + struct regmap *regmap_charger; + struct regmap *regmap_leds; + + int type; + + int irq; + int irq_base; + int irq_masks_cur[MAX77705_IRQ_GROUP_NR]; + int irq_masks_cache[MAX77705_IRQ_GROUP_NR]; + bool wakeup; + struct mutex irqlock; + +#ifdef CONFIG_HIBERNATION + /* For hibernation */ + u8 reg_pmic_dump[MAX77705_PMIC_REG_END]; + u8 reg_muic_dump[MAX77705_USBC_REG_END]; + u8 reg_led_dump[MAX77705_LED_REG_END]; +#endif + + /* pmic VER/REV register */ + u8 pmic_rev; /* pmic Rev */ + u8 pmic_ver; /* pmic version */ + + u8 cc_booting_complete; + + wait_queue_head_t queue_empty_wait_q; + int doing_irq; + int is_usbc_queue; + + struct max77705_platform_data *pdata; +}; + +enum max77705_types { + TYPE_MAX77705, +}; + + +/** + * Unmask sub device interrupts on device level + * + * @param max77705 - device structure + * @param mask - sub device interrupts to unmask + */ +extern inline int max77705_irq_unmask_subdevice(struct max77705_dev *max77705, unsigned int mask); + +/** + * Same as max77705_irq_unmask_device, but for masking. + */ +extern inline int max77705_irq_mask_subdevice(struct max77705_dev *max77705, unsigned int mask); + + +extern int max77705_irq_init(struct max77705_dev *max77705); + +#endif /* __LINUX_MFD_MAX77705_PRIV_H */ diff --git a/include/linux/mfd/max77705.h b/include/linux/mfd/max77705.h new file mode 100644 index 000000000000..e2d757c77973 --- /dev/null +++ b/include/linux/mfd/max77705.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * max77705.h - Driver for the Maxim 77705 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __MAX77705_H__ +#define __MAX77705_H__ + +#define MFD_DEV_NAME "max77705" + +struct max77705_platform_data { + struct power_supply_battery_info *bat_info; +}; + +#endif /* __MAX77705_H__ */ + From patchwork Tue Jun 18 13:59:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13702406 Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) (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 3386815FCFE; Tue, 18 Jun 2024 14:00:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719221; cv=none; b=mG+oTrkKcXTJxl3T1FbkBwm7dzC2tiaTLRF4zDNthFwzoSEnZ4pSWsToFP3RMomTEO66TcYynXM7jnEIuUAnNIYq1yOXvnhmWX3Ilm8zyJ6lfhcOhr1R8w5qea4rsCjX9pcOh0UYpZ2rlnbplcbWkFqgKtcjIAF5xMiG/0qMCgo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719221; c=relaxed/simple; bh=/5IwQ99bQQRhP1wEuLRjxNnEs6zzgSHLcHa2YEf0U7U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ABCh9U5KvZxN6slryF0ZWhK3GsHmais5N85CGOS9RiQ0p0TKCZH72H7dJefeJchm/7IjpyPUgoEDrB5IlyWp6B3k9A10MLhSSBJHGFK4SHUPA03qx6ObwRx74CaFp412HkYsG++VsgVaaZkjORemaVNG2RFDGOyOWIKfc/Api8Q= 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=Ry7b2TKA; arc=none smtp.client-ip=209.85.208.46 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="Ry7b2TKA" Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-57c83100cb4so6291666a12.1; Tue, 18 Jun 2024 07:00:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719217; x=1719324017; 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=Iyl7EIOgIrVaZahoT7LEDslZvULejKLZ0v4aPQDoonI=; b=Ry7b2TKAm1yR5Ryl0s6GIF0YOolM9igb92CEKouivniPhTBsatR5BeP4lrpV+KEbj4 zBVelCfcsw+eFBr1FSwg5JojIU9vnkE9OCJuNMCH1MIbfqfUDAYZytQF65exKd6vFEws wNB7r/MTGFn0bLl7ld8deCRmIreOdEfTUKgVy8PWPuFUclvRpHssvN0aZKN0xMoaZdh7 aCckPh7vAy4b6MmRH0rYEKZMEpujkOg8hFflrZfF7/uWN7VhiWFF3rCYYPBFb8645Gbt 2m0uSXXw1tvjZJqWgUYGhVwCUF1WSTmxqmbhHWBp+oUS+gjb/vAadIdCiPNkh0WjY2YM Bnog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718719217; x=1719324017; 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=Iyl7EIOgIrVaZahoT7LEDslZvULejKLZ0v4aPQDoonI=; b=M+1e3/0v+1p11HNtd3CMgJRhosPbxAhZ/D3mtSmdhmxHiY4zpyj1M12hZVTsZ0vWZC Gc8g1jYrW8ATH6bxKf4lhUXYcb/gQ3nPlvkbgK2Pa9ZquGcYtuVTD0PPHOxSuaYLKFNn l9uniil4kvXyNSiiozkfd0U/uP1wPuVywKFpmXMiJ1ufjI5kXhs1t6es5eXtSjpxyY1p uRiJxrV99+2LFoS+mIMQp+3p7/0xJs7BkcmU/craLSUnlYAr1Hco3I5xoh1FqXD/ovR2 InRwbC8jHaV4MvKGcvqq0IWP5iyCpnShzXkIJlZ4kLW7RtKaIjcEa0FlZyIVdt0dLaWf YmOw== X-Forwarded-Encrypted: i=1; AJvYcCUi2HiV/C9tmixniD2/gTyHLV5VdwfC7UIXniTRjCmpf0vzyZdMCM2cYGn/ynGrbE91pbpdBPdopTzOC0LuGaqlt7Paj885iREO8AxmbrEqR12rDE7GAacDI5hGQODojo9zJ1NhPCpFeZ4/ZKM+7JK/ql8B7NeC2JAul2TUl8G+SEgUGZc1JDxfULs+FbZsdoe2Ra8ysbj9M66HyRt9rLeIlf4XqEktMJx8GWdd/VRlPygssZyd6757pEZ521rylVvV0tQrfRURSUTzNkslpMcfxZZKyt9HQM3ilGPuGJDRZqdc6eX8uOSSarf0Yp/25h9GGK4HwRHueisLD/XQzC1BOKwqdGEEHkHgbLrC9/b/24ayLvLNeC4wnePJDflhrZKHLozYUd1pLLLdx7q0hR2X9ywPP/iU X-Gm-Message-State: AOJu0YygOZy9ch78//V+ANnffnC7NPMXpYTIUtz1ugxc6jSfWYFd/B5+ a0QRq5AX3KKyPaqkJmcXCQdhgxzcHS4qccU9e07R+N22NrvZTwCAKPm3agSx X-Google-Smtp-Source: AGHT+IGGllCbRRfBvYmKtKXfQgz30xuR5BJBT8uIwbflUAozAyJ4/JF5SSTi5ZjGzFImDK2lcpqPHA== X-Received: by 2002:a50:c346:0:b0:578:f472:d9d5 with SMTP id 4fb4d7f45d1cf-57cbd906889mr7353992a12.37.1718719217184; Tue, 18 Jun 2024 07:00:17 -0700 (PDT) Received: from [127.0.1.1] (mm-167-232-122-178.mgts.dynamic.pppoe.byfly.by. [178.122.232.167]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-57cb72da156sm7731278a12.22.2024.06.18.07.00.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 07:00:16 -0700 (PDT) From: Dzmitry Sankouski Date: Tue, 18 Jun 2024 16:59:47 +0300 Subject: [PATCH v3 13/23] input: add max77705 haptic driver Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240618-starqltechn_integration_upstream-v3-13-e3f6662017ac@gmail.com> References: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> In-Reply-To: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> To: Sebastian Reichel , Bjorn Andersson , Michael Turquette , Stephen Boyd , Neil Armstrong , Jessica Zhang , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lee Jones , Dmitry Torokhov , Pavel Machek , Liam Girdwood , Mark Brown , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Krzysztof Kozlowski , Konrad Dybcio , Chanwoo Choi , phone-devel@vger.kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, linux-pwm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1718719184; l=12244; i=dsankouski@gmail.com; s=20240618; h=from:subject:message-id; bh=/5IwQ99bQQRhP1wEuLRjxNnEs6zzgSHLcHa2YEf0U7U=; b=IwqH87QADreHlElJVBH5g4BbXvWQGNAdUcyW7w342IefcdtH3+/qzYsds1Feycq0cFdWX/lgJ hLq8aG1QBixAubL/2LUzHO+Svtbe1BLs23uvNyDAmy3jBOGBU0mNcYn X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=6pMMVVDDReSiRgPCbMOUauN5nS3ty4Sf5b7a2gi4x0M= Add support for haptic controller on MAX77705 Multifunction device. This driver supports external pwm and LRA (Linear Resonant Actuator) motor. User can control the haptic device via force feedback framework. Signed-off-by: Dzmitry Sankouski --- drivers/input/misc/Kconfig | 11 + drivers/input/misc/Makefile | 1 + drivers/input/misc/max77705-haptic.c | 378 +++++++++++++++++++++++++++++++++++ 3 files changed, 390 insertions(+) diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 6ba984d7f0b1..26f7b25a0b42 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -233,6 +233,17 @@ config INPUT_MAX77693_HAPTIC To compile this driver as module, choose M here: the module will be called max77693-haptic. +config INPUT_MAX77705_HAPTIC + tristate "MAXIM MAX77705 haptic controller support" + depends on MFD_MAX77705 && PWM + select INPUT_FF_MEMLESS + help + This option enables support for the haptic controller on + MAXIM MAX77705 chip. + + To compile this driver as module, choose M here: the + module will be called max77705-haptic. + config INPUT_MAX8925_ONKEY tristate "MAX8925 ONKEY support" depends on MFD_MAX8925 diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index 04296a4abe8e..4dea2720b757 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile @@ -51,6 +51,7 @@ obj-$(CONFIG_INPUT_KXTJ9) += kxtj9.o obj-$(CONFIG_INPUT_M68K_BEEP) += m68kspkr.o obj-$(CONFIG_INPUT_MAX77650_ONKEY) += max77650-onkey.o obj-$(CONFIG_INPUT_MAX77693_HAPTIC) += max77693-haptic.o +obj-$(CONFIG_INPUT_MAX77705_HAPTIC) += max77705-haptic.o obj-$(CONFIG_INPUT_MAX8925_ONKEY) += max8925_onkey.o obj-$(CONFIG_INPUT_MAX8997_HAPTIC) += max8997_haptic.o obj-$(CONFIG_INPUT_MC13783_PWRBUTTON) += mc13783-pwrbutton.o diff --git a/drivers/input/misc/max77705-haptic.c b/drivers/input/misc/max77705-haptic.c new file mode 100644 index 000000000000..e92dcb4fff37 --- /dev/null +++ b/drivers/input/misc/max77705-haptic.c @@ -0,0 +1,378 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Based on max77693-haptic.c: + * Copyright (C) 2014,2015 Samsung Electronics + * Jaewon Kim + * Krzysztof Kozlowski + * + * Copyright (C) 2024 Dzmitry Sankouski + * + * This program is not provided / owned by Maxim Integrated Products. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAX_MAGNITUDE_SHIFT 16 + +enum max77705_haptic_motor_type { + MAX77705_HAPTIC_ERM = 0, + MAX77705_HAPTIC_LRA, +}; + +enum max77705_haptic_pulse_mode { + MAX77705_HAPTIC_EXTERNAL_MODE = 0, + MAX77705_HAPTIC_INTERNAL_MODE, +}; + +enum max77705_haptic_pwm_divisor { + MAX77705_HAPTIC_PWM_DIVISOR_32 = 0, + MAX77705_HAPTIC_PWM_DIVISOR_64, + MAX77705_HAPTIC_PWM_DIVISOR_128, + MAX77705_HAPTIC_PWM_DIVISOR_256, +}; + +struct max77705_haptic { + enum max77705_types dev_type; + + struct regmap *regmap_pmic; + struct regmap *regmap_haptic; + struct device *dev; + struct input_dev *input_dev; + struct pwm_device *pwm_dev; + struct regulator *motor_reg; + + bool enabled; + bool suspend_state; + unsigned int magnitude; + unsigned int pwm_duty; + enum max77705_haptic_motor_type type; + enum max77705_haptic_pulse_mode mode; + + struct work_struct work; +}; + +static int max77705_haptic_set_duty_cycle(struct max77705_haptic *haptic) +{ + struct pwm_args pargs; + int delta; + int error; + + pwm_get_args(haptic->pwm_dev, &pargs); + delta = (pargs.period + haptic->pwm_duty) / 2; + error = pwm_config(haptic->pwm_dev, delta, pargs.period); + if (error) { + dev_err(haptic->dev, "failed to configure pwm: %d\n", error); + return error; + } + + return 0; +} + +static int max77705_haptic_bias(struct max77705_haptic *haptic, bool on) +{ + int error; + + error = regmap_update_bits(haptic->regmap_haptic, + MAX77705_PMIC_REG_MAINCTRL1, + MAX77705_MAINCTRL1_BIASEN_MASK, + on << MAX77705_MAINCTRL1_BIASEN_SHIFT); + + if (error) { + dev_err(haptic->dev, "failed to %s bias: %d\n", + on ? "enable" : "disable", error); + return error; + } + + return 0; +} + +static int max77705_haptic_configure(struct max77705_haptic *haptic, + bool enable) +{ + unsigned int value, config_reg; + int error; + + value = ((haptic->type << MAX77705_CONFIG2_MODE_SHIFT) | + (enable << MAX77705_CONFIG2_MEN_SHIFT) | + (haptic->mode << MAX77705_CONFIG2_HTYP_SHIFT) | + MAX77705_HAPTIC_PWM_DIVISOR_128); + config_reg = MAX77705_PMIC_REG_MCONFIG; + + error = regmap_write(haptic->regmap_haptic, + config_reg, value); + if (error) { + dev_err(haptic->dev, + "failed to update haptic config: %d\n", error); + return error; + } + + return 0; +} + +static void max77705_haptic_enable(struct max77705_haptic *haptic) +{ + int error; + + if (haptic->enabled) + return; + + error = pwm_enable(haptic->pwm_dev); + if (error) { + dev_err(haptic->dev, + "failed to enable haptic pwm device: %d\n", error); + return; + } + + error = max77705_haptic_configure(haptic, true); + if (error) + goto err_enable_config; + + haptic->enabled = true; + + return; + +err_enable_config: + pwm_disable(haptic->pwm_dev); +} + +static void max77705_haptic_disable(struct max77705_haptic *haptic) +{ + int error; + + if (!haptic->enabled) + return; + + error = max77705_haptic_configure(haptic, false); + if (error) + return; + + pwm_disable(haptic->pwm_dev); + haptic->enabled = false; +} + +static void max77705_haptic_play_work(struct work_struct *work) +{ + struct max77705_haptic *haptic = + container_of(work, struct max77705_haptic, work); + int error; + + error = max77705_haptic_set_duty_cycle(haptic); + if (error) { + dev_err(haptic->dev, "failed to set duty cycle: %d\n", error); + return; + } + + if (haptic->magnitude) + max77705_haptic_enable(haptic); + else + max77705_haptic_disable(haptic); +} + +static int max77705_haptic_play_effect(struct input_dev *dev, void *data, + struct ff_effect *effect) +{ + struct max77705_haptic *haptic = input_get_drvdata(dev); + struct pwm_args pargs; + u64 period_mag_multi; + + haptic->magnitude = effect->u.rumble.strong_magnitude; + if (!haptic->magnitude) + haptic->magnitude = effect->u.rumble.weak_magnitude; + + /* + * The magnitude comes from force-feedback interface. + * The formula to convert magnitude to pwm_duty as follows: + * - pwm_duty = (magnitude * pwm_period) / MAX_MAGNITUDE(0xFFFF) + */ + pr_info("magnitude: %d(%x)", haptic->magnitude, haptic->magnitude); + pwm_get_args(haptic->pwm_dev, &pargs); + period_mag_multi = (u64)pargs.period * haptic->magnitude; + haptic->pwm_duty = (unsigned int)(period_mag_multi >> + MAX_MAGNITUDE_SHIFT); + + schedule_work(&haptic->work); + + return 0; +} + +static int max77705_haptic_open(struct input_dev *dev) +{ + struct max77705_haptic *haptic = input_get_drvdata(dev); + int error; + + error = max77705_haptic_bias(haptic, true); + if (error) + return error; + + error = regulator_enable(haptic->motor_reg); + if (error) { + dev_err(haptic->dev, + "failed to enable regulator: %d\n", error); + return error; + } + + return 0; +} + +static void max77705_haptic_close(struct input_dev *dev) +{ + struct max77705_haptic *haptic = input_get_drvdata(dev); + int error; + + cancel_work_sync(&haptic->work); + max77705_haptic_disable(haptic); + + error = regulator_disable(haptic->motor_reg); + if (error) + dev_err(haptic->dev, + "failed to disable regulator: %d\n", error); + + max77705_haptic_bias(haptic, false); +} + +static int max77705_haptic_probe(struct platform_device *pdev) +{ + struct max77705_dev *max77705 = dev_get_drvdata(pdev->dev.parent); + struct max77705_haptic *haptic; + int error; + + haptic = devm_kzalloc(&pdev->dev, sizeof(*haptic), GFP_KERNEL); + if (!haptic) + return -ENOMEM; + + haptic->regmap_pmic = max77705->regmap; + haptic->dev = &pdev->dev; + haptic->type = MAX77705_HAPTIC_LRA; + haptic->mode = MAX77705_HAPTIC_EXTERNAL_MODE; + haptic->suspend_state = false; + + /* Variant-specific init */ + haptic->dev_type = max77705->type; + haptic->regmap_haptic = max77705->regmap; + + INIT_WORK(&haptic->work, max77705_haptic_play_work); + + /* Get pwm and regulatot for haptic device */ + haptic->pwm_dev = devm_pwm_get(&pdev->dev, NULL); + if (IS_ERR(haptic->pwm_dev)) { + dev_err(&pdev->dev, "failed to get pwm device\n"); + return PTR_ERR(haptic->pwm_dev); + } + + /* + * FIXME: pwm_apply_args() should be removed when switching to the + * atomic PWM API. + */ + pwm_apply_args(haptic->pwm_dev); + + haptic->motor_reg = devm_regulator_get(&pdev->dev, "haptic"); + if (IS_ERR(haptic->motor_reg)) { + dev_err(&pdev->dev, "failed to get regulator\n"); + return PTR_ERR(haptic->motor_reg); + } + + /* Initialize input device for haptic device */ + haptic->input_dev = devm_input_allocate_device(&pdev->dev); + if (!haptic->input_dev) { + dev_err(&pdev->dev, "failed to allocate input device\n"); + return -ENOMEM; + } + + haptic->input_dev->name = "max77705-haptic"; + haptic->input_dev->id.version = 1; + haptic->input_dev->dev.parent = &pdev->dev; + haptic->input_dev->open = max77705_haptic_open; + haptic->input_dev->close = max77705_haptic_close; + input_set_drvdata(haptic->input_dev, haptic); + input_set_capability(haptic->input_dev, EV_FF, FF_RUMBLE); + + error = input_ff_create_memless(haptic->input_dev, NULL, + max77705_haptic_play_effect); + if (error) { + dev_err(&pdev->dev, "failed to create force-feedback\n"); + return error; + } + + error = input_register_device(haptic->input_dev); + if (error) { + dev_err(&pdev->dev, "failed to register input device\n"); + return error; + } + + platform_set_drvdata(pdev, haptic); + + return 0; +} + +static void max77705_haptic_remove(struct platform_device *pdev) +{ + struct max77705_haptic *haptic = platform_get_drvdata(pdev); + + if (haptic->enabled) + max77705_haptic_disable(haptic); +} + +static int max77705_haptic_suspend(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct max77705_haptic *haptic = platform_get_drvdata(pdev); + + if (haptic->enabled) { + max77705_haptic_disable(haptic); + haptic->suspend_state = true; + } + + return 0; +} + +static int max77705_haptic_resume(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct max77705_haptic *haptic = platform_get_drvdata(pdev); + + if (haptic->suspend_state) { + max77705_haptic_enable(haptic); + haptic->suspend_state = false; + } + + return 0; +} + +static DEFINE_SIMPLE_DEV_PM_OPS(max77705_haptic_pm_ops, + max77705_haptic_suspend, + max77705_haptic_resume); + +static const struct of_device_id of_max77705_haptic_dt_match[] = { + { .compatible = "maxim,max77705-haptic", }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, of_max77705_haptic_dt_match); + +static struct platform_driver max77705_haptic_driver = { + .driver = { + .name = "max77705-haptic", + .pm = pm_sleep_ptr(&max77705_haptic_pm_ops), + .of_match_table = of_max77705_haptic_dt_match, + }, + .probe = max77705_haptic_probe, + .remove_new = max77705_haptic_remove, +}; +module_platform_driver(max77705_haptic_driver); + +MODULE_AUTHOR("Dzmitry Sankouski "); +MODULE_AUTHOR("Jaewon Kim "); +MODULE_AUTHOR("Krzysztof Kozlowski "); +MODULE_DESCRIPTION("MAXIM 77705/77705 Haptic driver"); +MODULE_LICENSE("GPL"); From patchwork Tue Jun 18 13:59:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13702407 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 8C4821607B2; Tue, 18 Jun 2024 14:00:21 +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=1718719224; cv=none; b=bf9UHizC3bewgv/z+6Z/s444ozW46oNDXgVoy0kSOXzIrizJ3/+utL3NofnehzHBP5AC0D+BGp0hRpnI82gZHBF9AgnOCBmGhcf9EBBVZbRr5gTnwUdPbSD+fVA75wJQP1b1pG33zjjsn3f0NuEcgcBEzh/WRDlHe5ek8PMxeic= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719224; c=relaxed/simple; bh=hKVjmHg9fPappw6Ge/EdwOBFJeuWIpNZ6cWmDemYKw8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dNRMXnuizK5xEvDFkdGtvZBS5tUq4oaNZyPJ5WHI9kmvWM1bk/xDsWWN0cRPMp3QaJe9xY7uTxbCDgZnX5jEF5bDSq81UvTD14A8KCUTIi3eSTRlIQ1k4W8/yZcpt6yCBUq67+fzkhx9RSbNruEZY7FsijhiD02CuupJz22j7+Q= 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=HgsHqu2A; 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="HgsHqu2A" Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-2eabd22d3f4so65210421fa.1; Tue, 18 Jun 2024 07:00:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719220; x=1719324020; 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=pq6Yfp+kXuwWjkVTMffVNFCMFuU+SGEaW56q4iKxBz4=; b=HgsHqu2ARF5yg++0SP9+jD0FDUvA1M531TNsZ9US6u5ItoKkspdCdFdX1WYsZKp6oF /P0w3+z8snlXr2Pus7outjYIl67rZeHmI2ApBwLSdW+u5iZdUYfqwiQQxK4kxYY9wZVS 5fi5ke2lUP0KKx7RXJh8t0mh2HKjw0QjlkRCNuP11Og5dDu5Rux7GNjAwiZmrjra+qe+ 7TEzic1tJ9B+qx3P27oEBQF7yQiuzHsBcFo3RA03AAC0ffnuW4FgHlLpBPwY6pLFZ9H0 KBqFw837AVtstLyBU4JeQ/+rwxQrUlZKsxT279FBYQnECXNgzq/qT9xnwF8lY0iSj4Bo l1/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718719220; x=1719324020; 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=pq6Yfp+kXuwWjkVTMffVNFCMFuU+SGEaW56q4iKxBz4=; b=P/V8VZVhJu1nkDmOHnhgCeL1U+Is/sXGhOXvT4tfNLvyUABIQIgKSC4C+vSVFQreXh Ki86stvp6xV6FdCzIN6Hl62+dfkR1n3sUPXGdd6yYiAfpsd+wH40cKgTFAIOy84EFGJg cOhfPP4UTOJsLnzGjttHNrDxJrWQgZLwMbp7xgzgXZ5jW0QGMpUP1oEN90BZ6K0RiTrb ebsu1CoXhXPKYaRsnI+H03hsnrrryjtBnrKGUutKBsjrBUP9tPbDCfQdsEfCVUoPWR/F egGxnTa7tMjsTkrJHUrmvo335syB9q63d2UAnTlAP6xFuQOv3ukeRAxQlInLpJ/yvo4U 5Mcg== X-Forwarded-Encrypted: i=1; AJvYcCXI8zS7okeMGvGRdNy/ortbqkPN1JnAZE7sD4Z3hMme7NzfPBt4SRFdh3VPfqOoS7bY5VT2lnmWNjZeZ5/R6+NwfeUqa3xrxhoL0IMW/o1yTRyb9AhF9B6C+Ubi/4EgaHerRhcWm9ry/gXwuS6DzWwKjIqFN6yqaZ2qDW3jrOf/knBkCCvhW3S8geD86UQi8LLo9eu9/KTZQh2qBmCosi4Da0BOuey2N7WAfKGzCPU4boO+gHcuO5muHMJQijuES4Zsh7BFdZBuXyc00hoLOvQYDMJIcQKwpmtiWyKnxTbkgexuJ6dF5MJwgGdFh3T9BtwWjhyi2byISbLflXgm7rWkYrTY7n2KKSBYDb1AUg2Vf/nys8PQadxvxZAomwrDcl/bC0FKelbu0Y9ee8e1ZTiGNawxvSqt X-Gm-Message-State: AOJu0YyhCqmNiHLxHRcmmYF4hEOxgt9KvTyh94nIw0R0AHTIVqv7xUot WedvrFm69IdFvtysspAX96yx8hagLksP+tViqn6I+odW0BF8MlvQ X-Google-Smtp-Source: AGHT+IEIc2idIrMoCRSMpb70Qx8ivNcZJAnEoJ4kpGJ1qvn9RY/NxJohVfT7t3cUTk1JitYhqXeL/g== X-Received: by 2002:a2e:7205:0:b0:2eb:f9a1:7dd6 with SMTP id 38308e7fff4ca-2ec0e5b5844mr80733881fa.3.1718719219550; Tue, 18 Jun 2024 07:00:19 -0700 (PDT) Received: from [127.0.1.1] (mm-167-232-122-178.mgts.dynamic.pppoe.byfly.by. [178.122.232.167]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-57cb72da156sm7731278a12.22.2024.06.18.07.00.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 07:00:19 -0700 (PDT) From: Dzmitry Sankouski Date: Tue, 18 Jun 2024 16:59:48 +0300 Subject: [PATCH v3 14/23] power: supply: max77705: Add charger driver for Maxim 77705 Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240618-starqltechn_integration_upstream-v3-14-e3f6662017ac@gmail.com> References: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> In-Reply-To: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> To: Sebastian Reichel , Bjorn Andersson , Michael Turquette , Stephen Boyd , Neil Armstrong , Jessica Zhang , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lee Jones , Dmitry Torokhov , Pavel Machek , Liam Girdwood , Mark Brown , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Krzysztof Kozlowski , Konrad Dybcio , Chanwoo Choi , phone-devel@vger.kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, linux-pwm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1718719185; l=34495; i=dsankouski@gmail.com; s=20240618; h=from:subject:message-id; bh=hKVjmHg9fPappw6Ge/EdwOBFJeuWIpNZ6cWmDemYKw8=; b=xfxQadM+f4Z/jGSyjeHbx9fCbIOIfVRWeUMeqh1I4IKNwLQMEIYvF/fRaLke7MY7m6tZWyLC2 d+pny78wduhDySBTNMcMO8qTJZwEYPVeMZvR8QkjYBQVAnu01+bjNvI X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=6pMMVVDDReSiRgPCbMOUauN5nS3ty4Sf5b7a2gi4x0M= Add driver for Maxim 77705 switch-mode charger (part of max77705 MFD driver) providing power supply class information to userspace. The driver is configured through DTS (battery and system related settings). Also, POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE property is writable, which allows to configure charge end at less than 100% Signed-off-by: Dzmitry Sankouski --- drivers/power/supply/Kconfig | 6 + drivers/power/supply/Makefile | 1 + drivers/power/supply/max77705_charger.c | 772 ++++++++++++++++++++++++++++++++ include/linux/mfd/max77705_charger.h | 225 ++++++++++ 4 files changed, 1004 insertions(+) diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index 3e31375491d5..47ca8cc00a80 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -552,6 +552,12 @@ config CHARGER_MAX77693 help Say Y to enable support for the Maxim MAX77693 battery charger. +config CHARGER_MAX77705 + tristate "Maxim MAX77705 battery charger driver" + depends on MFD_MAX77705 + help + Say Y to enable support for the Maxim MAX77705 battery charger. + config CHARGER_MAX77976 tristate "Maxim MAX77976 battery charger driver" depends on I2C diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index 58b567278034..dbec648c78c9 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -77,6 +77,7 @@ obj-$(CONFIG_CHARGER_MAX14577) += max14577_charger.o obj-$(CONFIG_CHARGER_DETECTOR_MAX14656) += max14656_charger_detector.o obj-$(CONFIG_CHARGER_MAX77650) += max77650-charger.o obj-$(CONFIG_CHARGER_MAX77693) += max77693_charger.o +obj-$(CONFIG_CHARGER_MAX77705) += max77705_charger.o obj-$(CONFIG_CHARGER_MAX77976) += max77976_charger.o obj-$(CONFIG_CHARGER_MAX8997) += max8997_charger.o obj-$(CONFIG_CHARGER_MAX8998) += max8998_charger.o diff --git a/drivers/power/supply/max77705_charger.c b/drivers/power/supply/max77705_charger.c new file mode 100644 index 000000000000..2b3e836d4c55 --- /dev/null +++ b/drivers/power/supply/max77705_charger.c @@ -0,0 +1,772 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * max77705_charger.c - Battery charger driver for the Maxim 77705 + * + * Copyright (C) 2014 Samsung Electronics + * Krzysztof Kozlowski + * Copyright (C) 2024 Dzmitry Sankouski + */ + +#include +#include +#include +#include +#include + +#include +#include +#include + +#define MAX77705_CHARGER_NAME "max77705-charger" +static const char *max77705_charger_model = "max77705"; +static const char *max77705_charger_manufacturer = "Maxim Integrated"; +static struct dentry *debugfs_file; + +static enum power_supply_property max77705_charger_props[] = { + POWER_SUPPLY_PROP_ONLINE, + POWER_SUPPLY_PROP_PRESENT, + POWER_SUPPLY_PROP_STATUS, + POWER_SUPPLY_PROP_CHARGE_TYPE, + POWER_SUPPLY_PROP_HEALTH, + POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN, + POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE, + POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT, + POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT, +}; + +static int max77705_get_online(struct regmap *regmap, int *val) +{ + unsigned int data; + int ret; + + ret = regmap_read(regmap, MAX77705_CHG_REG_INT_OK, &data); + if (ret < 0) + return ret; + + *val = !!(data & MAX77705_CHGIN_OK); + + return 0; +} + +static int max77705_get_charger_state(struct max77705_charger_data *charger) +{ + struct regmap *regmap = charger->max77705->regmap_charger; + int status = POWER_SUPPLY_STATUS_UNKNOWN; + unsigned int reg_data; + + regmap_read(regmap, MAX77705_CHG_REG_DETAILS_01, ®_data); + + pr_debug("%s: charger status (0x%02x)\n", __func__, reg_data); + + reg_data &= 0x0f; + + switch (reg_data) { + case 0x0: + case MAX77705_CHARGER_CONSTANT_CURRENT: + case MAX77705_CHARGER_CONSTANT_VOLTAGE: + status = POWER_SUPPLY_STATUS_CHARGING; + break; + case MAX77705_CHARGER_END_OF_CHARGE: + case MAX77705_CHARGER_DONE: + status = POWER_SUPPLY_STATUS_FULL; + break; + case 0x05: + case 0x06: + case 0x07: + status = POWER_SUPPLY_STATUS_NOT_CHARGING; + break; + case 0x08: + case 0xA: + case 0xB: + status = POWER_SUPPLY_STATUS_DISCHARGING; + break; + default: + status = POWER_SUPPLY_STATUS_UNKNOWN; + break; + } + + return (int)status; +} + +static int max77705_get_battery_health(struct regmap *regmap, int *value) +{ + unsigned int bat_dtls; + + regmap_read(regmap, MAX77705_CHG_REG_DETAILS_01, &bat_dtls); + bat_dtls = ((bat_dtls & MAX77705_BAT_DTLS) >> MAX77705_BAT_DTLS_SHIFT); + + pr_debug("%s: bat_dtls(0x%x)\n", __func__, bat_dtls); + + switch (bat_dtls) { + case MAX77705_BATTERY_NOBAT: + pr_debug("%s: No battery and the charger is suspended\n", __func__); + *value = POWER_SUPPLY_HEALTH_NO_BATTERY; + break; + case MAX77705_BATTERY_PREQUALIFICATION: + pr_debug("%s: battery is okay but its voltage is low(~VPQLB)\n", __func__); + break; + case MAX77705_BATTERY_DEAD: + pr_debug("%s: battery dead\n", __func__); + *value = POWER_SUPPLY_HEALTH_DEAD; + break; + case MAX77705_BATTERY_GOOD: + case MAX77705_BATTERY_LOWVOLTAGE: + *value = POWER_SUPPLY_HEALTH_GOOD; + break; + case MAX77705_BATTERY_OVERVOLTAGE: + pr_debug("%s: battery ovp\n", __func__); + *value = POWER_SUPPLY_HEALTH_OVERVOLTAGE; + break; + default: + pr_debug("%s: battery unknown\n", __func__); + *value = POWER_SUPPLY_HEALTH_UNSPEC_FAILURE; + break; + } + + return 0; +} + +static int max77705_get_vbus_state(struct regmap *regmap, int *value) +{ + int ret; + unsigned int charge_dtls; + + ret = regmap_read(regmap, MAX77705_CHG_REG_DETAILS_00, &charge_dtls); + if (ret) + return ret; + + charge_dtls = ((charge_dtls & MAX77705_CHGIN_DTLS) >> + MAX77705_CHGIN_DTLS_SHIFT); + + switch (charge_dtls) { + case 0x00: + *value = POWER_SUPPLY_HEALTH_UNDERVOLTAGE; + break; + case 0x01: + *value = POWER_SUPPLY_HEALTH_UNDERVOLTAGE; + break; + case 0x02: + *value = POWER_SUPPLY_HEALTH_OVERVOLTAGE; + break; + case 0x03: + *value = POWER_SUPPLY_HEALTH_GOOD; + break; + default: + return 0; + } + return 0; +} + +static int max77705_get_health(struct regmap *regmap, int *value) +{ + int ret, is_online = 0; + + ret = max77705_get_online(regmap, &is_online); + if (ret) + return ret; + if (is_online) { + ret = max77705_get_vbus_state(regmap, value); + if (ret || (*value != POWER_SUPPLY_HEALTH_GOOD)) + return ret; + } + ret = max77705_get_battery_health(regmap, value); + if (ret) + return ret; + return ret; +} + +static int max77705_get_input_current(struct max77705_charger_data *charger) +{ + unsigned int reg_data; + int get_current = 0; + struct regmap *regmap = charger->max77705->regmap_charger; + + regmap_read(regmap, + MAX77705_CHG_REG_CNFG_09, ®_data); + /* AND operation for removing the formal 1bit */ + reg_data &= MAX77705_CHG_CHGIN_LIM_MASK; + + if (reg_data <= 0x3) + get_current = 100; + else if (reg_data >= 0x7F) + get_current = 3200; + else + get_current = (reg_data + 0x01) * 25; + + dev_dbg(charger->dev, "reg:(0x%x), charging_current:(%d)\n", + reg_data, get_current); + + return get_current; +} + +static void max77705_set_input_current(struct max77705_charger_data *charger, + int input_current) +{ + int curr_step = 25; + u8 set_reg, set_mask, reg_data = 0; + struct regmap *regmap = charger->max77705->regmap_charger; + + mutex_lock(&charger->charger_mutex); + + + set_reg = MAX77705_CHG_REG_CNFG_09; + set_mask = MAX77705_CHG_CHGIN_LIM_MASK; + + if (input_current < 100) { + reg_data = 0x00; + regmap_update_bits(regmap, set_reg, set_mask, reg_data); + } else { + input_current = (input_current > 3200) ? 3200 : input_current; + reg_data = (input_current / curr_step) - 0x01; + regmap_update_bits(regmap, set_reg, set_mask, reg_data); + } + + mutex_unlock(&charger->charger_mutex); + dev_dbg(charger->dev, "REG(0x%02x) DATA(0x%02x), CURRENT(%d)\n", + set_reg, reg_data, input_current); +} + +static int max77705_get_float_voltage(struct max77705_charger_data *charger) +{ + unsigned int reg_data = 0; + int float_voltage; + struct regmap *regmap = charger->max77705->regmap_charger; + + regmap_read(regmap, MAX77705_CHG_REG_CNFG_04, ®_data); + reg_data &= 0x3F; + float_voltage = reg_data <= 0x04 ? reg_data * 50 + 4000 : + (reg_data - 4) * 10 + 4200; + dev_dbg(charger->dev, "battery cv reg : 0x%x, float voltage val : %d\n", + reg_data, float_voltage); + + return float_voltage; +} + +static void max77705_set_float_voltage(struct max77705_charger_data *charger, + int float_voltage) +{ + int float_voltage_mv; + unsigned int reg_data = 0; + struct regmap *regmap = charger->max77705->regmap_charger; + + float_voltage_mv = float_voltage / 1000; + reg_data = float_voltage_mv <= 4000 ? 0x0 : + float_voltage_mv >= 4500 ? 0x23 : + (float_voltage_mv <= 4200) ? (float_voltage_mv - 4000) / 50 : + (((float_voltage_mv - 4200) / 10) + 0x04); + + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_04, + CHG_CNFG_04_CHG_CV_PRM_MASK, + (reg_data << CHG_CNFG_04_CHG_CV_PRM_SHIFT)); + + regmap_read(regmap, MAX77705_CHG_REG_CNFG_04, ®_data); + dev_dbg(charger->dev, "battery cv voltage 0x%x\n", reg_data); +} + +static bool max77705_check_battery(struct max77705_charger_data *charger) +{ + unsigned int reg_data; + unsigned int reg_data2; + struct regmap *regmap = charger->max77705->regmap_charger; + + + regmap_read(regmap, MAX77705_CHG_REG_INT_OK, ®_data); + + dev_dbg(charger->dev, "CHG_INT_OK(0x%x)\n", reg_data); + + regmap_read(regmap, + MAX77705_CHG_REG_DETAILS_00, ®_data2); + + dev_dbg(charger->dev, "CHG_DETAILS00(0x%x)\n", reg_data2); + + if ((reg_data & MAX77705_BATP_OK) || !(reg_data2 & MAX77705_BATP_DTLS)) + return true; + else + return false; +} + +static int max77705_get_charge_type(struct regmap *regmap, + union power_supply_propval *val) +{ + unsigned int reg_data; + + regmap_read(regmap, MAX77705_CHG_REG_DETAILS_01, ®_data); + reg_data &= 0x0F; + switch (reg_data) { + case MAX77705_CHARGER_CONSTANT_CURRENT: + val->strval = "CC Mode"; + break; + case MAX77705_CHARGER_CONSTANT_VOLTAGE: + val->strval = "CV Mode"; + break; + case MAX77705_CHARGER_END_OF_CHARGE: + val->strval = "EOC"; + break; + case MAX77705_CHARGER_DONE: + val->strval = "DONE"; + break; + default: + val->strval = "NONE"; + break; + } + + return 0; +} + +static int max77705_get_charge_current(struct max77705_charger_data *charger) +{ + unsigned int reg_data; + int get_current = 0; + struct regmap *regmap = charger->max77705->regmap_charger; + + + regmap_read(regmap, MAX77705_CHG_REG_CNFG_02, ®_data); + reg_data &= MAX77705_CHG_CC; + + get_current = reg_data <= 0x2 ? 100 : reg_data * 50; + + dev_dbg(charger->dev, "reg:(0x%x), charging_current:(%d)\n", + reg_data, get_current); + return get_current; +} + +static void max77705_set_charge_current(struct max77705_charger_data *charger, + int fast_charging_current) +{ + int curr_step = 50; + u8 set_mask, reg_data = 0; + struct regmap *regmap = charger->max77705->regmap_charger; + + set_mask = MAX77705_CHG_CC; + + if (fast_charging_current < 100) { + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_02, set_mask, 0x00); + } else { + fast_charging_current = + (fast_charging_current > 3150) ? 3150 : fast_charging_current; + + reg_data |= (fast_charging_current / curr_step); + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_02, set_mask, reg_data); + } + + dev_dbg(charger->dev, "REG(0x%02x) DATA(0x%02x), CURRENT(%d)\n", + MAX77705_CHG_REG_CNFG_02, + reg_data, fast_charging_current); +} + +static int max77705_chg_set_wdtmr_en(struct max77705_charger_data *charger, bool enable) +{ + dev_dbg(charger->dev, "WDT en = %d\n", enable); + struct regmap *regmap = charger->max77705->regmap_charger; + + if (enable) { + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_00, + CHG_CNFG_00_WDTEN_MASK, CHG_CNFG_00_WDTEN_MASK); + } else { + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_00, + CHG_CNFG_00_WDTEN_MASK, 0); + } + + return 0; +} + +static void max77705_charger_initialize(struct max77705_charger_data *charger) +{ + u8 reg_data; + struct power_supply_battery_info *info; + struct regmap *regmap = charger->max77705->regmap_charger; + + if (power_supply_get_battery_info(charger->psy_chg, &info) < 0) + return; + + charger->bat_info = info; + + /* unlock charger setting protect + * slowest LX slope + */ + reg_data = MAX77705_CHGPROT_MASK | MAX77705_SLOWEST_LX_SLOPE; + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_06, reg_data, + reg_data); + + /* + * fast charge timer disable + * restart threshold disable + * pre-qual charge disable + */ + reg_data = (MAX77705_FCHGTIME_DISABLE << CHG_CNFG_01_FCHGTIME_SHIFT) | + (MAX77705_CHG_RSTRT_DISABLE << CHG_CNFG_01_CHG_RSTRT_SHIFT) | + (MAX77705_CHG_PQEN_DISABLE << CHG_CNFG_01_PQEN_SHIFT); + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_01, + (CHG_CNFG_01_FCHGTIME_MASK | + CHG_CNFG_01_CHG_RSTRT_MASK | + CHG_CNFG_01_PQEN_MASK), + reg_data); + + /* + * OTG off(UNO on), boost off + */ + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_00, + CHG_CNFG_00_OTG_CTRL, 0); + + /* + * charge current 450mA(default) + * otg current limit 900mA + */ + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_02, + CHG_CNFG_02_OTG_ILIM_MASK, + MAX77705_OTG_ILIM_900 << CHG_CNFG_02_OTG_ILIM_SHIFT); + + /* BAT to SYS OCP 4.80A */ + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_05, + CHG_CNFG_05_REG_B2SOVRC_MASK, + MAX77705_B2SOVRC_4_8A << CHG_CNFG_05_REG_B2SOVRC_SHIFT); + /* + * top off current 150mA + * top off timer 30min + */ + reg_data = (MAX77705_TO_ITH_150MA << CHG_CNFG_03_TO_ITH_SHIFT) | + (MAX77705_TO_TIME_30M << CHG_CNFG_03_TO_TIME_SHIFT) | + (MAX77705_SYS_TRACK_DISABLE << CHG_CNFG_03_SYS_TRACK_DIS_SHIFT); + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_03, + (CHG_CNFG_03_TO_ITH_MASK | + CHG_CNFG_03_TO_TIME_MASK | + CHG_CNFG_03_SYS_TRACK_DIS_MASK), reg_data); + + /* + * cv voltage 4.2V or 4.35V + * MINVSYS 3.6V(default) + */ + if (info->voltage_max_design_uv < 0) { + dev_warn(charger->dev, "missing battery:voltage-max-design-microvolt\n"); + max77705_set_float_voltage(charger, 4200000); + } else { + max77705_set_float_voltage(charger, info->voltage_max_design_uv); + } + + /* VCHGIN : REG=4.5V, UVLO=4.7V, WCHGIN : REG=4.5V, UVLO=4.7V */ + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_12, + CHG_CNFG_12_VCHGIN_REG_MASK | CHG_CNFG_12_WCIN_REG_MASK, 0); + + /* Boost mode possible in FACTORY MODE */ + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_07, + CHG_CNFG_07_REG_FMBST_MASK, MAX77705_CHG_FMBST); + + /* Watchdog timer */ + max77705_chg_set_wdtmr_en(charger, 0); + + /* Active Discharge Enable */ + regmap_update_bits(regmap, MAX77705_PMIC_REG_MAINCTRL1, 1, 1); + + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_09, MAX77705_CHG_EN, MAX77705_CHG_EN); + + /* VBYPSET=5.0V */ + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_11, CHG_CNFG_11_VBYPSET_MASK, 0); + + /* Switching Frequency : 1.5MHz */ + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_08, CHG_CNFG_08_REG_FSW_MASK, + (MAX77705_CHG_FSW_1_5MHz << CHG_CNFG_08_REG_FSW_SHIFT)); + + /* Auto skip mode */ + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_12, CHG_CNFG_12_REG_DISKIP_MASK, + (MAX77705_AUTO_SKIP << CHG_CNFG_12_REG_DISKIP_SHIFT)); +} + +static bool max77705_charger_unlock(struct max77705_charger_data *charger) +{ + unsigned int reg_data; + unsigned int chgprot; + int retry_cnt = 0; + bool need_init = false; + struct regmap *regmap = charger->max77705->regmap_charger; + + do { + regmap_read(regmap, MAX77705_CHG_REG_CNFG_06, + ®_data); + chgprot = (reg_data & MAX77705_CHGPROT_MASK); + if (chgprot != MAX77705_CHGPROT_UNLOCKED) { + dev_err(charger->dev, "unlock err, chgprot(0x%x), retry(%d)\n", + chgprot, retry_cnt); + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_06, + MAX77705_CHGPROT_MASK, MAX77705_CHGPROT_MASK); + need_init = true; + msleep(20); + } else + break; + } while ((chgprot != MAX77705_CHGPROT_UNLOCKED) && (++retry_cnt < 10)); + + return need_init; +} + +static int max77705_prop_writeable(struct power_supply *psy, + enum power_supply_property psp) +{ + return (psp == POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT) || + (psp == POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN) || + (psp == POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT) || + (psp == POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE); +} + +static int max77705_chg_set_property(struct power_supply *psy, + enum power_supply_property psp, + const union power_supply_propval *val) +{ + struct max77705_charger_data *charger = power_supply_get_drvdata(psy); + + /* check unlock status before does set the register */ + max77705_charger_unlock(charger); + switch (psp) { + case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT: + max77705_set_input_current(charger, val->intval); + break; + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT: + max77705_set_charge_current(charger, val->intval); + break; + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE: + if (val->intval > charger->bat_info->voltage_max_design_uv) { + dev_err(charger->dev, "%d voltage higher than max", + val->intval); + return -EINVAL; + } + max77705_set_float_voltage(charger, val->intval); + break; + default: + return -EINVAL; + } + return 0; +} + +static int max77705_chg_get_property(struct power_supply *psy, + enum power_supply_property psp, + union power_supply_propval *val) +{ + int ret = 0; + struct max77705_charger_data *charger = power_supply_get_drvdata(psy); + struct regmap *regmap = charger->max77705->regmap_charger; + + switch (psp) { + case POWER_SUPPLY_PROP_ONLINE: + max77705_get_online(regmap, &val->intval); + break; + case POWER_SUPPLY_PROP_PRESENT: + val->intval = max77705_check_battery(charger); + break; + case POWER_SUPPLY_PROP_STATUS: + val->intval = max77705_get_charger_state(charger); + break; + case POWER_SUPPLY_PROP_HEALTH: + ret = max77705_get_health(regmap, &val->intval); + break; + case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT: + val->intval = max77705_get_input_current(charger); + break; + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT: + val->intval = max77705_get_charge_current(charger); + break; + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE: + val->intval = max77705_get_float_voltage(charger); + break; + case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN: + val->intval = charger->bat_info->voltage_max_design_uv; + break; + case POWER_SUPPLY_PROP_CHARGE_TYPE: + ret = max77705_get_charge_type(regmap, val); + break; + case POWER_SUPPLY_PROP_MODEL_NAME: + val->strval = max77705_charger_model; + break; + case POWER_SUPPLY_PROP_MANUFACTURER: + val->strval = max77705_charger_manufacturer; + break; + default: + return -EINVAL; + } + return ret; +} + +static void max77705_chgin_isr_work(struct work_struct *work) +{ + struct max77705_charger_data *charger = + container_of(work, struct max77705_charger_data, chgin_work); + regmap_update_bits(charger->max77705->regmap_charger, + MAX77705_CHG_REG_INT_MASK, + MAX77705_CHGIN_IM, MAX77705_CHGIN_IM); + power_supply_changed(charger->psy_chg); + regmap_update_bits(charger->max77705->regmap_charger, + MAX77705_CHG_REG_INT_MASK, + MAX77705_CHGIN_IM, 0); +} + +static irqreturn_t max77705_chgin_irq(int irq, void *data) +{ + struct max77705_charger_data *charger = data; + + queue_work(charger->wqueue, &charger->chgin_work); + + return IRQ_HANDLED; +} + +static int max77705_debugfs_show(struct seq_file *s, void *data) +{ + struct max77705_charger_data *charger = s->private; + struct regmap *regmap = charger->max77705->regmap_charger; + unsigned int reg, reg_data; + + seq_printf(s, "MAX77705 CHARGER IC, ver.0x%x\n", charger->pmic_ver); + seq_puts(s, "===================\n"); + for (reg = 0xB0; reg <= 0xC3; reg++) { + regmap_read(regmap, reg, ®_data); + seq_printf(s, "0x%02x:\t0x%02x\n", reg, reg_data); + } + + seq_puts(s, "\n"); + return 0; +} + +static int max77705_debugfs_open(struct inode *inode, struct file *file) +{ + return single_open(file, max77705_debugfs_show, inode->i_private); +} + +static const struct file_operations max77705_debugfs_fops = { + .open = max77705_debugfs_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static const struct power_supply_desc max77705_charger_power_supply_desc = { + .name = MAX77705_CHARGER_NAME, + .type = POWER_SUPPLY_TYPE_BATTERY, + .properties = max77705_charger_props, + .num_properties = ARRAY_SIZE(max77705_charger_props), + .get_property = max77705_chg_get_property, + .set_property = max77705_chg_set_property, + .property_is_writeable = max77705_prop_writeable, +}; + +static int max77705_charger_probe(struct platform_device *pdev) +{ + struct max77705_dev *max77705 = dev_get_drvdata(pdev->dev.parent); + struct max77705_platform_data *pdata = dev_get_platdata(max77705->dev); + struct max77705_charger_data *charger; + struct regmap *regmap = max77705->regmap_charger; + struct power_supply_config charger_cfg = { }; + int ret = 0; + unsigned int reg_data; + + charger = kzalloc(sizeof(*charger), GFP_KERNEL); + if (!charger) + return -ENOMEM; + + mutex_init(&charger->charger_mutex); + + charger->dev = &pdev->dev; + charger->max77705 = max77705; + charger->max77705_pdata = pdata; + + platform_set_drvdata(pdev, charger); + + regmap_read(regmap, MAX77705_CHG_REG_INT_OK, ®_data); + + if (regmap_read + (max77705->regmap, MAX77705_PMIC_REG_PMICREV, ®_data) < 0) { + dev_err(charger->dev, + "device not found on this channel (this is not an error)\n"); + ret = -ENOMEM; + } else { + charger->pmic_ver = (reg_data & 0x7); + dev_dbg(charger->dev, "device found : ver.0x%x\n", charger->pmic_ver); + } + + debugfs_file = debugfs_create_file("max77705-charger-regs", + 0664, NULL, (void *)charger, + &max77705_debugfs_fops); + if (!debugfs_file) + dev_err(charger->dev, "Failed to create debugfs file\n"); + + charger_cfg.drv_data = charger; + charger_cfg.of_node = charger->dev->of_node; + + charger->psy_chg = + devm_power_supply_register(&pdev->dev, + &max77705_charger_power_supply_desc, + &charger_cfg); + if (IS_ERR(charger->psy_chg)) { + dev_err(charger->dev, "Failed to Register psy_chg\n"); + goto err_free; + } + + max77705_charger_initialize(charger); + + charger->wqueue = create_singlethread_workqueue(dev_name(&pdev->dev)); + if (!charger->wqueue) { + pr_err("%s: Fail to Create Workqueue\n", __func__); + goto err_free; + } + INIT_WORK(&charger->chgin_work, max77705_chgin_isr_work); + + charger->irq_chgin = max77705->irq_base + MAX77705_CHG_IRQ_CHGIN_I; + ret = devm_request_threaded_irq(charger->dev, charger->irq_chgin, NULL, + max77705_chgin_irq, 0, "chgin-irq", charger); + if (ret < 0) { + pr_err("%s: fail to request chgin IRQ: %d: %d\n", + __func__, charger->irq_chgin, ret); + } else { + max77705_irq_unmask_subdevice(max77705, MAX77705_IRQSRC_CHG); + } + + return 0; + +err_free: + kfree(charger); + + return ret; +} + +static void max77705_charger_remove(struct platform_device *pdev) +{ + struct max77705_charger_data *charger = platform_get_drvdata(pdev); + struct regmap *regmap = charger->max77705->regmap_charger; + + max77705_irq_mask_subdevice(charger->max77705, MAX77705_IRQSRC_CHG); + + if (regmap) { + u8 reg_data; + + reg_data = CHG_CNFG_00_BUCK_MASK; + regmap_write(regmap, MAX77705_CHG_REG_CNFG_00, reg_data); + reg_data = max77705_convert_ma_to_chgin_ilim_value(500); + regmap_write(regmap, MAX77705_CHG_REG_CNFG_09, reg_data); + reg_data = max77705_convert_ma_to_wcin_ilim_value(320); + regmap_write(regmap, MAX77705_CHG_REG_CNFG_10, reg_data); + reg_data = CHG_CNFG_12_CHGINSEL_MASK | CHG_CNFG_12_WCINSEL_MASK; + regmap_write(regmap, MAX77705_CHG_REG_CNFG_12, reg_data); + } else { + dev_err(charger->dev, "no max77705 i2c client\n"); + } + + if (debugfs_file) + debugfs_remove(debugfs_file); + + kfree(charger); +} + +static const struct platform_device_id max77705_charger_id[] = { + { "max77705-charger", 0, }, + { } +}; +MODULE_DEVICE_TABLE(platform, max77705_charger_id); + +static struct platform_driver max77705_charger_driver = { + .driver = { + .name = "max77705-charger", + }, + .probe = max77705_charger_probe, + .remove_new = max77705_charger_remove, + .id_table = max77705_charger_id, +}; +module_platform_driver(max77705_charger_driver); + +MODULE_AUTHOR("Dzmitry Sankouski "); +MODULE_DESCRIPTION("Maxim 77705 charger driver"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/mfd/max77705_charger.h b/include/linux/mfd/max77705_charger.h new file mode 100644 index 000000000000..816bb63d9583 --- /dev/null +++ b/include/linux/mfd/max77705_charger.h @@ -0,0 +1,225 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * max77705_charger.h + * Samsung max77705 Charger Header + * + * Copyright (C) 2015 Samsung Electronics, Inc. + * + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifndef __MAX77705_CHARGER_H +#define __MAX77705_CHARGER_H __FILE__ + +#include +#include +#include +#include + +/* MAX77705_CHG_REG_CHG_INT */ +#define MAX77705_BYP_I BIT(0) +#define MAX77705_INP_LIMIT_I BIT(1) +#define MAX77705_BATP_I BIT(2) +#define MAX77705_BAT_I BIT(3) +#define MAX77705_CHG_I BIT(4) +#define MAX77705_WCIN_I BIT(5) +#define MAX77705_CHGIN_I BIT(6) +#define MAX77705_AICL_I BIT(7) + +/* MAX77705_CHG_REG_CHG_INT_MASK */ +#define MAX77705_BYP_IM BIT(0) +#define MAX77705_INP_LIMIT_IM BIT(1) +#define MAX77705_BATP_IM BIT(2) +#define MAX77705_BAT_IM BIT(3) +#define MAX77705_CHG_IM BIT(4) +#define MAX77705_WCIN_IM BIT(5) +#define MAX77705_CHGIN_IM BIT(6) +#define MAX77705_AICL_IM BIT(7) + +/* MAX77705_CHG_REG_CHG_INT_OK */ +#define MAX77705_BYP_OK BIT(0) +#define MAX77705_DISQBAT_OK BIT(1) +#define MAX77705_BATP_OK BIT(2) +#define MAX77705_BAT_OK BIT(3) +#define MAX77705_CHG_OK BIT(4) +#define MAX77705_WCIN_OK BIT(5) +#define MAX77705_CHGIN_OK BIT(6) +#define MAX77705_AICL_OK BIT(7) + +/* MAX77705_CHG_REG_CHG_DTLS_00 */ +#define MAX77705_BATP_DTLS BIT(0) +#define MAX77705_WCIN_DTLS (BIT(3) | BIT(4)) +#define MAX77705_WCIN_DTLS_SHIFT 3 +#define MAX77705_CHGIN_DTLS (BIT(5) | BIT(6)) +#define MAX77705_CHGIN_DTLS_SHIFT 5 + +/* MAX77705_CHG_REG_CHG_DTLS_01 */ +#define MAX77705_CHG_DTLS (BIT(0) | BIT(1) | BIT(2) | BIT(3)) +#define MAX77705_CHG_DTLS_SHIFT 0 +#define MAX77705_BAT_DTLS (BIT(4) | BIT(5) | BIT(6)) +#define MAX77705_BAT_DTLS_SHIFT 4 + +/* MAX77705_CHG_REG_CHG_DTLS_02 */ +#define MAX77705_BYP_DTLS (BIT(0) | BIT(1) | BIT(2) | BIT(3)) +#define MAX77705_BYP_DTLS_SHIFT 0 + +/* MAX77705_CHG_REG_CHG_CNFG_00 */ +#define CHG_CNFG_00_MODE_SHIFT 0 +#define CHG_CNFG_00_CHG_SHIFT 0 +#define CHG_CNFG_00_UNO_SHIFT 1 +#define CHG_CNFG_00_OTG_SHIFT 1 +#define CHG_CNFG_00_BUCK_SHIFT 2 +#define CHG_CNFG_00_BOOST_SHIFT 3 +#define CHG_CNFG_00_WDTEN_SHIFT 4 +#define CHG_CNFG_00_MODE_MASK (0x0F << CHG_CNFG_00_MODE_SHIFT) +#define CHG_CNFG_00_CHG_MASK BIT(CHG_CNFG_00_CHG_SHIFT) +#define CHG_CNFG_00_UNO_MASK BIT(CHG_CNFG_00_UNO_SHIFT) +#define CHG_CNFG_00_OTG_MASK BIT(CHG_CNFG_00_OTG_SHIFT) +#define CHG_CNFG_00_BUCK_MASK BIT(CHG_CNFG_00_BUCK_SHIFT) +#define CHG_CNFG_00_BOOST_MASK BIT(CHG_CNFG_00_BOOST_SHIFT) +#define CHG_CNFG_00_WDTEN_MASK BIT(CHG_CNFG_00_WDTEN_SHIFT) +#define CHG_CNFG_00_UNO_CTRL (CHG_CNFG_00_UNO_MASK | CHG_CNFG_00_BOOST_MASK) +#define CHG_CNFG_00_OTG_CTRL (CHG_CNFG_00_OTG_MASK | CHG_CNFG_00_BOOST_MASK) + +/* MAX77705_CHG_REG_CHG_CNFG_01 */ +#define CHG_CNFG_01_FCHGTIME_SHIFT 0 +#define CHG_CNFG_01_FCHGTIME_MASK (0x7 << CHG_CNFG_01_FCHGTIME_SHIFT) +#define MAX77705_FCHGTIME_DISABLE 0x0 + +#define CHG_CNFG_01_CHG_RSTRT_SHIFT 4 +#define CHG_CNFG_01_CHG_RSTRT_MASK (0x3 << CHG_CNFG_01_CHG_RSTRT_SHIFT) +#define MAX77705_CHG_RSTRT_DISABLE 0x3 + +#define CHG_CNFG_01_PQEN_SHIFT 7 +#define CHG_CNFG_01_PQEN_MASK (0x1 << CHG_CNFG_01_PQEN_SHIFT) +#define MAX77705_CHG_PQEN_DISABLE 0x0 +#define MAX77705_CHG_PQEN_ENABLE 0x1 + +/* MAX77705_CHG_REG_CHG_CNFG_02 */ +#define CHG_CNFG_02_OTG_ILIM_SHIFT 6 +#define CHG_CNFG_02_OTG_ILIM_MASK (0x3 << CHG_CNFG_02_OTG_ILIM_SHIFT) +#define MAX77705_OTG_ILIM_500 0x0 +#define MAX77705_OTG_ILIM_900 0x1 +#define MAX77705_OTG_ILIM_1200 0x2 +#define MAX77705_OTG_ILIM_1500 0x3 +#define MAX77705_CHG_CC 0x3F + +/* MAX77705_CHG_REG_CHG_CNFG_03 */ +#define CHG_CNFG_03_TO_ITH_SHIFT 0 +#define CHG_CNFG_03_TO_ITH_MASK (0x7 << CHG_CNFG_03_TO_ITH_SHIFT) +#define MAX77705_TO_ITH_150MA 0x0 + +#define CHG_CNFG_03_TO_TIME_SHIFT 3 +#define CHG_CNFG_03_TO_TIME_MASK (0x7 << CHG_CNFG_03_TO_TIME_SHIFT) +#define MAX77705_TO_TIME_30M 0x3 + +#define CHG_CNFG_03_SYS_TRACK_DIS_SHIFT 7 +#define CHG_CNFG_03_SYS_TRACK_DIS_MASK (0x1 << CHG_CNFG_03_SYS_TRACK_DIS_SHIFT) +#define MAX77705_SYS_TRACK_ENABLE 0x0 +#define MAX77705_SYS_TRACK_DISABLE 0x1 + +/* MAX77705_CHG_REG_CHG_CNFG_04 */ +#define MAX77705_CHG_MINVSYS_MASK 0xC0 +#define MAX77705_CHG_MINVSYS_SHIFT 6 +#define MAX77705_CHG_PRM_MASK 0x1F +#define MAX77705_CHG_PRM_SHIFT 0 + +#define CHG_CNFG_04_CHG_CV_PRM_SHIFT 0 +#define CHG_CNFG_04_CHG_CV_PRM_MASK (0x3F << CHG_CNFG_04_CHG_CV_PRM_SHIFT) + +/* MAX77705_CHG_REG_CHG_CNFG_05 */ +#define CHG_CNFG_05_REG_B2SOVRC_SHIFT 0 +#define CHG_CNFG_05_REG_B2SOVRC_MASK (0xF << CHG_CNFG_05_REG_B2SOVRC_SHIFT) +#define MAX77705_B2SOVRC_DISABLE 0x0 +#define MAX77705_B2SOVRC_4_5A 0x6 +#define MAX77705_B2SOVRC_4_8A 0x8 +#define MAX77705_B2SOVRC_5_0A 0x9 + +/* MAX77705_CHG_CNFG_06 */ +#define CHG_CNFG_01_WDTCLR_SHIFT 0 +#define CHG_CNFG_01_WDTCLR_MASK (0x3 << CHG_CNFG_01_WDTCLR_SHIFT) +#define MAX77705_WDTCLR 0x01 +#define MAX77705_CHGPROT_MASK (BIT(2) | BIT(3)) +#define MAX77705_CHGPROT_UNLOCKED (BIT(2) | BIT(3)) +#define MAX77705_SLOWEST_LX_SLOPE (BIT(5) | BIT(6)) + +/* MAX77705_CHG_REG_CHG_CNFG_07 */ +#define MAX77705_CHG_FMBST 0x04 +#define CHG_CNFG_07_REG_FMBST_SHIFT 2 +#define CHG_CNFG_07_REG_FMBST_MASK (0x1 << CHG_CNFG_07_REG_FMBST_SHIFT) +#define CHG_CNFG_07_REG_FGSRC_SHIFT 1 +#define CHG_CNFG_07_REG_FGSRC_MASK (0x1 << CHG_CNFG_07_REG_FGSRC_SHIFT) + +/* MAX77705_CHG_REG_CHG_CNFG_08 */ +#define CHG_CNFG_08_REG_FSW_SHIFT 0 +#define CHG_CNFG_08_REG_FSW_MASK (0x3 << CHG_CNFG_08_REG_FSW_SHIFT) +#define MAX77705_CHG_FSW_3MHz 0x00 +#define MAX77705_CHG_FSW_2MHz 0x01 +#define MAX77705_CHG_FSW_1_5MHz 0x02 + +/* MAX77705_CHG_REG_CHG_CNFG_09 */ +#define MAX77705_CHG_CHGIN_LIM_MASK 0x7F +#define MAX77705_CHG_EN 0x80 + +/* MAX77705_CHG_REG_CHG_CNFG_10 */ +#define MAX77705_CHG_WCIN_LIM 0x3F + +/* MAX77705_CHG_REG_CHG_CNFG_11 */ +#define CHG_CNFG_11_VBYPSET_SHIFT 0 +#define CHG_CNFG_11_VBYPSET_MASK (0x7F << CHG_CNFG_11_VBYPSET_SHIFT) + +/* MAX77705_CHG_REG_CHG_CNFG_12 */ +#define CHG_CNFG_12_CHGINSEL_SHIFT 5 +#define MAX77705_CHG_WCINSEL BIT(CHG_CNFG_12_CHGINSEL_SHIFT) +#define CHG_CNFG_12_CHGINSEL_MASK BIT(CHG_CNFG_12_CHGINSEL_SHIFT) +#define CHG_CNFG_12_WCINSEL_SHIFT 6 +#define CHG_CNFG_12_WCINSEL_MASK BIT(CHG_CNFG_12_WCINSEL_SHIFT) +#define CHG_CNFG_12_VCHGIN_REG_MASK (0x3 << 3) +#define CHG_CNFG_12_WCIN_REG_MASK (0x3 << 1) +#define CHG_CNFG_12_REG_DISKIP_SHIFT 0 +#define CHG_CNFG_12_REG_DISKIP_MASK (0x1 << CHG_CNFG_12_REG_DISKIP_SHIFT) +#define MAX77705_DISABLE_SKIP 0x1 +#define MAX77705_AUTO_SKIP 0x0 + +/* Convert current in mA to corresponding CNFG09 value */ +inline u8 max77705_convert_ma_to_chgin_ilim_value(int cur) +{ + if (unlikely(cur < 0 && cur > 4000)) + return 0; + return (((cur - 100) / 33) + 3); +} + +/* Convert current in mA to corresponding CNFG10 value */ +inline u8 max77705_convert_ma_to_wcin_ilim_value(int cur) +{ + if (unlikely(cur < 0 && cur > 4000)) + return 0; + return (((cur - 60) / 20) + 3); +} + +struct max77705_charger_data { + struct device *dev; + struct mutex charger_mutex; + + struct max77705_platform_data *max77705_pdata; + struct max77705_dev *max77705; + struct power_supply_battery_info *bat_info; + struct workqueue_struct *wqueue; + struct work_struct chgin_work; + int irq_chgin; + + struct power_supply *psy_chg; + + int pmic_ver; +}; + +#endif /* __MAX77705_CHARGER_H */ From patchwork Tue Jun 18 13:59:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13702408 Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) (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 BEB5C15E5BB; Tue, 18 Jun 2024 14:00:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719226; cv=none; b=HxiDsXcBqIEC7Q0SsEU5IZFPO0oPIfk8gVLtWjlRypWVwE8yvy5OWhat7uQpENnE6+a8NsQIPe6EpZCDPCZNYSbbhzhwKnVCwjiHTZ+HBrlR6xpLVQFW4r+M/mCHNaHQ042LGYC3heUX/8dO348MbhBVYSj3/kYCh1hY9GDlGug= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719226; c=relaxed/simple; bh=BLOwIqGw+wExDrQOQm9Fvk1lqNaWLusTKKjG//P54Vw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BFpmnwh0OEy+erQS6+gPui6lusE26nHjvGx6kceWYGOqHCUVpRcpato9N2SkYkneEkgd6br2/ckk0fXDD6JT7p3l0U1mHw7fg4COQVi48VKOKve/g8nuU0zzsb7ND4wPqvz960m+OTnBsrmMJdbVEcpOMfRE2mv4XFWHpaonE88= 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=kgGZKuRU; arc=none smtp.client-ip=209.85.208.48 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="kgGZKuRU" Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-57cb9a370ddso6246119a12.1; Tue, 18 Jun 2024 07:00:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719222; x=1719324022; 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=qhfnNpNBsnC71c1gGip7xlB/2wIBnZLefF+1ERb3g1U=; b=kgGZKuRUPVFrBnkwOXdnc3rQ/EJUR7xD9bu0ZT6pfAzhdPNYKG/u2s+ZiQWyrQU9PG YqCTev/TFHklivkAzudkfOqFx9NyhG9sk9E78z4MTKprCIb58ZfDbVhnw4vsDRVtzVCx vB/CaYZRheC2ankuaW5VGPoSDWHmFMTIacTURYBjHbJi+69zdP5EkJSe82MKeVc4x5ZD nBd9CQfLt+4LtAVpji1rCa9V6wpqXyiWsc11RN0FZ5xGk8HGn/kdqVfGInqvEyMUQLO7 H3fHtMnOtX+WNhgLd/l+Ix9qO7QtsE7BZOks43tlVRlXEU+iPcpslN8S4dogTb9gAtN6 RFcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718719222; x=1719324022; 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=qhfnNpNBsnC71c1gGip7xlB/2wIBnZLefF+1ERb3g1U=; b=k2GbTHiMxhs6vDWMWV9AoO1pLAsFrdaRkRVlcAX5imbFzTS6Gu7rfeKa/xadVst5of iZptKrBzQCVzY16ywuXJET8ZCLaGfTrE8erLos0gKBXVDofc/PLJ4C38ip74TMiqb6ur slilhRvmfpkvD2uotLC3VumGE+PJCINCe9ER7vUAA7CJ1c8LAT63MCrBC5KPTSRUbvj7 w+H0kpZgmLGGkFt5s/nd9AhLlN2jmSpWtUO1pkiApJPCSH/CF3U5Cnz0eHO1lfUdWmD2 xAoCOw+W01Mx+JHfcy98ZFFIMsltaozsjWjdXrorEPedgBnu1ud/hbrT6O+wsOXVlqwY jftw== X-Forwarded-Encrypted: i=1; AJvYcCW0Lib5SdMtYhB9XTbPAtNGA53HTnuWk7UWtrpsy1WJQ6wXituVadkaMQq3GtF0boEsaRZTnT2fJUnmXxLwvt78LGsB1QG/kpMqBGYFcaEQ9HazypG1pMTNpv1lWPeY3gVEAJLOPQEnR3XAKTtWTjK5+SaH7JdkMBvyfiq0D/jnwrUOfp1bWglYnDTSOetGcFdJTnpM9Tju7Q19UZrn9U2c4w3uFx4leUfvFG94lefazA4N7NyHCc9JfhaEUTUWs0SZOsgtEPTl7MZ9GyAibY7evahrS6g+Ow7GP0PQmaWsH7/y9GVSv2wXidnlEDPCJGbOUxG7vyRTGlqXSo8vUyTyFfxr3XDp06uAkGqkVmDu5ooWasZSD6FhcOwg43vO1roSpZgFpSmVfdSmhWwfRM/v3TaqEQ36 X-Gm-Message-State: AOJu0Ywe93JkjXiMAsM2QnccnrXtQ8Qgqw8VY0Btry5afv6mjr8morjq U82YzNDL/f7hr5/3A5W84e1TLCw9RJjTPnXGevuVszSk4RZlefDR X-Google-Smtp-Source: AGHT+IFQTJJ8QXvmtZf52Rf+zFnxjPxqgb7tm/65oOMrxXvpZ0Qcdy5rUNwoYgyi05CXcmCv69WNzA== X-Received: by 2002:a50:ccc5:0:b0:57c:dbf6:931f with SMTP id 4fb4d7f45d1cf-57cdbf694e3mr4303195a12.5.1718719221872; Tue, 18 Jun 2024 07:00:21 -0700 (PDT) Received: from [127.0.1.1] (mm-167-232-122-178.mgts.dynamic.pppoe.byfly.by. [178.122.232.167]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-57cb72da156sm7731278a12.22.2024.06.18.07.00.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 07:00:21 -0700 (PDT) From: Dzmitry Sankouski Date: Tue, 18 Jun 2024 16:59:49 +0300 Subject: [PATCH v3 15/23] power: supply: max77705: Add fuel gauge driver for Maxim 77705 Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240618-starqltechn_integration_upstream-v3-15-e3f6662017ac@gmail.com> References: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> In-Reply-To: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> To: Sebastian Reichel , Bjorn Andersson , Michael Turquette , Stephen Boyd , Neil Armstrong , Jessica Zhang , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lee Jones , Dmitry Torokhov , Pavel Machek , Liam Girdwood , Mark Brown , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Krzysztof Kozlowski , Konrad Dybcio , Chanwoo Choi , phone-devel@vger.kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, linux-pwm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1718719185; l=23884; i=dsankouski@gmail.com; s=20240618; h=from:subject:message-id; bh=BLOwIqGw+wExDrQOQm9Fvk1lqNaWLusTKKjG//P54Vw=; b=maw2WZrWl3pVzUdoaXHmGfxI5ztVfjrdMkzqrfqQYRf+fFwaZMnvw7lsTEmQfZhw4lTpZsnIt TK/iewOe2LrAy22IKK7OAVg4nSDqwyizG7HiojHq5SKo0DCRshFJuoA X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=6pMMVVDDReSiRgPCbMOUauN5nS3ty4Sf5b7a2gi4x0M= Add driver for Maxim 77705 fuel gauge (part of max77705 MFD driver) providing power supply class information to userspace. The driver is configured through DTS (battery and system related settings). Signed-off-by: Dzmitry Sankouski --- drivers/power/supply/Kconfig | 7 + drivers/power/supply/Makefile | 1 + drivers/power/supply/max77705_fuelgauge.c | 624 ++++++++++++++++++++++++++++++ include/linux/power/max77705_fuelgauge.h | 107 +++++ 4 files changed, 739 insertions(+) diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index 47ca8cc00a80..a3fdfcb5aa64 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -558,6 +558,13 @@ config CHARGER_MAX77705 help Say Y to enable support for the Maxim MAX77705 battery charger. +config FUEL_GAUGE_MAX77705 + tristate "MAX77705 fuel gauge driver" + depends on MFD_MAX77705 + default n + help + Say Y to enable support for MAXIM MAX77705 fuel gauge driver. + config CHARGER_MAX77976 tristate "Maxim MAX77976 battery charger driver" depends on I2C diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index dbec648c78c9..e1abad8b6b75 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -78,6 +78,7 @@ obj-$(CONFIG_CHARGER_DETECTOR_MAX14656) += max14656_charger_detector.o obj-$(CONFIG_CHARGER_MAX77650) += max77650-charger.o obj-$(CONFIG_CHARGER_MAX77693) += max77693_charger.o obj-$(CONFIG_CHARGER_MAX77705) += max77705_charger.o +obj-$(CONFIG_FUEL_GAUGE_MAX77705) += max77705_fuelgauge.o obj-$(CONFIG_CHARGER_MAX77976) += max77976_charger.o obj-$(CONFIG_CHARGER_MAX8997) += max8997_charger.o obj-$(CONFIG_CHARGER_MAX8998) += max8998_charger.o diff --git a/drivers/power/supply/max77705_fuelgauge.c b/drivers/power/supply/max77705_fuelgauge.c new file mode 100644 index 000000000000..108a829421d7 --- /dev/null +++ b/drivers/power/supply/max77705_fuelgauge.c @@ -0,0 +1,624 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * max77705_fuelgauge.c + * Samsung max77705 Fuel Gauge Driver + * + * Copyright (C) 2015 Samsung Electronics + * Copyright (C) 2024 Dzmitry Sankouski + */ + +#include +#include +#include +#include +#include +#include +#include + +static const char *max77705_fuelgauge_model = "max77705"; +static const char *max77705_fuelgauge_manufacturer = "Maxim Integrated"; +static struct dentry *debugfs_file; + +static enum power_supply_property max77705_fuelgauge_props[] = { + POWER_SUPPLY_PROP_STATUS, + POWER_SUPPLY_PROP_PRESENT, + POWER_SUPPLY_PROP_VOLTAGE_NOW, + POWER_SUPPLY_PROP_VOLTAGE_OCV, + POWER_SUPPLY_PROP_VOLTAGE_AVG, + POWER_SUPPLY_PROP_CURRENT_NOW, + POWER_SUPPLY_PROP_CURRENT_AVG, + POWER_SUPPLY_PROP_CHARGE_NOW, + POWER_SUPPLY_PROP_CHARGE_FULL, + POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, + POWER_SUPPLY_PROP_CAPACITY, + POWER_SUPPLY_PROP_TEMP, + POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW, + POWER_SUPPLY_PROP_TIME_TO_FULL_NOW, +}; + +static int max77705_fg_read_vcell(struct max77705_fuelgauge_data *fuelgauge) +{ + struct regmap *regmap = fuelgauge->max77705->regmap_fg; + u8 data[2]; + u16 w_data; + + if (regmap_noinc_read(regmap, VCELL_REG, data, sizeof(data)) < 0) { + pr_err("%s: Failed to read VCELL_REG\n", __func__); + return -1; + } + + w_data = (data[1] << 8) | data[0]; + + return max77705_fg_vs_convert(w_data); +} + +static int max77705_fg_read_vfocv(struct max77705_fuelgauge_data *fuelgauge) +{ + struct regmap *regmap = fuelgauge->max77705->regmap_fg; + u8 data[2]; + u16 w_data; + + if (regmap_noinc_read(regmap, VFOCV_REG, data, sizeof(data)) < 0) { + pr_err("%s: Failed to read VFOCV_REG\n", __func__); + return -1; + } + + w_data = (data[1] << 8) | data[0]; + + return max77705_fg_vs_convert(w_data); +} + +static int max77705_fg_read_avg_vcell(struct max77705_fuelgauge_data *fuelgauge) +{ + struct regmap *regmap = fuelgauge->max77705->regmap_fg; + u8 data[2]; + u16 w_data; + + if (regmap_noinc_read(regmap, AVR_VCELL_REG, data, sizeof(data)) < 0) { + pr_err("%s: Failed to read AVR_VCELL_REG\n", __func__); + return -1; + } + + w_data = (data[1] << 8) | data[0]; + return max77705_fg_vs_convert(w_data); +} + +static int max77705_fg_check_battery_present(struct max77705_fuelgauge_data + *fuelgauge) +{ + struct regmap *regmap = fuelgauge->max77705->regmap_fg; + u8 status_data[2]; + + if (regmap_noinc_read(regmap, STATUS_REG, status_data, sizeof(status_data)) < 0) { + dev_err(fuelgauge->dev, "Failed to read STATUS_REG\n"); + return 0; + } + + return !(status_data[0] & MAX77705_BAT_ABSENT_MASK); +} + +static int max77705_fg_read_temp(struct max77705_fuelgauge_data *fuelgauge) +{ + struct regmap *regmap = fuelgauge->max77705->regmap_fg; + u8 data[2] = { 0, 0 }; + int temper = 0; + + if (regmap_noinc_read(regmap, TEMPERATURE_REG, data, sizeof(data)) < 0) { + pr_err("%s: Failed to read TEMPERATURE_REG\n", __func__); + return -1; + } + + if (data[1] & BIT(7)) + temper = ((~(data[1])) & 0xFF) + 1; + else + temper = data[1] & 0x7f; + + temper *= 10; + temper += data[0] * 10 / 256; + + return temper; +} + +static int max77705_fg_read_socrep(struct max77705_fuelgauge_data *fuelgauge) +{ + struct regmap *regmap = fuelgauge->max77705->regmap_fg; + u8 data[2]; + int soc; + + if (regmap_noinc_read(regmap, SOCREP_REG, data, sizeof(data)) < 0) { + pr_err("%s: Failed to read SOCREP_REG\n", __func__); + return -1; + } + + soc = data[1]; + + return min(soc, 100); +} + +static int max77705_fg_read_fullcaprep(struct max77705_fuelgauge_data + *fuelgauge) +{ + struct regmap *regmap = fuelgauge->max77705->regmap_fg; + u8 data[2]; + int ret; + + if (regmap_noinc_read(regmap, FULLCAP_REP_REG, data, sizeof(data)) < 0) { + pr_err("%s: Failed to read FULLCAP_REP_REG\n", __func__); + return -1; + } + + ret = (data[1] << 8) + data[0]; + + return ret * 1000; +} + +static int max77705_fg_read_repcap(struct max77705_fuelgauge_data *fuelgauge) +{ + struct regmap *regmap = fuelgauge->max77705->regmap_fg; + u8 data[2]; + int ret; + + if (regmap_noinc_read(regmap, REMCAP_REP_REG, data, sizeof(data)) < 0) { + pr_err("%s: Failed to read REMCAP_REP_REG\n", __func__); + return -1; + } + + ret = (data[1] << 8) + data[0]; + + return ret * 1000; +} + +static int max77705_fg_read_charge_design(struct max77705_fuelgauge_data + *fuelgauge) +{ + struct regmap *regmap = fuelgauge->max77705->regmap_fg; + u8 data[2]; + int reg; + + if (regmap_noinc_read(regmap, DESIGNCAP_REG, data, sizeof(data)) < 0) { + pr_err("%s: Failed to read DESIGNCAP_REG\n", __func__); + return -1; + } + + reg = (data[1] << 8) | (data[0]); + + return reg * 1000; +} + +static int max77705_fg_set_charge_design(struct regmap *regmap, int value) +{ + u8 data[2]; + int value_mah; + + value_mah = value / 1000; + data[0] = value_mah & 0xFF; + data[1] = (value_mah >> 8) & 0xFF; + + if (regmap_noinc_write(regmap, DESIGNCAP_REG, data, sizeof(data)) < 0) { + pr_err("%s: Failed to write DESIGNCAP_REG\n", __func__); + return -1; + } + + return 0; +} + +static int max77705_fg_read_current(struct max77705_fuelgauge_data *fuelgauge) +{ + struct regmap *regmap = fuelgauge->max77705->regmap_fg; + u8 reg_data[2]; + s16 reg_value; + s32 i_current; + + if (regmap_noinc_read(regmap, CURRENT_REG, reg_data, sizeof(reg_data)) < 0) { + pr_err("%s: Failed to read CURRENT\n", __func__); + return -1; + } + + reg_value = ((reg_data[1] << 8) | reg_data[0]); + i_current = max77705_fg_cs_convert(reg_value, fuelgauge->rsense_conductance); + + return i_current; +} + +static int max77705_fg_read_avg_current(struct max77705_fuelgauge_data *fuelgauge) +{ + struct regmap *regmap = fuelgauge->max77705->regmap_fg; + u8 reg_data[2]; + u32 reg_value; + s32 avg_current; + + if (regmap_noinc_read(regmap, AVG_CURRENT_REG, reg_data, sizeof(reg_data)) < 0) { + pr_err("%s: Failed to read AVG_CURRENT_REG\n", __func__); + return -1; + } + + reg_value = ((reg_data[1] << 8) | reg_data[0]); + avg_current = max77705_fg_cs_convert(reg_value, fuelgauge->rsense_conductance); + + return avg_current; +} + +static int max77705_fg_read_tte(struct max77705_fuelgauge_data *fuelgauge) +{ + struct regmap *regmap = fuelgauge->max77705->regmap_fg; + u8 data[2]; + int reg; + + if (regmap_noinc_read(regmap, TIME_TO_EMPTY_REG, data, sizeof(data)) < 0) { + pr_err("%s: Failed to read TIME_TO_EMPTY_REG\n", __func__); + return -1; + } + + reg = (data[1] << 8) | (data[0]); + + return reg; +} + +static int max77705_fg_read_ttf(struct max77705_fuelgauge_data *fuelgauge) +{ + struct regmap *regmap = fuelgauge->max77705->regmap_fg; + u8 data[2]; + int reg; + + if (regmap_noinc_read(regmap, TIME_TO_FULL_REG, data, sizeof(data)) < 0) { + pr_err("%s: Failed to read TIME_TO_FULL_REG\n", __func__); + return -1; + } + + reg = (data[1] << 8) | (data[0]); + + return reg; +} + +static int max77705_fg_read_cycle(struct max77705_fuelgauge_data *fuelgauge) +{ + struct regmap *regmap = fuelgauge->max77705->regmap_fg; + u8 data[2]; + int ret; + + if (regmap_noinc_read(regmap, CYCLES_REG, data, sizeof(data)) < 0) { + pr_err("%s: Failed to read CYCLES_REG\n", __func__); + return -1; + } + + ret = (data[1] << 8) + data[0]; + + return ret; +} + +static int max77705_battery_get_status(struct max77705_fuelgauge_data *fuelgauge) +{ + int current_now; + int am_i_supplied; + + am_i_supplied = power_supply_am_i_supplied(fuelgauge->psy_fg); + if (am_i_supplied) { + if (am_i_supplied == -ENODEV) + dev_err(fuelgauge->dev, + "power supply not found, fall back to current-based status checking\n"); + else + return POWER_SUPPLY_STATUS_CHARGING; + } + if (max77705_fg_read_socrep(fuelgauge) < 100) { + current_now = max77705_fg_read_current(fuelgauge); + if (current_now > 0) + return POWER_SUPPLY_STATUS_CHARGING; + else if (current_now < 0) + return POWER_SUPPLY_STATUS_DISCHARGING; + else + return POWER_SUPPLY_STATUS_NOT_CHARGING; + } else { + return POWER_SUPPLY_STATUS_FULL; + } + return POWER_SUPPLY_STATUS_DISCHARGING; +} + +static bool max77705_fg_init(struct max77705_fuelgauge_data *fuelgauge) +{ + struct regmap *regmap = fuelgauge->max77705->regmap_fg; + u8 data[2] = { 0, 0 }; + u32 volt_threshold = 0; + u32 temp_threshold = 0; + + if (fuelgauge->auto_discharge_en) { + /* Auto discharge EN & Alert Enable */ + regmap_noinc_read(regmap, CONFIG2_REG, data, sizeof(data)); + data[1] |= MAX77705_AUTO_DISCHARGE_EN_MASK >> 8; + regmap_noinc_write(regmap, CONFIG2_REG, data, sizeof(data)); + + /* Set Auto Discharge temperature & Voltage threshold */ + volt_threshold = + fuelgauge->discharge_volt_threshold < 3900 ? 0x0 : + fuelgauge->discharge_volt_threshold > 4540 ? 0x20 : + (fuelgauge->discharge_volt_threshold - 3900) / 20; + + temp_threshold = + fuelgauge->discharge_temp_threshold < 470 ? 0x0 : + fuelgauge->discharge_temp_threshold > 630 ? 0x20 : + (fuelgauge->discharge_temp_threshold - 470) / 5; + + regmap_noinc_read(regmap, DISCHARGE_THRESHOLD_REG, data, sizeof(data)); + data[1] &= ~MAX77705_AUTO_DISCHARGE_VALUE_MASK; + data[1] |= volt_threshold << MAX77705_AUTO_DISCHARGE_VALUE_SHIFT; + + data[0] &= ~MAX77705_AUTO_DISCHARGE_VALUE_MASK; + data[0] |= temp_threshold << MAX77705_AUTO_DISCHARGE_VALUE_SHIFT; + + regmap_noinc_write(regmap, DISCHARGE_THRESHOLD_REG, data, sizeof(data)); + + pr_info("%s: DISCHARGE_THRESHOLD Value : 0x%x\n", + __func__, (data[1] << 8) | data[0]); + } + + return true; +} + +static int max77705_fg_get_property(struct power_supply *psy, + enum power_supply_property psp, + union power_supply_propval *val) +{ + struct max77705_fuelgauge_data *fuelgauge = + power_supply_get_drvdata(psy); + + switch (psp) { + case POWER_SUPPLY_PROP_STATUS: + val->intval = max77705_battery_get_status(fuelgauge); + break; + case POWER_SUPPLY_PROP_PRESENT: + val->intval = max77705_fg_check_battery_present(fuelgauge); + break; + case POWER_SUPPLY_PROP_VOLTAGE_NOW: + val->intval = max77705_fg_read_vcell(fuelgauge); + break; + case POWER_SUPPLY_PROP_VOLTAGE_OCV: + val->intval = max77705_fg_read_vfocv(fuelgauge); + break; + case POWER_SUPPLY_PROP_VOLTAGE_AVG: + val->intval = max77705_fg_read_avg_vcell(fuelgauge); + break; + case POWER_SUPPLY_PROP_CURRENT_NOW: + val->intval = max77705_fg_read_current(fuelgauge); + break; + case POWER_SUPPLY_PROP_CURRENT_AVG: + val->intval = max77705_fg_read_avg_current(fuelgauge); + break; + case POWER_SUPPLY_PROP_CHARGE_NOW: + val->intval = max77705_fg_read_repcap(fuelgauge); + break; + case POWER_SUPPLY_PROP_CHARGE_FULL: + val->intval = max77705_fg_read_fullcaprep(fuelgauge); + break; + case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: + val->intval = max77705_fg_read_charge_design(fuelgauge); + break; + case POWER_SUPPLY_PROP_CAPACITY: + val->intval = max77705_fg_read_socrep(fuelgauge); + break; + case POWER_SUPPLY_PROP_TEMP: + val->intval = max77705_fg_read_temp(fuelgauge); + break; + case POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW: + val->intval = max77705_fg_read_tte(fuelgauge); + break; + case POWER_SUPPLY_PROP_TIME_TO_FULL_NOW: + val->intval = max77705_fg_read_ttf(fuelgauge); + break; + case POWER_SUPPLY_PROP_CYCLE_COUNT: + val->intval = max77705_fg_read_cycle(fuelgauge); + break; + case POWER_SUPPLY_PROP_MODEL_NAME: + val->strval = max77705_fuelgauge_model; + break; + case POWER_SUPPLY_PROP_MANUFACTURER: + val->strval = max77705_fuelgauge_manufacturer; + break; + default: + return -EINVAL; + } + return 0; +} + +static int max77705_fuelgauge_debugfs_show(struct seq_file *s, void *data) +{ + struct max77705_fuelgauge_data *fuelgauge = s->private; + struct regmap *regmap = fuelgauge->max77705->regmap_fg; + int i; + u16 reg_data; + int regs[] = { 0x00, 0x01, 0x02, 0x03, 0x05, 0x06, 0x08, 0x09, 0x11, 0x13, 0x0A, + 0x0B, 0x0D, 0x0E, 0x0F, 0x10, 0x15, 0x16, 0x17, 0x18, 0x19, 0x20, + 0x1D, 0x1E, 0x1F, 0x23, 0x28, 0x29, 0x2B, 0x32, 0x35, 0x38, 0x3A, + 0x3D, 0x40, 0x42, 0x43, 0x45, 0x46, 0x4B, 0x4D, 0xB1, 0xB2, 0xB3, + 0xBB, 0xD0, 0xEE, 0xFB, 0xFF, }; + + seq_puts(s, "MAX77705 FUELGAUGE IC :\n"); + seq_puts(s, "===================\n"); + for (i = 0; i < ARRAY_SIZE(regs); i++) { + regmap_noinc_read(regmap, regs[i], ®_data, 2); + seq_printf(s, "0x%02x:\t0x%02x\n", regs[i], reg_data); + } + seq_puts(s, "\n"); + return 0; +} + +static int max77705_fuelgauge_debugfs_open(struct inode *inode, + struct file *file) +{ + return single_open(file, max77705_fuelgauge_debugfs_show, inode->i_private); +} + +static const struct file_operations max77705_fuelgauge_debugfs_fops = { + .open = max77705_fuelgauge_debugfs_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static void max77705_battery_settings(struct max77705_fuelgauge_data *fuelgauge) +{ + struct power_supply_battery_info *info; + struct regmap *regmap = fuelgauge->max77705->regmap_fg; + + if (power_supply_get_battery_info(fuelgauge->psy_fg, &info) < 0) + return; + + fuelgauge->bat_info = info; + + if (!regmap) { + dev_warn(fuelgauge->dev, "data memory update not supported for chip\n"); + return; + } + + if (info->energy_full_design_uwh != info->charge_full_design_uah) { + if (info->charge_full_design_uah == -EINVAL) + dev_warn(fuelgauge->dev, "missing battery:charge-full-design-microamp-hours\n"); + max77705_fg_set_charge_design(regmap, info->charge_full_design_uah); + } +} + +static int max77705_fuelgauge_parse_dt(struct max77705_fuelgauge_data + *fuelgauge) +{ + struct device *dev = fuelgauge->dev; + struct device_node *np = dev->of_node; + unsigned int rsense; + + if (!np) { + dev_err(dev, "no fuelgauge OF node\n"); + return -EINVAL; + } + + int ret; + + if (np == NULL) { + pr_err("%s np NULL\n", __func__); + return -EINVAL; + } + + ret = of_property_read_u32(np, "rsense", + &rsense); + if (ret < 0) { + pr_err("%s error reading rsense %d\n", + __func__, ret); + fuelgauge->rsense_conductance = 100; + } else + fuelgauge->rsense_conductance = 1000 / rsense; /* rsense in Ohm^-1 */ + + fuelgauge->auto_discharge_en = of_property_read_bool(np, + "auto_discharge_en"); + if (fuelgauge->auto_discharge_en) { + ret = of_property_read_u32(np, + "discharge_temp_threshold", + &fuelgauge->discharge_temp_threshold); + if (ret < 0) { + dev_err(dev, "error reading rsense_conductance %d\n", ret); + fuelgauge->discharge_temp_threshold = 600; + } + + ret = of_property_read_u32(np, + "discharge_volt_threshold", + &fuelgauge->discharge_volt_threshold); + if (ret < 0) + fuelgauge->discharge_volt_threshold = 4200; + } + + return 0; +} + +static const struct power_supply_desc max77705_fuelgauge_power_supply_desc = { + .name = "max77705-fuelgauge", + .type = POWER_SUPPLY_TYPE_BATTERY, + .properties = max77705_fuelgauge_props, + .num_properties = ARRAY_SIZE(max77705_fuelgauge_props), + .get_property = max77705_fg_get_property, +}; + +static int max77705_fuelgauge_probe(struct platform_device *pdev) +{ + struct max77705_dev *max77705 = dev_get_drvdata(pdev->dev.parent); + struct max77705_platform_data *pdata = dev_get_platdata(max77705->dev); + struct max77705_fuelgauge_data *fuelgauge; + struct power_supply_config fuelgauge_cfg = { }; + int ret = 0; + + fuelgauge = kzalloc(sizeof(*fuelgauge), GFP_KERNEL); + if (!fuelgauge) + return -ENOMEM; + + mutex_init(&fuelgauge->fg_lock); + + fuelgauge->dev = &pdev->dev; + fuelgauge->max77705 = max77705; + fuelgauge->max77705_pdata = pdata; + + ret = max77705_fuelgauge_parse_dt(fuelgauge); + if (ret < 0) + pr_err("%s not found charger dt! ret[%d]\n", __func__, ret); + + platform_set_drvdata(pdev, fuelgauge); + + + debugfs_file = debugfs_create_file("max77705-fuelgauge-regs", + 0664, NULL, (void *)fuelgauge, + &max77705_fuelgauge_debugfs_fops); + if (!debugfs_file) + dev_err(fuelgauge->dev, "Failed to create debugfs file\n"); + + fuelgauge_cfg.drv_data = fuelgauge; + fuelgauge_cfg.of_node = fuelgauge->dev->of_node; + + fuelgauge->psy_fg = + devm_power_supply_register(&pdev->dev, + &max77705_fuelgauge_power_supply_desc, + &fuelgauge_cfg); + + if (IS_ERR(fuelgauge->psy_fg)) { + pr_err("%s: Failed to Register psy_fg\n", __func__); + goto err_data_free; + } + + fuelgauge->fg_irq = max77705->irq_base + MAX77705_FG_IRQ_ALERT; + pr_info("[%s]IRQ_BASE(%d) FG_IRQ(%d)\n", + __func__, max77705->irq_base, fuelgauge->fg_irq); + + if (!max77705_fg_init(fuelgauge)) { + pr_err("%s: Failed to Initialize Fuelgauge\n", __func__); + goto err_supply_unreg; + } + + max77705_battery_settings(fuelgauge); + + return 0; + +err_supply_unreg: + power_supply_unregister(fuelgauge->psy_fg); + kfree(fuelgauge->bat_info); +err_data_free: + mutex_destroy(&fuelgauge->fg_lock); + + return ret; +} + +static void max77705_fuelgauge_remove(struct platform_device *pdev) +{ + if (debugfs_file) + debugfs_remove(debugfs_file); +} +static const struct platform_device_id max77705_fuelgauge_id[] = { + { "max77705-fuelgauge", 0, }, + { } +}; +MODULE_DEVICE_TABLE(platform, max77705_fuelgauge_id); + +static struct platform_driver max77705_fuelgauge_driver = { + .driver = { + .name = "max77705-fuelgauge", + }, + .probe = max77705_fuelgauge_probe, + .remove_new = max77705_fuelgauge_remove, + .id_table = max77705_fuelgauge_id, +}; +module_platform_driver(max77705_fuelgauge_driver); + +MODULE_DESCRIPTION("Samsung max77705 Fuel Gauge Driver"); +MODULE_AUTHOR("Samsung Electronics"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/power/max77705_fuelgauge.h b/include/linux/power/max77705_fuelgauge.h new file mode 100644 index 000000000000..718cd47bc7b6 --- /dev/null +++ b/include/linux/power/max77705_fuelgauge.h @@ -0,0 +1,107 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * max77705_fuelgauge.h + * Samsung max77705 Fuel Gauge Header + * + * Copyright (C) 2015 Samsung Electronics, Inc. + * + * This software is 77854 under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifndef __MAX77705_FUELGAUGE_H +#define __MAX77705_FUELGAUGE_H __FILE__ + +#include +#include +#include +#include + +#define ALERT_EN 0x04 +#define CAPACITY_SCALE_DEFAULT_CURRENT 1000 +#define CAPACITY_SCALE_HV_CURRENT 600 +/* + * Current and capacity values are displayed as a voltage + * and must be divided by the sense resistor to determine Amps or Amp-hours. + * This should be applied to all current, charge, energy registers, + * except ModelGauge m5 Algorithm related ones. + */ +/* current sense resolution */ +#define MAX77705_FG_CS_ADC_RESOLUTION 15625 /* 1.5625 microvolts */ +/* voltage sense resolution */ +#define MAX77705_FG_VS_ADC_RESOLUTION 78125 /* 78.125 microvolts */ +/* CONFIG register */ +#define MAX77705_SOC_ALERT_EN_MASK BIT(2) +/* When set to 1, external temperature measurements should be written from the host */ +#define MAX77705_TEX_MASK BIT(8) +/* Enable Thermistor */ +#define MAX77705_ETHRM_MASK BIT(5) +/* CONFIG2 register */ +#define MAX77705_AUTO_DISCHARGE_EN_MASK BIT(9) +/* DISCHARGE register*/ +#define MAX77705_AUTO_DISCHARGE_VALUE_SHIFT 3 +#define MAX77705_AUTO_DISCHARGE_VALUE_MASK 0xF8 + +#define MAX77705_FG_CS_MASK BIT(15) +/* MISCCFG register */ +#define MAX77705_AUTO_DISCHARGE_VALUE_MASK 0xF8 + +/* adc resolution for voltage sensing is 78.125 microvolts */ +inline u64 max77705_fg_vs_convert(u16 reg_val) +{ + u64 result = (u64)reg_val * MAX77705_FG_VS_ADC_RESOLUTION; + + return result / 1000; +} + +/* adc resolution for current sensing is 1.5625 microvolts */ +inline s32 max77705_fg_cs_convert(s16 reg_val, u32 rsense_conductance) +{ + s64 result = (s64)reg_val * rsense_conductance * MAX77705_FG_CS_ADC_RESOLUTION; + + return result / 10000; +} + +struct max77705_fuelgauge_data { + struct device *dev; + struct i2c_client *i2c; + struct i2c_client *pmic; + struct mutex fuelgauge_mutex; + struct max77705_dev *max77705; + struct max77705_platform_data *max77705_pdata; + struct power_supply *psy_fg; + struct delayed_work isr_work; + + int cable_type; + bool is_charging; + + struct power_supply_battery_info *bat_info; + + struct mutex fg_lock; + + /* register programming */ + int reg_addr; + u8 reg_data[2]; + + unsigned int pre_soc; + int fg_irq; + + int temperature; + int low_temp_limit; + + bool auto_discharge_en; + u32 discharge_temp_threshold; + u32 discharge_volt_threshold; + + u32 rsense_conductance; + u32 fuel_alert_soc; +}; + +#endif /* __MAX77705_FUELGAUGE_H */ From patchwork Tue Jun 18 13:59:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13702409 Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (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 EE5E519E83A; Tue, 18 Jun 2024 14:00:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719228; cv=none; b=YYBmah8+k6SQzVhKBUPu4C/1dXCaTAGesGdePpRtqzRw5hbmVLQoIFNLbUERtnK3tP0RnfcyixIyLyQO/n5q/uwR2QWNcYG4goW0D94lj24SDr1RILls4uFZxRY4KIhHxfw0uXGTbBgcFBlAY3LyY/7kFeLoOf7vJ/n+yw6ZLPQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719228; c=relaxed/simple; bh=pPwrFR5exq+IxTWESOD7VyV5pvbIzgEk0udUDtiXqZg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ViuCkfFBrYH5MUdGzvhKk4OsmhEMZmlAHxprIr/s69wcs+jd7+U/iAY1CHkEoDi+lFcMPrU6PGItHNli6I9fsRUmaj2QIGeh7NLSYol1Iax0RbOdychsBYUOD9pH+1B1CTIKHQHqztaSyQj2otN5dqoQYwVyLQEX41xuQHLvPRI= 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=l+j5v8fD; arc=none smtp.client-ip=209.85.208.53 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="l+j5v8fD" Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-57c714a1e24so6223782a12.2; Tue, 18 Jun 2024 07:00:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719224; x=1719324024; 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=OEluC/nRoMdvS4Ro4zahM5vs8cVpDlDDLc77qRFJKWo=; b=l+j5v8fDhfbzU0aPjhDH2NTYWcoQltn2rQWlPblL3QJgS7BpBxTxJf3Uw/SrSh47BE EnHh9Ev8ZEP3uxUb2TFsGawNvjhdnnAV2WIsvtjyei5dE+kxbEzx0G1Tz+C4cdvjL/yB JjRLY3pCgQyA5y4O3+5y4GgPx6AAXaSHYSMlnB3jhDbpxr64M2iRbovFv8eArjwVwQfc 9QtDr/yNdu8BJKNeIYeN7UyodU/2s1QskFpU/TC4DRXtRtd6mhdzV6byyxOQuv7JXVeW 0HRt5XUnqpQ3KSQ4EntHzJtp6KZhDYVKQbuGgEUm3psA9+gPyzxgobakCvL8OwfefrPh pHIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718719224; x=1719324024; 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=OEluC/nRoMdvS4Ro4zahM5vs8cVpDlDDLc77qRFJKWo=; b=f112oDAsWjuNoKyiFKxEBBSOcGf2s2CHJ2Zg5ueTlgIX3PkeZyhKQOxAcFehVr291u T4hro3iSW9RO9GGDm1HCsHL2Zfa4fndu8w5glXlHHul7jWfmnKKi+6tydX7iCGcVpS+E M3L5QfdL7PRtdh35O+Ft7ZGfS3E5D4CAjcjMRn8r1Ror47wHrq0crNwjYnTAlilruTyt 3rhxpabv0yKWu5f0n7nbr92jXD4sbAo4ohMMXRY1izUEM+8aoDeUg7OS9e9vx4ZSU2bo fJYoEyUapo/zhmk9JQVU5RPJO2eoPajTzr/rOlcwPvvdN4y0ZRPqQrthSd8HOWopaLw5 GoPg== X-Forwarded-Encrypted: i=1; AJvYcCVp3kJMSMImQDvDeKivzGXThjSO1rqT8yPBBVb0ITYe93lKIZzF8dWR35/dUCf3IVClB7YS96AlKYs9vAyRAsU2kHcYZfUVHAnh+JGxlztGss/MacrCqkRSCXW6M++wt1pGlDMCxGJeAuxjfuBzuINgS2wD9o5WRg0HUpyg5FFYiZtoklgYZYZAUg6opsi9cNygxm3UgVRrl60pOJazCUrp8+kzIZI9YEgDVMFSBwfyx1r+HoZfLCjmCOPzVZDZru8Ni4nUlFj9jvV3TSNsd5iJlsBayxEb8ll8OCiWkDydfu4lk2m8QKDeJo9/mocNK6rGYm+2xQvgp142MBAmuceXSOa52D7DYR+76/ZqVCnKG36E98YJN1J6licCxBXJfU9pLBKK5DkqeZVxR1WNJ5G4wlsI9jGk X-Gm-Message-State: AOJu0Yz3/qJNYPSeh1Unux5yUuOz9ZFgiIPJZd5eBMh8G2dEUjWPCXLP CS3C5iGG9CQuBPx/sBLfpkMgsa2Llo7UddYtTusfbylzvBzUd2EE X-Google-Smtp-Source: AGHT+IEXoTD4UVq/0bh14D5fCZNipCHOrom/4r6nnwXy173CyH9/8knLg1HbtmmM6CIGaSTERIqipw== X-Received: by 2002:a50:9b48:0:b0:57c:7676:ea4d with SMTP id 4fb4d7f45d1cf-57cbd682be9mr7568090a12.13.1718719224127; Tue, 18 Jun 2024 07:00:24 -0700 (PDT) Received: from [127.0.1.1] (mm-167-232-122-178.mgts.dynamic.pppoe.byfly.by. [178.122.232.167]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-57cb72da156sm7731278a12.22.2024.06.18.07.00.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 07:00:23 -0700 (PDT) From: Dzmitry Sankouski Date: Tue, 18 Jun 2024 16:59:50 +0300 Subject: [PATCH v3 16/23] leds: max77705: Add LEDs support Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240618-starqltechn_integration_upstream-v3-16-e3f6662017ac@gmail.com> References: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> In-Reply-To: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> To: Sebastian Reichel , Bjorn Andersson , Michael Turquette , Stephen Boyd , Neil Armstrong , Jessica Zhang , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lee Jones , Dmitry Torokhov , Pavel Machek , Liam Girdwood , Mark Brown , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Krzysztof Kozlowski , Konrad Dybcio , Chanwoo Choi , phone-devel@vger.kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, linux-pwm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1718719185; l=6791; i=dsankouski@gmail.com; s=20240618; h=from:subject:message-id; bh=pPwrFR5exq+IxTWESOD7VyV5pvbIzgEk0udUDtiXqZg=; b=L9i9P5Ho7DBA/hISx6SLpWJuEv3//Q9yHsSr3YHDDzpUOQotvp/jufa3+eEe2F3R7zNpjo4ID wvCHTWg9mzSDgKnrLjvEgBpfMTFTttsEnSsmZzX1v9P8ucbLM/kivkc X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=6pMMVVDDReSiRgPCbMOUauN5nS3ty4Sf5b7a2gi4x0M= This adds basic support for LEDs for the max77705 PMIC. Signed-off-by: Dzmitry Sankouski --- MAINTAINERS | 1 + drivers/leds/Kconfig | 6 ++ drivers/leds/Makefile | 1 + drivers/leds/leds-max77705.c | 166 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 174 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index f66f08825db9..f3c245d432d9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -13691,6 +13691,7 @@ F: drivers/*/max14577*.c F: drivers/*/max77686*.c F: drivers/*/max77693*.c F: drivers/*/max77705*.c +F: drivers/leds/leds-max77705.c F: drivers/clk/clk-max77686.c F: drivers/extcon/extcon-max14577.c F: drivers/extcon/extcon-max77693.c diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 05e6af88b88c..14d483011308 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -728,6 +728,12 @@ config LEDS_MAX77650 help LEDs driver for MAX77650 family of PMICs from Maxim Integrated. +config LEDS_MAX77705 + tristate "LED support for Maxim MAX77705 RGB" + depends on MFD_MAX77705 && LEDS_CLASS && I2C + help + LED driver for MAX77705 MFD chip from Maxim Integrated. + config LEDS_MAX8997 tristate "LED support for MAX8997 PMIC" depends on LEDS_CLASS && MFD_MAX8997 diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index effdfc6f1e95..be064e3d678e 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -58,6 +58,7 @@ obj-$(CONFIG_LEDS_LP8860) += leds-lp8860.o obj-$(CONFIG_LEDS_LT3593) += leds-lt3593.o obj-$(CONFIG_LEDS_MAX5970) += leds-max5970.o obj-$(CONFIG_LEDS_MAX77650) += leds-max77650.o +obj-$(CONFIG_LEDS_MAX77705) += leds-max77705.o obj-$(CONFIG_LEDS_MAX8997) += leds-max8997.o obj-$(CONFIG_LEDS_MC13783) += leds-mc13783.o obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.o diff --git a/drivers/leds/leds-max77705.c b/drivers/leds/leds-max77705.c new file mode 100644 index 000000000000..f91c0e41056c --- /dev/null +++ b/drivers/leds/leds-max77705.c @@ -0,0 +1,166 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Based on leds-max77650 driver: + * Copyright (C) 2018 BayLibre SAS + * Author: Bartosz Golaszewski + * + * LED driver for MAXIM 77705 MFD. + * Copyright (C) 2024 Dzmitry Sankouski + */ + +#include +#include +#include +#include +#include +#include +#include + +#define MAX77705_LED_NUM_LEDS 4 +#define MAX77705_LED_EN_MASK GENMASK(1, 0) +#define MAX77705_LED_MAX_BRIGHTNESS 0xff + +#define LEDBLNK_ON(time) ((time < 100) ? 0 : \ + (time < 500) ? time/100-1 : \ + (time < 3250) ? (time-500)/250+4 : 15) + +#define LEDBLNK_OFF(time) ((time < 1) ? 0x00 : \ + (time < 500) ? 0x01 : \ + (time < 5000) ? time/500 : \ + (time < 8000) ? (time-5000)/1000+10 : \ + (time < 12000) ? (time-8000)/2000+13 : 15) + +struct max77705_led { + struct led_classdev cdev; + struct regmap *regmap; + unsigned int en_shift; + unsigned int reg_brightness; + unsigned int regB; +}; + +static struct max77705_led *max77705_to_led(struct led_classdev *cdev) +{ + return container_of(cdev, struct max77705_led, cdev); +} + +static int max77705_rgb_blink(struct led_classdev *cdev, + unsigned long *delay_on, + unsigned long *delay_off) +{ + struct max77705_led *led = max77705_to_led(cdev); + int value; + + value = (LEDBLNK_ON(*delay_on) << 4) | LEDBLNK_OFF(*delay_off); + return regmap_write(led->regmap, MAX77705_RGBLED_REG_LEDBLNK, value); +} + +static int max77705_led_brightness_set(struct led_classdev *cdev, + enum led_brightness brightness) +{ + struct max77705_led *led = max77705_to_led(cdev); + int ret; + unsigned long blink_default = 0; + + if (brightness == LED_OFF) { + /* Flash OFF */ + ret = regmap_update_bits(led->regmap, + MAX77705_RGBLED_REG_LEDEN, + MAX77705_LED_EN_MASK << led->en_shift, 0); + max77705_rgb_blink(cdev, &blink_default, &blink_default); + } else { + /* Set current */ + ret = regmap_write(led->regmap, + led->reg_brightness, brightness); + if (ret < 0) + return ret; + + ret = regmap_update_bits(led->regmap, + MAX77705_RGBLED_REG_LEDEN, LED_ON << led->en_shift, + MAX77705_LED_EN_MASK << led->en_shift); + } + + return ret; +} + +static int max77705_led_probe(struct platform_device *pdev) +{ + struct fwnode_handle *child; + struct max77705_led *leds, *led; + struct device *dev; + struct regmap *map; + int rv, num_leds; + u32 reg; + + dev = &pdev->dev; + + leds = devm_kcalloc(dev, sizeof(*leds), + MAX77705_LED_NUM_LEDS, GFP_KERNEL); + if (!leds) + return -ENOMEM; + + map = dev_get_regmap(dev->parent, NULL); + if (!map) + return -ENODEV; + + num_leds = device_get_child_node_count(dev); + if (!num_leds || num_leds > MAX77705_LED_NUM_LEDS) + return -ENODEV; + + device_for_each_child_node(dev, child) { + struct led_init_data init_data = {}; + + rv = fwnode_property_read_u32(child, "reg", ®); + if (rv || reg >= MAX77705_LED_NUM_LEDS) { + rv = -EINVAL; + goto err_node_put; + } + + led = &leds[reg]; + led->regmap = map; + led->reg_brightness = MAX77705_RGBLED_REG_LED0BRT + reg; + led->en_shift = 2 * reg; + led->cdev.brightness_set_blocking = max77705_led_brightness_set; + led->cdev.blink_set = max77705_rgb_blink; + led->cdev.max_brightness = MAX77705_LED_MAX_BRIGHTNESS; + + init_data.fwnode = child; + init_data.devicename = "max77705"; + /* for backwards compatibility if `label` is not present */ + init_data.default_label = ":"; + + rv = devm_led_classdev_register_ext(dev, &led->cdev, + &init_data); + if (rv) + goto err_node_put; + + rv = max77705_led_brightness_set(&led->cdev, LED_OFF); + if (rv) + goto err_node_put; + } + + return 0; +err_node_put: + fwnode_handle_put(child); + return rv; +} + +static const struct of_device_id max77705_led_of_match[] = { + { .compatible = "maxim,max77705-led" }, + { } +}; +MODULE_DEVICE_TABLE(of, max77705_led_of_match); + +static struct platform_driver max77705_led_driver = { + .driver = { + .name = "max77705-led", + .of_match_table = max77705_led_of_match, + }, + .probe = max77705_led_probe, +}; +module_platform_driver(max77705_led_driver); + +MODULE_DESCRIPTION("MAXIM 77705 LED driver"); +MODULE_AUTHOR("Bartosz Golaszewski "); +MODULE_AUTHOR("Dzmitry Sankouski "); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:max77705-led"); From patchwork Tue Jun 18 13:59:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13702410 Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) (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 634C119F481; Tue, 18 Jun 2024 14:00:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719230; cv=none; b=LcIkCNRNd76CbUF70hzUM8odfWr7t11UUHg0fk2oEGTD1ZsMDxO8FBM1WaxoalFpo6PhKKEawNMWg2kPwR4zegemjm1CqXXhROSnYNarl/lhibDASY8LmI+E6lzMqnEAVUSvpjyjPCcIAeQVLWsKt0Z1JLZdzrMKlcSgNX9RKyk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719230; c=relaxed/simple; bh=IHZAr5+Cdn0wmqhOZ2PeM9l2Gdz/tWq1OFfADxf5XIQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gmrlZ8lp74xDEcU2MSdycnbtdMjIVtoyIAVk9IWsMxzvrbI8Lx2b9WfBCtlLkB7MDTwyxs7kCLQ4Ln2QwCUDQNWWzH/gMTf++PLBXTWHPwB4eNLnT0eqc1BNFvHpu5663BFdyAaOiPJ7AMESifYSDexj7jhfRfMueAvTBH05cgo= 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=lRmTYiqe; arc=none smtp.client-ip=209.85.208.49 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="lRmTYiqe" Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-57d046f4afdso268519a12.1; Tue, 18 Jun 2024 07:00:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719227; x=1719324027; 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=lVpSUbQ0RxUxTD6Qqs+KFz8X9qCBPybUa3iBtTp8xZM=; b=lRmTYiqet/n1S42Ij86i6/mKITc/Imt1qa53nFDawxVKRJ816hLtRJklA2XIpSXIfb DC49NQekC1RROEHKXg68LwOS1b1+tqrwQgGjH4Vrpy5Ano2F9vCXF8dJiBIez7RSzUBv Y5SgR7pa/gB3eLDRm1bPItyFIlfDR7rgzWaaqaQtIzztHRhFZ/3t9f2fvb6HQ34qjygU 4hZ7ADKmm/4+nYWKTkHcMjr2MHybBem5EEZqau3gxJq2ocmtBfmQXicl3udNmUGpiTpv WFhtfYkTwMo9L9snTzCTRpfjGb/lXaT7kpqWwIQzeVqei/eKPWwjPszGSEMAd91RGa2u B6Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718719227; x=1719324027; 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=lVpSUbQ0RxUxTD6Qqs+KFz8X9qCBPybUa3iBtTp8xZM=; b=F8GD1Bh3NCRgE837DsrVjgqCFFA+ZxCm9NgePdBy9jhCPKVXyVX8P1ByKxdHR3qlJe bb6f2zzjCWkdmIDgm3S+u5fgxm7HPrRF0hRi1PK89z2HM7roxH2TRInxvokBLDVoXFhU yuGVu7Vu+3XA/K+RTwRZRUsfiPIIDqFEKjUiYrRZxbBYp4BhlZIPY/F7p5JHOMu7fKy4 XWdRq1FHPUUzMpoajn7eHxh4VtNe1Nh4eY7IJp+JblXtqqaF+SKjhw53xEVX8HIcVR4S oNTyTl0YhtBfqYNd+PYow0k7LFnwrM6cCH9VqxGviYEh8q3NnAI8kuBZG0ZZDIj+dugY 2RFQ== X-Forwarded-Encrypted: i=1; AJvYcCXuqk9s42snKqAdQttXyUbGb0PYEL3PmCfhbdrU1xRo4P+BTo/HFj/C0DSRdNeigtoNnwGossdZlrpCLgOaHQw/X7TTSq9DNveNKxUsbWBHQU3jLhONeDExDDWHwq8b8GbnqUcojHGszH0WpySywWhxzTSWwjqpGQ70ZZqmDBl2vxKvZtu6FaYpSnuF6K1DLp11M6NG8yUUK1NGnJFh8cn2mtQl/c/MF/c200PMv151iBoxBO6Ery4ZYYjnih7DXHiWNvBMu9QOADOXWO02GXYBR1zc7Rn7YqQiFkSGdJOoXFM/ybYPMTCjacluKeL5PwL3Uan1d0VsrDCEsL60KjoWY0SVanY57um9ZFtvqeo2G62d3Dq05hC4JBGq8kBZY7xuRnC1JOdB6NXcGTZq7FSa7YpVFg5b X-Gm-Message-State: AOJu0Yw1RjUnw6IeSj8Bc/d/HdWjtRC33Deyco7FsZbq4SyqCeovVlar h0LL5slC21BAOYM+p+hEr1zyVxoSGddGXUyHjWFi8pR322NV1NAf X-Google-Smtp-Source: AGHT+IHe/0ra3yC6deGQmpMua4UTqdcMRRszmsFv8+QoEjoDXgFjZqQesDDjmgynaNQbxBP6akhjMw== X-Received: by 2002:aa7:ce04:0:b0:57d:3cf:899d with SMTP id 4fb4d7f45d1cf-57d03cf8aa2mr974692a12.22.1718719226445; Tue, 18 Jun 2024 07:00:26 -0700 (PDT) Received: from [127.0.1.1] (mm-167-232-122-178.mgts.dynamic.pppoe.byfly.by. [178.122.232.167]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-57cb72da156sm7731278a12.22.2024.06.18.07.00.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 07:00:26 -0700 (PDT) From: Dzmitry Sankouski Date: Tue, 18 Jun 2024 16:59:51 +0300 Subject: [PATCH v3 17/23] mfd: add s2dos series core driver Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240618-starqltechn_integration_upstream-v3-17-e3f6662017ac@gmail.com> References: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> In-Reply-To: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> To: Sebastian Reichel , Bjorn Andersson , Michael Turquette , Stephen Boyd , Neil Armstrong , Jessica Zhang , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lee Jones , Dmitry Torokhov , Pavel Machek , Liam Girdwood , Mark Brown , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Krzysztof Kozlowski , Konrad Dybcio , Chanwoo Choi , phone-devel@vger.kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, linux-pwm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1718719185; l=10509; i=dsankouski@gmail.com; s=20240618; h=from:subject:message-id; bh=IHZAr5+Cdn0wmqhOZ2PeM9l2Gdz/tWq1OFfADxf5XIQ=; b=l66fMD8sHB8UJYTpLpJ1ay3lJvzfpqGlDq6nPosqrMEDYoFHMPD/dy7mDaSAk2An0pOO6QxUi qEyrqTzd98iCKNsZDfsTPkuE8JTVRSRulb9nsxxFrfA4H6vj652yV10 X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=6pMMVVDDReSiRgPCbMOUauN5nS3ty4Sf5b7a2gi4x0M= S2DOS05 is a panel/touchscreen PMIC, often found in Samsung phones. We define 2 sub-devices for which drivers will be added in subsequent patches. Signed-off-by: Dzmitry Sankouski --- MAINTAINERS | 1 + drivers/mfd/Kconfig | 13 +++ drivers/mfd/Makefile | 2 +- drivers/mfd/s2dos-core.c | 141 +++++++++++++++++++++++++++++++++ include/linux/mfd/samsung/s2dos-core.h | 21 +++++ include/linux/mfd/samsung/s2dos05.h | 115 +++++++++++++++++++++++++++ 6 files changed, 292 insertions(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index f3c245d432d9..b53462684a30 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19908,6 +19908,7 @@ F: Documentation/devicetree/bindings/regulator/samsung,s2dos*.yaml 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/s2dos*.c F: drivers/mfd/sec*.c F: drivers/regulator/s2m*.c F: drivers/regulator/s5m*.c diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index c4eb8ff2dcad..517d8778d7a8 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -1278,6 +1278,19 @@ config MFD_RN5T618 additional drivers must be enabled in order to use the functionality of the device. +config MFD_S2DOS_CORE + tristate "Samsung Electronics PMIC Series Support" + depends on I2C=y + depends on OF + select MFD_CORE + select REGMAP_I2C + help + Support for the Samsung Electronics PMIC devices + usually used to power displays. + This driver provides common support for accessing the device, + additional drivers must be enabled in order to use the functionality + of the device. + config MFD_SEC_CORE tristate "Samsung Electronics PMIC Series Support" depends on I2C=y diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index bf65cc36d59c..37c51aab0205 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -228,7 +228,7 @@ obj-$(CONFIG_MFD_RK8XX_I2C) += rk8xx-i2c.o obj-$(CONFIG_MFD_RK8XX_SPI) += rk8xx-spi.o obj-$(CONFIG_MFD_RN5T618) += rn5t618.o obj-$(CONFIG_MFD_SEC_CORE) += sec-core.o sec-irq.o -obj-$(CONFIG_MFD_S2DOS05) += s2dos05.o +obj-$(CONFIG_MFD_S2DOS_CORE) += s2dos-core.o obj-$(CONFIG_MFD_SYSCON) += syscon.o obj-$(CONFIG_MFD_LM3533) += lm3533-core.o lm3533-ctrlbank.o obj-$(CONFIG_MFD_VEXPRESS_SYSREG) += vexpress-sysreg.o diff --git a/drivers/mfd/s2dos-core.c b/drivers/mfd/s2dos-core.c new file mode 100644 index 000000000000..a04363b15a2a --- /dev/null +++ b/drivers/mfd/s2dos-core.c @@ -0,0 +1,141 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * s2dos05.c - mfd core driver for the s2dos05 chip + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Copyright (C) 2024 Dzmitry Sankouski + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static struct dentry *debugfs_file; + +static int s2dos05_debugfs_show(struct seq_file *s, void *data) +{ + struct s2dos_core *s2dos05 = s->private; + struct regmap *regmap = s2dos05->regmap; + unsigned int i, reg, reg_data, pmic_id; + int regs[] = { + 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, + S2DOS05_REG_SSD_TSD, + S2DOS05_REG_OCL, + S2DOS05_REG_IRQ + }; + regmap_read(regmap, S2DOS05_REG_DEV_ID, &pmic_id); + seq_printf(s, "S2DOS05, id: %d\n", pmic_id); + seq_puts(s, "===================\n"); + for (i = 0; i < ARRAY_SIZE(regs); i++) { + reg = regs[i]; + regmap_read(regmap, reg, ®_data); + seq_printf(s, "0x%02x:\t0x%02x\n", reg, reg_data); + } + + seq_puts(s, "\n"); + return 0; +} + +DEFINE_SHOW_ATTRIBUTE(s2dos05_debugfs); + +static const struct regmap_config s2dos05_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .max_register = S2DOS05_REG_IRQ, +}; + +static struct mfd_cell s2dos05_devs[] = { + { .name = "s2dos05-fg" }, + { + .name = "s2dos05-regulator", + .of_compatible = "samsung,s2dos05-regulator", + }, +}; + + +static int s2dos05_i2c_probe(struct i2c_client *i2c) +{ + struct s2dos_core *s2dos05; + struct regmap *regmap; + struct device *dev = &i2c->dev; + + unsigned int reg_data; + int ret = 0; + + s2dos05 = kzalloc(sizeof(struct s2dos_core), GFP_KERNEL); + if (!s2dos05) + return -ENOMEM; + + regmap = devm_regmap_init_i2c(i2c, &s2dos05_regmap_config); + if (IS_ERR(regmap)) { + dev_err(dev, "Unable to initialise I2C Regmap\n"); + return PTR_ERR(regmap); + } + s2dos05->regmap = regmap; + + if (regmap_read(regmap, S2DOS05_REG_DEV_ID, ®_data) < 0) { + dev_err(dev, + "device not found on this channel (this is not an error)\n"); + ret = -ENODEV; + } else { + dev_info(dev, "%s device found with id: .0x%x\n", + __func__, reg_data); + } + + i2c_set_clientdata(i2c, s2dos05); + + debugfs_file = debugfs_create_file("s2dos05-regs", + 0664, NULL, (void *)s2dos05, + &s2dos05_debugfs_fops); + if (!debugfs_file) + dev_err(dev, "Failed to create debugfs file\n"); + + return mfd_add_devices(dev, -1, s2dos05_devs, + ARRAY_SIZE(s2dos05_devs), NULL, 0, NULL); +} + +static const struct of_device_id s2dos05_i2c_dt_ids[] = { + { .compatible = "samsung,s2dos05-pmic" }, + { }, +}; +MODULE_DEVICE_TABLE(of, s2dos05_i2c_dt_ids); + +static struct i2c_driver s2dos05_i2c_driver = { + .driver = { + .name = "s2dos-core", + .owner = THIS_MODULE, + .of_match_table = s2dos05_i2c_dt_ids, + }, + .probe = s2dos05_i2c_probe, +}; + +module_i2c_driver(s2dos05_i2c_driver); + +MODULE_DESCRIPTION("s2dos core driver"); +MODULE_AUTHOR("Dzmitry Sankouski "); +MODULE_LICENSE("GPL"); diff --git a/include/linux/mfd/samsung/s2dos-core.h b/include/linux/mfd/samsung/s2dos-core.h new file mode 100644 index 000000000000..7e84b387063c --- /dev/null +++ b/include/linux/mfd/samsung/s2dos-core.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * s2dos-core.h + * + * Copyright (c) 2016 Samsung Electronics Co., Ltd + * http://www.samsung.com + * Copyright (C) 2024 Dzmitry Sankouski + * + */ + +#ifndef __LINUX_MFD_S2DOS_CORE_H +#define __LINUX_MFD_S2DOS_CORE_H +#include +#include + +struct s2dos_core { + struct device *dev; + struct regmap *regmap; +}; + +#endif /* __LINUX_MFD_S2DOS_CORE_H */ diff --git a/include/linux/mfd/samsung/s2dos05.h b/include/linux/mfd/samsung/s2dos05.h new file mode 100644 index 000000000000..0317dbe56f10 --- /dev/null +++ b/include/linux/mfd/samsung/s2dos05.h @@ -0,0 +1,115 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * s2dos05.h + * + * Copyright (c) 2016 Samsung Electronics Co., Ltd + * http://www.samsung.com + * + */ + +#ifndef __LINUX_MFD_S2DOS05_H +#define __LINUX_MFD_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 BIT(7) +#define S2DOS05_BUCK_VSEL_MASK 0xFF +#define S2DOS05_BUCK_FD_MASK BIT(3) + +#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_ENABLE_SHIFT 0x06 +#define S2DOS05_LDO_N_VOLTAGES (S2DOS05_LDO_VSEL_MASK + 1) +#define S2DOS05_BUCK_N_VOLTAGES (S2DOS05_BUCK_VSEL_MASK + 1) + +#define S2DOS05_PMIC_EN_SHIFT 6 +#define S2DOS05_REGULATOR_MAX (S2DOS05_REG_MAX) + +/* ----------power meter ----------*/ +#define S2DOS05_REG_PWRMT_CTRL1 0x0A +#define S2DOS05_REG_PWRMT_CTRL2 0x0B +#define S2DOS05_REG_PWRMT_DATA 0x0C +#define S2DOS05_REG_IRQ_MASK 0x0D + +#define CHANNEL_ELVDD 0 +#define CHANNEL_ELVSS 1 +#define CHANNEL_AVDD 2 +#define CHANNEL_BUCK 3 +#define CHANNEL_L1 4 +#define CHANNEL_L2 5 +#define CHANNEL_L3 6 +#define CHANNEL_L4 7 + +#define POWER_ELVDD 24500 +#define POWER_ELVSS 24500 +#define POWER_AVDD 3060 +#define POWER_BUCK 1525 +#define POWER_L1 5000 +#define POWER_L2 5000 +#define POWER_L3 5000 +#define POWER_L4 5000 + +/* S2DOS05_REG_OCL */ +#define ADC_VALID_MASK BIT(7) +/* S2DOS05_REG_PWRMT_CTRL1 */ +#define ADC_ASYNCRD_MASK BIT(7) +#define PWRMT_EN_CHK BIT(6) +#define SMPNUM_MASK 0x0F +/* S2DOS05_REG_PWRMT_CTRL2 */ +#define ADC_EN_MASK BIT(7) +#define ADC_PTR_MASK 0x0F +#define POWER_MODE BIT(4) +#define RAWCURRENT_MODE BIT(5) + +#define S2DOS05_MAX_ADC_CHANNEL 8 + +#endif /* __LINUX_MFD_S2DOS05_H */ From patchwork Tue Jun 18 13:59:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13702411 Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.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 B24A119F49B; Tue, 18 Jun 2024 14:00:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719233; cv=none; b=m1HRABoS7+dd3egzSzxaqxFL7UjKE6Bb2Aj4pQbVdhXZEFtrmL+zBKFPlHJQBR1QdN+MqeST3VvOCqZBruqtUGYzqjqSfwX/qEqAnnR7o0HTdv50yAMTsEN5Avtv8ICVnwHy0TDPPe3uvT8iy9sACCd6QWKVwI5eK63C0Swo7bU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719233; c=relaxed/simple; bh=uZejq3wX3OBYE+9S5+uNP8az/DWpQYHhHiLxkXJUgAg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tZXDZ2IZvPgM63KmmMxWBbDusVUMr4ljEc8+Ypm/lzpnK3zGM0a+tzI1y17AhsoGukUUqrGP8W4rqrjUvwoVUO9cbMRX1g6BsFKtMhRorh6lyYmpd1JkhgdYWUfGKAHQjQhTBkm7HudoCPl8pG2ZSZT4VBipEO7Mx5bhXkdbleA= 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=WkJIOb1o; arc=none smtp.client-ip=209.85.208.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="WkJIOb1o" Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-57cce3bc8c6so3823782a12.3; Tue, 18 Jun 2024 07:00:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719229; x=1719324029; 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=eJjzPFzeK4OTnNmyhk2Z69T0Mv/GEdnDyv14Qjd1AMA=; b=WkJIOb1o1+ffYugCAnkSw9Zr134fhg9M3VdiZAefDntFXJNNKnMR0x0OA5qimNCetA aiIG/Lf9z4gieMsu2smeiYhcsbkHMrv1I2grUjJ7ykBHMeZn9d6hPu894Hi/OOmdxRxy SnOy0kzjWlPNX8LAMOIZQa7fvXHudNR2oOz3lfIgv+E/KqTHvKR2Jzb3oRo+HFj4QCqE kDGuHWA4yEud/gCfjg+i2yOw0Y3ooLDOGGJvR7GGghHLgPqxqvCnxcZNAEeEruZOpHBw bty3TgmNdBp5b3B0ElqZh7tTIlDjIzVnIy+rgKUBHhWZ8ScF2Ow+NQpEtrOl3BdtaNBK 2DLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718719229; x=1719324029; 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=eJjzPFzeK4OTnNmyhk2Z69T0Mv/GEdnDyv14Qjd1AMA=; b=P8jiVXsOMmHQr1F/HfN0RL9waM45wRiN48GJ+97XpjWwb97Yu5DBx8fY0jAmTQdo/5 E4Gs6653SD3yMoOVqGGt2nOOfh3jAk+hTVP8JQE4LVTnz9Idun8HBW5DpcGwqStBV9L/ 579UqO70taz+4IIJ9RbdV65hciQWlmRDqDVn1ZPCnkhfnEL8ij5T4tfQVgsjo8yixpLd W1s2zn7ENUXaxobPLeEkp+bxYobvJCDAwlfJBriVrAn5/hRg/Z6+6AtDWzc3HdgOKVKk R/Y1O09IHprytMAHZbG3hqXMrLZpFcUaMAbZdN1RSWIePUFnTh8NX8LbHP1c15MgtNl8 q0VQ== X-Forwarded-Encrypted: i=1; AJvYcCVsMs1TT+C+Daq4euQXqZdmvnSSw0QapT7I0PEKYa3VVFXjKK7Ymva22LODIrRtLTF9no54bwLYrfMH0YT8/ekjwXSZeNS3QQMLVhqaL7u7gpVMzxS++KuCXiTC4wWHwXxbDzTHUuRTgba4mAdtoBELdyMO8B9CYrcUBS3OzjTtdYFjB9adssGDw6sErzpYUUhh8W33iWlKDApA3LfOfxG0FlmDP4sY5ZRcDz6kiW59C2I0olQ4mh2pC+2t2I+BqNSFmI9VIe/9xjm+1AVulOSvX6YmntMh+YxIGAXVuCFsu9a5X7Ycowd29ExuCJb12+IdNs/KAt3/Jn7aU5u0mlN5M5WhN3yaq0zPis2SmyPkTYwDxMsaZsUUq3h2eWHGcJBKwfS9okQWEDrLtI+n28Wwssjt+hKD X-Gm-Message-State: AOJu0YysE39hlYE31kT2HXWP/6gbQD9kJvkaosnA1utWHv5q48zU+wR1 uOJHSRrKHBgAC4npPabXdItRjnGSPeVgbVAx+1oNq0pNroVBqeFy X-Google-Smtp-Source: AGHT+IF4ZzHLI9V3+LTX7+JTibxZTfVLCoXIxk/IYmJanCqg5Sh7sZ08YDb/9Oipl6vdG3BZDB9ekA== X-Received: by 2002:a50:ab4a:0:b0:578:6c19:4801 with SMTP id 4fb4d7f45d1cf-57cbd6a70e9mr8232702a12.22.1718719228794; Tue, 18 Jun 2024 07:00:28 -0700 (PDT) Received: from [127.0.1.1] (mm-167-232-122-178.mgts.dynamic.pppoe.byfly.by. [178.122.232.167]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-57cb72da156sm7731278a12.22.2024.06.18.07.00.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 07:00:28 -0700 (PDT) From: Dzmitry Sankouski Date: Tue, 18 Jun 2024 16:59:52 +0300 Subject: [PATCH v3 18/23] 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: <20240618-starqltechn_integration_upstream-v3-18-e3f6662017ac@gmail.com> References: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> In-Reply-To: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> To: Sebastian Reichel , Bjorn Andersson , Michael Turquette , Stephen Boyd , Neil Armstrong , Jessica Zhang , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lee Jones , Dmitry Torokhov , Pavel Machek , Liam Girdwood , Mark Brown , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Krzysztof Kozlowski , Konrad Dybcio , Chanwoo Choi , phone-devel@vger.kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, linux-pwm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1718719185; l=12895; i=dsankouski@gmail.com; s=20240618; h=from:subject:message-id; bh=uZejq3wX3OBYE+9S5+uNP8az/DWpQYHhHiLxkXJUgAg=; b=5XtWTi2CQq9/wixtulx+pvi4NO3P+hcgPgRzF8p95jBWt9lMboWJtUeAdy8U69KlHIY638Q7u vUZauNkhQbHBrjHjjmEPIjCHoFB1/7esgo0w4z1F6LxEg9G5mvxG1nM X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=6pMMVVDDReSiRgPCbMOUauN5nS3ty4Sf5b7a2gi4x0M= S2dos05 has 1 buck and 4 LDO regulators, used for powering panel/touchscreen. Signed-off-by: Dzmitry Sankouski --- MAINTAINERS | 1 + drivers/regulator/Kconfig | 8 + drivers/regulator/Makefile | 1 + drivers/regulator/s2dos05-regulator.c | 362 ++++++++++++++++++++++++++++++++++ 4 files changed, 372 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index b53462684a30..bee700a5e648 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19910,6 +19910,7 @@ F: Documentation/devicetree/bindings/regulator/samsung,s5m*.yaml F: drivers/clk/clk-s2mps11.c F: drivers/mfd/s2dos*.c F: drivers/mfd/sec*.c +F: drivers/regulator/s2dos*.c F: drivers/regulator/s2m*.c F: drivers/regulator/s5m*.c F: drivers/rtc/rtc-s5m.c diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index d333be2bea3b..d6d6f571a65d 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -1297,6 +1297,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 "SLSI S2DOS05 regulator" + depends on MFD_S2DOS_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 ba15fa5f30ad..80f889404597 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -151,6 +151,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..3c58a1bd2262 --- /dev/null +++ b/drivers/regulator/s2dos05-regulator.c @@ -0,0 +1,362 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * s2dos05.c - Regulator driver for the Samsung s2dos05 + * + * Copyright (C) 2016 Samsung Electronics + * Copyright (C) 2023 Dzmitry Sankouski + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct s2dos05_data { + struct regmap *regmap; + struct device *dev; +}; + +static int s2m_enable(struct regulator_dev *rdev) +{ + struct s2dos05_data *info = rdev_get_drvdata(rdev); + struct regmap *regmap = info->regmap; + + return regmap_update_bits(regmap, rdev->desc->enable_reg, + rdev->desc->enable_mask, + rdev->desc->enable_mask); +} + +static int s2m_disable_regmap(struct regulator_dev *rdev) +{ + struct s2dos05_data *info = rdev_get_drvdata(rdev); + struct regmap *regmap = info->regmap; + u8 val; + + if (rdev->desc->enable_is_inverted) + val = rdev->desc->enable_mask; + else + val = 0; + + return regmap_update_bits(regmap, rdev->desc->enable_reg, rdev->desc->enable_mask, + val); +} + +static int s2m_is_enabled_regmap(struct regulator_dev *rdev) +{ + struct s2dos05_data *info = rdev_get_drvdata(rdev); + struct regmap *regmap = info->regmap; + int ret; + unsigned int val; + + ret = regmap_read(regmap, rdev->desc->enable_reg, &val); + if (ret < 0) + return ret; + + if (rdev->desc->enable_is_inverted) + return (val & rdev->desc->enable_mask) == 0; + else + return (val & rdev->desc->enable_mask) != 0; +} + +static int s2m_get_voltage_sel_regmap(struct regulator_dev *rdev) +{ + struct s2dos05_data *info = rdev_get_drvdata(rdev); + struct regmap *regmap = info->regmap; + int ret; + unsigned int val; + + ret = regmap_read(regmap, rdev->desc->vsel_reg, &val); + if (ret < 0) + return ret; + + val &= rdev->desc->vsel_mask; + + return val; +} + +static int s2m_set_voltage_sel_regmap(struct regulator_dev *rdev, + unsigned int sel) +{ + struct s2dos05_data *info = rdev_get_drvdata(rdev); + struct regmap *regmap = info->regmap; + int ret; + + ret = regmap_update_bits(regmap, rdev->desc->vsel_reg, rdev->desc->vsel_mask, + sel); + if (ret < 0) + goto out; + + if (rdev->desc->apply_bit) + ret = regmap_update_bits(regmap, rdev->desc->apply_reg, + rdev->desc->apply_bit, + rdev->desc->apply_bit); + return ret; +out: + pr_warn("%s: failed to set voltage_sel_regmap\n", rdev->desc->name); + return ret; +} + +static int s2m_set_voltage_sel_regmap_buck(struct regulator_dev *rdev, + unsigned int sel) +{ + struct s2dos05_data *info = rdev_get_drvdata(rdev); + struct regmap *regmap = info->regmap; + int ret; + + ret = regmap_write(regmap, rdev->desc->vsel_reg, sel); + if (ret < 0) + goto out; + + if (rdev->desc->apply_bit) + ret = regmap_update_bits(regmap, rdev->desc->apply_reg, + rdev->desc->apply_bit, + rdev->desc->apply_bit); + return ret; +out: + pr_warn("%s: failed to set voltage_sel_regmap\n", rdev->desc->name); + return ret; +} + +static int s2m_set_voltage_time_sel(struct regulator_dev *rdev, + unsigned int old_selector, + unsigned int new_selector) +{ + int old_volt, new_volt; + + /* sanity check */ + if (!rdev->desc->ops->list_voltage) + return -EINVAL; + + old_volt = rdev->desc->ops->list_voltage(rdev, old_selector); + new_volt = rdev->desc->ops->list_voltage(rdev, new_selector); + + if (old_selector < new_selector) + return DIV_ROUND_UP(new_volt - old_volt, S2DOS05_RAMP_DELAY); + + return 0; +} + +static int s2m_set_active_discharge(struct regulator_dev *rdev, + bool enable) +{ + struct s2dos05_data *info = rdev_get_drvdata(rdev); + struct regmap *regmap = info->regmap; + int ret; + u8 val; + + if (enable) + val = rdev->desc->active_discharge_on; + else + val = rdev->desc->active_discharge_off; + + ret = regmap_update_bits(regmap, rdev->desc->active_discharge_reg, + rdev->desc->active_discharge_mask, val); + return ret; +} + +static const struct regulator_ops s2dos05_ldo_ops = { + .list_voltage = regulator_list_voltage_linear, + .map_voltage = regulator_map_voltage_linear, + .is_enabled = s2m_is_enabled_regmap, + .enable = s2m_enable, + .disable = s2m_disable_regmap, + .get_voltage_sel = s2m_get_voltage_sel_regmap, + .set_voltage_sel = s2m_set_voltage_sel_regmap, + .set_voltage_time_sel = s2m_set_voltage_time_sel, + .set_active_discharge = s2m_set_active_discharge, +}; + +static const struct regulator_ops s2dos05_buck_ops = { + .list_voltage = regulator_list_voltage_linear, + .map_voltage = regulator_map_voltage_linear, + .is_enabled = s2m_is_enabled_regmap, + .enable = s2m_enable, + .disable = s2m_disable_regmap, + .get_voltage_sel = s2m_get_voltage_sel_regmap, + .set_voltage_sel = s2m_set_voltage_sel_regmap_buck, + .set_voltage_time_sel = s2m_set_voltage_time_sel, + .set_active_discharge = s2m_set_active_discharge, +}; + +#define _BUCK(macro) S2DOS05_BUCK##macro +#define _buck_ops(num) s2dos05_buck_ops##num + +#define _LDO(macro) S2DOS05_LDO##macro +#define _REG(ctrl) S2DOS05_REG##ctrl +#define _ldo_ops(num) s2dos05_ldo_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, \ + .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, \ + .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 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("buck1", _BUCK(1), &_buck_ops(), _BUCK(_MIN1), + _BUCK(_STEP1), _REG(_BUCK_VOUT), + _REG(_EN), _MASK(_B1), _TIME(_BUCK), _REG(_BUCK_CFG)), +}; + +static int s2dos05_pmic_dt_parse_pdata(struct device *dev, + struct of_regulator_match *rdata, + unsigned int rdev_num) +{ + struct device_node *reg_np; + int err; + + reg_np = of_get_child_by_name(dev->parent->of_node, "regulators"); + if (!reg_np) { + dev_err(dev, "could not find regulators sub-node\n"); + return -EINVAL; + } + + err = of_regulator_match(dev, reg_np, rdata, rdev_num); + of_node_put(reg_np); + + return err; +} + +static int s2dos05_pmic_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct s2dos_core *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; + int ret, err = 0; + + s2dos05 = devm_kzalloc(dev, sizeof(struct s2dos05_data), + GFP_KERNEL); + if (!s2dos05) { + ret = -ENOMEM; + goto err_data; + } + platform_set_drvdata(pdev, s2dos05); + + rdata = kcalloc(rdev_num, sizeof(*rdata), GFP_KERNEL); + if (!rdata) + return -ENOMEM; + + for (i = 0; i < rdev_num; i++) + rdata[i].name = regulators[i].name; + + err = s2dos05_pmic_dt_parse_pdata(dev, rdata, rdev_num); + if (err < 0) { + dev_err(dev, "Failed to parse regulators device of_node\n"); + goto err_data; + } + + s2dos05->regmap = iodev->regmap; + s2dos05->dev = dev; + + 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); + goto out; + } + } + +out: + kfree(rdata); + + return ret; + +err_data: + devm_kfree(dev, (void *)s2dos05); + kfree(s2dos05); + + 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"); From patchwork Tue Jun 18 13:59:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13702412 Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) (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 0677D1A00CF; Tue, 18 Jun 2024 14:00:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719235; cv=none; b=uISn4HKfM5+6osFDcB0EOY1Tlshrr6b0OKmbRjorFqsIYYxx7ibhhVQ3z9Z0kLl2u+BzS1wH0jDkG9ntXPk/LEUCmF+tjaR5SJFxYyY6LNf9Pla1eFSOX1LnzDxdtn+n52SV7dQiaqze6wSz2ZvAd3bwB2RRNxpyGkgwJoUBwjA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719235; c=relaxed/simple; bh=M+uc6GTvoNAckqEvB4YdUBo7gTDSwvEY9HdmtBtM0OA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EUEMjG3C5POw2oTDoARBqnYZfJshcF5DK+HAMqyFDnOzmrTQyDgKpdWNC+FVRw2S4OQ27kh6EY03Swj52uPoaBThKqPJj7rMEIxlT7ek8+Sy0K6QH7SPclw7rDB/Y2rJ6O1+WqVlNqMYs2L/NPAka5WC2SapFhVDBeV2FV8v1YE= 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=YFU/fJNi; arc=none smtp.client-ip=209.85.208.48 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="YFU/fJNi" Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-57cc7e85b4bso2284452a12.0; Tue, 18 Jun 2024 07:00:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719231; x=1719324031; 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=Q4ELQwjzHA4yApdsWewX3oXEq3EZwSJvDLoYd1jNQ34=; b=YFU/fJNiLdWH8K5pTEa8pKMdTc8UeFGXXaecMbItRVi4/091B7mJ6hPwY2Fc8U2av8 qFJYnuCGEUpcbnM472oqomhNm/cRU6LyfLPwTDLLv5FRPVal9KbDnkCCpvJSd1K5U9mE gYcnC098z3Gkze3wC+FPMRVyT3TEs60A2hO6dyHFnK42ocMoGaYFsBDvZqW/LhNwTiXK hB+EFpw/oLtNzkqME+7uarAjt1vWOpDGXAEmarzxH/O3Dv9AHm2k/XRp3sdsxwf/+DNU YB5LrQGpFNNbUWnmkkrhXdUMhawpTXfJ6+xbzaSYskPpeajROVJmAB/aIck0K+JH3soJ HEcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718719231; x=1719324031; 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=Q4ELQwjzHA4yApdsWewX3oXEq3EZwSJvDLoYd1jNQ34=; b=tR4nMkREcZ8Awn9lxhIsvBVyEieW4PNT0M5GPQjflET4hdTJPESQVpwroje9L3Ymxj ZEtClSj1EjRQPkpRxO8CG/0lNWOUB3iXTUHVcEiJxLrkWtYlT3E9EyxsKMdTxNKjMOGL 4zfoRevnVw/LiX1bExnfi7mXzkZrMQ3HlIeIV5aV+b5d+kyoqxFiybyG6CY8zZacsE2s KsJ+whuuN5Ecy+VqaKWo0lVzfwKZzRRFLu4G7nvBkhL738j+H2EEX8OVTtivCBavRj0c xcSeqa9hx43lpJ1aAuXNVsT50bxg6L1ydI8lcCr4uMok3HwRLC3Wg/GO7ZjEidpNxvW9 Ru/g== X-Forwarded-Encrypted: i=1; AJvYcCUVs5dF93p/EwERhr7XLYEVB0tl+Hhb/9hKPvDoUhsVJCopONSRlPnw7ps6qXZZuEX35j452vCld8DTS12uDC+uWyHbPhLxbEBY0LLeMfQpQlzGaTgriYAeF/ZYdI9rywWxqFNd+GgOofWTIGa93QRgQJBmCiXP6LdFrmJGFLHLC6n1YiGnkOFpExZEmS0iJ+YjdWTkDo57a3cJlZcieFNbtX/JkhYDcOuhf6OtR1hrHymWlEAZ1g9p7VS2rOAOtfEa2Yxsb1cRqDVmDK36LSJ3HzA+hXL/y7CIVGi5nCPQs41N4S2fwx5bl7g9h1i9DEVtJriwxburcrqvngVxZyu8V6wRQWXqzBN0BnRSETOPKKKb4aTr+8ngGuCy7C67QF4oKKsqiME1w8dnrxoHeA8JOU0B2ziP X-Gm-Message-State: AOJu0YxSn0OKja92Tmq5FI9ORdYeNEm/CNMwhPs2kyD7LyKKpQhO89E0 1JLilEhsZeBohDIKYKfPJenhKNVbe7sUUMjwQ27BbllJPbmPctNI X-Google-Smtp-Source: AGHT+IG56CjchONS6I1JegFr/43CXmjz4UPasXM/HnpGFAACjVWB6VLqx/Impr4a3DUI4prupBUQPg== X-Received: by 2002:a50:998c:0:b0:57c:c171:2fb6 with SMTP id 4fb4d7f45d1cf-57cf7a4e148mr1877504a12.1.1718719231063; Tue, 18 Jun 2024 07:00:31 -0700 (PDT) Received: from [127.0.1.1] (mm-167-232-122-178.mgts.dynamic.pppoe.byfly.by. [178.122.232.167]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-57cb72da156sm7731278a12.22.2024.06.18.07.00.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 07:00:30 -0700 (PDT) From: Dzmitry Sankouski Date: Tue, 18 Jun 2024 16:59:53 +0300 Subject: [PATCH v3 19/23] power: supply: s2dos05: Add fuel gauge driver for s2dos05 Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240618-starqltechn_integration_upstream-v3-19-e3f6662017ac@gmail.com> References: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> In-Reply-To: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> To: Sebastian Reichel , Bjorn Andersson , Michael Turquette , Stephen Boyd , Neil Armstrong , Jessica Zhang , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lee Jones , Dmitry Torokhov , Pavel Machek , Liam Girdwood , Mark Brown , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Krzysztof Kozlowski , Konrad Dybcio , Chanwoo Choi , phone-devel@vger.kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, linux-pwm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1718719185; l=18925; i=dsankouski@gmail.com; s=20240618; h=from:subject:message-id; bh=M+uc6GTvoNAckqEvB4YdUBo7gTDSwvEY9HdmtBtM0OA=; b=wYpibWI2SfJGhhqeC25dhyZfx7jwIHK7peeTCQGamB97n/dYfX6y9D6lfjfMafBFp9MtQEP2c PSrkGaJweMFBPaMye7WabuIUy9Ns45BE7DW5DmrdldpFpOVCId66k3E X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=6pMMVVDDReSiRgPCbMOUauN5nS3ty4Sf5b7a2gi4x0M= Add fuel gauge driver for s2dos05 PMIC. It uses adc to measure power on each power output s2dos05 provides, including regulator outputs and AVDD, ELVSS, ELVDD lines. Driver registers power supply for each corresponding power line. Adc can be disabled and enabled via sysfs. Signed-off-by: Dzmitry Sankouski --- MAINTAINERS | 1 + drivers/power/supply/Kconfig | 8 + drivers/power/supply/Makefile | 1 + drivers/power/supply/s2dos05-fg.c | 427 ++++++++++++++++++++++++++++++++++++++ include/linux/mfd/s2dos05.h | 123 +++++++++++ 5 files changed, 560 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index bee700a5e648..2c5d9a74f977 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19910,6 +19910,7 @@ F: Documentation/devicetree/bindings/regulator/samsung,s5m*.yaml F: drivers/clk/clk-s2mps11.c F: drivers/mfd/s2dos*.c F: drivers/mfd/sec*.c +F: drivers/power/supply/s2dos*.c F: drivers/regulator/s2dos*.c F: drivers/regulator/s2m*.c F: drivers/regulator/s5m*.c diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index a3fdfcb5aa64..22090b150885 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -964,6 +964,14 @@ config CHARGER_SURFACE Microsoft Surface devices, i.e. Surface Pro 7, Surface Laptop 3, Surface Book 3, and Surface Laptop Go. +config FUEL_GAUGE_S2DOS05 + tristate "Power measurement driver for s2dos05 pmic" + depends on MFD_S2DOS_CORE + help + This driver measures power consumption of s2dos05 regulator consumers. + + Say M or Y here to include power measurement ability in s2dos05 pmic. + config BATTERY_UG3105 tristate "uPI uG3105 battery monitor driver" depends on I2C diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index e1abad8b6b75..fcea83c8aa79 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -113,6 +113,7 @@ obj-$(CONFIG_RN5T618_POWER) += rn5t618_power.o obj-$(CONFIG_BATTERY_ACER_A500) += acer_a500_battery.o obj-$(CONFIG_BATTERY_SURFACE) += surface_battery.o obj-$(CONFIG_CHARGER_SURFACE) += surface_charger.o +obj-$(CONFIG_FUEL_GAUGE_S2DOS05) += s2dos05-fg.o obj-$(CONFIG_BATTERY_UG3105) += ug3105_battery.o obj-$(CONFIG_CHARGER_QCOM_SMB2) += qcom_pmi8998_charger.o obj-$(CONFIG_FUEL_GAUGE_MM8013) += mm8013.o diff --git a/drivers/power/supply/s2dos05-fg.c b/drivers/power/supply/s2dos05-fg.c new file mode 100644 index 000000000000..d2070f90c80c --- /dev/null +++ b/drivers/power/supply/s2dos05-fg.c @@ -0,0 +1,427 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * s2dos05-fg.c + * + * Copyright (c) 2015 Samsung Electronics Co., Ltd + * http://www.samsung.com + * Copyright (c) 2024 Dzmitry Sankouski + * + */ +#include +#include +#include +#include +#include +#include + +#define SYNC_MODE 1 +#define ASYNC_MODE 2 + +struct s2dos05_fg { + struct regmap *regmap; + struct device *dev; + u8 adc_sync_mode; + struct power_supply *psy_elvdd; + struct power_supply *psy_elvss; + struct power_supply *psy_avdd; + struct power_supply *psy_buck; + struct power_supply *psy_ldo1; + struct power_supply *psy_ldo2; + struct power_supply *psy_ldo3; + struct power_supply *psy_ldo4; +}; + +static const unsigned int power_coeffs[8] = {POWER_ELVDD, POWER_ELVSS, POWER_AVDD, + POWER_BUCK, POWER_L1, POWER_L2, POWER_L3, POWER_L4}; + +static void s2dos05_is_online(struct s2dos05_fg *drv_data, int *val) +{ + unsigned int adc_ctrl2; + + regmap_read(drv_data->regmap, S2DOS05_REG_PWRMT_CTRL2, &adc_ctrl2); + if ((adc_ctrl2 & ADC_EN_MASK) > 0) + *val = 1; + else + *val = 0; +} + +static void s2dos05_start_measurement_if_async(struct s2dos05_fg *drv_data, unsigned int channel) +{ + unsigned int temp; + + if (drv_data->adc_sync_mode == ASYNC_MODE) { + regmap_read(drv_data->regmap, S2DOS05_REG_PWRMT_CTRL1, &temp); + if (!(temp & PWRMT_EN_CHK)) + return; + + regmap_update_bits(drv_data->regmap, S2DOS05_REG_PWRMT_CTRL1, + ADC_ASYNCRD_MASK, ADC_ASYNCRD_MASK); + usleep_range(2000, 2100); + } +} + +static void s2dos05_adc_read_power(struct s2dos05_fg *drv_data, unsigned int channel, int *val) +{ + unsigned int data_l, data_h, adc_val; + + regmap_update_bits(drv_data->regmap, S2DOS05_REG_PWRMT_CTRL2, ADC_PTR_MASK, + 2*channel); + regmap_read(drv_data->regmap, S2DOS05_REG_PWRMT_DATA, + &data_l); + + regmap_update_bits(drv_data->regmap, S2DOS05_REG_PWRMT_CTRL2, ADC_PTR_MASK, + 2*channel+1); + regmap_read(drv_data->regmap, S2DOS05_REG_PWRMT_DATA, + &data_h); + + adc_val = ((data_h & 0xff) << 8) | (data_l & 0xff); + *val = adc_val * power_coeffs[channel] / 100; +} + +static int s2dos05_get_adc_validity(struct s2dos05_fg *drv_data) +{ + unsigned int adc_validity; + + regmap_read(drv_data->regmap, S2DOS05_REG_OCL, &adc_validity); + return !!(adc_validity | ADC_VALID_MASK); +} + +static ssize_t adc_en_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct s2dos05_fg *drv_data = dev_get_drvdata(dev); + unsigned int adc_ctrl3; + + regmap_read(drv_data->regmap, S2DOS05_REG_PWRMT_CTRL2, &adc_ctrl3); + if ((adc_ctrl3 & ADC_EN_MASK) > 0) + return snprintf(buf, PAGE_SIZE, "ADC enable (%x)\n", adc_ctrl3); + else + return snprintf(buf, PAGE_SIZE, "ADC disable (%x)\n", adc_ctrl3); +} + +static ssize_t adc_en_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct s2dos05_fg *drv_data = dev_get_drvdata(dev); + int ret; + unsigned int temp, val; + + ret = kstrtouint(buf, 16, &temp); + if (ret) + return -EINVAL; + + switch (temp) { + case 0: + val = 0x00; + break; + case 1: + val = 0x80; + break; + default: + val = 0x00; + break; + } + + regmap_update_bits(drv_data->regmap, S2DOS05_REG_PWRMT_CTRL2, ADC_EN_MASK, + val); + return count; +} + +static ssize_t adc_sync_mode_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct s2dos05_fg *drv_data = dev_get_drvdata(dev); + + switch (drv_data->adc_sync_mode) { + case SYNC_MODE: + return snprintf(buf, PAGE_SIZE, "SYNC_MODE (%d)\n", drv_data->adc_sync_mode); + case ASYNC_MODE: + return snprintf(buf, PAGE_SIZE, "ASYNC_MODE (%d)\n", drv_data->adc_sync_mode); + default: + return snprintf(buf, PAGE_SIZE, "error (%d)\n", drv_data->adc_sync_mode); + } +} + +static ssize_t adc_sync_mode_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct s2dos05_fg *drv_data = dev_get_drvdata(dev); + int ret; + u8 temp; + + ret = kstrtou8(buf, 16, &temp); + if (ret) + return -EINVAL; + + switch (temp) { + case SYNC_MODE: + drv_data->adc_sync_mode = 1; + break; + case ASYNC_MODE: + drv_data->adc_sync_mode = 2; + break; + default: + drv_data->adc_sync_mode = 1; + break; + } + + return count; +} + +static DEVICE_ATTR_RW(adc_en); +static DEVICE_ATTR_RW(adc_sync_mode); + +static int s2dos05_fg_get_property(struct power_supply *psy, + enum power_supply_property psp, + union power_supply_propval *val, + unsigned int channel + ) +{ + struct s2dos05_fg *drv_data = power_supply_get_drvdata(psy); + + switch (psp) { + case POWER_SUPPLY_PROP_ONLINE: + s2dos05_is_online(drv_data, &val->intval); + break; + case POWER_SUPPLY_PROP_STATUS: + if (s2dos05_get_adc_validity(drv_data)) + val->intval = POWER_SUPPLY_HEALTH_GOOD; + else + val->intval = POWER_SUPPLY_HEALTH_UNSPEC_FAILURE; + break; + case POWER_SUPPLY_PROP_POWER_NOW: + s2dos05_start_measurement_if_async(drv_data, channel); + s2dos05_adc_read_power(drv_data, channel, &val->intval); + break; + default: + return -EINVAL; + } + + return 0; +} + +static int s2dos05_fg_get_property_elvdd(struct power_supply *psy, + enum power_supply_property psp, + union power_supply_propval *val + ) +{ + return s2dos05_fg_get_property(psy, psp, val, CHANNEL_ELVDD); +} + +static int s2dos05_fg_get_property_elvss(struct power_supply *psy, + enum power_supply_property psp, + union power_supply_propval *val + ) +{ + return s2dos05_fg_get_property(psy, psp, val, CHANNEL_ELVSS); +} + +static int s2dos05_fg_get_property_avdd(struct power_supply *psy, + enum power_supply_property psp, + union power_supply_propval *val + ) +{ + return s2dos05_fg_get_property(psy, psp, val, CHANNEL_AVDD); +} + +static int s2dos05_fg_get_property_buck(struct power_supply *psy, + enum power_supply_property psp, + union power_supply_propval *val + ) +{ + return s2dos05_fg_get_property(psy, psp, val, CHANNEL_BUCK); +} + +static int s2dos05_fg_get_property_ldo1(struct power_supply *psy, + enum power_supply_property psp, + union power_supply_propval *val + ) +{ + return s2dos05_fg_get_property(psy, psp, val, CHANNEL_L1); +} + +static int s2dos05_fg_get_property_ldo2(struct power_supply *psy, + enum power_supply_property psp, + union power_supply_propval *val + ) +{ + return s2dos05_fg_get_property(psy, psp, val, CHANNEL_L2); +} + +static int s2dos05_fg_get_property_ldo3(struct power_supply *psy, + enum power_supply_property psp, + union power_supply_propval *val + ) +{ + return s2dos05_fg_get_property(psy, psp, val, CHANNEL_L3); +} + +static int s2dos05_fg_get_property_ldo4(struct power_supply *psy, + enum power_supply_property psp, + union power_supply_propval *val + ) +{ + return s2dos05_fg_get_property(psy, psp, val, CHANNEL_L4); +} + +static void s2dos05_powermeter_init(struct s2dos05_fg *drv_data) +{ + /* SMP_NUM = 1100(16384) ~16s in case of aync mode */ + regmap_write(drv_data->regmap, S2DOS05_REG_PWRMT_CTRL1, 0x0C); + regmap_update_bits(drv_data->regmap, S2DOS05_REG_PWRMT_CTRL2, POWER_MODE, + POWER_MODE); + /* ADC EN */ + regmap_update_bits(drv_data->regmap, S2DOS05_REG_PWRMT_CTRL2, + ADC_EN_MASK, ADC_EN_MASK); + +} + +static void s2dos05_powermeter_deinit(struct s2dos05_fg *s2dos05) +{ + /* ADC turned off */ + regmap_write(s2dos05->regmap, S2DOS05_REG_PWRMT_CTRL2, 0); +} + +static enum power_supply_property s2dos05_fg_properties[] = { + POWER_SUPPLY_PROP_ONLINE, + POWER_SUPPLY_PROP_STATUS, + POWER_SUPPLY_PROP_POWER_NOW, +}; + +static const struct power_supply_desc s2dos05_elvdd_fg_desc = { + .name = "s2dos05_elvdd", + .type = POWER_SUPPLY_TYPE_UNKNOWN, + .get_property = s2dos05_fg_get_property_elvdd, + .properties = s2dos05_fg_properties, + .num_properties = ARRAY_SIZE(s2dos05_fg_properties), +}; + +static const struct power_supply_desc s2dos05_elvss_fg_desc = { + .name = "s2dos05_elvss", + .type = POWER_SUPPLY_TYPE_UNKNOWN, + .get_property = s2dos05_fg_get_property_elvss, + .properties = s2dos05_fg_properties, + .num_properties = ARRAY_SIZE(s2dos05_fg_properties), +}; + +static const struct power_supply_desc s2dos05_avdd_fg_desc = { + .name = "s2dos05_avdd", + .type = POWER_SUPPLY_TYPE_UNKNOWN, + .get_property = s2dos05_fg_get_property_avdd, + .properties = s2dos05_fg_properties, + .num_properties = ARRAY_SIZE(s2dos05_fg_properties), +}; + +static const struct power_supply_desc s2dos05_buck_fg_desc = { + .name = "s2dos05_buck", + .type = POWER_SUPPLY_TYPE_UNKNOWN, + .get_property = s2dos05_fg_get_property_buck, + .properties = s2dos05_fg_properties, + .num_properties = ARRAY_SIZE(s2dos05_fg_properties), +}; + +static const struct power_supply_desc s2dos05_ldo1_fg_desc = { + .name = "s2dos05_ldo1", + .type = POWER_SUPPLY_TYPE_UNKNOWN, + .get_property = s2dos05_fg_get_property_ldo1, + .properties = s2dos05_fg_properties, + .num_properties = ARRAY_SIZE(s2dos05_fg_properties), +}; + +static const struct power_supply_desc s2dos05_ldo2_fg_desc = { + .name = "s2dos05_ldo2", + .type = POWER_SUPPLY_TYPE_UNKNOWN, + .get_property = s2dos05_fg_get_property_ldo2, + .properties = s2dos05_fg_properties, + .num_properties = ARRAY_SIZE(s2dos05_fg_properties), +}; + +static const struct power_supply_desc s2dos05_ldo3_fg_desc = { + .name = "s2dos05_ldo3", + .type = POWER_SUPPLY_TYPE_UNKNOWN, + .get_property = s2dos05_fg_get_property_ldo3, + .properties = s2dos05_fg_properties, + .num_properties = ARRAY_SIZE(s2dos05_fg_properties), +}; + +static const struct power_supply_desc s2dos05_ldo4_fg_desc = { + .name = "s2dos05_ldo4", + .type = POWER_SUPPLY_TYPE_UNKNOWN, + .get_property = s2dos05_fg_get_property_ldo4, + .properties = s2dos05_fg_properties, + .num_properties = ARRAY_SIZE(s2dos05_fg_properties), +}; + +static int s2dos05_fuelgauge_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct s2dos_core *iodev = dev_get_drvdata(dev->parent); + struct s2dos05_fg *drv_data; + struct power_supply_config pscfg = {}; + int ret; + + drv_data = devm_kzalloc(dev, sizeof(struct s2dos05_fg), + GFP_KERNEL); + if (!drv_data) + ret = -ENOMEM; + + drv_data->regmap = iodev->regmap; + s2dos05_powermeter_init(drv_data); + pscfg.drv_data = drv_data; + + drv_data->psy_elvdd = devm_power_supply_register(dev, &s2dos05_elvdd_fg_desc, &pscfg); + drv_data->psy_elvss = devm_power_supply_register(dev, &s2dos05_elvss_fg_desc, &pscfg); + drv_data->psy_avdd = devm_power_supply_register(dev, &s2dos05_avdd_fg_desc, &pscfg); + drv_data->psy_buck = devm_power_supply_register(dev, &s2dos05_buck_fg_desc, &pscfg); + drv_data->psy_ldo1 = devm_power_supply_register(dev, &s2dos05_ldo1_fg_desc, &pscfg); + drv_data->psy_ldo2 = devm_power_supply_register(dev, &s2dos05_ldo2_fg_desc, &pscfg); + drv_data->psy_ldo3 = devm_power_supply_register(dev, &s2dos05_ldo3_fg_desc, &pscfg); + drv_data->psy_ldo4 = devm_power_supply_register(dev, &s2dos05_ldo4_fg_desc, &pscfg); + + platform_set_drvdata(pdev, drv_data); + + ret = device_create_file(&pdev->dev, &dev_attr_adc_en); + if (ret) { + dev_err(dev, "failed: create adc enable sysfs entry\n"); + goto err; + } + ret = device_create_file(&pdev->dev, &dev_attr_adc_sync_mode); + if (ret) { + dev_err(dev, "failed: create adc sync mode sysfs entry\n"); + goto err; + } + +err: + device_remove_file(dev, &dev_attr_adc_en); + device_remove_file(dev, &dev_attr_adc_sync_mode); + + return 0; +} + +static void s2dos05_fuelgauge_remove(struct platform_device *pdev) +{ + struct s2dos05_fg *info = platform_get_drvdata(pdev); + + s2dos05_powermeter_deinit(info); + + device_remove_file(&pdev->dev, &dev_attr_adc_en); + device_remove_file(&pdev->dev, &dev_attr_adc_sync_mode); +} + +static const struct platform_device_id s2dos05_platform_ids[] = { + {"s2dos05-fg", 0}, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(platform, s2dos05_platform_ids); + +static struct platform_driver s2dos05_platform_driver = { + .driver = { + .name = "s2dos05-fg", + }, + .probe = s2dos05_fuelgauge_probe, + .id_table = s2dos05_platform_ids, + .remove_new = s2dos05_fuelgauge_remove, +}; +module_platform_driver(s2dos05_platform_driver); + +MODULE_DESCRIPTION("s2dos05 power meter"); +MODULE_AUTHOR("Dzmitry Sankouski "); +MODULE_LICENSE("GPL"); diff --git a/include/linux/mfd/s2dos05.h b/include/linux/mfd/s2dos05.h new file mode 100644 index 000000000000..8d216064bc78 --- /dev/null +++ b/include/linux/mfd/s2dos05.h @@ -0,0 +1,123 @@ +/* SPDX-License-Identifier: GPL-2.0+ + * s2dos05.h + * + * Copyright (c) 2016 Samsung Electronics Co., Ltd + * http://www.samsung.com + * + */ + +#ifndef __LINUX_MFD_S2DOS05_H +#define __LINUX_MFD_S2DOS05_H +#include +#include + +#define MFD_DEV_NAME "s2dos05" + +struct s2dos05_dev { + struct device *dev; + struct regmap *regmap; +}; + +/* 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_ENABLE_SHIFT 0x06 +#define S2DOS05_LDO_N_VOLTAGES (S2DOS05_LDO_VSEL_MASK + 1) +#define S2DOS05_BUCK_N_VOLTAGES (S2DOS05_BUCK_VSEL_MASK + 1) + +#define S2DOS05_PMIC_EN_SHIFT 6 +#define S2DOS05_REGULATOR_MAX (S2DOS05_REG_MAX) + +/* ----------power meter ----------*/ +#define S2DOS05_REG_PWRMT_CTRL1 0x0A +#define S2DOS05_REG_PWRMT_CTRL2 0x0B +#define S2DOS05_REG_PWRMT_DATA 0x0C +#define S2DOS05_REG_IRQ_MASK 0x0D + +#define CHANNEL_ELVDD 0 +#define CHANNEL_ELVSS 1 +#define CHANNEL_AVDD 2 +#define CHANNEL_BUCK 3 +#define CHANNEL_L1 4 +#define CHANNEL_L2 5 +#define CHANNEL_L3 6 +#define CHANNEL_L4 7 + +#define POWER_ELVDD 24500 +#define POWER_ELVSS 24500 +#define POWER_AVDD 3060 +#define POWER_BUCK 1525 +#define POWER_L1 5000 +#define POWER_L2 5000 +#define POWER_L3 5000 +#define POWER_L4 5000 + +/* S2DOS05_REG_OCL */ +#define ADC_VALID_MASK BIT(7) +/* S2DOS05_REG_PWRMT_CTRL1 */ +#define ADC_ASYNCRD_MASK BIT(7) +#define PWRMT_EN_CHK BIT(6) +#define SMPNUM_MASK 0x0F +/* S2DOS05_REG_PWRMT_CTRL2 */ +#define ADC_EN_MASK BIT(7) +#define ADC_PTR_MASK 0x0F +#define POWER_MODE BIT(4) +#define RAWCURRENT_MODE BIT(5) + +#define S2DOS05_MAX_ADC_CHANNEL 8 + +#endif /* __LINUX_MFD_S2DOS05_H */ From patchwork Tue Jun 18 13:59:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13702413 Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (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 E303E1A01A0; Tue, 18 Jun 2024 14:00:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719236; cv=none; b=gYjytO48/UBPgAKecbQRD1hLhe5qw9VmsdhJkoJ9c5xDvrh6xk7KOa+Ug+O4bJwbId3H1IqZ4DvvfwQDB1MIzlyPKoU3St1Y+sJXkN3kWSwiVy6lME+Gz1UjALiqV20NsYcZ8MmHfysX0pCMtPzyXKr80l6rAIylPJdBUI/rlbE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719236; c=relaxed/simple; bh=MWsqiRVXsQwpa/BJsSBZlzlVtHIs1c7rhP0PmAUfrYI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MruAjGMNCicQyxF/DPA4mKxIF1idDE8bwQHzoABKfxPQ7CXOCAWRchDscRDSTcAlQIx5M/Ptb0U4RckzQ4p12jGr6E489aInYtEwJs4UJecGJZ1SSL8uUJB+ZvNVL9dHm25G45MUsAxcNYNnar6NLATe8TUer0GuQc3ULmZFF5E= 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=T6fjO+km; arc=none smtp.client-ip=209.85.208.51 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="T6fjO+km" Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-57cfe600cbeso767945a12.2; Tue, 18 Jun 2024 07:00:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719233; x=1719324033; 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=B9Gf8rtcSoFk0i/i8QsJvx4g8bW8LJTVUFR2J5NOhaQ=; b=T6fjO+kmemNjYRnXPu12NFYyRMGuOBd77TzgZz7mFCEdkUzv1hJBiDfSfooKEcJVJz pUOf46Ibit45vNQJMBl6/pIYojBaltUz1Q80Nk92vEALPeECGBXPNPgIeUQKDjVABkJD Z7TilmOIPrlQFVNwxwZcqPYDn2rWqim6ss9E/kHDafVoovCGgTs/I9DXb+bAdyqT3yMs YIvN19yQfJo9gUsyDkmwJpfqv8NnT1O4zyxhWoOdikn3J+O8IT+dQKzMn2lRO1F5yIBC Bw9OTPToE72xk7E8MLPqqWi0r0HKLTUwrpBgcbiHfythxwBgURscIP7M48lrwAyx8hI2 0JHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718719233; x=1719324033; 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=B9Gf8rtcSoFk0i/i8QsJvx4g8bW8LJTVUFR2J5NOhaQ=; b=vrdRBlwEiDVkVEmL+z9MUnZXY8jxDuRW9irfTiwI6hDBpYLg6UV5MGIwxeurzOyMyE hip/XxzOLfGkaTxremS4AXdmHiDlQOpyZ8qNM9sHSA2JUSKFQe0nSscdroAuKxMHlddM 1BmPfiIVQPmc2Y2Gh6yi71n7FoLeZ5vhtbUjmiOqg+DDStVzg/i+PYmaPtnB7C+7bBHb WjtFynLpLZC+ze1KtRKu2e1+vqu8w9zaatBYb17ggBlCAaVP8dF0W78qmxJQIih8IrYU sntWcoGmIEeCbuGJeGKiPHWwKZ1YbLgJL0N+ErEZwKkNnCs8VzWLJpFg8qvw24eVirZA UOpw== X-Forwarded-Encrypted: i=1; AJvYcCWX6eWZN1eUzMFU6L6cnVz0r4ojsw3ViHrkAYUfWUKQBArGJVqtx9UQiwUNNnqe5Guufg7qnJ7eCDDa/FwpfD9DdJpMMGe0Ty8MA9Qu13SXFkZLolZlKmxc8jJG4fJDKYlStHxZF3W64a5+c13RHaEed2Q5aoI9L53aMbRYJK3g6Yxc8PD+TE8md8TFc5b86BaRpnqjzzSRjAhpvmnLtLbLAX2/R+RcQwGSCYh9SOduwm91TAck+lxpEZemrh+Hw5j1a5gAsbmqPXYAGOxb/PYLypbEEF36t7yZtLJ66OniLwgtHP1PLr6JAnsvwGvk53vMnMmqub2V4DlAg5OkxNdRAKH67+3ZGTlexBnxVQBAu3UGU2VVhtkXbFrSQp2vzKQa8e/8kjBLQ9Jd/NVuMZkPWxywhOid X-Gm-Message-State: AOJu0YxUfaM2S22gFeZ7FgKAi++3TN/MPdTXlNwenX3DbktQ62g41JZ2 dG/RabmsFD7G+guQJDkFn1FXar6r2x7TcsSq9G8IrfaH/LVv4X40 X-Google-Smtp-Source: AGHT+IEzlujelQJZgkVk9tQETLWjgeiYiRGiSHlbCzMcWjnBZo37sEMYpBAy10o1Z/JwAfiRNQv5Xw== X-Received: by 2002:a50:d51b:0:b0:57c:c171:2fb5 with SMTP id 4fb4d7f45d1cf-57cc17169a7mr7086495a12.5.1718719233288; Tue, 18 Jun 2024 07:00:33 -0700 (PDT) Received: from [127.0.1.1] (mm-167-232-122-178.mgts.dynamic.pppoe.byfly.by. [178.122.232.167]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-57cb72da156sm7731278a12.22.2024.06.18.07.00.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 07:00:32 -0700 (PDT) From: Dzmitry Sankouski Date: Tue, 18 Jun 2024 16:59:54 +0300 Subject: [PATCH v3 20/23] arm64: dts: qcom: starqltechn: remove wifi Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240618-starqltechn_integration_upstream-v3-20-e3f6662017ac@gmail.com> References: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> In-Reply-To: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> To: Sebastian Reichel , Bjorn Andersson , Michael Turquette , Stephen Boyd , Neil Armstrong , Jessica Zhang , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lee Jones , Dmitry Torokhov , Pavel Machek , Liam Girdwood , Mark Brown , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Krzysztof Kozlowski , Konrad Dybcio , Chanwoo Choi , phone-devel@vger.kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, linux-pwm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1718719185; l=998; i=dsankouski@gmail.com; s=20240618; h=from:subject:message-id; bh=MWsqiRVXsQwpa/BJsSBZlzlVtHIs1c7rhP0PmAUfrYI=; b=CAAGH21zd8iXQILS+hUtOdlu9JiX3XNwrCbwiN0odP2njtPSc+QFw5o7AN1NWe7kfsnx1w+NM KcvYyY+WBKUDjmAQvVktkCpOX6OsdZf3SgbEbhhMovjd6H42UA08T+G X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=6pMMVVDDReSiRgPCbMOUauN5nS3ty4Sf5b7a2gi4x0M= Starqltechn has broadcom chip for wifi, so sdm845 wifi part can be disabled. Fixes: d711b22eee55 ("arm64: dts: qcom: starqltechn: add initial device tree for starqltechn") Signed-off-by: Dzmitry Sankouski Reviewed-by: Konrad Dybcio --- arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts b/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts index d37a433130b9..6fc30fd1262b 100644 --- a/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts +++ b/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts @@ -418,14 +418,6 @@ &usb_1_qmpphy { status = "okay"; }; -&wifi { - vdd-0.8-cx-mx-supply = <&vreg_l5a_0p8>; - vdd-1.8-xo-supply = <&vreg_l7a_1p8>; - vdd-1.3-rfa-supply = <&vreg_l17a_1p3>; - vdd-3.3-ch0-supply = <&vreg_l25a_3p3>; - status = "okay"; -}; - &tlmm { gpio-reserved-ranges = <0 4>, <27 4>, <81 4>, <85 4>; From patchwork Tue Jun 18 13:59:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13702414 Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) (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 4FF841A072E; Tue, 18 Jun 2024 14:00:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719238; cv=none; b=TmuQdR5nLMfvF/L1g4v0cgM+H8xhFWuWRZNkBaauX0KKTV1zAg6d/Yb/4a0RnOSL2rAU8lSymbTIlWc47t7mJyRjL1gp6VuhmkpHwkCfES9Pm/fMnGBlIL90sSXgD38WAKbV445xlCV8onRqgAU83YLJf7ICrCNjRQSHlhJZK4s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719238; c=relaxed/simple; bh=DzdFdRz1gVcaCMECSJAIQnLBTgojo3XrhxzENnm7+Yk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WZOw+CmrjR7WVu4ZuBp5ZoQKfEvOvfKX7cOMlkw4WA06ijqB/oVG3jPnEB12wzRfsEbXW1i6ukdsk31SlLCvbRqgVTP9H4xUZGzYI4CnEwhaXNcpYP43m52X39uN0wxf4klJvbeNV+3X+QcvtzWar02J6S+98jjh8uBn5KVMt70= 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=JfaEAGfI; arc=none smtp.client-ip=209.85.208.48 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="JfaEAGfI" Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-57cfe600cbeso768035a12.2; Tue, 18 Jun 2024 07:00:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719236; x=1719324036; 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=N8C5cZtO+2UCwtEojtBuXITHFJF0Ul+anrs/LLrVrxk=; b=JfaEAGfIKRlATPRzpxbaRiuXBrbgrA7s3fGaeKJHmFBNdwRg40DYKa3Kji4QyhnplE KN7DZ35sJ6eCHBFaMHKwU198tjmOicefm9ORorV/KxjuTUSFLYsM/RVi6ACmVvAoAxJu onQpG3erUV4yB9rfJHJikzJa3J+y2m/RpwKgUgN/RxlK5Lh9tcifq8iTFFt4ZWwKRmXt CN19Eh2m6OTKAt86aTB/11eMuiAz1xqippqnrnTZYZMmeFgl3Bdr6V4fwwuDLiBCZUor esMfVXSbBZjszgNsyAznla9kZIxsogUXYoAo7S6vDxENt9pQ1TRQ+Ds8iXsGvsunSXZJ TZjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718719236; x=1719324036; 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=N8C5cZtO+2UCwtEojtBuXITHFJF0Ul+anrs/LLrVrxk=; b=upDKPA6cUVRkAL1BBf0PxBwb6U1Lq5DJnqpzjwY7rMFX5vO1RoABLWPKVQDPyVX/mx UC1s8tGRVogDBbF5wxALtVPoRMVHsifxeauLZqo+CCXxqIRsN5EL3A7dLKDul01uc3wU HeCMtaUd4A7mLNO9cL3CG6tcUapgp8kyjpfcHkZw8Ij3B7yZqG7HuCYXZflyJMPzpez9 z5kT7gYH4QS9GhE/M/NFpXDhAvdnhcy/FB5rQXYsW0Ra0Pjevmn75XB3pS4Dv/jlFK30 1BVE1A5pd/8KmRXvcawfsd+gdJDckm13S+xnzlKza8L8cQytITp5HQfqHt3gvwnXOqdV fW8g== X-Forwarded-Encrypted: i=1; AJvYcCWsnbdIP4cOVNb8pA9L0ZR0aqIp8VyGn2DTpiy7JtHPqqdXSN/bN3ybNfD46/PAe8QkHWARr432hlwwzAwJ9+b1BNp4igqs0hl9ZzaQ/Z96KoOrp1XS0oP0D2YTW/uSaURTEcsxVyQz8p9s08ecUpeRgPuVUEbo1oqiVp7PGobnwCS+ZvPSL2Dvwe8G6hADi8+XhLpaabjsuiPS29nBXihSJKVqZb9abewPSRPJH3Ki8EppleGclX1OHvlujrI9Hj8qkg98zL1JXfJ75xa8crcjla+Aj3cR5K3IWheyE8PuWEV5U07cZeiyPRxJ/zsqSAPMIsBx49sZ+xETWI1TGNHvkOnH2VEaM1G9n5JA9LgOhXty9j9WAafsKd940TiFBv5M/f/DvYloVYvXwxI5EnQuxQYuUOjU X-Gm-Message-State: AOJu0YxYA/QopuPhEItJfOXmCSAs8Ayi68vze1L6vY8fQDXMXpBmTZKj Om5TYkkPMvgEwrk7WvlEdTb1b6XSEjdVpsFv0kG8YSQgFj3v7Qai X-Google-Smtp-Source: AGHT+IHQorFEBelRVlnJYSg0Nj0exKGkeoGt+vHNChz4s1U63SUJqDJ4IXGFzwDNCjEMHQbzrx2ZIw== X-Received: by 2002:a50:ab4a:0:b0:578:6c19:4801 with SMTP id 4fb4d7f45d1cf-57cbd6a70e9mr8232985a12.22.1718719235560; Tue, 18 Jun 2024 07:00:35 -0700 (PDT) Received: from [127.0.1.1] (mm-167-232-122-178.mgts.dynamic.pppoe.byfly.by. [178.122.232.167]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-57cb72da156sm7731278a12.22.2024.06.18.07.00.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 07:00:35 -0700 (PDT) From: Dzmitry Sankouski Date: Tue, 18 Jun 2024 16:59:55 +0300 Subject: [PATCH v3 21/23] arm64: dts: qcom: starqltechn: remove framebuffer Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240618-starqltechn_integration_upstream-v3-21-e3f6662017ac@gmail.com> References: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> In-Reply-To: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> To: Sebastian Reichel , Bjorn Andersson , Michael Turquette , Stephen Boyd , Neil Armstrong , Jessica Zhang , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lee Jones , Dmitry Torokhov , Pavel Machek , Liam Girdwood , Mark Brown , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Krzysztof Kozlowski , Konrad Dybcio , Chanwoo Choi , phone-devel@vger.kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, linux-pwm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1718719185; l=914; i=dsankouski@gmail.com; s=20240618; h=from:subject:message-id; bh=DzdFdRz1gVcaCMECSJAIQnLBTgojo3XrhxzENnm7+Yk=; b=V19181JL5PJh1FZxnidHS2IZyd3Qo7EGVRrt7RJyFup2Mg4Or7+mluh4O8nPJterG1dcIbP87 yDealaQ5i9cA12cOnIJfdiYlbhP/WAfUNEcsJ0zd6HRE5SQ9Rep2O3Z X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=6pMMVVDDReSiRgPCbMOUauN5nS3ty4Sf5b7a2gi4x0M= Remove framebuffer because a panel driver introduced. Signed-off-by: Dzmitry Sankouski --- arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts b/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts index 6fc30fd1262b..578798704577 100644 --- a/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts +++ b/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts @@ -19,15 +19,6 @@ / { chosen { #address-cells = <2>; #size-cells = <2>; - ranges; - framebuffer: framebuffer@9d400000 { - compatible = "simple-framebuffer"; - reg = <0 0x9d400000 0 (2960 * 1440 * 4)>;//2400000 - width = <1440>; - height = <2960>; - stride = <(1440 * 4)>; - format = "a8r8g8b8"; - }; }; vph_pwr: vph-pwr-regulator { From patchwork Tue Jun 18 13:59:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13702415 Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) (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 51E981A08C6; Tue, 18 Jun 2024 14:00:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719241; cv=none; b=ACcDbUWbn2c3sEyCGlBvWIKk871R02euzZaXYG8EfJLabF1P544IKFTobNSbyGg/A6yiyaJTLoQ+jl2D4yexmo8msPxpWkNgOuLjepQOgmEgrjbrqpQhR+uBZFb9/NqxgZuDcL634KqKxXUEEmkU3za1a7o5jJklmFKeiDpny8o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719241; c=relaxed/simple; bh=bJDbtUbL+y5wg/waQs7Lp8AQgTgkl1/W9/LG9VfOOh4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IA62i/4Z2snKMOozHVVLGNTszWImmuLoQKHu2D7MvokgIgwb7I51wLBtvIND4ayMWwMTXkCqK5bpfY3Gt6B0XRcC2N7w9Jc/bBeNocWtxhCIhu3odxkQYmTZBzhuCqbMDyNcZCYgs2uFMwIHD1P9eoasWrFMLpl/6trAGUpSnkY= 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=ijxzbX00; arc=none smtp.client-ip=209.85.208.50 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="ijxzbX00" Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-57d05e0017aso47503a12.1; Tue, 18 Jun 2024 07:00:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719238; x=1719324038; 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=bKqBqiUFuc0JpR2mqQXDoqJZzafqiedaqDrYiJZ4fmQ=; b=ijxzbX00F2r/4e5WRJ1I3xQnFsdGawIiCzG/CE9jaUsncskBryo3TbYVeQqd80H+HX iADOmj2g9bNJWvPR/ySAS6D87bPXLFE8/EUa1NIn26oLSh/JspWVTAidzpAvhrl4e1ZG 1EcCNJvRz73kLyQZBgEXeZbKvHC85rsR6+gJE534Gv+y0QQFzmjTI07gQTcLhg58eDfP b/ttHmNKbny7+Xlpn6p0A8nKvjvegRmZ83Jjumgg9JydvcLoM1rVFK2LQnKw8qMrp0TN xU0g7VVAOXMGhfX/dRBxLBJ0l829JvIpWKwvcmQxhUd5cLvHKuTfZmvXfqgRjH1l4+Cy WbCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718719238; x=1719324038; 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=bKqBqiUFuc0JpR2mqQXDoqJZzafqiedaqDrYiJZ4fmQ=; b=BuWpZvNpwYneXTs1G/cLBU5myVTVWnZiTvMMOmoj25ae8/IzP2QtFOnQR4i9RiJ26y xOuW2iDFfnq6LmUKepNdGXQ/5MG0hNrtA0jSLEZc/5vtn5nIDkSj2sngsgvFy0p1n9Ys Go0b3x1JK5kndnkVFpGrpembCWYwzzlOvkXrswuZKHrS/GxO0VXJHq3qm/1cbqGaKcRJ 4yQbI27wUTPWBU2CdqgQP9H1U759E7jEy0RT7FMHaLq9lZzfDHoKdx359hMK/8vNAFZC UdZ3GiIS4YwmZE7Iv6pARQQJMrz5eLbIkLBrMNoVSIr+jMQakAhio4pNwnejArS61NGa P4RA== X-Forwarded-Encrypted: i=1; AJvYcCUSGXksKZsP9y22A8QC1Sy4BTkvgksTgrXQHYL6lFyK7LOSGigQK7isV0u3Oq9eG+J94sI8pOUTC9KnfsCF7RmAQ3DzzanSWn/9kf3+1LYf4E1QGnMJUikk7ib1fnAM5ODNGeTqNqVmtiPcMLtdQkPfL3c1iIETFxp9eISvYbyhvOiBYwzJoRF4Tfp2CpIqZLzTgfgrs33PQNo6L3cCYTXCOfqEjGMtdkBACuTmqHr75LUBEmnL1iZAnWEke6bbuK7X/xpkRpB8DAMNcgXLdZDDfTwP6JMvu9sgwnOldFg0ulP7IrA/W4LcEQdrcVGgqFW/TyvuiuahKzZiE+9bdWEUzMSjJzxWpzsmzz7sopG7C0UIR06Q+IrHw2eT6FlNFvpfCfiG132A20BT9Yqk1mkEjSnqz7GC X-Gm-Message-State: AOJu0Yx14QdjWHjLcvJXSM+lDxscaKcDW/DTIoMovfTwPfAQfysoFJqt USdf8F5a8G3pGn/WSwYbS54xY52RpRGn5W/XdcWIi64FTv/WcfP9 X-Google-Smtp-Source: AGHT+IHj0NVO2LbmqVwPKLiM4o8xwGtgHAaztxBmavCHO3e8YhM7E9p3r0tm0tYI9onhxvxtZXb41w== X-Received: by 2002:a50:c34e:0:b0:57d:61a:7f20 with SMTP id 4fb4d7f45d1cf-57d061a7f8cmr36144a12.3.1718719237717; Tue, 18 Jun 2024 07:00:37 -0700 (PDT) Received: from [127.0.1.1] (mm-167-232-122-178.mgts.dynamic.pppoe.byfly.by. [178.122.232.167]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-57cb72da156sm7731278a12.22.2024.06.18.07.00.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 07:00:37 -0700 (PDT) From: Dzmitry Sankouski Date: Tue, 18 Jun 2024 16:59:56 +0300 Subject: [PATCH v3 22/23] arm64: dts: qcom: starqltechn: fix usb regulator mistake Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240618-starqltechn_integration_upstream-v3-22-e3f6662017ac@gmail.com> References: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> In-Reply-To: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> To: Sebastian Reichel , Bjorn Andersson , Michael Turquette , Stephen Boyd , Neil Armstrong , Jessica Zhang , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lee Jones , Dmitry Torokhov , Pavel Machek , Liam Girdwood , Mark Brown , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Krzysztof Kozlowski , Konrad Dybcio , Chanwoo Choi , phone-devel@vger.kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, linux-pwm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1718719185; l=1140; i=dsankouski@gmail.com; s=20240618; h=from:subject:message-id; bh=bJDbtUbL+y5wg/waQs7Lp8AQgTgkl1/W9/LG9VfOOh4=; b=vQvnoeSWgPz4eSKFu+g3ROb/3wWMV5zcWLBJBEbi09PSN9t4bbEHIOEE3tV5BtVu/RZcsInhL 2HFncvbDEwDAvdoxgn+AsxypoVxKaQ9PVyDF809mOr1KJqn/aQULMnK X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=6pMMVVDDReSiRgPCbMOUauN5nS3ty4Sf5b7a2gi4x0M= Usb regulator was wrongly pointed to vreg_l1a_0p875. However, on starqltechn it's powered from vreg_l5a_0p8. Fixes: d711b22eee55 ("arm64: dts: qcom: starqltechn: add initial device tree for starqltechn") Signed-off-by: Dzmitry Sankouski --- arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts b/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts index 578798704577..bad154b1e894 100644 --- a/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts +++ b/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts @@ -126,8 +126,6 @@ vdda_pll_cc_ebi23: vdda_sp_sensor: vdda_ufs1_core: vdda_ufs2_core: - vdda_usb1_ss_core: - vdda_usb2_ss_core: vreg_l1a_0p875: ldo1 { regulator-min-microvolt = <880000>; regulator-max-microvolt = <880000>; @@ -148,6 +146,7 @@ vreg_l3a_1p0: ldo3 { regulator-initial-mode = ; }; + vdda_usb1_ss_core: vdd_wcss_cx: vdd_wcss_mx: vdda_wcss_pll: From patchwork Tue Jun 18 13:59:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13702416 Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.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 F13531A2554; Tue, 18 Jun 2024 14:00:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719244; cv=none; b=Fh7LFtKx621sxGVo2elyxiUZFEAyzCr9HB00gKMlj4bVsOUBmORTgrCaJii5QDoDlhIO58MGzsv9mkVua+PdhgpsTctpMdVwI5g+ZYjYbsOkgpte+Z7kqllic7BVtqvgnvAbMLu/xDQ6B2Rdyu+0n77xucSMx7c3IFhxHEcmdXs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718719244; c=relaxed/simple; bh=ZW5/h6ouVrrBXLRGXUEoLufARTLrpkHg1IiP7Xktm9k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Z/aD/rXCwkiN9Tz80cajk4ttruVip3lOy5phcEIJDKTjoiUyQ6YPYMMS8l+SjJEEJES6pM6qGjfWuke8GCgbQEMCCHg/E73lGu2tDNeWDzDiK1c1DM5D8r3amCKueA2AUGs3pfeuta7SLzmdaEFa/hpowpDCgW5cESDCmdIdtaY= 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=U0QlxwI/; arc=none smtp.client-ip=209.85.218.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="U0QlxwI/" Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-a6efe62f583so550785766b.3; Tue, 18 Jun 2024 07:00:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719240; x=1719324040; 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=QnGqb9LdUpFo9CK6p9zAXnt5zDSobIuIEOWLz7JLT7A=; b=U0QlxwI/tihEiubah6Vzp1+ce+sVmwEPPKIGRk1FzOj6z2B3dP+0WAzIO+DQWj7n4k 6czhZuYAuJdWFM84YjSJ9QaT/x74YiXel8wJFEpkiNiqUACGgCj1YXpSsCtY9cRAWIUY e6FAoYIAllNiGalmOkgfJCQVdRVFGA0vGCeZM47HbDK5E6e5EObyzI8COWBEv2LgTPzw MhwlAMW7NDUvwNx1CCcBq6pDK/jXOvWvkoNYqKtM39AagBMeWC4r8R8WZ4ZNhTqWUxMM 9DSyY4SfY3at608x2wVXvYr/JfH9e2oz8L2vBSoF9Egwk/oLgdIh5fGNY6DbhKFmsLaO ITqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718719240; x=1719324040; 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=QnGqb9LdUpFo9CK6p9zAXnt5zDSobIuIEOWLz7JLT7A=; b=WlXPFtUOCN4kEIGNxR1GVk9RTvJgqxXqFRI0Q/l+84c7MsZFwnxSgsKjL/XtG+Cqro lol5nJaZ5geVIWf9d9sx+uViie40UZ9pEPd4gm1Zbf/hOplAGAgaejDa2EwwubZLoXRC NwzNHG0TctFefN5IkXdDlORdaZfU5f1UVUj8RQSpWBKFBrzzsjjf0xeAyuBFC1du1vZZ bklbEA2XBxEnRLmFHJKeeH6u+AEz99urTK8WQI7H5ya0kVTL4LE5EdKVcSzCVp8WjJ/y xmbHTBf0kWJFaKRJ3CRXbGYvgNpNfs4oO9IvwQC6p4WUYRKkPO3Y5pveRlYcjCIcCcZ9 4MIg== X-Forwarded-Encrypted: i=1; AJvYcCUOzjm0syPWD5FEPaA++GS9K7ojk7LxQK4u7B86EyIQPhzUMy2jkgncCLqI2eAXEAS1gif+kQJ+E4kPecp10PCEIcK0ct0yvYgL+zU6VJ2SGK+JUKELMnscFXoYl6lenVOGOhjGwpkRhygN0/pIS2iNIZl1I55cNrkYba8y7fCzHKpRolRDumJi2Q11jrMfQNljJadIv6v1gyntvVkKuPHLBiMRq0VzMZg7NAzqCtMyz7zZyLJ6ch3DnO6Z3nPDMaHN5uBxq8fKBp6P12n7d1BZAQ3SFYR/ukprnnu3kQgA7NU3NA/g84l7sHr/wKwixuMc5eeVd0pbu0COgWCuPfqAPUl1VjRsJl4Vgdc67x+HQA4Jqr9k0ahs8ssCn/0hUDH2x0TeBfK/xgyZ5BMd6z82+SGTJuAV X-Gm-Message-State: AOJu0YxTvrqxaqHM+QSw2ms0edPkGMdvSb3IX/Lrz9IWJvNlZ3RHtr6D EYx80do7iaXmUj4kPg6uRfabsW1g88euqRYk18j/2eLrshhQHTZA X-Google-Smtp-Source: AGHT+IGPPiSPuLy3CAfkI5tf48nr72YmeYQ5pug2vxNgFfhWd7s15QYH+/yq15N13UcYtqPTSjDbdw== X-Received: by 2002:a17:906:fa92:b0:a6f:15c9:9aa3 with SMTP id a640c23a62f3a-a6f60de1b3bmr859682766b.67.1718719239981; Tue, 18 Jun 2024 07:00:39 -0700 (PDT) Received: from [127.0.1.1] (mm-167-232-122-178.mgts.dynamic.pppoe.byfly.by. [178.122.232.167]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-57cb72da156sm7731278a12.22.2024.06.18.07.00.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 07:00:39 -0700 (PDT) From: Dzmitry Sankouski Date: Tue, 18 Jun 2024 16:59:57 +0300 Subject: [PATCH v3 23/23] arm64: dts: qcom: starqltechn: add new features Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240618-starqltechn_integration_upstream-v3-23-e3f6662017ac@gmail.com> References: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> In-Reply-To: <20240618-starqltechn_integration_upstream-v3-0-e3f6662017ac@gmail.com> To: Sebastian Reichel , Bjorn Andersson , Michael Turquette , Stephen Boyd , Neil Armstrong , Jessica Zhang , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lee Jones , Dmitry Torokhov , Pavel Machek , Liam Girdwood , Mark Brown , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Krzysztof Kozlowski , Konrad Dybcio , Chanwoo Choi , phone-devel@vger.kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, linux-pwm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1718719185; l=14368; i=dsankouski@gmail.com; s=20240618; h=from:subject:message-id; bh=ZW5/h6ouVrrBXLRGXUEoLufARTLrpkHg1IiP7Xktm9k=; b=U7LweIymrYPIlyG7gXxJdMjzBRSF9CyuuijIHSfWGI1INzjWG3kWUggSD713gpauIFc9HFIJM 6Vq2DvNHAp8CkSNIR6sq7/le6ye4aYaxRLQkXGrquoTHhCMCM0ZuPpm X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=6pMMVVDDReSiRgPCbMOUauN5nS3ty4Sf5b7a2gi4x0M= Add support for new features: - sound (headphones and mics only) - gpu - panel - buttons - MAX77705 MFD:    - charger    - fuelgauge    - haptic    - led Signed-off-by: Dzmitry Sankouski --- .../boot/dts/qcom/sdm845-samsung-starqltechn.dts | 593 ++++++++++++++++++++- 1 file changed, 592 insertions(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts b/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts index bad154b1e894..28a5210e22fb 100644 --- a/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts +++ b/arch/arm64/boot/dts/qcom/sdm845-samsung-starqltechn.dts @@ -7,15 +7,40 @@ /dts-v1/; +#include #include #include +#include +#include + #include "sdm845.dtsi" +#include "pm8998.dtsi" +#include "sdm845-wcd9340.dtsi" + +/delete-node/ &rmtfs_mem; +/delete-node/ &adsp_mem; +/delete-node/ &slpi_mem; +/delete-node/ &spss_mem; / { chassis-type = "handset"; model = "Samsung Galaxy S9 SM-G9600"; compatible = "samsung,starqltechn", "qcom,sdm845"; + aliases { + serial0 = &uart9; + }; + + battery: battery { + compatible = "simple-battery"; + constant-charge-current-max-microamp = <2150000>; + charge-full-design-microamp-hours = <3000000>; + + over-voltage-threshold-microvolt = <4500000>; + voltage-min-design-microvolt = <3400000>; + voltage-max-design-microvolt = <4350000>; + }; + chosen { #address-cells = <2>; #size-cells = <2>; @@ -59,9 +84,199 @@ memory@a1300000 { ftrace-size = <0x40000>; pmsg-size = <0x40000>; }; + + /* The rmtfs_mem needs to be guarded due to "XPU limitations" + * it is otherwise possible for an allocation adjacent to the + * rmtfs_mem region to trigger an XPU violation, causing a crash. + */ + rmtfs_lower_guard: memory@fde00000 { + no-map; + reg = <0 0xfde00000 0 0x1000>; + }; + + rmtfs_mem: rmtfs-mem@fde01000 { + compatible = "qcom,rmtfs-mem"; + reg = <0 0xfde01000 0 0x200000>; + no-map; + + qcom,client-id = <1>; + qcom,vmid = <15>; + }; + + rmtfs_upper_guard: rmtfs-upper-guard@fe001000 { + no-map; + reg = <0 0xfe001000 0 0x1000>; + }; + + /* + * It seems like reserving the old rmtfs_mem region is also needed to prevent + * random crashes which are most likely modem related, more testing needed. + */ + removed_region: removed-region@88f00000 { + no-map; + reg = <0 0x88f00000 0 0x1c00000>; + }; + + slpi_mem: slpi@96700000 { + reg = <0 0x96700000 0 0xf00000>; + no-map; + }; + + spss_mem: spss@97700000 { + reg = <0 0x97700000 0 0x100000>; + no-map; + }; + + adsp_mem: memory@97800000 { + reg = <0 0x97800000 0 0x2000000>; + no-map; + }; + }; + + gpio_keys { + compatible = "gpio-keys"; + autorepeat; + + key-vol-up { + label = "volume_up"; + gpios = <&pm8998_gpios 6 GPIO_ACTIVE_LOW>; + linux,code = ; + debounce-interval = <15>; + }; + + key-wink { + label = "key_wink"; + gpios = <&pm8998_gpios 19 GPIO_ACTIVE_LOW>; + linux,code = ; + debounce-interval = <15>; + }; + }; + + i2c21 { + compatible = "i2c-gpio"; + sda-gpios = <&tlmm 127 GPIO_ACTIVE_HIGH>; + scl-gpios = <&tlmm 128 GPIO_ACTIVE_HIGH>; + i2c-gpio,delay-us = <2>; + pinctrl-0 = <&i2c21_sda_state &i2c21_scl_state>; + pinctrl-names = "default"; + #address-cells = <1>; + #size-cells = <0>; + + pmic@60 { + compatible = "samsung,s2dos05-pmic"; + reg = <0x60>; + + regulators { + s2dos05_ldo1: ldo1 { + regulator-name = "s2dos05-ldo1"; + regulator-min-microvolt = <1500000>; + regulator-max-microvolt = <2000000>; + regulator-active-discharge = <1>; + }; + + s2dos05_ldo2: ldo2 { + regulator-name = "s2dos05-ldo2"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-active-discharge = <1>; + regulator-boot-on; + }; + + s2dos05_ldo3: ldo3 { + regulator-name = "s2dos05-ldo3"; + regulator-min-microvolt = <3000000>; + regulator-max-microvolt = <3000000>; + regulator-active-discharge = <1>; + regulator-boot-on; + }; + + s2dos05_ldo4: ldo4 { + regulator-name = "s2dos05-ldo4"; + regulator-min-microvolt = <2700000>; + regulator-max-microvolt = <3775000>; + regulator-active-discharge = <1>; + }; + + s2dos05_buck1: buck1 { + regulator-name = "s2dos05-buck1"; + regulator-min-microvolt = <850000>; + regulator-max-microvolt = <2100000>; + regulator-active-discharge = <1>; + }; + }; + }; + }; + + vib_regulator: gpio-regulator { + compatible = "regulator-fixed"; + regulator-name = "haptic"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-boot-on; + enable-active-high; + gpio = <&pm8998_gpios 18 GPIO_ACTIVE_HIGH>; + }; + + vib_pwm: pwm { + #pwm-cells = <2>; + compatible = "clk-pwm"; + clocks = <&gcc GCC_GP1_CLK>; + pinctrl-0 = <&motor_pwm_default_state>; + pinctrl-1 = <&motor_pwm_suspend_state>; + pinctrl-names = "default", "suspend"; + }; +}; + +&gmu { + status = "okay"; +}; + +&gpu { + status = "okay"; + + zap-shader { + memory-region = <&gpu_mem>; + firmware-name = "qcom/sdm845/starqltechn/a630_zap.mbn"; + }; +}; + +&mdss { + status = "okay"; +}; + +&mdss_dsi0 { + vdda-supply = <&vreg_l26a_1p2>; + status = "okay"; + + panel@0 { + compatible = "samsung,s6e3ha8"; + reg = <0>; + vci-supply = <&s2dos05_ldo4>; + vddr-supply = <&s2dos05_buck1>; + vdd3-supply = <&s2dos05_ldo1>; + te-gpios = <&tlmm 10 GPIO_ACTIVE_HIGH>; + reset-gpios = <&tlmm 6 GPIO_ACTIVE_HIGH>; + pinctrl-0 = <&sde_dsi_default &sde_te>; + pinctrl-1 = <&sde_dsi_suspend &sde_te>; + pinctrl-names = "default", "suspend"; + + port { + panel_in: endpoint { + remote-endpoint = <&mdss_dsi0_out>; + }; + }; }; }; +&mdss_dsi0_out { + data-lanes = <0 1 2 3>; + remote-endpoint = <&panel_in>; +}; + +&mdss_dsi0_phy { + vdds-supply = <&vdda_mipi_dsi0_pll>; + status = "okay"; +}; &apps_rsc { regulators-0 { @@ -355,10 +570,72 @@ &qupv3_id_1 { status = "okay"; }; +&gpi_dma0 { + status = "okay"; +}; + +&gpi_dma1 { + status = "okay"; +}; + &uart9 { status = "okay"; }; +&i2c14 { + status = "okay"; + + pmic@66 { + compatible = "maxim,max77705"; + reg = <0x66>; + interrupt-parent = <&pm8998_gpios>; + interrupts = <11 IRQ_TYPE_LEVEL_LOW>; + interrupt-names = "max77705_irq"; + pinctrl-0 = <&chg_int_default>; + pinctrl-names = "default"; + + leds { + compatible = "maxim,max77705-led"; + #address-cells = <1>; + #size-cells = <0>; + + led@1 { + reg = <1>; + label = "red:usr1"; + }; + + led@2 { + reg = <2>; + label = "green:usr2"; + }; + + led@3 { + reg = <3>; + label = "blue:usr3"; + }; + }; + + max77705_charger: charger { + compatible = "maxim,max77705-charger"; + monitored-battery = <&battery>; + }; + + fuelgauge { + compatible = "maxim,max77705-fg"; + monitored-battery = <&battery>; + power-supplies = <&max77705_charger>; + rsense = <5>; + }; + + + haptic { + compatible = "maxim,max77705-haptic"; + haptic-supply = <&vib_regulator>; + pwms = <&vib_pwm 0 50000>; + }; + }; +}; + &ufs_mem_hc { reset-gpios = <&tlmm 150 GPIO_ACTIVE_LOW>; vcc-supply = <&vreg_l20a_2p95>; @@ -373,14 +650,241 @@ &ufs_mem_phy { }; &sdhc_2 { - pinctrl-names = "default"; pinctrl-0 = <&sdc2_clk_state &sdc2_cmd_state &sdc2_data_state &sd_card_det_n_state>; + pinctrl-names = "default"; cd-gpios = <&tlmm 126 GPIO_ACTIVE_LOW>; vmmc-supply = <&vreg_l21a_2p95>; vqmmc-supply = <&vddpx_2>; status = "okay"; }; +&i2c11 { + clock-frequency = <400000>; + status = "okay"; + + touchscreen@48 { + compatible = "samsung,s6sy761"; + reg = <0x48>; + interrupt-parent = <&tlmm>; + interrupts = <120 IRQ_TYPE_LEVEL_HIGH>; + vdd-supply = <&s2dos05_ldo2>; + avdd-supply = <&s2dos05_ldo3>; + + pinctrl-0 = <&touch_irq_state>; + pinctrl-names = "default"; + }; +}; + +&adsp_pas { + firmware-name = "qcom/sdm845/starqltechn/adsp.mbn"; + status = "okay"; +}; + +&lpasscc { + status = "okay"; +}; + +&wcd9340 { + reset-gpios = <&tlmm 64 GPIO_ACTIVE_HIGH>; + vdd-buck-supply = <&vreg_s4a_1p8>; + vdd-buck-sido-supply = <&vreg_s4a_1p8>; + vdd-tx-supply = <&vreg_s4a_1p8>; + vdd-rx-supply = <&vreg_s4a_1p8>; + vdd-io-supply = <&vreg_s4a_1p8>; + qcom,micbias1-microvolt = <1800000>; + qcom,micbias2-microvolt = <2700000>; + qcom,micbias3-microvolt = <1800000>; + qcom,micbias4-microvolt = <1800000>; +}; + +&sound { + compatible = "qcom,sdm845-sndcard"; + model = "Samsung Galaxy S9"; + pinctrl-0 = <&quat_mi2s_active &quat_mi2s_sd0_active &quat_mi2s_sd1_active>; + pinctrl-names = "default"; + status = "okay"; + + audio-routing = "RX_BIAS", "MCLK", + "AMIC2", "MIC BIAS2", /* Headset Mic */ + "AMIC3", "MIC BIAS2", /* FMLeft Tx */ + "AMIC4", "MIC BIAS2", /* FMRight Tx */ + "DMIC0", "MIC BIAS1", /* Digital Mic0 */ + "DMIC5", "MIC BIAS4", /* Digital Mic1 */ + "DMIC4", "MIC BIAS4", /* Digital Mic2 */ + "DMIC3", "MIC BIAS3", /* Digital Mic3 */ + "DMIC2", "MIC BIAS3", /* Digital Mic4 */ + "DMIC1", "MIC BIAS1"; /* Digital Mic5 */ + + mm1-dai-link { + link-name = "MultiMedia1"; + cpu { + sound-dai = <&q6asmdai MSM_FRONTEND_DAI_MULTIMEDIA1>; + }; + }; + + mm2-dai-link { + link-name = "MultiMedia2"; + cpu { + sound-dai = <&q6asmdai MSM_FRONTEND_DAI_MULTIMEDIA2>; + }; + }; + + mm3-dai-link { + link-name = "MultiMedia3"; + cpu { + sound-dai = <&q6asmdai MSM_FRONTEND_DAI_MULTIMEDIA3>; + }; + }; + + mm4-dai-link { + link-name = "MultiMedia4"; + cpu { + sound-dai = <&q6asmdai MSM_FRONTEND_DAI_MULTIMEDIA4>; + }; + }; + + mm5-dai-link { + link-name = "MultiMedia5"; + cpu { + sound-dai = <&q6asmdai MSM_FRONTEND_DAI_MULTIMEDIA5>; + }; + }; + + mm6-dai-link { + link-name = "MultiMedia6"; + cpu { + sound-dai = <&q6asmdai MSM_FRONTEND_DAI_MULTIMEDIA6>; + }; + }; + + slim-dai-link { + link-name = "SLIM Playback 1"; + cpu { + sound-dai = <&q6afedai SLIMBUS_0_RX>; + }; + + platform { + sound-dai = <&q6routing>; + }; + + codec { + sound-dai = <&wcd9340 0>; + }; + }; + + slimcap-dai-link { + link-name = "SLIM Capture 1"; + cpu { + sound-dai = <&q6afedai SLIMBUS_0_TX>; + }; + + platform { + sound-dai = <&q6routing>; + }; + + codec { + sound-dai = <&wcd9340 1>; + }; + }; + + slim2-dai-link { + link-name = "SLIM Playback 2"; + cpu { + sound-dai = <&q6afedai SLIMBUS_1_RX>; + }; + + platform { + sound-dai = <&q6routing>; + }; + + codec { + sound-dai = <&wcd9340 2>; /* AIF2_PB */ + }; + }; + + slimcap2-dai-link { + link-name = "SLIM Capture 2"; + cpu { + sound-dai = <&q6afedai SLIMBUS_1_TX>; + }; + + platform { + sound-dai = <&q6routing>; + }; + + codec { + sound-dai = <&wcd9340 3>; /* AIF2_CAP */ + }; + }; + + slimcap3-dai-link { + link-name = "SLIM Capture 3"; + cpu { + sound-dai = <&q6afedai SLIMBUS_2_TX>; + }; + + platform { + sound-dai = <&q6routing>; + }; + + codec { + sound-dai = <&wcd9340 5>; /* AIF3_CAP */ + }; + }; +}; + +&q6afedai { + dai@22 { + reg = <22>; + qcom,sd-lines = <1>; + }; + + dai@23 { + reg = <23>; + qcom,sd-lines = <0>; + }; +}; + +&q6asmdai { + dai@0 { + reg = <0>; + }; + + dai@1 { + reg = <1>; + }; + + dai@2 { + reg = <2>; + }; + + dai@3 { + reg = <3>; + }; + + dai@4 { + reg = <4>; + }; + + dai@5 { + reg = <5>; + }; +}; + +/* Modem/wifi */ +&mss_pil { + firmware-name = "qcom/sdm845/starqltechn/mba.mbn", + "qcom/sdm845/starqltechn/modem.mbn"; + status = "okay"; +}; + +&ipa { + qcom,gsi-loader = "self"; + memory-region = <&ipa_fw_mem>; + firmware-name = "qcom/sdm845/starqltechn/ipa_fws.mbn"; + status = "okay"; +}; + &usb_1 { status = "okay"; }; @@ -408,9 +912,45 @@ &usb_1_qmpphy { status = "okay"; }; +&pm8998_resin { + linux,code = ; + status = "okay"; +}; + +&pm8998_gpios { + chg_int_default: chg-int-default-state { + pins = "gpio11"; + function = "normal"; + input-enable; + bias-disable; + power-source = <0>; + }; +}; + &tlmm { gpio-reserved-ranges = <0 4>, <27 4>, <81 4>, <85 4>; + sde_dsi_default: sde-dsi-default-state { + pins = "gpio6"; + function = "gpio"; + drive-strength = <8>; + bias-disable; + }; + + sde_dsi_suspend: sde-dsi-suspend-state { + pins = "gpio6"; + function = "gpio"; + drive-strength = <2>; + bias-pull-down; + }; + + sde_te: sde-te-state { + pins = "gpio10"; + function = "mdp_vsync"; + drive-strength = <2>; + bias-pull-down; + }; + sdc2_clk_state: sdc2-clk-state { pins = "sdc2_clk"; bias-disable; @@ -439,4 +979,55 @@ sd_card_det_n_state: sd-card-det-n-state { function = "gpio"; bias-pull-up; }; + + motor_pwm_default_state: motor-pwm-active-state { + pins = "gpio57"; + function = "gcc_gp1"; + drive-strength = <2>; + bias-disable; + output-high; + }; + + motor_pwm_suspend_state: motor-pwm-suspend-state { + pins = "gpio57"; + function = "gpio"; + drive-strength = <2>; + bias-disable; + output-low; + }; + + i2c21_sda_state: i2c21-sda-state { + pins = "gpio127"; + function = "gpio"; + drive-strength = <2>; + bias-disable; + }; + + i2c21_scl_state: i2c21-scl-state { + pins = "gpio128"; + function = "gpio"; + drive-strength = <2>; + bias-disable; + }; + + touch_irq_state: touch-irq-state { + pins = "gpio120"; + function = "gpio"; + bias-disable; + }; +}; + +&qup_uart9_tx { + drive-strength = <2>; + bias-pull-up; +}; + +&qup_uart9_rx { + drive-strength = <2>; + bias-pull-up; +}; + +&qup_i2c11_default { + drive-strength = <2>; + bias-disable; };