intflags;unsignedlongwork_flags;void(*brightness_set)(structled_classdev *led_cdev,enumled_brightness brightness);--光强设置接口。int(*brightness_set_blocking)(structled_classdev *led_cdev,enumled_brightness brightness);--非阻塞式光强设置接口。enumled_brightness (*brightness_get)(structled_classdev ...
static struct platform_driver gpio_led_driver = { .probe = gpio_led_probe, .remove = gpio_led_remove, .driver = { .name = "leds-gpio", .owner = THIS_MODULE, .of_match_table = of_match_ptr(of_gpio_leds_match), }, }; module_platform_driver(gpio_led_driver); 1. 2. 3. 4. ...
linux内核在初始化时,会根据platform_driver中定义的兼容名称列表,找到所有使用该platform_driver的platform_device,并逐个调用gpio_led_probe。 gpio_led_probe会申请每个GPIO,并调用led_classdev_register函数。 led_classdev_register()函数在led-calss.c文件中定义,该函数会将GPIO-LED加入名为leds_list的列表中。leds...
leddrv"},123{},124};125126/* 1. 定义platform_driver */127staticstruct platform_driver chip_demo_gpio_driver={128.probe=chip_demo_gpio_probe,129.remove=chip_demo_gpio_remove,130.driver={131.name="100ask_led",132.of_match_table=ask100_leds,133},134};135...
led_ctrl_probe(struct platform_device *pdev) //compatible的属性和dts的compatible一致,就会调用probe...
static int led_ctrl_probe(struct platform_device *pdev) //compatible的属性和dts的compatible一致,就会调用probe函数 { struct device_node *led_ctrl_node = pdev->dev.of_node; enum of_gpio_flags flags; int gpio_value; printk("[%d] enter %s start..\n", __LINE__, __func__); //printk...
led-power GPIO8_A1 GPIO_ACTIVE_LOW GPIO_ACTIVE_LOW 表示低电平有效(灯亮),如果是高电平有效,需要替换为 GPIO_ACTIVE_HIGH。 之后在驱动程序中加入对 GPIO 口的申请和控制则可: #ifdef CONFIG_OF#include<linux/of.h>#include<linux/of_gpio.h>#endifstaticintfirefly_led_probe(structplatform_device*pdev...
第2-15行:为代码的第一部分,仅实现.probe函数和.driver,当驱动和设备匹配成功后会执行该函数, 这个函数的函数实现我们在后面介绍。.driver描述这个驱动的属性,包括.name驱动的名字,.owner驱动的所有者, .of_match_table驱动匹配表,用于匹配驱动和设备。驱动设备匹配表定义为“rgb_led”在这个表里只有一个匹配值 ...
* platform 驱动的 probe 函数 * 驱动与设备匹配成功以后此函数就会执行 */ static int gpio_learning_probe(struct platform_device *dev) { printk("led driver and device was matched!\r\n"); /* 1、设置设备号 */ if (gpiodev.major) { //如果定义了主设备号 ...
};staticintmy_pdrv_probe(struct platform_device *pdev){intretval;structdevice*dev= &pdev->dev;// 获得 gpio descriptor 的同时也将其设置为 output,并且输出低电平red = gpiod_get_index(dev,"led",0, GPIOD_OUT_LOW); green = gpiod_get_index(dev,"led",1, GPIOD_OUT_LOW); ...