WIP: kbled control for darp5
This commit is contained in:
@@ -19,6 +19,9 @@ CFLAGS+=-DLEVEL=4
|
||||
# Set battery I2C bus
|
||||
CFLAGS+=-DI2C_SMBUS=I2C_0
|
||||
|
||||
# Set keyboard LED I2C bus
|
||||
CFLAGS+=-DI2C_KBLED=I2C_1
|
||||
|
||||
# Set scratch ROM parameters
|
||||
SCRATCH_OFFSET=1024
|
||||
SCRATCH_SIZE=1024
|
||||
|
@@ -94,9 +94,9 @@ void gpio_init() {
|
||||
// ALL_SYS_PWRGD
|
||||
GPCRC0 = GPIO_IN;
|
||||
// SMC_VGA_THERM
|
||||
GPCRC1 = GPIO_IN | GPIO_UP;
|
||||
GPCRC1 = GPIO_ALT;
|
||||
// SMD_VGA_THERM
|
||||
GPCRC2 = GPIO_IN | GPIO_UP;
|
||||
GPCRC2 = GPIO_ALT;
|
||||
// KSO16 (Darter)
|
||||
GPCRC3 = GPIO_IN;
|
||||
// CNVI_DET#
|
||||
|
11
src/board/system76/darp5/include/board/kbled.h
Normal file
11
src/board/system76/darp5/include/board/kbled.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifndef _BOARD_KBLED_H
|
||||
#define _BOARD_KBLED_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void kbled_init(void);
|
||||
uint8_t kbled_get(void);
|
||||
void kbled_set(uint8_t level);
|
||||
void kbled_set_color(uint32_t color);
|
||||
|
||||
#endif // _BOARD_KBLED_H
|
58
src/board/system76/darp5/kbled.c
Normal file
58
src/board/system76/darp5/kbled.c
Normal file
@@ -0,0 +1,58 @@
|
||||
#include <board/kbled.h>
|
||||
#include <common/macro.h>
|
||||
#include <ec/i2c.h>
|
||||
|
||||
#define kbled_i2c_get(A, D, L) i2c_get(&I2C_KBLED, 0x68, A, D, L)
|
||||
#define kbled_i2c_set(A, D, L) i2c_set(&I2C_KBLED, 0x68, A, D, L)
|
||||
|
||||
static uint8_t __code levels[] = {
|
||||
0x00,
|
||||
0x80,
|
||||
0x90,
|
||||
0xA8,
|
||||
0xC0,
|
||||
0xFF
|
||||
};
|
||||
|
||||
void kbled_init(void) {
|
||||
i2c_reset(&I2C_KBLED, true);
|
||||
kbled_set(0xFF);
|
||||
kbled_set_color(0xFFFFFF);
|
||||
}
|
||||
|
||||
uint8_t kbled_get(void) {
|
||||
uint8_t level;
|
||||
uint8_t raw = 0;
|
||||
kbled_i2c_get(0x12, &raw, 1);
|
||||
for (level = 0; level < ARRAY_SIZE(levels); level++) {
|
||||
if (raw <= levels[level]) {
|
||||
return level;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void kbled_set(uint8_t level) {
|
||||
uint8_t raw = 0;
|
||||
if (level < ARRAY_SIZE(levels)) {
|
||||
raw = levels[level];
|
||||
}
|
||||
kbled_i2c_set(0x12, &raw, 1);
|
||||
}
|
||||
|
||||
void kbled_set_color(uint32_t color) {
|
||||
uint8_t b = (uint8_t)(color);
|
||||
kbled_i2c_set(0x02, &b, 1);
|
||||
kbled_i2c_set(0x03, &b, 1);
|
||||
kbled_i2c_set(0x04, &b, 1);
|
||||
|
||||
uint8_t g = (uint8_t)(color >> 8);
|
||||
kbled_i2c_set(0x05, &g, 1);
|
||||
kbled_i2c_set(0x06, &g, 1);
|
||||
kbled_i2c_set(0x07, &g, 1);
|
||||
|
||||
uint8_t r = (uint8_t)(color >> 16);
|
||||
kbled_i2c_set(0x08, &r, 1);
|
||||
kbled_i2c_set(0x09, &r, 1);
|
||||
kbled_i2c_set(0x0A, &r, 1);
|
||||
}
|
@@ -9,6 +9,7 @@
|
||||
#include <board/gpio.h>
|
||||
#include <board/gctrl.h>
|
||||
#include <board/kbc.h>
|
||||
#include <board/kbled.h>
|
||||
#include <board/kbscan.h>
|
||||
#include <board/lid.h>
|
||||
#include <board/peci.h>
|
||||
@@ -41,6 +42,7 @@ void init(void) {
|
||||
// Can happen in any order
|
||||
ecpm_init();
|
||||
kbc_init();
|
||||
kbled_init();
|
||||
kbscan_init();
|
||||
peci_init();
|
||||
pmc_init();
|
||||
|
Reference in New Issue
Block a user