大家好,我用GPIO_162做为主板工作指示灯,同时测试了gpio_63,64,在linux下board_am3517evm.c中增加了以下代码
static struct omap_board_mux board_gpio_led_mux[] = {
OMAP3_MUX(MCBSP1_CLKX,OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT), //DS2
OMAP3_MUX(GPMC_WAIT1, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
OMAP3_MUX(GPMC_WAIT2, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
{ .reg_offset = OMAP_MUX_TERMINATOR },
}
static int gpio_leds_init(void)
{
int ret = 0;
omap3_mux_init(board_gpio_led_mux, OMAP_PACKAGE_CBB);
ret = gpio_request(162, "DS2");
if (ret) {
printk(KERN_ERR "failed to get DS2\n");
return 1;
}
gpio_direction_output(162, 1);
gpio_direction_output(63, 0);
gpio_direction_output(64, 0);
// gpio_set_value(162,1);
printk(KERN_INFO"Led initialized successfully\n");
return ret;
}
发现无论gpio_direction_output设置成1,还是0,io口的电平没有任何变化。我还有哪有需要配置吗?期待大家的帮助。
Steven Liu1:
GPIO Module那块的配置进行了吗?SYSCONFIG之类的
Qi Fu:
回复 Steven Liu1:
Steven Liu,谢谢你的回复,但是我不明白GPIO Module,SYSCONFIG是配置什么内容呢?具体在哪个地方进行配置?
我看了linux/gpio.h文件
static inline int gpio_direction_output(unsigned gpio, int value){ return -ENOSYS;}
这个设置输出并未实现,这个函数是在哪里实现的呢?
Yaoming Qin:
回复 Qi Fu:
你看看这个
http://processors.wiki.ti.com/index.php/GPIO_Driver_Guide
Qi Fu:
回复 Yaoming Qin:
Dear Yaoming Qin,
我尝试了这个方法,发现value 0/1,gpio 162的电压始终是1.7V左右,LED灯还是未能点亮。能帮忙分析下可能是什么原因导致?
root@am3517-evm:~# echo "162" > /sys/class/gpio/export
root@am3517-evm:~# ls /sys/class/gpio/
export gpiochip0 gpiochip160 gpiochip64 unexport
gpio162 gpiochip128 gpiochip32 gpiochip96
root@am3517-evm:~# echo "out" > /sys/class/gpio/gpio162/direction
root@am3517-evm:~# echo "1" > /sys/class/gpio/gpio162/value
root@am3517-evm:~# echo "0" > /sys/class/gpio/gpio162/value
Yaoming Qin:
回复 Qi Fu:
先问一个,你是在ti的evm板还是你自己设计的板子上做的实验
Qi Fu:
回复 Yaoming Qin:
在瑞泰的am3517与自己的板子上都测试过,gpio162 和63均不受控制,但是64可以。这三个gpio都是我自己添加的。
使用测试瑞泰自身带的led灯,测试也是有效果的。
所以我怀疑gpio162与63哪里配置不正确,pinmux配置了,输出模式配置了,就是想不出来还有哪里少配了或者是错配了。
以下是最新的测试代码 gpio 24 26 27 29都是可以的,63和162不行,64可以。
static struct gpio_led gpio_leds[] = { { .name = "am3517::D8", .default_trigger = "default-on", .gpio = 27, .active_low = true, }, { .name = "am3517::D7", .default_trigger = "default-on", .gpio = 26, .active_low = true, }, { .name = "am3517::D12", .default_trigger = "default-on", .gpio = 24, // gets replaced .active_low = true, }, { .name = "am3517::D11", .default_trigger = "default-on", .gpio = 29, // gets replaced .active_low = true, }, { .name = "am3517::DS2", .default_trigger = "default-on", .gpio = 162, .active_low = true, },};
static struct gpio_led_platform_data gpio_led_info = { .leds = gpio_leds, .num_leds = ARRAY_SIZE(gpio_leds),};
static struct platform_device leds_gpio = { .name = "leds-gpio", .id = -1, .dev = { .platform_data = &gpio_led_info, },};
static struct omap_board_mux board_gpio_led_mux[] = { OMAP3_MUX(ETK_D12, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT), OMAP3_MUX(ETK_D13, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT), OMAP3_MUX(ETK_D10, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT), OMAP3_MUX(ETK_D15, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
OMAP3_MUX(MCBSP1_CLKX,OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT), //Power DS2 gpio 162 OMAP3_MUX(GPMC_WAIT1, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),//63 OMAP3_MUX(GPMC_WAIT2, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),//64
{ .reg_offset = OMAP_MUX_TERMINATOR },};
static int gpio_leds_init(void){ int ret = 0; omap3_mux_init(board_gpio_led_mux, OMAP_PACKAGE_CBB);
return ret;
}
Qi Fu:
回复 Qi Fu:
暂时调好了,不知道为什么uboot中的pinmux配置会影响到kernel.
Yaoming Qin:
回复 Qi Fu:
如果uboot中配了,系统没有重启,kernel中不会失效啊