peeter123
Posts: 2
Joined: Wed Oct 08, 2014 2:25 pm

SDIO for Wifi/Bluetooth module

Wed Oct 08, 2014 2:52 pm

We are currently designing a consumer product with the Raspberry Pi compute module and are looking to integrate a Wifi/Bluetooth combo module. These modules are plentiful but almost all have a SDIO-interface.

If I look at the GPIO map for the Raspberry I find SDIO1 interface on GPIO 22->27(ALT3) but the problem is there is absolutely no documentation available about this. Can someone shed some light on how the interface works, what kind of driver support there is or how I can get into contact with some people who know how to get this up and running?

As far as I know there is no driver for this SDIO port in the current Raspberry Pi Linux kernel but maybe someone can correct me if I'm wrong.

jdb
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1764
Joined: Thu Jul 11, 2013 2:37 pm

Re: SDIO for Wifi/Bluetooth module

Wed Oct 08, 2014 6:58 pm

The main problem with the SD"1" interface (i.e. not the interface used to talk to the eMMC) is that it isn't exactly an SDIO interface. There would be a considerable number of hacks or workarounds needed to get the interface to even talk to an SDIO device. It has not been documented as the Arasan eMMC/SD interface is its effective replacement.

Getting this second interface working acceptably with SDIO would be a "nice to have" addition, especially as the pins also pop out on the Model B+ expansion header.

There is documentation currently working its way through the bowels of Broadcom that should at least give the register map for the interface, but after that you're on your own.

There was a driver in the 3.2.27 branch of the Linux source on github specifically for SD cards but that got removed in favour of the eMMC driver.

https://github.com/raspberrypi/linux/bl ... 2708_mci.c
Rockets are loud.
https://astro-pi.org

0x73DB07
Posts: 11
Joined: Fri Jun 01, 2012 8:46 pm

Re: SDIO for Wifi/Bluetooth module

Wed Nov 05, 2014 5:03 pm

Hm, so what IS the best way to connect a wifi module to the RPi Compute?

tsaG
Posts: 80
Joined: Thu Jun 26, 2014 1:30 pm

Re: SDIO for Wifi/Bluetooth Module

Thu Nov 06, 2014 2:21 pm

I plan to use a RT5370 embedded module which is connected via USB. You can get those for about 3$ as THT or SMT in China

J Sanderson
Posts: 30
Joined: Thu Nov 03, 2011 8:59 pm

Re: SDIO for Wifi/Bluetooth module

Fri Nov 07, 2014 11:35 am

"I plan to use a RT5370 embedded module which is connected via USB. You can get those for about 3$ as THT or SMT in China"

Any ideas of a source of a datasheet for it?
I've been trying to get one out of MediaTek for nearly a year now.
I'd be interested in any single chip USB to Wifi that has support built into the standard Raspian distribution, which AIUI means various MediaTek or Realtek chips

Also a pointer to a supplier would be brilliant neither MediaTek or Realtek have any European distribution and aren't interested in talking to me:-(

pjriot
Posts: 4
Joined: Mon Jan 26, 2015 3:53 pm

Re: SDIO for Wifi/Bluetooth module

Mon Jan 26, 2015 4:07 pm

