Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp5826807ybg; Tue, 22 Oct 2019 08:56:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqxNSZI+Qy33yoC+yXA5FVQccIN30TTRovf1AfXC+5D5Ygg+3NbCgnnOrCbanWkfshW89Fs1 X-Received: by 2002:a17:906:684:: with SMTP id u4mr27180131ejb.155.1571759802758; Tue, 22 Oct 2019 08:56:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571759802; cv=none; d=google.com; s=arc-20160816; b=xu6Q2sMZZWNPkEBEf4hAkoOfLyDeJVokW4moL7RMDvmvv7VOdwzHk+d48dSHQy0I0k pVP3lcsoA7C68wCJpxcz7q2RLz/2u/Ix7Lw6i2MIEMtlEX1URaudeqhknPu8PNaVaaUW 1LUAqt3x3x5VGqB+VSg21WNJ03HNF+ahcmVOhybBMeP1Ulskh5ao3d6yL4kfV4Jtc6tl jfubj6gNkJnDnnGnjjTJ4weBNglfEpGAYSflM7/9SljYB9Djl9FqHsx6ns/LivXZq21c 85JYX8fqw4pkjjBexHyMSEASFK5qusnP6MSMlHtjUZoUwa/6ii96q663udaV2q3ZLQ2z xrlg== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=HDIziD0BfrlxmPMJrkTLh7QjnKsfiQF7jyPiMzEXqs4=; b=uOeBJS7fwD82QqevXtNYORU+zNfxDPPG1+ZcRYckrmp9HuO/gWqD/ZREw84XhJNG63 tg6S0cFk/quYHT1J/eLxdUDpt4OWLiBcRW3zmYjOyysWFdzsAjCDaqsQi/YN2VS7CZUa vXup0TZKvFfBPECOY/XDQdW1aNn7F0F9lTQDFgaFjD/ynzy7H+R3Gza/wKRrfb0q1ZUP vSbiIYxRshrGzhdFsnf1T5+uZczJxwzZck0uZn0dIqb+fWgYi6SHbGgevGJI8dvH5wgr 0i2UrRmFjEk5tAx77hUuqTXuFYmQzezBt9drsdji/5hhpqI6o+7C3/Pt8oGhsKCX6VEM RkXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ndN7SQEh; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h19si11791446edv.393.2019.10.22.08.56.18; Tue, 22 Oct 2019 08:56:42 -0700 (PDT) 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=pass header.i=@gmail.com header.s=20161025 header.b=ndN7SQEh; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388942AbfJVNyp (ORCPT + 99 others); Tue, 22 Oct 2019 09:54:45 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:37884 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729425AbfJVNyp (ORCPT ); Tue, 22 Oct 2019 09:54:45 -0400 Received: by mail-ed1-f67.google.com with SMTP id r4so12966097edy.4; Tue, 22 Oct 2019 06:54:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=HDIziD0BfrlxmPMJrkTLh7QjnKsfiQF7jyPiMzEXqs4=; b=ndN7SQEhquOMTyprORwJUKFqnEd+Xtf3KaGZl5lySQFOvpI3tYGEq0E6cVJ3sb1nPd JTzO2En4F2pjs0JFoAvszFakYkMPJ0zoaS61goJcbMPVEwoX9e2SzSLW8yWGHPq4jD+o a8xj/W6xikpUak5eRWEf8YrWwo0/6B/bzDGYFeRo6HNfR85d72d6JakciUKmMbIpwKOV ug7n54y2gKQMnzUk0EuUNfi6gXqceHHhZgLy7D+pQftrOSDhTuPIGCqDxB3pWAN80QLQ n9nvcTmftCgAO2inkDbwDaPETnhFpXQ0stJFheO7ZL7hKopAIuyJbGTvf4L1KtgqLrjs YHnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=HDIziD0BfrlxmPMJrkTLh7QjnKsfiQF7jyPiMzEXqs4=; b=fCASqGa12YbOSR9KLm/PdQImhkkf039Dhyxm+riRYOF8rUhu8PQcMbTxU/duKo+UHj fnQj4JK/hWostvLZ/O81E9m2pIpPUKkzCjTGbMjqP9LqH0Zj701DZiesq1hi2flsZeWg 9Tv1tcY7PuMOXtT2PAmHeA/0I5WDXzgW+7KAa1qph5ILXVCH1xzWOI2G3s88LXnwzglx tmBPRvSySsyU4/aroilM03UCZVBHpKwUA7uAl/aReZwNAkSgQ1oQ8utWM5pAmaaLCeJP Af7kGutW9h8wLbt7zAef03QphanA53NDIXv+NoCNaXOAR0uLSgO1bqe77ElTbEkAmBxM P4Yg== X-Gm-Message-State: APjAAAXzVrWvH9+rpeA5nd7hkKR1J/LpkVNcQioFKOjhfvd5imRBi98A UqOCWb9EGQDty72bUnTR1RsepTZnO73VK+lKo5Y= X-Received: by 2002:a50:9fc1:: with SMTP id c59mr4805544edf.305.1571752481193; Tue, 22 Oct 2019 06:54:41 -0700 (PDT) MIME-Version: 1.0 References: <20191021161654.14353-1-igor.opaniuk@gmail.com> <20191022020748.GA26973@b29397-desktop> In-Reply-To: <20191022020748.GA26973@b29397-desktop> From: Igor Opaniuk Date: Tue, 22 Oct 2019 16:54:30 +0300 Message-ID: Subject: Re: [PATCH v1 1/2] usb: chipidea: use of extcon framework to work for non OTG case To: Peter Chen Cc: "linux-usb@vger.kernel.org" , Marcel Ziswiler , Philippe Schenker , Stefan Agner , Max Krummenacher , Oleksandr Suvorov , Sanchayan Maity , Igor Opaniuk , Greg Kroah-Hartman , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" 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, On Tue, Oct 22, 2019 at 5:11 AM Peter Chen wrote: > > On 19-10-21 19:16:53, Igor Opaniuk wrote: > > From: Stefan Agner > > > > The existing usage of extcon in chipidea driver freezes the kernel > > presumably due to OTGSC register access. > > > > Prevent accessing any OTG registers for SoC with dual role devices > > but no true OTG support. Use the flag CI_HDRC_DUAL_ROLE_NOT_OTG for > > those devices and in case extcon is present, do the role switch > > using extcon only. > > Hi Igor & Stefan, > > I have several questions about the problem you met: > - Which vendor's controller you have used? > - What do you mean "no true OTG"? Does it mean no "OTGSC" register? Probably the commit message adds a bit of confusion here (I've kept the original one from the patch in our downstream kernel, but will probably reword it). The actual problem is that USB_OTG1_ID pin isn't wired, so we can't rely on the value of ID pin state in OTGSC for the role detection. In our SoM (Colibri iMX6ULL) ID pin from USB connector is wired to SNVS_TAMPER2 which is pinmuxed as GPIO pin (GPIO5_02), [1] (this is schematic for the Carrier Board, not SoM (isn't publicly available), but there is a pretty good explanation + schematic in the section "2.3.2.2 USB 2.0 OTG Schematic Example "). > > > if (dr_mode =3D=3D USB_DR_MODE_OTG || dr_mode =3D=3D USB_DR_MODE_= HOST) { > > ret =3D ci_hdrc_host_init(ci); > > @@ -1145,8 +1208,18 @@ static int ci_hdrc_probe(struct platform_device = *pdev) > > > > if (!ci_otg_is_fsm_mode(ci)) { > > /* only update vbus status for peripheral */ > > - if (ci->role =3D=3D CI_ROLE_GADGET) > > - ci_handle_vbus_change(ci); > > + if (dr_mode =3D=3D USB_DR_MODE_PERIPHERAL) { > > + usb_gadget_vbus_connect(&ci->gadget); > > We only use ci->role at runtime, since it has already considered the > dts setting, kernel configuration and hardware setting. > > If your controller doesn't otgsc register, but do need to support > role switch, you may enhance the function ci_get_role Btw, ci_get_role() implementation still resides in the NXP dowstream kernel and I've never seen anything posted to the ML (if it was, could you please point me to the patch?). I can introduce the new one, which wraps both OTGSC handling + extcon for CI_HDRC_DUAL_ROLE_NOT_OTG controllers. Frankly speaking, I don't know the reason why additional workqueue (ci->wor= k_dr) was introduced (will try to reach Stefan regarding this). As I see it's valid to call extcon_get_state() from the atomic context, so probably using something like ci_get_role()(or ci_detect_role(), whatever) instead of explicitly retrieving bits from OTGSC in every ID pin check is a good choice. Thanks for your feedback! > > Peter > > > + } else if (ci->role =3D=3D CI_ROLE_GADGET) { > > + struct ci_hdrc_cable *vbus =3D &ci->platdata->vbu= s_extcon; > > + > > + /* Use vbus state from extcon if provided */ > > + if (!IS_ERR(vbus->edev) && > > + extcon_get_state(vbus->edev, EXTCON_USB)) > > + usb_gadget_vbus_connect(&ci->gadget); > > + else > > + ci_handle_vbus_change(ci); > > + } > > > > ret =3D ci_role_start(ci, ci->role); > > if (ret) { > > @@ -1161,10 +1234,6 @@ static int ci_hdrc_probe(struct platform_device = *pdev) > > if (ret) > > goto stop; > > > > - ret =3D ci_extcon_register(ci); > > - if (ret) > > - goto stop; > > - > > if (ci->supports_runtime_pm) { > > pm_runtime_set_active(&pdev->dev); > > pm_runtime_enable(&pdev->dev); > > -- > > 2.17.1 > > > > -- > > Thanks, > Peter Chen [1] https://docs.toradex.com/102491-colibri-arm-carrier-board-design-guide.= pdf --=20 Best regards - Freundliche Gr=C3=BCsse - Meilleures salutations Igor Opaniuk mailto: igor.opaniuk@gmail.com skype: igor.opanyuk +380 (93) 836 40 67 http://ua.linkedin.com/in/iopaniuk