From: Arnd Bergmann <arnd@arndb.de>
To: Kukjin Kim <kgene@kernel.org>, Krzysztof Kozlowski <krzk@kernel.org>
Cc: linux-samsung-soc@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linus.walleij@linaro.org,
Arnd Bergmann <arnd@arndb.de>,
linux-kernel@vger.kernel.org
Subject: [PATCH 02/36] ARM: s3c: simplify mach/io.h
Date: Thu, 10 Oct 2019 22:29:46 +0200 [thread overview]
Message-ID: <20191010203043.1241612-2-arnd@arndb.de> (raw)
In-Reply-To: <20191010203043.1241612-1-arnd@arndb.de>
s3c24xx has a custom implementation of the inb/outb family of I/O
accessors, implementing both general register access and ISA I/O port
through a multiplexer.
As far as I can tell, the first case has never been needed, and certainly
is not used now, as drivers only use inb/outb to actually driver ISA or
PCI port I/O.
Similarly, the special ISA support is limited to a single machine, the
Simtec Electronics BAST (EB2410ITX) with its PC/104 expansion connector,
all other machines could simply use the generic implementation from
asm/io.h that expects a single memory-mapped address range for byte,
word and dword access. As no other machines besides BAST actually selects
CONFIG_ISA, this is likely not even necessary.
As a cleanup, remove suport for the non-ISA access from the helpers,
and make the ISA access use the virtual address window that we use
elsewhere for PCI I/O ports. In configurations without the BAST machine,
this now falls back on the generic implementation from asm/io.h, but
the mach/io.h header is still relied on to include a number of other
header files implicitly.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
arch/arm/mach-s3c24xx/include/mach/io.h | 209 +++----------------
arch/arm/plat-samsung/include/plat/map-s3c.h | 10 +-
2 files changed, 26 insertions(+), 193 deletions(-)
diff --git a/arch/arm/mach-s3c24xx/include/mach/io.h b/arch/arm/mach-s3c24xx/include/mach/io.h
index f960e6d10114..3e8bff26cdd5 100644
--- a/arch/arm/mach-s3c24xx/include/mach/io.h
+++ b/arch/arm/mach-s3c24xx/include/mach/io.h
@@ -12,201 +12,40 @@
#include <mach/hardware.h>
-#define IO_SPACE_LIMIT 0xffffffff
/*
- * We use two different types of addressing - PC style addresses, and ARM
- * addresses. PC style accesses the PC hardware with the normal PC IO
- * addresses, eg 0x3f8 for serial#1. ARM addresses are above A28
- * and are translated to the start of IO. Note that all addresses are
- * not shifted left!
+ * ISA style IO, for each machine to sort out mappings for,
+ * if it implements it. We reserve two 16M regions for ISA,
+ * so the PC/104 can use separate addresses for 8-bit and
+ * 16-bit port I/O.
*/
+#define PCIO_BASE S3C_ADDR(0x02000000)
+#define IO_SPACE_LIMIT 0x00ffffff
+#define S3C24XX_VA_ISA_WORD (PCIO_BASE)
+#define S3C24XX_VA_ISA_BYTE (PCIO_BASE + 0x01000000)
-#define __PORT_PCIO(x) ((x) < (1<<28))
+#ifdef CONFIG_ISA
-#define PCIO_BASE (S3C24XX_VA_ISA_WORD)
-#define PCIO_BASE_b (S3C24XX_VA_ISA_BYTE)
-#define PCIO_BASE_w (S3C24XX_VA_ISA_WORD)
-#define PCIO_BASE_l (S3C24XX_VA_ISA_WORD)
-/*
- * Dynamic IO functions - let the compiler
- * optimize the expressions
- */
-
-#define DECLARE_DYN_OUT(sz,fnsuffix,instr) \
-static inline void __out##fnsuffix (unsigned int val, unsigned int port) \
-{ \
- unsigned long temp; \
- __asm__ __volatile__( \
- "cmp %2, #(1<<28)\n\t" \
- "mov %0, %2\n\t" \
- "addcc %0, %0, %3\n\t" \
- "str" instr " %1, [%0, #0 ] @ out" #fnsuffix \
- : "=&r" (temp) \
- : "r" (val), "r" (port), "Ir" (PCIO_BASE_##fnsuffix) \
- : "cc"); \
-}
-
-
-#define DECLARE_DYN_IN(sz,fnsuffix,instr) \
-static inline unsigned sz __in##fnsuffix (unsigned int port) \
-{ \
- unsigned long temp, value; \
- __asm__ __volatile__( \
- "cmp %2, #(1<<28)\n\t" \
- "mov %0, %2\n\t" \
- "addcc %0, %0, %3\n\t" \
- "ldr" instr " %1, [%0, #0 ] @ in" #fnsuffix \
- : "=&r" (temp), "=r" (value) \
- : "r" (port), "Ir" (PCIO_BASE_##fnsuffix) \
- : "cc"); \
- return (unsigned sz)value; \
-}
+#define inb(p) readb(S3C24XX_VA_ISA_BYTE + (p))
+#define inw(p) readw(S3C24XX_VA_ISA_WORD + (p))
+#define inl(p) readl(S3C24XX_VA_ISA_WORD + (p))
-static inline void __iomem *__ioaddr (unsigned long port)
-{
- return __PORT_PCIO(port) ? (PCIO_BASE + port) : (void __iomem *)port;
-}
+#define outb(v,p) writeb((v), S3C24XX_VA_ISA_BYTE + (p))
+#define outw(v,p) writew((v), S3C24XX_VA_ISA_WORD + (p))
+#define outl(v,p) writel((v), S3C24XX_VA_ISA_WORD + (p))
-#define DECLARE_IO(sz,fnsuffix,instr) \
- DECLARE_DYN_IN(sz,fnsuffix,instr) \
- DECLARE_DYN_OUT(sz,fnsuffix,instr)
+#define insb(p,d,l) readsb(S3C24XX_VA_ISA_BYTE + (p),d,l)
+#define insw(p,d,l) readsw(S3C24XX_VA_ISA_WORD + (p),d,l)
+#define insl(p,d,l) readsl(S3C24XX_VA_ISA_WORD + (p),d,l)
-DECLARE_IO(char,b,"b")
-DECLARE_IO(short,w,"h")
-DECLARE_IO(int,l,"")
+#define outsb(p,d,l) writesb(S3C24XX_VA_ISA_BYTE + (p),d,l)
+#define outsw(p,d,l) writesw(S3C24XX_VA_ISA_WORD + (p),d,l)
+#define outsl(p,d,l) writesl(S3C24XX_VA_ISA_WORD + (p),d,l)
-#undef DECLARE_IO
-#undef DECLARE_DYN_IN
-
-/*
- * Constant address IO functions
- *
- * These have to be macros for the 'J' constraint to work -
- * +/-4096 immediate operand.
- */
-#define __outbc(value,port) \
-({ \
- if (__PORT_PCIO((port))) \
- __asm__ __volatile__( \
- "strb %0, [%1, %2] @ outbc" \
- : : "r" (value), "r" (PCIO_BASE), "Jr" ((port))); \
- else \
- __asm__ __volatile__( \
- "strb %0, [%1, #0] @ outbc" \
- : : "r" (value), "r" ((port))); \
-})
+#else
-#define __inbc(port) \
-({ \
- unsigned char result; \
- if (__PORT_PCIO((port))) \
- __asm__ __volatile__( \
- "ldrb %0, [%1, %2] @ inbc" \
- : "=r" (result) : "r" (PCIO_BASE), "Jr" ((port))); \
- else \
- __asm__ __volatile__( \
- "ldrb %0, [%1, #0] @ inbc" \
- : "=r" (result) : "r" ((port))); \
- result; \
-})
+#define __io(x) (PCIO_BASE + (x))
-#define __outwc(value,port) \
-({ \
- unsigned long v = value; \
- if (__PORT_PCIO((port))) { \
- if ((port) < 256 && (port) > -256) \
- __asm__ __volatile__( \
- "strh %0, [%1, %2] @ outwc" \
- : : "r" (v), "r" (PCIO_BASE), "Jr" ((port))); \
- else if ((port) > 0) \
- __asm__ __volatile__( \
- "strh %0, [%1, %2] @ outwc" \
- : : "r" (v), \
- "r" (PCIO_BASE + ((port) & ~0xff)), \
- "Jr" (((port) & 0xff))); \
- else \
- __asm__ __volatile__( \
- "strh %0, [%1, #0] @ outwc" \
- : : "r" (v), \
- "r" (PCIO_BASE + (port))); \
- } else \
- __asm__ __volatile__( \
- "strh %0, [%1, #0] @ outwc" \
- : : "r" (v), "r" ((port))); \
-})
-
-#define __inwc(port) \
-({ \
- unsigned short result; \
- if (__PORT_PCIO((port))) { \
- if ((port) < 256 && (port) > -256 ) \
- __asm__ __volatile__( \
- "ldrh %0, [%1, %2] @ inwc" \
- : "=r" (result) \
- : "r" (PCIO_BASE), \
- "Jr" ((port))); \
- else if ((port) > 0) \
- __asm__ __volatile__( \
- "ldrh %0, [%1, %2] @ inwc" \
- : "=r" (result) \
- : "r" (PCIO_BASE + ((port) & ~0xff)), \
- "Jr" (((port) & 0xff))); \
- else \
- __asm__ __volatile__( \
- "ldrh %0, [%1, #0] @ inwc" \
- : "=r" (result) \
- : "r" (PCIO_BASE + ((port)))); \
- } else \
- __asm__ __volatile__( \
- "ldrh %0, [%1, #0] @ inwc" \
- : "=r" (result) : "r" ((port))); \
- result; \
-})
-
-#define __outlc(value,port) \
-({ \
- unsigned long v = value; \
- if (__PORT_PCIO((port))) \
- __asm__ __volatile__( \
- "str %0, [%1, %2] @ outlc" \
- : : "r" (v), "r" (PCIO_BASE), "Jr" ((port))); \
- else \
- __asm__ __volatile__( \
- "str %0, [%1, #0] @ outlc" \
- : : "r" (v), "r" ((port))); \
-})
-
-#define __inlc(port) \
-({ \
- unsigned long result; \
- if (__PORT_PCIO((port))) \
- __asm__ __volatile__( \
- "ldr %0, [%1, %2] @ inlc" \
- : "=r" (result) : "r" (PCIO_BASE), "Jr" ((port))); \
- else \
- __asm__ __volatile__( \
- "ldr %0, [%1, #0] @ inlc" \
- : "=r" (result) : "r" ((port))); \
- result; \
-})
-
-#define __ioaddrc(port) ((__PORT_PCIO(port) ? PCIO_BASE + (port) : (void __iomem *)0 + (port)))
-
-#define inb(p) (__builtin_constant_p((p)) ? __inbc(p) : __inb(p))
-#define inw(p) (__builtin_constant_p((p)) ? __inwc(p) : __inw(p))
-#define inl(p) (__builtin_constant_p((p)) ? __inlc(p) : __inl(p))
-#define outb(v,p) (__builtin_constant_p((p)) ? __outbc(v,p) : __outb(v,p))
-#define outw(v,p) (__builtin_constant_p((p)) ? __outwc(v,p) : __outw(v,p))
-#define outl(v,p) (__builtin_constant_p((p)) ? __outlc(v,p) : __outl(v,p))
-#define __ioaddr(p) (__builtin_constant_p((p)) ? __ioaddr(p) : __ioaddrc(p))
-
-#define insb(p,d,l) __raw_readsb(__ioaddr(p),d,l)
-#define insw(p,d,l) __raw_readsw(__ioaddr(p),d,l)
-#define insl(p,d,l) __raw_readsl(__ioaddr(p),d,l)
-
-#define outsb(p,d,l) __raw_writesb(__ioaddr(p),d,l)
-#define outsw(p,d,l) __raw_writesw(__ioaddr(p),d,l)
-#define outsl(p,d,l) __raw_writesl(__ioaddr(p),d,l)
+#endif
#endif
diff --git a/arch/arm/plat-samsung/include/plat/map-s3c.h b/arch/arm/plat-samsung/include/plat/map-s3c.h
index 4244acbf4b65..bf247d836684 100644
--- a/arch/arm/plat-samsung/include/plat/map-s3c.h
+++ b/arch/arm/plat-samsung/include/plat/map-s3c.h
@@ -9,6 +9,8 @@
#ifndef __ASM_PLAT_MAP_S3C_H
#define __ASM_PLAT_MAP_S3C_H __FILE__
+#include <mach/map.h>
+
#define S3C24XX_VA_IRQ S3C_VA_IRQ
#define S3C24XX_VA_MEMCTRL S3C_VA_MEM
#define S3C24XX_VA_UART S3C_VA_UART
@@ -45,16 +47,8 @@
#define S3C_VA_USB_HSPHY S3C64XX_VA_USB_HSPHY
-/*
- * ISA style IO, for each machine to sort out mappings for,
- * if it implements it. We reserve two 16M regions for ISA.
- */
-
#define S3C2410_ADDR(x) S3C_ADDR(x)
-#define S3C24XX_VA_ISA_WORD S3C2410_ADDR(0x02000000)
-#define S3C24XX_VA_ISA_BYTE S3C2410_ADDR(0x03000000)
-
/* deal with the registers that move under the 2412/2413 */
#if defined(CONFIG_CPU_S3C2412)
--
2.20.0
next prev parent reply other threads:[~2019-10-10 20:31 UTC|newest]
Thread overview: 88+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-10 20:28 [PATCH 00/36] ARM: samsung platform cleanup Arnd Bergmann
2019-10-10 20:29 ` [PATCH 01/36] ARM: samsung: make S3C24XX_MISCCR access indirect Arnd Bergmann
2019-10-10 20:29 ` Arnd Bergmann [this message]
2019-10-10 20:29 ` [PATCH 03/36] usb: gadget: s3c: use platform resources Arnd Bergmann
2019-10-23 10:06 ` Krzysztof Kozlowski
2019-10-23 12:46 ` Krzysztof Kozlowski
2019-10-23 13:26 ` Arnd Bergmann
2019-10-10 20:29 ` [PATCH 04/36] usb: gadget: s3c-hsudc: remove platform header dependency Arnd Bergmann
2019-10-23 10:09 ` Krzysztof Kozlowski
2019-10-23 12:21 ` Arnd Bergmann
2019-10-10 20:29 ` [PATCH 05/36] ARM: samsung: make pm-debug platform independent Arnd Bergmann
2019-10-23 10:27 ` Krzysztof Kozlowski
2019-10-23 12:13 ` Arnd Bergmann
2019-10-10 20:29 ` [PATCH 06/36] ARM: samsung: move CONFIG_DEBUG_S3C_UART to Kconfig.debug Arnd Bergmann
2019-10-23 10:12 ` Krzysztof Kozlowski
2019-10-23 12:22 ` Arnd Bergmann
2019-10-10 20:29 ` [PATCH 07/36] ARM: exynos: use private samsung_cpu_id copy Arnd Bergmann
2019-10-23 10:54 ` Krzysztof Kozlowski
2019-10-23 12:37 ` Arnd Bergmann
2019-10-10 20:29 ` [PATCH 08/36] ARM: exynos: stop selecting PLAT_SAMSUNG Arnd Bergmann
2019-10-15 14:12 ` Ulf Hansson
2019-10-23 10:57 ` Krzysztof Kozlowski
2019-10-23 12:43 ` Arnd Bergmann
2019-10-10 20:29 ` [PATCH 09/36] ARM: samsung: move pm check code to drivers/soc Arnd Bergmann
2019-10-23 11:32 ` Krzysztof Kozlowski
2019-10-23 12:45 ` Arnd Bergmann
2019-10-10 20:29 ` [PATCH 10/36] ARM: s5pv210: use private pm save/restore Arnd Bergmann
2019-10-23 11:55 ` Krzysztof Kozlowski
2019-10-23 13:12 ` Arnd Bergmann
2019-10-10 20:29 ` [PATCH 11/36] ARM: s5pv210: split from plat-samsung Arnd Bergmann
2019-10-11 5:51 ` Uwe Kleine-König
2019-10-22 14:01 ` Arnd Bergmann
2019-10-22 15:53 ` Uwe Kleine-König
2019-10-22 16:20 ` Arnd Bergmann
2019-10-15 14:13 ` Ulf Hansson
2019-10-15 14:23 ` Thierry Reding
2019-10-23 12:14 ` Krzysztof Kozlowski
2019-10-23 13:17 ` Arnd Bergmann
2019-10-23 14:12 ` Krzysztof Kozlowski
2019-10-10 20:29 ` [PATCH 12/36] ARM: s3c64xx: remove mach/hardware.h Arnd Bergmann
2019-10-16 10:09 ` Charles Keepax
2019-10-10 20:29 ` [PATCH 13/36] ARM: s3c: move regs-spi.h into spi driver Arnd Bergmann
2019-10-23 12:32 ` Krzysztof Kozlowski
2019-10-23 13:21 ` Arnd Bergmann
2019-10-10 20:29 ` [PATCH 14/36] ARM: s3c: move irqchip driver back into platform Arnd Bergmann
2019-10-10 20:29 ` [PATCH 15/36] ARM: s3c: adc: move header to linux/soc/samsung Arnd Bergmann
2019-10-10 22:20 ` Guenter Roeck
2019-10-10 22:29 ` Dmitry Torokhov
2019-10-10 22:44 ` Sebastian Reichel
2019-10-23 12:37 ` Krzysztof Kozlowski
2019-10-23 13:23 ` Arnd Bergmann
2019-10-10 20:30 ` [PATCH 16/36] ARM: s3c: move spi fiq handler into platform Arnd Bergmann
2019-10-10 20:30 ` [PATCH 17/36] ARM: s3c: h1940-audio: turn into platform driver Arnd Bergmann
2019-10-10 20:30 ` [PATCH 18/36] ARM: s3c: gta02-audio: " Arnd Bergmann
2019-10-10 20:30 ` [PATCH 19/36] ARM: s3c: rx1950: " Arnd Bergmann
2019-10-10 20:30 ` [PATCH 20/36] ASoC: samsung: s3c2412-i2s: avoid hardcoded S3C2410_PA_IIS Arnd Bergmann
2019-10-11 10:50 ` Mark Brown
2019-10-10 20:30 ` [PATCH 21/36] ARM: s3c: move iis pinctrl config into boards Arnd Bergmann
2019-10-23 12:50 ` Krzysztof Kozlowski
2019-10-23 13:29 ` Arnd Bergmann
2019-10-10 20:30 ` [PATCH 22/36] ARM: s3c: leds: move setpull() calls into board files Arnd Bergmann
2019-10-10 20:30 ` [PATCH 23/36] ARM: s3c: move s3cmci pinctrl handling " Arnd Bergmann
2019-10-15 14:12 ` Ulf Hansson
2019-10-16 13:12 ` Linus Walleij
2019-10-10 20:30 ` [PATCH 24/36] ARM: s3c: include mach/irqs.h where needed Arnd Bergmann
2019-10-10 20:30 ` [PATCH 25/36] ARM: s3c: spi: avoid hardcoding fiq number in driver Arnd Bergmann
2019-10-10 20:30 ` [PATCH 26/36] ARM: s3c: bast: avoid irq_desc array usage Arnd Bergmann
2019-10-10 20:30 ` [PATCH 27/36] ARM: s3c: fix mmc gpio lookup tables Arnd Bergmann
2019-10-10 20:30 ` [PATCH 28/36] fbdev: s3c2410fb: remove mach header dependency Arnd Bergmann
2019-10-23 13:13 ` Krzysztof Kozlowski
2019-10-23 13:35 ` Arnd Bergmann
2019-10-10 20:30 ` [PATCH 29/36] ARM: s3c: cpufreq: split out registers Arnd Bergmann
2019-10-10 20:30 ` [PATCH 30/36] ARM: s3c: remove cpufreq header dependencies Arnd Bergmann
2019-10-23 13:38 ` Krzysztof Kozlowski
2019-10-23 13:46 ` Arnd Bergmann
2019-10-10 20:30 ` [PATCH 31/36] ARM: s3c: cpufreq: use global s3c2412_cpufreq_setrefresh Arnd Bergmann
2019-10-23 13:44 ` Krzysztof Kozlowski
2019-10-23 13:57 ` Arnd Bergmann
2019-10-10 20:30 ` [PATCH 32/36] ARM: s3c: iotiming: make functions static Arnd Bergmann
2019-10-10 20:30 ` [PATCH 33/36] ARM: s3c: move low-level clk reg access into platform code Arnd Bergmann
2019-10-23 13:49 ` Krzysztof Kozlowski
2019-10-23 13:54 ` Arnd Bergmann
2019-10-10 20:30 ` [PATCH 34/36] ARM: s3c: stop including mach/hardware.h from mach/io.h Arnd Bergmann
2019-10-10 21:02 ` Russell King - ARM Linux admin
2019-10-10 21:53 ` Arnd Bergmann
2019-10-15 14:52 ` [PATCH 01/36] ARM: samsung: make S3C24XX_MISCCR access indirect Tomasz Figa
2019-10-23 13:10 ` [PATCH 00/36] ARM: samsung platform cleanup Krzysztof Kozlowski
2019-10-23 13:39 ` Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191010203043.1241612-2-arnd@arndb.de \
--to=arnd@arndb.de \
--cc=kgene@kernel.org \
--cc=krzk@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).