1
Linux SD/MMC Driver Stack
Champ Yen
http://champyen.blogspot.com
champ.yen@gmail.com
2
Core
SDIO SD MMC
BLOCK
Device
UART
(SDIO)
BlueTooth
(SDIO)
WIFI
(SDIO)
Host
AIT OMAP S3C ......
Device
● Implement specific subsystem
devices(ex: UART, WIFI) by utilizing
Core API.
Core
-Diagnosing SD/MMC/SDIO device
-SD/MMC/SDIO Protocol Layer
implementation
-Power Management Policy
Host
-Hardware dependent interface
-Handling requests from Core layer.
SD/MMC Stack Architecture
3
Host Structure
struct mmc_host {
……
const struct mmc_host_ops *ops;
/* minimum frequency */
unsigned int f_min;
/* maximum frequency */
unsigned int f_max;
/* provided voltages */
u32 ocr_avail;
unsigned long caps;
/* host specific block data */
unsigned int max_seg_size;
unsigned short max_hw_segs;
unsigned short max_phys_segs;
unsigned short unused;
unsigned int max_req_size;
unsigned int max_blk_size;
unsigned int max_blk_count;
……
};
4
host allocation
struct mmc_host *mmc;
//private host data, hw dependent info is saved here.
struct foo_host *host;
//allocate mmc_host structure with private data size
//pdev is the pointer of platform_device
mmc = mmc_alloc_host(sizeof(struct foo_host), &pdev->dev);
////////////// initialization after allocation ///////////////////
////////////// private host data pointer is get as below
struct foo_host *host;
host = mmc_priv(mmc);
5
Host Operations
struct mmc_host_ops {
/* request handler */
void (*request)(struct mmc_host *host, struct mmc_request *req);
/* host controller setting function */
void (*set_ios)(struct mmc_host *host, struct mmc_ios *ios);
/* read-only detection , return 1: read-only, 0: read-write */
int (*get_ro)(struct mmc_host *host);
/* card detection return 1: Card Inserted, 0: Card Not Inserted */
int (*get_cd)(struct mmc_host *host);
/* enable SDIO irq */
void (*enable_sdio_irq)(struct mmc_host *host, int enable);
};
6
request
struct mmc_request {
/* command to be issued */
struct mmc_command *cmd;
/* data transmission, NULL means no transmission */
struct mmc_data *data;
/*stop command after data transmission */
struct mmc_command *stop;
/* completion data, used by core layer for sync. */
void *done_data;
/* request post processing function */
void (*done)(struct mmc_request *);
};
7
request handling flow
req->data == NULLsendcmd(req->cmd)
Data Transmission req>stop == NULL
mmc_request_done
sendcmd(req->stop)
N
Y
Y
N
mmc_request
cmd
data
stop
8
Q&A

Linux SD/MMC Driver Stack

  • 1.
    1 Linux SD/MMC DriverStack Champ Yen http://champyen.blogspot.com champ.yen@gmail.com
  • 2.
    2 Core SDIO SD MMC BLOCK Device UART (SDIO) BlueTooth (SDIO) WIFI (SDIO) Host AITOMAP S3C ...... Device ● Implement specific subsystem devices(ex: UART, WIFI) by utilizing Core API. Core -Diagnosing SD/MMC/SDIO device -SD/MMC/SDIO Protocol Layer implementation -Power Management Policy Host -Hardware dependent interface -Handling requests from Core layer. SD/MMC Stack Architecture
  • 3.
    3 Host Structure struct mmc_host{ …… const struct mmc_host_ops *ops; /* minimum frequency */ unsigned int f_min; /* maximum frequency */ unsigned int f_max; /* provided voltages */ u32 ocr_avail; unsigned long caps; /* host specific block data */ unsigned int max_seg_size; unsigned short max_hw_segs; unsigned short max_phys_segs; unsigned short unused; unsigned int max_req_size; unsigned int max_blk_size; unsigned int max_blk_count; …… };
  • 4.
    4 host allocation struct mmc_host*mmc; //private host data, hw dependent info is saved here. struct foo_host *host; //allocate mmc_host structure with private data size //pdev is the pointer of platform_device mmc = mmc_alloc_host(sizeof(struct foo_host), &pdev->dev); ////////////// initialization after allocation /////////////////// ////////////// private host data pointer is get as below struct foo_host *host; host = mmc_priv(mmc);
  • 5.
    5 Host Operations struct mmc_host_ops{ /* request handler */ void (*request)(struct mmc_host *host, struct mmc_request *req); /* host controller setting function */ void (*set_ios)(struct mmc_host *host, struct mmc_ios *ios); /* read-only detection , return 1: read-only, 0: read-write */ int (*get_ro)(struct mmc_host *host); /* card detection return 1: Card Inserted, 0: Card Not Inserted */ int (*get_cd)(struct mmc_host *host); /* enable SDIO irq */ void (*enable_sdio_irq)(struct mmc_host *host, int enable); };
  • 6.
    6 request struct mmc_request { /*command to be issued */ struct mmc_command *cmd; /* data transmission, NULL means no transmission */ struct mmc_data *data; /*stop command after data transmission */ struct mmc_command *stop; /* completion data, used by core layer for sync. */ void *done_data; /* request post processing function */ void (*done)(struct mmc_request *); };
  • 7.
    7 request handling flow req->data== NULLsendcmd(req->cmd) Data Transmission req>stop == NULL mmc_request_done sendcmd(req->stop) N Y Y N mmc_request cmd data stop
  • 8.