common: Drop net.h from common header
[oweals/u-boot.git] / board / qualcomm / dragonboard410c / dragonboard410c.c
index e7ead57f0dac313caab6ace495cee64be4f379bd..75505d0c189746e309e2d073008189426fc3ce99 100644 (file)
@@ -6,10 +6,17 @@
  */
 
 #include <common.h>
+#include <cpu_func.h>
 #include <dm.h>
+#include <env.h>
+#include <init.h>
+#include <net.h>
 #include <usb.h>
+#include <asm/cache.h>
 #include <asm/gpio.h>
 #include <fdt_support.h>
+#include <asm/arch/dram.h>
+#include <asm/arch/misc.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -41,7 +48,7 @@ int dram_init_banksize(void)
        return 0;
 }
 
-int board_prepare_usb(enum usb_init_type type)
+int board_usb_init(int index, enum usb_init_type init)
 {
        static struct udevice *pmic_gpio;
        static struct gpio_desc hub_reset, usb_sel;
@@ -90,7 +97,7 @@ int board_prepare_usb(enum usb_init_type type)
                }
        }
 
-       if (type == USB_INIT_HOST) {
+       if (init == USB_INIT_HOST) {
                /* Start USB Hub */
                dm_gpio_set_dir_flags(&hub_reset,
                                      GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
@@ -137,7 +144,8 @@ int misc_init_r(void)
 
        if (dm_gpio_get_value(&resin)) {
                env_set("bootdelay", "-1");
-               printf("Power button pressed - dropping to console.\n");
+               env_set("bootcmd", "fastboot 0");
+               printf("key_vol_down pressed - Starting fastboot.\n");
        }
 
        return 0;
@@ -148,38 +156,48 @@ int board_init(void)
        return 0;
 }
 
+int board_late_init(void)
+{
+       char serial[16];
+
+       memset(serial, 0, 16);
+       snprintf(serial, 13, "%x", msm_board_serial());
+       env_set("serial#", serial);
+       return 0;
+}
+
+/* Fixup of DTB for Linux Kernel
+ * 1. Fixup installed DRAM.
+ * 2. Fixup WLAN/BT Mac address:
+ *     First, check if MAC addresses for WLAN/BT exists as environemnt
+ *     variables wlanaddr,btaddr. if not, generate a unique address.
+ */
+
 int ft_board_setup(void *blob, bd_t *bd)
 {
-       int offset, len, i;
-       const char *mac;
-       struct {
-               const char *compatible;
-               const char *property;
-       } fix[] = {
-               [0] = {
-                       /* update the kernel's dtb with wlan mac */
-                       .compatible = "qcom,wcnss-wlan",
-                       .property = "local-mac-address",
-               },
-               [1] = {
-                       /* update the kernel's dtb with bt mac */
-                       .compatible = "qcom,wcnss-bt",
-                       .property = "local-bd-address",
-               },
+       u8 mac[ARP_HLEN];
+
+       msm_fixup_memory(blob);
+
+       if (!eth_env_get_enetaddr("wlanaddr", mac)) {
+               msm_generate_mac_addr(mac);
        };
 
-       for (i = 0; i < sizeof(fix) / sizeof(fix[0]); i++) {
-               offset = fdt_node_offset_by_compatible(gd->fdt_blob, -1,
-                                                      fix[i].compatible);
-               if (offset < 0)
-                       continue;
+       do_fixup_by_compat(blob, "qcom,wcnss-wlan",
+                          "local-mac-address", mac, ARP_HLEN, 1);
 
-               mac = fdt_getprop(gd->fdt_blob, offset, fix[i].property, &len);
-               if (mac)
-                       do_fixup_by_compat(blob, fix[i].compatible,
-                                          fix[i].property, mac, ARP_HLEN, 1);
-       }
 
+       if (!eth_env_get_enetaddr("btaddr", mac)) {
+               msm_generate_mac_addr(mac);
+
+/* The BD address is same as WLAN MAC address but with
+ * least significant bit flipped.
+ */
+               mac[0] ^= 0x01;
+       };
+
+       do_fixup_by_compat(blob, "qcom,wcnss-bt",
+                          "local-bd-address", mac, ARP_HLEN, 1);
        return 0;
 }