diff options
Diffstat (limited to 'drivers')
27 files changed, 323 insertions, 2321 deletions
diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c index 1bbdd1693d57..889855d8d9f9 100644 --- a/drivers/amba/bus.c +++ b/drivers/amba/bus.c | |||
@@ -15,7 +15,6 @@ | |||
15 | #include <linux/amba/bus.h> | 15 | #include <linux/amba/bus.h> |
16 | 16 | ||
17 | #include <asm/io.h> | 17 | #include <asm/io.h> |
18 | #include <asm/irq.h> | ||
19 | #include <asm/sizes.h> | 18 | #include <asm/sizes.h> |
20 | 19 | ||
21 | #define to_amba_device(d) container_of(d, struct amba_device, dev) | 20 | #define to_amba_device(d) container_of(d, struct amba_device, dev) |
diff --git a/drivers/input/serio/sa1111ps2.c b/drivers/input/serio/sa1111ps2.c index 3f0df3330fb2..ebd9976fc811 100644 --- a/drivers/input/serio/sa1111ps2.c +++ b/drivers/input/serio/sa1111ps2.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include <linux/spinlock.h> | 20 | #include <linux/spinlock.h> |
21 | 21 | ||
22 | #include <asm/io.h> | 22 | #include <asm/io.h> |
23 | #include <asm/irq.h> | ||
24 | #include <asm/system.h> | 23 | #include <asm/system.h> |
25 | 24 | ||
26 | #include <asm/hardware/sa1111.h> | 25 | #include <asm/hardware/sa1111.h> |
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 6696f71363b9..bfca5c176e88 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c | |||
@@ -495,6 +495,7 @@ static void mmc_decode_cid(struct mmc_card *card) | |||
495 | 495 | ||
496 | case 2: /* MMC v2.0 - v2.2 */ | 496 | case 2: /* MMC v2.0 - v2.2 */ |
497 | case 3: /* MMC v3.1 - v3.3 */ | 497 | case 3: /* MMC v3.1 - v3.3 */ |
498 | case 4: /* MMC v4 */ | ||
498 | card->cid.manfid = UNSTUFF_BITS(resp, 120, 8); | 499 | card->cid.manfid = UNSTUFF_BITS(resp, 120, 8); |
499 | card->cid.oemid = UNSTUFF_BITS(resp, 104, 16); | 500 | card->cid.oemid = UNSTUFF_BITS(resp, 104, 16); |
500 | card->cid.prod_name[0] = UNSTUFF_BITS(resp, 96, 8); | 501 | card->cid.prod_name[0] = UNSTUFF_BITS(resp, 96, 8); |
diff --git a/drivers/mmc/mmc_block.c b/drivers/mmc/mmc_block.c index d5f28981596b..f2c42b13945d 100644 --- a/drivers/mmc/mmc_block.c +++ b/drivers/mmc/mmc_block.c | |||
@@ -187,7 +187,13 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) | |||
187 | brq.data.flags |= MMC_DATA_WRITE; | 187 | brq.data.flags |= MMC_DATA_WRITE; |
188 | brq.data.blocks = 1; | 188 | brq.data.blocks = 1; |
189 | } | 189 | } |
190 | brq.mrq.stop = brq.data.blocks > 1 ? &brq.stop : NULL; | 190 | |
191 | if (brq.data.blocks > 1) { | ||
192 | brq.data.flags |= MMC_DATA_MULTI; | ||
193 | brq.mrq.stop = &brq.stop; | ||
194 | } else { | ||
195 | brq.mrq.stop = NULL; | ||
196 | } | ||
191 | 197 | ||
192 | brq.data.sg = mq->sg; | 198 | brq.data.sg = mq->sg; |
193 | brq.data.sg_len = blk_rq_map_sg(req->q, req, brq.data.sg); | 199 | brq.data.sg_len = blk_rq_map_sg(req->q, req, brq.data.sg); |
diff --git a/drivers/mmc/wbsd.c b/drivers/mmc/wbsd.c index 4f13bd2ccf9a..f25757625361 100644 --- a/drivers/mmc/wbsd.c +++ b/drivers/mmc/wbsd.c | |||
@@ -90,7 +90,7 @@ static int dma = 2; | |||
90 | * Basic functions | 90 | * Basic functions |
91 | */ | 91 | */ |
92 | 92 | ||
93 | static inline void wbsd_unlock_config(struct wbsd_host* host) | 93 | static inline void wbsd_unlock_config(struct wbsd_host *host) |
94 | { | 94 | { |
95 | BUG_ON(host->config == 0); | 95 | BUG_ON(host->config == 0); |
96 | 96 | ||
@@ -98,14 +98,14 @@ static inline void wbsd_unlock_config(struct wbsd_host* host) | |||
98 | outb(host->unlock_code, host->config); | 98 | outb(host->unlock_code, host->config); |
99 | } | 99 | } |
100 | 100 | ||
101 | static inline void wbsd_lock_config(struct wbsd_host* host) | 101 | static inline void wbsd_lock_config(struct wbsd_host *host) |
102 | { | 102 | { |
103 | BUG_ON(host->config == 0); | 103 | BUG_ON(host->config == 0); |
104 | 104 | ||
105 | outb(LOCK_CODE, host->config); | 105 | outb(LOCK_CODE, host->config); |
106 | } | 106 | } |
107 | 107 | ||
108 | static inline void wbsd_write_config(struct wbsd_host* host, u8 reg, u8 value) | 108 | static inline void wbsd_write_config(struct wbsd_host *host, u8 reg, u8 value) |
109 | { | 109 | { |
110 | BUG_ON(host->config == 0); | 110 | BUG_ON(host->config == 0); |
111 | 111 | ||
@@ -113,7 +113,7 @@ static inline void wbsd_write_config(struct wbsd_host* host, u8 reg, u8 value) | |||
113 | outb(value, host->config + 1); | 113 | outb(value, host->config + 1); |
114 | } | 114 | } |
115 | 115 | ||
116 | static inline u8 wbsd_read_config(struct wbsd_host* host, u8 reg) | 116 | static inline u8 wbsd_read_config(struct wbsd_host *host, u8 reg) |
117 | { | 117 | { |
118 | BUG_ON(host->config == 0); | 118 | BUG_ON(host->config == 0); |
119 | 119 | ||
@@ -121,13 +121,13 @@ static inline u8 wbsd_read_config(struct wbsd_host* host, u8 reg) | |||
121 | return inb(host->config + 1); | 121 | return inb(host->config + 1); |
122 | } | 122 | } |
123 | 123 | ||
124 | static inline void wbsd_write_index(struct wbsd_host* host, u8 index, u8 value) | 124 | static inline void wbsd_write_index(struct wbsd_host *host, u8 index, u8 value) |
125 | { | 125 | { |
126 | outb(index, host->base + WBSD_IDXR); | 126 | outb(index, host->base + WBSD_IDXR); |
127 | outb(value, host->base + WBSD_DATAR); | 127 | outb(value, host->base + WBSD_DATAR); |
128 | } | 128 | } |
129 | 129 | ||
130 | static inline u8 wbsd_read_index(struct wbsd_host* host, u8 index) | 130 | static inline u8 wbsd_read_index(struct wbsd_host *host, u8 index) |
131 | { | 131 | { |
132 | outb(index, host->base + WBSD_IDXR); | 132 | outb(index, host->base + WBSD_IDXR); |
133 | return inb(host->base + WBSD_DATAR); | 133 | return inb(host->base + WBSD_DATAR); |
@@ -137,7 +137,7 @@ static inline u8 wbsd_read_index(struct wbsd_host* host, u8 index) | |||
137 | * Common routines | 137 | * Common routines |
138 | */ | 138 | */ |
139 | 139 | ||
140 | static void wbsd_init_device(struct wbsd_host* host) | 140 | static void wbsd_init_device(struct wbsd_host *host) |
141 | { | 141 | { |
142 | u8 setup, ier; | 142 | u8 setup, ier; |
143 | 143 | ||
@@ -197,7 +197,7 @@ static void wbsd_init_device(struct wbsd_host* host) | |||
197 | inb(host->base + WBSD_ISR); | 197 | inb(host->base + WBSD_ISR); |
198 | } | 198 | } |
199 | 199 | ||
200 | static void wbsd_reset(struct wbsd_host* host) | 200 | static void wbsd_reset(struct wbsd_host *host) |
201 | { | 201 | { |
202 | u8 setup; | 202 | u8 setup; |
203 | 203 | ||
@@ -211,14 +211,13 @@ static void wbsd_reset(struct wbsd_host* host) | |||
211 | wbsd_write_index(host, WBSD_IDX_SETUP, setup); | 211 | wbsd_write_index(host, WBSD_IDX_SETUP, setup); |
212 | } | 212 | } |
213 | 213 | ||
214 | static void wbsd_request_end(struct wbsd_host* host, struct mmc_request* mrq) | 214 | static void wbsd_request_end(struct wbsd_host *host, struct mmc_request *mrq) |
215 | { | 215 | { |
216 | unsigned long dmaflags; | 216 | unsigned long dmaflags; |
217 | 217 | ||
218 | DBGF("Ending request, cmd (%x)\n", mrq->cmd->opcode); | 218 | DBGF("Ending request, cmd (%x)\n", mrq->cmd->opcode); |
219 | 219 | ||
220 | if (host->dma >= 0) | 220 | if (host->dma >= 0) { |
221 | { | ||
222 | /* | 221 | /* |
223 | * Release ISA DMA controller. | 222 | * Release ISA DMA controller. |
224 | */ | 223 | */ |
@@ -247,7 +246,7 @@ static void wbsd_request_end(struct wbsd_host* host, struct mmc_request* mrq) | |||
247 | * Scatter/gather functions | 246 | * Scatter/gather functions |
248 | */ | 247 | */ |
249 | 248 | ||
250 | static inline void wbsd_init_sg(struct wbsd_host* host, struct mmc_data* data) | 249 | static inline void wbsd_init_sg(struct wbsd_host *host, struct mmc_data *data) |
251 | { | 250 | { |
252 | /* | 251 | /* |
253 | * Get info. about SG list from data structure. | 252 | * Get info. about SG list from data structure. |
@@ -259,7 +258,7 @@ static inline void wbsd_init_sg(struct wbsd_host* host, struct mmc_data* data) | |||
259 | host->remain = host->cur_sg->length; | 258 | host->remain = host->cur_sg->length; |
260 | } | 259 | } |
261 | 260 | ||
262 | static inline int wbsd_next_sg(struct wbsd_host* host) | 261 | static inline int wbsd_next_sg(struct wbsd_host *host) |
263 | { | 262 | { |
264 | /* | 263 | /* |
265 | * Skip to next SG entry. | 264 | * Skip to next SG entry. |
@@ -270,33 +269,32 @@ static inline int wbsd_next_sg(struct wbsd_host* host) | |||
270 | /* | 269 | /* |
271 | * Any entries left? | 270 | * Any entries left? |
272 | */ | 271 | */ |
273 | if (host->num_sg > 0) | 272 | if (host->num_sg > 0) { |
274 | { | 273 | host->offset = 0; |
275 | host->offset = 0; | 274 | host->remain = host->cur_sg->length; |
276 | host->remain = host->cur_sg->length; | 275 | } |
277 | } | ||
278 | 276 | ||
279 | return host->num_sg; | 277 | return host->num_sg; |
280 | } | 278 | } |
281 | 279 | ||
282 | static inline char* wbsd_kmap_sg(struct wbsd_host* host) | 280 | static inline char *wbsd_kmap_sg(struct wbsd_host *host) |
283 | { | 281 | { |
284 | host->mapped_sg = kmap_atomic(host->cur_sg->page, KM_BIO_SRC_IRQ) + | 282 | host->mapped_sg = kmap_atomic(host->cur_sg->page, KM_BIO_SRC_IRQ) + |
285 | host->cur_sg->offset; | 283 | host->cur_sg->offset; |
286 | return host->mapped_sg; | 284 | return host->mapped_sg; |
287 | } | 285 | } |
288 | 286 | ||
289 | static inline void wbsd_kunmap_sg(struct wbsd_host* host) | 287 | static inline void wbsd_kunmap_sg(struct wbsd_host *host) |
290 | { | 288 | { |
291 | kunmap_atomic(host->mapped_sg, KM_BIO_SRC_IRQ); | 289 | kunmap_atomic(host->mapped_sg, KM_BIO_SRC_IRQ); |
292 | } | 290 | } |
293 | 291 | ||
294 | static inline void wbsd_sg_to_dma(struct wbsd_host* host, struct mmc_data* data) | 292 | static inline void wbsd_sg_to_dma(struct wbsd_host *host, struct mmc_data *data) |
295 | { | 293 | { |
296 | unsigned int len, i, size; | 294 | unsigned int len, i, size; |
297 | struct scatterlist* sg; | 295 | struct scatterlist *sg; |
298 | char* dmabuf = host->dma_buffer; | 296 | char *dmabuf = host->dma_buffer; |
299 | char* sgbuf; | 297 | char *sgbuf; |
300 | 298 | ||
301 | size = host->size; | 299 | size = host->size; |
302 | 300 | ||
@@ -308,8 +306,7 @@ static inline void wbsd_sg_to_dma(struct wbsd_host* host, struct mmc_data* data) | |||
308 | * be the entire list though so make sure that | 306 | * be the entire list though so make sure that |
309 | * we do not transfer too much. | 307 | * we do not transfer too much. |
310 | */ | 308 | */ |
311 | for (i = 0;i < len;i++) | 309 | for (i = 0; i < len; i++) { |
312 | { | ||
313 | sgbuf = kmap_atomic(sg[i].page, KM_BIO_SRC_IRQ) + sg[i].offset; | 310 | sgbuf = kmap_atomic(sg[i].page, KM_BIO_SRC_IRQ) + sg[i].offset; |
314 | if (size < sg[i].length) | 311 | if (size < sg[i].length) |
315 | memcpy(dmabuf, sgbuf, size); | 312 | memcpy(dmabuf, sgbuf, size); |
@@ -337,12 +334,12 @@ static inline void wbsd_sg_to_dma(struct wbsd_host* host, struct mmc_data* data) | |||
337 | host->size -= size; | 334 | host->size -= size; |
338 | } | 335 | } |
339 | 336 | ||
340 | static inline void wbsd_dma_to_sg(struct wbsd_host* host, struct mmc_data* data) | 337 | static inline void wbsd_dma_to_sg(struct wbsd_host *host, struct mmc_data *data) |
341 | { | 338 | { |
342 | unsigned int len, i, size; | 339 | unsigned int len, i, size; |
343 | struct scatterlist* sg; | 340 | struct scatterlist *sg; |
344 | char* dmabuf = host->dma_buffer; | 341 | char *dmabuf = host->dma_buffer; |
345 | char* sgbuf; | 342 | char *sgbuf; |
346 | 343 | ||
347 | size = host->size; | 344 | size = host->size; |
348 | 345 | ||
@@ -354,8 +351,7 @@ static inline void wbsd_dma_to_sg(struct wbsd_host* host, struct mmc_data* data) | |||
354 | * be the entire list though so make sure that | 351 | * be the entire list though so make sure that |
355 | * we do not transfer too much. | 352 | * we do not transfer too much. |
356 | */ | 353 | */ |
357 | for (i = 0;i < len;i++) | 354 | for (i = 0; i < len; i++) { |
358 | { | ||
359 | sgbuf = kmap_atomic(sg[i].page, KM_BIO_SRC_IRQ) + sg[i].offset; | 355 | sgbuf = kmap_atomic(sg[i].page, KM_BIO_SRC_IRQ) + sg[i].offset; |
360 | if (size < sg[i].length) | 356 | if (size < sg[i].length) |
361 | memcpy(sgbuf, dmabuf, size); | 357 | memcpy(sgbuf, dmabuf, size); |
@@ -387,46 +383,38 @@ static inline void wbsd_dma_to_sg(struct wbsd_host* host, struct mmc_data* data) | |||
387 | * Command handling | 383 | * Command handling |
388 | */ | 384 | */ |
389 | 385 | ||
390 | static inline void wbsd_get_short_reply(struct wbsd_host* host, | 386 | static inline void wbsd_get_short_reply(struct wbsd_host *host, |
391 | struct mmc_command* cmd) | 387 | struct mmc_command *cmd) |
392 | { | 388 | { |
393 | /* | 389 | /* |
394 | * Correct response type? | 390 | * Correct response type? |
395 | */ | 391 | */ |
396 | if (wbsd_read_index(host, WBSD_IDX_RSPLEN) != WBSD_RSP_SHORT) | 392 | if (wbsd_read_index(host, WBSD_IDX_RSPLEN) != WBSD_RSP_SHORT) { |
397 | { | ||
398 | cmd->error = MMC_ERR_INVALID; | 393 | cmd->error = MMC_ERR_INVALID; |
399 | return; | 394 | return; |
400 | } | 395 | } |
401 | 396 | ||
402 | cmd->resp[0] = | 397 | cmd->resp[0] = wbsd_read_index(host, WBSD_IDX_RESP12) << 24; |
403 | wbsd_read_index(host, WBSD_IDX_RESP12) << 24; | 398 | cmd->resp[0] |= wbsd_read_index(host, WBSD_IDX_RESP13) << 16; |
404 | cmd->resp[0] |= | 399 | cmd->resp[0] |= wbsd_read_index(host, WBSD_IDX_RESP14) << 8; |
405 | wbsd_read_index(host, WBSD_IDX_RESP13) << 16; | 400 | cmd->resp[0] |= wbsd_read_index(host, WBSD_IDX_RESP15) << 0; |
406 | cmd->resp[0] |= | 401 | cmd->resp[1] = wbsd_read_index(host, WBSD_IDX_RESP16) << 24; |
407 | wbsd_read_index(host, WBSD_IDX_RESP14) << 8; | ||
408 | cmd->resp[0] |= | ||
409 | wbsd_read_index(host, WBSD_IDX_RESP15) << 0; | ||
410 | cmd->resp[1] = | ||
411 | wbsd_read_index(host, WBSD_IDX_RESP16) << 24; | ||
412 | } | 402 | } |
413 | 403 | ||
414 | static inline void wbsd_get_long_reply(struct wbsd_host* host, | 404 | static inline void wbsd_get_long_reply(struct wbsd_host *host, |
415 | struct mmc_command* cmd) | 405 | struct mmc_command *cmd) |
416 | { | 406 | { |
417 | int i; | 407 | int i; |
418 | 408 | ||
419 | /* | 409 | /* |
420 | * Correct response type? | 410 | * Correct response type? |
421 | */ | 411 | */ |
422 | if (wbsd_read_index(host, WBSD_IDX_RSPLEN) != WBSD_RSP_LONG) | 412 | if (wbsd_read_index(host, WBSD_IDX_RSPLEN) != WBSD_RSP_LONG) { |
423 | { | ||
424 | cmd->error = MMC_ERR_INVALID; | 413 | cmd->error = MMC_ERR_INVALID; |
425 | return; | 414 | return; |
426 | } | 415 | } |
427 | 416 | ||
428 | for (i = 0;i < 4;i++) | 417 | for (i = 0; i < 4; i++) { |
429 | { | ||
430 | cmd->resp[i] = | 418 | cmd->resp[i] = |
431 | wbsd_read_index(host, WBSD_IDX_RESP1 + i * 4) << 24; | 419 | wbsd_read_index(host, WBSD_IDX_RESP1 + i * 4) << 24; |
432 | cmd->resp[i] |= | 420 | cmd->resp[i] |= |
@@ -438,7 +426,7 @@ static inline void wbsd_get_long_reply(struct wbsd_host* host, | |||
438 | } | 426 | } |
439 | } | 427 | } |
440 | 428 | ||
441 | static void wbsd_send_command(struct wbsd_host* host, struct mmc_command* cmd) | 429 | static void wbsd_send_command(struct wbsd_host *host, struct mmc_command *cmd) |
442 | { | 430 | { |
443 | int i; | 431 | int i; |
444 | u8 status, isr; | 432 | u8 status, isr; |
@@ -456,7 +444,7 @@ static void wbsd_send_command(struct wbsd_host* host, struct mmc_command* cmd) | |||
456 | * Send the command (CRC calculated by host). | 444 | * Send the command (CRC calculated by host). |
457 | */ | 445 | */ |
458 | outb(cmd->opcode, host->base + WBSD_CMDR); | 446 | outb(cmd->opcode, host->base + WBSD_CMDR); |
459 | for (i = 3;i >= 0;i--) | 447 | for (i = 3; i >= 0; i--) |
460 | outb((cmd->arg >> (i * 8)) & 0xff, host->base + WBSD_CMDR); | 448 | outb((cmd->arg >> (i * 8)) & 0xff, host->base + WBSD_CMDR); |
461 | 449 | ||
462 | cmd->error = MMC_ERR_NONE; | 450 | cmd->error = MMC_ERR_NONE; |
@@ -471,8 +459,7 @@ static void wbsd_send_command(struct wbsd_host* host, struct mmc_command* cmd) | |||
471 | /* | 459 | /* |
472 | * Do we expect a reply? | 460 | * Do we expect a reply? |
473 | */ | 461 | */ |
474 | if ((cmd->flags & MMC_RSP_MASK) != MMC_RSP_NONE) | 462 | if ((cmd->flags & MMC_RSP_MASK) != MMC_RSP_NONE) { |
475 | { | ||
476 | /* | 463 | /* |
477 | * Read back status. | 464 | * Read back status. |
478 | */ | 465 | */ |
@@ -488,8 +475,7 @@ static void wbsd_send_command(struct wbsd_host* host, struct mmc_command* cmd) | |||
488 | else if ((cmd->flags & MMC_RSP_CRC) && (isr & WBSD_INT_CRC)) | 475 | else if ((cmd->flags & MMC_RSP_CRC) && (isr & WBSD_INT_CRC)) |
489 | cmd->error = MMC_ERR_BADCRC; | 476 | cmd->error = MMC_ERR_BADCRC; |
490 | /* All ok */ | 477 | /* All ok */ |
491 | else | 478 | else { |
492 | { | ||
493 | if ((cmd->flags & MMC_RSP_MASK) == MMC_RSP_SHORT) | 479 | if ((cmd->flags & MMC_RSP_MASK) == MMC_RSP_SHORT) |
494 | wbsd_get_short_reply(host, cmd); | 480 | wbsd_get_short_reply(host, cmd); |
495 | else | 481 | else |
@@ -504,10 +490,10 @@ static void wbsd_send_command(struct wbsd_host* host, struct mmc_command* cmd) | |||
504 | * Data functions | 490 | * Data functions |
505 | */ | 491 | */ |
506 | 492 | ||
507 | static void wbsd_empty_fifo(struct wbsd_host* host) | 493 | static void wbsd_empty_fifo(struct wbsd_host *host) |
508 | { | 494 | { |
509 | struct mmc_data* data = host->mrq->cmd->data; | 495 | struct mmc_data *data = host->mrq->cmd->data; |
510 | char* buffer; | 496 | char *buffer; |
511 | int i, fsr, fifo; | 497 | int i, fsr, fifo; |
512 | 498 | ||
513 | /* | 499 | /* |
@@ -522,8 +508,7 @@ static void wbsd_empty_fifo(struct wbsd_host* host) | |||
522 | * Drain the fifo. This has a tendency to loop longer | 508 | * Drain the fifo. This has a tendency to loop longer |
523 | * than the FIFO length (usually one block). | 509 | * than the FIFO length (usually one block). |
524 | */ | 510 | */ |
525 | while (!((fsr = inb(host->base + WBSD_FSR)) & WBSD_FIFO_EMPTY)) | 511 | while (!((fsr = inb(host->base + WBSD_FSR)) & WBSD_FIFO_EMPTY)) { |
526 | { | ||
527 | /* | 512 | /* |
528 | * The size field in the FSR is broken so we have to | 513 | * The size field in the FSR is broken so we have to |
529 | * do some guessing. | 514 | * do some guessing. |
@@ -535,8 +520,7 @@ static void wbsd_empty_fifo(struct wbsd_host* host) | |||
535 | else | 520 | else |
536 | fifo = 1; | 521 | fifo = 1; |
537 | 522 | ||
538 | for (i = 0;i < fifo;i++) | 523 | for (i = 0; i < fifo; i++) { |
539 | { | ||
540 | *buffer = inb(host->base + WBSD_DFR); | 524 | *buffer = inb(host->base + WBSD_DFR); |
541 | buffer++; | 525 | buffer++; |
542 | host->offset++; | 526 | host->offset++; |
@@ -547,8 +531,7 @@ static void wbsd_empty_fifo(struct wbsd_host* host) | |||
547 | /* | 531 | /* |
548 | * Transfer done? | 532 | * Transfer done? |
549 | */ | 533 | */ |
550 | if (data->bytes_xfered == host->size) | 534 | if (data->bytes_xfered == host->size) { |
551 | { | ||
552 | wbsd_kunmap_sg(host); | 535 | wbsd_kunmap_sg(host); |
553 | return; | 536 | return; |
554 | } | 537 | } |
@@ -556,15 +539,13 @@ static void wbsd_empty_fifo(struct wbsd_host* host) | |||
556 | /* | 539 | /* |
557 | * End of scatter list entry? | 540 | * End of scatter list entry? |
558 | */ | 541 | */ |
559 | if (host->remain == 0) | 542 | if (host->remain == 0) { |
560 | { | ||
561 | wbsd_kunmap_sg(host); | 543 | wbsd_kunmap_sg(host); |
562 | 544 | ||
563 | /* | 545 | /* |
564 | * Get next entry. Check if last. | 546 | * Get next entry. Check if last. |
565 | */ | 547 | */ |
566 | if (!wbsd_next_sg(host)) | 548 | if (!wbsd_next_sg(host)) { |
567 | { | ||
568 | /* | 549 | /* |
569 | * We should never reach this point. | 550 | * We should never reach this point. |
570 | * It means that we're trying to | 551 | * It means that we're trying to |
@@ -594,10 +575,10 @@ static void wbsd_empty_fifo(struct wbsd_host* host) | |||
594 | tasklet_schedule(&host->fifo_tasklet); | 575 | tasklet_schedule(&host->fifo_tasklet); |
595 | } | 576 | } |
596 | 577 | ||
597 | static void wbsd_fill_fifo(struct wbsd_host* host) | 578 | static void wbsd_fill_fifo(struct wbsd_host *host) |
598 | { | 579 | { |
599 | struct mmc_data* data = host->mrq->cmd->data; | 580 | struct mmc_data *data = host->mrq->cmd->data; |
600 | char* buffer; | 581 | char *buffer; |
601 | int i, fsr, fifo; | 582 | int i, fsr, fifo; |
602 | 583 | ||
603 | /* | 584 | /* |
@@ -613,8 +594,7 @@ static void wbsd_fill_fifo(struct wbsd_host* host) | |||
613 | * Fill the fifo. This has a tendency to loop longer | 594 | * Fill the fifo. This has a tendency to loop longer |
614 | * than the FIFO length (usually one block). | 595 | * than the FIFO length (usually one block). |
615 | */ | 596 | */ |
616 | while (!((fsr = inb(host->base + WBSD_FSR)) & WBSD_FIFO_FULL)) | 597 | while (!((fsr = inb(host->base + WBSD_FSR)) & WBSD_FIFO_FULL)) { |
617 | { | ||
618 | /* | 598 | /* |
619 | * The size field in the FSR is broken so we have to | 599 | * The size field in the FSR is broken so we have to |
620 | * do some guessing. | 600 | * do some guessing. |
@@ -626,8 +606,7 @@ static void wbsd_fill_fifo(struct wbsd_host* host) | |||
626 | else | 606 | else |
627 | fifo = 15; | 607 | fifo = 15; |
628 | 608 | ||
629 | for (i = 16;i > fifo;i--) | 609 | for (i = 16; i > fifo; i--) { |
630 | { | ||
631 | outb(*buffer, host->base + WBSD_DFR); | 610 | outb(*buffer, host->base + WBSD_DFR); |
632 | buffer++; | 611 | buffer++; |
633 | host->offset++; | 612 | host->offset++; |
@@ -638,8 +617,7 @@ static void wbsd_fill_fifo(struct wbsd_host* host) | |||
638 | /* | 617 | /* |
639 | * Transfer done? | 618 | * Transfer done? |
640 | */ | 619 | */ |
641 | if (data->bytes_xfered == host->size) | 620 | if (data->bytes_xfered == host->size) { |
642 | { | ||
643 | wbsd_kunmap_sg(host); | 621 | wbsd_kunmap_sg(host); |
644 | return; | 622 | return; |
645 | } | 623 | } |
@@ -647,15 +625,13 @@ static void wbsd_fill_fifo(struct wbsd_host* host) | |||
647 | /* | 625 | /* |
648 | * End of scatter list entry? | 626 | * End of scatter list entry? |
649 | */ | 627 | */ |
650 | if (host->remain == 0) | 628 | if (host->remain == 0) { |
651 | { | ||
652 | wbsd_kunmap_sg(host); | 629 | wbsd_kunmap_sg(host); |
653 | 630 | ||
654 | /* | 631 | /* |
655 | * Get next entry. Check if last. | 632 | * Get next entry. Check if last. |
656 | */ | 633 | */ |
657 | if (!wbsd_next_sg(host)) | 634 | if (!wbsd_next_sg(host)) { |
658 | { | ||
659 | /* | 635 | /* |
660 | * We should never reach this point. | 636 | * We should never reach this point. |
661 | * It means that we're trying to | 637 | * It means that we're trying to |
@@ -684,7 +660,7 @@ static void wbsd_fill_fifo(struct wbsd_host* host) | |||
684 | tasklet_schedule(&host->fifo_tasklet); | 660 | tasklet_schedule(&host->fifo_tasklet); |
685 | } | 661 | } |
686 | 662 | ||
687 | static void wbsd_prepare_data(struct wbsd_host* host, struct mmc_data* data) | 663 | static void wbsd_prepare_data(struct wbsd_host *host, struct mmc_data *data) |
688 | { | 664 | { |
689 | u16 blksize; | 665 | u16 blksize; |
690 | u8 setup; | 666 | u8 setup; |
@@ -706,8 +682,10 @@ static void wbsd_prepare_data(struct wbsd_host* host, struct mmc_data* data) | |||
706 | */ | 682 | */ |
707 | if (data->timeout_ns > 127000000) | 683 | if (data->timeout_ns > 127000000) |
708 | wbsd_write_index(host, WBSD_IDX_TAAC, 127); | 684 | wbsd_write_index(host, WBSD_IDX_TAAC, 127); |
709 | else | 685 | else { |
710 | wbsd_write_index(host, WBSD_IDX_TAAC, data->timeout_ns/1000000); | 686 | wbsd_write_index(host, WBSD_IDX_TAAC, |
687 | data->timeout_ns / 1000000); | ||
688 | } | ||
711 | 689 | ||
712 | if (data->timeout_clks > 255) | 690 | if (data->timeout_clks > 255) |
713 | wbsd_write_index(host, WBSD_IDX_NSAC, 255); | 691 | wbsd_write_index(host, WBSD_IDX_NSAC, 255); |
@@ -722,23 +700,18 @@ static void wbsd_prepare_data(struct wbsd_host* host, struct mmc_data* data) | |||
722 | * Space for CRC must be included in the size. | 700 | * Space for CRC must be included in the size. |
723 | * Two bytes are needed for each data line. | 701 | * Two bytes are needed for each data line. |
724 | */ | 702 | */ |
725 | if (host->bus_width == MMC_BUS_WIDTH_1) | 703 | if (host->bus_width == MMC_BUS_WIDTH_1) { |
726 | { | ||
727 | blksize = (1 << data->blksz_bits) + 2; | 704 | blksize = (1 << data->blksz_bits) + 2; |
728 | 705 | ||
729 | wbsd_write_index(host, WBSD_IDX_PBSMSB, (blksize >> 4) & 0xF0); | 706 | wbsd_write_index(host, WBSD_IDX_PBSMSB, (blksize >> 4) & 0xF0); |
730 | wbsd_write_index(host, WBSD_IDX_PBSLSB, blksize & 0xFF); | 707 | wbsd_write_index(host, WBSD_IDX_PBSLSB, blksize & 0xFF); |
731 | } | 708 | } else if (host->bus_width == MMC_BUS_WIDTH_4) { |
732 | else if (host->bus_width == MMC_BUS_WIDTH_4) | ||
733 | { | ||
734 | blksize = (1 << data->blksz_bits) + 2 * 4; | 709 | blksize = (1 << data->blksz_bits) + 2 * 4; |
735 | 710 | ||
736 | wbsd_write_index(host, WBSD_IDX_PBSMSB, ((blksize >> 4) & 0xF0) | 711 | wbsd_write_index(host, WBSD_IDX_PBSMSB, |
737 | | WBSD_DATA_WIDTH); | 712 | ((blksize >> 4) & 0xF0) | WBSD_DATA_WIDTH); |
738 | wbsd_write_index(host, WBSD_IDX_PBSLSB, blksize & 0xFF); | 713 | wbsd_write_index(host, WBSD_IDX_PBSLSB, blksize & 0xFF); |
739 | } | 714 | } else { |
740 | else | ||
741 | { | ||
742 | data->error = MMC_ERR_INVALID; | 715 | data->error = MMC_ERR_INVALID; |
743 | return; | 716 | return; |
744 | } | 717 | } |
@@ -755,14 +728,12 @@ static void wbsd_prepare_data(struct wbsd_host* host, struct mmc_data* data) | |||
755 | /* | 728 | /* |
756 | * DMA transfer? | 729 | * DMA transfer? |
757 | */ | 730 | */ |
758 | if (host->dma >= 0) | 731 | if (host->dma >= 0) { |
759 | { | ||
760 | /* | 732 | /* |
761 | * The buffer for DMA is only 64 kB. | 733 | * The buffer for DMA is only 64 kB. |
762 | */ | 734 | */ |
763 | BUG_ON(host->size > 0x10000); | 735 | BUG_ON(host->size > 0x10000); |
764 | if (host->size > 0x10000) | 736 | if (host->size > 0x10000) { |
765 | { | ||
766 | data->error = MMC_ERR_INVALID; | 737 | data->error = MMC_ERR_INVALID; |
767 | return; | 738 | return; |
768 | } | 739 | } |
@@ -794,9 +765,7 @@ static void wbsd_prepare_data(struct wbsd_host* host, struct mmc_data* data) | |||
794 | * Enable DMA on the host. | 765 | * Enable DMA on the host. |
795 | */ | 766 | */ |
796 | wbsd_write_index(host, WBSD_IDX_DMA, WBSD_DMA_ENABLE); | 767 | wbsd_write_index(host, WBSD_IDX_DMA, WBSD_DMA_ENABLE); |
797 | } | 768 | } else { |
798 | else | ||
799 | { | ||
800 | /* | 769 | /* |
801 | * This flag is used to keep printk | 770 | * This flag is used to keep printk |
802 | * output to a minimum. | 771 | * output to a minimum. |
@@ -817,13 +786,10 @@ static void wbsd_prepare_data(struct wbsd_host* host, struct mmc_data* data) | |||
817 | * Set up FIFO threshold levels (and fill | 786 | * Set up FIFO threshold levels (and fill |
818 | * buffer if doing a write). | 787 | * buffer if doing a write). |
819 | */ | 788 | */ |
820 | if (data->flags & MMC_DATA_READ) | 789 | if (data->flags & MMC_DATA_READ) { |
821 | { | ||
822 | wbsd_write_index(host, WBSD_IDX_FIFOEN, | 790 | wbsd_write_index(host, WBSD_IDX_FIFOEN, |
823 | WBSD_FIFOEN_FULL | 8); | 791 | WBSD_FIFOEN_FULL | 8); |
824 | } | 792 | } else { |
825 | else | ||
826 | { | ||
827 | wbsd_write_index(host, WBSD_IDX_FIFOEN, | 793 | wbsd_write_index(host, WBSD_IDX_FIFOEN, |
828 | WBSD_FIFOEN_EMPTY | 8); | 794 | WBSD_FIFOEN_EMPTY | 8); |
829 | wbsd_fill_fifo(host); | 795 | wbsd_fill_fifo(host); |
@@ -833,7 +799,7 @@ static void wbsd_prepare_data(struct wbsd_host* host, struct mmc_data* data) | |||
833 | data->error = MMC_ERR_NONE; | 799 | data->error = MMC_ERR_NONE; |
834 | } | 800 | } |
835 | 801 | ||
836 | static void wbsd_finish_data(struct wbsd_host* host, struct mmc_data* data) | 802 | static void wbsd_finish_data(struct wbsd_host *host, struct mmc_data *data) |
837 | { | 803 | { |
838 | unsigned long dmaflags; | 804 | unsigned long dmaflags; |
839 | int count; | 805 | int count; |
@@ -851,16 +817,14 @@ static void wbsd_finish_data(struct wbsd_host* host, struct mmc_data* data) | |||
851 | * Wait for the controller to leave data | 817 | * Wait for the controller to leave data |
852 | * transfer state. | 818 | * transfer state. |
853 | */ | 819 | */ |
854 | do | 820 | do { |
855 | { | ||
856 | status = wbsd_read_index(host, WBSD_IDX_STATUS); | 821 | status = wbsd_read_index(host, WBSD_IDX_STATUS); |
857 | } while (status & (WBSD_BLOCK_READ | WBSD_BLOCK_WRITE)); | 822 | } while (status & (WBSD_BLOCK_READ | WBSD_BLOCK_WRITE)); |
858 | 823 | ||
859 | /* | 824 | /* |
860 | * DMA transfer? | 825 | * DMA transfer? |
861 | */ | 826 | */ |
862 | if (host->dma >= 0) | 827 | if (host->dma >= 0) { |
863 | { | ||
864 | /* | 828 | /* |
865 | * Disable DMA on the host. | 829 | * Disable DMA on the host. |
866 | */ | 830 | */ |
@@ -878,16 +842,13 @@ static void wbsd_finish_data(struct wbsd_host* host, struct mmc_data* data) | |||
878 | /* | 842 | /* |
879 | * Any leftover data? | 843 | * Any leftover data? |
880 | */ | 844 | */ |
881 | if (count) | 845 | if (count) { |
882 | { | ||
883 | printk(KERN_ERR "%s: Incomplete DMA transfer. " | 846 | printk(KERN_ERR "%s: Incomplete DMA transfer. " |
884 | "%d bytes left.\n", | 847 | "%d bytes left.\n", |
885 | mmc_hostname(host->mmc), count); | 848 | mmc_hostname(host->mmc), count); |
886 | 849 | ||
887 | data->error = MMC_ERR_FAILED; | 850 | data->error = MMC_ERR_FAILED; |
888 | } | 851 | } else { |
889 | else | ||
890 | { | ||
891 | /* | 852 | /* |
892 | * Transfer data from DMA buffer to | 853 | * Transfer data from DMA buffer to |
893 | * SG list. | 854 | * SG list. |
@@ -910,10 +871,10 @@ static void wbsd_finish_data(struct wbsd_host* host, struct mmc_data* data) | |||
910 | * * | 871 | * * |
911 | \*****************************************************************************/ | 872 | \*****************************************************************************/ |
912 | 873 | ||
913 | static void wbsd_request(struct mmc_host* mmc, struct mmc_request* mrq) | 874 | static void wbsd_request(struct mmc_host *mmc, struct mmc_request *mrq) |
914 | { | 875 | { |
915 | struct wbsd_host* host = mmc_priv(mmc); | 876 | struct wbsd_host *host = mmc_priv(mmc); |
916 | struct mmc_command* cmd; | 877 | struct mmc_command *cmd; |
917 | 878 | ||
918 | /* | 879 | /* |
919 | * Disable tasklets to avoid a deadlock. | 880 | * Disable tasklets to avoid a deadlock. |
@@ -930,8 +891,7 @@ static void wbsd_request(struct mmc_host* mmc, struct mmc_request* mrq) | |||
930 | * If there is no card in the slot then | 891 | * If there is no card in the slot then |
931 | * timeout immediatly. | 892 | * timeout immediatly. |
932 | */ | 893 | */ |
933 | if (!(host->flags & WBSD_FCARD_PRESENT)) | 894 | if (!(host->flags & WBSD_FCARD_PRESENT)) { |
934 | { | ||
935 | cmd->error = MMC_ERR_TIMEOUT; | 895 | cmd->error = MMC_ERR_TIMEOUT; |
936 | goto done; | 896 | goto done; |
937 | } | 897 | } |
@@ -939,8 +899,7 @@ static void wbsd_request(struct mmc_host* mmc, struct mmc_request* mrq) | |||
939 | /* | 899 | /* |
940 | * Does the request include data? | 900 | * Does the request include data? |
941 | */ | 901 | */ |
942 | if (cmd->data) | 902 | if (cmd->data) { |
943 | { | ||
944 | wbsd_prepare_data(host, cmd->data); | 903 | wbsd_prepare_data(host, cmd->data); |
945 | 904 | ||
946 | if (cmd->data->error != MMC_ERR_NONE) | 905 | if (cmd->data->error != MMC_ERR_NONE) |
@@ -954,8 +913,7 @@ static void wbsd_request(struct mmc_host* mmc, struct mmc_request* mrq) | |||
954 | * will be finished after the data has | 913 | * will be finished after the data has |
955 | * transfered. | 914 | * transfered. |
956 | */ | 915 | */ |
957 | if (cmd->data && (cmd->error == MMC_ERR_NONE)) | 916 | if (cmd->data && (cmd->error == MMC_ERR_NONE)) { |
958 | { | ||
959 | /* | 917 | /* |
960 | * Dirty fix for hardware bug. | 918 | * Dirty fix for hardware bug. |
961 | */ | 919 | */ |
@@ -973,14 +931,14 @@ done: | |||
973 | spin_unlock_bh(&host->lock); | 931 | spin_unlock_bh(&host->lock); |
974 | } | 932 | } |
975 | 933 | ||
976 | static void wbsd_set_ios(struct mmc_host* mmc, struct mmc_ios* ios) | 934 | static void wbsd_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) |
977 | { | 935 | { |
978 | struct wbsd_host* host = mmc_priv(mmc); | 936 | struct wbsd_host *host = mmc_priv(mmc); |
979 | u8 clk, setup, pwr; | 937 | u8 clk, setup, pwr; |
980 | 938 | ||
981 | DBGF("clock %uHz busmode %u powermode %u cs %u Vdd %u width %u\n", | 939 | DBGF("clock %uHz busmode %u powermode %u cs %u Vdd %u width %u\n", |
982 | ios->clock, ios->bus_mode, ios->power_mode, ios->chip_select, | 940 | ios->clock, ios->bus_mode, ios->power_mode, ios->chip_select, |
983 | ios->vdd, ios->bus_width); | 941 | ios->vdd, ios->bus_width); |
984 | 942 | ||
985 | spin_lock_bh(&host->lock); | 943 | spin_lock_bh(&host->lock); |
986 | 944 | ||
@@ -1004,8 +962,7 @@ static void wbsd_set_ios(struct mmc_host* mmc, struct mmc_ios* ios) | |||
1004 | * Only write to the clock register when | 962 | * Only write to the clock register when |
1005 | * there is an actual change. | 963 | * there is an actual change. |
1006 | */ | 964 | */ |
1007 | if (clk != host->clk) | 965 | if (clk != host->clk) { |
1008 | { | ||
1009 | wbsd_write_index(host, WBSD_IDX_CLK, clk); | 966 | wbsd_write_index(host, WBSD_IDX_CLK, clk); |
1010 | host->clk = clk; | 967 | host->clk = clk; |
1011 | } | 968 | } |
@@ -1013,8 +970,7 @@ static void wbsd_set_ios(struct mmc_host* mmc, struct mmc_ios* ios) | |||
1013 | /* | 970 | /* |
1014 | * Power up card. | 971 | * Power up card. |
1015 | */ | 972 | */ |
1016 | if (ios->power_mode != MMC_POWER_OFF) | 973 | if (ios->power_mode != MMC_POWER_OFF) { |
1017 | { | ||
1018 | pwr = inb(host->base + WBSD_CSR); | 974 | pwr = inb(host->base + WBSD_CSR); |
1019 | pwr &= ~WBSD_POWER_N; | 975 | pwr &= ~WBSD_POWER_N; |
1020 | outb(pwr, host->base + WBSD_CSR); | 976 | outb(pwr, host->base + WBSD_CSR); |
@@ -1026,23 +982,19 @@ static void wbsd_set_ios(struct mmc_host* mmc, struct mmc_ios* ios) | |||
1026 | * that needs to be disabled. | 982 | * that needs to be disabled. |
1027 | */ | 983 | */ |
1028 | setup = wbsd_read_index(host, WBSD_IDX_SETUP); | 984 | setup = wbsd_read_index(host, WBSD_IDX_SETUP); |
1029 | if (ios->chip_select == MMC_CS_HIGH) | 985 | if (ios->chip_select == MMC_CS_HIGH) { |
1030 | { | ||
1031 | BUG_ON(ios->bus_width != MMC_BUS_WIDTH_1); | 986 | BUG_ON(ios->bus_width != MMC_BUS_WIDTH_1); |
1032 | setup |= WBSD_DAT3_H; | 987 | setup |= WBSD_DAT3_H; |
1033 | host->flags |= WBSD_FIGNORE_DETECT; | 988 | host->flags |= WBSD_FIGNORE_DETECT; |
1034 | } | 989 | } else { |
1035 | else | 990 | if (setup & WBSD_DAT3_H) { |
1036 | { | ||
1037 | if (setup & WBSD_DAT3_H) | ||
1038 | { | ||
1039 | setup &= ~WBSD_DAT3_H; | 991 | setup &= ~WBSD_DAT3_H; |
1040 | 992 | ||
1041 | /* | 993 | /* |
1042 | * We cannot resume card detection immediatly | 994 | * We cannot resume card detection immediatly |
1043 | * because of capacitance and delays in the chip. | 995 | * because of capacitance and delays in the chip. |
1044 | */ | 996 | */ |
1045 | mod_timer(&host->ignore_timer, jiffies + HZ/100); | 997 | mod_timer(&host->ignore_timer, jiffies + HZ / 100); |
1046 | } | 998 | } |
1047 | } | 999 | } |
1048 | wbsd_write_index(host, WBSD_IDX_SETUP, setup); | 1000 | wbsd_write_index(host, WBSD_IDX_SETUP, setup); |
@@ -1056,9 +1008,9 @@ static void wbsd_set_ios(struct mmc_host* mmc, struct mmc_ios* ios) | |||
1056 | spin_unlock_bh(&host->lock); | 1008 | spin_unlock_bh(&host->lock); |
1057 | } | 1009 | } |
1058 | 1010 | ||
1059 | static int wbsd_get_ro(struct mmc_host* mmc) | 1011 | static int wbsd_get_ro(struct mmc_host *mmc) |
1060 | { | 1012 | { |
1061 | struct wbsd_host* host = mmc_priv(mmc); | 1013 | struct wbsd_host *host = mmc_priv(mmc); |
1062 | u8 csr; | 1014 | u8 csr; |
1063 | 1015 | ||
1064 | spin_lock_bh(&host->lock); | 1016 | spin_lock_bh(&host->lock); |
@@ -1096,7 +1048,7 @@ static struct mmc_host_ops wbsd_ops = { | |||
1096 | 1048 | ||
1097 | static void wbsd_reset_ignore(unsigned long data) | 1049 | static void wbsd_reset_ignore(unsigned long data) |
1098 | { | 1050 | { |
1099 | struct wbsd_host *host = (struct wbsd_host*)data; | 1051 | struct wbsd_host *host = (struct wbsd_host *)data; |
1100 | 1052 | ||
1101 | BUG_ON(host == NULL); | 1053 | BUG_ON(host == NULL); |
1102 | 1054 | ||
@@ -1119,7 +1071,7 @@ static void wbsd_reset_ignore(unsigned long data) | |||
1119 | * Tasklets | 1071 | * Tasklets |
1120 | */ | 1072 | */ |
1121 | 1073 | ||
1122 | static inline struct mmc_data* wbsd_get_data(struct wbsd_host* host) | 1074 | static inline struct mmc_data *wbsd_get_data(struct wbsd_host *host) |
1123 | { | 1075 | { |
1124 | WARN_ON(!host->mrq); | 1076 | WARN_ON(!host->mrq); |
1125 | if (!host->mrq) | 1077 | if (!host->mrq) |
@@ -1138,14 +1090,13 @@ static inline struct mmc_data* wbsd_get_data(struct wbsd_host* host) | |||
1138 | 1090 | ||
1139 | static void wbsd_tasklet_card(unsigned long param) | 1091 | static void wbsd_tasklet_card(unsigned long param) |
1140 | { | 1092 | { |
1141 | struct wbsd_host* host = (struct wbsd_host*)param; | 1093 | struct wbsd_host *host = (struct wbsd_host *)param; |
1142 | u8 csr; | 1094 | u8 csr; |
1143 | int delay = -1; | 1095 | int delay = -1; |
1144 | 1096 | ||
1145 | spin_lock(&host->lock); | 1097 | spin_lock(&host->lock); |
1146 | 1098 | ||
1147 | if (host->flags & WBSD_FIGNORE_DETECT) | 1099 | if (host->flags & WBSD_FIGNORE_DETECT) { |
1148 | { | ||
1149 | spin_unlock(&host->lock); | 1100 | spin_unlock(&host->lock); |
1150 | return; | 1101 | return; |
1151 | } | 1102 | } |
@@ -1153,23 +1104,18 @@ static void wbsd_tasklet_card(unsigned long param) | |||
1153 | csr = inb(host->base + WBSD_CSR); | 1104 | csr = inb(host->base + WBSD_CSR); |
1154 | WARN_ON(csr == 0xff); | 1105 | WARN_ON(csr == 0xff); |
1155 | 1106 | ||
1156 | if (csr & WBSD_CARDPRESENT) | 1107 | if (csr & WBSD_CARDPRESENT) { |
1157 | { | 1108 | if (!(host->flags & WBSD_FCARD_PRESENT)) { |
1158 | if (!(host->flags & WBSD_FCARD_PRESENT)) | ||
1159 | { | ||
1160 | DBG("Card inserted\n"); | 1109 | DBG("Card inserted\n"); |
1161 | host->flags |= WBSD_FCARD_PRESENT; | 1110 | host->flags |= WBSD_FCARD_PRESENT; |
1162 | 1111 | ||
1163 | delay = 500; | 1112 | delay = 500; |
1164 | } | 1113 | } |
1165 | } | 1114 | } else if (host->flags & WBSD_FCARD_PRESENT) { |
1166 | else if (host->flags & WBSD_FCARD_PRESENT) | ||
1167 | { | ||
1168 | DBG("Card removed\n"); | 1115 | DBG("Card removed\n"); |
1169 | host->flags &= ~WBSD_FCARD_PRESENT; | 1116 | host->flags &= ~WBSD_FCARD_PRESENT; |
1170 | 1117 | ||
1171 | if (host->mrq) | 1118 | if (host->mrq) { |
1172 | { | ||
1173 | printk(KERN_ERR "%s: Card removed during transfer!\n", | 1119 | printk(KERN_ERR "%s: Card removed during transfer!\n", |
1174 | mmc_hostname(host->mmc)); | 1120 | mmc_hostname(host->mmc)); |
1175 | wbsd_reset(host); | 1121 | wbsd_reset(host); |
@@ -1193,8 +1139,8 @@ static void wbsd_tasklet_card(unsigned long param) | |||
1193 | 1139 | ||
1194 | static void wbsd_tasklet_fifo(unsigned long param) | 1140 | static void wbsd_tasklet_fifo(unsigned long param) |
1195 | { | 1141 | { |
1196 | struct wbsd_host* host = (struct wbsd_host*)param; | 1142 | struct wbsd_host *host = (struct wbsd_host *)param; |
1197 | struct mmc_data* data; | 1143 | struct mmc_data *data; |
1198 | 1144 | ||
1199 | spin_lock(&host->lock); | 1145 | spin_lock(&host->lock); |
1200 | 1146 | ||
@@ -1213,8 +1159,7 @@ static void wbsd_tasklet_fifo(unsigned long param) | |||
1213 | /* | 1159 | /* |
1214 | * Done? | 1160 | * Done? |
1215 | */ | 1161 | */ |
1216 | if (host->size == data->bytes_xfered) | 1162 | if (host->size == data->bytes_xfered) { |
1217 | { | ||
1218 | wbsd_write_index(host, WBSD_IDX_FIFOEN, 0); | 1163 | wbsd_write_index(host, WBSD_IDX_FIFOEN, 0); |
1219 | tasklet_schedule(&host->finish_tasklet); | 1164 | tasklet_schedule(&host->finish_tasklet); |
1220 | } | 1165 | } |
@@ -1225,8 +1170,8 @@ end: | |||
1225 | 1170 | ||
1226 | static void wbsd_tasklet_crc(unsigned long param) | 1171 | static void wbsd_tasklet_crc(unsigned long param) |
1227 | { | 1172 | { |
1228 | struct wbsd_host* host = (struct wbsd_host*)param; | 1173 | struct wbsd_host *host = (struct wbsd_host *)param; |
1229 | struct mmc_data* data; | 1174 | struct mmc_data *data; |
1230 | 1175 | ||
1231 | spin_lock(&host->lock); | 1176 | spin_lock(&host->lock); |
1232 | 1177 | ||
@@ -1249,8 +1194,8 @@ end: | |||
1249 | 1194 | ||
1250 | static void wbsd_tasklet_timeout(unsigned long param) | 1195 | static void wbsd_tasklet_timeout(unsigned long param) |
1251 | { | 1196 | { |
1252 | struct wbsd_host* host = (struct wbsd_host*)param; | 1197 | struct wbsd_host *host = (struct wbsd_host *)param; |
1253 | struct mmc_data* data; | 1198 | struct mmc_data *data; |
1254 | 1199 | ||
1255 | spin_lock(&host->lock); | 1200 | spin_lock(&host->lock); |
1256 | 1201 | ||
@@ -1273,8 +1218,8 @@ end: | |||
1273 | 1218 | ||
1274 | static void wbsd_tasklet_finish(unsigned long param) | 1219 | static void wbsd_tasklet_finish(unsigned long param) |
1275 | { | 1220 | { |
1276 | struct wbsd_host* host = (struct wbsd_host*)param; | 1221 | struct wbsd_host *host = (struct wbsd_host *)param; |
1277 | struct mmc_data* data; | 1222 | struct mmc_data *data; |
1278 | 1223 | ||
1279 | spin_lock(&host->lock); | 1224 | spin_lock(&host->lock); |
1280 | 1225 | ||
@@ -1294,14 +1239,13 @@ end: | |||
1294 | 1239 | ||
1295 | static void wbsd_tasklet_block(unsigned long param) | 1240 | static void wbsd_tasklet_block(unsigned long param) |
1296 | { | 1241 | { |
1297 | struct wbsd_host* host = (struct wbsd_host*)param; | 1242 | struct wbsd_host *host = (struct wbsd_host *)param; |
1298 | struct mmc_data* data; | 1243 | struct mmc_data *data; |
1299 | 1244 | ||
1300 | spin_lock(&host->lock); | 1245 | spin_lock(&host->lock); |
1301 | 1246 | ||
1302 | if ((wbsd_read_index(host, WBSD_IDX_CRCSTATUS) & WBSD_CRC_MASK) != | 1247 | if ((wbsd_read_index(host, WBSD_IDX_CRCSTATUS) & WBSD_CRC_MASK) != |
1303 | WBSD_CRC_OK) | 1248 | WBSD_CRC_OK) { |
1304 | { | ||
1305 | data = wbsd_get_data(host); | 1249 | data = wbsd_get_data(host); |
1306 | if (!data) | 1250 | if (!data) |
1307 | goto end; | 1251 | goto end; |
@@ -1323,7 +1267,7 @@ end: | |||
1323 | 1267 | ||
1324 | static irqreturn_t wbsd_irq(int irq, void *dev_id, struct pt_regs *regs) | 1268 | static irqreturn_t wbsd_irq(int irq, void *dev_id, struct pt_regs *regs) |
1325 | { | 1269 | { |
1326 | struct wbsd_host* host = dev_id; | 1270 | struct wbsd_host *host = dev_id; |
1327 | int isr; | 1271 | int isr; |
1328 | 1272 | ||
1329 | isr = inb(host->base + WBSD_ISR); | 1273 | isr = inb(host->base + WBSD_ISR); |
@@ -1365,10 +1309,10 @@ static irqreturn_t wbsd_irq(int irq, void *dev_id, struct pt_regs *regs) | |||
1365 | * Allocate/free MMC structure. | 1309 | * Allocate/free MMC structure. |
1366 | */ | 1310 | */ |
1367 | 1311 | ||
1368 | static int __devinit wbsd_alloc_mmc(struct device* dev) | 1312 | static int __devinit wbsd_alloc_mmc(struct device *dev) |
1369 | { | 1313 | { |
1370 | struct mmc_host* mmc; | 1314 | struct mmc_host *mmc; |
1371 | struct wbsd_host* host; | 1315 | struct wbsd_host *host; |
1372 | 1316 | ||
1373 | /* | 1317 | /* |
1374 | * Allocate MMC structure. | 1318 | * Allocate MMC structure. |
@@ -1388,7 +1332,7 @@ static int __devinit wbsd_alloc_mmc(struct device* dev) | |||
1388 | mmc->ops = &wbsd_ops; | 1332 | mmc->ops = &wbsd_ops; |
1389 | mmc->f_min = 375000; | 1333 | mmc->f_min = 375000; |
1390 | mmc->f_max = 24000000; | 1334 | mmc->f_max = 24000000; |
1391 | mmc->ocr_avail = MMC_VDD_32_33|MMC_VDD_33_34; | 1335 | mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; |
1392 | mmc->caps = MMC_CAP_4_BIT_DATA; | 1336 | mmc->caps = MMC_CAP_4_BIT_DATA; |
1393 | 1337 | ||
1394 | spin_lock_init(&host->lock); | 1338 | spin_lock_init(&host->lock); |
@@ -1424,10 +1368,10 @@ static int __devinit wbsd_alloc_mmc(struct device* dev) | |||
1424 | return 0; | 1368 | return 0; |
1425 | } | 1369 | } |
1426 | 1370 | ||
1427 | static void __devexit wbsd_free_mmc(struct device* dev) | 1371 | static void __devexit wbsd_free_mmc(struct device *dev) |
1428 | { | 1372 | { |
1429 | struct mmc_host* mmc; | 1373 | struct mmc_host *mmc; |
1430 | struct wbsd_host* host; | 1374 | struct wbsd_host *host; |
1431 | 1375 | ||
1432 | mmc = dev_get_drvdata(dev); | 1376 | mmc = dev_get_drvdata(dev); |
1433 | if (!mmc) | 1377 | if (!mmc) |
@@ -1447,7 +1391,7 @@ static void __devexit wbsd_free_mmc(struct device* dev) | |||
1447 | * Scan for known chip id:s | 1391 | * Scan for known chip id:s |
1448 | */ | 1392 | */ |
1449 | 1393 | ||
1450 | static int __devinit wbsd_scan(struct wbsd_host* host) | 1394 | static int __devinit wbsd_scan(struct wbsd_host *host) |
1451 | { | 1395 | { |
1452 | int i, j, k; | 1396 | int i, j, k; |
1453 | int id; | 1397 | int id; |
@@ -1477,16 +1421,14 @@ static int __devinit wbsd_scan(struct wbsd_host* host) | |||
1477 | wbsd_lock_config(host); | 1421 | wbsd_lock_config(host); |
1478 | 1422 | ||
1479 | for (k = 0; k < ARRAY_SIZE(valid_ids); k++) { | 1423 | for (k = 0; k < ARRAY_SIZE(valid_ids); k++) { |
1480 | if (id == valid_ids[k]) | 1424 | if (id == valid_ids[k]) { |
1481 | { | ||
1482 | host->chip_id = id; | 1425 | host->chip_id = id; |
1483 | 1426 | ||
1484 | return 0; | 1427 | return 0; |
1485 | } | 1428 | } |
1486 | } | 1429 | } |
1487 | 1430 | ||
1488 | if (id != 0xFFFF) | 1431 | if (id != 0xFFFF) { |
1489 | { | ||
1490 | DBG("Unknown hardware (id %x) found at %x\n", | 1432 | DBG("Unknown hardware (id %x) found at %x\n", |
1491 | id, config_ports[i]); | 1433 | id, config_ports[i]); |
1492 | } | 1434 | } |
@@ -1505,7 +1447,7 @@ static int __devinit wbsd_scan(struct wbsd_host* host) | |||
1505 | * Allocate/free io port ranges | 1447 | * Allocate/free io port ranges |
1506 | */ | 1448 | */ |
1507 | 1449 | ||
1508 | static int __devinit wbsd_request_region(struct wbsd_host* host, int base) | 1450 | static int __devinit wbsd_request_region(struct wbsd_host *host, int base) |
1509 | { | 1451 | { |
1510 | if (io & 0x7) | 1452 | if (io & 0x7) |
1511 | return -EINVAL; | 1453 | return -EINVAL; |
@@ -1518,7 +1460,7 @@ static int __devinit wbsd_request_region(struct wbsd_host* host, int base) | |||
1518 | return 0; | 1460 | return 0; |
1519 | } | 1461 | } |
1520 | 1462 | ||
1521 | static void __devexit wbsd_release_regions(struct wbsd_host* host) | 1463 | static void __devexit wbsd_release_regions(struct wbsd_host *host) |
1522 | { | 1464 | { |
1523 | if (host->base) | 1465 | if (host->base) |
1524 | release_region(host->base, 8); | 1466 | release_region(host->base, 8); |
@@ -1535,7 +1477,7 @@ static void __devexit wbsd_release_regions(struct wbsd_host* host) | |||
1535 | * Allocate/free DMA port and buffer | 1477 | * Allocate/free DMA port and buffer |
1536 | */ | 1478 | */ |
1537 | 1479 | ||
1538 | static void __devinit wbsd_request_dma(struct wbsd_host* host, int dma) | 1480 | static void __devinit wbsd_request_dma(struct wbsd_host *host, int dma) |
1539 | { | 1481 | { |
1540 | if (dma < 0) | 1482 | if (dma < 0) |
1541 | return; | 1483 | return; |
@@ -1579,8 +1521,8 @@ kfree: | |||
1579 | */ | 1521 | */ |
1580 | BUG_ON(1); | 1522 | BUG_ON(1); |
1581 | 1523 | ||
1582 | dma_unmap_single(host->mmc->dev, host->dma_addr, WBSD_DMA_SIZE, | 1524 | dma_unmap_single(host->mmc->dev, host->dma_addr, |
1583 | DMA_BIDIRECTIONAL); | 1525 | WBSD_DMA_SIZE, DMA_BIDIRECTIONAL); |
1584 | host->dma_addr = (dma_addr_t)NULL; | 1526 | host->dma_addr = (dma_addr_t)NULL; |
1585 | 1527 | ||
1586 | kfree(host->dma_buffer); | 1528 | kfree(host->dma_buffer); |
@@ -1594,11 +1536,12 @@ err: | |||
1594 | "Falling back on FIFO.\n", dma); | 1536 | "Falling back on FIFO.\n", dma); |
1595 | } | 1537 | } |
1596 | 1538 | ||
1597 | static void __devexit wbsd_release_dma(struct wbsd_host* host) | 1539 | static void __devexit wbsd_release_dma(struct wbsd_host *host) |
1598 | { | 1540 | { |
1599 | if (host->dma_addr) | 1541 | if (host->dma_addr) { |
1600 | dma_unmap_single(host->mmc->dev, host->dma_addr, WBSD_DMA_SIZE, | 1542 | dma_unmap_single(host->mmc->dev, host->dma_addr, |
1601 | DMA_BIDIRECTIONAL); | 1543 | WBSD_DMA_SIZE, DMA_BIDIRECTIONAL); |
1544 | } | ||
1602 | kfree(host->dma_buffer); | 1545 | kfree(host->dma_buffer); |
1603 | if (host->dma >= 0) | 1546 | if (host->dma >= 0) |
1604 | free_dma(host->dma); | 1547 | free_dma(host->dma); |
@@ -1612,7 +1555,7 @@ static void __devexit wbsd_release_dma(struct wbsd_host* host) | |||
1612 | * Allocate/free IRQ. | 1555 | * Allocate/free IRQ. |
1613 | */ | 1556 | */ |
1614 | 1557 | ||
1615 | static int __devinit wbsd_request_irq(struct wbsd_host* host, int irq) | 1558 | static int __devinit wbsd_request_irq(struct wbsd_host *host, int irq) |
1616 | { | 1559 | { |
1617 | int ret; | 1560 | int ret; |
1618 | 1561 | ||
@@ -1629,17 +1572,23 @@ static int __devinit wbsd_request_irq(struct wbsd_host* host, int irq) | |||
1629 | /* | 1572 | /* |
1630 | * Set up tasklets. | 1573 | * Set up tasklets. |
1631 | */ | 1574 | */ |
1632 | tasklet_init(&host->card_tasklet, wbsd_tasklet_card, (unsigned long)host); | 1575 | tasklet_init(&host->card_tasklet, wbsd_tasklet_card, |
1633 | tasklet_init(&host->fifo_tasklet, wbsd_tasklet_fifo, (unsigned long)host); | 1576 | (unsigned long)host); |
1634 | tasklet_init(&host->crc_tasklet, wbsd_tasklet_crc, (unsigned long)host); | 1577 | tasklet_init(&host->fifo_tasklet, wbsd_tasklet_fifo, |
1635 | tasklet_init(&host->timeout_tasklet, wbsd_tasklet_timeout, (unsigned long)host); | 1578 | (unsigned long)host); |
1636 | tasklet_init(&host->finish_tasklet, wbsd_tasklet_finish, (unsigned long)host); | 1579 | tasklet_init(&host->crc_tasklet, wbsd_tasklet_crc, |
1637 | tasklet_init(&host->block_tasklet, wbsd_tasklet_block, (unsigned long)host); | 1580 | (unsigned long)host); |
1581 | tasklet_init(&host->timeout_tasklet, wbsd_tasklet_timeout, | ||
1582 | (unsigned long)host); | ||
1583 | tasklet_init(&host->finish_tasklet, wbsd_tasklet_finish, | ||
1584 | (unsigned long)host); | ||
1585 | tasklet_init(&host->block_tasklet, wbsd_tasklet_block, | ||
1586 | (unsigned long)host); | ||
1638 | 1587 | ||
1639 | return 0; | 1588 | return 0; |
1640 | } | 1589 | } |
1641 | 1590 | ||
1642 | static void __devexit wbsd_release_irq(struct wbsd_host* host) | 1591 | static void __devexit wbsd_release_irq(struct wbsd_host *host) |
1643 | { | 1592 | { |
1644 | if (!host->irq) | 1593 | if (!host->irq) |
1645 | return; | 1594 | return; |
@@ -1660,7 +1609,7 @@ static void __devexit wbsd_release_irq(struct wbsd_host* host) | |||
1660 | * Allocate all resources for the host. | 1609 | * Allocate all resources for the host. |
1661 | */ | 1610 | */ |
1662 | 1611 | ||
1663 | static int __devinit wbsd_request_resources(struct wbsd_host* host, | 1612 | static int __devinit wbsd_request_resources(struct wbsd_host *host, |
1664 | int base, int irq, int dma) | 1613 | int base, int irq, int dma) |
1665 | { | 1614 | { |
1666 | int ret; | 1615 | int ret; |
@@ -1691,7 +1640,7 @@ static int __devinit wbsd_request_resources(struct wbsd_host* host, | |||
1691 | * Release all resources for the host. | 1640 | * Release all resources for the host. |
1692 | */ | 1641 | */ |
1693 | 1642 | ||
1694 | static void __devexit wbsd_release_resources(struct wbsd_host* host) | 1643 | static void __devexit wbsd_release_resources(struct wbsd_host *host) |
1695 | { | 1644 | { |
1696 | wbsd_release_dma(host); | 1645 | wbsd_release_dma(host); |
1697 | wbsd_release_irq(host); | 1646 | wbsd_release_irq(host); |
@@ -1702,7 +1651,7 @@ static void __devexit wbsd_release_resources(struct wbsd_host* host) | |||
1702 | * Configure the resources the chip should use. | 1651 | * Configure the resources the chip should use. |
1703 | */ | 1652 | */ |
1704 | 1653 | ||
1705 | static void wbsd_chip_config(struct wbsd_host* host) | 1654 | static void wbsd_chip_config(struct wbsd_host *host) |
1706 | { | 1655 | { |
1707 | wbsd_unlock_config(host); | 1656 | wbsd_unlock_config(host); |
1708 | 1657 | ||
@@ -1746,7 +1695,7 @@ static void wbsd_chip_config(struct wbsd_host* host) | |||
1746 | * Check that configured resources are correct. | 1695 | * Check that configured resources are correct. |
1747 | */ | 1696 | */ |
1748 | 1697 | ||
1749 | static int wbsd_chip_validate(struct wbsd_host* host) | 1698 | static int wbsd_chip_validate(struct wbsd_host *host) |
1750 | { | 1699 | { |
1751 | int base, irq, dma; | 1700 | int base, irq, dma; |
1752 | 1701 | ||
@@ -1786,7 +1735,7 @@ static int wbsd_chip_validate(struct wbsd_host* host) | |||
1786 | * Powers down the SD function | 1735 | * Powers down the SD function |
1787 | */ | 1736 | */ |
1788 | 1737 | ||
1789 | static void wbsd_chip_poweroff(struct wbsd_host* host) | 1738 | static void wbsd_chip_poweroff(struct wbsd_host *host) |
1790 | { | 1739 | { |
1791 | wbsd_unlock_config(host); | 1740 | wbsd_unlock_config(host); |
1792 | 1741 | ||
@@ -1802,11 +1751,11 @@ static void wbsd_chip_poweroff(struct wbsd_host* host) | |||
1802 | * * | 1751 | * * |
1803 | \*****************************************************************************/ | 1752 | \*****************************************************************************/ |
1804 | 1753 | ||
1805 | static int __devinit wbsd_init(struct device* dev, int base, int irq, int dma, | 1754 | static int __devinit wbsd_init(struct device *dev, int base, int irq, int dma, |
1806 | int pnp) | 1755 | int pnp) |
1807 | { | 1756 | { |
1808 | struct wbsd_host* host = NULL; | 1757 | struct wbsd_host *host = NULL; |
1809 | struct mmc_host* mmc = NULL; | 1758 | struct mmc_host *mmc = NULL; |
1810 | int ret; | 1759 | int ret; |
1811 | 1760 | ||
1812 | ret = wbsd_alloc_mmc(dev); | 1761 | ret = wbsd_alloc_mmc(dev); |
@@ -1820,16 +1769,12 @@ static int __devinit wbsd_init(struct device* dev, int base, int irq, int dma, | |||
1820 | * Scan for hardware. | 1769 | * Scan for hardware. |
1821 | */ | 1770 | */ |
1822 | ret = wbsd_scan(host); | 1771 | ret = wbsd_scan(host); |
1823 | if (ret) | 1772 | if (ret) { |
1824 | { | 1773 | if (pnp && (ret == -ENODEV)) { |
1825 | if (pnp && (ret == -ENODEV)) | ||
1826 | { | ||
1827 | printk(KERN_WARNING DRIVER_NAME | 1774 | printk(KERN_WARNING DRIVER_NAME |
1828 | ": Unable to confirm device presence. You may " | 1775 | ": Unable to confirm device presence. You may " |
1829 | "experience lock-ups.\n"); | 1776 | "experience lock-ups.\n"); |
1830 | } | 1777 | } else { |
1831 | else | ||
1832 | { | ||
1833 | wbsd_free_mmc(dev); | 1778 | wbsd_free_mmc(dev); |
1834 | return ret; | 1779 | return ret; |
1835 | } | 1780 | } |
@@ -1839,8 +1784,7 @@ static int __devinit wbsd_init(struct device* dev, int base, int irq, int dma, | |||
1839 | * Request resources. | 1784 | * Request resources. |
1840 | */ | 1785 | */ |
1841 | ret = wbsd_request_resources(host, io, irq, dma); | 1786 | ret = wbsd_request_resources(host, io, irq, dma); |
1842 | if (ret) | 1787 | if (ret) { |
1843 | { | ||
1844 | wbsd_release_resources(host); | 1788 | wbsd_release_resources(host); |
1845 | wbsd_free_mmc(dev); | 1789 | wbsd_free_mmc(dev); |
1846 | return ret; | 1790 | return ret; |
@@ -1849,18 +1793,15 @@ static int __devinit wbsd_init(struct device* dev, int base, int irq, int dma, | |||
1849 | /* | 1793 | /* |
1850 | * See if chip needs to be configured. | 1794 | * See if chip needs to be configured. |
1851 | */ | 1795 | */ |
1852 | if (pnp) | 1796 | if (pnp) { |
1853 | { | 1797 | if ((host->config != 0) && !wbsd_chip_validate(host)) { |
1854 | if ((host->config != 0) && !wbsd_chip_validate(host)) | ||
1855 | { | ||
1856 | printk(KERN_WARNING DRIVER_NAME | 1798 | printk(KERN_WARNING DRIVER_NAME |
1857 | ": PnP active but chip not configured! " | 1799 | ": PnP active but chip not configured! " |
1858 | "You probably have a buggy BIOS. " | 1800 | "You probably have a buggy BIOS. " |
1859 | "Configuring chip manually.\n"); | 1801 | "Configuring chip manually.\n"); |
1860 | wbsd_chip_config(host); | 1802 | wbsd_chip_config(host); |
1861 | } | 1803 | } |
1862 | } | 1804 | } else |
1863 | else | ||
1864 | wbsd_chip_config(host); | 1805 | wbsd_chip_config(host); |
1865 | 1806 | ||
1866 | /* | 1807 | /* |
@@ -1868,8 +1809,7 @@ static int __devinit wbsd_init(struct device* dev, int base, int irq, int dma, | |||
1868 | * Not tested. | 1809 | * Not tested. |
1869 | */ | 1810 | */ |
1870 | #ifdef CONFIG_PM | 1811 | #ifdef CONFIG_PM |
1871 | if (host->config) | 1812 | if (host->config) { |
1872 | { | ||
1873 | wbsd_unlock_config(host); | 1813 | wbsd_unlock_config(host); |
1874 | wbsd_write_config(host, WBSD_CONF_PME, 0xA0); | 1814 | wbsd_write_config(host, WBSD_CONF_PME, 0xA0); |
1875 | wbsd_lock_config(host); | 1815 | wbsd_lock_config(host); |
@@ -1902,10 +1842,10 @@ static int __devinit wbsd_init(struct device* dev, int base, int irq, int dma, | |||
1902 | return 0; | 1842 | return 0; |
1903 | } | 1843 | } |
1904 | 1844 | ||
1905 | static void __devexit wbsd_shutdown(struct device* dev, int pnp) | 1845 | static void __devexit wbsd_shutdown(struct device *dev, int pnp) |
1906 | { | 1846 | { |
1907 | struct mmc_host* mmc = dev_get_drvdata(dev); | 1847 | struct mmc_host *mmc = dev_get_drvdata(dev); |
1908 | struct wbsd_host* host; | 1848 | struct wbsd_host *host; |
1909 | 1849 | ||
1910 | if (!mmc) | 1850 | if (!mmc) |
1911 | return; | 1851 | return; |
@@ -1929,12 +1869,12 @@ static void __devexit wbsd_shutdown(struct device* dev, int pnp) | |||
1929 | * Non-PnP | 1869 | * Non-PnP |
1930 | */ | 1870 | */ |
1931 | 1871 | ||
1932 | static int __devinit wbsd_probe(struct platform_device* dev) | 1872 | static int __devinit wbsd_probe(struct platform_device *dev) |
1933 | { | 1873 | { |
1934 | return wbsd_init(&dev->dev, io, irq, dma, 0); | 1874 | return wbsd_init(&dev->dev, io, irq, dma, 0); |
1935 | } | 1875 | } |
1936 | 1876 | ||
1937 | static int __devexit wbsd_remove(struct platform_device* dev) | 1877 | static int __devexit wbsd_remove(struct platform_device *dev) |
1938 | { | 1878 | { |
1939 | wbsd_shutdown(&dev->dev, 0); | 1879 | wbsd_shutdown(&dev->dev, 0); |
1940 | 1880 | ||
@@ -1948,7 +1888,7 @@ static int __devexit wbsd_remove(struct platform_device* dev) | |||
1948 | #ifdef CONFIG_PNP | 1888 | #ifdef CONFIG_PNP |
1949 | 1889 | ||
1950 | static int __devinit | 1890 | static int __devinit |
1951 | wbsd_pnp_probe(struct pnp_dev * pnpdev, const struct pnp_device_id *dev_id) | 1891 | wbsd_pnp_probe(struct pnp_dev *pnpdev, const struct pnp_device_id *dev_id) |
1952 | { | 1892 | { |
1953 | int io, irq, dma; | 1893 | int io, irq, dma; |
1954 | 1894 | ||
@@ -1967,7 +1907,7 @@ wbsd_pnp_probe(struct pnp_dev * pnpdev, const struct pnp_device_id *dev_id) | |||
1967 | return wbsd_init(&pnpdev->dev, io, irq, dma, 1); | 1907 | return wbsd_init(&pnpdev->dev, io, irq, dma, 1); |
1968 | } | 1908 | } |
1969 | 1909 | ||
1970 | static void __devexit wbsd_pnp_remove(struct pnp_dev * dev) | 1910 | static void __devexit wbsd_pnp_remove(struct pnp_dev *dev) |
1971 | { | 1911 | { |
1972 | wbsd_shutdown(&dev->dev, 1); | 1912 | wbsd_shutdown(&dev->dev, 1); |
1973 | } | 1913 | } |
@@ -1980,37 +1920,54 @@ static void __devexit wbsd_pnp_remove(struct pnp_dev * dev) | |||
1980 | 1920 | ||
1981 | #ifdef CONFIG_PM | 1921 | #ifdef CONFIG_PM |
1982 | 1922 | ||
1983 | static int wbsd_suspend(struct platform_device *dev, pm_message_t state) | 1923 | static int wbsd_suspend(struct wbsd_host *host, pm_message_t state) |
1924 | { | ||
1925 | BUG_ON(host == NULL); | ||
1926 | |||
1927 | return mmc_suspend_host(host->mmc, state); | ||
1928 | } | ||
1929 | |||
1930 | static int wbsd_resume(struct wbsd_host *host) | ||
1931 | { | ||
1932 | BUG_ON(host == NULL); | ||
1933 | |||
1934 | wbsd_init_device(host); | ||
1935 | |||
1936 | return mmc_resume_host(host->mmc); | ||
1937 | } | ||
1938 | |||
1939 | static int wbsd_platform_suspend(struct platform_device *dev, | ||
1940 | pm_message_t state) | ||
1984 | { | 1941 | { |
1985 | struct mmc_host *mmc = platform_get_drvdata(dev); | 1942 | struct mmc_host *mmc = platform_get_drvdata(dev); |
1986 | struct wbsd_host *host; | 1943 | struct wbsd_host *host; |
1987 | int ret; | 1944 | int ret; |
1988 | 1945 | ||
1989 | if (!mmc) | 1946 | if (mmc == NULL) |
1990 | return 0; | 1947 | return 0; |
1991 | 1948 | ||
1992 | DBG("Suspending...\n"); | 1949 | DBGF("Suspending...\n"); |
1993 | |||
1994 | ret = mmc_suspend_host(mmc, state); | ||
1995 | if (!ret) | ||
1996 | return ret; | ||
1997 | 1950 | ||
1998 | host = mmc_priv(mmc); | 1951 | host = mmc_priv(mmc); |
1999 | 1952 | ||
1953 | ret = wbsd_suspend(host, state); | ||
1954 | if (ret) | ||
1955 | return ret; | ||
1956 | |||
2000 | wbsd_chip_poweroff(host); | 1957 | wbsd_chip_poweroff(host); |
2001 | 1958 | ||
2002 | return 0; | 1959 | return 0; |
2003 | } | 1960 | } |
2004 | 1961 | ||
2005 | static int wbsd_resume(struct platform_device *dev) | 1962 | static int wbsd_platform_resume(struct platform_device *dev) |
2006 | { | 1963 | { |
2007 | struct mmc_host *mmc = platform_get_drvdata(dev); | 1964 | struct mmc_host *mmc = platform_get_drvdata(dev); |
2008 | struct wbsd_host *host; | 1965 | struct wbsd_host *host; |
2009 | 1966 | ||
2010 | if (!mmc) | 1967 | if (mmc == NULL) |
2011 | return 0; | 1968 | return 0; |
2012 | 1969 | ||
2013 | DBG("Resuming...\n"); | 1970 | DBGF("Resuming...\n"); |
2014 | 1971 | ||
2015 | host = mmc_priv(mmc); | 1972 | host = mmc_priv(mmc); |
2016 | 1973 | ||
@@ -2021,15 +1978,68 @@ static int wbsd_resume(struct platform_device *dev) | |||
2021 | */ | 1978 | */ |
2022 | mdelay(5); | 1979 | mdelay(5); |
2023 | 1980 | ||
2024 | wbsd_init_device(host); | 1981 | return wbsd_resume(host); |
1982 | } | ||
1983 | |||
1984 | #ifdef CONFIG_PNP | ||
1985 | |||
1986 | static int wbsd_pnp_suspend(struct pnp_dev *pnp_dev, pm_message_t state) | ||
1987 | { | ||
1988 | struct mmc_host *mmc = dev_get_drvdata(&pnp_dev->dev); | ||
1989 | struct wbsd_host *host; | ||
1990 | |||
1991 | if (mmc == NULL) | ||
1992 | return 0; | ||
1993 | |||
1994 | DBGF("Suspending...\n"); | ||
1995 | |||
1996 | host = mmc_priv(mmc); | ||
1997 | |||
1998 | return wbsd_suspend(host, state); | ||
1999 | } | ||
2000 | |||
2001 | static int wbsd_pnp_resume(struct pnp_dev *pnp_dev) | ||
2002 | { | ||
2003 | struct mmc_host *mmc = dev_get_drvdata(&pnp_dev->dev); | ||
2004 | struct wbsd_host *host; | ||
2005 | |||
2006 | if (mmc == NULL) | ||
2007 | return 0; | ||
2008 | |||
2009 | DBGF("Resuming...\n"); | ||
2025 | 2010 | ||
2026 | return mmc_resume_host(mmc); | 2011 | host = mmc_priv(mmc); |
2012 | |||
2013 | /* | ||
2014 | * See if chip needs to be configured. | ||
2015 | */ | ||
2016 | if (host->config != 0) { | ||
2017 | if (!wbsd_chip_validate(host)) { | ||
2018 | printk(KERN_WARNING DRIVER_NAME | ||
2019 | ": PnP active but chip not configured! " | ||
2020 | "You probably have a buggy BIOS. " | ||
2021 | "Configuring chip manually.\n"); | ||
2022 | wbsd_chip_config(host); | ||
2023 | } | ||
2024 | } | ||
2025 | |||
2026 | /* | ||
2027 | * Allow device to initialise itself properly. | ||
2028 | */ | ||
2029 | mdelay(5); | ||
2030 | |||
2031 | return wbsd_resume(host); | ||
2027 | } | 2032 | } |
2028 | 2033 | ||
2034 | #endif /* CONFIG_PNP */ | ||
2035 | |||
2029 | #else /* CONFIG_PM */ | 2036 | #else /* CONFIG_PM */ |
2030 | 2037 | ||
2031 | #define wbsd_suspend NULL | 2038 | #define wbsd_platform_suspend NULL |
2032 | #define wbsd_resume NULL | 2039 | #define wbsd_platform_resume NULL |
2040 | |||
2041 | #define wbsd_pnp_suspend NULL | ||
2042 | #define wbsd_pnp_resume NULL | ||
2033 | 2043 | ||
2034 | #endif /* CONFIG_PM */ | 2044 | #endif /* CONFIG_PM */ |
2035 | 2045 | ||
@@ -2039,8 +2049,8 @@ static struct platform_driver wbsd_driver = { | |||
2039 | .probe = wbsd_probe, | 2049 | .probe = wbsd_probe, |
2040 | .remove = __devexit_p(wbsd_remove), | 2050 | .remove = __devexit_p(wbsd_remove), |
2041 | 2051 | ||
2042 | .suspend = wbsd_suspend, | 2052 | .suspend = wbsd_platform_suspend, |
2043 | .resume = wbsd_resume, | 2053 | .resume = wbsd_platform_resume, |
2044 | .driver = { | 2054 | .driver = { |
2045 | .name = DRIVER_NAME, | 2055 | .name = DRIVER_NAME, |
2046 | }, | 2056 | }, |
@@ -2053,6 +2063,9 @@ static struct pnp_driver wbsd_pnp_driver = { | |||
2053 | .id_table = pnp_dev_table, | 2063 | .id_table = pnp_dev_table, |
2054 | .probe = wbsd_pnp_probe, | 2064 | .probe = wbsd_pnp_probe, |
2055 | .remove = __devexit_p(wbsd_pnp_remove), | 2065 | .remove = __devexit_p(wbsd_pnp_remove), |
2066 | |||
2067 | .suspend = wbsd_pnp_suspend, | ||
2068 | .resume = wbsd_pnp_resume, | ||
2056 | }; | 2069 | }; |
2057 | 2070 | ||
2058 | #endif /* CONFIG_PNP */ | 2071 | #endif /* CONFIG_PNP */ |
@@ -2072,31 +2085,26 @@ static int __init wbsd_drv_init(void) | |||
2072 | 2085 | ||
2073 | #ifdef CONFIG_PNP | 2086 | #ifdef CONFIG_PNP |
2074 | 2087 | ||
2075 | if (!nopnp) | 2088 | if (!nopnp) { |
2076 | { | ||
2077 | result = pnp_register_driver(&wbsd_pnp_driver); | 2089 | result = pnp_register_driver(&wbsd_pnp_driver); |
2078 | if (result < 0) | 2090 | if (result < 0) |
2079 | return result; | 2091 | return result; |
2080 | } | 2092 | } |
2081 | |||
2082 | #endif /* CONFIG_PNP */ | 2093 | #endif /* CONFIG_PNP */ |
2083 | 2094 | ||
2084 | if (nopnp) | 2095 | if (nopnp) { |
2085 | { | ||
2086 | result = platform_driver_register(&wbsd_driver); | 2096 | result = platform_driver_register(&wbsd_driver); |
2087 | if (result < 0) | 2097 | if (result < 0) |
2088 | return result; | 2098 | return result; |
2089 | 2099 | ||
2090 | wbsd_device = platform_device_alloc(DRIVER_NAME, -1); | 2100 | wbsd_device = platform_device_alloc(DRIVER_NAME, -1); |
2091 | if (!wbsd_device) | 2101 | if (!wbsd_device) { |
2092 | { | ||
2093 | platform_driver_unregister(&wbsd_driver); | 2102 | platform_driver_unregister(&wbsd_driver); |
2094 | return -ENOMEM; | 2103 | return -ENOMEM; |
2095 | } | 2104 | } |
2096 | 2105 | ||
2097 | result = platform_device_add(wbsd_device); | 2106 | result = platform_device_add(wbsd_device); |
2098 | if (result) | 2107 | if (result) { |
2099 | { | ||
2100 | platform_device_put(wbsd_device); | 2108 | platform_device_put(wbsd_device); |
2101 | platform_driver_unregister(&wbsd_driver); | 2109 | platform_driver_unregister(&wbsd_driver); |
2102 | return result; | 2110 | return result; |
@@ -2115,8 +2123,7 @@ static void __exit wbsd_drv_exit(void) | |||
2115 | 2123 | ||
2116 | #endif /* CONFIG_PNP */ | 2124 | #endif /* CONFIG_PNP */ |
2117 | 2125 | ||
2118 | if (nopnp) | 2126 | if (nopnp) { |
2119 | { | ||
2120 | platform_device_unregister(wbsd_device); | 2127 | platform_device_unregister(wbsd_device); |
2121 | 2128 | ||
2122 | platform_driver_unregister(&wbsd_driver); | 2129 | platform_driver_unregister(&wbsd_driver); |
diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig index b9b77cf39a18..7abd7fee0dda 100644 --- a/drivers/mtd/maps/Kconfig +++ b/drivers/mtd/maps/Kconfig | |||
@@ -473,14 +473,6 @@ config MTD_IXP2000 | |||
473 | IXDP425 and Coyote. If you have an IXP2000 based board and | 473 | IXDP425 and Coyote. If you have an IXP2000 based board and |
474 | would like to use the flash chips on it, say 'Y'. | 474 | would like to use the flash chips on it, say 'Y'. |
475 | 475 | ||
476 | config MTD_EPXA10DB | ||
477 | tristate "CFI Flash device mapped on Epxa10db" | ||
478 | depends on MTD_CFI && MTD_PARTITIONS && ARCH_CAMELOT | ||
479 | help | ||
480 | This enables support for the flash devices on the Altera | ||
481 | Excalibur XA10 Development Board. If you are building a kernel | ||
482 | for on of these boards then you should say 'Y' otherwise say 'N'. | ||
483 | |||
484 | config MTD_FORTUNET | 476 | config MTD_FORTUNET |
485 | tristate "CFI Flash device mapped on the FortuNet board" | 477 | tristate "CFI Flash device mapped on the FortuNet board" |
486 | depends on MTD_CFI && MTD_PARTITIONS && SA1100_FORTUNET | 478 | depends on MTD_CFI && MTD_PARTITIONS && SA1100_FORTUNET |
diff --git a/drivers/mtd/maps/Makefile b/drivers/mtd/maps/Makefile index 2f7e254912f0..ab71f172eb77 100644 --- a/drivers/mtd/maps/Makefile +++ b/drivers/mtd/maps/Makefile | |||
@@ -15,7 +15,6 @@ obj-$(CONFIG_MTD_CFI_FLAGADM) += cfi_flagadm.o | |||
15 | obj-$(CONFIG_MTD_CSTM_MIPS_IXX) += cstm_mips_ixx.o | 15 | obj-$(CONFIG_MTD_CSTM_MIPS_IXX) += cstm_mips_ixx.o |
16 | obj-$(CONFIG_MTD_DC21285) += dc21285.o | 16 | obj-$(CONFIG_MTD_DC21285) += dc21285.o |
17 | obj-$(CONFIG_MTD_DILNETPC) += dilnetpc.o | 17 | obj-$(CONFIG_MTD_DILNETPC) += dilnetpc.o |
18 | obj-$(CONFIG_MTD_EPXA10DB) += epxa10db-flash.o | ||
19 | obj-$(CONFIG_MTD_IQ80310) += iq80310.o | 18 | obj-$(CONFIG_MTD_IQ80310) += iq80310.o |
20 | obj-$(CONFIG_MTD_L440GX) += l440gx.o | 19 | obj-$(CONFIG_MTD_L440GX) += l440gx.o |
21 | obj-$(CONFIG_MTD_AMD76XROM) += amd76xrom.o | 20 | obj-$(CONFIG_MTD_AMD76XROM) += amd76xrom.o |
diff --git a/drivers/mtd/maps/epxa10db-flash.c b/drivers/mtd/maps/epxa10db-flash.c deleted file mode 100644 index 265b079fe934..000000000000 --- a/drivers/mtd/maps/epxa10db-flash.c +++ /dev/null | |||
@@ -1,179 +0,0 @@ | |||
1 | /* | ||
2 | * Flash memory access on EPXA based devices | ||
3 | * | ||
4 | * (C) 2000 Nicolas Pitre <nico@cam.org> | ||
5 | * Copyright (C) 2001 Altera Corporation | ||
6 | * Copyright (C) 2001 Red Hat, Inc. | ||
7 | * | ||
8 | * $Id: epxa10db-flash.c,v 1.15 2005/11/07 11:14:27 gleixner Exp $ | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
23 | */ | ||
24 | |||
25 | #include <linux/config.h> | ||
26 | #include <linux/module.h> | ||
27 | #include <linux/types.h> | ||
28 | #include <linux/kernel.h> | ||
29 | #include <linux/init.h> | ||
30 | #include <linux/slab.h> | ||
31 | |||
32 | #include <linux/mtd/mtd.h> | ||
33 | #include <linux/mtd/map.h> | ||
34 | #include <linux/mtd/partitions.h> | ||
35 | |||
36 | #include <asm/io.h> | ||
37 | #include <asm/hardware.h> | ||
38 | |||
39 | #ifdef CONFIG_EPXA10DB | ||
40 | #define BOARD_NAME "EPXA10DB" | ||
41 | #else | ||
42 | #define BOARD_NAME "EPXA1DB" | ||
43 | #endif | ||
44 | |||
45 | static int nr_parts = 0; | ||
46 | static struct mtd_partition *parts; | ||
47 | |||
48 | static struct mtd_info *mymtd; | ||
49 | |||
50 | static int epxa_default_partitions(struct mtd_info *master, struct mtd_partition **pparts); | ||
51 | |||
52 | |||
53 | static struct map_info epxa_map = { | ||
54 | .name = "EPXA flash", | ||
55 | .size = FLASH_SIZE, | ||
56 | .bankwidth = 2, | ||
57 | .phys = FLASH_START, | ||
58 | }; | ||
59 | |||
60 | static const char *probes[] = { "RedBoot", "afs", NULL }; | ||
61 | |||
62 | static int __init epxa_mtd_init(void) | ||
63 | { | ||
64 | int i; | ||
65 | |||
66 | printk(KERN_NOTICE "%s flash device: 0x%x at 0x%x\n", BOARD_NAME, FLASH_SIZE, FLASH_START); | ||
67 | |||
68 | epxa_map.virt = ioremap(FLASH_START, FLASH_SIZE); | ||
69 | if (!epxa_map.virt) { | ||
70 | printk("Failed to ioremap %s flash\n",BOARD_NAME); | ||
71 | return -EIO; | ||
72 | } | ||
73 | simple_map_init(&epxa_map); | ||
74 | |||
75 | mymtd = do_map_probe("cfi_probe", &epxa_map); | ||
76 | if (!mymtd) { | ||
77 | iounmap((void *)epxa_map.virt); | ||
78 | return -ENXIO; | ||
79 | } | ||
80 | |||
81 | mymtd->owner = THIS_MODULE; | ||
82 | |||
83 | /* Unlock the flash device. */ | ||
84 | if(mymtd->unlock){ | ||
85 | for (i=0; i<mymtd->numeraseregions;i++){ | ||
86 | int j; | ||
87 | for(j=0;j<mymtd->eraseregions[i].numblocks;j++){ | ||
88 | mymtd->unlock(mymtd,mymtd->eraseregions[i].offset + j * mymtd->eraseregions[i].erasesize,mymtd->eraseregions[i].erasesize); | ||
89 | } | ||
90 | } | ||
91 | } | ||
92 | |||
93 | #ifdef CONFIG_MTD_PARTITIONS | ||
94 | nr_parts = parse_mtd_partitions(mymtd, probes, &parts, 0); | ||
95 | |||
96 | if (nr_parts > 0) { | ||
97 | add_mtd_partitions(mymtd, parts, nr_parts); | ||
98 | return 0; | ||
99 | } | ||
100 | #endif | ||
101 | /* No recognised partitioning schemes found - use defaults */ | ||
102 | nr_parts = epxa_default_partitions(mymtd, &parts); | ||
103 | if (nr_parts > 0) { | ||
104 | add_mtd_partitions(mymtd, parts, nr_parts); | ||
105 | return 0; | ||
106 | } | ||
107 | |||
108 | /* If all else fails... */ | ||
109 | add_mtd_device(mymtd); | ||
110 | return 0; | ||
111 | } | ||
112 | |||
113 | static void __exit epxa_mtd_cleanup(void) | ||
114 | { | ||
115 | if (mymtd) { | ||
116 | if (nr_parts) | ||
117 | del_mtd_partitions(mymtd); | ||
118 | else | ||
119 | del_mtd_device(mymtd); | ||
120 | map_destroy(mymtd); | ||
121 | } | ||
122 | if (epxa_map.virt) { | ||
123 | iounmap((void *)epxa_map.virt); | ||
124 | epxa_map.virt = 0; | ||
125 | } | ||
126 | } | ||
127 | |||
128 | |||
129 | /* | ||
130 | * This will do for now, once we decide which bootldr we're finally | ||
131 | * going to use then we'll remove this function and do it properly | ||
132 | * | ||
133 | * Partions are currently (as offsets from base of flash): | ||
134 | * 0x00000000 - 0x003FFFFF - bootloader (!) | ||
135 | * 0x00400000 - 0x00FFFFFF - Flashdisk | ||
136 | */ | ||
137 | |||
138 | static int __init epxa_default_partitions(struct mtd_info *master, struct mtd_partition **pparts) | ||
139 | { | ||
140 | struct mtd_partition *parts; | ||
141 | int ret, i; | ||
142 | int npartitions = 0; | ||
143 | char *names; | ||
144 | const char *name = "jffs"; | ||
145 | |||
146 | printk("Using default partitions for %s\n",BOARD_NAME); | ||
147 | npartitions=1; | ||
148 | parts = kmalloc(npartitions*sizeof(*parts)+strlen(name), GFP_KERNEL); | ||
149 | memzero(parts,npartitions*sizeof(*parts)+strlen(name)); | ||
150 | if (!parts) { | ||
151 | ret = -ENOMEM; | ||
152 | goto out; | ||
153 | } | ||
154 | i=0; | ||
155 | names = (char *)&parts[npartitions]; | ||
156 | parts[i].name = names; | ||
157 | names += strlen(name) + 1; | ||
158 | strcpy(parts[i].name, name); | ||
159 | |||
160 | #ifdef CONFIG_EPXA10DB | ||
161 | parts[i].size = FLASH_SIZE-0x00400000; | ||
162 | parts[i].offset = 0x00400000; | ||
163 | #else | ||
164 | parts[i].size = FLASH_SIZE-0x00180000; | ||
165 | parts[i].offset = 0x00180000; | ||
166 | #endif | ||
167 | |||
168 | out: | ||
169 | *pparts = parts; | ||
170 | return npartitions; | ||
171 | } | ||
172 | |||
173 | |||
174 | module_init(epxa_mtd_init); | ||
175 | module_exit(epxa_mtd_cleanup); | ||
176 | |||
177 | MODULE_AUTHOR("Clive Davies"); | ||
178 | MODULE_DESCRIPTION("Altera epxa mtd flash map"); | ||
179 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/net/arm/Kconfig b/drivers/net/arm/Kconfig index 470364deded0..625184b65e38 100644 --- a/drivers/net/arm/Kconfig +++ b/drivers/net/arm/Kconfig | |||
@@ -31,16 +31,3 @@ config ARM_ETHERH | |||
31 | help | 31 | help |
32 | If you have an Acorn system with one of these network cards, you | 32 | If you have an Acorn system with one of these network cards, you |
33 | should say Y to this option if you wish to use it with Linux. | 33 | should say Y to this option if you wish to use it with Linux. |
34 | |||
35 | config ARM_ETHER00 | ||
36 | tristate "Altera Ether00 support" | ||
37 | depends on NET_ETHERNET && ARM && ARCH_CAMELOT | ||
38 | help | ||
39 | This is the driver for Altera's ether00 ethernet mac IP core. Say | ||
40 | Y here if you want to build support for this into the kernel. It | ||
41 | is also available as a module (say M here) that can be inserted/ | ||
42 | removed from the kernel at the same time as the PLD is configured. | ||
43 | If this driver is running on an epxa10 development board then it | ||
44 | will generate a suitable hw address based on the board serial | ||
45 | number (MTD support is required for this). Otherwise you will | ||
46 | need to set a suitable hw address using ifconfig. | ||
diff --git a/drivers/net/arm/Makefile b/drivers/net/arm/Makefile index b0d706834d89..bc263edf06a7 100644 --- a/drivers/net/arm/Makefile +++ b/drivers/net/arm/Makefile | |||
@@ -4,7 +4,6 @@ | |||
4 | # | 4 | # |
5 | 5 | ||
6 | obj-$(CONFIG_ARM_AM79C961A) += am79c961a.o | 6 | obj-$(CONFIG_ARM_AM79C961A) += am79c961a.o |
7 | obj-$(CONFIG_ARM_ETHER00) += ether00.o | ||
8 | obj-$(CONFIG_ARM_ETHERH) += etherh.o | 7 | obj-$(CONFIG_ARM_ETHERH) += etherh.o |
9 | obj-$(CONFIG_ARM_ETHER3) += ether3.o | 8 | obj-$(CONFIG_ARM_ETHER3) += ether3.o |
10 | obj-$(CONFIG_ARM_ETHER1) += ether1.o | 9 | obj-$(CONFIG_ARM_ETHER1) += ether1.o |
diff --git a/drivers/net/arm/am79c961a.c b/drivers/net/arm/am79c961a.c index 877891a29aaa..53e3afc1b7b7 100644 --- a/drivers/net/arm/am79c961a.c +++ b/drivers/net/arm/am79c961a.c | |||
@@ -668,9 +668,8 @@ static void __init am79c961_banner(void) | |||
668 | printk(KERN_INFO "%s", version); | 668 | printk(KERN_INFO "%s", version); |
669 | } | 669 | } |
670 | 670 | ||
671 | static int __init am79c961_probe(struct device *_dev) | 671 | static int __init am79c961_probe(struct platform_device *pdev) |
672 | { | 672 | { |
673 | struct platform_device *pdev = to_platform_device(_dev); | ||
674 | struct resource *res; | 673 | struct resource *res; |
675 | struct net_device *dev; | 674 | struct net_device *dev; |
676 | struct dev_priv *priv; | 675 | struct dev_priv *priv; |
@@ -758,15 +757,16 @@ out: | |||
758 | return ret; | 757 | return ret; |
759 | } | 758 | } |
760 | 759 | ||
761 | static struct device_driver am79c961_driver = { | 760 | static struct platform_driver am79c961_driver = { |
762 | .name = "am79c961", | ||
763 | .bus = &platform_bus_type, | ||
764 | .probe = am79c961_probe, | 761 | .probe = am79c961_probe, |
762 | .driver = { | ||
763 | .name = "am79c961", | ||
764 | }, | ||
765 | }; | 765 | }; |
766 | 766 | ||
767 | static int __init am79c961_init(void) | 767 | static int __init am79c961_init(void) |
768 | { | 768 | { |
769 | return driver_register(&am79c961_driver); | 769 | return platform_driver_register(&am79c961_driver); |
770 | } | 770 | } |
771 | 771 | ||
772 | __initcall(am79c961_init); | 772 | __initcall(am79c961_init); |
diff --git a/drivers/net/arm/ether00.c b/drivers/net/arm/ether00.c deleted file mode 100644 index 4f1f4e31bda5..000000000000 --- a/drivers/net/arm/ether00.c +++ /dev/null | |||
@@ -1,1017 +0,0 @@ | |||
1 | /* | ||
2 | * drivers/net/ether00.c | ||
3 | * | ||
4 | * Copyright (C) 2001 Altera Corporation | ||
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 as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | |||
21 | /* includes */ | ||
22 | #include <linux/config.h> | ||
23 | #include <linux/pci.h> | ||
24 | #include <linux/sched.h> | ||
25 | #include <linux/netdevice.h> | ||
26 | #include <linux/skbuff.h> | ||
27 | #include <linux/etherdevice.h> | ||
28 | #include <linux/module.h> | ||
29 | #include <linux/tqueue.h> | ||
30 | #include <linux/mtd/mtd.h> | ||
31 | #include <linux/pld/pld_hotswap.h> | ||
32 | #include <asm/arch/excalibur.h> | ||
33 | #include <asm/arch/hardware.h> | ||
34 | #include <asm/irq.h> | ||
35 | #include <asm/io.h> | ||
36 | #include <asm/sizes.h> | ||
37 | |||
38 | #include <asm/arch/ether00.h> | ||
39 | #include <asm/arch/tdkphy.h> | ||
40 | |||
41 | |||
42 | MODULE_AUTHOR("Clive Davies"); | ||
43 | MODULE_DESCRIPTION("Altera Ether00 IP core driver"); | ||
44 | MODULE_LICENSE("GPL"); | ||
45 | |||
46 | #define PKT_BUF_SZ 1540 /* Size of each rx buffer */ | ||
47 | #define ETH_NR 4 /* Number of MACs this driver supports */ | ||
48 | |||
49 | #define DEBUG(x) | ||
50 | |||
51 | #define __dma_va(x) (unsigned int)((unsigned int)priv->dma_data+(((unsigned int)(x))&(EXC_SPSRAM_BLOCK0_SIZE-1))) | ||
52 | #define __dma_pa(x) (unsigned int)(EXC_SPSRAM_BLOCK0_BASE+(((unsigned int)(x))-(unsigned int)priv->dma_data)) | ||
53 | |||
54 | #define ETHER00_BASE 0 | ||
55 | #define ETHER00_TYPE | ||
56 | #define ETHER00_NAME "ether00" | ||
57 | #define MAC_REG_SIZE 0x400 /* size of MAC register area */ | ||
58 | |||
59 | |||
60 | |||
61 | /* typedefs */ | ||
62 | |||
63 | /* The definition of the driver control structure */ | ||
64 | |||
65 | #define RX_NUM_BUFF 10 | ||
66 | #define RX_NUM_FDESC 10 | ||
67 | #define TX_NUM_FDESC 10 | ||
68 | |||
69 | struct tx_fda_ent{ | ||
70 | FDA_DESC fd; | ||
71 | BUF_DESC bd; | ||
72 | BUF_DESC pad; | ||
73 | }; | ||
74 | struct rx_fda_ent{ | ||
75 | FDA_DESC fd; | ||
76 | BUF_DESC bd; | ||
77 | BUF_DESC pad; | ||
78 | }; | ||
79 | struct rx_blist_ent{ | ||
80 | FDA_DESC fd; | ||
81 | BUF_DESC bd; | ||
82 | BUF_DESC pad; | ||
83 | }; | ||
84 | struct net_priv | ||
85 | { | ||
86 | struct net_device_stats stats; | ||
87 | struct sk_buff* skb; | ||
88 | void* dma_data; | ||
89 | struct rx_blist_ent* rx_blist_vp; | ||
90 | struct rx_fda_ent* rx_fda_ptr; | ||
91 | struct tx_fda_ent* tx_fdalist_vp; | ||
92 | struct tq_struct tq_memupdate; | ||
93 | unsigned char memupdate_scheduled; | ||
94 | unsigned char rx_disabled; | ||
95 | unsigned char queue_stopped; | ||
96 | spinlock_t rx_lock; | ||
97 | }; | ||
98 | |||
99 | static const char vendor_id[2]={0x07,0xed}; | ||
100 | |||
101 | #ifdef ETHER00_DEBUG | ||
102 | |||
103 | /* Dump (most) registers for debugging puposes */ | ||
104 | |||
105 | static void dump_regs(struct net_device *dev){ | ||
106 | struct net_priv* priv=dev->priv; | ||
107 | unsigned int* i; | ||
108 | |||
109 | printk("\n RX free descriptor area:\n"); | ||
110 | |||
111 | for(i=(unsigned int*)priv->rx_fda_ptr; | ||
112 | i<((unsigned int*)(priv->rx_fda_ptr+RX_NUM_FDESC));){ | ||
113 | printk("%#8x %#8x %#8x %#8x\n",*i,*(i+1),*(i+2),*(i+3)); | ||
114 | i+=4; | ||
115 | } | ||
116 | |||
117 | printk("\n RX buffer list:\n"); | ||
118 | |||
119 | for(i=(unsigned int*)priv->rx_blist_vp; | ||
120 | i<((unsigned int*)(priv->rx_blist_vp+RX_NUM_BUFF));){ | ||
121 | printk("%#8x %#8x %#8x %#8x\n",*i,*(i+1),*(i+2),*(i+3)); | ||
122 | i+=4; | ||
123 | } | ||
124 | |||
125 | printk("\n TX frame descriptor list:\n"); | ||
126 | |||
127 | for(i=(unsigned int*)priv->tx_fdalist_vp; | ||
128 | i<((unsigned int*)(priv->tx_fdalist_vp+TX_NUM_FDESC));){ | ||
129 | printk("%#8x %#8x %#8x %#8x\n",*i,*(i+1),*(i+2),*(i+3)); | ||
130 | i+=4; | ||
131 | } | ||
132 | |||
133 | printk("\ndma ctl=%#x\n",readw(ETHER_DMA_CTL(dev->base_addr))); | ||
134 | printk("txfrmptr=%#x\n",readw(ETHER_TXFRMPTR(dev->base_addr))); | ||
135 | printk("txthrsh=%#x\n",readw(ETHER_TXTHRSH(dev->base_addr))); | ||
136 | printk("txpollctr=%#x\n",readw(ETHER_TXPOLLCTR(dev->base_addr))); | ||
137 | printk("blfrmptr=%#x\n",readw(ETHER_BLFRMPTR(dev->base_addr))); | ||
138 | printk("rxfragsize=%#x\n",readw(ETHER_RXFRAGSIZE(dev->base_addr))); | ||
139 | printk("tx_int_en=%#x\n",readw(ETHER_INT_EN(dev->base_addr))); | ||
140 | printk("fda_bas=%#x\n",readw(ETHER_FDA_BAS(dev->base_addr))); | ||
141 | printk("fda_lim=%#x\n",readw(ETHER_FDA_LIM(dev->base_addr))); | ||
142 | printk("int_src=%#x\n",readw(ETHER_INT_SRC(dev->base_addr))); | ||
143 | printk("pausecnt=%#x\n",readw(ETHER_PAUSECNT(dev->base_addr))); | ||
144 | printk("rempaucnt=%#x\n",readw(ETHER_REMPAUCNT(dev->base_addr))); | ||
145 | printk("txconfrmstat=%#x\n",readw(ETHER_TXCONFRMSTAT(dev->base_addr))); | ||
146 | printk("mac_ctl=%#x\n",readw(ETHER_MAC_CTL(dev->base_addr))); | ||
147 | printk("arc_ctl=%#x\n",readw(ETHER_ARC_CTL(dev->base_addr))); | ||
148 | printk("tx_ctl=%#x\n",readw(ETHER_TX_CTL(dev->base_addr))); | ||
149 | } | ||
150 | #endif /* ETHER00_DEBUG */ | ||
151 | |||
152 | |||
153 | static int ether00_write_phy(struct net_device *dev, short address, short value) | ||
154 | { | ||
155 | volatile int count = 1024; | ||
156 | writew(value,ETHER_MD_DATA(dev->base_addr)); | ||
157 | writew( ETHER_MD_CA_BUSY_MSK | | ||
158 | ETHER_MD_CA_WR_MSK | | ||
159 | (address & ETHER_MD_CA_ADDR_MSK), | ||
160 | ETHER_MD_CA(dev->base_addr)); | ||
161 | |||
162 | /* Wait for the command to complete */ | ||
163 | while((readw(ETHER_MD_CA(dev->base_addr)) & ETHER_MD_CA_BUSY_MSK)&&count){ | ||
164 | count--; | ||
165 | } | ||
166 | if (!count){ | ||
167 | printk("Write to phy failed, addr=%#x, data=%#x\n",address, value); | ||
168 | return -EIO; | ||
169 | } | ||
170 | return 0; | ||
171 | } | ||
172 | |||
173 | static int ether00_read_phy(struct net_device *dev, short address) | ||
174 | { | ||
175 | volatile int count = 1024; | ||
176 | writew( ETHER_MD_CA_BUSY_MSK | | ||
177 | (address & ETHER_MD_CA_ADDR_MSK), | ||
178 | ETHER_MD_CA(dev->base_addr)); | ||
179 | |||
180 | /* Wait for the command to complete */ | ||
181 | while((readw(ETHER_MD_CA(dev->base_addr)) & ETHER_MD_CA_BUSY_MSK)&&count){ | ||
182 | count--; | ||
183 | } | ||
184 | if (!count){ | ||
185 | printk(KERN_WARNING "Read from phy timed out\n"); | ||
186 | return -EIO; | ||
187 | } | ||
188 | return readw(ETHER_MD_DATA(dev->base_addr)); | ||
189 | } | ||
190 | |||
191 | static void ether00_phy_int(int irq_num, void* dev_id, struct pt_regs* regs) | ||
192 | { | ||
193 | struct net_device* dev=dev_id; | ||
194 | int irq_status; | ||
195 | |||
196 | irq_status=ether00_read_phy(dev, PHY_IRQ_CONTROL); | ||
197 | |||
198 | if(irq_status & PHY_IRQ_CONTROL_ANEG_COMP_INT_MSK){ | ||
199 | /* | ||
200 | * Autonegotiation complete on epxa10db. The mac doesn't | ||
201 | * twig if we're in full duplex so we need to check the | ||
202 | * phy status register and configure the mac accordingly | ||
203 | */ | ||
204 | if(ether00_read_phy(dev, PHY_STATUS)&(PHY_STATUS_10T_F_MSK|PHY_STATUS_100_X_F_MSK)){ | ||
205 | int tmp; | ||
206 | tmp=readl(ETHER_MAC_CTL(dev->base_addr)); | ||
207 | writel(tmp|ETHER_MAC_CTL_FULLDUP_MSK,ETHER_MAC_CTL(dev->base_addr)); | ||
208 | } | ||
209 | } | ||
210 | |||
211 | if(irq_status&PHY_IRQ_CONTROL_LS_CHG_INT_MSK){ | ||
212 | |||
213 | if(ether00_read_phy(dev, PHY_STATUS)& PHY_STATUS_LINK_MSK){ | ||
214 | /* Link is up */ | ||
215 | netif_carrier_on(dev); | ||
216 | //printk("Carrier on\n"); | ||
217 | }else{ | ||
218 | netif_carrier_off(dev); | ||
219 | //printk("Carrier off\n"); | ||
220 | |||
221 | } | ||
222 | } | ||
223 | |||
224 | } | ||
225 | |||
226 | static void setup_blist_entry(struct sk_buff* skb,struct rx_blist_ent* blist_ent_ptr){ | ||
227 | /* Make the buffer consistent with the cache as the mac is going to write | ||
228 | * directly into it*/ | ||
229 | blist_ent_ptr->fd.FDSystem=(unsigned int)skb; | ||
230 | blist_ent_ptr->bd.BuffData=(char*)__pa(skb->data); | ||
231 | consistent_sync(skb->data,PKT_BUF_SZ,PCI_DMA_FROMDEVICE); | ||
232 | /* align IP on 16 Byte (DMA_CTL set to skip 2 bytes) */ | ||
233 | skb_reserve(skb,2); | ||
234 | blist_ent_ptr->bd.BuffLength=PKT_BUF_SZ-2; | ||
235 | blist_ent_ptr->fd.FDLength=1; | ||
236 | blist_ent_ptr->fd.FDCtl=FDCTL_COWNSFD_MSK; | ||
237 | blist_ent_ptr->bd.BDCtl=BDCTL_COWNSBD_MSK; | ||
238 | } | ||
239 | |||
240 | |||
241 | static int ether00_mem_init(struct net_device* dev) | ||
242 | { | ||
243 | struct net_priv* priv=dev->priv; | ||
244 | struct tx_fda_ent *tx_fd_ptr,*tx_end_ptr; | ||
245 | struct rx_blist_ent* blist_ent_ptr; | ||
246 | int i; | ||
247 | |||
248 | /* | ||
249 | * Grab a block of on chip SRAM to contain the control stuctures for | ||
250 | * the ethernet MAC. This uncached becuase it needs to be accesses by both | ||
251 | * bus masters (cpu + mac). However, it shouldn't matter too much in terms | ||
252 | * of speed as its on chip memory | ||
253 | */ | ||
254 | priv->dma_data=ioremap_nocache(EXC_SPSRAM_BLOCK0_BASE,EXC_SPSRAM_BLOCK0_SIZE ); | ||
255 | if (!priv->dma_data) | ||
256 | return -ENOMEM; | ||
257 | |||
258 | priv->rx_fda_ptr=(struct rx_fda_ent*)priv->dma_data; | ||
259 | /* | ||
260 | * Now share it out amongst the Frame descriptors and the buffer list | ||
261 | */ | ||
262 | priv->rx_blist_vp=(struct rx_blist_ent*)((unsigned int)priv->dma_data+RX_NUM_FDESC*sizeof(struct rx_fda_ent)); | ||
263 | |||
264 | /* | ||
265 | *Initalise the FDA list | ||
266 | */ | ||
267 | /* set ownership to the controller */ | ||
268 | memset(priv->rx_fda_ptr,0x80,RX_NUM_FDESC*sizeof(struct rx_fda_ent)); | ||
269 | |||
270 | /* | ||
271 | *Initialise the buffer list | ||
272 | */ | ||
273 | blist_ent_ptr=priv->rx_blist_vp; | ||
274 | i=0; | ||
275 | while(blist_ent_ptr<(priv->rx_blist_vp+RX_NUM_BUFF)){ | ||
276 | struct sk_buff *skb; | ||
277 | blist_ent_ptr->fd.FDLength=1; | ||
278 | skb=dev_alloc_skb(PKT_BUF_SZ); | ||
279 | if(skb){ | ||
280 | setup_blist_entry(skb,blist_ent_ptr); | ||
281 | blist_ent_ptr->fd.FDNext=(FDA_DESC*)__dma_pa(blist_ent_ptr+1); | ||
282 | blist_ent_ptr->bd.BDStat=i++; | ||
283 | blist_ent_ptr++; | ||
284 | } | ||
285 | else | ||
286 | { | ||
287 | printk("Failed to initalise buffer list\n"); | ||
288 | } | ||
289 | |||
290 | } | ||
291 | blist_ent_ptr--; | ||
292 | blist_ent_ptr->fd.FDNext=(FDA_DESC*)__dma_pa(priv->rx_blist_vp); | ||
293 | |||
294 | priv->tx_fdalist_vp=(struct tx_fda_ent*)(priv->rx_blist_vp+RX_NUM_BUFF); | ||
295 | |||
296 | /* Initialise the buffers to be a circular list. The mac will then go poll | ||
297 | * the list until it finds a frame ready to transmit */ | ||
298 | tx_end_ptr=priv->tx_fdalist_vp+TX_NUM_FDESC; | ||
299 | for(tx_fd_ptr=priv->tx_fdalist_vp;tx_fd_ptr<tx_end_ptr;tx_fd_ptr++){ | ||
300 | tx_fd_ptr->fd.FDNext=(FDA_DESC*)__dma_pa((tx_fd_ptr+1)); | ||
301 | tx_fd_ptr->fd.FDCtl=1; | ||
302 | tx_fd_ptr->fd.FDStat=0; | ||
303 | tx_fd_ptr->fd.FDLength=1; | ||
304 | |||
305 | } | ||
306 | /* Change the last FDNext pointer to make a circular list */ | ||
307 | tx_fd_ptr--; | ||
308 | tx_fd_ptr->fd.FDNext=(FDA_DESC*)__dma_pa(priv->tx_fdalist_vp); | ||
309 | |||
310 | /* Point the device at the chain of Rx and Tx Buffers */ | ||
311 | writel((unsigned int)__dma_pa(priv->rx_fda_ptr),ETHER_FDA_BAS(dev->base_addr)); | ||
312 | writel((RX_NUM_FDESC-1)*sizeof(struct rx_fda_ent),ETHER_FDA_LIM(dev->base_addr)); | ||
313 | writel((unsigned int)__dma_pa(priv->rx_blist_vp),ETHER_BLFRMPTR(dev->base_addr)); | ||
314 | |||
315 | writel((unsigned int)__dma_pa(priv->tx_fdalist_vp),ETHER_TXFRMPTR(dev->base_addr)); | ||
316 | |||
317 | return 0; | ||
318 | } | ||
319 | |||
320 | |||
321 | void ether00_mem_update(void* dev_id) | ||
322 | { | ||
323 | struct net_device* dev=dev_id; | ||
324 | struct net_priv* priv=dev->priv; | ||
325 | struct sk_buff* skb; | ||
326 | struct tx_fda_ent *fda_ptr=priv->tx_fdalist_vp; | ||
327 | struct rx_blist_ent* blist_ent_ptr; | ||
328 | unsigned long flags; | ||
329 | |||
330 | priv->tq_memupdate.sync=0; | ||
331 | //priv->tq_memupdate.list= | ||
332 | priv->memupdate_scheduled=0; | ||
333 | |||
334 | /* Transmit interrupt */ | ||
335 | while(fda_ptr<(priv->tx_fdalist_vp+TX_NUM_FDESC)){ | ||
336 | if(!(FDCTL_COWNSFD_MSK&fda_ptr->fd.FDCtl) && (ETHER_TX_STAT_COMP_MSK&fda_ptr->fd.FDStat)){ | ||
337 | priv->stats.tx_packets++; | ||
338 | priv->stats.tx_bytes+=fda_ptr->bd.BuffLength; | ||
339 | skb=(struct sk_buff*)fda_ptr->fd.FDSystem; | ||
340 | //printk("%d:txcln:fda=%#x skb=%#x\n",jiffies,fda_ptr,skb); | ||
341 | dev_kfree_skb(skb); | ||
342 | fda_ptr->fd.FDSystem=0; | ||
343 | fda_ptr->fd.FDStat=0; | ||
344 | fda_ptr->fd.FDCtl=0; | ||
345 | } | ||
346 | fda_ptr++; | ||
347 | } | ||
348 | /* Fill in any missing buffers from the received queue */ | ||
349 | spin_lock_irqsave(&priv->rx_lock,flags); | ||
350 | blist_ent_ptr=priv->rx_blist_vp; | ||
351 | while(blist_ent_ptr<(priv->rx_blist_vp+RX_NUM_BUFF)){ | ||
352 | /* fd.FDSystem of 0 indicates we failed to allocate the buffer in the ISR */ | ||
353 | if(!blist_ent_ptr->fd.FDSystem){ | ||
354 | struct sk_buff *skb; | ||
355 | skb=dev_alloc_skb(PKT_BUF_SZ); | ||
356 | blist_ent_ptr->fd.FDSystem=(unsigned int)skb; | ||
357 | if(skb){ | ||
358 | setup_blist_entry(skb,blist_ent_ptr); | ||
359 | } | ||
360 | else | ||
361 | { | ||
362 | break; | ||
363 | } | ||
364 | } | ||
365 | blist_ent_ptr++; | ||
366 | } | ||
367 | spin_unlock_irqrestore(&priv->rx_lock,flags); | ||
368 | if(priv->queue_stopped){ | ||
369 | //printk("%d:cln:start q\n",jiffies); | ||
370 | netif_start_queue(dev); | ||
371 | } | ||
372 | if(priv->rx_disabled){ | ||
373 | //printk("%d:enable_irq\n",jiffies); | ||
374 | priv->rx_disabled=0; | ||
375 | writel(ETHER_RX_CTL_RXEN_MSK,ETHER_RX_CTL(dev->base_addr)); | ||
376 | |||
377 | } | ||
378 | } | ||
379 | |||
380 | |||
381 | static void ether00_int( int irq_num, void* dev_id, struct pt_regs* regs) | ||
382 | { | ||
383 | struct net_device* dev=dev_id; | ||
384 | struct net_priv* priv=dev->priv; | ||
385 | |||
386 | unsigned int interruptValue; | ||
387 | |||
388 | interruptValue=readl(ETHER_INT_SRC(dev->base_addr)); | ||
389 | |||
390 | //printk("INT_SRC=%x\n",interruptValue); | ||
391 | |||
392 | if(!(readl(ETHER_INT_SRC(dev->base_addr)) & ETHER_INT_SRC_IRQ_MSK)) | ||
393 | { | ||
394 | return; /* Interrupt wasn't caused by us!! */ | ||
395 | } | ||
396 | |||
397 | if(readl(ETHER_INT_SRC(dev->base_addr))& | ||
398 | (ETHER_INT_SRC_INTMACRX_MSK | | ||
399 | ETHER_INT_SRC_FDAEX_MSK | | ||
400 | ETHER_INT_SRC_BLEX_MSK)) { | ||
401 | struct rx_blist_ent* blist_ent_ptr; | ||
402 | struct rx_fda_ent* fda_ent_ptr; | ||
403 | struct sk_buff* skb; | ||
404 | |||
405 | fda_ent_ptr=priv->rx_fda_ptr; | ||
406 | spin_lock(&priv->rx_lock); | ||
407 | while(fda_ent_ptr<(priv->rx_fda_ptr+RX_NUM_FDESC)){ | ||
408 | int result; | ||
409 | |||
410 | if(!(fda_ent_ptr->fd.FDCtl&FDCTL_COWNSFD_MSK)) | ||
411 | { | ||
412 | /* This frame is ready for processing */ | ||
413 | /*find the corresponding buffer in the bufferlist */ | ||
414 | blist_ent_ptr=priv->rx_blist_vp+fda_ent_ptr->bd.BDStat; | ||
415 | skb=(struct sk_buff*)blist_ent_ptr->fd.FDSystem; | ||
416 | |||
417 | /* Pass this skb up the stack */ | ||
418 | skb->dev=dev; | ||
419 | skb_put(skb,fda_ent_ptr->fd.FDLength); | ||
420 | skb->protocol=eth_type_trans(skb,dev); | ||
421 | skb->ip_summed=CHECKSUM_UNNECESSARY; | ||
422 | result=netif_rx(skb); | ||
423 | /* Update statistics */ | ||
424 | priv->stats.rx_packets++; | ||
425 | priv->stats.rx_bytes+=fda_ent_ptr->fd.FDLength; | ||
426 | |||
427 | /* Free the FDA entry */ | ||
428 | fda_ent_ptr->bd.BDStat=0xff; | ||
429 | fda_ent_ptr->fd.FDCtl=FDCTL_COWNSFD_MSK; | ||
430 | |||
431 | /* Allocate a new skb and point the bd entry to it */ | ||
432 | blist_ent_ptr->fd.FDSystem=0; | ||
433 | skb=dev_alloc_skb(PKT_BUF_SZ); | ||
434 | //printk("allocskb=%#x\n",skb); | ||
435 | if(skb){ | ||
436 | setup_blist_entry(skb,blist_ent_ptr); | ||
437 | |||
438 | } | ||
439 | else if(!priv->memupdate_scheduled){ | ||
440 | int tmp; | ||
441 | /* There are no buffers at the moment, so schedule */ | ||
442 | /* the background task to sort this out */ | ||
443 | schedule_task(&priv->tq_memupdate); | ||
444 | priv->memupdate_scheduled=1; | ||
445 | printk(KERN_DEBUG "%s:No buffers",dev->name); | ||
446 | /* If this interrupt was due to a lack of buffers then | ||
447 | * we'd better stop the receiver too */ | ||
448 | if(interruptValueÐER_INT_SRC_BLEX_MSK){ | ||
449 | priv->rx_disabled=1; | ||
450 | tmp=readl(ETHER_INT_SRC(dev->base_addr)); | ||
451 | writel(tmp&~ETHER_RX_CTL_RXEN_MSK,ETHER_RX_CTL(dev->base_addr)); | ||
452 | printk(KERN_DEBUG "%s:Halting rx",dev->name); | ||
453 | } | ||
454 | |||
455 | } | ||
456 | |||
457 | } | ||
458 | fda_ent_ptr++; | ||
459 | } | ||
460 | spin_unlock(&priv->rx_lock); | ||
461 | |||
462 | /* Clear the interrupts */ | ||
463 | writel(ETHER_INT_SRC_INTMACRX_MSK | ETHER_INT_SRC_FDAEX_MSK | ||
464 | | ETHER_INT_SRC_BLEX_MSK,ETHER_INT_SRC(dev->base_addr)); | ||
465 | |||
466 | } | ||
467 | |||
468 | if(readl(ETHER_INT_SRC(dev->base_addr))ÐER_INT_SRC_INTMACTX_MSK){ | ||
469 | |||
470 | if(!priv->memupdate_scheduled){ | ||
471 | schedule_task(&priv->tq_memupdate); | ||
472 | priv->memupdate_scheduled=1; | ||
473 | } | ||
474 | /* Clear the interrupt */ | ||
475 | writel(ETHER_INT_SRC_INTMACTX_MSK,ETHER_INT_SRC(dev->base_addr)); | ||
476 | } | ||
477 | |||
478 | if (readl(ETHER_INT_SRC(dev->base_addr)) & (ETHER_INT_SRC_SWINT_MSK| | ||
479 | ETHER_INT_SRC_INTEARNOT_MSK| | ||
480 | ETHER_INT_SRC_INTLINK_MSK| | ||
481 | ETHER_INT_SRC_INTEXBD_MSK| | ||
482 | ETHER_INT_SRC_INTTXCTLCMP_MSK)) | ||
483 | { | ||
484 | /* | ||
485 | * Not using any of these so they shouldn't happen | ||
486 | * | ||
487 | * In the cased of INTEXBD - if you allocate more | ||
488 | * than 28 decsriptors you may need to think about this | ||
489 | */ | ||
490 | printk("Not using this interrupt\n"); | ||
491 | } | ||
492 | |||
493 | if (readl(ETHER_INT_SRC(dev->base_addr)) & | ||
494 | (ETHER_INT_SRC_INTSBUS_MSK | | ||
495 | ETHER_INT_SRC_INTNRABT_MSK | ||
496 | |ETHER_INT_SRC_DMPARERR_MSK)) | ||
497 | { | ||
498 | /* | ||
499 | * Hardware errors, we can either ignore them and hope they go away | ||
500 | *or reset the device, I'll try the first for now to see if they happen | ||
501 | */ | ||
502 | printk("Hardware error\n"); | ||
503 | } | ||
504 | } | ||
505 | |||
506 | static void ether00_setup_ethernet_address(struct net_device* dev) | ||
507 | { | ||
508 | int tmp; | ||
509 | |||
510 | dev->addr_len=6; | ||
511 | writew(0,ETHER_ARC_ADR(dev->base_addr)); | ||
512 | writel((dev->dev_addr[0]<<24) | | ||
513 | (dev->dev_addr[1]<<16) | | ||
514 | (dev->dev_addr[2]<<8) | | ||
515 | dev->dev_addr[3], | ||
516 | ETHER_ARC_DATA(dev->base_addr)); | ||
517 | |||
518 | writew(4,ETHER_ARC_ADR(dev->base_addr)); | ||
519 | tmp=readl(ETHER_ARC_DATA(dev->base_addr)); | ||
520 | tmp&=0xffff; | ||
521 | tmp|=(dev->dev_addr[4]<<24) | (dev->dev_addr[5]<<16); | ||
522 | writel(tmp, ETHER_ARC_DATA(dev->base_addr)); | ||
523 | /* Enable this entry in the ARC */ | ||
524 | |||
525 | writel(1,ETHER_ARC_ENA(dev->base_addr)); | ||
526 | |||
527 | return; | ||
528 | } | ||
529 | |||
530 | |||
531 | static void ether00_reset(struct net_device *dev) | ||
532 | { | ||
533 | /* reset the controller */ | ||
534 | writew(ETHER_MAC_CTL_RESET_MSK,ETHER_MAC_CTL(dev->base_addr)); | ||
535 | |||
536 | /* | ||
537 | * Make sure we're not going to send anything | ||
538 | */ | ||
539 | |||
540 | writew(ETHER_TX_CTL_TXHALT_MSK,ETHER_TX_CTL(dev->base_addr)); | ||
541 | |||
542 | /* | ||
543 | * Make sure we're not going to receive anything | ||
544 | */ | ||
545 | writew(ETHER_RX_CTL_RXHALT_MSK,ETHER_RX_CTL(dev->base_addr)); | ||
546 | |||
547 | /* | ||
548 | * Disable Interrupts for now, and set the burst size to 8 bytes | ||
549 | */ | ||
550 | |||
551 | writel(ETHER_DMA_CTL_INTMASK_MSK | | ||
552 | ((8 << ETHER_DMA_CTL_DMBURST_OFST) & ETHER_DMA_CTL_DMBURST_MSK) | ||
553 | |(2<<ETHER_DMA_CTL_RXALIGN_OFST), | ||
554 | ETHER_DMA_CTL(dev->base_addr)); | ||
555 | |||
556 | |||
557 | /* | ||
558 | * Set TxThrsh - start transmitting a packet after 1514 | ||
559 | * bytes or when a packet is complete, whichever comes first | ||
560 | */ | ||
561 | writew(1514,ETHER_TXTHRSH(dev->base_addr)); | ||
562 | |||
563 | /* | ||
564 | * Set TxPollCtr. Each cycle is | ||
565 | * 61.44 microseconds with a 33 MHz bus | ||
566 | */ | ||
567 | writew(1,ETHER_TXPOLLCTR(dev->base_addr)); | ||
568 | |||
569 | /* | ||
570 | * Set Rx_Ctl - Turn off reception and let RxData turn it | ||
571 | * on later | ||
572 | */ | ||
573 | writew(ETHER_RX_CTL_RXHALT_MSK,ETHER_RX_CTL(dev->base_addr)); | ||
574 | |||
575 | } | ||
576 | |||
577 | |||
578 | static void ether00_set_multicast(struct net_device* dev) | ||
579 | { | ||
580 | int count=dev->mc_count; | ||
581 | |||
582 | /* Set promiscuous mode if it's asked for. */ | ||
583 | |||
584 | if (dev->flags&IFF_PROMISC){ | ||
585 | |||
586 | writew( ETHER_ARC_CTL_COMPEN_MSK | | ||
587 | ETHER_ARC_CTL_BROADACC_MSK | | ||
588 | ETHER_ARC_CTL_GROUPACC_MSK | | ||
589 | ETHER_ARC_CTL_STATIONACC_MSK, | ||
590 | ETHER_ARC_CTL(dev->base_addr)); | ||
591 | return; | ||
592 | } | ||
593 | |||
594 | /* | ||
595 | * Get all multicast packets if required, or if there are too | ||
596 | * many addresses to fit in hardware | ||
597 | */ | ||
598 | if (dev->flags & IFF_ALLMULTI){ | ||
599 | writew( ETHER_ARC_CTL_COMPEN_MSK | | ||
600 | ETHER_ARC_CTL_GROUPACC_MSK | | ||
601 | ETHER_ARC_CTL_BROADACC_MSK, | ||
602 | ETHER_ARC_CTL(dev->base_addr)); | ||
603 | return; | ||
604 | } | ||
605 | if (dev->mc_count > (ETHER_ARC_SIZE - 1)){ | ||
606 | |||
607 | printk(KERN_WARNING "Too many multicast addresses for hardware to filter - receiving all multicast packets\n"); | ||
608 | writew( ETHER_ARC_CTL_COMPEN_MSK | | ||
609 | ETHER_ARC_CTL_GROUPACC_MSK | | ||
610 | ETHER_ARC_CTL_BROADACC_MSK, | ||
611 | ETHER_ARC_CTL(dev->base_addr)); | ||
612 | return; | ||
613 | } | ||
614 | |||
615 | if(dev->mc_count){ | ||
616 | struct dev_mc_list *mc_list_ent=dev->mc_list; | ||
617 | unsigned int temp,i; | ||
618 | DEBUG(printk("mc_count=%d mc_list=%#x\n",dev-> mc_count, dev->mc_list)); | ||
619 | DEBUG(printk("mc addr=%02#x%02x%02x%02x%02x%02x\n", | ||
620 | mc_list_ent->dmi_addr[5], | ||
621 | mc_list_ent->dmi_addr[4], | ||
622 | mc_list_ent->dmi_addr[3], | ||
623 | mc_list_ent->dmi_addr[2], | ||
624 | mc_list_ent->dmi_addr[1], | ||
625 | mc_list_ent->dmi_addr[0]);) | ||
626 | |||
627 | /* | ||
628 | * The first 6 bytes are the MAC address, so | ||
629 | * don't change them! | ||
630 | */ | ||
631 | writew(4,ETHER_ARC_ADR(dev->base_addr)); | ||
632 | temp=readl(ETHER_ARC_DATA(dev->base_addr)); | ||
633 | temp&=0xffff0000; | ||
634 | |||
635 | /* Disable the current multicast stuff */ | ||
636 | writel(1,ETHER_ARC_ENA(dev->base_addr)); | ||
637 | |||
638 | for(;;){ | ||
639 | temp|=mc_list_ent->dmi_addr[1] | | ||
640 | mc_list_ent->dmi_addr[0]<<8; | ||
641 | writel(temp,ETHER_ARC_DATA(dev->base_addr)); | ||
642 | |||
643 | i=readl(ETHER_ARC_ADR(dev->base_addr)); | ||
644 | writew(i+4,ETHER_ARC_ADR(dev->base_addr)); | ||
645 | |||
646 | temp=mc_list_ent->dmi_addr[5]| | ||
647 | mc_list_ent->dmi_addr[4]<<8 | | ||
648 | mc_list_ent->dmi_addr[3]<<16 | | ||
649 | mc_list_ent->dmi_addr[2]<<24; | ||
650 | writel(temp,ETHER_ARC_DATA(dev->base_addr)); | ||
651 | |||
652 | count--; | ||
653 | if(!mc_list_ent->next || !count){ | ||
654 | break; | ||
655 | } | ||
656 | DEBUG(printk("mc_list_next=%#x\n",mc_list_ent->next);) | ||
657 | mc_list_ent=mc_list_ent->next; | ||
658 | |||
659 | |||
660 | i=readl(ETHER_ARC_ADR(dev->base_addr)); | ||
661 | writel(i+4,ETHER_ARC_ADR(dev->base_addr)); | ||
662 | |||
663 | temp=mc_list_ent->dmi_addr[3]| | ||
664 | mc_list_ent->dmi_addr[2]<<8 | | ||
665 | mc_list_ent->dmi_addr[1]<<16 | | ||
666 | mc_list_ent->dmi_addr[0]<<24; | ||
667 | writel(temp,ETHER_ARC_DATA(dev->base_addr)); | ||
668 | |||
669 | i=readl(ETHER_ARC_ADR(dev->base_addr)); | ||
670 | writel(i+4,ETHER_ARC_ADR(dev->base_addr)); | ||
671 | |||
672 | temp=mc_list_ent->dmi_addr[4]<<16 | | ||
673 | mc_list_ent->dmi_addr[5]<<24; | ||
674 | |||
675 | writel(temp,ETHER_ARC_DATA(dev->base_addr)); | ||
676 | |||
677 | count--; | ||
678 | if(!mc_list_ent->next || !count){ | ||
679 | break; | ||
680 | } | ||
681 | mc_list_ent=mc_list_ent->next; | ||
682 | } | ||
683 | |||
684 | |||
685 | if(count) | ||
686 | printk(KERN_WARNING "Multicast list size error\n"); | ||
687 | |||
688 | |||
689 | writew( ETHER_ARC_CTL_BROADACC_MSK| | ||
690 | ETHER_ARC_CTL_COMPEN_MSK, | ||
691 | ETHER_ARC_CTL(dev->base_addr)); | ||
692 | |||
693 | } | ||
694 | |||
695 | /* enable the active ARC enties */ | ||
696 | writew((1<<(count+2))-1,ETHER_ARC_ENA(dev->base_addr)); | ||
697 | } | ||
698 | |||
699 | |||
700 | static int ether00_open(struct net_device* dev) | ||
701 | { | ||
702 | int result,tmp; | ||
703 | struct net_priv* priv; | ||
704 | |||
705 | if (!is_valid_ether_addr(dev->dev_addr)) | ||
706 | return -EINVAL; | ||
707 | |||
708 | /* Install interrupt handlers */ | ||
709 | result=request_irq(dev->irq,ether00_int,0,"ether00",dev); | ||
710 | if(result) | ||
711 | goto open_err1; | ||
712 | |||
713 | result=request_irq(2,ether00_phy_int,0,"ether00_phy",dev); | ||
714 | if(result) | ||
715 | goto open_err2; | ||
716 | |||
717 | ether00_reset(dev); | ||
718 | result=ether00_mem_init(dev); | ||
719 | if(result) | ||
720 | goto open_err3; | ||
721 | |||
722 | |||
723 | ether00_setup_ethernet_address(dev); | ||
724 | |||
725 | ether00_set_multicast(dev); | ||
726 | |||
727 | result=ether00_write_phy(dev,PHY_CONTROL, PHY_CONTROL_ANEGEN_MSK | PHY_CONTROL_RANEG_MSK); | ||
728 | if(result) | ||
729 | goto open_err4; | ||
730 | result=ether00_write_phy(dev,PHY_IRQ_CONTROL, PHY_IRQ_CONTROL_LS_CHG_IE_MSK | | ||
731 | PHY_IRQ_CONTROL_ANEG_COMP_IE_MSK); | ||
732 | if(result) | ||
733 | goto open_err4; | ||
734 | |||
735 | /* Start the device enable interrupts */ | ||
736 | writew(ETHER_RX_CTL_RXEN_MSK | ||
737 | // | ETHER_RX_CTL_STRIPCRC_MSK | ||
738 | | ETHER_RX_CTL_ENGOOD_MSK | ||
739 | | ETHER_RX_CTL_ENRXPAR_MSK| ETHER_RX_CTL_ENLONGERR_MSK | ||
740 | | ETHER_RX_CTL_ENOVER_MSK| ETHER_RX_CTL_ENCRCERR_MSK, | ||
741 | ETHER_RX_CTL(dev->base_addr)); | ||
742 | |||
743 | writew(ETHER_TX_CTL_TXEN_MSK| | ||
744 | ETHER_TX_CTL_ENEXDEFER_MSK| | ||
745 | ETHER_TX_CTL_ENLCARR_MSK| | ||
746 | ETHER_TX_CTL_ENEXCOLL_MSK| | ||
747 | ETHER_TX_CTL_ENLATECOLL_MSK| | ||
748 | ETHER_TX_CTL_ENTXPAR_MSK| | ||
749 | ETHER_TX_CTL_ENCOMP_MSK, | ||
750 | ETHER_TX_CTL(dev->base_addr)); | ||
751 | |||
752 | tmp=readl(ETHER_DMA_CTL(dev->base_addr)); | ||
753 | writel(tmp&~ETHER_DMA_CTL_INTMASK_MSK,ETHER_DMA_CTL(dev->base_addr)); | ||
754 | |||
755 | return 0; | ||
756 | |||
757 | open_err4: | ||
758 | ether00_reset(dev); | ||
759 | open_err3: | ||
760 | free_irq(2,dev); | ||
761 | open_err2: | ||
762 | free_irq(dev->irq,dev); | ||
763 | open_err1: | ||
764 | return result; | ||
765 | |||
766 | } | ||
767 | |||
768 | |||
769 | static int ether00_tx(struct sk_buff* skb, struct net_device* dev) | ||
770 | { | ||
771 | struct net_priv *priv=dev->priv; | ||
772 | struct tx_fda_ent *fda_ptr; | ||
773 | int i; | ||
774 | |||
775 | |||
776 | /* | ||
777 | * Find an empty slot in which to stick the frame | ||
778 | */ | ||
779 | fda_ptr=(struct tx_fda_ent*)__dma_va(readl(ETHER_TXFRMPTR(dev->base_addr))); | ||
780 | i=0; | ||
781 | while(i<TX_NUM_FDESC){ | ||
782 | if (fda_ptr->fd.FDStat||(fda_ptr->fd.FDCtl & FDCTL_COWNSFD_MSK)){ | ||
783 | fda_ptr =(struct tx_fda_ent*) __dma_va((struct tx_fda_ent*)fda_ptr->fd.FDNext); | ||
784 | } | ||
785 | else { | ||
786 | break; | ||
787 | } | ||
788 | i++; | ||
789 | } | ||
790 | |||
791 | /* Write the skb data from the cache*/ | ||
792 | consistent_sync(skb->data,skb->len,PCI_DMA_TODEVICE); | ||
793 | fda_ptr->bd.BuffData=(char*)__pa(skb->data); | ||
794 | fda_ptr->bd.BuffLength=(unsigned short)skb->len; | ||
795 | /* Save the pointer to the skb for freeing later */ | ||
796 | fda_ptr->fd.FDSystem=(unsigned int)skb; | ||
797 | fda_ptr->fd.FDStat=0; | ||
798 | /* Pass ownership of the buffers to the controller */ | ||
799 | fda_ptr->fd.FDCtl=1; | ||
800 | fda_ptr->fd.FDCtl|=FDCTL_COWNSFD_MSK; | ||
801 | |||
802 | /* If the next buffer in the list is full, stop the queue */ | ||
803 | fda_ptr=(struct tx_fda_ent*)__dma_va(fda_ptr->fd.FDNext); | ||
804 | if ((fda_ptr->fd.FDStat)||(fda_ptr->fd.FDCtl & FDCTL_COWNSFD_MSK)){ | ||
805 | netif_stop_queue(dev); | ||
806 | priv->queue_stopped=1; | ||
807 | } | ||
808 | |||
809 | return 0; | ||
810 | } | ||
811 | |||
812 | static struct net_device_stats *ether00_stats(struct net_device* dev) | ||
813 | { | ||
814 | struct net_priv *priv=dev->priv; | ||
815 | return &priv->stats; | ||
816 | } | ||
817 | |||
818 | |||
819 | static int ether00_stop(struct net_device* dev) | ||
820 | { | ||
821 | struct net_priv *priv=dev->priv; | ||
822 | int tmp; | ||
823 | |||
824 | /* Stop/disable the device. */ | ||
825 | tmp=readw(ETHER_RX_CTL(dev->base_addr)); | ||
826 | tmp&=~(ETHER_RX_CTL_RXEN_MSK | ETHER_RX_CTL_ENGOOD_MSK); | ||
827 | tmp|=ETHER_RX_CTL_RXHALT_MSK; | ||
828 | writew(tmp,ETHER_RX_CTL(dev->base_addr)); | ||
829 | |||
830 | tmp=readl(ETHER_TX_CTL(dev->base_addr)); | ||
831 | tmp&=~ETHER_TX_CTL_TXEN_MSK; | ||
832 | tmp|=ETHER_TX_CTL_TXHALT_MSK; | ||
833 | writel(tmp,ETHER_TX_CTL(dev->base_addr)); | ||
834 | |||
835 | /* Free up system resources */ | ||
836 | free_irq(dev->irq,dev); | ||
837 | free_irq(2,dev); | ||
838 | iounmap(priv->dma_data); | ||
839 | |||
840 | return 0; | ||
841 | } | ||
842 | |||
843 | |||
844 | static void ether00_get_ethernet_address(struct net_device* dev) | ||
845 | { | ||
846 | struct mtd_info *mymtd=NULL; | ||
847 | int i; | ||
848 | size_t retlen; | ||
849 | |||
850 | /* | ||
851 | * For the Epxa10 dev board (camelot), the ethernet MAC | ||
852 | * address is of the form 00:aa:aa:00:xx:xx where | ||
853 | * 00:aa:aa is the Altera vendor ID and xx:xx is the | ||
854 | * last 2 bytes of the board serial number, as programmed | ||
855 | * into the OTP area of the flash device on EBI1. If this | ||
856 | * isn't an expa10 dev board, or there's no mtd support to | ||
857 | * read the serial number from flash then we'll force the | ||
858 | * use to set their own mac address using ifconfig. | ||
859 | */ | ||
860 | |||
861 | #ifdef CONFIG_ARCH_CAMELOT | ||
862 | #ifdef CONFIG_MTD | ||
863 | /* get the mtd_info structure for the first mtd device*/ | ||
864 | for(i=0;i<MAX_MTD_DEVICES;i++){ | ||
865 | mymtd=get_mtd_device(NULL,i); | ||
866 | if(!mymtd||!strcmp(mymtd->name,"EPXA10DB flash")) | ||
867 | break; | ||
868 | } | ||
869 | |||
870 | if(!mymtd || !mymtd->read_user_prot_reg){ | ||
871 | printk(KERN_WARNING "%s: Failed to read MAC address from flash\n",dev->name); | ||
872 | }else{ | ||
873 | mymtd->read_user_prot_reg(mymtd,2,1,&retlen,&dev->dev_addr[5]); | ||
874 | mymtd->read_user_prot_reg(mymtd,3,1,&retlen,&dev->dev_addr[4]); | ||
875 | dev->dev_addr[3]=0; | ||
876 | dev->dev_addr[2]=vendor_id[1]; | ||
877 | dev->dev_addr[1]=vendor_id[0]; | ||
878 | dev->dev_addr[0]=0; | ||
879 | } | ||
880 | #else | ||
881 | printk(KERN_WARNING "%s: MTD support required to read MAC address from EPXA10 dev board\n", dev->name); | ||
882 | #endif | ||
883 | #endif | ||
884 | |||
885 | if (!is_valid_ether_addr(dev->dev_addr)) | ||
886 | printk("%s: Invalid ethernet MAC address. Please set using " | ||
887 | "ifconfig\n", dev->name); | ||
888 | |||
889 | } | ||
890 | |||
891 | /* | ||
892 | * Keep a mapping of dev_info addresses -> port lines to use when | ||
893 | * removing ports dev==NULL indicates unused entry | ||
894 | */ | ||
895 | |||
896 | |||
897 | static struct net_device* dev_list[ETH_NR]; | ||
898 | |||
899 | static int ether00_add_device(struct pldhs_dev_info* dev_info,void* dev_ps_data) | ||
900 | { | ||
901 | struct net_device *dev; | ||
902 | struct net_priv *priv; | ||
903 | void *map_addr; | ||
904 | int result; | ||
905 | int i; | ||
906 | |||
907 | i=0; | ||
908 | while(dev_list[i] && i < ETH_NR) | ||
909 | i++; | ||
910 | |||
911 | if(i==ETH_NR){ | ||
912 | printk(KERN_WARNING "ether00: Maximum number of ports reached\n"); | ||
913 | return 0; | ||
914 | } | ||
915 | |||
916 | |||
917 | if (!request_mem_region(dev_info->base_addr, MAC_REG_SIZE, "ether00")) | ||
918 | return -EBUSY; | ||
919 | |||
920 | dev = alloc_etherdev(sizeof(struct net_priv)); | ||
921 | if(!dev) { | ||
922 | result = -ENOMEM; | ||
923 | goto out_release; | ||
924 | } | ||
925 | priv = dev->priv; | ||
926 | |||
927 | priv->tq_memupdate.routine=ether00_mem_update; | ||
928 | priv->tq_memupdate.data=(void*) dev; | ||
929 | |||
930 | spin_lock_init(&priv->rx_lock); | ||
931 | |||
932 | map_addr=ioremap_nocache(dev_info->base_addr,SZ_4K); | ||
933 | if(!map_addr){ | ||
934 | result = -ENOMEM; | ||
935 | out_kfree; | ||
936 | } | ||
937 | |||
938 | dev->open=ether00_open; | ||
939 | dev->stop=ether00_stop; | ||
940 | dev->set_multicast_list=ether00_set_multicast; | ||
941 | dev->hard_start_xmit=ether00_tx; | ||
942 | dev->get_stats=ether00_stats; | ||
943 | |||
944 | ether00_get_ethernet_address(dev); | ||
945 | |||
946 | SET_MODULE_OWNER(dev); | ||
947 | |||
948 | dev->base_addr=(unsigned int)map_addr; | ||
949 | dev->irq=dev_info->irq; | ||
950 | dev->features=NETIF_F_DYNALLOC | NETIF_F_HW_CSUM; | ||
951 | |||
952 | result=register_netdev(dev); | ||
953 | if(result){ | ||
954 | printk("Ether00: Error %i registering driver\n",result); | ||
955 | goto out_unmap; | ||
956 | } | ||
957 | printk("registered ether00 device at %#x\n",dev_info->base_addr); | ||
958 | |||
959 | dev_list[i]=dev; | ||
960 | |||
961 | return result; | ||
962 | |||
963 | out_unmap: | ||
964 | iounmap(map_addr); | ||
965 | out_kfree: | ||
966 | free_netdev(dev); | ||
967 | out_release: | ||
968 | release_mem_region(dev_info->base_addr, MAC_REG_SIZE); | ||
969 | return result; | ||
970 | } | ||
971 | |||
972 | |||
973 | static int ether00_remove_devices(void) | ||
974 | { | ||
975 | int i; | ||
976 | |||
977 | for(i=0;i<ETH_NR;i++){ | ||
978 | if(dev_list[i]){ | ||
979 | netif_device_detach(dev_list[i]); | ||
980 | unregister_netdev(dev_list[i]); | ||
981 | iounmap((void*)dev_list[i]->base_addr); | ||
982 | release_mem_region(dev_list[i]->base_addr, MAC_REG_SIZE); | ||
983 | free_netdev(dev_list[i]); | ||
984 | dev_list[i]=0; | ||
985 | } | ||
986 | } | ||
987 | return 0; | ||
988 | } | ||
989 | |||
990 | static struct pld_hotswap_ops ether00_pldhs_ops={ | ||
991 | .name = ETHER00_NAME, | ||
992 | .add_device = ether00_add_device, | ||
993 | .remove_devices = ether00_remove_devices, | ||
994 | }; | ||
995 | |||
996 | |||
997 | static void __exit ether00_cleanup_module(void) | ||
998 | { | ||
999 | int result; | ||
1000 | result=ether00_remove_devices(); | ||
1001 | if(result) | ||
1002 | printk(KERN_WARNING "ether00: failed to remove all devices\n"); | ||
1003 | |||
1004 | pldhs_unregister_driver(ETHER00_NAME); | ||
1005 | } | ||
1006 | module_exit(ether00_cleanup_module); | ||
1007 | |||
1008 | |||
1009 | static int __init ether00_mod_init(void) | ||
1010 | { | ||
1011 | printk("mod init\n"); | ||
1012 | return pldhs_register_driver(ðer00_pldhs_ops); | ||
1013 | |||
1014 | } | ||
1015 | |||
1016 | module_init(ether00_mod_init); | ||
1017 | |||
diff --git a/drivers/net/arm/ether3.c b/drivers/net/arm/ether3.c index 1cc53abc3a39..f1d5b1027ff7 100644 --- a/drivers/net/arm/ether3.c +++ b/drivers/net/arm/ether3.c | |||
@@ -69,7 +69,6 @@ | |||
69 | #include <asm/system.h> | 69 | #include <asm/system.h> |
70 | #include <asm/ecard.h> | 70 | #include <asm/ecard.h> |
71 | #include <asm/io.h> | 71 | #include <asm/io.h> |
72 | #include <asm/irq.h> | ||
73 | 72 | ||
74 | static char version[] __initdata = "ether3 ethernet driver (c) 1995-2000 R.M.King v1.17\n"; | 73 | static char version[] __initdata = "ether3 ethernet driver (c) 1995-2000 R.M.King v1.17\n"; |
75 | 74 | ||
diff --git a/drivers/net/arm/etherh.c b/drivers/net/arm/etherh.c index 942a2819576c..6a93b666eb72 100644 --- a/drivers/net/arm/etherh.c +++ b/drivers/net/arm/etherh.c | |||
@@ -50,7 +50,6 @@ | |||
50 | #include <asm/system.h> | 50 | #include <asm/system.h> |
51 | #include <asm/ecard.h> | 51 | #include <asm/ecard.h> |
52 | #include <asm/io.h> | 52 | #include <asm/io.h> |
53 | #include <asm/irq.h> | ||
54 | 53 | ||
55 | #include "../8390.h" | 54 | #include "../8390.h" |
56 | 55 | ||
diff --git a/drivers/scsi/arm/acornscsi.c b/drivers/scsi/arm/acornscsi.c index 09ed05727bcb..dda5a5f79c53 100644 --- a/drivers/scsi/arm/acornscsi.c +++ b/drivers/scsi/arm/acornscsi.c | |||
@@ -146,7 +146,6 @@ | |||
146 | 146 | ||
147 | #include <asm/system.h> | 147 | #include <asm/system.h> |
148 | #include <asm/io.h> | 148 | #include <asm/io.h> |
149 | #include <asm/irq.h> | ||
150 | #include <asm/ecard.h> | 149 | #include <asm/ecard.h> |
151 | 150 | ||
152 | #include "../scsi.h" | 151 | #include "../scsi.h" |
diff --git a/drivers/scsi/arm/arxescsi.c b/drivers/scsi/arm/arxescsi.c index 804125e35fc3..a28940156703 100644 --- a/drivers/scsi/arm/arxescsi.c +++ b/drivers/scsi/arm/arxescsi.c | |||
@@ -33,7 +33,6 @@ | |||
33 | 33 | ||
34 | #include <asm/dma.h> | 34 | #include <asm/dma.h> |
35 | #include <asm/io.h> | 35 | #include <asm/io.h> |
36 | #include <asm/irq.h> | ||
37 | #include <asm/ecard.h> | 36 | #include <asm/ecard.h> |
38 | 37 | ||
39 | #include "../scsi.h" | 38 | #include "../scsi.h" |
diff --git a/drivers/scsi/arm/cumana_1.c b/drivers/scsi/arm/cumana_1.c index 81e266be26d0..e6c9491dc5c0 100644 --- a/drivers/scsi/arm/cumana_1.c +++ b/drivers/scsi/arm/cumana_1.c | |||
@@ -13,7 +13,6 @@ | |||
13 | 13 | ||
14 | #include <asm/ecard.h> | 14 | #include <asm/ecard.h> |
15 | #include <asm/io.h> | 15 | #include <asm/io.h> |
16 | #include <asm/irq.h> | ||
17 | #include <asm/system.h> | 16 | #include <asm/system.h> |
18 | 17 | ||
19 | #include "../scsi.h" | 18 | #include "../scsi.h" |
diff --git a/drivers/scsi/arm/cumana_2.c b/drivers/scsi/arm/cumana_2.c index 3a7a46b0dc41..583d2d8c8335 100644 --- a/drivers/scsi/arm/cumana_2.c +++ b/drivers/scsi/arm/cumana_2.c | |||
@@ -31,7 +31,6 @@ | |||
31 | #include <asm/dma.h> | 31 | #include <asm/dma.h> |
32 | #include <asm/ecard.h> | 32 | #include <asm/ecard.h> |
33 | #include <asm/io.h> | 33 | #include <asm/io.h> |
34 | #include <asm/irq.h> | ||
35 | #include <asm/pgtable.h> | 34 | #include <asm/pgtable.h> |
36 | 35 | ||
37 | #include "../scsi.h" | 36 | #include "../scsi.h" |
diff --git a/drivers/scsi/arm/eesox.c b/drivers/scsi/arm/eesox.c index 4d1e8f52c924..3ffec7efc9d5 100644 --- a/drivers/scsi/arm/eesox.c +++ b/drivers/scsi/arm/eesox.c | |||
@@ -35,7 +35,6 @@ | |||
35 | #include <linux/dma-mapping.h> | 35 | #include <linux/dma-mapping.h> |
36 | 36 | ||
37 | #include <asm/io.h> | 37 | #include <asm/io.h> |
38 | #include <asm/irq.h> | ||
39 | #include <asm/dma.h> | 38 | #include <asm/dma.h> |
40 | #include <asm/ecard.h> | 39 | #include <asm/ecard.h> |
41 | #include <asm/pgtable.h> | 40 | #include <asm/pgtable.h> |
diff --git a/drivers/scsi/arm/powertec.c b/drivers/scsi/arm/powertec.c index 3333d7b39139..3113bdcedb13 100644 --- a/drivers/scsi/arm/powertec.c +++ b/drivers/scsi/arm/powertec.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include <asm/dma.h> | 22 | #include <asm/dma.h> |
23 | #include <asm/ecard.h> | 23 | #include <asm/ecard.h> |
24 | #include <asm/io.h> | 24 | #include <asm/io.h> |
25 | #include <asm/irq.h> | ||
26 | #include <asm/pgtable.h> | 25 | #include <asm/pgtable.h> |
27 | 26 | ||
28 | #include "../scsi.h" | 27 | #include "../scsi.h" |
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c index 1891cf5bdeef..e8454611cb65 100644 --- a/drivers/serial/8250.c +++ b/drivers/serial/8250.c | |||
@@ -54,6 +54,8 @@ | |||
54 | */ | 54 | */ |
55 | static unsigned int share_irqs = SERIAL8250_SHARE_IRQS; | 55 | static unsigned int share_irqs = SERIAL8250_SHARE_IRQS; |
56 | 56 | ||
57 | static unsigned int nr_uarts = CONFIG_SERIAL_8250_RUNTIME_UARTS; | ||
58 | |||
57 | /* | 59 | /* |
58 | * Debugging. | 60 | * Debugging. |
59 | */ | 61 | */ |
@@ -2118,7 +2120,7 @@ static void __init serial8250_isa_init_ports(void) | |||
2118 | return; | 2120 | return; |
2119 | first = 0; | 2121 | first = 0; |
2120 | 2122 | ||
2121 | for (i = 0; i < UART_NR; i++) { | 2123 | for (i = 0; i < nr_uarts; i++) { |
2122 | struct uart_8250_port *up = &serial8250_ports[i]; | 2124 | struct uart_8250_port *up = &serial8250_ports[i]; |
2123 | 2125 | ||
2124 | up->port.line = i; | 2126 | up->port.line = i; |
@@ -2137,7 +2139,7 @@ static void __init serial8250_isa_init_ports(void) | |||
2137 | } | 2139 | } |
2138 | 2140 | ||
2139 | for (i = 0, up = serial8250_ports; | 2141 | for (i = 0, up = serial8250_ports; |
2140 | i < ARRAY_SIZE(old_serial_port) && i < UART_NR; | 2142 | i < ARRAY_SIZE(old_serial_port) && i < nr_uarts; |
2141 | i++, up++) { | 2143 | i++, up++) { |
2142 | up->port.iobase = old_serial_port[i].port; | 2144 | up->port.iobase = old_serial_port[i].port; |
2143 | up->port.irq = irq_canonicalize(old_serial_port[i].irq); | 2145 | up->port.irq = irq_canonicalize(old_serial_port[i].irq); |
@@ -2159,7 +2161,7 @@ serial8250_register_ports(struct uart_driver *drv, struct device *dev) | |||
2159 | 2161 | ||
2160 | serial8250_isa_init_ports(); | 2162 | serial8250_isa_init_ports(); |
2161 | 2163 | ||
2162 | for (i = 0; i < UART_NR; i++) { | 2164 | for (i = 0; i < nr_uarts; i++) { |
2163 | struct uart_8250_port *up = &serial8250_ports[i]; | 2165 | struct uart_8250_port *up = &serial8250_ports[i]; |
2164 | 2166 | ||
2165 | up->port.dev = dev; | 2167 | up->port.dev = dev; |
@@ -2262,7 +2264,7 @@ static int serial8250_console_setup(struct console *co, char *options) | |||
2262 | * if so, search for the first available port that does have | 2264 | * if so, search for the first available port that does have |
2263 | * console support. | 2265 | * console support. |
2264 | */ | 2266 | */ |
2265 | if (co->index >= UART_NR) | 2267 | if (co->index >= nr_uarts) |
2266 | co->index = 0; | 2268 | co->index = 0; |
2267 | port = &serial8250_ports[co->index].port; | 2269 | port = &serial8250_ports[co->index].port; |
2268 | if (!port->iobase && !port->membase) | 2270 | if (!port->iobase && !port->membase) |
@@ -2298,7 +2300,7 @@ static int __init find_port(struct uart_port *p) | |||
2298 | int line; | 2300 | int line; |
2299 | struct uart_port *port; | 2301 | struct uart_port *port; |
2300 | 2302 | ||
2301 | for (line = 0; line < UART_NR; line++) { | 2303 | for (line = 0; line < nr_uarts; line++) { |
2302 | port = &serial8250_ports[line].port; | 2304 | port = &serial8250_ports[line].port; |
2303 | if (uart_match_port(p, port)) | 2305 | if (uart_match_port(p, port)) |
2304 | return line; | 2306 | return line; |
@@ -2420,7 +2422,7 @@ static int __devexit serial8250_remove(struct platform_device *dev) | |||
2420 | { | 2422 | { |
2421 | int i; | 2423 | int i; |
2422 | 2424 | ||
2423 | for (i = 0; i < UART_NR; i++) { | 2425 | for (i = 0; i < nr_uarts; i++) { |
2424 | struct uart_8250_port *up = &serial8250_ports[i]; | 2426 | struct uart_8250_port *up = &serial8250_ports[i]; |
2425 | 2427 | ||
2426 | if (up->port.dev == &dev->dev) | 2428 | if (up->port.dev == &dev->dev) |
@@ -2487,7 +2489,7 @@ static struct uart_8250_port *serial8250_find_match_or_unused(struct uart_port * | |||
2487 | /* | 2489 | /* |
2488 | * First, find a port entry which matches. | 2490 | * First, find a port entry which matches. |
2489 | */ | 2491 | */ |
2490 | for (i = 0; i < UART_NR; i++) | 2492 | for (i = 0; i < nr_uarts; i++) |
2491 | if (uart_match_port(&serial8250_ports[i].port, port)) | 2493 | if (uart_match_port(&serial8250_ports[i].port, port)) |
2492 | return &serial8250_ports[i]; | 2494 | return &serial8250_ports[i]; |
2493 | 2495 | ||
@@ -2496,7 +2498,7 @@ static struct uart_8250_port *serial8250_find_match_or_unused(struct uart_port * | |||
2496 | * free entry. We look for one which hasn't been previously | 2498 | * free entry. We look for one which hasn't been previously |
2497 | * used (indicated by zero iobase). | 2499 | * used (indicated by zero iobase). |
2498 | */ | 2500 | */ |
2499 | for (i = 0; i < UART_NR; i++) | 2501 | for (i = 0; i < nr_uarts; i++) |
2500 | if (serial8250_ports[i].port.type == PORT_UNKNOWN && | 2502 | if (serial8250_ports[i].port.type == PORT_UNKNOWN && |
2501 | serial8250_ports[i].port.iobase == 0) | 2503 | serial8250_ports[i].port.iobase == 0) |
2502 | return &serial8250_ports[i]; | 2504 | return &serial8250_ports[i]; |
@@ -2505,7 +2507,7 @@ static struct uart_8250_port *serial8250_find_match_or_unused(struct uart_port * | |||
2505 | * That also failed. Last resort is to find any entry which | 2507 | * That also failed. Last resort is to find any entry which |
2506 | * doesn't have a real port associated with it. | 2508 | * doesn't have a real port associated with it. |
2507 | */ | 2509 | */ |
2508 | for (i = 0; i < UART_NR; i++) | 2510 | for (i = 0; i < nr_uarts; i++) |
2509 | if (serial8250_ports[i].port.type == PORT_UNKNOWN) | 2511 | if (serial8250_ports[i].port.type == PORT_UNKNOWN) |
2510 | return &serial8250_ports[i]; | 2512 | return &serial8250_ports[i]; |
2511 | 2513 | ||
@@ -2590,8 +2592,11 @@ static int __init serial8250_init(void) | |||
2590 | { | 2592 | { |
2591 | int ret, i; | 2593 | int ret, i; |
2592 | 2594 | ||
2595 | if (nr_uarts > UART_NR) | ||
2596 | nr_uarts = UART_NR; | ||
2597 | |||
2593 | printk(KERN_INFO "Serial: 8250/16550 driver $Revision: 1.90 $ " | 2598 | printk(KERN_INFO "Serial: 8250/16550 driver $Revision: 1.90 $ " |
2594 | "%d ports, IRQ sharing %sabled\n", (int) UART_NR, | 2599 | "%d ports, IRQ sharing %sabled\n", nr_uarts, |
2595 | share_irqs ? "en" : "dis"); | 2600 | share_irqs ? "en" : "dis"); |
2596 | 2601 | ||
2597 | for (i = 0; i < NR_IRQS; i++) | 2602 | for (i = 0; i < NR_IRQS; i++) |
@@ -2651,6 +2656,9 @@ module_param(share_irqs, uint, 0644); | |||
2651 | MODULE_PARM_DESC(share_irqs, "Share IRQs with other non-8250/16x50 devices" | 2656 | MODULE_PARM_DESC(share_irqs, "Share IRQs with other non-8250/16x50 devices" |
2652 | " (unsafe)"); | 2657 | " (unsafe)"); |
2653 | 2658 | ||
2659 | module_param(nr_uarts, uint, 0644); | ||
2660 | MODULE_PARM_DESC(nr_uarts, "Maximum number of UARTs supported. (1-" __MODULE_STRING(CONFIG_SERIAL_8250_NR_UARTS) ")"); | ||
2661 | |||
2654 | #ifdef CONFIG_SERIAL_8250_RSA | 2662 | #ifdef CONFIG_SERIAL_8250_RSA |
2655 | module_param_array(probe_rsa, ulong, &probe_rsa_count, 0444); | 2663 | module_param_array(probe_rsa, ulong, &probe_rsa_count, 0444); |
2656 | MODULE_PARM_DESC(probe_rsa, "Probe I/O ports for RSA"); | 2664 | MODULE_PARM_DESC(probe_rsa, "Probe I/O ports for RSA"); |
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index 812bae62c8ec..1bae26a8a503 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig | |||
@@ -95,6 +95,16 @@ config SERIAL_8250_NR_UARTS | |||
95 | PCI enumeration and any ports that may be added at run-time | 95 | PCI enumeration and any ports that may be added at run-time |
96 | via hot-plug, or any ISA multi-port serial cards. | 96 | via hot-plug, or any ISA multi-port serial cards. |
97 | 97 | ||
98 | config SERIAL_8250_RUNTIME_UARTS | ||
99 | int "Number of 8250/16550 serial ports to register at runtime" | ||
100 | depends on SERIAL_8250 | ||
101 | default "4" | ||
102 | help | ||
103 | Set this to the maximum number of serial ports you want | ||
104 | the kernel to register at boot time. This can be overriden | ||
105 | with the module parameter "nr_uarts", or boot-time parameter | ||
106 | 8250.nr_uarts | ||
107 | |||
98 | config SERIAL_8250_EXTENDED | 108 | config SERIAL_8250_EXTENDED |
99 | bool "Extended 8250/16550 serial driver options" | 109 | bool "Extended 8250/16550 serial driver options" |
100 | depends on SERIAL_8250 | 110 | depends on SERIAL_8250 |
@@ -359,29 +369,6 @@ config SERIAL_21285_CONSOLE | |||
359 | your boot loader (lilo or loadlin) about how to pass options to the | 369 | your boot loader (lilo or loadlin) about how to pass options to the |
360 | kernel at boot time.) | 370 | kernel at boot time.) |
361 | 371 | ||
362 | config SERIAL_UART00 | ||
363 | bool "Excalibur serial port (uart00) support" | ||
364 | depends on ARM && ARCH_CAMELOT | ||
365 | select SERIAL_CORE | ||
366 | help | ||
367 | Say Y here if you want to use the hard logic uart on Excalibur. This | ||
368 | driver also supports soft logic implementations of this uart core. | ||
369 | |||
370 | config SERIAL_UART00_CONSOLE | ||
371 | bool "Support for console on Excalibur serial port" | ||
372 | depends on SERIAL_UART00 | ||
373 | select SERIAL_CORE_CONSOLE | ||
374 | help | ||
375 | Say Y here if you want to support a serial console on an Excalibur | ||
376 | hard logic uart or uart00 IP core. | ||
377 | |||
378 | Even if you say Y here, the currently visible virtual console | ||
379 | (/dev/tty0) will still be used as the system console by default, but | ||
380 | you can alter that using a kernel command line option such as | ||
381 | "console=ttyS1". (Try "man bootparam" or see the documentation of | ||
382 | your boot loader (lilo or loadlin) about how to pass options to the | ||
383 | kernel at boot time.) | ||
384 | |||
385 | config SERIAL_MPSC | 372 | config SERIAL_MPSC |
386 | bool "Marvell MPSC serial port support" | 373 | bool "Marvell MPSC serial port support" |
387 | depends on PPC32 && MV64X60 | 374 | depends on PPC32 && MV64X60 |
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile index d7c7c7180e33..137148bba4fa 100644 --- a/drivers/serial/Makefile +++ b/drivers/serial/Makefile | |||
@@ -29,7 +29,6 @@ obj-$(CONFIG_SERIAL_CLPS711X) += clps711x.o | |||
29 | obj-$(CONFIG_SERIAL_PXA) += pxa.o | 29 | obj-$(CONFIG_SERIAL_PXA) += pxa.o |
30 | obj-$(CONFIG_SERIAL_SA1100) += sa1100.o | 30 | obj-$(CONFIG_SERIAL_SA1100) += sa1100.o |
31 | obj-$(CONFIG_SERIAL_S3C2410) += s3c2410.o | 31 | obj-$(CONFIG_SERIAL_S3C2410) += s3c2410.o |
32 | obj-$(CONFIG_SERIAL_UART00) += uart00.o | ||
33 | obj-$(CONFIG_SERIAL_SUNCORE) += suncore.o | 32 | obj-$(CONFIG_SERIAL_SUNCORE) += suncore.o |
34 | obj-$(CONFIG_SERIAL_SUNZILOG) += sunzilog.o | 33 | obj-$(CONFIG_SERIAL_SUNZILOG) += sunzilog.o |
35 | obj-$(CONFIG_SERIAL_IP22_ZILOG) += ip22zilog.o | 34 | obj-$(CONFIG_SERIAL_IP22_ZILOG) += ip22zilog.o |
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c index 34c576dfad8d..9589509fc5bd 100644 --- a/drivers/serial/serial_core.c +++ b/drivers/serial/serial_core.c | |||
@@ -1440,6 +1440,7 @@ uart_block_til_ready(struct file *filp, struct uart_state *state) | |||
1440 | * modem is ready for us. | 1440 | * modem is ready for us. |
1441 | */ | 1441 | */ |
1442 | spin_lock_irq(&port->lock); | 1442 | spin_lock_irq(&port->lock); |
1443 | port->ops->enable_ms(port); | ||
1443 | mctrl = port->ops->get_mctrl(port); | 1444 | mctrl = port->ops->get_mctrl(port); |
1444 | spin_unlock_irq(&port->lock); | 1445 | spin_unlock_irq(&port->lock); |
1445 | if (mctrl & TIOCM_CAR) | 1446 | if (mctrl & TIOCM_CAR) |
diff --git a/drivers/serial/uart00.c b/drivers/serial/uart00.c deleted file mode 100644 index 47b504ff38b2..000000000000 --- a/drivers/serial/uart00.c +++ /dev/null | |||
@@ -1,782 +0,0 @@ | |||
1 | /* | ||
2 | * linux/drivers/serial/uart00.c | ||
3 | * | ||
4 | * Driver for UART00 serial ports | ||
5 | * | ||
6 | * Based on drivers/char/serial_amba.c, by ARM Limited & | ||
7 | * Deep Blue Solutions Ltd. | ||
8 | * Copyright 2001 Altera Corporation | ||
9 | * | ||
10 | * Update for 2.6.4 by Dirk Behme <dirk.behme@de.bosch.com> | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or modify | ||
13 | * it under the terms of the GNU General Public License as published by | ||
14 | * the Free Software Foundation; either version 2 of the License, or | ||
15 | * (at your option) any later version. | ||
16 | * | ||
17 | * This program is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | * GNU General Public License for more details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
25 | * | ||
26 | * $Id: uart00.c,v 1.35 2002/07/28 10:03:28 rmk Exp $ | ||
27 | * | ||
28 | */ | ||
29 | #include <linux/config.h> | ||
30 | |||
31 | #if defined(CONFIG_SERIAL_UART00_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) | ||
32 | #define SUPPORT_SYSRQ | ||
33 | #endif | ||
34 | |||
35 | #include <linux/module.h> | ||
36 | #include <linux/ioport.h> | ||
37 | #include <linux/init.h> | ||
38 | #include <linux/console.h> | ||
39 | #include <linux/sysrq.h> | ||
40 | #include <linux/tty.h> | ||
41 | #include <linux/tty_flip.h> | ||
42 | #include <linux/serial_core.h> | ||
43 | #include <linux/serial.h> | ||
44 | |||
45 | #include <asm/io.h> | ||
46 | #include <asm/irq.h> | ||
47 | #include <asm/sizes.h> | ||
48 | |||
49 | #include <asm/arch/excalibur.h> | ||
50 | #define UART00_TYPE (volatile unsigned int*) | ||
51 | #include <asm/arch/uart00.h> | ||
52 | #include <asm/arch/int_ctrl00.h> | ||
53 | |||
54 | #define UART_NR 2 | ||
55 | |||
56 | #define SERIAL_UART00_NAME "ttyUA" | ||
57 | #define SERIAL_UART00_MAJOR 204 | ||
58 | #define SERIAL_UART00_MINOR 16 /* Temporary - will change in future */ | ||
59 | #define SERIAL_UART00_NR UART_NR | ||
60 | #define UART_PORT_SIZE 0x50 | ||
61 | |||
62 | #define UART00_ISR_PASS_LIMIT 256 | ||
63 | |||
64 | /* | ||
65 | * Access macros for the UART00 UARTs | ||
66 | */ | ||
67 | #define UART_GET_INT_STATUS(p) inl(UART_ISR((p)->membase)) | ||
68 | #define UART_PUT_IES(p, c) outl(c,UART_IES((p)->membase)) | ||
69 | #define UART_GET_IES(p) inl(UART_IES((p)->membase)) | ||
70 | #define UART_PUT_IEC(p, c) outl(c,UART_IEC((p)->membase)) | ||
71 | #define UART_GET_IEC(p) inl(UART_IEC((p)->membase)) | ||
72 | #define UART_PUT_CHAR(p, c) outl(c,UART_TD((p)->membase)) | ||
73 | #define UART_GET_CHAR(p) inl(UART_RD((p)->membase)) | ||
74 | #define UART_GET_RSR(p) inl(UART_RSR((p)->membase)) | ||
75 | #define UART_GET_RDS(p) inl(UART_RDS((p)->membase)) | ||
76 | #define UART_GET_MSR(p) inl(UART_MSR((p)->membase)) | ||
77 | #define UART_GET_MCR(p) inl(UART_MCR((p)->membase)) | ||
78 | #define UART_PUT_MCR(p, c) outl(c,UART_MCR((p)->membase)) | ||
79 | #define UART_GET_MC(p) inl(UART_MC((p)->membase)) | ||
80 | #define UART_PUT_MC(p, c) outl(c,UART_MC((p)->membase)) | ||
81 | #define UART_GET_TSR(p) inl(UART_TSR((p)->membase)) | ||
82 | #define UART_GET_DIV_HI(p) inl(UART_DIV_HI((p)->membase)) | ||
83 | #define UART_PUT_DIV_HI(p,c) outl(c,UART_DIV_HI((p)->membase)) | ||
84 | #define UART_GET_DIV_LO(p) inl(UART_DIV_LO((p)->membase)) | ||
85 | #define UART_PUT_DIV_LO(p,c) outl(c,UART_DIV_LO((p)->membase)) | ||
86 | #define UART_RX_DATA(s) ((s) & UART_RSR_RX_LEVEL_MSK) | ||
87 | #define UART_TX_READY(s) (((s) & UART_TSR_TX_LEVEL_MSK) < 15) | ||
88 | //#define UART_TX_EMPTY(p) ((UART_GET_FR(p) & UART00_UARTFR_TMSK) == 0) | ||
89 | |||
90 | static void uart00_stop_tx(struct uart_port *port) | ||
91 | { | ||
92 | UART_PUT_IEC(port, UART_IEC_TIE_MSK); | ||
93 | } | ||
94 | |||
95 | static void uart00_stop_rx(struct uart_port *port) | ||
96 | { | ||
97 | UART_PUT_IEC(port, UART_IEC_RE_MSK); | ||
98 | } | ||
99 | |||
100 | static void uart00_enable_ms(struct uart_port *port) | ||
101 | { | ||
102 | UART_PUT_IES(port, UART_IES_ME_MSK); | ||
103 | } | ||
104 | |||
105 | static void | ||
106 | uart00_rx_chars(struct uart_port *port, struct pt_regs *regs) | ||
107 | { | ||
108 | struct tty_struct *tty = port->info->tty; | ||
109 | unsigned int status, ch, rds, flg, ignored = 0; | ||
110 | |||
111 | status = UART_GET_RSR(port); | ||
112 | while (UART_RX_DATA(status)) { | ||
113 | /* | ||
114 | * We need to read rds before reading the | ||
115 | * character from the fifo | ||
116 | */ | ||
117 | rds = UART_GET_RDS(port); | ||
118 | ch = UART_GET_CHAR(port); | ||
119 | port->icount.rx++; | ||
120 | |||
121 | if (tty->flip.count >= TTY_FLIPBUF_SIZE) | ||
122 | goto ignore_char; | ||
123 | |||
124 | flg = TTY_NORMAL; | ||
125 | |||
126 | /* | ||
127 | * Note that the error handling code is | ||
128 | * out of the main execution path | ||
129 | */ | ||
130 | if (rds & (UART_RDS_BI_MSK |UART_RDS_FE_MSK| | ||
131 | UART_RDS_PE_MSK |UART_RDS_PE_MSK)) | ||
132 | goto handle_error; | ||
133 | if (uart_handle_sysrq_char(port, ch, regs)) | ||
134 | goto ignore_char; | ||
135 | |||
136 | error_return: | ||
137 | tty_insert_flip_char(tty, ch, flg); | ||
138 | |||
139 | ignore_char: | ||
140 | status = UART_GET_RSR(port); | ||
141 | } | ||
142 | out: | ||
143 | tty_flip_buffer_push(tty); | ||
144 | return; | ||
145 | |||
146 | handle_error: | ||
147 | if (rds & UART_RDS_BI_MSK) { | ||
148 | status &= ~(UART_RDS_FE_MSK | UART_RDS_PE_MSK); | ||
149 | port->icount.brk++; | ||
150 | if (uart_handle_break(port)) | ||
151 | goto ignore_char; | ||
152 | } else if (rds & UART_RDS_PE_MSK) | ||
153 | port->icount.parity++; | ||
154 | else if (rds & UART_RDS_FE_MSK) | ||
155 | port->icount.frame++; | ||
156 | if (rds & UART_RDS_OE_MSK) | ||
157 | port->icount.overrun++; | ||
158 | |||
159 | if (rds & port->ignore_status_mask) { | ||
160 | if (++ignored > 100) | ||
161 | goto out; | ||
162 | goto ignore_char; | ||
163 | } | ||
164 | rds &= port->read_status_mask; | ||
165 | |||
166 | if (rds & UART_RDS_BI_MSK) | ||
167 | flg = TTY_BREAK; | ||
168 | else if (rds & UART_RDS_PE_MSK) | ||
169 | flg = TTY_PARITY; | ||
170 | else if (rds & UART_RDS_FE_MSK) | ||
171 | flg = TTY_FRAME; | ||
172 | |||
173 | if (rds & UART_RDS_OE_MSK) { | ||
174 | /* | ||
175 | * CHECK: does overrun affect the current character? | ||
176 | * ASSUMPTION: it does not. | ||
177 | */ | ||
178 | tty_insert_flip_char(tty, ch, flg); | ||
179 | ch = 0; | ||
180 | flg = TTY_OVERRUN; | ||
181 | } | ||
182 | #ifdef SUPPORT_SYSRQ | ||
183 | port->sysrq = 0; | ||
184 | #endif | ||
185 | goto error_return; | ||
186 | } | ||
187 | |||
188 | static void uart00_tx_chars(struct uart_port *port) | ||
189 | { | ||
190 | struct circ_buf *xmit = &port->info->xmit; | ||
191 | int count; | ||
192 | |||
193 | if (port->x_char) { | ||
194 | while ((UART_GET_TSR(port) & UART_TSR_TX_LEVEL_MSK) == 15) | ||
195 | barrier(); | ||
196 | UART_PUT_CHAR(port, port->x_char); | ||
197 | port->icount.tx++; | ||
198 | port->x_char = 0; | ||
199 | return; | ||
200 | } | ||
201 | if (uart_circ_empty(xmit) || uart_tx_stopped(port)) { | ||
202 | uart00_stop_tx(port); | ||
203 | return; | ||
204 | } | ||
205 | |||
206 | count = port->fifosize >> 1; | ||
207 | do { | ||
208 | while ((UART_GET_TSR(port) & UART_TSR_TX_LEVEL_MSK) == 15) | ||
209 | barrier(); | ||
210 | UART_PUT_CHAR(port, xmit->buf[xmit->tail]); | ||
211 | xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); | ||
212 | port->icount.tx++; | ||
213 | if (uart_circ_empty(xmit)) | ||
214 | break; | ||
215 | } while (--count > 0); | ||
216 | |||
217 | if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) | ||
218 | uart_write_wakeup(port); | ||
219 | |||
220 | if (uart_circ_empty(xmit)) | ||
221 | uart00_stop_tx(port); | ||
222 | } | ||
223 | |||
224 | static void uart00_start_tx(struct uart_port *port) | ||
225 | { | ||
226 | UART_PUT_IES(port, UART_IES_TIE_MSK); | ||
227 | uart00_tx_chars(port); | ||
228 | } | ||
229 | |||
230 | static void uart00_modem_status(struct uart_port *port) | ||
231 | { | ||
232 | unsigned int status; | ||
233 | |||
234 | status = UART_GET_MSR(port); | ||
235 | |||
236 | if (!(status & (UART_MSR_DCTS_MSK | UART_MSR_DDSR_MSK | | ||
237 | UART_MSR_TERI_MSK | UART_MSR_DDCD_MSK))) | ||
238 | return; | ||
239 | |||
240 | if (status & UART_MSR_DDCD_MSK) | ||
241 | uart_handle_dcd_change(port, status & UART_MSR_DCD_MSK); | ||
242 | |||
243 | if (status & UART_MSR_DDSR_MSK) | ||
244 | port->icount.dsr++; | ||
245 | |||
246 | if (status & UART_MSR_DCTS_MSK) | ||
247 | uart_handle_cts_change(port, status & UART_MSR_CTS_MSK); | ||
248 | |||
249 | wake_up_interruptible(&port->info->delta_msr_wait); | ||
250 | } | ||
251 | |||
252 | static irqreturn_t uart00_int(int irq, void *dev_id, struct pt_regs *regs) | ||
253 | { | ||
254 | struct uart_port *port = dev_id; | ||
255 | unsigned int status, pass_counter = 0; | ||
256 | |||
257 | status = UART_GET_INT_STATUS(port); | ||
258 | do { | ||
259 | if (status & UART_ISR_RI_MSK) | ||
260 | uart00_rx_chars(port, regs); | ||
261 | if (status & UART_ISR_MI_MSK) | ||
262 | uart00_modem_status(port); | ||
263 | if (status & (UART_ISR_TI_MSK | UART_ISR_TII_MSK)) | ||
264 | uart00_tx_chars(port); | ||
265 | if (pass_counter++ > UART00_ISR_PASS_LIMIT) | ||
266 | break; | ||
267 | |||
268 | status = UART_GET_INT_STATUS(port); | ||
269 | } while (status); | ||
270 | |||
271 | return IRQ_HANDLED; | ||
272 | } | ||
273 | |||
274 | static unsigned int uart00_tx_empty(struct uart_port *port) | ||
275 | { | ||
276 | return UART_GET_TSR(port) & UART_TSR_TX_LEVEL_MSK? 0 : TIOCSER_TEMT; | ||
277 | } | ||
278 | |||
279 | static unsigned int uart00_get_mctrl(struct uart_port *port) | ||
280 | { | ||
281 | unsigned int result = 0; | ||
282 | unsigned int status; | ||
283 | |||
284 | status = UART_GET_MSR(port); | ||
285 | if (status & UART_MSR_DCD_MSK) | ||
286 | result |= TIOCM_CAR; | ||
287 | if (status & UART_MSR_DSR_MSK) | ||
288 | result |= TIOCM_DSR; | ||
289 | if (status & UART_MSR_CTS_MSK) | ||
290 | result |= TIOCM_CTS; | ||
291 | if (status & UART_MSR_RI_MSK) | ||
292 | result |= TIOCM_RI; | ||
293 | |||
294 | return result; | ||
295 | } | ||
296 | |||
297 | static void uart00_set_mctrl_null(struct uart_port *port, unsigned int mctrl) | ||
298 | { | ||
299 | } | ||
300 | |||
301 | static void uart00_break_ctl(struct uart_port *port, int break_state) | ||
302 | { | ||
303 | unsigned long flags; | ||
304 | unsigned int mcr; | ||
305 | |||
306 | spin_lock_irqsave(&port->lock, flags); | ||
307 | mcr = UART_GET_MCR(port); | ||
308 | if (break_state == -1) | ||
309 | mcr |= UART_MCR_BR_MSK; | ||
310 | else | ||
311 | mcr &= ~UART_MCR_BR_MSK; | ||
312 | UART_PUT_MCR(port, mcr); | ||
313 | spin_unlock_irqrestore(&port->lock, flags); | ||
314 | } | ||
315 | |||
316 | static void | ||
317 | uart00_set_termios(struct uart_port *port, struct termios *termios, | ||
318 | struct termios *old) | ||
319 | { | ||
320 | unsigned int uart_mc, old_ies, baud, quot; | ||
321 | unsigned long flags; | ||
322 | |||
323 | /* | ||
324 | * We don't support CREAD (yet) | ||
325 | */ | ||
326 | termios->c_cflag |= CREAD; | ||
327 | |||
328 | /* | ||
329 | * Ask the core to calculate the divisor for us. | ||
330 | */ | ||
331 | baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); | ||
332 | quot = uart_get_divisor(port, baud); | ||
333 | |||
334 | /* byte size and parity */ | ||
335 | switch (termios->c_cflag & CSIZE) { | ||
336 | case CS5: | ||
337 | uart_mc = UART_MC_CLS_CHARLEN_5; | ||
338 | break; | ||
339 | case CS6: | ||
340 | uart_mc = UART_MC_CLS_CHARLEN_6; | ||
341 | break; | ||
342 | case CS7: | ||
343 | uart_mc = UART_MC_CLS_CHARLEN_7; | ||
344 | break; | ||
345 | default: // CS8 | ||
346 | uart_mc = UART_MC_CLS_CHARLEN_8; | ||
347 | break; | ||
348 | } | ||
349 | if (termios->c_cflag & CSTOPB) | ||
350 | uart_mc|= UART_MC_ST_TWO; | ||
351 | if (termios->c_cflag & PARENB) { | ||
352 | uart_mc |= UART_MC_PE_MSK; | ||
353 | if (!(termios->c_cflag & PARODD)) | ||
354 | uart_mc |= UART_MC_EP_MSK; | ||
355 | } | ||
356 | |||
357 | spin_lock_irqsave(&port->lock, flags); | ||
358 | |||
359 | /* | ||
360 | * Update the per-port timeout. | ||
361 | */ | ||
362 | uart_update_timeout(port, termios->c_cflag, baud); | ||
363 | |||
364 | port->read_status_mask = UART_RDS_OE_MSK; | ||
365 | if (termios->c_iflag & INPCK) | ||
366 | port->read_status_mask |= UART_RDS_FE_MSK | UART_RDS_PE_MSK; | ||
367 | if (termios->c_iflag & (BRKINT | PARMRK)) | ||
368 | port->read_status_mask |= UART_RDS_BI_MSK; | ||
369 | |||
370 | /* | ||
371 | * Characters to ignore | ||
372 | */ | ||
373 | port->ignore_status_mask = 0; | ||
374 | if (termios->c_iflag & IGNPAR) | ||
375 | port->ignore_status_mask |= UART_RDS_FE_MSK | UART_RDS_PE_MSK; | ||
376 | if (termios->c_iflag & IGNBRK) { | ||
377 | port->ignore_status_mask |= UART_RDS_BI_MSK; | ||
378 | /* | ||
379 | * If we're ignoring parity and break indicators, | ||
380 | * ignore overruns to (for real raw support). | ||
381 | */ | ||
382 | if (termios->c_iflag & IGNPAR) | ||
383 | port->ignore_status_mask |= UART_RDS_OE_MSK; | ||
384 | } | ||
385 | |||
386 | /* first, disable everything */ | ||
387 | old_ies = UART_GET_IES(port); | ||
388 | |||
389 | if (UART_ENABLE_MS(port, termios->c_cflag)) | ||
390 | old_ies |= UART_IES_ME_MSK; | ||
391 | |||
392 | /* Set baud rate */ | ||
393 | UART_PUT_DIV_LO(port, (quot & 0xff)); | ||
394 | UART_PUT_DIV_HI(port, ((quot & 0xf00) >> 8)); | ||
395 | |||
396 | UART_PUT_MC(port, uart_mc); | ||
397 | UART_PUT_IES(port, old_ies); | ||
398 | |||
399 | spin_unlock_irqrestore(&port->lock, flags); | ||
400 | } | ||
401 | |||
402 | static int uart00_startup(struct uart_port *port) | ||
403 | { | ||
404 | int result; | ||
405 | |||
406 | /* | ||
407 | * Allocate the IRQ | ||
408 | */ | ||
409 | result = request_irq(port->irq, uart00_int, 0, "uart00", port); | ||
410 | if (result) { | ||
411 | printk(KERN_ERR "Request of irq %d failed\n", port->irq); | ||
412 | return result; | ||
413 | } | ||
414 | |||
415 | /* | ||
416 | * Finally, enable interrupts. Use the TII interrupt to minimise | ||
417 | * the number of interrupts generated. If higher performance is | ||
418 | * needed, consider using the TI interrupt with a suitable FIFO | ||
419 | * threshold | ||
420 | */ | ||
421 | UART_PUT_IES(port, UART_IES_RE_MSK | UART_IES_TIE_MSK); | ||
422 | |||
423 | return 0; | ||
424 | } | ||
425 | |||
426 | static void uart00_shutdown(struct uart_port *port) | ||
427 | { | ||
428 | /* | ||
429 | * disable all interrupts, disable the port | ||
430 | */ | ||
431 | UART_PUT_IEC(port, 0xff); | ||
432 | |||
433 | /* disable break condition and fifos */ | ||
434 | UART_PUT_MCR(port, UART_GET_MCR(port) &~UART_MCR_BR_MSK); | ||
435 | |||
436 | /* | ||
437 | * Free the interrupt | ||
438 | */ | ||
439 | free_irq(port->irq, port); | ||
440 | } | ||
441 | |||
442 | static const char *uart00_type(struct uart_port *port) | ||
443 | { | ||
444 | return port->type == PORT_UART00 ? "Altera UART00" : NULL; | ||
445 | } | ||
446 | |||
447 | /* | ||
448 | * Release the memory region(s) being used by 'port' | ||
449 | */ | ||
450 | static void uart00_release_port(struct uart_port *port) | ||
451 | { | ||
452 | release_mem_region(port->mapbase, UART_PORT_SIZE); | ||
453 | |||
454 | #ifdef CONFIG_ARCH_CAMELOT | ||
455 | if (port->membase != (void*)IO_ADDRESS(EXC_UART00_BASE)) { | ||
456 | iounmap(port->membase); | ||
457 | } | ||
458 | #endif | ||
459 | } | ||
460 | |||
461 | /* | ||
462 | * Request the memory region(s) being used by 'port' | ||
463 | */ | ||
464 | static int uart00_request_port(struct uart_port *port) | ||
465 | { | ||
466 | return request_mem_region(port->mapbase, UART_PORT_SIZE, "serial_uart00") | ||
467 | != NULL ? 0 : -EBUSY; | ||
468 | } | ||
469 | |||
470 | /* | ||
471 | * Configure/autoconfigure the port. | ||
472 | */ | ||
473 | static void uart00_config_port(struct uart_port *port, int flags) | ||
474 | { | ||
475 | |||
476 | /* | ||
477 | * Map the io memory if this is a soft uart | ||
478 | */ | ||
479 | if (!port->membase) | ||
480 | port->membase = ioremap_nocache(port->mapbase,SZ_4K); | ||
481 | |||
482 | if (!port->membase) | ||
483 | printk(KERN_ERR "serial00: cannot map io memory\n"); | ||
484 | else | ||
485 | port->type = PORT_UART00; | ||
486 | |||
487 | } | ||
488 | |||
489 | /* | ||
490 | * verify the new serial_struct (for TIOCSSERIAL). | ||
491 | */ | ||
492 | static int uart00_verify_port(struct uart_port *port, struct serial_struct *ser) | ||
493 | { | ||
494 | int ret = 0; | ||
495 | if (ser->type != PORT_UNKNOWN && ser->type != PORT_UART00) | ||
496 | ret = -EINVAL; | ||
497 | if (ser->irq < 0 || ser->irq >= NR_IRQS) | ||
498 | ret = -EINVAL; | ||
499 | if (ser->baud_base < 9600) | ||
500 | ret = -EINVAL; | ||
501 | return ret; | ||
502 | } | ||
503 | |||
504 | static struct uart_ops uart00_pops = { | ||
505 | .tx_empty = uart00_tx_empty, | ||
506 | .set_mctrl = uart00_set_mctrl_null, | ||
507 | .get_mctrl = uart00_get_mctrl, | ||
508 | .stop_tx = uart00_stop_tx, | ||
509 | .start_tx = uart00_start_tx, | ||
510 | .stop_rx = uart00_stop_rx, | ||
511 | .enable_ms = uart00_enable_ms, | ||
512 | .break_ctl = uart00_break_ctl, | ||
513 | .startup = uart00_startup, | ||
514 | .shutdown = uart00_shutdown, | ||
515 | .set_termios = uart00_set_termios, | ||
516 | .type = uart00_type, | ||
517 | .release_port = uart00_release_port, | ||
518 | .request_port = uart00_request_port, | ||
519 | .config_port = uart00_config_port, | ||
520 | .verify_port = uart00_verify_port, | ||
521 | }; | ||
522 | |||
523 | |||
524 | #ifdef CONFIG_ARCH_CAMELOT | ||
525 | static struct uart_port epxa10db_port = { | ||
526 | .membase = (void*)IO_ADDRESS(EXC_UART00_BASE), | ||
527 | .mapbase = EXC_UART00_BASE, | ||
528 | .iotype = SERIAL_IO_MEM, | ||
529 | .irq = IRQ_UART, | ||
530 | .uartclk = EXC_AHB2_CLK_FREQUENCY, | ||
531 | .fifosize = 16, | ||
532 | .ops = &uart00_pops, | ||
533 | .flags = ASYNC_BOOT_AUTOCONF, | ||
534 | }; | ||
535 | #endif | ||
536 | |||
537 | |||
538 | #ifdef CONFIG_SERIAL_UART00_CONSOLE | ||
539 | static void uart00_console_write(struct console *co, const char *s, unsigned count) | ||
540 | { | ||
541 | #ifdef CONFIG_ARCH_CAMELOT | ||
542 | struct uart_port *port = &epxa10db_port; | ||
543 | unsigned int status, old_ies; | ||
544 | int i; | ||
545 | |||
546 | /* | ||
547 | * First save the CR then disable the interrupts | ||
548 | */ | ||
549 | old_ies = UART_GET_IES(port); | ||
550 | UART_PUT_IEC(port,0xff); | ||
551 | |||
552 | /* | ||
553 | * Now, do each character | ||
554 | */ | ||
555 | for (i = 0; i < count; i++) { | ||
556 | do { | ||
557 | status = UART_GET_TSR(port); | ||
558 | } while (!UART_TX_READY(status)); | ||
559 | UART_PUT_CHAR(port, s[i]); | ||
560 | if (s[i] == '\n') { | ||
561 | do { | ||
562 | status = UART_GET_TSR(port); | ||
563 | } while (!UART_TX_READY(status)); | ||
564 | UART_PUT_CHAR(port, '\r'); | ||
565 | } | ||
566 | } | ||
567 | |||
568 | /* | ||
569 | * Finally, wait for transmitter to become empty | ||
570 | * and restore the IES | ||
571 | */ | ||
572 | do { | ||
573 | status = UART_GET_TSR(port); | ||
574 | } while (status & UART_TSR_TX_LEVEL_MSK); | ||
575 | UART_PUT_IES(port, old_ies); | ||
576 | #endif | ||
577 | } | ||
578 | |||
579 | static void __init | ||
580 | uart00_console_get_options(struct uart_port *port, int *baud, | ||
581 | int *parity, int *bits) | ||
582 | { | ||
583 | unsigned int uart_mc, quot; | ||
584 | |||
585 | uart_mc = UART_GET_MC(port); | ||
586 | |||
587 | *parity = 'n'; | ||
588 | if (uart_mc & UART_MC_PE_MSK) { | ||
589 | if (uart_mc & UART_MC_EP_MSK) | ||
590 | *parity = 'e'; | ||
591 | else | ||
592 | *parity = 'o'; | ||
593 | } | ||
594 | |||
595 | switch (uart_mc & UART_MC_CLS_MSK) { | ||
596 | case UART_MC_CLS_CHARLEN_5: | ||
597 | *bits = 5; | ||
598 | break; | ||
599 | case UART_MC_CLS_CHARLEN_6: | ||
600 | *bits = 6; | ||
601 | break; | ||
602 | case UART_MC_CLS_CHARLEN_7: | ||
603 | *bits = 7; | ||
604 | break; | ||
605 | case UART_MC_CLS_CHARLEN_8: | ||
606 | *bits = 8; | ||
607 | break; | ||
608 | } | ||
609 | quot = UART_GET_DIV_LO(port) | (UART_GET_DIV_HI(port) << 8); | ||
610 | *baud = port->uartclk / (16 *quot ); | ||
611 | } | ||
612 | |||
613 | static int __init uart00_console_setup(struct console *co, char *options) | ||
614 | { | ||
615 | struct uart_port *port; | ||
616 | int baud = 115200; | ||
617 | int bits = 8; | ||
618 | int parity = 'n'; | ||
619 | int flow = 'n'; | ||
620 | |||
621 | #ifdef CONFIG_ARCH_CAMELOT | ||
622 | port = &epxa10db_port; ; | ||
623 | #else | ||
624 | return -ENODEV; | ||
625 | #endif | ||
626 | if (options) | ||
627 | uart_parse_options(options, &baud, &parity, &bits, &flow); | ||
628 | else | ||
629 | uart00_console_get_options(port, &baud, &parity, &bits); | ||
630 | |||
631 | return uart_set_options(port, co, baud, parity, bits, flow); | ||
632 | } | ||
633 | |||
634 | extern struct uart_driver uart00_reg; | ||
635 | static struct console uart00_console = { | ||
636 | .name = SERIAL_UART00_NAME, | ||
637 | .write = uart00_console_write, | ||
638 | .device = uart_console_device, | ||
639 | .setup = uart00_console_setup, | ||
640 | .flags = CON_PRINTBUFFER, | ||
641 | .index = 0, | ||
642 | .data = &uart00_reg, | ||
643 | }; | ||
644 | |||
645 | static int __init uart00_console_init(void) | ||
646 | { | ||
647 | register_console(&uart00_console); | ||
648 | return 0; | ||
649 | } | ||
650 | console_initcall(uart00_console_init); | ||
651 | |||
652 | #define UART00_CONSOLE &uart00_console | ||
653 | #else | ||
654 | #define UART00_CONSOLE NULL | ||
655 | #endif | ||
656 | |||
657 | static struct uart_driver uart00_reg = { | ||
658 | .owner = NULL, | ||
659 | .driver_name = SERIAL_UART00_NAME, | ||
660 | .dev_name = SERIAL_UART00_NAME, | ||
661 | .major = SERIAL_UART00_MAJOR, | ||
662 | .minor = SERIAL_UART00_MINOR, | ||
663 | .nr = UART_NR, | ||
664 | .cons = UART00_CONSOLE, | ||
665 | }; | ||
666 | |||
667 | struct dev_port_entry{ | ||
668 | unsigned int base_addr; | ||
669 | struct uart_port *port; | ||
670 | }; | ||
671 | |||
672 | #ifdef CONFIG_PLD_HOTSWAP | ||
673 | |||
674 | static struct dev_port_entry dev_port_map[UART_NR]; | ||
675 | |||
676 | /* | ||
677 | * Keep a mapping of dev_info addresses -> port lines to use when | ||
678 | * removing ports dev==NULL indicates unused entry | ||
679 | */ | ||
680 | |||
681 | struct uart00_ps_data{ | ||
682 | unsigned int clk; | ||
683 | unsigned int fifosize; | ||
684 | }; | ||
685 | |||
686 | int uart00_add_device(struct pldhs_dev_info* dev_info, void* dev_ps_data) | ||
687 | { | ||
688 | struct uart00_ps_data* dev_ps=dev_ps_data; | ||
689 | struct uart_port * port; | ||
690 | int i,result; | ||
691 | |||
692 | i=0; | ||
693 | while(dev_port_map[i].port) | ||
694 | i++; | ||
695 | |||
696 | if(i==UART_NR){ | ||
697 | printk(KERN_WARNING "uart00: Maximum number of ports reached\n"); | ||
698 | return 0; | ||
699 | } | ||
700 | |||
701 | port=kmalloc(sizeof(struct uart_port),GFP_KERNEL); | ||
702 | if(!port) | ||
703 | return -ENOMEM; | ||
704 | |||
705 | printk("clk=%d fifo=%d\n",dev_ps->clk,dev_ps->fifosize); | ||
706 | port->membase=0; | ||
707 | port->mapbase=dev_info->base_addr; | ||
708 | port->iotype=SERIAL_IO_MEM; | ||
709 | port->irq=dev_info->irq; | ||
710 | port->uartclk=dev_ps->clk; | ||
711 | port->fifosize=dev_ps->fifosize; | ||
712 | port->ops=&uart00_pops; | ||
713 | port->line=i; | ||
714 | port->flags=ASYNC_BOOT_AUTOCONF; | ||
715 | |||
716 | result=uart_add_one_port(&uart00_reg, port); | ||
717 | if(result){ | ||
718 | printk("uart_add_one_port returned %d\n",result); | ||
719 | return result; | ||
720 | } | ||
721 | dev_port_map[i].base_addr=dev_info->base_addr; | ||
722 | dev_port_map[i].port=port; | ||
723 | printk("uart00: added device at %x as ttyUA%d\n",dev_port_map[i].base_addr,i); | ||
724 | return 0; | ||
725 | |||
726 | } | ||
727 | |||
728 | int uart00_remove_devices(void) | ||
729 | { | ||
730 | int i,result; | ||
731 | |||
732 | |||
733 | result=0; | ||
734 | for(i=1;i<UART_NR;i++){ | ||
735 | if(dev_port_map[i].base_addr){ | ||
736 | result=uart_remove_one_port(&uart00_reg, dev_port_map[i].port); | ||
737 | if(result) | ||
738 | return result; | ||
739 | |||
740 | /* port removed sucessfully, so now tidy up */ | ||
741 | kfree(dev_port_map[i].port); | ||
742 | dev_port_map[i].base_addr=0; | ||
743 | dev_port_map[i].port=NULL; | ||
744 | } | ||
745 | } | ||
746 | return 0; | ||
747 | |||
748 | } | ||
749 | |||
750 | struct pld_hotswap_ops uart00_pldhs_ops={ | ||
751 | .name = "uart00", | ||
752 | .add_device = uart00_add_device, | ||
753 | .remove_devices = uart00_remove_devices, | ||
754 | }; | ||
755 | |||
756 | #endif | ||
757 | |||
758 | static int __init uart00_init(void) | ||
759 | { | ||
760 | int result; | ||
761 | |||
762 | printk(KERN_INFO "Serial: UART00 driver $Revision: 1.35 $\n"); | ||
763 | |||
764 | printk(KERN_WARNING "serial_uart00:Using temporary major/minor pairs" | ||
765 | " - these WILL change in the future\n"); | ||
766 | |||
767 | result = uart_register_driver(&uart00_reg); | ||
768 | if (result) | ||
769 | return result; | ||
770 | #ifdef CONFIG_ARCH_CAMELOT | ||
771 | result = uart_add_one_port(&uart00_reg,&epxa10db_port); | ||
772 | #endif | ||
773 | if (result) | ||
774 | uart_unregister_driver(&uart00_reg); | ||
775 | |||
776 | #ifdef CONFIG_PLD_HOTSWAP | ||
777 | pldhs_register_driver(&uart00_pldhs_ops); | ||
778 | #endif | ||
779 | return result; | ||
780 | } | ||
781 | |||
782 | __initcall(uart00_init); | ||
diff --git a/drivers/video/cyber2000fb.c b/drivers/video/cyber2000fb.c index a9300f930ef2..55a3514157ed 100644 --- a/drivers/video/cyber2000fb.c +++ b/drivers/video/cyber2000fb.c | |||
@@ -50,7 +50,6 @@ | |||
50 | #include <linux/init.h> | 50 | #include <linux/init.h> |
51 | 51 | ||
52 | #include <asm/io.h> | 52 | #include <asm/io.h> |
53 | #include <asm/irq.h> | ||
54 | #include <asm/pgtable.h> | 53 | #include <asm/pgtable.h> |
55 | #include <asm/system.h> | 54 | #include <asm/system.h> |
56 | #include <asm/uaccess.h> | 55 | #include <asm/uaccess.h> |
diff --git a/drivers/video/sa1100fb.c b/drivers/video/sa1100fb.c index 2ea1354e439f..087e58689e4c 100644 --- a/drivers/video/sa1100fb.c +++ b/drivers/video/sa1100fb.c | |||
@@ -178,7 +178,6 @@ | |||
178 | 178 | ||
179 | #include <asm/hardware.h> | 179 | #include <asm/hardware.h> |
180 | #include <asm/io.h> | 180 | #include <asm/io.h> |
181 | #include <asm/irq.h> | ||
182 | #include <asm/mach-types.h> | 181 | #include <asm/mach-types.h> |
183 | #include <asm/uaccess.h> | 182 | #include <asm/uaccess.h> |
184 | #include <asm/arch/assabet.h> | 183 | #include <asm/arch/assabet.h> |
@@ -1455,7 +1454,11 @@ static struct sa1100fb_info * __init sa1100fb_init_fbinfo(struct device *dev) | |||
1455 | static int __init sa1100fb_probe(struct platform_device *pdev) | 1454 | static int __init sa1100fb_probe(struct platform_device *pdev) |
1456 | { | 1455 | { |
1457 | struct sa1100fb_info *fbi; | 1456 | struct sa1100fb_info *fbi; |
1458 | int ret; | 1457 | int ret, irq; |
1458 | |||
1459 | irq = platform_get_irq(pdev, 0); | ||
1460 | if (irq <= 0) | ||
1461 | return -EINVAL; | ||
1459 | 1462 | ||
1460 | if (!request_mem_region(0xb0100000, 0x10000, "LCD")) | 1463 | if (!request_mem_region(0xb0100000, 0x10000, "LCD")) |
1461 | return -EBUSY; | 1464 | return -EBUSY; |
@@ -1470,7 +1473,7 @@ static int __init sa1100fb_probe(struct platform_device *pdev) | |||
1470 | if (ret) | 1473 | if (ret) |
1471 | goto failed; | 1474 | goto failed; |
1472 | 1475 | ||
1473 | ret = request_irq(IRQ_LCD, sa1100fb_handle_irq, SA_INTERRUPT, | 1476 | ret = request_irq(irq, sa1100fb_handle_irq, SA_INTERRUPT, |
1474 | "LCD", fbi); | 1477 | "LCD", fbi); |
1475 | if (ret) { | 1478 | if (ret) { |
1476 | printk(KERN_ERR "sa1100fb: request_irq failed: %d\n", ret); | 1479 | printk(KERN_ERR "sa1100fb: request_irq failed: %d\n", ret); |
@@ -1492,7 +1495,7 @@ static int __init sa1100fb_probe(struct platform_device *pdev) | |||
1492 | 1495 | ||
1493 | ret = register_framebuffer(&fbi->fb); | 1496 | ret = register_framebuffer(&fbi->fb); |
1494 | if (ret < 0) | 1497 | if (ret < 0) |
1495 | goto failed; | 1498 | goto err_free_irq; |
1496 | 1499 | ||
1497 | #ifdef CONFIG_CPU_FREQ | 1500 | #ifdef CONFIG_CPU_FREQ |
1498 | fbi->freq_transition.notifier_call = sa1100fb_freq_transition; | 1501 | fbi->freq_transition.notifier_call = sa1100fb_freq_transition; |
@@ -1504,7 +1507,9 @@ static int __init sa1100fb_probe(struct platform_device *pdev) | |||
1504 | /* This driver cannot be unloaded at the moment */ | 1507 | /* This driver cannot be unloaded at the moment */ |
1505 | return 0; | 1508 | return 0; |
1506 | 1509 | ||
1507 | failed: | 1510 | err_free_irq: |
1511 | free_irq(irq, fbi); | ||
1512 | failed: | ||
1508 | platform_set_drvdata(pdev, NULL); | 1513 | platform_set_drvdata(pdev, NULL); |
1509 | kfree(fbi); | 1514 | kfree(fbi); |
1510 | release_mem_region(0xb0100000, 0x10000); | 1515 | release_mem_region(0xb0100000, 0x10000); |