blob: c75d12b1ddab79aef416cfb537f6ab02cc2dc386 [file] [log] [blame]
Duy Truong790f06d2013-02-13 16:38:12 -08001/* Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 */
13
14/*
15 * SDIO-Abstraction-Layer API.
16 */
17
18#ifndef __SDIO_AL__
19#define __SDIO_AL__
20
21#include <linux/mmc/card.h>
22
23struct sdio_channel; /* Forward Declaration */
24
Manu Gautamb19046a2011-09-02 15:56:38 +053025
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070026/**
27 * Channel Events.
28 * Available bytes notification.
29 */
30#define SDIO_EVENT_DATA_READ_AVAIL 0x01
31#define SDIO_EVENT_DATA_WRITE_AVAIL 0x02
32
Manu Gautamb19046a2011-09-02 15:56:38 +053033#ifdef CONFIG_MSM_SDIO_AL
34
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070035struct sdio_al_platform_data {
36 int (*config_mdm2ap_status)(int);
37 int (*get_mdm2ap_status)(void);
38 int allow_sdioc_version_major_2;
39 int peer_sdioc_version_minor;
40 int peer_sdioc_version_major;
41 int peer_sdioc_boot_version_minor;
42 int peer_sdioc_boot_version_major;
43};
44
45/**
46 * sdio_open - open a channel for read/write data.
47 *
48 * @name: channel name - identify the channel to open.
49 * @ch: channel handle returned.
50 * @priv: caller private context pointer, passed to the notify callback.
51 * @notify: notification callback for data available.
52 * @channel_event: SDIO_EVENT_DATA_READ_AVAIL or SDIO_EVENT_DATA_WRITE_AVAIL
53 * @return 0 on success, negative value on error.
54 *
55 * Warning: notify() may be called before open returns.
56 */
57int sdio_open(const char *name, struct sdio_channel **ch, void *priv,
58 void (*notify)(void *priv, unsigned channel_event));
59
60
61/**
62 * sdio_close - close a channel.
63 *
64 * @ch: channel handle.
65 * @return 0 on success, negative value on error.
66 */
67int sdio_close(struct sdio_channel *ch);
68
69/**
70 * sdio_read - synchronous read.
71 *
72 * @ch: channel handle.
73 * @data: caller buffer pointer. should be non-cacheable.
74 * @len: byte count.
75 * @return 0 on success, negative value on error.
76 *
77 * May wait if no available bytes.
78 * May wait if other channel with higher priority has pending
79 * transfers.
80 * Client should check available bytes prior to calling this
81 * api.
82 */
83int sdio_read(struct sdio_channel *ch, void *data, int len);
84
85/**
86 * sdio_write - synchronous write.
87 *
88 * @ch: channel handle.
89 * @data: caller buffer pointer. should be non-cacheable.
90 * @len: byte count.
91 * @return 0 on success, negative value on error.
92 *
93 * May wait if no available bytes.
94 * May wait if other channel with higher priority has pending
95 * transfers.
96 * Client should check available bytes prior to calling this
97 * api.
98 */
99int sdio_write(struct sdio_channel *ch, const void *data, int len);
100
101/**
102 * sdio_write_avail - get available bytes to write.
103 *
104 * @ch: channel handle.
105 * @return byte count on success, negative value on error.
106 */
107int sdio_write_avail(struct sdio_channel *ch);
108
109/**
110 * sdio_read_avail - get available bytes to read.
111 *
112 * @ch: channel handle.
113 * @return byte count on success, negative value on error.
114 */
115int sdio_read_avail(struct sdio_channel *ch);
116
Manu Gautamb19046a2011-09-02 15:56:38 +0530117#else
118
119static int __maybe_unused sdio_open(const char *name, struct sdio_channel **ch,
120 void *priv, void (*notify)(void *priv, unsigned channel_event))
121{
122 return -ENODEV;
123}
124
125static int __maybe_unused sdio_close(struct sdio_channel *ch)
126{
127 return -ENODEV;
128}
129
130static int __maybe_unused sdio_read(struct sdio_channel *ch, void *data,
131 int len)
132{
133 return -ENODEV;
134}
135
136static int __maybe_unused sdio_write(struct sdio_channel *ch, const void *data,
137 int len)
138{
139 return -ENODEV;
140}
141
142static int __maybe_unused sdio_write_avail(struct sdio_channel *ch)
143{
144 return -ENODEV;
145}
146
147static int __maybe_unused sdio_read_avail(struct sdio_channel *ch)
148{
149 return -ENODEV;
150}
151#endif
152
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700153#endif /* __SDIO_AL__ */