This source file includes following definitions.
- deferred_fiq
- ams_delta_init_fiq
1
2
3
4
5
6
7
8
9
10
11
12
13 #include <linux/gpio/consumer.h>
14 #include <linux/gpio/machine.h>
15 #include <linux/gpio/driver.h>
16 #include <linux/interrupt.h>
17 #include <linux/irq.h>
18 #include <linux/module.h>
19 #include <linux/io.h>
20 #include <linux/platform_data/ams-delta-fiq.h>
21 #include <linux/platform_device.h>
22
23 #include <asm/fiq.h>
24
25 #include "ams-delta-fiq.h"
26 #include "board-ams-delta.h"
27
28 static struct fiq_handler fh = {
29 .name = "ams-delta-fiq"
30 };
31
32
33
34
35
36
37
38
39
40 static unsigned int fiq_buffer[1024];
41
42 static struct irq_chip *irq_chip;
43 static struct irq_data *irq_data[16];
44 static unsigned int irq_counter[16];
45
46 static const char *pin_name[16] __initconst = {
47 [AMS_DELTA_GPIO_PIN_KEYBRD_DATA] = "keybrd_data",
48 [AMS_DELTA_GPIO_PIN_KEYBRD_CLK] = "keybrd_clk",
49 };
50
51 static irqreturn_t deferred_fiq(int irq, void *dev_id)
52 {
53 struct irq_data *d;
54 int gpio, irq_num, fiq_count;
55
56
57
58
59
60 for (gpio = AMS_DELTA_GPIO_PIN_KEYBRD_CLK;
61 gpio <= AMS_DELTA_GPIO_PIN_HOOK_SWITCH; gpio++) {
62 d = irq_data[gpio];
63 irq_num = d->irq;
64 fiq_count = fiq_buffer[FIQ_CNT_INT_00 + gpio];
65
66 if (irq_counter[gpio] < fiq_count &&
67 gpio != AMS_DELTA_GPIO_PIN_KEYBRD_CLK) {
68
69
70
71
72
73 if (!WARN_ON_ONCE(!irq_chip->irq_unmask))
74 irq_chip->irq_unmask(d);
75 }
76 for (; irq_counter[gpio] < fiq_count; irq_counter[gpio]++)
77 generic_handle_irq(irq_num);
78 }
79 return IRQ_HANDLED;
80 }
81
82 void __init ams_delta_init_fiq(struct gpio_chip *chip,
83 struct platform_device *serio)
84 {
85 struct gpio_desc *gpiod, *data = NULL, *clk = NULL;
86 void *fiqhandler_start;
87 unsigned int fiqhandler_length;
88 struct pt_regs FIQ_regs;
89 unsigned long val, offset;
90 int i, retval;
91
92
93 irq_chip = chip->irq.chip;
94 if (!irq_chip) {
95 pr_err("%s: GPIO chip %s is missing IRQ function\n", __func__,
96 chip->label);
97 return;
98 }
99
100 for (i = 0; i < ARRAY_SIZE(irq_data); i++) {
101 gpiod = gpiochip_request_own_desc(chip, i, pin_name[i],
102 GPIO_ACTIVE_HIGH, GPIOD_IN);
103 if (IS_ERR(gpiod)) {
104 pr_err("%s: failed to get GPIO pin %d (%ld)\n",
105 __func__, i, PTR_ERR(gpiod));
106 return;
107 }
108
109 irq_data[i] = irq_get_irq_data(gpiod_to_irq(gpiod));
110
111
112
113
114
115
116 switch (i) {
117 case AMS_DELTA_GPIO_PIN_KEYBRD_DATA:
118 data = gpiod;
119 gpiod_direction_input(data);
120 break;
121 case AMS_DELTA_GPIO_PIN_KEYBRD_CLK:
122 clk = gpiod;
123 gpiod_direction_input(clk);
124 break;
125 default:
126 gpiochip_free_own_desc(gpiod);
127 break;
128 }
129 }
130 if (!data || !clk)
131 goto out_gpio;
132
133 fiqhandler_start = &qwerty_fiqin_start;
134 fiqhandler_length = &qwerty_fiqin_end - &qwerty_fiqin_start;
135 pr_info("Installing fiq handler from %p, length 0x%x\n",
136 fiqhandler_start, fiqhandler_length);
137
138 retval = claim_fiq(&fh);
139 if (retval) {
140 pr_err("ams_delta_init_fiq(): couldn't claim FIQ, ret=%d\n",
141 retval);
142 goto out_gpio;
143 }
144
145 retval = request_irq(INT_DEFERRED_FIQ, deferred_fiq,
146 IRQ_TYPE_EDGE_RISING, "deferred_fiq", NULL);
147 if (retval < 0) {
148 pr_err("Failed to get deferred_fiq IRQ, ret=%d\n", retval);
149 release_fiq(&fh);
150 goto out_gpio;
151 }
152
153
154
155
156 offset = IRQ_ILR0_REG_OFFSET +
157 ((INT_DEFERRED_FIQ - NR_IRQS_LEGACY) & 0x1f) * 0x4;
158 val = omap_readl(DEFERRED_FIQ_IH_BASE + offset) & ~(1 << 1);
159 omap_writel(val, DEFERRED_FIQ_IH_BASE + offset);
160
161 set_fiq_handler(fiqhandler_start, fiqhandler_length);
162
163
164
165
166
167 fiq_buffer[FIQ_GPIO_INT_MASK] = 0;
168 fiq_buffer[FIQ_MASK] = 0;
169 fiq_buffer[FIQ_STATE] = 0;
170 fiq_buffer[FIQ_KEY] = 0;
171 fiq_buffer[FIQ_KEYS_CNT] = 0;
172 fiq_buffer[FIQ_KEYS_HICNT] = 0;
173 fiq_buffer[FIQ_TAIL_OFFSET] = 0;
174 fiq_buffer[FIQ_HEAD_OFFSET] = 0;
175 fiq_buffer[FIQ_BUF_LEN] = 256;
176 fiq_buffer[FIQ_MISSED_KEYS] = 0;
177 fiq_buffer[FIQ_BUFFER_START] =
178 (unsigned int) &fiq_buffer[FIQ_CIRC_BUFF];
179
180 for (i = FIQ_CNT_INT_00; i <= FIQ_CNT_INT_15; i++)
181 fiq_buffer[i] = 0;
182
183
184
185
186
187
188
189 FIQ_regs.ARM_r9 = (unsigned int)fiq_buffer;
190 set_fiq_regs(&FIQ_regs);
191
192 pr_info("request_fiq(): fiq_buffer = %p\n", fiq_buffer);
193
194
195
196
197 offset = IRQ_ILR0_REG_OFFSET + (INT_GPIO_BANK1 - NR_IRQS_LEGACY) * 0x4;
198 val = omap_readl(OMAP_IH1_BASE + offset) | 1;
199 omap_writel(val, OMAP_IH1_BASE + offset);
200
201
202 serio->resource[0].start = gpiod_to_irq(clk);
203 serio->resource[0].end = serio->resource[0].start;
204 serio->dev.platform_data = fiq_buffer;
205
206
207
208
209
210
211
212
213
214
215
216
217
218 return;
219
220 out_gpio:
221 if (data)
222 gpiochip_free_own_desc(data);
223 if (clk)
224 gpiochip_free_own_desc(clk);
225 }