~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/staging/keucr/smilmain.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
DWORD ErrXDCode;
49
49
DWORD ErrCode;
50
50
//BYTE  SectBuf[SECTSIZE];
51
 
BYTE  WorkBuf[SECTSIZE];
52
 
BYTE  Redundant[REDTSIZE];
53
 
BYTE  WorkRedund[REDTSIZE];
 
51
static BYTE  WorkBuf[SECTSIZE];
 
52
static BYTE  Redundant[REDTSIZE];
 
53
static BYTE  WorkRedund[REDTSIZE];
54
54
//WORD  Log2Phy[MAX_ZONENUM][MAX_LOGBLOCK];
55
 
WORD  *Log2Phy[MAX_ZONENUM];                 // 128 x 1000,   Log2Phy[MAX_ZONENUM][MAX_LOGBLOCK];
56
 
BYTE  Assign[MAX_ZONENUM][MAX_BLOCKNUM/8];
57
 
WORD  AssignStart[MAX_ZONENUM];
 
55
static WORD  *Log2Phy[MAX_ZONENUM];                 // 128 x 1000,   Log2Phy[MAX_ZONENUM][MAX_LOGBLOCK];
 
56
static BYTE  Assign[MAX_ZONENUM][MAX_BLOCKNUM/8];
 
57
static WORD  AssignStart[MAX_ZONENUM];
58
58
WORD  ReadBlock;
59
59
WORD  WriteBlock;
60
60
DWORD MediaChange;
61
 
DWORD SectCopyMode;
62
 
 
63
 
extern struct SSFDCTYPE  Ssfdc;
64
 
extern struct ADDRESS    Media;
65
 
extern struct CIS_AREA   CisArea;
66
 
 
67
 
//BIT Controll Macro
68
 
BYTE BitData[] = { 0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80 } ;
 
61
static DWORD SectCopyMode;
 
62
 
 
63
//BIT Control Macro
 
64
static BYTE BitData[] = { 0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80 } ;
69
65
#define Set_D_Bit(a,b)    (a[(BYTE)((b)/8)]|= BitData[(b)%8])
70
66
#define Clr_D_Bit(a,b)    (a[(BYTE)((b)/8)]&=~BitData[(b)%8])
71
67
#define Chk_D_Bit(a,b)    (a[(BYTE)((b)/8)] & BitData[(b)%8])
72
68
 
73
69
//extern PBYTE    SMHostAddr;
74
 
extern BYTE     IsSSFDCCompliance;
75
 
extern BYTE     IsXDCompliance;
 
70
BYTE     IsSSFDCCompliance;
 
71
BYTE     IsXDCompliance;
76
72
 
77
73
 
78
74
//
79
 
////Power Controll & Media Exist Check Function
 
