diff options
-rw-r--r-- | apps/debug_menu.c | 24 | ||||
-rw-r--r-- | firmware/drivers/ata_mmc.c | 18 | ||||
-rw-r--r-- | firmware/hotswap.c | 9 | ||||
-rw-r--r-- | firmware/target/arm/ata-sd-pp.c | 10 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c | 10 |
5 files changed, 38 insertions, 33 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 97bd698871..ab2f2821b2 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -1910,20 +1910,20 @@ static int disk_callback(int btn, struct gui_synclist *lists) | |||
1910 | strncpy(card_name, ((unsigned char*)card->cid) + 3, 6); | 1910 | strncpy(card_name, ((unsigned char*)card->cid) + 3, 6); |
1911 | simplelist_addline(SIMPLELIST_ADD_LINE, | 1911 | simplelist_addline(SIMPLELIST_ADD_LINE, |
1912 | "%s Rev %d.%d", card_name, | 1912 | "%s Rev %d.%d", card_name, |
1913 | (int) card_extract_bits(card->cid, 72, 4), | 1913 | (int) card_extract_bits(card->cid, 55, 4), |
1914 | (int) card_extract_bits(card->cid, 76, 4)); | 1914 | (int) card_extract_bits(card->cid, 51, 4)); |
1915 | simplelist_addline(SIMPLELIST_ADD_LINE, | 1915 | simplelist_addline(SIMPLELIST_ADD_LINE, |
1916 | "Prod: %d/%d", | 1916 | "Prod: %d/%d", |
1917 | (int) card_extract_bits(card->cid, 112, 4), | 1917 | (int) card_extract_bits(card->cid, 15, 4), |
1918 | (int) card_extract_bits(card->cid, 116, 4) + 1997); | 1918 | (int) card_extract_bits(card->cid, 11, 4) + 1997); |
1919 | simplelist_addline(SIMPLELIST_ADD_LINE, | 1919 | simplelist_addline(SIMPLELIST_ADD_LINE, |
1920 | "Ser#: 0x%08lx", | 1920 | "Ser#: 0x%08lx", |
1921 | card_extract_bits(card->cid, 80, 32)); | 1921 | card_extract_bits(card->cid, 47, 32)); |
1922 | simplelist_addline(SIMPLELIST_ADD_LINE, | 1922 | simplelist_addline(SIMPLELIST_ADD_LINE, |
1923 | "M=%02x, O=%04x", | 1923 | "M=%02x, O=%04x", |
1924 | (int) card_extract_bits(card->cid, 0, 8), | 1924 | (int) card_extract_bits(card->cid, 127, 8), |
1925 | (int) card_extract_bits(card->cid, 8, 16)); | 1925 | (int) card_extract_bits(card->cid, 119, 16)); |
1926 | int temp = card_extract_bits(card->csd, 2, 4); | 1926 | int temp = card_extract_bits(card->csd, 125, 4); |
1927 | simplelist_addline(SIMPLELIST_ADD_LINE, | 1927 | simplelist_addline(SIMPLELIST_ADD_LINE, |
1928 | CARDTYPE " v%s", temp < 5 ? | 1928 | CARDTYPE " v%s", temp < 5 ? |
1929 | spec_vers[temp] : "?.?"); | 1929 | spec_vers[temp] : "?.?"); |
@@ -1943,12 +1943,12 @@ static int disk_callback(int btn, struct gui_synclist *lists) | |||
1943 | "R2W: *%d", card->r2w_factor); | 1943 | "R2W: *%d", card->r2w_factor); |
1944 | simplelist_addline(SIMPLELIST_ADD_LINE, | 1944 | simplelist_addline(SIMPLELIST_ADD_LINE, |
1945 | "IRmax: %d..%d mA", | 1945 | "IRmax: %d..%d mA", |
1946 | i_vmin[card_extract_bits(card->csd, 66, 3)], | 1946 | i_vmin[card_extract_bits(card->csd, 61, 3)], |
1947 | i_vmax[card_extract_bits(card->csd, 69, 3)]); | 1947 | i_vmax[card_extract_bits(card->csd, 58, 3)]); |
1948 | simplelist_addline(SIMPLELIST_ADD_LINE, | 1948 | simplelist_addline(SIMPLELIST_ADD_LINE, |
1949 | "IWmax: %d..%d mA", | 1949 | "IWmax: %d..%d mA", |
1950 | i_vmin[card_extract_bits(card->csd, 72, 3)], | 1950 | i_vmin[card_extract_bits(card->csd, 55, 3)], |
1951 | i_vmax[card_extract_bits(card->csd, 75, 3)]); | 1951 | i_vmax[card_extract_bits(card->csd, 52, 3)]); |
1952 | } | 1952 | } |
1953 | else if (card->initialized == 0) | 1953 | else if (card->initialized == 0) |
1954 | { | 1954 | { |
diff --git a/firmware/drivers/ata_mmc.c b/firmware/drivers/ata_mmc.c index 1dc330c538..0fe89c5be8 100644 --- a/firmware/drivers/ata_mmc.c +++ b/firmware/drivers/ata_mmc.c | |||
@@ -425,25 +425,25 @@ static int initialize_card(int card_no) | |||
425 | if (rc) | 425 | if (rc) |
426 | return rc * 10 - 5; | 426 | return rc * 10 - 5; |
427 | 427 | ||
428 | blk_exp = card_extract_bits(card->csd, 44, 4); | 428 | blk_exp = card_extract_bits(card->csd, 83, 4); |
429 | if (blk_exp < 9) /* block size < 512 bytes not supported */ | 429 | if (blk_exp < 9) /* block size < 512 bytes not supported */ |
430 | return -6; | 430 | return -6; |
431 | 431 | ||
432 | card->numblocks = (card_extract_bits(card->csd, 54, 12) + 1) | 432 | card->numblocks = (card_extract_bits(card->csd, 73, 12) + 1) |
433 | << (card_extract_bits(card->csd, 78, 3) + 2 + blk_exp - 9); | 433 | << (card_extract_bits(card->csd, 49, 3) + 2 + blk_exp - 9); |
434 | card->blocksize = BLOCK_SIZE; | 434 | card->blocksize = BLOCK_SIZE; |
435 | 435 | ||
436 | /* max transmission speed, clock divider */ | 436 | /* max transmission speed, clock divider */ |
437 | ts_exp = card_extract_bits(card->csd, 29, 3); | 437 | ts_exp = card_extract_bits(card->csd, 98, 3); |
438 | ts_exp = (ts_exp > 3) ? 3 : ts_exp; | 438 | ts_exp = (ts_exp > 3) ? 3 : ts_exp; |
439 | card->speed = mantissa[card_extract_bits(card->csd, 25, 4)] | 439 | card->speed = mantissa[card_extract_bits(card->csd, 102, 4)] |
440 | * exponent[ts_exp + 4]; | 440 | * exponent[ts_exp + 4]; |
441 | card->bitrate_register = (FREQ/4-1) / card->speed; | 441 | card->bitrate_register = (FREQ/4-1) / card->speed; |
442 | 442 | ||
443 | /* NSAC, TAAC, read timeout */ | 443 | /* NSAC, TAAC, read timeout */ |
444 | card->nsac = 100 * card_extract_bits(card->csd, 16, 8); | 444 | card->nsac = 100 * card_extract_bits(card->csd, 111, 8); |
445 | card->taac = mantissa[card_extract_bits(card->csd, 9, 4)]; | 445 | card->taac = mantissa[card_extract_bits(card->csd, 118, 4)]; |
446 | taac_exp = card_extract_bits(card->csd, 13, 3); | 446 | taac_exp = card_extract_bits(card->csd, 114, 3); |
447 | card->read_timeout = ((FREQ/4) / (card->bitrate_register + 1) | 447 | card->read_timeout = ((FREQ/4) / (card->bitrate_register + 1) |
448 | * card->taac / exponent[9 - taac_exp] | 448 | * card->taac / exponent[9 - taac_exp] |
449 | + (10 * card->nsac)); | 449 | + (10 * card->nsac)); |
@@ -451,7 +451,7 @@ static int initialize_card(int card_no) | |||
451 | card->taac = card->taac * exponent[taac_exp] / 10; | 451 | card->taac = card->taac * exponent[taac_exp] / 10; |
452 | 452 | ||
453 | /* r2w_factor, write timeout */ | 453 | /* r2w_factor, write timeout */ |
454 | card->r2w_factor = BIT_N(card_extract_bits(card->csd, 99, 3)); | 454 | card->r2w_factor = BIT_N(card_extract_bits(card->csd, 28, 3)); |
455 | card->write_timeout = card->read_timeout * card->r2w_factor; | 455 | card->write_timeout = card->read_timeout * card->r2w_factor; |
456 | 456 | ||
457 | if (card->r2w_factor > 32) /* Such cards often need extra read delay */ | 457 | if (card->r2w_factor > 32) /* Such cards often need extra read delay */ |
diff --git a/firmware/hotswap.c b/firmware/hotswap.c index 97c162ce39..ec298f7243 100644 --- a/firmware/hotswap.c +++ b/firmware/hotswap.c | |||
@@ -33,9 +33,14 @@ unsigned long card_extract_bits( | |||
33 | unsigned int start, /* bit no. to start reading */ | 33 | unsigned int start, /* bit no. to start reading */ |
34 | unsigned int size) /* how many bits to read */ | 34 | unsigned int size) /* how many bits to read */ |
35 | { | 35 | { |
36 | unsigned int long_index = start / 32; | 36 | unsigned int long_index, bit_index; |
37 | unsigned int bit_index = start % 32; | ||
38 | unsigned long result; | 37 | unsigned long result; |
38 | |||
39 | /* we assume words of CSD/CID are stored least significant word first */ | ||
40 | start = 127 - start; | ||
41 | |||
42 | long_index = start / 32; | ||
43 | bit_index = start % 32; | ||
39 | 44 | ||
40 | result = p[long_index] << bit_index; | 45 | result = p[long_index] << bit_index; |
41 | 46 | ||
diff --git a/firmware/target/arm/ata-sd-pp.c b/firmware/target/arm/ata-sd-pp.c index ade5b8090b..8f30195791 100644 --- a/firmware/target/arm/ata-sd-pp.c +++ b/firmware/target/arm/ata-sd-pp.c | |||
@@ -1306,12 +1306,12 @@ tCardInfo *card_get_info_target(int card_no) | |||
1306 | for(i=0; i<4; i++) card.cid[i] = card_info[card_no].cid[3-i]; | 1306 | for(i=0; i<4; i++) card.cid[i] = card_info[card_no].cid[3-i]; |
1307 | card.numblocks = card_info[card_no].numblocks; | 1307 | card.numblocks = card_info[card_no].numblocks; |
1308 | card.blocksize = card_info[card_no].blocksize; | 1308 | card.blocksize = card_info[card_no].blocksize; |
1309 | temp = card_extract_bits(card.csd, 29, 3); | 1309 | temp = card_extract_bits(card.csd, 98, 3); |
1310 | card.speed = mantissa[card_extract_bits(card.csd, 25, 4)] | 1310 | card.speed = mantissa[card_extract_bits(card.csd, 102, 4)] |
1311 | * exponent[temp > 2 ? 7 : temp + 4]; | 1311 | * exponent[temp > 2 ? 7 : temp + 4]; |
1312 | card.nsac = 100 * card_extract_bits(card.csd, 16, 8); | 1312 | card.nsac = 100 * card_extract_bits(card.csd, 111, 8); |
1313 | temp = card_extract_bits(card.csd, 13, 3); | 1313 | temp = card_extract_bits(card.csd, 114, 3); |
1314 | card.taac = mantissa[card_extract_bits(card.csd, 9, 4)] | 1314 | card.taac = mantissa[card_extract_bits(card.csd, 118, 4)] |
1315 | * exponent[temp] / 10; | 1315 | * exponent[temp] / 10; |
1316 | card.cid[0] = htobe32(card.cid[0]); /* ascii chars here */ | 1316 | card.cid[0] = htobe32(card.cid[0]); /* ascii chars here */ |
1317 | card.cid[1] = htobe32(card.cid[1]); /* ascii chars here */ | 1317 | card.cid[1] = htobe32(card.cid[1]); /* ascii chars here */ |
diff --git a/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c b/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c index 31a9f7d2b0..6e7f62a2e5 100644 --- a/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c +++ b/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c | |||
@@ -1675,12 +1675,12 @@ tCardInfo* card_get_info_target(int card_no) | |||
1675 | card.csd[i] = ((unsigned long*)&mmcinfo.csd)[i]; | 1675 | card.csd[i] = ((unsigned long*)&mmcinfo.csd)[i]; |
1676 | for(i=0; i<4; i++) | 1676 | for(i=0; i<4; i++) |
1677 | card.cid[i] = ((unsigned long*)&mmcinfo.cid)[i]; | 1677 | card.cid[i] = ((unsigned long*)&mmcinfo.cid)[i]; |
1678 | temp = card_extract_bits(card.csd, 29, 3); | 1678 | temp = card_extract_bits(card.csd, 98, 3); |
1679 | card.speed = sd_mantissa[card_extract_bits(card.csd, 25, 4)] | 1679 | card.speed = sd_mantissa[card_extract_bits(card.csd, 102, 4)] |
1680 | * sd_exponent[temp > 2 ? 7 : temp + 4]; | 1680 | * sd_exponent[temp > 2 ? 7 : temp + 4]; |
1681 | card.nsac = 100 * card_extract_bits(card.csd, 16, 8); | 1681 | card.nsac = 100 * card_extract_bits(card.csd, 111, 8); |
1682 | temp = card_extract_bits(card.csd, 13, 3); | 1682 | temp = card_extract_bits(card.csd, 114, 3); |
1683 | card.taac = sd_mantissa[card_extract_bits(card.csd, 9, 4)] | 1683 | card.taac = sd_mantissa[card_extract_bits(card.csd, 118, 4)] |
1684 | * sd_exponent[temp] / 10; | 1684 | * sd_exponent[temp] / 10; |
1685 | card.numblocks = mmcinfo.block_num; | 1685 | card.numblocks = mmcinfo.block_num; |
1686 | card.blocksize = mmcinfo.block_len; | 1686 | card.blocksize = mmcinfo.block_len; |