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