blob: 3cf258aedc11bedd2bffa0d18f078290e8663ac4 [file] [log] [blame]
Greg Kroah-Hartman83ddaaa2014-08-11 17:27:22 +08001/*
2 * SD/MMC Greybus driver.
3 *
4 * Copyright 2014 Google Inc.
5 *
6 * Released under the GPLv2 only.
7 */
8
9#include <linux/kernel.h>
10#include <linux/module.h>
11#include <linux/slab.h>
12#include <linux/mmc/host.h>
13#include "greybus.h"
14
Greg Kroah-Hartman199d68d2014-08-30 16:20:22 -070015struct gb_sdio_host {
Greg Kroah-Hartman83ddaaa2014-08-11 17:27:22 +080016 struct mmc_host *mmc;
17 struct mmc_request *mrq;
18 // FIXME - some lock?
19};
20
Greg Kroah-Hartman6584c8a2014-09-01 13:31:31 -070021static const struct greybus_module_id id_table[] = {
Greg Kroah-Hartman83ddaaa2014-08-11 17:27:22 +080022 { GREYBUS_DEVICE(0x43, 0x43) }, /* make shit up */
23 { }, /* terminating NULL entry */
24};
25
26static void gb_sd_request(struct mmc_host *mmc, struct mmc_request *mrq)
27{
28 // FIXME - do something here...
29}
30
31static void gb_sd_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
32{
33 // FIXME - do something here...
34}
35
36static int gb_sd_get_ro(struct mmc_host *mmc)
37{
38 // FIXME - do something here...
39 return 0;
40}
41
42static const struct mmc_host_ops gb_sd_ops = {
43 .request = gb_sd_request,
44 .set_ios = gb_sd_set_ios,
45 .get_ro = gb_sd_get_ro,
46};
47
Alex Elder778c69c2014-09-22 19:19:03 -050048int gb_sdio_probe(struct greybus_module *gmod,
Greg Kroah-Hartman6584c8a2014-09-01 13:31:31 -070049 const struct greybus_module_id *id)
Greg Kroah-Hartman83ddaaa2014-08-11 17:27:22 +080050{
51 struct mmc_host *mmc;
Greg Kroah-Hartman199d68d2014-08-30 16:20:22 -070052 struct gb_sdio_host *host;
Greg Kroah-Hartman83ddaaa2014-08-11 17:27:22 +080053
Alex Elder778c69c2014-09-22 19:19:03 -050054 mmc = mmc_alloc_host(sizeof(struct gb_sdio_host), &gmod->dev);
Greg Kroah-Hartman83ddaaa2014-08-11 17:27:22 +080055 if (!mmc)
56 return -ENOMEM;
57
58 host = mmc_priv(mmc);
59 host->mmc = mmc;
60
61 mmc->ops = &gb_sd_ops;
62 // FIXME - set up size limits we can handle.
63
Alex Elder778c69c2014-09-22 19:19:03 -050064 gmod->gb_sdio_host = host;
Greg Kroah-Hartman83ddaaa2014-08-11 17:27:22 +080065 return 0;
66}
67
Alex Elder778c69c2014-09-22 19:19:03 -050068void gb_sdio_disconnect(struct greybus_module *gmod)
Greg Kroah-Hartman83ddaaa2014-08-11 17:27:22 +080069{
70 struct mmc_host *mmc;
Greg Kroah-Hartman199d68d2014-08-30 16:20:22 -070071 struct gb_sdio_host *host;
Greg Kroah-Hartman83ddaaa2014-08-11 17:27:22 +080072
Alex Elder778c69c2014-09-22 19:19:03 -050073 host = gmod->gb_sdio_host;
Greg Kroah-Hartman83ddaaa2014-08-11 17:27:22 +080074 mmc = host->mmc;
75
76 mmc_remove_host(mmc);
77 mmc_free_host(mmc);
78}
79
Greg Kroah-Hartmandb6e1fd2014-08-30 16:47:26 -070080#if 0
Greg Kroah-Hartman83ddaaa2014-08-11 17:27:22 +080081static struct greybus_driver sd_gb_driver = {
Greg Kroah-Hartmandb6e1fd2014-08-30 16:47:26 -070082 .probe = gb_sdio_probe,
83 .disconnect = gb_sdio_disconnect,
Greg Kroah-Hartman83ddaaa2014-08-11 17:27:22 +080084 .id_table = id_table,
85};
86
87module_greybus_driver(sd_gb_driver);
88MODULE_LICENSE("GPL");
89MODULE_DESCRIPTION("Greybus SD/MMC Host driver");
90MODULE_AUTHOR("Greg Kroah-Hartman <gregkh@linuxfoundation.org>");
Greg Kroah-Hartmandb6e1fd2014-08-30 16:47:26 -070091#endif