00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef _SDIO_API_H
00010 #define _SDIO_API_H
00011
00035 struct sdioemb_func_driver;
00036 struct sdioemb_dev;
00037 struct sdioemb_dev_priv;
00038
00048 struct sdioemb_dev {
00049 struct sdioemb_func_driver *driver;
00050 uint16_t vendor_id;
00051 uint16_t device_id;
00052 int function;
00053 uint8_t interface;
00054 uint16_t max_blocksize;
00055 uint16_t blocksize;
00056 int slot_id;
00057 void * os_device;
00058 struct sdioemb_dev_priv *priv;
00059 void * drv_data;
00060 };
00061
00062 #define SDIOEMB_ANY_ID 0xffff
00063 #define SDIOEMB_UIF_FUNC 0
00064 #define SDIOEMB_ANY_FUNC 0xff
00065 #define SDIOEMB_ANY_IFACE 0xff
00066
00079 struct sdioemb_id_table {
00080 uint16_t vendor_id;
00081 uint16_t device_id;
00082 int function;
00083 uint8_t interface;
00084 };
00085
00091 struct sdioemb_func_driver {
00095 const char *name;
00096
00104 struct sdioemb_id_table *id_table;
00105
00122 int (*probe)(struct sdioemb_dev *fdev);
00123
00137 void (*remove)(struct sdioemb_dev *fdev);
00138
00154 void (*card_int_handler)(struct sdioemb_dev *fdev);
00155
00169 void (*suspend)(struct sdioemb_dev *fdev);
00170
00185 void (*resume)(struct sdioemb_dev *fdev);
00186 };
00187
00188 int sdioemb_driver_register(struct sdioemb_func_driver *fdriver);
00189 void sdioemb_driver_unregister(struct sdioemb_func_driver *fdriver);
00190
00191 int sdioemb_driver_probe(struct sdioemb_func_driver *fdriver, struct sdioemb_dev *fdev);
00192 void sdioemb_driver_remove(struct sdioemb_func_driver *fdriver, struct sdioemb_dev *fdev);
00193
00194
00195 #define sdio_register_driver sdioemb_driver_register
00196 #define sdio_unregister_driver sdioemb_driver_unregister
00197
00198 int sdioemb_set_block_size(struct sdioemb_dev *fdev, uint16_t blksz);
00199 void sdioemb_set_max_bus_freq(struct sdioemb_dev *fdev, int max_freq);
00200 int sdioemb_set_bus_width(struct sdioemb_dev *fdev, int bus_width);
00201
00202 int sdioemb_enable_function(struct sdioemb_dev *fdev);
00203 int sdioemb_disable_function(struct sdioemb_dev *fdev);
00204 int sdioemb_reenable_csr_function(struct sdioemb_dev *dev);
00205 void sdioemb_idle_function(struct sdioemb_dev *fdev);
00206
00207 int sdioemb_read8(struct sdioemb_dev *fdev, uint32_t addr, uint8_t *val);
00208 int sdioemb_read16(struct sdioemb_dev *fdev, uint32_t addr, uint16_t *val);
00209 int sdioemb_write8(struct sdioemb_dev *fdev, uint32_t addr, uint8_t val);
00210 int sdioemb_write16(struct sdioemb_dev *fdev, uint32_t addr, uint16_t val);
00211 int sdioemb_f0_read8(struct sdioemb_dev *fdev, uint32_t addr, uint8_t *val);
00212 int sdioemb_f0_write8(struct sdioemb_dev *fdev, uint32_t addr, uint8_t val);
00213 int sdioemb_read(struct sdioemb_dev *fdev, uint32_t addr, void *data, size_t len);
00214 int sdioemb_write(struct sdioemb_dev *fdev, uint32_t addr, const void *data, size_t len);
00215
00216 int sdioemb_hard_reset(struct sdioemb_dev *fdev);
00217
00218 void sdioemb_power_on(struct sdioemb_dev *fdev);
00219 void sdioemb_power_off(struct sdioemb_dev *fdev);
00220
00221 int sdioemb_interrupt_enable(struct sdioemb_dev *fdev);
00222 int sdioemb_interrupt_disable(struct sdioemb_dev *fdev);
00223 void sdioemb_interrupt_acknowledge(struct sdioemb_dev *fdev);
00224
00225 int sdioemb_cis_get_tuple(struct sdioemb_dev *fdev, uint8_t tuple,
00226 void *buf, size_t len);
00227
00228 void sdioemb_suspend_function(struct sdioemb_dev *fdev);
00229 void sdioemb_resume_function(struct sdioemb_dev *fdev);
00230
00236 enum sdioemb_cmd_status {
00237 SDIOEMB_CMD_OK = 0x00,
00239 SDIOEMB_CMD_ERR_CMD = 0x01,
00240 SDIOEMB_CMD_ERR_DAT = 0x02,
00241
00242 SDIOEMB_CMD_ERR_CRC = 0x10,
00243 SDIOEMB_CMD_ERR_TIMEOUT = 0x20,
00244 SDIOEMB_CMD_ERR_OTHER = 0x40,
00245
00246 SDIOEMB_CMD_ERR_CMD_CRC = SDIOEMB_CMD_ERR_CMD | SDIOEMB_CMD_ERR_CRC,
00247 SDIOEMB_CMD_ERR_CMD_TIMEOUT = SDIOEMB_CMD_ERR_CMD | SDIOEMB_CMD_ERR_TIMEOUT,
00248 SDIOEMB_CMD_ERR_CMD_OTHER = SDIOEMB_CMD_ERR_CMD | SDIOEMB_CMD_ERR_OTHER,
00249 SDIOEMB_CMD_ERR_DAT_CRC = SDIOEMB_CMD_ERR_DAT | SDIOEMB_CMD_ERR_CRC,
00250 SDIOEMB_CMD_ERR_DAT_TIMEOUT = SDIOEMB_CMD_ERR_DAT | SDIOEMB_CMD_ERR_TIMEOUT,
00251 SDIOEMB_CMD_ERR_DAT_OTHER = SDIOEMB_CMD_ERR_DAT | SDIOEMB_CMD_ERR_OTHER,
00253 SDIOEMB_CMD_ERR_NO_CARD = 0x04,
00255 SDIOEMB_CMD_IN_PROGRESS = 0xff,
00256 };
00257
00271 union sdioemb_response {
00272 uint32_t r1;
00273 uint32_t r4;
00274 uint32_t r5;
00275 uint32_t r6;
00276 };
00277
00281 struct sdioemb_cmd_resp {
00282 uint8_t cmd;
00283 uint32_t arg;
00284 union sdioemb_response response;
00287 };
00288
00292 struct cspi_cmd_resp {
00293 unsigned cmd : 8;
00294 unsigned addr: 24;
00295 uint16_t val;
00296 uint8_t response;
00298 };
00299
00300
00309 struct sdioemb_cmd {
00314 struct sdioemb_dev *owner;
00315
00323 void (*callback)(struct sdioemb_cmd *cmd);
00324
00346 unsigned flags;
00347
00353 struct sdioemb_cmd_resp sdio;
00354
00360 struct cspi_cmd_resp cspi;
00361
00367 uint8_t *data;
00368
00375 size_t len;
00376
00380 enum sdioemb_cmd_status status;
00381
00385 void *priv;
00386 };
00387
00390 #define SDIOEMB_CMD_FLAG_RESP_NONE 0x00
00391 #define SDIOEMB_CMD_FLAG_RESP_R1 0x01
00392 #define SDIOEMB_CMD_FLAG_RESP_R1B 0x02
00393 #define SDIOEMB_CMD_FLAG_RESP_R2 0x03
00394 #define SDIOEMB_CMD_FLAG_RESP_R3 0x04
00395 #define SDIOEMB_CMD_FLAG_RESP_R4 0x05
00396 #define SDIOEMB_CMD_FLAG_RESP_R5 0x06
00397 #define SDIOEMB_CMD_FLAG_RESP_R5B 0x07
00398 #define SDIOEMB_CMD_FLAG_RESP_R6 0x08
00399 #define SDIOEMB_CMD_FLAG_RESP_MASK 0xff
00400 #define SDIOEMB_CMD_FLAG_RAW 0x0100
00401 #define SDIOEMB_CMD_FLAG_READ 0x0200
00402 #define SDIOEMB_CMD_FLAG_CSPI 0x0400
00403 #define SDIOEMB_CMD_FLAG_ABORT 0x0800
00405
00406 int sdioemb_start_cmd(struct sdioemb_dev *fdev, struct sdioemb_cmd *cmd);
00407
00408 #endif