diff options
author | Vasily Khoruzhick <anarsoul@gmail.com> | 2010-09-08 05:39:46 -0400 |
---|---|---|
committer | Ben Dooks <ben-linux@fluff.org> | 2010-09-25 19:45:18 -0400 |
commit | 14477095abc661a9f195ca4733bb739c54794b32 (patch) | |
tree | 92b4da26c1c7f1349706819756895e462f7bbdd7 | |
parent | 56162badadb91aae93843d8d6558c7d7780e3cb2 (diff) |
ARM: h1940: Use gpiolib for latch access
This patch adds gpiolib support for h1940 latch.
With this patch it's possible to use leds-gpio and uda1380
drivers (they require gpiolib support for appropriate pins).
And now it's possible to drop leds-h1940 driver.
Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
-rw-r--r-- | arch/arm/mach-s3c2410/h1940-bluetooth.c | 13 | ||||
-rw-r--r-- | arch/arm/mach-s3c2410/include/mach/h1940-latch.h | 57 | ||||
-rw-r--r-- | arch/arm/mach-s3c2410/mach-h1940.c | 64 | ||||
-rw-r--r-- | arch/arm/plat-s3c24xx/Kconfig | 1 |
4 files changed, 87 insertions, 48 deletions
diff --git a/arch/arm/mach-s3c2410/h1940-bluetooth.c b/arch/arm/mach-s3c2410/h1940-bluetooth.c index 8cdeb14af592..8aa2f1902a94 100644 --- a/arch/arm/mach-s3c2410/h1940-bluetooth.c +++ b/arch/arm/mach-s3c2410/h1940-bluetooth.c | |||
@@ -30,7 +30,7 @@ static void h1940bt_enable(int on) | |||
30 | { | 30 | { |
31 | if (on) { | 31 | if (on) { |
32 | /* Power on the chip */ | 32 | /* Power on the chip */ |
33 | h1940_latch_control(0, H1940_LATCH_BLUETOOTH_POWER); | 33 | gpio_set_value(H1940_LATCH_BLUETOOTH_POWER, 1); |
34 | /* Reset the chip */ | 34 | /* Reset the chip */ |
35 | mdelay(10); | 35 | mdelay(10); |
36 | 36 | ||
@@ -43,7 +43,7 @@ static void h1940bt_enable(int on) | |||
43 | mdelay(10); | 43 | mdelay(10); |
44 | gpio_set_value(S3C2410_GPH(1), 0); | 44 | gpio_set_value(S3C2410_GPH(1), 0); |
45 | mdelay(10); | 45 | mdelay(10); |
46 | h1940_latch_control(H1940_LATCH_BLUETOOTH_POWER, 0); | 46 | gpio_set_value(H1940_LATCH_BLUETOOTH_POWER, 0); |
47 | } | 47 | } |
48 | } | 48 | } |
49 | 49 | ||
@@ -64,7 +64,14 @@ static int __devinit h1940bt_probe(struct platform_device *pdev) | |||
64 | 64 | ||
65 | ret = gpio_request(S3C2410_GPH(1), dev_name(&pdev->dev)); | 65 | ret = gpio_request(S3C2410_GPH(1), dev_name(&pdev->dev)); |
66 | if (ret) { | 66 | if (ret) { |
67 | dev_err(&pdev->dev, "could not get GPH1\n");\ | 67 | dev_err(&pdev->dev, "could not get GPH1\n"); |
68 | return ret; | ||
69 | } | ||
70 | |||
71 | ret = gpio_request(H1940_LATCH_BLUETOOTH_POWER, dev_name(&pdev->dev)); | ||
72 | if (ret) { | ||
73 | gpio_free(S3C2410_GPH(1)); | ||
74 | dev_err(&pdev->dev, "could not get BT_POWER\n"); | ||
68 | return ret; | 75 | return ret; |
69 | } | 76 | } |
70 | 77 | ||
diff --git a/arch/arm/mach-s3c2410/include/mach/h1940-latch.h b/arch/arm/mach-s3c2410/include/mach/h1940-latch.h index d8a832729a8a..73586f20930e 100644 --- a/arch/arm/mach-s3c2410/include/mach/h1940-latch.h +++ b/arch/arm/mach-s3c2410/include/mach/h1940-latch.h | |||
@@ -14,51 +14,30 @@ | |||
14 | #ifndef __ASM_ARCH_H1940_LATCH_H | 14 | #ifndef __ASM_ARCH_H1940_LATCH_H |
15 | #define __ASM_ARCH_H1940_LATCH_H | 15 | #define __ASM_ARCH_H1940_LATCH_H |
16 | 16 | ||
17 | #include <mach/gpio.h> | ||
17 | 18 | ||
18 | #ifndef __ASSEMBLY__ | 19 | #define H1940_LATCH_GPIO(x) (S3C_GPIO_END + (x)) |
19 | #define H1940_LATCH ((void __force __iomem *)0xF8000000) | ||
20 | #else | ||
21 | #define H1940_LATCH 0xF8000000 | ||
22 | #endif | ||
23 | |||
24 | #define H1940_PA_LATCH (S3C2410_CS2) | ||
25 | 20 | ||
26 | /* SD layer latch */ | 21 | /* SD layer latch */ |
27 | 22 | ||
28 | #define H1940_LATCH_SDQ1 (1<<16) | 23 | #define H1940_LATCH_SDQ1 H1940_LATCH_GPIO(0) |
29 | #define H1940_LATCH_LCD_P1 (1<<17) | 24 | #define H1940_LATCH_LCD_P1 H1940_LATCH_GPIO(1) |
30 | #define H1940_LATCH_LCD_P2 (1<<18) | 25 | #define H1940_LATCH_LCD_P2 H1940_LATCH_GPIO(2) |
31 | #define H1940_LATCH_LCD_P3 (1<<19) | 26 | #define H1940_LATCH_LCD_P3 H1940_LATCH_GPIO(3) |
32 | #define H1940_LATCH_MAX1698_nSHUTDOWN (1<<20) /* LCD backlight */ | 27 | #define H1940_LATCH_MAX1698_nSHUTDOWN H1940_LATCH_GPIO(4) |
33 | #define H1940_LATCH_LED_RED (1<<21) | 28 | #define H1940_LATCH_LED_RED H1940_LATCH_GPIO(5) |
34 | #define H1940_LATCH_SDQ7 (1<<22) | 29 | #define H1940_LATCH_SDQ7 H1940_LATCH_GPIO(6) |
35 | #define H1940_LATCH_USB_DP (1<<23) | 30 | #define H1940_LATCH_USB_DP H1940_LATCH_GPIO(7) |
36 | 31 | ||
37 | /* CPU layer latch */ | 32 | /* CPU layer latch */ |
38 | 33 | ||
39 | #define H1940_LATCH_UDA_POWER (1<<24) | 34 | #define H1940_LATCH_UDA_POWER H1940_LATCH_GPIO(8) |
40 | #define H1940_LATCH_AUDIO_POWER (1<<25) | 35 | #define H1940_LATCH_AUDIO_POWER H1940_LATCH_GPIO(9) |
41 | #define H1940_LATCH_SM803_ENABLE (1<<26) | 36 | #define H1940_LATCH_SM803_ENABLE H1940_LATCH_GPIO(10) |
42 | #define H1940_LATCH_LCD_P4 (1<<27) | 37 | #define H1940_LATCH_LCD_P4 H1940_LATCH_GPIO(11) |
43 | #define H1940_LATCH_CPUQ5 (1<<28) /* untraced */ | 38 | #define H1940_LATCH_CPUQ5 H1940_LATCH_GPIO(12) |
44 | #define H1940_LATCH_BLUETOOTH_POWER (1<<29) /* active high */ | 39 | #define H1940_LATCH_BLUETOOTH_POWER H1940_LATCH_GPIO(13) |
45 | #define H1940_LATCH_LED_GREEN (1<<30) | 40 | #define H1940_LATCH_LED_GREEN H1940_LATCH_GPIO(14) |
46 | #define H1940_LATCH_LED_FLASH (1<<31) | 41 | #define H1940_LATCH_LED_FLASH H1940_LATCH_GPIO(15) |
47 | |||
48 | /* default settings */ | ||
49 | |||
50 | #define H1940_LATCH_DEFAULT \ | ||
51 | H1940_LATCH_LCD_P4 | \ | ||
52 | H1940_LATCH_SM803_ENABLE | \ | ||
53 | H1940_LATCH_SDQ1 | \ | ||
54 | H1940_LATCH_LCD_P1 | \ | ||
55 | H1940_LATCH_LCD_P2 | \ | ||
56 | H1940_LATCH_LCD_P3 | \ | ||
57 | H1940_LATCH_MAX1698_nSHUTDOWN | \ | ||
58 | H1940_LATCH_CPUQ5 | ||
59 | |||
60 | /* control functions */ | ||
61 | |||
62 | extern void h1940_latch_control(unsigned int clear, unsigned int set); | ||
63 | 42 | ||
64 | #endif /* __ASM_ARCH_H1940_LATCH_H */ | 43 | #endif /* __ASM_ARCH_H1940_LATCH_H */ |
diff --git a/arch/arm/mach-s3c2410/mach-h1940.c b/arch/arm/mach-s3c2410/mach-h1940.c index 3ba3bab139d0..f0493bdbf0dc 100644 --- a/arch/arm/mach-s3c2410/mach-h1940.c +++ b/arch/arm/mach-s3c2410/mach-h1940.c | |||
@@ -59,6 +59,12 @@ | |||
59 | #include <plat/mci.h> | 59 | #include <plat/mci.h> |
60 | #include <plat/ts.h> | 60 | #include <plat/ts.h> |
61 | 61 | ||
62 | #define H1940_LATCH ((void __force __iomem *)0xF8000000) | ||
63 | |||
64 | #define H1940_PA_LATCH S3C2410_CS2 | ||
65 | |||
66 | #define H1940_LATCH_BIT(x) (1 << ((x) + 16 - S3C_GPIO_END)) | ||
67 | |||
62 | static struct map_desc h1940_iodesc[] __initdata = { | 68 | static struct map_desc h1940_iodesc[] __initdata = { |
63 | [0] = { | 69 | [0] = { |
64 | .virtual = (unsigned long)H1940_LATCH, | 70 | .virtual = (unsigned long)H1940_LATCH, |
@@ -100,9 +106,16 @@ static struct s3c2410_uartcfg h1940_uartcfgs[] __initdata = { | |||
100 | 106 | ||
101 | /* Board control latch control */ | 107 | /* Board control latch control */ |
102 | 108 | ||
103 | static unsigned int latch_state = H1940_LATCH_DEFAULT; | 109 | static unsigned int latch_state = H1940_LATCH_BIT(H1940_LATCH_LCD_P4) | |
110 | H1940_LATCH_BIT(H1940_LATCH_SM803_ENABLE) | | ||
111 | H1940_LATCH_BIT(H1940_LATCH_SDQ1) | | ||
112 | H1940_LATCH_BIT(H1940_LATCH_LCD_P1) | | ||
113 | H1940_LATCH_BIT(H1940_LATCH_LCD_P2) | | ||
114 | H1940_LATCH_BIT(H1940_LATCH_LCD_P3) | | ||
115 | H1940_LATCH_BIT(H1940_LATCH_MAX1698_nSHUTDOWN) | | ||
116 | H1940_LATCH_BIT(H1940_LATCH_CPUQ5); | ||
104 | 117 | ||
105 | void h1940_latch_control(unsigned int clear, unsigned int set) | 118 | static void h1940_latch_control(unsigned int clear, unsigned int set) |
106 | { | 119 | { |
107 | unsigned long flags; | 120 | unsigned long flags; |
108 | 121 | ||
@@ -116,7 +129,42 @@ void h1940_latch_control(unsigned int clear, unsigned int set) | |||
116 | local_irq_restore(flags); | 129 | local_irq_restore(flags); |
117 | } | 130 | } |
118 | 131 | ||
119 | EXPORT_SYMBOL_GPL(h1940_latch_control); | 132 | static inline int h1940_gpiolib_to_latch(int offset) |
133 | { | ||
134 | return 1 << (offset + 16); | ||
135 | } | ||
136 | |||
137 | static void h1940_gpiolib_latch_set(struct gpio_chip *chip, | ||
138 | unsigned offset, int value) | ||
139 | { | ||
140 | int latch_bit = h1940_gpiolib_to_latch(offset); | ||
141 | |||
142 | h1940_latch_control(value ? 0 : latch_bit, | ||
143 | value ? latch_bit : 0); | ||
144 | } | ||
145 | |||
146 | static int h1940_gpiolib_latch_output(struct gpio_chip *chip, | ||
147 | unsigned offset, int value) | ||
148 | { | ||
149 | h1940_gpiolib_latch_set(chip, offset, value); | ||
150 | return 0; | ||
151 | } | ||
152 | |||
153 | static int h1940_gpiolib_latch_get(struct gpio_chip *chip, | ||
154 | unsigned offset) | ||
155 | { | ||
156 | return (latch_state >> (offset + 16)) & 1; | ||
157 | } | ||
158 | |||
159 | struct gpio_chip h1940_latch_gpiochip = { | ||
160 | .base = H1940_LATCH_GPIO(0), | ||
161 | .owner = THIS_MODULE, | ||
162 | .label = "H1940_LATCH", | ||
163 | .ngpio = 16, | ||
164 | .direction_output = h1940_gpiolib_latch_output, | ||
165 | .set = h1940_gpiolib_latch_set, | ||
166 | .get = h1940_gpiolib_latch_get, | ||
167 | }; | ||
120 | 168 | ||
121 | static void h1940_udc_pullup(enum s3c2410_udc_cmd_e cmd) | 169 | static void h1940_udc_pullup(enum s3c2410_udc_cmd_e cmd) |
122 | { | 170 | { |
@@ -125,10 +173,10 @@ static void h1940_udc_pullup(enum s3c2410_udc_cmd_e cmd) | |||
125 | switch (cmd) | 173 | switch (cmd) |
126 | { | 174 | { |
127 | case S3C2410_UDC_P_ENABLE : | 175 | case S3C2410_UDC_P_ENABLE : |
128 | h1940_latch_control(0, H1940_LATCH_USB_DP); | 176 | gpio_set_value(H1940_LATCH_USB_DP, 1); |
129 | break; | 177 | break; |
130 | case S3C2410_UDC_P_DISABLE : | 178 | case S3C2410_UDC_P_DISABLE : |
131 | h1940_latch_control(H1940_LATCH_USB_DP, 0); | 179 | gpio_set_value(H1940_LATCH_USB_DP, 0); |
132 | break; | 180 | break; |
133 | case S3C2410_UDC_P_RESET : | 181 | case S3C2410_UDC_P_RESET : |
134 | break; | 182 | break; |
@@ -303,6 +351,8 @@ static void __init h1940_map_io(void) | |||
303 | memcpy(phys_to_virt(H1940_SUSPEND_RESUMEAT), h1940_pm_return, 1024); | 351 | memcpy(phys_to_virt(H1940_SUSPEND_RESUMEAT), h1940_pm_return, 1024); |
304 | #endif | 352 | #endif |
305 | s3c_pm_init(); | 353 | s3c_pm_init(); |
354 | |||
355 | WARN_ON(gpiochip_add(&h1940_latch_gpiochip)); | ||
306 | } | 356 | } |
307 | 357 | ||
308 | /* H1940 and RX3715 need to reserve this for suspend */ | 358 | /* H1940 and RX3715 need to reserve this for suspend */ |
@@ -342,9 +392,11 @@ static void __init h1940_init(void) | |||
342 | gpio_request(S3C2410_GPC(0), "LCD power"); | 392 | gpio_request(S3C2410_GPC(0), "LCD power"); |
343 | gpio_request(S3C2410_GPC(5), "LCD power"); | 393 | gpio_request(S3C2410_GPC(5), "LCD power"); |
344 | gpio_request(S3C2410_GPC(6), "LCD power"); | 394 | gpio_request(S3C2410_GPC(6), "LCD power"); |
345 | |||
346 | gpio_direction_input(S3C2410_GPC(6)); | 395 | gpio_direction_input(S3C2410_GPC(6)); |
347 | 396 | ||
397 | gpio_request(H1940_LATCH_USB_DP, "USB pullup"); | ||
398 | gpio_direction_output(H1940_LATCH_USB_DP, 0); | ||
399 | |||
348 | platform_add_devices(h1940_devices, ARRAY_SIZE(h1940_devices)); | 400 | platform_add_devices(h1940_devices, ARRAY_SIZE(h1940_devices)); |
349 | } | 401 | } |
350 | 402 | ||
diff --git a/arch/arm/plat-s3c24xx/Kconfig b/arch/arm/plat-s3c24xx/Kconfig index 984bf66826d2..5a27b1b538f2 100644 --- a/arch/arm/plat-s3c24xx/Kconfig +++ b/arch/arm/plat-s3c24xx/Kconfig | |||
@@ -69,6 +69,7 @@ config S3C24XX_GPIO_EXTRA | |||
69 | int | 69 | int |
70 | default 128 if S3C24XX_GPIO_EXTRA128 | 70 | default 128 if S3C24XX_GPIO_EXTRA128 |
71 | default 64 if S3C24XX_GPIO_EXTRA64 | 71 | default 64 if S3C24XX_GPIO_EXTRA64 |
72 | default 16 if ARCH_H1940 | ||
72 | default 0 | 73 | default 0 |
73 | 74 | ||
74 | config S3C24XX_GPIO_EXTRA64 | 75 | config S3C24XX_GPIO_EXTRA64 |