From 839d934c79aee95a7d67d2f8dceacbfd0e5ea848 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 12 Oct 2021 09:33:51 +0200 Subject: cdev: Add function to get unallocated space at start of device On several SoCs barebox is written to the raw device in front of the first partition. So far we blindly trust that there is enough space available for the barebox image. Start changing this by adding a function that retrieves the available space. Signed-off-by: Sascha Hauer Link: https://lore.barebox.org/20211012073352.4071559-8-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer --- include/driver.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/driver.h b/include/driver.h index c7f5903fce..4f6d40e17c 100644 --- a/include/driver.h +++ b/include/driver.h @@ -494,6 +494,7 @@ ssize_t cdev_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulo ssize_t cdev_write(struct cdev *cdev, const void *buf, size_t count, loff_t offset, ulong flags); int cdev_ioctl(struct cdev *cdev, int cmd, void *buf); int cdev_erase(struct cdev *cdev, loff_t count, loff_t offset); +loff_t cdev_unallocated_space(struct cdev *cdev); #define DEVFS_PARTITION_FIXED (1U << 0) #define DEVFS_PARTITION_READONLY (1U << 1) -- cgit v1.2.3 From bd516e38dd1490cb83b58f8f7914912f3a702978 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 8 Nov 2021 08:52:07 +0100 Subject: clk: handle CLK_OF_DECLARE in deep probe An assigned-clock-parents referring to a fixed-clock will result in a warning: WARNING: clk: couldn't get parent clock 0 for /ethernet@fe300000 That's because the device for the fixed clock is created on demand and even after ensuring probe, no driver will have bound against it as CLK_OF_DECLARE operates outside the driver model. Fix this by creating devices and binding the dummy driver while iterating over the CLK_OF_DECLARE list. No functional change for systems not enabling deep-probe. Signed-off-by: Ahmad Fatoum Link: https://lore.barebox.org/20211108075209.2366770-7-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer --- drivers/clk/clk.c | 8 +++++++- drivers/of/platform.c | 5 ++++- include/of.h | 6 ++++++ 3 files changed, 17 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index fff1e21144..189c9c62df 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -845,9 +845,15 @@ int of_clk_init(struct device_node *root, const struct of_device_id *matches) struct device_node *np = clk_provider->np; if (force || parent_ready(np)) { + struct device_d *dev; of_pinctrl_select_state_default(np); - clk_provider->clk_init_cb(np); + + dev = of_device_create_on_demand(np); + + if (clk_provider->clk_init_cb(np) == 0 && dev) + of_platform_device_dummy_drv(dev); + of_clk_set_defaults(np, true); list_del(&clk_provider->node); diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 92b6caef5a..ce7a2a0df5 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -373,11 +373,14 @@ int of_platform_populate(struct device_node *root, } EXPORT_SYMBOL_GPL(of_platform_populate); -static struct device_d *of_device_create_on_demand(struct device_node *np) +struct device_d *of_device_create_on_demand(struct device_node *np) { struct device_node *parent; struct device_d *parent_dev, *dev; + if (!deep_probe_is_supported()) + return NULL; + parent = of_get_parent(np); if (!parent) return NULL; diff --git a/include/of.h b/include/of.h index f9c2b283de..1b7392cdb3 100644 --- a/include/of.h +++ b/include/of.h @@ -279,6 +279,7 @@ extern struct device_d *of_device_enable_and_register_by_name(const char *name); extern struct device_d *of_device_enable_and_register_by_alias( const char *alias); +extern struct device_d *of_device_create_on_demand(struct device_node *np); extern int of_device_ensure_probed(struct device_node *np); extern int of_device_ensure_probed_by_alias(const char *alias); extern int of_devices_ensure_probed_by_property(const char *property_name); @@ -372,6 +373,11 @@ static inline void of_platform_device_dummy_drv(struct device_d *dev) { } +static inline struct device_d *of_device_create_on_demand(struct device_node *np) +{ + return NULL; +} + static inline int of_device_ensure_probed(struct device_node *np) { return 0; -- cgit v1.2.3