pn544.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Driver include for the PN544 NFC chip.
  3. *
  4. * Copyright (C) Nokia Corporation
  5. *
  6. * Author: Jari Vanhala <ext-jari.vanhala@nokia.com>
  7. * Contact: Matti Aaltoenn <matti.j.aaltonen@nokia.com>
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * version 2 as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. */
  22. #ifndef _PN544_H_
  23. #define _PN544_H_
  24. #include <linux/i2c.h>
  25. #define PN544_DRIVER_NAME "pn544"
  26. #define PN544_MAXWINDOW_SIZE 7
  27. #define PN544_WINDOW_SIZE 4
  28. #define PN544_RETRIES 10
  29. #define PN544_MAX_I2C_TRANSFER 0x0400
  30. #define PN544_MSG_MAX_SIZE 0x21 /* at normal HCI mode */
  31. /* ioctl */
  32. #define PN544_CHAR_BASE 'P'
  33. #define PN544_IOR(num, dtype) _IOR(PN544_CHAR_BASE, num, dtype)
  34. #define PN544_IOW(num, dtype) _IOW(PN544_CHAR_BASE, num, dtype)
  35. #define PN544_GET_FW_MODE PN544_IOW(1, unsigned int)
  36. #define PN544_SET_FW_MODE PN544_IOW(2, unsigned int)
  37. #define PN544_GET_DEBUG PN544_IOW(3, unsigned int)
  38. #define PN544_SET_DEBUG PN544_IOW(4, unsigned int)
  39. /* Timing restrictions (ms) */
  40. #define PN544_RESETVEN_TIME 30 /* 7 */
  41. #define PN544_PVDDVEN_TIME 0
  42. #define PN544_VBATVEN_TIME 0
  43. #define PN544_GPIO4VEN_TIME 0
  44. #define PN544_WAKEUP_ACK 5
  45. #define PN544_WAKEUP_GUARD (PN544_WAKEUP_ACK + 1)
  46. #define PN544_INACTIVITY_TIME 1000
  47. #define PN544_INTERFRAME_DELAY 200 /* us */
  48. #define PN544_BAUDRATE_CHANGE 150 /* us */
  49. /* Debug bits */
  50. #define PN544_DEBUG_BUF 0x01
  51. #define PN544_DEBUG_READ 0x02
  52. #define PN544_DEBUG_WRITE 0x04
  53. #define PN544_DEBUG_IRQ 0x08
  54. #define PN544_DEBUG_CALLS 0x10
  55. #define PN544_DEBUG_MODE 0x20
  56. /* Normal (HCI) mode */
  57. #define PN544_LLC_HCI_OVERHEAD 3 /* header + crc (to length) */
  58. #define PN544_LLC_MIN_SIZE (1 + PN544_LLC_HCI_OVERHEAD) /* length + */
  59. #define PN544_LLC_MAX_DATA (PN544_MSG_MAX_SIZE - 2)
  60. #define PN544_LLC_MAX_HCI_SIZE (PN544_LLC_MAX_DATA - 2)
  61. struct pn544_llc_packet {
  62. unsigned char length; /* of rest of packet */
  63. unsigned char header;
  64. unsigned char data[PN544_LLC_MAX_DATA]; /* includes crc-ccitt */
  65. };
  66. /* Firmware upgrade mode */
  67. #define PN544_FW_HEADER_SIZE 3
  68. /* max fw transfer is 1024bytes, but I2C limits it to 0xC0 */
  69. #define PN544_MAX_FW_DATA (PN544_MAX_I2C_TRANSFER - PN544_FW_HEADER_SIZE)
  70. struct pn544_fw_packet {
  71. unsigned char command; /* status in answer */
  72. unsigned char length[2]; /* big-endian order (msf) */
  73. unsigned char data[PN544_MAX_FW_DATA];
  74. };
  75. #ifdef __KERNEL__
  76. enum {
  77. NFC_GPIO_ENABLE,
  78. NFC_GPIO_FW_RESET,
  79. NFC_GPIO_IRQ
  80. };
  81. /* board config */
  82. struct pn544_nfc_platform_data {
  83. int (*request_resources) (struct i2c_client *client);
  84. void (*free_resources) (void);
  85. void (*enable) (int fw);
  86. int (*test) (void);
  87. void (*disable) (void);
  88. int (*get_gpio)(int type);
  89. };
  90. #endif /* __KERNEL__ */
  91. #endif /* _PN544_H_ */