75
////Power Control & Media Exist Check Function
80
76
////----- Init_D_SmartMedia() --------------------------------------------
81
77
//int Init_D_SmartMedia(void)
82
78
//{
102
98
{
103
99
        int     i;
104
100
 
105
 
        printk("SM_FreeMem start\n");
 
101
        pr_info("SM_FreeMem start\n");
106
102
        for (i=0; i<MAX_ZONENUM; i++)
107
103
        {
108
104
                if (Log2Phy[i]!=NULL)
109
105
                {
110
 
                        printk("Free Zone = %x, Addr = %p\n", i, Log2Phy[i]);
 
106
                        pr_info("Free Zone = %x, Addr = %p\n", i, Log2Phy[i]);
111
107
                        kfree(Log2Phy[i]);
112
108
                        Log2Phy[i] = NULL;
113
109
                }
198
194
        //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
199
195
        //ADDRESS_T   bb = (ADDRESS_T) &Media;
200
196
 
201
 
        //printk("Media_D_CopySector !!!\n");
 
197
        /* pr_info("Media_D_CopySector !!!\n"); */
202
198
        if (Conv_D_MediaAddr(us, start))
203
199
                return(ErrCode);
204
200
 
256
252
        if (Media.PhyBlock==NO_ASSIGN)
257
253
        {
258
254
                Media.PhyBlock=WriteBlock;
259
 
                return(SUCCESS);
 
255
                return(SMSUCCESS);
260
256
        }
261
257
 
262
258
        Clr_D_Bit(Assign[Media.Zone],Media.PhyBlock);
263
259
        Media.PhyBlock=WriteBlock;
264
260
 
265
 
        return(SUCCESS);
 
261
        return(SMSUCCESS);
266
262
}
267
263
/*
268
264
//----- Media_D_WriteSector() ------------------------------------------
572
568
//        default:         *c= 0;  *h= 0; *s= 0; ErrCode = ERR_NoSmartMedia;    return(ERROR);
573
569
//    }
574
570
//
575
 
//    return(SUCCESS);
 
571
//    return(SMSUCCESS);
576
572
//}
577
573
//
578
 
////Power Controll & Media Exist Check Subroutine
 
574
////Power Control & Media Exist Check Subroutine
579
575
////----- Initialize_D_Media() -------------------------------------------
580
576
//void Initialize_D_Media(void)
581
577
//{
599
595
//        MediaChange = ERROR;
600
596
//    //usleep(56*1024);
601
597
//    if ((!Check_D_CntPower())&&(!MediaChange))  // �� power & Media �S�Q change, �h return success
602
 
//        return(SUCCESS);
 
598
//        return(SMSUCCESS);
603
599
//    //usleep(56*1024);
604
600
//
605
601
//    if (Check_D_CardExist())                    // Check if card is not exist, return err
618
614
//    //usleep(56*1024);
619
615
//    Ssfdc_D_Reset(fdoExt);
620
616
//    //usleep(56*1024);
621
 
//    return(SUCCESS);
 
617
//    return(SMSUCCESS);
622
618
//}
623
619
//
624
620
////-----Check_D_MediaExist() --------------------------------------------
630
626
//    if (!Check_D_CardExist())
631
627
//    {
632
628
//        if (!MediaChange)
633
 
//            return(SUCCESS);
 
629
//            return(SMSUCCESS);
634
630
//
635
631
//        ErrCode = ERR_ChangedMedia;
636
632
//        return(ERROR);
650
646
//        return(ERROR);
651
647
//    }
652
648
//
653
 
//    return(SUCCESS);
 
649
//    return(SMSUCCESS);
654
650
//}
655
651
*/
656
652
//SmartMedia Physical Format Test Subroutine
657
653
//----- Check_D_MediaFmt() ---------------------------------------------
658
654
int Check_D_MediaFmt(struct us_data *us)
659
655
{
660
 
        printk("Check_D_MediaFmt\n");
 
656
        pr_info("Check_D_MediaFmt\n");
661
657
        //ULONG i,j, result=FALSE, zone,block;
662
658
 
663
659
        //usleep(56*1024);
664
660
        if (!MediaChange)
665
 
                return(SUCCESS);
 
661
                return(SMSUCCESS);
666
662
 
667
663
        MediaChange  = ERROR;
668
664
        SectCopyMode = COMPLETED;
682
678
        }
683
679
 
684
680
 
685
 
    MediaChange = SUCCESS;
686
 
    return(SUCCESS);
 
681
    MediaChange = SMSUCCESS;
 
682
    return(SMSUCCESS);
687
683
}
688
684
/*
689
685
////----- Check_D_BlockIsFull() ----------------------------------
735
731
//        return(ERROR);
736
732
//    }
737
733
//
738
 
//    return(SUCCESS);
 
734
//    return(SMSUCCESS);
739
735
//}
740
736
*/
741
 
//SmartMedia Physical Address Controll Subroutine
 
