📄 sdio.patch
字号:
+inline int+sdio_card_read_cia (struct sd_card* card) {+ DBG("\n");+ if (sdio_ext_ops == NULL) {+ DBG("Function not assigned: sdio_card_read_cia()\n");+ return -EINVAL;+ }+ return sdio_ext_ops->sdio_card_read_cia(card);+}++inline int+sdio_card_rw_direct(struct sd_card* card,+ unsigned char read_write,+ unsigned char function,+ unsigned long address,+ unsigned char write_data,+ unsigned char* read_data) {+ DBG("\n");+ if (sdio_ext_ops == NULL) {+ DBG("Function not assigned: sdio_card_rw_direct()\n");+ return -EINVAL;+ }+ return sdio_ext_ops->sdio_card_rw_direct+ (card, read_write, function, address, write_data, read_data);+}++inline int+sdio_card_rw_block(struct sd_card* card,+ unsigned char read_write,+ unsigned char function,+ unsigned char blk_mode,+ unsigned char op_mode,+ unsigned long address,+ unsigned char *buffer,+ unsigned int buflen) {+ DBG("\n");+ if (sdio_ext_ops == NULL) {+ DBG("Function not assigned: sdio_card_rw_block()\n");+ return -EINVAL;+ }+ return sdio_ext_ops->sdio_card_rw_block+ (card, read_write, function, blk_mode, op_mode, address,+ buffer, buflen);+}++inline int+sdio_card_read_tuple(struct sd_card* card,+ unsigned char sd_tuple_code,+ unsigned char* buffer,+ unsigned char* size) {+ DBG("\n");+ if (sdio_ext_ops == NULL) {+ DBG("Function not assigned: sdio_card_read_tuple()\n");+ return -EINVAL;+ }+ return sdio_ext_ops->sdio_card_read_tuple+ (card, sd_tuple_code, buffer, size);+}++#else+int +sdio_card_decode_buffer (struct sd_card* sd_card,+ void* buffer,+ unsigned int sdio_buffer_type) {+ DBG("Function not implemented: sdio_card_decode_buffer()\n");+ return -EINVAL;+}++int+sdio_card_read_cia (struct sd_card* card) {+ DBG("Function not implemented: sdio_card_read_cia()\n");+ return -EINVAL;+}++int+sdio_card_rw_direct(struct sd_card* card,+ unsigned char read_write,+ unsigned char function,+ unsigned long address,+ unsigned char write_data,+ unsigned char* read_data) {+ DBG("Function not implemented: sdio_card_rw_direct()\n");+ return -EINVAL;+}++int+sdio_card_rw_block(struct sd_card* card,+ unsigned char read_write,+ unsigned char function,+ unsigned char blk_mode,+ unsigned char op_mode,+ unsigned long address,+ unsigned char *buffer,+ unsigned int buflen) {+ DBG("Function not implemented: sdio_card_rw_block()\n");+ return -EINVAL;+}++int+sdio_card_read_tuple(struct sd_card* card,+ unsigned char sd_tuple_code,+ unsigned char* buffer,+ unsigned char* size) {+ DBG("Function not implemented: sdio_card_read_tuple()\n");+ return -EINVAL;+}++#endif++static+struct sd_card* sdio_card_alloc(void) {+ struct sd_card* card = NULL;+ + card = kmalloc(sizeof(struct sd_card), GFP_KERNEL);+ if (card != NULL) {+ memset(card, 0, sizeof(struct sd_card));+ }+ + return card;+}++static void+sdio_card_free(struct sd_card * card)+{+ if (card != NULL)+ kfree(card);+}++int sdio_card_issue_command(struct sd_card* card,+ u32 command,+ u32 argument,+ unsigned int flags,+ int retries,+ u32* response) {+ struct mmc_command cmd;+ int err = MMC_ERR_NONE;+ + cmd.opcode = command;+ cmd.arg = argument;+ cmd.flags = flags;+ + if (card == NULL) {+ err = MMC_ERR_INVALID;+ }+ + if (err == MMC_ERR_NONE) {+ mmc_card_claim_host(card->mmc_card);+ err = mmc_wait_for_cmd(card->mmc_card->host, &cmd, retries);+ mmc_card_release_host(card->mmc_card);+ }+ + if (err == MMC_ERR_NONE) {+ if (response != NULL) {+ response[0] = cmd.resp[0];+ if ((cmd.flags & MMC_RSP_LONG) != 0) {+ response[1] = cmd.resp[1];+ response[2] = cmd.resp[2];+ response[3] = cmd.resp[3];+ }+ }+ }+ + return err;+}++EXPORT_SYMBOL(sdio_card_issue_command);++int sdio_card_read_direct(struct sd_card* card,+ unsigned char function,+ unsigned long address,+ unsigned char* read_buffer,+ unsigned int length) {+ int err = MMC_ERR_NONE;+ + /* NULL pointer check */+ if (err == MMC_ERR_NONE) {+ if (card == NULL) {+ err = MMC_ERR_INVALID;+ }+ if (read_buffer == NULL) {+ err = MMC_ERR_INVALID;+ }+ }+ + /* Read buffer */+ unsigned int bytes_read = 0;+ do {+ if (bytes_read >= length) {+ /* Finished */+ break;+ }+ err = sdio_card_rw_direct(card,+ 0, /* read */+ function,+ address,+ 0,+ &read_buffer[bytes_read]);+ ++bytes_read;+ ++address;+ } while (err == MMC_ERR_NONE);+ + return err;+}++EXPORT_SYMBOL(sdio_card_read_direct);++int sdio_card_write_direct(struct sd_card* card,+ unsigned char function,+ unsigned long address,+ unsigned char* write_buffer,+ unsigned int length,+ unsigned char* read_buffer) {+ int err = MMC_ERR_NONE;+ + /* NULL pointer check */+ if (err == MMC_ERR_NONE) {+ if (card == NULL) {+ err = MMC_ERR_INVALID;+ }+ if (write_buffer == NULL) {+ err = MMC_ERR_INVALID;+ }+ }+ + /* Write buffer */+ int bytes_written = 0;+ do {+ if (bytes_written == length) {+ /* Finished */+ break;+ }+ + if (read_buffer != NULL) {+ err = sdio_card_rw_direct(card,+ 1, /* write */+ function,+ address,+ write_buffer[bytes_written],+ &read_buffer[bytes_written]);+ }+ else {+ err = sdio_card_rw_direct(card,+ 1, /* write */+ function,+ address,+ write_buffer[bytes_written],+ NULL);+ }+ ++bytes_written;+ ++address;+ } while (err == MMC_ERR_NONE);+ + return err;+}++EXPORT_SYMBOL(sdio_card_write_direct);++int sdio_card_read_block(struct sd_card* card,+ unsigned char function,+ unsigned long address,+ unsigned char* read_buffer,+ unsigned int length) {+ return sdio_card_rw_block(card,+ 0, /* Read */+ function,+ 0, /* Byte mode */+ 1, /* Incrementing address */+ address,+ read_buffer,+ length);+}++EXPORT_SYMBOL(sdio_card_read_block);++int sdio_card_write_block(struct sd_card* card,+ unsigned char function,+ unsigned long address,+ unsigned char* write_buffer,+ unsigned int length) {+ return sdio_card_rw_block(card,+ 1, /* Write */+ function,+ 0, /* Byte mode */+ 1, /* Incrementing address */+ address,+ write_buffer,+ length);+}++EXPORT_SYMBOL(sdio_card_write_block);++void sdio_card_set_isr_callback(struct sd_card* card,+ void (*isr_callback)(struct sd_card* card)) {+#if 0+ if (card->isr_callback != NULL) {+ /* TODO: rrichter: Disable SDIO function interrupts */+ ;+ }+#endif + card->isr_callback = isr_callback;+#if 0+ if (card->isr_callback != NULL) {+ /* TODO: rrichter: Enable SDIO function interrupts */+ ;+ }+#endif+}++EXPORT_SYMBOL(sdio_card_set_isr_callback);++static+void __sdio_host_irq_handler(unsigned long param) {+ struct mmc_host *host = (struct mmc_host *) param;+ struct mmc_card *card;+ + list_for_each_entry(card, &host->sdio_cards, sdio_node) {+ if (card->sd_card->isr_callback != NULL)+ card->sd_card->isr_callback(card->sd_card);+ }+}++void sdio_host_irq_handler(struct mmc_host* mmc_host) {+ tasklet_schedule(&mmc_host->sdio_host->irq_handler);+ return;+}++EXPORT_SYMBOL(sdio_host_irq_handler);++static+struct sdio_host_ops sdio_host_ops = {+ .sdio_card_alloc = sdio_card_alloc,+ .sdio_card_free = sdio_card_free,+ .sdio_card_register = sdio_card_register,+ .sdio_card_unregister = sdio_card_unregister,+ .sdio_card_read_cia = sdio_card_read_cia,+ .sdio_card_decode_buffer = sdio_card_decode_buffer,+};++int sdio_host_alloc(struct mmc_host* mmc_host) {+ struct sdio_host* sdio_host = NULL;+ + if (mmc_host == NULL)+ return -EINVAL;+ + if (mmc_host->sdio_host != NULL)+ return -EBUSY;+ + sdio_host = kmalloc(sizeof(struct sdio_host), GFP_KERNEL);+ if (sdio_host == NULL)+ return -ENOMEM;+ + memset(sdio_host, 0, sizeof(struct sdio_host));+ sdio_host->mmc_host = mmc_host;+ sdio_host->ops = &sdio_host_ops;+ tasklet_init(&sdio_host->irq_handler,+ __sdio_host_irq_handler, + (unsigned long) mmc_host);+ + mmc_host->sdio_host = sdio_host;+ + return 0;+}++EXPORT_SYMBOL(sdio_host_alloc);++void sdio_host_free(struct mmc_host *mmc_host) {+ struct sdio_host* sdio_host = NULL;+ + if (mmc_host == NULL)+ return;+ + sdio_host = mmc_host->sdio_host;+ if (sdio_host == NULL)+ return;+ + mmc_host->sdio_host = NULL;+ tasklet_kill(&sdio_host->irq_handler);+ kfree(sdio_host);+}++EXPORT_SYMBOL(sdio_host_free);diff -Naur -x '.*' -x '*~' -x '*.o' -x '*.ko' -x '*.mod.c' -x '*.cmd' linux26-cvs.BOM/drivers/mmc/sdio.h linux26-cvs.sdio/drivers/mmc/sdio.h--- linux26-cvs.BOM/drivers/mmc/sdio.h 1970-01-01 01:00:00.000000000 +0100+++ linux26-cvs.sdio/drivers/mmc/sdio.h 2005-10-20 18:49:51.000000000 +0200@@ -0,0 +1,120 @@+/*****************************************************************************+ *+ * Filename: drivers/mmc/sdio.h+ * Document Number: + *+ * Revision Number: $Revision: #14 $+ * Revision Status: $State$+ *+ * Last Changed: $Author: rrichter $+ * $Date: 2005/10/20 $+ *+ *-----------------------------------------------------------------------------+ *+ * Copyright 2005 ADVANCED MICRO DEVICES, INC. All Rights Reserved.+ * by Robert Richter+ * + * This program is free software; you can redistribute it and/or+ * modify it under the terms of the GNU General Public License+ * as published by the Free Software Foundation; either version 2+ * of the License, or (at your option) any later version.+ * + * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU General Public License for more details.+ * + * You should have received a copy of the GNU General Public License+ * along with this program; if not, write to the Free Software+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,+ * MA 02110-1301, USA.+ * + *****************************************************************************/++/*****************************************************************************+ *+ * SDIO specific source code implements only:+ * + * Simplified Version of:+ * Part E1+ * SD Input/Output (SDIO)+ * Card Specification+ * Version 1.00+ * October, 2001+ * http://www.sdcard.org/sdio/Simplified%20SDIO%20Card%20Specification.pdf+ * + * This source code does not contain information that can be treated as + * confidential under the Non Disclosure Agreement (NDA) with SD Card + * Association.+ * + *****************************************************************************/++#ifndef _SDIO_H+#define _SDIO_H++/* SDIO card handle */+struct sd_card {+ struct mmc_card* mmc_card; /* belonging card */+ u8 crd_rdy; /* R4 */+ u8 func;+ u8 mem;+ u32 ocr;+ u8 status; /* R5 */+ u8 rw_data;+ u32 common_cis_pointer; /* CCCR */+ u8 bus_if;+ u8 caps;+ u16 mid_manf; /* CIS - MANFID */+ u16 mid_card;+ u16 fn0_blk_size; /* CIS - FUNCE */+ u32 max_dtr;+#define SD_CARD_MAX_DTR_FULL_SPEED 25000000u+ void (*isr_callback) (struct sd_card* card); /* SDIO card ISR */+};++struct sdio_host_ops {+ struct sd_card* (*sdio_card_alloc) (void);+ void (*sdio_card_free) (struct sd_card* card);+ int (*sdio_card_register) (struct sd_card* card);+ void (*sdio_card_unregister) (struct sd_card* card);+ int (*sdio_card_read_cia) (struct sd_card* card);+ int (*sdio_card_decode_buffer) (struct sd_card* card,+ void* buffer,+ unsigned int sdio_buffer_type);+};++struct sdio_host {+ struct mmc_host* mmc_host;+ struct sdio_host_ops* ops;+ struct tasklet_struct irq_handler;+};++#ifdef CONFIG_SDIO_EXT+struct sdio_ext_ops {+ int (*sdio_card_decode_buffer) (struct sd_card* sd_card,+ void* buffer,+ unsigned int sdio_buffer_type);+ int (*sdio_card_read_cia) (struct sd_card* card);+ int (*sdio_card_rw_direct) (struct sd_card* card,+ unsigned char read_write,+ unsigned char function,+ unsigned long address,+ unsigned char write_data,+ unsigned char* read_data);+ int (*sdio_card_rw_block) (struct sd_card* card,+ unsigned char read_write,+ unsigned char function,+ unsigned char blk_mode,+ unsigned char op_mode,+ unsigned long address,+ unsigned char *buffer,+ unsigned int buflen);+ int (*sdio_card_r
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -