From patchwork Mon Oct 23 21:47:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 738165 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E9C422F14 for ; Mon, 23 Oct 2023 21:53:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="VRwZkeLW" Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5326810E for ; Mon, 23 Oct 2023 14:53:33 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-507bd644a96so5610010e87.3 for ; Mon, 23 Oct 2023 14:53:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698098011; x=1698702811; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FHQPeaj7JIAfkzHBWsKTDrZ2sXAmH8LlIRsWgPLYV7o=; b=VRwZkeLWsvqX3frtuvkBwABVgvqh709qbY715/2IsGqsqwPyloQEPJU9gbbiD1oJJq jK83e3F6Z6ch2qrwM4ADX6yULRB2Z4FWceCn0bBqtTHkkFerc0r+ihVBYPYpizdGMt+O t/kCt5hpazudSnuQxMddebBhvIslzLwbkjem1cH8U4WDp3S0dAjOY4ktWYNtPO4EqN7q zJSLlfzIChrmENyrXozqxwGHpE+Iz3R5fgOOtxiern3vuRQOr+6zfJKNG8RJbO58NQt5 rEpBPnp1upTNwQ1XOfMwiSgAD9qSuqC6q2FXBEFzErbliaKbd2aU6lre2gfAl3yuOC7l l5qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698098011; x=1698702811; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FHQPeaj7JIAfkzHBWsKTDrZ2sXAmH8LlIRsWgPLYV7o=; b=SEm0OQ5q+/Y5H/fnl6HRT9uEgby9XvUjiP98/5yKLRD1HSUxnYL8wj+TCOUuW0wMsK sGqdthw9qE4QkgcxvEm91WonANLqWduQPHvjHRGbgveHy/W+uVJ1oFmyvWYImDdv1+OX SJYEPq0fDVefgC5D5E8QyoAsRIRTR/Q2ZLKzgOGy2l4jAmcynG9EUZjVe5pXTLIeVuqx onpGzvjuNM/vMIjQkgNpEnI8SMbMVZMRCWmGnxP44U+1n6Q1yhvmP+ZutLM18S1+LILu pSX41U4qFDQzKMpwoFAnvLFDMJ+0QDqImGhhqio3y/hbQKkhoDGyQoc1ojAWvylG3WoH L3iQ== X-Gm-Message-State: AOJu0YzYpNc7wcOpdiehHRqmiPIBJd8AVBjST9wNCJ2K/7DcBSskbeWD HUFg/ecyBT6awVol9botfabL5A== X-Google-Smtp-Source: AGHT+IFQ5E49cCJA+S2lWIbu4D1qLDRU4CqhR8pa1g7kImjWJq9iQJPwHDToo56TnuxKFO2A5jEUXw== X-Received: by 2002:ac2:490c:0:b0:501:bd6f:7c1e with SMTP id n12-20020ac2490c000000b00501bd6f7c1emr7095971lfi.33.1698098011108; Mon, 23 Oct 2023 14:53:31 -0700 (PDT) Received: from eriador.lumag.spb.ru (85-76-147-63-nat.elisa-mobile.fi. [85.76.147.63]) by smtp.gmail.com with ESMTPSA id g3-20020a056512118300b005079dac9620sm1845143lfr.43.2023.10.23.14.53.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 14:53:30 -0700 (PDT) From: Dmitry Baryshkov To: Heikki Krogerus , Greg Kroah-Hartman , Andy Gross , Bjorn Andersson , Konrad Dybcio , Neil Armstrong Cc: Rob Herring , linux-usb@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 1/2] usb: typec: ucsi: fix UCSI on buggy Qualcomm devices Date: Tue, 24 Oct 2023 00:47:26 +0300 Message-ID: <20231023215327.695720-2-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231023215327.695720-1-dmitry.baryshkov@linaro.org> References: <20231023215327.695720-1-dmitry.baryshkov@linaro.org> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On sevral Qualcomm platforms (SC8180X, SM8350, SC8280XP) a call to UCSI_GET_PDOS for non-PD partners will cause a firmware crash with no easy way to recover from it. Since we have no easy way to determine whether the partner really has PD support, shortcut UCSI_GET_PDOS on such platforms. This allows us to enable UCSI support on such devices. Signed-off-by: Dmitry Baryshkov --- drivers/usb/typec/ucsi/ucsi.c | 3 +++ drivers/usb/typec/ucsi/ucsi.h | 3 +++ drivers/usb/typec/ucsi/ucsi_glink.c | 3 +++ 3 files changed, 9 insertions(+) diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c index 61b64558f96c..5392ec698959 100644 --- a/drivers/usb/typec/ucsi/ucsi.c +++ b/drivers/usb/typec/ucsi/ucsi.c @@ -578,6 +578,9 @@ static int ucsi_read_pdos(struct ucsi_connector *con, u64 command; int ret; + if (ucsi->quirks & UCSI_NO_PARTNER_PDOS) + return 0; + command = UCSI_COMMAND(UCSI_GET_PDOS) | UCSI_CONNECTOR_NUMBER(con->num); command |= UCSI_GET_PDOS_PARTNER_PDO(is_partner); command |= UCSI_GET_PDOS_PDO_OFFSET(offset); diff --git a/drivers/usb/typec/ucsi/ucsi.h b/drivers/usb/typec/ucsi/ucsi.h index 474315a72c77..6478016d5cb8 100644 --- a/drivers/usb/typec/ucsi/ucsi.h +++ b/drivers/usb/typec/ucsi/ucsi.h @@ -317,6 +317,9 @@ struct ucsi { #define EVENT_PENDING 0 #define COMMAND_PENDING 1 #define ACK_PENDING 2 + + unsigned long quirks; +#define UCSI_NO_PARTNER_PDOS BIT(0) /* Don't read partner's PDOs */ }; #define UCSI_MAX_SVID 5 diff --git a/drivers/usb/typec/ucsi/ucsi_glink.c b/drivers/usb/typec/ucsi/ucsi_glink.c index db6e248f8208..5c159e7b2b65 100644 --- a/drivers/usb/typec/ucsi/ucsi_glink.c +++ b/drivers/usb/typec/ucsi/ucsi_glink.c @@ -327,6 +327,8 @@ static int pmic_glink_ucsi_probe(struct auxiliary_device *adev, if (ret) return ret; + ucsi->ucsi->quirks = id->driver_data; + ucsi_set_drvdata(ucsi->ucsi, ucsi); device_for_each_child_node(dev, fwnode) { @@ -379,6 +381,7 @@ static void pmic_glink_ucsi_remove(struct auxiliary_device *adev) static const struct auxiliary_device_id pmic_glink_ucsi_id_table[] = { { .name = "pmic_glink.ucsi", }, + { .name = "pmic_glink.ucsi-no-pdos", .driver_data = UCSI_NO_PARTNER_PDOS, }, {}, }; MODULE_DEVICE_TABLE(auxiliary, pmic_glink_ucsi_id_table); From patchwork Mon Oct 23 21:47:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 737504 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4EFF22F16 for ; Mon, 23 Oct 2023 21:53:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ZZoSqPyd" Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 360AAD79 for ; Mon, 23 Oct 2023 14:53:34 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-5079f9675c6so6004766e87.2 for ; Mon, 23 Oct 2023 14:53:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698098012; x=1698702812; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SN2sLOa9xwGM67Rq52+5iCupQnqxlWnolzeyMPzN3QU=; b=ZZoSqPyd550fbXScvbW2Lf0ybFwCJUOvz73JJd+k1Lw5NiApZF0Oom0hx6qo+x3BEu tpm6EN1+FpjEM6ErziUvqdywm41dRFaYBmObHOi2Pj53ufMqPGnPX4Nd1j7TKrE+xd3k E9ZhE76tgMFTnuc7uhWVPDBQDJyf0iWqpcEpcNXpDBCf6vGv0H6moilmHARlgYuVLIuF LX20Qc2cGxlTGvh7vPeJ3SHLY2v/8IU+da3OW3u02TtvMjmoQxjZYBsgD46srfvVZGln G65kI6R8zjwDCoxIRW1xBWSS0R39xat4NCSODqKaczGAExV+O+YbRDvIXph75HpRjOVj 5Nuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698098012; x=1698702812; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SN2sLOa9xwGM67Rq52+5iCupQnqxlWnolzeyMPzN3QU=; b=Mcl1KzH685FgH07MKxYWwx/4egDgaNPNULN7Zq4Pi1XZXaQXcv5xkvPLyaRHWV+EcJ L8TRDy6b9qPVE8ArbWoUV1S93HoKMkcGRph3orOPdFCdYbDJJGy+2PWfsXpn9O86kGXu K4gs5XRFyi7EyE/T70DM7aP73jtgMoXiXfrFDf9s2nD0vX5CAeesxzASAIsQqWU43gff 8G6VAn6CuI+L6n8jXTv2ZY0jeh3VptjQnnIK9C1A5VgJTIcbP1qtZnhp5vkQYdZ1+wan U3F1tZT4GuaHc+2FwNBGR5PididS4w08qE4/xpDLFVOTC3KM+syOjEHZaIhojPEyUeQ+ U7iQ== X-Gm-Message-State: AOJu0Yy4eJfN7Lu+uHtvAgKDwJ1zYrZpcb+OQF3JTodG8yvc1gXzIK6v 05KL77oBJNqGR8265OReBU3+PlCeGnC3FzHaK8j1Nw== X-Google-Smtp-Source: AGHT+IHuJfk9KdAfnGmoSEogeTq5EFh5oiYm9phVPnu+CdkR8gpXcG8+3xH88P6QZsMQ6U3VJYKPDA== X-Received: by 2002:a05:6512:3449:b0:503:1d46:6f29 with SMTP id j9-20020a056512344900b005031d466f29mr7218271lfr.37.1698098012440; Mon, 23 Oct 2023 14:53:32 -0700 (PDT) Received: from eriador.lumag.spb.ru (85-76-147-63-nat.elisa-mobile.fi. [85.76.147.63]) by smtp.gmail.com with ESMTPSA id g3-20020a056512118300b005079dac9620sm1845143lfr.43.2023.10.23.14.53.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 14:53:32 -0700 (PDT) From: Dmitry Baryshkov To: Heikki Krogerus , Greg Kroah-Hartman , Andy Gross , Bjorn Andersson , Konrad Dybcio , Neil Armstrong Cc: Rob Herring , linux-usb@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 2/2] soc: qcom: pmic-glink: enable UCSI on older devices Date: Tue, 24 Oct 2023 00:47:27 +0300 Message-ID: <20231023215327.695720-3-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231023215327.695720-1-dmitry.baryshkov@linaro.org> References: <20231023215327.695720-1-dmitry.baryshkov@linaro.org> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Now that the UCSI driver got support for the 'no partner PDOs' quirk, enable UCSI device on all older Qualcomm platforms. Newer platforms, which handle UCSI_GET_PDOS properly, should opt-in to use full-featured UCSI device (see sm8450 and sm8550). Signed-off-by: Dmitry Baryshkov --- drivers/soc/qcom/pmic_glink.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/soc/qcom/pmic_glink.c b/drivers/soc/qcom/pmic_glink.c index 914057331afd..b524291586d8 100644 --- a/drivers/soc/qcom/pmic_glink.c +++ b/drivers/soc/qcom/pmic_glink.c @@ -16,9 +16,11 @@ enum { PMIC_GLINK_CLIENT_BATT = 0, PMIC_GLINK_CLIENT_ALTMODE, PMIC_GLINK_CLIENT_UCSI, + PMIC_GLINK_CLIENT_UCSI_NO_PDOS, }; #define PMIC_GLINK_CLIENT_DEFAULT (BIT(PMIC_GLINK_CLIENT_BATT) | \ + BIT(PMIC_GLINK_CLIENT_UCSI_NO_PDOS) | \ BIT(PMIC_GLINK_CLIENT_ALTMODE)) struct pmic_glink { @@ -273,6 +275,11 @@ static int pmic_glink_probe(struct platform_device *pdev) if (ret) return ret; } + if (pg->client_mask & BIT(PMIC_GLINK_CLIENT_UCSI_NO_PDOS)) { + ret = pmic_glink_add_aux_device(pg, &pg->ucsi_aux, "ucsi-no-pdos"); + if (ret) + return ret; + } if (pg->client_mask & BIT(PMIC_GLINK_CLIENT_ALTMODE)) { ret = pmic_glink_add_aux_device(pg, &pg->altmode_aux, "altmode"); if (ret)