From 5ef1e02e997ade6e482e589a5c5ed7cf442b173b Mon Sep 17 00:00:00 2001 From: Vasily Khoruzhick Date: Sat, 16 Nov 2019 11:32:03 -0800 Subject: power: fan53555: add support for Silergy SYR82X and SYR83X SYR82X and SYR83X are almost identical to FAN53555, the only difference is different die ID and revision, voltage ranges and steps. Signed-off-by: Vasily Khoruzhick Tested-by: Anand Moon Reviewed-by: Kever Yang --- drivers/power/pmic/fan53555.c | 7 ++++-- drivers/power/regulator/fan53555.c | 45 ++++++++++++++++++++++++++++---------- 2 files changed, 38 insertions(+), 14 deletions(-) (limited to 'drivers') diff --git a/drivers/power/pmic/fan53555.c b/drivers/power/pmic/fan53555.c index 1ca59c5f0c..11304d2146 100644 --- a/drivers/power/pmic/fan53555.c +++ b/drivers/power/pmic/fan53555.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -58,7 +59,7 @@ static int pmic_fan53555_bind(struct udevice *dev) return -ENOENT; } - return device_bind_with_driver_data(dev, drv, "SW", 0, + return device_bind_with_driver_data(dev, drv, "SW", dev->driver_data, dev_ofnode(dev), &child); }; @@ -69,7 +70,9 @@ static struct dm_pmic_ops pmic_fan53555_ops = { }; static const struct udevice_id pmic_fan53555_match[] = { - { .compatible = "fcs,fan53555" }, + { .compatible = "fcs,fan53555", .data = FAN53555_VENDOR_FAIRCHILD, }, + { .compatible = "silergy,syr827", .data = FAN53555_VENDOR_SILERGY, }, + { .compatible = "silergy,syr828", .data = FAN53555_VENDOR_SILERGY, }, { }, }; diff --git a/drivers/power/regulator/fan53555.c b/drivers/power/regulator/fan53555.c index dbd5502377..9c48b26216 100644 --- a/drivers/power/regulator/fan53555.c +++ b/drivers/power/regulator/fan53555.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -27,21 +28,37 @@ * See http://www.onsemi.com/pub/Collateral/FAN53555-D.pdf for details. */ static const struct { + unsigned int vendor; u8 die_id; u8 die_rev; + bool check_rev; u32 vsel_min; u32 vsel_step; } ic_types[] = { - { 0x0, 0x3, 600000, 10000 }, /* Option 00 */ - { 0x0, 0xf, 800000, 10000 }, /* Option 13 */ - { 0x0, 0xc, 600000, 12500 }, /* Option 23 */ - { 0x1, 0x3, 600000, 10000 }, /* Option 01 */ - { 0x3, 0x3, 600000, 10000 }, /* Option 03 */ - { 0x4, 0xf, 603000, 12826 }, /* Option 04 */ - { 0x5, 0x3, 600000, 10000 }, /* Option 05 */ - { 0x8, 0x1, 600000, 10000 }, /* Option 08 */ - { 0x8, 0xf, 600000, 10000 }, /* Option 08 */ - { 0xc, 0xf, 603000, 12826 }, /* Option 09 */ + /* Option 00 */ + { FAN53555_VENDOR_FAIRCHILD, 0x0, 0x3, true, 600000, 10000 }, + /* Option 13 */ + { FAN53555_VENDOR_FAIRCHILD, 0x0, 0xf, true, 800000, 10000 }, + /* Option 23 */ + { FAN53555_VENDOR_FAIRCHILD, 0x0, 0xc, true, 600000, 12500 }, + /* Option 01 */ + { FAN53555_VENDOR_FAIRCHILD, 0x1, 0x3, true, 600000, 10000 }, + /* Option 03 */ + { FAN53555_VENDOR_FAIRCHILD, 0x3, 0x3, true, 600000, 10000 }, + /* Option 04 */ + { FAN53555_VENDOR_FAIRCHILD, 0x4, 0xf, true, 603000, 12826 }, + /* Option 05 */ + { FAN53555_VENDOR_FAIRCHILD, 0x5, 0x3, true, 600000, 10000 }, + /* Option 08 */ + { FAN53555_VENDOR_FAIRCHILD, 0x8, 0x1, true, 600000, 10000 }, + /* Option 08 */ + { FAN53555_VENDOR_FAIRCHILD, 0x8, 0xf, true, 600000, 10000 }, + /* Option 09 */ + { FAN53555_VENDOR_FAIRCHILD, 0xc, 0xf, true, 603000, 12826 }, + /* SYL82X */ + { FAN53555_VENDOR_SILERGY, 0x8, 0x0, false, 712500, 12500 }, + /* SYL83X */ + { FAN53555_VENDOR_SILERGY, 0x9, 0x0, false, 712500, 12500 }, }; /* I2C-accessible byte-sized registers */ @@ -152,10 +169,14 @@ static int fan53555_voltages_setup(struct udevice *dev) /* Init voltage range and step */ for (i = 0; i < ARRAY_SIZE(ic_types); ++i) { + if (ic_types[i].vendor != priv->vendor) + continue; + if (ic_types[i].die_id != priv->die_id) continue; - if (ic_types[i].die_rev != priv->die_rev) + if (ic_types[i].check_rev && + ic_types[i].die_rev != priv->die_rev) continue; priv->vsel_min = ic_types[i].vsel_min; @@ -193,7 +214,7 @@ static int fan53555_probe(struct udevice *dev) return ID2; /* extract vendor, die_id and die_rev */ - priv->vendor = bitfield_extract(ID1, 5, 3); + priv->vendor = dev->driver_data; priv->die_id = ID1 & GENMASK(3, 0); priv->die_rev = ID2 & GENMASK(3, 0); -- cgit From c9fca5ec8849b8fa16b16cece091645e7d3aa02b Mon Sep 17 00:00:00 2001 From: Vasily Khoruzhick Date: Sat, 16 Nov 2019 11:32:57 -0800 Subject: rockchip: i2c: don't sent stop bit after each message That's not correct and it breaks SMBUS-style reads and and writes for some chips (e.g. SYR82X/SYR83X). Stop bit should be sent only after the last message. Signed-off-by: Vasily Khoruzhick Reviewed-by: Kever Yang --- drivers/i2c/rk_i2c.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/i2c/rk_i2c.c b/drivers/i2c/rk_i2c.c index cdd94bb05a..32b2ee8578 100644 --- a/drivers/i2c/rk_i2c.c +++ b/drivers/i2c/rk_i2c.c @@ -253,7 +253,6 @@ static int rk_i2c_read(struct rk_i2c *i2c, uchar chip, uint reg, uint r_len, } i2c_exit: - rk_i2c_send_stop_bit(i2c); rk_i2c_disable(i2c); return err; @@ -332,7 +331,6 @@ static int rk_i2c_write(struct rk_i2c *i2c, uchar chip, uint reg, uint r_len, } i2c_exit: - rk_i2c_send_stop_bit(i2c); rk_i2c_disable(i2c); return err; @@ -360,6 +358,9 @@ static int rockchip_i2c_xfer(struct udevice *bus, struct i2c_msg *msg, } } + rk_i2c_send_stop_bit(i2c); + rk_i2c_disable(i2c); + return 0; } -- cgit From e82692ab325088fe78beba727862c377ced0fc8b Mon Sep 17 00:00:00 2001 From: Vasily Khoruzhick Date: Sun, 17 Nov 2019 10:47:36 -0800 Subject: power: fan53555: fix fan53555_regulator_set_value fan53555_regulator_set_value() passes its own dev to pmic_clrsetbits() instead of its parent (pmic). As result u-boot crashes when you try to set voltage on fan53555 regulator Signed-off-by: Vasily Khoruzhick Reviewed-by: Kever Yang --- drivers/power/regulator/fan53555.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/power/regulator/fan53555.c b/drivers/power/regulator/fan53555.c index 9c48b26216..24a9b67586 100644 --- a/drivers/power/regulator/fan53555.c +++ b/drivers/power/regulator/fan53555.c @@ -159,7 +159,7 @@ static int fan53555_regulator_set_value(struct udevice *dev, int uV) debug("%s: uV=%d; writing volume %d: %02x\n", __func__, uV, pdata->vol_reg, vol); - return pmic_clrsetbits(dev, pdata->vol_reg, GENMASK(6, 0), vol); + return pmic_clrsetbits(dev->parent, pdata->vol_reg, GENMASK(6, 0), vol); } static int fan53555_voltages_setup(struct udevice *dev) -- cgit From 89e311d494c9179d7b44787ca2f2c84654b83425 Mon Sep 17 00:00:00 2001 From: Jagan Teki Date: Tue, 19 Nov 2019 13:56:14 +0530 Subject: gadget: Select USB_GADGET_MANUFACTURER for rockchip Select the gadget manufacturer as 'Rockchip' for all rockchip platform SoC's. This eventually drop the explicit defined added on supported board defconfig files. Tested-by: Levin Du Signed-off-by: Jagan Teki Reviewed-by: Kever Yang --- drivers/usb/gadget/Kconfig | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 26b4d12a09..1959a390f3 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -39,6 +39,7 @@ if USB_GADGET config USB_GADGET_MANUFACTURER string "Vendor name of the USB device" default "Allwinner Technology" if ARCH_SUNXI + default "Rockchip" if ARCH_ROCKCHIP default "U-Boot" help Vendor name of the USB device emulated, reported to the host device. -- cgit From 89cbceb3888b665b39967a7b9035efedf2708ad3 Mon Sep 17 00:00:00 2001 From: Jagan Teki Date: Tue, 19 Nov 2019 13:56:15 +0530 Subject: gadget: Select USB_GADGET_VENDOR_NUM for rockchip Gadget vendor number, 0x2207 is common across all platfroms supported in Rockchip SoC. So, select the same number globally, if ARCH_ROCKCHIP. This eventually drop the explicit configs defined in supported board defconfig files. Tested-by: Levin Du Signed-off-by: Jagan Teki Reviewed-by: Kever Yang --- drivers/usb/gadget/Kconfig | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 1959a390f3..844c3be16f 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -48,6 +48,7 @@ config USB_GADGET_MANUFACTURER config USB_GADGET_VENDOR_NUM hex "Vendor ID of the USB device" default 0x1f3a if ARCH_SUNXI + default 0x2207 if ARCH_ROCKCHIP default 0x0 help Vendor ID of the USB device emulated, reported to the host device. -- cgit From 132b012edef93855204243d6f0a7380e11a78392 Mon Sep 17 00:00:00 2001 From: Jagan Teki Date: Tue, 19 Nov 2019 13:56:16 +0530 Subject: gadget: rockchip: USB_GADGET_PRODUCT_NUM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rockchip support differnet or common gadget product number between Rockchip SoCs like, 0x310a - rk3036 0x320a - rk3229, rk3288 0x330a - rk3328 So, select them on Kconfig based on platform specific config defined.     This eventually drop the explicit configs defined in supporting board defconfig files. Tested-by: Levin Du Signed-off-by: Jagan Teki Reviewed-by: Kever Yang --- drivers/usb/gadget/Kconfig | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers') diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 844c3be16f..e120b48b33 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -58,6 +58,9 @@ config USB_GADGET_VENDOR_NUM config USB_GADGET_PRODUCT_NUM hex "Product ID of the USB device" default 0x1010 if ARCH_SUNXI + default 0x310a if ROCKCHIP_RK3036 + default 0x320a if ROCKCHIP_RK3229 || ROCKCHIP_RK3288 + default 0x330a if ROCKCHIP_RK3328 default 0x0 help Product ID of the USB device emulated, reported to the host device. -- cgit From b032061405ca42a94a5a0ccf1c97fcbf0f616243 Mon Sep 17 00:00:00 2001 From: Jagan Teki Date: Tue, 19 Nov 2019 13:56:17 +0530 Subject: gadget: rockchip: Add rk3128 USB_GADGET_PRODUCT_NUM Add 0x310c for rk3128 gadget product number. Tested-by: Levin Du Signed-off-by: Jagan Teki Reviewed-by: Kever Yang --- drivers/usb/gadget/Kconfig | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index e120b48b33..2da8b40e05 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -59,6 +59,7 @@ config USB_GADGET_PRODUCT_NUM hex "Product ID of the USB device" default 0x1010 if ARCH_SUNXI default 0x310a if ROCKCHIP_RK3036 + default 0x310c if ROCKCHIP_RK3128 default 0x320a if ROCKCHIP_RK3229 || ROCKCHIP_RK3288 default 0x330a if ROCKCHIP_RK3328 default 0x0 -- cgit From a9af59a30ab8e701e4247a0bc8dfe1b155ffdb8a Mon Sep 17 00:00:00 2001 From: Jagan Teki Date: Tue, 19 Nov 2019 13:56:18 +0530 Subject: fastboot: rockchip: Select FASTBOOT_FLASH[_MMC_DEV] Select CONFIG_FASTBOOT_FLASH, CONFIG_FASTBOOT_FLASH_MMC_DEV for rockchip SoC plaforms in fastboot Kconfig file instead of defined it in board defconfig. This eventually drop the explicit configs defined in supporting board defconfig files. Tested-by: Levin Du Signed-off-by: Jagan Teki Reviewed-by: Kever Yang --- drivers/fastboot/Kconfig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig index d63ecdd27e..34864ca613 100644 --- a/drivers/fastboot/Kconfig +++ b/drivers/fastboot/Kconfig @@ -64,7 +64,7 @@ config FASTBOOT_USB_DEV config FASTBOOT_FLASH bool "Enable FASTBOOT FLASH command" - default y if ARCH_SUNXI + default y if ARCH_SUNXI || ARCH_ROCKCHIP depends on MMC || (NAND && CMD_MTDPARTS) select IMAGE_SPARSE help @@ -89,6 +89,8 @@ endchoice config FASTBOOT_FLASH_MMC_DEV int "Define FASTBOOT MMC FLASH default device" depends on FASTBOOT_FLASH_MMC + default 1 if ROCKCHIP_RK3328 + default 0 if ARCH_ROCKCHIP default 0 if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA = -1 default 1 if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA != -1 help -- cgit From 35172ac02f2f2bba3daf1f3d68e8e2348491239e Mon Sep 17 00:00:00 2001 From: Jagan Teki Date: Tue, 19 Nov 2019 13:56:19 +0530 Subject: fastboot: rockchip: Fix rk3328 default mmc device Technically the default mmc device for fastboot would use eMMC if the board support for it. Rockchip platform access device 0 for eMMC so, use the same device number for rk3328. Signed-off-by: Jagan Teki Reviewed-by: Kever Yang --- drivers/fastboot/Kconfig | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers') diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig index 34864ca613..433ea0dc3b 100644 --- a/drivers/fastboot/Kconfig +++ b/drivers/fastboot/Kconfig @@ -89,7 +89,6 @@ endchoice config FASTBOOT_FLASH_MMC_DEV int "Define FASTBOOT MMC FLASH default device" depends on FASTBOOT_FLASH_MMC - default 1 if ROCKCHIP_RK3328 default 0 if ARCH_ROCKCHIP default 0 if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA = -1 default 1 if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA != -1 -- cgit From 6b7ebff00190649d2136b34f6feebc0dbe85bfdc Mon Sep 17 00:00:00 2001 From: Jagan Teki Date: Tue, 19 Nov 2019 13:56:20 +0530 Subject: usb: dwc3: Add phy interface for dwc3_uboot U-Boot has two different variants of dwc3 initializations, - with dm variant gadget, so the respective dm driver would call the dwc3_init in core. - with non-dm variant gadget, so the usage board file would call dwc3_uboot_init in core. The driver probe would handle all respective gadget properties including phy interface via phy_type property and then trigger dwc3_init for dm-variant gadgets. So, to support the phy interface for non-dm variant gadgets, the better option is dwc3_uboot_init since there is no dedicated controller for non-dm variant gadgets. This patch support for adding phy interface like 8/16-bit UTMI+ code for dwc3_uboot. This change used Linux phy.h enum list, to make proper code compatibility. Cc: Marek Vasut Tested-by: Levin Du Signed-off-by: Jagan Teki Reviewed-by: Marek Vasut Reviewed-by: Kever Yang --- drivers/usb/dwc3/core.c | 27 +++++++++++++++++++++++++++ drivers/usb/dwc3/core.h | 12 ++++++++++++ 2 files changed, 39 insertions(+) (limited to 'drivers') diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 23af60c98d..f779562de2 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -613,6 +613,31 @@ static void dwc3_core_exit_mode(struct dwc3 *dwc) dwc3_gadget_run(dwc); } +static void dwc3_uboot_hsphy_mode(struct dwc3_device *dwc3_dev, + struct dwc3 *dwc) +{ + enum usb_phy_interface hsphy_mode = dwc3_dev->hsphy_mode; + u32 reg; + + /* Set dwc3 usb2 phy config */ + reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); + reg |= DWC3_GUSB2PHYCFG_PHYIF; + reg &= ~DWC3_GUSB2PHYCFG_USBTRDTIM_MASK; + + switch (hsphy_mode) { + case USBPHY_INTERFACE_MODE_UTMI: + reg |= DWC3_GUSB2PHYCFG_USBTRDTIM_8BIT; + break; + case USBPHY_INTERFACE_MODE_UTMIW: + reg |= DWC3_GUSB2PHYCFG_USBTRDTIM_16BIT; + break; + default: + break; + } + + dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); +} + #define DWC3_ALIGN_MASK (16 - 1) /** @@ -721,6 +746,8 @@ int dwc3_uboot_init(struct dwc3_device *dwc3_dev) goto err0; } + dwc3_uboot_hsphy_mode(dwc3_dev, dwc); + ret = dwc3_event_buffers_setup(dwc); if (ret) { dev_err(dwc->dev, "failed to setup event buffers\n"); diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index be9672266a..bff53e072b 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -162,6 +162,18 @@ /* Global USB2 PHY Configuration Register */ #define DWC3_GUSB2PHYCFG_PHYSOFTRST (1 << 31) #define DWC3_GUSB2PHYCFG_SUSPHY (1 << 6) +#define DWC3_GUSB2PHYCFG_PHYIF BIT(3) + +/* Global USB2 PHY Configuration Mask */ +#define DWC3_GUSB2PHYCFG_USBTRDTIM_MASK (0xf << 10) + +/* Global USB2 PHY Configuration Offset */ +#define DWC3_GUSB2PHYCFG_USBTRDTIM_OFFSET 10 + +#define DWC3_GUSB2PHYCFG_USBTRDTIM_16BIT (0x5 << \ + DWC3_GUSB2PHYCFG_USBTRDTIM_OFFSET) +#define DWC3_GUSB2PHYCFG_USBTRDTIM_8BIT (0x9 << \ + DWC3_GUSB2PHYCFG_USBTRDTIM_OFFSET) /* Global USB3 PIPE Control Register */ #define DWC3_GUSB3PIPECTL_PHYSOFTRST (1 << 31) -- cgit From 3d3b83a5731bab26e8d822659e7d8ff906f6149a Mon Sep 17 00:00:00 2001 From: Jagan Teki Date: Tue, 19 Nov 2019 13:56:21 +0530 Subject: gadget: rockchip: Add rk3399 USB_GADGET_PRODUCT_NUM Add 0x330c for rk3399 gadget product number. Tested-by: Levin Du Signed-off-by: Jagan Teki Reviewed-by: Kever Yang --- drivers/usb/gadget/Kconfig | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 2da8b40e05..58ca82d4de 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -62,6 +62,7 @@ config USB_GADGET_PRODUCT_NUM default 0x310c if ROCKCHIP_RK3128 default 0x320a if ROCKCHIP_RK3229 || ROCKCHIP_RK3288 default 0x330a if ROCKCHIP_RK3328 + default 0x330c if ROCKCHIP_RK3399 default 0x0 help Product ID of the USB device emulated, reported to the host device. -- cgit From c8dd0e42d709c9734f313c547d0707e27ca0de51 Mon Sep 17 00:00:00 2001 From: Heiko Stuebner Date: Tue, 19 Nov 2019 12:04:01 +0100 Subject: rockchip: dwmmc: add handling for u-boot, spl-fifo-mode Rockchips dwmmc controllers can't do dma to non-ddr addresses, like for example the soc-internal sram but during boot parts of TrustedFirmware need to be placed there from the read FIT image. So add handling for a u-boot,spl-fifo-mode to not put the mmc controllers into fifo mode for all time. The regular fifo-mode property still takes precedent and only if not set do we check for the spl-specific property. Suggested-by: Philipp Tomsich Signed-off-by: Heiko Stuebner Reviewed-by: Kever Yang Signed-off-by: Philipp Tomsich Reviewed-by: Philipp Tomsich --- drivers/mmc/rockchip_dw_mmc.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers') diff --git a/drivers/mmc/rockchip_dw_mmc.c b/drivers/mmc/rockchip_dw_mmc.c index b2a1201631..a0e1be8794 100644 --- a/drivers/mmc/rockchip_dw_mmc.c +++ b/drivers/mmc/rockchip_dw_mmc.c @@ -72,6 +72,11 @@ static int rockchip_dwmmc_ofdata_to_platdata(struct udevice *dev) return -EINVAL; priv->fifo_mode = dev_read_bool(dev, "fifo-mode"); +#ifdef CONFIG_SPL_BUILD + if (!priv->fifo_mode) + priv->fifo_mode = dev_read_bool(dev, "u-boot,spl-fifo-mode"); +#endif + /* * 'clock-freq-min-max' is deprecated * (see https://github.com/torvalds/linux/commit/b023030f10573de738bbe8df63d43acab64c9f7b) -- cgit