Commit graph

71 commits

Author SHA1 Message Date
William Wilgus
7272f821da Imx233 Disable Autoslow only at maximum cpu frequency
At normal loads:
- disabling auto slow boosts performance at the cost of runtime (~ -5%)
- disabling at max cpu does not noticibly decrease runtime

Change-Id: I5de80201c9a24ce556862151cbd6b21b01708b63
2017-11-12 14:28:03 +01:00
William Wilgus
b2c470719a imx233: Implement mutex for cpu_boost_lock/unlock
Playing AAC-HE files resulted in a race condition between
audio/codec/buffering for set_cpu_frequency

Change-Id: I35e1c1fd18db623e2990c305acdca03f57184d0d
2017-10-28 14:47:21 +02:00
Amaury Pouly
c7f897faa4 zen/zenxfi: always set EMI frequency to 130MHz
The ZEN/X-Fi (STMP3700) don't handle memory frequency scaling really well, for
this reason we run it at a fixed frequency. That frequency was previously set
to 64Mhz because when the CPU run at its lowest frequency, we set the VDD voltage
to 0.975 V and on STMP3700, VDDD=VDDDMEM and this is too low to run EMI at 130Mhz.
This is not a good solution because under heavy load, running the EMI at 64Mhz
results in frame drops and a sluggish device. Thus we now run the EMI at 130Mhz
all the time now. To do so, increase the minimum VDD voltage to 1.275 V.
This may result is a decreased battery life on those targets but it will also
avoid all sorts of glictches and all the device to truly run at full speed.

Change-Id: Ia8391492c29fe67bc2701aa7d8cfd00a9df349e8
2017-08-27 17:50:59 +02:00
Amaury Pouly
b81c1555ef imx233: fix potential bug in udelay
Change-Id: I5c8f5d9917f7a3353862c856bd9bbbbe9b291b1d
2017-08-27 17:49:45 +02:00
Amaury Pouly
c156c5f5e5 zen/zenxfi: adjust maximum emi voltage
Running at 130MHz is unsafe since on those targets, we disable memory frequency
scaling because it is unstable. That leads to situation where cpu is running at
64MHz and VDD is at 1.050V. But on STMP3700, the EMI uses the VDD rail instead
of a dedicated VDDMEM rail as on STMP3780. Thus we are essentially running the
EMI at 130MHz at 1.050V when the minimum recommened voltage is 1.2V. This commit
runs the EMI at 64MHz all the time on the ZEN and ZEN X-Fi which will lead to
reduce performance but hopefully increases stability.

Change-Id: Ida6c2ec130b1778973e383d7c44a06a6ca8f9268
2017-02-04 17:17:44 +01:00
Amaury Pouly
b23b7088cb imx233: add small framework for LED
It handles GPIO and PWM based LEDs, possibly with several channels (red-green
LED for example). The debug allows one to play with the setting.
Currently the code supports the ZEN, ZEN X-Fi, and ZEN Mozaic.

Change-Id: I8c3b66e6ba21778acdb123daabb724280a7d1a4f
2017-01-16 20:08:13 +01:00
Amaury Pouly
a523c3fcfe imx233: fix IRQ handler w.r.t unwinder
The IRQ handler saves registers on the IRQ stack, saves the old PC to imx233
HW_DIGCTL_SCRATCH0 register and switcht to SVC for the actual handling. The
old code had a problem in that if the unwinder is called during the IRQ (for
example by the watchdog), then __get_sp() will use SPSR_svc to discover the
previous mode, switch to it and recover SP. But SPSR_svc is invalid, it should
be SPSR_irq but we switch from IRQ to SVC mode. The new code copies SPSR_irq
to SPSR_svc in IRQ to fix this problem. It also saves/restore SCRATCH0 in
case I one day renable nested interrupts or use SCRATCH0 for other purposes.
I also changed the old watchdog code to call UIE directly instead of trying
to make the code crash with a SWI.

Change-Id: Id87462d410764b019bd2aa9adc71cb917ade32e3
2016-12-12 13:17:33 +01:00
Amaury Pouly
1c97083ca7 imx233: refactor power off and reboot
There is no reason to use different code paths

Change-Id: I4894c7963c802b56b5d3576909e1008a7c401935
2016-12-12 12:06:42 +01:00
Amaury Pouly
d245b7a2a1 imx233: fix system_exception_wait()
The old code used button_get() to read the button status and wait for a
key to leave the panic screen. This is broken since when IRQ are disable,
the button mask is not updated anymore for touchpad and adc buttons. For
now, only use pswitch: this should be good enough for all targets.

