guowenxue
2020-08-21 d58257e9ac32dd22561b56a0ee1b208e34f46ba9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*********************************************************************************
 *      Copyright:  (C) 2017 LingYun IoT Studio <www.iot-yun.com>
 *                  All rights reserved.
 *
 *       Filename:  platdev_led.c
 *    Description:  This is the LED platform device
 *                 
 *        Version:  1.0.0(10/27/2011~)
 *         Author:  Guo Wenxue <guowenxue@gmail.com>
 *      ChangeLog:  1, Release initial version on "10/27/2011 11:39:10 AM"
 *                 
 ********************************************************************************/
#include <linux/module.h>   
#include <linux/init.h>    
#include <linux/kernel.h>  
 
#include "platdev_led.h"
 
/* LED hardware informtation data*/ 
static struct s3c_led_info  s3c_leds[] = {
    [0] = {
        .num = 1,
        .gpio = S3C2410_GPB(5),
        .active_level = LOWLEVEL,
        .status = OFF,
        .blink = ENABLE,
    },
    [1] = {
        .num = 2,
        .gpio = S3C2410_GPB(6),
        .active_level = LOWLEVEL,
        .status = OFF,
        .blink = DISABLE,
    },
    [2] = {
        .num = 3,
        .gpio = S3C2410_GPB(8),
        .active_level = LOWLEVEL,
        .status = OFF,
        .blink = DISABLE,
    },
    [3] = { 
        .num = 4,
        .gpio = S3C2410_GPB(10),
        .active_level = LOWLEVEL,
        .status = OFF,
        .blink = DISABLE,
    }, 
};
 
/*  The LED platform device private data */
static struct s3c_led_platform_data s3c_led_data = {
    .leds = s3c_leds,
    .nleds = ARRAY_SIZE(s3c_leds),
};
 
 
static void platform_led_release(struct device * dev)
{
    int i;
    struct s3c_led_platform_data *pdata = dev->platform_data; 
 
    for(i=0; i<pdata->nleds; i++)
    {
        /* Turn all LED off */
        s3c2410_gpio_setpin(pdata->leds[i].gpio, ~pdata->leds[i].active_level); 
    }
}
 
static struct platform_device s3c_led_device = {
    .name    = "s3c_led",
    .id      = 1,
    .dev     = 
    {
        .platform_data = &s3c_led_data, 
        .release = platform_led_release,
    },
};
 
 
static int __init platdev_led_init(void)
{
   int       rv = 0;
 
   rv = platform_device_register(&s3c_led_device);
   if(rv)
   {
        printk(KERN_ERR "%s:%d: Can't register platform device %d\n", __FUNCTION__,__LINE__, rv); 
        return rv;
   }
   printk("Regist S3C LED Platform Device successfully.\n");
 
   return 0;
}
 
 
static void platdev_led_exit(void)
{
    printk("%s():%d remove LED platform device\n", __FUNCTION__,__LINE__);
    platform_device_unregister(&s3c_led_device);
}
 
module_init(platdev_led_init);
module_exit(platdev_led_exit);
 
MODULE_AUTHOR("GuoWenxue<guowenxue@gmail.com>");
MODULE_DESCRIPTION("FL2440 LED driver platform device");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:s3c_platdev_led");