]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/linux/tifm.h
pktcdvd: Convert from class_device to device for block/pktcdvd
[mirror_ubuntu-bionic-kernel.git] / include / linux / tifm.h
CommitLineData
4020f2d7
AD
1/*
2 * tifm.h - TI FlashMedia driver
3 *
4 * Copyright (C) 2006 Alex Dubov <oakad@yahoo.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 */
11
12#ifndef _TIFM_H
13#define _TIFM_H
14
15#include <linux/spinlock.h>
16#include <linux/interrupt.h>
4020f2d7
AD
17#include <linux/delay.h>
18#include <linux/pci.h>
91f8d011 19#include <linux/workqueue.h>
4020f2d7
AD
20
21/* Host registers (relative to pci base address): */
22enum {
23 FM_SET_INTERRUPT_ENABLE = 0x008,
24 FM_CLEAR_INTERRUPT_ENABLE = 0x00c,
91f8d011
AD
25 FM_INTERRUPT_STATUS = 0x014
26};
4020f2d7
AD
27
28/* Socket registers (relative to socket base address): */
29enum {
30 SOCK_CONTROL = 0x004,
31 SOCK_PRESENT_STATE = 0x008,
32 SOCK_DMA_ADDRESS = 0x00c,
33 SOCK_DMA_CONTROL = 0x010,
34 SOCK_DMA_FIFO_INT_ENABLE_SET = 0x014,
35 SOCK_DMA_FIFO_INT_ENABLE_CLEAR = 0x018,
36 SOCK_DMA_FIFO_STATUS = 0x020,
37 SOCK_FIFO_CONTROL = 0x024,
38 SOCK_FIFO_PAGE_SIZE = 0x028,
39 SOCK_MMCSD_COMMAND = 0x104,
40 SOCK_MMCSD_ARG_LOW = 0x108,
41 SOCK_MMCSD_ARG_HIGH = 0x10c,
42 SOCK_MMCSD_CONFIG = 0x110,
43 SOCK_MMCSD_STATUS = 0x114,
44 SOCK_MMCSD_INT_ENABLE = 0x118,
45 SOCK_MMCSD_COMMAND_TO = 0x11c,
46 SOCK_MMCSD_DATA_TO = 0x120,
47 SOCK_MMCSD_DATA = 0x124,
48 SOCK_MMCSD_BLOCK_LEN = 0x128,
49 SOCK_MMCSD_NUM_BLOCKS = 0x12c,
50 SOCK_MMCSD_BUFFER_CONFIG = 0x130,
51 SOCK_MMCSD_SPI_CONFIG = 0x134,
52 SOCK_MMCSD_SDIO_MODE_CONFIG = 0x138,
53 SOCK_MMCSD_RESPONSE = 0x144,
54 SOCK_MMCSD_SDIO_SR = 0x164,
55 SOCK_MMCSD_SYSTEM_CONTROL = 0x168,
56 SOCK_MMCSD_SYSTEM_STATUS = 0x16c,
57 SOCK_MS_COMMAND = 0x184,
58 SOCK_MS_DATA = 0x188,
59 SOCK_MS_STATUS = 0x18c,
60 SOCK_MS_SYSTEM = 0x190,
91f8d011
AD
61 SOCK_FIFO_ACCESS = 0x200
62};
4020f2d7 63
4020f2d7
AD
64#define TIFM_CTRL_LED 0x00000040
65#define TIFM_CTRL_FAST_CLK 0x00000100
055b8224 66#define TIFM_CTRL_POWER_MASK 0x00000007
4020f2d7
AD
67
68#define TIFM_SOCK_STATE_OCCUPIED 0x00000008
69#define TIFM_SOCK_STATE_POWERED 0x00000080
70
91f8d011
AD
71#define TIFM_FIFO_ENABLE 0x00000001
72#define TIFM_FIFO_READY 0x00000001
4020f2d7 73#define TIFM_FIFO_INT_SETALL 0x0000ffff
91f8d011 74#define TIFM_FIFO_INTMASK 0x00000005
4020f2d7 75
91f8d011
AD
76#define TIFM_DMA_RESET 0x00000002
77#define TIFM_DMA_TX 0x00008000
78#define TIFM_DMA_EN 0x00000001
13cdf48e 79#define TIFM_DMA_TSIZE 0x0000007f
4020f2d7 80
e23f2b8a
AD
81#define TIFM_TYPE_XD 1
82#define TIFM_TYPE_MS 2
83#define TIFM_TYPE_SD 3
84
85struct tifm_device_id {
86 unsigned char type;
87};
4020f2d7
AD
88
89struct tifm_driver;
90struct tifm_dev {
91f8d011
AD
91 char __iomem *addr;
92 spinlock_t lock;
93 unsigned char type;
94 unsigned int socket_id;
4020f2d7 95
4552f0cb
AD
96 void (*card_event)(struct tifm_dev *sock);
97 void (*data_event)(struct tifm_dev *sock);
4020f2d7 98
91f8d011 99 struct device dev;
4020f2d7
AD
100};
101
102struct tifm_driver {
e23f2b8a 103 struct tifm_device_id *id_table;
91f8d011
AD
104 int (*probe)(struct tifm_dev *dev);
105 void (*remove)(struct tifm_dev *dev);
106 int (*suspend)(struct tifm_dev *dev,
107 pm_message_t state);
108 int (*resume)(struct tifm_dev *dev);
4020f2d7 109
91f8d011 110 struct device_driver driver;
4020f2d7
AD
111};
112
113struct tifm_adapter {
91f8d011
AD
114 char __iomem *addr;
115 spinlock_t lock;
116 unsigned int irq_status;
117 unsigned int socket_change_set;
118 unsigned int id;
119 unsigned int num_sockets;
120 struct completion *finish_me;
6113ed73 121
91f8d011
AD
122 struct work_struct media_switcher;
123 struct class_device cdev;
4020f2d7 124
91f8d011
AD
125 void (*eject)(struct tifm_adapter *fm,
126 struct tifm_dev *sock);
6113ed73 127
91f8d011 128 struct tifm_dev *sockets[0];
4020f2d7
AD
129};
130
6113ed73
AD
131struct tifm_adapter *tifm_alloc_adapter(unsigned int num_sockets,
132 struct device *dev);
3540af8f 133int tifm_add_adapter(struct tifm_adapter *fm);
4020f2d7 134void tifm_remove_adapter(struct tifm_adapter *fm);
6113ed73
AD
135void tifm_free_adapter(struct tifm_adapter *fm);
136
137void tifm_free_device(struct device *dev);
2428a8fe
AD
138struct tifm_dev *tifm_alloc_device(struct tifm_adapter *fm, unsigned int id,
139 unsigned char type);
140
4020f2d7
AD
141int tifm_register_driver(struct tifm_driver *drv);
142void tifm_unregister_driver(struct tifm_driver *drv);
143void tifm_eject(struct tifm_dev *sock);
144int tifm_map_sg(struct tifm_dev *sock, struct scatterlist *sg, int nents,
145 int direction);
146void tifm_unmap_sg(struct tifm_dev *sock, struct scatterlist *sg, int nents,
147 int direction);
3540af8f 148void tifm_queue_work(struct work_struct *work);
4020f2d7
AD
149
150static inline void *tifm_get_drvdata(struct tifm_dev *dev)
151{
91f8d011 152 return dev_get_drvdata(&dev->dev);
4020f2d7
AD
153}
154
155static inline void tifm_set_drvdata(struct tifm_dev *dev, void *data)
156{
157 dev_set_drvdata(&dev->dev, data);
158}
159
4020f2d7 160#endif