Commit graph

3927 commits

Author SHA1 Message Date
William Wilgus
084aa9c1fd Sansa ClipZip set lcd SSP properly
Change-Id: Ice62dfa7f266ee4369793777a39e675bceae1831
2020-05-23 14:44:34 +02:00
William Wilgus
4382d3f5ed ClipZip LCD Corruption Backlight fix
User reported LCD screen corruption via forum in 3.14 and 3.15
turning backlight off and back on seems to fix the issue
http://forums.rockbox.org/index.php/topic,53192.0.html

Change-Id: Id0b34d2f9b77e79ab0ecabace331f0b203184724
2020-04-17 06:53:33 +02:00
Solomon Peachy
a820a98361 obsolete: Nuke the very-incomplete Archos AV300 target
It's even missing a config header file.  Just shoot it in the head.

Change-Id: I4c5cdb4fb63361a4e4fc893e93d73d3890fe17df
2020-04-13 22:06:22 +02:00
Solomon Peachy
5bd86eb4b4 pp502x: Don't fill the cache starting from address 0x0
The pp502x cache init code tries to flush the cache by reading
a block of DRAM.  Change the starting point from 0x0 to 0x1000
so the compiler doesn't helpfully insert an undefined instruction
to deliberately crash the target.

(This behavior is intentional on the part of GCC, and was triggered
 by using -Os with my experimental 4.9.4 toolchain)

Change-Id: I2d2719615a1164a035f3dac8a56dd3737bbab1d5
2020-04-04 23:07:04 +02:00
William Wilgus
8794b95a72 Fix As3525 SD unused parameter warning
Change-Id: I0a4bbcf94e9cadf43a822c1cb2f2dad3bd4f7588
2019-12-30 23:41:46 -06:00
William Wilgus
9f336217c2 Sansa AS3525V1 Sd Interface implement powersave mode
This patch cleans up the sd driver for the V1 sansas
powersave implemented for the sd interface

Change-Id: I3d864f7aa304cf792cc65fa4ff06c1e52fbed329
2019-12-31 05:57:38 +01:00
Franklin Wei
3d6d90382e iPod Classic: enable IRAM1 in bootloader
7442742 ("iPod Classic: disable IRAM1") was causing subsequent ipod6g
bootloader builds to result in a completely black screen upon
installation, with recovery only possible with a reflash through DFU
mode.

IRAM1 is re-enabled for bootloader only.

Change-Id: I92d489c91f81cad55d66a8647c1e61a45f468770
2019-10-13 23:23:32 -04:00
Sebastian Leonhardt
03e63da316 YH820: implement LCD sleep
use sleep setting to keep transflective LCD active without backlight

Change-Id: Iccd97e956d5e4a2a22abc90d15e9123782126ecb
2019-02-07 20:04:19 +01:00
Solomon Peachy
d4942cc74c Add Xuelin iHIFI 770/770C/800 support
Taken from the xvortex fork (Roman Stolyarov)
Ported, rebased, and cleaned up by myself.

Change-Id: I7b2bca2d29502f2e4544e42f3d122786dd4b7978
2019-01-02 08:10:01 -05:00
Cástor Muñoz
7442742208 iPod Classic: disable IRAM1
On Classic, IRAM1 (second 128Kb of a total of 256KB available IRAM) is
slower than DRAM. Codecs that actually are using regions of IRAM1 runs
faster when DRAM is used, so IRAM1 is disabled and only IRAM0 remains
enabled: 48KB for core and 80KB for codecs/plugins.

The next test_codec results shows how decode time is decreased:

file           boosted     unboosted
*.ra           ~1.5%       ~0.5%
*.mpc          ~21%        ~4.5%
*.ogg          ~0.5%       ~0%
nero_he*.m4a   ~8%         ~1%
nero*.m4a      ~25%        ~7%
wmapro*.wma    ~4.5%       ~0%
wma*.wma       ~25%        ~7%

In addition there is a small power save when IRAM1 HW is disabled.

Change-Id: I102adee11458e82037f23076d5d5956e23235de8
2018-07-30 18:50:27 -04:00
William Wilgus
d8bd356e56 Revert "As3525 v1/v2 Add power savings menu"
This reverts commit 6f0320a953.

Change-Id: I7425d422a4a0af7a49e9194cfe0bb55d431bc401
2018-07-28 17:35:07 +02:00
William Wilgus
16f10e2abd Revert "Fix Red on PowerSave in Simulator"
This reverts commit 568b81202e.

Change-Id: I2af42cd53d0ce490bf96c68288e9fbde034c0069
2018-07-28 17:34:31 +02:00
Michael Giacomelli
c75aac8424 Slightly raise voltage on FuzeV2 devices.
Some devices seem to have trouble accessing the storage at lower voltages.
2018-07-28 11:05:59 -04:00
William Wilgus
568b81202e Fix Red on PowerSave in Simulator
Change-Id: Ic5d9de230efceabc2c428e5c78fa6596a5a34840
2018-07-28 14:55:52 +02:00
William Wilgus
6f0320a953 As3525 v1/v2 Add power savings menu
Allow user to select cpu undervolt

There have been quite a few issues across the SANSA AMS line related
to CPU undervolting while most players show greatly increased runtime
some crash.
Rather than constanly upping the voltage we now have a
setting with a safe value for all players and the option for lower voltages

I plan to add a few other options here later such as disk
timings and maybe some other clocks/experimental settings

Added: Disk Low speed option for AS3525v2 devices cuts
	frequency to 12 MHz from 24 MHz
Added: Disk Low speed option for AS3525v1 devices cuts
        frequency to 15.5 MHz from 31 MHz

Added: I2c Low Speed AS3525 devices, should be bigger improvement for v1 devices

Fixed: Debug menu for AS3525v2 No SDSLOT frequency,
	Showed IDE freq though it is unused

Added: DBOP and SSP underclocking affects display on v1/v2 respectively

Fixed: debug menu now has SSP frequency, and SSP_CPSR

Update: made settings menu more generic

Update: cleaned up code

Added: Clip v1 & Fuze v1 didn't have HAVE_ADJUSTABLE_CPU_VOLTAGE.
	not sure why but,  waiting on testing to confirm

Added: C200v2 and E200v2 devices and HAVE_ADJUSTABLE_CPU_VOLTAGE.

Fixed: v1 devices don't like display timing set lower (dbop)
       v1 devices don't have a divider set for ssp (causes divide by 0)

Fixed: ClipZip display lags with Max SSP divider changed from 0xFE to 0x32

Fixed: v1 devices didn't work properly with highspeed sd cards
	Added code from http://gerrit.rockbox.org/r/#/c/1704/
	Added powersave and IDE interface enable/disable

Added: V2 devices now have powersave enabled on sd interface

Update: cleaned up code, lang defines, added manual entries

Update ssp clock mechanism added calculated ssp divider to clipzip

Update turn display clock off when clip+ turns off display

Fixed: clipzip wrong register for SSP clock

Change-Id: I04137682243be92f0f8d8bf1cfa54fbb1965559b
TODO: add other players?
2018-07-27 23:56:32 +02:00
William Wilgus
dcd71e66bd Optimize lcd-ssd1303 driver (clip series)
Saves 100+ bytes (50 of it in iram), saves a bit of power

Internal LCD clock decreased but with added efficiency of drawing routines
loses only around 2 Hz on the scanrate (~75Hz) while fps is slightly increased

Column offsets are now calculated outside the loops saving a few instructions

Passing a LCD_NOP command after lcd_update turns off Data/Cmd# gpio
saving a bit more power

