Enable i.MX8MM EVK BD71837 pmic
Subsystems (5)
cover Enable i.MX8MM EVK BD71837 pmic
This patch is to enable BD71837 pmic for i.MX8MM EVK. Two i.MX8MQ patches are also included.
Peng Fan (10):
imx8m: imx8mq: get chip rev for B1 revision
imx8m: clock: improve irq response latency
imx: imx8mq: add init_nand_clk
imx: spl: implement spl_boot_mode for i.MX7/8/8M
dt-bindings: import usb pd
arm: dts: imx8mm: sync dts from Linux Kernel
pmic: bd71837: drop DEBUG macro
power: pmic: Kconfig: add CONFIG_SPL_DM_PMIC_BD71837
imx8m: evk: spl: probe clk in spl early stage
imx8mm: evk: enable bd71837 pmic
arch/arm/dts/imx8mm-evk-u-boot.dtsi | 22 +- arch/arm/dts/imx8mm-evk.dts | 285 ++++++++++++++++++++++++- arch/arm/dts/imx8mm.dtsi | 222 +++++++++++++++---- arch/arm/include/asm/arch-imx8m/clock_imx8mq.h | 2 + arch/arm/mach-imx/imx8m/clock_imx8mq.c | 16 ++ arch/arm/mach-imx/imx8m/soc.c | 21 +- arch/arm/mach-imx/spl.c | 29 +++ board/freescale/imx8mm_evk/spl.c | 63 +++++- configs/imx8mm_evk_defconfig | 5 +- drivers/power/pmic/Kconfig | 8 + drivers/power/pmic/bd71837.c | 2 - include/dt-bindings/usb/pd.h | 88 ++++++++ 12 files changed, 692 insertions(+), 71 deletions(-) create mode 100644 include/dt-bindings/usb/pd.h
Signature · 1 line
2.16.4
PATCH 1/10 imx8m: imx8mq: get chip rev for B1 revision
The i.MX8MQ B1 uses OCOTP_HW_OCOTP_READ_FUSE_DATA register for chip id. It returns a magic number 0xff0055aa. update get_cpu_rev to support it, and enable ocotp clock to access ocotp.
--- arch/arm/mach-imx/imx8m/clock_imx8mq.c | 1 + arch/arm/mach-imx/imx8m/soc.c | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-)
arch/arm/mach-imx/imx8m/clock_imx8mq.c +1 -0
@@ -804,6 +804,7 @@ int clock_init(void)init_wdog_clk ();clock_enable (CCGR_TSENSOR ,1 ); +clock_enable (CCGR_OCOTP ,1 );return 0 ; }
arch/arm/mach-imx/imx8m/soc.c +14 -7
@@ -204,14 +204,21 @@ u32 get_cpu_rev(void) }else {if (reg ==CHIP_REV_1_0 ) {/* -* For B0 chip, the DIGPROG is not updated, still TO1.0. -* we have to check ROM version further +* For B0 chip, the DIGPROG is not updated, +* it is still TO1.0. we have to check ROM +* version or OCOTP_READ_FUSE_DATA. +* 0xff0055aa is magic number for B1. */ - rom_version =readl ((void __iomem *)ROM_VERSION_A0 ); -if (rom_version !=CHIP_REV_1_0 ) { - rom_version =readl ((void __iomem *)ROM_VERSION_B0 ); -if (rom_version >=CHIP_REV_2_0 ) - reg =CHIP_REV_2_0 ; +if (readl ((void __iomem *)(OCOTP_BASE_ADDR +0x40 )) ==0xff0055aa ) { + reg =CHIP_REV_2_1 ; + }else { + rom_version = +readl ((void __iomem *)ROM_VERSION_A0 ); +if (rom_version !=CHIP_REV_1_0 ) { + rom_version =readl ((void __iomem *)ROM_VERSION_B0 ); +if (rom_version ==CHIP_REV_2_0 ) + reg =CHIP_REV_2_0 ; + } } } }
Signature · 1 line
2.16.4
PATCH 2/10 imx8m: clock: improve irq response latency
In reply to Peng FanImprove the IRQ response latency by setting GIC root clock source to sys_pll2_200m from osc.
--- arch/arm/mach-imx/imx8m/clock_imx8mq.c | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm/mach-imx/imx8m/clock_imx8mq.c +6 -0
@@ -806,6 +806,12 @@ int clock_init(void)clock_enable (CCGR_TSENSOR ,1 );clock_enable (CCGR_OCOTP ,1 ); +/* config GIC ROOT to sys_pll2_200m */ +clock_enable (CCGR_GIC ,0 ); +clock_set_target_val (GIC_CLK_ROOT , +CLK_ROOT_ON |CLK_ROOT_SOURCE_SEL (1 )); +clock_enable (CCGR_GIC ,1 ); + return 0; }#endif
Signature · 1 line
2.16.4
PATCH 3/10 imx: imx8mq: add init_nand_clk
In reply to Peng FanAdd init_nand_clk to enable gpmi nand clock. Since i.MX8MQ not use CCF, so we still use legacy mode to configure the clock.
--- arch/arm/include/asm/arch-imx8m/clock_imx8mq.h | 2 ++ arch/arm/mach-imx/imx8m/clock_imx8mq.c | 9 +++++++++ 2 files changed, 11 insertions(+)
arch/arm/include/asm/arch-imx8m/clock_imx8mq.h +2 -0
@@ -421,4 +421,6 @@ enum frac_pll_out_val {FRAC_PLL_OUT_1000M , FRAC_PLL_OUT_1600M, }; + +void init_nand_clk (void );#endif
arch/arm/mach-imx/imx8m/clock_imx8mq.c +9 -0
@@ -393,6 +393,15 @@ void init_usb_clk(void) } } +void init_nand_clk (void ) +{ +clock_enable (CCGR_RAWNAND ,0 ); +clock_set_target_val (NAND_CLK_ROOT , +CLK_ROOT_ON |CLK_ROOT_SOURCE_SEL (3 ) | +CLK_ROOT_POST_DIV (CLK_ROOT_POST_DIV4 )); +clock_enable (CCGR_RAWNAND ,1 ); +} +void init_uart_clk (u32 index) {/* Set uart clock root 25M OSC */
Signature · 1 line
2.16.4
PATCH 4/10 imx: spl: implement spl_boot_mode for i.MX7/8/8M
In reply to Peng FanIt will be easy to separate SD/EMMC when booting in SPL stage, then no need to bother which device is BOOT_DEVICE_MMC1/2.
--- arch/arm/mach-imx/spl.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
arch/arm/mach-imx/spl.c +29 -0
@@ -189,6 +189,34 @@ int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)/* called from spl_mmc to see type of boot mode for storage (RAW or FAT) */ u32 spl_boot_mode (const u32 boot_device) { +#if defined(CONFIG_MX7 ) || defined(CONFIG_IMX8M ) || defined(CONFIG_IMX8 ) +switch (get_boot_device ()) { +/* for MMC return either RAW or FAT mode */ +case SD1_BOOT : +case SD2_BOOT : +case SD3_BOOT : +#if defined(CONFIG_SPL_FAT_SUPPORT ) +return MMCSD_MODE_FS ; +#else +return MMCSD_MODE_RAW ; +#endif +break ; +case MMC1_BOOT : +case MMC2_BOOT : +case MMC3_BOOT : +#if defined(CONFIG_SPL_FAT_SUPPORT ) +return MMCSD_MODE_FS ; +#elif defined(CONFIG_SUPPORT_EMMC_BOOT ) +return MMCSD_MODE_EMMCBOOT ; +#else +return MMCSD_MODE_RAW ; +#endif +break ; +default : +puts ("spl: ERROR: unsupported device\n" ); +hang (); + } +#else /* * When CONFIG_SPL_FORCE_MMC_BOOT is defined the 'boot_device' is used * unconditionally to decide about device to use for booting.
@@ -217,6 +245,7 @@ u32 spl_boot_mode(const u32 boot_device)puts ("spl: ERROR: unsupported device\n" );hang (); } +#endif }#endif
Signature · 1 line
2.16.4
PATCH 5/10 dt-bindings: import usb pd
In reply to Peng FanImport usb pd bindings from Linux 5.4.0-rc1.
This file will be included by imx8mm-evk.dts.
--- include/dt-bindings/usb/pd.h | 88 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 include/dt-bindings/usb/pd.h
include/dt-bindings/usb/pd.h new file +88 -0
@@ -0,0 +1,88 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __DT_POWER_DELIVERY_H +#define __DT_POWER_DELIVERY_H + +/* Power delivery Power Data Object definitions */ +#define PDO_TYPE_FIXED 0 +#define PDO_TYPE_BATT 1 +#define PDO_TYPE_VAR 2 +#define PDO_TYPE_APDO 3 + +#define PDO_TYPE_SHIFT 30 +#define PDO_TYPE_MASK 0x3 + +#define PDO_TYPE (t) ((t) << PDO_TYPE_SHIFT) + +#define PDO_VOLT_MASK 0x3ff +#define PDO_CURR_MASK 0x3ff +#define PDO_PWR_MASK 0x3ff + +#define PDO_FIXED_DUAL_ROLE (1 << 29)/* Power role swap supported */ +#define PDO_FIXED_SUSPEND (1 << 28)/* USB Suspend supported (Source) */ +#define PDO_FIXED_HIGHER_CAP (1 << 28)/* Requires more than vSafe5V (Sink) */ +#define PDO_FIXED_EXTPOWER (1 << 27)/* Externally powered */ +#define PDO_FIXED_USB_COMM (1 << 26)/* USB communications capable */ +#define PDO_FIXED_DATA_SWAP (1 << 25)/* Data role swap supported */ +#define PDO_FIXED_VOLT_SHIFT 10/* 50mV units */ +#define PDO_FIXED_CURR_SHIFT 0/* 10mA units */ + +#define PDO_FIXED_VOLT (mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_FIXED_VOLT_SHIFT) +#define PDO_FIXED_CURR (ma) ((((ma) / 10) & PDO_CURR_MASK) << PDO_FIXED_CURR_SHIFT) + +#define PDO_FIXED (mv, ma, flags) \ + (PDO_TYPE(PDO_TYPE_FIXED) | (flags) | \ + PDO_FIXED_VOLT(mv) | PDO_FIXED_CURR(ma)) + +#define VSAFE5V 5000/* mv units */ + +#define PDO_BATT_MAX_VOLT_SHIFT 20/* 50mV units */ +#define PDO_BATT_MIN_VOLT_SHIFT 10/* 50mV units */ +#define PDO_BATT_MAX_PWR_SHIFT 0/* 250mW units */ + +#define PDO_BATT_MIN_VOLT (mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_BATT_MIN_VOLT_SHIFT) +#define PDO_BATT_MAX_VOLT (mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_BATT_MAX_VOLT_SHIFT) +#define PDO_BATT_MAX_POWER (mw) ((((mw) / 250) & PDO_PWR_MASK) << PDO_BATT_MAX_PWR_SHIFT) + +#define PDO_BATT (min_mv, max_mv, max_mw) \ + (PDO_TYPE(PDO_TYPE_BATT) | PDO_BATT_MIN_VOLT(min_mv) | \ + PDO_BATT_MAX_VOLT(max_mv) | PDO_BATT_MAX_POWER(max_mw)) + +#define PDO_VAR_MAX_VOLT_SHIFT 20/* 50mV units */ +#define PDO_VAR_MIN_VOLT_SHIFT 10/* 50mV units */ +#define PDO_VAR_MAX_CURR_SHIFT 0/* 10mA units */ + +#define PDO_VAR_MIN_VOLT (mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_VAR_MIN_VOLT_SHIFT) +#define PDO_VAR_MAX_VOLT (mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_VAR_MAX_VOLT_SHIFT) +#define PDO_VAR_MAX_CURR (ma) ((((ma) / 10) & PDO_CURR_MASK) << PDO_VAR_MAX_CURR_SHIFT) + +#define PDO_VAR (min_mv, max_mv, max_ma) \ + (PDO_TYPE(PDO_TYPE_VAR) | PDO_VAR_MIN_VOLT(min_mv) | \ + PDO_VAR_MAX_VOLT(max_mv) | PDO_VAR_MAX_CURR(max_ma)) + +#define APDO_TYPE_PPS 0 + +#define PDO_APDO_TYPE_SHIFT 28/* Only valid value currently is 0x0 - PPS */ +#define PDO_APDO_TYPE_MASK 0x3 + +#define PDO_APDO_TYPE (t) ((t) << PDO_APDO_TYPE_SHIFT) + +#define PDO_PPS_APDO_MAX_VOLT_SHIFT 17/* 100mV units */ +#define PDO_PPS_APDO_MIN_VOLT_SHIFT 8/* 100mV units */ +#define PDO_PPS_APDO_MAX_CURR_SHIFT 0/* 50mA units */ + +#define PDO_PPS_APDO_VOLT_MASK 0xff +#define PDO_PPS_APDO_CURR_MASK 0x7f + +#define PDO_PPS_APDO_MIN_VOLT (mv) \ + ((((mv) / 100) & PDO_PPS_APDO_VOLT_MASK) << PDO_PPS_APDO_MIN_VOLT_SHIFT) +#define PDO_PPS_APDO_MAX_VOLT (mv) \ + ((((mv) / 100) & PDO_PPS_APDO_VOLT_MASK) << PDO_PPS_APDO_MAX_VOLT_SHIFT) +#define PDO_PPS_APDO_MAX_CURR (ma) \ + ((((ma) / 50) & PDO_PPS_APDO_CURR_MASK) << PDO_PPS_APDO_MAX_CURR_SHIFT) + +#define PDO_PPS_APDO (min_mv, max_mv, max_ma) \ + (PDO_TYPE(PDO_TYPE_APDO) | PDO_APDO_TYPE(APDO_TYPE_PPS) | \ + PDO_PPS_APDO_MIN_VOLT(min_mv) | PDO_PPS_APDO_MAX_VOLT(max_mv) | \ + PDO_PPS_APDO_MAX_CURR(max_ma)) + +#endif /* __DT_POWER_DELIVERY_H */
Signature · 1 line
2.16.4
PATCH 6/10 arm: dts: imx8mm: sync dts from Linux Kernel
In reply to Peng FanSync dts for i.MX8MM from Linux Kernel 5.4.0-rc1
--- arch/arm/dts/imx8mm-evk-u-boot.dtsi | 2 +- arch/arm/dts/imx8mm-evk.dts | 285 +++++++++++++++++++++++++++++++++++- arch/arm/dts/imx8mm.dtsi | 222 ++++++++++++++++++++++------ 3 files changed, 459 insertions(+), 50 deletions(-)
arch/arm/dts/imx8mm-evk-u-boot.dtsi +1 -1
@@ -3,7 +3,7 @@ * Copyright 2019 NXP */ -&{/soc} { +&{/soc at 0} { u-boot,dm-pre-reloc; u-boot,dm-spl; };
arch/arm/dts/imx8mm-evk.dts +279 -6
343 lines not on this page · raw message
arch/arm/dts/imx8mm.dtsi +179 -43
433 lines not on this page · raw message
Signature · 1 line
2.16.4
PATCH 7/10 pmic: bd71837: drop DEBUG macro
In reply to Peng FanDrop DEBUG macro definition which is used for debug purpose.
--- drivers/power/pmic/bd71837.c | 2 -- 1 file changed, 2 deletions(-)
drivers/power/pmic/bd71837.c +0 -2
@@ -3,8 +3,6 @@* Copyright 2018 NXP */ -#define DEBUG -#include <common.h> #include <errno.h> #include <dm.h>
Signature · 1 line
2.16.4
PATCH 8/10 power: pmic: Kconfig: add CONFIG_SPL_DM_PMIC_BD71837
In reply to Peng FanAdd CONFIG_SPL_DM_PMIC_BD71837 to make this driver could be used in SPL stage
--- drivers/power/pmic/Kconfig | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/power/pmic/Kconfig +8 -0
@@ -55,6 +55,14 @@ config DM_PMIC_BD71837 This config enables implementation of driver-model pmic uclass features for PMIC BD71837. The driver implements read/write operations. +config SPL_DM_PMIC_BD71837 + bool "Enable Driver Model for PMIC BD71837 in SPL stage" + depends on DM_PMIC + help + This config enables implementation of driver-model pmic uclass + features for PMIC BD71837. The driver implements read/write + operations. + config DM_PMIC_FAN53555 bool "Enable support for OnSemi FAN53555" depends on DM_PMIC && DM_REGULATOR && DM_I2C
Signature · 1 line
2.16.4
PATCH 9/10 imx8m: evk: spl: probe clk in spl early stage
In reply to Peng FanWe are going to add i2c pmic support before dram could be used. So we need enable clk driver earlier, so use spl_early_init and move clock controller probe eariler to board_init_f.
--- board/freescale/imx8mm_evk/spl.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
board/freescale/imx8mm_evk/spl.c +11 -11
@@ -41,16 +41,7 @@ void spl_dram_init(void)void spl_board_init (void ) { -struct udevice *dev; -int ret; -puts ("Normal Boot\n" ); - - ret =uclass_get_device_by_name (UCLASS_CLK , -"clock-controller at 30380000" , - &dev); -if (ret <0 ) -printf ("Failed to find clock node. Check device tree\n" ); }#ifdef CONFIG_SPL_LOAD_FIT
@@ -90,6 +81,7 @@ int board_early_init_f(void)void board_init_f (ulong dummy) { +struct udevice *dev;int ret;arch_cpu_init ();
@@ -105,9 +97,17 @@ void board_init_f(ulong dummy)/* Clear the BSS. */ memset (__bss_start,0 , __bss_end - __bss_start); - ret =spl_init (); + ret =spl_early_init ();if (ret) { -debug ("spl_init() failed: %d\n" , ret); +debug ("spl_early_init() failed: %d\n" , ret); +hang (); + } + + ret =uclass_get_device_by_name (UCLASS_CLK , +"clock-controller@30380000" , + &dev); +if (ret <0 ) { +printf ("Failed to find clock node. Check device tree\n" );hang (); }
Signature · 1 line
2.16.4
PATCH 10/10 imx8mm: evk: enable bd71837 pmic
In reply to Peng FanEnable bd71837 pmic for i.MX8MM EVK board, need to set voltage for DRAM and linux suspend voltage requirement.
--- arch/arm/dts/imx8mm-evk-u-boot.dtsi | 20 ++++++++++++++++++ board/freescale/imx8mm_evk/spl.c | 41 +++++++++++++++++++++++++++++++++++++ configs/imx8mm_evk_defconfig | 5 ++++- 3 files changed, 65 insertions(+), 1 deletion(-)
arch/arm/dts/imx8mm-evk-u-boot.dtsi +20 -0
@@ -90,3 +90,23 @@ &usdhc3 { u-boot,dm-spl; }; + +&i2c1 { + u-boot,dm-spl; +}; + +&{/soc at 0/bus at 30800000/i2c at 30a20000/pmic at 4b} { + u-boot,dm-spl; +}; + +&{/soc at 0/bus at 30800000/i2c at 30a20000/pmic at 4b/regulators} { + u-boot,dm-spl; +}; + +&pinctrl_i2c1 { + u-boot,dm-spl; +}; + +&pinctrl_pmic { + u-boot,dm-spl; +};
board/freescale/imx8mm_evk/spl.c +41 -0
59 lines not on this page · raw message
configs/imx8mm_evk_defconfig +4 -1
@@ -12,6 +12,7 @@ CONFIG_SPL_MMC_SUPPORT=y CONFIG_SPL_SERIAL_SUPPORT=y CONFIG_SPL_DRIVERS_MISC_SUPPORT=y CONFIG_SPL=y +CONFIG_SPL_TEXT_BASE=0x7E1000 CONFIG_FIT=y CONFIG_FIT_EXTERNAL_OFFSET=0x3000 CONFIG_SPL_LOAD_FIT=y
@@ -20,10 +21,10 @@ CONFIG_OF_SYSTEM_SETUP=y CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/imx8m/imximage-8mm-lpddr4.cfg" CONFIG_DEFAULT_FDT_FILE="fsl-imx8mm-evk.dtb" CONFIG_BOARD_LATE_INIT=y -CONFIG_SPL_TEXT_BASE=0x7E1000 CONFIG_SPL_BOARD_INIT=y CONFIG_SPL_SEPARATE_BSS=y CONFIG_SPL_I2C_SUPPORT=y +CONFIG_SPL_POWER_SUPPORT=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PROMPT="u-boot=> " # CONFIG_CMD_EXPORTENV is not set
@@ -65,6 +66,8 @@ CONFIG_DM_ETH=y CONFIG_PINCTRL=y CONFIG_SPL_PINCTRL=y CONFIG_PINCTRL_IMX8M=y +CONFIG_DM_PMIC=y +CONFIG_SPL_DM_PMIC_BD71837=y CONFIG_DM_REGULATOR=y CONFIG_DM_REGULATOR_FIXED=y CONFIG_DM_REGULATOR_GPIO=y
Signature · 1 line
2.16.4