int s5p_mfc_reset(struct s5p_mfc_dev *dev)
{
	unsigned int mc_status;
	unsigned long timeout;

	mfc_debug_enter();
	
	
	mfc_write(dev, 0x3f6, S5P_FIMV_SW_RESET);
	
	mfc_write(dev, 0x3e2, S5P_FIMV_SW_RESET);
	mdelay(10);

	timeout = jiffies + msecs_to_jiffies(MFC_BW_TIMEOUT);
	
	do {
		if (time_after(jiffies, timeout)) {
			mfc_err("Timeout while resetting MFC\n");
			return -EIO;
		}

		mc_status = mfc_read(dev, S5P_FIMV_MC_STATUS);

	} while (mc_status & 0x3);

	mfc_write(dev, 0x0, S5P_FIMV_SW_RESET);
	mfc_write(dev, 0x3fe, S5P_FIMV_SW_RESET);
	mfc_debug_leave();
	return 0;
}
Пример #2
0
static int s5p_mfc_wait_wakeup(struct s5p_mfc_dev *dev)
{
	int ret;

	/* Send MFC wakeup command */
	ret = s5p_mfc_hw_call(dev->mfc_cmds, wakeup_cmd, dev);
	if (ret) {
		mfc_err("Failed to send command to MFC - timeout\n");
		return ret;
	}

	/* Release reset signal to the RISC */
	if (IS_MFCV6_PLUS(dev)) {
		dev->risc_on = 1;
		mfc_write(dev, 0x1, S5P_FIMV_RISC_ON_V6);
	} else {
		mfc_write(dev, 0x3ff, S5P_FIMV_SW_RESET);
	}

	if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_WAKEUP_RET)) {
		mfc_err("Failed to wakeup MFC\n");
		return -EIO;
	}
	return ret;
}
static inline void s5p_mfc_clear_cmds(struct s5p_mfc_dev *dev)
{
	mfc_write(dev, 0xffffffff, S5P_FIMV_SI_CH0_INST_ID);
	mfc_write(dev, 0xffffffff, S5P_FIMV_SI_CH1_INST_ID);
	mfc_write(dev, 0, S5P_FIMV_RISC2HOST_CMD);
	mfc_write(dev, 0, S5P_FIMV_HOST2RISC_CMD);
}
Пример #4
0
/* Open a new instance and get its number */
static int s5p_mfc_open_inst_cmd_v6(struct s5p_mfc_ctx *ctx)
{
	struct s5p_mfc_dev *dev = ctx->dev;
	struct s5p_mfc_cmd_args h2r_args;
	int codec_type;

	mfc_debug(2, "Requested codec mode: %d\n", ctx->codec_mode);
	dev->curr_ctx = ctx->num;
	switch (ctx->codec_mode) {
	case S5P_MFC_CODEC_H264_DEC:
		codec_type = S5P_FIMV_CODEC_H264_DEC_V6;
		break;
	case S5P_MFC_CODEC_H264_MVC_DEC:
		codec_type = S5P_FIMV_CODEC_H264_MVC_DEC_V6;
		break;
	case S5P_MFC_CODEC_VC1_DEC:
		codec_type = S5P_FIMV_CODEC_VC1_DEC_V6;
		break;
	case S5P_MFC_CODEC_MPEG4_DEC:
		codec_type = S5P_FIMV_CODEC_MPEG4_DEC_V6;
		break;
	case S5P_MFC_CODEC_MPEG2_DEC:
		codec_type = S5P_FIMV_CODEC_MPEG2_DEC_V6;
		break;
	case S5P_MFC_CODEC_H263_DEC:
		codec_type = S5P_FIMV_CODEC_H263_DEC_V6;
		break;
	case S5P_MFC_CODEC_VC1RCV_DEC:
		codec_type = S5P_FIMV_CODEC_VC1RCV_DEC_V6;
		break;
	case S5P_MFC_CODEC_VP8_DEC:
		codec_type = S5P_FIMV_CODEC_VP8_DEC_V6;
		break;
	case S5P_MFC_CODEC_H264_ENC:
		codec_type = S5P_FIMV_CODEC_H264_ENC_V6;
		break;
	case S5P_MFC_CODEC_H264_MVC_ENC:
		codec_type = S5P_FIMV_CODEC_H264_MVC_ENC_V6;
		break;
	case S5P_MFC_CODEC_MPEG4_ENC:
		codec_type = S5P_FIMV_CODEC_MPEG4_ENC_V6;
		break;
	case S5P_MFC_CODEC_H263_ENC:
		codec_type = S5P_FIMV_CODEC_H263_ENC_V6;
		break;
	case S5P_MFC_CODEC_VP8_ENC:
		codec_type = S5P_FIMV_CODEC_VP8_ENC_V7;
		break;
	default:
		codec_type = S5P_FIMV_CODEC_NONE_V6;
	};
	mfc_write(dev, codec_type, S5P_FIMV_CODEC_TYPE_V6);
	mfc_write(dev, ctx->ctx.dma, S5P_FIMV_CONTEXT_MEM_ADDR_V6);
	mfc_write(dev, ctx->ctx.size, S5P_FIMV_CONTEXT_MEM_SIZE_V6);
	mfc_write(dev, 0, S5P_FIMV_D_CRC_CTRL_V6); /* no crc */

	return s5p_mfc_cmd_host2risc_v6(dev, S5P_FIMV_H2R_CMD_OPEN_INSTANCE_V6,
					&h2r_args);
}
Пример #5
0
static int s5p_mfc_sys_init_cmd_v6(struct s5p_mfc_dev *dev)
{
	struct s5p_mfc_cmd_args h2r_args;
	struct s5p_mfc_buf_size_v6 *buf_size = dev->variant->buf_size->priv;

	s5p_mfc_hw_call(dev->mfc_ops, alloc_dev_context_buffer, dev);
	mfc_write(dev, dev->ctx_buf.dma, S5P_FIMV_CONTEXT_MEM_ADDR_V6);
	mfc_write(dev, buf_size->dev_ctx, S5P_FIMV_CONTEXT_MEM_SIZE_V6);
	return s5p_mfc_cmd_host2risc_v6(dev, S5P_FIMV_H2R_CMD_SYS_INIT_V6,
					&h2r_args);
}
Пример #6
0
static inline void s5p_mfc_clear_cmds(struct s5p_mfc_dev *dev)
{
    if (IS_MFCV6_PLUS(dev)) {
        /* Zero initialization should be done before RESET.
         * Nothing to do here. */
    } else {
        mfc_write(dev, 0xffffffff, S5P_FIMV_SI_CH0_INST_ID);
        mfc_write(dev, 0xffffffff, S5P_FIMV_SI_CH1_INST_ID);
        mfc_write(dev, 0, S5P_FIMV_RISC2HOST_CMD);
        mfc_write(dev, 0, S5P_FIMV_HOST2RISC_CMD);
    }
}
Пример #7
0
static inline void s5p_mfc_init_memctrl(struct s5p_mfc_dev *dev)
{
    if (IS_MFCV6_PLUS(dev)) {
        mfc_write(dev, dev->bank1, S5P_FIMV_RISC_BASE_ADDRESS_V6);
        mfc_debug(2, "Base Address : %pad\n", &dev->bank1);
    } else {
        mfc_write(dev, dev->bank1, S5P_FIMV_MC_DRAMBASE_ADR_A);
        mfc_write(dev, dev->bank2, S5P_FIMV_MC_DRAMBASE_ADR_B);
        mfc_debug(2, "Bank1: %pad, Bank2: %pad\n",
                  &dev->bank1, &dev->bank2);
    }
}
Пример #8
0
static int s5p_mfc_cmd_host2risc_v6(struct s5p_mfc_dev *dev, int cmd,
				struct s5p_mfc_cmd_args *args)
{
	mfc_debug(2, "Issue the command: %d\n", cmd);

