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