示例#1
0
static void init_disp_comond(void)
{

	unsigned char value;
	//init pin.
	printk("[%s][%d]\r\n",__FUNCTION__,__LINE__);
	
	cs_pin = gp_gpio_request(MK_GPIO_INDEX(0,0,48,15), NULL ); //IOA15
	data_pin = gp_gpio_request(MK_GPIO_INDEX(1,0,12,0), NULL ); //IOB0
	clk_pin = gp_gpio_request(MK_GPIO_INDEX(1,0,13,1), NULL ); //IOB1

	gp_gpio_set_output(cs_pin,1,0);
	gp_gpio_set_output(data_pin,1,0);
	gp_gpio_set_output(clk_pin,1,0);

	sent_command(0x05,0x5f);
	read_command(0x05,&value);
	sent_command(0x05,0x1f);
	read_command(0x05,&value);
	sent_command(0x05,0x5f);
	read_command(0x05,&value);
	sent_command(0x2b,0x01);
	read_command(0x2b,&value);
	sent_command(0x00,0x09);
	read_command(0x00,&value);
	sent_command(0x01,0x9f);
	read_command(0x01,&value);
	
	//m-sent_command(0x03,0x60);
	sent_command(0x03,0x2e);
	read_command(0x03,&value);	
	
	//m-sent_command(0x0d,0x60);
	sent_command(0x0d,0x50);
	read_command(0x0d,&value);	
	
	//m-sent_command(0x04,0x1b);
	sent_command(0x04,0x18);
	read_command(0x04,&value);
	sent_command(0x16,0x04);
	read_command(0x16,&value);
	gp_gpio_release(cs_pin);
	gp_gpio_release(data_pin);
	gp_gpio_release(clk_pin);

}
示例#2
0
static void gpio_test_isr(void *data)
{
	int p1 = (int)data;
	int p2;

	gp_gpio_enable_irq(p1, 0);
	p2 = gp_gpio_request(MK_GPIO_INDEX(2,2,4,6), "gpio_test"); /* IOC6 */
	gp_gpio_set_output(p2, 1, 1);
	gp_gpio_release(p2);
	printk("!!! gpio_test_isr\n");
}
static int gp_touchpad_request_gpio(void)
{
	//int ret = 0;
	//int value;
	printk("begin to request gpio\n");
	gp_touchpad_irq_data->gpiohd = gp_gpio_request(MK_GPIO_INDEX( touchpad_set_scl_channel, touchpad_set_scl_func, touchpad_set_scl_gid, touchpad_set_scl_pin ), "touchpad");
	if(IS_ERR_VALUE(gp_touchpad_irq_data->gpiohd)){
		DIAG_ERROR("touchpad request gpio clk = %d\n", gp_touchpad_irq_data->gpiohd);
		return -EINVAL;
	}
	
	gp_gpio_set_function(gp_touchpad_irq_data->gpiohd, GPIO_FUNC_GPIO);
	printk("touchpad set gpio function handle=0x%x\n",gp_touchpad_irq_data->gpiohd);
	gp_gpio_set_direction(gp_touchpad_irq_data->gpiohd, GPIO_DIR_INPUT);
	printk("touchpad set gpio direction\n");
	return 0;
}
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;
}
示例#6
0
/**
 * @brief   Gpio device ioctl function
 */
static long gpio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
	long ret = 0;
	int handle;
	gpio_content_t ctx;

	switch (cmd) {
	case GPIO_IOCTL_SET_VALUE:
		{
			if (copy_from_user(&ctx, (void __user*)arg, sizeof(ctx))) 
			{
				ret = -EFAULT;
				break;
			}

			handle = gp_gpio_request(ctx.pin_index, NULL);
			if (IS_ERR_VALUE(handle)) 
			{
				ret = (long)handle; /* gpio request error code */
				break;
			}

			ret = gp_gpio_set_output(handle, ctx.value, 0);

			gp_gpio_release(handle);
		}
		break;

	case GPIO_IOCTL_GET_VALUE:
		{
			if (copy_from_user(&ctx, (void __user*)arg, sizeof(ctx))) 
			{
				ret = -EFAULT;
				break;
			}

			handle = gp_gpio_request(ctx.pin_index, NULL);
			if (IS_ERR_VALUE(handle)) 
			{
				ret = (long)handle; /* gpio request error code */
				break;
			}

			ret = gp_gpio_set_input(handle, GPIO_PULL_FLOATING);
			if (ret == 0) 
			{
				ret = gp_gpio_get_value(handle, &ctx.value);
				if (ret == 0) 
				{
					if (copy_to_user((void __user*)arg, &ctx, sizeof(ctx))) 
					{
						ret = -EFAULT;
					}
				}
			}

			gp_gpio_release(handle);
		}
		break;
	case GPIO_IOCTL_SET_INPUT:
		{
			if (copy_from_user(&ctx, (void __user*)arg, sizeof(ctx))) 
			{
				ret = -EFAULT;
				break;
			}

			handle = gp_gpio_request(ctx.pin_index, NULL);
			if (IS_ERR_VALUE(handle)) 
			{
				ret = (long)handle; /* gpio request error code */
				break;
			}
			ret = gp_gpio_set_input(handle, ctx.value);
			
			gp_gpio_release(handle);			
		}
		break;
		case GPIO_IOCTL_IRQ_TEST:
		{
			if (copy_from_user(&ctx, (void __user*)arg, sizeof(ctx))) 
			{
				ret = -EFAULT;
				break;
			}

			handle = gp_gpio_request(ctx.pin_index, "gpio_irq_test");
			if (IS_ERR_VALUE(handle)) 
			{
				ret = (long)handle; /* gpio request error code */
				break;
			}
			ret = gp_gpio_set_input(handle, ctx.value);
			if(ctx.value == 1)
			 gp_gpio_irq_property(handle, GPIO_IRQ_ACTIVE_FALING, NULL);//low triggle
			else
			 gp_gpio_irq_property(handle, GPIO_IRQ_ACTIVE_RISING, NULL);//high triggle
			 
			 gp_gpio_register_isr(handle, gpio_test_isr, (void *)handle);		
		}
		break;
#ifdef GPIO_IOCTL_TEST
	case GPIO_IOCTL_TEST:
		{
			static int p1 = 0;
			int p2;

			if (p1 == 0) 
			{
				printk("--- gpio test begin!\n");
				p2 = gp_gpio_request(MK_GPIO_INDEX(2,2,4,6), "gpio_test"); /* IOC6 */
				gp_gpio_set_output(p2, 0, 1);
				gp_gpio_release(p2);

				p1 = gp_gpio_request(MK_GPIO_INDEX(2,2,4,5), "gpio_test"); /* IOC5 */
				gp_gpio_set_input(p1, GPIO_PULL_LOW);
				gp_gpio_irq_property(p1, GPIO_IRQ_LEVEL_TRIGGER|GPIO_IRQ_LEVEL_HIGH, NULL);
				gp_gpio_register_isr(p1, gpio_test_isr, (void *)p1);
			}
			else 
			{
				gp_gpio_unregister_isr(p1);
				gp_gpio_release(p1);
				p1 = 0;
				printk("--- gpio test end!\n");
			}
		}
		break;
#endif
	default:
		ret = -ENOTTY; /* Inappropriate ioctl for device */
		break;
	}

	return ret;
}