Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1508778d authored by Yogesh Lal's avatar Yogesh Lal Committed by Rohit Agarwal
Browse files

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: default avatarYogesh Lal <ylal@codeaurora.org>
parent cb6bfc80
Loading
Loading
Loading
Loading
+33 −2
Original line number Diff line number Diff line
@@ -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)
+1 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
enum qcom_download_mode {
	QCOM_DOWNLOAD_NODUMP	= 0x00,
	QCOM_DOWNLOAD_EDL	= 0x01,
	QCOM_EDLOAD_PCI_MODE = 0X04,
	QCOM_DOWNLOAD_FULLDUMP	= 0x10,
	QCOM_DOWNLOAD_MINIDUMP	= 0x20,
};