Commit graph

10387 commits

Author SHA1 Message Date
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
2d850b7c66 iPod Classic: define USB_STATUS_BY_EVENT and USB_DETECT_BY_REQUEST
Change-Id: I333fe779d8977bf58a579561466ef8872aa4e228
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
00a3658e5a iPod Classic: modify USB storage read/write buffers size
The write buffer size is undefined to use the default 24Kb. size
defined (and recomended) in usb_storage.c, the read buffer size is
also decremented to 24 Kb. USB sequential read and write benchmarks
using diskdump are now 8-9% faster.

Change-Id: Ia7c9f77b57c8ca5b566b508efffbd713d1587acf
2016-05-15 23:43:00 +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
Amaury Pouly
187ce123f1 dx90: fix spurious button events
The kernel on this device reports nonexistent key presses, in particular it
reports right presses when pressing the left button... Since when it happens,
the right press comes after the left one, the new code simply ignores any
right press when the left button in pressed.

Change-Id: Ib6ced02682d9cecf4c7f6c58834907a667419cd7
2016-05-14 23:32:36 +01: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
Michael Giacomelli
18fecd9461 Update runtime estimation after recent power optimizations.
Values taken from Mihail's Clip Zip, should be similar
on all AMSv2 devices.

Change-Id: I9432ecffea94afae224391a86f1d3fa46cd87bc0
2016-04-22 22:42:05 +02:00
Mihail Zenkov
7cb1e5ae8b Fix AMSv2 variant 1 detection if rockbox loaded from SD card
Change-Id: Ie7c9c06170601e109f8d3de9686773c38a6e224a
2016-04-22 20:43:45 +00:00
Mihail Zenkov
79ca6d4e3c AMS: enable SD card support in bootloader
With this changes rockbox can be loaded from SD card when internal storage
can't be mount (due to hardware or software problem).

Change-Id: I32b20d3f341566364def747a708a54ba6b4a7f8b
2016-04-20 15:53:33 +00:00
Mihail Zenkov
8a0360dd1e AMSv2: enable voltage scaling
Change-Id: I8d64b8578d28884e326f8b43100b3b4691f95acf
2016-04-13 23:10:30 +00:00
Mihail Zenkov
c537e05784 Fix (D)EBUG compilation
Change-Id: I5cb6d9ec3d14389b03ae43edb15b9c6199df322b
2016-04-07 10:28:15 +00:00