linux/drivers/extcon/extcon-axp288.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * extcon-axp288.c - X-Power AXP288 PMIC extcon cable detection driver
 *
 * Copyright (c) 2017-2018 Hans de Goede <[email protected]>
 * Copyright (C) 2015 Intel Corporation
 * Author: Ramakrishna Pallala <[email protected]>
 */

#include <linux/acpi.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/io.h>
#include <linux/slab.h>
#include <linux/interrupt.h>
#include <linux/platform_device.h>
#include <linux/property.h>
#include <linux/notifier.h>
#include <linux/extcon-provider.h>
#include <linux/regmap.h>
#include <linux/mfd/axp20x.h>
#include <linux/usb/role.h>
#include <linux/workqueue.h>

#include <asm/cpu_device_id.h>
#include <asm/intel-family.h>
#include <asm/iosf_mbi.h>

/* Power source status register */
#define PS_STAT_VBUS_TRIGGER
#define PS_STAT_BAT_CHRG_DIR
#define PS_STAT_VBUS_ABOVE_VHOLD
#define PS_STAT_VBUS_VALID
#define PS_STAT_VBUS_PRESENT

/* BC module global register */
#define BC_GLOBAL_RUN
#define BC_GLOBAL_DET_STAT
#define BC_GLOBAL_DBP_TOUT
#define BC_GLOBAL_VLGC_COM_SEL
#define BC_GLOBAL_DCD_TOUT_MASK
#define BC_GLOBAL_DCD_TOUT_300MS
#define BC_GLOBAL_DCD_TOUT_100MS
#define BC_GLOBAL_DCD_TOUT_500MS
#define BC_GLOBAL_DCD_TOUT_900MS
#define BC_GLOBAL_DCD_DET_SEL

/* BC module vbus control and status register */
#define VBUS_CNTL_DPDM_PD_EN
#define VBUS_CNTL_DPDM_FD_EN
#define VBUS_CNTL_FIRST_PO_STAT

/* BC USB status register */
#define USB_STAT_BUS_STAT_MASK
#define USB_STAT_BUS_STAT_SHIFT
#define USB_STAT_BUS_STAT_ATHD
#define USB_STAT_BUS_STAT_CONN
#define USB_STAT_BUS_STAT_SUSP
#define USB_STAT_BUS_STAT_CONF
#define USB_STAT_USB_SS_MODE
#define USB_STAT_DEAD_BAT_DET
#define USB_STAT_DBP_UNCFG

/* BC detect status register */
#define DET_STAT_MASK
#define DET_STAT_SHIFT
#define DET_STAT_SDP
#define DET_STAT_CDP
#define DET_STAT_DCP

enum axp288_extcon_reg {};

enum axp288_extcon_irq {};

static const unsigned int axp288_extcon_cables[] =;

struct axp288_extcon_info {};

static const struct x86_cpu_id cherry_trail_cpu_ids[] =;

/* Power up/down reason string array */
static const char * const axp288_pwr_up_down_info[] =;

/*
 * Decode and log the given "reset source indicator" (rsi)
 * register and then clear it.
 */
static void axp288_extcon_log_rsi(struct axp288_extcon_info *info)
{}

/*
 * The below code to control the USB role-switch on devices with an AXP288
 * may seem out of place, but there are 2 reasons why this is the best place
 * to control the USB role-switch on such devices:
 * 1) On many devices the USB role is controlled by AML code, but the AML code
 *    only switches between the host and none roles, because of Windows not
 *    really using device mode. To make device mode work we need to toggle
 *    between the none/device roles based on Vbus presence, and this driver
 *    gets interrupts on Vbus insertion / removal.
 * 2) In order for our BC1.2 charger detection to work properly the role
 *    mux must be properly set to device mode before we do the detection.
 */

/* Returns the id-pin value, note pulled low / false == host-mode */
static bool axp288_get_id_pin(struct axp288_extcon_info *info)
{}

static void axp288_usb_role_work(struct work_struct *work)
{}

static bool axp288_get_vbus_attach(struct axp288_extcon_info *info)
{}

static int axp288_handle_chrg_det_event(struct axp288_extcon_info *info)
{}

static int axp288_extcon_id_evt(struct notifier_block *nb,
				unsigned long event, void *param)
{}

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

static int axp288_extcon_enable(struct axp288_extcon_info *info)
{}

static void axp288_put_role_sw(void *data)
{}

static int axp288_extcon_find_role_sw(struct axp288_extcon_info *info)
{}

static int axp288_extcon_probe(struct platform_device *pdev)
{}

static int __maybe_unused axp288_extcon_suspend(struct device *dev)
{}

static int __maybe_unused axp288_extcon_resume(struct device *dev)
{}

static SIMPLE_DEV_PM_OPS(axp288_extcon_pm_ops, axp288_extcon_suspend,
			 axp288_extcon_resume);

static const struct platform_device_id axp288_extcon_table[] =;
MODULE_DEVICE_TABLE(platform, axp288_extcon_table);

static struct platform_driver axp288_extcon_driver =;
module_platform_driver();

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