2 * Copyright (c) 2019 Justin Hibbits
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #include <sys/cdefs.h>
27 __FBSDID("$FreeBSD$");
29 #include <sys/param.h>
30 #include <sys/systm.h>
31 #include <sys/kernel.h>
33 #include <sys/malloc.h>
36 #include <machine/intr_machdep.h>
37 #include <machine/platform.h>
38 #include <machine/platformvar.h>
40 #include <dev/ofw/openfirm.h>
41 #include <dev/ofw/ofw_bus.h>
43 #include <powerpc/mpc85xx/mpc85xx.h>
45 #include "platform_if.h"
47 static void aeon_pbutton_intr(void *_unused);
48 static void aeon_setup_intr(void *unused);
50 static int aeon_probe(platform_t);
51 static int aeon_attach(platform_t);
53 static platform_method_t aeon_methods[] = {
54 PLATFORMMETHOD(platform_probe, aeon_probe),
55 PLATFORMMETHOD(platform_attach, aeon_attach),
59 DEFINE_CLASS_1(aeon, aeon_platform, aeon_methods, 0, mpc85xx_platform);
61 PLATFORM_DEF(aeon_platform);
66 aeon_probe(platform_t plat)
71 rootnode = OF_finddevice("/");
73 if (OF_getprop(rootnode, "model", model, sizeof(model)) > 0) {
74 if (strncmp(model, "varisys,", strlen("varisys,")) == 0)
75 return (BUS_PROBE_SPECIFIC);
82 aeon_attach(platform_t plat)
86 error = mpc85xx_attach(plat);
95 /* Notify devd(8) that the power button was pressed (IRQ#4 on A-Eon machines). */
97 aeon_pbutton_intr(void *_unused)
99 devctl_notify("AEON", "power", "press", NULL);
102 /* Manually configure the power button IRQ handler. */
104 aeon_setup_intr(void *unused)
112 printf("Configuring AmigaOne power button.\n");
114 irq = 4; /* From TRM, IRQ4 is raised when power button is pressed. */
116 /* Get us the root PIC. */
117 irq = MAP_IRQ(0, irq);
118 powerpc_config_intr(irq, INTR_TRIGGER_EDGE, INTR_POLARITY_LOW);
119 powerpc_setup_intr("power_button", irq, NULL, aeon_pbutton_intr, NULL,
120 INTR_TYPE_MISC, NULL, 0);
123 SYSINIT(aeon_setup_intr, SI_SUB_CONFIGURE, SI_ORDER_ANY, aeon_setup_intr, NULL);