Commit 3a3ef1be authored by aTc's avatar aTc

Merge branch 'master' into debian/stretch

parents 4fab3552 59b9faab
......@@ -71,7 +71,8 @@ DEF_INC_PATH = -I. -Icommon -Ipmic -Iaudioic -Ilinux -Ii2c-tools\
-Iarch/arm/mach-omap/am335x\
-Iarch/arm/mach-omap/am335x/prcm\
-Iarch/arm/mach-omap/am335x/dpll\
-Iarch/arm/mach-omap/am437x
-Iarch/arm/mach-omap/am437x\
-Iarch/arm/mach-omap/am437x/prcm
STATIC_BUILD ?= -static
......@@ -298,7 +299,14 @@ AM437XSOURCES=\
arch/arm/mach-omap/am437x/cpuinfo_am437x.c\
arch/arm/mach-omap/am437x/main_am437x.c\
arch/arm/mach-omap/am437x/help_am437x.c\
arch/arm/mach-omap/am437x/ctt_am437x.c
arch/arm/mach-omap/am437x/ctt_am437x.c\
arch/arm/mach-omap/am437x/emif_am437x-defs.c\
arch/arm/mach-omap/am437x/emif_am437x.c\
arch/arm/mach-omap/am437x/prcm/cm_am437x-defs.c\
arch/arm/mach-omap/am437x/prcm/cm_am437x.c\
arch/arm/mach-omap/am437x/prcm/prm_am437x-defs.c\
arch/arm/mach-omap/am437x/prcm/prm_am437x.c\
arch/arm/mach-omap/am437x/prcm/prcm_am437x.c
AM437XOBJECTS= $(AM437XSOURCES:.c=.o)
......@@ -402,7 +410,7 @@ builddate.c: $(ALLOBJECTS)
@echo 'char *builddate="'`date`'";' > builddate.c
version.c: $(ALLOBJECTS)
@echo 'char *omapconf_version="'`git describe --dirty||echo "$(VERSION_MAJOR).$(VERSION_MINOR)-nogit"`'";' > version.c
@echo 'char *omapconf_version="'`git describe --dirty 2>/dev/null||echo "$(VERSION_MAJOR).$(VERSION_MINOR)-nogit"`'";' > version.c
......
......@@ -228,9 +228,11 @@ static int ctt_am335x_regtable_init(void)
prcm_ctt_reg_table[i++].addr = 0x44e00004;
prcm_ctt_reg_table[i++].addr = 0x44e00008;
prcm_ctt_reg_table[i++].addr = 0x44e0000c;
prcm_ctt_reg_table[i++].addr = 0x44e00010;
prcm_ctt_reg_table[i++].addr = 0x44e00014;
prcm_ctt_reg_table[i++].addr = 0x44e00018;
prcm_ctt_reg_table[i++].addr = 0x44e0001c;
prcm_ctt_reg_table[i++].addr = 0x44e00020;
prcm_ctt_reg_table[i++].addr = 0x44e00024;
prcm_ctt_reg_table[i++].addr = 0x44e00028;
prcm_ctt_reg_table[i++].addr = 0x44e0002c;
......@@ -243,6 +245,8 @@ static int ctt_am335x_regtable_init(void)
prcm_ctt_reg_table[i++].addr = 0x44e00048;
prcm_ctt_reg_table[i++].addr = 0x44e0004c;
prcm_ctt_reg_table[i++].addr = 0x44e00050;
prcm_ctt_reg_table[i++].addr = 0x44e00054;
prcm_ctt_reg_table[i++].addr = 0x44e00058;
prcm_ctt_reg_table[i++].addr = 0x44e00060;
prcm_ctt_reg_table[i++].addr = 0x44e00064;
prcm_ctt_reg_table[i++].addr = 0x44e00068;
......@@ -254,9 +258,18 @@ static int ctt_am335x_regtable_init(void)
prcm_ctt_reg_table[i++].addr = 0x44e00080;
prcm_ctt_reg_table[i++].addr = 0x44e00084;
prcm_ctt_reg_table[i++].addr = 0x44e00088;
prcm_ctt_reg_table[i++].addr = 0x44e0008c;
prcm_ctt_reg_table[i++].addr = 0x44e00090;
prcm_ctt_reg_table[i++].addr = 0x44e00094;
prcm_ctt_reg_table[i++].addr = 0x44e00098;
prcm_ctt_reg_table[i++].addr = 0x44e0009c;
prcm_ctt_reg_table[i++].addr = 0x44e000a0;
prcm_ctt_reg_table[i++].addr = 0x44e000a4;
prcm_ctt_reg_table[i++].addr = 0x44e000a8;
prcm_ctt_reg_table[i++].addr = 0x44e000ac;
prcm_ctt_reg_table[i++].addr = 0x44e000b0;
prcm_ctt_reg_table[i++].addr = 0x44e000b4;
prcm_ctt_reg_table[i++].addr = 0x44e000b8;
prcm_ctt_reg_table[i++].addr = 0x44e000bc;
prcm_ctt_reg_table[i++].addr = 0x44e000c0;
prcm_ctt_reg_table[i++].addr = 0x44e000c4;
......@@ -275,10 +288,18 @@ static int ctt_am335x_regtable_init(void)
prcm_ctt_reg_table[i++].addr = 0x44e000f8;
prcm_ctt_reg_table[i++].addr = 0x44e000fc;
prcm_ctt_reg_table[i++].addr = 0x44e00100;
prcm_ctt_reg_table[i++].addr = 0x44e00104;
prcm_ctt_reg_table[i++].addr = 0x44e0010c;
prcm_ctt_reg_table[i++].addr = 0x44e00110;
prcm_ctt_reg_table[i++].addr = 0x44e0011c;
prcm_ctt_reg_table[i++].addr = 0x44e00120;
prcm_ctt_reg_table[i++].addr = 0x44e00124;
prcm_ctt_reg_table[i++].addr = 0x44e00128;
prcm_ctt_reg_table[i++].addr = 0x44e0012c;
prcm_ctt_reg_table[i++].addr = 0x44e00130;
prcm_ctt_reg_table[i++].addr = 0x44e00134;
prcm_ctt_reg_table[i++].addr = 0x44e00138;
prcm_ctt_reg_table[i++].addr = 0x44e0013c;
prcm_ctt_reg_table[i++].addr = 0x44e00140;
prcm_ctt_reg_table[i++].addr = 0x44e00144;
prcm_ctt_reg_table[i++].addr = 0x44e00148;
......@@ -291,10 +312,31 @@ static int ctt_am335x_regtable_init(void)
prcm_ctt_reg_table[i++].addr = 0x44e00410;
prcm_ctt_reg_table[i++].addr = 0x44e00414;
prcm_ctt_reg_table[i++].addr = 0x44e00418;
prcm_ctt_reg_table[i++].addr = 0x44e0041c;
prcm_ctt_reg_table[i++].addr = 0x44e00420;
prcm_ctt_reg_table[i++].addr = 0x44e00424;
prcm_ctt_reg_table[i++].addr = 0x44e00428;
prcm_ctt_reg_table[i++].addr = 0x44e0042c;
prcm_ctt_reg_table[i++].addr = 0x44e00430;
prcm_ctt_reg_table[i++].addr = 0x44e00434;
prcm_ctt_reg_table[i++].addr = 0x44e00438;
prcm_ctt_reg_table[i++].addr = 0x44e0043c;
prcm_ctt_reg_table[i++].addr = 0x44e00440;
prcm_ctt_reg_table[i++].addr = 0x44e00444;
prcm_ctt_reg_table[i++].addr = 0x44e00448;
prcm_ctt_reg_table[i++].addr = 0x44e0044c;
prcm_ctt_reg_table[i++].addr = 0x44e00450;
prcm_ctt_reg_table[i++].addr = 0x44e00454;
prcm_ctt_reg_table[i++].addr = 0x44e00458;
prcm_ctt_reg_table[i++].addr = 0x44e0045c;
prcm_ctt_reg_table[i++].addr = 0x44e00460;
prcm_ctt_reg_table[i++].addr = 0x44e00464;
prcm_ctt_reg_table[i++].addr = 0x44e00468;
prcm_ctt_reg_table[i++].addr = 0x44e0046c;
prcm_ctt_reg_table[i++].addr = 0x44e00470;
prcm_ctt_reg_table[i++].addr = 0x44e00474;
prcm_ctt_reg_table[i++].addr = 0x44e00478;
prcm_ctt_reg_table[i++].addr = 0x44e0047c;
prcm_ctt_reg_table[i++].addr = 0x44e00480;
prcm_ctt_reg_table[i++].addr = 0x44e00484;
prcm_ctt_reg_table[i++].addr = 0x44e00488;
......@@ -338,9 +380,44 @@ static int ctt_am335x_regtable_init(void)
prcm_ctt_reg_table[i++].addr = 0x44e00804;
prcm_ctt_reg_table[i++].addr = 0x44e00900;
prcm_ctt_reg_table[i++].addr = 0x44e00904;
prcm_ctt_reg_table[i++].addr = 0x44e00908;
prcm_ctt_reg_table[i++].addr = 0x44e0090c;
prcm_ctt_reg_table[i++].addr = 0x44e00910;
prcm_ctt_reg_table[i++].addr = 0x44e00914;
prcm_ctt_reg_table[i++].addr = 0x44e00a00;
prcm_ctt_reg_table[i++].addr = 0x44e00a20;
prcm_ctt_reg_table[i++].addr = 0x44e00b00;
prcm_ctt_reg_table[i++].addr = 0x44e00b04;
prcm_ctt_reg_table[i++].addr = 0x44e00b08;
prcm_ctt_reg_table[i++].addr = 0x44e00b0c;
prcm_ctt_reg_table[i++].addr = 0x44e00b10;
prcm_ctt_reg_table[i++].addr = 0x44e00c00;
prcm_ctt_reg_table[i++].addr = 0x44e00c04;
prcm_ctt_reg_table[i++].addr = 0x44e00c08;
prcm_ctt_reg_table[i++].addr = 0x44e00c0c;
prcm_ctt_reg_table[i++].addr = 0x44e00d00;
prcm_ctt_reg_table[i++].addr = 0x44e00d04;
prcm_ctt_reg_table[i++].addr = 0x44e00d08;
prcm_ctt_reg_table[i++].addr = 0x44e00d0c;
prcm_ctt_reg_table[i++].addr = 0x44e00e00;
prcm_ctt_reg_table[i++].addr = 0x44e00e04;
prcm_ctt_reg_table[i++].addr = 0x44e00e08;
prcm_ctt_reg_table[i++].addr = 0x44e00f00;
prcm_ctt_reg_table[i++].addr = 0x44e00f04;
prcm_ctt_reg_table[i++].addr = 0x44e00f08;
prcm_ctt_reg_table[i++].addr = 0x44e00f0c;
prcm_ctt_reg_table[i++].addr = 0x44e00f10;
prcm_ctt_reg_table[i++].addr = 0x44e00f14;
prcm_ctt_reg_table[i++].addr = 0x44e00f18;
prcm_ctt_reg_table[i++].addr = 0x44e00f1c;
prcm_ctt_reg_table[i++].addr = 0x44e01000;
prcm_ctt_reg_table[i++].addr = 0x44e01004;
prcm_ctt_reg_table[i++].addr = 0x44e01100;
prcm_ctt_reg_table[i++].addr = 0x44e01104;
prcm_ctt_reg_table[i++].addr = 0x44e01110;
prcm_ctt_reg_table[i++].addr = 0x44e01114;
prcm_ctt_reg_table[i++].addr = 0x44e01200;
prcm_ctt_reg_table[i++].addr = 0x44e01204;
prcm_ctt_reg_table[i++].addr = 0x44e10040;
prcm_ctt_reg_table[i].addr = 0;
......
This diff is collapsed.
This diff is collapsed.
/*
* @Component OMAPCONF
* @Filename emif_am437x.c
* @Description AM437X EMIF Functions
* @Author Dave Gerlach <d-gerlach@ti.com>
* @Date 2016
* @Copyright Texas Instruments Incorporated
*
* Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <autoadjust_table.h>
#include <cpuinfo.h>
#include <emif_am437x.h>
#include <lib.h>
#include <module.h>
#ifdef EMIF_AM437X_DEBUG
#define dprintf(format, ...) printf(format, ## __VA_ARGS__)
#else
#define dprintf(format, ...)
#endif
/*
* @FUNCTION emif_am437x_mod_name_get
* @BRIEF return EMIF module name
* @RETURNS EMIF module name
* NULL in case of incorrect id
* @param[in] id: EMIF module ID
* @DESCRIPTION return EMIF module name
*/
const char *emif_am437x_mod_name_get(emif_am437x_mod_id id)
{
if (id >= EMIF_AM437X_MODS_COUNT) {
fprintf(stderr, "%s(): id (%u) >= EMIF_AM437X_MODS_COUNT (%u)!\n",
__func__, id, EMIF_AM437X_MODS_COUNT);
return NULL;
}
return emif_am437x_mods_name[id];
}
/*
* @FUNCTION emif_am437x_dump
* @BRIEF dump selected registers
* @RETURNS 0 in case of success
* OMAPCONF_ERR_CPU
* OMAPCONF_ERR_ARG
* @param[in,out] stream: output stream
* @param[in] id: EMIF module ID
* If id == EMIF_AM437X_MODS_COUNT, dump all EMIF registers.
* @DESCRIPTION dump selected registers and pretty-print it in selected
* output stream
*/
int emif_am437x_dump(FILE *stream, emif_am437x_mod_id id)
{
unsigned int i, mid;
unsigned int val;
reg **mod;
reg *r;
char s[TABLE_MAX_ELT_LEN];
char table[TABLE_MAX_ROW][TABLE_MAX_COL][TABLE_MAX_ELT_LEN];
unsigned int row;
if (!cpu_is_am437x())
return OMAPCONF_ERR_CPU;
CHECK_NULL_ARG(stream, OMAPCONF_ERR_ARG);
if (id > EMIF_AM437X_MODS_COUNT) {
fprintf(stderr, "%s(): id (%u) > EMIF_AM437X_MODS_COUNT!!! (%u)\n",
__func__, id, EMIF_AM437X_MODS_COUNT);
return OMAPCONF_ERR_ARG;
}
autoadjust_table_init(table);
row = 0;
if (id != EMIF_AM437X_MODS_COUNT)
snprintf(table[row][0], TABLE_MAX_ELT_LEN, "%s Reg. Name",
emif_am437x_mod_name_get(id));
else
strncpy(table[row][0], "EMIF Reg. Name", TABLE_MAX_ELT_LEN);
strncpy(table[row][1], "Reg. Address", TABLE_MAX_ELT_LEN);
strncpy(table[row][2], "Reg. Value", TABLE_MAX_ELT_LEN);
row++;
for (mid = 0; mid < EMIF_AM437X_MODS_COUNT; mid++) {
if ((id != EMIF_AM437X_MODS_COUNT) && (mid != id)) {
continue;
} else {
mod = emif_am437x_mods[mid];
for (i = 0; mod[i] != NULL; i++) {
r = mod[i];
/* Read register */
dprintf("%s(): read %s 0x%08X\n", __func__,
r->name, r->addr);
val = reg_read(r);
dprintf("%s(): OK\n", __func__);
/* Show register name, addr & content */
snprintf(s, TABLE_MAX_ELT_LEN, "%s", r->name);
autoadjust_table_strncpy(table, row, 0, s);
snprintf(s, TABLE_MAX_ELT_LEN, "0x%08X",
r->addr);
autoadjust_table_strncpy(table, row, 1, s);
snprintf(s, TABLE_MAX_ELT_LEN, "0x%08X", val);
autoadjust_table_strncpy(table, row++, 2, s);
}
}
}
autoadjust_table_print(table, row, 3);
return 0;
}
/*
*
* @Component OMAPCONF
* @Filename emif_am437x.h
* @Description AM437X EMIF Functions
* @Author Dave Gerlach <d-gerlach@ti.com>
* @Date 2016
* @Copyright Texas Instruments Incorporated
*
*
* Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __EMIF_AM437X_H__
#define __EMIF_AM437X_H__
#include <emif_am437x-defs.h>
#include <stdio.h>
const char *emif_am437x_mod_name_get(emif_am437x_mod_id id);
int emif_am437x_dump(FILE *stream, emif_am437x_mod_id id);
#endif /* __EMIF_AM437X_H__ */
......@@ -72,4 +72,17 @@ void help_am437x(help_category cat, char *context)
"Tree Tool (CTT, <http://omappedia.org/wiki/CTT>), to "
"<filename> or stdout if omitted.\n");
}
if ((cat == HELP_ALL) || (cat == HELP_EMIF)) {
printf("\n\tomapconf dump emif\n");
printf("\t Dump EMIF4D registers to stdout\n");
}
if((cat == HELP_ALL) || (cat == HELP_PRCM)) {
printf("\n\tomapconf dump prcm [<pwrdm>]\n");
printf("\t Dump PRCM Registers related to <pwrdm> power "
"domain ('all' assumed if omitted).\n");
printf("\t Support <pwrdm>: all, cefuse, device, gfx, mpu, per, "
"rtc, wkup, irq, dpll\n");
}
}
......@@ -54,6 +54,8 @@
#include <unistd.h>
#include <ctt_am437x.h>
#include <emif_am437x.h>
#include <prcm_am437x.h>
#ifdef MAIN_AM437X_DEBUG
#define dprintf(format, ...) printf(format, ## __VA_ARGS__)
......@@ -61,6 +63,42 @@
#define dprintf(format, ...)
#endif
/*
* @FUNCTION main_am437x_dump
* @BRIEF dump some AM437X registers, which category is found in
* argv
* @RETURNS 0 in case of success
* OMAPCONF_ERR_ARG
* OMAPCONF_ERR_CPU
* @param[in] argc: number of arguments
* @param[in] argv: argument(s)
* @DESCRIPTION dump some AM437X registers, which category is found in
* argv
*/
int main_am437x_dump(int argc, char *argv[])
{
if (!cpu_is_am437x())
return OMAPCONF_ERR_CPU;
if (argc < 1) {
help(HELP_USAGE);
return OMAPCONF_ERR_ARG;
} else if (strcmp(argv[0], "emif") == 0) {
if (argc == 1)
return emif_am437x_dump(stdout, EMIF_AM437X_EMIF4D);
else
return err_arg_too_many_msg_show(HELP_EMIF);
} else if (strcmp(argv[0], "prcm") == 0) {
if (argc == 1)
return prcm_am437x_dump(NULL);
else if (argc == 2)
return prcm_am437x_dump(argv[1]);
else
return err_arg_too_many_msg_show(HELP_PRCM);
} else {
return err_unknown_argument_msg_show(argv[0]);
}
}
/* ------------------------------------------------------------------------*//**
* @FUNCTION main_am437x_export
......@@ -110,7 +148,13 @@ static int main_am437x_legacy(int argc, char*argv[])
ret = err_unknown_argument_msg_show(argv[0]);
}
if (strcmp(argv[0], "ctt") == 0) {
if ((argc == 2) && (strcmp(argv[0], "prcm") == 0) &&
(strcmp(argv[1], "dump") == 0)) {
ret = prcm_am437x_dump(NULL);
} else if ((argc == 3) && (strcmp(argv[0], "prcm") == 0) &&
(strcmp(argv[1], "dump") == 0)) {
ret = prcm_am437x_dump(argv[2]);
} else if (strcmp(argv[0], "ctt") == 0) {
ret = ctt_am437x_main(argc - 1, argv + 1);
} else {
ret = err_unknown_argument_msg_show(argv[0]);
......@@ -151,6 +195,8 @@ int main_am437x(int argc, char *argv[])
if (strcmp(argv[0], "export") == 0)
ret = main_am437x_export(argc - 1, argv + 1);
else if (strcmp(argv[0], "dump") == 0)
ret = main_am437x_dump(argc - 1, argv + 1);
else
ret = main_am437x_legacy(argc, argv);
......
This diff is collapsed.
This diff is collapsed.
/*
*
* @Component OMAPCONF
* @Filename cm_am437x.c
* @Description AM437X CM Register Functions
* @Author Dave Gerlach <d-gerlach@ti.com>
* @Date 2016
* @Copyright Texas Instruments Incorporated
*
*
* Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <autoadjust_table.h>
#include <cm_am437x.h>
#include <cpuinfo.h>
#include <lib.h>
#include <module.h>
#include <prcm-module.h>
#ifdef CM_AM437X_DEBUG
#define dprintf(format, ...) printf(format, ## __VA_ARGS__)
#else
#define dprintf(format, ...)
#endif
/* ------------------------------------------------------------------------*//**
* @FUNCTION cm_am437x_mod_name_get
* @BRIEF return CM module name
* @RETURNS CM module name
* NULL in case of incorrect id
* @param[in] id: CM module ID
* @DESCRIPTION return CM module name
*//*------------------------------------------------------------------------ */
const char *cm_am437x_mod_name_get(cm_am437x_mod_id id)
{
if (id >= CM_AM437X_MODS_COUNT) {
fprintf(stderr, "%s(): id (%u) >= CM_AM437X_MODS_COUNT (%u)!\n",
__func__, id, CM_AM437X_MODS_COUNT);
return NULL;
}
return cm_am437x_mods_name[id];
}
/* ------------------------------------------------------------------------*//**
* @FUNCTION cm_am437x_dump
* @BRIEF dump selected registers
* @RETURNS 0 in case of success
* OMAPCONF_ERR_CPU
* OMAPCONF_ERR_ARG
* @param[in,out] stream: output stream
* @param[in] id: CM module ID
* If id == CM_AM437X_MODS_COUNT, dump all CM registers.
* @DESCRIPTION dump selected registers and pretty-print it in selected
* output stream
*//*------------------------------------------------------------------------ */
int cm_am437x_dump(FILE *stream, cm_am437x_mod_id id)
{
unsigned int i, mid;
unsigned int val;
reg **mod;
reg *r;
char s[TABLE_MAX_ELT_LEN];
char table[TABLE_MAX_ROW][TABLE_MAX_COL][TABLE_MAX_ELT_LEN];
unsigned int row = 0;
if (!cpu_is_am437x())
return OMAPCONF_ERR_CPU;
CHECK_NULL_ARG(stream, OMAPCONF_ERR_ARG);
if (id > CM_AM437X_MODS_COUNT) {
fprintf(stderr, "%s(): id (%u) > CM_AM437X_MODS_COUNT!!! (%u)\n",
__func__, id, CM_AM437X_MODS_COUNT);
return OMAPCONF_ERR_ARG;
}
autoadjust_table_init(table);
if (id != CM_AM437X_MODS_COUNT)
snprintf(table[row][0], TABLE_MAX_ELT_LEN, "%s Reg. Name",
cm_am437x_mod_name_get(id));
else
strncpy(table[row][0], "CM Reg. Name", TABLE_MAX_ELT_LEN);
strncpy(table[row][1], "Reg. Address", TABLE_MAX_ELT_LEN);
strncpy(table[row][2], "Reg. Value", TABLE_MAX_ELT_LEN);
row++;
for (mid = 0; mid < CM_AM437X_MODS_COUNT; mid++) {
if ((id != CM_AM437X_MODS_COUNT) && (mid != id)) {
continue;
} else {
mod = cm_am437x_mods[mid];
for (i = 0; mod[i] != NULL; i++) {
r = mod[i];
/* Read register */
dprintf("%s(): read %s 0x%08X\n", __func__,
r->name, r->addr);
val = reg_read(r);
dprintf("%s(): OK\n", __func__);
/* Show register name, addr & content */
snprintf(s, TABLE_MAX_ELT_LEN, "%s", r->name);
autoadjust_table_strncpy(table, row, 0, s);
snprintf(s, TABLE_MAX_ELT_LEN, "0x%08X",
r->addr);
autoadjust_table_strncpy(table, row, 1, s);
snprintf(s, TABLE_MAX_ELT_LEN, "0x%08X", val);
autoadjust_table_strncpy(table, row++, 2, s);
}
}
}
autoadjust_table_print(table, row, 3);
return 0;
}
/*
*
* @Component OMAPCONF
* @Filename cm_am437x.h
* @Description AM437x CM Register Functions
* @Author Dave Gerlach <d-gerlach@ti.com>
* @Date 2016
* @Copyright Texas Instruments Incorporated
*
*
* Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,