Commit c882f43aefc1be3f45f38a73e4fc2ed41e6fa2da
1 parent
caada879d1
Exists in
smarc_8mm-imx_v2018.03_4.14.98_2.0.0_ga
and in
4 other branches
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> (cherry picked from commit 81dd157fd0ba476c994e95a63515cb65164f1e87)
Showing 1 changed file with 46 additions and 0 deletions Side-by-side Diff
arch/arm/mach-imx/imx8/cpu.c
... | ... | @@ -1818,6 +1818,32 @@ |
1818 | 1818 | } |
1819 | 1819 | } |
1820 | 1820 | |
1821 | +bool check_owned_udevice(struct udevice *dev) | |
1822 | +{ | |
1823 | + int ret; | |
1824 | + sc_rsrc_t resource_id; | |
1825 | + struct ofnode_phandle_args args; | |
1826 | + | |
1827 | + /* Get the resource id from its power-domain */ | |
1828 | + ret = dev_read_phandle_with_args(dev, "power-domains", | |
1829 | + "#power-domain-cells", 0, 0, &args); | |
1830 | + if (ret) { | |
1831 | + printf("no power-domains found\n"); | |
1832 | + return false; | |
1833 | + } | |
1834 | + | |
1835 | + /* Get the owner partition for resource*/ | |
1836 | + resource_id = (sc_rsrc_t)ofnode_read_u32_default(args.node, "reg", SC_R_LAST); | |
1837 | + if (resource_id == SC_R_LAST) { | |
1838 | + printf("Can't find the resource id for udev %s\n", dev->name); | |
1839 | + return false; | |
1840 | + } | |
1841 | + | |
1842 | + debug("udev %s, resource id %d\n", dev->name, resource_id); | |
1843 | + | |
1844 | + return check_owned_resource(resource_id); | |
1845 | +} | |
1846 | + | |
1821 | 1847 | #ifdef CONFIG_IMX_VSERVICE |
1822 | 1848 | struct udevice * board_imx_vservice_find_mu(struct udevice *dev) |
1823 | 1849 | { |
... | ... | @@ -1911,4 +1937,24 @@ |
1911 | 1937 | return NULL; |
1912 | 1938 | } |
1913 | 1939 | #endif |
1940 | + | |
1941 | +/* imx8qxp i2c1 has lots of devices may used by both M4 and A core | |
1942 | +* If A core partition does not own the resource, we will start | |
1943 | +* virtual i2c driver. Otherwise use local i2c driver. | |
1944 | +*/ | |
1945 | +int board_imx_virt_i2c_bind(struct udevice *dev) | |
1946 | +{ | |
1947 | + if (check_owned_udevice(dev)) | |
1948 | + return -ENODEV; | |
1949 | + | |
1950 | + return 0; | |
1951 | +} | |
1952 | + | |
1953 | +int board_imx_lpi2c_bind(struct udevice *dev) | |
1954 | +{ | |
1955 | + if (check_owned_udevice(dev)) | |
1956 | + return 0; | |
1957 | + | |
1958 | + return -ENODEV; | |
1959 | +} |