aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Dubov <oakad@yahoo.com>2008-03-10 14:43:40 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-03-10 21:01:18 -0400
commiteebbe9ca7855eb520cde62234028b6bd90083659 (patch)
tree5fc1e82eb2d2f6b76ca41ac19f5bbe2180d56c98
parent92b22d935fed1e4d88b9b6f9a674ab2a4272ee78 (diff)
tifm: fix memorystick host initialization code
Instead of assuming that host is powered on only once at card insertion, allow for the possibility that memstick layer may need to cycle card's power to get it out from some unhealthy states. Signed-off-by: Alex Dubov <oakad@yahoo.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/memstick/host/tifm_ms.c40
1 files changed, 15 insertions, 25 deletions
diff --git a/drivers/memstick/host/tifm_ms.c b/drivers/memstick/host/tifm_ms.c
index b88f5b30efbf..2b5bf52a8302 100644
--- a/drivers/memstick/host/tifm_ms.c
+++ b/drivers/memstick/host/tifm_ms.c
@@ -496,7 +496,18 @@ static void tifm_ms_set_param(struct memstick_host *msh,
496 496
497 switch (param) { 497 switch (param) {
498 case MEMSTICK_POWER: 498 case MEMSTICK_POWER:
499 /* this is set by card detection mechanism */ 499 /* also affected by media detection mechanism */
500 if (value == MEMSTICK_POWER_ON) {
501 host->mode_mask = TIFM_MS_SYS_SRAC | TIFM_MS_SYS_REI;
502 writel(TIFM_MS_SYS_RESET, sock->addr + SOCK_MS_SYSTEM);
503 writel(TIFM_MS_SYS_FCLR | TIFM_MS_SYS_INTCLR,
504 sock->addr + SOCK_MS_SYSTEM);
505 writel(0xffffffff, sock->addr + SOCK_MS_STATUS);
506 } else if (value == MEMSTICK_POWER_OFF) {
507 writel(TIFM_MS_SYS_FCLR | TIFM_MS_SYS_INTCLR,
508 sock->addr + SOCK_MS_SYSTEM);
509 writel(0xffffffff, sock->addr + SOCK_MS_STATUS);
510 }
500 break; 511 break;
501 case MEMSTICK_INTERFACE: 512 case MEMSTICK_INTERFACE:
502 if (value == MEMSTICK_SERIAL) { 513 if (value == MEMSTICK_SERIAL) {
@@ -531,22 +542,6 @@ static void tifm_ms_abort(unsigned long data)
531 tifm_eject(host->dev); 542 tifm_eject(host->dev);
532} 543}
533 544
534static int tifm_ms_initialize_host(struct tifm_ms *host)
535{
536 struct tifm_dev *sock = host->dev;
537 struct memstick_host *msh = tifm_get_drvdata(sock);
538
539 host->mode_mask = TIFM_MS_SYS_SRAC | TIFM_MS_SYS_REI;
540 writel(TIFM_MS_SYS_RESET, sock->addr + SOCK_MS_SYSTEM);
541 writel(TIFM_MS_SYS_FCLR | TIFM_MS_SYS_INTCLR,
542 sock->addr + SOCK_MS_SYSTEM);
543 writel(0xffffffff, sock->addr + SOCK_MS_STATUS);
544 if (tifm_has_ms_pif(sock))
545 msh->caps |= MEMSTICK_CAP_PAR4;
546
547 return 0;
548}
549
550static int tifm_ms_probe(struct tifm_dev *sock) 545static int tifm_ms_probe(struct tifm_dev *sock)
551{ 546{
552 struct memstick_host *msh; 547 struct memstick_host *msh;
@@ -575,10 +570,10 @@ static int tifm_ms_probe(struct tifm_dev *sock)
575 msh->set_param = tifm_ms_set_param; 570 msh->set_param = tifm_ms_set_param;
576 sock->card_event = tifm_ms_card_event; 571 sock->card_event = tifm_ms_card_event;
577 sock->data_event = tifm_ms_data_event; 572 sock->data_event = tifm_ms_data_event;
578 rc = tifm_ms_initialize_host(host); 573 if (tifm_has_ms_pif(sock))
574 msh->caps |= MEMSTICK_CAP_PAR4;
579 575
580 if (!rc) 576 rc = memstick_add_host(msh);
581 rc = memstick_add_host(msh);
582 if (!rc) 577 if (!rc)
583 return 0; 578 return 0;
584 579
@@ -616,11 +611,6 @@ static void tifm_ms_remove(struct tifm_dev *sock)
616 spin_unlock_irqrestore(&sock->lock, flags); 611 spin_unlock_irqrestore(&sock->lock, flags);
617 612
618 memstick_remove_host(msh); 613 memstick_remove_host(msh);
619
620 writel(TIFM_MS_SYS_FCLR | TIFM_MS_SYS_INTCLR,
621 sock->addr + SOCK_MS_SYSTEM);
622 writel(0xffffffff, sock->addr + SOCK_MS_STATUS);
623
624 memstick_free_host(msh); 614 memstick_free_host(msh);
625} 615}
626 616