aboutsummaryrefslogtreecommitdiff
path: root/drivers/misc/mediatek/c2k_ccci/c2k_hw.h
blob: 04e6297718a5474e60f4764b9c1b9d1cb9ef448b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#ifndef C2K_HW_H
#define C2K_HW_H

#include <linux/interrupt.h>
#include "core.h"

#define GPIO_C2K_UNKNOW (-1)
#ifndef CONFIG_EVDO_DT_VIA_SUPPORT
#define AP_USING_REGISTER (0xFFFFFF)
#endif
#define GPIO_C2K_VALID(gpio) ((gpio == GPIO_C2K_UNKNOW) ? 0 : 1)

#ifdef CONFIG_EVDO_DT_VIA_SUPPORT
#define MDM_MMC_ID "mmc2"
#else
#define MDM_MMC_ID "mmc3"
#endif

//////////////////////////////////////////////////////////////////////////////////
/*******************************  Gpio Config ***********************************/
//////////////////////////////////////////////////////////////////////////////////
#include <mach/mt_gpio.h>
#include <mach/eint.h>
#include <cust_gpio_usage.h>
#include "modem_sdio.h"

#ifdef CONFIG_EVDO_DT_VIA_SUPPORT

#define GPIO_C2K_MDM_PWR_EN  			GPIO_VIA_MDM_PWR_EN
#define GPIO_C2K_MDM_PWR_IND 			GPIO_C2K_UNKNOW

#define GPIO_C2K_MDM_RST     			GPIO_VIA_MDM_RST
#define GPIO_C2K_MDM_RST_IND 			GPIO_VIA_MDM_RST_IND
#define GPIO_C2K_MDM_RST_IND_POLAR 		0
#define GPIO_C2K_MDM_BOOT_SEL 			GPIO_C2K_UNKNOW

#ifdef MTK_PCA9575A_SUPPORT
//#define GPIO_C2K_MDM_ETS_SEL GPIO_VIA_ETS_SEL
#define GPIO_C2K_MDM_ETS_SEL 			GPIO_C2K_UNKNOW
#else
#define GPIO_C2K_MDM_ETS_SEL 			GPIO_VIA_ETS_SEL
//#define GPIO_C2K_MDM_ETS_SEL GPIO_C2K_UNKNOW
#endif

#define GPIO_C2K_SDIO_AP_RDY 			GPIO_VIA_AP_RDY
#define GPIO_C2K_SDIO_MDM_RDY 			GPIO_VIA_MDM_RDY
#define GPIO_C2K_SDIO_AP_WAKE_MDM 		GPIO_VIA_AP_WAKE_MDM
#define GPIO_C2K_SDIO_MDM_WAKE_AP 		GPIO_VIA_MDM_WAKE_AP

#define GPIO_C2K_SDIO_SYNC_POLAR 0

#ifdef GPIO_VIA_CBP_BCKUP_1
#define GPIO_C2K_CRASH_CBP 				GPIO_VIA_CBP_BCKUP_1
#else
#define GPIO_C2K_CRASH_CBP 				GPIO_C2K_UNKNOW
#endif

#define GPIO_C2K_SDIO_DATA_ACK 			GPIO_VIA_SDIO_ACK
#define GPIO_C2K_SDIO_DATA_ACK_POLAR 	0

#define GPIO_C2K_SDIO_FLOW_CTRL 		GPIO_VIA_FLOW_CTRL
#define GPIO_C2K_SDIO_FLOW_CTRL_POLAR 	1

//level shift maybe not used
#define GPIO_C2K_MC3_EN_N				GPIO_C2K_UNKNOW
#define GPIO_C2K_SD_SEL_N				GPIO_C2K_UNKNOW

#else//CONFIG_EVDO_DT_VIA_SUPPORT

/*We actually only use EINT, no real GPIO. So no GPIO dws setting.*/
#define GPIO_C2K_MDM_RST_IND 			208	//EINT NUM, not GPIO num
#define GPIO_C2K_SDIO_MDM_RDY			211	//EINT NUM, not GPIO num
#define GPIO_C2K_SDIO_MDM_WAKE_AP		212	//EINT NUM, not GPIO num
#define GPIO_C2K_EXCEPTION				210	//EINT NUM, not GPIO num

#define GPIO_C2K_MDM_RST_IND_POLAR 		0
#define GPIO_C2K_SDIO_SYNC_POLAR		0

#define GPIO_C2K_MDM_PWR_EN  			GPIO_C2K_UNKNOW
#define GPIO_C2K_MDM_PWR_IND 			GPIO_C2K_UNKNOW
#define GPIO_C2K_MDM_RST     			GPIO_C2K_UNKNOW
#define GPIO_C2K_MDM_BOOT_SEL 			GPIO_C2K_UNKNOW
#define GPIO_C2K_MDM_ETS_SEL			AP_USING_REGISTER
#define GPIO_C2K_SDIO_AP_RDY			AP_USING_REGISTER
#define GPIO_C2K_SDIO_AP_WAKE_MDM		AP_USING_REGISTER

