From patchwork Thu Feb 22 21:09:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Felsch X-Patchwork-Id: 205059 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp212003dyb; Thu, 22 Feb 2024 13:10:51 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVcI7+fZl+qE5seBxGcPqziRpWPer7M5LjSJq7Xwe7IMwZ8jwmeSRCxIRbwhyE4h0PxC0VPXNZ5rNgnKNm7hsPNSfpTRA== X-Google-Smtp-Source: AGHT+IETmoXG2lN7FmUq2tcLSmYVeMbE2dzSe/gXzQCaYSI9F/eN4wjFuaAq8AYXaiKc4+qwWg+D X-Received: by 2002:a05:6358:9893:b0:17b:602f:24e7 with SMTP id q19-20020a056358989300b0017b602f24e7mr6434052rwa.14.1708636251556; Thu, 22 Feb 2024 13:10:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708636251; cv=pass; d=google.com; s=arc-20160816; b=xSjbq/ck9W4P7/WPlXdRZfh8KzBt1O5PnOWsmB6K6LAuLoy9DuLGSQfpn/RDSbWPMb unzgr3raXOPLeqdKEPVfK4baRFhfXmWL2nPdDF8NbDF6KwjYCIUDd12UZzr/IIkbMN5p 4WZIR3ZeV72DIgMSCKcRiJ8FZLYDqmswKeGLYWrKrK9aiyn5g0RtwVmx3EGd+dougI4P NQKsakmEs1MTW/wjMdq4nrIvco6FDBtwv128ZE7r58Pz/LfUa8j7MTahvWuX3tRVwv7Q LTAwXIMq9rkabG+d1/Pb43rcOMxqcTV3OZXz834mS3JtRfB8XgtDpvYe98KAFPNw1Bu5 3qNw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=rry6g/dpzUGOq1A1h43yCDjq/lLaNgUv+Gv32r8PnEE=; fh=FttDRjnFdpjso3V5tb3WR+hSGsT8UJL4OhhG9l/Cs7o=; b=lH8oPj7DDe9fy2yaZdHW93hiqDC6hu4pcBzdaYQg1QCZV6YJ9dMHyQdQErCMk1mUjX GCXLbjEaMlH/IVWNFmBbkPV+4rZzG4llSthBL80dAnaAsWerg82DOvpwBxHWc7WRIMLJ rpmkZJ5lKxU3VLYXlvNmY+rVHWrQ6270DjDFNGhEuXqexOguimEQaiBStqOAGTadzEBr GAzjZXNpbHoq5CNAqcxh975Hh+07OksbaA7UOTtjQREjbFhdDbFChDjTgH1hwQZDHqiH sNwA5/l6yrrSy7I+BZzcJ4sGFa4BsF7L9Sp9cggUqP1s1znLRiidpVO0XCE5fdT8ZG3G Rrag==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-77362-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77362-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id t24-20020a639558000000b005dc4ec6cd2esi10926378pgn.767.2024.02.22.13.10.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 13:10:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77362-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-77362-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77362-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id EEF45286A2F for ; Thu, 22 Feb 2024 21:10:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4B00E13790B; Thu, 22 Feb 2024 21:09:32 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F4DE7175C for ; Thu, 22 Feb 2024 21:09:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708636170; cv=none; b=STFasF2r5LV7tXQLa1j6RvVLKzEclIfwT4hfERyJaPaNHeUMdFQT5Tx8zMjaSD9ik9xQoD7C/G29ygg2gDTGAek3tGese1AI/eb9ebj+HvdRWC+m2C8rBou8bSK09/aUVuuLwvKcHCO6eqEm6zxMqcCcY7E/EGA81Yh5yIAZIRI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708636170; c=relaxed/simple; bh=9fXdVza5W4TGckttMR2jjvZECW0BZ3vgTQy5/Q1KsoQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=t8Q6rBjSUR6pFTcMhU3rXDL6d2K1F0VYSbznq+M1HelhJHroEXEp5DJ7YbCJr9kv6jDX0OLoc7ZJqFgFnKzlCLdOuOmDrezf32R50iA7ZTy1GbDgKs6A1k1+zHLhSXPZk6NLrSoVkEfRWFahza1NITGATeD7eMqsqN0nhdWxjxY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from dude02.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::28]) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1rdGJZ-0000lo-A0; Thu, 22 Feb 2024 22:09:09 +0100 From: Marco Felsch To: gregkh@linuxfoundation.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, linux@roeck-us.net, heikki.krogerus@linux.intel.com, jun.li@nxp.com Cc: devicetree@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH v3 3/4] usb: typec: tcpm: add support to set tcpc connector orientatition Date: Thu, 22 Feb 2024 22:09:02 +0100 Message-Id: <20240222210903.208901-4-m.felsch@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240222210903.208901-1-m.felsch@pengutronix.de> References: <20240222210903.208901-1-m.felsch@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:1101:1d::28 X-SA-Exim-Mail-From: m.felsch@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791634965931670120 X-GMAIL-MSGID: 1791634965931670120 This adds the support to set the connector orientation value accordingly. This is part of the optional CONFIG_STANDARD_OUTPUT register 0x18, specified within the USB port controller spsicification rev. 2.0 [1]. [1] https://www.usb.org/sites/default/files/documents/usb-port_controller_specification_rev2.0_v1.0_0.pdf Signed-off-by: Marco Felsch Reviewed-by: Heikki Krogerus --- v3: - no changes v2: - no changes drivers/usb/typec/tcpm/tcpm.c | 6 ++++++ include/linux/usb/tcpm.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index 5945e3a2b0f7..85ca26687324 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -1099,6 +1099,12 @@ static int tcpm_set_roles(struct tcpm_port *port, bool attached, if (ret < 0) return ret; + if (port->tcpc->set_orientation) { + ret = port->tcpc->set_orientation(port->tcpc, orientation); + if (ret < 0) + return ret; + } + port->pwr_role = role; port->data_role = data; typec_set_data_role(port->typec_port, data); diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h index 65fac5e1f317..93b681ff3ef9 100644 --- a/include/linux/usb/tcpm.h +++ b/include/linux/usb/tcpm.h @@ -133,6 +133,8 @@ struct tcpc_dev { enum typec_cc_status *cc2); int (*set_polarity)(struct tcpc_dev *dev, enum typec_cc_polarity polarity); + int (*set_orientation)(struct tcpc_dev *dev, + enum typec_orientation orientation); int (*set_vconn)(struct tcpc_dev *dev, bool on); int (*set_vbus)(struct tcpc_dev *dev, bool on, bool charge); int (*set_current_limit)(struct tcpc_dev *dev, u32 max_ma, u32 mv);