X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=arch%2Farm%2Fmach-uniphier%2Fdebug-uart%2Fdebug-uart.c;h=a70ce59accdc63e49edc1e15947e5baa450ad335;hb=1cdb6148450e851abe1df5d7eb20aa07a409941c;hp=d884785acbbe5f87e3f5f3be5017ba73d3acd7c8;hpb=b5b84be8a7356d4c3618b6edcb501885e53569f5;p=oweals%2Fu-boot.git diff --git a/arch/arm/mach-uniphier/debug-uart/debug-uart.c b/arch/arm/mach-uniphier/debug-uart/debug-uart.c index d884785acb..a70ce59acc 100644 --- a/arch/arm/mach-uniphier/debug-uart/debug-uart.c +++ b/arch/arm/mach-uniphier/debug-uart/debug-uart.c @@ -1,7 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * Copyright (C) 2016 Masahiro Yamada - * - * SPDX-License-Identifier: GPL-2.0+ */ #include @@ -9,6 +8,7 @@ #include #include +#include "../sg-regs.h" #include "../soc-info.h" #include "debug-uart.h" @@ -27,52 +27,70 @@ static void _debug_uart_putc(int c) writel(c, base + UNIPHIER_UART_TX); } +#ifdef CONFIG_SPL_BUILD +void sg_set_pinsel(unsigned int pin, unsigned int muxval, + unsigned int mux_bits, unsigned int reg_stride) +{ + unsigned int shift = pin * mux_bits % 32; + void __iomem *reg = sg_base + SG_PINCTRL_BASE + + pin * mux_bits / 32 * reg_stride; + u32 mask = (1U << mux_bits) - 1; + u32 tmp; + + tmp = readl(reg); + tmp &= ~(mask << shift); + tmp |= (mask & muxval) << shift; + writel(tmp, reg); +} + +void sg_set_iectrl(unsigned int pin) +{ + unsigned int bit = pin % 32; + void __iomem *reg = sg_base + SG_IECTRL + pin / 32 * 4; + u32 tmp; + + tmp = readl(reg); + tmp |= 1 << bit; + writel(tmp, reg); +} +#endif + void _debug_uart_init(void) { +#ifdef CONFIG_SPL_BUILD void __iomem *base = (void __iomem *)CONFIG_DEBUG_UART_BASE; unsigned int divisor; - switch (uniphier_get_soc_type()) { -#if defined(CONFIG_ARCH_UNIPHIER_SLD3) - case SOC_UNIPHIER_SLD3: - divisor = uniphier_sld3_debug_uart_init(); - break; -#endif + switch (uniphier_get_soc_id()) { #if defined(CONFIG_ARCH_UNIPHIER_LD4) - case SOC_UNIPHIER_LD4: + case UNIPHIER_LD4_ID: divisor = uniphier_ld4_debug_uart_init(); break; #endif #if defined(CONFIG_ARCH_UNIPHIER_PRO4) - case SOC_UNIPHIER_PRO4: + case UNIPHIER_PRO4_ID: divisor = uniphier_pro4_debug_uart_init(); break; #endif #if defined(CONFIG_ARCH_UNIPHIER_SLD8) - case SOC_UNIPHIER_SLD8: + case UNIPHIER_SLD8_ID: divisor = uniphier_sld8_debug_uart_init(); break; #endif #if defined(CONFIG_ARCH_UNIPHIER_PRO5) - case SOC_UNIPHIER_PRO5: + case UNIPHIER_PRO5_ID: divisor = uniphier_pro5_debug_uart_init(); break; #endif #if defined(CONFIG_ARCH_UNIPHIER_PXS2) - case SOC_UNIPHIER_PXS2: + case UNIPHIER_PXS2_ID: divisor = uniphier_pxs2_debug_uart_init(); break; #endif #if defined(CONFIG_ARCH_UNIPHIER_LD6B) - case SOC_UNIPHIER_LD6B: + case UNIPHIER_LD6B_ID: divisor = uniphier_ld6b_debug_uart_init(); break; -#endif -#if defined(CONFIG_ARCH_UNIPHIER_LD11) || defined(CONFIG_ARCH_UNIPHIER_LD20) - case SOC_UNIPHIER_LD11: - case SOC_UNIPHIER_LD20: - divisor = uniphier_ld20_debug_uart_init(); - break; #endif default: return; @@ -81,5 +99,6 @@ void _debug_uart_init(void) writel(UART_LCR_WLEN8 << 8, base + UNIPHIER_UART_LCR_MCR); writel(divisor, base + UNIPHIER_UART_LDR); +#endif } DEBUG_UART_FUNCS