aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/irda
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2012-01-08 11:40:07 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2012-02-09 10:37:54 -0500
commitcbe1d24fb70751ef14801338aa945e807ba63a90 (patch)
tree43ad30013992f470dee8eaf2ef42406a931594c6 /drivers/net/irda
parentba84525bd9015e7dd20f7c97a2a96b0a238b0223 (diff)
NET: sa11x0-ir: move sa1100_irda_{startup,shutdown,suspend,resume}
Places these functions in better locations in the file, near where they are used. This saves some tiresome paging up/down. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers/net/irda')
-rw-r--r--drivers/net/irda/sa1100_ir.c262
1 files changed, 131 insertions, 131 deletions
diff --git a/drivers/net/irda/sa1100_ir.c b/drivers/net/irda/sa1100_ir.c
index 9dc564830c9d..32ac4a44ce76 100644
--- a/drivers/net/irda/sa1100_ir.c
+++ b/drivers/net/irda/sa1100_ir.c
@@ -230,137 +230,6 @@ sa1100_set_power(struct sa1100_irda *si, unsigned int state)
230 return ret; 230 return ret;
231} 231}
232 232
233static int sa1100_irda_startup(struct sa1100_irda *si)
234{
235 int ret;
236
237 /*
238 * Ensure that the ports for this device are setup correctly.
239 */
240 if (si->pdata->startup) {
241 ret = si->pdata->startup(si->dev);
242 if (ret)
243 return ret;
244 }
245
246 /*
247 * Configure PPC for IRDA - we want to drive TXD2 low.
248 * We also want to drive this pin low during sleep.
249 */
250 PPSR &= ~PPC_TXD2;
251 PSDR &= ~PPC_TXD2;
252 PPDR |= PPC_TXD2;
253
254 /*
255 * Enable HP-SIR modulation, and ensure that the port is disabled.
256 */
257 Ser2UTCR3 = 0;
258 Ser2HSCR0 = HSCR0_UART;
259 Ser2UTCR4 = si->utcr4;
260 Ser2UTCR0 = UTCR0_8BitData;
261 Ser2HSCR2 = HSCR2_TrDataH | HSCR2_RcDataL;
262
263 /*
264 * Clear status register
265 */
266 Ser2UTSR0 = UTSR0_REB | UTSR0_RBB | UTSR0_RID;
267
268 ret = sa1100_irda_set_speed(si, si->speed = 9600);
269 if (ret) {
270 Ser2UTCR3 = 0;
271 Ser2HSCR0 = 0;
272
273 if (si->pdata->shutdown)
274 si->pdata->shutdown(si->dev);
275 }
276
277 return ret;
278}
279
280static void sa1100_irda_shutdown(struct sa1100_irda *si)
281{
282 /*
283 * Stop all DMA activity.
284 */
285 sa1100_stop_dma(si->dma_rx.regs);
286 sa1100_stop_dma(si->dma_tx.regs);
287
288 /* Disable the port. */
289 Ser2UTCR3 = 0;
290 Ser2HSCR0 = 0;
291
292 if (si->pdata->shutdown)
293 si->pdata->shutdown(si->dev);
294}
295
296#ifdef CONFIG_PM
297/*
298 * Suspend the IrDA interface.
299 */
300static int sa1100_irda_suspend(struct platform_device *pdev, pm_message_t state)
301{
302 struct net_device *dev = platform_get_drvdata(pdev);
303 struct sa1100_irda *si;
304
305 if (!dev)
306 return 0;
307
308 si = netdev_priv(dev);
309 if (si->open) {
310 /*
311 * Stop the transmit queue
312 */
313 netif_device_detach(dev);
314 disable_irq(dev->irq);
315 sa1100_irda_shutdown(si);
316 __sa1100_irda_set_power(si, 0);
317 }
318
319 return 0;
320}
321
322/*
323 * Resume the IrDA interface.
324 */
325static int sa1100_irda_resume(struct platform_device *pdev)
326{
327 struct net_device *dev = platform_get_drvdata(pdev);
328 struct sa1100_irda *si;
329
330 if (!dev)
331 return 0;
332
333 si = netdev_priv(dev);
334 if (si->open) {
335 /*
336 * If we missed a speed change, initialise at the new speed
337 * directly. It is debatable whether this is actually
338 * required, but in the interests of continuing from where
339 * we left off it is desirable. The converse argument is
340 * that we should re-negotiate at 9600 baud again.
341 */
342 if (si->newspeed) {
343 si->speed = si->newspeed;
344 si->newspeed = 0;
345 }
346
347 sa1100_irda_startup(si);
348 __sa1100_irda_set_power(si, si->power);
349 enable_irq(dev->irq);
350
351 /*
352 * This automatically wakes up the queue
353 */
354 netif_device_attach(dev);
355 }
356
357 return 0;
358}
359#else
360#define sa1100_irda_suspend NULL
361#define sa1100_irda_resume NULL
362#endif
363
364/* 233/*
365 * HP-SIR format interrupt service routines. 234 * HP-SIR format interrupt service routines.
366 */ 235 */
@@ -774,6 +643,69 @@ sa1100_irda_ioctl(struct net_device *dev, struct ifreq *ifreq, int cmd)
774 return ret; 643 return ret;
775} 644}
776 645
646static int sa1100_irda_startup(struct sa1100_irda *si)
647{
648 int ret;
649
650 /*
651 * Ensure that the ports for this device are setup correctly.
652 */
653 if (si->pdata->startup) {
654 ret = si->pdata->startup(si->dev);
655 if (ret)
656 return ret;
657 }
658
659 /*
660 * Configure PPC for IRDA - we want to drive TXD2 low.
661 * We also want to drive this pin low during sleep.
662 */
663 PPSR &= ~PPC_TXD2;
664 PSDR &= ~PPC_TXD2;
665 PPDR |= PPC_TXD2;
666
667 /*
668 * Enable HP-SIR modulation, and ensure that the port is disabled.
669 */
670 Ser2UTCR3 = 0;
671 Ser2HSCR0 = HSCR0_UART;
672 Ser2UTCR4 = si->utcr4;
673 Ser2UTCR0 = UTCR0_8BitData;
674 Ser2HSCR2 = HSCR2_TrDataH | HSCR2_RcDataL;
675
676 /*
677 * Clear status register
678 */
679 Ser2UTSR0 = UTSR0_REB | UTSR0_RBB | UTSR0_RID;
680
681 ret = sa1100_irda_set_speed(si, si->speed = 9600);
682 if (ret) {
683 Ser2UTCR3 = 0;
684 Ser2HSCR0 = 0;
685
686 if (si->pdata->shutdown)
687 si->pdata->shutdown(si->dev);
688 }
689
690 return ret;
691}
692
693static void sa1100_irda_shutdown(struct sa1100_irda *si)
694{
695 /*
696 * Stop all DMA activity.
697 */
698 sa1100_stop_dma(si->dma_rx.regs);
699 sa1100_stop_dma(si->dma_tx.regs);
700
701 /* Disable the port. */
702 Ser2UTCR3 = 0;
703 Ser2HSCR0 = 0;
704
705 if (si->pdata->shutdown)
706 si->pdata->shutdown(si->dev);
707}
708
777static int sa1100_irda_start(struct net_device *dev) 709static int sa1100_irda_start(struct net_device *dev)
778{ 710{
779 struct sa1100_irda *si = netdev_priv(dev); 711 struct sa1100_irda *si = netdev_priv(dev);
@@ -1024,6 +956,74 @@ static int sa1100_irda_remove(struct platform_device *pdev)
1024 return 0; 956 return 0;
1025} 957}
1026 958
959#ifdef CONFIG_PM
960/*
961 * Suspend the IrDA interface.
962 */
963static int sa1100_irda_suspend(struct platform_device *pdev, pm_message_t state)
964{
965 struct net_device *dev = platform_get_drvdata(pdev);
966 struct sa1100_irda *si;
967
968 if (!dev)
969 return 0;
970
971 si = netdev_priv(dev);
972 if (si->open) {
973 /*
974 * Stop the transmit queue
975 */
976 netif_device_detach(dev);
977 disable_irq(dev->irq);
978 sa1100_irda_shutdown(si);
979 __sa1100_irda_set_power(si, 0);
980 }
981
982 return 0;
983}
984
985/*
986 * Resume the IrDA interface.
987 */
988static int sa1100_irda_resume(struct platform_device *pdev)
989{
990 struct net_device *dev = platform_get_drvdata(pdev);
991 struct sa1100_irda *si;
992
993 if (!dev)
994 return 0;
995
996 si = netdev_priv(dev);
997 if (si->open) {
998 /*
999 * If we missed a speed change, initialise at the new speed
1000 * directly. It is debatable whether this is actually
1001 * required, but in the interests of continuing from where
1002 * we left off it is desirable. The converse argument is
1003 * that we should re-negotiate at 9600 baud again.
1004 */
1005 if (si->newspeed) {
1006 si->speed = si->newspeed;
1007 si->newspeed = 0;
1008 }
1009
1010 sa1100_irda_startup(si);
1011 __sa1100_irda_set_power(si, si->power);
1012 enable_irq(dev->irq);
1013
1014 /*
1015 * This automatically wakes up the queue
1016 */
1017 netif_device_attach(dev);
1018 }
1019
1020 return 0;
1021}
1022#else
1023#define sa1100_irda_suspend NULL
1024#define sa1100_irda_resume NULL
1025#endif
1026
1027static struct platform_driver sa1100ir_driver = { 1027static struct platform_driver sa1100ir_driver = {
1028 .probe = sa1100_irda_probe, 1028 .probe = sa1100_irda_probe,
1029 .remove = sa1100_irda_remove, 1029 .remove = sa1100_irda_remove,