sd_misc.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #ifndef _H_SD_MISC
  2. #define _H_SD_MISC
  3. #include <linux/types.h>
  4. #include <linux/kernel.h>
  5. #include <linux/err.h>
  6. #include <linux/slab.h>
  7. #include <linux/module.h>
  8. #include <linux/init.h>
  9. #include <linux/delay.h>
  10. #include <linux/io.h>
  11. #include <linux/mii.h>
  12. #include <linux/skbuff.h>
  13. #include <mach/am_regs.h>
  14. #include <mach/irqs.h>
  15. #include <mach/card_io.h>
  16. #include "sd_port.h"
  17. #define sd_get_timer_tick() READ_CBUS_REG(ISA_TIMERE) //unit: 10us or 1/100ms, max: 0 ~ 0xFFFFFF
  18. #define SD_MAX_TIMER_TICK 0xFFFFFF
  19. #define TIMER_1US 1
  20. #define TIMER_10US (10*TIMER_1US)
  21. #define TIMER_1MS (100*TIMER_10US)
  22. void sd_start_timer(unsigned long time_value);
  23. int sd_check_timer(void);
  24. int sd_check_timeout(void);
  25. #define Debug_Printf printk
  26. extern const unsigned short sd_crc_table[];
  27. //#define inline _Inline
  28. #define SD_CAL_BIT_CRC(crc_val,bit_mask_value) {if(crc_val&0x8000){crc_val<<=1;crc_val^=0x1021;}else{crc_val<<=1;};if(bit_mask_value){crc_val^=0x1021;};}
  29. #define WRITE_BYTE_TO_FIFO(DATA) {WRITE_MPEG_REG(HFIFO_DATA,DATA);while((READ_MPEG_REG(BFIFO_LEVEL)>>8) >= 120){}}
  30. #define SD_MMC_HW_CONTROL
  31. #define SD_MMC_SW_CONTROL
  32. #define SD_MMC_ALLOC_MEMORY
  33. /* there is problem if sd dma buffer is allocated by malloc,
  34. so we #undef SD_MMC_ALLOC_MEMORY and define this address in bsp: MEMITEM_CARDREADER_BUF
  35. */
  36. #ifdef SD_MMC_ALLOC_MEMORY
  37. #define sd_mmc_malloc kzalloc
  38. #define sd_mmc_free kfree
  39. #endif /* */
  40. #define SD_MMC_DEBUG
  41. #define SD_MMC_CRC_CHECK
  42. #define sd_delay_us udelay
  43. #define sd_delay_ms msleep
  44. //Delay time in 1 us
  45. //void sd_delay_us(unsigned long num_us);
  46. //Delay time in 1 ms
  47. //void sd_delay_ms(unsigned long num_ms);
  48. //clock low delay in identification mode
  49. #define sd_clk_delay_identify_low() sd_delay_us(3)
  50. //clock high delay in identification mode
  51. #define sd_clk_delay_identify_high() sd_delay_us(3)
  52. //clock low delay in transfer mode
  53. #define sd_clk_delay_tranfer_low()
  54. //clock high delay in transfer mode
  55. #define sd_clk_delay_tranfer_high()
  56. #define sd_clk_identify_high() {sd_set_clk_high();sd_clk_delay_identify_high();}
  57. #define sd_clk_identify_low() {sd_set_clk_low();sd_clk_delay_identify_low();}
  58. #define sd_clk_transfer_high() {sd_set_clk_high();sd_clk_delay_tranfer_high();}
  59. #define sd_clk_transfer_low() {sd_set_clk_low();sd_clk_delay_tranfer_low();}
  60. //calculate Nac cycles in clock
  61. unsigned long sd_cal_clks_nac(unsigned char TAAC, unsigned char NSAC);
  62. unsigned char sd_verify_crc7(unsigned char *ptr, unsigned int len);
  63. unsigned short sd_verify_crc16(unsigned char *ptr, unsigned int len);
  64. unsigned char sd_cal_crc7(unsigned char *ptr, unsigned int len);
  65. unsigned short sd_cal_crc16(unsigned char *ptr, unsigned int len);
  66. unsigned short sd_cal_crc_mode(unsigned char *ptr, unsigned int len,
  67. unsigned char *mode);
  68. #endif //_H_SD_MISC