1 /* SPDX-License-Identifier: GPL-2.0-or-later * 1 2 /* 3 * Generic framer header file 4 * 5 * Copyright 2023 CS GROUP France 6 * 7 * Author: Herve Codina <herve.codina@bootlin. 8 */ 9 10 #ifndef __DRIVERS_FRAMER_H 11 #define __DRIVERS_FRAMER_H 12 13 #include <linux/err.h> 14 #include <linux/mutex.h> 15 #include <linux/notifier.h> 16 #include <linux/of.h> 17 #include <linux/device.h> 18 #include <linux/workqueue.h> 19 20 /** 21 * enum framer_iface - Framer interface 22 * @FRAMER_IFACE_E1: E1 interface 23 * @FRAMER_IFACE_T1: T1 interface 24 */ 25 enum framer_iface { 26 FRAMER_IFACE_E1, 27 FRAMER_IFACE_T1, 28 }; 29 30 /** 31 * enum framer_clock_type - Framer clock type 32 * @FRAMER_CLOCK_EXT: External clock 33 * @FRAMER_CLOCK_INT: Internal clock 34 */ 35 enum framer_clock_type { 36 FRAMER_CLOCK_EXT, 37 FRAMER_CLOCK_INT, 38 }; 39 40 /** 41 * struct framer_config - Framer configuration 42 * @iface: Framer line interface 43 * @clock_type: Framer clock type 44 * @line_clock_rate: Framer line clock rate 45 */ 46 struct framer_config { 47 enum framer_iface iface; 48 enum framer_clock_type clock_type; 49 unsigned long line_clock_rate; 50 }; 51 52 /** 53 * struct framer_status - Framer status 54 * @link_is_on: Framer link state. true, the l 55 */ 56 struct framer_status { 57 bool link_is_on; 58 }; 59 60 /** 61 * enum framer_event - Event available for not 62 * @FRAMER_EVENT_STATUS: Event notified on fra 63 */ 64 enum framer_event { 65 FRAMER_EVENT_STATUS, 66 }; 67 68 /** 69 * struct framer - represents the framer devic 70 * @dev: framer device 71 * @id: id of the framer device 72 * @ops: function pointers for performing fram 73 * @mutex: mutex to protect framer_ops 74 * @init_count: used to protect when the frame 75 * @power_count: used to protect when the fram 76 * @pwr: power regulator associated with the f 77 * @notify_status_work: work structure used fo 78 * @notifier_list: notifier list used for noti 79 * @polling_work: delayed work structure used 80 * @prev_status: previous read status used by 81 */ 82 struct framer { 83 struct device dev; 84 int id; 85 const struct framer_ops *ops; 86 struct mutex mutex; 87 int init_c 88 int power_ 89 struct regulator *pwr; 90 struct work_struct notify 91 struct blocking_notifier_head notifi 92 struct delayed_work pollin 93 struct framer_status prev_s 94 }; 95 96 #if IS_ENABLED(CONFIG_GENERIC_FRAMER) 97 int framer_pm_runtime_get(struct framer *frame 98 int framer_pm_runtime_get_sync(struct framer * 99 int framer_pm_runtime_put(struct framer *frame 100 int framer_pm_runtime_put_sync(struct framer * 101 int framer_init(struct framer *framer); 102 int framer_exit(struct framer *framer); 103 int framer_power_on(struct framer *framer); 104 int framer_power_off(struct framer *framer); 105 int framer_get_status(struct framer *framer, s 106 int framer_get_config(struct framer *framer, s 107 int framer_set_config(struct framer *framer, c 108 int framer_notifier_register(struct framer *fr 109 int framer_notifier_unregister(struct framer * 110 111 struct framer *framer_get(struct device *dev, 112 void framer_put(struct device *dev, struct fra 113 114 struct framer *devm_framer_get(struct device * 115 struct framer *devm_framer_optional_get(struct 116 #else 117 static inline int framer_pm_runtime_get(struct 118 { 119 return -ENOSYS; 120 } 121 122 static inline int framer_pm_runtime_get_sync(s 123 { 124 return -ENOSYS; 125 } 126 127 static inline int framer_pm_runtime_put(struct 128 { 129 return -ENOSYS; 130 } 131 132 static inline int framer_pm_runtime_put_sync(s 133 { 134 return -ENOSYS; 135 } 136 137 static inline int framer_init(struct framer *f 138 { 139 return -ENOSYS; 140 } 141 142 static inline int framer_exit(struct framer *f 143 { 144 return -ENOSYS; 145 } 146 147 static inline int framer_power_on(struct frame 148 { 149 return -ENOSYS; 150 } 151 152 static inline int framer_power_off(struct fram 153 { 154 return -ENOSYS; 155 } 156 157 static inline int framer_get_status(struct fra 158 { 159 return -ENOSYS; 160 } 161 162 static inline int framer_get_config(struct fra 163 { 164 return -ENOSYS; 165 } 166 167 static inline int framer_set_config(struct fra 168 { 169 return -ENOSYS; 170 } 171 172 static inline int framer_notifier_register(str 173 str 174 { 175 return -ENOSYS; 176 } 177 178 static inline int framer_notifier_unregister(s 179 s 180 { 181 return -ENOSYS; 182 } 183 184 static inline struct framer *framer_get(struct 185 { 186 return ERR_PTR(-ENOSYS); 187 } 188 189 static inline void framer_put(struct device *d 190 { 191 } 192 193 static inline struct framer *devm_framer_get(s 194 { 195 return ERR_PTR(-ENOSYS); 196 } 197 198 static inline struct framer *devm_framer_optio 199 { 200 return NULL; 201 } 202 203 #endif 204 205 #endif /* __DRIVERS_FRAMER_H */ 206
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.