Skip to content

Commit 20ab366

Browse files
authored
Merge pull request #708 from FrameworkComputer/fwk.als_sensor
Read the ALS sensor (CM32183) vai ALS task
2 parents 7ab57c2 + 1ddcf8e commit 20ab366

File tree

15 files changed

+172
-4
lines changed

15 files changed

+172
-4
lines changed

common/als.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
#include "timer.h"
1919
#include "util.h"
2020

21+
#ifdef CONFIG_ZEPHYR
22+
#include "cros_als.h"
23+
#endif
24+
2125
#define CPUTS(outstr) cputs(CC_ALS, outstr)
2226
#define CPRINTS(format, args...) cprints(CC_ALS, format, ##args)
2327
#define CPRINTF(format, args...) cprintf(CC_ALS, format, ##args)

zephyr/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_BODY_DETECTION
201201
"${PLATFORM_EC}/common/body_detection.c")
202202
zephyr_library_sources_ifdef(CONFIG_NAMED_ADC_CHANNELS
203203
"${PLATFORM_EC}/common/adc.c")
204+
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_DEDICATED_ALS
205+
"${PLATFORM_EC}/common/als.c")
204206
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ALS_TCS3400
205207
"${PLATFORM_EC}/driver/als_tcs3400.c")
206208
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ALS_CM32183

zephyr/Kconfig.motionsense

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,17 @@ rsource "Kconfig.sensor_devices"
193193
rsource "Kconfig.body_detection"
194194

195195
endif # PLATFORM_EC_MOTIONSENSE
196+
197+
config PLATFORM_EC_DEDICATED_ALS
198+
bool "Enable als task without motionsense config"
199+
default n
200+
select HAS_TASK_ALS
201+
help
202+
Enable ALS task without motionsense.
203+
This config must defines the als_t als[] in project layer.
204+
205+
if PLATFORM_EC_DEDICATED_ALS
206+
207+
rsource "Kconfig.sensor_devices"
208+
209+
endif #PLATFORM_EC_DEDICATED_ALS

zephyr/Kconfig.stacks

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ config TASK_CYPD_STACK_SIZE
8686
default 1024 if SOC_SERIES_NPCX7
8787
default 1024 if SOC_SERIES_NPCX9
8888

89+
config TASK_ALS_STACK_SIZE
90+
default 1280 if SOC_SERIES_RISCV32_IT8XXX2
91+
default 1024 if SOC_SERIES_NPCX7
92+
default 1024 if SOC_SERIES_NPCX9
93+
8994
config TASK_USB_CHG_STACK_SIZE
9095
default 1152 if SOC_SERIES_RISCV32_IT8XXX2
9196
default 800 if SOC_SERIES_NPCX7

zephyr/Kconfig.tasks

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,23 @@ config TASK_CYPD_STACK_SIZE
270270

271271
endif # HASK_TASK_CYPD
272272

273+
config HAS_TASK_ALS
274+
bool
275+
depends on PLATFORM_EC_DEDICATED_ALS
276+
help
277+
This turns on the ALS task which store the ASL sensor value into
278+
EC memmap.
279+
280+
if HAS_TASK_ALS
281+
282+
config TASK_ALS_STACK_SIZE
283+
int "ALS task stack size"
284+
default 768
285+
help
286+
The stack size of the ALS task.
287+
288+
endif # HAS_TASK_ALS
289+
273290
config HAS_TASK_TOUCHPAD
274291
bool
275292
help
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright 2021 The ChromiumOS Authors
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
description: >
6+
Properties for a CM32183 I2C ambient light sensor
7+
8+
compatible: "nxp,cm32183"
9+
10+
include: i2c-device.yaml

zephyr/program/lotus/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ zephyr_library_sources("src/cpu_power.c")
1414
zephyr_library_sources("src/factory.c")
1515
zephyr_library_sources("src/diagnostics.c")
1616
zephyr_library_sources("src/ucsi.c")
17+
zephyr_library_sources("src/als.c")
1718

1819
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_COMMON
1920
"src/led_pwm.c")

zephyr/program/lotus/azalea/i2c.dtsi

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
i2c_sensor: sensor {
4444
i2c-port = <&i2c7_0>;
4545
enum-names = "I2C_PORT_SENSOR",
46-
"I2C_PORT_THERMAL_AP";
46+
"I2C_PORT_THERMAL_AP",
47+
"I2C_PORT_ALS";
4748
};
4849
};
4950
};
@@ -156,6 +157,11 @@
156157
compatible = "amd,sb-tsi";
157158
reg = <0x4c>;
158159
};
160+
161+
als_cm32183: als-cm32183@29 {
162+
compatible = "nxp,cm32183";
163+
reg = <0x29>;
164+
};
159165
};
160166

161167
&i2c_ctrl7 {

zephyr/program/lotus/lotus/i2c.dtsi

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@
5454
i2c_sensor: sensor {
5555
i2c-port = <&i2c7_0>;
5656
enum-names = "I2C_PORT_SENSOR",
57-
"I2C_PORT_THERMAL_AP";
57+
"I2C_PORT_THERMAL_AP",
58+
"I2C_PORT_ALS";
5859
};
5960
};
6061
};
@@ -214,6 +215,11 @@
214215
compatible = "amd,sb-tsi";
215216
reg = <0x4c>;
216217
};
218+
219+
als_cm32183: als-cm32183@29 {
220+
compatible = "nxp,cm32183";
221+
reg = <0x29>;
222+
};
217223
};
218224

219225
&i2c_ctrl7 {

zephyr/program/lotus/program.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ CONFIG_SENSOR=y
7474
CONFIG_PLATFORM_EC_FAN=y
7575
CONFIG_LTO=n
7676

77+
# ALS
78+
CONFIG_PLATFORM_EC_MOTIONSENSE=n
79+
CONFIG_PLATFORM_EC_DEDICATED_ALS=y
80+
7781
# LED
7882
CONFIG_PLATFORM_EC_LED_COMMON=y
7983
CONFIG_PLATFORM_EC_LED_DT=n

0 commit comments

Comments
 (0)