📄 sdio.patch
字号:
+ __res = resp[__off] >> __shft; \+ if (__size + __shft > 32) \+ __res |= resp[__off-1] << ((32 - __shft) % 32); \+ __res & __mask; \+ })++#define CMD_RETRIES 3+ /* core-internal functions */-void mmc_init_card(struct mmc_card *card, struct mmc_host *host);-int mmc_register_card(struct mmc_card *card);-void mmc_remove_card(struct mmc_card *card);-#endif+extern unsigned int mmc_calc_max_dtr(unsigned char clock);+extern int mmc_register_card(struct mmc_card *card);+extern void mmc_unregister_card(struct mmc_card *card);++#endif /* _MMC_H */diff -Naur -x '.*' -x '*~' -x '*.o' -x '*.ko' -x '*.mod.c' -x '*.cmd' linux26-cvs.BOM/drivers/mmc/mmc_sysfs.c linux26-cvs.sdio/drivers/mmc/mmc_sysfs.c--- linux26-cvs.BOM/drivers/mmc/mmc_sysfs.c 2005-10-20 18:17:10.000000000 +0200+++ linux26-cvs.sdio/drivers/mmc/mmc_sysfs.c 2005-10-20 18:22:18.000000000 +0200@@ -3,6 +3,9 @@ * * Copyright (C) 2003 Russell King, All Rights Reserved. *+ * SDIO support: 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 version 2 as * published by the Free Software Foundation.@@ -21,11 +24,10 @@ #define dev_to_mmc_card(d) container_of(d, struct mmc_card, dev) #define to_mmc_driver(d) container_of(d, struct mmc_driver, drv) -static void mmc_release_card(struct device *dev)-{- struct mmc_card *card = dev_to_mmc_card(dev);-- kfree(card);+static void mmc_release_card(struct device *dev) {+ /* Add release function, see device_release(), core.c */+ /* Nothing to do here */+ return; } /*@@ -186,33 +188,24 @@ }; /*- * Internal function. Initialise a MMC card structure.- */-void mmc_init_card(struct mmc_card *card, struct mmc_host *host)-{- memset(card, 0, sizeof(struct mmc_card));- card->host = host;- device_initialize(&card->dev);- card->dev.parent = card->host->dev;- card->dev.bus = &mmc_bus_type;- card->dev.release = mmc_release_card;-}--/* * Internal function. Register a new MMC card with the driver model. */ int mmc_register_card(struct mmc_card *card) { int ret, i;-+ snprintf(card->dev.bus_id, sizeof(card->dev.bus_id), "%s:%04x", card->host->host_name, card->rca);-- ret = device_add(&card->dev);+ + card->dev.parent = card->host->dev;+ card->dev.bus = &mmc_bus_type;+ card->dev.release = mmc_release_card;+ + ret = device_register(&card->dev); if (ret == 0) for (i = 0; i < ARRAY_SIZE(mmc_dev_attributes); i++) device_create_file(&card->dev, mmc_dev_attributes[i]);-+ return ret; } @@ -220,12 +213,13 @@ * Internal function. Unregister a new MMC card with the * driver model, and (eventually) free it. */-void mmc_remove_card(struct mmc_card *card)+void mmc_unregister_card(struct mmc_card *card) {- if (mmc_card_present(card))- device_del(&card->dev);-- put_device(&card->dev);+ int i = 0;+ + for (i = 0; i < ARRAY_SIZE(mmc_dev_attributes); i++)+ device_remove_file(&card->dev, mmc_dev_attributes[i]);+ device_unregister(&card->dev); } diff -Naur -x '.*' -x '*~' -x '*.o' -x '*.ko' -x '*.mod.c' -x '*.cmd' linux26-cvs.BOM/drivers/mmc/sdiobus.c linux26-cvs.sdio/drivers/mmc/sdiobus.c--- linux26-cvs.BOM/drivers/mmc/sdiobus.c 1970-01-01 01:00:00.000000000 +0100+++ linux26-cvs.sdio/drivers/mmc/sdiobus.c 2005-10-20 18:49:51.000000000 +0200@@ -0,0 +1,297 @@+/*****************************************************************************+ *+ * Filename: drivers/mmc/sdiobus.c+ * Document Number: + *+ * Revision Number: $Revision: #7 $+ * 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.+ * + *****************************************************************************/++#include <linux/device.h>+#include <linux/mmc/card.h>+#include <linux/mmc/host.h>+#include <linux/mmc/sdiocard.h>+#include "sdio.h"+++#ifdef CONFIG_MMC_DEBUG+#define DBG(fmt, x...) printk("%s:%4d: " fmt, "SDIOBUS", __LINE__, ##x)+#else+#define DBG(x...) do { } while (0)+#endif++#define BUS_ID_STRING "SDIO-%04x-%04x"++struct sd_card* dev_to_sdio_card (struct device *dev) {+ struct sd_card* sd_card = NULL;+ struct mmc_card* mmc_card = NULL;+ + if (dev != NULL) {+ mmc_card = container_of(dev, struct mmc_card, dev);+ sd_card = mmc_card->sd_card;+ }+ + return sd_card;+}++EXPORT_SYMBOL(dev_to_sdio_card);++static+int sdio_bus_match(struct device * dev, struct device_driver * drv) {+ int err = MMC_ERR_NONE;+ struct mmc_card* card = NULL;+ struct sdio_driver* driver = NULL;+ int found = 0;+ + DBG("Entering sdio_bus_match()\n");+ + /* NULL pointer check */+ if (err == MMC_ERR_NONE) {+ if (dev == NULL) {+ DBG("Invalid device\n");+ err = MMC_ERR_INVALID;+ }+ if (drv == NULL) {+ DBG("Invalid driver\n");+ err = MMC_ERR_INVALID;+ }+ }+ + /* Calculate card and driver handle */+ if (err == MMC_ERR_NONE) {+ card = container_of(dev, struct mmc_card, dev);+ driver = container_of(drv, struct sdio_driver, driver);+ if (card == NULL) {+ DBG("Invalid MMC card\n");+ err = MMC_ERR_INVALID;+ }+ else if (card->sd_card == NULL) {+ DBG("Invalid SDIO card\n");+ err = MMC_ERR_INVALID;+ }+ + if (driver == NULL) {+ DBG("Invalid SDIO driver\n");+ err = MMC_ERR_INVALID;+ }+ }+ + /* Check card ID */+ if (err == MMC_ERR_NONE) {+ if ((card->sd_card->mid_manf == driver->mid_manf) &&+ (card->sd_card->mid_card == driver->mid_card)) {+ printk(KERN_INFO "Driver found for SDIO device: %s ("+ BUS_ID_STRING ")\n",+ driver->driver.name,+ driver->mid_manf,+ driver->mid_card);+ found = 1;+ }+ else {+ DBG("No match: Driver ID: %s ("+ BUS_ID_STRING+ "), Card ID: "+ BUS_ID_STRING+ "\n",+ driver->driver.name,+ driver->mid_manf,+ driver->mid_card,+ card->sd_card->mid_manf,+ card->sd_card->mid_card);+ }+ }+ + DBG("Leaving sdio_bus_match()\n");+ + return found;+}++/* This defines the Secure Digital bus */+struct bus_type sdio_bus_type = {+ .name = "sdio",+ .match = sdio_bus_match,+ /* TODO: rrichter: Add hotplug, suspend, resume bus fuctions */+};++/* SD bus register functions */+int sdio_driver_register (struct sdio_driver *drv) {+ int retVal = 0;+ struct bus_type* sdio_bus = NULL;+ + /* NULL pointer check */+ if (retVal == 0) {+ if (drv == NULL) {+ retVal = -EINVAL;+ }+ }+ + /* Search SD bus */+ if (retVal == 0) {+ sdio_bus = find_bus(sdio_bus_type.name);+ if (sdio_bus != &sdio_bus_type) {+ /* Not found */+ DBG("SDIO bus not found\n");+ retVal = -ENXIO;+ }+ }+ + /* Register driver on bus */+ if (retVal == 0) {+ DBG("SDIO bus found\n");+ drv->driver.bus = &sdio_bus_type;+ printk(KERN_INFO "Registering SDIO driver: %s ("+ BUS_ID_STRING ")\n",+ drv->driver.name,+ drv->mid_manf,+ drv->mid_card);+ retVal = driver_register(&drv->driver);+ }+ + return retVal;+}++EXPORT_SYMBOL(sdio_driver_register);++void sdio_driver_unregister (struct sdio_driver *drv) {+ if (drv != NULL) {+ printk(KERN_INFO "Unregistering SDIO driver: %s ("+ BUS_ID_STRING ")\n",+ drv->driver.name,+ drv->mid_manf,+ drv->mid_card);+ driver_unregister(&drv->driver);+ }+ + return;+}++EXPORT_SYMBOL(sdio_driver_unregister);++static+void sdio_card_release(struct device * dev) {+ /* Add release function, see device_release(), core.c */+ /* Nothing to do here */+ return;+}++int sdio_card_register (struct sd_card *card) {+ int retVal = 0;+ + /* NULL pointer check */+ if (retVal == 0) {+ if (card == NULL) {+ retVal = -EINVAL;+ }+ else if (card->mmc_card == NULL) {+ retVal = -EINVAL;+ }+ else if (card->mmc_card->host == NULL) {+ retVal = -EINVAL;+ }+ }+ + if (retVal == 0) {+ if (card->mmc_card->dev.parent == NULL) {+ /* Host controller device is parent */+ card->mmc_card->dev.parent =+ card->mmc_card->host->dev;+ }+ /* Register at SD bus */+ card->mmc_card->dev.bus = &sdio_bus_type;+ card->mmc_card->dev.release = &sdio_card_release;+ /* Set bus id string */+ snprintf(card->mmc_card->dev.bus_id,+ BUS_ID_SIZE,+ BUS_ID_STRING,+ card->mid_manf,+ card->mid_card);+ printk(KERN_INFO "Registering SDIO device: %s\n",+ card->mmc_card->dev.bus_id);+ retVal = device_register(&card->mmc_card->dev);+ }+ + return retVal; +}++EXPORT_SYMBOL(sdio_card_register);++void sdio_card_unregister (struct sd_card *card) {+ struct device * dev = NULL;+ + /* NULL pointer check */+ if (card != NULL) {+ if (card->mmc_card != NULL) {+ dev = &card->mmc_card->dev;+ }+ }+ + /* Unregister device */+ if (dev != NULL) {+ printk(KERN_INFO "Unregistering SDIO device: %s\n",+ dev->bus_id);+ device_unregister(dev);+ }+ + return;+}++EXPORT_SYMBOL(sdio_card_unregister);++static int __init sdio_bus_init(void)+{+ return bus_register(&sdio_bus_type);+}++static void __exit sdio_bus_exit(void)+{+ bus_unregister(&sdio_bus_type);+}++module_init(sdio_bus_init);+module_exit(sdio_bus_exit);++MODULE_AUTHOR("Robert Richter");++MODULE_LICENSE("GPL");diff -Naur -x '.*' -x '*~' -x '*.o' -x '*.ko' -x '*.mod.c' -x '*.cmd' linux26-cvs.BOM/drivers/mmc/sdio.c linux26-cvs.sdio/drivers/mmc/sdio.c--- linux26-cvs.BOM/drivers/mmc/sdio.c 1970-01-01 01:00:00.000000000 +0100+++ linux26-cvs.sdio/drivers/mmc/sdio.c 2005-10-20 18:49:51.000000000 +0200@@ -0,0 +1,465 @@+/*****************************************************************************+ *+ * Filename: drivers/mmc/sdio.c+ * Document Number: + *+ * Revision Number: $Revision: #12 $+ * 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.+ * + *****************************************************************************/++#include <linux/mmc/host.h>+#include <linux/mmc/card.h>+#include <linux/mmc/protocol.h>+#include <linux/mmc/sdiocard.h>+#include <linux/mmc/sdiohost.h>+#include "mmc.h"+#include "sdio.h"+++#ifdef CONFIG_MMC_DEBUG+#define DBG(fmt, x...) printk("%s:%4d: " fmt, "SDIO", __LINE__, ##x)+#else+#define DBG(x...) do { } while (0)+#endif+++#ifdef CONFIG_SDIO_EXT+struct sdio_ext_ops *sdio_ext_ops = NULL;+EXPORT_SYMBOL(sdio_ext_ops);++inline int +sdio_card_decode_buffer (struct sd_card* sd_card,+ void* buffer,+ unsigned int sdio_buffer_type) {+ DBG("\n");+ if (sdio_ext_ops == NULL) {+ DBG("Function not assigned: sdio_card_decode_buffer()\n");+ return -EINVAL;+ }+ return sdio_ext_ops->sdio_card_decode_buffer+ (sd_card, buffer, sdio_buffer_type);+}+
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -