Source
x
/*
* extcon-sm5502.c - Silicon Mitus SM5502 extcon drvier 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;
unsigned int val;
bool invert;
};
struct sm5502_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;
struct work_struct irq_work;
struct reg_data *reg_data;
unsigned int num_reg_data;
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 SM5502 register to bring up MUIC device. */
static struct reg_data sm5502_reg_data[] = {
{
.reg = SM5502_REG_CONTROL,
.val = SM5502_REG_CONTROL_MASK_INT_MASK,
.invert = false,
}, {
.reg = SM5502_REG_INTMASK1,
.val = SM5502_REG_INTM1_KP_MASK
| SM5502_REG_INTM1_LKP_MASK
| SM5502_REG_INTM1_LKR_MASK,
.invert = true,
}, {
.reg = SM5502_REG_INTMASK2,
.val = SM5502_REG_INTM2_VBUS_DET_MASK
| SM5502_REG_INTM2_REV_ACCE_MASK
| SM5502_REG_INTM2_ADC_CHG_MASK
| SM5502_REG_INTM2_STUCK_KEY_MASK
| SM5502_REG_INTM2_STUCK_KEY_RCV_MASK
| SM5502_REG_INTM2_MHL_MASK,
.invert = true,
},
{ }
};