linux/drivers/regulator/cpcap-regulator.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Motorola CPCAP PMIC regulator driver
 *
 * Based on cpcap-regulator.c from Motorola Linux kernel tree
 * Copyright (C) 2009-2011 Motorola, Inc.
 *
 * Rewritten for mainline kernel to use device tree and regmap
 * Copyright (C) 2017 Tony Lindgren <[email protected]>
 */

#include <linux/err.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/of_regulator.h>
#include <linux/mfd/motorola-cpcap.h>

/*
 * Resource assignment register bits. These seem to control the state
 * idle modes adn are used at least for omap4.
 */

/* CPCAP_REG_ASSIGN2 bits - Resource Assignment 2 */
#define CPCAP_BIT_VSDIO_SEL
#define CPCAP_BIT_VDIG_SEL
#define CPCAP_BIT_VCAM_SEL
#define CPCAP_BIT_SW6_SEL
#define CPCAP_BIT_SW5_SEL
#define CPCAP_BIT_SW4_SEL
#define CPCAP_BIT_SW3_SEL
#define CPCAP_BIT_SW2_SEL
#define CPCAP_BIT_SW1_SEL

/* CPCAP_REG_ASSIGN3 bits - Resource Assignment 3 */
#define CPCAP_BIT_VUSBINT2_SEL
#define CPCAP_BIT_VUSBINT1_SEL
#define CPCAP_BIT_VVIB_SEL
#define CPCAP_BIT_VWLAN1_SEL
#define CPCAP_BIT_VRF1_SEL
#define CPCAP_BIT_VHVIO_SEL
#define CPCAP_BIT_VDAC_SEL
#define CPCAP_BIT_VUSB_SEL
#define CPCAP_BIT_VSIM_SEL
#define CPCAP_BIT_VRFREF_SEL
#define CPCAP_BIT_VPLL_SEL
#define CPCAP_BIT_VFUSE_SEL
#define CPCAP_BIT_VCSI_SEL
#define CPCAP_BIT_SPARE_14_2
#define CPCAP_BIT_VWLAN2_SEL
#define CPCAP_BIT_VRF2_SEL

/* CPCAP_REG_ASSIGN4 bits - Resource Assignment 4 */
#define CPCAP_BIT_VAUDIO_SEL

/*
 * Enable register bits. At least CPCAP_BIT_AUDIO_LOW_PWR is generic,
 * and not limited to audio regulator. Let's use the Motorola kernel
 * naming for now until we have a better understanding of the other
 * enable register bits. No idea why BIT(3) is not defined.
 */
#define CPCAP_BIT_AUDIO_LOW_PWR
#define CPCAP_BIT_AUD_LOWPWR_SPEED
#define CPCAP_BIT_VAUDIOPRISTBY
#define CPCAP_BIT_VAUDIO_MODE1
#define CPCAP_BIT_VAUDIO_MODE0
#define CPCAP_BIT_V_AUDIO_EN

#define CPCAP_BIT_AUDIO_NORMAL_MODE

/*
 * Off mode configuration bit. Used currently only by SW5 on omap4. There's
 * the following comment in Motorola Linux kernel tree for it:
 *
 * When set in the regulator mode, the regulator assignment will be changed
 * to secondary when the regulator is disabled. The mode will be set back to
 * primary when the regulator is turned on.
 */
#define CPCAP_REG_OFF_MODE_SEC

/*
 * SoC specific configuration for CPCAP regulator. There are at least three
 * different SoCs each with their own parameters: omap3, omap4 and tegra2.
 *
 * The assign_reg and assign_mask seem to allow toggling between primary
 * and secondary mode that at least omap4 uses for off mode.
 */
struct cpcap_regulator {};

#define CPCAP_REG(_ID, reg, assignment_reg, assignment_mask, val_tbl,	\
		mode_mask, volt_mask, mode_val, off_val,		\
		volt_trans_time)

struct cpcap_ddata {};

enum cpcap_regulator_id {};

/*
 * We need to also configure regulator idle mode for SoC off mode if
 * CPCAP_REG_OFF_MODE_SEC is set.
 */
static int cpcap_regulator_enable(struct regulator_dev *rdev)
{}

/*
 * We need to also configure regulator idle mode for SoC off mode if
 * CPCAP_REG_OFF_MODE_SEC is set.
 */
static int cpcap_regulator_disable(struct regulator_dev *rdev)
{}

static unsigned int cpcap_map_mode(unsigned int mode)
{}

static unsigned int cpcap_regulator_get_mode(struct regulator_dev *rdev)
{}

static int cpcap_regulator_set_mode(struct regulator_dev *rdev,
				    unsigned int mode)
{}

static const struct regulator_ops cpcap_regulator_ops =;

static const unsigned int unknown_val_tbl[] =;
static const unsigned int sw2_sw4_val_tbl[] =;
static const unsigned int sw5_val_tbl[] =;
static const unsigned int vcam_val_tbl[] =;
static const unsigned int vcsi_val_tbl[] =;
static const unsigned int vdac_val_tbl[] =;
static const unsigned int vdig_val_tbl[] =;
static const unsigned int vfuse_val_tbl[] =;
static const unsigned int vhvio_val_tbl[] =;
static const unsigned int vsdio_val_tbl[] =;
static const unsigned int vpll_val_tbl[] =;
/* Quirk: 2775000 is before 2500000 for vrf1 regulator */
static const unsigned int vrf1_val_tbl[] =;
static const unsigned int vrf2_val_tbl[] =;
static const unsigned int vrfref_val_tbl[] =;
static const unsigned int vwlan1_val_tbl[] =;
static const unsigned int vwlan2_val_tbl[] =;
static const unsigned int vsim_val_tbl[] =;
static const unsigned int vsimcard_val_tbl[] =;
static const unsigned int vvib_val_tbl[] =;
static const unsigned int vusb_val_tbl[] =;
static const unsigned int vaudio_val_tbl[] =;

/*
 * SoC specific configuration for omap4. The data below is comes from Motorola
 * Linux kernel tree. It's basically the values of cpcap_regltr_data,
 * cpcap_regulator_mode_values and cpcap_regulator_off_mode_values, see
 * CPCAP_REG macro above.
 *
 * SW1 to SW4 and SW6 seems to be unused for mapphone. Note that VSIM and
 * VSIMCARD have a shared resource assignment bit.
 */
static const struct cpcap_regulator omap4_regulators[] =;

static const struct cpcap_regulator xoom_regulators[] =;

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

static int cpcap_regulator_probe(struct platform_device *pdev)
{}

static struct platform_driver cpcap_regulator_driver =;

module_platform_driver();

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