software/drivers/sd8887/src/bluetooth/bt/bt_main.c
/**
 *  @brief This function read/write firmware via cmd52
 *
 *  @param phandle   A pointer to moal_handle
 *
 *  @return         MLAN_STATUS_SUCCESS
 */
@brief This function read/write firmware via cmd52
@param phandle   A pointer to moal_handle


@brief This function read / write firmware via cmd52 @param phandle A pointer to moal_handle
rdwr_status
bt_cmd52_rdwr_firmware(bt_private *priv, u8 doneflag)
{
	int ret = 0;
	int tries = 0;
	u8 ctrl_data = 0;
	u8 dbg_dump_ctrl_reg = 0;
	dbg_dump_ctrl_reg = DEBUG_DUMP_CTRL_REG;
	ret = sd_write_reg(priv, dbg_dump_ctrl_reg, DEBUG_HOST_READY);
	if (ret) {
		PRINTM(ERROR, "SDIO Write ERR\n");
		return RDWR_STATUS_FAILURE;
	}
	for (tries = 0; tries < DUMP_MAX_POLL_TRIES; tries++) {
		ret = sd_read_reg(priv, dbg_dump_ctrl_reg, &ctrl_data);
		if (ret) {
			PRINTM(ERROR, "SDIO READ ERR\n");
			return RDWR_STATUS_FAILURE;
		}
		if (ctrl_data == DEBUG_FW_DONE)
			break;
		if (doneflag && ctrl_data == doneflag)
			return RDWR_STATUS_DONE;
		if (ctrl_data != DEBUG_HOST_READY) {
			PRINTM(INFO,
			       "The ctrl reg was changed, re-try again!\n");
			ret = sd_write_reg(priv, dbg_dump_ctrl_reg,
					   DEBUG_HOST_READY);
			if (ret) {
				PRINTM(ERROR, "SDIO Write ERR\n");
				return RDWR_STATUS_FAILURE;
			}
		}
		udelay(100);
	}
	if (ctrl_data == DEBUG_HOST_READY) {
		PRINTM(ERROR, "Fail to pull ctrl_data\n");
		return RDWR_STATUS_FAILURE;
	}
	return RDWR_STATUS_SUCCESS;
}
rdwr_status bt_cmd52_rdwr_firmware ( bt_private * priv , u8 doneflag ) { int ret = 0 ; int tries = 0 ; u8 ctrl_data = 0 ; u8 dbg_dump_ctrl_reg = 0 ; dbg_dump_ctrl_reg = DEBUG_DUMP_CTRL_REG ; ret = sd_write_reg ( priv , dbg_dump_ctrl_reg , DEBUG_HOST_READY ) ; if ( ret ) { PRINTM ( ERROR , " \n " ) ; return RDWR_STATUS_FAILURE ; } for ( tries = 0 ; tries < DUMP_MAX_POLL_TRIES ; tries ++ ) { ret = sd_read_reg ( priv , dbg_dump_ctrl_reg , & ctrl_data ) ; if ( ret ) { PRINTM ( ERROR , " \n " ) ; return RDWR_STATUS_FAILURE ; } if ( ctrl_data == DEBUG_FW_DONE ) break ; if ( doneflag && ctrl_data == doneflag ) return RDWR_STATUS_DONE ; if ( ctrl_data != DEBUG_HOST_READY ) { PRINTM ( INFO , " \n " ) ; ret = sd_write_reg ( priv , dbg_dump_ctrl_reg , DEBUG_HOST_READY ) ; if ( ret ) { PRINTM ( ERROR , " \n " ) ; return RDWR_STATUS_FAILURE ; } } udelay ( 100 ) ; } if ( ctrl_data == DEBUG_HOST_READY ) { PRINTM ( ERROR , " \n " ) ; return RDWR_STATUS_FAILURE ; } return RDWR_STATUS_SUCCESS ; }
@brief This function read/write firmware via cmd52
  @param phandle   A pointer to moal_handle
@brief This function read / write firmware via cmd52 @param phandle A pointer to moal_handle