| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) 2017 Icenowy Zheng <icenowy@aosc.io> |
|---|
| 3 | | - * |
|---|
| 4 | | - * This software is licensed under the terms of the GNU General Public |
|---|
| 5 | | - * License version 2, as published by the Free Software Foundation, and |
|---|
| 6 | | - * may be copied, distributed, and modified under those terms. |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 9 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 10 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 11 | | - * GNU General Public License for more details. |
|---|
| 12 | 4 | */ |
|---|
| 13 | 5 | |
|---|
| 14 | 6 | #include <linux/clk.h> |
|---|
| .. | .. |
|---|
| 31 | 23 | 0x04, BIT(1), 0); |
|---|
| 32 | 24 | static SUNXI_CCU_GATE(bus_wb_clk, "bus-wb", "bus-de", |
|---|
| 33 | 25 | 0x04, BIT(2), 0); |
|---|
| 26 | +static SUNXI_CCU_GATE(bus_rot_clk, "bus-rot", "bus-de", |
|---|
| 27 | + 0x04, BIT(3), 0); |
|---|
| 34 | 28 | |
|---|
| 35 | 29 | static SUNXI_CCU_GATE(mixer0_clk, "mixer0", "mixer0-div", |
|---|
| 36 | 30 | 0x00, BIT(0), CLK_SET_RATE_PARENT); |
|---|
| .. | .. |
|---|
| 38 | 32 | 0x00, BIT(1), CLK_SET_RATE_PARENT); |
|---|
| 39 | 33 | static SUNXI_CCU_GATE(wb_clk, "wb", "wb-div", |
|---|
| 40 | 34 | 0x00, BIT(2), CLK_SET_RATE_PARENT); |
|---|
| 35 | +static SUNXI_CCU_GATE(rot_clk, "rot", "rot-div", |
|---|
| 36 | + 0x00, BIT(3), CLK_SET_RATE_PARENT); |
|---|
| 41 | 37 | |
|---|
| 42 | 38 | static SUNXI_CCU_M(mixer0_div_clk, "mixer0-div", "de", 0x0c, 0, 4, |
|---|
| 43 | 39 | CLK_SET_RATE_PARENT); |
|---|
| .. | .. |
|---|
| 45 | 41 | CLK_SET_RATE_PARENT); |
|---|
| 46 | 42 | static SUNXI_CCU_M(wb_div_clk, "wb-div", "de", 0x0c, 8, 4, |
|---|
| 47 | 43 | CLK_SET_RATE_PARENT); |
|---|
| 44 | +static SUNXI_CCU_M(rot_div_clk, "rot-div", "de", 0x0c, 0x0c, 4, |
|---|
| 45 | + CLK_SET_RATE_PARENT); |
|---|
| 48 | 46 | |
|---|
| 49 | 47 | static SUNXI_CCU_M(mixer0_div_a83_clk, "mixer0-div", "pll-de", 0x0c, 0, 4, |
|---|
| 50 | 48 | CLK_SET_RATE_PARENT); |
|---|
| 51 | 49 | static SUNXI_CCU_M(mixer1_div_a83_clk, "mixer1-div", "pll-de", 0x0c, 4, 4, |
|---|
| 52 | 50 | CLK_SET_RATE_PARENT); |
|---|
| 53 | 51 | static SUNXI_CCU_M(wb_div_a83_clk, "wb-div", "pll-de", 0x0c, 8, 4, |
|---|
| 52 | + CLK_SET_RATE_PARENT); |
|---|
| 53 | +static SUNXI_CCU_M(rot_div_a83_clk, "rot-div", "pll-de", 0x0c, 0x0c, 4, |
|---|
| 54 | 54 | CLK_SET_RATE_PARENT); |
|---|
| 55 | 55 | |
|---|
| 56 | 56 | static struct ccu_common *sun8i_a83t_de2_clks[] = { |
|---|
| .. | .. |
|---|
| 65 | 65 | &mixer0_div_a83_clk.common, |
|---|
| 66 | 66 | &mixer1_div_a83_clk.common, |
|---|
| 67 | 67 | &wb_div_a83_clk.common, |
|---|
| 68 | + |
|---|
| 69 | + &bus_rot_clk.common, |
|---|
| 70 | + &rot_clk.common, |
|---|
| 71 | + &rot_div_a83_clk.common, |
|---|
| 68 | 72 | }; |
|---|
| 69 | 73 | |
|---|
| 70 | 74 | static struct ccu_common *sun8i_h3_de2_clks[] = { |
|---|
| .. | .. |
|---|
| 92 | 96 | &wb_div_clk.common, |
|---|
| 93 | 97 | }; |
|---|
| 94 | 98 | |
|---|
| 99 | +static struct ccu_common *sun50i_a64_de2_clks[] = { |
|---|
| 100 | + &mixer0_clk.common, |
|---|
| 101 | + &mixer1_clk.common, |
|---|
| 102 | + &wb_clk.common, |
|---|
| 103 | + |
|---|
| 104 | + &bus_mixer0_clk.common, |
|---|
| 105 | + &bus_mixer1_clk.common, |
|---|
| 106 | + &bus_wb_clk.common, |
|---|
| 107 | + |
|---|
| 108 | + &mixer0_div_clk.common, |
|---|
| 109 | + &mixer1_div_clk.common, |
|---|
| 110 | + &wb_div_clk.common, |
|---|
| 111 | + |
|---|
| 112 | + &bus_rot_clk.common, |
|---|
| 113 | + &rot_clk.common, |
|---|
| 114 | + &rot_div_clk.common, |
|---|
| 115 | +}; |
|---|
| 116 | + |
|---|
| 95 | 117 | static struct clk_hw_onecell_data sun8i_a83t_de2_hw_clks = { |
|---|
| 96 | 118 | .hws = { |
|---|
| 97 | 119 | [CLK_MIXER0] = &mixer0_clk.common.hw, |
|---|
| 98 | 120 | [CLK_MIXER1] = &mixer1_clk.common.hw, |
|---|
| 99 | 121 | [CLK_WB] = &wb_clk.common.hw, |
|---|
| 122 | + [CLK_ROT] = &rot_clk.common.hw, |
|---|
| 100 | 123 | |
|---|
| 101 | 124 | [CLK_BUS_MIXER0] = &bus_mixer0_clk.common.hw, |
|---|
| 102 | 125 | [CLK_BUS_MIXER1] = &bus_mixer1_clk.common.hw, |
|---|
| 103 | 126 | [CLK_BUS_WB] = &bus_wb_clk.common.hw, |
|---|
| 127 | + [CLK_BUS_ROT] = &bus_rot_clk.common.hw, |
|---|
| 104 | 128 | |
|---|
| 105 | 129 | [CLK_MIXER0_DIV] = &mixer0_div_a83_clk.common.hw, |
|---|
| 106 | 130 | [CLK_MIXER1_DIV] = &mixer1_div_a83_clk.common.hw, |
|---|
| 107 | 131 | [CLK_WB_DIV] = &wb_div_a83_clk.common.hw, |
|---|
| 132 | + [CLK_ROT_DIV] = &rot_div_a83_clk.common.hw, |
|---|
| 108 | 133 | }, |
|---|
| 109 | | - .num = CLK_NUMBER, |
|---|
| 134 | + .num = CLK_NUMBER_WITH_ROT, |
|---|
| 110 | 135 | }; |
|---|
| 111 | 136 | |
|---|
| 112 | 137 | static struct clk_hw_onecell_data sun8i_h3_de2_hw_clks = { |
|---|
| .. | .. |
|---|
| 123 | 148 | [CLK_MIXER1_DIV] = &mixer1_div_clk.common.hw, |
|---|
| 124 | 149 | [CLK_WB_DIV] = &wb_div_clk.common.hw, |
|---|
| 125 | 150 | }, |
|---|
| 126 | | - .num = CLK_NUMBER, |
|---|
| 151 | + .num = CLK_NUMBER_WITHOUT_ROT, |
|---|
| 127 | 152 | }; |
|---|
| 128 | 153 | |
|---|
| 129 | 154 | static struct clk_hw_onecell_data sun8i_v3s_de2_hw_clks = { |
|---|
| .. | .. |
|---|
| 137 | 162 | [CLK_MIXER0_DIV] = &mixer0_div_clk.common.hw, |
|---|
| 138 | 163 | [CLK_WB_DIV] = &wb_div_clk.common.hw, |
|---|
| 139 | 164 | }, |
|---|
| 140 | | - .num = CLK_NUMBER, |
|---|
| 165 | + .num = CLK_NUMBER_WITHOUT_ROT, |
|---|
| 166 | +}; |
|---|
| 167 | + |
|---|
| 168 | +static struct clk_hw_onecell_data sun50i_a64_de2_hw_clks = { |
|---|
| 169 | + .hws = { |
|---|
| 170 | + [CLK_MIXER0] = &mixer0_clk.common.hw, |
|---|
| 171 | + [CLK_MIXER1] = &mixer1_clk.common.hw, |
|---|
| 172 | + [CLK_WB] = &wb_clk.common.hw, |
|---|
| 173 | + [CLK_ROT] = &rot_clk.common.hw, |
|---|
| 174 | + |
|---|
| 175 | + [CLK_BUS_MIXER0] = &bus_mixer0_clk.common.hw, |
|---|
| 176 | + [CLK_BUS_MIXER1] = &bus_mixer1_clk.common.hw, |
|---|
| 177 | + [CLK_BUS_WB] = &bus_wb_clk.common.hw, |
|---|
| 178 | + [CLK_BUS_ROT] = &bus_rot_clk.common.hw, |
|---|
| 179 | + |
|---|
| 180 | + [CLK_MIXER0_DIV] = &mixer0_div_clk.common.hw, |
|---|
| 181 | + [CLK_MIXER1_DIV] = &mixer1_div_clk.common.hw, |
|---|
| 182 | + [CLK_WB_DIV] = &wb_div_clk.common.hw, |
|---|
| 183 | + [CLK_ROT_DIV] = &rot_div_clk.common.hw, |
|---|
| 184 | + }, |
|---|
| 185 | + .num = CLK_NUMBER_WITH_ROT, |
|---|
| 141 | 186 | }; |
|---|
| 142 | 187 | |
|---|
| 143 | 188 | static struct ccu_reset_map sun8i_a83t_de2_resets[] = { |
|---|
| 144 | 189 | [RST_MIXER0] = { 0x08, BIT(0) }, |
|---|
| 145 | 190 | /* |
|---|
| 146 | | - * For A83T, H3 and R40, mixer1 reset line is shared with wb, so |
|---|
| 147 | | - * only RST_WB is exported here. |
|---|
| 148 | | - * For V3s there's just no mixer1, so it also shares this struct. |
|---|
| 191 | + * Mixer1 reset line is shared with wb, so only RST_WB is |
|---|
| 192 | + * exported here. |
|---|
| 193 | + */ |
|---|
| 194 | + [RST_WB] = { 0x08, BIT(2) }, |
|---|
| 195 | + [RST_ROT] = { 0x08, BIT(3) }, |
|---|
| 196 | +}; |
|---|
| 197 | + |
|---|
| 198 | +static struct ccu_reset_map sun8i_h3_de2_resets[] = { |
|---|
| 199 | + [RST_MIXER0] = { 0x08, BIT(0) }, |
|---|
| 200 | + /* |
|---|
| 201 | + * Mixer1 reset line is shared with wb, so only RST_WB is |
|---|
| 202 | + * exported here. |
|---|
| 203 | + * V3s doesn't have mixer1, so it also shares this struct. |
|---|
| 149 | 204 | */ |
|---|
| 150 | 205 | [RST_WB] = { 0x08, BIT(2) }, |
|---|
| 151 | 206 | }; |
|---|
| 152 | 207 | |
|---|
| 153 | 208 | static struct ccu_reset_map sun50i_a64_de2_resets[] = { |
|---|
| 209 | + [RST_MIXER0] = { 0x08, BIT(0) }, |
|---|
| 210 | + [RST_MIXER1] = { 0x08, BIT(1) }, |
|---|
| 211 | + [RST_WB] = { 0x08, BIT(2) }, |
|---|
| 212 | + [RST_ROT] = { 0x08, BIT(3) }, |
|---|
| 213 | +}; |
|---|
| 214 | + |
|---|
| 215 | +static struct ccu_reset_map sun50i_h5_de2_resets[] = { |
|---|
| 154 | 216 | [RST_MIXER0] = { 0x08, BIT(0) }, |
|---|
| 155 | 217 | [RST_MIXER1] = { 0x08, BIT(1) }, |
|---|
| 156 | 218 | [RST_WB] = { 0x08, BIT(2) }, |
|---|
| .. | .. |
|---|
| 172 | 234 | |
|---|
| 173 | 235 | .hw_clks = &sun8i_h3_de2_hw_clks, |
|---|
| 174 | 236 | |
|---|
| 175 | | - .resets = sun8i_a83t_de2_resets, |
|---|
| 176 | | - .num_resets = ARRAY_SIZE(sun8i_a83t_de2_resets), |
|---|
| 237 | + .resets = sun8i_h3_de2_resets, |
|---|
| 238 | + .num_resets = ARRAY_SIZE(sun8i_h3_de2_resets), |
|---|
| 177 | 239 | }; |
|---|
| 178 | 240 | |
|---|
| 179 | | -static const struct sunxi_ccu_desc sun50i_a64_de2_clk_desc = { |
|---|
| 180 | | - .ccu_clks = sun8i_h3_de2_clks, |
|---|
| 181 | | - .num_ccu_clks = ARRAY_SIZE(sun8i_h3_de2_clks), |
|---|
| 241 | +static const struct sunxi_ccu_desc sun8i_r40_de2_clk_desc = { |
|---|
| 242 | + .ccu_clks = sun50i_a64_de2_clks, |
|---|
| 243 | + .num_ccu_clks = ARRAY_SIZE(sun50i_a64_de2_clks), |
|---|
| 182 | 244 | |
|---|
| 183 | | - .hw_clks = &sun8i_h3_de2_hw_clks, |
|---|
| 245 | + .hw_clks = &sun50i_a64_de2_hw_clks, |
|---|
| 184 | 246 | |
|---|
| 185 | | - .resets = sun50i_a64_de2_resets, |
|---|
| 186 | | - .num_resets = ARRAY_SIZE(sun50i_a64_de2_resets), |
|---|
| 247 | + .resets = sun8i_a83t_de2_resets, |
|---|
| 248 | + .num_resets = ARRAY_SIZE(sun8i_a83t_de2_resets), |
|---|
| 187 | 249 | }; |
|---|
| 188 | 250 | |
|---|
| 189 | 251 | static const struct sunxi_ccu_desc sun8i_v3s_de2_clk_desc = { |
|---|
| .. | .. |
|---|
| 194 | 256 | |
|---|
| 195 | 257 | .resets = sun8i_a83t_de2_resets, |
|---|
| 196 | 258 | .num_resets = ARRAY_SIZE(sun8i_a83t_de2_resets), |
|---|
| 259 | +}; |
|---|
| 260 | + |
|---|
| 261 | +static const struct sunxi_ccu_desc sun50i_a64_de2_clk_desc = { |
|---|
| 262 | + .ccu_clks = sun50i_a64_de2_clks, |
|---|
| 263 | + .num_ccu_clks = ARRAY_SIZE(sun50i_a64_de2_clks), |
|---|
| 264 | + |
|---|
| 265 | + .hw_clks = &sun50i_a64_de2_hw_clks, |
|---|
| 266 | + |
|---|
| 267 | + .resets = sun50i_a64_de2_resets, |
|---|
| 268 | + .num_resets = ARRAY_SIZE(sun50i_a64_de2_resets), |
|---|
| 269 | +}; |
|---|
| 270 | + |
|---|
| 271 | +static const struct sunxi_ccu_desc sun50i_h5_de2_clk_desc = { |
|---|
| 272 | + .ccu_clks = sun8i_h3_de2_clks, |
|---|
| 273 | + .num_ccu_clks = ARRAY_SIZE(sun8i_h3_de2_clks), |
|---|
| 274 | + |
|---|
| 275 | + .hw_clks = &sun8i_h3_de2_hw_clks, |
|---|
| 276 | + |
|---|
| 277 | + .resets = sun50i_h5_de2_resets, |
|---|
| 278 | + .num_resets = ARRAY_SIZE(sun50i_h5_de2_resets), |
|---|
| 197 | 279 | }; |
|---|
| 198 | 280 | |
|---|
| 199 | 281 | static int sunxi_de2_clk_probe(struct platform_device *pdev) |
|---|
| .. | .. |
|---|
| 285 | 367 | .data = &sun8i_h3_de2_clk_desc, |
|---|
| 286 | 368 | }, |
|---|
| 287 | 369 | { |
|---|
| 370 | + .compatible = "allwinner,sun8i-r40-de2-clk", |
|---|
| 371 | + .data = &sun8i_r40_de2_clk_desc, |
|---|
| 372 | + }, |
|---|
| 373 | + { |
|---|
| 288 | 374 | .compatible = "allwinner,sun8i-v3s-de2-clk", |
|---|
| 289 | 375 | .data = &sun8i_v3s_de2_clk_desc, |
|---|
| 290 | 376 | }, |
|---|
| .. | .. |
|---|
| 294 | 380 | }, |
|---|
| 295 | 381 | { |
|---|
| 296 | 382 | .compatible = "allwinner,sun50i-h5-de2-clk", |
|---|
| 297 | | - .data = &sun50i_a64_de2_clk_desc, |
|---|
| 383 | + .data = &sun50i_h5_de2_clk_desc, |
|---|
| 384 | + }, |
|---|
| 385 | + { |
|---|
| 386 | + .compatible = "allwinner,sun50i-h6-de3-clk", |
|---|
| 387 | + .data = &sun50i_h5_de2_clk_desc, |
|---|
| 298 | 388 | }, |
|---|
| 299 | 389 | { } |
|---|
| 300 | 390 | }; |
|---|