logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

revision 2148 committed: msg#00091

Subject: revision 2148 committed
Project     : madwifi
Revision    : 2148
Author      : proski (Pavel Roskin)
Date        : 2007-02-23 04:12:17 +0100 (Fri, 23 Feb 2007)

Log Message :
Merge revision 2130 - better support for AHB bus

Affected Files:
* branches/dadwifi/ath/if_ath_ahb.c                   updated             
* branches/dadwifi/ath/if_ath_ahb.h                   updated             


Modified: branches/dadwifi/ath/if_ath_ahb.c
===================================================================
--- branches/dadwifi/ath/if_ath_ahb.c   2007-02-23 02:48:05 UTC (rev 2147)
+++ branches/dadwifi/ath/if_ath_ahb.c   2007-02-23 03:12:17 UTC (rev 2148)
@@ -20,6 +20,9 @@
 #include <linux/netdevice.h>
 #include <linux/cache.h>
 #include <linux/delay.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
+#include <linux/platform_device.h>
+#endif
 
 #include <asm/io.h>
 #include <asm/uaccess.h>
@@ -43,6 +46,7 @@
 static struct ath_ahb_softc *sclist[2] = {NULL, NULL};
 static u_int8_t num_activesc = 0;
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
 static struct ar531x_boarddata *ar5312_boardConfig = NULL;
 static char *radioConfig = NULL;
 
@@ -140,6 +144,8 @@
                data[i] = eepromAddr[off];
 }
 
+#endif
+
 /* set bus cachesize in 4B word units */
 void
 bus_read_cachesize(struct ath_softc *sc, u_int8_t *csz)
@@ -183,7 +189,8 @@
        u_int32_t reset;
        u_int32_t enable;
        
