Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Rewrite the aibs(4) driver in order to support new models. D...



details:   https://anonhg.NetBSD.org/src/rev/d647c7aca686
branches:  trunk
changeset: 765987:d647c7aca686
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Sun Jun 12 07:25:43 2011 +0000

description:
Rewrite the aibs(4) driver in order to support new models. Draws from the
revision 1.6 (claudio@) of the OpenBSD's equivalent driver. Tested by mrg@.

diffstat:

 share/man/man4/aibs.4     |   76 ++--
 sys/dev/acpi/aibs_acpi.c  |  742 ++++++++++++++++++++++++++++++++++++++++++++++
 sys/dev/acpi/atk0110.c    |  458 ----------------------------
 sys/dev/acpi/files.acpi   |    6 +-
 sys/modules/aibs/Makefile |    4 +-
 5 files changed, 785 insertions(+), 501 deletions(-)

diffs (truncated from 1396 to 300 lines):

diff -r b741230c5196 -r d647c7aca686 share/man/man4/aibs.4
--- a/share/man/man4/aibs.4     Sun Jun 12 07:19:49 2011 +0000
+++ b/share/man/man4/aibs.4     Sun Jun 12 07:25:43 2011 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: aibs.4,v 1.6 2010/03/06 19:53:33 cnst Exp $
+.\"    $NetBSD: aibs.4,v 1.7 2011/06/12 07:25:43 jruoho Exp $
 .\"    $OpenBSD: aibs.4,v 1.4 2009/07/30 06:30:45 jmc Exp $
 .\"
 .\" Copyright (c) 2009 Constantine A. Murenin <cnst+netbsd%bugmail.mojo.ru@localhost>
@@ -15,24 +15,21 @@
 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 .\"
-.Dd February 8, 2010
+.Dd June 12, 2011
 .Dt AIBS 4
 .Os
 .Sh NAME
 .Nm aibs
-.Nd ASUSTeK AI Booster ACPI ATK0110 voltage, temperature, and fan sensor
+.Nd ASUSTeK AI Booster voltage, temperature, and fan sensor
 .Sh SYNOPSIS
 .Cd "aibs* at acpi?"
 .Sh DESCRIPTION
 The
 .Nm
-driver provides support for the voltage, temperature and fan sensors
-available through the
-.Tn ATK0110
-.Tn ASOC
+driver provides support for voltage, temperature, and fan sensors
+available as an
 .Tn ACPI
-device
-on
+device on
 .Tn ASUSTeK
 motherboards.
 The number of sensors of each type,
@@ -53,43 +50,43 @@
 .Bl -bullet
 .It
 Voltage sensors can have a state of
-.Dv valid ,
-.Dv critunder ,
+.Sq valid ,
+.Sq critunder ,
 or
-.Dv critover ;
+.Sq critover ;
 temperature sensors can have a state of
-.Dv valid ,
-.Dv warnover ,
-.Dv critover ,
+.Sq valid ,
+.Sq warnover ,
+.Sq critover ,
 or
-.Dv invalid ;
+.Sq invalid ;
 and fan sensors can have a state of
-.Dv valid ,
-.Dv warnunder ,
+.Sq valid ,
+.Sq warnunder ,
 or
-.Dv warnover .
+.Sq warnover .
 .It
 Temperature sensors that have a reading of 0
 are marked
-.Dv invalid ,
+.Sq invalid ,
 whereas all other sensors are always assumed valid.
 .It
-Voltage sensors have a lower and an upper limit
-.Dv ( critunder
+Voltage sensors have a lower and an upper limit,
+.Sq critunder
 and
-.Dv critover ) ,
-temperature sensors have two upper limits
-.Dv ( warnover
+.Sq critover ,
+temperature sensors have two upper limits,
+.Sq warnover
 and
-.Dv critover ) ,
+.Sq critover ,
 whereas fan sensors may either have only the lower limit
-.Dv ( warnunder ) ,
-or, depending on the
-.Tn DSDT ,
-one lower and one upper limit
-.Dv ( warnunder
+.Sq warnunder ,
+or, depending on the vendor's
+.Tn ACPI
+implementation, one lower and one upper limit,
+.Sq warnunder
 and
-.Dv warnover ) .
+.Sq warnover .
 .El
 .Pp
 Sensor values and limits are made available through the
@@ -189,6 +186,7 @@
 the hardware monitoring chip through
 .Tn ACPI .
 .Sh SEE ALSO
+.Xr acpi 4 ,
 .Xr envsys 4 ,
 .Xr envstat 8
 .Sh HISTORY
@@ -199,8 +197,7 @@
 DragonFly 2.4.1
 and
 .Nx 6.0 .
-.Pp
-An earlier version of the driver,
+An earlier version of the driver, named
 .Nm aiboost ,
 first appeared in
 .Fx 7.0
@@ -212,16 +209,19 @@
 .Nm
 driver was written for
 .Ox ,
-DragonFly
-and
+DragonFly BSD, and
 .Nx
 by
 .An Constantine A. Murenin Aq http://cnst.su/ ,
 Raouf Boutaba Research Group,
 David R. Cheriton School of Computer Science,
 University of Waterloo.
