Stefan thinks they don't add value. Command used: sed -i -e '/file is part of /d' $(git grep "file is part of " |egrep ":( */\*.*\*/\$|#|;#|-- | *\* )" | cut -d: -f1 |grep -v crossgcc |grep -v gcov | grep -v /elf.h |grep -v nvramtool) The exceptions are for: - crossgcc (patch file) - gcov (imported from gcc) - elf.h (imported from GNU's libc) - nvramtool (more complicated header) The removed lines are: - fmt.Fprintln(f, "/* This file is part of the coreboot project. */") -# This file is part of a set of unofficial pre-commit hooks available -/* This file is part of coreboot */ -# This file is part of msrtool. -/* This file is part of msrtool. */ - * This file is part of ncurses, designed to be appended after curses.h.in -/* This file is part of pgtblgen. */ - * This file is part of the coreboot project. - /* This file is part of the coreboot project. */ -# This file is part of the coreboot project. -# This file is part of the coreboot project. -## This file is part of the coreboot project. --- This file is part of the coreboot project. -/* This file is part of the coreboot project */ -/* This file is part of the coreboot project. */ -;## This file is part of the coreboot project. -# This file is part of the coreboot project. It originated in the - * This file is part of the coreinfo project. -## This file is part of the coreinfo project. - * This file is part of the depthcharge project. -/* This file is part of the depthcharge project. */ -/* This file is part of the ectool project. */ - * This file is part of the GNU C Library. - * This file is part of the libpayload project. -## This file is part of the libpayload project. -/* This file is part of the Linux kernel. */ -## This file is part of the superiotool project. -/* This file is part of the superiotool project */ -/* This file is part of uio_usbdebug */ Change-Id: I82d872b3b337388c93d5f5bf704e9ee9e53ab3a9 Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/41194 Reviewed-by: HAOUAS Elyes <ehaouas@noos.fr> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
120 lines
3 KiB
C
120 lines
3 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
|
|
#include <device/mmio.h>
|
|
#include <soc/addressmap.h>
|
|
#include <soc/padconfig.h>
|
|
|
|
static uint32_t * const pinmux_regs = (void *)(uintptr_t)TEGRA_APB_PINMUX_BASE;
|
|
static struct gpio_bank * const gpio_regs = (void *)(uintptr_t)TEGRA_GPIO_BASE;
|
|
|
|
static inline struct gpio_bank * const get_gpio_bank_regs(int index)
|
|
{
|
|
return &gpio_regs[gpio_index_to_bank(index)];
|
|
}
|
|
|
|
static inline uint32_t pad_get_pinmux(int index)
|
|
{
|
|
return read32(&pinmux_regs[index]);
|
|
}
|
|
|
|
static inline void pad_set_pinmux(int index, uint32_t reg)
|
|
{
|
|
return write32(&pinmux_regs[index], reg);
|
|
}
|
|
|
|
static inline void pad_set_gpio_out(int gpio_index, int val)
|
|
{
|
|
struct gpio_bank * const regs = get_gpio_bank_regs(gpio_index);
|
|
int port = gpio_index_to_port(gpio_index);
|
|
int bit = gpio_to_bit(gpio_index);
|
|
|
|
write32(®s->out_value_mask[port],
|
|
(1 << (bit + GPIO_GPIOS_PER_PORT)) | (val << bit));
|
|
write32(®s->out_enable_mask[port],
|
|
(1 << (bit + GPIO_GPIOS_PER_PORT)) | (1 << bit));
|
|
}
|
|
|
|
static inline void pad_set_mode(int gpio_index, int sfio_or_gpio)
|
|
{
|
|
struct gpio_bank * const regs = get_gpio_bank_regs(gpio_index);
|
|
int port = gpio_index_to_port(gpio_index);
|
|
int bit = gpio_to_bit(gpio_index);
|
|
|
|
write32(®s->config_mask[port],
|
|
(1 << (bit + GPIO_GPIOS_PER_PORT)) | (sfio_or_gpio << bit));
|
|
}
|
|
|
|
static inline void pad_set_gpio_mode(int gpio_index)
|
|
{
|
|
pad_set_mode(gpio_index, 1);
|
|
}
|
|
|
|
static inline void pad_set_sfio_mode(int gpio_index)
|
|
{
|
|
pad_set_mode(gpio_index, 0);
|
|
}
|
|
|
|
static void configure_unused_pad(const struct pad_config * const entry)
|
|
{
|
|
uint32_t reg;
|
|
|
|
/*
|
|
* Tristate the pad and disable input. If power-on-reset state is a
|
|
* pullup maintain that. Otherwise enable pulldown.
|
|
*/
|
|
reg = pad_get_pinmux(entry->pinmux_index);
|
|
reg &= ~PINMUX_INPUT_ENABLE;
|
|
reg |= PINMUX_TRISTATE;
|
|
reg &= ~PINMUX_PULL_MASK;
|
|
if (entry->por_pullup)
|
|
reg |= PINMUX_PULL_UP;
|
|
else
|
|
reg |= PINMUX_PULL_DOWN;
|
|
pad_set_pinmux(entry->pinmux_index, reg);
|
|
|
|
/*
|
|
* Set to GPIO mode if GPIO available to bypass collisions of
|
|
* controller signals going to more than one pad.
|
|
*/
|
|
if (entry->pad_has_gpio)
|
|
pad_set_gpio_mode(entry->gpio_index);
|
|
}
|
|
|
|
static void configure_sfio_pad(const struct pad_config * const entry)
|
|
{
|
|
pad_set_pinmux(entry->pinmux_index, entry->pinmux_flags);
|
|
pad_set_sfio_mode(entry->gpio_index);
|
|
}
|
|
|
|
static void configure_gpio_pad(const struct pad_config * const entry)
|
|
{
|
|
uint32_t reg;
|
|
|
|
if (entry->gpio_out0 || entry->gpio_out1)
|
|
pad_set_gpio_out(entry->gpio_index, entry->gpio_out1 ? 1 : 0);
|
|
|
|
/* Keep the original SFIO selection. */
|
|
reg = pinmux_get_config(entry->pinmux_index);
|
|
reg &= PINMUX_FUNC_MASK;
|
|
reg |= entry->pinmux_flags;
|
|
|
|
pad_set_pinmux(entry->pinmux_index, reg);
|
|
pad_set_gpio_mode(entry->gpio_index);
|
|
}
|
|
|
|
void soc_configure_pads(const struct pad_config * const entries, size_t num)
|
|
{
|
|
size_t i;
|
|
|
|
for (i = 0; i < num; i++) {
|
|
const struct pad_config * const entry = &entries[i];
|
|
|
|
if (entry->unused) {
|
|
configure_unused_pad(entry);
|
|
} else if (entry->sfio) {
|
|
configure_sfio_pad(entry);
|
|
} else {
|
|
configure_gpio_pad(entry);
|
|
}
|
|
}
|
|
}
|