power: reset: qcom-dload-mode: Add support for EDL over PCIe

Currently EDL mode works over USB, if PCIe is early
enumerated on the device add support for EDL over PCIe.

Change-Id: I051ef2a5fa4f63890a1044838dd870fa0195b0b7
Signed-off-by: Yogesh Lal <[email protected]>
This commit is contained in:
Yogesh Lal 2021-08-12 16:37:41 +05:30 • committed by Rohit Agarwal
commit 1508778d30
2 changed files with 34 additions and 2 deletions

View file

@ -39,6 +39,7 @@ static bool enable_dump =
IS_ENABLED(CONFIG_POWER_RESET_QCOM_DOWNLOAD_MODE_DEFAULT);
static enum qcom_download_mode current_download_mode = QCOM_DOWNLOAD_NODUMP;
static enum qcom_download_mode dump_mode = QCOM_DOWNLOAD_FULLDUMP;
static bool early_pcie_init_enable;
static int set_download_mode(enum qcom_download_mode mode)
{
@ -262,8 +263,10 @@ static int qcom_dload_reboot(struct notifier_block *this, unsigned long event,
set_download_mode(QCOM_DOWNLOAD_NODUMP);
if (cmd) {
if (!strcmp(cmd, "edl"))
set_download_mode(QCOM_DOWNLOAD_EDL);
if (!strcmp(cmd, "edl")) {
early_pcie_init_enable ? set_download_mode(QCOM_EDLOAD_PCI_MODE)
: set_download_mode(QCOM_DOWNLOAD_EDL);
}
else if (!strcmp(cmd, "qcom_dload"))
msm_enable_dump_mode(true);
}
@ -311,6 +314,33 @@ static void store_kaslr_offset(void)
static void store_kaslr_offset(void) {}
#endif /* CONFIG_RANDOMIZE_BASE */
static void check_pci_edl(struct device_node *np)
{
void __iomem *mem;
uint32_t read_val;
int ret_l, ret_h, l, h, mask_value;
mem = of_iomap(np, 0);
if (!mem) {
pr_info("Unable to map memory for DT property: %s\n", np->name);
return;
}
read_val = __raw_readl(mem);
ret_l = of_property_read_u32_index(np, "qcom,boot-config-shift", 0, &l);
ret_h = of_property_read_u32_index(np, "qcom,boot-config-shift", 1, &h);
if (!ret_l && !ret_h) {
mask_value = (read_val >> l) & GENMASK(h - l, 0);
if (mask_value == 5 || mask_value == 7) {
early_pcie_init_enable = true;
pr_info("Setting up EDL mode to PCIE\n");
}
}
iounmap(mem);
}
static int qcom_dload_probe(struct platform_device *pdev)
{
struct qcom_dload *poweroff;
@ -340,6 +370,7 @@ static int qcom_dload_probe(struct platform_device *pdev)
poweroff->dload_dest_addr = map_prop_mem("qcom,msm-imem-dload-type");
store_kaslr_offset();
check_pci_edl(pdev->dev.of_node);
msm_enable_dump_mode(enable_dump);
if (!enable_dump)