Blame view

drivers/leds/leds-cobalt-qube.c 1.97 KB
2fea6f35c   Florian Fainelli   leds: Add support...
1
2
3
4
5
  /*
   * Copyright 2006 - Florian Fainelli <florian@openwrt.org>
   *
   * Control the Cobalt Qube/RaQ front LED
   */
4276fd734   Yoichi Yuasa   leds: Update Coba...
6
7
8
9
  #include <linux/init.h>
  #include <linux/io.h>
  #include <linux/ioport.h>
  #include <linux/leds.h>
2fea6f35c   Florian Fainelli   leds: Add support...
10
  #include <linux/module.h>
4276fd734   Yoichi Yuasa   leds: Update Coba...
11
  #include <linux/platform_device.h>
2fea6f35c   Florian Fainelli   leds: Add support...
12
  #include <linux/types.h>
2fea6f35c   Florian Fainelli   leds: Add support...
13

4276fd734   Yoichi Yuasa   leds: Update Coba...
14
15
16
17
18
19
20
  #define LED_FRONT_LEFT	0x01
  #define LED_FRONT_RIGHT	0x02
  
  static void __iomem *led_port;
  static u8 led_value;
  
  static void qube_front_led_set(struct led_classdev *led_cdev,
4d404fd5c   Németh Márton   leds: Cleanup var...
21
  			       enum led_brightness brightness)
2fea6f35c   Florian Fainelli   leds: Add support...
22
23
  {
  	if (brightness)
4276fd734   Yoichi Yuasa   leds: Update Coba...
24
  		led_value = LED_FRONT_LEFT | LED_FRONT_RIGHT;
2fea6f35c   Florian Fainelli   leds: Add support...
25
  	else
4276fd734   Yoichi Yuasa   leds: Update Coba...
26
27
28
29
30
  		led_value = ~(LED_FRONT_LEFT | LED_FRONT_RIGHT);
  	writeb(led_value, led_port);
  }
  
  static struct led_classdev qube_front_led = {
db3f52073   Olaf Hering   leds: Fix LED names
31
  	.name			= "qube::front",
4276fd734   Yoichi Yuasa   leds: Update Coba...
32
33
  	.brightness		= LED_FULL,
  	.brightness_set		= qube_front_led_set,
51de036ba   Florian Fainelli   leds: use default...
34
  	.default_trigger	= "default-on",
4276fd734   Yoichi Yuasa   leds: Update Coba...
35
36
37
38
39
40
41
42
43
44
  };
  
  static int __devinit cobalt_qube_led_probe(struct platform_device *pdev)
  {
  	struct resource *res;
  	int retval;
  
  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  	if (!res)
  		return -EBUSY;
3c0f6e1ed   H Hartley Sweeten   leds: leds-cobalt...
45
  	led_port = ioremap(res->start, resource_size(res));
4276fd734   Yoichi Yuasa   leds: Update Coba...
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
  	if (!led_port)
  		return -ENOMEM;
  
  	led_value = LED_FRONT_LEFT | LED_FRONT_RIGHT;
  	writeb(led_value, led_port);
  
  	retval = led_classdev_register(&pdev->dev, &qube_front_led);
  	if (retval)
  		goto err_iounmap;
  
  	return 0;
  
  err_iounmap:
  	iounmap(led_port);
  	led_port = NULL;
  
  	return retval;
  }
  
  static int __devexit cobalt_qube_led_remove(struct platform_device *pdev)
  {
  	led_classdev_unregister(&qube_front_led);
  
  	if (led_port) {
  		iounmap(led_port);
  		led_port = NULL;
  	}
  
  	return 0;
2fea6f35c   Florian Fainelli   leds: Add support...
75
  }
4276fd734   Yoichi Yuasa   leds: Update Coba...
76
77
78
79
80
81
82
  static struct platform_driver cobalt_qube_led_driver = {
  	.probe	= cobalt_qube_led_probe,
  	.remove	= __devexit_p(cobalt_qube_led_remove),
  	.driver	= {
  		.name	= "cobalt-qube-leds",
  		.owner	= THIS_MODULE,
  	},
2fea6f35c   Florian Fainelli   leds: Add support...
83
  };
892a8843f   Axel Lin   leds: convert led...
84
  module_platform_driver(cobalt_qube_led_driver);
2fea6f35c   Florian Fainelli   leds: Add support...
85
86
87
88
  
  MODULE_LICENSE("GPL");
  MODULE_DESCRIPTION("Front LED support for Cobalt Server");
  MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>");
892a8843f   Axel Lin   leds: convert led...
89
  MODULE_ALIAS("platform:cobalt-qube-leds");