1 // SPDX-License-Identifier: GPL-2.0+
3 * Board init file for Dragonboard 410C
5 * (C) Copyright 2015 Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
13 #include <fdt_support.h>
14 #include <environment.h>
15 #include <asm/arch/dram.h>
16 #include <asm/arch/misc.h>
18 DECLARE_GLOBAL_DATA_PTR;
20 /* pointer to the device tree ammended by the firmware */
23 void *board_fdt_blob_setup(void)
25 if (fdt_magic(fw_dtb) != FDT_MAGIC) {
26 printf("Firmware provided invalid dtb!\n");
35 gd->ram_size = PHYS_SDRAM_1_SIZE;
40 int dram_init_banksize(void)
42 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
43 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
48 int board_usb_init(int index, enum usb_init_type init)
50 static struct udevice *pmic_gpio;
51 static struct gpio_desc hub_reset, usb_sel;
55 ret = uclass_get_device_by_name(UCLASS_GPIO,
59 printf("Failed to find pm8916_gpios@c000 node.\n");
64 /* Try to request gpios needed to start usb host on dragonboard */
65 if (!dm_gpio_is_valid(&hub_reset)) {
66 node = fdt_subnode_offset(gd->fdt_blob,
67 dev_of_offset(pmic_gpio),
70 printf("Failed to find usb_hub_reset_pm dt node.\n");
73 ret = gpio_request_by_name_nodev(offset_to_ofnode(node),
74 "gpios", 0, &hub_reset, 0);
76 printf("Failed to request usb_hub_reset_pm gpio.\n");
81 if (!dm_gpio_is_valid(&usb_sel)) {
82 node = fdt_subnode_offset(gd->fdt_blob,
83 dev_of_offset(pmic_gpio),
86 printf("Failed to find usb_sw_sel_pm dt node.\n");
89 ret = gpio_request_by_name_nodev(offset_to_ofnode(node),
90 "gpios", 0, &usb_sel, 0);
92 printf("Failed to request usb_sw_sel_pm gpio.\n");
97 if (init == USB_INIT_HOST) {
99 dm_gpio_set_dir_flags(&hub_reset,
100 GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
102 /* Switch usb to host connectors */
103 dm_gpio_set_dir_flags(&usb_sel,
104 GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
106 } else { /* Device */
108 dm_gpio_set_dir_flags(&hub_reset, GPIOD_IS_OUT);
109 /* Switch back to device connector */
110 dm_gpio_set_dir_flags(&usb_sel, GPIOD_IS_OUT);
116 /* Check for vol- button - if pressed - stop autoboot */
117 int misc_init_r(void)
120 struct gpio_desc resin;
123 ret = uclass_get_device_by_name(UCLASS_GPIO, "pm8916_pon@800", &pon);
125 printf("Failed to find PMIC pon node. Check device tree\n");
129 node = fdt_subnode_offset(gd->fdt_blob, dev_of_offset(pon),
132 printf("Failed to find key_vol_down node. Check device tree\n");
136 if (gpio_request_by_name_nodev(offset_to_ofnode(node), "gpios", 0,
138 printf("Failed to request key_vol_down button.\n");
142 if (dm_gpio_get_value(&resin)) {
143 env_set("bootdelay", "-1");
144 env_set("bootcmd", "fastboot 0");
145 printf("key_vol_down pressed - Starting fastboot.\n");
156 int board_late_init(void)
160 memset(serial, 0, 16);
161 snprintf(serial, 13, "%x", msm_board_serial());
162 env_set("serial#", serial);
166 /* Fixup of DTB for Linux Kernel
167 * 1. Fixup installed DRAM.
168 * 2. Fixup WLAN/BT Mac address:
169 * First, check if MAC addresses for WLAN/BT exists as environemnt
170 * variables wlanaddr,btaddr. if not, generate a unique address.
173 int ft_board_setup(void *blob, bd_t *bd)
177 msm_fixup_memory(blob);
179 if (!eth_env_get_enetaddr("wlanaddr", mac)) {
180 msm_generate_mac_addr(mac);
183 do_fixup_by_compat(blob, "qcom,wcnss-wlan",
184 "local-mac-address", mac, ARP_HLEN, 1);
187 if (!eth_env_get_enetaddr("btaddr", mac)) {
188 msm_generate_mac_addr(mac);
190 /* The BD address is same as WLAN MAC address but with
191 * least significant bit flipped.
196 do_fixup_by_compat(blob, "qcom,wcnss-bt",
197 "local-bd-address", mac, ARP_HLEN, 1);
201 void reset_cpu(ulong addr)