diff options
Diffstat (limited to 'include/linux/tifm.h')
-rw-r--r-- | include/linux/tifm.h | 117 |
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): */ |
23 | enum { | 22 | enum { |
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): */ |
29 | enum { | 29 | enum { |
@@ -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 | ||
84 | typedef enum {FM_NULL = 0, FM_XD = 0x01, FM_MS = 0x02, FM_SD = 0x03} tifm_media_id; | 84 | struct tifm_device_id { |
85 | unsigned char type; | ||
86 | }; | ||
85 | 87 | ||
86 | struct tifm_driver; | 88 | struct tifm_driver; |
87 | struct tifm_dev { | 89 | struct 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 | ||
100 | struct tifm_driver { | 101 | struct 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 | ||
111 | struct tifm_adapter { | 112 | struct 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 | ||
127 | struct tifm_adapter *tifm_alloc_adapter(void); | 130 | struct tifm_adapter *tifm_alloc_adapter(unsigned int num_sockets, |
128 | void tifm_free_device(struct device *dev); | 131 | struct device *dev); |
129 | void tifm_free_adapter(struct tifm_adapter *fm); | 132 | int tifm_add_adapter(struct tifm_adapter *fm); |
130 | int tifm_add_adapter(struct tifm_adapter *fm, int (*mediathreadfn)(void *data)); | ||
131 | void tifm_remove_adapter(struct tifm_adapter *fm); | 133 | void tifm_remove_adapter(struct tifm_adapter *fm); |
132 | struct tifm_dev *tifm_alloc_device(struct tifm_adapter *fm); | 134 | void tifm_free_adapter(struct tifm_adapter *fm); |
135 | |||
136 | void tifm_free_device(struct device *dev); | ||
137 | struct tifm_dev *tifm_alloc_device(struct tifm_adapter *fm, unsigned int id, | ||
138 | unsigned char type); | ||
139 | |||
133 | int tifm_register_driver(struct tifm_driver *drv); | 140 | int tifm_register_driver(struct tifm_driver *drv); |
134 | void tifm_unregister_driver(struct tifm_driver *drv); | 141 | void tifm_unregister_driver(struct tifm_driver *drv); |
135 | void tifm_eject(struct tifm_dev *sock); | 142 | void 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); |
138 | void tifm_unmap_sg(struct tifm_dev *sock, struct scatterlist *sg, int nents, | 145 | void tifm_unmap_sg(struct tifm_dev *sock, struct scatterlist *sg, int nents, |
139 | int direction); | 146 | int direction); |
140 | 147 | void tifm_queue_work(struct work_struct *work); | |
141 | 148 | ||
142 | static inline void *tifm_get_drvdata(struct tifm_dev *dev) | 149 | static 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 | ||
147 | static inline void tifm_set_drvdata(struct tifm_dev *dev, void *data) | 154 | static 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 | ||
152 | struct tifm_device_id { | ||
153 | tifm_media_id media_id; | ||
154 | }; | ||
155 | |||
156 | #endif | 159 | #endif |