Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933124AbcKHKPh (ORCPT ); Tue, 8 Nov 2016 05:15:37 -0500 Received: from relmlor4.renesas.com ([210.160.252.174]:53936 "EHLO relmlie3.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932609AbcKHKP3 (ORCPT ); Tue, 8 Nov 2016 05:15:29 -0500 X-IronPort-AV: E=Sophos;i="5.31,609,1473087600"; d="scan'208";a="225392989" From: Yoshihiro Shimoda To: Peter Chen CC: "kishon@ti.com" , "gregkh@linuxfoundation.org" , "balbi@kernel.org" , "Peter.Chen@nxp.com" , "linux-kernel@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-renesas-soc@vger.kernel.org" Subject: RE: [PATCH v3] phy: rcar-gen3-usb2: add sysfs for usb role swap Thread-Topic: [PATCH v3] phy: rcar-gen3-usb2: add sysfs for usb role swap Thread-Index: AQHSNNUfgYkBz5mVJkWGG82HsIxsqaDO2l6AgAAK/3A= Date: Tue, 8 Nov 2016 10:15:25 +0000 Message-ID: References: <1478069232-20570-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> <20161108092516.GB12276@b29397-desktop> In-Reply-To: <20161108092516.GB12276@b29397-desktop> Accept-Language: ja-JP, en-US Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=yoshihiro.shimoda.uh@renesas.com; x-originating-ip: [211.11.155.144] x-ms-office365-filtering-correlation-id: ae001732-6ade-43ab-d9d1-08d407c0281e x-microsoft-exchange-diagnostics: 1;HK2PR06MB0547;7:mTTFmQH+yBSDdjOBxDUt5ii/WBmrT2L7PWkbTxnJunSxS/hfVa0ir/bUeJQDZekRgIZPghde488LC6wc59rYSYUJfB7rdG3ExdlmviGpW+yqoJFv09dvrAA0T6g2psKYSlyybFsKaVlQCMa9J/vwDPSnXP7ufP7RPClnd4Y29drK0CKvSYNDBAPj/Ma6JFb7ngfPqXEh+E6/6SGswG3FHuuCUOlDmCbo6K3n/gz1nl6JOle20cC+GKhjh+oys3dlwJI4EsTdbHODtjolEl0hSElOuBsQWidxd+5b+mMkWP4qyh2DiVqicGGeJVTMBiR8rPgBPbenuSkj74b0bUx3Dky2IF/EW+sl+2KHutoRaLY=;20:+jOZ2MLNSOZLxne3Ar/CfLusYfpbWklmNmQ+yeFTzAM1exz8uMhIBSbUZMyFjoZCS/CBQB8AO/+nqgkEN5zfi37e367pKpPYwFluFg2wd+HJ8Ux8ikv5f0qqLYKaJ1Cery94NGbhWu/A2nhKwGajzrrGJ+dpxPUgXcq2kVfQdxo= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:HK2PR06MB0547; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026);SRVR:HK2PR06MB0547;BCL:0;PCL:0;RULEID:;SRVR:HK2PR06MB0547; x-forefront-prvs: 01208B1E18 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(7916002)(189002)(199003)(377454003)(24454002)(76176999)(6916009)(8666005)(81166006)(101416001)(122556002)(92566002)(33656002)(2950100002)(106116001)(586003)(3280700002)(81156014)(6116002)(102836003)(4326007)(68736007)(3846002)(76576001)(8936002)(86362001)(66066001)(3660700001)(110136003)(7696004)(8676002)(345774005)(2900100001)(87936001)(105586002)(9686002)(305945005)(74316002)(2906002)(1411001)(77096005)(5660300001)(7846002)(54356999)(106356001)(7736002)(97736004)(189998001)(50986999)(230783001)(7059030);DIR:OUT;SFP:1102;SCL:1;SRVR:HK2PR06MB0547;H:HK2PR06MB0548.apcprd06.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Nov 2016 10:15:25.2446 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK2PR06MB0547 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id uA8AFvsd006305 Content-Length: 1624 Lines: 62 Hi, > From: Peter Chen > Sent: Tuesday, November 08, 2016 6:25 PM > > On Wed, Nov 02, 2016 at 03:47:12PM +0900, Yoshihiro Shimoda wrote: < snip > > > + /* If current and new mode is the same, this returns the error */ > > + if (is_host == new_mode_is_host) > > + return -EINVAL; > > + > > + if (new_mode_is_host) { > > + if (!is_b_device && !is_host) /* A-Peripheral */ > > + rcar_gen3_init_from_a_peri_to_a_host(ch); > > + if (is_b_device && !is_host) /* B-Peripheral */ > > + rcar_gen3_init_for_b_host(ch); > > is_host must be false here Thank you for the review! I will clean up the code and submit v4 patch soon. > > + } else { > > + if (!is_b_device && is_host) /* A-Host */ > > + rcar_gen3_init_for_a_peri(ch); > > + if (is_b_device && is_host) /* B-Host */ > > + rcar_gen3_init_for_peri(ch); > > is_host must be true here Same the above. > > + } > > + > > + return count; > > +} > > + > > How can you handle the case which ID pin is incorrect, eg, ID is 0, but > it is peripheral mode at the initialization? This driver always checks the ID pin and sets the suitable mode in initialization timing. So, we can ignore such a situation. < In detail > phy_init() @ drivers/phy/phy-core.c --> rcar_gen3_phy_usb2_init() --> rcar_gen3_phy_init_otg() --> rcar_gen3_device_recognition() --> if (!rcar_gen3_check_id(ch)) rcar_gen3_init_for_host(ch); <-- Sets the mode as host else rcar_gen3_init_for_peri(ch); <-- Sets the mode as peripheral ++phy->init_count; @ drivers/phy/phy-core.c Best regards, Yoshihiro Shimoda > -- > > Best Regards, > Peter Chen