Commit 50f803d4 authored by Alex Elder's avatar Alex Elder Committed by Jakub Kicinski

net: ipa: encapsulate decision about firmware load

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: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 4ca0c647
...@@ -81,6 +81,19 @@ ...@@ -81,6 +81,19 @@
/* Divider for 19.2 MHz crystal oscillator clock to get common timer clock */ /* Divider for 19.2 MHz crystal oscillator clock to get common timer clock */
#define IPA_XO_CLOCK_DIVIDER 192 /* 1 is subtracted where used */ #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_setup() - Set up IPA hardware
* @ipa: IPA pointer * @ipa: IPA pointer
...@@ -696,6 +709,18 @@ static void ipa_validate_build(void) ...@@ -696,6 +709,18 @@ static void ipa_validate_build(void)
BUILD_BUG_ON(!ipa_aggr_granularity_val(IPA_AGGR_GRANULARITY)); 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 * ipa_probe() - IPA platform driver probe function
* @pdev: Platform device pointer * @pdev: Platform device pointer
...@@ -722,9 +747,9 @@ static void ipa_validate_build(void) ...@@ -722,9 +747,9 @@ static void ipa_validate_build(void)
static int ipa_probe(struct platform_device *pdev) static int ipa_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
enum ipa_firmware_loader loader;
const struct ipa_data *data; const struct ipa_data *data;
struct ipa_power *power; struct ipa_power *power;
bool modem_init;
struct ipa *ipa; struct ipa *ipa;
int ret; int ret;
...@@ -747,10 +772,8 @@ static int ipa_probe(struct platform_device *pdev) ...@@ -747,10 +772,8 @@ static int ipa_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
/* If we need Trust Zone, make sure it's available */ loader = ipa_firmware_loader(dev);
modem_init = of_property_read_bool(dev->of_node, "modem-init"); if (loader == IPA_LOADER_DEFER)
if (!modem_init)
if (!qcom_scm_is_available())
return -EPROBE_DEFER; return -EPROBE_DEFER;
/* The clock and interconnects might not be ready when we're /* The clock and interconnects might not be ready when we're
...@@ -796,7 +819,7 @@ static int ipa_probe(struct platform_device *pdev) ...@@ -796,7 +819,7 @@ static int ipa_probe(struct platform_device *pdev)
if (ret) if (ret)
goto err_endpoint_exit; goto err_endpoint_exit;
ret = ipa_smp2p_init(ipa, modem_init); ret = ipa_smp2p_init(ipa, loader == IPA_LOADER_MODEM);
if (ret) if (ret)
goto err_table_exit; goto err_table_exit;
...@@ -815,7 +838,7 @@ static int ipa_probe(struct platform_device *pdev) ...@@ -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 * call to ipa_setup() when it has finished. In that case we're
* done here. * done here.
*/ */
if (modem_init) if (loader == IPA_LOADER_MODEM)
goto done; goto done;
/* Otherwise we need to load the firmware and have Trust Zone validate /* Otherwise we need to load the firmware and have Trust Zone validate
......
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