@@ -61,6 +61,7 @@ struct jmb38x_ms_host {
6161 struct memstick_request * req ;
6262 unsigned char cmd_flags ;
6363 unsigned char io_pos ;
64+ unsigned char ifmode ;
6465 unsigned int io_word [2 ];
6566};
6667
@@ -136,15 +137,14 @@ struct jmb38x_ms {
136137#define PAD_PU_PD_ON_MS_SOCK0 0x5f8f0000
137138#define PAD_PU_PD_ON_MS_SOCK1 0x0f0f0000
138139
140+ #define CLOCK_CONTROL_BY_MMIO 0x00000008
139141#define CLOCK_CONTROL_40MHZ 0x00000001
140- #define CLOCK_CONTROL_50MHZ 0x0000000a
141- #define CLOCK_CONTROL_60MHZ 0x00000008
142- #define CLOCK_CONTROL_62_5MHZ 0x0000000c
142+ #define CLOCK_CONTROL_50MHZ 0x00000002
143+ #define CLOCK_CONTROL_60MHZ 0x00000010
144+ #define CLOCK_CONTROL_62_5MHZ 0x00000004
143145#define CLOCK_CONTROL_OFF 0x00000000
144146
145147#define PCI_CTL_CLOCK_DLY_ADDR 0x000000b0
146- #define PCI_CTL_CLOCK_DLY_MASK_A 0x00000f00
147- #define PCI_CTL_CLOCK_DLY_MASK_B 0x0000f000
148148
149149enum {
150150 CMD_READY = 0x01 ,
@@ -390,8 +390,13 @@ static int jmb38x_ms_issue_cmd(struct memstick_host *msh)
390390
391391 if (host -> req -> data_dir == READ )
392392 cmd |= TPC_DIR ;
393- if (host -> req -> need_card_int )
394- cmd |= TPC_WAIT_INT ;
393+
394+ if (host -> req -> need_card_int ) {
395+ if (host -> ifmode == MEMSTICK_SERIAL )
396+ cmd |= TPC_GET_INT ;
397+ else
398+ cmd |= TPC_WAIT_INT ;
399+ }
395400
396401 data = host -> req -> data ;
397402
@@ -529,7 +534,10 @@ static irqreturn_t jmb38x_ms_isr(int irq, void *dev_id)
529534 if (irq_status & INT_STATUS_ANY_ERR ) {
530535 if (irq_status & INT_STATUS_CRC_ERR )
531536 host -> req -> error = - EILSEQ ;
532- else
537+ else if (irq_status & INT_STATUS_TPC_ERR ) {
538+ dev_dbg (& host -> chip -> pdev -> dev , "TPC_ERR\n" );
539+ jmb38x_ms_complete_cmd (msh , 0 );
540+ } else
533541 host -> req -> error = - ETIME ;
534542 } else {
535543 if (host -> cmd_flags & DMA_DATA ) {
@@ -644,7 +652,6 @@ static int jmb38x_ms_reset(struct jmb38x_ms_host *host)
644652 ndelay (20 );
645653 }
646654 dev_dbg (& host -> chip -> pdev -> dev , "reset_req timeout\n" );
647- /* return -EIO; */
648655
649656reset_next :
650657 writel (HOST_CONTROL_RESET | HOST_CONTROL_CLOCK_EN
@@ -675,7 +682,7 @@ static int jmb38x_ms_set_param(struct memstick_host *msh,
675682{
676683 struct jmb38x_ms_host * host = memstick_priv (msh );
677684 unsigned int host_ctl = readl (host -> addr + HOST_CONTROL );
678- unsigned int clock_ctl = CLOCK_CONTROL_40MHZ , clock_delay = 0 ;
685+ unsigned int clock_ctl = CLOCK_CONTROL_BY_MMIO , clock_delay = 0 ;
679686 int rc = 0 ;
680687
681688 switch (param ) {
@@ -687,9 +694,7 @@ static int jmb38x_ms_set_param(struct memstick_host *msh,
687694
688695 host_ctl = 7 ;
689696 host_ctl |= HOST_CONTROL_POWER_EN
690- | HOST_CONTROL_CLOCK_EN
691- | HOST_CONTROL_HW_OC_P
692- | HOST_CONTROL_TDELAY_EN ;
697+ | HOST_CONTROL_CLOCK_EN ;
693698 writel (host_ctl , host -> addr + HOST_CONTROL );
694699
695700 writel (host -> id ? PAD_PU_PD_ON_MS_SOCK1
@@ -712,41 +717,42 @@ static int jmb38x_ms_set_param(struct memstick_host *msh,
712717 return - EINVAL ;
713718 break ;
714719 case MEMSTICK_INTERFACE :
720+ dev_dbg (& host -> chip -> pdev -> dev ,
721+ "Set Host Interface Mode to %d\n" , value );
722+ host_ctl &= ~(HOST_CONTROL_FAST_CLK | HOST_CONTROL_REI |
723+ HOST_CONTROL_REO );
724+ host_ctl |= HOST_CONTROL_TDELAY_EN | HOST_CONTROL_HW_OC_P ;
715725 host_ctl &= ~(3 << HOST_CONTROL_IF_SHIFT );
716- pci_read_config_dword (host -> chip -> pdev ,
717- PCI_CTL_CLOCK_DLY_ADDR ,
718- & clock_delay );
719- clock_delay &= host -> id ? ~PCI_CTL_CLOCK_DLY_MASK_B
720- : ~PCI_CTL_CLOCK_DLY_MASK_A ;
721726
722727 if (value == MEMSTICK_SERIAL ) {
723- host_ctl &= ~HOST_CONTROL_FAST_CLK ;
724- host_ctl &= ~HOST_CONTROL_REO ;
725728 host_ctl |= HOST_CONTROL_IF_SERIAL
726729 << HOST_CONTROL_IF_SHIFT ;
727730 host_ctl |= HOST_CONTROL_REI ;
728- clock_ctl = CLOCK_CONTROL_40MHZ ;
731+ clock_ctl |= CLOCK_CONTROL_40MHZ ;
732+ clock_delay = 0 ;
729733 } else if (value == MEMSTICK_PAR4 ) {
730- host_ctl |= HOST_CONTROL_FAST_CLK | HOST_CONTROL_REO ;
734+ host_ctl |= HOST_CONTROL_FAST_CLK ;
731735 host_ctl |= HOST_CONTROL_IF_PAR4
732736 << HOST_CONTROL_IF_SHIFT ;
733- host_ctl &= ~ HOST_CONTROL_REI ;
734- clock_ctl = CLOCK_CONTROL_40MHZ ;
735- clock_delay |= host -> id ? ( 4 << 12 ) : ( 4 << 8 ) ;
737+ host_ctl |= HOST_CONTROL_REO ;
738+ clock_ctl | = CLOCK_CONTROL_40MHZ ;
739+ clock_delay = 4 ;
736740 } else if (value == MEMSTICK_PAR8 ) {
737741 host_ctl |= HOST_CONTROL_FAST_CLK ;
738742 host_ctl |= HOST_CONTROL_IF_PAR8
739743 << HOST_CONTROL_IF_SHIFT ;
740- host_ctl &= ~( HOST_CONTROL_REI | HOST_CONTROL_REO ) ;
741- clock_ctl = CLOCK_CONTROL_50MHZ ;
744+ clock_ctl |= CLOCK_CONTROL_50MHZ ;
745+ clock_delay = 0 ;
742746 } else
743747 return - EINVAL ;
744748
745749 writel (host_ctl , host -> addr + HOST_CONTROL );
750+ writel (CLOCK_CONTROL_OFF , host -> addr + CLOCK_CONTROL );
746751 writel (clock_ctl , host -> addr + CLOCK_CONTROL );
747- pci_write_config_dword (host -> chip -> pdev ,
748- PCI_CTL_CLOCK_DLY_ADDR ,
749- clock_delay );
752+ pci_write_config_byte (host -> chip -> pdev ,
753+ PCI_CTL_CLOCK_DLY_ADDR + 1 ,
754+ clock_delay );
755+ host -> ifmode = value ;
750756 break ;
751757 };
752758 return 0 ;
0 commit comments