Commit 07f2f8e1 authored by Alex Elder's avatar Alex Elder Committed by Jakub Kicinski

net: ipa: introduce "qcom,gsi-loader" property

Introduce a new way of specifying how the GSI firmware gets loaded
for IPA.  Currently, this is indicated by the presence or absence of
the Boolean "modem-init" Device Tree property.  The new property
must have a value--either "self" or "modem"--which indicates whether
the AP or modem is the GSI firmware loader, respectively.

For legacy systems, the new property will not exist, and the
"modem-init" property will be used.  For newer systems, the
"qcom,gsi-loader" property *must* exist, and must have one of the
two prescribed values.  It is an error to have both properties
defined, and it is an error for the new property to have an
unrecognized value.
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 50f803d4
...@@ -87,11 +87,13 @@ ...@@ -87,11 +87,13 @@
* @IPA_LOADER_DEFER: System not ready; try again later * @IPA_LOADER_DEFER: System not ready; try again later
* @IPA_LOADER_SELF: AP loads GSI firmware * @IPA_LOADER_SELF: AP loads GSI firmware
* @IPA_LOADER_MODEM: Modem loads GSI firmware, signals when done * @IPA_LOADER_MODEM: Modem loads GSI firmware, signals when done
* @IPA_LOADER_INVALID: GSI firmware loader specification is invalid
*/ */
enum ipa_firmware_loader { enum ipa_firmware_loader {
IPA_LOADER_DEFER, IPA_LOADER_DEFER,
IPA_LOADER_SELF, IPA_LOADER_SELF,
IPA_LOADER_MODEM, IPA_LOADER_MODEM,
IPA_LOADER_INVALID,
}; };
/** /**
...@@ -711,9 +713,37 @@ static void ipa_validate_build(void) ...@@ -711,9 +713,37 @@ static void ipa_validate_build(void)
static enum ipa_firmware_loader ipa_firmware_loader(struct device *dev) static enum ipa_firmware_loader ipa_firmware_loader(struct device *dev)
{ {
if (of_property_read_bool(dev->of_node, "modem-init")) bool modem_init;
const char *str;
int ret;
/* Look up the old and new properties by name */
modem_init = of_property_read_bool(dev->of_node, "modem-init");
ret = of_property_read_string(dev->of_node, "qcom,gsi-loader", &str);
/* If the new property doesn't exist, it's legacy behavior */
if (ret == -EINVAL) {
if (modem_init)
return IPA_LOADER_MODEM; return IPA_LOADER_MODEM;
goto out_self;
}
/* Any other error on the new property means it's poorly defined */
if (ret)
return IPA_LOADER_INVALID;
/* New property value exists; if old one does too, that's invalid */
if (modem_init)
return IPA_LOADER_INVALID;
/* Modem loads GSI firmware for "modem" */
if (!strcmp(str, "modem"))
return IPA_LOADER_MODEM;
/* Any value other than "self" is an error */
if (strcmp(str, "self"))
return IPA_LOADER_INVALID;
out_self:
/* We need Trust Zone to load firmware; make sure it's available */ /* We need Trust Zone to load firmware; make sure it's available */
if (qcom_scm_is_available()) if (qcom_scm_is_available())
return IPA_LOADER_SELF; return IPA_LOADER_SELF;
...@@ -773,6 +803,8 @@ static int ipa_probe(struct platform_device *pdev) ...@@ -773,6 +803,8 @@ static int ipa_probe(struct platform_device *pdev)
} }
loader = ipa_firmware_loader(dev); loader = ipa_firmware_loader(dev);
if (loader == IPA_LOADER_INVALID)
return -EINVAL;
if (loader == IPA_LOADER_DEFER) if (loader == IPA_LOADER_DEFER)
return -EPROBE_DEFER; return -EPROBE_DEFER;
...@@ -834,20 +866,18 @@ static int ipa_probe(struct platform_device *pdev) ...@@ -834,20 +866,18 @@ static int ipa_probe(struct platform_device *pdev)
dev_info(dev, "IPA driver initialized"); dev_info(dev, "IPA driver initialized");
/* If the modem is doing early initialization, it will trigger a /* If the modem is loading GSI firmware, it will trigger a call to
* call to ipa_setup() when it has finished. In that case we're * ipa_setup() when it has finished. In that case we're done here.
* done here.
*/ */
if (loader == IPA_LOADER_MODEM) if (loader == IPA_LOADER_MODEM)
goto done; goto done;
/* Otherwise we need to load the firmware and have Trust Zone validate /* The AP is loading GSI firmware; do so now */
* and install it. If that succeeds we can proceed with setup.
*/
ret = ipa_firmware_load(dev); ret = ipa_firmware_load(dev);
if (ret) if (ret)
goto err_deconfig; goto err_deconfig;
/* GSI firmware is loaded; proceed to setup */
ret = ipa_setup(ipa); ret = ipa_setup(ipa);
if (ret) if (ret)
goto err_deconfig; goto err_deconfig;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment