Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
20cc0ddd
Commit
20cc0ddd
authored
Feb 15, 2021
by
Daniel Lezcano
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'iio-thermal-5.11-rc1/ib-iio-thermal-5.11-rc1' into testing
parents
c13636ba
24a7dc6f
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
240 additions
and
207 deletions
+240
-207
drivers/iio/adc/qcom-pm8xxx-xoadc.c
drivers/iio/adc/qcom-pm8xxx-xoadc.c
+1
-2
drivers/iio/adc/qcom-spmi-adc5.c
drivers/iio/adc/qcom-spmi-adc5.c
+14
-81
drivers/iio/adc/qcom-spmi-vadc.c
drivers/iio/adc/qcom-spmi-vadc.c
+1
-2
drivers/iio/adc/qcom-vadc-common.c
drivers/iio/adc/qcom-vadc-common.c
+132
-97
drivers/iio/inkern.c
drivers/iio/inkern.c
+26
-8
include/linux/fixp-arith.h
include/linux/fixp-arith.h
+19
-0
include/linux/iio/adc/qcom-vadc-common.h
include/linux/iio/adc/qcom-vadc-common.h
+11
-17
include/linux/iio/consumer.h
include/linux/iio/consumer.h
+36
-0
No files found.
drivers/iio/adc/qcom-pm8xxx-xoadc.c
View file @
20cc0ddd
...
...
@@ -10,6 +10,7 @@
* Author: Linus Walleij <linus.walleij@linaro.org>
*/
#include <linux/iio/adc/qcom-vadc-common.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
#include <linux/module.h>
...
...
@@ -21,8 +22,6 @@
#include <linux/interrupt.h>
#include <linux/regulator/consumer.h>
#include "qcom-vadc-common.h"
/*
* Definitions for the "user processor" registers lifted from the v3.4
* Qualcomm tree. Their kernel has two out-of-tree drivers for the ADC:
...
...
drivers/iio/adc/qcom-spmi-adc5.c
View file @
20cc0ddd
...
...
@@ -7,6 +7,7 @@
#include <linux/completion.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/iio/adc/qcom-vadc-common.h>
#include <linux/iio/iio.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
...
...
@@ -14,12 +15,12 @@
#include <linux/math64.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/slab.h>
#include <dt-bindings/iio/qcom,spmi-vadc.h>
#include "qcom-vadc-common.h"
#define ADC5_USR_REVISION1 0x0
#define ADC5_USR_STATUS1 0x8
...
...
@@ -154,18 +155,6 @@ struct adc5_chip {
const
struct
adc5_data
*
data
;
};
static
const
struct
vadc_prescale_ratio
adc5_prescale_ratios
[]
=
{
{.
num
=
1
,
.
den
=
1
},
{.
num
=
1
,
.
den
=
3
},
{.
num
=
1
,
.
den
=
4
},
{.
num
=
1
,
.
den
=
6
},
{.
num
=
1
,
.
den
=
20
},
{.
num
=
1
,
.
den
=
8
},
{.
num
=
10
,
.
den
=
81
},
{.
num
=
1
,
.
den
=
10
},
{.
num
=
1
,
.
den
=
16
}
};
static
int
adc5_read
(
struct
adc5_chip
*
adc
,
u16
offset
,
u8
*
data
,
int
len
)
{
return
regmap_bulk_read
(
adc
->
regmap
,
adc
->
base
+
offset
,
data
,
len
);
...
...
@@ -181,55 +170,6 @@ static int adc5_masked_write(struct adc5_chip *adc, u16 offset, u8 mask, u8 val)
return
regmap_update_bits
(
adc
->
regmap
,
adc
->
base
+
offset
,
mask
,
val
);
}
static
int
adc5_prescaling_from_dt
(
u32
num
,
u32
den
)
{
unsigned
int
pre
;
for
(
pre
=
0
;
pre
<
ARRAY_SIZE
(
adc5_prescale_ratios
);
pre
++
)
if
(
adc5_prescale_ratios
[
pre
].
num
==
num
&&
adc5_prescale_ratios
[
pre
].
den
==
den
)
break
;
if
(
pre
==
ARRAY_SIZE
(
adc5_prescale_ratios
))
return
-
EINVAL
;
return
pre
;
}
static
int
adc5_hw_settle_time_from_dt
(
u32
value
,
const
unsigned
int
*
hw_settle
)
{
unsigned
int
i
;
for
(
i
=
0
;
i
<
VADC_HW_SETTLE_SAMPLES_MAX
;
i
++
)
{
if
(
value
==
hw_settle
[
i
])
return
i
;
}
return
-
EINVAL
;
}
static
int
adc5_avg_samples_from_dt
(
u32
value
)
{
if
(
!
is_power_of_2
(
value
)
||
value
>
ADC5_AVG_SAMPLES_MAX
)
return
-
EINVAL
;
return
__ffs
(
value
);
}
static
int
adc5_decimation_from_dt
(
u32
value
,
const
unsigned
int
*
decimation
)
{
unsigned
int
i
;
for
(
i
=
0
;
i
<
ADC5_DECIMATION_SAMPLES_MAX
;
i
++
)
{
if
(
value
==
decimation
[
i
])
return
i
;
}
return
-
EINVAL
;
}
static
int
adc5_read_voltage_data
(
struct
adc5_chip
*
adc
,
u16
*
data
)
{
int
ret
;
...
...
@@ -511,7 +451,7 @@ static int adc_read_raw_common(struct iio_dev *indio_dev,
return
ret
;
ret
=
qcom_adc5_hw_scale
(
prop
->
scale_fn_type
,
&
adc5_prescale_ratios
[
prop
->
prescale
]
,
prop
->
prescale
,
adc
->
data
,
adc_code_volt
,
val
);
if
(
ret
)
...
...
@@ -717,7 +657,7 @@ static int adc5_get_dt_channel_data(struct adc5_chip *adc,
ret
=
of_property_read_u32
(
node
,
"qcom,decimation"
,
&
value
);
if
(
!
ret
)
{
ret
=
adc5_decimation_from_dt
(
value
,
data
->
decimation
);
ret
=
qcom_
adc5_decimation_from_dt
(
value
,
data
->
decimation
);
if
(
ret
<
0
)
{
dev_err
(
dev
,
"%02x invalid decimation %d
\n
"
,
chan
,
value
);
...
...
@@ -730,7 +670,7 @@ static int adc5_get_dt_channel_data(struct adc5_chip *adc,
ret
=
of_property_read_u32_array
(
node
,
"qcom,pre-scaling"
,
varr
,
2
);
if
(
!
ret
)
{
ret
=
adc5_prescaling_from_dt
(
varr
[
0
],
varr
[
1
]);
ret
=
qcom_
adc5_prescaling_from_dt
(
varr
[
0
],
varr
[
1
]);
if
(
ret
<
0
)
{
dev_err
(
dev
,
"%02x invalid pre-scaling <%d %d>
\n
"
,
chan
,
varr
[
0
],
varr
[
1
]);
...
...
@@ -759,11 +699,9 @@ static int adc5_get_dt_channel_data(struct adc5_chip *adc,
if
((
dig_version
[
0
]
>=
ADC5_HW_SETTLE_DIFF_MINOR
&&
dig_version
[
1
]
>=
ADC5_HW_SETTLE_DIFF_MAJOR
)
||
adc
->
data
->
info
==
&
adc7_info
)
ret
=
adc5_hw_settle_time_from_dt
(
value
,
data
->
hw_settle_2
);
ret
=
qcom_adc5_hw_settle_time_from_dt
(
value
,
data
->
hw_settle_2
);
else
ret
=
adc5_hw_settle_time_from_dt
(
value
,
data
->
hw_settle_1
);
ret
=
qcom_adc5_hw_settle_time_from_dt
(
value
,
data
->
hw_settle_1
);
if
(
ret
<
0
)
{
dev_err
(
dev
,
"%02x invalid hw-settle-time %d us
\n
"
,
...
...
@@ -777,7 +715,7 @@ static int adc5_get_dt_channel_data(struct adc5_chip *adc,
ret
=
of_property_read_u32
(
node
,
"qcom,avg-samples"
,
&
value
);
if
(
!
ret
)
{
ret
=
adc5_avg_samples_from_dt
(
value
);
ret
=
qcom_
adc5_avg_samples_from_dt
(
value
);
if
(
ret
<
0
)
{
dev_err
(
dev
,
"%02x invalid avg-samples %d
\n
"
,
chan
,
value
);
...
...
@@ -870,8 +808,6 @@ static int adc5_get_dt_data(struct adc5_chip *adc, struct device_node *node)
struct
adc5_channel_prop
prop
,
*
chan_props
;
struct
device_node
*
child
;
unsigned
int
index
=
0
;
const
struct
of_device_id
*
id
;
const
struct
adc5_data
*
data
;
int
ret
;
adc
->
nchannels
=
of_get_available_child_count
(
node
);
...
...
@@ -890,24 +826,21 @@ static int adc5_get_dt_data(struct adc5_chip *adc, struct device_node *node)
chan_props
=
adc
->
chan_props
;
iio_chan
=
adc
->
iio_chans
;
id
=
of_match_node
(
adc5_match_table
,
node
);
if
(
id
)
data
=
id
->
data
;
else
data
=
&
adc5_data_pmic
;
adc
->
data
=
data
;
adc
->
data
=
of_device_get_match_data
(
adc
->
dev
);
if
(
!
adc
->
data
)
adc
->
data
=
&
adc5_data_pmic
;
for_each_available_child_of_node
(
node
,
child
)
{
ret
=
adc5_get_dt_channel_data
(
adc
,
&
prop
,
child
,
data
);
ret
=
adc5_get_dt_channel_data
(
adc
,
&
prop
,
child
,
adc
->
data
);
if
(
ret
)
{
of_node_put
(
child
);
return
ret
;
}
prop
.
scale_fn_type
=
data
->
adc_chans
[
prop
.
channel
].
scale_fn_type
;
adc
->
data
->
adc_chans
[
prop
.
channel
].
scale_fn_type
;
*
chan_props
=
prop
;
adc_chan
=
&
data
->
adc_chans
[
prop
.
channel
];
adc_chan
=
&
adc
->
data
->
adc_chans
[
prop
.
channel
];
iio_chan
->
channel
=
prop
.
channel
;
iio_chan
->
datasheet_name
=
prop
.
datasheet_name
;
...
...
drivers/iio/adc/qcom-spmi-vadc.c
View file @
20cc0ddd
...
...
@@ -7,6 +7,7 @@
#include <linux/completion.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/iio/adc/qcom-vadc-common.h>
#include <linux/iio/iio.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
...
...
@@ -20,8 +21,6 @@
#include <dt-bindings/iio/qcom,spmi-vadc.h>
#include "qcom-vadc-common.h"
/* VADC register and bit definitions */
#define VADC_REVISION2 0x1
#define VADC_REVISION2_SUPPORTED_VADC 1
...
...
drivers/iio/adc/qcom-vadc-common.c
View file @
20cc0ddd
...
...
@@ -2,50 +2,61 @@
#include <linux/bug.h>
#include <linux/kernel.h>
#include <linux/bitops.h>
#include <linux/fixp-arith.h>
#include <linux/iio/adc/qcom-vadc-common.h>
#include <linux/math64.h>
#include <linux/log2.h>
#include <linux/err.h>
#include <linux/module.h>
#include <linux/units.h>
#include "qcom-vadc-common.h"
/**
* struct vadc_map_pt - Map the graph representation for ADC channel
* @x: Represent the ADC digitized code.
* @y: Represent the physical data which can be temperature, voltage,
* resistance.
*/
struct
vadc_map_pt
{
s32
x
;
s32
y
;
};
/* Voltage to temperature */
static
const
struct
vadc_map_pt
adcmap_100k_104ef_104fb
[]
=
{
{
1758
,
-
40
},
{
1742
,
-
35
},
{
1719
,
-
30
},
{
1691
,
-
25
},
{
1654
,
-
20
},
{
1608
,
-
15
},
{
1551
,
-
10
},
{
1483
,
-
5
},
{
1404
,
0
},
{
1315
,
5
},
{
1218
,
10
},
{
1114
,
15
},
{
1007
,
20
},
{
900
,
25
},
{
795
,
30
},
{
696
,
35
},
{
605
,
40
},
{
522
,
45
},
{
448
,
50
},
{
383
,
55
},
{
327
,
60
},
{
278
,
65
},
{
237
,
70
},
{
202
,
75
},
{
172
,
80
},
{
146
,
85
},
{
125
,
90
},
{
107
,
95
},
{
92
,
100
},
{
79
,
105
},
{
68
,
110
},
{
59
,
115
},
{
51
,
120
},
{
44
,
125
}
{
1758
,
-
40
000
},
{
1742
,
-
35
000
},
{
1719
,
-
30
000
},
{
1691
,
-
25
000
},
{
1654
,
-
20
000
},
{
1608
,
-
15
000
},
{
1551
,
-
10
000
},
{
1483
,
-
5
000
},
{
1404
,
0
},
{
1315
,
5
000
},
{
1218
,
10
000
},
{
1114
,
15
000
},
{
1007
,
20
000
},
{
900
,
25
000
},
{
795
,
30
000
},
{
696
,
35
000
},
{
605
,
40
000
},
{
522
,
45
000
},
{
448
,
50
000
},
{
383
,
55
000
},
{
327
,
60
000
},
{
278
,
65
000
},
{
237
,
70
000
},
{
202
,
75
000
},
{
172
,
80
000
},
{
146
,
85
000
},
{
125
,
90
000
},
{
107
,
95
000
},
{
92
,
100
000
},
{
79
,
105
000
},
{
68
,
110
000
},
{
59
,
115
000
},
{
51
,
120
000
},
{
44
,
125
000
}
};
/*
...
...
@@ -90,18 +101,18 @@ static const struct vadc_map_pt adcmap_100k_104ef_104fb_1875_vref[] = {
};
static
const
struct
vadc_map_pt
adcmap7_die_temp
[]
=
{
{
433700
,
1967
},
{
473100
,
1964
},
{
512400
,
1957
},
{
551500
,
1949
},
{
590500
,
1940
},
{
6
29300
,
1930
},
{
6
67900
,
1921
},
{
706400
,
1910
},
{
744600
,
1896
},
{
782500
,
1878
},
{
820100
,
1859
},
{
857300
,
0
},
{
857300
,
160000
},
{
820100
,
140000
},
{
782500
,
120000
},
{
744600
,
100000
},
{
706400
,
80000
},
{
6
67900
,
60000
},
{
6
29300
,
40000
},
{
590500
,
20000
},
{
551500
,
0
},
{
512400
,
-
20000
},
{
473100
,
-
40000
},
{
433700
,
-
60000
},
};
/*
...
...
@@ -278,6 +289,18 @@ static const struct vadc_map_pt adcmap7_100k[] = {
{
2420
,
130048
}
};
static
const
struct
vadc_prescale_ratio
adc5_prescale_ratios
[]
=
{
{.
num
=
1
,
.
den
=
1
},
{.
num
=
1
,
.
den
=
3
},
{.
num
=
1
,
.
den
=
4
},
{.
num
=
1
,
.
den
=
6
},
{.
num
=
1
,
.
den
=
20
},
{.
num
=
1
,
.
den
=
8
},
{.
num
=
10
,
.
den
=
81
},
{.
num
=
1
,
.
den
=
10
},
{.
num
=
1
,
.
den
=
16
}
};
static
int
qcom_vadc_scale_hw_calib_volt
(
const
struct
vadc_prescale_ratio
*
prescale
,
const
struct
adc5_data
*
data
,
...
...
@@ -323,43 +346,23 @@ static struct qcom_adc5_scale_type scale_adc5_fn[] = {
static
int
qcom_vadc_map_voltage_temp
(
const
struct
vadc_map_pt
*
pts
,
u32
tablesize
,
s32
input
,
int
*
output
)
{
bool
descending
=
1
;
u32
i
=
0
;
if
(
!
pts
)
return
-
EINVAL
;
/* Check if table is descending or ascending */
if
(
tablesize
>
1
)
{
if
(
pts
[
0
].
x
<
pts
[
1
].
x
)
descending
=
0
;
}
while
(
i
<
tablesize
)
{
if
((
descending
)
&&
(
pts
[
i
].
x
<
input
))
{
/* table entry is less than measured*/
/* value and table is descending, stop */
break
;
}
else
if
((
!
descending
)
&&
(
pts
[
i
].
x
>
input
))
{
/* table entry is greater than measured*/
/*value and table is ascending, stop */
break
;
}
while
(
i
<
tablesize
&&
pts
[
i
].
x
>
input
)
i
++
;
}
if
(
i
==
0
)
{
*
output
=
pts
[
0
].
y
;
}
else
if
(
i
==
tablesize
)
{
*
output
=
pts
[
tablesize
-
1
].
y
;
}
else
{
/* result is between search_index and search_index-1 */
/* interpolate linearly */
*
output
=
(((
s32
)((
pts
[
i
].
y
-
pts
[
i
-
1
].
y
)
*
(
input
-
pts
[
i
-
1
].
x
))
/
(
pts
[
i
].
x
-
pts
[
i
-
1
].
x
))
+
pts
[
i
-
1
].
y
);
*
output
=
fixp_linear_interpolate
(
pts
[
i
-
1
].
x
,
pts
[
i
-
1
].
y
,
pts
[
i
].
x
,
pts
[
i
].
y
,
input
);
}
return
0
;
...
...
@@ -415,8 +418,6 @@ static int qcom_vadc_scale_therm(const struct vadc_linear_graph *calib_graph,
if
(
ret
)
return
ret
;
*
result_mdec
*=
1000
;
return
0
;
}
...
...
@@ -563,33 +564,13 @@ static int qcom_vadc7_scale_hw_calib_die_temp(
u16
adc_code
,
int
*
result_mdec
)
{
int
voltage
,
vtemp0
,
temp
,
i
;
int
voltage
;
voltage
=
qcom_vadc_scale_code_voltage_factor
(
adc_code
,
prescale
,
data
,
1
);
if
(
adcmap7_die_temp
[
0
].
x
>
voltage
)
{
*
result_mdec
=
DIE_TEMP_ADC7_SCALE_1
;
return
0
;
}
if
(
adcmap7_die_temp
[
ARRAY_SIZE
(
adcmap7_die_temp
)
-
1
].
x
<=
voltage
)
{
*
result_mdec
=
DIE_TEMP_ADC7_MAX
;
return
0
;
}
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
adcmap7_die_temp
);
i
++
)
if
(
adcmap7_die_temp
[
i
].
x
>
voltage
)
break
;
vtemp0
=
adcmap7_die_temp
[
i
-
1
].
x
;
voltage
=
voltage
-
vtemp0
;
temp
=
div64_s64
(
voltage
*
DIE_TEMP_ADC7_SCALE_FACTOR
,
adcmap7_die_temp
[
i
-
1
].
y
);
temp
+=
DIE_TEMP_ADC7_SCALE_1
+
(
DIE_TEMP_ADC7_SCALE_2
*
(
i
-
1
));
*
result_mdec
=
temp
;
return
0
;
return
qcom_vadc_map_voltage_temp
(
adcmap7_die_temp
,
ARRAY_SIZE
(
adcmap7_die_temp
),
voltage
,
result_mdec
);
}
static
int
qcom_vadc_scale_hw_smb_temp
(
...
...
@@ -647,10 +628,12 @@ int qcom_vadc_scale(enum vadc_scale_fn_type scaletype,
EXPORT_SYMBOL
(
qcom_vadc_scale
);
int
qcom_adc5_hw_scale
(
enum
vadc_scale_fn_type
scaletype
,
const
struct
vadc_prescale_ratio
*
prescale
,
unsigned
int
prescale_ratio
,
const
struct
adc5_data
*
data
,
u16
adc_code
,
int
*
result
)
{
const
struct
vadc_prescale_ratio
*
prescale
=
&
adc5_prescale_ratios
[
prescale_ratio
];
if
(
!
(
scaletype
>=
SCALE_HW_CALIB_DEFAULT
&&
scaletype
<
SCALE_HW_CALIB_INVALID
))
{
pr_err
(
"Invalid scale type %d
\n
"
,
scaletype
);
...
...
@@ -662,6 +645,58 @@ int qcom_adc5_hw_scale(enum vadc_scale_fn_type scaletype,
}
EXPORT_SYMBOL
(
qcom_adc5_hw_scale
);
int
qcom_adc5_prescaling_from_dt
(
u32
num
,
u32
den
)
{
unsigned
int
pre
;
for
(
pre
=
0
;
pre
<
ARRAY_SIZE
(
adc5_prescale_ratios
);
pre
++
)
if
(
adc5_prescale_ratios
[
pre
].
num
==
num
&&
adc5_prescale_ratios
[
pre
].
den
==
den
)
break
;
if
(
pre
==
ARRAY_SIZE
(
adc5_prescale_ratios
))
return
-
EINVAL
;
return
pre
;
}
EXPORT_SYMBOL
(
qcom_adc5_prescaling_from_dt
);
int
qcom_adc5_hw_settle_time_from_dt
(
u32
value
,
const
unsigned
int
*
hw_settle
)
{
unsigned
int
i
;
for
(
i
=
0
;
i
<
VADC_HW_SETTLE_SAMPLES_MAX
;
i
++
)
{
if
(
value
==
hw_settle
[
i
])
return
i
;
}
return
-
EINVAL
;
}
EXPORT_SYMBOL
(
qcom_adc5_hw_settle_time_from_dt
);
int
qcom_adc5_avg_samples_from_dt
(
u32
value
)
{
if
(
!
is_power_of_2
(
value
)
||
value
>
ADC5_AVG_SAMPLES_MAX
)
return
-
EINVAL
;
return
__ffs
(
value
);
}
EXPORT_SYMBOL
(
qcom_adc5_avg_samples_from_dt
);
int
qcom_adc5_decimation_from_dt
(
u32
value
,
const
unsigned
int
*
decimation
)
{
unsigned
int
i
;
for
(
i
=
0
;
i
<
ADC5_DECIMATION_SAMPLES_MAX
;
i
++
)
{
if
(
value
==
decimation
[
i
])
return
i
;
}
return
-
EINVAL
;
}
EXPORT_SYMBOL
(
qcom_adc5_decimation_from_dt
);
int
qcom_vadc_decimation_from_dt
(
u32
value
)
{
if
(
!
is_power_of_2
(
value
)
||
value
<
VADC_DECIMATION_MIN
||
...
...
drivers/iio/inkern.c
View file @
20cc0ddd
...
...
@@ -191,7 +191,7 @@ static struct iio_channel *of_iio_channel_get(struct device_node *np, int index)
return
ERR_PTR
(
err
);
}
st
atic
st
ruct
iio_channel
*
of_iio_channel_get_by_name
(
struct
device_node
*
np
,
struct
iio_channel
*
of_iio_channel_get_by_name
(
struct
device_node
*
np
,
const
char
*
name
)
{
struct
iio_channel
*
chan
=
NULL
;
...
...
@@ -230,6 +230,7 @@ static struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
return
chan
;
}
EXPORT_SYMBOL_GPL
(
of_iio_channel_get_by_name
);
static
struct
iio_channel
*
of_iio_channel_get_all
(
struct
device
*
dev
)
{
...
...
@@ -272,12 +273,6 @@ static struct iio_channel *of_iio_channel_get_all(struct device *dev)
#else
/* CONFIG_OF */
static
inline
struct
iio_channel
*
of_iio_channel_get_by_name
(
struct
device_node
*
np
,
const
char
*
name
)
{
return
NULL
;
}
static
inline
struct
iio_channel
*
of_iio_channel_get_all
(
struct
device
*
dev
)
{
return
NULL
;
...
...
@@ -393,6 +388,29 @@ struct iio_channel *devm_iio_channel_get(struct device *dev,
}
EXPORT_SYMBOL_GPL
(
devm_iio_channel_get
);
struct
iio_channel
*
devm_of_iio_channel_get_by_name
(
struct
device
*
dev
,
struct
device_node
*
np
,
const
char
*
channel_name
)
{
struct
iio_channel
**
ptr
,
*
channel
;
ptr
=
devres_alloc
(
devm_iio_channel_free
,
sizeof
(
*
ptr
),
GFP_KERNEL
);
if
(
!
ptr
)
return
ERR_PTR
(
-
ENOMEM
);
channel
=
of_iio_channel_get_by_name
(
np
,
channel_name
);
if
(
IS_ERR
(
channel
))
{
devres_free
(
ptr
);
return
channel
;
}
*
ptr
=
channel
;
devres_add
(
dev
,
ptr
);
return
channel
;
}
EXPORT_SYMBOL_GPL
(
devm_of_iio_channel_get_by_name
);
struct
iio_channel
*
iio_channel_get_all
(
struct
device
*
dev
)
{
const
char
*
name
;
...
...
include/linux/fixp-arith.h
View file @
20cc0ddd
...
...
@@ -141,4 +141,23 @@ static inline s32 fixp_sin32_rad(u32 radians, u32 twopi)
#define fixp_cos32_rad(rad, twopi) \
fixp_sin32_rad(rad + twopi / 4, twopi)
/**
* fixp_linear_interpolate() - interpolates a value from two known points
*
* @x0: x value of point 0
* @y0: y value of point 0
* @x1: x value of point 1
* @y1: y value of point 1
* @x: the linear interpolant
*/
static
inline
int
fixp_linear_interpolate
(
int
x0
,
int
y0
,
int
x1
,
int
y1
,
int
x
)
{
if
(
y0
==
y1
||
x
==
x0
)
return
y0
;
if
(
x1
==
x0
||
x
==
x1
)
return
y1
;
return
y0
+
((
y1
-
y0
)
*
(
x
-
x0
)
/
(
x1
-
x0
));
}
#endif
drivers
/iio/adc/qcom-vadc-common.h
→
include/linux
/iio/adc/qcom-vadc-common.h
View file @
20cc0ddd
...
...
@@ -6,6 +6,8 @@
#ifndef QCOM_VADC_COMMON_H
#define QCOM_VADC_COMMON_H
#include <linux/types.h>
#define VADC_CONV_TIME_MIN_US 2000
#define VADC_CONV_TIME_MAX_US 2100
...
...
@@ -52,22 +54,6 @@
#define R_PU_100K 100000
#define RATIO_MAX_ADC7 BIT(14)
#define DIE_TEMP_ADC7_SCALE_1 -60000
#define DIE_TEMP_ADC7_SCALE_2 20000
#define DIE_TEMP_ADC7_SCALE_FACTOR 1000
#define DIE_TEMP_ADC7_MAX 160000
/**
* struct vadc_map_pt - Map the graph representation for ADC channel
* @x: Represent the ADC digitized code.
* @y: Represent the physical data which can be temperature, voltage,
* resistance.
*/
struct
vadc_map_pt
{
s32
x
;
s32
y
;
};
/*
* VADC_CALIB_ABSOLUTE: uses the 625mV and 1.25V as reference channels.
* VADC_CALIB_RATIOMETRIC: uses the reference voltage (1.8V) and GND for
...
...
@@ -168,10 +154,18 @@ struct qcom_adc5_scale_type {
};
int
qcom_adc5_hw_scale
(
enum
vadc_scale_fn_type
scaletype
,
const
struct
vadc_prescale_ratio
*
prescale
,
unsigned
int
prescale_ratio
,
const
struct
adc5_data
*
data
,
u16
adc_code
,
int
*
result_mdec
);
int
qcom_adc5_prescaling_from_dt
(
u32
num
,
u32
den
);
int
qcom_adc5_hw_settle_time_from_dt
(
u32
value
,
const
unsigned
int
*
hw_settle
);
int
qcom_adc5_avg_samples_from_dt
(
u32
value
);
int
qcom_adc5_decimation_from_dt
(
u32
value
,
const
unsigned
int
*
decimation
);
int
qcom_vadc_decimation_from_dt
(
u32
value
);
#endif
/* QCOM_VADC_COMMON_H */
include/linux/iio/consumer.h
View file @
20cc0ddd
...
...
@@ -13,6 +13,7 @@
struct
iio_dev
;
struct
iio_chan_spec
;
struct
device
;
struct
device_node
;
/**
* struct iio_channel - everything needed for a consumer to use a channel
...
...
@@ -97,6 +98,41 @@ void iio_channel_release_all(struct iio_channel *chan);
*/
struct
iio_channel
*
devm_iio_channel_get_all
(
struct
device
*
dev
);
/**
* of_iio_channel_get_by_name() - get description of all that is needed to access channel.
* @np: Pointer to consumer device tree node
* @consumer_channel: Unique name to identify the channel on the consumer
* side. This typically describes the channels use within
* the consumer. E.g. 'battery_voltage'
*/
#ifdef CONFIG_OF
struct
iio_channel
*
of_iio_channel_get_by_name
(
struct
device_node
*
np
,
const
char
*
name
);
#else
static
inline
struct
iio_channel
*
of_iio_channel_get_by_name
(
struct
device_node
*
np
,
const
char
*
name
)
{
return
NULL
;
}
#endif
/**
* devm_of_iio_channel_get_by_name() - Resource managed version of of_iio_channel_get_by_name().
* @dev: Pointer to consumer device.
* @np: Pointer to consumer device tree node
* @consumer_channel: Unique name to identify the channel on the consumer
* side. This typically describes the channels use within
* the consumer. E.g. 'battery_voltage'
*
* Returns a pointer to negative errno if it is not able to get the iio channel
* otherwise returns valid pointer for iio channel.
*
* The allocated iio channel is automatically released when the device is
* unbound.
*/
struct
iio_channel
*
devm_of_iio_channel_get_by_name
(
struct
device
*
dev
,
struct
device_node
*
np
,
const
char
*
consumer_channel
);
struct
iio_cb_buffer
;
/**
* iio_channel_get_all_cb() - register callback for triggered capture
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment