diff --git a/bdk/bdk.h b/bdk/bdk.h index 9a96228..840a976 100644 --- a/bdk/bdk.h +++ b/bdk/bdk.h @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include diff --git a/bdk/display/di.c b/bdk/display/di.c index a6147f3..12f6b0c 100644 --- a/bdk/display/di.c +++ b/bdk/display/di.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include diff --git a/bdk/input/joycon.c b/bdk/input/joycon.c index dab2f57..76b7d58 100644 --- a/bdk/input/joycon.c +++ b/bdk/input/joycon.c @@ -1,7 +1,7 @@ /* * Joy-Con UART driver for Nintendo Switch * - * Copyright (c) 2019-2021 CTCaer + * Copyright (c) 2019-2022 CTCaer * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -27,9 +27,9 @@ #include #include #include +#include #include #include -#include // For disabling driver when logging is enabled. #include @@ -82,9 +82,9 @@ #define JC_BTN_MASK_L 0xFF2900 // 0xFFE900: with charge status. #define JC_BTN_MASK_R 0x0056FF -#define JC_ID_L 0x01 -#define JC_ID_R 0x02 -#define JC_ID_HORI 0x20 +#define JC_ID_L 0x01 // Joycon (L). Mask for Hori (L). +#define JC_ID_R 0x02 // Joycon (R). Mask for Hori (R). +#define JC_ID_HORI 0x20 // Mask for Hori. Actual ids: 0x21, 0x22. #define JC_CRC8_POLY 0x8D diff --git a/bdk/input/touch.c b/bdk/input/touch.c index af696d9..748429a 100644 --- a/bdk/input/touch.c +++ b/bdk/input/touch.c @@ -24,9 +24,9 @@ #include #include #include +#include #include #include -#include #include "touch.h" @@ -35,12 +35,12 @@ static touch_panel_info_t _panels[] = { - { 0, 1, 1, 1, "NISSHA NFT-K12D" }, - { 1, 0, 1, 1, "GiS GGM6 B2X" }, - { 2, 0, 0, 0, "NISSHA NBF-K9A" }, - { 3, 1, 0, 0, "GiS 5.5\"" }, - { 4, 0, 0, 1, "Samsung BH2109" }, - { -1, 1, 0, 1, "GiS VA 6.2\"" } + { 0, 1, 1, 1, "NISSHA NFT-K12D" },// 0. + { 1, 0, 1, 1, "GiS GGM6 B2X" },// 1. + { 2, 0, 0, 0, "NISSHA NBF-K9A" },// 3. + { 3, 1, 0, 0, "GiS 5.5\"" },// 4. + { 4, 0, 0, 1, "Samsung BH2109" },// 5? + { -1, 1, 0, 1, "GiS VA 6.2\"" } // 2. }; static int touch_command(u8 cmd, u8 *buf, u8 size) diff --git a/bdk/libs/lv_conf.h b/bdk/libs/lv_conf.h index 7af36a4..dbf44bd 100644 --- a/bdk/libs/lv_conf.h +++ b/bdk/libs/lv_conf.h @@ -17,7 +17,7 @@ #ifndef LV_CONF_H #define LV_CONF_H -#include +#include #include /*=================== Dynamic memory diff --git a/bdk/mem/mc.c b/bdk/mem/mc.c index 31af89c..d8949bc 100644 --- a/bdk/mem/mc.c +++ b/bdk/mem/mc.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2018 naehrwert - * Copyright (c) 2018-2021 CTCaer + * Copyright (c) 2018-2022 CTCaer * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -17,9 +17,9 @@ #include #include +#include #include #include -#include void mc_config_tsec_carveout(u32 bom, u32 size1mb, bool lock) { diff --git a/bdk/mem/sdram.c b/bdk/mem/sdram.c index 79160f1..1876016 100644 --- a/bdk/mem/sdram.c +++ b/bdk/mem/sdram.c @@ -1,7 +1,7 @@ /* * Copyright (c) 2018 naehrwert * Copyright (c) 2018 balika011 - * Copyright (c) 2019-2021 CTCaer + * Copyright (c) 2019-2022 CTCaer * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -31,8 +31,8 @@ #include #include #include +#include #include -#include #define CONFIG_SDRAM_KEEP_ALIVE diff --git a/bdk/mem/sdram.h b/bdk/mem/sdram.h index 03e4611..f367628 100644 --- a/bdk/mem/sdram.h +++ b/bdk/mem/sdram.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2018 naehrwert - * Copyright (c) 2020-2021 CTCaer + * Copyright (c) 2020-2022 CTCaer * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, diff --git a/bdk/mem/sdram_config.inl b/bdk/mem/sdram_config.inl index 6805365..19e8494 100644 --- a/bdk/mem/sdram_config.inl +++ b/bdk/mem/sdram_config.inl @@ -1,6 +1,6 @@ /* * Copyright (c) 2018 naehrwert - * Copyright (c) 2020-2021 CTCaer + * Copyright (c) 2020-2022 CTCaer * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -541,8 +541,12 @@ static const sdram_params_t210_t _dram_cfg_0_samsung_4gb = { .mc_video_protect_bom = 0xFFF00000, .mc_video_protect_bom_adr_hi = 0x00000000, .mc_video_protect_size_mb = 0x00000000, + + // AFI, BPMP, HC, ISP2, CCPLEX, PPCS (AHB), SATA, VI, XUSB_HOST, XUSB_DEV, ADSP, PPCS1 (AHB), DC1, SDMMC1A, SDMMC2A, SDMMC3A. .mc_video_protect_vpr_override = 0xE4BAC343, + // SDMMC4A, ISP2B, PPCS2 (AHB), APE, SE, HC1, SE1, AXIAP, ETR. .mc_video_protect_vpr_override1 = 0x00001ED3, + .mc_video_protect_gpu_override0 = 0x00000000, .mc_video_protect_gpu_override1 = 0x00000000, .mc_sec_carveout_bom = 0xFFF00000, diff --git a/bdk/mem/sdram_config_t210b01.inl b/bdk/mem/sdram_config_t210b01.inl index 52b6b25..6c996a3 100644 --- a/bdk/mem/sdram_config_t210b01.inl +++ b/bdk/mem/sdram_config_t210b01.inl @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021 CTCaer + * Copyright (c) 2020-2022 CTCaer * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -594,8 +594,12 @@ static const sdram_params_t210b01_t _dram_cfg_08_10_12_14_samsung_hynix_4gb = { .mc_video_protect_bom = 0xFFF00000, .mc_video_protect_bom_adr_hi = 0x00000000, .mc_video_protect_size_mb = 0x00000000, + + // AFI, BPMP, HC, ISP2, CCPLEX, PPCS (AHB), SATA, VI, XUSB_HOST, XUSB_DEV, ADSP, PPCS1 (AHB), DC1, SDMMC1A, SDMMC2A, SDMMC3A. .mc_video_protect_vpr_override = 0xE4BAC343, - .mc_video_protect_vpr_override1 = 0x06001ED3, // Add SE2, SE2B. + // SDMMC4A, ISP2B, PPCS2 (AHB), APE, SE, HC1, SE1, AXIAP, ETR. Plus SE2, SE2B. + .mc_video_protect_vpr_override1 = 0x06001ED3, + .mc_video_protect_gpu_override0 = 0x00000000, .mc_video_protect_gpu_override1 = 0x00000000, .mc_sec_carveout_bom = 0xFFF00000, diff --git a/bdk/mem/smmu.c b/bdk/mem/smmu.c index f2f20fb..9c2b8e4 100644 --- a/bdk/mem/smmu.c +++ b/bdk/mem/smmu.c @@ -1,6 +1,7 @@ /* * Copyright (c) 2018 naehrwert * Copyright (c) 2018 balika011 + * Copyright (c) 2018-2022 CTCaer * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -18,10 +19,10 @@ #include #include +#include #include #include #include -#include #include bool smmu_used = false; diff --git a/bdk/power/bq24193.h b/bdk/power/bq24193.h index 1b6e717..399e225 100644 --- a/bdk/power/bq24193.h +++ b/bdk/power/bq24193.h @@ -28,7 +28,7 @@ // REG 1 masks. #define BQ24193_PORCONFIG_BOOST_MASK (1<<0) -#define BQ24193_PORCONFIG_SYSMIN_MASK (7<<1) +#define BQ24193_PORCONFIG_SYSMIN_MASK (7<<1) // 3000uV HOS default. #define BQ24193_PORCONFIG_CHGCONFIG_MASK (3<<4) #define BQ24193_PORCONFIG_CHGCONFIG_CHARGER_EN (1<<4) #define BQ24193_PORCONFIG_I2CWATCHDOG_MASK (1<<6) diff --git a/bdk/power/max17050.c b/bdk/power/max17050.c index a561724..c718d2b 100644 --- a/bdk/power/max17050.c +++ b/bdk/power/max17050.c @@ -24,7 +24,7 @@ #include "max17050.h" #include -#include +#include #define BASE_SNS_UOHM 5000 diff --git a/bdk/power/max7762x.c b/bdk/power/max7762x.c index a7d30ce..e69bb4c 100644 --- a/bdk/power/max7762x.c +++ b/bdk/power/max7762x.c @@ -20,8 +20,8 @@ #include #include #include +#include #include -#include #define REGULATOR_SD 0 #define REGULATOR_LDO 1 diff --git a/bdk/sec/se.c b/bdk/sec/se.c index 4e3b141..dfacddf 100644 --- a/bdk/sec/se.c +++ b/bdk/sec/se.c @@ -23,8 +23,8 @@ #include #include #include +#include #include -#include typedef struct _se_ll_t { diff --git a/bdk/sec/tsec.c b/bdk/sec/tsec.c index 6d6f895..0097c09 100644 --- a/bdk/sec/tsec.c +++ b/bdk/sec/tsec.c @@ -25,11 +25,11 @@ #include #include #include +#include #include #include #include #include -#include // #include diff --git a/bdk/soc/bpmp.c b/bdk/soc/bpmp.c index fc0e412..a3c18aa 100644 --- a/bdk/soc/bpmp.c +++ b/bdk/soc/bpmp.c @@ -1,7 +1,7 @@ /* * BPMP-Lite Cache/MMU and Frequency driver for Tegra X1 * - * Copyright (c) 2019-2021 CTCaer + * Copyright (c) 2019-2022 CTCaer * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -18,9 +18,9 @@ #include #include +#include #include #include -#include #define BPMP_MMU_CACHE_LINE_SIZE 0x20 diff --git a/bdk/soc/ccplex.c b/bdk/soc/ccplex.c index 6e7aef1..d7f6252 100644 --- a/bdk/soc/ccplex.c +++ b/bdk/soc/ccplex.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2018 naehrwert - * Copyright (c) 2018-2020 CTCaer + * Copyright (c) 2018-2022 CTCaer * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, diff --git a/bdk/soc/clock.c b/bdk/soc/clock.c index e9e4fb5..ad2d1fa 100644 --- a/bdk/soc/clock.c +++ b/bdk/soc/clock.c @@ -18,9 +18,9 @@ #include #include #include +#include #include #include -#include typedef struct _clock_osc_t { @@ -351,7 +351,7 @@ void clock_disable_actmon() void clock_enable_extperiph1() { clock_enable(&_clock_extperiph1); - + PMC(APBDEV_PMC_CLK_OUT_CNTRL) |= PMC_CLK_OUT_CNTRL_CLK1_SRC_SEL(OSC_CAR) | PMC_CLK_OUT_CNTRL_CLK1_FORCE_EN; usleep(5); } @@ -528,9 +528,9 @@ void clock_enable_pllu() CLOCK(CLK_RST_CONTROLLER_PLLU_BASE) = pllu_cfg | PLLCX_BASE_ENABLE; // Enable. // Wait for PLL to stabilize. - u32 timeout = (u32)TMR(TIMERUS_CNTR_1US) + 1300; + u32 timeout = get_tmr_us() + 1300; while (!(CLOCK(CLK_RST_CONTROLLER_PLLU_BASE) & PLLCX_BASE_LOCK)) // PLL_LOCK. - if ((u32)TMR(TIMERUS_CNTR_1US) > timeout) + if (get_tmr_us() > timeout) break; usleep(10); diff --git a/bdk/soc/clock.h b/bdk/soc/clock.h index 30d4a46..9b974f6 100644 --- a/bdk/soc/clock.h +++ b/bdk/soc/clock.h @@ -117,6 +117,7 @@ #define CLK_RST_CONTROLLER_LVL2_CLK_GATE_OVRD 0x3A4 #define CLK_RST_CONTROLLER_CLK_SOURCE_MSELECT 0x3B4 #define CLK_RST_CONTROLLER_CLK_SOURCE_I2C4 0x3C4 +#define CLK_RST_CONTROLLER_CLK_SOURCE_AHUB 0x3D0 #define CLK_RST_CONTROLLER_CLK_SOURCE_ACTMON 0x3E8 #define CLK_RST_CONTROLLER_CLK_SOURCE_EXTPERIPH1 0x3EC #define CLK_RST_CONTROLLER_CLK_SOURCE_EXTPERIPH2 0x3F0 @@ -157,6 +158,7 @@ #define CLK_RST_CONTROLLER_CLK_SOURCE_UART_FST_MIPI_CAL 0x66C #define CLK_RST_CONTROLLER_CLK_SOURCE_SDMMC_LEGACY_TM 0x694 #define CLK_RST_CONTROLLER_CLK_SOURCE_NVENC 0x6A0 +#define CLK_RST_CONTROLLER_CLK_SOURCE_APE 0x6C0 #define CLK_RST_CONTROLLER_CLK_SOURCE_USB2_HSIC_TRK 0x6CC #define CLK_RST_CONTROLLER_SE_SUPER_CLK_DIVIDER 0x704 #define CLK_RST_CONTROLLER_CLK_SOURCE_UARTAPE 0x710 diff --git a/bdk/soc/hw_init.c b/bdk/soc/hw_init.c index 4e5cead..754309d 100644 --- a/bdk/soc/hw_init.c +++ b/bdk/soc/hw_init.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include diff --git a/bdk/soc/i2c.c b/bdk/soc/i2c.c index 5db5476..ce98634 100644 --- a/bdk/soc/i2c.c +++ b/bdk/soc/i2c.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2018 naehrwert - * Copyright (c) 2018-2020 CTCaer + * Copyright (c) 2018-2022 CTCaer * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -18,7 +18,7 @@ #include #include -#include +#include #define I2C_PACKET_PROT_I2C BIT(4) #define I2C_HEADER_CONT_XFER BIT(15) diff --git a/bdk/soc/irq.c b/bdk/soc/irq.c index e2f925c..c512c87 100644 --- a/bdk/soc/irq.c +++ b/bdk/soc/irq.c @@ -19,6 +19,7 @@ #include #include "irq.h" +#include #include #include #include diff --git a/bdk/soc/pmc.c b/bdk/soc/pmc.c index aa86cb7..589b9f3 100644 --- a/bdk/soc/pmc.c +++ b/bdk/soc/pmc.c @@ -16,8 +16,8 @@ #include #include +#include #include -#include void pmc_scratch_lock(pmc_sec_lock_t lock_mask) { diff --git a/bdk/soc/t210.h b/bdk/soc/t210.h index f9ef17a..3a4d4ea 100644 --- a/bdk/soc/t210.h +++ b/bdk/soc/t210.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2018 naehrwert +* Copyright (c) 2018-2022 CTCaer * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -244,28 +245,6 @@ #define SYSCTR0_COUNTERID10 0xFF8 #define SYSCTR0_COUNTERID11 0xFFC -/*! TMR registers. */ -#define TIMERUS_CNTR_1US (0x10 + 0x0) -#define TIMERUS_USEC_CFG (0x10 + 0x4) -#define TIMER_TMR8_TMR_PTV 0x78 -#define TIMER_TMR9_TMR_PTV 0x80 -#define TIMER_PER_EN BIT(30) -#define TIMER_EN BIT(31) -#define TIMER_TMR8_TMR_PCR 0x7C -#define TIMER_TMR9_TMR_PCR 0x8C -#define TIMER_INTR_CLR BIT(30) - -#define TIMER_WDT4_CONFIG (0x100 + 0x80) -#define TIMER_SRC(TMR) ((TMR) & 0xF) -#define TIMER_PER(PER) (((PER) & 0xFF) << 4) -#define TIMER_SYSRESET_EN BIT(14) -#define TIMER_PMCRESET_EN BIT(15) -#define TIMER_WDT4_COMMAND (0x108 + 0x80) -#define TIMER_START_CNT BIT(0) -#define TIMER_CNT_DISABLE BIT(1) -#define TIMER_WDT4_UNLOCK_PATTERN (0x10C + 0x80) -#define TIMER_MAGIC_PTRN 0xC45A - /*! I2S registers. */ #define I2S1_CG 0x88 #define I2S1_CTRL 0xA0 diff --git a/bdk/soc/uart.c b/bdk/soc/uart.c index 1ccfc76..7cb7671 100644 --- a/bdk/soc/uart.c +++ b/bdk/soc/uart.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2018 naehrwert -* Copyright (c) 2019-2020 CTCaer +* Copyright (c) 2019-2022 CTCaer * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -17,8 +17,8 @@ #include #include +#include #include -#include /* UART A, B, C, D and E. */ static const u32 uart_baseoff[5] = { 0, 0x40, 0x200, 0x300, 0x400 }; diff --git a/bdk/storage/sdmmc.c b/bdk/storage/sdmmc.c index ddf21fc..0f0773d 100644 --- a/bdk/storage/sdmmc.c +++ b/bdk/storage/sdmmc.c @@ -16,6 +16,9 @@ */ #include + +#include +#include #include #include #include @@ -23,8 +26,6 @@ #include #include #include -#include -#include //#define DPRINTF(...) gfx_printf(__VA_ARGS__) #define DPRINTF(...) diff --git a/bdk/storage/sdmmc_driver.c b/bdk/storage/sdmmc_driver.c index e869666..b5c2e3d 100644 --- a/bdk/storage/sdmmc_driver.c +++ b/bdk/storage/sdmmc_driver.c @@ -27,8 +27,8 @@ #include #include #include +#include #include -#include //#define DPRINTF(...) gfx_printf(__VA_ARGS__) //#define ERROR_EXTRA_PRINTING diff --git a/bdk/thermal/fan.c b/bdk/thermal/fan.c index 019fd60..6c23b0f 100644 --- a/bdk/thermal/fan.c +++ b/bdk/thermal/fan.c @@ -1,7 +1,7 @@ /* * Fan driver for Nintendo Switch * - * Copyright (c) 2018-2021 CTCaer + * Copyright (c) 2018-2022 CTCaer * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -24,8 +24,8 @@ #include #include #include +#include #include -#include void set_fan_duty(u32 duty) { diff --git a/bdk/usb/usb_gadget_hid.c b/bdk/usb/usb_gadget_hid.c index b255e0a..4b54ede 100644 --- a/bdk/usb/usb_gadget_hid.c +++ b/bdk/usb/usb_gadget_hid.c @@ -1,7 +1,7 @@ /* * USB Gadget HID driver for Tegra X1 * - * Copyright (c) 2019-2020 CTCaer + * Copyright (c) 2019-2022 CTCaer * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -23,8 +23,8 @@ #include #include #include +#include #include -#include #include diff --git a/bdk/usb/usb_gadget_ums.c b/bdk/usb/usb_gadget_ums.c index 2f56247..a434e02 100644 --- a/bdk/usb/usb_gadget_ums.c +++ b/bdk/usb/usb_gadget_ums.c @@ -24,13 +24,13 @@ #include #include #include +#include #include #include #include #include #include #include -#include #include diff --git a/bdk/usb/usbd.c b/bdk/usb/usbd.c index e6be7fb..c8e5e23 100644 --- a/bdk/usb/usbd.c +++ b/bdk/usb/usbd.c @@ -1,7 +1,7 @@ /* * Enhanced USB Device (EDCI) driver for Tegra X1 * - * Copyright (c) 2019-2021 CTCaer + * Copyright (c) 2019-2022 CTCaer * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -30,9 +30,9 @@ #include #include #include +#include #include #include -#include #include diff --git a/bdk/usb/xusbd.c b/bdk/usb/xusbd.c index b3a9905..ec3b62d 100644 --- a/bdk/usb/xusbd.c +++ b/bdk/usb/xusbd.c @@ -1,7 +1,7 @@ /* * eXtensible USB Device driver (XDCI) for Tegra X1 * - * Copyright (c) 2020-2021 CTCaer + * Copyright (c) 2020-2022 CTCaer * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -28,9 +28,9 @@ #include #include #include +#include #include #include -#include #include diff --git a/bdk/utils/btn.c b/bdk/utils/btn.c index ded903d..53b8123 100644 --- a/bdk/utils/btn.c +++ b/bdk/utils/btn.c @@ -18,8 +18,8 @@ #include "btn.h" #include #include +#include #include -#include #include u8 btn_read() diff --git a/bdk/utils/types.h b/bdk/utils/types.h index b8d77e4..02fd05c 100644 --- a/bdk/utils/types.h +++ b/bdk/utils/types.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2018 naehrwert -* Copyright (c) 2018-2021 CTCaer +* Copyright (c) 2018-2022 CTCaer * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -100,7 +100,7 @@ typedef unsigned long uptr; #define byte_swap_16(num) ((((num) >> 8) & 0xff) | (((num) << 8) & 0xff00)) #define byte_swap_32(num) ((((num) >> 24) & 0xff) | (((num) << 8) & 0xff0000) | \ - (((num) >> 8 )& 0xff00) | (((num) << 24) & 0xff000000)) + (((num) >> 8 ) & 0xff00) | (((num) << 24) & 0xff000000)) /* Bootloader/Nyx */