1/05/2012

Porting wg7210(WL1251) with Linux 2.6.37 on AM18


Below is port of wg7210 info for kernel 2.6.37 with Linux on the AM18 platform.

First, your can get patches and nlcp driver ( modifies to wg7210 ) with firmware 4.0.4.32 from my git.

kernel patches ( include firmware for wg7210 ):

$ git clone git://github.com/dickychiang/am18-wg7210-patch.git

compat-wireless-r4-11-wg7210 :

$ git clone git://github.com/dickychiang/compat-wireless-r4-11.git

The driver will support iw tool to configure wireless.

Also the porting of wg7210 need to take care to important the following :

a) wg7210 has inside the eeprom. To fill structure in wl12xx_platform_data of "use_eeprom".

In board-*.c file :


static struct wl12xx_platform_data da850_wl12xx_wlan_data __initdata = {                                                              

    .irq = -1,
    .board_ref_clock = CONFIG_DA850_MISTRAL_WL12XX_REFCLOCK,
    .platform_quirks = WL12XX_PLATFORM_QUIRK_EDGE_IRQ,
    .use_eeprom = 1,
};

If already, in insert wl1251.ko module will be R/W to eeprom and create a network interface. ( Note, check the irq is work well and connected to EVB.)

And then insert wl1251_sdio.ko will be download firmware into chip.

wl1251: chip id 0x7020101 (1251 PG11)
wl1251: firmware booted (Rev 4.0.4.3.5)

b)  Since it the SDIO of CCCR,CIS,FBR is in not corrent. so kernel can not to get right information to match for wg7210. My ideas is give the card information to kernel such as vendor and device id which let kernel to know the sdio device is match to my sdio driver for wg7210.

In drivers/mmc/core/sdio.c :

b-1) Mark the read cccr,cis at mmc_sdio_init_card func.
                                                  
#ifndef CONFIG_WG7210                                                                                  
    err = sdio_read_cccr(card);                                                                        
    if (err)                                                                                                                          
        goto remove;                                                                                   
#endif                                                                                                 
                                                                                
#ifndef CONFIG_WG7210                                                                                  
    err = sdio_read_common_cis(card);                                                                  
    if (err)                                                                                           
        goto remove;                                                                                   
#endif

To fill the card''s maximum speed with clock. ( Default the value is get from cccr register )

#ifdef CONFIG_WG7210
    card->cis.max_dtr = 25000000;
#endif
    mmc_set_clock(host, mmc_sdio_get_max_clock(card));
b-2) Mark the read fbr and set the id's info to structure sdio_func at sdio_init_func.

#ifndef CONFIG_WG7210                                                                                  
    if (!(card->quirks & MMC_QUIRK_NONSTD_SDIO)) {                                                     
        ret = sdio_read_fbr(func);                                                                     
        if (ret)                                                                                       
            goto fail;                                                                                 
                                                                                                       
        ret = sdio_read_func_cis(func);                                                                
        if (ret)
            goto fail;                                                                                 
    } else {                                                                                           
        func->vendor = func->card->cis.vendor;                                                         
        func->device = func->card->cis.device;                                                         
        func->max_blksize = func->card->cis.blksize;                                                   
    }                                                                                                  
#else                                                                                                  
    func->vendor = 0x104c;                                                                             
    func->device = 0x9066;                                                                             
    func->max_blksize = 4096;                                                                          
#endif  

Note, the max block size value is depend on mmc host controller, if not to match wii be failed in send CMD52.


c) Modify the download firmware path in nlcp driver :

In compat-wireless/drivers/net/wireless/wl1251/wl1251.h

#define WL1251_FW_NAME "ti-connectivity/wl1251-fw.bin"
#define WL1251_NVS_NAME "ti-connectivity/wl1251-nvs.bin"


d) If want to debug NLCP driver,do it to following. ( The method can used to wl12xx )

    look at compat-wireless/driver/net/wireless/wl1251/wl1251.h, you can find its.

enum {
    DEBUG_NONE  = 0,
    DEBUG_IRQ   = BIT(0),
    DEBUG_SPI   = BIT(1),
    DEBUG_BOOT  = BIT(2),
    DEBUG_MAILBOX   = BIT(3),
    DEBUG_NETLINK   = BIT(4),
    DEBUG_EVENT = BIT(5),
    DEBUG_TX    = BIT(6),
    DEBUG_RX    = BIT(7),
    DEBUG_SCAN  = BIT(8),
    DEBUG_CRYPT = BIT(9),
    DEBUG_PSM   = BIT(10),
    DEBUG_MAC80211  = BIT(11),
    DEBUG_CMD   = BIT(12),
    DEBUG_ACX   = BIT(13),
    DEBUG_ALL   = ~0,
};

#define DEBUG_LEVEL (DEBUG_NONE)

To modifies the DEBUG_LEVEL for you want to check the driver info. Suppose I wonder to see the BOOT and MAC80211 information :
 DEBUG_BOOT  = BIT(2)             =>    (1 << 2)  =  0x4
 DEBUG_MAC80211  = BIT(11)     =>   (1 << 11) =  0x800

so the answer :

#deinfe DEBUG_LEVEL   0x804

Re-build it now.   And then to entry the file system ( For example with Linux based ) and enable all kernel prints level.
echo 8 > /proc/sys/kernel/printk

Running daemon for print the kernel logs :

cat /proc/kmsg &

Your can see the debug message when insert wl1251.ko ( or wl12xx.ko ) and wl1251_sdio.ko ( or wl12xx_sdio.ko ).

No comments:

Post a Comment