/* ------------------------------------------------------------------------*//** * @FUNCTION temp_sensor_show * @BRIEF display all available temperatures formatted in a table. * @RETURNS temperatures formatted in a table * OMAPCONF_ERR_CPU * OMAPCONF_ERR_ARG * OMAPCONF_ERR_INTERNAL * OMAPCONF_ERR_NOT_AVAILABLE * @param[in,out] stream: output file * @param[in,out] sensor: generic temperature sensor name * Use "all" to show all temperatures * @param[in] hw: use s/w (driver based) read or hw_sensor read? * @DESCRIPTION display all available temperatures formatted in a table. * Display both Celcius and Fahrenheit degrees. *//*------------------------------------------------------------------------ */ static int _temp_sensor_show(FILE *stream, const char *sensor, const char hw) { char table[TABLE_MAX_ROW][TABLE_MAX_COL][TABLE_MAX_ELT_LEN]; unsigned int row = 0; int i, count, temp, temp_f; char temp_s[EMIF_TEMP_MAX_NAME_LENGTH]; const char sensor2[TEMP_SENSOR_MAX_NAME_LENGTH]; const genlist *list; CHECK_NULL_ARG(stream, OMAPCONF_ERR_ARG); CHECK_NULL_ARG(sensor, OMAPCONF_ERR_ARG); if (strcasecmp(sensor, "all") != 0) { if (!temp_sensor_is_available(sensor)) { fprintf(stderr, "omapconf: '%s' temperature sensor is not available!\n", sensor); return OMAPCONF_ERR_NOT_AVAILABLE; } if (hw) temp = hwtemp_sensor_get(sensor); else temp = temp_sensor_get(sensor); if (temp == TEMP_ABSOLUTE_ZERO) { fprintf(stderr, "omapconf: could not retrieve '%s' temperature!\n", sensor); return OMAPCONF_ERR_INTERNAL; } else if ((strcasecmp(sensor, TEMP_SENSOR_MEM1) == 0) || (strcasecmp(sensor, TEMP_SENSOR_MEM2) == 0)) { fprintf(stream, "%s\n", emif_mr4_convert((emif_mr4_code) temp, TEMP_CELCIUS_DEGREES)); return 0; } else { fprintf(stream, "%d\n", temp); return 0; } } /* Retrieve temperature sensor list */ list = temp_sensor_list_get(); if (list == NULL) { fprintf(stderr, "omapconf: CPU not yet supported, sorry...\n"); return OMAPCONF_ERR_INTERNAL; } /* Retrieve temperature sensor list count */ count = temp_sensor_count_get(); if (count <= 0) { fprintf(stderr, "omapconf: could not retrieve sensor count!\n"); return OMAPCONF_ERR_INTERNAL; } dprintf("found %d temperature sensors\n", count); /* Fill table header */ row = 0; autoadjust_table_init(table); autoadjust_table_strncpy(table, row, 0, "Sensor"); autoadjust_table_strncpy(table, row, 1, "Temperature (C)"); autoadjust_table_strncpy(table, row++, 2, "Temperature (F)"); /* Fill table with temperatures */ for (i = 0; i < count; i++) { genlist_get((genlist *) list, i, (char *) &sensor2); if (sensor2 == NULL) { fprintf(stderr, "omapconf: could not retrieve sensor!\n"); return OMAPCONF_ERR_INTERNAL; } autoadjust_table_strncpy(table, row, 0, (char *) sensor2); dprintf("%s(): sensor is %s\n", __func__, sensor2); if (hw) temp = hwtemp_sensor_get(sensor2); else temp = temp_sensor_get(sensor2); if (temp != TEMP_ABSOLUTE_ZERO) { if ((strcasecmp(sensor2, TEMP_SENSOR_MEM1) == 0) || (strcasecmp(sensor2, TEMP_SENSOR_MEM2) == 0)) { sprintf(temp_s, "%s", emif_mr4_convert((emif_mr4_code) temp, TEMP_CELCIUS_DEGREES)); autoadjust_table_strncpy(table, row, 1, temp_s); sprintf(temp_s, "%s", emif_mr4_convert((emif_mr4_code) temp, TEMP_FAHRENHEIT_DEGREES)); autoadjust_table_strncpy(table, row++, 2, temp_s); } else { sprintf(temp_s, "%d", temp); autoadjust_table_strncpy(table, row, 1, temp_s); temp_f = celcius2fahrenheit(temp); sprintf(temp_s, "%d", temp_f); autoadjust_table_strncpy(table, row++, 2, temp_s); } } else { autoadjust_table_strncpy(table, row, 1, "NA"); autoadjust_table_strncpy(table, row++, 2, "NA"); } } /* Display table */ return autoadjust_table_fprint(stream, table, row, 3); }
/* ------------------------------------------------------------------------*//** * @FUNCTION vc44xx_config_show * @BRIEF decode and show VC current configuration * @RETURNS 0 in case of success * OMAPCONF_ERR_CPU * OMAPCONF_ERR_REG_ACCESS * @param[in,out] stream: output file (NULL: no output (silent)) * @param[in,out] vc_regs: Voltage Controller registers content * @DESCRIPTION decode and show VC current configuration *//*------------------------------------------------------------------------ */ int vc44xx_config_show(FILE *stream, vc44xx_registers *vc_regs) { voltdm44xx_id id; unsigned char raw_cmd_on, raw_cmd_onlp, raw_cmd_ret, raw_cmd_off; unsigned char cmd_on, cmd_onlp, cmd_ret, cmd_off; char table[TABLE_MAX_ROW][TABLE_MAX_COL][TABLE_MAX_ELT_LEN]; unsigned int row = 0; CHECK_CPU(44xx, OMAPCONF_ERR_CPU); row = 0; autoadjust_table_init(table); autoadjust_table_strncpy(table, row, 0, "PRM VC Configuration"); autoadjust_table_strncpy(table, row, 1, "VC_MPU"); autoadjust_table_strncpy(table, row, 2, "VC_IVA"); autoadjust_table_strncpy(table, row, 3, "VC_CORE"); row++; for (id = OMAP4_VDD_MPU; id <= OMAP4_VDD_CORE; id++) { row = 1; autoadjust_table_strncpy(table, row, 0, "Power IC Slave Address (SA)"); snprintf(table[row][id], TABLE_MAX_ELT_LEN, "0x%02X", vc44xx_sa_get(id, vc_regs->prm_vc_smps_sa, vc_regs->prm_vc_cfg_channel)); row++; autoadjust_table_strncpy(table, row, 0, "Voltage Reg. Addr (VOLRA)"); snprintf(table[row][id], TABLE_MAX_ELT_LEN, "0x%02X", vc44xx_volra_get(id, vc_regs->prm_vc_cfg_channel, vc_regs->prm_vc_smps_ra_vol)); row++; autoadjust_table_strncpy(table, row, 0, "Command Reg. Addr (CMDRA)"); snprintf(table[row][id], TABLE_MAX_ELT_LEN, "0x%02X", vc44xx_cmdra_get(id, vc_regs->prm_vc_cfg_channel, vc_regs->prm_vc_val_smps_ra_cmd)); row++; autoadjust_table_strncpy(table, row++, 0, "Command Values:"); vc44xx_raw_cmd_values_get(id, vc_regs, &raw_cmd_on, &raw_cmd_onlp, &raw_cmd_ret, &raw_cmd_off); vc44xx_cmd_values_get(id, vc_regs, &cmd_on, &cmd_onlp, &cmd_ret, &cmd_off); strncpy(table[row][0], " ON", TABLE_MAX_ELT_LEN); snprintf(table[row][id], TABLE_MAX_ELT_LEN, "0x%02X (%.6lfV)", raw_cmd_on, smps_vsel2volt(vdd_id2smps_id(id), cmd_on)); row++; autoadjust_table_strncpy(table, row, 0, " ON-Low-Power (ONLP)"); snprintf(table[row][id], TABLE_MAX_ELT_LEN, "0x%02X (%.6lfV)", raw_cmd_onlp, smps_vsel2volt(vdd_id2smps_id(id), cmd_onlp)); row++; autoadjust_table_strncpy(table, row, 0, " RET"); snprintf(table[row][id], TABLE_MAX_ELT_LEN, "0x%02X (%.6lfV)", raw_cmd_ret, smps_vsel2volt(vdd_id2smps_id(id), cmd_ret)); row++; autoadjust_table_strncpy(table, row, 0, " OFF"); snprintf(table[row][id], TABLE_MAX_ELT_LEN, "0x%02X (%.6lfV)", raw_cmd_off, smps_vsel2volt(vdd_id2smps_id(id), cmd_off)); row++; } if (stream != NULL) autoadjust_table_fprint(stream, table, row, 4); return 0; }
/* ------------------------------------------------------------------------*//** * @FUNCTION emif54xx_dump * @BRIEF dump selected registers * @RETURNS 0 in case of success * OMAPCONF_ERR_CPU * OMAPCONF_ERR_ARG * @param[in,out] stream: output stream * @param[in] id: EMIF module ID * If id == EMIF54XX_MODS_COUNT, dump all EMIF registers. * @DESCRIPTION dump selected registers and pretty-print it in selected * output stream *//*------------------------------------------------------------------------ */ int emif54xx_dump(FILE *stream, emif54xx_mod_id id) { unsigned int i = 0, mid, accessible; unsigned int val = 0; int err = 0; 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; CHECK_CPU(54xx, OMAPCONF_ERR_CPU); CHECK_NULL_ARG(stream, OMAPCONF_ERR_ARG); if (id > EMIF54XX_MODS_COUNT) { fprintf(stderr, "%s(): id (%u) > EMIF54XX_MODS_COUNT!!! (%u)\n", __func__, id, EMIF54XX_MODS_COUNT); err = OMAPCONF_ERR_ARG; goto emif54xx_dump_end; } autoadjust_table_init(table); row = 0; if (id != EMIF54XX_MODS_COUNT) snprintf(table[row][0], TABLE_MAX_ELT_LEN, "%s Reg. Name", emif54xx_mod_name_get(id)); else strncpy(table[row][0], "EMIF Reg. Name", TABLE_MAX_ELT_LEN); strncpy(table[row][1], "Reg. Address", TABLE_MAX_ELT_LEN); strncpy(table[row][2], "Reg. Value", TABLE_MAX_ELT_LEN); row++; for (mid = 0; mid < EMIF54XX_MODS_COUNT; mid++) { if ((id != EMIF54XX_MODS_COUNT) && (mid != id)) continue; else { switch (mid) { case EMIF54XX_EMIF1: accessible = module_is_accessible(MOD_EMIF1); break; case EMIF54XX_EMIF2: accessible = module_is_accessible(MOD_EMIF2); break; default: accessible = 0; } if (!accessible) { printf("%s module is not running, registers not" " accessible.\n", emif54xx_mod_name_get(mid)); return 0; } if (cpu_revision_get() == REV_ES1_0) mod = emif54xxes1_mods[mid]; else mod = emif54xx_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); emif54xx_dump_end: return err; }
/* ------------------------------------------------------------------------*//** * @FUNCTION prm54xx_dump * @BRIEF dump selected registers and pretty-print it in * selected output stream * @RETURNS 0 in case of success * OMAPCONF_ERR_CPU * OMAPCONF_ERR_ARG * @param[in,out] stream: output stream * @param[in] id: PRM module ID - If id == PRM54XX_MODS_COUNT, * dump all PRM registers. * @DESCRIPTION dump selected registers and pretty-print it in * selected output stream *//*------------------------------------------------------------------------ */ int prm54xx_dump(FILE *stream, prm54xx_mod_id id) { unsigned int i = 0, mid; unsigned int val = 0; int err = 0; reg **mod; reg *r; char s[TABLE_MAX_ELT_LEN]; char table[TABLE_MAX_ROW][TABLE_MAX_COL][TABLE_MAX_ELT_LEN]; unsigned int row; if (stream == NULL) { fprintf(stderr, "%s(): stream == NULL!!!\n", __func__); err = OMAPCONF_ERR_ARG; goto prm54xx_dump_end; } if (id > PRM54XX_MODS_COUNT) { fprintf(stderr, "%s(): id (%u) > PRM54XX_MODS_COUNT!!! (%u)\n", __func__, id, PRM54XX_MODS_COUNT); err = OMAPCONF_ERR_ARG; goto prm54xx_dump_end; } autoadjust_table_init(table); row = 0; if (id != PRM54XX_MODS_COUNT) snprintf(table[row][0], TABLE_MAX_ELT_LEN, "%s Reg. Name", prm54xx_mod_name_get(id)); else strncpy(table[row][0], "PRM 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 = PRM54XX_DSS_PRM; mid < PRM54XX_MODS_COUNT; mid++) { if ((id != PRM54XX_MODS_COUNT) && (mid != id)) continue; else { if (cpu_revision_get() == REV_ES1_0) mod = prm54xxes1_mods[mid]; else mod = prm54xx_mods[mid]; for (i = 0; mod[i] != NULL; i++) { r = mod[i]; /* Read register */ val = reg_read(r); /* 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); prm54xx_dump_end: return err; }
/* ------------------------------------------------------------------------*//** * @FUNCTION sr54xx_dump * @BRIEF dump selected registers and pretty-print it in selected * output stream * @RETURNS 0 in case of success * OMAPCONF_ERR_CPU * OMAPCONF_ERR_ARG * @param[in,out] stream: output stream * @param[in] id: SR module ID - If id == SR54XX_MODS_COUNT, * dump all SR registers. * @DESCRIPTION dump selected registers and pretty-print it in selected * output stream *//*------------------------------------------------------------------------ */ int sr54xx_dump(FILE *stream, sr54xx_mod_id id) { unsigned int i = 0, mid; unsigned int val = 0; int err = 0; reg **mod; reg *r; char s[TABLE_MAX_ELT_LEN]; char table[TABLE_MAX_ROW][TABLE_MAX_COL][TABLE_MAX_ELT_LEN]; unsigned int row; if (stream == NULL) { fprintf(stderr, "%s(): stream == NULL!!!\n", __func__); err = OMAPCONF_ERR_ARG; goto sr54xx_dump_end; } if (id > SR54XX_MODS_COUNT) { fprintf(stderr, "%s(): id (%u) > SR54XX_MODS_COUNT!!! (%u)\n", __func__, id, SR54XX_MODS_COUNT); err = OMAPCONF_ERR_ARG; goto sr54xx_dump_end; } autoadjust_table_init(table); row = 0; if (id != SR54XX_MODS_COUNT) snprintf(table[row][0], TABLE_MAX_ELT_LEN, "%s Reg. Name", sr54xx_mod_name_get(id)); else strncpy(table[row][0], "SR 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 = SR54XX_SMARTREFLEX_MPU; mid < SR54XX_MODS_COUNT; mid++) { if ((id != SR54XX_MODS_COUNT) && (mid != id)) continue; else { if (!sr54xx_is_enabled(mid)) { if (stream != NULL) fprintf(stream, "%s module not running" ", registers not accessible.\n", sr54xx_mod_name_get(mid)); return 0; } mod = sr54xx_mods[mid]; for (i = 0; mod[i] != NULL; i++) { r = mod[i]; /* Read register */ val = reg_read(r); /* 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_fprint(stream, table, row, 3); sr54xx_dump_end: return err; }