diff options
-rw-r--r-- | drivers/memstick/core/memstick.c | 10 | ||||
-rw-r--r-- | drivers/memstick/core/mspro_block.c | 33 | ||||
-rw-r--r-- | drivers/memstick/host/jmb38x_ms.c | 39 | ||||
-rw-r--r-- | include/linux/memstick.h | 97 |
4 files changed, 106 insertions, 73 deletions
diff --git a/drivers/memstick/core/memstick.c b/drivers/memstick/core/memstick.c index a38005008a20..cea46906408e 100644 --- a/drivers/memstick/core/memstick.c +++ b/drivers/memstick/core/memstick.c | |||
@@ -185,7 +185,7 @@ static void memstick_free(struct device *dev) | |||
185 | } | 185 | } |
186 | 186 | ||
187 | static struct class memstick_host_class = { | 187 | static struct class memstick_host_class = { |
188 | .name = "memstick_host", | 188 | .name = "memstick_host", |
189 | .dev_release = memstick_free | 189 | .dev_release = memstick_free |
190 | }; | 190 | }; |
191 | 191 | ||
@@ -264,7 +264,7 @@ EXPORT_SYMBOL(memstick_new_req); | |||
264 | * @sg - TPC argument | 264 | * @sg - TPC argument |
265 | */ | 265 | */ |
266 | void memstick_init_req_sg(struct memstick_request *mrq, unsigned char tpc, | 266 | void memstick_init_req_sg(struct memstick_request *mrq, unsigned char tpc, |
267 | struct scatterlist *sg) | 267 | const struct scatterlist *sg) |
268 | { | 268 | { |
269 | mrq->tpc = tpc; | 269 | mrq->tpc = tpc; |
270 | if (tpc & 8) | 270 | if (tpc & 8) |
@@ -294,7 +294,7 @@ EXPORT_SYMBOL(memstick_init_req_sg); | |||
294 | * user supplied buffer. | 294 | * user supplied buffer. |
295 | */ | 295 | */ |
296 | void memstick_init_req(struct memstick_request *mrq, unsigned char tpc, | 296 | void memstick_init_req(struct memstick_request *mrq, unsigned char tpc, |
297 | void *buf, size_t length) | 297 | const void *buf, size_t length) |
298 | { | 298 | { |
299 | mrq->tpc = tpc; | 299 | mrq->tpc = tpc; |
300 | if (tpc & 8) | 300 | if (tpc & 8) |
@@ -439,7 +439,7 @@ static void memstick_check(struct work_struct *work) | |||
439 | if (!host->card) { | 439 | if (!host->card) { |
440 | if (memstick_power_on(host)) | 440 | if (memstick_power_on(host)) |
441 | goto out_power_off; | 441 | goto out_power_off; |
442 | } else | 442 | } else if (host->card->stop) |
443 | host->card->stop(host->card); | 443 | host->card->stop(host->card); |
444 | 444 | ||
445 | card = memstick_alloc_card(host); | 445 | card = memstick_alloc_card(host); |
@@ -458,7 +458,7 @@ static void memstick_check(struct work_struct *work) | |||
458 | || !(host->card->check(host->card))) { | 458 | || !(host->card->check(host->card))) { |
459 | device_unregister(&host->card->dev); | 459 | device_unregister(&host->card->dev); |
460 | host->card = NULL; | 460 | host->card = NULL; |
461 | } else | 461 | } else if (host->card->start) |
462 | host->card->start(host->card); | 462 | host->card->start(host->card); |
463 | } | 463 | } |
464 | 464 | ||
diff --git a/drivers/memstick/core/mspro_block.c b/drivers/memstick/core/mspro_block.c index 44b1817f2f2f..d2d2318dafa4 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 | |||
33 | enum { | 35 | enum { |
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) | |||
195 | static int mspro_block_disk_release(struct gendisk *disk) | 197 | static 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 | ||
882 | try_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 | ||
1417 | static struct memstick_device_id mspro_block_id_tbl[] = { | 1434 | static 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 | ||
diff --git a/drivers/memstick/host/jmb38x_ms.c b/drivers/memstick/host/jmb38x_ms.c index 3485c63d20b0..2fb95a5b72eb 100644 --- a/drivers/memstick/host/jmb38x_ms.c +++ b/drivers/memstick/host/jmb38x_ms.c | |||
@@ -81,6 +81,8 @@ struct jmb38x_ms { | |||
81 | #define TPC_CODE_SZ_MASK 0x00000700 | 81 | #define TPC_CODE_SZ_MASK 0x00000700 |
82 | #define TPC_DATA_SZ_MASK 0x00000007 | 82 | #define TPC_DATA_SZ_MASK 0x00000007 |
83 | 83 | ||
84 | #define HOST_CONTROL_TDELAY_EN 0x00040000 | ||
85 | #define HOST_CONTROL_HW_OC_P 0x00010000 | ||
84 | #define HOST_CONTROL_RESET_REQ 0x00008000 | 86 | #define HOST_CONTROL_RESET_REQ 0x00008000 |
85 | #define HOST_CONTROL_REI 0x00004000 | 87 | #define HOST_CONTROL_REI 0x00004000 |
86 | #define HOST_CONTROL_LED 0x00000400 | 88 | #define HOST_CONTROL_LED 0x00000400 |
@@ -88,6 +90,7 @@ struct jmb38x_ms { | |||
88 | #define HOST_CONTROL_RESET 0x00000100 | 90 | #define HOST_CONTROL_RESET 0x00000100 |
89 | #define HOST_CONTROL_POWER_EN 0x00000080 | 91 | #define HOST_CONTROL_POWER_EN 0x00000080 |
90 | #define HOST_CONTROL_CLOCK_EN 0x00000040 | 92 | #define HOST_CONTROL_CLOCK_EN 0x00000040 |
93 | #define HOST_CONTROL_REO 0x00000008 | ||
91 | #define HOST_CONTROL_IF_SHIFT 4 | 94 | #define HOST_CONTROL_IF_SHIFT 4 |
92 | 95 | ||
93 | #define HOST_CONTROL_IF_SERIAL 0x0 | 96 | #define HOST_CONTROL_IF_SERIAL 0x0 |
@@ -133,11 +136,15 @@ struct jmb38x_ms { | |||
133 | #define PAD_PU_PD_ON_MS_SOCK1 0x0f0f0000 | 136 | #define PAD_PU_PD_ON_MS_SOCK1 0x0f0f0000 |
134 | 137 | ||
135 | #define CLOCK_CONTROL_40MHZ 0x00000001 | 138 | #define CLOCK_CONTROL_40MHZ 0x00000001 |
136 | #define CLOCK_CONTROL_50MHZ 0x00000002 | 139 | #define CLOCK_CONTROL_50MHZ 0x0000000a |
137 | #define CLOCK_CONTROL_60MHZ 0x00000008 | 140 | #define CLOCK_CONTROL_60MHZ 0x00000008 |
138 | #define CLOCK_CONTROL_62_5MHZ 0x0000000c | 141 | #define CLOCK_CONTROL_62_5MHZ 0x0000000c |
139 | #define CLOCK_CONTROL_OFF 0x00000000 | 142 | #define CLOCK_CONTROL_OFF 0x00000000 |
140 | 143 | ||
144 | #define PCI_CTL_CLOCK_DLY_ADDR 0x000000b0 | ||
145 | #define PCI_CTL_CLOCK_DLY_MASK_A 0x00000f00 | ||
146 | #define PCI_CTL_CLOCK_DLY_MASK_B 0x0000f000 | ||
147 | |||
141 | enum { | 148 | enum { |
142 | CMD_READY = 0x01, | 149 | CMD_READY = 0x01, |
143 | FIFO_READY = 0x02, | 150 | FIFO_READY = 0x02, |
@@ -367,8 +374,7 @@ static int jmb38x_ms_issue_cmd(struct memstick_host *msh) | |||
367 | return host->req->error; | 374 | return host->req->error; |
368 | } | 375 | } |
369 | 376 | ||
370 | dev_dbg(&msh->dev, "control %08x\n", | 377 | dev_dbg(&msh->dev, "control %08x\n", readl(host->addr + HOST_CONTROL)); |
371 | readl(host->addr + HOST_CONTROL)); | ||
372 | dev_dbg(&msh->dev, "status %08x\n", readl(host->addr + INT_STATUS)); | 378 | dev_dbg(&msh->dev, "status %08x\n", readl(host->addr + INT_STATUS)); |
373 | dev_dbg(&msh->dev, "hstatus %08x\n", readl(host->addr + STATUS)); | 379 | dev_dbg(&msh->dev, "hstatus %08x\n", readl(host->addr + STATUS)); |
374 | 380 | ||
@@ -637,7 +643,7 @@ static int jmb38x_ms_reset(struct jmb38x_ms_host *host) | |||
637 | ndelay(20); | 643 | ndelay(20); |
638 | } | 644 | } |
639 | dev_dbg(&host->chip->pdev->dev, "reset_req timeout\n"); | 645 | dev_dbg(&host->chip->pdev->dev, "reset_req timeout\n"); |
640 | return -EIO; | 646 | /* return -EIO; */ |
641 | 647 | ||
642 | reset_next: | 648 | reset_next: |
643 | writel(HOST_CONTROL_RESET | HOST_CONTROL_CLOCK_EN | 649 | writel(HOST_CONTROL_RESET | HOST_CONTROL_CLOCK_EN |
@@ -680,7 +686,9 @@ static int jmb38x_ms_set_param(struct memstick_host *msh, | |||
680 | 686 | ||
681 | host_ctl = 7; | 687 | host_ctl = 7; |
682 | host_ctl |= HOST_CONTROL_POWER_EN | 688 | host_ctl |= HOST_CONTROL_POWER_EN |
683 | | HOST_CONTROL_CLOCK_EN; | 689 | | HOST_CONTROL_CLOCK_EN |
690 | | HOST_CONTROL_HW_OC_P | ||
691 | | HOST_CONTROL_TDELAY_EN; | ||
684 | writel(host_ctl, host->addr + HOST_CONTROL); | 692 | writel(host_ctl, host->addr + HOST_CONTROL); |
685 | 693 | ||
686 | writel(host->id ? PAD_PU_PD_ON_MS_SOCK1 | 694 | writel(host->id ? PAD_PU_PD_ON_MS_SOCK1 |
@@ -704,33 +712,40 @@ static int jmb38x_ms_set_param(struct memstick_host *msh, | |||
704 | break; | 712 | break; |
705 | case MEMSTICK_INTERFACE: | 713 | case MEMSTICK_INTERFACE: |
706 | host_ctl &= ~(3 << HOST_CONTROL_IF_SHIFT); | 714 | host_ctl &= ~(3 << HOST_CONTROL_IF_SHIFT); |
715 | pci_read_config_dword(host->chip->pdev, | ||
716 | PCI_CTL_CLOCK_DLY_ADDR, | ||
717 | &clock_delay); | ||
718 | clock_delay &= host->id ? ~PCI_CTL_CLOCK_DLY_MASK_B | ||
719 | : ~PCI_CTL_CLOCK_DLY_MASK_A; | ||
707 | 720 | ||
708 | if (value == MEMSTICK_SERIAL) { | 721 | if (value == MEMSTICK_SERIAL) { |
709 | host_ctl &= ~HOST_CONTROL_FAST_CLK; | 722 | host_ctl &= ~HOST_CONTROL_FAST_CLK; |
723 | host_ctl &= ~HOST_CONTROL_REO; | ||
710 | host_ctl |= HOST_CONTROL_IF_SERIAL | 724 | host_ctl |= HOST_CONTROL_IF_SERIAL |
711 | << HOST_CONTROL_IF_SHIFT; | 725 | << HOST_CONTROL_IF_SHIFT; |
712 | host_ctl |= HOST_CONTROL_REI; | 726 | host_ctl |= HOST_CONTROL_REI; |
713 | clock_ctl = CLOCK_CONTROL_40MHZ; | 727 | clock_ctl = CLOCK_CONTROL_40MHZ; |
714 | clock_delay = 0; | ||
715 | } else if (value == MEMSTICK_PAR4) { | 728 | } else if (value == MEMSTICK_PAR4) { |
716 | host_ctl |= HOST_CONTROL_FAST_CLK; | 729 | host_ctl |= HOST_CONTROL_FAST_CLK | HOST_CONTROL_REO; |
717 | host_ctl |= HOST_CONTROL_IF_PAR4 | 730 | host_ctl |= HOST_CONTROL_IF_PAR4 |
718 | << HOST_CONTROL_IF_SHIFT; | 731 | << HOST_CONTROL_IF_SHIFT; |
719 | host_ctl &= ~HOST_CONTROL_REI; | 732 | host_ctl &= ~HOST_CONTROL_REI; |
720 | clock_ctl = CLOCK_CONTROL_40MHZ; | 733 | clock_ctl = CLOCK_CONTROL_40MHZ; |
721 | clock_delay = 4; | 734 | clock_delay |= host->id ? (4 << 12) : (4 << 8); |
722 | } else if (value == MEMSTICK_PAR8) { | 735 | } else if (value == MEMSTICK_PAR8) { |
723 | host_ctl |= HOST_CONTROL_FAST_CLK; | 736 | host_ctl |= HOST_CONTROL_FAST_CLK; |
724 | host_ctl |= HOST_CONTROL_IF_PAR8 | 737 | host_ctl |= HOST_CONTROL_IF_PAR8 |
725 | << HOST_CONTROL_IF_SHIFT; | 738 | << HOST_CONTROL_IF_SHIFT; |
726 | host_ctl &= ~HOST_CONTROL_REI; | 739 | host_ctl &= ~(HOST_CONTROL_REI | HOST_CONTROL_REO); |
727 | clock_ctl = CLOCK_CONTROL_60MHZ; | 740 | clock_ctl = CLOCK_CONTROL_50MHZ; |
728 | clock_delay = 0; | ||
729 | } else | 741 | } else |
730 | return -EINVAL; | 742 | return -EINVAL; |
743 | |||
731 | writel(host_ctl, host->addr + HOST_CONTROL); | 744 | writel(host_ctl, host->addr + HOST_CONTROL); |
732 | writel(clock_ctl, host->addr + CLOCK_CONTROL); | 745 | writel(clock_ctl, host->addr + CLOCK_CONTROL); |
733 | writel(clock_delay, host->addr + CLOCK_DELAY); | 746 | pci_write_config_dword(host->chip->pdev, |
747 | PCI_CTL_CLOCK_DLY_ADDR, | ||
748 | clock_delay); | ||
734 | break; | 749 | break; |
735 | }; | 750 | }; |
736 | return 0; | 751 | return 0; |
diff --git a/include/linux/memstick.h b/include/linux/memstick.h index a9f998a3f48b..d0c37e682234 100644 --- a/include/linux/memstick.h +++ b/include/linux/memstick.h | |||
@@ -21,30 +21,30 @@ | |||
21 | struct ms_status_register { | 21 | struct ms_status_register { |
22 | unsigned char reserved; | 22 | unsigned char reserved; |
23 | unsigned char interrupt; | 23 | unsigned char interrupt; |
24 | #define MEMSTICK_INT_CMDNAK 0x0001 | 24 | #define MEMSTICK_INT_CMDNAK 0x01 |
25 | #define MEMSTICK_INT_IOREQ 0x0008 | 25 | #define MEMSTICK_INT_IOREQ 0x08 |
26 | #define MEMSTICK_INT_IOBREQ 0x0010 | 26 | #define MEMSTICK_INT_IOBREQ 0x10 |
27 | #define MEMSTICK_INT_BREQ 0x0020 | 27 | #define MEMSTICK_INT_BREQ 0x20 |
28 | #define MEMSTICK_INT_ERR 0x0040 | 28 | #define MEMSTICK_INT_ERR 0x40 |
29 | #define MEMSTICK_INT_CED 0x0080 | 29 | #define MEMSTICK_INT_CED 0x80 |
30 | 30 | ||
31 | unsigned char status0; | 31 | unsigned char status0; |
32 | #define MEMSTICK_STATUS0_WP 0x0001 | 32 | #define MEMSTICK_STATUS0_WP 0x01 |
33 | #define MEMSTICK_STATUS0_SL 0x0002 | 33 | #define MEMSTICK_STATUS0_SL 0x02 |
34 | #define MEMSTICK_STATUS0_BF 0x0010 | 34 | #define MEMSTICK_STATUS0_BF 0x10 |
35 | #define MEMSTICK_STATUS0_BE 0x0020 | 35 | #define MEMSTICK_STATUS0_BE 0x20 |
36 | #define MEMSTICK_STATUS0_FB0 0x0040 | 36 | #define MEMSTICK_STATUS0_FB0 0x40 |
37 | #define MEMSTICK_STATUS0_MB 0x0080 | 37 | #define MEMSTICK_STATUS0_MB 0x80 |
38 | 38 | ||
39 | unsigned char status1; | 39 | unsigned char status1; |
40 | #define MEMSTICK_STATUS1_UCFG 0x0001 | 40 | #define MEMSTICK_STATUS1_UCFG 0x01 |
41 | #define MEMSTICK_STATUS1_FGER 0x0002 | 41 | #define MEMSTICK_STATUS1_FGER 0x02 |
42 | #define MEMSTICK_STATUS1_UCEX 0x0004 | 42 | #define MEMSTICK_STATUS1_UCEX 0x04 |
43 | #define MEMSTICK_STATUS1_EXER 0x0008 | 43 | #define MEMSTICK_STATUS1_EXER 0x08 |
44 | #define MEMSTICK_STATUS1_UCDT 0x0010 | 44 | #define MEMSTICK_STATUS1_UCDT 0x10 |
45 | #define MEMSTICK_STATUS1_DTER 0x0020 | 45 | #define MEMSTICK_STATUS1_DTER 0x20 |
46 | #define MEMSTICK_STATUS1_FBI 0x0040 | 46 | #define MEMSTICK_STATUS1_FB1 0x40 |
47 | #define MEMSTICK_STATUS1_MB 0x0080 | 47 | #define MEMSTICK_STATUS1_MB 0x80 |
48 | } __attribute__((packed)); | 48 | } __attribute__((packed)); |
49 | 49 | ||
50 | struct ms_id_register { | 50 | struct ms_id_register { |
@@ -56,32 +56,32 @@ struct ms_id_register { | |||
56 | 56 | ||
57 | struct ms_param_register { | 57 | struct ms_param_register { |
58 | unsigned char system; | 58 | unsigned char system; |
59 | #define MEMSTICK_SYS_ATEN 0xc0 | ||
60 | #define MEMSTICK_SYS_BAMD 0x80 | ||
61 | #define MEMSTICK_SYS_PAM 0x08 | 59 | #define MEMSTICK_SYS_PAM 0x08 |
60 | #define MEMSTICK_SYS_BAMD 0x80 | ||
62 | 61 | ||
63 | unsigned char block_address_msb; | 62 | unsigned char block_address_msb; |
64 | unsigned short block_address; | 63 | unsigned short block_address; |
65 | unsigned char cp; | 64 | unsigned char cp; |
66 | #define MEMSTICK_CP_BLOCK 0x0000 | 65 | #define MEMSTICK_CP_BLOCK 0x00 |
67 | #define MEMSTICK_CP_PAGE 0x0020 | 66 | #define MEMSTICK_CP_PAGE 0x20 |
68 | #define MEMSTICK_CP_EXTRA 0x0040 | 67 | #define MEMSTICK_CP_EXTRA 0x40 |
69 | #define MEMSTICK_CP_OVERWRITE 0x0080 | 68 | #define MEMSTICK_CP_OVERWRITE 0x80 |
70 | 69 | ||
71 | unsigned char page_address; | 70 | unsigned char page_address; |
72 | } __attribute__((packed)); | 71 | } __attribute__((packed)); |
73 | 72 | ||
74 | struct ms_extra_data_register { | 73 | struct ms_extra_data_register { |
75 | unsigned char overwrite_flag; | 74 | unsigned char overwrite_flag; |
76 | #define MEMSTICK_OVERWRITE_UPDATA 0x0010 | 75 | #define MEMSTICK_OVERWRITE_UDST 0x10 |
77 | #define MEMSTICK_OVERWRITE_PAGE 0x0060 | 76 | #define MEMSTICK_OVERWRITE_PGST1 0x20 |
78 | #define MEMSTICK_OVERWRITE_BLOCK 0x0080 | 77 | #define MEMSTICK_OVERWRITE_PGST0 0x40 |
78 | #define MEMSTICK_OVERWRITE_BKST 0x80 | ||
79 | 79 | ||
80 | unsigned char management_flag; | 80 | unsigned char management_flag; |
81 | #define MEMSTICK_MANAGEMENT_SYSTEM 0x0004 | 81 | #define MEMSTICK_MANAGEMENT_SYSFLG 0x04 |
82 | #define MEMSTICK_MANAGEMENT_TRANS_TABLE 0x0008 | 82 | #define MEMSTICK_MANAGEMENT_ATFLG 0x08 |
83 | #define MEMSTICK_MANAGEMENT_COPY 0x0010 | 83 | #define MEMSTICK_MANAGEMENT_SCMS1 0x10 |
84 | #define MEMSTICK_MANAGEMENT_ACCESS 0x0020 | 84 | #define MEMSTICK_MANAGEMENT_SCMS0 0x20 |
85 | 85 | ||
86 | unsigned short logical_address; | 86 | unsigned short logical_address; |
87 | } __attribute__((packed)); | 87 | } __attribute__((packed)); |
@@ -96,9 +96,9 @@ struct ms_register { | |||
96 | 96 | ||
97 | struct mspro_param_register { | 97 | struct mspro_param_register { |
98 | unsigned char system; | 98 | unsigned char system; |
99 | #define MEMSTICK_SYS_SERIAL 0x80 | ||
100 | #define MEMSTICK_SYS_PAR4 0x00 | 99 | #define MEMSTICK_SYS_PAR4 0x00 |
101 | #define MEMSTICK_SYS_PAR8 0x40 | 100 | #define MEMSTICK_SYS_PAR8 0x40 |
101 | #define MEMSTICK_SYS_SERIAL 0x80 | ||
102 | 102 | ||
103 | unsigned short data_count; | 103 | unsigned short data_count; |
104 | unsigned int data_address; | 104 | unsigned int data_address; |
@@ -147,7 +147,7 @@ struct ms_register_addr { | |||
147 | unsigned char w_length; | 147 | unsigned char w_length; |
148 | } __attribute__((packed)); | 148 | } __attribute__((packed)); |
149 | 149 | ||
150 | enum { | 150 | enum memstick_tpc { |
151 | MS_TPC_READ_MG_STATUS = 0x01, | 151 | MS_TPC_READ_MG_STATUS = 0x01, |
152 | MS_TPC_READ_LONG_DATA = 0x02, | 152 | MS_TPC_READ_LONG_DATA = 0x02, |
153 | MS_TPC_READ_SHORT_DATA = 0x03, | 153 | MS_TPC_READ_SHORT_DATA = 0x03, |
@@ -167,7 +167,7 @@ enum { | |||
167 | MS_TPC_SET_CMD = 0x0e | 167 | MS_TPC_SET_CMD = 0x0e |
168 | }; | 168 | }; |
169 | 169 | ||
170 | enum { | 170 | enum memstick_command { |
171 | MS_CMD_BLOCK_END = 0x33, | 171 | MS_CMD_BLOCK_END = 0x33, |
172 | MS_CMD_RESET = 0x3c, | 172 | MS_CMD_RESET = 0x3c, |
173 | MS_CMD_BLOCK_WRITE = 0x55, | 173 | MS_CMD_BLOCK_WRITE = 0x55, |
@@ -201,8 +201,6 @@ enum { | |||
201 | 201 | ||
202 | /*** Driver structures and functions ***/ | 202 | /*** Driver structures and functions ***/ |
203 | 203 | ||
204 | #define MEMSTICK_PART_SHIFT 3 | ||
205 | |||
206 | enum memstick_param { MEMSTICK_POWER = 1, MEMSTICK_INTERFACE }; | 204 | enum memstick_param { MEMSTICK_POWER = 1, MEMSTICK_INTERFACE }; |
207 | 205 | ||
208 | #define MEMSTICK_POWER_OFF 0 | 206 | #define MEMSTICK_POWER_OFF 0 |
@@ -215,24 +213,27 @@ enum memstick_param { MEMSTICK_POWER = 1, MEMSTICK_INTERFACE }; | |||
215 | struct memstick_host; | 213 | struct memstick_host; |
216 | struct memstick_driver; | 214 | struct memstick_driver; |
217 | 215 | ||
216 | struct memstick_device_id { | ||
217 | unsigned char match_flags; | ||
218 | #define MEMSTICK_MATCH_ALL 0x01 | 218 | #define MEMSTICK_MATCH_ALL 0x01 |
219 | 219 | ||
220 | unsigned char type; | ||
220 | #define MEMSTICK_TYPE_LEGACY 0xff | 221 | #define MEMSTICK_TYPE_LEGACY 0xff |
221 | #define MEMSTICK_TYPE_DUO 0x00 | 222 | #define MEMSTICK_TYPE_DUO 0x00 |
222 | #define MEMSTICK_TYPE_PRO 0x01 | 223 | #define MEMSTICK_TYPE_PRO 0x01 |
223 | 224 | ||
225 | unsigned char category; | ||
224 | #define MEMSTICK_CATEGORY_STORAGE 0xff | 226 | #define MEMSTICK_CATEGORY_STORAGE 0xff |
225 | #define MEMSTICK_CATEGORY_STORAGE_DUO 0x00 | 227 | #define MEMSTICK_CATEGORY_STORAGE_DUO 0x00 |
228 | #define MEMSTICK_CATEGORY_IO 0x01 | ||
229 | #define MEMSTICK_CATEGORY_IO_PRO 0x10 | ||
226 | 230 | ||
227 | #define MEMSTICK_CLASS_GENERIC 0xff | ||
228 | #define MEMSTICK_CLASS_GENERIC_DUO 0x00 | ||
229 | |||
230 | |||
231 | struct memstick_device_id { | ||
232 | unsigned char match_flags; | ||
233 | unsigned char type; | ||
234 | unsigned char category; | ||
235 | unsigned char class; | 231 | unsigned char class; |
232 | #define MEMSTICK_CLASS_FLASH 0xff | ||
233 | #define MEMSTICK_CLASS_DUO 0x00 | ||
234 | #define MEMSTICK_CLASS_ROM 0x01 | ||
235 | #define MEMSTICK_CLASS_RO 0x02 | ||
236 | #define MEMSTICK_CLASS_WP 0x03 | ||
236 | }; | 237 | }; |
237 | 238 | ||
238 | struct memstick_request { | 239 | struct memstick_request { |
@@ -319,9 +320,9 @@ void memstick_suspend_host(struct memstick_host *host); | |||
319 | void memstick_resume_host(struct memstick_host *host); | 320 | void memstick_resume_host(struct memstick_host *host); |
320 | 321 | ||
321 | void memstick_init_req_sg(struct memstick_request *mrq, unsigned char tpc, | 322 | void memstick_init_req_sg(struct memstick_request *mrq, unsigned char tpc, |
322 | struct scatterlist *sg); | 323 | const struct scatterlist *sg); |
323 | void memstick_init_req(struct memstick_request *mrq, unsigned char tpc, | 324 | void memstick_init_req(struct memstick_request *mrq, unsigned char tpc, |
324 | void *buf, size_t length); | 325 | const void *buf, size_t length); |
325 | int memstick_next_req(struct memstick_host *host, | 326 | int memstick_next_req(struct memstick_host *host, |
326 | struct memstick_request **mrq); | 327 | struct memstick_request **mrq); |
327 | void memstick_new_req(struct memstick_host *host); | 328 | void memstick_new_req(struct memstick_host *host); |