armada_common.h 2.92 KB
Newer Older
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
 * Copyright (C) 2018 Marvell International Ltd.
 *
 * SPDX-License-Identifier:     BSD-3-Clause
 * https://spdx.org/licenses
 */

#ifndef __A8K_COMMON_H__
#define __A8K_COMMON_H__

#include <amb_adec.h>
#include <io_win.h>
#include <iob.h>
#include <ccu.h>

/*
 * This struct supports skip image request
 * detection_method: the method used to detect the request "signal".
 * info:
 *	GPIO:
 *		detection_method: HIGH (pressed button), LOW (unpressed button),
 *		num (button mpp number).
 *	i2c:
 *		i2c_addr: the address of the i2c chosen.
 *		i2d_reg: the i2c register chosen.
 *	test:
 *		choose the DIE you picked the button in (AP or CP).
 *		in case of CP(cp_index = 0 if CP0, cp_index = 1 if CP1)
 */
struct skip_image {
	enum {
		GPIO,
		I2C,
		USER_DEFINED
	} detection_method;

	struct {
		struct {
			int num;
			enum {
				HIGH,
				LOW
			} button_state;

		} gpio;

		struct {
			int i2c_addr;
			int i2c_reg;
		} i2c;

		struct {
			enum {
				CP,
				AP
			} cp_ap;
			int cp_index;
		} test;
	} info;
};

/*
 * This struct supports SoC power off method
 * type: the method used to power off the SoC
 * cfg:
 *	PMIC_GPIO:
 *	pin_count: current GPIO pin number used for toggling the signal for
 *		   notifying external PMIC
 *	info:	   holds the GPIOs information, CP GPIO should be used and
 *		   all GPIOs should be within same GPIO config. register
 *	step_count: current step number to toggle the GPIO for PMIC
 *	seq:       GPIO toggling values in sequence, each bit represents a GPIO.
 *		   For example, bit0 represents first GPIO used for toggling
 *		   the GPIO the last step is used to trigger the power off
 *		   signal
 *	delay_ms:  transition interval for the GPIO setting to take effect
 *		   in unit of ms
 */
/* Max GPIO number used to notify PMIC to power off the SoC */
#define PMIC_GPIO_MAX_NUMBER		8
/* Max GPIO toggling steps in sequence to power off the SoC */
#define PMIC_GPIO_MAX_TOGGLE_STEP	8

enum gpio_output_state {
	GPIO_LOW = 0,
	GPIO_HIGH
};

typedef struct gpio_info {
	int cp_index;
	int gpio_index;
} gpio_info_t;

struct power_off_method {
	enum {
		PMIC_GPIO,
	} type;

	struct {
		struct {
			int pin_count;
			struct gpio_info info[PMIC_GPIO_MAX_NUMBER];
			int step_count;
			uint32_t seq[PMIC_GPIO_MAX_TOGGLE_STEP];
			int delay_ms;
		} gpio;
	} cfg;
};

int marvell_gpio_config(void);
uint32_t marvell_get_io_win_gcr_target(int ap_idx);
uint32_t marvell_get_ccu_gcr_target(int ap_idx);


/*
 * The functions below are defined as Weak and may be overridden
 * in specific Marvell standard platform
 */
int marvell_get_amb_memory_map(struct addr_map_win **win,
			       uint32_t *size, uintptr_t base);
int marvell_get_io_win_memory_map(int ap_idx, struct addr_map_win **win,
				  uint32_t *size);
int marvell_get_iob_memory_map(struct addr_map_win **win,
			       uint32_t *size, uintptr_t base);
int marvell_get_ccu_memory_map(int ap_idx, struct addr_map_win **win,
			       uint32_t *size);

#endif /* __A8K_COMMON_H__ */