Commit graph

217 commits

Author SHA1 Message Date
hexkyz
3cf37330ca fusee: Disable AHB redirection when necessary.
fusee: Add 3.0.0/3.0.1/3.0.2 warmboot fix.
2018-08-30 19:49:33 +01:00
hexkyz
611e85e6ee fusee: Implement BootConfig and Boot Reason handling. 2018-08-29 18:28:21 +01:00
Lioncash
a400b10921 fusee-primary: Fix always false conditional in xmemmove
This was corrected in 4b8455baf9 for
fusee-secondary, but I neglected to also fix it in fusee-primary (my
bad!)
2018-08-24 22:30:36 -04:00
hexkyz
43bde3fcc9
fusee: Fix register definition. 2018-08-24 17:03:53 +01:00
hexkyz
320ec38be1 fusee: Complete re-write of the hardware initialization code:
- Updated code to match hekate's;
- Improved nxboot (now boots firmwares 2.x successfully);
- Temporarily disabled built-in boot system module support;
- Fixed multiple bugs.
2018-08-18 17:59:33 +01:00
Luke Street
a3d53fbb2c Define wait() in fusee-primary/secondary 2018-07-29 10:53:06 -07:00
hexkyz
7836609839 Fix multiple issues reported by Coverity Scan 2018-07-26 18:45:18 +01:00
hexkyz
a2104b85ce
fusee: Disable the SDCLK when switching to low voltage. 2018-07-24 19:05:27 +01:00
hexkyz
e58927a8ab fusee: Fix SDMMC high speed support and other bugs. 2018-07-23 20:14:53 +01:00
hexkyz
3db9ce32fa Fusee: Deployed new SDMMC driver in fusee-secondary. All stages boot now.
Fusee: Fixed wrong argument in se.c function.
Fusee: Improved timers.
2018-07-19 21:07:53 +01:00
hexkyz
22ae5b861c
fusee: Correct wrong comment (thanks @desowin) 2018-07-05 16:05:38 +01:00
hexkyz
ddbbb0b758 fusee: SDMMC driver re-design:
- Based on hekate's, linux's and u-boot's source code;
- Full support for SD and MMC;
- Fixes multiple issues;
- Deployed first in fusee-primary.

fusee: Code cleanup and style fixes.
2018-07-04 21:55:27 +01:00
Tomasz Moń
206c10f333 Rework sdmmc clocking configuration
Use 204 MHz as host clock in SDR104 mode instead of 136 MHz.
Due to this, also change the frequency init divider so the
initialization frequency is below 400 kHz.
This makes the clocks for SDMMC1 in all modes to match the TRM table.

Make it clear in the code that HS200/HS400 modes in fact use PLLP_OUT0
and not PLLC4_OUT2_LJ like the comment suggest. In fact selecting the
PLLC4_OUT2_LJ as clock source results in freeze after switching to
HS200/HS400 mode. This is most likely related to the PLLC4 not being
enabled, but it should be checked later.

Set the HS200/HS400 divider to 3, as this is what the code really did
set prior to this change - so this commit does not change that.

Configure Legacy 12 MHz clock to run at 12 MHz using the SW default
configuration (as per TRM) for the SDMMC legacy timer.

