Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1978666pxu; Tue, 24 Nov 2020 13:43:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJyoZzCHS3FaKVfmCviKX9p4nUR1VN1pS8VT5kzxFCBH5OlnJAwbjWj7H7I14teeqsCG2fXb X-Received: by 2002:a05:6402:22c9:: with SMTP id dm9mr549957edb.96.1606254225894; Tue, 24 Nov 2020 13:43:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606254225; cv=none; d=google.com; s=arc-20160816; b=OnG0QQpTUE/WoF1o6M0qJYGsgVirgMymZz6cryHRPY4BZWga4MUfPb04x7LMSqm54D x3W7cbr59WyMb79mii/k1wJZYOZIJ8KmNoVITqVFwEqS/IHSk2Lv+2cY5Jtp2Q2XdMRy e0t+LKUvS7k94X/DLvP/CrTPeOX7AWkELUnYb6DVhdKELX/5m6au878+kFvGzZ1JQks9 TsGYUI1FNgT2i10zDhdVNW9Zg5my9n7v+JQ77J9S545YyQVW6TuHVO9Kbs2/InPlWXK4 AdO68ZhKtQ6UKMxUCMNSmXbLkbcH3UnM4/GmzGmRCUlPE+PSK2skptMzyKXomlIgCT6P wnUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=x24vlfzLyE77QIt6cp3BSR5WjGdYPmRgvAFaen/KIJc=; b=byvkp3tKTvWPaIJ0RhGr2MRMS7/v/JsqyFaO8xqyqUlik9oiucU7Ejy6a4WqmO18nO xdGJ17L6qt0r4F0y3biMjALV5Rb86jSP0ewZAu+dHp/W8nisSPZztQgHIzq4NbJLf6/Y rMJ4gQ9iH5x4QeZuEKBWgaRkFplPFscw6l4L7x3lL9BnC5aDTEZWWrvVzliMaNUq5RJP V94zu4vP6VoWfmT+uusYu7mFjzq3aLgpp+ugmDafzKkW4Z7Chj896NuGjzruVI+XEOQJ AJ+nBPc2EZMmhmSmQeskvHJ7PghrnVRFipqO3LNov1lR1qAvzFTQfduwhEOmqKB4LTjo dlag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=QIkKAb25; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r9si84846ejr.645.2020.11.24.13.43.22; Tue, 24 Nov 2020 13:43:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=QIkKAb25; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733296AbgKXMWj (ORCPT + 99 others); Tue, 24 Nov 2020 07:22:39 -0500 Received: from fllv0015.ext.ti.com ([198.47.19.141]:50310 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732603AbgKXMWi (ORCPT ); Tue, 24 Nov 2020 07:22:38 -0500 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 0AOCMTx4115256; Tue, 24 Nov 2020 06:22:29 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1606220549; bh=x24vlfzLyE77QIt6cp3BSR5WjGdYPmRgvAFaen/KIJc=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=QIkKAb25Vuey29w6HX8Ow0PzHRBn2OctfRqZsdPNPgBa3ChpUQdeFiMlQ18c4X/RT j20EGTEkcBJl1jFhb84N7R73d47IwcBVSlRXUNmHGlZMrie19Xx+s14DwOfwexOtHG 3726w3BfWGVNO2H22LWn8XTMaZdipy7a/p4/RfC8= Received: from DLEE107.ent.ti.com (dlee107.ent.ti.com [157.170.170.37]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 0AOCMTqw008568 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 24 Nov 2020 06:22:29 -0600 Received: from DLEE110.ent.ti.com (157.170.170.21) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Tue, 24 Nov 2020 06:22:28 -0600 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE110.ent.ti.com (157.170.170.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Tue, 24 Nov 2020 06:22:28 -0600 Received: from [192.168.2.14] (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 0AOCMQNf099790; Tue, 24 Nov 2020 06:22:26 -0600 Subject: Re: [PATCH] Revert "usb: cdns3: core: quit if it uses role switch class" To: Peter Chen CC: "heikki.krogerus@linux.intel.com" , "pawell@cadence.com" , "gregkh@linuxfoundation.org" , "balbi@kernel.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <20201123115051.30047-1-rogerq@ti.com> <20201124064242.GA32310@b29397-desktop> <89067b6a-5b94-d7d2-b07a-f434c9e5e2bd@ti.com> <20201124114641.GA9929@b29397-desktop> From: Roger Quadros Message-ID: <1c4fb95a-97b7-9022-7062-8fafcfe42c3d@ti.com> Date: Tue, 24 Nov 2020 14:22:25 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20201124114641.GA9929@b29397-desktop> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Peter, On 24/11/2020 13:47, Peter Chen wrote: > On 20-11-24 12:33:34, Roger Quadros wrote: >>>>> >>>>> I am sorry about that. Do you use role switch /sys entry, if you have >>>>> used, I prefer using "usb-role-switch" property at dts to judge if SoC >>>>> OTG signals or external signals for role switch. If you have not used >>>>> it, I prefer only setting cdns->role_sw for role switch use cases. >>>>> >>>> >>>> We use both hardware role switch and /sys entries for manually forcing a >>>> certain role. >>>> >>>> We do not set any "usb-role-switch" property at DTS. >>>> >>>> Currently cdns->role_sw is being always set by driver irrespective of any DT >>>> property, so this patch is clearly wrong and needs to be reverted. >>>> >>>> What do you think? >>>> >>> >>> Could you accept below fix? >>> >>> diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c >>> index 2e469139769f..fdd52e87a7b2 100644 >>> --- a/drivers/usb/cdns3/core.c >>> +++ b/drivers/usb/cdns3/core.c >>> @@ -280,8 +280,8 @@ int cdns3_hw_role_switch(struct cdns3 *cdns) >>> enum usb_role real_role, current_role; >>> int ret = 0; >>> >>> - /* Depends on role switch class */ >>> - if (cdns->role_sw) >>> + /* quit if switch role through external signals */ >>> + if (device_property_read_bool(cdns->dev, "usb-role-switch")) >>> return 0; >>> >>> pm_runtime_get_sync(cdns->dev); >> >> Although this will fix the issue I don't think this is making the driver to behave >> as expected with usb-role-switch property. >> >> Now, even if usb-role-switch property is not present the driver will still register >> the role switch driver. >> >> I think we need to register the role switch driver only if usb-role-switch property >> is present. We would also need to set the default role if role-switch-default-mode is present. >> >> How about the following? It still doesn't handle role-switch-default-mode property though. >> > > Roger, you said you also use /sys entries (I suppose it means through role > switch class) to do role switch, with your change, there will be no /sys > entry for role switch. Sorry for the confusion. Although we do need both features (SW role switch + HW role switch) I don't think it is required to operate simultaneously. If users need SW control they can set the DT flag. cheers, -roger > > Peter > >>>> We use both hardware role switch and /sys entries for manually forcing a >>>> certain role. > > > > >> diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c >> index 4c1445cf2ad0..986b56a9940c 100644 >> --- a/drivers/usb/cdns3/core.c >> +++ b/drivers/usb/cdns3/core.c >> @@ -532,11 +532,13 @@ static int cdns3_probe(struct platform_device *pdev) >> if (device_property_read_bool(dev, "usb-role-switch")) >> sw_desc.fwnode = dev->fwnode; >> - cdns->role_sw = usb_role_switch_register(dev, &sw_desc); >> - if (IS_ERR(cdns->role_sw)) { >> - ret = PTR_ERR(cdns->role_sw); >> - dev_warn(dev, "Unable to register Role Switch\n"); >> - goto err3; >> + if (device_property_read_bool(cdns->dev, "usb-role-switch")) { >> + cdns->role_sw = usb_role_switch_register(dev, &sw_desc); >> + if (IS_ERR(cdns->role_sw)) { >> + ret = PTR_ERR(cdns->role_sw); >> + dev_warn(dev, "Unable to register Role Switch\n"); >> + goto err3; >> + } >> } >> if (cdns->wakeup_irq) { >> >> >> >> cheers, >> -roger >> -- >> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. >> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki > -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki