Ejemplo n.º 1
0
/**
* @brief 	SD driver initial function.
* @return 	SUCCESS/ERROR_ID.
*/
static int __init gp_sdcard_init(void)
{
	int i;
	/* ----- Get registered. ----- */
	sd_major = register_blkdev(sd_major, "sdcard");
	if (sd_major <= 0) 
	{
		DERROR(KERN_WARNING "SD card : unable to get major number\n");
		return -EBUSY;
	}
	/* ----- Allocate the device array, and initialize each one. ----- */
	sd_info = kmalloc(SD_NUM*sizeof (gpSDInfo_t), GFP_KERNEL);
	if (sd_info == NULL)
		goto out_unregister;
	/* ----- Initial SD information ----- */
	for(i=0; i<SD_NUM; i++)
	{
		gpSDInfo_t *sd = &sd_info[i];
		/* ----- Clear memory ----- */
		memset (sd, 0, sizeof (gpSDInfo_t));
		sd->device_id = i;
		/* ----- Initial spinlock ----- */
		spin_lock_init(&sd->lock);
		spin_lock_init(&sd->hal_lock);
		/* ----- Initial work queue ----- */
		INIT_WORK(&sd->init, gp_sdcard_work_init);
		INIT_WORK(&sd->uninit, gp_sdcard_work_uninit);
		if(i==0)
		{
			/* ----- request IO function ----- */
			sd->sd_func = gp_board_get_config("sd0",gp_board_sd_t);
			/* ----- Initial dma module ----- */
			sd->dma_param.module = SD0;
		}
		else
		{
			/* ----- request IO function ----- */
			sd->sd_func = gp_board_get_config("sd1",gp_board_sd_t);
			/* ----- Initial dma module ----- */
			sd->dma_param.module = SD1;
		}
		/* ----- Init timer ----- */
		init_timer(&sd->timer);
		sd->timer.data = (unsigned long) sd;
		sd->timer.function = gp_sdcard_timer_fn;
		sd->timer.expires = jiffies + SD_CD_POLL;
		add_timer(&sd->timer);
	}
	gp_sdio_init();
	return 0;
out_unregister:
	unregister_blkdev(sd_major, "sdcard");
	return -ENOMEM;
}
Ejemplo n.º 2
0
static UINT8 USB_HOST_DET()
{
	gp_board_audio_t *pSystem = gp_board_get_config("audio_out", gp_board_audio_t);
	if(pSystem && pSystem->get_headphone_detect)	
	{
		 	 return pSystem->get_headphone_detect();
	}
	else
	{
		return 0;
	}	
	
}
Ejemplo n.º 3
0
void wifiPowerOn(int enable)
{
#if 0
	UINT32	gpio_info;

	/* WiFi_PWR_ON : B_KEYSCAN1 */
	gpio_info = 0;	/*GPIO0*/
	gpio_info <<= 8;
	gpio_info |= 0;	/* Function : 0 */
	gpio_info <<= 8;
	gpio_info |= 19;	/* GID : 19 */
	gpio_info <<= 8;
	gpio_info |= 1;	/* Pin */
	gpHalGpioSetPadGrp( gpio_info );
	gpHalGpioSetDirection( gpio_info, 0 );
	gpHalGpioSetValue( gpio_info,enable?1:0 );
#else
	UINT32	gpio_info;
	gp_board_sd_t *sdio_power;

	sdio_power = gp_board_get_config("sd1", gp_board_sd_t );
	sdio_power->set_power(enable);
#endif
}
Ejemplo n.º 4
0
static UINT32
displayInit(
	void
)
{
	int dispDev;
	int outputCnt;
	int res_ptr;
	int pllsel;
	int showbg;
	
	if(strcmp(SYSCONFIG_PLATFORM, "gplus.cvr_turnkey_evm") == 0 ||
		strcmp(SYSCONFIG_PLATFORM, "gplus.cvr_turnkey_demo0") == 0 ||
		strcmp(SYSCONFIG_PLATFORM, "gplus.cvr_turnkey_demo1") == 0 ) {
		pllsel = 2;
		showbg = 0;
	} else {
		pllsel = 0;
		showbg = 1;		
	}

#ifdef SYSCONFIG_DISP0
	outputCnt = 0;
	/* install display module */
	if(pllsel == 0) {
		if (insmod("gp_display pll_sel=\"%s\"", "PLL0") != SP_OK) {
			DIAG_ERROR("insmod display error!\n");
			return SP_FAIL;
		}
	} else if(pllsel == 2) {
		if (insmod("gp_display pll_sel=\"%s\"", "PLL2") != SP_OK) {
			DIAG_ERROR("insmod display error!\n");
			return SP_FAIL;
		}
	}
	sysMknod("disp0", S_IFCHR);	

	/* install panel module */
	if ((strcmp(SYSCONFIG_DISP0_PANEL, "None") != 0) && (insmod("/lib/modules/common/%s.ko", SYSCONFIG_DISP0_PANEL) == SP_OK)) {
		outputCnt ++;
	}

	/* install tv module */
	#ifdef SYSCONFIG_DISP0_TVOUT
	if( gp_ver.major == MACH_GPL32900 ) {
		if (insmod("tv_ntsc") == SP_OK) {
			outputCnt ++;
		}
	}
	
	if( gp_ver.major == MACH_GPL32900B ) {
		if (insmod("gp_tv") == SP_OK) {
			outputCnt ++;
		}	
	}
	#endif

	#ifdef SYSCONFIG_DISP0_HDMI
	if(pllsel == 0) {
		if (insmod("gp_hdmi pll_sel=\"%s\"", "PLL0") == SP_OK)
			outputCnt ++;
	} else if(pllsel == 2) {
		if (insmod("gp_hdmi pll_sel=\"%s\"", "PLL2") == SP_OK)
			outputCnt ++;		
	}
	#endif

	if (!outputCnt) {
		DIAG_ERROR("Error!! No output device of display installed!\n");
		return SP_FAIL;
	}
if(showbg) {
	/* Initial display device */
	dispDev = open("/dev/disp0",O_RDWR);
	if(dispDev < 0) {
		DIAG_ERROR("Error!! open /dev/disp0/\n");
		return SP_FAIL;
	}

	ioctl(dispDev, DISPIO_SET_INITIAL, NULL);
	
	/* Download Display Gamma Curve */
	res_ptr = open( PATH_GAMMA,O_RDONLY);
	if(res_ptr < 0) {
		DIAG_ERROR("Error!! can't ");
		DIAG_ERROR(PATH_GAMMA);
		DIAG_ERROR("\n");
	}
	else {
		gp_disp_gammatable_t	pGammaTable_R;
		gp_disp_gammatable_t	pGammaTable_G;
		gp_disp_gammatable_t	pGammaTable_B;
		
		pGammaTable_R.id = SP_DISP_GAMMA_R;
		read( res_ptr, pGammaTable_R.table, 256 );
		pGammaTable_G.id = SP_DISP_GAMMA_G;
		read( res_ptr, pGammaTable_G.table, 256 );
		pGammaTable_B.id = SP_DISP_GAMMA_B;
		read( res_ptr, pGammaTable_B.table, 256 );

		ioctl(dispDev, DISPIO_SET_GAMMA_ENABLE, 0 );
		ioctl(dispDev, DISPIO_SET_GAMMA_PARAM, &pGammaTable_R );
		ioctl(dispDev, DISPIO_SET_GAMMA_PARAM, &pGammaTable_G );
		ioctl(dispDev, DISPIO_SET_GAMMA_PARAM, &pGammaTable_B );
		ioctl(dispDev, DISPIO_SET_GAMMA_ENABLE, 1 );
		close(res_ptr);
	}

	/* Download Display Color Matrix */
	res_ptr = open( PATH_COLOR, O_RDONLY);
	if(res_ptr < 0) {
		DIAG_ERROR("Error!! can't ");
		DIAG_ERROR(PATH_COLOR);
		DIAG_ERROR("\n");
	}
	else {
		gp_disp_colormatrix_t	colorMatrix;
		uint32_t	parameter;
		
		read( res_ptr, &parameter, sizeof(uint32_t));
		colorMatrix.a00 = (uint16_t) parameter;
		read( res_ptr, &parameter, sizeof(uint32_t));
		colorMatrix.a01 = (uint16_t) parameter;
		read( res_ptr, &parameter, sizeof(uint32_t));
		colorMatrix.a02 = (uint16_t) parameter;
		read( res_ptr, &parameter, sizeof(uint32_t));
		colorMatrix.a10 = (uint16_t) parameter;
		read( res_ptr, &parameter, sizeof(uint32_t));
		colorMatrix.a11 = (uint16_t) parameter;
		read( res_ptr, &parameter, sizeof(uint32_t));
		colorMatrix.a12 = (uint16_t) parameter;
		read( res_ptr, &parameter, sizeof(uint32_t));
		colorMatrix.a20 = (uint16_t) parameter;
		read( res_ptr, &parameter, sizeof(uint32_t));
		colorMatrix.a21 = (uint16_t) parameter;
		read( res_ptr, &parameter, sizeof(uint32_t));
		colorMatrix.a22 = (uint16_t) parameter;
		read( res_ptr, &parameter, sizeof(uint32_t));
		colorMatrix.b0 = (uint16_t) parameter;
		read( res_ptr, &parameter, sizeof(uint32_t));
		colorMatrix.b1 = (uint16_t) parameter;
		read( res_ptr, &parameter, sizeof(uint32_t));
		colorMatrix.b2 = (uint16_t) parameter;
			
		ioctl(dispDev, DISPIO_SET_CMATRIX_PARAM, &colorMatrix );
		close(res_ptr);
	}	
	
	close(dispDev);
}
	#ifdef SYSCONFIG_DISP0_FB
		#ifdef SYSCONFIG_FB_PARAMETER
		if (insmod("gp_fb fbparam=\"%s\"", SYSCONFIG_FB_PARAMETER) != SP_OK) {
		#else
		if (insmod("gp_fb main_disp=\"%s\"", SYSCONFIG_DISP0_PANEL) != SP_OK) {
		#endif
			DIAG_ERROR("insmod fb fail\n");
			return SP_FAIL;
		}
	#endif
#endif

#ifdef SYSCONFIG_DISP1
	outputCnt = 0;
	/* install display1 module */
	if (insmod("gp_display1") != SP_OK) {
		DIAG_ERROR("insmod display1 error!\n");
		return SP_FAIL;
	}
	sysMknod("disp1", S_IFCHR);

	/* install panel module */
	if ((strcmp(SYSCONFIG_DISP1_PANEL, "None") != 0) && (insmod("/lib/modules/common/%s.ko", SYSCONFIG_DISP1_PANEL) == SP_OK)) {
		outputCnt ++;
	}

	if (!outputCnt) {
		DIAG_ERROR("Error!! No output device of display1 installed!\n");
		return SP_FAIL;
	}

	/* Initial display1 device */
	dispDev = open("/dev/disp1",O_RDWR);
	if(dispDev < 0) {
		DIAG_ERROR("Error!! open /dev/disp0/\n");
		return SP_FAIL;
	}

	ioctl(dispDev, DISPIO_SET_INITIAL, NULL);
	close(dispDev);

	#ifdef SYSCONFIG_DISP1_FB
		if (insmod("gp_fb1") != SP_OK) {
			DIAG_ERROR("insmod fb1 fail\n");
			return SP_FAIL;
		}
	#endif
#endif

#ifdef SYSCONFIG_DISP2
	outputCnt = 0;
	/* install display module */
	if (insmod("gp_display2") != SP_OK) {
		DIAG_ERROR("insmod display2 error!\n");
		return SP_FAIL;
	}
	sysMknod("disp2", S_IFCHR);	

	/* install tv module */
	if (insmod("tv1") == SP_OK) {
		outputCnt ++;
	}

	if (!outputCnt) {
		DIAG_ERROR("Error!! No output device of display2 installed!\n");
		return SP_FAIL;
	}

	/* Initial display device */
	dispDev = open("/dev/disp2",O_RDWR);
	if(dispDev < 0) {
		DIAG_ERROR("Error!! open /dev/disp2/\n");
		return SP_FAIL;
	}

	ioctl(dispDev, DISPIO_SET_INITIAL, NULL);
	close(dispDev);

	#ifdef SYSCONFIG_DISP2_FB
		if (insmod("gp_fb2") != SP_OK) {
			DIAG_ERROR("insmod fb2 fail\n");
			return SP_FAIL;
		}
	#endif
#endif

	return SP_OK;
}

static UINT32
backlightEnable(
	UINT32 en
)
{
	gp_board_panel_t *panel_config;
	panel_config = gp_board_get_config("panel", gp_board_panel_t);
	if (panel_config != NULL && panel_config->set_backlight != NULL) {
		panel_config->set_backlight(en);
	}
	else {
		return SP_FAIL;
	}

	return SP_OK;
}
Ejemplo n.º 5
0
void spmp_initial_sdio_gpio()
{
#if 0   
	UINT32	gpio_info;

	/* USB Host Power Enable : B_NAND15 */
	gpio_info = 0;	/*GPIO0*/
	gpio_info <<= 8;
	gpio_info |= 2;	/* Function : 2*/
	gpio_info <<= 8;
	gpio_info |= 27;	/* GID : 27 */
	gpio_info <<= 8;
	gpio_info |= 21;	/* Pin */
	gpHalGpioSetPadGrp( gpio_info );
	gpHalGpioSetDirection( gpio_info, 0 );
	gpHalGpioSetValue( gpio_info,1 );

       //mdelay(100);
        /*power off*/
	/* WiFi_PWR_ON : B_KEYSCAN1 */
	gpio_info = 0;	/*GPIO0*/
	gpio_info <<= 8;
	gpio_info |= 0;	/* Function : 0 */
	gpio_info <<= 8;
	gpio_info |= 19;	/* GID : 19 */
	gpio_info <<= 8;
	gpio_info |= 1;	/* Pin */
	gpHalGpioSetPadGrp( gpio_info );
	gpHalGpioSetDirection( gpio_info, 0 );
	gpHalGpioSetValue( gpio_info,0 );

      /*disable wlan(high)*/
	/* WL_EN : B_SD_CARD1 */
	gpio_info = 0;	/*GPIO0*/
	gpio_info <<= 8;
	gpio_info |= 2;	/* Function : 2 */
	gpio_info <<= 8;
	gpio_info |= 30;	/* GID : 30 */
	gpio_info <<= 8;
	gpio_info |= 24;	/* Pin */
	gpHalGpioSetPadGrp( gpio_info );
	gpHalGpioSetDirection( gpio_info, 0 );
	gpHalGpioSetValue( gpio_info,1 );

      /*not reset(low)*/
	/* WL_REG_ON : B_SD_CARD3 */
	gpio_info = 0;	/*GPIO0*/
	gpio_info <<= 8;
	gpio_info |= 2;	/* Function : 2 */
	gpio_info <<= 8;
	gpio_info |= 34;	/* GID : 34 */
	gpio_info <<= 8;
	gpio_info |= 26;	/* Pin */
	gpHalGpioSetPadGrp( gpio_info );
	gpHalGpioSetDirection( gpio_info, 0 );
	gpHalGpioSetValue( gpio_info,0 );
        mdelay(200);

        /*power on*/
	/* WiFi_PWR_ON : B_KEYSCAN1 */
	gpio_info = 0;	/*GPIO0*/
	gpio_info <<= 8;
	gpio_info |= 0;	/* Function : 0 */
	gpio_info <<= 8;
	gpio_info |= 19;	/* GID : 19 */
	gpio_info <<= 8;
	gpio_info |= 1;	/* Pin */
	gpHalGpioSetPadGrp( gpio_info );
	gpHalGpioSetDirection( gpio_info, 0 );
	gpHalGpioSetValue( gpio_info,1);
        //mdelay(200);

        /*wlan enable(low)*/
	/* WL_EN : B_SD_CARD1 */
	gpio_info = 0;	/*GPIO0*/
	gpio_info <<= 8;
	gpio_info |= 2;	/* Function : 2 */
	gpio_info <<= 8;
	gpio_info |= 30;	/* GID : 30 */
	gpio_info <<= 8;
	gpio_info |= 24;	/* Pin */
	gpHalGpioSetPadGrp( gpio_info );
	gpHalGpioSetDirection( gpio_info, 0 );
	gpHalGpioSetValue( gpio_info,1 );
        //mdelay(200);

	/* Switch SDIO Function : B_KEYSCAN_2 */
	gpio_info = 0;	/*GPIO0*/
	gpio_info <<= 8;
	gpio_info |= 2;	/* Function : 2 */
	gpio_info <<= 8;
	gpio_info |= 20;	/* GID : 20 */
	gpio_info <<= 8;
	gpio_info |= 2;	/* Pin 2 */
	gpHalGpioSetPadGrp( gpio_info );

	/* Switch SDIO Function : B_KEYSCAN_3 */
	gpio_info = 0;	/*GPIO0*/
	gpio_info <<= 8;
	gpio_info |= 2;	/* Function : 2 */
	gpio_info <<= 8;
	gpio_info |= 21;	/* GID : 21 */
	gpio_info <<= 8;
	gpio_info |= 3;	/* Pin 3 */
	gpHalGpioSetPadGrp( gpio_info );

	/* Switch SDIO Function : B_KEYSCAN_4/5 */
	gpio_info = 0;	/*GPIO0*/
	gpio_info <<= 8;
	gpio_info |= 2;	/* Function : 2 */
	gpio_info <<= 8;
	gpio_info |= 22;	/* GID : 22 */
	gpio_info <<= 8;
	gpio_info |= 4;	/* Pin 4 */
	gpHalGpioSetPadGrp( gpio_info );

	/* Switch SDIO Function : B_KEYSCAN_6 */
	gpio_info = 0;	/*GPIO0*/
	gpio_info <<= 8;
	gpio_info |= 2;	/* Function : 2 */
	gpio_info <<= 8;
	gpio_info |= 23;	/* GID : 23 */
	gpio_info <<= 8;
	gpio_info |= 6;	/* Pin 6 */
	gpHalGpioSetPadGrp( gpio_info );

	/* Switch SDIO Function : B_KEYSCAN_7 */
	gpio_info = 0;	/*GPIO0*/
	gpio_info <<= 8;
	gpio_info |= 2;	/* Function : 2 */
	gpio_info <<= 8;
	gpio_info |= 24;	/* GID : 24 */
	gpio_info <<= 8;
	gpio_info |= 7;	/* Pin 7 */
	gpHalGpioSetPadGrp( gpio_info );
#else
	gp_board_sd_t *sdio_power;

	sdio_power = gp_board_get_config("sd0", gp_board_sd_t );

	if ( sdio_power->get_func() != 1 ) {		/* 0: SD, 1: SDIO, 0xff: no used */
		sdio_power = gp_board_get_config("sd1", gp_board_sd_t );
	}

	//sdio_power->set_standby(1);		/* 0: Normal, 1: Standby */
	//sdio_power->set_power(0);
	mdelay(200);
	
	sdio_power->set_standby(0);		/* 0: Normal, 1: Standby */
	sdio_power->set_power(1);
	sdio_power->set_io( 2, 0 );			/* SD I/F 0: output, 1: input, 2: sd/sdio */
	mdelay(200);
#endif
	spmp_regdev_sd1();

}
static int32_t
lcd_resume(
	void
)
{
	int32_t real_freq = 0;
	gp_board_panel_t *lcd_power;
	int handle;
	gpio_content_t ctx;

	printk("[%s:%d]\n", __FUNCTION__, __LINE__);

	lcd_power = gp_board_get_config("panel", gp_board_panel_t);

	gpHalDispSetDevType(HAL_DISP_DEV_LCD);

	// set lcd source : XTAL(27MHZ)
	gpHalClkLcdSetSrc(HAL_LCD_CLK_XTAL);
	// Set lcd clock rate, must enable before lcd clk on
	gp_clk_set_rate("clk_lcd", gPanelInfo.workFreq, &real_freq, NULL);	

	gpHalDispSetClkType(gPanelInfo.clkType);

#ifdef CONFIG_PM
	gp_enable_clock((int*)"READLTIME_ABT", 1);
#endif
	gpHalLcdClkEnable(1);		

	gpHalDispSetRes(gPanelInfo.width, gPanelInfo.height);
	gpHalDispSetLcdVsync(gPanelInfo.vsync);
	gpHalDispSetLcdHsync(gPanelInfo.hsync);
	gpHalDispSetPanelFormat(gPanelInfo.format, gPanelInfo.type, gPanelInfo.dataSeqEven, gPanelInfo.dataSeqOdd);
	gpHalDispSetClkPolarity(gPanelInfo.clkPolatiry);

	lcd_power->set_panelpowerOn0(1);		/* Power on VCC, VGL, AVDD, VGH */

	ctx.pin_index = MK_GPIO_INDEX( PCLK_channel, PCLK_func, PCLK_gid, PCLK_pin );
	handle = gp_gpio_request( ctx.pin_index, NULL );
	gp_gpio_set_function( handle, PCLK_func );	
	gp_gpio_release( handle );

	ctx.pin_index = MK_GPIO_INDEX( B_DATA_channel, B_DATA_func, B_DATA_gid, B_DATA_pin );
	handle = gp_gpio_request( ctx.pin_index, NULL );
	gp_gpio_set_function( handle, B_DATA_func );	
	gp_gpio_release( handle );

	ctx.pin_index = MK_GPIO_INDEX( G_DATA_channel, G_DATA_func, G_DATA_gid, G_DATA_pin );
	handle = gp_gpio_request( ctx.pin_index, NULL );
	gp_gpio_set_function( handle, G_DATA_func );	
	gp_gpio_release( handle );
	
	ctx.pin_index = MK_GPIO_INDEX( R_DATA_channel, R_DATA_func, R_DATA_gid, R_DATA_pin );
	handle = gp_gpio_request( ctx.pin_index, NULL );
	gp_gpio_set_function( handle, R_DATA_func );	
	gp_gpio_release( handle );

	lcd_power->set_panelpowerOn1(1);		/* Set LCD RESET to high */

	/* Set dither */
	disp_set_dither_type(gPanelInfo.ditherType);
	disp_set_dither_param(gPanelInfo.pDitherParam);
	disp_set_dither_enable(1);

	/* Set color matrix */
	disp_set_color_matrix(gPanelInfo.pColorMatrix);

	/* Set gamma table */
	disp_set_gamma_enable(0);
	disp_set_gamma_table(SP_DISP_GAMMA_R, (uint8_t*) gPanelInfo.pGammaTable[SP_DISP_GAMMA_R]);
	disp_set_gamma_table(SP_DISP_GAMMA_G, (uint8_t*) gPanelInfo.pGammaTable[SP_DISP_GAMMA_G]);
	disp_set_gamma_table(SP_DISP_GAMMA_B, (uint8_t*) gPanelInfo.pGammaTable[SP_DISP_GAMMA_B]);
	disp_set_gamma_enable(1);

	gpHalDispSetPriDmaType(gPanelInfo.dmaType);
	gpHalDispSetOsdDmaType(0, gPanelInfo.dmaType);
	gpHalDispSetOsdDmaType(1, gPanelInfo.dmaType);

	return 0;
}
static int32_t
lcd_suspend(
	void
)
{
	uint8_t	white_gamma[256];
	uint16_t	i;
	gp_board_panel_t *lcd_power;
	int handle;
	gpio_content_t ctx;

	printk("[%s:%d]\n", __FUNCTION__, __LINE__);

	lcd_power = gp_board_get_config("panel", gp_board_panel_t);

	/* Set dither */
	//disp_set_dither_type(gPanelInfo.ditherType);
	//disp_set_dither_param(gPanelInfo.pDitherParam);
	//disp_set_dither_enable(1);

	/* Set color matrix */
	//disp_set_color_matrix(gPanelInfo.pColorMatrix);

	/* Set white gamma table */
	for ( i = 0 ; i < 256 ; i++ ) {
		white_gamma[i] = 0xff;
	}
	disp_set_gamma_enable(0);
	disp_set_gamma_table(SP_DISP_GAMMA_R, (uint8_t*) white_gamma);
	disp_set_gamma_table(SP_DISP_GAMMA_G, (uint8_t*) white_gamma);
	disp_set_gamma_table(SP_DISP_GAMMA_B, (uint8_t*) white_gamma);
	disp_set_gamma_enable(1);

	//msleep(60);
	disp_wait_frame_end();
	disp_wait_frame_end();
	//LCD_RST to Low
	lcd_power->set_panelpowerOn1(0);

// Disable LCD bus
	ctx.pin_index = MK_GPIO_INDEX( PCLK_channel, PCLK_GPIO, PCLK_gid, PCLK_pin );
	handle = gp_gpio_request( ctx.pin_index, NULL );
	gp_gpio_set_function( handle, PCLK_GPIO );	
	gp_gpio_release( handle );

	for ( i = 0 ; i <= 10 ; i++ ) {
		ctx.pin_index = MK_GPIO_INDEX( PCLK_channel, PCLK_GPIO, PCLK_gid, i );
		handle = gp_gpio_request( ctx.pin_index, NULL );
		gp_gpio_set_output( handle, 0, 0 );
		gp_gpio_release( handle );	
	}

	ctx.pin_index = MK_GPIO_INDEX( B_DATA_channel, B_DATA_GPIO, B_DATA_gid, B_DATA_pin );
	handle = gp_gpio_request( ctx.pin_index, NULL );
	gp_gpio_set_function( handle, B_DATA_GPIO );	
	gp_gpio_release( handle );

	for ( i = 0 ; i <= 7 ; i++ ) {
		ctx.pin_index = MK_GPIO_INDEX( B_DATA_channel, B_DATA_GPIO, B_DATA_gid, i );
		handle = gp_gpio_request( ctx.pin_index, NULL );
		gp_gpio_set_output( handle, 0, 0 );
		gp_gpio_release( handle );	
	}

	ctx.pin_index = MK_GPIO_INDEX( G_DATA_channel, G_DATA_GPIO, G_DATA_gid, G_DATA_pin );
	handle = gp_gpio_request( ctx.pin_index, NULL );
	gp_gpio_set_function( handle, G_DATA_GPIO );	
	gp_gpio_release( handle );

	for ( i = 8 ; i <= 11 ; i++ ) {
		ctx.pin_index = MK_GPIO_INDEX( G_DATA_channel, G_DATA_GPIO, G_DATA_gid, i );
		handle = gp_gpio_request( ctx.pin_index, NULL );
		gp_gpio_set_output( handle, 0, 0 );
		gp_gpio_release( handle );
	}
	
	ctx.pin_index = MK_GPIO_INDEX( R_DATA_channel, R_DATA_GPIO, R_DATA_gid, R_DATA_pin );
	handle = gp_gpio_request( ctx.pin_index, NULL );
	gp_gpio_set_function( handle, R_DATA_GPIO );	
	gp_gpio_release( handle );
	
	for ( i = 12 ; i <= 15 ; i++ ) {
		ctx.pin_index = MK_GPIO_INDEX( R_DATA_channel, R_DATA_GPIO, R_DATA_gid, i );
		handle = gp_gpio_request( ctx.pin_index, NULL );
		gp_gpio_set_output( handle, 0, 0 );
		gp_gpio_release( handle );
	}

	//VGH, AVDD, VGL, VCC to low
	lcd_power->set_panelpowerOn0(0);

	/* Disable lcd clock */
	gpHalLcdClkEnable(0);	
#ifdef CONFIG_PM
	gp_enable_clock((int*)"READLTIME_ABT", 0);
#endif

	return 0;
}
Ejemplo n.º 8
0
/**
* @brief 	SD driver initial function.
* @return 	SUCCESS/ERROR_ID.
*/
static int __init gp_sdcard_init(void)
{
	int i;
	/* ----- Get registered. ----- */
	sd_major = register_blkdev(sd_major, "sdcard");
	if (sd_major <= 0)
	{
		DERROR(KERN_WARNING "SD card : unable to get major number\n");
		return -EBUSY;
	}
	/* ----- Allocate the device array, and initialize each one. ----- */
	sd_info = kmalloc(SD_NUM*sizeof (gpSDInfo_t), GFP_KERNEL);
	if (sd_info == NULL)
		goto out_unregister;
	/* ----- Initial SD information ----- */
	for(i = 0; i < SD_NUM; i++)
	{
		char tag[4] = "sd0";
		gpSDInfo_t *sd = &sd_info[i];
		/* ----- Clear memory ----- */
		memset (sd, 0, sizeof (gpSDInfo_t));
		sd->device_id = i;
		/* ----- Initial spinlock ----- */
		spin_lock_init(&sd->lock);
		spin_lock_init(&sd->hal_lock);
		/* ----- Initial work queue ----- */
		INIT_WORK(&sd->init, gp_sdcard_work_init);
		INIT_WORK(&sd->uninit, gp_sdcard_work_uninit);
		/* ----- request IO function ----- */
		tag[2] = '0'+ i;
		sd->sd_func = gp_board_get_config( tag, gp_board_sd_t );
		if ( sd->sd_func == NULL ) {
            DEBUG("NO SD%d found in board config\n",i);
            continue;
        }
		/* ----- Initial dma module ----- */
		sd->dma_param.module = SD0+i;
		/* ----- Register get serial number function to board config ----- */
		sd->sd_func->get_sn = gp_sdcard_get_sn;
		/* ------Register gadget used function to board config ------*/
		sd->sd_func->read_cmd = gp_sdcard_readcmd;
		sd->sd_func->write_cmd = gp_sdcard_writecmd;
		sd->sd_func->dma_enable = gp_sdcard_dma_en;
		sd->sd_func->dma_finish = gp_sdcard_dma_finish;
		sd->sd_func->dma_stop = gp_sdcard_dma_stop;
		sd->sd_func->transfer_stop = gp_sdcard_stop;
		sd->sd_func->WaitDataComplete = gpHalSDWaitDataComplete;

		//gp_sdcard_carduninit(sd);						// Clock will disable when booting
        /* ----- Set Power Off Default ----- */
        sd->sd_func->set_power(0);
		/* ----- Init timer ----- */
		init_timer(&sd->timer);
		sd->timer.data = (unsigned long) sd;

		sd->timer.function = gp_sdcard_timer_fn;
		sd->timer.expires = jiffies + SD_CD_POLL;

		add_timer(&sd->timer);
	}

	gp_sdio_init();

	platform_device_register(&gp_sd_device);
	platform_driver_register(&gp_sd_driver);

	return 0;
out_unregister:
	unregister_blkdev(sd_major, "sdcard");
	return -ENOMEM;
}
Ejemplo n.º 9
0
/*****************************************************************
 * USB HOST OHCI Info
*****************************************************************/
static int spmp_usb_host_phy( unsigned int host_id, int enable )
{
    struct gp_board_usb_s *pConfig = gp_board_get_config("usb", gp_board_usb_t);
    static int g_usb_host_cnt[2] = {0};
    //char *host_name = (host_id)? "USB_HOST1" : "USB_HOST0";
    int phy_config;
    
    if(host_id == 0 )
    {
    	phy_config = (pConfig->phy0_func_en_get() == PHY0_HOST)? 1 : 0;
    }
    else
    {
    	phy_config = (pConfig->phy1_func_sel_get() == PHY0_HOST)? 1 : 0;
    }
    
    if(enable)
    {
        if( g_usb_host_cnt[host_id] <= 0 )
        {
			printk("host id %d enable\n",host_id );
			g_usb_host_cnt[host_id] = 0;
			gpHalUsbHostEn(host_id, 1);
			pConfig->set_power(1);
			gpHalScuUsbPhyClkEnable(1);	
			gpHalUsbPhyPowerControlSet( host_id ^0x01, 0x0 );
			if(phy_config)
				gpHalUsbPhyFuncSet( host_id ^0x01, 1 );
			msleep(5);
		}
		g_usb_host_cnt[host_id] ++;
    }
    else
    {
        g_usb_host_cnt[host_id] --;
        if(g_usb_host_cnt[host_id] <= 0)
        {
        	g_usb_host_cnt[host_id] = 0;
			if(phy_config)
		    	gpHalUsbPhyFuncSet( host_id ^0x01, 0 );
        	gpHalUsbPhyPowerControlSet( host_id ^0x01, 0x1);
			pConfig->set_power(0);
			gpHalUsbHostEn(host_id, 0);
		}
	}
    
#if 0 
    int phy0_config = pConfig->phy0_func_en_get();
	/*0: phy0 host, 1: phy0 disable*/
	int phy1_config = pConfig->phy1_func_sel_get();
	/*0: phy1 host, 1: phy1 slave, 2: phy1 host/slave, 3 phy1 disable*/
    int host_phy = -1;
    
    if( phy0_config == PHY0_HOST ) 
    {
        host_phy = 0;
    }
	else if( phy1_config == PHY1_HOST || phy1_config == PHY1_HOST_SLAVE ) 
    {
        host_phy = 1;
	}
    else
        return -1;

    if(enable)
    {
        if( g_usb_host_cnt <= 0 )
        {
            printk("host id %d enable, host phy = %d\n",host_id,host_phy );
            g_usb_host_cnt = 0;
		    gpHalUsbHostEn(host_id, 1);
		    pConfig->set_power(1);
		    gpHalScuUsbPhyClkEnable(1);	
		    gpHalUsbPhyPowerControlSet(host_phy, 0x0);
		    msleep(5);
		}
		g_usb_host_cnt ++;
    }
    else
    {
        g_usb_host_cnt --;
        if(g_usb_host_cnt <= 0)
        {
        	g_usb_host_cnt = 0;
        	gpHalUsbPhyPowerControlSet(host_phy, 0x1);
			pConfig->set_power(0);
			gpHalUsbHostEn(host_id, 0);
		}
	}
#endif
    return 0;
}