aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/tifm.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/tifm.h')
-rw-r--r--include/linux/tifm.h117
1 files changed, 60 insertions, 57 deletions
diff --git a/include/linux/tifm.h b/include/linux/tifm.h
index 3deb0a6c1370..2a196982601f 100644
--- a/include/linux/tifm.h
+++ b/include/linux/tifm.h
@@ -14,16 +14,16 @@
14 14
15#include <linux/spinlock.h> 15#include <linux/spinlock.h>
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <linux/wait.h>
18#include <linux/delay.h> 17#include <linux/delay.h>
19#include <linux/pci.h> 18#include <linux/pci.h>
20#include <linux/kthread.h> 19#include <linux/workqueue.h>
21 20
22/* Host registers (relative to pci base address): */ 21/* Host registers (relative to pci base address): */
23enum { 22enum {
24 FM_SET_INTERRUPT_ENABLE = 0x008, 23 FM_SET_INTERRUPT_ENABLE = 0x008,
25 FM_CLEAR_INTERRUPT_ENABLE = 0x00c, 24 FM_CLEAR_INTERRUPT_ENABLE = 0x00c,
26 FM_INTERRUPT_STATUS = 0x014 }; 25 FM_INTERRUPT_STATUS = 0x014
26};
27 27
28/* Socket registers (relative to socket base address): */ 28/* Socket registers (relative to socket base address): */
29enum { 29enum {
@@ -58,14 +58,8 @@ enum {
58 SOCK_MS_DATA = 0x188, 58 SOCK_MS_DATA = 0x188,
59 SOCK_MS_STATUS = 0x18c, 59 SOCK_MS_STATUS = 0x18c,
60 SOCK_MS_SYSTEM = 0x190, 60 SOCK_MS_SYSTEM = 0x190,
61 SOCK_FIFO_ACCESS = 0x200 }; 61 SOCK_FIFO_ACCESS = 0x200
62 62};
63
64#define TIFM_IRQ_ENABLE 0x80000000
65#define TIFM_IRQ_SOCKMASK(x) (x)
66#define TIFM_IRQ_CARDMASK(x) ((x) << 8)
67#define TIFM_IRQ_FIFOMASK(x) ((x) << 16)
68#define TIFM_IRQ_SETALL 0xffffffff
69 63
70#define TIFM_CTRL_LED 0x00000040 64#define TIFM_CTRL_LED 0x00000040
71#define TIFM_CTRL_FAST_CLK 0x00000100 65#define TIFM_CTRL_FAST_CLK 0x00000100
@@ -73,63 +67,76 @@ enum {
73#define TIFM_SOCK_STATE_OCCUPIED 0x00000008 67#define TIFM_SOCK_STATE_OCCUPIED 0x00000008
74#define TIFM_SOCK_STATE_POWERED 0x00000080 68#define TIFM_SOCK_STATE_POWERED 0x00000080
75 69
76#define TIFM_FIFO_ENABLE 0x00000001 /* Meaning of this constant is unverified */ 70#define TIFM_FIFO_ENABLE 0x00000001
71#define TIFM_FIFO_READY 0x00000001
77#define TIFM_FIFO_INT_SETALL 0x0000ffff 72#define TIFM_FIFO_INT_SETALL 0x0000ffff
78#define TIFM_FIFO_INTMASK 0x00000005 /* Meaning of this constant is unverified */ 73#define TIFM_FIFO_INTMASK 0x00000005
74
75#define TIFM_DMA_RESET 0x00000002
76#define TIFM_DMA_TX 0x00008000
77#define TIFM_DMA_EN 0x00000001
78#define TIFM_DMA_TSIZE 0x0000007f
79 79
80#define TIFM_DMA_RESET 0x00000002 /* Meaning of this constant is unverified */ 80#define TIFM_TYPE_XD 1
81#define TIFM_DMA_TX 0x00008000 /* Meaning of this constant is unverified */ 81#define TIFM_TYPE_MS 2
82#define TIFM_DMA_EN 0x00000001 /* Meaning of this constant is unverified */ 82#define TIFM_TYPE_SD 3
83 83
84typedef enum {FM_NULL = 0, FM_XD = 0x01, FM_MS = 0x02, FM_SD = 0x03} tifm_media_id; 84struct tifm_device_id {
85 unsigned char type;
86};
85 87
86struct tifm_driver; 88struct tifm_driver;
87struct tifm_dev { 89struct tifm_dev {
88 char __iomem *addr; 90 char __iomem *addr;
89 spinlock_t lock; 91 spinlock_t lock;
90 tifm_media_id media_id; 92 unsigned char type;
91 unsigned int socket_id; 93 unsigned int socket_id;
92 94
93 void (*signal_irq)(struct tifm_dev *sock, 95 void (*card_event)(struct tifm_dev *sock);
94 unsigned int sock_irq_status); 96 void (*data_event)(struct tifm_dev *sock);
95 97
96 struct tifm_driver *drv; 98 struct device dev;
97 struct device dev;
98}; 99};
99 100
100struct tifm_driver { 101struct tifm_driver {
101 tifm_media_id *id_table; 102 struct tifm_device_id *id_table;
102 int (*probe)(struct tifm_dev *dev); 103 int (*probe)(struct tifm_dev *dev);
103 void (*remove)(struct tifm_dev *dev); 104 void (*remove)(struct tifm_dev *dev);
104 int (*suspend)(struct tifm_dev *dev, 105 int (*suspend)(struct tifm_dev *dev,
105 pm_message_t state); 106 pm_message_t state);
106 int (*resume)(struct tifm_dev *dev); 107 int (*resume)(struct tifm_dev *dev);
107 108
108 struct device_driver driver; 109 struct device_driver driver;
109}; 110};
110 111
111struct tifm_adapter { 112struct tifm_adapter {
112 char __iomem *addr; 113 char __iomem *addr;
113 spinlock_t lock; 114 spinlock_t lock;
114 unsigned int irq_status; 115 unsigned int irq_status;
115 unsigned int socket_change_set; 116 unsigned int socket_change_set;
116 wait_queue_head_t change_set_notify; 117 unsigned int id;
117 unsigned int id; 118 unsigned int num_sockets;
118 unsigned int num_sockets; 119 struct completion *finish_me;
119 struct tifm_dev **sockets; 120
120 struct task_struct *media_switcher; 121 struct work_struct media_switcher;
121 struct class_device cdev; 122 struct class_device cdev;
122 struct device *dev; 123
123 124 void (*eject)(struct tifm_adapter *fm,
124 void (*eject)(struct tifm_adapter *fm, struct tifm_dev *sock); 125 struct tifm_dev *sock);
126
127 struct tifm_dev *sockets[0];
125}; 128};
126 129
127struct tifm_adapter *tifm_alloc_adapter(void); 130struct tifm_adapter *tifm_alloc_adapter(unsigned int num_sockets,
128void tifm_free_device(struct device *dev); 131 struct device *dev);
129void tifm_free_adapter(struct tifm_adapter *fm); 132int tifm_add_adapter(struct tifm_adapter *fm);
130int tifm_add_adapter(struct tifm_adapter *fm, int (*mediathreadfn)(void *data));
131void tifm_remove_adapter(struct tifm_adapter *fm); 133void tifm_remove_adapter(struct tifm_adapter *fm);
132struct tifm_dev *tifm_alloc_device(struct tifm_adapter *fm); 134void tifm_free_adapter(struct tifm_adapter *fm);
135
136void tifm_free_device(struct device *dev);
137struct tifm_dev *tifm_alloc_device(struct tifm_adapter *fm, unsigned int id,
138 unsigned char type);
139
133int tifm_register_driver(struct tifm_driver *drv); 140int tifm_register_driver(struct tifm_driver *drv);
134void tifm_unregister_driver(struct tifm_driver *drv); 141void tifm_unregister_driver(struct tifm_driver *drv);
135void tifm_eject(struct tifm_dev *sock); 142void tifm_eject(struct tifm_dev *sock);
@@ -137,11 +144,11 @@ int tifm_map_sg(struct tifm_dev *sock, struct scatterlist *sg, int nents,
137 int direction); 144 int direction);
138void tifm_unmap_sg(struct tifm_dev *sock, struct scatterlist *sg, int nents, 145void tifm_unmap_sg(struct tifm_dev *sock, struct scatterlist *sg, int nents,
139 int direction); 146 int direction);
140 147void tifm_queue_work(struct work_struct *work);
141 148
142static inline void *tifm_get_drvdata(struct tifm_dev *dev) 149static inline void *tifm_get_drvdata(struct tifm_dev *dev)
143{ 150{
144 return dev_get_drvdata(&dev->dev); 151 return dev_get_drvdata(&dev->dev);
145} 152}
146 153
147static inline void tifm_set_drvdata(struct tifm_dev *dev, void *data) 154static inline void tifm_set_drvdata(struct tifm_dev *dev, void *data)
@@ -149,8 +156,4 @@ static inline void tifm_set_drvdata(struct tifm_dev *dev, void *data)
149 dev_set_drvdata(&dev->dev, data); 156 dev_set_drvdata(&dev->dev, data);
150} 157}
151 158
152struct tifm_device_id {
153 tifm_media_id media_id;
154};
155
156#endif 159#endif