/********************************************************************************* 
 | 
 *      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"); 
 |