737
//SmartMedia Physical Address Control Subroutine
742
738
//----- Conv_D_MediaAddr() ---------------------------------------------
743
739
int Conv_D_MediaAddr(struct us_data *us, DWORD addr)
744
740
{
767
763
                Clr_D_RedundantData(Redundant);
768
764
                Set_D_LogBlockAddr(Redundant);
769
765
                Media.PhyBlock = Log2Phy[Media.Zone][Media.LogBlock];
770
 
                return(SUCCESS);
 
766
                return(SMSUCCESS);
771
767
        }
772
768
 
773
769
        ErrCode = ERR_OutOfLBA;
782
778
        //ADDRESS_T   bb = (ADDRESS_T) &Media;
783
779
 
784
780
        if (++Media.Sector<Ssfdc.MaxSectors)
785
 
                return(SUCCESS);
 
781
                return(SMSUCCESS);
786
782
 
787
783
        if (Log2Phy[Media.Zone]==NULL)
788
784
        {
801
797
                Clr_D_RedundantData(Redundant);
802
798
                Set_D_LogBlockAddr(Redundant);
803
799
                Media.PhyBlock=Log2Phy[Media.Zone][Media.LogBlock];
804
 
                return(SUCCESS);
 
800
                return(SMSUCCESS);
805
801
        }
806
802
 
807
803
        Media.LogBlock=0;
822
818
                Clr_D_RedundantData(Redundant);
823
819
                Set_D_LogBlockAddr(Redundant);
824
820
                Media.PhyBlock=Log2Phy[Media.Zone][Media.LogBlock];
825
 
                return(SUCCESS);
 
821
                return(SMSUCCESS);
826
822
        }
827
823
 
828
824
        Media.Zone=0;
838
834
    ADDRESS_T   bb = (ADDRESS_T) &Media;
839
835
 
840
836
    if (!Media.Sector)
841
 
        return(SUCCESS);
 
837
        return(SMSUCCESS);
842
838
 
843
839
    return(ERROR);
844
840
}
852
848
    if (Media.Sector<(Ssfdc.MaxSectors-1))
853
849
        return(ERROR);
854
850
 
855
 
    return(SUCCESS);
 
851
    return(SMSUCCESS);
856
852
}
857
853
*/
858
854
//SmartMedia Read/Write Subroutine with Retry
862
858
        DWORD err, retry;
863
859
 
864
860
        if (!Read_D_PhyOneSect(us, count, buf))
865
 
                return(SUCCESS);
 
861
                return(SMSUCCESS);
866
862
        if (ErrCode==ERR_HwError)
867
863
                return(ERROR);
868
864
        if (ErrCode==ERR_DataStatus)
872
868
        if (Ssfdc.Attribute &MWP)
873
869
        {
874
870
                if (ErrCode==ERR_CorReadErr)
875
 
                        return(SUCCESS);
 
871
                        return(SMSUCCESS);
876
872
                return(ERROR);
877
873
        }
878
874
 
888
884
 
889
885
                ErrCode = err;
890
886
                if (ErrCode==ERR_CorReadErr)
891
 
                        return(SUCCESS);
 
887
                        return(SMSUCCESS);
892
888
                return(ERROR);
893
889
        }
894
890
 
895
891
        MediaChange = ERROR;
896
892
#else
897
 
        if (ErrCode==ERR_CorReadErr) return(SUCCESS);
 
893
        if (ErrCode==ERR_CorReadErr) return(SMSUCCESS);
898
894
#endif
899
895
 
900
896
        return(ERROR);
908
904
    ADDRESS_T   bb = (ADDRESS_T) &Media;
909
905
 
910
906
    if (!Write_D_PhyOneSect(fdoExt, count, buf))
911
 
        return(SUCCESS);
 
907
        return(SMSUCCESS);
912
908
    if (ErrCode==ERR_HwError)
913
909
        return(ERROR);
914
910
 
922
918
        }
923
919
 
924
920
        if (!Write_D_PhyOneSect(fdoExt, count, buf))
925
 
            return(SUCCESS);
 
921
            return(SMSUCCESS);
926
922
        if (ErrCode==ERR_HwError)
927
923
            return(ERROR);
928
924
    }
