mlxreg.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
  2. /*
  3. * Copyright (C) 2017-2020 Mellanox Technologies Ltd.
  4. */
  5. #ifndef __LINUX_PLATFORM_DATA_MLXREG_H
  6. #define __LINUX_PLATFORM_DATA_MLXREG_H
  7. #define MLXREG_CORE_LABEL_MAX_SIZE 32
  8. #define MLXREG_CORE_WD_FEATURE_NOWAYOUT BIT(0)
  9. #define MLXREG_CORE_WD_FEATURE_START_AT_BOOT BIT(1)
  10. /**
  11. * enum mlxreg_wdt_type - type of HW watchdog
  12. *
  13. * TYPE1 HW watchdog implementation exist in old systems.
  14. * All new systems have TYPE2 HW watchdog.
  15. * TYPE3 HW watchdog can exist on all systems with new CPLD.
  16. * TYPE3 is selected by WD capability bit.
  17. */
  18. enum mlxreg_wdt_type {
  19. MLX_WDT_TYPE1,
  20. MLX_WDT_TYPE2,
  21. MLX_WDT_TYPE3,
  22. };
  23. /**
  24. * enum mlxreg_hotplug_kind - kind of hotplug entry
  25. *
  26. * @MLXREG_HOTPLUG_DEVICE_NA: do not care;
  27. * @MLXREG_HOTPLUG_LC_PRESENT: entry for line card presence in/out events;
  28. * @MLXREG_HOTPLUG_LC_VERIFIED: entry for line card verification status events
  29. * coming after line card security signature validation;
  30. * @MLXREG_HOTPLUG_LC_POWERED: entry for line card power on/off events;
  31. * @MLXREG_HOTPLUG_LC_SYNCED: entry for line card synchronization events, coming
  32. * after hardware-firmware synchronization handshake;
  33. * @MLXREG_HOTPLUG_LC_READY: entry for line card ready events, indicating line card
  34. PHYs ready / unready state;
  35. * @MLXREG_HOTPLUG_LC_ACTIVE: entry for line card active events, indicating firmware
  36. * availability / unavailability for the ports on line card;
  37. * @MLXREG_HOTPLUG_LC_THERMAL: entry for line card thermal shutdown events, positive
  38. * event indicates that system should power off the line
  39. * card for which this event has been received;
  40. */
  41. enum mlxreg_hotplug_kind {
  42. MLXREG_HOTPLUG_DEVICE_NA = 0,
  43. MLXREG_HOTPLUG_LC_PRESENT = 1,
  44. MLXREG_HOTPLUG_LC_VERIFIED = 2,
  45. MLXREG_HOTPLUG_LC_POWERED = 3,
  46. MLXREG_HOTPLUG_LC_SYNCED = 4,
  47. MLXREG_HOTPLUG_LC_READY = 5,
  48. MLXREG_HOTPLUG_LC_ACTIVE = 6,
  49. MLXREG_HOTPLUG_LC_THERMAL = 7,
  50. };
  51. /**
  52. * enum mlxreg_hotplug_device_action - hotplug device action required for
  53. * driver's connectivity
  54. *
  55. * @MLXREG_HOTPLUG_DEVICE_DEFAULT_ACTION: probe device for 'on' event, remove
  56. * for 'off' event;
  57. * @MLXREG_HOTPLUG_DEVICE_PLATFORM_ACTION: probe platform device for 'on'
  58. * event, remove for 'off' event;
  59. * @MLXREG_HOTPLUG_DEVICE_NO_ACTION: no connectivity action is required;
  60. */
  61. enum mlxreg_hotplug_device_action {
  62. MLXREG_HOTPLUG_DEVICE_DEFAULT_ACTION = 0,
  63. MLXREG_HOTPLUG_DEVICE_PLATFORM_ACTION = 1,
  64. MLXREG_HOTPLUG_DEVICE_NO_ACTION = 2,
  65. };
  66. /**
  67. * struct mlxreg_core_hotplug_notifier - hotplug notifier block:
  68. *
  69. * @identity: notifier identity name;
  70. * @handle: user handle to be passed by user handler function;
  71. * @user_handler: user handler function associated with the event;
  72. */
  73. struct mlxreg_core_hotplug_notifier {
  74. char identity[MLXREG_CORE_LABEL_MAX_SIZE];
  75. void *handle;
  76. int (*user_handler)(void *handle, enum mlxreg_hotplug_kind kind, u8 action);
  77. };
  78. /**
  79. * struct mlxreg_hotplug_device - I2C device data:
  80. *
  81. * @adapter: I2C device adapter;
  82. * @client: I2C device client;
  83. * @brdinfo: device board information;
  84. * @nr: I2C device adapter number, to which device is to be attached;
  85. * @pdev: platform device, if device is instantiated as a platform device;
  86. * @action: action to be performed upon event receiving;
  87. * @handle: user handle to be passed by user handler function;
  88. * @user_handler: user handler function associated with the event;
  89. * @notifier: pointer to event notifier block;
  90. *
  91. * Structure represents I2C hotplug device static data (board topology) and
  92. * dynamic data (related kernel objects handles).
  93. */
  94. struct mlxreg_hotplug_device {
  95. struct i2c_adapter *adapter;
  96. struct i2c_client *client;
  97. struct i2c_board_info *brdinfo;
  98. int nr;
  99. struct platform_device *pdev;
  100. enum mlxreg_hotplug_device_action action;
  101. void *handle;
  102. int (*user_handler)(void *handle, enum mlxreg_hotplug_kind kind, u8 action);
  103. struct mlxreg_core_hotplug_notifier *notifier;
  104. };
  105. /**
  106. * struct mlxreg_core_data - attributes control data:
  107. *
  108. * @label: attribute label;
  109. * @reg: attribute register;
  110. * @mask: attribute access mask;
  111. * @bit: attribute effective bit;
  112. * @capability: attribute capability register;
  113. * @reg_prsnt: attribute presence register;
  114. * @reg_sync: attribute synch register;
  115. * @reg_pwr: attribute power register;
  116. * @reg_ena: attribute enable register;
  117. * @mode: access mode;
  118. * @np - pointer to node platform associated with attribute;
  119. * @hpdev - hotplug device data;
  120. * @notifier: pointer to event notifier block;
  121. * @health_cntr: dynamic device health indication counter;
  122. * @attached: true if device has been attached after good health indication;
  123. * @regnum: number of registers occupied by multi-register attribute;
  124. * @slot: slot number, at which device is located;
  125. * @secured: if set indicates that entry access is secured;
  126. */
  127. struct mlxreg_core_data {
  128. char label[MLXREG_CORE_LABEL_MAX_SIZE];
  129. u32 reg;
  130. u32 mask;
  131. u32 bit;
  132. u32 capability;
  133. u32 reg_prsnt;
  134. u32 reg_sync;
  135. u32 reg_pwr;
  136. u32 reg_ena;
  137. umode_t mode;
  138. struct device_node *np;
  139. struct mlxreg_hotplug_device hpdev;
  140. struct mlxreg_core_hotplug_notifier *notifier;
  141. u32 health_cntr;
  142. bool attached;
  143. u8 regnum;
  144. u8 slot;
  145. u8 secured;
  146. };
  147. /**
  148. * struct mlxreg_core_item - same type components controlled by the driver:
  149. *
  150. * @data: component data;
  151. * @kind: kind of hotplug attribute;
  152. * @aggr_mask: group aggregation mask;
  153. * @reg: group interrupt status register;
  154. * @mask: group interrupt mask;
  155. * @capability: group capability register;
  156. * @cache: last status value for elements fro the same group;
  157. * @count: number of available elements in the group;
  158. * @ind: element's index inside the group;
  159. * @inversed: if 0: 0 for signal status is OK, if 1 - 1 is OK;
  160. * @health: true if device has health indication, false in other case;
  161. */
  162. struct mlxreg_core_item {
  163. struct mlxreg_core_data *data;
  164. enum mlxreg_hotplug_kind kind;
  165. u32 aggr_mask;
  166. u32 reg;
  167. u32 mask;
  168. u32 capability;
  169. u32 cache;
  170. u8 count;
  171. u8 ind;
  172. u8 inversed;
  173. u8 health;
  174. };
  175. /**
  176. * struct mlxreg_core_platform_data - platform data:
  177. *
  178. * @data: instance private data;
  179. * @regmap: register map of parent device;
  180. * @counter: number of instances;
  181. * @features: supported features of device;
  182. * @version: implementation version;
  183. * @identity: device identity name;
  184. * @capability: device capability register;
  185. */
  186. struct mlxreg_core_platform_data {
  187. struct mlxreg_core_data *data;
  188. void *regmap;
  189. int counter;
  190. u32 features;
  191. u32 version;
  192. char identity[MLXREG_CORE_LABEL_MAX_SIZE];
  193. u32 capability;
  194. };
  195. /**
  196. * struct mlxreg_core_hotplug_platform_data - hotplug platform data:
  197. *
  198. * @items: same type components with the hotplug capability;
  199. * @irq: platform interrupt number;
  200. * @regmap: register map of parent device;
  201. * @counter: number of the components with the hotplug capability;
  202. * @cell: location of top aggregation interrupt register;
  203. * @mask: top aggregation interrupt common mask;
  204. * @cell_low: location of low aggregation interrupt register;
  205. * @mask_low: low aggregation interrupt common mask;
  206. * @deferred_nr: I2C adapter number must be exist prior probing execution;
  207. * @shift_nr: I2C adapter numbers must be incremented by this value;
  208. * @handle: handle to be passed by callback;
  209. * @completion_notify: callback to notify when platform driver probing is done;
  210. */
  211. struct mlxreg_core_hotplug_platform_data {
  212. struct mlxreg_core_item *items;
  213. int irq;
  214. void *regmap;
  215. int counter;
  216. u32 cell;
  217. u32 mask;
  218. u32 cell_low;
  219. u32 mask_low;
  220. int deferred_nr;
  221. int shift_nr;
  222. void *handle;
  223. int (*completion_notify)(void *handle, int id);
  224. };
  225. #endif /* __LINUX_PLATFORM_DATA_MLXREG_H */