From 0da51416c7eaa82fa95522910c0a925f2a700b1d Mon Sep 17 00:00:00 2001 From: CoolStar Date: Fri, 5 Jan 2024 15:35:05 -0800 Subject: [PATCH] Platform/RK3588: Refactor I2cIoMux to use GpioPinSetFunction and add missing controllers (#113) --- .../RockchipPlatformLib/RockchipPlatformLib.c | 28 ++++++++--------- .../RockchipPlatformLib/RockchipPlatformLib.c | 27 +++++++++------- .../RockchipPlatformLib/RockchipPlatformLib.c | 26 ++++++---------- .../RockchipPlatformLib/RockchipPlatformLib.c | 26 ++++++---------- .../RockchipPlatformLib/RockchipPlatformLib.c | 26 ++++++---------- .../RockchipPlatformLib/RockchipPlatformLib.c | 31 ++++++++++++------- .../RockchipPlatformLib/RockchipPlatformLib.c | 25 ++++++++------- .../RockchipPlatformLib/RockchipPlatformLib.c | 26 ++++++---------- .../RockchipPlatformLib/RockchipPlatformLib.c | 29 ++++++++--------- .../RockchipPlatformLib/RockchipPlatformLib.c | 25 ++++++++------- .../RockchipPlatformLib/RockchipPlatformLib.c | 26 +++++++--------- .../RockchipPlatformLib/RockchipPlatformLib.c | 28 +++++++---------- .../RockchipPlatformLib/RockchipPlatformLib.c | 21 ++++++------- .../RockchipPlatformLib/RockchipPlatformLib.c | 28 +++++++---------- 14 files changed, 177 insertions(+), 195 deletions(-) diff --git a/edk2-rockchip/Platform/Ameridroid/IndiedroidNova/Library/RockchipPlatformLib/RockchipPlatformLib.c b/edk2-rockchip/Platform/Ameridroid/IndiedroidNova/Library/RockchipPlatformLib/RockchipPlatformLib.c index 941668275..aa8d2c162 100644 --- a/edk2-rockchip/Platform/Ameridroid/IndiedroidNova/Library/RockchipPlatformLib/RockchipPlatformLib.c +++ b/edk2-rockchip/Platform/Ameridroid/IndiedroidNova/Library/RockchipPlatformLib/RockchipPlatformLib.c @@ -145,32 +145,32 @@ I2cIomux ( { switch (id) { case 0: - /* io mux M2 */ - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x0F00UL << 16) | 0x0300; - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x00F0UL << 16) | 0x0030; + GpioPinSetFunction(0, GPIO_PIN_PD1, 3); //i2c0_scl_m2 + GpioPinSetFunction(0, GPIO_PIN_PD2, 3); //i2c0_sda_m2 break; case 1: - /* io mux */ - //BUS_IOC->GPIO0B_IOMUX_SEL_H = (0x0FF0UL << 16) | 0x0990; - //PMU2_IOC->GPIO0B_IOMUX_SEL_H = (0x0FF0UL << 16) | 0x0880; break; case 2: - /* io mux */ - BUS_IOC->GPIO0B_IOMUX_SEL_H = (0xF000UL << 16) | 0x9000; - BUS_IOC->GPIO0C_IOMUX_SEL_L = (0x000FUL << 16) | 0x0009; - PMU2_IOC->GPIO0B_IOMUX_SEL_H = (0xF000UL << 16) | 0x8000; - PMU2_IOC->GPIO0C_IOMUX_SEL_L = (0x000FUL << 16) | 0x0008; + GpioPinSetFunction(0, GPIO_PIN_PB7, 9); //i2c2_scl_m0 + GpioPinSetFunction(0, GPIO_PIN_PC0, 9); //i2c2_sda_m0 break; case 3: break; case 4: + GpioPinSetFunction(1, GPIO_PIN_PA3, 9); //i2c4_scl_m3 + GpioPinSetFunction(1, GPIO_PIN_PA2, 9); //i2c4_sda_m3 break; case 5: + GpioPinSetFunction(3, GPIO_PIN_PC7, 9); //i2c5_scl_m0 + GpioPinSetFunction(3, GPIO_PIN_PD0, 9); //i2c5_sda_m0 break; case 6: - /* io mux M3 */ - BUS_IOC->GPIO4B_IOMUX_SEL_L = (0x00F0UL << 16) | 0x0090; - BUS_IOC->GPIO4B_IOMUX_SEL_L = (0x000FUL << 16) | 0x0009; + GpioPinSetFunction(4, GPIO_PIN_PB1, 9); //i2c6_scl_m3 + GpioPinSetFunction(4, GPIO_PIN_PB0, 9); //i2c6_sda_m3 + break; + case 7: + GpioPinSetFunction(1, GPIO_PIN_PD0, 9); //i2c7_scl_m0 + GpioPinSetFunction(1, GPIO_PIN_PD1, 9); //i2c7_sda_m0 break; default: break; diff --git a/edk2-rockchip/Platform/Firefly/ROC-RK3588S-PC/Library/RockchipPlatformLib/RockchipPlatformLib.c b/edk2-rockchip/Platform/Firefly/ROC-RK3588S-PC/Library/RockchipPlatformLib/RockchipPlatformLib.c index f89f98a6e..c6167cfaf 100644 --- a/edk2-rockchip/Platform/Firefly/ROC-RK3588S-PC/Library/RockchipPlatformLib/RockchipPlatformLib.c +++ b/edk2-rockchip/Platform/Firefly/ROC-RK3588S-PC/Library/RockchipPlatformLib/RockchipPlatformLib.c @@ -197,28 +197,33 @@ I2cIomux ( { switch (id) { case 0: - /* io mux M2 */ - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x0F00UL << 16) | 0x0300; - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x00F0UL << 16) | 0x0030; + GpioPinSetFunction(0, GPIO_PIN_PD1, 3); //i2c0_scl_m2 + GpioPinSetFunction(0, GPIO_PIN_PD2, 3); //i2c0_sda_m2 break; case 1: - /* io mux */ - //BUS_IOC->GPIO0B_IOMUX_SEL_H = (0x0FF0UL << 16) | 0x0990; - //PMU2_IOC->GPIO0B_IOMUX_SEL_H = (0x0FF0UL << 16) | 0x0880; break; case 2: - /* io mux */ - BUS_IOC->GPIO0B_IOMUX_SEL_H = (0xF000UL << 16) | 0x9000; - BUS_IOC->GPIO0C_IOMUX_SEL_L = (0x000FUL << 16) | 0x0009; - PMU2_IOC->GPIO0B_IOMUX_SEL_H = (0xF000UL << 16) | 0x8000; - PMU2_IOC->GPIO0C_IOMUX_SEL_L = (0x000FUL << 16) | 0x0008; + GpioPinSetFunction(0, GPIO_PIN_PB7, 9); //i2c2_scl_m0 + GpioPinSetFunction(0, GPIO_PIN_PC0, 9); //i2c2_sda_m0 break; case 3: + GpioPinSetFunction(1, GPIO_PIN_PC1, 9); //i2c3_scl_m0 + GpioPinSetFunction(1, GPIO_PIN_PC0, 9); //i2c3_sda_m0 break; case 4: + GpioPinSetFunction(1, GPIO_PIN_PA3, 9); //i2c4_scl_m3 + GpioPinSetFunction(1, GPIO_PIN_PA2, 9); //i2c4_sda_m3 break; case 5: break; + case 6: + GpioPinSetFunction(4, GPIO_PIN_PB1, 9); //i2c6_scl_m3 + GpioPinSetFunction(4, GPIO_PIN_PB0, 9); //i2c6_sda_m3 + break; + case 7: + GpioPinSetFunction(1, GPIO_PIN_PD0, 9); //i2c7_scl_m0 + GpioPinSetFunction(1, GPIO_PIN_PD1, 9); //i2c7_sda_m0 + break; default: break; } diff --git a/edk2-rockchip/Platform/FriendlyElec/NanoPC-T6/Library/RockchipPlatformLib/RockchipPlatformLib.c b/edk2-rockchip/Platform/FriendlyElec/NanoPC-T6/Library/RockchipPlatformLib/RockchipPlatformLib.c index 7833fac2e..7a091bad3 100644 --- a/edk2-rockchip/Platform/FriendlyElec/NanoPC-T6/Library/RockchipPlatformLib/RockchipPlatformLib.c +++ b/edk2-rockchip/Platform/FriendlyElec/NanoPC-T6/Library/RockchipPlatformLib/RockchipPlatformLib.c @@ -164,34 +164,28 @@ I2cIomux ( { switch (id) { case 0: - /* io mux M2 */ - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x0F00UL << 16) | 0x0300; - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x00F0UL << 16) | 0x0030; + GpioPinSetFunction(0, GPIO_PIN_PD1, 3); //i2c0_scl_m2 + GpioPinSetFunction(0, GPIO_PIN_PD2, 3); //i2c0_sda_m2 break; case 1: - /* io mux */ - //BUS_IOC->GPIO0B_IOMUX_SEL_H = (0x0FF0UL << 16) | 0x0990; - //PMU2_IOC->GPIO0B_IOMUX_SEL_H = (0x0FF0UL << 16) | 0x0880; break; case 2: - /* io mux */ - BUS_IOC->GPIO0B_IOMUX_SEL_H = (0xF000UL << 16) | 0x9000; - BUS_IOC->GPIO0C_IOMUX_SEL_L = (0x000FUL << 16) | 0x0009; - PMU2_IOC->GPIO0B_IOMUX_SEL_H = (0xF000UL << 16) | 0x8000; - PMU2_IOC->GPIO0C_IOMUX_SEL_L = (0x000FUL << 16) | 0x0008; + GpioPinSetFunction(0, GPIO_PIN_PB7, 9); //i2c2_scl_m0 + GpioPinSetFunction(0, GPIO_PIN_PC0, 9); //i2c2_sda_m0 break; case 3: + GpioPinSetFunction(1, GPIO_PIN_PC1, 9); //i2c3_scl_m0 + GpioPinSetFunction(1, GPIO_PIN_PC0, 9); //i2c3_sda_m0 break; case 4: break; case 5: break; case 6: - /* io mux M0 */ - BUS_IOC->GPIO0C_IOMUX_SEL_H = (0xF000UL << 16) | 0x9000; - BUS_IOC->GPIO0D_IOMUX_SEL_L = (0x000FUL << 16) | 0x0009; - PMU2_IOC->GPIO0C_IOMUX_SEL_H = (0xF000UL << 16) | 0x8000; - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x000FUL << 16) | 0x0008; + GpioPinSetFunction(0, GPIO_PIN_PD0, 9); //i2c6_scl_m0 + GpioPinSetFunction(0, GPIO_PIN_PC7, 9); //i2c6_sda_m0 + break; + case 7: break; default: break; diff --git a/edk2-rockchip/Platform/FriendlyElec/NanoPi-R6C/Library/RockchipPlatformLib/RockchipPlatformLib.c b/edk2-rockchip/Platform/FriendlyElec/NanoPi-R6C/Library/RockchipPlatformLib/RockchipPlatformLib.c index 7d5c2903b..6525824e8 100644 --- a/edk2-rockchip/Platform/FriendlyElec/NanoPi-R6C/Library/RockchipPlatformLib/RockchipPlatformLib.c +++ b/edk2-rockchip/Platform/FriendlyElec/NanoPi-R6C/Library/RockchipPlatformLib/RockchipPlatformLib.c @@ -176,34 +176,28 @@ I2cIomux ( { switch (id) { case 0: - /* io mux M2 */ - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x0F00UL << 16) | 0x0300; - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x00F0UL << 16) | 0x0030; + GpioPinSetFunction(0, GPIO_PIN_PD1, 3); //i2c0_scl_m2 + GpioPinSetFunction(0, GPIO_PIN_PD2, 3); //i2c0_sda_m2 break; case 1: - /* io mux */ - //BUS_IOC->GPIO0B_IOMUX_SEL_H = (0x0FF0UL << 16) | 0x0990; - //PMU2_IOC->GPIO0B_IOMUX_SEL_H = (0x0FF0UL << 16) | 0x0880; break; case 2: - /* io mux */ - BUS_IOC->GPIO0B_IOMUX_SEL_H = (0xF000UL << 16) | 0x9000; - BUS_IOC->GPIO0C_IOMUX_SEL_L = (0x000FUL << 16) | 0x0009; - PMU2_IOC->GPIO0B_IOMUX_SEL_H = (0xF000UL << 16) | 0x8000; - PMU2_IOC->GPIO0C_IOMUX_SEL_L = (0x000FUL << 16) | 0x0008; + GpioPinSetFunction(0, GPIO_PIN_PB7, 9); //i2c2_scl_m0 + GpioPinSetFunction(0, GPIO_PIN_PC0, 9); //i2c2_sda_m0 break; case 3: + GpioPinSetFunction(1, GPIO_PIN_PC1, 9); //i2c3_scl_m0 + GpioPinSetFunction(1, GPIO_PIN_PC0, 9); //i2c3_sda_m0 break; case 4: break; case 5: break; case 6: - /* io mux M0 */ - BUS_IOC->GPIO0C_IOMUX_SEL_H = (0xF000UL << 16) | 0x9000; - BUS_IOC->GPIO0D_IOMUX_SEL_L = (0x000FUL << 16) | 0x0009; - PMU2_IOC->GPIO0C_IOMUX_SEL_H = (0xF000UL << 16) | 0x8000; - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x000FUL << 16) | 0x0008; + GpioPinSetFunction(0, GPIO_PIN_PD0, 9); //i2c6_scl_m0 + GpioPinSetFunction(0, GPIO_PIN_PC7, 9); //i2c6_sda_m0 + break; + case 7: break; default: break; diff --git a/edk2-rockchip/Platform/FriendlyElec/NanoPi-R6S/Library/RockchipPlatformLib/RockchipPlatformLib.c b/edk2-rockchip/Platform/FriendlyElec/NanoPi-R6S/Library/RockchipPlatformLib/RockchipPlatformLib.c index 40f00de67..403a08209 100644 --- a/edk2-rockchip/Platform/FriendlyElec/NanoPi-R6S/Library/RockchipPlatformLib/RockchipPlatformLib.c +++ b/edk2-rockchip/Platform/FriendlyElec/NanoPi-R6S/Library/RockchipPlatformLib/RockchipPlatformLib.c @@ -174,34 +174,28 @@ I2cIomux ( { switch (id) { case 0: - /* io mux M2 */ - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x0F00UL << 16) | 0x0300; - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x00F0UL << 16) | 0x0030; + GpioPinSetFunction(0, GPIO_PIN_PD1, 3); //i2c0_scl_m2 + GpioPinSetFunction(0, GPIO_PIN_PD2, 3); //i2c0_sda_m2 break; case 1: - /* io mux */ - //BUS_IOC->GPIO0B_IOMUX_SEL_H = (0x0FF0UL << 16) | 0x0990; - //PMU2_IOC->GPIO0B_IOMUX_SEL_H = (0x0FF0UL << 16) | 0x0880; break; case 2: - /* io mux */ - BUS_IOC->GPIO0B_IOMUX_SEL_H = (0xF000UL << 16) | 0x9000; - BUS_IOC->GPIO0C_IOMUX_SEL_L = (0x000FUL << 16) | 0x0009; - PMU2_IOC->GPIO0B_IOMUX_SEL_H = (0xF000UL << 16) | 0x8000; - PMU2_IOC->GPIO0C_IOMUX_SEL_L = (0x000FUL << 16) | 0x0008; + GpioPinSetFunction(0, GPIO_PIN_PB7, 9); //i2c2_scl_m0 + GpioPinSetFunction(0, GPIO_PIN_PC0, 9); //i2c2_sda_m0 break; case 3: + GpioPinSetFunction(1, GPIO_PIN_PC1, 9); //i2c3_scl_m0 + GpioPinSetFunction(1, GPIO_PIN_PC0, 9); //i2c3_sda_m0 break; case 4: break; case 5: break; case 6: - /* io mux M0 */ - BUS_IOC->GPIO0C_IOMUX_SEL_H = (0xF000UL << 16) | 0x9000; - BUS_IOC->GPIO0D_IOMUX_SEL_L = (0x000FUL << 16) | 0x0009; - PMU2_IOC->GPIO0C_IOMUX_SEL_H = (0xF000UL << 16) | 0x8000; - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x000FUL << 16) | 0x0008; + GpioPinSetFunction(0, GPIO_PIN_PD0, 9); //i2c6_scl_m0 + GpioPinSetFunction(0, GPIO_PIN_PC7, 9); //i2c6_sda_m0 + break; + case 7: break; default: break; diff --git a/edk2-rockchip/Platform/Hinlink/H88K/Library/RockchipPlatformLib/RockchipPlatformLib.c b/edk2-rockchip/Platform/Hinlink/H88K/Library/RockchipPlatformLib/RockchipPlatformLib.c index ea81ae265..84e24c398 100644 --- a/edk2-rockchip/Platform/Hinlink/H88K/Library/RockchipPlatformLib/RockchipPlatformLib.c +++ b/edk2-rockchip/Platform/Hinlink/H88K/Library/RockchipPlatformLib/RockchipPlatformLib.c @@ -197,27 +197,36 @@ I2cIomux ( { switch (id) { case 0: - /* io mux M2 */ - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x0F00UL << 16) | 0x0300; - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x00F0UL << 16) | 0x0030; + GpioPinSetFunction(0, GPIO_PIN_PD1, 3); //i2c0_scl_m2 + GpioPinSetFunction(0, GPIO_PIN_PD2, 3); //i2c0_sda_m2 break; case 1: - /* io mux */ - //BUS_IOC->GPIO0B_IOMUX_SEL_H = (0x0FF0UL << 16) | 0x0990; - //PMU2_IOC->GPIO0B_IOMUX_SEL_H = (0x0FF0UL << 16) | 0x0880; + GpioPinSetFunction(0, GPIO_PIN_PB5, 9); //i2c1_scl_m0 + GpioPinSetFunction(0, GPIO_PIN_PB6, 9); //i2c1_sda_m0 break; case 2: - /* io mux */ - BUS_IOC->GPIO0B_IOMUX_SEL_H = (0xF000UL << 16) | 0x9000; - BUS_IOC->GPIO0C_IOMUX_SEL_L = (0x000FUL << 16) | 0x0009; - PMU2_IOC->GPIO0B_IOMUX_SEL_H = (0xF000UL << 16) | 0x8000; - PMU2_IOC->GPIO0C_IOMUX_SEL_L = (0x000FUL << 16) | 0x0008; + GpioPinSetFunction(0, GPIO_PIN_PB7, 9); //i2c2_scl_m0 + GpioPinSetFunction(0, GPIO_PIN_PC0, 9); //i2c2_sda_m0 break; case 3: + GpioPinSetFunction(1, GPIO_PIN_PC1, 9); //i2c3_scl_m0 + GpioPinSetFunction(1, GPIO_PIN_PC0, 9); //i2c3_sda_m0 break; case 4: + GpioPinSetFunction(3, GPIO_PIN_PA6, 9); //i2c4_scl_m0 + GpioPinSetFunction(3, GPIO_PIN_PA5, 9); //i2c4_sda_m0 break; case 5: + GpioPinSetFunction(3, GPIO_PIN_PC7, 9); //i2c5_scl_m0 + GpioPinSetFunction(3, GPIO_PIN_PD0, 9); //i2c5_sda_m0 + break; + case 6: + GpioPinSetFunction(0, GPIO_PIN_PD0, 9); //i2c6_scl_m0 + GpioPinSetFunction(0, GPIO_PIN_PC7, 9); //i2c6_sda_m0 + break; + case 7: + GpioPinSetFunction(1, GPIO_PIN_PD0, 9); //i2c7_scl_m0 + GpioPinSetFunction(1, GPIO_PIN_PD1, 9); //i2c7_sda_m0 break; default: break; diff --git a/edk2-rockchip/Platform/Khadas/Edge2/Library/RockchipPlatformLib/RockchipPlatformLib.c b/edk2-rockchip/Platform/Khadas/Edge2/Library/RockchipPlatformLib/RockchipPlatformLib.c index 9897cc2c8..8d214dff3 100644 --- a/edk2-rockchip/Platform/Khadas/Edge2/Library/RockchipPlatformLib/RockchipPlatformLib.c +++ b/edk2-rockchip/Platform/Khadas/Edge2/Library/RockchipPlatformLib/RockchipPlatformLib.c @@ -175,28 +175,31 @@ I2cIomux ( { switch (id) { case 0: - /* io mux M2 */ - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x0F00UL << 16) | 0x0300; - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x00F0UL << 16) | 0x0030; + GpioPinSetFunction(0, GPIO_PIN_PD1, 3); //i2c0_scl_m2 + GpioPinSetFunction(0, GPIO_PIN_PD2, 3); //i2c0_sda_m2 break; case 1: - /* io mux */ - //BUS_IOC->GPIO0B_IOMUX_SEL_H = (0x0FF0UL << 16) | 0x0990; - //PMU2_IOC->GPIO0B_IOMUX_SEL_H = (0x0FF0UL << 16) | 0x0880; break; case 2: - /* io mux */ - BUS_IOC->GPIO0B_IOMUX_SEL_H = (0xF000UL << 16) | 0x9000; - BUS_IOC->GPIO0C_IOMUX_SEL_L = (0x000FUL << 16) | 0x0009; - PMU2_IOC->GPIO0B_IOMUX_SEL_H = (0xF000UL << 16) | 0x8000; - PMU2_IOC->GPIO0C_IOMUX_SEL_L = (0x000FUL << 16) | 0x0008; + GpioPinSetFunction(0, GPIO_PIN_PB7, 9); //i2c2_scl_m0 + GpioPinSetFunction(0, GPIO_PIN_PC0, 9); //i2c2_sda_m0 break; case 3: + GpioPinSetFunction(1, GPIO_PIN_PC1, 9); //i2c3_scl_m0 + GpioPinSetFunction(1, GPIO_PIN_PC0, 9); //i2c3_sda_m0 break; case 4: + GpioPinSetFunction(1, GPIO_PIN_PA3, 9); //i2c4_scl_m3 + GpioPinSetFunction(1, GPIO_PIN_PA2, 9); //i2c4_sda_m3 break; case 5: break; + case 6: + GpioPinSetFunction(0, GPIO_PIN_PD0, 9); //i2c6_scl_m0 + GpioPinSetFunction(0, GPIO_PIN_PC7, 9); //i2c6_sda_m0 + break; + case 7: + break; default: break; } diff --git a/edk2-rockchip/Platform/Mekotronics/R58-Mini/Library/RockchipPlatformLib/RockchipPlatformLib.c b/edk2-rockchip/Platform/Mekotronics/R58-Mini/Library/RockchipPlatformLib/RockchipPlatformLib.c index 835e0dfa8..8c113ceed 100644 --- a/edk2-rockchip/Platform/Mekotronics/R58-Mini/Library/RockchipPlatformLib/RockchipPlatformLib.c +++ b/edk2-rockchip/Platform/Mekotronics/R58-Mini/Library/RockchipPlatformLib/RockchipPlatformLib.c @@ -196,34 +196,28 @@ I2cIomux ( { switch (id) { case 0: - /* io mux M2 */ - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x0F00UL << 16) | 0x0300; - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x00F0UL << 16) | 0x0030; + GpioPinSetFunction(0, GPIO_PIN_PD1, 3); //i2c0_scl_m2 + GpioPinSetFunction(0, GPIO_PIN_PD2, 2); //i2c0_sda_m2 break; case 1: - /* io mux */ - //BUS_IOC->GPIO0B_IOMUX_SEL_H = (0x0FF0UL << 16) | 0x0990; - //PMU2_IOC->GPIO0B_IOMUX_SEL_H = (0x0FF0UL << 16) | 0x0880; break; case 2: - /* io mux */ - BUS_IOC->GPIO0B_IOMUX_SEL_H = (0xF000UL << 16) | 0x9000; - BUS_IOC->GPIO0C_IOMUX_SEL_L = (0x000FUL << 16) | 0x0009; - PMU2_IOC->GPIO0B_IOMUX_SEL_H = (0xF000UL << 16) | 0x8000; - PMU2_IOC->GPIO0C_IOMUX_SEL_L = (0x000FUL << 16) | 0x0008; + GpioPinSetFunction(0, GPIO_PIN_PB7, 9); //i2c2_scl_m0 + GpioPinSetFunction(0, GPIO_PIN_PC0, 9); //i2c2_sda_m0 break; case 3: break; case 4: break; case 5: + GpioPinSetFunction(1, GPIO_PIN_PB6, 9); //i2c5_scl_m3 + GpioPinSetFunction(1, GPIO_PIN_PB7, 9); //i2c5_sda_m3 break; case 6: - /* io mux M0 */ - BUS_IOC->GPIO0C_IOMUX_SEL_H = (0xF000UL << 16) | 0x9000; - BUS_IOC->GPIO0D_IOMUX_SEL_L = (0x000FUL << 16) | 0x0009; - PMU2_IOC->GPIO0C_IOMUX_SEL_H = (0xF000UL << 16) | 0x8000; - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x000FUL << 16) | 0x0008; + GpioPinSetFunction(0, GPIO_PIN_PD0, 9); //i2c6_scl_m0 + GpioPinSetFunction(0, GPIO_PIN_PC7, 9); //i2c6_sda_m0 + break; + case 7: break; default: break; diff --git a/edk2-rockchip/Platform/Mekotronics/R58X/Library/RockchipPlatformLib/RockchipPlatformLib.c b/edk2-rockchip/Platform/Mekotronics/R58X/Library/RockchipPlatformLib/RockchipPlatformLib.c index 4dae8bc15..537c805b1 100644 --- a/edk2-rockchip/Platform/Mekotronics/R58X/Library/RockchipPlatformLib/RockchipPlatformLib.c +++ b/edk2-rockchip/Platform/Mekotronics/R58X/Library/RockchipPlatformLib/RockchipPlatformLib.c @@ -211,34 +211,31 @@ I2cIomux ( { switch (id) { case 0: - /* io mux M2 */ - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x0F00UL << 16) | 0x0300; - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x00F0UL << 16) | 0x0030; + GpioPinSetFunction(0, GPIO_PIN_PD1, 3); //i2c0_scl_m2 + GpioPinSetFunction(0, GPIO_PIN_PD2, 2); //i2c0_sda_m2 break; case 1: - /* io mux */ - //BUS_IOC->GPIO0B_IOMUX_SEL_H = (0x0FF0UL << 16) | 0x0990; - //PMU2_IOC->GPIO0B_IOMUX_SEL_H = (0x0FF0UL << 16) | 0x0880; break; case 2: - /* io mux */ - BUS_IOC->GPIO0B_IOMUX_SEL_H = (0xF000UL << 16) | 0x9000; - BUS_IOC->GPIO0C_IOMUX_SEL_L = (0x000FUL << 16) | 0x0009; - PMU2_IOC->GPIO0B_IOMUX_SEL_H = (0xF000UL << 16) | 0x8000; - PMU2_IOC->GPIO0C_IOMUX_SEL_L = (0x000FUL << 16) | 0x0008; + GpioPinSetFunction(0, GPIO_PIN_PB7, 9); //i2c2_scl_m0 + GpioPinSetFunction(0, GPIO_PIN_PC0, 9); //i2c2_sda_m0 break; case 3: + GpioPinSetFunction(1, GPIO_PIN_PC1, 9); //i2c3_scl_m0 + GpioPinSetFunction(1, GPIO_PIN_PC0, 9); //i2c3_sda_m0 break; case 4: break; case 5: + GpioPinSetFunction(1, GPIO_PIN_PB6, 9); //i2c5_scl_m3 + GpioPinSetFunction(1, GPIO_PIN_PB7, 9); //i2c5_sda_m3 break; case 6: - /* io mux M0 */ - BUS_IOC->GPIO0C_IOMUX_SEL_H = (0xF000UL << 16) | 0x9000; - BUS_IOC->GPIO0D_IOMUX_SEL_L = (0x000FUL << 16) | 0x0009; - PMU2_IOC->GPIO0C_IOMUX_SEL_H = (0xF000UL << 16) | 0x8000; - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x000FUL << 16) | 0x0008; + GpioPinSetFunction(0, GPIO_PIN_PD0, 9); //i2c6_scl_m0 + GpioPinSetFunction(0, GPIO_PIN_PC7, 9); //i2c6_sda_m0 + break; + case 7: + break; default: break; } diff --git a/edk2-rockchip/Platform/Mixtile/Blade3/Library/RockchipPlatformLib/RockchipPlatformLib.c b/edk2-rockchip/Platform/Mixtile/Blade3/Library/RockchipPlatformLib/RockchipPlatformLib.c index 27ab12e6c..9ab05e9db 100644 --- a/edk2-rockchip/Platform/Mixtile/Blade3/Library/RockchipPlatformLib/RockchipPlatformLib.c +++ b/edk2-rockchip/Platform/Mixtile/Blade3/Library/RockchipPlatformLib/RockchipPlatformLib.c @@ -165,27 +165,30 @@ I2cIomux ( { switch (id) { case 0: - /* io mux M2 */ - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x0F00UL << 16) | 0x0300; - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x00F0UL << 16) | 0x0030; + GpioPinSetFunction(0, GPIO_PIN_PD1, 3); //i2c0_scl_m2 + GpioPinSetFunction(0, GPIO_PIN_PD2, 3); //i2c0_sda_m2 break; case 1: - /* io mux */ - //BUS_IOC->GPIO0B_IOMUX_SEL_H = (0x0FF0UL << 16) | 0x0990; - //PMU2_IOC->GPIO0B_IOMUX_SEL_H = (0x0FF0UL << 16) | 0x0880; + GpioPinSetFunction(0, GPIO_PIN_PD4, 9); //i2c1_scl_m2 + GpioPinSetFunction(0, GPIO_PIN_PD5, 9); //i2c1_sda_m2 break; case 2: - /* io mux */ - BUS_IOC->GPIO0B_IOMUX_SEL_H = (0xF000UL << 16) | 0x9000; - BUS_IOC->GPIO0C_IOMUX_SEL_L = (0x000FUL << 16) | 0x0009; - PMU2_IOC->GPIO0B_IOMUX_SEL_H = (0xF000UL << 16) | 0x8000; - PMU2_IOC->GPIO0C_IOMUX_SEL_L = (0x000FUL << 16) | 0x0008; break; case 3: break; case 4: + GpioPinSetFunction(3, GPIO_PIN_PA6, 9); //i2c4_scl_m0 + GpioPinSetFunction(3, GPIO_PIN_PA5, 9); //i2c4_sda_m0 break; case 5: + GpioPinSetFunction(1, GPIO_PIN_PB6, 9); //i2c5_scl_m3 + GpioPinSetFunction(1, GPIO_PIN_PB7, 9); //i2c5_sda_m3 + break; + case 6: + GpioPinSetFunction(0, GPIO_PIN_PD0, 9); //i2c6_scl_m0 + GpioPinSetFunction(0, GPIO_PIN_PC7, 9); //i2c6_sda_m0 + break; + case 7: break; default: break; diff --git a/edk2-rockchip/Platform/OrangePi/OrangePi5/Library/RockchipPlatformLib/RockchipPlatformLib.c b/edk2-rockchip/Platform/OrangePi/OrangePi5/Library/RockchipPlatformLib/RockchipPlatformLib.c index 1b60dd688..6c0f3bc2d 100644 --- a/edk2-rockchip/Platform/OrangePi/OrangePi5/Library/RockchipPlatformLib/RockchipPlatformLib.c +++ b/edk2-rockchip/Platform/OrangePi/OrangePi5/Library/RockchipPlatformLib/RockchipPlatformLib.c @@ -177,32 +177,30 @@ I2cIomux ( { switch (id) { case 0: - /* io mux M2 */ - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x0F00UL << 16) | 0x0300; - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x00F0UL << 16) | 0x0030; + GpioPinSetFunction(0, GPIO_PIN_PB3, 2); //i2c0_scl_m0 + GpioPinSetFunction(0, GPIO_PIN_PA6, 2); //i2c0_sda_m0 break; case 1: - /* io mux */ - //BUS_IOC->GPIO0B_IOMUX_SEL_H = (0x0FF0UL << 16) | 0x0990; - //PMU2_IOC->GPIO0B_IOMUX_SEL_H = (0x0FF0UL << 16) | 0x0880; break; case 2: - /* io mux */ - BUS_IOC->GPIO0B_IOMUX_SEL_H = (0xF000UL << 16) | 0x9000; - BUS_IOC->GPIO0C_IOMUX_SEL_L = (0x000FUL << 16) | 0x0009; - PMU2_IOC->GPIO0B_IOMUX_SEL_H = (0xF000UL << 16) | 0x8000; - PMU2_IOC->GPIO0C_IOMUX_SEL_L = (0x000FUL << 16) | 0x0008; + GpioPinSetFunction(0, GPIO_PIN_PB7, 9); //i2c2_scl_m0 + GpioPinSetFunction(0, GPIO_PIN_PC0, 9); //i2c2_sda_m0 break; case 3: break; case 4: + GpioPinSetFunction(3, GPIO_PIN_PA6, 9); //i2c4_scl_m0 + GpioPinSetFunction(3, GPIO_PIN_PA5, 9); //i2c4_sda_m0 break; case 5: break; case 6: - /* io mux M3 */ - BUS_IOC->GPIO4B_IOMUX_SEL_L = (0x00F0UL << 16) | 0x0090; - BUS_IOC->GPIO4B_IOMUX_SEL_L = (0x000FUL << 16) | 0x0009; + GpioPinSetFunction(4, GPIO_PIN_PB1, 9); //i2c6_scl_m3 + GpioPinSetFunction(4, GPIO_PIN_PB0, 9); //i2c6_sda_m3 + break; + case 7: + GpioPinSetFunction(1, GPIO_PIN_PD0, 9); //i2c7_scl_m0 + GpioPinSetFunction(1, GPIO_PIN_PD1, 9); //i2c7_sda_m0 break; default: break; diff --git a/edk2-rockchip/Platform/OrangePi/OrangePi5Plus/Library/RockchipPlatformLib/RockchipPlatformLib.c b/edk2-rockchip/Platform/OrangePi/OrangePi5Plus/Library/RockchipPlatformLib/RockchipPlatformLib.c index c2ac79712..2c6fc0dd7 100644 --- a/edk2-rockchip/Platform/OrangePi/OrangePi5Plus/Library/RockchipPlatformLib/RockchipPlatformLib.c +++ b/edk2-rockchip/Platform/OrangePi/OrangePi5Plus/Library/RockchipPlatformLib/RockchipPlatformLib.c @@ -165,34 +165,30 @@ I2cIomux ( { switch (id) { case 0: - /* io mux M2 */ - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x0F00UL << 16) | 0x0300; - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x00F0UL << 16) | 0x0030; + GpioPinSetFunction(0, GPIO_PIN_PD1, 3); //i2c0_scl_m2 + GpioPinSetFunction(0, GPIO_PIN_PD2, 3); //i2c0_sda_m2 break; case 1: - /* io mux */ - //BUS_IOC->GPIO0B_IOMUX_SEL_H = (0x0FF0UL << 16) | 0x0990; - //PMU2_IOC->GPIO0B_IOMUX_SEL_H = (0x0FF0UL << 16) | 0x0880; + GpioPinSetFunction(0, GPIO_PIN_PD4, 9); //i2c1_scl_m2 + GpioPinSetFunction(0, GPIO_PIN_PD5, 9); //i2c1_sda_m2 break; case 2: - /* io mux */ - BUS_IOC->GPIO0B_IOMUX_SEL_H = (0xF000UL << 16) | 0x9000; - BUS_IOC->GPIO0C_IOMUX_SEL_L = (0x000FUL << 16) | 0x0009; - PMU2_IOC->GPIO0B_IOMUX_SEL_H = (0xF000UL << 16) | 0x8000; - PMU2_IOC->GPIO0C_IOMUX_SEL_L = (0x000FUL << 16) | 0x0008; break; case 3: + GpioPinSetFunction(1, GPIO_PIN_PC1, 9); //i2c3_scl_m0 + GpioPinSetFunction(1, GPIO_PIN_PC0, 9); //i2c3_sda_m0 break; case 4: break; case 5: break; case 6: - /* io mux M0 */ - BUS_IOC->GPIO0C_IOMUX_SEL_H = (0xF000UL << 16) | 0x9000; - BUS_IOC->GPIO0D_IOMUX_SEL_L = (0x000FUL << 16) | 0x0009; - PMU2_IOC->GPIO0C_IOMUX_SEL_H = (0xF000UL << 16) | 0x8000; - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x000FUL << 16) | 0x0008; + GpioPinSetFunction(0, GPIO_PIN_PD0, 9); //i2c6_scl_m0 + GpioPinSetFunction(0, GPIO_PIN_PC7, 9); //i2c6_sda_m0 + break; + case 7: + GpioPinSetFunction(1, GPIO_PIN_PD0, 9); //i2c7_scl_m0 + GpioPinSetFunction(1, GPIO_PIN_PD1, 9); //i2c7_sda_m0 break; default: break; diff --git a/edk2-rockchip/Platform/Radxa/ROCK5A/Library/RockchipPlatformLib/RockchipPlatformLib.c b/edk2-rockchip/Platform/Radxa/ROCK5A/Library/RockchipPlatformLib/RockchipPlatformLib.c index c250ffdcf..c78bdb2c7 100644 --- a/edk2-rockchip/Platform/Radxa/ROCK5A/Library/RockchipPlatformLib/RockchipPlatformLib.c +++ b/edk2-rockchip/Platform/Radxa/ROCK5A/Library/RockchipPlatformLib/RockchipPlatformLib.c @@ -175,21 +175,14 @@ I2cIomux ( { switch (id) { case 0: - /* io mux M2 */ - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x0F00UL << 16) | 0x0300; - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x00F0UL << 16) | 0x0030; + GpioPinSetFunction(0, GPIO_PIN_PD1, 3); //i2c0_scl_m2 + GpioPinSetFunction(0, GPIO_PIN_PD2, 3); //i2c0_sda_m2 break; case 1: - /* io mux */ - //BUS_IOC->GPIO0B_IOMUX_SEL_H = (0x0FF0UL << 16) | 0x0990; - //PMU2_IOC->GPIO0B_IOMUX_SEL_H = (0x0FF0UL << 16) | 0x0880; break; case 2: - /* io mux */ - BUS_IOC->GPIO0B_IOMUX_SEL_H = (0xF000UL << 16) | 0x9000; - BUS_IOC->GPIO0C_IOMUX_SEL_L = (0x000FUL << 16) | 0x0009; - PMU2_IOC->GPIO0B_IOMUX_SEL_H = (0xF000UL << 16) | 0x8000; - PMU2_IOC->GPIO0C_IOMUX_SEL_L = (0x000FUL << 16) | 0x0008; + GpioPinSetFunction(0, GPIO_PIN_PB7, 9); //i2c2_scl_m0 + GpioPinSetFunction(0, GPIO_PIN_PC0, 9); //i2c2_sda_m0 break; case 3: break; @@ -197,6 +190,12 @@ I2cIomux ( break; case 5: break; + case 6: + break; + case 7: + GpioPinSetFunction(1, GPIO_PIN_PD0, 9); //i2c7_scl_m0 + GpioPinSetFunction(1, GPIO_PIN_PD1, 9); //i2c7_sda_m0 + break; default: break; } diff --git a/edk2-rockchip/Platform/Radxa/ROCK5B/Library/RockchipPlatformLib/RockchipPlatformLib.c b/edk2-rockchip/Platform/Radxa/ROCK5B/Library/RockchipPlatformLib/RockchipPlatformLib.c index 5e3eb3fc9..27c3ca1c8 100644 --- a/edk2-rockchip/Platform/Radxa/ROCK5B/Library/RockchipPlatformLib/RockchipPlatformLib.c +++ b/edk2-rockchip/Platform/Radxa/ROCK5B/Library/RockchipPlatformLib/RockchipPlatformLib.c @@ -165,34 +165,30 @@ I2cIomux ( { switch (id) { case 0: - /* io mux M2 */ - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x0F00UL << 16) | 0x0300; - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x00F0UL << 16) | 0x0030; + GpioPinSetFunction(0, GPIO_PIN_PD1, 3); //i2c0_scl_m2 + GpioPinSetFunction(0, GPIO_PIN_PD2, 3); //i2c0_sda_m2 break; case 1: - /* io mux */ - //BUS_IOC->GPIO0B_IOMUX_SEL_H = (0x0FF0UL << 16) | 0x0990; - //PMU2_IOC->GPIO0B_IOMUX_SEL_H = (0x0FF0UL << 16) | 0x0880; + GpioPinSetFunction(0, GPIO_PIN_PD4, 9); //i2c1_scl_m2 + GpioPinSetFunction(0, GPIO_PIN_PD5, 9); //i2c1_sda_m2 break; case 2: - /* io mux */ - BUS_IOC->GPIO0B_IOMUX_SEL_H = (0xF000UL << 16) | 0x9000; - BUS_IOC->GPIO0C_IOMUX_SEL_L = (0x000FUL << 16) | 0x0009; - PMU2_IOC->GPIO0B_IOMUX_SEL_H = (0xF000UL << 16) | 0x8000; - PMU2_IOC->GPIO0C_IOMUX_SEL_L = (0x000FUL << 16) | 0x0008; break; case 3: break; case 4: + GpioPinSetFunction(2, GPIO_PIN_PB5, 9); //i2c4_scl_m1 + GpioPinSetFunction(2, GPIO_PIN_PB4, 9); //i2c4_sda_m1 break; case 5: break; case 6: - /* io mux M0 */ - BUS_IOC->GPIO0C_IOMUX_SEL_H = (0xF000UL << 16) | 0x9000; - BUS_IOC->GPIO0D_IOMUX_SEL_L = (0x000FUL << 16) | 0x0009; - PMU2_IOC->GPIO0C_IOMUX_SEL_H = (0xF000UL << 16) | 0x8000; - PMU2_IOC->GPIO0D_IOMUX_SEL_L = (0x000FUL << 16) | 0x0008; + GpioPinSetFunction(0, GPIO_PIN_PD0, 9); //i2c6_scl_m0 + GpioPinSetFunction(0, GPIO_PIN_PC7, 9); //i2c6_sda_m0 + break; + case 7: + GpioPinSetFunction(1, GPIO_PIN_PD0, 9); //i2c7_scl_m0 + GpioPinSetFunction(1, GPIO_PIN_PD1, 9); //i2c7_sda_m0 break; default: break;