summaryrefslogtreecommitdiff
path: root/arch/arm/mach-imx/imx8/cpu.c
diff options
context:
space:
mode:
authorYe Li <ye.li@nxp.com>2019-01-30 22:24:15 -0800
committerYe Li <ye.li@nxp.com>2019-02-11 00:07:23 -0800
commit81dd157fd0ba476c994e95a63515cb65164f1e87 (patch)
treebbbd5cb2e7066c33aae439aed68777e40d687188 /arch/arm/mach-imx/imx8/cpu.c
parent4358b4cdfc4752822066d480dd1c10086c211be7 (diff)
MLK-20886-6 imx8qm/qxp: Implement runtime i2c driver binding
When a i2c device is binding with drivers, we check whether current partition ownes the resource. If not owned, the binding to local lpi2c driver will fail, otherwise binding to virtual i2c driver will fail. Signed-off-by: Ye Li <ye.li@nxp.com>
Diffstat (limited to 'arch/arm/mach-imx/imx8/cpu.c')
-rw-r--r--arch/arm/mach-imx/imx8/cpu.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/arch/arm/mach-imx/imx8/cpu.c b/arch/arm/mach-imx/imx8/cpu.c
index 64f4d900c1..50aa463876 100644
--- a/arch/arm/mach-imx/imx8/cpu.c
+++ b/arch/arm/mach-imx/imx8/cpu.c
@@ -1818,6 +1818,32 @@ void disconnect_from_pc(void)
}
}
+bool check_owned_udevice(struct udevice *dev)
+{
+ int ret;
+ sc_rsrc_t resource_id;
+ struct ofnode_phandle_args args;
+
+ /* Get the resource id from its power-domain */
+ ret = dev_read_phandle_with_args(dev, "power-domains",
+ "#power-domain-cells", 0, 0, &args);
+ if (ret) {
+ printf("no power-domains found\n");
+ return false;
+ }
+
+ /* Get the owner partition for resource*/
+ resource_id = (sc_rsrc_t)ofnode_read_u32_default(args.node, "reg", SC_R_LAST);
+ if (resource_id == SC_R_LAST) {
+ printf("Can't find the resource id for udev %s\n", dev->name);
+ return false;
+ }
+
+ debug("udev %s, resource id %d\n", dev->name, resource_id);
+
+ return check_owned_resource(resource_id);
+}
+
#ifdef CONFIG_IMX_VSERVICE
struct udevice * board_imx_vservice_find_mu(struct udevice *dev)
{
@@ -1911,3 +1937,23 @@ void * board_imx_vservice_get_buffer(struct imx_vservice_channel *node, u32 size
return NULL;
}
#endif
+
+/* imx8qxp i2c1 has lots of devices may used by both M4 and A core
+* If A core partition does not own the resource, we will start
+* virtual i2c driver. Otherwise use local i2c driver.
+*/
+int board_imx_virt_i2c_bind(struct udevice *dev)
+{
+ if (check_owned_udevice(dev))
+ return -ENODEV;
+
+ return 0;
+}
+
+int board_imx_lpi2c_bind(struct udevice *dev)
+{
+ if (check_owned_udevice(dev))
+ return 0;
+
+ return -ENODEV;
+}