diff options
| author | Tom Rini <[email protected]> | 2023-10-02 10:55:44 -0400 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2023-10-02 10:55:44 -0400 |
| commit | ac897385bbfa30cfdfb62ccf24acfcd4b274b2ff (patch) | |
| tree | ae567980737beb24ca24e2ee8cfeaf6eb9e26e3f /drivers | |
| parent | 4459ed60cb1e0562bc5b40405e2b4b9bbf766d57 (diff) | |
| parent | e29b932aa07fa0226d325b35d96cd4eea0370129 (diff) | |
Merge branch 'next'
Signed-off-by: Tom Rini <[email protected]>
Diffstat (limited to 'drivers')
302 files changed, 2323 insertions, 851 deletions
diff --git a/drivers/adc/adc-uclass.c b/drivers/adc/adc-uclass.c index 9646e4d7062..1b35bf22014 100644 --- a/drivers/adc/adc-uclass.c +++ b/drivers/adc/adc-uclass.c @@ -15,6 +15,7 @@ #include <dm/uclass-internal.h> #include <adc.h> #include <linux/delay.h> +#include <linux/printk.h> #include <power/regulator.h> #define ADC_UCLASS_PLATDATA_SIZE sizeof(struct adc_uclass_plat) @@ -51,23 +52,21 @@ static int check_channel(struct udevice *dev, int value, bool number_or_mask, static int adc_supply_enable(struct udevice *dev) { struct adc_uclass_plat *uc_pdata = dev_get_uclass_plat(dev); - const char *supply_type; - int ret = 0; + int ret; - if (uc_pdata->vdd_supply) { - supply_type = "vdd"; - ret = regulator_set_enable(uc_pdata->vdd_supply, true); + ret = regulator_set_enable_if_allowed(uc_pdata->vdd_supply, true); + if (ret && ret != -ENOSYS) { + pr_err("%s: can't enable vdd-supply!", dev->name); + return ret; } - if (!ret && uc_pdata->vss_supply) { - supply_type = "vss"; - ret = regulator_set_enable(uc_pdata->vss_supply, true); + ret = regulator_set_enable_if_allowed(uc_pdata->vss_supply, true); + if (ret && ret != -ENOSYS) { + pr_err("%s: can't enable vss-supply!", dev->name); + return ret; } - if (ret) - pr_err("%s: can't enable %s-supply!", dev->name, supply_type); - - return ret; + return 0; } int adc_data_mask(struct udevice *dev, unsigned int *data_mask) diff --git a/drivers/adc/exynos-adc.c b/drivers/adc/exynos-adc.c index 65898170858..2bda733af90 100644 --- a/drivers/adc/exynos-adc.c +++ b/drivers/adc/exynos-adc.c @@ -8,6 +8,7 @@ #include <dm.h> #include <adc.h> #include <asm/arch/adc.h> +#include <linux/printk.h> struct exynos_adc_priv { int active_channel; diff --git a/drivers/adc/meson-saradc.c b/drivers/adc/meson-saradc.c index 37023512f0d..c15c7fea47f 100644 --- a/drivers/adc/meson-saradc.c +++ b/drivers/adc/meson-saradc.c @@ -18,6 +18,7 @@ #include <linux/delay.h> #include <linux/math64.h> #include <linux/bitfield.h> +#include <linux/printk.h> #include <power/regulator.h> #define MESON_SAR_ADC_REG0 0x00 diff --git a/drivers/adc/rockchip-saradc.c b/drivers/adc/rockchip-saradc.c index 809486eba27..03caca78b5f 100644 --- a/drivers/adc/rockchip-saradc.c +++ b/drivers/adc/rockchip-saradc.c @@ -13,6 +13,7 @@ #include <asm/io.h> #include <linux/bitops.h> #include <linux/err.h> +#include <linux/printk.h> #include <power/regulator.h> #define SARADC_CTRL_CHN_MASK GENMASK(2, 0) diff --git a/drivers/adc/sandbox.c b/drivers/adc/sandbox.c index 6e435462ab8..43cad34ffeb 100644 --- a/drivers/adc/sandbox.c +++ b/drivers/adc/sandbox.c @@ -8,6 +8,7 @@ #include <dm.h> #include <adc.h> #include <sandbox-adc.h> +#include <linux/printk.h> /** * struct sandbox_adc_priv - sandbox ADC device's operation status and data diff --git a/drivers/ata/dwc_ahci.c b/drivers/ata/dwc_ahci.c index 1dc91e7fce7..15fd3e365b2 100644 --- a/drivers/ata/dwc_ahci.c +++ b/drivers/ata/dwc_ahci.c @@ -18,6 +18,7 @@ #endif #include <asm/io.h> #include <generic-phy.h> +#include <linux/printk.h> struct dwc_ahci_priv { void *base; diff --git a/drivers/ata/sata_ceva.c b/drivers/ata/sata_ceva.c index 47366438fdf..7769d4f99ef 100644 --- a/drivers/ata/sata_ceva.c +++ b/drivers/ata/sata_ceva.c @@ -217,7 +217,7 @@ static int sata_ceva_probe(struct udevice *dev) } } - if (phy.dev) { + if (generic_phy_valid(&phy)) { dev_dbg(dev, "Perform PHY power on\n"); ret = generic_phy_power_on(&phy); if (ret) { diff --git a/drivers/bios_emulator/include/x86emu/debug.h b/drivers/bios_emulator/include/x86emu/debug.h index 4962a2acaf1..859b54d8600 100644 --- a/drivers/bios_emulator/include/x86emu/debug.h +++ b/drivers/bios_emulator/include/x86emu/debug.h @@ -43,6 +43,7 @@ /* checks to be enabled for "runtime" */ +#include <linux/printk.h> #define CHECK_IP_FETCH_F 0x1 #define CHECK_SP_ACCESS_F 0x2 #define CHECK_MEM_ACCESS_F 0x4 /*using regular linear pointer */ diff --git a/drivers/bios_emulator/include/x86emu/regs.h b/drivers/bios_emulator/include/x86emu/regs.h index 29341297d96..4b4c5908923 100644 --- a/drivers/bios_emulator/include/x86emu/regs.h +++ b/drivers/bios_emulator/include/x86emu/regs.h @@ -41,6 +41,7 @@ /*---------------------- Macros and type definitions ----------------------*/ +#include <linux/printk.h> #pragma pack(1) /* diff --git a/drivers/bios_emulator/x86emu/debug.c b/drivers/bios_emulator/x86emu/debug.c index 27e90e441aa..95f3cc09aad 100644 --- a/drivers/bios_emulator/x86emu/debug.c +++ b/drivers/bios_emulator/x86emu/debug.c @@ -40,6 +40,7 @@ #include <stdarg.h> #include <common.h> #include <linux/ctype.h> +#include <linux/printk.h> #include "x86emu/x86emui.h" /*----------------------------- Implementation ----------------------------*/ diff --git a/drivers/bios_emulator/x86emu/decode.c b/drivers/bios_emulator/x86emu/decode.c index a9a01b52d6c..e2028eaf083 100644 --- a/drivers/bios_emulator/x86emu/decode.c +++ b/drivers/bios_emulator/x86emu/decode.c @@ -37,6 +37,7 @@ * ****************************************************************************/ #include <common.h> +#include <linux/printk.h> #include "x86emu/x86emui.h" /*----------------------------- Implementation ----------------------------*/ diff --git a/drivers/bios_emulator/x86emu/ops.c b/drivers/bios_emulator/x86emu/ops.c index ba18135fe13..8c1a146165c 100644 --- a/drivers/bios_emulator/x86emu/ops.c +++ b/drivers/bios_emulator/x86emu/ops.c @@ -73,6 +73,7 @@ ****************************************************************************/ #include <common.h> +#include <linux/printk.h> #include "x86emu/x86emui.h" /*----------------------------- Implementation ----------------------------*/ diff --git a/drivers/bios_emulator/x86emu/ops2.c b/drivers/bios_emulator/x86emu/ops2.c index be4ef364432..6cd1ac39825 100644 --- a/drivers/bios_emulator/x86emu/ops2.c +++ b/drivers/bios_emulator/x86emu/ops2.c @@ -43,6 +43,7 @@ #include <common.h> #include <linux/compiler.h> +#include <linux/printk.h> #include "x86emu/x86emui.h" /*----------------------------- Implementation ----------------------------*/ diff --git a/drivers/bios_emulator/x86emu/sys.c b/drivers/bios_emulator/x86emu/sys.c index 882a8a34cc3..f96652415cd 100644 --- a/drivers/bios_emulator/x86emu/sys.c +++ b/drivers/bios_emulator/x86emu/sys.c @@ -40,6 +40,7 @@ ****************************************************************************/ #include <common.h> +#include <linux/printk.h> #include "x86emu/x86emui.h" /*------------------------- Global Variables ------------------------------*/ diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig index 6baaa6f0711..1abea3f10db 100644 --- a/drivers/block/Kconfig +++ b/drivers/block/Kconfig @@ -167,7 +167,7 @@ config SYS_IDE_MAXDEVICE config SYS_ATA_BASE_ADDR hex "Base address of IDE controller" - default 0 + default 0x0 help This is the address of the IDE controller, from which other addresses are calculated. Each bus is at a fixed offset from this address, diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c index 614b975e25c..885513893f6 100644 --- a/drivers/block/blk-uclass.c +++ b/drivers/block/blk-uclass.c @@ -17,6 +17,8 @@ #include <dm/uclass-internal.h> #include <linux/err.h> +#define blk_get_ops(dev) ((struct blk_ops *)(dev)->driver->ops) + static struct { enum uclass_id id; const char *name; @@ -444,6 +446,26 @@ int blk_get_device(int uclass_id, int devnum, struct udevice **devp) return device_probe(*devp); } +struct blk_bounce_buffer { + struct udevice *dev; + struct bounce_buffer state; +}; + +static int blk_buffer_aligned(struct bounce_buffer *state) +{ +#if IS_ENABLED(CONFIG_BOUNCE_BUFFER) + struct blk_bounce_buffer *bbstate = + container_of(state, struct blk_bounce_buffer, state); + struct udevice *dev = bbstate->dev; + const struct blk_ops *ops = blk_get_ops(dev); + + if (ops->buffer_aligned) + return ops->buffer_aligned(dev, state); +#endif /* CONFIG_BOUNCE_BUFFER */ + + return 1; /* Default, any buffer is OK */ +} + long blk_read(struct udevice *dev, lbaint_t start, lbaint_t blkcnt, void *buf) { struct blk_desc *desc = dev_get_uclass_plat(dev); @@ -456,7 +478,25 @@ long blk_read(struct udevice *dev, lbaint_t start, lbaint_t blkcnt, void *buf) if (blkcache_read(desc->uclass_id, desc->devnum, start, blkcnt, desc->blksz, buf)) return blkcnt; - blks_read = ops->read(dev, start, blkcnt, buf); + + if (IS_ENABLED(CONFIG_BOUNCE_BUFFER)) { + struct blk_bounce_buffer bbstate = { .dev = dev }; + int ret; + + ret = bounce_buffer_start_extalign(&bbstate.state, buf, + blkcnt * desc->blksz, + GEN_BB_WRITE, desc->blksz, + blk_buffer_aligned); + if (ret) + return ret; + + blks_read = ops->read(dev, start, blkcnt, bbstate.state.bounce_buffer); + + bounce_buffer_stop(&bbstate.state); + } else { + blks_read = ops->read(dev, start, blkcnt, buf); + } + if (blks_read == blkcnt) blkcache_fill(desc->uclass_id, desc->devnum, start, blkcnt, desc->blksz, buf); @@ -469,13 +509,33 @@ long blk_write(struct udevice *dev, lbaint_t start, lbaint_t blkcnt, { struct blk_desc *desc = dev_get_uclass_plat(dev); const struct blk_ops *ops = blk_get_ops(dev); + long blks_written; if (!ops->write) return -ENOSYS; blkcache_invalidate(desc->uclass_id, desc->devnum); - return ops->write(dev, start, blkcnt, buf); + if (IS_ENABLED(CONFIG_BOUNCE_BUFFER)) { + struct blk_bounce_buffer bbstate = { .dev = dev }; + int ret; + + ret = bounce_buffer_start_extalign(&bbstate.state, (void *)buf, + blkcnt * desc->blksz, + GEN_BB_READ, desc->blksz, + blk_buffer_aligned); + if (ret) + return ret; + + blks_written = ops->write(dev, start, blkcnt, + bbstate.state.bounce_buffer); + + bounce_buffer_stop(&bbstate.state); + } else { + blks_written = ops->write(dev, start, blkcnt, buf); + } + + return blks_written; } long blk_erase(struct udevice *dev, lbaint_t start, lbaint_t blkcnt) @@ -766,6 +826,54 @@ int blk_unbind_all(int uclass_id) return 0; } +static int part_create_block_devices(struct udevice *blk_dev) +{ + int part, count; + struct blk_desc *desc = dev_get_uclass_plat(blk_dev); + struct disk_partition info; + struct disk_part *part_data; + char devname[32]; + struct udevice *dev; + int ret; + + if (!CONFIG_IS_ENABLED(PARTITIONS) || !blk_enabled()) + return 0; + + if (device_get_uclass_id(blk_dev) != UCLASS_BLK) + return 0; + + /* Add devices for each partition */ + for (count = 0, part = 1; part <= MAX_SEARCH_PARTITIONS; part++) { + if (part_get_info(desc, part, &info)) + continue; + snprintf(devname, sizeof(devname), "%s:%d", blk_dev->name, + part); + + ret = device_bind_driver(blk_dev, "blk_partition", + strdup(devname), &dev); + if (ret) + return ret; + + part_data = dev_get_uclass_plat(dev); + part_data->partnum = part; + part_data->gpt_part_info = info; + count++; + + ret = device_probe(dev); + if (ret) { + debug("Can't probe\n"); + count--; + device_unbind(dev); + + continue; + } + } + debug("%s: %d partitions found in %s\n", __func__, count, + blk_dev->name); + + return 0; +} + static int blk_post_probe(struct udevice *dev) { if (CONFIG_IS_ENABLED(PARTITIONS) && blk_enabled()) { diff --git a/drivers/block/blkcache.c b/drivers/block/blkcache.c index f99465aa479..26bcbea4353 100644 --- a/drivers/block/blkcache.c +++ b/drivers/block/blkcache.c @@ -13,10 +13,6 @@ #include <linux/ctype.h> #include <linux/list.h> -#ifdef CONFIG_NEEDS_MANUAL_RELOC -DECLARE_GLOBAL_DATA_PTR; -#endif - struct block_cache_node { struct list_head lh; int iftype; @@ -34,18 +30,6 @@ static struct block_cache_stats _stats = { .max_entries = 32 }; -#ifdef CONFIG_NEEDS_MANUAL_RELOC -int blkcache_init(void) -{ - struct list_head *head = &block_cache; - - head->next = (uintptr_t)head->next + gd->reloc_off; - head->prev = (uintptr_t)head->prev + gd->reloc_off; - - return 0; -} -#endif - static struct block_cache_node *cache_find(int iftype, int devnum, lbaint_t start, lbaint_t blkcnt, unsigned long blksz) diff --git a/drivers/bootcount/bootcount-uclass.c b/drivers/bootcount/bootcount-uclass.c index c747c9ab276..5a369c82f1c 100644 --- a/drivers/bootcount/bootcount-uclass.c +++ b/drivers/bootcount/bootcount-uclass.c @@ -10,6 +10,7 @@ #include <errno.h> #include <bootcount.h> #include <log.h> +#include <linux/printk.h> int dm_bootcount_get(struct udevice *dev, u32 *bootcount) { diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig index 29859cdfa15..bfd23a99046 100644 --- a/drivers/clk/Kconfig +++ b/drivers/clk/Kconfig @@ -83,6 +83,19 @@ config CLK_COMPOSITE_CCF Enable this option if you want to (re-)use the Linux kernel's Common Clock Framework [CCF] composite code in U-Boot's clock driver. +config CLK_GPIO + bool "GPIO-controlled clock gate driver" + depends on CLK + help + Enable this option to add GPIO-controlled clock gate driver. + +config SPL_CLK_GPIO + bool "GPIO-controlled clock gate driver in SPL" + depends on SPL_CLK + help + Enable this option to add GPIO-controlled clock gate driver + in U-Boot SPL. + config CLK_BCM6345 bool "Clock controller driver for BCM6345" depends on CLK && ARCH_BMIPS diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile index e22c8cf291f..26bf429acbc 100644 --- a/drivers/clk/Makefile +++ b/drivers/clk/Makefile @@ -10,6 +10,7 @@ obj-$(CONFIG_$(SPL_TPL_)CLK) += clk_fixed_factor.o obj-$(CONFIG_$(SPL_TPL_)CLK_CCF) += clk.o clk-divider.o clk-mux.o clk-gate.o obj-$(CONFIG_$(SPL_TPL_)CLK_CCF) += clk-fixed-factor.o obj-$(CONFIG_$(SPL_TPL_)CLK_COMPOSITE_CCF) += clk-composite.o +obj-$(CONFIG_$(SPL_TPL_)CLK_GPIO) += clk-gpio.o obj-y += analogbits/ obj-y += imx/ diff --git a/drivers/clk/analogbits/wrpll-cln28hpc.c b/drivers/clk/analogbits/wrpll-cln28hpc.c index 776ead319ae..a3cb109d357 100644 --- a/drivers/clk/analogbits/wrpll-cln28hpc.c +++ b/drivers/clk/analogbits/wrpll-cln28hpc.c @@ -26,6 +26,7 @@ #include <linux/log2.h> #include <linux/math64.h> #include <linux/clk/analogbits-wrpll-cln28hpc.h> +#include <linux/printk.h> /* MIN_INPUT_FREQ: minimum input clock frequency, in Hz (Fref_min) */ #define MIN_INPUT_FREQ 7000000 diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c index 6ab137a72be..2ad682b8fe2 100644 --- a/drivers/clk/clk-divider.c +++ b/drivers/clk/clk-divider.c @@ -28,6 +28,7 @@ #include <linux/log2.h> #include <div64.h> #include <clk.h> +#include <linux/printk.h> #include "clk.h" #define UBOOT_DM_CLK_CCF_DIVIDER "ccf_clk_divider" diff --git a/drivers/clk/clk-gate.c b/drivers/clk/clk-gate.c index a8775c77dc2..cfd90b717e7 100644 --- a/drivers/clk/clk-gate.c +++ b/drivers/clk/clk-gate.c @@ -21,6 +21,7 @@ #include <linux/bitops.h> #include <linux/clk-provider.h> #include <linux/err.h> +#include <linux/printk.h> #include "clk.h" diff --git a/drivers/clk/clk-gpio.c b/drivers/clk/clk-gpio.c new file mode 100644 index 00000000000..26d795b9783 --- /dev/null +++ b/drivers/clk/clk-gpio.c @@ -0,0 +1,66 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2023 Marek Vasut <[email protected]> + */ + +#include <asm/gpio.h> +#include <common.h> +#include <clk-uclass.h> +#include <dm.h> + +struct clk_gpio_priv { + struct gpio_desc enable; +}; + +static int clk_gpio_enable(struct clk *clk) +{ + struct clk_gpio_priv *priv = dev_get_priv(clk->dev); + + dm_gpio_set_value(&priv->enable, 1); + + return 0; +} + +static int clk_gpio_disable(struct clk *clk) +{ + struct clk_gpio_priv *priv = dev_get_priv(clk->dev); + + dm_gpio_set_value(&priv->enable, 0); + + return 0; +} + +const struct clk_ops clk_gpio_ops = { + .enable = clk_gpio_enable, + .disable = clk_gpio_disable, +}; + +static int clk_gpio_probe(struct udevice *dev) +{ + struct clk_gpio_priv *priv = dev_get_priv(dev); + + return gpio_request_by_name(dev, "enable-gpios", 0, + &priv->enable, GPIOD_IS_OUT); +} + +/* + * When implementing clk-mux-clock, use gpio_request_list_by_name + * and implement get_rate/set_rate/set_parent ops. This should be + * in a separate driver and with separate Kconfig option to enable + * that driver, since unlike Linux implementation, the U-Boot DM + * integration would be orthogonal to this driver. + */ +static const struct udevice_id clk_gpio_match[] = { + { .compatible = "gpio-gate-clock" }, + { /* sentinel */ } +}; + +U_BOOT_DRIVER(gpio_gate_clock) = { + .name = "gpio_clock", + .id = UCLASS_CLK, + .of_match = clk_gpio_match, + .probe = clk_gpio_probe, + .priv_auto = sizeof(struct clk_gpio_priv), + .ops = &clk_gpio_ops, + .flags = DM_FLAG_PRE_RELOC, +}; diff --git a/drivers/clk/clk-hsdk-cgu.c b/drivers/clk/clk-hsdk-cgu.c index e28543ef78b..85074f1b86e 100644 --- a/drivers/clk/clk-hsdk-cgu.c +++ b/drivers/clk/clk-hsdk-cgu.c @@ -19,6 +19,7 @@ #include <linux/delay.h> #include <linux/io.h> #include <asm/arcregs.h> +#include <linux/printk.h> #include <dt-bindings/clock/snps,hsdk-cgu.h> diff --git a/drivers/clk/clk-mux.c b/drivers/clk/clk-mux.c index 017f25f7a5a..f410518461e 100644 --- a/drivers/clk/clk-mux.c +++ b/drivers/clk/clk-mux.c @@ -36,6 +36,7 @@ #include <linux/bitops.h> #include <linux/clk-provider.h> #include <linux/err.h> +#include <linux/printk.h> #include "clk.h" diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c index dc3e9d6a261..f186fcbcdb8 100644 --- a/drivers/clk/clk-uclass.c +++ b/drivers/clk/clk-uclass.c @@ -329,7 +329,13 @@ static int clk_set_default_rates(struct udevice *dev, dev_dbg(dev, "could not get assigned clock %d (err = %d)\n", index, ret); - continue; + /* Skip if it is empty */ + if (ret == -ENOENT) { + ret = 0; + continue; + } + + return ret; } /* This is clk provider device trying to program itself diff --git a/drivers/clk/clk_boston.c b/drivers/clk/clk_boston.c index 2e81777b703..4bcf9117551 100644 --- a/drivers/clk/clk_boston.c +++ b/drivers/clk/clk_boston.c @@ -10,6 +10,7 @@ #include <regmap.h> #include <syscon.h> #include <linux/bitops.h> +#include <linux/printk.h> struct clk_boston { struct regmap *regmap; diff --git a/drivers/clk/clk_versal.c b/drivers/clk/clk_versal.c index b3b33331235..2e004beca2f 100644 --- a/drivers/clk/clk_versal.c +++ b/drivers/clk/clk_versal.c @@ -68,6 +68,13 @@ #define CLOCK_NODE_TYPE_DIV 4 #define CLOCK_NODE_TYPE_GATE 6 +#define PM_CLK_REF_CLK (0x830c06aU) +#define PM_CLK_PL_ALT_REF_CLK (0x830c06bU) +#define PM_CLK_MUXED_IRO (0x830c06cU) +#define PM_CLK_EMIO (0x830c071U) + +#define TOPOLOGY_TYPE_FIXEDFACTOR 0x3 + enum clk_type { CLK_TYPE_OUTPUT, CLK_TYPE_EXTERNAL, @@ -365,48 +372,37 @@ static u32 versal_clock_set_div(u32 clk_id, u32 div) return div; } -static u64 versal_clock_ref(u32 clk_id) +static u64 versal_clock_get_ref_rate(u32 clk_id) { - u32 ret_payload[PAYLOAD_ARG_CNT]; - int ref; - - xilinx_pm_request(PM_CLOCK_GETPARENT, clk_id, 0, 0, 0, ret_payload); - ref = ret_payload[0]; - if (!(ref & 1)) + if (clk_id == PM_CLK_REF_CLK || clk_id == PM_CLK_MUXED_IRO || clk_id == PM_CLK_EMIO) return ref_clk; - if (ref & 2) + else if (clk_id == PM_CLK_PL_ALT_REF_CLK) return pl_alt_ref_clk; - return 0; + else + return 0; } -static u64 versal_clock_get_pll_rate(u32 clk_id) +static int versal_clock_get_fixed_factor_rate(u32 clock_id, u32 parent_id) { + struct versal_pm_query_data qdata = {0}; u32 ret_payload[PAYLOAD_ARG_CNT]; - u32 fbdiv; - u32 res; - u32 frac; - u64 freq; - u32 parent_rate, parent_id; - u32 id = clk_id & 0xFFF; + u32 mult, div; + u32 parent_rate; + int ret; - xilinx_pm_request(PM_CLOCK_GETSTATE, clk_id, 0, 0, 0, ret_payload); - res = ret_payload[1]; - if (!res) { - printf("0%x PLL not enabled\n", clk_id); - return 0; - } + qdata.qid = PM_QID_CLOCK_GET_FIXEDFACTOR_PARAMS; + qdata.arg1 = clock_id; - parent_id = clock[clock[id].parent[0].id].clk_id; - parent_rate = versal_clock_ref(parent_id); + ret = versal_pm_query(qdata, ret_payload); + if (ret) + return ret; - xilinx_pm_request(PM_CLOCK_GETDIVIDER, clk_id, 0, 0, 0, ret_payload); - fbdiv = ret_payload[1]; - xilinx_pm_request(PM_CLOCK_PLL_GETPARAM, clk_id, 2, 0, 0, ret_payload); - frac = ret_payload[1]; + mult = ret_payload[1]; + div = ret_payload[2]; - freq = (fbdiv * parent_rate) >> (1 << frac); + parent_rate = versal_clock_get_ref_rate(parent_id); + return parent_rate * mult / div; - return freq; } static u32 versal_clock_mux(u32 clk_id) @@ -437,6 +433,37 @@ static u32 versal_clock_get_parentid(u32 clk_id) return clock[clock[id].parent[parent_id].id].clk_id; } +static u64 versal_clock_get_pll_rate(u32 clk_id) +{ + u32 ret_payload[PAYLOAD_ARG_CNT]; + u32 fbdiv; + u32 res; + u32 frac; + u64 freq; + u32 parent_rate, parent_id, parent_ref_clk_id; + u32 id = clk_id & 0xFFF; + + xilinx_pm_request(PM_CLOCK_GETSTATE, clk_id, 0, 0, 0, ret_payload); + res = ret_payload[1]; + if (!res) { + printf("0%x PLL not enabled\n", clk_id); + return 0; + } + + parent_id = clock[clock[id].parent[0].id].clk_id; + parent_ref_clk_id = versal_clock_get_parentid(parent_id); + parent_rate = versal_clock_get_ref_rate(parent_ref_clk_id); + + xilinx_pm_request(PM_CLOCK_GETDIVIDER, clk_id, 0, 0, 0, ret_payload); + fbdiv = ret_payload[1]; + xilinx_pm_request(PM_CLOCK_PLL_GETPARAM, clk_id, 2, 0, 0, ret_payload); + frac = ret_payload[1]; + + freq = (fbdiv * parent_rate) >> (1 << frac); + + return freq; +} + static u32 versal_clock_gate(u32 clk_id) { u32 id = clk_id & 0xFFF; @@ -479,14 +506,19 @@ static u64 versal_clock_calc(u32 clk_id) u32 parent_id; u64 clk_rate; u32 div; + struct clock_topology topology; if (versal_clock_pll(clk_id, &clk_rate)) return clk_rate; parent_id = versal_clock_get_parentid(clk_id); if (((parent_id >> NODE_SUBCLASS_SHIFT) & - NODE_CLASS_MASK) == NODE_SUBCLASS_CLOCK_REF) - return versal_clock_ref(clk_id); + NODE_CLASS_MASK) == NODE_SUBCLASS_CLOCK_REF) { + topology = clock[clk_id & 0x3FF].node[0]; + if (topology.type == TOPOLOGY_TYPE_FIXEDFACTOR) + return versal_clock_get_fixed_factor_rate(clk_id, parent_id); + return versal_clock_get_ref_rate(parent_id); + } if (!parent_id) return 0; @@ -505,7 +537,7 @@ static int versal_clock_get_rate(u32 clk_id, u64 *clk_rate) { if (((clk_id >> NODE_SUBCLASS_SHIFT) & NODE_CLASS_MASK) == NODE_SUBCLASS_CLOCK_REF) - *clk_rate = versal_clock_ref(clk_id); + *clk_rate = versal_clock_get_ref_rate(clk_id); if (versal_clock_pll(clk_id, clk_rate)) return 0; diff --git a/drivers/clk/imx/clk-pll14xx.c b/drivers/clk/imx/clk-pll14xx.c index b93c0bc64e7..1cb685ee9ab 100644 --- a/drivers/clk/imx/clk-pll14xx.c +++ b/drivers/clk/imx/clk-pll14xx.c @@ -18,6 +18,7 @@ #include <linux/iopoll.h> #include <clk.h> #include <div64.h> +#include <linux/printk.h> #include "clk.h" diff --git a/drivers/clk/rockchip/clk_rk3368.c b/drivers/clk/rockchip/clk_rk3368.c index a47c431cf5f..3406ff592e1 100644 --- a/drivers/clk/rockchip/clk_rk3368.c +++ b/drivers/clk/rockchip/clk_rk3368.c @@ -23,6 +23,7 @@ #include <dm/lists.h> #include <dt-bindings/clock/rk3368-cru.h> #include <linux/delay.h> +#include <linux/printk.h> #include <linux/stringify.h> #if CONFIG_IS_ENABLED(OF_PLATDATA) diff --git a/drivers/clk/rockchip/clk_rk3399.c b/drivers/clk/rockchip/clk_rk3399.c index f748fb5189e..c37e8a53a26 100644 --- a/drivers/clk/rockchip/clk_rk3399.c +++ b/drivers/clk/rockchip/clk_rk3399.c @@ -24,6 +24,7 @@ #include <dt-bindings/clock/rk3399-cru.h> #include <linux/bitops.h> #include <linux/delay.h> +#include <linux/printk.h> DECLARE_GLOBAL_DATA_PTR; diff --git a/drivers/core/device.c b/drivers/core/device.c index 6e26b64fb81..bf7f261cbce 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -33,6 +33,7 @@ #include <linux/err.h> #include <linux/list.h> #include <power-domain.h> +#include <linux/printk.h> DECLARE_GLOBAL_DATA_PTR; @@ -598,9 +599,10 @@ int device_probe(struct udevice *dev) ret = device_notify(dev, EVT_DM_POST_PROBE); if (ret) - return ret; + goto fail_event; return 0; +fail_event: fail_uclass: if (device_remove(dev, DM_REMOVE_NORMAL)) { dm_warn("%s: Device '%s' failed to remove on error path\n", diff --git a/drivers/core/dump.c b/drivers/core/dump.c index 3e77832a3a0..4023b390f54 100644 --- a/drivers/core/dump.c +++ b/drivers/core/dump.c @@ -85,29 +85,65 @@ static void show_devices(struct udevice *dev, int depth, int last_flag, } } -void dm_dump_tree(bool sort) +static void dm_dump_tree_single(struct udevice *dev, bool sort) { - struct udevice *root; + int dev_count, uclasses; + struct udevice **devs = NULL; - root = dm_root(); - if (root) { - int dev_count, uclasses; - struct udevice **devs = NULL; - - dm_get_stats(&dev_count, &uclasses); - - printf(" Class Index Probed Driver Name\n"); - printf("-----------------------------------------------------------\n"); - if (sort) { - devs = calloc(dev_count, sizeof(struct udevice *)); - if (!devs) { - printf("(out of memory)\n"); - return; + dm_get_stats(&dev_count, &uclasses); + + if (sort) { + devs = calloc(dev_count, sizeof(struct udevice *)); + if (!devs) { + printf("(out of memory)\n"); + return; + } + } + show_devices(dev, -1, 0, devs); + free(devs); +} + +static void dm_dump_tree_recursive(struct udevice *dev, char *dev_name, + bool extended, bool sort) +{ + struct udevice *child; + size_t len; + + len = strlen(dev_name); + + device_foreach_child(child, dev) { + if (extended) { + if (!strncmp(child->name, dev_name, len)) { + dm_dump_tree_single(child, sort); + continue; + } + } else { + if (!strcmp(child->name, dev_name)) { + dm_dump_tree_single(child, sort); + continue; } } - show_devices(root, -1, 0, devs); - free(devs); + dm_dump_tree_recursive(child, dev_name, extended, sort); + } +} + +void dm_dump_tree(char *dev_name, bool extended, bool sort) +{ + struct udevice *root; + + printf(" Class Index Probed Driver Name\n"); + printf("-----------------------------------------------------------\n"); + + root = dm_root(); + if (!root) + return; + + if (!dev_name || !strcmp(dev_name, "root")) { + dm_dump_tree_single(root, sort); + return; } + + dm_dump_tree_recursive(root, dev_name, extended, sort); } /** @@ -127,26 +163,50 @@ static void dm_display_line(struct udevice *dev, int index) puts("\n"); } -void dm_dump_uclass(void) +static void dm_dump_uclass_single(enum uclass_id id) { struct uclass *uc; + struct udevice *dev; + int i = 0, ret; + + ret = uclass_get(id, &uc); + if (ret) + return; + + printf("uclass %d: %s\n", id, uc->uc_drv->name); + uclass_foreach_dev(dev, uc) { + dm_display_line(dev, i); + i++; + } + puts("\n"); +} + +void dm_dump_uclass(char *uclass, bool extended) +{ + struct uclass *uc; + enum uclass_id id; + bool matching; int ret; - int id; - for (id = 0; id < UCLASS_COUNT; id++) { - struct udevice *dev; - int i = 0; + matching = !!(uclass && strcmp(uclass, "root")); + for (id = 0; id < UCLASS_COUNT; id++) { ret = uclass_get(id, &uc); if (ret) continue; - printf("uclass %d: %s\n", id, uc->uc_drv->name); - uclass_foreach_dev(dev, uc) { - dm_display_line(dev, i); - i++; + if (matching) { + if (extended) { + if (!strncmp(uc->uc_drv->name, uclass, + strlen(uclass))) + dm_dump_uclass_single(id); + } else { + if (!strcmp(uc->uc_drv->name, uclass)) + dm_dump_uclass_single(id); + } + } else { + dm_dump_uclass_single(id); } - puts("\n"); } } diff --git a/drivers/core/of_access.c b/drivers/core/of_access.c index 57f10445b12..1bb4d8eab70 100644 --- a/drivers/core/of_access.c +++ b/drivers/core/of_access.c @@ -570,26 +570,34 @@ int of_read_u32_index(const struct device_node *np, const char *propname, return 0; } -int of_read_u64(const struct device_node *np, const char *propname, u64 *outp) +int of_read_u64_index(const struct device_node *np, const char *propname, + int index, u64 *outp) { const __be64 *val; debug("%s: %s: ", __func__, propname); if (!np) return -EINVAL; - val = of_find_property_value_of_size(np, propname, sizeof(*outp)); + + val = of_find_property_value_of_size(np, propname, + sizeof(*outp) * (index + 1)); if (IS_ERR(val)) { debug("(not found)\n"); return PTR_ERR(val); } - *outp = be64_to_cpup(val); + *outp = be64_to_cpup(val + index); debug("%#llx (%lld)\n", (unsigned long long)*outp, - (unsigned long long)*outp); + (unsigned long long)*outp); return 0; } +int of_read_u64(const struct device_node *np, const char *propname, u64 *outp) +{ + return of_read_u64_index(np, propname, 0, outp); +} + int of_property_match_string(const struct device_node *np, const char *propname, const char *string) { diff --git a/drivers/core/of_addr.c b/drivers/core/of_addr.c index 431dd4e565d..b3b3d7ccdd5 100644 --- a/drivers/core/of_addr.c +++ b/drivers/core/of_addr.c @@ -14,6 +14,7 @@ #include <dm/of_addr.h> #include <linux/err.h> #include <linux/ioport.h> +#include <linux/printk.h> /* Max address size we deal with */ #define OF_MAX_ADDR_CELLS 4 diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 8df16e56af5..2cafa7bca5b 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -103,7 +103,7 @@ void *ofnode_lookup_fdt(ofnode node) if (gd->flags & GD_FLG_RELOC) { uint i = OFTREE_TREE_ID(node.of_offset); - if (i > oftree_count) { + if (i >= oftree_count) { log_debug("Invalid tree ID %x\n", i); return NULL; } @@ -344,6 +344,36 @@ int ofnode_read_u32_index(ofnode node, const char *propname, int index, return 0; } +int ofnode_read_u64_index(ofnode node, const char *propname, int index, + u64 *outp) +{ + const fdt64_t *cell; + int len; + + assert(ofnode_valid(node)); + + if (ofnode_is_np(node)) + return of_read_u64_index(ofnode_to_np(node), propname, index, + outp); + + cell = fdt_getprop(ofnode_to_fdt(node), ofnode_to_offset(node), + propname, &len); + if (!cell) { + debug("(not found)\n"); + return -EINVAL; + } + + if (len < (sizeof(u64) * (index + 1))) { + debug("(not large enough)\n"); + return -EOVERFLOW; + } + + *outp = fdt64_to_cpu(cell[index]); + debug("%#llx (%lld)\n", *outp, *outp); + + return 0; +} + u32 ofnode_read_u32_index_default(ofnode node, const char *propname, int index, u32 def) { @@ -1353,7 +1383,7 @@ bool ofnode_pre_reloc(ofnode node) */ if (ofnode_read_bool(node, "bootph-pre-ram") || ofnode_read_bool(node, "bootph-pre-sram")) - return true; + return gd->flags & GD_FLG_RELOC; if (IS_ENABLED(CONFIG_OF_TAG_MIGRATE)) { /* detect and handle old tags */ @@ -1563,6 +1593,65 @@ const char *ofnode_conf_read_str(const char *prop_name) return ofnode_read_string(node, prop_name); } +int ofnode_read_bootscript_address(u64 *bootscr_address, u64 *bootscr_offset) +{ + int ret; + ofnode uboot; + + *bootscr_address = 0; + *bootscr_offset = 0; + + uboot = ofnode_path("/options/u-boot"); + if (!ofnode_valid(uboot)) { + debug("%s: Missing /u-boot node\n", __func__); + return -EINVAL; + } + + ret = ofnode_read_u64(uboot, "bootscr-address", bootscr_address); + if (ret) { + ret = ofnode_read_u64(uboot, "bootscr-ram-offset", + bootscr_offset); + if (ret) + return -EINVAL; + } + + return 0; +} + +int ofnode_read_bootscript_flash(u64 *bootscr_flash_offset, + u64 *bootscr_flash_size) +{ + int ret; + ofnode uboot; + + *bootscr_flash_offset = 0; + *bootscr_flash_size = 0; + + uboot = ofnode_path("/options/u-boot"); + if (!ofnode_valid(uboot)) { + debug("%s: Missing /u-boot node\n", __func__); + return -EINVAL; + } + + ret = ofnode_read_u64(uboot, "bootscr-flash-offset", + bootscr_flash_offset); + if (ret) + return -EINVAL; + + ret = ofnode_read_u64(uboot, "bootscr-flash-size", + bootscr_flash_size); + if (ret) + return -EINVAL; + + if (!bootscr_flash_size) { + debug("bootscr-flash-size is zero. Ignoring properties!\n"); + *bootscr_flash_offset = 0; + return -EINVAL; + } + + return 0; +} + ofnode ofnode_get_phy_node(ofnode node) { /* DT node properties that reference a PHY node */ diff --git a/drivers/core/root.c b/drivers/core/root.c index 79d871ab291..126b3140666 100644 --- a/drivers/core/root.c +++ b/drivers/core/root.c @@ -29,6 +29,7 @@ #include <dm/uclass-internal.h> #include <dm/util.h> #include <linux/list.h> +#include <linux/printk.h> DECLARE_GLOBAL_DATA_PTR; @@ -55,81 +56,6 @@ void dm_fixup_for_gd_move(struct global_data *new_gd) } } -void fix_drivers(void) -{ - struct driver *drv = - ll_entry_start(struct driver, driver); - const int n_ents = ll_entry_count(struct driver, driver); - struct driver *entry; - - for (entry = drv; entry != drv + n_ents; entry++) { - if (entry->of_match) - entry->of_match = (const struct udevice_id *) - ((ulong)entry->of_match + gd->reloc_off); - if (entry->bind) - entry->bind += gd->reloc_off; - if (entry->probe) - entry->probe += gd->reloc_off; - if (entry->remove) - entry->remove += gd->reloc_off; - if (entry->unbind) - entry->unbind += gd->reloc_off; - if (entry->of_to_plat) - entry->of_to_plat += gd->reloc_off; - if (entry->child_post_bind) - entry->child_post_bind += gd->reloc_off; - if (entry->child_pre_probe) - entry->child_pre_probe += gd->reloc_off; - if (entry->child_post_remove) - entry->child_post_remove += gd->reloc_off; - /* OPS are fixed in every uclass post_probe function */ - if (entry->ops) - entry->ops += gd->reloc_off; - } -} - -void fix_uclass(void) -{ - struct uclass_driver *uclass = - ll_entry_start(struct uclass_driver, uclass_driver); - const int n_ents = ll_entry_count(struct uclass_driver, uclass_driver); - struct uclass_driver *entry; - - for (entry = uclass; entry != uclass + n_ents; entry++) { - if (entry->post_bind) - entry->post_bind += gd->reloc_off; - if (entry->pre_unbind) - entry->pre_unbind += gd->reloc_off; - if (entry->pre_probe) - entry->pre_probe += gd->reloc_off; - if (entry->post_probe) - entry->post_probe += gd->reloc_off; - if (entry->pre_remove) - entry->pre_remove += gd->reloc_off; - if (entry->child_post_bind) - entry->child_post_bind += gd->reloc_off; - if (entry->child_pre_probe) - entry->child_pre_probe += gd->reloc_off; - if (entry->init) - entry->init += gd->reloc_off; - if (entry->destroy) - entry->destroy += gd->reloc_off; - } -} - -void fix_devices(void) -{ - struct driver_info *dev = - ll_entry_start(struct driver_info, driver_info); - const int n_ents = ll_entry_count(struct driver_info, driver_info); - struct driver_info *entry; - - for (entry = dev; entry != dev + n_ents; entry++) { - if (entry->plat) - entry->plat += gd->reloc_off; - } -} - static int dm_setup_inst(void) { DM_ROOT_NON_CONST = DM_DEVICE_GET(root); @@ -181,12 +107,6 @@ int dm_init(bool of_live) INIT_LIST_HEAD(DM_UCLASS_ROOT_NON_CONST); } - if (IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC)) { - fix_drivers(); - fix_uclass(); - fix_devices(); - } - if (CONFIG_IS_ENABLED(OF_PLATDATA_INST)) { ret = dm_setup_inst(); if (ret) { diff --git a/drivers/cpu/cpu-uclass.c b/drivers/cpu/cpu-uclass.c index a7548325265..9772578968b 100644 --- a/drivers/cpu/cpu-uclass.c +++ b/drivers/cpu/cpu-uclass.c @@ -127,36 +127,9 @@ static int uclass_cpu_init(struct uclass *uc) return ret; } -static int uclass_cpu_post_bind(struct udevice *dev) -{ - if (IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC) && - (gd->flags & GD_FLG_RELOC)) { - struct cpu_ops *ops = cpu_get_ops(dev); - static int reloc_done; - - if (!reloc_done) { - if (ops->get_desc) - MANUAL_RELOC(ops->get_desc); - if (ops->get_info) - MANUAL_RELOC(ops->get_info); - if (ops->get_count) - MANUAL_RELOC(ops->get_count); - if (ops->get_vendor) - MANUAL_RELOC(ops->get_vendor); - if (ops->is_current) - MANUAL_RELOC(ops->is_current); - - reloc_done++; - } - } - - return 0; -} - UCLASS_DRIVER(cpu) = { .id = UCLASS_CPU, .name = "cpu", .flags = DM_UC_FLAG_SEQ_ALIAS, .init = uclass_cpu_init, - .post_bind = uclass_cpu_post_bind, }; diff --git a/drivers/cpu/microblaze_cpu.c b/drivers/cpu/microblaze_cpu.c index c97a89fbd5c..a229f6913b0 100644 --- a/drivers/cpu/microblaze_cpu.c +++ b/drivers/cpu/microblaze_cpu.c @@ -19,7 +19,7 @@ DECLARE_GLOBAL_DATA_PTR; ci = tmp; \ } -static int microblaze_cpu_probe_all(void *ctx, struct event *event) +static int microblaze_cpu_probe_all(void) { int ret; @@ -29,7 +29,7 @@ static int microblaze_cpu_probe_all(void *ctx, struct event *event) return 0; } -EVENT_SPY(EVT_DM_POST_INIT_F, microblaze_cpu_probe_all); +EVENT_SPY_SIMPLE(EVT_DM_POST_INIT_F, microblaze_cpu_probe_all); static void microblaze_set_cpuinfo_pvr(struct microblaze_cpuinfo *ci) { diff --git a/drivers/crypto/rsa_mod_exp/mod_exp_uclass.c b/drivers/crypto/rsa_mod_exp/mod_exp_uclass.c index 6a4d235d57b..057cc74b10b 100644 --- a/drivers/crypto/rsa_mod_exp/mod_exp_uclass.c +++ b/drivers/crypto/rsa_mod_exp/mod_exp_uclass.c @@ -16,24 +16,11 @@ #include <asm/io.h> #include <linux/list.h> -#if !defined(USE_HOSTCC) && defined(CONFIG_NEEDS_MANUAL_RELOC) -DECLARE_GLOBAL_DATA_PTR; -#endif - int rsa_mod_exp(struct udevice *dev, const uint8_t *sig, uint32_t sig_len, struct key_prop *node, uint8_t *out) { struct mod_exp_ops *ops = (struct mod_exp_ops *)device_get_ops(dev); -#if !defined(USE_HOSTCC) && defined(CONFIG_NEEDS_MANUAL_RELOC) - static bool done; - - if (!done) { - done = true; - ops->mod_exp += gd->reloc_off; - } -#endif - if (!ops->mod_exp) return -ENOSYS; diff --git a/drivers/ddr/imx/phy/helper.c b/drivers/ddr/imx/phy/helper.c index 8cd438791e5..855a874ac1e 100644 --- a/drivers/ddr/imx/phy/helper.c +++ b/drivers/ddr/imx/phy/helper.c @@ -46,13 +46,13 @@ void ddr_load_train_firmware(enum fw_type type) u32 error = 0; unsigned long pr_to32, pr_from32; uint32_t fw_offset = type ? IMEM_2D_OFFSET : 0; - unsigned long imem_start = (unsigned long)&_end + fw_offset; + unsigned long imem_start = (unsigned long)_end + fw_offset; unsigned long dmem_start; unsigned long imem_len = IMEM_LEN, dmem_len = DMEM_LEN; #ifdef CONFIG_SPL_OF_CONTROL if (gd->fdt_blob && !fdt_check_header(gd->fdt_blob)) { - imem_start = roundup((unsigned long)&_end + + imem_start = roundup((unsigned long)_end + fdt_totalsize(gd->fdt_blob), 4) + fw_offset; } diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c index b2ee5f1ede6..2adf26e2fe2 100644 --- a/drivers/dfu/dfu.c +++ b/drivers/dfu/dfu.c @@ -17,6 +17,7 @@ #include <hash.h> #include <linux/list.h> #include <linux/compiler.h> +#include <linux/printk.h> LIST_HEAD(dfu_list); static int dfu_alt_num; diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c index f5832083ba1..cdb3c18b01d 100644 --- a/drivers/dfu/dfu_mmc.c +++ b/drivers/dfu/dfu_mmc.c @@ -17,6 +17,7 @@ #include <mmc.h> #include <part.h> #include <command.h> +#include <linux/printk.h> static unsigned char *dfu_file_buf; static u64 dfu_file_buf_len; diff --git a/drivers/dfu/dfu_ram.c b/drivers/dfu/dfu_ram.c index 9d10303164e..c4f4bd2e482 100644 --- a/drivers/dfu/dfu_ram.c +++ b/drivers/dfu/dfu_ram.c @@ -13,6 +13,7 @@ #include <mapmem.h> #include <errno.h> #include <dfu.h> +#include <linux/printk.h> static int dfu_transfer_medium_ram(enum dfu_op op, struct dfu_entity *dfu, u64 offset, void *buf, long *len) diff --git a/drivers/dma/bcm6348-iudma.c b/drivers/dma/bcm6348-iudma.c index 4fc650272d9..d4cfe0c1868 100644 --- a/drivers/dma/bcm6348-iudma.c +++ b/drivers/dma/bcm6348-iudma.c @@ -28,6 +28,7 @@ #include <asm/io.h> #include <linux/bitops.h> #include <linux/delay.h> +#include <linux/printk.h> #define DMA_RX_DESC 6 #define DMA_TX_DESC 1 diff --git a/drivers/dma/dma-uclass.c b/drivers/dma/dma-uclass.c index 34f72fa5dc8..0c1d88e10c6 100644 --- a/drivers/dma/dma-uclass.c +++ b/drivers/dma/dma-uclass.c @@ -22,6 +22,7 @@ #include <linux/dma-mapping.h> #include <dt-structs.h> #include <errno.h> +#include <linux/printk.h> #ifdef CONFIG_DMA_CHANNELS static inline struct dma_ops *dma_dev_ops(struct udevice *dev) diff --git a/drivers/dma/lpc32xx_dma.c b/drivers/dma/lpc32xx_dma.c index ab58e97bfe2..0efdfd028cf 100644 --- a/drivers/dma/lpc32xx_dma.c +++ b/drivers/dma/lpc32xx_dma.c @@ -17,6 +17,7 @@ #include <asm/io.h> #include <linux/bitops.h> #include <linux/delay.h> +#include <linux/printk.h> /* DMA controller channel register structure */ struct dmac_chan_reg { diff --git a/drivers/dma/sandbox-dma-test.c b/drivers/dma/sandbox-dma-test.c index 2b8259a35b4..a19e5e37fb9 100644 --- a/drivers/dma/sandbox-dma-test.c +++ b/drivers/dma/sandbox-dma-test.c @@ -15,6 +15,7 @@ #include <dma-uclass.h> #include <dt-structs.h> #include <errno.h> +#include <linux/printk.h> #define SANDBOX_DMA_CH_CNT 3 #define SANDBOX_DMA_BUF_SIZE 1024 diff --git a/drivers/dma/ti-edma3.c b/drivers/dma/ti-edma3.c index 1ad3b92dbf4..31ffff07f5b 100644 --- a/drivers/dma/ti-edma3.c +++ b/drivers/dma/ti-edma3.c @@ -16,6 +16,7 @@ #include <linux/dma-mapping.h> #include <asm/omap_common.h> #include <asm/ti-common/ti-edma3.h> +#include <linux/printk.h> #define EDMA3_SL_BASE(slot) (0x4000 + ((slot) << 5)) #define EDMA3_SL_MAX_NUM 512 diff --git a/drivers/dma/ti/k3-psil-j721e.c b/drivers/dma/ti/k3-psil-j721e.c index 105ffd946f4..8e57e860f25 100644 --- a/drivers/dma/ti/k3-psil-j721e.c +++ b/drivers/dma/ti/k3-psil-j721e.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* - * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com + * Copyright (C) 2019-2023 Texas Instruments Incorporated - https://www.ti.com * Author: Peter Ujfalusi <[email protected]> */ @@ -21,13 +21,15 @@ /* PSI-L source thread IDs, used for RX (DMA_DEV_TO_MEM) */ static struct psil_ep j721e_src_ep_map[] = { - /* CPSW0 */ + /* MCU_CPSW0 */ PSIL_ETHERNET(0x7000), + /* MAIN_CPSW0 */ + PSIL_ETHERNET(0x4a00), }; /* PSI-L destination thread IDs, used for TX (DMA_MEM_TO_DEV) */ static struct psil_ep j721e_dst_ep_map[] = { - /* CPSW0 */ + /* MCU_CPSW0 */ PSIL_ETHERNET(0xf000), PSIL_ETHERNET(0xf001), PSIL_ETHERNET(0xf002), @@ -36,6 +38,15 @@ static struct psil_ep j721e_dst_ep_map[] = { PSIL_ETHERNET(0xf005), PSIL_ETHERNET(0xf006), PSIL_ETHERNET(0xf007), + /* MAIN_CPSW0 */ + PSIL_ETHERNET(0xca00), + PSIL_ETHERNET(0xca01), + PSIL_ETHERNET(0xca02), + PSIL_ETHERNET(0xca03), + PSIL_ETHERNET(0xca04), + PSIL_ETHERNET(0xca05), + PSIL_ETHERNET(0xca06), + PSIL_ETHERNET(0xca07), }; struct psil_ep_map j721e_ep_map = { diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c index 05c3a4311ce..4f2effd39a8 100644 --- a/drivers/dma/ti/k3-udma.c +++ b/drivers/dma/ti/k3-udma.c @@ -25,6 +25,7 @@ #include <linux/delay.h> #include <linux/bitmap.h> #include <linux/err.h> +#include <linux/printk.h> #include <linux/soc/ti/k3-navss-ringacc.h> #include <linux/soc/ti/cppi5.h> #include <linux/soc/ti/ti-udma.h> diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig index a3df9aa3d0f..837c6f1180d 100644 --- a/drivers/fastboot/Kconfig +++ b/drivers/fastboot/Kconfig @@ -56,7 +56,7 @@ config FASTBOOT_BUF_ADDR ROCKCHIP_RK3399 default 0x280000 if ROCKCHIP_RK3368 default 0x100000 if ARCH_ZYNQMP - default 0 if SANDBOX + default 0x0 if SANDBOX help The fastboot protocol requires a large memory buffer for downloads. Define this to the starting RAM address to use for diff --git a/drivers/fastboot/fb_command.c b/drivers/fastboot/fb_command.c index 71cfaec6e9d..5fcadcdf503 100644 --- a/drivers/fastboot/fb_command.c +++ b/drivers/fastboot/fb_command.c @@ -12,6 +12,7 @@ #include <fb_nand.h> #include <part.h> #include <stdlib.h> +#include <linux/printk.h> /** * image_size - final fastboot image size diff --git a/drivers/fastboot/fb_getvar.c b/drivers/fastboot/fb_getvar.c index dd3475e0a8b..8cb8ffa2c6c 100644 --- a/drivers/fastboot/fb_getvar.c +++ b/drivers/fastboot/fb_getvar.c @@ -12,6 +12,7 @@ #include <fs.h> #include <part.h> #include <version.h> +#include <linux/printk.h> static void getvar_version(char *var_parameter, char *response); static void getvar_version_bootloader(char *var_parameter, char *response); @@ -183,7 +184,7 @@ static void __maybe_unused getvar_has_slot(char *part_name, char *response) /* part_name_wslot = part_name + "_a" */ len = strlcpy(part_name_wslot, part_name, PART_NAME_LEN - 3); - if (len > PART_NAME_LEN - 3) + if (len >= PART_NAME_LEN - 3) goto fail; strcat(part_name_wslot, "_a"); diff --git a/drivers/fastboot/fb_nand.c b/drivers/fastboot/fb_nand.c index 6d3a900c772..bbe26ddcc9b 100644 --- a/drivers/fastboot/fb_nand.c +++ b/drivers/fastboot/fb_nand.c @@ -11,6 +11,7 @@ #include <fastboot.h> #include <image-sparse.h> +#include <linux/printk.h> #include <linux/mtd/mtd.h> #include <jffs2/jffs2.h> #include <nand.h> diff --git a/drivers/firmware/firmware-zynqmp.c b/drivers/firmware/firmware-zynqmp.c index ab4c4f1a690..43fb7fa7787 100644 --- a/drivers/firmware/firmware-zynqmp.c +++ b/drivers/firmware/firmware-zynqmp.c @@ -195,6 +195,19 @@ int zynqmp_pm_set_sd_config(u32 node, enum pm_sd_config_type config, u32 value) return ret; } +int zynqmp_pm_feature(const u32 api_id) +{ + int ret; + u32 ret_payload[PAYLOAD_ARG_CNT]; + + /* Check feature check API version */ + ret = xilinx_pm_request(PM_FEATURE_CHECK, api_id, 0, 0, 0, + ret_payload); + + /* Return feature check version */ + return ret_payload[1] & FIRMWARE_VERSION_MASK; +} + int zynqmp_pm_is_function_supported(const u32 api_id, const u32 id) { int ret; diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c index 31027f3d990..7aece85a70a 100644 --- a/drivers/gpio/gpio-uclass.c +++ b/drivers/gpio/gpio-uclass.c @@ -28,6 +28,8 @@ DECLARE_GLOBAL_DATA_PTR; +#define GPIO_ALLOC_BITS 32 + /** * gpio_desc_init() - Initialize the GPIO descriptor * @@ -75,6 +77,46 @@ static int gpio_to_device(unsigned int gpio, struct gpio_desc *desc) return -ENOENT; } +/** + * gpio_is_claimed() - Test whether GPIO is claimed by consumer + * + * Test whether GPIO is claimed by consumer already. + * + * @uc_priv: gpio_dev_priv pointer. + * @offset: gpio offset within the device + * @return: true if claimed, false if not claimed + */ +static bool gpio_is_claimed(struct gpio_dev_priv *uc_priv, unsigned int offset) +{ + return !!(uc_priv->claimed[offset / GPIO_ALLOC_BITS] & BIT(offset % GPIO_ALLOC_BITS)); +} + +/** + * gpio_set_claim() - Set GPIO claimed by consumer + * + * Set a bit which indicate the GPIO is claimed by consumer + * + * @uc_priv: gpio_dev_priv pointer. + * @offset: gpio offset within the device + */ +static void gpio_set_claim(struct gpio_dev_priv *uc_priv, unsigned int offset) +{ + uc_priv->claimed[offset / GPIO_ALLOC_BITS] |= BIT(offset % GPIO_ALLOC_BITS); +} + +/** + * gpio_clear_claim() - Clear GPIO claimed by consumer + * + * Clear a bit which indicate the GPIO is claimed by consumer + * + * @uc_priv: gpio_dev_priv pointer. + * @offset: gpio offset within the device + */ +static void gpio_clear_claim(struct gpio_dev_priv *uc_priv, unsigned int offset) +{ + uc_priv->claimed[offset / GPIO_ALLOC_BITS] &= ~BIT(offset % GPIO_ALLOC_BITS); +} + #if CONFIG_IS_ENABLED(DM_GPIO_LOOKUP_LABEL) /** * dm_gpio_lookup_label() - look for name in gpio device @@ -94,7 +136,7 @@ static int dm_gpio_lookup_label(const char *name, *offset = -1; for (i = 0; i < uc_priv->gpio_count; i++) { - if (!uc_priv->name[i]) + if (!gpio_is_claimed(uc_priv, i)) continue; if (!strcmp(name, uc_priv->name[i])) { *offset = i; @@ -350,7 +392,7 @@ int dm_gpio_request(struct gpio_desc *desc, const char *label) int ret; uc_priv = dev_get_uclass_priv(dev); - if (uc_priv->name[desc->offset]) + if (gpio_is_claimed(uc_priv, desc->offset)) return -EBUSY; str = strdup(label); if (!str) @@ -362,6 +404,8 @@ int dm_gpio_request(struct gpio_desc *desc, const char *label) return ret; } } + + gpio_set_claim(uc_priv, desc->offset); uc_priv->name[desc->offset] = str; return 0; @@ -438,7 +482,7 @@ int _dm_gpio_free(struct udevice *dev, uint offset) int ret; uc_priv = dev_get_uclass_priv(dev); - if (!uc_priv->name[offset]) + if (!gpio_is_claimed(uc_priv, offset)) return -ENXIO; if (ops->rfree) { ret = ops->rfree(dev, offset); @@ -446,6 +490,7 @@ int _dm_gpio_free(struct udevice *dev, uint offset) return ret; } + gpio_clear_claim(uc_priv, offset); free(uc_priv->name[offset]); uc_priv->name[offset] = NULL; @@ -480,7 +525,7 @@ static int check_reserved(const struct gpio_desc *desc, const char *func) return -ENOENT; uc_priv = dev_get_uclass_priv(desc->dev); - if (!uc_priv->name[desc->offset]) { + if (!gpio_is_claimed(uc_priv, desc->offset)) { printf("%s: %s: error: gpio %s%d not reserved\n", desc->dev->name, func, uc_priv->bank_name ? uc_priv->bank_name : "", @@ -826,7 +871,7 @@ static int get_function(struct udevice *dev, int offset, bool skip_unused, return -EINVAL; if (namep) *namep = uc_priv->name[offset]; - if (skip_unused && !uc_priv->name[offset]) + if (skip_unused && !gpio_is_claimed(uc_priv, offset)) return GPIOF_UNUSED; if (ops->get_function) { int ret; @@ -1341,6 +1386,14 @@ static int gpio_post_probe(struct udevice *dev) if (!uc_priv->name) return -ENOMEM; + uc_priv->claimed = calloc(DIV_ROUND_UP(uc_priv->gpio_count, + GPIO_ALLOC_BITS), + GPIO_ALLOC_BITS / 8); + if (!uc_priv->claimed) { + free(uc_priv->name); + return -ENOMEM; + } + return gpio_renumber(NULL); } @@ -1353,6 +1406,7 @@ static int gpio_pre_remove(struct udevice *dev) if (uc_priv->name[i]) free(uc_priv->name[i]); } + free(uc_priv->claimed); free(uc_priv->name); return gpio_renumber(dev); @@ -1444,36 +1498,6 @@ void devm_gpiod_put(struct udevice *dev, struct gpio_desc *desc) static int gpio_post_bind(struct udevice *dev) { -#if defined(CONFIG_NEEDS_MANUAL_RELOC) - struct dm_gpio_ops *ops = (struct dm_gpio_ops *)device_get_ops(dev); - static int reloc_done; - - if (!reloc_done) { - if (ops->request) - ops->request += gd->reloc_off; - if (ops->rfree) - ops->rfree += gd->reloc_off; - if (ops->direction_input) - ops->direction_input += gd->reloc_off; - if (ops->direction_output) - ops->direction_output += gd->reloc_off; - if (ops->get_value) - ops->get_value += gd->reloc_off; - if (ops->set_value) - ops->set_value += gd->reloc_off; - if (ops->get_function) - ops->get_function += gd->reloc_off; - if (ops->xlate) - ops->xlate += gd->reloc_off; - if (ops->set_flags) - ops->set_flags += gd->reloc_off; - if (ops->get_flags) - ops->get_flags += gd->reloc_off; - - reloc_done++; - } -#endif - if (CONFIG_IS_ENABLED(GPIO_HOG) && dev_has_ofnode(dev)) { struct udevice *child; ofnode node; diff --git a/drivers/gpio/pca953x_gpio.c b/drivers/gpio/pca953x_gpio.c index 4654f9e0989..b0c66d18317 100644 --- a/drivers/gpio/pca953x_gpio.c +++ b/drivers/gpio/pca953x_gpio.c @@ -407,6 +407,7 @@ static const struct udevice_id pca953x_ids[] = { { .compatible = "ti,tca6416", .data = OF_953X(16, PCA_INT), }, { .compatible = "ti,tca6424", .data = OF_953X(24, PCA_INT), }, { .compatible = "ti,tca9539", .data = OF_953X(16, PCA_INT), }, + { .compatible = "ti,tca9554", .data = OF_953X(8, PCA_INT), }, { .compatible = "onsemi,pca9654", .data = OF_953X(8, PCA_INT), }, diff --git a/drivers/hwspinlock/hwspinlock-uclass.c b/drivers/hwspinlock/hwspinlock-uclass.c index e012d5a4c93..e9a4d7f9fbb 100644 --- a/drivers/hwspinlock/hwspinlock-uclass.c +++ b/drivers/hwspinlock/hwspinlock-uclass.c @@ -123,28 +123,7 @@ int hwspinlock_unlock(struct hwspinlock *hws) return ops->unlock(hws->dev, hws->id); } -static int hwspinlock_post_bind(struct udevice *dev) -{ -#if defined(CONFIG_NEEDS_MANUAL_RELOC) - struct hwspinlock_ops *ops = device_get_ops(dev); - static int reloc_done; - - if (!reloc_done) { - if (ops->lock) - ops->lock += gd->reloc_off; - if (ops->unlock) - ops->unlock += gd->reloc_off; - if (ops->relax) - ops->relax += gd->reloc_off; - - reloc_done++; - } -#endif - return 0; -} - UCLASS_DRIVER(hwspinlock) = { .id = UCLASS_HWSPINLOCK, .name = "hwspinlock", - .post_bind = hwspinlock_post_bind, }; diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig index 4c76fd7e415..4f42200f392 100644 --- a/drivers/i2c/Kconfig +++ b/drivers/i2c/Kconfig @@ -372,7 +372,7 @@ config SYS_MXC_I2C1_SPEED config SYS_MXC_I2C1_SLAVE hex "I2C1 Slave" - default 0 + default 0x0 help MXC I2C1 Slave endif @@ -387,7 +387,7 @@ config SYS_MXC_I2C2_SPEED config SYS_MXC_I2C2_SLAVE hex "I2C2 Slave" - default 0 + default 0x0 help MXC I2C2 Slave endif @@ -401,7 +401,7 @@ config SYS_MXC_I2C3_SPEED config SYS_MXC_I2C3_SLAVE hex "I2C3 Slave" - default 0 + default 0x0 help MXC I2C3 Slave endif @@ -415,7 +415,7 @@ config SYS_MXC_I2C4_SPEED config SYS_MXC_I2C4_SLAVE hex "I2C4 Slave" - default 0 + default 0x0 help MXC I2C4 Slave endif @@ -429,7 +429,7 @@ config SYS_MXC_I2C5_SPEED config SYS_MXC_I2C5_SLAVE hex "I2C5 Slave" - default 0 + default 0x0 help MXC I2C5 Slave endif @@ -443,7 +443,7 @@ config SYS_MXC_I2C6_SPEED config SYS_MXC_I2C6_SLAVE hex "I2C6 Slave" - default 0 + default 0x0 help MXC I2C6 Slave endif @@ -457,7 +457,7 @@ config SYS_MXC_I2C7_SPEED config SYS_MXC_I2C7_SLAVE hex "I2C7 Slave" - default 0 + default 0x0 help MXC I2C7 Slave endif @@ -471,7 +471,7 @@ config SYS_MXC_I2C8_SPEED config SYS_MXC_I2C8_SLAVE hex "I2C8 Slave" - default 0 + default 0x0 help MXC I2C8 Slave endif diff --git a/drivers/i2c/i2c-gpio.c b/drivers/i2c/i2c-gpio.c index c1fc290bd25..5fc3cfe42ef 100644 --- a/drivers/i2c/i2c-gpio.c +++ b/drivers/i2c/i2c-gpio.c @@ -12,6 +12,7 @@ #include <log.h> #include <asm/gpio.h> #include <linux/delay.h> +#include <linux/printk.h> #define DEFAULT_UDELAY 5 #define RETRIES 0 diff --git a/drivers/i2c/iproc_i2c.c b/drivers/i2c/iproc_i2c.c index d975e782649..39af49c4ec5 100644 --- a/drivers/i2c/iproc_i2c.c +++ b/drivers/i2c/iproc_i2c.c @@ -9,6 +9,7 @@ #include <common.h> #include <config.h> #include <dm.h> +#include <linux/printk.h> #include "errno.h" #include <i2c.h> #include "iproc_i2c.h" diff --git a/drivers/i2c/omap24xx_i2c.c b/drivers/i2c/omap24xx_i2c.c index c656cf8b7a1..6fc9d1eba9d 100644 --- a/drivers/i2c/omap24xx_i2c.c +++ b/drivers/i2c/omap24xx_i2c.c @@ -43,6 +43,7 @@ #include <i2c.h> #include <log.h> #include <linux/delay.h> +#include <linux/printk.h> #include <asm/io.h> #include <asm/omap_i2c.h> diff --git a/drivers/i2c/stm32f7_i2c.c b/drivers/i2c/stm32f7_i2c.c index 836148e4c1a..b6c71789eec 100644 --- a/drivers/i2c/stm32f7_i2c.c +++ b/drivers/i2c/stm32f7_i2c.c @@ -19,6 +19,7 @@ #include <linux/delay.h> #include <linux/err.h> #include <linux/io.h> +#include <linux/printk.h> /* STM32 I2C registers */ struct stm32_i2c_regs { diff --git a/drivers/i2c/tegra_i2c.c b/drivers/i2c/tegra_i2c.c index 5864a1ad5bc..57d77d56ea5 100644 --- a/drivers/i2c/tegra_i2c.c +++ b/drivers/i2c/tegra_i2c.c @@ -21,6 +21,7 @@ #include <asm/arch-tegra/tegra_i2c.h> #include <linux/delay.h> #include <linux/err.h> +#include <linux/printk.h> enum i2c_type { TYPE_114, diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index b9f5c7a37ae..c930e4a361b 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -122,6 +122,14 @@ config VEXPRESS_CONFIG configuration bus on the Arm Versatile Express boards via a sysreg driver. +config CBMEM_CONSOLE + bool "Write console output to coreboot cbmem" + depends on X86 + help + Enables console output to the cbmem console, which is a memory + region set up by coreboot to hold a record of all console output. + Enable this only if booting from coreboot. + config CMD_CROS_EC bool "Enable crosec command" depends on CROS_EC @@ -555,7 +563,7 @@ config SPL_I2C_EEPROM config SYS_I2C_EEPROM_ADDR hex "Chip address of the EEPROM device" depends on ID_EEPROM || I2C_EEPROM || SPL_I2C_EEPROM || CMD_EEPROM || ENV_IS_IN_EEPROM - default 0 + default 0x0 if I2C_EEPROM diff --git a/drivers/misc/cbmem_console.c b/drivers/misc/cbmem_console.c index 8bbe33d414d..ba3a599c4a5 100644 --- a/drivers/misc/cbmem_console.c +++ b/drivers/misc/cbmem_console.c @@ -5,27 +5,37 @@ #include <common.h> #include <console.h> -#ifndef CONFIG_SYS_COREBOOT -#error This driver requires coreboot -#endif - #include <asm/cb_sysinfo.h> -struct cbmem_console { - u32 buffer_size; - u32 buffer_cursor; - u8 buffer_body[0]; -} __attribute__ ((__packed__)); - -static struct cbmem_console *cbmem_console_p; - void cbmemc_putc(struct stdio_dev *dev, char data) { - int cursor; + const struct sysinfo_t *sysinfo = cb_get_sysinfo(); + struct cbmem_console *cons; + uint pos, flags; + + if (!sysinfo) + return; + cons = sysinfo->cbmem_cons; + if (!cons) + return; + + pos = cons->cursor & CBMC_CURSOR_MASK; + + /* preserve the overflow flag if present */ + flags = cons->cursor & ~CBMC_CURSOR_MASK; + + cons->body[pos++] = data; + + /* + * Deal with overflow - the flag may be cleared by another program which + * reads the buffer out later, e.g. Linux + */ + if (pos >= cons->size) { + pos = 0; + flags |= CBMC_OVERFLOW; + } - cursor = cbmem_console_p->buffer_cursor++; - if (cursor < cbmem_console_p->buffer_size) - cbmem_console_p->buffer_body[cursor] = data; + cons->cursor = flags | pos; } void cbmemc_puts(struct stdio_dev *dev, const char *str) @@ -40,7 +50,6 @@ int cbmemc_init(void) { int rc; struct stdio_dev cons_dev; - cbmem_console_p = lib_sysinfo.cbmem_cons; memset(&cons_dev, 0, sizeof(cons_dev)); diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c index 621d1752176..9c1e6a5e3e7 100644 --- a/drivers/misc/cros_ec.c +++ b/drivers/misc/cros_ec.c @@ -1100,8 +1100,11 @@ int cros_ec_get_sku_id(struct udevice *dev) ret = ec_command_inptr(dev, EC_CMD_GET_SKU_ID, 0, NULL, 0, (uint8_t **)&r, sizeof(*r)); - if (ret != sizeof(*r)) - return -ret; + if (ret != sizeof(*r)) { + if (ret >= 0) + ret = -EIO; + return ret; + } return r->sku_id; } diff --git a/drivers/misc/k3_avs.c b/drivers/misc/k3_avs.c index 840148d0900..acfc7318452 100644 --- a/drivers/misc/k3_avs.c +++ b/drivers/misc/k3_avs.c @@ -382,6 +382,8 @@ static struct vd_config am654_vd_config = { static const struct udevice_id k3_avs_ids[] = { { .compatible = "ti,am654-avs", .data = (ulong)&am654_vd_config }, { .compatible = "ti,j721e-avs", .data = (ulong)&j721e_vd_config }, + { .compatible = "ti,j721e-vtm", .data = (ulong)&j721e_vd_config }, + { .compatible = "ti,j7200-vtm", .data = (ulong)&j721e_vd_config }, {} }; diff --git a/drivers/misc/sifive-otp.c b/drivers/misc/sifive-otp.c index 3e658b35662..a624a358802 100644 --- a/drivers/misc/sifive-otp.c +++ b/drivers/misc/sifive-otp.c @@ -24,6 +24,7 @@ #include <linux/delay.h> #include <linux/io.h> #include <misc.h> +#include <linux/printk.h> #define BYTES_PER_FUSE 4 diff --git a/drivers/misc/tegra186_bpmp.c b/drivers/misc/tegra186_bpmp.c index dbee7f77db3..fecac9c4d90 100644 --- a/drivers/misc/tegra186_bpmp.c +++ b/drivers/misc/tegra186_bpmp.c @@ -17,6 +17,7 @@ #include <asm/arch-tegra/ivc.h> #include <linux/bitops.h> #include <linux/err.h> +#include <linux/printk.h> #define BPMP_IVC_FRAME_COUNT 1 #define BPMP_IVC_FRAME_SIZE 128 diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c index 5085a3b491d..400066fa99a 100644 --- a/drivers/mmc/dw_mmc.c +++ b/drivers/mmc/dw_mmc.c @@ -509,6 +509,10 @@ static int dwmci_set_ios(struct mmc *mmc) if (mmc->vqmmc_supply) { int ret; + ret = regulator_set_enable_if_allowed(mmc->vqmmc_supply, false); + if (ret) + return ret; + if (mmc->signal_voltage == MMC_SIGNAL_VOLTAGE_180) regulator_set_value(mmc->vqmmc_supply, 1800000); else diff --git a/drivers/mmc/exynos_dw_mmc.c b/drivers/mmc/exynos_dw_mmc.c index 544798bb71d..2f849c43b12 100644 --- a/drivers/mmc/exynos_dw_mmc.c +++ b/drivers/mmc/exynos_dw_mmc.c @@ -16,6 +16,7 @@ #include <asm/arch/pinmux.h> #include <asm/arch/power.h> #include <asm/gpio.h> +#include <linux/printk.h> #define DWMMC_MAX_CH_NUM 4 #define DWMMC_MAX_FREQ 52000000 diff --git a/drivers/mmc/fsl_esdhc_imx.c b/drivers/mmc/fsl_esdhc_imx.c index 66caf683f74..7c39c86c5e9 100644 --- a/drivers/mmc/fsl_esdhc_imx.c +++ b/drivers/mmc/fsl_esdhc_imx.c @@ -26,6 +26,7 @@ #include <linux/bitops.h> #include <linux/delay.h> #include <linux/err.h> +#include <linux/printk.h> #include <power/regulator.h> #include <malloc.h> #include <fsl_esdhc_imx.h> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 31cfda28858..d96db7a0f83 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -19,6 +19,7 @@ #include <part.h> #include <linux/bitops.h> #include <linux/delay.h> +#include <linux/printk.h> #include <power/regulator.h> #include <malloc.h> #include <memalign.h> @@ -2775,9 +2776,10 @@ static int mmc_power_on(struct mmc *mmc) { #if CONFIG_IS_ENABLED(DM_MMC) && CONFIG_IS_ENABLED(DM_REGULATOR) if (mmc->vmmc_supply) { - int ret = regulator_set_enable(mmc->vmmc_supply, true); + int ret = regulator_set_enable_if_allowed(mmc->vmmc_supply, + true); - if (ret && ret != -EACCES) { + if (ret && ret != -ENOSYS) { printf("Error enabling VMMC supply : %d\n", ret); return ret; } @@ -2791,9 +2793,10 @@ static int mmc_power_off(struct mmc *mmc) mmc_set_clock(mmc, 0, MMC_CLK_DISABLE); #if CONFIG_IS_ENABLED(DM_MMC) && CONFIG_IS_ENABLED(DM_REGULATOR) if (mmc->vmmc_supply) { - int ret = regulator_set_enable(mmc->vmmc_supply, false); + int ret = regulator_set_enable_if_allowed(mmc->vmmc_supply, + false); - if (ret && ret != -EACCES) { + if (ret && ret != -ENOSYS) { pr_debug("Error disabling VMMC supply : %d\n", ret); return ret; } diff --git a/drivers/mmc/mtk-sd.c b/drivers/mmc/mtk-sd.c index b206b0a0858..d21a30c9543 100644 --- a/drivers/mmc/mtk-sd.c +++ b/drivers/mmc/mtk-sd.c @@ -20,6 +20,7 @@ #include <linux/bitops.h> #include <linux/io.h> #include <linux/iopoll.h> +#include <linux/printk.h> /* MSDC_CFG */ #define MSDC_CFG_HS400_CK_MODE_EXT BIT(22) diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index 9cbe126106c..fc9c6c37996 100644 --- a/drivers/mmc/sdhci.c +++ b/drivers/mmc/sdhci.c @@ -19,6 +19,7 @@ #include <linux/bitops.h> #include <linux/delay.h> #include <linux/dma-mapping.h> +#include <linux/printk.h> #include <phys2bus.h> #include <power/regulator.h> diff --git a/drivers/mmc/sti_sdhci.c b/drivers/mmc/sti_sdhci.c index 6194768fd72..23a1dd43c9b 100644 --- a/drivers/mmc/sti_sdhci.c +++ b/drivers/mmc/sti_sdhci.c @@ -12,6 +12,7 @@ #include <sdhci.h> #include <asm/arch/sdhci.h> #include <asm/global_data.h> +#include <linux/printk.h> DECLARE_GLOBAL_DATA_PTR; diff --git a/drivers/mmc/stm32_sdmmc2.c b/drivers/mmc/stm32_sdmmc2.c index b68594de373..5ff5e1a4d8b 100644 --- a/drivers/mmc/stm32_sdmmc2.c +++ b/drivers/mmc/stm32_sdmmc2.c @@ -27,6 +27,7 @@ #include <linux/iopoll.h> #include <power/regulator.h> #include <watchdog.h> +#include <linux/printk.h> struct stm32_sdmmc2_plat { struct mmc_config cfg; diff --git a/drivers/mmc/xenon_sdhci.c b/drivers/mmc/xenon_sdhci.c index 16ac84a24a6..27dbe0404e0 100644 --- a/drivers/mmc/xenon_sdhci.c +++ b/drivers/mmc/xenon_sdhci.c @@ -23,6 +23,7 @@ #include <linux/libfdt.h> #include <malloc.h> #include <sdhci.h> +#include <linux/printk.h> #include <power/regulator.h> DECLARE_GLOBAL_DATA_PTR; diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c index af3c4765c4d..51232581d96 100644 --- a/drivers/mtd/mtdconcat.c +++ b/drivers/mtd/mtdconcat.c @@ -23,6 +23,7 @@ #include <div64.h> #include <linux/bug.h> #include <linux/compat.h> +#include <linux/printk.h> #endif #include <linux/mtd/mtd.h> diff --git a/drivers/mtd/nand/bbt.c b/drivers/mtd/nand/bbt.c index 294daee7b22..972aec6e266 100644 --- a/drivers/mtd/nand/bbt.c +++ b/drivers/mtd/nand/bbt.c @@ -16,6 +16,7 @@ #ifndef __UBOOT__ #include <linux/slab.h> #endif +#include <linux/printk.h> /** * nanddev_bbt_init() - Initialize the BBT (Bad Block Table) diff --git a/drivers/mtd/nand/core.c b/drivers/mtd/nand/core.c index 4b9dd6a9269..f6d9c584f78 100644 --- a/drivers/mtd/nand/core.c +++ b/drivers/mtd/nand/core.c @@ -17,6 +17,7 @@ #endif #include <linux/bitops.h> #include <linux/mtd/nand.h> +#include <linux/printk.h> /** * nanddev_isbad() - Check if a block is bad diff --git a/drivers/mtd/nand/raw/arasan_nfc.c b/drivers/mtd/nand/raw/arasan_nfc.c index 587941290dc..14766401bf6 100644 --- a/drivers/mtd/nand/raw/arasan_nfc.c +++ b/drivers/mtd/nand/raw/arasan_nfc.c @@ -18,6 +18,7 @@ #include <asm/arch/sys_proto.h> #include <dm.h> #include <nand.h> +#include <linux/printk.h> struct nand_config { u32 page; diff --git a/drivers/mtd/nand/raw/atmel/nand-controller.c b/drivers/mtd/nand/raw/atmel/nand-controller.c index 950e626f918..fa962ba591c 100644 --- a/drivers/mtd/nand/raw/atmel/nand-controller.c +++ b/drivers/mtd/nand/raw/atmel/nand-controller.c @@ -1474,7 +1474,6 @@ static void atmel_nand_init(struct atmel_nand_controller *nc, mtd->dev->parent = nc->dev; nand->controller = &nc->base; - nand->controller = &nc->base; chip->cmd_ctrl = atmel_nand_cmd_ctrl; chip->read_byte = atmel_nand_read_byte; diff --git a/drivers/mtd/nand/raw/atmel_nand.c b/drivers/mtd/nand/raw/atmel_nand.c index b7e473c598d..6b17e744a69 100644 --- a/drivers/mtd/nand/raw/atmel_nand.c +++ b/drivers/mtd/nand/raw/atmel_nand.c @@ -19,6 +19,7 @@ #include <linux/bitops.h> #include <linux/bug.h> #include <linux/delay.h> +#include <linux/printk.h> #include <malloc.h> #include <nand.h> diff --git a/drivers/mtd/nand/raw/brcmnand/bcm63158_nand.c b/drivers/mtd/nand/raw/brcmnand/bcm63158_nand.c index aa095c439ba..4e6d99fd3ca 100644 --- a/drivers/mtd/nand/raw/brcmnand/bcm63158_nand.c +++ b/drivers/mtd/nand/raw/brcmnand/bcm63158_nand.c @@ -10,6 +10,7 @@ #include <linux/io.h> #include <linux/ioport.h> #include <dm.h> +#include <linux/printk.h> #include "brcmnand.h" diff --git a/drivers/mtd/nand/raw/brcmnand/bcm6368_nand.c b/drivers/mtd/nand/raw/brcmnand/bcm6368_nand.c index e4bf1936810..6164989b937 100644 --- a/drivers/mtd/nand/raw/brcmnand/bcm6368_nand.c +++ b/drivers/mtd/nand/raw/brcmnand/bcm6368_nand.c @@ -9,6 +9,7 @@ #include <linux/io.h> #include <linux/ioport.h> #include <dm.h> +#include <linux/printk.h> #include "brcmnand.h" diff --git a/drivers/mtd/nand/raw/brcmnand/bcm68360_nand.c b/drivers/mtd/nand/raw/brcmnand/bcm68360_nand.c index 586ea3d8fbb..dbd85af7079 100644 --- a/drivers/mtd/nand/raw/brcmnand/bcm68360_nand.c +++ b/drivers/mtd/nand/raw/brcmnand/bcm68360_nand.c @@ -9,6 +9,7 @@ #include <linux/io.h> #include <linux/ioport.h> #include <dm.h> +#include <linux/printk.h> #include "brcmnand.h" diff --git a/drivers/mtd/nand/raw/brcmnand/bcm6838_nand.c b/drivers/mtd/nand/raw/brcmnand/bcm6838_nand.c index 85f318bd779..ef3649688c6 100644 --- a/drivers/mtd/nand/raw/brcmnand/bcm6838_nand.c +++ b/drivers/mtd/nand/raw/brcmnand/bcm6838_nand.c @@ -10,6 +10,7 @@ #include <linux/io.h> #include <linux/ioport.h> #include <dm.h> +#include <linux/printk.h> #include "brcmnand.h" diff --git a/drivers/mtd/nand/raw/brcmnand/bcm6858_nand.c b/drivers/mtd/nand/raw/brcmnand/bcm6858_nand.c index a5e159ad521..027fdd37da3 100644 --- a/drivers/mtd/nand/raw/brcmnand/bcm6858_nand.c +++ b/drivers/mtd/nand/raw/brcmnand/bcm6858_nand.c @@ -10,6 +10,7 @@ #include <linux/io.h> #include <linux/ioport.h> #include <dm.h> +#include <linux/printk.h> #include "brcmnand.h" diff --git a/drivers/mtd/nand/raw/davinci_nand.c b/drivers/mtd/nand/raw/davinci_nand.c index e4e144bd7c8..71bbb8231bf 100644 --- a/drivers/mtd/nand/raw/davinci_nand.c +++ b/drivers/mtd/nand/raw/davinci_nand.c @@ -35,6 +35,7 @@ #include <nand.h> #include <dm/uclass.h> #include <asm/ti-common/davinci_nand.h> +#include <linux/printk.h> /* Definitions for 4-bit hardware ECC */ #define NAND_TIMEOUT 10240 diff --git a/drivers/mtd/nand/raw/lpc32xx_nand_mlc.c b/drivers/mtd/nand/raw/lpc32xx_nand_mlc.c index 28541177609..ac2e669d46b 100644 --- a/drivers/mtd/nand/raw/lpc32xx_nand_mlc.c +++ b/drivers/mtd/nand/raw/lpc32xx_nand_mlc.c @@ -28,6 +28,7 @@ #include <nand.h> #include <asm/arch/clk.h> #include <asm/arch/sys_proto.h> +#include <linux/printk.h> /* * MLC NAND controller registers. diff --git a/drivers/mtd/nand/raw/lpc32xx_nand_slc.c b/drivers/mtd/nand/raw/lpc32xx_nand_slc.c index 356f8d9440b..b21a0b9d293 100644 --- a/drivers/mtd/nand/raw/lpc32xx_nand_slc.c +++ b/drivers/mtd/nand/raw/lpc32xx_nand_slc.c @@ -23,6 +23,7 @@ #include <asm/arch/sys_proto.h> #include <asm/arch/dma.h> #include <asm/arch/cpu.h> +#include <linux/printk.h> struct lpc32xx_nand_slc_regs { u32 data; diff --git a/drivers/mtd/nand/raw/mxc_nand.c b/drivers/mtd/nand/raw/mxc_nand.c index 051ded6a240..dbdc5b0bca1 100644 --- a/drivers/mtd/nand/raw/mxc_nand.c +++ b/drivers/mtd/nand/raw/mxc_nand.c @@ -15,6 +15,7 @@ #if defined(CONFIG_MX51) || defined(CONFIG_MX53) #include <asm/arch/imx-regs.h> #endif +#include <linux/printk.h> #include "mxc_nand.h" #define DRIVER_NAME "mxc_nand" diff --git a/drivers/mtd/nand/raw/nand_bch.c b/drivers/mtd/nand/raw/nand_bch.c index 734d1c6204e..bb48ebbb96c 100644 --- a/drivers/mtd/nand/raw/nand_bch.c +++ b/drivers/mtd/nand/raw/nand_bch.c @@ -10,6 +10,7 @@ #include <common.h> #include <log.h> #include <dm/devres.h> +#include <linux/printk.h> /*#include <asm/io.h>*/ #include <linux/types.h> diff --git a/drivers/mtd/nand/raw/pxa3xx_nand.c b/drivers/mtd/nand/raw/pxa3xx_nand.c index d502e967f92..1d9a6d107b1 100644 --- a/drivers/mtd/nand/raw/pxa3xx_nand.c +++ b/drivers/mtd/nand/raw/pxa3xx_nand.c @@ -22,6 +22,7 @@ #include <asm/arch/cpu.h> #include <linux/mtd/mtd.h> #include <linux/mtd/rawnand.h> +#include <linux/printk.h> #include <linux/types.h> #include <syscon.h> #include <regmap.h> diff --git a/drivers/mtd/nand/raw/stm32_fmc2_nand.c b/drivers/mtd/nand/raw/stm32_fmc2_nand.c index 69dbb629e93..64be6486b4e 100644 --- a/drivers/mtd/nand/raw/stm32_fmc2_nand.c +++ b/drivers/mtd/nand/raw/stm32_fmc2_nand.c @@ -21,6 +21,7 @@ #include <linux/iopoll.h> #include <linux/ioport.h> #include <linux/mtd/rawnand.h> +#include <linux/printk.h> /* Bad block marker length */ #define FMC2_BBM_LEN 2 diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c index c0fa1e310c6..0b5b74dc242 100644 --- a/drivers/mtd/nand/raw/sunxi_nand.c +++ b/drivers/mtd/nand/raw/sunxi_nand.c @@ -36,6 +36,7 @@ #include <linux/bitops.h> #include <linux/delay.h> #include <linux/err.h> +#include <linux/printk.h> #include <linux/kernel.h> #include <linux/mtd/mtd.h> diff --git a/drivers/mtd/nand/raw/tegra_nand.c b/drivers/mtd/nand/raw/tegra_nand.c index 139d978a49b..6086ecdfa3d 100644 --- a/drivers/mtd/nand/raw/tegra_nand.c +++ b/drivers/mtd/nand/raw/tegra_nand.c @@ -24,6 +24,7 @@ #include <fdtdec.h> #include <bouncebuf.h> #include <dm.h> +#include <linux/printk.h> #include "tegra_nand.h" DECLARE_GLOBAL_DATA_PTR; diff --git a/drivers/mtd/nand/raw/vf610_nfc.c b/drivers/mtd/nand/raw/vf610_nfc.c index d4b40e810f0..d2363a0662e 100644 --- a/drivers/mtd/nand/raw/vf610_nfc.c +++ b/drivers/mtd/nand/raw/vf610_nfc.c @@ -24,6 +24,7 @@ #include <common.h> #include <malloc.h> #include <dm/device_compat.h> +#include <linux/printk.h> #include <linux/mtd/mtd.h> #include <linux/mtd/rawnand.h> diff --git a/drivers/mtd/nand/raw/zynq_nand.c b/drivers/mtd/nand/raw/zynq_nand.c index 545fdd7b697..bacaf13c570 100644 --- a/drivers/mtd/nand/raw/zynq_nand.c +++ b/drivers/mtd/nand/raw/zynq_nand.c @@ -21,6 +21,7 @@ #include <asm/arch/hardware.h> #include <asm/arch/sys_proto.h> #include <dm.h> +#include <linux/printk.h> /* The NAND flash driver defines */ #define ZYNQ_NAND_CMD_PHASE 1 diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c index 70d8ae531ee..4ee11e812d8 100644 --- a/drivers/mtd/nand/spi/core.c +++ b/drivers/mtd/nand/spi/core.c @@ -30,6 +30,7 @@ #include <linux/bitops.h> #include <linux/bug.h> #include <linux/mtd/spinand.h> +#include <linux/printk.h> #endif /* SPI NAND index visible in MTD names */ diff --git a/drivers/mtd/nvmxip/nvmxip-uclass.c b/drivers/mtd/nvmxip/nvmxip-uclass.c index 6d8eb177b50..9a316d1de39 100644 --- a/drivers/mtd/nvmxip/nvmxip-uclass.c +++ b/drivers/mtd/nvmxip/nvmxip-uclass.c @@ -22,27 +22,13 @@ #define DEFAULT_LBA_SZ BIT(DEFAULT_LBA_SHIFT) -/** - * nvmxip_post_bind() - post binding treatments - * @dev: the NVMXIP device - * - * Create and probe a child block device. - * - * Return: - * - * 0 on success. Otherwise, failure - */ -static int nvmxip_post_bind(struct udevice *udev) +int nvmxip_probe(struct udevice *udev) { int ret; struct udevice *bdev = NULL; char bdev_name[NVMXIP_BLKDEV_NAME_SZ + 1]; int devnum; -#if CONFIG_IS_ENABLED(SANDBOX64) - sandbox_set_enable_memio(true); -#endif - devnum = uclass_id_count(UCLASS_NVMXIP); snprintf(bdev_name, NVMXIP_BLKDEV_NAME_SZ, "blk#%d", devnum); @@ -67,6 +53,12 @@ static int nvmxip_post_bind(struct udevice *udev) return 0; } +static int nvmxip_post_bind(struct udevice *udev) +{ + dev_or_flags(udev, DM_FLAG_PROBE_AFTER_BIND); + return 0; +} + UCLASS_DRIVER(nvmxip) = { .name = "nvmxip", .id = UCLASS_NVMXIP, diff --git a/drivers/mtd/nvmxip/nvmxip.c b/drivers/mtd/nvmxip/nvmxip.c index a359e3b4822..0bd98d64275 100644 --- a/drivers/mtd/nvmxip/nvmxip.c +++ b/drivers/mtd/nvmxip/nvmxip.c @@ -16,23 +16,6 @@ #include "nvmxip.h" /** - * nvmxip_mmio_rawread() - read from the XIP flash - * @address: address of the data - * @value: pointer to where storing the value read - * - * Read raw data from the XIP flash. - * - * Return: - * - * Always return 0. - */ -static int nvmxip_mmio_rawread(const phys_addr_t address, u64 *value) -{ - *value = readq(address); - return 0; -} - -/** * nvmxip_blk_read() - block device read operation * @dev: the block device * @blknr: first block number to read from @@ -49,15 +32,14 @@ static ulong nvmxip_blk_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcn { struct nvmxip_plat *plat = dev_get_plat(dev->parent); struct blk_desc *desc = dev_get_uclass_plat(dev); - /* number of the u64 words to read */ - u32 qwords = (blkcnt * desc->blksz) / sizeof(u64); + /* number of bytes to read */ + u32 size = blkcnt * desc->blksz; /* physical address of the first block to read */ phys_addr_t blkaddr = plat->phys_base + blknr * desc->blksz; - u64 *virt_blkaddr; - u64 *pdst = buffer; + void *virt_blkaddr; uint qdata_idx; - if (!pdst) + if (!buffer) return -EINVAL; log_debug("[%s]: reading from blknr: %lu , blkcnt: %lu\n", dev->name, blknr, blkcnt); @@ -66,12 +48,16 @@ static ulong nvmxip_blk_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcn /* assumption: the data is virtually contiguous */ - for (qdata_idx = 0 ; qdata_idx < qwords ; qdata_idx++) - nvmxip_mmio_rawread((phys_addr_t)(virt_blkaddr + qdata_idx), pdst++); - +#if IS_ENABLED(CONFIG_PHYS_64BIT) + for (qdata_idx = 0 ; qdata_idx < size; qdata_idx += sizeof(u64)) + *(u64 *)(buffer + qdata_idx) = readq(virt_blkaddr + qdata_idx); +#else + for (qdata_idx = 0 ; qdata_idx < size; qdata_idx += sizeof(u32)) + *(u32 *)(buffer + qdata_idx) = readl(virt_blkaddr + qdata_idx); +#endif log_debug("[%s]: src[0]: 0x%llx , dst[0]: 0x%llx , src[-1]: 0x%llx , dst[-1]: 0x%llx\n", dev->name, - *virt_blkaddr, + *(u64 *)virt_blkaddr, *(u64 *)buffer, *(u64 *)((u8 *)virt_blkaddr + desc->blksz * blkcnt - sizeof(u64)), *(u64 *)((u8 *)buffer + desc->blksz * blkcnt - sizeof(u64))); diff --git a/drivers/mtd/nvmxip/nvmxip_qspi.c b/drivers/mtd/nvmxip/nvmxip_qspi.c index 7221fd1cb46..4d7471118a4 100644 --- a/drivers/mtd/nvmxip/nvmxip_qspi.c +++ b/drivers/mtd/nvmxip/nvmxip_qspi.c @@ -50,8 +50,8 @@ static int nvmxip_qspi_of_to_plat(struct udevice *dev) return -EINVAL; } - log_debug("[%s]: XIP device base addr: 0x%llx , lba_shift: %d , lbas: %lu\n", - dev->name, plat->phys_base, plat->lba_shift, plat->lba); + log_debug("[%s]: XIP device base addr: 0x%p , lba_shift: %d , lbas: %lu\n", + dev->name, (void *)(uintptr_t)plat->phys_base, plat->lba_shift, plat->lba); return 0; } @@ -66,5 +66,6 @@ U_BOOT_DRIVER(nvmxip_qspi) = { .id = UCLASS_NVMXIP, .of_match = nvmxip_qspi_ids, .of_to_plat = nvmxip_qspi_of_to_plat, + .probe = nvmxip_probe, .plat_auto = sizeof(struct nvmxip_plat), }; diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c index 08fe7d427ac..762b01c1b0f 100644 --- a/drivers/mtd/onenand/onenand_base.c +++ b/drivers/mtd/onenand/onenand_base.c @@ -26,6 +26,7 @@ #include <linux/bitops.h> #include <linux/compat.h> #include <linux/mtd/mtd.h> +#include <linux/printk.h> #include "linux/mtd/flashchip.h" #include <linux/mtd/onenand.h> diff --git a/drivers/mtd/onenand/onenand_bbt.c b/drivers/mtd/onenand/onenand_bbt.c index eca9edff603..cc1e449f4a7 100644 --- a/drivers/mtd/onenand/onenand_bbt.c +++ b/drivers/mtd/onenand/onenand_bbt.c @@ -20,6 +20,7 @@ #include <linux/mtd/mtd.h> #include <linux/mtd/onenand.h> #include <malloc.h> +#include <linux/printk.h> #include <linux/errno.h> diff --git a/drivers/mtd/onenand/samsung.c b/drivers/mtd/onenand/samsung.c index 657abaab8f4..c415e5149a0 100644 --- a/drivers/mtd/onenand/samsung.c +++ b/drivers/mtd/onenand/samsung.c @@ -16,6 +16,7 @@ #include <linux/mtd/onenand.h> #include <linux/mtd/flashchip.h> #include <linux/mtd/samsung_onenand.h> +#include <linux/printk.h> #include <asm/io.h> #include <linux/errno.h> diff --git a/drivers/mtd/spi/sf-uclass.c b/drivers/mtd/spi/sf-uclass.c index df1f75390c4..2da0cf0dcf9 100644 --- a/drivers/mtd/spi/sf-uclass.c +++ b/drivers/mtd/spi/sf-uclass.c @@ -96,22 +96,6 @@ static int spi_flash_post_bind(struct udevice *dev) return log_msg_ret("bd", ret); } -#if defined(CONFIG_NEEDS_MANUAL_RELOC) - struct dm_spi_flash_ops *ops = sf_get_ops(dev); - static int reloc_done; - - if (!reloc_done) { - if (ops->read) - ops->read += gd->reloc_off; - if (ops->write) - ops->write += gd->reloc_off; - if (ops->erase) - ops->erase += gd->reloc_off; - - reloc_done++; - } -#endif - return 0; } diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c index 6093277f171..db20feb4dae 100644 --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c @@ -21,6 +21,7 @@ #include <linux/errno.h> #include <linux/log2.h> #include <linux/math64.h> +#include <linux/printk.h> #include <linux/sizes.h> #include <linux/bitfield.h> #include <linux/delay.h> diff --git a/drivers/mtd/spi/spi-nor-ids.c b/drivers/mtd/spi/spi-nor-ids.c index 45872159842..b03dd1cd08e 100644 --- a/drivers/mtd/spi/spi-nor-ids.c +++ b/drivers/mtd/spi/spi-nor-ids.c @@ -249,6 +249,7 @@ const struct flash_info spi_nor_ids[] = { { INFO("mx25u6435f", 0xc22537, 0, 64 * 1024, 128, SECT_4K) }, { INFO("mx25l12805d", 0xc22018, 0, 64 * 1024, 256, SECT_4K) }, { INFO("mx25u12835f", 0xc22538, 0, 64 * 1024, 256, SECT_4K) }, + { INFO("mx25u25635f", 0xc22539, 0, 64 * 1024, 512, SECT_4K) }, { INFO("mx25u51245g", 0xc2253a, 0, 64 * 1024, 1024, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) }, { INFO("mx25l12855e", 0xc22618, 0, 64 * 1024, 256, 0) }, diff --git a/drivers/mtd/spi/spi-nor-tiny.c b/drivers/mtd/spi/spi-nor-tiny.c index 7aa24e129f9..0719fe845ca 100644 --- a/drivers/mtd/spi/spi-nor-tiny.c +++ b/drivers/mtd/spi/spi-nor-tiny.c @@ -16,6 +16,7 @@ #include <linux/errno.h> #include <linux/log2.h> #include <linux/math64.h> +#include <linux/printk.h> #include <linux/sizes.h> #include <linux/mtd/mtd.h> diff --git a/drivers/mtd/ubi/attach.c b/drivers/mtd/ubi/attach.c index e488caa5547..2ef8fde3d32 100644 --- a/drivers/mtd/ubi/attach.c +++ b/drivers/mtd/ubi/attach.c @@ -81,6 +81,7 @@ #include <div64.h> #include <linux/bug.h> #include <linux/err.h> +#include <linux/printk.h> #endif #include <linux/math64.h> diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 3ac0b194028..a1941b8eb88 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c @@ -33,6 +33,7 @@ #else #include <linux/bug.h> #include <linux/log2.h> +#include <linux/printk.h> #endif #include <linux/err.h> #include <ubi_uboot.h> diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c index d2b7ca5e33f..b119cb6e9c0 100644 --- a/drivers/mtd/ubi/debug.c +++ b/drivers/mtd/ubi/debug.c @@ -8,6 +8,7 @@ #include <hexdump.h> #include <malloc.h> #include <ubi_uboot.h> +#include <linux/printk.h> #include "ubi.h" #ifndef __UBOOT__ #include <linux/debugfs.h> diff --git a/drivers/mtd/ubi/debug.h b/drivers/mtd/ubi/debug.h index 9c8ce51636b..2e13ebb2fb7 100644 --- a/drivers/mtd/ubi/debug.h +++ b/drivers/mtd/ubi/debug.h @@ -17,6 +17,7 @@ void ubi_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr); #endif #include <hexdump.h> +#include <linux/printk.h> #ifndef __UBOOT__ #define ubi_assert(expr) do { \ diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h index f44960186bb..175988899c3 100644 --- a/drivers/mtd/ubi/ubi.h +++ b/drivers/mtd/ubi/ubi.h @@ -28,6 +28,7 @@ #include <asm/pgtable.h> #else #include <ubi_uboot.h> +#include <linux/printk.h> #endif #include <linux/mtd/mtd.h> #include <linux/mtd/ubi.h> diff --git a/drivers/net/bcm-sf2-eth-gmac.c b/drivers/net/bcm-sf2-eth-gmac.c index 3caf0f33109..cbe1e85222f 100644 --- a/drivers/net/bcm-sf2-eth-gmac.c +++ b/drivers/net/bcm-sf2-eth-gmac.c @@ -6,6 +6,7 @@ #ifdef BCM_GMAC_DEBUG #ifndef DEBUG #define DEBUG +#include <linux/printk.h> #endif #endif diff --git a/drivers/net/bcm-sf2-eth.c b/drivers/net/bcm-sf2-eth.c index 88dc3ab3846..1524f5c9989 100644 --- a/drivers/net/bcm-sf2-eth.c +++ b/drivers/net/bcm-sf2-eth.c @@ -9,6 +9,7 @@ #include <net.h> #include <config.h> #include <linux/delay.h> +#include <linux/printk.h> #include <phy.h> #include <miiphy.h> diff --git a/drivers/net/bcm6348-eth.c b/drivers/net/bcm6348-eth.c index 53171736117..72dcd07d30d 100644 --- a/drivers/net/bcm6348-eth.c +++ b/drivers/net/bcm6348-eth.c @@ -18,6 +18,7 @@ #include <reset.h> #include <wait_bit.h> #include <asm/io.h> +#include <linux/printk.h> #define ETH_RX_DESC PKTBUFSRX #define ETH_MAX_MTU_SIZE 1518 diff --git a/drivers/net/bcm6368-eth.c b/drivers/net/bcm6368-eth.c index c2a8b9f0576..fdd938ce0dd 100644 --- a/drivers/net/bcm6368-eth.c +++ b/drivers/net/bcm6368-eth.c @@ -19,6 +19,7 @@ #include <asm/io.h> #include <dm/device_compat.h> #include <linux/delay.h> +#include <linux/printk.h> #define ETH_PORT_STR "brcm,enetsw-port" diff --git a/drivers/net/designware.c b/drivers/net/designware.c index e09ca3313dd..20b86e74cec 100644 --- a/drivers/net/designware.c +++ b/drivers/net/designware.c @@ -29,6 +29,7 @@ #include <linux/err.h> #include <linux/kernel.h> #include <asm/io.h> +#include <linux/printk.h> #include <power/regulator.h> #include "designware.h" diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c index 1e92bd9ca9c..9b1a9e69bf8 100644 --- a/drivers/net/dwc_eth_qos.c +++ b/drivers/net/dwc_eth_qos.c @@ -52,6 +52,7 @@ #include <asm/mach-imx/sys_proto.h> #endif #include <linux/delay.h> +#include <linux/printk.h> #include "dwc_eth_qos.h" diff --git a/drivers/net/fsl-mc/dpio/qbman_sys.h b/drivers/net/fsl-mc/dpio/qbman_sys.h index ff998d49dc4..1c6e4891302 100644 --- a/drivers/net/fsl-mc/dpio/qbman_sys.h +++ b/drivers/net/fsl-mc/dpio/qbman_sys.h @@ -21,6 +21,7 @@ /* Trace the 3 different classes of read/write access to QBMan. #undef as * required. */ #include <linux/bug.h> +#include <linux/printk.h> #undef QBMAN_CCSR_TRACE #undef QBMAN_CINH_TRACE #undef QBMAN_CENA_TRACE diff --git a/drivers/net/ftgmac100.c b/drivers/net/ftgmac100.c index a50cde338a2..587d3658fa9 100644 --- a/drivers/net/ftgmac100.c +++ b/drivers/net/ftgmac100.c @@ -25,6 +25,7 @@ #include <linux/bitops.h> #include <linux/io.h> #include <linux/iopoll.h> +#include <linux/printk.h> #include "ftgmac100.h" diff --git a/drivers/net/mscc_eswitch/jr2_switch.c b/drivers/net/mscc_eswitch/jr2_switch.c index 1462b8f3bc8..7157428a685 100644 --- a/drivers/net/mscc_eswitch/jr2_switch.c +++ b/drivers/net/mscc_eswitch/jr2_switch.c @@ -17,6 +17,7 @@ #include <miiphy.h> #include <net.h> #include <wait_bit.h> +#include <linux/printk.h> #include <dt-bindings/mscc/jr2_data.h> #include "mscc_xfer.h" diff --git a/drivers/net/mscc_eswitch/ocelot_switch.c b/drivers/net/mscc_eswitch/ocelot_switch.c index 1bf6c42c0fc..7ea1f551a11 100644 --- a/drivers/net/mscc_eswitch/ocelot_switch.c +++ b/drivers/net/mscc_eswitch/ocelot_switch.c @@ -17,6 +17,7 @@ #include <miiphy.h> #include <net.h> #include <wait_bit.h> +#include <linux/printk.h> #include "mscc_xfer.h" #include "mscc_mac_table.h" diff --git a/drivers/net/mscc_eswitch/serval_switch.c b/drivers/net/mscc_eswitch/serval_switch.c index 38ddba12b66..be06e483373 100644 --- a/drivers/net/mscc_eswitch/serval_switch.c +++ b/drivers/net/mscc_eswitch/serval_switch.c @@ -17,6 +17,7 @@ #include <miiphy.h> #include <net.h> #include <wait_bit.h> +#include <linux/printk.h> #include "mscc_xfer.h" #include "mscc_mac_table.h" diff --git a/drivers/net/mscc_eswitch/servalt_switch.c b/drivers/net/mscc_eswitch/servalt_switch.c index db863c2a9ff..2d2329c204a 100644 --- a/drivers/net/mscc_eswitch/servalt_switch.c +++ b/drivers/net/mscc_eswitch/servalt_switch.c @@ -16,6 +16,7 @@ #include <miiphy.h> #include <net.h> #include <wait_bit.h> +#include <linux/printk.h> #include "mscc_xfer.h" #include "mscc_miim.h" diff --git a/drivers/net/mt7628-eth.c b/drivers/net/mt7628-eth.c index 0a9bdb3ddbd..b95de474fb0 100644 --- a/drivers/net/mt7628-eth.c +++ b/drivers/net/mt7628-eth.c @@ -28,6 +28,7 @@ #include <linux/bitops.h> #include <linux/delay.h> #include <linux/err.h> +#include <linux/printk.h> /* Ethernet frame engine register */ #define PDMA_RELATED 0x0800 diff --git a/drivers/net/mtk_eth.c b/drivers/net/mtk_eth.c index d4111e73df1..3cfce058451 100644 --- a/drivers/net/mtk_eth.c +++ b/drivers/net/mtk_eth.c @@ -26,6 +26,7 @@ #include <linux/ioport.h> #include <linux/mdio.h> #include <linux/mii.h> +#include <linux/printk.h> #include "mtk_eth.h" diff --git a/drivers/net/mvmdio.c b/drivers/net/mvmdio.c index c0ebcdb1f68..5ebcfe14b7f 100644 --- a/drivers/net/mvmdio.c +++ b/drivers/net/mvmdio.c @@ -13,6 +13,7 @@ #include <asm/io.h> #include <wait_bit.h> #include <linux/bitops.h> +#include <linux/printk.h> #define MVMDIO_SMI_DATA_SHIFT 0 #define MVMDIO_SMI_PHY_ADDR_SHIFT 16 diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index 0c3c39a5504..3d96938eaba 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig @@ -224,7 +224,7 @@ config PHY_MOTORCOMM tristate "Motorcomm PHYs" help Enables support for Motorcomm network PHYs. - Currently supports the YT8531 Gigabit Ethernet PHYs. + Currently supports the YT8511 and YT8531 Gigabit Ethernet PHYs. config PHY_MSCC bool "Microsemi Corp Ethernet PHYs support" diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c index 36c70da181a..82e3bbef7dd 100644 --- a/drivers/net/phy/broadcom.c +++ b/drivers/net/phy/broadcom.c @@ -30,10 +30,87 @@ #define MIIM_BCM54XX_EXP_SEL_ER 0x0f00 /* Expansion register select */ #define MIIM_BCM_AUXCNTL_SHDWSEL_MISC 0x0007 -#define MIIM_BCM_AUXCNTL_ACTL_SMDSP_EN 0x0800 +#define MIIM_BCM_AUXCNTL_SHDWSEL_MISC_WIRESPEED_EN 0x0010 +#define MIIM_BCM_AUXCNTL_SHDWSEL_MISC_RGMII_EN 0x0080 +#define MIIM_BCM_AUXCNTL_SHDWSEL_MISC_RGMII_SKEW_EN 0x0100 +#define MIIM_BCM_AUXCNTL_MISC_FORCE_AMDIX 0x0200 +#define MIIM_BCM_AUXCNTL_ACTL_SMDSP_EN 0x0800 +#define MIIM_BCM_AUXCNTL_MISC_WREN 0x8000 #define MIIM_BCM_CHANNEL_WIDTH 0x2000 +#define BCM54810_SHD_CLK_CTL 0x3 +#define BCM54810_SHD_CLK_CTL_GTXCLK_EN BIT(9) + +static int bcm54xx_auxctl_read(struct phy_device *phydev, u16 regnum) +{ + /* The register must be written to both the Shadow Register Select and + * the Shadow Read Register Selector + */ + phy_write(phydev, MDIO_DEVAD_NONE, MIIM_BCM54xx_AUXCNTL, + MIIM_BCM54xx_AUXCNTL_ENCODE(regnum)); + return phy_read(phydev, MDIO_DEVAD_NONE, MIIM_BCM54xx_AUXCNTL); +} + +static int bcm54xx_auxctl_write(struct phy_device *phydev, u16 regnum, u16 val) +{ + return phy_write(phydev, MDIO_DEVAD_NONE, MIIM_BCM54xx_AUXCNTL, regnum | val); +} + +static int bcm_phy_read_shadow(struct phy_device *phydev, u16 shadow) +{ + phy_write(phydev, MDIO_DEVAD_NONE, MIIM_BCM54XX_SHD, + MIIM_BCM54XX_SHD_VAL(shadow)); + return MIIM_BCM54XX_SHD_DATA(phy_read(phydev, MDIO_DEVAD_NONE, + MIIM_BCM54XX_SHD)); +} + +static int bcm_phy_write_shadow(struct phy_device *phydev, u16 shadow, u16 val) +{ + return phy_write(phydev, MDIO_DEVAD_NONE, MIIM_BCM54XX_SHD, + MIIM_BCM54XX_SHD_WR_ENCODE(shadow, val)); +} + +static int bcm54xx_config_clock_delay(struct phy_device *phydev) +{ + int rc, val; + + /* handling PHY's internal RX clock delay */ + val = bcm54xx_auxctl_read(phydev, MIIM_BCM_AUXCNTL_SHDWSEL_MISC); + val |= MIIM_BCM_AUXCNTL_MISC_WREN; + if (phydev->interface == PHY_INTERFACE_MODE_RGMII || + phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) { + /* Disable RGMII RXC-RXD skew */ + val &= ~MIIM_BCM_AUXCNTL_SHDWSEL_MISC_RGMII_SKEW_EN; + } + if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || + phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) { + /* Enable RGMII RXC-RXD skew */ + val |= MIIM_BCM_AUXCNTL_SHDWSEL_MISC_RGMII_SKEW_EN; + } + rc = bcm54xx_auxctl_write(phydev, MIIM_BCM_AUXCNTL_SHDWSEL_MISC, val); + if (rc < 0) + return rc; + + /* handling PHY's internal TX clock delay */ + val = bcm_phy_read_shadow(phydev, BCM54810_SHD_CLK_CTL); + if (phydev->interface == PHY_INTERFACE_MODE_RGMII || + phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) { + /* Disable internal TX clock delay */ + val &= ~BCM54810_SHD_CLK_CTL_GTXCLK_EN; + } + if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || + phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) { + /* Enable internal TX clock delay */ + val |= BCM54810_SHD_CLK_CTL_GTXCLK_EN; + } + rc = bcm_phy_write_shadow(phydev, BCM54810_SHD_CLK_CTL, val); + if (rc < 0) + return rc; + + return 0; +} + static void bcm_phy_write_misc(struct phy_device *phydev, u16 reg, u16 chl, u16 value) { @@ -62,6 +139,18 @@ static int bcm5461_config(struct phy_device *phydev) return 0; } +/* Broadcom BCM54210E */ +static int bcm54210e_config(struct phy_device *phydev) +{ + int ret; + + ret = bcm54xx_config_clock_delay(phydev); + if (ret < 0) + return ret; + + return bcm5461_config(phydev); +} + static int bcm54xx_parse_status(struct phy_device *phydev) { unsigned int mii_reg; @@ -311,6 +400,16 @@ static int bcm5482_startup(struct phy_device *phydev) return bcm54xx_parse_status(phydev); } +U_BOOT_PHY_DRIVER(bcm54210e) = { + .name = "Broadcom BCM54210E", + .uid = 0x600d84a0, + .mask = 0xfffffff0, + .features = PHY_GBIT_FEATURES, + .config = &bcm54210e_config, + .startup = &bcm54xx_startup, + .shutdown = &genphy_shutdown, +}; + U_BOOT_PHY_DRIVER(bcm5461s) = { .name = "Broadcom BCM5461S", .uid = 0x2060c0, diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c index 7111e36aa0d..b6726031ebb 100644 --- a/drivers/net/phy/dp83867.c +++ b/drivers/net/phy/dp83867.c @@ -10,6 +10,7 @@ #include <linux/bitops.h> #include <linux/compat.h> #include <malloc.h> +#include <linux/printk.h> #include <dm.h> #include <dt-bindings/net/ti-dp83867.h> diff --git a/drivers/net/phy/miiphybb.c b/drivers/net/phy/miiphybb.c index 24d617553e7..cf71f7d4e7e 100644 --- a/drivers/net/phy/miiphybb.c +++ b/drivers/net/phy/miiphybb.c @@ -18,10 +18,6 @@ #include <miiphy.h> #include <asm/global_data.h> -#define BB_MII_RELOCATE(v,off) (v += (v?off:0)) - -DECLARE_GLOBAL_DATA_PTR; - #ifndef CONFIG_BITBANGMII_MULTI /* @@ -110,21 +106,9 @@ int bb_miiphy_init(void) { int i; - for (i = 0; i < bb_miiphy_buses_num; i++) { -#if defined(CONFIG_NEEDS_MANUAL_RELOC) - /* Relocate the hook pointers*/ - BB_MII_RELOCATE(bb_miiphy_buses[i].init, gd->reloc_off); - BB_MII_RELOCATE(bb_miiphy_buses[i].mdio_active, gd->reloc_off); - BB_MII_RELOCATE(bb_miiphy_buses[i].mdio_tristate, gd->reloc_off); - BB_MII_RELOCATE(bb_miiphy_buses[i].set_mdio, gd->reloc_off); - BB_MII_RELOCATE(bb_miiphy_buses[i].get_mdio, gd->reloc_off); - BB_MII_RELOCATE(bb_miiphy_buses[i].set_mdc, gd->reloc_off); - BB_MII_RELOCATE(bb_miiphy_buses[i].delay, gd->reloc_off); -#endif - if (bb_miiphy_buses[i].init != NULL) { + for (i = 0; i < bb_miiphy_buses_num; i++) + if (bb_miiphy_buses[i].init != NULL) bb_miiphy_buses[i].init(&bb_miiphy_buses[i]); - } - } return 0; } diff --git a/drivers/net/phy/motorcomm.c b/drivers/net/phy/motorcomm.c index e822fd76f27..8635a960d6e 100644 --- a/drivers/net/phy/motorcomm.c +++ b/drivers/net/phy/motorcomm.c @@ -11,6 +11,7 @@ #include <phy.h> #include <linux/bitfield.h> +#define PHY_ID_YT8511 0x0000010a #define PHY_ID_YT8531 0x4f51e91b #define PHY_ID_MASK GENMASK(31, 0) @@ -26,6 +27,31 @@ #define YTPHY_DTS_OUTPUT_CLK_25M 25000000 #define YTPHY_DTS_OUTPUT_CLK_125M 125000000 +#define YT8511_EXT_CLK_GATE 0x0c +#define YT8511_EXT_DELAY_DRIVE 0x0d +#define YT8511_EXT_SLEEP_CTRL 0x27 + +/* 2b00 25m from pll + * 2b01 25m from xtl *default* + * 2b10 62.m from pll + * 2b11 125m from pll + */ +#define YT8511_CLK_125M (BIT(2) | BIT(1)) +#define YT8511_PLLON_SLP BIT(14) + +/* RX Delay enabled = 1.8ns 1000T, 8ns 10/100T */ +#define YT8511_DELAY_RX BIT(0) + +/* TX Gig-E Delay is bits 7:4, default 0x5 + * TX Fast-E Delay is bits 15:12, default 0xf + * Delay = 150ps * N - 250ps + * On = 2000ps, off = 50ps + */ +#define YT8511_DELAY_GE_TX_EN (0xf << 4) +#define YT8511_DELAY_GE_TX_DIS (0x2 << 4) +#define YT8511_DELAY_FE_TX_EN (0xf << 12) +#define YT8511_DELAY_FE_TX_DIS (0x2 << 12) + #define YT8531_SCR_SYNCE_ENABLE BIT(6) /* 1b0 output 25m clock *default* * 1b1 output 125m clock @@ -347,6 +373,58 @@ static void ytphy_dt_parse(struct phy_device *phydev) priv->flag |= TX_CLK_1000_INVERTED; } +static int yt8511_config(struct phy_device *phydev) +{ + u32 ge, fe; + int ret; + + ret = genphy_config_aneg(phydev); + if (ret < 0) + return ret; + + switch (phydev->interface) { + case PHY_INTERFACE_MODE_RGMII: + ge = YT8511_DELAY_GE_TX_DIS; + fe = YT8511_DELAY_FE_TX_DIS; + break; + case PHY_INTERFACE_MODE_RGMII_RXID: + ge = YT8511_DELAY_RX | YT8511_DELAY_GE_TX_DIS; + fe = YT8511_DELAY_FE_TX_DIS; + break; + case PHY_INTERFACE_MODE_RGMII_TXID: + ge = YT8511_DELAY_GE_TX_EN; + fe = YT8511_DELAY_FE_TX_EN; + break; + case PHY_INTERFACE_MODE_RGMII_ID: + ge = YT8511_DELAY_RX | YT8511_DELAY_GE_TX_EN; + fe = YT8511_DELAY_FE_TX_EN; + break; + default: /* do not support other modes */ + return -EOPNOTSUPP; + } + + ret = ytphy_modify_ext(phydev, YT8511_EXT_CLK_GATE, + (YT8511_DELAY_RX | YT8511_DELAY_GE_TX_EN), ge); + if (ret < 0) + return ret; + /* set clock mode to 125m */ + ret = ytphy_modify_ext(phydev, YT8511_EXT_CLK_GATE, + YT8511_CLK_125M, YT8511_CLK_125M); + if (ret < 0) + return ret; + ret = ytphy_modify_ext(phydev, YT8511_EXT_DELAY_DRIVE, + YT8511_DELAY_FE_TX_EN, fe); + if (ret < 0) + return ret; + /* sleep control, disable PLL in sleep for now */ + ret = ytphy_modify_ext(phydev, YT8511_EXT_SLEEP_CTRL, YT8511_PLLON_SLP, + 0); + if (ret < 0) + return ret; + + return 0; +} + static int yt8531_config(struct phy_device *phydev) { struct ytphy_plat_priv *priv = phydev->priv; @@ -425,6 +503,16 @@ static int yt8531_probe(struct phy_device *phydev) return 0; } +U_BOOT_PHY_DRIVER(motorcomm8511) = { + .name = "YT8511 Gigabit Ethernet", + .uid = PHY_ID_YT8511, + .mask = PHY_ID_MASK, + .features = PHY_GBIT_FEATURES, + .config = &yt8511_config, + .startup = &genphy_startup, + .shutdown = &genphy_shutdown, +}; + U_BOOT_PHY_DRIVER(motorcomm8531) = { .name = "YT8531 Gigabit Ethernet", .uid = PHY_ID_YT8531, diff --git a/drivers/net/phy/mscc.c b/drivers/net/phy/mscc.c index ef1761a8bda..bd9cd952975 100644 --- a/drivers/net/phy/mscc.c +++ b/drivers/net/phy/mscc.c @@ -15,6 +15,7 @@ #include <time.h> #include <linux/bitops.h> #include <linux/delay.h> +#include <linux/printk.h> /* Microsemi PHY ID's */ #define PHY_ID_VSC8530 0x00070560 diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index ae21acb059b..63b3e46f101 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -463,37 +463,6 @@ U_BOOT_PHY_DRIVER(genphy) = { .shutdown = genphy_shutdown, }; -#ifdef CONFIG_NEEDS_MANUAL_RELOC -int phy_init(void) -{ - const int ll_n_ents = ll_entry_count(struct phy_driver, phy_driver); - struct phy_driver *drv, *ll_entry; - - /* Perform manual relocation on linker list based PHY drivers */ - ll_entry = ll_entry_start(struct phy_driver, phy_driver); - for (drv = ll_entry; drv != ll_entry + ll_n_ents; drv++) { - if (drv->probe) - drv->probe += gd->reloc_off; - if (drv->config) - drv->config += gd->reloc_off; - if (drv->startup) - drv->startup += gd->reloc_off; - if (drv->shutdown) - drv->shutdown += gd->reloc_off; - if (drv->readext) - drv->readext += gd->reloc_off; - if (drv->writeext) - drv->writeext += gd->reloc_off; - if (drv->read_mmd) - drv->read_mmd += gd->reloc_off; - if (drv->write_mmd) - drv->write_mmd += gd->reloc_off; - } - - return 0; -} -#endif - int phy_set_supported(struct phy_device *phydev, u32 max_speed) { /* The default values for phydev->supported are provided by the PHY @@ -838,7 +807,10 @@ static struct phy_device *phy_connect_gmii2rgmii(struct mii_dev *bus, ofnode_for_each_subnode(node, dev_ofnode(dev)) { node = ofnode_by_compatible(node, "xlnx,gmii-to-rgmii-1.0"); if (ofnode_valid(node)) { - phydev = phy_device_create(bus, 0, + int gmiirgmii_phyaddr; + + gmiirgmii_phyaddr = ofnode_read_u32_default(node, "reg", 0); + phydev = phy_device_create(bus, gmiirgmii_phyaddr, PHY_GMII2RGMII_ID, false); if (phydev) phydev->node = node; diff --git a/drivers/net/rtl8169.c b/drivers/net/rtl8169.c index 963702777c2..93e83661cec 100644 --- a/drivers/net/rtl8169.c +++ b/drivers/net/rtl8169.c @@ -51,6 +51,7 @@ #include <asm/io.h> #include <pci.h> #include <linux/delay.h> +#include <linux/printk.h> #undef DEBUG_RTL8169 #undef DEBUG_RTL8169_TX diff --git a/drivers/net/sni_ave.c b/drivers/net/sni_ave.c index f5a0d80af7a..8eeecbc4cf3 100644 --- a/drivers/net/sni_ave.c +++ b/drivers/net/sni_ave.c @@ -23,6 +23,7 @@ #include <linux/err.h> #include <linux/io.h> #include <linux/iopoll.h> +#include <linux/printk.h> #define AVE_GRST_DELAY_MSEC 40 #define AVE_MIN_XMITSIZE 60 diff --git a/drivers/net/ti/am65-cpsw-nuss.c b/drivers/net/ti/am65-cpsw-nuss.c index 51a8167d14a..18a33c4c0e3 100644 --- a/drivers/net/ti/am65-cpsw-nuss.c +++ b/drivers/net/ti/am65-cpsw-nuss.c @@ -9,6 +9,7 @@ #include <common.h> #include <malloc.h> #include <asm/cache.h> +#include <asm/gpio.h> #include <asm/io.h> #include <asm/processor.h> #include <clk.h> @@ -26,6 +27,8 @@ #include <soc.h> #include <syscon.h> #include <linux/bitops.h> +#include <linux/delay.h> +#include <linux/printk.h> #include <linux/soc/ti/ti-udma.h> #include "cpsw_mdio.h" @@ -57,6 +60,12 @@ #define AM65_CPSW_PN_REG_SA_L 0x308 #define AM65_CPSW_PN_REG_SA_H 0x30c +#define AM65_CPSW_SGMII_CONTROL_REG 0x010 +#define AM65_CPSW_SGMII_MR_ADV_ABILITY_REG 0x018 +#define AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE BIT(0) + +#define ADVERTISE_SGMII 0x1 + #define AM65_CPSW_ALE_CTL_REG 0x8 #define AM65_CPSW_ALE_CTL_REG_ENABLE BIT(31) #define AM65_CPSW_ALE_CTL_REG_RESET_TBL BIT(30) @@ -90,8 +99,11 @@ #define AM65_CPSW_CPPI_PKT_TYPE 0x7 +#define DEFAULT_GPIO_RESET_DELAY 10 + struct am65_cpsw_port { fdt_addr_t port_base; + fdt_addr_t port_sgmii_base; fdt_addr_t macsl_base; bool disabled; u32 mac_control; @@ -113,6 +125,10 @@ struct am65_cpsw_common { struct mii_dev *bus; u32 bus_freq; + struct gpio_desc mdio_gpio_reset; + u32 reset_delay_us; + u32 reset_post_delay_us; + struct dma dma_tx; struct dma dma_rx; u32 rx_next; @@ -204,6 +220,8 @@ static int am65_cpsw_update_link(struct am65_cpsw_priv *priv) mac_control |= AM65_CPSW_MACSL_CTL_REG_FULL_DUPLEX; if (phy->speed == 100) mac_control |= AM65_CPSW_MACSL_CTL_REG_IFCTL_A; + if (phy->interface == PHY_INTERFACE_MODE_SGMII) + mac_control |= AM65_CPSW_MACSL_CTL_EXT_EN; } if (mac_control == port->mac_control) @@ -229,6 +247,7 @@ out: #define AM65_GMII_SEL_MODE_MII 0 #define AM65_GMII_SEL_MODE_RMII 1 #define AM65_GMII_SEL_MODE_RGMII 2 +#define AM65_GMII_SEL_MODE_SGMII 3 #define AM65_GMII_SEL_RGMII_IDMODE BIT(4) @@ -280,6 +299,10 @@ static int am65_cpsw_gmii_sel_k3(struct am65_cpsw_priv *priv, rgmii_id = true; break; + case PHY_INTERFACE_MODE_SGMII: + mode = AM65_GMII_SEL_MODE_SGMII; + break; + default: dev_warn(dev, "Unsupported PHY mode: %u. Defaulting to MII.\n", @@ -420,6 +443,13 @@ static int am65_cpsw_start(struct udevice *dev) goto err_dis_rx; } + if (priv->phydev->interface == PHY_INTERFACE_MODE_SGMII) { + writel(ADVERTISE_SGMII, + port->port_sgmii_base + AM65_CPSW_SGMII_MR_ADV_ABILITY_REG); + writel(AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE, + port->port_sgmii_base + AM65_CPSW_SGMII_CONTROL_REG); + } + ret = phy_startup(priv->phydev); if (ret) { dev_err(dev, "phy_startup failed\n"); @@ -658,6 +688,16 @@ static int am65_cpsw_mdio_init(struct udevice *dev) if (!priv->has_phy || cpsw_common->bus) return 0; + if (IS_ENABLED(CONFIG_DM_GPIO)) { + if (dm_gpio_is_valid(&cpsw_common->mdio_gpio_reset)) { + dm_gpio_set_value(&cpsw_common->mdio_gpio_reset, 1); + udelay(cpsw_common->reset_delay_us); + dm_gpio_set_value(&cpsw_common->mdio_gpio_reset, 0); + if (cpsw_common->reset_post_delay_us > 0) + udelay(cpsw_common->reset_post_delay_us); + } + } + ret = am65_cpsw_mdio_setup(dev); if (ret) return ret; @@ -797,7 +837,7 @@ out: static int am65_cpsw_probe_nuss(struct udevice *dev) { struct am65_cpsw_common *cpsw_common = dev_get_priv(dev); - ofnode ports_np, node; + ofnode ports_np, node, mdio_np; int ret, i; struct udevice *port_dev; @@ -824,6 +864,24 @@ static int am65_cpsw_probe_nuss(struct udevice *dev) AM65_CPSW_CPSW_NU_ALE_BASE; cpsw_common->mdio_base = cpsw_common->ss_base + AM65_CPSW_MDIO_BASE; + if (IS_ENABLED(CONFIG_DM_GPIO)) { + /* get bus level PHY reset GPIO details */ + mdio_np = dev_read_subnode(dev, "mdio"); + if (!ofnode_valid(mdio_np)) { + ret = -ENOENT; + goto out; + } + + cpsw_common->reset_delay_us = ofnode_read_u32_default(mdio_np, "reset-delay-us", + DEFAULT_GPIO_RESET_DELAY); + cpsw_common->reset_post_delay_us = ofnode_read_u32_default(mdio_np, + "reset-post-delay-us", + 0); + ret = gpio_request_by_name_nodev(mdio_np, "reset-gpios", 0, + &cpsw_common->mdio_gpio_reset, + GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE); + } + ports_np = dev_read_subnode(dev, "ethernet-ports"); if (!ofnode_valid(ports_np)) { ret = -ENOENT; @@ -872,6 +930,8 @@ static int am65_cpsw_probe_nuss(struct udevice *dev) port->port_base = cpsw_common->cpsw_base + AM65_CPSW_CPSW_NU_PORTS_OFFSET + (i * AM65_CPSW_CPSW_NU_PORTS_OFFSET); + port->port_sgmii_base = cpsw_common->ss_base + + (i * AM65_CPSW_SGMII_BASE); port->macsl_base = port->port_base + AM65_CPSW_CPSW_NU_PORT_MACSL_OFFSET; } diff --git a/drivers/net/ti/cpsw-common.c b/drivers/net/ti/cpsw-common.c index 3140f2515fb..d5428274d19 100644 --- a/drivers/net/ti/cpsw-common.c +++ b/drivers/net/ti/cpsw-common.c @@ -12,6 +12,7 @@ #include <asm/io.h> #include <cpsw.h> #include <dm/device_compat.h> +#include <linux/printk.h> DECLARE_GLOBAL_DATA_PTR; diff --git a/drivers/net/ti/cpsw.c b/drivers/net/ti/cpsw.c index 3a8cc9c52a5..877be7fca52 100644 --- a/drivers/net/ti/cpsw.c +++ b/drivers/net/ti/cpsw.c @@ -24,6 +24,7 @@ #include <phy.h> #include <asm/arch/cpu.h> #include <dm.h> +#include <linux/printk.h> #include "cpsw_mdio.h" diff --git a/drivers/net/ti/keystone_net.c b/drivers/net/ti/keystone_net.c index 89b04b6fbda..43dbf3f1067 100644 --- a/drivers/net/ti/keystone_net.c +++ b/drivers/net/ti/keystone_net.c @@ -10,6 +10,7 @@ #include <console.h> #include <asm/global_data.h> #include <linux/delay.h> +#include <linux/printk.h> #include <dm.h> #include <dm/lists.h> diff --git a/drivers/net/xilinx_axi_emac.c b/drivers/net/xilinx_axi_emac.c index 39cb3cc260b..54f22327684 100644 --- a/drivers/net/xilinx_axi_emac.c +++ b/drivers/net/xilinx_axi_emac.c @@ -112,7 +112,7 @@ struct axidma_plat { int pcsaddr; int phyaddr; u8 eth_hasnobuf; - int phy_of_handle; + ofnode phynode; enum emac_variant mactype; }; @@ -127,7 +127,7 @@ struct axidma_priv { struct phy_device *phydev; struct mii_dev *bus; u8 eth_hasnobuf; - int phy_of_handle; + ofnode phynode; enum emac_variant mactype; }; @@ -335,8 +335,8 @@ static int axiemac_phy_init(struct udevice *dev) phydev->supported &= supported; phydev->advertising = phydev->supported; priv->phydev = phydev; - if (priv->phy_of_handle) - priv->phydev->node = offset_to_ofnode(priv->phy_of_handle); + if (ofnode_valid(priv->phynode)) + priv->phydev->node = priv->phynode; phy_config(phydev); return 0; @@ -839,7 +839,7 @@ static int axi_emac_probe(struct udevice *dev) priv->eth_hasnobuf = plat->eth_hasnobuf; priv->pcsaddr = plat->pcsaddr; priv->phyaddr = plat->phyaddr; - priv->phy_of_handle = plat->phy_of_handle; + priv->phynode = plat->phynode; priv->interface = pdata->phy_interface; if (IS_ENABLED(CONFIG_DM_ETH_PHY)) @@ -894,20 +894,21 @@ static int axi_emac_of_to_plat(struct udevice *dev) { struct axidma_plat *plat = dev_get_plat(dev); struct eth_pdata *pdata = &plat->eth_pdata; - int node = dev_of_offset(dev); - int offset = 0; + struct ofnode_phandle_args pcs_node, axistream_node; + ofnode phynode; + int ret; pdata->iobase = dev_read_addr(dev); plat->mactype = dev_get_driver_data(dev); - offset = fdtdec_lookup_phandle(gd->fdt_blob, node, - "axistream-connected"); - if (offset <= 0) { + ret = dev_read_phandle_with_args(dev, "axistream-connected", NULL, 0, 0, + &axistream_node); + if (ret) { printf("%s: axistream is not found\n", __func__); return -EINVAL; } - plat->dmatx = (struct axidma_reg *)fdtdec_get_addr_size_auto_parent - (gd->fdt_blob, 0, offset, "reg", 0, NULL, false); + + plat->dmatx = (struct axidma_reg *)ofnode_get_addr(axistream_node.node); if (!plat->dmatx) { printf("%s: axi_dma register space not found\n", __func__); return -EINVAL; @@ -918,30 +919,27 @@ static int axi_emac_of_to_plat(struct udevice *dev) /* PHYAD 0 always redirects to the PCS/PMA PHY */ plat->pcsaddr = 0; - offset = fdtdec_lookup_phandle(gd->fdt_blob, node, - "phy-handle"); - if (offset > 0) { + phynode = dev_get_phy_node(dev); + if (ofnode_valid(phynode)) { if (!(IS_ENABLED(CONFIG_DM_ETH_PHY))) - plat->phyaddr = fdtdec_get_int(gd->fdt_blob, - offset, - "reg", -1); - plat->phy_of_handle = offset; + plat->phyaddr = ofnode_read_u32_default(phynode, + "reg", -1); + plat->phynode = phynode; } pdata->phy_interface = dev_read_phy_mode(dev); if (pdata->phy_interface == PHY_INTERFACE_MODE_NA) return -EINVAL; - plat->eth_hasnobuf = fdtdec_get_bool(gd->fdt_blob, node, - "xlnx,eth-hasnobuf"); + plat->eth_hasnobuf = dev_read_bool(dev, "xlnx,eth-hasnobuf"); if (pdata->phy_interface == PHY_INTERFACE_MODE_SGMII || pdata->phy_interface == PHY_INTERFACE_MODE_1000BASEX) { - offset = fdtdec_lookup_phandle(gd->fdt_blob, node, - "pcs-handle"); - if (offset > 0) { - plat->pcsaddr = fdtdec_get_int(gd->fdt_blob, - offset, "reg", -1); + ret = dev_read_phandle_with_args(dev, "pcs-handle", NULL, 0, 0, + &pcs_node); + if (!ret) { + plat->pcsaddr = ofnode_read_u32_default(pcs_node.node, + "reg", -1); } } } diff --git a/drivers/net/zynq_gem.c b/drivers/net/zynq_gem.c index f3cdfb0275d..3377e669f2f 100644 --- a/drivers/net/zynq_gem.c +++ b/drivers/net/zynq_gem.c @@ -890,7 +890,8 @@ static int zynq_gem_probe(struct udevice *dev) if (ret) goto err3; - if (priv->interface == PHY_INTERFACE_MODE_SGMII && phy.dev) { + if (priv->interface == PHY_INTERFACE_MODE_SGMII && + generic_phy_valid(&phy)) { if (IS_ENABLED(CONFIG_DM_ETH_PHY)) { if (device_is_compatible(dev, "cdns,zynqmp-gem") || device_is_compatible(dev, "xlnx,zynqmp-gem")) { diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig index a0bf44d38a9..463ec47eb92 100644 --- a/drivers/pci/Kconfig +++ b/drivers/pci/Kconfig @@ -121,11 +121,18 @@ config PCIE_APPLE bool "Enable Apple PCIe driver" depends on ARCH_APPLE imply PCI_INIT_R + select SYS_PCI_64BIT default y help Say Y here if you want to enable PCIe controller support on Apple SoCs. +config PCI_FTPCI100 + bool "Enable Faraday FTPCI100 PCI Bridge Controller driver" + help + Say Y here if you want to enable Faraday FTPCI100 PCI. + FTPCI100 IP is used in SoC chip designs. + config PCI_GT64120 bool "GT64120 PCI support" depends on MIPS diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile index a712a317a39..72ef8b4bc77 100644 --- a/drivers/pci/Makefile +++ b/drivers/pci/Makefile @@ -14,6 +14,7 @@ obj-$(CONFIG_PCI) += pci_auto_common.o pci_common.o obj-$(CONFIG_PCIE_ECAM_GENERIC) += pcie_ecam_generic.o obj-$(CONFIG_PCIE_ECAM_SYNQUACER) += pcie_ecam_synquacer.o obj-$(CONFIG_PCIE_APPLE) += pcie_apple.o +obj-$(CONFIG_PCI_FTPCI100) += pci_ftpci100.o obj-$(CONFIG_PCI_GT64120) += pci_gt64120.o obj-$(CONFIG_PCI_MPC85XX) += pci_mpc85xx.o obj-$(CONFIG_PCI_MSC01) += pci_msc01.o diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c index 632c1a63cfc..ae7350aaff9 100644 --- a/drivers/pci/pci-uclass.c +++ b/drivers/pci/pci-uclass.c @@ -24,6 +24,7 @@ #endif #include <dt-bindings/pci/pci.h> #include <linux/delay.h> +#include <linux/printk.h> #include "pci_internal.h" DECLARE_GLOBAL_DATA_PTR; @@ -541,14 +542,13 @@ int pci_auto_config_devices(struct udevice *bus) struct pci_child_plat *pplat; unsigned int sub_bus; struct udevice *dev; - int ret; sub_bus = dev_seq(bus); debug("%s: start\n", __func__); pciauto_config_init(hose); - for (ret = device_find_first_child(bus, &dev); - !ret && dev; - ret = device_find_next_child(&dev)) { + for (device_find_first_child(bus, &dev); + dev; + device_find_next_child(&dev)) { unsigned int max_bus; int ret; @@ -1446,7 +1446,7 @@ phys_addr_t dm_pci_bus_to_phys(struct udevice *dev, pci_addr_t bus_addr, return res->phys_start + offset; } - puts("pci_hose_bus_to_phys: invalid physical address\n"); + puts("dm_pci_bus_to_phys: invalid physical address\n"); return 0; } @@ -1486,7 +1486,7 @@ pci_addr_t dm_pci_phys_to_bus(struct udevice *dev, phys_addr_t phys_addr, return res->bus_start + offset; } - puts("pci_hose_phys_to_bus: invalid physical address\n"); + puts("dm_pci_phys_to_bus: invalid physical address\n"); return 0; } diff --git a/drivers/pci/pci_ftpci100.c b/drivers/pci/pci_ftpci100.c new file mode 100644 index 00000000000..a1775445005 --- /dev/null +++ b/drivers/pci/pci_ftpci100.c @@ -0,0 +1,95 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include <common.h> +#include <pci.h> +#include <dm.h> +#include <asm/io.h> + +struct ftpci100_data { + void *reg_base; +}; + +/* AHB Control Registers */ +struct ftpci100_ahbc { + u32 iosize; /* 0x00 - I/O Space Size Signal */ + u32 prot; /* 0x04 - AHB Protection */ + u32 rsved[8]; /* 0x08-0x24 - Reserved */ + u32 conf; /* 0x28 - PCI Configuration */ + u32 data; /* 0x2c - PCI Configuration DATA */ +}; + +static int ftpci100_read_config(const struct udevice *dev, pci_dev_t bdf, + uint offset, ulong *valuep, + enum pci_size_t size) +{ + struct ftpci100_data *priv = dev_get_priv(dev); + struct ftpci100_ahbc *regs = priv->reg_base; + u32 data; + + out_le32(®s->conf, PCI_CONF1_ADDRESS(PCI_BUS(bdf), PCI_DEV(bdf), PCI_FUNC(bdf), offset)); + data = in_le32(®s->data); + *valuep = pci_conv_32_to_size(data, offset, size); + + return 0; +} + +static int ftpci100_write_config(struct udevice *dev, pci_dev_t bdf, + uint offset, ulong value, + enum pci_size_t size) +{ + struct ftpci100_data *priv = dev_get_priv(dev); + struct ftpci100_ahbc *regs = priv->reg_base; + u32 data; + + out_le32(®s->conf, PCI_CONF1_ADDRESS(PCI_BUS(bdf), PCI_DEV(bdf), PCI_FUNC(bdf), offset)); + + if (size == PCI_SIZE_32) { + data = value; + } else { + u32 old = in_le32(®s->data); + + data = pci_conv_size_to_32(old, value, offset, size); + } + + out_le32(®s->data, data); + + return 0; +} + +static int ftpci100_probe(struct udevice *dev) +{ + struct ftpci100_data *priv = dev_get_priv(dev); + struct pci_region *io, *mem; + int count; + + count = pci_get_regions(dev, &io, &mem, NULL); + if (count != 2) { + printf("%s: wrong count of regions: %d != 2\n", dev->name, count); + return -EINVAL; + } + + priv->reg_base = phys_to_virt(io->phys_start); + if (!priv->reg_base) + return -EINVAL; + + return 0; +} + +static const struct dm_pci_ops ftpci100_ops = { + .read_config = ftpci100_read_config, + .write_config = ftpci100_write_config, +}; + +static const struct udevice_id ftpci100_ids[] = { + { .compatible = "faraday,ftpci100" }, + { } +}; + +U_BOOT_DRIVER(ftpci100_pci) = { + .name = "ftpci100_pci", + .id = UCLASS_PCI, + .of_match = ftpci100_ids, + .ops = &ftpci100_ops, + .probe = ftpci100_probe, + .priv_auto = sizeof(struct ftpci100_data), +}; diff --git a/drivers/pci/pci_mvebu.c b/drivers/pci/pci_mvebu.c index 93a7508d8a2..3697cd8d652 100644 --- a/drivers/pci/pci_mvebu.c +++ b/drivers/pci/pci_mvebu.c @@ -28,6 +28,7 @@ #include <linux/errno.h> #include <linux/ioport.h> #include <linux/mbus.h> +#include <linux/printk.h> #include <linux/sizes.h> /* PCIe unit register offsets */ diff --git a/drivers/pci/pci_tegra.c b/drivers/pci/pci_tegra.c index 29d54117e93..131c21b7684 100644 --- a/drivers/pci/pci_tegra.c +++ b/drivers/pci/pci_tegra.c @@ -22,6 +22,7 @@ #include <power-domain.h> #include <reset.h> #include <linux/delay.h> +#include <linux/printk.h> #include <asm/io.h> #include <asm/gpio.h> diff --git a/drivers/pci/pcie_brcmstb.c b/drivers/pci/pcie_brcmstb.c index 1de28021138..cd45f0bee9b 100644 --- a/drivers/pci/pcie_brcmstb.c +++ b/drivers/pci/pcie_brcmstb.c @@ -33,6 +33,9 @@ #define PCIE_RC_CFG_PRIV1_ID_VAL3 0x043c #define CFG_PRIV1_ID_VAL3_CLASS_CODE_MASK 0xffffff +#define PCIE_RC_CFG_PRIV1_LINK_CAPABILITY 0x04dc +#define PCIE_RC_CFG_PRIV1_LINK_CAPABILITY_ASPM_SUPPORT_MASK 0xc00 + #define PCIE_RC_DL_MDIO_ADDR 0x1100 #define PCIE_RC_DL_MDIO_WR_DATA 0x1104 #define PCIE_RC_DL_MDIO_RD_DATA 0x1108 @@ -88,7 +91,6 @@ PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LIMIT_HI + ((win) * 8) #define PCIE_MISC_HARD_PCIE_HARD_DEBUG 0x4204 -#define PCIE_HARD_DEBUG_CLKREQ_DEBUG_ENABLE_MASK 0x2 #define PCIE_HARD_DEBUG_SERDES_IDDQ_MASK 0x08000000 #define PCIE_MSI_INTR2_CLR 0x4508 @@ -223,6 +225,10 @@ static int brcm_pcie_config_address(const struct udevice *dev, pci_dev_t bdf, return 0; } + /* An access to our HW w/o link-up will cause a CPU Abort */ + if (!brcm_pcie_link_up(pcie)) + return -EINVAL; + /* For devices, write to the config space index register */ idx = PCIE_ECAM_OFFSET(pci_bus, pci_dev, pci_func, 0); @@ -505,6 +511,12 @@ static int brcm_pcie_probe(struct udevice *dev) clrbits_le32(pcie->base + PCIE_RGR1_SW_INIT_1, RGR1_SW_INIT_1_PERST_MASK); + /* + * Wait for 100ms after PERST# deassertion; see PCIe CEM specification + * sections 2.2, PCIe r5.0, 6.6.1. + */ + mdelay(100); + /* Give the RC/EP time to wake up, before trying to configure RC. * Intermittently check status for link-up, up to a total of 100ms. */ @@ -562,12 +574,18 @@ static int brcm_pcie_probe(struct udevice *dev) clrsetbits_le32(base + PCIE_RC_CFG_VENDOR_SPECIFIC_REG1, VENDOR_SPECIFIC_REG1_ENDIAN_MODE_BAR2_MASK, VENDOR_SPECIFIC_REG1_LITTLE_ENDIAN); + /* - * Refclk from RC should be gated with CLKREQ# input when ASPM L0s,L1 - * is enabled => setting the CLKREQ_DEBUG_ENABLE field to 1. + * We used to enable the CLKREQ# input here, but a few PCIe cards don't + * attach anything to the CLKREQ# line, so we shouldn't assume that + * it's connected and working. The controller does allow detecting + * whether the port on the other side of our link is/was driving this + * signal, so we could check before we assume. But because this signal + * is for power management, which doesn't make sense in a bootloader, + * let's instead just unadvertise ASPM support. */ - setbits_le32(base + PCIE_MISC_HARD_PCIE_HARD_DEBUG, - PCIE_HARD_DEBUG_CLKREQ_DEBUG_ENABLE_MASK); + clrbits_le32(base + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY, + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY_ASPM_SUPPORT_MASK); return 0; } diff --git a/drivers/pci/pcie_ecam_generic.c b/drivers/pci/pcie_ecam_generic.c index 1a9f9aec2ee..2e089b0e033 100644 --- a/drivers/pci/pcie_ecam_generic.c +++ b/drivers/pci/pcie_ecam_generic.c @@ -11,6 +11,7 @@ #include <dm.h> #include <pci.h> #include <asm/global_data.h> +#include <linux/printk.h> #include <asm/io.h> diff --git a/drivers/pci/pcie_fsl.c b/drivers/pci/pcie_fsl.c index 8d89a1e5919..ec917ee7d5b 100644 --- a/drivers/pci/pcie_fsl.c +++ b/drivers/pci/pcie_fsl.c @@ -16,6 +16,7 @@ #include <asm/global_data.h> #include <asm/io.h> #include <linux/delay.h> +#include <linux/printk.h> #include "pcie_fsl.h" #include <dm/device_compat.h> diff --git a/drivers/pci/pcie_mediatek.c b/drivers/pci/pcie_mediatek.c index c6e30e24622..ed25a10bcf0 100644 --- a/drivers/pci/pcie_mediatek.c +++ b/drivers/pci/pcie_mediatek.c @@ -20,6 +20,7 @@ #include <linux/bitops.h> #include <linux/iopoll.h> #include <linux/list.h> +#include <linux/printk.h> #include "pci_internal.h" /* PCIe shared registers */ diff --git a/drivers/pci/pcie_phytium.c b/drivers/pci/pcie_phytium.c index a8072762542..3bd1f5cd6d9 100644 --- a/drivers/pci/pcie_phytium.c +++ b/drivers/pci/pcie_phytium.c @@ -12,6 +12,7 @@ #include <pci.h> #include <asm/global_data.h> #include <asm/io.h> +#include <linux/printk.h> /** * struct phytium_pcie - phytium PCIe controller state diff --git a/drivers/pci/pcie_xilinx.c b/drivers/pci/pcie_xilinx.c index eb9ec97b74f..53fd121e905 100644 --- a/drivers/pci/pcie_xilinx.c +++ b/drivers/pci/pcie_xilinx.c @@ -10,6 +10,7 @@ #include <pci.h> #include <asm/global_data.h> #include <linux/bitops.h> +#include <linux/printk.h> #include <asm/io.h> diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 7a2d54f71d2..8ac5769ed9a 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -70,6 +70,16 @@ config AB8500_USB_PHY help Support for the USB OTG PHY in ST-Ericsson AB8500. +config APPLE_ATCPHY + bool "Apple Type-C PHY Driver" + depends on PHY && ARCH_APPLE + default y + help + Support for the Apple Type-C PHY. + + This is a dummy driver since the PHY is initialized + sufficiently by previous stage firmware. + config BCM6318_USBH_PHY bool "BCM6318 USBH PHY support" depends on PHY && ARCH_BMIPS diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index aca365d219c..5d4de86e71a 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -12,6 +12,7 @@ obj-$(CONFIG_$(SPL_)PHY) += phy-uclass.o obj-$(CONFIG_$(SPL_)NOP_PHY) += nop-phy.o obj-$(CONFIG_MIPI_DPHY_HELPERS) += phy-core-mipi-dphy.o obj-$(CONFIG_AB8500_USB_PHY) += phy-ab8500-usb.o +obj-$(CONFIG_APPLE_ATCPHY) += phy-apple-atc.o obj-$(CONFIG_BCM6318_USBH_PHY) += bcm6318-usbh-phy.o obj-$(CONFIG_BCM6348_USBH_PHY) += bcm6348-usbh-phy.o obj-$(CONFIG_BCM6358_USBH_PHY) += bcm6358-usbh-phy.o diff --git a/drivers/phy/keystone-usb-phy.c b/drivers/phy/keystone-usb-phy.c index 12f8a265f77..6799e232370 100644 --- a/drivers/phy/keystone-usb-phy.c +++ b/drivers/phy/keystone-usb-phy.c @@ -13,6 +13,7 @@ #include <asm/arch/psc_defs.h> #include <linux/bitops.h> #include <linux/delay.h> +#include <linux/printk.h> /* USB PHY control register offsets */ #define USB_PHY_CTL_UTMI 0x0000 diff --git a/drivers/phy/marvell/comphy_cp110.c b/drivers/phy/marvell/comphy_cp110.c index a7e0099045f..bb15fbaf347 100644 --- a/drivers/phy/marvell/comphy_cp110.c +++ b/drivers/phy/marvell/comphy_cp110.c @@ -12,6 +12,7 @@ #include <asm/arch/cpu.h> #include <asm/arch/soc.h> #include <linux/delay.h> +#include <linux/printk.h> #include "comphy_core.h" #include "sata.h" diff --git a/drivers/phy/meson-g12a-usb2.c b/drivers/phy/meson-g12a-usb2.c index 650b88bd180..8b243225156 100644 --- a/drivers/phy/meson-g12a-usb2.c +++ b/drivers/phy/meson-g12a-usb2.c @@ -17,6 +17,7 @@ #include <generic-phy.h> #include <regmap.h> #include <linux/delay.h> +#include <linux/printk.h> #include <power/regulator.h> #include <reset.h> #include <clk.h> diff --git a/drivers/phy/meson-g12a-usb3-pcie.c b/drivers/phy/meson-g12a-usb3-pcie.c index 8f72b5a6a74..40a5da948dc 100644 --- a/drivers/phy/meson-g12a-usb3-pcie.c +++ b/drivers/phy/meson-g12a-usb3-pcie.c @@ -18,6 +18,7 @@ #include <bitfield.h> #include <generic-phy.h> #include <linux/delay.h> +#include <linux/printk.h> #include <linux/bitops.h> #include <linux/compat.h> diff --git a/drivers/phy/meson-gxbb-usb2.c b/drivers/phy/meson-gxbb-usb2.c index 70a80b86381..725b056a71a 100644 --- a/drivers/phy/meson-gxbb-usb2.c +++ b/drivers/phy/meson-gxbb-usb2.c @@ -15,6 +15,7 @@ #include <regmap.h> #include <reset.h> #include <linux/bitops.h> +#include <linux/printk.h> #define REG_CONFIG 0x00 #define REG_CONFIG_CLK_EN BIT(0) diff --git a/drivers/phy/meson-gxl-usb2.c b/drivers/phy/meson-gxl-usb2.c index 4c631310efa..8f5e4a43661 100644 --- a/drivers/phy/meson-gxl-usb2.c +++ b/drivers/phy/meson-gxl-usb2.c @@ -11,12 +11,13 @@ #include <malloc.h> #include <asm/io.h> #include <bitfield.h> +#include <clk.h> #include <dm.h> #include <errno.h> #include <generic-phy.h> #include <regmap.h> #include <linux/delay.h> -#include <clk.h> +#include <linux/printk.h> #include <linux/usb/otg.h> #include <asm/arch/usb-gx.h> diff --git a/drivers/phy/phy-apple-atc.c b/drivers/phy/phy-apple-atc.c new file mode 100644 index 00000000000..15c5b8a1c2d --- /dev/null +++ b/drivers/phy/phy-apple-atc.c @@ -0,0 +1,56 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2022 Mark Kettenis <[email protected]> + */ + +#include <common.h> +#include <dm.h> +#include <dm/device-internal.h> +#include <generic-phy.h> +#include <reset-uclass.h> + +static const struct phy_ops apple_atcphy_ops = { +}; + +static struct driver apple_atcphy_driver = { + .name = "apple-atcphy", + .id = UCLASS_PHY, + .ops = &apple_atcphy_ops, +}; + +static int apple_atcphy_reset_of_xlate(struct reset_ctl *reset_ctl, + struct ofnode_phandle_args *args) +{ + if (args->args_count != 0) + return -EINVAL; + + return 0; +} + +static const struct reset_ops apple_atcphy_reset_ops = { + .of_xlate = apple_atcphy_reset_of_xlate, +}; + +static int apple_atcphy_reset_probe(struct udevice *dev) +{ + struct udevice *child; + + device_bind(dev, &apple_atcphy_driver, "apple-atcphy", NULL, + dev_ofnode(dev), &child); + + return 0; +} + +static const struct udevice_id apple_atcphy_ids[] = { + { .compatible = "apple,t6000-atcphy" }, + { .compatible = "apple,t8103-atcphy" }, + { } +}; + +U_BOOT_DRIVER(apple_atcphy_reset) = { + .name = "apple-atcphy-reset", + .id = UCLASS_RESET, + .of_match = apple_atcphy_ids, + .ops = &apple_atcphy_reset_ops, + .probe = apple_atcphy_reset_probe, +}; diff --git a/drivers/phy/phy-rcar-gen3.c b/drivers/phy/phy-rcar-gen3.c index 8c59631428b..7159e7e8716 100644 --- a/drivers/phy/phy-rcar-gen3.c +++ b/drivers/phy/phy-rcar-gen3.c @@ -17,6 +17,7 @@ #include <usb.h> #include <asm/io.h> #include <linux/bitops.h> +#include <linux/printk.h> #include <power/regulator.h> /* USB2.0 Host registers (original offset is +0x200) */ diff --git a/drivers/phy/phy-stm32-usbphyc.c b/drivers/phy/phy-stm32-usbphyc.c index 15bd60ca8c5..000e495dbd4 100644 --- a/drivers/phy/phy-stm32-usbphyc.c +++ b/drivers/phy/phy-stm32-usbphyc.c @@ -23,6 +23,7 @@ #include <linux/bitfield.h> #include <linux/bitops.h> #include <linux/delay.h> +#include <linux/printk.h> #include <power/regulator.h> /* USBPHYC registers */ diff --git a/drivers/phy/phy-uclass.c b/drivers/phy/phy-uclass.c index 629ef3aa3de..22f2fe91487 100644 --- a/drivers/phy/phy-uclass.c +++ b/drivers/phy/phy-uclass.c @@ -12,6 +12,7 @@ #include <dm/devres.h> #include <generic-phy.h> #include <linux/list.h> +#include <linux/printk.h> #include <power/regulator.h> /** @@ -195,6 +196,7 @@ int generic_phy_get_by_index_nodev(ofnode node, int index, struct phy *phy) return 0; err: + phy->dev = NULL; return ret; } @@ -211,6 +213,9 @@ int generic_phy_get_by_name(struct udevice *dev, const char *phy_name, debug("%s(dev=%p, name=%s, phy=%p)\n", __func__, dev, phy_name, phy); + assert(phy); + phy->dev = NULL; + index = dev_read_stringlist_search(dev, "phy-names", phy_name); if (index < 0) { debug("dev_read_stringlist_search() failed: %d\n", index); @@ -506,44 +511,35 @@ int generic_phy_power_off_bulk(struct phy_bulk *bulk) int generic_setup_phy(struct udevice *dev, struct phy *phy, int index) { - int ret = 0; - - if (!phy) - return 0; + int ret; ret = generic_phy_get_by_index(dev, index, phy); - if (ret) { - if (ret != -ENOENT) - return ret; - } else { - ret = generic_phy_init(phy); - if (ret) - return ret; + if (ret) + return ret == -ENOENT ? 0 : ret; - ret = generic_phy_power_on(phy); - if (ret) - ret = generic_phy_exit(phy); - } + ret = generic_phy_init(phy); + if (ret) + return ret; + + ret = generic_phy_power_on(phy); + if (ret) + generic_phy_exit(phy); return ret; } int generic_shutdown_phy(struct phy *phy) { - int ret = 0; + int ret; - if (!phy) + if (!generic_phy_valid(phy)) return 0; - if (generic_phy_valid(phy)) { - ret = generic_phy_power_off(phy); - if (ret) - return ret; - - ret = generic_phy_exit(phy); - } + ret = generic_phy_power_off(phy); + if (ret) + return ret; - return ret; + return generic_phy_exit(phy); } UCLASS_DRIVER(phy) = { diff --git a/drivers/phy/sti_usb_phy.c b/drivers/phy/sti_usb_phy.c index ce4caafce7e..9e5ac9bfde6 100644 --- a/drivers/phy/sti_usb_phy.c +++ b/drivers/phy/sti_usb_phy.c @@ -18,6 +18,7 @@ #include <reset-uclass.h> #include <syscon.h> #include <wait_bit.h> +#include <linux/printk.h> #include <linux/bitops.h> #include <linux/compat.h> diff --git a/drivers/phy/ti-pipe3-phy.c b/drivers/phy/ti-pipe3-phy.c index b5b3c3f1522..313735844ab 100644 --- a/drivers/phy/ti-pipe3-phy.c +++ b/drivers/phy/ti-pipe3-phy.c @@ -16,6 +16,7 @@ #include <linux/bitops.h> #include <linux/delay.h> #include <linux/err.h> +#include <linux/printk.h> /* PLLCTRL Registers */ #define PLL_STATUS 0x00000004 diff --git a/drivers/phy/ti/phy-j721e-wiz.c b/drivers/phy/ti/phy-j721e-wiz.c index 34314d0bd1e..72613399073 100644 --- a/drivers/phy/ti/phy-j721e-wiz.c +++ b/drivers/phy/ti/phy-j721e-wiz.c @@ -585,12 +585,20 @@ static int wiz_reset_assert(struct reset_ctl *reset_ctl) static int wiz_phy_fullrt_div(struct wiz *wiz, int lane) { - if (wiz->type != AM64_WIZ_10G) - return 0; - - if (wiz->lane_phy_type[lane] == PHY_TYPE_PCIE) - return regmap_field_write(wiz->p0_fullrt_div[lane], 0x1); + switch (wiz->type) { + case AM64_WIZ_10G: + if (wiz->lane_phy_type[lane] == PHY_TYPE_PCIE) + return regmap_field_write(wiz->p0_fullrt_div[lane], 0x1); + break; + case J721E_WIZ_16G: + case J721E_WIZ_10G: + if (wiz->lane_phy_type[lane] == PHY_TYPE_SGMII) + return regmap_field_write(wiz->p0_fullrt_div[lane], 0x2); + break; + default: + return 0; + } return 0; } @@ -706,7 +714,8 @@ static int wiz_p_mac_div_sel(struct wiz *wiz) int i; for (i = 0; i < num_lanes; i++) { - if (wiz->lane_phy_type[i] == PHY_TYPE_QSGMII) { + if (wiz->lane_phy_type[i] == PHY_TYPE_SGMII || + wiz->lane_phy_type[i] == PHY_TYPE_QSGMII) { ret = regmap_field_write(wiz->p_mac_div_sel0[i], 1); if (ret) return ret; diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c index 1be6252227d..e834dddfd13 100644 --- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c +++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c @@ -35,6 +35,7 @@ #include <asm/io.h> #include <linux/bitops.h> #include <linux/libfdt.h> +#include <linux/printk.h> DECLARE_GLOBAL_DATA_PTR; diff --git a/drivers/pinctrl/pinctrl-sti.c b/drivers/pinctrl/pinctrl-sti.c index 20cdbb0702e..1ff7ea00555 100644 --- a/drivers/pinctrl/pinctrl-sti.c +++ b/drivers/pinctrl/pinctrl-sti.c @@ -17,6 +17,7 @@ #include <dm/pinctrl.h> #include <linux/bug.h> #include <linux/libfdt.h> +#include <linux/printk.h> DECLARE_GLOBAL_DATA_PTR; diff --git a/drivers/pinctrl/pinctrl-zynqmp.c b/drivers/pinctrl/pinctrl-zynqmp.c index 02626a7561e..517035961da 100644 --- a/drivers/pinctrl/pinctrl-zynqmp.c +++ b/drivers/pinctrl/pinctrl-zynqmp.c @@ -158,6 +158,12 @@ static int zynqmp_pm_pinctrl_set_config(const u32 pin, const u32 param, u32 valu { int ret; + if (param == PM_PINCTRL_CONFIG_TRI_STATE) { + ret = zynqmp_pm_feature(PM_PINCTRL_CONFIG_PARAM_SET); + if (ret < PM_PINCTRL_PARAM_SET_VERSION) + return -EOPNOTSUPP; + } + /* Request the pin first */ ret = xilinx_pm_request(PM_PINCTRL_REQUEST, pin, 0, 0, 0, NULL); if (ret) { @@ -467,6 +473,10 @@ static int zynqmp_pinconf_set(struct udevice *dev, unsigned int pin, pin); break; case PIN_CONFIG_BIAS_HIGH_IMPEDANCE: + param = PM_PINCTRL_CONFIG_TRI_STATE; + arg = PM_PINCTRL_TRI_STATE_ENABLE; + ret = zynqmp_pm_pinctrl_set_config(pin, param, arg); + break; case PIN_CONFIG_LOW_POWER_MODE: /* * This cases are mentioned in dts but configurable @@ -475,6 +485,11 @@ static int zynqmp_pinconf_set(struct udevice *dev, unsigned int pin, */ ret = 0; break; + case PIN_CONFIG_OUTPUT_ENABLE: + param = PM_PINCTRL_CONFIG_TRI_STATE; + arg = PM_PINCTRL_TRI_STATE_DISABLE; + ret = zynqmp_pm_pinctrl_set_config(pin, param, arg); + break; default: dev_warn(dev, "unsupported configuration parameter '%u'\n", param); diff --git a/drivers/pinctrl/pinctrl_stm32.c b/drivers/pinctrl/pinctrl_stm32.c index b06da50b2cd..8bb7588714a 100644 --- a/drivers/pinctrl/pinctrl_stm32.c +++ b/drivers/pinctrl/pinctrl_stm32.c @@ -18,6 +18,7 @@ #include <linux/bitops.h> #include <linux/err.h> #include <linux/libfdt.h> +#include <linux/printk.h> #include "../gpio/stm32_gpio_priv.h" diff --git a/drivers/power/palmas.c b/drivers/power/palmas.c index 0959445364e..3ac97123401 100644 --- a/drivers/power/palmas.c +++ b/drivers/power/palmas.c @@ -5,6 +5,7 @@ */ #include <config.h> #include <palmas.h> +#include <linux/printk.h> void palmas_init_settings(void) { diff --git a/drivers/power/pmic/as3722.c b/drivers/power/pmic/as3722.c index 3aa3cce945e..c7dd9705d18 100644 --- a/drivers/power/pmic/as3722.c +++ b/drivers/power/pmic/as3722.c @@ -12,6 +12,7 @@ #include <i2c.h> #include <log.h> #include <dm/lists.h> +#include <linux/printk.h> #include <power/as3722.h> #include <power/pmic.h> diff --git a/drivers/power/pmic/as3722_gpio.c b/drivers/power/pmic/as3722_gpio.c index 96943bc1ad5..987fbdf9bc0 100644 --- a/drivers/power/pmic/as3722_gpio.c +++ b/drivers/power/pmic/as3722_gpio.c @@ -6,6 +6,7 @@ #include <common.h> #include <dm.h> #include <asm/gpio.h> +#include <linux/printk.h> #include <power/as3722.h> #include <power/pmic.h> diff --git a/drivers/power/pmic/bd71837.c b/drivers/power/pmic/bd71837.c index fdbbd6f5593..ee6ae78e5c4 100644 --- a/drivers/power/pmic/bd71837.c +++ b/drivers/power/pmic/bd71837.c @@ -9,6 +9,7 @@ #include <i2c.h> #include <log.h> #include <asm/global_data.h> +#include <linux/printk.h> #include <power/pmic.h> #include <power/regulator.h> #include <power/bd71837.h> diff --git a/drivers/power/pmic/da9063.c b/drivers/power/pmic/da9063.c index 25101d18f74..ca95b82e6d0 100644 --- a/drivers/power/pmic/da9063.c +++ b/drivers/power/pmic/da9063.c @@ -10,6 +10,7 @@ #include <dm.h> #include <i2c.h> #include <log.h> +#include <linux/printk.h> #include <power/pmic.h> #include <power/regulator.h> #include <power/da9063_pmic.h> diff --git a/drivers/power/pmic/fan53555.c b/drivers/power/pmic/fan53555.c index 0d91628f572..d556b9a5878 100644 --- a/drivers/power/pmic/fan53555.c +++ b/drivers/power/pmic/fan53555.c @@ -10,6 +10,7 @@ #include <dm/device_compat.h> #include <dm/lists.h> #include <i2c.h> +#include <linux/printk.h> #include <power/fan53555.h> #include <power/pmic.h> #include <power/regulator.h> diff --git a/drivers/power/pmic/i2c_pmic_emul.c b/drivers/power/pmic/i2c_pmic_emul.c index abe3a1051f1..f0a03742f87 100644 --- a/drivers/power/pmic/i2c_pmic_emul.c +++ b/drivers/power/pmic/i2c_pmic_emul.c @@ -10,6 +10,7 @@ #include <i2c.h> #include <log.h> #include <malloc.h> +#include <linux/printk.h> #include <power/pmic.h> #include <power/sandbox_pmic.h> diff --git a/drivers/power/pmic/lp873x.c b/drivers/power/pmic/lp873x.c index 2b1260ec6b1..fda5bc15164 100644 --- a/drivers/power/pmic/lp873x.c +++ b/drivers/power/pmic/lp873x.c @@ -10,6 +10,7 @@ #include <dm.h> #include <i2c.h> #include <log.h> +#include <linux/printk.h> #include <power/pmic.h> #include <power/regulator.h> #include <power/lp873x.h> diff --git a/drivers/power/pmic/lp87565.c b/drivers/power/pmic/lp87565.c index f4a4bd03d70..904e02c4d81 100644 --- a/drivers/power/pmic/lp87565.c +++ b/drivers/power/pmic/lp87565.c @@ -10,6 +10,7 @@ #include <dm.h> #include <i2c.h> #include <log.h> +#include <linux/printk.h> #include <power/pmic.h> #include <power/regulator.h> #include <power/lp87565.h> diff --git a/drivers/power/pmic/max77686.c b/drivers/power/pmic/max77686.c index 9f02c0b6f6f..7e6f7d1966f 100644 --- a/drivers/power/pmic/max77686.c +++ b/drivers/power/pmic/max77686.c @@ -10,6 +10,7 @@ #include <dm.h> #include <i2c.h> #include <log.h> +#include <linux/printk.h> #include <power/pmic.h> #include <power/regulator.h> #include <power/max77686_pmic.h> diff --git a/drivers/power/pmic/max8997.c b/drivers/power/pmic/max8997.c index dbae155fb34..504a63bf743 100644 --- a/drivers/power/pmic/max8997.c +++ b/drivers/power/pmic/max8997.c @@ -7,6 +7,7 @@ #include <common.h> #include <dm.h> #include <i2c.h> +#include <linux/printk.h> #include <power/pmic.h> #include <power/max8997_pmic.h> #include <errno.h> diff --git a/drivers/power/pmic/max8998.c b/drivers/power/pmic/max8998.c index f58d9f2d74c..d155474447f 100644 --- a/drivers/power/pmic/max8998.c +++ b/drivers/power/pmic/max8998.c @@ -8,6 +8,7 @@ #include <dm.h> #include <errno.h> #include <i2c.h> +#include <linux/printk.h> #include <power/pmic.h> #include <power/max8998_pmic.h> diff --git a/drivers/power/pmic/palmas.c b/drivers/power/pmic/palmas.c index 6080cbff0be..eb83c88d564 100644 --- a/drivers/power/pmic/palmas.c +++ b/drivers/power/pmic/palmas.c @@ -10,6 +10,7 @@ #include <dm.h> #include <i2c.h> #include <log.h> +#include <linux/printk.h> #include <power/pmic.h> #include <power/regulator.h> #include <power/palmas.h> diff --git a/drivers/power/pmic/pca9450.c b/drivers/power/pmic/pca9450.c index e99ece8fb08..0bbe98cd8a2 100644 --- a/drivers/power/pmic/pca9450.c +++ b/drivers/power/pmic/pca9450.c @@ -13,6 +13,7 @@ #include <log.h> #include <asm/global_data.h> #include <asm-generic/gpio.h> +#include <linux/printk.h> #include <power/pmic.h> #include <power/regulator.h> #include <power/pca9450.h> diff --git a/drivers/power/pmic/pfuze100.c b/drivers/power/pmic/pfuze100.c index 65c4456977c..15420acb472 100644 --- a/drivers/power/pmic/pfuze100.c +++ b/drivers/power/pmic/pfuze100.c @@ -10,6 +10,7 @@ #include <dm.h> #include <i2c.h> #include <log.h> +#include <linux/printk.h> #include <power/pmic.h> #include <power/regulator.h> #include <power/pfuze100_pmic.h> diff --git a/drivers/power/pmic/pmic_tps65910_dm.c b/drivers/power/pmic/pmic_tps65910_dm.c index e03ddc98d73..8ead1db802a 100644 --- a/drivers/power/pmic/pmic_tps65910_dm.c +++ b/drivers/power/pmic/pmic_tps65910_dm.c @@ -7,6 +7,7 @@ #include <dm.h> #include <i2c.h> #include <log.h> +#include <linux/printk.h> #include <power/pmic.h> #include <power/regulator.h> #include <power/tps65910_pmic.h> diff --git a/drivers/power/pmic/s2mps11.c b/drivers/power/pmic/s2mps11.c index 1ba1640a8df..5ff4f205211 100644 --- a/drivers/power/pmic/s2mps11.c +++ b/drivers/power/pmic/s2mps11.c @@ -10,6 +10,7 @@ #include <dm.h> #include <i2c.h> #include <log.h> +#include <linux/printk.h> #include <power/pmic.h> #include <power/s2mps11.h> diff --git a/drivers/power/pmic/s5m8767.c b/drivers/power/pmic/s5m8767.c index db6d0357ee4..eea072ae824 100644 --- a/drivers/power/pmic/s5m8767.c +++ b/drivers/power/pmic/s5m8767.c @@ -9,6 +9,7 @@ #include <dm.h> #include <i2c.h> #include <log.h> +#include <linux/printk.h> #include <power/pmic.h> #include <power/regulator.h> #include <power/s5m8767.h> diff --git a/drivers/power/pmic/sandbox.c b/drivers/power/pmic/sandbox.c index acfeae2df97..14b82455f5f 100644 --- a/drivers/power/pmic/sandbox.c +++ b/drivers/power/pmic/sandbox.c @@ -12,6 +12,7 @@ #include <dm.h> #include <i2c.h> #include <log.h> +#include <linux/printk.h> #include <power/pmic.h> #include <power/regulator.h> #include <power/sandbox_pmic.h> diff --git a/drivers/power/pmic/tps65090.c b/drivers/power/pmic/tps65090.c index b81df0dff1a..2a04d5948a5 100644 --- a/drivers/power/pmic/tps65090.c +++ b/drivers/power/pmic/tps65090.c @@ -10,6 +10,7 @@ #include <fdtdec.h> #include <i2c.h> #include <log.h> +#include <linux/printk.h> #include <power/pmic.h> #include <power/tps65090.h> diff --git a/drivers/power/pmic/tps65941.c b/drivers/power/pmic/tps65941.c index 83d0f83c64a..727b42747ab 100644 --- a/drivers/power/pmic/tps65941.c +++ b/drivers/power/pmic/tps65941.c @@ -10,6 +10,7 @@ #include <dm.h> #include <i2c.h> #include <log.h> +#include <linux/printk.h> #include <power/pmic.h> #include <power/regulator.h> #include <power/tps65941.h> diff --git a/drivers/power/regulator/bd71837.c b/drivers/power/regulator/bd71837.c index d4f8da80ad7..913ed88d45f 100644 --- a/drivers/power/regulator/bd71837.c +++ b/drivers/power/regulator/bd71837.c @@ -9,6 +9,7 @@ #include <dm.h> #include <log.h> #include <linux/bitops.h> +#include <linux/printk.h> #include <power/bd71837.h> #include <power/pmic.h> #include <power/regulator.h> diff --git a/drivers/power/regulator/fan53555.c b/drivers/power/regulator/fan53555.c index 815f96beef6..fa8d88f2e0d 100644 --- a/drivers/power/regulator/fan53555.c +++ b/drivers/power/regulator/fan53555.c @@ -11,6 +11,7 @@ #include <log.h> #include <asm/gpio.h> #include <linux/bitops.h> +#include <linux/printk.h> #include <power/fan53555.h> #include <power/pmic.h> #include <power/regulator.h> diff --git a/drivers/power/regulator/fixed.c b/drivers/power/regulator/fixed.c index f7ddba8b45e..590c288d657 100644 --- a/drivers/power/regulator/fixed.c +++ b/drivers/power/regulator/fixed.c @@ -11,8 +11,10 @@ #include <dm.h> #include <linux/delay.h> #include <log.h> +#include <asm/gpio.h> #include <power/pmic.h> #include <power/regulator.h> +#include "regulator_common.h" #include "regulator_common.h" diff --git a/drivers/power/regulator/gpio-regulator.c b/drivers/power/regulator/gpio-regulator.c index ded7be059bb..74137b7b876 100644 --- a/drivers/power/regulator/gpio-regulator.c +++ b/drivers/power/regulator/gpio-regulator.c @@ -10,8 +10,10 @@ #include <dm.h> #include <log.h> #include <asm/gpio.h> +#include <linux/printk.h> #include <power/pmic.h> #include <power/regulator.h> +#include "regulator_common.h" #include "regulator_common.h" diff --git a/drivers/power/regulator/max77686.c b/drivers/power/regulator/max77686.c index cef20e11897..3a208039934 100644 --- a/drivers/power/regulator/max77686.c +++ b/drivers/power/regulator/max77686.c @@ -10,6 +10,7 @@ #include <fdtdec.h> #include <errno.h> #include <dm.h> +#include <linux/printk.h> #include <power/pmic.h> #include <power/regulator.h> #include <power/max77686_pmic.h> diff --git a/drivers/power/regulator/pbias_regulator.c b/drivers/power/regulator/pbias_regulator.c index 5bf186e4d4c..cf4e2858443 100644 --- a/drivers/power/regulator/pbias_regulator.c +++ b/drivers/power/regulator/pbias_regulator.c @@ -10,6 +10,7 @@ #include <log.h> #include <linux/delay.h> #include <linux/err.h> +#include <linux/printk.h> #include <power/pmic.h> #include <power/regulator.h> #include <regmap.h> diff --git a/drivers/power/regulator/regulator_common.c b/drivers/power/regulator/regulator_common.c index e26f5ebec34..0116fa01bbf 100644 --- a/drivers/power/regulator/regulator_common.c +++ b/drivers/power/regulator/regulator_common.c @@ -7,8 +7,10 @@ #include <common.h> #include <dm.h> #include <log.h> +#include <asm/gpio.h> #include <linux/delay.h> #include <power/regulator.h> +#include "regulator_common.h" #include "regulator_common.h" diff --git a/drivers/power/regulator/s2mps11_regulator.c b/drivers/power/regulator/s2mps11_regulator.c index 93fb580407a..987a1f9d863 100644 --- a/drivers/power/regulator/s2mps11_regulator.c +++ b/drivers/power/regulator/s2mps11_regulator.c @@ -9,6 +9,7 @@ #include <errno.h> #include <dm.h> #include <linux/delay.h> +#include <linux/printk.h> #include <power/pmic.h> #include <power/regulator.h> #include <power/s2mps11.h> diff --git a/drivers/power/regulator/sandbox.c b/drivers/power/regulator/sandbox.c index e8b66bf2b14..71ef0c5441a 100644 --- a/drivers/power/regulator/sandbox.c +++ b/drivers/power/regulator/sandbox.c @@ -8,6 +8,7 @@ #include <fdtdec.h> #include <errno.h> #include <dm.h> +#include <linux/printk.h> #include <power/pmic.h> #include <power/regulator.h> #include <power/sandbox_pmic.h> diff --git a/drivers/power/regulator/tps65910_regulator.c b/drivers/power/regulator/tps65910_regulator.c index 0ed4952a1e0..a4b9d449274 100644 --- a/drivers/power/regulator/tps65910_regulator.c +++ b/drivers/power/regulator/tps65910_regulator.c @@ -6,6 +6,7 @@ #include <common.h> #include <dm.h> #include <log.h> +#include <linux/printk.h> #include <power/pmic.h> #include <power/regulator.h> #include <power/tps65910_pmic.h> diff --git a/drivers/power/twl4030.c b/drivers/power/twl4030.c index d3e8949af99..0c7c3960904 100644 --- a/drivers/power/twl4030.c +++ b/drivers/power/twl4030.c @@ -25,6 +25,7 @@ #include <command.h> #include <twl4030.h> #include <linux/delay.h> +#include <linux/printk.h> /* * Power Reset diff --git a/drivers/power/twl6030.c b/drivers/power/twl6030.c index 2b50a56faf8..39c05f9b7d3 100644 --- a/drivers/power/twl6030.c +++ b/drivers/power/twl6030.c @@ -5,6 +5,7 @@ */ #include <config.h> #include <linux/delay.h> +#include <linux/printk.h> #include <twl6030.h> diff --git a/drivers/ram/imxrt_sdram.c b/drivers/ram/imxrt_sdram.c index d0a88845cf9..6a15242c20c 100644 --- a/drivers/ram/imxrt_sdram.c +++ b/drivers/ram/imxrt_sdram.c @@ -15,6 +15,7 @@ #include <linux/bitops.h> #include <linux/delay.h> #include <linux/err.h> +#include <linux/printk.h> /* SDRAM Command Code */ #define SD_CC_ARD 0x0 /* Master Bus (AXI) command - Read */ diff --git a/drivers/ram/rockchip/dmc-rk3368.c b/drivers/ram/rockchip/dmc-rk3368.c index dd5b1917445..f36be941a38 100644 --- a/drivers/ram/rockchip/dmc-rk3368.c +++ b/drivers/ram/rockchip/dmc-rk3368.c @@ -23,6 +23,7 @@ #include <linux/bitops.h> #include <linux/delay.h> #include <linux/err.h> +#include <linux/printk.h> struct dram_info { struct ram_info info; diff --git a/drivers/ram/stm32_sdram.c b/drivers/ram/stm32_sdram.c index 47a930ee954..891f4137813 100644 --- a/drivers/ram/stm32_sdram.c +++ b/drivers/ram/stm32_sdram.c @@ -16,6 +16,7 @@ #include <dm/device_compat.h> #include <linux/bitops.h> #include <linux/delay.h> +#include <linux/printk.h> #define MEM_MODE_MASK GENMASK(2, 0) #define SWP_FMC_OFFSET 10 diff --git a/drivers/ram/stm32mp1/stm32mp1_ddr.c b/drivers/ram/stm32mp1/stm32mp1_ddr.c index ab913a68761..8ee4e24f39d 100644 --- a/drivers/ram/stm32mp1/stm32mp1_ddr.c +++ b/drivers/ram/stm32mp1/stm32mp1_ddr.c @@ -16,6 +16,7 @@ #include <linux/bitops.h> #include <linux/delay.h> #include <linux/iopoll.h> +#include <linux/printk.h> #include "stm32mp1_ddr.h" #include "stm32mp1_ddr_regs.h" diff --git a/drivers/ram/stm32mp1/stm32mp1_ram.c b/drivers/ram/stm32mp1/stm32mp1_ram.c index a6c19af9722..61bc002d979 100644 --- a/drivers/ram/stm32mp1/stm32mp1_ram.c +++ b/drivers/ram/stm32mp1/stm32mp1_ram.c @@ -15,6 +15,7 @@ #include <syscon.h> #include <asm/io.h> #include <dm/device_compat.h> +#include <linux/printk.h> #include "stm32mp1_ddr.h" #include "stm32mp1_ddr_regs.h" diff --git a/drivers/remoteproc/rproc-elf-loader.c b/drivers/remoteproc/rproc-elf-loader.c index b185a6cafb8..5e070e5076e 100644 --- a/drivers/remoteproc/rproc-elf-loader.c +++ b/drivers/remoteproc/rproc-elf-loader.c @@ -11,6 +11,7 @@ #include <asm/cache.h> #include <dm/device_compat.h> #include <linux/compat.h> +#include <linux/printk.h> /** * struct resource_table - firmware resource table header diff --git a/drivers/remoteproc/rproc-uclass.c b/drivers/remoteproc/rproc-uclass.c index 50bcc9030e9..ece534c3c0e 100644 --- a/drivers/remoteproc/rproc-uclass.c +++ b/drivers/remoteproc/rproc-uclass.c @@ -20,6 +20,7 @@ #include <dm/uclass.h> #include <dm/uclass-internal.h> #include <linux/compat.h> +#include <linux/printk.h> DECLARE_GLOBAL_DATA_PTR; @@ -689,7 +690,7 @@ static int alloc_vring(struct udevice *dev, struct fw_rsc_vdev *rsc, int i) debug("alloc_mem(%#x, %d): %p\n", size, order, pa); vring->da = (uintptr_t)pa; - return !pa; + return 0; } static int handle_vdev(struct udevice *dev, struct fw_rsc_vdev *rsc, diff --git a/drivers/remoteproc/sandbox_testproc.c b/drivers/remoteproc/sandbox_testproc.c index 78b108184bb..d360cf3169f 100644 --- a/drivers/remoteproc/sandbox_testproc.c +++ b/drivers/remoteproc/sandbox_testproc.c @@ -10,6 +10,7 @@ #include <log.h> #include <remoteproc.h> #include <asm/io.h> +#include <linux/printk.h> /** * enum sandbox_state - different device states diff --git a/drivers/remoteproc/stm32_copro.c b/drivers/remoteproc/stm32_copro.c index 5271f83bc0b..3e322c4d719 100644 --- a/drivers/remoteproc/stm32_copro.c +++ b/drivers/remoteproc/stm32_copro.c @@ -14,6 +14,7 @@ #include <asm/io.h> #include <dm/device_compat.h> #include <linux/err.h> +#include <linux/printk.h> /** * struct stm32_copro_privdata - power processor private data diff --git a/drivers/remoteproc/ti_power_proc.c b/drivers/remoteproc/ti_power_proc.c index 86d544cc854..6887a3c8541 100644 --- a/drivers/remoteproc/ti_power_proc.c +++ b/drivers/remoteproc/ti_power_proc.c @@ -11,6 +11,7 @@ #include <log.h> #include <remoteproc.h> #include <asm/global_data.h> +#include <linux/printk.h> #include <mach/psc_defs.h> DECLARE_GLOBAL_DATA_PTR; diff --git a/drivers/remoteproc/ti_sci_proc.h b/drivers/remoteproc/ti_sci_proc.h index f8299d1aff9..36351da63fc 100644 --- a/drivers/remoteproc/ti_sci_proc.h +++ b/drivers/remoteproc/ti_sci_proc.h @@ -10,6 +10,7 @@ #ifndef REMOTEPROC_TI_SCI_PROC_H #define REMOTEPROC_TI_SCI_PROC_H +#include <linux/printk.h> #define TISCI_INVALID_HOST 0xff /** diff --git a/drivers/reset/sti-reset.c b/drivers/reset/sti-reset.c index ea449bbaaf0..5305270fbf2 100644 --- a/drivers/reset/sti-reset.c +++ b/drivers/reset/sti-reset.c @@ -16,6 +16,7 @@ #include <asm/global_data.h> #include <dt-bindings/reset/stih407-resets.h> #include <linux/bitops.h> +#include <linux/printk.h> DECLARE_GLOBAL_DATA_PTR; diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 0a3420b7fbc..7411660d465 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -14,6 +14,7 @@ #include <env.h> #include <libata.h> #include <log.h> +#include <memalign.h> #include <part.h> #include <pci.h> #include <scsi.h> @@ -42,7 +43,7 @@ const struct pci_device_id scsi_device_list[] = { SCSI_DEV_LIST }; #endif static struct scsi_cmd tempccb; /* temporary scsi command buffer */ -static unsigned char tempbuff[512]; /* temporary data buffer */ +DEFINE_CACHE_ALIGN_BUFFER(u8, tempbuff, 512); /* temporary data buffer */ #if !defined(CONFIG_DM_SCSI) static int scsi_max_devs; /* number of highest available scsi device */ @@ -273,6 +274,18 @@ static ulong scsi_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, __func__, start, smallblks, buf_addr); return blkcnt; } + +#if IS_ENABLED(CONFIG_BOUNCE_BUFFER) +static int scsi_buffer_aligned(struct udevice *dev, struct bounce_buffer *state) +{ + struct scsi_ops *ops = scsi_get_ops(dev->parent); + + if (ops->buffer_aligned) + return ops->buffer_aligned(dev->parent, state); + + return 1; +} +#endif /* CONFIG_BOUNCE_BUFFER */ #endif #if defined(CONFIG_PCI) && !defined(CONFIG_SCSI_AHCI_PLAT) && \ @@ -490,7 +503,7 @@ static int scsi_detect_dev(struct udevice *dev, int target, int lun, pccb->target = target; pccb->lun = lun; - pccb->pdata = (unsigned char *)&tempbuff; + pccb->pdata = tempbuff; pccb->datalen = 512; pccb->dma_dir = DMA_FROM_DEVICE; scsi_setup_inquiry(pccb); @@ -719,6 +732,9 @@ int scsi_scan(bool verbose) static const struct blk_ops scsi_blk_ops = { .read = scsi_read, .write = scsi_write, +#if IS_ENABLED(CONFIG_BOUNCE_BUFFER) + .buffer_aligned = scsi_buffer_aligned, +#endif /* CONFIG_BOUNCE_BUFFER */ }; U_BOOT_DRIVER(scsi_blk) = { diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index 8c54bc9c470..6cb6598f3d2 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -485,8 +485,8 @@ endchoice config DEBUG_UART_BASE hex "Base address of UART" depends on DEBUG_UART - default 0 if DEBUG_SBI_CONSOLE - default 0 if DEBUG_UART_SANDBOX + default 0x0 if DEBUG_SBI_CONSOLE + default 0x0 if DEBUG_UART_SANDBOX default 0xff000000 if DEBUG_UART_ZYNQ && ARCH_ZYNQMP default 0xe0000000 if DEBUG_UART_ZYNQ && ARCH_ZYNQ help @@ -675,7 +675,7 @@ config COREBOOT_SERIAL config COREBOOT_SERIAL_FROM_DBG2 bool "Obtain UART from ACPI tables" depends on COREBOOT_SERIAL - default y if !SPL + default y help Select this to try to find a DBG2 record in the ACPI tables, in the event that coreboot does not provide information about the UART in the @@ -1142,6 +1142,6 @@ config SYS_SDSR config SYS_SDMR hex "SDMR Value" depends on MPC8XX_CONS - default 0 + default 0x0 endif diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c index 067fae26145..5e2e7dfbcb3 100644 --- a/drivers/serial/serial-uclass.c +++ b/drivers/serial/serial-uclass.c @@ -151,6 +151,7 @@ static void serial_find_console_or_panic(void) #ifdef CONFIG_REQUIRE_SERIAL_CONSOLE panic_str("No serial driver found"); #endif + gd->cur_serial_dev = NULL; } #endif /* CONFIG_SERIAL_PRESENT */ @@ -507,28 +508,6 @@ static int serial_post_probe(struct udevice *dev) #endif int ret; -#if defined(CONFIG_NEEDS_MANUAL_RELOC) - if (ops->setbrg) - ops->setbrg += gd->reloc_off; - if (ops->getc) - ops->getc += gd->reloc_off; - if (ops->putc) - ops->putc += gd->reloc_off; - if (ops->pending) - ops->pending += gd->reloc_off; - if (ops->clear) - ops->clear += gd->reloc_off; - if (ops->getconfig) - ops->getconfig += gd->reloc_off; - if (ops->setconfig) - ops->setconfig += gd->reloc_off; -#if CFG_POST & CFG_SYS_POST_UART - if (ops->loop) - ops->loop += gd->reloc_off; -#endif - if (ops->getinfo) - ops->getinfo += gd->reloc_off; -#endif /* Set the baud rate */ if (ops->setbrg) { ret = ops->setbrg(dev, gd->baudrate); diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c index 9a380d7c5e7..787edd53602 100644 --- a/drivers/serial/serial.c +++ b/drivers/serial/serial.c @@ -142,23 +142,6 @@ serial_initfunc(mtk_serial_initialize); */ void serial_register(struct serial_device *dev) { -#ifdef CONFIG_NEEDS_MANUAL_RELOC - if (dev->start) - dev->start += gd->reloc_off; - if (dev->stop) - dev->stop += gd->reloc_off; - if (dev->setbrg) - dev->setbrg += gd->reloc_off; - if (dev->getc) - dev->getc += gd->reloc_off; - if (dev->tstc) - dev->tstc += gd->reloc_off; - if (dev->putc) - dev->putc += gd->reloc_off; - if (dev->puts) - dev->puts += gd->reloc_off; -#endif - dev->next = serial_devices; serial_devices = dev; } diff --git a/drivers/serial/serial_mtk.c b/drivers/serial/serial_mtk.c index 2dffa14ea75..f146f2b006e 100644 --- a/drivers/serial/serial_mtk.c +++ b/drivers/serial/serial_mtk.c @@ -19,6 +19,7 @@ #include <asm/io.h> #include <asm/types.h> #include <linux/err.h> +#include <linux/printk.h> struct mtk_serial_regs { u32 rbr; diff --git a/drivers/soc/ti/k3-navss-ringacc.c b/drivers/soc/ti/k3-navss-ringacc.c index f110d78ce10..9881bffc8e1 100644 --- a/drivers/soc/ti/k3-navss-ringacc.c +++ b/drivers/soc/ti/k3-navss-ringacc.c @@ -21,6 +21,7 @@ #include <linux/compat.h> #include <linux/dma-mapping.h> #include <linux/err.h> +#include <linux/printk.h> #include <linux/soc/ti/k3-navss-ringacc.h> #include <linux/soc/ti/ti_sci_protocol.h> #include <linux/soc/ti/cppi5.h> diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c index 702e2253581..aec6f4eca9a 100644 --- a/drivers/spi/atmel_spi.c +++ b/drivers/spi/atmel_spi.c @@ -17,6 +17,7 @@ #include <asm/gpio.h> #endif #include <linux/bitops.h> +#include <linux/printk.h> /* * Register definitions for the Atmel AT32/AT91 SPI Controller diff --git a/drivers/spi/fsl_dspi.c b/drivers/spi/fsl_dspi.c index 8e5cc5552f0..f8ec268812c 100644 --- a/drivers/spi/fsl_dspi.c +++ b/drivers/spi/fsl_dspi.c @@ -26,6 +26,7 @@ #include <fsl_dspi.h> #include <linux/bitops.h> #include <linux/delay.h> +#include <linux/printk.h> /* linux/include/time.h */ #define NSEC_PER_SEC 1000000000L diff --git a/drivers/spi/mt7621_spi.c b/drivers/spi/mt7621_spi.c index eb0931747b7..3d008099862 100644 --- a/drivers/spi/mt7621_spi.c +++ b/drivers/spi/mt7621_spi.c @@ -16,6 +16,7 @@ #include <wait_bit.h> #include <linux/bitops.h> #include <linux/io.h> +#include <linux/printk.h> #define MT7621_RX_FIFO_LEN 32 #define MT7621_TX_FIFO_LEN 36 diff --git a/drivers/spi/mxc_spi.c b/drivers/spi/mxc_spi.c index 840660ffe9a..33360a18329 100644 --- a/drivers/spi/mxc_spi.c +++ b/drivers/spi/mxc_spi.c @@ -19,6 +19,7 @@ #include <asm/arch/imx-regs.h> #include <asm/arch/clock.h> #include <asm/mach-imx/spi.h> +#include <linux/printk.h> DECLARE_GLOBAL_DATA_PTR; diff --git a/drivers/spi/pl022_spi.c b/drivers/spi/pl022_spi.c index fc7388b379d..e2b49ebd149 100644 --- a/drivers/spi/pl022_spi.c +++ b/drivers/spi/pl022_spi.c @@ -18,6 +18,7 @@ #include <asm/global_data.h> #include <asm/gpio.h> #include <spi.h> +#include <linux/printk.h> #define SSP_CR0 0x000 #define SSP_CR1 0x004 diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c index c929e7c1d0e..f4795e68672 100644 --- a/drivers/spi/spi-uclass.c +++ b/drivers/spi/spi-uclass.c @@ -196,38 +196,6 @@ static int spi_post_probe(struct udevice *bus) spi->max_hz = dev_read_u32_default(bus, "spi-max-frequency", 0); } -#if defined(CONFIG_NEEDS_MANUAL_RELOC) - struct dm_spi_ops *ops = spi_get_ops(bus); - static int reloc_done; - - if (!reloc_done) { - if (ops->claim_bus) - ops->claim_bus += gd->reloc_off; - if (ops->release_bus) - ops->release_bus += gd->reloc_off; - if (ops->set_wordlen) - ops->set_wordlen += gd->reloc_off; - if (ops->xfer) - ops->xfer += gd->reloc_off; - if (ops->set_speed) - ops->set_speed += gd->reloc_off; - if (ops->set_mode) - ops->set_mode += gd->reloc_off; - if (ops->cs_info) - ops->cs_info += gd->reloc_off; - if (ops->mem_ops) { - struct spi_controller_mem_ops *mem_ops = - (struct spi_controller_mem_ops *)ops->mem_ops; - if (mem_ops->adjust_op_size) - mem_ops->adjust_op_size += gd->reloc_off; - if (mem_ops->supports_op) - mem_ops->supports_op += gd->reloc_off; - if (mem_ops->exec_op) - mem_ops->exec_op += gd->reloc_off; - } - reloc_done++; - } -#endif return 0; } diff --git a/drivers/spi/stm32_qspi.c b/drivers/spi/stm32_qspi.c index eb52ff73b23..2ffa201a66e 100644 --- a/drivers/spi/stm32_qspi.c +++ b/drivers/spi/stm32_qspi.c @@ -22,6 +22,7 @@ #include <linux/delay.h> #include <linux/iopoll.h> #include <linux/ioport.h> +#include <linux/printk.h> #include <linux/sizes.h> struct stm32_qspi_regs { diff --git a/drivers/spi/stm32_spi.c b/drivers/spi/stm32_spi.c index fe5419e8518..82f6ed783f9 100644 --- a/drivers/spi/stm32_spi.c +++ b/drivers/spi/stm32_spi.c @@ -18,6 +18,7 @@ #include <dm/device_compat.h> #include <linux/bitops.h> #include <linux/delay.h> +#include <linux/printk.h> #include <asm/io.h> #include <asm/gpio.h> diff --git a/drivers/spi/uniphier_spi.c b/drivers/spi/uniphier_spi.c index fcc1bfe64b6..6402acbf14a 100644 --- a/drivers/spi/uniphier_spi.c +++ b/drivers/spi/uniphier_spi.c @@ -17,6 +17,7 @@ #include <linux/io.h> #include <spi.h> #include <wait_bit.h> +#include <linux/printk.h> DECLARE_GLOBAL_DATA_PTR; diff --git a/drivers/spi/zynqmp_gqspi.c b/drivers/spi/zynqmp_gqspi.c index c4aee279aa4..ec59ef58044 100644 --- a/drivers/spi/zynqmp_gqspi.c +++ b/drivers/spi/zynqmp_gqspi.c @@ -690,7 +690,7 @@ static int zynqmp_qspi_start_dma(struct zynqmp_qspi_priv *priv, writel(GQSPI_DMA_DST_I_STS_MASK, &dma_regs->dmaier); addr = (unsigned long)buf; size = roundup(priv->len, GQSPI_DMA_ALIGN); - flush_dcache_range(addr, addr + size); + invalidate_dcache_range(addr, addr + size); while (priv->len) { zynqmp_qspi_calc_exp(priv, &gen_fifo_cmd); @@ -707,6 +707,8 @@ static int zynqmp_qspi_start_dma(struct zynqmp_qspi_priv *priv, return -ETIMEDOUT; } + invalidate_dcache_range(addr, addr + size); + writel(GQSPI_DMA_DST_I_STS_DONE, &dma_regs->dmaisr); debug("buf:0x%lx, rxbuf:0x%lx, *buf:0x%x len: 0x%x\n", diff --git a/drivers/sysreset/sysreset-uclass.c b/drivers/sysreset/sysreset-uclass.c index 279b087d16d..6151b5fe03e 100644 --- a/drivers/sysreset/sysreset-uclass.c +++ b/drivers/sysreset/sysreset-uclass.c @@ -158,23 +158,7 @@ int do_poweroff(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) } #endif -static int sysreset_post_bind(struct udevice *dev) -{ -#if defined(CONFIG_NEEDS_MANUAL_RELOC) - struct sysreset_ops *ops = sysreset_get_ops(dev); - static int reloc_done; - - if (!reloc_done) { - if (ops->request) - ops->request += gd->reloc_off; - reloc_done++; - } -#endif - return 0; -} - UCLASS_DRIVER(sysreset) = { .id = UCLASS_SYSRESET, .name = "sysreset", - .post_bind = sysreset_post_bind, }; diff --git a/drivers/sysreset/sysreset_sti.c b/drivers/sysreset/sysreset_sti.c index f0f445f22ed..edd90aab061 100644 --- a/drivers/sysreset/sysreset_sti.c +++ b/drivers/sysreset/sysreset_sti.c @@ -12,6 +12,7 @@ #include <asm/global_data.h> #include <asm/io.h> #include <linux/bitops.h> +#include <linux/printk.h> DECLARE_GLOBAL_DATA_PTR; diff --git a/drivers/sysreset/sysreset_syscon.c b/drivers/sysreset/sysreset_syscon.c index 525faf2f89e..e468dac0e90 100644 --- a/drivers/sysreset/sysreset_syscon.c +++ b/drivers/sysreset/sysreset_syscon.c @@ -14,6 +14,7 @@ #include <sysreset.h> #include <syscon.h> #include <linux/err.h> +#include <linux/printk.h> struct syscon_reboot_priv { struct regmap *regmap; diff --git a/drivers/sysreset/sysreset_watchdog.c b/drivers/sysreset/sysreset_watchdog.c index 8a659ee9b97..ceada2e47b5 100644 --- a/drivers/sysreset/sysreset_watchdog.c +++ b/drivers/sysreset/sysreset_watchdog.c @@ -10,6 +10,7 @@ #include <malloc.h> #include <sysreset.h> #include <wdt.h> +#include <linux/printk.h> struct wdt_reboot_plat { struct udevice *wdt; diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c index f4b871ac23a..0c2018bfe3b 100644 --- a/drivers/timer/timer-uclass.c +++ b/drivers/timer/timer-uclass.c @@ -51,19 +51,6 @@ unsigned long notrace timer_get_rate(struct udevice *dev) static int timer_pre_probe(struct udevice *dev) { - if (IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC) && - (gd->flags & GD_FLG_RELOC)) { - struct timer_ops *ops = timer_get_ops(dev); - static int reloc_done; - - if (!reloc_done) { - if (ops->get_count) - MANUAL_RELOC(ops->get_count); - - reloc_done++; - } - } - if (CONFIG_IS_ENABLED(OF_REAL)) { struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev); struct clk timer_clk; diff --git a/drivers/tpm/tpm_tis_infineon.c b/drivers/tpm/tpm_tis_infineon.c index 525ad72f4c9..16f4af0e331 100644 --- a/drivers/tpm/tpm_tis_infineon.c +++ b/drivers/tpm/tpm_tis_infineon.c @@ -28,6 +28,7 @@ #include <linux/delay.h> #include <linux/errno.h> #include <linux/compiler.h> +#include <linux/printk.h> #include <linux/types.h> #include <linux/unaligned/be_byteshift.h> diff --git a/drivers/ufs/Kconfig b/drivers/ufs/Kconfig index 69ea18edf8d..0e0cc58e3d6 100644 --- a/drivers/ufs/Kconfig +++ b/drivers/ufs/Kconfig @@ -21,4 +21,13 @@ config TI_J721E_UFS This selects the glue layer driver for Cadence controller present on TI's J721E devices. +config UFS_RENESAS + bool "Renesas specific hooks to UFS controller platform driver" + depends on UFS + select BOUNCE_BUFFER + help + This selects the Renesas specific additions to UFSHCD platform driver. + UFS host on Renesas needs some vendor specific configuration before + accessing the hardware. + endmenu diff --git a/drivers/ufs/Makefile b/drivers/ufs/Makefile index 62ed0166084..4f3344fd4e4 100644 --- a/drivers/ufs/Makefile +++ b/drivers/ufs/Makefile @@ -6,3 +6,4 @@ obj-$(CONFIG_UFS) += ufs.o ufs-uclass.o obj-$(CONFIG_CADENCE_UFS) += cdns-platform.o obj-$(CONFIG_TI_J721E_UFS) += ti-j721e-ufs.o +obj-$(CONFIG_UFS_RENESAS) += ufs-renesas.o diff --git a/drivers/ufs/cdns-platform.c b/drivers/ufs/cdns-platform.c index bad1bf7de5f..1e62e252e7a 100644 --- a/drivers/ufs/cdns-platform.c +++ b/drivers/ufs/cdns-platform.c @@ -119,7 +119,7 @@ static const struct udevice_id cdns_ufs_pltfm_ids[] = { U_BOOT_DRIVER(cdns_ufs_pltfm) = { .name = "cdns-ufs-pltfm", - .id = UCLASS_UFS, + .id = UCLASS_UFS, .of_match = cdns_ufs_pltfm_ids, .probe = cdns_ufs_pltfm_probe, .bind = cdns_ufs_pltfm_bind, diff --git a/drivers/ufs/ufs-renesas.c b/drivers/ufs/ufs-renesas.c new file mode 100644 index 00000000000..ae05bdc8102 --- /dev/null +++ b/drivers/ufs/ufs-renesas.c @@ -0,0 +1,412 @@ +// SPDX-License-Identifier: GPL-2.0 OR MIT +/* + * Renesas UFS host controller driver + * + * Copyright (C) 2022 Renesas Electronics Corporation + */ + +#include <clk.h> +#include <dm.h> +#include <ufs.h> +#include <asm/io.h> +#include <dm/device_compat.h> +#include <linux/bitops.h> +#include <linux/delay.h> +#include <linux/err.h> +#include <linux/bug.h> +#include <linux/iopoll.h> + +#include "ufs.h" + +struct ufs_renesas_priv { + struct clk_bulk clks; + bool initialized; /* The hardware needs initialization once */ +}; + +enum { + SET_PHY_INDEX_LO = 0, + SET_PHY_INDEX_HI, + TIMER_INDEX, + MAX_INDEX +}; + +enum ufs_renesas_init_param_mode { + MODE_RESTORE, + MODE_SET, + MODE_SAVE, + MODE_POLL, + MODE_WAIT, + MODE_WRITE, +}; + +#define PARAM_RESTORE(_reg, _index) \ + { .mode = MODE_RESTORE, .reg = _reg, .index = _index } +#define PARAM_SET(_index, _set) \ + { .mode = MODE_SET, .index = _index, .u.set = _set } +#define PARAM_SAVE(_reg, _mask, _index) \ + { .mode = MODE_SAVE, .reg = _reg, .mask = (u32)(_mask), \ + .index = _index } +#define PARAM_POLL(_reg, _expected, _mask) \ + { .mode = MODE_POLL, .reg = _reg, .u.expected = _expected, \ + .mask = (u32)(_mask) } +#define PARAM_WAIT(_delay_us) \ + { .mode = MODE_WAIT, .u.delay_us = _delay_us } + +#define PARAM_WRITE(_reg, _val) \ + { .mode = MODE_WRITE, .reg = _reg, .u.val = _val } + +#define PARAM_WRITE_D0_D4(_d0, _d4) \ + PARAM_WRITE(0xd0, _d0), PARAM_WRITE(0xd4, _d4) + +#define PARAM_WRITE_800_80C_POLL(_addr, _data_800) \ + PARAM_WRITE_D0_D4(0x0000080c, 0x00000100), \ + PARAM_WRITE_D0_D4(0x00000800, ((_data_800) << 16) | BIT(8) | (_addr)), \ + PARAM_WRITE(0xd0, 0x0000080c), \ + PARAM_POLL(0xd4, BIT(8), BIT(8)) + +#define PARAM_RESTORE_800_80C_POLL(_index) \ + PARAM_WRITE_D0_D4(0x0000080c, 0x00000100), \ + PARAM_WRITE(0xd0, 0x00000800), \ + PARAM_RESTORE(0xd4, (_index)), \ + PARAM_WRITE(0xd0, 0x0000080c), \ + PARAM_POLL(0xd4, BIT(8), BIT(8)) + +#define PARAM_WRITE_804_80C_POLL(_addr, _data_804) \ + PARAM_WRITE_D0_D4(0x0000080c, 0x00000100), \ + PARAM_WRITE_D0_D4(0x00000804, ((_data_804) << 16) | BIT(8) | (_addr)), \ + PARAM_WRITE(0xd0, 0x0000080c), \ + PARAM_POLL(0xd4, BIT(8), BIT(8)) + +#define PARAM_WRITE_828_82C_POLL(_data_828) \ + PARAM_WRITE_D0_D4(0x0000082c, 0x0f000000), \ + PARAM_WRITE_D0_D4(0x00000828, _data_828), \ + PARAM_WRITE(0xd0, 0x0000082c), \ + PARAM_POLL(0xd4, _data_828, _data_828) + +#define PARAM_WRITE_PHY(_addr16, _data16) \ + PARAM_WRITE(0xf0, 1), \ + PARAM_WRITE_800_80C_POLL(0x16, (_addr16) & 0xff), \ + PARAM_WRITE_800_80C_POLL(0x17, ((_addr16) >> 8) & 0xff), \ + PARAM_WRITE_800_80C_POLL(0x18, (_data16) & 0xff), \ + PARAM_WRITE_800_80C_POLL(0x19, ((_data16) >> 8) & 0xff), \ + PARAM_WRITE_800_80C_POLL(0x1c, 0x01), \ + PARAM_WRITE_828_82C_POLL(0x0f000000), \ + PARAM_WRITE(0xf0, 0) + +#define PARAM_SET_PHY(_addr16, _data16) \ + PARAM_WRITE(0xf0, 1), \ + PARAM_WRITE_800_80C_POLL(0x16, (_addr16) & 0xff), \ + PARAM_WRITE_800_80C_POLL(0x17, ((_addr16) >> 8) & 0xff), \ + PARAM_WRITE_800_80C_POLL(0x1c, 0x01), \ + PARAM_WRITE_828_82C_POLL(0x0f000000), \ + PARAM_WRITE_804_80C_POLL(0x1a, 0), \ + PARAM_WRITE(0xd0, 0x00000808), \ + PARAM_SAVE(0xd4, 0xff, SET_PHY_INDEX_LO), \ + PARAM_WRITE_804_80C_POLL(0x1b, 0), \ + PARAM_WRITE(0xd0, 0x00000808), \ + PARAM_SAVE(0xd4, 0xff, SET_PHY_INDEX_HI), \ + PARAM_WRITE_828_82C_POLL(0x0f000000), \ + PARAM_WRITE(0xf0, 0), \ + PARAM_WRITE(0xf0, 1), \ + PARAM_WRITE_800_80C_POLL(0x16, (_addr16) & 0xff), \ + PARAM_WRITE_800_80C_POLL(0x17, ((_addr16) >> 8) & 0xff), \ + PARAM_SET(SET_PHY_INDEX_LO, (((_data16) & 0xff) << 16) | BIT(8) | 0x18), \ + PARAM_RESTORE_800_80C_POLL(SET_PHY_INDEX_LO), \ + PARAM_SET(SET_PHY_INDEX_HI, ((((_data16) >> 8) & 0xff) << 16) | BIT(8) | 0x19), \ + PARAM_RESTORE_800_80C_POLL(SET_PHY_INDEX_HI), \ + PARAM_WRITE_800_80C_POLL(0x1c, 0x01), \ + PARAM_WRITE_828_82C_POLL(0x0f000000), \ + PARAM_WRITE(0xf0, 0) + +#define PARAM_INDIRECT_WRITE(_gpio, _addr, _data_800) \ + PARAM_WRITE(0xf0, _gpio), \ + PARAM_WRITE_800_80C_POLL((_addr), _data_800), \ + PARAM_WRITE_828_82C_POLL(0x0f000000), \ + PARAM_WRITE(0xf0, 0) + +#define PARAM_INDIRECT_POLL(_gpio, _addr, _expected, _mask) \ + PARAM_WRITE(0xf0, _gpio), \ + PARAM_WRITE_800_80C_POLL((_addr), 0), \ + PARAM_WRITE(0xd0, 0x00000808), \ + PARAM_POLL(0xd4, (_expected), (_mask)), \ + PARAM_WRITE(0xf0, 0) + +struct ufs_renesas_init_param { + enum ufs_renesas_init_param_mode mode; + u32 reg; + union { + u32 expected; + u32 delay_us; + u32 set; + u32 val; + } u; + u32 mask; + u32 index; +}; + +/* This setting is for SERIES B */ +static const struct ufs_renesas_init_param ufs_param[] = { + PARAM_WRITE(0xc0, 0x49425308), + PARAM_WRITE_D0_D4(0x00000104, 0x00000002), + PARAM_WAIT(1), + PARAM_WRITE_D0_D4(0x00000828, 0x00000200), + PARAM_WAIT(1), + PARAM_WRITE_D0_D4(0x00000828, 0x00000000), + PARAM_WRITE_D0_D4(0x00000104, 0x00000001), + PARAM_WRITE_D0_D4(0x00000940, 0x00000001), + PARAM_WAIT(1), + PARAM_WRITE_D0_D4(0x00000940, 0x00000000), + + PARAM_WRITE(0xc0, 0x49425308), + PARAM_WRITE(0xc0, 0x41584901), + + PARAM_WRITE_D0_D4(0x0000080c, 0x00000100), + PARAM_WRITE_D0_D4(0x00000804, 0x00000000), + PARAM_WRITE(0xd0, 0x0000080c), + PARAM_POLL(0xd4, BIT(8), BIT(8)), + + PARAM_WRITE(REG_CONTROLLER_ENABLE, 0x00000001), + + PARAM_WRITE(0xd0, 0x00000804), + PARAM_POLL(0xd4, BIT(8) | BIT(6) | BIT(0), BIT(8) | BIT(6) | BIT(0)), + + PARAM_WRITE(0xd0, 0x00000d00), + PARAM_SAVE(0xd4, 0x0000ffff, TIMER_INDEX), + PARAM_WRITE(0xd4, 0x00000000), + PARAM_WRITE_D0_D4(0x0000082c, 0x0f000000), + PARAM_WRITE_D0_D4(0x00000828, 0x08000000), + PARAM_WRITE(0xd0, 0x0000082c), + PARAM_POLL(0xd4, BIT(27), BIT(27)), + PARAM_WRITE(0xd0, 0x00000d2c), + PARAM_POLL(0xd4, BIT(0), BIT(0)), + + /* phy setup */ + PARAM_INDIRECT_WRITE(1, 0x01, 0x001f), + PARAM_INDIRECT_WRITE(7, 0x5d, 0x0014), + PARAM_INDIRECT_WRITE(7, 0x5e, 0x0014), + PARAM_INDIRECT_WRITE(7, 0x0d, 0x0003), + PARAM_INDIRECT_WRITE(7, 0x0e, 0x0007), + PARAM_INDIRECT_WRITE(7, 0x5f, 0x0003), + PARAM_INDIRECT_WRITE(7, 0x60, 0x0003), + PARAM_INDIRECT_WRITE(7, 0x5b, 0x00a6), + PARAM_INDIRECT_WRITE(7, 0x5c, 0x0003), + + PARAM_INDIRECT_POLL(7, 0x3c, 0, BIT(7)), + PARAM_INDIRECT_POLL(7, 0x4c, 0, BIT(4)), + + PARAM_INDIRECT_WRITE(1, 0x32, 0x0080), + PARAM_INDIRECT_WRITE(1, 0x1f, 0x0001), + PARAM_INDIRECT_WRITE(0, 0x2c, 0x0001), + PARAM_INDIRECT_WRITE(0, 0x32, 0x0087), + + PARAM_INDIRECT_WRITE(1, 0x4d, 0x0061), + PARAM_INDIRECT_WRITE(4, 0x9b, 0x0009), + PARAM_INDIRECT_WRITE(4, 0xa6, 0x0005), + PARAM_INDIRECT_WRITE(4, 0xa5, 0x0058), + PARAM_INDIRECT_WRITE(1, 0x39, 0x0027), + PARAM_INDIRECT_WRITE(1, 0x47, 0x004c), + + PARAM_INDIRECT_WRITE(7, 0x0d, 0x0002), + PARAM_INDIRECT_WRITE(7, 0x0e, 0x0007), + + PARAM_WRITE_PHY(0x0028, 0x0061), + PARAM_WRITE_PHY(0x4014, 0x0061), + PARAM_SET_PHY(0x401c, BIT(2)), + PARAM_WRITE_PHY(0x4000, 0x0000), + PARAM_WRITE_PHY(0x4001, 0x0000), + + PARAM_WRITE_PHY(0x10ae, 0x0001), + PARAM_WRITE_PHY(0x10ad, 0x0000), + PARAM_WRITE_PHY(0x10af, 0x0001), + PARAM_WRITE_PHY(0x10b6, 0x0001), + PARAM_WRITE_PHY(0x10ae, 0x0000), + + PARAM_WRITE_PHY(0x10ae, 0x0001), + PARAM_WRITE_PHY(0x10ad, 0x0000), + PARAM_WRITE_PHY(0x10af, 0x0002), + PARAM_WRITE_PHY(0x10b6, 0x0001), + PARAM_WRITE_PHY(0x10ae, 0x0000), + + PARAM_WRITE_PHY(0x10ae, 0x0001), + PARAM_WRITE_PHY(0x10ad, 0x0080), + PARAM_WRITE_PHY(0x10af, 0x0000), + PARAM_WRITE_PHY(0x10b6, 0x0001), + PARAM_WRITE_PHY(0x10ae, 0x0000), + + PARAM_WRITE_PHY(0x10ae, 0x0001), + PARAM_WRITE_PHY(0x10ad, 0x0080), + PARAM_WRITE_PHY(0x10af, 0x001a), + PARAM_WRITE_PHY(0x10b6, 0x0001), + PARAM_WRITE_PHY(0x10ae, 0x0000), + + PARAM_INDIRECT_WRITE(7, 0x70, 0x0016), + PARAM_INDIRECT_WRITE(7, 0x71, 0x0016), + PARAM_INDIRECT_WRITE(7, 0x72, 0x0014), + PARAM_INDIRECT_WRITE(7, 0x73, 0x0014), + PARAM_INDIRECT_WRITE(7, 0x74, 0x0000), + PARAM_INDIRECT_WRITE(7, 0x75, 0x0000), + PARAM_INDIRECT_WRITE(7, 0x76, 0x0010), + PARAM_INDIRECT_WRITE(7, 0x77, 0x0010), + PARAM_INDIRECT_WRITE(7, 0x78, 0x00ff), + PARAM_INDIRECT_WRITE(7, 0x79, 0x0000), + + PARAM_INDIRECT_WRITE(7, 0x19, 0x0007), + + PARAM_INDIRECT_WRITE(7, 0x1a, 0x0007), + + PARAM_INDIRECT_WRITE(7, 0x24, 0x000c), + + PARAM_INDIRECT_WRITE(7, 0x25, 0x000c), + + PARAM_INDIRECT_WRITE(7, 0x62, 0x0000), + PARAM_INDIRECT_WRITE(7, 0x63, 0x0000), + PARAM_INDIRECT_WRITE(7, 0x5d, 0x0014), + PARAM_INDIRECT_WRITE(7, 0x5e, 0x0017), + PARAM_INDIRECT_WRITE(7, 0x5d, 0x0004), + PARAM_INDIRECT_WRITE(7, 0x5e, 0x0017), + PARAM_INDIRECT_POLL(7, 0x55, 0, BIT(6)), + PARAM_INDIRECT_POLL(7, 0x41, 0, BIT(7)), + /* end of phy setup */ + + PARAM_WRITE(0xf0, 0), + PARAM_WRITE(0xd0, 0x00000d00), + PARAM_RESTORE(0xd4, TIMER_INDEX), +}; + +static void ufs_renesas_reg_control(struct ufs_hba *hba, + const struct ufs_renesas_init_param *p) +{ + static u32 save[MAX_INDEX]; + int ret; + u32 val; + + WARN_ON(p->index >= MAX_INDEX); + + switch (p->mode) { + case MODE_RESTORE: + ufshcd_writel(hba, save[p->index], p->reg); + break; + case MODE_SET: + save[p->index] |= p->u.set; + break; + case MODE_SAVE: + save[p->index] = ufshcd_readl(hba, p->reg) & p->mask; + break; + case MODE_POLL: + ret = readl_poll_timeout(hba->mmio_base + p->reg, val, + (val & p->mask) == p->u.expected, + 10000); + if (ret) + dev_err(hba->dev, "%s: poll failed %d (%08x, %08x, %08x)\n", + __func__, ret, val, p->mask, p->u.expected); + break; + case MODE_WAIT: + if (p->u.delay_us > 1000) + mdelay(DIV_ROUND_UP(p->u.delay_us, 1000)); + else + udelay(p->u.delay_us); + break; + case MODE_WRITE: + ufshcd_writel(hba, p->u.val, p->reg); + break; + default: + break; + } +} + +static void ufs_renesas_pre_init(struct ufs_hba *hba) +{ + const struct ufs_renesas_init_param *p = ufs_param; + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(ufs_param); i++) + ufs_renesas_reg_control(hba, &p[i]); +} + +static int ufs_renesas_hce_enable_notify(struct ufs_hba *hba, + enum ufs_notify_change_status status) +{ + struct ufs_renesas_priv *priv = dev_get_priv(hba->dev); + + if (priv->initialized) + return 0; + + if (status == PRE_CHANGE) + ufs_renesas_pre_init(hba); + + priv->initialized = true; + + return 0; +} + +static int ufs_renesas_init(struct ufs_hba *hba) +{ + hba->quirks |= UFSHCD_QUIRK_BROKEN_64BIT_ADDRESS | UFSHCD_QUIRK_HIBERN_FASTAUTO; + + return 0; +} + +static struct ufs_hba_ops ufs_renesas_vops = { + .init = ufs_renesas_init, + .hce_enable_notify = ufs_renesas_hce_enable_notify, +}; + +static int ufs_renesas_pltfm_bind(struct udevice *dev) +{ + struct udevice *scsi_dev; + + return ufs_scsi_bind(dev, &scsi_dev); +} + +static int ufs_renesas_pltfm_probe(struct udevice *dev) +{ + struct ufs_renesas_priv *priv = dev_get_priv(dev); + int err; + + err = clk_get_bulk(dev, &priv->clks); + if (err < 0) + return err; + + err = clk_enable_bulk(&priv->clks); + if (err) + goto err_clk_enable; + + err = ufshcd_probe(dev, &ufs_renesas_vops); + if (err) { + dev_err(dev, "ufshcd_probe() failed %d\n", err); + goto err_ufshcd_probe; + } + + return 0; + +err_ufshcd_probe: + clk_disable_bulk(&priv->clks); +err_clk_enable: + clk_release_bulk(&priv->clks); + return err; +} + +static int ufs_renesas_pltfm_remove(struct udevice *dev) +{ + struct ufs_renesas_priv *priv = dev_get_priv(dev); + + clk_disable_bulk(&priv->clks); + clk_release_bulk(&priv->clks); + + return 0; +} + +static const struct udevice_id ufs_renesas_pltfm_ids[] = { + { .compatible = "renesas,r8a779f0-ufs" }, + { /* sentinel */ } +}; + +U_BOOT_DRIVER(ufs_renesas) = { + .name = "ufs-renesas", + .id = UCLASS_UFS, + .of_match = ufs_renesas_pltfm_ids, + .bind = ufs_renesas_pltfm_bind, + .probe = ufs_renesas_pltfm_probe, + .remove = ufs_renesas_pltfm_remove, + .priv_auto = sizeof(struct ufs_renesas_priv), +}; diff --git a/drivers/ufs/ufs.c b/drivers/ufs/ufs.c index 3bf1a95e7f2..7c48d57f99d 100644 --- a/drivers/ufs/ufs.c +++ b/drivers/ufs/ufs.c @@ -8,6 +8,7 @@ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com */ +#include <bouncebuf.h> #include <charset.h> #include <common.h> #include <dm.h> @@ -692,13 +693,29 @@ static inline u8 ufshcd_get_upmcrs(struct ufs_hba *hba) } /** + * ufshcd_cache_flush_and_invalidate - Flush and invalidate cache + * + * Flush and invalidate cache in aligned address..address+size range. + * The invalidation is in place to avoid stale data in cache. + */ +static void ufshcd_cache_flush_and_invalidate(void *addr, unsigned long size) +{ + uintptr_t aaddr = (uintptr_t)addr & ~(ARCH_DMA_MINALIGN - 1); + unsigned long asize = ALIGN(size, ARCH_DMA_MINALIGN); + + flush_dcache_range(aaddr, aaddr + asize); + invalidate_dcache_range(aaddr, aaddr + asize); +} + +/** * ufshcd_prepare_req_desc_hdr() - Fills the requests header * descriptor according to request */ -static void ufshcd_prepare_req_desc_hdr(struct utp_transfer_req_desc *req_desc, +static void ufshcd_prepare_req_desc_hdr(struct ufs_hba *hba, u32 *upiu_flags, enum dma_data_direction cmd_dir) { + struct utp_transfer_req_desc *req_desc = hba->utrdl; u32 data_direction; u32 dword_0; @@ -733,6 +750,8 @@ static void ufshcd_prepare_req_desc_hdr(struct utp_transfer_req_desc *req_desc, req_desc->header.dword_3 = 0; req_desc->prd_table_length = 0; + + ufshcd_cache_flush_and_invalidate(req_desc, sizeof(*req_desc)); } static void ufshcd_prepare_utp_query_req_upiu(struct ufs_hba *hba, @@ -761,10 +780,15 @@ static void ufshcd_prepare_utp_query_req_upiu(struct ufs_hba *hba, memcpy(&ucd_req_ptr->qr, &query->request.upiu_req, QUERY_OSF_SIZE); /* Copy the Descriptor */ - if (query->request.upiu_req.opcode == UPIU_QUERY_OPCODE_WRITE_DESC) + if (query->request.upiu_req.opcode == UPIU_QUERY_OPCODE_WRITE_DESC) { memcpy(ucd_req_ptr + 1, query->descriptor, len); + ufshcd_cache_flush_and_invalidate(ucd_req_ptr, 2 * sizeof(*ucd_req_ptr)); + } else { + ufshcd_cache_flush_and_invalidate(ucd_req_ptr, sizeof(*ucd_req_ptr)); + } memset(hba->ucd_rsp_ptr, 0, sizeof(struct utp_upiu_rsp)); + ufshcd_cache_flush_and_invalidate(hba->ucd_rsp_ptr, sizeof(*hba->ucd_rsp_ptr)); } static inline void ufshcd_prepare_utp_nop_upiu(struct ufs_hba *hba) @@ -781,6 +805,9 @@ static inline void ufshcd_prepare_utp_nop_upiu(struct ufs_hba *hba) ucd_req_ptr->header.dword_2 = 0; memset(hba->ucd_rsp_ptr, 0, sizeof(struct utp_upiu_rsp)); + + ufshcd_cache_flush_and_invalidate(ucd_req_ptr, sizeof(*ucd_req_ptr)); + ufshcd_cache_flush_and_invalidate(hba->ucd_rsp_ptr, sizeof(*hba->ucd_rsp_ptr)); } /** @@ -792,11 +819,10 @@ static int ufshcd_comp_devman_upiu(struct ufs_hba *hba, { u32 upiu_flags; int ret = 0; - struct utp_transfer_req_desc *req_desc = hba->utrdl; hba->dev_cmd.type = cmd_type; - ufshcd_prepare_req_desc_hdr(req_desc, &upiu_flags, DMA_NONE); + ufshcd_prepare_req_desc_hdr(hba, &upiu_flags, DMA_NONE); switch (cmd_type) { case DEV_CMD_TYPE_QUERY: ufshcd_prepare_utp_query_req_upiu(hba, upiu_flags); @@ -857,7 +883,9 @@ static inline int ufshcd_get_req_rsp(struct utp_upiu_rsp *ucd_rsp_ptr) */ static inline int ufshcd_get_tr_ocs(struct ufs_hba *hba) { - return le32_to_cpu(hba->utrdl->header.dword_2) & MASK_OCS; + struct utp_transfer_req_desc *req_desc = hba->utrdl; + + return le32_to_cpu(req_desc->header.dword_2) & MASK_OCS; } static inline int ufshcd_get_rsp_upiu_result(struct utp_upiu_rsp *ucd_rsp_ptr) @@ -1406,6 +1434,8 @@ void ufshcd_prepare_utp_scsi_cmd_upiu(struct ufs_hba *hba, memcpy(ucd_req_ptr->sc.cdb, pccb->cmd, cdb_len); memset(hba->ucd_rsp_ptr, 0, sizeof(struct utp_upiu_rsp)); + ufshcd_cache_flush_and_invalidate(ucd_req_ptr, sizeof(*ucd_req_ptr)); + ufshcd_cache_flush_and_invalidate(hba->ucd_rsp_ptr, sizeof(*hba->ucd_rsp_ptr)); } static inline void prepare_prdt_desc(struct ufshcd_sg_entry *entry, @@ -1420,6 +1450,7 @@ static void prepare_prdt_table(struct ufs_hba *hba, struct scsi_cmd *pccb) { struct utp_transfer_req_desc *req_desc = hba->utrdl; struct ufshcd_sg_entry *prd_table = hba->ucd_prdt_ptr; + uintptr_t aaddr = (uintptr_t)(pccb->pdata) & ~(ARCH_DMA_MINALIGN - 1); ulong datalen = pccb->datalen; int table_length; u8 *buf; @@ -1427,9 +1458,19 @@ static void prepare_prdt_table(struct ufs_hba *hba, struct scsi_cmd *pccb) if (!datalen) { req_desc->prd_table_length = 0; + ufshcd_cache_flush_and_invalidate(req_desc, sizeof(*req_desc)); return; } + if (pccb->dma_dir == DMA_TO_DEVICE) { /* Write to device */ + flush_dcache_range(aaddr, aaddr + + ALIGN(datalen, ARCH_DMA_MINALIGN)); + } + + /* In any case, invalidate cache to avoid stale data in it. */ + invalidate_dcache_range(aaddr, aaddr + + ALIGN(datalen, ARCH_DMA_MINALIGN)); + table_length = DIV_ROUND_UP(pccb->datalen, MAX_PRDT_ENTRY); buf = pccb->pdata; i = table_length; @@ -1443,17 +1484,18 @@ static void prepare_prdt_table(struct ufs_hba *hba, struct scsi_cmd *pccb) prepare_prdt_desc(&prd_table[table_length - i - 1], buf, datalen - 1); req_desc->prd_table_length = table_length; + ufshcd_cache_flush_and_invalidate(prd_table, sizeof(*prd_table) * table_length); + ufshcd_cache_flush_and_invalidate(req_desc, sizeof(*req_desc)); } static int ufs_scsi_exec(struct udevice *scsi_dev, struct scsi_cmd *pccb) { struct ufs_hba *hba = dev_get_uclass_priv(scsi_dev->parent); - struct utp_transfer_req_desc *req_desc = hba->utrdl; u32 upiu_flags; int ocs, result = 0; u8 scsi_status; - ufshcd_prepare_req_desc_hdr(req_desc, &upiu_flags, pccb->dma_dir); + ufshcd_prepare_req_desc_hdr(hba, &upiu_flags, pccb->dma_dir); ufshcd_prepare_utp_scsi_cmd_upiu(hba, pccb, upiu_flags); prepare_prdt_table(hba, pccb); @@ -1630,8 +1672,13 @@ static int ufshcd_get_max_pwr_mode(struct ufs_hba *hba) if (hba->max_pwr_info.is_valid) return 0; - pwr_info->pwr_tx = FAST_MODE; - pwr_info->pwr_rx = FAST_MODE; + if (hba->quirks & UFSHCD_QUIRK_HIBERN_FASTAUTO) { + pwr_info->pwr_tx = FASTAUTO_MODE; + pwr_info->pwr_rx = FASTAUTO_MODE; + } else { + pwr_info->pwr_tx = FAST_MODE; + pwr_info->pwr_rx = FAST_MODE; + } pwr_info->hs_rate = PA_HS_MODE_B; /* Get the connected lane count */ @@ -1889,13 +1936,16 @@ int ufshcd_probe(struct udevice *ufs_dev, struct ufs_hba_ops *hba_ops) /* Read capabilties registers */ hba->capabilities = ufshcd_readl(hba, REG_CONTROLLER_CAPABILITIES); + if (hba->quirks & UFSHCD_QUIRK_BROKEN_64BIT_ADDRESS) + hba->capabilities &= ~MASK_64_ADDRESSING_SUPPORT; /* Get UFS version supported by the controller */ hba->version = ufshcd_get_ufs_version(hba); if (hba->version != UFSHCI_VERSION_10 && hba->version != UFSHCI_VERSION_11 && hba->version != UFSHCI_VERSION_20 && - hba->version != UFSHCI_VERSION_21) + hba->version != UFSHCI_VERSION_21 && + hba->version != UFSHCI_VERSION_30) dev_err(hba->dev, "invalid UFS version 0x%x\n", hba->version); @@ -1942,8 +1992,31 @@ int ufs_scsi_bind(struct udevice *ufs_dev, struct udevice **scsi_devp) return ret; } +#if IS_ENABLED(CONFIG_BOUNCE_BUFFER) +static int ufs_scsi_buffer_aligned(struct udevice *scsi_dev, struct bounce_buffer *state) +{ +#ifdef CONFIG_PHYS_64BIT + struct ufs_hba *hba = dev_get_uclass_priv(scsi_dev->parent); + uintptr_t ubuf = (uintptr_t)state->user_buffer; + size_t len = state->len_aligned; + + /* Check if below 32bit boundary */ + if ((hba->quirks & UFSHCD_QUIRK_BROKEN_64BIT_ADDRESS) && + ((ubuf >> 32) || (ubuf + len) >> 32)) { + dev_dbg(scsi_dev, "Buffer above 32bit boundary %lx-%lx\n", + ubuf, ubuf + len); + return 0; + } +#endif + return 1; +} +#endif /* CONFIG_BOUNCE_BUFFER */ + static struct scsi_ops ufs_ops = { .exec = ufs_scsi_exec, +#if IS_ENABLED(CONFIG_BOUNCE_BUFFER) + .buffer_aligned = ufs_scsi_buffer_aligned, +#endif /* CONFIG_BOUNCE_BUFFER */ }; int ufs_probe_dev(int index) diff --git a/drivers/ufs/ufs.h b/drivers/ufs/ufs.h index 8a38832b05f..9daaf03d222 100644 --- a/drivers/ufs/ufs.h +++ b/drivers/ufs/ufs.h @@ -717,7 +717,19 @@ struct ufs_hba { * the LCC transmission on UFS device (by clearing TX_LCC_ENABLE * attribute of device to 0). */ -#define UFSHCD_QUIRK_BROKEN_LCC 0x1 +#define UFSHCD_QUIRK_BROKEN_LCC BIT(0) + +/* + * This quirk needs to be enabled if the host controller has + * 64-bit addressing supported capability but it doesn't work. + */ +#define UFSHCD_QUIRK_BROKEN_64BIT_ADDRESS BIT(1) + +/* + * This quirk needs to be enabled if the host controller has + * auto-hibernate capability but it's FASTAUTO only. + */ +#define UFSHCD_QUIRK_HIBERN_FASTAUTO BIT(2) /* Virtual memory reference */ struct utp_transfer_cmd_desc *ucdl; @@ -769,6 +781,7 @@ enum { UFSHCI_VERSION_11 = 0x00010100, /* 1.1 */ UFSHCI_VERSION_20 = 0x00000200, /* 2.0 */ UFSHCI_VERSION_21 = 0x00000210, /* 2.1 */ + UFSHCI_VERSION_30 = 0x00000300, /* 3.0 */ }; /* Interrupt disable masks */ diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c index cae570cf598..7aa0c6b2bee 100644 --- a/drivers/usb/cdns3/gadget.c +++ b/drivers/usb/cdns3/gadget.c @@ -62,6 +62,7 @@ #include <linux/bitops.h> #include <linux/delay.h> #include <linux/err.h> +#include <linux/printk.h> #include <linux/usb/gadget.h> #include <linux/compat.h> #include <linux/iopoll.h> diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c index cff86a51ae0..7137a569d97 100644 --- a/drivers/usb/common/common.c +++ b/drivers/usb/common/common.c @@ -9,6 +9,7 @@ #include <common.h> #include <dm.h> #include <asm/global_data.h> +#include <linux/printk.h> #include <linux/usb/otg.h> #include <linux/usb/ch9.h> #include <linux/usb/phy.h> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 49f6a1900b0..7ca9d09824e 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -986,18 +986,18 @@ void dwc3_uboot_exit(int index) /** * dwc3_uboot_handle_interrupt - handle dwc3 core interrupt - * @index: index of this controller + * @dev: device of this controller * * Invokes dwc3 gadget interrupts. * * Generally called from board file. */ -void dwc3_uboot_handle_interrupt(int index) +void dwc3_uboot_handle_interrupt(struct udevice *dev) { struct dwc3 *dwc = NULL; list_for_each_entry(dwc, &dwc3_list, list) { - if (dwc->index != index) + if (dwc->dev != dev) continue; dwc3_gadget_uboot_handle_interrupt(dwc); diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c index 7f0af05855a..744fde80694 100644 --- a/drivers/usb/dwc3/dwc3-generic.c +++ b/drivers/usb/dwc3/dwc3-generic.c @@ -17,6 +17,7 @@ #include <generic-phy.h> #include <linux/bitops.h> #include <linux/delay.h> +#include <linux/printk.h> #include <linux/usb/ch9.h> #include <linux/usb/gadget.h> #include <malloc.h> @@ -541,8 +542,6 @@ int dwc3_glue_probe(struct udevice *dev) } else if (ret != -ENOENT && ret != -ENODATA) { debug("could not get phy (err %d)\n", ret); return ret; - } else { - phy.dev = NULL; } glue->regs = dev_read_addr_size_index(dev, 0, &glue->size); @@ -555,7 +554,7 @@ int dwc3_glue_probe(struct udevice *dev) if (ret) return ret; - if (phy.dev) { + if (generic_phy_valid(&phy)) { ret = generic_phy_power_on(&phy); if (ret) return ret; diff --git a/drivers/usb/dwc3/dwc3-meson-g12a.c b/drivers/usb/dwc3/dwc3-meson-g12a.c index c62e42de73f..dc5a976f71a 100644 --- a/drivers/usb/dwc3/dwc3-meson-g12a.c +++ b/drivers/usb/dwc3/dwc3-meson-g12a.c @@ -15,6 +15,7 @@ #include <dwc3-uboot.h> #include <generic-phy.h> #include <linux/delay.h> +#include <linux/printk.h> #include <linux/usb/ch9.h> #include <linux/usb/gadget.h> #include <malloc.h> diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c index 9596bf144c3..ff4ebfb4447 100644 --- a/drivers/usb/dwc3/dwc3-omap.c +++ b/drivers/usb/dwc3/dwc3-omap.c @@ -119,7 +119,7 @@ #define USBOTGSS_UTMI_OTG_STATUS_VBUSVALID (1 << 1) struct dwc3_omap { - struct device *dev; + struct udevice *dev; void __iomem *base; @@ -429,19 +429,19 @@ void dwc3_omap_uboot_exit(int index) /** * dwc3_omap_uboot_interrupt_status - check the status of interrupt - * @index: index of this controller + * @dev: device of this controller * * Checks the status of interrupts and returns true if an interrupt * is detected or false otherwise. * * Generally called from board file. */ -int dwc3_omap_uboot_interrupt_status(int index) +int dwc3_omap_uboot_interrupt_status(struct udevice *dev) { struct dwc3_omap *omap = NULL; list_for_each_entry(omap, &dwc3_omap_list, list) - if (omap->index == index) + if (omap->dev == dev) return dwc3_omap_interrupt(-1, omap); return 0; diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index eb416b832aa..68cf32cd189 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -24,6 +24,7 @@ #include <linux/delay.h> #include <linux/dma-mapping.h> #include <linux/list.h> +#include <linux/printk.h> #include <linux/usb/ch9.h> #include <linux/usb/gadget.h> diff --git a/drivers/usb/eth/mcs7830.c b/drivers/usb/eth/mcs7830.c index 8a256b3e346..d94204f22d5 100644 --- a/drivers/usb/eth/mcs7830.c +++ b/drivers/usb/eth/mcs7830.c @@ -19,6 +19,7 @@ #include <malloc.h> #include <memalign.h> #include <usb.h> +#include <linux/printk.h> #include "usb_ether.h" diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 1cfe6022842..4eccc5e3370 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -160,7 +160,7 @@ config USB_GADGET_VBUS_DRAW config SDP_LOADADDR hex "Default load address at SDP_WRITE and SDP_JUMP" - default 0 + default 0x0 # Selected by UDC drivers that support high-speed operation. config USB_GADGET_DUALSPEED diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index 1feed417d68..e573a03477b 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c @@ -21,6 +21,7 @@ #include <asm/io.h> #include <asm/gpio.h> #include <asm/hardware.h> +#include <linux/printk.h> #include <mach/at91_matrix.h> #include <linux/list.h> #include <linux/usb/ch9.h> @@ -1429,7 +1430,7 @@ static const struct at91_udc_caps at91sam9261_udc_caps = { }; #endif -int usb_gadget_handle_interrupts(int index) +int dm_usb_gadget_handle_interrupts(struct udevice *dev) { struct at91_udc *udc = controller; diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c index 7d51821497b..f16731c8ebd 100644 --- a/drivers/usb/gadget/atmel_usba_udc.c +++ b/drivers/usb/gadget/atmel_usba_udc.c @@ -13,6 +13,7 @@ #include <asm/gpio.h> #include <asm/hardware.h> #include <linux/list.h> +#include <linux/printk.h> #include <linux/usb/ch9.h> #include <linux/usb/gadget.h> #include <linux/usb/atmel_usba_udc.h> @@ -1198,14 +1199,13 @@ static struct usba_udc controller = { }, }; -int usb_gadget_handle_interrupts(int index) +int dm_usb_gadget_handle_interrupts(struct udevice *dev) { struct usba_udc *udc = &controller; return usba_udc_irq(udc); } - int usb_gadget_register_driver(struct usb_gadget_driver *driver) { struct usba_udc *udc = &controller; diff --git a/drivers/usb/gadget/ci_udc.c b/drivers/usb/gadget/ci_udc.c index b9258d73575..2bfacfe59f9 100644 --- a/drivers/usb/gadget/ci_udc.c +++ b/drivers/usb/gadget/ci_udc.c @@ -869,10 +869,10 @@ void udc_irq(void) } } -int usb_gadget_handle_interrupts(int index) +int dm_usb_gadget_handle_interrupts(struct udevice *dev) { - u32 value; struct ci_udc *udc = (struct ci_udc *)controller.ctrl->hcor; + u32 value; value = readl(&udc->usbsts); if (value) diff --git a/drivers/usb/gadget/dwc2_udc_otg.c b/drivers/usb/gadget/dwc2_udc_otg.c index 2bf7ed8d604..27082f5152c 100644 --- a/drivers/usb/gadget/dwc2_udc_otg.c +++ b/drivers/usb/gadget/dwc2_udc_otg.c @@ -28,6 +28,7 @@ #include <dm/devres.h> #include <linux/bug.h> #include <linux/delay.h> +#include <linux/printk.h> #include <linux/errno.h> #include <linux/list.h> @@ -941,15 +942,12 @@ int dwc2_udc_handle_interrupt(void) return 0; } -#if !CONFIG_IS_ENABLED(DM_USB_GADGET) - -int usb_gadget_handle_interrupts(int index) +int dm_usb_gadget_handle_interrupts(struct udevice *dev) { return dwc2_udc_handle_interrupt(); } -#else /* CONFIG_IS_ENABLED(DM_USB_GADGET) */ - +#if CONFIG_IS_ENABLED(DM_USB_GADGET) struct dwc2_priv_data { struct clk_bulk clks; struct reset_ctl_bulk resets; @@ -957,11 +955,6 @@ struct dwc2_priv_data { struct udevice *usb33d_supply; }; -int dm_usb_gadget_handle_interrupts(struct udevice *dev) -{ - return dwc2_udc_handle_interrupt(); -} - static int dwc2_phy_setup(struct udevice *dev, struct phy_bulk *phys) { int ret; diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 5ff06d3814b..36618f0bdf3 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -14,6 +14,7 @@ #include <part.h> #include <linux/errno.h> #include <linux/netdevice.h> +#include <linux/printk.h> #include <linux/usb/ch9.h> #include <linux/usb/cdc.h> #include <linux/usb/gadget.h> @@ -1880,8 +1881,10 @@ static void eth_start(struct eth_dev *dev, gfp_t gfp_flags) } } -static int eth_stop(struct eth_dev *dev) +static int eth_stop(struct udevice *udev) { + struct ether_priv *priv = dev_get_priv(udev); + struct eth_dev *dev = &priv->ethdev; #ifdef RNDIS_COMPLETE_SIGNAL_DISCONNECT unsigned long ts; unsigned long timeout = CONFIG_SYS_HZ; /* 1 sec to stop RNDIS */ @@ -1895,7 +1898,7 @@ static int eth_stop(struct eth_dev *dev) /* Wait until host receives OID_GEN_MEDIA_CONNECT_STATUS */ ts = get_timer(0); while (get_timer(ts) < timeout) - usb_gadget_handle_interrupts(0); + dm_usb_gadget_handle_interrupts(udev->parent); #endif rndis_uninit(dev->rndis_config); @@ -2300,7 +2303,7 @@ static int usb_eth_start(struct udevice *udev) pr_err("The remote end did not respond in time."); goto fail; } - usb_gadget_handle_interrupts(0); + dm_usb_gadget_handle_interrupts(udev->parent); } packet_received = 0; @@ -2370,7 +2373,7 @@ static int usb_eth_send(struct udevice *udev, void *packet, int length) printf("timeout sending packets to usb ethernet\n"); return -1; } - usb_gadget_handle_interrupts(0); + dm_usb_gadget_handle_interrupts(udev->parent); } free(rndis_pkt); @@ -2400,13 +2403,13 @@ static void usb_eth_stop(struct udevice *udev) * 2) 'pullup' callback in your UDC driver can be improved to perform * this deinitialization. */ - eth_stop(dev); + eth_stop(udev); usb_gadget_disconnect(dev->gadget); /* Clear pending interrupt */ if (dev->network_started) { - usb_gadget_handle_interrupts(0); + dm_usb_gadget_handle_interrupts(udev->parent); dev->network_started = 0; } } @@ -2416,7 +2419,7 @@ static int usb_eth_recv(struct udevice *dev, int flags, uchar **packetp) struct ether_priv *priv = dev_get_priv(dev); struct eth_dev *ethdev = &priv->ethdev; - usb_gadget_handle_interrupts(0); + dm_usb_gadget_handle_interrupts(dev->parent); if (packet_received) { if (ethdev->rx_req) { @@ -2467,7 +2470,7 @@ int usb_ether_init(void) return ret; } - return usb_gadget_initialize(0); + return 0; } static int usb_eth_probe(struct udevice *dev) @@ -2528,7 +2531,7 @@ static int usb_eth_remove(struct udevice *dev) static int usb_eth_unbind(struct udevice *dev) { - usb_gadget_release(0); + udc_device_put(dev->parent); return 0; } diff --git a/drivers/usb/gadget/f_acm.c b/drivers/usb/gadget/f_acm.c index b2ddd1ada8b..de42e0189e8 100644 --- a/drivers/usb/gadget/f_acm.c +++ b/drivers/usb/gadget/f_acm.c @@ -51,7 +51,7 @@ struct f_acm { #define ACM_CTRL_RTS BIT(1) /* unused with full duplex */ #define ACM_CTRL_DTR BIT(0) /* host is ready for data r/w */ - int controller_index; + struct udevice *udc; }; static struct f_acm *default_acm_function; @@ -489,7 +489,7 @@ static void __acm_tx(struct f_acm *f_acm) int len, ret; do { - usb_gadget_handle_interrupts(f_acm->controller_index); + dm_usb_gadget_handle_interrupts(f_acm->udc); if (!(f_acm->handshake_bits & ACM_CTRL_DTR)) break; @@ -520,7 +520,7 @@ static bool acm_connected(struct stdio_dev *dev) struct f_acm *f_acm = stdio_to_acm(dev); /* give a chance to process udc irq */ - usb_gadget_handle_interrupts(f_acm->controller_index); + dm_usb_gadget_handle_interrupts(f_acm->udc); return f_acm->connected; } @@ -543,7 +543,10 @@ static int acm_add(struct usb_configuration *c) f_acm->usb_function.descriptors = acm_fs_function; f_acm->usb_function.hs_descriptors = acm_hs_function; f_acm->usb_function.setup = acm_setup; - f_acm->controller_index = 0; + + status = udc_device_get_by_index(0, &f_acm->udc); + if (status) + return status; status = usb_add_function(c, &f_acm->usb_function); if (status) { @@ -567,7 +570,7 @@ static int acm_stdio_tstc(struct stdio_dev *dev) { struct f_acm *f_acm = stdio_to_acm(dev); - usb_gadget_handle_interrupts(f_acm->controller_index); + dm_usb_gadget_handle_interrupts(f_acm->udc); return (f_acm->rx_buf.size > 0); } diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 6d97b4bbdc3..741775a7bcf 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -17,6 +17,7 @@ #include <fastboot.h> #include <log.h> #include <malloc.h> +#include <linux/printk.h> #include <linux/usb/ch9.h> #include <linux/usb/gadget.h> #include <linux/usb/composite.h> diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index f46829eb7ad..1d17331cb03 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -435,7 +435,7 @@ static void set_bulk_out_req_length(struct fsg_common *common, static struct ums *ums; static int ums_count; static struct fsg_common *the_fsg_common; -static unsigned int controller_index; +static struct udevice *udcdev; static int fsg_set_halt(struct fsg_dev *fsg, struct usb_ep *ep) { @@ -680,7 +680,7 @@ static int sleep_thread(struct fsg_common *common) k = 0; } - usb_gadget_handle_interrupts(controller_index); + dm_usb_gadget_handle_interrupts(udcdev); } common->thread_wakeup_needed = 0; return rc; @@ -2764,11 +2764,11 @@ int fsg_add(struct usb_configuration *c) return fsg_bind_config(c->cdev, c, fsg_common); } -int fsg_init(struct ums *ums_devs, int count, unsigned int controller_idx) +int fsg_init(struct ums *ums_devs, int count, struct udevice *udc) { ums = ums_devs; ums_count = count; - controller_index = controller_idx; + udcdev = udc; return 0; } diff --git a/drivers/usb/gadget/f_sdp.c b/drivers/usb/gadget/f_sdp.c index 4da5a160a09..2b3a9c5fd4c 100644 --- a/drivers/usb/gadget/f_sdp.c +++ b/drivers/usb/gadget/f_sdp.c @@ -22,6 +22,7 @@ #include <env.h> #include <log.h> #include <malloc.h> +#include <linux/printk.h> #include <linux/usb/ch9.h> #include <linux/usb/gadget.h> @@ -702,7 +703,7 @@ static int sdp_bind_config(struct usb_configuration *c) return status; } -int sdp_init(int controller_index) +int sdp_init(struct udevice *udc) { printf("SDP: initialize...\n"); while (!sdp_func->configuration_done) { @@ -712,7 +713,7 @@ int sdp_init(int controller_index) } schedule(); - usb_gadget_handle_interrupts(controller_index); + dm_usb_gadget_handle_interrupts(udc); } return 0; @@ -911,9 +912,9 @@ static void sdp_handle_out_ep(void) } #ifndef CONFIG_SPL_BUILD -int sdp_handle(int controller_index) +int sdp_handle(struct udevice *udc) #else -int spl_sdp_handle(int controller_index, struct spl_image_info *spl_image, +int spl_sdp_handle(struct udevice *udc, struct spl_image_info *spl_image, struct spl_boot_device *bootdev) #endif { @@ -929,7 +930,7 @@ int spl_sdp_handle(int controller_index, struct spl_image_info *spl_image, return 0; schedule(); - usb_gadget_handle_interrupts(controller_index); + dm_usb_gadget_handle_interrupts(udc); #ifdef CONFIG_SPL_BUILD flag = sdp_handle_in_ep(spl_image, bootdev); diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c index 47ef55b2fd3..0e7529dcdbb 100644 --- a/drivers/usb/gadget/f_thor.c +++ b/drivers/usb/gadget/f_thor.c @@ -15,15 +15,17 @@ */ #include <command.h> -#include <errno.h> #include <common.h> #include <console.h> +#include <dm.h> +#include <errno.h> #include <init.h> #include <log.h> #include <malloc.h> #include <memalign.h> #include <version.h> #include <linux/delay.h> +#include <linux/printk.h> #include <linux/usb/ch9.h> #include <linux/usb/gadget.h> #include <linux/usb/composite.h> @@ -34,9 +36,9 @@ #include "f_thor.h" -static void thor_tx_data(unsigned char *data, int len); +static void thor_tx_data(struct udevice *udc, unsigned char *data, int len); static void thor_set_dma(void *addr, int len); -static int thor_rx_data(void); +static int thor_rx_data(struct udevice *udc); static struct f_thor *thor_func; static inline struct f_thor *func_to_thor(struct usb_function *f) @@ -56,15 +58,15 @@ DEFINE_CACHE_ALIGN_BUFFER(char, f_name, F_NAME_BUF_SIZE + 1); static unsigned long long int thor_file_size; static int alt_setting_num; -static void send_rsp(const struct rsp_box *rsp) +static void send_rsp(struct udevice *udc, const struct rsp_box *rsp) { memcpy(thor_tx_data_buf, rsp, sizeof(struct rsp_box)); - thor_tx_data(thor_tx_data_buf, sizeof(struct rsp_box)); + thor_tx_data(udc, thor_tx_data_buf, sizeof(struct rsp_box)); debug("-RSP: %d, %d\n", rsp->rsp, rsp->rsp_data); } -static void send_data_rsp(s32 ack, s32 count) +static void send_data_rsp(struct udevice *udc, s32 ack, s32 count) { ALLOC_CACHE_ALIGN_BUFFER(struct data_rsp_box, rsp, sizeof(struct data_rsp_box)); @@ -73,12 +75,12 @@ static void send_data_rsp(s32 ack, s32 count) rsp->count = count; memcpy(thor_tx_data_buf, rsp, sizeof(struct data_rsp_box)); - thor_tx_data(thor_tx_data_buf, sizeof(struct data_rsp_box)); + thor_tx_data(udc, thor_tx_data_buf, sizeof(struct data_rsp_box)); debug("-DATA RSP: %d, %d\n", ack, count); } -static int process_rqt_info(const struct rqt_box *rqt) +static int process_rqt_info(struct udevice *udc, const struct rqt_box *rqt) { ALLOC_CACHE_ALIGN_BUFFER(struct rsp_box, rsp, sizeof(struct rsp_box)); memset(rsp, 0, sizeof(struct rsp_box)); @@ -111,11 +113,11 @@ static int process_rqt_info(const struct rqt_box *rqt) return -EINVAL; } - send_rsp(rsp); + send_rsp(udc, rsp); return true; } -static int process_rqt_cmd(const struct rqt_box *rqt) +static int process_rqt_cmd(struct udevice *udc, const struct rqt_box *rqt) { ALLOC_CACHE_ALIGN_BUFFER(struct rsp_box, rsp, sizeof(struct rsp_box)); memset(rsp, 0, sizeof(struct rsp_box)); @@ -126,7 +128,7 @@ static int process_rqt_cmd(const struct rqt_box *rqt) switch (rqt->rqt_data) { case RQT_CMD_REBOOT: debug("TARGET RESET\n"); - send_rsp(rsp); + send_rsp(udc, rsp); g_dnl_unregister(); dfu_free_entities(); #ifdef CONFIG_THOR_RESET_OFF @@ -136,7 +138,7 @@ static int process_rqt_cmd(const struct rqt_box *rqt) break; case RQT_CMD_POWEROFF: case RQT_CMD_EFSCLEAR: - send_rsp(rsp); + send_rsp(udc, rsp); default: printf("Command not supported -> cmd: %d\n", rqt->rqt_data); return -EINVAL; @@ -145,7 +147,8 @@ static int process_rqt_cmd(const struct rqt_box *rqt) return true; } -static long long int download_head(unsigned long long total, +static long long int download_head(struct udevice *udc, + unsigned long long total, unsigned int packet_size, long long int *left, int *cnt) @@ -166,7 +169,7 @@ static long long int download_head(unsigned long long total, while (total - rcv_cnt >= packet_size) { thor_set_dma(buf, packet_size); buf += packet_size; - ret_rcv = thor_rx_data(); + ret_rcv = thor_rx_data(udc); if (ret_rcv < 0) return ret_rcv; rcv_cnt += ret_rcv; @@ -184,7 +187,7 @@ static long long int download_head(unsigned long long total, } buf = transfer_buffer; } - send_data_rsp(0, ++usb_pkt_cnt); + send_data_rsp(udc, 0, ++usb_pkt_cnt); } /* Calculate the amount of data to arrive from PC (in bytes) */ @@ -200,11 +203,11 @@ static long long int download_head(unsigned long long total, if (left_to_rcv) { thor_set_dma(buf, packet_size); - ret_rcv = thor_rx_data(); + ret_rcv = thor_rx_data(udc); if (ret_rcv < 0) return ret_rcv; rcv_cnt += ret_rcv; - send_data_rsp(0, ++usb_pkt_cnt); + send_data_rsp(udc, 0, ++usb_pkt_cnt); } debug("%s: %llu total: %llu cnt: %d\n", __func__, rcv_cnt, total, *cnt); @@ -254,7 +257,7 @@ static int download_tail(long long int left, int cnt) return ret; } -static long long int process_rqt_download(const struct rqt_box *rqt) +static long long int process_rqt_download(struct udevice *udc, const struct rqt_box *rqt) { ALLOC_CACHE_ALIGN_BUFFER(struct rsp_box, rsp, sizeof(struct rsp_box)); static long long int left, ret_head; @@ -301,8 +304,8 @@ static long long int process_rqt_download(const struct rqt_box *rqt) } break; case RQT_DL_FILE_START: - send_rsp(rsp); - ret_head = download_head(thor_file_size, THOR_PACKET_SIZE, + send_rsp(udc, rsp); + ret_head = download_head(udc, thor_file_size, THOR_PACKET_SIZE, &left, &cnt); if (ret_head < 0) { left = 0; @@ -324,11 +327,11 @@ static long long int process_rqt_download(const struct rqt_box *rqt) ret = -ENOTSUPP; } - send_rsp(rsp); + send_rsp(udc, rsp); return ret; } -static int process_data(void) +static int process_data(struct udevice *udc) { ALLOC_CACHE_ALIGN_BUFFER(struct rqt_box, rqt, sizeof(struct rqt_box)); int ret = -EINVAL; @@ -339,13 +342,13 @@ static int process_data(void) switch (rqt->rqt) { case RQT_INFO: - ret = process_rqt_info(rqt); + ret = process_rqt_info(udc, rqt); break; case RQT_CMD: - ret = process_rqt_cmd(rqt); + ret = process_rqt_cmd(udc, rqt); break; case RQT_DL: - ret = (int) process_rqt_download(rqt); + ret = (int) process_rqt_download(udc, rqt); break; case RQT_UL: puts("RQT: UPLOAD not supported!\n"); @@ -536,7 +539,7 @@ static struct usb_request *alloc_ep_req(struct usb_ep *ep, unsigned length) return req; } -static int thor_rx_data(void) +static int thor_rx_data(struct udevice *udc) { struct thor_dev *dev = thor_func->dev; int data_to_rx, tmp, status; @@ -557,7 +560,7 @@ static int thor_rx_data(void) } while (!dev->rxdata) { - usb_gadget_handle_interrupts(0); + dm_usb_gadget_handle_interrupts(udc); if (ctrlc()) return -1; } @@ -568,7 +571,7 @@ static int thor_rx_data(void) return tmp; } -static void thor_tx_data(unsigned char *data, int len) +static void thor_tx_data(struct udevice *udc, unsigned char *data, int len) { struct thor_dev *dev = thor_func->dev; unsigned char *ptr = dev->in_req->buf; @@ -591,7 +594,7 @@ static void thor_tx_data(unsigned char *data, int len) /* Wait until tx interrupt received */ while (!dev->txdata) - usb_gadget_handle_interrupts(0); + dm_usb_gadget_handle_interrupts(udc); dev->txdata = 0; } @@ -685,18 +688,18 @@ static void thor_set_dma(void *addr, int len) dev->out_req->length = len; } -int thor_init(void) +int thor_init(struct udevice *udc) { struct thor_dev *dev = thor_func->dev; /* Wait for a device enumeration and configuration settings */ debug("THOR enumeration/configuration setting....\n"); while (!dev->configuration_done) - usb_gadget_handle_interrupts(0); + dm_usb_gadget_handle_interrupts(udc); thor_set_dma(thor_rx_data_buf, strlen("THOR")); /* detect the download request from Host PC */ - if (thor_rx_data() < 0) { + if (thor_rx_data(udc) < 0) { printf("%s: Data not received!\n", __func__); return -1; } @@ -706,7 +709,7 @@ int thor_init(void) udelay(30 * 1000); /* 30 ms */ strcpy((char *)thor_tx_data_buf, "ROHT"); - thor_tx_data(thor_tx_data_buf, strlen("ROHT")); + thor_tx_data(udc, thor_tx_data_buf, strlen("ROHT")); } else { puts("Wrong reply information\n"); return -1; @@ -715,17 +718,17 @@ int thor_init(void) return 0; } -int thor_handle(void) +int thor_handle(struct udevice *udc) { int ret; /* receive the data from Host PC */ while (1) { thor_set_dma(thor_rx_data_buf, sizeof(struct rqt_box)); - ret = thor_rx_data(); + ret = thor_rx_data(udc); if (ret > 0) { - ret = process_data(); + ret = process_data(udc); #ifdef CONFIG_THOR_RESET_OFF if (ret == RESET_DONE) break; diff --git a/drivers/usb/gadget/udc/Makefile b/drivers/usb/gadget/udc/Makefile index 95dbf0c82ee..467c566f6d3 100644 --- a/drivers/usb/gadget/udc/Makefile +++ b/drivers/usb/gadget/udc/Makefile @@ -7,4 +7,4 @@ obj-$(CONFIG_USB_DWC3_GADGET) += udc-core.o endif obj-$(CONFIG_$(SPL_)DM_USB_GADGET) += udc-core.o -obj-$(CONFIG_$(SPL_)DM) += udc-uclass.o +obj-y += udc-uclass.o diff --git a/drivers/usb/gadget/udc/udc-uclass.c b/drivers/usb/gadget/udc/udc-uclass.c index de8861829c7..3e433129ace 100644 --- a/drivers/usb/gadget/udc/udc-uclass.c +++ b/drivers/usb/gadget/udc/udc-uclass.c @@ -9,58 +9,58 @@ #include <common.h> #include <dm.h> #include <dm/device-internal.h> +#include <linux/printk.h> #include <linux/usb/gadget.h> #if CONFIG_IS_ENABLED(DM_USB_GADGET) -#define MAX_UDC_DEVICES 4 -static struct udevice *dev_array[MAX_UDC_DEVICES]; -int usb_gadget_initialize(int index) +int udc_device_get_by_index(int index, struct udevice **udev) { - int ret; struct udevice *dev = NULL; + int ret; - if (index < 0 || index >= ARRAY_SIZE(dev_array)) - return -EINVAL; - if (dev_array[index]) - return 0; ret = uclass_get_device_by_seq(UCLASS_USB_GADGET_GENERIC, index, &dev); - if (!dev || ret) { - ret = uclass_get_device(UCLASS_USB_GADGET_GENERIC, index, &dev); - if (!dev || ret) { - pr_err("No USB device found\n"); - return -ENODEV; - } + if (!ret && dev) { + *udev = dev; + return 0; + } + + ret = uclass_get_device(UCLASS_USB_GADGET_GENERIC, index, &dev); + if (!ret && dev) { + *udev = dev; + return 0; } - dev_array[index] = dev; - return 0; + + pr_err("No USB device found\n"); + return -ENODEV; } -int usb_gadget_release(int index) +int udc_device_put(struct udevice *udev) { #if CONFIG_IS_ENABLED(DM_DEVICE_REMOVE) - int ret; - if (index < 0 || index >= ARRAY_SIZE(dev_array)) - return -EINVAL; - - ret = device_remove(dev_array[index], DM_REMOVE_NORMAL); - if (!ret) - dev_array[index] = NULL; - return ret; + return device_remove(udev, DM_REMOVE_NORMAL); #else return -ENOSYS; #endif } +#else +/* Backwards hardware compatibility -- switch to DM_USB_GADGET */ +static int legacy_index; +int udc_device_get_by_index(int index, struct udevice **udev) +{ + legacy_index = index; + return board_usb_init(index, USB_INIT_DEVICE); +} -int usb_gadget_handle_interrupts(int index) +int udc_device_put(struct udevice *udev) { - if (index < 0 || index >= ARRAY_SIZE(dev_array)) - return -EINVAL; - return dm_usb_gadget_handle_interrupts(dev_array[index]); + return board_usb_cleanup(legacy_index, USB_INIT_DEVICE); } #endif +#if CONFIG_IS_ENABLED(DM) UCLASS_DRIVER(usb_gadget_generic) = { .id = UCLASS_USB_GADGET_GENERIC, .name = "usb", .flags = DM_UC_FLAG_SEQ_ALIAS, }; +#endif diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c index 9818f9be94e..637eb2dd06f 100644 --- a/drivers/usb/host/dwc2.c +++ b/drivers/usb/host/dwc2.c @@ -194,8 +194,8 @@ static int dwc_vbus_supply_init(struct udevice *dev) return 0; } - ret = regulator_set_enable(priv->vbus_supply, true); - if (ret) { + ret = regulator_set_enable_if_allowed(priv->vbus_supply, true); + if (ret && ret != -ENOSYS) { dev_err(dev, "Error enabling vbus supply\n"); return ret; } @@ -208,12 +208,10 @@ static int dwc_vbus_supply_exit(struct udevice *dev) struct dwc2_priv *priv = dev_get_priv(dev); int ret; - if (priv->vbus_supply) { - ret = regulator_set_enable(priv->vbus_supply, false); - if (ret) { - dev_err(dev, "Error disabling vbus supply\n"); - return ret; - } + ret = regulator_set_enable_if_allowed(priv->vbus_supply, false); + if (ret && ret != -ENOSYS) { + dev_err(dev, "Error disabling vbus supply\n"); + return ret; } return 0; diff --git a/drivers/usb/host/dwc3-sti-glue.c b/drivers/usb/host/dwc3-sti-glue.c index 239b671ac38..4a3ab611127 100644 --- a/drivers/usb/host/dwc3-sti-glue.c +++ b/drivers/usb/host/dwc3-sti-glue.c @@ -17,6 +17,7 @@ #include <reset-uclass.h> #include <syscon.h> #include <usb.h> +#include <linux/printk.h> #include <linux/usb/dwc3.h> #include <linux/usb/otg.h> diff --git a/drivers/usb/host/ehci-generic.c b/drivers/usb/host/ehci-generic.c index a765a307a32..936e30438d9 100644 --- a/drivers/usb/host/ehci-generic.c +++ b/drivers/usb/host/ehci-generic.c @@ -39,14 +39,10 @@ static int ehci_enable_vbus_supply(struct udevice *dev) if (ret && ret != -ENOENT) return ret; - if (priv->vbus_supply) { - ret = regulator_set_enable(priv->vbus_supply, true); - if (ret) { - dev_err(dev, "Error enabling VBUS supply (ret=%d)\n", ret); - return ret; - } - } else { - dev_dbg(dev, "No vbus supply\n"); + ret = regulator_set_enable_if_allowed(priv->vbus_supply, true); + if (ret && ret != -ENOSYS) { + dev_err(dev, "Error enabling VBUS supply (ret=%d)\n", ret); + return ret; } return 0; @@ -54,10 +50,13 @@ static int ehci_enable_vbus_supply(struct udevice *dev) static int ehci_disable_vbus_supply(struct generic_ehci *priv) { - if (priv->vbus_supply) - return regulator_set_enable(priv->vbus_supply, false); - else - return 0; + int ret; + + ret = regulator_set_enable_if_allowed(priv->vbus_supply, false); + if (ret && ret != -ENOSYS) + return ret; + + return 0; } static int ehci_usb_probe(struct udevice *dev) diff --git a/drivers/usb/host/ohci-generic.c b/drivers/usb/host/ohci-generic.c index 2d8d38ce9a4..ceed1911a95 100644 --- a/drivers/usb/host/ohci-generic.c +++ b/drivers/usb/host/ohci-generic.c @@ -16,75 +16,41 @@ struct generic_ohci { ohci_t ohci; - struct clk *clocks; /* clock list */ - struct reset_ctl *resets; /* reset list */ + struct clk_bulk clocks; /* clock list */ + struct reset_ctl_bulk resets; /* reset list */ struct phy phy; - int clock_count; /* number of clock in clock list */ - int reset_count; /* number of reset in reset list */ }; static int ohci_usb_probe(struct udevice *dev) { struct ohci_regs *regs = dev_read_addr_ptr(dev); struct generic_ohci *priv = dev_get_priv(dev); - int i, err, ret, clock_nb, reset_nb; - - err = 0; - priv->clock_count = 0; - clock_nb = dev_count_phandle_with_args(dev, "clocks", "#clock-cells", - 0); - if (clock_nb > 0) { - priv->clocks = devm_kcalloc(dev, clock_nb, sizeof(struct clk), - GFP_KERNEL); - if (!priv->clocks) - return -ENOMEM; - - for (i = 0; i < clock_nb; i++) { - err = clk_get_by_index(dev, i, &priv->clocks[i]); - if (err < 0) - break; - - err = clk_enable(&priv->clocks[i]); - if (err && err != -ENOSYS) { - dev_err(dev, "failed to enable clock %d\n", i); - clk_free(&priv->clocks[i]); - goto clk_err; - } - priv->clock_count++; - } - } else if (clock_nb != -ENOENT) { - dev_err(dev, "failed to get clock phandle(%d)\n", clock_nb); - return clock_nb; + int err, ret; + + ret = clk_get_bulk(dev, &priv->clocks); + if (ret && ret != -ENOENT) { + dev_err(dev, "Failed to get clocks (ret=%d)\n", ret); + return ret; + } + + err = clk_enable_bulk(&priv->clocks); + if (err) { + dev_err(dev, "Failed to enable clocks (err=%d)\n", err); + goto clk_err; } - priv->reset_count = 0; - reset_nb = dev_count_phandle_with_args(dev, "resets", "#reset-cells", - 0); - if (reset_nb > 0) { - priv->resets = devm_kcalloc(dev, reset_nb, - sizeof(struct reset_ctl), - GFP_KERNEL); - if (!priv->resets) - return -ENOMEM; - - for (i = 0; i < reset_nb; i++) { - err = reset_get_by_index(dev, i, &priv->resets[i]); - if (err < 0) - break; - - err = reset_deassert(&priv->resets[i]); - if (err) { - dev_err(dev, "failed to deassert reset %d\n", i); - reset_free(&priv->resets[i]); - goto reset_err; - } - priv->reset_count++; - } - } else if (reset_nb != -ENOENT) { - dev_err(dev, "failed to get reset phandle(%d)\n", reset_nb); + err = reset_get_bulk(dev, &priv->resets); + if (err && err != -ENOENT) { + dev_err(dev, "failed to get resets (err=%d)\n", err); goto clk_err; } + err = reset_deassert_bulk(&priv->resets); + if (err) { + dev_err(dev, "failed to deassert resets (err=%d)\n", err); + goto reset_err; + } + err = generic_setup_phy(dev, &priv->phy, 0); if (err) goto reset_err; @@ -101,13 +67,13 @@ phy_err: dev_err(dev, "failed to shutdown usb phy\n"); reset_err: - ret = reset_release_all(priv->resets, priv->reset_count); + ret = reset_release_bulk(&priv->resets); if (ret) - dev_err(dev, "failed to assert all resets\n"); + dev_err(dev, "failed to release resets (ret=%d)\n", ret); clk_err: - ret = clk_release_all(priv->clocks, priv->clock_count); + ret = clk_release_bulk(&priv->clocks); if (ret) - dev_err(dev, "failed to disable all clocks\n"); + dev_err(dev, "failed to release clocks (ret=%d)\n", ret); return err; } @@ -125,11 +91,11 @@ static int ohci_usb_remove(struct udevice *dev) if (ret) return ret; - ret = reset_release_all(priv->resets, priv->reset_count); + ret = reset_release_bulk(&priv->resets); if (ret) return ret; - return clk_release_all(priv->clocks, priv->clock_count); + return clk_release_bulk(&priv->clocks); } static const struct udevice_id ohci_usb_ids[] = { diff --git a/drivers/usb/host/usb-sandbox.c b/drivers/usb/host/usb-sandbox.c index d1103dcb2e9..3d4f8d653b5 100644 --- a/drivers/usb/host/usb-sandbox.c +++ b/drivers/usb/host/usb-sandbox.c @@ -124,11 +124,12 @@ static int sandbox_submit_int(struct udevice *bus, struct usb_device *udev, return ret; } -int usb_gadget_handle_interrupts(int index) +#if CONFIG_IS_ENABLED(DM_USB_GADGET) +int dm_usb_gadget_handle_interrupts(struct udevice *dev) { return 0; } - +#else int usb_gadget_register_driver(struct usb_gadget_driver *driver) { struct sandbox_udc *dev = this_controller; @@ -144,6 +145,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) return 0; } +#endif static int sandbox_alloc_device(struct udevice *dev, struct usb_device *udev) { diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c index 7a03435ba77..a1cd0ad2d66 100644 --- a/drivers/usb/host/usb-uclass.c +++ b/drivers/usb/host/usb-uclass.c @@ -9,6 +9,7 @@ #define LOG_CATEGORY UCLASS_USB #include <common.h> +#include <bootdev.h> #include <dm.h> #include <errno.h> #include <log.h> @@ -208,6 +209,13 @@ int usb_stop(void) #ifdef CONFIG_USB_STORAGE usb_stor_reset(); #endif + if (CONFIG_IS_ENABLED(BOOTSTD)) { + int ret; + + ret = bootdev_unhunt(UCLASS_USB); + if (IS_ENABLED(CONFIG_BOOTSTD_FULL) && ret && ret != -EALREADY) + printf("failed to unhunt USB (err=%dE)\n", ret); + } uc_priv->companion_device_count = 0; usb_started = 0; @@ -249,6 +257,37 @@ static void remove_inactive_children(struct uclass *uc, struct udevice *bus) } } +static int usb_probe_companion(struct udevice *bus) +{ + struct udevice *companion_dev; + int ret; + + /* + * Enforce optional companion controller is marked as such in order to + * 1st scan the primary controller, before the companion controller + * (ownership is given to companion when low or full speed devices + * have been detected). + */ + ret = uclass_get_device_by_phandle(UCLASS_USB, bus, "companion", &companion_dev); + if (!ret) { + struct usb_bus_priv *companion_bus_priv; + + debug("%s is the companion of %s\n", companion_dev->name, bus->name); + companion_bus_priv = dev_get_uclass_priv(companion_dev); + companion_bus_priv->companion = true; + } else if (ret && ret != -ENOENT && ret != -ENODEV) { + /* + * Treat everything else than no companion or disabled + * companion as an error. (It may not be enabled on boards + * that have a High-Speed HUB to handle FS and LS traffic). + */ + printf("Failed to get companion (ret=%d)\n", ret); + return ret; + } + + return 0; +} + int usb_init(void) { int controllers_initialized = 0; @@ -299,6 +338,11 @@ int usb_init(void) printf("probe failed, error %d\n", ret); continue; } + + ret = usb_probe_companion(bus); + if (ret) + continue; + controllers_initialized++; usb_started = true; } diff --git a/drivers/usb/musb-new/mt85xx.c b/drivers/usb/musb-new/mt85xx.c index 730045cf9a7..1e632dca046 100644 --- a/drivers/usb/musb-new/mt85xx.c +++ b/drivers/usb/musb-new/mt85xx.c @@ -16,6 +16,7 @@ #include <dm/lists.h> #include <dm/root.h> #include <linux/delay.h> +#include <linux/printk.h> #include <linux/usb/musb.h> #include <usb.h> #include "linux-compat.h" diff --git a/drivers/usb/musb-new/musb_core.c b/drivers/usb/musb-new/musb_core.c index a42d98ece9b..00da554982f 100644 --- a/drivers/usb/musb-new/musb_core.c +++ b/drivers/usb/musb-new/musb_core.c @@ -86,6 +86,7 @@ #include <linux/bitops.h> #include <linux/bug.h> #include <linux/errno.h> +#include <linux/printk.h> #include <linux/usb/ch9.h> #include <linux/usb/gadget.h> #include <linux/usb/musb.h> diff --git a/drivers/usb/musb-new/musb_debug.h b/drivers/usb/musb-new/musb_debug.h index c468bda9ff2..94375b72c70 100644 --- a/drivers/usb/musb-new/musb_debug.h +++ b/drivers/usb/musb-new/musb_debug.h @@ -10,6 +10,7 @@ #ifndef __MUSB_LINUX_DEBUG_H__ #define __MUSB_LINUX_DEBUG_H__ +#include <linux/printk.h> #define yprintk(facility, format, args...) \ do { printk(facility "%s %d: " format , \ __func__, __LINE__ , ## args); } while (0) diff --git a/drivers/usb/musb-new/musb_dsps.c b/drivers/usb/musb-new/musb_dsps.c index d55a920ae59..a8ff7434c9f 100644 --- a/drivers/usb/musb-new/musb_dsps.c +++ b/drivers/usb/musb-new/musb_dsps.c @@ -35,6 +35,7 @@ #include <dm.h> #include <dm/device_compat.h> #include <asm/omap_musb.h> +#include <linux/printk.h> #include "linux-compat.h" #endif diff --git a/drivers/usb/musb-new/musb_gadget.c b/drivers/usb/musb-new/musb_gadget.c index 05bd9487857..c6083963ede 100644 --- a/drivers/usb/musb-new/musb_gadget.c +++ b/drivers/usb/musb-new/musb_gadget.c @@ -26,6 +26,7 @@ #include <dm.h> #include <dm/device_compat.h> #include <linux/bug.h> +#include <linux/printk.h> #include <linux/usb/ch9.h> #include "linux-compat.h" #endif diff --git a/drivers/usb/musb-new/musb_gadget_ep0.c b/drivers/usb/musb-new/musb_gadget_ep0.c index 7fdd24005e7..55ce8de99bb 100644 --- a/drivers/usb/musb-new/musb_gadget_ep0.c +++ b/drivers/usb/musb-new/musb_gadget_ep0.c @@ -21,6 +21,7 @@ #include <common.h> #include <dm.h> #include <dm/device_compat.h> +#include <linux/printk.h> #include <asm/processor.h> #include "linux-compat.h" #endif diff --git a/drivers/usb/musb-new/musb_uboot.c b/drivers/usb/musb-new/musb_uboot.c index 62c5e8e5fa4..7cea9a2ed65 100644 --- a/drivers/usb/musb-new/musb_uboot.c +++ b/drivers/usb/musb-new/musb_uboot.c @@ -376,7 +376,7 @@ struct dm_usb_ops musb_usb_ops = { #if defined(CONFIG_USB_MUSB_GADGET) && !CONFIG_IS_ENABLED(DM_USB_GADGET) static struct musb *gadget; -int usb_gadget_handle_interrupts(int index) +int dm_usb_gadget_handle_interrupts(struct udevice *dev) { schedule(); if (!gadget || !gadget->isr) diff --git a/drivers/usb/musb-new/omap2430.c b/drivers/usb/musb-new/omap2430.c index 482dfdc6be6..308eff832c9 100644 --- a/drivers/usb/musb-new/omap2430.c +++ b/drivers/usb/musb-new/omap2430.c @@ -16,6 +16,7 @@ #include <dm/device_compat.h> #include <dm/lists.h> #include <linux/err.h> +#include <linux/printk.h> #include <linux/usb/otg.h> #include <asm/global_data.h> #include <asm/omap_common.h> diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c index 485b9dce156..91f082fe05e 100644 --- a/drivers/usb/musb-new/sunxi.c +++ b/drivers/usb/musb-new/sunxi.c @@ -30,6 +30,7 @@ #include <dm/root.h> #include <linux/bitops.h> #include <linux/delay.h> +#include <linux/printk.h> #include <linux/usb/musb.h> #include "linux-compat.h" #include "musb_core.h" diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c index 3be3f93dd85..ed5e5194d8c 100644 --- a/drivers/usb/musb-new/ti-musb.c +++ b/drivers/usb/musb-new/ti-musb.c @@ -12,6 +12,7 @@ #include <log.h> #include <malloc.h> #include <asm/global_data.h> +#include <linux/printk.h> #include <linux/usb/otg.h> #include <dm/device-internal.h> #include <dm/lists.h> diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 69f4809cf4a..ab927641bb7 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -66,7 +66,7 @@ config VIDEO_PCI_DEFAULT_FB_SIZE hex "Default framebuffer size to use if no drivers request it" default 0x1000000 if X86 default 0x800000 if !X86 && VIDEO_BOCHS - default 0 if !X86 && !VIDEO_BOCHS + default 0x0 if !X86 && !VIDEO_BOCHS help Generally, video drivers request the amount of memory they need for the frame buffer when they are bound, by setting the size field in @@ -959,6 +959,14 @@ config SPLASH_SOURCE endif # SPLASH_SCREEN +config BMP + bool "Enable bmp image display" + help + Enable bmp functions to display bmp image and get bmp info. + + BMP is a simple graphics-image file format designed to store bitmap + images. It is primarily used on Windows devices. + config VIDEO_BMP_GZIP bool "Gzip compressed BMP image support" depends on BMP || SPLASH_SCREEN @@ -1049,7 +1057,7 @@ config SPL_VIDEO_PCI_DEFAULT_FB_SIZE hex "Default framebuffer size to use if no drivers request it at SPL" default 0x1000000 if X86 default 0x800000 if !X86 && VIDEO_BOCHS - default 0 if !X86 && !VIDEO_BOCHS + default 0x0 if !X86 && !VIDEO_BOCHS help Generally, video drivers request the amount of memory they need for the frame buffer when they are bound, by setting the size field in @@ -1162,6 +1170,14 @@ config SPL_SPLASH_SOURCE endif # SPL_SPLASH_SCREEN +config SPL_BMP + bool "Enable bmp image display at SPL" + help + Enable bmp functions to display bmp image and get bmp info in SPL. + + BMP is a simple graphics-image file format designed to store bitmap + images. It is primarily used on Windows devices. + config SPL_VIDEO_BMP_GZIP bool "Gzip compressed BMP image support at SPL" depends on SPL_SPLASH_SCREEN || SPL_BMP diff --git a/drivers/video/Makefile b/drivers/video/Makefile index d13af9f3b19..fdc29376324 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile @@ -25,6 +25,7 @@ obj-$(CONFIG_PANEL_HX8238D) += hx8238d.o obj-$(CONFIG_$(SPL_TPL_)SIMPLE_PANEL) += simple_panel.o obj-$(CONFIG_VIDEO_LOGO) += u_boot_logo.o +obj-$(CONFIG_$(SPL_TPL_)BMP) += bmp.o endif diff --git a/drivers/video/bmp.c b/drivers/video/bmp.c new file mode 100644 index 00000000000..bab6fa7265a --- /dev/null +++ b/drivers/video/bmp.c @@ -0,0 +1,142 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2002 + * Detlev Zundel, DENX Software Engineering, [email protected]. + */ + +/* + * BMP handling routines + */ + +#include <common.h> +#include <bmp_layout.h> +#include <command.h> +#include <dm.h> +#include <gzip.h> +#include <log.h> +#include <malloc.h> +#include <mapmem.h> +#include <splash.h> +#include <video.h> +#include <asm/byteorder.h> + +/* + * Allocate and decompress a BMP image using gunzip(). + * + * Returns a pointer to the decompressed image data. This pointer is + * aligned to 32-bit-aligned-address + 2. + * See doc/README.displaying-bmps for explanation. + * + * The allocation address is passed to 'alloc_addr' and must be freed + * by the caller after use. + * + * Returns NULL if decompression failed, or if the decompressed data + * didn't contain a valid BMP signature or decompression is not enabled in + * Kconfig. + */ +struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp, + void **alloc_addr) +{ + void *dst; + unsigned long len; + struct bmp_image *bmp; + + if (!CONFIG_IS_ENABLED(VIDEO_BMP_GZIP)) + return NULL; + + /* + * Decompress bmp image + */ + len = CONFIG_VAL(VIDEO_LOGO_MAX_SIZE); + /* allocate extra 3 bytes for 32-bit-aligned-address + 2 alignment */ + dst = malloc(CONFIG_VAL(VIDEO_LOGO_MAX_SIZE) + 3); + if (!dst) { + puts("Error: malloc in gunzip failed!\n"); + return NULL; + } + + /* align to 32-bit-aligned-address + 2 */ + bmp = dst + 2; + + if (gunzip(bmp, CONFIG_VAL(VIDEO_LOGO_MAX_SIZE), map_sysmem(addr, 0), + &len)) { + free(dst); + return NULL; + } + if (len == CONFIG_VAL(VIDEO_LOGO_MAX_SIZE)) + puts("Image could be truncated (increase CONFIG_VIDEO_LOGO_MAX_SIZE)!\n"); + + /* + * Check for bmp mark 'BM' + */ + if (!((bmp->header.signature[0] == 'B') && + (bmp->header.signature[1] == 'M'))) { + free(dst); + return NULL; + } + + debug("Gzipped BMP image detected!\n"); + + *alloc_addr = dst; + return bmp; +} + +int bmp_info(ulong addr) +{ + struct bmp_image *bmp = (struct bmp_image *)map_sysmem(addr, 0); + void *bmp_alloc_addr = NULL; + unsigned long len; + + if (!((bmp->header.signature[0] == 'B') && + (bmp->header.signature[1] == 'M'))) + bmp = gunzip_bmp(addr, &len, &bmp_alloc_addr); + + if (!bmp) { + printf("There is no valid bmp file at the given address\n"); + return 1; + } + + printf("Image size : %d x %d\n", le32_to_cpu(bmp->header.width), + le32_to_cpu(bmp->header.height)); + printf("Bits per pixel: %d\n", le16_to_cpu(bmp->header.bit_count)); + printf("Compression : %d\n", le32_to_cpu(bmp->header.compression)); + + if (bmp_alloc_addr) + free(bmp_alloc_addr); + + return 0; +} + +int bmp_display(ulong addr, int x, int y) +{ + struct udevice *dev; + int ret; + struct bmp_image *bmp = map_sysmem(addr, 0); + void *bmp_alloc_addr = NULL; + unsigned long len; + + if (!((bmp->header.signature[0] == 'B') && + (bmp->header.signature[1] == 'M'))) + bmp = gunzip_bmp(addr, &len, &bmp_alloc_addr); + + if (!bmp) { + printf("There is no valid bmp file at the given address\n"); + return 1; + } + addr = map_to_sysmem(bmp); + + ret = uclass_first_device_err(UCLASS_VIDEO, &dev); + if (!ret) { + bool align = false; + + if (x == BMP_ALIGN_CENTER || y == BMP_ALIGN_CENTER) + align = true; + + ret = video_bmp_display(dev, addr, x, y, align); + } + + if (bmp_alloc_addr) + free(bmp_alloc_addr); + + return ret ? CMD_RET_FAILURE : 0; +} diff --git a/drivers/video/coreboot.c b/drivers/video/coreboot.c index c586475e41e..5b718ae3e5a 100644 --- a/drivers/video/coreboot.c +++ b/drivers/video/coreboot.c @@ -73,6 +73,17 @@ err: return ret; } +static int coreboot_video_bind(struct udevice *dev) +{ + struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev); + + /* Set the maximum supported resolution */ + uc_plat->size = 4096 * 2160 * 4; + log_debug("%s: Frame buffer size %x\n", __func__, uc_plat->size); + + return 0; +} + static const struct udevice_id coreboot_video_ids[] = { { .compatible = "coreboot-fb" }, { } @@ -82,5 +93,6 @@ U_BOOT_DRIVER(coreboot_video) = { .name = "coreboot_video", .id = UCLASS_VIDEO, .of_match = coreboot_video_ids, + .bind = coreboot_video_bind, .probe = coreboot_video_probe, }; diff --git a/drivers/video/meson/meson_dw_hdmi.c b/drivers/video/meson/meson_dw_hdmi.c index e5f28132053..5db01904b53 100644 --- a/drivers/video/meson/meson_dw_hdmi.c +++ b/drivers/video/meson/meson_dw_hdmi.c @@ -14,6 +14,7 @@ #include <dm/device-internal.h> #include <dm/uclass-internal.h> #include <linux/bitops.h> +#include <linux/printk.h> #include <power/regulator.h> #include <clk.h> #include <linux/delay.h> diff --git a/drivers/video/meson/meson_vclk.c b/drivers/video/meson/meson_vclk.c index cd1e69040f7..e718a0074ed 100644 --- a/drivers/video/meson/meson_vclk.c +++ b/drivers/video/meson/meson_vclk.c @@ -10,6 +10,7 @@ #include <dm.h> #include <edid.h> #include <linux/bitops.h> +#include <linux/printk.h> #include "meson_vpu.h" #include <log.h> #include <linux/iopoll.h> diff --git a/drivers/video/rockchip/dw_mipi_dsi_rockchip.c b/drivers/video/rockchip/dw_mipi_dsi_rockchip.c index 0852b53ebed..1a5ab781e3f 100644 --- a/drivers/video/rockchip/dw_mipi_dsi_rockchip.c +++ b/drivers/video/rockchip/dw_mipi_dsi_rockchip.c @@ -377,7 +377,7 @@ static int dsi_phy_init(void *priv_data) struct dw_rockchip_dsi_priv *dsi = dev_get_priv(dev); int ret, i, vco; - if (dsi->phy.dev) { + if (generic_phy_valid(&dsi->phy)) { ret = generic_phy_configure(&dsi->phy, &dsi->phy_opts); if (ret) { dev_err(dsi->dsi_host, @@ -559,7 +559,7 @@ dw_mipi_dsi_get_lane_mbps(void *priv_data, struct display_timing *timings, } /* for external phy only the mipi_dphy_config is necessary */ - if (dsi->phy.dev) { + if (generic_phy_valid(&dsi->phy)) { phy_mipi_dphy_get_default_config(timings->pixelclock.typ * 10 / 8, bpp, lanes, &dsi->phy_opts); @@ -859,7 +859,7 @@ static int dw_mipi_dsi_rockchip_probe(struct udevice *dev) } /* Get a ref clock only if not using an external phy. */ - if (priv->phy.dev) { + if (generic_phy_valid(&priv->phy)) { dev_dbg(dev, "setting priv->ref to NULL\n"); priv->ref = NULL; diff --git a/drivers/video/stm32/stm32_dsi.c b/drivers/video/stm32/stm32_dsi.c index a7420fb2ee7..a18c1e027a8 100644 --- a/drivers/video/stm32/stm32_dsi.c +++ b/drivers/video/stm32/stm32_dsi.c @@ -26,6 +26,7 @@ #include <dm/lists.h> #include <linux/bitops.h> #include <linux/iopoll.h> +#include <linux/printk.h> #include <power/regulator.h> #define HWVER_130 0x31333000 /* IP version 1.30 */ diff --git a/drivers/video/stm32/stm32_ltdc.c b/drivers/video/stm32/stm32_ltdc.c index f48badc517a..6fd90e33919 100644 --- a/drivers/video/stm32/stm32_ltdc.c +++ b/drivers/video/stm32/stm32_ltdc.c @@ -20,6 +20,7 @@ #include <dm/device-internal.h> #include <dm/device_compat.h> #include <linux/bitops.h> +#include <linux/printk.h> struct stm32_ltdc_priv { void __iomem *regs; diff --git a/drivers/video/tegra124/sor.c b/drivers/video/tegra124/sor.c index f291db3dc76..258685182c7 100644 --- a/drivers/video/tegra124/sor.c +++ b/drivers/video/tegra124/sor.c @@ -15,6 +15,7 @@ #include <asm/arch/clock.h> #include <asm/arch-tegra/dc.h> #include <linux/delay.h> +#include <linux/printk.h> #include "displayport.h" #include "sor.h" #include <linux/err.h> diff --git a/drivers/watchdog/stm32mp_wdt.c b/drivers/watchdog/stm32mp_wdt.c index 4be616c1b6b..7ebcd255266 100644 --- a/drivers/watchdog/stm32mp_wdt.c +++ b/drivers/watchdog/stm32mp_wdt.c @@ -15,6 +15,7 @@ #include <dm/device_compat.h> #include <linux/bitops.h> #include <linux/iopoll.h> +#include <linux/printk.h> /* IWDG registers */ #define IWDG_KR 0x00 /* Key register */ diff --git a/drivers/watchdog/wdt-uclass.c b/drivers/watchdog/wdt-uclass.c index 509896a1b80..ed329284dec 100644 --- a/drivers/watchdog/wdt-uclass.c +++ b/drivers/watchdog/wdt-uclass.c @@ -236,28 +236,6 @@ void watchdog_reset(void) } #endif -static int wdt_post_bind(struct udevice *dev) -{ -#if defined(CONFIG_NEEDS_MANUAL_RELOC) - struct wdt_ops *ops = (struct wdt_ops *)device_get_ops(dev); - static int reloc_done; - - if (!reloc_done) { - if (ops->start) - ops->start += gd->reloc_off; - if (ops->stop) - ops->stop += gd->reloc_off; - if (ops->reset) - ops->reset += gd->reloc_off; - if (ops->expire_now) - ops->expire_now += gd->reloc_off; - - reloc_done++; - } -#endif - return 0; -} - static int wdt_pre_probe(struct udevice *dev) { u32 timeout = WATCHDOG_TIMEOUT_SECS; @@ -295,7 +273,6 @@ UCLASS_DRIVER(wdt) = { .id = UCLASS_WDT, .name = "watchdog", .flags = DM_UC_FLAG_SEQ_ALIAS, - .post_bind = wdt_post_bind, .pre_probe = wdt_pre_probe, .per_device_auto = sizeof(struct wdt_priv), }; |
