~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to roms/skiboot/core/sensor.c

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright 2013-2015 IBM Corp.
 
2
 *
 
3
 * Licensed under the Apache License, Version 2.0 (the "License");
 
4
 * you may not use this file except in compliance with the License.
 
5
 * You may obtain a copy of the License at
 
6
 *
 
7
 *      http://www.apache.org/licenses/LICENSE-2.0
 
8
 *
 
9
 * Unless required by applicable law or agreed to in writing, software
 
10
 * distributed under the License is distributed on an "AS IS" BASIS,
 
11
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 
12
 * implied.
 
13
 * See the License for the specific language governing permissions and
 
14
 * limitations under the License.
 
15
 */
 
16
 
 
17
 
 
18
#include <sensor.h>
 
19
#include <skiboot.h>
 
20
#include <device.h>
 
21
#include <opal.h>
 
22
#include <dts.h>
 
23
 
 
24
struct dt_node *sensor_node;
 
25
 
 
26
static int64_t opal_sensor_read(uint32_t sensor_hndl, int token,
 
27
                uint32_t *sensor_data)
 
28
{
 
29
        if (sensor_is_dts(sensor_hndl))
 
30
                return dts_sensor_read(sensor_hndl, sensor_data);
 
31
 
 
32
        if (platform.sensor_read)
 
33
                return platform.sensor_read(sensor_hndl, token, sensor_data);
 
34
 
 
35
        return OPAL_UNSUPPORTED;
 
36
}
 
37
 
 
38
void sensor_init(void)
 
39
{
 
40
        sensor_node = dt_new(opal_node, "sensors");
 
41
 
 
42
        dt_add_property_string(sensor_node, "compatible", "ibm,opal-sensor");
 
43
        dts_sensor_create_nodes(sensor_node);
 
44
 
 
45
        /* Register OPAL interface */
 
46
        opal_register(OPAL_SENSOR_READ, opal_sensor_read, 3);
 
47
}