Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[OMAP5][MODULE] make "show opp" and "show pwst" use new generic frame…

…works

Define generic low level functions in prcm-module.h to handle PRCM register bitfields
dedicated to modules.
Define generic functions in module.h to call these functions with device-specific addresses.
Create module_status_show() to replace lib54xx_pwst_show().
Update opp_show() to use new generic libs.

Signed-off-by: Patrick Titiano <p-titiano@ti.com>
  • Loading branch information...
commit 614787c45f45709f6bdf6cad266bb9860a499eb7 1 parent 5ace350
Patrick Titiano authored
View
816 arch/arm/mach-omap/common/module.c
@@ -49,6 +49,7 @@
#include <module54xx.h>
#include <cpuinfo.h>
#include <opp.h>
+#include <voltdomain.h>
/* #define MODULE_DEBUG */
@@ -60,11 +61,11 @@
/* ------------------------------------------------------------------------*//**
- * @FUNCTION mod_init
+ * @FUNCTION module_init
* @BRIEF initialize internal data
* @DESCRIPTION initialize internal data (architecture dependent)
*//*------------------------------------------------------------------------ */
-void mod_init(void)
+void module_init(void)
{
#ifdef MODULE_DEBUG
int i, j, count, count_opp;
@@ -83,7 +84,7 @@ void mod_init(void)
}
#ifdef MODULE_DEBUG
- mod_list = mod_list_get();
+ mod_list = module_list_get();
count = genlist_getcount((genlist *) mod_list);
printf("Module List:\n");
for (i = 0; i < count; i++) {
@@ -113,12 +114,12 @@ void mod_init(void)
/* ------------------------------------------------------------------------*//**
- * @FUNCTION mod_deinit
+ * @FUNCTION module_deinit
* @BRIEF free dynamically allocated internal data.
* @DESCRIPTION free dynamically allocated internal data.
* MUST BE CALLED AT END OF EXECUTION.
*//*------------------------------------------------------------------------ */
-void mod_deinit(void)
+void module_deinit(void)
{
if (cpu_is_omap44xx()) {
mod44xx_deinit();
@@ -132,13 +133,13 @@ void mod_deinit(void)
/* ------------------------------------------------------------------------*//**
- * @FUNCTION mod_list_get
+ * @FUNCTION module_list_get
* @BRIEF return the list of modules
* @RETURNS list of modules in case of success
* NULL in case of error
* @DESCRIPTION return the list of modules
*//*------------------------------------------------------------------------ */
-const genlist *mod_list_get(void)
+const genlist *module_list_get(void)
{
if (cpu_is_omap44xx()) {
return mod44xx_list_get();
@@ -153,14 +154,14 @@ const genlist *mod_list_get(void)
/* ------------------------------------------------------------------------*//**
- * @FUNCTION mod_count_get
+ * @FUNCTION module_count_get
* @BRIEF return the number of modules
* @RETURNS number of modules (> 0) in case of success
* OMAPCONF_ERR_CPU
* OMAPCONF_ERR_ARG
* @DESCRIPTION return the number of modules
*//*------------------------------------------------------------------------ */
-int mod_count_get(void)
+int module_count_get(void)
{
if (cpu_is_omap44xx()) {
return mod44xx_count_get();
@@ -172,3 +173,800 @@ int mod_count_get(void)
return OMAPCONF_ERR_CPU;
}
}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION _module_info_get
+ * @BRIEF return the saved informations of a given module.
+ * @RETURNS 0 in case of success
+ * -1 in case of error
+ * @param[in] mod: module name
+ * @param[in,out] data: module details
+ * @DESCRIPTION return the saved informations of a given module.
+ *//*------------------------------------------------------------------------ */
+static int _module_info_get(const char *mod, mod_info *data)
+{
+ const genlist *mod_list;
+ int i, count;
+
+ CHECK_NULL_ARG(mod, -1);
+ CHECK_NULL_ARG(data, -1);
+
+ mod_list = module_list_get();
+ count = genlist_getcount((genlist *) mod_list);
+ for (i = 0; i < count; i++) {
+ genlist_get((genlist *) mod_list, i, (void *) data);
+ if (strcmp(data->name, mod) == 0) {
+ dprintf("%s(%s): found.\n", __func__, mod);
+ return 0;
+ }
+ }
+
+ dprintf("%s(%s): not found!\n", __func__, mod);
+ return -1;
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION module_id_get
+ * @BRIEF return the unique ID of a given module.
+ * @RETURNS >= 0 module ID
+ * -1 in case of error
+ * @param[in] mod: module name
+ * @DESCRIPTION return the unique ID of a given module.
+ *//*------------------------------------------------------------------------ */
+int module_id_get(const char *mod)
+{
+ int id;
+ mod_info data;
+
+ CHECK_NULL_ARG(mod, -1);
+
+ id = _module_info_get(mod, &data);
+ if (id == 0)
+ id = data.id;
+
+ dprintf("%s(%s) = %d\n", __func__, mod, id);
+ return id;
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION module_is_accessible
+ * @BRIEF check omap module's registers accessibility
+ * @RETURNS 1 if omap module's registers accessible
+ * 0 if omap module's registers NOT accessible
+ * (or in case of error)
+ * @param[in] mod: module name
+ * @DESCRIPTION check omap module's registers accessibility
+ *//*------------------------------------------------------------------------ */
+unsigned short int module_is_accessible(const char *mod)
+{
+ int ret;
+ mod_info data;
+ unsigned int cm_clkctrl;
+
+ CHECK_NULL_ARG(mod, 0);
+
+ ret = _module_info_get(mod, &data);
+ if (ret != 0) {
+ dprintf("%s(%s): could not retrieve mod_info struct!\n",
+ __func__, mod);
+ return 0;
+ }
+
+ if (data.clkctrl == NULL) {
+ dprintf("%s(%s): cm_clkctrl_reg == NULL!!!\n", __func__, mod);
+ return 0;
+ }
+
+ cm_clkctrl = reg_read(data.clkctrl);
+ dprintf("%s(%s) = %d\n", __func__, mod, mod_is_accessible(cm_clkctrl));
+ return mod_is_accessible(cm_clkctrl);
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION module_mode_get
+ * @BRIEF retrieve module mode from CM register
+ * @RETURNS module mode on success
+ * MOD_MODULE_MODE_MAX in case of error or not available
+ * @param[in] mod: module name
+ * @DESCRIPTION retrieve module mode from CM register
+ *//*------------------------------------------------------------------------ */
+mod_module_mode module_mode_get(const char *mod)
+{
+ int ret;
+ mod_info data;
+ unsigned int cm_clkctrl;
+ mod_module_mode mmode;
+
+ CHECK_NULL_ARG(mod, MOD_MODULE_MODE_MAX);
+
+ ret = _module_info_get(mod, &data);
+ if (ret != 0) {
+ dprintf("%s(%s): could not retrieve mod_info struct!\n",
+ __func__, mod);
+ mmode = MOD_MODULE_MODE_MAX;
+ } else if (data.clkctrl == NULL) {
+ /* Module is not SW-Controlled via PRCM */
+ dprintf("%s(%s): CM_CLKCTRL ADDR = NULL\n", __func__, mod);
+ mmode = MOD_MODULE_MODE_MAX;
+ } else {
+ /* Retrieve module mode */
+ cm_clkctrl = reg_read(data.clkctrl);
+ mmode = mod_module_mode_get(cm_clkctrl);
+ }
+
+ dprintf("%s(%s) = %s\n", __func__, mod,
+ mod_module_mode_name_get(mmode));
+ return mmode;
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION module_autoidle_mode_get
+ * @BRIEF retrieve module autoidle mode
+ * @RETURNS module autoidle mode
+ * MOD_AUTOIDLE_MODE_MAX in case of error
+ * @param[in] mod: module name
+ * @DESCRIPTION retrieve module autoidle mode
+ *//*------------------------------------------------------------------------ */
+mod_autoidle_mode module_autoidle_mode_get(const char *mod)
+{
+ int ret;
+ mod_info data;
+ unsigned int sysconfig;
+ mod_autoidle_mode mode;
+
+ CHECK_NULL_ARG(mod, MOD_AUTOIDLE_MODE_MAX);
+
+ ret = _module_info_get(mod, &data);
+ if (ret != 0) {
+ dprintf("%s(%s): could not retrieve mod_info struct!\n",
+ __func__, mod);
+ mode = MOD_AUTOIDLE_MODE_MAX;
+ } else if (data.sysconfig == NULL) {
+ dprintf("%s(%s): sysconfig == NULL!!!\n", __func__, mod);
+ mode = MOD_AUTOIDLE_MODE_MAX;
+ } else if (!module_is_accessible(mod)) {
+ dprintf("%s(%s): module is not accessible.\n", __func__, mod);
+ mode = MOD_AUTOIDLE_MODE_MAX;
+ } else {
+ sysconfig = reg_read(data.sysconfig);
+ mode = mod_autoidle_mode_get(sysconfig, data.properties);
+ dprintf("%s(%s)=%u (%s)\n", __func__, mod, mode,
+ mod_autoidle_mode_name_get(mode));
+ }
+
+ return mode;
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION module_idle_mode_get
+ * @BRIEF retrieve omap module's idle mode
+ * @RETURNS module's idle mode
+ * MOD_IDLE_MODE_MAX in case of error
+ * @param[in] mod: module name
+ * @DESCRIPTION retrieve omap module's idle mode
+ *//*------------------------------------------------------------------------ */
+mod_idle_mode module_idle_mode_get(const char *mod)
+{
+ int ret;
+ mod_info data;
+ unsigned int sysconfig;
+ mod_idle_mode mode;
+
+ CHECK_NULL_ARG(mod, MOD_IDLE_MODE_MAX);
+
+ ret = _module_info_get(mod, &data);
+ if (ret != 0) {
+ dprintf("%s(%s): could not retrieve mod_info struct!\n",
+ __func__, mod);
+ mode = MOD_IDLE_MODE_MAX;
+ } else if (data.sysconfig == NULL) {
+ dprintf("%s(%s): sysconfig == NULL!!!\n", __func__, mod);
+ mode = MOD_IDLE_MODE_MAX;
+ } else if (!module_is_accessible(mod)) {
+ dprintf("%s(%s): module is not accessible.\n", __func__, mod);
+ mode = MOD_IDLE_MODE_MAX;
+ } else {
+ sysconfig = reg_read(data.sysconfig);
+ mode = mod_idle_mode_get(sysconfig, data.properties);
+ dprintf("%s(%s)=%u (%s)\n", __func__, mod, mode,
+ mod_idle_mode_name_get(mode));
+ }
+
+ return mode;
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION module_idle_status_get
+ * @BRIEF retrieve module's idle status from CM_xxx_xxx_CLKCTRL
+ * @RETURNS module idle status
+ * MOD_IDLE_STATUS_MAX in case of error
+ * @param[in] mod: module name
+ * @DESCRIPTION retrieve module's idle status from CM_xxx_xxx_CLKCTRL
+ *//*------------------------------------------------------------------------ */
+mod_idle_status module_idle_status_get(const char *mod)
+{
+ int ret;
+ mod_info data;
+ unsigned int clkctrl;
+ mod_idle_status mstatus;
+
+ CHECK_NULL_ARG(mod, MOD_IDLE_STATUS_MAX);
+
+ ret = _module_info_get(mod, &data);
+ if (ret != 0) {
+ dprintf("%s(%s): could not retrieve mod_info struct!\n",
+ __func__, mod);
+ mstatus = MOD_IDLE_STATUS_MAX;
+ } else if (data.clkctrl == NULL) {
+ dprintf("%s(%s): clkctrl == NULL!!!\n", __func__, mod);
+ mstatus = MOD_IDLE_STATUS_MAX;
+ } else {
+ clkctrl = reg_read(data.clkctrl);
+ mstatus = mod_idle_status_get(clkctrl, data.properties);
+ dprintf("%s(%s)=%u (%s)\n", __func__, mod, mstatus,
+ mod_idle_status_name_get(mstatus));
+ }
+
+ return mstatus;
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION module_standby_mode_get
+ * @BRIEF retrieve omap module's standby mode
+ * @RETURNS module's standby mode
+ * MOD_STANDBY_MODE_MAX in case of error
+ * @param[in] mod: module name
+ * @DESCRIPTION retrieve omap module's standby mode
+ *//*------------------------------------------------------------------------ */
+mod_standby_mode module_standby_mode_get(const char *mod)
+{
+ int ret;
+ mod_info data;
+ unsigned int sysconfig;
+ mod_standby_mode mode;
+
+ CHECK_NULL_ARG(mod, MOD_STANDBY_MODE_MAX);
+
+ ret = _module_info_get(mod, &data);
+ if (ret != 0) {
+ dprintf("%s(%s): could not retrieve mod_info struct!\n",
+ __func__, mod);
+ return MOD_STANDBY_MODE_MAX;
+ } else if (data.sysconfig == NULL) {
+ dprintf("%s(%s): sysconfig == NULL!!!\n", __func__, mod);
+ mode = MOD_STANDBY_MODE_MAX;
+ } else if (!module_is_accessible(mod)) {
+ dprintf("%s(%s): module is not accessible.\n", __func__, mod);
+ return MOD_STANDBY_MODE_MAX;
+ } else {
+ sysconfig = reg_read(data.sysconfig);
+ mode = mod_standby_mode_get(sysconfig, data.properties);
+ dprintf("%s(%s)=%u (%s)\n", __func__, mod, mode,
+ mod_standby_mode_name_get(mode));
+ }
+
+ return mode;
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION module_standby_status_get
+ * @BRIEF retrieve module standby status from CM_xxx_xxx_CLKCTRL
+ * @RETURNS module standby status
+ * MOD_STANDBY_STATUS_MAX in case of error
+ * @param[in] mod: module name
+ * @DESCRIPTION retrieve module standby status from CM_xxx_xxx_CLKCTRL
+ *//*------------------------------------------------------------------------ */
+mod_standby_status module_standby_status_get(const char *mod)
+{
+ int ret;
+ mod_info data;
+ unsigned int clkctrl;
+ mod_standby_status mstatus;
+
+ CHECK_NULL_ARG(mod, MOD_STANDBY_STATUS_MAX);
+
+ ret = _module_info_get(mod, &data);
+ if (ret != 0) {
+ dprintf("%s(%s): could not retrieve mod_info struct!\n",
+ __func__, mod);
+ return MOD_STANDBY_STATUS_MAX;
+ } else if (data.clkctrl == NULL) {
+ dprintf("%s(%s): clkctrl == NULL!!!\n", __func__, mod);
+ mstatus = MOD_STANDBY_STATUS_MAX;
+ } else {
+ clkctrl = reg_read(data.clkctrl);
+ mstatus = mod_standby_status_get(clkctrl, data.properties);
+ dprintf("%s(%s)=%u (%s)\n", __func__, mod, mstatus,
+ mod_standby_status_name_get(mstatus));
+ }
+
+ return mstatus;
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION module_context_is_lost
+ * @BRIEF check if module's context was retained or lost
+ * during last power transition
+ * @RETURNS 1 if module's context was LOST during last power
+ * transition (or in case of error)
+ * 0 if module's context was RETAINED during last power
+ * transition
+ * -1 in case of error or module has no context register
+ * @param[in] mod: module name
+ * @DESCRIPTION check if module's context was retained or lost
+ * during last power transition
+ *//*------------------------------------------------------------------------ */
+int module_context_is_lost(const char *mod)
+{
+ int ret;
+ mod_info data;
+ unsigned int rm_context;
+ unsigned short lost;
+
+ CHECK_NULL_ARG(mod, -1);
+
+ ret = _module_info_get(mod, &data);
+ if (ret != 0) {
+ dprintf("%s(%s): could not retrieve mod_info struct!\n",
+ __func__, mod);
+ lost = -1;
+ } else if (data.context == NULL) {
+ dprintf("%s(%s): RM_CONTEXT addr==NULL\n", __func__, mod);
+ lost = -1;
+ } else {
+ rm_context = reg_read(data.context);
+ lost = mod_context_is_lost(rm_context);
+ dprintf("%s(%s)=%d\n", __func__, mod, lost);
+ }
+
+ return lost;
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION module_clock_activity_mode_get
+ * @BRIEF retrieve omap module's clock activity mode
+ * @RETURNS module's clock activity mode
+ * MOD_CLOCK_ACTIVITY_MODE_MAX in case of error
+ * @param[in] mod: module name
+ * @DESCRIPTION retrieve omap module's clock activity mode
+ *//*------------------------------------------------------------------------ */
+mod_clock_activity_mode module_clock_activity_mode_get(const char *mod)
+{
+ int ret;
+ mod_info data;
+ unsigned int sysconfig;
+ mod_clock_activity_mode mode;
+
+ CHECK_NULL_ARG(mod, MOD_CLOCK_ACTIVITY_MODE_MAX);
+
+ ret = _module_info_get(mod, &data);
+ if (ret != 0) {
+ dprintf("%s(%s): could not retrieve mod_info struct!\n",
+ __func__, mod);
+ return MOD_CLOCK_ACTIVITY_MODE_MAX;
+ } else if (data.sysconfig == NULL) {
+ dprintf("%s(%s): sysconfig == NULL!!!\n", __func__, mod);
+ mode = MOD_CLOCK_ACTIVITY_MODE_MAX;
+ } else if (!module_is_accessible(mod)) {
+ dprintf("%s(%s): module is not accessible.\n", __func__, mod);
+ mode = MOD_CLOCK_ACTIVITY_MODE_MAX;
+ } else {
+ sysconfig = reg_read(data.sysconfig);
+ mode = mod_clock_activity_mode_get(sysconfig, data.properties);
+ dprintf("%s(%s)=%u (%s)\n", __func__, mod, mode,
+ mod_clock_activity_mode_name_get(mode));
+
+
+ }
+
+ return mode;
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION module_por_clk_rate_get
+ * @BRIEF return the recommended module functional clock rate,
+ * in KHz, for a given OPerating Point (OPP),
+ * as defined in Data Manual.
+ * @RETURNS module recommended functional clock rate, in KHz.
+ * OMAPCONF_ERR_CPU
+ * OMAPCONF_ERR_ARG
+ * OMAPCONF_ERR_NOT_AVAILABLE
+ * @param[in] mod: module name, as defined in module.h
+ * @DESCRIPTION return the recommended module functional clock rate,
+ * in KHz, for a given OPerating Point (OPP),
+ * as defined in Data Manual.
+ *//*------------------------------------------------------------------------ */
+int module_por_clk_rate_get(const char *mod, const char *opp)
+{
+ mod_info data;
+ mod_opp data_opp;
+ int ret, i, opp_count, rate_khz;
+
+ CHECK_NULL_ARG(mod, OMAPCONF_ERR_ARG);
+
+ ret = _module_info_get(mod, &data);
+ if (ret != 0) {
+ dprintf("%s(%s): could not retrieve mod_info struct!\n",
+ __func__, mod);
+ rate_khz = OMAPCONF_ERR_NOT_AVAILABLE;
+ goto module_por_clk_rate_get_end;
+ }
+
+ opp_count = genlist_getcount((genlist *) &(data.mod_opp_list));
+ for (i = 0; i < opp_count; i++) {
+ genlist_get(&(data.mod_opp_list), i,
+ (mod_opp *) &data_opp);
+ if (strcmp(data_opp.name, opp) != 0)
+ continue;
+
+ /* Module OPP details found */
+ rate_khz = data_opp.rate;
+ goto module_por_clk_rate_get_end;
+ }
+
+ dprintf("%s(%s): Module OPP details could not be found!\n",
+ __func__, opp);
+ rate_khz = OMAPCONF_ERR_NOT_AVAILABLE;
+
+
+
+
+#if 0
+ opp_id = opp_s2id(opp);
+ if (opp_id < 0) {
+ dprintf("%s(%s): could not retrieve OPP ID! (%d)\n",
+ __func__, mod, opp_id);
+ rate_khz = opp_id;
+ goto mod_por_clk_rate_get_end;
+ }
+
+ if (cpu_is_omap44xx()) {
+ ret = mod44xx_get_por_clk_speed((mod44xx_id) mod_id,
+ (unsigned short) opp_id, &rate_mhz);
+ if (ret < 0) {
+ dprintf(
+ "%s(%s): could not retrieve module POR rate! (%d)\n",
+ __func__, mod, ret);
+ rate_khz = ret;
+ } else {
+ rate_khz = mhz2khz(rate_mhz);
+ }
+ } else if (cpu_is_omap54xx()) {
+ rate_mhz = mod54xx_por_clk_rate_get(
+ (mod54xx_id) mod_id, (opp54xx_id) opp_id);
+ if (rate_mhz < 0) {
+ rate_khz = (int) rate_mhz;
+ dprintf(
+ "%s(%s): could not retrieve module POR rate! (%d)\n",
+ __func__, mod, rate_khz);
+ } else {
+ rate_khz = mhz2khz(rate_mhz);
+ }
+ } else {
+ fprintf(stderr, "omapconf: %s(): cpu not supported!!!\n",
+ __func__);
+ rate_khz = OMAPCONF_ERR_CPU;
+ }
+#endif
+
+
+module_por_clk_rate_get_end:
+ dprintf("%s(%s) = %d KHz\n", __func__, mod, rate_khz);
+ return rate_khz;
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION module_clk_rate_get
+ * @BRIEF return the module functional clock rate, in KHz.
+ * @RETURNS module functional clock rate, in KHz.
+ * OMAPCONF_ERR_CPU
+ * OMAPCONF_ERR_ARG
+ * OMAPCONF_ERR_NOT_AVAILABLE
+ * @param[in] mod: module name, as defined in module.h
+ * @param[in] ignore: do not consider DPLL status (if any).
+ * @DESCRIPTION return the module functional clock rate, in KHz.
+ *//*------------------------------------------------------------------------ */
+int module_clk_rate_get(const char *mod, unsigned short ignore)
+{
+ mod_info data;
+ int ret, rate_khz;
+ double rate_mhz;
+
+ CHECK_NULL_ARG(mod, OMAPCONF_ERR_ARG);
+
+ ret = _module_info_get(mod, &data);
+ if (ret != 0) {
+ dprintf("%s(%s): could not retrieve mod_info struct!\n",
+ __func__, mod);
+ rate_khz = OMAPCONF_ERR_NOT_AVAILABLE;
+ } else if (data.clk < 0) {
+ dprintf("%s(%s): could not retrieve module clock ID!\n",
+ __func__, mod);
+ rate_khz = OMAPCONF_ERR_NOT_AVAILABLE;
+ } else {
+ rate_mhz = clk54xx_rate_get(data.clk, ignore);
+ if (rate_mhz < 0.0) {
+ rate_khz = (int) rate_mhz;
+ dprintf(
+ "%s(%s): could not retrieve module rate! (%d)\n",
+ __func__, mod, rate_khz);
+ } else {
+ rate_khz = mhz2khz(rate_mhz);
+ }
+ }
+
+ dprintf("%s(%s)=%d KHz\n", __func__, mod, rate_khz);
+ return rate_khz;
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION module_status_show
+ * @BRIEF show OMAP5 power status
+ * @RETURNS 0 on success
+ * OMAPCONF_ERR_ARG
+ * OMAPCONF_ERR_CPU
+ * OMAPCONF_ERR_INTERNAL
+ * @param[in,out] stream: output file stream (!= NULL)
+ * @DESCRIPTION show OMAP5 power status
+ *//*------------------------------------------------------------------------ */
+int module_status_show(FILE *stream)
+{
+ int voltdm_count;
+ const genlist *voltdm_list;
+ voltdm_info voltdm;
+ const char *opp;
+ char s_voltdm_name[VOLTDM_MAX_NAME_LENGTH + 10];
+ int powerdm_count;
+ const genlist *powerdm_list;
+ powerdm_info pwrdm;
+ int clockdm_count;
+ const genlist *clockdm_list;
+ clockdm_info clkdm;
+ int mod_count;
+ const genlist *mod_list;
+ mod_info mod;
+ int v, p, c, m;
+
+
+
+ mod_idle_status idlest;
+ mod_standby_status stbyst;
+ char s_idlest[MODULE_MODES_MAX_NAME_LENGTH];
+ char s_stbyst[MODULE_MODES_MAX_NAME_LENGTH];
+ pwrdm_state pwst, pwtgst;
+ char s_pwst[PWRDM_STATE_MAX_NAME_LENGTH];
+ char s_pwtgst[PWRDM_STATE_MAX_NAME_LENGTH];
+ char s_pwrdm_name[PWRDM_MAX_NAME_LENGTH];
+ clkdm_status clkst;
+ char s_clkst[CLKDM_STATUS_MAX_NAME_LENGTH];
+ char s_clkdm_name[CLKDM_MAX_NAME_LENGTH];
+ double clk_rate;
+ char s_clk_rate[12];
+ char s_current_opp[OPP_MAX_NAME_LENGTH];
+ unsigned short first_mod, first_clkdm, first_pwrdm;
+ double volt;
+
+ /* Retrieve voltage domain list and count */
+ voltdm_list = voltdm_list_get();
+ if (voltdm_list == NULL) {
+ fprintf(stderr,
+ "omapconf: %s(): failed to retrieve VDD List!\n",
+ __func__);
+ return OMAPCONF_ERR_NOT_AVAILABLE;
+ }
+
+ voltdm_count = voltdm_count_get();
+ if (voltdm_count <= 0) {
+ fprintf(stderr,
+ "omapconf: %s(): failed to retrieve VDD count!\n",
+ __func__);
+ return OMAPCONF_ERR_NOT_AVAILABLE;
+ }
+
+ /* Retrieve power domain list and count */
+ powerdm_list = powerdm_list_get();
+ if (powerdm_list == NULL) {
+ fprintf(stderr,
+ "omapconf: %s(): failed to retrieve PWRDM List!\n",
+ __func__);
+ return OMAPCONF_ERR_NOT_AVAILABLE;
+ }
+ powerdm_count = powerdm_count_get();
+ if (powerdm_count <= 0) {
+ fprintf(stderr,
+ "omapconf: %s(): failed to retrieve PWRDM count!\n",
+ __func__);
+ return OMAPCONF_ERR_NOT_AVAILABLE;
+ }
+
+ /* Retrieve clock domain list and count */
+ clockdm_list = clockdm_list_get();
+ if (clockdm_list == NULL) {
+ fprintf(stderr,
+ "omapconf: %s(): failed to retrieve CLKDM List!\n",
+ __func__);
+ return OMAPCONF_ERR_NOT_AVAILABLE;
+ }
+ clockdm_count = clockdm_count_get();
+ if (clockdm_count <= 0) {
+ fprintf(stderr,
+ "omapconf: %s(): failed to retrieve CLKDM count!\n",
+ __func__);
+ return OMAPCONF_ERR_NOT_AVAILABLE;
+ }
+
+ /* Retrieve module domain list and count */
+ mod_list = module_list_get();
+ if (mod_list == NULL) {
+ fprintf(stderr,
+ "omapconf: %s(): failed to retrieve MODULE List!\n",
+ __func__);
+ return OMAPCONF_ERR_NOT_AVAILABLE;
+ }
+ mod_count = module_count_get();
+ if (mod_count <= 0) {
+ fprintf(stderr,
+ "omapconf: %s(): failed to retrieve MODULE count!\n",
+ __func__);
+ return OMAPCONF_ERR_NOT_AVAILABLE;
+ }
+
+
+ /* For each voltage domain, retrieve the current OPP */
+ fprintf(stream,
+ "|---------------------------------------------------------------------------------------------------------------------------------------------------------------|\n");
+ fprintf(stream,
+ "| OMAP5 Power Status |\n");
+ fprintf(stream,
+ "|---------------------------------------------------------------------------------------------------------------------------------------------------------------|\n");
+ fprintf(stream,
+ "| Voltage Domain | Power Domain | Clock Domain | Module Status |\n");
+ fprintf(stream,
+ "| Name | OPP | Name | Curr. | Target | Name | Status | Name | Rate (MHz) | Idle | Standby |\n");
+ /* For each domain, retrieve the clock & power domain status */
+ for (v = 0; v < voltdm_count; v++) {
+ fprintf(stream,
+ "|---------------------------------------------------------------------------------------------------------------------------------------------------------------|\n");
+ genlist_get((genlist *) voltdm_list, v, (void *) &voltdm);
+
+ opp = opp_get(voltdm.name, 1);
+ strncpy(s_current_opp, opp, OPP_MAX_NAME_LENGTH);
+
+ volt = (double) voltdm_voltage_get(voltdm.name) / 1000000.0;
+ if (volt > 0)
+ sprintf(s_voltdm_name, "%s (%.3lfV)",
+ voltdm.name, volt);
+ else
+ strcpy(s_voltdm_name, voltdm.name);
+
+ for (p = 0, first_pwrdm = 1; p < powerdm_count; p++) {
+ genlist_get(
+ (genlist *) powerdm_list, p, (void *) &pwrdm);
+
+ if (strcmp(pwrdm.voltdm, voltdm.name) != 0)
+ continue;
+ /* Ignore these power domains (and modules) */
+ else if (strcmp(pwrdm.name, "MMAON") == 0)
+ continue;
+ else if (strcmp(pwrdm.name, "MPUAON") == 0)
+ continue;
+ else if (strcmp(pwrdm.name, "CUSTEFUSE") == 0)
+ continue;
+
+ *s_pwst = '\0';
+ pwst = powerdm_state_get(pwrdm.name,
+ PWRDM_STATE_CURRENT);
+ pwrdm_state2string(s_pwst, pwst);
+
+ *s_pwtgst = '\0';
+ pwtgst = powerdm_state_get(pwrdm.name,
+ PWRDM_STATE_TARGET);
+ pwrdm_state2string(s_pwtgst, pwtgst);
+ strncpy(s_pwrdm_name, pwrdm.name,
+ PWRDM_MAX_NAME_LENGTH);
+
+ for (c = 0, first_clkdm = 1; c < clockdm_count; c++) {
+ genlist_get((genlist *) clockdm_list, c,
+ (void *) &clkdm);
+
+ if (strcmp(clkdm.powerdm, pwrdm.name) != 0)
+ continue;
+ if ((strcmp(clkdm.name, CLKDM_L4_SEC) == 0) &&
+ cpu_is_gp_device())
+ continue;
+ if (strcmp(clkdm.name, CLKDM_NONE) == 0)
+ continue;
+
+ if ((!first_pwrdm) && (first_clkdm))
+ fprintf(stream,
+ "| %-17s | %-9s |-------------------------------------------------------------------------------------------------------------------------------|\n",
+ "", "");
+ *s_clkst = '\0';
+ clkst = clockdm_status_get(clkdm.name);
+ if (clkst != CLKDM_STATUS_MAX)
+ strcpy(s_clkst,
+ clkdm_status_name_get(clkst));
+
+ strncpy(s_clkdm_name, clkdm.name,
+ CLKDM_MAX_NAME_LENGTH);
+
+ /* For each module, retrieve status */
+ for (m = 0, first_mod = 1; m < mod_count; m++) {
+ genlist_get((genlist *) mod_list, m,
+ (void *) &mod);
+
+ if (strcmp(mod.clkdm, clkdm.name) != 0)
+ continue;
+
+ *s_idlest = '\0';
+ *s_stbyst = '\0';
+
+ idlest = module_idle_status_get(
+ mod.name);
+ if (idlest != MOD_IDLE_STATUS_MAX) {
+ strcpy(s_idlest, mod_idle_status_name_get(idlest));
+ } else if (idlest != MOD_DISABLED) {
+ stbyst = module_standby_status_get(mod.name);
+ if (stbyst != MOD_STANDBY_STATUS_MAX)
+ strcpy(s_stbyst, mod_standby_status_name_get(stbyst));
+ }
+ clk_rate = (double) module_clk_rate_get(
+ mod.name, 0) / 1000.0;
+ if (clk_rate < 0.0)
+ strcpy(s_clk_rate, "Error");
+ else
+ snprintf(s_clk_rate, 12,
+ "%.3lf", clk_rate);
+ if ((first_mod) && (!first_clkdm))
+ fprintf(stream,
+ "| %-17s | %-9s | %-10s | %-6s | %-6s |------------------------------------------------------------------------------------------------|\n",
+ "", "", "", "", "");
+ fprintf(stream,
+ "| %-17s | %-9s | %-10s | %-6s | %-6s | %-10s | %-8s | %-21s | %-10s | %-20s | %-10s |\n",
+ s_voltdm_name,
+ s_current_opp,
+ s_pwrdm_name,
+ s_pwst,
+ s_pwtgst,
+ s_clkdm_name,
+ s_clkst,
+ mod.name,
+ s_clk_rate,
+ s_idlest,
+ s_stbyst);
+ if (first_mod) {
+ *s_clkdm_name = '\0';
+ *s_pwrdm_name = '\0';
+ *s_voltdm_name = '\0';
+ *s_current_opp = '\0';
+ *s_pwst = '\0';
+ *s_pwtgst = '\0';
+ *s_clkst = '\0';
+ first_mod = 0;
+ }
+ }
+ first_clkdm = 0;
+ }
+ first_pwrdm = 0;
+ }
+
+ }
+ fprintf(stream,
+ "|---------------------------------------------------------------------------------------------------------------------------------------------------------------|\n");
+
+ return 0;
+}
View
25 arch/arm/mach-omap/common/module.h
@@ -48,6 +48,8 @@
#include <genlist.h>
#include <reg.h>
+#include <prcm-module.h>
+#include <stdio.h>
#define MOD_UNKNOWN ((const char *) "UNKNOWN")
@@ -227,11 +229,26 @@ typedef struct {
} mod_opp;
-void mod_init(void);
-void mod_deinit(void);
+void module_init(void);
+void module_deinit(void);
-int mod_count_get(void);
-const genlist *mod_list_get(void);
+int module_count_get(void);
+const genlist *module_list_get(void);
+
+int module_id_get(const char *mod);
+unsigned short int module_is_accessible(const char *mod);
+mod_module_mode module_mode_get(const char *mod);
+mod_autoidle_mode module_autoidle_mode_get(const char *mod);
+mod_idle_mode module_idle_mode_get(const char *mod);
+mod_idle_status module_idle_status_get(const char *mod);
+mod_standby_mode module_standby_mode_get(const char *mod);
+mod_standby_status module_standby_status_get(const char *mod);
+mod_clock_activity_mode module_clock_activity_mode_get(const char *mod);
+int module_context_is_lost(const char *mod);
+int module_clk_rate_get(const char *mod, unsigned short ignore);
+int module_por_clk_rate_get(const char *mod, const char *opp);
+
+int module_status_show(FILE *stream);
#endif
View
519 arch/arm/mach-omap/common/prcm/prcm-module.c
@@ -60,17 +60,19 @@
static const char
- mod_autoidle_mode_names_table[MOD_AUTOIDLE_MODE_MAX][MODULE_MODES_MAX_NAME_LENGTH] = {
+ mod_autoidle_mode_names_table[MOD_AUTOIDLE_MODE_MAX + 1][MODULE_MODES_MAX_NAME_LENGTH] = {
"Free Running",
- "Autogating"};
+ "Autogating",
+ "FIXME"};
static const char
- mod_idle_mode_names_table[MOD_IDLE_MODE_MAX][MODULE_MODES_MAX_NAME_LENGTH] = {
+ mod_idle_mode_names_table[MOD_IDLE_MODE_MAX + 1][MODULE_MODES_MAX_NAME_LENGTH] = {
"Force-Idle",
"No Idle",
"Smart-Idle",
- "Smart-Idle Wakeup"};
+ "Smart-Idle Wakeup",
+ "FIXME"};
static const char
@@ -83,11 +85,12 @@ static const char
static const char
- mod_standby_mode_names_table[MOD_STANDBY_MODE_MAX][MODULE_MODES_MAX_NAME_LENGTH] = {
+ mod_standby_mode_names_table[MOD_STANDBY_MODE_MAX + 1][MODULE_MODES_MAX_NAME_LENGTH] = {
"Force-standby",
"No standby",
"Smart-Standby",
- "Reserved"};
+ "Reserved",
+ "FIXME"};
static const char
@@ -98,32 +101,35 @@ static const char
static const char
- mod_module_mode_names_table[MOD_MODULE_MODE_MAX][MODULE_MODES_MAX_NAME_LENGTH] = {
+ mod_module_mode_names_table[MOD_MODULE_MODE_MAX + 1][MODULE_MODES_MAX_NAME_LENGTH] = {
"Disabled (NO ACCESS)",
"HW-Auto",
"Enabled (EXPLICITLY)",
- "Reserved"};
+ "Reserved",
+ "FIXME"};
static const char
- mod_clock_activity_mode_names_table[MOD_CLOCK_ACTIVITY_MODE_MAX][MODULE_MODES_MAX_NAME_LENGTH] = {
+ mod_clock_activity_mode_names_table[MOD_CLOCK_ACTIVITY_MODE_MAX + 1][MODULE_MODES_MAX_NAME_LENGTH] = {
"F-CLK AUTO / I-CLK AUTO",
"F-CLK AUTO / I-CLK ON",
"F-CLK ON / I-CLK AUTO",
- "F-CLK ON / I-CLK ON"};
+ "F-CLK ON / I-CLK ON",
+ "FIXME"};
/* ------------------------------------------------------------------------*//**
* @FUNCTION mod_module_mode_name_get
* @BRIEF return module mode name
* @RETURNS module mode name on success
- * NULL otherwise
+ * "FIXME" otherwise
* @param[in] mode: valid module mode
* @DESCRIPTION return module mode name
*//*------------------------------------------------------------------------ */
const char *mod_module_mode_name_get(mod_module_mode mode)
{
- CHECK_ARG_LESS_THAN(mode, MOD_MODULE_MODE_MAX, NULL);
+ if (mode > MOD_MODULE_MODE_MAX)
+ mode = MOD_MODULE_MODE_MAX;
return mod_module_mode_names_table[mode];
}
@@ -133,13 +139,14 @@ const char *mod_module_mode_name_get(mod_module_mode mode)
* @FUNCTION mod_autoidle_mode_name_get
* @BRIEF return autoidle mode name
* @RETURNS autoidle mode name on success
- * NULL otherwise
+ * "FIXME" otherwise
* @param[in] mode: valid autoidle mode
* @DESCRIPTION return autoidle mode name
*//*------------------------------------------------------------------------ */
const char *mod_autoidle_mode_name_get(mod_autoidle_mode mode)
{
- CHECK_ARG_LESS_THAN(mode, MOD_AUTOIDLE_MODE_MAX, NULL);
+ if (mode > MOD_AUTOIDLE_MODE_MAX)
+ mode = MOD_AUTOIDLE_MODE_MAX;
return mod_autoidle_mode_names_table[mode];
}
@@ -149,14 +156,14 @@ const char *mod_autoidle_mode_name_get(mod_autoidle_mode mode)
* @FUNCTION mod_idle_mode_name_get
* @BRIEF return idle mode name
* @RETURNS idle mode name on success
- * NULL otherwise
+ * "FIXME" otherwise
* @param[in] mode: valid idle mode
* @DESCRIPTION return idle mode name
*//*------------------------------------------------------------------------ */
const char *mod_idle_mode_name_get(mod_idle_mode mode)
{
- CHECK_ARG_LESS_THAN(mode, MOD_IDLE_MODE_MAX, NULL);
-
+ if (mode > MOD_IDLE_MODE_MAX)
+ mode = MOD_IDLE_MODE_MAX;
return mod_idle_mode_names_table[mode];
}
@@ -166,13 +173,14 @@ const char *mod_idle_mode_name_get(mod_idle_mode mode)
* @FUNCTION mod_standby_mode_name_get
* @BRIEF return standby mode name
* @RETURNS standby mode name on success
- * NULL otherwise
+ * "FIXME" otherwise
* @param[in] mode: valid standby mode
* @DESCRIPTION return standby mode name
*//*------------------------------------------------------------------------ */
const char *mod_standby_mode_name_get(mod_standby_mode mode)
{
- CHECK_ARG_LESS_THAN(mode, MOD_STANDBY_MODE_MAX, NULL);
+ if (mode > MOD_STANDBY_MODE_MAX)
+ mode = MOD_STANDBY_MODE_MAX;
return mod_standby_mode_names_table[mode];
}
@@ -182,13 +190,14 @@ const char *mod_standby_mode_name_get(mod_standby_mode mode)
* @FUNCTION mod_clock_activity_mode_name_get
* @BRIEF return clock activity mode name
* @RETURNS clock activity mode name on success
- * NULL otherwise
+ * "FIXME" otherwise
* @param[in] mode: valid clock activity mode
* @DESCRIPTION return clock activity mode name
*//*------------------------------------------------------------------------ */
const char *mod_clock_activity_mode_name_get(mod_clock_activity_mode mode)
{
- CHECK_ARG_LESS_THAN(mode, MOD_CLOCK_ACTIVITY_MODE_MAX, NULL);
+ if (mode > MOD_CLOCK_ACTIVITY_MODE_MAX)
+ mode = MOD_CLOCK_ACTIVITY_MODE_MAX;
return mod_clock_activity_mode_names_table[mode];
}
@@ -198,13 +207,14 @@ const char *mod_clock_activity_mode_name_get(mod_clock_activity_mode mode)
* @FUNCTION mod_idle_status_name_get
* @BRIEF return module idle status name
* @RETURNS module idle status name on success
- * NULL otherwise
+ * "FIXME" otherwise
* @param[in] status: valid module idle status
* @DESCRIPTION return module idle status name
*//*------------------------------------------------------------------------ */
const char *mod_idle_status_name_get(mod_idle_status status)
{
- CHECK_ARG_LESS_THAN(status, MOD_IDLE_STATUS_MAX + 1, NULL);
+ if (status > MOD_IDLE_STATUS_MAX)
+ status = MOD_IDLE_STATUS_MAX;
return mod_idle_status_names_table[status];
}
@@ -214,13 +224,14 @@ const char *mod_idle_status_name_get(mod_idle_status status)
* @FUNCTION mod_standby_status_name_get
* @BRIEF return module standby status name
* @RETURNS module standby status name on success
- * NULL otherwise
+ * "FIXME" otherwise
* @param[in] status: valid module standby status
* @DESCRIPTION return module standby status name
*//*------------------------------------------------------------------------ */
const char *mod_standby_status_name_get(mod_standby_status status)
{
- CHECK_ARG_LESS_THAN(status, MOD_STANDBY_STATUS_MAX + 1, NULL);
+ if (status > MOD_STANDBY_STATUS_MAX)
+ status = MOD_STANDBY_STATUS_MAX;
return mod_standby_status_names_table[status];
}
@@ -230,7 +241,7 @@ const char *mod_standby_status_name_get(mod_standby_status status)
* @FUNCTION mod_is_accessible
* @BRIEF return 1 if module is running, 0 otherwise
* @RETURNS 1 if module is running, 0 otherwise
- * @param[in] cm_clkctrl: CM_XYZ_CLKCTRL register content
+ * @param[in] cm_clkctrl: CM_xxx_xxx_CLKCTRL register content
* @DESCRIPTION return 1 if module is running, 0 otherwise
*//*------------------------------------------------------------------------ */
unsigned int mod_is_accessible(unsigned int cm_clkctrl)
@@ -455,276 +466,260 @@ int mod_id_get(const char *mod)
/* ------------------------------------------------------------------------*//**
- * @FUNCTION mod_clk_rate_get
- * @BRIEF return the module functional clock rate, in KHz.
- * @RETURNS module functional clock rate, in KHz.
- * OMAPCONF_ERR_CPU
- * OMAPCONF_ERR_ARG
- * OMAPCONF_ERR_NOT_AVAILABLE
- * @param[in] mod: module name, as defined in module.h
- * @DESCRIPTION return the module functional clock rate, in KHz.
+ * @FUNCTION mod_module_mode_get
+ * @BRIEF return the module module mode.
+ * @RETURNS module mode in case of success
+ * MOD_MODULE_MODE_MAX otherwise
+ * @param[in] cm_clkctrl: CM_XYZ_CLKCTRL register content
+ * @DESCRIPTION return the module module mode.
*//*------------------------------------------------------------------------ */
-int mod_clk_rate_get(const char *mod)
+mod_module_mode mod_module_mode_get(unsigned int cm_clkctrl)
{
- int ret, mod_id, rate_khz;
- double rate_mhz;
- clock44xx_id clk_id;
- opp44xx_id opp_id;
+ mod_module_mode mmode;
- CHECK_NULL_ARG(mod, OMAPCONF_ERR_ARG);
+ mmode = (mod_module_mode) extract_bitfield(cm_clkctrl, 0, 2);
+ dprintf(
+ "%s(): CM_CLKCTRL=0x%08X MODULEMODE (bit [1-0])=%u (%s)\n",
+ __func__, cm_clkctrl, mmode,
+ mod_module_mode_name_get(mmode));
- /* FIXME: TACTICAL IMPLEMENTATION, NEED TO BE REWORKED/COMPLETED!!! */
+ return mmode;
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION mod_idle_status_get
+ * @BRIEF retrieve module's idle status from CM_xxx_xxx_CLKCTRL
+ * @RETURNS module idle status
+ * MOD_IDLE_STATUS_MAX in case of error
+ * @param[in] cm_clkctrl: CM_xxx_xxx_CLKCTRL register content
+ * @param[in] properties: module properties
+ * @DESCRIPTION retrieve module's idle status from CM_xxx_xxx_CLKCTRL
+ *//*------------------------------------------------------------------------ */
+mod_idle_status mod_idle_status_get(
+ unsigned int cm_clkctrl, unsigned int properties)
+{
+ mod_idle_status mstatus;
- mod_id = mod_id_get(mod);
- if (mod_id < 0) {
- dprintf("%s(%s): could not retrieve module ID! (%d)\n",
- __func__, mod, mod_id);
- rate_khz = mod_id;
- } else if (cpu_is_omap44xx()) {
- ret = mod44xx_get_clk_speed((mod44xx_id) mod_id,
- &clk_id, &opp_id, &rate_mhz);
- if (ret != 0) {
- dprintf(
- "%s(%s): could not retrieve module rate! (%d)\n",
- __func__, mod, ret);
- rate_khz = ret;
- } else {
- if (mod_id == OMAP4_DDRPHY)
- rate_mhz /= 2.0;
- rate_khz = mhz2khz(rate_mhz);
- }
- } else if (cpu_is_omap54xx()) {
- rate_mhz = mod54xx_clk_rate_get((mod54xx_id) mod_id, 1);
- if (rate_mhz < 0) {
- dprintf(
- "%s(%s): could not retrieve module rate! (%d)\n",
- __func__, mod, (int) rate_mhz);
- rate_khz = (int) rate_mhz;
- } else {
- rate_khz = mhz2khz(rate_mhz);
- }
+ if ((properties & MOD_HAS_NO_IDLE_STATUS) != 0) {
+ dprintf("%s(): module HAS NO idle status (prop=%u)\n",
+ __func__, properties);
+ mstatus = MOD_IDLE_STATUS_MAX;
} else {
- fprintf(stderr, "omapconf: %s(): cpu not supported!!!\n",
- __func__);
- rate_khz = OMAPCONF_ERR_CPU;
+ mstatus = (mod_idle_status) extract_bitfield(cm_clkctrl, 16, 2);
+ dprintf(
+ "%s(): CM_CLKCTRL=0x%08X, IDLEST (bit [17-16])=%u (%s)\n",
+ __func__, cm_clkctrl, mstatus,
+ mod_idle_status_name_get(mstatus));
}
- dprintf("%s(%s) = %d KHz\n", __func__, mod, rate_khz);
- return rate_khz;
+ return mstatus;
}
/* ------------------------------------------------------------------------*//**
- * @FUNCTION mod_mode_get
- * @BRIEF return the module module.
- * @RETURNS module module in case of success
- * MOD_MODULE_MODE_MAX otherwise
- * @param[in] mod: module name, as defined in module.h
- * @DESCRIPTION return the module module.
+ * @FUNCTION mod_standby_status_get
+ * @BRIEF retrieve module standby status from CM_xxx_xxx_CLKCTRL
+ * @RETURNS module standby status
+ * MOD_STANDBY_STATUS_MAX in case of error
+ * @param[in] cm_clkctrl: CM_xxx_xxx_CLKCTRL register content
+ * @param[in] properties: module properties
+ * @DESCRIPTION retrieve module standby status from CM_xxx_xxx_CLKCTRL
*//*------------------------------------------------------------------------ */
-mod_module_mode mod_mode_get(const char *mod)
+mod_standby_status mod_standby_status_get(
+ unsigned int cm_clkctrl, unsigned int properties)
{
- mod_module_mode mmode;
+ mod_standby_status mstatus;
- /* FIXME: TACTICAL IMPLEMENTATION, NEED TO BE REWORKED/COMPLETED!!! */
+ if ((properties & MOD_HAS_STANDBY_STATUS) != 0) {
+ mstatus = (mod_standby_status) extract_bit(cm_clkctrl, 18);
+ dprintf(
+ "%s(): CM_CLKCTRL=0x%08X, STANDBYST (bit 18)=%u (%s)\n",
+ __func__, cm_clkctrl, mstatus,
+ mod_standby_status_name_get(mstatus));
+ } else {
+ dprintf("%s(): module does NOT have STANDBY status bit\n",
+ __func__);
+ mstatus = MOD_STANDBY_STATUS_MAX;
+ }
- CHECK_NULL_ARG(mod, MOD_MODULE_MODE_MAX);
+ return mstatus;
+}
- if (strcmp(mod, "MPU") == 0) {
- if (cpu_is_omap44xx())
- mod44xx_get_mode(OMAP4_MPU, &mmode);
- else if (cpu_is_omap54xx())
- mmode = mod54xx_mode_get(OMAP5_MPU);
- else
- mmode = MOD_MODULE_MODE_MAX;
- } else if (strcmp(mod, "IVA") == 0) {
- if (cpu_is_omap44xx())
- mod44xx_get_mode(OMAP4_IVAHD, &mmode);
- else if (cpu_is_omap54xx())
- mmode = mod54xx_mode_get(OMAP5_IVA);
- else
- mmode = MOD_MODULE_MODE_MAX;
- } else if (strcmp(mod, "DSP") == 0) {
- if (cpu_is_omap44xx())
- mod44xx_get_mode(OMAP4_DSP, &mmode);
- else if (cpu_is_omap54xx())
- mmode = mod54xx_mode_get(OMAP5_DSP);
- else
- mmode = MOD_MODULE_MODE_MAX;
- } else if (strcmp(mod, "GPU") == 0) {
- if (cpu_is_omap44xx())
- mod44xx_get_mode(OMAP4_GFX, &mmode);
- else if (cpu_is_omap54xx())
- mmode = mod54xx_mode_get(OMAP5_GPU);
- else
- mmode = MOD_MODULE_MODE_MAX;
- } else if (strcmp(mod, "AESS") == 0) {
- if (cpu_is_omap44xx())
- mod44xx_get_mode(OMAP4_AESS, &mmode);
- else if (cpu_is_omap54xx())
- mmode = mod54xx_mode_get(OMAP5_AESS);
- else
- mmode = MOD_MODULE_MODE_MAX;
- } else if (strcmp(mod, "L3") == 0) {
- if (cpu_is_omap44xx())
- mod44xx_get_mode(OMAP4_L3_1, &mmode);
- else if (cpu_is_omap54xx())
- mmode = mod54xx_mode_get(OMAP5_L3_MAIN1_INTERCONNECT);
- else
- mmode = MOD_MODULE_MODE_MAX;
- } else if (strcmp(mod, "L4") == 0) {
- if (cpu_is_omap44xx())
- mod44xx_get_mode(OMAP4_L4_CFG, &mmode);
- else if (cpu_is_omap54xx())
- mmode = mod54xx_mode_get(OMAP5_L4_CFG_INTERCONNECT);
- else
- mmode = MOD_MODULE_MODE_MAX;
- } else if (strcmp(mod, "EMIF") == 0) {
- if (cpu_is_omap44xx())
- mod44xx_get_mode(OMAP4_EMIF1, &mmode);
- else if (cpu_is_omap54xx())
- mmode = mod54xx_mode_get(OMAP5_EMIF1);
- else
- mmode = MOD_MODULE_MODE_MAX;
- } else if (strcmp(mod, "MEM") == 0) {
- if (cpu_is_omap44xx())
- mod44xx_get_mode(OMAP4_DDRPHY, &mmode);
- else if (cpu_is_omap54xx())
- mmode = mod54xx_mode_get(OMAP5_PHY_EMIF);
- else
- mmode = MOD_MODULE_MODE_MAX;
- } else if (strcmp(mod, "ISS") == 0) {
- if (cpu_is_omap44xx())
- mod44xx_get_mode(OMAP4_ISS, &mmode);
- else if (cpu_is_omap54xx())
- mmode = mod54xx_mode_get(OMAP5_ISS);
- else
- mmode = MOD_MODULE_MODE_MAX;
- } else if (strcmp(mod, "FDIF") == 0) {
- if (cpu_is_omap44xx())
- mod44xx_get_mode(OMAP4_FDIF, &mmode);
- else if (cpu_is_omap54xx())
- mmode = mod54xx_mode_get(OMAP5_FDIF);
- else
- mmode = MOD_MODULE_MODE_MAX;
- } else if (strcmp(mod, "CAL") == 0) {
- if (cpu_is_omap54xx())
- mmode = mod54xx_mode_get(OMAP5_CAL);
- else
- mmode = MOD_MODULE_MODE_MAX;
- } else if (strcmp(mod, "IPU") == 0) {
- if (cpu_is_omap44xx())
- mod44xx_get_mode(OMAP4_MPU_M3, &mmode);
- else if (cpu_is_omap54xx())
- mmode = mod54xx_mode_get(OMAP5_IPU);
- else
- mmode = MOD_MODULE_MODE_MAX;
- } else if (strcmp(mod, "DSS") == 0) {
- if (cpu_is_omap44xx())
- mod44xx_get_mode(OMAP4_DISPC, &mmode);
- else if (cpu_is_omap54xx())
- mmode = mod54xx_mode_get(OMAP5_DSS);
- else
- mmode = MOD_MODULE_MODE_MAX;
- } else if (strcmp(mod, "BB2D") == 0) {
- if (cpu_is_omap44xx())
- mod44xx_get_mode(OMAP4_BB2D, &mmode);
- else if (cpu_is_omap54xx())
- mmode = mod54xx_mode_get(OMAP5_BB2D);
- else
- mmode = MOD_MODULE_MODE_MAX;
- } else if (strcmp(mod, "HSI") == 0) {
- if (cpu_is_omap44xx())
- mod44xx_get_mode(OMAP4_HSI, &mmode);
- else if (cpu_is_omap54xx())
- mmode = mod54xx_mode_get(OMAP5_HSI);
- else
- mmode = MOD_MODULE_MODE_MAX;
- } else if (strcmp(mod, "C2C") == 0) {
- if (cpu_is_omap44xx())
- mod44xx_get_mode(OMAP4_C2C, &mmode);
- else if (cpu_is_omap54xx())
- mmode = mod54xx_mode_get(OMAP5_C2C);
- else
- mmode = MOD_MODULE_MODE_MAX;
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION mod_autoidle_mode_get
+ * @BRIEF retrieve module autoidle mode
+ * @RETURNS module autoidle mode
+ * MOD_AUTOIDLE_MODE_MAX in case of error
+ * @param[in] sysconfig: SYSCONFIG register content
+ * @param[in] properties: module properties
+ * @DESCRIPTION retrieve module autoidle mode
+ *//*------------------------------------------------------------------------ */
+mod_autoidle_mode mod_autoidle_mode_get(
+ unsigned int sysconfig, unsigned int properties)
+{
+ mod_autoidle_mode mode;
+
+ if ((properties & MOD_HAS_AUTOIDLE_BIT0) != 0) {
+ mode = (mod_autoidle_mode) extract_bit(sysconfig, 0);
+ dprintf(
+ "%s(): SYSCONFIG=0x%08X POS=0 AUTOIDLE MODE=%u (%s)\n",
+ __func__, sysconfig, mode,
+ mod_autoidle_mode_name_get(mode));
+ } else if ((properties & MOD_HAS_AUTOIDLE_BIT8) != 0) {
+ /*
+ * NB: AUTOGATINGDISABLE instead of AUTOGATING,
+ * bit is inverted compared to other modules ...
+ */
+ mode = (mod_autoidle_mode) !extract_bit(sysconfig, 8);
+ dprintf("%s(): SYSCONFIG=0x%08X POS=8 AUTOIDLE MODE=%u (%s)\n",
+ __func__, sysconfig, mode,
+ mod_autoidle_mode_name_get(mode));
} else {
- mmode = MOD_MODULE_MODE_MAX;
+ dprintf("%s(): MODULE DOES NOT HAVE AUTOIDLE MODE?! (%u)\n",
+ __func__, properties);
+ mode = MOD_AUTOIDLE_MODE_MAX;
}
- dprintf("%s(%s) = %s\n", __func__, mod,
- mod_module_mode_name_get(mmode));
- return mmode;
+ return mode;
}
/* ------------------------------------------------------------------------*//**
- * @FUNCTION mod_por_clk_rate_get
- * @BRIEF return the recommended module functional clock rate,
- * in KHz, for a given OPerating Point (OPP),
- * as defined in Data Manual.
- * @RETURNS module recommended functional clock rate, in KHz.
- * OMAPCONF_ERR_CPU
- * OMAPCONF_ERR_ARG
- * OMAPCONF_ERR_NOT_AVAILABLE
- * @param[in] mod: module name, as defined in module.h
- * @DESCRIPTION return the recommended module functional clock rate,
- * in KHz, for a given OPerating Point (OPP),
- * as defined in Data Manual.
+ * @FUNCTION mod_idle_mode_get
+ * @BRIEF retrieve omap module's idle mode
+ * @RETURNS module's idle mode
+ * MOD_IDLE_MODE_MAX in case of error
+ * @param[in] sysconfig: SYSCONFIG register content
+ * @param[in] properties: module properties
+ * @DESCRIPTION retrieve omap module's idle mode
*//*------------------------------------------------------------------------ */
-int mod_por_clk_rate_get(const char *mod, const char *opp)
+mod_idle_mode mod_idle_mode_get(
+ unsigned int sysconfig, unsigned int properties)
{
- int ret, mod_id, opp_id, rate_khz;
- double rate_mhz;
+ mod_idle_mode mode;
- CHECK_NULL_ARG(mod, OMAPCONF_ERR_ARG);
+ if ((properties & MOD_HAS_IDLE_MODE1) != 0) {
+ mode = (mod_idle_mode) extract_bitfield(sysconfig, 0, 2);
+ dprintf(
+ "%s(): SYSCONFIG=0x%08X POS=[1-0] IDLE MODE=%u (%s)\n",
+ __func__, sysconfig, mode,
+ mod_idle_mode_name_get(mode));
+ } else if ((properties & MOD_HAS_IDLE_MODE3) != 0) {
+ mode = (mod_idle_mode) extract_bitfield(sysconfig, 2, 2);
+ dprintf("%s(): SYSCONFIG=0x%08X POS=[3-2] IDLE MODE=%u (%s)\n",
+ __func__, sysconfig, mode,
+ mod_idle_mode_name_get(mode));
+ } else if ((properties & MOD_HAS_IDLE_MODE4) != 0) {
+ mode = (mod_idle_mode) extract_bitfield(sysconfig, 3, 2);
+ dprintf("%s(): SYSCONFIG=0x%08X POS=[4-3] IDLE MODE=%u (%s)\n",
+ __func__, sysconfig, mode,
+ mod_idle_mode_name_get(mode));
+ } else {
+ dprintf("%s(): MODULE DOES NOT HAVE IDLE MODE?! (%u)\n",
+ __func__, properties);
+ mode = MOD_IDLE_MODE_MAX;
+ }
+
+ return mode;
+}
- /* FIXME: TACTICAL IMPLEMENTATION, NEED TO BE REWORKED/COMPLETED!!! */
- mod_id = mod_id_get(mod);
- if (mod_id < 0) {
- dprintf("%s(%s): could not retrieve module ID! (%d)\n",
- __func__, mod, mod_id);
- rate_khz = mod_id;
- goto mod_por_clk_rate_get_end;
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION mod_standby_mode_get
+ * @BRIEF retrieve omap module's standby mode
+ * @RETURNS module's standby mode
+ * MOD_STANDBY_MODE_MAX in case of error
+ * @param[in] sysconfig: SYSCONFIG register content
+ * @param[in] properties: module properties
+ * @DESCRIPTION retrieve omap module's standby mode
+ *//*------------------------------------------------------------------------ */
+mod_standby_mode mod_standby_mode_get(
+ unsigned int sysconfig, unsigned int properties)
+{
+ mod_standby_mode mode;
+
+ if ((properties & MOD_HAS_STANDBY_MODE5) != 0) {
+ mode = (mod_standby_mode) extract_bitfield(sysconfig, 4, 2);
+ dprintf(
+ "%s(): SYSCONFIG=0x%08X POS=[5-4] STANDBY MODE=%u (%s)\n",
+ __func__, sysconfig, mode,
+ mod_standby_mode_name_get(mode));
+ } else if ((properties & MOD_HAS_STANDBY_MODE13) != 0) {
+ mode = (mod_standby_mode) extract_bitfield(sysconfig, 12, 2);
+ dprintf(
+ "%s(): SYSCONFIG=0x%08X POS=[13-12] STANDBY MODE=%u (%s)\n",
+ __func__, sysconfig, mode,
+ mod_standby_mode_name_get(mode));
+ } else {
+ dprintf("%s(): MODULE DOES NOT HAVE STANDBY MODE?! (%u)\n",
+ __func__, properties);
+ mode = MOD_STANDBY_MODE_MAX;
}
- opp_id = opp_s2id(opp);
- if (opp_id < 0) {
- dprintf("%s(%s): could not retrieve OPP ID! (%d)\n",
- __func__, mod, opp_id);
- rate_khz = opp_id;
- goto mod_por_clk_rate_get_end;
+ return mode;
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION mod_clock_activity_mode_get
+ * @BRIEF retrieve omap module's clock activity mode
+ * @RETURNS module's clock activity mode
+ * MOD_CLOCK_ACTIVITY_MODE_MAX in case of error
+ * @param[in] sysconfig: SYSCONFIG register content
+ * @param[in] properties: module properties
+ * @DESCRIPTION retrieve omap module's clock activity mode
+ *//*------------------------------------------------------------------------ */
+mod_clock_activity_mode mod_clock_activity_mode_get(
+ unsigned int sysconfig, unsigned int properties)
+{
+ mod_clock_activity_mode mode;
+
+ if ((properties & MOD_HAS_CLOCK_ACTIVITY_MODE) != 0) {
+ mode = (mod_clock_activity_mode) extract_bitfield(sysconfig, 8, 2);
+ dprintf(
+ "%s(): SYSCONFIG=0x%08X POS=[9-8] CLOCK ACTIVITY MODE=%u (%s)\n",
+ __func__, sysconfig, mode,
+ mod_clock_activity_mode_name_get(mode));
+ } else {
+ dprintf("%s(): module does NOT have clock activity mode (%u)\n",
+ __func__, properties);
+ mode = MOD_CLOCK_ACTIVITY_MODE_MAX;
}
- if (cpu_is_omap44xx()) {
- ret = mod44xx_get_por_clk_speed((mod44xx_id) mod_id,
- (unsigned short) opp_id, &rate_mhz);
- if (ret < 0) {
- dprintf(
- "%s(%s): could not retrieve module POR rate! (%d)\n",
- __func__, mod, ret);
- rate_khz = ret;
- } else {
- rate_khz = mhz2khz(rate_mhz);
- }
- } else if (cpu_is_omap54xx()) {
- rate_mhz = mod54xx_por_clk_rate_get(
- (mod54xx_id) mod_id, (opp54xx_id) opp_id);
- if (rate_mhz < 0) {
- rate_khz = (int) rate_mhz;
- dprintf(
- "%s(%s): could not retrieve module POR rate! (%d)\n",
- __func__, mod, rate_khz);
- } else {
- rate_khz = mhz2khz(rate_mhz);
- }
+ return mode;
+}
+
+
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION mod_context_is_lost
+ * @BRIEF check if module's context was retained or lost
+ * during last power transition
+ * @RETURNS 1 if module's context was LOST during last power
+ * transition
+ * 0 if module's context was RETAINED during last power
+ * transition
+ * @param[in] sysconfig: RM_XYZ_CONTEXT register content
+ * @DESCRIPTION check if module's context was retained or lost
+ * during last power transition
+ *//*------------------------------------------------------------------------ */
+int mod_context_is_lost(unsigned int rm_context)
+{
+ int lost;
+ if (rm_context == 0) {
+ /* All memory bank(s) were retained */
+ dprintf(
+ "%s(): RM_CONTEXT=0x%08X => context is RETAINED\n",
+ __func__, rm_context);
+ lost = 0;
} else {
- fprintf(stderr, "omapconf: %s(): cpu not supported!!!\n",
- __func__);
- rate_khz = OMAPCONF_ERR_CPU;
+ /* At least 1 memory bank was lost */
+ dprintf(
+ "%s(): RM_CONTEXT=0x%08X => context is LOST\n",
+ __func__, rm_context);
+ lost = 1;
}
-mod_por_clk_rate_get_end:
- dprintf("%s(%s) = %d KHz\n", __func__, mod, rate_khz);
- return rate_khz;
+ return lost;
}
View
24 arch/arm/mach-omap/common/prcm/prcm-module.h
@@ -136,6 +136,24 @@ typedef enum {
} mod_interface_type;
+unsigned int mod_is_accessible(unsigned int cm_clkctrl);
+mod_module_mode mod_module_mode_get(unsigned int cm_clkctrl);
+mod_idle_status mod_idle_status_get(
+ unsigned int cm_clkctrl, unsigned int properties);
+mod_standby_status mod_standby_status_get(
+ unsigned int cm_clkctrl, unsigned int properties);
+
+mod_autoidle_mode mod_autoidle_mode_get(
+ unsigned int sysconfig, unsigned int properties);
+mod_idle_mode mod_idle_mode_get(
+ unsigned int sysconfig, unsigned int properties);
+mod_standby_mode mod_standby_mode_get(
+ unsigned int sysconfig, unsigned int properties);
+mod_clock_activity_mode mod_clock_activity_mode_get(
+ unsigned int sysconfig, unsigned int properties);
+
+int mod_context_is_lost(unsigned int rm_context);
+
const char *mod_module_mode_name_get(mod_module_mode mode);
const char *mod_autoidle_mode_name_get(mod_autoidle_mode mode);
const char *mod_idle_mode_name_get(mod_idle_mode mode);
@@ -143,12 +161,6 @@ const char *mod_standby_mode_name_get(mod_standby_mode mode);
const char *mod_clock_activity_mode_name_get(mod_clock_activity_mode mode);
const char *mod_idle_status_name_get(mod_idle_status status);
const char *mod_standby_status_name_get(mod_standby_status status);
-unsigned int mod_is_accessible(unsigned int cm_clkctrl);
-
-int mod_id_get(const char *mod);
-int mod_clk_rate_get(const char *mod);
-int mod_por_clk_rate_get(const char *mod, const char *opp);
-mod_module_mode mod_mode_get(const char *mod);
#endif
View
249 arch/arm/mach-omap/omap5/lib54xx.c
@@ -77,255 +77,6 @@
/* ------------------------------------------------------------------------*//**
- * @FUNCTION lib54xx_pwst_show
- * @BRIEF show OMAP5 power status
- * @RETURNS 0 on success
- * OMAPCONF_ERR_ARG
- * OMAPCONF_ERR_CPU
- * OMAPCONF_ERR_INTERNAL
- * @param[in,out] stream: output file stream (!= NULL)
- * @DESCRIPTION show OMAP5 power status
- *//*------------------------------------------------------------------------ */
-int lib54xx_pwst_show(FILE *stream)
-{
- mod_idle_status idlest;
- mod_standby_status stbyst;
- char s_idlest[MODULE_MODES_MAX_NAME_LENGTH];
- char s_stbyst[MODULE_MODES_MAX_NAME_LENGTH];
- char s_mod_name[MODULE_MAX_NAME_LENGTH];
- pwrdm_state pwst, pwtgst;
- char s_pwst[PWRDM_STATE_MAX_NAME_LENGTH];
- char s_pwtgst[PWRDM_STATE_MAX_NAME_LENGTH];
- char s_pwrdm_name[PWRDM54XX_MAX_NAME_LENGTH];
- clkdm_status clkst;
- char s_clkst[CLKDM_STATUS_MAX_NAME_LENGTH];
- char s_clkdm_name[CLKDM54XX_MAX_NAME_LENGTH];
- double clk_rate;
- char s_clk_rate[12];
- opp54xx_id current_opp[VDD54XX_ID_MAX] = {
- OPP54XX_ID_MAX, OPP54XX_ID_MAX, OPP54XX_ID_MAX, OPP54XX_ID_MAX};
- char s_current_opp[VDD54XX_ID_MAX][OPP_MAX_NAME_LENGTH] = {
- "UNKNOWN",
- "UNKNOWN",
- "UNKNOWN",
- "UNKNOWN"};
- char s_voltdm_name[VOLTDM_MAX_NAME_LENGTH + 10];
- unsigned short first_mod, first_clkdm, first_pwrdm;
- mod54xx_id mod_id;
- clkdm54xx_id clkdm_id;
- pwrdm54xx_id pwrdm_id;
- voltdm54xx_id voltdm_id;
- double volt;
-
- CHECK_CPU(54xx, OMAPCONF_ERR_CPU);
- CHECK_NULL_ARG(stream, OMAPCONF_ERR_ARG);
-
- /* For each voltage domain, retrieve the current OPP */
- current_opp[VDD54XX_WKUP] = voltdm54xx_opp_get(VDD54XX_WKUP);
- if (current_opp[VDD54XX_WKUP] == OPP54XX_ID_MAX)
- fprintf(stderr, "Warning: %s OPP not detected!\n",
- voltdm54xx_name_get(VDD54XX_WKUP));
- current_opp[VDD54XX_MPU] = voltdm54xx_opp_get(VDD54XX_MPU);
- if (current_opp[VDD54XX_MPU] == OPP54XX_ID_MAX)
- fprintf(stderr, "Warning: %s OPP not detected!\n",
- voltdm54xx_name_get(VDD54XX_MPU));
- current_opp[VDD54XX_MM] = voltdm54xx_opp_get(VDD54XX_MM);
- if (current_opp[VDD54XX_MM] == OPP54XX_ID_MAX)
- fprintf(stderr, "Warning: %s OPP not detected!\n",
- voltdm54xx_name_get(VDD54XX_MM));
- current_opp[VDD54XX_CORE] = voltdm54xx_opp_get(VDD54XX_CORE);
- if (current_opp[VDD54XX_CORE] == OPP54XX_ID_MAX)
- fprintf(stderr, "Warning: %s OPP not detected!\n",
- voltdm54xx_name_get(VDD54XX_CORE));
- strcpy(s_current_opp[VDD54XX_WKUP],
- opp54xx_name_get(current_opp[VDD54XX_WKUP]));
- strcpy(s_current_opp[VDD54XX_MPU],
- opp54xx_name_get(current_opp[VDD54XX_MPU]));
- strcpy(s_current_opp[VDD54XX_MM],
- opp54xx_name_get(current_opp[VDD54XX_MM]));
- strcpy(s_current_opp[VDD54XX_CORE],
- opp54xx_name_get(current_opp[VDD54XX_CORE]));
-
- dprintf("%s():\n"
- " current_opp[WKUP] = %s\n"
- " current_opp[MPU] = %s\n"
- " current_opp[MM] = %s\n"
- " current_opp[CORE] = %s\n", __func__,
- s_current_opp[VDD54XX_WKUP],
- s_current_opp[VDD54XX_MPU],
- s_current_opp[VDD54XX_MM],
- s_current_opp[VDD54XX_CORE]);
-
-
- fprintf(stream, "|-----------------------------------------------------"
- "--------------------------------------------------------------"
- "--------------------------------------------|\n");
- fprintf(stream, "| OMAP5 Power Status "
- " "
- " |\n");
- fprintf(stream, "|-----------------------------------------------------"
- "--------------------------------------------------------------"
- "--------------------------------------------|\n");
- fprintf(stream, "| Voltage Domain | Power Domain "
- " | Clock Domain | Module Status "
- " |\n");
- fprintf(stream, "| Name | OPP | Name | Curr. "
- "| Target | Name | Status | Name "
- "| Rate (MHz) | Idle | Standby |\n");
- /* For each domain, retrieve the clock & power domain status */
- for (voltdm_id = 0; voltdm_id < VDD54XX_ID_MAX; voltdm_id++) {
- fprintf(stream, "|---------------------------------------------"
- "------------------------------------------------------"
- "------------------------------------------------------"
- "------|\n");
- volt = voltdm54xx_voltage_get(voltdm_id);
- if (volt > 0)
- sprintf(s_voltdm_name, "%s (%.3lfV)",
- voltdm54xx_name_get(voltdm_id), volt);
- else
- strcpy(s_voltdm_name, voltdm54xx_name_get(voltdm_id));
- for (pwrdm_id = 0, first_pwrdm = 1; pwrdm_id < PWRDM54XX_ID_MAX;
- pwrdm_id++) {
- if (pwrdm54xx_voltdm_get(pwrdm_id) != voltdm_id)
- continue;
-
- switch (pwrdm_id) {
- case PWRDM54XX_MPUAON:
- case PWRDM54XX_MMAON:
- case PWRDM54XX_CUST_EFUSE:
- /* Ignore these power domains (and modules) */
- continue;
-
- default:
- *s_pwst = '\0';
- pwst = pwrdm54xx_state_get(pwrdm_id,
- PWRDM_STATE_CURRENT);
- if (pwst != PWRDM_STATE_MAX)
- pwrdm_state2string(s_pwst, pwst);
- *s_pwtgst = '\0';
- pwtgst = pwrdm54xx_state_get(pwrdm_id,
- PWRDM_STATE_TARGET);
- if (pwtgst != PWRDM_STATE_MAX)
- pwrdm_state2string(s_pwtgst, pwtgst);
-
- pwrdm_state2string(s_pwtgst, pwtgst);
- strcpy(s_pwrdm_name,
- pwrdm54xx_name_get(pwrdm_id));
- }
-
- for (clkdm_id = 0, first_clkdm = 1;
- clkdm_id < CLKDM54XX_NONE; clkdm_id++) {
- if ((clkdm_id == CLKDM54XX_L4_SEC) &&
- cpu_is_gp_device())
- continue;
- if (clkdm_id == CLKDM54XX_NONE)
- continue;
- if (clkdm54xx_pwrdm_get(clkdm_id) != pwrdm_id)
- continue;
-
- if ((!first_pwrdm) && (first_clkdm))
- fprintf(stream, "| %-17s | %-9s |------"
- "------------------------------"
- "------------------------------"
- "------------------------------"
- "------------------------------"
- "-|\n", "", "");
- *s_clkst = '\0';
- clkst = clkdm54xx_status_get(clkdm_id);
- if (clkst != CLKDM_STATUS_MAX)
- strcpy(s_clkst,
- clkdm_status_name_get(clkst));
-
- strcpy(s_clkdm_name,
- clkdm54xx_name_get(clkdm_id));
-
- /* For each module, retrieve status */
- for (mod_id = 0, first_mod = 1;
- mod_id < MOD54XX_ID_MAX; mod_id++) {
- if (mod54xx_clkdm_get(mod_id) !=
- clkdm_id)
- continue;
-
- *s_idlest = '\0';
- *s_stbyst = '\0';
-
- idlest = mod54xx_idle_status_get(
- mod_id);
- if (idlest != MOD_IDLE_STATUS_MAX)
- strcpy(s_idlest,
- mod_idle_status_name_get(
- idlest));
- else if (idlest != MOD_DISABLED) {
- stbyst = mod54xx_standby_status_get(
- mod_id);
- if (stbyst != MOD_STANDBY_STATUS_MAX)
- strcpy(s_stbyst,
- mod_standby_status_name_get(
- stbyst));
- }
- strcpy(s_mod_name,
- mod54xx_name_get(mod_id));
- clk_rate =
- mod54xx_clk_rate_get(mod_id, 0);
- if (clk_rate < 0.0)
- strcpy(s_clk_rate, "Error");
- else if (clk_rate < 1.0)
- snprintf(s_clk_rate, 12,
- "%lf", clk_rate);
- else
- snprintf(s_clk_rate, 12,
- "%.3lf", clk_rate);
- if ((first_mod) && (!first_clkdm))
- fprintf(stream, "| %-17s | %-9s"
- " | %-10s | %-6s | %-6s"
- " |--------------------"
- "----------------------"
- "----------------------"
- "----------------------"
- "----------|\n",
- "", "", "", "", "");
- fprintf(stream, "| %-17s | %-9s | %-10s"
- " | %-6s | %-6s | %-10s | %-8s "
- "| %-21s | %-10s | %-20s |"
- " %-10s |\n",
- s_voltdm_name,
- s_current_opp[voltdm_id],
- s_pwrdm_name,
- s_pwst,
- s_pwtgst,
- s_clkdm_name,
- s_clkst,
- s_mod_name,
- s_clk_rate,
- s_idlest,
- s_stbyst);
- if (first_mod) {
- *s_clkdm_name = '\0';
- *s_pwrdm_name = '\0';
- *s_voltdm_name = '\0';
- *s_current_opp[voltdm_id] =
- '\0';
- *s_pwst = '\0';
- *s_pwtgst = '\0';
- *s_clkst = '\0';
- first_mod = 0;
- }
- }
- first_clkdm = 0;
- }
- first_pwrdm = 0;
- }
-
- }
- fprintf(stream, "|-----------------------------------------------------"
- "--------------------------------------------------------------"
- "--------------------------------------------|\n\n");
-
- return 0;
-}
-
-
-/* ------------------------------------------------------------------------*//**
* @FUNCTION lib54xx_voltage_set
* @BRIEF change voltage of a given voltage domain, switching
* CPUFreq governor to "userspace" & disabling smart-reflex
View
1  arch/arm/mach-omap/omap5/lib54xx.h
@@ -50,7 +50,6 @@
#include <voltdm54xx.h>
-int lib54xx_pwst_show(FILE *stream);
int lib54xx_export(char *file);
int lib54xx_import(char *file);
int lib54xx_voltage_set(voltdm54xx_id vdd_id, double volt);
View
4 arch/arm/mach-omap/omap5/main54xx.c
@@ -56,7 +56,7 @@
#include <sr54xx.h>
#include <dpll54xx.h>
#include <voltdm54xx.h>
-#include <module54xx.h>
+#include <module.h>
#include <audit54xx.h>
#include <ctrlmod54xx.h>
#include <temp54xx.h>
@@ -659,7 +659,7 @@ int main54xx_show(int argc, char *argv[])
return err_arg_too_many_msg_show(HELP_SOC_OPP);
} else if (strcmp(argv[0], "pwst") == 0) {
if (argc == 1)
- return lib54xx_pwst_show(stdout);
+ return module_status_show(stdout);
else
return err_arg_too_many_msg_show(HELP_SOC_PWST);
} else if (strcmp(argv[0], "temp") == 0) {
View
153 common/opp.c
@@ -54,8 +54,7 @@
#include <opp44xx.h>
#include <clock44xx.h>
#include <prcm-module.h>
-#include <module44xx.h>
-#include <module54xx.h>
+#include <module.h>
#include <opp54xx.h>
@@ -471,8 +470,8 @@ int opp_show(FILE *stream)
unsigned int retry_cnt = 0;
unsigned int found = 0;
const genlist *voltdm_list;
+ voltdm_info voltdm;
int i, vdd_count;
- const char voltdm[VOLTDM_MAX_NAME_LENGTH];
char prev_gov[CPUFREQ_GOV_MAX_NAME_LENGTH],
prev_gov2[CPUFREQ_GOV_MAX_NAME_LENGTH];
const char *temp_sensor;
@@ -506,10 +505,11 @@ int opp_show(FILE *stream)
return OMAPCONF_ERR_INTERNAL;
dprintf("found %d voltage domains\n", vdd_count);
for (i = 1; i < vdd_count; i++) {
- genlist_get((genlist *) voltdm_list, i, (char *) &voltdm);
+ genlist_get((genlist *) voltdm_list, i,
+ (voltdm_info *) &voltdm);
snprintf(table[row][0], TABLE_MAX_ELT_LEN, "%s / VDD_CORE%u",
- voltdm, i);
- dprintf(" %s:\n", voltdm);
+ voltdm.name, i);
+ dprintf(" %s:\n", voltdm.name);
/* Retrieve OPP and clock rates */
retry_cnt = 0;
@@ -518,9 +518,9 @@ int opp_show(FILE *stream)
dprintf(" TRY #%u:\n", retry_cnt);
if (retry_cnt == 0)
/* Print warning on first try */
- opp_s = opp_get(voltdm, 0);
+ opp_s = opp_get(voltdm.name, 0);
else
- opp_s = opp_get(voltdm, 1);
+ opp_s = opp_get(voltdm.name, 1);
if (opp_s == NULL) {
dprintf(" OPP NOT detected!\n");
opp_s = OPP_UNKNOWN;
@@ -528,45 +528,47 @@ int opp_show(FILE *stream)
dprintf(" OPP detected: %s\n", opp_s);
}
- volt = voltdm_voltage_get(voltdm);
+ volt = voltdm_voltage_get(voltdm.name);
dprintf(" Voltage: %duV\n", volt);
- if (strcmp(voltdm, "VDD_MPU") == 0) {
- rate_mpu = mod_clk_rate_get("MPU");
+ if (strcmp(voltdm.name, VDD_MPU) == 0) {
+ rate_mpu = module_clk_rate_get(MOD_MPU, 1);
if (strcmp(opp_s, OPP_UNKNOWN) != 0)
- rate_mpu_por = mod_por_clk_rate_get(
- "MPU", opp_s);
+ rate_mpu_por = module_por_clk_rate_get(
+ MOD_MPU, opp_s);
else
rate_mpu_por = -1;
dprintf(
" MPU Rate: %dKHz, POR Rate: %dKHz\n",
rate_mpu, rate_mpu_por);
- } else if ((strcmp(voltdm, "VDD_IVA") == 0) ||
- (strcmp(voltdm, "VDD_MM") == 0)) {
+ } else if ((strcmp(voltdm.name, VDD_IVA) == 0) ||
+ (strcmp(voltdm.name, VDD_MM) == 0)) {
rate_dsp_por = -1;
rate_iva_por = -1;
rate_aess_por = -1;
rate_gpu_por = -1;
- rate_dsp = mod_clk_rate_get("DSP");
- rate_iva = mod_clk_rate_get("IVA");
+ rate_dsp = module_clk_rate_get(MOD_DSP, 1);
+ rate_iva = module_clk_rate_get(MOD_IVA, 1);
if (cpu_is_omap44xx())
- rate_aess = mod_clk_rate_get("AESS");
+ rate_aess =
+ module_clk_rate_get(MOD_AESS, 1);
else if (cpu_is_omap54xx())
- rate_gpu = mod_clk_rate_get("GPU");
+ rate_gpu =
+ module_clk_rate_get(MOD_GPU, 1);
if (strcmp(opp_s, OPP_UNKNOWN) != 0) {
- rate_dsp_por = mod_por_clk_rate_get(
- "DSP", opp_s);
- rate_iva_por = mod_por_clk_rate_get(
- "IVA", opp_s);
+ rate_dsp_por = module_por_clk_rate_get(
+ MOD_DSP, opp_s);
+ rate_iva_por = module_por_clk_rate_get(
+ MOD_IVA, opp_s);
if (cpu_is_omap44xx())
rate_aess_por =
- mod_por_clk_rate_get(
- "AESS", opp_s);
+ module_por_clk_rate_get(
+ MOD_AESS, opp_s);
else if (cpu_is_omap54xx())
rate_gpu_por =
- mod_por_clk_rate_get(
- "GPU", opp_s);
+ module_por_clk_rate_get(
+ MOD_GPU, opp_s);
}
dprintf(
" DSP Rate: %dMHz, POR Rate: %dMHz\n",
@@ -583,38 +585,46 @@ int opp_show(FILE *stream)
" GPU Rate: %dMHz, POR Rate: %dMHz\n",
rate_gpu, rate_gpu_por);
}
- } else if (strcmp(voltdm, "VDD_CORE") == 0) {
- rate_l3 = mod_clk_rate_get("L3");
+ } else if (strcmp(voltdm.name, VDD_CORE) == 0) {
+ rate_l3 = module_clk_rate_get(
+ MOD_L3_MAIN1_INTERCONNECT, 1);
if (strcmp(opp_s, OPP_UNKNOWN) != 0)
- rate_l3_por = mod_por_clk_rate_get(
- "L3", opp_s);
+ rate_l3_por = module_por_clk_rate_get(
+ MOD_L3_MAIN1_INTERCONNECT,
+ opp_s);
else
rate_l3_por = -1;
dprintf(
" L3_1 Rate: %dMHz, POR Rate: %dMHz\n",
rate_l3, rate_l3_por);
- rate_emif = mod_clk_rate_get("EMIF");
- rate_lpddr2 = mod_clk_rate_get("MEM");
- rate_l4 = mod_clk_rate_get("L4");
+ rate_emif = module_clk_rate_get(MOD_EMIF1, 1);
+ rate_lpddr2 = module_clk_rate_get(
+ MOD_PHY_EMIF, 1);
+ rate_l4 = module_clk_rate_get(
+ MOD_L4_CFG_INTERCONNECT, 1);
if (cpu_is_omap44xx())
- rate_gpu = mod_clk_rate_get("GPU");
+ rate_gpu =
+ module_clk_rate_get(MOD_GPU, 1);
else if (cpu_is_omap54xx())
- rate_aess = mod_clk_rate_get("AESS");
- rate_iss = mod_clk_rate_get("ISS");
- rate_fdif = mod_clk_rate_get("FDIF");
+ rate_aess = module_clk_rate_get(
+ MOD_AESS, 1);
+ rate_iss = module_clk_rate_get(MOD_ISS, 1);
+ rate_fdif = module_clk_rate_get(MOD_FDIF, 1);
if (!cpu_is_omap44xx())
- rate_cal = mod_clk_rate_get("CAL");
+ rate_cal =
+ module_clk_rate_get(MOD_CAL, 1);
else
rate_cal = -1;
- rate_ipu = mod_clk_rate_get("IPU");
- rate_dss = mod_clk_rate_get("DSS");
- rate_hsi = mod_clk_rate_get("HSI");
+ rate_ipu = module_clk_rate_get(MOD_IPU, 1);
+ rate_dss = module_clk_rate_get(MOD_DSS, 1);
+ rate_hsi = module_clk_rate_get(MOD_HSI, 1);
if (cpu_is_omap4470() || cpu_is_omap54xx())
- rate_bb2d = mod_clk_rate_get("BB2D");
+ rate_bb2d = module_clk_rate_get(
+ MOD_BB2D, 1);
else
rate_bb2d = -1;
- rate_c2c = mod_clk_rate_get("C2C");
+ rate_c2c = module_clk_rate_get(MOD_C2C, 1);
}
@@ -624,7 +634,7 @@ int opp_show(FILE *stream)
break;
}
- opp_s2 = opp_get(voltdm, 1);
+ opp_s2 = opp_get(voltdm.name, 1);
if (opp_s2 == NULL) {
dprintf(" OPP NOT detected! (2)\n");
opp_s2 = OPP_UNKNOWN;
@@ -632,26 +642,26 @@ int opp_show(FILE *stream)
dprintf(" OPP detected: %s (2)\n", opp_s2);
}
- volt2 = voltdm_voltage_get(voltdm);
+ volt2 = voltdm_voltage_get(voltdm.name);
dprintf(" Voltage (2): %dV\n", volt2);
- if (strcmp(voltdm, "VDD_MPU") == 0) {
+ if (strcmp(voltdm.name, VDD_MPU) == 0) {
found = ((rate_mpu == rate_mpu_por) &&
(strcmp(opp_s, opp_s2) == 0) &&
(volt == volt2));
- } else if (strcmp(voltdm, "VDD_IVA") == 0) {
+ } else if (strcmp(voltdm.name, VDD_IVA) == 0) {
found = ((strcmp(opp_s, opp_s2) == 0) &&
(volt == volt2) &&
(((unsigned int) rate_dsp == (unsigned int) rate_dsp_por) ||
((unsigned int) rate_iva == (unsigned int) rate_iva_por) ||
((unsigned int) rate_aess == (unsigned int) rate_aess_por)));
- } else if (strcmp(voltdm, "VDD_MM") == 0) {
+ } else if (strcmp(voltdm.name, VDD_MM) == 0) {
found = ((strcmp(opp_s, opp_s2) == 0) &&
(volt == volt2) &&
((rate_dsp == rate_dsp_por) ||
(rate_iva == rate_iva_por) ||
(rate_gpu == rate_gpu_por)));
- } else if (strcmp(voltdm, "VDD_CORE") == 0) {
+ } else if (strcmp(voltdm.name, VDD_CORE) == 0) {
found = ((strcmp(opp_s, opp_s2) == 0) &&
(volt == volt2) &&
(rate_l3 == rate_l3_por));
@@ -662,7 +672,7 @@ int opp_show(FILE *stream)
} while ((retry_cnt < OPP_MAX_RETRY) && (found == 0));
/* Print temperature */
- temp_sensor = temp_sensor_voltdm2sensor(voltdm);
+ temp_sensor = temp_sensor_voltdm2sensor(voltdm.name);
if (temp_sensor == NULL) {
snprintf(table[row][1], TABLE_MAX_ELT_LEN, "NA");
} else {
@@ -693,13 +703,13 @@ int opp_show(FILE *stream)
} else {
fprintf(stderr,
"omapconf: too many %s OPP changes, could not retrieve it!!!\n",
- voltdm);
+ voltdm.name);
strncpy(table[row][4], "ERROR", TABLE_MAX_ELT_LEN);
}
row++;
/* Print clock rates */
- if (strcmp(voltdm, "VDD_MPU") == 0) {
+ if (strcmp(voltdm.name, VDD_MPU) == 0) {
if (cpu_is_online(1) == 1)
strncpy(table[row][0], " MPU (CPU1 ON)",
TABLE_MAX_ELT_LEN);
@@ -709,10 +719,10 @@ int opp_show(FILE *stream)
snprintf(table[row][3], TABLE_MAX_ELT_LEN, " %-4d MHz",
rate_mpu / 1000);
row += 2;
- } else if ((strcmp(voltdm, "VDD_IVA") == 0) ||
- (strcmp(voltdm, "VDD_MM") == 0)) {
+ } else if ((strcmp(voltdm.name, VDD_IVA) == 0) ||
+ (strcmp(voltdm.name, VDD_MM) == 0)) {
strncpy(table[row][0], " IVA", TABLE_MAX_ELT_LEN);
- mmode = mod_mode_get("IVA");
+ mmode = module_mode_get("IVA");
if (mmode == MOD_DISABLED_MODE)
snprintf(table[row][3], TABLE_MAX_ELT_LEN,
"(%-4d MHz) (1)", rate_iva / 1000);
@@ -724,7 +734,7 @@ int opp_show(FILE *stream)
if (cpu_is_omap44xx()) {
strncpy(table[row][0], " AESS",
TABLE_MAX_ELT_LEN);
- mmode = mod_mode_get("AESS");
+ mmode = module_mode_get(MOD_AESS);
if (mmode == MOD_DISABLED_MODE)
snprintf(table[row][3],
TABLE_MAX_ELT_LEN,
@@ -738,7 +748,7 @@ int opp_show(FILE *stream)
} else if (cpu_is_omap54xx()) {
strncpy(table[row][0], " GPU",
TABLE_MAX_ELT_LEN);
- mmode = mod_mode_get("GPU");
+ mmode = module_mode_get(MOD_GPU);
if (mmode == MOD_DISABLED_MODE)
snprintf(table[row][3],
TABLE_MAX_ELT_LEN,
@@ -752,7 +762,7 @@ int opp_show(FILE *stream)
}
strncpy(table[row][0], " DSP", TABLE_MAX_ELT_LEN);
- mmode = mod_mode_get("DSP");
+ mmode = module_mode_get(MOD_DSP);
if (mmode == MOD_DISABLED_MODE)
snprintf(table[row][3], TABLE_MAX_ELT_LEN,
"(%-4d MHz) (1)", rate_dsp / 1000);
@@ -760,7 +770,7 @@ int opp_show(FILE *stream)
snprintf(table[row][3], TABLE_MAX_ELT_LEN,
" %-4d MHz", rate_dsp / 1000);
row += 2;
- } else if (strcmp(voltdm, "VDD_CORE") == 0) {
+ } else if (strcmp(voltdm.name, VDD_CORE) == 0) {
strncpy(table[row][0], " L3", TABLE_MAX_ELT_LEN);
snprintf(table[row][3], TABLE_MAX_ELT_LEN, " %-4d MHz",
rate_l3 / 1000);
@@ -785,7 +795,7 @@ int opp_show(FILE *stream)
if (cpu_is_omap44xx()) {
strncpy(table[row][0], " GPU",
TABLE_MAX_ELT_LEN);
- mmode = mod_mode_get("GPU");
+ mmode = module_mode_get(MOD_GPU);
if (mmode == MOD_DISABLED_MODE)
snprintf(table[row][3],
TABLE_MAX_ELT_LEN,
@@ -799,7 +809,7 @@ int opp_show(FILE *stream)
} else if (cpu_is_omap54xx()) {
strncpy(table[row][0], " AESS",
TABLE_MAX_ELT_LEN);
- mmode = mod_mode_get("AESS");
+ mmode = module_mode_get(MOD_AESS);
if (mmode == MOD_DISABLED_MODE)
snprintf(table[row][3],
TABLE_MAX_ELT_LEN,
@@ -813,7 +823,7 @@ int opp_show(FILE *stream)
}
strncpy(table[row][0], " FDIF", TABLE_MAX_ELT_LEN);
- mmode = mod_mode_get("FDIF");
+ mmode = module_mode_get(MOD_FDIF);
if (mmode == MOD_DISABLED_MODE)
snprintf(table[row][3], TABLE_MAX_ELT_LEN,
"(%-4d MHz) (1)", rate_fdif / 1000);
@@ -825,7 +835,7 @@ int opp_show(FILE *stream)
if (cpu_is_omap54xx()) {
strncpy(table[row][0], " CAL",
TABLE_MAX_ELT_LEN);
- mmode = mod_mode_get("CAL");
+ mmode = module_mode_get(MOD_CAL);
if (mmode == MOD_DISABLED_MODE)
snprintf(table[row][3],
TABLE_MAX_ELT_LEN,
@@ -840,7 +850,7 @@ int opp_show(FILE *stream)
}
strncpy(table[row][0], " IPU", TABLE_MAX_ELT_LEN);
- mmode = mod_mode_get("IPU");
+ mmode = module_mode_get(MOD_IPU);
if (mmode == MOD_DISABLED_MODE)
snprintf(table[row][3], TABLE_MAX_ELT_LEN,
"(%-4d MHz) (1)", rate_ipu / 1000);
@@ -877,7 +887,7 @@ int opp_show(FILE *stream)
}
strncpy(table[row][0], " ISS", TABLE_MAX_ELT_LEN);
- mmode = mod_mode_get("ISS");
+ mmode = module_mode_get(MOD_ISS);
if (mmode == MOD_DISABLED_MODE)
snprintf(table[row][3], TABLE_MAX_ELT_LEN,
"(%-4d MHz) (1)", rate_iss / 1000);
@@ -887,7 +897,7 @@ int opp_show(FILE *stream)
row++;
strncpy(table[row][0], " DSS", TABLE_MAX_ELT_LEN);
- mmode = mod_mode_get("DSS");
+ mmode = module_mode_get(MOD_DSS);
if (mmode == MOD_DISABLED_MODE)
snprintf(table[row][3], TABLE_MAX_ELT_LEN,
"(%-4d MHz) (1)", rate_dss / 1000);
@@ -896,10 +906,11 @@ int opp_show(FILE *stream)
" %-4d MHz", rate_dss / 1000);
row++;
- if (cpu_is_omap4470() || cpu_is_omap54xx()) {
+ if (cpu_is_omap4470() ||
+ (cpu_is_omap54xx() && (cpu_revision_get() != REV_ES1_0))) {
strncpy(table[row][0], " BB2D",
TABLE_MAX_ELT_LEN);
- mmode = mod_mode_get("BB2D");
+ mmode = module_mode_get(MOD_BB2D);
if (mmode == MOD_DISABLED_MODE)
snprintf(table[row][3],
TABLE_MAX_ELT_LEN,
@@ -913,7 +924,7 @@ int opp_show(FILE *stream)