1 // SPDX-License-Identifier: GPL-2.0+
3 * Board init file for Dragonboard 410C
5 * (C) Copyright 2015 Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
12 #include <fdt_support.h>
13 #include <asm/arch/dram.h>
15 DECLARE_GLOBAL_DATA_PTR;
17 /* pointer to the device tree ammended by the firmware */
20 void *board_fdt_blob_setup(void)
22 if (fdt_magic(fw_dtb) != FDT_MAGIC) {
23 printf("Firmware provided invalid dtb!\n");
32 gd->ram_size = PHYS_SDRAM_1_SIZE;
37 int dram_init_banksize(void)
39 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
40 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
45 int board_prepare_usb(enum usb_init_type type)
47 static struct udevice *pmic_gpio;
48 static struct gpio_desc hub_reset, usb_sel;
52 ret = uclass_get_device_by_name(UCLASS_GPIO,
56 printf("Failed to find pm8916_gpios@c000 node.\n");
61 /* Try to request gpios needed to start usb host on dragonboard */
62 if (!dm_gpio_is_valid(&hub_reset)) {
63 node = fdt_subnode_offset(gd->fdt_blob,
64 dev_of_offset(pmic_gpio),
67 printf("Failed to find usb_hub_reset_pm dt node.\n");
70 ret = gpio_request_by_name_nodev(offset_to_ofnode(node),
71 "gpios", 0, &hub_reset, 0);
73 printf("Failed to request usb_hub_reset_pm gpio.\n");
78 if (!dm_gpio_is_valid(&usb_sel)) {
79 node = fdt_subnode_offset(gd->fdt_blob,
80 dev_of_offset(pmic_gpio),
83 printf("Failed to find usb_sw_sel_pm dt node.\n");
86 ret = gpio_request_by_name_nodev(offset_to_ofnode(node),
87 "gpios", 0, &usb_sel, 0);
89 printf("Failed to request usb_sw_sel_pm gpio.\n");
94 if (type == USB_INIT_HOST) {
96 dm_gpio_set_dir_flags(&hub_reset,
97 GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
99 /* Switch usb to host connectors */
100 dm_gpio_set_dir_flags(&usb_sel,
101 GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
103 } else { /* Device */
105 dm_gpio_set_dir_flags(&hub_reset, GPIOD_IS_OUT);
106 /* Switch back to device connector */
107 dm_gpio_set_dir_flags(&usb_sel, GPIOD_IS_OUT);
113 /* Check for vol- button - if pressed - stop autoboot */
114 int misc_init_r(void)
117 struct gpio_desc resin;
120 ret = uclass_get_device_by_name(UCLASS_GPIO, "pm8916_pon@800", &pon);
122 printf("Failed to find PMIC pon node. Check device tree\n");
126 node = fdt_subnode_offset(gd->fdt_blob, dev_of_offset(pon),
129 printf("Failed to find key_vol_down node. Check device tree\n");
133 if (gpio_request_by_name_nodev(offset_to_ofnode(node), "gpios", 0,
135 printf("Failed to request key_vol_down button.\n");
139 if (dm_gpio_get_value(&resin)) {
140 env_set("bootdelay", "-1");
141 printf("Power button pressed - dropping to console.\n");
152 int ft_board_setup(void *blob, bd_t *bd)
157 const char *compatible;
158 const char *property;
161 /* update the kernel's dtb with wlan mac */
162 .compatible = "qcom,wcnss-wlan",
163 .property = "local-mac-address",
166 /* update the kernel's dtb with bt mac */
167 .compatible = "qcom,wcnss-bt",
168 .property = "local-bd-address",
172 for (i = 0; i < sizeof(fix) / sizeof(fix[0]); i++) {
173 offset = fdt_node_offset_by_compatible(gd->fdt_blob, -1,
178 mac = fdt_getprop(gd->fdt_blob, offset, fix[i].property, &len);
180 do_fixup_by_compat(blob, fix[i].compatible,
181 fix[i].property, mac, ARP_HLEN, 1);
184 msm_fixup_memory(blob);
189 void reset_cpu(ulong addr)