]> git.karo-electronics.de Git - mv-sheeva.git/blob - arch/arm/mach-s5pv310/mach-universal_c210.c
ARM: S5PV310: Add GPIO keys at Universal board
[mv-sheeva.git] / arch / arm / mach-s5pv310 / mach-universal_c210.c
1 /* linux/arch/arm/mach-s5pv310/mach-universal_c210.c
2  *
3  * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation.
8 */
9
10 #include <linux/platform_device.h>
11 #include <linux/serial_core.h>
12 #include <linux/input.h>
13 #include <linux/gpio_keys.h>
14 #include <linux/gpio.h>
15
16 #include <asm/mach/arch.h>
17 #include <asm/mach-types.h>
18 #include <asm/hardware/cache-l2x0.h>
19
20 #include <plat/regs-serial.h>
21 #include <plat/s5pv310.h>
22 #include <plat/cpu.h>
23
24 #include <mach/map.h>
25
26 /* Following are default values for UCON, ULCON and UFCON UART registers */
27 #define UNIVERSAL_UCON_DEFAULT  (S3C2410_UCON_TXILEVEL |        \
28                                  S3C2410_UCON_RXILEVEL |        \
29                                  S3C2410_UCON_TXIRQMODE |       \
30                                  S3C2410_UCON_RXIRQMODE |       \
31                                  S3C2410_UCON_RXFIFO_TOI |      \
32                                  S3C2443_UCON_RXERR_IRQEN)
33
34 #define UNIVERSAL_ULCON_DEFAULT S3C2410_LCON_CS8
35
36 #define UNIVERSAL_UFCON_DEFAULT (S3C2410_UFCON_FIFOMODE |       \
37                                  S5PV210_UFCON_TXTRIG256 |      \
38                                  S5PV210_UFCON_RXTRIG256)
39
40 static struct s3c2410_uartcfg universal_uartcfgs[] __initdata = {
41         [0] = {
42                 .hwport         = 0,
43                 .ucon           = UNIVERSAL_UCON_DEFAULT,
44                 .ulcon          = UNIVERSAL_ULCON_DEFAULT,
45                 .ufcon          = UNIVERSAL_UFCON_DEFAULT,
46         },
47         [1] = {
48                 .hwport         = 1,
49                 .ucon           = UNIVERSAL_UCON_DEFAULT,
50                 .ulcon          = UNIVERSAL_ULCON_DEFAULT,
51                 .ufcon          = UNIVERSAL_UFCON_DEFAULT,
52         },
53         [2] = {
54                 .hwport         = 2,
55                 .ucon           = UNIVERSAL_UCON_DEFAULT,
56                 .ulcon          = UNIVERSAL_ULCON_DEFAULT,
57                 .ufcon          = UNIVERSAL_UFCON_DEFAULT,
58         },
59         [3] = {
60                 .hwport         = 3,
61                 .ucon           = UNIVERSAL_UCON_DEFAULT,
62                 .ulcon          = UNIVERSAL_ULCON_DEFAULT,
63                 .ufcon          = UNIVERSAL_UFCON_DEFAULT,
64         },
65 };
66
67 static struct gpio_keys_button universal_gpio_keys_tables[] = {
68         {
69                 .code                   = KEY_VOLUMEUP,
70                 .gpio                   = S5PV310_GPX2(0),      /* XEINT16 */
71                 .desc                   = "gpio-keys: KEY_VOLUMEUP",
72                 .type                   = EV_KEY,
73                 .active_low             = 1,
74                 .debounce_interval      = 1,
75         }, {
76                 .code                   = KEY_VOLUMEDOWN,
77                 .gpio                   = S5PV310_GPX2(1),      /* XEINT17 */
78                 .desc                   = "gpio-keys: KEY_VOLUMEDOWN",
79                 .type                   = EV_KEY,
80                 .active_low             = 1,
81                 .debounce_interval      = 1,
82         }, {
83                 .code                   = KEY_CONFIG,
84                 .gpio                   = S5PV310_GPX2(2),      /* XEINT18 */
85                 .desc                   = "gpio-keys: KEY_CONFIG",
86                 .type                   = EV_KEY,
87                 .active_low             = 1,
88                 .debounce_interval      = 1,
89         }, {
90                 .code                   = KEY_CAMERA,
91                 .gpio                   = S5PV310_GPX2(3),      /* XEINT19 */
92                 .desc                   = "gpio-keys: KEY_CAMERA",
93                 .type                   = EV_KEY,
94                 .active_low             = 1,
95                 .debounce_interval      = 1,
96         }, {
97                 .code                   = KEY_OK,
98                 .gpio                   = S5PV310_GPX3(5),      /* XEINT29 */
99                 .desc                   = "gpio-keys: KEY_OK",
100                 .type                   = EV_KEY,
101                 .active_low             = 1,
102                 .debounce_interval      = 1,
103         },
104 };
105
106 static struct gpio_keys_platform_data universal_gpio_keys_data = {
107         .buttons        = universal_gpio_keys_tables,
108         .nbuttons       = ARRAY_SIZE(universal_gpio_keys_tables),
109 };
110
111 static struct platform_device universal_gpio_keys = {
112         .name                   = "gpio-keys",
113         .dev                    = {
114                 .platform_data  = &universal_gpio_keys_data,
115         },
116 };
117
118 static struct platform_device *universal_devices[] __initdata = {
119         &universal_gpio_keys,
120 };
121
122 static void __init universal_map_io(void)
123 {
124         s5p_init_io(NULL, 0, S5P_VA_CHIPID);
125         s3c24xx_init_clocks(24000000);
126         s3c24xx_init_uarts(universal_uartcfgs, ARRAY_SIZE(universal_uartcfgs));
127 }
128
129 static void __init universal_machine_init(void)
130 {
131 #ifdef CONFIG_CACHE_L2X0
132         l2x0_init(S5P_VA_L2CC, 1 << 28, 0xffffffff);
133 #endif
134
135         /* Last */
136         platform_add_devices(universal_devices, ARRAY_SIZE(universal_devices));
137 }
138
139 MACHINE_START(UNIVERSAL_C210, "UNIVERSAL_C210")
140         /* Maintainer: Kyungmin Park <kyungmin.park@samsung.com> */
141         .phys_io        = S3C_PA_UART & 0xfff00000,
142         .io_pg_offst    = (((u32)S3C_VA_UART) >> 18) & 0xfffc,
143         .boot_params    = S5P_PA_SDRAM + 0x100,
144         .init_irq       = s5pv310_init_irq,
145         .map_io         = universal_map_io,
146         .init_machine   = universal_machine_init,
147         .timer          = &s5pv310_timer,
148 MACHINE_END