mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-08 12:58:12 -04:00
Added dts901b1 thermopile kernel module
changelist: Added dts901b1 thermopile kernel module Change-Id: IeMontana5d74842f373d3fdc8ec2a7689d21535396af Signed-off-by: Yan Zhang <zhangy26@motorola.com> Reviewed-on: https://gerrit.mot.com/1654384 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Xiangpo Zhao <zhaoxp3@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
976597a1be
commit
f7aadbe62a
8 changed files with 2261 additions and 1 deletions
9
drivers/misc/dts201a/Android.mk
Normal file
9
drivers/misc/dts201a/Android.mk
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
DLKM_DIR := motorola/kernel/modules
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := dts201a_mmi.ko
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_MODULE_PATH := $(KERNEL_MODULES_OUT)
|
||||
include $(DLKM_DIR)/AndroidKernelModule.mk
|
||||
|
||||
40
drivers/misc/dts201a/Kbuild
Normal file
40
drivers/misc/dts201a/Kbuild
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
HAVE_KERNEL_414 = $(shell test -d $(TOP)/kernel/msm-4.14 && echo 1)
|
||||
|
||||
ifeq ($(HAVE_KERNEL_414),1)
|
||||
KERNEL_SOURCE_PATH ?= kernel/msm-4.14
|
||||
else
|
||||
KERNEL_SOURCE_PATH ?= kernel/msm-4.9
|
||||
endif
|
||||
|
||||
# Each configuration option enables a list of files.
|
||||
FEATURE_USE_CCI := false
|
||||
|
||||
ifeq ($(FEATURE_USE_CCI), true)
|
||||
HAVE_TECHPACK_CAMERA = $(shell test -d $(TOP)/$(KERNEL_SOURCE_PATH)/techpack/camera && echo 1)
|
||||
|
||||
ifeq ($(HAVE_TECHPACK_CAMERA),1)
|
||||
KERNEL_CAMERA_DRIVER_PATH ?= $(TOP)/$(KERNEL_SOURCE_PATH)/techpack/camera/drivers
|
||||
EXTRA_CFLAGS += -DCONFIG_SPECTRA_CAMERA=1
|
||||
EXTRA_CFLAGS += -I$(KERNEL_CAMERA_DRIVER_PATH)/../include
|
||||
EXTRA_CFLAGS += -I$(KERNEL_CAMERA_DRIVER_PATH)/../include/uapi
|
||||
else
|
||||
KERNEL_CAMERA_DRIVER_PATH ?= $(TOP)/$(KERNEL_SOURCE_PATH)/drivers/media/platform/msm/camera
|
||||
endif
|
||||
|
||||
EXTRA_CFLAGS += -DCAMERA_CCI
|
||||
EXTRA_CFLAGS += -I$(KERNEL_CAMERA_DRIVER_PATH)/cam_utils
|
||||
EXTRA_CFLAGS += -I$(KERNEL_CAMERA_DRIVER_PATH)/cam_cpas/include
|
||||
EXTRA_CFLAGS += -I$(KERNEL_CAMERA_DRIVER_PATH)/cam_sensor_module/cam_sensor_io
|
||||
EXTRA_CFLAGS += -I$(KERNEL_CAMERA_DRIVER_PATH)/cam_sensor_module/cam_sensor_utils
|
||||
EXTRA_CFLAGS += -I$(KERNEL_CAMERA_DRIVER_PATH)/cam_sensor_module/cam_cci
|
||||
EXTRA_CFLAGS += -I$(KERNEL_CAMERA_DRIVER_PATH)/cam_req_mgr
|
||||
EXTRA_CFLAGS += -I$(KERNEL_CAMERA_DRIVER_PATH)/cam_smmu
|
||||
endif
|
||||
|
||||
EXTRA_CFLAGS += -I$(TOP)/motorola/kernel/modules/include
|
||||
EXTRA_CFLAGS += -Wall
|
||||
KBUILD_EXTRA_SYMBOLS += $(CURDIR)/$(KBUILD_EXTMOD)/../../sensors/Module.symvers
|
||||
dts201a_mmi-y := dts201a.o dts201a-cci.o
|
||||
obj-m += dts201a_mmi.o
|
||||
|
||||
|
||||
10
drivers/misc/dts201a/Makefile
Normal file
10
drivers/misc/dts201a/Makefile
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
KERNEL_SRC ?= /lib/modules/$(shell uname -r)/build
|
||||
|
||||
all:
|
||||
$(MAKE) -C $(KERNEL_SRC) M=$(shell pwd) modules $(KBUILD_OPTIONS)
|
||||
|
||||
modules_install:
|
||||
$(MAKE) INSTALL_MOD_STRIP=1 -C $(KERNEL_SRC) M=$(shell pwd) modules_install
|
||||
|
||||
clean:
|
||||
$(MAKE) -C $(KERNEL_SRC) M=$(PWD) clean
|
||||
471
drivers/misc/dts201a/dts201a-cci.c
Normal file
471
drivers/misc/dts201a/dts201a-cci.c
Normal file
|
|
@ -0,0 +1,471 @@
|
|||
/*
|
||||
* dts201a_module-cci.c - Linux kernel modules for Partron
|
||||
* sensor
|
||||
*
|
||||
* Copyright (C) 2020 Motorola mobility
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
#ifdef CAMERA_CCI
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/irq.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/input.h>
|
||||
#include <linux/miscdevice.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/time.h>
|
||||
#include <linux/platform_device.h>
|
||||
/*
|
||||
* power specific includes
|
||||
*/
|
||||
#include <linux/pwm.h>
|
||||
#include <linux/regulator/consumer.h>
|
||||
#include <linux/pinctrl/consumer.h>
|
||||
#include <linux/clk.h>
|
||||
#include <linux/of_gpio.h>
|
||||
/*
|
||||
* API includes
|
||||
*/
|
||||
#include "dts201a-cci.h"
|
||||
|
||||
#define SENSOR_NAME "dts201a"
|
||||
#define DRV_NAME "dts201a_cci"
|
||||
|
||||
|
||||
#define OTHER_DEVICE_TYPE 0x000200ff
|
||||
struct cam_subdev *g_v4l2_dev_str = NULL;
|
||||
|
||||
|
||||
|
||||
static int dts201a_request_pwren(struct cci_ctrl_t *cci_ctrl)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (cci_ctrl->pwren_gpio == -1) {
|
||||
dts201a_wanrmsg("pwren gpio disable");
|
||||
goto no_gpio;
|
||||
}
|
||||
|
||||
dts201a_dbgmsg("request pwren_gpio %d", cci_ctrl->pwren_gpio);
|
||||
rc = gpio_request(cci_ctrl->pwren_gpio, "dts201a_pwren");
|
||||
if (rc) {
|
||||
dts201a_errmsg("fail to acquire pwren %d", rc);
|
||||
goto no_gpio;
|
||||
}
|
||||
|
||||
rc = gpio_direction_output(cci_ctrl->pwren_gpio, 0);
|
||||
if (rc) {
|
||||
dts201a_errmsg("fail to configure pwren as output %d", rc);
|
||||
}
|
||||
|
||||
return rc;
|
||||
|
||||
no_gpio:
|
||||
rc =-1;
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void dts201a_release_pwren(struct cci_ctrl_t *cci_ctrl)
|
||||
{
|
||||
if (cci_ctrl->pwren_gpio > 0) {
|
||||
dts201a_dbgmsg("release pwren_gpio %d", cci_ctrl->pwren_gpio);
|
||||
gpio_free(cci_ctrl->pwren_gpio);
|
||||
}
|
||||
cci_ctrl->pwren_gpio = -1;
|
||||
}
|
||||
|
||||
static void dts201a_release_gpios_cci(struct cci_ctrl_t *t_ctrl)
|
||||
{
|
||||
if (t_ctrl->power_supply) {
|
||||
regulator_put(t_ctrl->power_supply);
|
||||
t_ctrl->power_supply = NULL;
|
||||
}
|
||||
if (t_ctrl->cci_supply) {
|
||||
regulator_put(t_ctrl->cci_supply);
|
||||
t_ctrl->cci_supply = NULL;
|
||||
}
|
||||
dts201a_release_pwren(t_ctrl);
|
||||
}
|
||||
|
||||
static int dts201a_get_dt_info(struct device *dev, struct cci_ctrl_t *t_ctrl)
|
||||
{
|
||||
int rc = 0;
|
||||
struct device_node *of_node = NULL;
|
||||
|
||||
if (!dev || !t_ctrl)
|
||||
return -EINVAL;
|
||||
|
||||
of_node = dev->of_node;
|
||||
if (!of_node) {
|
||||
dts201a_errmsg("of_node is NULL %d\n", __LINE__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
t_ctrl->pwren_gpio = -1;
|
||||
rc = of_property_read_u32(of_node, "cell-index", &t_ctrl->pdev->id);
|
||||
if (rc < 0) {
|
||||
dts201a_errmsg("failed to read cell index %d\n", __LINE__);
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = of_property_read_u32(of_node, "cci-master", &t_ctrl->cci_master);
|
||||
if (rc < 0) {
|
||||
dts201a_errmsg("failed to get the cci master %d\n", __LINE__);
|
||||
return rc;
|
||||
}
|
||||
rc = of_property_read_u32(of_node, "cci-device", &t_ctrl->cci_num);
|
||||
if (rc < 0) {
|
||||
/* Set default master 0 */
|
||||
t_ctrl->cci_num = CCI_DEVICE_0;
|
||||
rc = 0;
|
||||
}
|
||||
t_ctrl->io_master_info.cci_client->cci_device = t_ctrl->cci_num;
|
||||
|
||||
t_ctrl->power_supply = regulator_get(dev, "laser");
|
||||
if (IS_ERR(t_ctrl->power_supply) || t_ctrl->power_supply == NULL) {
|
||||
t_ctrl->power_supply = NULL;
|
||||
|
||||
dts201a_wanrmsg("no regulator, laser power_supply");
|
||||
}
|
||||
t_ctrl->cci_supply = regulator_get(dev, "cci");
|
||||
if (IS_ERR(t_ctrl->cci_supply)) {
|
||||
t_ctrl->cci_supply = NULL;
|
||||
/* try gpio */
|
||||
rc = of_property_read_u32_array(dev->of_node, "pwren-gpio", &t_ctrl->pwren_gpio, 1);
|
||||
if (rc) {
|
||||
t_ctrl->pwren_gpio = -1;
|
||||
dts201a_wanrmsg("no regulator, nor power gpio => power ctrl disabled");
|
||||
}
|
||||
if (gpio_is_valid(t_ctrl->pwren_gpio)) {
|
||||
rc = devm_gpio_request(dev, gf_dev->pwr_gpio, "fir_pwr");
|
||||
if (rc) {
|
||||
dts201a_wanrmsg("failed to request pwr gpio, rc = %d\n", rc);
|
||||
}
|
||||
gpio_direction_output(gf_dev->pwr_gpio, 1);
|
||||
dts201a_wanrmsg("Unable to get cci power supply");
|
||||
}
|
||||
if (t_ctrl->pwren_gpio != -1)
|
||||
rc = dts201a_request_pwren(t_ctrl);
|
||||
return rc;
|
||||
|
||||
|
||||
}
|
||||
static int msm_tof_close(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
|
||||
{
|
||||
int rc = 0;
|
||||
return rc;
|
||||
}
|
||||
|
||||
static const struct v4l2_subdev_internal_ops msm_tof_internal_ops = {
|
||||
.close = msm_tof_close,
|
||||
};
|
||||
|
||||
static long msm_tof_subdev_ioctl(struct v4l2_subdev *sd,
|
||||
unsigned int cmd, void *arg)
|
||||
{
|
||||
int32_t rc = 0;
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int32_t msm_tof_power(struct v4l2_subdev *sd, int on)
|
||||
{
|
||||
dts201a_dbgmsg("TOF power called\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct v4l2_subdev_core_ops msm_tof_subdev_core_ops = {
|
||||
.ioctl = msm_tof_subdev_ioctl,
|
||||
.s_power = msm_tof_power,
|
||||
};
|
||||
|
||||
static struct v4l2_subdev_ops msm_tof_subdev_ops = {
|
||||
.core = &msm_tof_subdev_core_ops,
|
||||
};
|
||||
|
||||
static int32_t dts201a_platform_probe(struct platform_device *pdev)
|
||||
{
|
||||
int32_t rc = 0;
|
||||
struct dts201a_data *dts201a_data = NULL;
|
||||
struct cci_ctrl_t *cci_ctrl = NULL;
|
||||
struct cam_sensor_cci_client *cci_client = NULL;
|
||||
|
||||
dts201a_errmsg("Enter\n");
|
||||
|
||||
if (!cam_cci_get_subdev(0)){
|
||||
dts201a_errmsg("Get cam_cci_get_subdev error\n");
|
||||
return -EPROBE_DEFER;
|
||||
}
|
||||
dts201a_info("Get cam_cci_get_subdev success\n");
|
||||
dts201a_data = kzalloc(sizeof(struct dts201a_data), GFP_KERNEL);
|
||||
if (!dts201a_data) {
|
||||
rc = -ENOMEM;
|
||||
dts201a_errmsg("memory failed\n");
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (dts201a_data) {
|
||||
dts201a_data->client_object = kzalloc(sizeof(struct cci_ctrl_t), GFP_KERNEL);
|
||||
if (!dts201a_data->client_object) {
|
||||
rc = -ENOMEM;
|
||||
dts201a_errmsg("alloc client_object failed\n");
|
||||
goto free_dts201a_data;
|
||||
}
|
||||
cci_ctrl = (struct cci_ctrl_t *)dts201a_data->client_object;
|
||||
}
|
||||
mutex_init(&dts201a_data->lock);
|
||||
mutex_lock(&dts201a_data->lock);
|
||||
cci_ctrl->pdev = pdev;
|
||||
|
||||
cci_ctrl->dts201a_data = dts201a_data;
|
||||
cci_ctrl->device_type = MSM_CAMERA_PLATFORM_DEVICE;
|
||||
cci_ctrl->cam_pinctrl_status = 0;
|
||||
cci_ctrl->io_master_info.master_type = CCI_MASTER;
|
||||
cci_ctrl->io_master_info.cci_client = kzalloc(
|
||||
sizeof(struct cam_sensor_cci_client), GFP_KERNEL);
|
||||
if (!cci_ctrl->io_master_info.cci_client) {
|
||||
dts201a_errmsg("alloc cci_client failed\n");
|
||||
goto free_tof_ctrl;
|
||||
}
|
||||
|
||||
rc = dts201a_get_dt_info(&pdev->dev, cci_ctrl);
|
||||
if (rc < 0) {
|
||||
dts201a_errmsg("%d, failed to get dt info rc %d\n", __LINE__, rc);
|
||||
goto free_cci_client;
|
||||
}
|
||||
|
||||
|
||||
cci_client = cci_ctrl->io_master_info.cci_client;
|
||||
cci_client->cci_i2c_master = cci_ctrl->cci_master;
|
||||
//i2c slave address
|
||||
cci_client->sid = 0x3A;
|
||||
cci_client->retries = 3;
|
||||
cci_client->id_map = 0;
|
||||
//i2c speed 400k fast, 100k standard I2C_STANDARD_MODE
|
||||
cci_client->i2c_freq_mode = I2C_FAST_MODE;
|
||||
|
||||
cci_ctrl->v4l2_dev_str.internal_ops = &msm_tof_internal_ops;
|
||||
cci_ctrl->v4l2_dev_str.ops = &msm_tof_subdev_ops;
|
||||
strlcpy(cci_ctrl->device_name, SENSOR_NAME,
|
||||
sizeof(cci_ctrl->device_name));
|
||||
cci_ctrl->v4l2_dev_str.name = cci_ctrl->device_name;
|
||||
cci_ctrl->v4l2_dev_str.sd_flags = (V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS);
|
||||
cci_ctrl->v4l2_dev_str.sd_flags = (V4L2_SUBDEV_FL_HAS_EVENTS);
|
||||
cci_ctrl->v4l2_dev_str.ent_function = OTHER_DEVICE_TYPE;
|
||||
cci_ctrl->v4l2_dev_str.token = cci_ctrl;
|
||||
|
||||
rc = cam_register_subdev(&(cci_ctrl->v4l2_dev_str));
|
||||
if (rc) {
|
||||
dts201a_errmsg("fail to create subdev");
|
||||
goto unregister_subdev;
|
||||
}
|
||||
dts201a_info("cam_register_subdev done \n");
|
||||
g_v4l2_dev_str = &cci_ctrl->v4l2_dev_str;
|
||||
|
||||
/* setup device data */
|
||||
dev_set_drvdata(&pdev->dev, dts201a_data);
|
||||
|
||||
dts201a_power_up_cci((void *)cci_ctrl);
|
||||
msleep(10);
|
||||
/* setup other stuff */
|
||||
rc = dts201a_setup(&pdev->dev, dts201a_data);
|
||||
if (rc) {
|
||||
dts201a_errmsg("fail to dts201a_palfrform_probe");
|
||||
goto release_gpios;
|
||||
}
|
||||
kref_init(&cci_ctrl->ref);
|
||||
|
||||
dts201a_info("End = %d\n", rc);
|
||||
mutex_unlock(&dts201a_data->lock);
|
||||
return rc;
|
||||
|
||||
release_gpios:
|
||||
camera_io_release(&cci_ctrl->io_master_info);
|
||||
dts201a_release_gpios_cci(cci_ctrl);
|
||||
unregister_subdev:
|
||||
cam_unregister_subdev(&(cci_ctrl->v4l2_dev_str));
|
||||
free_cci_client:
|
||||
kfree(cci_ctrl->io_master_info.cci_client);
|
||||
free_tof_ctrl:
|
||||
kfree(cci_ctrl);
|
||||
free_dts201a_data:
|
||||
mutex_unlock(&dts201a_data->lock);
|
||||
kfree(dts201a_data);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int32_t dts201a_platform_remove(struct platform_device *pdev)
|
||||
{
|
||||
int ret = 0;
|
||||
struct dts201a_data *dts201a_data = platform_get_drvdata(pdev);
|
||||
struct cci_ctrl_t *cci_ctrl = (struct cci_ctrl_t *)dts201a_data->client_object;
|
||||
dts201a_cleanup(dts201a_data);
|
||||
platform_set_drvdata(pdev, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct of_device_id dts201a_cci_dt_match[] = {
|
||||
{.compatible = "partron,dts201a",},
|
||||
{},
|
||||
};
|
||||
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
/**
|
||||
* dts201a_pm_suspend - PM suspend function
|
||||
* Called by kernel during system suspend phrase
|
||||
*/
|
||||
static int dts201a_pm_suspend(struct device *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* dts201a_pm_resume - PM resume function
|
||||
* Called by kernel during system wakeup
|
||||
*/
|
||||
static int dts201a_pm_resume(struct device *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static const struct dev_pm_ops dev_pm_ops = {
|
||||
.suspend = dts201a_pm_suspend,
|
||||
.resume = dts201a_pm_resume,
|
||||
};
|
||||
#endif
|
||||
|
||||
static struct platform_driver dts201a_platform_driver = {
|
||||
.probe = dts201a_platform_probe,
|
||||
.remove = dts201a_platform_remove,
|
||||
.driver = {
|
||||
.name = DRV_NAME,
|
||||
.owner = THIS_MODULE,
|
||||
.of_match_table = dts201a_cci_dt_match,
|
||||
#ifdef CONFIG_PM
|
||||
.pm = &dev_pm_ops,
|
||||
#endif
|
||||
|
||||
},
|
||||
};
|
||||
|
||||
int dts201a_power_up_cci(void *object)
|
||||
{
|
||||
int rc = 0;
|
||||
struct cci_ctrl_t *cci_ctrl = (struct cci_ctrl_t *)object;
|
||||
|
||||
dts201a_dbgmsg("Enter");
|
||||
|
||||
if (!cci_ctrl) {
|
||||
dts201a_errmsg("dts201a_power_up_cci failed %d\n", __LINE__);
|
||||
return -EINVAL;
|
||||
}
|
||||
/* turn on power */
|
||||
if (cci_ctrl->power_supply) {
|
||||
rc = cam_soc_util_regulator_enable(cci_ctrl->power_supply, "laser", 2800000, 2800000, 80000, 0);
|
||||
if (rc) {
|
||||
dts201a_errmsg("fail to turn on avdd regulator");
|
||||
return rc;
|
||||
}
|
||||
dts201a_dbgmsg("enable laser 28\n");
|
||||
} else
|
||||
dts201a_wanrmsg("no power control");
|
||||
if (cci_ctrl->cci_supply) {
|
||||
rc = cam_soc_util_regulator_enable(cci_ctrl->cci_supply,"cci", 1800000, 1800000, 0, 0);
|
||||
if (rc) {
|
||||
dts201a_errmsg("fail to turn on iovdd regulator");
|
||||
return rc;
|
||||
}
|
||||
dts201a_dbgmsg("enable laser 18\n");
|
||||
} else {
|
||||
if (cci_ctrl->pwren_gpio != -1) {
|
||||
gpio_set_value_cansleep(cci_ctrl->pwren_gpio, 1);
|
||||
}
|
||||
}
|
||||
msleep(10);
|
||||
rc = camera_io_init(&cci_ctrl->io_master_info);
|
||||
if (rc < 0)
|
||||
dts201a_errmsg("cci init failed: rc: %d", rc);
|
||||
|
||||
dts201a_dbgmsg("End\n");
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int dts201a_power_down_cci(void *cci_object)
|
||||
{
|
||||
int rc = 0;
|
||||
struct cci_ctrl_t *cci_ctrl = (struct cci_ctrl_t *)cci_object;
|
||||
|
||||
if (!cci_ctrl) {
|
||||
dts201a_errmsg("dts201a_power_down_cci failed %d\n", __LINE__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
dts201a_dbgmsg("Enter\n");
|
||||
/* turn off power */
|
||||
if (cci_ctrl->power_supply) {
|
||||
rc = cam_soc_util_regulator_disable(cci_ctrl->power_supply, "laser", 2800000, 2800000, 80000, 0);
|
||||
rc = cam_soc_util_regulator_disable(cci_ctrl->cci_supply,"cci", 1800000, 1800000, 0, 0);
|
||||
if (rc)
|
||||
dts201a_errmsg("reg disable failed. rc=%d\n",
|
||||
rc);
|
||||
} else if (cci_ctrl->pwren_gpio != -1) {
|
||||
gpio_set_value_cansleep(cci_ctrl->pwren_gpio, 0);
|
||||
}
|
||||
camera_io_release(&cci_ctrl->io_master_info);
|
||||
|
||||
dts201a_dbgmsg("power off");
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
void dts201a_clean_up_cci(void)
|
||||
{
|
||||
int rc = 0;
|
||||
rc = cam_unregister_subdev(g_v4l2_dev_str);
|
||||
}
|
||||
|
||||
int dts201a_init_cci(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
dts201a_errmsg("Enter\n");
|
||||
|
||||
/* register as a platform device */
|
||||
ret = platform_driver_register(&dts201a_platform_driver);
|
||||
if (ret)
|
||||
dts201a_errmsg("%d, error ret:%d\n", __LINE__, ret);
|
||||
|
||||
dts201a_dbgmsg("End\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void dts201a_exit_cci(void *object)
|
||||
{
|
||||
struct cci_ctrl_t *cci_ctrl = (struct cci_ctrl_t *)object;
|
||||
|
||||
dts201a_dbgmsg("Enter\n");
|
||||
platform_driver_unregister(&dts201a_platform_driver);
|
||||
dts201a_dbgmsg("End\n");
|
||||
}
|
||||
#endif /* end of CAMERA_CCI */
|
||||
63
drivers/misc/dts201a/dts201a-cci.h
Normal file
63
drivers/misc/dts201a/dts201a-cci.h
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* dts201a_module-cci.h - Linux kernel modules for Partron thermopile sensor
|
||||
*
|
||||
* Copyright (C) 2020 Motorola mobility
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
/*
|
||||
* Defines
|
||||
*/
|
||||
#ifndef DTS201A_CCI_H
|
||||
#define DTS201A_CCI_H
|
||||
#include <linux/types.h>
|
||||
#include "dts201a.h"
|
||||
|
||||
|
||||
#ifdef CAMERA_CCI
|
||||
struct cci_ctrl_t {
|
||||
struct platform_device *pdev;
|
||||
enum msm_camera_device_type_t device_type;
|
||||
enum cci_device_num cci_num;
|
||||
enum cci_i2c_master_t cci_master;
|
||||
struct camera_io_master io_master_info;
|
||||
struct cam_subdev v4l2_dev_str;
|
||||
struct dts201a_data *dts201a_data;
|
||||
struct msm_pinctrl_info pinctrl_info;
|
||||
uint8_t cam_pinctrl_status;
|
||||
char device_name[20];
|
||||
|
||||
/* reference counter */
|
||||
struct kref ref;
|
||||
/*!< if null no regulator use for power ctrl */
|
||||
struct regulator *power_supply;
|
||||
|
||||
struct regulator *cci_supply;
|
||||
|
||||
/*!< power enable gpio number
|
||||
*
|
||||
* if -1 no gpio if vdd not avl pwr is not controllable
|
||||
*/
|
||||
int pwren_gpio;
|
||||
};
|
||||
|
||||
int dts201a_init_cci(void);
|
||||
void __exit dts201a_exit_cci(void *);
|
||||
int dts201a_power_up_cci(void *);
|
||||
int dts201a_power_down_cci(void *);
|
||||
int dts201a_reset_release_cci(void *);
|
||||
int dts201a_reset_hold_cci(void *);
|
||||
void dts201a_clean_up_cci(void);
|
||||
void *dts201a_get_cci(void *);
|
||||
void dts201a_put_cci(void *);
|
||||
|
||||
#endif /* CAMERA_CCI */
|
||||
#endif /* DTS201A_CCI_H */
|
||||
1450
drivers/misc/dts201a/dts201a.c
Normal file
1450
drivers/misc/dts201a/dts201a.c
Normal file
File diff suppressed because it is too large
Load diff
216
drivers/misc/dts201a/dts201a.h
Normal file
216
drivers/misc/dts201a/dts201a.h
Normal file
|
|
@ -0,0 +1,216 @@
|
|||
/*
|
||||
* linux/sensor/dts201a.h
|
||||
*
|
||||
* Partron DTS201A Digital Thermopile Sensor module driver
|
||||
*
|
||||
* Copyright (C) 2013 Partron Co., Ltd. - Sensor Lab.
|
||||
* partron (partron@partron.co.kr)
|
||||
*
|
||||
* Both authors are willing to be considered the contact and update points for
|
||||
* the driver.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
/******************************************************************************
|
||||
Revision 1.0.0 2013/Nov/22:
|
||||
first release
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __DTS201A_H__
|
||||
#define __DTS201A_H__
|
||||
#include <linux/types.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/workqueue.h>
|
||||
#include <linux/miscdevice.h>
|
||||
#include <linux/wait.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/power_supply.h>
|
||||
#ifdef CAMERA_CCI
|
||||
#include <media/v4l2-event.h>
|
||||
#include <media/v4l2-subdev.h>
|
||||
#include <media/v4l2-ioctl.h>
|
||||
#include <media/cam_sensor.h>
|
||||
#include <cam_sensor_i2c.h>
|
||||
#include <cam_sensor_spi.h>
|
||||
#include <cam_sensor_io.h>
|
||||
#include <cam_cci_dev.h>
|
||||
#include <cam_req_mgr_util.h>
|
||||
#include <cam_req_mgr_interface.h>
|
||||
#include <cam_mem_mgr.h>
|
||||
#include <cam_subdev.h>
|
||||
#include "cam_soc_util.h"
|
||||
#endif
|
||||
/**
|
||||
* set to 0 1 activate or not debug from work (data interrupt/polling)
|
||||
*/
|
||||
#define WORK_DEBUG 0
|
||||
#if WORK_DEBUG
|
||||
# define work_dbg(msg, ...)\
|
||||
printk("[D DTS201A] :" msg "\n", ##__VA_ARGS__)
|
||||
#else
|
||||
# define work_dbg(...) (void)0
|
||||
#endif
|
||||
#define DEBUG
|
||||
#ifdef DEBUG
|
||||
#define dts201a_dbgmsg(str, ...) \
|
||||
pr_info("%s:" str, __func__,##__VA_ARGS__);
|
||||
#else
|
||||
# define dts201a_dbgmsg(...) (void)0
|
||||
#endif
|
||||
|
||||
|
||||
#define dts201a_info(str, args...) \
|
||||
pr_info("%s: %d: " str "\n", __func__,__LINE__, ##args)
|
||||
|
||||
#define dts201a_errmsg(str, args...) \
|
||||
pr_err("%s:%d: " str, __func__, __LINE__,##args)
|
||||
|
||||
#define dts201a_wanrmsg(str, args...) \
|
||||
pr_warn("%s:%d: " str, __func__, __LINE__,##args)
|
||||
|
||||
/* turn off poll log if not defined */
|
||||
#ifndef DTS201A_LOG_POLL_TIMING
|
||||
# define DTS201A_LOG_POLL_TIMING 0
|
||||
#endif
|
||||
/* turn off cci log timing if not defined */
|
||||
#ifndef DTS201A_LOG_CCI_TIMING
|
||||
# define DTS201A_LOG_CCI_TIMING 0
|
||||
#endif
|
||||
#define DTS_I2C_WRITE 0
|
||||
#define DTS_I2C_READ 1
|
||||
#define DTS201A_SADDR (0x3A)
|
||||
|
||||
#define DTS201A_ID0 0x0000
|
||||
#define DTS201A_ID1 0x0000
|
||||
|
||||
|
||||
|
||||
//#define DTS201A_MAVG
|
||||
//#define DTS201A_ONE_MODE
|
||||
|
||||
#ifdef DTS201A_ONE_MODE
|
||||
#define STX 0x1A
|
||||
#define ETX 0x2E
|
||||
#else /* DTS201A_TWO_MODE */
|
||||
#define STX_N1 0x1A
|
||||
#define ETX_N1 0x27
|
||||
#define STX_M1 0x13
|
||||
#define ETX_M1 0x15
|
||||
#define STX_H2 0x28
|
||||
#define ETX_H2 0x2C
|
||||
#define STX_M2 0x36
|
||||
#define ETX_M2 0x38
|
||||
#endif
|
||||
|
||||
#define DTS_VENDOR "PARTRON"
|
||||
#define DTS_CHIP_ID "DTS201A"
|
||||
#define DTS_DEV_NAME "dts201a"
|
||||
|
||||
|
||||
//#define DTS201A_ID0 0x3026
|
||||
//#define DTS201A_ID1 0x0010
|
||||
//#define DTS201A_ID0 0x3027
|
||||
//#define DTS201A_ID1 0x0110
|
||||
//#define DTS201A_ID0 0x3218
|
||||
//#define DTS201A_ID1 0x1110
|
||||
#define DTS_DELAY_DEFAULT 200
|
||||
#define DTS_DELAY_MINIMUM 30
|
||||
#define DTS_CONVERSION_TIME 30
|
||||
|
||||
#ifdef DTS201A_MAVG
|
||||
#define DTS100A_MOVING_OAVG 5
|
||||
#define DTS100A_MOVING_AAVG 5
|
||||
#endif
|
||||
|
||||
/* CONTROL REGISTERS */
|
||||
#define DTS_CUST_ID0 0x00 /* customer ID Low byte */
|
||||
#define DTS_CUST_ID1 0x01 /* customer ID High byte */
|
||||
#define DTS_SM 0xA0 /* Sensor Measurement */
|
||||
#define DTS_SM_USER 0xA1 /* Sensor Measurement User Config */
|
||||
#define DTS_SM_AZSM 0xA2 /* Auto-Zero corrected Sensor Measurement */
|
||||
#define DTS_SM_AZSM_USER 0xA3 /* Auto-Zero corrected Sensor Measurement User Config */
|
||||
#define DTS_TM 0xA4 /* Temperature Measurement */
|
||||
#define DTS_TM_USER 0xA5 /* Temperature Measurement User Config */
|
||||
#define DTS_TM_AZTM 0xA6 /* Auto-Zero corrected Temperature Measurement */
|
||||
#define DTS_TM_AZTM_USER 0xA7 /* Auto-Zero corrected Temperature Measurement User Config */
|
||||
#define DTS_START_NOM 0xA8 /* transition to normal mode */
|
||||
#define DTS_START_CM 0xA9 /* transition to command mode */
|
||||
#define DTS_MEASURE 0xAA /* measurement cycle and calculation and storage 1*/
|
||||
#define DTS_MEASURE1 0xAB /* measurement cycle and calculation and storage 1*/
|
||||
#define DTS_MEASURE2 0xAC /* measurement cycle and calculation and storage 2*/
|
||||
#define DTS_MEASURE4 0xAD /* measurement cycle and calculation and storage 4*/
|
||||
#define DTS_MEASURE8 0xAE /* measurement cycle and calculation and storage 8*/
|
||||
#define DTS_MEASURE16 0xAF /* measurement cycle and calculation and storage 16*/
|
||||
|
||||
//#define COEFFICIENT_FILE_PATH "/efs/FactoryApp/coefficient"
|
||||
#define COEFFICIENT_FILE_PATH "/sdcard/Download/coefficient"
|
||||
|
||||
struct outputdata {
|
||||
#ifdef DTS201A_MAVG
|
||||
u32 therm_avg[DTS100A_MOVING_OAVG];
|
||||
u32 ambient_avg[DTS100A_MOVING_AAVG];
|
||||
#endif
|
||||
u32 therm; // object temperature
|
||||
u32 temp; // ambient temperature
|
||||
u8 status;
|
||||
};
|
||||
|
||||
#ifdef __KERNEL__
|
||||
struct dts201a_platform_data {
|
||||
int irq;
|
||||
};
|
||||
#endif /* __KERNEL__ */
|
||||
struct dts201a_data {
|
||||
int id; /*!< multiple device id 0 based*/
|
||||
char name[64]; /*!< misc device name */
|
||||
int32_t hw_rev; /*!< hardware revision number*/
|
||||
|
||||
void *client_object; /*!< cci or i2c model i/f specific ptr */
|
||||
bool is_device_remove; /*!< true when device has been remove */
|
||||
|
||||
struct class* thermopile_class;
|
||||
struct mutex lock;
|
||||
struct mutex dts201a_i2c_mutex;
|
||||
struct workqueue_struct *thermopile_wq;
|
||||
struct work_struct work_thermopile;
|
||||
struct input_dev *input_dev;
|
||||
struct device *dev;
|
||||
struct outputdata out;
|
||||
struct hrtimer timer;
|
||||
ktime_t poll_delay;
|
||||
int hw_initialized;
|
||||
atomic_t enabled;
|
||||
u8 ndata[34];
|
||||
u8 hdata[34];
|
||||
|
||||
struct i2c_client *client;
|
||||
struct regulator *i2c_power_supply;
|
||||
/*!< power enable gpio number
|
||||
*
|
||||
* if -1 no gpio if vdd not avl pwr is not controllable
|
||||
*/
|
||||
int i2c_pwren_gpio;
|
||||
bool vdd_en;
|
||||
};
|
||||
|
||||
|
||||
int dts201a_setup(struct device *dev,struct dts201a_data *data);
|
||||
int dts201a_cleanup(struct dts201a_data *ther);
|
||||
int dts201a_enable(struct dts201a_data *ther);
|
||||
int dts201a_disable(struct dts201a_data *ther);
|
||||
#endif /* __DTS201A_H__ */
|
||||
|
|
@ -50,8 +50,9 @@
|
|||
#define SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR 20
|
||||
|
||||
#define SENSOR_TYPE_MOTO_CAPSENSE (SENSOR_TYPE_DEVICE_PRIVATE_BASE + 16)
|
||||
#define SENSOR_TYPE_MOTO_DOUBLE_TAP (SENSOR_TYPE_DEVICE_PRIVATE_BASE + 30)
|
||||
|
||||
#define SENSOR_TYPE_MOTO_DOUBLE_TAP (SENSOR_TYPE_DEVICE_PRIVATE_BASE + 30)
|
||||
#define SENSOR_TYPE_MOTO_BODYTEMP (SENSOR_TYPE_DEVICE_PRIVATE_BASE + 42)
|
||||
enum LIS3DH_AXIS {
|
||||
AXIS_X = 0,
|
||||
AXIS_Y,
|
||||
|
|
|
|||
Loading…
Reference in a new issue