Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at ee9dce44362b2d8132c32964656ab6dff7dfbc6a 204 lines 5.2 kB view raw
1/* SPDX-License-Identifier: GPL-2.0-or-later */ 2/* 3 * Generic framer header file 4 * 5 * Copyright 2023 CS GROUP France 6 * 7 * Author: Herve Codina <herve.codina@bootlin.com> 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 */ 25enum 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 */ 35enum 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 */ 46struct 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 link is on, false, the link is off. 55 */ 56struct framer_status { 57 bool link_is_on; 58}; 59 60/** 61 * enum framer_event - Event available for notification 62 * @FRAMER_EVENT_STATUS: Event notified on framer_status changes 63 */ 64enum framer_event { 65 FRAMER_EVENT_STATUS, 66}; 67 68/** 69 * struct framer - represents the framer device 70 * @dev: framer device 71 * @id: id of the framer device 72 * @ops: function pointers for performing framer operations 73 * @mutex: mutex to protect framer_ops 74 * @init_count: used to protect when the framer is used by multiple consumers 75 * @power_count: used to protect when the framer is used by multiple consumers 76 * @pwr: power regulator associated with the framer 77 * @notify_status_work: work structure used for status notifications 78 * @notifier_list: notifier list used for notifications 79 * @polling_work: delayed work structure used for the polling task 80 * @prev_status: previous read status used by the polling task to detect changes 81 */ 82struct framer { 83 struct device dev; 84 int id; 85 const struct framer_ops *ops; 86 struct mutex mutex; /* Protect framer */ 87 int init_count; 88 int power_count; 89 struct regulator *pwr; 90 struct work_struct notify_status_work; 91 struct blocking_notifier_head notifier_list; 92 struct delayed_work polling_work; 93 struct framer_status prev_status; 94}; 95 96#if IS_ENABLED(CONFIG_GENERIC_FRAMER) 97int framer_pm_runtime_get(struct framer *framer); 98int framer_pm_runtime_get_sync(struct framer *framer); 99void framer_pm_runtime_put(struct framer *framer); 100int framer_pm_runtime_put_sync(struct framer *framer); 101int framer_init(struct framer *framer); 102int framer_exit(struct framer *framer); 103int framer_power_on(struct framer *framer); 104int framer_power_off(struct framer *framer); 105int framer_get_status(struct framer *framer, struct framer_status *status); 106int framer_get_config(struct framer *framer, struct framer_config *config); 107int framer_set_config(struct framer *framer, const struct framer_config *config); 108int framer_notifier_register(struct framer *framer, struct notifier_block *nb); 109int framer_notifier_unregister(struct framer *framer, struct notifier_block *nb); 110 111struct framer *framer_get(struct device *dev, const char *con_id); 112void framer_put(struct device *dev, struct framer *framer); 113 114struct framer *devm_framer_get(struct device *dev, const char *con_id); 115struct framer *devm_framer_optional_get(struct device *dev, const char *con_id); 116#else 117static inline int framer_pm_runtime_get(struct framer *framer) 118{ 119 return -ENOSYS; 120} 121 122static inline int framer_pm_runtime_get_sync(struct framer *framer) 123{ 124 return -ENOSYS; 125} 126 127static inline void framer_pm_runtime_put(struct framer *framer) 128{ 129} 130 131static inline int framer_pm_runtime_put_sync(struct framer *framer) 132{ 133 return -ENOSYS; 134} 135 136static inline int framer_init(struct framer *framer) 137{ 138 return -ENOSYS; 139} 140 141static inline int framer_exit(struct framer *framer) 142{ 143 return -ENOSYS; 144} 145 146static inline int framer_power_on(struct framer *framer) 147{ 148 return -ENOSYS; 149} 150 151static inline int framer_power_off(struct framer *framer) 152{ 153 return -ENOSYS; 154} 155 156static inline int framer_get_status(struct framer *framer, struct framer_status *status) 157{ 158 return -ENOSYS; 159} 160 161static inline int framer_get_config(struct framer *framer, struct framer_config *config) 162{ 163 return -ENOSYS; 164} 165 166static inline int framer_set_config(struct framer *framer, const struct framer_config *config) 167{ 168 return -ENOSYS; 169} 170 171static inline int framer_notifier_register(struct framer *framer, 172 struct notifier_block *nb) 173{ 174 return -ENOSYS; 175} 176 177static inline int framer_notifier_unregister(struct framer *framer, 178 struct notifier_block *nb) 179{ 180 return -ENOSYS; 181} 182 183static inline struct framer *framer_get(struct device *dev, const char *con_id) 184{ 185 return ERR_PTR(-ENOSYS); 186} 187 188static inline void framer_put(struct device *dev, struct framer *framer) 189{ 190} 191 192static inline struct framer *devm_framer_get(struct device *dev, const char *con_id) 193{ 194 return ERR_PTR(-ENOSYS); 195} 196 197static inline struct framer *devm_framer_optional_get(struct device *dev, const char *con_id) 198{ 199 return NULL; 200} 201 202#endif 203 204#endif /* __DRIVERS_FRAMER_H */