]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
greybus: Greybus SD/MMC host driver
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 11 Aug 2014 09:27:22 +0000 (17:27 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 11 Aug 2014 09:27:22 +0000 (17:27 +0800)
Need to add specifics, but this should be enough to hook up to the mmc
framework.

drivers/staging/greybus/Makefile
drivers/staging/greybus/sdio-gb.c [new file with mode: 0644]

index 432ad4c72863e908fad0066a32370fec9d83695e..753436d94f1fd396d4c85813a2272efa8a2bca04 100644 (file)
@@ -2,6 +2,7 @@ greybus-y := core.o
 
 obj-m += greybus.o
 obj-m += i2c-gb.o
+obj-m += sdio-gb.o
 
 KERNELVER              ?= $(shell uname -r)
 KERNELDIR              ?= /lib/modules/$(KERNELVER)/build
diff --git a/drivers/staging/greybus/sdio-gb.c b/drivers/staging/greybus/sdio-gb.c
new file mode 100644 (file)
index 0000000..f92ab1b
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * SD/MMC Greybus driver.
+ *
+ * Copyright 2014 Google Inc.
+ *
+ * Released under the GPLv2 only.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/mmc/host.h>
+#include "greybus.h"
+
+struct sd_gb_host {
+       struct mmc_host *mmc;
+       struct mmc_request *mrq;
+       // FIXME - some lock?
+};
+
+static const struct greybus_device_id id_table[] = {
+       { GREYBUS_DEVICE(0x43, 0x43) }, /* make shit up */
+       { },    /* terminating NULL entry */
+};
+
+static void gb_sd_request(struct mmc_host *mmc, struct mmc_request *mrq)
+{
+       // FIXME - do something here...
+}
+
+static void gb_sd_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
+{
+       // FIXME - do something here...
+}
+
+static int gb_sd_get_ro(struct mmc_host *mmc)
+{
+       // FIXME - do something here...
+       return 0;
+}
+
+static const struct mmc_host_ops gb_sd_ops = {
+       .request        = gb_sd_request,
+       .set_ios        = gb_sd_set_ios,
+       .get_ro         = gb_sd_get_ro,
+};
+
+static int sd_gb_probe(struct greybus_device *gdev, const struct greybus_device_id *id)
+{
+       struct mmc_host *mmc;
+       struct sd_gb_host *host;
+
+       mmc = mmc_alloc_host(sizeof(struct sd_gb_host), &gdev->dev);
+       if (!mmc)
+               return -ENOMEM;
+
+       host = mmc_priv(mmc);
+       host->mmc = mmc;
+
+       mmc->ops = &gb_sd_ops;
+       // FIXME - set up size limits we can handle.
+
+       greybus_set_drvdata(gdev, host);
+       return 0;
+}
+
+static void sd_gb_disconnect(struct greybus_device *gdev)
+{
+       struct mmc_host *mmc;
+       struct sd_gb_host *host;
+
+       host = greybus_get_drvdata(gdev);
+       mmc = host->mmc;
+
+       mmc_remove_host(mmc);
+       mmc_free_host(mmc);
+}
+
+static struct greybus_driver sd_gb_driver = {
+       .probe =        sd_gb_probe,
+       .disconnect =   sd_gb_disconnect,
+       .id_table =     id_table,
+};
+
+module_greybus_driver(sd_gb_driver);
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Greybus SD/MMC Host driver");
+MODULE_AUTHOR("Greg Kroah-Hartman <gregkh@linuxfoundation.org>");