idp.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. /*
  2. * arch/arm/mach-pxa/include/mach/idp.h
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. *
  8. * Copyright (c) 2001 Cliff Brake, Accelent Systems Inc.
  9. *
  10. * 2001-09-13: Cliff Brake <cbrake@accelent.com>
  11. * Initial code
  12. *
  13. * 2005-02-15: Cliff Brake <cliff.brake@gmail.com>
  14. * <http://www.vibren.com> <http://bec-systems.com>
  15. * Changes for 2.6 kernel.
  16. */
  17. /*
  18. * Note: this file must be safe to include in assembly files
  19. *
  20. * Support for the Vibren PXA255 IDP requires rev04 or later
  21. * IDP hardware.
  22. */
  23. #include <mach/irqs.h> /* PXA_GPIO_TO_IRQ */
  24. #define IDP_FLASH_PHYS (PXA_CS0_PHYS)
  25. #define IDP_ALT_FLASH_PHYS (PXA_CS1_PHYS)
  26. #define IDP_MEDIAQ_PHYS (PXA_CS3_PHYS)
  27. #define IDP_IDE_PHYS (PXA_CS5_PHYS + 0x03000000)
  28. #define IDP_ETH_PHYS (PXA_CS5_PHYS + 0x03400000)
  29. #define IDP_COREVOLT_PHYS (PXA_CS5_PHYS + 0x03800000)
  30. #define IDP_CPLD_PHYS (PXA_CS5_PHYS + 0x03C00000)
  31. /*
  32. * virtual memory map
  33. */
  34. #define IDP_COREVOLT_VIRT (0xf0000000)
  35. #define IDP_COREVOLT_SIZE (1*1024*1024)
  36. #define IDP_CPLD_VIRT (IDP_COREVOLT_VIRT + IDP_COREVOLT_SIZE)
  37. #define IDP_CPLD_SIZE (1*1024*1024)
  38. #if (IDP_CPLD_VIRT + IDP_CPLD_SIZE) > 0xfc000000
  39. #error Your custom IO space is getting a bit large !!
  40. #endif
  41. #define CPLD_P2V(x) ((x) - IDP_CPLD_PHYS + IDP_CPLD_VIRT)
  42. #define CPLD_V2P(x) ((x) - IDP_CPLD_VIRT + IDP_CPLD_PHYS)
  43. #ifndef __ASSEMBLY__
  44. # define __CPLD_REG(x) (*((volatile unsigned long *)CPLD_P2V(x)))
  45. #else
  46. # define __CPLD_REG(x) CPLD_P2V(x)
  47. #endif
  48. /* board level registers in the CPLD: (offsets from CPLD_VIRT) */
  49. #define _IDP_CPLD_REV (IDP_CPLD_PHYS + 0x00)
  50. #define _IDP_CPLD_PERIPH_PWR (IDP_CPLD_PHYS + 0x04)
  51. #define _IDP_CPLD_LED_CONTROL (IDP_CPLD_PHYS + 0x08)
  52. #define _IDP_CPLD_KB_COL_HIGH (IDP_CPLD_PHYS + 0x0C)
  53. #define _IDP_CPLD_KB_COL_LOW (IDP_CPLD_PHYS + 0x10)
  54. #define _IDP_CPLD_PCCARD_EN (IDP_CPLD_PHYS + 0x14)
  55. #define _IDP_CPLD_GPIOH_DIR (IDP_CPLD_PHYS + 0x18)
  56. #define _IDP_CPLD_GPIOH_VALUE (IDP_CPLD_PHYS + 0x1C)
  57. #define _IDP_CPLD_GPIOL_DIR (IDP_CPLD_PHYS + 0x20)
  58. #define _IDP_CPLD_GPIOL_VALUE (IDP_CPLD_PHYS + 0x24)
  59. #define _IDP_CPLD_PCCARD_PWR (IDP_CPLD_PHYS + 0x28)
  60. #define _IDP_CPLD_MISC_CTRL (IDP_CPLD_PHYS + 0x2C)
  61. #define _IDP_CPLD_LCD (IDP_CPLD_PHYS + 0x30)
  62. #define _IDP_CPLD_FLASH_WE (IDP_CPLD_PHYS + 0x34)
  63. #define _IDP_CPLD_KB_ROW (IDP_CPLD_PHYS + 0x50)
  64. #define _IDP_CPLD_PCCARD0_STATUS (IDP_CPLD_PHYS + 0x54)
  65. #define _IDP_CPLD_PCCARD1_STATUS (IDP_CPLD_PHYS + 0x58)
  66. #define _IDP_CPLD_MISC_STATUS (IDP_CPLD_PHYS + 0x5C)
  67. /* FPGA register virtual addresses */
  68. #define IDP_CPLD_REV __CPLD_REG(_IDP_CPLD_REV)
  69. #define IDP_CPLD_PERIPH_PWR __CPLD_REG(_IDP_CPLD_PERIPH_PWR)
  70. #define IDP_CPLD_LED_CONTROL __CPLD_REG(_IDP_CPLD_LED_CONTROL)
  71. #define IDP_CPLD_KB_COL_HIGH __CPLD_REG(_IDP_CPLD_KB_COL_HIGH)
  72. #define IDP_CPLD_KB_COL_LOW __CPLD_REG(_IDP_CPLD_KB_COL_LOW)
  73. #define IDP_CPLD_PCCARD_EN __CPLD_REG(_IDP_CPLD_PCCARD_EN)
  74. #define IDP_CPLD_GPIOH_DIR __CPLD_REG(_IDP_CPLD_GPIOH_DIR)
  75. #define IDP_CPLD_GPIOH_VALUE __CPLD_REG(_IDP_CPLD_GPIOH_VALUE)
  76. #define IDP_CPLD_GPIOL_DIR __CPLD_REG(_IDP_CPLD_GPIOL_DIR)
  77. #define IDP_CPLD_GPIOL_VALUE __CPLD_REG(_IDP_CPLD_GPIOL_VALUE)
  78. #define IDP_CPLD_PCCARD_PWR __CPLD_REG(_IDP_CPLD_PCCARD_PWR)
  79. #define IDP_CPLD_MISC_CTRL __CPLD_REG(_IDP_CPLD_MISC_CTRL)
  80. #define IDP_CPLD_LCD __CPLD_REG(_IDP_CPLD_LCD)
  81. #define IDP_CPLD_FLASH_WE __CPLD_REG(_IDP_CPLD_FLASH_WE)
  82. #define IDP_CPLD_KB_ROW __CPLD_REG(_IDP_CPLD_KB_ROW)
  83. #define IDP_CPLD_PCCARD0_STATUS __CPLD_REG(_IDP_CPLD_PCCARD0_STATUS)
  84. #define IDP_CPLD_PCCARD1_STATUS __CPLD_REG(_IDP_CPLD_PCCARD1_STATUS)
  85. #define IDP_CPLD_MISC_STATUS __CPLD_REG(_IDP_CPLD_MISC_STATUS)
  86. /*
  87. * Bit masks for various registers
  88. */
  89. // IDP_CPLD_PCCARD_PWR
  90. #define PCC0_PWR0 (1 << 0)
  91. #define PCC0_PWR1 (1 << 1)
  92. #define PCC0_PWR2 (1 << 2)
  93. #define PCC0_PWR3 (1 << 3)
  94. #define PCC1_PWR0 (1 << 4)
  95. #define PCC1_PWR1 (1 << 5)
  96. #define PCC1_PWR2 (1 << 6)
  97. #define PCC1_PWR3 (1 << 7)
  98. // IDP_CPLD_PCCARD_EN
  99. #define PCC0_RESET (1 << 6)
  100. #define PCC1_RESET (1 << 7)
  101. #define PCC0_ENABLE (1 << 0)
  102. #define PCC1_ENABLE (1 << 1)
  103. // IDP_CPLD_PCCARDx_STATUS
  104. #define _PCC_WRPROT (1 << 7) // 7-4 read as low true
  105. #define _PCC_RESET (1 << 6)
  106. #define _PCC_IRQ (1 << 5)
  107. #define _PCC_INPACK (1 << 4)
  108. #define PCC_BVD2 (1 << 3)
  109. #define PCC_BVD1 (1 << 2)
  110. #define PCC_VS2 (1 << 1)
  111. #define PCC_VS1 (1 << 0)
  112. /* A listing of interrupts used by external hardware devices */
  113. #define TOUCH_PANEL_IRQ PXA_GPIO_TO_IRQ(5)
  114. #define IDE_IRQ PXA_GPIO_TO_IRQ(21)
  115. #define TOUCH_PANEL_IRQ_EDGE IRQ_TYPE_EDGE_FALLING
  116. #define ETHERNET_IRQ PXA_GPIO_TO_IRQ(4)
  117. #define ETHERNET_IRQ_EDGE IRQ_TYPE_EDGE_RISING
  118. #define IDE_IRQ_EDGE IRQ_TYPE_EDGE_RISING
  119. #define PCMCIA_S0_CD_VALID PXA_GPIO_TO_IRQ(7)
  120. #define PCMCIA_S0_CD_VALID_EDGE IRQ_TYPE_EDGE_BOTH
  121. #define PCMCIA_S1_CD_VALID PXA_GPIO_TO_IRQ(8)
  122. #define PCMCIA_S1_CD_VALID_EDGE IRQ_TYPE_EDGE_BOTH
  123. #define PCMCIA_S0_RDYINT PXA_GPIO_TO_IRQ(19)
  124. #define PCMCIA_S1_RDYINT PXA_GPIO_TO_IRQ(22)
  125. /*
  126. * Macros for LED Driver
  127. */
  128. /* leds 0 = ON */
  129. #define IDP_HB_LED (1<<5)
  130. #define IDP_BUSY_LED (1<<6)
  131. #define IDP_LEDS_MASK (IDP_HB_LED | IDP_BUSY_LED)
  132. /*
  133. * macros for MTD driver
  134. */
  135. #define FLASH_WRITE_PROTECT_DISABLE() ((IDP_CPLD_FLASH_WE) &= ~(0x1))
  136. #define FLASH_WRITE_PROTECT_ENABLE() ((IDP_CPLD_FLASH_WE) |= (0x1))
  137. /*
  138. * macros for matrix keyboard driver
  139. */
  140. #define KEYBD_MATRIX_NUMBER_INPUTS 7
  141. #define KEYBD_MATRIX_NUMBER_OUTPUTS 14
  142. #define KEYBD_MATRIX_INVERT_OUTPUT_LOGIC FALSE
  143. #define KEYBD_MATRIX_INVERT_INPUT_LOGIC FALSE
  144. #define KEYBD_MATRIX_SETTLING_TIME_US 100
  145. #define KEYBD_MATRIX_KEYSTATE_DEBOUNCE_CONSTANT 2
  146. #define KEYBD_MATRIX_SET_OUTPUTS(outputs) \
  147. {\
  148. IDP_CPLD_KB_COL_LOW = outputs;\
  149. IDP_CPLD_KB_COL_HIGH = outputs >> 7;\
  150. }
  151. #define KEYBD_MATRIX_GET_INPUTS(inputs) \
  152. {\
  153. inputs = (IDP_CPLD_KB_ROW & 0x7f);\
  154. }