diff options
Diffstat (limited to 'include')
32 files changed, 405 insertions, 50 deletions
diff --git a/include/altera.h b/include/altera.h index 0327a1b82a..ae5f7eec46 100644 --- a/include/altera.h +++ b/include/altera.h @@ -26,7 +26,7 @@ typedef enum { /* typedef Altera_Family */ min_altera_type, /* insert all new types after this */ Altera_ACEX1K, /* ACEX1K Family */ Altera_CYC2, /* CYCLONII Family */ - Altera_StratixII, /* StratixII Familiy */ + Altera_StratixII, /* StratixII Family */ /* Add new models here */ max_altera_type /* insert all new types before this */ } Altera_Family; /* end, typedef Altera_Family */ diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index 2850ed8a69..74df210033 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -65,7 +65,8 @@ typedef struct global_data { struct global_data *new_gd; /* relocated global data */ #ifdef CONFIG_DM - struct udevice *dm_root;/* Root instance for Driver Model */ + struct udevice *dm_root; /* Root instance for Driver Model */ + struct udevice *dm_root_f; /* Pre-relocation root instance */ struct list_head uclass_root; /* Head of core tree */ #endif @@ -85,6 +86,11 @@ typedef struct global_data { #endif unsigned long timebase_h; unsigned long timebase_l; +#ifdef CONFIG_SYS_MALLOC_F_LEN + unsigned long malloc_base; /* base address of early malloc() */ + unsigned long malloc_limit; /* limit address */ + unsigned long malloc_ptr; /* current address */ +#endif struct arch_global_data arch; /* architecture-specific data */ } gd_t; #endif @@ -100,5 +106,6 @@ typedef struct global_data { #define GD_FLG_LOGINIT 0x00020 /* Log Buffer has been initialized */ #define GD_FLG_DISABLE_CONSOLE 0x00040 /* Disable console (in & out) */ #define GD_FLG_ENV_READY 0x00080 /* Env. imported into hash table */ +#define GD_FLG_SERIAL_READY 0x00100 /* Pre-reloc serial console ready */ #endif /* __ASM_GENERIC_GBL_DATA_H */ diff --git a/include/common.h b/include/common.h index 82c0a5a9a6..a75fc25c5f 100644 --- a/include/common.h +++ b/include/common.h @@ -639,6 +639,11 @@ void serial_puts (const char *); int serial_getc (void); int serial_tstc (void); +/* These versions take a stdio_dev pointer */ +struct stdio_dev; +int serial_stub_getc(struct stdio_dev *sdev); +int serial_stub_tstc(struct stdio_dev *sdev); + void _serial_setbrg (const int); void _serial_putc (const char, const int); void _serial_putc_raw(const char, const int); diff --git a/include/compiler.h b/include/compiler.h index 0734ed4942..9afc11be19 100644 --- a/include/compiler.h +++ b/include/compiler.h @@ -48,6 +48,7 @@ # include <machine/endian.h> typedef unsigned long ulong; #endif +#include <time.h> typedef uint8_t __u8; typedef uint16_t __u16; diff --git a/include/configs/ELPPC.h b/include/configs/ELPPC.h index 0ffbd41b49..debfc3697e 100644 --- a/include/configs/ELPPC.h +++ b/include/configs/ELPPC.h @@ -234,8 +234,8 @@ #define CONFIG_VIDEO #define CONFIG_CFB_CONSOLE #define VIDEO_KBD_INIT_FCT (simple_strtol (getenv("console"), NULL, 10)) -#define VIDEO_TSTC_FCT serial_tstc -#define VIDEO_GETC_FCT serial_getc +#define VIDEO_TSTC_FCT serial_stub_tstc +#define VIDEO_GETC_FCT serial_stub_getc #define CONFIG_VIDEO_SMI_LYNXEM #define CONFIG_VIDEO_LOGO diff --git a/include/configs/MHPC.h b/include/configs/MHPC.h index 6314b5380d..d45be0f609 100644 --- a/include/configs/MHPC.h +++ b/include/configs/MHPC.h @@ -96,8 +96,8 @@ #define CONFIG_VIDEO_LOGO #define VIDEO_KBD_INIT_FCT 0 /* no KBD dev on MHPC - use serial */ -#define VIDEO_TSTC_FCT serial_tstc -#define VIDEO_GETC_FCT serial_getc +#define VIDEO_TSTC_FCT serial_stub_tstc +#define VIDEO_GETC_FCT serial_stub_getc #define CONFIG_BR0_WORKAROUND 1 diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h index a48b386477..34d27c632a 100644 --- a/include/configs/am335x_evm.h +++ b/include/configs/am335x_evm.h @@ -117,7 +117,7 @@ "bootenv=uEnv.txt\0" \ "loadbootenv=load mmc ${mmcdev} ${loadaddr} ${bootenv}\0" \ "importbootenv=echo Importing environment from mmc ...; " \ - "env import -t $loadaddr $filesize\0" \ + "env import -t -r $loadaddr $filesize\0" \ "ramargs=setenv bootargs console=${console} " \ "${optargs} " \ "root=${ramroot} " \ diff --git a/include/configs/h2200.h b/include/configs/h2200.h index 5d0b85e431..9470ad6abc 100644 --- a/include/configs/h2200.h +++ b/include/configs/h2200.h @@ -123,6 +123,7 @@ #define CONFIG_CMD_IMI #define CONFIG_FIT +#define CONFIG_FIT_DISABLE_SHA256 #define CONFIG_SETUP_MEMORY_TAGS #define CONFIG_CMDLINE_TAG #define CONFIG_INITRD_TAG diff --git a/include/configs/jadecpu.h b/include/configs/jadecpu.h index b34e3422da..759e1129c2 100644 --- a/include/configs/jadecpu.h +++ b/include/configs/jadecpu.h @@ -87,8 +87,8 @@ #define CONFIG_SYS_VIDEO_LOGO_MAX_SIZE (800*480 + 256*4 + 10*1024) #define VIDEO_FB_16BPP_WORD_SWAP #define VIDEO_KBD_INIT_FCT 0 -#define VIDEO_TSTC_FCT serial_tstc -#define VIDEO_GETC_FCT serial_getc +#define VIDEO_TSTC_FCT serial_stub_tstc +#define VIDEO_GETC_FCT serial_stub_getc /* * BOOTP options diff --git a/include/configs/nokia_rx51.h b/include/configs/nokia_rx51.h index e0c0fac8e1..53cb3902f3 100644 --- a/include/configs/nokia_rx51.h +++ b/include/configs/nokia_rx51.h @@ -263,9 +263,10 @@ #define VIDEO_TSTC_FCT rx51_kp_tstc #define VIDEO_GETC_FCT rx51_kp_getc #ifndef __ASSEMBLY__ +struct stdio_dev; int rx51_kp_init(void); -int rx51_kp_tstc(void); -int rx51_kp_getc(void); +int rx51_kp_tstc(struct stdio_dev *sdev); +int rx51_kp_getc(struct stdio_dev *sdev); #endif #ifndef MTDPARTS_DEFAULT diff --git a/include/configs/omap3_beagle.h b/include/configs/omap3_beagle.h index 3782049ee6..9ba031d4ba 100644 --- a/include/configs/omap3_beagle.h +++ b/include/configs/omap3_beagle.h @@ -195,7 +195,7 @@ "bootenv=uEnv.txt\0" \ "loadbootenv=fatload mmc ${mmcdev} ${loadaddr} ${bootenv}\0" \ "importbootenv=echo Importing environment from mmc ...; " \ - "env import -t $loadaddr $filesize\0" \ + "env import -t -r $loadaddr $filesize\0" \ "ramargs=setenv bootargs console=${console} " \ "${optargs} " \ "mpurate=${mpurate} " \ diff --git a/include/configs/rpi_b.h b/include/configs/rpi_b.h index ff48598dd5..60f24895e5 100644 --- a/include/configs/rpi_b.h +++ b/include/configs/rpi_b.h @@ -98,7 +98,7 @@ #define CONFIG_SYS_CONSOLE_IS_IN_ENV #define CONFIG_PREBOOT \ "if load mmc 0:1 ${loadaddr} /uEnv.txt; then " \ - "env import -t ${loadaddr} ${filesize}; " \ + "env import -t -r ${loadaddr} ${filesize}; " \ "fi" #define ENV_DEVICE_SETTINGS \ diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h index 12b69d9a24..bf2d25c871 100644 --- a/include/configs/sandbox.h +++ b/include/configs/sandbox.h @@ -68,8 +68,10 @@ #define CONFIG_EFI_PARTITION /* - * Size of malloc() pool, although we don't actually use this yet. + * Size of malloc() pool, before and after relocation */ +#define CONFIG_SYS_MALLOC_F_LEN (1 << 10) +#define CONFIG_MALLOC_F_ADDR 0x0010000 #define CONFIG_SYS_MALLOC_LEN (32 << 20) /* 32MB */ #define CONFIG_SYS_HUSH_PARSER diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h index 26e5cf530e..7005d03d08 100644 --- a/include/dm/device-internal.h +++ b/include/dm/device-internal.h @@ -45,12 +45,14 @@ int device_bind(struct udevice *parent, struct driver *drv, * tree. * * @parent: Pointer to device's parent + * @pre_reloc_only: If true, bind the driver only if its DM_INIT_F flag is set. + * If false bind the driver always. * @info: Name and platdata for this device * @devp: Returns a pointer to the bound device * @return 0 if OK, -ve on error */ -int device_bind_by_name(struct udevice *parent, const struct driver_info *info, - struct udevice **devp); +int device_bind_by_name(struct udevice *parent, bool pre_reloc_only, + const struct driver_info *info, struct udevice **devp); /** * device_probe() - Probe a device, activating it diff --git a/include/dm/device.h b/include/dm/device.h index ae75a3f54d..c8a4072bcf 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -23,6 +23,9 @@ struct driver_info; /* DM is responsible for allocating and freeing platdata */ #define DM_FLAG_ALLOC_PDATA (1 << 1) +/* DM should init this device prior to relocation */ +#define DM_FLAG_PRE_RELOC (1 << 2) + /** * struct udevice - An instance of a driver * @@ -48,10 +51,13 @@ struct driver_info; * @priv: Private data for this device * @uclass: Pointer to uclass for this device * @uclass_priv: The uclass's private data for this device + * @parent_priv: The parent's private data for this device * @uclass_node: Used by uclass to link its devices * @child_head: List of children of this device * @sibling_node: Next device in list of all devices * @flags: Flags for this device DM_FLAG_... + * @req_seq: Requested sequence number for this device (-1 = any) + * @seq: Allocated sequence number for this device (-1 = none) */ struct udevice { struct driver *driver; @@ -62,12 +68,18 @@ struct udevice { void *priv; struct uclass *uclass; void *uclass_priv; + void *parent_priv; struct list_head uclass_node; struct list_head child_head; struct list_head sibling_node; uint32_t flags; + int req_seq; + int seq; }; +/* Maximum sequence number supported */ +#define DM_MAX_SEQ 999 + /* Returns the operations for a device */ #define device_get_ops(dev) (dev->driver->ops) @@ -106,6 +118,10 @@ struct udevice_id { * @remove: Called to remove a device, i.e. de-activate it * @unbind: Called to unbind a device from its driver * @ofdata_to_platdata: Called before probe to decode device tree data + * @child_pre_probe: Called before a child device is probed. The device has + * memory allocated but it has not yet been probed. + * @child_post_remove: Called after a child device is removed. The device + * has memory allocated but its device_remove() method has been called. * @priv_auto_alloc_size: If non-zero this is the size of the private data * to be allocated in the device's ->priv pointer. If zero, then the driver * is responsible for allocating any data required. @@ -114,9 +130,13 @@ struct udevice_id { * This is typically only useful for device-tree-aware drivers (those with * an of_match), since drivers which use platdata will have the data * provided in the U_BOOT_DEVICE() instantiation. - * ops: Driver-specific operations. This is typically a list of function + * @per_child_auto_alloc_size: Each device can hold private data owned by + * its parent. If required this will be automatically allocated if this + * value is non-zero. + * @ops: Driver-specific operations. This is typically a list of function * pointers defined by the driver, to implement driver functions required by * the uclass. + * @flags: driver flags - see DM_FLAGS_... */ struct driver { char *name; @@ -127,9 +147,13 @@ struct driver { int (*remove)(struct udevice *dev); int (*unbind)(struct udevice *dev); int (*ofdata_to_platdata)(struct udevice *dev); + int (*child_pre_probe)(struct udevice *dev); + int (*child_post_remove)(struct udevice *dev); int priv_auto_alloc_size; int platdata_auto_alloc_size; + int per_child_auto_alloc_size; const void *ops; /* driver-specific operations */ + uint32_t flags; }; /* Declare a new U-Boot driver */ @@ -147,6 +171,20 @@ struct driver { void *dev_get_platdata(struct udevice *dev); /** + * dev_get_parentdata() - Get the parent data for a device + * + * The parent data is data stored in the device but owned by the parent. + * For example, a USB device may have parent data which contains information + * about how to talk to the device over USB. + * + * This checks that dev is not NULL, but no other checks for now + * + * @dev Device to check + * @return parent data, or NULL if none + */ +void *dev_get_parentdata(struct udevice *dev); + +/** * dev_get_priv() - Get the private data for a device * * This checks that dev is not NULL, but no other checks for now @@ -156,4 +194,84 @@ void *dev_get_platdata(struct udevice *dev); */ void *dev_get_priv(struct udevice *dev); +/** + * device_get_child() - Get the child of a device by index + * + * Returns the numbered child, 0 being the first. This does not use + * sequence numbers, only the natural order. + * + * @dev: Parent device to check + * @index: Child index + * @devp: Returns pointer to device + */ +int device_get_child(struct udevice *parent, int index, struct udevice **devp); + +/** + * device_find_child_by_seq() - Find a child device based on a 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. + * + * @parent: Parent device + * @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). + * Set to NULL if none is found + * @return 0 if OK, -ve on error + */ +int device_find_child_by_seq(struct udevice *parent, int seq_or_req_seq, + bool find_req_seq, struct udevice **devp); + +/** + * device_get_child_by_seq() - Get a child device based on a sequence + * + * If an active device has this sequence it will be returned. If there is no + * such device then this will check for a device that is requesting this + * sequence. + * + * The device is probed to activate it ready for use. + * + * @parent: Parent device + * @seq: Sequence number to find (0=first) + * @devp: Returns pointer to device (there is only one per for each seq) + * Set to NULL if none is found + * @return 0 if OK, -ve on error + */ +int device_get_child_by_seq(struct udevice *parent, int seq, + struct udevice **devp); + +/** + * device_find_child_by_of_offset() - Find a child device based on FDT offset + * + * Locates a child device by its device tree offset. + * + * @parent: Parent device + * @of_offset: Device tree offset to find + * @devp: Returns pointer to device if found, otherwise this is set to NULL + * @return 0 if OK, -ve on error + */ +int device_find_child_by_of_offset(struct udevice *parent, int of_offset, + struct udevice **devp); + +/** + * device_get_child_by_of_offset() - Get a child device based on FDT offset + * + * Locates a child device by its device tree offset. + * + * The device is probed to activate it ready for use. + * + * @parent: Parent device + * @of_offset: Device tree offset to find + * @devp: Returns pointer to device if found, otherwise this is set to NULL + * @return 0 if OK, -ve on error + */ +int device_get_child_by_of_offset(struct udevice *parent, int seq, + struct udevice **devp); + #endif diff --git a/include/dm/lists.h b/include/dm/lists.h index 49d87e6176..87a3af59c2 100644 --- a/include/dm/lists.h +++ b/include/dm/lists.h @@ -42,7 +42,7 @@ struct uclass_driver *lists_uclass_lookup(enum uclass_id id); * @early_only: If true, bind only drivers with the DM_INIT_F flag. If false * bind all drivers. */ -int lists_bind_drivers(struct udevice *parent); +int lists_bind_drivers(struct udevice *parent, bool pre_reloc_only); /** * lists_bind_fdt() - bind a device tree node diff --git a/include/dm/platdata.h b/include/dm/platdata.h index 0ef3353e74..2bc8b147ed 100644 --- a/include/dm/platdata.h +++ b/include/dm/platdata.h @@ -11,9 +11,15 @@ #ifndef _DM_PLATDATA_H #define _DM_PLATDATA_H +/** + * struct driver_info - Information required to instantiate a device + * + * @name: Device name + * @platdata: Driver-specific platform data + */ struct driver_info { - const char *name; - const void *platdata; + const char *name; + const void *platdata; }; #define U_BOOT_DEVICE(__name) \ diff --git a/include/dm/root.h b/include/dm/root.h index a4826a6e3c..c7f0c1d5ca 100644 --- a/include/dm/root.h +++ b/include/dm/root.h @@ -26,19 +26,66 @@ struct udevice *dm_root(void); * * This scans all available platdata and creates drivers for each * + * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC + * flag. If false bind all drivers. * @return 0 if OK, -ve on error */ -int dm_scan_platdata(void); +int dm_scan_platdata(bool pre_reloc_only); /** * dm_scan_fdt() - Scan the device tree and bind drivers * - * This scans the device tree and creates a driver for each node + * This scans the device tree and creates a driver for each node. Only + * the top-level subnodes are examined. * * @blob: Pointer to device tree blob + * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC + * flag. If false bind all drivers. * @return 0 if OK, -ve on error */ -int dm_scan_fdt(const void *blob); +int dm_scan_fdt(const void *blob, bool pre_reloc_only); + +/** + * dm_scan_fdt_node() - Scan the device tree and bind drivers for a node + * + * This scans the subnodes of a device tree node and and creates a driver + * for each one. + * + * @parent: Parent device for the devices that will be created + * @blob: Pointer to device tree blob + * @offset: Offset of node to scan + * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC + * flag. If false bind all drivers. + * @return 0 if OK, -ve on error + */ +int dm_scan_fdt_node(struct udevice *parent, const void *blob, int offset, + bool pre_reloc_only); + +/** + * dm_scan_other() - Scan for other devices + * + * Some devices may not be visible to Driver Model. This weak function can + * be provided by boards which wish to create their own devices + * programmaticaly. They should do this by calling device_bind() on each + * device. + * + * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC + * flag. If false bind all drivers. + */ +int dm_scan_other(bool pre_reloc_only); + +/** + * dm_init_and_scan() - Initialise Driver Model structures and scan for devices + * + * This function initialises the roots of the driver tree and uclass trees, + * then scans and binds available devices from platform data and the FDT. + * This calls dm_init() to set up Driver Model structures. + * + * @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC + * flag. If false bind all drivers. + * @return 0 if OK, -ve on error + */ +int dm_init_and_scan(bool pre_reloc_only); /** * dm_init() - Initialise Driver Model structures @@ -50,4 +97,12 @@ int dm_scan_fdt(const void *blob); */ int dm_init(void); +/** + * dm_uninit - Uninitialise Driver Model structures + * + * All devices will be removed and unbound + * @return 0 if OK, -ve on error + */ +int dm_uninit(void); + #endif diff --git a/include/dm/test.h b/include/dm/test.h index 409f1a3667..235d728bfb 100644 --- a/include/dm/test.h +++ b/include/dm/test.h @@ -82,6 +82,17 @@ struct dm_test_uclass_priv { int total_add; }; +/** + * struct dm_test_parent_data - parent's information on each child + * + * @sum: Test value used to check parent data works correctly + * @flag: Used to track calling of parent operations + */ +struct dm_test_parent_data { + int sum; + int flag; +}; + /* * Operation counts for the test driver, used to check that each method is * called correctly @@ -100,6 +111,7 @@ extern struct dm_test_state global_test_state; * @fail_count: Number of tests that failed * @force_fail_alloc: Force all memory allocs to fail * @skip_post_probe: Skip uclass post-probe processing + * @removed: Used to keep track of a device that was removed */ struct dm_test_state { struct udevice *root; @@ -107,6 +119,7 @@ struct dm_test_state { int fail_count; int force_fail_alloc; int skip_post_probe; + struct udevice *removed; }; /* Test flags for each test */ @@ -156,6 +169,15 @@ int dm_check_operations(struct dm_test_state *dms, struct udevice *dev, uint32_t base, struct dm_test_priv *priv); /** + * dm_check_devices() - check the devices respond to operations correctly + * + * @dms: Overall test state + * @num_devices: Number of test devices to check + * @return 0 if OK, -ve on error + */ +int dm_check_devices(struct dm_test_state *dms, int num_devices); + +/** * dm_test_main() - Run all the tests * * This runs all available driver model tests diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h index f0e691c18c..dd95fca428 100644 --- a/include/dm/uclass-id.h +++ b/include/dm/uclass-id.h @@ -17,9 +17,10 @@ enum uclass_id { UCLASS_DEMO, UCLASS_TEST, UCLASS_TEST_FDT, + UCLASS_TEST_BUS, /* U-Boot uclasses start here */ - UCLASS_GPIO, + UCLASS_GPIO, /* Bank of general-purpose I/O pins */ UCLASS_COUNT, UCLASS_INVALID = -1, diff --git a/include/dm/uclass-internal.h b/include/dm/uclass-internal.h index 1434db3eb4..f718f37aff 100644 --- a/include/dm/uclass-internal.h +++ b/include/dm/uclass-internal.h @@ -82,4 +82,27 @@ 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 diff --git a/include/dm/uclass.h b/include/dm/uclass.h index afd9923fb3..8d09ecff7b 100644 --- a/include/dm/uclass.h +++ b/include/dm/uclass.h @@ -98,7 +98,7 @@ int uclass_get(enum uclass_id key, struct uclass **ucp); * * The device is probed to activate it ready for use. * - * id: ID to look up + * @id: ID to look up * @index: Device number within that uclass (0=first) * @devp: Returns pointer to device (there is only one per for each ID) * @return 0 if OK, -ve on error @@ -106,6 +106,38 @@ 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_seq() - Get a uclass device based on an ID and sequence + * + * If an active device has this sequence it will be returned. If there is no + * such device then this will check for a device that is requesting this + * sequence. + * + * The device is probed to activate it ready for use. + * + * @id: ID to look up + * @seq: Sequence number to find (0=first) + * @devp: Returns pointer to device (there is only one for each seq) + * @return 0 if OK, -ve on error + */ +int uclass_get_device_by_seq(enum uclass_id id, int seq, struct udevice **devp); + +/** + * uclass_get_device_by_of_offset() - Get a uclass device by device tree node + * + * This searches the devices in the uclass for one attached to the given + * device tree node. + * + * The device is probed to activate it ready for use. + * + * @id: ID to look up + * @node: Device tree offset to search for (if -ve then -ENODEV is returned) + * @devp: Returns pointer to device (there is only one for each node) + * @return 0 if OK, -ve on error + */ +int uclass_get_device_by_of_offset(enum uclass_id id, int node, + struct udevice **devp); + +/** * uclass_first_device() - Get the first device in a uclass * * @id: Uclass ID to look up @@ -124,6 +156,21 @@ int uclass_first_device(enum uclass_id id, struct udevice **devp); int uclass_next_device(struct udevice **devp); /** + * uclass_resolve_seq() - Resolve a device's sequence number + * + * On entry dev->seq is -1, and dev->req_seq may be -1 (to allocate a + * sequence number automatically, or >= 0 to select a particular number. + * If the requested sequence number is in use, then this device will + * be allocated another one. + * + * Note that the device's seq value is not changed by this function. + * + * @dev: Device for which to allocate sequence number + * @return sequence number allocated, or -ve on error + */ +int uclass_resolve_seq(struct udevice *dev); + +/** * uclass_foreach_dev() - Helper function to iteration through devices * * This creates a for() loop which works through the available devices in diff --git a/include/env_callback.h b/include/env_callback.h index f90a7fa3b6..ab4e115fb0 100644 --- a/include/env_callback.h +++ b/include/env_callback.h @@ -60,7 +60,7 @@ void env_callback_init(ENTRY *var_entry); */ #ifdef CONFIG_SPL_BUILD #define U_BOOT_ENV_CALLBACK(name, callback) \ - static inline void _u_boot_env_noop_##name(void) \ + static inline __maybe_unused void _u_boot_env_noop_##name(void) \ { \ (void)callback; \ } diff --git a/include/fdtdec.h b/include/fdtdec.h index a7e6ee7fdf..856e6cf766 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -345,6 +345,35 @@ int fdtdec_find_aliases_for_id(const void *blob, const char *name, int fdtdec_add_aliases_for_id(const void *blob, const char *name, enum fdt_compat_id id, int *node_list, int maxcount); +/** + * Get the alias sequence number of a node + * + * This works out whether a node is pointed to by an alias, and if so, the + * sequence number of that alias. Aliases are of the form <base><num> where + * <num> is the sequence number. For example spi2 would be sequence number + * 2. + * + * @param blob Device tree blob (if NULL, then error is returned) + * @param base Base name for alias (before the underscore) + * @param node Node to look up + * @param seqp This is set to the sequence number if one is found, + * but otherwise the value is left alone + * @return 0 if a sequence was found, -ve if not + */ +int fdtdec_get_alias_seq(const void *blob, const char *base, int node, + int *seqp); + +/** + * Get the offset of the given alias node + * + * This looks up an alias in /aliases then finds the offset of that node. + * + * @param blob Device tree blob (if NULL, then error is returned) + * @param name Alias name, e.g. "console" + * @return Node offset referred to by that alias, or -ve FDT_ERR_... + */ +int fdtdec_get_alias_node(const void *blob, const char *name); + /* * Get the name for a compatible ID * diff --git a/include/i8042.h b/include/i8042.h index 963061920c..58c85ec5f0 100644 --- a/include/i8042.h +++ b/include/i8042.h @@ -72,8 +72,10 @@ void i8042_flush(void); */ int i8042_disable(void); +struct stdio_dev; + int i8042_kbd_init(void); -int i8042_tstc(void); -int i8042_getc(void); +int i8042_tstc(struct stdio_dev *dev); +int i8042_getc(struct stdio_dev *dev); #endif /* _I8042_H_ */ diff --git a/include/ide.h b/include/ide.h index 0424d045a1..c2a48e0b37 100644 --- a/include/ide.h +++ b/include/ide.h @@ -66,12 +66,16 @@ void ide_write_data(int dev, const ulong *sect_buf, int words); /* * I/O function overrides */ +unsigned char ide_inb(int dev, int port); +void ide_outb(int dev, int port, unsigned char val); void ide_input_swap_data(int dev, ulong *sect_buf, int words); void ide_input_data(int dev, ulong *sect_buf, int words); void ide_output_data(int dev, const ulong *sect_buf, int words); void ide_input_data_shorts(int dev, ushort *sect_buf, int shorts); void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts); +void ide_led(uchar led, uchar status); + /** * board_start_ide() - Start up the board IDE interfac * diff --git a/include/linux/compat.h b/include/linux/compat.h index 3fdfb399b5..35e216e06e 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -57,4 +57,23 @@ , __FILE__, __LINE__); } #define PAGE_SIZE 4096 + +/** + * upper_32_bits - return MSB bits 32-63 of a number if little endian, or + * return MSB bits 0-31 of a number if big endian. + * @n: the number we're accessing + * + * A basic shift-right of a 64- or 32-bit quantity. Use this to suppress + * the "right shift count >= width of type" warning when that quantity is + * 32-bits. + */ +#define upper_32_bits(n) ((u32)(((n) >> 16) >> 16)) + +/** + * lower_32_bits - return LSB bits 0-31 of a number if little endian, or + * return LSB bits 32-63 of a number if big endian. + * @n: the number we're accessing + */ +#define lower_32_bits(n) ((u32)(n)) + #endif diff --git a/include/mmc.h b/include/mmc.h index f46572e177..7f5f9bc8ca 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -327,10 +327,11 @@ struct mmc *find_mmc_device(int dev_num); int mmc_set_dev(int dev_num); void print_mmc_devices(char separator); int get_mmc_num(void); -int board_mmc_getcd(struct mmc *mmc); int mmc_switch_part(int dev_num, unsigned int part_num); int mmc_getcd(struct mmc *mmc); +int board_mmc_getcd(struct mmc *mmc); int mmc_getwp(struct mmc *mmc); +int board_mmc_getwp(struct mmc *mmc); int mmc_set_dsr(struct mmc *mmc, u16 val); /* Function to change the size of boot partition and rpmb partitions */ int mmc_boot_partition_size_change(struct mmc *mmc, unsigned long bootsize, @@ -385,6 +386,7 @@ int mmc_legacy_init(int verbose); #endif int board_mmc_init(bd_t *bis); +int cpu_mmc_init(bd_t *bis); /* Set block count limit because of 16 bit register limit on some hardware*/ #ifndef CONFIG_SYS_MMC_MAX_BLK_COUNT diff --git a/include/search.h b/include/search.h index ae3efc43ca..9701efb2df 100644 --- a/include/search.h +++ b/include/search.h @@ -102,7 +102,8 @@ extern ssize_t hexport_r(struct hsearch_data *__htab, */ extern int himport_r(struct hsearch_data *__htab, const char *__env, size_t __size, const char __sep, - int __flag, int nvars, char * const vars[]); + int __flag, int __crlf_is_lf, int nvars, + char * const vars[]); /* Walk the whole table calling the callback on each element */ extern int hwalk_r(struct hsearch_data *__htab, int (*callback)(ENTRY *)); diff --git a/include/status_led.h b/include/status_led.h index 0eb91b8695..b8aaaf78fc 100644 --- a/include/status_led.h +++ b/include/status_led.h @@ -272,19 +272,21 @@ extern void __led_set (led_id_t mask, int state); # include <asm/status_led.h> #endif +#endif /* CONFIG_STATUS_LED */ + /* * Coloured LEDs API */ #ifndef __ASSEMBLY__ -extern void coloured_LED_init (void); -extern void red_led_on(void); -extern void red_led_off(void); -extern void green_led_on(void); -extern void green_led_off(void); -extern void yellow_led_on(void); -extern void yellow_led_off(void); -extern void blue_led_on(void); -extern void blue_led_off(void); +void coloured_LED_init(void); +void red_led_on(void); +void red_led_off(void); +void green_led_on(void); +void green_led_off(void); +void yellow_led_on(void); +void yellow_led_off(void); +void blue_led_on(void); +void blue_led_off(void); #else .extern LED_init .extern red_led_on @@ -297,6 +299,4 @@ extern void blue_led_off(void); .extern blue_led_off #endif -#endif /* CONFIG_STATUS_LED */ - #endif /* _STATUS_LED_H_ */ diff --git a/include/stdio_dev.h b/include/stdio_dev.h index e6dc12ac39..a7d0825c7e 100644 --- a/include/stdio_dev.h +++ b/include/stdio_dev.h @@ -27,18 +27,21 @@ struct stdio_dev { /* GENERAL functions */ - int (*start) (void); /* To start the device */ - int (*stop) (void); /* To stop the device */ + int (*start)(struct stdio_dev *dev); /* To start the device */ + int (*stop)(struct stdio_dev *dev); /* To stop the device */ /* OUTPUT functions */ - void (*putc) (const char c); /* To put a char */ - void (*puts) (const char *s); /* To put a string (accelerator) */ + /* To put a char */ + void (*putc)(struct stdio_dev *dev, const char c); + /* To put a string (accelerator) */ + void (*puts)(struct stdio_dev *dev, const char *s); /* INPUT functions */ - int (*tstc) (void); /* To test if a char is ready... */ - int (*getc) (void); /* To get that char */ + /* To test if a char is ready... */ + int (*tstc)(struct stdio_dev *dev); + int (*getc)(struct stdio_dev *dev); /* To get that char */ /* Other functions */ @@ -74,10 +77,12 @@ extern char *stdio_names[MAX_FILES]; * PROTOTYPES */ int stdio_register (struct stdio_dev * dev); +int stdio_register_dev(struct stdio_dev *dev, struct stdio_dev **devp); int stdio_init (void); void stdio_print_current_devices(void); #ifdef CONFIG_SYS_STDIO_DEREGISTER int stdio_deregister(const char *devname); +int stdio_deregister_dev(struct stdio_dev *dev); #endif struct list_head* stdio_get_list(void); struct stdio_dev* stdio_get_by_name(const char* name); diff --git a/include/video.h b/include/video.h index 0ff857bc9f..673aa2ec56 100644 --- a/include/video.h +++ b/include/video.h @@ -11,9 +11,11 @@ /* Video functions */ -int video_init (void *videobase); -void video_putc (const char c); -void video_puts (const char *s); +struct stdio_dev; + +int video_init(void *videobase); +void video_putc(struct stdio_dev *dev, const char c); +void video_puts(struct stdio_dev *dev, const char *s); /** * Display a BMP format bitmap on the screen |