sa11xx_base.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*======================================================================
  2. Device driver for the PCMCIA control functionality of StrongARM
  3. SA-1100 microprocessors.
  4. The contents of this file are subject to the Mozilla Public
  5. License Version 1.1 (the "License"); you may not use this file
  6. except in compliance with the License. You may obtain a copy of
  7. the License at http://www.mozilla.org/MPL/
  8. Software distributed under the License is distributed on an "AS
  9. IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  10. implied. See the License for the specific language governing
  11. rights and limitations under the License.
  12. The initial developer of the original code is John G. Dorsey
  13. <john+@cs.cmu.edu>. Portions created by John G. Dorsey are
  14. Copyright (C) 1999 John G. Dorsey. All Rights Reserved.
  15. Alternatively, the contents of this file may be used under the
  16. terms of the GNU Public License version 2 (the "GPL"), in which
  17. case the provisions of the GPL are applicable instead of the
  18. above. If you wish to allow the use of your version of this file
  19. only under the terms of the GPL and not to allow others to use
  20. your version of this file under the MPL, indicate your decision
  21. by deleting the provisions above and replace them with the notice
  22. and other provisions required by the GPL. If you do not delete
  23. the provisions above, a recipient may use your version of this
  24. file under either the MPL or the GPL.
  25. ======================================================================*/
  26. #if !defined(_PCMCIA_SA1100_H)
  27. # define _PCMCIA_SA1100_H
  28. /* SA-1100 PCMCIA Memory and I/O timing
  29. * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  30. * The SA-1110 Developer's Manual, section 10.2.5, says the following:
  31. *
  32. * "To calculate the recommended BS_xx value for each address space:
  33. * divide the command width time (the greater of twIOWR and twIORD,
  34. * or the greater of twWE and twOE) by processor cycle time; divide
  35. * by 2; divide again by 3 (number of BCLK's per command assertion);
  36. * round up to the next whole number; and subtract 1."
  37. */
  38. /* MECR: Expansion Memory Configuration Register
  39. * (SA-1100 Developers Manual, p.10-13; SA-1110 Developers Manual, p.10-24)
  40. *
  41. * MECR layout is:
  42. *
  43. * FAST1 BSM1<4:0> BSA1<4:0> BSIO1<4:0> FAST0 BSM0<4:0> BSA0<4:0> BSIO0<4:0>
  44. *
  45. * (This layout is actually true only for the SA-1110; the FASTn bits are
  46. * reserved on the SA-1100.)
  47. */
  48. #define MECR_SOCKET_0_SHIFT (0)
  49. #define MECR_SOCKET_1_SHIFT (16)
  50. #define MECR_BS_MASK (0x1f)
  51. #define MECR_FAST_MODE_MASK (0x01)
  52. #define MECR_BSIO_SHIFT (0)
  53. #define MECR_BSA_SHIFT (5)
  54. #define MECR_BSM_SHIFT (10)
  55. #define MECR_FAST_SHIFT (15)
  56. #define MECR_SET(mecr, sock, shift, mask, bs) \
  57. ((mecr)=((mecr)&~(((mask)<<(shift))<<\
  58. ((sock)==0?MECR_SOCKET_0_SHIFT:MECR_SOCKET_1_SHIFT)))|\
  59. (((bs)<<(shift))<<((sock)==0?MECR_SOCKET_0_SHIFT:MECR_SOCKET_1_SHIFT)))
  60. #define MECR_GET(mecr, sock, shift, mask) \
  61. ((((mecr)>>(((sock)==0)?MECR_SOCKET_0_SHIFT:MECR_SOCKET_1_SHIFT))>>\
  62. (shift))&(mask))
  63. #define MECR_BSIO_SET(mecr, sock, bs) \
  64. MECR_SET((mecr), (sock), MECR_BSIO_SHIFT, MECR_BS_MASK, (bs))
  65. #define MECR_BSIO_GET(mecr, sock) \
  66. MECR_GET((mecr), (sock), MECR_BSIO_SHIFT, MECR_BS_MASK)
  67. #define MECR_BSA_SET(mecr, sock, bs) \
  68. MECR_SET((mecr), (sock), MECR_BSA_SHIFT, MECR_BS_MASK, (bs))
  69. #define MECR_BSA_GET(mecr, sock) \
  70. MECR_GET((mecr), (sock), MECR_BSA_SHIFT, MECR_BS_MASK)
  71. #define MECR_BSM_SET(mecr, sock, bs) \
  72. MECR_SET((mecr), (sock), MECR_BSM_SHIFT, MECR_BS_MASK, (bs))
  73. #define MECR_BSM_GET(mecr, sock) \
  74. MECR_GET((mecr), (sock), MECR_BSM_SHIFT, MECR_BS_MASK)
  75. #define MECR_FAST_SET(mecr, sock, fast) \
  76. MECR_SET((mecr), (sock), MECR_FAST_SHIFT, MECR_FAST_MODE_MASK, (fast))
  77. #define MECR_FAST_GET(mecr, sock) \
  78. MECR_GET((mecr), (sock), MECR_FAST_SHIFT, MECR_FAST_MODE_MASK)
  79. /* This function implements the BS value calculation for setting the MECR
  80. * using integer arithmetic:
  81. */
  82. static inline unsigned int sa1100_pcmcia_mecr_bs(unsigned int pcmcia_cycle_ns,
  83. unsigned int cpu_clock_khz){
  84. unsigned int t = ((pcmcia_cycle_ns * cpu_clock_khz) / 6) - 1000000;
  85. return (t / 1000000) + (((t % 1000000) == 0) ? 0 : 1);
  86. }
  87. /* This function returns the (approximate) command assertion period, in
  88. * nanoseconds, for a given CPU clock frequency and MECR BS value:
  89. */
  90. static inline unsigned int sa1100_pcmcia_cmd_time(unsigned int cpu_clock_khz,
  91. unsigned int pcmcia_mecr_bs){
  92. return (((10000000 * 2) / cpu_clock_khz) * (3 * (pcmcia_mecr_bs + 1))) / 10;
  93. }
  94. int sa11xx_drv_pcmcia_add_one(struct soc_pcmcia_socket *skt);
  95. void sa11xx_drv_pcmcia_ops(struct pcmcia_low_level *ops);
  96. extern int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, int first, int nr);
  97. #endif /* !defined(_PCMCIA_SA1100_H) */