hiddenDangerAnalysis.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * linux/arch/arm/mach-sa1100/neponset.c
  3. */
  4. #include <linux/err.h>
  5. #include <linux/init.h>
  6. #include <linux/ioport.h>
  7. #include <linux/irq.h>
  8. #include <linux/kernel.h>
  9. #include <linux/module.h>
  10. #include <linux/platform_data/sa11x0-serial.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/pm.h>
  13. #include <linux/serial_core.h>
  14. #include <linux/slab.h>
  15. #include <asm/mach-types.h>
  16. #include <asm/mach/map.h>
  17. #include <asm/hardware/sa1111.h>
  18. #include <asm/sizes.h>
  19. #include <mach/hardware.h>
  20. #include <mach/assabet.h>
  21. #include <mach/neponset.h>
  22. #include <mach/irqs.h>
  23. #define NEP_IRQ_SMC91X 0
  24. #define NEP_IRQ_USAR 1
  25. #define NEP_IRQ_SA1111 2
  26. #define NEP_IRQ_NR 3
  27. #define WHOAMI 0x00
  28. #define LEDS 0x10
  29. #define SWPK 0x20
  30. #define IRR 0x24
  31. #define KP_Y_IN 0x80
  32. #define KP_X_OUT 0x90
  33. #define NCR_0 0xa0
  34. #define MDM_CTL_0 0xb0
  35. #define MDM_CTL_1 0xb4
  36. #define AUD_CTL 0xc0
  37. #define IRR_ETHERNET (1 << 0)
  38. #define IRR_USAR (1 << 1)
  39. #define IRR_SA1111 (1 << 2)
  40. #define MDM_CTL0_RTS1 (1 << 0)
  41. #define MDM_CTL0_DTR1 (1 << 1)
  42. #define MDM_CTL0_RTS2 (1 << 2)
  43. #define MDM_CTL0_DTR2 (1 << 3)
  44. #define MDM_CTL1_CTS1 (1 << 0)
  45. #define MDM_CTL1_DSR1 (1 << 1)
  46. #define MDM_CTL1_DCD1 (1 << 2)
  47. #define MDM_CTL1_CTS2 (1 << 3)
  48. #define MDM_CTL1_DSR2 (1 << 4)
  49. #define MDM_CTL1_DCD2 (1 << 5)
  50. #define AUD_SEL_1341 (1 << 0)
  51. #define AUD_MUTE_1341 (1 << 1)
  52. extern void sa1110_mb_disable(void);
  53. struct neponset_drvdata {
  54. void __iomem *base;
  55. struct platform_device *sa1111;
  56. struct platform_device *smc91x;
  57. unsigned irq_base;
  58. #ifdef CONFIG_PM_SLEEP
  59. u32 ncr0;
  60. u32 mdm_ctl_0;
  61. #endif
  62. };
  63. static void __iomem *nep_base;
  64. void neponset_ncr_frob(unsigned int mask, unsigned int val)
  65. {
  66. void __iomem *base = nep_base;
  67. if (base) {
  68. unsigned long flags;
  69. unsigned v;
  70. local_irq_save(flags);
  71. v = readb_relaxed(base + NCR_0);
  72. writeb_relaxed((v & ~mask) | val, base + NCR_0);
  73. local_irq_restore(flags);
  74. } else {
  75. WARN(1, "nep_base unset\n");
  76. }
  77. }
  78. EXPORT_SYMBOL(neponset_ncr_frob);
  79. static void neponset_set_mctrl(struct uart_port *port, u_int mctrl)
  80. {
  81. void __iomem *base = nep_base;
  82. u_int mdm_ctl0;
  83. if (!base)
  84. return;
  85. mdm_ctl0 = readb_relaxed(base + MDM_CTL_0);
  86. if (port->mapbase == _Ser1UTCR0) {
  87. if (mctrl & TIOCM_RTS)
  88. mdm_ctl0 &= ~MDM_CTL0_RTS2;
  89. else
  90. mdm_ctl0 |= MDM_CTL0_RTS2;
  91. if (mctrl & TIOCM_DTR)
  92. mdm_ctl0 &= ~MDM_CTL0_DTR2;
  93. else
  94. mdm_ctl0 |= MDM_CTL0_DTR2;
  95. } else if (port->mapbase == _Ser3UTCR0) {
  96. if (mctrl & TIOCM_RTS)
  97. mdm_ctl0 &= ~MDM_CTL0_RTS1;
  98. else
  99. mdm_ctl0 |= MDM_CTL0_RTS1;
  100. if (mctrl & TIOCM_DTR)
  101. mdm_ctl0 &= ~MDM_CTL0_DTR1;