Commit df02638f authored by Dave Gerlach's avatar Dave Gerlach Committed by Nishanth Menon

[AM437x][EMIF] Add support for dump EMIF

Add EMIF register functions to implement the dump EMIF command in
omapconf for AM437X.
Signed-off-by: default avatarDave Gerlach <d-gerlach@ti.com>
Signed-off-by: default avatarNishanth Menon <nm@ti.com>
parent d67b7496
......@@ -298,7 +298,9 @@ 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\
AM437XOBJECTS= $(AM437XSOURCES:.c=.o)
......
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,9 @@ 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");
}
}
......@@ -54,6 +54,7 @@
#include <unistd.h>
#include <ctt_am437x.h>
#include <emif_am437x.h>
#ifdef MAIN_AM437X_DEBUG
#define dprintf(format, ...) printf(format, ## __VA_ARGS__)
......@@ -61,6 +62,35 @@
#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 {
return err_unknown_argument_msg_show(argv[0]);
}
}
/* ------------------------------------------------------------------------*//**
* @FUNCTION main_am437x_export
......@@ -151,6 +181,8 @@ int main_am437x(int argc, char *argv[])
if (strcmp(argv[0], "export") == 0)
ret = main_am437x_export(argc - 1, argv + 1);
if (strcmp(argv[0], "dump") == 0)
ret = main_am437x_dump(argc - 1, argv + 1);
else
ret = main_am437x_legacy(argc, argv);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment