| 1 |
|
| 2 |
|
| 3 |
#include <console/console.h> |
| 4 |
#include <device/device.h> |
| 5 |
#include <types.h> |
| 6 |
|
| 7 |
#include "nct7802y.h" |
| 8 |
#include "chip.h" |
| 9 |
|
| 10 |
static void nct7802y_init_sensors(struct device *const dev) |
| 11 |
{ |
| 12 |
const struct drivers_i2c_nct7802y_config *const config = dev->chip_info; |
| 13 |
unsigned int i; |
| 14 |
u8 value = 0; |
| 15 |
|
| 16 |
for (i = 0; i < NCT7802Y_RTD_CNT; ++i) |
| 17 |
value |= MODE_SELECTION_RTDx(i, config->sensors.rtd[i]); |
| 18 |
if (config->sensors.local_enable) |
| 19 |
value |= MODE_SELECTION_LTD_EN; |
| 20 |
nct7802y_write(dev, MODE_SELECTION, value); |
| 21 |
} |
| 22 |
|
| 23 |
static void nct7802y_init(struct device *const dev) |
| 24 |
{ |
| 25 |
if (!dev->chip_info) { |
| 26 |
printk(BIOS_WARNING, |
| 27 |
"NCT7802Y driver selected but not configured."); |
| 28 |
return; |
| 29 |
} |
| 30 |
|
| 31 |
nct7802y_init_peci(dev); |
| 32 |
nct7802y_init_sensors(dev); |
| 33 |
nct7802y_init_fan(dev); |
| 34 |
} |
| 35 |
|
| 36 |
static struct device_operations nct7802y_ops = { |
| 37 |
.read_resources = noop_read_resources, |
| 38 |
.set_resources = noop_set_resources, |
| 39 |
.init = nct7802y_init, |
| 40 |
}; |
| 41 |
|
| 42 |
static void nct7802y_enable(struct device *const dev) |
| 43 |
{ |
| 44 |
dev->ops = &nct7802y_ops; |
| 45 |
} |
| 46 |
|
| 47 |
struct chip_operations drivers_i2c_nct7802y_ops = { |
| 48 |
.name = "NCT7802Y", |
| 49 |
.enable_dev = nct7802y_enable |
| 50 |
}; |