1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Copyright 2020 Samsung Electronics Co., Ltd.
4 * Copyright 2020 Google LLC.
5 * Copyright 2024 Linaro Ltd.
6 */
7
8 #ifndef __EXYNOS_ACPM_PROTOCOL_H
9 #define __EXYNOS_ACPM_PROTOCOL_H
10
11 #include <linux/types.h>
12
13 struct acpm_handle;
14 struct device_node;
15
16 struct acpm_dvfs_ops {
17 int (*set_rate)(const struct acpm_handle *handle,
18 unsigned int acpm_chan_id, unsigned int clk_id,
19 unsigned long rate);
20 unsigned long (*get_rate)(const struct acpm_handle *handle,
21 unsigned int acpm_chan_id,
22 unsigned int clk_id);
23 };
24
25 struct acpm_pmic_ops {
26 int (*read_reg)(const struct acpm_handle *handle,
27 unsigned int acpm_chan_id, u8 type, u8 reg, u8 chan,
28 u8 *buf);
29 int (*bulk_read)(const struct acpm_handle *handle,
30 unsigned int acpm_chan_id, u8 type, u8 reg, u8 chan,
31 u8 count, u8 *buf);
32 int (*write_reg)(const struct acpm_handle *handle,
33 unsigned int acpm_chan_id, u8 type, u8 reg, u8 chan,
34 u8 value);
35 int (*bulk_write)(const struct acpm_handle *handle,
36 unsigned int acpm_chan_id, u8 type, u8 reg, u8 chan,
37 u8 count, const u8 *buf);
38 int (*update_reg)(const struct acpm_handle *handle,
39 unsigned int acpm_chan_id, u8 type, u8 reg, u8 chan,
40 u8 value, u8 mask);
41 };
42
43 struct acpm_ops {
44 struct acpm_dvfs_ops dvfs_ops;
45 struct acpm_pmic_ops pmic_ops;
46 };
47
48 /**
49 * struct acpm_handle - Reference to an initialized protocol instance
50 * @ops:
51 */
52 struct acpm_handle {
53 struct acpm_ops ops;
54 };
55
56 struct device;
57
58 #if IS_ENABLED(CONFIG_EXYNOS_ACPM_PROTOCOL)
59 const struct acpm_handle *devm_acpm_get_by_node(struct device *dev,
60 struct device_node *np);
61 #else
62
devm_acpm_get_by_node(struct device * dev,struct device_node * np)63 static inline const struct acpm_handle *devm_acpm_get_by_node(struct device *dev,
64 struct device_node *np)
65 {
66 return NULL;
67 }
68 #endif
69
70 #endif /* __EXYNOS_ACPM_PROTOCOL_H */
71