diff options
author | Paul Irofti <pirofti@cvs.openbsd.org> | 2013-01-14 21:18:48 +0000 |
---|---|---|
committer | Paul Irofti <pirofti@cvs.openbsd.org> | 2013-01-14 21:18:48 +0000 |
commit | f0178e58b56f0f2bcbbaa3ecd0715902fe2b8b8b (patch) | |
tree | 03ee409b4af575adf7440ca36934b3a283a2947b /sys/dev | |
parent | b5f4d8317383c4b5408a9c6bffcf5a50c557122f (diff) |
Loongson: Replace the system clock provided by the CPU with a GLX MFGPT.
CPU throttling was not possible due to the fact that the system clock
was the CPU clock. So slowing down the CPU would also slow down the
passing of time.
This commit adds a driver for the MFGPT1 clock from the AMD companion
chip found on lemote and hooks it up as the system clock.
It also changes the frequency value of hz from the default, which was
100, to 128. That's because the scaling on MFGPT clocks is represented
by powers of two.
Okay miod@.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/pci/files.pci | 4 | ||||
-rw-r--r-- | sys/dev/pci/glxpcib.c | 49 | ||||
-rw-r--r-- | sys/dev/pci/glxvar.h | 10 |
3 files changed, 58 insertions, 5 deletions
diff --git a/sys/dev/pci/files.pci b/sys/dev/pci/files.pci index b4af38167a9..a9359be20c1 100644 --- a/sys/dev/pci/files.pci +++ b/sys/dev/pci/files.pci @@ -1,4 +1,4 @@ -# $OpenBSD: files.pci,v 1.291 2013/01/12 13:02:22 sf Exp $ +# $OpenBSD: files.pci,v 1.292 2013/01/14 21:18:47 pirofti Exp $ # $NetBSD: files.pci,v 1.20 1996/09/24 17:47:15 christos Exp $ # # Config file and device description for machine-independent PCI code. @@ -819,7 +819,7 @@ attach itherm at pci file dev/pci/itherm.c itherm # AMD Geode CS5536 PCI-ISA bridge -device glxpcib: isabus, gpiobus, i2cbus +device glxpcib{}: isabus, gpiobus, i2cbus attach glxpcib at pci file dev/pci/glxpcib.c glxpcib diff --git a/sys/dev/pci/glxpcib.c b/sys/dev/pci/glxpcib.c index 9f89180cde7..5ae0ef9978e 100644 --- a/sys/dev/pci/glxpcib.c +++ b/sys/dev/pci/glxpcib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: glxpcib.c,v 1.7 2012/10/17 22:32:01 deraadt Exp $ */ +/* $OpenBSD: glxpcib.c,v 1.8 2013/01/14 21:18:47 pirofti Exp $ */ /* * Copyright (c) 2007 Marc Balmer <mbalmer@openbsd.org> @@ -211,6 +211,8 @@ struct cfdriver glxpcib_cd = { int glxpcib_match(struct device *, void *, void *); void glxpcib_attach(struct device *, struct device *, void *); int glxpcib_activate(struct device *, int); +int glxpcib_search(struct device *, void *, void *); +int glxpcib_print(void *, const char *); struct cfattach glxpcib_ca = { sizeof(struct glxpcib_softc), glxpcib_match, glxpcib_attach, @@ -300,7 +302,8 @@ glxpcib_attach(struct device *parent, struct device *self, void *aux) /* count in seconds (as upper level desires) */ bus_space_write_2(sc->sc_iot, sc->sc_ioh, AMD5536_MFGPT0_SETUP, AMD5536_MFGPT_CNT_EN | AMD5536_MFGPT_CMP2EV | - AMD5536_MFGPT_CMP2 | AMD5536_MFGPT_DIV_MASK); + AMD5536_MFGPT_CMP2 | AMD5536_MFGPT_DIV_MASK | + AMD5536_MFGPT_STOP_EN); wdog_register(glxpcib_wdogctl_cb, sc); sc->sc_wdog = 1; printf(", watchdog"); @@ -396,6 +399,8 @@ glxpcib_attach(struct device *parent, struct device *self, void *aux) if (i2c) config_found(&sc->sc_dev, &iba, iicbus_print); #endif + + config_search(glxpcib_search, self, pa); } int @@ -684,6 +689,46 @@ glxpcib_smb_read_byte(void *arg, uint8_t *bytep, int flags) } int +glxpcib_print(void *args, const char *parentname) +{ + struct glxpcib_attach_args *gaa = (struct glxpcib_attach_args *)args; + + if (parentname != NULL) + printf("%s at %s", gaa->gaa_name, parentname); + + return UNCONF; +} + +int +glxpcib_search(struct device *parent, void *gcf, void *args) +{ + struct glxpcib_softc *sc = (struct glxpcib_softc *)parent; + struct cfdata *cf = (struct cfdata *)gcf; + struct pci_attach_args *pa = (struct pci_attach_args *)args; + struct glxpcib_attach_args gaa; + + gaa.gaa_name = cf->cf_driver->cd_name; + gaa.gaa_pa = pa; + gaa.gaa_iot = sc->sc_iot; + gaa.gaa_ioh = sc->sc_ioh; + + /* + * These devices are attached directly, either from + * glxpcib_attach() or later in time from pcib_callback(). + */ + if (strcmp(cf->cf_driver->cd_name, "gpio") == 0 || + strcmp(cf->cf_driver->cd_name, "iic") == 0 || + strcmp(cf->cf_driver->cd_name, "isa") == 0) + return 0; + + if (cf->cf_attach->ca_match(parent, cf, &gaa) == 0) + return 0; + + config_attach(parent, cf, &gaa, glxpcib_print); + return 1; +} + +int glxpcib_smb_write_byte(void *arg, uint8_t byte, int flags) { struct glxpcib_softc *sc = arg; diff --git a/sys/dev/pci/glxvar.h b/sys/dev/pci/glxvar.h index 93c80a7ccba..2eef5ced737 100644 --- a/sys/dev/pci/glxvar.h +++ b/sys/dev/pci/glxvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: glxvar.h,v 1.1 2010/10/14 21:23:05 pirofti Exp $ */ +/* $OpenBSD: glxvar.h,v 1.2 2013/01/14 21:18:47 pirofti Exp $ */ /* * Copyright (c) 2009 Miodrag Vallat. @@ -20,3 +20,11 @@ void glx_init(pci_chipset_tag_t, pcitag_t, int); uint64_t rdmsr(uint); void wrmsr(uint, uint64_t); + +struct glxpcib_attach_args { + const char *gaa_name; + + struct pci_attach_args *gaa_pa; + bus_space_tag_t gaa_iot; + bus_space_handle_t gaa_ioh; +}; |