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>
This commit is contained in:
Kevin O'Connor 2020-11-25 19:39:02 -05:00
parent 21a3a8559d
commit 7b28cdbae5
1 changed files with 19 additions and 9 deletions

View File

@ -1,6 +1,6 @@
// GPIO functions on PRU // 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. // 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 (void*)0x44e07000, (void*)0x4804c000, (void*)0x481ac000, (void*)0x481ae000
}; };
/****************************************************************
* Pin mux handling
****************************************************************/
#define MUXPORT(offset) (((offset)-0x800) / 4) #define MUXPORT(offset) (((offset)-0x800) / 4)
static uint8_t gpio_mux_offset[32 * ARRAY_SIZE(digital_regs)] = { 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) #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 * 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)) if (GPIO2PORT(pin) >= ARRAY_SIZE(digital_regs))
goto fail; goto fail;
uint8_t mux_offset = gpio_mux_offset[pin];
if (mux_offset == 0xff)
goto fail;
struct gpio_regs *regs = digital_regs[GPIO2PORT(pin)]; struct gpio_regs *regs = digital_regs[GPIO2PORT(pin)];
uint32_t bit = GPIO2BIT(pin); uint32_t bit = GPIO2BIT(pin);
struct gpio_out rv = (struct gpio_out){.reg=&regs->cleardataout, .bit=bit}; struct gpio_out rv = (struct gpio_out){.reg=&regs->cleardataout, .bit=bit};
gpio_out_write(rv, val); gpio_out_write(rv, val);
regs->oe &= ~bit; regs->oe &= ~bit;
*MUXREG(mux_offset) = 0x0f; set_pin_mux(pin, 0x0f);
return rv; return rv;
fail: fail:
shutdown("Not an output pin"); 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)) if (GPIO2PORT(pin) >= ARRAY_SIZE(digital_regs))
goto fail; goto fail;
uint8_t mux_offset = gpio_mux_offset[pin];
if (mux_offset == 0xff)
goto fail;
struct gpio_regs *regs = digital_regs[GPIO2PORT(pin)]; struct gpio_regs *regs = digital_regs[GPIO2PORT(pin)];
uint32_t bit = GPIO2BIT(pin); uint32_t bit = GPIO2BIT(pin);
regs->oe |= bit; 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 }; return (struct gpio_in){ .reg=&regs->datain, .bit=bit };
fail: fail:
shutdown("Not an input pin"); shutdown("Not an input pin");