linux/drivers/mfd/tps6594-core.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Core functions for TI TPS65224/TPS6594/TPS6593/LP8764 PMICs
 *
 * Copyright (C) 2023 BayLibre Incorporated - https://www.baylibre.com/
 */

#include <linux/completion.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/of.h>

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

#define TPS6594_CRC_SYNC_TIMEOUT_MS

/* Completion to synchronize CRC feature enabling on all PMICs */
static DECLARE_COMPLETION(tps6594_crc_comp);

static const struct resource tps6594_regulator_resources[] =;

static const struct resource tps6594_pinctrl_resources[] =;

static const struct resource tps6594_pfsm_resources[] =;

static const struct resource tps6594_esm_resources[] =;

static const struct resource tps6594_rtc_resources[] =;

static const struct mfd_cell tps6594_common_cells[] =;

static const struct mfd_cell tps6594_rtc_cells[] =;

static const struct regmap_irq tps6594_irqs[] =;

static const unsigned int tps6594_irq_reg[] =;

/* TPS65224 Resources */

static const struct resource tps65224_regulator_resources[] =;

static const struct resource tps65224_pinctrl_resources[] =;

static const struct resource tps65224_pfsm_resources[] =;

static const struct resource tps65224_adc_resources[] =;

static const struct mfd_cell tps65224_common_cells[] =;

static const struct regmap_irq tps65224_irqs[] =;

static const unsigned int tps65224_irq_reg[] =;

static inline unsigned int tps6594_get_irq_reg(struct regmap_irq_chip_data *data,
					       unsigned int base, int index)
{
	return tps6594_irq_reg[index];
};

static inline unsigned int tps65224_get_irq_reg(struct regmap_irq_chip_data *data,
						unsigned int base, int index)
{
	return tps65224_irq_reg[index];
};

static int tps6594_handle_post_irq(void *irq_drv_data)
{
	struct tps6594 *tps = irq_drv_data;
	int ret = 0;
	unsigned int regmap_reg, mask_val;

	/*
	 * When CRC is enabled, writing to a read-only bit triggers an error,
	 * and COMM_ADR_ERR_INT bit is set. Besides, bits indicating interrupts
	 * (that must be cleared) and read-only bits are sometimes grouped in
	 * the same register.
	 * Since regmap clears interrupts by doing a write per register, clearing
	 * an interrupt bit in a register containing also a read-only bit makes
	 * COMM_ADR_ERR_INT bit set. Clear immediately this bit to avoid raising
	 * a new interrupt.
	 */
	if (tps->use_crc) {
		if (tps->chip_id == TPS65224) {
			regmap_reg = TPS6594_REG_INT_FSM_ERR;
			mask_val = TPS6594_BIT_COMM_ERR_INT;
		} else {
			regmap_reg = TPS6594_REG_INT_COMM_ERR;
			mask_val = TPS6594_BIT_COMM_ADR_ERR_INT;
		}

		ret = regmap_write_bits(tps->regmap, regmap_reg, mask_val, mask_val);
	}

	return ret;
};

static struct regmap_irq_chip tps6594_irq_chip =;

static struct regmap_irq_chip tps65224_irq_chip =;

static const struct regmap_range tps6594_volatile_ranges[] =;

const struct regmap_access_table tps6594_volatile_table =;
EXPORT_SYMBOL_GPL();

static const struct regmap_range tps65224_volatile_ranges[] =;

const struct regmap_access_table tps65224_volatile_table =;
EXPORT_SYMBOL_GPL();

static int tps6594_check_crc_mode(struct tps6594 *tps, bool primary_pmic)
{}

static int tps6594_set_crc_feature(struct tps6594 *tps)
{}

static int tps6594_enable_crc(struct tps6594 *tps)
{}

int tps6594_device_init(struct tps6594 *tps, bool enable_crc)
{}
EXPORT_SYMBOL_GPL();

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