kempld.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * Kontron PLD driver definitions
  3. *
  4. * Copyright (c) 2010-2012 Kontron Europe GmbH
  5. * Author: Michael Brunner <michael.brunner@kontron.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License 2 as published
  9. * by the Free Software Foundation.
  10. */
  11. #ifndef _LINUX_MFD_KEMPLD_H_
  12. #define _LINUX_MFD_KEMPLD_H_
  13. /* kempld register definitions */
  14. #define KEMPLD_IOINDEX 0xa80
  15. #define KEMPLD_IODATA 0xa81
  16. #define KEMPLD_MUTEX_KEY 0x80
  17. #define KEMPLD_VERSION 0x00
  18. #define KEMPLD_VERSION_LSB 0x00
  19. #define KEMPLD_VERSION_MSB 0x01
  20. #define KEMPLD_VERSION_GET_MINOR(x) (x & 0x1f)
  21. #define KEMPLD_VERSION_GET_MAJOR(x) ((x >> 5) & 0x1f)
  22. #define KEMPLD_VERSION_GET_NUMBER(x) ((x >> 10) & 0xf)
  23. #define KEMPLD_VERSION_GET_TYPE(x) ((x >> 14) & 0x3)
  24. #define KEMPLD_BUILDNR 0x02
  25. #define KEMPLD_BUILDNR_LSB 0x02
  26. #define KEMPLD_BUILDNR_MSB 0x03
  27. #define KEMPLD_FEATURE 0x04
  28. #define KEMPLD_FEATURE_LSB 0x04
  29. #define KEMPLD_FEATURE_MSB 0x05
  30. #define KEMPLD_FEATURE_BIT_I2C (1 << 0)
  31. #define KEMPLD_FEATURE_BIT_WATCHDOG (1 << 1)
  32. #define KEMPLD_FEATURE_BIT_GPIO (1 << 2)
  33. #define KEMPLD_FEATURE_MASK_UART (7 << 3)
  34. #define KEMPLD_FEATURE_BIT_NMI (1 << 8)
  35. #define KEMPLD_FEATURE_BIT_SMI (1 << 9)
  36. #define KEMPLD_FEATURE_BIT_SCI (1 << 10)
  37. #define KEMPLD_SPEC 0x06
  38. #define KEMPLD_SPEC_GET_MINOR(x) (x & 0x0f)
  39. #define KEMPLD_SPEC_GET_MAJOR(x) ((x >> 4) & 0x0f)
  40. #define KEMPLD_IRQ_GPIO 0x35
  41. #define KEMPLD_IRQ_I2C 0x36
  42. #define KEMPLD_CFG 0x37
  43. #define KEMPLD_CFG_GPIO_I2C_MUX (1 << 0)
  44. #define KEMPLD_CFG_BIOS_WP (1 << 7)
  45. #define KEMPLD_CLK 33333333
  46. #define KEMPLD_TYPE_RELEASE 0x0
  47. #define KEMPLD_TYPE_DEBUG 0x1
  48. #define KEMPLD_TYPE_CUSTOM 0x2
  49. #define KEMPLD_VERSION_LEN 10
  50. /**
  51. * struct kempld_info - PLD device information structure
  52. * @major: PLD major revision
  53. * @minor: PLD minor revision
  54. * @buildnr: PLD build number
  55. * @number: PLD board specific index
  56. * @type: PLD type
  57. * @spec_major: PLD FW specification major revision
  58. * @spec_minor: PLD FW specification minor revision
  59. * @version: PLD version string
  60. */
  61. struct kempld_info {
  62. unsigned int major;
  63. unsigned int minor;
  64. unsigned int buildnr;
  65. unsigned int number;
  66. unsigned int type;
  67. unsigned int spec_major;
  68. unsigned int spec_minor;
  69. char version[KEMPLD_VERSION_LEN];
  70. };
  71. /**
  72. * struct kempld_device_data - Internal representation of the PLD device
  73. * @io_base: Pointer to the IO memory
  74. * @io_index: Pointer to the IO index register
  75. * @io_data: Pointer to the IO data register
  76. * @pld_clock: PLD clock frequency
  77. * @feature_mask: PLD feature mask
  78. * @dev: Pointer to kernel device structure
  79. * @info: KEMPLD info structure
  80. * @lock: PLD mutex
  81. */
  82. struct kempld_device_data {
  83. void __iomem *io_base;
  84. void __iomem *io_index;
  85. void __iomem *io_data;
  86. u32 pld_clock;
  87. u32 feature_mask;
  88. struct device *dev;
  89. struct kempld_info info;
  90. struct mutex lock;
  91. };
  92. /**
  93. * struct kempld_platform_data - PLD hardware configuration structure
  94. * @pld_clock: PLD clock frequency
  95. * @gpio_base GPIO base pin number
  96. * @ioresource: IO addresses of the PLD
  97. * @get_mutex: PLD specific get_mutex callback
  98. * @release_mutex: PLD specific release_mutex callback
  99. * @get_info: PLD specific get_info callback
  100. * @register_cells: PLD specific register_cells callback
  101. */
  102. struct kempld_platform_data {
  103. u32 pld_clock;
  104. int gpio_base;
  105. struct resource *ioresource;
  106. void (*get_hardware_mutex) (struct kempld_device_data *);
  107. void (*release_hardware_mutex) (struct kempld_device_data *);
  108. int (*get_info) (struct kempld_device_data *);
  109. int (*register_cells) (struct kempld_device_data *);
  110. };
  111. extern void kempld_get_mutex(struct kempld_device_data *pld);
  112. extern void kempld_release_mutex(struct kempld_device_data *pld);
  113. extern u8 kempld_read8(struct kempld_device_data *pld, u8 index);
  114. extern void kempld_write8(struct kempld_device_data *pld, u8 index, u8 data);
  115. extern u16 kempld_read16(struct kempld_device_data *pld, u8 index);
  116. extern void kempld_write16(struct kempld_device_data *pld, u8 index, u16 data);
  117. extern u32 kempld_read32(struct kempld_device_data *pld, u8 index);
  118. extern void kempld_write32(struct kempld_device_data *pld, u8 index, u32 data);
  119. #endif /* _LINUX_MFD_KEMPLD_H_ */