From patchwork Thu Apr 11 04:49: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: 788009 Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (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 B344513C3ED for ; Thu, 11 Apr 2024 04:50:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712811003; cv=none; b=NWNoik7wFfLX/2XlUHePG9Q6S324gUwXZmAf8hXWB8KD9AYZ9LoBrjxoc1y2Om0bS9sFRRUFa2aeKXyg+vkGMQ7gw6t5Oz15ay1pDCVMq/W/GNpWtgs+KSjksPQgC8Y8L44HDMm8nhugOsFYmcYq0MAt6E5UQlPy2Z+ZzjWDwSM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712811003; c=relaxed/simple; bh=o0n7CdTQicezVYHkhHA+eu0PFvXKHx9vQdAaZcpUKvM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=urqbON83NVZAi1HnlHinJG3UnrxQf/pcjg9VMJA2Br8cHGgWpIN89bxISRMeMt9h2/jLq806mKZdnngXccvQtLgYEKTN6t8nSoSg7FaK4HNgxmP0SEBUwvnQtf/dlADx9jMJkba2DyRgHdk7jZNBxCPAFmH2f6vW/G3ZzJMCZq4= 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=z3eWVdh4; arc=none smtp.client-ip=209.85.218.45 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="z3eWVdh4" Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a44f2d894b7so838112466b.1 for ; Wed, 10 Apr 2024 21:50:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712811000; x=1713415800; 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=8XYpc5SxTXH/MsQrVYYEDUZMigDy27y83NbauXg0EFI=; b=z3eWVdh4kSiaZ1HVJtOPqqXjDaEdR0yB/qv/c18kMCuptbYfXi5x3zi1DPLOeC+HNN Fsy3HeJY0xlm6ILDrm3YWBtu0ATqCfHy3HumeYIFyxXS9ybxMy8fF8p4v7bIwhXq+m5E jfeoNFNS/8/O1OBSkLBd9Vv2GlMIzzN6MSpofCRE3EO3o8jhQyyEepDCjo+JRmZC+QMY C8aN74IhxXOrpNWBD0jU5y1qNLnWQ9wM3cYQLbFC3HkNUoNP/Uen922gfIvAf6fYh4Oe KeihFqcxV/WjV2TBQjWBTmgk//+AqrNCiJT34XHwA1hsq8sE9r65X8k6NZnmoOXpTAuZ LuaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712811000; x=1713415800; 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=8XYpc5SxTXH/MsQrVYYEDUZMigDy27y83NbauXg0EFI=; b=oIddsp31JJBvRcWQCXxJvM4ZRSjx+saH2EpyRt3TRrDv2P9jXgCVnU7dXQ+a4z+OZS /KRMNjMIErAq/YxNf4/rn1nF7GKw1ksGhXHxUffvP7JDUoJquHbKo89bnj5fgd2KZ4h9 +1N9DcyKZaRmLWiHFHj904vg0DBpdOT6vdf0VH3remt3+YoEyiaqnfSmb7LaDt01XJIM lauGgdjwdgbLiaKdvDdb9se1c54TqSJAhWGRmB8TJ6s47q0cPE7a2aD2TDQxawJKZa0Q /6Do/KpzuJElo0FI3PrkKIVLizGDnYcKQtD0ac7JaqA9ZlcQaK6cLCcega9Uz2Nv2HKh iT7Q== X-Forwarded-Encrypted: i=1; AJvYcCWWgNl77ll5qhG3ku54QkW3hjCec/mhUPYb9J2NRNHFZGvHdoJprY90d/pDviEyMoZu1NqJJMSfBbfh2DduqpHMEYdWpXMQqHet1f3yLA== X-Gm-Message-State: AOJu0YwmvvGckvZGm8As/qtml02DSc75D5ErO7VNDkNAi4LkPJoFD6uU Antl7R2KH4jSQsOi0JVFqRviL+fl4g5a088GcWnfiu3HXlHI/UOLPEuXfWCNG8I= X-Google-Smtp-Source: AGHT+IHfOS7TMMEPhMNqCrs2YJCCHD4EXfinhHN+glELQjcm2ZidXGZ5C649R9o5G1KRNLgmNjjXuA== X-Received: by 2002:a17:906:a389:b0:a52:192a:4ea with SMTP id k9-20020a170906a38900b00a52192a04eamr1144097ejz.29.1712811000000; Wed, 10 Apr 2024 21:50:00 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id dm11-20020a170907948b00b00a51eed4f0d7sm364899ejc.130.2024.04.10.21.49.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 21:49:59 -0700 (PDT) From: Dmitry Baryshkov Date: Thu, 11 Apr 2024 07:49:53 +0300 Subject: [PATCH v2 1/5] usb: typec: ucsi: add callback for connector status updates Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240411-ucsi-orient-aware-v2-1-d4b1cb22a33f@linaro.org> References: <20240411-ucsi-orient-aware-v2-0-d4b1cb22a33f@linaro.org> In-Reply-To: <20240411-ucsi-orient-aware-v2-0-d4b1cb22a33f@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=2605; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=o0n7CdTQicezVYHkhHA+eu0PFvXKHx9vQdAaZcpUKvM=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBmF2v1zcM0rrrGE4aOLnDVKdErruEX+D/hxk6do U+KlmclAnqJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZhdr9QAKCRCLPIo+Aiko 1U01B/kB78Y8wS5Ox4gzzekFlLF4pp7KtBmCVkxAZLP5I67A7gRC4ibEGNAyP8QuarHRj4gsyRZ Dn+h7zL+XlBGHsOcwn78reF6iJCjwNoO6TCaZixM2CcCzkVt9Rky+xVhqBm8r6ax4vleyaUbfDM vX9/FU0jdbfHutYJ/oqG6iAs/F7nKf2619h0tARI13FqWlzaIbd8Qgl0YwM7kkHeUcoB7DdvpoW tD2G2fLOl+qImHV7v/fAQSVXH4CJMr/9C3RBgfs0Uq4bAaXtWadaqrxpUPak+hbgvUxNvJPWeVK uRwqdlL+hRhTPiPRBhtFnIDm21YQGPNn2v5khXPWg5GkuGf2 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 Reviewed-by: Heikki Krogerus --- 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..3e1241e38f3c 100644 --- a/drivers/usb/typec/ucsi/ucsi.h +++ b/drivers/usb/typec/ucsi/ucsi.h @@ -16,6 +16,7 @@ struct ucsi; struct ucsi_altmode; +struct ucsi_connector; struct dentry; /* UCSI offsets (Bytes) */ @@ -59,6 +60,7 @@ struct dentry; * @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 Thu Apr 11 04:49:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 788008 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 06A5813C676 for ; Thu, 11 Apr 2024 04:50:02 +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=1712811006; cv=none; b=SQCI67Ba70COrolr0OaDw7MlqZn1CVZie27YAeZAvlnk6wkjW2E2MnVs8W492yPu9U8g0DTQleEznGSSUQve0XOpmFdhYSoXiEP/bsxw+01AE2g7sX7NH8JhVwHTPiyDROY06DU8xbywQU2RpgctskXJUWol+OZ0ntHaSnxAbiw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712811006; c=relaxed/simple; bh=qh1N6xxXbxoyVeqUNnk7R8GnYu19bjjRQ9vc+mtv88M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fWg7uLcT26WQz8Yo2Dob1OgvyS3JC0dlx0PJdpqjZyMMqq7dS9fXQRHZSGRgRYOHlTC0U1wgR2Z+IakOWB4uTLEpuZnra3Gs0UZbo9SVqsOgRRS/J+5kF82AtD8LFISJHifQProiMd28I5frqbhzuA9kkNKmkeHn79bwWOgkQE0= 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=xmxb8fS6; 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="xmxb8fS6" Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-516d6e23253so6261477e87.1 for ; Wed, 10 Apr 2024 21:50:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712811001; x=1713415801; 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=7DAgGIo5zGQJrhgWPTd7vjLm3kyMY5b0dhTHS4JYFN8=; b=xmxb8fS65/s4BOeZ6TQsiMY6MGRCmOEenJIn4yHBQzIHT7YrYReIr5+w1S4f/coXH8 5iBZ3Kw+4iNa909rEqPxqMH7GwD4JHPxzaCiVn8NXhVwkiMrp7/dJXbOK2YdSny4l7e+ zJGLch1gAD+g1TOdcdmvU0OZMmmBwMWg2W9kSsP3+HBPD8nKI7mt/9z5mlq5lv4XqHGd X8lVB3kYBhDNgcnwoEQfR03hkPwSJNZls9HQ//dBe7XP2f0Qccc+Fe3ZEJWoWXYKxTwf cxK5zWMPSZQeevTuqA9zTZA2plTCP7DFyoDT51GilPvN0uUHLOnwA95sLqj4rWhPeidK nT/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712811001; x=1713415801; 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=7DAgGIo5zGQJrhgWPTd7vjLm3kyMY5b0dhTHS4JYFN8=; b=jMGuHBHZnAClaPoR0Int8VT9fc6WpxnKaCBEVoRkiHmX4PIuIifLJRGD1SkQueQSId dNCVJ2L7yRuisaptvCRpkPljm7tFzm7pE0yEy4PqDdORffkkA7Tob9F/hY6GjPzgBIGn o1kWaKtnV1XBC16oWOSjc0X+pmSDP+7TEmuRAIcVD+HNePLleVD5N3Hx1+rj7i0I2AKu ttrw3LBAsbdXn8jHp57+wDjEPrwWXlF43YjOFs3kZP2dL53LjNkDaBQ43icSlwZc64Hh KtEFQ+Jr/sSpzFrlibsKKxKuYmJj+/dy+13qgusZpUj1REf2lrBrB5X0Gk8YRHjl+x4g drkA== X-Forwarded-Encrypted: i=1; AJvYcCXIbPQXx2K3iapmD9HXYnKQT3pnqVmllb2AAUaMUnBmW05nmEuZBk4g5eC5Y2ptB1LWBdbKaRrsC47jkiVD4u17wvMGwcAP0b0QQDHDeg== X-Gm-Message-State: AOJu0YzeEhvdpieo7+LkDH3dFBHcjtBsAKZsIQaK2j0i0uZcwhUP9lPN T9kbCT+pb5Bt5E/JmBPO5M+/kEB0y8GGNkks2qcqgOVdWuQK+iT2wcHJ1OvUshQ= X-Google-Smtp-Source: AGHT+IHpxgoE6ryp41Qq6i2wozrgrTFsBC6bA+PKRXj/vk1+J47DXHlckvZHjw+/8nR1hnh2N3E0aw== X-Received: by 2002:ac2:4645:0:b0:516:d8ca:40a9 with SMTP id s5-20020ac24645000000b00516d8ca40a9mr3477934lfo.62.1712811001090; Wed, 10 Apr 2024 21:50:01 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id dm11-20020a170907948b00b00a51eed4f0d7sm364899ejc.130.2024.04.10.21.50.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 21:50:00 -0700 (PDT) From: Dmitry Baryshkov Date: Thu, 11 Apr 2024 07:49:54 +0300 Subject: [PATCH v2 2/5] usb: typec: ucsi: glink: move GPIO reading into connector_status callback Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240411-ucsi-orient-aware-v2-2-d4b1cb22a33f@linaro.org> References: <20240411-ucsi-orient-aware-v2-0-d4b1cb22a33f@linaro.org> In-Reply-To: <20240411-ucsi-orient-aware-v2-0-d4b1cb22a33f@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 , Krishna Kurapati X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3245; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=qh1N6xxXbxoyVeqUNnk7R8GnYu19bjjRQ9vc+mtv88M=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBmF2v1iUg9yoEuR3Se6lcpQLtve2t8p7w/ulopP OKjCNyy6N+JATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZhdr9QAKCRCLPIo+Aiko 1XeYB/0QAqEbcE+8+WLZOds7OkmX13QLXz2T3UpuLdHesZHk3IGjSlDGaTBjKXXz4ABc+CfM4lc khJK0mkFRQqsaBcLH42zGOKLBg1APPZuTOwPZmYPY9KlofcDQZ7/r4hUSdeL0CgqYTA0CUWKcAk EZcDN05hb85LsK6ESba3lUrondR/QYjLDOeFkRE0svNmmzBg6HxK7yK99Elsg2vgf6AhUM1k5x2 dysr7mM6kkPURDYMo5CVF2meyo/FvpnxqwBG2KREfSeulcGATneIhQb7ht22dpPJoScNaKgObPf 7H44dBzNUl1NOpeccZL+G8OG6t0AuxvksM31s/bvuxd5NEpy 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(). Tested-by: Krishna Kurapati Signed-off-by: Dmitry Baryshkov Reviewed-by: Heikki Krogerus --- 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 Thu Apr 11 04:49:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 788372 Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.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 C0F4213C693 for ; Thu, 11 Apr 2024 04:50:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712811005; cv=none; b=OAq2JYtTLSkA6ug2L+nlYNic6ARAVNIoFxwIW5CcaPhMN0r3yGEVLU71PXQF007RmzqVy7GrNmmX2GTcCHg9bQpQIoFX9kRFRkym4E0HCLe5HXQlyTYrLFZYQTXTIJCDrlsUJDcd8OP7RFPeOcJBDh3qDhsjQ5u5QqeHOJg6RVc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712811005; c=relaxed/simple; bh=6Pp8ISuDZAtUkxCFA5Mzr7Pj0egqS4eDsl4x+9fdzEg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mGAOPczV6tEaef1YV1yI3QaaO5eET82m4GVy98xden2ls/piM6OZ4p+jvYTDRPupe9q9F3N0mSTCE8y4LSXC/VJUHwWv8sLvXCaVSeOXlgoV3dfDDS84qoXO2md7oHpD4giRBxhrh9bT0AcntIABFB9e0SbUBArUBXX1YIji98A= 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=TtjeLiaQ; arc=none smtp.client-ip=209.85.218.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="TtjeLiaQ" Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a51ddc783e3so481890166b.0 for ; Wed, 10 Apr 2024 21:50:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712811002; x=1713415802; 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=TtjeLiaQATmsaTfMHDw4ldavl861eNdXhfYXLpaYbaKF5thP0oioA83R+XTuXCctZv m4DXecX4S1Nvz1p6WL+8IR1lE88wdlh99ln+eOC4UQMA6YybSPIJsCzxw/P12zUIwHFN R6/ItPPzK++t78O8sHFinW4cuVy1bVehwuEaJqYUgf1+PvQPq+j7eRIs+r3ErPuYz8e2 PIZM51FlfCCxqIMM1Pnjy4kbhoalDnVua4X3ge48srPI8uDsheJAw/hpp0c33fnG1UZ+ jTlfYXwpYVk4yUaQiRDFAOX6BTaAToXCjZiRUGiN+mrJc6qPVbmR3IzT3G+3QzNvgSsu hhhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712811002; x=1713415802; 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=ZNab/ftk885dzzKt/V6TBVQZSDmIQSsuxZHGM6YXLXaEY0Vruw2Gs5qyPO+LoJvpbY qBvJ5qO3MZZPTSqHsIfpvW4VFBxkB88zbjy1dP7bzWZpKIJkHy0KZKfOYW0p6urc8qXu pZ5aq6DJ4tgoaul+ibAVBBCDXuhQllpARjPj+237c16/Qb9IOnZgbc2nVXZdj3t+6IYR NCgyq9KYOS+v1fGJdjZfM9vxCTt3ZTAtaU2V9matp7UNIrEOeePgw+aVAYIVhfmDwBAZ TbZmlDOW8WOMMhTPYASp+4hiigoErHLxsZjuj9aLHa/AhTx0TE4giQcBODqxpnz0w0S3 xKtQ== X-Forwarded-Encrypted: i=1; AJvYcCU2/XndL3AD6PsSqPXTp0qIpgjxkQHn7sPV/podiTzw8AkqLnnaoFUeD6sYH/KL6C2lG4dlCnUPg+/DApeF5hTIm0hYGSxpttI1ZNPx8A== X-Gm-Message-State: AOJu0Yw/94v6kiUQkrapYkaiNUKU3yxfVCv/66MWB4OcmHSlErkacnso BNsbCI8WkT5+IM18rKo+MuTmhErLfBusbEki3CNonKYqKkCzQYPYlovgQUJDl6Q= X-Google-Smtp-Source: AGHT+IHesucWaQVhU+ySwSaf9UH4m6ngiyzben7VuTh4ldeFSL9wrCB7OsRC2EdaRpeJrGQN92yaNQ== X-Received: by 2002:a17:907:9302:b0:a52:1466:4d1b with SMTP id bu2-20020a170907930200b00a5214664d1bmr2587568ejc.17.1712811002170; Wed, 10 Apr 2024 21:50:02 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id dm11-20020a170907948b00b00a51eed4f0d7sm364899ejc.130.2024.04.10.21.50.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 21:50:01 -0700 (PDT) From: Dmitry Baryshkov Date: Thu, 11 Apr 2024 07:49:55 +0300 Subject: [PATCH v2 3/5] usb: typec: ucsi: glink: use typec_set_orientation Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240411-ucsi-orient-aware-v2-3-d4b1cb22a33f@linaro.org> References: <20240411-ucsi-orient-aware-v2-0-d4b1cb22a33f@linaro.org> In-Reply-To: <20240411-ucsi-orient-aware-v2-0-d4b1cb22a33f@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/pANAwAKAYs8ij4CKSjVAcsmYgBmF2v1Ts5oco0Vxtg+IMFkLrQdp5RJEX0U75Sjv QG9Ip4gsiSJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZhdr9QAKCRCLPIo+Aiko 1d2AB/wKkOfWM1fPn1jyD71SiAMg6J1MtmKyjRvYnw9RRB1S83ELd5MRGIDu8b4I6RvSozMhXoB vIovM4TO/DsApVnKUfyJJwIerHrNW5QuLQyLlqrPpZZr24anhuvIZBNATW3/6nUqPAEVtw/7X5m MAsfM/KGHaZeSgT4Eyv/P1vntZKjbbUCOgLZdYi13rMTDrS3EXaNgDnq1dia1D8322yQY00Gp0R 7z7J7MqHFrm5CIyd3/yxoQe/63vssYVCQWgQJxUdO+4SDqonx3PQKINDGyumrbW6SfqnSgrNGWf 1CNgakyWYKaOS2eDyIALb52/5kBSjfNbJD1mNYA1+FOUiVy4 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 Reviewed-by: Heikki Krogerus --- 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 Thu Apr 11 04:49:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 788371 Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) (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 C48F513C818 for ; Thu, 11 Apr 2024 04:50:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712811006; cv=none; b=HZ9zvHz9eH4RPVjKkwr/8HKt3heT3hht1YrtQaLqMxpXhWlxoM0Snsid+V97HAMSisTFF5zXo5NSg7KWK6bHEepgH+cMH89LQNLS5McwtmHJtg/IMAgpQ0pGFhZWofcecNzfF/tZE92u2oIW11XfafetlvAmGCqMeeqVN67caAs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712811006; c=relaxed/simple; bh=u4jDQO/0VgtW95lOQWBbsTeV5DQ/5FtzVIksyRFfWk8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OPxaPe1FmbtqcVsXvsC+7ApDRRkpjin44RVEq3GYX14NTJXxToQPJZdGsz7KiGrTUWmUTidrTDs019Jd3xWBcnGZhmhEnkFKI3tcjXakZsj0g6EpmnXH7OD5T7Pbm98vyeqlyakjMCDnZKaDIi5poVeHfo7D0ttgsXVFGYnJBWA= 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=yqRJLHdQ; arc=none smtp.client-ip=209.85.208.45 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="yqRJLHdQ" Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-55a179f5fa1so8280460a12.0 for ; Wed, 10 Apr 2024 21:50:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712811003; x=1713415803; 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=nbmZnNz7wfcYRQ4tunBdMeZpxGP9080ZCBcMGoX6drU=; b=yqRJLHdQzjU00g6ZMoOfvBwOfHbG5DqdhIbQC+QUhcV0hUZVQfNyDNXs0FXwfDLSLg dnKh/jGE+A3Igh84/un+m0L9yXb2Xx1YztVyZMcBLMKf77xP7NZ7nlD4kEvOzqVpSdYg yjq8CD4YR6Xv85hxXwYsHmR/zk/rghsCjOrt61y9PQZ5tPmuhybFAgBWJEeRFkzteJpF 4xM+ZHHWn5BT6U3JaTwwK7ZiS8El7ZrYBP3bRpJ1hm8puEDv9OA5SY57iDAwGBs28svl p9dXEPz7cfYch3WejEZitPcR1hIaHilui87Zvs1+fNv73QL2+7BDO8SeZS4J31ETYN4g 4TvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712811003; x=1713415803; 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=nbmZnNz7wfcYRQ4tunBdMeZpxGP9080ZCBcMGoX6drU=; b=D3yTIHb3SwAKX4e9chLRJOpY8ZSgLL2rcrKvIMtS6311sqcBHi5miXNYJU7tulU/Bn HF1NiUL7EL3MfmLePAeufMhvgz+mgzsH2baEWM7CqYoNjcZU/u4gUOEPz2XAoLYoKSyq qjayrwdSROKqcwMPg7oBq0S8GUhNVfOxlDkynMdHk0dIebfF1sJVKtCfGqdeKYeNaoZz 9LEkMrwJSJQy8o2Iajwvsh6xis3WLQtvv7OblW6ct1luOOp3/BHasPhhipUBS2bUo1y2 i0n20Z16PMnJPFp3cFtWR0iZ8hmH3RXiCbx4E8iog4y5Pv8Swnij8ufK/2NKiyi5j9l/ jQ2w== X-Forwarded-Encrypted: i=1; AJvYcCWI4YyV9ETz1xUIkEeWz3msuvro5gtb4bM2IXbbw1KFPIZ7gpLfyjWYWEXgQsSrxQ18Bmy0uAIwfCjB2EGrOCu4rchbsJ+ynzy8JCtFAw== X-Gm-Message-State: AOJu0YzLF6MGLhqIZE5Y11B7P36rkFSwGt4GFKo5k11Am5Q06hKogsUS kX1cKrHwa17M8+Wi2o0AqN2H6cxymtwRik8YjCMB2sI/hNEkFFagOLhSzGcIO/Q= X-Google-Smtp-Source: AGHT+IGwim/1leSiJmZtZ8mYj3dH/Ok7T2kMgKqWGmEz9ndiADGBSUnqAi2n7SIJ8+QbqZ+s2RtLxg== X-Received: by 2002:a17:907:7e84:b0:a4e:24af:d8a4 with SMTP id qb4-20020a1709077e8400b00a4e24afd8a4mr2043984ejc.28.1712811003083; Wed, 10 Apr 2024 21:50:03 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id dm11-20020a170907948b00b00a51eed4f0d7sm364899ejc.130.2024.04.10.21.50.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 21:50:02 -0700 (PDT) From: Dmitry Baryshkov Date: Thu, 11 Apr 2024 07:49:56 +0300 Subject: [PATCH v2 4/5] usb: typec: ucsi: add update_connector callback Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240411-ucsi-orient-aware-v2-4-d4b1cb22a33f@linaro.org> References: <20240411-ucsi-orient-aware-v2-0-d4b1cb22a33f@linaro.org> In-Reply-To: <20240411-ucsi-orient-aware-v2-0-d4b1cb22a33f@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=1847; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=u4jDQO/0VgtW95lOQWBbsTeV5DQ/5FtzVIksyRFfWk8=; b=owGbwMvMwMXYbdNlx6SpcZXxtFoSQ5p49tepFmkxUwtOv5uxnVvo6Yxt3zL3TVyzb2qq3qPsH Bsp3q3hnYzGLAyMXAyyYoosPgUtU2M2JYd92DG1HmYQKxPIFAYuTgGYyK8f7H/FGLbFvJY8E/hg 7xr23IPJyvFetqlJD7VzM/sYJrCqsD6zlOkWrfkjnOiT7beaf/V6zTfuzH17vzy2+fdD4gar3lo LrfxzC9M2tK5l9lkrIutUws2880RswBNNNZ/dbDpNIR9e7nq4dtHMWXFGOYVqgUmsRrXxSVdqNS JE02rWJM3obKn9fPHNbD1OSwEF+2gzqePlpjmFux7POue3WqvG7ZaY226G9leT+KMZhIwjQ/TeP MyJ+3dcZ8utUgO9H3FWvzO4r/b/sjv73pUpY2J60WrvvjWeC8X32s3dn/U26ZXdu16LZ5X3l+op WNtLSEnME3oYVi0/7T5LbMzswzZF56v7zVqO7MzKTAwHAA== X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A Add a callback to allow glue drivers to update the connector before registering corresponding power supply and Type-C port. In particular this is useful if glue drivers want to touch the connector's Type-C capabilities structure. Signed-off-by: Dmitry Baryshkov Reviewed-by: Heikki Krogerus --- drivers/usb/typec/ucsi/ucsi.c | 3 +++ drivers/usb/typec/ucsi/ucsi.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c index 7ad544c968e4..57e73b823a4c 100644 --- a/drivers/usb/typec/ucsi/ucsi.c +++ b/drivers/usb/typec/ucsi/ucsi.c @@ -1559,6 +1559,9 @@ static int ucsi_register_port(struct ucsi *ucsi, struct ucsi_connector *con) cap->driver_data = con; cap->ops = &ucsi_ops; + if (ucsi->ops->update_connector) + ucsi->ops->update_connector(con); + ret = ucsi_register_port_psy(con); if (ret) goto out; diff --git a/drivers/usb/typec/ucsi/ucsi.h b/drivers/usb/typec/ucsi/ucsi.h index 3e1241e38f3c..c4d103db9d0f 100644 --- a/drivers/usb/typec/ucsi/ucsi.h +++ b/drivers/usb/typec/ucsi/ucsi.h @@ -60,6 +60,7 @@ struct dentry; * @sync_write: Blocking write operation * @async_write: Non-blocking write operation * @update_altmodes: Squashes duplicate DP altmodes + * @update_connector: Update connector capabilities before registering * @connector_status: Updates connector status, called holding connector lock * * Read and write routines for UCSI interface. @sync_write must wait for the @@ -75,6 +76,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 (*update_connector)(struct ucsi_connector *con); void (*connector_status)(struct ucsi_connector *con); }; From patchwork Thu Apr 11 04:49:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 788007 Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (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 9CB3113C8E0 for ; Thu, 11 Apr 2024 04:50:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712811007; cv=none; b=iJNq0LmCMy4AQD1WElD38HHI6GTMnXle2QKolnn5SYU0cjnvcuFe8efygNcxJwN1fs+1CHQJP6sox4oOzQD/9+vww28pC7s+UIbkI7VjCLwnwd7N3yi9W+x1Db/I4mL9T3Aq4u5vUknb6QCzGrqMnrgrxwRyt0AUURzUcRrbtG4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712811007; c=relaxed/simple; bh=KDEnFAKDHgm7Dl9TTJXgLNhiWKY43ebH4R6QBCie46s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=U8RH7op3tKEiLfee8WuhZtf+1k5ZOlxJ28XhY4ZuJwKNUMu2houOKuv7ALjpp52ghYy+Rsl9fqoRQSzBEvRWt0vKdIRlrQDw6E80cUh1i+pH84/PMk9G7Ed7LHDRKcKbc13nvDV/Cmae+TVB+SuAgyDBRWl5xlSlnyxyPUB6ZeQ= 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=BtpW+64o; arc=none smtp.client-ip=209.85.218.43 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="BtpW+64o" Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-a46ea03c2a5so79855566b.1 for ; Wed, 10 Apr 2024 21:50:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712811004; x=1713415804; 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=eyRSagPW9Tbd2MSaq4Y1W6L6VLAUgCS+QRdXG739ECo=; b=BtpW+64oF8VjKawF+lJayXFYR3TL5VSjB65fgDANkIb7JX2TFjvZUQnyrdX9a31jeN CNhLX6VD1+di3fWUGR5REC8fDzatcgJQigLl6q2EmCxHT7q1q3vujM6U30fe5s0mUYI7 hJQ0cNtQ/kT9JRd1h0hPW3WwpaC5gtAEBsRsmo0XwNeIUYmuuLwUWNY2POfZT+3yLBBy A0IUzUkJCqMC8b3r4+1RKkHvDIlpRjmZkqssv++JV2psT0dyxCT8KBB0zJPoGhHwuHcJ AipelS4KEG+wsU/1rHuCB5bRJjYZV2fFuBTBVaMD2xv6i6l3OWeo9UwP+nobFqvKoa4F BVLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712811004; x=1713415804; 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=eyRSagPW9Tbd2MSaq4Y1W6L6VLAUgCS+QRdXG739ECo=; b=AfmOqLwV+wWCvj6BNMXtLGgXg1ddx5QV4IINKXC5/1c/YlQ9DS0eWHE8ghbi/5y8fk YRHIS2rUJgCb08jTD5iWJjc32saW2oLU47TC9T0wJFMi4MEI9O7TQkQ4zrdELN2F57Mk oHuONH4zRkUmwCCOu/jVDKS9fBy/Nw3pU4ucDQJnlJQFttCCw8Ncr5HL8IQiQAQXZQqq /moaM2kRq75MRuFTCI4Jw7W++asMpPXx5iyVdQ+0Q/WWp9l93YnL0DCwxvROPoc3SHyG ZOVEyd2/vHJzteGAZfNFYqw7bQrJoHxEV3MJBxpTEb7KGWgJAGyZNorXGXZwdBHo3WLF amEw== X-Forwarded-Encrypted: i=1; AJvYcCWq0M6QmovT5IgSJSwF30U5ffkWniksksfW7C14A209K63YTUvTY3zgUTveZE93mltluIk2WrY5LW32a7N72QaY8prE0V1RXF7OSfnE0Q== X-Gm-Message-State: AOJu0YzYkWlgL8viNjfSDmJNjfNpMpPhhy7aSA4BF1SFwvP2Sg1xXA8A aKu8XeOSajYYqc2UYi+PxEaQvM62a+gAPgeg03mwFWUSrDXEb77noEPnJXXv8n8= X-Google-Smtp-Source: AGHT+IGjx37we05P9i4gCPI0RoWu9lvWlM5KED6DWJGabckpTB99Kjph/n10TCysW/TlIG+QVL60xQ== X-Received: by 2002:a17:906:6a20:b0:a52:b65:e978 with SMTP id qw32-20020a1709066a2000b00a520b65e978mr1516000ejc.5.1712811004067; Wed, 10 Apr 2024 21:50:04 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id dm11-20020a170907948b00b00a51eed4f0d7sm364899ejc.130.2024.04.10.21.50.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 21:50:03 -0700 (PDT) From: Dmitry Baryshkov Date: Thu, 11 Apr 2024 07:49:57 +0300 Subject: [PATCH v2 5/5] usb: typec: ucsi: glink: set orientation aware if supported Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240411-ucsi-orient-aware-v2-5-d4b1cb22a33f@linaro.org> References: <20240411-ucsi-orient-aware-v2-0-d4b1cb22a33f@linaro.org> In-Reply-To: <20240411-ucsi-orient-aware-v2-0-d4b1cb22a33f@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=1460; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=KDEnFAKDHgm7Dl9TTJXgLNhiWKY43ebH4R6QBCie46s=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBmF2v13bz1z7B8Jpthr7MhOLJh6qa1f2AHk+B7O uDA14GA1bGJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZhdr9QAKCRCLPIo+Aiko 1WzUB/9eFq/D/Yoke7i3WLWxjylyhnOq/qtFUaqzTUUTJCnpYzRcHXAfQpyneQm18QzYrHJdUad nFaeMLvwSIhy/+6E352BRPjXzQM5corVZ7+56o0LRbP5S/C5C1TymShRiN3Ou+ur58o41gmbDy1 UpGobTl1HQBUPZ3srYjmmxvRE+tYKs5smwIxtVjbYzzdefnMBYZY7S628ufdOhIKV+CsLqrQy7l RttUR9Ifj9nFknaN+h5l9sn7dQlH+v8zf8eaO1LAHqSYdcA1yCz+Wn4KsvHn/0ddArxPMDQSQfp rUZcDML/FWHqbTeKhGO5TsENVNP4bCnm8uHwUOI/C2kjjXmr 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 Reviewed-by: Heikki Krogerus --- drivers/usb/typec/ucsi/ucsi_glink.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/usb/typec/ucsi/ucsi_glink.c b/drivers/usb/typec/ucsi/ucsi_glink.c index d279e2cf9bba..f7546bb488c3 100644 --- a/drivers/usb/typec/ucsi/ucsi_glink.c +++ b/drivers/usb/typec/ucsi/ucsi_glink.c @@ -186,6 +186,17 @@ static int pmic_glink_ucsi_sync_write(struct ucsi *__ucsi, unsigned int offset, return ret; } +static void pmic_glink_ucsi_update_connector(struct ucsi_connector *con) +{ + struct pmic_glink_ucsi *ucsi = ucsi_get_drvdata(con->ucsi); + int i; + + for (i = 0; i < PMIC_GLINK_MAX_PORTS; i++) { + if (ucsi->port_orientation[i]) + con->typec_cap.orientation_aware = true; + } +} + static void pmic_glink_ucsi_connector_status(struct ucsi_connector *con) { struct pmic_glink_ucsi *ucsi = ucsi_get_drvdata(con->ucsi); @@ -208,6 +219,7 @@ 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, + .update_connector = pmic_glink_ucsi_update_connector, .connector_status = pmic_glink_ucsi_connector_status, };