Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp4598093rwr; Mon, 8 May 2023 09:49:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5fOhJMzIRvWu/L5Ewqv0HCT/0QSxZDHPdn8d2ZyCjoMh/GgFjHvRVd6zo33AhRTaSuYb7c X-Received: by 2002:a17:903:245:b0:1a9:85f2:5df6 with SMTP id j5-20020a170903024500b001a985f25df6mr13037706plh.6.1683564555805; Mon, 08 May 2023 09:49:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683564555; cv=none; d=google.com; s=arc-20160816; b=JB2kW6/86Zem3sQIdsrCOTYC1UwM5mLQjPM+zuloO11TfgDp1gwFen9Xd5R2lF6uZE c+o610lBJFz9Xet32OOOmjitQ6kqY1fOeEjKADWhwDr/Tag/61qtkbmZuray060Yvmku 0nf5YDb3p9fKQpMh9tsfMQg81nPbw/G0EAjAOw+mb7aG7VDLt6cRAFAlu4fpaOOXJ/kX nSdGRquZkbzjGHGiIThOMq5nUp7ZoKm85bMRBQjH1FIIjj61F7ODQUmoAcvkd8D02Dun iv6sW+6gGCc/Ge1GDfT34GvFal1cZn6pFE60gv+pb0T1Dci7AAc6VKYwd2L6H00fAHrU U6dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=mHI4blVbGWD+ix6BYWxIJ+uxXLB8TaKXmzOb2kvpHR8=; b=HuT9FRZmRg0RSoua43PIDsAT+AcWNIYu4bv3O1DRMmUk3qwOTOnyyBPyhrs7b6DzYc 5/CbxzUVbH2kz13HOb+lcGQ+86k/bb8T2MwJ8BgDjMWhSWBrV/cPuA/5/7zDpDSdpmdI bGmv1NaJU4jLf1T+f3TePOIsqE5Bu/R0W24ipOylslGCRCPF6dR1N8LTdZNgZnjnkTkV RO6pn0M9rSHaWzM1g+75rFrAKhxFowaq+u3teexuEi02M8nmd79JH1/OXT2TM9WVVfsv xKmSZxzJYD8fpbvj35/iGDA1mk11yQFUOGDlbUZsYODxKneeZmkh9waGYWw0RFxClkql lTcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=WPuBeesl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b5-20020a170902e94500b001ac3f3cc15fsi8115328pll.275.2023.05.08.09.49.01; Mon, 08 May 2023 09:49:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=WPuBeesl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234298AbjEHQhz (ORCPT + 99 others); Mon, 8 May 2023 12:37:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234319AbjEHQhi (ORCPT ); Mon, 8 May 2023 12:37:38 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 494E36E8F; Mon, 8 May 2023 09:37:35 -0700 (PDT) Received: from mercury (195-23-45-170.net.novis.pt [195.23.45.170]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: sre) by madras.collabora.co.uk (Postfix) with ESMTPSA id 68ECB66034CF; Mon, 8 May 2023 17:37:32 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1683563852; bh=uZCfI6nSerksNmlPugy693GyFz8gqLCBRGAQ3defUSo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WPuBeeslpqeyX/tYiivm5tjgQrfSuZl+GX5bEtLYBGwLFC0lCi8Z6P3MTH564TMb3 2q1N6gWhV1FS1xBH+pWruRt2R+zz9oQjNJGc2TyUqiJR4s1SDNVxmnZqrEi52RGlgt RIjCRZBxJaXY01kvORkC6czbvyNE9fNYOI39gPq6NIAiE42Z38oHpVE0BDGnb9H4PT VVqVgsk/eTK3dQCsXNhBVaMkCVvi4N6ueG2R/cHaYpWJ5kOgCG7nhb4f1+U7GzA9nO crONdNx+dWudnZlqMaavNEQrcspKTdFeqZTW8shmB36/giDwhpKdzBih+IFhsYX9+e SXIpkEtkKP3jw== Received: by mercury (Postfix, from userid 1000) id F26281066FA2; Mon, 8 May 2023 13:43:23 +0200 (CEST) Date: Mon, 8 May 2023 13:43:23 +0200 From: Sebastian Reichel To: Jakob Hauser Cc: Lee Jones , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Beomho Seo , Chanwoo Choi , Stephan Gerhold , Raymond Hackley , Pavel Machek , Axel Lin , ChiYuan Huang , Linus Walleij , Henrik Grimler , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, phone-devel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht Subject: Re: [PATCH v4 6/8] power: supply: rt5033_charger: Add cable detection and USB OTG supply Message-ID: <20230508114323.rzqbp2isvczzg3wx@mercury.elektranox.org> References: <20230506155435.3005-1-jahau@rocketmail.com> <20230506155435.3005-7-jahau@rocketmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="is77izww4ugbdpkq" Content-Disposition: inline In-Reply-To: <20230506155435.3005-7-jahau@rocketmail.com> X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_00,DATE_IN_PAST_03_06, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --is77izww4ugbdpkq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Sat, May 06, 2023 at 05:54:33PM +0200, Jakob Hauser wrote: > Implement cable detection by extcon and handle the driver according to the > connector type. >=20 > There are basically three types of action: "set_charging", "set_otg" and > "set_disconnect". >=20 > A forth helper function to "unset_otg" was added because this is used in = both > "set_charging" and "set_disconnect". In the first case it covers the rath= er > rare event that someone changes from OTG to charging without disconnect. = In > the second case, when disconnecting, the values are set back to the ones = =66rom > initialization to return into a defined state. >=20 > Additionally, there is "set_mivr". When connecting to e.g. a laptop/PC, t= he > minimum input voltage regulation (MIVR) shall prevent a voltage drop if t= he > cable or the supply is weak. The MIVR value is set to 4600MV, same as in = the > Android driver [1]. When disconnecting, MIVR is set back to DISABLED. >=20 > In the function rt5033_get_charger_state(): When in OTG mode, the chip > reports status "charging". Change this to "discharging" because there is > no charging going on in OTG mode [2]. >=20 > [1] https://github.com/msm8916-mainline/linux-downstream/blob/GT-I9195I/d= rivers/battery/rt5033_charger.c#L499 > [2] https://github.com/msm8916-mainline/linux-downstream/blob/GT-I9195I/d= rivers/battery/rt5033_charger.c#L686-L687 >=20 > Tested-by: Raymond Hackley > Signed-off-by: Jakob Hauser > --- > [...] > diff --git a/include/linux/mfd/rt5033.h b/include/linux/mfd/rt5033.h > index e99e2ab0c1c1..d2c613764756 100644 > --- a/include/linux/mfd/rt5033.h > +++ b/include/linux/mfd/rt5033.h > @@ -53,6 +53,14 @@ struct rt5033_charger { > struct rt5033_dev *rt5033; > struct power_supply *psy; > struct rt5033_charger_data *chg; > + struct extcon_dev *edev; > + struct notifier_block extcon_nb; > + struct work_struct extcon_work; > + struct mutex lock; > + bool online; > + bool otg; > + bool mivr_enabled; > + u8 cv_regval; > }; Please move 'struct rt5033_charger' and 'struct rt5033_charger_data' to drivers/power/supply/rt5033_charger.c; they are not supposed to be used directly by others. Making it private helps to avoid cross-subsystem series for future maintanence patches. Otherwise LGTM. -- Sebastian --is77izww4ugbdpkq Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAmRY4FsACgkQ2O7X88g7 +ppgzhAAiuyrMlrlL+A6FWUNH5NALnLtlzgNOlXErWC5EzseHFk7cDfSIgzoM+eR Fu6YN08pmniDN2okXmr4L+JRyu/8ALmtrgZRYG9t2juQwLyoyjGj+ZEOMtb1UQPz Lz9tuAEsCRKv2mwBKl5P3wNewgKS/aqe0xrndg+86Qesb3bLyO5pPhG2UesBU3yv DE/NdbG5+0aXGrEYnpN58XT4S+ZK717sfFlLTBePHUnA1ANpRXrdgPrv3p4xvp1/ X7EA1FQ4jnZL7AlhGCartvygqrPUpUF0387jPervjYeAbs7emA+Y3ZOYQvyhTCez fXnLi9ETD9Dhd6/XMmd0Vp3p5aR4EyojAXkIP5kS1iOHni6R9aUuFQi7Kobfy2na zLKsfKIOpVOlYADWRWB4oEMPAVmdZLZUeMHY1Tl3abJuvwK/yhGDIbPspk/t1UKS sz41mNz9y16MVPPNEsxRrO/D3G3e2IhNrfuGxRZ0YmzLlRFsULNvSKKhTP2FZ6vT 2z8+hiukyH45uf758funq9mvm2Y0/DPkMLtyEUfnWJk3EJWTRmCUJvGoGMG+wjH9 ChYUNYz2jbKgSXUZkPfxnoxDACUlF2L+YkEdxbtgRKxERqxVQoH6KfcHb46ZbtD6 EggsiR0izVGdq1TE5hIRU/9OhLxb9z4QpeZZ51T+3I4VHYQM6bQ= =NU/1 -----END PGP SIGNATURE----- --is77izww4ugbdpkq--