blob: 1d8bcf7d38b18564ee5bfab4a9244123b74bd9e3 [file] [log] [blame]
Kevin Scholz521a4ef2019-10-07 19:26:36 +05301/* SPDX-License-Identifier: BSD-3-Clause */
Dave Gerlachd712b362021-05-11 10:22:11 -05002/*
3 * Cadence DDR Driver
4 *
Bryan Brattlof85b5cc82022-10-24 16:53:28 -05005 * Copyright (C) 2012-2022 Cadence Design Systems, Inc.
6 * Copyright (C) 2018-2022 Texas Instruments Incorporated - https://www.ti.com/
Kevin Scholz521a4ef2019-10-07 19:26:36 +05307 */
8
9#ifndef LPDDR4_IF_H
10#define LPDDR4_IF_H
11
12#include <linux/types.h>
Dave Gerlachd712b362021-05-11 10:22:11 -050013#ifdef CONFIG_K3_AM64_DDRSS
Bryan Brattlof85b5cc82022-10-24 16:53:28 -050014#include <lpddr4_am64_if.h>
15#elif CONFIG_K3_AM62A_DDRSS
16#include <lpddr4_am62a_if.h>
Dave Gerlachd712b362021-05-11 10:22:11 -050017#else
Bryan Brattlof85b5cc82022-10-24 16:53:28 -050018#include <lpddr4_j721e_if.h>
Dave Gerlachd712b362021-05-11 10:22:11 -050019#endif
Kevin Scholz521a4ef2019-10-07 19:26:36 +053020
Kevin Scholz521a4ef2019-10-07 19:26:36 +053021typedef struct lpddr4_config_s lpddr4_config;
22typedef struct lpddr4_privatedata_s lpddr4_privatedata;
23typedef struct lpddr4_debuginfo_s lpddr4_debuginfo;
24typedef struct lpddr4_fspmoderegs_s lpddr4_fspmoderegs;
Kevin Scholz521a4ef2019-10-07 19:26:36 +053025
Dave Gerlachd712b362021-05-11 10:22:11 -050026typedef enum {
27 LPDDR4_CTL_REGS = 0U,
28 LPDDR4_PHY_REGS = 1U,
29 LPDDR4_PHY_INDEP_REGS = 2U
Kevin Scholz521a4ef2019-10-07 19:26:36 +053030} lpddr4_regblock;
31
Dave Gerlachd712b362021-05-11 10:22:11 -050032typedef enum {
33 LPDDR4_DRV_NONE = 0U,
34 LPDDR4_DRV_SOC_PLL_UPDATE = 1U
Kevin Scholz521a4ef2019-10-07 19:26:36 +053035} lpddr4_infotype;
36
Dave Gerlachd712b362021-05-11 10:22:11 -050037typedef enum {
38 LPDDR4_LPI_PD_WAKEUP_FN = 0U,
39 LPDDR4_LPI_SR_SHORT_WAKEUP_FN = 1U,
40 LPDDR4_LPI_SR_LONG_WAKEUP_FN = 2U,
41 LPDDR4_LPI_SR_LONG_MCCLK_GATE_WAKEUP_FN = 3U,
42 LPDDR4_LPI_SRPD_SHORT_WAKEUP_FN = 4U,
43 LPDDR4_LPI_SRPD_LONG_WAKEUP_FN = 5U,
44 LPDDR4_LPI_SRPD_LONG_MCCLK_GATE_WAKEUP_FN = 6U
Kevin Scholz521a4ef2019-10-07 19:26:36 +053045} lpddr4_lpiwakeupparam;
46
Dave Gerlachd712b362021-05-11 10:22:11 -050047typedef enum {
48 LPDDR4_REDUC_ON = 0U,
49 LPDDR4_REDUC_OFF = 1U
Kevin Scholz521a4ef2019-10-07 19:26:36 +053050} lpddr4_reducmode;
51
Dave Gerlachd712b362021-05-11 10:22:11 -050052typedef enum {
53 LPDDR4_ECC_DISABLED = 0U,
54 LPDDR4_ECC_ENABLED = 1U,
55 LPDDR4_ECC_ERR_DETECT = 2U,
56 LPDDR4_ECC_ERR_DETECT_CORRECT = 3U
Kevin Scholz521a4ef2019-10-07 19:26:36 +053057} lpddr4_eccenable;
58
Dave Gerlachd712b362021-05-11 10:22:11 -050059typedef enum {
60 LPDDR4_DBI_RD_ON = 0U,
61 LPDDR4_DBI_RD_OFF = 1U,
62 LPDDR4_DBI_WR_ON = 2U,
63 LPDDR4_DBI_WR_OFF = 3U
Kevin Scholz521a4ef2019-10-07 19:26:36 +053064} lpddr4_dbimode;
65
Dave Gerlachd712b362021-05-11 10:22:11 -050066typedef enum {
67 LPDDR4_FSP_0 = 0U,
68 LPDDR4_FSP_1 = 1U,
69 LPDDR4_FSP_2 = 2U
Kevin Scholz521a4ef2019-10-07 19:26:36 +053070} lpddr4_ctlfspnum;
71
Dave Gerlachd712b362021-05-11 10:22:11 -050072typedef void (*lpddr4_infocallback)(const lpddr4_privatedata *pd, lpddr4_infotype infotype);
Kevin Scholz521a4ef2019-10-07 19:26:36 +053073
Dave Gerlachd712b362021-05-11 10:22:11 -050074typedef void (*lpddr4_ctlcallback)(const lpddr4_privatedata *pd, lpddr4_intr_ctlinterrupt ctlinterrupt, u8 chipselect);
Kevin Scholz521a4ef2019-10-07 19:26:36 +053075
Dave Gerlachd712b362021-05-11 10:22:11 -050076typedef void (*lpddr4_phyindepcallback)(const lpddr4_privatedata *pd, lpddr4_intr_phyindepinterrupt phyindepinterrupt, u8 chipselect);
Kevin Scholz521a4ef2019-10-07 19:26:36 +053077
Dave Gerlachd712b362021-05-11 10:22:11 -050078u32 lpddr4_probe(const lpddr4_config *config, u16 *configsize);
Kevin Scholz521a4ef2019-10-07 19:26:36 +053079
Dave Gerlachd712b362021-05-11 10:22:11 -050080u32 lpddr4_init(lpddr4_privatedata *pd, const lpddr4_config *cfg);
Kevin Scholz521a4ef2019-10-07 19:26:36 +053081
Dave Gerlachd712b362021-05-11 10:22:11 -050082u32 lpddr4_start(const lpddr4_privatedata *pd);
Kevin Scholz521a4ef2019-10-07 19:26:36 +053083
Dave Gerlachd712b362021-05-11 10:22:11 -050084u32 lpddr4_readreg(const lpddr4_privatedata *pd, lpddr4_regblock cpp, u32 regoffset, u32 *regvalue);
Kevin Scholz521a4ef2019-10-07 19:26:36 +053085
Dave Gerlachd712b362021-05-11 10:22:11 -050086u32 lpddr4_writereg(const lpddr4_privatedata *pd, lpddr4_regblock cpp, u32 regoffset, u32 regvalue);
Kevin Scholz521a4ef2019-10-07 19:26:36 +053087
Dave Gerlachd712b362021-05-11 10:22:11 -050088u32 lpddr4_getmmrregister(const lpddr4_privatedata *pd, u32 readmoderegval, u64 *mmrvalue, u8 *mmrstatus);
Kevin Scholz521a4ef2019-10-07 19:26:36 +053089
Dave Gerlachd712b362021-05-11 10:22:11 -050090u32 lpddr4_setmmrregister(const lpddr4_privatedata *pd, u32 writemoderegval, u8 *mrwstatus);
Kevin Scholz521a4ef2019-10-07 19:26:36 +053091
Dave Gerlachd712b362021-05-11 10:22:11 -050092u32 lpddr4_writectlconfig(const lpddr4_privatedata *pd, u32 regvalues[], u16 regnum[], u16 regcount);
Kevin Scholz521a4ef2019-10-07 19:26:36 +053093
Dave Gerlachd712b362021-05-11 10:22:11 -050094u32 lpddr4_writephyconfig(const lpddr4_privatedata *pd, u32 regvalues[], u16 regnum[], u16 regcount);
Kevin Scholz521a4ef2019-10-07 19:26:36 +053095
Dave Gerlachd712b362021-05-11 10:22:11 -050096u32 lpddr4_writephyindepconfig(const lpddr4_privatedata *pd, u32 regvalues[], u16 regnum[], u16 regcount);
Kevin Scholz521a4ef2019-10-07 19:26:36 +053097
Dave Gerlachd712b362021-05-11 10:22:11 -050098u32 lpddr4_readctlconfig(const lpddr4_privatedata *pd, u32 regvalues[], u16 regnum[], u16 regcount);
Kevin Scholz521a4ef2019-10-07 19:26:36 +053099
Dave Gerlachd712b362021-05-11 10:22:11 -0500100u32 lpddr4_readphyconfig(const lpddr4_privatedata *pd, u32 regvalues[], u16 regnum[], u16 regcount);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530101
Dave Gerlachd712b362021-05-11 10:22:11 -0500102u32 lpddr4_readphyindepconfig(const lpddr4_privatedata *pd, u32 regvalues[], u16 regnum[], u16 regcount);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530103
Dave Gerlachd712b362021-05-11 10:22:11 -0500104u32 lpddr4_getctlinterruptmask(const lpddr4_privatedata *pd, u64 *mask);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530105
Dave Gerlachd712b362021-05-11 10:22:11 -0500106u32 lpddr4_setctlinterruptmask(const lpddr4_privatedata *pd, const u64 *mask);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530107
Dave Gerlachd712b362021-05-11 10:22:11 -0500108u32 lpddr4_checkctlinterrupt(const lpddr4_privatedata *pd, lpddr4_intr_ctlinterrupt intr, bool *irqstatus);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530109
Dave Gerlachd712b362021-05-11 10:22:11 -0500110u32 lpddr4_ackctlinterrupt(const lpddr4_privatedata *pd, lpddr4_intr_ctlinterrupt intr);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530111
Dave Gerlachd712b362021-05-11 10:22:11 -0500112u32 lpddr4_getphyindepinterruptmask(const lpddr4_privatedata *pd, u32 *mask);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530113
Dave Gerlachd712b362021-05-11 10:22:11 -0500114u32 lpddr4_setphyindepinterruptmask(const lpddr4_privatedata *pd, const u32 *mask);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530115
Dave Gerlachd712b362021-05-11 10:22:11 -0500116u32 lpddr4_checkphyindepinterrupt(const lpddr4_privatedata *pd, lpddr4_intr_phyindepinterrupt intr, bool *irqstatus);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530117
Dave Gerlachd712b362021-05-11 10:22:11 -0500118u32 lpddr4_ackphyindepinterrupt(const lpddr4_privatedata *pd, lpddr4_intr_phyindepinterrupt intr);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530119
Dave Gerlachd712b362021-05-11 10:22:11 -0500120u32 lpddr4_getdebuginitinfo(const lpddr4_privatedata *pd, lpddr4_debuginfo *debuginfo);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530121
Dave Gerlachd712b362021-05-11 10:22:11 -0500122u32 lpddr4_getlpiwakeuptime(const lpddr4_privatedata *pd, const lpddr4_lpiwakeupparam *lpiwakeupparam, const lpddr4_ctlfspnum *fspnum, u32 *cycles);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530123
Dave Gerlachd712b362021-05-11 10:22:11 -0500124u32 lpddr4_setlpiwakeuptime(const lpddr4_privatedata *pd, const lpddr4_lpiwakeupparam *lpiwakeupparam, const lpddr4_ctlfspnum *fspnum, const u32 *cycles);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530125
Dave Gerlachd712b362021-05-11 10:22:11 -0500126u32 lpddr4_geteccenable(const lpddr4_privatedata *pd, lpddr4_eccenable *eccparam);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530127
Dave Gerlachd712b362021-05-11 10:22:11 -0500128u32 lpddr4_seteccenable(const lpddr4_privatedata *pd, const lpddr4_eccenable *eccparam);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530129
Dave Gerlachd712b362021-05-11 10:22:11 -0500130u32 lpddr4_getreducmode(const lpddr4_privatedata *pd, lpddr4_reducmode *mode);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530131
Dave Gerlachd712b362021-05-11 10:22:11 -0500132u32 lpddr4_setreducmode(const lpddr4_privatedata *pd, const lpddr4_reducmode *mode);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530133
Dave Gerlachd712b362021-05-11 10:22:11 -0500134u32 lpddr4_getdbireadmode(const lpddr4_privatedata *pd, bool *on_off);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530135
Dave Gerlachd712b362021-05-11 10:22:11 -0500136u32 lpddr4_getdbiwritemode(const lpddr4_privatedata *pd, bool *on_off);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530137
Dave Gerlachd712b362021-05-11 10:22:11 -0500138u32 lpddr4_setdbimode(const lpddr4_privatedata *pd, const lpddr4_dbimode *mode);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530139
Dave Gerlachd712b362021-05-11 10:22:11 -0500140u32 lpddr4_getrefreshrate(const lpddr4_privatedata *pd, const lpddr4_ctlfspnum *fspnum, u32 *tref, u32 *tras_max);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530141
Dave Gerlachd712b362021-05-11 10:22:11 -0500142u32 lpddr4_setrefreshrate(const lpddr4_privatedata *pd, const lpddr4_ctlfspnum *fspnum, const u32 *tref, const u32 *tras_max);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530143
Dave Gerlachd712b362021-05-11 10:22:11 -0500144u32 lpddr4_refreshperchipselect(const lpddr4_privatedata *pd, const u32 trefinterval);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530145
Bryan Brattlof85b5cc82022-10-24 16:53:28 -0500146u32 lpddr4_deferredregverify(const lpddr4_privatedata *pd, lpddr4_regblock cpp, u32 regvalues[], u16 regnum[], u16 regcount);
147
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530148#endif /* LPDDR4_IF_H */