1b843c749SSergey Zigachev /*
2b843c749SSergey Zigachev * Copyright 2012-16 Advanced Micro Devices, Inc.
3b843c749SSergey Zigachev *
4b843c749SSergey Zigachev * Permission is hereby granted, free of charge, to any person obtaining a
5b843c749SSergey Zigachev * copy of this software and associated documentation files (the "Software"),
6b843c749SSergey Zigachev * to deal in the Software without restriction, including without limitation
7b843c749SSergey Zigachev * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8b843c749SSergey Zigachev * and/or sell copies of the Software, and to permit persons to whom the
9b843c749SSergey Zigachev * Software is furnished to do so, subject to the following conditions:
10b843c749SSergey Zigachev *
11b843c749SSergey Zigachev * The above copyright notice and this permission notice shall be included in
12b843c749SSergey Zigachev * all copies or substantial portions of the Software.
13b843c749SSergey Zigachev *
14b843c749SSergey Zigachev * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15b843c749SSergey Zigachev * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16b843c749SSergey Zigachev * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17b843c749SSergey Zigachev * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18b843c749SSergey Zigachev * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19b843c749SSergey Zigachev * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20b843c749SSergey Zigachev * OTHER DEALINGS IN THE SOFTWARE.
21b843c749SSergey Zigachev *
22b843c749SSergey Zigachev * Authors: AMD
23b843c749SSergey Zigachev *
24b843c749SSergey Zigachev */
25b843c749SSergey Zigachev
26b843c749SSergey Zigachev #include "dm_services.h"
27b843c749SSergey Zigachev
28b843c749SSergey Zigachev #include "include/i2caux_interface.h"
29b843c749SSergey Zigachev #include "../i2caux.h"
30b843c749SSergey Zigachev #include "../engine.h"
31b843c749SSergey Zigachev #include "../i2c_engine.h"
32b843c749SSergey Zigachev #include "../i2c_sw_engine.h"
33b843c749SSergey Zigachev #include "../i2c_hw_engine.h"
34b843c749SSergey Zigachev
35b843c749SSergey Zigachev #include "../dce110/i2c_hw_engine_dce110.h"
36b843c749SSergey Zigachev #include "../dce110/aux_engine_dce110.h"
37b843c749SSergey Zigachev #include "../dce110/i2caux_dce110.h"
38b843c749SSergey Zigachev
39b843c749SSergey Zigachev #include "dce/dce_12_0_offset.h"
40b843c749SSergey Zigachev #include "dce/dce_12_0_sh_mask.h"
41b843c749SSergey Zigachev #include "soc15_hw_ip.h"
42b843c749SSergey Zigachev #include "vega10_ip_offset.h"
43b843c749SSergey Zigachev
44*78973132SSergey Zigachev #include "i2caux_dce120.h"
45*78973132SSergey Zigachev
46b843c749SSergey Zigachev /* begin *********************
47b843c749SSergey Zigachev * macros to expend register list macro defined in HW object header file */
48b843c749SSergey Zigachev
49b843c749SSergey Zigachev #define BASE_INNER(seg) \
50b843c749SSergey Zigachev DCE_BASE__INST0_SEG ## seg
51b843c749SSergey Zigachev
52b843c749SSergey Zigachev /* compile time expand base address. */
53b843c749SSergey Zigachev #define BASE(seg) \
54b843c749SSergey Zigachev BASE_INNER(seg)
55b843c749SSergey Zigachev
56b843c749SSergey Zigachev #define SR(reg_name)\
57b843c749SSergey Zigachev .reg_name = BASE(mm ## reg_name ## _BASE_IDX) + \
58b843c749SSergey Zigachev mm ## reg_name
59b843c749SSergey Zigachev
60b843c749SSergey Zigachev #define SRI(reg_name, block, id)\
61b843c749SSergey Zigachev .reg_name = BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \
62b843c749SSergey Zigachev mm ## block ## id ## _ ## reg_name
63b843c749SSergey Zigachev /* macros to expend register list macro defined in HW object header file
64b843c749SSergey Zigachev * end *********************/
65b843c749SSergey Zigachev
66b843c749SSergey Zigachev #define aux_regs(id)\
67b843c749SSergey Zigachev [id] = {\
68b843c749SSergey Zigachev AUX_COMMON_REG_LIST(id), \
69b843c749SSergey Zigachev .AUX_RESET_MASK = DP_AUX0_AUX_CONTROL__AUX_RESET_MASK \
70b843c749SSergey Zigachev }
71b843c749SSergey Zigachev
72b843c749SSergey Zigachev static const struct dce110_aux_registers dce120_aux_regs[] = {
73b843c749SSergey Zigachev aux_regs(0),
74b843c749SSergey Zigachev aux_regs(1),
75b843c749SSergey Zigachev aux_regs(2),
76b843c749SSergey Zigachev aux_regs(3),
77b843c749SSergey Zigachev aux_regs(4),
78b843c749SSergey Zigachev aux_regs(5),
79b843c749SSergey Zigachev };
80b843c749SSergey Zigachev
81b843c749SSergey Zigachev #define hw_engine_regs(id)\
82b843c749SSergey Zigachev {\
83b843c749SSergey Zigachev I2C_HW_ENGINE_COMMON_REG_LIST(id) \
84b843c749SSergey Zigachev }
85b843c749SSergey Zigachev
86b843c749SSergey Zigachev static const struct dce110_i2c_hw_engine_registers dce120_hw_engine_regs[] = {
87b843c749SSergey Zigachev hw_engine_regs(1),
88b843c749SSergey Zigachev hw_engine_regs(2),
89b843c749SSergey Zigachev hw_engine_regs(3),
90b843c749SSergey Zigachev hw_engine_regs(4),
91b843c749SSergey Zigachev hw_engine_regs(5),
92b843c749SSergey Zigachev hw_engine_regs(6)
93b843c749SSergey Zigachev };
94b843c749SSergey Zigachev
95b843c749SSergey Zigachev static const struct dce110_i2c_hw_engine_shift i2c_shift = {
96b843c749SSergey Zigachev I2C_COMMON_MASK_SH_LIST_DCE110(__SHIFT)
97b843c749SSergey Zigachev };
98b843c749SSergey Zigachev
99b843c749SSergey Zigachev static const struct dce110_i2c_hw_engine_mask i2c_mask = {
100b843c749SSergey Zigachev I2C_COMMON_MASK_SH_LIST_DCE110(_MASK)
101b843c749SSergey Zigachev };
102b843c749SSergey Zigachev
dal_i2caux_dce120_create(struct dc_context * ctx)103b843c749SSergey Zigachev struct i2caux *dal_i2caux_dce120_create(
104b843c749SSergey Zigachev struct dc_context *ctx)
105b843c749SSergey Zigachev {
106b843c749SSergey Zigachev struct i2caux_dce110 *i2caux_dce110 =
107b843c749SSergey Zigachev kzalloc(sizeof(struct i2caux_dce110), GFP_KERNEL);
108b843c749SSergey Zigachev
109b843c749SSergey Zigachev if (!i2caux_dce110) {
110b843c749SSergey Zigachev ASSERT_CRITICAL(false);
111b843c749SSergey Zigachev return NULL;
112b843c749SSergey Zigachev }
113b843c749SSergey Zigachev
114b843c749SSergey Zigachev dal_i2caux_dce110_construct(i2caux_dce110,
115b843c749SSergey Zigachev ctx,
116b843c749SSergey Zigachev ARRAY_SIZE(dce120_aux_regs),
117b843c749SSergey Zigachev dce120_aux_regs,
118b843c749SSergey Zigachev dce120_hw_engine_regs,
119b843c749SSergey Zigachev &i2c_shift,
120b843c749SSergey Zigachev &i2c_mask);
121b843c749SSergey Zigachev return &i2caux_dce110->base;
122b843c749SSergey Zigachev }
123