Change-Id: I0ae179e24555ac20c3d2bf2d267c1bb0e2ceded0
2016-05-28 17:19:48 +02:00
Amaury Pouly
a25700e4a0 imx233: fix frequency reporting
The code reported the frequency in kHz instead of Hz, thus breaking a debug
screen.

Change-Id: Id46de970cfb55bcdc09b63f59b244ee3ad6264b8
2016-05-28 17:18:52 +02:00
Amaury Pouly
643c0a1e0e imx233: simplify timrot API
The old timrot setup API was very low-level and unfriendly. The new one
makes in easier to select the frequency source. Use to simplify timer
and kernel timer code.

Change-Id: Iffcdf11c00e925be9ec8d9a4efc74b197b6bd2aa
2016-05-28 17:18:32 +02:00
Amaury Pouly
eac1ca22bd imx233: generate register headers using headergen_v2 and update code for it
NOTE: this commit does not introduce any change, ideally even the binary should
be almost the same. I checked the disassembly by hand and there are only a few
differences here and there, mostly the compiler decides to compile very close
expressions slightly differently. I tried to run the new code on several targets
to make sure and saw no difference.

The major syntax changes of the new headers are as follows:
- BF_{WR,SET,CLR} are now superpowerful and allows to set several fileds at once:
  BF_WR(reg, field1(value1), field2(value2), ...)
- BF_CS (use like BF_WR) does a write to reg_CLR and then reg_SET instead of RMW
- there is no more need for macros like BF_{WR_,SET,CLR}_V, since one can simply
  BF_WR with field_V(name)
- the old BF_SETV macro has no trivial equivalent and is replaced with its
  its equivalent for BF_WR(reg_SET, ...)

I also rename the register headers: "regs/regs-x.h" -> "regs/x.h" to avoid the
redundant "regs".

Final note: the registers were generated using the following command:
./headergen_v2 -g imx -o ../../firmware/target/arm/imx233/regs/ desc/regs-stmp3{600,700,780}.xml

Change-Id: I7485e8b4315a0929a8edb63e7fa1edcaa54b1edc
2016-05-28 16:49:22 +02:00
Marcin Bukat
89ba7e818c Get rid of stupid _backlight_* function names
_remote_backlight_* and _buttonlight_* are cleaned as well

Change-Id: I73653752831bbe170c26ba95d3bc04c2e3a5cf30
2015-01-12 11:09:27 +01:00
Amaury Pouly
761f59c9e3 zen/zenxfi: don't switch emi on cpu change to avoid screen flicker
On those targets, since the LCDIF cannot recover from underflow, changing the
EMI frequency kills one frame and cause flicker.

Change-Id: Id3c130636bcfddcc6c54896602699fbaa1636ab4
2014-06-24 18:07:56 +02:00
Amaury Pouly
9637f4486b imx233: rewrite frequency scaling to use the new function
Change-Id: I0f9968de76ce17710d31f7bc609440654e68b6f1
2014-03-08 18:51:54 +01:00
Amaury Pouly
3e2f3efd89 imx233: prepare frequency scaling for stmp3700
Add entry for stmp3700 maximum frequency which is 320MHz.

Change-Id: I6db4aad4efa0a7c1347a1ceb262a0295f63057ae
2014-03-08 18:51:54 +01:00
Amaury Pouly
961498d58a imx233: stop watchdog on exception
Change-Id: If11d90343d32d5889857e7ba30a99f60a87639f1
2014-02-18 18:20:57 +01:00
Amaury Pouly
935c0ad14a imx233: stop the watchdog before loading main firmware
Change-Id: I0a13444d6788a09b0fc04ed1a5115cb2e5fe6f57
2014-02-10 23:14:26 +01:00
Amaury Pouly
6d64111b3c imx233: add hardware and software watchdog
The hardware watchdog automatically shutdown the device after 10s of
inactivity, being defined as 10s without the tick IRQ fired (aka braindead
device).
The software IRQ mechanism is more interesting: it uses a very high priority
timer setup as one-shot to trigger after 5s of inactivity (but IRQ still
enabled). When detected, it patches the running code to insert a SWI
instruction so that on interrupt return it will trigger a SWI and produce
a meaningfull backtrace to debug the deadlock. This should allow to debug
freezes in IRQ context.

