aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-01-13 13:13:36 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-01-13 13:13:36 -0500
commit39272dde8ffcfd1322209e05f3f8fa4d14f796de (patch)
tree1c06907119d0ae484319379ec4404edf95ac37b5 /include/linux
parent67ad058d97b8cff441211b791d97e5f776b81210 (diff)
parent841e3ed977e0284e3680d6345d880a64e8072573 (diff)
Merge tag 'staging-4.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
Pull staging driver updates from Greg KH: "Here is the big staging driver pull request for 4.5-rc1. Lots of cleanups and fixes here, not as many as some releases, but 800+ isn't that bad. Full details in the shortlog. All of these have been in linux-next for a while" * tag 'staging-4.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (843 commits) Revert "arm64: dts: Add dts files to enable ION on Hi6220 SoC." staging: gdm724x: constify tty_port_operations structs staging: gdm72xx: add userspace data struct staging: gdm72xx: Replace timeval with ktime_t iio: adc: ina2xx: Fix incorrect report of data endianness to userspace. iio: light: us5182d: Refactor read_raw function iio: light: us5182d: Add interrupt support and events iio: light: us5182d: Fix enable status inconcistency iio: Make IIO value formating function globally available. staging: emxx_udc: use list_first_entry_or_null() staging/emxx_udc: fix 64-bit warnings STAGING: COMEDI: Using kernel types in plx9080.h STAGING: COMEDI: Added spaces around binary operators in plx9080.h STAGING: COMEDI: Fixed format of comments in plx9080.h staging: comedi: comedilib.h: Coding style warning fix for block comments staging: comedi: s526: add macros for counter control reg values staging: comedi: s526: replace counter mode bitfield struct staging: comedi: check for more errors for zero-length write staging: comedi: simplify returned errors for comedi_write() staging: comedi: return error on "write" if no command set up ...
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/iio/buffer-dma.h152
-rw-r--r--include/linux/iio/buffer-dmaengine.h18
-rw-r--r--include/linux/iio/buffer.h16
-rw-r--r--include/linux/iio/configfs.h15
-rw-r--r--include/linux/iio/iio.h2
-rw-r--r--include/linux/iio/sw_trigger.h70
-rw-r--r--include/linux/mfd/palmas.h75
7 files changed, 324 insertions, 24 deletions
diff --git a/include/linux/iio/buffer-dma.h b/include/linux/iio/buffer-dma.h
new file mode 100644
index 000000000000..767467d886de
--- /dev/null
+++ b/include/linux/iio/buffer-dma.h
@@ -0,0 +1,152 @@
1/*
2 * Copyright 2013-2015 Analog Devices Inc.
3 * Author: Lars-Peter Clausen <lars@metafoo.de>
4 *
5 * Licensed under the GPL-2.
6 */
7
8#ifndef __INDUSTRIALIO_DMA_BUFFER_H__
9#define __INDUSTRIALIO_DMA_BUFFER_H__
10
11#include <linux/list.h>
12#include <linux/kref.h>
13#include <linux/spinlock.h>
14#include <linux/mutex.h>
15#include <linux/iio/buffer.h>
16
17struct iio_dma_buffer_queue;
18struct iio_dma_buffer_ops;
19struct device;
20
21struct iio_buffer_block {
22 u32 size;
23 u32 bytes_used;
24};
25
26/**
27 * enum iio_block_state - State of a struct iio_dma_buffer_block
28 * @IIO_BLOCK_STATE_DEQUEUED: Block is not queued
29 * @IIO_BLOCK_STATE_QUEUED: Block is on the incoming queue
30 * @IIO_BLOCK_STATE_ACTIVE: Block is currently being processed by the DMA
31 * @IIO_BLOCK_STATE_DONE: Block is on the outgoing queue
32 * @IIO_BLOCK_STATE_DEAD: Block has been marked as to be freed
33 */
34enum iio_block_state {
35 IIO_BLOCK_STATE_DEQUEUED,
36 IIO_BLOCK_STATE_QUEUED,
37 IIO_BLOCK_STATE_ACTIVE,
38 IIO_BLOCK_STATE_DONE,
39 IIO_BLOCK_STATE_DEAD,
40};
41
42/**
43 * struct iio_dma_buffer_block - IIO buffer block
44 * @head: List head
45 * @size: Total size of the block in bytes
46 * @bytes_used: Number of bytes that contain valid data
47 * @vaddr: Virutal address of the blocks memory
48 * @phys_addr: Physical address of the blocks memory
49 * @queue: Parent DMA buffer queue
50 * @kref: kref used to manage the lifetime of block
51 * @state: Current state of the block
52 */
53struct iio_dma_buffer_block {
54 /* May only be accessed by the owner of the block */
55 struct list_head head;
56 size_t bytes_used;
57
58 /*
59 * Set during allocation, constant thereafter. May be accessed read-only
60 * by anybody holding a reference to the block.
61 */
62 void *vaddr;
63 dma_addr_t phys_addr;
64 size_t size;
65 struct iio_dma_buffer_queue *queue;
66
67 /* Must not be accessed outside the core. */
68 struct kref kref;
69 /*
70 * Must not be accessed outside the core. Access needs to hold
71 * queue->list_lock if the block is not owned by the core.
72 */
73 enum iio_block_state state;
74};
75
76/**
77 * struct iio_dma_buffer_queue_fileio - FileIO state for the DMA buffer
78 * @blocks: Buffer blocks used for fileio
79 * @active_block: Block being used in read()
80 * @pos: Read offset in the active block
81 * @block_size: Size of each block
82 */
83struct iio_dma_buffer_queue_fileio {
84 struct iio_dma_buffer_block *blocks[2];
85 struct iio_dma_buffer_block *active_block;
86 size_t pos;
87 size_t block_size;
88};
89
90/**
91 * struct iio_dma_buffer_queue - DMA buffer base structure
92 * @buffer: IIO buffer base structure
93 * @dev: Parent device
94 * @ops: DMA buffer callbacks
95 * @lock: Protects the incoming list, active and the fields in the fileio
96 * substruct
97 * @list_lock: Protects lists that contain blocks which can be modified in
98 * atomic context as well as blocks on those lists. This is the outgoing queue
99 * list and typically also a list of active blocks in the part that handles
100 * the DMA controller
101 * @incoming: List of buffers on the incoming queue
102 * @outgoing: List of buffers on the outgoing queue
103 * @active: Whether the buffer is currently active
104 * @fileio: FileIO state
105 */
106struct iio_dma_buffer_queue {
107 struct iio_buffer buffer;
108 struct device *dev;
109 const struct iio_dma_buffer_ops *ops;
110
111 struct mutex lock;
112 spinlock_t list_lock;
113 struct list_head incoming;
114 struct list_head outgoing;
115
116 bool active;
117
118 struct iio_dma_buffer_queue_fileio fileio;
119};
120
121/**
122 * struct iio_dma_buffer_ops - DMA buffer callback operations
123 * @submit: Called when a block is submitted to the DMA controller
124 * @abort: Should abort all pending transfers
125 */
126struct iio_dma_buffer_ops {
127 int (*submit)(struct iio_dma_buffer_queue *queue,
128 struct iio_dma_buffer_block *block);
129 void (*abort)(struct iio_dma_buffer_queue *queue);
130};
131
132void iio_dma_buffer_block_done(struct iio_dma_buffer_block *block);
133void iio_dma_buffer_block_list_abort(struct iio_dma_buffer_queue *queue,
134 struct list_head *list);
135
136int iio_dma_buffer_enable(struct iio_buffer *buffer,
137 struct iio_dev *indio_dev);
138int iio_dma_buffer_disable(struct iio_buffer *buffer,
139 struct iio_dev *indio_dev);
140int iio_dma_buffer_read(struct iio_buffer *buffer, size_t n,
141 char __user *user_buffer);
142size_t iio_dma_buffer_data_available(struct iio_buffer *buffer);
143int iio_dma_buffer_set_bytes_per_datum(struct iio_buffer *buffer, size_t bpd);
144int iio_dma_buffer_set_length(struct iio_buffer *buffer, int length);
145int iio_dma_buffer_request_update(struct iio_buffer *buffer);
146
147int iio_dma_buffer_init(struct iio_dma_buffer_queue *queue,
148 struct device *dma_dev, const struct iio_dma_buffer_ops *ops);
149void iio_dma_buffer_exit(struct iio_dma_buffer_queue *queue);
150void iio_dma_buffer_release(struct iio_dma_buffer_queue *queue);
151
152#endif
diff --git a/include/linux/iio/buffer-dmaengine.h b/include/linux/iio/buffer-dmaengine.h
new file mode 100644
index 000000000000..5dcddf427bb0
--- /dev/null
+++ b/include/linux/iio/buffer-dmaengine.h
@@ -0,0 +1,18 @@
1/*
2 * Copyright 2014-2015 Analog Devices Inc.
3 * Author: Lars-Peter Clausen <lars@metafoo.de>
4 *
5 * Licensed under the GPL-2 or later.
6 */
7
8#ifndef __IIO_DMAENGINE_H__
9#define __IIO_DMAENGINE_H__
10
11struct iio_buffer;
12struct device;
13
14struct iio_buffer *iio_dmaengine_buffer_alloc(struct device *dev,
15 const char *channel);
16void iio_dmaengine_buffer_free(struct iio_buffer *buffer);
17
18#endif
diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h
index 1600c55828e0..2ec3ad58e8a0 100644
--- a/include/linux/iio/buffer.h
+++ b/include/linux/iio/buffer.h
@@ -18,6 +18,12 @@
18struct iio_buffer; 18struct iio_buffer;
19 19
20/** 20/**
21 * INDIO_BUFFER_FLAG_FIXED_WATERMARK - Watermark level of the buffer can not be
22 * configured. It has a fixed value which will be buffer specific.
23 */
24#define INDIO_BUFFER_FLAG_FIXED_WATERMARK BIT(0)
25
26/**
21 * struct iio_buffer_access_funcs - access functions for buffers. 27 * struct iio_buffer_access_funcs - access functions for buffers.
22 * @store_to: actually store stuff to the buffer 28 * @store_to: actually store stuff to the buffer
23 * @read_first_n: try to get a specified number of bytes (must exist) 29 * @read_first_n: try to get a specified number of bytes (must exist)
@@ -27,9 +33,15 @@ struct iio_buffer;
27 * storage. 33 * storage.
28 * @set_bytes_per_datum:set number of bytes per datum 34 * @set_bytes_per_datum:set number of bytes per datum
29 * @set_length: set number of datums in buffer 35 * @set_length: set number of datums in buffer
36 * @enable: called if the buffer is attached to a device and the
37 * device starts sampling. Calls are balanced with
38 * @disable.
39 * @disable: called if the buffer is attached to a device and the
40 * device stops sampling. Calles are balanced with @enable.
30 * @release: called when the last reference to the buffer is dropped, 41 * @release: called when the last reference to the buffer is dropped,
31 * should free all resources allocated by the buffer. 42 * should free all resources allocated by the buffer.
32 * @modes: Supported operating modes by this buffer type 43 * @modes: Supported operating modes by this buffer type
44 * @flags: A bitmask combination of INDIO_BUFFER_FLAG_*
33 * 45 *
34 * The purpose of this structure is to make the buffer element 46 * The purpose of this structure is to make the buffer element
35 * modular as event for a given driver, different usecases may require 47 * modular as event for a given driver, different usecases may require
@@ -51,9 +63,13 @@ struct iio_buffer_access_funcs {
51 int (*set_bytes_per_datum)(struct iio_buffer *buffer, size_t bpd); 63 int (*set_bytes_per_datum)(struct iio_buffer *buffer, size_t bpd);
52 int (*set_length)(struct iio_buffer *buffer, int length); 64 int (*set_length)(struct iio_buffer *buffer, int length);
53 65
66 int (*enable)(struct iio_buffer *buffer, struct iio_dev *indio_dev);
67 int (*disable)(struct iio_buffer *buffer, struct iio_dev *indio_dev);
68
54 void (*release)(struct iio_buffer *buffer); 69 void (*release)(struct iio_buffer *buffer);
55 70
56 unsigned int modes; 71 unsigned int modes;
72 unsigned int flags;
57}; 73};
58 74
59/** 75/**
diff --git a/include/linux/iio/configfs.h b/include/linux/iio/configfs.h
new file mode 100644
index 000000000000..93befd67c15c
--- /dev/null
+++ b/include/linux/iio/configfs.h
@@ -0,0 +1,15 @@
1/*
2 * Industrial I/O configfs support
3 *
4 * Copyright (c) 2015 Intel Corporation
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published by
8 * the Free Software Foundation.
9 */
10#ifndef __IIO_CONFIGFS
11#define __IIO_CONFIGFS
12
13extern struct configfs_subsystem iio_configfs_subsys;
14
15#endif /* __IIO_CONFIGFS */
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index 19c94c9acc81..b5894118755f 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -636,6 +636,8 @@ static inline struct dentry *iio_get_debugfs_dentry(struct iio_dev *indio_dev)
636} 636}
637#endif 637#endif
638 638
639ssize_t iio_format_value(char *buf, unsigned int type, int size, int *vals);
640
639int iio_str_to_fixpoint(const char *str, int fract_mult, int *integer, 641int iio_str_to_fixpoint(const char *str, int fract_mult, int *integer,
640 int *fract); 642 int *fract);
641 643
diff --git a/include/linux/iio/sw_trigger.h b/include/linux/iio/sw_trigger.h
new file mode 100644
index 000000000000..5198f8ed08a4
--- /dev/null
+++ b/include/linux/iio/sw_trigger.h
@@ -0,0 +1,70 @@
1/*
2 * Industrial I/O software trigger interface
3 *
4 * Copyright (c) 2015 Intel Corporation
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published by
8 * the Free Software Foundation.
9 */
10
11#ifndef __IIO_SW_TRIGGER
12#define __IIO_SW_TRIGGER
13
14#include <linux/module.h>
15#include <linux/device.h>
16#include <linux/iio/iio.h>
17#include <linux/configfs.h>
18
19#define module_iio_sw_trigger_driver(__iio_sw_trigger_type) \
20 module_driver(__iio_sw_trigger_type, iio_register_sw_trigger_type, \
21 iio_unregister_sw_trigger_type)
22
23struct iio_sw_trigger_ops;
24
25struct iio_sw_trigger_type {
26 const char *name;
27 struct module *owner;
28 const struct iio_sw_trigger_ops *ops;
29 struct list_head list;
30 struct config_group *group;
31};
32
33struct iio_sw_trigger {
34 struct iio_trigger *trigger;
35 struct iio_sw_trigger_type *trigger_type;
36 struct config_group group;
37};
38
39struct iio_sw_trigger_ops {
40 struct iio_sw_trigger* (*probe)(const char *);
41 int (*remove)(struct iio_sw_trigger *);
42};
43
44static inline
45struct iio_sw_trigger *to_iio_sw_trigger(struct config_item *item)
46{
47 return container_of(to_config_group(item), struct iio_sw_trigger,
48 group);
49}
50
51int iio_register_sw_trigger_type(struct iio_sw_trigger_type *tt);
52void iio_unregister_sw_trigger_type(struct iio_sw_trigger_type *tt);
53
54struct iio_sw_trigger *iio_sw_trigger_create(const char *, const char *);
55void iio_sw_trigger_destroy(struct iio_sw_trigger *);
56
57int iio_sw_trigger_type_configfs_register(struct iio_sw_trigger_type *tt);
58void iio_sw_trigger_type_configfs_unregister(struct iio_sw_trigger_type *tt);
59
60static inline
61void iio_swt_group_init_type_name(struct iio_sw_trigger *t,
62 const char *name,
63 struct config_item_type *type)
64{
65#ifdef CONFIG_CONFIGFS_FS
66 config_group_init_type_name(&t->group, name, type);
67#endif
68}
69
70#endif /* __IIO_SW_TRIGGER */
diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h
index 13e1d96935ed..c800dbc42079 100644
--- a/include/linux/mfd/palmas.h
+++ b/include/linux/mfd/palmas.h
@@ -134,21 +134,32 @@ struct palmas_pmic_driver_data {
134 struct regulator_config config); 134 struct regulator_config config);
135}; 135};
136 136
137struct palmas_adc_wakeup_property {
138 int adc_channel_number;
139 int adc_high_threshold;
140 int adc_low_threshold;
141};
142
137struct palmas_gpadc_platform_data { 143struct palmas_gpadc_platform_data {
138 /* Channel 3 current source is only enabled during conversion */ 144 /* Channel 3 current source is only enabled during conversion */
139 int ch3_current; 145 int ch3_current; /* 0: off; 1: 10uA; 2: 400uA; 3: 800 uA */
140 146
141 /* Channel 0 current source can be used for battery detection. 147 /* Channel 0 current source can be used for battery detection.
142 * If used for battery detection this will cause a permanent current 148 * If used for battery detection this will cause a permanent current
143 * consumption depending on current level set here. 149 * consumption depending on current level set here.
144 */ 150 */
145 int ch0_current; 151 int ch0_current; /* 0: off; 1: 5uA; 2: 15uA; 3: 20 uA */
152 bool extended_delay; /* use extended delay for conversion */
146 153
147 /* default BAT_REMOVAL_DAT setting on device probe */ 154 /* default BAT_REMOVAL_DAT setting on device probe */
148 int bat_removal; 155 int bat_removal;
149 156
150 /* Sets the START_POLARITY bit in the RT_CTRL register */ 157 /* Sets the START_POLARITY bit in the RT_CTRL register */
151 int start_polarity; 158 int start_polarity;
159
160 int auto_conversion_period_ms;
161 struct palmas_adc_wakeup_property *adc_wakeup1_data;
162 struct palmas_adc_wakeup_property *adc_wakeup2_data;
152}; 163};
153 164
154struct palmas_reg_init { 165struct palmas_reg_init {
@@ -405,28 +416,7 @@ struct palmas_gpadc_calibration {
405 s32 offset_error; 416 s32 offset_error;
406}; 417};
407 418
408struct palmas_gpadc { 419#define PALMAS_DATASHEET_NAME(_name) "palmas-gpadc-chan-"#_name
409 struct device *dev;
410 struct palmas *palmas;
411
412 int ch3_current;
413 int ch0_current;
414
415 int gpadc_force;
416
417 int bat_removal;
418
419 struct mutex reading_lock;
420 struct completion irq_complete;
421
422 int eoc_sw_irq;
423
424 struct palmas_gpadc_calibration *palmas_cal_tbl;
425
426 int conv0_channel;
427 int conv1_channel;
428 int rt_channel;
429};
430 420
431struct palmas_gpadc_result { 421struct palmas_gpadc_result {
432 s32 raw_code; 422 s32 raw_code;
@@ -520,6 +510,43 @@ enum palmas_irqs {
520 PALMAS_NUM_IRQ, 510 PALMAS_NUM_IRQ,
521}; 511};
522 512
513/* Palmas GPADC Channels */
514enum {
515 PALMAS_ADC_CH_IN0,
516 PALMAS_ADC_CH_IN1,
517 PALMAS_ADC_CH_IN2,
518 PALMAS_ADC_CH_IN3,
519 PALMAS_ADC_CH_IN4,
520 PALMAS_ADC_CH_IN5,
521 PALMAS_ADC_CH_IN6,
522 PALMAS_ADC_CH_IN7,
523 PALMAS_ADC_CH_IN8,
524 PALMAS_ADC_CH_IN9,
525 PALMAS_ADC_CH_IN10,
526 PALMAS_ADC_CH_IN11,
527 PALMAS_ADC_CH_IN12,
528 PALMAS_ADC_CH_IN13,
529 PALMAS_ADC_CH_IN14,
530 PALMAS_ADC_CH_IN15,
531 PALMAS_ADC_CH_MAX,
532};
533
534/* Palmas GPADC Channel0 Current Source */
535enum {
536 PALMAS_ADC_CH0_CURRENT_SRC_0,
537 PALMAS_ADC_CH0_CURRENT_SRC_5,
538 PALMAS_ADC_CH0_CURRENT_SRC_15,
539 PALMAS_ADC_CH0_CURRENT_SRC_20,
540};
541
542/* Palmas GPADC Channel3 Current Source */
543enum {
544 PALMAS_ADC_CH3_CURRENT_SRC_0,
545 PALMAS_ADC_CH3_CURRENT_SRC_10,
546 PALMAS_ADC_CH3_CURRENT_SRC_400,
547 PALMAS_ADC_CH3_CURRENT_SRC_800,
548};
549
523struct palmas_pmic { 550struct palmas_pmic {
524 struct palmas *palmas; 551 struct palmas *palmas;
525 struct device *dev; 552 struct device *dev;