linux/drivers/mfd/twl-core.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * twl_core.c - driver for TWL4030/TWL5030/TWL60X0/TPS659x0 PM
 * and audio CODEC devices
 *
 * Copyright (C) 2005-2006 Texas Instruments, Inc.
 *
 * Modifications to defer interrupt handling to a kernel thread:
 * Copyright (C) 2006 MontaVista Software, Inc.
 *
 * Based on tlv320aic23.c:
 * Copyright (c) by Kai Svahn <[email protected]>
 *
 * Code cleanup and modifications to IRQ handler.
 * by syed khasim <[email protected]>
 */

#include <linux/init.h>
#include <linux/mutex.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/clk.h>
#include <linux/err.h>
#include <linux/device.h>
#include <linux/of.h>
#include <linux/of_irq.h>
#include <linux/of_platform.h>
#include <linux/irq.h>
#include <linux/irqdomain.h>

#include <linux/regulator/machine.h>

#include <linux/i2c.h>

#include <linux/mfd/core.h>
#include <linux/mfd/twl.h>

/* Register descriptions for audio */
#include <linux/mfd/twl4030-audio.h>

#include "twl-core.h"

/*
 * The TWL4030 "Triton 2" is one of a family of a multi-function "Power
 * Management and System Companion Device" chips originally designed for
 * use in OMAP2 and OMAP 3 based systems.  Its control interfaces use I2C,
 * often at around 3 Mbit/sec, including for interrupt handling.
 *
 * This driver core provides genirq support for the interrupts emitted,
 * by the various modules, and exports register access primitives.
 *
 * FIXME this driver currently requires use of the first interrupt line
 * (and associated registers).
 */

#define DRIVER_NAME

/* Triton Core internal information (BEGIN) */

/* Base Address defns for twl4030_map[] */

/* subchip/slave 0 - USB ID */
#define TWL4030_BASEADD_USB

/* subchip/slave 1 - AUD ID */
#define TWL4030_BASEADD_AUDIO_VOICE
#define TWL4030_BASEADD_GPIO
#define TWL4030_BASEADD_INTBR
#define TWL4030_BASEADD_PIH
#define TWL4030_BASEADD_TEST

/* subchip/slave 2 - AUX ID */
#define TWL4030_BASEADD_INTERRUPTS
#define TWL4030_BASEADD_LED
#define TWL4030_BASEADD_MADC
#define TWL4030_BASEADD_MAIN_CHARGE
#define TWL4030_BASEADD_PRECHARGE
#define TWL4030_BASEADD_PWM
#define TWL4030_BASEADD_KEYPAD

#define TWL5031_BASEADD_ACCESSORY
#define TWL5031_BASEADD_INTERRUPTS

/* subchip/slave 3 - POWER ID */
#define TWL4030_BASEADD_BACKUP
#define TWL4030_BASEADD_INT
#define TWL4030_BASEADD_PM_MASTER

#define TWL4030_BASEADD_PM_RECEIVER
#define TWL4030_DCDC_GLOBAL_CFG
#define SMARTREFLEX_ENABLE

#define TWL4030_BASEADD_RTC
#define TWL4030_BASEADD_SECURED_REG

/* Triton Core internal information (END) */


/* subchip/slave 0 0x48 - POWER */
#define TWL6030_BASEADD_RTC
#define TWL6030_BASEADD_SECURED_REG
#define TWL6030_BASEADD_PM_MASTER
#define TWL6030_BASEADD_PM_SLAVE_MISC
#define TWL6030_BASEADD_PM_MISC
#define TWL6030_BASEADD_PM_PUPD

/* subchip/slave 1 0x49 - FEATURE */
#define TWL6030_BASEADD_USB
#define TWL6030_BASEADD_GPADC_CTRL
#define TWL6030_BASEADD_AUX
#define TWL6030_BASEADD_PWM
#define TWL6030_BASEADD_GASGAUGE
#define TWL6030_BASEADD_PIH
#define TWL6032_BASEADD_CHARGER
#define TWL6030_BASEADD_CHARGER
#define TWL6030_BASEADD_LED

/* subchip/slave 2 0x4A - DFT */
#define TWL6030_BASEADD_DIEID

/* subchip/slave 3 0x4B - AUDIO */
#define TWL6030_BASEADD_AUDIO
#define TWL6030_BASEADD_RSV
#define TWL6030_BASEADD_ZERO

/* Some fields in TWL6030_PHOENIX_DEV_ON */
#define TWL6030_APP_DEVOFF
#define TWL6030_CON_DEVOFF
#define TWL6030_MOD_DEVOFF

/* Few power values */
#define R_CFG_BOOT

