2 * Board init file for Dragonboard 410C
4 * (C) Copyright 2015 Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
6 * SPDX-License-Identifier: GPL-2.0+
13 #include <fdt_support.h>
15 DECLARE_GLOBAL_DATA_PTR;
17 /* pointer to the device tree ammended by the firmware */
18 extern const void *fw_dtb;
20 static char wlan_mac[ARP_HLEN];
21 static char bt_mac[ARP_HLEN];
25 gd->ram_size = PHYS_SDRAM_1_SIZE;
29 int dram_init_banksize(void)
31 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
32 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
37 int board_prepare_usb(enum usb_init_type type)
39 static struct udevice *pmic_gpio;
40 static struct gpio_desc hub_reset, usb_sel;
44 ret = uclass_get_device_by_name(UCLASS_GPIO,
48 printf("Failed to find pm8916_gpios@c000 node.\n");
53 /* Try to request gpios needed to start usb host on dragonboard */
54 if (!dm_gpio_is_valid(&hub_reset)) {
55 node = fdt_subnode_offset(gd->fdt_blob,
56 dev_of_offset(pmic_gpio),
59 printf("Failed to find usb_hub_reset_pm dt node.\n");
62 ret = gpio_request_by_name_nodev(offset_to_ofnode(node),
63 "gpios", 0, &hub_reset, 0);
65 printf("Failed to request usb_hub_reset_pm gpio.\n");
70 if (!dm_gpio_is_valid(&usb_sel)) {
71 node = fdt_subnode_offset(gd->fdt_blob,
72 dev_of_offset(pmic_gpio),
75 printf("Failed to find usb_sw_sel_pm dt node.\n");
78 ret = gpio_request_by_name_nodev(offset_to_ofnode(node),
79 "gpios", 0, &usb_sel, 0);
81 printf("Failed to request usb_sw_sel_pm gpio.\n");
86 if (type == USB_INIT_HOST) {
88 dm_gpio_set_dir_flags(&hub_reset,
89 GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
91 /* Switch usb to host connectors */
92 dm_gpio_set_dir_flags(&usb_sel,
93 GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
97 dm_gpio_set_dir_flags(&hub_reset, GPIOD_IS_OUT);
98 /* Switch back to device connector */
99 dm_gpio_set_dir_flags(&usb_sel, GPIOD_IS_OUT);
105 /* Check for vol- button - if pressed - stop autoboot */
106 int misc_init_r(void)
109 struct gpio_desc resin;
112 ret = uclass_get_device_by_name(UCLASS_GPIO, "pm8916_pon@800", &pon);
114 printf("Failed to find PMIC pon node. Check device tree\n");
118 node = fdt_subnode_offset(gd->fdt_blob, dev_of_offset(pon),
121 printf("Failed to find key_vol_down node. Check device tree\n");
125 if (gpio_request_by_name_nodev(offset_to_ofnode(node), "gpios", 0,
127 printf("Failed to request key_vol_down button.\n");
131 if (dm_gpio_get_value(&resin)) {
132 env_set("bootdelay", "-1");
133 printf("Power button pressed - dropping to console.\n");
144 /* take a copy of the firmware information (the user could unknownly
145 overwrite that DDR via tftp or other means) */
147 offset = fdt_node_offset_by_compatible(fw_dtb, -1, "qcom,wcnss-wlan");
149 mac = fdt_getprop(fw_dtb, offset, "local-mac-address", &len);
151 memcpy(wlan_mac, mac, ARP_HLEN);
154 offset = fdt_node_offset_by_compatible(fw_dtb, -1, "qcom,wcnss-bt");
156 mac = fdt_getprop(fw_dtb, offset, "local-bd-address", &len);
158 memcpy(bt_mac, mac, ARP_HLEN);
164 int ft_board_setup(void *blob, bd_t *bd)
166 do_fixup_by_compat(blob, "qcom,wcnss-wlan", "local-mac-address",
167 wlan_mac, ARP_HLEN, 1);
169 do_fixup_by_compat(blob, "qcom,wcnss-bt", "local-bd-address",
170 bt_mac, ARP_HLEN, 1);