Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp92696pxm; Wed, 2 Mar 2022 11:03:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJwFY4H/ts2Mr+KiKjUtH0NlW1V/RZNOZmpHJIzaMWQVMgCyr2vsuscYA1LU83hQRS/dpzAh X-Received: by 2002:a17:906:5f96:b0:6bb:3024:9444 with SMTP id a22-20020a1709065f9600b006bb30249444mr25829333eju.298.1646247790038; Wed, 02 Mar 2022 11:03:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646247790; cv=none; d=google.com; s=arc-20160816; b=eJ3SGiXS5eCP1MAqpflOtQUtIvhwJJa3sF6kBKx/75+mq2VLXCr4Ma9Bv9+SZ+jJ1d B/GWlAa9fEm84SArllQEj2PISlz8asIO94hEQ9s1wFXBQ5DaLxl3BZnJ53dj16xUL1hJ 5GNAD5DamwAv2U20YjSuXriRxUFyyP271icFMLUXF4VeFH6eKWsLWURQcc+j/Qi4z5lT 6429g98BfPBNYyNrtNWpbN4UnsrNMcNkDz5jyTCw45TRf87IQxN90Jvjv3siVYwvJ/pZ puxYRwA5PKomFG+VvysXNx4fvmxMRE7CDQhjqXVT+zoxDWCfB0b4AdzsbG8Xn1WmA/th DGaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=fSy3hxn70cspo86qB4pn1JZcvcU5kK56P3p3AlCUZLo=; b=mNESATz98S/vb8Ugwt8Nw1O4BIzf/BiPSP9DU1LClBWpyysX4COlMhe1cyeoGD5z7w vcuVMlIh/ZECcuQUJm0vcQtpha3lxkX1qXJ3hWmC9J3vrAM193SHHmyBx3858MjwvWef EA58iIY9agnTR8QDeo0zLho6xtLOp+szIjXeZ6+fi9bBK10JorZs5U0UHkxuULJMLIqd rZQoxQpBhq06s4r0b8Qi0QndDwFBeakXMj0g9RLa5J34OaQZCiqw7QUFWz6MxwT492o4 H9NOsaOmd3XTf6fj9/UqGmJhGgZMcyXKvGxANNI4BZ4oW0FqB1adzSD8xvzuzTV/V+Qq QOxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZQsY8Ow8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l3-20020aa7c3c3000000b00412f150424csi11922162edr.259.2022.03.02.11.02.44; Wed, 02 Mar 2022 11:03:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZQsY8Ow8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241666AbiCBMHF (ORCPT + 99 others); Wed, 2 Mar 2022 07:07:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233223AbiCBMHB (ORCPT ); Wed, 2 Mar 2022 07:07:01 -0500 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13B58C0859; Wed, 2 Mar 2022 04:06:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646222778; x=1677758778; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=AnjlKf1LQKzOgzxBT/jxnMz1bZYSfLAR8Dv3xXjRDio=; b=ZQsY8Ow8nwoLaosyScGJFXUnkNAat/0ujx/vtvV7Uxt5xfOCJ6ZgoaZz IF/OzVls2jwyTuBRxghvzNtaj04WxRsBxGpBLqnUSe2LyMTDDT8oey4he XqQN4FFH0cQbaVl+O/bGJNCexsPYdKnmDdRUBwVXXf6PRmu/ChfARUxtv YH2Pr0lAv7uXFUbTD9lTW1sOWkn8cvQxHjvCMhZp2bSkxMJ1ysE591tvS hsemIhhMoeCWiY7mZSgBbMa1aP4hMXV/LKuE7xO7FXVkFMHXp3cyu18Oc GSbt1pH/SCdifmRYfHnYIbbbnZkv38aMp8TPj3iHq0zFo3tnozIAq5N2/ w==; X-IronPort-AV: E=McAfee;i="6200,9189,10273"; a="236894996" X-IronPort-AV: E=Sophos;i="5.90,148,1643702400"; d="scan'208";a="236894996" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2022 04:06:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,148,1643702400"; d="scan'208";a="686116074" Received: from kuha.fi.intel.com ([10.237.72.185]) by fmsmga001.fm.intel.com with SMTP; 02 Mar 2022 04:06:00 -0800 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Wed, 02 Mar 2022 14:06:00 +0200 Date: Wed, 2 Mar 2022 14:06:00 +0200 From: Heikki Krogerus To: Sven Peter Cc: Greg Kroah-Hartman , Guido =?iso-8859-1?Q?G=FCnther?= , Hector Martin , Alyssa Rosenzweig , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] usb: typec: tipd: Forward plug orientation to typec subsystem Message-ID: References: <20220226125912.59828-1-sven@svenpeter.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220226125912.59828-1-sven@svenpeter.dev> X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Feb 26, 2022 at 01:59:12PM +0100, Sven Peter wrote: > In order to bring up the USB3 PHY on the Apple M1 we need to know the > orientation of the Type-C cable. Extract it from the status register and > forward it to the typec subsystem. > > Signed-off-by: Sven Peter Reviewed-by: Heikki Krogerus > --- > drivers/usb/typec/tipd/core.c | 5 +++++ > drivers/usb/typec/tipd/tps6598x.h | 1 + > 2 files changed, 6 insertions(+) > > diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c > index 7ffcda94d323..16b4560216ba 100644 > --- a/drivers/usb/typec/tipd/core.c > +++ b/drivers/usb/typec/tipd/core.c > @@ -256,6 +256,10 @@ static int tps6598x_connect(struct tps6598x *tps, u32 status) > typec_set_pwr_opmode(tps->port, mode); > typec_set_pwr_role(tps->port, TPS_STATUS_TO_TYPEC_PORTROLE(status)); > typec_set_vconn_role(tps->port, TPS_STATUS_TO_TYPEC_VCONN(status)); > + if (TPS_STATUS_TO_UPSIDE_DOWN(status)) > + typec_set_orientation(tps->port, TYPEC_ORIENTATION_REVERSE); > + else > + typec_set_orientation(tps->port, TYPEC_ORIENTATION_NORMAL); > tps6598x_set_data_role(tps, TPS_STATUS_TO_TYPEC_DATAROLE(status), true); > > tps->partner = typec_register_partner(tps->port, &desc); > @@ -278,6 +282,7 @@ static void tps6598x_disconnect(struct tps6598x *tps, u32 status) > typec_set_pwr_opmode(tps->port, TYPEC_PWR_MODE_USB); > typec_set_pwr_role(tps->port, TPS_STATUS_TO_TYPEC_PORTROLE(status)); > typec_set_vconn_role(tps->port, TPS_STATUS_TO_TYPEC_VCONN(status)); > + typec_set_orientation(tps->port, TYPEC_ORIENTATION_NONE); > tps6598x_set_data_role(tps, TPS_STATUS_TO_TYPEC_DATAROLE(status), false); > > power_supply_changed(tps->psy); > diff --git a/drivers/usb/typec/tipd/tps6598x.h b/drivers/usb/typec/tipd/tps6598x.h > index 3dae84c524fb..527857549d69 100644 > --- a/drivers/usb/typec/tipd/tps6598x.h > +++ b/drivers/usb/typec/tipd/tps6598x.h > @@ -17,6 +17,7 @@ > /* TPS_REG_STATUS bits */ > #define TPS_STATUS_PLUG_PRESENT BIT(0) > #define TPS_STATUS_PLUG_UPSIDE_DOWN BIT(4) > +#define TPS_STATUS_TO_UPSIDE_DOWN(s) (!!((s) & TPS_STATUS_PLUG_UPSIDE_DOWN)) > #define TPS_STATUS_PORTROLE BIT(5) > #define TPS_STATUS_TO_TYPEC_PORTROLE(s) (!!((s) & TPS_STATUS_PORTROLE)) > #define TPS_STATUS_DATAROLE BIT(6) > -- > 2.25.1 thanks, -- heikki