aboutsummaryrefslogtreecommitdiff
path: root/drivers/misc/mnh/mnh-ddr.h
blob: 372ca55d0505b5deabb5e3311ad180dc6d10460c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
*
* MNH DDR Driver
* Copyright (c) 2016-2017, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
* more details.
*
*/
#ifndef __MNH_DDR_H__
#define __MNH_DDR_H__

#include <linux/types.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/gpio/consumer.h>
#include <linux/platform_device.h>

#define MNH_DDR_NUM_CTL_REG	(558 + 1)
#define MNH_DDR_NUM_PHY_REG	(1100 + 1)
#define MNH_DDR_NUM_PI_REG	(191 + 1)

#define MNH_DDR_NUM_FSPS (4)
#define MNH_DDR_NUM_BASES (3)

/* arbitrary but sufficient size for phy deltas */
#define MNH_DDR_PHY_SET_SIZE 32
/* need reg index for setA/B */
#define MNH_DDR_PHY_SET_ELEMS 2
struct mnh_ddr_reg_config {
	u32 fsps[MNH_DDR_NUM_FSPS];
	u32 ctl[MNH_DDR_NUM_CTL_REG];
	u32 pi[MNH_DDR_NUM_PI_REG];
	u32 phy[MNH_DDR_NUM_PHY_REG];
	u32 phy_setA[MNH_DDR_PHY_SET_SIZE][MNH_DDR_PHY_SET_ELEMS];
	u32 phy_setB[MNH_DDR_PHY_SET_SIZE][MNH_DDR_PHY_SET_ELEMS];
};

struct mnh_ddr_internal_state {
	u32 ctl_base;
	u32 ctl[MNH_DDR_NUM_CTL_REG];
	u32 pi_base;
	u32 pi[MNH_DDR_NUM_PI_REG];
	u32 phy_base;
	u32 phy[MNH_DDR_NUM_FSPS][MNH_DDR_NUM_PHY_REG];
	u32 fsps[MNH_DDR_NUM_FSPS];
	u32 suspend_fsp;
	u32 tref[MNH_DDR_NUM_FSPS];
};

enum mnh_ddr_bist_type {
	MOVI1_3N = 0,
	LIMITED_MOVI1_3N,
};

struct mnh_ddr_data {
	struct platform_device *pdev;
	struct mnh_ddr_internal_state _state;
};

int mnh_ddr_platform_init(struct platform_device *pdev,
			  struct mnh_ddr_data *data);
int mnh_ddr_po_init(struct mnh_ddr_data *data, struct gpio_desc *iso_n);
int mnh_ddr_resume(struct mnh_ddr_data *data, struct gpio_desc *iso_n);
int mnh_ddr_suspend(struct mnh_ddr_data *data, struct gpio_desc *iso_n);
int mnh_ddr_clr_int_status(struct device *dev);
u64 mnh_ddr_int_status(struct device *dev);
u32 mnh_ddr_mbist(struct mnh_ddr_data *data, enum mnh_ddr_bist_type bist_type);

#endif /* __MNH_DDR_H__ */