1 /* $OpenBSD: omap_machdep.c,v 1.13 2021/03/25 04:12:01 jsg Exp $ */
2 /*
3 * Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18 #include <sys/param.h>
19 #include <sys/device.h>
20 #include <sys/systm.h>
21
22 #include <machine/bus.h>
23
24 #include <arm/mainbus/mainbus.h>
25 #include <armv7/armv7/armv7_machdep.h>
26
27 extern void omap4_smc_call(uint32_t, uint32_t);
28 extern void omdog_reset(void);
29 extern struct board_dev *omap_board_devs(void);
30 extern void omap_board_init(void);
31
32 void
omap_platform_smc_write(bus_space_tag_t iot,bus_space_handle_t ioh,bus_size_t off,uint32_t op,uint32_t val)33 omap_platform_smc_write(bus_space_tag_t iot, bus_space_handle_t ioh,
34 bus_size_t off, uint32_t op, uint32_t val)
35 {
36 switch (op) {
37 case 0x100: /* PL310 DEBUG */
38 case 0x102: /* PL310 CTL */
39 break;
40 default:
41 panic("platform_smc_write: invalid operation %d", op);
42 }
43
44 omap4_smc_call(op, val);
45 }
46
47 void
omap_platform_init_mainbus(struct device * self)48 omap_platform_init_mainbus(struct device *self)
49 {
50 mainbus_legacy_found(self, "cortex");
51 mainbus_legacy_found(self, "omap");
52 }
53
54 void
omap_platform_watchdog_reset(void)55 omap_platform_watchdog_reset(void)
56 {
57 omdog_reset();
58 }
59
60 void
omap_platform_powerdown(void)61 omap_platform_powerdown(void)
62 {
63
64 }
65
66 void
omap_platform_board_init(void)67 omap_platform_board_init(void)
68 {
69 omap_board_init();
70 }
71
72 struct armv7_platform omap_platform = {
73 .board_init = omap_platform_board_init,
74 .smc_write = omap_platform_smc_write,
75 .watchdog_reset = omap_platform_watchdog_reset,
76 .powerdown = omap_platform_powerdown,
77 .init_mainbus = omap_platform_init_mainbus,
78 };
79
80 struct armv7_platform *
omap_platform_match(void)81 omap_platform_match(void)
82 {
83 struct board_dev *devs;
84
85 devs = omap_board_devs();
86 if (devs == NULL)
87 return (NULL);
88
89 omap_platform.devs = devs;
90 return (&omap_platform);
91 }
92