Add imx8mp video support
v3 cover Add imx8mp video support
In order to display a boot picture or an error message, the i.MX8MP display pipeline must be enabled. The SoC has support for various interfaces (LVDS, HDMI, DSI). The one supported in this series is the standard 4-lane LVDS output. The minimal setup is thus composed of:
* An LCD InterFace (LCDIF) with an AXI/APB interface, generating a pixel stream
* One LVDS Display Bridge (LDB), also named pixel mapper, which receives the pixel stream and route it to one or two (possibly combined) LVDS displays.
* All necessary clocks and power controls coming from the MEDIAMIX control block.
Patch 1 adds a very useful helper to the core in order to grab devices through endpoints instead of being limited to phandles. Video pipelines being often described using graphs endpoints, the introduced helper is used several times in the serires (there are 3 LCDIF, one of them being connected to the LDB, itself having 2 ports).
Patch 2 is a fix which is necessary for this series to work properly, but is way broader than just this use case. In practice, when assigned clocks are defined in the device tree, the clock uclass tries to assign the parents first and then sets them to the correct frequency. This only works if the parents have been enabled themselves. Otherwise we end-up with a non-clocked parent. I believe this is not the intended behavior in general, but more importantly on the i.MX8MP, there are "clock slices" which have pre-requisites in order to be modified and selecting an ungated parent is one of them.
All the other patches progressively build support for the whole video pipeline. Regarding the LCDIF driver, there is already a similar driver for older i.MX SoCs but I didn't manage to get it to work. It was written more than a decade ago while device-model, clocks and others were not yet generically supported. Thus, numerous ad-hoc solutions were implemented, which no longer fit today's requirements. I preferred to add a new "clean" driver instead of modifying the existing one because of the too high risk of breaking these platforms. Once proper clocks/power-domain descriptions will be added to them they might be converted (and tested) to work with the "new" implementation, but going the opposite way felt drawback.
---
Changes in v3:
- Fix a clock name in the imx8mp clock driver (mismatch between Linux
and U-Boot).
- Fixed the Azure tests with extra changes in the test files
and sandbox configurations:
https://dev.azure.com/u-boot/u-boot/_build/results?buildId=10296&view=results
- Link to v2: https://lore.kernel.org/r/20241205-ge-mainline-display-support-v2-0-4683bb4388dc@bootlin.com
Changes in v2:
- Add ISP clocks to avoid harmless errors when shutting down the
pipeline.
- Add power domain refcounting to avoid shutting down a power domain already disabled. This is useful when a device points several times to the same power domain in the DT.
- Ensure the mediamix driver frees all the power domains it got a
reference on.
- Add an in-tree user as requested by Fabio: the EVK.
- Use the same Kconfig prompts as in Linux.
- Add sandbox tests for uclass_get_device_by_endpoint().
- Enclosed media clocks definitions within #if CONFIG_IS_ENABLED()
guards to avoid bloating the SPL and configurations without video support, as Adam and Fabio advised.
- Disable the enabled clocks in the remove path of the mediamix block driver.
- Fix many typos.
- Fix checkpatch warnings.
- Rebase on next.
- Collect tags
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Miquel Raynal (13):
dm: doc: Fix example
dm: core: Add a helper to retrieve devices through graph endpoints
sandbox: Add a fake DSI controller and link it to the panel
test: dm: test-fdt: Add checks for uclass_get_device_by_endpoint()
power-domain: Add refcounting
clk: Ensure the parent clocks are enabled while reparenting
clk: imx8mp: Add media related clocks
imx: power-domain: Describe the i.MX8 MEDIAMIX domain
imx: power-domain: Add support for the MEDIAMIX control block
video: imx: Fix Makefile in order to be able to add other imx drivers
video: imx: Add LDB driver
video: imx: Add LCDIF driver
imx8mp_evk: Enable display support
arch/sandbox/dts/test.dts | 23 ++ configs/imx8mp_evk_defconfig | 7 + configs/sandbox64_defconfig | 1 + configs/sandbox_flattree_defconfig | 1 + doc/develop/driver-model/design.rst | 2 +- drivers/clk/clk-uclass.c | 21 +- drivers/clk/imx/clk-imx8mp.c | 69 +++++ drivers/core/uclass.c | 62 +++++ drivers/firmware/scmi/sandbox-scmi_devices.c | 1 + drivers/power/domain/Kconfig | 7 + drivers/power/domain/Makefile | 1 + drivers/power/domain/imx8m-power-domain.c | 17 ++ drivers/power/domain/imx8mp-mediamix.c | 208 +++++++++++++++ drivers/power/domain/power-domain-uclass.c | 37 ++- drivers/power/domain/sandbox-power-domain-test.c | 1 + drivers/video/Makefile | 2 +- drivers/video/imx/Kconfig | 9 + drivers/video/imx/Makefile | 4 +- drivers/video/imx/lcdif.c | 314 +++++++++++++++++++++++ drivers/video/imx/ldb.c | 251 ++++++++++++++++++ include/dm/uclass.h | 21 ++ include/power-domain.h | 4 +- test/dm/power-domain.c | 2 +- test/dm/test-fdt.c | 20 +- 24 files changed, 1072 insertions(+), 13 deletions(-)
---
base-commit: c498b6cace9e0de45ea12146312f5a6f43a03a9b
change-id: 20241205-ge-mainline-display-support-00cf60fbd2cc
Best regards,
Signature · 1 line
Miquel Raynal <[email protected]>
PATCH v3 1/13 dm: doc: Fix example
.priv_data_size does not exist. I believe the actual structure member was supposed to be .priv_auto.
--- doc/develop/driver-model/design.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
doc/develop/driver-model/design.rst +1 -1
@@ -312,7 +312,7 @@ drivers/demo/demo-shape.c): .name = "demo_shape_drv", .id = UCLASS_DEMO, .ops = &shape_ops, - .priv_data_size = sizeof(struct shape_data), + .priv_auto = sizeof(struct shape_data), };
Signature · 1 line
2.47.0
PATCH v3 2/13 dm: core: Add a helper to retrieve devices through graph endpoints
In reply to Miquel RaynalThere are already several helpers to find a udevice based on its position in a device tree, like getting a child or a node pointed by a phandle, but there was no support for graph endpoints, which are very common in display pipelines.
Add a new helper, named uclass_get_device_by_endpoint() which enters the child graph reprensentation, looks for a specific port, then follows the remote endpoint, and finally retrieves the first parent of the given uclass_id.
This is a very handy and straightforward way to get a bridge or a panel handle.
--- drivers/core/uclass.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++ include/dm/uclass.h | 21 +++++++++++++++++ 2 files changed, 83 insertions(+)
drivers/core/uclass.c +62 -0
@@ -582,6 +582,68 @@ int uclass_get_device_by_phandle(enum uclass_id id, struct udevice *parent, ret =uclass_find_device_by_phandle (id, parent, name, &dev);return uclass_get_device_tail (dev, ret, devp); } + +int uclass_get_device_by_endpoint (enum uclass_id class_id,struct udevice *dev, +u32 ep_idx,struct udevice **devp) +{ +ofnode port =ofnode_null (), ep, remote_ep; +struct udevice *target =NULL ; +u32 remote_phandle; +int ret; + +if (!ep_idx) + port =dev_read_subnode (dev,"port" ); + +if (!ofnode_valid (port)) { +char port_name[32 ]; + + port =dev_read_subnode (dev,"ports" ); +if (!ofnode_valid (port)) { +debug ("%s: no 'port'/'ports' subnode\n" , +dev_read_name (dev)); +return -EINVAL ; + } + +snprintf (port_name,sizeof (port_name),"port@%x" , ep_idx); + port =ofnode_find_subnode (port, port_name); +if (!ofnode_valid (port)) { +debug ("%s: no 'port@%x' subnode\n" , +dev_read_name (dev), ep_idx); +return -EINVAL ; + } + } + + ep =ofnode_find_subnode (port,"endpoint" ); +if (!ofnode_valid (ep)) { +debug ("%s: no 'endpoint' in %s subnode\n" , +ofnode_get_name (port),dev_read_name (dev)); +return -EINVAL ; + } + + ret =ofnode_read_u32 (ep,"remote-endpoint" , &remote_phandle); +if (ret) +return ret; + + remote_ep =ofnode_get_by_phandle (remote_phandle); +if (!ofnode_valid (remote_ep)) +return -EINVAL ; + +while (ofnode_valid (remote_ep)) { + remote_ep =ofnode_get_parent (remote_ep); +debug ("trying subnode: %s\n" ,ofnode_get_name (remote_ep)); +if (!ofnode_valid (remote_ep)) { +debug ("%s: no more remote devices\n" , +ofnode_get_name (remote_ep)); +return -ENODEV ; + } + + ret =uclass_find_device_by_ofnode (class_id, remote_ep, &target); +if (!ret) +break ; + }; + +return uclass_get_device_tail (target, ret, devp); +}#endif /*
include/dm/uclass.h +21 -0
@@ -333,6 +333,27 @@ int uclass_get_device_by_phandle(enum uclass_id id, struct udevice *parent,int uclass_get_device_by_driver (enum uclass_id id,const struct driver *drv,struct udevice **devp); +/** +* uclass_get_device_by_endpoint() - Get a uclass device for a remote endpoint +* +* This searches through the parents of the specified remote endpoint +* for the first device matching the uclass. Said otherwise, this helper +* goes through the graph (endpoint) representation and searches for +* matching devices. Endpoints can be subnodes of the "port" node or +* subnodes of ports identified with a reg property, themselves in a +* "ports" container. +* +* The device is probed to activate it ready for use. +* +* @class_id: uclass ID to look up +* @dev: Device to start from +* @ep_idx: Index of the endpoint to follow, 0 if there is none. +* @target: Returns pointer to the first device matching the expected uclass. +* Return: 0 if OK, -ve on error +*/ +int uclass_get_device_by_endpoint (enum uclass_id class_id,struct udevice *dev, +u32 ep_idx,struct udevice **target); +/** * uclass_first_device() - Get the first device in a uclass *
Signature · 1 line
2.47.0
PATCH v3 3/13 sandbox: Add a fake DSI controller and link it to the panel
In reply to Miquel RaynalUse a graph endpoint representation for that in order to test a new core DM helper going through these properties.
Display pipelines typically include graph endpoints, but the helper is generic and would work with any device type.
--- arch/sandbox/dts/test.dts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
arch/sandbox/dts/test.dts +23 -0
@@ -295,6 +295,23 @@ dsi_host: dsi_host { compatible = "sandbox,dsi-host"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + port@0 { + reg = <0>; + unused_ep: endpoint { + }; + }; + + port@1 { + reg = <1>; + dispc_out1: endpoint { + remote-endpoint = <&panel_to_dispc>; + }; + }; + }; }; a-test {
@@ -1359,6 +1376,12 @@ panel { compatible = "simple-panel"; backlight = <&backlight 0 100>; + + port { + panel_to_dispc: endpoint { + remote-endpoint = <&dispc_out1>; + }; + }; }; scsi {
Signature · 1 line
2.47.0
PATCH v3 4/13 test: dm: test-fdt: Add checks for uclass_get_device_by_endpoint()
In reply to Miquel RaynalThis is a new DM core helper. There is now a graph endpoint representation in the sandbox test DTS, so we can just use it to verify the helper proper behavior.
--- configs/sandbox64_defconfig | 1 + configs/sandbox_flattree_defconfig | 1 + test/dm/test-fdt.c | 20 +++++++++++++++++++- 3 files changed, 21 insertions(+), 1 deletion(-)
configs/sandbox64_defconfig +1 -0
@@ -256,6 +256,7 @@ CONFIG_CONSOLE_TRUETYPE=y CONFIG_CONSOLE_TRUETYPE_CANTORAONE=y CONFIG_I2C_EDID=y CONFIG_VIDEO_SANDBOX_SDL=y +CONFIG_VIDEO_DSI_HOST_SANDBOX=y CONFIG_OSD=y CONFIG_SANDBOX_OSD=y CONFIG_BMP_16BPP=y
configs/sandbox_flattree_defconfig +1 -0
@@ -220,6 +220,7 @@ CONFIG_CONSOLE_TRUETYPE=y CONFIG_CONSOLE_TRUETYPE_CANTORAONE=y CONFIG_I2C_EDID=y CONFIG_VIDEO_SANDBOX_SDL=y +CONFIG_VIDEO_DSI_HOST_SANDBOX=y CONFIG_OSD=y CONFIG_SANDBOX_OSD=y CONFIG_BMP_16BPP=y
test/dm/test-fdt.c +19 -1
@@ -792,7 +792,7 @@ DM_TEST(dm_test_fdt_disable_enable_by_path, UTF_SCAN_PDATA | UTF_SCAN_FDT);/* Test a few uclass phandle functions */ static int dm_test_fdt_phandle (struct unit_test_state *uts) { -struct udevice *back, *dev, *dev2; +struct udevice *back, *dispc, *panel, *dev, *dev2;ut_assertok (uclass_find_first_device (UCLASS_PANEL_BACKLIGHT , &back));ut_assertnonnull (back);
@@ -807,6 +807,24 @@ static int dm_test_fdt_phandle(struct unit_test_state *uts) "power-supply", &dev2));ut_asserteq_ptr (dev, dev2); +/* Test uclass_get_device_by_endpoint() */ +ut_assertok (uclass_find_device_by_name (UCLASS_DSI_HOST ,"dsi_host" , &dispc)); +ut_assertnonnull (dispc); +ut_asserteq (0 ,device_active (dispc)); +ut_assertok (uclass_find_device_by_name (UCLASS_PANEL ,"panel" , &panel)); +ut_assertnonnull (panel); +ut_asserteq (0 ,device_active (panel)); + +ut_asserteq (-ENODEV ,uclass_get_device_by_endpoint (UCLASS_PANEL_BACKLIGHT , dispc,1 , &dev)); +ut_asserteq (-EINVAL ,uclass_get_device_by_endpoint (UCLASS_PANEL , dispc,0 , &dev)); +ut_assertok (uclass_get_device_by_endpoint (UCLASS_PANEL , dispc,1 , &dev)); +ut_asserteq_ptr (panel, dev); + +ut_asserteq (-ENODEV ,uclass_get_device_by_endpoint (UCLASS_PANEL_BACKLIGHT , panel,0 , &dev2)); +ut_asserteq (-EINVAL ,uclass_get_device_by_endpoint (UCLASS_DSI_HOST , panel,1 , &dev2)); +ut_assertok (uclass_get_device_by_endpoint (UCLASS_DSI_HOST , panel,0 , &dev2)); +ut_asserteq_ptr (dispc, dev2); +return 0 ; }DM_TEST (dm_test_fdt_phandle,UTF_SCAN_PDATA |UTF_SCAN_FDT );
Signature · 1 line
2.47.0
PATCH v3 5/13 power-domain: Add refcounting
In reply to Miquel RaynalIt is very surprising that such an uclass, specifically designed to handle resources that may be shared by different devices, is not keeping the count of the number of times a power domain has been enabled/disabled to avoid shutting it down unexpectedly or disabling it several times.
Doing this causes troubles on eg. i.MX8MP because disabling power domains can be done in recursive loops were the same power domain disabled up to 4 times in a row. PGCs seem to have tight FSM internal timings to respect and it is easy to produce a race condition that puts the power domains in an unstable state, leading to ADB400 errors and later crashes in Linux.
CI tests using power domains are slightly updated to make sure the count of on/off calls is even and the results match what we *now* expect.
--- drivers/firmware/scmi/sandbox-scmi_devices.c | 1 + drivers/power/domain/power-domain-uclass.c | 37 ++++++++++++++++++++++-- drivers/power/domain/sandbox-power-domain-test.c | 1 + include/power-domain.h | 4 +-- test/dm/power-domain.c | 2 +- 5 files changed, 40 insertions(+), 5 deletions(-)
drivers/firmware/scmi/sandbox-scmi_devices.c +1 -0
@@ -163,4 +163,5 @@ U_BOOT_DRIVER(sandbox_scmi_devices) = { .priv_auto = sizeof(struct sandbox_scmi_device_priv), .remove = sandbox_scmi_devices_remove, .probe = sandbox_scmi_devices_probe, + .flags = DM_FLAG_DEFAULT_PD_CTRL_OFF, };
drivers/power/domain/power-domain-uclass.c +35 -2
@@ -12,6 +12,10 @@#include <power-domain-uclass.h> #include <dm/device-internal.h> +struct power_domain_priv { +int on_count; +}; +static inline struct power_domain_ops *power_domain_dev_ops (struct udevice *dev) {return (struct power_domain_ops *)dev->driver->ops;
@@ -110,19 +114,47 @@ int power_domain_free(struct power_domain *power_domain)int power_domain_on (struct power_domain *power_domain) {struct power_domain_ops *ops =power_domain_dev_ops (power_domain->dev); +struct power_domain_priv *priv =dev_get_uclass_priv (power_domain->dev); +int ret;debug ("%s(power_domain=%p)\n" , __func__, power_domain); -return ops->on ? ops->on (power_domain) :0 ; +if (priv->on_count++ >0 ) +return 0 ; + + ret = ops->on ? ops->on (power_domain) :0 ; +if (ret) { + priv->on_count--; +return ret; + } + +return 0 ; }int power_domain_off (struct power_domain *power_domain) {struct power_domain_ops *ops =power_domain_dev_ops (power_domain->dev); +struct power_domain_priv *priv =dev_get_uclass_priv (power_domain->dev); +int ret;debug ("%s(power_domain=%p)\n" , __func__, power_domain); -return ops->off ? ops->off (power_domain) :0 ; +if (priv->on_count <=0 ) { +debug ("Power domain %s already off.\n" , power_domain->dev->name); + priv->on_count--; +return 0 ; + } + +if (priv->on_count-- >1 ) +return 0 ; + + ret = ops->off ? ops->off (power_domain) :0 ; +if (ret) { + priv->on_count++; +return ret; + } + +return 0 ; }#if CONFIG_IS_ENABLED (OF_REAL )
@@ -180,4 +212,5 @@ int dev_power_domain_off(struct udevice *dev)UCLASS_DRIVER (power_domain) = { .id =UCLASS_POWER_DOMAIN , .name ="power_domain" , + .per_device_auto =sizeof (struct power_domain_priv ), };
drivers/power/domain/sandbox-power-domain-test.c +1 -0
@@ -51,4 +51,5 @@ U_BOOT_DRIVER(sandbox_power_domain_test) = { .id = UCLASS_MISC, .of_match = sandbox_power_domain_test_ids, .priv_auto = sizeof(struct sandbox_power_domain_test), + .flags = DM_FLAG_DEFAULT_PD_CTRL_OFF, };
include/power-domain.h +2 -2
@@ -147,7 +147,7 @@ static inline int power_domain_free(struct power_domain *power_domain)#endif /** -* power_domain_on - Enable power to a power domain. +* power_domain_on - Enable power to a power domain (with refcounting) * * @power_domain: A power domain struct that was previously successfully * requested by power_domain_get().
@@ -163,7 +163,7 @@ static inline int power_domain_on(struct power_domain *power_domain)#endif /** -* power_domain_off - Disable power to a power domain. +* power_domain_off - Disable power to a power domain (with refcounting) * * @power_domain: A power domain struct that was previously successfully * requested by power_domain_get().
test/dm/power-domain.c +1 -1
@@ -27,7 +27,7 @@ static int dm_test_power_domain(struct unit_test_state *uts)ut_assertok (uclass_get_device_by_name (UCLASS_MISC ,"power-domain-test" , &dev_test)); -ut_asserteq (1 ,sandbox_power_domain_query (dev_power_domain, +ut_asserteq (0 ,sandbox_power_domain_query (dev_power_domain,TEST_POWER_DOMAIN ));ut_assertok (sandbox_power_domain_test_get (dev_test));
Signature · 1 line
2.47.0
Re: [PATCH v3 05/13] power-domain: Add refcounting
Hi Miquel,
Quoted 53 lines · Miquel Raynal
It is very surprising that such an uclass, specifically designed to handle resources that may be shared by different devices, is not keeping the count of the number of times a power domain has been enabled/disabled to avoid shutting it down unexpectedly or disabling it several times.
Doing this causes troubles on eg. i.MX8MP because disabling power domains can be done in recursive loops were the same power domain disabled up to 4 times in a row. PGCs seem to have tight FSM internal timings to respect and it is easy to produce a race condition that puts the power domains in an unstable state, leading to ADB400 errors and later crashes in Linux.
CI tests using power domains are slightly updated to make sure the count of on/off calls is even and the results match what we *now* expect.
Signed-off-by Miquel Raynal <[email protected]>--- drivers/firmware/scmi/sandbox-scmi_devices.c | 1 + drivers/power/domain/power-domain-uclass.c | 37 ++++++++++++++++++++++-- drivers/power/domain/sandbox-power-domain-test.c | 1 + include/power-domain.h | 4 +-- test/dm/power-domain.c | 2 +- 5 files changed, 40 insertions(+), 5 deletions(-)drivers/firmware/scmi/sandbox-scmi_devices.c +1
-0@@ -163,4 +163,5 @@ U_BOOT_DRIVER(sandbox_scmi_devices) = { .priv_auto = sizeof(struct sandbox_scmi_device_priv), .remove = sandbox_scmi_devices_remove, .probe = sandbox_scmi_devices_probe, + .flags = DM_FLAG_DEFAULT_PD_CTRL_OFF, };drivers/power/domain/power-domain-uclass.c +4
-0@@ -12,6 +12,10 @@#include <power-domain-uclass.h> #include <dm/device-internal.h> +struct power_domain_priv { +int on_count; +}; +static inline struct power_domain_ops *power_domain_dev_ops (struct udevice *dev) {return (struct power_domain_ops *)dev->driver->ops;@@ -110,19 +114,47 @@ int power_domain_free(struct power_domain *power_domain)int power_domain_on (struct power_domain *power_domain)
drivers/power/domain/power-domain-uclass.c int power_domain_free(struct power_domain *power_domain) · line 123
Quoted 10 lines
drivers/power/domain/power-domain-uclass.c +4
-1{struct power_domain_ops *ops =power_domain_dev_ops (power_domain->dev); +struct power_domain_priv *priv =dev_get_uclass_priv (power_domain->dev); +int ret;debug ("%s(power_domain=%p)\n" , __func__, power_domain); -return ops->on ? ops->on (power_domain) :0 ; +if (priv->on_count++ >0 ) +return 0 ;
-EALREADY
Quoted 17 lines
drivers/power/domain/power-domain-uclass.c +10
-0+ + ret = ops->on ? ops->on (power_domain) :0 ; +if (ret) { + priv->on_count--; +return ret; + } + +return 0 ; }int power_domain_off (struct power_domain *power_domain) {struct power_domain_ops *ops =power_domain_dev_ops (power_domain->dev); +struct power_domain_priv *priv =dev_get_uclass_priv (power_domain->dev); +int ret;debug ("%s(power_domain=%p)\n" , __func__, power_domain);
drivers/power/domain/power-domain-uclass.c int power_domain_free(struct power_domain *power_domain) · line 149
Quoted 10 lines
drivers/power/domain/power-domain-uclass.c +8
-1-return ops->off ? ops->off (power_domain) :0 ; +if (priv->on_count <=0 ) { +debug ("Power domain %s already off.\n" , power_domain->dev->name); + priv->on_count--; +return 0 ; + } + +if (priv->on_count-- >1 ) +return 0 ;
-EBUSY
See how the regulator uclass does it.
Quoted 64 lines
drivers/power/domain/power-domain-uclass.c +9
-0+ + ret = ops->off ? ops->off (power_domain) :0 ; +if (ret) { + priv->on_count++; +return ret; + } + +return 0 ; }#if CONFIG_IS_ENABLED (OF_REAL )@@ -180,4 +212,5 @@ int dev_power_domain_off(struct udevice *dev)UCLASS_DRIVER (power_domain) = { .id =UCLASS_POWER_DOMAIN , .name ="power_domain" , + .per_device_auto =sizeof (struct power_domain_priv ), };drivers/power/domain/sandbox-power-domain-test.c +1
-0@@ -51,4 +51,5 @@ U_BOOT_DRIVER(sandbox_power_domain_test) = { .id = UCLASS_MISC, .of_match = sandbox_power_domain_test_ids, .priv_auto = sizeof(struct sandbox_power_domain_test), + .flags = DM_FLAG_DEFAULT_PD_CTRL_OFF, };include/power-domain.h +2
-2@@ -147,7 +147,7 @@ static inline int power_domain_free(struct power_domain *power_domain)#endif /** -* power_domain_on - Enable power to a power domain. +* power_domain_on - Enable power to a power domain (with refcounting) * * @power_domain: A power domain struct that was previously successfully * requested by power_domain_get(). @@ -163,7 +163,7 @@ static inline int power_domain_on(struct power_domain *power_domain)#endif /** -* power_domain_off - Disable power to a power domain. +* power_domain_off - Disable power to a power domain (with refcounting) * * @power_domain: A power domain struct that was previously successfully * requested by power_domain_get(). test/dm/power-domain.c +1
-2@@ -27,7 +27,7 @@ static int dm_test_power_domain(struct unit_test_state *uts)ut_assertok (uclass_get_device_by_name (UCLASS_MISC ,"power-domain-test" , &dev_test)); -ut_asserteq (1 ,sandbox_power_domain_query (dev_power_domain, +ut_asserteq (0 ,sandbox_power_domain_query (dev_power_domain,TEST_POWER_DOMAIN ));ut_assertok (sandbox_power_domain_test_get (dev_test)); --
Quoted 2 lines
2.47.0
Regards,
SImon
Re: [PATCH v3 05/13] power-domain: Add refcounting
Hello Simon,
Quoted 2 lines
Quoted 2 lines
int
power_domain_on(struct power_domain *power_domain){
...
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (priv->on_count++ > 0) + return 0;
-EALREADY
...
Quoted 2 lines
Quoted 2 lines
int
power_domain_off(struct power_domain *power_domain){
...
Quoted 6 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (priv->on_count-- > 1) + return 0;
-EBUSYSee how the regulator uclass does it.
I really does not understand why we would like to do that.
It is perfectly normal operation to call power_domain_on/off() on the same power domain several times in a row and there is no reason to return an error code. It is quite the opposite, the main reason for power domains is to act like shared regulators. Se while a regulator has one user and doing the same action on it several times does not make much sense and can be reported, that is not how power domains have been thought about in the first place.
Hence, I do not agree with returning error codes in these situations, they are misleading and they would have to be ignored anyway.
Thanks,
Miquèl
Re: [PATCH v3 05/13] power-domain: Add refcounting
Hi Miquel,
Quoted 29 lines · Miquel Raynal
Hello Simon,
Quoted 2 lines
Quoted 2 lines
int
power_domain_on(struct power_domain *power_domain){...
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (priv->on_count++ > 0) + return 0;
-EALREADY...
Quoted 2 lines
Quoted 2 lines
int
power_domain_off(struct power_domain *power_domain){...
Quoted 6 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (priv->on_count-- > 1) + return 0;
-EBUSYSee how the regulator uclass does it.
I really does not understand why we would like to do that.
Quoted 7 lines
It is perfectly normal operation to call power_domain_on/off() on the same power domain several times in a row and there is no reason to return an error code. It is quite the opposite, the main reason for power domains is to act like shared regulators. Se while a regulator has one user and doing the same action on it several times does not make much sense and can be reported, that is not how power domains have been thought about in the first place.
I am not aware of any difference between these two subsystems. If we want a power domain to actually turn off, how many times do we need to call power_domain_off()? The function silently does nothing in many cases, so it is not deterministic. In the case where we *actually* want to turn the power domain off, we are at a loss as to what code to write.
Quoted 4 lines
Hence, I do not agree with returning error codes in these situations, they are misleading and they would have to be ignored anyway.
How about creating a power_domain_off_if_allowed() or power_domain_soft_off/on() or power_domain_req_off (for request)?
Regards,
SImon
Re: [PATCH v3 05/13] power-domain: Add refcounting
Hi Simon,
Quoted 40 lines · Simon Glass
Hi Miquel,
Quoted 29 lines · Miquel Raynal
Hello Simon,
Quoted 2 lines
Quoted 2 lines
int
power_domain_on(struct power_domain *power_domain){...
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (priv->on_count++ > 0) + return 0;
-EALREADY...
Quoted 2 lines
Quoted 2 lines
int
power_domain_off(struct power_domain *power_domain){...
Quoted 6 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (priv->on_count-- > 1) + return 0;
-EBUSYSee how the regulator uclass does it.
I really does not understand why we would like to do that.
Quoted 7 lines
It is perfectly normal operation to call power_domain_on/off() on the same power domain several times in a row and there is no reason to return an error code. It is quite the opposite, the main reason for power domains is to act like shared regulators. Se while a regulator has one user and doing the same action on it several times does not make much sense and can be reported, that is not how power domains have been thought about in the first place.
Quoted 1 line
I am not aware of any difference between these two subsystems.
Actually you're right on this point, the regulator API works like the pmdomain one. I had a look: it always returns 0, no matter the state of the regulator after the operation (as long as there is no error of course).
Quoted 3 lines
If we
want a power domain to actually turn off, how many times do we need to callpower_domain_off()?
We do not? It is why I add refcounting, if a power domain has 2 consumers, each consumer says whether it needs the power domain to be on or off and the core will handle, but in no case they should force it's state.
Quoted 2 lines
The function silently does nothing in many cases, so it is not deterministic.
It is fully deterministic, as long as consumers call power_on/off evenly (and this is already what we request in U-Boot).
Quoted 10 lines
In the case where we *actually*
want to turn the power domain off, we are at a loss as to what code to write.Quoted 3 lines
Hence, I do not agree with returning error codes in these situations, they are misleading and they would have to be ignored anyway.
How about creating a
power_domain_off_if_allowed()or power_domain_soft_off/on() orpower_domain_req_off(for request)?
The power domain logic has a hardware reality in many SoCs but is also a software concept that is shared with Linux. Changing the semantics in U-Boot would be very misleading and if my understanding is correct, this approach would be new.
If you really want a way to track the state of the power domain, however, I can maybe add a helper returning its state, ie:
bool power_domain_is_on(domain)
Would that work?
Thanks,
Miquèl
Re: [PATCH v3 05/13] power-domain: Add refcounting
Hi Miquel,
Quoted 45 lines · Miquel Raynal
Hi Simon,
Quoted 40 lines · Simon Glass
Hi Miquel,
Quoted 36 lines · Miquel Raynal
Hello Simon,
Quoted 2 lines
Quoted 2 lines
int
power_domain_on(struct power_domain *power_domain){...
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (priv->on_count++ > 0) + return 0;
-EALREADY...
Quoted 2 lines
Quoted 2 lines
int
power_domain_off(struct power_domain *power_domain){...
Quoted 6 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (priv->on_count-- > 1) + return 0;
-EBUSYSee how the regulator uclass does it.
I really does not understand why we would like to do that.
It is perfectly normal operation to call power_domain_on/off() on the same power domain several times in a row and there is no reason to return an error code. It is quite the opposite, the main reason for power domains is to act like shared regulators. Se while a regulator has one user and doing the same action on it several times does not make much sense and can be reported, that is not how power domains have been thought about in the first place.
Quoted 6 lines
Quoted 1 line
I am not aware of any difference between these two subsystems.
Actually you're right on this point, the regulator API works like the pmdomain one. I had a look: it always returns 0, no matter the state of the regulator after the operation (as long as there is no error of course).
You can see dm_test_power_regulator_set_enable_if_allowed() for a test that relates to this.
Quoted 9 lines
Quoted 4 lines
If we
want a power domain to actually turn off, how many times do we need to callpower_domain_off()?We do not? It is why I add refcounting, if a power domain has 2 consumers, each consumer says whether it needs the power domain to be on or off and the core will handle, but in no case they should force it's state.
This is a bootloader, so we do sometimes need to force something off, or on.
Quoted 6 lines
Quoted 3 lines
The function silently does nothing in many cases, so it is not deterministic.
It is fully deterministic, as long as consumers call power_on/off evenly (and this is already what we request in U-Boot).
But I foresee people setting up power domains in board code, not drivers. My concern is that this is hiding the real state.
Quoted 9 lines
Quoted 9 lines
In the case where we *actually*
want to turn the power domain off, we are at a loss as to what code to write.Quoted 3 lines
Hence, I do not agree with returning error codes in these situations, they are misleading and they would have to be ignored anyway.
Quoted 7 lines
Quoted 2 lines
How about creating a
power_domain_off_if_allowed()or power_domain_soft_off/on() orpower_domain_req_off(for request)?The power domain logic has a hardware reality in many SoCs but is also a software concept that is shared with Linux. Changing the semantics in U-Boot would be very misleading and if my understanding is correct, this approach would be new.
Yes this is quite a strong argument. Can you point me to the equivalent API in Linux? I see pm_domain but not the same as U-Boot
Quoted 7 lines
If you really want a way to track the state of the power domain, however, I can maybe add a helper returning its state, ie:
bool
power_domain_is_on(domain)Would that work?
Not really. We should have an API which returns -EALREADY or -EBUSY based on the ref counts.
But yes, we can change the naming, so that this 'deterministic' ones have a different name, with the current names used for your ref-counting one. Then the ref-counting one is a thin layer on top of the deterministic one.
Regards,
Simon
Re: [PATCH v3 05/13] power-domain: Add refcounting
Hi Simon,
Quoted 11 lines
Quoted 8 lines
Quoted 3 lines
If we
want a power domain to actually turn off, how many times do we need to callpower_domain_off()?We do not? It is why I add refcounting, if a power domain has 2 consumers, each consumer says whether it needs the power domain to be on or off and the core will handle, but in no case they should force it's state.
This is a bootloader, so we do sometimes need to force something off, or on.
This, I do understand.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
The function silently does nothing in many cases, so it is not deterministic.
It is fully deterministic, as long as consumers call power_on/off evenly (and this is already what we request in U-Boot).
But I foresee people setting up power domains in board code, not drivers. My concern is that this is hiding the real state.
Setting up power domains in board code is drawback. It is legacy behaviour, people should switch to the device model (ie. using a proper DT description) and stop messing around with board files. It's been like 5 years since U-Boot forced people to transition, I wouldn't feel bad if these boards were no longer behaving like expected (mind there are very little chances this will break anything, as the kernel is supposed to re-init these domains anyway).
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
In the case where we *actually*
want to turn the power domain off, we are at a loss as to what code to write.Quoted 3 lines
Hence, I do not agree with returning error codes in these situations, they are misleading and they would have to be ignored anyway.
How about creating a
power_domain_off_if_allowed()or power_domain_soft_off/on() orpower_domain_req_off(for request)?
Quoted 7 lines
Quoted 4 lines
The power domain logic has a hardware reality in many SoCs but is also a software concept that is shared with Linux. Changing the semantics in U-Boot would be very misleading and if my understanding is correct, this approach would be new.
Yes this is quite a strong argument. Can you point me to the equivalent API in Linux? I see
pm_domainbut not the same as U-Boot
Yes, pmdomain (former genpd if I get it correctly), how are they different? From my point of view it is the same. The same devices are supported. So why would we want the API to be different?
Quoted 5 lines
Quoted 5 lines
If you really want a way to track the state of the power domain, however, I can maybe add a helper returning its state, ie:
bool
power_domain_is_on(domain)
Quoted 7 lines
Quoted 1 line
Would that work?
Not really. We should have an API which returns
-EALREADYor-EBUSYbased on the ref counts. But yes, we can change the naming, so that this 'deterministic' ones have a different name, with the current names used for your ref-counting one. Then the ref-counting one is a thin layer on top of the deterministic one.
Honestly, I am not convinced, but I will anyway assume we need a way to force a domain off. There is no need to force a power domain on however, as after power_domain_on(), the power domain cannot be off (except error condition of course).
So I'll add a helper to force power off. It will be called power_domain_off_force() and be preceded with a comment stating that this is not the standard approach, to guide people towards the refcounted helper instead.
Would this address your request?
Thanks,
Miquèl
Re: [PATCH v3 05/13] power-domain: Add refcounting
Hi Miquel,
Quoted 26 lines · Miquel Raynal
Hi Simon,
Quoted 11 lines
Quoted 8 lines
Quoted 3 lines
If we
want a power domain to actually turn off, how many times do we need to callpower_domain_off()?We do not? It is why I add refcounting, if a power domain has 2 consumers, each consumer says whether it needs the power domain to be on or off and the core will handle, but in no case they should force it's state.
This is a bootloader, so we do sometimes need to force something off, or on.
This, I do understand.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
The function silently does nothing in many cases, so it is not deterministic.
It is fully deterministic, as long as consumers call power_on/off evenly (and this is already what we request in U-Boot).
But I foresee people setting up power domains in board code, not drivers. My concern is that this is hiding the real state.
Quoted 7 lines
Setting up power domains in board code is drawback. It is legacy behaviour, people should switch to the device model (ie. using a proper DT description) and stop messing around with board files. It's been like 5 years since U-Boot forced people to transition, I wouldn't feel bad if these boards were no longer behaving like expected (mind there are very little chances this will break anything, as the kernel is supposed to re-init these domains anyway).
While I agree with you, the message is not fully landing, certainly not in SPL where there are code-size constraints.
Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
Quoted 11 lines
In the case where we *actually*
want to turn the power domain off, we are at a loss as to what code to write.Quoted 3 lines
Hence, I do not agree with returning error codes in these situations, they are misleading and they would have to be ignored anyway.
How about creating a
power_domain_off_if_allowed()or power_domain_soft_off/on() orpower_domain_req_off(for request)?The power domain logic has a hardware reality in many SoCs but is also a software concept that is shared with Linux. Changing the semantics in U-Boot would be very misleading and if my understanding is correct, this approach would be new.
Quoted 6 lines
Quoted 2 lines
Yes this is quite a strong argument. Can you point me to the equivalent API in Linux? I see
pm_domainbut not the same as U-BootYes, pmdomain (former genpd if I get it correctly), how are they different? From my point of view it is the same. The same devices are supported. So why would we want the API to be different?
But can you please point me to the API? I am seeing struct generic_pm_domain, which is uncommented, so it isn't clear what the power_off() and power_on() functions actually do. Perhaps they work differently from what you think?
Quoted 19 lines
Quoted 6 lines
Quoted 6 lines
If you really want a way to track the state of the power domain, however, I can maybe add a helper returning its state, ie:
bool
power_domain_is_on(domain)Quoted 7 lines
Quoted 1 line
Would that work?
Not really. We should have an API which returns
-EALREADYor-EBUSYbased on the ref counts. But yes, we can change the naming, so that this 'deterministic' ones have a different name, with the current names used for your ref-counting one. Then the ref-counting one is a thin layer on top of the deterministic one.Honestly, I am not convinced, but I will anyway assume we need a way to force a domain off. There is no need to force a power domain on however, as after
power_domain_on(), the power domain cannot be off (except error condition of course).
Quoted 6 lines
So I'll add a helper to force power off. It will be called
power_domain_off_force()and be preceded with a comment stating that this is not the standard approach, to guide people towards the refcounted helper instead.Would this address your request?
I believe it would be better to have a 'low-level' function which handles the refcounting and returns -EALREADY or -EBUSY if it does nothing, with your 'Linux' functions sitting above that. You can put any comment you like on the low-level function.
The idea of 'forcing' something just seems odd to me. I imagine people would call that just to be sure :-)
Regards,
Simon
Re: [PATCH v3 05/13] power-domain: Add refcounting
Hi Simon,
Quoted 37 lines · Simon Glass
Hi Miquel,
Quoted 26 lines · Miquel Raynal
Hi Simon,
Quoted 11 lines
Quoted 8 lines
Quoted 3 lines
If we
want a power domain to actually turn off, how many times do we need to callpower_domain_off()?We do not? It is why I add refcounting, if a power domain has 2 consumers, each consumer says whether it needs the power domain to be on or off and the core will handle, but in no case they should force it's state.
This is a bootloader, so we do sometimes need to force something off, or on.
This, I do understand.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
The function silently does nothing in many cases, so it is not deterministic.
It is fully deterministic, as long as consumers call power_on/off evenly (and this is already what we request in U-Boot).
But I foresee people setting up power domains in board code, not drivers. My concern is that this is hiding the real state.
Quoted 7 lines
Setting up power domains in board code is drawback. It is legacy behaviour, people should switch to the device model (ie. using a proper DT description) and stop messing around with board files. It's been like 5 years since U-Boot forced people to transition, I wouldn't feel bad if these boards were no longer behaving like expected (mind there are very little chances this will break anything, as the kernel is supposed to re-init these domains anyway).
Quoted 2 lines
While I agree with you, the message is not fully landing, certainly not in SPL where there are code-size constraints.
I don't think the SPL is a problem here? I consider broken a board file with one main function calling enable() twice on the same domain and disable() only once. Although I am fine implementing a "force power off", I still consider this is not a correct approach.
Quoted 19 lines
Quoted 19 lines
Quoted 18 lines
Quoted 8 lines
Quoted 8 lines
In the case where we *actually*
want to turn the power domain off, we are at a loss as to what code to write.Quoted 3 lines
Hence, I do not agree with returning error codes in these situations, they are misleading and they would have to be ignored anyway.
Quoted 7 lines
Quoted 2 lines
How about creating a
power_domain_off_if_allowed()or power_domain_soft_off/on() orpower_domain_req_off(for request)?The power domain logic has a hardware reality in many SoCs but is also a software concept that is shared with Linux. Changing the semantics in U-Boot would be very misleading and if my understanding is correct, this approach would be new.
Yes this is quite a strong argument. Can you point me to the equivalent API in Linux? I see
pm_domainbut not the same as U-Boot
Quoted 8 lines
Quoted 3 lines
Yes, pmdomain (former genpd if I get it correctly), how are they different? From my point of view it is the same. The same devices are supported. So why would we want the API to be different?
But can you please point me to the API? I am seeing struct
generic_pm_domain, which is uncommented, so it isn't clear what thepower_off()andpower_on()functions actually do. Perhaps they work differently from what you think?
->power_on() and ->power_off() perform a state transition, like you would expect. But these callbacks are not supposed to be called directly, they are typically called in the genpd_power_on/off() helpers (through _genpd_power_on/off()), see below.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines
If you really want a way to track the state of the power domain, however, I can maybe add a helper returning its state, ie:
bool
power_domain_is_on(domain)Would that work?
Not really. We should have an API which returns
-EALREADYor-EBUSYbased on the ref counts.
In Linux, we do not return -EALREADY if the refcount of a power domain indicates it is already on when powering up:
https://elixir.bootlin.com/linux/v6.12.6/source/drivers/pmdomain/core.c#L922
However, while we do return -EBUSY when turning it off if there are children still enabled,
(https://elixir.bootlin.com/linux/v6.12.6/source/drivers/pmdomain/core.c#L848)
this function is not exposed and there is not a single caller that actually checks the return code. As a matter of fact, disabling the power domains is mostly done asynchronously anyway in a work queue that is supposed to "try" disabling the unused domains:
https://elixir.bootlin.com/linux/v6.12.6/source/drivers/pmdomain/core.c#L2890
So in the end, consumers just do not care about the final status of the domain, and they are unaware of it.
Please note that most of the handling of the domains is abstracted through Runtime PM handling where, again, the return value is never forwarded to the device drivers.
Quoted 17 lines
Quoted 10 lines
Quoted 4 lines
But yes, we can change the naming, so that
this 'deterministic' ones have a different name, with the current names used for your ref-counting one. Then the ref-counting one is a thin layer on top of the deterministic one.Honestly, I am not convinced, but I will anyway assume we need a way to force a domain off. There is no need to force a power domain on however, as after
power_domain_on(), the power domain cannot be off (except error condition of course).Quoted 6 lines
So I'll add a helper to force power off. It will be called
power_domain_off_force()and be preceded with a comment stating that this is not the standard approach, to guide people towards the refcounted helper instead.Would this address your request?
Quoted 7 lines
I believe it would be better to have a 'low-level' function which handles the refcounting and returns
-EALREADYor-EBUSYif it does nothing, with your 'Linux' functions sitting above that. You can put any comment you like on the low-level function.The idea of 'forcing' something just seems odd to me. I imagine people would call that just to be sure :-)
I am okay having two levels, one returning statuses and the other one hiding them. After some time if nobody complained nor used the low-level one, we can certainly merge them. So I would propose something like:
int power_domain_on_low_level()
{
//refcount handling, power_on() if needed
}static inline int power_domain_on(pd) {
int ret = power_domain_on_low_level(pd);
if (ret == -EBUSY || ret == -EALREADY)
ret = 0;
return ret;
}Would that work for you?
Thanks,
Miquèl
Re: [PATCH v3 05/13] power-domain: Add refcounting
Hi Miquel,
Quoted 146 lines · Miquel Raynal
Hi Simon,
Quoted 37 lines · Simon Glass
Hi Miquel,
Quoted 26 lines · Miquel Raynal
Hi Simon,
Quoted 11 lines
Quoted 8 lines
Quoted 3 lines
If we
want a power domain to actually turn off, how many times do we need to callpower_domain_off()?We do not? It is why I add refcounting, if a power domain has 2 consumers, each consumer says whether it needs the power domain to be on or off and the core will handle, but in no case they should force it's state.
This is a bootloader, so we do sometimes need to force something off, or on.
This, I do understand.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
The function silently does nothing in many cases, so it is not deterministic.
It is fully deterministic, as long as consumers call power_on/off evenly (and this is already what we request in U-Boot).
But I foresee people setting up power domains in board code, not drivers. My concern is that this is hiding the real state.
Quoted 7 lines
Setting up power domains in board code is drawback. It is legacy behaviour, people should switch to the device model (ie. using a proper DT description) and stop messing around with board files. It's been like 5 years since U-Boot forced people to transition, I wouldn't feel bad if these boards were no longer behaving like expected (mind there are very little chances this will break anything, as the kernel is supposed to re-init these domains anyway).
Quoted 2 lines
While I agree with you, the message is not fully landing, certainly not in SPL where there are code-size constraints.
I don't think the SPL is a problem here? I consider broken a board file with one main function calling
enable()twice on the same domain anddisable()only once. Although I am fine implementing a "force power off", I still consider this is not a correct approach.Quoted 19 lines
Quoted 19 lines
Quoted 18 lines
Quoted 8 lines
Quoted 8 lines
In the case where we *actually*
want to turn the power domain off, we are at a loss as to what code to write.Quoted 3 lines
Hence, I do not agree with returning error codes in these situations, they are misleading and they would have to be ignored anyway.
Quoted 7 lines
Quoted 2 lines
How about creating a
power_domain_off_if_allowed()or power_domain_soft_off/on() orpower_domain_req_off(for request)?The power domain logic has a hardware reality in many SoCs but is also a software concept that is shared with Linux. Changing the semantics in U-Boot would be very misleading and if my understanding is correct, this approach would be new.
Yes this is quite a strong argument. Can you point me to the equivalent API in Linux? I see
pm_domainbut not the same as U-BootQuoted 8 lines
Quoted 3 lines
Yes, pmdomain (former genpd if I get it correctly), how are they different? From my point of view it is the same. The same devices are supported. So why would we want the API to be different?
But can you please point me to the API? I am seeing struct
generic_pm_domain, which is uncommented, so it isn't clear what thepower_off()andpower_on()functions actually do. Perhaps they work differently from what you think?->power_on() and ->power_off() perform a state transition, like you would expect. But these callbacks are not supposed to be called directly, they are typically called in the genpd_power_on/off() helpers (through _genpd_power_on/off()), see below.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines
If you really want a way to track the state of the power domain, however, I can maybe add a helper returning its state, ie:
bool
power_domain_is_on(domain)Would that work?
Not really. We should have an API which returns
-EALREADYor-EBUSYbased on the ref counts.In Linux, we do not return
-EALREADYif the refcount of a power domain indicates it is already on when powering up:
https://elixir.bootlin.com/linux/v6.12.6/source/drivers/pmdomain/core.c#L922However, while we do return
-EBUSYwhen turning it off if there are children still enabled,
(https://elixir.bootlin.com/linux/v6.12.6/source/drivers/pmdomain/core.c#L848)
this function is not exposed and there is not a single caller that actually checks the return code. As a matter of fact, disabling the power domains is mostly done asynchronously anyway in a work queue that is supposed to "try" disabling the unused domains:
https://elixir.bootlin.com/linux/v6.12.6/source/drivers/pmdomain/core.c#L2890
So in the end, consumers just do not care about the final status of the domain, and they are unaware of it.Please note that most of the handling of the domains is abstracted through Runtime PM handling where, again, the return value is never forwarded to the device drivers.
Quoted 17 lines
Quoted 10 lines
Quoted 4 lines
But yes, we can change the naming, so that
this 'deterministic' ones have a different name, with the current names used for your ref-counting one. Then the ref-counting one is a thin layer on top of the deterministic one.Honestly, I am not convinced, but I will anyway assume we need a way to force a domain off. There is no need to force a power domain on however, as after
power_domain_on(), the power domain cannot be off (except error condition of course).Quoted 6 lines
So I'll add a helper to force power off. It will be called
power_domain_off_force()and be preceded with a comment stating that this is not the standard approach, to guide people towards the refcounted helper instead.Would this address your request?
Quoted 7 lines
I believe it would be better to have a 'low-level' function which handles the refcounting and returns
-EALREADYor-EBUSYif it does nothing, with your 'Linux' functions sitting above that. You can put any comment you like on the low-level function.The idea of 'forcing' something just seems odd to me. I imagine people would call that just to be sure :-)
I am okay having two levels, one returning statuses and the other one hiding them. After some time if nobody complained nor used the low-level one, we can certainly merge them. So I would propose something like:
int
power_domain_on_low_level(){ //refcount handling, power_on() if needed }
Quoted 8 lines
static inline int power_domain_on(pd) { int ret = power_domain_on_low_level(pd); if (ret == -EBUSY || ret == -EALREADY) ret = 0; return ret; }Would that work for you?
Yes, that's perfect.
Regards,
Simon
Re: [PATCH v3 05/13] power-domain: Add refcounting
Hi Simon,
Cheers,
Miquèl
PATCH v3 6/13 clk: Ensure the parent clocks are enabled while reparenting
In reply to Miquel RaynalReparenting a clock C with a new parent P means that C will only continue clocking if P is already clocking when the mux is updated. In case the parent is currently disabled, failures (stalls) are likely to happen.
This is exactly what happens on i.MX8 when enabling the video pipeline. We tell LCDIF clocks to use the VIDEO PLL as input, while the VIDEO PLL is currently off. This all happens as part of the assigned-clocks handling procedure, where the reparenting happens before the enable() calls. Enabling the parents as part of the reparenting procedure seems sane and also matches the logic applied in other parts of the CCM.
--- drivers/clk/clk-uclass.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
drivers/clk/clk-uclass.c +17 -4
@@ -593,14 +593,27 @@ int clk_set_parent(struct clk *clk, struct clk *parent)if (!ops->set_parent)return -ENOSYS ; - ret = ops->set_parent (clk, parent); -if (ret) + ret =clk_enable (parent); +if (ret) { +printf ("Cannot enable parent %s\n" , parent->dev->name);return ret; + } -if (CONFIG_IS_ENABLED (CLK_CCF )) + ret = ops->set_parent (clk, parent); +if (ret) { +clk_disable (parent); +return ret; + } + +if (CONFIG_IS_ENABLED (CLK_CCF )) { ret =device_reparent (clk->dev, parent->dev); +if (ret) { +clk_disable (parent); +return ret; + } + } -return ret; +return 0 ; }int clk_enable (struct clk *clk)
Signature · 1 line
2.47.0
PATCH v3 7/13 clk: imx8mp: Add media related clocks
In reply to Miquel RaynalThese are all the clocks needed to get an LCD panel working, going through one of the LCDIF and the LDB. The media AXI and APB clocks are also described.
--- drivers/clk/imx/clk-imx8mp.c | 69 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+)
drivers/clk/imx/clk-imx8mp.c +69 -0
@@ -14,7 +14,14 @@#include "clk.h" +#if CONFIG_IS_ENABLED (VIDEO ) +static u32 share_count_media; +#endif +static const char *const pll_ref_sels[] = {"clock-osc-24m" ,"dummy" ,"dummy" ,"dummy" , }; +#if CONFIG_IS_ENABLED (VIDEO ) +static const char *const video_pll1_bypass_sels[] = {"video_pll1" ,"video_pll1_ref_sel" , }; +#endif static const char *const dram_pll_bypass_sels[] = {"dram_pll" ,"dram_pll_ref_sel" , };static const char *const arm_pll_bypass_sels[] = {"arm_pll" ,"arm_pll_ref_sel" , };static const char *const sys_pll1_bypass_sels[] = {"sys_pll1" ,"sys_pll1_ref_sel" , };
@@ -31,6 +38,12 @@ static const char * const imx8mp_hsio_axi_sels[] = {"clock-osc-24m", "sys_pll2_5"sys_pll2_100m" ,"sys_pll2_200m" ,"clk_ext2" , "clk_ext4", "audio_pll2_out", }; +#if CONFIG_IS_ENABLED (VIDEO ) +static const char *const imx8mp_media_isp_sels[] = {"clock-osc-24m" ,"sys_pll2_1000m" ,"sys_pll1_800m" , +"sys_pll3_out" ,"sys_pll1_400m" ,"audio_pll2_out" , +"clk_ext1" ,"sys_pll2_500m" , }; +#endif +static const char *const imx8mp_main_axi_sels[] = {"clock-osc-24m" ,"sys_pll2_333m" ,"sys_pll1_800m" ,"sys_pll2_250m" ,"sys_pll2_1000m" ,"audio_pll1_out" ,"video_pll1_out" ,"sys_pll1_100m" ,};
@@ -43,6 +56,16 @@ static const char * const imx8mp_nand_usdhc_sels[] = {"clock-osc-24m", "sys_pll1"sys_pll2_200m" ,"sys_pll1_133m" ,"sys_pll3_out" , "sys_pll2_250m", "audio_pll1_out", }; +#if CONFIG_IS_ENABLED (VIDEO ) +static const char *const imx8mp_media_axi_sels[] = {"clock-osc-24m" ,"sys_pll2_1000m" ,"sys_pll1_800m" , +"sys_pll3_out" ,"sys_pll1_40m" ,"audio_pll2_out" , +"clk_ext1" ,"sys_pll2_500m" , }; + +static const char *const imx8mp_media_apb_sels[] = {"clock-osc-24m" ,"sys_pll2_125m" ,"sys_pll1_800m" , +"sys_pll3_out" ,"sys_pll1_40m" ,"audio_pll2_out" , +"clk_ext1" ,"sys_pll1_133m" , }; +#endif +static const char *const imx8mp_noc_sels[] = {"clock-osc-24m" ,"sys_pll1_800m" ,"sys_pll3_out" ,"sys_pll2_1000m" ,"sys_pll2_500m" ,"audio_pll1_out" ,"video_pll1_out" ,"audio_pll2_out" , };
@@ -175,6 +198,17 @@ static const char * const imx8mp_usdhc3_sels[] = {"clock-osc-24m", "sys_pll1_400"sys_pll2_500m" ,"sys_pll3_out" ,"sys_pll1_266m" , "audio_pll2_out", "sys_pll1_100m", }; +#if CONFIG_IS_ENABLED (VIDEO ) +static const char *const imx8mp_media_disp_pix_sels[] = {"clock-osc-24m" ,"video_pll1_out" ,"audio_pll2_out" , +"audio_pll1_out" ,"sys_pll1_800m" , +"sys_pll2_1000m" ,"sys_pll3_out" ,"clk_ext4" , }; + +static const char *const imx8mp_media_ldb_sels[] = {"clock-osc-24m" ,"sys_pll2_333m" ,"sys_pll2_100m" , +"sys_pll1_800m" ,"sys_pll2_1000m" , +"clk_ext2" ,"audio_pll2_out" , +"video_pll1_out" , }; +#endif +static const char *const imx8mp_enet_ref_sels[] = {"clock-osc-24m" ,"sys_pll2_125m" ,"sys_pll2_50m" ,"sys_pll2_100m" ,"sys_pll1_160m" ,"audio_pll1_out" ,"video_pll1_out" ,"clk_ext4" , };
@@ -199,12 +233,19 @@ static int imx8mp_clk_probe(struct udevice *dev)clk_dm (IMX8MP_CLK_DUMMY ,clk_register_fixed_rate (NULL ,"dummy" ,0 )); +#if CONFIG_IS_ENABLED (VIDEO ) +clk_dm (IMX8MP_VIDEO_PLL1_REF_SEL ,imx_clk_mux ("video_pll1_ref_sel" , base +0x28 ,0 ,2 , pll_ref_sels,ARRAY_SIZE (pll_ref_sels))); +#endif clk_dm (IMX8MP_DRAM_PLL_REF_SEL ,imx_clk_mux ("dram_pll_ref_sel" , base +0x50 ,0 ,2 , pll_ref_sels,ARRAY_SIZE (pll_ref_sels)));clk_dm (IMX8MP_ARM_PLL_REF_SEL ,imx_clk_mux ("arm_pll_ref_sel" , base +0x84 ,0 ,2 , pll_ref_sels,ARRAY_SIZE (pll_ref_sels)));clk_dm (IMX8MP_SYS_PLL1_REF_SEL ,imx_clk_mux ("sys_pll1_ref_sel" , base +0x94 ,0 ,2 , pll_ref_sels,ARRAY_SIZE (pll_ref_sels)));clk_dm (IMX8MP_SYS_PLL2_REF_SEL ,imx_clk_mux ("sys_pll2_ref_sel" , base +0x104 ,0 ,2 , pll_ref_sels,ARRAY_SIZE (pll_ref_sels)));clk_dm (IMX8MP_SYS_PLL3_REF_SEL ,imx_clk_mux ("sys_pll3_ref_sel" , base +0x114 ,0 ,2 , pll_ref_sels,ARRAY_SIZE (pll_ref_sels))); +#if CONFIG_IS_ENABLED (VIDEO ) +clk_dm (IMX8MP_VIDEO_PLL1 ,imx_clk_pll14xx ("video_pll1" ,"video_pll1_ref_sel" , base +0x28 , + &imx_1443x_pll)); +#endif clk_dm (IMX8MP_DRAM_PLL ,imx_clk_pll14xx ("dram_pll" ,"dram_pll_ref_sel" , base +0x50 , &imx_1443x_dram_pll)); clk_dm(IMX8MP_ARM_PLL, imx_clk_pll14xx("arm_pll", "arm_pll_ref_sel", base + 0x84,
@@ -216,12 +257,18 @@ static int imx8mp_clk_probe(struct udevice *dev)clk_dm (IMX8MP_SYS_PLL3 ,imx_clk_pll14xx ("sys_pll3" ,"sys_pll3_ref_sel" , base +0x114 , &imx_1416x_pll)); +#if CONFIG_IS_ENABLED (VIDEO ) +clk_dm (IMX8MP_VIDEO_PLL1_BYPASS ,imx_clk_mux_flags ("video_pll1_bypass" , base +0x28 ,16 ,1 , video_pll1_bypass_sels,ARRAY_SIZE (video_pll1_bypass_sels),CLK_SET_RATE_PARENT )); +#endif clk_dm (IMX8MP_DRAM_PLL_BYPASS ,imx_clk_mux_flags ("dram_pll_bypass" , base +0x50 ,4 ,1 , dram_pll_bypass_sels,ARRAY_SIZE (dram_pll_bypass_sels),CLK_SET_RATE_PARENT ));clk_dm (IMX8MP_ARM_PLL_BYPASS ,imx_clk_mux_flags ("arm_pll_bypass" , base +0x84 ,4 ,1 , arm_pll_bypass_sels,ARRAY_SIZE (arm_pll_bypass_sels),CLK_SET_RATE_PARENT ));clk_dm (IMX8MP_SYS_PLL1_BYPASS ,imx_clk_mux_flags ("sys_pll1_bypass" , base +0x94 ,4 ,1 , sys_pll1_bypass_sels,ARRAY_SIZE (sys_pll1_bypass_sels),CLK_SET_RATE_PARENT ));clk_dm (IMX8MP_SYS_PLL2_BYPASS ,imx_clk_mux_flags ("sys_pll2_bypass" , base +0x104 ,4 ,1 , sys_pll2_bypass_sels,ARRAY_SIZE (sys_pll2_bypass_sels),CLK_SET_RATE_PARENT ));clk_dm (IMX8MP_SYS_PLL3_BYPASS ,imx_clk_mux_flags ("sys_pll3_bypass" , base +0x114 ,4 ,1 , sys_pll3_bypass_sels,ARRAY_SIZE (sys_pll3_bypass_sels),CLK_SET_RATE_PARENT )); +#if CONFIG_IS_ENABLED (VIDEO ) +clk_dm (IMX8MP_VIDEO_PLL1_OUT ,imx_clk_gate ("video_pll1_out" ,"video_pll1_bypass" , base +0x28 ,13 )); +#endif clk_dm (IMX8MP_DRAM_PLL_OUT ,imx_clk_gate ("dram_pll_out" ,"dram_pll_bypass" , base +0x50 ,13 ));clk_dm (IMX8MP_ARM_PLL_OUT ,imx_clk_gate ("arm_pll_out" ,"arm_pll_bypass" , base +0x84 ,11 ));clk_dm (IMX8MP_SYS_PLL1_OUT ,imx_clk_gate ("sys_pll1_out" ,"sys_pll1_bypass" , base +0x94 ,11 ));
@@ -267,13 +314,23 @@ static int imx8mp_clk_probe(struct udevice *dev)clk_dm (IMX8MP_CLK_A53_DIV ,imx_clk_divider2 ("arm_a53_div" ,"arm_a53_cg" , base +0x8000 ,0 ,3 ));clk_dm (IMX8MP_CLK_HSIO_AXI ,imx8m_clk_composite ("hsio_axi" , imx8mp_hsio_axi_sels, base +0x8380 )); +#if CONFIG_IS_ENABLED (VIDEO ) +clk_dm (IMX8MP_CLK_MEDIA_ISP ,imx8m_clk_composite ("media_isp" , imx8mp_media_isp_sels, base +0x8400 )); +#endif clk_dm (IMX8MP_CLK_MAIN_AXI ,imx8m_clk_composite_critical ("main_axi" , imx8mp_main_axi_sels, base +0x8800 ));clk_dm (IMX8MP_CLK_ENET_AXI ,imx8m_clk_composite_critical ("enet_axi" , imx8mp_enet_axi_sels, base +0x8880 ));clk_dm (IMX8MP_CLK_NAND_USDHC_BUS ,imx8m_clk_composite_critical ("nand_usdhc_bus" , imx8mp_nand_usdhc_sels, base +0x8900 )); +#if CONFIG_IS_ENABLED (VIDEO ) +clk_dm (IMX8MP_CLK_MEDIA_AXI ,imx8m_clk_composite ("media_axi" , imx8mp_media_axi_sels, base +0x8a00 )); +clk_dm (IMX8MP_CLK_MEDIA_APB ,imx8m_clk_composite ("media_apb" , imx8mp_media_apb_sels, base +0x8a80 )); +#endif clk_dm (IMX8MP_CLK_NOC ,imx8m_clk_composite_critical ("noc" , imx8mp_noc_sels, base +0x8d00 ));clk_dm (IMX8MP_CLK_NOC_IO ,imx8m_clk_composite_critical ("noc_io" , imx8mp_noc_io_sels, base +0x8d80 ));clk_dm (IMX8MP_CLK_AHB ,imx8m_clk_composite_critical ("ahb_root" , imx8mp_ahb_sels, base +0x9000 )); +#if CONFIG_IS_ENABLED (VIDEO ) +clk_dm (IMX8MP_CLK_MEDIA_DISP2_PIX ,imx8m_clk_composite ("media_disp2_pix" , imx8mp_media_disp_pix_sels, base +0x9300 )); +#endif clk_dm (IMX8MP_CLK_IPG_ROOT ,imx_clk_divider2 ("ipg_root" ,"ahb_root" , base +0x9080 ,0 ,1 ));
@@ -312,6 +369,10 @@ static int imx8mp_clk_probe(struct udevice *dev)clk_dm (IMX8MP_CLK_WDOG ,imx8m_clk_composite ("wdog" , imx8mp_wdog_sels, base +0xb900 ));clk_dm (IMX8MP_CLK_USDHC3 ,imx8m_clk_composite ("usdhc3" , imx8mp_usdhc3_sels, base +0xbc80 )); +#if CONFIG_IS_ENABLED (VIDEO ) +clk_dm (IMX8MP_CLK_MEDIA_DISP1_PIX ,imx8m_clk_composite ("media_disp1_pix" , imx8mp_media_disp_pix_sels, base +0xbe00 )); +clk_dm (IMX8MP_CLK_MEDIA_LDB ,imx8m_clk_composite ("media_ldb" , imx8mp_media_ldb_sels, base +0xbf00 )); +#endif clk_dm (IMX8MP_CLK_DRAM_ALT_ROOT ,imx_clk_fixed_factor ("dram_alt_root" ,"dram_alt" ,1 ,4 ));clk_dm (IMX8MP_CLK_DRAM_CORE ,imx_clk_mux2_flags ("dram_core_clk" , base +0x9800 ,24 ,1 , imx8mp_dram_core_sels,ARRAY_SIZE (imx8mp_dram_core_sels),CLK_IS_CRITICAL ));
@@ -355,6 +416,14 @@ static int imx8mp_clk_probe(struct udevice *dev)clk_dm (IMX8MP_CLK_WDOG2_ROOT ,imx_clk_gate4 ("wdog2_root_clk" ,"wdog" , base +0x4540 ,0 ));clk_dm (IMX8MP_CLK_WDOG3_ROOT ,imx_clk_gate4 ("wdog3_root_clk" ,"wdog" , base +0x4550 ,0 ));clk_dm (IMX8MP_CLK_HSIO_ROOT ,imx_clk_gate4 ("hsio_root_clk" ,"ipg_root" , base +0x45c0 ,0 )); +#if CONFIG_IS_ENABLED (VIDEO ) +clk_dm (IMX8MP_CLK_MEDIA_APB_ROOT ,imx_clk_gate2_shared2 ("media_apb_root_clk" ,"media_apb" , base +0x45d0 ,0 , &share_count_media)); +clk_dm (IMX8MP_CLK_MEDIA_AXI_ROOT ,imx_clk_gate2_shared2 ("media_axi_root_clk" ,"media_axi" , base +0x45d0 ,0 , &share_count_media)); +clk_dm (IMX8MP_CLK_MEDIA_DISP1_PIX_ROOT ,imx_clk_gate2_shared2 ("media_disp1_pix_root_clk" ,"media_disp1_pix" , base +0x45d0 ,0 , &share_count_media)); +clk_dm (IMX8MP_CLK_MEDIA_DISP2_PIX_ROOT ,imx_clk_gate2_shared2 ("media_disp2_pix_root_clk" ,"media_disp2_pix" , base +0x45d0 ,0 , &share_count_media)); +clk_dm (IMX8MP_CLK_MEDIA_LDB_ROOT ,imx_clk_gate2_shared2 ("media_ldb_root_clk" ,"media_ldb" , base +0x45d0 ,0 , &share_count_media)); +clk_dm (IMX8MP_CLK_MEDIA_ISP_ROOT ,imx_clk_gate2_shared2 ("media_isp_root_clk" ,"media_isp" , base +0x45d0 ,0 , &share_count_media)); +#endif clk_dm (IMX8MP_CLK_USDHC3_ROOT ,imx_clk_gate4 ("usdhc3_root_clk" ,"usdhc3" , base +0x45e0 ,0 ));
Signature · 1 line
2.47.0
PATCH v3 8/13 imx: power-domain: Describe the i.MX8 MEDIAMIX domain
In reply to Miquel RaynalAdd support for the i.MX8 MEDIAMIX domain which is driving the power over the whole display/rendering pipeline.
--- drivers/power/domain/imx8m-power-domain.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/power/domain/imx8m-power-domain.c +17 -0
@@ -40,6 +40,7 @@ DECLARE_GLOBAL_DATA_PTR;#define IMX8MN_MIPI_A53_DOMAIN BIT(2)#define IMX8MP_HSIOMIX_A53_DOMAIN BIT(19) +#define IMX8MP_MEDIAMIX_A53_DOMAIN BIT(12)#define IMX8MP_USB2_PHY_A53_DOMAIN BIT(5)#define IMX8MP_USB1_PHY_A53_DOMAIN BIT(4)#define IMX8MP_PCIE_PHY_A53_DOMAIN BIT(3)
@@ -63,6 +64,7 @@ DECLARE_GLOBAL_DATA_PTR;#define IMX8MN_MIPI_SW_Pxx_REQ BIT(0)#define IMX8MP_HSIOMIX_Pxx_REQ BIT(17) +#define IMX8MP_MEDIAMIX_Pxx_REQ BIT(10)#define IMX8MP_USB2_PHY_Pxx_REQ BIT(3)#define IMX8MP_USB1_PHY_Pxx_REQ BIT(2)#define IMX8MP_PCIE_PHY_SW_Pxx_REQ BIT(1)
@@ -81,6 +83,9 @@ DECLARE_GLOBAL_DATA_PTR;#define IMX8MP_HSIOMIX_PWRDNACKN BIT(28)#define IMX8MP_HSIOMIX_PWRDNREQN BIT(12) +#define IMX8MP_MEDIAMIX_PWRDNACKN BIT(30) +#define IMX8MP_MEDIAMIX_PWRDNREQN BIT(14) +/* * The PGC offset values in Reference Manual * (Rev. 1, 01/2018 and the older ones) GPC chapter's
@@ -101,6 +106,7 @@ DECLARE_GLOBAL_DATA_PTR;#define IMX8MP_PGC_PCIE 13#define IMX8MP_PGC_USB1 14#define IMX8MP_PGC_USB2 15 +#define IMX8MP_PGC_MEDIAMIX 22#define IMX8MP_PGC_HSIOMIX 29#define GPC_PGC_CTRL (n) (0x800 + (n) * 0x40)
@@ -303,6 +309,17 @@ static const struct imx_pgc_domain imx8mp_pgc_domains[] = { .pgc = BIT(IMX8MP_PGC_HSIOMIX), .keep_clocks = true, }, + + [IMX8MP_POWER_DOMAIN_MEDIAMIX] = { + .bits = { + .pxx = IMX8MP_MEDIAMIX_Pxx_REQ, + .map = IMX8MP_MEDIAMIX_A53_DOMAIN, + .hskreq = IMX8MP_MEDIAMIX_PWRDNREQN, + .hskack = IMX8MP_MEDIAMIX_PWRDNACKN, + }, + .pgc = BIT(IMX8MP_PGC_MEDIAMIX), + .keep_clocks = true, + }, };static const struct imx_pgc_regs imx8mp_pgc_regs = {
Signature · 1 line
2.47.0
PATCH v3 9/13 imx: power-domain: Add support for the MEDIAMIX control block
In reply to Miquel RaynalThis block delivers power and clocks to the whole display and rendering pipeline.
--- drivers/power/domain/Kconfig | 7 ++ drivers/power/domain/Makefile | 1 + drivers/power/domain/imx8mp-mediamix.c | 208 +++++++++++++++++++++++++++++++++ 3 files changed, 216 insertions(+)
drivers/power/domain/Kconfig +7 -0
@@ -47,6 +47,13 @@ config IMX8MP_HSIOMIX_BLKCTRL help Enable support for manipulating NXP i.MX8MP on-SoC HSIOMIX block controller. +config IMX8MP_MEDIAMIX_BLKCTRL + bool "Enable i.MX8MP MEDIAMIX domain driver" + depends on POWER_DOMAIN && IMX8MP + select CLK + help + Enable support for manipulating NXP i.MX8MP on-SoC MEDIAMIX block controller. + config MTK_POWER_DOMAIN bool "Enable the MediaTek power domain driver" depends on POWER_DOMAIN && ARCH_MEDIATEK
drivers/power/domain/Makefile +1 -0
@@ -9,6 +9,7 @@ obj-$(CONFIG_BCM6328_POWER_DOMAIN) += bcm6328-power-domain.o obj-$(CONFIG_IMX8_POWER_DOMAIN) += imx8-power-domain-legacy.o imx8-power-domain.o obj-$(CONFIG_IMX8M_POWER_DOMAIN) += imx8m-power-domain.o obj-$(CONFIG_IMX8MP_HSIOMIX_BLKCTRL) += imx8mp-hsiomix.o +obj-$(CONFIG_IMX8MP_MEDIAMIX_BLKCTRL) += imx8mp-mediamix.o obj-$(CONFIG_MTK_POWER_DOMAIN) += mtk-power-domain.o obj-$(CONFIG_MESON_GX_VPU_POWER_DOMAIN) += meson-gx-pwrc-vpu.o obj-$(CONFIG_MESON_EE_POWER_DOMAIN) += meson-ee-pwrc.o
drivers/power/domain/imx8mp-mediamix.c new file +208 -0
208 lines not on this page · raw message
Signature · 1 line
2.47.0
PATCH v3 10/13 video: imx: Fix Makefile in order to be able to add other imx drivers
In reply to Miquel RaynalThe IPUv3 is one IP part of the imx world, there are others, and selecting the whole imx/ folder based on such a specific Kconfig symbol is sub-optimal. Let's always enter the imx/ folder, and then selectively compile parts of the folder based on the configuration.
--- drivers/video/Makefile | 2 +- drivers/video/imx/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/video/Makefile +1 -1
@@ -52,7 +52,7 @@ obj-$(CONFIG_VIDEO_COREBOOT) += coreboot.o obj-$(CONFIG_VIDEO_DW_HDMI) += dw_hdmi.o obj-$(CONFIG_VIDEO_DW_MIPI_DSI) += dw_mipi_dsi.o obj-$(CONFIG_VIDEO_EFI) += efi.o -obj-$(CONFIG_VIDEO_IPUV3) += imx/ +obj-y += imx/ obj-$(CONFIG_VIDEO_IVYBRIDGE_IGD) += ivybridge_igd.o obj-$(CONFIG_VIDEO_LCD_ANX9804) += anx9804.o obj-$(CONFIG_VIDEO_LCD_ENDEAVORU) += endeavoru-panel.o
drivers/video/imx/Makefile +1 -1
@@ -3,4 +3,4 @@ # (C) Copyright 2000-2007 # Wolfgang Denk, DENX Software Engineering, [email protected]. -obj-y += mxc_ipuv3_fb.o ipu_common.o ipu_disp.o +obj-$(CONFIG_VIDEO_IPUV3) += mxc_ipuv3_fb.o ipu_common.o ipu_disp.o
Signature · 1 line
2.47.0
PATCH v3 11/13 video: imx: Add LDB driver
In reply to Miquel RaynalAdd support for the LVDS Display Bridge (LDB) found on i.MX8MP.
When attached, the bridge driver looks for panels connected to one of its two outputs and adapts its own configuration to use them. There is currently no support for merged/split displays.
Note regarding the clock configuration:
The LDB output clock should be absolutely identical to the LCDIF output clock so both blocks can talk to each other synchronously. However, the LDB clock has an internal divisor of 7 (respectively 3.5 in dual configuration) which means the LDB input clock must be explicitly set once we know the configuration.
This driver was tested on i.MX8MP using a single panel connected to the LVDS2 interface.
--- drivers/video/imx/Kconfig | 6 ++ drivers/video/imx/Makefile | 1 + drivers/video/imx/ldb.c | 251 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 258 insertions(+)
drivers/video/imx/Kconfig +6 -0
@@ -13,3 +13,9 @@ config IMX_VIDEO_SKIP config IMX_HDMI bool "Enable HDMI support in IPUv3" depends on VIDEO_IPUV3 + +config IMX_LDB + bool "Freescale i.MX8MP LDB bridge" + depends on VIDEO_BRIDGE + help + Support for i.MX8MP DPI-to-LVDS on-SoC encoder.
drivers/video/imx/Makefile +1 -0
@@ -4,3 +4,4 @@ # Wolfgang Denk, DENX Software Engineering, [email protected]. obj-$(CONFIG_VIDEO_IPUV3) += mxc_ipuv3_fb.o ipu_common.o ipu_disp.o +obj-$(CONFIG_IMX_LDB) += ldb.o
drivers/video/imx/ldb.c new file +251 -0
251 lines not on this page · raw message
Signature · 1 line
2.47.0
PATCH v3 12/13 video: imx: Add LCDIF driver
In reply to Miquel RaynalAdd support for the LCD interfaces (LCDIF1/2). When probed, these interfaces request numerous clocks and power domains, attach the bridge and look for a panel in order to retrieve its capabilities and properties.
There is a similar existing driver in the upper folder for other i.MX targets, I discovered this driver a bit late. It is not targeting the i.MX8MP and I have no idea how different can the LCDIF be on this SoC, but I did not manage to get it work, especially because it is not fully compliant with the device-model, especially on the clocks/power management side which is all ad-hoc. This is normal though, it was contributed more than ten years ago.
--- drivers/video/imx/Kconfig | 3 + drivers/video/imx/Makefile | 1 + drivers/video/imx/lcdif.c | 314 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 318 insertions(+)
drivers/video/imx/Kconfig +3 -0
@@ -19,3 +19,6 @@ config IMX_LDB depends on VIDEO_BRIDGE help Support for i.MX8MP DPI-to-LVDS on-SoC encoder. + +config IMX_LCDIF + bool "i.MX LCDIFv3 LCD controller"
drivers/video/imx/Makefile +1 -0
@@ -5,3 +5,4 @@ obj-$(CONFIG_VIDEO_IPUV3) += mxc_ipuv3_fb.o ipu_common.o ipu_disp.o obj-$(CONFIG_IMX_LDB) += ldb.o +obj-$(CONFIG_IMX_LCDIF) += lcdif.o
drivers/video/imx/lcdif.c new file +314 -0
314 lines not on this page · raw message
Signature · 1 line
2.47.0
PATCH v3 13/13 imx8mp_evk: Enable display support
In reply to Miquel RaynalThere is now support for the display pipeline using one LCD interface, the LDB bridge and of course the related media power domain controls.
This is untested as I do not have the EVK but should be enough to use the display, using bmp, lcdputs and co. For console-like commands, it might be also needed to enable the VIDEO_CONSOLE explicitly using:
setenv stdout serial,vidconsole0
--- configs/imx8mp_evk_defconfig | 7 +++++++ 1 file changed, 7 insertions(+)
configs/imx8mp_evk_defconfig +7 -0
@@ -31,6 +31,7 @@ CONFIG_OF_SYSTEM_SETUP=y CONFIG_DEFAULT_FDT_FILE="imx8mp-evk.dtb" CONFIG_SYS_CBSIZE=2048 CONFIG_SYS_PBSIZE=2074 +# CONFIG_CONSOLE_MUX is not set CONFIG_BOARD_LATE_INIT=y CONFIG_SPL_MAX_SIZE=0x26000 CONFIG_SPL_BOARD_INIT=y
@@ -60,6 +61,7 @@ CONFIG_CMD_USB=y CONFIG_CMD_USB_SDP=y CONFIG_CMD_USB_MASS_STORAGE=y CONFIG_CMD_CACHE=y +# CONFIG_CMD_CLS is not set CONFIG_CMD_REGULATOR=y CONFIG_CMD_EXT4_WRITE=y CONFIG_OF_CONTROL=y
@@ -112,6 +114,7 @@ CONFIG_PINCTRL_IMX8M=y CONFIG_POWER_DOMAIN=y CONFIG_IMX8M_POWER_DOMAIN=y CONFIG_IMX8MP_HSIOMIX_BLKCTRL=y +CONFIG_IMX8MP_MEDIAMIX_BLKCTRL=y CONFIG_DM_PMIC=y CONFIG_DM_PMIC_PCA9450=y CONFIG_SPL_DM_PMIC_PCA9450=y
@@ -139,4 +142,8 @@ CONFIG_USB_GADGET=y CONFIG_USB_GADGET_MANUFACTURER="FSL" CONFIG_USB_GADGET_VENDOR_NUM=0x0525 CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5 +CONFIG_VIDEO=y +CONFIG_VIDEO_BRIDGE=y +CONFIG_IMX_LDB=y +CONFIG_IMX_LCDIF=y CONFIG_IMX_WATCHDOG=y
Signature · 1 line
2.47.0
Fabio Estevam
reviewerRe: [PATCH v3 13/13] imx8mp_evk: Enable display support
Hi Peng,
Quoted 9 lines · Miquel Raynal
There is now support for the display pipeline using one LCD interface, the LDB bridge and of course the related media power domain controls.
This is untested as I do not have the EVK but should be enough to use the display, using bmp, lcdputs and co. For console-like commands, it might be also needed to enable the
VIDEO_CONSOLEexplicitly using:setenv stdout serial,vidconsole0
I have access to an imx8mp-evk but don't have an LVDS panel to test.
Could you please test this series on an imx8mp-evk + LVDS setup?
Thanks
Re: [PATCH v3 13/13] imx8mp_evk: Enable display support
Hello Fabio,
Quoted 11 lines · Fabio Estevam
Hi Peng,
Quoted 8 lines · Miquel Raynal
There is now support for the display pipeline using one LCD interface, the LDB bridge and of course the related media power domain controls.
This is untested as I do not have the EVK but should be enough to use the display, using bmp, lcdputs and co. For console-like commands, it might be also needed to enable the
VIDEO_CONSOLEexplicitly using:
Quoted 5 lines
Quoted 1 line
setenv stdout serial,vidconsole0
I have access to an imx8mp-evk but don't have an LVDS panel to test.
Could you please test this series on an imx8mp-evk + LVDS setup?
I only worked on a custom design based on a i.MX8MP. We do have an EVK, but it has no display. I was asked to add a user, but in practice I cannot test that. I can enable the ldb in the EVK DTS or drop that patch.
Thanks,
Miquèl
Fabio Estevam
reviewerRe: [PATCH v3 13/13] imx8mp_evk: Enable display support
Hi Miquel,
Quoted 4 lines · Miquel Raynal
I only worked on a custom design based on a i.MX8MP. We do have an EVK, but it has no display. I was asked to add a user, but in practice I cannot test that. I can enable the ldb in the EVK DTS or drop that patch.
I wanted to have an in-tree user for the i.MX8MP LDB, but if you cannot test, I suggest dropping the imx8mp-evk patch from v4.
Hopefully, someone can enable LDB support for some other imx8mp-based board.
Besides that, there are some comments from Simon on the patch 05/13 that need to be addressed in v4.
I hope v4 can be merged.
Re: [PATCH v3 13/13] imx8mp_evk: Enable display support
Quoted 9 lines · Fabio Estevam
Hi Miquel,
Quoted 4 lines · Miquel Raynal
I only worked on a custom design based on a i.MX8MP. We do have an EVK, but it has no display. I was asked to add a user, but in practice I cannot test that. I can enable the ldb in the EVK DTS or drop that patch.
Quoted 4 lines
I wanted to have an in-tree user for the i.MX8MP LDB, but if you cannot test, I suggest dropping the imx8mp-evk patch from v4.
Hopefully, someone can enable LDB support for some other imx8mp-based board.
Ok.
Quoted 4 lines
Besides that, there are some comments from Simon on the patch 05/13 that need to be addressed in v4.
I hope v4 can be merged.
Yes, I need to get into this again because he asked something similar in response to one of my previous versions, and I disagreed. I will reconsider his requests. Hopefully we'll settle at some point.
Thanks,
Miquèl
Fabio Estevam
reviewerRe: [PATCH v3 13/13] imx8mp_evk: Enable display support
In reply to Miquel RaynalQuoted 6 lines · Miquel Raynal
There is now support for the display pipeline using one LCD interface, the LDB bridge and of course the related media power domain controls.
This is untested as I do not have the EVK but should be enough to use the display, using bmp, lcdputs and co. For console-like commands, it
Hmm, this cannot work. The upstream imx8mp-evk.dts does not have the LDB enabled.
Quoted 50 lines
might be also needed to enable the
VIDEO_CONSOLEexplicitly using:setenv stdout serial,vidconsole0
Signed-off-by Miquel Raynal <[email protected]>--- configs/imx8mp_evk_defconfig | 7 +++++++ 1 file changed, 7 insertions(+)configs/imx8mp_evk_defconfig +7
-1@@ -31,6 +31,7 @@ CONFIG_OF_SYSTEM_SETUP=y CONFIG_DEFAULT_FDT_FILE="imx8mp-evk.dtb" CONFIG_SYS_CBSIZE=2048 CONFIG_SYS_PBSIZE=2074 +# CONFIG_CONSOLE_MUX is not set CONFIG_BOARD_LATE_INIT=y CONFIG_SPL_MAX_SIZE=0x26000 CONFIG_SPL_BOARD_INIT=y@@ -60,6 +61,7 @@ CONFIG_CMD_USB=y CONFIG_CMD_USB_SDP=y CONFIG_CMD_USB_MASS_STORAGE=y CONFIG_CMD_CACHE=y +# CONFIG_CMD_CLS is not set CONFIG_CMD_REGULATOR=y CONFIG_CMD_EXT4_WRITE=y CONFIG_OF_CONTROL=y@@ -112,6 +114,7 @@ CONFIG_PINCTRL_IMX8M=y CONFIG_POWER_DOMAIN=y CONFIG_IMX8M_POWER_DOMAIN=y CONFIG_IMX8MP_HSIOMIX_BLKCTRL=y +CONFIG_IMX8MP_MEDIAMIX_BLKCTRL=y CONFIG_DM_PMIC=y CONFIG_DM_PMIC_PCA9450=y CONFIG_SPL_DM_PMIC_PCA9450=y@@ -139,4 +142,8 @@ CONFIG_USB_GADGET=y CONFIG_USB_GADGET_MANUFACTURER="FSL" CONFIG_USB_GADGET_VENDOR_NUM=0x0525 CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5 +CONFIG_VIDEO=y +CONFIG_VIDEO_BRIDGE=y +CONFIG_IMX_LDB=y +CONFIG_IMX_LCDIF=y CONFIG_IMX_WATCHDOG=y --2.47.0