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