0001
0002
0003
0004
0005
0006
0007
0008 #ifndef _TIFM_H
0009 #define _TIFM_H
0010
0011 #include <linux/spinlock.h>
0012 #include <linux/interrupt.h>
0013 #include <linux/delay.h>
0014 #include <linux/pci.h>
0015 #include <linux/workqueue.h>
0016
0017
0018 enum {
0019 FM_SET_INTERRUPT_ENABLE = 0x008,
0020 FM_CLEAR_INTERRUPT_ENABLE = 0x00c,
0021 FM_INTERRUPT_STATUS = 0x014
0022 };
0023
0024
0025 enum {
0026 SOCK_CONTROL = 0x004,
0027 SOCK_PRESENT_STATE = 0x008,
0028 SOCK_DMA_ADDRESS = 0x00c,
0029 SOCK_DMA_CONTROL = 0x010,
0030 SOCK_DMA_FIFO_INT_ENABLE_SET = 0x014,
0031 SOCK_DMA_FIFO_INT_ENABLE_CLEAR = 0x018,
0032 SOCK_DMA_FIFO_STATUS = 0x020,
0033 SOCK_FIFO_CONTROL = 0x024,
0034 SOCK_FIFO_PAGE_SIZE = 0x028,
0035 SOCK_MMCSD_COMMAND = 0x104,
0036 SOCK_MMCSD_ARG_LOW = 0x108,
0037 SOCK_MMCSD_ARG_HIGH = 0x10c,
0038 SOCK_MMCSD_CONFIG = 0x110,
0039 SOCK_MMCSD_STATUS = 0x114,
0040 SOCK_MMCSD_INT_ENABLE = 0x118,
0041 SOCK_MMCSD_COMMAND_TO = 0x11c,
0042 SOCK_MMCSD_DATA_TO = 0x120,
0043 SOCK_MMCSD_DATA = 0x124,
0044 SOCK_MMCSD_BLOCK_LEN = 0x128,
0045 SOCK_MMCSD_NUM_BLOCKS = 0x12c,
0046 SOCK_MMCSD_BUFFER_CONFIG = 0x130,
0047 SOCK_MMCSD_SPI_CONFIG = 0x134,
0048 SOCK_MMCSD_SDIO_MODE_CONFIG = 0x138,
0049 SOCK_MMCSD_RESPONSE = 0x144,
0050 SOCK_MMCSD_SDIO_SR = 0x164,
0051 SOCK_MMCSD_SYSTEM_CONTROL = 0x168,
0052 SOCK_MMCSD_SYSTEM_STATUS = 0x16c,
0053 SOCK_MS_COMMAND = 0x184,
0054 SOCK_MS_DATA = 0x188,
0055 SOCK_MS_STATUS = 0x18c,
0056 SOCK_MS_SYSTEM = 0x190,
0057 SOCK_FIFO_ACCESS = 0x200
0058 };
0059
0060 #define TIFM_CTRL_LED 0x00000040
0061 #define TIFM_CTRL_FAST_CLK 0x00000100
0062 #define TIFM_CTRL_POWER_MASK 0x00000007
0063
0064 #define TIFM_SOCK_STATE_OCCUPIED 0x00000008
0065 #define TIFM_SOCK_STATE_POWERED 0x00000080
0066
0067 #define TIFM_FIFO_ENABLE 0x00000001
0068 #define TIFM_FIFO_READY 0x00000001
0069 #define TIFM_FIFO_MORE 0x00000008
0070 #define TIFM_FIFO_INT_SETALL 0x0000ffff
0071 #define TIFM_FIFO_INTMASK 0x00000005
0072
0073 #define TIFM_DMA_RESET 0x00000002
0074 #define TIFM_DMA_TX 0x00008000
0075 #define TIFM_DMA_EN 0x00000001
0076 #define TIFM_DMA_TSIZE 0x0000007f
0077
0078 #define TIFM_TYPE_XD 1
0079 #define TIFM_TYPE_MS 2
0080 #define TIFM_TYPE_SD 3
0081
0082 struct tifm_device_id {
0083 unsigned char type;
0084 };
0085
0086 struct tifm_driver;
0087 struct tifm_dev {
0088 char __iomem *addr;
0089 spinlock_t lock;
0090 unsigned char type;
0091 unsigned int socket_id;
0092
0093 void (*card_event)(struct tifm_dev *sock);
0094 void (*data_event)(struct tifm_dev *sock);
0095
0096 struct device dev;
0097 };
0098
0099 struct tifm_driver {
0100 struct tifm_device_id *id_table;
0101 int (*probe)(struct tifm_dev *dev);
0102 void (*remove)(struct tifm_dev *dev);
0103 int (*suspend)(struct tifm_dev *dev,
0104 pm_message_t state);
0105 int (*resume)(struct tifm_dev *dev);
0106
0107 struct device_driver driver;
0108 };
0109
0110 struct tifm_adapter {
0111 char __iomem *addr;
0112 spinlock_t lock;
0113 unsigned int irq_status;
0114 unsigned int socket_change_set;
0115 unsigned int id;
0116 unsigned int num_sockets;
0117 struct completion *finish_me;
0118
0119 struct work_struct media_switcher;
0120 struct device dev;
0121
0122 void (*eject)(struct tifm_adapter *fm,
0123 struct tifm_dev *sock);
0124 int (*has_ms_pif)(struct tifm_adapter *fm,
0125 struct tifm_dev *sock);
0126
0127 struct tifm_dev *sockets[];
0128 };
0129
0130 struct tifm_adapter *tifm_alloc_adapter(unsigned int num_sockets,
0131 struct device *dev);
0132 int tifm_add_adapter(struct tifm_adapter *fm);
0133 void tifm_remove_adapter(struct tifm_adapter *fm);
0134 void tifm_free_adapter(struct tifm_adapter *fm);
0135
0136 void tifm_free_device(struct device *dev);
0137 struct tifm_dev *tifm_alloc_device(struct tifm_adapter *fm, unsigned int id,
0138 unsigned char type);
0139
0140 int tifm_register_driver(struct tifm_driver *drv);
0141 void tifm_unregister_driver(struct tifm_driver *drv);
0142 void tifm_eject(struct tifm_dev *sock);
0143 int tifm_has_ms_pif(struct tifm_dev *sock);
0144 int tifm_map_sg(struct tifm_dev *sock, struct scatterlist *sg, int nents,
0145 int direction);
0146 void tifm_unmap_sg(struct tifm_dev *sock, struct scatterlist *sg, int nents,
0147 int direction);
0148 void tifm_queue_work(struct work_struct *work);
0149
0150 static inline void *tifm_get_drvdata(struct tifm_dev *dev)
0151 {
0152 return dev_get_drvdata(&dev->dev);
0153 }
0154
0155 static inline void tifm_set_drvdata(struct tifm_dev *dev, void *data)
0156 {
0157 dev_set_drvdata(&dev->dev, data);
0158 }
0159
0160 #endif