diff options
Diffstat (limited to 'include')
53 files changed, 405 insertions, 183 deletions
diff --git a/include/_exports.h b/include/_exports.h index aeb666c847..8030d70c0b 100644 --- a/include/_exports.h +++ b/include/_exports.h @@ -40,7 +40,7 @@ EXPORT_FUNC(simple_strtol, long, simple_strtol, const char *, char **, unsigned int) EXPORT_FUNC(strcmp, int, strcmp, const char *cs, const char *ct) -#if defined(CONFIG_CMD_I2C) && !defined(CONFIG_DM_I2C) +#if defined(CONFIG_CMD_I2C) && !CONFIG_IS_ENABLED(DM_I2C) EXPORT_FUNC(i2c_write, int, i2c_write, uchar, uint, int , uchar * , int) EXPORT_FUNC(i2c_read, int, i2c_read, uchar, uint, int , uchar * , int) #else diff --git a/include/config_fallbacks.h b/include/config_fallbacks.h index c18f19a550..a318926fe8 100644 --- a/include/config_fallbacks.h +++ b/include/config_fallbacks.h @@ -46,7 +46,7 @@ #define CONFIG_SYS_MAXARGS 16 #endif -#ifdef CONFIG_DM_I2C +#if CONFIG_IS_ENABLED(DM_I2C) # ifdef CONFIG_SYS_I2C # error "Cannot define CONFIG_SYS_I2C when CONFIG_DM_I2C is used" # endif diff --git a/include/configs/MPC8548CDS.h b/include/configs/MPC8548CDS.h index 4efc182ef8..0605f70ffc 100644 --- a/include/configs/MPC8548CDS.h +++ b/include/configs/MPC8548CDS.h @@ -296,7 +296,7 @@ extern unsigned long get_clock_freq(void); /* * I2C */ -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) #define CONFIG_SYS_I2C #define CONFIG_SYS_FSL_I2C_SPEED 400000 #define CONFIG_SYS_FSL_I2C_SLAVE 0x7F diff --git a/include/configs/P1010RDB.h b/include/configs/P1010RDB.h index 806d154328..1b68fd1072 100644 --- a/include/configs/P1010RDB.h +++ b/include/configs/P1010RDB.h @@ -525,7 +525,7 @@ extern unsigned long get_sdram_size(void); #define CONFIG_SYS_NS16550_COM2 (CONFIG_SYS_CCSRBAR+0x4600) /* I2C */ -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) #define CONFIG_SYS_I2C #define CONFIG_SYS_FSL_I2C_SPEED 400000 #define CONFIG_SYS_FSL_I2C_SLAVE 0x7F diff --git a/include/configs/P2041RDB.h b/include/configs/P2041RDB.h index 65d3dfa0f0..3895c2d0c7 100644 --- a/include/configs/P2041RDB.h +++ b/include/configs/P2041RDB.h @@ -259,7 +259,7 @@ unsigned long get_board_sys_clk(unsigned long dummy); #define CONFIG_SYS_NS16550_COM4 (CONFIG_SYS_CCSRBAR+0x11D600) /* I2C */ -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) #define CONFIG_SYS_I2C #define CONFIG_SYS_FSL_I2C_SPEED 400000 #define CONFIG_SYS_FSL_I2C_SLAVE 0x7F diff --git a/include/configs/T102xRDB.h b/include/configs/T102xRDB.h index 201da871bd..35b11ad88a 100644 --- a/include/configs/T102xRDB.h +++ b/include/configs/T102xRDB.h @@ -422,7 +422,7 @@ unsigned long get_board_ddr_clk(void); #endif /* I2C */ -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) #define CONFIG_SYS_I2C #define CONFIG_SYS_FSL_I2C_SPEED 50000 /* I2C speed in Hz */ #define CONFIG_SYS_FSL_I2C_SLAVE 0x7F diff --git a/include/configs/T104xRDB.h b/include/configs/T104xRDB.h index aee00a86cf..ea239f74c1 100644 --- a/include/configs/T104xRDB.h +++ b/include/configs/T104xRDB.h @@ -30,7 +30,6 @@ #define CONFIG_SPL_SKIP_RELOCATE #define CONFIG_SPL_COMMON_INIT_DDR #define CONFIG_SYS_CCSR_DO_NOT_RELOCATE -#undef CONFIG_DM_I2C #endif #define RESET_VECTOR_OFFSET 0x27FFC #define BOOT_PAGE_OFFSET 0x27000 @@ -453,7 +452,7 @@ $(SRCTREE)/board/freescale/t104xrdb/t1042d4_sd_rcw.cfg #endif /* I2C */ -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) #define CONFIG_SYS_I2C #define CONFIG_SYS_FSL_I2C_SPEED 400000 /* I2C speed in Hz */ #define CONFIG_SYS_FSL_I2C2_SPEED 400000 diff --git a/include/configs/T208xQDS.h b/include/configs/T208xQDS.h index 1735b170fd..f0ef365a85 100644 --- a/include/configs/T208xQDS.h +++ b/include/configs/T208xQDS.h @@ -377,7 +377,7 @@ unsigned long get_board_ddr_clk(void); /* * I2C */ -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) #define CONFIG_SYS_I2C #define CONFIG_SYS_FSL_I2C_SLAVE 0x7F #define CONFIG_SYS_FSL_I2C2_SLAVE 0x7F diff --git a/include/configs/T208xRDB.h b/include/configs/T208xRDB.h index 30e38444c0..e467ef453d 100644 --- a/include/configs/T208xRDB.h +++ b/include/configs/T208xRDB.h @@ -322,7 +322,7 @@ unsigned long get_board_ddr_clk(void); /* * I2C */ -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) #define CONFIG_SYS_I2C #define CONFIG_SYS_FSL_I2C_SLAVE 0x7F #define CONFIG_SYS_FSL_I2C2_SLAVE 0x7F diff --git a/include/configs/T4240RDB.h b/include/configs/T4240RDB.h index 7f831fb8bc..a04d9137b3 100644 --- a/include/configs/T4240RDB.h +++ b/include/configs/T4240RDB.h @@ -154,7 +154,7 @@ #define CONFIG_SYS_NS16550_COM4 (CONFIG_SYS_CCSRBAR+0x11D600) /* I2C */ -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) #define CONFIG_SYS_I2C #define CONFIG_SYS_FSL_I2C_SLAVE 0x7F #define CONFIG_SYS_FSL_I2C_OFFSET 0x118000 diff --git a/include/configs/am43xx_evm.h b/include/configs/am43xx_evm.h index 8355b4abc0..6df6b49c80 100644 --- a/include/configs/am43xx_evm.h +++ b/include/configs/am43xx_evm.h @@ -26,7 +26,7 @@ #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2 /* Power */ -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) #define CONFIG_POWER #define CONFIG_POWER_I2C #endif diff --git a/include/configs/corenet_ds.h b/include/configs/corenet_ds.h index 731f884f40..d0843c284e 100644 --- a/include/configs/corenet_ds.h +++ b/include/configs/corenet_ds.h @@ -269,7 +269,7 @@ #define CONFIG_SYS_NS16550_COM4 (CONFIG_SYS_CCSRBAR+0x11D600) /* I2C */ -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) #define CONFIG_SYS_I2C #define CONFIG_SYS_FSL_I2C_SPEED 400000 #define CONFIG_SYS_FSL_I2C_SLAVE 0x7F diff --git a/include/configs/imx8mp_evk.h b/include/configs/imx8mp_evk.h index 4850b1b934..61a5c6fb79 100644 --- a/include/configs/imx8mp_evk.h +++ b/include/configs/imx8mp_evk.h @@ -37,7 +37,6 @@ #define CONFIG_POWER_I2C #define CONFIG_POWER_PCA9450 -#undef CONFIG_DM_I2C #define CONFIG_SYS_I2C #endif diff --git a/include/configs/ls1012a_common.h b/include/configs/ls1012a_common.h index f6b5d47c25..a908b0acb0 100644 --- a/include/configs/ls1012a_common.h +++ b/include/configs/ls1012a_common.h @@ -55,7 +55,7 @@ CONFIG_SYS_SCSI_MAX_LUN) /* I2C */ -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) #define CONFIG_SYS_I2C #else #define CONFIG_I2C_SET_DEFAULT_BUS_NUM diff --git a/include/configs/ls1021aiot.h b/include/configs/ls1021aiot.h index cf4d60ad60..e2ae6e46c0 100644 --- a/include/configs/ls1021aiot.h +++ b/include/configs/ls1021aiot.h @@ -98,7 +98,7 @@ * I2C */ -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) #define CONFIG_SYS_I2C #else #define CONFIG_I2C_SET_DEFAULT_BUS_NUM diff --git a/include/configs/ls1021aqds.h b/include/configs/ls1021aqds.h index b4c70333de..7f65845283 100644 --- a/include/configs/ls1021aqds.h +++ b/include/configs/ls1021aqds.h @@ -330,7 +330,7 @@ unsigned long get_board_ddr_clk(void); /* * I2C */ -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) #define CONFIG_SYS_I2C #else #define CONFIG_I2C_SET_DEFAULT_BUS_NUM diff --git a/include/configs/ls1021atsn.h b/include/configs/ls1021atsn.h index 996c970ec8..f76d5a1bd7 100644 --- a/include/configs/ls1021atsn.h +++ b/include/configs/ls1021atsn.h @@ -104,7 +104,7 @@ #define CONFIG_SYS_NS16550_CLK get_serial_clock() /* I2C */ -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) #define CONFIG_SYS_I2C #else #define CONFIG_I2C_SET_DEFAULT_BUS_NUM diff --git a/include/configs/ls1021atwr.h b/include/configs/ls1021atwr.h index dfb56437d9..d6783db2c2 100644 --- a/include/configs/ls1021atwr.h +++ b/include/configs/ls1021atwr.h @@ -208,7 +208,7 @@ /* * I2C */ -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) #define CONFIG_SYS_I2C #else #define CONFIG_I2C_SET_DEFAULT_BUS_NUM @@ -442,7 +442,6 @@ #ifdef CONFIG_SPL_BUILD #define CONFIG_SYS_MONITOR_BASE CONFIG_SPL_TEXT_BASE -#undef CONFIG_DM_I2C #else #define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_TEXT_BASE /* start of monitor */ #endif diff --git a/include/configs/ls1028a_common.h b/include/configs/ls1028a_common.h index 1c4af7d176..31fcdae986 100644 --- a/include/configs/ls1028a_common.h +++ b/include/configs/ls1028a_common.h @@ -44,7 +44,7 @@ #endif /* I2C */ -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) #define CONFIG_SYS_I2C #endif diff --git a/include/configs/ls1043a_common.h b/include/configs/ls1043a_common.h index 4e3e1a946b..29a3790c45 100644 --- a/include/configs/ls1043a_common.h +++ b/include/configs/ls1043a_common.h @@ -149,7 +149,7 @@ #endif /* I2C */ -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) #define CONFIG_SYS_I2C #define CONFIG_SYS_I2C_MXC_I2C1 /* enable I2C bus 1 */ #define CONFIG_SYS_I2C_MXC_I2C2 /* enable I2C bus 2 */ diff --git a/include/configs/ls1046a_common.h b/include/configs/ls1046a_common.h index 32658cf641..0c3978a922 100644 --- a/include/configs/ls1046a_common.h +++ b/include/configs/ls1046a_common.h @@ -16,7 +16,6 @@ #define SPL_NO_QSPI #define SPL_NO_USB #define SPL_NO_SATA -#undef CONFIG_DM_I2C #endif #if defined(CONFIG_SPL_BUILD) && \ (defined(CONFIG_NAND_BOOT) || defined(CONFIG_QSPI_BOOT)) @@ -134,7 +133,7 @@ #endif /* I2C */ -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) #define CONFIG_SYS_I2C #define CONFIG_SYS_I2C_MXC_I2C1 /* enable I2C bus 1 */ #define CONFIG_SYS_I2C_MXC_I2C2 /* enable I2C bus 2 */ diff --git a/include/configs/ls1088a_common.h b/include/configs/ls1088a_common.h index b9a956b90b..d574e7e592 100644 --- a/include/configs/ls1088a_common.h +++ b/include/configs/ls1088a_common.h @@ -61,7 +61,7 @@ #endif /* I2C */ -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) #define CONFIG_SYS_I2C #endif diff --git a/include/configs/ls1088aqds.h b/include/configs/ls1088aqds.h index 1626e65056..0dcf844303 100644 --- a/include/configs/ls1088aqds.h +++ b/include/configs/ls1088aqds.h @@ -26,7 +26,7 @@ unsigned long get_board_ddr_clk(void); #define CONFIG_DDR_CLK_FREQ 100000000 #else #define CONFIG_QIXIS_I2C_ACCESS -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) #define CONFIG_SYS_I2C_EARLY_INIT #endif #define CONFIG_SYS_CLK_FREQ get_board_sys_clk() diff --git a/include/configs/ls2080a_common.h b/include/configs/ls2080a_common.h index 1042555a8c..2ed6584073 100644 --- a/include/configs/ls2080a_common.h +++ b/include/configs/ls2080a_common.h @@ -74,7 +74,7 @@ #endif /* I2C */ -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) #define CONFIG_SYS_I2C #endif diff --git a/include/configs/ls2080aqds.h b/include/configs/ls2080aqds.h index 9e174afb92..b3fce1b7f7 100644 --- a/include/configs/ls2080aqds.h +++ b/include/configs/ls2080aqds.h @@ -16,7 +16,7 @@ unsigned long get_board_ddr_clk(void); #ifdef CONFIG_FSL_QSPI #define CONFIG_QIXIS_I2C_ACCESS -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) #define CONFIG_SYS_I2C_EARLY_INIT #endif #define CONFIG_SYS_I2C_IFDR_DIV 0x7e diff --git a/include/configs/ls2080ardb.h b/include/configs/ls2080ardb.h index ab4214c265..8626a1d5e6 100644 --- a/include/configs/ls2080ardb.h +++ b/include/configs/ls2080ardb.h @@ -13,7 +13,7 @@ #ifdef CONFIG_TARGET_LS2081ARDB #define CONFIG_QIXIS_I2C_ACCESS #endif -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) #define CONFIG_SYS_I2C_EARLY_INIT #endif #endif diff --git a/include/configs/p1_p2_rdb_pc.h b/include/configs/p1_p2_rdb_pc.h index a9bf213d8b..066311a97e 100644 --- a/include/configs/p1_p2_rdb_pc.h +++ b/include/configs/p1_p2_rdb_pc.h @@ -463,7 +463,7 @@ #define CONFIG_SYS_NS16550_COM2 (CONFIG_SYS_CCSRBAR+0x4600) /* I2C */ -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) #define CONFIG_SYS_I2C #define CONFIG_SYS_FSL_I2C_SPEED 400000 #define CONFIG_SYS_FSL_I2C_SLAVE 0x7F diff --git a/include/configs/phycore_imx8mp.h b/include/configs/phycore_imx8mp.h index 889dd36e6e..0490049850 100644 --- a/include/configs/phycore_imx8mp.h +++ b/include/configs/phycore_imx8mp.h @@ -33,7 +33,6 @@ #define CONFIG_POWER_I2C #define CONFIG_POWER_PCA9450 -#undef CONFIG_DM_I2C #define CONFIG_SYS_I2C #endif diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h index 000f386470..7b602dd9ea 100644 --- a/include/configs/sunxi-common.h +++ b/include/configs/sunxi-common.h @@ -134,11 +134,6 @@ #define CONFIG_BOARD_SIZE_LIMIT 0x7e000 #endif -#if CONFIG_MMC_SUNXI_SLOT_EXTRA != -1 -/* If we have two devices (most likely eMMC + MMC), favour the eMMC */ -#else -/* Otherwise, use the only device we have */ -#endif #define CONFIG_SYS_MMC_MAX_DEVICE 4 #endif @@ -199,15 +194,11 @@ /* I2C */ -#if defined CONFIG_AXP152_POWER || defined CONFIG_AXP209_POWER || \ - defined CONFIG_SY8106A_POWER -#endif - #if defined CONFIG_I2C0_ENABLE || defined CONFIG_I2C1_ENABLE || \ defined CONFIG_I2C2_ENABLE || defined CONFIG_I2C3_ENABLE || \ defined CONFIG_I2C4_ENABLE || defined CONFIG_R_I2C_ENABLE #define CONFIG_SYS_I2C_MVTWSI -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) #define CONFIG_SYS_I2C #define CONFIG_SYS_I2C_SPEED 400000 #define CONFIG_SYS_I2C_SLAVE 0x7f @@ -232,30 +223,6 @@ extern int soft_i2c_gpio_scl; #define CONFIG_VIDEO_LCD_I2C_BUS -1 /* NA, but necessary to compile */ #endif -/* PMU */ -#if defined CONFIG_AXP152_POWER || defined CONFIG_AXP209_POWER || \ - defined CONFIG_AXP221_POWER || defined CONFIG_AXP818_POWER || \ - defined CONFIG_SY8106A_POWER -#endif - -#ifdef CONFIG_REQUIRE_SERIAL_CONSOLE -#if CONFIG_CONS_INDEX == 1 -#ifdef CONFIG_MACH_SUN9I -#define OF_STDOUT_PATH "/soc/serial@07000000:115200" -#else -#define OF_STDOUT_PATH "/soc@01c00000/serial@01c28000:115200" -#endif -#elif CONFIG_CONS_INDEX == 2 && defined(CONFIG_MACH_SUN5I) -#define OF_STDOUT_PATH "/soc@01c00000/serial@01c28400:115200" -#elif CONFIG_CONS_INDEX == 3 && defined(CONFIG_MACH_SUN8I) -#define OF_STDOUT_PATH "/soc@01c00000/serial@01c28800:115200" -#elif CONFIG_CONS_INDEX == 5 && defined(CONFIG_MACH_SUN8I) -#define OF_STDOUT_PATH "/soc@01c00000/serial@01f02800:115200" -#else -#error Unsupported console port nr. Please fix stdout-path in sunxi-common.h. -#endif -#endif /* ifdef CONFIG_REQUIRE_SERIAL_CONSOLE */ - #ifdef CONFIG_VIDEO_SUNXI /* * The amount of RAM to keep free at the top of RAM when relocating u-boot, diff --git a/include/configs/ti_armv7_common.h b/include/configs/ti_armv7_common.h index 0c9856a11a..f13e9e5264 100644 --- a/include/configs/ti_armv7_common.h +++ b/include/configs/ti_armv7_common.h @@ -87,7 +87,7 @@ #define CONFIG_SYS_PTV 2 /* Divisor: 2^(PTV+1) => 8 */ /* If DM_I2C, enable non-DM I2C support */ -#if !defined(CONFIG_DM_I2C) +#if !CONFIG_IS_ENABLED(DM_I2C) #define CONFIG_I2C #define CONFIG_SYS_I2C #endif diff --git a/include/dm/device.h b/include/dm/device.h index 28533ce0b6..bb9faa0ed9 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -159,6 +159,8 @@ enum { * When CONFIG_DEVRES is enabled, devm_kmalloc() and friends will * add to this list. Memory so-allocated will be freed * automatically when the device is removed / unbound + * @dma_offset: Offset between the physical address space (CPU's) and the + * device's bus address space */ struct udevice { const struct driver *driver; @@ -183,6 +185,9 @@ struct udevice { #ifdef CONFIG_DEVRES struct list_head devres_head; #endif +#if CONFIG_IS_ENABLED(DM_DMA) + ulong dma_offset; +#endif }; /* Maximum sequence number supported */ @@ -224,6 +229,14 @@ static inline ofnode dev_ofnode(const struct udevice *dev) /* Returns non-zero if the device is active (probed and not removed) */ #define device_active(dev) (dev_get_flags(dev) & DM_FLAG_ACTIVATED) +#if CONFIG_IS_ENABLED(DM_DMA) +#define dev_set_dma_offset(_dev, _offset) _dev->dma_offset = _offset +#define dev_get_dma_offset(_dev) _dev->dma_offset +#else +#define dev_set_dma_offset(_dev, _offset) +#define dev_get_dma_offset(_dev) 0 +#endif + static inline int dev_of_offset(const struct udevice *dev) { #if !CONFIG_IS_ENABLED(OF_PLATDATA) diff --git a/include/dm/of_addr.h b/include/dm/of_addr.h index 3fa1ffce81..ee21d5cf4f 100644 --- a/include/dm/of_addr.h +++ b/include/dm/of_addr.h @@ -44,6 +44,23 @@ u64 of_translate_address(const struct device_node *no, const __be32 *in_addr); */ u64 of_translate_dma_address(const struct device_node *no, const __be32 *in_addr); + +/** + * of_get_dma_range() - get dma-ranges for a specific DT node + * + * Get DMA ranges for a specifc node, this is useful to perform bus->cpu and + * cpu->bus address translations + * + * @param blob Pointer to device tree blob + * @param node_offset Node DT offset + * @param cpu Pointer to variable storing the range's cpu address + * @param bus Pointer to variable storing the range's bus address + * @param size Pointer to variable storing the range's size + * @return translated DMA address or OF_BAD_ADDR on error + */ +int of_get_dma_range(const struct device_node *dev, phys_addr_t *cpu, + dma_addr_t *bus, u64 *size); + /** * of_get_address() - obtain an address from a node * diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 5318d65035..2c0597c407 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -999,6 +999,22 @@ u64 ofnode_translate_address(ofnode node, const fdt32_t *in_addr); u64 ofnode_translate_dma_address(ofnode node, const fdt32_t *in_addr); /** + * ofnode_get_dma_range() - get dma-ranges for a specific DT node + * + * Get DMA ranges for a specifc node, this is useful to perform bus->cpu and + * cpu->bus address translations + * + * @param blob Pointer to device tree blob + * @param node_offset Node DT offset + * @param cpu Pointer to variable storing the range's cpu address + * @param bus Pointer to variable storing the range's bus address + * @param size Pointer to variable storing the range's size + * @return translated DMA address or OF_BAD_ADDR on error + */ +int ofnode_get_dma_range(ofnode node, phys_addr_t *cpu, dma_addr_t *bus, + u64 *size); + +/** * ofnode_device_is_compatible() - check if the node is compatible with compat * * This allows to check whether the node is comaptible with the compat. diff --git a/include/dm/read.h b/include/dm/read.h index 97575bcad0..5bf3405614 100644 --- a/include/dm/read.h +++ b/include/dm/read.h @@ -648,6 +648,21 @@ u64 dev_translate_dma_address(const struct udevice *dev, const fdt32_t *in_addr); /** + * dev_get_dma_range() - Get a device's DMA constraints + * + * Provide the address bases and size of the linear mapping between the CPU and + * a device's BUS address space. + * + * @dev: device giving the context in which to translate the DMA address + * @cpu: base address for CPU's view of memory + * @bus: base address for BUS's view of memory + * @size: size of the address space + * @return 0 if ok, negative on error + */ +int dev_get_dma_range(const struct udevice *dev, phys_addr_t *cpu, + dma_addr_t *bus, u64 *size); + +/** * dev_read_alias_highest_id - Get highest alias id for the given stem * @stem: Alias stem to be examined * @@ -1005,6 +1020,12 @@ static inline u64 dev_translate_dma_address(const struct udevice *dev, return ofnode_translate_dma_address(dev_ofnode(dev), in_addr); } +static inline int dev_get_dma_range(const struct udevice *dev, phys_addr_t *cpu, + dma_addr_t *bus, u64 *size) +{ + return ofnode_get_dma_range(dev_ofnode(dev), cpu, bus, size); +} + static inline int dev_read_alias_highest_id(const char *stem) { if (!CONFIG_IS_ENABLED(OF_LIBFDT) || !gd->fdt_blob) diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h index ae4425d7a5..d75de368c5 100644 --- a/include/dm/uclass-id.h +++ b/include/dm/uclass-id.h @@ -46,6 +46,7 @@ enum uclass_id { UCLASS_DISPLAY, /* Display (e.g. DisplayPort, HDMI) */ UCLASS_DSI_HOST, /* Display Serial Interface host */ UCLASS_DMA, /* Direct Memory Access */ + UCLASS_DSA, /* Distributed (Ethernet) Switch Architecture */ UCLASS_EFI, /* EFI managed devices */ UCLASS_ETH, /* Ethernet device */ UCLASS_ETH_PHY, /* Ethernet PHY device */ diff --git a/include/exports.h b/include/exports.h index 99436e4132..550cafdc7a 100644 --- a/include/exports.h +++ b/include/exports.h @@ -49,7 +49,7 @@ long simple_strtol(const char *cp, char **endp, unsigned int base); int strcmp(const char *cs, const char *ct); unsigned long ustrtoul(const char *cp, char **endp, unsigned int base); unsigned long long ustrtoull(const char *cp, char **endp, unsigned int base); -#if defined(CONFIG_CMD_I2C) && !defined(CONFIG_DM_I2C) +#if defined(CONFIG_CMD_I2C) && !CONFIG_IS_ENABLED(DM_I2C) int i2c_write (uchar, uint, int , uchar* , int); int i2c_read (uchar, uint, int , uchar* , int); #endif diff --git a/include/fdt_support.h b/include/fdt_support.h index dbbac0fb6a..46eb1dbbb2 100644 --- a/include/fdt_support.h +++ b/include/fdt_support.h @@ -260,6 +260,20 @@ u64 fdt_translate_address(const void *blob, int node_offset, u64 fdt_translate_dma_address(const void *blob, int node_offset, const __be32 *in_addr); +/** + * Get DMA ranges for a specifc node, this is useful to perform bus->cpu and + * cpu->bus address translations + * + * @param blob Pointer to device tree blob + * @param node_offset Node DT offset + * @param cpu Pointer to variable storing the range's cpu address + * @param bus Pointer to variable storing the range's bus address + * @param size Pointer to variable storing the range's size + * @return translated DMA address or OF_BAD_ADDR on error + */ +int fdt_get_dma_range(const void *blob, int node_offset, phys_addr_t *cpu, + dma_addr_t *bus, u64 *size); + int fdt_node_offset_by_compat_reg(void *blob, const char *compat, phys_addr_t compat_off); int fdt_alloc_phandle(void *blob); diff --git a/include/i2c.h b/include/i2c.h index e45e33f503..7ae0c42706 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -581,7 +581,7 @@ extern struct acpi_ops i2c_acpi_ops; */ int acpi_i2c_of_to_plat(struct udevice *dev); -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) /* * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING diff --git a/include/image.h b/include/image.h index d5a940313a..138c83dd28 100644 --- a/include/image.h +++ b/include/image.h @@ -1556,8 +1556,6 @@ bool android_image_print_dtb_contents(ulong hdr_addr); */ int board_fit_config_name_match(const char *name); -#if defined(CONFIG_SPL_FIT_IMAGE_POST_PROCESS) || \ - defined(CONFIG_FIT_IMAGE_POST_PROCESS) /** * board_fit_image_post_process() - Do any post-process on FIT binary data * @@ -1572,11 +1570,6 @@ int board_fit_config_name_match(const char *name); * @return no return value (failure should be handled internally) */ void board_fit_image_post_process(void **p_image, size_t *p_size); -#else -static inline void board_fit_image_post_process(void **p_image, size_t *p_size) -{ -} -#endif /* CONFIG_SPL_FIT_IMAGE_POST_PROCESS */ #define FDT_ERROR ((ulong)(-1)) diff --git a/include/iomux.h b/include/iomux.h index da7ff697d2..37f5f6dee6 100644 --- a/include/iomux.h +++ b/include/iomux.h @@ -24,7 +24,14 @@ extern struct stdio_dev **console_devices[MAX_FILES]; */ extern int cd_count[MAX_FILES]; +#define for_each_console_dev(i, file, dev) \ + for (i = 0, dev = console_devices[file][i]; \ + i < cd_count[file]; \ + i++, dev = console_devices[file][i]) + +int iomux_match_device(struct stdio_dev **, const int, struct stdio_dev *); int iomux_doenv(const int, const char *); +int iomux_replace_device(const int, const char *, const char *); void iomux_printdevs(const int); #endif /* _IO_MUX_H */ diff --git a/include/mb862xx.h b/include/mb862xx.h deleted file mode 100644 index 54c8c757c0..0000000000 --- a/include/mb862xx.h +++ /dev/null @@ -1,101 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* - * (C) Copyright 2007 - * DENX Software Engineering, Anatolij Gustschin, agust@denx.de - */ - -/* - * mb862xx.h - Graphic interface for Fujitsu CoralP/Lime - */ - -#ifndef _MB862XX_H_ -#define _MB862XX_H_ - -#define PCI_VENDOR_ID_FUJITSU 0x10CF -#define PCI_DEVICE_ID_CORAL_P 0x2019 -#define PCI_DEVICE_ID_CORAL_PA 0x201E - -#define MB862XX_TYPE_LIME 0x1 - -#define GC_HOST_BASE 0x01fc0000 -#define GC_DISP_BASE 0x01fd0000 -#define GC_DRAW_BASE 0x01ff0000 - -/* Host interface registers */ -#define GC_SRST 0x0000002c -#define GC_CCF 0x00000038 -#define GC_CID 0x000000f0 -#define GC_MMR 0x0000fffc - -/* - * Display Controller registers - * _A means the offset is aligned, we use these for boards - * with 8-/16-bit GDC access not working or buggy. - */ -#define GC_DCM0 0x00000000 -#define GC_HTP_A 0x00000004 -#define GC_HTP 0x00000006 -#define GC_HDB_HDP_A 0x00000008 -#define GC_HDP 0x00000008 -#define GC_HDB 0x0000000a -#define GC_VSW_HSW_HSP_A 0x0000000c -#define GC_HSP 0x0000000c -#define GC_HSW 0x0000000e -#define GC_VSW 0x0000000f -#define GC_VTR_A 0x00000010 -#define GC_VTR 0x00000012 -#define GC_VDP_VSP_A 0x00000014 -#define GC_VSP 0x00000014 -#define GC_VDP 0x00000016 -#define GC_WY_WX 0x00000018 -#define GC_WH_WW 0x0000001c -#define GC_L0M 0x00000020 -#define GC_L0OA0 0x00000024 -#define GC_L0DA0 0x00000028 -#define GC_L0DY_L0DX 0x0000002c -#define GC_L2M 0x00000040 -#define GC_L2OA0 0x00000044 -#define GC_L2DA0 0x00000048 -#define GC_L2OA1 0x0000004c -#define GC_L2DA1 0x00000050 -#define GC_L2DX 0x00000054 -#define GC_L2DY 0x00000056 -#define GC_DCM1 0x00000100 -#define GC_DCM2 0x00000104 -#define GC_DCM3 0x00000108 -#define GC_L0EM 0x00000110 -#define GC_L0WY_L0WX 0x00000114 -#define GC_L0WH_L0WW 0x00000118 -#define GC_L2EM 0x00000130 -#define GC_L2WX 0x00000134 -#define GC_L2WY 0x00000136 -#define GC_L2WW 0x00000138 -#define GC_L2WH 0x0000013a -#define GC_L0PAL0 0x00000400 - -/* Drawing registers */ -#define GC_CTR 0x00000400 -#define GC_IFCNT 0x00000408 -#define GC_FBR 0x00000440 -#define GC_XRES 0x00000444 -#define GC_CXMIN 0x00000454 -#define GC_CXMAX 0x00000458 -#define GC_CYMIN 0x0000045c -#define GC_CYMAX 0x00000460 -#define GC_FC 0x00000480 -#define GC_BC 0x00000484 -#define GC_FIFO 0x000004a0 -#define GC_REV 0x00008084 -#define GC_GEO_FIFO 0x00008400 - -typedef struct { - unsigned int index; - unsigned int value; -} gdc_regs; - -int mb862xx_probe(unsigned int addr); -const gdc_regs *board_get_regs (void); -unsigned int board_video_init (void); -void board_backlight_switch(int); - -#endif /* _MB862XX_H_ */ diff --git a/include/mmc.h b/include/mmc.h index 1d377e0281..8600881705 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -178,6 +178,7 @@ static inline bool mmc_is_tuning_cmd(uint cmdidx) #define MMC_STATUS_ERROR (1 << 19) #define MMC_STATE_PRG (7 << 9) +#define MMC_STATE_TRANS (4 << 9) #define MMC_VDD_165_195 0x00000080 /* VDD voltage 1.65 - 1.95 */ #define MMC_VDD_20_21 0x00000100 /* VDD voltage 2.0 ~ 2.1 */ @@ -591,6 +592,9 @@ struct mmc_config { uint f_max; uint b_max; unsigned char part_type; +#ifdef CONFIG_MMC_PWRSEQ + struct udevice *pwr_dev; +#endif }; struct sd_ssr { @@ -736,6 +740,12 @@ struct mmc { u8 hs400_tuning; }; +#if CONFIG_IS_ENABLED(DM_MMC) +#define mmc_to_dev(_mmc) _mmc->dev +#else +#define mmc_to_dev(_mmc) NULL +#endif + struct mmc_hwpart_conf { struct { uint enh_start; /* in 512-byte sectors */ @@ -801,6 +811,17 @@ int mmc_deinit(struct mmc *mmc); */ int mmc_of_parse(struct udevice *dev, struct mmc_config *cfg); +#ifdef CONFIG_MMC_PWRSEQ +/** + * mmc_pwrseq_get_power() - get a power device from device tree + * + * @dev: MMC device + * @cfg: MMC configuration + * @return 0 if OK, -ve on error + */ +int mmc_pwrseq_get_power(struct udevice *dev, struct mmc_config *cfg); +#endif + int mmc_read(struct mmc *mmc, u64 src, uchar *dst, int size); /** diff --git a/include/net.h b/include/net.h index 13da69b7c1..b95d6a6f60 100644 --- a/include/net.h +++ b/include/net.h @@ -499,7 +499,13 @@ struct icmp_hdr { * maximum packet size and multiple of 32 bytes = 1536 */ #define PKTSIZE 1522 +#ifndef CONFIG_DM_DSA #define PKTSIZE_ALIGN 1536 +#else +/* Maximum DSA tagging overhead (headroom and/or tailroom) */ +#define DSA_MAX_OVR 256 +#define PKTSIZE_ALIGN (1536 + DSA_MAX_OVR) +#endif /* * Maximum receive ring size; that is, the number of packets diff --git a/include/net/dsa.h b/include/net/dsa.h new file mode 100644 index 0000000000..0f31a908c9 --- /dev/null +++ b/include/net/dsa.h @@ -0,0 +1,165 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2019-2021 NXP Semiconductors + */ + +#ifndef __DSA_H__ +#define __DSA_H__ + +#include <phy.h> +#include <net.h> + +/** + * DSA stands for Distributed Switch Architecture and it is infrastructure + * intended to support drivers for Switches that rely on an intermediary + * Ethernet device for I/O. These switches may support cascading allowing + * them to be arranged as a tree. + * DSA is documented in detail in the Linux kernel documentation under + * Documentation/networking/dsa/dsa.txt + * The network layout of such a switch is shown below: + * + * |------| + * | eth0 | <--- master eth device (regular eth driver) + * |------| + * ^ | + * tag added by switch -->| | + * | | + * | |<-- tag added by DSA driver + * | v + * |--------------------------------------| + * | | CPU port | | <-- DSA (switch) device + * | ------------ | (DSA driver) + * | _________ _________ _________ | + * | | port0 | | port1 | ... | portn | | <-- ports as eth devices + * |-+-------+--+-------+-------+-------+-| ('dsa-port' eth driver) + * + * In U-Boot the intent is to allow access to front panel ports (shown at the + * bottom of the picture) through the master Ethernet dev (eth0 in the picture). + * Front panel ports are presented as regular Ethernet devices in U-Boot and + * they are expected to support the typical networking commands. + * In general DSA switches require the use of tags, extra headers added both by + * software on Tx and by the switch on Rx. These tags carry at a minimum port + * information and switch information for cascaded set-ups. + * In U-Boot these tags are inserted and parsed by the DSA switch driver, the + * class code helps with headroom/tailroom for the extra headers. + * + * TODO: + * - handle switch cascading, for now U-Boot only supports stand-alone switches. + * - Add support to probe DSA switches connected to a MDIO bus, this is needed + * to convert switch drivers that are now under drivers/net/phy. + */ + +#define DSA_PORT_NAME_LENGTH 16 + +/* Maximum number of ports each DSA device can have */ +#define DSA_MAX_PORTS 12 + +/** + * struct dsa_ops - DSA operations + * + * @port_enable: Initialize a switch port for I/O. + * @port_disable: Disable I/O for a port. + * @xmit: Insert the DSA tag for transmission. + * DSA drivers receive a copy of the packet with headroom and + * tailroom reserved and set to 0. 'packet' points to headroom + * and 'length' is updated to include both head and tailroom. + * @rcv: Process the DSA tag on reception and return the port index + * from the h/w provided tag. Return the index via 'portp'. + * 'packet' and 'length' describe the frame as received from + * master including any additional headers. + */ +struct dsa_ops { + int (*port_enable)(struct udevice *dev, int port, + struct phy_device *phy); + void (*port_disable)(struct udevice *dev, int port, + struct phy_device *phy); + int (*xmit)(struct udevice *dev, int port, void *packet, int length); + int (*rcv)(struct udevice *dev, int *portp, void *packet, int length); +}; + +#define dsa_get_ops(dev) ((struct dsa_ops *)(dev)->driver->ops) + +/** + * struct dsa_port_pdata - DSA port platform data + * + * @phy: PHY device associated with this port. + * The uclass code attempts to set this field for all ports except CPU + * port, based on DT information. It may be NULL. + * @index: Port index in the DSA switch, set by the uclass code. + * @name: Name of the port Eth device. If a label property is present in the + * port DT node, it is used as name. + */ +struct dsa_port_pdata { + struct phy_device *phy; + u32 index; + char name[DSA_PORT_NAME_LENGTH]; +}; + +/** + * struct dsa_pdata - Per-device platform data for DSA DM + * + * @num_ports: Number of ports the device has, must be <= DSA_MAX_PORTS. + * This number is extracted from the DT 'ports' node of this + * DSA device, and it counts the CPU port and all the other + * port subnodes including the disabled ones. + * @cpu_port: Index of the switch port linked to the master Ethernet. + * The uclass code sets this based on DT information. + * @master_node: OF node of the host Ethernet controller. + * @cpu_port_node: DT node of the switch's CPU port. + */ +struct dsa_pdata { + int num_ports; + u32 cpu_port; + ofnode master_node; + ofnode cpu_port_node; +}; + +/** + * dsa_set_tagging() - Configure the headroom and/or tailroom sizes + * + * The DSA class code allocates headroom and tailroom on Tx before + * calling the DSA driver's xmit function. + * All drivers must call this at probe time. + * + * @dev: DSA device pointer + * @headroom: Size, in bytes, of headroom needed for the DSA tag. + * @tailroom: Size, in bytes, of tailroom needed for the DSA tag. + * Total headroom and tailroom size should not exceed + * DSA_MAX_OVR. + * @return 0 if OK, -ve on error + */ +int dsa_set_tagging(struct udevice *dev, ushort headroom, ushort tailroom); + +/* DSA helpers */ + +/** + * dsa_get_master() - Return a reference to the master Ethernet device + * + * Can be called at driver probe time or later. + * + * @dev: DSA device pointer + * @return Master Eth 'udevice' pointer if OK, NULL on error + */ +struct udevice *dsa_get_master(struct udevice *dev); + +/** + * dsa_port_get_pdata() - Helper that returns the platdata of an active + * (non-CPU) DSA port device. + * + * Can be called at driver probe time or later. + * + * @pdev: DSA port device pointer + * @return 'dsa_port_pdata' pointer if OK, NULL on error + */ +static inline struct dsa_port_pdata * + dsa_port_get_pdata(struct udevice *pdev) +{ + struct eth_pdata *eth = dev_get_plat(pdev); + + if (!eth) + return NULL; + + return eth->priv_pdata; +} + +#endif /* __DSA_H__ */ diff --git a/include/palmas.h b/include/palmas.h index 20c7e489c1..e259a4d04b 100644 --- a/include/palmas.h +++ b/include/palmas.h @@ -117,7 +117,7 @@ #define BB_VSEL_VBAT (3 << 1) #define BB_CHRG_EN (1 << 0) -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) /* * Functions to read and write from TPS659038/TWL6035/TWL6037 * or other Palmas family of TI PMICs diff --git a/include/phy.h b/include/phy.h index 7750efd8bb..2754421ed4 100644 --- a/include/phy.h +++ b/include/phy.h @@ -402,6 +402,27 @@ int phy_reset(struct phy_device *phydev); struct phy_device *phy_find_by_mask(struct mii_dev *bus, unsigned phy_mask, phy_interface_t interface); +#ifdef CONFIG_PHY_FIXED + +/** + * fixed_phy_create() - create an unconnected fixed-link pseudo-PHY device + * @node: OF node for the container of the fixed-link node + * + * Description: Creates a struct phy_device based on a fixed-link of_node + * description. Can be used without phy_connect by drivers which do not expose + * a UCLASS_ETH udevice. + */ +struct phy_device *fixed_phy_create(ofnode node); + +#else + +static inline struct phy_device *fixed_phy_create(ofnode node) +{ + return NULL; +} + +#endif + #ifdef CONFIG_DM_ETH /** diff --git a/include/phys2bus.h b/include/phys2bus.h index dc9b8e5a25..866b8b51a8 100644 --- a/include/phys2bus.h +++ b/include/phys2bus.h @@ -21,4 +21,21 @@ static inline unsigned long bus_to_phys(unsigned long bus) } #endif +#if CONFIG_IS_ENABLED(DM) +#include <dm/device.h> + +static inline dma_addr_t dev_phys_to_bus(struct udevice *dev, phys_addr_t phys) +{ + return phys - dev_get_dma_offset(dev); +} + +static inline phys_addr_t dev_bus_to_phys(struct udevice *dev, dma_addr_t bus) +{ + return bus + dev_get_dma_offset(dev); +} +#else +#define dev_phys_to_bus(_, _addr) _addr +#define dev_bus_to_phys(_, _addr) _addr +#endif + #endif diff --git a/include/spl.h b/include/spl.h index e172500b5f..0d134587de 100644 --- a/include/spl.h +++ b/include/spl.h @@ -701,9 +701,9 @@ int board_return_to_bootrom(struct spl_image_info *spl_image, /** * board_spl_fit_post_load - allow process images after loading finished - * + * @fit: Pointer to a valid Flattened Image Tree blob */ -void board_spl_fit_post_load(ulong load_addr, size_t length); +void board_spl_fit_post_load(const void *fit); /** * board_spl_fit_size_align - specific size align before processing payload diff --git a/include/stdio_dev.h b/include/stdio_dev.h index 48871a6a22..8fb9a12dd8 100644 --- a/include/stdio_dev.h +++ b/include/stdio_dev.h @@ -18,6 +18,8 @@ #define DEV_FLAGS_OUTPUT 0x00000002 /* Device can be used as output console */ #define DEV_FLAGS_DM 0x00000004 /* Device priv is a struct udevice * */ +int stdio_file_to_flags(const int file); + /* Device information */ struct stdio_dev { int flags; /* Device flags: input/output/system */ @@ -83,7 +85,6 @@ int stdio_add_devices(void); int stdio_init(void); void stdio_print_current_devices(void); -int stdio_deregister(const char *devname, int force); /** * stdio_deregister_dev() - deregister the device "devname". diff --git a/include/tee/optee_ta_rpc_test.h b/include/tee/optee_ta_rpc_test.h new file mode 100644 index 0000000000..9491fbab1d --- /dev/null +++ b/include/tee/optee_ta_rpc_test.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ +/* Copyright (c) 2020 Foundries Ltd */ + +#ifndef __TA_RPC_TEST_H +#define __TA_RPC_TEST_H + +#define TA_RPC_TEST_UUID { 0x48420575, 0x96ca, 0x401a, \ + { 0x89, 0x91, 0x1e, 0xfd, 0xce, 0xbd, 0x7d, 0x04 } } + +/* + * Does a reverse RPC call for I2C read + * + * in params[0].value.a: bus number + * in params[0].value.b: chip address + * in params[0].value.c: control flags + * inout params[1].u.memref: buffer to read data + */ +#define TA_RPC_TEST_CMD_I2C_READ 0 + +/* + * Does a reverse RPC call for I2C write + * + * in params[0].value.a: bus number + * in params[0].value.b: chip address + * in params[0].value.c: control flags + * inout params[1].u.memref: buffer with data to write + */ +#define TA_RPC_TEST_CMD_I2C_WRITE 1 + +#endif /* __TA_RPC_TEST_H */ diff --git a/include/twl4030.h b/include/twl4030.h index ef05193996..0a6d85a7c1 100644 --- a/include/twl4030.h +++ b/include/twl4030.h @@ -648,7 +648,7 @@ * examples are TWL4030_PM_RECEIVER_VMMC1_DEV_GRP and * TWL4030_LED_LEDEN. */ -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) static inline int twl4030_i2c_write_u8(u8 chip_no, u8 reg, u8 val) { return i2c_write(chip_no, reg, 1, &val, 1); diff --git a/include/twl6030.h b/include/twl6030.h index 41f17de3ab..05d476f804 100644 --- a/include/twl6030.h +++ b/include/twl6030.h @@ -186,7 +186,7 @@ struct twl6030_data{ }; /* Functions to read and write from TWL6030 */ -#ifndef CONFIG_DM_I2C +#if !CONFIG_IS_ENABLED(DM_I2C) static inline int twl6030_i2c_write_u8(u8 chip_no, u8 reg, u8 val) { return i2c_write(chip_no, reg, 1, &val, 1); diff --git a/include/usb/xhci.h b/include/usb/xhci.h index e1d382369a..8d95e213b0 100644 --- a/include/usb/xhci.h +++ b/include/usb/xhci.h @@ -16,6 +16,7 @@ #ifndef HOST_XHCI_H_ #define HOST_XHCI_H_ +#include <phys2bus.h> #include <reset.h> #include <asm/types.h> #include <asm/cache.h> @@ -1221,6 +1222,12 @@ struct xhci_ctrl { #define XHCI_MTK_HOST BIT(0) }; +#if CONFIG_IS_ENABLED(DM_USB) +#define xhci_to_dev(_ctrl) _ctrl->dev +#else +#define xhci_to_dev(_ctrl) NULL +#endif + unsigned long trb_addr(struct xhci_segment *seg, union xhci_trb *trb); struct xhci_input_control_ctx *xhci_get_input_control_ctx(struct xhci_container_ctx *ctx); @@ -1250,7 +1257,8 @@ int xhci_check_maxpacket(struct usb_device *udev); void xhci_flush_cache(uintptr_t addr, u32 type_len); void xhci_inval_cache(uintptr_t addr, u32 type_len); void xhci_cleanup(struct xhci_ctrl *ctrl); -struct xhci_ring *xhci_ring_alloc(unsigned int num_segs, bool link_trbs); +struct xhci_ring *xhci_ring_alloc(struct xhci_ctrl *ctrl, unsigned int num_segs, + bool link_trbs); int xhci_alloc_virt_device(struct xhci_ctrl *ctrl, unsigned int slot_id); int xhci_mem_init(struct xhci_ctrl *ctrl, struct xhci_hccr *hccr, struct xhci_hcor *hcor); @@ -1278,4 +1286,14 @@ extern struct dm_usb_ops xhci_usb_ops; struct xhci_ctrl *xhci_get_ctrl(struct usb_device *udev); +static inline dma_addr_t xhci_virt_to_bus(struct xhci_ctrl *ctrl, void *addr) +{ + return dev_phys_to_bus(xhci_to_dev(ctrl), virt_to_phys(addr)); +} + +static inline void *xhci_bus_to_virt(struct xhci_ctrl *ctrl, dma_addr_t addr) +{ + return phys_to_virt(dev_bus_to_phys(xhci_to_dev(ctrl), addr)); +} + #endif /* HOST_XHCI_H_ */ |