Skip to content

Commit

Permalink
net: ipa: optionally define firmware name via DT
Browse files Browse the repository at this point in the history
IPA initialization includes loading some firmware.  This step is
done either by the modem or by the AP under Trust Zone.  If the
AP loads firmware, the name of the firmware file is currently
hard-coded ("ipa_fws.mdt").

Add the ability to specify the relative path of the firmware file to
use in a property in the Device Tree IPA node.  If the property is
not found (or if any other error occurs attempting to get it), fall
back to using a default relative path.

Use the "old" fixed name as the default.  Rename the symbol that
represents this default to emphasize its purpose.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Alex Elder authored and David S. Miller committed Apr 16, 2021
1 parent d8604b2 commit 9ce062b
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions drivers/net/ipa/ipa_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
*/

/* The name of the GSI firmware file relative to /lib/firmware */
#define IPA_FWS_PATH "ipa_fws.mdt"
#define IPA_FW_PATH_DEFAULT "ipa_fws.mdt"
#define IPA_PAS_ID 15

/* Shift of 19.2 MHz timestamp to achieve lower resolution timestamps */
Expand Down Expand Up @@ -517,6 +517,7 @@ static int ipa_firmware_load(struct device *dev)
struct device_node *node;
struct resource res;
phys_addr_t phys;
const char *path;
ssize_t size;
void *virt;
int ret;
Expand All @@ -534,9 +535,17 @@ static int ipa_firmware_load(struct device *dev)
return ret;
}

ret = request_firmware(&fw, IPA_FWS_PATH, dev);
/* Use name from DTB if specified; use default for *any* error */
ret = of_property_read_string(dev->of_node, "firmware-name", &path);
if (ret) {
dev_err(dev, "error %d requesting \"%s\"\n", ret, IPA_FWS_PATH);
dev_dbg(dev, "error %d getting \"firmware-name\" resource\n",
ret);
path = IPA_FW_PATH_DEFAULT;
}

ret = request_firmware(&fw, path, dev);
if (ret) {
dev_err(dev, "error %d requesting \"%s\"\n", ret, path);
return ret;
}

Expand All @@ -549,13 +558,11 @@ static int ipa_firmware_load(struct device *dev)
goto out_release_firmware;
}

ret = qcom_mdt_load(dev, fw, IPA_FWS_PATH, IPA_PAS_ID,
virt, phys, size, NULL);
ret = qcom_mdt_load(dev, fw, path, IPA_PAS_ID, virt, phys, size, NULL);
if (ret)
dev_err(dev, "error %d loading \"%s\"\n", ret, IPA_FWS_PATH);
dev_err(dev, "error %d loading \"%s\"\n", ret, path);
else if ((ret = qcom_scm_pas_auth_and_reset(IPA_PAS_ID)))
dev_err(dev, "error %d authenticating \"%s\"\n", ret,
IPA_FWS_PATH);
dev_err(dev, "error %d authenticating \"%s\"\n", ret, path);

memunmap(virt);
out_release_firmware:
Expand Down

0 comments on commit 9ce062b

Please sign in to comment.