linux/drivers/soc/mediatek/mtk-pmic-wrap.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2014 MediaTek Inc.
 * Author: Flora Fu, MediaTek
 */
#include <linux/clk.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/reset.h>

#define PWRAP_POLL_DELAY_US
#define PWRAP_POLL_TIMEOUT_US

#define PWRAP_MT8135_BRIDGE_IORD_ARB_EN
#define PWRAP_MT8135_BRIDGE_WACS3_EN
#define PWRAP_MT8135_BRIDGE_INIT_DONE3
#define PWRAP_MT8135_BRIDGE_WACS4_EN
#define PWRAP_MT8135_BRIDGE_INIT_DONE4
#define PWRAP_MT8135_BRIDGE_INT_EN
#define PWRAP_MT8135_BRIDGE_TIMER_EN
#define PWRAP_MT8135_BRIDGE_WDT_UNIT
#define PWRAP_MT8135_BRIDGE_WDT_SRC_EN

/* macro for wrapper status */
#define PWRAP_GET_WACS_RDATA(x)
#define PWRAP_GET_WACS_ARB_FSM(x)
#define PWRAP_GET_WACS_FSM(x)
#define PWRAP_GET_WACS_REQ(x)
#define PWRAP_STATE_SYNC_IDLE0
#define PWRAP_STATE_INIT_DONE0
#define PWRAP_STATE_INIT_DONE0_MT8186
#define PWRAP_STATE_INIT_DONE1

/* macro for WACS FSM */
#define PWRAP_WACS_FSM_IDLE
#define PWRAP_WACS_FSM_REQ
#define PWRAP_WACS_FSM_WFDLE
#define PWRAP_WACS_FSM_WFVLDCLR
#define PWRAP_WACS_INIT_DONE
#define PWRAP_WACS_WACS_SYNC_IDLE
#define PWRAP_WACS_SYNC_BUSY

/* macro for device wrapper default value */
#define PWRAP_DEW_READ_TEST_VAL
#define PWRAP_DEW_COMP_READ_TEST_VAL
#define PWRAP_DEW_WRITE_TEST_VAL

/* macro for manual command */
#define PWRAP_MAN_CMD_SPI_WRITE_NEW
#define PWRAP_MAN_CMD_SPI_WRITE
#define PWRAP_MAN_CMD_OP_CSH
#define PWRAP_MAN_CMD_OP_CSL
#define PWRAP_MAN_CMD_OP_CK
#define PWRAP_MAN_CMD_OP_OUTS
#define PWRAP_MAN_CMD_OP_OUTD
#define PWRAP_MAN_CMD_OP_OUTQ

/* macro for Watch Dog Timer Source */
#define PWRAP_WDT_SRC_EN_STAUPD_TRIG
#define PWRAP_WDT_SRC_EN_HARB_STAUPD_DLE
#define PWRAP_WDT_SRC_EN_HARB_STAUPD_ALE
#define PWRAP_WDT_SRC_MASK_ALL
#define PWRAP_WDT_SRC_MASK_NO_STAUPD

/* Group of bits used for shown slave capability */
#define PWRAP_SLV_CAP_SPI
#define PWRAP_SLV_CAP_DUALIO
#define PWRAP_SLV_CAP_SECURITY
#define HAS_CAP(_c, _x)

/* Group of bits used for shown pwrap capability */
#define PWRAP_CAP_BRIDGE
#define PWRAP_CAP_RESET
#define PWRAP_CAP_DCM
#define PWRAP_CAP_INT1_EN
#define PWRAP_CAP_WDT_SRC1
#define PWRAP_CAP_ARB
#define PWRAP_CAP_ARB_MT8186

/* defines for slave device wrapper registers */
enum dew_regs {};

static const u32 mt6323_regs[] =;

static const u32 mt6331_regs[] =;

static const u32 mt6332_regs[] =;

static const u32 mt6351_regs[] =;

static const u32 mt6357_regs[] =;

static const u32 mt6358_regs[] =;

static const u32 mt6359_regs[] =;

static const u32 mt6397_regs[] =;

enum pwrap_regs {};

static int mt2701_regs[] =;

static int mt6765_regs[] =;

static int mt6779_regs[] =;

static int mt6795_regs[] =;

static int mt6797_regs[] =;

static int mt6873_regs[] =;

static int mt7622_regs[] =;

static int mt8135_regs[] =;

static int mt8173_regs[] =;

static int mt8183_regs[] =;

static int mt8195_regs[] =;

static int mt8365_regs[] =;

static int mt8516_regs[] =;

static int mt8186_regs[] =;

enum pmic_type {};

enum pwrap_type {};

struct pmic_wrapper;

struct pwrap_slv_regops {};

/**
 * struct pwrap_slv_type - PMIC device wrapper definitions
 * @dew_regs:      Device Wrapper (DeW) register offsets
 * @type:          PMIC Type (model)
 * @comp_dew_regs: Device Wrapper (DeW) register offsets for companion device
 * @comp_type:     Companion PMIC Type (model)
 * @regops:        Register R/W ops
 * @caps:          Capability flags for the target device
 */
struct pwrap_slv_type {};

struct pmic_wrapper {};

struct pmic_wrapper_type {};

static u32 pwrap_readl(struct pmic_wrapper *wrp, enum pwrap_regs reg)
{}

static void pwrap_writel(struct pmic_wrapper *wrp, u32 val, enum pwrap_regs reg)
{}

static u32 pwrap_get_fsm_state(struct pmic_wrapper *wrp)
{}

static bool pwrap_is_fsm_idle(struct pmic_wrapper *wrp)
{}

static bool pwrap_is_fsm_vldclr(struct pmic_wrapper *wrp)
{}

