1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright 2018 NXP.
4  *
5  * SPDX-License-Identifier:     GPL-2.0+
6  */
7 
8 #include <common.h>
9 #include <command.h>
10 #include <i2c.h>
11 #include <asm/io.h>
12 
13 #include "emc2305.h"
14 
15 DECLARE_GLOBAL_DATA_PTR;
16 
set_fan_speed(u8 data)17 void set_fan_speed(u8 data)
18 {
19 	u8 index;
20 	u8 Fan[NUM_OF_FANS] = {I2C_EMC2305_FAN1,
21 			       I2C_EMC2305_FAN2,
22 			       I2C_EMC2305_FAN3,
23 			       I2C_EMC2305_FAN4,
24 			       I2C_EMC2305_FAN5};
25 
26 	for (index = 0; index < NUM_OF_FANS; index++) {
27 		if (i2c_write(I2C_EMC2305_ADDR, Fan[index], 1, &data, 1) != 0) {
28 			printf("Error: failed to change fan speed @%x\n",
29 			       Fan[index]);
30 		}
31 	}
32 }
33 
emc2305_init(void)34 void emc2305_init(void)
35 {
36 	u8 data;
37 
38 	data = I2C_EMC2305_CMD;
39 	if (i2c_write(I2C_EMC2305_ADDR, I2C_EMC2305_CONF, 1, &data, 1) != 0)
40 		printf("Error: failed to configure EMC2305\n");
41 }
42