-       if ((devid & AR5315_REV_MAJ_M) == AR5315_REV_MAJ) {
+       if (((devid & AR5315_REV_MAJ_M) == AR5315_REV_MAJ) ||
+               ((devid & AR5315_REV_MAJ_M) == AR5317_REV_MAJ)) {
                u_int32_t reg;
                u_int32_t *en = (u_int32_t *) AR5315_AHB_ARB_CTL;
                
@@ -244,7 +251,8 @@
 ahb_disable_wmac(u_int16_t devid, u_int16_t wlanNum)
 {
        u_int32_t enable;
-       if ((devid & AR5315_REV_MAJ_M) == AR5315_REV_MAJ) {
+       if (((devid & AR5315_REV_MAJ_M) == AR5315_REV_MAJ) ||
+               ((devid & AR5315_REV_MAJ_M) == AR5317_REV_MAJ)) {
                u_int32_t *en = (u_int32_t *) AR5315_AHB_ARB_CTL;
 
                KASSERT(wlanNum == 0, ("invalid wlan # %d", wlanNum) ); 
@@ -295,12 +303,11 @@
 }
 
 static int
-init_ath_wmac(u_int16_t devid, u_int16_t wlanNum)
+init_ath_wmac(u_int16_t devid, u_int16_t wlanNum, struct ar531x_config *config)
 {
        const char *athname;
        unsigned long mem_start;
        struct ath_ahb_softc *sc;
-       struct ar531x_config config;
         
        if (((wlanNum != 0) && (wlanNum != 1)) ||
                (sclist[wlanNum] != NULL))
@@ -324,7 +331,8 @@
 
        switch (wlanNum) {
        case AR531X_WLAN0_NUM:
-               if ((devid & AR5315_REV_MAJ_M) == AR5315_REV_MAJ) {
+               if (((devid & AR5315_REV_MAJ_M) == AR5315_REV_MAJ) ||
+                       ((devid & AR5315_REV_MAJ_M) == AR5317_REV_MAJ)) {
                        sc->irq = AR5315_IRQ_WLAN0_INTRS;
                        mem_start = AR5315_WLAN0;
                } else {
@@ -347,11 +355,7 @@
                goto bad3;
        }
        
-       config.board = ar5312_boardConfig;
-       config.radio = radioConfig;
-       config.unit = wlanNum;
-       config.tag = NULL;
-       if (ath_attach(devid, &sc->aps_sc, &config) != 0)
+       if (ath_attach(devid, &sc->aps_sc, config) != 0)
                goto bad4;
        athname = ath_hal_probe(ATHEROS_VENDOR_ID, devid);
        printk(KERN_INFO "%s: %s: mem=0x%lx, irq=%d\n",
@@ -372,24 +376,63 @@
        return -ENODEV;
 }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
+static int ahb_wmac_probe(struct platform_device *pdev)
+{
+       u32 devid;
+       struct ar531x_config *config;
+
+       config = (struct ar531x_config *) pdev->dev.platform_data;
+       devid = (u32) config->tag;
+       config->tag = NULL;
+       
+       return init_ath_wmac((u_int16_t) devid, pdev->id, config);
+}
+
+
+static int ahb_wmac_remove(struct platform_device *pdev)
+{
+       exit_ath_wmac(pdev->id);
+
+       return 0;
+}
+
+struct platform_driver ahb_wmac_driver = {
+       .driver.name = "ar531x-wmac",
+       .probe = ahb_wmac_probe,
+       .remove = ahb_wmac_remove
+};
+
+#else
+
 static int
 init_ahb(void)
 {
        int ret;
        u_int16_t devid, radioMask;
        const char *sysType;
+       struct ar531x_config config;
+
        sysType = get_system_type();
+       
+       /* Probe to find out the silicon revision and enable the
+          correct number of macs */
+       if (!ar5312SetupFlash())
+               return -ENODEV;
+
+       config.board = ar5312_boardConfig;
+       config.radio = radioConfig;
+       config.unit = wlanNum;
+       config.tag = NULL;
+
        if (!strcmp(sysType,"Atheros AR5315")) {
                devid = (u_int16_t) (sysRegRead(AR5315_SREV) &
                        (AR5315_REV_MAJ_M | AR5315_REV_MIN_M));
-               if ((devid & AR5315_REV_MAJ_M) == AR5315_REV_MAJ)
-                       return init_ath_wmac(devid, 0);
+               if (((devid & AR5315_REV_MAJ_M) == AR5315_REV_MAJ) ||
+                       ((devid & AR5315_REV_MAJ_M) == AR5317_REV_MAJ))
+                       return init_ath_wmac(devid, 0, &config);
        }
 
-       /* Probe to find out the silicon revision and enable the
-          correct number of macs */
-       if (!ar5312SetupFlash())
-               return -ENODEV;
        devid = (u_int16_t) ((sysRegRead(AR531X_REV) >>8) &
                (AR531X_REV_MAJ | AR531X_REV_MIN));
        switch (devid) {
@@ -400,11 +443,11 @@
                ar5312BspEepromRead(2 * AR531X_RADIO_MASK_OFF, 2,
                        (char *) &radioMask);
                if ((radioMask & AR531X_RADIO0_MASK) != 0)
-                       if ((ret = init_ath_wmac(devid, 0)) !=0 )
+                       if ((ret = init_ath_wmac(devid, 0, &config)) !=0 )
                                return ret;
                /* XXX: Fall through?! */
        case AR5212_AR2313_REV8:
-               if ((ret = init_ath_wmac(devid, 1)) != 0)
+               if ((ret = init_ath_wmac(devid, 1, &config)) != 0)
                        return ret;
                break;
        default:
@@ -413,6 +456,7 @@
        return 0;
 }
 
+#endif
 
 /*
  * Module glue.
@@ -453,10 +497,15 @@
 {
        printk(KERN_INFO "%s: %s\n", dev_info, version);
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
+       platform_driver_register(&ahb_wmac_driver);
+#else
        if (init_ahb() != 0) {
                printk("ath_ahb: No devices found, driver not installed.\n");
                return (-ENODEV);
        }
+#endif
+
        ath_sysctl_register();
        return 0;
 }
@@ -466,8 +515,13 @@
 exit_ath_ahb(void)
 {
        ath_sysctl_unregister();
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
+       platform_driver_unregister(&ahb_wmac_driver);
+#else
        exit_ath_wmac(AR531X_WLAN0_NUM);
        exit_ath_wmac(AR531X_WLAN1_NUM);
+#endif
 
        printk(KERN_INFO "%s: driver unloaded\n", dev_info);
 }

Modified: branches/dadwifi/ath/if_ath_ahb.h
===================================================================
--- branches/dadwifi/ath/if_ath_ahb.h   2007-02-23 02:48:05 UTC (rev 2147)
+++ branches/dadwifi/ath/if_ath_ahb.h   2007-02-23 03:12:17 UTC (rev 2148)
@@ -59,6 +59,7 @@
 #define AR5315_SREV            0xb1000014
 
 #define AR5315_REV_MAJ         0x0080
+#define AR5317_REV_MAJ         0x0090
 #define AR5315_REV_MAJ_M       0x00f0
 #define AR5315_REV_MAJ_S       4
 #define AR5315_REV_MIN_M       0x000f

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV


<Prev in Thread] Current Thread [Next in Thread>