944
940
    for(retry=0; retry<2; retry++)
945
941
    {
946
942
        if (!Copy_D_BlockHead(fdoExt))
947
 
            return(SUCCESS);
 
943
            return(SMSUCCESS);
948
944
        if (ErrCode==ERR_HwError)
949
945
            return(ERROR);
950
946
    }
959
955
    DWORD retry;
960
956
 
961
957
    if (!Copy_D_BlockTail(fdoExt))
962
 
        return(SUCCESS);
 
958
        return(SMSUCCESS);
963
959
    if (ErrCode==ERR_HwError)
964
960
        return(ERROR);
965
961
 
973
969
        }
974
970
 
975
971
        if (!Copy_D_BlockTail(fdoExt))
976
 
            return(SUCCESS);
 
972
            return(SMSUCCESS);
977
973
        if (ErrCode==ERR_HwError)
978
974
            return(ERROR);
979
975
    }
995
991
//    ADDRESS_T   bb = (ADDRESS_T) &Media;
996
992
//
997
993
//    if (Media.PhyBlock==NO_ASSIGN)
998
 
//        return(SUCCESS);
 
994
//        return(SMSUCCESS);
999
995
//
1000
996
//    if (Log2Phy[Media.Zone]==NULL)
1001
997
//    {
1023
1019
//
1024
1020
//    Clr_D_Bit(Assign[Media.Zone],Media.PhyBlock);
1025
1021
//    Media.PhyBlock=NO_ASSIGN;
1026
 
//    return(SUCCESS);
 
1022
//    return(SMSUCCESS);
1027
1023
//}
1028
1024
//
1029
1025
////SmartMedia Erase Subroutine
1076
1072
//            }
1077
1073
//
1078
1074
//        }
1079
 
//    return(SUCCESS);
 
1075
//    return(SMSUCCESS);
1080
1076
//}
1081
1077
*/
1082
1078
//SmartMedia Physical Sector Data Copy Subroutine
1116
1112
 
1117
1113
        Media.PhyBlock=WriteBlock;
1118
1114
        Media.Sector=sect;
1119
 
        return(SUCCESS);
 
1115
        return(SMSUCCESS);
1120
1116
}
1121
1117
/*
1122
1118
//----- Copy_D_BlockHead() ---------------------------------------------
1149
1145
 
1150
1146
    Media.PhyBlock=WriteBlock;
1151
1147
    Media.Sector=sect;
1152
 
    return(SUCCESS);
 
1148
    return(SMSUCCESS);
1153
1149
}
1154
1150
 
1155
1151
//----- Copy_D_BlockTail() ---------------------------------------------
1178
1174
 
1179
1175
    Media.PhyBlock=WriteBlock;
1180
1176
    Media.Sector=sect;
1181
 
    return(SUCCESS);
 
1177
    return(SMSUCCESS);
1182
1178
}
1183
1179
 
1184
1180
//----- Reassign_D_BlockHead() -----------------------------------------
1226
1222
    ReadBlock=block;
1227
1223
    Media.Sector=sect;
1228
1224
    Media.PhyBlock=WriteBlock;
1229
 
    return(SUCCESS);
 
1225
    return(SMSUCCESS);
1230
1226
}
1231
1227
*/
1232
1228
//SmartMedia Physical Block Assign/Release Subroutine
1246
1242
                        Media.PhyBlock=WriteBlock;
1247
1243
                        SectCopyMode=REQ_ERASE;
1248
1244
                        //ErrXDCode = NO_ERROR;
1249
 
                        return(SUCCESS);
 
1245
                        return(SMSUCCESS);
1250
1246
                }
1251
1247
        }
1252
1248
 
1259
1255
                        Media.PhyBlock=WriteBlock;
1260
1256
                        SectCopyMode=REQ_ERASE;
1261
1257
                        //ErrXDCode = NO_ERROR;
1262
 
                        return(SUCCESS);
 
1258
                        return(SMSUCCESS);
1263
1259
                }
1264
1260
        }
