docbook: fix fatal rapidio yet again (and more to come)
[linux/fpc-iii.git] / arch / powerpc / platforms / 44x / warp.c
blob39cf6150a72b2701af6eb62348ce364b3d88ce26
1 /*
2 * PIKA Warp(tm) board specific routines
4 * Copyright (c) 2008 PIKA Technologies
5 * Sean MacLennan <smaclennan@pikatech.com>
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
12 #include <linux/init.h>
13 #include <linux/of_platform.h>
14 #include <linux/kthread.h>
16 #include <asm/machdep.h>
17 #include <asm/prom.h>
18 #include <asm/udbg.h>
19 #include <asm/time.h>
20 #include <asm/uic.h>
21 #include <asm/ppc4xx.h>
23 static __initdata struct of_device_id warp_of_bus[] = {
24 { .compatible = "ibm,plb4", },
25 { .compatible = "ibm,opb", },
26 { .compatible = "ibm,ebc", },
27 {},
30 static int __init warp_device_probe(void)
32 of_platform_bus_probe(NULL, warp_of_bus, NULL);
33 return 0;
35 machine_device_initcall(warp, warp_device_probe);
37 static int __init warp_probe(void)
39 unsigned long root = of_get_flat_dt_root();
41 return of_flat_dt_is_compatible(root, "pika,warp");
44 define_machine(warp) {
45 .name = "Warp",
46 .probe = warp_probe,
47 .progress = udbg_progress,
48 .init_IRQ = uic_init_tree,
49 .get_irq = uic_get_irq,
50 .restart = ppc4xx_reset_system,
51 .calibrate_decr = generic_calibrate_decr,
55 #define LED_GREEN (0x80000000 >> 0)
56 #define LED_RED (0x80000000 >> 1)
59 /* This is for the power LEDs 1 = on, 0 = off, -1 = leave alone */
60 void warp_set_power_leds(int green, int red)
62 static void __iomem *gpio_base = NULL;
63 unsigned leds;
65 if (gpio_base == NULL) {
66 struct device_node *np;
68 /* Power LEDS are on the second GPIO controller */
69 np = of_find_compatible_node(NULL, NULL, "ibm,gpio-440EP");
70 if (np)
71 np = of_find_compatible_node(np, NULL, "ibm,gpio-440EP");
72 if (np == NULL) {
73 printk(KERN_ERR __FILE__ ": Unable to find gpio\n");
74 return;
77 gpio_base = of_iomap(np, 0);
78 of_node_put(np);
79 if (gpio_base == NULL) {
80 printk(KERN_ERR __FILE__ ": Unable to map gpio");
81 return;
85 leds = in_be32(gpio_base);
87 switch (green) {
88 case 0: leds &= ~LED_GREEN; break;
89 case 1: leds |= LED_GREEN; break;
91 switch (red) {
92 case 0: leds &= ~LED_RED; break;
93 case 1: leds |= LED_RED; break;
96 out_be32(gpio_base, leds);
98 EXPORT_SYMBOL(warp_set_power_leds);
101 #ifdef CONFIG_SENSORS_AD7414
102 static int pika_dtm_thread(void __iomem *fpga)
104 extern int ad7414_get_temp(int index);
106 while (!kthread_should_stop()) {
107 int temp = ad7414_get_temp(0);
109 out_be32(fpga, temp);
111 set_current_state(TASK_INTERRUPTIBLE);
112 schedule_timeout(HZ);
115 return 0;
118 static int __init pika_dtm_start(void)
120 struct task_struct *dtm_thread;
121 struct device_node *np;
122 struct resource res;
123 void __iomem *fpga;
125 np = of_find_compatible_node(NULL, NULL, "pika,fpga");
126 if (np == NULL)
127 return -ENOENT;
129 /* We do not call of_iomap here since it would map in the entire
130 * fpga space, which is over 8k.
132 if (of_address_to_resource(np, 0, &res)) {
133 of_node_put(np);
134 return -ENOENT;
136 of_node_put(np);
138 fpga = ioremap(res.start, 0x24);
139 if (fpga == NULL)
140 return -ENOENT;
142 dtm_thread = kthread_run(pika_dtm_thread, fpga + 0x20, "pika-dtm");
143 if (IS_ERR(dtm_thread)) {
144 iounmap(fpga);
145 return PTR_ERR(dtm_thread);
148 return 0;
150 device_initcall(pika_dtm_start);
151 #endif