4 * Copyright 2008-2013 Freescale Semiconductor, Inc.
5 * Copyright 2008-2009 Embedded Alley Solutions, Inc All Rights Reserved.
9 * The code contained herein is licensed under the GNU General Public
10 * License. You may obtain a copy of the GNU General Public License
11 * Version 2 or later at the following locations:
13 * http://www.opensource.org/licenses/gpl-license.html
14 * http://www.gnu.org/copyleft/gpl.html
17 #ifndef __FSL_UPDATER_H
18 #define __FSL_UPDATER_H
20 #include <linux/miscdevice.h>
21 #include <linux/list.h>
22 #include <linux/vmalloc.h>
23 #include <linux/ioctl.h>
24 /* #include <mach/hardware.h> */
26 static int utp_init(struct fsg_dev *fsg);
27 static void utp_exit(struct fsg_dev *fsg);
28 static ssize_t utp_file_read(struct file *file,
33 static ssize_t utp_file_write(struct file *file,
34 const char __user *buf,
38 static long utp_ioctl(struct file *file,
39 unsigned int cmd, unsigned long arg);
40 static struct utp_user_data *utp_user_data_alloc(size_t size);
41 static void utp_user_data_free(struct utp_user_data *uud);
42 static int utp_get_sense(struct fsg_dev *fsg);
43 static int utp_do_read(struct fsg_dev *fsg, void *data, size_t size);
44 static int utp_do_write(struct fsg_dev *fsg, void *data, size_t size);
45 static inline void utp_set_sense(struct fsg_dev *fsg, u16 code, u64 reply);
46 static int utp_handle_message(struct fsg_dev *fsg,
50 #define UTP_REPLY_PASS 0
51 #define UTP_REPLY_EXIT 0x8001
52 #define UTP_REPLY_BUSY 0x8002
53 #define UTP_REPLY_SIZE 0x8003
54 #define UTP_SENSE_KEY 9
57 /* MISC_DYNAMIC_MINOR would be better, but... */
59 #define UTP_COMMAND_SIZE 80
61 #define UTP_SS_EXIT(fsg, r) utp_set_sense(fsg, UTP_REPLY_EXIT, (u64)r)
62 #define UTP_SS_PASS(fsg) utp_set_sense(fsg, UTP_REPLY_PASS, 0)
63 #define UTP_SS_BUSY(fsg, r) utp_set_sense(fsg, UTP_REPLY_BUSY, (u64)r)
64 #define UTP_SS_SIZE(fsg, r) utp_set_sense(fsg, UTP_REPLY_SIZE, (u64)r)
66 #define UTP_IOCTL_BASE 'U'
67 #define UTP_GET_CPU_ID _IOR(UTP_IOCTL_BASE, 0, int)
68 /* the structure of utp message which is mapped to 16-byte SCSI CBW's CDB */
90 static struct utp_context {
92 wait_queue_head_t list_full_wq;
94 struct list_head read;
95 struct list_head write;
96 u32 sd, sdinfo, sdinfo_h; /* sense data */
103 static const struct file_operations utp_fops = {
104 .open = nonseekable_open,
105 .read = utp_file_read,
106 .write = utp_file_write,
107 /* .ioctl = utp_ioctl, */
108 .unlocked_ioctl = utp_ioctl,
111 static struct miscdevice utp_dev = {
117 #define UTP_FLAG_COMMAND 0x00000001
118 #define UTP_FLAG_DATA 0x00000002
119 #define UTP_FLAG_STATUS 0x00000004
120 #define UTP_FLAG_REPORT_BUSY 0x10000000
137 struct utp_user_data {
138 struct list_head link;
139 struct utp_message data;
143 static inline struct utp_context *UTP_CTX(struct fsg_dev *fsg)
145 return (struct utp_context *)fsg->utp;
148 #endif /* __FSL_UPDATER_H */