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

[AM437x][CM] Add register definitions and register access support

Add all AM437X CM register definitions and appropriate accessors
functions for use by 'dump prcm' command.
Signed-off-by: default avatarDave Gerlach <d-gerlach@ti.com>
Signed-off-by: default avatarNishanth Menon <nm@ti.com>
parent df02638f
......@@ -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
......@@ -301,6 +302,8 @@ AM437XSOURCES=\
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
AM437XOBJECTS= $(AM437XSOURCES:.c=.o)
......
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,
* 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 __CM_AM437X_H__
#define __CM_AM437X_H__
#include <cm_am437x-defs.h>
#include <stdio.h>
#include <string.h>
const char *cm_am437x_mod_name_get(cm_am437x_mod_id id);
int cm_am437x_dump(FILE *stream, cm_am437x_mod_id id);
int cm_am437x_name2addr(char *name, unsigned int *addr);
#endif
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