1/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */ 2/* 3 * Copyright (C) 2017-2020 Mellanox Technologies Ltd. 4 */ 5 6#ifndef __LINUX_PLATFORM_DATA_MLXREG_H 7#define __LINUX_PLATFORM_DATA_MLXREG_H 8 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) 12 13/** 14 * enum mlxreg_wdt_type - type of HW watchdog 15 * 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. 20 */ 21enum mlxreg_wdt_type { 22 MLX_WDT_TYPE1, 23 MLX_WDT_TYPE2, 24 MLX_WDT_TYPE3, 25}; 26 27/** 28 * struct mlxreg_hotplug_device - I2C device data: 29 * 30 * @adapter: I2C device adapter; 31 * @client: I2C device client; 32 * @brdinfo: device board information; 33 * @nr: I2C device adapter number, to which device is to be attached; 34 * 35 * Structure represents I2C hotplug device static data (board topology) and 36 * dynamic data (related kernel objects handles). 37 */ 38struct mlxreg_hotplug_device { 39 struct i2c_adapter *adapter; 40 struct i2c_client *client; 41 struct i2c_board_info *brdinfo; 42 int nr; 43}; 44 45/** 46 * struct mlxreg_core_data - attributes control data: 47 * 48 * @label: attribute label; 49 * @reg: attribute register; 50 * @mask: attribute access mask; 51 * @bit: attribute effective bit; 52 * @capability: attribute capability register; 53 * @reg_prsnt: attribute presence register; 54 * @mode: access mode; 55 * @np - pointer to node platform associated with attribute; 56 * @hpdev - hotplug device data; 57 * @health_cntr: dynamic device health indication counter; 58 * @attached: true if device has been attached after good health indication; 59 * @regnum: number of registers occupied by multi-register attribute; 60 */ 61struct mlxreg_core_data { 62 char label[MLXREG_CORE_LABEL_MAX_SIZE]; 63 u32 reg; 64 u32 mask; 65 u32 bit; 66 u32 capability; 67 u32 reg_prsnt; 68 umode_t mode; 69 struct device_node *np; 70 struct mlxreg_hotplug_device hpdev; 71 u32 health_cntr; 72 bool attached; 73 u8 regnum; 74}; 75 76/** 77 * struct mlxreg_core_item - same type components controlled by the driver: 78 * 79 * @data: component data; 80 * @aggr_mask: group aggregation mask; 81 * @reg: group interrupt status register; 82 * @mask: group interrupt mask; 83 * @capability: group capability register; 84 * @cache: last status value for elements fro the same group; 85 * @count: number of available elements in the group; 86 * @ind: element's index inside the group; 87 * @inversed: if 0: 0 for signal status is OK, if 1 - 1 is OK; 88 * @health: true if device has health indication, false in other case; 89 */ 90struct mlxreg_core_item { 91 struct mlxreg_core_data *data; 92 u32 aggr_mask; 93 u32 reg; 94 u32 mask; 95 u32 capability; 96 u32 cache; 97 u8 count; 98 u8 ind; 99 u8 inversed; 100 u8 health; 101}; 102 103/** 104 * struct mlxreg_core_platform_data - platform data: 105 * 106 * @data: instance private data; 107 * @regmap: register map of parent device; 108 * @counter: number of instances; 109 * @features: supported features of device; 110 * @version: implementation version; 111 * @identity: device identity name; 112 * @capability: device capability register; 113 */ 114struct mlxreg_core_platform_data { 115 struct mlxreg_core_data *data; 116 void *regmap; 117 int counter; 118 u32 features; 119 u32 version; 120 char identity[MLXREG_CORE_LABEL_MAX_SIZE]; 121 u32 capability; 122}; 123 124/** 125 * struct mlxreg_core_hotplug_platform_data - hotplug platform data: 126 * 127 * @items: same type components with the hotplug capability; 128 * @irq: platform interrupt number; 129 * @regmap: register map of parent device; 130 * @counter: number of the components with the hotplug capability; 131 * @cell: location of top aggregation interrupt register; 132 * @mask: top aggregation interrupt common mask; 133 * @cell_low: location of low aggregation interrupt register; 134 * @mask_low: low aggregation interrupt common mask; 135 * @deferred_nr: I2C adapter number must be exist prior probing execution; 136 * @shift_nr: I2C adapter numbers must be incremented by this value; 137 */ 138struct mlxreg_core_hotplug_platform_data { 139 struct mlxreg_core_item *items; 140 int irq; 141 void *regmap; 142 int counter; 143 u32 cell; 144 u32 mask; 145 u32 cell_low; 146 u32 mask_low; 147 int deferred_nr; 148 int shift_nr; 149}; 150 151#endif /* __LINUX_PLATFORM_DATA_MLXREG_H */ 152