cf3c20ae |
1 | /* $OpenBSD: omap_machdep.c,v 1.6 2015/05/19 03:30:54 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 <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 char *omap_board_name(void); |
38 | extern struct board_dev *omap_board_devs(void); |
39 | extern void omap_board_init(void); |
40 | extern int comcnspeed; |
41 | extern int comcnmode; |
42 | |
43 | void |
44 | omap_platform_smc_write(bus_space_tag_t iot, bus_space_handle_t ioh, |
45 | bus_size_t off, uint32_t op, uint32_t val) |
46 | { |
47 | switch (op) { |
48 | case 0x100: /* PL310 DEBUG */ |
49 | case 0x102: /* PL310 CTL */ |
50 | break; |
51 | default: |
52 | panic("platform_smc_write: invalid operation %d", op); |
53 | } |
54 | |
55 | omap4_smc_call(op, val); |
56 | } |
57 | |
58 | void |
59 | omap_platform_init_cons(void) |
60 | { |
61 | paddr_t paddr; |
62 | |
63 | switch (board_id) { |
64 | case BOARD_ID_OMAP3_BEAGLE: |
65 | case BOARD_ID_OMAP3_OVERO: |
66 | paddr = 0x49020000; |
67 | break; |
68 | case BOARD_ID_AM335X_BEAGLEBONE: |
69 | paddr = 0x44e09000; |
70 | break; |
71 | case BOARD_ID_OMAP4_PANDA: |
72 | paddr = 0x48020000; |
73 | break; |
74 | } |
75 | |
76 | comcnattach(&armv7_a4x_bs_tag, paddr, comcnspeed, 48000000, comcnmode); |
77 | comdefaultrate = comcnspeed; |
78 | } |
79 | |
80 | void |
81 | omap_platform_watchdog_reset(void) |
82 | { |
83 | omdog_reset(); |
84 | } |
85 | |
86 | void |
87 | omap_platform_powerdown(void) |
88 | { |
89 | |
90 | } |
91 | |
92 | const char * |
93 | omap_platform_board_name(void) |
94 | { |
95 | return (omap_board_name()); |
96 | } |
97 | |
98 | void |
99 | omap_platform_disable_l2_if_needed(void) |
100 | { |
101 | switch (board_id) { |
102 | case BOARD_ID_OMAP4_PANDA: |
103 | /* disable external L2 cache */ |
104 | omap4_smc_call(0x102, 0); |
105 | break; |
106 | } |
107 | } |
108 | |
109 | void |
110 | omap_platform_board_init(void) |
111 | { |
112 | omap_board_init(); |
113 | } |
114 | |
115 | struct armv7_platform omap_platform = { |
116 | .boot_name = "OpenBSD/omap", |
117 | .board_name = omap_platform_board_name, |
118 | .board_init = omap_platform_board_init, |
119 | .smc_write = omap_platform_smc_write, |
120 | .init_cons = omap_platform_init_cons, |
121 | .watchdog_reset = omap_platform_watchdog_reset, |
122 | .powerdown = omap_platform_powerdown, |
123 | .disable_l2_if_needed = omap_platform_disable_l2_if_needed, |
124 | }; |
125 | |
126 | struct armv7_platform * |
127 | omap_platform_match(void) |
128 | { |
129 | struct board_dev *devs; |
130 | |
131 | devs = omap_board_devs(); |
132 | if (devs == NULL) |
133 | return (NULL); |
134 | |
135 | omap_platform.devs = devs; |
136 | return (&omap_platform); |
137 | } |