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

Commit 49ff867b authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "net: stmmac: add support to read mac address from oem fuse"

parents 48476141 bf62d5f8
Loading
Loading
Loading
Loading
+37 −0
Original line number Diff line number Diff line
@@ -2703,6 +2703,40 @@ static struct notifier_block qcom_ethqos_panic_blk = {
	.notifier_call  = qcom_ethos_panic_notifier,
};

static void read_mac_addr_from_fuse_reg(struct device_node *np)
{
	int ret, i;
	u32 mac_efuse_prop, efuse_size = 8;
	void __iomem *mac_efuse_addr;
	unsigned long mac_addr;
	bool valid_mac = false;

	ret = of_property_read_u32(np, "mac-efuse-addr", &mac_efuse_prop);
	if (!ret) {
		mac_efuse_addr = ioremap(mac_efuse_prop, efuse_size);
		if (!mac_efuse_addr) {
			ETHQOSERR("unable to do ioremap\n");
			return;
		}
		mac_addr = readq(mac_efuse_addr);
		ETHQOSINFO("Mac address read: %llx\n", mac_addr);

		/* create byte array out of value read from efuse */
		for (i = 0; i < ETH_ALEN ; i++) {
			pparams.mac_addr[ETH_ALEN - 1 - i] = mac_addr & 0xff;
			mac_addr = mac_addr >> 8;
		}

		valid_mac = is_valid_ether_addr(pparams.mac_addr);
		if (!valid_mac) {
			ETHQOSERR("Invalid Mac address set: %llx\n", mac_addr);
			return;
		}
	}

	pparams.is_valid_mac_addr = true;
}

static int qcom_ethqos_probe(struct platform_device *pdev)
{
	struct device_node *np = pdev->dev.of_node;
@@ -2786,6 +2820,9 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
	if (ret)
		goto err_mem;

	/* Read mac address from fuse register */
	read_mac_addr_from_fuse_reg(np);

	/*Initialize Early ethernet to false*/
	ethqos->early_eth_enabled = false;