summaryrefslogtreecommitdiff
path: root/chip
diff options
context:
space:
mode:
authormartin yan <martin.yan@microchip.corp-partner.google.com>2021-08-17 14:38:44 -0400
committerCommit Bot <commit-bot@chromium.org>2021-08-19 22:09:03 +0000
commit722141bc3060fb60cc6b364d5fc9e8d6536f0788 (patch)
tree2d9bf16ffbab6a93e86914dbf2add199c0ec2f19 /chip
parent481429fd98900042dc0f6ed18f644800a5863109 (diff)
downloadchrome-ec-722141bc3060fb60cc6b364d5fc9e8d6536f0788.tar.gz
mchp: Update RPM-PWM registers and configuration
Update RPM-PWM block's registers and configuration as POR, RPM based Fan Control Algorithm via RPM-PWM hardware block is not supported or validated in previous mchp projects. BUG=none BRANCH=none TEST=Tested on ADL RVP and MCHP1727 MECC system via UART console Signed-off-by: martin yan <martin.yan@microchip.corp-partner.google.com> Change-Id: Ibe15dfbec4f2c2d4558d27c8b101345ad81a09f3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3100925 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'chip')
-rw-r--r--chip/mchp/fan.c27
-rw-r--r--chip/mchp/registers-mec1701.h4
-rw-r--r--chip/mchp/registers-mec172x.h4
3 files changed, 23 insertions, 12 deletions
diff --git a/chip/mchp/fan.c b/chip/mchp/fan.c
index dc939bb58f..17b60b703d 100644
--- a/chip/mchp/fan.c
+++ b/chip/mchp/fan.c
@@ -12,6 +12,12 @@
#include "util.h"
#include "tfdp_chip.h"
+/* Maximum fan driver setting value */
+#define MAX_FAN_DRIVER_SETTING 0x3ff
+
+/* Fan driver setting data in bit[15:6] of hardware register */
+#define FAN_DRIVER_SETTING_SHIFT 6
+
/* Maximum tach reading/target value */
#define MAX_TACH 0x1fff
@@ -71,12 +77,15 @@ void fan_set_duty(int ch, int percent)
percent = 100;
duty_setting = percent;
- MCHP_FAN_SETTING(0) = percent * 255 / 100;
+ MCHP_FAN_SETTING(0) = (percent * MAX_FAN_DRIVER_SETTING / 100)
+ << FAN_DRIVER_SETTING_SHIFT;
clear_status();
}
int fan_get_duty(int ch)
{
+ duty_setting = (MCHP_FAN_SETTING(0) >> FAN_DRIVER_SETTING_SHIFT)
+ * 100 / MAX_FAN_DRIVER_SETTING;
return duty_setting;
}
@@ -140,7 +149,8 @@ void fan_channel_setup(int ch, unsigned int flags)
{
/* Clear PCR sleep enable for RPM2FAN0 */
MCHP_PCR_SLP_DIS_DEV(MCHP_PCR_RPMPWM0);
-
+ /* Configure PWM Min drive */
+ MCHP_FAN_MIN_DRV(0) = 0x0A;
/*
* Fan configuration 1 register:
* 0x80 = bit 7 = RPM mode (0x00 if FAN_USE_RPM_MODE not set)
@@ -149,16 +159,17 @@ void fan_channel_setup(int ch, unsigned int flags)
* 0x03 = bits 2:0 = 400 ms update time
*
* Fan configuration 2 register:
- * 0x00 = bit 6 = Ramp control disabled
- * 0x00 = bit 5 = Glitch filter enabled
- * 0x18 = bits 4:3 = Using both derivative options
- * 0x02 = bits 2:1 = error range is 50 RPM
- * 0x00 = bits 0 = normal polarity
+ * 0x00 = bit 7 = Ramp control disabled
+ * 0x00 = bit 6 = Glitch filter enabled
+ * 0x30 = bits 5:4 = Using both derivative options
+ * 0x04 = bits 3:2 = error range is 50 RPM
+ * 0x00 = bits 1 = normal polarity
+ * 0x00 = bit 0 = Reserved
*/
if (flags & FAN_USE_RPM_MODE)
MCHP_FAN_CFG1(0) = 0xab;
else
MCHP_FAN_CFG1(0) = 0x2b;
- MCHP_FAN_CFG2(0) = 0x1a;
+ MCHP_FAN_CFG2(0) = 0x34;
clear_status();
}
diff --git a/chip/mchp/registers-mec1701.h b/chip/mchp/registers-mec1701.h
index 04f80dd905..bfe012a0d8 100644
--- a/chip/mchp/registers-mec1701.h
+++ b/chip/mchp/registers-mec1701.h
@@ -995,10 +995,10 @@
#define MCHP_FAN_SPACING 0x80U
#define MCHP_FAN_BASE(x) \
(MCHP_RPM2PWM0_BASE + ((x) * MCHP_FAN_SPACING))
-#define MCHP_FAN_SETTING(x) REG8(MCHP_FAN_BASE(x) + 0x0)
-#define MCHP_FAN_PWM_DIVIDE(x) REG8(MCHP_FAN_BASE(x) + 0x1)
+#define MCHP_FAN_SETTING(x) REG16(MCHP_FAN_BASE(x) + 0x0)
#define MCHP_FAN_CFG1(x) REG8(MCHP_FAN_BASE(x) + 0x2)
#define MCHP_FAN_CFG2(x) REG8(MCHP_FAN_BASE(x) + 0x3)
+#define MCHP_FAN_PWM_DIVIDE(x) REG8(MCHP_FAN_BASE(x) + 0x4)
#define MCHP_FAN_GAIN(x) REG8(MCHP_FAN_BASE(x) + 0x5)
#define MCHP_FAN_SPIN_UP(x) REG8(MCHP_FAN_BASE(x) + 0x6)
#define MCHP_FAN_STEP(x) REG8(MCHP_FAN_BASE(x) + 0x7)
diff --git a/chip/mchp/registers-mec172x.h b/chip/mchp/registers-mec172x.h
index 146ad046dd..dc811ea3c7 100644
--- a/chip/mchp/registers-mec172x.h
+++ b/chip/mchp/registers-mec172x.h
@@ -1110,10 +1110,10 @@
#define MCHP_FAN_SPACING 0x80U
#define MCHP_FAN_BASE(x) \
(MCHP_RPM2PWM0_BASE + ((x) * MCHP_FAN_SPACING))
-#define MCHP_FAN_SETTING(x) REG8(MCHP_FAN_BASE(x) + 0x0)
-#define MCHP_FAN_PWM_DIVIDE(x) REG8(MCHP_FAN_BASE(x) + 0x1)
+#define MCHP_FAN_SETTING(x) REG16(MCHP_FAN_BASE(x) + 0x0)
#define MCHP_FAN_CFG1(x) REG8(MCHP_FAN_BASE(x) + 0x2)
#define MCHP_FAN_CFG2(x) REG8(MCHP_FAN_BASE(x) + 0x3)
+#define MCHP_FAN_PWM_DIVIDE(x) REG8(MCHP_FAN_BASE(x) + 0x4)
#define MCHP_FAN_GAIN(x) REG8(MCHP_FAN_BASE(x) + 0x5)
#define MCHP_FAN_SPIN_UP(x) REG8(MCHP_FAN_BASE(x) + 0x6)
#define MCHP_FAN_STEP(x) REG8(MCHP_FAN_BASE(x) + 0x7)