felica.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725
  1. /*
  2. * This program is free software; you can redistribute it and/or modify
  3. * it under the terms of the GNU General Public License as published by
  4. * the Free Software Foundation; either version 2 of the License, or
  5. * (at your option) any later version.
  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. #ifndef _FELICA_H
  13. #define _FELICA_H
  14. #include <linux/module.h>
  15. #include <linux/fs.h>
  16. #include <linux/irq.h>
  17. #include <linux/poll.h>
  18. #include <linux/regulator/consumer.h>
  19. #include <linux/ioctl.h>
  20. #include <linux/module.h>
  21. #include <linux/i2c.h>
  22. #include <net/sock.h>
  23. #include <linux/netlink.h>
  24. #include <linux/skbuff.h>
  25. #include <linux/tty.h>
  26. /* jmodel */
  27. #if defined(CONFIG_ARCH_EXYNOS)
  28. #include <mach/gpio-exynos.h>
  29. #include <plat/gpio-cfg.h>
  30. #elif defined(CONFIG_ARCH_APQ8064)
  31. #include "../../arch/arm/mach-msm/board-8064.h"
  32. #include <mach/apq8064-gpio.h>
  33. #include <mach/gpiomux.h>
  34. #include <linux/barcode_emul.h>
  35. #elif defined(CONFIG_ARCH_MSM8974) || defined(CONFIG_ARCH_MSM8974PRO)
  36. #include "../../arch/arm/mach-msm/board-8064.h"
  37. #if defined(CONFIG_MACH_KLTE_KDI) || defined(CONFIG_MACH_KLTE_DCM) || defined(CONFIG_MACH_KLTE_SBM)
  38. #include <mach/klte_felica_gpio.h>
  39. #else
  40. #include <mach/hlte_felica_gpio.h>
  41. #endif
  42. #include <mach/gpiomux.h>
  43. #include <linux/barcode_emul.h>
  44. #endif
  45. /******************************************************************************
  46. * log
  47. ******************************************************************************/
  48. #if defined(CONFIG_SEC_FACTORY) || !defined(CONFIG_SEC_DEBUG)
  49. /* shown at FACTORY */
  50. #define FELICA_PR_ERR(A,...) pr_err("[FELICA]"A,##__VA_ARGS__)
  51. /* NOT shown at FACTORY */
  52. #define FELICA_PR_INFO(A,...)
  53. #define FELICA_PR_DBG(A,...)
  54. #else
  55. extern unsigned int sec_dbg_level;
  56. /* shown at HIGH/MID/LOW, user mode:default LOW, eng mode: default MID*/
  57. #define FELICA_PR_ERR(A,...) pr_err("[FELICA]"A,##__VA_ARGS__)
  58. /* shown at HIGH/MID, user mode:default LOW, eng mode: default MID*/
  59. #define FELICA_PR_INFO(A,...) \
  60. do { \
  61. if (sec_dbg_level != KERNEL_SEC_DEBUG_LEVEL_LOW) \
  62. pr_info("[FELICA]"A,##__VA_ARGS__);\
  63. } while(0)
  64. /* shown at HIGH/MID under debug control, user mode:default LOW, eng mode: default MID*/
  65. #define FELICA_PR_DBG(A,...) \
  66. do { \
  67. if (sec_dbg_level != KERNEL_SEC_DEBUG_LEVEL_LOW) \
  68. pr_debug("[FELICA]"A,##__VA_ARGS__);\
  69. } while(0)
  70. #endif
  71. /******************************************************************************
  72. * config option
  73. ******************************************************************************/
  74. #ifdef CONFIG_ARCH_APQ8064
  75. #define P2P_FPGA_ALWAYS_ON // FPGA clock always enable for jmodel.
  76. #endif
  77. #define FELICA_UICC_FUNCTION // If SWP is present, must be defined.
  78. #define F_WAKE_LOCK // If wake lock is needed, can be defined.
  79. /******************************************************************************
  80. * common
  81. ******************************************************************************/
  82. /* constant definition */
  83. #define FELICA_MAJOR 10 /* same value as MISC_MAJOR */
  84. #define FELICA_MINOR 0
  85. /* first of the requested range of minor numbers */
  86. #define FELICA_BASEMINOR 0
  87. /* the number of minor numbers required */
  88. #define FELICA_MINOR_COUNT 1
  89. #define GPIO_VALUE_HIGH 1
  90. #define GPIO_VALUE_LOW 0
  91. /* function prototype */
  92. static void felica_initialize_pin(void);
  93. static void felica_finalize_pin(void);
  94. static void felica_register_device(void);
  95. static void felica_deregister_device(void);
  96. static int __init felica_init(void);
  97. static void __exit felica_exit(void);
  98. /******************************************************************************
  99. * /dev/felica
  100. ******************************************************************************/
  101. /* constant definition */
  102. #define FELICA_UART_NAME "felica"
  103. #define FELICA_NL_NETLINK_USER 31
  104. #define FELICA_NL_SUCCESS 1
  105. #define FELICA_NL_EFAILED 2
  106. #define FELICA_NL_REQ_OPEN 0x01
  107. #define FELICA_NL_REQ_CLOSE 0x02
  108. #define FELICA_NL_REQ_READ 0x03
  109. #define FELICA_NL_REQ_WRITE 0x04
  110. #define FELICA_NL_REQ_AVAIABLE 0x05
  111. #define FELICA_NL_REQ_SYNC 0x06
  112. #ifdef FELICA_UICC_FUNCTION
  113. #define FELICA_NL_INIT_END_RES 0x50
  114. #define FELICA_INIT_UICC_END 0x51
  115. #endif
  116. #define FELICA_NL_RESPONCE 0xFE
  117. #define FELICA_NL_CONNECT_MSG 0xFF
  118. /* jmodel */
  119. /*#define FELICA_NL_MSG_DATA_SIZE 4096*/
  120. #define FELICA_NL_MSG_DATA_SIZE N_TTY_BUF_SIZE
  121. /*#define FELICA_NL_MSG_DATA_SIZE 4096*4*/
  122. #define FELICA_NL_MSG_SIZE (FELICA_NL_MSG_DATA_SIZE+4)
  123. #define MSG_READ1_FLAGS_OFFSET 1
  124. #define MSG_READ1_LEN_OFFSET 2
  125. #define MSG_READ2_FLAGS_OFFSET 3
  126. #define MSG_READ2_LEN_OFFSET 4
  127. #define MSG_WRITE_FLAGS_OFFSET 5
  128. #define MSG_WRITE_LEN_OFFSET 6
  129. #define MSG_LOCK_ADDR_OFFSET 7
  130. #define MSG_I2C_ADDR_OFFSET 8
  131. #define MSG_DIAG_NAME_OFFSET 9
  132. #define MSG_MFC_UID_FRONT_OFFSET 24
  133. #define MSG_MFC_UID_BACK_OFFSET 25
  134. #define MSG_MFL_UID_FRONT_OFFSET 26
  135. #define MSG_MFL_UID_BACK_OFFSET 27
  136. #define MSG_RWM_UID_FRONT_OFFSET 28
  137. #define MSG_RWM_UID_BACK_OFFSET 29
  138. #define MSG_ANT_ADDR_OFFSET 30
  139. #define MSG_ANT_UID_FRONT_OFFSET 31
  140. #define MSG_ANT_UID_BACK_OFFSET 32
  141. #ifdef CONFIG_NFC_FELICA
  142. #define MSG_NFC_UID_FRONT_OFFSET 33
  143. #define MSG_NFC_UID_BACK_OFFSET 34
  144. #endif /* CONFIG_NFC_FELICA */
  145. #ifdef FELICA_UICC_FUNCTION
  146. #define MSG_PROC_NAME_OFFSET 35
  147. #endif
  148. #define FELICA_HLOS_IMG_TAMPER_FUSE 0
  149. #define FELICA_SCM_SVC_FUSE 0x08
  150. #define FELICA_SCM_BLOW_SW_FUSE_ID 0x01
  151. #define FELICA_SCM_IS_SW_FUSE_BLOWN_ID 0x02
  152. #ifdef FELICA_UICC_FUNCTION
  153. #define PROC_NAME_MAXSIZE 16
  154. #endif
  155. /* function prototype */
  156. static void felica_uart_init(void);
  157. static void felica_uart_exit(void);
  158. static int felica_uart_open(struct inode *inode, struct file *file);
  159. static int felica_uart_close(struct inode *inode, struct file *file);
  160. static ssize_t felica_uart_read(struct file *file, char __user *buf,\
  161. size_t len, loff_t *ppos);
  162. static ssize_t felica_uart_write(struct file *file, const char __user *data,\
  163. size_t len, loff_t *ppos);
  164. static int felica_uart_sync(struct file *file, loff_t start, loff_t len,\
  165. int datasync);
  166. static long felica_uart_ioctl(struct file *file, unsigned int cmd,\
  167. unsigned long arg);
  168. static void felica_nl_init(void);
  169. static void felica_nl_exit(void);
  170. static int felica_nl_send_msg(int len);
  171. static void felica_nl_recv_msg(struct sk_buff *skb);
  172. static void felica_nl_wait_ret_msg(void);
  173. static void felica_set_felica_info(void);
  174. #if defined(CONFIG_ARCH_EXYNOS)
  175. static int felica_smc_read_oemflag(u32 ctrl_word, u32 *val);
  176. static int felica_Cpu0(void);
  177. static int felica_CpuAll(void);
  178. #endif
  179. #if defined(CONFIG_ARCH_APQ8064) || defined(CONFIG_ARCH_MSM8974) || defined(CONFIG_ARCH_MSM8974PRO)
  180. static uint8_t felica_get_tamper_fuse_cmd(void);
  181. #endif
  182. #ifdef CONFIG_NFC_FELICA
  183. static int felica_uart_open_wait_for_polling(void);
  184. #endif /* CONFIG_NFC_FELICA */
  185. /******************************************************************************
  186. * /dev/felica_pon
  187. ******************************************************************************/
  188. /* constant definition */
  189. #define FELICA_PON_NAME "felica_pon"
  190. /* jmodel */
  191. #if defined(CONFIG_ARCH_EXYNOS)
  192. #define GPIO_PINID_FELICA_PON EXYNOS5410_GPJ2(7)
  193. #elif defined(CONFIG_ARCH_APQ8064)
  194. #define GPIO_PINID_FELICA_PON FPGA_GPIO_FELICA_PON
  195. #elif defined(CONFIG_ARCH_MSM8974) || defined(CONFIG_ARCH_MSM8974PRO)
  196. #if !defined(CONFIG_MACH_KLTE_KDI) && !defined(CONFIG_MACH_KLTE_DCM) && !defined(CONFIG_MACH_KLTE_SBM)
  197. #define GPIO_PINID_FELICA_PON GPIO_FELICA_PON
  198. #endif // CONFIG_MACH_KLTE
  199. #endif
  200. #define FELICA_PON_DATA_LEN 1
  201. #define FELICA_PON_WIRELESS 0
  202. #define FELICA_PON_WIRED 1
  203. /* function prototype */
  204. static void felica_pon_init(void);
  205. static void felica_pon_exit(void);
  206. static int felica_pon_open(struct inode *inode, struct file *file);
  207. static int felica_pon_close(struct inode *inode, struct file *file);
  208. static ssize_t felica_pon_read(struct file *file, char __user *buf,\
  209. size_t len, loff_t *ppos);
  210. static ssize_t felica_pon_write(struct file *file, const char __user *data, \
  211. size_t len, loff_t *ppos);
  212. /******************************************************************************
  213. * felica_i2c_driver
  214. ******************************************************************************/
  215. /* constant definition */
  216. #define FELICA_I2C_NAME "felica_i2c"
  217. /* function prototype */
  218. static void felica_i2c_init(void);
  219. static void felica_i2c_exit(void);
  220. static int felica_i2c_probe(struct i2c_client *client,\
  221. const struct i2c_device_id *devid);
  222. static int felica_i2c_remove(struct i2c_client *client);
  223. /******************************************************************************
  224. * /dev/felica_cen
  225. ******************************************************************************/
  226. /* constant definition */
  227. #define FELICA_CEN_NAME "felica_cen"
  228. #define FELICA_CEN_DATA_LEN 1
  229. #define FELICA_CONTROL_LOCK_MASK 1
  230. #define FELICA_CEN_LOCK 0
  231. #define FELICA_CEN_UNLOCK 1
  232. #define FELICA_CEN_SET_LOCK 0x80
  233. #define FELICA_CEN_SET_UNLOCK 0x81
  234. /* function prototype */
  235. static void felica_cen_init(void);
  236. static void felica_cen_exit(void);
  237. static int felica_cen_open(struct inode *inode, struct file *file);
  238. static int felica_cen_close(struct inode *inode, struct file *file);
  239. static ssize_t felica_cen_read(struct file *file, char __user *buf,\
  240. size_t len, loff_t *ppos);
  241. static ssize_t felica_cen_write(struct file *file, const char __user *data,\
  242. size_t len, loff_t *ppos);
  243. /******************************************************************************
  244. * /dev/felica_rfs
  245. ******************************************************************************/
  246. /* constant definition */
  247. #define FELICA_RFS_NAME "felica_rfs"
  248. /* jmodel */
  249. #if defined(CONFIG_ARCH_EXYNOS)
  250. #define GPIO_PINID_FELICA_RFS EXYNOS5410_GPJ3(0)
  251. #elif defined(CONFIG_ARCH_APQ8064) || defined(CONFIG_ARCH_MSM8974) || defined(CONFIG_ARCH_MSM8974PRO)
  252. #define GPIO_PINID_FELICA_RFS GPIO_FELICA_RFS
  253. #endif
  254. #define FELICA_RFS_DATA_LEN 1
  255. #define FELICA_RFS_STANDBY 0
  256. #define FELICA_RFS_DETECTED 1
  257. /* function prototype */
  258. static void felica_rfs_init(void);
  259. static void felica_rfs_exit(void);
  260. static int felica_rfs_open(struct inode *inode, struct file *file);
  261. static int felica_rfs_close(struct inode *inode, struct file *file);
  262. static ssize_t felica_rfs_read(struct file *file, char __user *buf, \
  263. size_t len, loff_t *ppos);
  264. /******************************************************************************
  265. * /dev/felica_rws
  266. ******************************************************************************/
  267. /* constant definition */
  268. #define FELICA_RWS_NAME "felica_rws"
  269. #define FELICA_RWS_DATA_LEN 1
  270. #define FELICA_RW_STATUS_INIT 0
  271. #define FELICA_RW_STATUS_ENABLE 0
  272. #define FELICA_RW_STATUS_DISABLE 1
  273. /* function prototype */
  274. static void felica_rws_init(void);
  275. static void felica_rws_exit(void);
  276. static int felica_rws_open(struct inode *inode, struct file *file);
  277. static int felica_rws_close(struct inode *inode, struct file *file);
  278. static ssize_t felica_rws_read(struct file *file, char __user *buf,\
  279. size_t len, loff_t *ppos);
  280. static ssize_t felica_rws_write(struct file *file, const char __user *data, \
  281. size_t len, loff_t *ppos);
  282. /******************************************************************************
  283. * /dev/felica_int_poll
  284. ******************************************************************************/
  285. /* constant definition */
  286. #define FELICA_INT_POLL_NAME "felica_int_poll"
  287. /* jmodel */
  288. #if defined(CONFIG_ARCH_EXYNOS)
  289. #define GPIO_PINID_FELICA_INT_REV03 EXYNOS5410_GPX1(3) /* rev0.3 */
  290. #define GPIO_PINID_FELICA_INT_REV00 EXYNOS5410_GPX1(6) /* rev0.0 */
  291. #elif defined(CONFIG_ARCH_APQ8064)
  292. #define GPIO_PINID_FELICA_INT_REV03 GPIO_FELICA_INT
  293. #elif defined(CONFIG_ARCH_MSM8974) || defined(CONFIG_ARCH_MSM8974PRO)
  294. #if defined(CONFIG_MACH_KLTE_KDI) || defined(CONFIG_MACH_KLTE_DCM) || defined(CONFIG_MACH_KLTE_SBM)
  295. #define GPIO_PINID_FELICA_INT GPIO_FELICA_INT
  296. #endif // CONFIG_MACH_KLTE
  297. #endif //CONFIG_ARCH_MSM8974
  298. #define FELICA_INT_DATA_LEN 1
  299. #define FELICA_INT_DELAY_TIME 3
  300. #define FELICA_INT_LOW 0
  301. #define FELICA_INT_HIGH 1
  302. /* function prototype */
  303. static irqreturn_t felica_int_irq_handler(int irq, void *dev_id);
  304. static void felica_int_irq_work(struct work_struct *work);
  305. static void felica_int_poll_init(void);
  306. static void felica_int_poll_exit(void);
  307. static int felica_int_poll_open(struct inode *inode, struct file *file);
  308. static int felica_int_poll_close(struct inode *inode, struct file *file);
  309. static ssize_t felica_int_poll_read(struct file *file, \
  310. char __user *buf, size_t len, loff_t *ppos);
  311. static unsigned int felica_int_poll_poll(struct file *file, poll_table *wait);
  312. /******************************************************************************
  313. * /dev/felica_uid
  314. ******************************************************************************/
  315. /* constant definition */
  316. #define FELICA_UID_NAME "felica_uid"
  317. #define DIAG_NAME_MAXSIZE 15
  318. #define FELICA_MAGIC 0xF8
  319. #define SET_FELICA_UID_DIAG _IOW(FELICA_MAGIC, 4, void *)
  320. /* function prototype */
  321. static void felica_uid_init(void);
  322. static void felica_uid_exit(void);
  323. static int felica_uid_open(struct inode *inode, struct file *file);
  324. static int felica_uid_close(struct inode *inode, struct file *file);
  325. static long felica_uid_ioctl(struct file *file, unsigned int cmd, \
  326. unsigned long arg);
  327. /******************************************************************************
  328. * /dev/felica_ant
  329. ******************************************************************************/
  330. /* constant definition */
  331. #define FELICA_ANT_NAME "felica_ant"
  332. #define FELICA_ANT_DATA_LEN 1
  333. /* function prototype */
  334. static void felica_ant_init(void);
  335. static void felica_ant_exit(void);
  336. static int felica_ant_open(struct inode *inode, struct file *file);
  337. static int felica_ant_close(struct inode *inode, struct file *file);
  338. static ssize_t felica_ant_read(struct file *file, char __user *buf,\
  339. size_t len, loff_t *ppos);
  340. static ssize_t felica_ant_write(struct file *file, const char __user *data,\
  341. size_t len, loff_t *ppos);
  342. /******************************************************************************
  343. *
  344. *
  345. *
  346. *
  347. * Add driver code for CXD2235AGG NFC/Felica IC
  348. *
  349. *
  350. *
  351. *
  352. ******************************************************************************/
  353. #ifdef CONFIG_NFC_FELICA
  354. /******************************************************************************
  355. * common
  356. ******************************************************************************/
  357. /* function prototype */
  358. static void snfc_register_device(void);
  359. static void snfc_deregister_device(void);
  360. static ssize_t snfc_cen_sts_init(void);
  361. static int snfc_uid_check(void);
  362. /******************************************************************************
  363. * /dev/snfc_hsel
  364. ******************************************************************************/
  365. /* constant definition */
  366. #if defined(CONFIG_ARCH_EXYNOS)
  367. #define GPIO_PINID_NFC_HSEL EXYNOS5410_GPX0(4)
  368. #elif defined(CONFIG_ARCH_APQ8064)
  369. #define GPIO_PINID_NFC_HSEL FPGA_GPIO_FELICA_HSEL
  370. #elif defined(CONFIG_ARCH_MSM8974) || defined(CONFIG_ARCH_MSM8974PRO)
  371. #define GPIO_PINID_NFC_HSEL GPIO_FELICA_HSEL
  372. #endif
  373. #define HSEL_DEV_NAME "snfc_hsel"
  374. #define HSEL_DEV_COUNT 1
  375. /* function prototype */
  376. static int hsel_init(void);
  377. static void hsel_exit(void);
  378. static ssize_t hsel_read(struct file *file, char __user * buf, size_t len,\
  379. loff_t * ppos);
  380. static ssize_t hsel_write(struct file *file, const char __user *data,\
  381. size_t len, loff_t *ppos);
  382. static int hsel_open(struct inode *inode, struct file *file);
  383. static int hsel_release(struct inode *inode, struct file *file);
  384. /******************************************************************************
  385. * /dev/snfc_intu_poll
  386. ******************************************************************************/
  387. /* constant definition */
  388. #if defined(CONFIG_ARCH_EXYNOS)
  389. #define GPIO_PINID_NFC_INTU_REV03 EXYNOS5410_GPX2(7) /* rev0.3 */
  390. #define GPIO_PINID_NFC_INTU_REV00 EXYNOS5410_GPX1(5) /* rev0.0 */
  391. #elif defined(CONFIG_ARCH_APQ8064)
  392. #define GPIO_PINID_NFC_INTU_REV03 GPIO_FELICA_INTU
  393. #define GPIO_PINID_NFC_INTU_REV06 GPIO_FELICA_INTU_REV06
  394. #elif defined(CONFIG_ARCH_MSM8974) || defined(CONFIG_ARCH_MSM8974PRO)
  395. #define GPIO_PINID_NFC_INTU GPIO_FELICA_INTU
  396. #endif
  397. #define INTU_POLL_DEV_NAME "snfc_intu_poll"
  398. #define INTU_POLL_DEV_COUNT 1
  399. #define INTU_POLL_DELAY 3
  400. #define INTU_POLL_DEV_LOW 0
  401. #define INTU_POLL_DEV_HIGH 1
  402. /* function prototype */
  403. static irqreturn_t intu_poll_irq_handler(int irq, void *dev_id);
  404. static void intu_poll_work_func(struct work_struct *work);
  405. static int intu_poll_init(void);
  406. static void intu_poll_exit(void);
  407. static ssize_t intu_poll_read(struct file *file, char __user * buf,\
  408. size_t len, loff_t * ppos);
  409. static int intu_poll_open(struct inode *inode, struct file *file);
  410. static int intu_poll_release(struct inode *inode, struct file *file);
  411. /******************************************************************************
  412. * /dev/snfc_available_poll
  413. ******************************************************************************/
  414. /* constant definition */
  415. #define AVAILABLE_POLL_DEV_NAME "snfc_available_poll"
  416. #define AVAILABLE_POLL_DEV_COUNT 1
  417. #define AVAILABLE_POLL_DEV_MAGIC 0xFC
  418. #define AVAILABLE_POLL_DEV_SET_PRE_LOCK _IO(AVAILABLE_POLL_DEV_MAGIC, 8)
  419. /* function prototype */
  420. static int available_poll_init(void);
  421. static void available_poll_exit(void);
  422. static long available_poll_ioctl(struct file *file, unsigned int cmd,\
  423. unsigned long arg);
  424. static ssize_t available_poll_read(struct file *file, char __user * buf,\
  425. size_t len, loff_t * ppos);
  426. static int available_poll_open(struct inode *inode, struct file *file);
  427. static int available_poll_release(struct inode *inode, struct file *file);
  428. /******************************************************************************
  429. * /dev/snfc_rfs_poll
  430. ******************************************************************************/
  431. /* constant definition */
  432. #define GPIO_PINID_NFC_RFS_POLL GPIO_PINID_FELICA_RFS
  433. #define RFS_POLL_DEV_NAME "snfc_rfs_poll"
  434. #define RFS_POLL_DEV_COUNT 1
  435. #define RFS_POLL_RETRY_CNT 3
  436. #define RFS_POLL_SLEEP 1
  437. #define RFS_POLL_DELAY 3
  438. #define RFS_POLL_DEV_LOW 0
  439. #define RFS_POLL_DEV_HIGH 1
  440. #define RFS_POLL_RET_STS_LOW 0
  441. #define RFS_POLL_RET_STS_HIGH 1
  442. /* function prototype */
  443. static irqreturn_t rfs_poll_irq_handler(int irq, void *dev_id);
  444. static void rfs_poll_work_func(struct work_struct *work);
  445. static int rfs_poll_init(void);
  446. static void rfs_poll_exit(void);
  447. static int rfs_poll_open(struct inode *inode, struct file *file);
  448. static int rfs_poll_release(struct inode *inode, struct file *file);
  449. static unsigned int rfs_poll_poll(struct file *file, poll_table *wait);
  450. static ssize_t rfs_poll_read(struct file *file, char __user * buf, size_t len,
  451. loff_t * ppos);
  452. /******************************************************************************
  453. * /dev/snfc_pon
  454. ******************************************************************************/
  455. /* constant definition */
  456. /* CXD2235POWER device */
  457. #if !defined(CONFIG_MACH_KLTE_KDI) && !defined(CONFIG_MACH_KLTE_DCM) && !defined(CONFIG_MACH_KLTE_SBM)
  458. #define GPIO_PINID_NFC_PON GPIO_PINID_FELICA_PON
  459. #endif
  460. #define CXD2235_POWER_DEV_NAME "snfc_pon"
  461. #define CXD2235_POWER_DEV_COUNT 1
  462. /* function prototype */
  463. static int cxd2235power_init(void);
  464. static void cxd2235power_exit(void);
  465. static int cxd2235power_open(struct inode *inode, struct file *file);
  466. static int cxd2235power_release(struct inode *inode, struct file *file);
  467. static ssize_t cxd2235power_write(struct file *file, const char __user *data,\
  468. size_t len, loff_t *ppos);
  469. /******************************************************************************
  470. * /dev/snfc_rfs
  471. ******************************************************************************/
  472. /* constant definition */
  473. #define SNFC_RFS_NAME "snfc_rfs"
  474. #if defined(CONFIG_ARCH_EXYNOS)
  475. #define GPIO_PINID_SNFC_RFS EXYNOS5410_GPJ3(0)
  476. #elif defined(CONFIG_ARCH_APQ8064) || defined(CONFIG_ARCH_MSM8974) || defined(CONFIG_ARCH_MSM8974PRO)
  477. #define GPIO_PINID_SNFC_RFS GPIO_PINID_FELICA_RFS
  478. #endif
  479. #define SNFC_RFS_DATA_LEN 1
  480. #define SNFC_RFS_STANDBY 0
  481. #define SNFC_RFS_DETECTED 1
  482. /* function prototype */
  483. static void snfc_rfs_init(void);
  484. static void snfc_rfs_exit(void);
  485. static int snfc_rfs_open(struct inode *inode, struct file *file);
  486. static int snfc_rfs_close(struct inode *inode, struct file *file);
  487. static ssize_t snfc_rfs_read(struct file *file, char __user *buf, \
  488. size_t len, loff_t *ppos);
  489. /******************************************************************************
  490. * /dev/snfc_uart
  491. ******************************************************************************/
  492. /* constant definition */
  493. #define SNFC_UART_NAME "snfc_uart"
  494. #if defined(CONFIG_ARCH_EXYNOS)
  495. #define UART_DEV_NAME "/dev/ttySAC1"
  496. #elif defined(CONFIG_ARCH_APQ8064)
  497. #define UART_DEV_NAME "/dev/ttyHSL2"
  498. #elif defined(CONFIG_MACH_KLTE_DCM) || defined(CONFIG_MACH_KLTE_KDI) || defined(CONFIG_MACH_KLTE_SBM)
  499. #define UART_DEV_NAME "/dev/ttyHSL2"
  500. #elif defined(CONFIG_MACH_HLTEDCM) || defined(CONFIG_MACH_HLTEKDI) || defined(CONFIG_MACH_JS01LTEDCM)
  501. #define UART_DEV_NAME "/dev/ttyHSL1"
  502. #endif
  503. /* function prototype */
  504. static void snfc_uart_init(void);
  505. static void snfc_uart_exit(void);
  506. static int snfc_uart_open(struct inode *inode, struct file *file);
  507. static int snfc_uart_close(struct inode *inode, struct file *file);
  508. static ssize_t snfc_uart_read(struct file *file, char __user *buf,\
  509. size_t len, loff_t *ppos);
  510. static ssize_t snfc_uart_write(struct file *file, const char __user *data, \
  511. size_t len, loff_t *ppos);
  512. static long snfc_uart_ioctl(struct file *file, unsigned int cmd, \
  513. unsigned long arg);
  514. static unsigned int snfc_uart_poll(struct file *file, \
  515. struct poll_table_struct *poll_table);
  516. /******************************************************************************
  517. * /dev/uartcc
  518. ******************************************************************************/
  519. /* constant definition */
  520. #define UARTCC_MAJOR FELICA_MAJOR /* 10 */
  521. #define UARTCC_MINOR FELICA_MINOR /* 0 */
  522. #define UARTCC_BASEMINOR FELICA_BASEMINOR /* 0 */
  523. #define UARTCC_MINOR_COUNT FELICA_MINOR_COUNT /* 1 */
  524. #define UARTCC_NAME "uartcc"
  525. #define UARTCC_MAGIC FELICA_MAGIC /* 0xF8 */
  526. #define UARTCC_SET_FELICA_STATUS _IOW(UARTCC_MAGIC, 1, int)
  527. #define UARTCC_SET_NFC_START_REQ _IOW(UARTCC_MAGIC, 2, int)
  528. #define UARTCC_GET_FELICA_STATUS _IOR(UARTCC_MAGIC, 3, int)
  529. /* felica usage state */
  530. enum {
  531. UARTCC_FELICA_STATAUS_IDLE = 0, /* idle */
  532. UARTCC_FELICA_STATAUS_WAIT_POLLING, /* wait pollig */
  533. UARTCC_FELICA_STATAUS_IN_USE, /* in use */
  534. #ifdef FELICA_UICC_FUNCTION
  535. UARTCC_FELICA_STATAUS_IN_INIT, /* INIT UICC */
  536. #endif
  537. };
  538. /* nfc start request */
  539. enum {
  540. UARTCC_NFC_START_AUTOPOLLING = 1,
  541. UARTCC_NFC_START_ENDPROC = 0xFF,
  542. };
  543. #ifdef P2P_FPGA_ALWAYS_ON
  544. enum {
  545. SNFC_START_SETTING = 0,
  546. SNFC_START_AUTOPOLL,
  547. SNFC_START_RW,
  548. SNFC_START_TARGET,
  549. SNFC_START_INTU,
  550. SNFC_START_WAITSIMBOOT,
  551. };
  552. #endif
  553. #define UARTCC_GET_NFC_START_REQ _IOR(UARTCC_MAGIC, 4, int)
  554. /* function prototype */
  555. static void uartcc_init(void);
  556. static void uartcc_exit(void);
  557. static int uartcc_open(struct inode *inode, struct file *file);
  558. static int uartcc_close(struct inode *inode, struct file *file);
  559. static long uartcc_ioctl(struct file *file, unsigned int cmd,\
  560. unsigned long arg);
  561. static void uartcc_felica_start_request(void);
  562. static void uartcc_set_felica_status(int status);
  563. static int uartcc_get_felica_status(void);
  564. static unsigned int uartcc_is_idle_status(void);
  565. /******************************************************************************
  566. * /dev/felica_uicc
  567. ******************************************************************************/
  568. /* constant definition */
  569. #define UICC_MAJOR FELICA_MAJOR
  570. #define UICC_MINOR FELICA_MINOR
  571. #define UICC_BASEMINOR FELICA_BASEMINOR /* 0 */
  572. #define UICC_MINOR_COUNT FELICA_MINOR_COUNT /* 1 */
  573. #define UICC_NAME "felica_uicc"
  574. #define UICC_MAGIC FELICA_MAGIC /* 0xF8 */
  575. #define FELICA_UICC_DATA_LEN 1 // permissive mode issue
  576. #define UICC_POWER_ON _IO(UICC_MAGIC, 1)
  577. #define UICC_POWER_OFF _IO(UICC_MAGIC, 2)
  578. #define UICC_POWER_SPS_PMIC _IO(UICC_MAGIC, 3)
  579. #define UICC_POWER_UIM_MON _IO(UICC_MAGIC, 4)
  580. #define UICC_ERROR 1
  581. #define UICC_SUCCESS 2
  582. #define GPIO_PINID_SPS 10
  583. /* function prototype */
  584. static void uicc_init(void);
  585. static void uicc_exit(void);
  586. static int uicc_open(struct inode *inode, struct file *file);
  587. static int uicc_close(struct inode *inode, struct file *file);
  588. static ssize_t uicc_read(struct file *file, char __user *buf,\
  589. size_t len, loff_t *ppos); // permissive mode issue
  590. static long uicc_ioctl(struct file *file, unsigned int cmd, \
  591. unsigned long arg);
  592. #define FELICA_GPIO_DRIVER_NAME "felica_gpio_table"
  593. /******************************************************************************
  594. * /dev/snfc_cen
  595. ******************************************************************************/
  596. /* constant definition */
  597. #define SNFC_CEN_NAME "snfc_cen"
  598. #define SNFC_CEN_DATA_LEN 1
  599. #define SNFC_CONTROL_LOCK_MASK 1
  600. #define SNFC_CEN_LOCK 0
  601. #define SNFC_CEN_UNLOCK 1
  602. #define SNFC_CEN_SET_LOCK 0x80
  603. #define SNFC_CEN_SET_UNLOCK 0x81
  604. /* function prototype */
  605. static void snfc_cen_init(void);
  606. static void snfc_cen_exit(void);
  607. static int snfc_cen_open(struct inode *inode, struct file *file);
  608. static int snfc_cen_close(struct inode *inode, struct file *file);
  609. static ssize_t snfc_cen_read(struct file *file, char __user *buf,\
  610. size_t len, loff_t *ppos);
  611. #endif /* CONFIG_NFC_FELICA */
  612. #endif /* _FELICA_H */