1 // SPDX-License-Identifier: GPL-2.0+
3 * Board init file for Dragonboard 820C
5 * (C) Copyright 2017 Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
8 #include <asm/arch/sysmap-apq8096.h>
9 #include <linux/arm-smccc.h>
10 #include <linux/psci.h>
14 #include <linux/bitops.h>
18 DECLARE_GLOBAL_DATA_PTR;
22 gd->ram_size = PHYS_SDRAM_SIZE;
27 int dram_init_banksize(void)
29 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
30 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
32 gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
33 gd->bd->bi_dram[1].size = PHYS_SDRAM_2_SIZE;
38 static void sdhci_power_init(void)
40 const u32 TLMM_PULL_MASK = 0x3;
41 const u32 TLMM_HDRV_MASK = 0x7;
44 u32 bit; /* bit in the register */
45 u8 mask; /* mask clk/dat/cmd control */
49 /* bit offsets in the sdc tlmm register */
50 enum { SDC1_DATA_HDRV = 0,
59 enum { TLMM_PULL_DOWN = 0x1,
64 enum { TLMM_CUR_VAL_10MA = 0x04,
65 TLMM_CUR_VAL_16MA = 0x07,
69 /* drive strength configs for sdhc pins */
70 const struct tlmm_cfg hdrv[] = {
72 { SDC1_CLK_HDRV, TLMM_CUR_VAL_16MA, TLMM_HDRV_MASK, },
73 { SDC1_CMD_HDRV, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK, },
74 { SDC1_DATA_HDRV, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK, },
77 /* pull configs for sdhc pins */
78 const struct tlmm_cfg pull[] = {
80 { SDC1_CLK_PULL, TLMM_NO_PULL, TLMM_PULL_MASK, },
81 { SDC1_CMD_PULL, TLMM_PULL_UP, TLMM_PULL_MASK, },
82 { SDC1_DATA_PULL, TLMM_PULL_UP, TLMM_PULL_MASK, },
85 const struct tlmm_cfg rclk[] = {
87 { SDC1_RCLK_PULL, TLMM_PULL_DOWN, TLMM_PULL_MASK,},
90 for (i = 0; i < ARRAY_SIZE(hdrv); i++)
91 clrsetbits_le32(SDC1_HDRV_PULL_CTL_REG,
92 hdrv[i].mask << hdrv[i].bit,
93 hdrv[i].val << hdrv[i].bit);
95 for (i = 0; i < ARRAY_SIZE(pull); i++)
96 clrsetbits_le32(SDC1_HDRV_PULL_CTL_REG,
97 pull[i].mask << pull[i].bit,
98 pull[i].val << pull[i].bit);
100 for (i = 0; i < ARRAY_SIZE(rclk); i++)
101 clrsetbits_le32(SDC1_HDRV_PULL_CTL_REG,
102 rclk[i].mask << rclk[i].bit,
103 rclk[i].val << rclk[i].bit);
106 static void show_psci_version(void)
108 struct arm_smccc_res res;
110 arm_smccc_smc(ARM_PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0, 0, 0, 0, 0, &res);
112 printf("PSCI: v%ld.%ld\n",
113 PSCI_VERSION_MAJOR(res.a0),
114 PSCI_VERSION_MINOR(res.a0));
125 void reset_cpu(ulong addr)
130 /* Check for vol- button - if pressed - stop autoboot */
131 int misc_init_r(void)
134 struct gpio_desc resin;
137 ret = uclass_get_device_by_name(UCLASS_GPIO, "pm8994_pon@800", &pon);
139 printf("Failed to find PMIC pon node. Check device tree\n");
143 node = fdt_subnode_offset(gd->fdt_blob, dev_of_offset(pon),
146 printf("Failed to find key_vol_down node. Check device tree\n");
150 if (gpio_request_by_name_nodev(offset_to_ofnode(node), "gpios", 0,
152 printf("Failed to request key_vol_down button.\n");
156 if (dm_gpio_get_value(&resin)) {
157 env_set("bootdelay", "-1");
158 printf("Power button pressed - dropping to console.\n");