/*
 * Timeout issue sometimes caused by the last read command
 * failed because pmic wrap could not got the FSM_VLDCLR
 * in time after finishing WACS2_CMD. It made state machine
 * still on FSM_VLDCLR and timeout next time.
 * Check the status of FSM and clear the vldclr to recovery the
 * error.
 */
static inline void pwrap_leave_fsm_vldclr(struct pmic_wrapper *wrp)
{}

static bool pwrap_is_sync_idle(struct pmic_wrapper *wrp)
{}

static bool pwrap_is_fsm_idle_and_sync_idle(struct pmic_wrapper *wrp)
{}

static int pwrap_read16(struct pmic_wrapper *wrp, u32 adr, u32 *rdata)
{}

static int pwrap_read32(struct pmic_wrapper *wrp, u32 adr, u32 *rdata)
{}

static int pwrap_read(struct pmic_wrapper *wrp, u32 adr, u32 *rdata)
{}

static int pwrap_write16(struct pmic_wrapper *wrp, u32 adr, u32 wdata)
{}

static int pwrap_write32(struct pmic_wrapper *wrp, u32 adr, u32 wdata)
{}

static int pwrap_write(struct pmic_wrapper *wrp, u32 adr, u32 wdata)
{}

static int pwrap_regmap_read(void *context, u32 adr, u32 *rdata)
{}

static int pwrap_regmap_write(void *context, u32 adr, u32 wdata)
{}

static bool pwrap_pmic_read_test(struct pmic_wrapper *wrp, const u32 *dew_regs,
				 u16 read_test_val)
{}

static int pwrap_reset_spislave(struct pmic_wrapper *wrp)
{}

/*
 * pwrap_init_sidly - configure serial input delay
 *
 * This configures the serial input delay. We can configure 0, 2, 4 or 6ns
 * delay. Do a read test with all possible values and chose the best delay.
 */
static int pwrap_init_sidly(struct pmic_wrapper *wrp)
{}

static int pwrap_init_dual_io(struct pmic_wrapper *wrp)
{}

/*
 * pwrap_init_chip_select_ext is used to configure CS extension time for each
 * phase during data transactions on the pwrap bus.
 */
static void pwrap_init_chip_select_ext(struct pmic_wrapper *wrp, u8 hext_write,
				       u8 hext_read, u8 lext_start,
				       u8 lext_end)
{}

static int pwrap_common_init_reg_clock(struct pmic_wrapper *wrp)
{}

static int pwrap_mt2701_init_reg_clock(struct pmic_wrapper *wrp)
{}

static bool pwrap_is_cipher_ready(struct pmic_wrapper *wrp)
{}

static bool __pwrap_is_pmic_cipher_ready(struct pmic_wrapper *wrp, const u32 *dew_regs)
{}


static bool pwrap_is_pmic_cipher_ready(struct pmic_wrapper *wrp)
{}

static void pwrap_config_cipher(struct pmic_wrapper *wrp, const u32 *dew_regs)
{}

static int pwrap_init_cipher(struct pmic_wrapper *wrp)
{}

static int pwrap_init_security(struct pmic_wrapper *wrp)
{}

static int pwrap_mt8135_init_soc_specific(struct pmic_wrapper *wrp)
{}

static int pwrap_mt8173_init_soc_specific(struct pmic_wrapper *wrp)
{}

static int pwrap_mt2701_init_soc_specific(struct pmic_wrapper *wrp)
{}

static int pwrap_mt6795_init_soc_specific(struct pmic_wrapper *wrp)
{}

static int pwrap_mt7622_init_soc_specific(struct pmic_wrapper *wrp)
{}

static int pwrap_mt8183_init_soc_specific(struct pmic_wrapper *wrp)
{}

static int pwrap_init(struct pmic_wrapper *wrp)
{}

static irqreturn_t pwrap_interrupt(int irqno, void *dev_id)
{}

static const struct regmap_config pwrap_regmap_config16 =;

static const struct regmap_config pwrap_regmap_config32 =;

static const struct pwrap_slv_regops pwrap_regops16 =;

static const struct pwrap_slv_regops pwrap_regops32 =;

static const struct pwrap_slv_type pmic_mt6323 =;

static const struct pwrap_slv_type pmic_mt6331 =;

static const struct pwrap_slv_type pmic_mt6351 =;

static const struct pwrap_slv_type pmic_mt6357 =;

static const struct pwrap_slv_type pmic_mt6358 =;

static const struct pwrap_slv_type pmic_mt6359 =;

static const struct pwrap_slv_type pmic_mt6380 =;

static const struct pwrap_slv_type pmic_mt6397 =;

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

static const struct pmic_wrapper_type pwrap_mt2701 =;

static const struct pmic_wrapper_type pwrap_mt6765 =;

static const struct pmic_wrapper_type pwrap_mt6779 =;

static const struct pmic_wrapper_type pwrap_mt6795 =;

static const struct pmic_wrapper_type pwrap_mt6797 =;

static const struct pmic_wrapper_type pwrap_mt6873 =;

static const struct pmic_wrapper_type pwrap_mt7622 =;

static const struct pmic_wrapper_type pwrap_mt8135 =;

static const struct pmic_wrapper_type pwrap_mt8173 =;

static const struct pmic_wrapper_type pwrap_mt8183 =;

static struct pmic_wrapper_type pwrap_mt8195 =;

static const struct pmic_wrapper_type pwrap_mt8365 =;

static struct pmic_wrapper_type pwrap_mt8516 =;

static struct pmic_wrapper_type pwrap_mt8186 =;

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

static int pwrap_probe(struct platform_device *pdev)
{}

static struct platform_driver pwrap_drv =;

module_platform_driver();

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