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>
16 #include <asm/global_data.h>
18 #include <fdt_support.h>
19 #include <asm/arch/dram.h>
20 #include <asm/arch/misc.h>
21 #include <linux/delay.h>
23 DECLARE_GLOBAL_DATA_PTR;
27 gd->ram_size = PHYS_SDRAM_1_SIZE;
32 int dram_init_banksize(void)
34 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
35 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
40 int board_usb_init(int index, enum usb_init_type init)
42 static struct udevice *pmic_gpio;
43 static struct gpio_desc hub_reset, usb_sel;
47 ret = uclass_get_device_by_name(UCLASS_GPIO,
51 printf("Failed to find pm8916_gpios@c000 node.\n");
56 /* Try to request gpios needed to start usb host on dragonboard */
57 if (!dm_gpio_is_valid(&hub_reset)) {
58 node = fdt_subnode_offset(gd->fdt_blob,
59 dev_of_offset(pmic_gpio),
62 printf("Failed to find usb_hub_reset_pm dt node.\n");
65 ret = gpio_request_by_name_nodev(offset_to_ofnode(node),
66 "gpios", 0, &hub_reset, 0);
68 printf("Failed to request usb_hub_reset_pm gpio.\n");
73 if (!dm_gpio_is_valid(&usb_sel)) {
74 node = fdt_subnode_offset(gd->fdt_blob,
75 dev_of_offset(pmic_gpio),
78 printf("Failed to find usb_sw_sel_pm dt node.\n");
81 ret = gpio_request_by_name_nodev(offset_to_ofnode(node),
82 "gpios", 0, &usb_sel, 0);
84 printf("Failed to request usb_sw_sel_pm gpio.\n");
89 if (init == USB_INIT_HOST) {
91 dm_gpio_set_dir_flags(&hub_reset,
92 GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
94 /* Switch usb to host connectors */
95 dm_gpio_set_dir_flags(&usb_sel,
96 GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
100 dm_gpio_set_dir_flags(&hub_reset, GPIOD_IS_OUT);
101 /* Switch back to device connector */
102 dm_gpio_set_dir_flags(&usb_sel, GPIOD_IS_OUT);
108 /* Check for vol- button - if pressed - stop autoboot */
109 int misc_init_r(void)
112 struct gpio_desc resin;
115 ret = uclass_get_device_by_name(UCLASS_GPIO, "pm8916_pon@800", &pon);
117 printf("Failed to find PMIC pon node. Check device tree\n");
121 node = fdt_subnode_offset(gd->fdt_blob, dev_of_offset(pon),
124 printf("Failed to find key_vol_down node. Check device tree\n");
128 if (gpio_request_by_name_nodev(offset_to_ofnode(node), "gpios", 0,
130 printf("Failed to request key_vol_down button.\n");
134 if (dm_gpio_get_value(&resin)) {
135 env_set("bootdelay", "-1");
136 env_set("bootcmd", "fastboot 0");
137 printf("key_vol_down pressed - Starting fastboot.\n");
148 int board_late_init(void)
152 memset(serial, 0, 16);
153 snprintf(serial, 13, "%x", msm_board_serial());
154 env_set("serial#", serial);
158 /* Fixup of DTB for Linux Kernel
159 * 1. Fixup installed DRAM.
160 * 2. Fixup WLAN/BT Mac address:
161 * First, check if MAC addresses for WLAN/BT exists as environemnt
162 * variables wlanaddr,btaddr. if not, generate a unique address.
165 int ft_board_setup(void *blob, struct bd_info *bd)
169 msm_fixup_memory(blob);
171 if (!eth_env_get_enetaddr("wlanaddr", mac)) {
172 msm_generate_mac_addr(mac);
175 do_fixup_by_compat(blob, "qcom,wcnss-wlan",
176 "local-mac-address", mac, ARP_HLEN, 1);
179 if (!eth_env_get_enetaddr("btaddr", mac)) {
180 msm_generate_mac_addr(mac);
182 /* The BD address is same as WLAN MAC address but with
183 * least significant bit flipped.
188 do_fixup_by_compat(blob, "qcom,wcnss-bt",
189 "local-bd-address", mac, ARP_HLEN, 1);