summaryrefslogtreecommitdiff
path: root/drivers/misc
diff options
context:
space:
mode:
authorDavide Garberi <dade.garberi@gmail.com>2018-11-08 22:05:48 +0100
committerDavide Garberi <dade.garberi@gmail.com>2022-07-27 18:59:06 +0200
commit8e6f42808d5e2fc18866cfdae51eb5745d757994 (patch)
treeaa871461ac25aa130c49839569506ce2839a963a /drivers/misc
parent90f7546c2b4ac17a46a24e699877a727d6033757 (diff)
cclogic: Linuxify
* Bring the coding style closer to Linux's fixing most checkpatch.pl warnings on all the files of the directories * I didn't fix every 80 chars line warning because that was way too much Signed-off-by: Davide Garberi <dade.garberi@gmail.com>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/cclogic/cclogic-class.c120
-rw-r--r--drivers/misc/cclogic/cclogic-class.h8
-rw-r--r--drivers/misc/cclogic/cclogic-core.c1058
-rw-r--r--drivers/misc/cclogic/cclogic-core.h32
-rw-r--r--drivers/misc/cclogic/pi5usb30216d.c119
-rw-r--r--drivers/misc/cclogic/tusb320hai.c391
6 files changed, 756 insertions, 972 deletions
diff --git a/drivers/misc/cclogic/cclogic-class.c b/drivers/misc/cclogic/cclogic-class.c
index fffce515ed1a..a58e7b6575b5 100644
--- a/drivers/misc/cclogic/cclogic-class.c
+++ b/drivers/misc/cclogic/cclogic-class.c
@@ -11,31 +11,34 @@
struct class *cclogic_class;
static atomic_t device_count;
-
-// USB port's supported modes. (read-only)
-// Contents: "", "ufp", "dfp", or "ufp dfp".
-static ssize_t cclogic_supported_modes_show(struct device *dev,
+/*
+ * USB port's supported modes. (read-only)
+ * Contents: "", "ufp", "dfp", or "ufp dfp".
+*/
+static ssize_t cclogic_supported_modes_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct cclogic_class_dev *cdev = (struct cclogic_class_dev *) dev_get_drvdata(dev);
pr_debug("[%s][%d]\n", __func__, __LINE__);
- if(cdev->support & (CCLOGIC_SUPPORT_MODE_DUAL))
+ if (cdev->support & (CCLOGIC_SUPPORT_MODE_DUAL))
return sprintf(buf, "ufp dfp");
else if (cdev->support & CCLOGIC_SUPPORT_MODE_UFP)
return sprintf(buf, "ufp");
else if (cdev->support & CCLOGIC_SUPPORT_MODE_DFP)
return sprintf(buf, "dfp");
- else{
- *buf='\0';
+ else {
+ *buf = '\0';
return 0;
}
}
-// USB port's current mode. (read-write if configurable)
-// Contents: "", "ufp", or "dfp".
-static ssize_t cclogic_mode_show(struct device *dev,
+/*
+ * USB port's current mode. (read-write if configurable)
+ * Contents: "", "ufp", or "dfp".
+*/
+static ssize_t cclogic_mode_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct cclogic_class_dev *cdev = (struct cclogic_class_dev *) dev_get_drvdata(dev);
@@ -46,19 +49,21 @@ static ssize_t cclogic_mode_show(struct device *dev,
pr_debug("[%s][%d]\n", __func__, __LINE__);
mode = cclogic_get_connected_mode(pstate);
- if(mode == CCLOGIC_MODE_UFP)
- return sprintf(buf,"ufp");
+ if (mode == CCLOGIC_MODE_UFP)
+ return sprintf(buf, "ufp");
else if (mode == CCLOGIC_MODE_DFP)
- return sprintf(buf,"dfp");
- else{
+ return sprintf(buf, "dfp");
+ else {
*buf = '\0';
return 0;
}
}
-// USB port's current mode. (read-write if configurable)
-// Contents: "", "ufp", or "dfp".
-static ssize_t cclogic_mode_store(struct device *dev,
+/*
+ * USB port's current mode. (read-write if configurable)
+ * Contents: "", "ufp", or "dfp".
+*/
+static ssize_t cclogic_mode_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct cclogic_class_dev *cdev = (struct cclogic_class_dev *) dev_get_drvdata(dev);
@@ -66,18 +71,19 @@ static ssize_t cclogic_mode_store(struct device *dev,
pr_debug("[%s][%d]\n", __func__, __LINE__);
- if(!strcmp(buf,"ufp")){
+ if (!strcmp(buf, "ufp"))
cclogic_set_mode(cclogic_dev, CCLOGIC_MODE_UFP);
- }else if(!strcmp(buf,"dfp")){
+ else if (!strcmp(buf, "dfp"))
cclogic_set_mode(cclogic_dev, CCLOGIC_MODE_DFP);
- }
return count;
}
-// USB port's current power role. (read-write if configurable)
-// Contents: "", "source", or "sink".
-static ssize_t cclogic_power_role_show(struct device *dev,
+/*
+ * USB port's current power role. (read-write if configurable)
+ * Contents: "", "source", or "sink".
+*/
+static ssize_t cclogic_power_role_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct cclogic_class_dev *cdev = (struct cclogic_class_dev *) dev_get_drvdata(dev);
@@ -86,19 +92,21 @@ static ssize_t cclogic_power_role_show(struct device *dev,
pr_debug("[%s][%d]\n", __func__, __LINE__);
- if(cclogic_get_power_role(pstate)==CCLOGIC_POWER_SINK)
- return sprintf(buf,"sink");
- else if(cclogic_get_power_role(pstate)==CCLOGIC_POWER_SOURCE)
- return sprintf(buf,"source");
- else{
+ if (cclogic_get_power_role(pstate) == CCLOGIC_POWER_SINK)
+ return sprintf(buf, "sink");
+ else if (cclogic_get_power_role(pstate) == CCLOGIC_POWER_SOURCE)
+ return sprintf(buf, "source");
+ else {
*buf = '\0';
return 0;
}
}
-// USB port's current power role. (read-write if configurable)
-// Contents: "", "source", or "sink".
-static ssize_t cclogic_power_role_store(struct device *dev,
+/*
+ * USB port's current power role. (read-write if configurable)
+ * Contents: "", "source", or "sink".
+*/
+static ssize_t cclogic_power_role_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct cclogic_class_dev *cdev = (struct cclogic_class_dev *) dev_get_drvdata(dev);
@@ -106,18 +114,19 @@ static ssize_t cclogic_power_role_store(struct device *dev,
pr_debug("[%s][%d]\n", __func__, __LINE__);
- if(!strcmp(buf,"sink")){
+ if (!strcmp(buf, "sink"))
cclogic_set_power_role(cclogic_dev, CCLOGIC_POWER_SINK);
- }else if(!strcmp(buf,"source")){
+ else if (!strcmp(buf, "source"))
cclogic_set_power_role(cclogic_dev, CCLOGIC_POWER_SOURCE);
- }
return count;
}
-// USB port's current data role. (read-write if configurable)
-// Contents: "", "host", or "device".
-static ssize_t cclogic_data_role_show(struct device *dev,
+/*
+ * USB port's current data role. (read-write if configurable)
+ * Contents: "", "host", or "device".
+*/
+static ssize_t cclogic_data_role_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct cclogic_class_dev *cdev = (struct cclogic_class_dev *) dev_get_drvdata(dev);
@@ -126,19 +135,21 @@ static ssize_t cclogic_data_role_show(struct device *dev,
pr_debug("[%s][%d]\n", __func__, __LINE__);
- if(cclogic_get_data_role(pstate)==CCLOGIC_DATA_HOST)
- return sprintf(buf,"host");
- else if(cclogic_get_data_role(pstate)==CCLOGIC_DATA_DEVICE)
- return sprintf(buf,"device");
- else{
+ if (cclogic_get_data_role(pstate) == CCLOGIC_DATA_HOST)
+ return sprintf(buf, "host");
+ else if (cclogic_get_data_role(pstate) == CCLOGIC_DATA_DEVICE)
+ return sprintf(buf, "device");
+ else {
*buf = '\0';
return 0;
}
}
-// USB port's current data role. (read-write if configurable)
-// Contents: "", "host", or "device".
-static ssize_t cclogic_data_role_store(struct device *dev,
+/*
+ * USB port's current data role. (read-write if configurable)
+ * Contents: "", "host", or "device".
+*/
+static ssize_t cclogic_data_role_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct cclogic_class_dev *cdev = (struct cclogic_class_dev *) dev_get_drvdata(dev);
@@ -146,17 +157,14 @@ static ssize_t cclogic_data_role_store(struct device *dev,
pr_debug("[%s][%d]\n", __func__, __LINE__);
- if(!strcmp(buf,"host")){
+ if (!strcmp(buf, "host"))
cclogic_set_data_role(cclogic_dev, CCLOGIC_DATA_HOST);
- }else if(!strcmp(buf,"device")){
+ else if (!strcmp(buf, "device"))
cclogic_set_data_role(cclogic_dev, CCLOGIC_DATA_DEVICE);
- }
return count;
}
-
-
void cclogic_class_update_state(struct cclogic_class_dev *cdev)
{
kobject_uevent(&cdev->dev->kobj, KOBJ_CHANGE);
@@ -204,11 +212,11 @@ int cclogic_class_register(struct cclogic_class_dev *cdev)
cdev->device_mode_attr.attr.name = "mode";
cdev->device_mode_attr.attr.mode = S_IRUGO;
cdev->device_mode_attr.show = cclogic_mode_show;
- if((cdev->support & CCLOGIC_SUPPORT_MODE_DUAL) == CCLOGIC_SUPPORT_MODE_DUAL){
+ if ((cdev->support & CCLOGIC_SUPPORT_MODE_DUAL) == CCLOGIC_SUPPORT_MODE_DUAL) {
cdev->device_mode_attr.attr.mode |= S_IWUSR;
cdev->device_mode_attr.store = cclogic_mode_store;
}
- sysfs_attr_init(&cdev->device_mode_attr.attr);
+ sysfs_attr_init(&cdev->device_mode_attr.attr);
ret = device_create_file(cdev->dev, &cdev->device_mode_attr);
if (ret < 0)
goto err_create_file_2;
@@ -216,11 +224,11 @@ int cclogic_class_register(struct cclogic_class_dev *cdev)
cdev->device_power_role_attr.attr.name = "power_role";
cdev->device_power_role_attr.attr.mode = S_IRUGO;
cdev->device_power_role_attr.show = cclogic_power_role_show;
- if((cdev->support & CCLOGIC_SUPPORT_POWER_SWAP) == CCLOGIC_SUPPORT_POWER_SWAP){
+ if ((cdev->support & CCLOGIC_SUPPORT_POWER_SWAP) == CCLOGIC_SUPPORT_POWER_SWAP) {
cdev->device_power_role_attr.attr.mode |= S_IWUSR;
cdev->device_power_role_attr.store = cclogic_power_role_store;
}
- sysfs_attr_init(&cdev->device_power_role_attr.attr);
+ sysfs_attr_init(&cdev->device_power_role_attr.attr);
ret = device_create_file(cdev->dev, &cdev->device_power_role_attr);
if (ret < 0)
goto err_create_file_3;
@@ -228,11 +236,11 @@ int cclogic_class_register(struct cclogic_class_dev *cdev)
cdev->device_data_role_attr.attr.name = "data_role";
cdev->device_data_role_attr.attr.mode = S_IRUGO;
cdev->device_data_role_attr.show = cclogic_data_role_show;
- if((cdev->support & CCLOGIC_SUPPORT_DATA_SWAP) == CCLOGIC_SUPPORT_DATA_SWAP){
+ if ((cdev->support & CCLOGIC_SUPPORT_DATA_SWAP) == CCLOGIC_SUPPORT_DATA_SWAP) {
cdev->device_data_role_attr.attr.mode |= S_IWUSR;
cdev->device_data_role_attr.store = cclogic_data_role_store;
}
- sysfs_attr_init(&cdev->device_data_role_attr.attr);
+ sysfs_attr_init(&cdev->device_data_role_attr.attr);
ret = device_create_file(cdev->dev, &cdev->device_data_role_attr);
if (ret < 0)
goto err_create_file_4;
diff --git a/drivers/misc/cclogic/cclogic-class.h b/drivers/misc/cclogic/cclogic-class.h
index f9b664c4b339..c5276839ee65 100644
--- a/drivers/misc/cclogic/cclogic-class.h
+++ b/drivers/misc/cclogic/cclogic-class.h
@@ -1,10 +1,10 @@
#ifndef __CCLOGIC_CLASS_H__
#define __CCLOGIC_CLASS_H__
-struct cclogic_class_dev{
- const char *name;
- struct device *dev;
- int index;
+struct cclogic_class_dev {
+ const char *name;
+ struct device *dev;
+ int index;
unsigned int support;
struct device_attribute device_supported_modes_attr;
struct device_attribute device_mode_attr;
diff --git a/drivers/misc/cclogic/cclogic-core.c b/drivers/misc/cclogic/cclogic-core.c
index e2de82c81532..47efe02e20f9 100644
--- a/drivers/misc/cclogic/cclogic-core.c
+++ b/drivers/misc/cclogic/cclogic-core.c
@@ -1,12 +1,12 @@
-//
-// cclogic-core.c
-//
-// Core of CC-Logic drivers
-//
+/*
+ * cclogic-core.c
+ *
+ * Core of CC-Logic drivers
+ */
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/io.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
#include <linux/fs.h>
#include <linux/slab.h>
#include <linux/init.h>
@@ -33,13 +33,13 @@
static struct cclogic_dev *cclogic_priv;
static struct mutex cclogic_ops_lock;
-static int m_plug_state = 0;
+static int m_plug_state;
#define DRIVER_NAME "cclogic"
static BLOCKING_NOTIFIER_HEAD(cclogic_notifier_list);
-/**
+/*
* cclogic_register_client - register a client notifier
* @nb: notifier block to callback on events
*/
@@ -49,7 +49,7 @@ int cclogic_register_client(struct notifier_block *nb)
}
EXPORT_SYMBOL(cclogic_register_client);
-/**
+/*
* cclogic_unregister_client - unregister a client notifier
* @nb: notifier block to callback on events
*/
@@ -59,70 +59,59 @@ int cclogic_unregister_client(struct notifier_block *nb)
}
EXPORT_SYMBOL(cclogic_unregister_client);
-/**
- * cclogic_notifier_call_chain - notify clients of fb_events
- *
- */
+/* cclogic_notifier_call_chain - notify clients of fb_events */
int cclogic_notifier_call_chain(unsigned long val, void *v)
{
return blocking_notifier_call_chain(&cclogic_notifier_list, val, v);
}
EXPORT_SYMBOL_GPL(cclogic_notifier_call_chain);
-/*
- *
- */
static void cclogic_patch_state(struct cclogic_dev *pdata)
{
struct cclogic_state *state = &pdata->state;
- if(gpio_get_value(pdata->platform_data->irq_plug)){
+ if (gpio_get_value(pdata->platform_data->irq_plug)) {
state->evt = CCLOGIC_EVENT_DETACHED;
state->device = CCLOGIC_NO_DEVICE;
state->vbus = false;
state->cc = CCLOGIC_CC1;
}
}
-/*
- *
- */
+
int cclogic_vbus_power_on(struct cclogic_dev *cclogic_dev, bool enable)
{
struct cclogic_platform *p = cclogic_dev->platform_data;
int ret;
- pr_debug("[%s][%d] enable=%d\n", __func__, __LINE__,enable);
+ pr_debug("[%s][%d] enable=%d\n", __func__, __LINE__, enable);
- if (!p->vbus_reg) {
+ if (!p->vbus_reg)
return 0;
- }
- if(enable){
- if(cclogic_dev->vbus_on)
+ if (enable) {
+ if (cclogic_dev->vbus_on)
return 0;
ret = regulator_enable(p->vbus_reg);
- if (ret) {
- dev_err(&cclogic_dev->i2c_client->dev, "Failed to enable vbus_reg\n");
+ if (ret) {
+ dev_err(&cclogic_dev->i2c_client->dev, "Failed to enable vbus_reg\n");
return ret;
- }
+ }
cclogic_dev->vbus_on = true;
- }else{
- if(!cclogic_dev->vbus_on)
+ } else{
+ if (!cclogic_dev->vbus_on)
return 0;
- ret = regulator_disable(p->vbus_reg);
- if (ret) {
- dev_err(&cclogic_dev->i2c_client->dev, "Failed to disable vbus_reg\n");
- return ret;
- }
+ ret = regulator_disable(p->vbus_reg);
+ if (ret) {
+ dev_err(&cclogic_dev->i2c_client->dev, "Failed to disable vbus_reg\n");
+ return ret;
+ }
cclogic_dev->vbus_on = false;
}
return 0;
}
-/*
- *
- */
+
static int cclogic_reg_set_optimum_mode_check(struct regulator *reg,
int load_uA)
{
@@ -131,38 +120,36 @@ static int cclogic_reg_set_optimum_mode_check(struct regulator *reg,
return (regulator_count_voltages(reg) > 0) ?
regulator_set_load(reg, load_uA) : 0;
}
-/*
- *
- */
-static int cclogic_power_on(struct cclogic_dev *cclogic_dev, bool on)
+
+static int cclogic_power_on(struct cclogic_dev *cclogic_dev, bool on)
{
- int ret=0;
+ int ret = 0;
pr_debug("[%s][%d]\n", __func__, __LINE__);
- if (cclogic_dev->platform_data->i2c_pull_up) {
- if (on == false){
- if(cclogic_dev->regulator_en){
+ if (cclogic_dev->platform_data->i2c_pull_up) {
+ if (on == false) {
+ if (cclogic_dev->regulator_en) {
cclogic_reg_set_optimum_mode_check(
cclogic_dev->vcc_i2c, 0);
regulator_disable(cclogic_dev->vcc_i2c);
cclogic_dev->regulator_en = false;
}
- }else{
- if(!cclogic_dev->regulator_en){
+ } else{
+ if (!cclogic_dev->regulator_en) {
ret = cclogic_reg_set_optimum_mode_check(
- cclogic_dev->vcc_i2c,CCLOGIC_I2C_LOAD_UA);
+ cclogic_dev->vcc_i2c, CCLOGIC_I2C_LOAD_UA);
if (ret < 0) {
dev_err(&cclogic_dev->i2c_client->dev,
- "%s-->Regulator vcc_i2c set_opt"
- " failed rc=%d\n",__func__,ret);
+ "%s-->Regulator vcc_i2c set_opt failed rc=%d\n",
+ __func__, ret);
goto error_reg_opt_i2c;
}
ret = regulator_enable(cclogic_dev->vcc_i2c);
if (ret) {
dev_err(&cclogic_dev->i2c_client->dev,
- "%s-->Regulator vcc_i2c enable "
- "failed rc=%d\n", __func__,ret);
+ "%s-->Regulator vcc_i2c enable failed rc=%d\n",
+ __func__, ret);
goto error_reg_en_vcc_i2c;
}
cclogic_dev->regulator_en = true;
@@ -177,27 +164,24 @@ error_reg_opt_i2c:
cclogic_dev->regulator_en = false;
return ret;
}
-/*
- *
- */
+
static int cclogic_regulator_configure(struct cclogic_dev *cclogic_dev, bool on)
{
- int ret=0;
+ int ret = 0;
pr_debug("[%s][%d]\n", __func__, __LINE__);
- if (!cclogic_dev->platform_data->i2c_pull_up) {
+ if (!cclogic_dev->platform_data->i2c_pull_up)
return 0;
- }
- if (on == false && cclogic_dev->vcc_i2c){
+ if (on == false && cclogic_dev->vcc_i2c) {
if (regulator_count_voltages(cclogic_dev->vcc_i2c) > 0)
- regulator_set_voltage(cclogic_dev->vcc_i2c,0,
+ regulator_set_voltage(cclogic_dev->vcc_i2c, 0,
CCLOGIC_I2C_VTG_MAX_UV);
regulator_put(cclogic_dev->vcc_i2c);
cclogic_dev->vcc_i2c = NULL;
- }else if(!cclogic_dev->vcc_i2c){
- cclogic_dev->vcc_i2c =
- regulator_get(&cclogic_dev->i2c_client->dev,"vcc_i2c");
+ } else if (!cclogic_dev->vcc_i2c) {
+ cclogic_dev->vcc_i2c =
+ regulator_get(&cclogic_dev->i2c_client->dev, "vcc_i2c");
if (IS_ERR(cclogic_dev->vcc_i2c)) {
dev_err(&cclogic_dev->i2c_client->dev,
"%s: Failed to get i2c regulator\n",
@@ -207,13 +191,13 @@ static int cclogic_regulator_configure(struct cclogic_dev *cclogic_dev, bool on)
}
if (regulator_count_voltages(cclogic_dev->vcc_i2c) > 0) {
- ret = regulator_set_voltage(cclogic_dev->vcc_i2c,
- CCLOGIC_I2C_VTG_MIN_UV,
+ ret = regulator_set_voltage(cclogic_dev->vcc_i2c,
+ CCLOGIC_I2C_VTG_MIN_UV,
CCLOGIC_I2C_VTG_MAX_UV);
if (ret) {
dev_err(&cclogic_dev->i2c_client->dev,
- "%s-->reg set i2c vtg failed "
- "ret =%d\n", __func__,ret);
+ "%s-->reg set i2c vtg failed ret =%d\n",
+ __func__, ret);
goto err_set_vtg_i2c;
}
}
@@ -224,43 +208,37 @@ static int cclogic_regulator_configure(struct cclogic_dev *cclogic_dev, bool on)
err_set_vtg_i2c:
regulator_put(cclogic_dev->vcc_i2c);
err_get_vtg_i2c:
- cclogic_dev->vcc_i2c=NULL;
+ cclogic_dev->vcc_i2c = NULL;
return ret;
};
-/*
- *
- */
+
static int cclogic_irq_enable(struct cclogic_dev *cclogic_dev, bool enable)
{
int ret = 0;
pr_debug("[%s][%d] enable=%d irq_enabled=%d\n", __func__, __LINE__,
- enable,cclogic_dev->irq_enabled);
+ enable, cclogic_dev->irq_enabled);
if (enable) {
- if (!cclogic_dev->irq_enabled){
+ if (!cclogic_dev->irq_enabled) {
enable_irq(cclogic_dev->irq_working);
- if (gpio_is_valid(cclogic_dev->platform_data->irq_plug)) {
+ if (gpio_is_valid(cclogic_dev->platform_data->irq_plug))
enable_irq(cclogic_dev->irq_plug);
- }
cclogic_dev->irq_enabled = true;
}
} else {
if (cclogic_dev->irq_enabled) {
disable_irq(cclogic_dev->irq_working);
- if (gpio_is_valid(cclogic_dev->platform_data->irq_plug)) {
+ if (gpio_is_valid(cclogic_dev->platform_data->irq_plug))
disable_irq(cclogic_dev->irq_plug);
- }
cclogic_dev->irq_enabled = false;
}
}
return ret;
}
-/*
- *
- */
+
static int cclogic_parse_dt(struct device *dev, struct cclogic_platform *pdata)
{
struct device_node *np = dev->of_node;
@@ -273,9 +251,9 @@ static int cclogic_parse_dt(struct device *dev, struct cclogic_platform *pdata)
pdata->chip_num = 0;
- pdata->irq_working = of_get_named_gpio_flags(np, "cc_logic,irq-working", 0,
+ pdata->irq_working = of_get_named_gpio_flags(np, "cc_logic,irq-working", 0,
&pdata->irq_working_flags);
- pdata->irq_plug = of_get_named_gpio_flags(np, "cc_logic,irq-plug", 0,
+ pdata->irq_plug = of_get_named_gpio_flags(np, "cc_logic,irq-plug", 0,
&pdata->irq_plug_flags);
pdata->function_switch_gpio1 = of_get_named_gpio(np,
"cc_logic,function-switch-gpio1", 0);
@@ -285,23 +263,23 @@ static int cclogic_parse_dt(struct device *dev, struct cclogic_platform *pdata)
"cc_logic,function-switch-gpio2", 0);
pdata->usb_ss_gpio = of_get_named_gpio(np, "cc_logic,usb-ss-gpio", 0);
pdata->enb_gpio = of_get_named_gpio(np, "cc_logic,power-control", 0);
- pdata->i2c_pull_up = of_property_read_bool(np,"cc_logic,i2c-pull-up");
+ pdata->i2c_pull_up = of_property_read_bool(np, "cc_logic,i2c-pull-up");
pdata->ccchip_power_gpio = of_get_named_gpio_flags(np,
"cc_logic,bypass-power-control", 0, NULL);
- if (of_get_property(np, "vcc_otg-supply", NULL)) {
+ if (of_get_property(np, "vcc_otg-supply", NULL)) {
pdata->vbus_reg = devm_regulator_get(dev, "vcc_otg");
- if (IS_ERR(pdata->vbus_reg)) {
- dev_err(dev, "Failed to get vbus regulator\n");
- ret = PTR_ERR(pdata->vbus_reg);
+ if (IS_ERR(pdata->vbus_reg)) {
+ dev_err(dev, "Failed to get vbus regulator\n");
+ ret = PTR_ERR(pdata->vbus_reg);
return ret;
- }
+ }
}
for_each_child_of_node(np, temp) {
- if(idx>CCLOGIC_MAX_SUPPORT_CHIP){
- dev_err(dev,"%s-->too many devices\n",__func__);
+ if (idx > CCLOGIC_MAX_SUPPORT_CHIP) {
+ dev_err(dev, "%s-->too many devices\n", __func__);
break;
}
ret = of_property_read_string(temp, "chip-name",
@@ -310,15 +288,15 @@ static int cclogic_parse_dt(struct device *dev, struct cclogic_platform *pdata)
return ret;
ret = of_property_read_u32(temp, "chip-address", &val);
- if(ret)
+ if (ret)
return ret;
pdata->chip[idx].address = val;
- pdata->chip[idx].enb = of_property_read_bool(temp,"cc_logic,power-active-high");
+ pdata->chip[idx].enb = of_property_read_bool(temp, "cc_logic,power-active-high");
- pr_debug("%s--> chip:%s, address:0x%02x, enb=%d\n",__func__,
- pdata->chip[idx].chip_name,val,pdata->chip[idx].enb);
+ pr_debug("%s--> chip:%s, address:0x%02x, enb=%d\n", __func__,
+ pdata->chip[idx].chip_name, val, pdata->chip[idx].enb);
idx++;
}
@@ -328,43 +306,33 @@ static int cclogic_parse_dt(struct device *dev, struct cclogic_platform *pdata)
return 0;
}
-
-/*
- *
- */
static irqreturn_t cclogic_irq(int irq, void *data)
{
struct cclogic_dev *cclogic_dev = (struct cclogic_dev *)data;
pr_debug("[%s][%d]\n", __func__, __LINE__);
- if(!cclogic_dev || !cclogic_dev->i2c_client){
+ if (!cclogic_dev || !cclogic_dev->i2c_client)
return IRQ_HANDLED;
- }
- if (!wake_lock_active(&cclogic_dev->wakelock)){
+ if (!wake_lock_active(&cclogic_dev->wakelock))
wake_lock(&cclogic_dev->wakelock);
- }
cancel_delayed_work(&cclogic_dev->work);
schedule_delayed_work(&cclogic_dev->work, 0);
return IRQ_HANDLED;
}
-/*
- *
- */
static irqreturn_t cclogic_plug_irq(int irq, void *data)
{
struct cclogic_dev *cclogic_dev = (struct cclogic_dev *)data;
pr_debug("[%s][%d]\n", __func__, __LINE__);
- if(!cclogic_dev || !cclogic_dev->i2c_client){
+ if (!cclogic_dev || !cclogic_dev->i2c_client)
return IRQ_HANDLED;
- }
- if (!wake_lock_active(&cclogic_dev->wakelock_plug)){
+ if (!wake_lock_active(&cclogic_dev->wakelock_plug)) {
pm_runtime_get(cclogic_dev->dev);
wake_lock(&cclogic_dev->wakelock_plug);
}
@@ -376,130 +344,119 @@ static irqreturn_t cclogic_plug_irq(int irq, void *data)
return IRQ_HANDLED;
}
-#ifdef DEV_STAGE_DEBUG
-/*
- *
- */
+#ifdef DEV_STAGE_DEBUG
static ssize_t cclogic_show_real_status(struct cclogic_state *pdata, char *buf)
{
- char * vbus=NULL;
- char * charging=NULL;
- char * port=NULL;
- char * polarity=NULL;
- char * evt=NULL;
+ char *vbus = NULL;
+ char *charging = NULL;
+ char *port = NULL;
+ char *polarity = NULL;
+ char *evt = NULL;
pr_debug("[%s][%d]\n", __func__, __LINE__);
- switch(pdata->evt){
- case CCLOGIC_EVENT_NONE:
- evt="No Event";
- break;
- case CCLOGIC_EVENT_DETACHED:
- evt = "Detached Event";
- break;
- case CCLOGIC_EVENT_ATTACHED:
- evt = "Attached Event";
- break;
- default:
- evt = "unknown event";
+ switch (pdata->evt) {
+ case CCLOGIC_EVENT_NONE:
+ evt = "No Event";
+ break;
+ case CCLOGIC_EVENT_DETACHED:
+ evt = "Detached Event";
+ break;
+ case CCLOGIC_EVENT_ATTACHED:
+ evt = "Attached Event";
+ break;
+ default:
+ evt = "unknown event";
}
- if(pdata->vbus){
+ if (pdata->vbus)
vbus = "vbus=1";
- }else{
+ else
vbus = "vbus=0";
- }
- switch(pdata->cc){
- case CCLOGIC_CC1:
- polarity = "polarity=cc1";
- break;
- case CCLOGIC_CC2:
- polarity = "polarity=cc2";
- break;
- case CCLOGIC_CC_UNKNOWN:
- polarity = "polarity=unknown";
- break;
- case CCLOGIC_CC1_CC2:
- polarity = "polarity=cc1_cc2";
- break;
+ switch (pdata->cc) {
+ case CCLOGIC_CC1:
+ polarity = "polarity=cc1";
+ break;
+ case CCLOGIC_CC2:
+ polarity = "polarity=cc2";
+ break;
+ case CCLOGIC_CC_UNKNOWN:
+ polarity = "polarity=unknown";
+ break;
+ case CCLOGIC_CC1_CC2:
+ polarity = "polarity=cc1_cc2";
+ break;
}
- switch(pdata->device){
- case CCLOGIC_NO_DEVICE:
- port = "attached=nothing";
- break;
- case CCLOGIC_USB_DEVICE:
- port = "attached=device";
- break;
- case CCLOGIC_USB_HOST:
- port = "attached=host";
- break;
- case CCLOGIC_DEBUG_DEVICE:
- if(pdata->vbus){
- port = "attached=debug_vbus";
- }else{
- port = "attached=debug_novbus";
- }
- break;
- case CCLOGIC_AUDIO_DEVICE:
- port = "attached=audio";
- break;
- case CCLOGIC_DEVICE_UNKNOWN:
- port = "attached=unknown";
- break;
+ switch (pdata->device) {
+ case CCLOGIC_NO_DEVICE:
+ port = "attached=nothing";
+ break;
+ case CCLOGIC_USB_DEVICE:
+ port = "attached=device";
+ break;
+ case CCLOGIC_USB_HOST:
+ port = "attached=host";
+ break;
+ case CCLOGIC_DEBUG_DEVICE:
+ if (pdata->vbus)
+ port = "attached=debug_vbus";
+ else
+ port = "attached=debug_novbus";
+ break;
+ case CCLOGIC_AUDIO_DEVICE:
+ port = "attached=audio";
+ break;
+ case CCLOGIC_DEVICE_UNKNOWN:
+ port = "attached=unknown";
+ break;
}
- switch(pdata->charger){
- case CCLOGIC_CURRENT_NONE:
- charging = "charging=none";
- break;
- case CCLOGIC_CURRENT_DEFAULT:
- charging = "charging=default";
- break;
- case CCLOGIC_CURRENT_MEDIUM:
- charging = "charging=medium";
- break;
- case CCLOGIC_CURRENT_ACCESSORY:
- charging = "charging=from accessory";
- break;
- case CCLOGIC_CURRENT_HIGH:
- charging = "charging=high";
- break;
+ switch (pdata->charger) {
+ case CCLOGIC_CURRENT_NONE:
+ charging = "charging=none";
+ break;
+ case CCLOGIC_CURRENT_DEFAULT:
+ charging = "charging=default";
+ break;
+ case CCLOGIC_CURRENT_MEDIUM:
+ charging = "charging=medium";
+ break;
+ case CCLOGIC_CURRENT_ACCESSORY:
+ charging = "charging=from accessory";
+ break;
+ case CCLOGIC_CURRENT_HIGH:
+ charging = "charging=high";
+ break;
}
return sprintf(buf, " %15s:%8s;%25s;%23s;%15s\n",
- evt,vbus,charging,port,polarity);
+ evt, vbus, charging, port, polarity);
}
-/*
- *
- */
-static ssize_t cclogic_set_chip_power_enable(struct device *dev,
+static ssize_t cclogic_set_chip_power_enable(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct cclogic_dev *cclogic_dev = dev_get_drvdata(dev);
- int value;
+ int value;
pr_debug("[%s][%d]\n", __func__, __LINE__);
if (gpio_is_valid(cclogic_dev->platform_data->ccchip_power_gpio)) {
- if (1 != sscanf(buf, "%d", &value)) {
+ if (sscanf(buf, "%d", &value) != 1) {
dev_err(dev, "Failed to parse integer: <%s>\n", buf);
return -EINVAL;
}
- gpio_set_value_cansleep(cclogic_dev->platform_data->ccchip_power_gpio,value);
+ gpio_set_value_cansleep(cclogic_dev->platform_data->ccchip_power_gpio, value);
}
return count;
}
-/*
- *
- */
-static ssize_t cclogic_get_chip_power_enable(struct device *dev,
+static ssize_t cclogic_get_chip_power_enable(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct cclogic_dev *cclogic_dev = dev_get_drvdata(dev);
@@ -509,46 +466,37 @@ static ssize_t cclogic_get_chip_power_enable(struct device *dev,
if (gpio_is_valid(cclogic_dev->platform_data->ccchip_power_gpio)) {
ret = gpio_get_value_cansleep(cclogic_dev->platform_data->ccchip_power_gpio);
- if(!ret){
- return sprintf(buf, "disabled\n");
- }else{
- return sprintf(buf, "enabled\n");
- }
- }else{
- return sprintf(buf, "No chip power control pin\n");
- }
+ if (!ret)
+ return sprintf(buf, "disabled\n");
+ else
+ return sprintf(buf, "enabled\n");
+ } else
+ return sprintf(buf, "No chip power control pin\n");
}
static DEVICE_ATTR(chip_power, S_IRUGO|S_IWUSR, cclogic_get_chip_power_enable, cclogic_set_chip_power_enable);
-
-/*
- *
- */
-static ssize_t cclogic_chip_store_enable(struct device *dev,
+static ssize_t cclogic_chip_store_enable(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct cclogic_dev *cclogic_dev = dev_get_drvdata(dev);
- int value;
+ int value;
pr_debug("[%s][%d]\n", __func__, __LINE__);
if (gpio_is_valid(cclogic_dev->platform_data->enb_gpio)) {
- if (1 != sscanf(buf, "%d", &value)) {
+ if (sscanf(buf, "%d", &value) != 1) {
dev_err(dev, "Failed to parse integer: <%s>\n", buf);
return -EINVAL;
}
- gpio_set_value_cansleep(cclogic_dev->platform_data->enb_gpio,cclogic_dev->enb == value);
+ gpio_set_value_cansleep(cclogic_dev->platform_data->enb_gpio, cclogic_dev->enb == value);
}
return count;
}
-/*
- *
- */
-static ssize_t cclogic_chip_show_enable(struct device *dev,
+static ssize_t cclogic_chip_show_enable(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct cclogic_dev *cclogic_dev = dev_get_drvdata(dev);
@@ -558,22 +506,17 @@ static ssize_t cclogic_chip_show_enable(struct device *dev,
if (gpio_is_valid(cclogic_dev->platform_data->enb_gpio)) {
ret = gpio_get_value_cansleep(cclogic_dev->platform_data->enb_gpio);
- if(ret == cclogic_dev->enb){
- return sprintf(buf, "enabled\n");
- }else{
- return sprintf(buf, "disabled\n");
- }
- }else{
- return sprintf(buf, "No enabled pin\n");
- }
+ if (ret == cclogic_dev->enb)
+ return sprintf(buf, "enabled\n");
+ else
+ return sprintf(buf, "disabled\n");
+ } else
+ return sprintf(buf, "No enabled pin\n");
}
static DEVICE_ATTR(enable, S_IRUGO|S_IWUSR, cclogic_chip_show_enable, cclogic_chip_store_enable);
-/*
- *
- */
-static ssize_t cclogic_show_status(struct device *dev,
+static ssize_t cclogic_show_status(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct cclogic_dev *cclogic_dev = dev_get_drvdata(dev);
@@ -584,18 +527,18 @@ static ssize_t cclogic_show_status(struct device *dev,
#ifdef CCLOGIC_UPDATE_REAL_STATUS
pm_runtime_get_sync(dev);
mutex_lock(&cclogic_ops_lock);
- if(cclogic_dev->ops && cclogic_dev->ops->get_state){
+ if (cclogic_dev->ops && cclogic_dev->ops->get_state) {
ret = cclogic_dev->ops->get_state(cclogic_dev->i2c_client,
&cclogic_dev->state);
- if(ret){
+ if (ret) {
mutex_unlock(&cclogic_ops_lock);
pm_runtime_put(dev);
- return sprintf(buf, "error\n");
+ return sprintf(buf, "error\n");
}
- }else{
+ } else{
mutex_unlock(&cclogic_ops_lock);
pm_runtime_put(dev);
- return sprintf(buf, "no chip\n");
+ return sprintf(buf, "no chip\n");
}
mutex_unlock(&cclogic_ops_lock);
pm_runtime_put(dev);
@@ -609,10 +552,7 @@ static DEVICE_ATTR(status, S_IRUGO, cclogic_show_status, NULL);
#endif
-/*
- *
- */
-static ssize_t cclogic_show_cc(struct device *dev,
+static ssize_t cclogic_show_cc(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct cclogic_dev *cclogic_dev = dev_get_drvdata(dev);
@@ -623,11 +563,8 @@ static ssize_t cclogic_show_cc(struct device *dev,
}
-static DEVICE_ATTR(cc,S_IRUGO, cclogic_show_cc, NULL);
+static DEVICE_ATTR(cc, S_IRUGO, cclogic_show_cc, NULL);
-/*
- *
- */
static ssize_t cclogic_reg_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
@@ -635,48 +572,46 @@ static ssize_t cclogic_reg_show(struct device *dev,
int size;
int reg, value;
- if(cclogic_dev->ops && cclogic_dev->ops->read){
+ if (cclogic_dev->ops && cclogic_dev->ops->read) {
reg = 0x08;
- value = cclogic_dev->ops->read(cclogic_dev->i2c_client,reg);
- size+=sprintf(&buf[size],"[0x%02x] register = 0x%02x\n",reg,value);
+ value = cclogic_dev->ops->read(cclogic_dev->i2c_client, reg);
+ size += sprintf(&buf[size], "[0x%02x] register = 0x%02x\n", reg, value);
pr_debug("[0x%x] = [0x%x]\n", reg, value);
reg = 0x09;
- value = cclogic_dev->ops->read(cclogic_dev->i2c_client,reg);
- size+=sprintf(&buf[size],"[0x%02x] register = 0x%02x\n",reg,value);
+ value = cclogic_dev->ops->read(cclogic_dev->i2c_client, reg);
+ size += sprintf(&buf[size], "[0x%02x] register = 0x%02x\n", reg, value);
pr_debug("[0x%x] = [0x%x]\n", reg, value);
reg = 0x0A;
- value = cclogic_dev->ops->read(cclogic_dev->i2c_client,reg);
- size+=sprintf(&buf[size],"[0x%02x] register = 0x%02x\n",reg,value);
+ value = cclogic_dev->ops->read(cclogic_dev->i2c_client, reg);
+ size += sprintf(&buf[size], "[0x%02x] register = 0x%02x\n", reg, value);
pr_debug("[0x%x] = [0x%x]\n", reg, value);
reg = 0x45;
- value = cclogic_dev->ops->read(cclogic_dev->i2c_client,reg);
- size+=sprintf(&buf[size],"[0x%02x] register = 0x%02x\n",reg,value);
+ value = cclogic_dev->ops->read(cclogic_dev->i2c_client, reg);
+ size += sprintf(&buf[size], "[0x%02x] register = 0x%02x\n", reg, value);
pr_debug("[0x%x] = [0x%x]\n", reg, value);
reg = 0xA0;
- value = cclogic_dev->ops->read(cclogic_dev->i2c_client,reg);
- size+=sprintf(&buf[size],"[0x%02x] register = 0x%02x\n",reg,value);
+ value = cclogic_dev->ops->read(cclogic_dev->i2c_client, reg);
+ size += sprintf(&buf[size], "[0x%02x] register = 0x%02x\n", reg, value);
pr_debug("[0x%x] = [0x%x]\n", reg, value);
}
return size;
}
- static ssize_t cclogic_reg_store(struct device *dev,
+static ssize_t cclogic_reg_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t size)
{
struct cclogic_dev *cclogic_dev = dev_get_drvdata(dev);
-// int ret;
int reg, value;
char rw[10];
pr_debug("[%s][%d]\n", __func__, __LINE__);
- gpio_set_value_cansleep(cclogic_dev->platform_data->enb_gpio,1);
+ gpio_set_value_cansleep(cclogic_dev->platform_data->enb_gpio, 1);
- sscanf(buf,"%s %x %x",rw,&reg, &value);
- if(!strcmp(rw,"write")){
- if(cclogic_dev->ops && cclogic_dev->ops->read){
+ sscanf(buf, "%s %x %x", rw, &reg, &value);
+ if (!strcmp(rw, "write")) {
+ if (cclogic_dev->ops && cclogic_dev->ops->read)
cclogic_dev->ops->write(cclogic_dev->i2c_client, reg, value);
- }
}
return size;
}
@@ -684,269 +619,224 @@ static ssize_t cclogic_reg_show(struct device *dev,
static DEVICE_ATTR(reg, S_IRUGO | S_IWUSR, cclogic_reg_show, cclogic_reg_store);
-static void cclogic_func_set(struct cclogic_platform *p,enum cclogic_func_type func)
+static void cclogic_func_set(struct cclogic_platform *p, enum cclogic_func_type func)
{
- switch(func){
+ switch (func) {
case CCLOGIC_FUNC_HIZ:
- gpio_set_value_cansleep(p->function_switch_gpio2,0);
- if (gpio_is_valid(p->function_switch_gpio1)){
- gpio_set_value_cansleep(p->function_switch_gpio1,0);
- }
- if (gpio_is_valid(p->function_switch_gpio10)){
- gpio_set_value_cansleep(p->function_switch_gpio10,1);
- }
+ gpio_set_value_cansleep(p->function_switch_gpio2, 0);
+ if (gpio_is_valid(p->function_switch_gpio1))
+ gpio_set_value_cansleep(p->function_switch_gpio1, 0);
+ if (gpio_is_valid(p->function_switch_gpio10))
+ gpio_set_value_cansleep(p->function_switch_gpio10, 1);
break;
case CCLOGIC_FUNC_USB:
- gpio_set_value_cansleep(p->function_switch_gpio2,1);
- if (gpio_is_valid(p->function_switch_gpio1)){
- gpio_set_value_cansleep(p->function_switch_gpio1,0);
- }
- if (gpio_is_valid(p->function_switch_gpio10)){
- gpio_set_value_cansleep(p->function_switch_gpio10,0);
- }
+ gpio_set_value_cansleep(p->function_switch_gpio2, 1);
+ if (gpio_is_valid(p->function_switch_gpio1))
+ gpio_set_value_cansleep(p->function_switch_gpio1, 0);
+ if (gpio_is_valid(p->function_switch_gpio10))
+ gpio_set_value_cansleep(p->function_switch_gpio10, 0);
break;
case CCLOGIC_FUNC_AUDIO:
- gpio_set_value_cansleep(p->function_switch_gpio2,0);
- if (gpio_is_valid(p->function_switch_gpio1)){
+ gpio_set_value_cansleep(p->function_switch_gpio2, 0);
+ if (gpio_is_valid(p->function_switch_gpio1))
#ifdef CONFIG_MACH_ZUK_Z2_PLUS
- gpio_set_value_cansleep(p->function_switch_gpio1,0);
+ gpio_set_value_cansleep(p->function_switch_gpio1, 0);
#else
- gpio_set_value_cansleep(p->function_switch_gpio1,1);
+ gpio_set_value_cansleep(p->function_switch_gpio1, 1);
#endif
- }
- if (gpio_is_valid(p->function_switch_gpio10)){
- gpio_set_value_cansleep(p->function_switch_gpio10,0);
- }
+ if (gpio_is_valid(p->function_switch_gpio10))
+ gpio_set_value_cansleep(p->function_switch_gpio10, 0);
break;
case CCLOGIC_FUNC_UART:
- gpio_set_value_cansleep(p->function_switch_gpio2,1);
- if (gpio_is_valid(p->function_switch_gpio1)){
- gpio_set_value_cansleep(p->function_switch_gpio1,0);
- }
- if (gpio_is_valid(p->function_switch_gpio10)){
- gpio_set_value_cansleep(p->function_switch_gpio10,0);
- }
+ gpio_set_value_cansleep(p->function_switch_gpio2, 1);
+ if (gpio_is_valid(p->function_switch_gpio1))
+ gpio_set_value_cansleep(p->function_switch_gpio1, 0);
+ if (gpio_is_valid(p->function_switch_gpio10))
+ gpio_set_value_cansleep(p->function_switch_gpio10, 0);
break;
}
}
-/*
- *
- */
+
int cclogic_get_connected_mode(struct cclogic_state *state)
{
- if( state->evt == CCLOGIC_EVENT_DETACHED)
+ if (state->evt == CCLOGIC_EVENT_DETACHED)
return CCLOGIC_MODE_NONE;
-
- if(state->device == CCLOGIC_NO_DEVICE){
+
+ if (state->device == CCLOGIC_NO_DEVICE)
return CCLOGIC_MODE_NONE;
- }else if( state->device == CCLOGIC_USB_DEVICE ){
+ else if (state->device == CCLOGIC_USB_DEVICE)
return CCLOGIC_MODE_DFP;
- }else if(state->device == CCLOGIC_USB_HOST){
+ else if (state->device == CCLOGIC_USB_HOST)
return CCLOGIC_MODE_UFP;
- }else if(state->vbus){
+ else if (state->vbus)
return CCLOGIC_MODE_UFP;
- }else
+ else
return CCLOGIC_MODE_DFP;
return CCLOGIC_MODE_NONE;
}
EXPORT_SYMBOL(cclogic_get_connected_mode);
-/*
- *
- */
int cclogic_set_mode(struct cclogic_dev *pdata, int mode)
{
- int ret=0;
- if(pdata->ops->chip_trymode)
- ret = pdata->ops->chip_trymode(pdata->i2c_client,mode);
+ int ret = 0;
+
+ if (pdata->ops->chip_trymode)
+ ret = pdata->ops->chip_trymode(pdata->i2c_client, mode);
return ret;
}
EXPORT_SYMBOL(cclogic_set_mode);
-/*
- *
- */
int cclogic_get_power_role(struct cclogic_state *state)
{
- if(cclogic_get_connected_mode(state)==CCLOGIC_MODE_NONE){
+ if (cclogic_get_connected_mode(state) == CCLOGIC_MODE_NONE)
return CCLOGIC_POWER_NONE;
- }
- if(state->vbus){
+ if (state->vbus)
return CCLOGIC_POWER_SINK;
- }else
+ else
return CCLOGIC_POWER_SOURCE;
}
EXPORT_SYMBOL(cclogic_get_power_role);
-/*
- *
- */
int cclogic_set_power_role(struct cclogic_dev *pdata, int role)
{
return 0;
}
EXPORT_SYMBOL(cclogic_set_power_role);
-/*
- *
- */
int cclogic_get_data_role(struct cclogic_state *state)
{
- if(cclogic_get_connected_mode(state)==CCLOGIC_MODE_NONE){
+ if (cclogic_get_connected_mode(state) == CCLOGIC_MODE_NONE)
return CCLOGIC_DATA_NONE;
- }
- if( state->device == CCLOGIC_USB_DEVICE ){
+ if (state->device == CCLOGIC_USB_DEVICE)
return CCLOGIC_DATA_HOST;
- }else if( state->device == CCLOGIC_USB_HOST ){
+ else if (state->device == CCLOGIC_USB_HOST)
return CCLOGIC_DATA_DEVICE;
- }
return CCLOGIC_DATA_NONE;
}
EXPORT_SYMBOL(cclogic_get_data_role);
-/*
- *
- */
int cclogic_set_data_role(struct cclogic_dev *pdata, int role)
{
return 0;
}
EXPORT_SYMBOL(cclogic_set_data_role);
-static int cc_otg_state = 0;
+static int cc_otg_state;
int cclogic_get_otg_state(void)
{
return cc_otg_state;
}
EXPORT_SYMBOL(cclogic_get_otg_state);
-/*
- *
- */
-static int cclogic_do_real_work(struct cclogic_state *state,
+static int cclogic_do_real_work(struct cclogic_state *state,
struct cclogic_dev *pdata)
{
- int ret=0;
+ int ret = 0;
struct cclogic_platform *p = pdata->platform_data;
- static int cclogic_last_status = 0;
+ static int cclogic_last_status;
pr_debug("[%s][%d]\n", __func__, __LINE__);
cc_otg_state = 0;
- switch(state->evt){
+ switch (state->evt) {
case CCLOGIC_EVENT_DETACHED:
cclogic_notifier_call_chain(CCLOGIC_EVENT_DETACHED, NULL);
- pr_debug("%s-->cable detached\n",__func__);
- cclogic_vbus_power_on(pdata,false);
- cclogic_func_set(p,CCLOGIC_FUNC_UART);
+ pr_debug("%s-->cable detached\n", __func__);
+ cclogic_vbus_power_on(pdata, false);
+ cclogic_func_set(p, CCLOGIC_FUNC_UART);
ret = pdata->ops->chip_config(pdata->i2c_client);
goto out;
- case CCLOGIC_EVENT_NONE:
- pr_debug("%s-->No event\n",__func__);
+ case CCLOGIC_EVENT_NONE:
+ pr_debug("%s-->No event\n", __func__);
break;
case CCLOGIC_EVENT_ATTACHED:
cclogic_notifier_call_chain(CCLOGIC_EVENT_ATTACHED, NULL);
- pr_debug("%s-->cable attached\n",__func__);
+ pr_debug("%s-->cable attached\n", __func__);
break;
}
- if(state->device == CCLOGIC_USB_DEVICE){//in order to disable usb3.0 when in host mode
- switch(state->cc){
+ if (state->device == CCLOGIC_USB_DEVICE) {/* in order to disable usb3.0 when in host mode */
+ switch (state->cc) {
case CCLOGIC_CC1:
- pr_debug("%s-->usb_ss signal to cc2\n",__func__);
+ pr_debug("%s-->usb_ss signal to cc2\n", __func__);
if (gpio_is_valid(p->usb_ss_gpio))
- gpio_set_value_cansleep(p->usb_ss_gpio,0);
+ gpio_set_value_cansleep(p->usb_ss_gpio, 0);
break;
case CCLOGIC_CC2:
- pr_debug("%s-->usb_ss signal to cc1\n",__func__);
+ pr_debug("%s-->usb_ss signal to cc1\n", __func__);
if (gpio_is_valid(p->usb_ss_gpio))
- gpio_set_value_cansleep(p->usb_ss_gpio,1);
+ gpio_set_value_cansleep(p->usb_ss_gpio, 1);
break;
case CCLOGIC_CC_UNKNOWN:
default:
- pr_debug("%s-->usb_ss signal to unknown\n",__func__);
+ pr_debug("%s-->usb_ss signal to unknown\n", __func__);
ret = -1;
break;
}
- }else{
- switch(state->cc){
+ } else {
+ switch (state->cc) {
case CCLOGIC_CC1:
- pr_debug("%s-->usb_ss signal to cc1\n",__func__);
+ pr_debug("%s-->usb_ss signal to cc1\n", __func__);
if (gpio_is_valid(p->usb_ss_gpio))
- gpio_set_value_cansleep(p->usb_ss_gpio,1);
+ gpio_set_value_cansleep(p->usb_ss_gpio, 1);
break;
case CCLOGIC_CC2:
- pr_debug("%s-->usb_ss signal to cc2\n",__func__);
+ pr_debug("%s-->usb_ss signal to cc2\n", __func__);
if (gpio_is_valid(p->usb_ss_gpio))
- gpio_set_value_cansleep(p->usb_ss_gpio,0);
+ gpio_set_value_cansleep(p->usb_ss_gpio, 0);
break;
case CCLOGIC_CC_UNKNOWN:
default:
- pr_debug("%s-->usb_ss signal to unknown\n",__func__);
+ pr_debug("%s-->usb_ss signal to unknown\n", __func__);
ret = -1;
break;
}
}
- /*
- if(state->vbus){
- switch(state->charger){
- case CCLOGIC_CURRENT_NONE:
- case CCLOGIC_CURRENT_DEFAULT:
- case CCLOGIC_CURRENT_MEDIUM:
- case CCLOGIC_CURRENT_ACCESSORY:
- case CCLOGIC_CURRENT_HIGH:
- }
- }
- */
-
- switch(state->device){
- case CCLOGIC_NO_DEVICE://nothing attached
- pr_debug("%s-->nothing attached,switch to UART\n",__func__);
- cclogic_vbus_power_on(pdata,false);
- cclogic_func_set(p,CCLOGIC_FUNC_UART);
+ switch (state->device) {
+ case CCLOGIC_NO_DEVICE:/* nothing attached */
+ pr_debug("%s-->nothing attached,switch to UART\n", __func__);
+ cclogic_vbus_power_on(pdata, false);
+ cclogic_func_set(p, CCLOGIC_FUNC_UART);
ret = pdata->ops->chip_config(pdata->i2c_client);
break;
case CCLOGIC_USB_DEVICE:
- pr_debug("%s-->function switch set to usb host\n",__func__);
+ pr_debug("%s-->function switch set to usb host\n", __func__);
cc_otg_state = 1;
- cclogic_func_set(p,CCLOGIC_FUNC_HIZ);
- cclogic_vbus_power_on(pdata,true);
- mdelay(300);
- cclogic_func_set(p,CCLOGIC_FUNC_USB);
+ cclogic_func_set(p, CCLOGIC_FUNC_HIZ);
+ cclogic_vbus_power_on(pdata, true);
+ msleep(300);
+ cclogic_func_set(p, CCLOGIC_FUNC_USB);
break;
case CCLOGIC_USB_HOST:
- pr_debug("%s-->function switch set to usb device\n",__func__);
- cclogic_vbus_power_on(pdata,false);
- cclogic_func_set(p,CCLOGIC_FUNC_USB);
+ pr_debug("%s-->function switch set to usb device\n", __func__);
+ cclogic_vbus_power_on(pdata, false);
+ cclogic_func_set(p, CCLOGIC_FUNC_USB);
break;
case CCLOGIC_DEBUG_DEVICE:
- pr_debug("%s-->function switch set to debug device,vbus=%d\n", __func__,state->vbus);
- cclogic_func_set(p,CCLOGIC_FUNC_HIZ);
+ pr_debug("%s-->function switch set to debug device,vbus=%d\n", __func__, state->vbus);
+ cclogic_func_set(p, CCLOGIC_FUNC_HIZ);
break;
case CCLOGIC_AUDIO_DEVICE:
- pr_debug("%s-->function switch set to audio device(HiZ)\n",__func__);
- cclogic_func_set(p,CCLOGIC_FUNC_HIZ);
+ pr_debug("%s-->function switch set to audio device(HiZ)\n", __func__);
+ cclogic_func_set(p, CCLOGIC_FUNC_HIZ);
break;
case CCLOGIC_DEVICE_UNKNOWN:
default:
- dev_err(&pdata->i2c_client->dev,"%s-->function unknown,"
- " switch to HiZ\n",__func__);
- cclogic_func_set(p,CCLOGIC_FUNC_HIZ);
+ dev_err(&pdata->i2c_client->dev, "%s-->function unknown, switch to HiZ\n",
+ __func__);
+ cclogic_func_set(p, CCLOGIC_FUNC_HIZ);
ret = -1;
}
out:
- if(pdata->typec_version==11){
+ if (pdata->typec_version == 11)
cclogic_class_update_state(&pdata->cdev);
- }
-
-// if(unlikely(!gpio_get_value(pdata->platform_data->irq_plug) &&
- if(unlikely(state->evt == CCLOGIC_EVENT_DETACHED &&
+ if (unlikely(state->evt == CCLOGIC_EVENT_DETACHED &&
cclogic_last_status == CCLOGIC_EVENT_DETACHED)) {
msleep(20);
pr_debug("cclogic: reset driver ic, try again\n");
@@ -957,105 +847,90 @@ out:
return ret;
}
-/*
- *
- */
static void cclogic_do_work(struct work_struct *w)
{
- struct cclogic_dev *pdata = container_of(w,
+ struct cclogic_dev *pdata = container_of(w,
struct cclogic_dev, work.work);
- int ret=0;
- static int retries = 0;
+ int ret = 0;
+ static int retries;
pr_debug("[%s][%d]\n", __func__, __LINE__);
- if(pm_runtime_suspended(pdata->dev)){
+ if (pm_runtime_suspended(pdata->dev))
return;
- }
mutex_lock(&cclogic_ops_lock);
- ret = pdata->ops->get_state(pdata->i2c_client,&pdata->state);
- if(ret){
+ ret = pdata->ops->get_state(pdata->i2c_client, &pdata->state);
+ if (ret)
goto work_end;
- }
- if(pdata->ops->ack_irq){
+ if (pdata->ops->ack_irq) {
ret = pdata->ops->ack_irq(pdata->i2c_client);
- if(ret){
+ if (ret)
goto work_end;
- }
}
cclogic_patch_state(pdata);
- ret = cclogic_do_real_work(&pdata->state,pdata);
+ ret = cclogic_do_real_work(&pdata->state, pdata);
work_end:
mutex_unlock(&cclogic_ops_lock);
- if(ret || !gpio_get_value(cclogic_priv->platform_data->irq_working)){
+ if (ret || !gpio_get_value(cclogic_priv->platform_data->irq_working)) {
retries++;
- if(retries <= CCLOGIC_MAX_RETRIES){
+ if (retries <= CCLOGIC_MAX_RETRIES) {
schedule_delayed_work(&pdata->work, msecs_to_jiffies(100));
return;
- }else
- pr_err("[%s][%d] still in error,more than %d retries\n", __func__, __LINE__,CCLOGIC_MAX_RETRIES);
+ } else
+ pr_err("[%s][%d] still in error,more than %d retries\n", __func__, __LINE__, CCLOGIC_MAX_RETRIES);
}
- if(wake_lock_active(&pdata->wakelock)){
+ if (wake_lock_active(&pdata->wakelock))
wake_unlock(&pdata->wakelock);
- }
retries = 0;
}
-/*
- *
- */
static void cclogic_do_plug_work(struct work_struct *w)
{
- struct cclogic_dev *pdata = container_of(w,
+ struct cclogic_dev *pdata = container_of(w,
struct cclogic_dev, plug_work.work);
struct cclogic_platform *p = pdata->platform_data;
- static int retries = 0;
+ static int retries;
pr_debug("[%s][%d]\n", __func__, __LINE__);
- if(m_plug_state){
- if(gpio_get_value(pdata->platform_data->irq_plug)){
- if(retries<10){
+ if (m_plug_state) {
+ if (gpio_get_value(pdata->platform_data->irq_plug)) {
+ if (retries < 10) {
retries++;
schedule_delayed_work(&pdata->plug_work, msecs_to_jiffies(100));
- }else{
+ } else{
m_plug_state = 0;
cancel_delayed_work(&cclogic_priv->work);
- flush_delayed_work(&cclogic_priv->work);
- cclogic_vbus_power_on(pdata,false);
- cclogic_func_set(p,CCLOGIC_FUNC_UART);
+ flush_delayed_work(&cclogic_priv->work);
+ cclogic_vbus_power_on(pdata, false);
+ cclogic_func_set(p, CCLOGIC_FUNC_UART);
retries = 0;
- if (wake_lock_active(&cclogic_priv->wakelock_plug)){
+ if (wake_lock_active(&cclogic_priv->wakelock_plug)) {
pm_runtime_put(pdata->dev);
wake_unlock(&cclogic_priv->wakelock_plug);
}
}
- }else{
+ } else{
retries = 0;
- if (wake_lock_active(&cclogic_priv->wakelock_plug)){
+ if (wake_lock_active(&cclogic_priv->wakelock_plug))
wake_unlock(&cclogic_priv->wakelock_plug);
- }
}
- }else{
+ } else{
retries = 0;
- if (wake_lock_active(&cclogic_priv->wakelock_plug)){
+ if (wake_lock_active(&cclogic_priv->wakelock_plug)) {
pm_runtime_put(pdata->dev);
wake_unlock(&cclogic_priv->wakelock_plug);
}
}
}
-
-/*
- *
- */
static int cclogic_init_gpio(struct cclogic_dev *cclogic_dev)
{
struct i2c_client *client = cclogic_dev->i2c_client;
@@ -1065,77 +940,77 @@ static int cclogic_init_gpio(struct cclogic_dev *cclogic_dev)
pr_debug("[%s][%d]\n", __func__, __LINE__);
if (gpio_is_valid(pdata->function_switch_gpio1)) {
- ret = gpio_request(pdata->function_switch_gpio1,
+ ret = gpio_request(pdata->function_switch_gpio1,
"cclogic_func_gpio1");
if (ret) {
- dev_err(&client->dev,
+ dev_err(&client->dev,
"%s-->unable to request gpio [%d]\n",
- __func__,pdata->function_switch_gpio1);
+ __func__, pdata->function_switch_gpio1);
goto err_gpio1;
}
- ret = gpio_direction_output(pdata->function_switch_gpio1,0);
+ ret = gpio_direction_output(pdata->function_switch_gpio1, 0);
if (ret) {
dev_err(&client->dev,
"%s-->unable to set direction for gpio [%d]\n",
- __func__,pdata->function_switch_gpio1);
+ __func__, pdata->function_switch_gpio1);
goto err_gpio1_dir;
}
}
if (gpio_is_valid(pdata->function_switch_gpio10)) {
- ret = gpio_request(pdata->function_switch_gpio10,
+ ret = gpio_request(pdata->function_switch_gpio10,
"cclogic_func_gpio10");
if (ret) {
- dev_err(&client->dev,
+ dev_err(&client->dev,
"%s-->unable to request gpio [%d]\n",
- __func__,pdata->function_switch_gpio10);
+ __func__, pdata->function_switch_gpio10);
goto err_gpio1_dir;
}
- ret = gpio_direction_output(pdata->function_switch_gpio10,0);
+ ret = gpio_direction_output(pdata->function_switch_gpio10, 0);
if (ret) {
dev_err(&client->dev,
"%s-->unable to set direction for gpio [%d]\n",
- __func__,pdata->function_switch_gpio10);
+ __func__, pdata->function_switch_gpio10);
goto err_gpio10_dir;
}
}
if (gpio_is_valid(pdata->function_switch_gpio2)) {
- ret = gpio_request(pdata->function_switch_gpio2,
+ ret = gpio_request(pdata->function_switch_gpio2,
"cclogic_func_gpio2");
if (ret) {
dev_err(&client->dev,
"%s-->unable to request gpio [%d]\n",
- __func__,pdata->function_switch_gpio2);
+ __func__, pdata->function_switch_gpio2);
goto err_gpio10_dir;
}
- ret = gpio_direction_output(pdata->function_switch_gpio2,1);
+ ret = gpio_direction_output(pdata->function_switch_gpio2, 1);
if (ret) {
dev_err(&client->dev,
"%s-->unable to set direction for gpio [%d]\n",
- __func__,pdata->function_switch_gpio2);
+ __func__, pdata->function_switch_gpio2);
goto err_gpio2_dir;
}
} else {
ret = -ENODEV;
dev_err(&client->dev,
- "%s-->function_switch_gpio2 not provided\n",__func__);
+ "%s-->function_switch_gpio2 not provided\n", __func__);
goto err_gpio10_dir;
}
if (gpio_is_valid(pdata->usb_ss_gpio)) {
ret = gpio_request(pdata->usb_ss_gpio, "usb_ss_gpio");
if (ret) {
- dev_err(&client->dev,
+ dev_err(&client->dev,
"%s-->unable to request gpio [%d]\n",
- __func__,pdata->usb_ss_gpio);
+ __func__, pdata->usb_ss_gpio);
goto err_gpio2_dir;
}
- ret = gpio_direction_output(pdata->usb_ss_gpio,0);
+ ret = gpio_direction_output(pdata->usb_ss_gpio, 0);
if (ret) {
dev_err(&client->dev,
"%s-->unable to set direction for gpio [%d]\n",
- __func__,pdata->usb_ss_gpio);
+ __func__, pdata->usb_ss_gpio);
goto err_ss_gpio;
}
}
@@ -1143,16 +1018,16 @@ static int cclogic_init_gpio(struct cclogic_dev *cclogic_dev)
if (gpio_is_valid(pdata->enb_gpio)) {
ret = gpio_request(pdata->enb_gpio, "enb_gpio");
if (ret) {
- dev_err(&client->dev,
+ dev_err(&client->dev,
"%s-->unable to request gpio [%d]\n",
- __func__,pdata->enb_gpio);
+ __func__, pdata->enb_gpio);
goto err_ss_gpio;
}
- ret = gpio_direction_output(pdata->enb_gpio,!cclogic_dev->enb);
+ ret = gpio_direction_output(pdata->enb_gpio, !cclogic_dev->enb);
if (ret) {
- dev_err(&client->dev,
+ dev_err(&client->dev,
"%s-->unable to set direction for gpio [%d]\n",
- __func__,pdata->enb_gpio);
+ __func__, pdata->enb_gpio);
goto err_enb_gpio;
}
}
@@ -1160,16 +1035,16 @@ static int cclogic_init_gpio(struct cclogic_dev *cclogic_dev)
if (gpio_is_valid(pdata->ccchip_power_gpio)) {
ret = gpio_request(pdata->ccchip_power_gpio, "chip_power_gpio");
if (ret) {
- dev_err(&client->dev,
+ dev_err(&client->dev,
"%s-->unable to request gpio [%d]\n",
- __func__,pdata->ccchip_power_gpio);
+ __func__, pdata->ccchip_power_gpio);
goto err_enb_gpio;
}
- ret = gpio_direction_output(pdata->ccchip_power_gpio,1);
+ ret = gpio_direction_output(pdata->ccchip_power_gpio, 1);
if (ret) {
- dev_err(&client->dev,
+ dev_err(&client->dev,
"%s-->unable to set direction for gpio [%d]\n",
- __func__,pdata->ccchip_power_gpio);
+ __func__, pdata->ccchip_power_gpio);
goto err_cc_power_gpio;
}
}
@@ -1178,11 +1053,11 @@ static int cclogic_init_gpio(struct cclogic_dev *cclogic_dev)
err_cc_power_gpio:
if (gpio_is_valid(pdata->ccchip_power_gpio))
- gpio_free(pdata->ccchip_power_gpio);
+ gpio_free(pdata->ccchip_power_gpio);
err_enb_gpio:
if (gpio_is_valid(pdata->enb_gpio))
- gpio_free(pdata->enb_gpio);
+ gpio_free(pdata->enb_gpio);
err_ss_gpio:
if (gpio_is_valid(pdata->usb_ss_gpio))
@@ -1203,9 +1078,6 @@ err_gpio1:
return ret;
}
-/*
- *
- */
static int cclogic_remove_gpio(struct cclogic_dev *cclogic_dev)
{
struct cclogic_platform *pdata = cclogic_dev->platform_data;
@@ -1213,7 +1085,7 @@ static int cclogic_remove_gpio(struct cclogic_dev *cclogic_dev)
pr_debug("[%s][%d]\n", __func__, __LINE__);
if (gpio_is_valid(pdata->enb_gpio))
- gpio_free(pdata->enb_gpio);
+ gpio_free(pdata->enb_gpio);
if (gpio_is_valid(pdata->usb_ss_gpio))
gpio_free(pdata->usb_ss_gpio);
@@ -1228,55 +1100,49 @@ static int cclogic_remove_gpio(struct cclogic_dev *cclogic_dev)
gpio_free(pdata->function_switch_gpio10);
if (gpio_is_valid(pdata->ccchip_power_gpio))
- gpio_free(pdata->ccchip_power_gpio);
+ gpio_free(pdata->ccchip_power_gpio);
return 0;
}
-/**
- * cclogic_match_id()
- */
+/* cclogic_match_id() */
static int cclogic_match_id(const char *name)
{
- int i=0;
+ int i = 0;
pr_debug("[%s][%d]\n", __func__, __LINE__);
- if(unlikely(!name)){
- pr_err("%s-->No name\n",__func__);
+ if (unlikely(!name)) {
+ pr_err("%s-->No name\n", __func__);
return -ENODEV;
}
- if(cclogic_priv && cclogic_priv->platform_data){
- for(i=0;i<cclogic_priv->platform_data->chip_num;i++){
- struct cclogic_of_chip *chip =
+ if (cclogic_priv && cclogic_priv->platform_data) {
+ for (i = 0; i < cclogic_priv->platform_data->chip_num; i++) {
+ struct cclogic_of_chip *chip =
&cclogic_priv->platform_data->chip[i];
- if(!chip->chip_name){
- pr_err("%s-->%s mismatch\n",__func__,name);
+ if (!chip->chip_name) {
+ pr_err("%s-->%s mismatch\n", __func__, name);
return -ENODEV;
}
- if(!strcmp(chip->chip_name, name))
+ if (!strcmp(chip->chip_name, name))
break;
}
- }else{
- pr_err("%s-->%s mismatch\n",__func__,name);
+ } else {
+ pr_err("%s-->%s mismatch\n", __func__, name);
return -ENODEV;
}
- if(i >= cclogic_priv->platform_data->chip_num){
- pr_err("%s-->%s mismatch\n",__func__,name);
+ if (i >= cclogic_priv->platform_data->chip_num) {
+ pr_err("%s-->%s mismatch\n", __func__, name);
return -ENODEV;
}
-
return i;
-
}
-/**
- * cclogic_register()
- */
+/* cclogic_register() */
int cclogic_register(struct cclogic_chip *c)
{
int ret = 0;
@@ -1284,56 +1150,51 @@ int cclogic_register(struct cclogic_chip *c)
pr_debug("[%s][%d]\n", __func__, __LINE__);
mutex_lock(&cclogic_ops_lock);
- if(cclogic_priv->ops){
+ if (cclogic_priv->ops) {
mutex_unlock(&cclogic_ops_lock);
return -EINVAL;
}
mutex_unlock(&cclogic_ops_lock);
ret = cclogic_match_id(c->chip_name);
- if(ret<0){
+ if (ret < 0)
return ret;
- }
c->addr = cclogic_priv->platform_data->chip[ret].address;
cclogic_priv->enb = cclogic_priv->platform_data->chip[ret].enb;
- if (!c->chip_check) {
+ if (!c->chip_check)
return -ENODEV;
- }
pm_runtime_get_sync(cclogic_priv->dev);
wake_lock(&cclogic_priv->wakelock_plug);
- mdelay(100);
-
+ msleep(100);
+
mutex_lock(&cclogic_ops_lock);
cclogic_priv->i2c_client->addr = c->addr;
- if(c->chip_reset){
+ if (c->chip_reset) {
ret = c->chip_reset(cclogic_priv->i2c_client);
- if(ret){
+ if (ret)
goto err_ret;
- }
}
ret = c->chip_check(cclogic_priv->i2c_client);
- if(ret){
+ if (ret)
goto err_ret;
- }
ret = c->chip_config(cclogic_priv->i2c_client);
- if(ret){
+ if (ret)
goto err_ret;
- }
- pr_info("%s select chip:%s\n",__func__,c->chip_name);
+ pr_info("%s select chip:%s\n", __func__, c->chip_name);
cclogic_priv->ops = c;
cclogic_priv->typec_version = c->typec_version;
mutex_unlock(&cclogic_ops_lock);
- if(cclogic_priv->typec_version==11){
- //cclogic_priv->cdev.name = c->chip_name;
+ if (cclogic_priv->typec_version == 11) {
+ /* cclogic_priv->cdev.name = c->chip_name; */
cclogic_priv->cdev.name = "otg_default";
ret = cclogic_class_register(&cclogic_priv->cdev);
if (ret) {
@@ -1343,7 +1204,7 @@ int cclogic_register(struct cclogic_chip *c)
}
}
- cclogic_irq_enable(cclogic_priv,true);
+ cclogic_irq_enable(cclogic_priv, true);
m_plug_state = 1;
schedule_delayed_work(&cclogic_priv->plug_work, 0);
@@ -1358,34 +1219,30 @@ err_ret1:
}
EXPORT_SYMBOL(cclogic_register);
-/**
- * cclogic_unregister()
- */
+/*cclogic_unregister() */
void cclogic_unregister(struct cclogic_chip *c)
{
pr_debug("[%s][%d]\n", __func__, __LINE__);
- if(cclogic_priv->ops != c){
+ if (cclogic_priv->ops != c)
return;
- }
cancel_delayed_work(&cclogic_priv->work);
- flush_delayed_work(&cclogic_priv->work);
+ flush_delayed_work(&cclogic_priv->work);
cancel_delayed_work(&cclogic_priv->plug_work);
- flush_delayed_work(&cclogic_priv->plug_work);
+ flush_delayed_work(&cclogic_priv->plug_work);
- cclogic_irq_enable(cclogic_priv,false);
+ cclogic_irq_enable(cclogic_priv, false);
- if (wake_lock_active(&cclogic_priv->wakelock)){
+ if (wake_lock_active(&cclogic_priv->wakelock))
wake_unlock(&cclogic_priv->wakelock);
- }
pm_runtime_put(cclogic_priv->dev);
mutex_lock(&cclogic_ops_lock);
cclogic_priv->ops = NULL;
mutex_unlock(&cclogic_ops_lock);
- if(cclogic_priv->typec_version==11){
+ if (cclogic_priv->typec_version == 11) {
cclogic_priv->typec_version = 10;
cclogic_class_unregister(&cclogic_priv->cdev);
}
@@ -1394,9 +1251,8 @@ void cclogic_unregister(struct cclogic_chip *c)
}
EXPORT_SYMBOL(cclogic_unregister);
-
static struct attribute *cclogic_attrs[] = {
-#ifdef DEV_STAGE_DEBUG
+#ifdef DEV_STAGE_DEBUG
&dev_attr_chip_power.attr,
&dev_attr_status.attr,
&dev_attr_enable.attr,
@@ -1410,9 +1266,7 @@ static struct attribute_group cclogic_attr_group = {
.attrs = cclogic_attrs,
};
-/**
- * cclogic_probe()
- */
+/* cclogic_probe() */
static int cclogic_probe(struct i2c_client *client,
const struct i2c_device_id *dev_id)
{
@@ -1423,36 +1277,35 @@ static int cclogic_probe(struct i2c_client *client,
pr_info("%s start\n", __func__);
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
- dev_err(&client->dev,"%s: i2c check failed\n", __func__);
+ dev_err(&client->dev, "%s: i2c check failed\n", __func__);
ret = -ENODEV;
goto err_i2c;
}
- if(!cclogic_dev){
+ if (!cclogic_dev) {
ret = -ENODEV;
goto err_i2c;
}
- memset(cclogic_dev,0,sizeof(*cclogic_dev));
+ memset(cclogic_dev, 0, sizeof(*cclogic_dev));
if (client->dev.of_node) {
platform_data = devm_kzalloc(&client->dev,
- sizeof(*platform_data),GFP_KERNEL);
+ sizeof(*platform_data), GFP_KERNEL);
if (!platform_data) {
- dev_err(&client->dev,"%s-->Failed to allocate memory\n",
+ dev_err(&client->dev, "%s-->Failed to allocate memory\n",
__func__);
ret = -ENOMEM;
goto err_i2c;
}
ret = cclogic_parse_dt(&client->dev, platform_data);
- if (ret){
- dev_err(&client->dev,"%s-->Failed parse dt\n",__func__);
+ if (ret) {
+ dev_err(&client->dev, "%s-->Failed parse dt\n", __func__);
goto err_i2c;
}
- } else {
+ } else
platform_data = client->dev.platform_data;
- }
cclogic_dev->pin = devm_pinctrl_get(&client->dev);
if (IS_ERR_OR_NULL(cclogic_dev->pin)) {
@@ -1485,7 +1338,7 @@ static int cclogic_probe(struct i2c_client *client,
cclogic_dev->i2c_client = client;
cclogic_dev->dev = &client->dev;
- i2c_set_clientdata(client,cclogic_dev);
+ i2c_set_clientdata(client, cclogic_dev);
pm_runtime_set_suspended(&client->dev);
@@ -1498,13 +1351,13 @@ static int cclogic_probe(struct i2c_client *client,
ret = cclogic_power_on(cclogic_dev, true);
if (ret < 0) {
- dev_err(&client->dev, "%s-->Failed to power on\n",__func__);
+ dev_err(&client->dev, "%s-->Failed to power on\n", __func__);
goto err_regulator_conf;
}
ret = cclogic_init_gpio(cclogic_dev);
- if(ret){
- dev_err(&client->dev,"%s-->error in set gpio\n",__func__);
+ if (ret) {
+ dev_err(&client->dev, "%s-->error in set gpio\n", __func__);
goto err_regulator_on;
}
@@ -1514,20 +1367,20 @@ static int cclogic_probe(struct i2c_client *client,
/* configure cclogic irq working */
ret = gpio_request(platform_data->irq_working, "cclogic_irq_working");
if (ret) {
- dev_err(&client->dev,
+ dev_err(&client->dev,
"%s-->unable to request gpio [%d]\n",
- __func__,platform_data->irq_working);
+ __func__, platform_data->irq_working);
goto err_set_gpio;
}
ret = gpio_direction_input(platform_data->irq_working);
if (ret) {
- dev_err(&client->dev,
+ dev_err(&client->dev,
"%s-->unable to set direction for gpio [%d]\n",
- __func__,platform_data->irq_working);
+ __func__, platform_data->irq_working);
goto err_irq_working_dir;
}
} else {
- dev_err(&client->dev, "%s-->irq gpio not provided\n",__func__);
+ dev_err(&client->dev, "%s-->irq gpio not provided\n", __func__);
goto err_set_gpio;
}
cclogic_dev->irq_working = gpio_to_irq(platform_data->irq_working);
@@ -1536,21 +1389,21 @@ static int cclogic_probe(struct i2c_client *client,
/* configure cclogic irq plug */
ret = gpio_request(platform_data->irq_plug, "cclogic_irq_plug");
if (ret) {
- dev_err(&client->dev,
+ dev_err(&client->dev,
"%s-->unable to request gpio [%d]\n",
- __func__,platform_data->irq_plug);
+ __func__, platform_data->irq_plug);
goto err_irq_working_dir;
}
ret = gpio_direction_input(platform_data->irq_plug);
if (ret) {
- dev_err(&client->dev,
+ dev_err(&client->dev,
"%s-->unable to set direction for gpio [%d]\n",
- __func__,platform_data->irq_plug);
+ __func__, platform_data->irq_plug);
goto err_irq_plug_dir;
}
cclogic_dev->irq_plug = gpio_to_irq(platform_data->irq_plug);
} else {
- dev_err(&client->dev, "%s-->irq plug gpio not provided\n",__func__);
+ dev_err(&client->dev, "%s-->irq plug gpio not provided\n", __func__);
goto err_irq_working_dir;
}
@@ -1568,34 +1421,33 @@ static int cclogic_probe(struct i2c_client *client,
ret = sysfs_create_group(&client->dev.kobj, &cclogic_attr_group);
if (ret) {
dev_err(&client->dev,
- "%s-->Unable to create sysfs for cclogic,"
- " errors: %d\n", __func__, ret);
+ "%s-->Unable to create sysfs for cclogic, errors: %d\n",
+ __func__, ret);
goto err_chip_check;
}
- ret = request_threaded_irq(cclogic_dev->irq_working,NULL, cclogic_irq,
- cclogic_dev->platform_data->irq_working_flags|IRQF_ONESHOT, DRIVER_NAME,
+ ret = request_threaded_irq(cclogic_dev->irq_working, NULL, cclogic_irq,
+ cclogic_dev->platform_data->irq_working_flags | IRQF_ONESHOT, DRIVER_NAME,
cclogic_dev);
if (ret) {
- dev_err(&client->dev,
+ dev_err(&client->dev,
"%s: Failed to create working-irq thread\n", __func__);
goto err_irq_req;
}
if (gpio_is_valid(platform_data->irq_plug)) {
- ret = request_threaded_irq(cclogic_dev->irq_plug,NULL, cclogic_plug_irq,
- cclogic_dev->platform_data->irq_plug_flags|IRQF_ONESHOT, DRIVER_NAME,
+ ret = request_threaded_irq(cclogic_dev->irq_plug, NULL, cclogic_plug_irq,
+ cclogic_dev->platform_data->irq_plug_flags | IRQF_ONESHOT, DRIVER_NAME,
cclogic_dev);
if (ret) {
- dev_err(&client->dev,
+ dev_err(&client->dev,
"%s: Failed to create plug-irq thread\n", __func__);
goto err_irq_enable;
}
}
disable_irq(cclogic_dev->irq_working);
- if (gpio_is_valid(cclogic_dev->platform_data->irq_plug)) {
+ if (gpio_is_valid(cclogic_dev->platform_data->irq_plug))
disable_irq(cclogic_dev->irq_plug);
- }
pr_info("%s Success\n", __func__);
@@ -1603,15 +1455,16 @@ static int cclogic_probe(struct i2c_client *client,
cancel_delayed_work_sync(&cclogic_dev->work);
cancel_delayed_work_sync(&cclogic_dev->plug_work);
- cclogic_irq_enable(cclogic_dev,false);
+ cclogic_irq_enable(cclogic_dev, false);
if (gpio_is_valid(platform_data->irq_plug))
- free_irq(cclogic_dev->irq_plug,cclogic_dev);
+ free_irq(cclogic_dev->irq_plug, cclogic_dev);
+
err_irq_enable:
- free_irq(cclogic_dev->irq_working,cclogic_dev);
+ free_irq(cclogic_dev->irq_working, cclogic_dev);
err_irq_req:
sysfs_remove_group(&client->dev.kobj, &cclogic_attr_group);
-err_chip_check:
+err_chip_check:
device_init_wakeup(cclogic_dev->dev, 0);
wake_lock_destroy(&cclogic_dev->wakelock);
wake_lock_destroy(&cclogic_dev->wakelock_plug);
@@ -1628,16 +1481,12 @@ err_regulator_on:
err_regulator_conf:
cclogic_regulator_configure(cclogic_dev, false);
err_i2c:
- dev_err(&client->dev,"%s Failed\n", __func__);
+ dev_err(&client->dev, "%s Failed\n", __func__);
return ret;
}
-
-
-/**
- * cclogic_remove()
- */
+/* cclogic_remove() */
static int cclogic_remove(struct i2c_client *client)
{
struct cclogic_dev *cclogic_dev;
@@ -1646,9 +1495,9 @@ static int cclogic_remove(struct i2c_client *client)
cclogic_dev = i2c_get_clientdata(client);
- cclogic_irq_enable(cclogic_dev,false);
+ cclogic_irq_enable(cclogic_dev, false);
- cclogic_vbus_power_on(cclogic_dev,false);
+ cclogic_vbus_power_on(cclogic_dev, false);
sysfs_remove_group(&client->dev.kobj, &cclogic_attr_group);
@@ -1656,20 +1505,19 @@ static int cclogic_remove(struct i2c_client *client)
wake_lock_destroy(&cclogic_dev->wakelock);
wake_lock_destroy(&cclogic_dev->wakelock_plug);
- cancel_delayed_work_sync(&cclogic_dev->work);
+ cancel_delayed_work_sync(&cclogic_dev->work);
cancel_delayed_work_sync(&cclogic_dev->plug_work);
- free_irq(cclogic_dev->irq_working,cclogic_dev);
+ free_irq(cclogic_dev->irq_working, cclogic_dev);
if (gpio_is_valid(cclogic_dev->platform_data->irq_plug))
- free_irq(cclogic_dev->irq_plug,cclogic_dev);
+ free_irq(cclogic_dev->irq_plug, cclogic_dev);
- if (gpio_is_valid(cclogic_dev->platform_data->ccchip_power_gpio))
- gpio_set_value(cclogic_dev->platform_data->ccchip_power_gpio,0);
+ if (gpio_is_valid(cclogic_dev->platform_data->ccchip_power_gpio))
+ gpio_set_value(cclogic_dev->platform_data->ccchip_power_gpio, 0);
disable_irq_wake(cclogic_dev->irq_working);
- if (gpio_is_valid(cclogic_dev->platform_data->irq_plug)){
+ if (gpio_is_valid(cclogic_dev->platform_data->irq_plug))
disable_irq_wake(cclogic_dev->irq_plug);
- }
cclogic_remove_gpio(cclogic_dev);
@@ -1684,16 +1532,13 @@ static int cclogic_remove(struct i2c_client *client)
cclogic_regulator_configure(cclogic_dev, false);
- pm_runtime_disable(&client->dev);
- pm_runtime_set_suspended(&client->dev);
+ pm_runtime_disable(&client->dev);
+ pm_runtime_set_suspended(&client->dev);
return 0;
}
#ifdef CONFIG_PM
-/*
- *
- */
static int cclogic_runtime_suspend(struct device *dev)
{
struct cclogic_dev *cclogic_dev = dev_get_drvdata(dev);
@@ -1701,16 +1546,12 @@ static int cclogic_runtime_suspend(struct device *dev)
pr_debug("[%s][%d]\n", __func__, __LINE__);
- if (gpio_is_valid(pdata->enb_gpio)){
- gpio_direction_output(pdata->enb_gpio,!cclogic_dev->enb);
- }
+ if (gpio_is_valid(pdata->enb_gpio))
+ gpio_direction_output(pdata->enb_gpio, !cclogic_dev->enb);
- return 0;
+ return 0;
}
-/*
- *
- */
static int cclogic_runtime_resume(struct device *dev)
{
struct cclogic_dev *cclogic_dev = dev_get_drvdata(dev);
@@ -1718,19 +1559,15 @@ static int cclogic_runtime_resume(struct device *dev)
pr_debug("[%s][%d]\n", __func__, __LINE__);
- if (gpio_is_valid(pdata->enb_gpio)){
- gpio_direction_output(pdata->enb_gpio,cclogic_dev->enb);
- }
+ if (gpio_is_valid(pdata->enb_gpio))
+ gpio_direction_output(pdata->enb_gpio, cclogic_dev->enb);
- return 0;
+ return 0;
}
#endif
#ifdef CONFIG_PM_SLEEP
-/*
- *
- */
static int cclogic_suspend(struct device *dev)
{
struct cclogic_dev *cclogic_dev = dev_get_drvdata(dev);
@@ -1740,24 +1577,17 @@ static int cclogic_suspend(struct device *dev)
disable_irq(cclogic_dev->irq_working);
enable_irq_wake(cclogic_dev->irq_working);
- if (gpio_is_valid(pdata->irq_plug)){
+ if (gpio_is_valid(pdata->irq_plug)) {
disable_irq(cclogic_dev->irq_plug);
enable_irq_wake(cclogic_dev->irq_plug);
}
- //if(!gpio_get_value(pdata->platform_data->irq_plug)){
- //}
cclogic_power_on(cclogic_dev, false);
pinctrl_select_state(cclogic_dev->pin, cclogic_dev->pin_suspend);
- //if (gpio_is_valid(pdata->ccchip_power_gpio))
- // gpio_set_value(pdata->ccchip_power_gpio,0);
-
+
return 0;
}
-/*
- *
- */
static int cclogic_resume(struct device *dev)
{
struct cclogic_dev *cclogic_dev = dev_get_drvdata(dev);
@@ -1767,14 +1597,11 @@ static int cclogic_resume(struct device *dev)
pinctrl_select_state(cclogic_dev->pin, cclogic_dev->pin_active);
- //if (gpio_is_valid(pdata->ccchip_power_gpio))
- // gpio_set_value(pdata->ccchip_power_gpio,1);
-
cclogic_power_on(cclogic_dev, true);
disable_irq_wake(cclogic_dev->irq_working);
enable_irq(cclogic_dev->irq_working);
- if (gpio_is_valid(pdata->irq_plug)){
+ if (gpio_is_valid(pdata->irq_plug)) {
disable_irq_wake(cclogic_dev->irq_plug);
enable_irq(cclogic_dev->irq_plug);
}
@@ -1789,8 +1616,8 @@ void cclogic_shutdown(struct i2c_client *client)
}
static const struct dev_pm_ops cclogic_pm_ops = {
- SET_SYSTEM_SLEEP_PM_OPS(cclogic_suspend, cclogic_resume)
- SET_RUNTIME_PM_OPS(cclogic_runtime_suspend, cclogic_runtime_resume, NULL)
+ SET_SYSTEM_SLEEP_PM_OPS(cclogic_suspend, cclogic_resume)
+ SET_RUNTIME_PM_OPS(cclogic_runtime_suspend, cclogic_runtime_resume, NULL)
};
static const struct i2c_device_id cclogic_id_table[] = {
@@ -1800,7 +1627,7 @@ static const struct i2c_device_id cclogic_id_table[] = {
MODULE_DEVICE_TABLE(i2c, cclogic_id_table);
#ifdef CONFIG_OF
-static struct of_device_id cclogic_match_table[] = {
+static const struct of_device_id cclogic_match_table[] = {
{ .compatible = "typec,cclogic", },
{ },
};
@@ -1844,8 +1671,7 @@ static void __exit cclogic_exit(void)
i2c_del_driver(&cclogic_driver);
- if(cclogic_priv)
- kfree(cclogic_priv);
+ kfree(cclogic_priv);
cclogic_priv = NULL;
return;
diff --git a/drivers/misc/cclogic/cclogic-core.h b/drivers/misc/cclogic/cclogic-core.h
index 49361a73a80a..5e7b28d51b97 100644
--- a/drivers/misc/cclogic/cclogic-core.h
+++ b/drivers/misc/cclogic/cclogic-core.h
@@ -1,32 +1,32 @@
#ifndef __CCLOGIC_COMMON_H
-#define __CCLOGIC_COMMON_H
+#define __CCLOGIC_COMMON_H
#include <linux/wakelock.h>
#include "cclogic-class.h"
#define DEBUG
-#define DEV_STAGE_DEBUG
+#define DEV_STAGE_DEBUG
#define CCLOGIC_UPDATE_REAL_STATUS
#ifdef DEBUG
#undef pr_debug
#undef pr_info
-#define pr_debug(fmt, args...) pr_err(fmt, ##args)
-#define pr_info(fmt, args...) pr_err(fmt, ##args)
+#define pr_debug(fmt, args...) pr_err(fmt, ##args)
+#define pr_info(fmt, args...) pr_err(fmt, ##args)
#endif
#define CCLOGIC_I2C_VTG_MIN_UV 1800000
#define CCLOGIC_I2C_VTG_MAX_UV 1800000
-#define CCLOGIC_I2C_LOAD_UA 1800
+#define CCLOGIC_I2C_LOAD_UA 1800
#define CCLOGIC_MAX_SUPPORT_CHIP 2
-//#define CCLOGIC_MAX_RETRIES 100
+/* #define CCLOGIC_MAX_RETRIES 100 */
#define CCLOGIC_MAX_RETRIES 5
struct cclogic_of_chip {
- const char * chip_name;
+ const char *chip_name;
int enb;
int address;
};
@@ -57,7 +57,7 @@ struct cclogic_platform {
unsigned int irq_working;
unsigned int irq_plug_flags;
unsigned int irq_plug;
- bool i2c_pull_up;
+ bool i2c_pull_up;
unsigned int function_switch_gpio1;
unsigned int function_switch_gpio10;
unsigned int function_switch_gpio2;
@@ -96,7 +96,7 @@ enum cclogic_event_type {
enum cclogic_cc_type {
CCLOGIC_CC_UNKNOWN,
CCLOGIC_CC1,
- CCLOGIC_CC2,
+ CCLOGIC_CC2,
CCLOGIC_CC1_CC2,
};
@@ -115,30 +115,30 @@ struct cclogic_dev {
unsigned int irq_working;
unsigned int irq_plug;
bool irq_enabled;
- struct regulator *vcc_i2c;
- bool regulator_en;
+ struct regulator *vcc_i2c;
+ bool regulator_en;
struct delayed_work work;
struct delayed_work plug_work;
struct cclogic_platform *platform_data;
- struct wake_lock wakelock;
- struct wake_lock wakelock_plug;
+ struct wake_lock wakelock;
+ struct wake_lock wakelock_plug;
bool vbus_on;
struct cclogic_chip *ops;
struct cclogic_state state;
struct pinctrl *pin;
struct pinctrl_state *pin_active;
- struct pinctrl_state *pin_suspend;
+ struct pinctrl_state *pin_suspend;
struct cclogic_class_dev cdev;
int enb;
unsigned int typec_version;
};
struct cclogic_chip {
- const char * chip_name;
+ const char *chip_name;
unsigned char addr;
unsigned int typec_version;
unsigned int support;
- int (*get_state)(struct i2c_client *client,struct cclogic_state *result);
+ int (*get_state)(struct i2c_client *client, struct cclogic_state *result);
int (*ack_irq)(struct i2c_client *client);
int (*chip_config)(struct i2c_client *client);
int (*chip_reset)(struct i2c_client *client);
diff --git a/drivers/misc/cclogic/pi5usb30216d.c b/drivers/misc/cclogic/pi5usb30216d.c
index 6832328f1a47..ba7d6449c736 100644
--- a/drivers/misc/cclogic/pi5usb30216d.c
+++ b/drivers/misc/cclogic/pi5usb30216d.c
@@ -1,12 +1,12 @@
-//
-// pi5usb30216d.c
-//
-// Drivers for usb type-C interface's CC-Logic chip of Pericom
-//
+/*
+ * pi5usb30216d.c
+ *
+ * Drivers for usb type-C interface's CC-Logic chip of Pericom
+ */
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/io.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
#include <linux/fs.h>
#include <linux/slab.h>
#include <linux/init.h>
@@ -26,8 +26,8 @@
#define DRIVER_NAME "pericom,pi5usb30216d"
-/**
- * pi5usb30216d_write_i2c()
+/*
+ * pi5usb30216d_write_i2c()
* only modified 0x2 register value.
*/
static int pi5usb30216d_write_i2c(struct i2c_client *client, u8 reg, u8 data)
@@ -39,19 +39,17 @@ static int pi5usb30216d_write_i2c(struct i2c_client *client, u8 reg, u8 data)
val[reg-1] = data;
- ret = i2c_master_send(client, val, 2);
+ ret = i2c_master_send(client, val, 2);
if (ret != 2) {
- dev_err(&client->dev,"cclogic:%s-->i2c send error\n",__func__);
+ dev_err(&client->dev, "cclogic:%s-->i2c send error\n", __func__);
return ret;
}
return 0;
}
-/**
- * pi5usb30216d_parse_cclogic_state()
- */
-static void pi5usb30216d_parse_cclogic_state(int reg3, int reg4,
+/* pi5usb30216d_parse_cclogic_state() */
+static void pi5usb30216d_parse_cclogic_state(int reg3, int reg4,
struct cclogic_state *result)
{
pr_debug("cclogic:[%s][%d]\n", __func__, __LINE__);
@@ -62,23 +60,20 @@ static void pi5usb30216d_parse_cclogic_state(int reg3, int reg4,
result->device = CCLOGIC_DEVICE_UNKNOWN;
result->charger = CCLOGIC_CURRENT_NONE;
- if(reg3 == 0x3){
+ if (reg3 == 0x3) {
pr_err("cclogic:%s-->detach and attach in the same time\n",
__func__);
- }else{
- if(reg3&0x2){
+ } else{
+ if (reg3&0x2)
result->evt = CCLOGIC_EVENT_DETACHED;
- }
- if(reg3&0x1){
+ if (reg3&0x1)
result->evt = CCLOGIC_EVENT_ATTACHED;
- }
- }
+ }
- if(reg4&0x80){
+ if (reg4&0x80)
result->vbus = true;
- }
- switch(reg4&0x60){
+ switch (reg4&0x60) {
case 0x00:
result->charger = CCLOGIC_CURRENT_NONE;
break;
@@ -93,7 +88,7 @@ static void pi5usb30216d_parse_cclogic_state(int reg3, int reg4,
break;
}
- switch(reg4&0x3){
+ switch (reg4&0x3) {
case 0x01:
result->cc = CCLOGIC_CC1;
break;
@@ -104,11 +99,11 @@ static void pi5usb30216d_parse_cclogic_state(int reg3, int reg4,
break;
}
- switch(reg4&0x1C){
- case 0x00:
+ switch (reg4&0x1C) {
+ case 0x00:
result->device = CCLOGIC_NO_DEVICE;
break;
- case 0x04:
+ case 0x04:
result->device = CCLOGIC_USB_DEVICE;
break;
case 0x08:
@@ -127,33 +122,29 @@ static void pi5usb30216d_parse_cclogic_state(int reg3, int reg4,
}
-/**
- * pi5usb30216d_get_state()
- */
+/* pi5usb30216d_get_state() */
static int pi5usb30216d_get_state(struct i2c_client *client,
struct cclogic_state *state)
{
char reg[4] = {0};
int ret = 0;
-
+
pr_debug("cclogic:[%s][%d]\n", __func__, __LINE__);
- ret = i2c_master_recv(client, reg, 4);
+ ret = i2c_master_recv(client, reg, 4);
if (ret != 4) {
- dev_err(&client->dev,"cclogic:%s-->i2c recv error\n", __func__);
+ dev_err(&client->dev, "cclogic:%s-->i2c recv error\n", __func__);
return ret;
- }
+ }
pr_debug("cclogic:%s-->i2c reg value: 0x%02x 0x%02x 0x%02x 0x%02x\n",
- __func__,reg[0],reg[1],reg[2],reg[3]);
+ __func__, reg[0], reg[1], reg[2], reg[3]);
- pi5usb30216d_parse_cclogic_state(reg[2],reg[3],state);
+ pi5usb30216d_parse_cclogic_state(reg[2], reg[3], state);
return 0;
}
-/**
- * pi5usb30216d_check_chip()
- */
+/* pi5usb30216d_check_chip() */
static int pi5usb30216d_check_chip(struct i2c_client *client)
{
int ret;
@@ -162,23 +153,21 @@ static int pi5usb30216d_check_chip(struct i2c_client *client)
pr_debug("cclogic:[%s][%d]\n", __func__, __LINE__);
/* ID check */
- ret = i2c_master_recv(client, &reg_test_r, 1);
- if(ret!=1){
- dev_err(&client->dev,"cclogic:%s: i2c read error\n", __func__);
+ ret = i2c_master_recv(client, &reg_test_r, 1);
+ if (ret != 1) {
+ dev_err(&client->dev, "cclogic:%s: i2c read error\n", __func__);
return ret;
}
- if(reg_test_r != 0x20){
- dev_err(&client->dev,"cclogic:%s: devid mismatch"
- " (0x%02x!=0x20)\n", __func__,reg_test_r);
+ if (reg_test_r != 0x20) {
+ dev_err(&client->dev, "cclogic:%s: devid mismatch (0x%02x!=0x20)\n",
+ __func__, reg_test_r);
return -ENODEV;
}
return 0;
}
-/**
- * pi5usb30216d_trymode()
- */
+/* pi5usb30216d_trymode() */
static int pi5usb30216d_trymode(struct i2c_client *client, int mode)
{
int ret;
@@ -186,34 +175,32 @@ static int pi5usb30216d_trymode(struct i2c_client *client, int mode)
pr_debug("cclogic:[%s][%d]\n", __func__, __LINE__);
- if(mode == CCLOGIC_MODE_UFP){
+ if (mode == CCLOGIC_MODE_UFP) {
reg = 0x60;
pr_debug("cclogic:trymode sink\n");
- }else{
+ } else{
reg = 0x62;
pr_debug("cclogic:trymode source\n");
}
- ret = pi5usb30216d_write_i2c(client,0x2,reg);
- if(ret){
- dev_err(&client->dev,"cclogic:%s: i2c write error\n", __func__);
+ ret = pi5usb30216d_write_i2c(client, 0x2, reg);
+ if (ret) {
+ dev_err(&client->dev, "cclogic:%s: i2c write error\n", __func__);
return ret;
}
return ret;
}
-/**
- * pi5usb30216d_config_chip()
- */
+/* pi5usb30216d_config_chip() */
static int pi5usb30216d_config_chip(struct i2c_client *client)
{
int ret;
pr_debug("cclogic:[%s][%d]\n", __func__, __LINE__);
- ret = pi5usb30216d_write_i2c(client,0x2, 0x66);
- if(ret){
- dev_err(&client->dev,"cclogic:%s: i2c write error\n", __func__);
+ ret = pi5usb30216d_write_i2c(client, 0x2, 0x66);
+ if (ret) {
+ dev_err(&client->dev, "cclogic:%s: i2c write error\n", __func__);
return ret;
}
@@ -223,18 +210,16 @@ static int pi5usb30216d_config_chip(struct i2c_client *client)
static struct cclogic_chip pi5usb30216d_chip = {
.chip_name = DRIVER_NAME,
.get_state = pi5usb30216d_get_state,
- .ack_irq = NULL,
+ .ack_irq = NULL,
.chip_config = pi5usb30216d_config_chip,
.chip_reset = NULL,
.chip_check = pi5usb30216d_check_chip,
.chip_trymode = pi5usb30216d_trymode,
- .typec_version = 11,//spec 1.1
+ .typec_version = 11,/* spec 1.1 */
.support = CCLOGIC_SUPPORT_MODE_DUAL,
};
-/**
- * pi5usb30216d_init()
- */
+/* pi5usb30216d_init() */
static int __init pi5usb30216d_init(void)
{
pr_info("cclogic:[%s][%d]\n", __func__, __LINE__);
@@ -242,9 +227,7 @@ static int __init pi5usb30216d_init(void)
return cclogic_register(&pi5usb30216d_chip);
}
-/**
- * pi5usb30216d_exit()
- */
+/* pi5usb30216d_exit() */
static void __exit pi5usb30216d_exit(void)
{
pr_info("cclogic:[%s][%d]\n", __func__, __LINE__);
diff --git a/drivers/misc/cclogic/tusb320hai.c b/drivers/misc/cclogic/tusb320hai.c
index cefba953a54b..d7f9c4f60bb9 100644
--- a/drivers/misc/cclogic/tusb320hai.c
+++ b/drivers/misc/cclogic/tusb320hai.c
@@ -1,8 +1,8 @@
-//
-// tusb320hai.c
-//
-// Drivers for usb type-C interface's CC-Logic chip of TI
-//
+/*
+ * tusb320hai.c
+ *
+ * Drivers for usb type-C interface's CC-Logic chip of TI
+ */
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/io.h>
@@ -29,76 +29,68 @@
#define TUSB320_DEVID "023BSUT"
-/**
- * tusb320hai_read_i2c()
- */
+/* tusb320hai_read_i2c() */
static int tusb320hai_read_i2c(struct i2c_client *client, u8 reg)
{
- struct i2c_msg msg[2];
- int data=0;
- int ret;
-
- pr_debug("cclogic:[%s][%d]\n", __func__, __LINE__);
-
- if (!client->adapter)
- return -ENODEV;
+ struct i2c_msg msg[2];
+ int data = 0;
+ int ret;
- msg[0].addr = client->addr;
- msg[0].flags = 0;
- msg[0].buf = &reg;
- msg[0].len = sizeof(reg);
- msg[1].addr = client->addr;
- msg[1].flags = I2C_M_RD;
- msg[1].buf = (char *)&data;
- msg[1].len = 1;
+ pr_debug("cclogic:[%s][%d]\n", __func__, __LINE__);
+ if (!client->adapter)
+ return -ENODEV;
- ret = i2c_transfer(client->adapter, msg, 2);
- if (ret != 2){
- dev_err(&client->dev,"cclogic:%s-->i2c_transfer error\n",
- __func__);
- return ret;
- }
+ msg[0].addr = client->addr;
+ msg[0].flags = 0;
+ msg[0].buf = &reg;
+ msg[0].len = sizeof(reg);
+ msg[1].addr = client->addr;
+ msg[1].flags = I2C_M_RD;
+ msg[1].buf = (char *)&data;
+ msg[1].len = 1;
+
+ ret = i2c_transfer(client->adapter, msg, 2);
+ if (ret != 2) {
+ dev_err(&client->dev, "cclogic:%s-->i2c_transfer error\n",
+ __func__);
+ return ret;
+ }
- return data;
+ return data;
}
-/**
- * tusb320hai_recv_i2c()
- */
-static int tusb320hai_recv_i2c(struct i2c_client *client, char baseaddr,
- char * buf, int len)
+/* tusb320hai_recv_i2c() */
+static int tusb320hai_recv_i2c(struct i2c_client *client, char baseaddr,
+ char *buf, int len)
{
- struct i2c_msg msg[2];
- int ret;
-
- pr_debug("cclogic:[%s][%d]\n", __func__, __LINE__);
-
- if (!client->adapter)
- return -ENODEV;
+ struct i2c_msg msg[2];
+ int ret;
- msg[0].addr = client->addr;
- msg[0].flags = 0;
- msg[0].buf = &baseaddr;
- msg[0].len = 1;
- msg[1].addr = client->addr;
- msg[1].flags = I2C_M_RD;
- msg[1].buf = buf;
- msg[1].len = len;
+ pr_debug("cclogic:[%s][%d]\n", __func__, __LINE__);
+ if (!client->adapter)
+ return -ENODEV;
- ret = i2c_transfer(client->adapter, msg, 2);
- if (ret != 2){
- dev_err(&client->dev,"cclogic:%s-->i2c_transfer error\n",
+ msg[0].addr = client->addr;
+ msg[0].flags = 0;
+ msg[0].buf = &baseaddr;
+ msg[0].len = 1;
+ msg[1].addr = client->addr;
+ msg[1].flags = I2C_M_RD;
+ msg[1].buf = buf;
+ msg[1].len = len;
+
+ ret = i2c_transfer(client->adapter, msg, 2);
+ if (ret != 2) {
+ dev_err(&client->dev, "cclogic:%s-->i2c_transfer error\n",
__func__);
return ret;
- }
+ }
- return 0;
+ return 0;
}
-/**
- * tusb320hai_write_i2c()
- */
+/* tusb320hai_write_i2c() */
static int tusb320hai_write_i2c(struct i2c_client *client, u8 reg, u8 data)
{
int ret = 0;
@@ -108,7 +100,7 @@ static int tusb320hai_write_i2c(struct i2c_client *client, u8 reg, u8 data)
pr_debug("cclogic:[%s][%d]\n", __func__, __LINE__);
if (!client->adapter)
- return -ENODEV;
+ return -ENODEV;
buf[0] = reg;
buf[1] = data;
@@ -118,8 +110,8 @@ static int tusb320hai_write_i2c(struct i2c_client *client, u8 reg, u8 data)
msg.len = sizeof(buf);
ret = i2c_transfer(client->adapter, &msg, 1);
- if (ret != 1){
- dev_err(&client->dev,"cclogic:%s-->i2c_transfer error\n",
+ if (ret != 1) {
+ dev_err(&client->dev, "cclogic:%s-->i2c_transfer error\n",
__func__);
return ret;
}
@@ -128,10 +120,8 @@ static int tusb320hai_write_i2c(struct i2c_client *client, u8 reg, u8 data)
}
-/**
- * tusb320hai_parse_cclogic_state()
- */
-static void tusb320hai_parse_cclogic_state(int reg8, int reg9,
+/* tusb320hai_parse_cclogic_state() */
+static void tusb320hai_parse_cclogic_state(int reg8, int reg9,
struct cclogic_state *result)
{
pr_debug("cclogic:[%s][%d]\n", __func__, __LINE__);
@@ -141,24 +131,22 @@ static void tusb320hai_parse_cclogic_state(int reg8, int reg9,
result->evt = CCLOGIC_EVENT_NONE;
result->device = CCLOGIC_NO_DEVICE;
result->charger = CCLOGIC_CURRENT_NONE;
-
- if(!(reg9&0x10)){//No interrupt
+
+ if (!(reg9&0x10)) {/* No interrupt */
result->evt = CCLOGIC_EVENT_NONE;
- }else{
+ } else{
result->evt = CCLOGIC_EVENT_ATTACHED;
}
- if(reg9&0x20){
+ if (reg9&0x20)
result->cc = CCLOGIC_CC2;
- }else{
+ else
result->cc = CCLOGIC_CC1;
- }
- switch(reg9&0xc0){
- case 0x00://nothing attached
- if(reg9&0x10){
+ switch (reg9&0xc0) {
+ case 0x00:/* nothing attached */
+ if (reg9&0x10)
result->evt = CCLOGIC_EVENT_DETACHED;
- }
result->vbus = false;
result->device = CCLOGIC_NO_DEVICE;
break;
@@ -170,62 +158,59 @@ static void tusb320hai_parse_cclogic_state(int reg8, int reg9,
result->device = CCLOGIC_USB_HOST;
result->vbus = true;
break;
- case 0xC0://accessory
- switch(reg8&0x0e){
- case 0x00: //No Accessory attached
- if(reg9&0x10){
- result->evt = CCLOGIC_EVENT_DETACHED;
- }
- result->vbus = false;
- result->device = CCLOGIC_NO_DEVICE;
- break;
- case 0x08: //Audio Accessory DFP
- result->vbus = false;
- result->device = CCLOGIC_AUDIO_DEVICE;
- break;
- case 0x0a: //Audio Accessory UFP
- result->vbus = true;
- result->device = CCLOGIC_AUDIO_DEVICE;
- break;
- case 0x0e:// Debug Accessory UFP
- result->vbus = true;
- result->device = CCLOGIC_DEBUG_DEVICE;
- break;
- case 0x0c:// Debug Accessory DFP set to Hi-Z
- result->vbus = false;
- result->device = CCLOGIC_DEBUG_DEVICE;
- break;
- default://Reserve
- result->vbus = false;
- result->device = CCLOGIC_NO_DEVICE;
- break;
+ case 0xC0:/* accessory */
+ switch (reg8&0x0e) {
+ case 0x00: /* No Accessory attached */
+ if (reg9&0x10)
+ result->evt = CCLOGIC_EVENT_DETACHED;
+ result->vbus = false;
+ result->device = CCLOGIC_NO_DEVICE;
+ break;
+ case 0x08: /* Audio Accessory DFP */
+ result->vbus = false;
+ result->device = CCLOGIC_AUDIO_DEVICE;
+ break;
+ case 0x0a: /* Audio Accessory UFP */
+ result->vbus = true;
+ result->device = CCLOGIC_AUDIO_DEVICE;
+ break;
+ case 0x0e:/* Debug Accessory UFP */
+ result->vbus = true;
+ result->device = CCLOGIC_DEBUG_DEVICE;
+ break;
+ case 0x0c:/* Debug Accessory DFP set to Hi-Z */
+ result->vbus = false;
+ result->device = CCLOGIC_DEBUG_DEVICE;
+ break;
+ default:/* Reserve */
+ result->vbus = false;
+ result->device = CCLOGIC_NO_DEVICE;
+ break;
}
break;
}
- switch(reg8&0x30){
- case 0x00:
- result->charger = CCLOGIC_CURRENT_DEFAULT;
- break;
- case 0x10:
- result->charger = CCLOGIC_CURRENT_MEDIUM;
- break;
- case 0x20:
- result->charger = CCLOGIC_CURRENT_ACCESSORY;
- //result->vbus = false;
- break;
- case 0x30:
- result->charger = CCLOGIC_CURRENT_HIGH;
- break;
+ switch (reg8&0x30) {
+ case 0x00:
+ result->charger = CCLOGIC_CURRENT_DEFAULT;
+ break;
+ case 0x10:
+ result->charger = CCLOGIC_CURRENT_MEDIUM;
+ break;
+ case 0x20:
+ result->charger = CCLOGIC_CURRENT_ACCESSORY;
+ /* result->vbus = false; */
+ break;
+ case 0x30:
+ result->charger = CCLOGIC_CURRENT_HIGH;
+ break;
}
}
-/**
- * tusb320hai_reset_chip()
- */
+/* tusb320hai_reset_chip() */
static int tusb320hai_reset_chip(struct i2c_client *client)
{
int retries = 10;
@@ -233,34 +218,29 @@ static int tusb320hai_reset_chip(struct i2c_client *client)
pr_debug("cclogic:[%s][%d]\n", __func__, __LINE__);
- regval = tusb320hai_write_i2c(client,0xa,0x8);
- if(regval){
- dev_err(&client->dev,"cclogic:%s: i2c write error\n", __func__);
+ regval = tusb320hai_write_i2c(client, 0xa, 0x8);
+ if (regval) {
+ dev_err(&client->dev, "cclogic:%s: i2c write error\n", __func__);
return regval;
}
- while(retries--){
- regval = tusb320hai_read_i2c(client,0xa);
- if(regval<0){
- dev_err(&client->dev,"cclogic:%s: i2c read error\n",
+ while (retries--) {
+ regval = tusb320hai_read_i2c(client, 0xa);
+ if (regval < 0) {
+ dev_err(&client->dev, "cclogic:%s: i2c read error\n",
__func__);
return regval;
}
- if(!(regval&0x08)){
+ if (!(regval&0x08))
return 0;
- }
- mdelay(100);
+ msleep(100);
}
- if(regval&0x08){
+ if (regval&0x08)
return -1;
- }
return 0;
-
}
-/**
- * tusb320hai_trymode()
- */
+/* tusb320hai_trymode() */
static int tusb320hai_trymode(struct i2c_client *client, int mode)
{
int ret;
@@ -268,30 +248,30 @@ static int tusb320hai_trymode(struct i2c_client *client, int mode)
pr_debug("cclogic:[%s][%d]\n", __func__, __LINE__);
- ret = tusb320hai_write_i2c(client,0xa,0x33);
- if(ret){
- dev_err(&client->dev,"cclogic:%s: i2c write error\n", __func__);
+ ret = tusb320hai_write_i2c(client, 0xa, 0x33);
+ if (ret) {
+ dev_err(&client->dev, "cclogic:%s: i2c write error\n", __func__);
return ret;
}
- if(mode == CCLOGIC_MODE_UFP){
+ if (mode == CCLOGIC_MODE_UFP) {
regval = 0x13;
pr_debug("cclogic:trymode sink\n");
- }else{
+ } else{
regval = 0x23;
pr_debug("cclogic:trymode source\n");
}
- ret = tusb320hai_write_i2c(client,0xa,regval);
- if(ret){
- dev_err(&client->dev,"cclogic:%s: i2c write error\n", __func__);
+ ret = tusb320hai_write_i2c(client, 0xa, regval);
+ if (ret) {
+ dev_err(&client->dev, "cclogic:%s: i2c write error\n", __func__);
return ret;
}
- mdelay(6);
-
- ret = tusb320hai_write_i2c(client,0xa,regval & 0xfe);
- if(ret){
- dev_err(&client->dev,"cclogic:%s: i2c write error\n", __func__);
+ msleep(6);
+
+ ret = tusb320hai_write_i2c(client, 0xa, regval & 0xfe);
+ if (ret) {
+ dev_err(&client->dev, "cclogic:%s: i2c write error\n", __func__);
return ret;
}
@@ -299,23 +279,21 @@ static int tusb320hai_trymode(struct i2c_client *client, int mode)
}
-/**
- * tusb320hai_config_chip()
- */
+/* tusb320hai_config_chip() */
static int tusb320hai_config_chip(struct i2c_client *client)
{
int ret;
pr_debug("cclogic:[%s][%d]\n", __func__, __LINE__);
- ret = tusb320hai_write_i2c(client,0x8,0);//charger:default
- if(ret){
- dev_err(&client->dev,"cclogic:%s: i2c write error\n", __func__);
+ ret = tusb320hai_write_i2c(client, 0x8, 0);
+ if (ret) {
+ dev_err(&client->dev, "cclogic:%s: i2c write error\n", __func__);
return ret;
}
- ret = tusb320hai_write_i2c(client,0xa,0x32);//DRP and try.snk
- if(ret){
- dev_err(&client->dev,"cclogic:%s: i2c write error\n", __func__);
+ ret = tusb320hai_write_i2c(client, 0xa, 0x32);
+ if (ret) {
+ dev_err(&client->dev, "cclogic:%s: i2c write error\n", __func__);
return ret;
}
@@ -323,9 +301,7 @@ static int tusb320hai_config_chip(struct i2c_client *client)
}
-/**
- * tusb320hai_check_chip()
- */
+/* tusb320hai_check_chip() */
static int tusb320hai_check_chip(struct i2c_client *client)
{
char buf[8];
@@ -334,92 +310,88 @@ static int tusb320hai_check_chip(struct i2c_client *client)
pr_debug("cclogic:[%s][%d]\n", __func__, __LINE__);
/* ID check */
- ret = tusb320hai_recv_i2c(client, 0, buf, 8);
- if(ret){
- dev_err(&client->dev,"cclogic:%s: i2c recv error\n", __func__);
+ ret = tusb320hai_recv_i2c(client, 0, buf, 8);
+ if (ret) {
+ dev_err(&client->dev, "cclogic:%s: i2c recv error\n", __func__);
return -ENODEV;
}
- if(memcmp(buf,TUSB320_DEVID,sizeof(TUSB320_DEVID))){
- dev_err(&client->dev,"cclogic:%s: devid mismatch (%s != %s)\n",
- __func__,buf,TUSB320_DEVID);
+ if (memcmp(buf, TUSB320_DEVID, sizeof(TUSB320_DEVID))) {
+ dev_err(&client->dev, "cclogic:%s: devid mismatch (%s != %s)\n",
+ __func__, buf, TUSB320_DEVID);
return -ENODEV;
}
return 0;
}
-/**
- * tusb320hai_ack_irq()
- */
+/* tusb320hai_ack_irq() */
static int tusb320hai_ack_irq(struct i2c_client *client)
{
- int reg9,ret;
-
+ int reg9, ret;
+
pr_debug("cclogic:[%s][%d]\n", __func__, __LINE__);
- reg9 = tusb320hai_read_i2c(client,0x9);
- if(reg9<0){
- dev_err(&client->dev,"cclogic:%s-->i2c read error\n", __func__);
+ reg9 = tusb320hai_read_i2c(client, 0x9);
+ if (reg9 < 0) {
+ dev_err(&client->dev, "cclogic:%s-->i2c read error\n", __func__);
return reg9;
}
/* clear interrupt */
- ret = tusb320hai_write_i2c(client,0x9,reg9);
- if(ret){
- dev_err(&client->dev,"cclogic:%s-->i2c write error\n",__func__);
+ ret = tusb320hai_write_i2c(client, 0x9, reg9);
+ if (ret) {
+ dev_err(&client->dev, "cclogic:%s-->i2c write error\n", __func__);
return ret;
}
-
+
return 0;
}
-/**
- * tusb320hai_get_state()
- */
+/* tusb320hai_get_state() */
static int tusb320hai_get_state(struct i2c_client *client,
struct cclogic_state *state)
{
- int reg8,reg9,rega;
- static int flag = 0;
+ int reg8, reg9, rega;
+ static int flag;
pr_debug("cclogic:[%s][%d]\n", __func__, __LINE__);
- reg9 = tusb320hai_read_i2c(client,0x9);
- if(reg9<0){
- dev_err(&client->dev,"cclogic:%s-->i2c read error,reg9=%d\n",
- __func__,reg9);
+ reg9 = tusb320hai_read_i2c(client, 0x9);
+ if (reg9 < 0) {
+ dev_err(&client->dev, "cclogic:%s-->i2c read error,reg9=%d\n",
+ __func__, reg9);
return reg9;
}
- reg8 = tusb320hai_read_i2c(client,0x8);
- if(reg8<0){
- dev_err(&client->dev,"cclogic:%s-->i2c read error,reg8=%d\n",
- __func__,reg8);
+ reg8 = tusb320hai_read_i2c(client, 0x8);
+ if (reg8 < 0) {
+ dev_err(&client->dev, "cclogic:%s-->i2c read error,reg8=%d\n",
+ __func__, reg8);
return reg8;
}
pr_debug("cclogic:%s-->i2c register value: reg8=0x%02x reg9=0x%02x\n",
- __func__,reg8,reg9);
+ __func__, reg8, reg9);
- tusb320hai_parse_cclogic_state(reg8,reg9,state);
+ tusb320hai_parse_cclogic_state(reg8, reg9, state);
-#if 1 //for chip bug
- if(state->evt == CCLOGIC_EVENT_DETACHED){//skip detach event
+#if 1 /* for chip bug */
+ if (state->evt == CCLOGIC_EVENT_DETACHED) {/* skip detach event */
return 0;
}
- rega = tusb320hai_read_i2c(client,0xa);
- if(rega<0){
- dev_err(&client->dev,"cclogic:%s: i2c read error\n",
+ rega = tusb320hai_read_i2c(client, 0xa);
+ if (rega < 0) {
+ dev_err(&client->dev, "cclogic:%s: i2c read error\n",
__func__);
return rega;
}
- if((rega & 0x30)!=0x30) //skip UFP and DFP mode
+ if ((rega & 0x30) != 0x30)
return 0;
- if(!flag && (state->device == CCLOGIC_USB_DEVICE)){
+ if (!flag && (state->device == CCLOGIC_USB_DEVICE)) {
tusb320hai_reset_chip(client);
tusb320hai_config_chip(client);
flag = 1;
@@ -436,20 +408,18 @@ static int tusb320hai_get_state(struct i2c_client *client,
static struct cclogic_chip tusb320hai_chip = {
.chip_name = DRIVER_NAME,
.get_state = tusb320hai_get_state,
- .ack_irq = tusb320hai_ack_irq,
+ .ack_irq = tusb320hai_ack_irq,
.chip_config = tusb320hai_config_chip,
.chip_reset = tusb320hai_reset_chip,
.chip_check = tusb320hai_check_chip,
.chip_trymode = tusb320hai_trymode,
- .typec_version = 11,//spec 1.1
+ .typec_version = 11,/* spec 1.1 */
.support = CCLOGIC_SUPPORT_MODE_DUAL,
.read = tusb320hai_read_i2c,
.write = tusb320hai_write_i2c,
};
-/**
- * tusb320hai_init()
- */
+/* tusb320hai_init() */
static int __init tusb320hai_init(void)
{
pr_info("cclogic:[%s][%d]\n", __func__, __LINE__);
@@ -457,9 +427,7 @@ static int __init tusb320hai_init(void)
return cclogic_register(&tusb320hai_chip);
}
-/**
- * tusb320hai_exit()
- */
+/* tusb320hai_exit() */
static void __exit tusb320hai_exit(void)
{
pr_info("cclogic:[%s][%d]\n", __func__, __LINE__);
@@ -471,7 +439,6 @@ static void __exit tusb320hai_exit(void)
late_initcall(tusb320hai_init);
module_exit(tusb320hai_exit);
-
MODULE_LICENSE("Dual BSD/GPL");
MODULE_AUTHOR("Yang ShaoYing <yangsy2@lenovo.com>");
MODULE_DESCRIPTION("Drivers for usb type-C CC-Logic chip of TI Tusb320");