aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/memstick/core/mspro_block.c
diff options
context:
space:
mode:
authorAlex Dubov <oakad@yahoo.com>2008-09-13 05:33:26 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-09-13 17:41:52 -0400
commit8e82f8c34b1759ae0d80fe96101746ec51fb1ba4 (patch)
tree376e4c63b96c214bc50290742996b0b9b4b01e10 /drivers/memstick/core/mspro_block.c
parent8d99f83b9478768d3a8d7d1bcd9bd182c75a0447 (diff)
memstick: fix MSProHG 8-bit interface mode support
- 8-bit interface mode never worked properly. The only adapter I have which supports the 8b mode (the Jmicron) had some problems with its clock wiring and they discovered it only now. We also discovered that ProHG media is more sensitive to the ordering of initialization commands. - Make the driver fall back to highest supported mode instead of always falling back to serial. The driver will attempt the switch to 8b mode for any new MSPro card, but not all of them support it. Previously, these new cards ended up in serial mode, which is not the best idea (they work fine with 4b, after all). - Edit some macros for better conformance to Sony documentation 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>
Diffstat (limited to 'drivers/memstick/core/mspro_block.c')
-rw-r--r--drivers/memstick/core/mspro_block.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/drivers/memstick/core/mspro_block.c b/drivers/memstick/core/mspro_block.c
index 44b1817f2f2..d2d2318dafa 100644
--- a/drivers/memstick/core/mspro_block.c
+++ b/drivers/memstick/core/mspro_block.c
@@ -30,6 +30,8 @@ module_param(major, int, 0644);
30#define MSPRO_BLOCK_SIGNATURE 0xa5c3 30#define MSPRO_BLOCK_SIGNATURE 0xa5c3
31#define MSPRO_BLOCK_MAX_ATTRIBUTES 41 31#define MSPRO_BLOCK_MAX_ATTRIBUTES 41
32 32
33#define MSPRO_BLOCK_PART_SHIFT 3
34
33enum { 35enum {
34 MSPRO_BLOCK_ID_SYSINFO = 0x10, 36 MSPRO_BLOCK_ID_SYSINFO = 0x10,
35 MSPRO_BLOCK_ID_MODELNAME = 0x15, 37 MSPRO_BLOCK_ID_MODELNAME = 0x15,
@@ -195,7 +197,7 @@ static int mspro_block_bd_open(struct inode *inode, struct file *filp)
195static int mspro_block_disk_release(struct gendisk *disk) 197static int mspro_block_disk_release(struct gendisk *disk)
196{ 198{
197 struct mspro_block_data *msb = disk->private_data; 199 struct mspro_block_data *msb = disk->private_data;
198 int disk_id = disk->first_minor >> MEMSTICK_PART_SHIFT; 200 int disk_id = disk->first_minor >> MSPRO_BLOCK_PART_SHIFT;
199 201
200 mutex_lock(&mspro_block_disk_lock); 202 mutex_lock(&mspro_block_disk_lock);
201 203
@@ -877,6 +879,7 @@ static int mspro_block_switch_interface(struct memstick_dev *card)
877 struct mspro_block_data *msb = memstick_get_drvdata(card); 879 struct mspro_block_data *msb = memstick_get_drvdata(card);
878 int rc = 0; 880 int rc = 0;
879 881
882try_again:
880 if (msb->caps & MEMSTICK_CAP_PAR4) 883 if (msb->caps & MEMSTICK_CAP_PAR4)
881 rc = mspro_block_set_interface(card, MEMSTICK_SYS_PAR4); 884 rc = mspro_block_set_interface(card, MEMSTICK_SYS_PAR4);
882 else 885 else
@@ -930,6 +933,18 @@ static int mspro_block_switch_interface(struct memstick_dev *card)
930 rc = memstick_set_rw_addr(card); 933 rc = memstick_set_rw_addr(card);
931 if (!rc) 934 if (!rc)
932 rc = mspro_block_set_interface(card, msb->system); 935 rc = mspro_block_set_interface(card, msb->system);
936
937 if (!rc) {
938 msleep(150);
939 rc = mspro_block_wait_for_ced(card);
940 if (rc)
941 return rc;
942
943 if (msb->caps & MEMSTICK_CAP_PAR8) {
944 msb->caps &= ~MEMSTICK_CAP_PAR8;
945 goto try_again;
946 }
947 }
933 } 948 }
934 return rc; 949 return rc;
935} 950}
@@ -1117,14 +1132,16 @@ static int mspro_block_init_card(struct memstick_dev *card)
1117 return -EIO; 1132 return -EIO;
1118 1133
1119 msb->caps = host->caps; 1134 msb->caps = host->caps;
1120 rc = mspro_block_switch_interface(card); 1135
1136 msleep(150);
1137 rc = mspro_block_wait_for_ced(card);
1121 if (rc) 1138 if (rc)
1122 return rc; 1139 return rc;
1123 1140
1124 msleep(200); 1141 rc = mspro_block_switch_interface(card);
1125 rc = mspro_block_wait_for_ced(card);
1126 if (rc) 1142 if (rc)
1127 return rc; 1143 return rc;
1144
1128 dev_dbg(&card->dev, "card activated\n"); 1145 dev_dbg(&card->dev, "card activated\n");
1129 if (msb->system != MEMSTICK_SYS_SERIAL) 1146 if (msb->system != MEMSTICK_SYS_SERIAL)
1130 msb->caps |= MEMSTICK_CAP_AUTO_GET_INT; 1147 msb->caps |= MEMSTICK_CAP_AUTO_GET_INT;
@@ -1192,12 +1209,12 @@ static int mspro_block_init_disk(struct memstick_dev *card)
1192 if (rc) 1209 if (rc)
1193 return rc; 1210 return rc;
1194 1211
1195 if ((disk_id << MEMSTICK_PART_SHIFT) > 255) { 1212 if ((disk_id << MSPRO_BLOCK_PART_SHIFT) > 255) {
1196 rc = -ENOSPC; 1213 rc = -ENOSPC;
1197 goto out_release_id; 1214 goto out_release_id;
1198 } 1215 }
1199 1216
1200 msb->disk = alloc_disk(1 << MEMSTICK_PART_SHIFT); 1217 msb->disk = alloc_disk(1 << MSPRO_BLOCK_PART_SHIFT);
1201 if (!msb->disk) { 1218 if (!msb->disk) {
1202 rc = -ENOMEM; 1219 rc = -ENOMEM;
1203 goto out_release_id; 1220 goto out_release_id;
@@ -1220,7 +1237,7 @@ static int mspro_block_init_disk(struct memstick_dev *card)
1220 MSPRO_BLOCK_MAX_PAGES * msb->page_size); 1237 MSPRO_BLOCK_MAX_PAGES * msb->page_size);
1221 1238
1222 msb->disk->major = major; 1239 msb->disk->major = major;
1223 msb->disk->first_minor = disk_id << MEMSTICK_PART_SHIFT; 1240 msb->disk->first_minor = disk_id << MSPRO_BLOCK_PART_SHIFT;
1224 msb->disk->fops = &ms_block_bdops; 1241 msb->disk->fops = &ms_block_bdops;
1225 msb->usage_count = 1; 1242 msb->usage_count = 1;
1226 msb->disk->private_data = msb; 1243 msb->disk->private_data = msb;
@@ -1416,7 +1433,7 @@ out_unlock:
1416 1433
1417static struct memstick_device_id mspro_block_id_tbl[] = { 1434static struct memstick_device_id mspro_block_id_tbl[] = {
1418 {MEMSTICK_MATCH_ALL, MEMSTICK_TYPE_PRO, MEMSTICK_CATEGORY_STORAGE_DUO, 1435 {MEMSTICK_MATCH_ALL, MEMSTICK_TYPE_PRO, MEMSTICK_CATEGORY_STORAGE_DUO,
1419 MEMSTICK_CLASS_GENERIC_DUO}, 1436 MEMSTICK_CLASS_DUO},
1420 {} 1437 {}
1421}; 1438};
1422 1439