11
11
* it under the terms of the GNU General Public License version 2 as
12
12
* published by the Free Software Foundation.
13
13
*/
14
+ #include <linux/basic_mmio_gpio.h>
14
15
#include <linux/gpio.h>
15
16
#include <linux/kernel.h>
16
17
#include <linux/init.h>
40
41
41
42
#include <mach/ams-delta-fiq.h>
42
43
43
- static u8 ams_delta_latch1_reg ;
44
- static u16 ams_delta_latch2_reg ;
45
-
46
44
static const unsigned int ams_delta_keymap [] = {
47
45
KEY (0 , 0 , KEY_F1 ), /* Advert */
48
46
@@ -121,39 +119,32 @@ static const unsigned int ams_delta_keymap[] = {
121
119
KEY (7 , 3 , KEY_LEFTCTRL ), /* Vol down */
122
120
};
123
121
124
- void ams_delta_latch1_write (u8 mask , u8 value )
125
- {
126
- ams_delta_latch1_reg &= ~mask ;
127
- ams_delta_latch1_reg |= value ;
128
- * (volatile __u8 * ) AMS_DELTA_LATCH1_VIRT = ams_delta_latch1_reg ;
129
- }
130
-
131
- void ams_delta_latch2_write (u16 mask , u16 value )
132
- {
133
- ams_delta_latch2_reg &= ~mask ;
134
- ams_delta_latch2_reg |= value ;
135
- * (volatile __u16 * ) AMS_DELTA_LATCH2_VIRT = ams_delta_latch2_reg ;
136
- }
122
+ #define LATCH1_PHYS 0x01000000
123
+ #define LATCH1_VIRT 0xEA000000
124
+ #define MODEM_PHYS 0x04000000
125
+ #define MODEM_VIRT 0xEB000000
126
+ #define LATCH2_PHYS 0x08000000
127
+ #define LATCH2_VIRT 0xEC000000
137
128
138
129
static struct map_desc ams_delta_io_desc [] __initdata = {
139
130
/* AMS_DELTA_LATCH1 */
140
131
{
141
- .virtual = AMS_DELTA_LATCH1_VIRT ,
142
- .pfn = __phys_to_pfn (AMS_DELTA_LATCH1_PHYS ),
132
+ .virtual = LATCH1_VIRT ,
133
+ .pfn = __phys_to_pfn (LATCH1_PHYS ),
143
134
.length = 0x01000000 ,
144
135
.type = MT_DEVICE
145
136
},
146
137
/* AMS_DELTA_LATCH2 */
147
138
{
148
- .virtual = AMS_DELTA_LATCH2_VIRT ,
149
- .pfn = __phys_to_pfn (AMS_DELTA_LATCH2_PHYS ),
139
+ .virtual = LATCH2_VIRT ,
140
+ .pfn = __phys_to_pfn (LATCH2_PHYS ),
150
141
.length = 0x01000000 ,
151
142
.type = MT_DEVICE
152
143
},
153
144
/* AMS_DELTA_MODEM */
154
145
{
155
- .virtual = AMS_DELTA_MODEM_VIRT ,
156
- .pfn = __phys_to_pfn (AMS_DELTA_MODEM_PHYS ),
146
+ .virtual = MODEM_VIRT ,
147
+ .pfn = __phys_to_pfn (MODEM_PHYS ),
157
148
.length = 0x01000000 ,
158
149
.type = MT_DEVICE
159
150
}
@@ -173,6 +164,190 @@ static struct omap_board_config_kernel ams_delta_config[] __initdata = {
173
164
{ OMAP_TAG_LCD , & ams_delta_lcd_config },
174
165
};
175
166
167
+ static struct resource latch1_resources [] __initconst = {
168
+ [0 ] = {
169
+ .name = "dat" ,
170
+ .start = LATCH1_PHYS ,
171
+ .end = LATCH1_PHYS + (AMS_DELTA_LATCH1_NGPIO - 1 ) / 8 ,
172
+ .flags = IORESOURCE_MEM ,
173
+ },
174
+ };
175
+
176
+ static struct bgpio_pdata latch1_pdata __initconst = {
177
+ .base = AMS_DELTA_LATCH1_GPIO_BASE ,
178
+ .ngpio = AMS_DELTA_LATCH1_NGPIO ,
179
+ };
180
+
181
+ static struct platform_device latch1_gpio_device = {
182
+ .name = "basic-mmio-gpio" ,
183
+ .id = 0 ,
184
+ .resource = latch1_resources ,
185
+ .num_resources = ARRAY_SIZE (latch1_resources ),
186
+ .dev = {
187
+ .platform_data = & latch1_pdata ,
188
+ },
189
+ };
190
+
191
+ static struct resource latch2_resources [] __initconst = {
192
+ [0 ] = {
193
+ .name = "dat" ,
194
+ .start = LATCH2_PHYS ,
195
+ .end = LATCH2_PHYS + (AMS_DELTA_LATCH2_NGPIO - 1 ) / 8 ,
196
+ .flags = IORESOURCE_MEM ,
197
+ },
198
+ };
199
+
200
+ static struct bgpio_pdata latch2_pdata __initconst = {
201
+ .base = AMS_DELTA_LATCH2_GPIO_BASE ,
202
+ .ngpio = AMS_DELTA_LATCH2_NGPIO ,
203
+ };
204
+
205
+ static struct platform_device latch2_gpio_device = {
206
+ .name = "basic-mmio-gpio" ,
207
+ .id = 1 ,
208
+ .resource = latch2_resources ,
209
+ .num_resources = ARRAY_SIZE (latch2_resources ),
210
+ .dev = {
211
+ .platform_data = & latch2_pdata ,
212
+ },
213
+ };
214
+
215
+ static struct gpio latch_gpios [] __initconst = {
216
+ {
217
+ .gpio = AMS_DELTA_GPIO_PIN_LED_CAMERA ,
218
+ .flags = GPIOF_OUT_INIT_LOW ,
219
+ .label = "led_camera" ,
220
+ },
221
+ {
222
+ .gpio = AMS_DELTA_GPIO_PIN_LED_ADVERT ,
223
+ .flags = GPIOF_OUT_INIT_LOW ,
224
+ .label = "led_advert" ,
225
+ },
226
+ {
227
+ .gpio = AMS_DELTA_GPIO_PIN_LED_EMAIL ,
228
+ .flags = GPIOF_OUT_INIT_LOW ,
229
+ .label = "led_email" ,
230
+ },
231
+ {
232
+ .gpio = AMS_DELTA_GPIO_PIN_LED_HANDSFREE ,
233
+ .flags = GPIOF_OUT_INIT_LOW ,
234
+ .label = "led_handsfree" ,
235
+ },
236
+ {
237
+ .gpio = AMS_DELTA_GPIO_PIN_LED_VOICEMAIL ,
238
+ .flags = GPIOF_OUT_INIT_LOW ,
239
+ .label = "led_voicemail" ,
240
+ },
241
+ {
242
+ .gpio = AMS_DELTA_GPIO_PIN_LED_VOICE ,
243
+ .flags = GPIOF_OUT_INIT_LOW ,
244
+ .label = "led_voice" ,
245
+ },
246
+ {
247
+ .gpio = AMS_DELTA_LATCH1_GPIO_BASE + 6 ,
248
+ .flags = GPIOF_OUT_INIT_LOW ,
249
+ .label = "dockit1" ,
250
+ },
251
+ {
252
+ .gpio = AMS_DELTA_LATCH1_GPIO_BASE + 7 ,
253
+ .flags = GPIOF_OUT_INIT_LOW ,
254
+ .label = "dockit2" ,
255
+ },
256
+ {
257
+ .gpio = AMS_DELTA_GPIO_PIN_LCD_VBLEN ,
258
+ .flags = GPIOF_OUT_INIT_LOW ,
259
+ .label = "lcd_vblen" ,
260
+ },
261
+ {
262
+ .gpio = AMS_DELTA_GPIO_PIN_LCD_NDISP ,
263
+ .flags = GPIOF_OUT_INIT_LOW ,
264
+ .label = "lcd_ndisp" ,
265
+ },
266
+ {
267
+ .gpio = AMS_DELTA_GPIO_PIN_NAND_NCE ,
268
+ .flags = GPIOF_OUT_INIT_LOW ,
269
+ .label = "nand_nce" ,
270
+ },
271
+ {
272
+ .gpio = AMS_DELTA_GPIO_PIN_NAND_NRE ,
273
+ .flags = GPIOF_OUT_INIT_LOW ,
274
+ .label = "nand_nre" ,
275
+ },
276
+ {
277
+ .gpio = AMS_DELTA_GPIO_PIN_NAND_NWP ,
278
+ .flags = GPIOF_OUT_INIT_LOW ,
279
+ .label = "nand_nwp" ,
280
+ },
281
+ {
282
+ .gpio = AMS_DELTA_GPIO_PIN_NAND_NWE ,
283
+ .flags = GPIOF_OUT_INIT_LOW ,
284
+ .label = "nand_nwe" ,
285
+ },
286
+ {
287
+ .gpio = AMS_DELTA_GPIO_PIN_NAND_ALE ,
288
+ .flags = GPIOF_OUT_INIT_LOW ,
289
+ .label = "nand_ale" ,
290
+ },
291
+ {
292
+ .gpio = AMS_DELTA_GPIO_PIN_NAND_CLE ,
293
+ .flags = GPIOF_OUT_INIT_LOW ,
294
+ .label = "nand_cle" ,
295
+ },
296
+ {
297
+ .gpio = AMS_DELTA_GPIO_PIN_KEYBRD_PWR ,
298
+ .flags = GPIOF_OUT_INIT_LOW ,
299
+ .label = "keybrd_pwr" ,
300
+ },
301
+ {
302
+ .gpio = AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT ,
303
+ .flags = GPIOF_OUT_INIT_LOW ,
304
+ .label = "keybrd_dataout" ,
305
+ },
306
+ {
307
+ .gpio = AMS_DELTA_GPIO_PIN_SCARD_RSTIN ,
308
+ .flags = GPIOF_OUT_INIT_LOW ,
309
+ .label = "scard_rstin" ,
310
+ },
311
+ {
312
+ .gpio = AMS_DELTA_GPIO_PIN_SCARD_CMDVCC ,
313
+ .flags = GPIOF_OUT_INIT_LOW ,
314
+ .label = "scard_cmdvcc" ,
315
+ },
316
+ {
317
+ .gpio = AMS_DELTA_GPIO_PIN_MODEM_NRESET ,
318
+ .flags = GPIOF_OUT_INIT_LOW ,
319
+ .label = "modem_nreset" ,
320
+ },
321
+ {
322
+ .gpio = AMS_DELTA_GPIO_PIN_MODEM_CODEC ,
323
+ .flags = GPIOF_OUT_INIT_LOW ,
324
+ .label = "modem_codec" ,
325
+ },
326
+ {
327
+ .gpio = AMS_DELTA_LATCH2_GPIO_BASE + 14 ,
328
+ .flags = GPIOF_OUT_INIT_LOW ,
329
+ .label = "hookflash1" ,
330
+ },
331
+ {
332
+ .gpio = AMS_DELTA_LATCH2_GPIO_BASE + 15 ,
333
+ .flags = GPIOF_OUT_INIT_LOW ,
334
+ .label = "hookflash2" ,
335
+ },
336
+ };
337
+
338
+ void ams_delta_latch_write (int base , int ngpio , u16 mask , u16 value )
339
+ {
340
+ int bit = 0 ;
341
+ u16 bitpos = 1 << bit ;
342
+
343
+ for (; bit < ngpio ; bit ++ , bitpos = bitpos << 1 ) {
344
+ if (!(mask & bitpos ))
345
+ continue ;
346
+ gpio_set_value (base + bit , (value & bitpos ) != 0 );
347
+ }
348
+ }
349
+ EXPORT_SYMBOL (ams_delta_latch_write );
350
+
176
351
static struct resource ams_delta_nand_resources [] = {
177
352
[0 ] = {
178
353
.start = OMAP1_MPUIO_BASE ,
@@ -275,11 +450,13 @@ static struct omap1_cam_platform_data ams_delta_camera_platform_data = {
275
450
};
276
451
277
452
static struct platform_device * ams_delta_devices [] __initdata = {
453
+ & latch1_gpio_device ,
454
+ & latch2_gpio_device ,
278
455
& ams_delta_kp_device ,
279
456
& ams_delta_camera_device ,
280
457
};
281
458
282
- static struct platform_device * late_devices [] __initdata = {
459
+ static struct platform_device * late_devices [] __initconst = {
283
460
& ams_delta_nand_device ,
284
461
& ams_delta_lcd_device ,
285
462
& ams_delta_led_device ,
@@ -325,8 +502,8 @@ static void __init ams_delta_init(void)
325
502
326
503
static struct plat_serial8250_port ams_delta_modem_ports [] = {
327
504
{
328
- .membase = IOMEM (AMS_DELTA_MODEM_VIRT ),
329
- .mapbase = AMS_DELTA_MODEM_PHYS ,
505
+ .membase = IOMEM (MODEM_VIRT ),
506
+ .mapbase = MODEM_PHYS ,
330
507
.irq = - EINVAL , /* changed later */
331
508
.flags = UPF_BOOT_AUTOCONF ,
332
509
.irqflags = IRQF_TRIGGER_RISING ,
@@ -352,8 +529,11 @@ static int __init late_init(void)
352
529
if (!machine_is_ams_delta ())
353
530
return - ENODEV ;
354
531
355
- /* Clear latch2 (NAND, LCD, modem enable) */
356
- ams_delta_latch2_write (~0 , 0 );
532
+ err = gpio_request_array (latch_gpios , ARRAY_SIZE (latch_gpios ));
533
+ if (err ) {
534
+ pr_err ("Couldn't take over latch1/latch2 GPIO pins\n" );
535
+ return err ;
536
+ }
357
537
358
538
platform_add_devices (late_devices , ARRAY_SIZE (late_devices ));
359
539
@@ -399,6 +579,3 @@ MACHINE_START(AMS_DELTA, "Amstrad E3 (Delta)")
399
579
.init_machine = ams_delta_init ,
400
580
.timer = & omap1_timer ,
401
581
MACHINE_END
402
-
403
- EXPORT_SYMBOL (ams_delta_latch1_write );
404
- EXPORT_SYMBOL (ams_delta_latch2_write );
0 commit comments