linux/drivers/extcon/extcon-lc824206xa.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * ON Semiconductor LC824206XA Micro USB Switch driver
 *
 * Copyright (c) 2024 Hans de Goede <[email protected]>
 *
 * ON Semiconductor has an "Advance Information" datasheet available
 * (ENA2222-D.PDF), but no full datasheet. So there is no documentation
 * available for the registers.
 *
 * This driver is based on the register info from the extcon-fsa9285.c driver,
 * from the Lollipop Android sources for the Lenovo Yoga Tablet 2 (Pro)
 * 830 / 1050 / 1380 models. Note despite the name this is actually a driver
 * for the LC824206XA not the FSA9285. The Android sources can be downloaded
 * from Lenovo's support page for these tablets, filename:
 * yoga_tab_2_osc_android_to_lollipop_201505.rar.
 */

#include <linux/bits.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/extcon-provider.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/power_supply.h>
#include <linux/property.h>
#include <linux/regulator/consumer.h>
#include <linux/workqueue.h>

/*
 * Register defines as mentioned above there is no datasheet with register
 * info, so this may not be 100% accurate.
 */
#define REG00
#define REG00_INIT_VALUE

#define REG_STATUS
#define STATUS_OVP
#define STATUS_DATA_SHORT
#define STATUS_VBUS_PRESENT
#define STATUS_USB_ID
#define STATUS_USB_ID_GND
#define STATUS_USB_ID_ACA
#define STATUS_USB_ID_FLOAT

/*
 * This controls the DP/DM muxes + other switches,
 * meaning of individual bits is unknown.
 */
#define REG_SWITCH_CONTROL
#define SWITCH_STEREO_MIC
#define SWITCH_USB_HOST
#define SWITCH_DISCONNECTED
#define SWITCH_USB_DEVICE

/* 5 bits? ADC 0x10 GND, 0x1a-0x1f ACA, 0x1f float */
#define REG_ID_PIN_ADC_VALUE

/* Masks for all 3 interrupt registers */
#define INTR_ID_PIN_CHANGE
#define INTR_VBUS_CHANGE
/* Both of these get set after a continuous mode ADC conversion */
#define INTR_ID_PIN_ADC_INT1
#define INTR_ID_PIN_ADC_INT2
/* Charger type available in reg 0x09 */
#define INTR_CHARGER_DET_DONE
#define INTR_OVP

/* There are 7 interrupt sources, bit 6 use is unknown (OCP?) */
#define INTR_ALL

/* Unmask interrupts this driver cares about */
#define INTR_MASK

/* Active (event happened and not cleared yet) interrupts */
#define REG_INTR_STATUS

/*
 * Writing a 1 to a bit here clears it in INTR_STATUS. These bits do NOT
 * auto-reset to 0, so these must be set to 0 manually after clearing.
 */
#define REG_INTR_CLEAR

/* Interrupts which bit is set to 1 here will not raise the HW IRQ */
#define REG_INTR_MASK

/* ID pin ADC control, meaning of individual bits is unknown */
#define REG_ID_PIN_ADC_CTRL
#define ID_PIN_ADC_AUTO
#define ID_PIN_ADC_CONTINUOUS

#define REG_CHARGER_DET
#define CHARGER_DET_ON
#define CHARGER_DET_CDP_ON
#define CHARGER_DET_CDP_VAL

#define REG_CHARGER_TYPE
#define CHARGER_TYPE_UNKNOWN
#define CHARGER_TYPE_DCP
#define CHARGER_TYPE_SDP_OR_CDP
#define CHARGER_TYPE_QC

#define REG10
#define REG10_INIT_VALUE

struct lc824206xa_data {};

static const unsigned int lc824206xa_cables[] =;

/* read/write reg helpers to add error logging to smbus byte functions */
static int lc824206xa_read_reg(struct lc824206xa_data *data, u8 reg)
{}

static int lc824206xa_write_reg(struct lc824206xa_data *data, u8 reg, u8 val)
{}

static int lc824206xa_get_id(struct lc824206xa_data *data)
{}

static void lc824206xa_set_vbus_boost(struct lc824206xa_data *data, bool enable)
{}

static void lc824206xa_charger_detect(struct lc824206xa_data *data)
{}

static void lc824206xa_work(struct work_struct *work)
{}

static irqreturn_t lc824206xa_irq(int irq, void *_data)
{}

/*
 * Newer charger (power_supply) drivers expect the max input current to be
 * provided by a parent power_supply device for the charger chip.
 */
static int lc824206xa_psy_get_prop(struct power_supply *psy,
				   enum power_supply_property psp,
				   union power_supply_propval *val)
{}

static const enum power_supply_property lc824206xa_psy_props[] =;

static const struct power_supply_desc lc824206xa_psy_desc =;

static int lc824206xa_probe(struct i2c_client *client)
{}

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

static struct i2c_driver lc824206xa_driver =;

module_i2c_driver();

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