Skip to content

Commit 937eb4b

Browse files
jkrzyszttmlind
authored andcommitted
ARM: OMAP1: ams-delta: convert latches to basic_mmio_gpio
Once ready, ams-delta specific device drivers currently calling custom ams_delta_latch[12]_write() functions can be updated to call generic gpio_set_value() instead, which will make them less platform dependent. Even more, some custom ams-delta only drivers can perhaps be dropped from the tree after converting selected ams-delta platform devices to follow generic GPIO based device models. The latch_gpios[] table is initially filled with all latch1 and latch2 GPIO pins in order to register and initialize them from the board file until those are handled by respective existing device drivers (leds, nand, lcd, serio, asoc, serial). That table will get almost empty after the transision process is completed, holding only pins not used by any drivers / connected to unused devices, in order to initialize them from the board file for power saving purposes. The new ams_delta_latch_write() function is a unified replacement for those removed ams_delta_latch[12]_write(), and serves as a temporary wrapper over gpio_set_value(), providing the old API for those not yet updated device drivers, and will be removed after all custom drivers are converted or replaced. Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> Signed-off-by: Tony Lindgren <tony@atomide.com>
1 parent f7519d8 commit 937eb4b

File tree

3 files changed

+242
-39
lines changed

3 files changed

+242
-39
lines changed

arch/arm/mach-omap1/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ config MACH_AMS_DELTA
155155
bool "Amstrad E3 (Delta)"
156156
depends on ARCH_OMAP1 && ARCH_OMAP15XX
157157
select FIQ
158+
select GPIO_GENERIC_PLATFORM
158159
help
159160
Support for the Amstrad E3 (codename Delta) videophone. Say Y here
160161
if you have such a device.

arch/arm/mach-omap1/board-ams-delta.c

Lines changed: 207 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* it under the terms of the GNU General Public License version 2 as
1212
* published by the Free Software Foundation.
1313
*/
14+
#include <linux/basic_mmio_gpio.h>
1415
#include <linux/gpio.h>
1516
#include <linux/kernel.h>
1617
#include <linux/init.h>
@@ -40,9 +41,6 @@
4041

4142
#include <mach/ams-delta-fiq.h>
4243

