linux/drivers/hwmon/sch5627.c
<<
>>
Prefs
   1/***************************************************************************
   2 *   Copyright (C) 2010-2012 Hans de Goede <hdegoede@redhat.com>           *
   3 *                                                                         *
   4 *   This program is free software; you can redistribute it and/or modify  *
   5 *   it under the terms of the GNU General Public License as published by  *
   6 *   the Free Software Foundation; either version 2 of the License, or     *
   7 *   (at your option) any later version.                                   *
   8 *                                                                         *
   9 *   This program is distributed in the hope that it will be useful,       *
  10 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
  11 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
  12 *   GNU General Public License for more details.                          *
  13 *                                                                         *
  14 *   You should have received a copy of the GNU General Public License     *
  15 *   along with this program; if not, write to the                         *
  16 *   Free Software Foundation, Inc.,                                       *
  17 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  18 ***************************************************************************/
  19
  20#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  21
  22#include <linux/module.h>
  23#include <linux/init.h>
  24#include <linux/slab.h>
  25#include <linux/jiffies.h>
  26#include <linux/platform_device.h>
  27#include <linux/hwmon.h>
  28#include <linux/hwmon-sysfs.h>
  29#include <linux/err.h>
  30#include <linux/mutex.h>
  31#include "sch56xx-common.h"
  32
  33#define DRVNAME "sch5627"
  34#define DEVNAME DRVNAME /* We only support one model */
  35
  36#define SCH5627_HWMON_ID                0xa5
  37#define SCH5627_COMPANY_ID              0x5c
  38#define SCH5627_PRIMARY_ID              0xa0
  39
  40#define SCH5627_REG_BUILD_CODE          0x39
  41#define SCH5627_REG_BUILD_ID            0x3a
  42#define SCH5627_REG_HWMON_ID            0x3c
  43#define SCH5627_REG_HWMON_REV           0x3d
  44#define SCH5627_REG_COMPANY_ID          0x3e
  45#define SCH5627_REG_PRIMARY_ID          0x3f
  46#define SCH5627_REG_CTRL                0x40
  47
  48#define SCH5627_NO_TEMPS                8
  49#define SCH5627_NO_FANS                 4
  50#define SCH5627_NO_IN                   5
  51
  52static const u16 SCH5627_REG_TEMP_MSB[SCH5627_NO_TEMPS] = {
  53        0x3S, 0x3gXlude ;lude 9lude Alude180lude181 }"
u16 SCH5627_REG_LS_P_MSB[SCH5627_NO_TEMPS] = {
u16 SCH5627_REG_HIGH_NIBBLDP_MSB[SCH5627_NO_TEMPS] = {
u16 SCH5627_REG_HIGHP_MSB[SCH5627_NO_TEMPS] = {
u16 SCH5627_REG_AB_P_MSB[SCH5627_NO_TEMPS] = {
  32
u16 SCH56277_NP_MSB[SCH5627_NO_FANS] = {
u16 SCH56277_N_M7_P_MSB[SCH5627_NO_FANS] = {
  47
u16 SCH5627IN_TEMP_MSB[SCH5627_NO_IS] = {
u16 SCH5627IN_LS_P_MSB[SCH5627_NO_IS] = {
  52static const u16 SCH5627IN_HIGH_NIBBLDP_MSB[SCH5627_NO_IS] = {
  53   1,  , 1, 0, 1 }"
u16 SCH5627IN_FACTORP_MSB[SCH5627_NO_IS] = {
SCHIN_LABELO_FANS" class="sref">SCHIN_LABELOP_MSB[SCH5627_NO_IS] = {
&VCCh5627" &VTTh5627" &VBATh5627" &VTRh5627" &V27_ot;: "sc_watchdog_dataNO_IN" class="swmon/sc_watchdog_data>  53*onst   53   onst u16 u16 SCH5627_NO_TEMPS"
u16 SCH5627_NO_TEMPS"
u16 SCH5627_NO_FANS"
  47
u16   5&a>    
  5&a>    u16 SCH5627_NO_TEMPS"
  53   onst u16 SCH5627_NO_FANS"
u16 SCH5627_NO_IS"
  32
  53   onst   5 + 300 *  SCH5627_REG_CTR,] = {
  5 =const   51

  5 +  SCH5627_NO_TEMP;const SCH5627_REG_TEMP_MSB[SCH5627_REG_LS_P_MSB[SCH5627_REG_HIGH_NIBBLDP_MSB[  35
SCH5627_NO_FAN;const SCH56277_NP_MSB[  35
SCH5627_NO_I;const SCH5627IN_TEMP_MSB[SCH5627IN_LS_P_MSB[SCH5627IN_HIGH_NIBBLDP_MSB[  47
  5 =const   5onst   53   mit="re   35
  39
SCH5627_NO_TEMP;const 
  12  13  14SCH5627_REG_AB_P_MSB[ SCH5627_REG_HIGHP_MSB[ SCH5627_NO_FAN;const SCH56277_N_M7_P_MSB[   53   }quot;
  47
u16   32
u16   47
u16   47
  5(2&%s\nh5627" u1>] = {
&%d\nh5627"   47
&%d\nh5627"   39
&%d\nh5627"   52stonst   5>] = {
  47
&%d\nh5627"   51
  12stonst   51
   35
&%d\nh5627"   47
&%d\nh5627"
  51
  12stonst  &%d\nh5627" u1>] = {
&%d\nh5627"   39
&%s\nh5627"
SCHIN_LABELOP_MSB[  5,    5,    52stonst   12stonst   52stonst   12stonst   52stonst   12stonst   52stonst   1quot;
  52stonst   12stonst   35
  52stonst   12stonst   35
  5.onst /* No in4_label as in4 is a generic inpud pin */  35
  5}"
  1quot;
  1(2  53*onst   1(onst   1quot;
  1(&a   1(2  53*onst   5, onst   1quot;
  1(onst "invalid %s#L2: 0x%02X (expected 0x%02X)\n""vers/""invalid %s#L2: 0x%02X (expected 0x%02X)\n""company"  35
"invalid %s#L2: 0x%02X (expected 0x%02X)\n""primary"  53=    53< 0) >] = {
  5"
"hardware rs/itoring not enabled\n"/* Trigger a Vbat voltage reasurement, so that we get a valid reading  5   3   the first time we read Vbat */  53=    35
/*   3 * Read limits, we do this only once as reading a register on   3 * the wmon/sc is quite expensf=" (and they don't change).   3 */"found %s#chip at %#hx\n""firmware build: ef=" 0x%02X,#L4 0x%04X,#vers/: rev 0x%02X\n"  5, onst /* Register wysfs in erface files */  1quot;
  1(&a /* Note failing to register the watchdog is not a fatal error */  53<< 24) | (onst   1(   53onst   53= >] = {
  53= >] = {
  53<=    53   1          =    1,quot;
  1         =    1,quot;
  1(   5)"
  1quot;
"SMSC SCHn/sc Hardware Ms/itoring Def="d""Hans de Goede <hdegoede@redhat.com>a"  3 "GPL"
The original LXR software by the uot;
LXR commu/ity>  5, this experimental ="drion by uot;
lxr@assux.no>  5.
lxr.assux.no kindly hosted by uot; Redpill Lsspro AS> 5, provider of Lssuxtconsulting and oper/a>ons serric"s since 1995.