Added a function lcd_write_cmd_triple() that allows 3 commands to be sent at once
when enabled with LCD_USE_FIFO_FOR_COMMANDS it sends them back to back without
checking FIFO status in between or sending to thhe D/C# Gpio.
Makes an assumption about the FIFO being large enough to
accept 3 commands after being emptied which should be the case on the
clipv1, clipv2, clipplus. I have only enabled it for the clip plus
as thats the only device I have to test it on.

On clip+ the SSP clock is now turned off when screen is off

Change-Id: Ib5fd24697bfe4ac8b8ee017361e789e4a7910d21
2018-07-26 04:23:28 +02:00
William Wilgus
056d4b0ec0 Update AS3525 v1/v2 debug menu; add scrolling and missing frequencies
On the clip zip most debug menu items get cut off and there is
no way to read most of the debug menu items.

This patch makes the menu button scroll the text 1 character
to the right with each press and the center (select) button
re-aligns the text

Adds SSP frequency(v2) & register
Adds SD slot frequency(v2)

Change-Id: If4705d6790e25061931ca654062e22fc2e0a6f16
2018-07-26 04:00:28 +02:00
William Wilgus
c15af64452 AMS v1/v2: Fix I2C2_CSPR debug menu entry
I2c controller needs to be enabled in order to read CSPR0, CSPR1
registers function sets CGU_I2C_AUDIO_MASTER_CLOCK_ENABLE
and only clears if it wasn't previously enabled

Use divider set in register to calculate frequency rather than
hard coded divider

Change-Id: I54ecc0c1859e906c00f4c2ae8ae2424a4619df98
2018-07-25 06:03:44 +02:00
William Wilgus
6a568761c8 CLIPPLUS -- Remove un-needed handling for power button button button_read_device()
switching GPIOB in order to read GPIOD96)
(power button) is apparently unneeded

Change-Id: I1fbf13f67f938806086754cdd5e389ef6746ae5f
2018-07-25 06:01:56 +02:00
Michael Sevakis
19b2964d78 AMS v1/v2: Remove sd_enabled as an externally-visible variable.
Also removes the sd_enable() function call. It was only used in
the debug screen on AMSv1 and not used at all on AMS v2.

For v1,obtain debug info in a struture passed to a dedicated
debug info function so that enabling and disabling the controller
isn't racy.

Change-Id: I7c44693bc2df5a1f16168b05b3abfe622f9584ce
2018-07-04 15:20:47 +02:00
William Wilgus
1f63604e2c Fuze PLUS Fix lcd_update_rect()
Lcd_update rect was hanging during horizontal screen update x = 238 and width = 2
which was within the bounds of the screen, this seems to be a weird corner case
but more testing needs done.

Update_rect now properly bounded between 0 - screen w/h
--Cleaned up code

Pixels in x are now multiples of 4.

Datasheet states:
-------------------------------------------------------------------------------------------
WORD_LENGTH=0 implies the input frame buffer is RGB 16 bits per pixel.
DATA_FORMAT_16_BIT field indicates if the pixels are in RGB 555 or RGB 565 format.
Limitations:
— BYTE_PACKING_FORMAT [3:0] should be 0x3 or 0xC if there is only one pixel per word.
— If there are two pixels per word, BYTE_PACKING_FORMAT [3:0] should be 0xF and
H_COUNT will be restricted to be a multiple of 2 pixels.

and

WORD_LENGTH=3 indicates that the input frame-buffer is RGB 24 bits per pixel (RGB 888). If
BYTE_PACKING_FORMAT [3:0] is 0x7, it indicates that there is only one pixel per 32-bit word
and there is no restriction on H_COUNT.
Limitations:
— If BYTE_PACKING_FORMAT [3:0] is 0xF, it indicates that the pixels are packed, i.e. there
are 4 pixels in 3 words or 12 bytes. In that case, H_COUNT must be a multiple of 4 pixels.
-------------------------------------------------------------------------------------------

We are using 16 bits per pixel and byte_packing = 0xF but device crashes with multiple of 2 pixels

Behaviour can be verified with plugin - oscilloscope, Horizontal mode device hangs as indicator
reaches right of screen

Change-Id: I1445f5334f4e7fe59304c65c76b47d0daa0614b2
2018-05-25 22:48:01 +02:00
Sebastian Leonhardt
0486e5b93e Zen XFi2: Enable Plugins
Keymaps aren't tested, there may be room for improvement.


Change-Id: I6b8fe697899b241ea6e96f4fe446d88671ad7818
2018-04-03 11:34:01 +02:00
Michael Sevakis
a1123de28f Gigabeat S: Remove unwanted partitions on the fly
Windows now ignores the hidden flag, so just nullify the entries
to hide depending upon whether or not bootloader install mode is
activated.

Change-Id: I00d0797e40ea3b5f5d5d8e1243b50cfcdd029bb4
2018-01-14 08:23:48 -05:00
Michael Sevakis
f4c4221306 Convert i.MX31 and AMS target to use RTC interrupt
Instead of checking ticks, set a sticky dirty flag that indicates
that the RTC needs to be read. This gives a timely update and more
accurate readout without actually reading the RTC until it changes.
The implementation should atomically read the flag and clear it.
Setting the flag would typically happen in an RTC tick ISR.

Change-Id: I6fd325f22845029a485c502c884812d3676026ea
2017-11-21 07:52:02 -05:00
Michael Sevakis
5c9688961e Implement a much more capable vuprintf()
New support as well as some buggy support fixed.

Still no floating point support if ever that would be desired.

Support (*):
* Flags: '-', '+', ' ', '#', '0'

* Width and precision: 'n', '.n', '*' and '.*'

* Length modifiers: 'hh', 'h', 'j', 'l', 'll', 't', 'z'

* Radix: 'c', 'd', 'i', 'n', 'o', 'p/P', 's', 'u', 'x/X'

(*) Provision exists to switch lesser-used stuff on or off or when
certain functionality isn't desired (bootloader?). The compulsory
radixes are everything but 'o', 'n', 'p/P' and 'x/X' with length
modifiers being optional. The default setup is 'l', 'z', 'c', 'd',
'p/P', 's', 'u', 'x/X'.

* Move fdprintf() to its own file. It was in a strange place.

* Make callers compatible and fix a couple snprintf() bugs while
at it.

Could smush it down in size but I'm gonna get over the binsize
neurosis and just the let optimizer do its thing.

Change-Id: Ibdc613a9b6775802c188b29b9dd46c568c94f7c3
2017-11-21 05:00:27 -05:00
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
Amaury Pouly
8a925d283d fuzep: fix rds
Change-Id: I15900f638f8f45cb7035a0e7b1caecb62d1d70e8
2017-11-04 19:28:40 +01:00
Michael Sevakis
8ef33f479e AMS: Convert ascodec_endofch() to use bit mod function's return value.
It cleans up the code and it was the initial inspiring reason to
change them.

Change-Id: I299499117b8a12d93d13d6563683bab89ab80555
2017-10-30 22:12:58 -04:00
Michael Sevakis
f728559bf9 Make atomic bit modification functions return previous value.
Change-Id: I19a94cf946735e1d9e51c3207cd82198fd4dfc1a
2017-10-30 21:43:15 -04:00
William Wilgus
efb71ed0ce Add boot data to MOST AS3525 Devices
Adds boot data to as3525 devices Sansa C200v2 E200v2 Clip Clipv2 Clip+ ClipZip
fuze, fuzev2 m200v4

