#include <linux/init.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#define GPIO_BASE_ADDRESS 0x11400000
#define GPX1_CON 0x0C20
#define GPX1_SIZE 24
#define GPX2_CON 0x0C40
#define GPX2_SIZE 24
#define GPF3_CON 0x01E0
#define GPX3_SIZE 24
struct resource led_resource[] = {
[0] = {
.start = GPIO_BASE_ADDRESS + GPX2_CON,
.end = GPIO_BASE_ADDRESS + GPX2_CON + GPX2_SIZE - 1,
.name = "exynos4412_dev_led2",
.flags = IORESOURCE_MEM,
},
[1] = {
.start = GPIO_BASE_ADDRESS + GPX1_CON,
.end = GPIO_BASE_ADDRESS + GPX1_CON + GPX1_SIZE - 1,
.name = "exynos4412_dev_led3",
.flags = IORESOURCE_MEM,
},
[2] = {
.start = 73,
.end = 73,
.name = "exynos4412_dev_irq0",
.flags = IORESOURCE_IRQ,
},
};
struct platform_device dev_led = {
.name = "exynos4412_dev_led",
.id = -1,
.num_resources = ARRAY_SIZE(led_resource),
.resource = led_resource,
};
static int __init led_dev_init(void)
{
return platform_device_register(&dev_led);
}
static void __exit led_dev_exit(void)
{
platform_device_unregister(&dev_led);
}
module_init(led_dev_init);
module_exit(led_dev_exit);
MODULE_LICENSE("GPL");
#include <linux/init.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/mod_devicetable.h>
int exynos4412_led_drv_probe(struct platform_device *pdev)
{
printk("--------%s----------\n",__FUNCTION__);
return 0;
}
int exynos4412_led_drv_remove(struct platform_device *pdev)
{
printk("--------%s----------\n",__FUNCTION__);
return 0;
}
struct platform_device_id id_table[] = {
[0] = {
.name = "exynos4412_dev_led",
.driver_data = 0x1111,
},
[1] = {
.name = "exynos2410_dev_led",
.driver_data = 0x2222,
},
[2] = {
.name = "exynos6410_dev_led",
.driver_data = 0x3333,
},
[3] = {
.name = "exynos6412_dev_led",
.driver_data = 0x4444,
},
};
struct platform_driver pdrv = {
.probe = exynos4412_led_drv_probe,
.remove = exynos4412_led_drv_remove,
.driver = {
.name = "SAMSUNG_drv_led",
},
.id_table = id_table,
};
int __init exynos4412_led_drv_init(void)
{
printk("--------%s----------\n",__FUNCTION__);
return platform_driver_register(&pdrv);
}
void __exit exynos4412_led_drv_exit(void)
{
printk("--------%s----------\n",__FUNCTION__);
platform_driver_unregister(&pdrv);
}
module_init(exynos4412_led_drv_init);
module_exit(exynos4412_led_drv_exit);
MODULE_LICENSE("GPL");
ROOTFS_DIR = /home/linux/Level11
CROSS_COMPILE = arm-none-linux-gnueabi-
CC = $(CROSS_COMPILE)gcc
ifeq ($(KERNELRELEASE), )
KERNEL_DIR = /home/linux/Level10/day6/linux-5.4.79
CUR_DIR = $(shell pwd)
all :
make -C $(KERNEL_DIR) M=$(CUR_DIR) modules -j6 ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-
clean :
make -C $(KERNEL_DIR) M=$(CUR_DIR) clean
clear
install:
cp -raf *.ko ./1/
else
obj-m += exynos4412_led_dev.o
obj-m += exynos4412_led_drv.o
endif
[root@farsight ]
[ 35.847814] exynos4412_led_dev: loading out-of-tree module taints kernel.
[root@farsight ]
[ 42.539908] --------exynos4412_led_drv_init----------
[ 42.543801] --------exynos4412_led_drv_probe----------
[root@farsight ]
[root@farsight sys]
block class devices fs module
bus dev firmware kernel power
[root@farsight sys]
[root@farsight drivers]
[root@farsight SAMSUNG_drv_led]
bind module unbind
exynos4412_dev_led uevent