You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.4 KiB

/*
* Copyright (c) Hisilicon Technologies Co., Ltd. 2021-2021. All rights reserved.
* Description: adc.h
* Author: Hisilicon
* Create: 2021-12-15
*/
#ifndef ADC_H
#define ADC_H
#include <linux/semaphore.h>
#define SENSOR_NAME_NUM 16
#define ADC_CHANNEL_NUM 14
#define ADC_GROUP_SIZE 2
#define ADC_DEFAULT_TEMP 25000
#define ADC_MIN_TEMP (-40000)
#define ADC_MAX_TEMP 125000
/* in order to resolve divisor less than zero */
#define PRORATE_OF_INIT 1000
enum adc_channel_info {
ADC_SENSOR_NAME,
ADC_CHANNEL,
ADC_IC_NAME,
ADC_IC_CHANNEL,
ADC_TOTAL,
};
enum adc_op_user {
ADC_OP_USER_BEGIN = 0,
ADC_OP_USER_ADC7828 = ADC_OP_USER_BEGIN, /* for ext adc */
ADC_OP_USER_LSADC, /* for soc adc */
ADC_OP_USER_END,
};
struct adc_device_info {
struct platform_device *pdev;
struct device *dev;
};
struct adc_info {
char sensor_name[SENSOR_NAME_NUM];
unsigned char adc_channel;
char adc_ic_name[SENSOR_NAME_NUM];
unsigned char adc_ic_channel;
};
struct adc_ops {
const char *type_name;
int (*adc_get_volt)(unsigned int adc_channel);
};
/* power interface info */
struct adc_ops_device_info {
struct device *dev;
unsigned int total_ops;
const struct adc_ops *ops[ADC_OP_USER_END];
};
int adc_get_temp(unsigned int adc_channel, int *temp);
int adc_ops_register(const struct adc_ops *ops);
#endif