1 Index: linux-2.6.25.17/drivers/mmc/host/gpiommc.c
2 ===================================================================
3 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
4 +++ linux-2.6.25.17/drivers/mmc/host/gpiommc.c 2008-10-18 23:33:54.000000000 +0200
7 + * Driver an MMC/SD card on a bitbanging GPIO SPI bus.
8 + * This module hooks up the mmc_spi and spi_gpio modules and also
9 + * provides a configfs interface.
11 + * Licensed under the GNU/GPL. See COPYING for details.
14 +#include <linux/mmc/gpiommc.h>
15 +#include <linux/platform_device.h>
16 +#include <linux/list.h>
17 +#include <linux/mutex.h>
18 +#include <linux/spi/spi_gpio.h>
19 +#include <linux/configfs.h>
20 +#include <linux/gpio.h>
21 +#include <asm/atomic.h>
24 +#define PFX "gpio-mmc: "
27 +struct gpiommc_device {
28 + struct platform_device *pdev;
29 + struct platform_device *spi_pdev;
30 + struct spi_board_info boardinfo;
34 +MODULE_DESCRIPTION("GPIO based MMC driver");
35 +MODULE_LICENSE("GPL");
38 +static int gpiommc_boardinfo_setup(struct spi_board_info *bi,
39 + struct spi_master *master,
42 + struct gpiommc_device *d = data;
43 + struct gpiommc_platform_data *pdata = d->pdev->dev.platform_data;
45 + /* Bind the SPI master to the MMC-SPI host driver. */
46 + strlcpy(bi->modalias, "mmc_spi", sizeof(bi->modalias));
48 + bi->max_speed_hz = pdata->max_bus_speed;
49 + bi->bus_num = master->bus_num;
50 + bi->mode = pdata->mode;
55 +static int gpiommc_probe(struct platform_device *pdev)
57 + struct gpiommc_platform_data *mmc_pdata = pdev->dev.platform_data;
58 + struct spi_gpio_platform_data spi_pdata;
59 + struct gpiommc_device *d;
66 +#ifdef CONFIG_MMC_SPI_MODULE
67 + err = request_module("mmc_spi");
69 + printk(KERN_WARNING PFX
70 + "Failed to request mmc_spi module.\n");
72 +#endif /* CONFIG_MMC_SPI_MODULE */
74 + /* Allocate the GPIO-MMC device */
76 + d = kzalloc(sizeof(*d), GFP_KERNEL);
81 + /* Create the SPI-GPIO device */
82 + d->spi_pdev = platform_device_alloc(SPI_GPIO_PLATDEV_NAME,
83 + spi_gpio_next_id());
87 + memset(&spi_pdata, 0, sizeof(spi_pdata));
88 + spi_pdata.pin_clk = mmc_pdata->pins.gpio_clk;
89 + spi_pdata.pin_miso = mmc_pdata->pins.gpio_do;
90 + spi_pdata.pin_mosi = mmc_pdata->pins.gpio_di;
91 + spi_pdata.pin_cs = mmc_pdata->pins.gpio_cs;
92 + spi_pdata.cs_activelow = mmc_pdata->pins.cs_activelow;
93 + spi_pdata.no_spi_delay = mmc_pdata->no_spi_delay;
94 + spi_pdata.boardinfo_setup = gpiommc_boardinfo_setup;
95 + spi_pdata.boardinfo_setup_data = d;
97 + err = platform_device_add_data(d->spi_pdev, &spi_pdata,
100 + goto err_free_pdev;
101 + err = platform_device_add(d->spi_pdev);
103 + goto err_free_pdata;
104 + platform_set_drvdata(pdev, d);
106 + printk(KERN_INFO PFX "MMC-Card \"%s\" "
107 + "attached to GPIO pins di=%u, do=%u, clk=%u, cs=%u\n",
108 + mmc_pdata->name, mmc_pdata->pins.gpio_di,
109 + mmc_pdata->pins.gpio_do,
110 + mmc_pdata->pins.gpio_clk,
111 + mmc_pdata->pins.gpio_cs);
116 + kfree(d->spi_pdev->dev.platform_data);
117 + d->spi_pdev->dev.platform_data = NULL;
119 + platform_device_put(d->spi_pdev);
126 +static int gpiommc_remove(struct platform_device *pdev)
128 + struct gpiommc_device *d = platform_get_drvdata(pdev);
129 + struct gpiommc_platform_data *pdata = d->pdev->dev.platform_data;
131 + platform_device_unregister(d->spi_pdev);
132 + printk(KERN_INFO PFX "GPIO based MMC-Card \"%s\" removed\n",
134 + platform_device_put(d->spi_pdev);
139 +#ifdef CONFIG_GPIOMMC_CONFIGFS
141 +/* A device that was created through configfs */
142 +struct gpiommc_configfs_device {
143 + struct config_item item;
144 + /* The platform device, after registration. */
145 + struct platform_device *pdev;
146 + /* The configuration */
147 + struct gpiommc_platform_data pdata;
150 +#define GPIO_INVALID -1
152 +static inline bool gpiommc_is_registered(struct gpiommc_configfs_device *dev)
154 + return (dev->pdev != NULL);
157 +static inline struct gpiommc_configfs_device *ci_to_gpiommc(struct config_item *item)
159 + return item ? container_of(item, struct gpiommc_configfs_device, item) : NULL;
162 +static struct configfs_attribute gpiommc_attr_DI = {
163 + .ca_owner = THIS_MODULE,
164 + .ca_name = "gpio_data_in",
165 + .ca_mode = S_IRUGO | S_IWUSR,
168 +static struct configfs_attribute gpiommc_attr_DO = {
169 + .ca_owner = THIS_MODULE,
170 + .ca_name = "gpio_data_out",
171 + .ca_mode = S_IRUGO | S_IWUSR,
174 +static struct configfs_attribute gpiommc_attr_CLK = {
175 + .ca_owner = THIS_MODULE,
176 + .ca_name = "gpio_clock",
177 + .ca_mode = S_IRUGO | S_IWUSR,
180 +static struct configfs_attribute gpiommc_attr_CS = {
181 + .ca_owner = THIS_MODULE,
182 + .ca_name = "gpio_chipselect",
183 + .ca_mode = S_IRUGO | S_IWUSR,
186 +static struct configfs_attribute gpiommc_attr_CS_activelow = {
187 + .ca_owner = THIS_MODULE,
188 + .ca_name = "gpio_chipselect_activelow",
189 + .ca_mode = S_IRUGO | S_IWUSR,
192 +static struct configfs_attribute gpiommc_attr_spimode = {
193 + .ca_owner = THIS_MODULE,
194 + .ca_name = "spi_mode",
195 + .ca_mode = S_IRUGO | S_IWUSR,
198 +static struct configfs_attribute gpiommc_attr_spidelay = {
199 + .ca_owner = THIS_MODULE,
200 + .ca_name = "spi_delay",
201 + .ca_mode = S_IRUGO | S_IWUSR,
204 +static struct configfs_attribute gpiommc_attr_max_bus_speed = {
205 + .ca_owner = THIS_MODULE,
206 + .ca_name = "max_bus_speed",
207 + .ca_mode = S_IRUGO | S_IWUSR,
210 +static struct configfs_attribute gpiommc_attr_register = {
211 + .ca_owner = THIS_MODULE,
212 + .ca_name = "register",
213 + .ca_mode = S_IRUGO | S_IWUSR,
216 +static struct configfs_attribute *gpiommc_config_attrs[] = {
221 + &gpiommc_attr_CS_activelow,
222 + &gpiommc_attr_spimode,
223 + &gpiommc_attr_spidelay,
224 + &gpiommc_attr_max_bus_speed,
225 + &gpiommc_attr_register,
229 +static ssize_t gpiommc_config_attr_show(struct config_item *item,
230 + struct configfs_attribute *attr,
233 + struct gpiommc_configfs_device *dev = ci_to_gpiommc(item);
238 + if (attr == &gpiommc_attr_DI) {
239 + gpio = dev->pdata.pins.gpio_di;
240 + if (gpio == GPIO_INVALID)
241 + count = snprintf(page, PAGE_SIZE, "not configured\n");
243 + count = snprintf(page, PAGE_SIZE, "%u\n", gpio);
246 + if (attr == &gpiommc_attr_DO) {
247 + gpio = dev->pdata.pins.gpio_do;
248 + if (gpio == GPIO_INVALID)
249 + count = snprintf(page, PAGE_SIZE, "not configured\n");
251 + count = snprintf(page, PAGE_SIZE, "%u\n", gpio);
254 + if (attr == &gpiommc_attr_CLK) {
255 + gpio = dev->pdata.pins.gpio_clk;
256 + if (gpio == GPIO_INVALID)
257 + count = snprintf(page, PAGE_SIZE, "not configured\n");
259 + count = snprintf(page, PAGE_SIZE, "%u\n", gpio);
262 + if (attr == &gpiommc_attr_CS) {
263 + gpio = dev->pdata.pins.gpio_cs;
264 + if (gpio == GPIO_INVALID)
265 + count = snprintf(page, PAGE_SIZE, "not configured\n");
267 + count = snprintf(page, PAGE_SIZE, "%u\n", gpio);
270 + if (attr == &gpiommc_attr_CS_activelow) {
271 + count = snprintf(page, PAGE_SIZE, "%u\n",
272 + dev->pdata.pins.cs_activelow);
275 + if (attr == &gpiommc_attr_spimode) {
276 + count = snprintf(page, PAGE_SIZE, "%u\n",
280 + if (attr == &gpiommc_attr_spidelay) {
281 + count = snprintf(page, PAGE_SIZE, "%u\n",
282 + !dev->pdata.no_spi_delay);
285 + if (attr == &gpiommc_attr_max_bus_speed) {
286 + count = snprintf(page, PAGE_SIZE, "%u\n",
287 + dev->pdata.max_bus_speed);
290 + if (attr == &gpiommc_attr_register) {
291 + count = snprintf(page, PAGE_SIZE, "%u\n",
292 + gpiommc_is_registered(dev));
298 + return err ? err : count;
301 +static int gpiommc_do_register(struct gpiommc_configfs_device *dev,
306 + if (gpiommc_is_registered(dev))
309 + if (!gpio_is_valid(dev->pdata.pins.gpio_di) ||
310 + !gpio_is_valid(dev->pdata.pins.gpio_do) ||
311 + !gpio_is_valid(dev->pdata.pins.gpio_clk) ||
312 + !gpio_is_valid(dev->pdata.pins.gpio_cs)) {
313 + printk(KERN_ERR PFX
314 + "configfs: Invalid GPIO pin number(s)\n");
318 + strlcpy(dev->pdata.name, name,
319 + sizeof(dev->pdata.name));
321 + dev->pdev = platform_device_alloc(GPIOMMC_PLATDEV_NAME,
322 + gpiommc_next_id());
325 + err = platform_device_add_data(dev->pdev, &dev->pdata,
326 + sizeof(dev->pdata));
328 + platform_device_put(dev->pdev);
331 + err = platform_device_add(dev->pdev);
333 + platform_device_put(dev->pdev);
340 +static void gpiommc_do_unregister(struct gpiommc_configfs_device *dev)
342 + if (!gpiommc_is_registered(dev))
345 + platform_device_unregister(dev->pdev);
349 +static ssize_t gpiommc_config_attr_store(struct config_item *item,
350 + struct configfs_attribute *attr,
351 + const char *page, size_t count)
353 + struct gpiommc_configfs_device *dev = ci_to_gpiommc(item);
355 + unsigned long data;
357 + if (attr == &gpiommc_attr_register) {
358 + err = strict_strtoul(page, 10, &data);
363 + err = gpiommc_do_register(dev, item->ci_name);
365 + gpiommc_do_unregister(dev);
371 + if (gpiommc_is_registered(dev)) {
372 + /* The rest of the config parameters can only be set
373 + * as long as the device is not registered, yet. */
378 + if (attr == &gpiommc_attr_DI) {
379 + err = strict_strtoul(page, 10, &data);
383 + if (!gpio_is_valid(data))
385 + dev->pdata.pins.gpio_di = data;
389 + if (attr == &gpiommc_attr_DO) {
390 + err = strict_strtoul(page, 10, &data);
394 + if (!gpio_is_valid(data))
396 + dev->pdata.pins.gpio_do = data;
400 + if (attr == &gpiommc_attr_CLK) {
401 + err = strict_strtoul(page, 10, &data);
405 + if (!gpio_is_valid(data))
407 + dev->pdata.pins.gpio_clk = data;
411 + if (attr == &gpiommc_attr_CS) {
412 + err = strict_strtoul(page, 10, &data);
416 + if (!gpio_is_valid(data))
418 + dev->pdata.pins.gpio_cs = data;
422 + if (attr == &gpiommc_attr_CS_activelow) {
423 + err = strict_strtoul(page, 10, &data);
427 + if (data != 0 && data != 1)
429 + dev->pdata.pins.cs_activelow = data;
433 + if (attr == &gpiommc_attr_spimode) {
434 + err = strict_strtoul(page, 10, &data);
440 + dev->pdata.mode = SPI_MODE_0;
443 + dev->pdata.mode = SPI_MODE_1;
446 + dev->pdata.mode = SPI_MODE_2;
449 + dev->pdata.mode = SPI_MODE_3;
457 + if (attr == &gpiommc_attr_spidelay) {
458 + err = strict_strtoul(page, 10, &data);
462 + if (data != 0 && data != 1)
464 + dev->pdata.no_spi_delay = !data;
468 + if (attr == &gpiommc_attr_max_bus_speed) {
469 + err = strict_strtoul(page, 10, &data);
473 + if (data > UINT_MAX)
475 + dev->pdata.max_bus_speed = data;
482 + return err ? err : count;
485 +static void gpiommc_config_item_release(struct config_item *item)
487 + struct gpiommc_configfs_device *dev = ci_to_gpiommc(item);
492 +static struct configfs_item_operations gpiommc_config_item_ops = {
493 + .release = gpiommc_config_item_release,
494 + .show_attribute = gpiommc_config_attr_show,
495 + .store_attribute = gpiommc_config_attr_store,
498 +static struct config_item_type gpiommc_dev_ci_type = {
499 + .ct_item_ops = &gpiommc_config_item_ops,
500 + .ct_attrs = gpiommc_config_attrs,
501 + .ct_owner = THIS_MODULE,
504 +static struct config_item *gpiommc_make_item(struct config_group *group,
507 + struct gpiommc_configfs_device *dev;
509 + if (strlen(name) > GPIOMMC_MAX_NAMELEN) {
510 + printk(KERN_ERR PFX "configfs: device name too long\n");
514 + dev = kzalloc(sizeof(*dev), GFP_KERNEL);
518 + config_item_init_type_name(&dev->item, name,
519 + &gpiommc_dev_ci_type);
521 + /* Assign default configuration */
522 + dev->pdata.pins.gpio_di = GPIO_INVALID;
523 + dev->pdata.pins.gpio_do = GPIO_INVALID;
524 + dev->pdata.pins.gpio_clk = GPIO_INVALID;
525 + dev->pdata.pins.gpio_cs = GPIO_INVALID;
526 + dev->pdata.pins.cs_activelow = 1;
527 + dev->pdata.mode = SPI_MODE_0;
528 + dev->pdata.no_spi_delay = 0;
529 + dev->pdata.max_bus_speed = 5000000; /* 5 MHz */
531 + return &(dev->item);
534 +static void gpiommc_drop_item(struct config_group *group,
535 + struct config_item *item)
537 + struct gpiommc_configfs_device *dev = ci_to_gpiommc(item);
539 + gpiommc_do_unregister(dev);
543 +static struct configfs_group_operations gpiommc_ct_group_ops = {
544 + .make_item = gpiommc_make_item,
545 + .drop_item = gpiommc_drop_item,
548 +static struct config_item_type gpiommc_ci_type = {
549 + .ct_group_ops = &gpiommc_ct_group_ops,
550 + .ct_owner = THIS_MODULE,
553 +static struct configfs_subsystem gpiommc_subsys = {
556 + .ci_namebuf = GPIOMMC_PLATDEV_NAME,
557 + .ci_type = &gpiommc_ci_type,
560 + .su_mutex = __MUTEX_INITIALIZER(gpiommc_subsys.su_mutex),
563 +#endif /* CONFIG_GPIOMMC_CONFIGFS */
565 +static struct platform_driver gpiommc_plat_driver = {
566 + .probe = gpiommc_probe,
567 + .remove = gpiommc_remove,
569 + .name = GPIOMMC_PLATDEV_NAME,
570 + .owner = THIS_MODULE,
574 +int gpiommc_next_id(void)
576 + static atomic_t counter = ATOMIC_INIT(-1);
578 + return atomic_inc_return(&counter);
580 +EXPORT_SYMBOL(gpiommc_next_id);
582 +static int __init gpiommc_modinit(void)
586 + err = platform_driver_register(&gpiommc_plat_driver);
590 +#ifdef CONFIG_GPIOMMC_CONFIGFS
591 + config_group_init(&gpiommc_subsys.su_group);
592 + err = configfs_register_subsystem(&gpiommc_subsys);
594 + platform_driver_unregister(&gpiommc_plat_driver);
597 +#endif /* CONFIG_GPIOMMC_CONFIGFS */
601 +module_init(gpiommc_modinit);
603 +static void __exit gpiommc_modexit(void)
605 +#ifdef CONFIG_GPIOMMC_CONFIGFS
606 + configfs_unregister_subsystem(&gpiommc_subsys);
608 + platform_driver_unregister(&gpiommc_plat_driver);
610 +module_exit(gpiommc_modexit);
611 Index: linux-2.6.25.17/drivers/mmc/host/Kconfig
612 ===================================================================
613 --- linux-2.6.25.17.orig/drivers/mmc/host/Kconfig 2008-10-18 23:30:41.000000000 +0200
614 +++ linux-2.6.25.17/drivers/mmc/host/Kconfig 2008-10-18 23:32:54.000000000 +0200
615 @@ -130,3 +130,27 @@ config MMC_SPI
617 If unsure, or if your system has no SPI master driver, say N.
620 + tristate "MMC/SD over GPIO-based SPI"
621 + depends on MMC && MMC_SPI && SPI_GPIO
623 + This driver hooks up the mmc_spi and spi_gpio modules so that
624 + MMC/SD cards can be used on a GPIO based bus by bitbanging
625 + the SPI protocol in software.
627 + This driver provides a configfs interface to dynamically create
628 + and destroy GPIO-based MMC/SD card devices. It also provides
629 + a platform device interface API.
630 + See Documentation/gpiommc.txt for details.
632 + The module will be called gpiommc.
636 +config GPIOMMC_CONFIGFS
638 + depends on GPIOMMC && CONFIGFS_FS
641 + This option automatically enables configfs support for gpiommc
642 + if configfs is available.
643 Index: linux-2.6.25.17/drivers/mmc/host/Makefile
644 ===================================================================
645 --- linux-2.6.25.17.orig/drivers/mmc/host/Makefile 2008-10-18 23:30:41.000000000 +0200
646 +++ linux-2.6.25.17/drivers/mmc/host/Makefile 2008-10-18 23:32:54.000000000 +0200
647 @@ -17,4 +17,4 @@ obj-$(CONFIG_MMC_OMAP) += omap.o
648 obj-$(CONFIG_MMC_AT91) += at91_mci.o
649 obj-$(CONFIG_MMC_TIFM_SD) += tifm_sd.o
650 obj-$(CONFIG_MMC_SPI) += mmc_spi.o
652 +obj-$(CONFIG_GPIOMMC) += gpiommc.o
653 Index: linux-2.6.25.17/include/linux/mmc/gpiommc.h
654 ===================================================================
655 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
656 +++ linux-2.6.25.17/include/linux/mmc/gpiommc.h 2008-10-18 23:34:21.000000000 +0200
659 + * Device driver for MMC/SD cards driven over a GPIO bus.
661 + * Licensed under the GNU/GPL version 2.
663 +#ifndef LINUX_GPIOMMC_H_
664 +#define LINUX_GPIOMMC_H_
666 +#include <linux/types.h>
669 +#define GPIOMMC_MAX_NAMELEN 15
670 +#define GPIOMMC_MAX_NAMELEN_STR __stringify(GPIOMMC_MAX_NAMELEN)
673 + * struct gpiommc_pins - Hardware pin assignments
675 + * @gpio_di: The GPIO number of the DATA IN pin
676 + * @gpio_do: The GPIO number of the DATA OUT pin
677 + * @gpio_clk: The GPIO number of the CLOCK pin
678 + * @gpio_cs: The GPIO number of the CHIPSELECT pin
679 + * @cs_activelow: If true, the chip is considered selected if @gpio_cs is low.
681 +struct gpiommc_pins {
682 + unsigned int gpio_di;
683 + unsigned int gpio_do;
684 + unsigned int gpio_clk;
685 + unsigned int gpio_cs;
690 + * struct gpiommc_platform_data - Platform data for a MMC-over-SPI-GPIO device.
692 + * @name: The unique name string of the device.
693 + * @pins: The hardware pin assignments.
694 + * @mode: The hardware mode. This is either SPI_MODE_0,
695 + * SPI_MODE_1, SPI_MODE_2 or SPI_MODE_3. See the SPI documentation.
696 + * @no_spi_delay: Do not use delays in the lowlevel SPI bitbanging code.
697 + * This is not standards compliant, but may be required for some
698 + * embedded machines to gain reasonable speed.
699 + * @max_bus_speed: The maximum speed of the SPI bus, in Hertz.
701 +struct gpiommc_platform_data {
702 + char name[GPIOMMC_MAX_NAMELEN + 1];
703 + struct gpiommc_pins pins;
706 + unsigned int max_bus_speed;
710 + * GPIOMMC_PLATDEV_NAME - The platform device name string.
712 + * The name string that has to be used for platform_device_alloc
713 + * when allocating a gpiommc device.
715 +#define GPIOMMC_PLATDEV_NAME "gpiommc"
718 + * gpiommc_next_id - Get another platform device ID number.
720 + * This returns the next platform device ID number that has to be used
721 + * for platform_device_alloc. The ID is opaque and should not be used for
724 +int gpiommc_next_id(void);
726 +#endif /* LINUX_GPIOMMC_H_ */
727 Index: linux-2.6.25.17/Documentation/gpiommc.txt
728 ===================================================================
729 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
730 +++ linux-2.6.25.17/Documentation/gpiommc.txt 2008-10-18 23:32:54.000000000 +0200
732 +GPIOMMC - Driver for an MMC/SD card on a bitbanging GPIO SPI bus
733 +================================================================
735 +The gpiommc module hooks up the mmc_spi and spi_gpio modules for running an
736 +MMC or SD card on GPIO pins.
738 +Two interfaces for registering a new MMC/SD card device are provided:
739 +A static platform-device based mechanism and a dynamic configfs based interface.
742 +Registering devices via platform-device
743 +=======================================
745 +The platform-device interface is used for registering MMC/SD devices that are
746 +part of the hardware platform. This is most useful only for embedded machines
747 +with MMC/SD devices statically connected to the platform GPIO bus.
749 +The data structures are declared in <linux/mmc/gpiommc.h>.
751 +To register a new device, define an instance of struct gpiommc_platform_data.
752 +This structure holds any information about how the device is hooked up to the
753 +GPIO pins and what hardware modes the device supports. See the docbook-style
754 +documentation in the header file for more information on the struct fields.
756 +Then allocate a new instance of a platform device by doing:
758 + pdev = platform_device_alloc(GPIOMMC_PLATDEV_NAME, gpiommc_next_id());
760 +This will allocate the platform device data structures and hook it up to the
762 +Then add the gpiommc_platform_data to the platform device.
764 + err = platform_device_add_data(pdev, pdata, sizeof(struct gpiommc_platform_data));
766 +You may free the local instance of struct gpiommc_platform_data now. (So the
767 +struct may be allocated on the stack, too).
768 +Now simply register the platform device.
770 + err = platform_device_add(pdev);
772 +Done. The gpiommc probe routine will be invoked now and you should see a kernel
773 +log message for the added device.
776 +Registering devices via configfs
777 +================================
779 +MMC/SD cards connected via GPIO often are a pretty dynamic thing, as for example
780 +selfmade hacks for soldering an MMC/SD card to standard GPIO pins on embedded
781 +hardware are a common situation.
782 +So we provide a dynamic interface to conveniently handle adding and removing
783 +devices from userspace, without the need to recompile the kernel.
785 +The "gpiommc" subdirectory at the configfs mountpoint is used for handling
786 +the dynamic configuration.
788 +To create a new device, it must first be allocated with mkdir.
789 +The following command will allocate a device named "my_mmc":
790 + mkdir /config/gpiommc/my_mmc
792 +There are several configuration files available in the new
793 +/config/gpiommc/my_mmc/ directory:
795 +gpio_data_in = The SPI data-IN GPIO pin number.
796 +gpio_data_out = The SPI data-OUT GPIO pin number.
797 +gpio_clock = The SPI Clock GPIO pin number.
798 +gpio_chipselect = The SPI Chipselect GPIO pin number.
799 +gpio_chipselect_activelow = Boolean. If 0, Chipselect is active-HIGH.
800 + If 1, Chipselect is active-LOW.
801 +spi_mode = The SPI data mode. Can be 0-3.
802 +spi_delay = Enable all delays in the lowlevel bitbanging.
803 +max_bus_speed = The maximum SPI bus speed. In Hertz.
805 +register = Not a configuration parameter.
806 + Used to register the configured card
809 +The device must first get configured and then registered by writing "1" to
810 +the "register" file.
811 +The configuration parameters "gpio_data_in", "gpio_data_out", "gpio_clock"
812 +and "gpio_chipselect" are essential and _must_ be configured before writing
813 +"1" to the "register" file. The registration will fail, otherwise.
815 +The default values for the other parameters are:
816 +gpio_chipselect_activelow = 1 (CS active-LOW)
817 +spi_mode = 0 (SPI_MODE_0)
818 +spi_delay = 1 (enabled)
819 +max_bus_speed = 5000000 (5 Mhz)
821 +Configuration values can not be changed after registration. To unregister
822 +the device, write a "0" to the "register" file. The configuration can be
823 +changed again after unregistering.
825 +To completely remove the device, simply rmdir the directory
826 +(/config/gpiommc/my_mmc in this example).
827 +There's no need to first unregister the device before removing it. That will
828 +be done automatically.