1 /* 2 * Copyright (C) 2018 Marvell International Ltd. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 * https://spdx.org/licenses 6 */ 7 8 #ifndef ARMADA_COMMON_H 9 #define ARMADA_COMMON_H 10 11 #include <drivers/marvell/amb_adec.h> 12 #include <drivers/marvell/ccu.h> 13 #include <drivers/marvell/io_win.h> 14 #include <drivers/marvell/iob.h> 15 16 /* 17 * This struct supports skip image request 18 * detection_method: the method used to detect the request "signal". 19 * info: 20 * GPIO: 21 * detection_method: HIGH (pressed button), LOW (unpressed button), 22 * num (button mpp number). 23 * i2c: 24 * i2c_addr: the address of the i2c chosen. 25 * i2d_reg: the i2c register chosen. 26 * test: 27 * choose the DIE you picked the button in (AP or CP). 28 * in case of CP(cp_index = 0 if CP0, cp_index = 1 if CP1) 29 */ 30 struct skip_image { 31 enum { 32 GPIO, 33 I2C, 34 USER_DEFINED 35 } detection_method; 36 37 struct { 38 struct { 39 int num; 40 enum { 41 HIGH, 42 LOW 43 } button_state; 44 45 } gpio; 46 47 struct { 48 int i2c_addr; 49 int i2c_reg; 50 } i2c; 51 52 struct { 53 enum { 54 CP, 55 AP 56 } cp_ap; 57 int cp_index; 58 } test; 59 } info; 60 }; 61 62 /* 63 * This struct supports SoC power off method 64 * type: the method used to power off the SoC 65 * cfg: 66 * PMIC_GPIO: 67 * pin_count: current GPIO pin number used for toggling the signal for 68 * notifying external PMIC 69 * info: holds the GPIOs information, CP GPIO should be used and 70 * all GPIOs should be within same GPIO config. register 71 * step_count: current step number to toggle the GPIO for PMIC 72 * seq: GPIO toggling values in sequence, each bit represents a GPIO. 73 * For example, bit0 represents first GPIO used for toggling 74 * the GPIO the last step is used to trigger the power off 75 * signal 76 * delay_ms: transition interval for the GPIO setting to take effect 77 * in unit of ms 78 */ 79 /* Max GPIO number used to notify PMIC to power off the SoC */ 80 #define PMIC_GPIO_MAX_NUMBER 8 81 /* Max GPIO toggling steps in sequence to power off the SoC */ 82 #define PMIC_GPIO_MAX_TOGGLE_STEP 8 83 84 enum gpio_output_state { 85 GPIO_LOW = 0, 86 GPIO_HIGH 87 }; 88 89 typedef struct gpio_info { 90 int cp_index; 91 int gpio_index; 92 } gpio_info_t; 93 94 struct power_off_method { 95 enum { 96 PMIC_GPIO, 97 } type; 98 99 struct { 100 struct { 101 int pin_count; 102 struct gpio_info info[PMIC_GPIO_MAX_NUMBER]; 103 int step_count; 104 uint32_t seq[PMIC_GPIO_MAX_TOGGLE_STEP]; 105 int delay_ms; 106 } gpio; 107 } cfg; 108 }; 109 110 int marvell_gpio_config(void); 111 uint32_t marvell_get_io_win_gcr_target(int ap_idx); 112 uint32_t marvell_get_ccu_gcr_target(int ap_idx); 113 114 115 /* 116 * The functions below are defined as Weak and may be overridden 117 * in specific Marvell standard platform 118 */ 119 int marvell_get_amb_memory_map(struct addr_map_win **win, 120 uint32_t *size, uintptr_t base); 121 int marvell_get_io_win_memory_map(int ap_idx, struct addr_map_win **win, 122 uint32_t *size); 123 int marvell_get_iob_memory_map(struct addr_map_win **win, 124 uint32_t *size, uintptr_t base); 125 int marvell_get_ccu_memory_map(int ap_idx, struct addr_map_win **win, 126 uint32_t *size); 127 int system_power_off(void); 128 129 #endif /* ARMADA_COMMON_H */ 130