diff options
Diffstat (limited to 'drivers/block/mg_disk.c')
-rw-r--r-- | drivers/block/mg_disk.c | 537 |
1 files changed, 323 insertions, 214 deletions
diff --git a/drivers/block/mg_disk.c b/drivers/block/mg_disk.c index f3898353d0a8..60de5a01e71e 100644 --- a/drivers/block/mg_disk.c +++ b/drivers/block/mg_disk.c | |||
@@ -17,71 +17,220 @@ | |||
17 | #include <linux/fs.h> | 17 | #include <linux/fs.h> |
18 | #include <linux/blkdev.h> | 18 | #include <linux/blkdev.h> |
19 | #include <linux/hdreg.h> | 19 | #include <linux/hdreg.h> |
20 | #include <linux/libata.h> | 20 | #include <linux/ata.h> |
21 | #include <linux/interrupt.h> | 21 | #include <linux/interrupt.h> |
22 | #include <linux/delay.h> | 22 | #include <linux/delay.h> |
23 | #include <linux/platform_device.h> | 23 | #include <linux/platform_device.h> |
24 | #include <linux/gpio.h> | 24 | #include <linux/gpio.h> |
25 | #include <linux/mg_disk.h> | ||
26 | 25 | ||
27 | #define MG_RES_SEC (CONFIG_MG_DISK_RES << 1) | 26 | #define MG_RES_SEC (CONFIG_MG_DISK_RES << 1) |
28 | 27 | ||
28 | /* name for block device */ | ||
29 | #define MG_DISK_NAME "mgd" | ||
30 | /* name for platform device */ | ||
31 | #define MG_DEV_NAME "mg_disk" | ||
32 | |||
33 | #define MG_DISK_MAJ 0 | ||
34 | #define MG_DISK_MAX_PART 16 | ||
35 | #define MG_SECTOR_SIZE 512 | ||
36 | #define MG_MAX_SECTS 256 | ||
37 | |||
38 | /* Register offsets */ | ||
39 | #define MG_BUFF_OFFSET 0x8000 | ||
40 | #define MG_STORAGE_BUFFER_SIZE 0x200 | ||
41 | #define MG_REG_OFFSET 0xC000 | ||
42 | #define MG_REG_FEATURE (MG_REG_OFFSET + 2) /* write case */ | ||
43 | #define MG_REG_ERROR (MG_REG_OFFSET + 2) /* read case */ | ||
44 | #define MG_REG_SECT_CNT (MG_REG_OFFSET + 4) | ||
45 | #define MG_REG_SECT_NUM (MG_REG_OFFSET + 6) | ||
46 | #define MG_REG_CYL_LOW (MG_REG_OFFSET + 8) | ||
47 | #define MG_REG_CYL_HIGH (MG_REG_OFFSET + 0xA) | ||
48 | #define MG_REG_DRV_HEAD (MG_REG_OFFSET + 0xC) | ||
49 | #define MG_REG_COMMAND (MG_REG_OFFSET + 0xE) /* write case */ | ||
50 | #define MG_REG_STATUS (MG_REG_OFFSET + 0xE) /* read case */ | ||
51 | #define MG_REG_DRV_CTRL (MG_REG_OFFSET + 0x10) | ||
52 | #define MG_REG_BURST_CTRL (MG_REG_OFFSET + 0x12) | ||
53 | |||
54 | /* handy status */ | ||
55 | #define MG_STAT_READY (ATA_DRDY | ATA_DSC) | ||
56 | #define MG_READY_OK(s) (((s) & (MG_STAT_READY | (ATA_BUSY | ATA_DF | \ | ||
57 | ATA_ERR))) == MG_STAT_READY) | ||
58 | |||
59 | /* error code for others */ | ||
60 | #define MG_ERR_NONE 0 | ||
61 | #define MG_ERR_TIMEOUT 0x100 | ||
62 | #define MG_ERR_INIT_STAT 0x101 | ||
63 | #define MG_ERR_TRANSLATION 0x102 | ||
64 | #define MG_ERR_CTRL_RST 0x103 | ||
65 | #define MG_ERR_INV_STAT 0x104 | ||
66 | #define MG_ERR_RSTOUT 0x105 | ||
67 | |||
68 | #define MG_MAX_ERRORS 6 /* Max read/write errors */ | ||
69 | |||
70 | /* command */ | ||
71 | #define MG_CMD_RD 0x20 | ||
72 | #define MG_CMD_WR 0x30 | ||
73 | #define MG_CMD_SLEEP 0x99 | ||
74 | #define MG_CMD_WAKEUP 0xC3 | ||
75 | #define MG_CMD_ID 0xEC | ||
76 | #define MG_CMD_WR_CONF 0x3C | ||
77 | #define MG_CMD_RD_CONF 0x40 | ||
78 | |||
79 | /* operation mode */ | ||
80 | #define MG_OP_CASCADE (1 << 0) | ||
81 | #define MG_OP_CASCADE_SYNC_RD (1 << 1) | ||
82 | #define MG_OP_CASCADE_SYNC_WR (1 << 2) | ||
83 | #define MG_OP_INTERLEAVE (1 << 3) | ||
84 | |||
85 | /* synchronous */ | ||
86 | #define MG_BURST_LAT_4 (3 << 4) | ||
87 | #define MG_BURST_LAT_5 (4 << 4) | ||
88 | #define MG_BURST_LAT_6 (5 << 4) | ||
89 | #define MG_BURST_LAT_7 (6 << 4) | ||
90 | #define MG_BURST_LAT_8 (7 << 4) | ||
91 | #define MG_BURST_LEN_4 (1 << 1) | ||
92 | #define MG_BURST_LEN_8 (2 << 1) | ||
93 | #define MG_BURST_LEN_16 (3 << 1) | ||
94 | #define MG_BURST_LEN_32 (4 << 1) | ||
95 | #define MG_BURST_LEN_CONT (0 << 1) | ||
96 | |||
97 | /* timeout value (unit: ms) */ | ||
98 | #define MG_TMAX_CONF_TO_CMD 1 | ||
99 | #define MG_TMAX_WAIT_RD_DRQ 10 | ||
100 | #define MG_TMAX_WAIT_WR_DRQ 500 | ||
101 | #define MG_TMAX_RST_TO_BUSY 10 | ||
102 | #define MG_TMAX_HDRST_TO_RDY 500 | ||
103 | #define MG_TMAX_SWRST_TO_RDY 500 | ||
104 | #define MG_TMAX_RSTOUT 3000 | ||
105 | |||
106 | /* device attribution */ | ||
107 | /* use mflash as boot device */ | ||
108 | #define MG_BOOT_DEV (1 << 0) | ||
109 | /* use mflash as storage device */ | ||
110 | #define MG_STORAGE_DEV (1 << 1) | ||
111 | /* same as MG_STORAGE_DEV, but bootloader already done reset sequence */ | ||
112 | #define MG_STORAGE_DEV_SKIP_RST (1 << 2) | ||
113 | |||
114 | #define MG_DEV_MASK (MG_BOOT_DEV | MG_STORAGE_DEV | MG_STORAGE_DEV_SKIP_RST) | ||
115 | |||
116 | /* names of GPIO resource */ | ||
117 | #define MG_RST_PIN "mg_rst" | ||
118 | /* except MG_BOOT_DEV, reset-out pin should be assigned */ | ||
119 | #define MG_RSTOUT_PIN "mg_rstout" | ||
120 | |||
121 | /* private driver data */ | ||
122 | struct mg_drv_data { | ||
123 | /* disk resource */ | ||
124 | u32 use_polling; | ||
125 | |||
126 | /* device attribution */ | ||
127 | u32 dev_attr; | ||
128 | |||
129 | /* internally used */ | ||
130 | struct mg_host *host; | ||
131 | }; | ||
132 | |||
133 | /* main structure for mflash driver */ | ||
134 | struct mg_host { | ||
135 | struct device *dev; | ||
136 | |||
137 | struct request_queue *breq; | ||
138 | struct request *req; | ||
139 | spinlock_t lock; | ||
140 | struct gendisk *gd; | ||
141 | |||
142 | struct timer_list timer; | ||
143 | void (*mg_do_intr) (struct mg_host *); | ||
144 | |||
145 | u16 id[ATA_ID_WORDS]; | ||
146 | |||
147 | u16 cyls; | ||
148 | u16 heads; | ||
149 | u16 sectors; | ||
150 | u32 n_sectors; | ||
151 | u32 nres_sectors; | ||
152 | |||
153 | void __iomem *dev_base; | ||
154 | unsigned int irq; | ||
155 | unsigned int rst; | ||
156 | unsigned int rstout; | ||
157 | |||
158 | u32 major; | ||
159 | u32 error; | ||
160 | }; | ||
161 | |||
162 | /* | ||
163 | * Debugging macro and defines | ||
164 | */ | ||
165 | #undef DO_MG_DEBUG | ||
166 | #ifdef DO_MG_DEBUG | ||
167 | # define MG_DBG(fmt, args...) \ | ||
168 | printk(KERN_DEBUG "%s:%d "fmt, __func__, __LINE__, ##args) | ||
169 | #else /* CONFIG_MG_DEBUG */ | ||
170 | # define MG_DBG(fmt, args...) do { } while (0) | ||
171 | #endif /* CONFIG_MG_DEBUG */ | ||
172 | |||
29 | static void mg_request(struct request_queue *); | 173 | static void mg_request(struct request_queue *); |
30 | 174 | ||
175 | static bool mg_end_request(struct mg_host *host, int err, unsigned int nr_bytes) | ||
176 | { | ||
177 | if (__blk_end_request(host->req, err, nr_bytes)) | ||
178 | return true; | ||
179 | |||
180 | host->req = NULL; | ||
181 | return false; | ||
182 | } | ||
183 | |||
184 | static bool mg_end_request_cur(struct mg_host *host, int err) | ||
185 | { | ||
186 | return mg_end_request(host, err, blk_rq_cur_bytes(host->req)); | ||
187 | } | ||
188 | |||
31 | static void mg_dump_status(const char *msg, unsigned int stat, | 189 | static void mg_dump_status(const char *msg, unsigned int stat, |
32 | struct mg_host *host) | 190 | struct mg_host *host) |
33 | { | 191 | { |
34 | char *name = MG_DISK_NAME; | 192 | char *name = MG_DISK_NAME; |
35 | struct request *req; | ||
36 | 193 | ||
37 | if (host->breq) { | 194 | if (host->req) |
38 | req = elv_next_request(host->breq); | 195 | name = host->req->rq_disk->disk_name; |
39 | if (req) | ||
40 | name = req->rq_disk->disk_name; | ||
41 | } | ||
42 | 196 | ||
43 | printk(KERN_ERR "%s: %s: status=0x%02x { ", name, msg, stat & 0xff); | 197 | printk(KERN_ERR "%s: %s: status=0x%02x { ", name, msg, stat & 0xff); |
44 | if (stat & MG_REG_STATUS_BIT_BUSY) | 198 | if (stat & ATA_BUSY) |
45 | printk("Busy "); | 199 | printk("Busy "); |
46 | if (stat & MG_REG_STATUS_BIT_READY) | 200 | if (stat & ATA_DRDY) |
47 | printk("DriveReady "); | 201 | printk("DriveReady "); |
48 | if (stat & MG_REG_STATUS_BIT_WRITE_FAULT) | 202 | if (stat & ATA_DF) |
49 | printk("WriteFault "); | 203 | printk("WriteFault "); |
50 | if (stat & MG_REG_STATUS_BIT_SEEK_DONE) | 204 | if (stat & ATA_DSC) |
51 | printk("SeekComplete "); | 205 | printk("SeekComplete "); |
52 | if (stat & MG_REG_STATUS_BIT_DATA_REQ) | 206 | if (stat & ATA_DRQ) |
53 | printk("DataRequest "); | 207 | printk("DataRequest "); |
54 | if (stat & MG_REG_STATUS_BIT_CORRECTED_ERROR) | 208 | if (stat & ATA_CORR) |
55 | printk("CorrectedError "); | 209 | printk("CorrectedError "); |
56 | if (stat & MG_REG_STATUS_BIT_ERROR) | 210 | if (stat & ATA_ERR) |
57 | printk("Error "); | 211 | printk("Error "); |
58 | printk("}\n"); | 212 | printk("}\n"); |
59 | if ((stat & MG_REG_STATUS_BIT_ERROR) == 0) { | 213 | if ((stat & ATA_ERR) == 0) { |
60 | host->error = 0; | 214 | host->error = 0; |
61 | } else { | 215 | } else { |
62 | host->error = inb((unsigned long)host->dev_base + MG_REG_ERROR); | 216 | host->error = inb((unsigned long)host->dev_base + MG_REG_ERROR); |
63 | printk(KERN_ERR "%s: %s: error=0x%02x { ", name, msg, | 217 | printk(KERN_ERR "%s: %s: error=0x%02x { ", name, msg, |
64 | host->error & 0xff); | 218 | host->error & 0xff); |
65 | if (host->error & MG_REG_ERR_BBK) | 219 | if (host->error & ATA_BBK) |
66 | printk("BadSector "); | 220 | printk("BadSector "); |
67 | if (host->error & MG_REG_ERR_UNC) | 221 | if (host->error & ATA_UNC) |
68 | printk("UncorrectableError "); | 222 | printk("UncorrectableError "); |
69 | if (host->error & MG_REG_ERR_IDNF) | 223 | if (host->error & ATA_IDNF) |
70 | printk("SectorIdNotFound "); | 224 | printk("SectorIdNotFound "); |
71 | if (host->error & MG_REG_ERR_ABRT) | 225 | if (host->error & ATA_ABORTED) |
72 | printk("DriveStatusError "); | 226 | printk("DriveStatusError "); |
73 | if (host->error & MG_REG_ERR_AMNF) | 227 | if (host->error & ATA_AMNF) |
74 | printk("AddrMarkNotFound "); | 228 | printk("AddrMarkNotFound "); |
75 | printk("}"); | 229 | printk("}"); |
76 | if (host->error & | 230 | if (host->error & (ATA_BBK | ATA_UNC | ATA_IDNF | ATA_AMNF)) { |
77 | (MG_REG_ERR_BBK | MG_REG_ERR_UNC | | 231 | if (host->req) |
78 | MG_REG_ERR_IDNF | MG_REG_ERR_AMNF)) { | 232 | printk(", sector=%u", |
79 | if (host->breq) { | 233 | (unsigned int)blk_rq_pos(host->req)); |
80 | req = elv_next_request(host->breq); | ||
81 | if (req) | ||
82 | printk(", sector=%u", (u32)req->sector); | ||
83 | } | ||
84 | |||
85 | } | 234 | } |
86 | printk("\n"); | 235 | printk("\n"); |
87 | } | 236 | } |
@@ -100,12 +249,12 @@ static unsigned int mg_wait(struct mg_host *host, u32 expect, u32 msec) | |||
100 | 249 | ||
101 | do { | 250 | do { |
102 | cur_jiffies = jiffies; | 251 | cur_jiffies = jiffies; |
103 | if (status & MG_REG_STATUS_BIT_BUSY) { | 252 | if (status & ATA_BUSY) { |
104 | if (expect == MG_REG_STATUS_BIT_BUSY) | 253 | if (expect == ATA_BUSY) |
105 | break; | 254 | break; |
106 | } else { | 255 | } else { |
107 | /* Check the error condition! */ | 256 | /* Check the error condition! */ |
108 | if (status & MG_REG_STATUS_BIT_ERROR) { | 257 | if (status & ATA_ERR) { |
109 | mg_dump_status("mg_wait", status, host); | 258 | mg_dump_status("mg_wait", status, host); |
110 | break; | 259 | break; |
111 | } | 260 | } |
@@ -114,8 +263,8 @@ static unsigned int mg_wait(struct mg_host *host, u32 expect, u32 msec) | |||
114 | if (MG_READY_OK(status)) | 263 | if (MG_READY_OK(status)) |
115 | break; | 264 | break; |
116 | 265 | ||
117 | if (expect == MG_REG_STATUS_BIT_DATA_REQ) | 266 | if (expect == ATA_DRQ) |
118 | if (status & MG_REG_STATUS_BIT_DATA_REQ) | 267 | if (status & ATA_DRQ) |
119 | break; | 268 | break; |
120 | } | 269 | } |
121 | if (!msec) { | 270 | if (!msec) { |
@@ -173,6 +322,42 @@ static irqreturn_t mg_irq(int irq, void *dev_id) | |||
173 | return IRQ_HANDLED; | 322 | return IRQ_HANDLED; |
174 | } | 323 | } |
175 | 324 | ||
325 | /* local copy of ata_id_string() */ | ||
326 | static void mg_id_string(const u16 *id, unsigned char *s, | ||
327 | unsigned int ofs, unsigned int len) | ||
328 | { | ||
329 | unsigned int c; | ||
330 | |||
331 | BUG_ON(len & 1); | ||
332 | |||
333 | while (len > 0) { | ||
334 | c = id[ofs] >> 8; | ||
335 | *s = c; | ||
336 | s++; | ||
337 | |||
338 | c = id[ofs] & 0xff; | ||
339 | *s = c; | ||
340 | s++; | ||
341 | |||
342 | ofs++; | ||
343 | len -= 2; | ||
344 | } | ||
345 | } | ||
346 | |||
347 | /* local copy of ata_id_c_string() */ | ||
348 | static void mg_id_c_string(const u16 *id, unsigned char *s, | ||
349 | unsigned int ofs, unsigned int len) | ||
350 | { | ||
351 | unsigned char *p; | ||
352 | |||
353 | mg_id_string(id, s, ofs, len - 1); | ||
354 | |||
355 | p = s + strnlen(s, len - 1); | ||
356 | while (p > s && p[-1] == ' ') | ||
357 | p--; | ||
358 | *p = '\0'; | ||
359 | } | ||
360 | |||
176 | static int mg_get_disk_id(struct mg_host *host) | 361 | static int mg_get_disk_id(struct mg_host *host) |
177 | { | 362 | { |
178 | u32 i; | 363 | u32 i; |
@@ -184,12 +369,10 @@ static int mg_get_disk_id(struct mg_host *host) | |||
184 | char serial[ATA_ID_SERNO_LEN + 1]; | 369 | char serial[ATA_ID_SERNO_LEN + 1]; |
185 | 370 | ||
186 | if (!prv_data->use_polling) | 371 | if (!prv_data->use_polling) |
187 | outb(MG_REG_CTRL_INTR_DISABLE, | 372 | outb(ATA_NIEN, (unsigned long)host->dev_base + MG_REG_DRV_CTRL); |
188 | (unsigned long)host->dev_base + | ||
189 | MG_REG_DRV_CTRL); | ||
190 | 373 | ||
191 | outb(MG_CMD_ID, (unsigned long)host->dev_base + MG_REG_COMMAND); | 374 | outb(MG_CMD_ID, (unsigned long)host->dev_base + MG_REG_COMMAND); |
192 | err = mg_wait(host, MG_REG_STATUS_BIT_DATA_REQ, MG_TMAX_WAIT_RD_DRQ); | 375 | err = mg_wait(host, ATA_DRQ, MG_TMAX_WAIT_RD_DRQ); |
193 | if (err) | 376 | if (err) |
194 | return err; | 377 | return err; |
195 | 378 | ||
@@ -219,9 +402,9 @@ static int mg_get_disk_id(struct mg_host *host) | |||
219 | host->n_sectors -= host->nres_sectors; | 402 | host->n_sectors -= host->nres_sectors; |
220 | } | 403 | } |
221 | 404 | ||
222 | ata_id_c_string(id, fwrev, ATA_ID_FW_REV, sizeof(fwrev)); | 405 | mg_id_c_string(id, fwrev, ATA_ID_FW_REV, sizeof(fwrev)); |
223 | ata_id_c_string(id, model, ATA_ID_PROD, sizeof(model)); | 406 | mg_id_c_string(id, model, ATA_ID_PROD, sizeof(model)); |
224 | ata_id_c_string(id, serial, ATA_ID_SERNO, sizeof(serial)); | 407 | mg_id_c_string(id, serial, ATA_ID_SERNO, sizeof(serial)); |
225 | printk(KERN_INFO "mg_disk: model: %s\n", model); | 408 | printk(KERN_INFO "mg_disk: model: %s\n", model); |
226 | printk(KERN_INFO "mg_disk: firm: %.8s\n", fwrev); | 409 | printk(KERN_INFO "mg_disk: firm: %.8s\n", fwrev); |
227 | printk(KERN_INFO "mg_disk: serial: %s\n", serial); | 410 | printk(KERN_INFO "mg_disk: serial: %s\n", serial); |
@@ -229,8 +412,7 @@ static int mg_get_disk_id(struct mg_host *host) | |||
229 | host->n_sectors, host->nres_sectors); | 412 | host->n_sectors, host->nres_sectors); |
230 | 413 | ||
231 | if (!prv_data->use_polling) | 414 | if (!prv_data->use_polling) |
232 | outb(MG_REG_CTRL_INTR_ENABLE, (unsigned long)host->dev_base + | 415 | outb(0, (unsigned long)host->dev_base + MG_REG_DRV_CTRL); |
233 | MG_REG_DRV_CTRL); | ||
234 | 416 | ||
235 | return err; | 417 | return err; |
236 | } | 418 | } |
@@ -244,7 +426,7 @@ static int mg_disk_init(struct mg_host *host) | |||
244 | 426 | ||
245 | /* hdd rst low */ | 427 | /* hdd rst low */ |
246 | gpio_set_value(host->rst, 0); | 428 | gpio_set_value(host->rst, 0); |
247 | err = mg_wait(host, MG_REG_STATUS_BIT_BUSY, MG_TMAX_RST_TO_BUSY); | 429 | err = mg_wait(host, ATA_BUSY, MG_TMAX_RST_TO_BUSY); |
248 | if (err) | 430 | if (err) |
249 | return err; | 431 | return err; |
250 | 432 | ||
@@ -255,17 +437,14 @@ static int mg_disk_init(struct mg_host *host) | |||
255 | return err; | 437 | return err; |
256 | 438 | ||
257 | /* soft reset on */ | 439 | /* soft reset on */ |
258 | outb(MG_REG_CTRL_RESET | | 440 | outb(ATA_SRST | (prv_data->use_polling ? ATA_NIEN : 0), |
259 | (prv_data->use_polling ? MG_REG_CTRL_INTR_DISABLE : | ||
260 | MG_REG_CTRL_INTR_ENABLE), | ||
261 | (unsigned long)host->dev_base + MG_REG_DRV_CTRL); | 441 | (unsigned long)host->dev_base + MG_REG_DRV_CTRL); |
262 | err = mg_wait(host, MG_REG_STATUS_BIT_BUSY, MG_TMAX_RST_TO_BUSY); | 442 | err = mg_wait(host, ATA_BUSY, MG_TMAX_RST_TO_BUSY); |
263 | if (err) | 443 | if (err) |
264 | return err; | 444 | return err; |
265 | 445 | ||
266 | /* soft reset off */ | 446 | /* soft reset off */ |
267 | outb(prv_data->use_polling ? MG_REG_CTRL_INTR_DISABLE : | 447 | outb(prv_data->use_polling ? ATA_NIEN : 0, |
268 | MG_REG_CTRL_INTR_ENABLE, | ||
269 | (unsigned long)host->dev_base + MG_REG_DRV_CTRL); | 448 | (unsigned long)host->dev_base + MG_REG_DRV_CTRL); |
270 | err = mg_wait(host, MG_STAT_READY, MG_TMAX_SWRST_TO_RDY); | 449 | err = mg_wait(host, MG_STAT_READY, MG_TMAX_SWRST_TO_RDY); |
271 | if (err) | 450 | if (err) |
@@ -281,11 +460,10 @@ static int mg_disk_init(struct mg_host *host) | |||
281 | 460 | ||
282 | static void mg_bad_rw_intr(struct mg_host *host) | 461 | static void mg_bad_rw_intr(struct mg_host *host) |
283 | { | 462 | { |
284 | struct request *req = elv_next_request(host->breq); | 463 | if (host->req) |
285 | if (req != NULL) | 464 | if (++host->req->errors >= MG_MAX_ERRORS || |
286 | if (++req->errors >= MG_MAX_ERRORS || | 465 | host->error == MG_ERR_TIMEOUT) |
287 | host->error == MG_ERR_TIMEOUT) | 466 | mg_end_request_cur(host, -EIO); |
288 | end_request(req, 0); | ||
289 | } | 467 | } |
290 | 468 | ||
291 | static unsigned int mg_out(struct mg_host *host, | 469 | static unsigned int mg_out(struct mg_host *host, |
@@ -311,7 +489,7 @@ static unsigned int mg_out(struct mg_host *host, | |||
311 | MG_REG_CYL_LOW); | 489 | MG_REG_CYL_LOW); |
312 | outb((u8)(sect_num >> 16), (unsigned long)host->dev_base + | 490 | outb((u8)(sect_num >> 16), (unsigned long)host->dev_base + |
313 | MG_REG_CYL_HIGH); | 491 | MG_REG_CYL_HIGH); |
314 | outb((u8)((sect_num >> 24) | MG_REG_HEAD_LBA_MODE), | 492 | outb((u8)((sect_num >> 24) | ATA_LBA | ATA_DEVICE_OBS), |
315 | (unsigned long)host->dev_base + MG_REG_DRV_HEAD); | 493 | (unsigned long)host->dev_base + MG_REG_DRV_HEAD); |
316 | outb(cmd, (unsigned long)host->dev_base + MG_REG_COMMAND); | 494 | outb(cmd, (unsigned long)host->dev_base + MG_REG_COMMAND); |
317 | return MG_ERR_NONE; | 495 | return MG_ERR_NONE; |
@@ -319,105 +497,77 @@ static unsigned int mg_out(struct mg_host *host, | |||
319 | 497 | ||
320 | static void mg_read(struct request *req) | 498 | static void mg_read(struct request *req) |
321 | { | 499 | { |
322 | u32 remains, j; | 500 | u32 j; |
323 | struct mg_host *host = req->rq_disk->private_data; | 501 | struct mg_host *host = req->rq_disk->private_data; |
324 | 502 | ||
325 | remains = req->nr_sectors; | 503 | if (mg_out(host, blk_rq_pos(req), blk_rq_sectors(req), |
326 | 504 | MG_CMD_RD, NULL) != MG_ERR_NONE) | |
327 | if (mg_out(host, req->sector, req->nr_sectors, MG_CMD_RD, NULL) != | ||
328 | MG_ERR_NONE) | ||
329 | mg_bad_rw_intr(host); | 505 | mg_bad_rw_intr(host); |
330 | 506 | ||
331 | MG_DBG("requested %d sects (from %ld), buffer=0x%p\n", | 507 | MG_DBG("requested %d sects (from %ld), buffer=0x%p\n", |
332 | remains, req->sector, req->buffer); | 508 | blk_rq_sectors(req), blk_rq_pos(req), req->buffer); |
509 | |||
510 | do { | ||
511 | u16 *buff = (u16 *)req->buffer; | ||
333 | 512 | ||
334 | while (remains) { | 513 | if (mg_wait(host, ATA_DRQ, |
335 | if (mg_wait(host, MG_REG_STATUS_BIT_DATA_REQ, | 514 | MG_TMAX_WAIT_RD_DRQ) != MG_ERR_NONE) { |
336 | MG_TMAX_WAIT_RD_DRQ) != MG_ERR_NONE) { | ||
337 | mg_bad_rw_intr(host); | 515 | mg_bad_rw_intr(host); |
338 | return; | 516 | return; |
339 | } | 517 | } |
340 | for (j = 0; j < MG_SECTOR_SIZE >> 1; j++) { | 518 | for (j = 0; j < MG_SECTOR_SIZE >> 1; j++) |
341 | *(u16 *)req->buffer = | 519 | *buff++ = inw((unsigned long)host->dev_base + |
342 | inw((unsigned long)host->dev_base + | 520 | MG_BUFF_OFFSET + (j << 1)); |
343 | MG_BUFF_OFFSET + (j << 1)); | ||
344 | req->buffer += 2; | ||
345 | } | ||
346 | |||
347 | req->sector++; | ||
348 | req->errors = 0; | ||
349 | remains = --req->nr_sectors; | ||
350 | --req->current_nr_sectors; | ||
351 | |||
352 | if (req->current_nr_sectors <= 0) { | ||
353 | MG_DBG("remain : %d sects\n", remains); | ||
354 | end_request(req, 1); | ||
355 | if (remains > 0) | ||
356 | req = elv_next_request(host->breq); | ||
357 | } | ||
358 | 521 | ||
359 | outb(MG_CMD_RD_CONF, (unsigned long)host->dev_base + | 522 | outb(MG_CMD_RD_CONF, (unsigned long)host->dev_base + |
360 | MG_REG_COMMAND); | 523 | MG_REG_COMMAND); |
361 | } | 524 | } while (mg_end_request(host, 0, MG_SECTOR_SIZE)); |
362 | } | 525 | } |
363 | 526 | ||
364 | static void mg_write(struct request *req) | 527 | static void mg_write(struct request *req) |
365 | { | 528 | { |
366 | u32 remains, j; | 529 | u32 j; |
367 | struct mg_host *host = req->rq_disk->private_data; | 530 | struct mg_host *host = req->rq_disk->private_data; |
368 | 531 | ||
369 | remains = req->nr_sectors; | 532 | if (mg_out(host, blk_rq_pos(req), blk_rq_sectors(req), |
370 | 533 | MG_CMD_WR, NULL) != MG_ERR_NONE) { | |
371 | if (mg_out(host, req->sector, req->nr_sectors, MG_CMD_WR, NULL) != | ||
372 | MG_ERR_NONE) { | ||
373 | mg_bad_rw_intr(host); | 534 | mg_bad_rw_intr(host); |
374 | return; | 535 | return; |
375 | } | 536 | } |
376 | 537 | ||
377 | |||
378 | MG_DBG("requested %d sects (from %ld), buffer=0x%p\n", | 538 | MG_DBG("requested %d sects (from %ld), buffer=0x%p\n", |
379 | remains, req->sector, req->buffer); | 539 | blk_rq_sectors(req), blk_rq_pos(req), req->buffer); |
380 | while (remains) { | 540 | |
381 | if (mg_wait(host, MG_REG_STATUS_BIT_DATA_REQ, | 541 | do { |
382 | MG_TMAX_WAIT_WR_DRQ) != MG_ERR_NONE) { | 542 | u16 *buff = (u16 *)req->buffer; |
543 | |||
544 | if (mg_wait(host, ATA_DRQ, MG_TMAX_WAIT_WR_DRQ) != MG_ERR_NONE) { | ||
383 | mg_bad_rw_intr(host); | 545 | mg_bad_rw_intr(host); |
384 | return; | 546 | return; |
385 | } | 547 | } |
386 | for (j = 0; j < MG_SECTOR_SIZE >> 1; j++) { | 548 | for (j = 0; j < MG_SECTOR_SIZE >> 1; j++) |
387 | outw(*(u16 *)req->buffer, | 549 | outw(*buff++, (unsigned long)host->dev_base + |
388 | (unsigned long)host->dev_base + | 550 | MG_BUFF_OFFSET + (j << 1)); |
389 | MG_BUFF_OFFSET + (j << 1)); | ||
390 | req->buffer += 2; | ||
391 | } | ||
392 | req->sector++; | ||
393 | remains = --req->nr_sectors; | ||
394 | --req->current_nr_sectors; | ||
395 | |||
396 | if (req->current_nr_sectors <= 0) { | ||
397 | MG_DBG("remain : %d sects\n", remains); | ||
398 | end_request(req, 1); | ||
399 | if (remains > 0) | ||
400 | req = elv_next_request(host->breq); | ||
401 | } | ||
402 | 551 | ||
403 | outb(MG_CMD_WR_CONF, (unsigned long)host->dev_base + | 552 | outb(MG_CMD_WR_CONF, (unsigned long)host->dev_base + |
404 | MG_REG_COMMAND); | 553 | MG_REG_COMMAND); |
405 | } | 554 | } while (mg_end_request(host, 0, MG_SECTOR_SIZE)); |
406 | } | 555 | } |
407 | 556 | ||
408 | static void mg_read_intr(struct mg_host *host) | 557 | static void mg_read_intr(struct mg_host *host) |
409 | { | 558 | { |
559 | struct request *req = host->req; | ||
410 | u32 i; | 560 | u32 i; |
411 | struct request *req; | 561 | u16 *buff; |
412 | 562 | ||
413 | /* check status */ | 563 | /* check status */ |
414 | do { | 564 | do { |
415 | i = inb((unsigned long)host->dev_base + MG_REG_STATUS); | 565 | i = inb((unsigned long)host->dev_base + MG_REG_STATUS); |
416 | if (i & MG_REG_STATUS_BIT_BUSY) | 566 | if (i & ATA_BUSY) |
417 | break; | 567 | break; |
418 | if (!MG_READY_OK(i)) | 568 | if (!MG_READY_OK(i)) |
419 | break; | 569 | break; |
420 | if (i & MG_REG_STATUS_BIT_DATA_REQ) | 570 | if (i & ATA_DRQ) |
421 | goto ok_to_read; | 571 | goto ok_to_read; |
422 | } while (0); | 572 | } while (0); |
423 | mg_dump_status("mg_read_intr", i, host); | 573 | mg_dump_status("mg_read_intr", i, host); |
@@ -427,60 +577,42 @@ static void mg_read_intr(struct mg_host *host) | |||
427 | 577 | ||
428 | ok_to_read: | 578 | ok_to_read: |
429 | /* get current segment of request */ | 579 | /* get current segment of request */ |
430 | req = elv_next_request(host->breq); | 580 | buff = (u16 *)req->buffer; |
431 | 581 | ||
432 | /* read 1 sector */ | 582 | /* read 1 sector */ |
433 | for (i = 0; i < MG_SECTOR_SIZE >> 1; i++) { | 583 | for (i = 0; i < MG_SECTOR_SIZE >> 1; i++) |
434 | *(u16 *)req->buffer = | 584 | *buff++ = inw((unsigned long)host->dev_base + MG_BUFF_OFFSET + |
435 | inw((unsigned long)host->dev_base + MG_BUFF_OFFSET + | 585 | (i << 1)); |
436 | (i << 1)); | ||
437 | req->buffer += 2; | ||
438 | } | ||
439 | 586 | ||
440 | /* manipulate request */ | ||
441 | MG_DBG("sector %ld, remaining=%ld, buffer=0x%p\n", | 587 | MG_DBG("sector %ld, remaining=%ld, buffer=0x%p\n", |
442 | req->sector, req->nr_sectors - 1, req->buffer); | 588 | blk_rq_pos(req), blk_rq_sectors(req) - 1, req->buffer); |
443 | |||
444 | req->sector++; | ||
445 | req->errors = 0; | ||
446 | i = --req->nr_sectors; | ||
447 | --req->current_nr_sectors; | ||
448 | |||
449 | /* let know if current segment done */ | ||
450 | if (req->current_nr_sectors <= 0) | ||
451 | end_request(req, 1); | ||
452 | |||
453 | /* set handler if read remains */ | ||
454 | if (i > 0) { | ||
455 | host->mg_do_intr = mg_read_intr; | ||
456 | mod_timer(&host->timer, jiffies + 3 * HZ); | ||
457 | } | ||
458 | 589 | ||
459 | /* send read confirm */ | 590 | /* send read confirm */ |
460 | outb(MG_CMD_RD_CONF, (unsigned long)host->dev_base + MG_REG_COMMAND); | 591 | outb(MG_CMD_RD_CONF, (unsigned long)host->dev_base + MG_REG_COMMAND); |
461 | 592 | ||
462 | /* goto next request */ | 593 | if (mg_end_request(host, 0, MG_SECTOR_SIZE)) { |
463 | if (!i) | 594 | /* set handler if read remains */ |
595 | host->mg_do_intr = mg_read_intr; | ||
596 | mod_timer(&host->timer, jiffies + 3 * HZ); | ||
597 | } else /* goto next request */ | ||
464 | mg_request(host->breq); | 598 | mg_request(host->breq); |
465 | } | 599 | } |
466 | 600 | ||
467 | static void mg_write_intr(struct mg_host *host) | 601 | static void mg_write_intr(struct mg_host *host) |
468 | { | 602 | { |
603 | struct request *req = host->req; | ||
469 | u32 i, j; | 604 | u32 i, j; |
470 | u16 *buff; | 605 | u16 *buff; |
471 | struct request *req; | 606 | bool rem; |
472 | |||
473 | /* get current segment of request */ | ||
474 | req = elv_next_request(host->breq); | ||
475 | 607 | ||
476 | /* check status */ | 608 | /* check status */ |
477 | do { | 609 | do { |
478 | i = inb((unsigned long)host->dev_base + MG_REG_STATUS); | 610 | i = inb((unsigned long)host->dev_base + MG_REG_STATUS); |
479 | if (i & MG_REG_STATUS_BIT_BUSY) | 611 | if (i & ATA_BUSY) |
480 | break; | 612 | break; |
481 | if (!MG_READY_OK(i)) | 613 | if (!MG_READY_OK(i)) |
482 | break; | 614 | break; |
483 | if ((req->nr_sectors <= 1) || (i & MG_REG_STATUS_BIT_DATA_REQ)) | 615 | if ((blk_rq_sectors(req) <= 1) || (i & ATA_DRQ)) |
484 | goto ok_to_write; | 616 | goto ok_to_write; |
485 | } while (0); | 617 | } while (0); |
486 | mg_dump_status("mg_write_intr", i, host); | 618 | mg_dump_status("mg_write_intr", i, host); |
@@ -489,18 +621,8 @@ static void mg_write_intr(struct mg_host *host) | |||
489 | return; | 621 | return; |
490 | 622 | ||
491 | ok_to_write: | 623 | ok_to_write: |
492 | /* manipulate request */ | 624 | if ((rem = mg_end_request(host, 0, MG_SECTOR_SIZE))) { |
493 | req->sector++; | 625 | /* write 1 sector and set handler if remains */ |
494 | i = --req->nr_sectors; | ||
495 | --req->current_nr_sectors; | ||
496 | req->buffer += MG_SECTOR_SIZE; | ||
497 | |||
498 | /* let know if current segment or all done */ | ||
499 | if (!i || (req->bio && req->current_nr_sectors <= 0)) | ||
500 | end_request(req, 1); | ||
501 | |||
502 | /* write 1 sector and set handler if remains */ | ||
503 | if (i > 0) { | ||
504 | buff = (u16 *)req->buffer; | 626 | buff = (u16 *)req->buffer; |
505 | for (j = 0; j < MG_STORAGE_BUFFER_SIZE >> 1; j++) { | 627 | for (j = 0; j < MG_STORAGE_BUFFER_SIZE >> 1; j++) { |
506 | outw(*buff, (unsigned long)host->dev_base + | 628 | outw(*buff, (unsigned long)host->dev_base + |
@@ -508,7 +630,7 @@ ok_to_write: | |||
508 | buff++; | 630 | buff++; |
509 | } | 631 | } |
510 | MG_DBG("sector %ld, remaining=%ld, buffer=0x%p\n", | 632 | MG_DBG("sector %ld, remaining=%ld, buffer=0x%p\n", |
511 | req->sector, req->nr_sectors, req->buffer); | 633 | blk_rq_pos(req), blk_rq_sectors(req), req->buffer); |
512 | host->mg_do_intr = mg_write_intr; | 634 | host->mg_do_intr = mg_write_intr; |
513 | mod_timer(&host->timer, jiffies + 3 * HZ); | 635 | mod_timer(&host->timer, jiffies + 3 * HZ); |
514 | } | 636 | } |
@@ -516,7 +638,7 @@ ok_to_write: | |||
516 | /* send write confirm */ | 638 | /* send write confirm */ |
517 | outb(MG_CMD_WR_CONF, (unsigned long)host->dev_base + MG_REG_COMMAND); | 639 | outb(MG_CMD_WR_CONF, (unsigned long)host->dev_base + MG_REG_COMMAND); |
518 | 640 | ||
519 | if (!i) | 641 | if (!rem) |
520 | mg_request(host->breq); | 642 | mg_request(host->breq); |
521 | } | 643 | } |
522 | 644 | ||
@@ -524,49 +646,45 @@ void mg_times_out(unsigned long data) | |||
524 | { | 646 | { |
525 | struct mg_host *host = (struct mg_host *)data; | 647 | struct mg_host *host = (struct mg_host *)data; |
526 | char *name; | 648 | char *name; |
527 | struct request *req; | ||
528 | 649 | ||
529 | spin_lock_irq(&host->lock); | 650 | spin_lock_irq(&host->lock); |
530 | 651 | ||
531 | req = elv_next_request(host->breq); | 652 | if (!host->req) |
532 | if (!req) | ||
533 | goto out_unlock; | 653 | goto out_unlock; |
534 | 654 | ||
535 | host->mg_do_intr = NULL; | 655 | host->mg_do_intr = NULL; |
536 | 656 | ||
537 | name = req->rq_disk->disk_name; | 657 | name = host->req->rq_disk->disk_name; |
538 | printk(KERN_DEBUG "%s: timeout\n", name); | 658 | printk(KERN_DEBUG "%s: timeout\n", name); |
539 | 659 | ||
540 | host->error = MG_ERR_TIMEOUT; | 660 | host->error = MG_ERR_TIMEOUT; |
541 | mg_bad_rw_intr(host); | 661 | mg_bad_rw_intr(host); |
542 | 662 | ||
543 | mg_request(host->breq); | ||
544 | out_unlock: | 663 | out_unlock: |
664 | mg_request(host->breq); | ||
545 | spin_unlock_irq(&host->lock); | 665 | spin_unlock_irq(&host->lock); |
546 | } | 666 | } |
547 | 667 | ||
548 | static void mg_request_poll(struct request_queue *q) | 668 | static void mg_request_poll(struct request_queue *q) |
549 | { | 669 | { |
550 | struct request *req; | 670 | struct mg_host *host = q->queuedata; |
551 | struct mg_host *host; | ||
552 | 671 | ||
553 | while ((req = elv_next_request(q)) != NULL) { | 672 | while (1) { |
554 | host = req->rq_disk->private_data; | 673 | if (!host->req) { |
555 | if (blk_fs_request(req)) { | 674 | host->req = blk_fetch_request(q); |
556 | switch (rq_data_dir(req)) { | 675 | if (!host->req) |
557 | case READ: | ||
558 | mg_read(req); | ||
559 | break; | ||
560 | case WRITE: | ||
561 | mg_write(req); | ||
562 | break; | ||
563 | default: | ||
564 | printk(KERN_WARNING "%s:%d unknown command\n", | ||
565 | __func__, __LINE__); | ||
566 | end_request(req, 0); | ||
567 | break; | 676 | break; |
568 | } | ||
569 | } | 677 | } |
678 | |||
679 | if (unlikely(!blk_fs_request(host->req))) { | ||
680 | mg_end_request_cur(host, -EIO); | ||
681 | continue; | ||
682 | } | ||
683 | |||
684 | if (rq_data_dir(host->req) == READ) | ||
685 | mg_read(host->req); | ||
686 | else | ||
687 | mg_write(host->req); | ||
570 | } | 688 | } |
571 | } | 689 | } |
572 | 690 | ||
@@ -588,18 +706,15 @@ static unsigned int mg_issue_req(struct request *req, | |||
588 | break; | 706 | break; |
589 | case WRITE: | 707 | case WRITE: |
590 | /* TODO : handler */ | 708 | /* TODO : handler */ |
591 | outb(MG_REG_CTRL_INTR_DISABLE, | 709 | outb(ATA_NIEN, (unsigned long)host->dev_base + MG_REG_DRV_CTRL); |
592 | (unsigned long)host->dev_base + | ||
593 | MG_REG_DRV_CTRL); | ||
594 | if (mg_out(host, sect_num, sect_cnt, MG_CMD_WR, &mg_write_intr) | 710 | if (mg_out(host, sect_num, sect_cnt, MG_CMD_WR, &mg_write_intr) |
595 | != MG_ERR_NONE) { | 711 | != MG_ERR_NONE) { |
596 | mg_bad_rw_intr(host); | 712 | mg_bad_rw_intr(host); |
597 | return host->error; | 713 | return host->error; |
598 | } | 714 | } |
599 | del_timer(&host->timer); | 715 | del_timer(&host->timer); |
600 | mg_wait(host, MG_REG_STATUS_BIT_DATA_REQ, MG_TMAX_WAIT_WR_DRQ); | 716 | mg_wait(host, ATA_DRQ, MG_TMAX_WAIT_WR_DRQ); |
601 | outb(MG_REG_CTRL_INTR_ENABLE, (unsigned long)host->dev_base + | 717 | outb(0, (unsigned long)host->dev_base + MG_REG_DRV_CTRL); |
602 | MG_REG_DRV_CTRL); | ||
603 | if (host->error) { | 718 | if (host->error) { |
604 | mg_bad_rw_intr(host); | 719 | mg_bad_rw_intr(host); |
605 | return host->error; | 720 | return host->error; |
@@ -614,11 +729,6 @@ static unsigned int mg_issue_req(struct request *req, | |||
614 | outb(MG_CMD_WR_CONF, (unsigned long)host->dev_base + | 729 | outb(MG_CMD_WR_CONF, (unsigned long)host->dev_base + |
615 | MG_REG_COMMAND); | 730 | MG_REG_COMMAND); |
616 | break; | 731 | break; |
617 | default: | ||
618 | printk(KERN_WARNING "%s:%d unknown command\n", | ||
619 | __func__, __LINE__); | ||
620 | end_request(req, 0); | ||
621 | break; | ||
622 | } | 732 | } |
623 | return MG_ERR_NONE; | 733 | return MG_ERR_NONE; |
624 | } | 734 | } |
@@ -626,16 +736,17 @@ static unsigned int mg_issue_req(struct request *req, | |||
626 | /* This function also called from IRQ context */ | 736 | /* This function also called from IRQ context */ |
627 | static void mg_request(struct request_queue *q) | 737 | static void mg_request(struct request_queue *q) |
628 | { | 738 | { |
739 | struct mg_host *host = q->queuedata; | ||
629 | struct request *req; | 740 | struct request *req; |
630 | struct mg_host *host; | ||
631 | u32 sect_num, sect_cnt; | 741 | u32 sect_num, sect_cnt; |
632 | 742 | ||
633 | while (1) { | 743 | while (1) { |
634 | req = elv_next_request(q); | 744 | if (!host->req) { |
635 | if (!req) | 745 | host->req = blk_fetch_request(q); |
636 | return; | 746 | if (!host->req) |
637 | 747 | break; | |
638 | host = req->rq_disk->private_data; | 748 | } |
749 | req = host->req; | ||
639 | 750 | ||
640 | /* check unwanted request call */ | 751 | /* check unwanted request call */ |
641 | if (host->mg_do_intr) | 752 | if (host->mg_do_intr) |
@@ -643,9 +754,9 @@ static void mg_request(struct request_queue *q) | |||
643 | 754 | ||
644 | del_timer(&host->timer); | 755 | del_timer(&host->timer); |
645 | 756 | ||
646 | sect_num = req->sector; | 757 | sect_num = blk_rq_pos(req); |
647 | /* deal whole segments */ | 758 | /* deal whole segments */ |
648 | sect_cnt = req->nr_sectors; | 759 | sect_cnt = blk_rq_sectors(req); |
649 | 760 | ||
650 | /* sanity check */ | 761 | /* sanity check */ |
651 | if (sect_num >= get_capacity(req->rq_disk) || | 762 | if (sect_num >= get_capacity(req->rq_disk) || |
@@ -655,12 +766,14 @@ static void mg_request(struct request_queue *q) | |||
655 | "%s: bad access: sector=%d, count=%d\n", | 766 | "%s: bad access: sector=%d, count=%d\n", |
656 | req->rq_disk->disk_name, | 767 | req->rq_disk->disk_name, |
657 | sect_num, sect_cnt); | 768 | sect_num, sect_cnt); |
658 | end_request(req, 0); | 769 | mg_end_request_cur(host, -EIO); |
659 | continue; | 770 | continue; |
660 | } | 771 | } |
661 | 772 | ||
662 | if (!blk_fs_request(req)) | 773 | if (unlikely(!blk_fs_request(req))) { |
663 | return; | 774 | mg_end_request_cur(host, -EIO); |
775 | continue; | ||
776 | } | ||
664 | 777 | ||
665 | if (!mg_issue_req(req, host, sect_num, sect_cnt)) | 778 | if (!mg_issue_req(req, host, sect_num, sect_cnt)) |
666 | return; | 779 | return; |
@@ -690,9 +803,7 @@ static int mg_suspend(struct platform_device *plat_dev, pm_message_t state) | |||
690 | return -EIO; | 803 | return -EIO; |
691 | 804 | ||
692 | if (!prv_data->use_polling) | 805 | if (!prv_data->use_polling) |
693 | outb(MG_REG_CTRL_INTR_DISABLE, | 806 | outb(ATA_NIEN, (unsigned long)host->dev_base + MG_REG_DRV_CTRL); |
694 | (unsigned long)host->dev_base + | ||
695 | MG_REG_DRV_CTRL); | ||
696 | 807 | ||
697 | outb(MG_CMD_SLEEP, (unsigned long)host->dev_base + MG_REG_COMMAND); | 808 | outb(MG_CMD_SLEEP, (unsigned long)host->dev_base + MG_REG_COMMAND); |
698 | /* wait until mflash deep sleep */ | 809 | /* wait until mflash deep sleep */ |
@@ -700,9 +811,7 @@ static int mg_suspend(struct platform_device *plat_dev, pm_message_t state) | |||
700 | 811 | ||
701 | if (mg_wait(host, MG_STAT_READY, MG_TMAX_CONF_TO_CMD)) { | 812 | if (mg_wait(host, MG_STAT_READY, MG_TMAX_CONF_TO_CMD)) { |
702 | if (!prv_data->use_polling) | 813 | if (!prv_data->use_polling) |
703 | outb(MG_REG_CTRL_INTR_ENABLE, | 814 | outb(0, (unsigned long)host->dev_base + MG_REG_DRV_CTRL); |
704 | (unsigned long)host->dev_base + | ||
705 | MG_REG_DRV_CTRL); | ||
706 | return -EIO; | 815 | return -EIO; |
707 | } | 816 | } |
708 | 817 | ||
@@ -725,8 +834,7 @@ static int mg_resume(struct platform_device *plat_dev) | |||
725 | return -EIO; | 834 | return -EIO; |
726 | 835 | ||
727 | if (!prv_data->use_polling) | 836 | if (!prv_data->use_polling) |
728 | outb(MG_REG_CTRL_INTR_ENABLE, (unsigned long)host->dev_base + | 837 | outb(0, (unsigned long)host->dev_base + MG_REG_DRV_CTRL); |
729 | MG_REG_DRV_CTRL); | ||
730 | 838 | ||
731 | return 0; | 839 | return 0; |
732 | } | 840 | } |
@@ -877,6 +985,7 @@ static int mg_probe(struct platform_device *plat_dev) | |||
877 | __func__, __LINE__); | 985 | __func__, __LINE__); |
878 | goto probe_err_5; | 986 | goto probe_err_5; |
879 | } | 987 | } |
988 | host->breq->queuedata = host; | ||
880 | 989 | ||
881 | /* mflash is random device, thanx for the noop */ | 990 | /* mflash is random device, thanx for the noop */ |
882 | elevator_exit(host->breq->elevator); | 991 | elevator_exit(host->breq->elevator); |
@@ -887,7 +996,7 @@ static int mg_probe(struct platform_device *plat_dev) | |||
887 | goto probe_err_6; | 996 | goto probe_err_6; |
888 | } | 997 | } |
889 | blk_queue_max_sectors(host->breq, MG_MAX_SECTS); | 998 | blk_queue_max_sectors(host->breq, MG_MAX_SECTS); |
890 | blk_queue_hardsect_size(host->breq, MG_SECTOR_SIZE); | 999 | blk_queue_logical_block_size(host->breq, MG_SECTOR_SIZE); |
891 | 1000 | ||
892 | init_timer(&host->timer); | 1001 | init_timer(&host->timer); |
893 | host->timer.function = mg_times_out; | 1002 | host->timer.function = mg_times_out; |