1b843c749SSergey Zigachev /*
2b843c749SSergey Zigachev * Copyright 2012-15 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/aux_engine_dce110.h"
36b843c749SSergey Zigachev #include "../dce110/i2c_hw_engine_dce110.h"
37b843c749SSergey Zigachev #include "../dce110/i2caux_dce110.h"
38b843c749SSergey Zigachev
39b843c749SSergey Zigachev #include "dce/dce_10_0_d.h"
40b843c749SSergey Zigachev #include "dce/dce_10_0_sh_mask.h"
41b843c749SSergey Zigachev
42*78973132SSergey Zigachev #include "i2caux_dce100.h"
43*78973132SSergey Zigachev
44b843c749SSergey Zigachev /* set register offset */
45b843c749SSergey Zigachev #define SR(reg_name)\
46b843c749SSergey Zigachev .reg_name = mm ## reg_name
47b843c749SSergey Zigachev
48b843c749SSergey Zigachev /* set register offset with instance */
49b843c749SSergey Zigachev #define SRI(reg_name, block, id)\
50b843c749SSergey Zigachev .reg_name = mm ## block ## id ## _ ## reg_name
51b843c749SSergey Zigachev
52b843c749SSergey Zigachev #define aux_regs(id)\
53b843c749SSergey Zigachev [id] = {\
54b843c749SSergey Zigachev AUX_COMMON_REG_LIST(id), \
55b843c749SSergey Zigachev .AUX_RESET_MASK = 0 \
56b843c749SSergey Zigachev }
57b843c749SSergey Zigachev
58b843c749SSergey Zigachev #define hw_engine_regs(id)\
59b843c749SSergey Zigachev {\
60b843c749SSergey Zigachev I2C_HW_ENGINE_COMMON_REG_LIST(id) \
61b843c749SSergey Zigachev }
62b843c749SSergey Zigachev
63b843c749SSergey Zigachev static const struct dce110_aux_registers dce100_aux_regs[] = {
64b843c749SSergey Zigachev aux_regs(0),
65b843c749SSergey Zigachev aux_regs(1),
66b843c749SSergey Zigachev aux_regs(2),
67b843c749SSergey Zigachev aux_regs(3),
68b843c749SSergey Zigachev aux_regs(4),
69b843c749SSergey Zigachev aux_regs(5),
70b843c749SSergey Zigachev };
71b843c749SSergey Zigachev
72b843c749SSergey Zigachev static const struct dce110_i2c_hw_engine_registers dce100_hw_engine_regs[] = {
73b843c749SSergey Zigachev hw_engine_regs(1),
74b843c749SSergey Zigachev hw_engine_regs(2),
75b843c749SSergey Zigachev hw_engine_regs(3),
76b843c749SSergey Zigachev hw_engine_regs(4),
77b843c749SSergey Zigachev hw_engine_regs(5),
78b843c749SSergey Zigachev hw_engine_regs(6)
79b843c749SSergey Zigachev };
80b843c749SSergey Zigachev
81b843c749SSergey Zigachev static const struct dce110_i2c_hw_engine_shift i2c_shift = {
82b843c749SSergey Zigachev I2C_COMMON_MASK_SH_LIST_DCE100(__SHIFT)
83b843c749SSergey Zigachev };
84b843c749SSergey Zigachev
85b843c749SSergey Zigachev static const struct dce110_i2c_hw_engine_mask i2c_mask = {
86b843c749SSergey Zigachev I2C_COMMON_MASK_SH_LIST_DCE100(_MASK)
87b843c749SSergey Zigachev };
88b843c749SSergey Zigachev
dal_i2caux_dce100_create(struct dc_context * ctx)89b843c749SSergey Zigachev struct i2caux *dal_i2caux_dce100_create(
90b843c749SSergey Zigachev struct dc_context *ctx)
91b843c749SSergey Zigachev {
92b843c749SSergey Zigachev struct i2caux_dce110 *i2caux_dce110 =
93b843c749SSergey Zigachev kzalloc(sizeof(struct i2caux_dce110), GFP_KERNEL);
94b843c749SSergey Zigachev
95b843c749SSergey Zigachev if (!i2caux_dce110) {
96b843c749SSergey Zigachev ASSERT_CRITICAL(false);
97b843c749SSergey Zigachev return NULL;
98b843c749SSergey Zigachev }
99b843c749SSergey Zigachev
100b843c749SSergey Zigachev dal_i2caux_dce110_construct(i2caux_dce110,
101b843c749SSergey Zigachev ctx,
102b843c749SSergey Zigachev ARRAY_SIZE(dce100_aux_regs),
103b843c749SSergey Zigachev dce100_aux_regs,
104b843c749SSergey Zigachev dce100_hw_engine_regs,
105b843c749SSergey Zigachev &i2c_shift,
106b843c749SSergey Zigachev &i2c_mask);
107b843c749SSergey Zigachev return &i2caux_dce110->base;
108b843c749SSergey Zigachev }
109