Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1820244ybl; Thu, 19 Dec 2019 03:36:47 -0800 (PST) X-Google-Smtp-Source: APXvYqzxbLoQp/C3ro8VRTqvfa1zODVTxrj2ldSmZ4QSHkDRpEuVSFTU2agCHeP7YCrJvKSmtgg0 X-Received: by 2002:a54:460f:: with SMTP id p15mr2023405oip.174.1576755407251; Thu, 19 Dec 2019 03:36:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576755407; cv=none; d=google.com; s=arc-20160816; b=lmnaXwkeFFfXrl+Ci/57AaMzioF0qBooAiw8MIVWDDzEgsoa1mtqYBodsz8xDLGfmu J2Y0HY8LKZjCJot35R//jqQbFz66KaMsbqAHla4G2HalJz7YSLZngJs0qIAsS2DRFg6X XOsuxxL5NYAw9k+vvyAc4pzFcnEoJQ3Uk3GfWMW3DbKBxOve2yEpzgLzd3OQ8L5RYVEF h1BhSx54e7ApYB8Hc2HbQ31TMrdXbUnvIpNOB/Lh5sVzGgqOO7+swZ6ciQPJup4THvjk 2Pv5v/C98S3cRDwBRZRwJsJ9HvTxSsKGQkawN24NoXntb9ZlGsueu86R8FQrdLYp2rg5 BZtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:cc:to:subject:from:date :dkim-signature; bh=ckop6Kqk0CV79KVL4zcYWdYOX/VFrNEJtlGjWhAJS+I=; b=El27n8f6VOd6u0XCM+7UNNw3HOOEfHpZxQ/TRk4xqFc5TWJElpkgg+g3ndy0IIhsis KotLnL0zfYWune9bJV9CLahW5vxY7GlHmZsIaln+lLLfqDYvJkOdcoQyYtD4XG+L/MYz xJc50+n/j8AiqF09s4H5pcAkQy8DLZvap8WzyJNiRcpF+Dvxr65Fp0WsXvjFOy/31dRB bRnAQNrq/pBYURoec6VXKrXqiT4It4mTNKd3xZy8I/YnU+lQxghb6h7BxiX67hLV92Qi p1f7jaB7JUQAa8eMkb7nuPVVBecHGJ+7gTNNlN+qd/yH4L9WD3+LeOEg7BsoHdlecmFT IShQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@crapouillou.net header.s=mail header.b=cHB0INpO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r14si2754446oic.12.2019.12.19.03.36.35; Thu, 19 Dec 2019 03:36:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@crapouillou.net header.s=mail header.b=cHB0INpO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726789AbfLSLfr (ORCPT + 99 others); Thu, 19 Dec 2019 06:35:47 -0500 Received: from outils.crapouillou.net ([89.234.176.41]:47908 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726695AbfLSLfr (ORCPT ); Thu, 19 Dec 2019 06:35:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1576755342; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ckop6Kqk0CV79KVL4zcYWdYOX/VFrNEJtlGjWhAJS+I=; b=cHB0INpO3f2CogS5CbRHjpHON4couUPO673zqq7Nuzt+0O+Ra3tG1zlgjfXmhQ2Kt3PwMz PHDsiKkqjNju5o4p8QeS2Z3/WPfYnErBSN8CD/X2l05m+WBKnaDH4WED7emxpQl0M3cUd5 xAKnVCRlloCicTthjywCisc97X4H6dU= Date: Thu, 19 Dec 2019 12:35:37 +0100 From: Paul Cercueil Subject: RE: [PATCH v2 3/3] power/supply: Add generic USB charger driver To: Peter Chen Cc: Sebastian Reichel , Rob Herring , Mark Rutland , Greg Kroah-Hartman , od@zcrc.me, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Message-Id: <1576755337.3.0@crapouillou.net> In-Reply-To: References: <20191211155032.167032-1-paul@crapouillou.net> <20191211155032.167032-3-paul@crapouillou.net> <20191212091814.GA7035@b29397-desktop> <1576270147.3.0@crapouillou.net> <1576493525.3.0@crapouillou.net> <1576617863.3.1@crapouillou.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Peter, Le mer., d=E9c. 18, 2019 at 02:46, Peter Chen a=20 =E9crit : >=20 >> >> > >> >> >> >> + >> >> >> >> + desc =3D &charger->desc; >> >> >> >> + desc->name =3D "usb-charger"; >> >> >> >> + desc->properties =3D usb_charger_properties; >> >> >> >> + desc->num_properties =3D=20 >> ARRAY_SIZE(usb_charger_properties); >> >> >> >> + desc->get_property =3D usb_charger_get_property; >> >> >> >> + desc->type =3D POWER_SUPPLY_TYPE_USB; >> >> >> > >> >> >> > What's your further plan for this generic USB charger? >> >> >> > To support BC1.2, we need to know charger type, and how we >> >> could >> get > it? >> >> >> > >> >> >> > Peter >> >> >> >> >> >> Well I don't really know. The USB role framework does not=20 >> give >> >> any >> info about what's plugged. >> >> >> >> >> > >> >> > What's the use case for this patch set? How it be used? >> >> >> >> My devicetree: >> >> >> >> usb_otg: usb@13440000 { >> >> compatible =3D "ingenic,jz4770-musb", "simple-mfd"; >> >> reg =3D <0x13440000 0x10000>; >> >> [...] >> >> >> >> usb-role-switch; >> >> >> >> connector { >> >> compatible =3D "gpio-usb-b-connector", "usb-b-connector"; >> >> label =3D "mini-USB"; >> >> type =3D "mini"; >> >> >> >> id-gpios =3D <&gpf 18 GPIO_ACTIVE_HIGH>; >> >> vbus-gpios =3D <&gpb 5 GPIO_ACTIVE_HIGH>; >> >> [...] >> >> }; >> >> >> >> usb_charger: usb-charger { >> >> compatible =3D "usb-charger"; >> >> }; >> >> }; >> >> >> >> The new gpio-usb-connector driver uses the ID/VBUS GPIOs to=20 >> detect >> >> in which state (device, host, unconnected) a OTG connector is. >> >> However, that means I cannot use the standard gpio-charger=20 >> driver to >> >> detect the presence of a charger based on the state of the VBUS >> >> gpio, since it's already requested here. So the point of this >> >> patchset is to provide an alternative to gpio-charger that works >> >> with OTG controllers compatible with 'usb-role-switch'. >> >> >> > >> > Thanks for explaining it. >> > >> > What's the user for this USB charger, PMIC or what else? How the=20 >> user >> > uses this USB charger interface? >>=20 >> It's exported as a standard charger, so it can be passed to client=20 >> drivers through >> devicetree, and its online status can be retrieved from sysfs. >>=20 >=20 > Hi Paul, >=20 > If you would like to get role from usb-role-switch, the udc driver=20 > may probably have already worked. > There is a 'state' entry under the udc device to indicate USB Ch9=20 > state. Try to see if it could > satisfy your requirement. This is not the proper way to retrieve charger status. Linux supports chargers through the power supply subsystem, that's=20 where it should be exported. Cheers, -Paul =