Commit 805e324b authored by Sean MacLennan's avatar Sean MacLennan Committed by Benjamin Herrenschmidt

powerpc: Update Warp to use leds-gpio driver

Now that leds-gpio is a proper OF platform driver, the Warp can use
the leds-gpio driver rather than the old out-of-kernel driver.

One side-effect is the leds-gpio driver always turns the leds off
while the old driver left them alone. So we have to set them back to
the correct settings.
Signed-off-by: default avatarSean MacLennan <smaclennan@pikatech.com>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent 54c18193
/* /*
* Device Tree Source for PIKA Warp * Device Tree Source for PIKA Warp
* *
* Copyright (c) 2008 PIKA Technologies * Copyright (c) 2008-2009 PIKA Technologies
* Sean MacLennan <smaclennan@pikatech.com> * Sean MacLennan <smaclennan@pikatech.com>
* *
* This file is licensed under the terms of the GNU General Public * This file is licensed under the terms of the GNU General Public
...@@ -158,7 +158,7 @@ nor@0,0 { ...@@ -158,7 +158,7 @@ nor@0,0 {
partition@0 { partition@0 {
label = "splash"; label = "splash";
reg = <0x00000000 0x00020000>; reg = <0x00000000 0x00010000>;
}; };
partition@300000 { partition@300000 {
label = "fpga"; label = "fpga";
...@@ -244,28 +244,27 @@ at24@52 { ...@@ -244,28 +244,27 @@ at24@52 {
}; };
GPIO0: gpio@ef600b00 { GPIO0: gpio@ef600b00 {
compatible = "ibm,gpio-440ep"; compatible = "ibm,ppc4xx-gpio";
reg = <0xef600b00 0x00000048>; reg = <0xef600b00 0x00000048>;
#gpio-cells = <2>; #gpio-cells = <2>;
gpio-controller; gpio-controller;
}; };
GPIO1: gpio@ef600c00 { GPIO1: gpio@ef600c00 {
compatible = "ibm,gpio-440ep"; compatible = "ibm,ppc4xx-gpio";
reg = <0xef600c00 0x00000048>; reg = <0xef600c00 0x00000048>;
#gpio-cells = <2>; #gpio-cells = <2>;
gpio-controller; gpio-controller;
led@31 {
compatible = "linux,gpio-led";
linux,name = ":green:";
gpios = <&GPIO1 31 0>;
}; };
led@30 { power-leds {
compatible = "linux,gpio-led"; compatible = "gpio-leds";
linux,name = ":red:"; green {
gpios = <&GPIO1 30 0>; gpios = <&GPIO1 0 0>;
default-state = "on";
};
red {
gpios = <&GPIO1 1 0>;
}; };
}; };
......
/* /*
* PIKA Warp(tm) board specific routines * PIKA Warp(tm) board specific routines
* *
* Copyright (c) 2008 PIKA Technologies * Copyright (c) 2008-2009 PIKA Technologies
* Sean MacLennan <smaclennan@pikatech.com> * Sean MacLennan <smaclennan@pikatech.com>
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/of_gpio.h>
#include <asm/machdep.h> #include <asm/machdep.h>
#include <asm/prom.h> #include <asm/prom.h>
...@@ -23,6 +24,7 @@ ...@@ -23,6 +24,7 @@
#include <asm/uic.h> #include <asm/uic.h>
#include <asm/ppc4xx.h> #include <asm/ppc4xx.h>
static __initdata struct of_device_id warp_of_bus[] = { static __initdata struct of_device_id warp_of_bus[] = {
{ .compatible = "ibm,plb4", }, { .compatible = "ibm,plb4", },
{ .compatible = "ibm,opb", }, { .compatible = "ibm,opb", },
...@@ -55,6 +57,8 @@ define_machine(warp) { ...@@ -55,6 +57,8 @@ define_machine(warp) {
}; };
static u32 post_info;
/* I am not sure this is the best place for this... */ /* I am not sure this is the best place for this... */
static int __init warp_post_info(void) static int __init warp_post_info(void)
{ {
...@@ -77,21 +81,21 @@ static int __init warp_post_info(void) ...@@ -77,21 +81,21 @@ static int __init warp_post_info(void)
iounmap(fpga); iounmap(fpga);
if (post1 || post2) if (post1 || post2) {
printk(KERN_INFO "Warp POST %08x %08x\n", post1, post2); printk(KERN_INFO "Warp POST %08x %08x\n", post1, post2);
else post_info = 1;
} else
printk(KERN_INFO "Warp POST OK\n"); printk(KERN_INFO "Warp POST OK\n");
return 0; return 0;
} }
machine_late_initcall(warp, warp_post_info);
#ifdef CONFIG_SENSORS_AD7414 #ifdef CONFIG_SENSORS_AD7414
static LIST_HEAD(dtm_shutdown_list); static LIST_HEAD(dtm_shutdown_list);
static void __iomem *dtm_fpga; static void __iomem *dtm_fpga;
static void __iomem *gpio_base; static unsigned green_led, red_led;
struct dtm_shutdown { struct dtm_shutdown {
...@@ -134,14 +138,17 @@ int pika_dtm_unregister_shutdown(void (*func)(void *arg), void *arg) ...@@ -134,14 +138,17 @@ int pika_dtm_unregister_shutdown(void (*func)(void *arg), void *arg)
static irqreturn_t temp_isr(int irq, void *context) static irqreturn_t temp_isr(int irq, void *context)
{ {
struct dtm_shutdown *shutdown; struct dtm_shutdown *shutdown;
int value = 1;
local_irq_disable(); local_irq_disable();
gpio_set_value(green_led, 0);
/* Run through the shutdown list. */ /* Run through the shutdown list. */
list_for_each_entry(shutdown, &dtm_shutdown_list, list) list_for_each_entry(shutdown, &dtm_shutdown_list, list)
shutdown->func(shutdown->arg); shutdown->func(shutdown->arg);
printk(KERN_EMERG "\n\nCritical Temperature Shutdown\n"); printk(KERN_EMERG "\n\nCritical Temperature Shutdown\n\n");
while (1) { while (1) {
if (dtm_fpga) { if (dtm_fpga) {
...@@ -149,52 +156,34 @@ static irqreturn_t temp_isr(int irq, void *context) ...@@ -149,52 +156,34 @@ static irqreturn_t temp_isr(int irq, void *context)
out_be32(dtm_fpga + 0x14, reset); out_be32(dtm_fpga + 0x14, reset);
} }
if (gpio_base) { gpio_set_value(red_led, value);
unsigned leds = in_be32(gpio_base); value ^= 1;
/* green off, red toggle */
leds &= ~0x80000000;
leds ^= 0x40000000;
out_be32(gpio_base, leds);
}
mdelay(500); mdelay(500);
} }
} }
static int pika_setup_leds(void) static int pika_setup_leds(void)
{ {
struct device_node *np; struct device_node *np, *child;
const u32 *gpios;
int len;
np = of_find_compatible_node(NULL, NULL, "linux,gpio-led"); np = of_find_compatible_node(NULL, NULL, "gpio-leds");
if (!np) { if (!np) {
printk(KERN_ERR __FILE__ ": Unable to find gpio-led\n"); printk(KERN_ERR __FILE__ ": Unable to find leds\n");
return -ENOENT; return -ENOENT;
} }
gpios = of_get_property(np, "gpios", &len); for_each_child_of_node(np, child)
of_node_put(np); if (strcmp(child->name, "green") == 0) {
if (!gpios || len < 4) { green_led = of_get_gpio(child, 0);
printk(KERN_ERR __FILE__ /* Turn back on the green LED */
": Unable to get gpios property (%d)\n", len); gpio_set_value(green_led, 1);
return -ENOENT; } else if (strcmp(child->name, "red") == 0) {
red_led = of_get_gpio(child, 0);
/* Set based on post */
gpio_set_value(red_led, post_info);
} }
np = of_find_node_by_phandle(gpios[0]);
if (!np) {
printk(KERN_ERR __FILE__ ": Unable to find gpio\n");
return -ENOENT;
}
gpio_base = of_iomap(np, 0);
of_node_put(np); of_node_put(np);
if (!gpio_base) {
printk(KERN_ERR __FILE__ ": Unable to map gpio");
return -ENOMEM;
}
return 0; return 0;
} }
...@@ -270,10 +259,10 @@ static int pika_dtm_thread(void __iomem *fpga) ...@@ -270,10 +259,10 @@ static int pika_dtm_thread(void __iomem *fpga)
} }
found_it: found_it:
i2c_put_adapter(adap);
pika_setup_critical_temp(client); pika_setup_critical_temp(client);
i2c_put_adapter(adap);
printk(KERN_INFO "PIKA DTM thread running.\n"); printk(KERN_INFO "PIKA DTM thread running.\n");
while (!kthread_should_stop()) { while (!kthread_should_stop()) {
...@@ -311,6 +300,9 @@ static int __init pika_dtm_start(void) ...@@ -311,6 +300,9 @@ static int __init pika_dtm_start(void)
if (dtm_fpga == NULL) if (dtm_fpga == NULL)
return -ENOENT; return -ENOENT;
/* Must get post info before thread starts. */
warp_post_info();
dtm_thread = kthread_run(pika_dtm_thread, dtm_fpga, "pika-dtm"); dtm_thread = kthread_run(pika_dtm_thread, dtm_fpga, "pika-dtm");
if (IS_ERR(dtm_thread)) { if (IS_ERR(dtm_thread)) {
iounmap(dtm_fpga); iounmap(dtm_fpga);
...@@ -333,6 +325,8 @@ int pika_dtm_unregister_shutdown(void (*func)(void *arg), void *arg) ...@@ -333,6 +325,8 @@ int pika_dtm_unregister_shutdown(void (*func)(void *arg), void *arg)
return 0; return 0;
} }
machine_late_initcall(warp, warp_post_info);
#endif #endif
EXPORT_SYMBOL(pika_dtm_register_shutdown); EXPORT_SYMBOL(pika_dtm_register_shutdown);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment