1 /* $OpenBSD: omapid.c,v 1.2 2013/11/06 19:03:07 syl Exp $ */
3 * Copyright (c) 2013 Dale Rahn <drahn@dalerahn.com>
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.
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.
18 #include <sys/param.h>
19 #include <sys/systm.h>
20 #include <sys/queue.h>
21 #include <sys/malloc.h>
22 #include <sys/device.h>
23 #include <sys/evcount.h>
24 #include <sys/socket.h>
25 #include <sys/timeout.h>
26 #include <machine/intr.h>
27 #include <machine/bus.h>
28 #include <armv7/armv7/armv7var.h>
31 #define O4_ID_SIZE 0x1000
32 #define O4_FUSE_ID0 0x200
33 #define O4_ID_CODE 0x204
34 #define O4_FUSE_ID1 0x208
35 #define O4_FUSE_ID2 0x20C
36 #define O4_FUSE_ID3 0x210
37 #define O4_FUSE_PRODID0 0x214
38 #define O4_FUSE_PRODID1 0x218
43 bus_space_tag_t sc_iot
;
44 bus_space_handle_t sc_ioh
;
47 struct omapid_softc
*omapid_sc
;
50 void omapid_attach(struct device
*parent
, struct device
*self
, void *args
);
51 void omapid_wpending(int flags
);
53 struct cfattach omapid_ca
= {
54 sizeof (struct omapid_softc
), NULL
, omapid_attach
57 struct cfdriver omapid_cd
= {
58 NULL
, "omapid", DV_DULL
61 void amptimer_set_clockrate(int32_t new_frequency
); /* XXX */
64 omapid_attach(struct device
*parent
, struct device
*self
, void *args
)
66 struct armv7_attach_args
*aa
= args
;
67 struct omapid_softc
*sc
= (struct omapid_softc
*) self
;
69 uint32_t newclockrate
= 0;
72 sc
->sc_iot
= aa
->aa_iot
;
73 if (bus_space_map(sc
->sc_iot
, aa
->aa_dev
->mem
[0].addr
,
74 aa
->aa_dev
->mem
[0].size
, 0, &sc
->sc_ioh
))
75 panic("omapid: bus_space_map failed!");
81 case BOARD_ID_OMAP4_PANDA
:
82 rev
= bus_space_read_4(sc
->sc_iot
, sc
->sc_ioh
, O4_ID_CODE
);
83 switch ((rev
>> 12) & 0xffff) {
87 newclockrate
= 400 * 1000 * 1000;
91 newclockrate
= 350 * 1000 * 1000;
98 printf(": %s\n", board
);
99 if (newclockrate
!= 0)
100 amptimer_set_clockrate(newclockrate
);