aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Artamonow <mad_soft@inbox.ru>2009-11-27 06:02:28 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2009-12-06 11:52:55 -0500
commit22f9740552b89c9f458f972f881d222b298ab165 (patch)
tree71939e8d7636afd8422bd18c00c8b33679f9c92a
parent2eec62d7dbaa8ed05f318d88f938a86fcf274b34 (diff)
ARM: 5814/1: SA1100: h3100/h3600: convert all users of assign_h3600_egpio to gpiolib
Use of gpio_request/gpio_free in some callbacks may look ugly, but corresponding drivers (sa1100_serial and sa1100_fb) don't provide (yet) init/exit hooks and registering these gpios in *_mach_init is also not possible, because htc-gpio driver starts a bit later... Signed-off-by: Dmitry Artamonow <mad_soft@inbox.ru> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r--arch/arm/mach-sa1100/h3600.c87
-rw-r--r--drivers/pcmcia/sa1100_h3600.c57
2 files changed, 126 insertions, 18 deletions
diff --git a/arch/arm/mach-sa1100/h3600.c b/arch/arm/mach-sa1100/h3600.c
index 429fdb051a35..5e6011ce36ee 100644
--- a/arch/arm/mach-sa1100/h3600.c
+++ b/arch/arm/mach-sa1100/h3600.c
@@ -111,12 +111,32 @@ static struct mtd_partition h3xxx_partitions[] = {
111 111
112static void h3xxx_set_vpp(int vpp) 112static void h3xxx_set_vpp(int vpp)
113{ 113{
114 assign_h3600_egpio(IPAQ_EGPIO_VPP_ON, vpp); 114 gpio_set_value(H3XXX_EGPIO_VPP_ON, vpp);
115}
116
117static int h3xxx_flash_init(void)
118{
119 int err = gpio_request(H3XXX_EGPIO_VPP_ON, "Flash Vpp");
120 if (err)
121 return err;
122
123 err = gpio_direction_output(H3XXX_EGPIO_VPP_ON, 0);
124 if (err)
125 gpio_free(H3XXX_EGPIO_VPP_ON);
126
127 return err;
128}
129
130static void h3xxx_flash_exit(void)
131{
132 gpio_free(H3XXX_EGPIO_VPP_ON);
115} 133}
116 134
117static struct flash_platform_data h3xxx_flash_data = { 135static struct flash_platform_data h3xxx_flash_data = {
118 .map_name = "cfi_probe", 136 .map_name = "cfi_probe",
119 .set_vpp = h3xxx_set_vpp, 137 .set_vpp = h3xxx_set_vpp,
138 .init = h3xxx_flash_init,
139 .exit = h3xxx_flash_exit,
120 .parts = h3xxx_partitions, 140 .parts = h3xxx_partitions,
121 .nr_parts = ARRAY_SIZE(h3xxx_partitions), 141 .nr_parts = ARRAY_SIZE(h3xxx_partitions),
122}; 142};
@@ -158,7 +178,10 @@ static u_int h3xxx_uart_get_mctrl(struct uart_port *port)
158static void h3xxx_uart_pm(struct uart_port *port, u_int state, u_int oldstate) 178static void h3xxx_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
159{ 179{
160 if (port->mapbase == _Ser3UTCR0) 180 if (port->mapbase == _Ser3UTCR0)
161 assign_h3600_egpio(IPAQ_EGPIO_RS232_ON, !state); 181 if (!gpio_request(H3XXX_EGPIO_RS232_ON, "RS232 transceiver")) {
182 gpio_direction_output(H3XXX_EGPIO_RS232_ON, !state);
183 gpio_free(H3XXX_EGPIO_RS232_ON);
184 }
162} 185}
163 186
164/* 187/*
@@ -362,7 +385,11 @@ static void h3100_control_egpio(enum ipaq_egpio_type x, int setp)
362 */ 385 */
363static void h3100_lcd_power(int enable) 386static void h3100_lcd_power(int enable)
364{ 387{
365 assign_h3600_egpio(IPAQ_EGPIO_LCD_POWER, enable); 388 if (!gpio_request(H3XXX_EGPIO_LCD_ON, "LCD ON")) {
389 gpio_set_value(H3100_GPIO_LCD_3V_ON, enable);
390 gpio_direction_output(H3XXX_EGPIO_LCD_ON, enable);
391 gpio_free(H3XXX_EGPIO_LCD_ON);
392 }
366} 393}
367 394
368 395
@@ -412,6 +439,7 @@ static struct gpio_default_state h3100_default_gpio[] = {
412 { H3XXX_GPIO_COM_DCD, GPIO_MODE_IN, "COM DCD" }, 439 { H3XXX_GPIO_COM_DCD, GPIO_MODE_IN, "COM DCD" },
413 { H3XXX_GPIO_COM_CTS, GPIO_MODE_IN, "COM CTS" }, 440 { H3XXX_GPIO_COM_CTS, GPIO_MODE_IN, "COM CTS" },
414 { H3XXX_GPIO_COM_RTS, GPIO_MODE_OUT0, "COM RTS" }, 441 { H3XXX_GPIO_COM_RTS, GPIO_MODE_OUT0, "COM RTS" },
442 { H3100_GPIO_LCD_3V_ON, GPIO_MODE_OUT0, "LCD 3v" },
415}; 443};
416 444
417static void __init h3100_mach_init(void) 445static void __init h3100_mach_init(void)
@@ -506,7 +534,25 @@ static void h3600_control_egpio(enum ipaq_egpio_type x, int setp)
506 */ 534 */
507static void h3600_lcd_power(int enable) 535static void h3600_lcd_power(int enable)
508{ 536{
509 assign_h3600_egpio(IPAQ_EGPIO_LCD_POWER, enable); 537 if (gpio_request(H3XXX_EGPIO_LCD_ON, "LCD power"))
538 goto err1;
539 if (gpio_request(H3600_EGPIO_LCD_PCI, "LCD control"))
540 goto err2;
541 if (gpio_request(H3600_EGPIO_LCD_5V_ON, "LCD 5v"))
542 goto err3;
543 if (gpio_request(H3600_EGPIO_LVDD_ON, "LCD 9v/-6.5v"))
544 goto err4;
545
546 gpio_direction_output(H3XXX_EGPIO_LCD_ON, enable);
547 gpio_direction_output(H3600_EGPIO_LCD_PCI, enable);
548 gpio_direction_output(H3600_EGPIO_LCD_5V_ON, enable);
549 gpio_direction_output(H3600_EGPIO_LVDD_ON, enable);
550
551 gpio_free(H3600_EGPIO_LVDD_ON);
552err4: gpio_free(H3600_EGPIO_LCD_5V_ON);
553err3: gpio_free(H3600_EGPIO_LCD_PCI);
554err2: gpio_free(H3XXX_EGPIO_LCD_ON);
555err1: return;
510} 556}
511 557
512static void __init h3600_map_io(void) 558static void __init h3600_map_io(void)
@@ -531,18 +577,47 @@ static void __init h3600_map_io(void)
531 */ 577 */
532static int h3600_irda_set_power(struct device *dev, unsigned int state) 578static int h3600_irda_set_power(struct device *dev, unsigned int state)
533{ 579{
534 assign_h3600_egpio(IPAQ_EGPIO_IR_ON, state); 580 gpio_set_value(H3600_EGPIO_IR_ON, state);
535 return 0; 581 return 0;
536} 582}
537 583
538static void h3600_irda_set_speed(struct device *dev, unsigned int speed) 584static void h3600_irda_set_speed(struct device *dev, unsigned int speed)
539{ 585{
540 assign_h3600_egpio(IPAQ_EGPIO_IR_FSEL, !(speed < 4000000)); 586 gpio_set_value(H3600_EGPIO_IR_FSEL, !(speed < 4000000));
587}
588
589static int h3600_irda_startup(struct device *dev)
590{
591 int err = gpio_request(H3600_EGPIO_IR_ON, "IrDA power");
592 if (err)
593 goto err1;
594 err = gpio_direction_output(H3600_EGPIO_IR_ON, 0);
595 if (err)
596 goto err2;
597 err = gpio_request(H3600_EGPIO_IR_FSEL, "IrDA fsel");
598 if (err)
599 goto err2;
600 err = gpio_direction_output(H3600_EGPIO_IR_FSEL, 0);
601 if (err)
602 goto err3;
603 return 0;
604
605err3: gpio_free(H3600_EGPIO_IR_FSEL);
606err2: gpio_free(H3600_EGPIO_IR_ON);
607err1: return err;
608}
609
610static void h3600_irda_shutdown(struct device *dev)
611{
612 gpio_free(H3600_EGPIO_IR_ON);
613 gpio_free(H3600_EGPIO_IR_FSEL);
541} 614}
542 615
543static struct irda_platform_data h3600_irda_data = { 616static struct irda_platform_data h3600_irda_data = {
544 .set_power = h3600_irda_set_power, 617 .set_power = h3600_irda_set_power,
545 .set_speed = h3600_irda_set_speed, 618 .set_speed = h3600_irda_set_speed,
619 .startup = h3600_irda_startup,
620 .shutdown = h3600_irda_shutdown,
546}; 621};
547 622
548static struct gpio_default_state h3600_default_gpio[] = { 623static struct gpio_default_state h3600_default_gpio[] = {
diff --git a/drivers/pcmcia/sa1100_h3600.c b/drivers/pcmcia/sa1100_h3600.c
index 97e5667fb2e3..fd7af123053c 100644
--- a/drivers/pcmcia/sa1100_h3600.c
+++ b/drivers/pcmcia/sa1100_h3600.c
@@ -47,9 +47,33 @@ static int h3600_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
47 goto err02; 47 goto err02;
48 irqs[0].irq = gpio_to_irq(H3XXX_GPIO_PCMCIA_CD0); 48 irqs[0].irq = gpio_to_irq(H3XXX_GPIO_PCMCIA_CD0);
49 49
50 err = soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs)); 50 err = gpio_request(H3XXX_EGPIO_OPT_NVRAM_ON, "OPT NVRAM ON");
51 if (err) 51 if (err)
52 goto err02; 52 goto err02;
53 err = gpio_direction_output(H3XXX_EGPIO_OPT_NVRAM_ON, 0);
54 if (err)
55 goto err03;
56 err = gpio_request(H3XXX_EGPIO_OPT_ON, "OPT ON");
57 if (err)
58 goto err03;
59 err = gpio_direction_output(H3XXX_EGPIO_OPT_ON, 0);
60 if (err)
61 goto err04;
62 err = gpio_request(H3XXX_EGPIO_OPT_RESET, "OPT RESET");
63 if (err)
64 goto err04;
65 err = gpio_direction_output(H3XXX_EGPIO_OPT_RESET, 0);
66 if (err)
67 goto err05;
68 err = gpio_request(H3XXX_EGPIO_CARD_RESET, "PCMCIA CARD RESET");
69 if (err)
70 goto err05;
71 err = gpio_direction_output(H3XXX_EGPIO_CARD_RESET, 0);
72 if (err)
73 goto err06;
74 err = soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
75 if (err)
76 goto err06;
53 break; 77 break;
54 case 1: 78 case 1:
55 err = gpio_request(H3XXX_GPIO_PCMCIA_IRQ1, "PCMCIA IRQ1"); 79 err = gpio_request(H3XXX_GPIO_PCMCIA_IRQ1, "PCMCIA IRQ1");
@@ -75,6 +99,10 @@ static int h3600_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
75 } 99 }
76 return 0; 100 return 0;
77 101
102err06: gpio_free(H3XXX_EGPIO_CARD_RESET);
103err05: gpio_free(H3XXX_EGPIO_OPT_RESET);
104err04: gpio_free(H3XXX_EGPIO_OPT_ON);
105err03: gpio_free(H3XXX_EGPIO_OPT_NVRAM_ON);
78err02: gpio_free(H3XXX_GPIO_PCMCIA_CD0); 106err02: gpio_free(H3XXX_GPIO_PCMCIA_CD0);
79err01: gpio_free(H3XXX_GPIO_PCMCIA_IRQ0); 107err01: gpio_free(H3XXX_GPIO_PCMCIA_IRQ0);
80err00: return err; 108err00: return err;
@@ -88,12 +116,17 @@ static void h3600_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
88{ 116{
89 soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs)); 117 soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
90 118
91 /* Disable CF bus: */
92 assign_h3600_egpio(IPAQ_EGPIO_OPT_NVRAM_ON, 0);
93 assign_h3600_egpio(IPAQ_EGPIO_OPT_ON, 0);
94 assign_h3600_egpio(IPAQ_EGPIO_OPT_RESET, 1);
95 switch (skt->nr) { 119 switch (skt->nr) {
96 case 0: 120 case 0:
121 /* Disable CF bus: */
122 gpio_set_value(H3XXX_EGPIO_OPT_NVRAM_ON, 0);
123 gpio_set_value(H3XXX_EGPIO_OPT_ON, 0);
124 gpio_set_value(H3XXX_EGPIO_OPT_RESET, 1);
125
126 gpio_free(H3XXX_EGPIO_CARD_RESET);
127 gpio_free(H3XXX_EGPIO_OPT_RESET);
128 gpio_free(H3XXX_EGPIO_OPT_ON);
129 gpio_free(H3XXX_EGPIO_OPT_NVRAM_ON);
97 gpio_free(H3XXX_GPIO_PCMCIA_CD0); 130 gpio_free(H3XXX_GPIO_PCMCIA_CD0);
98 gpio_free(H3XXX_GPIO_PCMCIA_IRQ0); 131 gpio_free(H3XXX_GPIO_PCMCIA_IRQ0);
99 break; 132 break;
@@ -139,7 +172,7 @@ h3600_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_
139 return -1; 172 return -1;
140 } 173 }
141 174
142 assign_h3600_egpio(IPAQ_EGPIO_CARD_RESET, !!(state->flags & SS_RESET)); 175 gpio_set_value(H3XXX_EGPIO_CARD_RESET, !!(state->flags & SS_RESET));
143 176
144 /* Silently ignore Vpp, output enable, speaker enable. */ 177 /* Silently ignore Vpp, output enable, speaker enable. */
145 178
@@ -149,9 +182,9 @@ h3600_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_
149static void h3600_pcmcia_socket_init(struct soc_pcmcia_socket *skt) 182static void h3600_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
150{ 183{
151 /* Enable CF bus: */ 184 /* Enable CF bus: */
152 assign_h3600_egpio(IPAQ_EGPIO_OPT_NVRAM_ON, 1); 185 gpio_set_value(H3XXX_EGPIO_OPT_NVRAM_ON, 1);
153 assign_h3600_egpio(IPAQ_EGPIO_OPT_ON, 1); 186 gpio_set_value(H3XXX_EGPIO_OPT_ON, 1);
154 assign_h3600_egpio(IPAQ_EGPIO_OPT_RESET, 0); 187 gpio_set_value(H3XXX_EGPIO_OPT_RESET, 0);
155 188
156 msleep(10); 189 msleep(10);
157 190
@@ -169,10 +202,10 @@ static void h3600_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
169 * socket 0 then socket 1. 202 * socket 0 then socket 1.
170 */ 203 */
171 if (skt->nr == 1) { 204 if (skt->nr == 1) {
172 assign_h3600_egpio(IPAQ_EGPIO_OPT_ON, 0); 205 gpio_set_value(H3XXX_EGPIO_OPT_ON, 0);
173 assign_h3600_egpio(IPAQ_EGPIO_OPT_NVRAM_ON, 0); 206 gpio_set_value(H3XXX_EGPIO_OPT_NVRAM_ON, 0);
174 /* hmm, does this suck power? */ 207 /* hmm, does this suck power? */
175 assign_h3600_egpio(IPAQ_EGPIO_OPT_RESET, 1); 208 gpio_set_value(H3XXX_EGPIO_OPT_RESET, 1);
176 } 209 }
177} 210}
178 211