This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

dm3730 驱动

Other Parts Discussed in Thread: DM3730

linux dm3730下写一个gpio驱动是需要以下几个函数吗?

omap_cfg_reg();配置成gpio

gpio_request() 申请gpio

gpio_is_valid()判断gpio是否占用

gpio_direction_input()

gpio_direction_output()

这些函数调用与平台无关吗?调用这些函数,驱动程序要包含的头文件有哪几个呢?一直找不到。

请求专家帮忙解惑,感激不尽!!!

 

  • 你可以看document下的gpio相关的文档,对于其他驱动kernel提供标准的gpio接口.

  • document 下有个gpio.txt. 我上面说的那些函数就是gpio.txt里的gpio接口函数。可我用gpio_request()函数申请了好几个个gpio端口用dmesg命令查看内核消息时,都是返回错误,申请不到。请您指点一下····

  • 返回什么错误,看看kernel的error,调一下.

  • 一下是我拷贝的内核消息,不知道哪错了怎么分析,恳请指点一下,感激不尽!

    root@beagleboard:/home/lxq# insmod omap3_gpio_drv.ko

    [   89.994445] ------------[ cut here ]------------

    [   89.999114] WARNING: at drivers/gpio/gpiolib.c:101 gpio_ensure_requested+0x50/0x118()

    [   90.006988] autorequest GPIO-15

    [   90.010131] Modules linked in: omap3_gpio_drv(+) omaplfb pvrsrvkm

    [   90.016296] [<c003d988>] (unwind_backtrace+0x0/0xdc) from [<c0065448>] (warn_slowpath_common+0x48/0x60)

    [   90.025756] [<c0065448>] (warn_slowpath_common+0x48/0x60) from [<c0065498>] (warn_slowpath_fmt+0x24/0x30)

    [   90.035369] [<c0065498>] (warn_slowpath_fmt+0x24/0x30) from [<c01f978c>] (gpio_ensure_requested+0x50/0x118)

    [   90.045166] [<c01f978c>] (gpio_ensure_requested+0x50/0x118) from [<c01f98cc>] (gpio_direction_output+0x78/0x138)

    [   90.055389] [<c01f98cc>] (gpio_direction_output+0x78/0x138) from [<bf038140>] (omap3_gpio_init+0x10/0x98 [omap3_gpio_drv])

    [   90.066497] [<bf038140>] (omap3_gpio_init+0x10/0x98 [omap3_gpio_drv]) from [<c00373b4>] (do_one_initcall+0x5c/0x1b4)

    [   90.077087] [<c00373b4>] (do_one_initcall+0x5c/0x1b4) from [<c008d684>] (sys_init_module+0xb0/0x1dc)

    [   90.086273] [<c008d684>] (sys_init_module+0xb0/0x1dc) from [<c0037f80>] (ret_fast_syscall+0x0/0x2c)

    [   90.095367] ---[ end trace abd06b7e97215090 ]---

    [   90.104553] gpio register_chrdev success, major = 251

    [   90.109649] mux: Broken omap_cfg_reg(15) entry

    [   90.114562] ------------[ cut here ]------------

    [   90.119232] WARNING: at arch/arm/plat-omap/mux.c:60 omap_cfg_reg+0x1c/0x2c()

    [   90.126586] Modules linked in: omap3_gpio_drv(+) omaplfb pvrsrvkm

    [   90.133056] [<c003d988>] (unwind_backtrace+0x0/0xdc) from [<c0065448>] (warn_slowpath_common+0x48/0x60)

    [   90.142761] [<c0065448>] (warn_slowpath_common+0x48/0x60) from [<c004ed70>] (omap_cfg_reg+0x1c/0x2c)

    [   90.152130] [<c004ed70>] (omap_cfg_reg+0x1c/0x2c) from [<bf03817c>] (omap3_gpio_init+0x4c/0x98 [omap3_gpio_drv])

    [   90.162567] [<bf03817c>] (omap3_gpio_init+0x4c/0x98 [omap3_gpio_drv]) from [<c00373b4>] (do_one_initcall+0x5c/0x1b4)

    [   90.173339] [<c00373b4>] (do_one_initcall+0x5c/0x1b4) from [<c008d684>] (sys_init_module+0xb0/0x1dc)

    [   90.182678] [<c008d684>] (sys_init_module+0xb0/0x1dc) from [<c0037f80>] (ret_fast_syscall+0x0/0x2c)

    [   90.192077] ---[ end trace abd06b7e97215091 ]---

    [   90.196716] failed to request GPIO gpio_pin       

    gpio_request()我是用这个函数申请gpio的。恳请指导··········

  • 请问楼主有结果了没?最近我也在学习DM3730,您现在是前辈了···

  • 请先确认相应的gpio是否已经request

  • 先调用omap_mux_init_gpio,设置mux,这是很关键的一步。当然如果在uboot里面已经设置过了,这里可以不调用。

    接着就可以gpio_direction_input(),gpio_direction_output()

    当然gpio_request() 申请gpio,gpio_is_valid()判断gpio是否占用这两个函数也可以用。