]>
git.ipfire.org Git - thirdparty/u-boot.git/blob - board/qualcomm/dragonboard410c/dragonboard410c.c
1 // SPDX-License-Identifier: GPL-2.0+
3 * Board init file for Dragonboard 410C
5 * (C) Copyright 2015 Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
13 #include <fdt_support.h>
14 #include <asm/arch/dram.h>
15 #include <asm/arch/misc.h>
17 DECLARE_GLOBAL_DATA_PTR
;
19 /* pointer to the device tree ammended by the firmware */
22 void *board_fdt_blob_setup(void)
24 if (fdt_magic(fw_dtb
) != FDT_MAGIC
) {
25 printf("Firmware provided invalid dtb!\n");
34 gd
->ram_size
= PHYS_SDRAM_1_SIZE
;
39 int dram_init_banksize(void)
41 gd
->bd
->bi_dram
[0].start
= PHYS_SDRAM_1
;
42 gd
->bd
->bi_dram
[0].size
= PHYS_SDRAM_1_SIZE
;
47 int board_usb_init(int index
, enum usb_init_type init
)
49 static struct udevice
*pmic_gpio
;
50 static struct gpio_desc hub_reset
, usb_sel
;
54 ret
= uclass_get_device_by_name(UCLASS_GPIO
,
58 printf("Failed to find pm8916_gpios@c000 node.\n");
63 /* Try to request gpios needed to start usb host on dragonboard */
64 if (!dm_gpio_is_valid(&hub_reset
)) {
65 node
= fdt_subnode_offset(gd
->fdt_blob
,
66 dev_of_offset(pmic_gpio
),
69 printf("Failed to find usb_hub_reset_pm dt node.\n");
72 ret
= gpio_request_by_name_nodev(offset_to_ofnode(node
),
73 "gpios", 0, &hub_reset
, 0);
75 printf("Failed to request usb_hub_reset_pm gpio.\n");
80 if (!dm_gpio_is_valid(&usb_sel
)) {
81 node
= fdt_subnode_offset(gd
->fdt_blob
,
82 dev_of_offset(pmic_gpio
),
85 printf("Failed to find usb_sw_sel_pm dt node.\n");
88 ret
= gpio_request_by_name_nodev(offset_to_ofnode(node
),
89 "gpios", 0, &usb_sel
, 0);
91 printf("Failed to request usb_sw_sel_pm gpio.\n");
96 if (init
== USB_INIT_HOST
) {
98 dm_gpio_set_dir_flags(&hub_reset
,
99 GPIOD_IS_OUT
| GPIOD_IS_OUT_ACTIVE
);
101 /* Switch usb to host connectors */
102 dm_gpio_set_dir_flags(&usb_sel
,
103 GPIOD_IS_OUT
| GPIOD_IS_OUT_ACTIVE
);
105 } else { /* Device */
107 dm_gpio_set_dir_flags(&hub_reset
, GPIOD_IS_OUT
);
108 /* Switch back to device connector */
109 dm_gpio_set_dir_flags(&usb_sel
, GPIOD_IS_OUT
);
115 /* Check for vol- button - if pressed - stop autoboot */
116 int misc_init_r(void)
119 struct gpio_desc resin
;
122 ret
= uclass_get_device_by_name(UCLASS_GPIO
, "pm8916_pon@800", &pon
);
124 printf("Failed to find PMIC pon node. Check device tree\n");
128 node
= fdt_subnode_offset(gd
->fdt_blob
, dev_of_offset(pon
),
131 printf("Failed to find key_vol_down node. Check device tree\n");
135 if (gpio_request_by_name_nodev(offset_to_ofnode(node
), "gpios", 0,
137 printf("Failed to request key_vol_down button.\n");
141 if (dm_gpio_get_value(&resin
)) {
142 env_set("bootdelay", "-1");
143 env_set("bootcmd", "fastboot 0");
144 printf("key_vol_down pressed - Starting fastboot.\n");
155 int board_late_init(void)
159 memset(serial
, 0, 16);
160 snprintf(serial
, 13, "%x", msm_board_serial());
161 env_set("serial#", serial
);
165 /* Fixup of DTB for Linux Kernel
166 * 1. Fixup installed DRAM.
167 * 2. Fixup WLAN/BT Mac address:
168 * First, check if MAC addresses for WLAN/BT exists as environemnt
169 * variables wlanaddr,btaddr. if not, generate a unique address.
172 int ft_board_setup(void *blob
, bd_t
*bd
)
176 msm_fixup_memory(blob
);
178 if (!eth_env_get_enetaddr("wlanaddr", mac
)) {
179 msm_generate_mac_addr(mac
);
182 do_fixup_by_compat(blob
, "qcom,wcnss-wlan",
183 "local-mac-address", mac
, ARP_HLEN
, 1);
186 if (!eth_env_get_enetaddr("btaddr", mac
)) {
187 msm_generate_mac_addr(mac
);
189 /* The BD address is same as WLAN MAC address but with
190 * least significant bit flipped.
195 do_fixup_by_compat(blob
, "qcom,wcnss-bt",
196 "local-bd-address", mac
, ARP_HLEN
, 1);
200 void reset_cpu(ulong addr
)