Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751902AbdIJVgY (ORCPT ); Sun, 10 Sep 2017 17:36:24 -0400 Received: from mail-eopbgr00102.outbound.protection.outlook.com ([40.107.0.102]:6351 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751782AbdIJVgV (ORCPT ); Sun, 10 Sep 2017 17:36:21 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=peda@axentia.se; Subject: Re: [PATCH v2 03/11] mux: core: Add usb.h header with MUX_USB_* and and MUX_TYPEC_* state constants To: Hans de Goede , MyungJoo Ham , Chanwoo Choi , Guenter Roeck , Heikki Krogerus , Darren Hart , Andy Shevchenko , Mathias Nyman Cc: linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, devel@driverdev.osuosl.org, Kuppuswamy Sathyanarayanan , Sathyanarayanan Kuppuswamy Natarajan , Greg Kroah-Hartman , linux-usb@vger.kernel.org References: <20170905164221.11266-1-hdegoede@redhat.com> <20170905164221.11266-4-hdegoede@redhat.com> From: Peter Rosin Organization: Axentia Technologies AB Message-ID: Date: Sun, 10 Sep 2017 23:36:11 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [81.224.168.30] X-ClientProxiedBy: AM4PR07CA0029.eurprd07.prod.outlook.com (2603:10a6:205:1::42) To VI1PR0202MB2558.eurprd02.prod.outlook.com (2603:10a6:801:6::9) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 52cf6c03-d800-4ace-05f2-08d4f893f881 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(2017082002075)(300000503095)(300135400095)(201703131423075)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:VI1PR0202MB2558; X-Microsoft-Exchange-Diagnostics: 1;VI1PR0202MB2558;3:YenMNdPFsDogvGVRKvNWXcdPUkcgrOlYhL0XzFjb9XpMM0lwjATR8bHOj8NCRhMysNgLW1fRHRV5QEpNNJXXPvQ4hyqK5nY6w8XypRPCIlOzUGhgv0XPM9YbJMdI/C9jqd7yOCd+mAZY6LTz0oVNcW6SDA36buvAropsLWyTAa5ONNo1Ci4mfoiO9NLFSPYaGpV+eBAdRF/vbrkbV705Y99gyXIQh5zykh+gVVduqa4Yrkkyqw48fBBA/ejGmsfa;25:amt33IcTZXhweP1FsZeT9MacHYnOuHd2y7rx3mrZffpwgdbr/CCVylot96bNroMRIasH6lwKCxzI13plAAh7wtqZ2KTmd+bN/ewplq/Vtj9uk9rUzR+66SS/obwYxxu7o5hLSEUKRsqq3aGcfuHQQB91bbMLrqepZ7G6OkA/DOhh5RjXMdJkWED4JJI7HV8/mPzJCi6Uf8TDQAuvncczMe1I8Iytmb5JeSvq57V9n+s+ZD99ADUbL9CEHNrzJizn8ysR/+0EpvIzHVvea97qg3BKsp6pjPEIcPZo9+mlgzxSbzptPT8+o4DGlJXqbE5uf+733kP0SjFPTAcUPjd2IQ==;31:f0swWQDF4tSnRDm4CU4V7LbIIRTtyeayDqBO4bAdxaR4p7oPNEifznLK1T1BO6YEjXEZBC2KH4GBnhgtLgqR3eQ6vG5NWpDPaBxm5prnIqXTdlKcXjLYGeFxu74xsd4oOODgZzvglNmgISj8YloZ4G/S4AvEIdW319yTLq3T1x4m6hnADShVIcDnQ7bm10Su1Eh11DUhocuuHkygGgK3yjDt7PwYJhGmRxkuP8LIe48= X-MS-TrafficTypeDiagnostic: VI1PR0202MB2558: X-Exchange-Antispam-Report-Test: UriScan:(31051911155226)(106291317490208); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(100000703101)(100105400095)(10201501046)(6041248)(20161123558100)(20161123560025)(20161123562025)(20161123555025)(201703131423075)(201703061421075)(2016111802025)(20161123564025)(6072148)(6042181)(6043046)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:VI1PR0202MB2558;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:VI1PR0202MB2558; X-Microsoft-Exchange-Diagnostics: 1;VI1PR0202MB2558;4:N2iHYUQEBKoieC0vU8RI54gLFyNrAAl547Iua5sEXxTNoH0kH8AWI2AL6vNlqLIC49yhs4JocHuE9p9m7I8Xol5x0LypQ7rC/pkUGaj/VR18OSxPg+MsQj+9ErH94kq7OG2cwBLuLp/fpXJiEINT+YgK9gZeuWICSkL62Wz0O32aSJgA/d0/mO21hbbqWBjqkwXtsVsuJKxP3ih3EGhHY8UWgw0QCxXMn6UfGperJSlbBMGt05+bgZmMYCCFMiOsPmaMGxbPpl+JXTU3vuyuntRkLCO5MVkAclurcgiloYboBEkv9oHBbEkdT0f7tdcWOWl+In0+bOiAJRnBuaiHkQ== X-Forefront-PRVS: 04267075BD X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(7370300001)(4630300001)(6009001)(6049001)(377424004)(189002)(199003)(24454002)(36756003)(4001350100001)(42186005)(93886005)(53546010)(54356999)(81166006)(66066001)(5890100001)(65806001)(65956001)(76176999)(81156014)(47776003)(50986999)(101416001)(7350300001)(8676002)(230700001)(2906002)(31686004)(7736002)(5660300001)(117156002)(305945005)(6246003)(65826007)(33646002)(83506001)(4326008)(508600001)(7416002)(229853002)(68736007)(53936002)(6666003)(25786009)(3260700006)(105586002)(106356001)(23676002)(2950100002)(74482002)(86362001)(6306002)(966005)(64126003)(6486002)(77096006)(54906002)(189998001)(97736004)(50466002)(31696002)(6116002)(3846002)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:VI1PR0202MB2558;H:[192.168.13.3];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtWSTFQUjAyMDJNQjI1NTg7MjM6U2lNNXVaaUNuM0N1UVZHeERIREJwc1Vh?= =?utf-8?B?dGxvMGdYZEpWY2d4TjcvekpLMTh0Nng4TlVPZ1o3SHdvN3lxTEQxemcrclhu?= =?utf-8?B?WXc5QTE5bXRXMnphSFpROVVERFJ3S0p1ZGxzVTBaczVLbWczQUlTcDdrSjJD?= =?utf-8?B?czlzSzRmRSt3enYzaDJmQkVER2lGM0F5MUhKRWJNdWs1dCtSdWpENngrYTZp?= =?utf-8?B?T2VvTUhZRHBhNS9kN3FsaGRQaVVGVTBGR0tHSjlBK2RtTUpHK1NSTjNkWk9U?= =?utf-8?B?NTRZczd6cHJHSEIzWmZING11ZnBhUzdOWC9RNWFYVDlMeVQ2L2ovdU12dC9S?= =?utf-8?B?VFMwYW54aWtkQ2pZYjd2STB4Zmw4Qmd4elpVc2psZC94TzhHVjltekpxSExU?= =?utf-8?B?NXp4Ym83UHZmRGl6cm53eUhmNGVGajFGUVdDRXNlRGMrc1RGcWhRclk3aXdQ?= =?utf-8?B?bk9CWlZpd2VkTHpFZ2VlQnRxd01WOXNONC9Ha2F6WVJaeFIzMXFabWthSW9E?= =?utf-8?B?UENxYXY0VHl0YUl2MWVyV0VhMXMrWXI1dnhBZXNGQ3lCZXF3eDZSS2d2eFU0?= =?utf-8?B?QXJUR1JRKytYeVhuM1ExZE0rUUZ1Q3NPaG50L1lXdmVLdXJMTnhJRVlCV0lY?= =?utf-8?B?MmxXcDJUaVE3MHQ2QmRrM3l1d1B1TDNkUTJJWkMxR0JRZks4MlNMb0UwejFS?= =?utf-8?B?L3ZrczhYaGdqdTkrNHNCYXNTS3ZiT3JB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xd8WU0HvGophgumIpXTMCJWPxmV6luPvvvcE47DIIwK//bomhirYhUu+kOAeVM+m/NfvNQcWezxE8c2W0N0ZiBOCWNyZlv+bWFvNP5o=;7:6ROublI/u7WSBV8YjxGSdaOMNOAl171pv582IDf5Ry/bqCx5cBAdzikuRf788N98xbG7Y2Asj1wOuwnkxWjqcpfJgrsY4QFAe57fxAicJLAZuSgQx4Z30+wY6MSHw6tQHSS6CK7ru3j5THFsHNsewyZORwAEM173+Ufo/1Io+nR9sAZel1IIiUOcf6w3bDpUz7rQSxlscQwILEBXlSdsLAl5NRpQm4nSKeESFPM25m0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2017 21:36:16.3231 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0202MB2558 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4450 Lines: 93 On 2017-09-08 19:07, Hans de Goede wrote: > Hi, > > On 08-09-17 17:47, Peter Rosin wrote: >> On 2017-09-05 18:42, Hans de Goede wrote: >>> Add MUX_USB_* and MUX_TYPEC_* state constant defines, which can be used by >>> USB device/host, resp. Type-C polarity/role/altmode mux drivers and >>> consumers to ensure that they agree on the meaning of the >>> mux_control_select() state argument. >>> >>> Signed-off-by: Hans de Goede >>> --- *snip* >>> +/* >>> + * Mux state values for Type-C polarity/role/altmode muxes. >>> + * >>> + * MUX_TYPEC_POLARITY_INV may be or-ed together with any other mux-state as >>> + * inverted-polarity (Type-C plugged in upside down) can happen with any >>> + * other mux-state. >>> + */ >>> +#define MUX_TYPEC_POLARITY_INV BIT(0) /* Polarity inverted bit */ >>> +#define MUX_TYPEC_DEVICE (0 << 1) /* USB device mode */ >>> +#define MUX_TYPEC_HOST (1 << 1) /* USB host mode */ >>> +#define MUX_TYPEC_HOST_AND_DP_SRC (2 << 1) /* USB host + 2 lanes DP src */ >>> +#define MUX_TYPEC_DP_SRC (3 << 1) /* 4 lanes Display Port src */ >>> +#define MUX_TYPEC_STATES (4 << 1) >> >> But USB Type-C muxes need not support just these states If I read it right? >> USB Type-C seems to be usable for a variety of protocols and the above list >> seems pretty much like a special case for this mux (and perhaps a set of >> other similar muxes). But when someone with a USB Type-C mux for different >> protocols shows up, that person will probably be frustrated by these >> defines, no? Or is there something I don't see that limits USB-C to DP? > > In general almost all hardware is limited to the above (+ analog audio over > the 2 Sideband use pins, but I expect that to have a separate mux). > > You're right, theoretically there might be other cases, e.g. there is a spec > for HDMI over Type-C (wishful thinking from the HDMI group, no one uses this), > but: > > 1) I expect most muxes to implement the above set, that is what all > hardware out there supports (well that or less). > > 2) We can always add extra defines here, that means that a Type-C mux may > not implement all states and return -EINVAL when asked for something it > does not implement, which I understand is a bit weird from a mux subsys > pov. But that can be the case anyways because even though the mux supports > these options, the board it is used on does no necessarily have to support > these options, e.g. there may be only 2 lanes of DP hooked up to the mux > (or no DP at all, but then I would them to expect a different mux). > > So the Type-C Port Manager already needs to be passed some platform > data describing which features the board has and keep that in mind > when negotiation with the dongle attached to the Type-C port, so if > we do get boards which do HDMI and no DP, then the TCPM would simply > never use the MUX_TYPEC_HOST_AND_DP_SRC and MUX_TYPEC_DP_SRC states. Ok, I googled "usb type c mux" and came up with HD3SS460 from Texas as the first hit. http://www.ti.com/lit/ds/symlink/hd3ss460.pdf That one has three control pins, but two of them (AMSEL and EN) are tri-state. So 18 states in theory. However, if EN is low everything is HighZ, so that collapses 6 states into 1, and 2 other states are reserved. Still 11 states, which is two more than what you have implemented for PI3USB30532. If we ignore polarity switching, it's only a one state diff. However, when I try to make sense of the states for the HD3SS460, I don't see anything that selects USB device or host. And I don't really see why a Type C mux has to know that; in my head the mux should just route the signals. And then when I look in your PI3USB30532 driver I don't seen any such difference either. Along the same lines, the Type C mux does not know/care if DP is source or sink. Or? How about: #define MUX_TYPEC_POLARITY_INV BIT(0) /* Polarity inverted bit */ #define MUX_TYPEC_USB (0 << 1) /* USB only mode */ #define MUX_TYPEC_USB_AND_DP (1 << 1) /* USB host + 2 lanes DP */ #define MUX_TYPEC_DP (2 << 1) /* 4 lanes Display Port */ #define MUX_TYPEC_STATES (3 << 1) I'm not sure what 2 states the HS3SS460 have in addition to the above, but the way I read the spec those to are variations on the MUX_TYPEC_USB_AND_DP state, but routing the DP signals to alternate pins. Which suggests that more documentation is needed to describe exactly what is meant when someone selects MUX_TYPEC_USB_AND_DP? Cheers, Peter