kempld.h 4.0 KB

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