Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[wrt350n-kernel.git] / include / linux / memstick.h
blob1da7970d072801fa67f114a3bc446dc6f6b37afa
1 /*
2 * Sony MemoryStick support
4 * Copyright (C) 2007 Alex Dubov <oakad@yahoo.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
12 #ifndef _MEMSTICK_H
13 #define _MEMSTICK_H
15 #include <linux/workqueue.h>
16 #include <linux/scatterlist.h>
17 #include <linux/device.h>
19 /*** Hardware based structures ***/
21 struct ms_status_register {
22 unsigned char reserved;
23 unsigned char interrupt;
24 #define MEMSTICK_INT_CMDNAK 0x0001
25 <<<<<<< HEAD:include/linux/memstick.h
26 =======
27 #define MEMSTICK_INT_IOREQ 0x0008
28 #define MEMSTICK_INT_IOBREQ 0x0010
29 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:include/linux/memstick.h
30 #define MEMSTICK_INT_BREQ 0x0020
31 #define MEMSTICK_INT_ERR 0x0040
32 #define MEMSTICK_INT_CED 0x0080
34 unsigned char status0;
35 #define MEMSTICK_STATUS0_WP 0x0001
36 #define MEMSTICK_STATUS0_SL 0x0002
37 #define MEMSTICK_STATUS0_BF 0x0010
38 #define MEMSTICK_STATUS0_BE 0x0020
39 #define MEMSTICK_STATUS0_FB0 0x0040
40 #define MEMSTICK_STATUS0_MB 0x0080
42 unsigned char status1;
43 #define MEMSTICK_STATUS1_UCFG 0x0001
44 #define MEMSTICK_STATUS1_FGER 0x0002
45 #define MEMSTICK_STATUS1_UCEX 0x0004
46 #define MEMSTICK_STATUS1_EXER 0x0008
47 #define MEMSTICK_STATUS1_UCDT 0x0010
48 #define MEMSTICK_STATUS1_DTER 0x0020
49 #define MEMSTICK_STATUS1_FBI 0x0040
50 #define MEMSTICK_STATUS1_MB 0x0080
51 } __attribute__((packed));
53 struct ms_id_register {
54 unsigned char type;
55 <<<<<<< HEAD:include/linux/memstick.h
56 unsigned char reserved;
57 =======
58 unsigned char if_mode;
59 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:include/linux/memstick.h
60 unsigned char category;
61 unsigned char class;
62 } __attribute__((packed));
64 struct ms_param_register {
65 unsigned char system;
66 <<<<<<< HEAD:include/linux/memstick.h
67 =======
68 #define MEMSTICK_SYS_ATEN 0xc0
69 #define MEMSTICK_SYS_BAMD 0x80
70 #define MEMSTICK_SYS_PAM 0x08
72 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:include/linux/memstick.h
73 unsigned char block_address_msb;
74 unsigned short block_address;
75 unsigned char cp;
76 #define MEMSTICK_CP_BLOCK 0x0000
77 #define MEMSTICK_CP_PAGE 0x0020
78 #define MEMSTICK_CP_EXTRA 0x0040
79 #define MEMSTICK_CP_OVERWRITE 0x0080
81 unsigned char page_address;
82 } __attribute__((packed));
84 struct ms_extra_data_register {
85 unsigned char overwrite_flag;
86 #define MEMSTICK_OVERWRITE_UPDATA 0x0010
87 #define MEMSTICK_OVERWRITE_PAGE 0x0060
88 #define MEMSTICK_OVERWRITE_BLOCK 0x0080
90 unsigned char management_flag;
91 #define MEMSTICK_MANAGEMENT_SYSTEM 0x0004
92 #define MEMSTICK_MANAGEMENT_TRANS_TABLE 0x0008
93 #define MEMSTICK_MANAGEMENT_COPY 0x0010
94 #define MEMSTICK_MANAGEMENT_ACCESS 0x0020
96 unsigned short logical_address;
97 } __attribute__((packed));
99 struct ms_register {
100 struct ms_status_register status;
101 struct ms_id_register id;
102 unsigned char reserved[8];
103 struct ms_param_register param;
104 struct ms_extra_data_register extra_data;
105 } __attribute__((packed));
107 struct mspro_param_register {
108 unsigned char system;
109 <<<<<<< HEAD:include/linux/memstick.h
110 =======
111 #define MEMSTICK_SYS_SERIAL 0x80
112 #define MEMSTICK_SYS_PAR4 0x00
113 #define MEMSTICK_SYS_PAR8 0x40
115 unsigned short data_count;
116 unsigned int data_address;
117 unsigned char tpc_param;
118 } __attribute__((packed));
120 struct mspro_io_info_register {
121 unsigned char version;
122 unsigned char io_category;
123 unsigned char current_req;
124 unsigned char card_opt_info;
125 unsigned char rdy_wait_time;
126 } __attribute__((packed));
128 struct mspro_io_func_register {
129 unsigned char func_enable;
130 unsigned char func_select;
131 unsigned char func_intmask;
132 unsigned char transfer_mode;
133 } __attribute__((packed));
135 struct mspro_io_cmd_register {
136 unsigned short tpc_param;
137 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:include/linux/memstick.h
138 unsigned short data_count;
139 unsigned int data_address;
140 <<<<<<< HEAD:include/linux/memstick.h
141 unsigned char cmd_param;
142 =======
143 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:include/linux/memstick.h
144 } __attribute__((packed));
146 struct mspro_register {
147 <<<<<<< HEAD:include/linux/memstick.h
148 struct ms_status_register status;
149 struct ms_id_register id;
150 unsigned char reserved[8];
151 struct mspro_param_register param;
152 =======
153 struct ms_status_register status;
154 struct ms_id_register id;
155 unsigned char reserved0[8];
156 struct mspro_param_register param;
157 unsigned char reserved1[8];
158 struct mspro_io_info_register io_info;
159 struct mspro_io_func_register io_func;
160 unsigned char reserved2[7];
161 struct mspro_io_cmd_register io_cmd;
162 unsigned char io_int;
163 unsigned char io_int_func;
164 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:include/linux/memstick.h
165 } __attribute__((packed));
167 struct ms_register_addr {
168 unsigned char r_offset;
169 unsigned char r_length;
170 unsigned char w_offset;
171 unsigned char w_length;
172 } __attribute__((packed));
174 enum {
175 <<<<<<< HEAD:include/linux/memstick.h
176 =======
177 MS_TPC_READ_MG_STATUS = 0x01,
178 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:include/linux/memstick.h
179 MS_TPC_READ_LONG_DATA = 0x02,
180 MS_TPC_READ_SHORT_DATA = 0x03,
181 <<<<<<< HEAD:include/linux/memstick.h
182 =======
183 MS_TPC_READ_MG_DATA = 0x03,
184 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:include/linux/memstick.h
185 MS_TPC_READ_REG = 0x04,
186 <<<<<<< HEAD:include/linux/memstick.h
187 MS_TPC_READ_IO_DATA = 0x05, /* unverified */
188 =======
189 MS_TPC_READ_QUAD_DATA = 0x05,
190 MS_TPC_READ_IO_DATA = 0x05,
191 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:include/linux/memstick.h
192 MS_TPC_GET_INT = 0x07,
193 MS_TPC_SET_RW_REG_ADRS = 0x08,
194 MS_TPC_EX_SET_CMD = 0x09,
195 <<<<<<< HEAD:include/linux/memstick.h
196 MS_TPC_WRITE_IO_DATA = 0x0a, /* unverified */
197 =======
198 MS_TPC_WRITE_QUAD_DATA = 0x0a,
199 MS_TPC_WRITE_IO_DATA = 0x0a,
200 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:include/linux/memstick.h
201 MS_TPC_WRITE_REG = 0x0b,
202 MS_TPC_WRITE_SHORT_DATA = 0x0c,
203 <<<<<<< HEAD:include/linux/memstick.h
204 =======
205 MS_TPC_WRITE_MG_DATA = 0x0c,
206 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:include/linux/memstick.h
207 MS_TPC_WRITE_LONG_DATA = 0x0d,
208 MS_TPC_SET_CMD = 0x0e
211 enum {
212 <<<<<<< HEAD:include/linux/memstick.h
213 MS_CMD_BLOCK_END = 0x33,
214 MS_CMD_RESET = 0x3c,
215 MS_CMD_BLOCK_WRITE = 0x55,
216 MS_CMD_SLEEP = 0x5a,
217 MS_CMD_BLOCK_ERASE = 0x99,
218 MS_CMD_BLOCK_READ = 0xaa,
219 MS_CMD_CLEAR_BUF = 0xc3,
220 MS_CMD_FLASH_STOP = 0xcc,
221 MSPRO_CMD_FORMAT = 0x10,
222 MSPRO_CMD_SLEEP = 0x11,
223 MSPRO_CMD_READ_DATA = 0x20,
224 MSPRO_CMD_WRITE_DATA = 0x21,
225 MSPRO_CMD_READ_ATRB = 0x24,
226 MSPRO_CMD_STOP = 0x25,
227 MSPRO_CMD_ERASE = 0x26,
228 MSPRO_CMD_SET_IBA = 0x46,
229 MSPRO_CMD_SET_IBD = 0x47
231 MSPRO_CMD_RESET
232 MSPRO_CMD_WAKEUP
233 MSPRO_CMD_IN_IO_DATA
234 MSPRO_CMD_OUT_IO_DATA
235 MSPRO_CMD_READ_IO_ATRB
236 MSPRO_CMD_IN_IO_FIFO
237 MSPRO_CMD_OUT_IO_FIFO
238 MSPRO_CMD_IN_IOM
239 MSPRO_CMD_OUT_IOM
241 =======
242 MS_CMD_BLOCK_END = 0x33,
243 MS_CMD_RESET = 0x3c,
244 MS_CMD_BLOCK_WRITE = 0x55,
245 MS_CMD_SLEEP = 0x5a,
246 MS_CMD_BLOCK_ERASE = 0x99,
247 MS_CMD_BLOCK_READ = 0xaa,
248 MS_CMD_CLEAR_BUF = 0xc3,
249 MS_CMD_FLASH_STOP = 0xcc,
250 MS_CMD_LOAD_ID = 0x60,
251 MS_CMD_CMP_ICV = 0x7f,
252 MSPRO_CMD_FORMAT = 0x10,
253 MSPRO_CMD_SLEEP = 0x11,
254 MSPRO_CMD_WAKEUP = 0x12,
255 MSPRO_CMD_READ_DATA = 0x20,
256 MSPRO_CMD_WRITE_DATA = 0x21,
257 MSPRO_CMD_READ_ATRB = 0x24,
258 MSPRO_CMD_STOP = 0x25,
259 MSPRO_CMD_ERASE = 0x26,
260 MSPRO_CMD_READ_QUAD = 0x27,
261 MSPRO_CMD_WRITE_QUAD = 0x28,
262 MSPRO_CMD_SET_IBD = 0x46,
263 MSPRO_CMD_GET_IBD = 0x47,
264 MSPRO_CMD_IN_IO_DATA = 0xb0,
265 MSPRO_CMD_OUT_IO_DATA = 0xb1,
266 MSPRO_CMD_READ_IO_ATRB = 0xb2,
267 MSPRO_CMD_IN_IO_FIFO = 0xb3,
268 MSPRO_CMD_OUT_IO_FIFO = 0xb4,
269 MSPRO_CMD_IN_IOM = 0xb5,
270 MSPRO_CMD_OUT_IOM = 0xb6,
271 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:include/linux/memstick.h
274 /*** Driver structures and functions ***/
276 #define MEMSTICK_PART_SHIFT 3
278 enum memstick_param { MEMSTICK_POWER = 1, MEMSTICK_INTERFACE };
280 #define MEMSTICK_POWER_OFF 0
281 #define MEMSTICK_POWER_ON 1
283 #define MEMSTICK_SERIAL 0
284 <<<<<<< HEAD:include/linux/memstick.h
285 #define MEMSTICK_PARALLEL 1
286 =======
287 #define MEMSTICK_PAR4 1
288 #define MEMSTICK_PAR8 2
289 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:include/linux/memstick.h
291 struct memstick_host;
292 struct memstick_driver;
294 #define MEMSTICK_MATCH_ALL 0x01
296 #define MEMSTICK_TYPE_LEGACY 0xff
297 #define MEMSTICK_TYPE_DUO 0x00
298 #define MEMSTICK_TYPE_PRO 0x01
300 #define MEMSTICK_CATEGORY_STORAGE 0xff
301 #define MEMSTICK_CATEGORY_STORAGE_DUO 0x00
303 #define MEMSTICK_CLASS_GENERIC 0xff
304 #define MEMSTICK_CLASS_GENERIC_DUO 0x00
307 struct memstick_device_id {
308 unsigned char match_flags;
309 unsigned char type;
310 unsigned char category;
311 unsigned char class;
314 struct memstick_request {
315 unsigned char tpc;
316 unsigned char data_dir:1,
317 need_card_int:1,
318 get_int_reg:1,
319 <<<<<<< HEAD:include/linux/memstick.h
320 io_type:2;
321 #define MEMSTICK_IO_NONE 0
322 #define MEMSTICK_IO_VAL 1
323 #define MEMSTICK_IO_SG 2
325 =======
326 long_data:1;
327 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:include/linux/memstick.h
328 unsigned char int_reg;
329 int error;
330 union {
331 struct scatterlist sg;
332 struct {
333 unsigned char data_len;
334 unsigned char data[15];
339 struct memstick_dev {
340 struct memstick_device_id id;
341 struct memstick_host *host;
342 struct ms_register_addr reg_addr;
343 struct completion mrq_complete;
344 struct memstick_request current_mrq;
346 /* Check that media driver is still willing to operate the device. */
347 int (*check)(struct memstick_dev *card);
348 /* Get next request from the media driver. */
349 int (*next_request)(struct memstick_dev *card,
350 struct memstick_request **mrq);
352 struct device dev;
355 struct memstick_host {
356 struct mutex lock;
357 unsigned int id;
358 unsigned int caps;
359 <<<<<<< HEAD:include/linux/memstick.h
360 #define MEMSTICK_CAP_PARALLEL 1
361 #define MEMSTICK_CAP_AUTO_GET_INT 2
362 =======
363 #define MEMSTICK_CAP_AUTO_GET_INT 1
364 #define MEMSTICK_CAP_PAR4 2
365 #define MEMSTICK_CAP_PAR8 4
366 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:include/linux/memstick.h
368 struct work_struct media_checker;
369 struct class_device cdev;
371 struct memstick_dev *card;
372 unsigned int retries;
374 /* Notify the host that some requests are pending. */
375 void (*request)(struct memstick_host *host);
376 /* Set host IO parameters (power, clock, etc). */
377 void (*set_param)(struct memstick_host *host,
378 enum memstick_param param,
379 int value);
380 unsigned long private[0] ____cacheline_aligned;
383 struct memstick_driver {
384 struct memstick_device_id *id_table;
385 int (*probe)(struct memstick_dev *card);
386 void (*remove)(struct memstick_dev *card);
387 int (*suspend)(struct memstick_dev *card,
388 pm_message_t state);
389 int (*resume)(struct memstick_dev *card);
391 struct device_driver driver;
394 int memstick_register_driver(struct memstick_driver *drv);
395 void memstick_unregister_driver(struct memstick_driver *drv);
397 struct memstick_host *memstick_alloc_host(unsigned int extra,
398 struct device *dev);
400 int memstick_add_host(struct memstick_host *host);
401 void memstick_remove_host(struct memstick_host *host);
402 void memstick_free_host(struct memstick_host *host);
403 void memstick_detect_change(struct memstick_host *host);
404 <<<<<<< HEAD:include/linux/memstick.h
405 =======
406 void memstick_suspend_host(struct memstick_host *host);
407 void memstick_resume_host(struct memstick_host *host);
408 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:include/linux/memstick.h
410 void memstick_init_req_sg(struct memstick_request *mrq, unsigned char tpc,
411 struct scatterlist *sg);
412 void memstick_init_req(struct memstick_request *mrq, unsigned char tpc,
413 void *buf, size_t length);
414 int memstick_next_req(struct memstick_host *host,
415 struct memstick_request **mrq);
416 void memstick_new_req(struct memstick_host *host);
418 int memstick_set_rw_addr(struct memstick_dev *card);
420 static inline void *memstick_priv(struct memstick_host *host)
422 return (void *)host->private;
425 static inline void *memstick_get_drvdata(struct memstick_dev *card)
427 return dev_get_drvdata(&card->dev);
430 static inline void memstick_set_drvdata(struct memstick_dev *card, void *data)
432 dev_set_drvdata(&card->dev, data);
435 #endif