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>
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", },
30 static int __init warp_device_probe(void)
32 of_platform_bus_probe(NULL, warp_of_bus, NULL);
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) {
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;
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");
71 np = of_find_compatible_node(np, NULL, "ibm,gpio-440EP");
73 printk(KERN_ERR __FILE__ ": Unable to find gpio\n");
77 gpio_base = of_iomap(np, 0);
79 if (gpio_base == NULL) {
80 printk(KERN_ERR __FILE__ ": Unable to map gpio");
85 leds = in_be32(gpio_base);
88 case 0: leds &= ~LED_GREEN; break;
89 case 1: leds |= LED_GREEN; break;
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);
118 static int __init pika_dtm_start(void)
120 struct task_struct *dtm_thread;
121 struct device_node *np;
125 np = of_find_compatible_node(NULL, NULL, "pika,fpga");
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)) {
138 fpga = ioremap(res.start, 0x24);
142 dtm_thread = kthread_run(pika_dtm_thread, fpga + 0x20, "pika-dtm");
143 if (IS_ERR(dtm_thread)) {
145 return PTR_ERR(dtm_thread);
150 device_initcall(pika_dtm_start);