1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * 4 * HDF is dual licensed: you can use it either under the terms of 5 * the GPL, or the BSD license, at your option. 6 * See the LICENSE file in the root of this repository for complete details. 7 */ 8 9 #ifndef SENSOR_HALL_DRIVER_H 10 #define SENSOR_HALL_DRIVER_H 11 12 #include "hdf_workqueue.h" 13 #include "sensor_config_parser.h" 14 #include "sensor_platform_if.h" 15 16 #define HALL_CHIP_NAME_AK8789 "ak8789" 17 18 enum HallGpioIrq { 19 HALL_NORTH_POLARITY_GPIO = 0, 20 HALL_SOUTH_POLARITY_GPIO = 1, 21 HALL_POLARITY_GPIO_MAX = 2, 22 }; 23 24 struct HallOpsCall { 25 int32_t (*Init)(struct SensorCfgData *data); 26 int32_t (*ReadData)(struct SensorCfgData *data); 27 }; 28 29 struct HallDrvData { 30 struct IDeviceIoService ioService; 31 struct HdfDeviceObject *device; 32 HdfWorkQueue hallWorkQueue; 33 HdfWork hallWork; 34 bool detectFlag; 35 bool enable; 36 int64_t interval; 37 struct SensorCfgData *hallCfg; 38 struct HallOpsCall ops; 39 int32_t GpioIrq[HALL_POLARITY_GPIO_MAX]; 40 }; 41 42 int32_t HallRegisterChipOps(const struct HallOpsCall *ops); 43 struct SensorCfgData *HallCreateCfgData(const struct DeviceResourceNode *node); 44 void HallReleaseCfgData(struct SensorCfgData *sensorCfgData); 45 46 #endif /* SENSOR_HALL_DRIVER_H */