aboutsummaryrefslogtreecommitdiff
path: root/lib/gpio.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gpio.c')
-rw-r--r--lib/gpio.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/gpio.c b/lib/gpio.c
index abf47cf..747977d 100644
--- a/lib/gpio.c
+++ b/lib/gpio.c
@@ -106,3 +106,17 @@ void gpio_port_write(u32 gpioport, u16 data)
{
GPIO_ODR(gpioport) = data;
}
+
+void gpio_port_config_lock(u32 gpioport, u16 gpios)
+{
+ u32 reg32;
+
+ /* Special "Lock Key Writing Sequence", see datasheet. */
+ GPIO_LCKR(gpioport) = GPIO_LCKK | gpios; /* Set LCKK. */
+ GPIO_LCKR(gpioport) = ~GPIO_LCKK & gpios; /* Clear LCKK. */
+ GPIO_LCKR(gpioport) = GPIO_LCKK | gpios; /* Set LCKK. */
+ reg32 = GPIO_LCKR(gpioport); /* Read LCKK. */
+ reg32 = GPIO_LCKR(gpioport); /* Read LCKK again. */
+
+ /* If (reg32 & GPIO_LCKK) is true, the lock is now active. */
+}