aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMarek Vasut <marek.vasut@gmail.com>2009-07-17 06:50:43 -0400
committerEric Miao <eric.y.miao@gmail.com>2009-09-10 06:49:39 -0400
commitc4bd01727380ce666aba987b3d7c0e838cb99bbe (patch)
tree5ee425da3645c1371b154bc47d1ae7ab3c81041b /drivers
parent2a23ec3679d84ac243add761fa3d3872cf6dcb11 (diff)
[ARM] pxa: add gpio_pwdown(_inverted) into pxaficp_ir.c
and convert PXA-based devices to gpio_pwdown where possible. Signed-off-by: Marek Vasut <marek.vasut@gmail.com> Signed-off-by: Eric Miao <eric.y.miao@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/irda/pxaficp_ir.c47
1 files changed, 41 insertions, 6 deletions
diff --git a/drivers/net/irda/pxaficp_ir.c b/drivers/net/irda/pxaficp_ir.c
index 77d10edefd25..f5b7d8320787 100644
--- a/drivers/net/irda/pxaficp_ir.c
+++ b/drivers/net/irda/pxaficp_ir.c
@@ -17,6 +17,7 @@
17#include <linux/etherdevice.h> 17#include <linux/etherdevice.h>
18#include <linux/platform_device.h> 18#include <linux/platform_device.h>
19#include <linux/clk.h> 19#include <linux/clk.h>
20#include <linux/gpio.h>
20 21
21#include <net/irda/irda.h> 22#include <net/irda/irda.h>
22#include <net/irda/irmod.h> 23#include <net/irda/irmod.h>
@@ -163,6 +164,22 @@ inline static void pxa_irda_fir_dma_tx_start(struct pxa_irda *si)
163} 164}
164 165
165/* 166/*
167 * Set the IrDA communications mode.
168 */
169static void pxa_irda_set_mode(struct pxa_irda *si, int mode)
170{
171 if (si->pdata->transceiver_mode)
172 si->pdata->transceiver_mode(si->dev, mode);
173 else {
174 if (gpio_is_valid(si->pdata->gpio_pwdown))
175 gpio_set_value(si->pdata->gpio_pwdown,
176 !(mode & IR_OFF) ^
177 !si->pdata->gpio_pwdown_inverted);
178 pxa2xx_transceiver_mode(si->dev, mode);
179 }
180}
181
182/*
166 * Set the IrDA communications speed. 183 * Set the IrDA communications speed.
167 */ 184 */
168static int pxa_irda_set_speed(struct pxa_irda *si, int speed) 185static int pxa_irda_set_speed(struct pxa_irda *si, int speed)
@@ -188,7 +205,7 @@ static int pxa_irda_set_speed(struct pxa_irda *si, int speed)
188 pxa_irda_disable_clk(si); 205 pxa_irda_disable_clk(si);
189 206
190 /* set board transceiver to SIR mode */ 207 /* set board transceiver to SIR mode */
191 si->pdata->transceiver_mode(si->dev, IR_SIRMODE); 208 pxa_irda_set_mode(si, IR_SIRMODE);
192 209
193 /* enable the STUART clock */ 210 /* enable the STUART clock */
194 pxa_irda_enable_sirclk(si); 211 pxa_irda_enable_sirclk(si);
@@ -222,7 +239,7 @@ static int pxa_irda_set_speed(struct pxa_irda *si, int speed)
222 ICCR0 = 0; 239 ICCR0 = 0;
223 240
224 /* set board transceiver to FIR mode */ 241 /* set board transceiver to FIR mode */
225 si->pdata->transceiver_mode(si->dev, IR_FIRMODE); 242 pxa_irda_set_mode(si, IR_FIRMODE);
226 243
227 /* enable the FICP clock */ 244 /* enable the FICP clock */
228 pxa_irda_enable_firclk(si); 245 pxa_irda_enable_firclk(si);
@@ -641,7 +658,7 @@ static void pxa_irda_shutdown(struct pxa_irda *si)
641 local_irq_restore(flags); 658 local_irq_restore(flags);
642 659
643 /* power off board transceiver */ 660 /* power off board transceiver */
644 si->pdata->transceiver_mode(si->dev, IR_OFF); 661 pxa_irda_set_mode(si, IR_OFF);
645 662
646 printk(KERN_DEBUG "pxa_ir: irda shutdown\n"); 663 printk(KERN_DEBUG "pxa_ir: irda shutdown\n");
647} 664}
@@ -849,10 +866,26 @@ static int pxa_irda_probe(struct platform_device *pdev)
849 if (err) 866 if (err)
850 goto err_mem_5; 867 goto err_mem_5;
851 868
852 if (si->pdata->startup) 869 if (gpio_is_valid(si->pdata->gpio_pwdown)) {
870 err = gpio_request(si->pdata->gpio_pwdown, "IrDA switch");
871 if (err)
872 goto err_startup;
873 err = gpio_direction_output(si->pdata->gpio_pwdown,
874 !si->pdata->gpio_pwdown_inverted);
875 if (err) {
876 gpio_free(si->pdata->gpio_pwdown);
877 goto err_startup;
878 }
879 }
880
881 if (si->pdata->startup) {
853 err = si->pdata->startup(si->dev); 882 err = si->pdata->startup(si->dev);
854 if (err) 883 if (err)
855 goto err_startup; 884 goto err_startup;
885 }
886
887 if (gpio_is_valid(si->pdata->gpio_pwdown) && si->pdata->startup)
888 dev_warn(si->dev, "gpio_pwdown and startup() both defined!\n");
856 889
857 dev->netdev_ops = &pxa_irda_netdev_ops; 890 dev->netdev_ops = &pxa_irda_netdev_ops;
858 891
@@ -903,6 +936,8 @@ static int pxa_irda_remove(struct platform_device *_dev)
903 if (dev) { 936 if (dev) {
904 struct pxa_irda *si = netdev_priv(dev); 937 struct pxa_irda *si = netdev_priv(dev);
905 unregister_netdev(dev); 938 unregister_netdev(dev);
939 if (gpio_is_valid(si->pdata->gpio_pwdown))
940 gpio_free(si->pdata->gpio_pwdown);
906 if (si->pdata->shutdown) 941 if (si->pdata->shutdown)
907 si->pdata->shutdown(si->dev); 942 si->pdata->shutdown(si->dev);
908 kfree(si->tx_buff.head); 943 kfree(si->tx_buff.head);