From patchwork Sat May 18 22:31:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 2589331 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id F1B70DF2E5 for ; Sat, 18 May 2013 22:31:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753342Ab3ERWbi (ORCPT ); Sat, 18 May 2013 18:31:38 -0400 Received: from mail-ee0-f43.google.com ([74.125.83.43]:47821 "EHLO mail-ee0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753318Ab3ERWbi (ORCPT ); Sat, 18 May 2013 18:31:38 -0400 Received: by mail-ee0-f43.google.com with SMTP id d41so2985264eek.2 for ; Sat, 18 May 2013 15:31:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=YDI95bQrTKWf6PRG6peAN+sjoDlmfQd4bcJTWYtSvEo=; b=V7zTNMXbOr6a7L5N57XnxdMXT+SnQT8OoQrPnt27dE2jqxPODUfYUQ1rQ3DdigVB1z d7qdUV8ziGHPPe69LRBmxUD29j/mXHsh3+bn++qVZDqytHIlY2jpFQSpi2FlmcjXMPbI oxSiFuWbd3z7A8C9DV6stm8ObP8Iqq5HOyQB6rD6w52kilBJdM+yYe6J9UlcQMKqDWc5 gsvESKWtrRIxRnzU/ZycHcSMYLuJGn4cxhb42iFOArE7sAfkyvCCg6HPrhnrXL1Yy20j HFi7Z7WHj6impzehq82+fp7CQ8w1zZeWjwjYduycIzN3zwlPmDPtS9zs27W2iUoYiat1 be3Q== X-Received: by 10.15.23.69 with SMTP id g45mr147030136eeu.25.1368916296670; Sat, 18 May 2013 15:31:36 -0700 (PDT) Received: from flatron.tomeq (87-207-52-162.dynamic.chello.pl. [87.207.52.162]) by mx.google.com with ESMTPSA id c42sm28149272eeb.10.2013.05.18.15.31.34 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 18 May 2013 15:31:35 -0700 (PDT) From: Tomasz Figa To: linux-arm-kernel@lists.infradead.org Cc: linux-samsung-soc@vger.kernel.org, Kukjin Kim , Tomasz Figa Subject: [PATCH] ARM: s5p64x0: Use common uncompress.h part for plat-samsung Date: Sun, 19 May 2013 00:31:21 +0200 Message-Id: <1368916282-22896-1-git-send-email-tomasz.figa@gmail.com> X-Mailer: git-send-email 1.8.2.1 Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org Since uart_base can be set dynamically in arch_detect_cpu(), there is no need to have a copy of all code locally, just to override UART base address. This patch removes any duplicate code in uncompress.h variant of s5p64x0 and implements proper arch_detect_cpu() function to initialize UART with SoC-specific parameters. Signed-off-by: Tomasz Figa --- arch/arm/mach-s5p64x0/include/mach/uncompress.h | 155 +----------------------- 1 file changed, 5 insertions(+), 150 deletions(-) diff --git a/arch/arm/mach-s5p64x0/include/mach/uncompress.h b/arch/arm/mach-s5p64x0/include/mach/uncompress.h index 19e0d64..b383b81 100644 --- a/arch/arm/mach-s5p64x0/include/mach/uncompress.h +++ b/arch/arm/mach-s5p64x0/include/mach/uncompress.h @@ -15,37 +15,11 @@ #include -/* - * cannot use commonly - * because uart base of S5P6440 and S5P6450 is different - */ - -typedef unsigned int upf_t; /* cannot include linux/serial_core.h */ - -/* uart setup */ - -unsigned int fifo_mask; -unsigned int fifo_max; - -/* forward declerations */ - -static void arch_detect_cpu(void); - -/* defines for UART registers */ - -#include -#include - -/* working in physical space... */ -#undef S3C2410_WDOGREG -#define S3C2410_WDOGREG(x) ((S3C24XX_PA_WATCHDOG + (x))) - -/* how many bytes we allow into the FIFO at a time in FIFO mode */ -#define FIFO_MAX (14) - unsigned long uart_base; -static __inline__ void get_uart_base(void) +#include + +static void arch_detect_cpu(void) { unsigned int chipid; @@ -57,128 +31,9 @@ static __inline__ void get_uart_base(void) uart_base += 0xEC800000; else uart_base += 0xEC000000; -} - -static __inline__ void uart_wr(unsigned int reg, unsigned int val) -{ - volatile unsigned int *ptr; - get_uart_base(); - ptr = (volatile unsigned int *)(reg + uart_base); - *ptr = val; -} - -static __inline__ unsigned int uart_rd(unsigned int reg) -{ - volatile unsigned int *ptr; - - get_uart_base(); - ptr = (volatile unsigned int *)(reg + uart_base); - return *ptr; -} - -/* - * we can deal with the case the UARTs are being run - * in FIFO mode, so that we don't hold up our execution - * waiting for tx to happen... - */ - -static void putc(int ch) -{ - if (uart_rd(S3C2410_UFCON) & S3C2410_UFCON_FIFOMODE) { - int level; - - while (1) { - level = uart_rd(S3C2410_UFSTAT); - level &= fifo_mask; - - if (level < fifo_max) - break; - } - - } else { - /* not using fifos */ - - while ((uart_rd(S3C2410_UTRSTAT) & S3C2410_UTRSTAT_TXE) != S3C2410_UTRSTAT_TXE) - barrier(); - } - - /* write byte to transmission register */ - uart_wr(S3C2410_UTXH, ch); -} - -static inline void flush(void) -{ -} - -#define __raw_writel(d, ad) \ - do { \ - *((volatile unsigned int __force *)(ad)) = (d); \ - } while (0) - - -#ifdef CONFIG_S3C_BOOT_ERROR_RESET - -static void arch_decomp_error(const char *x) -{ - putstr("\n\n"); - putstr(x); - putstr("\n\n -- System resetting\n"); - - __raw_writel(0x4000, S3C2410_WTDAT); - __raw_writel(0x4000, S3C2410_WTCNT); - __raw_writel(S3C2410_WTCON_ENABLE | S3C2410_WTCON_DIV128 | S3C2410_WTCON_RSTEN | S3C2410_WTCON_PRESCALE(0x40), S3C2410_WTCON); - - while(1); -} - -#define arch_error arch_decomp_error -#endif - -#ifdef CONFIG_S3C_BOOT_UART_FORCE_FIFO -static inline void arch_enable_uart_fifo(void) -{ - u32 fifocon = uart_rd(S3C2410_UFCON); - - if (!(fifocon & S3C2410_UFCON_FIFOMODE)) { - fifocon |= S3C2410_UFCON_RESETBOTH; - uart_wr(S3C2410_UFCON, fifocon); - - /* wait for fifo reset to complete */ - while (1) { - fifocon = uart_rd(S3C2410_UFCON); - if (!(fifocon & S3C2410_UFCON_RESETBOTH)) - break; - } - } -} -#else -#define arch_enable_uart_fifo() do { } while(0) -#endif - -static void arch_decomp_setup(void) -{ - /* - * we may need to setup the uart(s) here if we are not running - * on an BAST... the BAST will have left the uarts configured - * after calling linux. - */ - - arch_detect_cpu(); - - /* - * Enable the UART FIFOs if they where not enabled and our - * configuration says we should turn them on. - */ - - arch_enable_uart_fifo(); -} - - - -static void arch_detect_cpu(void) -{ - /* we do not need to do any cpu detection here at the moment. */ + fifo_mask = S3C2440_UFSTAT_TXMASK; + fifo_max = 63 << S3C2440_UFSTAT_TXSHIFT; } #endif /* __ASM_ARCH_UNCOMPRESS_H */