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: 13702975 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 11B6CC27C4F for ; Tue, 18 Jun 2024 20:22:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8F4E410E7AB; Tue, 18 Jun 2024 20:22:05 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="LGDyoUFe"; dkim-atps=neutral Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) by gabe.freedesktop.org (Postfix) with ESMTPS id 90ACB10E0C3 for ; Tue, 18 Jun 2024 13:59:51 +0000 (UTC) Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-57c714a1e24so6222807a12.2 for ; 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=lists.freedesktop.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=LGDyoUFeEfqXd4JN1El1MrQnCskAmp8lx0XRpKBPPjdpJSawmKDkDn6hnYVJxaCrut RXXnwjfaLwJX1B0sp7zX7t9+zrNj/YHzyR1arMX7maOmt3OIyoOlMe06HEb07nC/TdJZ ecGclSAJQmi4mniwOxioH/F7OVtV+mQuSQi4SCj4hm+j9CIkVQ5dWZa2poIzuq22OUrx R45+Ls548y8JgvV8m41f6AoYf8/pH4dAAmgBStGmLA2JXPZsiScHMXPXqFkUY7dCkxTX X91xH2YKPpOHRrS7Ev5b4w7CV3I2OKQRJY5iI5IjYg8Yay1GUnAoKz44njsB3TQX1Lrq 5h1Q== 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=hOp1cd9FYcskNImiqezWcf/nYGDzS0xpYTgbgxQPu1J8NMD4aNLDoX+4cwlp++7vGj RZkzAY+50A/eTpmNe8kM3y0Yg6L/rl4o5xlRQeWRwKhOWlOzJJkJ47F9ThInLxXHJOWn ckzP7qwHCjD/sXN20AT1mJllhff9Sz722YNyE+fFTRr2C/vP9n7CymOONgZ4q7Pj8XvD A6oJUJqAryrRIpFa+cf+VtVxyWP9EbAYA9wfbSx8fDB0WwYpTrT2G3xMgjIoobbSXiIz kVYzYO0pYm3rmhy4EU5o7ACqnpmKxsyu/kXp8CQwzfPmUanllOuzBtIUWEZ8oZLy3rrR vS9w== X-Forwarded-Encrypted: i=1; AJvYcCVep5mYLGIRZBcOIcLdFsaUr/bPTKrKpbtOS3f3e/pe2aS4C07LeOEv2603QUFaBkLLNowu9jB1ov94S6IoqFurqX7QRTM/KggVVViOpvh9 X-Gm-Message-State: AOJu0Yy6fRmy72Y/4VMkyz3EmZqiNuZci5aSXox7aN8xCpij6cNIEfiu N95YF5vrwIEDBihAxLcZOvvpe+yuc69/F8aKNZNhkJnY10vasUBFO9jGujfW 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 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= X-Mailman-Approved-At: Tue, 18 Jun 2024 20:22:02 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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: 13702979 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B3508C27C4F for ; Tue, 18 Jun 2024 20:22:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B826E10E7B4; Tue, 18 Jun 2024 20:22:07 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="EisF2AC7"; dkim-atps=neutral Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) by gabe.freedesktop.org (Postfix) with ESMTPS id B4CA410E0C3 for ; Tue, 18 Jun 2024 13:59:53 +0000 (UTC) Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-57cb9efd8d1so3665891a12.0 for ; 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=lists.freedesktop.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=EisF2AC7id9cTG5NoxaBrixjUADbIFJ1B/2Du+RoM2fw9h/toa11zMP4cl7eyWTAS2 naKbOHQIt3ZCJvPuRy4N6saErbIo0q+bpiGggnZuTmIqtloIwgmPOCMVp34bqFtswU6l CrtSGKz5Zfb3yPtZlfhiA0/yUiRbGFdo+X5LiJ/acfjWlXKpPUialxcbHo1Vg60E40F4 7yu3nOs8uwvOEv9mxGWuAepI8QCIjSpE1Q3qe8BtJtXpR+O5ny7pbFFCF8G30PJc12NH UlDGofUG9WPkCQMpo2lBZHYK8u26/qq5RicTq0dE9vzfqPN8fFkw1/02p+MI8T0xeoa/ UZHQ== 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=gmDz56uu/6LvchYtqK8OBnN4qaaHtOoVzzNsJuJ++eJeTRiP+7Wr08gb+9sM0M0Sn5 RBuP/7qjZtjliTf23KLJxJZREJORqaHWELPOLGrtNlJ4rBu44Q5MlXWRTpQvQbhErFEo VWp3nDV/7SnmFNWXPtCmJPwLaADrGooHGNz8VvQ086TOsjfgjX0jiWw2CyisecwEbUBP CxxnvtbpbruxGGAAXYVFxOtZ4PPpEF7fwFr8akhsp5c/WL51NZH04b10wVCXscSenCUt LCaykV254oUeDXIHH+CE0Je8JS2RNJKa8QcPSXiK0IrMEbP4wE+/thuoibInziPlVxXZ s4MA== X-Forwarded-Encrypted: i=1; AJvYcCXiXwuQof9hL/CodjfYQMTUbQrI2sZQ6/c1mLJ1XfGaNc5BsYbdBU9Ex5cK2c4e9EdpXB8F0gFZiFyk2FYhwAVpgP2+3oY4SLHOZlwsiddg X-Gm-Message-State: AOJu0YwdlJfIsT3CbUW4A95LtpyVXGm+jUcZoAGXuXeZ5qH4mhV+yQdZ 1IeJBJfKw6QotSZ1r091H3BbbKyWCwChlUcjsAQD/EisVnvumlEhlH1RE9yD 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 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= X-Mailman-Approved-At: Tue, 18 Jun 2024 20:22:02 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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: 13702987 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 61253C2BA15 for ; Tue, 18 Jun 2024 20:23:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7CEDB10E7BB; Tue, 18 Jun 2024 20:23:15 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Gc2pI1ud"; dkim-atps=neutral Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) by gabe.freedesktop.org (Postfix) with ESMTPS id D006C10E0C3 for ; Tue, 18 Jun 2024 13:59:55 +0000 (UTC) Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a6f1f33486eso336534166b.3 for ; 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=lists.freedesktop.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=Gc2pI1ud3JY75zcSXuZM5e8VFGmIVF1Fig96WT0LiioiM3govOilTm2w0S/eW/k/sQ R7qpVU6DZm/b7pMQOHGubSa2Nx2BtEEoIWFeWfGnhrEWFQyhbc6gys76q8FdranrLPB1 RGoVo0FZ97fTROkB7xvGRaHnzF/Hd23LUGiPujBmDE93MWm0d4Ok4ywM5Zx1yXBnG/DC mVrZaC3L7650S9Vv19cTw/4ovKTfBvbAwmG9LvdvCerKtFwDjFdIiPvzdsDzUFzpZBSE eNiI5AS+8MjFC6yh2cm55lcl3TcJK15pEkrDu/lbH66TiinwlvO5+rodCy19b+ASulNu ds8Q== 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=Sv7QKPVecLT48912qU2e87VqIXc/eGxpMAEIt4cMKs1T6jBriuVDXdV1sEBlscUsAy KMfvptoBDQs43e7eeqvHyn07FOgfGWdRrKiX3jH70qTtebgHI6UhDVzcfGZJXZZk2899 +vSisFQ22OGcPV61hFQCr0Jlo12Vt9SVHQ0dhQRt+sjdMacyaIgwqnnJS8McpiKUNQhT 7UR+3Jwc2R7n3YaemLppxqlrZM0XMgiLk9eNlam4Y5mIvoD4BzfvYssfLY+YqV5Hvvsw B0D4l9+mNwa1gIE8cCjI1v6gDkwAhA2GBcl21EJoOZ9tc8C7JWNfl0XC/SozFRZNfjZa rBUg== X-Forwarded-Encrypted: i=1; AJvYcCVSOBTKEbeGGH8lTAl3hkc8x/s/uPd/c60mbrymAlxHaFu+kOMrp3pmWUUPKa/2ALoXS8G2iWIcKhMQjhpNnLuuWkIEEbdAmq7K4ZlZX6GT X-Gm-Message-State: AOJu0YzPS5ro8e7ejCb3fVFitJCiztz2ao7uNtcpLfe82N94xBjaqoLJ 4jxLbTcM8adKC5LdqLzDFPGhU4T4lLwtUe4f66vNZ6z68Ks+WZC52pS+kgMh 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 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= X-Mailman-Approved-At: Tue, 18 Jun 2024 20:22:02 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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: 13702969 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2CBECC2BA15 for ; Tue, 18 Jun 2024 20:22:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EA71810E798; Tue, 18 Jun 2024 20:22:03 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="VNYoApD8"; dkim-atps=neutral Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0535110E0C3 for ; Tue, 18 Jun 2024 13:59:58 +0000 (UTC) Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-57c6011d75dso6699196a12.3 for ; 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=lists.freedesktop.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=VNYoApD8luD1k+2OCW/ZhiueGjlilFXfn3GbXH7DIyjT8wFSCUnuFPaaWUvyWkHdn6 Z5LcfrVD8BwtPKYuHlBk1S/Q89a+CkLo/7cH8XJxT2IyIfDllwW+Ygq1WR2SYpa7bAhj FchDf/loNYKjOFD9RNRiRIK0uObbzBtBrChMeia/9eA3NHLU3gwHDyB3ULpAxV6x07P5 QJDMifD6ts4+rWL4D2hpFl1q0PMVN9+xwyf9lISVQZsx1JVClGadqI8ncfCtblfIYIX3 RX196dwh902hDmsQsxn+xDzaYaYkDCOo9NzAJU8wt68vsBZJFtr3A4+nn5K4mPvcsaCz ndhw== 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=RoMpkMVf6np/P4GyA/r4+1RNVL+pGYW6mP1S1/tKxwQfK4kSvKBKMd81I4oF4hEgA+ y3D/vy4IeOy6OVvNjlJ0SPvAQjEQgQ2w9SpImEWK3Ewc2pWVEej2RwRntp5SiwmYGqHZ aO/ldQHNT9EK7NhypyXPHzP+stWagUiUYKziERe6IjEzY8mwsJnDx6F+bWoYBH5XOA55 zDsyXsuXbY57/ywgQ5KsdfYEk7tLOf6Ln9xzThBH6yIyTTv6XZMznebrUPVZmd7Olyqs BHwiWDajEiLyp4+vLrdqtrOIgt0r7qC77sTbFalkmWiS+4yJ712XmfZla7dhlFz1SnOk vLFw== X-Forwarded-Encrypted: i=1; AJvYcCXw+XQHlhHM2XRCen2/gwLN1TgRD+0WGUgU7Euz+egZeAr2DBq5fzzzhVmU7tWbOHA/TD7aTwnzIWQVMeID650FN21NByIq15C5cV+EebOj X-Gm-Message-State: AOJu0YyPS/Bh8vnosuRl+OyOXluXLVPZB2oN3/p4abMHYUp/ykx1tuZF +4RMZYGR4+Bjw/Qc5msN7apAwDrlSSTDVoWXQATsuxWCw3/HmvteUt9z+mWr 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 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= X-Mailman-Approved-At: Tue, 18 Jun 2024 20:22:02 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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: 13702988 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7A384C2BA1A for ; Tue, 18 Jun 2024 20:23:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7AEC510E7BA; Tue, 18 Jun 2024 20:23:15 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="AuxoB54y"; dkim-atps=neutral Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) by gabe.freedesktop.org (Postfix) with ESMTPS id 424D810E68A for ; Tue, 18 Jun 2024 14:00:00 +0000 (UTC) Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-57c76497cefso6477381a12.1 for ; Tue, 18 Jun 2024 07:00:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719198; x=1719323998; darn=lists.freedesktop.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=AuxoB54y/BkCa1Nc5lFxomgH1ILqwNnBhnrmq3Jxr9NHQWpvyEiZVpkQijzVUYliH5 Lds3+ZnixkFKgzbbNHEfWlHEbDE28QEcuwAv5PUIQUP9RkMAxRYcl9xYqUCwA/n99xvd kJ1tQpB9YPBOxO3+YJHcAnOPlnQ+EkX7HVWJJW8fBgBD5qZPFTDQPR+hj49amRXkxnp1 ul95dh7O4NIZrsXJPYR0REHWdsj81ooOYbYmhb5QVBLCagOasGdC1egBteago/yewQsY kjUok0UE0DEiOjjDWjQA8yrCxlriYAqAysxcX+12LIhyuL1oLCDOJf+AF1ndExLeD2S/ XMnQ== 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=k9sy6MzOURd+rnbZaHdi8mjv5+4a7CLIMQ+UPCLQ72xvywsLURvDkfQoM2o2uUD1mE fU6QNtXSsPkV1334s96IY1KfHnlYBdJLpIS+KC4ai0XhY6PqjULRA+ydrQA5KE1TY/pY Ql7znxLZJExk+FX8IMkihzaMPfVp3n05LXsx8xgY0Q3A0wzli/LhSJ44f4bTwCacOEL6 YCbeQDCJIvlH0z57MXZycaVUJn63qxgGVWCx/+UjdaTwlRa5aXzceOVQ+uNOWG9ze/Ew qlebOBQ9I6zOhekEUVLof7laeowvTDUsUUnzC4JMMwzhmZJK9mG73EX24c1dcomAT8ZF m5Rw== X-Forwarded-Encrypted: i=1; AJvYcCUO+OOhaFASyLm/IEijDy9OdRGFmUGqcpLEiLDqhuu6yxOr7PDm5j1oAqnKMtlcCDtqK+7nJYs71S58LAypNVFesTk9Q6lN6Dm3nKfyd8lB X-Gm-Message-State: AOJu0YwNNtxL6XkHiAjN2ZEg0CHio8YvTsBeTK1lgDfN4qPt5Wj/R5AB eW1N39T5MxeLUyIEXRPIndi4NgyerPFJw2orWMgCG8J8qfU/GvGxP8VknKe7 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 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= X-Mailman-Approved-At: Tue, 18 Jun 2024 20:22:03 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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: 13702989 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4637AC27C4F for ; Tue, 18 Jun 2024 20:23:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6CD7810E7B9; Tue, 18 Jun 2024 20:23:15 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="GGgSUSqp"; dkim-atps=neutral Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3DABE10E66E for ; Tue, 18 Jun 2024 14:00:03 +0000 (UTC) Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2e724bc466fso65303341fa.3 for ; Tue, 18 Jun 2024 07:00:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719201; x=1719324001; darn=lists.freedesktop.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=GGgSUSqpvA+rHt2usX7tK76Qnndnls1EMdXEyjLYplgqHtRxhJsZxCjUxtFExFHeti M22+8ooXemx0LzULLcbwCpncWpL/2uPIx/CAfFQOVVFutmn8KrvUYAc3UhCe839QlFO/ nj0/Wq5orG/dhlUlh4hKJ0DLmi+I5ibihqn2ckhxZcOKUpmi4W1r0Y4O3qmGV8wW1GI3 od+52Mbu8KyxRjyNV6cYyMgDs69axkfjkCQZc98hqlWqWfJwaUayMylWxW7+ty1lA7Ye BU6WK7k4d/30Z+mJyAIrHsFQrZNZaNVixGTSBoxJ2orAy8dWoXTvUPgljGQ8vWxv6lPR dYfg== 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=NK6BEiVVjQ4Zev07jCe/CiCXO/Xw0UMs3gmbBFFAfJOOOYL7VpXGbqlOfL9h1ojClv noekvCVHHFcBkhdsnPKVG97WfaVb/G9PnqoqNq2e99cfEGJSW/92yghiV3906POeq+Lk 9hsfUUfcVEOAt08hdyd4Iedd7sjfrrgzFumXoffty7VmKK50wiK17tM5hKoD5iDmMbll 3Y5locssWK8DcYcmcMQa2nIlbSGnEILFVuu5aKp79T05MzdfqYfyzT8mlOZfbYHR0Gzu hvB1hB2HoHiCRU6ccZqLQDHFLTJ60lNuNQquMmjRnaVZ2qQLFShEwQhd9LpwkiJW14TG c17Q== X-Forwarded-Encrypted: i=1; AJvYcCVbPonX3MLsoaqMxFogf7oPPVBe2fPrr/NLf0TSTt6ppxsnJLK6fSTI9/Rk0XqOJ/136ogM12qRmgqt0p3fXmrvXtp3Eg7pE8L5vaHfjkZz X-Gm-Message-State: AOJu0Yw4YJHIVjhtHLv/fPH2SQFnlxMNrgn4xz6Mbbdc15mXKWmPQwli +l+3JTAwRuYm3t85oXU1FgE3deiWpTb0l2hcOxm4ttBnyhvhdsFUlWEBDOwK 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 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= X-Mailman-Approved-At: Tue, 18 Jun 2024 20:22:03 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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: 13702971 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 61A9CC27C4F for ; Tue, 18 Jun 2024 20:22:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B636110E7A5; Tue, 18 Jun 2024 20:22:04 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="dDLV4KfE"; dkim-atps=neutral Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 04F7E10E66E for ; Tue, 18 Jun 2024 14:00:04 +0000 (UTC) Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-57c83100c5fso5996511a12.3 for ; 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=lists.freedesktop.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=dDLV4KfEK6KRt9bl03HIs557pzXwFReE5J38ZIVdidFq2zEJFF/pLeBFnlvxavXe6l fJL5DShPot56oC9sWR9ZFSlQ6++xjV3pL+hfuoyN6Rwn5HTyxDqfsSLe/4BOjXVgcPhR sjZ/u/cXx0Exn9SiBa++mcW+csc9+ddSTWIxsiOw5K6D5H80ZD3XbZpGvSja66oVwSUH gkWSt4W1rs36IpxkhqarNZPVNXEeD0rbEeFUGs4lylJT6Gy8c58iq6djvDOMQUjQ15EF 3ILJC7gb/UNuStKZyioF40vRLEMk5PM31P2gHalHodFRJk4bo9/IAte4LiCoe0Pj+zP1 sBuQ== 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=uO8/tfjnM5TjANf/6WeHoIWK7PjAtpbvFya2kzt+qK7+TLcnWeNH40ul0IshLt/Evj tJ6xcK4BCb5RhDNa1tLCi83W6PM/fCxlwVuGn2O2peS+8QwE3VtJRfjAGyXkCwGNbUJJ uZ5TZxMmazrApbXlfmoNEjC64hp0aWJnq8FzUJhd+GwpyBKIWd69p3TG9G7V2y3UiqYL N3tpmR8NIQdCwpkY7bGJyP1BzNMHt8sTxwQqsRrMN0sXQyuF9mnVjsxcZvrIJxE7Obxq sLm+E62HL1VzSmEsdl/pDVUr9zkNo0cF4h/o1DUc2df/cDz2/29KOdWnzAMSaLyHMY1p Ocxg== X-Forwarded-Encrypted: i=1; AJvYcCX0zToKAP967oEwGGwbqTsoc43UvkWJ1vrouFTvYmWDq7XkvZI7iqRGmM/qnOxd88M2f6MbTuUzuvZ65IPIYRWimnsBgNwy/rHVr+Pwt5pY X-Gm-Message-State: AOJu0Yz6HQn3yKa5RiDZ3gc2Zj3qWaT38OuVlKrBQMn/9x/8KTC4Sqhv sfA65Nbgg6feEQm4wwyHEqXVfKd8+9Xvefp4cEzJHwWxCO+x4mYuuIIptUqN 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 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= X-Mailman-Approved-At: Tue, 18 Jun 2024 20:22:03 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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: 13702985 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D7391C27C4F for ; Tue, 18 Jun 2024 20:23:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CEB1D10E7A4; Tue, 18 Jun 2024 20:23:14 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="b8hR7zqU"; dkim-atps=neutral Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) by gabe.freedesktop.org (Postfix) with ESMTPS id 19D3A10E0C3 for ; Tue, 18 Jun 2024 14:00:07 +0000 (UTC) Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-57a1fe6392eso7346561a12.0 for ; Tue, 18 Jun 2024 07:00:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719205; x=1719324005; darn=lists.freedesktop.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=b8hR7zqUW2zfjyScjNDX0LuCfmHiEVcpQGggBQ3Qx7qPpVJj/L/JOAxpqV9zdua/qf ypy7N5Y0FuV4q/vpr4zBmHYICr1XDV72l9BDG5mhtM29JWgFPQqTobQch8+Bi134hL/y O9u8NQXq4uyQO9BdgW5g+MUSK+yvvs6hFJvMQC9NgRUiYhU24bUF63rfMFlQ8+dFVex3 ITGuxlg47j3KI5CnuBHix9lP0B/d/Za6mMfjproqXoo7hlDKmfWCR1EhvqYnrU1/9mL4 L/mnfoe4EwhBcpQkzW0QAPRYiYuVHW99kozva5aygBoicva6rkM9oEhDENFSFPtpq0Jj 3VXg== 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=d7MLgogtymkIfweKHULp7Bw93m8uOVuWyEkjuo2hr8Hyu9hAkYYvxNgyyHKLNG7Ras as6IfL+A+/fJsFI0FruHjU1cOXd3uMd2cLsfERIpvKn+JIIVsN/dxUnKJnFmr5lnfImm ZDrOh7DhHCQxENvHLQkmEXxYHf6gLGN0J+HJHKzZ6pASMB+eylZwNAF28GyqqBNDNjiU WnlrsSdK9R11IG0J7dIMvJmNil59OxdofnsGwJ2S12mEz1LPJ1Fxxq8U63OSnAXCeVxP 4KJUEEckUn0XVnXQ/xTcblOudX4OjR0qDSqTo1QaMWaOaFruuji/X+oYe9yOCH0QvC1C sznA== X-Forwarded-Encrypted: i=1; AJvYcCUd84nedaDrKw1iNK10b8UGBKSEZwuTUwLkHrE+JOVhYJEFPhL1lyW/WGiEW3rroY8a9cIoxdBPcsQTq5N9tQFZyDqR0AvluaY1nUkjtvOd X-Gm-Message-State: AOJu0YyXgeNzJPuBON786HEQlQo4/0GxOYqZbYTuUdnW8oXdmvsMrTZA RrmC8x0Iuv0oen+UBqOaPE0fAgWYwbMrvdFg+zsafvWYQpMS5fREznjgvcaO 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 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= X-Mailman-Approved-At: Tue, 18 Jun 2024 20:22:03 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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: 13702978 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C5802C2BBCA for ; Tue, 18 Jun 2024 20:22:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AE84A10E7AD; Tue, 18 Jun 2024 20:22:05 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="lShd6aWD"; dkim-atps=neutral Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) by gabe.freedesktop.org (Postfix) with ESMTPS id 52DDE10E66E for ; Tue, 18 Jun 2024 14:00:09 +0000 (UTC) Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-57c75464e77so6758009a12.0 for ; Tue, 18 Jun 2024 07:00:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719207; x=1719324007; darn=lists.freedesktop.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=lShd6aWDE3Rslyz6Jl1ot1WCM/OeoP07aQYw8d24I1lSPh4yJV2LsAB9LyC8ZTO7Cg 3VgGBmut1jnNKZnas9+4X7awp72eDFnsP6r7L0oO0K61Dv3CjOag9pJcY0Kd18HRjSPt 2hBg0W4N2Geb6+u371nnphG7qZRYmpaL34phomgh6roeCHdHRqDfpZe7EKUDVvz3Haj0 RdOZAldiqH151wPeygCG+iOC5KTBfflRUleMPlt3s5lDIR8YB+DaWNe2vMVWiPrKwy/E xHpCfHNZdUG5BqsOo57QCitUnx6n9Y7HfyGplMLSC+hZokFmf+7kZDJ04d3rb/wh1pVO 5HAA== 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=b6ZFXVhl1sUPAnroxPN66VJTMvCpE5Pp2Of7zv5pnD03Gq/C6OCQ1sgvL4UGrE7LSZ n/IgmIRYThs8CDQNeCPYX4YmyBzMVRI662lnFtzWQ37aLfRYdI5Yx2dBoYreSIKOE4Ra kIZ/p5i4RcEmCE7oHTlNaSV6yQvS+hP/00GZdnMHzR6oX3sRZhMll+r5FrYOGpx2p/Q4 p2SI2k2W2QNn621OwqXd05cgbLhoJvMKLHaYneiUaY4aYmzEE+CvVkFS5Mgo0CH85NeT 2Tm7hSIb3p7t8YPnOSQEVJIi5oO166NP4QCJ9rLV+t49sVFnntgZ808+SJWHPOw73dBR AYVA== X-Forwarded-Encrypted: i=1; AJvYcCVktC3s/mVVyLaKsJtaz8DWV83pEiJmXVT4Kda7zb5H9HtZdEHBnv9ac3I61WnMo/JoHMFZW7gu6Tok1o97J7rMGUZ4ztQKZe95kO5OnomE X-Gm-Message-State: AOJu0Yz6IHIB0brO3ogdpcUM2RTwSWgr1avPgjymaZluXKhWGMyDA/wF CnxPE3qlYAsz7X+aGQ7QH91XiFvbff5vpug7BU96mP+GRCSd6XYpbyQ9m8+y 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 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= X-Mailman-Approved-At: Tue, 18 Jun 2024 20:22:03 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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: 13702973 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BFA09C2BA15 for ; Tue, 18 Jun 2024 20:22:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7C17F10E79F; Tue, 18 Jun 2024 20:22:04 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Wqi6PAlQ"; dkim-atps=neutral Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2A33B10E0C3 for ; Tue, 18 Jun 2024 14:00:13 +0000 (UTC) Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-57c76497cefso6477747a12.1 for ; Tue, 18 Jun 2024 07:00:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719210; x=1719324010; darn=lists.freedesktop.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=Wqi6PAlQhBLeSHkerrdUu/8fTNB52H9z7gCAE1RFGy1Sfy4lqIX/rZ0nnfA4NRpJyW 2NX6EsbhCZRfUsyaJGJQPyT2Mhm14zINr9OWyIf/XaM2LA/byqcERWohZcQnsSMv/+3S Cnzj42F8Fqj4ZtjOG9BS/Cui/4LCm+3VGgdnmFDewq8ANrxWLd75P6S5PJx7hiD1R5At Sq4mzPvxnuUsHyhSM0BeSF1B06FnujFvHalptsjHsJ8Ani9QcOF4DmCnYFl1EJdDf7Ad vvjkfA9FPkKJ3KylnrxTjAhxB9gCKmEatQgFvWK58K4JeM3NnXZ7jyCUo8I8X6udrAHC lG7Q== 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=KCCay9BOhiB/78VrDVk3+5VolNt5nM4F/W//14F6mFv4gbSln9iet6gEOBQkoc5nGY lHKsLCLeibCQoQMZrpjdIYYLeM8LHybS7mbzVX9y5ZvP7mKbEKyjtFPHVxuDgIyEyvTn XlWBlO+LVRo+vj60Qdt4B6C2RB9xyWHmZ6VF+6I8MVyjzhrtScpsIWY7KK+pbVUuSCWI QeRPyfVPqSNRQjl49tiYL5UBoat1tjCQPfjih9EvCDJsn2HhtT9oZwPnJrnk4hQTo6rn iG+FMsnKmw1sTUmGpiKy016H6oe1xIIMk3am4CSpiwb7OjSEkUWdownLtfEJ2jAwiZsD Lumg== X-Forwarded-Encrypted: i=1; AJvYcCXtorzEoFOARQOI5vZSr7psPrx1CHJSQujoABqNwiWn8nKxXn8vUY84ZM08whSdlwrGyPHX70Yc7j+URzeLWxtR8xNfbUwSrhvdQU2aWcjY X-Gm-Message-State: AOJu0YxSLoC2OJwmN5Ong/9R3iry/ruLQv+yKjsAR0LNr0GfoUMJORA6 WLtt6GseAFU+ny3Jg6YmHea9HmYbU8LEtLpgSdKHhaoQKI6qHtOsn8CC7S/p 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 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= X-Mailman-Approved-At: Tue, 18 Jun 2024 20:22:03 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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: 13702981 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DCDCDC2BA1A for ; Tue, 18 Jun 2024 20:22:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 29E5110E7AE; Tue, 18 Jun 2024 20:22:54 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ADoVsEFz"; dkim-atps=neutral Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) by gabe.freedesktop.org (Postfix) with ESMTPS id D472010E0C3 for ; Tue, 18 Jun 2024 14:00:14 +0000 (UTC) Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2ebed33cb65so61952521fa.2 for ; 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=lists.freedesktop.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=ADoVsEFzGX/UocpDJRx/wmdwjOnn3GU2lX0jmkkto6d7AWQWXmYvFwtareIkfY6sV8 4BQxJeMnntv2AdtxCcLigZhMKodildeP56PYuODFFMp+l1aI2dry9Tw0Q1r6BwB5qUqT 238xIOXk6KHaNkFeYT53rKEk2sPZp1Cx/IZdIY2NVrj9ceN5lrPfxY5J2Np8/AR5ZBbz /Bx7urq0ay5FWD5mSdqErFpARsFeLSQTUN46PFtvpt65mQTP0bf8Mm9FXlmsP0Xr8ZSl vw9FbflI90Rweh3mcO6Ab5BB04Zm/N5gcOlOPAHWo6Zk42R14MqGmXn9yirxRNzNva2F GlSg== 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=EJFDba01FZVgi75cPFEN/FHS8Sq1YLFuKWOJiS2Cbgq2FoCPtCSOiG7K6AqtWz8Glz w2W3y/wSSyEaxd+TH1jhqzRh9zno2aNhpMs0b1Z2QW2xdFVpWIO/0RGf53f8oFzFFUhx T1GUr+i3VBl/UMLSR0I+9453AVDo1l8VpenIz5mRQDHg8Y/oSAIr4s/J4cFfFp+GhkC5 /TOaKUMDs26d/MZPdbixyE+DgY0cqcWhAQVDOYQfpjQXA4xZcJuIYYWleg/PDhxnFoaV 4jpbrKrCcTKcqPi8CM3XApSAMO4hm3pVEFe8sMzzbhK8FVo5nvOepSfb9Tdm/x9y5Os0 WMXQ== X-Forwarded-Encrypted: i=1; AJvYcCUP+PHy5F3MeEJcv0zgL69qBy8+oSXcfaQs0g7dnHHgHYRV9/2Z2nZGNTABKBqAbqr4fnZ75RNYIV5zhvc6NvtaD4Hko529zQ8O3/hzA6zV X-Gm-Message-State: AOJu0YxFZ6Cfi6/gu9Co0aYtrOMWXYR2ihFZrb/WnIk4H50VVq16Otq8 5qsDz3mDOOMiSls9QyUG116JV6sjdCRMHDw7/b4oYzsFuOHOOjYoEjsX20ij 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 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= X-Mailman-Approved-At: Tue, 18 Jun 2024 20:22:03 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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: 13702991 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4D7FCC27C4F for ; Tue, 18 Jun 2024 20:23:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B6BD810E7BD; Tue, 18 Jun 2024 20:23:15 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="YUTPicyB"; dkim-atps=neutral Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) by gabe.freedesktop.org (Postfix) with ESMTPS id 32A0B10E0C3 for ; Tue, 18 Jun 2024 14:00:17 +0000 (UTC) Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-57d05e0017aso46820a12.1 for ; Tue, 18 Jun 2024 07:00:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719215; x=1719324015; darn=lists.freedesktop.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=YUTPicyB96eECwZVczFinhvcKWTpUxxBiQo3O/oi1YcacrerIIZLskxVcD7/oh9ENv GS2meUheW0ILno+aSoIuv2wcnKg6w76LQIEnc6ZnKYqvvFND/Qi7yL2+9kZ3CgdREh7W gA13J5p/q32yVvyVCjh9t2uHRzi8Qi5nzrruORtbdtk5qXYxZq4UGUefYudg5OlHj3l2 Wv1v8aHgeFRaztK1goR+ACPyHWQCkBnEEYw//B/EkmATlDyLTn6D2jtWc/6/cjesuNSJ YnUenfvZT1xFrdQ/Ohp6+aBMDIONQgF65kDcFygYBamoB2bkgaf4fTkQacArW0APPjt6 BFgA== 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=YpMgvPrBe8sUsg/H+ZxDg9mY20eJYGAtnTtNxsZtWwaumgWtJ1YuCF3HDf++WnfCU7 AiwTplaue30VchHacJKRlzx58T6An/ceWAskM4o1xJrbvGLbqzzKpyh/auTLx+3TrWI5 YXi3XdMRKPzD3hT5juGfbNe5UGphfDMiNwBlGl5ARMKFtyKsKrtaGO9cOmbIW+SNzgAE zVIiUC7DgmOq3ozLDY3vF1vDYcZQvmwK2qmAqdyBiqdrAl1+Xx2JJ7R5qlesfLiHK9Gf 522+B8PCn7g4X02s8qfNpYdzdGvWDQiSB59gBrspZ8JO3aAAEe1vHh8TPDzxL9CwBVFW X9aA== X-Forwarded-Encrypted: i=1; AJvYcCXqcpFCsfIUALSj/cP2Mgs9+U3Kkq1JGg8N2GCCGwigM1MmxFJ1YjWMkKDejPDQSVnMqPdgDESxbNb/HAtvPoMh2MzDkd9AorFyM3yX+2e4 X-Gm-Message-State: AOJu0YwvcYSijA75D7F6FR0bfBrPebVqm+sHCCQYQb2IJ+2wwhjsIGKD dkU3Xj+rVnrqQwCsWLWILw0Ak2DBvBiVF3iAWjBE57FkMUqmwNVcV1CFwl7h 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 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= X-Mailman-Approved-At: Tue, 18 Jun 2024 20:22:03 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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: 13702974 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 16A86C2BBCA for ; Tue, 18 Jun 2024 20:22:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 023CE10E7A8; Tue, 18 Jun 2024 20:22:05 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="UeiLeDAQ"; dkim-atps=neutral Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) by gabe.freedesktop.org (Postfix) with ESMTPS id 877F410E0C3 for ; Tue, 18 Jun 2024 14:00:19 +0000 (UTC) Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-57a1fe6392eso7346860a12.0 for ; Tue, 18 Jun 2024 07:00:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719217; x=1719324017; darn=lists.freedesktop.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=UeiLeDAQOgcIXrf1phpFgLNyolU+AEVfT/yhIHkonmBLgxp104VH0VQ47FWdibwDGf YMU3RO3nQErlWu+U7XHWkGzhjZupibctFBEDoBWGQtJOWaX+hXDk3EjHXR1aHiJwBMzW qePcYgVdv3q50s6xqetsH5aW/HsHnGtYf5fucsye5v5KByCl2IPqEvvrpiSKc2Adx8+D R/eEcc72WcL/eOPIPpIxO6KTBH903fSzTBlFWH/qU+E259DjMmL78IAO6g4qV83K8Y5c lhu7Z8EkTi33jAHc507p2fP1GmHh5hXVtY912tYzwADMwlr3noiJEsqVYtVTTnQ0wd66 jFIA== 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=St8Pe5VU2irOxGpOLJTKoK3bXKC/LEGvCnIPjo4w8AsY9+dFU2hNg4XR9AufkkXQVz 6F3XH47V/4yMXSlxXeTB5GjMmfbkL7OU+CjwRX/CB7cI0uR4yBm2b50izpp4KgKl8+IF eRBinGNzY01301pZzrQodpmmGBTNfgcF4a9dsn82ed0NK1JDVxkN3kBhhrQ6tg5vbR7C bBetg1F+CfebzT9YETVYA2QftuxUrRLIuQ3qDQtCvS9uRO4mQdaJPJFeSgg9+h4eW6N+ ao71/+rKQa3gOU5AufJfps+oTmm1ufmRbemxI4BPK7SedKrZ3O3HPhnPbQ04yQt4wyAk oLMQ== X-Forwarded-Encrypted: i=1; AJvYcCXL6A6SGIepkroy40bBjDG3SPmbw6Lc7uZWo6V4n/NtrNU5aoSdhE6kg+werEXFTx4yRddO01R2PIGTlBEHL3/4eIChV9eog0q6GhkZxftR X-Gm-Message-State: AOJu0Yya8iNSsSrwBQ9X9RH2V2D8cZS2PViA5XZk4s2/txjKvyFYsUCK ITr/ZiYcE63/28BJrJ9h1HujTqiCwowqxjqosHqe+2Sh68aDzWrOzTypymfx 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 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= X-Mailman-Approved-At: Tue, 18 Jun 2024 20:22:03 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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: 13702990 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 40B26C2BA1A for ; Tue, 18 Jun 2024 20:23:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F074510E7BE; Tue, 18 Jun 2024 20:23:15 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="iB3FJ96j"; dkim-atps=neutral Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) by gabe.freedesktop.org (Postfix) with ESMTPS id E5B9610E0C3 for ; Tue, 18 Jun 2024 14:00:21 +0000 (UTC) Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-2eabd22d3f4so65210471fa.1 for ; 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=lists.freedesktop.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=iB3FJ96j4Jx//0vX4j9F5/xwEoArWzRxA2org3fcvCeBGjiHgKnD8Hm0SsngCfbVqp tejokvJD4GbRhwoCpPR5ePXW3ITutUP5KBs9Nhb2Sd2gGYQbEQy32NMHO8kk5FgvYlmc 4v6NCodm0bYtjGr6CJbRFGqy+denL0AqIeBiMYryX63fK7+iZ4Y3g+bkqQIx2M/Jtyya qcmBgg12JpwAuKNK2NhZOduPwDwMSOSSf9guG9GkJFQTtlOrVdABFlJkdw4yncWT7rS1 DDtlRafR89rVhiaejP8j8ePMCql2wyRt4BF/NICtfaDXnkXCEentBKGrzfJ6CBZUd0PV 9nYA== 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=uxMFkc/kmcSiBkzDsdeFKEjs2gJ3MQ84EZQOZUBoYJ8WVLxJjMF1CipYRoWyVGaoWL AhVXNYgp3UNUthrIi2HsT4mgWKCryGYXjZ7lOHxX8nvze9BvK1YMm3gQToa+uaaZvQgn ecJu0MVjzEKL9FDcTew7uNv3fdPwotHeErsBya16dVWO3n/b6DU1OCo6ggXB2Qje2G9x cpBHjYt2trwr1/lDwJ0UrnwYCgqB5jtd3w8JwZQZmG1+EOUD9/OT6N9Uq5DPRfX/ltS/ C7abQDwF1Kl6+tBDrSdXGpXrJi83xQhAkefJEg3iMdO97kX20Vw5VWBqQvWzt9TW6iQQ 07+Q== X-Forwarded-Encrypted: i=1; AJvYcCWp9WWaZDXeciKIPfVfdcEiXXcX9sP0XZP43IejWXrrcT2+h0xgCp8tPo6a9f+bSONS52UC2voeshLX5s90KQ6DqFoCD8moIeKtw5/t261E X-Gm-Message-State: AOJu0YzsXV43hEtTvUeXT5JjiOcV4jzc3eaVxWwQdNBwiZtn7JJOhgIR PnctiRlH52EFim3TcsjjnmvT4743c7OeayGEaEh13tC+wJdx9vEt27r8dQwJ 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 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= X-Mailman-Approved-At: Tue, 18 Jun 2024 20:22:03 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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: 13702972 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6D029C27C4F for ; Tue, 18 Jun 2024 20:22:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0EBE810E7A9; Tue, 18 Jun 2024 20:22:05 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="gvnqaDQ5"; dkim-atps=neutral Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) by gabe.freedesktop.org (Postfix) with ESMTPS id EB6E710E0C3 for ; Tue, 18 Jun 2024 14:00:23 +0000 (UTC) Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-57cb9a370ddso6246121a12.1 for ; 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=lists.freedesktop.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=gvnqaDQ5NJjjPFISLQ9r1pa5Zll/ajF8LsCJvtf3dMKSjxIezyo/C3K+WkhMzwEHNd JrU8hnOzKHoMAfyGiqOxlv8tJEuzn29VB65AQifjvxqhcmKtVvAof71uhCVv+Y3INDtR /nzsVODS5CjjbTEjdB2+vaXnvtH4Kz2MnnDLxFnWHNy7x0Mpzq+p2yG6/9332EJHtXTH fm3jpr/L9bafXTGfmOP8zhkLTIOOLGgGWJTS8E1mQhOKJJVCytmhgvUzTHZhC2JhKshN FbBXDzieWUq+ObiCGpdiePNBWel55s9K7GT3BKzxfcFm387GY4XHhhNLk0AzDrImUWp2 4bnQ== 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=Zy58o3/jZR0a1jfivv+9y/ItJPOFZXKL4gkcqgfkZdTOy5d+zgcqZf8QGsRKu5v6g5 8SBaMcB74KG/2+9dv+A58fAD5NNC1jq33c+JQrM1cE9ToPn4gGlprY3ICB5a7ozWOR9V vy5eJzbM5S7TEkSddvMoOeiW7J/Ybjxc6snpl3lZ+VQDFKar/7mM3I10lTGq0ZOcmtGO 379L56CPHVt8iwLk/Ab1it7RlpZANv5+bTClFa3IXVn0UQbpeLGANo9k3oE4atznpxN3 3RhmFEL2bGc8SZZiwzpnbS68zgTCkPs/p4KK85NDJFJEEU4aJ4MP1qUvyeOuMOW/cSEs KD0g== X-Forwarded-Encrypted: i=1; AJvYcCUTdjMN2y1RNOQlCtvJINcXQ6q9oxPx14QlI++eO7cCmF00uBm7Vd7IXmtpbyZOrCH/5JGzovnrSq9x8B2KQkRxJMmCTiADhukX26CAGxMZ X-Gm-Message-State: AOJu0Yx1XexAXDyWyOkQ3ZgXIabWDoMB55vLvhQf7ueIm6L22ywO/N9i zfk10bUIOlQg7Js1K7UgOQuY5+PSjss+y6U9i2UAZqnuuaxmjmO6Qe8sSwrA 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 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= X-Mailman-Approved-At: Tue, 18 Jun 2024 20:22:03 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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: 13702992 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4DF55C2BC81 for ; Tue, 18 Jun 2024 20:23:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A5A5210E7C7; Tue, 18 Jun 2024 20:23:17 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="OH6GOAKF"; dkim-atps=neutral Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3CD7910E0C3 for ; Tue, 18 Jun 2024 14:00:26 +0000 (UTC) Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-57c83100c5fso5997091a12.3 for ; Tue, 18 Jun 2024 07:00:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719224; x=1719324024; darn=lists.freedesktop.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=OH6GOAKFZeF1xg7GayIHyC9MInd8JUrx8WTIdR/QSPhyauTZm9fwGJU6O+hALlcK4i 5tcZ82UC5QxNoQGbXBsLJpmBLX+pyzmAVopr9xMqje8USUqdKVMyV2XjsLfCU43XM7HR /VEku0/9PSm++iwoqhRPPk1H3eJZ+faBDwXD1DfH1NM6snU2KXwduPkg5Txv06uuvlIq 1QF1TCnQtB8/VS0MXnmGGqAvovvDZkxCT0ZgUf42Xq1RmCiAfEI/z89egfemrBMHQAfc 32q22y3hEhm0r/WpiRbyKeLtzpZNGXr1m7ys6nGMwU6fWGCpOmSnxDUj/U4uTAo986Zp lucw== 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=WeJsh/5Jmjsz6ehIM87Tvdl2e1qkYQscvFW2t9VG4xq4OBqX5kdWyWBLyAF7vdXIAQ Rk3vK5/4dIluFIVsgaAIvwfSnIVNMmPOc4SI/uEvutoxbplMPgC5qC2AoTR4+jEH3pQM ALwtxi1wfsWla+CyJSa/e7eAQKc5oZvM11wuxthbjKwFvUl84TAe4qWerkGRzqDROFI+ 00S9ngzhe4oueRUO9rW7SrIqgMbQhRPBW6ioCCGDqreHw8L/TxZNV3dXlijHB3TXz5T4 0/X8yEEvESS3EbgIdH/wse+GaUJyFXcUaE3+NQN3GA2IW4rGnOFSrWFEpT173BJm7u+H HU+g== X-Forwarded-Encrypted: i=1; AJvYcCVOqXKyOfoTugfQsha2P112PqEcmDS7bnCo34Ag8lRbeEXU0Sv2UU3pbOqng9EWUomTftHsX0xQKUhSGUsHU1WMa9xyTfCjrgTT7X50rM0M X-Gm-Message-State: AOJu0YxwTqA/nLFyXFfDLlsmZBegEAuRIS46d2D2HvLgGhWHqL3ABbia b3X8eOSUDAEL3WTcXKezDXbSlmlzfxLXCUlKmZF+jjdAUCcMSI/FiJMz7lgU 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 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= X-Mailman-Approved-At: Tue, 18 Jun 2024 20:22:03 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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: 13702984 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8D3B9C2BA1A for ; Tue, 18 Jun 2024 20:22:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C00F510E7B7; Tue, 18 Jun 2024 20:22:54 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="X9SxgqIo"; dkim-atps=neutral Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) by gabe.freedesktop.org (Postfix) with ESMTPS id 81B4E10E0C3 for ; Tue, 18 Jun 2024 14:00:28 +0000 (UTC) Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-57d046f4afdso268526a12.1 for ; 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=lists.freedesktop.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=X9SxgqIozdercT6iUw6kyr6tk6F6O0WgdOReL7lH4hkVDDBU0DJQSk66a4ZBLWvUPE 4qCGlPrTN2L21tetIUX/6ahwQ2IlX1Yt4kaIDAUJAusKyKuON+MU+dtRfr15lQl2m9SA noYI5R19jRew48e79pkFLgsdgYkMUYILZleoTcQLEcjBTObbcJYZ9jrWa0uggDUiilnk sMs4hZMKjqM8WrNi7oWMt+nzCoT83wltfubcdOlObmeLaOgpta2UBun0tF5/xx/ECYbf kLe7jtO2Fvw0sSn6w9megFssWQGuEMG9tKQoz8Zn0eKXJoGGX216GWV492hJkm0SH+JD w23A== 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=t8YhGLK4hSVm+i2lWXLRDcFvMXozJMRfSh5WbrpESU+lQoKoTIwofhhUGKwCPv9Jbk vihAyCfECbBJ/72ti4YAlkMwFnlNB8JKgeGagsAO3dHkqwJxBtYSDfd8HRMe8+rdhgN4 vwHVZ0DE6qnHAFCSxB/3JtsDUUTEWLGulonEVvTQWotLAhh8Fm8eQKD2f6tUFRpcG8b8 Dgkty2vabGMowiBNWOqETY7zkWwdWpbYxjyijn/Lnlew4SZWv5cy15FWYJiSGg6KJUbD HmePE7igEA+vFiABZWauBvnV/xpCkEdnLi3GpCo8Mo0e3rrFu4ipIpQF2BJf9b9IS+3n k6Gw== X-Forwarded-Encrypted: i=1; AJvYcCWadNv2zT2DJMV5DWEPUvmJ2q5ueJft94xavvjtzBgUqq8hma1Ub4cIYj3X0/3M1ErFcMSlOUhHH49CYFWC0xnMFxfwu2+Sn1AMMyhzN5Tr X-Gm-Message-State: AOJu0YzPf0KsoDVVWnbBZNgz8c+zGG1UdPKimpEcLoMQbcuhWUy9IAq1 GT1thLJ9lVZ3w8tD7xFfSZGqXb9IMDynigpbThJP0ROhFNDEgSKALafMag== 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 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= X-Mailman-Approved-At: Tue, 18 Jun 2024 20:22:03 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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: 13702983 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 227EDC2BA15 for ; Tue, 18 Jun 2024 20:22:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4B89F10E7B3; Tue, 18 Jun 2024 20:22:54 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="BQDS3JeA"; dkim-atps=neutral Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0BD8F10E0C3 for ; Tue, 18 Jun 2024 14:00:30 +0000 (UTC) Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-57cfe600cbeso767769a12.2 for ; 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=lists.freedesktop.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=BQDS3JeAr9CPatxMRNExJqg/60eLA5+/55sR9mfhPJBMwCsrCCQEc4n66YIKBvZzdu ZhOl09LpDuyfO531IdDbUrANu/g7lDoDr6Us93FISYFaIGuF8s8RI8WyRQFHO+KU25y3 q8NwPZoX6XtzEj7dFZnrxCkgkkmR5dZXOEsg8D3Zmzm4l+2T0bWzDxj/SyQMZQnaYAgV X0Kpp9x82JggkloLcUst5fa+oRmuLbCxXsufyLqFEClXZb/dtGgZgstENlKCLQmJuQUp JRovQlPGOD85a0DM7urywxQMVwE8GmiogWgIFJtXnlaMVnDm4EAVZvVaYrCNltJcwWIE qc5w== 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=wxH2BKbO14xZAgktjDuD3oNGRVFwI2LenUXedPPsQht3x1LV40JHyOpgHeMlgb5tIX +7PXu9IuggoF7J692JkGFCS8/avNvqwRZebaxZ42LECLZSuQ+MKMZcl+89TSQfPFwyBl Q4dJ+ngGLzEAF6UW+/QLjB/jDx1q0eOVS5O+qnqUJQQicY+zypkUhm2nPLPETGlBbypV PdVjnPuI+IbzFSdR3nxyfl7rDmNIKATXDCbr79tRzLsDphOd/gz0IWbIHAjB8rf/xbbK FYFYbe7Vn/ZSL1k6rbEkat2r8oDGA5wRNUP5S4yuQbcdunxiZIkLdd9sB8FmG3O1aNv5 ysOQ== X-Forwarded-Encrypted: i=1; AJvYcCU/+zPsCm79JSbeifCzJYpYTpFkJu0T4xCbSE8QiEw/GrKMsQxY5i8XdaSe7icsnZ8EaFtoHQDWYlpXdRamRg1b5lU+JAdu80XePhyGSlng X-Gm-Message-State: AOJu0YxqKtRE/olmdn0fd+fMZ2htDNxqM1l7OcrLFjrXrqdfPPLRersd i6DEyirHgEp55by7NpkPt0V/nASPmnPOeZHeO7vL0yDCCVnIug4qtukWXw== 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 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= X-Mailman-Approved-At: Tue, 18 Jun 2024 20:22:03 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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: 13702970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6F7EBC2BA15 for ; Tue, 18 Jun 2024 20:22:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 160B810E799; Tue, 18 Jun 2024 20:22:04 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Zn6tmmQR"; dkim-atps=neutral Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) by gabe.freedesktop.org (Postfix) with ESMTPS id 27E6F10E66E for ; Tue, 18 Jun 2024 14:00:33 +0000 (UTC) Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-57cc7e85b4bso2284461a12.0 for ; Tue, 18 Jun 2024 07:00:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719231; x=1719324031; darn=lists.freedesktop.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=Zn6tmmQRb248b3tG8uIc7YlZR3hcTfHBaXMFN1TnwCuT+1Va2PJEajPOxWrK6Csilz 2G/WfgoYuyNu3iWCKB9wMwXWfREzGIjrQvUeJOOo4dw8wQV/NFY/pAcCfvjAjGHdWGy2 8+4f8cQ4ihjVPC/+kM7lJizx4SzMu0/SuESm+4eumJGSFoBHpoTwy7UC8aDmNRg8UhJt xLFPlbbtAh4kNSM1368EFtYnXQCTekDVPKhYPaFH/lkWg2WR0EuXXQ3P4ND7Gyt05kUh ONpVs1NIQ8KpoHhaoX7GcE473veCcz58JT/SVZbDauasDHzZIh7PYCG3TBZT9Jdoaifr jhYA== 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=kQXwkdlYxy+MIwZWfzulIPcxCe2cyXrm/eBEAODMCpoThPBlKKl629QBM6ksY34lBR KJG/6JJwOL4vuWA/D82KV3cZgkdk86I8TOUXf7uvfYF2esvqdAM6IRcWW9TtJ1pvfn4L WUJkY2jRnBMd2vX0CvWSb6ZJAL4O3L/NY9+z81/I6+hm68k+P+RmegLg9nPh6VrXZ8Y4 QMj64IEcwltJBhSG3GShYzEAHZBxPSXWSuHcWWLoYgAPgyEMcS33aHAA2GK09Ky+lvI1 FY7gxHofrCTM0dT5uD1VjBxzPIYQT9DKt/H/d9hvg/l+MBudveKo5emM3p8uH29UzV+e evIg== X-Forwarded-Encrypted: i=1; AJvYcCUqlnGha1dkx1U9Zc+L8UTw4kTF+26VGetNB+racmKVj1GvR6BM19hy2Cjgz+71bYns+HoCnew6JV4glhj7IS5WGmpEXUlOLwJyj9kpYtJz X-Gm-Message-State: AOJu0Yy6HcaB2Qna13BUR5DP8110CXkFV0/8pQ9lR3MQ3wk68vEJPwns 5BVIePwS30SWESW4QxQ1cqPI6dEMFhxeXQsAXJaUBfdVRsxodZKIY3Kgfw== 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 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= X-Mailman-Approved-At: Tue, 18 Jun 2024 20:22:03 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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: 13702982 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 03A56C2BBCA for ; Tue, 18 Jun 2024 20:22:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 41D8310E7B2; Tue, 18 Jun 2024 20:22:54 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="jaIDTjNB"; dkim-atps=neutral Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2B81810E66E for ; Tue, 18 Jun 2024 14:00:35 +0000 (UTC) Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-57cfe600cbeso767956a12.2 for ; Tue, 18 Jun 2024 07:00:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719233; x=1719324033; darn=lists.freedesktop.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=jaIDTjNBbqlcwiR/X/XylYwB8/NPfk/Da4sJyXkRPdqqVAAZmeeUAKcs8hCQM1lqzr 46laltApbUTVfXb9Dth/J+l4Ct5by4VMLmc5nmhL+y3OP9NRP9vNJUMe+1vN0b5IlKEE R5LaI1CLDNaf7+cQMiZQQBpo4mcolA+zyllhGUESOCvSmga0alA5pPTvlCP8D6KJgzZe CXfpTmJu76LrC0dTgCbS1A8Zh1zQwwQW+9E6Lc5NCc5i11UYBwNtKrhrxpXhunDcwB1M TPBxxwAc3i5fr4/BhfsgkShklXG04LYvRYEj+0iQ3kxqdRrbPi01IyOC0CNDPa9DP6qV WrKQ== 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=rtfcNvSFOQZ8Kw3QYTK/GWSXoy0bAykDW8wsEphil/VPPKjav6zCuc5WaHjelAUipM Mp4B1lqNH26UzYkr7NpMYOhjFuBC+1UAsZzXUXL/Pmb/zdEhNkiWEEcPOHrcXF2aaItc nZTnS7FApeEbrvaTgz6zmymtpi5BuwkibZUf6rD9WjmoI77n5KiomLTTqyLAXiL80d5a dRedkb1AyHLd/uFbChCN2HniFQdIKZLJgjOfuLfrPoKhn+H4SU0aS6U9e55cFm8tdmrr ftc0c/JsZLul+M0wk2RnLxR82ZbDIvaLjwXtNe1YaCdh3ah4nDjWzq38A6U9y3LHSWMJ w9YQ== X-Forwarded-Encrypted: i=1; AJvYcCUQO8pNmO5FvCGDHHmoR/gowTfg0X7m0zCv+IUQ07PS5ZDV7g4nX0QyW5MNHMgcad1LZUHLS8O1XXg5Xvq8/kbVb6SjblYQkAaxXyZHT/8f X-Gm-Message-State: AOJu0YyKHMlTBebxqvxJ3fWThlks9izcY/NhAJcmFLbiXyH1TA9HK4rD v6LxpJppD7aVJ4emFDgae9otMZAf8j5efqGo3mpsNmljefGN3yoW4yW7yQ== 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 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= X-Mailman-Approved-At: Tue, 18 Jun 2024 20:22:03 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 --- 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: 13702993 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3CB65C27C4F for ; Tue, 18 Jun 2024 20:23:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8914810E7C0; Tue, 18 Jun 2024 20:23:50 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="fSQm+30q"; dkim-atps=neutral Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9E7D010E6AA for ; Tue, 18 Jun 2024 14:00:37 +0000 (UTC) Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-57a1fe6392eso7347355a12.0 for ; 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=lists.freedesktop.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=fSQm+30qd2Z6IKnxGfO5FRYLvC+wYrJFwwRVxs3itaeHGOugBeq0xitqI9kkCwNlnh HpyJGYsMc9i3GyR6q1Oqyd2Y/T2YCdsuPzChHRLac++OmX7EiI0uUck+AIbMiqJFwXb4 5d7hoNIUemuwySPBmbqRldkTMRq9ooRaXTNWoA9bLhjJOuSIm3EZijb0SurzgVYX8sot /eJU2oTsBA8IyRJVk+j6Xt1e/iZG48BXwJfA/QlayMcZhBMdxLuakl9VKDmFfcs7u2RK 0mkyYgxbHfYL1KUumP4Wz/NhXh6CDU/Ls+eIXPiJIzRsnUCbeGULWsB4YM6gWIqKno8E /r2A== 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=Q/gkBoSASCM1QQ9NT01DDFr17ydd6axUqxlMit7DzlrjsZ5b3z2Q5DUKH/HVMHKesO yWJgzGXjZXf+QvExifAj4ewWflz6aTO/P253l3VIPK8xR/Nb0RgLWM3crtxvnwy+9hXT LbthM0aqhinEFPxi392f8KYIW6boSy0NfqumPXUoCVXabpDhJUPz9lFSXAGaUoAw78fg 3GqwrPjxJEtcX5HWLUcpkXSTLGbJnzY00WRpv77q8VtzLg41BzosDlL5OyC0BG0Ckrx7 gDq0trv12p1qn1AAdTDJ1CNk0NZZX+7bkC2/nfFyZFODR6PLPqHFLr7WbfAa1/UQ/Wtf PG+w== X-Forwarded-Encrypted: i=1; AJvYcCV2ZzS5OKbPSY2W/NV/9usfqu6/HJ529NTGNvz0Qc0w1WcI/3vT0zZHKXM9urAYQJ8yhw83hxF8lMTldN2JxYmbUef14h3MqFqsrW4mmsRt X-Gm-Message-State: AOJu0YxUFXIiv+TC3LMPcflCoMBUTSM/Gq4VP521A1bRkCavlUnYwE8D ZoSnCxeUDbxN+JqiFpV4LYhz0/65EM68l4oOcPGYyvZ6tDiy9wfSkApIQQ== 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 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= X-Mailman-Approved-At: Tue, 18 Jun 2024 20:22:03 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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: 13702986 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 40AC6C2BA1A for ; Tue, 18 Jun 2024 20:23:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D3FF910E7B8; Tue, 18 Jun 2024 20:23:14 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="JeQvMPx5"; dkim-atps=neutral Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) by gabe.freedesktop.org (Postfix) with ESMTPS id A172610E6A4 for ; Tue, 18 Jun 2024 14:00:39 +0000 (UTC) Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-57c83100bd6so6736298a12.3 for ; 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=lists.freedesktop.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=JeQvMPx5Lz/rkCtfvSj3Erds7goL14fCpil6qI8Zxpr9iBLiUaHVlKGHoNHZTdLF3/ 7dPcEYPmAZ8KYo5lr+cb09L3PpoatD2T7v2vXwhPP/HorP70GRSIJDecJGFwHqXHoMYl H+KvYni5HPUdJOlBEHYSutauiKmQO0pHnF/MxVDi7ftVYV+Fqfrr9TIp7EiIrUb3fLwe m+PJNZ5A7D5pKXcI8CFryYEP9ZJok/QtQqz9yiC/F/ioxi0P5y9aXdmVK8+H6fG2jZKQ wHILiKv5u84QX5/xjJ5UAXjdzvmArKv7aH5FGcNj+pl+n3KclxhPaetQwXnxMT/FFTd9 JeTQ== 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=mXzBwjlHXSqD/vKYGti473kCmemLuFBHMoLikU9htV92E6jDivwDvjd3xqr08TwZ4n zGEO7DjgvWO/f7ts4ICCcUyInDds0rEP7Nqtc4e36AkJsS+7vYJNPnKrqrbU3MCQwDo9 snzaje/V3sjrhMdF4syB8u4hkPFxgaGIv/3cYLMDFcFy/0P1c8O6tXRy7XB8JAYJsqoC JYqZH8/uNLx/prUl3xi0QOpUrlocoPcTQneh9jEDqL67JkSGFmQ3uGHPoaQrk1g9AyFz qXUxMmg4J6Ql5ft9OgzDiJ6TFZY0uMnPbyFK01uN4bJ0T+8/RZPvgzmfI3oaVZmNHxI/ XetA== X-Forwarded-Encrypted: i=1; AJvYcCUvQ0G1KJPA6SnB7DjPPpszHrfbSPVD+qvvlYJQtKhRGtUO8Ed7C7s6Y53cpPdbZ6lPpJBTCNhjMyfkqyEYglb0iEXyfhAEaHHsl7Sp8Ev4 X-Gm-Message-State: AOJu0YztsTNoM9JFOVwwU/ajC2rIBNTDYPxscedK0b1bjgIGuKa+YwxM 1NtemhLUbE9+l/MIP5is5M1P66ftsb/U7fRNLYb33sDBpzM8umr4u41FQg== 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 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= X-Mailman-Approved-At: Tue, 18 Jun 2024 20:22:03 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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: 13702976 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 17991C2BA1A for ; Tue, 18 Jun 2024 20:22:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3ACD610E7AF; Tue, 18 Jun 2024 20:22:06 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="N3vuy3Gp"; dkim-atps=neutral Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) by gabe.freedesktop.org (Postfix) with ESMTPS id 360EF10E687 for ; Tue, 18 Jun 2024 14:00:42 +0000 (UTC) Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-a6f1dc06298so664173766b.1 for ; Tue, 18 Jun 2024 07:00:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718719240; x=1719324040; darn=lists.freedesktop.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=N3vuy3GpAFKDmBISJ7p1Q2f9PxUzeOIj/6ds0ukZdgu0R3Beqa65eIHEhcR79CmhGh z3dC7MbrKrdnVApAELtBKjNi68JA7M41X4cw7iV/SmZxsZNdgc49+yMEBacM9gm7g3nr rY7Mecn2bx3qP40iP/AD4blPYsQATQH4rqStzXaSfZX8g1nU7SVL+VIUnra5uHI/LFrK FneqiD6oYdc3w55N0MFtss763HKPy67rElqgk60gYImWzjnOb8GDA0WaOLNHi4rHuhPu X9xV2Uf6ccZpEtteCQg/RLzIT3wZVXmZDyHslNGyhsOsff8ho/YdM8byEpptZ73/SA3i /8vA== 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=aJ5SCSoafQZrSYQY5G1OcDlVwIjSD8FXvFStM3NC/J7gZzV1DM4doVxBVgk+z1ioxD aZnjEIthWCBq6GVIDNylMJ9/ckBa1IM5aLTYq9jK4kk+wdX0z88X5fkx3/jiNzqnasRG FzKOnSB5AsPm++RKOimZUYLhO4LQmd14aRWz5B9IOEPLCqDQMtTElqgeE7MaXvNLKsE0 5cjgWSLVqutgC0jGIjU7swlIY+sfWBLDMrr3qxkQ4ToBg+Wsje8tQETKUMWG62uypLcA TfVM0ACpcV8EEkXWxgy1kc91mI0Q9w2kHeyrsQkUfpq6sG9DiOzNm6LascpUMtAStmjp vsqQ== X-Forwarded-Encrypted: i=1; AJvYcCWIbO9oIKYGwl2oiA5UNiRhBVoEnknb9Rt9iDUmy5FbRkQdb8bRrEDPd3okHJHlPzcvefzkYjSP51qWqEWrtUIeaRtMqRUq+1/lmbdMIgHA X-Gm-Message-State: AOJu0Yzop5c5+nBkSHWVK+DfEYnXBPs+y5uku29fnBwnfLeWZ3Pqhajp YxruDPYMc1vQWfAQfrUQht+KkXl0akSKHBBL/BxDpcQ/rjUj4alsN9ukcQ== 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 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= X-Mailman-Approved-At: Tue, 18 Jun 2024 20:22:03 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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; };