viperboard.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * include/linux/mfd/viperboard.h
  3. *
  4. * Nano River Technologies viperboard definitions
  5. *
  6. * (C) 2012 by Lemonage GmbH
  7. * Author: Lars Poeschel <poeschel@lemonage.de>
  8. * All rights reserved.
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License as published by the
  12. * Free Software Foundation; either version 2 of the License, or (at your
  13. * option) any later version.
  14. *
  15. */
  16. #ifndef __MFD_VIPERBOARD_H__
  17. #define __MFD_VIPERBOARD_H__
  18. #include <linux/types.h>
  19. #include <linux/usb.h>
  20. #define VPRBRD_EP_OUT 0x02
  21. #define VPRBRD_EP_IN 0x86
  22. #define VPRBRD_I2C_MSG_LEN 512 /* max length of a msg on USB level */
  23. #define VPRBRD_I2C_FREQ_6MHZ 1 /* 6 MBit/s */
  24. #define VPRBRD_I2C_FREQ_3MHZ 2 /* 3 MBit/s */
  25. #define VPRBRD_I2C_FREQ_1MHZ 3 /* 1 MBit/s */
  26. #define VPRBRD_I2C_FREQ_FAST 4 /* 400 kbit/s */
  27. #define VPRBRD_I2C_FREQ_400KHZ VPRBRD_I2C_FREQ_FAST
  28. #define VPRBRD_I2C_FREQ_200KHZ 5 /* 200 kbit/s */
  29. #define VPRBRD_I2C_FREQ_STD 6 /* 100 kbit/s */
  30. #define VPRBRD_I2C_FREQ_100KHZ VPRBRD_I2C_FREQ_STD
  31. #define VPRBRD_I2C_FREQ_10KHZ 7 /* 10 kbit/s */
  32. #define VPRBRD_I2C_CMD_WRITE 0x00
  33. #define VPRBRD_I2C_CMD_READ 0x01
  34. #define VPRBRD_I2C_CMD_ADDR 0x02
  35. #define VPRBRD_USB_TYPE_OUT 0x40
  36. #define VPRBRD_USB_TYPE_IN 0xc0
  37. #define VPRBRD_USB_TIMEOUT_MS 100
  38. #define VPRBRD_USB_REQUEST_I2C_FREQ 0xe6
  39. #define VPRBRD_USB_REQUEST_I2C 0xe9
  40. #define VPRBRD_USB_REQUEST_MAJOR 0xea
  41. #define VPRBRD_USB_REQUEST_MINOR 0xeb
  42. #define VPRBRD_USB_REQUEST_ADC 0xec
  43. #define VPRBRD_USB_REQUEST_GPIOA 0xed
  44. #define VPRBRD_USB_REQUEST_GPIOB 0xdd
  45. struct vprbrd_i2c_write_hdr {
  46. u8 cmd;
  47. u16 addr;
  48. u8 len1;
  49. u8 len2;
  50. u8 last;
  51. u8 chan;
  52. u16 spi;
  53. } __packed;
  54. struct vprbrd_i2c_read_hdr {
  55. u8 cmd;
  56. u16 addr;
  57. u8 len0;
  58. u8 len1;
  59. u8 len2;
  60. u8 len3;
  61. u8 len4;
  62. u8 len5;
  63. u16 tf1; /* transfer 1 length */
  64. u16 tf2; /* transfer 2 length */
  65. } __packed;
  66. struct vprbrd_i2c_status {
  67. u8 unknown[11];
  68. u8 status;
  69. } __packed;
  70. struct vprbrd_i2c_write_msg {
  71. struct vprbrd_i2c_write_hdr header;
  72. u8 data[VPRBRD_I2C_MSG_LEN
  73. - sizeof(struct vprbrd_i2c_write_hdr)];
  74. } __packed;
  75. struct vprbrd_i2c_read_msg {
  76. struct vprbrd_i2c_read_hdr header;
  77. u8 data[VPRBRD_I2C_MSG_LEN
  78. - sizeof(struct vprbrd_i2c_read_hdr)];
  79. } __packed;
  80. struct vprbrd_i2c_addr_msg {
  81. u8 cmd;
  82. u8 addr;
  83. u8 unknown1;
  84. u16 len;
  85. u8 unknown2;
  86. u8 unknown3;
  87. } __packed;
  88. /* Structure to hold all device specific stuff */
  89. struct vprbrd {
  90. struct usb_device *usb_dev; /* the usb device for this device */
  91. struct mutex lock;
  92. u8 buf[sizeof(struct vprbrd_i2c_write_msg)];
  93. struct platform_device pdev;
  94. };
  95. #endif /* __MFD_VIPERBOARD_H__ */