Introduce initial version of sdmmc_host_clock_delay() in order to use it
in places where the wait is host clock dependent. The way it is
implemented now does not change the sleep that was used instead.
2018-06-12 17:20:15 +02:00
Max K
d8c9399cff fusee: Run periodic autocal only on the uSD controller (#137) 2018-06-10 21:09:48 -07:00
hexkyz
ceb93867b4
Merge pull request #132 from tslater2006/master
Add sdmmc_dump_regs function
2018-06-10 16:21:18 +01:00
Tomasz Moń
804a40830e Fix race conditions and misconfiguration in sdmmc
Properly configure pull up and pull down offsets for autocal.
Run autocal prior to every transfer.

Prevent race conditions in sdmmc_wait_for_event() - make sure the fault
handler has highest priority, then the target irq, state conditions and
finally the error mask.

Do not clear all bits (|=) when acknowledging fault conditions,
only acknowledge the fault conditions itself.

Enable interrupts before preparing command registers - if sdmmc is fast
enough it can actually finish transfer before we enabled the interrupts.
Enabling interrupts clears the COMMAND COMPLETE status bit.

Temporarily print all the sdmmc messages in stage2 - for yet unknown
reason respecting the log level results in some failures.

This results in working microsd card in stage2 on my switch with Samsung
EVO+ 256GB microsd card.
2018-06-09 17:37:53 +02:00
Timothy Slater
a79d3454d8 Switched to mmc_debug, and use inttypes 2018-06-08 07:50:36 -05:00
Timothy Slater
ca907077af Add sdmmc_dump_regs function 2018-06-07 12:55:29 -05:00
Tomasz Moń
7b9dcd2f1a Make sdmmc autocalibration follow TRM procedure
Sleep for 1 us, not 1 ms.
Timeout after 10 ms, set driver strength code values according to TRM.

Fix typo (mS) - time is in milliseconds, not milliSiemens.
2018-06-05 19:07:14 +02:00
TuxSH
b2139ed182 Pass screen status and mmc struct from stage1 to 2 2018-06-04 19:17:23 +02:00
Tomasz Moń
0534e36cf8 Set SDMMC controller to SDR104 as a workaround
According to Tegra X1 Series Processors Silicon Errata there is possible
misalignment of received data which results in a CRC error. The issue is
present only in SDR50 mode.
2018-05-27 17:43:25 +02:00
TuxSH
c9723d7b68 Refactor fusee's makefile 2018-05-27 00:59:02 +02:00
TuxSH
d57f4c54a9 Fix mmc->allow_voltage_switching assignment in sdmmc_init 2018-05-24 17:39:36 +02:00
TuxSH
4d43a86b60 Copy latest sdmmc driver to stage2 2018-05-24 01:17:13 +02:00
Kate J. Temkin
eaf8e559d6 fusee: work around some dual-init SDMMC issues 2018-05-23 07:47:02 -06:00
TuxSH
a4b1cf8b50 Stage1: fix SE issue too 2018-05-21 21:18:30 +02:00
TuxSH
561fa90669 Use uintX_t for the SE & copy bugfixed SE struct definition 2018-05-21 19:05:00 +02:00
TuxSH
ecb83903c0 Stage1: fix potential alignment issue 2018-05-21 14:18:03 +02:00
Kate J. Temkin
ac7ee45493 fusee: improve SDR104 frequency and support AUTOCMD23 2018-05-21 04:24:50 -06:00
TuxSH
bf2c6dff25 Stage2: Add exception handlers 2018-05-21 03:50:53 +02:00
TuxSH
c1687905a3 Fix stack overflow when chainloading stage2 2018-05-21 03:42:05 +02:00
TuxSH
ea2693dd2d Fix exception handlers (thanks @fincs) 2018-05-21 03:39:18 +02:00
TuxSH
43d1816ac2 [stage1] Add exception handlers... which somehow don't work? 2018-05-21 02:24:41 +02:00
TuxSH
83d9d874e6 Fusee use CAR reboot for fatal errors 2018-05-20 23:52:09 +02:00
TuxSH
4ec7d0fc82 Remove packed when not needed 2018-05-20 22:57:25 +02:00
TuxSH
3dd6ec5f6c wtf pmc reboot doesn't fully work -- display doesn't reinitialize 2018-05-20 16:56:15 +02:00
TuxSH
f45bc83bc4 Introduce fatal_error 2018-05-20 16:18:48 +02:00
Kate J. Temkin
add03d5774 fusee: correct computation of tuning block size 2018-05-20 07:21:49 -06:00
Kate J. Temkin
d5411b5b1f fusee: begin adding support for MMC HS modes 2018-05-20 07:05:35 -06:00
Kate J. Temkin
5f3fc8156c fusee: SD: implement tuning, allowing for all SD UHS-I speed 2018-05-20 07:05:35 -06:00
Kate J. Temkin
38350e769c fusee: SD driver: implement everything necessary for UHS except tuning 2018-05-20 07:05:35 -06:00
Kate J. Temkin
633c5e95ed fusee: correct constants in CAR 2018-05-20 07:05:35 -06:00
Kate J. Temkin
817c42efc2 fusee: handle SDMMC speeds sanely 2018-05-20 07:05:35 -06:00
TuxSH
ec7e0d923d Add custom panic driver 2018-05-20 14:11:46 +02:00
TuxSH
c820375a86 Make struct tegra_pmc not packed 2018-05-20 01:40:23 +02:00
TuxSH
64cdd2e63f Actually don't use memcpy in sdmmc 2018-05-19 03:10:06 +02:00
TuxSH
2a98e2e3b8 Sync sdmmc changes between stage1 and 2 2018-05-19 02:50:50 +02:00
TuxSH
b4eeddd7e1 Revamp all the Makefiles (thanks @fincs @WinterMute)
... dependencies are now properly handled (e.g. header changes, etc.)
2018-05-19 01:07:27 +02:00
Kate J. Temkin
7bfdf63a71 fusee sdmmc: don't time out on long reads 2018-05-18 07:43:09 -06:00
TuxSH
6c50723209 Fix tsec.c (thanks @rajkosto @tslater2006), fixes #106 2018-05-15 23:59:20 +02:00
TuxSH
172a2b679c Fix strncpy bugs in fusée, etc. 2018-05-15 01:18:05 +02:00
TuxSH
8df624a10d Rename sd_utils to fs_utils, etc 2018-05-13 23:49:50 +02:00
TuxSH
4f50d412f5 Redesign fs_dev, raw_dev, introducing device_partition and switch_fs.
In theory, one could mount an encrypted FAT partition itself coming from a disk image, etc.
2018-05-13 19:53:55 +02:00
TuxSH
9dce3b05ba [stage1] refactor diskio.c 2018-05-12 12:37:41 +02:00
TuxSH
75169790ff stage1 -> stage2 again 2018-05-12 11:00:36 +02:00
TuxSH
50047dffaa [stage1] unstub multiple sector-r/w code 2018-05-12 10:52:04 +02:00
Kate J. Temkin
9f86c75ea4 fusee: undo a silly mistake in longer-than-8K operations 2018-05-11 21:36:46 -07:00
TuxSH
4ada3b6195
Merge pull request #93 from encounter/fix/stage2-args
Fix stage2_args_t mismatch
2018-05-11 23:38:25 +02:00
TuxSH
eb8573093d Move sd init into diskio.c, write code for latest commit 2018-05-11 22:24:40 +02:00
Kate J. Temkin
2b871397c2 fusee: allow sdmmc_read / sdmmc_write of more data than fits in the bounce buffer 2018-05-11 11:28:13 -07:00
Kate J. Temkin
402b69c549 fusee: actually obey the SD spec when switching voltage 2018-05-10 07:10:37 -07:00
Kate J. Temkin
437344fd25 fusee: support low-voltage SDMMC mode 2018-05-10 06:05:28 -07:00
Kate J. Temkin
b20a04ede5 fusee: use full bus width and faster initial clock speed 2018-05-10 06:05:28 -07:00
TuxSH
ff2472385f [sdmmc] sdmmc_handle_cpu_transfer: handle unaligned buffers 2018-05-09 20:46:16 +02:00
TuxSH
b9b13e215f Fix struct tegra_sdmmc definition
Definition errors were cancelling each other (for the most part)
2018-05-09 19:33:54 +02:00
TuxSH
3206583db3 [sdmmc] Fix const-correctness issue 2018-05-09 19:11:16 +02:00
Luke Street
290fb356a1 stage2: fix init malloc size for stage2_args_t 2018-05-08 23:24:27 -04:00
Luke Street
6dbd8d0aae Fix stage2_args_t mismatch 2018-05-08 23:08:54 -04:00
TuxSH
70bb496388 Refactor stage1's and stage2's main.c files 2018-05-08 16:51:43 +02:00
TuxSH
d43255d484 Fix bug in crt0 2018-05-08 14:56:17 +02:00
TuxSH
461e886244 Make di.c accept arbitrary FB addresses, fix flickering issues 2018-05-08 13:45:37 +02:00
TuxSH
d390ead56f Fix faulty IRAM check in check_32bit_address_range_in_program 2018-05-08 13:45:37 +02:00
TuxSH
880f49cfa5 Fix inverted condition issue in check_32bit_address_range_loadable 2018-05-08 13:45:37 +02:00
TuxSH
1fd098e074 [stage1] Fix DEFAULT_BCT0_FOR_DEBUG 2018-05-08 13:45:37 +02:00
TuxSH
e8306361f0 Rewrote crt0, init, and chainloading code
start.s, init.c, linker.ld and linker.specs are meant
to be re-used by user applications, should they remove the defines
from init.c and the .chainloader* sections from the linker script
2018-05-08 13:45:37 +02:00
Kate J. Temkin
8d071ca7c9 fusee: fix boot partition selection 2018-05-06 22:47:36 -06:00
Kate J. Temkin
f5ed029cdb fusee: fix regression in card detection 2018-05-06 22:32:52 -06:00
TuxSH
8b418732ad Upgrade FatFs to R0.13b 2018-05-06 18:00:22 +02:00
TuxSH
4265dc7b65 Don't pass the mmc struct around 2018-05-06 17:22:12 +02:00
TuxSH
68eec056a9 Fix const-correctness issue in sdmmc.h 2018-05-06 15:22:35 +02:00
TuxSH
1aa6b92bc4 Normalize drivers between stage1 and 2 2018-05-06 15:02:13 +02:00
TuxSH
ddea5484b6 [stage1] support utf8 in fatfs 2018-05-05 22:05:11 +02:00
TuxSH
67b76cc8f1 Instead of passing FatFS structs around, unmount; other changes 2018-05-05 17:33:49 +02:00
Kate J. Temkin
8eb8de0e94 fusee: fix an obvious sdmmc error (oops) 2018-05-05 03:29:01 -06:00
Kate J. Temkin
bceb00ad8d fusee: sdmmc: clean up and prepare for better SD/MMC/version separations 2018-05-04 18:48:20 -06:00
Kate J. Temkin
2e362d93da fusee: add support for SDMMC write operations 2018-05-04 17:16:19 -06:00
Michael Scire
553cd236f2 Fusee: fix typo 2018-05-04 16:38:10 -06:00
Michael Scire
9487924973 Fusee: Add #define requirement for pragmatic reasons. 2018-05-04 16:35:33 -06:00
Kate J. Temkin
711f85305b fusee: enable sdmmc loglevel control 2018-05-04 16:15:51 -06:00
Kate J. Temkin
932a5bd645 fusee: fix multiple-block SDMMC transfers 2018-05-04 16:15:18 -06:00
TuxSH
e5fff14689 Move fatfs around 2018-05-05 00:11:22 +02:00
TuxSH
dc3099781d Change defaut BCT0 for debug 2018-05-04 21:52:38 +02:00
Michael Scire
4199be2460 Merge SD stuff into fusee-secondary. Switch diskio to single-sector reads temporarily 2018-05-04 11:47:05 -06:00
Michael Scire
299b020ecc Push minimally working FATFS. 2018-05-04 11:21:15 -06:00
Kate J. Temkin
010ba9248c fusee: make SDMMC debug printing more manageable 2018-05-04 03:38:41 -06:00
Kate J. Temkin
0120b9ce52 fusee: get uSD working, fix bad no_iopower, and abstract card differences 2018-05-04 03:24:27 -06:00
Kate J. Temkin
99f749ef82 fusee: fix SD pinmuxing / signal integrity issues 2018-05-04 03:24:27 -06:00
Kate J. Temkin
5b3be77f0e fusee: fix drive strength and avoid a pad wear-condition 2018-05-04 03:24:27 -06:00
Kate J. Temkin
fc97c3f773 fusee: merge in most of the microSD card (not fully working) 2018-05-04 03:24:27 -06:00
Kate J. Temkin
608d59c229 fusee: implement partition support; needs some tweeks 2018-05-04 03:24:27 -06:00
Kate J. Temkin
01e3761d4c fusee: sdmmc: use v3 compatibility mode for it's simpler DMA
we may want to change this at some point to get 64-bit addressing?
2018-05-04 03:24:27 -06:00
Kate J. Temkin
ef1923ebab fusee: sdmmc: support CPU reads in addition to (broken?) DMA 2018-05-04 03:24:27 -06:00
Kate J. Temkin
21c177804e fusee: sdmmc: handle DMA page boundaries 2018-05-04 03:24:27 -06:00
Kate J. Temkin
534c50fba5 sdmmc: mostly working for eMMC, now 2018-05-04 03:24:27 -06:00
Kate J. Temkin
eb48e06331 fusee: get non-data SDMMC commands fully working on eMMC 2018-05-04 03:24:27 -06:00
Kate J. Temkin
dbb65428e8 fusee: further flesh out sdmmc implementation 2018-05-04 03:24:27 -06:00
Kate J. Temkin
2e3af0c474 fusee: fix issue with SDMMC psuedo-interrupts 2018-05-04 03:24:27 -06:00
Kate J. Temkin
fbe159e4d3 fusee: add missing file 2018-05-04 03:24:27 -06:00
Kate J. Temkin
06bf132022 skeleton SDMMC 2018-05-04 03:24:27 -06:00
Michael Scire
ea609e68d3 Change read_sd_file semantics to return size read. 2018-04-26 04:47:22 -06:00
Kate J. Temkin
b5d3ce04e8 fusee: fix missing volatiles in memory utils 2018-04-20 19:12:20 -06:00
Kate J. Temkin
60c0df032d fusee: update header names for starting cpu0 2018-04-20 04:10:44 -06:00
Michael Scire
953c02dfba Update argument passing, add video resume 2018-04-08 13:51:44 -06:00
Michael Scire
82552b5a89 Implement much of the core Stage2 loader logic for Fusee 2018-04-08 05:51:57 -06:00
Michael Scire
353019a269 Add debugging prints, enable backlight for stage1 2018-04-07 23:04:30 -06:00
Michael Scire
33f76545df Implement all core Stage 1 logic for Fusee 2018-04-07 22:51:24 -06:00
Michael Scire
18f1274587 Change fusee folder naming 2018-04-07 21:45:57 -06:00