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>
25 static __initdata
struct of_device_id warp_of_bus
[] = {
26 { .compatible
= "ibm,plb4", },
27 { .compatible
= "ibm,opb", },
28 { .compatible
= "ibm,ebc", },
32 static int __init
warp_device_probe(void)
34 of_platform_bus_probe(NULL
, warp_of_bus
, NULL
);
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
) {
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
;
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");
73 np
= of_find_compatible_node(np
, NULL
, "ibm,gpio-440EP");
75 printk(KERN_ERR __FILE__
": Unable to find gpio\n");
79 gpio_base
= of_iomap(np
, 0);
81 if (gpio_base
== NULL
) {
82 printk(KERN_ERR __FILE__
": Unable to map gpio");
87 leds
= in_be32(gpio_base
);
90 case 0: leds
&= ~LED_GREEN
; break;
91 case 1: leds
|= LED_GREEN
; break;
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
);
120 static int __init
pika_dtm_start(void)
122 struct task_struct
*dtm_thread
;
123 struct device_node
*np
;
127 np
= of_find_compatible_node(NULL
, NULL
, "pika,fpga");
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
)) {
140 fpga
= ioremap(res
.start
, 0x24);
144 dtm_thread
= kthread_run(pika_dtm_thread
, fpga
+ 0x20, "pika-dtm");
145 if (IS_ERR(dtm_thread
)) {
147 return PTR_ERR(dtm_thread
);
152 device_initcall(pika_dtm_start
);