1265
1261
 
1282
1278
        SectCopyMode=COMPLETED;
1283
1279
 
1284
1280
        if (mode==COMPLETED)
1285
 
                return(SUCCESS);
 
1281
                return(SMSUCCESS);
1286
1282
 
1287
1283
        Log2Phy[Media.Zone][Media.LogBlock]=WriteBlock;
1288
1284
        Media.PhyBlock=ReadBlock;
1290
1286
        if (Media.PhyBlock==NO_ASSIGN)
1291
1287
        {
1292
1288
                Media.PhyBlock=WriteBlock;
1293
 
                return(SUCCESS);
 
1289
                return(SMSUCCESS);
1294
1290
        }
1295
1291
 
1296
1292
        if (mode==REQ_ERASE)
1307
1303
                return(ERROR);
1308
1304
 
1309
1305
        Media.PhyBlock=WriteBlock;
1310
 
        return(SUCCESS);
 
1306
        return(SMSUCCESS);
1311
1307
}
1312
1308
 
1313
1309
//----- Release_D_WriteBlock() -----------------------------------------
1322
1318
                return(ERROR);
1323
1319
 
1324
1320
        Media.PhyBlock=ReadBlock;
1325
 
        return(SUCCESS);
 
1321
        return(SMSUCCESS);
1326
1322
}
1327
1323
 
1328
1324
//SmartMedia Physical Sector Data Copy Subroutine
1334
1330
        //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
1335
1331
        //ADDRESS_T   bb = (ADDRESS_T) &Media;
1336
1332
 
1337
 
        //printk("Copy_D_PhyOneSect --- Secotr = %x\n", Media.Sector);
 
1333
        /* pr_info("Copy_D_PhyOneSect --- Secotr = %x\n", Media.Sector); */
1338
1334
        if (ReadBlock!=NO_ASSIGN)
1339
1335
        {
1340
1336
                Media.PhyBlock=ReadBlock;
1355
1351
                        if (Check_D_DataStatus(WorkRedund))
1356
1352
                        { err=ERROR; break; }
1357
1353
                        if (!Check_D_ReadError(WorkRedund))
1358
 
                        { err=SUCCESS; break; }
 
1354
                        { err=SMSUCCESS; break; }
1359
1355
                        if (!Check_D_Correct(WorkBuf,WorkRedund))
1360
 
                        { err=SUCCESS; break; }
 
1356
                        { err=SMSUCCESS; break; }
1361
1357
 
1362
1358
                        err=ERROR;
1363
1359
                        SectCopyMode=REQ_FAIL;
1365
1361
        }
1366
1362
        else
1367
1363
        {
1368
 
                err=SUCCESS;
 
1364
                err=SMSUCCESS;
1369
1365
                for(i=0; i<SECTSIZE; i++)
1370
1366
                        WorkBuf[i]=DUMMY_DATA;
1371
1367
                Clr_D_RedundantData(WorkRedund);
1386
1382
        { ErrCode = ERR_WriteFault; return(ERROR); }
1387
1383
 
1388
1384
        Media.PhyBlock=ReadBlock;
1389
 
        return(SUCCESS);
 
1385
        return(SMSUCCESS);
1390
1386
}
1391
1387
 
1392
1388
//SmartMedia Physical Sector Read/Write/Erase Subroutine
1402
1398
        {
1403
1399
                for(i=0; i<SECTSIZE; i++)
1404
1400
                        *buf++=DUMMY_DATA;
1405
 
                return(SUCCESS);
 
1401
                return(SMSUCCESS);
1406
1402
        }
1407
1403
 
1408
1404
        for(retry=0; retry<2; retry++)
1424
1420
                { ErrCode = ERR_DataStatus; return(ERROR); }
1425
1421
 
1426
1422
                if (!Check_D_ReadError(Redundant))
1427
 
                        return(SUCCESS);
 
1423
                        return(SMSUCCESS);
1428
1424
 
1429
1425
                if (!Check_D_Correct(buf,Redundant))
