File: [local] / sys / dev / acpi / acpihpet.c (download)
Revision 1.1.1.1 (vendor branch), Tue Mar 4 16:14:48 2008 UTC (16 years, 4 months ago) by nbrk
Branch: OPENBSD_4_2_BASE, MAIN
CVS Tags: jornada-partial-support-wip, HEAD Changes since 1.1: +0 -0 lines
Import of OpenBSD 4.2 release kernel tree with initial code to support
Jornada 720/728, StrongARM 1110-based handheld PC.
At this point kernel roots on NFS and boots into vfs_mountroot() and traps.
What is supported:
- glass console, Jornada framebuffer (jfb) works in 16bpp direct color mode
(needs some palette tweaks for non black/white/blue colors, i think)
- saic, SA11x0 interrupt controller (needs cleanup)
- sacom, SA11x0 UART (supported only as boot console for now)
- SA11x0 GPIO controller fully supported (but can't handle multiple interrupt
handlers on one gpio pin)
- sassp, SSP port on SA11x0 that attaches spibus
- Jornada microcontroller (jmcu) to control kbd, battery, etc throught
the SPI bus (wskbd attaches on jmcu, but not tested)
- tod functions seem work
- initial code for SA-1111 (chip companion) : this is TODO
Next important steps, i think:
- gpio and intc on sa1111
- pcmcia support for sa11x0 (and sa1111 help logic)
- REAL root on nfs when we have PCMCIA support (we may use any of supported pccard NICs)
- root on wd0! (using already supported PCMCIA-ATA)
|
/* $OpenBSD: acpihpet.c,v 1.4 2007/02/20 23:54:46 marco Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/malloc.h>
#ifdef __HAVE_TIMECOUNTER
#include <sys/timetc.h>
#endif
#include <machine/bus.h>
#include <dev/acpi/acpireg.h>
#include <dev/acpi/acpivar.h>
#include <dev/acpi/acpidev.h>
int acpihpet_match(struct device *, void *, void *);
void acpihpet_attach(struct device *, struct device *, void *);
#ifdef __HAVE_TIMECOUNTER
u_int acpihpet_gettime(struct timecounter *tc);
static struct timecounter hpet_timecounter = {
acpihpet_gettime, /* get_timecount */
0, /* no poll_pps */
0xffffffff, /* counter_mask (24 bits) */
0, /* frequency */
0, /* name */
1000 /* quality */
};
#endif
struct acpihpet_softc {
struct device sc_dev;
bus_space_tag_t sc_iot;
bus_space_handle_t sc_ioh;
};
struct cfattach acpihpet_ca = {
sizeof(struct acpihpet_softc), acpihpet_match, acpihpet_attach
};
struct cfdriver acpihpet_cd = {
NULL, "acpihpet", DV_DULL
};
int
acpihpet_match(struct device *parent, void *match, void *aux)
{
struct acpi_attach_args *aaa = aux;
struct acpi_table_header *hdr;
/*
* If we do not have a table, it is not us
*/
if (aaa->aaa_table == NULL)
return (0);
/*
* If it is an HPET table, we can attach
*/
hdr = (struct acpi_table_header *)aaa->aaa_table;
if (memcmp(hdr->signature, HPET_SIG, sizeof(HPET_SIG) - 1) != 0)
return (0);
return (1);
}
void
acpihpet_attach(struct device *parent, struct device *self, void *aux)
{
struct acpihpet_softc *sc = (struct acpihpet_softc *) self;
struct acpi_softc *psc = (struct acpi_softc *)parent;
struct acpi_attach_args *aaa = aux;
struct acpi_hpet *hpet = (struct acpi_hpet *)aaa->aaa_table;
u_int64_t period, freq; /* timer period in femtoseconds (10^-15) */
if (acpi_map_address(psc, &hpet->base_address, 0, HPET_REG_SIZE,
&sc->sc_ioh, &sc->sc_iot)) {
printf(": can't map i/o space\n");
return;
}
period = bus_space_read_4(sc->sc_iot, sc->sc_ioh,
HPET_CAPABILITIES + sizeof(u_int32_t));
freq = 1000000000000000ull / period;
printf(": %lld Hz\n", freq);
#ifdef __HAVE_TIMECOUNTER
hpet_timecounter.tc_frequency = (u_int32_t)freq;
hpet_timecounter.tc_priv = sc;
hpet_timecounter.tc_name = sc->sc_dev.dv_xname;
bus_space_write_4(sc->sc_iot, sc->sc_ioh, HPET_CONFIGURATION, 1);
tc_init(&hpet_timecounter);
#endif
}
#ifdef __HAVE_TIMECOUNTER
u_int
acpihpet_gettime(struct timecounter *tc)
{
struct acpihpet_softc *sc = tc->tc_priv;
return (bus_space_read_4(sc->sc_iot, sc->sc_ioh, HPET_MAIN_COUNTER));
}
#endif