]> rtime.felk.cvut.cz Git - linux-imx.git/blob - drivers/pcmcia/mx31ads-pcmcia.h
mx53: CPU HW idle state set to WAIT_CLOCKED
[linux-imx.git] / drivers / pcmcia / mx31ads-pcmcia.h
1 /*
2  * linux/drivers/pcmcia/mx31ads-pcmcia.h
3  *
4  * Copyright 2005-2010 Freescale Semiconductor, Inc. All Rights Reserved.
5  *
6  * This file contains definitions for the PCMCIA support code common to
7  * integrated SOCs like the i.Mx31 microprocessors.
8  */
9 #ifndef _ASM_ARCH_PCMCIA
10 #define _ASM_ARCH_PCMCIA
11
12 /* include the world */
13 #include <linux/cpufreq.h>
14 #include <pcmcia/cs_types.h>
15 #include <pcmcia/cs.h>
16 #include <pcmcia/ss.h>
17 #include <pcmcia/cistpl.h>
18 #include "cs_internal.h"
19
20 #define MX31ADS_PCMCIA  "Mx31ads_pcmcia_socket"
21
22 struct device;
23 struct pcmcia_low_level;
24
25 /*
26  * This structure encapsulates per-socket state which we might need to
27  * use when responding to a Card Services query of some kind.
28  */
29 struct mx31ads_pcmcia_socket {
30         struct pcmcia_socket socket;
31
32         /*
33          * Info from low level handler
34          */
35         struct device *dev;
36         unsigned int nr;
37         unsigned int irq;
38
39         struct clk *clk;
40
41         /*
42          * Core PCMCIA state
43          */
44         struct pcmcia_low_level *ops;
45
46         unsigned int status;
47         unsigned int pre_stat;
48         socket_state_t cs_state;
49
50         unsigned short spd_io[MAX_IO_WIN];
51         unsigned short spd_mem[MAX_WIN];
52         unsigned short spd_attr[MAX_WIN];
53
54         struct resource res_skt;
55         struct resource res_io;
56         struct resource res_mem;
57         struct resource res_attr;
58         void *virt_io;
59
60         unsigned int irq_state;
61
62         struct timer_list poll_timer;
63         struct list_head node;
64 };
65
66 struct pcmcia_state {
67         unsigned detect:1,
68             ready:1, bvd1:1, bvd2:1, wrprot:1, vs_3v:1, vs_Xv:1, poweron:1;
69 };
70
71 struct pcmcia_low_level {
72         struct module *owner;
73
74         /* first socket in system */
75         int first;
76         /* nr of sockets */
77         int nr;
78
79         int (*hw_init) (struct mx31ads_pcmcia_socket *);
80         void (*hw_shutdown) (struct mx31ads_pcmcia_socket *);
81
82         void (*socket_state) (struct mx31ads_pcmcia_socket *,
83                               struct pcmcia_state *);
84         int (*configure_socket) (struct mx31ads_pcmcia_socket *,
85                                  const socket_state_t *);
86
87         /*
88          * Enable card status IRQs on (re-)initialisation.  This can
89          * be called at initialisation, power management event, or
90          * pcmcia event.
91          */
92         void (*socket_init) (struct mx31ads_pcmcia_socket *);
93
94         /*
95          * Disable card status IRQs and PCMCIA bus on suspend.
96          */
97         void (*socket_suspend) (struct mx31ads_pcmcia_socket *);
98
99         /*
100          * Hardware specific timing routines.
101          * If provided, the get_timing routine overrides the SOC default.
102          */
103         unsigned int (*get_timing) (struct mx31ads_pcmcia_socket *,
104                                     unsigned int, unsigned int);
105         int (*set_timing) (struct mx31ads_pcmcia_socket *);
106         int (*show_timing) (struct mx31ads_pcmcia_socket *, char *);
107
108 #ifdef CONFIG_CPU_FREQ
109         /*
110          * CPUFREQ support.
111          */
112         int (*frequency_change) (struct mx31ads_pcmcia_socket *, unsigned long,
113                                  struct cpufreq_freqs *);
114 #endif
115 };
116
117 struct mx31ads_pcmcia_timing {
118         unsigned short io;
119         unsigned short mem;
120         unsigned short attr;
121 };
122
123 typedef struct {
124         ulong win_size;
125         int bsize;
126 } bsize_map_t;
127
128 /*
129  * The PC Card Standard, Release 7, section 4.13.4, says that twIORD
130  * has a minimum value of 165ns. Section 4.13.5 says that twIOWR has
131  * a minimum value of 165ns, as well. Section 4.7.2 (describing
132  * common and attribute memory write timing) says that twWE has a
133  * minimum value of 150ns for a 250ns cycle time (for 5V operation;
134  * see section 4.7.4), or 300ns for a 600ns cycle time (for 3.3V
135  * operation, also section 4.7.4). Section 4.7.3 says that taOE
136  * has a maximum value of 150ns for a 300ns cycle time (for 5V
137  * operation), or 300ns for a 600ns cycle time (for 3.3V operation).
138  *
139  * When configuring memory maps, Card Services appears to adopt the policy
140  * that a memory access time of "0" means "use the default." The default
141  * PCMCIA I/O command width time is 165ns. The default PCMCIA 5V attribute
142  * and memory command width time is 150ns; the PCMCIA 3.3V attribute and
143  * memory command width time is 300ns.
144  */
145 #define PCMCIA_IO_ACCESS                (165)
146 #define PCMCIA_5V_MEM_ACCESS    (150)
147 #define PCMCIA_3V_MEM_ACCESS    (300)
148 #define PCMCIA_ATTR_MEM_ACCESS  (300)
149
150 /*
151  * The socket driver actually works nicely in interrupt-driven form,
152  * so the (relatively infrequent) polling is "just to be sure."
153  */
154 #define PCMCIA_POLL_PERIOD    (2*HZ)
155 #endif