Commit 9337dfb4342a7bf2164405cdcb9c92b857ea0974

Authored by Jorge Ramirez-Ortiz
Committed by Tom Rini
1 parent 3b595da441

db410c: use the device tree parsed by the lk loader.

We dont need to keep copies of the properties that we are going to
fixup since we will be using the dtb provided by the firmware.

Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>

Showing 2 changed files with 41 additions and 28 deletions Side-by-side Diff

board/qualcomm/dragonboard410c/dragonboard410c.c
... ... @@ -15,14 +15,22 @@
15 15 DECLARE_GLOBAL_DATA_PTR;
16 16  
17 17 /* pointer to the device tree ammended by the firmware */
18   -extern const void *fw_dtb;
  18 +extern void *fw_dtb;
19 19  
20   -static char wlan_mac[ARP_HLEN];
21   -static char bt_mac[ARP_HLEN];
  20 +void *board_fdt_blob_setup(void)
  21 +{
  22 + if (fdt_magic(fw_dtb) != FDT_MAGIC) {
  23 + printf("Firmware provided invalid dtb!\n");
  24 + return NULL;
  25 + }
22 26  
  27 + return fw_dtb;
  28 +}
  29 +
23 30 int dram_init(void)
24 31 {
25 32 gd->ram_size = PHYS_SDRAM_1_SIZE;
  33 +
26 34 return 0;
27 35 }
28 36  
29 37  
30 38  
... ... @@ -138,36 +146,40 @@
138 146  
139 147 int board_init(void)
140 148 {
141   - int offset, len;
142   - const char *mac;
143   -
144   - /* take a copy of the firmware information (the user could unknownly
145   - overwrite that DDR via tftp or other means) */
146   -
147   - offset = fdt_node_offset_by_compatible(fw_dtb, -1, "qcom,wcnss-wlan");
148   - if (offset >= 0) {
149   - mac = fdt_getprop(fw_dtb, offset, "local-mac-address", &len);
150   - if (mac)
151   - memcpy(wlan_mac, mac, ARP_HLEN);
152   - }
153   -
154   - offset = fdt_node_offset_by_compatible(fw_dtb, -1, "qcom,wcnss-bt");
155   - if (offset >= 0) {
156   - mac = fdt_getprop(fw_dtb, offset, "local-bd-address", &len);
157   - if (mac)
158   - memcpy(bt_mac, mac, ARP_HLEN);
159   - }
160   -
161 149 return 0;
162 150 }
163 151  
164 152 int ft_board_setup(void *blob, bd_t *bd)
165 153 {
166   - do_fixup_by_compat(blob, "qcom,wcnss-wlan", "local-mac-address",
167   - wlan_mac, ARP_HLEN, 1);
  154 + int offset, len, i;
  155 + const char *mac;
  156 + struct {
  157 + const char *compatible;
  158 + const char *property;
  159 + } fix[] = {
  160 + [0] = {
  161 + /* update the kernel's dtb with wlan mac */
  162 + .compatible = "qcom,wcnss-wlan",
  163 + .property = "local-mac-address",
  164 + },
  165 + [1] = {
  166 + /* update the kernel's dtb with bt mac */
  167 + .compatible = "qcom,wcnss-bt",
  168 + .property = "local-bd-address",
  169 + },
  170 + };
168 171  
169   - do_fixup_by_compat(blob, "qcom,wcnss-bt", "local-bd-address",
170   - bt_mac, ARP_HLEN, 1);
  172 + for (i = 0; i < sizeof(fix) / sizeof(fix[0]); i++) {
  173 + offset = fdt_node_offset_by_compatible(gd->fdt_blob, -1,
  174 + fix[i].compatible);
  175 + if (offset < 0)
  176 + continue;
  177 +
  178 + mac = fdt_getprop(gd->fdt_blob, offset, fix[i].property, &len);
  179 + if (mac)
  180 + do_fixup_by_compat(blob, fix[i].compatible,
  181 + fix[i].property, mac, ARP_HLEN, 1);
  182 + }
171 183  
172 184 return 0;
173 185 }
configs/dragonboard410c_defconfig
... ... @@ -47,4 +47,5 @@
47 47 CONFIG_ENV_IS_IN_MMC=y
48 48 CONFIG_OF_BOARD_SETUP=y
49 49 CONFIG_PSCI_RESET=y
  50 +CONFIG_OF_SEPARATE=y