1 /*
2 * Copyright (c) 2011 Intel Corporation. All Rights Reserved.
3 * Copyright (c) Imagination Technologies Limited, UK
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sub license, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial portions
15 * of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
20 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
21 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 *
25 */
26 #ifndef _topazhp_cmdump_h
27 #define _topazhp_cmdump_h
28 
29 #include <stdlib.h>
30 #include <stdio.h>
31 #include <string.h>
32 #include <unistd.h> /* for libc5 */
33 
34 #ifdef ANDROID
35 #define  outl(...)
36 #define  outw(...)
37 #define  inl(...)   0
38 #define  inw(...)   0
39 #else
40 #include <sys/io.h> /* for glibc */
41 #endif
42 
43 #define MIN(a,b)  ((a)>(b)?(b):(a))
44 
45 struct RegisterInfomation {
46     char *name;
47     int offset;
48 };
49 
50 #define ui32TopazMulticoreRegId  1
51 
52 
53 
54 #define PCI_DEVICE_ID_CFG	0x02	/* 16 bits */
55 #define PCI_BASE_ADDRESS_0	0x10	/* 32 bits */
56 #define PCI_BASE_ADDRESS_1	0x14	/* 32 bits [htype 0,1 only] */
57 #define PCI_BASE_ADDRESS_2	0x18	/* 32 bits [htype 0 only] */
58 #define PCI_BASE_ADDRESS_3	0x1c	/* 32 bits */
59 #define CONFIG_CMD(bus,device_fn,where)   \
60    (0x80000000|((bus&0xff) << 16)|((device_fn&0xff) << 8)|((where&0xff) & ~3))
61 
pci_get_long(int bus,int device_fn,int where)62 static inline unsigned long pci_get_long(int bus,int device_fn, int where)
63 {
64     outl(CONFIG_CMD(bus,device_fn,where), 0xCF8);
65     return inl(0xCFC);
66 }
67 
pci_set_long(int bus,int device_fn,int where,unsigned long value)68 static inline int pci_set_long(int bus,int device_fn, int where,unsigned long value)
69 {
70     outl(CONFIG_CMD(bus,device_fn,where), 0xCF8);
71     outl(value,0xCFC);
72     return 0;
73 }
74 
pci_get_short(int bus,int device_fn,int where)75 static inline int pci_get_short(int bus,int device_fn, int where)
76 {
77     outl(CONFIG_CMD(bus,device_fn,where), 0xCF8);
78     return inw(0xCFC + (where&2));
79 }
80 
81 
pci_set_short(int bus,int device_fn,int where,unsigned short value)82 static inline int pci_set_short(int bus,int device_fn, int where,unsigned short value)
83 {
84     outl(CONFIG_CMD(bus,device_fn,where), 0xCF8);
85     outw(value,0xCFC + (where&2));
86     return 0;
87 }
88 
89 #define REG_OFFSET_TOPAZ_MULTICORE                      0x00000000
90 #define REG_OFFSET_TOPAZ_DMAC                           0x00000400
91 #define REG_OFFSET_TOPAZ_MTX                            0x00000800
92 
93 #define REGNUM_TOPAZ_CR_MMU_DIR_LIST_BASE_ADDR          0x0030
94 
95 #ifndef MV_OFFSET_IN_TABLE
96 #define MV_OFFSET_IN_TABLE(BDistance, Position) ((BDistance) * MV_ROW_STRIDE + (Position) * sizeof(IMG_MV_SETTINGS))
97 #endif
98 
99 #define MULTICORE_READ32(offset, pointer)                               \
100     do {                                                                \
101 	*(pointer) = *((unsigned long *)((unsigned char *)(linear_mmio_topaz) \
102                                          + REG_OFFSET_TOPAZ_MULTICORE + offset)); \
103     } while (0)
104 
105 int topazhp_dump_command(unsigned int comm_dword[]);
106 int tng_command_parameter_dump(int cmdid, void *virt_addr);
107 
108 #endif
109