Skip to content

Commit

Permalink
[AM335X][PRCM] Add prcm dump support
Browse files Browse the repository at this point in the history
Add functions to dump each prm and cm module according to power
domain. Option to dump all prcm registers. Although not technically a
power domain, prcm device registers can also be dumped.

Signed-off-by: Gilberto Rodriguez <gilrod@ti.com>
Signed-off-by: Nishanth Menon <nm@ti.com>
  • Loading branch information
gilbert-r3 authored and nmenon committed Jul 31, 2014
1 parent fadc4ae commit b71c5f5
Show file tree
Hide file tree
Showing 5 changed files with 334 additions and 2 deletions.
1 change: 1 addition & 0 deletions Makefile
Expand Up @@ -268,6 +268,7 @@ AM335XSOURCES=\
arch/arm/mach-omap/am335x/prcm/cm_am335x.c\
arch/arm/mach-omap/am335x/prcm/prm_am335x-defs.c\
arch/arm/mach-omap/am335x/prcm/prm_am335x.c\
arch/arm/mach-omap/am335x/prcm/prcm_am335x.c\

AM335XOBJECTS= $(AM335XSOURCES:.c=.o)

Expand Down
8 changes: 8 additions & 0 deletions arch/arm/mach-omap/am335x/help_am335x.c
Expand Up @@ -78,4 +78,12 @@ void help_am335x(help_category cat, char *context)
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, dev, efuse, gfx, mpu, per, "
"rtc, wkup\n");
}
}
18 changes: 16 additions & 2 deletions arch/arm/mach-omap/am335x/main_am335x.c
Expand Up @@ -49,6 +49,7 @@
#include <lib.h>
#include <main_am335x.h>
#include <opp.h>
#include <prcm_am335x.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -88,7 +89,14 @@ int main_am335x_dump(int argc, char *argv[])
return emif_am335x_dump(stdout, EMIF_AM335X_EMIF4D);
else
return err_arg_too_many_msg_show(HELP_EMIF);
} else {
} else if (strcmp(argv[0], "prcm") == 0) {
if (argc == 1)
return prcm_am335x_dump(NULL);
else if (argc == 2)
return prcm_am335x_dump(argv[1]);
else
return err_arg_too_many_msg_show(HELP_PRCM);
} else {
return err_unknown_argument_msg_show(argv[0]);
}
}
Expand Down Expand Up @@ -138,7 +146,13 @@ static int main_am335x_legacy(int argc, char*argv[])
{
int ret;

if (strcmp(argv[0], "ctt") == 0) {
if ((argc == 2) && (strcmp(argv[0], "prcm") == 0) &&
(strcmp(argv[1], "dump") == 0)) {
ret = prcm_am335x_dump(NULL);
} else if ((argc == 3) && (strcmp(argv[0], "prcm") == 0) &&
(strcmp(argv[1], "dump") == 0)) {
ret = prcm_am335x_dump(argv[2]);
} else if (strcmp(argv[0], "ctt") == 0) {
ret = ctt_am335x_main(argc - 1, argv + 1);
} else {
ret = err_unknown_argument_msg_show(argv[0]);
Expand Down
254 changes: 254 additions & 0 deletions arch/arm/mach-omap/am335x/prcm/prcm_am335x.c
@@ -0,0 +1,254 @@
/*
*
* @Component OMAPCONF
* @Filename prcm_am335x.c
* @Description OMAPCONF PRCM AM335X Main file
* @Author Gilberto Rodriguez <gilrod@ti.com>
* @Date 2014
* @Copyright Texas Instruments Incorporated
*
*
* Copyright (C) 2014 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 <clockdomain.h>
#include <cm_am335x.h>
#include <cpuinfo.h>
#include <help.h>
#include <lib.h>
#include <module.h>
#include <powerdomain.h>
#include <prcm_am335x.h>
#include <prm_am335x.h>
#include <string.h>


#ifdef PRCM_AM335X_DEBUG
#define dprintf(format, ...) printf(format, ## __VA_ARGS__)
#else
#define dprintf(format, ...)
#endif


/* ------------------------------------------------------------------------*//**
* @FUNCTION _prcm_am335x_wkup_dump
* @BRIEF dump WKUP PRCM registers and pretty-print it
* @RETURNS 0 in case of success
* OMAPCONF_ERR_CPU
* OMAPCONF_ERR_ARG
* OMAPCONF_ERR_REG_ACCESS
* @param[in,out] stream: output stream
* @DESCRIPTION dump WKUP PRCM registers and pretty-print it
*//*------------------------------------------------------------------------ */
static inline int _prcm_am335x_wkup_dump(FILE *stream)
{
int ret;

ret = prm_am335x_dump(stream, PRM_AM335X_PRM_WKUP);
if (ret != 0)
return ret;
return cm_am335x_dump(stream, CM_AM335X_CM_WKUP);
}


/* ------------------------------------------------------------------------*//**
* @FUNCTION _prcm_am335x_mpu_dump
* @BRIEF dump MPU PRCM registers and pretty-print it
* @RETURNS 0 in case of success
* OMAPCONF_ERR_CPU
* OMAPCONF_ERR_ARG
* OMAPCONF_ERR_REG_ACCESS
* @param[in,out] stream: output stream
* @DESCRIPTION dump MPU PRCM registers and pretty-print it
*//*------------------------------------------------------------------------ */
static inline int _prcm_am335x_mpu_dump(FILE *stream)
{
int ret;

ret = prm_am335x_dump(stream, PRM_AM335X_PRM_MPU);
if (ret != 0)
return ret;
return cm_am335x_dump(stream, CM_AM335X_CM_MPU);
}


/* ------------------------------------------------------------------------*//**
* @FUNCTION _prcm_am335x_gfx_dump
* @BRIEF dump GFX PRCM registers and pretty-print it
* @RETURNS 0 in case of success
* OMAPCONF_ERR_CPU
* OMAPCONF_ERR_ARG
* OMAPCONF_ERR_REG_ACCESS
* @param[in,out] stream: output stream
* @DESCRIPTION dump GFX PRCM registers and pretty-print it
*//*------------------------------------------------------------------------ */
static inline int _prcm_am335x_gfx_dump(FILE *stream)
{
int ret;

ret = prm_am335x_dump(stream, PRM_AM335X_PRM_GFX);
if (ret != 0)
return ret;
return cm_am335x_dump(stream, CM_AM335X_CM_GFX);
}


/* ------------------------------------------------------------------------*//**
* @FUNCTION _prcm_am335x_per_dump
* @BRIEF dump PER PRCM registers and pretty-print it
* @RETURNS 0 in case of success
* OMAPCONF_ERR_CPU
* OMAPCONF_ERR_ARG
* OMAPCONF_ERR_REG_ACCESS
* @param[in,out] stream: output stream
* @DESCRIPTION dump PER PRCM registers and pretty-print it
*//*------------------------------------------------------------------------ */
static inline int _prcm_am335x_per_dump(FILE *stream)
{
int ret;

ret = prm_am335x_dump(stream, PRM_AM335X_PRM_PER);
if (ret != 0)
return ret;
return cm_am335x_dump(stream, CM_AM335X_CM_PER);
}


/* ------------------------------------------------------------------------*//**
* @FUNCTION _prcm_am335x_rtc_dump
* @BRIEF dump RTC PRCM registers and pretty-print it
* @RETURNS 0 in case of success
* OMAPCONF_ERR_CPU
* OMAPCONF_ERR_ARG
* OMAPCONF_ERR_REG_ACCESS
* @param[in,out] stream: output stream
* @DESCRIPTION dump RTC PRCM registers and pretty-print it
*//*------------------------------------------------------------------------ */
static inline int _prcm_am335x_rtc_dump(FILE *stream)
{
int ret;

ret = prm_am335x_dump(stream, PRM_AM335X_PRM_RTC);
if (ret != 0)
return ret;
return cm_am335x_dump(stream, CM_AM335X_CM_RTC);
}


/* ------------------------------------------------------------------------*//**
* @FUNCTION _prcm_am335x_efuse_dump
* @BRIEF dump efuse PRCM registers and pretty-print it
* @RETURNS 0 in case of success
* OMAPCONF_ERR_CPU
* OMAPCONF_ERR_ARG
* OMAPCONF_ERR_REG_ACCESS
* @param[in,out] stream: output stream
* @DESCRIPTION dump MPU PRCM registers and pretty-print it
*//*------------------------------------------------------------------------ */
static inline int _prcm_am335x_efuse_dump(FILE *stream)
{
int ret;

ret = prm_am335x_dump(stream, PRM_AM335X_PRM_CEFUSE);
if (ret != 0)
return ret;
return cm_am335x_dump(stream, CM_AM335X_CM_CEFUSE);
}


/* ------------------------------------------------------------------------*//**
* @FUNCTION _prcm_am335x_dev_dump
* @BRIEF dump DEVICE PRCM registers and pretty-print it
* @RETURNS 0 in case of success
* OMAPCONF_ERR_CPU
* OMAPCONF_ERR_ARG
* OMAPCONF_ERR_REG_ACCESS
* @param[in,out] stream: output stream
* @DESCRIPTION dump DEVICE PRCM registers and pretty-print it
*//*------------------------------------------------------------------------ */
static inline int _prcm_am335x_dev_dump(FILE *stream)
{
int ret;

ret = prm_am335x_dump(stream, PRM_AM335X_PRM_DEVICE);
if (ret != 0)
return ret;
return cm_am335x_dump(stream, CM_AM335X_CM_DEVICE);
}


/* ------------------------------------------------------------------------*//**
* @FUNCTION prcm_am335x_dump
* @BRIEF dump (formated in table) PRCM registers related to power
* domain provided in string s.
* @RETURNS 0 in case of success
* OMAPCONF_ERR_CPU
* OMAPCONF_ERR_ARG
* OMAPCONF_ERR_REG_ACCESS
* @param[in] s: power domain
* @DESCRIPTION dump (formated in table) PRCM registers related to power
* domain provided in string s.
*//*------------------------------------------------------------------------ */
int prcm_am335x_dump(char *s)
{
int ret = 0;

if ((s == NULL) || (strcmp(s, "all") == 0)) {
/* ALL */
ret = _prcm_am335x_per_dump(stdout);
ret |= _prcm_am335x_wkup_dump(stdout);
ret |= _prcm_am335x_mpu_dump(stdout);
ret |= _prcm_am335x_dev_dump(stdout);
ret |= _prcm_am335x_rtc_dump(stdout);
ret |= _prcm_am335x_gfx_dump(stdout);
ret |= _prcm_am335x_efuse_dump(stdout);
return ret;
} else if (strcmp(s, "wkup") == 0) {
return _prcm_am335x_wkup_dump(stdout);
} else if (strcmp(s, "mpu") == 0) {
return _prcm_am335x_mpu_dump(stdout);
} else if (strcmp(s, "gfx") == 0) {
return _prcm_am335x_gfx_dump(stdout);
} else if (strcmp(s, "per") == 0) {
return _prcm_am335x_per_dump(stdout);
} else if (strcmp(s, "rtc") == 0) {
return _prcm_am335x_rtc_dump(stdout);
} else if (strcmp(s, "efuse") == 0) {
return _prcm_am335x_efuse_dump(stdout);
} else if (strcmp(s, "dev") == 0) {
return _prcm_am335x_dev_dump(stdout);
} else {
return err_arg_msg_show(HELP_PRCM);
}
}
55 changes: 55 additions & 0 deletions arch/arm/mach-omap/am335x/prcm/prcm_am335x.h
@@ -0,0 +1,55 @@
/*
*
* @Component OMAPCONF
* @Filename prcm_am335x.h
* @Description OMAPCONF PRCM AM335X Main file
* @Author Gilberto Rodriguez <gilrod@ti.com>
* @Date 2014
* @Copyright Texas Instruments Incorporated
*
*
* Copyright (C) 2014 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 __PRCM_AM335X_H__
#define __PRCM_AM335X_H__


#include <stdio.h>


int prcm_am335x_dump(char *s);


#endif

0 comments on commit b71c5f5

Please sign in to comment.