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>
20 #include <linux/delay.h>
22 DECLARE_GLOBAL_DATA_PTR;
24 /* pointer to the device tree ammended by the firmware */
27 void *board_fdt_blob_setup(void)
29 if (fdt_magic(fw_dtb) != FDT_MAGIC) {
30 printf("Firmware provided invalid dtb!\n");
39 gd->ram_size = PHYS_SDRAM_1_SIZE;
44 int dram_init_banksize(void)
46 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
47 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
52 int board_usb_init(int index, enum usb_init_type init)
54 static struct udevice *pmic_gpio;
55 static struct gpio_desc hub_reset, usb_sel;
59 ret = uclass_get_device_by_name(UCLASS_GPIO,
63 printf("Failed to find pm8916_gpios@c000 node.\n");
68 /* Try to request gpios needed to start usb host on dragonboard */
69 if (!dm_gpio_is_valid(&hub_reset)) {
70 node = fdt_subnode_offset(gd->fdt_blob,
71 dev_of_offset(pmic_gpio),
74 printf("Failed to find usb_hub_reset_pm dt node.\n");
77 ret = gpio_request_by_name_nodev(offset_to_ofnode(node),
78 "gpios", 0, &hub_reset, 0);
80 printf("Failed to request usb_hub_reset_pm gpio.\n");
85 if (!dm_gpio_is_valid(&usb_sel)) {
86 node = fdt_subnode_offset(gd->fdt_blob,
87 dev_of_offset(pmic_gpio),
90 printf("Failed to find usb_sw_sel_pm dt node.\n");
93 ret = gpio_request_by_name_nodev(offset_to_ofnode(node),
94 "gpios", 0, &usb_sel, 0);
96 printf("Failed to request usb_sw_sel_pm gpio.\n");
101 if (init == USB_INIT_HOST) {
103 dm_gpio_set_dir_flags(&hub_reset,
104 GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
106 /* Switch usb to host connectors */
107 dm_gpio_set_dir_flags(&usb_sel,
108 GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
110 } else { /* Device */
112 dm_gpio_set_dir_flags(&hub_reset, GPIOD_IS_OUT);
113 /* Switch back to device connector */
114 dm_gpio_set_dir_flags(&usb_sel, GPIOD_IS_OUT);
120 /* Check for vol- button - if pressed - stop autoboot */
121 int misc_init_r(void)
124 struct gpio_desc resin;
127 ret = uclass_get_device_by_name(UCLASS_GPIO, "pm8916_pon@800", &pon);
129 printf("Failed to find PMIC pon node. Check device tree\n");
133 node = fdt_subnode_offset(gd->fdt_blob, dev_of_offset(pon),
136 printf("Failed to find key_vol_down node. Check device tree\n");
140 if (gpio_request_by_name_nodev(offset_to_ofnode(node), "gpios", 0,
142 printf("Failed to request key_vol_down button.\n");
146 if (dm_gpio_get_value(&resin)) {
147 env_set("bootdelay", "-1");
148 env_set("bootcmd", "fastboot 0");
149 printf("key_vol_down pressed - Starting fastboot.\n");
160 int board_late_init(void)
164 memset(serial, 0, 16);
165 snprintf(serial, 13, "%x", msm_board_serial());
166 env_set("serial#", serial);
170 /* Fixup of DTB for Linux Kernel
171 * 1. Fixup installed DRAM.
172 * 2. Fixup WLAN/BT Mac address:
173 * First, check if MAC addresses for WLAN/BT exists as environemnt
174 * variables wlanaddr,btaddr. if not, generate a unique address.
177 int ft_board_setup(void *blob, bd_t *bd)
181 msm_fixup_memory(blob);
183 if (!eth_env_get_enetaddr("wlanaddr", mac)) {
184 msm_generate_mac_addr(mac);
187 do_fixup_by_compat(blob, "qcom,wcnss-wlan",
188 "local-mac-address", mac, ARP_HLEN, 1);
191 if (!eth_env_get_enetaddr("btaddr", mac)) {
192 msm_generate_mac_addr(mac);
194 /* The BD address is same as WLAN MAC address but with
195 * least significant bit flipped.
200 do_fixup_by_compat(blob, "qcom,wcnss-bt",
201 "local-bd-address", mac, ARP_HLEN, 1);
205 void reset_cpu(ulong addr)