Adds boot_data to features.txt

default arm crt0.s now had boot data if HAVE_BOOTDATA is defined

Change-Id: I614a556696540511a69fc12a4520b01c268bf8a9
2017-10-29 17:52:40 +01:00
William Wilgus
41869a6534 Add boot data support to rockbox.
Bootdata is a special location in the Firmware marked by a magic header
The bootloader is able to copy information to the firmware by locating
this struct and passing data to the firmware when it is loaded but
before it is actually executed

Data is verified by a crc of the bootdata


Change-Id: Ib3d78cc0c3a9d47d6fe73be4747a11b7ad6f0a9e
2017-10-29 17:50:59 +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
Michael Sevakis
e4a46c8d88 Fix a few missed things in 16454efc (and hopefully clear the red).
Change-Id: I2ce88e4c41e6e08efbfbdf261122318dfb0f8b0f
2017-10-26 16:32:53 -04:00
Michael Sevakis
1654efc313 Unify storage threads into one
* Editing a bunch of drivers' thread routines in order to
implement a new feature is tedious.

* No matter the number of storage drivers, they share one thread.
No extra threads needed for CONFIG_STORAGE_MULTI.

* Each has an event callback called by the storage thread.

* A default callback is provided to fake sleeping in order to
trigger idle callbacks. It could also do other default processing.
Changes to it will be part of driver code without editing each
one.

* Drivers may sleep and wake as they please as long as they give
a low pulse on their storage bit to ask to go into sleep mode.
Idle callback is called on its behalf and driver immediately put
into sleep mode.

* Drivers may indicate they are to continue receiving events in
USB mode, otherwise they receve nothing until disconnect (they
do receive SYS_USB_DISCONNECTED no matter what).

* Rework a few things to keep the callback implementation sane
and maintainable. ata.c was dreadful with all those bools; make
it a state machine and easier to follow. Remove last_user_activity;
it has no purpose that isn't served by keeping the disk active
through last_disk_activity instead.

* Even-out stack sizes partly because of a lack of a decent place
to define them by driver or SoC or whatever; it doesn't seem too
critical to do that anyway. Many are simply too large while at
least one isn't really adequate. They may be individually
overridden if necessary (figure out where). The thread uses the
greatest size demanded. Newer file code is much more frugal with
stack space. I barely see use crack 50% after idle callbacks
(usually mid-40s). Card insert/eject doesn't demand much.

* No forcing of idle callbacks. If it isn't necessary for one or
more non-disk storage types, it really isn't any more necessary for
disk storage. Besides, it makes the whole thing easier to implement.

Change-Id: Id30c284d82a8af66e47f2cfe104c52cbd8aa7215
2017-10-26 14:35:41 -04:00
Amaury Pouly
3d815406f4 Don't call touchscreen functions when we don't have a touchscreen
Change-Id: Ia8c05f45c289729031d6333445d932bb5ac242ca
2017-09-17 00:27:10 +02:00
Amaury Pouly
546d229ae4 imx233: make debug usable with a touchscreen
Change-Id: I08a3302024646c0d915aa34855970678730eb44c
2017-09-17 00:04:32 +02:00
Amaury Pouly
064fa902c5 zenxfi2: fix touchscreen bug
Due to some undocumented behavior, the touchscreen was almost unusable in point
mode. Now it's much better but still not very nice to use, probably it needs some
filtering.

Change-Id: Idc8a0214b09f268e6be907ee6ec3126cc0d88773
2017-09-17 00:04:14 +02:00
Amaury Pouly
1d121e8c08 Initial commit for the Sony NWZ linux port
SUPPORTED SERIES:
- NWZ-E450
- NWZ-E460
- NWZ-E470
- NWZ-E580
- NWZ-A10

NOTES:
- bootloader makefile convert an extra font to be installed alongside the bootloader
  since sysfont is way too small
- the toolsicon bitmap comes from the Oxygen iconset
- touchscreen driver is untested