-.Pp
-An earlier version of the driver, named
+.An Jukka Ruohonen
+.Aq jruohonen%iki.fi@localhost
+later reworked and adjusted the driver to support new
+.Tn ASUSTeK
+motherboards.
+The earlier version of the driver,
 .Nm aiboost ,
 was written for
 .Fx
diff -r b741230c5196 -r d647c7aca686 sys/dev/acpi/aibs_acpi.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/acpi/aibs_acpi.c  Sun Jun 12 07:25:43 2011 +0000
@@ -0,0 +1,742 @@
+/* $NetBSD: aibs_acpi.c,v 1.1 2011/06/12 07:25:43 jruoho Exp $ */
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jukka Ruohonen.
+ *
+ * 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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.
+ */
+
+/*     $OpenBSD: atk0110.c,v 1.1 2009/07/23 01:38:16 cnst Exp $        */
+/*
+ * Copyright (c) 2009 Constantine A. Murenin <cnst+netbsd%bugmail.mojo.ru@localhost>
+ *
+ * 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/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: aibs_acpi.c,v 1.1 2011/06/12 07:25:43 jruoho Exp $");
+
+#include <sys/param.h>
+#include <sys/kmem.h>
+#include <sys/module.h>
+
+#include <dev/acpi/acpireg.h>
+#include <dev/acpi/acpivar.h>
+
+/*
+ * ASUSTeK AI Booster (ACPI ASOC ATK0110).
+ *
+ * This code was originally written for OpenBSD after the techniques
+ * described in the Linux's asus_atk0110.c and FreeBSD's acpi_aiboost.c
+ * were verified to be accurate on the actual hardware kindly provided by
+ * Sam Fourman Jr.  It was subsequently ported from OpenBSD to DragonFly BSD,
+ * and then to the NetBSD's sysmon_envsys(9) framework.
+ *
+ *                               -- Constantine A. Murenin <http://cnst.su/>
+ */
+
+#define _COMPONENT              ACPI_RESOURCE_COMPONENT
+ACPI_MODULE_NAME                ("acpi_aibs")
+
+#define AIBS_MUX_HWMON          0x00000006
+#define AIBS_MUX_MGMT           0x00000011
+
+#define AIBS_TYPE(x)            (((x) >> 16) & 0xff)
+#define AIBS_TYPE_VOLT          2
+#define AIBS_TYPE_TEMP          3
+#define AIBS_TYPE_FAN           4
+
+struct aibs_sensor {
+       envsys_data_t                    as_sensor;
+       uint64_t                         as_type;
+       uint64_t                         as_liml;
+       uint64_t                         as_limh;
+
+       SIMPLEQ_ENTRY(aibs_sensor)       as_list;
+};
+
+struct aibs_softc {
+       device_t                         sc_dev;
+       struct acpi_devnode             *sc_node;
+       struct sysmon_envsys            *sc_sme;
+       bool                             sc_model;      /* new model = true */
+
+       SIMPLEQ_HEAD(, aibs_sensor)      as_head;
+};
+
+static int     aibs_match(device_t, cfdata_t, void *);
+static void    aibs_attach(device_t, device_t, void *);
+static int     aibs_detach(device_t, int);
+
+static void    aibs_init(device_t);
+static void    aibs_init_new(device_t);
+static void    aibs_init_old(device_t, int);
+
+static void    aibs_sensor_add(device_t, ACPI_OBJECT *);
+static bool    aibs_sensor_value(device_t, struct aibs_sensor *, uint64_t *);
+static void    aibs_sensor_refresh(struct sysmon_envsys *, envsys_data_t *);
+static void    aibs_sensor_limits(struct sysmon_envsys *, envsys_data_t *,
+                                  sysmon_envsys_lim_t *, uint32_t *);
+
+CFATTACH_DECL_NEW(aibs, sizeof(struct aibs_softc),
+    aibs_match, aibs_attach, aibs_detach, NULL);
+
+static const char* const aibs_hid[] = {
+       "ATK0110",
+       NULL
+};
+
+static int
+aibs_match(device_t parent, cfdata_t match, void *aux)
+{
+       struct acpi_attach_args *aa = aux;
+
+       if (aa->aa_node->ad_type != ACPI_TYPE_DEVICE)
+               return 0;
+
+       return acpi_match_hid(aa->aa_node->ad_devinfo, aibs_hid);
+}
+
+static void
+aibs_attach(device_t parent, device_t self, void *aux)
+{
+       struct aibs_softc *sc = device_private(self);
+       struct acpi_attach_args *aa = aux;
+
+       sc->sc_dev = self;
+       sc->sc_node = aa->aa_node;
+
+       aprint_naive("\n");
+       aprint_normal(": ASUSTeK AI Booster\n");
+
+       sc->sc_sme = sysmon_envsys_create();
+
+       sc->sc_sme->sme_cookie = sc;
+       sc->sc_sme->sme_name = device_xname(self);



Home | Main Index | Thread Index | Old Index