	/* Reset RISC2HOST command */
	mfc_write(dev, 0x0, S5P_FIMV_RISC2HOST_CMD_V6);

	/* Issue the command */
	mfc_write(dev, cmd, S5P_FIMV_HOST2RISC_CMD_V6);
	mfc_write(dev, 0x1, S5P_FIMV_HOST2RISC_INT_V6);

	return 0;
}
Пример #9
0
static int s5p_mfc_v8_wait_wakeup(struct s5p_mfc_dev *dev)
{
	int ret;

	/* Release reset signal to the RISC */
	dev->risc_on = 1;
	mfc_write(dev, 0x1, S5P_FIMV_RISC_ON_V6);

	if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_FW_STATUS_RET)) {
		mfc_err("Failed to reset MFCV8\n");
		return -EIO;
	}
	mfc_debug(2, "Write command to wakeup MFCV8\n");
	ret = s5p_mfc_hw_call(dev->mfc_cmds, wakeup_cmd, dev);
	if (ret) {
		mfc_err("Failed to send command to MFCV8 - timeout\n");
		return ret;
	}

	if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_WAKEUP_RET)) {
		mfc_err("Failed to wakeup MFC\n");
		return -EIO;
	}
	return ret;
}
Пример #10
0
int s5p_mfc_wakeup(struct s5p_mfc_dev *dev)
{
    int ret;

    mfc_debug_enter();
    /* 0. MFC reset */
    mfc_debug(2, "MFC reset..\n");
    s5p_mfc_clock_on();
    ret = s5p_mfc_reset(dev);
    if (ret) {
        mfc_err("Failed to reset MFC - timeout\n");
        return ret;
    }
    mfc_debug(2, "Done MFC reset..\n");
    /* 1. Set DRAM base Addr */
    s5p_mfc_init_memctrl(dev);
    /* 2. Initialize registers of channel I/F */
    s5p_mfc_clear_cmds(dev);
    s5p_mfc_clean_dev_int_flags(dev);
    /* 3. Initialize firmware */
    ret = s5p_mfc_hw_call(dev->mfc_cmds, wakeup_cmd, dev);
    if (ret) {
        mfc_err("Failed to send command to MFC - timeout\n");
        return ret;
    }
    /* 4. Release reset signal to the RISC */
    if (IS_MFCV6_PLUS(dev))
        mfc_write(dev, 0x1, S5P_FIMV_RISC_ON_V6);
    else
        mfc_write(dev, 0x3ff, S5P_FIMV_SW_RESET);
    mfc_debug(2, "Ok, now will write a command to wakeup the system\n");
    if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_WAKEUP_RET)) {
        mfc_err("Failed to load firmware\n");
        return -EIO;
    }
    s5p_mfc_clock_off();
    dev->int_cond = 0;
    if (dev->int_err != 0 || dev->int_type !=
            S5P_MFC_R2H_CMD_WAKEUP_RET) {
        /* Failure. */
        mfc_err("Failed to wakeup - error: %d int: %d\n", dev->int_err,
                dev->int_type);
        return -EIO;
    }
    mfc_debug_leave();
    return 0;
}
/* Reset the device */
static int s5p_mfc_reset_v6(struct s5p_mfc_dev *dev)
{
	int i;
	mfc_debug_enter();

	/* Zero Initialization of MFC registers */
	mfc_write(dev, 0, S5P_FIMV_RISC2HOST_CMD_V6);
	mfc_write(dev, 0, S5P_FIMV_HOST2RISC_CMD_V6);
	mfc_write(dev, 0, S5P_FIMV_FW_VERSION_V6);

	for (i = 0; i < S5P_FIMV_REG_CLEAR_COUNT_V6; i++)
		mfc_write(dev, 0, S5P_FIMV_REG_CLEAR_BEGIN_V6 + (i*4));

	/* check bus reset control before reset */
	if (dev->risc_on)
		if (s5p_mfc_bus_reset(dev))
			return -EIO;
	/* Reset
	 * set RISC_ON to 0 during power_on & wake_up.
	 * V6 needs RISC_ON set to 0 during reset also.
	 */
	if ((!dev->risc_on) || (!IS_MFCV7(dev)))
		mfc_write(dev, 0, S5P_FIMV_RISC_ON_V6);

	mfc_write(dev, 0x1FFF, S5P_FIMV_MFC_RESET_V6);
	mfc_write(dev, 0, S5P_FIMV_MFC_RESET_V6);

	mfc_debug_leave();
	return 0;
}
static void s5p_mfc_mem_req_enable_v6(struct s5p_mfc_dev *dev)
{
	unsigned int bus_reset_ctrl;
	if (dev->risc_on) {
		bus_reset_ctrl = mfc_read(dev, S5P_FIMV_MFC_BUS_RESET_CTRL);
		bus_reset_ctrl &= S5P_FIMV_MFC_BUS_RESET_CTRL_MASK;
		mfc_write(dev, bus_reset_ctrl, S5P_FIMV_MFC_BUS_RESET_CTRL);
	}
}
Пример #13
0
/* This function is used to send a command to the MFC */
static int s5p_mfc_cmd_host2risc_v5(struct s5p_mfc_dev *dev, int cmd,
				struct s5p_mfc_cmd_args *args)
{
	int cur_cmd;
	unsigned long timeout;

