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: 737627 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55848C25B45 for ; Mon, 23 Oct 2023 21:53:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231292AbjJWVxg (ORCPT ); Mon, 23 Oct 2023 17:53:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231167AbjJWVxf (ORCPT ); Mon, 23 Oct 2023 17:53:35 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B25210C for ; Mon, 23 Oct 2023 14:53:33 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-507ad511315so5642281e87.0 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=vQHTso6mB5/q+JgaKlF4M7KpAml/0MStUWIThI6iDO8A0Cs1BfVK+OWLSAnEcF/WzO btzEHBYPEmrs9cDBtxQhh1inpCrU+pM4jurMLfQiFt2ZOoIL15iRD4UULV5+Tqobm9tk 2zs35mLQs03J4QECHo696Emk6O7IFu7+Px90xc20XoJFuhmVmD3gmAAkiYlRkWEILMW5 QzoFzo4xoL8rFFlwHHpCsoFpQGMAMXsjEGHpL5wQPbuuufPu+tEp/bXz4eryBltYioy8 2/h/sUajzNEzNrK8KXtk6RmChBGt94u2EOpvJr9Ph66YPsmuWiuAdKUC4MJ5hLyTKr+R TMkg== X-Gm-Message-State: AOJu0YwHd2MDaEcWmplS5VSIbpxOoDL/75R9COth2ps8oyHEzHqycaLP q4wsLM2FdR0uxC8O24jGF9lYyw== 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> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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: 737367 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E59F6C25B47 for ; Mon, 23 Oct 2023 21:53:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231167AbjJWVxh (ORCPT ); Mon, 23 Oct 2023 17:53:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229845AbjJWVxg (ORCPT ); Mon, 23 Oct 2023 17:53:36 -0400 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 38388D7C for ; Mon, 23 Oct 2023 14:53:34 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-507a62d4788so6043064e87.0 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=vcs5WLq+kDimex/sqCHra30Ug9n7HEWZsGuvdqk0H/sXKqxbBvL5nR4wqkJBpC+xhl tsb4iNRkiOxlgYNZVfUw2sYol49aSJ05BIMv3s6n5mBuB9zczzahQuGhx0PDlgUgaQaL rrEgjFSjJ7380YQo1x4PI1D/HtB6/q76MJrIdgYyK6ztAtD5nudjpXdijV31RdYUGXnq QB6RJRWPNtYwTYBQvaZnCfGBbsbBoDMrHYs2MGg7BpJ3gpNRjP5HT56HXbYbJsEDMhLy RpzushwDmIn32aO3IlfCg03Uuwq2FuDv/xtlCeAiOh6uCxLsOF0Dc+mtn4zMpMJme4NA XzYg== X-Gm-Message-State: AOJu0YyeAlVIrh71DXGJeRr1KpQ18nd5EUGpYGzUK1xiJBdi4ReEmQIs qVIeaEljKnfs7b1aHKyWFQ2hRQ== 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> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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)