Skip to content

Commit a688404

Browse files
EvenxfJiri Kosina
authored andcommitted
HID: intel-thc-hid: intel-thc: Add THC DMA interfaces
As THC PIO only has 64 bytes FIFO length, THC DMAs are introduced to send/receive large data packets. THC has three types of DMA channels: Read DMA channel (RxDMA), Write DMA channel (TxDMA) and Software DMA (SWDMA). In addition to basic DMA functions, THC RxDMA also includes an auto hardware sequence which can handle external touch device's interrupt automatically without software involved. THC RxDMA channel usually is used for handling touch input reports. THC TxDMA is very similar with general IO TxDMA, and usually is used for sending command/request to exteranl touch device. THC SWDMA can perform read, write followed by read operation according to different configurations. Unlike RxDMA triggered by bus activity, SWDMA can be triggered by SW driver at any time, for example: - Retrieving an input report without interrupt - Sending command followed by reading response THC DMA operation flow includes 4 steps: 1. Allocate DMA buffers 2. Configure opcode, fill PRD table with DMA buffers, enable DMA channel 3. Wait for completion, read out DMA buffers and update buffer pointers 4. Stop DMA and release DMA buffers THC Hardware layer driver provides APIs for all above DMA Steps. Co-developed-by: Xinpeng Sun <[email protected]> Signed-off-by: Xinpeng Sun <[email protected]> Signed-off-by: Even Xu <[email protected]> Tested-by: Rui Zhang <[email protected]> Tested-by: Mark Pearson <[email protected]> Reviewed-by: Srinivas Pandruvada <[email protected]> Reviewed-by: Mark Pearson <[email protected]> Tested-by: Aaron Ma <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 86f5f4a commit a688404

File tree

5 files changed

+1142
-0
lines changed

5 files changed

+1142
-0
lines changed

drivers/hid/intel-thc-hid/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77

88
obj-$(CONFIG_INTEL_THC_HID) += intel-thc.o
99
intel-thc-objs += intel-thc/intel-thc-dev.o
10+
intel-thc-objs += intel-thc/intel-thc-dma.o
1011

1112
ccflags-y += -I $(src)/intel-thc

drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,14 @@ struct thc_device *thc_dev_init(struct device *device, void __iomem *mem_addr)
211211
thc_clear_state(thc_dev);
212212

213213
mutex_init(&thc_dev->thc_bus_lock);
214+
init_waitqueue_head(&thc_dev->write_complete_wait);
215+
init_waitqueue_head(&thc_dev->swdma_complete_wait);
216+
217+
thc_dev->dma_ctx = thc_dma_init(thc_dev);
218+
if (!thc_dev->dma_ctx) {
219+
dev_err_once(device, "DMA context init failed\n");
220+
return ERR_PTR(-ENOMEM);
221+
}
214222

215223
return thc_dev;
216224
}

drivers/hid/intel-thc-hid/intel-thc/intel-thc-dev.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
#include <linux/cdev.h>
88
#include <linux/mutex.h>
9+
#include <linux/workqueue.h>
10+
11+
#include "intel-thc-dma.h"
912

1013
#define THC_REGMAP_COMMON_OFFSET 0x10
1114
#define THC_REGMAP_MMIO_OFFSET 0x1000
@@ -27,6 +30,12 @@ enum thc_port_type {
2730
* @thc_bus_lock: mutex locker for THC config
2831
* @port_type: port type of THC port instance
2932
* @pio_int_supported: PIO interrupt supported flag
33+
* @dma_ctx: DMA specific data
34+
* @write_complete_wait: signal event for DMA write complete
35+
* @swdma_complete_wait: signal event for SWDMA sequence complete
36+
* @write_done: bool value that indicates if DMA write is done
37+
* @swdma_done: bool value that indicates if SWDMA swquence is done
38+
* @perf_limit: the delay between read operation and write operation
3039
*/
3140
struct thc_device {
3241
struct device *dev;
@@ -35,6 +44,15 @@ struct thc_device {
3544
struct mutex thc_bus_lock;
3645
enum thc_port_type port_type;
3746
bool pio_int_supported;
47+
48+
struct thc_dma_context *dma_ctx;
49+
50+
wait_queue_head_t write_complete_wait;
51+
wait_queue_head_t swdma_complete_wait;
52+
bool write_done;
53+
bool swdma_done;
54+
55+
u32 perf_limit;
3856
};
3957

4058
struct thc_device *thc_dev_init(struct device *device, void __iomem *mem_addr);

0 commit comments

Comments
 (0)