From patchwork Mon Jul 15 12:55:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 812728 Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8ECAC18D4B8; Mon, 15 Jul 2024 12:55:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721048116; cv=none; b=MCih89CR0MXx9InIzQ0qzU3FIKG2lgBhUVmH2S8tWyHbinFnM+yjsL7wwpitEwOJ9pbB4xyIXiHTSPfcBWCY/CXYa+N+aWz+kzh0x//cbsTv27FMyIxHEeU/tXEJszI63FWuGG/dH1Ln11jU/1z0tRxTBZ2vfBgyytiUyY0sJQ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721048116; c=relaxed/simple; bh=Sep2YFazyIuwJAAWmtMhPpLW3/gwTfw1XNyWXLhamO8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Q7ZC9c12sjniTvq01iMKV+s8U16YaEN81dsmVuffCPNGqXqOdJ5BkcZ3fWtAvQ0kku9vcuEe5k30SRNtPyLIbVv+6411Dhk/OLTrZQfqrnpM+liQF32rPeSRoU1SpYqxdBOb977k0SwV5iXud6IcZ/LxyvuNDHgGSGx1OBd2qyE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GrWptQsk; arc=none smtp.client-ip=209.85.208.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GrWptQsk" Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2eebc76119aso47977991fa.2; Mon, 15 Jul 2024 05:55:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721048113; x=1721652913; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Yy4EKK2MMNMVFHHJLnbyF0PIFup9QUbwgUbkF8k93AY=; b=GrWptQskV8HS4ww1ce+YEx+l0JwSZT3Alrp/PfApLsGKDAy6qreWZDyggcHxnwCPgF GRTvHe+5pnGQW5niajJ43iV20KV3d6bgG3xiYDdOmPhqDQJktSvdCan7/hKRHHyhH0oq fLCWTSP923x+GqlKFfFidBRWk9kKiIJvQVT7rAWR3EyreDQDcjThumDH/HCsiV6W9rNz fmhg6i2evQmNL70qThC4lE33QebvrU5hipfEAOJCwYjdNrsJpniaSAWMBKG6q3w7/S6R Hy3SWuuA6Wk8E8gcja5NoH/L4wzr37pkLXLJif2a+OrToInLSE1geKyxIxCUyICzkYtT ahBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721048113; x=1721652913; 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=Yy4EKK2MMNMVFHHJLnbyF0PIFup9QUbwgUbkF8k93AY=; b=OiMUjhCKQwPrJNE5sJ2orszf+eTnOqvKSEqDFVQMqCxARZcHB/8u3ToWzLXVP5LlQR M/5AbEwu2N9b005RbNTdl4VcAiRgdXH3rusW2Th9nlNco6C91Tj3GD/Y4a1OLESoTg5U 3Lre5tUnt515vFCcSadPEiizbX809H0eIP17tW2lbFIWfrBrCKed6qnePr70gYnp2rgy 4kDDluLPdXn8ytCvPuBqpC0sRopPMEU/dnPnTenxZpncbIryyKkcgIrxrDEOwRo9+81I 3x/IVCoAZVTkUjsZKTFRB7+cFmVEvWDRuSYWChrxLrHqvkv6yG2MujmDqkjzSMKAgtvw yRLQ== X-Forwarded-Encrypted: i=1; AJvYcCUqFoaefrTxIEi20D4hQOhv7IEfC/A1hZ88FoO4fdOdE784XzNzjXclQisEpeCKDA+05Z3AlibQLf/ZauSeNCWtOe8bsrYFrajpDJmI/DG33VeByVuhYdEsaAKRlZEEOMRJGaKD3JQ6GLdxkWJBjxKVx76bT5ZwXn/PkBd+hH9YZdFNnaL7zRTdoqUBq2jI/FQqUG0a02N2HGRsHePvFZ2OJ3F8hUM= X-Gm-Message-State: AOJu0YzpKmuEZcNxJLA54Ej6febO6y5wpH5BHSIZRB2HGv64Cjwg0EQ0 upHSwaX15FW9HTciEzfOK6d+nzdL4ZN7598QrRIvW5T55qmK9VjwPogRdUyq X-Google-Smtp-Source: AGHT+IEZ/wluphxBn2a6YcKsiQTSr9JzIe+b2teGX2aiGb1mLWNivX+caxnotyDZOe8tkjXU+WzrGQ== X-Received: by 2002:a2e:9d06:0:b0:2ec:4acf:97dc with SMTP id 38308e7fff4ca-2eeb30bc9eemr126107771fa.11.1721048112386; Mon, 15 Jul 2024 05:55:12 -0700 (PDT) Received: from tablet.my.domain (ip-37-248-157-210.multi.internet.cyfrowypolsat.pl. [37.248.157.210]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-59b26f62165sm3333307a12.87.2024.07.15.05.55.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 05:55:12 -0700 (PDT) From: Artur Weber Date: Mon, 15 Jul 2024 14:55:03 +0200 Subject: [PATCH v2 1/9] dt-bindings: power: supply: max77693: Add monitored-battery property Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240715-max77693-charger-extcon-v2-1-0838ffbb18c3@gmail.com> References: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> In-Reply-To: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> To: Krzysztof Kozlowski , Chanwoo Choi Cc: Sebastian Reichel , Rob Herring , Conor Dooley , Lee Jones , Krzysztof Kozlowski , Alim Akhtar , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Henrik Grimler , Wolfgang Wiedmeyer , Denis 'GNUtoo' Carikli , Artur Weber X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1452; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=Sep2YFazyIuwJAAWmtMhPpLW3/gwTfw1XNyWXLhamO8=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmlRwpJjCLdx8HCWez4ml9uY6NIVfmATTP1DiqK sIjVobrj/2JAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZpUcKQAKCRCzu/ihE6BR aA+OD/wKoQpFNAsUIXuHULAyeJawNlA3bvCuREiYKFG7ppjjBd3+Nx6dCwCUfb1o75KDWzlZ2zp v/r8kICqtqtcoyqKffJfMsaImvev6dq8Bk2hebpwa86QvRiEs+ssMw1eViuJXLmP4nw6r7lku4f q6mbFW5qHLvpxI4CBgeuwY28y9y6NR/OgwcGsTx9CRGNwo/Vf5WGQG5TASW7DskE11ftwWVprv5 6PIWKIg4EYWWwVqTsBPCc9bzk46dYMMO4sk0Q8fvkB4KUGGzI+0HMlj4bSDQdn/ZF2rPpJoow2v ba75TL3UVonJA/gCRZz14y+zdIc3Hpq0YObqOW7xDCa+GfPdc1QNyxd1p8+iyGhTPRk3Ix8kMWz lbH55+nzJ8jM8MGx//51mew6uWa8wzcA4GNA4NQP0pxoptfvcvu6NEBwqlJf/tpIp+eOc4G9OVV eqggCPYcLQuhrX+UuewKbxsigbH49om2D+Y3h+i3YZgZ8VokbmhdStE4aqddEcv9MVAmteM8DWq 6X/KaCOtvopY9MCw57bXHgyitnxbi6kgy9gXa9S/KThHcEXxfJBtXw9l7+XW0UiS+D4czK3M5us 86XTizBWbtRm0MfkNC0eyyx9QB5umLav+YaZLWYhojB6R6a2hmaYpK4AYdjwsmKyGL+8iO2mqS3 PFg7DCJfY4Xde5Q== X-Developer-Key: i=aweber.kernel@gmail.com; a=openpgp; fpr=E663000EAC1DECCD6AD2890DB3BBF8A113A05168 Add the monitored-battery property, so that its constant charge current property can be used to specify the current limit to use for fast charge (when plugged into a wall charger). Signed-off-by: Artur Weber Reviewed-by: Krzysztof Kozlowski --- Changes in v2: - Switched to monitored-battery property from separate fast charge current property --- .../devicetree/bindings/power/supply/maxim,max77693.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/devicetree/bindings/power/supply/maxim,max77693.yaml b/Documentation/devicetree/bindings/power/supply/maxim,max77693.yaml index f5fd53debbc8..2f4437dafdc0 100644 --- a/Documentation/devicetree/bindings/power/supply/maxim,max77693.yaml +++ b/Documentation/devicetree/bindings/power/supply/maxim,max77693.yaml @@ -16,10 +16,19 @@ description: | See also Documentation/devicetree/bindings/mfd/maxim,max77693.yaml for additional information and example. +allOf: + - $ref: power-supply.yaml# + properties: compatible: const: maxim,max77693-charger + monitored-battery: + description: + Phandle to "simple-battery"-compatible battery node. + The constant-charge-current-max-microamps property of the battery + node is used to specify the fast charge current. + maxim,constant-microvolt: description: | Battery constant voltage in uV. The charger will operate in fast From patchwork Mon Jul 15 12:55:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 813608 Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 30B4E18D4C1; Mon, 15 Jul 2024 12:55:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721048118; cv=none; b=gKkkZzcd5ESViPYpa5ml06wJFBPS+fNtUzwlWh48n3XEZ2Wh+qHzRYAlD+tZJ0JO0qNDQduYMzl6OjiWNFzl9NhyjxJjN77be16sSzWwVxrG/gf/oyXgZna0uYk2Bfa+J0x8bheHElgpkLUZqXjer6Ydy+MR5Uf3BFGPHKwSWn0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721048118; c=relaxed/simple; bh=UswaxFgNYGhQxO8i3hDmSgr/CcfH6MewnSR60PWmTJA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ttEn5qQmBrQ+8x1hhVAmOkzwj12bubWge/Ol5iQ3KXX4kSLSfM+an8N96Og++/Q0PlYtfpzSh38L5jjec7ZFkn5eahQztngQhGg0zgWmQHHso4fFZTSmEMApSSdSqlRtAUN38+eyHhRCEklEsXVURTFfp4kpTAwQ7PG3HiVnIlk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mK9Y1C0M; arc=none smtp.client-ip=209.85.208.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mK9Y1C0M" Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-595856e2336so277170a12.1; Mon, 15 Jul 2024 05:55:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721048114; x=1721652914; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=eGuQaKvthqNvOI+/BVZ1qQqCmj4BP1waMYjE3zo8K2s=; b=mK9Y1C0M1pIw7vEdLWwd14Zq8ViWIXSSxys3dSKRcwfEKOxkSpAgY3OVvrlU1HMPOs 7shuo9y3Ucx/OcQ7JiieJPeGJ6QVf1a151pbwsQD9QS32OmEY8bezPTQYnC91rDtFdSa cXgzYcFd626+w1DoCr+MIwRz84CgoekMtDxjRiRcT6SmSleH4HYGc+xVZOvkQfGC+yBP LeYt5qBAvU5sIpnclIntHRrcilx4SLejsRgm9IUVtbhdE0xABAokHK6AX76qF3zHCUY5 CmGfQ27Q8kSiAOMX6Zm3pT1xbjiZJdVZSfaUQpBumVBTqFg2t9+85Vz9CQGBVdI/PD5v ZDHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721048114; x=1721652914; 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=eGuQaKvthqNvOI+/BVZ1qQqCmj4BP1waMYjE3zo8K2s=; b=dhW1bi3p3Yx7RpjERWlOBPg0ipdquRGIA9XkEzhDMdXZdPWmvM97UOqie0x/y1rvtx ruOD2TpP825mPPgW/a6rMmTSbN36ipWXFEwc5bhNjFQLcacTu44Szw9f+hztN/Pd7cGB iGZG0VhlM9fEig9t2jCjq0DrOiJNkvEVDv95Ax53/NAlE835szG0AqL8TvyCGjvuNNSm h2AQEP1+k13C5IK9w9QM1HPCNrTZebvp26fzcQPCiFws+M93t9OpkQyOH6LWoA+ouaH4 IfWs3r06JhWNxUN8fNnXM2SLwOx931tt0iFA+thTngmsrAE9JmE6+QwjCaP3mKy+DeAP +QHw== X-Forwarded-Encrypted: i=1; AJvYcCVSE1Pv2Th/xsPZrGfsonWiy3PtB7ZW2RSw00+JOb5XSmvCIKxI4Rw5zcJYknmUhCmRUFwSEAUxOXOPG2eZG5qneecl5GneBQIQKne3Jrll8YkwfJzafddhm/UrT3x1EbRiULSp9b46BPDywho8O5JftXxaXi24l0Gmd7QXYzOnx6LW8tN1mBeyGutDOPJexA4o0Ky0qgNcpL7q8J0RirUfwEE8hdc= X-Gm-Message-State: AOJu0YzKTo5RZ4qQMg2Cn/pCD8pZb0QuGBYw9hN54Ao8J0ZFnEmNCUCv HBfWVCL4I+NghQYNlYOH80uUWiTfP/hvLyw4B2ZKrl3GaqNwxrUzVDqNaukG X-Google-Smtp-Source: AGHT+IF13yLztEYtO3ThN8vyYl93/m4din/5EPKTD6UXsAFnvdhgrZPhA9eeq1XL21Cu8GDzVWSlJw== X-Received: by 2002:a50:ccd1:0:b0:57d:3df:ba2d with SMTP id 4fb4d7f45d1cf-59a71454331mr6318170a12.2.1721048114285; Mon, 15 Jul 2024 05:55:14 -0700 (PDT) Received: from tablet.my.domain (ip-37-248-157-210.multi.internet.cyfrowypolsat.pl. [37.248.157.210]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-59b26f62165sm3333307a12.87.2024.07.15.05.55.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 05:55:13 -0700 (PDT) From: Artur Weber Date: Mon, 15 Jul 2024 14:55:04 +0200 Subject: [PATCH v2 2/9] dt-bindings: power: supply: max77693: Add maxim,usb-connector property Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240715-max77693-charger-extcon-v2-2-0838ffbb18c3@gmail.com> References: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> In-Reply-To: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> To: Krzysztof Kozlowski , Chanwoo Choi Cc: Sebastian Reichel , Rob Herring , Conor Dooley , Lee Jones , Krzysztof Kozlowski , Alim Akhtar , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Henrik Grimler , Wolfgang Wiedmeyer , Denis 'GNUtoo' Carikli , Artur Weber X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1063; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=UswaxFgNYGhQxO8i3hDmSgr/CcfH6MewnSR60PWmTJA=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmlRwp6OhrSlHrko5KiBUj7b51bE1zw8tFe6qng QWh1+Lw2OKJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZpUcKQAKCRCzu/ihE6BR aHigEACEj26TJHPcn6IEXY48/4k+ESHRoKR+3480pvLlXXKJQGt16YcfuChAKdYqUYtGo9Vr306 eklbsSUah/1GgSqBzCRD3UV1bFMyKMPA1k1KJIbz7/WHXah5wjo2g5ScP4+kt3mixKtd2N6DAnm 4R1GR5nrZ19SYOzjax9M2FpZmPf3Ql+H2qx+q3GuCnJqC1eTE4ewnYvFWKKsW5qpsvgUiG5GhAE KH6aCTz+YuIeMx1L4TMtveMPW51JEFTJDuwP1nNb68v2vV0t0FSWMHGVLRQRg+b64kXog1hm9fg g3fW3PF05hf6RaAz0kKERzD1F2VC0/lWhPpXvk36oHacyXxljXQl6dRZ/7pWRTc6ppJQW0GnH0H ep6dgNVULP36kORX44a7nPcegyzQJsNt76aLCzFbjGXV/Bt12VOkZP/cEiu55TfT1moN5C8j62F /Zm8nlCujXp678QpsoqkgjwJirdmsrSL0pZWSvm4jOm3fZDq09X5Vi7CPm+Hgarp5REazgOUOFj D7y8kfQ09t1BNukkcK2yI28MhlG2GThj9ZNm8A8E7z/eJPDSHKp/0bkMl53GN74Z6m3JIkKqPZ+ Jc2PDm4WMmF+DNwXmGrjonEWeXv21Mv6AS20sVs3oLNKiFvqtkc9n3FvLX5PmAenh5JxLI5cSIA G8ml3hlQloOqx6A== X-Developer-Key: i=aweber.kernel@gmail.com; a=openpgp; fpr=E663000EAC1DECCD6AD2890DB3BBF8A113A05168 Allow for specifying a USB connector to use for charger type/OTG cable detection. The way this is done is inspired by the rt5033-charger implementation. Signed-off-by: Artur Weber --- Documentation/devicetree/bindings/power/supply/maxim,max77693.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/power/supply/maxim,max77693.yaml b/Documentation/devicetree/bindings/power/supply/maxim,max77693.yaml index 2f4437dafdc0..b70c171bd4b9 100644 --- a/Documentation/devicetree/bindings/power/supply/maxim,max77693.yaml +++ b/Documentation/devicetree/bindings/power/supply/maxim,max77693.yaml @@ -73,6 +73,12 @@ properties: enum: [4300000, 4700000, 4800000, 4900000] default: 4300000 + maxim,usb-connector: + $ref: /schemas/types.yaml#/definitions/phandle + description: + USB connector to use for charger type/OTG cable detection. Phandle + to a USB connector according to usb-connector.yaml. + required: - compatible From patchwork Mon Jul 15 12:55:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 812727 Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 780D318E755; Mon, 15 Jul 2024 12:55:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721048120; cv=none; b=sfdCIISPOvU6Q4RKpGjGoTW8YRiur3LiPWMAXFkADern6dnGn+8sEKhi3fXSAuDmvCqla9xRfN8lyV7F8CIKOLudqUNfGo7bznOY9wEGHFe5WFgrtOofYMrr7sD5+v1o9aedOIjEjZHcgSBoBoP4VM6to7xeS8QGZEtx45C8hNE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721048120; c=relaxed/simple; bh=sa109WgAcykCnYFwcY2iDwvvtR/mCqo5hBu3QTu8IW4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oF9wfv275id31D4koT6/Eyym7OF+FbQJ94nocXgyFbIFKnlkQL1K9XAAaIn9mIRPsU+0cOGksfTmUox4qBXwqvCrYmIhsONdZl+Ss7c50netYORbE4rf6mKQF8UOMm3TJAZP26oh0LFEeeDGPkk4bwCHUV9QI0iJhb/ObdWNGkY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LRC/969B; arc=none smtp.client-ip=209.85.208.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LRC/969B" Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-595712c49ebso5133699a12.0; Mon, 15 Jul 2024 05:55:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721048117; x=1721652917; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Hy8uXIYsKBTu0N7Z2wuBwfh2n1x8LDG4iwV5RA5Sikk=; b=LRC/969BXBpy9ruF9OiSIyFQxq9qRX7NrQC+1JeliGPvxPX62R1ypiJpfOvGTJkV5c bSz6sW9kxZ+N5e/B42fjrunWhoJCV/AAPA8RJhTRA6fe94SyZ9lV7WOvjwppZpJj03Ij L/y6YqHufyrTXvWMReYyuF/P5E0XdFM4WpR9K9lj9sX5qoW9gheCEP4ZpM+EHICuQsz9 IIfa7zICKJftKifBguBkuafPn7eHI03ptepeh1IlPnbxFFSGloR59c9YrQSksE3AjS4b qWZl8f8SLvB5E9dvmjFqSGkmbqP7ZyynzXZ/2Nzyb6MD1LX6v5goEowNTo08FZzKXtLo U7wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721048117; x=1721652917; 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=Hy8uXIYsKBTu0N7Z2wuBwfh2n1x8LDG4iwV5RA5Sikk=; b=b/NZYSeImL3q6VUG6ByWeRTintAUd0WYGAIGatsdjPKG7wLs/vWBQt88eDXZJwjrKG GksNEcjBwiv/9fFvEqSdABl9qGIDp1xk8Fzqa5LnD12gR+3DAnGDxY7eCP1//zQEXn5K eKSJGBK93R658anG9IEammoat+Omy1JTMg6BFRVq2jAc5PoOcx2fnXpv/hZFIWSUGXE/ Q3LWGtOwP9L/kZe8zZAXMXWCAknM+MXQN9As0wuSeK1Q2uEB2ZHl+ZtyIh2FxEdwPZcc b+mbe/A9nhYFj25EzZ75/iqs2Oi0GDcLl/tUqivrvhAlz+gel6pW06YhHBv3kHaw76ML aVNA== X-Forwarded-Encrypted: i=1; AJvYcCUhC1XDkU5iCj37AbiK1iyc77ag2lubs1rlSfVlr7SpBlaCgCL964q+O4/Nx/87+gAfpPv3Uxhcn11yspZf4ZIfriJPRMzt9r9eSjpbAQkN/gCtZ7ScQq/Z+8q2QqEiEsOCFQi2TSkRPN70XojoQhr3ZpsMXw0j7HGzbNm8zW2Jr4wwTTipwfjcwsWiIGi01JEusMpOuByw4NtbYXF5Epw3BOaXAdY= X-Gm-Message-State: AOJu0YwvPkekLSXDDHDyRa+DfQy3lC0ZoXf16W/CWORro/i4jYQTrxqh 3AlLJb9tUTRI3bAEEPtQOdNy9Ohr4hPQChiCL2c6wft/q//3l1N9GV7U4SiR X-Google-Smtp-Source: AGHT+IFSeOUQ4GQ0JktHokv589tUfaMihwOmd9W2rP3yeBHjQVzPLMNMNZgec2Vx5yIRh3tyCsIOBA== X-Received: by 2002:a05:6402:5bc6:b0:587:2dd0:93ec with SMTP id 4fb4d7f45d1cf-594bc7c7e36mr12494193a12.30.1721048116556; Mon, 15 Jul 2024 05:55:16 -0700 (PDT) Received: from tablet.my.domain (ip-37-248-157-210.multi.internet.cyfrowypolsat.pl. [37.248.157.210]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-59b26f62165sm3333307a12.87.2024.07.15.05.55.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 05:55:16 -0700 (PDT) From: Artur Weber Date: Mon, 15 Jul 2024 14:55:05 +0200 Subject: [PATCH v2 3/9] regulator: max77693: Set fast charge current in MAX77693 CHARGER regulator Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240715-max77693-charger-extcon-v2-3-0838ffbb18c3@gmail.com> References: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> In-Reply-To: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> To: Krzysztof Kozlowski , Chanwoo Choi Cc: Sebastian Reichel , Rob Herring , Conor Dooley , Lee Jones , Krzysztof Kozlowski , Alim Akhtar , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Henrik Grimler , Wolfgang Wiedmeyer , Denis 'GNUtoo' Carikli , Artur Weber X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3543; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=sa109WgAcykCnYFwcY2iDwvvtR/mCqo5hBu3QTu8IW4=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmlRwpIpRGh8YMXJ3XQOkQ2hUgOoJw/29UT+Po2 VR5KAyFJ3yJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZpUcKQAKCRCzu/ihE6BR aLY6EACF7ffTvprcNEbjAy1hgs2bevgEwN4A3e2ItBicKITTLCZFfKxd2+k4A4oXyjZ3N15Ewg3 VKas0dQ03e4EoTGGlT/HTcwhVR8tIkGM3367YU8ZdNXJsOK8O0X5AbQ5m6YEHag6w5hVnICJEGA VUUXnOYofTqM5FkphC/9RrYfSRTmAwDV43Ha71LP+up6hhgZPDZz/MJWhTkfiI29P31gOBQGvhz C9maOTwMswG7NlAmTFofooE/R8jZRQ+tHrPj81cNjI75K5x8rb8vkYOTQphbU5GNnKBOp3llefC C5SjiHEgMfqAj9wV5wKYEee7W4rDkwygXa0deHUjG+ng2+hNJlwmkKSlgYSrmbcR5pA8XWPna3i qqgU7bDA7PxzgCLSzs9SfBu7gzx7dbhfUKA8Z5HG2lCuOu8kkz9QMrDjG6KwGoZ36gxcyAU+t2s PyFm4pBN+P3+OcRG8DKyi5ix9NGO/p0qdyhr9vo1HW/dTPhygvgt8HGBsZxQFYoOb4oAaA5UbKT 7JbQhROiYfHM5L8kjqAc5yldv3OtB9rnKJNUA9DimrwQeAkbMuXK0i2nHfrlLTy0TbtJMFFmuR3 O++w5f3y5GPOMfSDo6/iNb2iWs0SWVBKVJD0F7YAHdjlh8uhEuyHpOnRkXiUrD6B5xh5tmFe8s2 tfe4E4tD1MEgblQ== X-Developer-Key: i=aweber.kernel@gmail.com; a=openpgp; fpr=E663000EAC1DECCD6AD2890DB3BBF8A113A05168 The MAX77693 CHARGER regulator only controlled the "charge input current", with fast charge current being listed as a TODO. Fix this by also setting the fast charge current when the CHARGER regulator limits are changed. Signed-off-by: Artur Weber --- Changes in v2: - Added this commit --- drivers/regulator/max77693-regulator.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/drivers/regulator/max77693-regulator.c b/drivers/regulator/max77693-regulator.c index 72a67d0c5f1e..3fee2e255fd0 100644 --- a/drivers/regulator/max77693-regulator.c +++ b/drivers/regulator/max77693-regulator.c @@ -36,6 +36,7 @@ enum max77843_regulator_type { /* Register differences between chargers: MAX77693 and MAX77843 */ struct chg_reg_data { + enum max77693_types type; unsigned int linear_reg; unsigned int linear_mask; unsigned int uA_step; @@ -46,11 +47,12 @@ struct chg_reg_data { * MAX77693 CHARGER regulator - Min : 20mA, Max : 2580mA, step : 20mA * 0x00, 0x01, 0x2, 0x03 = 60 mA * 0x04 ~ 0x7E = (60 + (X - 3) * 20) mA - * Actually for MAX77693 the driver manipulates the maximum input current, - * not the fast charge current (output). This should be fixed. * * On MAX77843 the calculation formula is the same (except values). * Fortunately it properly manipulates the fast charge current. + * + * On MAX77693 there is an additional "fast charge current" register: + * min: 0 mA, max: 2100mA, step: 0.1A / 3. */ static int max77693_chg_get_current_limit(struct regulator_dev *rdev) { @@ -86,6 +88,7 @@ static int max77693_chg_set_current_limit(struct regulator_dev *rdev, const struct chg_reg_data *reg_data = rdev_get_drvdata(rdev); unsigned int chg_min_uA = rdev->constraints->min_uA; int sel = 0; + int ret; while (chg_min_uA + reg_data->uA_step * sel < min_uA) sel++; @@ -96,7 +99,30 @@ static int max77693_chg_set_current_limit(struct regulator_dev *rdev, /* the first four codes for charger current are all 60mA */ sel += reg_data->min_sel; - return regmap_write(rdev->regmap, reg_data->linear_reg, sel); + ret = regmap_write(rdev->regmap, reg_data->linear_reg, sel); + if (ret) + return ret; + + if (reg_data->type == TYPE_MAX77693) { + /* + * For MAX77693 we also have to set the fast charge current + * value. This value has a lower upper limit (2.1A), so we cap + * it at the highest possible value if it goes above the limit. + */ + + sel = (min_uA / 1000) * 10 / 333; /* 0.1A/3 steps */ + + if (sel > CHG_CNFG_02_CC_MASK) + sel = CHG_CNFG_02_CC_MASK; + + sel <<= CHG_CNFG_02_CC_SHIFT; + + return regmap_update_bits(rdev->regmap, + MAX77693_CHG_REG_CHG_CNFG_02, + CHG_CNFG_02_CC_MASK, sel); + } + + return 0; } /* end of CHARGER regulator ops */ @@ -179,6 +205,7 @@ static const struct regulator_desc max77693_supported_regulators[] = { }; static const struct chg_reg_data max77693_chg_reg_data = { + .type = TYPE_MAX77693, .linear_reg = MAX77693_CHG_REG_CHG_CNFG_09, .linear_mask = CHG_CNFG_09_CHGIN_ILIM_MASK, .uA_step = 20000, @@ -219,6 +246,7 @@ static const struct regulator_desc max77843_supported_regulators[] = { }; static const struct chg_reg_data max77843_chg_reg_data = { + .type = TYPE_MAX77843, .linear_reg = MAX77843_CHG_REG_CHG_CNFG_02, .linear_mask = MAX77843_CHG_FAST_CHG_CURRENT_MASK, .uA_step = MAX77843_CHG_FAST_CHG_CURRENT_STEP, From patchwork Mon Jul 15 12:55:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 813607 Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6AB0118EA61; Mon, 15 Jul 2024 12:55:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721048122; cv=none; b=jq3Bxsghai4A1eB0Y5njKK5Wtg/whYPcYbh3dik40yo0uOmgq2qFuEouf6XVBtdpipWZZU22tOBWJT+GVVu+VwbJz3PY1yTN2ENmZoC6iUAuMr/wRGw4xUKzQzRApaUeaZ61HMCyd4hPYrzHLBg4koCderfsniWtZLJ6jZrYI/g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721048122; c=relaxed/simple; bh=1lV+PvQs9RkMQaB50b7Zw5vUCqbzy36VnOEmeBWappo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Bm0VOlTymBnKCJ/843mLG5UPRKJqoDQ1Jms18GSvLWvAzC6OTFZzAVSKIvdiPvzGnzOACQ99XRzjvTAMGA7UMoEntWcncElJI2PXI9ua9OgHklVreXvDhM4HcmZlwvRwfCeLvvDgBvs4XE8/3D6BSqbhQYk0hwwjJZN1F9s3QJw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UKRKnbLj; arc=none smtp.client-ip=209.85.208.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UKRKnbLj" Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-58b0beaf703so5331768a12.2; Mon, 15 Jul 2024 05:55:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721048119; x=1721652919; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=2dnrbGKaoLS2/r35L01fJO0wiCmLb/VBCvJttZm/KZE=; b=UKRKnbLjXkcxRAt+6NRFNQCv/XcxAbsdqgEb4IyDHkqtMRvGWHl+gGRCwQ7giaSDO4 vFkFSoXweb6QoQ7uEnFXDSerVDuVpodG5vew8pC5u13/ulNSSBFsHWO29idLbNGU9ihr JRfM/TTMjKCJJyhTnPBFzsRkZ8u6+P3fzWe5cwKsfek5t7Y70Ba/VFtYLw137OsDqDog F9PEEZpAyLlFCrNFfc4PyuVeQZJJfLaW8XaDhI+wPLydvcdXPB+d6/lWTLBo3tMIFR89 HkF4oKOdrq60RRWXg9Uemhe7I7fsBuR14iFBef1PKI1HNZ05xqkU4Fmdj+SwaUdN+l/0 ahwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721048119; x=1721652919; 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=2dnrbGKaoLS2/r35L01fJO0wiCmLb/VBCvJttZm/KZE=; b=ZDo91c2oev4kovXj26HUdIA0AGAvh6yVdRykPaByjOJI3IR2mB7EQhLLzBvPL5ZrI0 3XhL13sOKInNzWncyqPnMq1MS1IEMxmQCL+g/+aVK0Hywzz2TdVtkJAKwlmQVFiqbwUf 5dvO3arc9A1dzhwTdlSBzknM5Wra2q8Zoa+fDq++U1nhQUlWmNXCkLMMwFfupBBYhWNX THoWsoJ/NpTI/hh4bAp80p9yuoVqY7gm6TXgs7wMsCmbpvUtT1ViTiXky49pNG378/8O lqMSJNwcbEPuz2AUN11HYZhOupnQ+QByicre9pki0k/nx3VyZrKr0VLM7/N9RL1iZ3TM ETLw== X-Forwarded-Encrypted: i=1; AJvYcCVzkHo5as5LSeotUZBOs0NZAsygHb4RCNOrqcwWWAx7mMbCNp6z83Reo+ggX45XFhwSlpJMV56XATQeUJnY7ro6hgqQeYuxevCtDNWKpKlOOntOrbOM/xLdxMXNvaveq1Bq7YdsCiLCMHoFDmmk9beIjARz1bZxSI8FtxZHXLwCKJraxoiqiQo8KAcmRxXr4Ax1iaTC21NeiSRNcJsNsOtpyge+Myc= X-Gm-Message-State: AOJu0YxkPi9oaULnM4tgteiMuEygBaQqatVC60oYcQ01/7EIKXq48mLr kkfeQAba3QfoJMj50lFnH/xXFarFKPJu2pifCdfS1jkBEEoU4EzTrNu42JMm X-Google-Smtp-Source: AGHT+IGKYmXJeIOPB/b6vl4yOzL3ahdkEu80vW0kNZgFlL4bFu7UcYPpvXzfkUGFqZN0xjUW9B6bFA== X-Received: by 2002:a50:bb04:0:b0:59e:65d1:a573 with SMTP id 4fb4d7f45d1cf-59e65d1a75fmr199688a12.21.1721048118746; Mon, 15 Jul 2024 05:55:18 -0700 (PDT) Received: from tablet.my.domain (ip-37-248-157-210.multi.internet.cyfrowypolsat.pl. [37.248.157.210]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-59b26f62165sm3333307a12.87.2024.07.15.05.55.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 05:55:18 -0700 (PDT) From: Artur Weber Date: Mon, 15 Jul 2024 14:55:06 +0200 Subject: [PATCH v2 4/9] power: supply: max77693: Expose CURRENT_MAX property Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240715-max77693-charger-extcon-v2-4-0838ffbb18c3@gmail.com> References: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> In-Reply-To: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> To: Krzysztof Kozlowski , Chanwoo Choi Cc: Sebastian Reichel , Rob Herring , Conor Dooley , Lee Jones , Krzysztof Kozlowski , Alim Akhtar , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Henrik Grimler , Wolfgang Wiedmeyer , Denis 'GNUtoo' Carikli , Artur Weber X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3161; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=1lV+PvQs9RkMQaB50b7Zw5vUCqbzy36VnOEmeBWappo=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmlRwpt1JLmGw3JWwB62NBhkT4suEV7QjKcBC3M zVBlzxGAFmJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZpUcKQAKCRCzu/ihE6BR aLeJD/9Ef/NUzUm3MsA+/2pPGkUkhL4zfMZx//VessDpHA5cioDs6pX5hk4kbkfKTFwVBiGE9+l EtoTOt7Jjqigf63T6WidXghkyjcY7IZ2KIL8Qr6ZhuJESM0BWmoafPQNmwHO8w0euZHLDknW0T5 M1inRVJynstVx/a1k2yM1peHB/oijHfPRKINmUFleDSURUVhxH0nBmj8eQ5YjV/CwA9p07EZ7MX cG9e8pl1Er379lWOc4NcT88omRw/aFz/znEfmJ8i+/lCm8rJV4LYdTes9Nx3/T+PTzrL9xj3y5s abiRw7f9JpQuuDJr3NVzIc0OxMEUPMFFIY7+ao8O7rmHE1A5bpzED45+VBiDCe1+ydTN9uOQO6f w+mt8u2Hx73aQjfQRymE710Uer8XBajg9hZTt3I27sb+3U8OL0n/+sJeRcOrf/w59rnrsx5j1xf OX1zwrxS5WkHkiaO5cMMcCkTazQmGAoG6/15v4ioJSP60+5fnQCGbkWLRT9EZJ435HWc1GFZWD6 JjhE2KqJ1NV2wzBfyDJxn4IbO0ymKzLikJ1i0lE0oXVHSy1j1Hvp/UVGTgy8kbonCtg4FS+Jzr7 WrLCMN9+Eol+lAmkfVn4DW0fTNicVqY0dnMcCbKs+QkQ6VUICLKz5mj8N4CbH1uC9wU3dXksxAp UnGHu9AqNxsyt7A== X-Developer-Key: i=aweber.kernel@gmail.com; a=openpgp; fpr=E663000EAC1DECCD6AD2890DB3BBF8A113A05168 There are two charger current limit registers: - Fast charge current limit (which controls current going from the charger to the battery); - CHGIN input current limit (which controls current going into the charger through the cable). Both of them are aggregated in the CHARGER regulator. Add a property that allows for reading the current limit from userspace. Signed-off-by: Artur Weber --- Changes in v2: - Adapted to both current limits being managed in the CHARGER regulator --- drivers/power/supply/max77693_charger.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/power/supply/max77693_charger.c b/drivers/power/supply/max77693_charger.c index 2001e12c9f7d..0d53f61d58ba 100644 --- a/drivers/power/supply/max77693_charger.c +++ b/drivers/power/supply/max77693_charger.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -21,6 +22,7 @@ struct max77693_charger { struct device *dev; struct max77693_dev *max77693; struct power_supply *charger; + struct regulator *regu; u32 constant_volt; u32 min_system_volt; @@ -197,12 +199,33 @@ static int max77693_get_online(struct regmap *regmap, int *val) return 0; } +/* + * There are *two* current limit registers: + * - CHGIN limit, which limits the input current from the external charger; + * - Fast charge current limit, which limits the current going to the battery. + * Both are managed by the CHARGER regulator. + */ + +static int max77693_get_current_limit(struct max77693_charger *chg, int *val) +{ + int ret; + + ret = regulator_get_current_limit(chg->regu); + if (ret < 0) + return ret; + + *val = ret; + + return 0; +} + static enum power_supply_property max77693_charger_props[] = { POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_PROP_CHARGE_TYPE, POWER_SUPPLY_PROP_HEALTH, POWER_SUPPLY_PROP_PRESENT, POWER_SUPPLY_PROP_ONLINE, + POWER_SUPPLY_PROP_CURRENT_MAX, POWER_SUPPLY_PROP_MODEL_NAME, POWER_SUPPLY_PROP_MANUFACTURER, }; @@ -231,6 +254,9 @@ static int max77693_charger_get_property(struct power_supply *psy, case POWER_SUPPLY_PROP_ONLINE: ret = max77693_get_online(regmap, &val->intval); break; + case POWER_SUPPLY_PROP_CURRENT_MAX: + ret = max77693_get_current_limit(chg, &val->intval); + break; case POWER_SUPPLY_PROP_MODEL_NAME: val->strval = max77693_charger_model; break; @@ -680,6 +706,12 @@ static int max77693_charger_probe(struct platform_device *pdev) chg->dev = &pdev->dev; chg->max77693 = max77693; + /* This gets the CHARGER regulator from the parent MAX77693 device */ + chg->regu = devm_regulator_get(chg->dev, "CHARGER"); + if (IS_ERR(chg->regu)) + return dev_err_probe(&pdev->dev, PTR_ERR(chg->regu), + "failed to get charger regulator\n"); + ret = max77693_dt_init(&pdev->dev, chg); if (ret) return ret; From patchwork Mon Jul 15 12:55:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 812726 Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 506F018EA81; Mon, 15 Jul 2024 12:55:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721048124; cv=none; b=p/EXkjwrKN/UZtbR23P7XX6GDTQPVJ1in2x5/GWNdgPlAfBbs3VXdnzFvsVPlyTJIdS9mZtUjA0JwX8+JCH024SsRo++HERZBLYdTnKZZ3ZqVuJxAuc4KC+nZ1ofXta1o4Z4xaAlFDwjduzVcIgYZ8DDMU7c0SsII8YS4RP9zOY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721048124; c=relaxed/simple; bh=d9xJyVGdkLb6jVsuC/vB8diOax6NmCIBMwGr2E4GxCQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rYikyN4/9oulxTKZCaE3tbzOADuriSNBv7kJ/+wbmklKVmAWwZ0jfmAqPEgovR9HLWMhZEr9xEtP/7ZOgpKT6IIIjrUl6TVM3ASl6eW3d04R7CfbUcfar+QdOufJPPKQ7rC0pGL4X9XeQfvYIrTu9mI+LZyBAJ/Un7COL7dLNFU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Vm34n+iL; arc=none smtp.client-ip=209.85.208.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Vm34n+iL" Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-57cf8880f95so5285481a12.3; Mon, 15 Jul 2024 05:55:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721048121; x=1721652921; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=JepbQc7AbCsn4MwQCws5rv8exDXvYLKDGPZlZpP5vYA=; b=Vm34n+iLhRLTODsfg4t6kHbpNY0KoLH6IWJwb2adkCkJMfrpSoTaxp8OMNB/z35uav S8wp0bNgsPDSXu5RvGnDyrkQv6ZRGujdTike7L+bhpxSTOFYanc9ddidKzvNQU54hJof HyYO3TyiaR5V3KaxJbB4a4/MBGXGpPrKPzKTRkjXgtx+3v8DYE0HaN9jslsX8FH5+8I8 gwE69pArcMy+6ShnwxLot6HRVDRpFB2EfK3DayI7bz8DAc1D0npCZtsBvHntyR3LN1m5 daS79VkhxhlRE6agOdq3nGDBVW3eMQW2WRq02fglV7LxrrEomp4BMUcyqsWjlkMw+QlE oxGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721048121; x=1721652921; 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=JepbQc7AbCsn4MwQCws5rv8exDXvYLKDGPZlZpP5vYA=; b=Cd7eaOka7hof3W9thO/at53ga5BRS4mfkpdfaK38tGpAd6gqlofFwsUwwlOudgOQvS kQCEVk9wqczp4oggRdZ+ctg9QiPhTquRtJvyi2suWgujjrYoI3u/hPwzosbDVWOe3lvG Gv+pfUdKqihHw7arWOdk1NimLU0dZukU+bPqoXPFL2AP/ho4ruR1DRc2NByM0U/rmKL6 ieRh3qMbswgRO5vjM3z/yae6hyUMLHaYEpnS2iqyo1psqLURjLcfBY5BdE1hF++JB3bT HknINxYzPJAR5nVNnhi80NYD2uwE5NWPgZYqkW9SvkVqNep3zDRZ5XE9oCN5HhLeCMP7 yzUQ== X-Forwarded-Encrypted: i=1; AJvYcCUHIaLiC5RRH1vUtYV1hQsoV9dF5yNvDeVj/jvLmVtA2LoWdvqHVycQ4WeouHs1iXT5jVR6+78nWeaSK4CFMg3vUFXTp7QkyeZTZ+OBsCezEyK8WVZNagBnuQJ68C2TsKqCtYQHHBIhPn1xB/x7TKoO/I8j/7a1duAKRUwmlFs4IY7FOIo5wVHAQexQpGS+qf2veIyELcMHoaHQ3vUel580mi30Amg= X-Gm-Message-State: AOJu0Yy3m2mrlyfjlWrTPzNnEWvYo/obg3CvNcpnXjqznfP9BDJt4xEH 2pgK10ybdFmSuD3HcvA5SJiO4WJqeot/1m3ajslRv5Vg199Jaxt216icDyht X-Google-Smtp-Source: AGHT+IGIWouH56vOf6Qbnawj6h4Sop+wyVlJV9Nl0ERoET1sC3NknxcHB6X4S/u+v6iC8pqN/5i91w== X-Received: by 2002:a05:6402:33d5:b0:57d:3ea:3862 with SMTP id 4fb4d7f45d1cf-594bc7c9133mr12051429a12.27.1721048120664; Mon, 15 Jul 2024 05:55:20 -0700 (PDT) Received: from tablet.my.domain (ip-37-248-157-210.multi.internet.cyfrowypolsat.pl. [37.248.157.210]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-59b26f62165sm3333307a12.87.2024.07.15.05.55.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 05:55:20 -0700 (PDT) From: Artur Weber Date: Mon, 15 Jul 2024 14:55:07 +0200 Subject: [PATCH v2 5/9] power: supply: max77693: Set charge current limits during init Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240715-max77693-charger-extcon-v2-5-0838ffbb18c3@gmail.com> References: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> In-Reply-To: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> To: Krzysztof Kozlowski , Chanwoo Choi Cc: Sebastian Reichel , Rob Herring , Conor Dooley , Lee Jones , Krzysztof Kozlowski , Alim Akhtar , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Henrik Grimler , Wolfgang Wiedmeyer , Denis 'GNUtoo' Carikli , Artur Weber X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5592; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=d9xJyVGdkLb6jVsuC/vB8diOax6NmCIBMwGr2E4GxCQ=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmlRwpgRncJxk6pRZ/FjwXbwkFvP4KP7Pdm10nk WTNeVQukMmJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZpUcKQAKCRCzu/ihE6BR aJB9D/wNFjY5v1IfChoZvKH+jUttjJ1AP8mE9CbHD9JEEL+mBrKMZzcDzm5hh18kwNHEpOKEu/1 E5vzCjNch4L//UPyRl3e6pYWXEfmpfiEz9d85F5sMq4zNvFw02YzjbMimMtUuNlV1ctR/Nu1Gei gwynsEPFtPbuJVB4VBspHyG280xHQiIDMubg23rmqBu+UTTz5ZyhzVJ15ZqjQbygADxSny7Nimf yLZJWa4dio75WN9sFk2nJKySk763gEjB02GKTtduYdHqWzx3bPBjJ5s3uw3x1R8NenUAOtl0pS1 5lRqtvlgOcfphmt5XRAECMMV5pm8k8ogFQsyRs/HiXHbPynIlLVdo6W4b78whASSgmvUyH2UHZj f8sQgNF/NVycHx5ZIBMM+TDrzIDv5VjYKec2XIAmzCdZELUP6zHUgcIzbYy5r2AdQ+nZSeOsrhc vWDvHgheH5ALFtSMOOdD41DlAi/HTSnMRzO3p8HNj3Ql0umti3IVq2OFtsO692CjGI1L59ADR8T T78fqI+g67R91MPQwbkiXHWM9XiwzuLC2qo9KXxMVRho/2ziVM1szI/A7BJBtA6P9XB84G4grNr s04avBsVnfKSlN6AUk6D7gQJSZ32lblxr9Ej6tyVtG9rxAaztiZVkyF2Ig5KqLtX6eLmM/iTG3A uuZlAiTByDE3fcQ== X-Developer-Key: i=aweber.kernel@gmail.com; a=openpgp; fpr=E663000EAC1DECCD6AD2890DB3BBF8A113A05168 There are two charger current limit registers: - Fast charge current limit (which controls current going from the charger to the battery); - CHGIN input current limit (which controls current going into the charger through the cable). Add a function for setting both of the values, and set them to a safe default value of 500mA at initialization. The default value for the fast charge current limit can be modified by setting the constant-charge-current-max-ua DT property of the battery node specified in the monitored-battery charger DT property. Signed-off-by: Artur Weber Acked-by: Lee Jones --- Changes in v2: - Squashed mfd include register additions into this commit - Changed from custom fast charge current property to monitored-battery (devm_power_supply_register call has been moved up as it is needed by the DT init function now) - Changed to adapt to both current limit values being managed by the CHARGER regulator --- drivers/power/supply/max77693_charger.c | 43 ++++++++++++++++++++++++--------- include/linux/mfd/max77693-private.h | 6 +++++ 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/drivers/power/supply/max77693_charger.c b/drivers/power/supply/max77693_charger.c index 0d53f61d58ba..0ddaa03669a2 100644 --- a/drivers/power/supply/max77693_charger.c +++ b/drivers/power/supply/max77693_charger.c @@ -28,6 +28,7 @@ struct max77693_charger { u32 min_system_volt; u32 thermal_regulation_temp; u32 batttery_overcurrent; + u32 fast_charge_current; u32 charge_input_threshold_volt; }; @@ -570,6 +571,14 @@ static int max77693_set_batttery_overcurrent(struct max77693_charger *chg, CHG_CNFG_12_B2SOVRC_MASK, data); } +static int max77693_set_current_limit(struct max77693_charger *chg, + unsigned int uamp) +{ + dev_dbg(chg->dev, "Current limit: %u\n", uamp); + + return regulator_set_current_limit(chg->regu, (int)uamp, (int)uamp); +} + static int max77693_set_charge_input_threshold_volt(struct max77693_charger *chg, unsigned int uvolt) { @@ -647,6 +656,10 @@ static int max77693_reg_init(struct max77693_charger *chg) if (ret) return ret; + ret = max77693_set_current_limit(chg, DEFAULT_FAST_CHARGE_CURRENT); + if (ret) + return ret; + return max77693_set_charge_input_threshold_volt(chg, chg->charge_input_threshold_volt); } @@ -654,6 +667,7 @@ static int max77693_reg_init(struct max77693_charger *chg) #ifdef CONFIG_OF static int max77693_dt_init(struct device *dev, struct max77693_charger *chg) { + struct power_supply_battery_info *battery_info; struct device_node *np = dev->of_node; if (!np) { @@ -682,11 +696,20 @@ static int max77693_dt_init(struct device *dev, struct max77693_charger *chg) chg->charge_input_threshold_volt = DEFAULT_CHARGER_INPUT_THRESHOLD_VOLT; + if (power_supply_get_battery_info(chg->charger, &battery_info) || + !battery_info->constant_charge_current_max_ua) + chg->fast_charge_current = DEFAULT_FAST_CHARGE_CURRENT; + else + chg->fast_charge_current = \ + battery_info->constant_charge_current_max_ua; + return 0; } #else /* CONFIG_OF */ static int max77693_dt_init(struct device *dev, struct max77693_charger *chg) { + chg->fast_charge_current = DEFAULT_FAST_CHARGE_CURRENT; + return 0; } #endif /* CONFIG_OF */ @@ -712,6 +735,15 @@ static int max77693_charger_probe(struct platform_device *pdev) return dev_err_probe(&pdev->dev, PTR_ERR(chg->regu), "failed to get charger regulator\n"); + psy_cfg.drv_data = chg; + + chg->charger = devm_power_supply_register(&pdev->dev, + &max77693_charger_desc, + &psy_cfg); + if (IS_ERR(chg->charger)) + return dev_err_probe(&pdev->dev, PTR_ERR(chg->charger), + "failed: power supply register\n"); + ret = max77693_dt_init(&pdev->dev, chg); if (ret) return ret; @@ -720,8 +752,6 @@ static int max77693_charger_probe(struct platform_device *pdev) if (ret) return ret; - psy_cfg.drv_data = chg; - ret = device_create_file(&pdev->dev, &dev_attr_fast_charge_timer); if (ret) { dev_err(&pdev->dev, "failed: create fast charge timer sysfs entry\n"); @@ -741,15 +771,6 @@ static int max77693_charger_probe(struct platform_device *pdev) goto err; } - chg->charger = devm_power_supply_register(&pdev->dev, - &max77693_charger_desc, - &psy_cfg); - if (IS_ERR(chg->charger)) { - dev_err(&pdev->dev, "failed: power supply register\n"); - ret = PTR_ERR(chg->charger); - goto err; - } - return 0; err: diff --git a/include/linux/mfd/max77693-private.h b/include/linux/mfd/max77693-private.h index 54444ff2a5de..4570646e2f33 100644 --- a/include/linux/mfd/max77693-private.h +++ b/include/linux/mfd/max77693-private.h @@ -145,6 +145,8 @@ enum max77693_pmic_reg { #define DEFAULT_THERMAL_REGULATION_TEMP 100 /* microamps */ #define DEFAULT_BATTERY_OVERCURRENT 3500000 +/* microamps */ +#define DEFAULT_FAST_CHARGE_CURRENT 500000 /* microvolts */ #define DEFAULT_CHARGER_INPUT_THRESHOLD_VOLT 4300000 @@ -217,6 +219,10 @@ enum max77693_charger_battery_state { #define CHG_CNFG_01_CHGRSTRT_MASK (0x3 << CHG_CNFG_01_CHGRSTRT_SHIFT) #define CHG_CNFG_01_PQEN_MAKS BIT(CHG_CNFG_01_PQEN_SHIFT) +/* MAX77693_CHG_REG_CHG_CNFG_02 register */ +#define CHG_CNFG_02_CC_SHIFT 0 +#define CHG_CNFG_02_CC_MASK 0x3F + /* MAX77693_CHG_REG_CHG_CNFG_03 register */ #define CHG_CNFG_03_TOITH_SHIFT 0 #define CHG_CNFG_03_TOTIME_SHIFT 3 From patchwork Mon Jul 15 12:55:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 813606 Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C715D18EFDD; Mon, 15 Jul 2024 12:55:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721048126; cv=none; b=IALRMEYlKCqdCEymUlWEZeeyKj2wuJkZeAPXBg5R2+TlQdz7ELd/CiycQjlUVh1sQXzFGwM+/Fuj6RNXf6ZqCQF6eyQ+PUEbMxSTpOX2IeY6LC8SmPNL/eW3RCNLNmE88s9qLRBL8Z5D+3jnoU2Si/9paeJM0y0mnrO6chOMB/U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721048126; c=relaxed/simple; bh=nORleTpwpWgNuuODzmLnTBwFLWHB5u9wp9/Xe63310I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Zga3/JikXpJ45gKR+G27dJv4uAkdUkL6NWdAIeOjGDzWKrLi7nL2lzwgkTTwsl5nSqA3Ok2MACEZHT4lkUfGCMXNCBUwCpLBR52m99ZXcQY3Tn0SfYk1lXjXeSFrqSkhYkxXjn1K65kx/r6wuj61PyGwmjiXdl08NbyoksfPhxU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mm6JxcGi; arc=none smtp.client-ip=209.85.208.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mm6JxcGi" Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-59a47d5c22aso4263859a12.1; Mon, 15 Jul 2024 05:55:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721048123; x=1721652923; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=HnYgYyIzLcEnadxIm9ww2cm2tQhdI4bTzCayN53bjXk=; b=mm6JxcGii2iMwVCscKvX89TQmiRk4u8xqBnbx8ecwDeku+VY1B1THJjI+pYKvEyMyf rOTsQCX2IeSoDkAUExSSjd8YCUsxkjnJchvMYV6YSBMtnnF06711ndXKr9H1coEXQGLK fSOHC7wJ2kRefhsY+ehWKT3fB+U/MVC6F64ATtLhGV8ZI/wYeynr9Rcb/MyaAiXsb0on TIE3aQZur2hb/orJqZToFqFlBiHrkv+Dub5aWtd9SLPvQZHrOoFp1krdusRlokiFzdv5 A2gkpmxl65w0Vp4sL26/E/6PkH/8NDqc2BOh+pwfLPC6jHwFSExxQoicJTS/fJ769N7H c7Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721048123; x=1721652923; 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=HnYgYyIzLcEnadxIm9ww2cm2tQhdI4bTzCayN53bjXk=; b=fOC4HH6FaMWGafyJA++VvuuRxQfId8HRkXD9C9JIXbmCcOS/P9QB5ILHYECK4mBuyY Q2PFc2+zTrJ8ZCiatH+UnNp+UVUlA/hWx97+EqeSKyJBFTyWnRiK5LhXKwgMUyTCZlNL eCpmVv7R4bUug+PabaA0P/fzrCOpFLri9BVJPAg1GsRL9WZxAdRnzqtO2OFTvHZTZL8Q uYX/fvEvjFM43YtBXVpuDcF+Utb0YlWj5UhXsWJHiPq73/jvsqTTVfku8A0owsSBZa4+ +CB41+vM2YA7n/3XEXCfFzFqPsj178mYxCBZcZHaTceBmtXPvVG8xISyNDFtM8ubgywW vGmQ== X-Forwarded-Encrypted: i=1; AJvYcCW7dPJ7TUbq1CV6THCBAYRHKl1aah+7KlxtdntD6yrOaLzbkh4meqxbhNQLQhfSc/rWq6ohLS8IfpDQEFyzQxu5j3oVypITpmzmxGnTv9ajbRIvdJ6vUWa11+14Y899fFdjnVZcxwVl7jivrQii5h+U6kCHCZkoQtZKKl3sLxW/c/ND7JKEpwTKPSCMd/IMjMrFRz5tudP5d/tBMm8mdObLXHvgruw= X-Gm-Message-State: AOJu0YxH5f6TLpJtgQDkJAQNQBI8e5weQHy9c7huXVvswT5mtqGOcvnw FWx1pCxIyUF7h6jFYkAcParEBD4DX3MexovnjBGyiMrW4EsZQPJJDOwW11zI X-Google-Smtp-Source: AGHT+IEyt6/37zigreQe/eBSyKTbMjngFktAPAGaKiuzzl4eqOkTPH3/6/JLn6fPOrQnCCih3MzkMw== X-Received: by 2002:a05:6402:520d:b0:58e:e2a:1b4b with SMTP id 4fb4d7f45d1cf-594ba98f273mr13167907a12.7.1721048123056; Mon, 15 Jul 2024 05:55:23 -0700 (PDT) Received: from tablet.my.domain (ip-37-248-157-210.multi.internet.cyfrowypolsat.pl. [37.248.157.210]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-59b26f62165sm3333307a12.87.2024.07.15.05.55.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 05:55:22 -0700 (PDT) From: Artur Weber Date: Mon, 15 Jul 2024 14:55:08 +0200 Subject: [PATCH v2 6/9] power: supply: max77693: Add USB extcon detection for enabling charging Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240715-max77693-charger-extcon-v2-6-0838ffbb18c3@gmail.com> References: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> In-Reply-To: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> To: Krzysztof Kozlowski , Chanwoo Choi Cc: Sebastian Reichel , Rob Herring , Conor Dooley , Lee Jones , Krzysztof Kozlowski , Alim Akhtar , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Henrik Grimler , Wolfgang Wiedmeyer , Denis 'GNUtoo' Carikli , Artur Weber X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6386; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=nORleTpwpWgNuuODzmLnTBwFLWHB5u9wp9/Xe63310I=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmlRwp5hracQTmctVBYewvzeIa4lw99or+rKlKb F//suZwLd6JAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZpUcKQAKCRCzu/ihE6BR aGxfD/9CZ7IEig+/B2weBvWrxK95bSBmd3P8A8A2fAp5O+1Nj3UdZa3Ntauaxbmoeg1QWzMmlpV n6dqLK/RysDFKkJBe/h/n6hdi9d6sRnzg5EdC8BYSLu4yXDWaSZKU+tAvvdzqlxtS7wKdQjo7OP 6rl4miwQF4XD/rhK8Acm4g3lyQ+clRwxjg3f1TY3Ympgtq0/rlc5az+CcAMBFpIyaHIDvxp3jLs JNkG2VPqtXfYej6Lli63nUu1FofMMmrPTe8XX9TI25DWrtA7V96T0FmQUxiy0krr3iF6jeAT0u0 VUb6S100hKINN85btRyeZZJEgAOu+H5hU5pNpCdXvyGs1nMneexRyKc5UTaZvYyH1SlmZKHGfzR 6ApcBMmXSiyEmu2OJupq5+jGzqMpG6WQE62ocmJvNnVcIDsm+3xWqU3SPK6xICV37TQ2TguTIF+ Y1Iqk2SUkX6KCPu6EkxjlnzKJ3x87mZb6BnFDNHHFAuqcfmtIvuMwNXRrFLX67j7t90jRTrbCmv VeLCJiGCqLDG+QVwfrKC1u0p1fWApT2g66P5UmTQsX+c/AnF1QQmxzkjouvsUSrwk4SpnIu9i5+ 8lglUXuHa8KaTrUrhBHf1BpZofqCu7+bCHqntqTB710rgoLw/S3er//gy6K7x5OkKPgZkcOL02p rXAwZxzDEOgWfrg== X-Developer-Key: i=aweber.kernel@gmail.com; a=openpgp; fpr=E663000EAC1DECCD6AD2890DB3BBF8A113A05168 Add a device tree property, "maxim,usb-connector", that can be used to specify a USB connector to use to detect whether a charging cable has been plugged in/out, and enable/disable charging accordingly. To accommodate this, also add an internal pointer to the CHARGER regulator, which is used to enable/disable charging and set the input current limit (which will be done in subsequent commits). The extcon listener/worker implementation is inspired by the rt5033_charger driver. Signed-off-by: Artur Weber --- Changes in v2: - Changed to adapt to both current limits being managed by one function --- drivers/power/supply/Kconfig | 1 + drivers/power/supply/max77693_charger.c | 125 ++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+) diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index 3e31375491d5..e4aeff9e7ad1 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -549,6 +549,7 @@ config CHARGER_MAX77650 config CHARGER_MAX77693 tristate "Maxim MAX77693 battery charger driver" depends on MFD_MAX77693 + depends on EXTCON || !EXTCON help Say Y to enable support for the Maxim MAX77693 battery charger. diff --git a/drivers/power/supply/max77693_charger.c b/drivers/power/supply/max77693_charger.c index 0ddaa03669a2..2dc273dd96ee 100644 --- a/drivers/power/supply/max77693_charger.c +++ b/drivers/power/supply/max77693_charger.c @@ -5,6 +5,8 @@ // Copyright (C) 2014 Samsung Electronics // Krzysztof Kozlowski +#include +#include #include #include #include @@ -30,6 +32,13 @@ struct max77693_charger { u32 batttery_overcurrent; u32 fast_charge_current; u32 charge_input_threshold_volt; + + /* USB cable notifications */ + struct { + struct extcon_dev *edev; + struct notifier_block nb; + struct work_struct work; + } cable; }; static int max77693_get_charger_state(struct regmap *regmap, int *val) @@ -664,17 +673,110 @@ static int max77693_reg_init(struct max77693_charger *chg) chg->charge_input_threshold_volt); } +static int max77693_set_charging(struct max77693_charger *chg, bool enable) +{ + int is_enabled; + int ret = 0; + + is_enabled = regulator_is_enabled(chg->regu); + if (is_enabled < 0) + return is_enabled; + + if (enable && !is_enabled) + ret = regulator_enable(chg->regu); + else if (!enable && is_enabled) + ret = regulator_disable(chg->regu); + + return ret; +} + +static void max77693_charger_extcon_work(struct work_struct *work) +{ + struct max77693_charger *chg = container_of(work, struct max77693_charger, + cable.work); + struct extcon_dev *edev = chg->cable.edev; + int connector, state; + int ret; + + for (connector = EXTCON_USB_HOST; connector <= EXTCON_CHG_USB_PD; + connector++) { + state = extcon_get_state(edev, connector); + if (state == 1) + break; + } + + switch (connector) { + case EXTCON_CHG_USB_SDP: + case EXTCON_CHG_USB_DCP: + case EXTCON_CHG_USB_CDP: + case EXTCON_CHG_USB_ACA: + case EXTCON_CHG_USB_FAST: + case EXTCON_CHG_USB_SLOW: + case EXTCON_CHG_USB_PD: + ret = max77693_set_charging(chg, true); + if (ret) { + dev_err(chg->dev, "failed to enable charging\n"); + break; + } + dev_info(chg->dev, "charging. connector type: %d\n", + connector); + break; + default: + ret = max77693_set_charging(chg, false); + if (ret) { + dev_err(chg->dev, "failed to disable charging\n"); + break; + } + dev_info(chg->dev, "charging. connector type: %d\n", + connector); + break; + } + + power_supply_changed(chg->charger); +} + +static int max77693_charger_extcon_notifier(struct notifier_block *nb, + unsigned long event, void *param) +{ + struct max77693_charger *chg = container_of(nb, struct max77693_charger, + cable.nb); + + schedule_work(&chg->cable.work); + + return NOTIFY_OK; +} + #ifdef CONFIG_OF static int max77693_dt_init(struct device *dev, struct max77693_charger *chg) { struct power_supply_battery_info *battery_info; struct device_node *np = dev->of_node; + struct device_node *np_conn, *np_edev; if (!np) { dev_err(dev, "no charger OF node\n"); return -EINVAL; } + np_conn = of_parse_phandle(np, "maxim,usb-connector", 0); + np_edev = of_get_parent(np_conn); + + chg->cable.edev = extcon_find_edev_by_node(np_edev); + if (IS_ERR(chg->cable.edev)) { + /* + * In case of deferred extcon probe, defer our probe as well + * until it appears. + */ + if (PTR_ERR(chg->cable.edev) == -EPROBE_DEFER) + return PTR_ERR(chg->cable.edev); + /* + * Otherwise, ignore errors (the charger can run without a + * connector provided). + */ + dev_warn(dev, "no extcon device found in device-tree (%ld)\n", + PTR_ERR(chg->cable.edev)); + } + if (of_property_read_u32(np, "maxim,constant-microvolt", &chg->constant_volt)) chg->constant_volt = DEFAULT_CONSTANT_VOLT; @@ -752,6 +854,26 @@ static int max77693_charger_probe(struct platform_device *pdev) if (ret) return ret; + /* Set up extcon if the USB connector node was found */ + if (!IS_ERR(chg->cable.edev)) { + ret = devm_work_autocancel(&pdev->dev, &chg->cable.work, + max77693_charger_extcon_work); + if (ret) { + dev_err(&pdev->dev, "failed: initialize extcon work\n"); + return ret; + } + + chg->cable.nb.notifier_call = max77693_charger_extcon_notifier; + + ret = devm_extcon_register_notifier_all(&pdev->dev, + chg->cable.edev, + &chg->cable.nb); + if (ret) { + dev_err(&pdev->dev, "failed: register extcon notifier\n"); + return ret; + } + } + ret = device_create_file(&pdev->dev, &dev_attr_fast_charge_timer); if (ret) { dev_err(&pdev->dev, "failed: create fast charge timer sysfs entry\n"); @@ -778,6 +900,9 @@ static int max77693_charger_probe(struct platform_device *pdev) device_remove_file(&pdev->dev, &dev_attr_top_off_threshold_current); device_remove_file(&pdev->dev, &dev_attr_fast_charge_timer); + devm_extcon_unregister_notifier_all(&pdev->dev, chg->cable.edev, + &chg->cable.nb); + return ret; } From patchwork Mon Jul 15 12:55:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 812725 Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8F7518F2C7; Mon, 15 Jul 2024 12:55:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721048128; cv=none; b=jeT8siUtvWvNIJb7hluiXFeQnJ9yzz0Xm4c1U5uMlKB87Kj5wfEirG4YBNMqQ6oWeUXGALxtWxLDeFnq8auamkmOQbJtZy9IxkuKJmm392mqnNahJXDa9sqF2hRntlfZsbVYoEJqAh75I0C/v3WF7O/fJK2FBKbawiAuB2GkuNw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721048128; c=relaxed/simple; bh=EXZReySANjkAeBrLFiKGCwE8yARrL34C4+BpkRUqMJU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XSGbP8Lp6hHytNVIjVVGdZd1NmB46AEXoGmvSXadbSz6c9q8scoYr+biZjvhRwWM5ENvB4YgC07dA1Y8y3on3+sA3atjwrW8w0uJEAf1wiIGazXpzrw21q5ZZz8rozEHX0EaEOdekUK5C9PYiNzlPscsgKCOeVcUf2pkref6ZCo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=hZA8KbwE; arc=none smtp.client-ip=209.85.208.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hZA8KbwE" Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-585e774fd3dso5507157a12.0; Mon, 15 Jul 2024 05:55:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721048125; x=1721652925; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=yplmBPab31T+ENfBznOyfetvZRWw0PUytsuLn61zZ54=; b=hZA8KbwE0uPXkDMRhZ+SqOZ9We/9+eJbC1aRgLBWPU/Ip4palY8LdG5xRSVe10JMvk AaSLBIxrVJzXbYiddadn8nk1HJSI2KeQ7xdP37XE6sTYpwDe9rYO0Lo4JcVMr6AyWt6J IH+RKgP3ZxeE8BdBn6p/6jQ1rehNZQMKbNr7mbMltEZ6tCkWXcW/D4rjLEO3fFekCVe5 1iUIH3OrTC6CP1rJwGGlpzOFB/qGLyPFajEthYNKAHzZudsvhZ05FSAdZ3Ba3XQfNqjq GvPSfFaMvtoMQG/4xsLm7sXismKsMG0g1/uSwvdEs5AMvMmHdnDoNeNuC7z47atiHHau OQow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721048125; x=1721652925; 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=yplmBPab31T+ENfBznOyfetvZRWw0PUytsuLn61zZ54=; b=CrpfdfFJGGBE9/36uUiVaNQl2KPhsvqB5RzSFvs2DYthL8tT/azajt/jBcsGtLUQxd trpsObqXq8CrWfLVUxd0qKD673x4WRw9J0/D3vR9fJKGeKRGVrDM5BlEEgmGWFN38ZIb xBE4wEjtrDncwzVJ2KmtIJ7HM3bc42t/4OQW3CG4O5eJMY69OzA/k/bFitb2ykMvZPCN t961bf5mdZdnUeyLMDiOcmGYUBgoTX7ZrsCB6RMP1cCOjDHAnKsFIfw2572y5V3VJ0a/ y/Vof0AGhqgE1lqrX+fNPrSlyFIJQFH3IkKpEaY0G37eXah/Q82+ea0DXLctCKUrvQRz kazg== X-Forwarded-Encrypted: i=1; AJvYcCU5pB6gse0JLP+5r5yj4NZPNg764V6na35SN153W8bEZMXZmpsa+0Rou5IcLeNNuVPkNY6xZEKGyd7YOPt3hXbaMKIh9fe6o0US3gjdI4n+eZakeWIg0QWce8DxoMWjFGwPqq5n1lT2S3L+tTlkr0jyIY+8GEXDk8w5/1wDVSopIZKz1leQh8xzI9N96XV01/VN5IrDy4t1xN7Dv9AbfspUGJI/+KA= X-Gm-Message-State: AOJu0YzfwfBis4JxTesSirQMTVdv9T72FXIlYwaGOJqa6jaHhvQFxwIK y8vOVhfaIE/XIVP7hd0H3gOKuFlrNyxaRFtYxJA5WmNNTHl85IF5l62uxZwg X-Google-Smtp-Source: AGHT+IEi0rB6grzKm+6JFok97+M2O9K/mc/iV01iqXjDpsx+NrTD6Yh0aFRRjs4CR0X9xR4LS9ghuw== X-Received: by 2002:a05:6402:11cb:b0:58e:4088:ed2 with SMTP id 4fb4d7f45d1cf-594baf8d6e7mr14449097a12.16.1721048125174; Mon, 15 Jul 2024 05:55:25 -0700 (PDT) Received: from tablet.my.domain (ip-37-248-157-210.multi.internet.cyfrowypolsat.pl. [37.248.157.210]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-59b26f62165sm3333307a12.87.2024.07.15.05.55.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 05:55:24 -0700 (PDT) From: Artur Weber Date: Mon, 15 Jul 2024 14:55:09 +0200 Subject: [PATCH v2 7/9] power: supply: max77693: Add support for detecting and enabling OTG Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240715-max77693-charger-extcon-v2-7-0838ffbb18c3@gmail.com> References: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> In-Reply-To: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> To: Krzysztof Kozlowski , Chanwoo Choi Cc: Sebastian Reichel , Rob Herring , Conor Dooley , Lee Jones , Krzysztof Kozlowski , Alim Akhtar , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Henrik Grimler , Wolfgang Wiedmeyer , Denis 'GNUtoo' Carikli , Artur Weber X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6011; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=EXZReySANjkAeBrLFiKGCwE8yARrL34C4+BpkRUqMJU=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmlRwqLWuWZaYoe183l0Kev4lM9FuRl+x8JjYe9 DhmziyLvsyJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZpUcKgAKCRCzu/ihE6BR aFqqD/9k+4cgfR7QbdCgxHMiTAdYZ6yaMlYJNKYairM6DJecVzZQ9oSl9CvPMC3Y+Mj7V+yDDM1 8uPupF/FP1Ske93xmu36wjbQsAc+6HsqG5Y49oq4pphAO6OKKmJLIlRMoxut9Y4S6cAob1K2l8j e3HKLdOgDxsMS3141wj9AgOxNOtbAzdcxrbpxng59RY3AKGSQU2vvIEvs1OiSvHezgrNZhQWBYa LuuUrGDZsYRChOMDovahmJ0FncmO2GSJSJ1pAbGmkyXJ03q/3a6EN0sEF0sZeHw464raM7I8mMI 5CxZbw7kbrvlZmUZrOfM60EIflph3OADafH1lL1vkV7KsKfLJNES2M4qjJwKNuOy60yKzr7fkz8 FD2tp8AvXjQGRbOhSougbNWjMrCkDhXJ0/dEGlZtgWJCrUetds8gOdU9lUXPq8SdZIk7YMoXjJP d9PL6RZ4r+pgDshMGQ6DJ+yCOQ5nuK+rEygkf32lW7PvdJ0B9Qj1lufEAJk9xUX1yeOdB5+RkCI 223MTVODK1YqRC5CVqnYKpGEGB6ATxrElIV7VzWZBKo4/s8L6K/O16q1K7bezshjOCkEtxd9bp0 6Mge3bn1D0xnpkJ5jQBXodYbxSsXbfyzqoCDT+diuZGwPqjudw1W/DfiznkMpdZnoPYdBkRZFYU I7W0r/aPUFzncuQ== X-Developer-Key: i=aweber.kernel@gmail.com; a=openpgp; fpr=E663000EAC1DECCD6AD2890DB3BBF8A113A05168 Building upon the newly added extcon detection support, add detection for USB OTG cables (EXTCON_USB_HOST type), and enable/disable the OTG bits as needed. Signed-off-by: Artur Weber Acked-by: Lee Jones --- Changes in v2: - Added CHGIN OTG current limit value - Squashed MFD header register changes into this commit --- drivers/power/supply/max77693_charger.c | 103 +++++++++++++++++++++++++++----- include/linux/mfd/max77693-private.h | 5 ++ 2 files changed, 94 insertions(+), 14 deletions(-) diff --git a/drivers/power/supply/max77693_charger.c b/drivers/power/supply/max77693_charger.c index 2dc273dd96ee..34d68b1050d4 100644 --- a/drivers/power/supply/max77693_charger.c +++ b/drivers/power/supply/max77693_charger.c @@ -669,6 +669,16 @@ static int max77693_reg_init(struct max77693_charger *chg) if (ret) return ret; + /* Set OTG current limit to 900 mA */ + data = (0x1 << CHG_CNFG_02_OTG_ILIM_SHIFT); + ret = regmap_update_bits(chg->max77693->regmap, + MAX77693_CHG_REG_CHG_CNFG_02, + CHG_CNFG_02_OTG_ILIM_MASK, data); + if (ret) { + dev_err(chg->dev, "Error setting OTG current limit: %d\n", ret); + return ret; + } + return max77693_set_charge_input_threshold_volt(chg, chg->charge_input_threshold_volt); } @@ -690,11 +700,42 @@ static int max77693_set_charging(struct max77693_charger *chg, bool enable) return ret; } +static int max77693_set_otg(struct max77693_charger *chg, bool enable) +{ + struct regmap *regmap = chg->max77693->regmap; + unsigned int data; + bool is_enabled; + int ret; + + ret = regmap_read(regmap, MAX77693_CHG_REG_CHG_CNFG_00, &data); + if (ret) + return ret; + + is_enabled = !!(data & CHG_CNFG_00_OTG_MASK); + + if (enable && !is_enabled) { + /* OTG on, boost on, DIS_MUIC_CTRL on */ + data |= CHG_CNFG_00_OTG_MASK | CHG_CNFG_00_BOOST_MASK \ + | CHG_CNFG_00_DIS_MUIC_CTRL_MASK; + + } else if (!enable && is_enabled) { + /* OTG off, boost off, DIS_MUIC_CTRL off */ + data &= ~(CHG_CNFG_00_OTG_MASK | CHG_CNFG_00_BOOST_MASK \ + | CHG_CNFG_00_DIS_MUIC_CTRL_MASK); + } + + return regmap_write(chg->max77693->regmap, + MAX77693_CHG_REG_CHG_CNFG_00, + data); +} + static void max77693_charger_extcon_work(struct work_struct *work) { struct max77693_charger *chg = container_of(work, struct max77693_charger, cable.work); struct extcon_dev *edev = chg->cable.edev; + bool set_charging, set_otg; + unsigned int current_limit; int connector, state; int ret; @@ -707,31 +748,61 @@ static void max77693_charger_extcon_work(struct work_struct *work) switch (connector) { case EXTCON_CHG_USB_SDP: - case EXTCON_CHG_USB_DCP: case EXTCON_CHG_USB_CDP: + case EXTCON_CHG_USB_SLOW: + current_limit = 500000; /* 500 mA */ + set_charging = true; + set_otg = false; + + dev_info(chg->dev, "slow charging. connector type: %d\n", + connector); + break; + case EXTCON_CHG_USB_DCP: case EXTCON_CHG_USB_ACA: case EXTCON_CHG_USB_FAST: - case EXTCON_CHG_USB_SLOW: case EXTCON_CHG_USB_PD: - ret = max77693_set_charging(chg, true); - if (ret) { - dev_err(chg->dev, "failed to enable charging\n"); - break; - } - dev_info(chg->dev, "charging. connector type: %d\n", + current_limit = chg->fast_charge_current; + set_charging = true; + set_otg = false; + + dev_info(chg->dev, "fast charging. connector type: %d\n", + connector); + break; + case EXTCON_USB_HOST: + current_limit = 500000; /* 500 mA */ + set_charging = false; + set_otg = true; + + dev_info(chg->dev, "USB host. connector type: %d\n", connector); break; default: - ret = max77693_set_charging(chg, false); - if (ret) { - dev_err(chg->dev, "failed to disable charging\n"); - break; - } - dev_info(chg->dev, "charging. connector type: %d\n", + current_limit = 500000; /* 500 mA */ + set_charging = false; + set_otg = false; + + dev_info(chg->dev, "disconnected. connector type: %d\n", connector); break; } + ret = max77693_set_current_limit(chg, current_limit); + if (ret) { + dev_err(chg->dev, "failed to set current limit (%d)\n", ret); + goto out; + } + + ret = max77693_set_charging(chg, set_charging); + if (ret) { + dev_err(chg->dev, "failed to set charging (%d)\n", ret); + goto out; + } + + ret = max77693_set_otg(chg, set_otg); + if (ret) + dev_err(chg->dev, "failed to set OTG (%d)\n", ret); + +out: power_supply_changed(chg->charger); } @@ -793,6 +864,10 @@ static int max77693_dt_init(struct device *dev, struct max77693_charger *chg) &chg->batttery_overcurrent)) chg->batttery_overcurrent = DEFAULT_BATTERY_OVERCURRENT; + if (of_property_read_u32(np, "maxim,fast-charge-current-microamp", + &chg->fast_charge_current)) + chg->fast_charge_current = DEFAULT_FAST_CHARGE_CURRENT; + if (of_property_read_u32(np, "maxim,charge-input-threshold-microvolt", &chg->charge_input_threshold_volt)) chg->charge_input_threshold_volt = diff --git a/include/linux/mfd/max77693-private.h b/include/linux/mfd/max77693-private.h index 4570646e2f33..313fcc3173f9 100644 --- a/include/linux/mfd/max77693-private.h +++ b/include/linux/mfd/max77693-private.h @@ -209,7 +209,10 @@ enum max77693_charger_battery_state { /* MAX77693 CHG_CNFG_00 register */ #define CHG_CNFG_00_CHG_MASK 0x1 +#define CHG_CNFG_00_OTG_MASK 0x2 #define CHG_CNFG_00_BUCK_MASK 0x4 +#define CHG_CNFG_00_BOOST_MASK 0x8 +#define CHG_CNFG_00_DIS_MUIC_CTRL_MASK 0x20 /* MAX77693_CHG_REG_CHG_CNFG_01 register */ #define CHG_CNFG_01_FCHGTIME_SHIFT 0 @@ -222,6 +225,8 @@ enum max77693_charger_battery_state { /* MAX77693_CHG_REG_CHG_CNFG_02 register */ #define CHG_CNFG_02_CC_SHIFT 0 #define CHG_CNFG_02_CC_MASK 0x3F +#define CHG_CNFG_02_OTG_ILIM_SHIFT 7 +#define CHG_CNFG_02_OTG_ILIM_MASK 0x80 /* MAX77693_CHG_REG_CHG_CNFG_03 register */ #define CHG_CNFG_03_TOITH_SHIFT 0 From patchwork Mon Jul 15 12:55:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 813605 Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2DD5318F2F1; Mon, 15 Jul 2024 12:55:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721048130; cv=none; b=q9gBvEnuUD+230klBdgH86l2DipxFs8YIRopOoL4JahKeM68vU/EStTQZCTPjd/LUfoRz7UDhIHse+Z4JwrRqDDR/mMEJ1M9yi42teVB8WCgeqT+3iaNpZFwVqkihTMle8VIMKhixoxdAF5CxKlY2TnXV5SswWnFWVViEelWKM8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721048130; c=relaxed/simple; bh=qWV+h/xYbFz0ncn8qK2kKImU9+PgmBKdHlR1+5460gc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZfUq1kvzUzr+Mt8VE8qj4PQcR61BLavZKi5t5Vf/nglrjFAA6B5Oi4TxqGG0n5r63vDFhsYrIbE8zQz7CNc4gcr1VaxUPFZfM9Pe0333KFPn/h9eOdmy7+g2ntHJeIKTqo2RrIkmOEIN8ENWGnVwjJz+uH/Un3IlkVOaFnWTTug= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=eKKtlaX4; arc=none smtp.client-ip=209.85.208.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eKKtlaX4" Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-595850e7e11so5301347a12.1; Mon, 15 Jul 2024 05:55:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721048127; x=1721652927; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=8XYGMuF1Px9oyTqZPSe/yTfw7ie0wV1T6OCEdpBxL0w=; b=eKKtlaX4weirzgG8ry0dK5CHDI7LjrxwzF/uk/mUmmk9EiKsLmsIXXwNbwZmUPd19R 1VGlEx71Fd5yUZ37llegT+2dwIh7FKJcTtt84hqZ3RBBmZ63MnJBRPn/9579twIGK3qn bGUnqsDQgxYju8FcR1hgML1Xqfj1RGOgJNHMa8pp24so8b/1G5QtKlEzvrAHPuLYkn9t hVTfnfa/NvcMV3sf2O0V6GFq3UMp+NjMpvX7A65kcmQi8z4zz5tHadltLf41OynHSlds pAPEj3oI2T00KkB4SJIYDqlUmdv722+fd/HKE9AwGSBQRcDcUBTCEtxoEerLyeG7WlBX KDjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721048127; x=1721652927; 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=8XYGMuF1Px9oyTqZPSe/yTfw7ie0wV1T6OCEdpBxL0w=; b=eK8SaQ0FGBkZ5NOvxcRXQ+gMy1itFyYknjV6jU37szCTor+trgUONipoXA7lBqn/m1 Unh9b9fDYDyHrlWZZh28vIVHUuj+Bz9Cgi+ukjqwK6iYSK36izfquep4DZOLH2cvvrWD Qtp5C1WNGYwvuylFgRvMMqFyznYizZQad/NSsnB8K5InQO+vYKbT1OkcEYXyC7XSeo3j J1X0iYHx6vER6fRYTkgr6lW6zc6HH4v8dqgrH/1EmSqZOpASwG5w782R7hKh6u1kMUHq ynRnpwVPKUKRh/EvYOMbVJSQ7zNQdFJT3X0bj9UU3EQyv193946YXUDQBkHTpgk6q0eB IRkw== X-Forwarded-Encrypted: i=1; AJvYcCWVQ2MoY72gryhuG8ta4ZWIh0vCq7yF5MiV9sYvmt6FtIuwg8MjZY7e80V6j9KfF8PRQXRN3UQp6VvslfyQUlBeWfWbwzrO+6KgjavjjDG5FcIQLLaPIy1/SrtmFA85CXZDbzWShIGBTQc8q+LtuiQgY6moixJ2LAsXGQoTSrbNQ1Ebl2cCLWARg1QW1/kR/1Al44EVHHb88/gNxR6JRznsjjCHt5c= X-Gm-Message-State: AOJu0Yz4hvCNkGREFkyPY2lk1UKlNOG1N5kf7gt3kXXkPCZV/513AUCr gIsCIGb9MCnkp3IcSSyIqx1CBRa0nC29h6XzmcJh4y7XdNFV8+bgvet7jz3i X-Google-Smtp-Source: AGHT+IFmHSVvcKYIfet4Vd+j7mQCt11AG4ZGYcRC6ZqhWGgENzJ92CnMf6jnirVTsXjCdmjb0Rdetg== X-Received: by 2002:a05:6402:2353:b0:58b:1737:1143 with SMTP id 4fb4d7f45d1cf-594b9b047d4mr16175281a12.9.1721048127126; Mon, 15 Jul 2024 05:55:27 -0700 (PDT) Received: from tablet.my.domain (ip-37-248-157-210.multi.internet.cyfrowypolsat.pl. [37.248.157.210]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-59b26f62165sm3333307a12.87.2024.07.15.05.55.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 05:55:26 -0700 (PDT) From: Artur Weber Date: Mon, 15 Jul 2024 14:55:10 +0200 Subject: [PATCH v2 8/9] ARM: dts: samsung: exynos4212-tab3: Add battery node with charge current value Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240715-max77693-charger-extcon-v2-8-0838ffbb18c3@gmail.com> References: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> In-Reply-To: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> To: Krzysztof Kozlowski , Chanwoo Choi Cc: Sebastian Reichel , Rob Herring , Conor Dooley , Lee Jones , Krzysztof Kozlowski , Alim Akhtar , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Henrik Grimler , Wolfgang Wiedmeyer , Denis 'GNUtoo' Carikli , Artur Weber X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1385; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=qWV+h/xYbFz0ncn8qK2kKImU9+PgmBKdHlR1+5460gc=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmlRwqz/mNBhtmHMjP9x0SegLgvHeyjSasKP4io /Ot65+rEcWJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZpUcKgAKCRCzu/ihE6BR aE2xD/0XcYfzNUnxcW31v4agx+YsQLMSCJvVejsHdSOgFuf+5W50fQwce8+oElnO+jms5rNOAxr bkU3c5zJOd7nuM695tJTUJ+1Kh0v3Gf57jhb86dHgiYq0fXIteWyGyX2jRGU2pSNg9gH/Zz1eCH IWXUV/eoXvZk75f+O17QgoX2W/noowMHOwwlNFM9CukLbCoE7t1a8pTRvIlgKg7l+5HQRe3JghA GJVfHucjWQx9+4KjOolKOJg/Vozo6ansJrmD0vsEPGD8E16Ob7vXk9aDt4xuvyqELKEqB2J6zHm 3528VHJ8tYBV/U/tQ+fV0jXveYUJdRQxi6sCWMtXSdOWka8M3cfjQfuyqO0tljBa3R3ZAdnRS/v d+7ZwyEkv1g5XtdfxfYCXq9qbOFvf15BBZ9BCMtHWYwI0qhTiHUinnxw5flSLJgmXprV26JPLyf LjR2IfOUoLqN6SW1NouTOfIn9uUw+3YdUs6obQgu39FhnUva16GL/2xVevNf7wlrlvflFPfJRKY ZdK8ZaeUTcW37nwNBvKqs7ZEZXRGYovByT2w3SLe2ASEwRdbbEsxOtvW45G5V1HjJi+ydpiPKQ3 Spw14yinRB1wu/6zmMBDWgfUXT3UdS022XroseU6wIENBoebyHjSIv+zeNyDt07Gkf9+/tzWdET Wcg0439UjsJcHEA== X-Developer-Key: i=aweber.kernel@gmail.com; a=openpgp; fpr=E663000EAC1DECCD6AD2890DB3BBF8A113A05168 This value was verified by comparing register dumps of the MAX77693 charger with on mainline with a downstream kernel under Android; the value on downstream was set to 1.8 amps when charging with a proper charger. Add it to a new battery node and pass it to the MAX77693 charger so that the fast charge current setting can be used for charging. Signed-off-by: Artur Weber --- Changes in v2: - Switched to monitored-battery --- arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi b/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi index e5254e32aa8f..7905e33234f2 100644 --- a/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi +++ b/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi @@ -153,6 +153,7 @@ charger_reg: CHARGER { charger { compatible = "maxim,max77693-charger"; + monitored-battery = <&battery>; maxim,constant-microvolt = <4350000>; maxim,min-system-microvolt = <3600000>; @@ -294,6 +295,11 @@ submic_bias_reg: voltage-regulator-5 { regulator-max-microvolt = <2800000>; }; + battery: battery { + compatible = "simple-battery"; + constant-charge-current-max-microamp = <1800000>; + }; + sound: sound { compatible = "samsung,midas-audio"; model = "TAB3"; From patchwork Mon Jul 15 12:55:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 812724 Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D9A7B18FA2C; Mon, 15 Jul 2024 12:55:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721048132; cv=none; b=APqAk14QXkd6vlGblqZZDKFTcbeH5FZa63YxrBpHJd9uAXtIw7fp1lMbmYpP1qbBQN2Hq3d0n38opiMpWme9dzTTkxgZxnzV/xM/nMi4QYg2tNkd4f7nHpEmuQA7ucsv2PmZVb45tReK/FzeQa2OGhHi4BWsvAo/oy+9XP1U9Ws= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721048132; c=relaxed/simple; bh=JPvmuWMb9Cv6qRz3cEGIn/kWuF1SOLW1hi0UXwnEzKQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LZ6Z8B3i8nLuU/tkgTIxZiqFfcRWu/EcPyXV1m1STwcSfjKiTYQoo0PbVytUEjNRbuxD18gQ8pB/vqg9I5levc4BFe0Y2dWSTrbvpAXJIcBr6SYI9k2PG9ISfgvukVlgbJ1xPm30fGwUNT/pq0Pwec3rVOv7o6l6oQM6Hz2r21c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=hIXtwzIO; arc=none smtp.client-ip=209.85.208.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hIXtwzIO" Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2eee1384e0aso21675831fa.1; Mon, 15 Jul 2024 05:55:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721048129; x=1721652929; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=g142l+1Rp8I4V1ReaaLX7dN3MJPiIMAN9KWL++3gC6o=; b=hIXtwzIOWrDvYitkLe5qMQs1KWxw9g96vgApmLCL3xxcORS3uby5rHn5jzcyCdytO+ fVwrXzc7lMOBwJqOIcB3ovPNa+ed3LV0v2pqq6ifamgAit+8tMKLPM4Ggq8lRk3u9xbq 8TpjW3AMm2kYsL2KvSLw6OurkvVN9AjyxdZ+/4YZi3LJMrHLtub9yfS6Rw8mFIzO08DJ 18cnACU2Ko0kVUbPv9bG1zYuWAdXfSVHjEnZ63EoDPQTL7A82McB86HloUY1MBu5LCoZ 3zTainZ7fSkPC42UjY73j/HjTlf4jfAMeYeJIul626roCQ+8R6Y8zt8mZkFSOFcPwmCo 0QsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721048129; x=1721652929; 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=g142l+1Rp8I4V1ReaaLX7dN3MJPiIMAN9KWL++3gC6o=; b=rWo3BeZRi/W+6885Qo9oyKftjGDe+zKRq47MiEsoYHdY75V7AOfVdnuUdOorVC9Gf+ nvtq0tfw5EhL/3eB5pD8g/3uy2G9R41WNa1IBmnQ+sCs1KBW7EF4qYXW3nyNuBcYts0z sqH+UEDo1ansl4yeIJRxpvdmPumawdmKsGqCr/JLXcSjHlQOHa/fLYK1IxLZacPOJ6jd HNqXjV3pjbqlzy/FshxDUVzudJrjWcEuUMXK4aVtPOkLqcstHTrn5/EjtUW0Ki2A9SB8 4dytpO41CCF7f//u2pki5eMes3r2Ah+2sE4JiEKkL+Txk0aoqD3P1bkBDQZXrnqJ8XDe NOSA== X-Forwarded-Encrypted: i=1; AJvYcCXPhcM5ymzLFxxzw7FheR20KQGMSb4p+1OF74O8VmsXaiaL40caHHQxlFN7nvrWUA/Iy5yGoxMPniP6HWNIZFDl3tZRtPuwPQr/7rkXhNXC61/6dmVLCLQAWpJJHCerSa0i/X/FaEMX3O4ju2aFlEvCpwoKPf4YWqLCgsE10cPlfpnTwVGFzPyXcL2/ycrUgi6a0EZwzTwGlTvASnIC8PAckMUQosc= X-Gm-Message-State: AOJu0YxchuPRxiasQv+1wt9JwEYGzHiznAa7XadVb2aNRF27rW0FUxlq 92B3lreW/gbXCIMoijqq725R4+gcaF4IpOXWDwPbDsgjTg/buPBTeizcrYFp X-Google-Smtp-Source: AGHT+IFx8MQcTRzx3JN+U8ZxghUQcdnvTgYnKydFLvaBZKUXf4eaprXj8MMYOE+oITfaurUMxJRBMQ== X-Received: by 2002:a05:6512:2247:b0:52c:dec1:4578 with SMTP id 2adb3069b0e04-52eb99d3d82mr11609664e87.60.1721048129043; Mon, 15 Jul 2024 05:55:29 -0700 (PDT) Received: from tablet.my.domain (ip-37-248-157-210.multi.internet.cyfrowypolsat.pl. [37.248.157.210]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-59b26f62165sm3333307a12.87.2024.07.15.05.55.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 05:55:28 -0700 (PDT) From: Artur Weber Date: Mon, 15 Jul 2024 14:55:11 +0200 Subject: [PATCH v2 9/9] ARM: dts: samsung: exynos4212-tab3: Add USB connector node Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240715-max77693-charger-extcon-v2-9-0838ffbb18c3@gmail.com> References: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> In-Reply-To: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> To: Krzysztof Kozlowski , Chanwoo Choi Cc: Sebastian Reichel , Rob Herring , Conor Dooley , Lee Jones , Krzysztof Kozlowski , Alim Akhtar , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Henrik Grimler , Wolfgang Wiedmeyer , Denis 'GNUtoo' Carikli , Artur Weber X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1245; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=JPvmuWMb9Cv6qRz3cEGIn/kWuF1SOLW1hi0UXwnEzKQ=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmlRwqnFSOEjC8QWSCPslauoOTiO933O3gvdDEc e3gOsFdVleJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZpUcKgAKCRCzu/ihE6BR aFmxEACYfKH/GNZtUBx1ayE51+WDZH8Lsh7YCHzX0J0u0GIF7sy4e52YDmnH48GfzystWyPPaXX 4tChxghI0ZSVFts1vH67Iqd3zBRaDCJkHERejtV5sMP6QIX5hSlqD8pj4OAFPecpgcJG3dT+pLj IK330kJ2pKG36NHMRti2HiX1GtLzdG4YL7EakFGVo79x2s0V1dLXYrUz8BGFpeEDT9sHnYVA/0x wKkvzRnSWK+aGj0Hj8AQHaC6z3+0J0sJin+VltFKpxLIIFuQtVZJzz9YXH+bpaHPg2oBBf6ixhE jReLMZEDFWSyt+bStQBUW6pp3ZB7vTx89JFQh1l9eIzLwufABxHIWWcKBcK1pBPGaWE5T42vLcr tfLeyEG9XJiypKn6b9SPCVsEvulMQ4y/zjhOZhiLht7qe3EtHkEEex0SAOKD1IGsR01bVhnOtfJ f4ojHCmJMu58yv0PLcKYW9JzCEW4zVp3rePVQngPLpYhCbM+iskfDyhP3z/d0aiBU05GojgWItf j6YyJEC0wpDsLiLDZF48LEMBb6sT3LjQtHXcME4t6fJeox3Nw9KPh6Dh9s40VGQxSzETgSd+i17 dB8Pf1NRrzuZ0lGjYPXjfPTh8Vo2SMTqsGlijr2xWVcWYxXZN0cKKoIix6fRrngVy79JzpYP1FL tULnfR+O6VXKZxw== X-Developer-Key: i=aweber.kernel@gmail.com; a=openpgp; fpr=E663000EAC1DECCD6AD2890DB3BBF8A113A05168 Add a subnode to the MAX77693 MFD for the MUIC and connect the USB connector node to the charger to allow for charger type/OTG cable detection. Signed-off-by: Artur Weber --- arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi b/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi index 7905e33234f2..f5ee3640a940 100644 --- a/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi +++ b/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi @@ -151,6 +151,17 @@ charger_reg: CHARGER { }; }; + muic { + compatible = "maxim,max77693-muic"; + + usb_conn: connector { + compatible = "samsung,usb-connector-11pin", + "usb-b-connector"; + label = "micro-USB"; + type = "micro"; + }; + }; + charger { compatible = "maxim,max77693-charger"; monitored-battery = <&battery>; @@ -160,6 +171,8 @@ charger { maxim,thermal-regulation-celsius = <100>; maxim,battery-overcurrent-microamp = <3500000>; maxim,charge-input-threshold-microvolt = <4300000>; + + maxim,usb-connector = <&usb_conn>; }; }; };