aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2020-11-25 19:39:02 -0500
committerKevin O'Connor <kevin@koconnor.net>2020-12-04 16:10:13 -0500
commit7b28cdbae57bec87a7c399415f36306030637852 (patch)
tree106ce3b7c9a3ec18202f10f5c01f211941c8b92b
parent21a3a8559d34957a8ed210d68f344d1c7e3288cd (diff)
downloadkutter-7b28cdbae57bec87a7c399415f36306030637852.tar.gz
kutter-7b28cdbae57bec87a7c399415f36306030637852.tar.xz
kutter-7b28cdbae57bec87a7c399415f36306030637852.zip
pru: Disable gpio mux configuration code
The code isn't actually capable of altering the mux registers due to hardware checks enforced by the chip. Disable that code to save a few bytes in the final binary. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--src/pru/gpio.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/pru/gpio.c b/src/pru/gpio.c
index 1e298657..2f77a071 100644
--- a/src/pru/gpio.c
+++ b/src/pru/gpio.c
@@ -1,6 +1,6 @@
// GPIO functions on PRU
//
-// Copyright (C) 2017 Kevin O'Connor <kevin@koconnor.net>
+// Copyright (C) 2017-2020 Kevin O'Connor <kevin@koconnor.net>
//
// This file may be distributed under the terms of the GNU GPLv3 license.
@@ -38,6 +38,11 @@ static struct gpio_regs *digital_regs[] = {
(void*)0x44e07000, (void*)0x4804c000, (void*)0x481ac000, (void*)0x481ae000
};
+
+/****************************************************************
+ * Pin mux handling
+ ****************************************************************/
+
#define MUXPORT(offset) (((offset)-0x800) / 4)
static uint8_t gpio_mux_offset[32 * ARRAY_SIZE(digital_regs)] = {
@@ -84,6 +89,17 @@ static uint8_t gpio_mux_offset[32 * ARRAY_SIZE(digital_regs)] = {
#define MUXREG(mux_offset) ((volatile uint32_t *)0x44e10800 + mux_offset)
+static void
+set_pin_mux(uint8_t pin, uint8_t val)
+{
+ return; // XXX - can not set mux value from PRU
+
+ uint8_t mux_offset = gpio_mux_offset[pin];
+ if (mux_offset == 0xff)
+ shutdown("Invalid mux pin");
+ *MUXREG(mux_offset) = val;
+}
+
/****************************************************************
* General Purpose Input Output (GPIO) pins
@@ -94,15 +110,12 @@ gpio_out_setup(uint8_t pin, uint8_t val)
{
if (GPIO2PORT(pin) >= ARRAY_SIZE(digital_regs))
goto fail;
- uint8_t mux_offset = gpio_mux_offset[pin];
- if (mux_offset == 0xff)
- goto fail;
struct gpio_regs *regs = digital_regs[GPIO2PORT(pin)];
uint32_t bit = GPIO2BIT(pin);
struct gpio_out rv = (struct gpio_out){.reg=&regs->cleardataout, .bit=bit};
gpio_out_write(rv, val);
regs->oe &= ~bit;
- *MUXREG(mux_offset) = 0x0f;
+ set_pin_mux(pin, 0x0f);
return rv;
fail:
shutdown("Not an output pin");
@@ -141,13 +154,10 @@ gpio_in_setup(uint8_t pin, int8_t pull_up)
{
if (GPIO2PORT(pin) >= ARRAY_SIZE(digital_regs))
goto fail;
- uint8_t mux_offset = gpio_mux_offset[pin];
- if (mux_offset == 0xff)
- goto fail;
struct gpio_regs *regs = digital_regs[GPIO2PORT(pin)];
uint32_t bit = GPIO2BIT(pin);
regs->oe |= bit;
- *MUXREG(mux_offset) = pull_up > 0 ? 0x37 : (pull_up < 0 ? 0x27 : 0x2f);
+ set_pin_mux(pin, pull_up > 0 ? 0x37 : (pull_up < 0 ? 0x27 : 0x2f));
return (struct gpio_in){ .reg=&regs->datain, .bit=bit };
fail:
shutdown("Not an input pin");