smart210驱动(6)leds-heartbeat

驱动内核里面已经提供了,这里只是设备端的描述即可。

led-heartbeat.c

/*
* linux-3.10.27
* arm-linux-gcc-4.5.1
*
* @ leds driver (heartbeat)
*/

#include <linux/module.h>
#include <linux/init.h>   /* module_init, ... */
#include <linux/kernel.h> /* everything */

#include <linux/cdev.h>   /* cdev_init, ... */
#include <linux/fs.h>     /* file_operations,  */
#include <linux/device.h>  /* class_create,... */
#include <linux/platform_device.h>
#include <linux/slab.h>   /* kmalloc, ... */
#include <asm/io.h>       /* ioremap,... */

#include <linux/uaccess.h>   /* copy_from_user, ... */

#include <linux/gpio.h>
#include <linux/leds.h>

static struct gpio_led leds[] = 
{
	[0] = {
		.name = "led0",
		.default_trigger = "heartbeat",
		.gpio = S5PV210_GPJ2(0),
		.active_low = 1,
		.default_state = LEDS_GPIO_DEFSTATE_OFF,
	},
};

static struct gpio_led_platform_data leds_data = {
	.num_leds = ARRAY_SIZE(leds),
	.leds = leds,
};

static void	led_heartbeat_release(struct device *dev)
{
	pr_info("%s called.\n", __func__);
}

static struct platform_device led_heartbeat = 
{
	.name = "leds-gpio",
	.dev = {
		.platform_data = &leds_data,
		.release = led_heartbeat_release,
	},
	.id = -1,
};

static int led_heartbeat_init(void)
{
	pr_info("%s called.\n", __func__);

	platform_device_register(&led_heartbeat);
	
	return 0;
}

static void led_heartbeat_exit(void)
{
	pr_info("%s called.\n", __func__);

	platform_device_unregister(&led_heartbeat);
}

module_init(led_heartbeat_init);
module_exit(led_heartbeat_exit);
MODULE_LICENSE("GPL");

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值