Changeset 76 for trunk/hal/x86_64/drivers/soclib_mmc.c
- Timestamp:
- Jun 27, 2017, 2:07:55 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/x86_64/drivers/soclib_mmc.c
r75 r76 31 31 #include <printk.h> 32 32 33 34 ///////////////////////////////////////35 33 void soclib_mmc_init( chdev_t * chdev ) 36 34 { 37 // get pointer on MMC segment base38 uint32_t * base = (uint32_t *)GET_PTR( chdev->base );39 35 40 // enable MMC IRQ41 *(base + (SOCLIB_MMC_ERROR_FUNC << 7) + SOCLIB_MMC_ERROR_IRQ_ENABLE) = 1;42 36 } 43 37 44 45 //////////////////////////////////////////////////////////////46 38 void __attribute__ ((noinline)) soclib_mmc_cmd( xptr_t th_xp ) 47 39 { 48 xptr_t dev_xp; // extended pointer on MMC device49 uint32_t type; // MMC command : type50 uint64_t buf_paddr; // MMC command : buffer physical address51 uint32_t buf_size; // MMC command : buffer size52 uint32_t reg_index; // MMC command : register index in MMC peripheral53 uint32_t * reg_ptr; // MMC command : pointer on dst/src buffer in client cluster54 40 55 // get client thread cluster and local pointer 56 cxy_t th_cxy = GET_CXY( th_xp ); 57 thread_t * th_ptr = (thread_t *)GET_PTR( th_xp ); 41 } 58 42 59 // get command type and extended pointer on MMC device60 type = hal_remote_lw ( XPTR( th_cxy , &th_ptr->command.mmc.type ) );61 dev_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr->command.mmc.dev_xp ) );62 63 // get MMC device cluster and local pointer64 cxy_t dev_cxy = GET_CXY( dev_xp );65 chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );66 67 // get extended pointer on SOCLIB-MMC peripheral68 xptr_t mmc_xp = hal_remote_lw( XPTR( dev_cxy , &dev_ptr->base ) );69 70 // get SOCLIB_MMC peripheral cluster and local pointer71 cxy_t mmc_cxy = GET_CXY( mmc_xp );72 uint32_t * mmc_ptr = (uint32_t *)GET_PTR( mmc_xp );73 74 if( (type == MMC_CC_INVAL) || (type == MMC_CC_SYNC) )75 {76 // get buffer paddr77 buf_paddr = hal_remote_lwd( XPTR( th_cxy , &th_ptr->command.mmc.buf_paddr ) );78 79 // split buffer paddr in two 32 bits words80 uint32_t buf_lo = (uint32_t)( buf_paddr );81 uint32_t buf_hi = (uint32_t)( buf_paddr>>32 );82 83 // get buffer size84 buf_size = hal_remote_lw( XPTR( th_cxy , &th_ptr->command.mmc.buf_size ) );85 86 // get command type87 uint32_t cc_cmd;88 if( type == MMC_CC_INVAL ) cc_cmd = SOCLIB_MMC_CC_INVAL;89 else cc_cmd = SOCLIB_MMC_CC_SYNC;90 91 // set SOCLIB_MMC registers to start INVAL/SYNC operation92 hal_remote_sw( XPTR( mmc_cxy , mmc_ptr + SOCLIB_MMC_ADDR_LO ) , buf_lo );93 hal_remote_sw( XPTR( mmc_cxy , mmc_ptr + SOCLIB_MMC_ADDR_HI ) , buf_hi );94 hal_remote_sw( XPTR( mmc_cxy , mmc_ptr + SOCLIB_MMC_BUF_LENGTH ) , buf_size );95 hal_remote_sw( XPTR( mmc_cxy , mmc_ptr + SOCLIB_MMC_CMD_TYPE ) , cc_cmd );96 }97 else // (type == MMC_GET_ERROR) or (type == MMC_GET_ERROR) pr (type == MMC_GET_INSTRU )98 {99 // get src/dst buffer local pointer and register index100 reg_ptr = (uint32_t *)hal_remote_lpt( XPTR( th_cxy , &th_ptr->command.mmc.reg_ptr ) );101 reg_index = hal_remote_lw( XPTR( th_cxy , &th_ptr->command.mmc.reg_index ) );102 103 // move register to/from local buffer104 if( (type == MMC_GET_ERROR) || (type == MMC_GET_INSTRU) )105 {106 *reg_ptr = hal_remote_lw( XPTR( mmc_cxy , mmc_ptr + reg_index ) );107 }108 else // type == MMC_SET_ERROR109 {110 hal_remote_sw( XPTR( mmc_cxy , mmc_ptr + reg_index ) , *reg_ptr );111 }112 }113 } // end soclib_mmc_cmd()114 115 116 ////////////////////////////////////////////////////////////////117 43 void __attribute__ ((noinline)) soclib_mmc_isr( chdev_t * chdev ) 118 44 { 119 // get pointer on MMC segment base120 uint32_t * base = (uint32_t *)GET_PTR( chdev->base );121 45 122 // get faulty ADDRESS and SRCID from MMC registers 123 uint32_t paddr_lo = *(base + (SOCLIB_MMC_ERROR_FUNC << 7) + SOCLIB_MMC_ERROR_ADDR_LO); 124 uint32_t paddr_hi = *(base + (SOCLIB_MMC_ERROR_FUNC << 7) + SOCLIB_MMC_ERROR_ADDR_HI); 125 uint32_t srcid = *(base + (SOCLIB_MMC_ERROR_FUNC << 7) + SOCLIB_MMC_ERROR_SRCID); 46 } 126 47 127 paddr_t paddr = (((paddr_t)paddr_hi)<<32) + ((paddr_t)paddr_lo);128 129 // reset MMC IRQ130 *(base + (SOCLIB_MMC_ERROR_FUNC << 7) + SOCLIB_MMC_ERROR_IRQ_RESET) = 0;131 132 // print an error message on kernel terminal TODO : should be improved133 printk("\n[ERROR] reported from MMC in cluster %x : faulty address = %l / srcid = %x\n",134 paddr , srcid );135 136 } // end soclib_mmc_isr()137 138 139
Note: See TracChangeset
for help on using the changeset viewer.