xref: /openbmc/linux/drivers/gpu/drm/amd/acp/acp_hw.c (revision 110e6f26)
1a8fe58ceSMaruthi Bayyavarapu /*
2a8fe58ceSMaruthi Bayyavarapu  * Copyright 2015 Advanced Micro Devices, Inc.
3a8fe58ceSMaruthi Bayyavarapu  *
4a8fe58ceSMaruthi Bayyavarapu  * Permission is hereby granted, free of charge, to any person obtaining a
5a8fe58ceSMaruthi Bayyavarapu  * copy of this software and associated documentation files (the "Software"),
6a8fe58ceSMaruthi Bayyavarapu  * to deal in the Software without restriction, including without limitation
7a8fe58ceSMaruthi Bayyavarapu  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8a8fe58ceSMaruthi Bayyavarapu  * and/or sell copies of the Software, and to permit persons to whom the
9a8fe58ceSMaruthi Bayyavarapu  * Software is furnished to do so, subject to the following conditions:
10a8fe58ceSMaruthi Bayyavarapu  *
11a8fe58ceSMaruthi Bayyavarapu  * The above copyright notice and this permission notice shall be included in
12a8fe58ceSMaruthi Bayyavarapu  * all copies or substantial portions of the Software.
13a8fe58ceSMaruthi Bayyavarapu  *
14a8fe58ceSMaruthi Bayyavarapu  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15a8fe58ceSMaruthi Bayyavarapu  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16a8fe58ceSMaruthi Bayyavarapu  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17a8fe58ceSMaruthi Bayyavarapu  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18a8fe58ceSMaruthi Bayyavarapu  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19a8fe58ceSMaruthi Bayyavarapu  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20a8fe58ceSMaruthi Bayyavarapu  * OTHER DEALINGS IN THE SOFTWARE.
21a8fe58ceSMaruthi Bayyavarapu  *
22a8fe58ceSMaruthi Bayyavarapu  */
23a8fe58ceSMaruthi Bayyavarapu 
24a8fe58ceSMaruthi Bayyavarapu #include <linux/mm.h>
25a8fe58ceSMaruthi Bayyavarapu #include <linux/slab.h>
26a8fe58ceSMaruthi Bayyavarapu #include <linux/device.h>
27a8fe58ceSMaruthi Bayyavarapu #include <linux/delay.h>
28a8fe58ceSMaruthi Bayyavarapu #include <linux/errno.h>
29a8fe58ceSMaruthi Bayyavarapu 
30a8fe58ceSMaruthi Bayyavarapu #include "acp_gfx_if.h"
31a8fe58ceSMaruthi Bayyavarapu 
32a8fe58ceSMaruthi Bayyavarapu #define ACP_MODE_I2S	0
33a8fe58ceSMaruthi Bayyavarapu #define ACP_MODE_AZ	1
34a8fe58ceSMaruthi Bayyavarapu 
35a8fe58ceSMaruthi Bayyavarapu #define mmACP_AZALIA_I2S_SELECT 0x51d4
36a8fe58ceSMaruthi Bayyavarapu 
amd_acp_hw_init(struct cgs_device * cgs_device,unsigned acp_version_major,unsigned acp_version_minor)37110e6f26SDave Airlie int amd_acp_hw_init(struct cgs_device *cgs_device,
38a8fe58ceSMaruthi Bayyavarapu 		    unsigned acp_version_major, unsigned acp_version_minor)
39a8fe58ceSMaruthi Bayyavarapu {
40a8fe58ceSMaruthi Bayyavarapu 	unsigned int acp_mode = ACP_MODE_I2S;
41a8fe58ceSMaruthi Bayyavarapu 
42a8fe58ceSMaruthi Bayyavarapu 	if ((acp_version_major == 2) && (acp_version_minor == 2))
43a8fe58ceSMaruthi Bayyavarapu 		acp_mode = cgs_read_register(cgs_device,
44a8fe58ceSMaruthi Bayyavarapu 					mmACP_AZALIA_I2S_SELECT);
45a8fe58ceSMaruthi Bayyavarapu 
46a8fe58ceSMaruthi Bayyavarapu 	if (acp_mode != ACP_MODE_I2S)
47a8fe58ceSMaruthi Bayyavarapu 		return -ENODEV;
48a8fe58ceSMaruthi Bayyavarapu 
49a8fe58ceSMaruthi Bayyavarapu 	return 0;
50a8fe58ceSMaruthi Bayyavarapu }
51