diff options
author | Micky Ching <micky_ching@realsil.com.cn> | 2014-01-23 18:56:17 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-23 19:37:04 -0500 |
commit | 63509beaf7ed7a9dc8c574be61189fce791489f0 (patch) | |
tree | a6cf3f6686bee216a0442f91257229026ae607b4 /drivers/memstick/host | |
parent | 949b9c3d4263c9b7c2448588afce37becd58e1ad (diff) |
drivers/memstick/host/rtsx_pci_ms.c: fix ms card data transfer bug
This patch is used to add support for ms card. The main difference
between ms card and mspro card is long data transfer mode. mspro card
can use auto mode DMA for long data transfer, but ms can not use this
mode, it should use normal mode DMA.
The memstick core added support for ms card, but the original driver will
make ms card fail at initialization, because it uses auto mode DMA. This
patch makes the ms card work properly.
Signed-off-by: Micky Ching <micky_ching@realsil.com.cn>
Cc: Maxim Levitsky <maximlevitsky@gmail.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>
Cc: Alex Dubov <oakad@yahoo.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/memstick/host')
-rw-r--r-- | drivers/memstick/host/rtsx_pci_ms.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/drivers/memstick/host/rtsx_pci_ms.c b/drivers/memstick/host/rtsx_pci_ms.c index 25f8f93decb6..2a635b6fdaf7 100644 --- a/drivers/memstick/host/rtsx_pci_ms.c +++ b/drivers/memstick/host/rtsx_pci_ms.c | |||
@@ -145,6 +145,8 @@ static int ms_transfer_data(struct realtek_pci_ms *host, unsigned char data_dir, | |||
145 | unsigned int length = sg->length; | 145 | unsigned int length = sg->length; |
146 | u16 sec_cnt = (u16)(length / 512); | 146 | u16 sec_cnt = (u16)(length / 512); |
147 | u8 val, trans_mode, dma_dir; | 147 | u8 val, trans_mode, dma_dir; |
148 | struct memstick_dev *card = host->msh->card; | ||
149 | bool pro_card = card->id.type == MEMSTICK_TYPE_PRO; | ||
148 | 150 | ||
149 | dev_dbg(ms_dev(host), "%s: tpc = 0x%02x, data_dir = %s, length = %d\n", | 151 | dev_dbg(ms_dev(host), "%s: tpc = 0x%02x, data_dir = %s, length = %d\n", |
150 | __func__, tpc, (data_dir == READ) ? "READ" : "WRITE", | 152 | __func__, tpc, (data_dir == READ) ? "READ" : "WRITE", |
@@ -152,19 +154,21 @@ static int ms_transfer_data(struct realtek_pci_ms *host, unsigned char data_dir, | |||
152 | 154 | ||
153 | if (data_dir == READ) { | 155 | if (data_dir == READ) { |
154 | dma_dir = DMA_DIR_FROM_CARD; | 156 | dma_dir = DMA_DIR_FROM_CARD; |
155 | trans_mode = MS_TM_AUTO_READ; | 157 | trans_mode = pro_card ? MS_TM_AUTO_READ : MS_TM_NORMAL_READ; |
156 | } else { | 158 | } else { |
157 | dma_dir = DMA_DIR_TO_CARD; | 159 | dma_dir = DMA_DIR_TO_CARD; |
158 | trans_mode = MS_TM_AUTO_WRITE; | 160 | trans_mode = pro_card ? MS_TM_AUTO_WRITE : MS_TM_NORMAL_WRITE; |
159 | } | 161 | } |
160 | 162 | ||
161 | rtsx_pci_init_cmd(pcr); | 163 | rtsx_pci_init_cmd(pcr); |
162 | 164 | ||
163 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, MS_TPC, 0xFF, tpc); | 165 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, MS_TPC, 0xFF, tpc); |
164 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, MS_SECTOR_CNT_H, | 166 | if (pro_card) { |
165 | 0xFF, (u8)(sec_cnt >> 8)); | 167 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, MS_SECTOR_CNT_H, |
166 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, MS_SECTOR_CNT_L, | 168 | 0xFF, (u8)(sec_cnt >> 8)); |
167 | 0xFF, (u8)sec_cnt); | 169 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, MS_SECTOR_CNT_L, |
170 | 0xFF, (u8)sec_cnt); | ||
171 | } | ||
168 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, MS_TRANS_CFG, 0xFF, cfg); | 172 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, MS_TRANS_CFG, 0xFF, cfg); |
169 | 173 | ||
170 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, IRQSTAT0, | 174 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, IRQSTAT0, |
@@ -192,8 +196,14 @@ static int ms_transfer_data(struct realtek_pci_ms *host, unsigned char data_dir, | |||
192 | } | 196 | } |
193 | 197 | ||
194 | rtsx_pci_read_register(pcr, MS_TRANS_CFG, &val); | 198 | rtsx_pci_read_register(pcr, MS_TRANS_CFG, &val); |
195 | if (val & (MS_INT_CMDNK | MS_INT_ERR | MS_CRC16_ERR | MS_RDY_TIMEOUT)) | 199 | if (pro_card) { |
196 | return -EIO; | 200 | if (val & (MS_INT_CMDNK | MS_INT_ERR | |
201 | MS_CRC16_ERR | MS_RDY_TIMEOUT)) | ||
202 | return -EIO; | ||
203 | } else { | ||
204 | if (val & (MS_CRC16_ERR | MS_RDY_TIMEOUT)) | ||
205 | return -EIO; | ||
206 | } | ||
197 | 207 | ||
198 | return 0; | 208 | return 0; |
199 | } | 209 | } |
@@ -462,8 +472,8 @@ static int rtsx_pci_ms_set_param(struct memstick_host *msh, | |||
462 | clock = 19000000; | 472 | clock = 19000000; |
463 | ssc_depth = RTSX_SSC_DEPTH_500K; | 473 | ssc_depth = RTSX_SSC_DEPTH_500K; |
464 | 474 | ||
465 | err = rtsx_pci_write_register(pcr, MS_CFG, | 475 | err = rtsx_pci_write_register(pcr, MS_CFG, 0x58, |
466 | 0x18, MS_BUS_WIDTH_1); | 476 | MS_BUS_WIDTH_1 | PUSH_TIME_DEFAULT); |
467 | if (err < 0) | 477 | if (err < 0) |
468 | return err; | 478 | return err; |
469 | } else if (value == MEMSTICK_PAR4) { | 479 | } else if (value == MEMSTICK_PAR4) { |