77 * it under the terms of the GNU General Public License version 2 as
88 * published by the Free Software Foundation.
99 *
10+ * Special thanks to Brad Campbell for extensive testing of this driver.
11+ *
1012 */
1113
1214
@@ -39,6 +41,7 @@ module_param(fixed_timeout, bool, 0644);
3941
4042#define TIFM_MMCSD_ERRMASK 0x01e0 /* set bits: CCRC, CTO, DCRC, DTO */
4143#define TIFM_MMCSD_EOC 0x0001 /* end of command phase */
44+ #define TIFM_MMCSD_CD 0x0002 /* card detect */
4245#define TIFM_MMCSD_CB 0x0004 /* card enter busy state */
4346#define TIFM_MMCSD_BRS 0x0008 /* block received/sent */
4447#define TIFM_MMCSD_EOFB 0x0010 /* card exit busy state */
@@ -48,6 +51,8 @@ module_param(fixed_timeout, bool, 0644);
4851#define TIFM_MMCSD_CCRC 0x0100 /* command crc error */
4952#define TIFM_MMCSD_AF 0x0400 /* fifo almost full */
5053#define TIFM_MMCSD_AE 0x0800 /* fifo almost empty */
54+ #define TIFM_MMCSD_OCRB 0x1000 /* OCR busy */
55+ #define TIFM_MMCSD_CIRQ 0x2000 /* card irq (cmd40/sdio) */
5156#define TIFM_MMCSD_CERR 0x4000 /* card status error */
5257
5358#define TIFM_MMCSD_ODTO 0x0040 /* open drain / extended timeout */
@@ -83,16 +88,16 @@ enum {
8388};
8489
8590struct tifm_sd {
86- struct tifm_dev * dev ;
91+ struct tifm_dev * dev ;
8792
88- unsigned short eject :1 ,
89- open_drain :1 ,
90- no_dma :1 ;
91- unsigned short cmd_flags ;
93+ unsigned short eject :1 ,
94+ open_drain :1 ,
95+ no_dma :1 ;
96+ unsigned short cmd_flags ;
9297
93- unsigned int clk_freq ;
94- unsigned int clk_div ;
95- unsigned long timeout_jiffies ;
98+ unsigned int clk_freq ;
99+ unsigned int clk_div ;
100+ unsigned long timeout_jiffies ;
96101
97102 struct tasklet_struct finish_tasklet ;
98103 struct timer_list timer ;
@@ -627,7 +632,8 @@ static void tifm_sd_request(struct mmc_host *mmc, struct mmc_request *mrq)
627632 }
628633
629634 if (host -> req ) {
630- printk (KERN_ERR DRIVER_NAME ": unfinished request detected\n" );
635+ printk (KERN_ERR "%s : unfinished request detected\n" ,
636+ sock -> dev .bus_id );
631637 spin_unlock_irqrestore (& sock -> lock , flags );
632638 goto err_out ;
633639 }
@@ -737,7 +743,8 @@ static void tifm_sd_end_cmd(unsigned long data)
737743 host -> req = NULL ;
738744
739745 if (!mrq ) {
740- printk (KERN_ERR DRIVER_NAME ": no request to complete?\n" );
746+ printk (KERN_ERR " %s : no request to complete?\n" ,
747+ sock -> dev .bus_id );
741748 spin_unlock_irqrestore (& sock -> lock , flags );
742749 return ;
743750 }
@@ -775,8 +782,10 @@ static void tifm_sd_abort(unsigned long data)
775782{
776783 struct tifm_sd * host = (struct tifm_sd * )data ;
777784
778- printk (KERN_ERR DRIVER_NAME
779- ": card failed to respond for a long period of time\n" );
785+ printk (KERN_ERR
786+ "%s : card failed to respond for a long period of time "
787+ "(%x, %x)\n" ,
788+ host -> dev -> dev .bus_id , host -> req -> cmd -> opcode , host -> cmd_flags );
780789
781790 tifm_eject (host -> dev );
782791}
@@ -790,8 +799,11 @@ static void tifm_sd_ios(struct mmc_host *mmc, struct mmc_ios *ios)
790799
791800 spin_lock_irqsave (& sock -> lock , flags );
792801
793- dev_dbg (& sock -> dev , "Setting bus width %d, power %d\n" , ios -> bus_width ,
794- ios -> power_mode );
802+ dev_dbg (& sock -> dev , "ios: clock = %u, vdd = %x, bus_mode = %x, "
803+ "chip_select = %x, power_mode = %x, bus_width = %x\n" ,
804+ ios -> clock , ios -> vdd , ios -> bus_mode , ios -> chip_select ,
805+ ios -> power_mode , ios -> bus_width );
806+
795807 if (ios -> bus_width == MMC_BUS_WIDTH_4 ) {
796808 writel (TIFM_MMCSD_4BBUS | readl (sock -> addr + SOCK_MMCSD_CONFIG ),
797809 sock -> addr + SOCK_MMCSD_CONFIG );
@@ -937,7 +949,8 @@ static int tifm_sd_probe(struct tifm_dev *sock)
937949
938950 if (!(TIFM_SOCK_STATE_OCCUPIED
939951 & readl (sock -> addr + SOCK_PRESENT_STATE ))) {
940- printk (KERN_WARNING DRIVER_NAME ": card gone, unexpectedly\n" );
952+ printk (KERN_WARNING "%s : card gone, unexpectedly\n" ,
953+ sock -> dev .bus_id );
941954 return rc ;
942955 }
943956
@@ -974,11 +987,9 @@ static int tifm_sd_probe(struct tifm_dev *sock)
974987
975988 if (!rc )
976989 rc = mmc_add_host (mmc );
977- if (rc )
978- goto out_free_mmc ;
990+ if (! rc )
991+ return 0 ;
979992
980- return 0 ;
981- out_free_mmc :
982993 mmc_free_host (mmc );
983994 return rc ;
984995}
0 commit comments