diff options
Diffstat (limited to 'firmware/target/arm')
-rw-r--r-- | firmware/target/arm/imx233/debug-imx233.c | 149 |
1 files changed, 138 insertions, 11 deletions
diff --git a/firmware/target/arm/imx233/debug-imx233.c b/firmware/target/arm/imx233/debug-imx233.c index 7d690446d8..b121450d13 100644 --- a/firmware/target/arm/imx233/debug-imx233.c +++ b/firmware/target/arm/imx233/debug-imx233.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include "dcp-imx233.h" | 33 | #include "dcp-imx233.h" |
34 | #include "pinctrl-imx233.h" | 34 | #include "pinctrl-imx233.h" |
35 | #include "ocotp-imx233.h" | 35 | #include "ocotp-imx233.h" |
36 | #include "pwm-imx233.h" | ||
36 | #include "string.h" | 37 | #include "string.h" |
37 | #include "stdio.h" | 38 | #include "stdio.h" |
38 | 39 | ||
@@ -56,7 +57,6 @@ static struct | |||
56 | unsigned src; | 57 | unsigned src; |
57 | } dbg_irqs[] = | 58 | } dbg_irqs[] = |
58 | { | 59 | { |
59 | { "ssp2_err", INT_SRC_SSP2_ERROR }, | ||
60 | { "vdd5v", INT_SRC_VDD5V }, | 60 | { "vdd5v", INT_SRC_VDD5V }, |
61 | { "dac_dma", INT_SRC_DAC_DMA }, | 61 | { "dac_dma", INT_SRC_DAC_DMA }, |
62 | { "dac_err", INT_SRC_DAC_ERROR }, | 62 | { "dac_err", INT_SRC_DAC_ERROR }, |
@@ -68,7 +68,13 @@ static struct | |||
68 | { "gpio0", INT_SRC_GPIO0 }, | 68 | { "gpio0", INT_SRC_GPIO0 }, |
69 | { "gpio1", INT_SRC_GPIO1 }, | 69 | { "gpio1", INT_SRC_GPIO1 }, |
70 | { "gpio2", INT_SRC_GPIO2 }, | 70 | { "gpio2", INT_SRC_GPIO2 }, |
71 | #if IMX233_SUBTARGET >= 3780 | ||
71 | { "ssp2_dma", INT_SRC_SSP2_DMA }, | 72 | { "ssp2_dma", INT_SRC_SSP2_DMA }, |
73 | { "ssp2_err", INT_SRC_SSP2_ERROR }, | ||
74 | { "lcdif_dma", INT_SRC_LCDIF_DMA }, | ||
75 | { "lcdif_err", INT_SRC_LCDIF_ERROR }, | ||
76 | { "dcp", INT_SRC_DCP }, | ||
77 | #endif | ||
72 | { "i2c_dma", INT_SRC_I2C_DMA }, | 78 | { "i2c_dma", INT_SRC_I2C_DMA }, |
73 | { "i2c_err", INT_SRC_I2C_ERROR }, | 79 | { "i2c_err", INT_SRC_I2C_ERROR }, |
74 | { "timer0", INT_SRC_TIMER(0) }, | 80 | { "timer0", INT_SRC_TIMER(0) }, |
@@ -84,10 +90,7 @@ static struct | |||
84 | { "lradc_ch5", INT_SRC_LRADC_CHx(5) }, | 90 | { "lradc_ch5", INT_SRC_LRADC_CHx(5) }, |
85 | { "lradc_ch6", INT_SRC_LRADC_CHx(6) }, | 91 | { "lradc_ch6", INT_SRC_LRADC_CHx(6) }, |
86 | { "lradc_ch7", INT_SRC_LRADC_CHx(7) }, | 92 | { "lradc_ch7", INT_SRC_LRADC_CHx(7) }, |
87 | { "lcdif_dma", INT_SRC_LCDIF_DMA }, | ||
88 | { "lcdif_err", INT_SRC_LCDIF_ERROR }, | ||
89 | { "rtc_1msec", INT_SRC_RTC_1MSEC }, | 93 | { "rtc_1msec", INT_SRC_RTC_1MSEC }, |
90 | { "dcp", INT_SRC_DCP }, | ||
91 | }; | 94 | }; |
92 | 95 | ||
93 | bool dbg_hw_info_dma(void) | 96 | bool dbg_hw_info_dma(void) |
@@ -166,9 +169,13 @@ bool dbg_hw_info_power(void) | |||
166 | lcd_putsf(0, line++, "%6s %4d %4d %s", #name, trg, bo, buf); \ | 169 | lcd_putsf(0, line++, "%6s %4d %4d %s", #name, trg, bo, buf); \ |
167 | 170 | ||
168 | DISP_REGULATOR(VDDD); | 171 | DISP_REGULATOR(VDDD); |
172 | #if IMX233_SUBTARGET >= 3700 | ||
169 | DISP_REGULATOR(VDDA); | 173 | DISP_REGULATOR(VDDA); |
170 | DISP_REGULATOR(VDDIO); | 174 | DISP_REGULATOR(VDDIO); |
175 | #endif | ||
176 | #if IMX233_SUBTARGET >= 3780 | ||
171 | DISP_REGULATOR(VDDMEM); | 177 | DISP_REGULATOR(VDDMEM); |
178 | #endif | ||
172 | lcd_putsf(0, line++, "DC-DC: pll: %d freq: %d", info.dcdc_sel_pllclk, info.dcdc_freqsel); | 179 | lcd_putsf(0, line++, "DC-DC: pll: %d freq: %d", info.dcdc_sel_pllclk, info.dcdc_freqsel); |
173 | lcd_putsf(0, line++, "charge: %d mA stop: %d mA", info.charge_current, info.stop_current); | 180 | lcd_putsf(0, line++, "charge: %d mA stop: %d mA", info.charge_current, info.stop_current); |
174 | lcd_putsf(0, line++, "charging: %d bat_adj: %d", info.charging, info.batt_adj); | 181 | lcd_putsf(0, line++, "charging: %d bat_adj: %d", info.charging, info.batt_adj); |
@@ -245,7 +252,7 @@ static struct | |||
245 | bool dbg_hw_info_clkctrl(void) | 252 | bool dbg_hw_info_clkctrl(void) |
246 | { | 253 | { |
247 | lcd_setfont(FONT_SYSFIXED); | 254 | lcd_setfont(FONT_SYSFIXED); |
248 | 255 | ||
249 | while(1) | 256 | while(1) |
250 | { | 257 | { |
251 | int button = get_action(CONTEXT_STD, HZ / 10); | 258 | int button = get_action(CONTEXT_STD, HZ / 10); |
@@ -296,7 +303,7 @@ bool dbg_hw_info_clkctrl(void) | |||
296 | bool dbg_hw_info_powermgmt(void) | 303 | bool dbg_hw_info_powermgmt(void) |
297 | { | 304 | { |
298 | lcd_setfont(FONT_SYSFIXED); | 305 | lcd_setfont(FONT_SYSFIXED); |
299 | 306 | ||
300 | while(1) | 307 | while(1) |
301 | { | 308 | { |
302 | int button = get_action(CONTEXT_STD, HZ / 10); | 309 | int button = get_action(CONTEXT_STD, HZ / 10); |
@@ -317,12 +324,17 @@ bool dbg_hw_info_powermgmt(void) | |||
317 | struct imx233_powermgmt_info_t info = imx233_powermgmt_get_info(); | 324 | struct imx233_powermgmt_info_t info = imx233_powermgmt_get_info(); |
318 | 325 | ||
319 | lcd_putsf(0, 0, "state: %s", | 326 | lcd_putsf(0, 0, "state: %s", |
327 | info.state == DISCHARGING ? "discharging" : | ||
328 | #if CONFIG_CHARGING >= CHARGING_MONITOR | ||
320 | info.state == CHARGE_STATE_DISABLED ? "disabled" : | 329 | info.state == CHARGE_STATE_DISABLED ? "disabled" : |
321 | info.state == CHARGE_STATE_ERROR ? "error" : | 330 | info.state == CHARGE_STATE_ERROR ? "error" : |
322 | info.state == DISCHARGING ? "discharging" : | 331 | #endif |
332 | #if CONFIG_CHARGING >= CHARGING_MONITOR | ||
323 | info.state == TRICKLE ? "trickle" : | 333 | info.state == TRICKLE ? "trickle" : |
324 | info.state == TOPOFF ? "topoff" : | 334 | info.state == TOPOFF ? "topoff" : |
325 | info.state == CHARGING ? "charging" : "<unknown>"); | 335 | info.state == CHARGING ? "charging" : |
336 | #endif | ||
337 | "<unknown>"); | ||
326 | lcd_putsf(0, 1, "charging tmo: %d", info.charging_timeout); | 338 | lcd_putsf(0, 1, "charging tmo: %d", info.charging_timeout); |
327 | lcd_putsf(0, 2, "topoff tmo: %d", info.topoff_timeout); | 339 | lcd_putsf(0, 2, "topoff tmo: %d", info.topoff_timeout); |
328 | lcd_putsf(0, 3, "4p2ilimit tmo: %d", info.incr_4p2_ilimit_timeout); | 340 | lcd_putsf(0, 3, "4p2ilimit tmo: %d", info.incr_4p2_ilimit_timeout); |
@@ -364,6 +376,7 @@ bool dbg_hw_info_rtc(void) | |||
364 | } | 376 | } |
365 | } | 377 | } |
366 | 378 | ||
379 | #if IMX233_SUBTARGET >= 3780 | ||
367 | bool dbg_hw_info_dcp(void) | 380 | bool dbg_hw_info_dcp(void) |
368 | { | 381 | { |
369 | lcd_setfont(FONT_SYSFIXED); | 382 | lcd_setfont(FONT_SYSFIXED); |
@@ -409,6 +422,12 @@ bool dbg_hw_info_dcp(void) | |||
409 | yield(); | 422 | yield(); |
410 | } | 423 | } |
411 | } | 424 | } |
425 | #else | ||
426 | bool dbg_hw_info_dcp(void) | ||
427 | { | ||
428 | return true; | ||
429 | } | ||
430 | #endif | ||
412 | 431 | ||
413 | bool dbg_hw_info_icoll(void) | 432 | bool dbg_hw_info_icoll(void) |
414 | { | 433 | { |
@@ -417,7 +436,7 @@ bool dbg_hw_info_icoll(void) | |||
417 | int first_irq = 0; | 436 | int first_irq = 0; |
418 | int dbg_irqs_count = sizeof(dbg_irqs) / sizeof(dbg_irqs[0]); | 437 | int dbg_irqs_count = sizeof(dbg_irqs) / sizeof(dbg_irqs[0]); |
419 | int line_count = lcd_getheight() / font_get(lcd_getfont())->height; | 438 | int line_count = lcd_getheight() / font_get(lcd_getfont())->height; |
420 | 439 | ||
421 | while(1) | 440 | while(1) |
422 | { | 441 | { |
423 | int button = get_action(CONTEXT_STD, HZ / 10); | 442 | int button = get_action(CONTEXT_STD, HZ / 10); |
@@ -447,7 +466,7 @@ bool dbg_hw_info_icoll(void) | |||
447 | { | 466 | { |
448 | struct imx233_icoll_irq_info_t info = imx233_icoll_get_irq_info(dbg_irqs[i].src); | 467 | struct imx233_icoll_irq_info_t info = imx233_icoll_get_irq_info(dbg_irqs[i].src); |
449 | lcd_putsf(0, j, "%s", dbg_irqs[i].name); | 468 | lcd_putsf(0, j, "%s", dbg_irqs[i].name); |
450 | if(info.enabled) | 469 | if(info.enabled || info.freq > 0) |
451 | lcd_putsf(10, j, "%d", info.freq); | 470 | lcd_putsf(10, j, "%d", info.freq); |
452 | } | 471 | } |
453 | lcd_update(); | 472 | lcd_update(); |
@@ -512,6 +531,7 @@ bool dbg_hw_info_pinctrl(void) | |||
512 | } | 531 | } |
513 | } | 532 | } |
514 | 533 | ||
534 | #if IMX233_SUBTARGET >= 3700 | ||
515 | struct | 535 | struct |
516 | { | 536 | { |
517 | const char *name; | 537 | const char *name; |
@@ -582,13 +602,120 @@ bool dbg_hw_info_ocotp(void) | |||
582 | yield(); | 602 | yield(); |
583 | } | 603 | } |
584 | } | 604 | } |
605 | #else | ||
606 | bool dbg_hw_info_ocotp(void) | ||
607 | { | ||
608 | return true; | ||
609 | } | ||
610 | #endif | ||
611 | |||
612 | bool dbg_hw_info_pwm(void) | ||
613 | { | ||
614 | lcd_setfont(FONT_SYSFIXED); | ||
615 | bool detailled_view = false; | ||
616 | |||
617 | while(1) | ||
618 | { | ||
619 | int button = get_action(CONTEXT_STD, HZ / 10); | ||
620 | switch(button) | ||
621 | { | ||
622 | case ACTION_STD_NEXT: | ||
623 | case ACTION_STD_PREV: | ||
624 | detailled_view = !detailled_view; | ||
625 | break; | ||
626 | case ACTION_STD_OK: | ||
627 | case ACTION_STD_MENU: | ||
628 | lcd_setfont(FONT_UI); | ||
629 | return true; | ||
630 | case ACTION_STD_CANCEL: | ||
631 | lcd_setfont(FONT_UI); | ||
632 | return false; | ||
633 | } | ||
634 | |||
635 | lcd_clear_display(); | ||
636 | int line = 0; | ||
637 | if(detailled_view) | ||
638 | lcd_putsf(0, line++, "c cdiv period active/x inactive"); | ||
639 | else | ||
640 | lcd_putsf(0, line++, "pwm"); | ||
641 | for(int i = 0; i < IMX233_PWM_NR_CHANNELS; i++) | ||
642 | { | ||
643 | struct imx233_pwm_info_t info = imx233_pwm_get_info(i); | ||
644 | if(!info.enabled) | ||
645 | continue; | ||
646 | if(detailled_view) | ||
647 | { | ||
648 | lcd_putsf(0, line++, "%d %4d %6d %6d/%c %6d/%c", i, info.cdiv, | ||
649 | info.period, info.active, info.active_state, | ||
650 | info.inactive, info.inactive_state); | ||
651 | } | ||
652 | else | ||
653 | { | ||
654 | char *prefix = ""; | ||
655 | int freq = imx233_clkctrl_get_freq(CLK_XTAL) * 1000 / info.cdiv / info.period; | ||
656 | if(freq > 1000) | ||
657 | { | ||
658 | prefix = "K"; | ||
659 | freq /= 1000; | ||
660 | } | ||
661 | int duty = (info.inactive - info.active) * 100 / info.period; | ||
662 | lcd_putsf(0, line++, "%d @%d %sHz, %d%% %c/%c", i, freq, prefix, | ||
663 | duty, info.active_state, info.inactive_state); | ||
664 | } | ||
665 | } | ||
666 | |||
667 | lcd_update(); | ||
668 | yield(); | ||
669 | } | ||
670 | } | ||
671 | |||
672 | bool dbg_hw_info_usb(void) | ||
673 | { | ||
674 | lcd_setfont(FONT_SYSFIXED); | ||
675 | |||
676 | while(1) | ||
677 | { | ||
678 | int button = get_action(CONTEXT_STD, HZ / 10); | ||
679 | switch(button) | ||
680 | { | ||
681 | case ACTION_STD_NEXT: | ||
682 | BF_SET(USBPHY_CTRL, ENOTGIDDETECT); | ||
683 | BF_SET(USBPHY_CTRL, ENDEVPLUGINDETECT); | ||
684 | break; | ||
685 | case ACTION_STD_PREV: | ||
686 | BF_CLR(USBPHY_CTRL, ENOTGIDDETECT); | ||
687 | BF_CLR(USBPHY_CTRL, ENDEVPLUGINDETECT); | ||
688 | break; | ||
689 | case ACTION_STD_OK: | ||
690 | case ACTION_STD_MENU: | ||
691 | lcd_setfont(FONT_UI); | ||
692 | return true; | ||
693 | case ACTION_STD_CANCEL: | ||
694 | lcd_setfont(FONT_UI); | ||
695 | return false; | ||
696 | } | ||
697 | |||
698 | lcd_clear_display(); | ||
699 | int line = 0; | ||
700 | lcd_putsf(0, line++, "VBUS valid: %d/%d", BF_RD(POWER_STS, VBUSVALID), BF_RD(POWER_STS, VBUSVALID_STATUS)); | ||
701 | lcd_putsf(0, line++, "A valid: %d/%d", BF_RD(POWER_STS, AVALID), BF_RD(POWER_STS, AVALID_STATUS)); | ||
702 | lcd_putsf(0, line++, "B valid: %d/%d", BF_RD(POWER_STS, BVALID), BF_RD(POWER_STS, BVALID_STATUS)); | ||
703 | lcd_putsf(0, line++, "session end: %d", BF_RD(POWER_STS, SESSEND)); | ||
704 | lcd_putsf(0, line++, "dev plugin: %d", BF_RD(USBPHY_STATUS, DEVPLUGIN_STATUS)); | ||
705 | lcd_putsf(0, line++, "OTG ID: %d", BF_RD(USBPHY_STATUS, OTGID_STATUS)); | ||
706 | |||
707 | lcd_update(); | ||
708 | yield(); | ||
709 | } | ||
710 | } | ||
585 | 711 | ||
586 | bool dbg_hw_info(void) | 712 | bool dbg_hw_info(void) |
587 | { | 713 | { |
588 | return dbg_hw_info_clkctrl() && dbg_hw_info_dma() && dbg_hw_info_adc() && | 714 | return dbg_hw_info_clkctrl() && dbg_hw_info_dma() && dbg_hw_info_adc() && |
589 | dbg_hw_info_power() && dbg_hw_info_powermgmt() && dbg_hw_info_rtc() && | 715 | dbg_hw_info_power() && dbg_hw_info_powermgmt() && dbg_hw_info_rtc() && |
590 | dbg_hw_info_dcp() && dbg_hw_info_pinctrl() && dbg_hw_info_icoll() && | 716 | dbg_hw_info_dcp() && dbg_hw_info_pinctrl() && dbg_hw_info_icoll() && |
591 | dbg_hw_info_ocotp() && dbg_hw_target_info(); | 717 | dbg_hw_info_ocotp() && dbg_hw_info_pwm() && dbg_hw_info_usb() && |
718 | dbg_hw_target_info(); | ||
592 | } | 719 | } |
593 | 720 | ||
594 | bool dbg_ports(void) | 721 | bool dbg_ports(void) |