Commit 3d031378 authored by Rajan Vaja's avatar Rajan Vaja Committed by Michal Simek
Browse files

drivers: Defer probe if firmware is not ready



Driver needs ZynqMP firmware interface to call EEMI
APIs. In case firmware is not ready, dependent drivers
should wait until the firmware is ready.

Signed-off-by: default avatarRajan Vaja <rajan.vaja@xilinx.com>
Signed-off-by: default avatarJolly Shah <jollys@xilinx.com>
Signed-off-by: default avatarMichal Simek <michal.simek@xilinx.com>
parent b9472f7d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -41,8 +41,8 @@ Example of EEMI ops usage:
	int ret;

	eemi_ops = zynqmp_pm_get_eemi_ops();
	if (!eemi_ops)
		return -ENXIO;
	if (IS_ERR(eemi_ops))
		return PTR_ERR(eemi_ops);

	ret = eemi_ops->query_data(qdata, ret_payload);

+2 −2
Original line number Diff line number Diff line
@@ -695,8 +695,8 @@ static int zynqmp_clock_probe(struct platform_device *pdev)
	struct device *dev = &pdev->dev;

	eemi_ops = zynqmp_pm_get_eemi_ops();
	if (!eemi_ops)
		return -ENXIO;
	if (IS_ERR(eemi_ops))
		return PTR_ERR(eemi_ops);

	ret = zynqmp_clk_setup(dev->of_node);

+0 −3
Original line number Diff line number Diff line
@@ -90,9 +90,6 @@ static int process_api_request(u32 pm_id, u64 *pm_api_arg, u32 *pm_api_ret)
	int ret;
	struct zynqmp_pm_query_data qdata = {0};

	if (!eemi_ops)
		return -ENXIO;

	switch (pm_id) {
	case PM_GET_API_VERSION:
		ret = eemi_ops->get_api_version(&pm_api_version);
+10 −1
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@
#include <linux/firmware/xlnx-zynqmp.h>
#include "zynqmp-debug.h"

static const struct zynqmp_eemi_ops *eemi_ops_tbl;

static const struct mfd_cell firmware_devs[] = {
	{
		.name = "zynqmp_power_controller",
@@ -649,7 +651,11 @@ static const struct zynqmp_eemi_ops eemi_ops = {
 */
const struct zynqmp_eemi_ops *zynqmp_pm_get_eemi_ops(void)
{
	return &eemi_ops;
	if (eemi_ops_tbl)
		return eemi_ops_tbl;
	else
		return ERR_PTR(-EPROBE_DEFER);

}
EXPORT_SYMBOL_GPL(zynqmp_pm_get_eemi_ops);

@@ -694,6 +700,9 @@ static int zynqmp_firmware_probe(struct platform_device *pdev)
	pr_info("%s Trustzone version v%d.%d\n", __func__,
		pm_tz_version >> 16, pm_tz_version & 0xFFFF);

	/* Assign eemi_ops_table */
	eemi_ops_tbl = &eemi_ops;

	zynqmp_pm_api_debugfs_init();

	ret = mfd_add_devices(&pdev->dev, PLATFORM_DEVID_NONE, firmware_devs,
+7 −3
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@ struct zynqmp_nvmem_data {
	struct nvmem_device *nvmem;
};

static const struct zynqmp_eemi_ops *eemi_ops;

static int zynqmp_nvmem_read(void *context, unsigned int offset,
			     void *val, size_t bytes)
{
@@ -23,9 +25,7 @@ static int zynqmp_nvmem_read(void *context, unsigned int offset,
	int idcode, version;
	struct zynqmp_nvmem_data *priv = context;

	const struct zynqmp_eemi_ops *eemi_ops = zynqmp_pm_get_eemi_ops();

	if (!eemi_ops || !eemi_ops->get_chipid)
	if (!eemi_ops->get_chipid)
		return -ENXIO;

	ret = eemi_ops->get_chipid(&idcode, &version);
@@ -61,6 +61,10 @@ static int zynqmp_nvmem_probe(struct platform_device *pdev)
	if (!priv)
		return -ENOMEM;

	eemi_ops = zynqmp_pm_get_eemi_ops();
	if (IS_ERR(eemi_ops))
		return PTR_ERR(eemi_ops);

	priv->dev = dev;
	econfig.dev = dev;
	econfig.reg_read = zynqmp_nvmem_read;
Loading