From patchwork Mon Apr 8 04:30:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 787150 Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97AF15244 for ; Mon, 8 Apr 2024 04:30:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712550657; cv=none; b=GAVkhvEaGValGo3/uZJG7duQ+JD6JLJFJ2x6KGaNZ/butsODfll7mcVG47OnBU1B+P91YOFJDcN1vcQHBWojFEVyCbulU0zGzFGoK+a71kKnSR2hTOl/NzxrkaG3/iGmaBN+9MUuvNyKKKF5p5s5JBzEEt+arl995GaANxuPkxI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712550657; c=relaxed/simple; bh=ZsrBSv+MDk5+UD0MFXH26dCUwN5ObviBN+4pNMZ7Mp4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=trq1lYQCgclYLOjcq27oK+Hf3iHamzC+/VGvcH3tRcrTerIS+PAuswc7QElfLCmH1e2sedjhu5xvvVpmvysEXqewnQQbXZfD7B9Q7oVLFxNL/DK4bkKgnGdUVTDGkyo2ijswGz+5MqHAkZxzTAsAK1oRrWhvLeLZNn3AX+Ccb2Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=h7syqkAY; arc=none smtp.client-ip=209.85.208.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="h7syqkAY" Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-2d8129797fcso53302381fa.1 for ; Sun, 07 Apr 2024 21:30:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712550654; x=1713155454; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=hZG8/w6c2g2XY/SjpCMDmc9IC0Y93zEgxZp35QKFMDk=; b=h7syqkAY+eB220fxznDUJDkLuTNTJCgwtbpMTEWPgdd84Ywb40AvHEzWA412HDlMZM Oznei7TEFDHoryTUsc86sjLnLfo7niGLOjbrkyy95L2I2Y2C03r3z0W3MSr0HtYP44lv /7yxp27iHMcp5U6aJ4IyjnTTgTOM+FLy5G4t/j+mOpROKzpYHXiAtvDnKUYOkwPj+uVW us7blU+Y0Y30/3HOJMhfqrmyyH1ifTl4lR/erGqQcE+QWphzxQnoP40ia6e6bi2pIwCO wXL1il5oymCxWap4hyq3E4fA2+/Wf1y4CRVrWFgk5i0H40UW+6io3frA5bWf/imbjLZo LlBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712550654; x=1713155454; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hZG8/w6c2g2XY/SjpCMDmc9IC0Y93zEgxZp35QKFMDk=; b=sgOo63suJ70O1IXdOcdNwUffpdDyj7upLV/wrpVevD4pssZweJMGCcpZNWUS2KzqOQ iivW2TEox6CaL6f1MIahgkt7SQRCfu93ZMXCkuePgL90j9s9ehtAQ956lSLTPT7Z1Llq uCaYkBWLWWf4yxvkglNK96Z/wIlX99sfGTb3tB6TyueUeWyamKrk1AY6w8NFpiQLxr9I KIB721jjZIvTVOzJ8B9HBqh35WTywD4DfQr5hN4Ki5oV5sAbLk5gBZZf2sH+HJtHp0fZ GsUawQzPhdtWBU7HlZr3ymEsXZsvZMfGKhaml6PwZ5M2G5muWt5I1MP7wYpuzXcm+3Y+ 4Rwg== X-Forwarded-Encrypted: i=1; AJvYcCXISVlmbeGWH7ndOtjrvk5U0acU7MzwBtOrl1uUmYZkdmSvVkmCOhgHjcseb5Q7Pcrzu9ZpFEqIfkEgyMWinqqUgAGVSZ/fa1v/ X-Gm-Message-State: AOJu0YxVQHa+hNIbkXWYT5SloZr4PVFR6H5NO1QWLaKwUUQ0FyJdQX+P SuwZ4OrAC+ehZuZzhnC8n6Sw8B0zZHQgLw64zoaXW+7zMxTDAK11BqX66f27/Lc= X-Google-Smtp-Source: AGHT+IH3sW9gR8rxmz0Z7/CnW7zJK5Z8Krjj5NurPe1/ZRqtYoetQdBEPvORqLq8SB1UGBs86qWvKg== X-Received: by 2002:a05:6512:485c:b0:516:c763:b4f5 with SMTP id ep28-20020a056512485c00b00516c763b4f5mr5368447lfb.3.1712550653727; Sun, 07 Apr 2024 21:30:53 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id g13-20020ac2538d000000b005132f12ee7asm1033207lfh.174.2024.04.07.21.30.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Apr 2024 21:30:53 -0700 (PDT) From: Dmitry Baryshkov Date: Mon, 08 Apr 2024 07:30:49 +0300 Subject: [PATCH 1/5] usb: typec: ucsi: add callback for connector status updates Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240408-ucsi-orient-aware-v1-1-95a74a163a10@linaro.org> References: <20240408-ucsi-orient-aware-v1-0-95a74a163a10@linaro.org> In-Reply-To: <20240408-ucsi-orient-aware-v1-0-95a74a163a10@linaro.org> To: Heikki Krogerus , Greg Kroah-Hartman Cc: Neil Armstrong , linux-usb@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Dmitry Baryshkov X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2663; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=ZsrBSv+MDk5+UD0MFXH26dCUwN5ObviBN+4pNMZ7Mp4=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBmE3L7KH6S9lSWKXRScQhis4OPHAVggX4qXjTVU 0j/th5VbvmJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZhNy+wAKCRCLPIo+Aiko 1RXgB/sEqkey8wBNfqOSKhcBZBtzrXky2hEub9ei/YuhmZ7GxQhAaglfwNEbPZCvEHzO2qzzaMu Z1ojxyKgC6bMXkG26x1AFEM6sMsqE/kBU3neRnLrhVL3YevKhHF3aEtUCP859ELvEKZSaAnGFP4 2WmEJpN4KU9QjTdPfifOykuBLcg4GydSD4cIEWz7CCDD47ypc1D8dISaqu2uTgPKYlxOLsf1k3y oF6BQhF/JDWapmrUX2JG87dBiTpmS/YLmPPzgVMxqjnAB1rpiYoWVCRnClHNmBVO/cczkRcrytH 90v7EARd3V+G8SL11n2bfTlxMYeFI02f3a+h6wTU4jXsiB6j X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A Allow UCSI glue driver to perform addtional work to update connector status. For example, it might check the cable orientation. This call is performed after reading new connector statatus, so the platform driver can peek at new connection status bits. The callback is called both when registering the port and when the connector change event is being handled. Signed-off-by: Dmitry Baryshkov --- drivers/usb/typec/ucsi/ucsi.c | 6 ++++++ drivers/usb/typec/ucsi/ucsi.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c index 3106e69050cd..7ad544c968e4 100644 --- a/drivers/usb/typec/ucsi/ucsi.c +++ b/drivers/usb/typec/ucsi/ucsi.c @@ -1199,6 +1199,9 @@ static void ucsi_handle_connector_change(struct work_struct *work) trace_ucsi_connector_change(con->num, &con->status); + if (ucsi->ops->connector_status) + ucsi->ops->connector_status(con); + role = !!(con->status.flags & UCSI_CONSTAT_PWR_DIR); if (con->status.change & UCSI_CONSTAT_POWER_DIR_CHANGE) { @@ -1588,6 +1591,9 @@ static int ucsi_register_port(struct ucsi *ucsi, struct ucsi_connector *con) } ret = 0; /* ucsi_send_command() returns length on success */ + if (ucsi->ops->connector_status) + ucsi->ops->connector_status(con); + switch (UCSI_CONSTAT_PARTNER_TYPE(con->status.flags)) { case UCSI_CONSTAT_PARTNER_TYPE_UFP: case UCSI_CONSTAT_PARTNER_TYPE_CABLE_AND_UFP: diff --git a/drivers/usb/typec/ucsi/ucsi.h b/drivers/usb/typec/ucsi/ucsi.h index 2caf2969668c..6599fbd09bee 100644 --- a/drivers/usb/typec/ucsi/ucsi.h +++ b/drivers/usb/typec/ucsi/ucsi.h @@ -53,12 +53,14 @@ struct dentry; #define UCSI_CCI_ERROR BIT(30) #define UCSI_CCI_COMMAND_COMPLETE BIT(31) +struct ucsi_connector; /** * struct ucsi_operations - UCSI I/O operations * @read: Read operation * @sync_write: Blocking write operation * @async_write: Non-blocking write operation * @update_altmodes: Squashes duplicate DP altmodes + * @connector_status: Updates connector status, called holding connector lock * * Read and write routines for UCSI interface. @sync_write must wait for the * Command Completion Event from the PPM before returning, and @async_write must @@ -73,6 +75,7 @@ struct ucsi_operations { const void *val, size_t val_len); bool (*update_altmodes)(struct ucsi *ucsi, struct ucsi_altmode *orig, struct ucsi_altmode *updated); + void (*connector_status)(struct ucsi_connector *con); }; struct ucsi *ucsi_create(struct device *dev, const struct ucsi_operations *ops); From patchwork Mon Apr 8 04:30:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 787438 Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E88C566A for ; Mon, 8 Apr 2024 04:30:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712550658; cv=none; b=POtksZUNpa/a6GQIoTaa4cwRvlZ9Mteqpu/w/iAGPo4sl6WIUagqt7QTSJCbrigbFXHODOqUGmEiNE7XOpgzRuHY8bNaAIg1SgeIsKqFpgGAg9XPl78rvWBgJI5A2DNyu2XmicLZCck8pdbMBbYwMZiNXcYaY1HpFhnlDQncf4Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712550658; c=relaxed/simple; bh=kO8dzpi4xvwBQro3NVL4pskyi7qzW3Wf3RIbzcN7iR4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XH1KQfYCSCc0avnkBd0j0HPrb598D/UXd8aNAfqgqbtDYXA2L3Wsefuc5kuTGJUvuRbYxZVOlBYka/eREX386jhuwPnRYiTw0lnuOhDn/Ksp8BCPz/xG/bbO2F2FsVCsIhqSuoL+1G5d2HgtyNTl9wt/yXJdLpyzAYplHUAxmeU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Ax+gMK+e; arc=none smtp.client-ip=209.85.167.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Ax+gMK+e" Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-516d487659bso3498599e87.2 for ; Sun, 07 Apr 2024 21:30:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712550654; x=1713155454; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Vaz5XoTM7xMyj+69kPNuDqaQ4j3uUvcbmmXoKXAw740=; b=Ax+gMK+eZKEPSdmpRkc4bOQR0SnEX17LAl1CdWjf6O6XyfZ9eAv4/4+MO9vYxhsYUA /axWE03EcvePHtn3ThFizJu4sGPHsmo6d3maQns0o3ar7BRaXKBYoLh5NwDuNNAmLFdf r51wUA8ZIs5kNzWdc6OyGtMz7jK49fzSkJVX++KCq9YVkzatNQQLyfwaM320aFzE6yj+ zMLLdqgVG/hlMJyCoRawSF3aUFtxMADdJCn859RCsGkFJFZmZrOn2aOY5HmDq98BbSEa ywPL0gkJgeKYHv9Z73hojeLsbwbw29Qa4kQ7/VOGNpZNaCTCwwUC2w2ISTMb4s43pAV2 PL9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712550654; x=1713155454; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Vaz5XoTM7xMyj+69kPNuDqaQ4j3uUvcbmmXoKXAw740=; b=Wuo4TosfVfQ4db+g3PNhoI25P4547bqtTULn4lpu0I0RNflP9P5cuquVvhMPSdYHnJ zR++wHEkhYHzNka0uS/6isTA1rR8rjLjXdQ//p7QlRyoYTmjFf/Rdrj877Q+JTb6Z46Z LQcJpReCHbwTrl89jSn78GV6iImvesmntgtk4i01HIPCGdzels1XnWIMl6EQIRHmZplV 4jJMeFY4XfAKxVr4Qplzu3x7PeG8JcBlox13IzU8uyvpRfraks3NIblZqwyVcUzS5hIL 71cLI1mReI2vFYxqxE5VZiz/cTcY/IvvI0gHd8/ZK/Wn86/qRN/NV+btAStxoZrMaIoH pBJA== X-Forwarded-Encrypted: i=1; AJvYcCX0hTjq1psg69GWhtuwLM9FYuVmbg8pLMTi12ozCV77f4eewC2TP9tGSj3fpAWjGBrzpv3dm1DA0M6pL2t6qJuv5RVAPyxnqAgS X-Gm-Message-State: AOJu0YxbMJV3SkOua5G59tJtfIScU/hLiukarLLjdDB7tEhAb6kR11r3 s+nn7E8bcnuCeSD46G7Q75N2IAoOox+6sI3uEvWG7nncGz76m+X8RF5OfG7z2U4= X-Google-Smtp-Source: AGHT+IHfjApLCsylVm5+NrfypVA3w+etvzDIaOlBVzBsqVchSYo7Tz8s1egFMZlt1KVXX8dgto8bUw== X-Received: by 2002:ac2:539c:0:b0:515:9185:652f with SMTP id g28-20020ac2539c000000b005159185652fmr4539995lfh.33.1712550654319; Sun, 07 Apr 2024 21:30:54 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id g13-20020ac2538d000000b005132f12ee7asm1033207lfh.174.2024.04.07.21.30.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Apr 2024 21:30:54 -0700 (PDT) From: Dmitry Baryshkov Date: Mon, 08 Apr 2024 07:30:50 +0300 Subject: [PATCH 2/5] usb: typec: ucsi: glink: move GPIO reading into connector_status callback Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240408-ucsi-orient-aware-v1-2-95a74a163a10@linaro.org> References: <20240408-ucsi-orient-aware-v1-0-95a74a163a10@linaro.org> In-Reply-To: <20240408-ucsi-orient-aware-v1-0-95a74a163a10@linaro.org> To: Heikki Krogerus , Greg Kroah-Hartman Cc: Neil Armstrong , linux-usb@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Dmitry Baryshkov X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3188; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=kO8dzpi4xvwBQro3NVL4pskyi7qzW3Wf3RIbzcN7iR4=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBmE3L7X0xzuUtwSZrdRISIp3qyNIQL2XeAng1Ip APJ9DcGg6+JATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZhNy+wAKCRCLPIo+Aiko 1TurB/4jxdOt96tIeWpN1/TOaeGrWxhjZYTx7m+JWjmRtlZK4XgPgk4+H/LhDReT4KDCHr947bS zFgmqOWlCU7aL8NOwAH/bNpoQt+4vXoUpjTJjqAi84bxmjJjqG0syfa0V6Ohu88ZzsSmvp53jZS vXP+bq812IuRKFPx9qS7JYUkGDPWuUAqAdMkizVxPuuyA+fZZQPx2OzNoE5gNL2er7xLRhF5C3y XxOvAsfP2oQ/zRuEvCf/DnvmIXFPrAdgDQjtlb+DrZv8UEQFi6cPgUSpjBx+L4938AMCniqkxHM ITbjddgW87gQ8G7OhGRpAB1iFszXIdheRDCsqDm2FRX1+xYV X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A To simplify the platform code move Type-C orientation handling into the connector_status callback. As it is called both during connector registration and on connector change events, duplicated code from pmic_glink_ucsi_register() can be dropped. Also this moves operations that can sleep into a worker thread, removing the only sleeping operation from pmic_glink_ucsi_notify(). Signed-off-by: Dmitry Baryshkov --- drivers/usb/typec/ucsi/ucsi_glink.c | 48 ++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/drivers/usb/typec/ucsi/ucsi_glink.c b/drivers/usb/typec/ucsi/ucsi_glink.c index b91d2d15d7d9..d21f8cd2fe35 100644 --- a/drivers/usb/typec/ucsi/ucsi_glink.c +++ b/drivers/usb/typec/ucsi/ucsi_glink.c @@ -187,10 +187,28 @@ static int pmic_glink_ucsi_sync_write(struct ucsi *__ucsi, unsigned int offset, return ret; } +static void pmic_glink_ucsi_connector_status(struct ucsi_connector *con) +{ + struct pmic_glink_ucsi *ucsi = ucsi_get_drvdata(con->ucsi); + int orientation; + + if (con->num >= PMIC_GLINK_MAX_PORTS || + !ucsi->port_orientation[con->num - 1]) + return; + + orientation = gpiod_get_value(ucsi->port_orientation[con->num - 1]); + if (orientation >= 0) { + typec_switch_set(ucsi->port_switch[con->num - 1], + orientation ? TYPEC_ORIENTATION_REVERSE + : TYPEC_ORIENTATION_NORMAL); + } +} + static const struct ucsi_operations pmic_glink_ucsi_ops = { .read = pmic_glink_ucsi_read, .sync_write = pmic_glink_ucsi_sync_write, - .async_write = pmic_glink_ucsi_async_write + .async_write = pmic_glink_ucsi_async_write, + .connector_status = pmic_glink_ucsi_connector_status, }; static void pmic_glink_ucsi_read_ack(struct pmic_glink_ucsi *ucsi, const void *data, int len) @@ -229,20 +247,8 @@ static void pmic_glink_ucsi_notify(struct work_struct *work) } con_num = UCSI_CCI_CONNECTOR(cci); - if (con_num) { - if (con_num <= PMIC_GLINK_MAX_PORTS && - ucsi->port_orientation[con_num - 1]) { - int orientation = gpiod_get_value(ucsi->port_orientation[con_num - 1]); - - if (orientation >= 0) { - typec_switch_set(ucsi->port_switch[con_num - 1], - orientation ? TYPEC_ORIENTATION_REVERSE - : TYPEC_ORIENTATION_NORMAL); - } - } - + if (con_num) ucsi_connector_change(ucsi->ucsi, con_num); - } if (ucsi->sync_pending && (cci & (UCSI_CCI_ACK_COMPLETE | UCSI_CCI_COMMAND_COMPLETE))) { @@ -253,20 +259,6 @@ static void pmic_glink_ucsi_notify(struct work_struct *work) static void pmic_glink_ucsi_register(struct work_struct *work) { struct pmic_glink_ucsi *ucsi = container_of(work, struct pmic_glink_ucsi, register_work); - int orientation; - int i; - - for (i = 0; i < PMIC_GLINK_MAX_PORTS; i++) { - if (!ucsi->port_orientation[i]) - continue; - orientation = gpiod_get_value(ucsi->port_orientation[i]); - - if (orientation >= 0) { - typec_switch_set(ucsi->port_switch[i], - orientation ? TYPEC_ORIENTATION_REVERSE - : TYPEC_ORIENTATION_NORMAL); - } - } ucsi_register(ucsi->ucsi); } From patchwork Mon Apr 8 04:30:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 787149 Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C68396FBE for ; Mon, 8 Apr 2024 04:30:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712550659; cv=none; b=H/TdXPJ40Oayq5y2Y5YUd4fR21BCYhENG/lDuRqeJZwElKJFpa7eLWDw1p17s+YD42IY7262hMakYzDnOrBDWfjJRQPAJxIT/wWT6vQ7U1F8te/WGaJxzq45BB27koOsfX4InsSGRIjSD3+0Jd0Lq2kRDlUyR3Yq9gJGHlJptdw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712550659; c=relaxed/simple; bh=6Pp8ISuDZAtUkxCFA5Mzr7Pj0egqS4eDsl4x+9fdzEg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hRvATtGJoXvlNNTp1ZK8LiFYH1Y58K7eXZq2GCdpjjkd5srfi5y5Q/+X0pfqOc2JuJlo7IaMadU+9yKsj8buMLtHAQ97dUxUerylrYPve4U6brL+6DwT/OdMpwVtN9a6r9Yw8keHjtIrEP/hflWYAuUGKWQk9lng+6609tC1aTo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Qz5uGkLP; arc=none smtp.client-ip=209.85.167.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Qz5uGkLP" Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-516d727074eso2575635e87.0 for ; Sun, 07 Apr 2024 21:30:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712550655; x=1713155455; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ENukurxkpnH6btr43WV4x/+l5y/bB4zzdKjrs7ksqE0=; b=Qz5uGkLPm7X1ffIvwhdN7kZdNkRJz5c9tU2AU5YzS92xA0Y3PMMbRcCJo1ztnpYOot ki5kORBS3g4z2H60jLqTjwwYAl8+TyX4XtECgpDhqb8YOumywlRFmzduS1m4ORorTfdj 7/E3PbxOYpDxAjceibZYXVL9/6JI/k/bRCrX/zzN020aiKAz8jf5tRG5NoXosMnk4sMY btNHUxrwKujJEeGuk3JlDEogCONyjEINqexShjW8IhCgh36ZMm2YewsA6kq1tXmEQUIo k1sww6Dr4WXjt4QtcjkZns6heVgIyw8cMtQflSIwMDpilBWPmPKWv230oynjmEcgV4c4 0uwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712550655; x=1713155455; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ENukurxkpnH6btr43WV4x/+l5y/bB4zzdKjrs7ksqE0=; b=iSGnELyhMDjh/2YgryvGXr0I0wWpSqvjBEO4ybh7Upy4XwCR+NwskaT1nbrbQGXHbl SAwIlVIUip0huir6kWQ0EvH3DyFjLiESYQohJoXkDELwvjVQlhX8kg4vcPMe3k3rPwTS mL0rMKrT1162e0wXUsl59rkpw8R22HJ521w6AD/i3Yh5K5W+iYVXMfcVASGnzO/JrG0g Q4i1dkKkhM75vRLIU2tBfdonfQodgyEAh1bp7SxZ1k4muHbo1TU94BV1EHVr5SZiPMv6 kzb5OOtBJJZARUq/4h91+GzJqn1Wts22zcwTtAhBCH8Vz1rJqbxDF9YimHwcRN5/V5WF Lv8Q== X-Forwarded-Encrypted: i=1; AJvYcCWGXrMgDK2wYLiWrfHfoywJI6JL+ev3kQ21FHWgAgcZVVElOwAqJIHWdsRWwfQ2U49ySxOrAnL/uwxgktXwjH0pk39PwEWClKEn X-Gm-Message-State: AOJu0YyWjq/Oa5Z2xClBXT0HPDHISqNtQipwE+bCrc/vlJiT/PFBTbOK Y9FyIxs89EocmkYx8bpPSTbsIyIShzOsaJrv4V+BoRGxI0eLUQ4DwMBBCIyAE64= X-Google-Smtp-Source: AGHT+IEjiBzAFkgSlnDA5c4dvuKfeCyu6QTyl5XSf+HAw91rTnk+Y0NsxdtJ8Wa70bGWdxCBEcih7Q== X-Received: by 2002:a19:6457:0:b0:516:d17f:3c30 with SMTP id b23-20020a196457000000b00516d17f3c30mr5266580lfj.3.1712550655081; Sun, 07 Apr 2024 21:30:55 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id g13-20020ac2538d000000b005132f12ee7asm1033207lfh.174.2024.04.07.21.30.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Apr 2024 21:30:54 -0700 (PDT) From: Dmitry Baryshkov Date: Mon, 08 Apr 2024 07:30:51 +0300 Subject: [PATCH 3/5] usb: typec: ucsi: glink: use typec_set_orientation Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240408-ucsi-orient-aware-v1-3-95a74a163a10@linaro.org> References: <20240408-ucsi-orient-aware-v1-0-95a74a163a10@linaro.org> In-Reply-To: <20240408-ucsi-orient-aware-v1-0-95a74a163a10@linaro.org> To: Heikki Krogerus , Greg Kroah-Hartman Cc: Neil Armstrong , linux-usb@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Dmitry Baryshkov X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1822; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=6Pp8ISuDZAtUkxCFA5Mzr7Pj0egqS4eDsl4x+9fdzEg=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBmE3L7gAxLAJjmRw2Ft1WpQQJcHwpO52VWP8lAH 1Anz7mkGzWJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZhNy+wAKCRCLPIo+Aiko 1aIAB/47+POeBCZy8cZ2CnEAbZYdtAhvloPtBOZ2ao7zEDTzYMD8yRKcF2Iacq7wo3MbDVfS+4+ sqUpRs2ENNWrinfQxmju5WLt/I/i3ReB9u3GVXxbkntyVQUGVuxRQ4znK7Ekskc01gSU1mJ2XZW x/W9gQfwMSkvgpzCDK5WRZTcbh8yGb5dVt8VU1pxIWhE6h2PhsXZLTFiwfSE8WFS10oqmb2apPV DrUHjXYCoEK8j+LmH5IU3hy+tbyDGs5KKDDkpsgkZFGA+xOJSnazYJRT43Brg/ZBqdw3YpGvgPv Pf+36qEskA3818lMpuofRHUNRTvhDmhXIBSvZyc8l4/BvBZV X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A Use typec_set_orientation() instead of calling typec_switch_set() manually. This way the rest of the typec framework and the userspace are notified about the orientation change. Signed-off-by: Dmitry Baryshkov --- drivers/usb/typec/ucsi/ucsi_glink.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/usb/typec/ucsi/ucsi_glink.c b/drivers/usb/typec/ucsi/ucsi_glink.c index d21f8cd2fe35..d279e2cf9bba 100644 --- a/drivers/usb/typec/ucsi/ucsi_glink.c +++ b/drivers/usb/typec/ucsi/ucsi_glink.c @@ -58,7 +58,6 @@ struct pmic_glink_ucsi { struct device *dev; struct gpio_desc *port_orientation[PMIC_GLINK_MAX_PORTS]; - struct typec_switch *port_switch[PMIC_GLINK_MAX_PORTS]; struct pmic_glink_client *client; @@ -198,9 +197,10 @@ static void pmic_glink_ucsi_connector_status(struct ucsi_connector *con) orientation = gpiod_get_value(ucsi->port_orientation[con->num - 1]); if (orientation >= 0) { - typec_switch_set(ucsi->port_switch[con->num - 1], - orientation ? TYPEC_ORIENTATION_REVERSE - : TYPEC_ORIENTATION_NORMAL); + typec_set_orientation(con->port, + orientation ? + TYPEC_ORIENTATION_REVERSE : + TYPEC_ORIENTATION_NORMAL); } } @@ -378,11 +378,6 @@ static int pmic_glink_ucsi_probe(struct auxiliary_device *adev, return dev_err_probe(dev, PTR_ERR(desc), "unable to acquire orientation gpio\n"); ucsi->port_orientation[port] = desc; - - ucsi->port_switch[port] = fwnode_typec_switch_get(fwnode); - if (IS_ERR(ucsi->port_switch[port])) - return dev_err_probe(dev, PTR_ERR(ucsi->port_switch[port]), - "failed to acquire orientation-switch\n"); } ucsi->client = devm_pmic_glink_register_client(dev, From patchwork Mon Apr 8 04:30:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 787148 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 80BE079C2 for ; Mon, 8 Apr 2024 04:30:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712550661; cv=none; b=INcj3RTpMChHzJJaubF7oYBpxJeGuAoZxNE28qqm5YCQ7OCDjfhycgXikZsxJolQru1aiJWXkt3TpIM8ojILK5rbALzrsxTS3XUgFRL8MdGED5cpJHRZyV1wQ9vw0FX7dPJN0St9ICgZrvllXPmHlM/p0Oes6vuP1qE/k03wqYU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712550661; c=relaxed/simple; bh=AiMHop6LtWh5la59tUhjUjvEK/UQiD8uM+1Bb2RGdcc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=K4fOcytaa8zIbZnIzya41pSxgU2FMBsjuOUgkruj+QsaPBJthZri32MdtJBv3PD2y203dTZbf9rb9Y7I22boQIZJ+r7jCmYaInCLUF+9ziKGkiq/SmT1IuZX/leNcHrim4DDtpbBQNjv+UydezwU6cEIcX9j9YKIfE8iKifmJp4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=oprSFMRv; arc=none smtp.client-ip=209.85.167.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="oprSFMRv" Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-516d0c004b1so4427351e87.2 for ; Sun, 07 Apr 2024 21:30:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712550655; x=1713155455; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=aWjHFP4FIwQxUWAPVoONDZq/MeuxzTLfwG/YafjPU/Y=; b=oprSFMRvTiJHEr15KFMeVH6QzEY8VIK5o6rXJOV9drS8/jr/Gcat7RmxgnQUw0r8f9 /ZAMr3XUYmuMQT9hkqRvrG0XaLmDchMZq6+d1DwLGF/073mgvM36Fl9lChwudvr7D+yI ScKMSgyXvEemCk53MIdRWoAPAobSemwSEW5QMbpxKAV66wIxmxu5wz6fbHzQ1/1KSGtj onoBRaExBfQN8PBMRF0oQadN7tmFpvT/ty3cxSxhWMbIqTT/DMGw8lUfiGJKTI5hUB2I KgBZVjOuApNDR0nm5GLtNmFKAbI10fakqP/SktnJ7Qzac95mz+2oXsjfQhAz88DUeeIt VxVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712550655; x=1713155455; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aWjHFP4FIwQxUWAPVoONDZq/MeuxzTLfwG/YafjPU/Y=; b=igGN9HDQxNG40Hg4zBoOcHDfbRkiDxhT5MfkqQ9dtR8DCB8CKF4IbejH8YhApVyl9j FkymJa+wygxitzPBWNpjjIpdhC7s1V4misSuNtnt5tYQKHrThUQ3+BpWepOi+RwyP9II asuyZj0QEoFwQoROmtOG/7ZEqGOWrcvh2ZsM6rxROt/tTrYRXPK7WckN7sZmASXlcFZT 1gzObr/RO8yAdYezTEXCVrmdEYaXZNZ60ZefZFipEwqmWmL7sDFxl2NNNLgpoqe/+VtC kPHYQUAvyTZZZ7s87kVB4OFeNR3stWQi6dMSkiOFml5XbxdIexQII0/q3P0UtzXgBNwg J6lw== X-Forwarded-Encrypted: i=1; AJvYcCU4wtNkEZ0DM380lC96F1SYDhnePpH0RSBp6oGQVR7RgZfd9QiVslbN/P7a47VWk9mlikyXuoNMGFmbctygu0R/Dd/HiC0IZSmF X-Gm-Message-State: AOJu0YyYY8pRw8iJ7RyygWeIh3n8MkqRU721p5tOTwtq248nx28cb+Mi 7qIZfOim2PXblQN46KpzERopnW5GipQZGZyv1H35cIFvR6f4qX/QKzh7tz/G15Q= X-Google-Smtp-Source: AGHT+IFIO6xNYoZfEPFKmXNYH/a6iz/UGLcCNim2Ck9xD7LkNwZBRVFMJ1PDf5p1BbUMWec2ZXfO4A== X-Received: by 2002:a19:644e:0:b0:513:aef9:7159 with SMTP id b14-20020a19644e000000b00513aef97159mr5407151lfj.39.1712550655691; Sun, 07 Apr 2024 21:30:55 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id g13-20020ac2538d000000b005132f12ee7asm1033207lfh.174.2024.04.07.21.30.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Apr 2024 21:30:55 -0700 (PDT) From: Dmitry Baryshkov Date: Mon, 08 Apr 2024 07:30:52 +0300 Subject: [PATCH 4/5] usb: typec: ucsi: make it orientation-aware Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240408-ucsi-orient-aware-v1-4-95a74a163a10@linaro.org> References: <20240408-ucsi-orient-aware-v1-0-95a74a163a10@linaro.org> In-Reply-To: <20240408-ucsi-orient-aware-v1-0-95a74a163a10@linaro.org> To: Heikki Krogerus , Greg Kroah-Hartman Cc: Neil Armstrong , linux-usb@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Dmitry Baryshkov X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1643; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=AiMHop6LtWh5la59tUhjUjvEK/UQiD8uM+1Bb2RGdcc=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBmE3L7IPs4Dy2cixnuxh6PbWMygAc34bJSsBTiS g87Qu8asz6JATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZhNy+wAKCRCLPIo+Aiko 1Wx+B/wL9D5rVVtyDGr8tJVBflDFYn+l/8QkHU+8lO8IayWT9KG+uOtsC1LnOmRspt6imRaDueZ JhbpbaOf6eL12HEDTo1MdSVR17h7wlk2hOaR4eBhVmbHocM50U7svsxLYiQ3GQFIQc7z+fBZJLk R7rf5B/Jt3TmYSG/ccUI4k6N8fK3QBLZJNPypICKqxXJmSjiol0fTJV+fH01FioNAA/f+YtFUnW mbzFsQid+kMnK7VL3ETL8JrCDzX8BciHnn4feM+b+h+d4bY1RurXYkwXX8lKLz6WV7eyEiydsJg Hp6tpehb5SQJcETvzry2zv3gtbe5SA3MGnxwc7QNWKIOQbFr X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A The UCSI 1.0 is not orientation aware. Only UCSI 2.0 has added orientation status to GET_CONNECTOR_STATUS data. However the glue code can be able to detect cable orientation on its own (and report it via corresponding typec API). Add a flag to let UCSI mark registered ports as orientation aware. Signed-off-by: Dmitry Baryshkov --- drivers/usb/typec/ucsi/ucsi.c | 2 ++ drivers/usb/typec/ucsi/ucsi.h | 1 + 2 files changed, 3 insertions(+) diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c index 7ad544c968e4..6f5adc335980 100644 --- a/drivers/usb/typec/ucsi/ucsi.c +++ b/drivers/usb/typec/ucsi/ucsi.c @@ -1551,6 +1551,8 @@ static int ucsi_register_port(struct ucsi *ucsi, struct ucsi_connector *con) cap->svdm_version = SVDM_VER_2_0; cap->prefer_role = TYPEC_NO_PREFERRED_ROLE; + cap->orientation_aware = !!(ucsi->quirks & UCSI_ORIENTATION_AWARE); + if (con->cap.op_mode & UCSI_CONCAP_OPMODE_AUDIO_ACCESSORY) *accessory++ = TYPEC_ACCESSORY_AUDIO; if (con->cap.op_mode & UCSI_CONCAP_OPMODE_DEBUG_ACCESSORY) diff --git a/drivers/usb/typec/ucsi/ucsi.h b/drivers/usb/typec/ucsi/ucsi.h index 6599fbd09bee..e92be45e4c1c 100644 --- a/drivers/usb/typec/ucsi/ucsi.h +++ b/drivers/usb/typec/ucsi/ucsi.h @@ -410,6 +410,7 @@ struct ucsi { unsigned long quirks; #define UCSI_NO_PARTNER_PDOS BIT(0) /* Don't read partner's PDOs */ #define UCSI_DELAY_DEVICE_PDOS BIT(1) /* Reading PDOs fails until the parter is in PD mode */ +#define UCSI_ORIENTATION_AWARE BIT(2) /* UCSI is orientation aware */ }; #define UCSI_MAX_SVID 5 From patchwork Mon Apr 8 04:30:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 787437 Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 057428BFC for ; Mon, 8 Apr 2024 04:30:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712550659; cv=none; b=qsbRRYozEE1jwoWAK4BHeK/YP3RPEx8srzBJQRlv8KUOTQFHouq2SuoC6o6V5f5WwcW1Ulhs7kQsSy81FlswbcxzR3aJaAcIz13vCJJO46tKqCoBKf7ObKXCADY/FrVVMlHFh+253RAtyY8yX+6wI2cALkSwZUlaAxd0gevJ/gU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712550659; c=relaxed/simple; bh=OFNjqXgDmhJBCTwEy8oCd/Fyq6JPLE6X9Ia9XrIuJs4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SBRWZMoW7l9eE4BPNkj8S+IF6qLQXDZzQXBuHsmx2xA7Otkfj04aw8XsNBKXqsq7M385RsJLp0eSNJ7EXZjI4kIQRGowVQhBfU6Tt8xC4pBLHUPqdYHUujlszKvl2naDqrkJ/PN0tLsI1gxOh/Wtbya3C+JVDEdAaZY4hZdOcDk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=yQXgrV+e; arc=none smtp.client-ip=209.85.167.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="yQXgrV+e" Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-516d756eb74so2671013e87.3 for ; Sun, 07 Apr 2024 21:30:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712550656; x=1713155456; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=DdS/iAbBxLLUZl8me/kS3vqa9hXzOuPdZZo0B9BMFVE=; b=yQXgrV+epafKe1hURc+6Q2r/2o5kntlDvrTEH3kWs6JcxakTMFbRsbd3lrRvO0pYVy zi+XOrgSN82fnAIVF8iJ8lXQnq89Pu/m3on220dn1gHN4VFgI+uitsmnX4E+gz1IYXCJ snmoXqfqOtF/PRSZCTvjKHcfETs5GnJWtU6rxxzZRKiumrQZr4vPr1J/PtzAEIh6N36+ xJ7rcmqaiX/fvvv5RbOtsSpED5hlCcKymaeRClUJT2lPwzAICAu5aTAkkvEfWBnT06b4 DddpTBYmgqIjAFD6tke6raC6eGNL1XhqgizPVnSmyK/ZgkhkxA0pAbH2YYVLyNTHUJPo 3+mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712550656; x=1713155456; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DdS/iAbBxLLUZl8me/kS3vqa9hXzOuPdZZo0B9BMFVE=; b=FKpBkmRnwb/0ghnFIlecsjtOelk+w09eYV29GspEY+6Q24VmHL6EMTugwpES4bHgXo vpl2T8hCm+geF4s54g7drDR3UOo6/0kXctJknceGFS25gE6MJmVlfC8FRhQR6cV5U3Dm vGjfB6gs72oTZB97pkfcS1xOxZGkvC8ajnNylSWailF+dZhlXeLLjyn5UwNSDb1N/SAy 65LsrUbt+Ua2/kJbAOEq8Syk/t3O0Xu2k/dX2N5TktrPMPvDcV5RtfOTlGxWc/gK/8FG O6G5l3j52sYmJAa1BhN/4xsSL3T/MO+OPTQJGhaP9WLwZvyu9nmahrZJSYVK2276FD6y Zw8w== X-Forwarded-Encrypted: i=1; AJvYcCWvRra01IT8tbF6buNss+4JaaHmGeLGKAb+jTptbA/qi1C0qET4o4hnLQyhuW7Gqi6gR2pvyGWDd3sTRTGBBZxgmn7klRa/RseQ X-Gm-Message-State: AOJu0Yzc5W6eWeMF8Z1Cc9HIULRCHfqYnqUSKGBoyhQ3wcqnf9I5eifW F7LBmNqxUfzhPVxwhlWFD8GnOUXCupVBmkKJmxxaP34lYmd0WJxekpZlHdxMCIs= X-Google-Smtp-Source: AGHT+IGolJn7tKx0Ibob0MCiWR5rKGe2h9hkerxCybsDQSTV08jAZ4Jp1ilgPOu7qsys6iKUMvZ1vg== X-Received: by 2002:a05:6512:14a:b0:516:c9a8:5ade with SMTP id m10-20020a056512014a00b00516c9a85ademr4869967lfo.22.1712550656243; Sun, 07 Apr 2024 21:30:56 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id g13-20020ac2538d000000b005132f12ee7asm1033207lfh.174.2024.04.07.21.30.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Apr 2024 21:30:55 -0700 (PDT) From: Dmitry Baryshkov Date: Mon, 08 Apr 2024 07:30:53 +0300 Subject: [PATCH 5/5] usb: typec: ucsi: glink: set orientation aware if supported Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240408-ucsi-orient-aware-v1-5-95a74a163a10@linaro.org> References: <20240408-ucsi-orient-aware-v1-0-95a74a163a10@linaro.org> In-Reply-To: <20240408-ucsi-orient-aware-v1-0-95a74a163a10@linaro.org> To: Heikki Krogerus , Greg Kroah-Hartman Cc: Neil Armstrong , linux-usb@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Dmitry Baryshkov X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=899; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=OFNjqXgDmhJBCTwEy8oCd/Fyq6JPLE6X9Ia9XrIuJs4=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBmE3L8yVMFuaX6oHTn7NO/hspCBjSC7aWF6DmsR yOlWW4CTxCJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZhNy/AAKCRCLPIo+Aiko 1SSCCACemQ21Bu0P55MdKeoqBVCH0prRGLInuVwcWDnQwyo+HgZGlTELmAHitNKlu1iW05uq3Di OB4Y/g3Dlk8j8pL7LulULIedAm5OfyQ5yihlH7zb1v73cIYscYn2cKoeDPMkReYqVn89sLFOmOd XaorhMzVfO3GashouK9oMTWBvWrfpPx1SWJWne2YJHWMpB49EANCgBtP7mqXpWKnQoSkCVSsgSZ qIP59I+SULpp6KlkhROoMmW56lp8lhAjxbPWu82pQ0mLlNgNhOj9VMBQh73s4St16xvGs3UU8lt 10mxv/8AJE9TKcl+Uu3DkNgZ6sgoPFMZeZ2kQKEcSiqLf5s2 X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A If the PMIC-GLINK device has orientation GPIOs declared, then it will report connection orientation. In this case set the flag to mark registered ports as orientation-aware. Signed-off-by: Dmitry Baryshkov --- drivers/usb/typec/ucsi/ucsi_glink.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/typec/ucsi/ucsi_glink.c b/drivers/usb/typec/ucsi/ucsi_glink.c index d279e2cf9bba..87a8b5f88da4 100644 --- a/drivers/usb/typec/ucsi/ucsi_glink.c +++ b/drivers/usb/typec/ucsi/ucsi_glink.c @@ -378,6 +378,8 @@ static int pmic_glink_ucsi_probe(struct auxiliary_device *adev, return dev_err_probe(dev, PTR_ERR(desc), "unable to acquire orientation gpio\n"); ucsi->port_orientation[port] = desc; + + ucsi->ucsi->quirks |= UCSI_ORIENTATION_AWARE; } ucsi->client = devm_pmic_glink_register_client(dev,