From 2f55d448eeaa7a9c58998cc057fd9e119f01c4ef Mon Sep 17 00:00:00 2001 From: liuchao <380263137@qq.com> Date: Thu, 28 Nov 2024 18:02:56 +0800 Subject: [PATCH] add als sensor Signed-off-by: liuchao <380263137@qq.com> --- .../khdf/device_info/device_info.hcs | 11 +++ .../khdf/sensor/als/stk33562_config.hcs | 74 +++++++++++++++++++ .../hdf_config/khdf/sensor/sensor_config.hcs | 1 + oriole/patch.yml | 2 +- ...atch => 0005-add-mag-and-als-sensor.patch} | 45 ++++++----- 5 files changed, 113 insertions(+), 20 deletions(-) create mode 100644 oriole/hdf_config/khdf/sensor/als/stk33562_config.hcs rename oriole/patches/drivers/hdf_core/{0005-add-mag-sensor.patch => 0005-add-mag-and-als-sensor.patch} (52%) diff --git a/oriole/hdf_config/khdf/device_info/device_info.hcs b/oriole/hdf_config/khdf/device_info/device_info.hcs index c583e4c..cf0d9cf 100644 --- a/oriole/hdf_config/khdf/device_info/device_info.hcs +++ b/oriole/hdf_config/khdf/device_info/device_info.hcs @@ -433,6 +433,17 @@ deviceMatchAttr = "hdf_sensor_als_bh1745_driver"; } } + device_sensor_stk33562 :: device { + device0 :: deviceNode { + policy = 1; + priority = 120; + preload = 0; + permission = 0664; + moduleName = "HDF_SENSOR_ALS_STK33562"; + serviceName = "hdf_als_stk33562"; + deviceMatchAttr = "hdf_sensor_als_stk33562_driver"; + } + } device_sensor_proximity :: device { device0 :: deviceNode { policy = 1; diff --git a/oriole/hdf_config/khdf/sensor/als/stk33562_config.hcs b/oriole/hdf_config/khdf/sensor/als/stk33562_config.hcs new file mode 100644 index 0000000..5df14ae --- /dev/null +++ b/oriole/hdf_config/khdf/sensor/als/stk33562_config.hcs @@ -0,0 +1,74 @@ +#include "../sensor_common.hcs" +root { + als_stk33562_chip_config : sensorConfig { + match_attr = "hdf_sensor_als_stk33562_driver"; + sensorInfo :: sensorDeviceInfo { + sensorName = "als"; // light_stk3a5x + vendorName = "sensortek"; // max string length is 16 bytes + sensorTypeId = 5; // enum SensorTypeTag + sensorId = 5; // user define sensor id + power = 230; + } + sensorBusConfig :: sensorBusInfo { + busType = 0; // 0:i2c 1:spi + busNum = 7; + busAddr = 0x46; + regWidth = 1; // 1byte + } + sensorIdAttr :: sensorIdInfo { + chipName = "stk33562"; + chipIdRegister = 0x3E; + chipIdValue = 0x51; + } + sensorRegConfig { + /* regAddr: register address + value: config register value + len: size of value + mask: mask of value + delay: config register delay time (ms) + opsType: enum SensorOpsType 0-none 1-read 2-write 3-read_check 4-update_bit + calType: enum SensorBitCalType 0-none 1-set 2-revert 3-xor 4-left shift 5-right shift + shiftNum: shift bits + debug: 0-no debug 1-debug + save: 0-no save 1-save + */ + /* regAddr, value, mask, len, delay, opsType, calType, shiftNum, debug, save */ + initSeqConfig = [ + 0x00, 0x00, 0xff, 1, 5, 2, 0, 0, 0, 0, + 0x01, 0x31, 0xff, 1, 5, 2, 0, 0, 0, 0, + 0x02, 0x12, 0xff, 1, 5, 2, 0, 0, 0, 0, + 0x04, 0x00, 0xff, 1, 5, 2, 0, 0, 0, 0, + 0x05, 0x1F, 0xff, 1, 5, 2, 0, 0, 0, 0, + 0x4E, 0x30, 0xff, 1, 5, 2, 0, 0, 0, 0, + 0xA0, 0x10, 0xff, 1, 5, 2, 0, 0, 0, 0, + 0xAA, 0x64, 0xff, 1, 5, 2, 0, 0, 0, 0, + 0xA1, 0x7F, 0xff, 1, 5, 2, 0, 0, 0, 0, + 0xF6, 0x82, 0xff, 1, 5, 2, 0, 0, 0, 0, + 0xFA, 0x01, 0xff, 1, 5, 2, 0, 0, 0, 0 + ]; + enableSeqConfig = [ + 0x00, 0x02, 0x02, 1, 5, 2, 0, 0, 0, 0 + ]; + disableSeqConfig = [ + 0x00, 0x00, 0x02, 1, 5, 2, 0, 0, 0, 0 + ]; + } + + extendAlsRegConfig { + /* regAddr, value, mask, len, delay, opsType, calType, shiftNum, debug, save */ + time = [ + 0x41, 0x00, 0x07, 1, 5, 0, 1, 0, 0, 0, //160msec + 0x41, 0x01, 0x07, 1, 5, 0, 1, 0, 0, 0, //320msec + 0x41, 0x02, 0x07, 1, 5, 0, 1, 0, 0, 0, //640msec + 0x41, 0x03, 0x07, 1, 5, 0, 1, 0, 0, 0, //1280msec + 0x41, 0x04, 0x07, 1, 5, 0, 1, 0, 0, 0, //2560msec + 0x41, 0x05, 0x07, 1, 5, 0, 1, 0, 0, 0, //5120msec + ]; + gain = [ + 0x42, 0x00, 0x03, 1, 5, 0, 1, 0, 0, 0, //1X + 0x42, 0x01, 0x03, 1, 5, 0, 1, 0, 0, 0, //2X + 0x42, 0x02, 0x03, 1, 5, 0, 1, 0, 0, 0 //16X + ]; + } + } +} diff --git a/oriole/hdf_config/khdf/sensor/sensor_config.hcs b/oriole/hdf_config/khdf/sensor/sensor_config.hcs index 8564e05..b995f47 100644 --- a/oriole/hdf_config/khdf/sensor/sensor_config.hcs +++ b/oriole/hdf_config/khdf/sensor/sensor_config.hcs @@ -2,6 +2,7 @@ #include "accel/mxc6655xa_config.hcs" #include "accel/sc7a20e_config.hcs" #include "als/bh1745_config.hcs" +#include "als/stk33562_config.hcs" #include "proximity/proximity_apds9960_config.hcs" #include "magnetic/magnetic_lsm303_config.hcs" #include "magnetic/magnetic_mmc5603nj_config.hcs" diff --git a/oriole/patch.yml b/oriole/patch.yml index 37864fe..00190c7 100644 --- a/oriole/patch.yml +++ b/oriole/patch.yml @@ -8,7 +8,7 @@ base/powermgr/power_manager: drivers/hdf_core: - vendor/hardmony/oriole/patches/drivers/hdf_core/0001-hdf_core.patch - vendor/hardmony/oriole/patches/drivers/hdf_core/0002-hdf_core.patch - - vendor/hardmony/oriole/patches/drivers/hdf_core/0005-add-mag-sensor.patch + - vendor/hardmony/oriole/patches/drivers/hdf_core/0005-add-mag-and-als-sensor.patch drivers/peripheral: - vendor/hardmony/oriole/patches/drivers/peripheral/0001-update-location-vintf.patch diff --git a/oriole/patches/drivers/hdf_core/0005-add-mag-sensor.patch b/oriole/patches/drivers/hdf_core/0005-add-mag-and-als-sensor.patch similarity index 52% rename from oriole/patches/drivers/hdf_core/0005-add-mag-sensor.patch rename to oriole/patches/drivers/hdf_core/0005-add-mag-and-als-sensor.patch index 016ce56..51e9c4c 100644 --- a/oriole/patches/drivers/hdf_core/0005-add-mag-sensor.patch +++ b/oriole/patches/drivers/hdf_core/0005-add-mag-and-als-sensor.patch @@ -1,20 +1,21 @@ -From 4ad5f2d33e63ec665de80559e3d9e2de227352d6 Mon Sep 17 00:00:00 2001 -From: liuchao <380263137@qq.com> -Date: Fri, 8 Nov 2024 09:37:42 +0800 -Subject: [PATCH] add mag sensor - -Change-Id: If8889bdc54db03ddd2d2b250832542e5dc4462a2 -Signed-off-by: liuchao <380263137@qq.com> ---- - adapter/khdf/linux/model/sensor/Kconfig | 6 ++++++ - adapter/khdf/linux/model/sensor/Makefile | 2 ++ - 2 files changed, 8 insertions(+) - diff --git a/adapter/khdf/linux/model/sensor/Kconfig b/adapter/khdf/linux/model/sensor/Kconfig -index 8e40b462..dd6d558a 100755 +index 470c8bcd..a23ef179 100755 --- a/adapter/khdf/linux/model/sensor/Kconfig +++ b/adapter/khdf/linux/model/sensor/Kconfig -@@ -154,6 +154,12 @@ config DRIVERS_HDF_SENSOR_MAGNETIC_LSM303 +@@ -64,6 +64,12 @@ config DRIVERS_HDF_SENSOR_ALS_BH1750 + depends on DRIVERS_HDF_SENSOR_ALS + help + Answer Y to enable HDF als bh1750 sensor driver. ++config DRIVERS_HDF_SENSOR_ALS_STK33562 ++ bool "Enable HDF als stk33562 sensor driver" ++ default n ++ depends on DRIVERS_HDF_SENSOR_ALS ++ help ++ Answer Y to enable HDF als stk33562 sensor driver. + config DRIVERS_HDF_SENSOR_GRAVITY + bool "Enable HDF gravity sensor driver" + default n +@@ -148,6 +154,12 @@ config DRIVERS_HDF_SENSOR_MAGNETIC_LSM303 depends on DRIVERS_HDF_SENSOR_MAGNETIC help Answer Y to enable HDF magnetic lsm303 sensor driver. @@ -28,10 +29,19 @@ index 8e40b462..dd6d558a 100755 bool "Enable HDF proximity sensor driver" default n diff --git a/adapter/khdf/linux/model/sensor/Makefile b/adapter/khdf/linux/model/sensor/Makefile -index 2e7a5881..b3a19a2d 100644 +index 9bc99aa5..689a0b71 100644 --- a/adapter/khdf/linux/model/sensor/Makefile +++ b/adapter/khdf/linux/model/sensor/Makefile -@@ -66,6 +66,8 @@ obj-$(CONFIG_DRIVERS_HDF_SENSOR_MAGNETIC) += $(SENSOR_ROOT_DIR)/magnetic/sensor_ +@@ -38,6 +38,8 @@ obj-$(CONFIG_DRIVERS_HDF_SENSOR_ALS_BH1745) += $(SENSOR_ROOT_CHIPSET)/chipset/al + + obj-$(CONFIG_DRIVERS_HDF_SENSOR_ALS_BH1750) += $(SENSOR_ROOT_CHIPSET)/chipset/als/als_bh1750.o + ++obj-$(CONFIG_DRIVERS_HDF_SENSOR_ALS_STK33562) += $(SENSOR_ROOT_CHIPSET)/chipset/als/als_stk33562.o ++ + obj-$(CONFIG_DRIVERS_HDF_SENSOR_PROXIMITY) += $(SENSOR_ROOT_DIR)/proximity/sensor_proximity_driver.o + + obj-$(CONFIG_DRIVERS_HDF_SENSOR_PROXIMITY_APDS9960) += $(SENSOR_ROOT_CHIPSET)/chipset/proximity/proximity_apds9960.o +@@ -64,6 +66,8 @@ obj-$(CONFIG_DRIVERS_HDF_SENSOR_MAGNETIC) += $(SENSOR_ROOT_DIR)/magnetic/sensor_ obj-$(CONFIG_DRIVERS_HDF_SENSOR_MAGNETIC_LSM303) += $(SENSOR_ROOT_CHIPSET)/chipset/magnetic/magnetic_lsm303.o @@ -40,6 +50,3 @@ index 2e7a5881..b3a19a2d 100644 obj-$(CONFIG_DRIVERS_HDF_SENSOR_GRAVITY) += $(SENSOR_ROOT_DIR)/accel/sensor_gravity_driver.o obj-$(CONFIG_DRIVERS_HDF_SENSOR_PEDOMETER) += $(SENSOR_ROOT_DIR)/pedometer/sensor_pedometer_driver.o --- -2.25.1 - -- Gitee