1430
1426
                { ErrCode = ERR_CorReadErr; return(ERROR); }
1446
1442
    if (Ssfdc_D_CheckStatus())
1447
1443
    { ErrCode = ERR_WriteFault; return(ERROR); }
1448
1444
 
1449
 
    return(SUCCESS);
 
1445
    return(SMSUCCESS);
1450
1446
}
1451
1447
*/
1452
1448
//----- Erase_D_PhyOneBlock() ------------------------------------------
1460
1456
        if (Ssfdc_D_CheckStatus())
1461
1457
        { ErrCode = ERR_WriteFault; return(ERROR); }
1462
1458
 
1463
 
        return(SUCCESS);
 
1459
        return(SMSUCCESS);
1464
1460
}
1465
1461
 
1466
1462
//SmartMedia Physical Format Check Local Subroutine
1544
1540
//       }
1545
1541
//    }
1546
1542
 
1547
 
    return(SUCCESS);
 
1543
    return(SMSUCCESS);
1548
1544
}
1549
1545
 
1550
1546
//----- Search_D_CIS() -------------------------------------------------
1600
1596
                        CisArea.PhyBlock=Media.PhyBlock;
1601
1597
                        CisArea.Sector=Media.Sector;
1602
1598
                        Ssfdc_D_Reset(us);
1603
 
                        return(SUCCESS);
 
1599
                        return(SMSUCCESS);
1604
1600
                }
1605
1601
 
1606
1602
                Media.Sector++;
1620
1616
        if (Log2Phy[Media.Zone]==NULL)
1621
1617
        {
1622
1618
                Log2Phy[Media.Zone] = kmalloc(MAX_LOGBLOCK*sizeof(WORD), GFP_KERNEL);
1623
 
                //printk("ExAllocatePool Zone = %x, Addr = %x\n", Media.Zone, Log2Phy[Media.Zone]);
 
1619
                /* pr_info("ExAllocatePool Zone = %x, Addr = %x\n",
 
1620
                                Media.Zone, Log2Phy[Media.Zone]); */
1624
1621
                if (Log2Phy[Media.Zone]==NULL)
1625
1622
                        return(ERROR);
1626
1623
        }
1630
1627
        //for(Media.Zone=0; Media.Zone<MAX_ZONENUM; Media.Zone++)
1631
1628
        //for(Media.Zone=0; Media.Zone<Ssfdc.MaxZones; Media.Zone++)
1632
1629
        {
1633
 
                //printk("Make_D_LogTable --- MediaZone = 0x%x\n", Media.Zone);
 
1630
                /* pr_info("Make_D_LogTable --- MediaZone = 0x%x\n",
 
1631
                                                        Media.Zone); */
1634
1632
                for(Media.LogBlock=0; Media.LogBlock<Ssfdc.MaxLogBlocks; Media.LogBlock++)
1635
1633
                        Log2Phy[Media.Zone][Media.LogBlock]=NO_ASSIGN;
1636
1634
 
1735
1733
        } // End for (Media.Zone<MAX_ZONENUM)
1736
1734
 
1737
1735
        Ssfdc_D_Reset(us);
1738
 
        return(SUCCESS);
 
1736
        return(SMSUCCESS);
1739
1737
}
1740
1738
 
1741
1739
//----- MarkFail_D_PhyOneBlock() ---------------------------------------
1763
1761
 
1764
1762
        Ssfdc_D_Reset(us);
1765
1763
        Media.Sector=sect;
1766
 
        return(SUCCESS);
 
1764
        return(SMSUCCESS);
1767
1765
}
1768
1766
/*
1769
1767
//
1821
1819
//
1822
1820
//    Ssfdc_D_Reset(fdoExt);
1823
1821
//
1824
 
//    return(SUCCESS);
 
1822
//    return(SMSUCCESS);
1825
1823
//}
1826
1824
//
1827
1825
////----- Media_D_GetMediaInfo() ---------------------------------------