TODO:
- implement audio routing driver (pcm is handled by pcm-alsa)
- fix playback: it crashes on illegal instruction in DEBUG builds
- find out why the browser starts at / instead of /contents
- implement radio support
- implement return to OF for usb handling
- calibrate battery curve (NB: of can report a battery level on a 0-5 scale but
  probabl don't want to use that ?)
- implement simulator build (we need a nice image of the player)
- figure out if we can detect jack removal

POTENTIAL TODOS:
- try to build a usb serial gadget and gdbserver

Change-Id: Ic77d71e0651355d47cc4e423a40fb64a60c69a80
2017-09-05 21:42:12 +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
7677a9946f zen/zenxfi: increase LCD clock frequency
Change-Id: I157e0d537a1b9d73eda4e18a4a64b10410c6fac4
2017-08-27 17:49:11 +02:00
Amaury Pouly
5d2d747247 imx233: update comment about vbusvalid
Change-Id: Ice1ece716657fa7f78f69736e5e733e1b7f67b59
2017-08-27 17:48:39 +02:00
Amaury Pouly
7ce764cdc3 zen/zenxfi: fix backlight white flash on backlight on
Change-Id: If028a208bd10f46dbe25e4aade085ba7ba13d7be
2017-08-27 17:33:29 +02:00
Franklin Wei
5645135092 Fix stupid omission
Change-Id: I9d65b8feeeb4c31e14fa60b370a12c0cc8b13f54
2017-08-16 11:02:55 -04:00
Franklin Wei
6df15ea653 Remove mutex_* calls from the MR:500 SPI driver
As before, they would trigger a panic.

Change-Id: I3c140f2897a9d3ed21e13f0a9e45025ede311de5
2017-08-16 10:51:29 -04:00
Franklin Wei
e00d78d5ab Remove bad mutex lock/unlock from tcc780x SD driver
This should make cowond2 work again.

Change-Id: Ib23d1548f72f9b604adad46fa1a1c0adee53c29e
2017-08-10 22:11:18 -04:00
Franklin Wei
0dbf7017be Remove bad mutex_* calls in telechips i2c driver
These were being called in a cpu mode they shouldn't have been,
leading to panics.

Change-Id: I7fbd0e4af5c6cbaf7177f9dafa901b3924617d7f
2017-08-10 21:53:55 -04:00
Amaury Pouly
3e1c8cca92 fix yellow
Change-Id: I682e8298aa926c3c9c073b22abdcef7f5dfef9aa
2017-07-31 09:18:25 +02:00
Amaury Pouly
70b4d1a9a6 imx233: fix horrible bug in linreg offset calculation
This was actually harmless because it was only used for the debug screen.

Change-Id: I76e802c947fdefa8df498ecfeb53e4b6ce0e12bb
2017-07-31 01:04:24 +02:00
Amaury Pouly
17e48e81af imx233: don't print stmp3780 debug info on stmp3700
Change-Id: Iffad6f39b62af496e6bb5975610807228c2986c7
2017-07-31 01:04:24 +02:00
Michael Giacomelli
365a005038 Slightly increase CVDD2 on AMSv2.
At least one person found an SD card that wouldn't work at 2.7v.

Change-Id: I84001f07acc9ce36c71165706cce28c2899ac6bf
2017-06-14 17:37:29 +02:00
Amaury Pouly
3210457764 imx233: fix touchscreen driver
One cannot call lradc_acquire in IRQ context. The solution is to reserve the
channel once at init. There is an additional complication on STMP3600 where
channel mapping is fixed.

Change-Id: Idccbac634a4d9002703e2b1d57748beb9b245cbb
2017-05-16 12:14:43 +10:00
Lorenzo Miori
e9f7385bdf Samsung YP-Z5: keypad adaption to the new button API
After compiling the ypz5 target, I have discovered that the keypad
system was refusing to compile, due to a much newer button API.
This patch adapts the target to the current imx233 implementation.
Additonally, some ADC button values have been re-adjusted.

Change-Id: Ib9bfd6aeec5e9e8dfef5887c4147201dd9028a44
2017-05-16 12:10:50 +10:00
Cástor Muñoz
3fffff90e2 ipod6g: some fixes for recording
- Fix broken recording from jack microphone.
- Fix recording hardware detection on models that do not support
  the jack microphone.
- Enable monitor mode when recording.

Change-Id: Ib79a2746f2d75f74cf6667d33bc9ed6512bbc8a9
2017-04-16 00:37:45 +02:00
Michael Sevakis
6db80020b4 Do some housekeeping with fat.h and SECTOR_SIZE
Many includes of fat.h are pointless. Some includes are just for
SECTOR_SIZE. Add a file 'firmware/include/fs_defines.h' for that
and to define tuneable values that were scattered amongst various
headers.

Remove some local definitions of SECTOR_SIZE since they have to be
in agreement with the rest of the fs code anyway.

(We'll see what's in fact pointless in a moment ;)

Change-Id: I9ba183bf58bd87f5c45eba7bd675c7e2c1c18ed5
2017-03-12 22:05:44 -04:00
Cástor Muñoz
1ba5ef716d ipod6g: rename some target files
As preparation to add new targets to the s5l8702 directory,
rename files as:

s5l8702/ipod6g/*-ipod6g.c -> s5l8702/ipod6g/*-6g.c

Change-Id: I0cd03d6bcf39b2aa198235f9014cb6948bbafcd5
2017-03-03 22:50:38 +01:00
Michael Sevakis
fc9695eb47 Improve radio RDS driver and framework
* Remove unused bits like the radio event and simplify basic
radio interface. It can be more self-contained with rds.h only
required by radio and tuner code.

* Add post-processing to text a-la Silicon Labs AN243. The chip's
error correction can only do so much; additional checks are highly
recommended. Simply testing for two identical messages in a row
is extremely effective and I've never seen corrupted text since
doing that, even with mediocre reception.

Groups segments must arrive in order, not randomly; logic change
only accepts them in order, starting at 0.

Time readout was made a bit better but really we'd need to use
verbose mode and ensure that no errors were seen during receiving
of time and more checks would be need to have a stable PI. The
text is the important bit anyway.

* Time out of stale text.

* Text is no longer updated until a complete group has been
received, as is specified in the standard. Perhaps go back to
scrolling text lines in the radio screen?

* Add proper character conversion to UTF-8. Only the default G0
table for the moment. The other two could be added in.

* Add variants "RDS_CFG_PROCESS" and "RDS_CFG_PUSH" to allow
the option for processed RDS data to be pushed to the driver and
still do proper post-processing (only text conversion for now for
the latter).

Change-Id: I4d83f8b2e89a209a5096d15ec266477318c66925
2017-02-11 22:19:32 -05:00
Cástor Muñoz
882921efb6 ipod6g: bootloader v1
- dual boot
- USB mode
- battery trap

Change-Id: I8586cfeb21ee63f45ab965430725225fdfc4212d
2017-02-09 20:47:16 +01:00
Mihail Zenkov
0d0b163dd1 Slightly increase CVDD1 for Clip Zip
Change-Id: Ic784c72a643546c8e31affa820f701eb7982b7c7
2017-02-07 17:28:42 +01: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
baec807d70 zenmozaic: adjust button voltage
The values were recorded for VDDIO at 3.46V and not 3.5

Change-Id: I12880c3d7336389bbac07fe01b8d63d9cd28d177
2017-02-04 17:17:11 +01:00
Amaury Pouly
501e8a7e71 imx233: remove weak attribute on some functions
This feature was never used and it is not even working because weak linking
doesn't work in-between files in a library.

Change-Id: I389ea5f17be1d9db0e2150828d704be5a091e09d
2017-02-04 17:16:32 +01:00
Cástor Muñoz
96a7603bf9 nano2g: fix dangerous mutex in hold switch
This is a quick patch to solve FS#13104, we can not disable the
clickwheel LDO from within interrupt code, so for the moment we
leave it enabled all the time, it is unknown how power comsumption
is affected when the hold switch is locked.

Change-Id: I8f675702e2b5becbcd9197c8b044e6b8daeea79f
2017-02-04 16:30:08 +01:00
Michael Sevakis
324ad2483a i.MX31: Restore screen clearing in DVFS/DPTC debug screen
Somewhere along the line the screen stopped being cleared prior to
writing new text on each frame, which left visible bits of
previously-displayed text when it changed.

Change-Id: I344e03c234daa77f4e64ed89281c40db887e4498
2017-01-29 19:53:49 -05:00
Michael Sevakis
2220a4b695 Improve imx31 interrupt code for PMIC and GPIO
Fix stuff that was bugging me about the way I did it at first.

While messing around I found RDS code wasn't masking its GPIO
ISR as it should, which might lead to two different interrupts
messing with the static data.

Change-Id: I54626809ea3039a842af0cc9e3e42853326c4193
2017-01-29 19:07:55 -05:00
Mihail Zenkov
d4303ac900 sd-as3525v2: simplify logic and cleanup
Remove "low power mode clocking" as we stop clocking by hands after each transfer.
Remove CGU_IDE and CGU_MEMSTICK as we don't use them.
Simplify logic in sd_transfer_sectors.

Change-Id: I120396d7ec5c99c62f3a746306aa8edd8686e08a
2017-01-27 23:29:55 +01:00
Michael Sevakis
58b849c451 Move intrinsic RTC implmentation differences to driver files
Some drivers set tm_wday just fine and do not need it coerced to
be correct. Others set tm_yday, so don't overwrite what the driver
sets; just zero it inside if it can't fill the field. Move calls
to set_day_of_week() to the sorts of drivers that presumably
required the hammer (FS#11814) in get_time() where the weekday
isn't locked to the date.

Change-Id: Idd0ded6bfc9d9f48fcc1a6074068164c42fcf24a
2017-01-26 23:07:49 -05:00
Michael Sevakis
783c77531c AMS: Return ascodec to interrupt-based I2C2 driver
1. Slightly revised and regularized internal interface. Callback is used
for read and write to provide completion signal instead of having two
mechanisms.

2. Lower overhead for asynchronous or alterate completion callbacks. We
now only init what is required by the transfer. A couple unneeded
structure members were also nixed.

3. Fixes a bug that would neglect a semaphore wait if pumping the I2C
interrupts in a loop when not in thread state or interrupts are masked.

4. Corrects broken initialization order by defining KDEV_INIT, which
makes kernel_init() call kernel_device_init() to initialize additional
devices _after_ the kernel, threading and synchronization objects are
safe to use.

5. Locking set_cpu_frequency has to be done at the highest level in
system.c to ensure the boost counter and the frequency are both set in
agreement. Reconcile the locking inteface between PP and AMS (the only
two currently using locking there) to keep it clean.

Now works fine with voltages in GIT HEAD on my Fuze v2, type 0.
Previously, everything crashed and died instantly. action.c calling
set_cpu_frequency from a tick was part of it. The rest may have been
related to 3. and 4. Honestly, I'm not certain!

Testing by Mihail Zenkov indicates it solves our problems. This will
get the developer builds running again after the kernel assert code
push.

Change-Id: Ie245994fb3e318dd5ef48e383ce61fdd977224d4
2017-01-25 00:05:13 +01:00
Amaury Pouly
dd7f834e61 imx233: remove redundant lines in linker script
Change-Id: Ief8ab0c33abdd3b36cd94b0578e2c5cad22bf2a6
2017-01-24 15:34:20 +01:00
Michael Sevakis
3e73866110 Add CPU mode asserts to kernel on blocking functions.
This scourge finds it's way back in far too often.
Right now, only defined for ARM.

Have fun!

Change-Id: Ib21be09ebf71dec10dc652a7a664779251f49644
2017-01-21 14:25:52 -05:00
Amaury Pouly
7eaf55868d zen/zenxfi: remove obsolete comment
Change-Id: I1e4a726c85a9d87216412162fd0815747eb32cf6
2017-01-16 20:10:28 +01:00
Amaury Pouly
5d048e04a0 zen/zenxfi: add remark about pin
Clearly this pin does not control power so don't call it lcd_power.

Change-Id: I9a6794e2606de99cb44dd3e7288b5cce5beb8d0d
2017-01-16 20:09:39 +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
42e54c508f imx233: workaround hardware dma bug
This bug mostly affects the ZEN and ZEN X-Fi and hangs the lcdif dma randomly
on boot.

Change-Id: I4255db90d87737b7a70d1d53e3ef84e4e14c8c13
2017-01-15 18:41:27 +01:00
Amaury Pouly
79e8cd4cfe imx233: fix audio debug screen on stmp3700
On STMP3700 there is no dedicated speaker amplifier but speaker is always on
lineout so it makes sense to report volume and power down of lineout.

Change-Id: If666bccf36d3a5ecc6d892823522d023f3206184
2017-01-14 01:17:25 +01:00
Amaury Pouly
c41a929119 imx233: add note about power down bits in audioout
Change-Id: I204acff8ee697d70fd16f9828010646b10a8f11b
2017-01-14 01:17:25 +01:00
Amaury Pouly
fd2629422c imx233: fix speaker enable/disable code
Change-Id: I6540f2f8ba09bc79b80d71e5f3b0adebd9fce727
2017-01-14 01:17:25 +01:00
Cástor Muñoz
954d934ad2 iPod Classic: fix small bug on PCM record
On PCM record initialization, an unknown clockgate is enabled instead
of the I2S clockgate. This bug does not produce incorrect functionallity
because the right clockgate is already enabled on PCM playback
initialization.

Change-Id: I97a3a4a6f12131e492c1431359a0a976b68014be
2017-01-13 05:06:15 +01:00
Amaury Pouly
ac0fc74d56 imx233: don't print disabled IRQs in debug screen
There are lot IRQ and most are unused most of the time, this is annoying on
devices with small screens.

Change-Id: I7f3453f2768b8e35a5a367fbcf1e4cf3cf73bcd7
2016-12-12 13:25:41 +01:00
Amaury Pouly
17277fa1bf imx233: add more icoll statistics
Those new statistics give the maximum time an IRQ took and also the total
time spent in IRQ, for each IRQ. Hopefully those do not take took much time
or space to collect. If this is the case, it can be enabled in debug builds only
the future.

Change-Id: I05af172897c5cb7ffcc9322452f974d8f968e29d
2016-12-12 13:20:10 +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
af81cc4a93 imx233: slightly rework 3D audio setting
The old code made the setting appear as 0dB, 1.5dB, 3dB and 4.5dB when
in fact it is 0dB, 3dB, 4.5dB and 6dB. This commit clarifies the code and
also fix this at the same time. This imx233 3D enhancement is complete crap anyway
but now you can satisfy yourself with 6 dB of pure crap, clearly an enhancement.

Change-Id: Ia3e088987c1ff0cdde228905ff70f46476a499a2
2016-12-12 12:15:24 +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
a983859291 imx233: add capability to boot OF or updater instead of Rockbox
This commit adds the necessary code in the dualboot stub (bootloader) to
let rockbox control the boot process. In particular, rockbox can now choose
if the next boot will be normal (boot rockbox or OF on magic key), to OF
or to updater.

The intents (to be added in follow-up commits) are:
1) Let the user more easily reboot to the OF. On some targets it is not trivial,
especially in USB mode.
2) Automatically reboot to updater when the user drop firmware.sb at the root
of the drive (currently, the user needs to do that in OF USB mode)
3) Document this OF magic

Change-Id: I86df651dec048c318c6a22de74abb8c6b41aa9ad
2016-12-12 12:03:08 +01:00
Szymon Dziok
a0b79ce7fa HDD16X0/HDD63X0: Enable power status of charging from USB.
Change-Id: I7b1e5e87921ae0770f7783680c3dbcdbf6f257f3
2016-10-02 23:30:30 +02:00
Szymon Dziok
e3deec949d HDD6330: Implement ATA power on/off.
This should fix some errors, panics in some individual cases.

Change-Id: I27ce41f0563378e03371724f8b044404c6e69b76
2016-09-25 23:11:21 +02:00
Amaury Pouly
6e553e315d fix red on stmp<3780
Change-Id: I74f0450e8f42032265b980b95f17b0b05d9dffa5
2016-09-22 21:13:12 +01:00
Amaury Pouly
420eb66cab imx233: add power-up source to the debug menu
Change-Id: Ib67385354b1d6529d41198bfdcb1ecd092e9b98b
2016-09-22 21:03:31 +01:00
Amaury Pouly
5e2600eb3a imx233: make microphone bias, bias pin and resistor configurable
This clearly fixes recording on targets where the bias pin was wrong. It may
also improve recording on targets where the bias voltage was wrong. I was unable
to find those parameters on the ZEN Mozaic, which fallback to default values.

Change-Id: Ifb5f823c9cbd01f0d9a80fa5d49d93972c8b7cfe
2016-09-21 00:36:51 +01:00
Amaury Pouly
9dc4b00df1 imx233: fix recording gain
For some reason, there was a mismatch between the setting (decibel) and the
audiohw code (centicel). This resulted in a gain divided by 10. This may
explain why some people experienced low volume with the mic on the fuze+.

Change-Id: I138ac18dd93c36f43a7dfce735efc826405c598c
2016-09-21 00:29:14 +01:00
Amaury Pouly
82b09144e9 imx233: add alarm value to debug menu
Hopefully this can help debugging alarm problems.

Change-Id: Id8c5603a6372744dfc62890443a37de2dd92a7c0
2016-08-22 23:37:33 +01:00
Cástor Muñoz
7083110f81 iPod Classic: NOR support for bootloader
- NOR driver (based on emCORE)
- read/write IM3 images
- read 'flsh' files

Change-Id: Ie0654e0d298affc0f47ed64b823767118bd1aa3f
2016-08-19 00:15:59 +02:00
Cástor Muñoz
bf89c757dd iPod Classic: hardware AES and SHA1 for bootloader
Based on emCORE.

Low level functions that do not depend on Rockbox kernel,
intended to be used by the bootloader, dualboot-installer,
RB drivers or other .dfu tools.

Change-Id: I3c616ded42260c6626bda23b7e580791981df61d
2016-08-19 00:15:44 +02:00
Cástor Muñoz
57a44854e3 iPod Classic: SPI driver for bootloader
Based on emCORE.

Low level functions that do not depend on Rockbox kernel,
intended to be used by the bootloader, dualboot-installer,
RB drivers or other .dfu tools.

Change-Id: Iad369627b55bf1778eab437424072f1a653e4db6
2016-08-19 00:15:36 +02:00
Cástor Muñoz
6a1644c52a as3525v2: use the new USB DesignWare driver
Targets: sansaclipplus, samsaclipv2, sansaclipzip, sansafuzev2.

Change-Id: I7773528a4e26707dd33fe9cb8948750d49570701
2016-08-15 02:56:23 +02:00
Cástor Muñoz
578525b463 iPod Classic: rework on I2C driver
- Some rewrite with the intent to get ride of these random errors
  appearing on some builds/devices (not much noticeable on RB but
  can ruin bootloader builds).
- Error handling (ACK).
- IIC clock increased to be the same as in OF.

Change-Id: Idf8cfa3c230a0a61ec9c879bf6f0ea8b061a4607
2016-08-12 14:17:46 +02:00
Cástor Muñoz
adbd2969e6 iPod Classic: ADC updates
Add code to read USB D+/D- and accessory ADCs, it is shown in HW
debug menu, might be useful in future for RB and/or the bootloader
to identify external USB chargers.

Change-Id: Ia48ca5e06bb7ddc52bb55abedde6734653ce8dba
2016-08-12 14:17:46 +02:00
Mihail Zenkov
a25d0c58aa Increase CVDD1 only for Clip+ version 0
Change-Id: I839ba2191a5c52ef6f58fd4a273db628b690a05c
2016-08-11 19:49:57 +00:00
Mihail Zenkov
cfa1c843f2 Increase CVDD1 for Clip+ to prevent ATA error
Change-Id: I0424d02196a6c5fb6d0185b007df5ece24b10b82
2016-08-10 01:36:11 +00:00
Cástor Muñoz
ef572fec52 iPod Nano 2G: use the new USB DesignWare driver
Change-Id: I8d1561bf4e239b55617a8d5075457a668e0c312c
2016-08-02 04:57:50 +02:00
Cástor Muñoz
3c5aa754de iPod Classic: use the new USB DesignWare driver
Change-Id: I36aabb5cb9cfe2d8c4f8fbcea944efec58ef9671
2016-08-02 04:57:50 +02:00
Cástor Muñoz
5e305d35c9 Introduce new USB driver for Synopsys DesignWare USB OTG core.
Based on g#844 and g#949, it is intended as a replacement for the
current s3c6400x USB driver.

The DesignWare USB OTG core is integrated into many SoC's, however
HW core version and capabilities (mainly DMA mode, Tx FIFO mode,
FIFO size and number of available IN/OUT endpoins) may differ:

CPU       targets        HW ver  DMA  NPTX FIFO  FIFO sz  #IN/OUT
--------  -------------  ------  ---  ---------  -------  -------
as3525v2  sansaclipplus  2.60a   Yes  Dedicated  0x535    4/4
          sansaclipv2
          sansaclipzip
          sansafuzev2
s5l8701   ipodnano2g     2.20a   Yes  Shared     0x500    4/5
s5l8702   ipod6g         2.60a   Yes  Dedicated  0x820    7/7
          ipodnano3g
s5l8720   ipodnano4g     ?       ?    ?          ?        ?

Functionality supported by this driver:
- Device mode, compatible with USB 1.1/2.0 hosts.
- Shared FIFO (USB_DW_SHARED_FIFO) or dedicated FIFOs.
- No DMA (USB_DW_ARCH_SLAVE) or internal DMA mode.
- Concurrent transfers: control, bulk (usb_storage, usb_serial) and
  interrupt (usb_hid).

Actually this driver is not used by any CPU, it will be enabled for
each individual CPU/target in next patches.

Change-Id: I74a1e836d18927a31f6977d71115fb442477dd5f
2016-08-02 04:57:49 +02:00
Amaury Pouly
1bd47de339 zenxfi3: recalibrate battery curve
Apparently I simply forgot to calibrate it when the port was done and the
current values are just plain wrong, especially for the charging curve.

Change-Id: Ied3cafa52f31f182f953714e28edc4c5e891255f
2016-06-12 18:38:38 +01:00
Cástor Muñoz
489044d1ca iPod Nano2G: clear external interrupts at startup
Fixes some ROLO issues after commit 9a4cd2e. Note that other ROLO
issues still persist.

Change-Id: I8e0c60519902013694c5a473dcb9fc62a6ff079c
2016-06-10 00:34:23 +02:00
Amaury Pouly
9a6700d52e imx233: fix power off code
There are two very suspicious things in the power off code:
- it does not properly unlock the power register, so it should fail (!)
- it does not disable sw/hw watchdog so if register fails, the device will
  most probably crash horribly because of the watchdog
I don't even understand how it worked before.

Change-Id: I9f3f94bd012e52c3b50cd5b658d68b5eb907f79b
2016-06-08 21:53:36 +02:00
Amaury Pouly
59ae562a32 fix yellow
Change-Id: Ie18d7f83ba3e7293d4cd110429e1578930d35d99
2016-06-01 22:19:59 +01:00
Amaury Pouly
ccd500a48a imx233: fix stupid typo in debug screen
Change-Id: Ife43543d6eee6522f4016f37479a20a0db39240d
2016-06-01 23:09:49 +02:00
Amaury Pouly
d42a4a4eb4 zenxfi3: rewrite mpr121 driver
The new driver uses an asynchronous architecture for touch status reading.

Change-Id: Ic75a8b91bc47ee16c3af873afde178cd70186376
2016-06-01 23:09:27 +02:00
Amaury Pouly
b2afd931e2 fuze+: rewrite touchpad driver
The old driver was bad in many respect, it had some race conditions, it was
using a thread to serialize transfers because of the legacy i2c interface.
It also had huge latency (typically 50ms but delays up to 300ms can happen),
thus some presses were missed.
The new driver takes advantage of the new i2c driver to do everything
asynchronously. It also does not need a thread anymore because queueing
ensures proper serialization. It provides much better and reliable latency
(typically ~2ms).
Also fix the debug screen which was horribly broken. The new screen also
displays the deadzones.

Change-Id: I69b7f99b75053e6b1d3d56beb4453c004fd2076e
2016-06-01 23:08:17 +02:00
Amaury Pouly
4d42e3685c imx233: rewrite i2c driver
The new driver provides several new features:
- asynchronous transfer
- transactions (several transfers executed at once)
- queueing
The style still provides the legacy interface.

Change-Id: I6d8ecc89d1f7057847c9b2dc69b76cd45c9c8407
2016-06-01 22:55:37 +02:00
Amaury Pouly
6d124c738b Fix red, forgotten file
Change-Id: Ia9c1e924c84772205472289494c62a63a3433727
2016-05-29 20:21:26 +01:00
Amaury Pouly
633c8edf47 imx233: two minor fixes for sd/mmc
Always enable support for SET_BLOCK_COUNT on mmc: it is mandatory. For some
reason (probably a mistake) it was disabled unconditionaly on mmc.
Also deselect sd card after init. Although it is unlikely to make a difference,
it is already done for mmc so stay consistent.

Change-Id: I276f0d95f5bb6a0bf431c2fff4589d3dfb15f8c7
2016-05-29 16:08:42 +01:00
Amaury Pouly
85ad99ee3d imx233: add sd/mmc debug screen
The screen currently displays for each device the bus width, set_block_count
support, HS capability and whether it is enabled for not.

Change-Id: I6b1c3b1019e55ef1097a23c1f54fb07f5c7aa3b0
2016-05-29 16:07:43 +01:00
Amaury Pouly
7aacf4da2d imx233: fix button debug screen on landscape mode screen
Some players like the ZEN X-Fi have a wide but not tall screen, it is
thus better to display everything on one line for each button

Change-Id: Ided3d4ff689cc5d3bcc2bdba4c7e046cf7dc0954
2016-05-29 16:05:56 +01:00
Amaury Pouly
ae7dd5388d imx233: fix red
stop pretending that stmp3600 and stmp3700 have a 4.2V power rail

Change-Id: If2506ed3e7c5db96dedc668f0931d59a5197dd88
2016-05-28 16:50:07 +01:00
Amaury Pouly
cdca7cee71 imx233: add new power debug screen
This screen allows to put the device in a special mode where:
- charging is disabled
- device only draws power from 5V (thus battery is untouched)
This is useful to measure the device consumption by measuring directly
the usb power consumption.

Change-Id: I2716ced0a5bb33c3c9a2607f2d17a0ce02f5689c
2016-05-28 17:38:29 +02:00
Amaury Pouly
2dcc9fc39f imx233: fix debug screen button handling
The code was very primitive and did not handle release events properly.

Change-Id: I1c56005282a9fb6608f79ff3b483ba614d635fdb
2016-05-28 17:38:10 +02:00
Amaury Pouly
941ac165d8 imx233: speedup charging trickle phase
Per Freescale recommandation, we need to ramp up the 4.2V rail before enabling
charging. Ramping should be done at 1 step/10ms, but the old code did 1 step/1s
because the powermgmt_step() function is called once every second. Use a tick
task to ramp up much faster.

Change-Id: I9a52bdd0c2ba5426d83ed42db8db7ecce2fea1f7
2016-05-28 16:21:03 +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
423c64770c zenxfi3: fix headphone detection
The adc channel monitored for jack detection does not really have a fixed
value when plugged. Instead use the same logic as the OF and simply use a
threshold.

Change-Id: I1d5270d83eb14decce29a39d8201ea1d1fb4436c
2016-05-28 17:12:01 +02:00
Amaury Pouly
7e00be9a1e nwz-370/380: increase adc button error margin
For some reason those targets have quite imprecise button voltages and the
old margin was too small. This should fix the button-not-working issue,
especially when the player is very hot and cold.

Change-Id: I9fcddd7f079cd1c4ee121567fb21a4a0cbc0562b
2016-05-28 17:11:49 +02:00
Amaury Pouly
9fe854e782 imx233: enhance button driver adc handling
The current driver is limited to checking if the adc value equals another
one with a hardcoded margin. This commit changes two aspects of that:
- the margin can be changed globally using IMX233_BUTTON_LRADC_MARGIN
  and can also be overriden per button using the new LRADC_EX macro
- the lradc logic gained two comparison modes to check if the source
  value is greater (or lower) than a threshold.

Change-Id: If1614451dafeae818a96e6f23a84e6731331ba03
2016-05-28 17:09:19 +02:00
Amaury Pouly
030a9da0d7 imx233: cosmetics
Shorten some text to make the text readable in the debug screen of
targets with small LCD (like NWZ-380). In some screens, the only
option is to display less information.

Change-Id: I78f8f35f7c507de19e5d27a918157504155f2ba6
2016-05-28 17:07:42 +02:00
Amaury Pouly
f182e2df66 imx233: make sure not to discharge battery when charge is complete
The power management code was erroneously shuting down the 4.2V rail
when charging is complete. This resulted in the DCDC draining the battery
and thus the battery discharging with USB plugged...
The new code keeps the 4.2V rail active so that battery remains untouched
once charge is complete.

Change-Id: I36e8d31e8115c12ce813c939c5d7bbf2c3490157
2016-05-28 17:07:11 +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
Cástor Muñoz
28920ec5cc iPod Classic: fix typos / cosmetic
Change-Id: Ic6552dea4b300032875097ef0b885a4ae059f4bc
2016-05-28 15:48:02 +02:00
Cástor Muñoz
9e284c11b1 iPod Classic: i2c updates
Change-Id: Ib516f3f52cf619fb44dc1bb6982b635c49f53a8f
2016-05-26 09:06:30 +02:00
Cástor Muñoz
daee722455 iPod Classic: use PMU interrupts to detect USB and FW
Change-Id: I9be733e1a943ddeb99335d362f81f74879eeb94b
2016-05-26 09:06:30 +02:00
Cástor Muñoz
f6ed4f8306 iPod Classic: use PMU interrupts to detect accessories
- Speed auto detection is launched when an accessory is inserted,
  so the user doesn't need to modify settings to use accessories
  that operates at different speeds (or when the same accessory is
  unplugged and plugged again).

- UART controller is disabled when no accessory is inserted, not
  much powersave but everything counts.

Change-Id: If20c3617c2a87b6277fd7e0270031030c44fa953
2016-05-26 09:05:44 +02:00
Cástor Muñoz
d8989b15b7 iPod Classic: use PMU interrupts to detect hold switch
Finally the hold switch workaround is removed and it is detected
in the same way as OF does.

Change-Id: Iceac6ca48ffd131b8ee9f62ffdc2b3e30eb02042
2016-05-26 02:15:28 +02:00
Tomasz Moń
94b23da3c4 Sansa Connect: change bootloader linker file
This change ensures that Sansa Connect bootloader.bin will fit in its flash
partition.

Fix _flash_sizem calculation, division was not working properly because
FLASHSIZE included subtraction and defined value was not in parenthesis.
Prior to this change _flash_sizem was 0x00800000, now it is correctly set
to 4 in case of Sansa Connect and 8 in case of other TMS320DM320 players.
This significantly improves boot time as cache is now enabled only for
real flash memory region.

Change-Id: If3e50a3075c840dcb69dfafe5bba608a0acd2bf8
2016-05-25 17:03:19 +02:00
Cástor Muñoz
98bd2231ec iPod Classic: introduce PMU interrupts
PMU interrupts are used to detect USB Vbus, wall adaptor, accessories
and holdswitch. A thread is needed to poll the PMU throught I2C, ATM
it does nothing but showing the state of the inputs on the HW debug
menu, funcionallity for each individual input will be added in next
patches.

Change-Id: If93bf2044d1052729237a7fd1431c8493e09f1c7
2016-05-25 12:45:34 +02:00
Cástor Muñoz
88caf222ed iPod Classic: rework on external interrupts
Change-Id: I5be450adeb12b16070d9bfa31503e2ef350b2981
2016-05-25 12:44:55 +02:00
Cástor Muñoz
3f17745930 iPod Classic: HW initialization for RB
Do not rely on a bootloader initializing the HW, RB initializes
and configures GPIO, I2C, and PMU at startup.

Change-Id: If7f856b1f345f63de584aa4e4fc22d130cd66c80
2016-05-25 12:23:47 +02:00
Cástor Muñoz
e863f9a0ce iPod Classic: piezo support for bootloader
Low level functions that do not depend on Rockbox kernel,
intended to be used by the bootloader, dualboot-installer,
RB drivers or other .dfu tools.

Change-Id: If80214d26e505265ace19d9704f1e1300f98b2f4
2016-05-25 10:59:44 +02:00
Cástor Muñoz
9c032ba61a iPod Classic: LCD init sequences for bootloader
Change-Id: I27b7d5fea3164df8d85f7d431dc5301e8cee123d
2016-05-25 10:59:44 +02:00
Cástor Muñoz
1aefd9ea41 iPod Classic: HW preliminary initialization for bootloader
When the bootloader starts, most of HW never has been initialized.
This patch includes all code needed to perform the preliminary
initialization on SYSCON, GPIO, i2c, and MIU.

The code is based on emCORE and OF reverse engineering, ported to
C for readability.

Change-Id: I9ecf2c3e8b1b636241a211dbba8735137accd05c
2016-05-25 10:59:31 +02:00
Cástor Muñoz
b8a237dca2 iPod Classic: wait for ATA power down on device shutdown
Change-Id: I5d3d19d6d0c937e11e28b99f34d729631051ab93
2016-05-15 23:43:00 +02:00
Cástor Muñoz
52a6db3a36 iPod Classic: optimize UDMA timming for ATA drives
This patch optimizes UDMA timings to increase write transfer rate on
ATA bus, these transfers are clocked by HCLK, tDVS+tDVH is modified to
decrease Tcyctyp (typical write cycle period). This is not overclocking,
we meet the ATA standar, the settings used by OF are not well optimized
for each UDMA mode, we will never know but probably this was due some
documentation issue.

ATA_UDMA_TIME register is documented on s3c6400 datasheet, information
included in s5l8700 datasheet is wrong or not valid for s5l8702.

From ATA specs, (Minimum, Maximum) values in nanoseconds:

             UDMA 0      UDMA 1      UDMA 2      UDMA 3      UDMA 4
 tACKENV     (20, 70)    (20, 70)    (20, 70)    (20, 55)    (20, 55)
 tRP         (160, --)   (125, --)   (100, --)   (100, --)   (100, --)
 tSS         (50, --)    (50, --)    (50, --)    (50, --)    (50, --)
 tDVS        (70, --)    (48, --)    (31, --)    (20, --)    (6.7, --)
 tDVH        (6.2, --)   (6.2, --)   (6.2, --)   (6.2, --)   (6.2, --)
 tDVS+tDVH   (120, --)   (80, --)    (60, --)    (45, --)    (30, --)

 Tcyc = tDVS+tDVH
 WR[bytes/s] = 1/Tcyc[s] * 2[bytes]

On Classic (boosted):
 HClk = 108 MHz. -> T = ~9.26 ns.

Old values (used by OF):
 UDMA  ATA_UDMA_TIME  tACK  tRP    tSS   tDVS  tDVH  Tcyc   WR(MB/s)
 0     0x5071152      27.8  166.7  55.6  74.1  55.6  129.7  15.4
 1     0x3050a52      27.8  101.8  55.6  55.6  37     92.6  21.6
 2     0x3030a52      27.8  101.8  55.6  37    37     74    27
 3     0x2020a52      27.8  101.8  55.6  27.8  27.8   55.6  36
 4     0x2010a52      27.8  101.8  55.6  18.5  27.8   46.3  43.2

New values:
 UDMA  ATA_UDMA_TIME  tACK  tRP    tSS   tDVS  tDVH  Tcyc   WR(MB/s)
 0     0x4071152      27.8  166.7  55.6  74.1  46.3  120.4  16.6
 1     0x2050d52      27.8  129.6  55.6  55.6  27.8   83.4  24
 2     0x2030a52      27.8  101.8  55.6  37    27.8   64.8  30.9
 3     0x1020a52      27.8  101.8  55.6  27.8  18.5   46.3  43.2
 4     0x1010a52      27.8  101.8  55.6  18.5  18.5   37    54

To verify that the settings are correct, a write-to-cache test was
performed using emCORE, the measured transfer rate (WRm) is compared
against the theoric transfer rate (WR) at 108 Mhz for the old and
the new UDMA4 settings (iPod 160, HDD Toshiba MK1634GAL):

 UDMA  ATA_UDMA_TIME  Tcyc(ns)  WR(MB/s)  WRm(MB/s)  RDm(MB/s)
 4     0x2010a52      46.3      43.2      42.9       59.8
 4     0x1010a52      37        54        53.5       59.8

Notes:
 - The new UDMA4 settings increases ~25% the ATA transfer rate for
   cached-writes. The real HDD write speed is limited by the internal
   transfer rate (depends on cilinder, for the MK1634GAL it is 276 to
   573 Mbits/s). Sequential write benchmark using diskdump on USB are
   ~8% faster.
 - Read transfers are clocked by the device, it depends on UDMA mode
   selected and are not affected by HClk or ATA_UDMA_TIME settings.
   Read-from-cache tests results (RDm) using HClk=108 and HClk=54 for
   UDMA4 are 59.8 MB/s on MK1634GAL.
 - Minimum HClk is limited by tACKENV specs, using current settings
   it is 54 MHz for UDMA4,UDMA3 and 43 MHz for UDMA2,UDMA1,UDMA0.

Change-Id: I61d67060410752518a59e1ff08072b21747ca997
2016-05-15 22:57:12 +02:00
Cástor Muñoz
201f57171a iPod Classic: remove ATA_HAVE_BBT
Change-Id: I45e26a413c13e401164a01996b0b4c6788096a7f
2016-05-15 21:47:22 +02:00
Cástor Muñoz
dbcde01835 iPod Classic: remove emCORE HDD endianess warning
Change-Id: I91aa2dca7e748fe043c16014661985c42ab84b1a
2016-05-15 21:38:37 +02:00
Cástor Muñoz
469d645390 iPod Classic: prepare i2c and PMU for bootloader
When the bootloader starts only IRAM is available, the first task is to
ask the PMU to verify if the iPod has previously been hibernated by OF.
Due to memory limitations, the kernel cannot be used on this stage.

This patch modifies I2C and PMU low level functions to not to depend
on kernel (removes mutexes, and uses HW timer instead of current_tick),
actual kernel functions are modified to be 'mutexed' wrappers of the new
functions.

Change-Id: I7cef9e95dedaf176dc0659315f3dc33166d5b116
2016-05-15 21:16:54 +02:00
Cástor Muñoz
44ce4eebd6 iPOd Classic: skip emCORE HDD endianness warning for bootloader
Change-Id: I274511cc1061c396a0642e8496d46a3b9c1228d3
2016-05-15 21:16:54 +02:00
Cástor Muñoz
9a4cd2eaee iPod Nano2G: add IPOD_ACCESSORY_PROTOCOL
Change-Id: I78a19972624504bc802d96b9b8e9cec132164c2c
2016-05-14 19:39:09 +02:00
Cástor Muñoz
d405026ca8 iPod Nano2G: add HAVE_SERIAL
Change-Id: I46dca69c6708d3e6189f66e70badf0a594bac00b
2016-05-13 23:23:35 +02:00
Cástor Muñoz
5017523a6b Add UART suuport for s5l8700 and s5l8701
Add UART support for s5l8700/1 using the UC870X UART controller,
actually the functionallity is disabled and must be enabled for
each individual target. Tested on iPod Nano 2G (s5l8701), not
tested on s5l8700.

Change-Id: Ic0f216bb871502d355a70e4b658e536a2c0976a9
2016-05-13 23:23:01 +02:00
Cástor Muñoz
8fb67f48ab iPod Classic: updates for uc8702 driver
- Small rework on the UC8702 UART controller to make it compatible with
  other s5l870x SOCs. Files moved and renamed, many conditional code
  added to deal with capabilities and 'features' of the different CPUs.

- A couple of optimizacions that should not affect the functionality.

Change-Id: I705169f7e8b18d5d1da642f81ffc31c4089780a6
2016-05-13 23:21:42 +02:00
Mihail Zenkov
98c15fe85d Red Alert
Change-Id: I5ddb6e6b4f84e036a7464b142fa9496446708beb
2016-04-06 00:39:23 +00:00