From c1d6f91952d0761f61b0f0f96e4c7aa32eee2788 Mon Sep 17 00:00:00 2001 From: Przemyslaw Marczak Date: Wed, 15 Apr 2015 13:07:17 +0200 Subject: dm: core: add internal functions for getting the device without probe This commit extends the uclass-internal functions by: - uclass_find_first_device() - uclass_find_next_device() For both functions, the returned device is not probed. After some cleanup, the above functions are called by: - uclass_first_device() - uclass_next_device() for which, the returned device is probed. Signed-off-by: Przemyslaw Marczak Cc: Simon Glass Acked-by: Simon Glass --- include/dm/uclass-internal.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'include') diff --git a/include/dm/uclass-internal.h b/include/dm/uclass-internal.h index ae2a93d7d4..befbae5a01 100644 --- a/include/dm/uclass-internal.h +++ b/include/dm/uclass-internal.h @@ -23,6 +23,28 @@ */ int uclass_find_device(enum uclass_id id, int index, struct udevice **devp); +/** + * uclass_find_first_device() - Return the first device in a uclass + * @id: Id number of the uclass + * #devp: Returns pointer to device, or NULL on error + * + * The device is not prepared for use - this is an internal function + * + * @return 0 if OK (found or not found), -1 on error + */ +int uclass_find_first_device(enum uclass_id id, struct udevice **devp); + +/** + * uclass_find_next_device() - Return the next device in a uclass + * @devp: On entry, pointer to device to lookup. On exit, returns pointer + * to the next device in the same uclass, or NULL if none + * + * The device is not prepared for use - this is an internal function + * + * @return 0 if OK (found or not found), -1 on error + */ +int uclass_find_next_device(struct udevice **devp); + /** * uclass_bind_device() - Associate device with a uclass * -- cgit From 5eaed880282480a5a0a2b555c5f98a11252ed94e Mon Sep 17 00:00:00 2001 From: Przemyslaw Marczak Date: Wed, 15 Apr 2015 13:07:18 +0200 Subject: dm: core: Extend struct udevice by '.uclass_platdata' field. This commit adds 'uclass_platdata' field to 'struct udevice', which can be automatically allocated at bind. The allocation size is defined in 'struct uclass_driver' as 'per_device_platdata_auto_alloc_size'. New device's flag is added: DM_FLAG_ALLOC_UCLASS_PDATA, which is used for memory freeing at device unbind method. As for other udevice's fields, a complementary function is added: - dev_get_uclass_platdata() Signed-off-by: Przemyslaw Marczak Cc: Simon Glass Acked-by: Simon Glass --- include/dm/device.h | 17 ++++++++++++++++- include/dm/uclass.h | 4 ++++ 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/dm/device.h b/include/dm/device.h index c11342c33b..ad002feca2 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -30,8 +30,11 @@ struct driver_info; /* DM is responsible for allocating and freeing parent_platdata */ #define DM_FLAG_ALLOC_PARENT_PDATA (1 << 3) +/* DM is responsible for allocating and freeing uclass_platdata */ +#define DM_FLAG_ALLOC_UCLASS_PDATA (1 << 4) + /* Allocate driver private data on a DMA boundary */ -#define DM_FLAG_ALLOC_PRIV_DMA (1 << 4) +#define DM_FLAG_ALLOC_PRIV_DMA (1 << 5) /** * struct udevice - An instance of a driver @@ -54,6 +57,7 @@ struct driver_info; * @name: Name of device, typically the FDT node name * @platdata: Configuration data for this device * @parent_platdata: The parent bus's configuration data for this device + * @uclass_platdata: The uclass's configuration data for this device * @of_offset: Device tree node offset for this device (- for none) * @driver_data: Driver data word for the entry that matched this device with * its driver @@ -75,6 +79,7 @@ struct udevice { const char *name; void *platdata; void *parent_platdata; + void *uclass_platdata; int of_offset; ulong driver_data; struct udevice *parent; @@ -209,6 +214,16 @@ void *dev_get_platdata(struct udevice *dev); */ void *dev_get_parent_platdata(struct udevice *dev); +/** + * dev_get_uclass_platdata() - Get the uclass platform data for a device + * + * This checks that dev is not NULL, but no other checks for now + * + * @dev Device to check + * @return uclass's platform data, or NULL if none + */ +void *dev_get_uclass_platdata(struct udevice *dev); + /** * dev_get_parentdata() - Get the parent data for a device * diff --git a/include/dm/uclass.h b/include/dm/uclass.h index d57d804259..b271472618 100644 --- a/include/dm/uclass.h +++ b/include/dm/uclass.h @@ -65,6 +65,9 @@ struct udevice; * @per_device_auto_alloc_size: Each device can hold private data owned * by the uclass. If required this will be automatically allocated if this * value is non-zero. + * @per_device_platdata_auto_alloc_size: Each device can hold platform data + * owned by the uclass as 'dev->uclass_platdata'. If the value is non-zero, + * then this will be automatically allocated. * @per_child_auto_alloc_size: Each child device (of a parent in this * uclass) can hold parent data for the device/uclass. This value is only * used as a falback if this member is 0 in the driver. @@ -90,6 +93,7 @@ struct uclass_driver { int (*destroy)(struct uclass *class); int priv_auto_alloc_size; int per_device_auto_alloc_size; + int per_device_platdata_auto_alloc_size; int per_child_auto_alloc_size; int per_child_platdata_auto_alloc_size; const void *ops; -- cgit From 754e71e850cb09d53543846fbed74cc5a1491c76 Mon Sep 17 00:00:00 2001 From: Przemyslaw Marczak Date: Wed, 15 Apr 2015 13:07:19 +0200 Subject: dm: test: Add tests for device's uclass platform data This test introduces new test structure type:dm_test_perdev_uc_pdata. The structure consists of three int values only. For the test purposes, three pattern values are defined by enum, starting with TEST_UC_PDATA_INTVAL1. This commit adds two test cases for uclass platform data: - Test: dm_test_autobind_uclass_pdata_alloc - this tests if: * uclass driver sets: .per_device_platdata_auto_alloc_size field * the devices's: dev->uclass_platdata is non-NULL - Test: dm_test_autobind_uclass_pdata_valid - this tests: * if the devices's: dev->uclass_platdata is non-NULL * the structure of type 'dm_test_perdev_uc_pdata' allocated at address pointed by dev->uclass_platdata. Each structure field, should be equal to proper pattern data, starting from .intval1 == TEST_UC_PDATA_INTVAL1. Signed-off-by: Przemyslaw Marczak Cc: Simon Glass Acked-by: Simon Glass --- include/dm/test.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'include') diff --git a/include/dm/test.h b/include/dm/test.h index 9c4b8d3e57..f03fbcb1cd 100644 --- a/include/dm/test.h +++ b/include/dm/test.h @@ -98,6 +98,26 @@ struct dm_test_parent_data { int flag; }; +/* Test values for test device's uclass platform data */ +enum { + TEST_UC_PDATA_INTVAL1 = 2, + TEST_UC_PDATA_INTVAL2 = 334, + TEST_UC_PDATA_INTVAL3 = 789452, +}; + +/** + * struct dm_test_uclass_platda - uclass's information on each device + * + * @intval1: set to TEST_UC_PDATA_INTVAL1 in .post_bind method of test uclass + * @intval2: set to TEST_UC_PDATA_INTVAL2 in .post_bind method of test uclass + * @intval3: set to TEST_UC_PDATA_INTVAL3 in .post_bind method of test uclass + */ +struct dm_test_perdev_uc_pdata { + int intval1; + int intval2; + int intval3; +}; + /* * Operation counts for the test driver, used to check that each method is * called correctly -- cgit From e0735a4c60577fafdaed71c5ef046f04b0f53f09 Mon Sep 17 00:00:00 2001 From: Przemyslaw Marczak Date: Wed, 15 Apr 2015 13:07:22 +0200 Subject: dm: core: uclass: add function: uclass_find_device_by_name() This commit extends the driver model uclass's API by function: - uclass_find_device_by_name() And this function returns the device if: - uclass with given ID, exists, - device with exactly given name(dev->name), exists. The returned device is not activated - need to be probed before use. Note: This function returns the first device, which name is equal to the given one. This means, that using this function you must assume, that the device name is unique in the given uclass's ID device list. uclass-internal.h: cleanup - move the uclass_find_device_by_seq() declaration and description, near the other uclass_find*() functions. Signed-off-by: Przemyslaw Marczak Cc: Simon Glass Acked-by: Simon Glass --- include/dm/uclass-internal.h | 61 +++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 23 deletions(-) (limited to 'include') diff --git a/include/dm/uclass-internal.h b/include/dm/uclass-internal.h index befbae5a01..d0f1e22e58 100644 --- a/include/dm/uclass-internal.h +++ b/include/dm/uclass-internal.h @@ -45,6 +45,44 @@ int uclass_find_first_device(enum uclass_id id, struct udevice **devp); */ int uclass_find_next_device(struct udevice **devp); +/** + * uclass_find_device_by_name() - Find uclass device based on ID and name + * + * This searches for a device with the given name. + * + * The device is NOT probed, it is merely returned. + * + * @id: ID to look up + * @name: name of a device to find + * @devp: Returns pointer to device (the first one with the name) + * @return 0 if OK, -ve on error + */ +int uclass_find_device_by_name(enum uclass_id id, const char *name, + struct udevice **devp); + +/** + * uclass_find_device_by_seq() - Find uclass device based on ID and sequence + * + * This searches for a device with the given seq or req_seq. + * + * For seq, if an active device has this sequence it will be returned. + * If there is no such device then this will return -ENODEV. + * + * For req_seq, if a device (whether activated or not) has this req_seq + * value, that device will be returned. This is a strong indication that + * the device will receive that sequence when activated. + * + * The device is NOT probed, it is merely returned. + * + * @id: ID to look up + * @seq_or_req_seq: Sequence number to find (0=first) + * @find_req_seq: true to find req_seq, false to find seq + * @devp: Returns pointer to device (there is only one per for each seq) + * @return 0 if OK, -ve on error + */ +int uclass_find_device_by_seq(enum uclass_id id, int seq_or_req_seq, + bool find_req_seq, struct udevice **devp); + /** * uclass_bind_device() - Associate device with a uclass * @@ -116,27 +154,4 @@ struct uclass *uclass_find(enum uclass_id key); */ int uclass_destroy(struct uclass *uc); -/** - * uclass_find_device_by_seq() - Find uclass device based on ID and sequence - * - * This searches for a device with the given seq or req_seq. - * - * For seq, if an active device has this sequence it will be returned. - * If there is no such device then this will return -ENODEV. - * - * For req_seq, if a device (whether activated or not) has this req_seq - * value, that device will be returned. This is a strong indication that - * the device will receive that sequence when activated. - * - * The device is NOT probed, it is merely returned. - * - * @id: ID to look up - * @seq_or_req_seq: Sequence number to find (0=first) - * @find_req_seq: true to find req_seq, false to find seq - * @devp: Returns pointer to device (there is only one per for each seq) - * @return 0 if OK, -ve on error - */ -int uclass_find_device_by_seq(enum uclass_id id, int seq_or_req_seq, - bool find_req_seq, struct udevice **devp); - #endif -- cgit From b7af1a2da767c0dd283ffce3d50efd36af32df14 Mon Sep 17 00:00:00 2001 From: Przemyslaw Marczak Date: Wed, 15 Apr 2015 13:07:23 +0200 Subject: dm: core: uclass: add function: uclass_get_device_by_name() This commit extends the driver model uclass's API by function: - uclass_get_device_by_name() And this function returns the device if: - uclass with given ID, exists, - device with exactly given name(dev->name), exists, - device probe, doesn't return an error. The returned device is activated and ready to use. Note: This function returns the first device, which name is equal to the given one. This means, that using this function you must assume, that the device name is unique in the given uclass's ID device list. Signed-off-by: Przemyslaw Marczak Cc: Simon Glass Acked-by: Simon Glass --- include/dm/uclass.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'include') diff --git a/include/dm/uclass.h b/include/dm/uclass.h index b271472618..66e0ea509c 100644 --- a/include/dm/uclass.h +++ b/include/dm/uclass.h @@ -129,6 +129,21 @@ int uclass_get(enum uclass_id key, struct uclass **ucp); */ int uclass_get_device(enum uclass_id id, int index, struct udevice **devp); +/** + * uclass_get_device_by_name() - Get a uclass device by it's name + * + * This searches the devices in the uclass for one with the given name. + * + * The device is probed to activate it ready for use. + * + * @id: ID to look up + * @name: name of a device to get + * @devp: Returns pointer to device (the first one with the name) + * @return 0 if OK, -ve on error + */ +int uclass_get_device_by_name(enum uclass_id id, const char *name, + struct udevice **devp); + /** * uclass_get_device_by_seq() - Get a uclass device based on an ID and sequence * -- cgit From cc73d37b7f1edbbf03e2abcf5815bdd122e8baed Mon Sep 17 00:00:00 2001 From: Przemyslaw Marczak Date: Wed, 15 Apr 2015 13:07:24 +0200 Subject: dm: core: device: add function: dev_get_driver_ops() This commit extends the driver model device's API by function: - dev_get_driver_ops() And this function returns the device's driver's operations if given: - dev pointer, is non-NULL - dev->driver->ops pointer, is non-NULL in other case the, the NULL pointer is returned. Signed-off-by: Przemyslaw Marczak Cc: Simon Glass Acked-by: Simon Glass --- include/dm/device.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include') diff --git a/include/dm/device.h b/include/dm/device.h index ad002feca2..049cb2f5e2 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -280,6 +280,17 @@ void *dev_get_uclass_priv(struct udevice *dev); */ ulong dev_get_driver_data(struct udevice *dev); +/** + * dev_get_driver_ops() - get the device's driver's operations + * + * This checks that dev is not NULL, and returns the pointer to device's + * driver's operations. + * + * @dev: Device to check + * @return void pointer to driver's operations or NULL for NULL-dev or NULL-ops + */ +const void *dev_get_driver_ops(struct udevice *dev); + /* * device_get_uclass_id() - return the uclass ID of a device * -- cgit From f9c370dcdf056f035f18bf77db8a706cea21f9ce Mon Sep 17 00:00:00 2001 From: Przemyslaw Marczak Date: Wed, 15 Apr 2015 13:07:25 +0200 Subject: dm: core: device: add function: dev_get_uclass_name() This commit extends the driver model device's API by function: - dev_get_uclass_name() And this function returns the device's uclass driver name if: - given dev pointer, is non_NULL otherwise, the NULL pointer is returned. Signed-off-by: Przemyslaw Marczak Cc: Simon Glass Acked-by: Simon Glass --- include/dm/device.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include') diff --git a/include/dm/device.h b/include/dm/device.h index 049cb2f5e2..18296bb686 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -299,6 +299,16 @@ const void *dev_get_driver_ops(struct udevice *dev); */ enum uclass_id device_get_uclass_id(struct udevice *dev); +/* + * dev_get_uclass_name() - return the uclass name of a device + * + * This checks that dev is not NULL. + * + * @dev: Device to check + * @return pointer to the uclass name for the device + */ +const char *dev_get_uclass_name(struct udevice *dev); + /** * device_get_child() - Get the child of a device by index * -- cgit From 794d521917eab07651248174a81ba51cd265d9dc Mon Sep 17 00:00:00 2001 From: Przemyslaw Marczak Date: Mon, 20 Apr 2015 13:32:32 +0200 Subject: dm: core: remove type 'static' of function uclass_get_device_tail() Uclass API provides a few functions for get/find the device. To provide a complete function set of uclass-internal functions, for use by the drivers, the function uclass_get_device_tail() should be non-static. Signed-off-by: Przemyslaw Marczak Cc: Simon Glass Acked-by: Simon Glass --- include/dm/uclass-internal.h | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/dm/uclass-internal.h b/include/dm/uclass-internal.h index d0f1e22e58..153f2a7626 100644 --- a/include/dm/uclass-internal.h +++ b/include/dm/uclass-internal.h @@ -10,13 +10,26 @@ #ifndef _DM_UCLASS_INTERNAL_H #define _DM_UCLASS_INTERNAL_H +/** + * uclass_get_device_tail() - handle the end of a get_device call + * + * This handles returning an error or probing a device as needed. + * + * @dev: Device that needs to be probed + * @ret: Error to return. If non-zero then the device is not probed + * @devp: Returns the value of 'dev' if there is no error + * @return ret, if non-zero, else the result of the device_probe() call + */ +int uclass_get_device_tail(struct udevice *dev, int ret, struct udevice **devp); + /** * uclass_find_device() - Return n-th child of uclass * @id: Id number of the uclass * @index: Position of the child in uclass's list * #devp: Returns pointer to device, or NULL on error * - * The device is not prepared for use - this is an internal function + * The device is not prepared for use - this is an internal function. + * The function uclass_get_device_tail() can be used to probe the device. * * @return the uclass pointer of a child at the given index or * return NULL on error. @@ -28,7 +41,8 @@ int uclass_find_device(enum uclass_id id, int index, struct udevice **devp); * @id: Id number of the uclass * #devp: Returns pointer to device, or NULL on error * - * The device is not prepared for use - this is an internal function + * The device is not prepared for use - this is an internal function. + * The function uclass_get_device_tail() can be used to probe the device. * * @return 0 if OK (found or not found), -1 on error */ @@ -39,7 +53,8 @@ int uclass_find_first_device(enum uclass_id id, struct udevice **devp); * @devp: On entry, pointer to device to lookup. On exit, returns pointer * to the next device in the same uclass, or NULL if none * - * The device is not prepared for use - this is an internal function + * The device is not prepared for use - this is an internal function. + * The function uclass_get_device_tail() can be used to probe the device. * * @return 0 if OK (found or not found), -1 on error */ -- cgit From a7b8250210cd1b449a06f7d20769944ebeca1a41 Mon Sep 17 00:00:00 2001 From: Przemyslaw Marczak Date: Mon, 20 Apr 2015 13:32:34 +0200 Subject: dm: core: precise comments for get/find device by name The functions: - uclass_find_device_by_name() - uclass_get_device_by_name() searches the required device for the exactly given name. This patch, presice this fact for both function's comments. Signed-off-by: Przemyslaw Marczak Cc: Simon Glass Acked-by: Simon Glass --- include/dm/uclass-internal.h | 2 +- include/dm/uclass.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/dm/uclass-internal.h b/include/dm/uclass-internal.h index 153f2a7626..a9b2fbe2c6 100644 --- a/include/dm/uclass-internal.h +++ b/include/dm/uclass-internal.h @@ -63,7 +63,7 @@ int uclass_find_next_device(struct udevice **devp); /** * uclass_find_device_by_name() - Find uclass device based on ID and name * - * This searches for a device with the given name. + * This searches for a device with the exactly given name. * * The device is NOT probed, it is merely returned. * diff --git a/include/dm/uclass.h b/include/dm/uclass.h index 66e0ea509c..4cfc0df84c 100644 --- a/include/dm/uclass.h +++ b/include/dm/uclass.h @@ -132,7 +132,7 @@ int uclass_get_device(enum uclass_id id, int index, struct udevice **devp); /** * uclass_get_device_by_name() - Get a uclass device by it's name * - * This searches the devices in the uclass for one with the given name. + * This searches the devices in the uclass for one with the exactly given name. * * The device is probed to activate it ready for use. * -- cgit From 36fa61dc612e363fb60840a06333fc37ec3fb68e Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 27 Feb 2015 22:06:30 -0700 Subject: dm: core: Allow sequence alias support to be removed for SPL In many cases SPL only uses a single serial port and there is no need for alias sequence support. We will just use the serial port pointed to by stdout-path in the /chosen node. Signed-off-by: Simon Glass --- include/config_uncmd_spl.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/config_uncmd_spl.h b/include/config_uncmd_spl.h index a9106f4f3b..38cb0e8aba 100644 --- a/include/config_uncmd_spl.h +++ b/include/config_uncmd_spl.h @@ -31,6 +31,7 @@ #undef CONFIG_DM_WARN #undef CONFIG_DM_DEVICE_REMOVE +#undef CONFIG_DM_SEQ_ALIAS #undef CONFIG_DM_STDIO #endif /* CONFIG_SPL_BUILD */ -- cgit From 7f9875e733b79556ade508b88f88ac1f8a2c7e3c Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 27 Feb 2015 22:06:31 -0700 Subject: dm: core: Remove unbind operations when not required The CONFIG_DM_DEVICE_REMOVE option takes out code related to removing devices. It should also remove the 'unbind' code since if we cannot remove we probably don't need to unbind. Signed-off-by: Simon Glass --- include/dm/uclass-internal.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include') diff --git a/include/dm/uclass-internal.h b/include/dm/uclass-internal.h index a9b2fbe2c6..9b68508667 100644 --- a/include/dm/uclass-internal.h +++ b/include/dm/uclass-internal.h @@ -116,7 +116,11 @@ int uclass_bind_device(struct udevice *dev); * @dev: Pointer to the device * #return 0 on success, -ve on error */ +#ifdef CONFIG_DM_DEVICE_REMOVE int uclass_unbind_device(struct udevice *dev); +#else +static inline int uclass_unbind_device(struct udevice *dev) { return 0; } +#endif /** * uclass_pre_probe_device() - Deal with a device that is about to be probed @@ -149,7 +153,11 @@ int uclass_post_probe_device(struct udevice *dev); * @dev: Pointer to the device * #return 0 on success, -ve on error */ +#ifdef CONFIG_DM_DEVICE_REMOVE int uclass_pre_remove_device(struct udevice *dev); +#else +static inline int uclass_pre_remove_device(struct udevice *dev) { return 0; } +#endif /** * uclass_find() - Find uclass by its id -- cgit From 66312374dca86e77fc9b08f774546e62b6cd1aa7 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 27 Feb 2015 22:06:32 -0700 Subject: dm: Add a panic_str() function to reduce code size The printf() in panic() adds about 1.5KB of code size to SPL when compiled with Thumb-2. Provide a smaller version that does not support printf()-style arguments and use it in two commonly compiled places. Signed-off-by: Simon Glass --- include/vsprintf.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'include') diff --git a/include/vsprintf.h b/include/vsprintf.h index 5624482d57..09c8abd951 100644 --- a/include/vsprintf.h +++ b/include/vsprintf.h @@ -39,9 +39,32 @@ int strict_strtoul(const char *cp, unsigned int base, unsigned long *res); unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base); long simple_strtol(const char *cp, char **endp, unsigned int base); + +/** + * panic() - Print a message and reset/hang + * + * Prints a message on the console(s) and then resets. If CONFIG_PANIC_HANG is + * defined, then it will hang instead of reseting. + * + * @param fmt: printf() format string for message, which should not include + * \n, followed by arguments + */ void panic(const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2), noreturn)); +/** + * panic_str() - Print a message and reset/hang + * + * Prints a message on the console(s) and then resets. If CONFIG_PANIC_HANG is + * defined, then it will hang instead of reseting. + * + * This function can be used instead of panic() when your board does not + * already use printf(), * to keep code size small. + * + * @param fmt: string to display, which should not include \n + */ +void panic_str(const char *str) __attribute__ ((noreturn)); + /** * Format a string and place it in a buffer * -- cgit From b45122fdf5d314ef1f492b051fb104a7b48b8079 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 27 Feb 2015 22:06:34 -0700 Subject: fdt: sandbox: Move setup code from board_f to fdtdec We want to be able to set up the device tree in SPL, so move this code to a common place. Signed-off-by: Simon Glass --- include/fdtdec.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/fdtdec.h b/include/fdtdec.h index d14e06abab..ea8a52602a 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -793,4 +793,10 @@ int fdt_get_named_resource(const void *fdt, int node, const char *property, int fdtdec_decode_memory_region(const void *blob, int node, const char *mem_type, const char *suffix, fdt_addr_t *basep, fdt_size_t *sizep); + +/** + * Set up the device tree ready for use + */ +int setup_fdt(void); + #endif -- cgit From 0879361fd3bc33eb52bcfb2574a78f1e52a36429 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 27 Feb 2015 22:06:35 -0700 Subject: fdt: Rename setup_fdt() and make it prepare also There is little reason to split these two functions. Bring them together which simplifies the init sequence. Signed-off-by: Simon Glass --- include/fdtdec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/fdtdec.h b/include/fdtdec.h index ea8a52602a..0d3e6d9711 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -797,6 +797,6 @@ int fdtdec_decode_memory_region(const void *blob, int node, /** * Set up the device tree ready for use */ -int setup_fdt(void); +int fdtdec_setup(void); #endif -- cgit From fb5cf7f16be725aec7ab0016268b3b4e26460bee Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 27 Feb 2015 22:06:36 -0700 Subject: Move initf_malloc() to a common place To allow this function to be used from SPL, move it to the malloc() code. Signed-off-by: Simon Glass --- include/malloc.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/malloc.h b/include/malloc.h index 5df634873f..f4da9e6ddd 100644 --- a/include/malloc.h +++ b/include/malloc.h @@ -906,6 +906,9 @@ void *realloc_simple(void *ptr, size_t size); #endif +/* Set up pre-relocation malloc() ready for use */ +int initf_malloc(void); + /* Public routines */ /* Simple versions which can be used when space is tight */ -- cgit From b2b0d3e7129d4e59be1a016ad4fb05db87b8c5b4 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 27 Feb 2015 22:06:41 -0700 Subject: dm: core: Select device tree control correctly for SPL Some boards will not use device tree for SPL even with driver model. Add the logic to support this. Signed-off-by: Simon Glass --- include/fdtdec.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include') diff --git a/include/fdtdec.h b/include/fdtdec.h index 0d3e6d9711..659047097a 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -41,6 +41,16 @@ struct fdt_memory { fdt_addr_t end; }; +#ifdef CONFIG_OF_CONTROL +# if defined(CONFIG_SPL_BUILD) && defined(SPL_DISABLE_OF_CONTROL) +# define OF_CONTROL 0 +# else +# define OF_CONTROL 1 +# endif +#else +# define OF_CONTROL 0 +#endif + /* * Information about a resource. start is the first address of the resource * and end is the last address (inclusive). The length of the resource will -- cgit