ARM: clps711x: p720t: Using "leds-gpio" driver for LED control
Instead of manually create LED class device, we will use "leds-gpio" driver for LED control. Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Olof Johansson <olof@lixom.net>
This commit is contained in:
parent
200daa367c
commit
b3a076dd02
@ -4,6 +4,9 @@
|
|||||||
* Common bits.
|
* Common bits.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define CLPS711X_NR_GPIO (4 * 8 + 3)
|
||||||
|
#define CLPS711X_GPIO(prt, bit) ((prt) * 8 + (bit))
|
||||||
|
|
||||||
struct sys_timer;
|
struct sys_timer;
|
||||||
|
|
||||||
extern void clps711x_map_io(void);
|
extern void clps711x_map_io(void);
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/leds.h>
|
#include <linux/leds.h>
|
||||||
|
#include <linux/platform_device.h>
|
||||||
|
|
||||||
#include <mach/hardware.h>
|
#include <mach/hardware.h>
|
||||||
#include <asm/pgtable.h>
|
#include <asm/pgtable.h>
|
||||||
@ -38,6 +39,8 @@
|
|||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
#define GPIO_USERLED CLPS711X_GPIO(3, 0)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Map the P720T system PLD. It occupies two address spaces:
|
* Map the P720T system PLD. It occupies two address spaces:
|
||||||
* 0x10000000 and 0x10400000. We map both regions as one.
|
* 0x10000000 and 0x10400000. We map both regions as one.
|
||||||
@ -103,71 +106,34 @@ static void __init p720t_init_early(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
static struct gpio_led p720t_gpio_leds[] = {
|
||||||
* LED controled by CPLD
|
{
|
||||||
*/
|
.name = "User LED",
|
||||||
#if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS)
|
.default_trigger = "heartbeat",
|
||||||
static void p720t_led_set(struct led_classdev *cdev,
|
.gpio = GPIO_USERLED,
|
||||||
enum led_brightness b)
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct gpio_led_platform_data p720t_gpio_led_pdata __initdata = {
|
||||||
|
.leds = p720t_gpio_leds,
|
||||||
|
.num_leds = ARRAY_SIZE(p720t_gpio_leds),
|
||||||
|
};
|
||||||
|
|
||||||
|
static void __init p720t_init_late(void)
|
||||||
{
|
{
|
||||||
u8 reg = clps_readb(PDDR);
|
platform_device_register_data(&platform_bus, "leds-gpio", 0,
|
||||||
|
&p720t_gpio_led_pdata,
|
||||||
if (b != LED_OFF)
|
sizeof(p720t_gpio_led_pdata));
|
||||||
reg |= 0x1;
|
|
||||||
else
|
|
||||||
reg &= ~0x1;
|
|
||||||
|
|
||||||
clps_writeb(reg, PDDR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum led_brightness p720t_led_get(struct led_classdev *cdev)
|
|
||||||
{
|
|
||||||
u8 reg = clps_readb(PDDR);
|
|
||||||
|
|
||||||
return (reg & 0x1) ? LED_FULL : LED_OFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int __init p720t_leds_init(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
struct led_classdev *cdev;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (!machine_is_p720t())
|
|
||||||
return -ENODEV;
|
|
||||||
|
|
||||||
cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
|
|
||||||
if (!cdev)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
cdev->name = "p720t:0";
|
|
||||||
cdev->brightness_set = p720t_led_set;
|
|
||||||
cdev->brightness_get = p720t_led_get;
|
|
||||||
cdev->default_trigger = "heartbeat";
|
|
||||||
|
|
||||||
ret = led_classdev_register(NULL, cdev);
|
|
||||||
if (ret < 0) {
|
|
||||||
kfree(cdev);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Since we may have triggers on any subsystem, defer registration
|
|
||||||
* until after subsystem_init.
|
|
||||||
*/
|
|
||||||
fs_initcall(p720t_leds_init);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
MACHINE_START(P720T, "ARM-Prospector720T")
|
MACHINE_START(P720T, "ARM-Prospector720T")
|
||||||
/* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
|
/* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
|
||||||
.atag_offset = 0x100,
|
.atag_offset = 0x100,
|
||||||
.fixup = fixup_p720t,
|
.fixup = fixup_p720t,
|
||||||
.init_early = p720t_init_early,
|
|
||||||
.map_io = p720t_map_io,
|
.map_io = p720t_map_io,
|
||||||
|
.init_early = p720t_init_early,
|
||||||
.init_irq = clps711x_init_irq,
|
.init_irq = clps711x_init_irq,
|
||||||
.timer = &clps711x_timer,
|
.timer = &clps711x_timer,
|
||||||
|
.init_late = p720t_init_late,
|
||||||
.restart = clps711x_restart,
|
.restart = clps711x_restart,
|
||||||
MACHINE_END
|
MACHINE_END
|
||||||
|
Loading…
Reference in New Issue
Block a user