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>
14 DECLARE_GLOBAL_DATA_PTR;
16 /* pointer to the device tree ammended by the firmware */
19 void *board_fdt_blob_setup(void)
21 if (fdt_magic(fw_dtb) != FDT_MAGIC) {
22 printf("Firmware provided invalid dtb!\n");
31 gd->ram_size = PHYS_SDRAM_1_SIZE;
36 int dram_init_banksize(void)
38 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
39 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
44 int board_prepare_usb(enum usb_init_type type)
46 static struct udevice *pmic_gpio;
47 static struct gpio_desc hub_reset, usb_sel;
51 ret = uclass_get_device_by_name(UCLASS_GPIO,
55 printf("Failed to find pm8916_gpios@c000 node.\n");
60 /* Try to request gpios needed to start usb host on dragonboard */
61 if (!dm_gpio_is_valid(&hub_reset)) {
62 node = fdt_subnode_offset(gd->fdt_blob,
63 dev_of_offset(pmic_gpio),
66 printf("Failed to find usb_hub_reset_pm dt node.\n");
69 ret = gpio_request_by_name_nodev(offset_to_ofnode(node),
70 "gpios", 0, &hub_reset, 0);
72 printf("Failed to request usb_hub_reset_pm gpio.\n");
77 if (!dm_gpio_is_valid(&usb_sel)) {
78 node = fdt_subnode_offset(gd->fdt_blob,
79 dev_of_offset(pmic_gpio),
82 printf("Failed to find usb_sw_sel_pm dt node.\n");
85 ret = gpio_request_by_name_nodev(offset_to_ofnode(node),
86 "gpios", 0, &usb_sel, 0);
88 printf("Failed to request usb_sw_sel_pm gpio.\n");
93 if (type == USB_INIT_HOST) {
95 dm_gpio_set_dir_flags(&hub_reset,
96 GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
98 /* Switch usb to host connectors */
99 dm_gpio_set_dir_flags(&usb_sel,
100 GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
102 } else { /* Device */
104 dm_gpio_set_dir_flags(&hub_reset, GPIOD_IS_OUT);
105 /* Switch back to device connector */
106 dm_gpio_set_dir_flags(&usb_sel, GPIOD_IS_OUT);
112 /* Check for vol- button - if pressed - stop autoboot */
113 int misc_init_r(void)
116 struct gpio_desc resin;
119 ret = uclass_get_device_by_name(UCLASS_GPIO, "pm8916_pon@800", &pon);
121 printf("Failed to find PMIC pon node. Check device tree\n");
125 node = fdt_subnode_offset(gd->fdt_blob, dev_of_offset(pon),
128 printf("Failed to find key_vol_down node. Check device tree\n");
132 if (gpio_request_by_name_nodev(offset_to_ofnode(node), "gpios", 0,
134 printf("Failed to request key_vol_down button.\n");
138 if (dm_gpio_get_value(&resin)) {
139 env_set("bootdelay", "-1");
140 printf("Power button pressed - dropping to console.\n");
151 int ft_board_setup(void *blob, bd_t *bd)
156 const char *compatible;
157 const char *property;
160 /* update the kernel's dtb with wlan mac */
161 .compatible = "qcom,wcnss-wlan",
162 .property = "local-mac-address",
165 /* update the kernel's dtb with bt mac */
166 .compatible = "qcom,wcnss-bt",
167 .property = "local-bd-address",
171 for (i = 0; i < sizeof(fix) / sizeof(fix[0]); i++) {
172 offset = fdt_node_offset_by_compatible(gd->fdt_blob, -1,
177 mac = fdt_getprop(gd->fdt_blob, offset, fix[i].property, &len);
179 do_fixup_by_compat(blob, fix[i].compatible,
180 fix[i].property, mac, ARP_HLEN, 1);
186 void reset_cpu(ulong addr)