secgateway/kernel/linux-4.14.83/drivers/hctel/hcen104_led/hcen104_led.c

112 lines
2.6 KiB
C
Raw Normal View History

2019-06-11 07:43:23 +00:00
#include<linux/module.h>
#include<linux/init.h>
#include <linux/miscdevice.h>
#include <linux/fs.h>
#include <linux/mm.h>
#include <linux/slab.h>
#include <asm/uaccess.h>
#include <linux/io.h>
#include <linux/delay.h>
#include <linux/kernel.h>
#include <linux/platform_device.h>
#include <linux/cdev.h>
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/string.h>
#include <linux/ctype.h>
#include <linux/gpio.h>
#include <linux/leds.h>
#define GPIO1_NUM 480
#define GPIO2_NUM 448
#define GPIO4_NUM 384
#define GPIO_EN104(a, b) (a + b)
#define CPU_LED GPIO_EN104(GPIO4_NUM, 12)
#define LTE_PWR_EN GPIO_EN104(GPIO1_NUM, 18)
#define LTE_LED_0 GPIO_EN104(GPIO4_NUM, 11)
#define LTE_LED_1 GPIO_EN104(GPIO4_NUM, 10)
#define LTE_LED_2 GPIO_EN104(GPIO1_NUM, 22)
#define WIFI_LED GPIO_EN104(GPIO4_NUM, 13)
#define GPIO_RST GPIO_EN104(GPIO1_NUM, 21)
#define CLOUD_LED GPIO_EN104(GPIO1_NUM, 16)
static struct gpio_led gpio_leds[] = {
{
.name = "sys",
.default_trigger = "timer",
.gpio = CPU_LED,
.default_state = LEDS_GPIO_DEFSTATE_ON, // 默认LED亮
.active_low = 1, // 低电平亮
},
{
.name = "cloud",
//.default_trigger = "timer",
.gpio = CLOUD_LED,
.default_state = LEDS_GPIO_DEFSTATE_OFF,
.active_low = 1,
},
{
.name = "lte_0",
.gpio = LTE_LED_0,
.default_state = LEDS_GPIO_DEFSTATE_OFF,
.active_low = 1,
},
{
.name = "lte_1",
.gpio = LTE_LED_1,
.default_state = LEDS_GPIO_DEFSTATE_OFF,
.active_low = 1,
},
{
.name = "lte_2",
.gpio = LTE_LED_2,
.default_state = LEDS_GPIO_DEFSTATE_OFF,
.active_low = 1,
},
{
.name = "wifi",
.gpio = WIFI_LED,
.default_state = LEDS_GPIO_DEFSTATE_OFF,
.active_low = 1,
},
};
static struct gpio_led_platform_data gpio_led_info = {
.leds = gpio_leds,
.num_leds = ARRAY_SIZE(gpio_leds),
};
static struct platform_device leds_gpio = {
.name = "leds-gpio",
.id = -1,
.dev = {
.platform_data = &gpio_led_info,
//.release = en104_led_drv_release, //old kernel do not need,but 4.14 need
},
};
static int __init en104_led_drv_init(void)
{
platform_device_register(&leds_gpio);
return 0;
}
static void __exit en104_led_drv_exit(void)
{
platform_device_unregister(&leds_gpio);
}
module_init(en104_led_drv_init);
module_exit(en104_led_drv_exit);
MODULE_AUTHOR("liji");
MODULE_DESCRIPTION("en104 led ctrl");
MODULE_LICENSE("GPL");