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 <asm/cache.h>
17 #include <fdt_support.h>
18 #include <asm/arch/dram.h>
19 #include <asm/arch/misc.h>
21 DECLARE_GLOBAL_DATA_PTR;
23 /* pointer to the device tree ammended by the firmware */
26 void *board_fdt_blob_setup(void)
28 if (fdt_magic(fw_dtb) != FDT_MAGIC) {
29 printf("Firmware provided invalid dtb!\n");
38 gd->ram_size = PHYS_SDRAM_1_SIZE;
43 int dram_init_banksize(void)
45 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
46 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
51 int board_usb_init(int index, enum usb_init_type init)
53 static struct udevice *pmic_gpio;
54 static struct gpio_desc hub_reset, usb_sel;
58 ret = uclass_get_device_by_name(UCLASS_GPIO,
62 printf("Failed to find pm8916_gpios@c000 node.\n");
67 /* Try to request gpios needed to start usb host on dragonboard */
68 if (!dm_gpio_is_valid(&hub_reset)) {
69 node = fdt_subnode_offset(gd->fdt_blob,
70 dev_of_offset(pmic_gpio),
73 printf("Failed to find usb_hub_reset_pm dt node.\n");
76 ret = gpio_request_by_name_nodev(offset_to_ofnode(node),
77 "gpios", 0, &hub_reset, 0);
79 printf("Failed to request usb_hub_reset_pm gpio.\n");
84 if (!dm_gpio_is_valid(&usb_sel)) {
85 node = fdt_subnode_offset(gd->fdt_blob,
86 dev_of_offset(pmic_gpio),
89 printf("Failed to find usb_sw_sel_pm dt node.\n");
92 ret = gpio_request_by_name_nodev(offset_to_ofnode(node),
93 "gpios", 0, &usb_sel, 0);
95 printf("Failed to request usb_sw_sel_pm gpio.\n");
100 if (init == USB_INIT_HOST) {
102 dm_gpio_set_dir_flags(&hub_reset,
103 GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
105 /* Switch usb to host connectors */
106 dm_gpio_set_dir_flags(&usb_sel,
107 GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
109 } else { /* Device */
111 dm_gpio_set_dir_flags(&hub_reset, GPIOD_IS_OUT);
112 /* Switch back to device connector */
113 dm_gpio_set_dir_flags(&usb_sel, GPIOD_IS_OUT);
119 /* Check for vol- button - if pressed - stop autoboot */
120 int misc_init_r(void)
123 struct gpio_desc resin;
126 ret = uclass_get_device_by_name(UCLASS_GPIO, "pm8916_pon@800", &pon);
128 printf("Failed to find PMIC pon node. Check device tree\n");
132 node = fdt_subnode_offset(gd->fdt_blob, dev_of_offset(pon),
135 printf("Failed to find key_vol_down node. Check device tree\n");
139 if (gpio_request_by_name_nodev(offset_to_ofnode(node), "gpios", 0,
141 printf("Failed to request key_vol_down button.\n");
145 if (dm_gpio_get_value(&resin)) {
146 env_set("bootdelay", "-1");
147 env_set("bootcmd", "fastboot 0");
148 printf("key_vol_down pressed - Starting fastboot.\n");
159 int board_late_init(void)
163 memset(serial, 0, 16);
164 snprintf(serial, 13, "%x", msm_board_serial());
165 env_set("serial#", serial);
169 /* Fixup of DTB for Linux Kernel
170 * 1. Fixup installed DRAM.
171 * 2. Fixup WLAN/BT Mac address:
172 * First, check if MAC addresses for WLAN/BT exists as environemnt
173 * variables wlanaddr,btaddr. if not, generate a unique address.
176 int ft_board_setup(void *blob, bd_t *bd)
180 msm_fixup_memory(blob);
182 if (!eth_env_get_enetaddr("wlanaddr", mac)) {
183 msm_generate_mac_addr(mac);
186 do_fixup_by_compat(blob, "qcom,wcnss-wlan",
187 "local-mac-address", mac, ARP_HLEN, 1);
190 if (!eth_env_get_enetaddr("btaddr", mac)) {
191 msm_generate_mac_addr(mac);
193 /* The BD address is same as WLAN MAC address but with
194 * least significant bit flipped.
199 do_fixup_by_compat(blob, "qcom,wcnss-bt",
200 "local-bd-address", mac, ARP_HLEN, 1);
204 void reset_cpu(ulong addr)