43-
static u8 ams_delta_latch1_reg;
44-
static u16 ams_delta_latch2_reg;
45-
4644
static const unsigned int ams_delta_keymap[] = {
4745
KEY(0, 0, KEY_F1), /* Advert */
4846

@@ -121,39 +119,32 @@ static const unsigned int ams_delta_keymap[] = {
121119
KEY(7, 3, KEY_LEFTCTRL), /* Vol down */
122120
};
123121

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
137128

138129
static struct map_desc ams_delta_io_desc[] __initdata = {
139130
/* AMS_DELTA_LATCH1 */
140131
{
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),
143134
.length = 0x01000000,
144135
.type = MT_DEVICE
145136
},
146137
/* AMS_DELTA_LATCH2 */
147138
{
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),
150141
.length = 0x01000000,
151142
.type = MT_DEVICE
152143
},
153144
/* AMS_DELTA_MODEM */
154145
{
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),
157148
.length = 0x01000000,
158149
.type = MT_DEVICE
159150
}
@@ -173,6 +164,190 @@ static struct omap_board_config_kernel ams_delta_config[] __initdata = {
173164
{ OMAP_TAG_LCD, &ams_delta_lcd_config },
174165
};
175166

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+
176351
static struct resource ams_delta_nand_resources[] = {
177352
[0] = {
178353
.start = OMAP1_MPUIO_BASE,
@@ -275,11 +450,13 @@ static struct omap1_cam_platform_data ams_delta_camera_platform_data = {
275450
};
276451

277452
static struct platform_device *ams_delta_devices[] __initdata = {
453+
&latch1_gpio_device,
454+
&latch2_gpio_device,
278455
&ams_delta_kp_device,
279456
&ams_delta_camera_device,
280457
};
281458

282-
static struct platform_device *late_devices[] __initdata = {
459+
static struct platform_device *late_devices[] __initconst = {
283460
&ams_delta_nand_device,
284461
&ams_delta_lcd_device,
285462
&ams_delta_led_device,
@@ -325,8 +502,8 @@ static void __init ams_delta_init(void)
325502

326503
static struct plat_serial8250_port ams_delta_modem_ports[] = {
327504
{
328-
.membase = IOMEM(AMS_DELTA_MODEM_VIRT),
329-
.mapbase = AMS_DELTA_MODEM_PHYS,
505+
.membase = IOMEM(MODEM_VIRT),
506+
.mapbase = MODEM_PHYS,
330507
.irq = -EINVAL, /* changed later */
331508
.flags = UPF_BOOT_AUTOCONF,
332509
.irqflags = IRQF_TRIGGER_RISING,
@@ -352,8 +529,11 @@ static int __init late_init(void)
352529
if (!machine_is_ams_delta())
353530
return -ENODEV;
354531

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+
}
357537

358538
platform_add_devices(late_devices, ARRAY_SIZE(late_devices));
359539

@@ -399,6 +579,3 @@ MACHINE_START(AMS_DELTA, "Amstrad E3 (Delta)")
399579
.init_machine = ams_delta_init,
400580
.timer = &omap1_timer,
401581
MACHINE_END
402-
403-
EXPORT_SYMBOL(ams_delta_latch1_write);
404-
EXPORT_SYMBOL(ams_delta_latch2_write);

arch/arm/plat-omap/include/plat/board-ams-delta.h

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@
2828

2929
#if defined (CONFIG_MACH_AMS_DELTA)
3030

31-
#define AMS_DELTA_LATCH1_PHYS 0x01000000
32-
#define AMS_DELTA_LATCH1_VIRT 0xEA000000
33-
#define AMS_DELTA_MODEM_PHYS 0x04000000
34-
#define AMS_DELTA_MODEM_VIRT 0xEB000000
35-
#define AMS_DELTA_LATCH2_PHYS 0x08000000
36-
#define AMS_DELTA_LATCH2_VIRT 0xEC000000
37-
3831
#define AMS_DELTA_LATCH1_LED_CAMERA 0x01
3932
#define AMS_DELTA_LATCH1_LED_ADVERT 0x02
4033
#define AMS_DELTA_LATCH1_LED_EMAIL 0x04
@@ -66,9 +59,41 @@
6659
#define AMS_DELTA_GPIO_PIN_CONFIG 11
6760
#define AMS_DELTA_GPIO_PIN_NAND_RB 12
6861

62+
#define AMS_DELTA_GPIO_PIN_LED_CAMERA 232
63+
#define AMS_DELTA_GPIO_PIN_LED_ADVERT 233
64+
#define AMS_DELTA_GPIO_PIN_LED_EMAIL 234
65+
#define AMS_DELTA_GPIO_PIN_LED_HANDSFREE 235
66+
#define AMS_DELTA_GPIO_PIN_LED_VOICEMAIL 236
67+
#define AMS_DELTA_GPIO_PIN_LED_VOICE 237
68+
69+
#define AMS_DELTA_GPIO_PIN_LCD_VBLEN 240
70+
#define AMS_DELTA_GPIO_PIN_LCD_NDISP 241
71+
#define AMS_DELTA_GPIO_PIN_NAND_NCE 242
72+
#define AMS_DELTA_GPIO_PIN_NAND_NRE 243
73+
#define AMS_DELTA_GPIO_PIN_NAND_NWP 244
74+
#define AMS_DELTA_GPIO_PIN_NAND_NWE 245
75+
#define AMS_DELTA_GPIO_PIN_NAND_ALE 246
76+
#define AMS_DELTA_GPIO_PIN_NAND_CLE 247
77+
#define AMS_DELTA_GPIO_PIN_KEYBRD_PWR 248
78+
#define AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT 249
79+
#define AMS_DELTA_GPIO_PIN_SCARD_RSTIN 250
80+
#define AMS_DELTA_GPIO_PIN_SCARD_CMDVCC 251
81+
#define AMS_DELTA_GPIO_PIN_MODEM_NRESET 252
82+
#define AMS_DELTA_GPIO_PIN_MODEM_CODEC 253
83+
84+
#define AMS_DELTA_LATCH1_GPIO_BASE AMS_DELTA_GPIO_PIN_LED_CAMERA
85+
#define AMS_DELTA_LATCH1_NGPIO 8
86+
#define AMS_DELTA_LATCH2_GPIO_BASE AMS_DELTA_GPIO_PIN_LCD_VBLEN
87+
#define AMS_DELTA_LATCH2_NGPIO 16
88+
6989
#ifndef __ASSEMBLY__
70-
void ams_delta_latch1_write(u8 mask, u8 value);
71-
void ams_delta_latch2_write(u16 mask, u16 value);
90+
void ams_delta_latch_write(int base, int ngpio, u16 mask, u16 value);
91+
#define ams_delta_latch1_write(mask, value) \
92+
ams_delta_latch_write(AMS_DELTA_LATCH1_GPIO_BASE, \
93+
AMS_DELTA_LATCH1_NGPIO, (mask), (value))
94+
#define ams_delta_latch2_write(mask, value) \
95+
ams_delta_latch_write(AMS_DELTA_LATCH2_GPIO_BASE, \
96+
AMS_DELTA_LATCH2_NGPIO, (mask), (value))
7297
#endif
7398

7499
#endif /* CONFIG_MACH_AMS_DELTA */

0 commit comments

Comments
 (0)