Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3758221rwb; Sat, 12 Nov 2022 12:11:09 -0800 (PST) X-Google-Smtp-Source: AA0mqf4tB+LJ8+eZMASWU7cW1b0PnRl6VqMS75rJfliwJZgEC5DUPuNDF4rATXrrsWxfATjDhLM6 X-Received: by 2002:a63:e450:0:b0:46f:7338:67e5 with SMTP id i16-20020a63e450000000b0046f733867e5mr6107033pgk.385.1668283869484; Sat, 12 Nov 2022 12:11:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668283869; cv=none; d=google.com; s=arc-20160816; b=YTR1PaCjk73o1SVgzqLokjwaBKmVOfV/W0eJSkH9XEnloJR3zG9NAlZsvWc1C5Ynhw YjTzD6Z8c4Xm5bYyULjewevug8hg2trMCBhky/cAm7dzDwttaWR7K5IG5NxLkrfFGCeJ cX4gwENno/tH+7U+kOi7jqX7p5Rp6JOeyMyBaooAz8vUTFWGoetA0Gk1WS2xovetYZwi 91ZsoGXEFSXn7lr7ExvXItAb+gWMaKVb+r0u5wJOXQGNkzDgRhldMVQ+YmyI4tDFETS8 GrqYz+4EqYSn1acL8kOqkiI7skv8TyMMvUf08NJI9cl/dgaZeI6WcokHrPSjZR92knHC REfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IbFCvRl1cs7XC6NWdvqbuTmw/rqE6VsOAXoQYLExO5Q=; b=iPJQt9fcBuh+1bzwI05FEmVGSmiPaybXZ/zzcqu/7cAGEQTpyntMpFtj4ChruBZTLw 9yI64+yxl0BEA2MQNfgeyy9eiCIzuerhctftxgCpMGmb4WhUzkmsQI1ZE+6wDPIXpFjh K/lCvKju9ut6w0/3EQsFgXZV/aFxT89eVXWnuJUghlMVrso4E0ve6neT9+E8IRQruwmO vUKfgDhh74xT9+QVwujdsTCqgibETdtUnSUPAXoschw7mRTsFfRBTDt6hdiFGB0QYhmr RdpGRRnddjsM1zuFQrONmMlUVb+N0QXGEM+e4UNyBFTo2ajkMCtXcIHzSkfNTImJ/wfL Gfyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kQdrYZsu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ob17-20020a17090b391100b00205ef38b646si6554495pjb.80.2022.11.12.12.10.57; Sat, 12 Nov 2022 12:11:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kQdrYZsu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235056AbiKLUHh (ORCPT + 90 others); Sat, 12 Nov 2022 15:07:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234928AbiKLUH0 (ORCPT ); Sat, 12 Nov 2022 15:07:26 -0500 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99ED41277D for ; Sat, 12 Nov 2022 12:07:25 -0800 (PST) Received: by mail-io1-xd35.google.com with SMTP id q21so5735624iod.4 for ; Sat, 12 Nov 2022 12:07:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=IbFCvRl1cs7XC6NWdvqbuTmw/rqE6VsOAXoQYLExO5Q=; b=kQdrYZsuJaVebDpUK1qll7fwMnM+JhAIDP0wsHb48mI9g/xXQwhDQ58vxgd8IOZmAn jREThxZltYYSej0l4guj6s7C0OLAbh4hiXfVjLgcIvkER/xnaGciGUWRh2in+9r7Tvaa LH8pJX0cLpnzOD/AD87PHklH+eKyUlyCV3JmeBKTUPyg67uQ+7Z1qMOBBaQCqtNs/jGW dkS45ArZEfQmsd66/or6Y6Ni9LfrjTg//FXAeJlnErIctxlPMyX5bLG5oVRvaCSSIKjA AqKZMRfn2AN5Ef942CZDRi80FYpxtpKuiDY9mo1yG+8PQ93wdgV1yd3gVHID7Ksaa5Md uLBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=IbFCvRl1cs7XC6NWdvqbuTmw/rqE6VsOAXoQYLExO5Q=; b=UQR8os6CA2Bn4q9JoTNJPhlYsX4FbbZjhdBWFaE8dxI/0BCMPjzvtrsrShfvBSKCHE JMcctVncnQJqLpyYjcyJQCsckjeVaiqvt8L4iI43O5dqR57zyTKGXyHa7ASy7QseNdp0 3hifCMZemBRUaYvJbv4fcUUgd0wkgjU7CacVDWOWGPkcpP03Wk5LbJY5+wRIklVd8/hj Pay3BQk+dB4Ez1qgf+U+K9nV3x9VDSfr6eBXXlEgUoOEvUtfmo3oD/o0U0by6kb3OKbj wAlUkFKTVdbK/QU7PBgG/xTE1fApkod5UDN5C12FvpkjXbrck1Aqfy5s8i14RVjNU0f+ hJpw== X-Gm-Message-State: ANoB5pncJPsFceXmEyYLJ27T8vxZYtK0/JPjnCWy30tQdKDNUEfSDfZy sMirlsbVnEsS5rRu9P4vBC+L8g== X-Received: by 2002:a6b:6c19:0:b0:6bc:4a3a:4de2 with SMTP id a25-20020a6b6c19000000b006bc4a3a4de2mr3097956ioh.207.1668283644942; Sat, 12 Nov 2022 12:07:24 -0800 (PST) Received: from presto.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id j28-20020a02cb1c000000b00363dee286edsm2036870jap.60.2022.11.12.12.07.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Nov 2022 12:07:24 -0800 (PST) From: Alex Elder To: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: andersson@kernel.org, konrad.dybcio@linaro.org, agross@kernel.org, elder@kernel.org, linux-arm-msm@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/5] net: ipa: encapsulate decision about firmware load Date: Sat, 12 Nov 2022 14:07:14 -0600 Message-Id: <20221112200717.1533622-3-elder@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221112200717.1533622-1-elder@linaro.org> References: <20221112200717.1533622-1-elder@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The GSI layer used for IPA requires firmware to be loaded. Currently either the AP or the modem loads the firmware, distinguished by whether the "modem-init" Device Tree property is defined. Some newer systems implement a third option. In preparation for that, encapsulate the code that determines how the GSI firmware gets loaded in a new function, ipa_firmware_loader(). Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_main.c | 39 ++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c index ebb6c9b311eb9..9e43b79d233e9 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -81,6 +81,19 @@ /* Divider for 19.2 MHz crystal oscillator clock to get common timer clock */ #define IPA_XO_CLOCK_DIVIDER 192 /* 1 is subtracted where used */ +/** + * enum ipa_firmware_loader: How GSI firmware gets loaded + * + * @IPA_LOADER_DEFER: System not ready; try again later + * @IPA_LOADER_SELF: AP loads GSI firmware + * @IPA_LOADER_MODEM: Modem loads GSI firmware, signals when done + */ +enum ipa_firmware_loader { + IPA_LOADER_DEFER, + IPA_LOADER_SELF, + IPA_LOADER_MODEM, +}; + /** * ipa_setup() - Set up IPA hardware * @ipa: IPA pointer @@ -696,6 +709,18 @@ static void ipa_validate_build(void) BUILD_BUG_ON(!ipa_aggr_granularity_val(IPA_AGGR_GRANULARITY)); } +static enum ipa_firmware_loader ipa_firmware_loader(struct device *dev) +{ + if (of_property_read_bool(dev->of_node, "modem-init")) + return IPA_LOADER_MODEM; + + /* We need Trust Zone to load firmware; make sure it's available */ + if (qcom_scm_is_available()) + return IPA_LOADER_SELF; + + return IPA_LOADER_DEFER; +} + /** * ipa_probe() - IPA platform driver probe function * @pdev: Platform device pointer @@ -722,9 +747,9 @@ static void ipa_validate_build(void) static int ipa_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + enum ipa_firmware_loader loader; const struct ipa_data *data; struct ipa_power *power; - bool modem_init; struct ipa *ipa; int ret; @@ -747,11 +772,9 @@ static int ipa_probe(struct platform_device *pdev) return -EINVAL; } - /* If we need Trust Zone, make sure it's available */ - modem_init = of_property_read_bool(dev->of_node, "modem-init"); - if (!modem_init) - if (!qcom_scm_is_available()) - return -EPROBE_DEFER; + loader = ipa_firmware_loader(dev); + if (loader == IPA_LOADER_DEFER) + return -EPROBE_DEFER; /* The clock and interconnects might not be ready when we're * probed, so might return -EPROBE_DEFER. @@ -796,7 +819,7 @@ static int ipa_probe(struct platform_device *pdev) if (ret) goto err_endpoint_exit; - ret = ipa_smp2p_init(ipa, modem_init); + ret = ipa_smp2p_init(ipa, loader == IPA_LOADER_MODEM); if (ret) goto err_table_exit; @@ -815,7 +838,7 @@ static int ipa_probe(struct platform_device *pdev) * call to ipa_setup() when it has finished. In that case we're * done here. */ - if (modem_init) + if (loader == IPA_LOADER_MODEM) goto done; /* Otherwise we need to load the firmware and have Trust Zone validate -- 2.34.1