Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp672165pxb; Tue, 5 Apr 2022 18:10:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAee9BKYdzLa964oRQ3NbUSCUw+8GiyRqSgvNr61drVhZs4EA5BGmWqeDHsUazJkDMZ/GD X-Received: by 2002:a17:907:7f0f:b0:6e4:c15e:7751 with SMTP id qf15-20020a1709077f0f00b006e4c15e7751mr6068464ejc.266.1649207428207; Tue, 05 Apr 2022 18:10:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649207428; cv=none; d=google.com; s=arc-20160816; b=tBbRI4WizwygicY4dKPzEE+DK8TdMhbrg0eiPvx8vGIzi9Z95dR9Ybh5oXPHWvrZFY 4LxE37W/zvBuk63PX2G3eJszK6F6D5bso8ek94DVaHd2sru6KGgbKwR5IyvNhOW/nciu 99OJJyNhY5MNv8bRXQfba/OgsO6E9nA0qpM1RR2t3EE+2gt8VlbO0KlYZCiBMhunfSl6 et3b2UorTBf8IS/Go1V6ciOl2ZAk6VCDuff5YMaZMfsuWuI8I67n4idWaT49JYVY8OkU u+lv8AvW9FxUFtXrC05T82h63MM+rLxjuoKGKxZklxndBBXrAkpb8xyfiAH6aHSIUE6y +pYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2ssstqc0VhcBZI85vsarW4A4AYj+2J6mwmeXY2wMEPA=; b=Jc7+Jfj2l5ga4xDANzRcr5kwkoAW+fxsap8ZPKBs1sibDm2Kk3wsI1CSvgvWxdidAg g5gezZXuZEBal5dQYKln+YAeQDqvjqiCD8IVawla72thghQGH6RvDvgVcIc3nFtITdyz YoOqPqxJnolRuMYy0d4VsAqsOntik/TPhqsV3Uv9oJv1Huk5tsxa0JymguS3rUdZGJOk 6xiuYj/I39BLdjmuK5c/3OOBRQEZOn6ulVBps16W6pak8SLpKf1GD3twy2xBblB5cmTx JTzM5OM1O4Q9KMJwp3W93IeQmhTAo07oOe/B20ngBEBW43xvkA9CTF1tRFD7w2JvIlC4 Me+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lhVF9Ppp; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v5-20020a1709060b4500b006e76f053445si7345627ejg.55.2022.04.05.18.10.03; Tue, 05 Apr 2022 18:10:28 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=lhVF9Ppp; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349404AbiDELDf (ORCPT + 99 others); Tue, 5 Apr 2022 07:03:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236932AbiDEIlX (ORCPT ); Tue, 5 Apr 2022 04:41:23 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 222B510B0; Tue, 5 Apr 2022 01:34:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B307F60B0A; Tue, 5 Apr 2022 08:34:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C967CC385A1; Tue, 5 Apr 2022 08:34:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649147641; bh=iNiqVVs3RFLMStxPJaJA1NO2p1BzNFd9jBlWtITpKTY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lhVF9PppQHCu+N0OTICDtqev8zeMHyJaiqZX/aWHof5UPYtZk0FtlS46o7a0WldQ9 zOPAjvgUSfunZIhZRUh7J8eZI9tfdWSd1lVplFDuRTwkCtyCwDAkLrbMrJcO6IGDNE cZihmym1FRmPHkd1YMFv7PThtXUXd74OYjXQ5rrU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Heikki Krogerus , Sven Peter Subject: [PATCH 5.16 0032/1017] usb: typec: tipd: Forward plug orientation to typec subsystem Date: Tue, 5 Apr 2022 09:15:45 +0200 Message-Id: <20220405070355.132479743@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,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 From: Sven Peter commit 676748389f5db74e7d28f9d630eebd75cb8a11b4 upstream. 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. Reviewed-by: Heikki Krogerus Cc: stable Signed-off-by: Sven Peter Link: https://lore.kernel.org/r/20220226125912.59828-1-sven@svenpeter.dev Signed-off-by: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/tipd/core.c | 5 +++++ drivers/usb/typec/tipd/tps6598x.h | 1 + 2 files changed, 6 insertions(+) --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -256,6 +256,10 @@ static int tps6598x_connect(struct tps65 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 t 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); --- 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)