Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/arm/marvell Add Thermal Sensor for Kirkwood(88F6282...
details: https://anonhg.NetBSD.org/src/rev/6abffe898fc6
branches: trunk
changeset: 780642:6abffe898fc6
user: kiyohara <kiyohara%NetBSD.org@localhost>
date: Wed Aug 01 10:34:42 2012 +0000
description:
Add Thermal Sensor for Kirkwood(88F6282). tested only OpenBlockS A6.
diffstat:
sys/arch/arm/marvell/kirkwoodreg.h | 7 +-
sys/arch/arm/marvell/mvsoc.c | 5 +-
sys/arch/arm/marvell/mvsocts.c | 129 +++++++++++++++++++++++++++++++++++++
3 files changed, 138 insertions(+), 3 deletions(-)
diffs (180 lines):
diff -r 380f13028339 -r 6abffe898fc6 sys/arch/arm/marvell/kirkwoodreg.h
--- a/sys/arch/arm/marvell/kirkwoodreg.h Wed Aug 01 09:38:55 2012 +0000
+++ b/sys/arch/arm/marvell/kirkwoodreg.h Wed Aug 01 10:34:42 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kirkwoodreg.h,v 1.3 2012/07/21 04:30:34 kiyohara Exp $ */
+/* $NetBSD: kirkwoodreg.h,v 1.4 2012/08/01 10:34:42 kiyohara Exp $ */
/*
* Copyright (c) 2007, 2008 KIYOHARA Takashi
* All rights reserved.
@@ -166,6 +166,11 @@
/*
+ * Kirkwood Thermal Sensor(6282 only)
+ */
+#define KIRKWOOD_TS_BASE (MVSOC_DEVBUS_BASE + 0x0078) /* XXXX: ??? */
+
+/*
* Two-Wire Serial Interface Registers
*/
#define KIRKWOOD_TWSI1_BASE (MVSOC_TWSI_BASE + 0x0100)
diff -r 380f13028339 -r 6abffe898fc6 sys/arch/arm/marvell/mvsoc.c
--- a/sys/arch/arm/marvell/mvsoc.c Wed Aug 01 09:38:55 2012 +0000
+++ b/sys/arch/arm/marvell/mvsoc.c Wed Aug 01 10:34:42 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mvsoc.c,v 1.7 2012/07/23 06:19:04 kiyohara Exp $ */
+/* $NetBSD: mvsoc.c,v 1.8 2012/08/01 10:34:42 kiyohara Exp $ */
/*
* Copyright (c) 2007, 2008 KIYOHARA Takashi
* All rights reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mvsoc.c,v 1.7 2012/07/23 06:19:04 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mvsoc.c,v 1.8 2012/08/01 10:34:42 kiyohara Exp $");
#include "opt_cputypes.h"
#include "opt_mvsoc.h"
@@ -353,6 +353,7 @@
{ KIRKWOOD(88F6282),"mvsoctmr",0, MVSOC_TMR_BASE, IRQ_DEFAULT },
{ KIRKWOOD(88F6282),"mvsocgpp",0, MVSOC_GPP_BASE, KIRKWOOD_IRQ_GPIOLO7_0},
{ KIRKWOOD(88F6282),"mvsocrtc",0, KIRKWOOD_RTC_BASE,IRQ_DEFAULT },
+ { KIRKWOOD(88F6282),"mvsocts", 0, KIRKWOOD_TS_BASE, IRQ_DEFAULT },
{ KIRKWOOD(88F6282),"com", 0, MVSOC_COM0_BASE, KIRKWOOD_IRQ_UART0INT },
{ KIRKWOOD(88F6282),"com", 1, MVSOC_COM1_BASE, KIRKWOOD_IRQ_UART1INT },
{ KIRKWOOD(88F6282),"ehci", 0, KIRKWOOD_USB_BASE,KIRKWOOD_IRQ_USB0CNT },
diff -r 380f13028339 -r 6abffe898fc6 sys/arch/arm/marvell/mvsocts.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/marvell/mvsocts.c Wed Aug 01 10:34:42 2012 +0000
@@ -0,0 +1,129 @@
+/* $NetBSD: mvsocts.c,v 1.1 2012/08/01 10:34:42 kiyohara Exp $ */
+/*
+ * Copyright (c) 2012 KIYOHARA Takashi
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: mvsocts.c,v 1.1 2012/08/01 10:34:42 kiyohara Exp $");
+
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/device.h>
+#include <sys/errno.h>
+
+#include <dev/sysmon/sysmonvar.h>
+
+#include <dev/marvell/marvellvar.h>
+
+#define TS_STATUS 0x0
+#define STATUS_VALID (1 << 9)
+#define STATUS_VAL(v) (((v) >> 10) & 0x1ff)
+
+#define VAL2MCELSIUS(v) (((322 - (v)) * 10000) / 13625)
+
+struct mvsocts_softc {
+ device_t sc_dev;
+
+ struct sysmon_envsys *sc_sme;
+ envsys_data_t sc_sensor;
+
+ bus_space_tag_t sc_iot;
+ bus_space_handle_t sc_ioh;
+};
+
+
+static int mvsocts_match(device_t, struct cfdata *, void *);
+static void mvsocts_attach(device_t, device_t, void *);
+
+static void mvsocts_refresh(struct sysmon_envsys *, envsys_data_t *);
+
+CFATTACH_DECL_NEW(mvsocts, sizeof(struct mvsocts_softc),
+ mvsocts_match, mvsocts_attach, NULL, NULL);
+
+
+/* ARGSUSED */
+static int
+mvsocts_match(device_t parent, struct cfdata *match, void *aux)
+{
+ struct marvell_attach_args *mva = aux;
+
+ if (strcmp(mva->mva_name, match->cf_name) != 0)
+ return 0;
+ return 1;
+}
+
+/* ARGSUSED */
+static void
+mvsocts_attach(device_t parent, device_t self, void *aux)
+{
+ struct mvsocts_softc *sc = device_private(self);
+ struct marvell_attach_args *mva = aux;
+
+ aprint_naive("\n");
+ aprint_normal(": Marvell SoC Thermal Sensor\n");
+
+ sc->sc_dev = self;
+ sc->sc_iot = mva->mva_iot;
+ if (bus_space_subregion(mva->mva_iot, mva->mva_ioh,
+ mva->mva_offset, sizeof(uint32_t), &sc->sc_ioh))
+ panic("%s: Cannot map registers", device_xname(self));
+
+ sc->sc_sme = sysmon_envsys_create();
+ /* Initialize sensor data. */
+ sc->sc_sensor.units = ENVSYS_STEMP;
+ sc->sc_sensor.state = ENVSYS_SINVALID;
+ strlcpy(sc->sc_sensor.desc, device_xname(self),
+ sizeof(sc->sc_sensor.desc));
+ if (sysmon_envsys_sensor_attach(sc->sc_sme, &sc->sc_sensor)) {
+ aprint_error_dev(self, "Unable to attach sysmon\n");
+ sysmon_envsys_destroy(sc->sc_sme);
+ return;
+ }
+
+ /* Hook into system monitor. */
+ sc->sc_sme->sme_name = device_xname(self);
+ sc->sc_sme->sme_cookie = sc;
+ sc->sc_sme->sme_refresh = mvsocts_refresh;
+ if (sysmon_envsys_register(sc->sc_sme)) {
+ aprint_error_dev(self, "Unable to register with sysmon\n");
+ sysmon_envsys_destroy(sc->sc_sme);
+ }
+}
+
+static void
+mvsocts_refresh(struct sysmon_envsys *sme, envsys_data_t *edata)
+{
+ struct mvsocts_softc *sc = sme->sme_cookie;
+ uint32_t val, uc, uk;
+
+ val = bus_space_read_4(sc->sc_iot, sc->sc_ioh, TS_STATUS);
+ if (!(val & STATUS_VALID)) {
+ aprint_error_dev(sc->sc_dev, "status value is invalid\n");
+ return;
+ }
+ uc = VAL2MCELSIUS(STATUS_VAL(val)) * 1000000; /* uC */
+ uk = uc + 273150000; /* convert to uKelvin */
+ sc->sc_sensor.value_cur = uk;
+ sc->sc_sensor.state = ENVSYS_SVALID;
+}
Home |
Main Index |
Thread Index |
Old Index