soc_common.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /*
  2. * linux/drivers/pcmcia/soc_common.h
  3. *
  4. * Copyright (C) 2000 John G Dorsey <john+@cs.cmu.edu>
  5. *
  6. * This file contains definitions for the PCMCIA support code common to
  7. * integrated SOCs like the SA-11x0 and PXA2xx microprocessors.
  8. */
  9. #ifndef _ASM_ARCH_PCMCIA
  10. #define _ASM_ARCH_PCMCIA
  11. /* include the world */
  12. #include <linux/clk.h>
  13. #include <linux/cpufreq.h>
  14. #include <pcmcia/ss.h>
  15. #include <pcmcia/cistpl.h>
  16. struct device;
  17. struct pcmcia_low_level;
  18. /*
  19. * This structure encapsulates per-socket state which we might need to
  20. * use when responding to a Card Services query of some kind.
  21. */
  22. struct soc_pcmcia_socket {
  23. struct pcmcia_socket socket;
  24. /*
  25. * Info from low level handler
  26. */
  27. unsigned int nr;
  28. struct clk *clk;
  29. /*
  30. * Core PCMCIA state
  31. */
  32. const struct pcmcia_low_level *ops;
  33. unsigned int status;
  34. socket_state_t cs_state;
  35. unsigned short spd_io[MAX_IO_WIN];
  36. unsigned short spd_mem[MAX_WIN];
  37. unsigned short spd_attr[MAX_WIN];
  38. struct resource res_skt;
  39. struct resource res_io;
  40. struct resource res_mem;
  41. struct resource res_attr;
  42. void __iomem *virt_io;
  43. struct {
  44. int gpio;
  45. unsigned int irq;
  46. const char *name;
  47. } stat[4];
  48. #define SOC_STAT_CD 0 /* Card detect */
  49. #define SOC_STAT_BVD1 1 /* BATDEAD / IOSTSCHG */
  50. #define SOC_STAT_BVD2 2 /* BATWARN / IOSPKR */
  51. #define SOC_STAT_RDY 3 /* Ready / Interrupt */
  52. unsigned int irq_state;
  53. struct timer_list poll_timer;
  54. struct list_head node;
  55. };
  56. struct skt_dev_info {
  57. int nskt;
  58. struct clk *clk;
  59. struct soc_pcmcia_socket skt[0];
  60. };
  61. struct pcmcia_state {
  62. unsigned detect: 1,
  63. ready: 1,
  64. bvd1: 1,
  65. bvd2: 1,
  66. wrprot: 1,
  67. vs_3v: 1,
  68. vs_Xv: 1;
  69. };
  70. struct pcmcia_low_level {
  71. struct module *owner;
  72. /* first socket in system */
  73. int first;
  74. /* nr of sockets */
  75. int nr;
  76. int (*hw_init)(struct soc_pcmcia_socket *);
  77. void (*hw_shutdown)(struct soc_pcmcia_socket *);
  78. void (*socket_state)(struct soc_pcmcia_socket *, struct pcmcia_state *);
  79. int (*configure_socket)(struct soc_pcmcia_socket *, const socket_state_t *);
  80. /*
  81. * Enable card status IRQs on (re-)initialisation. This can
  82. * be called at initialisation, power management event, or
  83. * pcmcia event.
  84. */
  85. void (*socket_init)(struct soc_pcmcia_socket *);
  86. /*
  87. * Disable card status IRQs and PCMCIA bus on suspend.
  88. */
  89. void (*socket_suspend)(struct soc_pcmcia_socket *);
  90. /*
  91. * Hardware specific timing routines.
  92. * If provided, the get_timing routine overrides the SOC default.
  93. */
  94. unsigned int (*get_timing)(struct soc_pcmcia_socket *, unsigned int, unsigned int);
  95. int (*set_timing)(struct soc_pcmcia_socket *);
  96. int (*show_timing)(struct soc_pcmcia_socket *, char *);
  97. #ifdef CONFIG_CPU_FREQ
  98. /*
  99. * CPUFREQ support.
  100. */
  101. int (*frequency_change)(struct soc_pcmcia_socket *, unsigned long, struct cpufreq_freqs *);
  102. #endif
  103. };
  104. struct pcmcia_irqs {
  105. int sock;
  106. int irq;
  107. const char *str;
  108. };
  109. struct soc_pcmcia_timing {
  110. unsigned short io;
  111. unsigned short mem;
  112. unsigned short attr;
  113. };
  114. extern int soc_pcmcia_request_irqs(struct soc_pcmcia_socket *skt, struct pcmcia_irqs *irqs, int nr);
  115. extern void soc_pcmcia_free_irqs(struct soc_pcmcia_socket *skt, struct pcmcia_irqs *irqs, int nr);
  116. extern void soc_pcmcia_disable_irqs(struct soc_pcmcia_socket *skt, struct pcmcia_irqs *irqs, int nr);
  117. extern void soc_pcmcia_enable_irqs(struct soc_pcmcia_socket *skt, struct pcmcia_irqs *irqs, int nr);
  118. extern void soc_common_pcmcia_get_timing(struct soc_pcmcia_socket *, struct soc_pcmcia_timing *);
  119. void soc_pcmcia_init_one(struct soc_pcmcia_socket *skt,
  120. struct pcmcia_low_level *ops, struct device *dev);
  121. void soc_pcmcia_remove_one(struct soc_pcmcia_socket *skt);
  122. int soc_pcmcia_add_one(struct soc_pcmcia_socket *skt);
  123. #ifdef CONFIG_PCMCIA_DEBUG
  124. extern void soc_pcmcia_debug(struct soc_pcmcia_socket *skt, const char *func,
  125. int lvl, const char *fmt, ...);
  126. #define debug(skt, lvl, fmt, arg...) \
  127. soc_pcmcia_debug(skt, __func__, lvl, fmt , ## arg)
  128. #else
  129. #define debug(skt, lvl, fmt, arg...) do { } while (0)
  130. #endif
  131. /*
  132. * The PC Card Standard, Release 7, section 4.13.4, says that twIORD
  133. * has a minimum value of 165ns. Section 4.13.5 says that twIOWR has
  134. * a minimum value of 165ns, as well. Section 4.7.2 (describing
  135. * common and attribute memory write timing) says that twWE has a
  136. * minimum value of 150ns for a 250ns cycle time (for 5V operation;
  137. * see section 4.7.4), or 300ns for a 600ns cycle time (for 3.3V
  138. * operation, also section 4.7.4). Section 4.7.3 says that taOE
  139. * has a maximum value of 150ns for a 300ns cycle time (for 5V
  140. * operation), or 300ns for a 600ns cycle time (for 3.3V operation).
  141. *
  142. * When configuring memory maps, Card Services appears to adopt the policy
  143. * that a memory access time of "0" means "use the default." The default
  144. * PCMCIA I/O command width time is 165ns. The default PCMCIA 5V attribute
  145. * and memory command width time is 150ns; the PCMCIA 3.3V attribute and
  146. * memory command width time is 300ns.
  147. */
  148. #define SOC_PCMCIA_IO_ACCESS (165)
  149. #define SOC_PCMCIA_5V_MEM_ACCESS (150)
  150. #define SOC_PCMCIA_3V_MEM_ACCESS (300)
  151. #define SOC_PCMCIA_ATTR_MEM_ACCESS (300)
  152. /*
  153. * The socket driver actually works nicely in interrupt-driven form,
  154. * so the (relatively infrequent) polling is "just to be sure."
  155. */
  156. #define SOC_PCMCIA_POLL_PERIOD (2*HZ)
  157. /* I/O pins replacing memory pins
  158. * (PCMCIA System Architecture, 2nd ed., by Don Anderson, p.75)
  159. *
  160. * These signals change meaning when going from memory-only to
  161. * memory-or-I/O interface:
  162. */
  163. #define iostschg bvd1
  164. #define iospkr bvd2
  165. #endif