SDIO_HOWTO
==========
by olg


Before we Start
---------------
This port of the Atheros SDIO-Stack is under development and UNSTABLE. It may crash your device, so be aware of it.

Checklist
---------

[ ] I have a recent Kamikaze checkout
[ ] I know my card <-> GPIO pin association
[ ] there's no sunshine outside for at least 2 hours


Some Notes on Hardware
--------------------------

- remove capaciators from PCB for "SW"-GPIOs (1,3,4,7) if you use them
- maybe not nesessary:
- add small cap btw. Vdd and Vss
- remove pull-down resistors from PCB
- add pullup to SD_DO

 
Default SD/MMC-Pin-Association
------------------------------

SD            GPIO    LOCATION
1    CS        7        SW1-6
2    DI        1        SW1-5
3    GND                GND
4    VCC                SW1-3
5    CLK        4        SW1-2
6    GND                GND
7    DO        3        SW1-1

Building SDIO
-------------

1) put the sdio files in your packages tree and (maybe) create a symlink to trunk/package/sdio

    cd trunk
    wget http://kwzs.be/~olg/sdio/snapshots/sdio-latest.tar.bz2
    tar -xvjf sdio*.tar.bz2 -C package

2) make menuconfig
select "Kernel modules  ---> Other modules  ---> kmod-sdio" and configure your gpio pins.
Here you can also select "debug", which bloats the package and slows down the driver, but is really useful for testing

Also select at "Kernel modules  ---> Filesystems" your preferred FS e.g. FAT or ext2. To use FAT you need: 

    kmod-fs-vfat
    kmod-nls-base
    kmod-nls-cp437
    kmod-nls-iso8859

3)

    make V=99

4) take "trunk/bin/packages/kmod-sdio*.ipkg" and the FS files and put it onto you box and type there:

    ipkg install kmod-sdio*.ipk
    ipkg install kmod-nls-base*.ipk
    ipkg install kmod-nls-cp437*.ipk
    ipkg install kmod-nls-iso8859*.ipk
    ipkg install kmod-fs-vfat*.ipk

Looking at dmesg
----------------

    dmesg

should look like this:

    ...
    SDIO Library load
    SDIO GPIO loading.. (DI:1 DO:3 CLK:4 CS:7)

and after inserting a card:

    sdmem0: p1

Mounting
--------

simply do one of them or something equivalent:

    mount -t vfat /dev/sdmem0p1 /mnt -o noatime,sync    
    mount -t vfat /dev/sdmem0 /mnt -o noatime,sync

That's it (i hope so) ...   

   
ADVANCE USAGE
=============

If something does not work as expected, try building SDIO with the debug option enabled and proceed ...
   
Verifing your Hardware
----------------------

To test proper soldering, you can load mmc_test

    insmod lib/modules/2.6.*/mmc_test.ko

and then watch the dmesg output, which will hopefully show something like that:

    dmesg
...
Size = 62720, hardsectsize = 512, sectors = 125440

    rmmod mmc_test

Then you know, it should work with the old 2.4 driver, and your hardware is ok.
   
Loading SDIO-Stack
-------------------

if you like to test it temporarily, you can do:

    cd /tmp
    wget http://.../packages/kmod-sdio*mips.ipk
    tar -xvzf kmod-sdio*.ipk
    tar -xvzf data.tar.gz  


    insmod /tmp/lib/modules/2.6.*/sdio_lib.ko debuglevel=7
    insmod /tmp/lib/modules/2.6.*/sdio_busdriver.ko debuglevel=7
    insmod /tmp/lib/modules/2.6.*/sdio_memory_fd.ko debuglevel=6
    insmod /tmp/lib/modules/2.6.*/sdio_gpio.ko debuglevel=7

and look for the dmesg output. And then test, if reading and writing works:
(This really may DESTROY the contents of your card, you have been warned ...)

    dd if=/dev/sdmem0 of=test count=1; dmesg -c
    dd of=/dev/sdmem0 if=test count=1; dmesg -c

If everything worked ok till now, you may decrease the debugging verbosity and try to mount the card:

    rmmod sdio_gpio
    rmmod sdio_memory_fd
    rmmod sdio_busdriver
    rmmod sdio_lib

    insmod /tmp/lib/modules/2.6.*/sdio_lib.ko debuglevel=7
    insmod /tmp/lib/modules/2.6.*/sdio_busdriver.ko debuglevel=7
    insmod /tmp/lib/modules/2.6.*/sdio_memory_fd.ko debuglevel=6
    insmod /tmp/lib/modules/2.6.*/sdio_gpio.ko debuglevel=7