Change-Id: Ic55dad01201676bfb6dd79e78e535c6707cb88e6
2014-02-10 23:14:24 +01:00
Amaury Pouly
23c6421f38 imx233: don't compile fm tuner code in bootloader
Change-Id: Icd36e6b03965272eb169a19630b720f38bac6d9e
2013-12-02 20:09:56 +01:00
Amaury Pouly
da7be39614 Fix sim red
Change-Id: Icbdf47c5c508516892b1ce75558b878dc512e780
2013-11-19 22:12:42 +00:00
Amaury Pouly
3d1666042e imx233/system: don't do frequency management on < stmp3780, it's not working
Change-Id: Ie9ff5122f1cb4fe3809bb4c6b88ef0cfc353e0e1
2013-10-22 00:16:22 +02:00
Amaury Pouly
2f5f2ba91d imx233: always boost in bootloader
Many imx233 targets boot in a very low performance mode, typically cpu and
dram at 24MHz. This results in very slow boots and very unstable USB
bootloader mode. Since cpu frequency scaling is disabled in bootloader in
rockbox, always make the frequency scaling code available and boost at boot
time.

Change-Id: Ie96623c00f7c4cd9a377b84dcb14b772558cfa4d
2013-09-25 14:31:39 +02:00
Amaury Pouly
b4c1bb0214 imx233: fix block reset code
Change-Id: I5fbc76315a651c91b278e1c7dc6cb49b7e00d9ad
2013-09-18 13:17:19 +02:00
Amaury Pouly
92725394eb imx233: always set VDDIO to 3.3V
On some device like Creative Zen X-Fi2 it is set to 3.1V on boot.

Change-Id: I1f9e407eb321c31b3109b7fed07862400073b54f
2013-08-22 23:44:15 +02:00
Amaury Pouly
3afcb53fb9 imx233: rework power management
The current code was spreaded over power and powermgmt which made
it behave strangely, especially since there are relationships
between power management and frequency scaling. The new code makes
sure power management is initialised before frequency scaling
starts. It also makes sure to start from a known state, thus
fixing potential issue when the bootloader stops in a trickle
state where DCDC is improperly configured.

Change-Id: Ibded2e590e108f6c98daa52d2cf1bd28763c8923
2013-07-07 17:36:21 +02:00
Amaury Pouly
2773673733 imx233: fix emi frequency scaling
On the ZEN X-Fi2, the fractiona dividers are gated by the
bootloader and must be ungated before switching emi to pll.

Change-Id: I5df57ed5581054883da4cbb3b4f3ce3539391ab5
2013-07-02 00:45:00 +02:00
Amaury Pouly
dafc359fad imx233: fix system for stmp3600 and stmp3700
Change-Id: I2b425b56358ed21269beae27a4afb490939b7f9d
2013-06-17 00:29:26 +02:00
Amaury Pouly
f5ac658d16 imx233: normalise clkctrl
The clkctrl functions were becoming a mess. Normalise the names,
get rid of the xtal derived as special case and use the same
interface.

Change-Id: Ib954a8d30a6bd691914b5e0d97774ec9fc560c50
2013-06-17 00:29:24 +02:00
Amaury Pouly
96b1d02b05 imx233: rewrite digctl using new register headers
Change-Id: I910a09e07b9f5a82bb6cb150739fcebc942cb7c1
2013-06-16 18:21:48 +02:00
Amaury Pouly
2a01b3766f imx233: rewrite clkctrl using new register headers
Change-Id: I6c79e99ed4ab20e00c3110d870e144a6c8596769
2013-06-16 15:28:04 +02:00
Amaury Pouly
4307f95a1f imx233: rework frequency scaling
Move to a table based approach (scales better) and distinguish
between upward changes (increase frequency) and downward changes
(decrease frequency). This provides a better ordering of
operations and in particular it allows to avoid changing the
regulator while running at low speed since it takes a long time !
This should result in a much smoother scaling.

Change-Id: Iad7e5b61277e215f31c07877fbbad07ddde1171f
2013-01-13 00:58:46 +00:00
Amaury Pouly
1fa406dc21 imx233: modify arm cache timings on frequency switch
The manual recommands to tweak the arm cache settings on frequency
changes. The meaning of these values is undocumented but 0 seems
to be a safe value for all frequencies whereas 3 seems to be valid
only for low frequencies (<=64MHz ?)