/* some fields in R_CFG_BOOT */
#define HFCLK_FREQ_19p2_MHZ
#define HFCLK_FREQ_26_MHZ
#define HFCLK_FREQ_38p4_MHZ
#define HIGH_PERF_SQ
#define CK32K_LOWPWR_EN

/*----------------------------------------------------------------------*/

/* Structure for each TWL4030/TWL6030 Slave */
struct twl_client {};

/* mapping the module id to slave id and base address */
struct twl_mapping {};

struct twl_private {};

static struct twl_private *twl_priv;

static struct twl_mapping twl4030_map[] =;

static const struct reg_default twl4030_49_defaults[] =;

static bool twl4030_49_nop_reg(struct device *dev, unsigned int reg)
{}

static const struct regmap_range twl4030_49_volatile_ranges[] =;

static const struct regmap_access_table twl4030_49_volatile_table =;

static const struct regmap_config twl4030_regmap_config[4] =;

static struct twl_mapping twl6030_map[] =;

static const struct regmap_config twl6030_regmap_config[3] =;

/*----------------------------------------------------------------------*/

static inline int twl_get_num_slaves(void)
{}

static inline int twl_get_last_module(void)
{}

/* Exported Functions */

unsigned int twl_rev(void)
{}
EXPORT_SYMBOL();

/**
 * twl_get_regmap - Get the regmap associated with the given module
 * @mod_no: module number
 *
 * Returns the regmap pointer or NULL in case of failure.
 */
static struct regmap *twl_get_regmap(u8 mod_no)
{}

/**
 * twl_i2c_write - Writes a n bit register in TWL4030/TWL5030/TWL60X0
 * @mod_no: module number
 * @value: an array of num_bytes+1 containing data to write
 * @reg: register address (just offset will do)
 * @num_bytes: number of bytes to transfer
 *
 * Returns 0 on success or else a negative error code.
 */
int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
{}
EXPORT_SYMBOL();

/**
 * twl_i2c_read - Reads a n bit register in TWL4030/TWL5030/TWL60X0
 * @mod_no: module number
 * @value: an array of num_bytes containing data to be read
 * @reg: register address (just offset will do)
 * @num_bytes: number of bytes to transfer
 *
 * Returns 0 on success or else a negative error code.
 */
int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
{}
EXPORT_SYMBOL();

/**
 * twl_set_regcache_bypass - Configure the regcache bypass for the regmap associated
 *			 with the module
 * @mod_no: module number
 * @enable: Regcache bypass state
 *
 * Returns 0 else failure.
 */
int twl_set_regcache_bypass(u8 mod_no, bool enable)
{}
EXPORT_SYMBOL();

/*----------------------------------------------------------------------*/

/**
 * twl_read_idcode_register - API to read the IDCODE register.
 *
 * Unlocks the IDCODE register and read the 32 bit value.
 */
static int twl_read_idcode_register(void)
{}

/**
 * twl_get_type - API to get TWL Si type.
 *
 * Api to get the TWL Si type from IDCODE value.
 */
int twl_get_type(void)
{}
EXPORT_SYMBOL_GPL();

/**
 * twl_get_version - API to get TWL Si version.
 *
 * Api to get the TWL Si version from IDCODE value.
 */
int twl_get_version(void)
{}
EXPORT_SYMBOL_GPL();

/**
 * twl_get_hfclk_rate - API to get TWL external HFCLK clock rate.
 *
 * Api to get the TWL HFCLK rate based on BOOT_CFG register.
 */
int twl_get_hfclk_rate(void)
{}
EXPORT_SYMBOL_GPL();

/*----------------------------------------------------------------------*/

/*
 * These three functions initialize the on-chip clock framework,
 * letting it generate the right frequencies for USB, MADC, and
 * other purposes.
 */
static inline int protect_pm_master(void)
{}

static inline int unprotect_pm_master(void)
{}

static void clocks_init(struct device *dev)
{}

/*----------------------------------------------------------------------*/


static void twl_remove(struct i2c_client *client)
{}

static void twl6030_power_off(void)
{}


static struct of_dev_auxdata twl_auxdata_lookup[] =;

static const struct mfd_cell twl6032_cells[] =;

/* NOTE: This driver only handles a single twl4030/tps659x0 chip */
static int
twl_probe(struct i2c_client *client)
{}

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

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

static SIMPLE_DEV_PM_OPS(twl_dev_pm_ops, twl_suspend, twl_resume);

static const struct i2c_device_id twl_ids[] =;

/* One Client Driver , 4 Clients */
static struct i2c_driver twl_driver =;
builtin_i2c_driver();