67 lines
1.4 KiB
C
67 lines
1.4 KiB
C
#include <linux/module.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/fs.h>
|
|
#include <linux/init.h>
|
|
#include <linux/device.h>
|
|
#include <linux/cdev.h>
|
|
#include <linux/uaccess.h>
|
|
#include <asm/io.h>
|
|
#include <linux/platform_device.h>
|
|
|
|
static struct resource led_resource[] = {
|
|
[0] = {
|
|
.start = 0x50000000 + 0x894,
|
|
.end = 0x50000000 + 0x894 + 3,
|
|
.flags = IORESOURCE_MEM,
|
|
},
|
|
[1] = {
|
|
.start = 0x50000000 + 0xA28,
|
|
.end = 0x50000000 + 0xA28 + 3,
|
|
.flags = IORESOURCE_MEM,
|
|
},
|
|
[2] = {
|
|
.start = 0x50002000 + 0x00,
|
|
.end = 0x50002000 + 0x00 + 3,
|
|
.flags = IORESOURCE_MEM,
|
|
},
|
|
[3] = {
|
|
.start = 0x50002000 + 0x18,
|
|
.end = 0x50002000 + 0x18 + 3,
|
|
.flags = IORESOURCE_MEM,
|
|
},
|
|
};
|
|
|
|
static void led_release(struct device *dev)
|
|
{
|
|
/* do nothing */
|
|
}
|
|
|
|
static struct platform_device led_device = {
|
|
.name = "led_jzh",
|
|
.id = -1,
|
|
.num_resources = ARRAY_SIZE(led_resource),
|
|
.resource = led_resource,
|
|
.dev = {
|
|
.release = led_release,
|
|
},
|
|
};
|
|
|
|
static int __init led_device_init(void)
|
|
{
|
|
platform_device_register(&led_device);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void __exit led_device_exit(void)
|
|
{
|
|
platform_device_unregister(&led_device);
|
|
}
|
|
|
|
module_init(led_device_init);
|
|
module_exit(led_device_exit);
|
|
MODULE_LICENSE("GPL");
|
|
MODULE_AUTHOR("jzhgonha@163.com");
|
|
MODULE_VERSION("V0.1");
|
|
MODULE_DESCRIPTION("A simple LED driver for STM32MP157");
|