#define GPIO_C2K_CRASH_CBP				GPIO_C2K_UNKNOW
#define GPIO_C2K_SDIO_DATA_ACK			GPIO_C2K_UNKNOW
#define GPIO_C2K_SDIO_DATA_ACK_POLAR 	0
#define GPIO_C2K_SDIO_FLOW_CTRL 		GPIO_C2K_UNKNOW
#define GPIO_C2K_SDIO_FLOW_CTRL_POLAR	1

//level shift maybe not used
#define GPIO_C2K_MC3_EN_N 				GPIO_C2K_UNKNOW
#define GPIO_C2K_SD_SEL_N 				GPIO_C2K_UNKNOW

#endif

//////////////////////////////////////////////////////////////////////////////////
/****************************** Gpio Function   *********************************/
//////////////////////////////////////////////////////////////////////////////////
/*config the gpio to be input for irq if the SOC need*/
int c2k_gpio_direction_input_for_irq(int gpio);
int c2k_gpio_direction_output(int gpio, int value);
int c2k_gpio_get_value(int gpio);
int c2k_gpio_to_irq(int gpio);
int c2k_irq_to_gpio(int irq);
int c2k_gpio_set_irq_type(int gpio, unsigned int type);
int c2k_gpio_request_irq(int gpio, irq_handler_t handler, unsigned long flags,
	    const char *name, void *dev);
void c2k_gpio_irq_mask(int gpio);
void c2k_gpio_irq_unmask(int gpio);
#ifndef CONFIG_EVDO_DT_VIA_SUPPORT
int c2k_gpio_to_ls(int gpio);
int c2k_ap_wake_cp(int value);
int c2k_ap_ready_indicate(int value);
#endif

//////////////////////////////////////////////////////////////////////////////////
/*******************************  Sync Control **********************************/
//////////////////////////////////////////////////////////////////////////////////
/* notifer events */
#define ASC_NTF_TX_READY      0x0001 /*notifie CBP is ready to work*/
#define ASC_NTF_TX_UNREADY    0x0002 /*notifie CBP is not ready to work*/
#define ASC_NTF_RX_PREPARE    0x1001 /* notifier the device active to receive data from CBP*/
#define ASC_NTF_RX_POST       0x1002 /* notifer the device CBP stop tx data*/

#define ASC_NAME_LEN   (64)

/*used to register handle*/
struct asc_config{
    int gpio_ready;
    int gpio_wake;
    /*the level which indicate ap is ready*/
    int polar;
    char name[ASC_NAME_LEN];
};

/*Used to registe user accoring to handle*/
struct asc_infor {
    void *data;
    int (*notifier)(int, void *);
    char name[ASC_NAME_LEN];
};

#define CBP_TX_HD_NAME "TxHdCbp"
#define CBP_TX_USER_NAME "cbp"

#define USB_RX_HD_NAME "RxHdUsb"
#define USB_RX_USER_NAME "usb"

#define UART_RX_HD_NAME "RxHdUart"
#define UART_RX_USER_NAME "uart"

#define SDIO_RX_HD_NAME "RxHdSdio"
#define SDIO_RX_USER_NAME "sdio"

#define RAWBULK_RX_USER_NAME "rawbulk"

#define ASC_PATH(hd, user) hd"."user

int asc_tx_register_handle(struct asc_config *cfg);
int asc_tx_add_user(const char *name, struct asc_infor *infor);
void asc_tx_del_user(const char *path);
int asc_tx_get_ready(const char *path, int sync);
int asc_tx_put_ready(const char *path, int sync);
int asc_tx_auto_ready(const char *name, int sync);
int asc_tx_ready_count(const char *name, int inc);

int asc_tx_check_ready(const char *name);
int asc_tx_set_auto_delay(const char *name, int delay);
int asc_tx_user_count(const char *path);
void asc_tx_reset(const char *name);

int asc_rx_register_handle(struct asc_config *cfg);
int asc_rx_add_user(const char *name, struct asc_infor *infor);
void asc_rx_del_user(const char *path);
int asc_rx_confirm_ready(const char *name, int ready);
void asc_rx_reset(const char *name);
int asc_rx_check_on_start(const char *name);

//////////////////////////////////////////////////////////////////////////////////
/*******************************  Power Control *********************************/
//////////////////////////////////////////////////////////////////////////////////
/* modem event notification values */
enum clock_event_nofitiers {
	MDM_EVT_NOTIFY_POWER_ON = 0,
	MDM_EVT_NOTIFY_POWER_OFF,
	MDM_EVT_NOTIFY_RESET_ON,
	MDM_EVT_NOTIFY_RESET_OFF,
	MDM_EVT_NOTIFY_HD_ERR,
	MDM_EVT_NOTIFY_HD_ENHANCE,
	MDM_EVT_NOTIFY_IPOH,
	MDM_EVT_NOTIFY_WDT,
	MDM_EVT_NOTIFY_EXCP,
	MDM_EVT_NOTIFY_NUM
};

void modem_notify_event(int event);
int modem_register_notifier(struct notifier_block *nb);
int modem_unregister_notifier(struct notifier_block *nb);
void c2k_reset_tx_gpio_ready(int gpio);
#endif