linux/drivers/extcon/extcon-fsa9480.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * extcon-fsa9480.c - Fairchild Semiconductor FSA9480 extcon driver
 *
 * Copyright (c) 2019 Tomasz Figa <[email protected]>
 *
 * Loosely based on old fsa9480 misc-device driver.
 */

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/i2c.h>
#include <linux/slab.h>
#include <linux/bitops.h>
#include <linux/interrupt.h>
#include <linux/err.h>
#include <linux/platform_device.h>
#include <linux/kobject.h>
#include <linux/extcon-provider.h>
#include <linux/irqdomain.h>
#include <linux/regmap.h>

/* FSA9480 I2C registers */
#define FSA9480_REG_DEVID
#define FSA9480_REG_CTRL
#define FSA9480_REG_INT1
#define FSA9480_REG_INT2
#define FSA9480_REG_INT1_MASK
#define FSA9480_REG_INT2_MASK
#define FSA9480_REG_ADC
#define FSA9480_REG_TIMING1
#define FSA9480_REG_TIMING2
#define FSA9480_REG_DEV_T1
#define FSA9480_REG_DEV_T2
#define FSA9480_REG_BTN1
#define FSA9480_REG_BTN2
#define FSA9480_REG_CK
#define FSA9480_REG_CK_INT1
#define FSA9480_REG_CK_INT2
#define FSA9480_REG_CK_INTMASK1
#define FSA9480_REG_CK_INTMASK2
#define FSA9480_REG_MANSW1
#define FSA9480_REG_MANSW2
#define FSA9480_REG_END

/* Control */
#define CON_SWITCH_OPEN
#define CON_RAW_DATA
#define CON_MANUAL_SW
#define CON_WAIT
#define CON_INT_MASK
#define CON_MASK

/* Device Type 1 */
#define DEV_USB_OTG
#define DEV_DEDICATED_CHG
#define DEV_USB_CHG
#define DEV_CAR_KIT
#define DEV_UART
#define DEV_USB
#define DEV_AUDIO_2
#define DEV_AUDIO_1

#define DEV_T1_USB_MASK
#define DEV_T1_UART_MASK
#define DEV_T1_CHARGER_MASK

/* Device Type 2 */
#define DEV_AV
#define DEV_TTY
#define DEV_PPD
#define DEV_JIG_UART_OFF
#define DEV_JIG_UART_ON
#define DEV_JIG_USB_OFF
#define DEV_JIG_USB_ON

#define DEV_T2_USB_MASK
#define DEV_T2_UART_MASK
#define DEV_T2_JIG_MASK

/*
 * Manual Switch
 * D- [7:5] / D+ [4:2]
 * 000: Open all / 001: USB / 010: AUDIO / 011: UART / 100: V_AUDIO
 */
#define SW_VAUDIO
#define SW_UART
#define SW_AUDIO
#define SW_DHOST
#define SW_AUTO

/* Interrupt 1 */
#define INT1_MASK
#define INT_DETACH
#define INT_ATTACH

/* Interrupt 2 mask */
#define INT2_MASK

/* Timing Set 1 */
#define TIMING1_ADC_500MS

struct fsa9480_usbsw {};

static const unsigned int fsa9480_extcon_cable[] =;

static const u64 cable_types[] =;

/* Define regmap configuration of FSA9480 for I2C communication  */
static bool fsa9480_volatile_reg(struct device *dev, unsigned int reg)
{}

static const struct regmap_config fsa9480_regmap_config =;

static int fsa9480_write_reg(struct fsa9480_usbsw *usbsw, int reg, int value)
{}

static int fsa9480_read_reg(struct fsa9480_usbsw *usbsw, int reg)
{}

static int fsa9480_read_irq(struct fsa9480_usbsw *usbsw, int *value)
{}

static void fsa9480_handle_change(struct fsa9480_usbsw *usbsw,
				  u16 mask, bool attached)
{}

static void fsa9480_detect_dev(struct fsa9480_usbsw *usbsw)
{}

static irqreturn_t fsa9480_irq_handler(int irq, void *data)
{}

static int fsa9480_probe(struct i2c_client *client)
{}

#ifdef CONFIG_PM_SLEEP
static int fsa9480_suspend(struct device *dev)
{}

static int fsa9480_resume(struct device *dev)
{}
#endif

static const struct dev_pm_ops fsa9480_pm_ops =;

static const struct i2c_device_id fsa9480_id[] =;
MODULE_DEVICE_TABLE(i2c, fsa9480_id);

static const struct of_device_id fsa9480_of_match[] =;
MODULE_DEVICE_TABLE(of, fsa9480_of_match);

static struct i2c_driver fsa9480_i2c_driver =;

static int __init fsa9480_module_init(void)
{}
subsys_initcall(fsa9480_module_init);

static void __exit fsa9480_module_exit(void)
{}
module_exit(fsa9480_module_exit);

MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_LICENSE();