Change-Id: Iaa8db4af8191010789cf986b1139ff259d73e2ed
2013-01-10 01:02:12 +00:00
Amaury Pouly
5aa19f3eeb imx233: implement emi frequency scaling (disabled by default)
CPU frequency scaling is basically useless without scaling the
memory frequency. On the i.MX233, the EMI (external memory
interface) and DRAM blocks are responsable for the DDR settings.
This commits implements emi frequency scaling. Only some settings
are implemented and the timings values only apply to mDDR
(extracted from Sigmatel linux port) and have been checked to
work on the Fuze+ and Zen X-Fi2/3. This feature is still disabled
by default but I expected some battery life savings by boosting
higher to 454MHz and unboosting lower to 64MHz.
Note that changing the emi frequency is particularly tricky and
to avoid writing it entirely in assembly we rely on the compiler
to not use the stack except in the prolog and epilog (because
it's in dram which is disabled when doing the change) and to put
constant pools in iram which should always be true if the
compiler isn't completely dumb and since the code itself is put
in iram. If this proves to be insufficient, one can always switch
the stack to the irq stack since interrupts are disabled during
the change.

Change-Id: If6ef5357f7ff091130ca1063e48536c6028f23ba
2013-01-10 00:51:35 +00:00
Amaury Pouly
68ff43e94b imx233: correctly restore auto slow on cpu frequency change
Change-Id: I3ba495488e20fdd19d391f84ff484c1ce305d11b
2012-12-29 01:40:35 +01:00
Amaury Pouly
2b1159dda0 imx233: move power init to system init
Do low level power init in system_init(). This can be needed
since imx233 must be able to frequecy scale atfer system_init()
and kernel_init() and this is only possible if power system was
initialised.

Change-Id: I27c66ec0dccd60bda26a45be24683c0bfe72c6da
2012-12-29 01:40:35 +01:00
Amaury Pouly
f7132e4044 Fix copyright headers
Change-Id: Ie65920b1192e9b737fcc2554d280fbcedfa39800
2012-12-29 01:40:35 +01:00
Amaury Pouly
09e6b890e6 imx233: rework cpu frequency scaling
When changing the cpu frequency, it is important to make sure that
HBUS stays at a reasonable frequency otherwise the chip will
crash. Special care is needed about auto-slow and clk_p/clk_h
ratio on intermediate steps.

Change-Id: Ief9f68ddf286caabe75c879718dac5027ab1560f
2012-12-26 01:17:28 +01:00
Amaury Pouly
49cded1704 imx233: properly disable frequency scaling for now
Change-Id: I3d700762a7f46e82ac99fed03e1aa9448b6cba47
2012-09-04 20:25:46 +02:00
Amaury Pouly
a1b101b107 imx233: disable cpu frequency scaling
Frequency scaling seems to be unstable and causes the device to
freeze. It is unclear why at the moment, perhaps we need to ramp
up the vddd voltage to avoid a false brownout ?

Change-Id: I7aaea9d7c213922a65250fe50775fb785d430226
2012-09-04 00:35:58 +02:00
Amaury Pouly
ee21359437 fix comment
Change-Id: I3a20b30e5707e98ffd5dfe3d0f267c5b2d4e7753
2012-08-31 01:06:57 +02:00
Amaury Pouly
d6732a1a9b fix comment
Change-Id: I9eaa21ecfafda9679b4aa1a3d15fa7a550b48876
2012-08-30 23:13:35 +02:00
Amaury Pouly
8723132aaa fix red
Change-Id: I1ee070291d70b2e30ac2096aa8b3b89e6fcdeff1
2012-08-30 21:17:34 +02:00
Amaury Pouly
16dc22f2be fix red
Change-Id: I6bc5fd019160b05f48c9a65639e1025899651f1e
2012-08-30 21:13:28 +02:00
Amaury Pouly
c9ad8688f1 imx233: implement basic frequency scaling and enable auto-slow
This does not scale the EMI frequency and keep the processor
betweel 261MHz and 454MHz. It can still be improve. The auto-slow
divisor could still be change, 8 seems reasonable for now

Change-Id: I639bb3f6b7f8efedc7dc58d08127849156eeb1b6
2012-08-30 20:56:39 +02:00
Amaury Pouly
cd7a478ec1 imx233: enable PLL on startup
Implement PLL enabling/disable and unconditionally power the PLL
on startup. This is needed at least on the Zen X-Fi2.

Change-Id: Ib9ddfdeaf973cedded4b3586dd16aa95a61e78ba
2012-05-21 16:29:11 +02:00
Amaury Pouly
58f8bddf88 zenxfi2: add fmradio i2c glue
Change-Id: Ifa8781b3c416002355b17591a4fdbed8a20979a8
2012-05-20 01:35:24 +02:00
Amaury Pouly
e401683482 zenxfi3&stfm1000: implement fmradio i2c and debug screen
Change-Id: I83dbdee13185d9adcf590dc213da5a8c97adb2ba
2012-05-19 18:04:25 +02:00
Amaury Pouly
3f59cf9708 imx233: fix compilation for target with HAVE_BUTTON_DATA defined
Change-Id: I9d92320b1e545b7ac3983b7f9904f281028cc22d
2012-05-19 16:10:52 +02:00
Amaury Pouly
9d87113958 imx233: add pwm driver
Change-Id: Ib920b119f52b492247d75e97c5ec9298146d583c
2012-05-19 16:10:52 +02:00