c_can.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * CAN bus driver for Bosch C_CAN controller
  3. *
  4. * Copyright (C) 2010 ST Microelectronics
  5. * Bhupesh Sharma <bhupesh.sharma@st.com>
  6. *
  7. * Borrowed heavily from the C_CAN driver originally written by:
  8. * Copyright (C) 2007
  9. * - Sascha Hauer, Marc Kleine-Budde, Pengutronix <s.hauer@pengutronix.de>
  10. * - Simon Kallweit, intefo AG <simon.kallweit@intefo.ch>
  11. *
  12. * Bosch C_CAN controller is compliant to CAN protocol version 2.0 part A and B.
  13. * Bosch C_CAN user manual can be obtained from:
  14. * http://www.semiconductors.bosch.de/media/en/pdf/ipmodules_1/c_can/
  15. * users_manual_c_can.pdf
  16. *
  17. * This file is licensed under the terms of the GNU General Public
  18. * License version 2. This program is licensed "as is" without any
  19. * warranty of any kind, whether express or implied.
  20. */
  21. #ifndef C_CAN_H
  22. #define C_CAN_H
  23. /* c_can IF registers */
  24. struct c_can_if_regs {
  25. u16 com_req;
  26. u16 com_mask;
  27. u16 mask1;
  28. u16 mask2;
  29. u16 arb1;
  30. u16 arb2;
  31. u16 msg_cntrl;
  32. u16 data[4];
  33. u16 _reserved[13];
  34. };
  35. /* c_can hardware registers */
  36. struct c_can_regs {
  37. u16 control;
  38. u16 status;
  39. u16 err_cnt;
  40. u16 btr;
  41. u16 interrupt;
  42. u16 test;
  43. u16 brp_ext;
  44. u16 _reserved1;
  45. struct c_can_if_regs ifregs[2]; /* [0] = IF1 and [1] = IF2 */
  46. u16 _reserved2[8];
  47. u16 txrqst1;
  48. u16 txrqst2;
  49. u16 _reserved3[6];
  50. u16 newdat1;
  51. u16 newdat2;
  52. u16 _reserved4[6];
  53. u16 intpnd1;
  54. u16 intpnd2;
  55. u16 _reserved5[6];
  56. u16 msgval1;
  57. u16 msgval2;
  58. u16 _reserved6[6];
  59. };
  60. /* c_can private data structure */
  61. struct c_can_priv {
  62. struct can_priv can; /* must be the first member */
  63. struct napi_struct napi;
  64. struct net_device *dev;
  65. int tx_object;
  66. int current_status;
  67. int last_status;
  68. u16 (*read_reg) (struct c_can_priv *priv, void *reg);
  69. void (*write_reg) (struct c_can_priv *priv, void *reg, u16 val);
  70. struct c_can_regs __iomem *regs;
  71. unsigned long irq_flags; /* for request_irq() */
  72. unsigned int tx_next;
  73. unsigned int tx_echo;
  74. void *priv; /* for board-specific data */
  75. };
  76. struct net_device *alloc_c_can_dev(void);
  77. void free_c_can_dev(struct net_device *dev);
  78. int register_c_can_dev(struct net_device *dev);
  79. void unregister_c_can_dev(struct net_device *dev);
  80. #endif /* C_CAN_H */