1 /* $OpenBSD: omap_machdep.c,v 1.12 2017/09/08 05:36:51 deraadt 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 #include <sys/termios.h> 22 23 #include <machine/bus.h> 24 #include <machine/bootconfig.h> 25 26 #include <dev/ic/comreg.h> 27 #include <dev/ic/comvar.h> 28 29 #include <arm/cortex/smc.h> 30 #include <arm/armv7/armv7var.h> 31 #include <arm/mainbus/mainbus.h> 32 #include <armv7/armv7/armv7var.h> 33 #include <armv7/armv7/armv7_machdep.h> 34 35 extern void omap4_smc_call(uint32_t, uint32_t); 36 extern void omdog_reset(void); 37 extern struct board_dev *omap_board_devs(void); 38 extern void omap_board_init(void); 39 40 void 41 omap_platform_smc_write(bus_space_tag_t iot, bus_space_handle_t ioh, 42 bus_size_t off, uint32_t op, uint32_t val) 43 { 44 switch (op) { 45 case 0x100: /* PL310 DEBUG */ 46 case 0x102: /* PL310 CTL */ 47 break; 48 default: 49 panic("platform_smc_write: invalid operation %d", op); 50 } 51 52 omap4_smc_call(op, val); 53 } 54 55 void 56 omap_platform_init_mainbus(struct device *self) 57 { 58 mainbus_legacy_found(self, "cortex"); 59 mainbus_legacy_found(self, "omap"); 60 } 61 62 void 63 omap_platform_watchdog_reset(void) 64 { 65 omdog_reset(); 66 } 67 68 void 69 omap_platform_powerdown(void) 70 { 71 72 } 73 74 void 75 omap_platform_board_init(void) 76 { 77 omap_board_init(); 78 } 79 80 struct armv7_platform omap_platform = { 81 .board_init = omap_platform_board_init, 82 .smc_write = omap_platform_smc_write, 83 .watchdog_reset = omap_platform_watchdog_reset, 84 .powerdown = omap_platform_powerdown, 85 .init_mainbus = omap_platform_init_mainbus, 86 }; 87 88 struct armv7_platform * 89 omap_platform_match(void) 90 { 91 struct board_dev *devs; 92 93 devs = omap_board_devs(); 94 if (devs == NULL) 95 return (NULL); 96 97 omap_platform.devs = devs; 98 return (&omap_platform); 99 } 100