diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/dm/device.h | 32 | ||||
-rw-r--r-- | include/dm/ofnode.h | 56 | ||||
-rw-r--r-- | include/dm/uclass-id.h | 1 | ||||
-rw-r--r-- | include/dm/uclass-internal.h | 37 | ||||
-rw-r--r-- | include/dm/uclass.h | 18 | ||||
-rw-r--r-- | include/linker_lists.h | 3 | ||||
-rw-r--r-- | include/pci.h | 2 | ||||
-rw-r--r-- | include/spi.h | 20 |
8 files changed, 98 insertions, 71 deletions
diff --git a/include/dm/device.h b/include/dm/device.h index ed80ae44..30fc98d 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -131,9 +131,11 @@ enum { * @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). This is set up - * when the device is probed and will be unique within the device's uclass. + * when the device is bound and is unique within the device's uclass. If the + * device has an alias in the devicetree then that is used to set the sequence + * number. Otherwise, the next available number is used. Sequence numbers are + * used by certain commands that need device to be numbered (e.g. 'mmc dev') * @devres_head: List of memory allocations associated with this device. * When CONFIG_DEVRES is enabled, devm_kmalloc() and friends will * add to this list. Memory so-allocated will be freed @@ -156,8 +158,7 @@ struct udevice { struct list_head child_head; struct list_head sibling_node; uint32_t flags; - int req_seq; - int seq; + int sqq; #ifdef CONFIG_DEVRES struct list_head devres_head; #endif @@ -182,6 +183,11 @@ static inline bool dev_has_of_node(struct udevice *dev) return ofnode_valid(dev->node); } +static inline int dev_seq(const struct udevice *dev) +{ + return dev->sqq; +} + /** * struct udevice_id - Lists the compatible strings supported by a driver * @compatible: Compatible string @@ -439,24 +445,16 @@ int device_get_child_count(const struct udevice *parent); /** * 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. + * This searches for a device with the given seq. * * @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 + * @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 + * @return 0 if OK, -ENODEV if not found */ -int device_find_child_by_seq(const struct udevice *parent, int seq_or_req_seq, - bool find_req_seq, struct udevice **devp); +int device_find_child_by_seq(const struct udevice *parent, int seq, + struct udevice **devp); /** * device_get_child_by_seq() - Get a child device based on a sequence diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 53f04ac..5b08865 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -10,6 +10,7 @@ /* TODO(sjg@chromium.org): Drop fdtdec.h include */ #include <fdtdec.h> #include <dm/of.h> +#include <dm/of_access.h> #include <log.h> /* Enable checks to protect against invalid calls */ @@ -357,17 +358,6 @@ const char *ofnode_read_string(ofnode node, const char *propname); */ int ofnode_read_u32_array(ofnode node, const char *propname, u32 *out_values, size_t sz); -/** - * ofnode_is_enabled() - Checks whether a node is enabled. - * This looks for a 'status' property. If this exists, then returns true if - * the status is 'okay' and false otherwise. If there is no status property, - * it returns true on the assumption that anything mentioned should be enabled - * by default. - * - * @node: node to examine - * @return false (not enabled) or true (enabled) - */ -bool ofnode_is_enabled(ofnode node); /** * ofnode_read_bool() - read a boolean value from a property @@ -388,6 +378,49 @@ bool ofnode_read_bool(ofnode node, const char *propname); */ ofnode ofnode_find_subnode(ofnode node, const char *subnode_name); +#if CONFIG_IS_ENABLED(DM_INLINE_OFNODE) +static inline bool ofnode_is_enabled(ofnode node) +{ + if (ofnode_is_np(node)) { + return of_device_is_available(ofnode_to_np(node)); + } else { + return fdtdec_get_is_enabled(gd->fdt_blob, + ofnode_to_offset(node)); + } +} + +static inline ofnode ofnode_first_subnode(ofnode node) +{ + assert(ofnode_valid(node)); + if (ofnode_is_np(node)) + return np_to_ofnode(node.np->child); + + return offset_to_ofnode( + fdt_first_subnode(gd->fdt_blob, ofnode_to_offset(node))); +} + +static inline ofnode ofnode_next_subnode(ofnode node) +{ + assert(ofnode_valid(node)); + if (ofnode_is_np(node)) + return np_to_ofnode(node.np->sibling); + + return offset_to_ofnode( + fdt_next_subnode(gd->fdt_blob, ofnode_to_offset(node))); +} +#else +/** + * ofnode_is_enabled() - Checks whether a node is enabled. + * This looks for a 'status' property. If this exists, then returns true if + * the status is 'okay' and false otherwise. If there is no status property, + * it returns true on the assumption that anything mentioned should be enabled + * by default. + * + * @node: node to examine + * @return false (not enabled) or true (enabled) + */ +bool ofnode_is_enabled(ofnode node); + /** * ofnode_first_subnode() - find the first subnode of a parent node * @@ -405,6 +438,7 @@ ofnode ofnode_first_subnode(ofnode node); * has no more siblings) */ ofnode ofnode_next_subnode(ofnode node); +#endif /* DM_INLINE_OFNODE */ /** * ofnode_get_parent() - get the ofnode's parent (enclosing ofnode) diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h index e952a99..ae4425d 100644 --- a/include/dm/uclass-id.h +++ b/include/dm/uclass-id.h @@ -16,6 +16,7 @@ enum uclass_id { UCLASS_DEMO, UCLASS_TEST, UCLASS_TEST_FDT, + UCLASS_TEST_FDT_MANUAL, UCLASS_TEST_BUS, UCLASS_TEST_PROBE, UCLASS_TEST_DUMMY, diff --git a/include/dm/uclass-internal.h b/include/dm/uclass-internal.h index 6e3f15c..3e052f9 100644 --- a/include/dm/uclass-internal.h +++ b/include/dm/uclass-internal.h @@ -12,17 +12,20 @@ #include <dm/ofnode.h> /** - * uclass_find_next_free_req_seq() - Get the next free req_seq number + * uclass_find_next_free_seq() - Get the next free sequence number * - * This returns the next free req_seq number. This is useful only if - * OF_CONTROL is not used. The next free req_seq number is simply the - * maximum req_seq of the uclass + 1. - * This allows assiging req_seq number in the binding order. + * This returns the next free sequence number. This is useful only if + * OF_CONTROL is not used. The next free sequence number is simply the + * maximum sequence number used by all devices in the uclass + 1. The value + * returned is always greater than the largest alias, if DM_SEQ_ALIAS is enabled + * and the uclass has the DM_UC_FLAG_SEQ_ALIAS flag. * - * @id: Id number of the uclass - * @return The next free req_seq number + * This allows assigning the sequence number in the binding order. + * + * @uc: uclass to check + * @return The next free sequence number */ -int uclass_find_next_free_req_seq(enum uclass_id id); +int uclass_find_next_free_seq(struct uclass *uc); /** * uclass_get_device_tail() - handle the end of a get_device call @@ -103,25 +106,17 @@ int uclass_find_device_by_name(enum uclass_id id, const char *name, /** * 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. + * This searches for a device with the given seq. * * 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 + * @seq: Sequence number to find (0=first) * @devp: Returns pointer to device (there is only one per for each seq) - * @return 0 if OK, -ve on error + * @return 0 if OK, -ENODEV if not found */ -int uclass_find_device_by_seq(enum uclass_id id, int seq_or_req_seq, - bool find_req_seq, struct udevice **devp); +int uclass_find_device_by_seq(enum uclass_id id, int seq, + struct udevice **devp); /** * uclass_find_device_by_of_offset() - Find a uclass device by device tree node diff --git a/include/dm/uclass.h b/include/dm/uclass.h index 068e8ea..91edbfb 100644 --- a/include/dm/uclass.h +++ b/include/dm/uclass.h @@ -44,6 +44,9 @@ struct udevice; /* Members of this uclass sequence themselves with aliases */ #define DM_UC_FLAG_SEQ_ALIAS (1 << 0) +/* Members of this uclass without aliases don't get a sequence number */ +#define DM_UC_FLAG_NO_AUTO_SEQ (1 << 1) + /* Same as DM_FLAG_ALLOC_PRIV_DMA */ #define DM_UC_FLAG_ALLOC_PRIV_DMA (1 << 5) @@ -366,21 +369,6 @@ int uclass_first_device_drvdata(enum uclass_id id, ulong driver_data, 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_id_foreach_dev() - Helper function to iteration through devices * * This creates a for() loop which works through the available devices in diff --git a/include/linker_lists.h b/include/linker_lists.h index d775d04..fd98ecd 100644 --- a/include/linker_lists.h +++ b/include/linker_lists.h @@ -124,7 +124,8 @@ */ #define ll_entry_start(_type, _list) \ ({ \ - static char start[0] __aligned(4) __attribute__((unused, \ + static char start[0] __aligned(CONFIG_LINKER_LIST_ALIGN) \ + __attribute__((unused, \ section(".u_boot_list_2_"#_list"_1"))); \ (_type *)&start; \ }) diff --git a/include/pci.h b/include/pci.h index d5b42ce..5f36537 100644 --- a/include/pci.h +++ b/include/pci.h @@ -934,7 +934,7 @@ struct dm_pci_ops { * PCI buses must support reading and writing configuration values * so that the bus can be scanned and its devices configured. * - * Normally PCI_BUS(@bdf) is the same as @bus->seq, but not always. + * Normally PCI_BUS(@bdf) is the same as @dev_seq(bus), but not always. * If bridges exist it is possible to use the top-level bus to * access a sub-bus. In that case @bus will be the top-level bus * and PCI_BUS(bdf) will be a different (higher) value diff --git a/include/spi.h b/include/spi.h index 6b42b3e..e81f799 100644 --- a/include/spi.h +++ b/include/spi.h @@ -39,9 +39,22 @@ #define SPI_DEFAULT_WORDLEN 8 -/* TODO(sjg@chromium.org): Remove this and use max_hz from struct spi_slave */ +/** + * struct dm_spi_bus - SPI bus info + * + * This contains information about a SPI bus. To obtain this structure, use + * dev_get_uclass_priv(bus) where bus is the SPI bus udevice. + * + * @max_hz: Maximum speed that the bus can tolerate. + * @speed: Current bus speed. This is 0 until the bus is first claimed. + * @mode: Current bus mode. This is 0 until the bus is first claimed. + * + * TODO(sjg@chromium.org): Remove this and use max_hz from struct spi_slave. + */ struct dm_spi_bus { uint max_hz; + uint speed; + uint mode; }; /** @@ -112,11 +125,9 @@ enum spi_polarity { * * @dev: SPI slave device * @max_hz: Maximum speed for this slave - * @speed: Current bus speed. This is 0 until the bus is first - * claimed. * @bus: ID of the bus that the slave is attached to. For * driver model this is the sequence number of the SPI - * bus (bus->seq) so does not need to be stored + * bus (dev_seq(bus)) so does not need to be stored * @cs: ID of the chip select connected to the slave. * @mode: SPI mode to use for this slave (see SPI mode flags) * @wordlen: Size of SPI word in number of bits @@ -131,7 +142,6 @@ struct spi_slave { #if CONFIG_IS_ENABLED(DM_SPI) struct udevice *dev; /* struct spi_slave is dev->parentdata */ uint max_hz; - uint speed; #else unsigned int bus; unsigned int cs; |