blob: 7562989d9982180998750d0cc81e462d4f532db3 [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 *
5 * Copyright (C) 2012-2021 Cadence Design Systems, Inc.
6 * Copyright (C) 2018-2021 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
14#include <lpddr4_16bit_if.h>
15#else
16#include <lpddr4_32bit_if.h>
17#endif
Kevin Scholz521a4ef2019-10-07 19:26:36 +053018
Kevin Scholz521a4ef2019-10-07 19:26:36 +053019typedef struct lpddr4_config_s lpddr4_config;
20typedef struct lpddr4_privatedata_s lpddr4_privatedata;
21typedef struct lpddr4_debuginfo_s lpddr4_debuginfo;
22typedef struct lpddr4_fspmoderegs_s lpddr4_fspmoderegs;
Kevin Scholz521a4ef2019-10-07 19:26:36 +053023
Dave Gerlachd712b362021-05-11 10:22:11 -050024typedef enum {
25 LPDDR4_CTL_REGS = 0U,
26 LPDDR4_PHY_REGS = 1U,
27 LPDDR4_PHY_INDEP_REGS = 2U
Kevin Scholz521a4ef2019-10-07 19:26:36 +053028} lpddr4_regblock;
29
Dave Gerlachd712b362021-05-11 10:22:11 -050030typedef enum {
31 LPDDR4_DRV_NONE = 0U,
32 LPDDR4_DRV_SOC_PLL_UPDATE = 1U
Kevin Scholz521a4ef2019-10-07 19:26:36 +053033} lpddr4_infotype;
34
Dave Gerlachd712b362021-05-11 10:22:11 -050035typedef enum {
36 LPDDR4_LPI_PD_WAKEUP_FN = 0U,
37 LPDDR4_LPI_SR_SHORT_WAKEUP_FN = 1U,
38 LPDDR4_LPI_SR_LONG_WAKEUP_FN = 2U,
39 LPDDR4_LPI_SR_LONG_MCCLK_GATE_WAKEUP_FN = 3U,
40 LPDDR4_LPI_SRPD_SHORT_WAKEUP_FN = 4U,
41 LPDDR4_LPI_SRPD_LONG_WAKEUP_FN = 5U,
42 LPDDR4_LPI_SRPD_LONG_MCCLK_GATE_WAKEUP_FN = 6U
Kevin Scholz521a4ef2019-10-07 19:26:36 +053043} lpddr4_lpiwakeupparam;
44
Dave Gerlachd712b362021-05-11 10:22:11 -050045typedef enum {
46 LPDDR4_REDUC_ON = 0U,
47 LPDDR4_REDUC_OFF = 1U
Kevin Scholz521a4ef2019-10-07 19:26:36 +053048} lpddr4_reducmode;
49
Dave Gerlachd712b362021-05-11 10:22:11 -050050typedef enum {
51 LPDDR4_ECC_DISABLED = 0U,
52 LPDDR4_ECC_ENABLED = 1U,
53 LPDDR4_ECC_ERR_DETECT = 2U,
54 LPDDR4_ECC_ERR_DETECT_CORRECT = 3U
Kevin Scholz521a4ef2019-10-07 19:26:36 +053055} lpddr4_eccenable;
56
Dave Gerlachd712b362021-05-11 10:22:11 -050057typedef enum {
58 LPDDR4_DBI_RD_ON = 0U,
59 LPDDR4_DBI_RD_OFF = 1U,
60 LPDDR4_DBI_WR_ON = 2U,
61 LPDDR4_DBI_WR_OFF = 3U
Kevin Scholz521a4ef2019-10-07 19:26:36 +053062} lpddr4_dbimode;
63
Dave Gerlachd712b362021-05-11 10:22:11 -050064typedef enum {
65 LPDDR4_FSP_0 = 0U,
66 LPDDR4_FSP_1 = 1U,
67 LPDDR4_FSP_2 = 2U
Kevin Scholz521a4ef2019-10-07 19:26:36 +053068} lpddr4_ctlfspnum;
69
Dave Gerlachd712b362021-05-11 10:22:11 -050070typedef void (*lpddr4_infocallback)(const lpddr4_privatedata *pd, lpddr4_infotype infotype);
Kevin Scholz521a4ef2019-10-07 19:26:36 +053071
Dave Gerlachd712b362021-05-11 10:22:11 -050072typedef void (*lpddr4_ctlcallback)(const lpddr4_privatedata *pd, lpddr4_intr_ctlinterrupt ctlinterrupt, u8 chipselect);
Kevin Scholz521a4ef2019-10-07 19:26:36 +053073
Dave Gerlachd712b362021-05-11 10:22:11 -050074typedef void (*lpddr4_phyindepcallback)(const lpddr4_privatedata *pd, lpddr4_intr_phyindepinterrupt phyindepinterrupt, u8 chipselect);
Kevin Scholz521a4ef2019-10-07 19:26:36 +053075
Dave Gerlachd712b362021-05-11 10:22:11 -050076u32 lpddr4_probe(const lpddr4_config *config, u16 *configsize);
Kevin Scholz521a4ef2019-10-07 19:26:36 +053077
Dave Gerlachd712b362021-05-11 10:22:11 -050078u32 lpddr4_init(lpddr4_privatedata *pd, const lpddr4_config *cfg);
Kevin Scholz521a4ef2019-10-07 19:26:36 +053079
Dave Gerlachd712b362021-05-11 10:22:11 -050080u32 lpddr4_start(const lpddr4_privatedata *pd);
Kevin Scholz521a4ef2019-10-07 19:26:36 +053081
Dave Gerlachd712b362021-05-11 10:22:11 -050082u32 lpddr4_readreg(const lpddr4_privatedata *pd, lpddr4_regblock cpp, u32 regoffset, u32 *regvalue);
Kevin Scholz521a4ef2019-10-07 19:26:36 +053083
Dave Gerlachd712b362021-05-11 10:22:11 -050084u32 lpddr4_writereg(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_getmmrregister(const lpddr4_privatedata *pd, u32 readmoderegval, u64 *mmrvalue, u8 *mmrstatus);
Kevin Scholz521a4ef2019-10-07 19:26:36 +053087
Dave Gerlachd712b362021-05-11 10:22:11 -050088u32 lpddr4_setmmrregister(const lpddr4_privatedata *pd, u32 writemoderegval, u8 *mrwstatus);
Kevin Scholz521a4ef2019-10-07 19:26:36 +053089
Dave Gerlachd712b362021-05-11 10:22:11 -050090u32 lpddr4_writectlconfig(const lpddr4_privatedata *pd, u32 regvalues[], u16 regnum[], u16 regcount);
Kevin Scholz521a4ef2019-10-07 19:26:36 +053091
Dave Gerlachd712b362021-05-11 10:22:11 -050092u32 lpddr4_writephyconfig(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_writephyindepconfig(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_readctlconfig(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_readphyconfig(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_readphyindepconfig(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_getctlinterruptmask(const lpddr4_privatedata *pd, u64 *mask);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530103
Dave Gerlachd712b362021-05-11 10:22:11 -0500104u32 lpddr4_setctlinterruptmask(const lpddr4_privatedata *pd, const u64 *mask);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530105
Dave Gerlachd712b362021-05-11 10:22:11 -0500106u32 lpddr4_checkctlinterrupt(const lpddr4_privatedata *pd, lpddr4_intr_ctlinterrupt intr, bool *irqstatus);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530107
Dave Gerlachd712b362021-05-11 10:22:11 -0500108u32 lpddr4_ackctlinterrupt(const lpddr4_privatedata *pd, lpddr4_intr_ctlinterrupt intr);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530109
Dave Gerlachd712b362021-05-11 10:22:11 -0500110u32 lpddr4_getphyindepinterruptmask(const lpddr4_privatedata *pd, u32 *mask);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530111
Dave Gerlachd712b362021-05-11 10:22:11 -0500112u32 lpddr4_setphyindepinterruptmask(const lpddr4_privatedata *pd, const u32 *mask);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530113
Dave Gerlachd712b362021-05-11 10:22:11 -0500114u32 lpddr4_checkphyindepinterrupt(const lpddr4_privatedata *pd, lpddr4_intr_phyindepinterrupt intr, bool *irqstatus);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530115
Dave Gerlachd712b362021-05-11 10:22:11 -0500116u32 lpddr4_ackphyindepinterrupt(const lpddr4_privatedata *pd, lpddr4_intr_phyindepinterrupt intr);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530117
Dave Gerlachd712b362021-05-11 10:22:11 -0500118u32 lpddr4_getdebuginitinfo(const lpddr4_privatedata *pd, lpddr4_debuginfo *debuginfo);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530119
Dave Gerlachd712b362021-05-11 10:22:11 -0500120u32 lpddr4_getlpiwakeuptime(const lpddr4_privatedata *pd, const lpddr4_lpiwakeupparam *lpiwakeupparam, const lpddr4_ctlfspnum *fspnum, u32 *cycles);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530121
Dave Gerlachd712b362021-05-11 10:22:11 -0500122u32 lpddr4_setlpiwakeuptime(const lpddr4_privatedata *pd, const lpddr4_lpiwakeupparam *lpiwakeupparam, const lpddr4_ctlfspnum *fspnum, const u32 *cycles);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530123
Dave Gerlachd712b362021-05-11 10:22:11 -0500124u32 lpddr4_geteccenable(const lpddr4_privatedata *pd, lpddr4_eccenable *eccparam);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530125
Dave Gerlachd712b362021-05-11 10:22:11 -0500126u32 lpddr4_seteccenable(const lpddr4_privatedata *pd, const lpddr4_eccenable *eccparam);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530127
Dave Gerlachd712b362021-05-11 10:22:11 -0500128u32 lpddr4_getreducmode(const lpddr4_privatedata *pd, lpddr4_reducmode *mode);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530129
Dave Gerlachd712b362021-05-11 10:22:11 -0500130u32 lpddr4_setreducmode(const lpddr4_privatedata *pd, const lpddr4_reducmode *mode);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530131
Dave Gerlachd712b362021-05-11 10:22:11 -0500132u32 lpddr4_getdbireadmode(const lpddr4_privatedata *pd, bool *on_off);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530133
Dave Gerlachd712b362021-05-11 10:22:11 -0500134u32 lpddr4_getdbiwritemode(const lpddr4_privatedata *pd, bool *on_off);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530135
Dave Gerlachd712b362021-05-11 10:22:11 -0500136u32 lpddr4_setdbimode(const lpddr4_privatedata *pd, const lpddr4_dbimode *mode);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530137
Dave Gerlachd712b362021-05-11 10:22:11 -0500138u32 lpddr4_getrefreshrate(const lpddr4_privatedata *pd, const lpddr4_ctlfspnum *fspnum, u32 *tref, u32 *tras_max);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530139
Dave Gerlachd712b362021-05-11 10:22:11 -0500140u32 lpddr4_setrefreshrate(const lpddr4_privatedata *pd, const lpddr4_ctlfspnum *fspnum, const u32 *tref, const u32 *tras_max);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530141
Dave Gerlachd712b362021-05-11 10:22:11 -0500142u32 lpddr4_refreshperchipselect(const lpddr4_privatedata *pd, const u32 trefinterval);
Kevin Scholz521a4ef2019-10-07 19:26:36 +0530143
144#endif /* LPDDR4_IF_H */