1 // SPDX-License-Identifier: GPL-2.0+
3 * Board init file for Dragonboard 410C
5 * (C) Copyright 2015 Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
15 #include <fdt_support.h>
16 #include <asm/arch/dram.h>
17 #include <asm/arch/misc.h>
19 DECLARE_GLOBAL_DATA_PTR;
21 /* pointer to the device tree ammended by the firmware */
24 void *board_fdt_blob_setup(void)
26 if (fdt_magic(fw_dtb) != FDT_MAGIC) {
27 printf("Firmware provided invalid dtb!\n");
36 gd->ram_size = PHYS_SDRAM_1_SIZE;
41 int dram_init_banksize(void)
43 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
44 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
49 int board_usb_init(int index, enum usb_init_type init)
51 static struct udevice *pmic_gpio;
52 static struct gpio_desc hub_reset, usb_sel;
56 ret = uclass_get_device_by_name(UCLASS_GPIO,
60 printf("Failed to find pm8916_gpios@c000 node.\n");
65 /* Try to request gpios needed to start usb host on dragonboard */
66 if (!dm_gpio_is_valid(&hub_reset)) {
67 node = fdt_subnode_offset(gd->fdt_blob,
68 dev_of_offset(pmic_gpio),
71 printf("Failed to find usb_hub_reset_pm dt node.\n");
74 ret = gpio_request_by_name_nodev(offset_to_ofnode(node),
75 "gpios", 0, &hub_reset, 0);
77 printf("Failed to request usb_hub_reset_pm gpio.\n");
82 if (!dm_gpio_is_valid(&usb_sel)) {
83 node = fdt_subnode_offset(gd->fdt_blob,
84 dev_of_offset(pmic_gpio),
87 printf("Failed to find usb_sw_sel_pm dt node.\n");
90 ret = gpio_request_by_name_nodev(offset_to_ofnode(node),
91 "gpios", 0, &usb_sel, 0);
93 printf("Failed to request usb_sw_sel_pm gpio.\n");
98 if (init == USB_INIT_HOST) {
100 dm_gpio_set_dir_flags(&hub_reset,
101 GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
103 /* Switch usb to host connectors */
104 dm_gpio_set_dir_flags(&usb_sel,
105 GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
107 } else { /* Device */
109 dm_gpio_set_dir_flags(&hub_reset, GPIOD_IS_OUT);
110 /* Switch back to device connector */
111 dm_gpio_set_dir_flags(&usb_sel, GPIOD_IS_OUT);
117 /* Check for vol- button - if pressed - stop autoboot */
118 int misc_init_r(void)
121 struct gpio_desc resin;
124 ret = uclass_get_device_by_name(UCLASS_GPIO, "pm8916_pon@800", &pon);
126 printf("Failed to find PMIC pon node. Check device tree\n");
130 node = fdt_subnode_offset(gd->fdt_blob, dev_of_offset(pon),
133 printf("Failed to find key_vol_down node. Check device tree\n");
137 if (gpio_request_by_name_nodev(offset_to_ofnode(node), "gpios", 0,
139 printf("Failed to request key_vol_down button.\n");
143 if (dm_gpio_get_value(&resin)) {
144 env_set("bootdelay", "-1");
145 env_set("bootcmd", "fastboot 0");
146 printf("key_vol_down pressed - Starting fastboot.\n");
157 int board_late_init(void)
161 memset(serial, 0, 16);
162 snprintf(serial, 13, "%x", msm_board_serial());
163 env_set("serial#", serial);
167 /* Fixup of DTB for Linux Kernel
168 * 1. Fixup installed DRAM.
169 * 2. Fixup WLAN/BT Mac address:
170 * First, check if MAC addresses for WLAN/BT exists as environemnt
171 * variables wlanaddr,btaddr. if not, generate a unique address.
174 int ft_board_setup(void *blob, bd_t *bd)
178 msm_fixup_memory(blob);
180 if (!eth_env_get_enetaddr("wlanaddr", mac)) {
181 msm_generate_mac_addr(mac);
184 do_fixup_by_compat(blob, "qcom,wcnss-wlan",
185 "local-mac-address", mac, ARP_HLEN, 1);
188 if (!eth_env_get_enetaddr("btaddr", mac)) {
189 msm_generate_mac_addr(mac);
191 /* The BD address is same as WLAN MAC address but with
192 * least significant bit flipped.
197 do_fixup_by_compat(blob, "qcom,wcnss-bt",
198 "local-bd-address", mac, ARP_HLEN, 1);
202 void reset_cpu(ulong addr)