// SPDX-License-Identifier: GPL-2.0-only /* * ID and revision information for mvebu SoCs * * Copyright (C) 2014 Marvell * * Gregory CLEMENT <gregory.clement@free-electrons.com> * * All the mvebu SoCs have information related to their variant and * revision that can be read from the PCI control register. This is * done before the PCI initialization to avoid any conflict. Once the * ID and revision are retrieved, the mapping is freed.
*/
staticint __init get_soc_id_by_pci(void)
{ struct device_node *np; int ret = 0; void __iomem *pci_base; struct clk *clk; struct device_node *child;
np = of_find_matching_node(NULL, mvebu_pcie_of_match_table); if (!np) return ret;
/* * ID and revision are available from any port, so we * just pick the first one
*/
child = of_get_next_child(np, NULL); if (child == NULL) {
pr_err("cannot get pci node\n");
ret = -ENOMEM; goto clk_err;
}
clk = of_clk_get_by_name(child, NULL); if (IS_ERR(clk)) {
pr_err("cannot get clock\n");
ret = -ENOMEM; goto clk_err;
}
ret = clk_prepare_enable(clk); if (ret) {
pr_err("cannot enable clock\n"); goto clk_err;
}
pci_base = of_iomap(child, 0); if (pci_base == NULL) {
pr_err("cannot map registers\n");
ret = -ENOMEM; goto res_ioremap;
}
res_ioremap: /* * If the PCIe unit is actually enabled and we have PCI * support in the kernel, we intentionally do not release the * reference to the clock. We want to keep it running since * the bootloader does some PCIe link configuration that the * kernel is for now unable to do, and gating the clock would * make us loose this precious configuration.
*/ if (!of_device_is_available(child) || !IS_ENABLED(CONFIG_PCI_MVEBU)) {
clk_disable_unprepare(clk);
clk_put(clk);
}
clk_err:
of_node_put(child);
of_node_put(np);
return ret;
}
staticint __init mvebu_soc_id_init(void)
{
/* * First try to get the ID and the revision by the system * register and use PCI registers only if it is not possible
*/ if (!mvebu_system_controller_get_soc_id(&soc_dev_id, &soc_rev)) {
is_id_valid = true;
pr_info("MVEBU SoC ID=0x%X, Rev=0x%X\n", soc_dev_id, soc_rev); return 0;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.