Source
x
/* Define OVP (Over Voltage Protection), OTP (Over Temperature Protection) */
/*
* extcon-rt8973a.c - Richtek RT8973A extcon driver to support USB switches
*
* Copyright (c) 2014 Samsung Electronics Co., Ltd
* Author: Chanwoo Choi <cw00.choi@samsung.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*/
/* unit: millisecond */
struct muic_irq {
unsigned int irq;
const char *name;
unsigned int virq;
};
struct reg_data {
u8 reg;
u8 mask;
u8 val;
bool invert;
};
struct rt8973a_muic_info {
struct device *dev;
struct extcon_dev *edev;
struct i2c_client *i2c;
struct regmap *regmap;
struct regmap_irq_chip_data *irq_data;
struct muic_irq *muic_irqs;
unsigned int num_muic_irqs;
int irq;
bool irq_attach;
bool irq_detach;
bool irq_ovp;
bool irq_otp;
struct work_struct irq_work;
struct reg_data *reg_data;
unsigned int num_reg_data;
bool auto_config;
struct mutex mutex;
/*
* Use delayed workqueue to detect cable state and then
* notify cable state to notifiee/platform through uevent.
* After completing the booting of platform, the extcon provider
* driver should notify cable state to upper layer.
*/
struct delayed_work wq_detcable;
};
/* Default value of RT8973A register to bring up MUIC device. */
static struct reg_data rt8973a_reg_data[] = {
{
.reg = RT8973A_REG_CONTROL1,
.mask = RT8973A_REG_CONTROL1_ADC_EN_MASK
| RT8973A_REG_CONTROL1_USB_CHD_EN_MASK
| RT8973A_REG_CONTROL1_CHGTYP_MASK
| RT8973A_REG_CONTROL1_SWITCH_OPEN_MASK
| RT8973A_REG_CONTROL1_AUTO_CONFIG_MASK
| RT8973A_REG_CONTROL1_INTM_MASK,
.val = RT8973A_REG_CONTROL1_ADC_EN_MASK
| RT8973A_REG_CONTROL1_USB_CHD_EN_MASK
| RT8973A_REG_CONTROL1_CHGTYP_MASK,
.invert = false,
},
{ /* sentinel */ }
};
/* List of detectable cables */