	timeout = jiffies + msecs_to_jiffies(MFC_BW_TIMEOUT);
	/* wait until host to risc command register becomes 'H2R_CMD_EMPTY' */
	do {
		if (time_after(jiffies, timeout)) {
			mfc_err("Timeout while waiting for hardware\n");
			return -EIO;
		}
		cur_cmd = mfc_read(dev, S5P_FIMV_HOST2RISC_CMD);
	} while (cur_cmd != S5P_FIMV_H2R_CMD_EMPTY);
	mfc_write(dev, args->arg[0], S5P_FIMV_HOST2RISC_ARG1);
	mfc_write(dev, args->arg[1], S5P_FIMV_HOST2RISC_ARG2);
	mfc_write(dev, args->arg[2], S5P_FIMV_HOST2RISC_ARG3);
	mfc_write(dev, args->arg[3], S5P_FIMV_HOST2RISC_ARG4);
	/* Issue the command */
	mfc_write(dev, cmd, S5P_FIMV_HOST2RISC_CMD);
	return 0;
}
Пример #14
0
/* Close instance */
static int s5p_mfc_close_inst_cmd_v6(struct s5p_mfc_ctx *ctx)
{
	struct s5p_mfc_dev *dev = ctx->dev;
	struct s5p_mfc_cmd_args h2r_args;
	int ret = 0;

	dev->curr_ctx = ctx->num;
	if (ctx->state != MFCINST_FREE) {
		mfc_write(dev, ctx->inst_no, S5P_FIMV_INSTANCE_ID_V6);
		ret = s5p_mfc_cmd_host2risc_v6(dev,
					S5P_FIMV_H2R_CMD_CLOSE_INSTANCE_V6,
					&h2r_args);
	} else {
		ret = -EINVAL;
	}

	return ret;
}
Пример #15
0
static int s5p_mfc_bus_reset(struct s5p_mfc_dev *dev)
{
	unsigned int status;
	unsigned long timeout;

	/* Reset */
	mfc_write(dev, 0x1, S5P_FIMV_MFC_BUS_RESET_CTRL);
	timeout = jiffies + msecs_to_jiffies(MFC_BW_TIMEOUT);
	/* Check bus status */
	do {
		if (time_after(jiffies, timeout)) {
			mfc_err("Timeout while resetting MFC.\n");
			return -EIO;
		}
		status = mfc_read(dev, S5P_FIMV_MFC_BUS_RESET_CTRL);
	} while ((status & 0x2) == 0);
	return 0;
}
int s5p_mfc_wakeup(struct s5p_mfc_dev *dev)
{
	int ret;

	mfc_debug_enter();
	
	mfc_debug(2, "MFC reset..\n");
	s5p_mfc_clock_on();
	ret = s5p_mfc_reset(dev);
	if (ret) {
		mfc_err("Failed to reset MFC - timeout\n");
		return ret;
	}
	mfc_debug(2, "Done MFC reset..\n");
	
	s5p_mfc_init_memctrl(dev);
	
	s5p_mfc_clear_cmds(dev);
	s5p_mfc_clean_dev_int_flags(dev);
	
	ret = s5p_mfc_wakeup_cmd(dev);
	if (ret) {
		mfc_err("Failed to send command to MFC - timeout\n");
		return ret;
	}
	
	mfc_write(dev, 0x3ff, S5P_FIMV_SW_RESET);
	mfc_debug(2, "Ok, now will write a command to wakeup the system\n");
	if (s5p_mfc_wait_for_done_dev(dev, S5P_FIMV_R2H_CMD_WAKEUP_RET)) {
		mfc_err("Failed to load firmware\n");
		return -EIO;
	}
	s5p_mfc_clock_off();
	dev->int_cond = 0;
	if (dev->int_err != 0 || dev->int_type !=
						S5P_FIMV_R2H_CMD_WAKEUP_RET) {
		
		mfc_err("Failed to wakeup - error: %d int: %d\n", dev->int_err,
								dev->int_type);
		return -EIO;
	}
	mfc_debug_leave();
	return 0;
}
/* Initialize MFC V6 hardware */
static int s5p_mfc_init_hw_v6(struct s5p_mfc_dev *dev)
{
	unsigned int ver;
	int ret;

	mfc_debug_enter();
	ret = s5p_mfc_load_firmware(dev);
	if (ret) {
		mfc_err("Failed to reload FW\n");
		return ret;
	}

	/* 0. MFC reset */
	mfc_debug(2, "MFC reset..\n");
	WARN_ON(dev->risc_on);
	s5p_mfc_clock_on(dev);
	ret = s5p_mfc_ctrl_ops_call(dev, reset, dev);
	if (ret) {
		mfc_err("Failed to reset MFC - timeout\n");
		s5p_mfc_clock_off(dev);
		return ret;
	}
	mfc_debug(2, "Done MFC reset..\n");
	/* 1. Set DRAM base Addr */
	s5p_mfc_init_memctrl_v6(dev);
	/* 2. Release reset signal to the RISC */
	s5p_mfc_clean_dev_int_flags(dev);
	mfc_write(dev, 0x1, S5P_FIMV_RISC_ON_V6);

	ret = s5p_mfc_init_fw(dev);
	if (ret) {
		s5p_mfc_clock_off(dev);
		return ret;
	}

	ver = mfc_read(dev, S5P_FIMV_FW_VERSION_V6);
	mfc_debug(2, "MFC F/W version : %02xyy, %02xmm, %02xdd\n",
		(ver >> 16) & 0xFF, (ver >> 8) & 0xFF, ver & 0xFF);
	s5p_mfc_clock_off(dev);
	dev->risc_on = 1;
	mfc_debug_leave();
	return ret;
}
static inline void s5p_mfc_init_memctrl_v6(struct s5p_mfc_dev *dev)
{
	mfc_write(dev, dev->bank1, S5P_FIMV_RISC_BASE_ADDRESS_V6);
	mfc_debug(2, "Base Address : %08x\n", dev->bank1);
}
int s5p_mfc_init_hw(struct s5p_mfc_dev *dev)
{
	unsigned int ver;
	int ret;

	mfc_debug_enter();
	if (!s5p_mfc_bitproc_buf)
		return -EINVAL;

	
	mfc_debug(2, "MFC reset..\n");
	s5p_mfc_clock_on();
	ret = s5p_mfc_reset(dev);
	if (ret) {
		mfc_err("Failed to reset MFC - timeout\n");
		return ret;
	}
	mfc_debug(2, "Done MFC reset..\n");
	
	s5p_mfc_init_memctrl(dev);
	
	s5p_mfc_clear_cmds(dev);
	
	s5p_mfc_clean_dev_int_flags(dev);
	mfc_write(dev, 0x3ff, S5P_FIMV_SW_RESET);
	mfc_debug(2, "Will now wait for completion of firmware transfer\n");
	if (s5p_mfc_wait_for_done_dev(dev, S5P_FIMV_R2H_CMD_FW_STATUS_RET)) {
		mfc_err("Failed to load firmware\n");
		s5p_mfc_reset(dev);
		s5p_mfc_clock_off();
		return -EIO;
	}
	s5p_mfc_clean_dev_int_flags(dev);
	
	ret = s5p_mfc_sys_init_cmd(dev);
	if (ret) {
		mfc_err("Failed to send command to MFC - timeout\n");
		s5p_mfc_reset(dev);
		s5p_mfc_clock_off();
		return ret;
	}
	mfc_debug(2, "Ok, now will write a command to init the system\n");
	if (s5p_mfc_wait_for_done_dev(dev, S5P_FIMV_R2H_CMD_SYS_INIT_RET)) {
		mfc_err("Failed to load firmware\n");
		s5p_mfc_reset(dev);
		s5p_mfc_clock_off();
		return -EIO;
	}
	dev->int_cond = 0;
	if (dev->int_err != 0 || dev->int_type !=
					S5P_FIMV_R2H_CMD_SYS_INIT_RET) {
		
		mfc_err("Failed to init firmware - error: %d int: %d\n",
						dev->int_err, dev->int_type);
		s5p_mfc_reset(dev);
		s5p_mfc_clock_off();
		return -EIO;
	}
	ver = mfc_read(dev, S5P_FIMV_FW_VERSION);
	mfc_debug(2, "MFC F/W version : %02xyy, %02xmm, %02xdd\n",
		(ver >> 16) & 0xFF, (ver >> 8) & 0xFF, ver & 0xFF);
	s5p_mfc_clock_off();
	mfc_debug_leave();
	return 0;
}
Пример #20
0
/* Reset the device */
int s5p_mfc_reset(struct s5p_mfc_dev *dev)
{
	unsigned int mc_status;
	unsigned long timeout;
	int i;

	mfc_debug_enter();

	if (IS_MFCV6_PLUS(dev)) {
		/* Zero Initialization of MFC registers */
		mfc_write(dev, 0, S5P_FIMV_RISC2HOST_CMD_V6);
		mfc_write(dev, 0, S5P_FIMV_HOST2RISC_CMD_V6);
		mfc_write(dev, 0, S5P_FIMV_FW_VERSION_V6);

		for (i = 0; i < S5P_FIMV_REG_CLEAR_COUNT_V6; i++)
			mfc_write(dev, 0, S5P_FIMV_REG_CLEAR_BEGIN_V6 + (i*4));

		/* check bus reset control before reset */
		if (dev->risc_on)
			if (s5p_mfc_bus_reset(dev))
				return -EIO;
		/* Reset
		 * set RISC_ON to 0 during power_on & wake_up.
		 * V6 needs RISC_ON set to 0 during reset also.
		 */
		if ((!dev->risc_on) || (!IS_MFCV7_PLUS(dev)))
			mfc_write(dev, 0, S5P_FIMV_RISC_ON_V6);

		mfc_write(dev, 0x1FFF, S5P_FIMV_MFC_RESET_V6);
		mfc_write(dev, 0, S5P_FIMV_MFC_RESET_V6);
	} else {
		/* Stop procedure */
		/*  reset RISC */
		mfc_write(dev, 0x3f6, S5P_FIMV_SW_RESET);
		/*  All reset except for MC */
		mfc_write(dev, 0x3e2, S5P_FIMV_SW_RESET);
		mdelay(10);

		timeout = jiffies + msecs_to_jiffies(MFC_BW_TIMEOUT);
		/* Check MC status */
		do {
			if (time_after(jiffies, timeout)) {
				mfc_err("Timeout while resetting MFC\n");
				return -EIO;
			}

			mc_status = mfc_read(dev, S5P_FIMV_MC_STATUS);

		} while (mc_status & 0x3);

		mfc_write(dev, 0x0, S5P_FIMV_SW_RESET);
		mfc_write(dev, 0x3fe, S5P_FIMV_SW_RESET);
	}

	mfc_debug_leave();
	return 0;
}
static inline void s5p_mfc_init_memctrl(struct s5p_mfc_dev *dev)
{
	mfc_write(dev, dev->bank1, S5P_FIMV_MC_DRAMBASE_ADR_A);
	mfc_write(dev, dev->bank2, S5P_FIMV_MC_DRAMBASE_ADR_B);
	mfc_debug(2, "Bank1: %08x, Bank2: %08x\n", dev->bank1, dev->bank2);
}
Пример #22
0
/* Reset the device */
int s5p_mfc_reset(struct s5p_mfc_dev *dev)
{
    unsigned int mc_status;
    unsigned long timeout;
    int i;

    mfc_debug_enter();

    if (IS_MFCV6_PLUS(dev)) {
        /* Reset IP */
        /*  except RISC, reset */
        mfc_write(dev, 0xFEE, S5P_FIMV_MFC_RESET_V6);
        /*  reset release */
        mfc_write(dev, 0x0, S5P_FIMV_MFC_RESET_V6);

        /* Zero Initialization of MFC registers */
        mfc_write(dev, 0, S5P_FIMV_RISC2HOST_CMD_V6);
        mfc_write(dev, 0, S5P_FIMV_HOST2RISC_CMD_V6);
        mfc_write(dev, 0, S5P_FIMV_FW_VERSION_V6);

        for (i = 0; i < S5P_FIMV_REG_CLEAR_COUNT_V6; i++)
            mfc_write(dev, 0, S5P_FIMV_REG_CLEAR_BEGIN_V6 + (i*4));

        /* Reset */
        mfc_write(dev, 0, S5P_FIMV_RISC_ON_V6);
        mfc_write(dev, 0x1FFF, S5P_FIMV_MFC_RESET_V6);
        mfc_write(dev, 0, S5P_FIMV_MFC_RESET_V6);
    } else {
        /* Stop procedure */
        /*  reset RISC */
        mfc_write(dev, 0x3f6, S5P_FIMV_SW_RESET);
        /*  All reset except for MC */
        mfc_write(dev, 0x3e2, S5P_FIMV_SW_RESET);
        mdelay(10);

        timeout = jiffies + msecs_to_jiffies(MFC_BW_TIMEOUT);
        /* Check MC status */
        do {
            if (time_after(jiffies, timeout)) {
                mfc_err("Timeout while resetting MFC\n");
                return -EIO;
            }

            mc_status = mfc_read(dev, S5P_FIMV_MC_STATUS);

        } while (mc_status & 0x3);

        mfc_write(dev, 0x0, S5P_FIMV_SW_RESET);
        mfc_write(dev, 0x3fe, S5P_FIMV_SW_RESET);
    }

    mfc_debug_leave();
    return 0;
}
Пример #23
0
/* Initialize hardware */
int s5p_mfc_init_hw(struct s5p_mfc_dev *dev)
{
    unsigned int ver;
    int ret;

    mfc_debug_enter();
    if (!dev->fw_virt_addr) {
        mfc_err("Firmware memory is not allocated.\n");
        return -EINVAL;
    }

    /* 0. MFC reset */
    mfc_debug(2, "MFC reset..\n");
    s5p_mfc_clock_on();
    ret = s5p_mfc_reset(dev);
    if (ret) {
        mfc_err("Failed to reset MFC - timeout\n");
        return ret;
    }
    mfc_debug(2, "Done MFC reset..\n");
    /* 1. Set DRAM base Addr */
    s5p_mfc_init_memctrl(dev);
    /* 2. Initialize registers of channel I/F */
    s5p_mfc_clear_cmds(dev);
    /* 3. Release reset signal to the RISC */
    s5p_mfc_clean_dev_int_flags(dev);
    if (IS_MFCV6_PLUS(dev))
        mfc_write(dev, 0x1, S5P_FIMV_RISC_ON_V6);
    else
        mfc_write(dev, 0x3ff, S5P_FIMV_SW_RESET);
    mfc_debug(2, "Will now wait for completion of firmware transfer\n");
    if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_FW_STATUS_RET)) {
        mfc_err("Failed to load firmware\n");
        s5p_mfc_reset(dev);
        s5p_mfc_clock_off();
        return -EIO;
    }
    s5p_mfc_clean_dev_int_flags(dev);
    /* 4. Initialize firmware */
    ret = s5p_mfc_hw_call(dev->mfc_cmds, sys_init_cmd, dev);
    if (ret) {
        mfc_err("Failed to send command to MFC - timeout\n");
        s5p_mfc_reset(dev);
        s5p_mfc_clock_off();
        return ret;
    }
    mfc_debug(2, "Ok, now will wait for completion of hardware init\n");
    if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_SYS_INIT_RET)) {
        mfc_err("Failed to init hardware\n");
        s5p_mfc_reset(dev);
        s5p_mfc_clock_off();
        return -EIO;
    }
    dev->int_cond = 0;
    if (dev->int_err != 0 || dev->int_type !=
            S5P_MFC_R2H_CMD_SYS_INIT_RET) {
        /* Failure. */
        mfc_err("Failed to init firmware - error: %d int: %d\n",
                dev->int_err, dev->int_type);
        s5p_mfc_reset(dev);
        s5p_mfc_clock_off();
        return -EIO;
    }
    if (IS_MFCV6_PLUS(dev))
        ver = mfc_read(dev, S5P_FIMV_FW_VERSION_V6);
    else
        ver = mfc_read(dev, S5P_FIMV_FW_VERSION);

    mfc_debug(2, "MFC F/W version : %02xyy, %02xmm, %02xdd\n",
              (ver >> 16) & 0xFF, (ver >> 8) & 0xFF, ver & 0xFF);
    s5p_mfc_clock_off();
    mfc_debug_leave();
    return 0;
}