blob: 9a0348c62478dc4e188a9e9ef54e510934390824 [file] [log] [blame]
Greg Kroah-Hartman83ddaaa2014-08-11 17:27:22 +08001/*
2 * SD/MMC Greybus driver.
3 *
4 * Copyright 2014 Google Inc.
Alex Eldera46e9672014-12-12 12:08:42 -06005 * Copyright 2014 Linaro Ltd.
Greg Kroah-Hartman83ddaaa2014-08-11 17:27:22 +08006 *
7 * Released under the GPLv2 only.
8 */
9
10#include <linux/kernel.h>
Greg Kroah-Hartman83ddaaa2014-08-11 17:27:22 +080011#include <linux/slab.h>
12#include <linux/mmc/host.h>
Alex Eldere1e9dbd2014-10-01 21:54:11 -050013
Greg Kroah-Hartman83ddaaa2014-08-11 17:27:22 +080014#include "greybus.h"
15
Greg Kroah-Hartman199d68d2014-08-30 16:20:22 -070016struct gb_sdio_host {
Greg Kroah-Hartmana2f47632014-10-28 10:17:09 +080017 struct gb_connection *connection;
Greg Kroah-Hartman83ddaaa2014-08-11 17:27:22 +080018 struct mmc_host *mmc;
19 struct mmc_request *mrq;
20 // FIXME - some lock?
21};
22
Greg Kroah-Hartman83ddaaa2014-08-11 17:27:22 +080023static void gb_sd_request(struct mmc_host *mmc, struct mmc_request *mrq)
24{
25 // FIXME - do something here...
26}
27
28static void gb_sd_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
29{
30 // FIXME - do something here...
31}
32
33static int gb_sd_get_ro(struct mmc_host *mmc)
34{
35 // FIXME - do something here...
36 return 0;
37}
38
39static const struct mmc_host_ops gb_sd_ops = {
40 .request = gb_sd_request,
41 .set_ios = gb_sd_set_ios,
42 .get_ro = gb_sd_get_ro,
43};
44
Greg Kroah-Hartmana2f47632014-10-28 10:17:09 +080045static int gb_sdio_connection_init(struct gb_connection *connection)
Greg Kroah-Hartman83ddaaa2014-08-11 17:27:22 +080046{
47 struct mmc_host *mmc;
Greg Kroah-Hartman199d68d2014-08-30 16:20:22 -070048 struct gb_sdio_host *host;
Greg Kroah-Hartman83ddaaa2014-08-11 17:27:22 +080049
Viresh Kumar64e69292014-11-19 17:24:58 +053050 mmc = mmc_alloc_host(sizeof(*host), &connection->dev);
Greg Kroah-Hartman83ddaaa2014-08-11 17:27:22 +080051 if (!mmc)
52 return -ENOMEM;
53
54 host = mmc_priv(mmc);
55 host->mmc = mmc;
56
57 mmc->ops = &gb_sd_ops;
58 // FIXME - set up size limits we can handle.
Greg Kroah-Hartmana2f47632014-10-28 10:17:09 +080059 // FIXME - register the host controller.
Greg Kroah-Hartman83ddaaa2014-08-11 17:27:22 +080060
Greg Kroah-Hartmana2f47632014-10-28 10:17:09 +080061 host->connection = connection;
62 connection->private = host;
Greg Kroah-Hartman83ddaaa2014-08-11 17:27:22 +080063 return 0;
64}
65
Greg Kroah-Hartmana2f47632014-10-28 10:17:09 +080066static void gb_sdio_connection_exit(struct gb_connection *connection)
Greg Kroah-Hartman83ddaaa2014-08-11 17:27:22 +080067{
68 struct mmc_host *mmc;
Greg Kroah-Hartman199d68d2014-08-30 16:20:22 -070069 struct gb_sdio_host *host;
Greg Kroah-Hartman83ddaaa2014-08-11 17:27:22 +080070
Greg Kroah-Hartmana2f47632014-10-28 10:17:09 +080071 host = connection->private;
Alex Elder051fb042014-10-16 06:35:24 -050072 if (!host)
73 return;
Greg Kroah-Hartman83ddaaa2014-08-11 17:27:22 +080074
Alex Elder051fb042014-10-16 06:35:24 -050075 mmc = host->mmc;
Greg Kroah-Hartman83ddaaa2014-08-11 17:27:22 +080076 mmc_remove_host(mmc);
77 mmc_free_host(mmc);
Greg Kroah-Hartmana2f47632014-10-28 10:17:09 +080078 connection->private = NULL;
Greg Kroah-Hartman83ddaaa2014-08-11 17:27:22 +080079}
80
Alex Elder19d03de2014-11-05 16:12:53 -060081static struct gb_protocol sdio_protocol = {
Greg Kroah-Hartman7422a1e2014-12-24 13:01:45 -080082 .name = "sdio",
Alex Elder19d03de2014-11-05 16:12:53 -060083 .id = GREYBUS_PROTOCOL_SDIO,
84 .major = 0,
85 .minor = 1,
Alex Elder5d9fd7e2014-11-05 16:12:54 -060086 .connection_init = gb_sdio_connection_init,
87 .connection_exit = gb_sdio_connection_exit,
Alex Elderf8fb05e2014-11-05 16:12:55 -060088 .request_recv = NULL, /* no incoming requests */
Alex Elder19d03de2014-11-05 16:12:53 -060089};
90
Viresh Kumarbdac5992015-05-20 17:20:10 +053091gb_gpbridge_protocol_driver(sdio_protocol);