arm: qcom: shikra: add SPL SD-card boot support
cover arm: qcom: shikra: add SPL SD-card boot support
Enable booting the Shikra CQS EVK from a removable SD card in SPL.
Add the required SDHC2 device-tree support and select the eMMC or SD boot device. Update clock handling so only the PLLs required by the selected clock source are enabled during early boot.
Depends on:
https://lore.kernel.org/u-boot/[email protected]/
Abhilash V (3):
arm: dts: shikra: enable SPL SD card boot
board: shikra: select SPL MMC boot source
clk: qcom: shikra: gate PLLs by clock source
arch/arm/dts/shikra-cqs-evk-u-boot.dtsi | 19 +++++ arch/arm/dts/shikra-cqs-evk.dts | 14 ++++ board/qualcomm/shikra/spl-shikra.c | 99 +++++++++++++++---------- drivers/clk/qcom/clock-shikra.c | 7 +- 4 files changed, 98 insertions(+), 41 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/3 arm: dts: shikra: enable SPL SD card boot
Enable SDHC2 on the CQS EVK and retain its pinctrl and regulator dependencies in the SPL device tree.
Add the MMC sequence-1 alias and describe the removable SD slot with its supplies, reset, and 100 MHz limit.
Do not add cd-gpios. SPL selects the boot source from PBL state and handles the selected SD device in board code.
--- arch/arm/dts/shikra-cqs-evk-u-boot.dtsi | 19 +++++++++++++++++++ arch/arm/dts/shikra-cqs-evk.dts | 14 ++++++++++++++ 2 files changed, 33 insertions(+)
arch/arm/dts/shikra-cqs-evk-u-boot.dtsi +19 -0
@@ -48,6 +48,25 @@ bootph-all; }; +&sdc2_default { + bootph-all; + clk-pins { bootph-all; }; + cmd-pins { bootph-all; }; + data-pins { bootph-all; }; +}; + +&sdc2_sleep { + bootph-all; + clk-pins { bootph-all; }; + cmd-pins { bootph-all; }; + data-pins { bootph-all; }; +}; + +&sdc2_card_det_n { bootph-all; }; +&sdhc_2 { bootph-all; }; +&pm4125_l18 { bootph-all; }; +&pm4125_l22 { bootph-all; }; + &qupv3_0 { bootph-all; };
arch/arm/dts/shikra-cqs-evk.dts +14 -0
@@ -15,6 +15,7 @@ aliases { mmc0 = &sdhc_1; + mmc1 = &sdhc_2; serial0 = &uart0; };
@@ -38,3 +39,16 @@ status = "okay"; }; + +&sdhc_2 { + resets = <&gcc GCC_SDCC2_BCR>; + vmmc-supply = <&pm4125_l22>; + vqmmc-supply = <&pm4125_l18>; + max-frequency = <100000000>; + no-sdio; + no-mmc; + pinctrl-0 = <&sdc2_default &sdc2_card_det_n>; + pinctrl-1 = <&sdc2_sleep &sdc2_card_det_n>; + pinctrl-names = "default", "sleep"; + status = "okay"; +};
Signature · 1 line
2.34.1
PATCH 2/3 board: shikra: select SPL MMC boot source
In reply to Abhilash VDecode the PBL boot-configuration register once and use it for MMC preparation, FIT partition lookup, and SPL boot-device reporting.
Map eMMC to MMC1/sequence 0 and SD to MMC2/sequence 1. When PBL selects SD, enable polling for that device because SPL does not resolve the optional card-detect GPIO.
--- board/qualcomm/shikra/spl-shikra.c | 99 ++++++++++++++++++------------ 1 file changed, 61 insertions(+), 38 deletions(-)
board/qualcomm/shikra/spl-shikra.c +61 -38
@@ -149,6 +149,32 @@ enum { IPQ_SPL_BOOTCFG_DEV_MAX }; +static int shikra_boot_device (int *mmc_seq) +{ +u8 boot_device_cfg; + + boot_device_cfg = + (readl (IPQ_SPL_BOOTCFG_REG_ADDR ) &IPQ_SPL_BOOTCFG_DEV_MASK ) >> +IPQ_SPL_BOOTCFG_DEV_SHFT ; + +switch (boot_device_cfg) { +case IPQ_SPL_BOOTCFG_DEV_MMC : +if (mmc_seq) + *mmc_seq =0 ; +return BOOT_DEVICE_MMC1 ; +case IPQ_SPL_BOOTCFG_DEV_SD_EMMC : +if (mmc_seq) + *mmc_seq =1 ; +return BOOT_DEVICE_MMC2 ; +case IPQ_SPL_BOOTCFG_DEV_EDL : +return BOOT_DEVICE_USB ; +case IPQ_SPL_BOOTCFG_DEV_NAND : +return BOOT_DEVICE_NAND ; +default : +return -EINVAL ; + } +} +#if defined(CONFIG_SPL_BUILD )/** * shikra_prepare_qup_clocks() - Enable QUP wrapper clocks.
@@ -197,23 +223,11 @@ static int shikra_prepare_boot_mmc(void) {struct udevice *dev;struct mmc *mmc; -u8 boot_device_cfg; -int seq, ret; +int boot_device, seq, ret; - boot_device_cfg = - (readl (IPQ_SPL_BOOTCFG_REG_ADDR ) &IPQ_SPL_BOOTCFG_DEV_MASK ) >> -IPQ_SPL_BOOTCFG_DEV_SHFT ; - -switch (boot_device_cfg) { -case IPQ_SPL_BOOTCFG_DEV_MMC : - seq =0 ; -break ; -case IPQ_SPL_BOOTCFG_DEV_SD_EMMC : - seq =1 ; -break ; -default : -return 0 ; - } + boot_device =shikra_boot_device (&seq); +if (boot_device !=BOOT_DEVICE_MMC1 && boot_device !=BOOT_DEVICE_MMC2 ) +return -ENODEV ; ret =uclass_get_device_by_seq (UCLASS_MMC , seq, &dev);if (ret)
@@ -223,6 +237,13 @@ static int shikra_prepare_boot_mmc(void)if (!mmc)return -ENODEV ; +/* +* SPL cannot resolve the SD card-detect GPIO from its live device tree. +* PBL selected this device as the boot source, so poll it for the card. +*/ +if (boot_device ==BOOT_DEVICE_MMC2 ) + ((struct mmc_config *)mmc->cfg)->host_caps |=MMC_CAP_NEEDS_POLL ; +return mmc_init (mmc); }
@@ -404,13 +425,20 @@ int spl_mmc_boot_partition(struct mmc *mmc, const u32 boot_device) {struct blk_desc *desc;struct disk_partition info; -int partition; +int mmc_seq, partition;if (!IS_ENABLED (CONFIG_MMC ))return -ENOSYS ; +/* +* The MMC core selected @mmc from @boot_device. Confirm that it is +* the device PBL configured before searching it for the FIT partition. +*/ +if (shikra_boot_device (&mmc_seq) != boot_device) +return -ENODEV ; + desc =mmc_get_blk_desc (mmc); -if (!desc) +if (!desc || desc->devnum != mmc_seq)return -ENODEV ; partition = part_get_info_by_name(desc, QCOM_SPL_FIT_IMG_PARTITION,
@@ -428,33 +456,28 @@ int spl_mmc_boot_partition(struct mmc *mmc, const u32 boot_device)*/ u32 spl_boot_device (void ) { -u8 boot_device_cfg = - (readl (IPQ_SPL_BOOTCFG_REG_ADDR ) &IPQ_SPL_BOOTCFG_DEV_MASK ) >> -IPQ_SPL_BOOTCFG_DEV_SHFT ; -u32 boot_device_smem; +int boot_device; -switch (boot_device_cfg) { -case IPQ_SPL_BOOTCFG_DEV_MMC : - boot_device_smem =BOOT_DEVICE_MMC1 ; + boot_device =shikra_boot_device (NULL ); +if (boot_device <0 ) { +pr_err ("Invalid boot device configured\n" ); +return boot_device; + } + +switch (boot_device) { +case BOOT_DEVICE_MMC1 :printf ("Selected boot device: MMC\n" );break ; -case IPQ_SPL_BOOTCFG_DEV_SD_EMMC : - boot_device_smem =BOOT_DEVICE_MMC2 ; +case BOOT_DEVICE_MMC2 :printf ("Selected boot device: SD MMC\n" );break ; -case IPQ_SPL_BOOTCFG_DEV_EDL : - boot_device_smem =BOOT_DEVICE_USB ; -printf ("Selected boot device: SPI-NAND\n" ); +case BOOT_DEVICE_USB : +printf ("Selected boot device: USB\n" );break ; -case IPQ_SPL_BOOTCFG_DEV_NAND : - boot_device_smem =BOOT_DEVICE_NAND ; -printf ("Selected boot device: SPI-NAND\n" ); +case BOOT_DEVICE_NAND : +printf ("Selected boot device: NAND\n" );break ; -default : -pr_err ("Invalid boot device configured: %d\n" , - boot_device_cfg); -return -EINVAL ; } -return boot_device_smem; +return boot_device; }
Signature · 1 line
2.34.1
PATCH 3/3 clk: qcom: shikra: gate PLLs by clock source
In reply to Abhilash VSelect the QUP and SDCC2 source table entry before enabling its PLL.
UART rates from GPLL0_AUX2 must not vote GPLL6. SDCC2 needs a GPLL7 vote only for its GPLL7 table entry. This avoids enabling unrelated PLLs during SPL clock setup.
--- drivers/clk/qcom/clock-shikra.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/clk/qcom/clock-shikra.c +4 -3
@@ -138,9 +138,9 @@ static ulong shikra_set_rate(struct clk *clk, ulong rate)switch (clk->id) {case GCC_QUPV3_WRAP0_S0_CLK : -/* The QUP clock table includes a GPLL6 source. */ -clk_enable_gpll0 (priv->base, &gpll6_vote_clk); freq =qcom_find_freq (ftbl_gcc_qupv3_wrap0_s0_clk_src, rate); +if (freq->src ==CFG_CLK_SRC_GPLL6 ) +clk_configure_enable_pll (priv->base, &gpll6_config);clk_rcg_set_rate_mnd (priv->base,GCC_QUPV3_WRAP0_S0_CLK_CMD_RCGR , freq->pre_div, freq->m, freq->n, freq->src,16 );return freq->freq;
@@ -152,8 +152,9 @@ static ulong shikra_set_rate(struct clk *clk, ulong rate) freq->pre_div, freq->m, freq->n, freq->src, 8);return freq->freq;case GCC_SDCC2_APPS_CLK : -clk_enable_gpll0 (priv->base, &gpll7_vote_clk); freq =qcom_find_freq (ftbl_gcc_sdcc2_apps_clk_src, rate); +if (freq->src ==CFG_CLK_SRC_GPLL7 ) +clk_enable_gpll0 (priv->base, &gpll7_vote_clk);clk_rcg_set_rate_mnd (priv->base,GCC_SDCC2_APPS_CLK_CMD_RCGR , freq->pre_div, freq->m, freq->n, freq->src,8 );return freq->freq;
Signature · 1 line
2.34.1