Blame view

drivers/leds/leds-hp6xx.c 1.8 KB
d2912cb15   Thomas Gleixner   treewide: Replace...
1
  // SPDX-License-Identifier: GPL-2.0-only
d39a7a63e   Kristoffer Ericson   leds: Add HP Jorn...
2
3
4
5
6
7
  /*
   * LED Triggers Core
   * For the HP Jornada 620/660/680/690 handhelds
   *
   * Copyright 2008 Kristoffer Ericson <kristoffer.ericson@gmail.com>
   *     this driver is based on leds-spitz.c by Richard Purdie.
d39a7a63e   Kristoffer Ericson   leds: Add HP Jorn...
8
   */
86383b557   Axel Lin   leds: add missing...
9
  #include <linux/module.h>
d39a7a63e   Kristoffer Ericson   leds: Add HP Jorn...
10
  #include <linux/kernel.h>
d39a7a63e   Kristoffer Ericson   leds: Add HP Jorn...
11
12
13
  #include <linux/platform_device.h>
  #include <linux/leds.h>
  #include <asm/hd64461.h>
7639a4541   Paul Mundt   sh: Migrate commo...
14
  #include <mach/hp6xx.h>
d39a7a63e   Kristoffer Ericson   leds: Add HP Jorn...
15

4d404fd5c   Németh Márton   leds: Cleanup var...
16
17
  static void hp6xxled_green_set(struct led_classdev *led_cdev,
  			       enum led_brightness value)
d39a7a63e   Kristoffer Ericson   leds: Add HP Jorn...
18
19
20
21
22
23
24
25
26
  {
  	u8 v8;
  
  	v8 = inb(PKDR);
  	if (value)
  		outb(v8 & (~PKDR_LED_GREEN), PKDR);
  	else
  		outb(v8 | PKDR_LED_GREEN, PKDR);
  }
4d404fd5c   Németh Márton   leds: Cleanup var...
27
28
  static void hp6xxled_red_set(struct led_classdev *led_cdev,
  			     enum led_brightness value)
d39a7a63e   Kristoffer Ericson   leds: Add HP Jorn...
29
30
31
32
33
34
35
36
37
38
39
40
41
42
  {
  	u16 v16;
  
  	v16 = inw(HD64461_GPBDR);
  	if (value)
  		outw(v16 & (~HD64461_GPBDR_LED_RED), HD64461_GPBDR);
  	else
  		outw(v16 | HD64461_GPBDR_LED_RED, HD64461_GPBDR);
  }
  
  static struct led_classdev hp6xx_red_led = {
  	.name			= "hp6xx:red",
  	.default_trigger	= "hp6xx-charge",
  	.brightness_set		= hp6xxled_red_set,
859cb7f2a   Richard Purdie   leds: Add suspend...
43
  	.flags			= LED_CORE_SUSPENDRESUME,
d39a7a63e   Kristoffer Ericson   leds: Add HP Jorn...
44
45
46
47
  };
  
  static struct led_classdev hp6xx_green_led = {
  	.name			= "hp6xx:green",
eb25cb995   Stephan Linz   leds: convert IDE...
48
  	.default_trigger	= "disk-activity",
d39a7a63e   Kristoffer Ericson   leds: Add HP Jorn...
49
  	.brightness_set		= hp6xxled_green_set,
859cb7f2a   Richard Purdie   leds: Add suspend...
50
  	.flags			= LED_CORE_SUSPENDRESUME,
d39a7a63e   Kristoffer Ericson   leds: Add HP Jorn...
51
  };
d39a7a63e   Kristoffer Ericson   leds: Add HP Jorn...
52
53
54
  static int hp6xxled_probe(struct platform_device *pdev)
  {
  	int ret;
c0fc68ba9   Muhammad Falak R Wani   leds: leds-hp6xx:...
55
  	ret = devm_led_classdev_register(&pdev->dev, &hp6xx_red_led);
d39a7a63e   Kristoffer Ericson   leds: Add HP Jorn...
56
57
  	if (ret < 0)
  		return ret;
c0fc68ba9   Muhammad Falak R Wani   leds: leds-hp6xx:...
58
  	return devm_led_classdev_register(&pdev->dev, &hp6xx_green_led);
d39a7a63e   Kristoffer Ericson   leds: Add HP Jorn...
59
60
61
62
  }
  
  static struct platform_driver hp6xxled_driver = {
  	.probe		= hp6xxled_probe,
d39a7a63e   Kristoffer Ericson   leds: Add HP Jorn...
63
64
65
66
  	.driver		= {
  		.name		= "hp6xx-led",
  	},
  };
892a8843f   Axel Lin   leds: convert led...
67
  module_platform_driver(hp6xxled_driver);
d39a7a63e   Kristoffer Ericson   leds: Add HP Jorn...
68
69
70
71
  
  MODULE_AUTHOR("Kristoffer Ericson <kristoffer.ericson@gmail.com>");
  MODULE_DESCRIPTION("HP Jornada 6xx LED driver");
  MODULE_LICENSE("GPL");
892a8843f   Axel Lin   leds: convert led...
72
  MODULE_ALIAS("platform:hp6xx-led");