summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Zabel <p.zabel@pengutronix.de>2018-04-12 13:05:34 +0200
committerPhilipp Zabel <p.zabel@pengutronix.de>2018-04-12 13:05:34 +0200
commit45d0d599067b6b03abbee058eb72ed58825525d5 (patch)
tree600d9da76f3b85d39ecb7c172d48a424acbcb123
parent4d64ad62927a9d63462458a01e19bb6c1e535943 (diff)
downloadimx6_ddrstat-45d0d599067b6b03abbee058eb72ed58825525d5.tar.gz
imx6_ddrstat-45d0d599067b6b03abbee058eb72ed58825525d5.tar.xz
Add i.MX6QuadPlus AXI filter support
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
-rw-r--r--imx6_ddrstat.c115
1 files changed, 95 insertions, 20 deletions
diff --git a/imx6_ddrstat.c b/imx6_ddrstat.c
index 7657e1f..e9fdfbf 100644
--- a/imx6_ddrstat.c
+++ b/imx6_ddrstat.c
@@ -237,7 +237,49 @@ struct axi_filter {
};
/* Table 43-8. i.MX 6Dual/6Quad AXI ID */
-static struct axi_filter filters[] = {
+static struct axi_filter filters_quad[] = {
+ { "arm-s0", 0b11100000000111, 0b00000000000000 },
+ { "arm-s1", 0b11100000000111, 0b00000000000001 },
+ { "ipu1", 0b11111111100111, 0b00000000000100 },
+ { "ipu1-0", 0b11111111111111, 0b00000000000100 },
+ { "ipu1-1", 0b11111111111111, 0b00000000001100 },
+ { "ipu1-2", 0b11111111111111, 0b00000000010100 },
+ { "ipu1-3", 0b11111111111111, 0b00000000011100 },
+ { "ipu2", 0b11111111100111, 0b00000000000101 },
+ { "ipu2-0", 0b11111111111111, 0b00000000000101 },
+ { "ipu2-1", 0b11111111111111, 0b00000000001101 },
+ { "ipu2-2", 0b11111111111111, 0b00000000010101 },
+ { "ipu2-3", 0b11111111111111, 0b00000000011101 },
+ { "gpu3d-a", 0b11110000111111, 0b00000000000010 },
+ { "gpu2d-a", 0b11110000111111, 0b00000000001010 },
+ { "vdoa", 0b11111100111111, 0b00000000010010 },
+ { "openvg", 0b11110000111111, 0b00000000100010 },
+ { "hdmi", 0b11111111111111, 0b00000100011010 },
+ { "sdma-brst", 0b11111111111111, 0b00000101011010 },
+ { "sdma-per", 0b11111111111111, 0b00000110011010 },
+ { "caam", 0b00001111111111, 0b00000000011010 },
+ { "usb", 0b11001111111111, 0b00000001011010 },
+ { "enet", 0b11111111111111, 0b00000010011010 },
+ { "hsi", 0b11111111111111, 0b00000011011010 },
+ { "usdhc1", 0b11111111111111, 0b00000111011010 },
+ { "gpu3d-b", 0b11110000111111, 0b00000000000011 },
+ /* the reference manual lists a second gpu3d-b instead of gpu2d-b */
+ { "gpu2d-b", 0b11110000111111, 0b00000000001011 },
+ { "vpu-prime", 0b11110000111111, 0b00000000010011 },
+ { "pcie", 0b11100000111111, 0b00000000011011 },
+ { "dap", 0b11111111111111, 0b00000000100011 },
+ { "apbh-dma", 0b11111111111111, 0b00000010100011 },
+ { "bch40", 0b00001111111111, 0b00000001100011 },
+ { "sata", 0b11111111111111, 0b00000011100011 },
+ { "mlb150", 0b11111111111111, 0b00000100100011 },
+ { "usdhc2", 0b11111111111111, 0b00000101100011 },
+ { "usdhc3", 0b11111111111111, 0b00000110100011 },
+ { "usdhc4", 0b11111111111111, 0b00000111100011 },
+ {},
+};
+
+/* Table 46-10. i.MX 6Dual/6QuadPlus AXI ID */
+static struct axi_filter filters_quadplus[] = {
{ "arm-s0", 0b11100000000111, 0b00000000000000 },
{ "arm-s1", 0b11100000000111, 0b00000000000001 },
{ "ipu1", 0b11111111100111, 0b00000000000100 },
@@ -250,10 +292,15 @@ static struct axi_filter filters[] = {
{ "ipu2-1", 0b11111111111111, 0b00000000001101 },
{ "ipu2-2", 0b11111111111111, 0b00000000010101 },
{ "ipu2-3", 0b11111111111111, 0b00000000011101 },
- { "gpu3d-a", 0b11110000111111, 0b00000000000010 },
- { "gpu2d-a", 0b11110000111111, 0b00000000001010 },
+ { "gpu3d0", 0b11111000011111, 0b00000000000110 },
+ { "gpu3d1", 0b11111000011111, 0b00000000001110 },
+ { "gpu2d", 0b11111000011111, 0b00000000010110 },
+ { "openvg", 0b11111000011111, 0b00000000011110 },
+ { "pre0", 0b11111000011111, 0b00000000000111 },
+ { "pre1", 0b11111000011111, 0b00000000001111 },
+ { "pre2", 0b11111000011111, 0b00000000010111 },
+ { "pre3", 0b11111000011111, 0b00000000011111 },
{ "vdoa", 0b11111100111111, 0b00000000010010 },
- { "openvg", 0b11110000111111, 0b00000000100010 },
{ "hdmi", 0b11111111111111, 0b00000100011010 },
{ "sdma-brst", 0b11111111111111, 0b00000101011010 },
{ "sdma-per", 0b11111111111111, 0b00000110011010 },
@@ -262,23 +309,20 @@ static struct axi_filter filters[] = {
{ "enet", 0b11111111111111, 0b00000010011010 },
{ "hsi", 0b11111111111111, 0b00000011011010 },
{ "usdhc1", 0b11111111111111, 0b00000111011010 },
- { "gpu3d-b", 0b11110000111111, 0b00000000000011 },
- /* the reference manual lists a second gpu3d-b instead of gpu2d-b */
- { "gpu2d-b", 0b11110000111111, 0b00000000001011 },
- { "vpu-prime", 0b11110000111111, 0b00000000010011 },
- { "pcie", 0b11100000111111, 0b00000000011011 },
- { "dap", 0b11111111111111, 0b00000000100011 },
- { "apbh-dma", 0b11111111111111, 0b00000010100011 },
- { "bch40", 0b00001111111111, 0b00000001100011 },
- { "sata", 0b11111111111111, 0b00000011100011 },
- { "mlb150", 0b11111111111111, 0b00000100100011 },
- { "usdhc2", 0b11111111111111, 0b00000101100011 },
- { "usdhc3", 0b11111111111111, 0b00000110100011 },
- { "usdhc4", 0b11111111111111, 0b00000111100011 },
+ { "vpu-prime", 0b11110000111111, 0b00000000000010 },
+ { "pcie", 0b11100000111111, 0b00000000001010 },
+ { "dap", 0b11111111111111, 0b00000000100010 },
+ { "apbh-dma", 0b11111111111111, 0b00000010100010 },
+ { "bch40", 0b00001111111111, 0b00000001100010 },
+ { "sata", 0b11111111111111, 0b00000011100010 },
+ { "mlb150", 0b11111111111111, 0b00000100100010 },
+ { "usdhc2", 0b11111111111111, 0b00000101100010 },
+ { "usdhc3", 0b11111111111111, 0b00000110100010 },
+ { "usdhc4", 0b11111111111111, 0b00000111100010 },
{},
};
-void setup_axi_filter(const char *master)
+void setup_axi_filter(const char *master, struct axi_filter *filters)
{
struct axi_filter *filter;
@@ -300,11 +344,42 @@ void setup_axi_filter(const char *master)
axi_id_mask = 0;
}
+bool of_machine_is_compatible(const char *compatible)
+{
+ int fd = open("/sys/firmware/devicetree/base/compatible", O_RDONLY);
+ char compatibles[256];
+ const char *p;
+ ssize_t n;
+
+ if (fd == -1)
+ return false;
+
+ memset(compatibles, 0, sizeof(compatibles));
+ n = read(fd, compatibles, sizeof(compatibles));
+ if (n == -1)
+ return false;
+
+ p = compatibles;
+ while (p < compatibles + n) {
+ if (strcmp(p, compatible) == 0)
+ return true;
+ p += strlen(p) + 1;
+ }
+
+ return false;
+}
+
int main(int argc, char **argv)
{
+ static struct axi_filter *filters;
int delay = 1;
char *endp;
+ if (of_machine_is_compatible("fsl,imx6qp"))
+ filters = filters_quadplus;
+ else
+ filters = filters_quad;
+
if (argc > 1 && strcmp(argv[1], "--help") == 0) {
struct axi_filter *filter;
@@ -327,10 +402,10 @@ int main(int argc, char **argv)
if (delay > 4)
return 1;
if (endp == argv[1] && argc == 2)
- setup_axi_filter(argv[1]);
+ setup_axi_filter(argv[1], filters);
}
if (argc > 2)
- setup_axi_filter(argv[2]);
+ setup_axi_filter(argv[2], filters);
if (delay <= 0)
delay = 1;