Committer: Michael Beasley <mike@snafu.setup>
[mikesnafu-overlay.git] / arch / powerpc / platforms / 44x / warp.c
blobda5b7b7599dbc3d0a19b649630d8e2d6fcc739ae
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>
22 #include "44x.h"
25 static __initdata struct of_device_id warp_of_bus[] = {
26 { .compatible = "ibm,plb4", },
27 { .compatible = "ibm,opb", },
28 { .compatible = "ibm,ebc", },
29 {},
32 static int __init warp_device_probe(void)
34 of_platform_bus_probe(NULL, warp_of_bus, NULL);
35 return 0;
37 machine_device_initcall(warp, warp_device_probe);
39 static int __init warp_probe(void)
41 unsigned long root = of_get_flat_dt_root();
43 return of_flat_dt_is_compatible(root, "pika,warp");
46 define_machine(warp) {
47 .name = "Warp",
48 .probe = warp_probe,
49 .progress = udbg_progress,
50 .init_IRQ = uic_init_tree,
51 .get_irq = uic_get_irq,
52 .restart = ppc44x_reset_system,
53 .calibrate_decr = generic_calibrate_decr,
57 #define LED_GREEN (0x80000000 >> 0)
58 #define LED_RED (0x80000000 >> 1)
61 /* This is for the power LEDs 1 = on, 0 = off, -1 = leave alone */
62 void warp_set_power_leds(int green, int red)
64 static void __iomem *gpio_base = NULL;
65 unsigned leds;
67 if (gpio_base == NULL) {
68 struct device_node *np;
70 /* Power LEDS are on the second GPIO controller */
71 np = of_find_compatible_node(NULL, NULL, "ibm,gpio-440EP");
72 if (np)
73 np = of_find_compatible_node(np, NULL, "ibm,gpio-440EP");
74 if (np == NULL) {
75 printk(KERN_ERR __FILE__ ": Unable to find gpio\n");
76 return;
79 gpio_base = of_iomap(np, 0);
80 of_node_put(np);
81 if (gpio_base == NULL) {
82 printk(KERN_ERR __FILE__ ": Unable to map gpio");
83 return;
87 leds = in_be32(gpio_base);
89 switch (green) {
90 case 0: leds &= ~LED_GREEN; break;
91 case 1: leds |= LED_GREEN; break;
93 switch (red) {
94 case 0: leds &= ~LED_RED; break;
95 case 1: leds |= LED_RED; break;
98 out_be32(gpio_base, leds);
100 EXPORT_SYMBOL(warp_set_power_leds);
103 #ifdef CONFIG_SENSORS_AD7414
104 static int pika_dtm_thread(void __iomem *fpga)
106 extern int ad7414_get_temp(int index);
108 while (!kthread_should_stop()) {
109 int temp = ad7414_get_temp(0);
111 out_be32(fpga, temp);
113 set_current_state(TASK_INTERRUPTIBLE);
114 schedule_timeout(HZ);
117 return 0;
120 static int __init pika_dtm_start(void)
122 struct task_struct *dtm_thread;
123 struct device_node *np;
124 struct resource res;
125 void __iomem *fpga;
127 np = of_find_compatible_node(NULL, NULL, "pika,fpga");
128 if (np == NULL)
129 return -ENOENT;
131 /* We do not call of_iomap here since it would map in the entire
132 * fpga space, which is over 8k.
134 if (of_address_to_resource(np, 0, &res)) {
135 of_node_put(np);
136 return -ENOENT;
138 of_node_put(np);
140 fpga = ioremap(res.start, 0x24);
141 if (fpga == NULL)
142 return -ENOENT;
144 dtm_thread = kthread_run(pika_dtm_thread, fpga + 0x20, "pika-dtm");
145 if (IS_ERR(dtm_thread)) {
146 iounmap(fpga);
147 return PTR_ERR(dtm_thread);
150 return 0;
152 device_initcall(pika_dtm_start);
153 #endif