添加到devices.c的代码如下:
/*added to devices.c*/ static struct resource tsc2007_resource[] = {{.start= OMAP_GPIO_IRQ(GPIO_TO_PIN(0, 12)),.end= OMAP_GPIO_IRQ(GPIO_TO_PIN(0, 12)),.flags= IORESOURCE_IRQ,},};static struct platform_device tsc2007_device = {.name= "tsc2007",.id= -1,.num_resources = ARRAY_SIZE(tsc2007_resource),.resource= tsc2007_resource,};
添加到board-am335xevm.c文件的代码如下:
/* TouchScreen */ # define TSC2007_INT_GPIO GPIO_TO_PIN(0, 12)static int tsc2007_hw_init(void) { int err; err=gpio_request(TSC2007_INT_GPIO,"tsc2007 irq"); if(err){ pr_err("tsc2007 irqgpio request err\n"); return err; } err=gpio_direction_input(TSC2007_INT_GPIO); if(err){ pr_err("tsc2007 irqgpio init input err %d\n",err); gpio_free(TSC2007_INT_GPIO); return err; } setup_pin_mux(tsc2007_irq_pin_mux); printk("tsc2007 gpio initok\n"); return 0; }static void tsc2007_hw_remove(void) { gpio_free(TSC2007_INT_GPIO); } static int tsc2007_get_pendown_state(void) { return !gpio_get_value(TSC2007_INT_GPIO); } static struct tsc2007_platform_data tsc2007_info = { .model = 2007, .x_plate_ohms = 180, .get_pendown_state = tsc2007_get_pendown_state, .init_platform_hw=tsc2007_hw_init, .exit_platform_hw=tsc2007_hw_remove, }; static struct i2c_board_info tsc2007_i2c_devices[] = { { I2C_BOARD_INFO("tsc2007", 0x4B), .type = "tsc2007", .platform_data = &tsc2007_info, .irq = OMAP_GPIO_IRQ(TSC2007_INT_GPIO), }, }; /* Module pin mux for tsc2007 */ static struct pinmux_config tsc2007_i2c1_pin_mux[] = { {"spi0_d1.i2c1_sda",OMAP_MUX_MODE3 | AM33XX_SLEWCTRL_SLOW | AM33XX_PULL_ENBL | AM33XX_INPUT_EN}, {"spi0_cs0.i2c1_scl",OMAP_MUX_MODE3 | AM33XX_SLEWCTRL_SLOW | AM33XX_PULL_ENBL | AM33XX_INPUT_EN}, {NULL, 0}, }; static struct pinmux_config tsc2007_irq_pin_mux[] = { {"uart1_ctsn.gpio0_12",OMAP_MUX_MODE7 | AM33XX_PIN_INPUT}, {NULL, 0}, }; static void i2c1_init(void) { setup_pin_mux(tsc2007_i2c1_pin_mux); omap_register_i2c_bus(2, 100, tsc2007_i2c_devices, ARRAY_SIZE(tsc2007_i2c_devices)); return; }
然后在添加i2c1_init();
static void __init am335x_evm_init(void)
{
…
i2c1_init();
…
}
请问为什么i2c探测不到,中断也探测不到?????
leo chen:
我最近也在调试i2c的触摸屏,各种故障,有2个方面可以建议尝试一下
1、确定i2c接口是不是好的,可以接个eeprom之类测试一下
2、确认触摸屏的接口是不是正确的,上接和下接是不一样的
Grant Su:
請問TS2007中斷問題有方法解決嗎?
目前我也遇到相同的問題,希望大大可以提供解決方法。謝謝。