forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/iio/dac/ad5686.h
....@@ -1,4 +1,4 @@
1
-/* SPDX-License-Identifier: GPL-2.0+ */
1
+/* SPDX-License-Identifier: GPL-2.0 */
22 /*
33 * This file is part of AD5686 DAC driver
44 *
....@@ -13,7 +13,10 @@
1313 #include <linux/mutex.h>
1414 #include <linux/kernel.h>
1515
16
+#define AD5310_CMD(x) ((x) << 12)
17
+
1618 #define AD5683_DATA(x) ((x) << 4)
19
+
1720 #define AD5686_ADDR(x) ((x) << 16)
1821 #define AD5686_CMD(x) ((x) << 20)
1922
....@@ -38,6 +41,8 @@
3841
3942 #define AD5686_CMD_CONTROL_REG 0x4
4043 #define AD5686_CMD_READBACK_ENABLE_V2 0x5
44
+
45
+#define AD5310_REF_BIT_MSK BIT(8)
4146 #define AD5683_REF_BIT_MSK BIT(12)
4247 #define AD5693_REF_BIT_MSK BIT(12)
4348
....@@ -45,12 +50,15 @@
4550 * ad5686_supported_device_ids:
4651 */
4752 enum ad5686_supported_device_ids {
53
+ ID_AD5310R,
4854 ID_AD5311R,
4955 ID_AD5671R,
5056 ID_AD5672R,
57
+ ID_AD5674R,
5158 ID_AD5675R,
5259 ID_AD5676,
5360 ID_AD5676R,
61
+ ID_AD5679R,
5462 ID_AD5681R,
5563 ID_AD5682R,
5664 ID_AD5683,
....@@ -72,6 +80,7 @@
7280 };
7381
7482 enum ad5686_regmap_type {
83
+ AD5310_REGMAP,
7584 AD5683_REGMAP,
7685 AD5686_REGMAP,
7786 AD5693_REGMAP
....@@ -95,7 +104,7 @@
95104 struct ad5686_chip_info {
96105 u16 int_vref_mv;
97106 unsigned int num_channels;
98
- struct iio_chan_spec *channels;
107
+ const struct iio_chan_spec *channels;
99108 enum ad5686_regmap_type regmap_type;
100109 };
101110
....@@ -108,6 +117,7 @@
108117 * @pwr_down_mask: power down mask
109118 * @pwr_down_mode: current power down mode
110119 * @use_internal_vref: set to true if the internal reference voltage is used
120
+ * @lock lock to protect the data buffer during regmap ops
111121 * @data: spi transfer buffers
112122 */
113123
....@@ -121,6 +131,7 @@
121131 ad5686_write_func write;
122132 ad5686_read_func read;
123133 bool use_internal_vref;
134
+ struct mutex lock;
124135
125136 /*
126137 * DMA (thus cache coherency maintenance) requires the