[adm5120] add USB drivers for the NFS-101U/WU profiles
[openwrt.git] / target / linux / s3c24xx / patches-2.6.24 / 1309--lis302dl-open-floodgates-on-zero-threshold.patch.patch
1 From ca57dbb5effd245e2619f4b730f8247f7279f954 Mon Sep 17 00:00:00 2001
2 From: Simon Kagstrom <simon.kagstrom@gmail.com>
3 Date: Thu, 16 Oct 2008 01:19:47 +0100
4 Subject: [PATCH] : lis302dl-open-floodgates-on-zero-threshold.patch
5
6 Generate data ready interrupts if threshold is zero
7
8 From: Simon Kagstrom <simon.kagstrom@gmail.com>
9
10 If the threshold is set to zero, enable the data ready interrupt
11 (generated one interrupt per datum). Otherwise use the freefall
12 interrupt as source.
13
14 Signed-off-by: Simon Kagstrom <simon.kagstrom@gmail.com>
15 ---
16 drivers/input/misc/lis302dl.c | 64 +++++++++++++++++++++++++++-------------
17 1 files changed, 43 insertions(+), 21 deletions(-)
18
19 diff --git a/drivers/input/misc/lis302dl.c b/drivers/input/misc/lis302dl.c
20 index d738199..e404a45 100644
21 --- a/drivers/input/misc/lis302dl.c
22 +++ b/drivers/input/misc/lis302dl.c
23 @@ -44,6 +44,7 @@
24 #include <linux/lis302dl.h>
25
26 /* Utility functions */
27 +
28 static u8 __reg_read(struct lis302dl_info *lis, u8 reg)
29 {
30 return (lis->pdata->lis302dl_bitbang_reg_read)(lis, reg);
31 @@ -132,6 +133,36 @@ static void __lis302dl_int_mode(struct device *dev, int int_pin,
32 }
33 }
34
35 +static void __enable_data_collection(struct lis302dl_info *lis)
36 +{
37 + u_int8_t ctrl1 = LIS302DL_CTRL1_PD | LIS302DL_CTRL1_Xen |
38 + LIS302DL_CTRL1_Yen | LIS302DL_CTRL1_Zen;
39 +
40 + /* make sure we're powered up and generate data ready */
41 + __reg_set_bit_mask(lis, LIS302DL_REG_CTRL1, ctrl1, ctrl1);
42 +
43 + /* If the threshold is zero, let the device generated an interrupt
44 + * on each datum */
45 + if (lis->threshold == 0) {
46 + __reg_write(lis, LIS302DL_REG_CTRL2, 0);
47 + __lis302dl_int_mode(lis->dev, 1, LIS302DL_INTMODE_DATA_READY);
48 + __lis302dl_int_mode(lis->dev, 2, LIS302DL_INTMODE_DATA_READY);
49 + } else {
50 + __reg_write(lis, LIS302DL_REG_CTRL2,
51 + LIS302DL_CTRL2_HPFF1);
52 + __reg_write(lis, LIS302DL_REG_FF_WU_THS_1, lis->threshold);
53 + __reg_write(lis, LIS302DL_REG_FF_WU_DURATION_1, lis->duration);
54 +
55 + /* Clear the HP filter "starting point" */
56 + __reg_read(lis, LIS302DL_REG_HP_FILTER_RESET);
57 + __reg_write(lis, LIS302DL_REG_FF_WU_CFG_1,
58 + LIS302DL_FFWUCFG_XHIE | LIS302DL_FFWUCFG_YHIE |
59 + LIS302DL_FFWUCFG_ZHIE);
60 + __lis302dl_int_mode(lis->dev, 1, LIS302DL_INTMODE_FF_WU_12);
61 + __lis302dl_int_mode(lis->dev, 2, LIS302DL_INTMODE_FF_WU_12);
62 + }
63 +}
64 +
65 #if 0
66 static void _report_btn_single(struct input_dev *inp, int btn)
67 {
68 @@ -263,7 +294,7 @@ static ssize_t set_scale(struct device *dev, struct device_attribute *attr,
69 /* Adjust the threshold */
70 lis->threshold = __mg_to_threshold(lis, threshold_mg);
71 if (lis->flags & LIS302DL_F_INPUT_OPEN)
72 - __reg_write(lis, LIS302DL_REG_FF_WU_THS_1, lis->threshold);
73 + __enable_data_collection(lis);
74
75 local_irq_restore(flags);
76
77 @@ -294,8 +325,14 @@ static ssize_t set_threshold(struct device *dev, struct device_attribute *attr,
78
79 /* Set the threshold and write it out if the device is used */
80 lis->threshold = __mg_to_threshold(lis, val);
81 - if (lis->flags & LIS302DL_F_INPUT_OPEN)
82 - __reg_write(lis, LIS302DL_REG_FF_WU_THS_1, lis->threshold);
83 +
84 + if (lis->flags & LIS302DL_F_INPUT_OPEN) {
85 + unsigned long flags;
86 +
87 + local_irq_save(flags);
88 + __enable_data_collection(lis);
89 + local_irq_restore(flags);
90 + }
91
92 return count;
93 }
94 @@ -562,29 +599,14 @@ static struct attribute_group lis302dl_attr_group = {
95 };
96
97 /* input device handling and driver core interaction */
98 -
99 static int lis302dl_input_open(struct input_dev *inp)
100 {
101 struct lis302dl_info *lis = inp->private;
102 - u_int8_t ctrl1 = LIS302DL_CTRL1_PD | LIS302DL_CTRL1_Xen |
103 - LIS302DL_CTRL1_Yen | LIS302DL_CTRL1_Zen;
104 - u_int8_t ctrl2 = LIS302DL_CTRL2_HPFF1;
105 unsigned long flags;
106
107 local_irq_save(flags);
108 - /* make sure we're powered up and generate data ready */
109 - __reg_set_bit_mask(lis, LIS302DL_REG_CTRL1, ctrl1, ctrl1);
110 -
111 - __reg_write(lis, LIS302DL_REG_CTRL2,
112 - ctrl2);
113 - __reg_write(lis, LIS302DL_REG_FF_WU_THS_1, lis->threshold);
114 - __reg_write(lis, LIS302DL_REG_FF_WU_DURATION_1, lis->duration);
115 -
116 - /* Clear the HP filter "starting point" */
117 - __reg_read(lis, LIS302DL_REG_HP_FILTER_RESET);
118 - __reg_write(lis, LIS302DL_REG_FF_WU_CFG_1, LIS302DL_FFWUCFG_XHIE |
119 - LIS302DL_FFWUCFG_YHIE | LIS302DL_FFWUCFG_ZHIE);
120
121 + __enable_data_collection(lis);
122 lis->flags |= LIS302DL_F_INPUT_OPEN;
123
124 /* kick it off -- since we are edge triggered, if we missed the edge
125 @@ -736,8 +758,8 @@ static int __devinit lis302dl_probe(struct platform_device *pdev)
126 /* push-pull, active-low */
127 __reg_write(lis, LIS302DL_REG_CTRL3, LIS302DL_CTRL3_IHL);
128
129 - __lis302dl_int_mode(lis->dev, 1, LIS302DL_INTMODE_FF_WU_12);
130 - __lis302dl_int_mode(lis->dev, 2, LIS302DL_INTMODE_FF_WU_12);
131 + __lis302dl_int_mode(lis->dev, 1, LIS302DL_INTMODE_GND);
132 + __lis302dl_int_mode(lis->dev, 2, LIS302DL_INTMODE_GND);
133
134 __reg_read(lis, LIS302DL_REG_STATUS);
135 __reg_read(lis, LIS302DL_REG_FF_WU_SRC_1);
136 --
137 1.5.6.5
138
This page took 0.050816 seconds and 5 git commands to generate.