Posts

Showing posts with the label mmccam

Building FreeBSD's SDIO driver for BeagleBone Black

Hi all, This post mainly concern with building FreeBSD's SDIO driver for BeagleBone Black by cross compiling it on AMD platform. I had few unresolved issues with the master branch of current FreeBSD tree. So, for this i used another unofficial branch: https://github.com/kibab/freebsd/tree/mmcam-new . It does have the required KERNCONF file with stable SDIO driver. A lot of steps below are similar to the one given on: https://forums.freebsd.org/threads/cross-compiling-beaglebone-on-amd64.64718/#post-384835   with slight but inevitable changes. Procedure:  Before proceeding you need to first install git. sudo pkg update -f sudo pkg install git  Setup project directory by mkdir /BBB  Clone the repository to /BBB/src by git clone -b mmcam-new https://github.com/kibab/freebsd.git /BBB/src Setup environment variables as setenv BASEDIR /BBB setenv MAKEOBJDIRPREFIX $BASEDIR/obj setenv TARGET arm setenv TARGET_ARCH armv6 Note that sometime it shows an error ...

Implementing a MMC/SD/SDIO stack using CAM framework(Part 2)

Image
Hi, In the next part lets look at other files which makes up the SDIO stack within mmccam framework. Please have  a look at previous part for more info: http://81.4.107.225/wordpress/index.php/2018/03/19/implementing-a-mmc-sd-sdio-stack-using-cam-framework/ mmc_sdio.c +void sdio_fill_mmcio_rw_direct(union ccb *ccb, uint8_t f, uint8_t wr, uint32_t adr, uint8_t *data) { + struct ccb_mmcio *mmcio; + + CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_TRACE, + ("sdio_fill_mmcio(f=%d, wr=%d, adr=%02x, data=%02x)\n", f, wr, adr, (data == NULL ? 0 : *data))); + mmcio = &ccb->mmcio; + + mmcio->cmd.opcode = SD_IO_RW_DIRECT; + mmcio->cmd.arg = SD_IO_RW_FUNC(f) | SD_IO_RW_ADR(adr); + if (wr) + mmcio->cmd.arg |= SD_IO_RW_WR | SD_IO_RW_RAW | SD_IO_RW_DAT(*data); + mmcio->cmd.flags = MMC_RSP_R5 | MMC_CMD_AC; + mmcio->cmd.data->len = 0; +} sdio_fill_mmcio_rw_direct is basically a wrapper for CMD_52 that's needed ...

Detailed SDIO protocol Implementation

Image
Reference: Wikipedia, https://www.sdcard.org/developers/overview/sdio/sdio_spec/Simplified_SDIO_Card_Spec.pdf  SDIO cards are intended to provide high speed data Input/Output on our regular sd card slot. SDIO cards are compatible with any sd card slot and will not cause any physical damage to the host if it's not compatible with SDIO. When SDIO is plugged in a SDIO compatible host, in its early stage it is in low power mode and consumes very little current. Host identifies the SDIO card ,it's power requirement, it's I/O capabilities etc. If host finds that power requirement is manageable and there is driver for the I/O functionality card is offering it allows the SDIO card to power up completely and start it's I/O functions.  SDIO card allows up to 7 different I/O functions along with 1 memory function. It's available in market in 2 form factors: miniSDIO and full size SDIO. For example http://www.spectec.com.tw/sdw-822..html is a miniSDIO wifi card by spectec. Typ...

Implementing a MMC/SD/SDIO stack using CAM framework(Part 1)

Image
In this blog post we will have a detailed look at all the files added/changed while implementing the MMC/SD/SDIO stack via CAM framework. We will basically discuss the commit  https://github.com/freebsd/freebsd/commit/a87c7a85be3e3727b6b08b19741b4282f942400d which aims at adding MMC/SD/SDIO stack to FreeBSD's already existing CAM framework. So, lets start one by one with each file: mmc.h #ifndef CAM_MMC_H #define CAM_MMC_H #include <dev/mmc/mmcreg.h> /* * This structure describes an MMC/SD card */ struct mmc_params { u_int8_t model[40]; /* Card model */ /* Card OCR */ uint32_t card_ocr; /* OCR of the IO portion of the card */ uint32_t io_ocr; /* Card CID -- raw and parsed */ uint32_t card_cid[4]; struct mmc_cid cid; /* Card CSD -- raw */ uint32_t card_csd[4]; /* Card RCA */ uint16_t card_rca; /* What kind of card is it */ uint32_t card_features; #define CARD_FEA...