Merge branch 'master' of git://git.denx.de/u-boot-dm

This commit is contained in:
Tom Rini
2015-04-23 13:53:09 -04:00
36 changed files with 814 additions and 216 deletions

View File

@@ -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 */

View File

@@ -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
*
@@ -265,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
*
@@ -273,6 +299,16 @@ ulong dev_get_driver_data(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
*

View File

@@ -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

View File

@@ -10,19 +10,94 @@
#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.
*/
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.
* The function uclass_get_device_tail() can be used to probe the device.
*
* @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.
* The function uclass_get_device_tail() can be used to probe the device.
*
* @return 0 if OK (found or not found), -1 on error
*/
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 exactly 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
*
@@ -41,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
@@ -74,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
@@ -94,27 +177,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

View File

@@ -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;
@@ -125,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 exactly 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
*

View File

@@ -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
@@ -793,4 +803,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 fdtdec_setup(void);
#endif

View File

@@ -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 */

View File

@@ -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
*