aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/txx9
diff options
context:
space:
mode:
authorAtsushi Nemoto <anemo@mba.ocn.ne.jp>2008-09-01 09:22:38 -0400
committerRalf Baechle <ralf@linux-mips.org>2008-10-11 11:18:49 -0400
commitae027ead87b13cff99b4f48da7696aa4fe75393b (patch)
tree48dff058f4682b4938c5e7e004634938994de80b /arch/mips/txx9
parent21e77df215e58523a755b5dd006cb17610616f20 (diff)
MIPS: TXx9: IOC LED support
Add leds-gpio platform device for controlling LEDs connected to IOC on RBTX49XX and JMR3927 board. Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/txx9')
-rw-r--r--arch/mips/txx9/generic/setup.c111
-rw-r--r--arch/mips/txx9/jmr3927/setup.c5
-rw-r--r--arch/mips/txx9/rbtx4927/setup.c1
-rw-r--r--arch/mips/txx9/rbtx4938/setup.c1
4 files changed, 118 insertions, 0 deletions
diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
index 118d716f7832..1ea06553a1e1 100644
--- a/arch/mips/txx9/generic/setup.c
+++ b/arch/mips/txx9/generic/setup.c
@@ -23,6 +23,7 @@
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/serial_core.h> 24#include <linux/serial_core.h>
25#include <linux/mtd/physmap.h> 25#include <linux/mtd/physmap.h>
26#include <linux/leds.h>
26#include <asm/bootinfo.h> 27#include <asm/bootinfo.h>
27#include <asm/time.h> 28#include <asm/time.h>
28#include <asm/reboot.h> 29#include <asm/reboot.h>
@@ -649,3 +650,113 @@ void __init txx9_physmap_flash_init(int no, unsigned long addr,
649 platform_device_put(pdev); 650 platform_device_put(pdev);
650#endif 651#endif
651} 652}
653
654#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
655static DEFINE_SPINLOCK(txx9_iocled_lock);
656
657#define TXX9_IOCLED_MAXLEDS 8
658
659struct txx9_iocled_data {
660 struct gpio_chip chip;
661 u8 cur_val;
662 void __iomem *mmioaddr;
663 struct gpio_led_platform_data pdata;
664 struct gpio_led leds[TXX9_IOCLED_MAXLEDS];
665 char names[TXX9_IOCLED_MAXLEDS][32];
666};
667
668static int txx9_iocled_get(struct gpio_chip *chip, unsigned int offset)
669{
670 struct txx9_iocled_data *data =
671 container_of(chip, struct txx9_iocled_data, chip);
672 return data->cur_val & (1 << offset);
673}
674
675static void txx9_iocled_set(struct gpio_chip *chip, unsigned int offset,
676 int value)
677{
678 struct txx9_iocled_data *data =
679 container_of(chip, struct txx9_iocled_data, chip);
680 unsigned long flags;
681 spin_lock_irqsave(&txx9_iocled_lock, flags);
682 if (value)
683 data->cur_val |= 1 << offset;
684 else
685 data->cur_val &= ~(1 << offset);
686 writeb(data->cur_val, data->mmioaddr);
687 mmiowb();
688 spin_unlock_irqrestore(&txx9_iocled_lock, flags);
689}
690
691static int txx9_iocled_dir_in(struct gpio_chip *chip, unsigned int offset)
692{
693 return 0;
694}
695
696static int txx9_iocled_dir_out(struct gpio_chip *chip, unsigned int offset,
697 int value)
698{
699 txx9_iocled_set(chip, offset, value);
700 return 0;
701}
702
703void __init txx9_iocled_init(unsigned long baseaddr,
704 int basenum, unsigned int num, int lowactive,
705 const char *color, char **deftriggers)
706{
707 struct txx9_iocled_data *iocled;
708 struct platform_device *pdev;
709 int i;
710 static char *default_triggers[] __initdata = {
711 "heartbeat",
712 "ide-disk",
713 "nand-disk",
714 NULL,
715 };
716
717 if (!deftriggers)
718 deftriggers = default_triggers;
719 iocled = kzalloc(sizeof(*iocled), GFP_KERNEL);
720 if (!iocled)
721 return;
722 iocled->mmioaddr = ioremap(baseaddr, 1);
723 if (!iocled->mmioaddr)
724 return;
725 iocled->chip.get = txx9_iocled_get;
726 iocled->chip.set = txx9_iocled_set;
727 iocled->chip.direction_input = txx9_iocled_dir_in;
728 iocled->chip.direction_output = txx9_iocled_dir_out;
729 iocled->chip.label = "iocled";
730 iocled->chip.base = basenum;
731 iocled->chip.ngpio = num;
732 if (gpiochip_add(&iocled->chip))
733 return;
734 if (basenum < 0)
735 basenum = iocled->chip.base;
736
737 pdev = platform_device_alloc("leds-gpio", basenum);
738 if (!pdev)
739 return;
740 iocled->pdata.num_leds = num;
741 iocled->pdata.leds = iocled->leds;
742 for (i = 0; i < num; i++) {
743 struct gpio_led *led = &iocled->leds[i];
744 snprintf(iocled->names[i], sizeof(iocled->names[i]),
745 "iocled:%s:%u", color, i);
746 led->name = iocled->names[i];
747 led->gpio = basenum + i;
748 led->active_low = lowactive;
749 if (deftriggers && *deftriggers)
750 led->default_trigger = *deftriggers++;
751 }
752 pdev->dev.platform_data = &iocled->pdata;
753 if (platform_device_add(pdev))
754 platform_device_put(pdev);
755}
756#else /* CONFIG_LEDS_GPIO */
757void __init txx9_iocled_init(unsigned long baseaddr,
758 int basenum, unsigned int num, int lowactive,
759 const char *color, char **deftriggers)
760{
761}
762#endif /* CONFIG_LEDS_GPIO */
diff --git a/arch/mips/txx9/jmr3927/setup.c b/arch/mips/txx9/jmr3927/setup.c
index 0f3843c92cf7..25e50a7be387 100644
--- a/arch/mips/txx9/jmr3927/setup.c
+++ b/arch/mips/txx9/jmr3927/setup.c
@@ -200,10 +200,15 @@ static void __init jmr3927_mtd_init(void)
200 200
201static void __init jmr3927_device_init(void) 201static void __init jmr3927_device_init(void)
202{ 202{
203 unsigned long iocled_base = JMR3927_IOC_LED_ADDR - IO_BASE;
204#ifdef __LITTLE_ENDIAN
205 iocled_base |= 1;
206#endif
203 __swizzle_addr_b = jmr3927_swizzle_addr_b; 207 __swizzle_addr_b = jmr3927_swizzle_addr_b;
204 jmr3927_rtc_init(); 208 jmr3927_rtc_init();
205 tx3927_wdt_init(); 209 tx3927_wdt_init();
206 jmr3927_mtd_init(); 210 jmr3927_mtd_init();
211 txx9_iocled_init(iocled_base, -1, 8, 1, "green", NULL);
207} 212}
208 213
209struct txx9_board_vec jmr3927_vec __initdata = { 214struct txx9_board_vec jmr3927_vec __initdata = {
diff --git a/arch/mips/txx9/rbtx4927/setup.c b/arch/mips/txx9/rbtx4927/setup.c
index abe32c1a79dc..4a74423b2ba8 100644
--- a/arch/mips/txx9/rbtx4927/setup.c
+++ b/arch/mips/txx9/rbtx4927/setup.c
@@ -321,6 +321,7 @@ static void __init rbtx4927_device_init(void)
321 rbtx4927_ne_init(); 321 rbtx4927_ne_init();
322 tx4927_wdt_init(); 322 tx4927_wdt_init();
323 rbtx4927_mtd_init(); 323 rbtx4927_mtd_init();
324 txx9_iocled_init(RBTX4927_LED_ADDR - IO_BASE, -1, 3, 1, "green", NULL);
324} 325}
325 326
326struct txx9_board_vec rbtx4927_vec __initdata = { 327struct txx9_board_vec rbtx4927_vec __initdata = {
diff --git a/arch/mips/txx9/rbtx4938/setup.c b/arch/mips/txx9/rbtx4938/setup.c
index ec6e81258f73..e077cc4d3a59 100644
--- a/arch/mips/txx9/rbtx4938/setup.c
+++ b/arch/mips/txx9/rbtx4938/setup.c
@@ -352,6 +352,7 @@ static void __init rbtx4938_device_init(void)
352 rbtx4938_ne_init(); 352 rbtx4938_ne_init();
353 tx4938_wdt_init(); 353 tx4938_wdt_init();
354 rbtx4938_mtd_init(); 354 rbtx4938_mtd_init();
355 txx9_iocled_init(RBTX4938_LED_ADDR - IO_BASE, -1, 8, 1, "green", NULL);
355} 356}
356 357
357struct txx9_board_vec rbtx4938_vec __initdata = { 358struct txx9_board_vec rbtx4938_vec __initdata = {