mirror of
https://github.com/ipxe/ipxe
synced 2026-01-23 20:49:40 +03:00
[dt] Provide dt_ioremap() to map device registers
Devicetree devices encode register address ranges within the "reg" property, with the number of cells used for addresses and for sizes determined by the #address-cells and #size-cells properties of the immediate parent device. Record the number of address and size cells for each device, and provide a dt_ioremap() function to allow drivers to map a specified range without having to directly handle the "reg" property. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -21,8 +21,19 @@ struct dt_device {
|
||||
struct dt_driver *driver;
|
||||
/** Driver-private data */
|
||||
void *priv;
|
||||
|
||||
/** Number of address cells for child devices */
|
||||
uint32_t address_cells;
|
||||
/** Number of size cells for child devices */
|
||||
uint32_t size_cells;
|
||||
};
|
||||
|
||||
/** Default number of address cells, if not specified */
|
||||
#define DT_DEFAULT_ADDRESS_CELLS 2
|
||||
|
||||
/** Default number of size cells, if not specified */
|
||||
#define DT_DEFAULT_SIZE_CELLS 1
|
||||
|
||||
/** A devicetree driver */
|
||||
struct dt_driver {
|
||||
/** Driver name */
|
||||
@@ -73,4 +84,7 @@ static inline void * dt_get_drvdata ( struct dt_device *dt ) {
|
||||
return dt->priv;
|
||||
}
|
||||
|
||||
extern void * dt_ioremap ( struct dt_device *dt, unsigned int offset,
|
||||
unsigned int index, size_t len );
|
||||
|
||||
#endif /* _IPXE_DEVTREE_H */
|
||||
|
||||
Reference in New Issue
Block a user