Yann Gautier | caf575b | 2018-07-24 17:18:19 +0200 | [diff] [blame] | 1 | /* |
Patrick Delaunay | a0f6ff7 | 2021-04-30 17:31:52 +0200 | [diff] [blame] | 2 | * Copyright (C) 2018-2022, STMicroelectronics - All Rights Reserved |
Yann Gautier | caf575b | 2018-07-24 17:18:19 +0200 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause |
| 5 | */ |
| 6 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 7 | #ifndef STM32MP1_DDR_H |
| 8 | #define STM32MP1_DDR_H |
Yann Gautier | caf575b | 2018-07-24 17:18:19 +0200 | [diff] [blame] | 9 | |
| 10 | #include <stdbool.h> |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 11 | #include <stdint.h> |
Yann Gautier | caf575b | 2018-07-24 17:18:19 +0200 | [diff] [blame] | 12 | |
Nicolas Le Bayon | 8ce825f | 2021-05-18 10:01:30 +0200 | [diff] [blame] | 13 | #include <drivers/st/stm32mp_ddr.h> |
Yann Gautier | caf575b | 2018-07-24 17:18:19 +0200 | [diff] [blame] | 14 | |
| 15 | struct stm32mp1_ddrctrl_reg { |
| 16 | uint32_t mstr; |
| 17 | uint32_t mrctrl0; |
| 18 | uint32_t mrctrl1; |
| 19 | uint32_t derateen; |
| 20 | uint32_t derateint; |
| 21 | uint32_t pwrctl; |
| 22 | uint32_t pwrtmg; |
| 23 | uint32_t hwlpctl; |
| 24 | uint32_t rfshctl0; |
| 25 | uint32_t rfshctl3; |
| 26 | uint32_t crcparctl0; |
| 27 | uint32_t zqctl0; |
| 28 | uint32_t dfitmg0; |
| 29 | uint32_t dfitmg1; |
| 30 | uint32_t dfilpcfg0; |
| 31 | uint32_t dfiupd0; |
| 32 | uint32_t dfiupd1; |
| 33 | uint32_t dfiupd2; |
| 34 | uint32_t dfiphymstr; |
| 35 | uint32_t odtmap; |
| 36 | uint32_t dbg0; |
| 37 | uint32_t dbg1; |
| 38 | uint32_t dbgcmd; |
| 39 | uint32_t poisoncfg; |
| 40 | uint32_t pccfg; |
| 41 | }; |
| 42 | |
| 43 | struct stm32mp1_ddrctrl_timing { |
| 44 | uint32_t rfshtmg; |
| 45 | uint32_t dramtmg0; |
| 46 | uint32_t dramtmg1; |
| 47 | uint32_t dramtmg2; |
| 48 | uint32_t dramtmg3; |
| 49 | uint32_t dramtmg4; |
| 50 | uint32_t dramtmg5; |
| 51 | uint32_t dramtmg6; |
| 52 | uint32_t dramtmg7; |
| 53 | uint32_t dramtmg8; |
| 54 | uint32_t dramtmg14; |
| 55 | uint32_t odtcfg; |
| 56 | }; |
| 57 | |
| 58 | struct stm32mp1_ddrctrl_map { |
| 59 | uint32_t addrmap1; |
| 60 | uint32_t addrmap2; |
| 61 | uint32_t addrmap3; |
| 62 | uint32_t addrmap4; |
| 63 | uint32_t addrmap5; |
| 64 | uint32_t addrmap6; |
| 65 | uint32_t addrmap9; |
| 66 | uint32_t addrmap10; |
| 67 | uint32_t addrmap11; |
| 68 | }; |
| 69 | |
| 70 | struct stm32mp1_ddrctrl_perf { |
| 71 | uint32_t sched; |
| 72 | uint32_t sched1; |
| 73 | uint32_t perfhpr1; |
| 74 | uint32_t perflpr1; |
| 75 | uint32_t perfwr1; |
| 76 | uint32_t pcfgr_0; |
| 77 | uint32_t pcfgw_0; |
| 78 | uint32_t pcfgqos0_0; |
| 79 | uint32_t pcfgqos1_0; |
| 80 | uint32_t pcfgwqos0_0; |
| 81 | uint32_t pcfgwqos1_0; |
Yann Gautier | 6d8c244 | 2020-09-17 12:42:46 +0200 | [diff] [blame] | 82 | #if STM32MP_DDR_DUAL_AXI_PORT |
Yann Gautier | caf575b | 2018-07-24 17:18:19 +0200 | [diff] [blame] | 83 | uint32_t pcfgr_1; |
| 84 | uint32_t pcfgw_1; |
| 85 | uint32_t pcfgqos0_1; |
| 86 | uint32_t pcfgqos1_1; |
| 87 | uint32_t pcfgwqos0_1; |
| 88 | uint32_t pcfgwqos1_1; |
Yann Gautier | 6d8c244 | 2020-09-17 12:42:46 +0200 | [diff] [blame] | 89 | #endif |
Yann Gautier | caf575b | 2018-07-24 17:18:19 +0200 | [diff] [blame] | 90 | }; |
| 91 | |
| 92 | struct stm32mp1_ddrphy_reg { |
| 93 | uint32_t pgcr; |
| 94 | uint32_t aciocr; |
| 95 | uint32_t dxccr; |
| 96 | uint32_t dsgcr; |
| 97 | uint32_t dcr; |
| 98 | uint32_t odtcr; |
| 99 | uint32_t zq0cr1; |
| 100 | uint32_t dx0gcr; |
| 101 | uint32_t dx1gcr; |
Yann Gautier | 6d8c244 | 2020-09-17 12:42:46 +0200 | [diff] [blame] | 102 | #if STM32MP_DDR_32BIT_INTERFACE |
Yann Gautier | caf575b | 2018-07-24 17:18:19 +0200 | [diff] [blame] | 103 | uint32_t dx2gcr; |
| 104 | uint32_t dx3gcr; |
Yann Gautier | 6d8c244 | 2020-09-17 12:42:46 +0200 | [diff] [blame] | 105 | #endif |
Yann Gautier | caf575b | 2018-07-24 17:18:19 +0200 | [diff] [blame] | 106 | }; |
| 107 | |
| 108 | struct stm32mp1_ddrphy_timing { |
| 109 | uint32_t ptr0; |
| 110 | uint32_t ptr1; |
| 111 | uint32_t ptr2; |
| 112 | uint32_t dtpr0; |
| 113 | uint32_t dtpr1; |
| 114 | uint32_t dtpr2; |
| 115 | uint32_t mr0; |
| 116 | uint32_t mr1; |
| 117 | uint32_t mr2; |
| 118 | uint32_t mr3; |
| 119 | }; |
| 120 | |
Nicolas Le Bayon | 8ce825f | 2021-05-18 10:01:30 +0200 | [diff] [blame] | 121 | struct stm32mp_ddr_config { |
| 122 | struct stm32mp_ddr_info info; |
Yann Gautier | caf575b | 2018-07-24 17:18:19 +0200 | [diff] [blame] | 123 | struct stm32mp1_ddrctrl_reg c_reg; |
| 124 | struct stm32mp1_ddrctrl_timing c_timing; |
| 125 | struct stm32mp1_ddrctrl_map c_map; |
| 126 | struct stm32mp1_ddrctrl_perf c_perf; |
| 127 | struct stm32mp1_ddrphy_reg p_reg; |
| 128 | struct stm32mp1_ddrphy_timing p_timing; |
Yann Gautier | caf575b | 2018-07-24 17:18:19 +0200 | [diff] [blame] | 129 | }; |
| 130 | |
Nicolas Le Bayon | 8ce825f | 2021-05-18 10:01:30 +0200 | [diff] [blame] | 131 | int stm32mp1_ddr_clk_enable(struct stm32mp_ddr_priv *priv, uint32_t mem_speed); |
| 132 | void stm32mp1_ddr_init(struct stm32mp_ddr_priv *priv, struct stm32mp_ddr_config *config); |
| 133 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 134 | #endif /* STM32MP1_DDR_H */ |