Yeesh, looking around the forum it seems there are a couple of posts on trying to get a wifi chip to work with the CM. Pinging this thread to see if anyone managed to make progress on that front. (and wouldn't mind sharing the details!)

Killertechno
Posts: 130
Joined: Wed Jan 02, 2013 8:28 am

Re: SDIO for Wifi/Bluetooth module

Tue Jul 07, 2015 12:27 pm

There is also LM811 (WiFi + Bluetooth module) with USB interface, but I still can't understand how several producers make SDIO when there are no support/examples about using SDIO devices......

Linux kernel already supporting SDIO devices, but I have no idea how declare it inside device tree.....

LukeW
Posts: 5
Joined: Tue Jul 07, 2015 2:19 pm

Re: SDIO for Wifi/Bluetooth module

Tue Jul 07, 2015 2:47 pm

Sorry for resurrecting an old thread, but I thought it would be useful to add some information.

SDIO is supported by the mmc (SD1) driver. In order to use SD1 for SDIO, you'll need to use SD0 (sdhost) for booting, as SD1 is currently being used for this. Phil has written a device tree overlay which does this. Add the following to your config.txt to boot using SD0:

Code: Select all

dtoverlay=sdhost
Note that this overlay is not included with the current Raspbian distribution on the website - the easiest way to get everything you need is to run "rpi-update next" to get the latest firmware and then follow the instructions here (https://www.raspberrypi.org/documentati ... uilding.md) to build a recent kernel. (4.0 is stable, 4.1 has more drivers for SDIO wifi modules.)

There are different ways of connecting SD1 to the GPIO pins. One of them is to use a device tree overlay. Here is a modified version of Phil's sdhost overlay which does this:

Code: Select all

/dts-v1/;
/plugin/;

/* Adapted from sdhost.dts, Phil Elwell */

/{
    compatible = "brcm,bcm2708";

    fragment@0 {
        target = <&soc>;
        __overlay__ {
            #address-cells = <1>;
            #size-cells = <1>;

            sdhost: sdhost@7e202000 {
                compatible = "brcm,bcm2835-sdhost";
                reg = <0x7e202000 0x100>;
                pinctrl-names = "default";
                pinctrl-0 = <&sdhost_pins &sdio_pins>;
                interrupts = <2 24>;
                clocks = <&clk_sdhost>;
                //dmas = <&dma 13>,
                //       <&dma 13>;
                dma-names = "tx", "rx";
                brcm,delay-after-stop = <0>;
                brcm,overclock-50 = <0>;
                status = "okay";
            };

            clocks {
                #address-cells = <1>;
                #size-cells = <0>;

                clk_sdhost: clock@3 {
                    compatible = "fixed-clock";
                    reg = <0>;
                    #clock-cells = <0>;
                    clock-output-names = "sdhost";
                    clock-frequency = <250000000>;
                };
            };
        };
    };

    fragment@1 {
        target = <&gpio>;
        __overlay__ {
            sdhost_pins: sdhost_pins {
                brcm,pins = <48 49 50 51 52 53>;
                brcm,function = <4>; /* alt0 */
            };
            sdio_pins: sdio_pins {
                brcm,pins = <22 23 24 25 26 27>;
                brcm,function = <7 7 7 7 7 7>;    /* alt3: SD1*/
                brcm,pull = <0 2 2 2 2 2>;    /* pull up all except clk */
            };
        };
    };

    /* We do not want to disable mmc; just remap its pins to GPIO (above) */

    fragment@2 {
        target-path = "/__overrides__";
        __overlay__ {
            sdhost_freq      = <&clk_sdhost>,"clock-frequency:0";
        };
    };

    __overrides__ {
        delay_after_stop = <&sdhost>,"brcm,delay-after-stop:0";
        overclock_50     = <&sdhost>,"brcm,overclock-50:0";
        force_pio        = <&sdhost>,"brcm,force-pio?";
        sdhost_freq      = <&clk_sdhost>,"clock-frequency:0";
    };
};
Save this file as sdio-sdhost.dts in your home folder and then run the following to install it:

Code: Select all

sudo apt-get update && sudo apt-get install device-tree-compiler
dtc -@ -I dts -O dtb -o sdio-sdhost.dtb sdio-sdhost.dts
sudo mv sdio-sdhost.dtb /boot/overlays/sdio-sdhost-overlay.dtb
Now add the following to /boot/config.txt (Removing sdhost overlay if you added it):

Code: Select all

dtoverlay=sdio-sdhost
You can also configure the pins using Python GPIO module, or however you see fit.

That should be all that is needed to get SDIO working. Linux will automatically poll the SDIO port once every second. Any devices that enumerate will appear in the sysfs folder /sys/bus/sdio. Provided Linux has the correct driver, and the driver has a compatibility string that matches the vendor and device IDs in /sys/bus/sdio, everything should Just Work (TM).
Last edited by LukeW on Tue Jul 07, 2015 3:38 pm, edited 1 time in total.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1734
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: SDIO for Wifi/Bluetooth module

Tue Jul 07, 2015 3:21 pm

Thanks for the update, Luke. The sdhost overlay has changed slightly since the one I first gave you, so you should also update your sdhost-sdio overlay:

Code: Select all

/dts-v1/;
/plugin/;

/* Adapted from sdhost-overlay.dts, Phil Elwell */

/{
    compatible = "brcm,bcm2708";

    fragment@0 {
        target = <&soc>;
        __overlay__ {
            #address-cells = <1>;
            #size-cells = <1>;

            sdhost: sdhost@7e202000 {
                compatible = "brcm,bcm2835-sdhost";
                reg = <0x7e202000 0x100>;
                pinctrl-names = "default";
                pinctrl-0 = <&sdhost_pins &sdio_pins>;
                interrupts = <2 24>;
                clocks = <&clk_core>;
                dmas = <&dma 13>,
                       <&dma 13>;
                dma-names = "tx", "rx";
                brcm,delay-after-stop = <0>;
                brcm,overclock-50 = <0>;
                brcm,pio-limit = <1>;
                status = "okay";
            };
        };
    };

    fragment@1 {
        target = <&gpio>;
        __overlay__ {
            sdhost_pins: sdhost_pins {
                brcm,pins = <48 49 50 51 52 53>;
                brcm,function = <4>; /* alt0 */
            };
            sdio_pins: sdio_pins {
                brcm,pins = <22 23 24 25 26 27>;
                brcm,function = <7 7 7 7 7 7>;    /* alt3: SD1*/
                brcm,pull = <0 2 2 2 2 2>;    /* pull up all except clk */
            };
        };
    };

    /* We do not want to disable mmc; just remap its pins to GPIO (above) */

    __overrides__ {
        overclock_50     = <&sdhost>,"brcm,overclock-50:0";
        force_pio        = <&sdhost>,"brcm,force-pio?";
        pio_limit        = <&sdhost>,"brcm,pio-limit:0";
        debug            = <&sdhost>,"brcm,debug?";
    };
};
For consistency I think this file should be called sdio-sdhost-overlay.dts, and compiled like this:

Code: Select all

# Skip this first step if you have an up-to-date dtc
sudo apt-get update && sudo apt-get install device-tree-compiler
dtc -@ -I dts -O dtb -o sdio-sdhost-overlay.dtb sdio-sdhost-overlay.dts
sudo mv sdio-sdhost-overlay.dtb /boot/overlays/sdio-sdhost-overlay.dtb

LukeW
Posts: 5
Joined: Tue Jul 07, 2015 2:19 pm

Re: SDIO for Wifi/Bluetooth module

Tue Jul 07, 2015 3:39 pm

Thank you Phil! I think I pulled the file from the 4.0 repo a couple of weeks ago.

pboettch
Posts: 7
Joined: Wed Nov 18, 2015 4:05 pm

Re: SDIO for Wifi/Bluetooth module

Wed Nov 18, 2015 4:14 pm

I found this thread during an internet search and it was really helping me to setup my environment - but it is not working.

I'm using raspbian jessie with 4.1.7+v7 (on RPI2) which contains the precompiled dt-overlays called sdio and sdhost. I tried both of them separately to no avail.

Pluging a scope on SD_CMD and SD_DATA shows me (sane) activity during raspi's boot, but nothing more. Especially no sign of the host polling every second to see if there is a device.

Is there something I can do?

--
Patrick.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1734
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: SDIO for Wifi/Bluetooth module

Wed Nov 18, 2015 7:42 pm

If your device isn't guaranteed to be there at boot time then you need to remove the "non-removable" property from the overlay. You can do this with a customised overlay, or by adding a Boolean parameter on that property, so that setting it to false/off/no will delete it; a suitable name would be "poll_once", and it's default value would be true.

pboettch
Posts: 7
Joined: Wed Nov 18, 2015 4:05 pm

Re: SDIO for Wifi/Bluetooth module

Thu Nov 19, 2015 11:23 am

Removing 'non-removable' makes it poll every second. Thanks.

I tried to make it in option by adding a section like this to sdio-overlay.dts:

Code: Select all

	__overrides__ {
		poll_once = <&mmc>,"non-removable?";
	};
Leeaving 'non-removable' in the 'fragment@3'-overlay-section (defaulting to true), but this has no impact. I think the mmc-label is wrong, but from all the examples I found I wasn't able to determine what would be the right label. I tried sdhost as well.

What is the right label?

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1734
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: SDIO for Wifi/Bluetooth module

Thu Nov 19, 2015 11:36 am

Parameters are now (this wasn't always the case) applied before the fragments are merged, so the correct label is actually "fragment@3".

You should then find that:

Code: Select all

dtoverlay=sdio,poll_once=no
works.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1734
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: SDIO for Wifi/Bluetooth module

Thu Nov 19, 2015 12:06 pm

OK - that's half right. You will need to add a label to fragment@3, and then use that, since fragment@3 is a node name rather than a label.

pboettch
Posts: 7
Joined: Wed Nov 18, 2015 4:05 pm

Re: SDIO for Wifi/Bluetooth module

Thu Nov 19, 2015 1:59 pm

Thanks for these insights: I tried the following:

Code: Select all

sdio_mmc: fragment@3 {
    ...
   [removed 'non-removable;']
}
__overrides__ {
    poll_once = <&sdio_mmc>,"non-removable?";
};
But it does not work as I'd like to. DeviceTree is not that easy.

Thanks for your help so far.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1734
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: SDIO for Wifi/Bluetooth module

Thu Nov 19, 2015 2:05 pm

I expected you to just add the parameter declaration, which ought to give the following behaviour:

Code: Select all

[default]     -> non-removable present
poll_once=on  -> non-removable present
poll_once=off -> non-removable absent
By removing the "non-removable" line, the default has become "removable":

Code: Select all

[default]     -> non-removable absent
poll_once=on  -> non-removable present
poll_once=off -> non-removable absent
Does this match your observations?

pboettch
Posts: 7
Joined: Wed Nov 18, 2015 4:05 pm

Re: SDIO for Wifi/Bluetooth module

Fri Nov 20, 2015 8:13 am

No, with the device-tree adaptation (*) and 'poll_once=on'

I can see

Code: Select all

/proc/device-tree/soc/mmc@7e300000/non-removable
and with poll_once=off

Code: Select all

/proc/device-tree/soc/mmc@7e300000/non-removable
is still there.


*) Diff is here, I was not able to attach a patch to my post https://github.com/pboettch/linux/commi ... 3172208485

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1734
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: SDIO for Wifi/Bluetooth module

Fri Nov 20, 2015 8:40 am

Ah, yes. The label should be on the __overlay__ node within fragment@3. Otherwise it looks good (I've tested it).

pboettch
Posts: 7
Joined: Wed Nov 18, 2015 4:05 pm

Re: SDIO for Wifi/Bluetooth module

Fri Nov 20, 2015 2:31 pm

Thanks. This is effectively fixed the issue - I can now toggle poll_once or every second.

But it still doesn't work. I will make a new thread with my new problem.

oneinsect
Posts: 6
Joined: Sun Aug 02, 2015 7:52 pm

Re: SDIO for Wifi/Bluetooth module

Wed Dec 02, 2015 9:32 am

pboettch wrote:Thanks. This is effectively fixed the issue - I can now toggle poll_once or every second.

But it still doesn't work. I will make a new thread with my new problem.
pboettch. Any update on the problem? What is working and what is not working??

gregeric
Posts: 1511
Joined: Mon Nov 28, 2011 10:08 am

Re: SDIO for Wifi/Bluetooth module

Mon Jan 25, 2016 7:33 am

@PhilE When using the sdio-overlay, the overclock_50 parameter sets the speed of the sdhost peripheral/driver. How do I specify an overclock for the emmc peripheral/driver on the GPIO pins?

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1734
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: SDIO for Wifi/Bluetooth module

Mon Jan 25, 2016 9:52 am

The MMC driver also understands the "brcm,overclock-50" property, but it isn't exposed by a DT parameter. I've just pushed a patch to the rpi-4.1.y source tree that adds the sdio_overclock parameter to the sdio overlay, but because of clock restrictions any value of 62 or higher will result in a 250/4 = 62.5MHz clock, while anything smaller (or no parameter) gets you a 250/6 = 41.6MHz clock.

Usage: dtoverlay=sdio,sdio_overclock=62

The updated overlay will appear in the next release, or you can grab a preview here.

I can't promise that SDIO is going to work at 62.5MHz - use at your own risk.

gregeric
Posts: 1511
Joined: Mon Nov 28, 2011 10:08 am

Re: SDIO for Wifi/Bluetooth module

Mon Jan 25, 2016 9:58 am

Thanks Phil will have a test later. If I increase the core frequency I assume I can get other speeds as per viewtopic.php?f=29&t=6201&p=761030&hilit=sdhost#p761030

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1734
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: SDIO for Wifi/Bluetooth module

Mon Jan 25, 2016 10:18 am

The EMMC block doesn't use the core clock, so core_freq has no effect. You can change the emmc clock using the "init_emmc_clock" config.txt setting (as it says in that Forum thread), but that information isn't currently propagated to the Device Tree clock information.

As it stands, changing init_emmc_clock without using sdio_overclock should result in a bus clock of (init_emmc_clock/250000000)*41.67MHz. However this isn't something I've experimented with, and I'm concerned that the init_emmc_clock default value has been left at 250MHz for a good reason. I'll talk it over here, and may end up propagating the emmc clock change into the DTB.

Return to “Compute Module”

Who is online

Users browsing this forum: No registered users and 4 guests