Fix charger values, again (#303)

* common: Add macros for min, max, clamp

Simple macros, with no type checking.

Signed-off-by: Tim Crawford <tcrawford@system76.com>

* charger: Limit charger values to max valid value

Use the maximum valid value instead of discarding bits.

Fixes: 6295f60172 ("Fix smart charger values")

Signed-off-by: Tim Crawford <tcrawford@system76.com>

* charger/bq24780s: Fix charge current mask

bq24780s uses bit 12 for 4096 a current weight.

Fixes: 6295f60172 ("Fix smart charger values")

Signed-off-by: Tim Crawford <tcrawford@system76.com>

* oryp: Reduce charge current to 2A

Signed-off-by: Tim Crawford <tcrawford@system76.com>

* charger/bq24780s: Set RSENSE ratio option

Signed-off-by: Tim Crawford <tcrawford@system76.com>

Signed-off-by: Tim Crawford <tcrawford@system76.com>
This commit is contained in:
Tim Crawford
2022-10-06 13:02:15 -06:00
committed by GitHub
parent a32a3e3e95
commit 76019bdb61
7 changed files with 71 additions and 26 deletions

View File

@@ -13,4 +13,8 @@
#define BIT(X) (1UL << (X))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define CLAMP(val, min, max) (MIN(MAX(val, min), max))
#endif // _COMMON_MACRO_H