Beispiel #1
0
static void __init evm_init(void)
{
	u8 mux;
	const char *label;
	struct clk *aemif_clk;
	struct davinci_soc_info *soc_info = &davinci_soc_info;

	/* Make sure we can configure the CPLD through CS1.  Then
	 * leave it on for later access to MMC and LED registers.
	 */
	aemif_clk = clk_get(NULL, "aemif");
	if (IS_ERR(aemif_clk))
		return;
	clk_enable(aemif_clk);

	if (request_mem_region(DM365_ASYNC_EMIF_DATA_CE0_BASE, SECTION_SIZE,
			"fpga") == NULL)
		goto fail;
	fpga = ioremap(DM365_ASYNC_EMIF_DATA_CE0_BASE, SECTION_SIZE);

	if (!fpga) {
		release_mem_region(DM365_ASYNC_EMIF_DATA_CE0_BASE,
				SECTION_SIZE);
fail:
		pr_err("ERROR: can't map CPLD\n");
		clk_disable(aemif_clk);
		return;
	}

	/* External muxing for some signals */
	mux = 0;

	/* Read CPLD version number */
	//soc_info->cpld_version = __raw_readb(cpld + CPLD_VERSION);
	soc_info->cpld_version = 0x21;//for lena,this is init by ourself,please refer to cputype.h

      if(device_lena_air_id == LENA_AIR){

		if (have_adv7611()) {
			mux |= VIDEO_INPUT_MUX_ADV7611;
			label = "ADV7611 HD";
		} else if (have_tvp5150()){
			/* default to tvp5146 */
			mux |= VIDEO_INPUT_MUX_TVP5150;
			label = "tvp5150 SD";
			dm365evm_reset_imager(0);
		}
	}

	pr_info("EVM: %s video input\n", label);

}
 /* Set the input mux for TVP7002/TVP5146/MTxxxx sensors */
static int dm365evm_setup_video_input(enum vpfe_subdev_id id)
{
	const char *label;
	u8 mux, resets;
	mux = __raw_readb(cpld + CPLD_MUX);
	mux &= ~CPLD_VIDEO_INPUT_MUX_MASK;
	resets = __raw_readb(cpld + CPLD_RESETS);
	switch (id) {
	case VPFE_SUBDEV_TVP5146:
		mux |= CPLD_VIDEO_INPUT_MUX_TVP5146;
		resets &= ~BIT(0);
		label = "tvp5146 SD";
		dm365evm_reset_imager(0);
		break;
	case VPFE_SUBDEV_MT9P031:
		mux |= CPLD_VIDEO_INPUT_MUX_IMAGER;
		resets |= BIT(0); /* Put TVP5146 in reset */
		label = "HD imager";

		dm365evm_reset_imager(1);
		/* Switch on pca9543a i2c switch */
		if (have_imager())
			dm365evm_enable_pca9543a(1);
		break;
	case VPFE_SUBDEV_TVP7002:
		resets &= ~BIT(2);
		mux |= CPLD_VIDEO_INPUT_MUX_TVP7002;
		label = "tvp7002 HD";
		break;
	default:
		return 0;
	}
	__raw_writeb(mux, cpld + CPLD_MUX);
	__raw_writeb(resets, cpld + CPLD_RESETS);

	pr_info("EVM: switch to %s video input\n", label);
	return 0;
}