From patchwork Thu Jun 6 13:11:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 13688462 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 76B19195F09 for ; Thu, 6 Jun 2024 13:11:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717679481; cv=none; b=RQLivEYFFwZIzaFXUnXlAos0+yvexw0CMPbBkW1NtYKobj1jzKg5eQkkOwvfW7xEfThkPZWtWfwVPAUuAWG+t/O7bVliVJkjLocKgY0RWBuB/YfycDCL5Nc1ZwYJIcq2x3SfpPOYDLmssZdDV98KhRAxDQouMa95EMbP/EvtmcQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717679481; c=relaxed/simple; bh=1iQB0TnxGPQD48SI52BVb8MYGJwHVX92ZuTXrjnYUgk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=frS6Ioy4khgVDzuyvXMQccFrLXZerddX57Cr4OMRpCG7l3Px9t0w0sKgVddx9ZpynT0j/I+MWJ4BQPQj6FFuclMOJyO3AlwBmyXuhFqtj1pejxKWE6m3hDgkOwYaAZSk+7NhFqOY/Vqz8xsa4dkNrj1k5PGa7uBS+0EeQsPIi0Q= 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=tpaTYL4M; arc=none smtp.client-ip=209.85.128.51 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="tpaTYL4M" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4215b0bffe1so5500415e9.0 for ; Thu, 06 Jun 2024 06:11:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717679478; x=1718284278; 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=kDW0b/YSgv4QXyctzYjGDcstuFPG7XMfwYDc0c3f2cg=; b=tpaTYL4MjR6NGA28zBVjSboSgwRHsHuuo34OuegLpJL7l1KTU5Attxjevp7jb+vlDi SUsRtd0k7ecdM0/dwQw9vB8NFnWHBXxx0jdr9MZs2z4XuR8rSqQdjYQmDo+AGD578UTx q+5WIUjxV+wELKheHWCBosaUdN8KqVyqP52NnYq7NbME+tMpiQmKJ8V16qL22FOa06Fx 0h843QD6BHogtFdzwNhRoxWgUbHgStH9lcvp1fOHtsgZp7Y9Ho6ZjCCv5IRMCYoum9iq yvGQwq9JVl6PaKPZXKcGWlKT1Pt7EFDzuPaqFuecwoSnLYO/bC+M68JIfsdluO5MnRcT gmAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717679478; x=1718284278; 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=kDW0b/YSgv4QXyctzYjGDcstuFPG7XMfwYDc0c3f2cg=; b=jO521yYMr6AO4uhNcAgWQHqnKHr6sgxeSDJYuyUfKVOXMP78fkZzJsPo9lKI9cBKlX J5FlyrGPTtWp4CniMwHZTOomP2/m4Qv1nud/ft2wfadAqoMytZlnr9KTAt+p/JyB5+e9 tJhmcY/D+QntxC9oKcUESCD52QCXFk21VHB5+Gkr5N4/qggw9SqBIllianqwhuqNs3Rf l5IoO2WwTgswrqfFit6pChOznUCoUzg203LqRUYXjd4LOPP7Ejya26zXoE/z6K68zHM8 7xxRfwDbpzetCorr7GDhBddymbH1hFK3VjUEegSLmCfoKCCbh2+gbRwKSYnGZMiRYOJu y+Mw== X-Forwarded-Encrypted: i=1; AJvYcCVIAUeU9EjOI0nFjvvCiFkInvoPhbHBI3mTQ1OkyC/47ZdwC9IbAIAQ+/0T1QnZa0QIQPogaEM3Do9J5zBW1FYj5y0qjsxzXta/dEOOPA== X-Gm-Message-State: AOJu0YwRAASGh5wNufnjkJidh6taJr4RhIA5Xe/o1E1lPYSHdfUWFeLl UBViS4hXTQ7bAOkuYDxJj4ruow1Hvy2b6GiqIrJfzcyYf8cfLCnotzJPStsHLUw= X-Google-Smtp-Source: AGHT+IHntx+2Ojv0Rn0jPTUKm+w43ccdTFur7Nx5THHhZ+lsv0dWB6JDEnSc1xmfwuc21ISzS7nYzA== X-Received: by 2002:adf:e543:0:b0:35d:bdb6:4910 with SMTP id ffacd0b85a97d-35ef0da66d5mr2214928f8f.22.1717679477706; Thu, 06 Jun 2024 06:11:17 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:52eb:f6ff:feb3:451a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35ef5e96d8csm1536316f8f.68.2024.06.06.06.11.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 06:11:17 -0700 (PDT) From: Neil Armstrong Date: Thu, 06 Jun 2024 15:11:13 +0200 Subject: [PATCH v2 1/4] usb: typec-mux: ptn36502: unregister typec switch on probe error and remove Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240606-topic-sm8x50-upstream-retimer-broadcast-mode-v2-1-c6f6eae479c3@linaro.org> References: <20240606-topic-sm8x50-upstream-retimer-broadcast-mode-v2-0-c6f6eae479c3@linaro.org> In-Reply-To: <20240606-topic-sm8x50-upstream-retimer-broadcast-mode-v2-0-c6f6eae479c3@linaro.org> To: Heikki Krogerus , Greg Kroah-Hartman Cc: Bjorn Andersson , Luca Weiss , linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Neil Armstrong X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1460; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=1iQB0TnxGPQD48SI52BVb8MYGJwHVX92ZuTXrjnYUgk=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBmYbVy+BHa85tAv1ttJWzOYAVF/BPHgf0KwQiABt0e joBVqJiJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZmG1cgAKCRB33NvayMhJ0ce6D/ 4ykGsXqyzHoq1EFglS1lBaAeQ8q4ROGVHl5Yg1P5BIZXnctOWZHkNJ4oLfT1K3hhgA29uVO8vt8s34 uA8WiV+7LfZQ59pdLpwxCm74waNUGAZ6tXoUGAWCBnbMUhGgN1/4ecX0meAfZextzAZogEIhGD72O/ Jb6xAJpMMt4MeAx8yFwXamtuoAEGatNE2lRw0vFRbwBeeuVx9P29XgkQoheP4RRUNLVzBTLgMC5Vft FpskOU7X1QfsanAvi0gfbtNreq1ditQOl4p4CJtdV+YtQZXNBUfjdQfcG49bLc2N7RGap+KDebFy7n s8YNSvefeX7cQrFJ/N9C75ZfkWNipE0LzE1nmpYQeNeOxjVIr7b5nMQkaw4W7KH06WdXVUHW/fiBpK kIynjwiEP2YGyZyVbf3UFRCFEGPF2Mm1bZPojQlWGzuqeMP4uOqRHrmFR/gOysems2kVO0tRpUqEIl WbYxU6q6Hg1Hs0hA1KgPsCguB2YiSCp9pKa5CdOILGSOpDsajTViqzs9fZ9zgsRSh8QvJNpTwxFDKg xiBp6u6w5Y0vLnYbz/E+nGBvw9568MdRZ5PZkvdmo+T6V5m2OQx2C+O9ipgeC9JqpwxxGndnP+H5mt yr30IqKChY4qXEdlHdk4p2IpS6WCwgJkQnKi5iThFJGkmtVJdJstxETmee9A== X-Developer-Key: i=neil.armstrong@linaro.org; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE Add the missing call to typec_switch_put() when probe fails and the ptn36502_remove() call is called. Fixes: 8e99dc783648 ("usb: typec: add support for PTN36502 redriver") Signed-off-by: Neil Armstrong Reviewed-by: Dmitry Baryshkov Reviewed-by: Heikki Krogerus --- drivers/usb/typec/mux/ptn36502.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/usb/typec/mux/ptn36502.c b/drivers/usb/typec/mux/ptn36502.c index 0ec86ef32a87..88136a6d6f31 100644 --- a/drivers/usb/typec/mux/ptn36502.c +++ b/drivers/usb/typec/mux/ptn36502.c @@ -322,8 +322,10 @@ static int ptn36502_probe(struct i2c_client *client) "Failed to acquire orientation-switch\n"); ret = regulator_enable(ptn->vdd18_supply); - if (ret) - return dev_err_probe(dev, ret, "Failed to enable vdd18\n"); + if (ret) { + ret = dev_err_probe(dev, ret, "Failed to enable vdd18\n"); + goto err_switch_put; + } ret = ptn36502_detect(ptn); if (ret) @@ -363,6 +365,9 @@ static int ptn36502_probe(struct i2c_client *client) err_disable_regulator: regulator_disable(ptn->vdd18_supply); +err_switch_put: + typec_switch_put(ptn->typec_switch); + return ret; } @@ -374,6 +379,8 @@ static void ptn36502_remove(struct i2c_client *client) typec_switch_unregister(ptn->sw); regulator_disable(ptn->vdd18_supply); + + typec_switch_put(ptn->typec_switch); } static const struct i2c_device_id ptn36502_table[] = { From patchwork Thu Jun 6 13:11:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 13688463 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.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 5188C195F19 for ; Thu, 6 Jun 2024 13:11:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717679482; cv=none; b=CggM//m3FjBQbF2HoyW1935/9HfTIChRUMW6yxbD8+Mp5QU4n/SnLdvUCqWXa3qU1zAIZEBQcRml1k1Sqox4ho5BX/A0L+Z9INqMiyYKe5DdAE9OXoA8qhc1io9/CK+Q/X6scBaP00c7Uak6ht011oytFgGOLWD/8+YAsEtQhOI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717679482; c=relaxed/simple; bh=tcdhakkg0NX4qYXx1dNiTJsUi801Kl1wRMPLSMJoGWw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=coLurC94yUOIC7f7CH5H41mUH1tqtTF9x1v22v9HKXiWxHLdoSXp7AIJuPKplpXc8GwuuPGy5nKKwbdUrvFey7/xO7sZe3Kw+LJ7w688JupiOXctFo5Zoh3bNYeS9Wvd+5kafdmCHraRF78YXE2NvP2gTmrO308fY3tqrZFGoHw= 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=G7GHoHE+; arc=none smtp.client-ip=209.85.128.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="G7GHoHE+" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4212b4eea2eso9704415e9.2 for ; Thu, 06 Jun 2024 06:11:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717679478; x=1718284278; 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=GaajZ883EdN6Sp1qsHSz8AVaEsngk8mZSxxcU3V4u6U=; b=G7GHoHE++3MpYMVKxb6eyI2nQcQKqb4WRtpvYutGbdzGt8WYrpNaySrV2+u/XytZCO VEwNGeSMoavn/5X4rOHtoa/1GFY9vRakeJLAU9BezfhRQdpsSPnLMqO0dLkJfDbnkumJ /WZKkekr9nIXW3gzQCz5CozMr4ryQC5BWJ406tsmm78bM5Vscz8LGQ8JxbK2Kp7RHOu2 GUw1YxzrmCpqV79oIhRH2UYMIRqqMfrZMHPEC61a4c7tPhpBjmbTTZAL3rtsl0PDp21M GW91jyu1WeWI3kmMS+RZsvLVdgqJIRACE2cIlczbAYuJwIJUj+n8sMpz5WFamzmtJjIf D4ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717679478; x=1718284278; 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=GaajZ883EdN6Sp1qsHSz8AVaEsngk8mZSxxcU3V4u6U=; b=dxDm/sxciGyYtLtiR5Se6ffxtZLKi3dNRU0HM06tisLBgJmaACzjChqvnZJyKmmcb/ GRHvBHMgbFp9CseJe+CQvfWimOnxhOMKtvkOVCgTC9qvglzw0Gw8Ak/DjIUQLCU+2S6b NK97Q0eNlUYEMBoHIvlQzt7hROMIFfDwj8AD2m2/lBwAivS2liJfvpzG5GTrIGOToKGz PVtRCI/T47AogiagyFmjX0U6mwxaoDWCVmgDlqsOTSUEw1qhtyZT9C86o5sdgN6XX6zD IGQXLUBFEaygaFYQVhRVYwk8qSoaaaoF/G+1L8ZpV4XdiwVH9beQkmQcb6poaP22uz1t Fc0g== X-Forwarded-Encrypted: i=1; AJvYcCU1xC0L73+sA70GpEX9YF9yO9A+Ik54IdqFAk0vSYfIPq2+sP5jqUzIwzS0wq3AeJS4Cg8Ibmiu2bpHmC8Q5vd/cMHhCo+BuXkLT8p9wQ== X-Gm-Message-State: AOJu0Yz5E9gug7ZDwwtk+EF/cOCgQqN3DqgMDlWnogriLpY8WDXSPgHC kK34J3CjcvIo0GiKbXJzHA3BNjUNfHQ634NObgq+GkTTPEdmlMwxenS0ecH5j1M= X-Google-Smtp-Source: AGHT+IGMPYBLZ9Wo50vmXxzKX91v23RBp7dbXilVXIlrsWjw61Se+3s/X+8R0dG+Q1zNGrY8PntKkQ== X-Received: by 2002:a5d:47a8:0:b0:35b:5ffd:9ad with SMTP id ffacd0b85a97d-35e8ef09964mr5020504f8f.41.1717679478518; Thu, 06 Jun 2024 06:11:18 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:52eb:f6ff:feb3:451a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35ef5e96d8csm1536316f8f.68.2024.06.06.06.11.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 06:11:18 -0700 (PDT) From: Neil Armstrong Date: Thu, 06 Jun 2024 15:11:14 +0200 Subject: [PATCH v2 2/4] usb: typec-mux: nb7vpq904m: unregister typec switch on probe error and remove Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240606-topic-sm8x50-upstream-retimer-broadcast-mode-v2-2-c6f6eae479c3@linaro.org> References: <20240606-topic-sm8x50-upstream-retimer-broadcast-mode-v2-0-c6f6eae479c3@linaro.org> In-Reply-To: <20240606-topic-sm8x50-upstream-retimer-broadcast-mode-v2-0-c6f6eae479c3@linaro.org> To: Heikki Krogerus , Greg Kroah-Hartman Cc: Bjorn Andersson , Luca Weiss , linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Neil Armstrong X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1350; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=tcdhakkg0NX4qYXx1dNiTJsUi801Kl1wRMPLSMJoGWw=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBmYbVyeiLv+WTK1IY9m4XWaI7kppF3M8JMgUcMa6b3 QtzUQT+JAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZmG1cgAKCRB33NvayMhJ0WcYD/ 4sSsizPLW2EUtIlkiqcXMuWhLCU20OJYh6YSMCqZItrNCryIETZsPwyH1QUu/W6Y3+x1MHbOKef1CF Md6s0jPf0wu3c/tc2kTQiKZlaW220WAddM3jIsCcTwL+K7wUI27NINHDNK4E9yb4PDwFyo4cyssmx1 Z0v8xtzaSscXV+6rH+G9T5TA7LMpvaQr/3QZP4hWpRhpKQCSSXWPPe2QqW3CwSV573gu4qmfgEQyWS LZJc7qmATZnrtffdMLezlfk5qD2jPUQSjw0knkw7yL+8m0yAiGmlf+E5TYW0Ql2WNbR4NYInzE4c9d /jeChGx7U+hNUCGHIA6hZymIXWCFRAIhOK/uW3Q5fLSSJESTHqVMYKfGzWcpn02e9wRnVHFJgrZ8yW gr/KS0SAtszf+CRV2re/hcQV2bdXAAzM1VP2nNaOxTEFNb/OrVbHw0JGS/kHPTPo8RDmI3RsxJ5nvQ h62YBa78liCilCxpiwzNCYNus4W926NwGJtOoUgQLFHetJoSMSqS44ALifSzT88NeYiiQhZveWH4SG s0LtqCkJg2COaeUc2pIfrNbo61PR89igmsv44pD8FZwSC9OY9inmvHh+dXSdwqK8E/Y+e0WVCp9Em1 qkN3BSqXMupgsseHozHKOFF0/gj+f07nJQoViP6tf41Eq+244q73k/B9vTFw== X-Developer-Key: i=neil.armstrong@linaro.org; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE Add the missing call to typec_switch_put() when probe fails and the nb7vpq904m_remove() call is called. Fixes: 348359e7c232 ("usb: typec: nb7vpq904m: Add an error handling path in nb7vpq904m_probe()") Signed-off-by: Neil Armstrong Reviewed-by: Dmitry Baryshkov Reviewed-by: Heikki Krogerus --- drivers/usb/typec/mux/nb7vpq904m.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/mux/nb7vpq904m.c b/drivers/usb/typec/mux/nb7vpq904m.c index ed93194b16cf..569f1162ee2e 100644 --- a/drivers/usb/typec/mux/nb7vpq904m.c +++ b/drivers/usb/typec/mux/nb7vpq904m.c @@ -415,7 +415,7 @@ static int nb7vpq904m_probe(struct i2c_client *client) ret = nb7vpq904m_parse_data_lanes_mapping(nb7); if (ret) - return ret; + goto err_switch_put; ret = regulator_enable(nb7->vcc_supply); if (ret) @@ -458,6 +458,9 @@ static int nb7vpq904m_probe(struct i2c_client *client) gpiod_set_value(nb7->enable_gpio, 0); regulator_disable(nb7->vcc_supply); +err_switch_put: + typec_switch_put(nb7->typec_switch); + return ret; } @@ -471,6 +474,8 @@ static void nb7vpq904m_remove(struct i2c_client *client) gpiod_set_value(nb7->enable_gpio, 0); regulator_disable(nb7->vcc_supply); + + typec_switch_put(nb7->typec_switch); } static const struct i2c_device_id nb7vpq904m_table[] = { From patchwork Thu Jun 6 13:11:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 13688464 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.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 F02E7195F31 for ; Thu, 6 Jun 2024 13:11:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717679482; cv=none; b=erszZBY/12FkNIBKG3gnZptyRRlxsBpzfu52Girt41DMiUjqjYN9fyxFwzjkKy5X9ry5wb2+M/J4VwOEyrrsHGVutjtUdmWRNxs68HCEfJlfXL1Y1moNlcrtHRhBFjvpQiX1VAXwpcM10Ox/j6oCAeDgqvj+1RfNs5KSTUp2oIc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717679482; c=relaxed/simple; bh=2D81KA27BBA+iDw6acVjawnZtbTrX1ZuhLRaECsL8os=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=W5YO3G4OnsNW5Cmo/UeGXNNWm/I0NDBd3OJbN2xFrZEuUOLpfHm39YsDIJIGuKRZmdaj5HIOq4mA/Jt3sj8yjTsea0Ifq6TUHump8p/lEzdzwDTyWgoYQNCSRAF0r8gDL/foJqDC3xZs5Pq35OAPAQnsRZ+igDK5YxgRH9/ER3U= 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=Ge8HCxEn; arc=none smtp.client-ip=209.85.221.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="Ge8HCxEn" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-35dc984b3d2so676410f8f.1 for ; Thu, 06 Jun 2024 06:11:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717679479; x=1718284279; 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=qqx6Rfo2v8stZ/0E2QNEl3F7bOYaE7YQtE5TXaL/qnA=; b=Ge8HCxEnms1cVYamMIM6BViOOaRhYhP7WvkDo9YGINuLDV0qg/SqXUnKAAxIaL4IBI QvAQVTv2Ggm3pKSia7hM1nzUZphY19MX8BuBRtsweNt2rFcM6GmBu14ejDN1JkHOflDC 8LGnLSkNwNFU7ADzjOhBBfIRuEd5znF8nae0zEO7AoDQoZwuSXwgEQymH4KBGxMlidxa xdAJJIcWB8w/l5QhUkOsHAYd/4OlWxyCALgqPkmFKDzSSfIJ+WxB4P6LxCpZP7UZF5Wr EoT3+aVislHV8Myj2zVtTmZ0EwqraiCCxafQJEriRv6PKrkE+PEieH3LS354MK+H8oqB Vivw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717679479; x=1718284279; 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=qqx6Rfo2v8stZ/0E2QNEl3F7bOYaE7YQtE5TXaL/qnA=; b=HbO5+T2xpC4ML6fe7r0S7FhUs7bn/Hjw1LtF3PkuMRCZpfavqXgkL7mr3X6jEcoDDQ tXvI3qMWXTXB+YT801qrdfYqotSYXeJJAoxhi2YzL0rvuc/GUiY5/kRhQcSahg32iR6J q2RtB+edE/mHN/16xjv6AY0tQ27/2Dj6N7eaGeT+05pHiz7Lqwdhur9nRtN+P7Oe8Ewy KCxNEmy3u3AGY2GC97xwImO5jg5EHFiklxCqgMtXDpwv/PpcCpL+YdmSNb5b0v4j8acp FBUnFsWX2dzmsUl9aeM9DTO+YTwjBpjtCVJiWR8QCEj8n6mNm1oE2OnUnEBX4qDnHCKR PNyQ== X-Forwarded-Encrypted: i=1; AJvYcCVg5k+XElf7ifTHMdvzpN9c/7uhDKv09RSKxMDzAgKEdI8gbDS23B4p36GJMpGaie9vLzX52+VK3ctZzW2mEA9Mh2OYbiYK++Z+/ZcaRQ== X-Gm-Message-State: AOJu0Yw8VLB/TS5XUiTrtteo0e6pecXXELHfHV5X1WlslnQ2UrGrDzBw 0RYEZumrwuWIgaio3a7o4TxvFfpvoNNbLL4Xq6ZIJL+le+6fv3y8b6myeKt5FGM= X-Google-Smtp-Source: AGHT+IHd2hgNJGF5hGKfvQxMegty1f1HzOHtA7bmcOdXE0FSZbv/HvwdZ+1xG0BLDkfaBAccsBGokQ== X-Received: by 2002:adf:ea92:0:b0:354:fa7d:dcfe with SMTP id ffacd0b85a97d-35e8e1a4b55mr4496064f8f.23.1717679479292; Thu, 06 Jun 2024 06:11:19 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:52eb:f6ff:feb3:451a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35ef5e96d8csm1536316f8f.68.2024.06.06.06.11.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 06:11:18 -0700 (PDT) From: Neil Armstrong Date: Thu, 06 Jun 2024 15:11:15 +0200 Subject: [PATCH v2 3/4] usb: typec-mux: ptn36502: broadcast typec state to next mux Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240606-topic-sm8x50-upstream-retimer-broadcast-mode-v2-3-c6f6eae479c3@linaro.org> References: <20240606-topic-sm8x50-upstream-retimer-broadcast-mode-v2-0-c6f6eae479c3@linaro.org> In-Reply-To: <20240606-topic-sm8x50-upstream-retimer-broadcast-mode-v2-0-c6f6eae479c3@linaro.org> To: Heikki Krogerus , Greg Kroah-Hartman Cc: Bjorn Andersson , Luca Weiss , linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Neil Armstrong X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3017; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=2D81KA27BBA+iDw6acVjawnZtbTrX1ZuhLRaECsL8os=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBmYbVzv65NFKTMozB0rDfmtAPdIDX7isOTZwpHit55 1DuHdeyJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZmG1cwAKCRB33NvayMhJ0RnAD/ 4xzBKSemaIdJCYyJXJ6lqs8GS4sXVyLAZc2MwcskIDTGY2GsD5pm1OpfJjzqxw7p53lIIyQxd888l2 7e9KbzZ+09gWWT2EltiOvW2WHj5+nj5NtrWq+tEOmqAWwpCDT5oC7vnd9WASBDuxJmxOeRoccKFNdX oYKKceAvfamp1CJc5c+KQTxv+OKmldAPJKompywXqEWDsOyHu1/4Qnuj7wZbq24BSM/9JnMGj9V21e J/ToESsqcFOBKRVCb4Fjiuwgvgs20hCGnHlr8Y3Pdeo+TsUWq4ThjE3+66IY/t9VTR42MyoaUuZ+Bg RmpDCWWCYKJP8IeqoF1Xc2uQc0HCb5aukHkz5W7by+VhRl20y9Gs7tEK37uudEUHqKKeePurSeKD6p X2p9UBVke7vPo8vyi3JMQ+W96bAMIbqSSj+CuM/lTaLNkBp/raYcw/D6K3KV+6Y/GGidiSHOdIBGFm taboiRGp/i/Mjk2FB2zFnh+ZflRJ9HRdEAP95SNl2yGhMiJhXkF/YAcFxmYPBRCveujIhK4/GixGzc IshlphhkOfmZK8VTm02N9uSojqiJSWucSELun+9+p+fyyV/S3ITIgBXpfgu6E596Bt5YnxblL02wik 1rsFtC3CHWv/76emciB7qJvUdOaG69mkfyRz0kkKcaHIA64TsyTq2t6H8Vvw== X-Developer-Key: i=neil.armstrong@linaro.org; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE In the Type-C graph, the ptn36502 retimer is in between the USB-C connector and the USB3/DP combo PHY, and this PHY also requires the USB-C mode events to properly set-up the SuperSpeed Lanes functions to setup USB3-only, USB3 + DP Altmode or DP Altmode only on the 4 lanes. Update the ptn36502 retimer to get an optional type-c mux on the next endpoint, and broadcast the received mode to it. Tested-by: Luca Weiss Signed-off-by: Neil Armstrong Reviewed-by: Dmitry Baryshkov Reviewed-by: Heikki Krogerus --- Reported Tested by Luca in [1] [1] https://lore.kernel.org/all/D1HOCBW6RG72.1B2RKGKW2Q5VC@fairphone.com/ --- drivers/usb/typec/mux/ptn36502.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/usb/typec/mux/ptn36502.c b/drivers/usb/typec/mux/ptn36502.c index 88136a6d6f31..129d9d24b932 100644 --- a/drivers/usb/typec/mux/ptn36502.c +++ b/drivers/usb/typec/mux/ptn36502.c @@ -67,6 +67,7 @@ struct ptn36502 { struct typec_retimer *retimer; struct typec_switch *typec_switch; + struct typec_mux *typec_mux; struct mutex lock; /* protect non-concurrent retimer & switch */ @@ -235,6 +236,7 @@ static int ptn36502_sw_set(struct typec_switch_dev *sw, enum typec_orientation o static int ptn36502_retimer_set(struct typec_retimer *retimer, struct typec_retimer_state *state) { struct ptn36502 *ptn = typec_retimer_get_drvdata(retimer); + struct typec_mux_state mux_state; int ret = 0; mutex_lock(&ptn->lock); @@ -252,7 +254,14 @@ static int ptn36502_retimer_set(struct typec_retimer *retimer, struct typec_reti mutex_unlock(&ptn->lock); - return ret; + if (ret) + return ret; + + mux_state.alt = state->alt; + mux_state.data = state->data; + mux_state.mode = state->mode; + + return typec_mux_set(ptn->typec_mux, &mux_state); } static int ptn36502_detect(struct ptn36502 *ptn) @@ -321,10 +330,17 @@ static int ptn36502_probe(struct i2c_client *client) return dev_err_probe(dev, PTR_ERR(ptn->typec_switch), "Failed to acquire orientation-switch\n"); + ptn->typec_mux = fwnode_typec_mux_get(dev->fwnode); + if (IS_ERR(ptn->typec_mux)) { + ret = dev_err_probe(dev, PTR_ERR(ptn->typec_mux), + "Failed to acquire mode-switch\n"); + goto err_switch_put; + } + ret = regulator_enable(ptn->vdd18_supply); if (ret) { ret = dev_err_probe(dev, ret, "Failed to enable vdd18\n"); - goto err_switch_put; + goto err_mux_put; } ret = ptn36502_detect(ptn); @@ -365,6 +381,9 @@ static int ptn36502_probe(struct i2c_client *client) err_disable_regulator: regulator_disable(ptn->vdd18_supply); +err_mux_put: + typec_mux_put(ptn->typec_mux); + err_switch_put: typec_switch_put(ptn->typec_switch); @@ -380,6 +399,7 @@ static void ptn36502_remove(struct i2c_client *client) regulator_disable(ptn->vdd18_supply); + typec_mux_put(ptn->typec_mux); typec_switch_put(ptn->typec_switch); } From patchwork Thu Jun 6 13:11:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 13688465 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.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 B7143195F09 for ; Thu, 6 Jun 2024 13:11:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717679483; cv=none; b=P0PMN52ai60Y8Hq6G8uEKSeG90bjf0igWe5MrePExAKUY1DAPow1KRb/OPV5iktpCSzKYc6rVmHR8Z4q8pYnpY+0J01/hyMtOEijFteTiHIpDkRy4vAZvICiLpsaat1eHRmH2pOZ6ZRB1Rk3Gg0LFm0vaW0mJcAjuo5eO3z6nRA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717679483; c=relaxed/simple; bh=qb+nX0PsQ8r0ONiEBtEpU+5wDoCjx57v1hbZ1gvN1vE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=K5UUxfyOfneJfBkHPVtzhiq0boGIv1SR4Y4pjQdQ93V7qYCTbHynnJjuzqWymrf+ykXbwfDiAB28BeAPTePtzKB4euYvYCtooL4GvouyMJB7AkG2EG/homXMyokcFLc0vLlZtOc5ZBiyAhsexDIrnmORMd9IDeaED2Tra/u+9l8= 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=YZqssjJx; arc=none smtp.client-ip=209.85.221.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="YZqssjJx" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-35e83828738so971977f8f.1 for ; Thu, 06 Jun 2024 06:11:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717679480; x=1718284280; 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=cEWi4BwYNC7NiwESLETKdGa2PVEvW42M7cysehMEv/w=; b=YZqssjJxZjALoW8a9Zo/Yg3sPXUytGVL/zKpYbAGboJkB20wwQ0Z7Np8MGXT+ov0sx Vfzn8y8wJX1ktb2CnbW4Og6L1NWzzNXCZLjeH6cPvwtWCzzltK4EmyY3qbKJrUl8vqkj FVhNCZnRmUxWIVvuA5mBFWptptps50x9LZfc0edUvFZD0wUt6jFiqrolrdgQR7Fn91DJ n8Hd/Wv2JjbmNjxwrXDPXnbGJCVD6KadAm51ZOlGAWAd4oDVByva+Hm0KJHduE+gEB9V t6T0oAwZaCrDR3bOZVgxPIw5L6tmO4E/t0C2EGDajBzC8CP9d7l+wDGT0wZ0TjBeQCf8 3TMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717679480; x=1718284280; 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=cEWi4BwYNC7NiwESLETKdGa2PVEvW42M7cysehMEv/w=; b=RJvrZwAq6K/m+4WjjpbGD8JbggA/gq6Y3GX4wwRH1y+yDO94KIrAocZ1D6QWFLWO+x 2fZbpw5728SiAWtIDdpN0R/X/TfbC0ocwWpcuq8NFLgKFbdT3PhZGRkG+CrhEU7U4IId aTKggxSXtYW5gPDaTZFazW1wM9+N+vubvKoCynys0tOoKHWjNoqwbSeYogNm4zPHDW9c 7iDwQu/gaLm0SDlcHlou3gqgWwHj29fZNsZsHBaWdrblk7H4uCclfp71qtPkuKMl4Mav 0f+SwDuFxpigKB+uC9Akj4SPVzjteCdUIkjHkwIvYxnc82dT82bkzwBiyvASFTV6scvF sKtg== X-Forwarded-Encrypted: i=1; AJvYcCWIiqSCqk1DmTw4M9VuxKPvOR+RAPS36jJI1FSh/j85MJU9dT6/maKYYGY9+DhMht/ataASERIsmVRYmuDfdrnzQDgGWvHaZ2n9wM2Hvg== X-Gm-Message-State: AOJu0YzdhN6QisJd1ai/ZpIUmMj9TMk1v1esaY2K+juB5ByyuPUk71iw +7T37/OVecA5hdkgcmruK9VYvSozddF+4hgiW92SHPhuorFaF+qGqG4uiVudMi8= X-Google-Smtp-Source: AGHT+IE9b0Gh3BEH2+Z6EhiMWZLgD7E7TuzNaS2tTCwJyO7yfVStod/NfZPZ5Zly8PO/5FoVvBMI+g== X-Received: by 2002:a5d:6789:0:b0:35e:5189:2d78 with SMTP id ffacd0b85a97d-35e8ef65f13mr4278385f8f.51.1717679480088; Thu, 06 Jun 2024 06:11:20 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:52eb:f6ff:feb3:451a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35ef5e96d8csm1536316f8f.68.2024.06.06.06.11.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 06:11:19 -0700 (PDT) From: Neil Armstrong Date: Thu, 06 Jun 2024 15:11:16 +0200 Subject: [PATCH v2 4/4] usb: typec-mux: nb7vpq904m: broadcast typec state to next mux Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240606-topic-sm8x50-upstream-retimer-broadcast-mode-v2-4-c6f6eae479c3@linaro.org> References: <20240606-topic-sm8x50-upstream-retimer-broadcast-mode-v2-0-c6f6eae479c3@linaro.org> In-Reply-To: <20240606-topic-sm8x50-upstream-retimer-broadcast-mode-v2-0-c6f6eae479c3@linaro.org> To: Heikki Krogerus , Greg Kroah-Hartman Cc: Bjorn Andersson , Luca Weiss , linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Neil Armstrong X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2837; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=qb+nX0PsQ8r0ONiEBtEpU+5wDoCjx57v1hbZ1gvN1vE=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBmYbVzE2VApWoDdpfFcgBobGdrW+oswV9CTaRJdatQ yQcQhE2JAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZmG1cwAKCRB33NvayMhJ0XMwEA CstrM6GVtFB3iT4ScLC99aKh3P3kIZ5m63NeW452HP255KG6zoj3lWFOOaZu5ni4doUIVI5mbRLUa1 mbMR/c76PjtFi5T+zuP65MGXcxxiXdiAUeLY4KelNaaAMXqeOFNgZaTdH8vjW3qqa0ri9XGxJQ362N WEcnUr1WbqqbXnJ8qIK5ntewXkwRpxfneqZCSrAA/78Yclc03W2BTESxgdMl/aJJwmYJyIW5rx+8n3 SxK5rlisB1GzOQGzH17bjtP6QUzh1YkczAW26+YOLvekqOS6NxAc8D/S042ZP68FSwY2WvRKhA/fZl c574ke1/S81rIF7GUWdWm7mTDEsz6mI56dcoxoNcnARx+cQVBc1Nk4bV84gMbyQ65OqYGmrglul/ga GfFINiQloveTpdP8uxBNuZLNPxQTUH91QgRR9LoCRe+fW7NUeHTipRq/2Dv4Pq6woouWR/j2xsRiAl 945OYEFAHkPU3FUJNJIhNvV9GJMeZ69rwzGyxLT3RT+OGU9KU/4TMCmspObIFtgEBGWFRSNjSuYP7F f5bI/IpmhMsiFu2V4Nz5kgIVl/bF55eoylVb79zBjXd+JxxUBRf5GIKUSeodBYN5FCGpQS80W4Bh2h POd0+GojKcV059dYoybl8ufZOpA6oHaBU4uWCr6arQ4Y5e5TOohbXTwvhCNA== X-Developer-Key: i=neil.armstrong@linaro.org; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE In the Type-C graph, the nb7vpq904m retimer is in between the USB-C connector and the USB3/DP combo PHY, and this PHY also requires the USB-C mode events to properly set-up the SuperSpeed Lanes functions to setup USB3-only, USB3 + DP Altmode or DP Altmode only on the 4 lanes. Update the nb7vpq904m retimer to get an optional type-c mux on the next endpoint, and broadcast the received mode to it. Signed-off-by: Neil Armstrong Reviewed-by: Dmitry Baryshkov Reviewed-by: Heikki Krogerus --- drivers/usb/typec/mux/nb7vpq904m.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/usb/typec/mux/nb7vpq904m.c b/drivers/usb/typec/mux/nb7vpq904m.c index 569f1162ee2e..b57b6c9c40fe 100644 --- a/drivers/usb/typec/mux/nb7vpq904m.c +++ b/drivers/usb/typec/mux/nb7vpq904m.c @@ -69,6 +69,7 @@ struct nb7vpq904m { bool swap_data_lanes; struct typec_switch *typec_switch; + struct typec_mux *typec_mux; struct mutex lock; /* protect non-concurrent retimer & switch */ @@ -275,6 +276,7 @@ static int nb7vpq904m_sw_set(struct typec_switch_dev *sw, enum typec_orientation static int nb7vpq904m_retimer_set(struct typec_retimer *retimer, struct typec_retimer_state *state) { struct nb7vpq904m *nb7 = typec_retimer_get_drvdata(retimer); + struct typec_mux_state mux_state; int ret = 0; mutex_lock(&nb7->lock); @@ -292,7 +294,14 @@ static int nb7vpq904m_retimer_set(struct typec_retimer *retimer, struct typec_re mutex_unlock(&nb7->lock); - return ret; + if (ret) + return ret; + + mux_state.alt = state->alt; + mux_state.data = state->data; + mux_state.mode = state->mode; + + return typec_mux_set(nb7->typec_mux, &mux_state); } static const struct regmap_config nb7_regmap = { @@ -413,9 +422,16 @@ static int nb7vpq904m_probe(struct i2c_client *client) return dev_err_probe(dev, PTR_ERR(nb7->typec_switch), "failed to acquire orientation-switch\n"); + nb7->typec_mux = fwnode_typec_mux_get(dev->fwnode); + if (IS_ERR(nb7->typec_mux)) { + ret = dev_err_probe(dev, PTR_ERR(nb7->typec_mux), + "Failed to acquire mode-switch\n"); + goto err_switch_put; + } + ret = nb7vpq904m_parse_data_lanes_mapping(nb7); if (ret) - goto err_switch_put; + goto err_mux_put; ret = regulator_enable(nb7->vcc_supply); if (ret) @@ -458,6 +474,9 @@ static int nb7vpq904m_probe(struct i2c_client *client) gpiod_set_value(nb7->enable_gpio, 0); regulator_disable(nb7->vcc_supply); +err_mux_put: + typec_mux_put(nb7->typec_mux); + err_switch_put: typec_switch_put(nb7->typec_switch); @@ -475,6 +494,7 @@ static void nb7vpq904m_remove(struct i2c_client *client) regulator_disable(nb7->vcc_supply); + typec_mux_put(nb7->typec_mux); typec_switch_put(nb7->typec_switch); }