tizen 2.4 release
[profile/mobile/platform/kernel/linux-3.10-sc7730.git] / drivers / char / mux_spi_hal / ipc_spi.h
1 /*
2  *  linux/drivers/mmc/host/sdio_hal.h - Secure Digital Host Controller Interface driver
3  *
4  *  Copyright (C) 2005-2008 Pierre Ossman, All Rights Reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or (at
9  * your option) any later version.
10  */
11 #ifndef __IPC_SPI_H
12 #define __IPC_SPI_H
13
14 #include <linux/kfifo.h>
15 #include <linux/miscdevice.h>
16 #include <linux/wakelock.h>
17 #include <mach/modem_interface.h>
18
19
20 //#define SETUP_PACKET_SIZE (128)
21 #define MAX_RECEIVER_SIZE (8*1024)
22
23 //#define SETUP_MAGIC 0x1a2b
24 #define DATA_MAGIC 0x3c4d
25 #define ACK_MAGIC 0x5e6f
26 //#define SETUP_ACK_MAGIC 0x789a
27 #define DATA_ACK_MAGIC 0x9abc
28 #define DUMMY_MAGIC 0x5a5a
29
30 #define CP2AP_NOIRQ 0x0
31 #define CP2AP_FALLING 0x1
32 #define CP2AP_RASING 0x2
33
34 //#define REMOTE_ALIVE_STATUS 0x1
35 //#define REMOTE_ASSERT_STATUS 0x2
36
37 typedef enum {
38         TYPE_ACK = 0x1,
39         TYPE_NAK,
40         TYPE_NAKALL, //if receive this ack , cancel the data you want to resend
41         TYPE_DATA,
42         TYPE_MAX
43 }packet_type;
44
45 struct ack_packet {
46         u16 magic;
47         u16 checksum;
48         u16 type;
49         u16 dummy;
50         u32 seq_begin;
51         u32 seq_end;
52 };
53
54 // data packet type like below
55
56 struct data_packet_header {
57         u16 magic;
58         u16 checksum;
59         union {
60                         struct ack_packet ack;
61                 };
62         u32 seqnum;
63         u32 len;
64 };
65
66
67 enum ipc_status {
68         IDLE_STATUS,
69         ACK_STATUS,
70         NAK_STATUS,
71         NAKALL_STATUS,
72         MAX_STATUS
73 };
74
75 struct frame_list {
76         struct list_head   frame_list_head;
77         struct mutex       list_mutex;
78         u32    counter;
79 };
80
81 struct ipc_transfer_frame {
82         u8*  buf_ptr;
83         u32  buf_size;
84         u16  pos;
85         u16  flag;
86         u32  status;
87         u32  seq;
88         struct list_head  link;
89 };
90
91
92 struct ipc_transfer
93 {
94    struct mutex transfer_mutex;
95    struct list_head frame_fifo;
96    struct ipc_transfer_frame* cur_frame_ptr;
97    u32 counter;
98 };
99
100 struct timer_info {
101         unsigned long long time;
102         u32 status;
103 };
104
105 struct ipc_spi_dev {
106         bool bneedrcv;
107         bool ipc_enable;
108         bool bneedread;
109         bool bneedsend;
110         u16 rx_ctl; // gpio control no irq: 0 , falling: 1, rasing: 2
111         u16 rwctrl; /* read write controlled by mux */
112         u16 rx_status; // rx status
113         u32 rx_seqnum; /* received num */
114         u32 tx_seqnum;
115         u32 remote_status;
116         struct frame_list tx_free_lst;
117         struct ipc_transfer tx_transfer;
118         struct frame_list rx_free_lst;
119         struct frame_list rx_recv_lst;
120         struct ipc_transfer_frame* rx_curframe;
121         struct ipc_transfer_frame *tx_curframe;
122         wait_queue_head_t wait;
123         wait_queue_head_t rx_read_wait;
124         wait_queue_head_t tx_frame_wait; // tx frame wait
125         struct task_struct *task;
126         struct spi_device *spi;
127         struct miscdevice               miscdev;
128         struct wake_lock wake_lock;
129         struct modemsts_chg modemsts;
130 #ifdef CONFIG_PM
131         bool bsuspend;
132 #endif
133         u32 irq_num; /* use for debug cp side irq num */
134         u32 task_count; /* use for debug task run count*/
135         u32 task_status; /* use for debug record the status of task */
136         u32 rwnum;
137         u32 tx_irqennum; /* use for debug enable gpio num */
138         u32 tx_irqdisnum; /* usefor debug disable gpio num */
139         u32 ap_infocnt;
140         struct timer_info cp2ap[100];
141         struct timer_info ap_info[100];
142 };
143
144
145
146
147 #endif /* __SDHCI_H */