ar71xx: build ALFA AP96 images with default profile as well
[oweals/openwrt.git] / target / linux / ar71xx / files / arch / mips / ar71xx / dev-ar9xxx-wmac.c
index f07d3683620242f1f47fc6f9c65c83f1dc4a3d69..90db388967b729af90ebdace10c18417a8162adb 100644 (file)
@@ -63,6 +63,36 @@ static void ar913x_wmac_init(void)
        ar9xxx_wmac_resources[0].end = AR91XX_WMAC_BASE + AR91XX_WMAC_SIZE - 1;
 }
 
+static int ar933x_r1_get_wmac_revision(void)
+{
+       return ar71xx_soc_rev;
+}
+
+static int ar933x_wmac_reset(void)
+{
+       unsigned retries = 0;
+
+       ar71xx_device_stop(AR933X_RESET_WMAC);
+       ar71xx_device_start(AR933X_RESET_WMAC);
+
+       while (1) {
+               u32 bootstrap;
+
+               bootstrap = ar71xx_reset_rr(AR933X_RESET_REG_BOOTSTRAP);
+               if ((bootstrap & AR933X_BOOTSTRAP_EEPBUSY) == 0)
+                       return 0;
+
+               if (retries > 20)
+                       break;
+
+               udelay(10000);
+               retries++;
+       }
+
+       pr_err("ar93xx: WMAC reset timed out");
+       return -ETIMEDOUT;
+}
+
 static void ar933x_wmac_init(void)
 {
        ar9xxx_wmac_device.name = "ar933x_wmac";
@@ -70,6 +100,13 @@ static void ar933x_wmac_init(void)
        ar9xxx_wmac_resources[0].end = AR933X_WMAC_BASE + AR933X_WMAC_SIZE - 1;
        if (ar71xx_ref_freq == MHZ_25)
                ar9xxx_wmac_data.is_clk_25mhz = true;
+
+       if (ar71xx_soc_rev == 1)
+               ar9xxx_wmac_data.get_mac_revision = ar933x_r1_get_wmac_revision;
+
+       ar9xxx_wmac_data.external_reset = ar933x_wmac_reset;
+
+       ar933x_wmac_reset();
 }
 
 static void ar934x_wmac_init(void)
@@ -77,6 +114,8 @@ static void ar934x_wmac_init(void)
        ar9xxx_wmac_device.name = "ar934x_wmac";
        ar9xxx_wmac_resources[0].start = AR934X_WMAC_BASE;
        ar9xxx_wmac_resources[0].end = AR934X_WMAC_BASE + AR934X_WMAC_SIZE - 1;
+       ar9xxx_wmac_resources[1].start = AR934X_IP2_IRQ_WMAC;
+       ar9xxx_wmac_resources[1].start = AR934X_IP2_IRQ_WMAC;
        if (ar71xx_ref_freq == MHZ_25)
                ar9xxx_wmac_data.is_clk_25mhz = true;
 }