aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/iio
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/iio')
-rw-r--r--include/linux/iio/buffer.h22
-rw-r--r--include/linux/iio/consumer.h34
-rw-r--r--include/linux/iio/dac/ad5421.h28
-rw-r--r--include/linux/iio/dac/ad5504.h16
-rw-r--r--include/linux/iio/dac/ad5791.h25
-rw-r--r--include/linux/iio/dac/max517.h15
-rw-r--r--include/linux/iio/dac/mcp4725.h16
-rw-r--r--include/linux/iio/events.h6
-rw-r--r--include/linux/iio/frequency/ad9523.h195
-rw-r--r--include/linux/iio/frequency/adf4350.h126
-rw-r--r--include/linux/iio/iio.h108
-rw-r--r--include/linux/iio/machine.h2
-rw-r--r--include/linux/iio/sysfs.h2
-rw-r--r--include/linux/iio/triggered_buffer.h15
-rw-r--r--include/linux/iio/types.h8
15 files changed, 572 insertions, 46 deletions
diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h
index fb0fe46fd659..8ba516fc2ec6 100644
--- a/include/linux/iio/buffer.h
+++ b/include/linux/iio/buffer.h
@@ -85,7 +85,7 @@ struct iio_buffer {
85 85
86/** 86/**
87 * iio_buffer_init() - Initialize the buffer structure 87 * iio_buffer_init() - Initialize the buffer structure
88 * @buffer: buffer to be initialized 88 * @buffer: buffer to be initialized
89 **/ 89 **/
90void iio_buffer_init(struct iio_buffer *buffer); 90void iio_buffer_init(struct iio_buffer *buffer);
91 91
@@ -107,8 +107,9 @@ int iio_scan_mask_query(struct iio_dev *indio_dev,
107 107
108/** 108/**
109 * iio_scan_mask_set() - set particular bit in the scan mask 109 * iio_scan_mask_set() - set particular bit in the scan mask
110 * @buffer: the buffer whose scan mask we are interested in 110 * @indio_dev IIO device structure
111 * @bit: the bit to be set. 111 * @buffer: the buffer whose scan mask we are interested in
112 * @bit: the bit to be set.
112 **/ 113 **/
113int iio_scan_mask_set(struct iio_dev *indio_dev, 114int iio_scan_mask_set(struct iio_dev *indio_dev,
114 struct iio_buffer *buffer, int bit); 115 struct iio_buffer *buffer, int bit);
@@ -116,8 +117,8 @@ int iio_scan_mask_set(struct iio_dev *indio_dev,
116/** 117/**
117 * iio_push_to_buffer() - push to a registered buffer. 118 * iio_push_to_buffer() - push to a registered buffer.
118 * @buffer: IIO buffer structure for device 119 * @buffer: IIO buffer structure for device
119 * @scan: Full scan. 120 * @data: the data to push to the buffer
120 * @timestamp: 121 * @timestamp: timestamp to associate with the data
121 */ 122 */
122int iio_push_to_buffer(struct iio_buffer *buffer, unsigned char *data, 123int iio_push_to_buffer(struct iio_buffer *buffer, unsigned char *data,
123 s64 timestamp); 124 s64 timestamp);
@@ -126,7 +127,9 @@ int iio_update_demux(struct iio_dev *indio_dev);
126 127
127/** 128/**
128 * iio_buffer_register() - register the buffer with IIO core 129 * iio_buffer_register() - register the buffer with IIO core
129 * @indio_dev: device with the buffer to be registered 130 * @indio_dev: device with the buffer to be registered
131 * @channels: the channel descriptions used to construct buffer
132 * @num_channels: the number of channels
130 **/ 133 **/
131int iio_buffer_register(struct iio_dev *indio_dev, 134int iio_buffer_register(struct iio_dev *indio_dev,
132 const struct iio_chan_spec *channels, 135 const struct iio_chan_spec *channels,
@@ -134,7 +137,7 @@ int iio_buffer_register(struct iio_dev *indio_dev,
134 137
135/** 138/**
136 * iio_buffer_unregister() - unregister the buffer from IIO core 139 * iio_buffer_unregister() - unregister the buffer from IIO core
137 * @indio_dev: the device with the buffer to be unregistered 140 * @indio_dev: the device with the buffer to be unregistered
138 **/ 141 **/
139void iio_buffer_unregister(struct iio_dev *indio_dev); 142void iio_buffer_unregister(struct iio_dev *indio_dev);
140 143
@@ -174,6 +177,9 @@ ssize_t iio_buffer_show_enable(struct device *dev,
174 177
175int iio_sw_buffer_preenable(struct iio_dev *indio_dev); 178int iio_sw_buffer_preenable(struct iio_dev *indio_dev);
176 179
180bool iio_validate_scan_mask_onehot(struct iio_dev *indio_dev,
181 const unsigned long *mask);
182
177#else /* CONFIG_IIO_BUFFER */ 183#else /* CONFIG_IIO_BUFFER */
178 184
179static inline int iio_buffer_register(struct iio_dev *indio_dev, 185static inline int iio_buffer_register(struct iio_dev *indio_dev,
@@ -184,7 +190,7 @@ static inline int iio_buffer_register(struct iio_dev *indio_dev,
184} 190}
185 191
186static inline void iio_buffer_unregister(struct iio_dev *indio_dev) 192static inline void iio_buffer_unregister(struct iio_dev *indio_dev)
187{}; 193{}
188 194
189#endif /* CONFIG_IIO_BUFFER */ 195#endif /* CONFIG_IIO_BUFFER */
190 196
diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
index 1a15e560a5a1..e2657e6d4d26 100644
--- a/include/linux/iio/consumer.h
+++ b/include/linux/iio/consumer.h
@@ -33,17 +33,17 @@ struct iio_channel {
33 * side. This typically describes the channels use within 33 * side. This typically describes the channels use within
34 * the consumer. E.g. 'battery_voltage' 34 * the consumer. E.g. 'battery_voltage'
35 */ 35 */
36struct iio_channel *iio_st_channel_get(const char *name, 36struct iio_channel *iio_channel_get(const char *name,
37 const char *consumer_channel); 37 const char *consumer_channel);
38 38
39/** 39/**
40 * iio_st_channel_release() - release channels obtained via iio_st_channel_get 40 * iio_channel_release() - release channels obtained via iio_channel_get
41 * @chan: The channel to be released. 41 * @chan: The channel to be released.
42 */ 42 */
43void iio_st_channel_release(struct iio_channel *chan); 43void iio_channel_release(struct iio_channel *chan);
44 44
45/** 45/**
46 * iio_st_channel_get_all() - get all channels associated with a client 46 * iio_channel_get_all() - get all channels associated with a client
47 * @name: name of consumer device. 47 * @name: name of consumer device.
48 * 48 *
49 * Returns an array of iio_channel structures terminated with one with 49 * Returns an array of iio_channel structures terminated with one with
@@ -51,37 +51,37 @@ void iio_st_channel_release(struct iio_channel *chan);
51 * This function is used by fairly generic consumers to get all the 51 * This function is used by fairly generic consumers to get all the
52 * channels registered as having this consumer. 52 * channels registered as having this consumer.
53 */ 53 */
54struct iio_channel *iio_st_channel_get_all(const char *name); 54struct iio_channel *iio_channel_get_all(const char *name);
55 55
56/** 56/**
57 * iio_st_channel_release_all() - reverse iio_st_get_all 57 * iio_channel_release_all() - reverse iio_channel_get_all
58 * @chan: Array of channels to be released. 58 * @chan: Array of channels to be released.
59 */ 59 */
60void iio_st_channel_release_all(struct iio_channel *chan); 60void iio_channel_release_all(struct iio_channel *chan);
61 61
62/** 62/**
63 * iio_st_read_channel_raw() - read from a given channel 63 * iio_read_channel_raw() - read from a given channel
64 * @channel: The channel being queried. 64 * @channel: The channel being queried.
65 * @val: Value read back. 65 * @val: Value read back.
66 * 66 *
67 * Note raw reads from iio channels are in adc counts and hence 67 * Note raw reads from iio channels are in adc counts and hence
68 * scale will need to be applied if standard units required. 68 * scale will need to be applied if standard units required.
69 */ 69 */
70int iio_st_read_channel_raw(struct iio_channel *chan, 70int iio_read_channel_raw(struct iio_channel *chan,
71 int *val); 71 int *val);
72 72
73/** 73/**
74 * iio_st_get_channel_type() - get the type of a channel 74 * iio_get_channel_type() - get the type of a channel
75 * @channel: The channel being queried. 75 * @channel: The channel being queried.
76 * @type: The type of the channel. 76 * @type: The type of the channel.
77 * 77 *
78 * returns the enum iio_chan_type of the channel 78 * returns the enum iio_chan_type of the channel
79 */ 79 */
80int iio_st_get_channel_type(struct iio_channel *channel, 80int iio_get_channel_type(struct iio_channel *channel,
81 enum iio_chan_type *type); 81 enum iio_chan_type *type);
82 82
83/** 83/**
84 * iio_st_read_channel_scale() - read the scale value for a channel 84 * iio_read_channel_scale() - read the scale value for a channel
85 * @channel: The channel being queried. 85 * @channel: The channel being queried.
86 * @val: First part of value read back. 86 * @val: First part of value read back.
87 * @val2: Second part of value read back. 87 * @val2: Second part of value read back.
@@ -90,7 +90,7 @@ int iio_st_get_channel_type(struct iio_channel *channel,
90 * as IIO_VAL_INT_PLUS_MICRO telling us we have a value of val 90 * as IIO_VAL_INT_PLUS_MICRO telling us we have a value of val
91 * + val2/1e6 91 * + val2/1e6
92 */ 92 */
93int iio_st_read_channel_scale(struct iio_channel *chan, int *val, 93int iio_read_channel_scale(struct iio_channel *chan, int *val,
94 int *val2); 94 int *val2);
95 95
96#endif 96#endif
diff --git a/include/linux/iio/dac/ad5421.h b/include/linux/iio/dac/ad5421.h
new file mode 100644
index 000000000000..8fd8f057a890
--- /dev/null
+++ b/include/linux/iio/dac/ad5421.h
@@ -0,0 +1,28 @@
1#ifndef __IIO_DAC_AD5421_H__
2#define __IIO_DAC_AD5421_H__
3
4/**
5 * enum ad5421_current_range - Current range the AD5421 is configured for.
6 * @AD5421_CURRENT_RANGE_4mA_20mA: 4 mA to 20 mA (RANGE1,0 pins = 00)
7 * @AD5421_CURRENT_RANGE_3mA8_21mA: 3.8 mA to 21 mA (RANGE1,0 pins = x1)
8 * @AD5421_CURRENT_RANGE_3mA2_24mA: 3.2 mA to 24 mA (RANGE1,0 pins = 10)
9 */
10
11enum ad5421_current_range {
12 AD5421_CURRENT_RANGE_4mA_20mA,
13 AD5421_CURRENT_RANGE_3mA8_21mA,
14 AD5421_CURRENT_RANGE_3mA2_24mA,
15};
16
17/**
18 * struct ad5421_platform_data - AD5421 DAC driver platform data
19 * @external_vref: whether an external reference voltage is used or not
20 * @current_range: Current range the AD5421 is configured for
21 */
22
23struct ad5421_platform_data {
24 bool external_vref;
25 enum ad5421_current_range current_range;
26};
27
28#endif
diff --git a/include/linux/iio/dac/ad5504.h b/include/linux/iio/dac/ad5504.h
new file mode 100644
index 000000000000..43895376a9ca
--- /dev/null
+++ b/include/linux/iio/dac/ad5504.h
@@ -0,0 +1,16 @@
1/*
2 * AD5504 SPI DAC driver
3 *
4 * Copyright 2011 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2.
7 */
8
9#ifndef SPI_AD5504_H_
10#define SPI_AD5504_H_
11
12struct ad5504_platform_data {
13 u16 vref_mv;
14};
15
16#endif /* SPI_AD5504_H_ */
diff --git a/include/linux/iio/dac/ad5791.h b/include/linux/iio/dac/ad5791.h
new file mode 100644
index 000000000000..45ee281c6660
--- /dev/null
+++ b/include/linux/iio/dac/ad5791.h
@@ -0,0 +1,25 @@
1/*
2 * AD5791 SPI DAC driver
3 *
4 * Copyright 2011 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2.
7 */
8
9#ifndef SPI_AD5791_H_
10#define SPI_AD5791_H_
11
12/**
13 * struct ad5791_platform_data - platform specific information
14 * @vref_pos_mv: Vdd Positive Analog Supply Volatge (mV)
15 * @vref_neg_mv: Vdd Negative Analog Supply Volatge (mV)
16 * @use_rbuf_gain2: ext. amplifier connected in gain of two configuration
17 */
18
19struct ad5791_platform_data {
20 u16 vref_pos_mv;
21 u16 vref_neg_mv;
22 bool use_rbuf_gain2;
23};
24
25#endif /* SPI_AD5791_H_ */
diff --git a/include/linux/iio/dac/max517.h b/include/linux/iio/dac/max517.h
new file mode 100644
index 000000000000..f6d1d252f08d
--- /dev/null
+++ b/include/linux/iio/dac/max517.h
@@ -0,0 +1,15 @@
1/*
2 * MAX517 DAC driver
3 *
4 * Copyright 2011 Roland Stigge <stigge@antcom.de>
5 *
6 * Licensed under the GPL-2 or later.
7 */
8#ifndef IIO_DAC_MAX517_H_
9#define IIO_DAC_MAX517_H_
10
11struct max517_platform_data {
12 u16 vref_mv[2];
13};
14
15#endif /* IIO_DAC_MAX517_H_ */
diff --git a/include/linux/iio/dac/mcp4725.h b/include/linux/iio/dac/mcp4725.h
new file mode 100644
index 000000000000..91530e6611e9
--- /dev/null
+++ b/include/linux/iio/dac/mcp4725.h
@@ -0,0 +1,16 @@
1/*
2 * MCP4725 DAC driver
3 *
4 * Copyright (C) 2012 Peter Meerwald <pmeerw@pmeerw.net>
5 *
6 * Licensed under the GPL-2 or later.
7 */
8
9#ifndef IIO_DAC_MCP4725_H_
10#define IIO_DAC_MCP4725_H_
11
12struct mcp4725_platform_data {
13 u16 vref_mv;
14};
15
16#endif /* IIO_DAC_MCP4725_H_ */
diff --git a/include/linux/iio/events.h b/include/linux/iio/events.h
index b5acbf93c5da..13ce220c7003 100644
--- a/include/linux/iio/events.h
+++ b/include/linux/iio/events.h
@@ -46,7 +46,7 @@ enum iio_event_direction {
46 * @diff: Whether the event is for an differential channel or not. 46 * @diff: Whether the event is for an differential channel or not.
47 * @modifier: Modifier for the channel. Should be one of enum iio_modifier. 47 * @modifier: Modifier for the channel. Should be one of enum iio_modifier.
48 * @direction: Direction of the event. One of enum iio_event_direction. 48 * @direction: Direction of the event. One of enum iio_event_direction.
49 * @type: Type of the event. Should be one enum iio_event_type. 49 * @type: Type of the event. Should be one of enum iio_event_type.
50 * @chan: Channel number for non-differential channels. 50 * @chan: Channel number for non-differential channels.
51 * @chan1: First channel number for differential channels. 51 * @chan1: First channel number for differential channels.
52 * @chan2: Second channel number for differential channels. 52 * @chan2: Second channel number for differential channels.
@@ -69,7 +69,7 @@ enum iio_event_direction {
69 * @chan_type: Type of the channel. Should be one of enum iio_chan_type. 69 * @chan_type: Type of the channel. Should be one of enum iio_chan_type.
70 * @number: Channel number. 70 * @number: Channel number.
71 * @modifier: Modifier for the channel. Should be one of enum iio_modifier. 71 * @modifier: Modifier for the channel. Should be one of enum iio_modifier.
72 * @type: Type of the event. Should be one enum iio_event_type. 72 * @type: Type of the event. Should be one of enum iio_event_type.
73 * @direction: Direction of the event. One of enum iio_event_direction. 73 * @direction: Direction of the event. One of enum iio_event_direction.
74 */ 74 */
75 75
@@ -81,7 +81,7 @@ enum iio_event_direction {
81 * IIO_UNMOD_EVENT_CODE() - create event identifier for unmodified channels 81 * IIO_UNMOD_EVENT_CODE() - create event identifier for unmodified channels
82 * @chan_type: Type of the channel. Should be one of enum iio_chan_type. 82 * @chan_type: Type of the channel. Should be one of enum iio_chan_type.
83 * @number: Channel number. 83 * @number: Channel number.
84 * @type: Type of the event. Should be one enum iio_event_type. 84 * @type: Type of the event. Should be one of enum iio_event_type.
85 * @direction: Direction of the event. One of enum iio_event_direction. 85 * @direction: Direction of the event. One of enum iio_event_direction.
86 */ 86 */
87 87
diff --git a/include/linux/iio/frequency/ad9523.h b/include/linux/iio/frequency/ad9523.h
new file mode 100644
index 000000000000..12ce3ee427fd
--- /dev/null
+++ b/include/linux/iio/frequency/ad9523.h
@@ -0,0 +1,195 @@
1/*
2 * AD9523 SPI Low Jitter Clock Generator
3 *
4 * Copyright 2012 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2.
7 */
8
9#ifndef IIO_FREQUENCY_AD9523_H_
10#define IIO_FREQUENCY_AD9523_H_
11
12enum outp_drv_mode {
13 TRISTATE,
14 LVPECL_8mA,
15 LVDS_4mA,
16 LVDS_7mA,
17 HSTL0_16mA,
18 HSTL1_8mA,
19 CMOS_CONF1,
20 CMOS_CONF2,
21 CMOS_CONF3,
22 CMOS_CONF4,
23 CMOS_CONF5,
24 CMOS_CONF6,
25 CMOS_CONF7,
26 CMOS_CONF8,
27 CMOS_CONF9
28};
29
30enum ref_sel_mode {
31 NONEREVERTIVE_STAY_ON_REFB,
32 REVERT_TO_REFA,
33 SELECT_REFA,
34 SELECT_REFB,
35 EXT_REF_SEL
36};
37
38/**
39 * struct ad9523_channel_spec - Output channel configuration
40 *
41 * @channel_num: Output channel number.
42 * @divider_output_invert_en: Invert the polarity of the output clock.
43 * @sync_ignore_en: Ignore chip-level SYNC signal.
44 * @low_power_mode_en: Reduce power used in the differential output modes.
45 * @use_alt_clock_src: Channel divider uses alternative clk source.
46 * @output_dis: Disables, powers down the entire channel.
47 * @driver_mode: Output driver mode (logic level family).
48 * @divider_phase: Divider initial phase after a SYNC. Range 0..63
49 LSB = 1/2 of a period of the divider input clock.
50 * @channel_divider: 10-bit channel divider.
51 * @extended_name: Optional descriptive channel name.
52 */
53
54struct ad9523_channel_spec {
55 unsigned channel_num;
56 bool divider_output_invert_en;
57 bool sync_ignore_en;
58 bool low_power_mode_en;
59 /* CH0..CH3 VCXO, CH4..CH9 VCO2 */
60 bool use_alt_clock_src;
61 bool output_dis;
62 enum outp_drv_mode driver_mode;
63 unsigned char divider_phase;
64 unsigned short channel_divider;
65 char extended_name[16];
66};
67
68enum pll1_rzero_resistor {
69 RZERO_883_OHM,
70 RZERO_677_OHM,
71 RZERO_341_OHM,
72 RZERO_135_OHM,
73 RZERO_10_OHM,
74 RZERO_USE_EXT_RES = 8,
75};
76
77enum rpole2_resistor {
78 RPOLE2_900_OHM,
79 RPOLE2_450_OHM,
80 RPOLE2_300_OHM,
81 RPOLE2_225_OHM,
82};
83
84enum rzero_resistor {
85 RZERO_3250_OHM,
86 RZERO_2750_OHM,
87 RZERO_2250_OHM,
88 RZERO_2100_OHM,
89 RZERO_3000_OHM,
90 RZERO_2500_OHM,
91 RZERO_2000_OHM,
92 RZERO_1850_OHM,
93};
94
95enum cpole1_capacitor {
96 CPOLE1_0_PF,
97 CPOLE1_8_PF,
98 CPOLE1_16_PF,
99 CPOLE1_24_PF,
100 _CPOLE1_24_PF, /* place holder */
101 CPOLE1_32_PF,
102 CPOLE1_40_PF,
103 CPOLE1_48_PF,
104};
105
106/**
107 * struct ad9523_platform_data - platform specific information
108 *
109 * @vcxo_freq: External VCXO frequency in Hz
110 * @refa_diff_rcv_en: REFA differential/single-ended input selection.
111 * @refb_diff_rcv_en: REFB differential/single-ended input selection.
112 * @zd_in_diff_en: Zero Delay differential/single-ended input selection.
113 * @osc_in_diff_en: OSC differential/ single-ended input selection.
114 * @refa_cmos_neg_inp_en: REFA single-ended neg./pos. input enable.
115 * @refb_cmos_neg_inp_en: REFB single-ended neg./pos. input enable.
116 * @zd_in_cmos_neg_inp_en: Zero Delay single-ended neg./pos. input enable.
117 * @osc_in_cmos_neg_inp_en: OSC single-ended neg./pos. input enable.
118 * @refa_r_div: PLL1 10-bit REFA R divider.
119 * @refb_r_div: PLL1 10-bit REFB R divider.
120 * @pll1_feedback_div: PLL1 10-bit Feedback N divider.
121 * @pll1_charge_pump_current_nA: Magnitude of PLL1 charge pump current (nA).
122 * @zero_delay_mode_internal_en: Internal, external Zero Delay mode selection.
123 * @osc_in_feedback_en: PLL1 feedback path, local feedback from
124 * the OSC_IN receiver or zero delay mode
125 * @pll1_loop_filter_rzero: PLL1 Loop Filter Zero Resistor selection.
126 * @ref_mode: Reference selection mode.
127 * @pll2_charge_pump_current_nA: Magnitude of PLL2 charge pump current (nA).
128 * @pll2_ndiv_a_cnt: PLL2 Feedback N-divider, A Counter, range 0..4.
129 * @pll2_ndiv_b_cnt: PLL2 Feedback N-divider, B Counter, range 0..63.
130 * @pll2_freq_doubler_en: PLL2 frequency doubler enable.
131 * @pll2_r2_div: PLL2 R2 divider, range 0..31.
132 * @pll2_vco_diff_m1: VCO1 divider, range 3..5.
133 * @pll2_vco_diff_m2: VCO2 divider, range 3..5.
134 * @rpole2: PLL2 loop filter Rpole resistor value.
135 * @rzero: PLL2 loop filter Rzero resistor value.
136 * @cpole1: PLL2 loop filter Cpole capacitor value.
137 * @rzero_bypass_en: PLL2 loop filter Rzero bypass enable.
138 * @num_channels: Array size of struct ad9523_channel_spec.
139 * @channels: Pointer to channel array.
140 * @name: Optional alternative iio device name.
141 */
142
143struct ad9523_platform_data {
144 unsigned long vcxo_freq;
145
146 /* Differential/ Single-Ended Input Configuration */
147 bool refa_diff_rcv_en;
148 bool refb_diff_rcv_en;
149 bool zd_in_diff_en;
150 bool osc_in_diff_en;
151
152 /*
153 * Valid if differential input disabled
154 * if false defaults to pos input
155 */
156 bool refa_cmos_neg_inp_en;
157 bool refb_cmos_neg_inp_en;
158 bool zd_in_cmos_neg_inp_en;
159 bool osc_in_cmos_neg_inp_en;
160
161 /* PLL1 Setting */
162 unsigned short refa_r_div;
163 unsigned short refb_r_div;
164 unsigned short pll1_feedback_div;
165 unsigned short pll1_charge_pump_current_nA;
166 bool zero_delay_mode_internal_en;
167 bool osc_in_feedback_en;
168 enum pll1_rzero_resistor pll1_loop_filter_rzero;
169
170 /* Reference */
171 enum ref_sel_mode ref_mode;
172
173 /* PLL2 Setting */
174 unsigned int pll2_charge_pump_current_nA;
175 unsigned char pll2_ndiv_a_cnt;
176 unsigned char pll2_ndiv_b_cnt;
177 bool pll2_freq_doubler_en;
178 unsigned char pll2_r2_div;
179 unsigned char pll2_vco_diff_m1; /* 3..5 */
180 unsigned char pll2_vco_diff_m2; /* 3..5 */
181
182 /* Loop Filter PLL2 */
183 enum rpole2_resistor rpole2;
184 enum rzero_resistor rzero;
185 enum cpole1_capacitor cpole1;
186 bool rzero_bypass_en;
187
188 /* Output Channel Configuration */
189 int num_channels;
190 struct ad9523_channel_spec *channels;
191
192 char name[SPI_NAME_SIZE];
193};
194
195#endif /* IIO_FREQUENCY_AD9523_H_ */
diff --git a/include/linux/iio/frequency/adf4350.h b/include/linux/iio/frequency/adf4350.h
new file mode 100644
index 000000000000..b76b4a87065e
--- /dev/null
+++ b/include/linux/iio/frequency/adf4350.h
@@ -0,0 +1,126 @@
1/*
2 * ADF4350/ADF4351 SPI PLL driver
3 *
4 * Copyright 2012 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2.
7 */
8
9#ifndef IIO_PLL_ADF4350_H_
10#define IIO_PLL_ADF4350_H_
11
12/* Registers */
13#define ADF4350_REG0 0
14#define ADF4350_REG1 1
15#define ADF4350_REG2 2
16#define ADF4350_REG3 3
17#define ADF4350_REG4 4
18#define ADF4350_REG5 5
19
20/* REG0 Bit Definitions */
21#define ADF4350_REG0_FRACT(x) (((x) & 0xFFF) << 3)
22#define ADF4350_REG0_INT(x) (((x) & 0xFFFF) << 15)
23
24/* REG1 Bit Definitions */
25#define ADF4350_REG1_MOD(x) (((x) & 0xFFF) << 3)
26#define ADF4350_REG1_PHASE(x) (((x) & 0xFFF) << 15)
27#define ADF4350_REG1_PRESCALER (1 << 27)
28
29/* REG2 Bit Definitions */
30#define ADF4350_REG2_COUNTER_RESET_EN (1 << 3)
31#define ADF4350_REG2_CP_THREESTATE_EN (1 << 4)
32#define ADF4350_REG2_POWER_DOWN_EN (1 << 5)
33#define ADF4350_REG2_PD_POLARITY_POS (1 << 6)
34#define ADF4350_REG2_LDP_6ns (1 << 7)
35#define ADF4350_REG2_LDP_10ns (0 << 7)
36#define ADF4350_REG2_LDF_FRACT_N (0 << 8)
37#define ADF4350_REG2_LDF_INT_N (1 << 8)
38#define ADF4350_REG2_CHARGE_PUMP_CURR_uA(x) (((((x)-312) / 312) & 0xF) << 9)
39#define ADF4350_REG2_DOUBLE_BUFF_EN (1 << 13)
40#define ADF4350_REG2_10BIT_R_CNT(x) ((x) << 14)
41#define ADF4350_REG2_RDIV2_EN (1 << 24)
42#define ADF4350_REG2_RMULT2_EN (1 << 25)
43#define ADF4350_REG2_MUXOUT(x) ((x) << 26)
44#define ADF4350_REG2_NOISE_MODE(x) ((x) << 29)
45#define ADF4350_MUXOUT_THREESTATE 0
46#define ADF4350_MUXOUT_DVDD 1
47#define ADF4350_MUXOUT_GND 2
48#define ADF4350_MUXOUT_R_DIV_OUT 3
49#define ADF4350_MUXOUT_N_DIV_OUT 4
50#define ADF4350_MUXOUT_ANALOG_LOCK_DETECT 5
51#define ADF4350_MUXOUT_DIGITAL_LOCK_DETECT 6
52
53/* REG3 Bit Definitions */
54#define ADF4350_REG3_12BIT_CLKDIV(x) ((x) << 3)
55#define ADF4350_REG3_12BIT_CLKDIV_MODE(x) ((x) << 16)
56#define ADF4350_REG3_12BIT_CSR_EN (1 << 18)
57#define ADF4351_REG3_CHARGE_CANCELLATION_EN (1 << 21)
58#define ADF4351_REG3_ANTI_BACKLASH_3ns_EN (1 << 22)
59#define ADF4351_REG3_BAND_SEL_CLOCK_MODE_HIGH (1 << 23)
60
61/* REG4 Bit Definitions */
62#define ADF4350_REG4_OUTPUT_PWR(x) ((x) << 3)
63#define ADF4350_REG4_RF_OUT_EN (1 << 5)
64#define ADF4350_REG4_AUX_OUTPUT_PWR(x) ((x) << 6)
65#define ADF4350_REG4_AUX_OUTPUT_EN (1 << 8)
66#define ADF4350_REG4_AUX_OUTPUT_FUND (1 << 9)
67#define ADF4350_REG4_AUX_OUTPUT_DIV (0 << 9)
68#define ADF4350_REG4_MUTE_TILL_LOCK_EN (1 << 10)
69#define ADF4350_REG4_VCO_PWRDOWN_EN (1 << 11)
70#define ADF4350_REG4_8BIT_BAND_SEL_CLKDIV(x) ((x) << 12)
71#define ADF4350_REG4_RF_DIV_SEL(x) ((x) << 20)
72#define ADF4350_REG4_FEEDBACK_DIVIDED (0 << 23)
73#define ADF4350_REG4_FEEDBACK_FUND (1 << 23)
74
75/* REG5 Bit Definitions */
76#define ADF4350_REG5_LD_PIN_MODE_LOW (0 << 22)
77#define ADF4350_REG5_LD_PIN_MODE_DIGITAL (1 << 22)
78#define ADF4350_REG5_LD_PIN_MODE_HIGH (3 << 22)
79
80/* Specifications */
81#define ADF4350_MAX_OUT_FREQ 4400000000ULL /* Hz */
82#define ADF4350_MIN_OUT_FREQ 137500000 /* Hz */
83#define ADF4351_MIN_OUT_FREQ 34375000 /* Hz */
84#define ADF4350_MIN_VCO_FREQ 2200000000ULL /* Hz */
85#define ADF4350_MAX_FREQ_45_PRESC 3000000000ULL /* Hz */
86#define ADF4350_MAX_FREQ_PFD 32000000 /* Hz */
87#define ADF4350_MAX_BANDSEL_CLK 125000 /* Hz */
88#define ADF4350_MAX_FREQ_REFIN 250000000 /* Hz */
89#define ADF4350_MAX_MODULUS 4095
90
91/**
92 * struct adf4350_platform_data - platform specific information
93 * @name: Optional device name.
94 * @clkin: REFin frequency in Hz.
95 * @channel_spacing: Channel spacing in Hz (influences MODULUS).
96 * @power_up_frequency: Optional, If set in Hz the PLL tunes to the desired
97 * frequency on probe.
98 * @ref_div_factor: Optional, if set the driver skips dynamic calculation
99 * and uses this default value instead.
100 * @ref_doubler_en: Enables reference doubler.
101 * @ref_div2_en: Enables reference divider.
102 * @r2_user_settings: User defined settings for ADF4350/1 REGISTER_2.
103 * @r3_user_settings: User defined settings for ADF4350/1 REGISTER_3.
104 * @r4_user_settings: User defined settings for ADF4350/1 REGISTER_4.
105 * @gpio_lock_detect: Optional, if set with a valid GPIO number,
106 * pll lock state is tested upon read.
107 * If not used - set to -1.
108 */
109
110struct adf4350_platform_data {
111 char name[32];
112 unsigned long clkin;
113 unsigned long channel_spacing;
114 unsigned long long power_up_frequency;
115
116 unsigned short ref_div_factor; /* 10-bit R counter */
117 bool ref_doubler_en;
118 bool ref_div2_en;
119
120 unsigned r2_user_settings;
121 unsigned r3_user_settings;
122 unsigned r4_user_settings;
123 int gpio_lock_detect;
124};
125
126#endif /* IIO_PLL_ADF4350_H_ */
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index 3a4f6a3ab80d..be82936c4089 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -130,14 +130,78 @@ struct iio_chan_spec_ext_info {
130}; 130};
131 131
132/** 132/**
133 * struct iio_enum - Enum channel info attribute
134 * @items: An array of strings.
135 * @num_items: Length of the item array.
136 * @set: Set callback function, may be NULL.
137 * @get: Get callback function, may be NULL.
138 *
139 * The iio_enum struct can be used to implement enum style channel attributes.
140 * Enum style attributes are those which have a set of strings which map to
141 * unsigned integer values. The IIO enum helper code takes care of mapping
142 * between value and string as well as generating a "_available" file which
143 * contains a list of all available items. The set callback will be called when
144 * the attribute is updated. The last parameter is the index to the newly
145 * activated item. The get callback will be used to query the currently active
146 * item and is supposed to return the index for it.
147 */
148struct iio_enum {
149 const char * const *items;
150 unsigned int num_items;
151 int (*set)(struct iio_dev *, const struct iio_chan_spec *, unsigned int);
152 int (*get)(struct iio_dev *, const struct iio_chan_spec *);
153};
154
155ssize_t iio_enum_available_read(struct iio_dev *indio_dev,
156 uintptr_t priv, const struct iio_chan_spec *chan, char *buf);
157ssize_t iio_enum_read(struct iio_dev *indio_dev,
158 uintptr_t priv, const struct iio_chan_spec *chan, char *buf);
159ssize_t iio_enum_write(struct iio_dev *indio_dev,
160 uintptr_t priv, const struct iio_chan_spec *chan, const char *buf,
161 size_t len);
162
163/**
164 * IIO_ENUM() - Initialize enum extended channel attribute
165 * @_name: Attribute name
166 * @_shared: Whether the attribute is shared between all channels
167 * @_e: Pointer to a iio_enum struct
168 *
169 * This should usually be used together with IIO_ENUM_AVAILABLE()
170 */
171#define IIO_ENUM(_name, _shared, _e) \
172{ \
173 .name = (_name), \
174 .shared = (_shared), \
175 .read = iio_enum_read, \
176 .write = iio_enum_write, \
177 .private = (uintptr_t)(_e), \
178}
179
180/**
181 * IIO_ENUM_AVAILABLE() - Initialize enum available extended channel attribute
182 * @_name: Attribute name ("_available" will be appended to the name)
183 * @_e: Pointer to a iio_enum struct
184 *
185 * Creates a read only attribute which list all the available enum items in a
186 * space separated list. This should usually be used together with IIO_ENUM()
187 */
188#define IIO_ENUM_AVAILABLE(_name, _e) \
189{ \
190 .name = (_name "_available"), \
191 .shared = true, \
192 .read = iio_enum_available_read, \
193 .private = (uintptr_t)(_e), \
194}
195
196/**
133 * struct iio_chan_spec - specification of a single channel 197 * struct iio_chan_spec - specification of a single channel
134 * @type: What type of measurement is the channel making. 198 * @type: What type of measurement is the channel making.
135 * @channel: What number or name do we wish to assign the channel. 199 * @channel: What number do we wish to assign the channel.
136 * @channel2: If there is a second number for a differential 200 * @channel2: If there is a second number for a differential
137 * channel then this is it. If modified is set then the 201 * channel then this is it. If modified is set then the
138 * value here specifies the modifier. 202 * value here specifies the modifier.
139 * @address: Driver specific identifier. 203 * @address: Driver specific identifier.
140 * @scan_index: Monotonic index to give ordering in scans when read 204 * @scan_index: Monotonic index to give ordering in scans when read
141 * from a buffer. 205 * from a buffer.
142 * @scan_type: Sign: 's' or 'u' to specify signed or unsigned 206 * @scan_type: Sign: 's' or 'u' to specify signed or unsigned
143 * realbits: Number of valid bits of data 207 * realbits: Number of valid bits of data
@@ -147,14 +211,14 @@ struct iio_chan_spec_ext_info {
147 * endianness: little or big endian 211 * endianness: little or big endian
148 * @info_mask: What information is to be exported about this channel. 212 * @info_mask: What information is to be exported about this channel.
149 * This includes calibbias, scale etc. 213 * This includes calibbias, scale etc.
150 * @event_mask: What events can this channel produce. 214 * @event_mask: What events can this channel produce.
151 * @ext_info: Array of extended info attributes for this channel. 215 * @ext_info: Array of extended info attributes for this channel.
152 * The array is NULL terminated, the last element should 216 * The array is NULL terminated, the last element should
153 * have it's name field set to NULL. 217 * have its name field set to NULL.
154 * @extend_name: Allows labeling of channel attributes with an 218 * @extend_name: Allows labeling of channel attributes with an
155 * informative name. Note this has no effect codes etc, 219 * informative name. Note this has no effect codes etc,
156 * unlike modifiers. 220 * unlike modifiers.
157 * @datasheet_name: A name used in in kernel mapping of channels. It should 221 * @datasheet_name: A name used in in-kernel mapping of channels. It should
158 * correspond to the first name that the channel is referred 222 * correspond to the first name that the channel is referred
159 * to by in the datasheet (e.g. IND), or the nearest 223 * to by in the datasheet (e.g. IND), or the nearest
160 * possible compound name (e.g. IND-INC). 224 * possible compound name (e.g. IND-INC).
@@ -163,9 +227,8 @@ struct iio_chan_spec_ext_info {
163 * channel2. Examples are IIO_MOD_X for axial sensors about 227 * channel2. Examples are IIO_MOD_X for axial sensors about
164 * the 'x' axis. 228 * the 'x' axis.
165 * @indexed: Specify the channel has a numerical index. If not, 229 * @indexed: Specify the channel has a numerical index. If not,
166 * the value in channel will be suppressed for attribute 230 * the channel index number will be suppressed for sysfs
167 * but not for event codes. Typically set it to 0 when 231 * attributes but not for event codes.
168 * the index is false.
169 * @differential: Channel is differential. 232 * @differential: Channel is differential.
170 */ 233 */
171struct iio_chan_spec { 234struct iio_chan_spec {
@@ -300,12 +363,16 @@ struct iio_info {
300 * @predisable: [DRIVER] function to run prior to marking buffer 363 * @predisable: [DRIVER] function to run prior to marking buffer
301 * disabled 364 * disabled
302 * @postdisable: [DRIVER] function to run after marking buffer disabled 365 * @postdisable: [DRIVER] function to run after marking buffer disabled
366 * @validate_scan_mask: [DRIVER] function callback to check whether a given
367 * scan mask is valid for the device.
303 */ 368 */
304struct iio_buffer_setup_ops { 369struct iio_buffer_setup_ops {
305 int (*preenable)(struct iio_dev *); 370 int (*preenable)(struct iio_dev *);
306 int (*postenable)(struct iio_dev *); 371 int (*postenable)(struct iio_dev *);
307 int (*predisable)(struct iio_dev *); 372 int (*predisable)(struct iio_dev *);
308 int (*postdisable)(struct iio_dev *); 373 int (*postdisable)(struct iio_dev *);
374 bool (*validate_scan_mask)(struct iio_dev *indio_dev,
375 const unsigned long *scan_mask);
309}; 376};
310 377
311/** 378/**
@@ -329,7 +396,7 @@ struct iio_buffer_setup_ops {
329 * @trig: [INTERN] current device trigger (buffer modes) 396 * @trig: [INTERN] current device trigger (buffer modes)
330 * @pollfunc: [DRIVER] function run on trigger being received 397 * @pollfunc: [DRIVER] function run on trigger being received
331 * @channels: [DRIVER] channel specification structure table 398 * @channels: [DRIVER] channel specification structure table
332 * @num_channels: [DRIVER] number of chanels specified in @channels. 399 * @num_channels: [DRIVER] number of channels specified in @channels.
333 * @channel_attr_list: [INTERN] keep track of automatically created channel 400 * @channel_attr_list: [INTERN] keep track of automatically created channel
334 * attributes 401 * attributes
335 * @chan_attr_group: [INTERN] group for all attrs in base directory 402 * @chan_attr_group: [INTERN] group for all attrs in base directory
@@ -419,7 +486,7 @@ extern struct bus_type iio_bus_type;
419 486
420/** 487/**
421 * iio_device_put() - reference counted deallocation of struct device 488 * iio_device_put() - reference counted deallocation of struct device
422 * @dev: the iio_device containing the device 489 * @indio_dev: IIO device structure containing the device
423 **/ 490 **/
424static inline void iio_device_put(struct iio_dev *indio_dev) 491static inline void iio_device_put(struct iio_dev *indio_dev)
425{ 492{
@@ -429,7 +496,7 @@ static inline void iio_device_put(struct iio_dev *indio_dev)
429 496
430/** 497/**
431 * dev_to_iio_dev() - Get IIO device struct from a device struct 498 * dev_to_iio_dev() - Get IIO device struct from a device struct
432 * @dev: The device embedded in the IIO device 499 * @dev: The device embedded in the IIO device
433 * 500 *
434 * Note: The device must be a IIO device, otherwise the result is undefined. 501 * Note: The device must be a IIO device, otherwise the result is undefined.
435 */ 502 */
@@ -438,11 +505,22 @@ static inline struct iio_dev *dev_to_iio_dev(struct device *dev)
438 return container_of(dev, struct iio_dev, dev); 505 return container_of(dev, struct iio_dev, dev);
439} 506}
440 507
508/**
509 * iio_device_get() - increment reference count for the device
510 * @indio_dev: IIO device structure
511 *
512 * Returns: The passed IIO device
513 **/
514static inline struct iio_dev *iio_device_get(struct iio_dev *indio_dev)
515{
516 return indio_dev ? dev_to_iio_dev(get_device(&indio_dev->dev)) : NULL;
517}
518
441/* Can we make this smaller? */ 519/* Can we make this smaller? */
442#define IIO_ALIGN L1_CACHE_BYTES 520#define IIO_ALIGN L1_CACHE_BYTES
443/** 521/**
444 * iio_device_alloc() - allocate an iio_dev from a driver 522 * iio_device_alloc() - allocate an iio_dev from a driver
445 * @sizeof_priv: Space to allocate for private structure. 523 * @sizeof_priv: Space to allocate for private structure.
446 **/ 524 **/
447struct iio_dev *iio_device_alloc(int sizeof_priv); 525struct iio_dev *iio_device_alloc(int sizeof_priv);
448 526
@@ -459,13 +537,13 @@ static inline struct iio_dev *iio_priv_to_dev(void *priv)
459 537
460/** 538/**
461 * iio_device_free() - free an iio_dev from a driver 539 * iio_device_free() - free an iio_dev from a driver
462 * @dev: the iio_dev associated with the device 540 * @indio_dev: the iio_dev associated with the device
463 **/ 541 **/
464void iio_device_free(struct iio_dev *indio_dev); 542void iio_device_free(struct iio_dev *indio_dev);
465 543
466/** 544/**
467 * iio_buffer_enabled() - helper function to test if the buffer is enabled 545 * iio_buffer_enabled() - helper function to test if the buffer is enabled
468 * @indio_dev: IIO device info structure for device 546 * @indio_dev: IIO device structure for device
469 **/ 547 **/
470static inline bool iio_buffer_enabled(struct iio_dev *indio_dev) 548static inline bool iio_buffer_enabled(struct iio_dev *indio_dev)
471{ 549{
@@ -475,7 +553,7 @@ static inline bool iio_buffer_enabled(struct iio_dev *indio_dev)
475 553
476/** 554/**
477 * iio_get_debugfs_dentry() - helper function to get the debugfs_dentry 555 * iio_get_debugfs_dentry() - helper function to get the debugfs_dentry
478 * @indio_dev: IIO device info structure for device 556 * @indio_dev: IIO device structure for device
479 **/ 557 **/
480#if defined(CONFIG_DEBUG_FS) 558#if defined(CONFIG_DEBUG_FS)
481static inline struct dentry *iio_get_debugfs_dentry(struct iio_dev *indio_dev) 559static inline struct dentry *iio_get_debugfs_dentry(struct iio_dev *indio_dev)
diff --git a/include/linux/iio/machine.h b/include/linux/iio/machine.h
index 0b1f19bfdc44..400a453ff67b 100644
--- a/include/linux/iio/machine.h
+++ b/include/linux/iio/machine.h
@@ -14,7 +14,7 @@
14 * This is matched against the datasheet_name element 14 * This is matched against the datasheet_name element
15 * of struct iio_chan_spec. 15 * of struct iio_chan_spec.
16 * @consumer_dev_name: Name to uniquely identify the consumer device. 16 * @consumer_dev_name: Name to uniquely identify the consumer device.
17 * @consumer_channel: Unique name used to idenitify the channel on the 17 * @consumer_channel: Unique name used to identify the channel on the
18 * consumer side. 18 * consumer side.
19 */ 19 */
20struct iio_map { 20struct iio_map {
diff --git a/include/linux/iio/sysfs.h b/include/linux/iio/sysfs.h
index bfedb73b850e..b7a934b9431b 100644
--- a/include/linux/iio/sysfs.h
+++ b/include/linux/iio/sysfs.h
@@ -97,7 +97,7 @@ struct iio_const_attr {
97#define IIO_DEV_ATTR_SAMP_FREQ_AVAIL(_show) \ 97#define IIO_DEV_ATTR_SAMP_FREQ_AVAIL(_show) \
98 IIO_DEVICE_ATTR(sampling_frequency_available, S_IRUGO, _show, NULL, 0) 98 IIO_DEVICE_ATTR(sampling_frequency_available, S_IRUGO, _show, NULL, 0)
99/** 99/**
100 * IIO_CONST_ATTR_AVAIL_SAMP_FREQ - list available sampling frequencies 100 * IIO_CONST_ATTR_SAMP_FREQ_AVAIL - list available sampling frequencies
101 * @_string: frequency string for the attribute 101 * @_string: frequency string for the attribute
102 * 102 *
103 * Constant version 103 * Constant version
diff --git a/include/linux/iio/triggered_buffer.h b/include/linux/iio/triggered_buffer.h
new file mode 100644
index 000000000000..c378ebec605e
--- /dev/null
+++ b/include/linux/iio/triggered_buffer.h
@@ -0,0 +1,15 @@
1#ifndef _LINUX_IIO_TRIGGERED_BUFFER_H_
2#define _LINUX_IIO_TRIGGERED_BUFFER_H_
3
4#include <linux/interrupt.h>
5
6struct iio_dev;
7struct iio_buffer_setup_ops;
8
9int iio_triggered_buffer_setup(struct iio_dev *indio_dev,
10 irqreturn_t (*pollfunc_bh)(int irq, void *p),
11 irqreturn_t (*pollfunc_th)(int irq, void *p),
12 const struct iio_buffer_setup_ops *setup_ops);
13void iio_triggered_buffer_cleanup(struct iio_dev *indio_dev);
14
15#endif
diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h
index 1b073b1cc7c2..44e397705d7f 100644
--- a/include/linux/iio/types.h
+++ b/include/linux/iio/types.h
@@ -11,7 +11,6 @@
11#define _IIO_TYPES_H_ 11#define _IIO_TYPES_H_
12 12
13enum iio_chan_type { 13enum iio_chan_type {
14 /* real channel types */
15 IIO_VOLTAGE, 14 IIO_VOLTAGE,
16 IIO_CURRENT, 15 IIO_CURRENT,
17 IIO_POWER, 16 IIO_POWER,
@@ -28,6 +27,7 @@ enum iio_chan_type {
28 IIO_TIMESTAMP, 27 IIO_TIMESTAMP,
29 IIO_CAPACITANCE, 28 IIO_CAPACITANCE,
30 IIO_ALTVOLTAGE, 29 IIO_ALTVOLTAGE,
30 IIO_CCT,
31}; 31};
32 32
33enum iio_modifier { 33enum iio_modifier {
@@ -45,6 +45,12 @@ enum iio_modifier {
45 IIO_MOD_X_OR_Y_OR_Z, 45 IIO_MOD_X_OR_Y_OR_Z,
46 IIO_MOD_LIGHT_BOTH, 46 IIO_MOD_LIGHT_BOTH,
47 IIO_MOD_LIGHT_IR, 47 IIO_MOD_LIGHT_IR,
48 IIO_MOD_ROOT_SUM_SQUARED_X_Y,
49 IIO_MOD_SUM_SQUARED_X_Y_Z,
50 IIO_MOD_LIGHT_CLEAR,
51 IIO_MOD_LIGHT_RED,
52 IIO_MOD_LIGHT_GREEN,
53 IIO_MOD_LIGHT_BLUE,
48}; 54};
49 55
50#define IIO_VAL_INT 1 56#define IIO_VAL_INT 1