18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *  linux/arch/arm/mach-ebsa110/isamem.c
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci *  Copyright (C) 2001 Russell King
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Perform "ISA" memory and IO accesses.  The EBSA110 has some "peculiarities"
88c2ecf20Sopenharmony_ci * in the way it handles accesses to odd IO ports on 16-bit devices.  These
98c2ecf20Sopenharmony_ci * devices have their D0-D15 lines connected to the processors D0-D15 lines.
108c2ecf20Sopenharmony_ci * Since they expect all byte IO operations to be performed on D0-D7, and the
118c2ecf20Sopenharmony_ci * StrongARM expects to transfer the byte to these odd addresses on D8-D15,
128c2ecf20Sopenharmony_ci * we must use a trick to get the required behaviour.
138c2ecf20Sopenharmony_ci *
148c2ecf20Sopenharmony_ci * The trick employed here is to use long word stores to odd address -1.  The
158c2ecf20Sopenharmony_ci * glue logic picks this up as a "trick" access, and asserts the LSB of the
168c2ecf20Sopenharmony_ci * peripherals address bus, thereby accessing the odd IO port.  Meanwhile, the
178c2ecf20Sopenharmony_ci * StrongARM transfers its data on D0-D7 as expected.
188c2ecf20Sopenharmony_ci *
198c2ecf20Sopenharmony_ci * Things get more interesting on the pass-1 EBSA110 - the PCMCIA controller
208c2ecf20Sopenharmony_ci * wiring was screwed in such a way that it had limited memory space access.
218c2ecf20Sopenharmony_ci * Luckily, the work-around for this is not too horrible.  See
228c2ecf20Sopenharmony_ci * __isamem_convert_addr for the details.
238c2ecf20Sopenharmony_ci */
248c2ecf20Sopenharmony_ci#include <linux/module.h>
258c2ecf20Sopenharmony_ci#include <linux/kernel.h>
268c2ecf20Sopenharmony_ci#include <linux/types.h>
278c2ecf20Sopenharmony_ci#include <linux/io.h>
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci#include <mach/hardware.h>
308c2ecf20Sopenharmony_ci#include <asm/page.h>
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_cistatic void __iomem *__isamem_convert_addr(const volatile void __iomem *addr)
338c2ecf20Sopenharmony_ci{
348c2ecf20Sopenharmony_ci	u32 ret, a = (u32 __force) addr;
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci	/*
378c2ecf20Sopenharmony_ci	 * The PCMCIA controller is wired up as follows:
388c2ecf20Sopenharmony_ci	 *        +---------+---------+---------+---------+---------+---------+
398c2ecf20Sopenharmony_ci	 * PCMCIA | 2 2 2 2 | 1 1 1 1 | 1 1 1 1 | 1 1     |         |         |
408c2ecf20Sopenharmony_ci	 *        | 3 2 1 0 | 9 8 7 6 | 5 4 3 2 | 1 0 9 8 | 7 6 5 4 | 3 2 1 0 |
418c2ecf20Sopenharmony_ci	 *        +---------+---------+---------+---------+---------+---------+
428c2ecf20Sopenharmony_ci	 *  CPU   | 2 2 2 2 | 2 1 1 1 | 1 1 1 1 | 1 1 1   |         |         |
438c2ecf20Sopenharmony_ci	 *        | 4 3 2 1 | 0 9 9 8 | 7 6 5 4 | 3 2 0 9 | 8 7 6 5 | 4 3 2 x |
448c2ecf20Sopenharmony_ci	 *        +---------+---------+---------+---------+---------+---------+
458c2ecf20Sopenharmony_ci	 *
468c2ecf20Sopenharmony_ci	 * This means that we can access PCMCIA regions as follows:
478c2ecf20Sopenharmony_ci	 *	0x*10000 -> 0x*1ffff
488c2ecf20Sopenharmony_ci	 *	0x*70000 -> 0x*7ffff
498c2ecf20Sopenharmony_ci	 *	0x*90000 -> 0x*9ffff
508c2ecf20Sopenharmony_ci	 *	0x*f0000 -> 0x*fffff
518c2ecf20Sopenharmony_ci	 */
528c2ecf20Sopenharmony_ci	ret  = (a & 0xf803fe) << 1;
538c2ecf20Sopenharmony_ci	ret |= (a & 0x03fc00) << 2;
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci	ret += 0xe8000000;
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci	if ((a & 0x20000) == (a & 0x40000) >> 1)
588c2ecf20Sopenharmony_ci		return (void __iomem *)ret;
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci	BUG();
618c2ecf20Sopenharmony_ci	return NULL;
628c2ecf20Sopenharmony_ci}
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci/*
658c2ecf20Sopenharmony_ci * read[bwl] and write[bwl]
668c2ecf20Sopenharmony_ci */
678c2ecf20Sopenharmony_ciu8 __readb(const volatile void __iomem *addr)
688c2ecf20Sopenharmony_ci{
698c2ecf20Sopenharmony_ci	void __iomem *a = __isamem_convert_addr(addr);
708c2ecf20Sopenharmony_ci	u32 ret;
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci	if ((unsigned long)addr & 1)
738c2ecf20Sopenharmony_ci		ret = __raw_readl(a);
748c2ecf20Sopenharmony_ci	else
758c2ecf20Sopenharmony_ci		ret = __raw_readb(a);
768c2ecf20Sopenharmony_ci	return ret;
778c2ecf20Sopenharmony_ci}
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ciu16 __readw(const volatile void __iomem *addr)
808c2ecf20Sopenharmony_ci{
818c2ecf20Sopenharmony_ci	void __iomem *a = __isamem_convert_addr(addr);
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci	if ((unsigned long)addr & 1)
848c2ecf20Sopenharmony_ci		BUG();
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci	return __raw_readw(a);
878c2ecf20Sopenharmony_ci}
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ciu32 __readl(const volatile void __iomem *addr)
908c2ecf20Sopenharmony_ci{
918c2ecf20Sopenharmony_ci	void __iomem *a = __isamem_convert_addr(addr);
928c2ecf20Sopenharmony_ci	u32 ret;
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci	if ((unsigned long)addr & 3)
958c2ecf20Sopenharmony_ci		BUG();
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci	ret = __raw_readw(a);
988c2ecf20Sopenharmony_ci	ret |= __raw_readw(a + 4) << 16;
998c2ecf20Sopenharmony_ci	return ret;
1008c2ecf20Sopenharmony_ci}
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__readb);
1038c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__readw);
1048c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__readl);
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_civoid readsw(const volatile void __iomem *addr, void *data, int len)
1078c2ecf20Sopenharmony_ci{
1088c2ecf20Sopenharmony_ci	void __iomem *a = __isamem_convert_addr(addr);
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci	BUG_ON((unsigned long)addr & 1);
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci	__raw_readsw(a, data, len);
1138c2ecf20Sopenharmony_ci}
1148c2ecf20Sopenharmony_ciEXPORT_SYMBOL(readsw);
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_civoid readsl(const volatile void __iomem *addr, void *data, int len)
1178c2ecf20Sopenharmony_ci{
1188c2ecf20Sopenharmony_ci	void __iomem *a = __isamem_convert_addr(addr);
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci	BUG_ON((unsigned long)addr & 3);
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_ci	__raw_readsl(a, data, len);
1238c2ecf20Sopenharmony_ci}
1248c2ecf20Sopenharmony_ciEXPORT_SYMBOL(readsl);
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_civoid __writeb(u8 val, volatile void __iomem *addr)
1278c2ecf20Sopenharmony_ci{
1288c2ecf20Sopenharmony_ci	void __iomem *a = __isamem_convert_addr(addr);
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ci	if ((unsigned long)addr & 1)
1318c2ecf20Sopenharmony_ci		__raw_writel(val, a);
1328c2ecf20Sopenharmony_ci	else
1338c2ecf20Sopenharmony_ci		__raw_writeb(val, a);
1348c2ecf20Sopenharmony_ci}
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_civoid __writew(u16 val, volatile void __iomem *addr)
1378c2ecf20Sopenharmony_ci{
1388c2ecf20Sopenharmony_ci	void __iomem *a = __isamem_convert_addr(addr);
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ci	if ((unsigned long)addr & 1)
1418c2ecf20Sopenharmony_ci		BUG();
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci	__raw_writew(val, a);
1448c2ecf20Sopenharmony_ci}
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_civoid __writel(u32 val, volatile void __iomem *addr)
1478c2ecf20Sopenharmony_ci{
1488c2ecf20Sopenharmony_ci	void __iomem *a = __isamem_convert_addr(addr);
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci	if ((unsigned long)addr & 3)
1518c2ecf20Sopenharmony_ci		BUG();
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ci	__raw_writew(val, a);
1548c2ecf20Sopenharmony_ci	__raw_writew(val >> 16, a + 4);
1558c2ecf20Sopenharmony_ci}
1568c2ecf20Sopenharmony_ci
1578c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__writeb);
1588c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__writew);
1598c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__writel);
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_civoid writesw(volatile void __iomem *addr, const void *data, int len)
1628c2ecf20Sopenharmony_ci{
1638c2ecf20Sopenharmony_ci	void __iomem *a = __isamem_convert_addr(addr);
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_ci	BUG_ON((unsigned long)addr & 1);
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_ci	__raw_writesw(a, data, len);
1688c2ecf20Sopenharmony_ci}
1698c2ecf20Sopenharmony_ciEXPORT_SYMBOL(writesw);
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_civoid writesl(volatile void __iomem *addr, const void *data, int len)
1728c2ecf20Sopenharmony_ci{
1738c2ecf20Sopenharmony_ci	void __iomem *a = __isamem_convert_addr(addr);
1748c2ecf20Sopenharmony_ci
1758c2ecf20Sopenharmony_ci	BUG_ON((unsigned long)addr & 3);
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_ci	__raw_writesl(a, data, len);
1788c2ecf20Sopenharmony_ci}
1798c2ecf20Sopenharmony_ciEXPORT_SYMBOL(writesl);
1808c2ecf20Sopenharmony_ci
1818c2ecf20Sopenharmony_ci/*
1828c2ecf20Sopenharmony_ci * The EBSA110 has a weird "ISA IO" region:
1838c2ecf20Sopenharmony_ci *
1848c2ecf20Sopenharmony_ci * Region 0 (addr = 0xf0000000 + io << 2)
1858c2ecf20Sopenharmony_ci * --------------------------------------------------------
1868c2ecf20Sopenharmony_ci * Physical region	IO region
1878c2ecf20Sopenharmony_ci * f0000fe0 - f0000ffc	3f8 - 3ff  ttyS0
1888c2ecf20Sopenharmony_ci * f0000e60 - f0000e64	398 - 399
1898c2ecf20Sopenharmony_ci * f0000de0 - f0000dfc	378 - 37f  lp0
1908c2ecf20Sopenharmony_ci * f0000be0 - f0000bfc	2f8 - 2ff  ttyS1
1918c2ecf20Sopenharmony_ci *
1928c2ecf20Sopenharmony_ci * Region 1 (addr = 0xf0000000 + (io & ~1) << 1 + (io & 1))
1938c2ecf20Sopenharmony_ci * --------------------------------------------------------
1948c2ecf20Sopenharmony_ci * Physical region	IO region
1958c2ecf20Sopenharmony_ci * f00014f1             a79        pnp write data
1968c2ecf20Sopenharmony_ci * f00007c0 - f00007c1	3e0 - 3e1  pcmcia
1978c2ecf20Sopenharmony_ci * f00004f1		279        pnp address
1988c2ecf20Sopenharmony_ci * f0000440 - f000046c  220 - 236  eth0
1998c2ecf20Sopenharmony_ci * f0000405		203        pnp read data
2008c2ecf20Sopenharmony_ci */
2018c2ecf20Sopenharmony_ci#define SUPERIO_PORT(p) \
2028c2ecf20Sopenharmony_ci	(((p) >> 3) == (0x3f8 >> 3) || \
2038c2ecf20Sopenharmony_ci	 ((p) >> 3) == (0x2f8 >> 3) || \
2048c2ecf20Sopenharmony_ci	 ((p) >> 3) == (0x378 >> 3))
2058c2ecf20Sopenharmony_ci
2068c2ecf20Sopenharmony_ci/*
2078c2ecf20Sopenharmony_ci * We're addressing an 8 or 16-bit peripheral which tranfers
2088c2ecf20Sopenharmony_ci * odd addresses on the low ISA byte lane.
2098c2ecf20Sopenharmony_ci */
2108c2ecf20Sopenharmony_ciu8 __inb8(unsigned int port)
2118c2ecf20Sopenharmony_ci{
2128c2ecf20Sopenharmony_ci	u32 ret;
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ci	/*
2158c2ecf20Sopenharmony_ci	 * The SuperIO registers use sane addressing techniques...
2168c2ecf20Sopenharmony_ci	 */
2178c2ecf20Sopenharmony_ci	if (SUPERIO_PORT(port))
2188c2ecf20Sopenharmony_ci		ret = __raw_readb((void __iomem *)ISAIO_BASE + (port << 2));
2198c2ecf20Sopenharmony_ci	else {
2208c2ecf20Sopenharmony_ci		void __iomem *a = (void __iomem *)ISAIO_BASE + ((port & ~1) << 1);
2218c2ecf20Sopenharmony_ci
2228c2ecf20Sopenharmony_ci		/*
2238c2ecf20Sopenharmony_ci		 * Shame nothing else does
2248c2ecf20Sopenharmony_ci		 */
2258c2ecf20Sopenharmony_ci		if (port & 1)
2268c2ecf20Sopenharmony_ci			ret = __raw_readl(a);
2278c2ecf20Sopenharmony_ci		else
2288c2ecf20Sopenharmony_ci			ret = __raw_readb(a);
2298c2ecf20Sopenharmony_ci	}
2308c2ecf20Sopenharmony_ci	return ret;
2318c2ecf20Sopenharmony_ci}
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_ci/*
2348c2ecf20Sopenharmony_ci * We're addressing a 16-bit peripheral which transfers odd
2358c2ecf20Sopenharmony_ci * addresses on the high ISA byte lane.
2368c2ecf20Sopenharmony_ci */
2378c2ecf20Sopenharmony_ciu8 __inb16(unsigned int port)
2388c2ecf20Sopenharmony_ci{
2398c2ecf20Sopenharmony_ci	unsigned int offset;
2408c2ecf20Sopenharmony_ci
2418c2ecf20Sopenharmony_ci	/*
2428c2ecf20Sopenharmony_ci	 * The SuperIO registers use sane addressing techniques...
2438c2ecf20Sopenharmony_ci	 */
2448c2ecf20Sopenharmony_ci	if (SUPERIO_PORT(port))
2458c2ecf20Sopenharmony_ci		offset = port << 2;
2468c2ecf20Sopenharmony_ci	else
2478c2ecf20Sopenharmony_ci		offset = (port & ~1) << 1 | (port & 1);
2488c2ecf20Sopenharmony_ci
2498c2ecf20Sopenharmony_ci	return __raw_readb((void __iomem *)ISAIO_BASE + offset);
2508c2ecf20Sopenharmony_ci}
2518c2ecf20Sopenharmony_ci
2528c2ecf20Sopenharmony_ciu16 __inw(unsigned int port)
2538c2ecf20Sopenharmony_ci{
2548c2ecf20Sopenharmony_ci	unsigned int offset;
2558c2ecf20Sopenharmony_ci
2568c2ecf20Sopenharmony_ci	/*
2578c2ecf20Sopenharmony_ci	 * The SuperIO registers use sane addressing techniques...
2588c2ecf20Sopenharmony_ci	 */
2598c2ecf20Sopenharmony_ci	if (SUPERIO_PORT(port))
2608c2ecf20Sopenharmony_ci		offset = port << 2;
2618c2ecf20Sopenharmony_ci	else {
2628c2ecf20Sopenharmony_ci		offset = port << 1;
2638c2ecf20Sopenharmony_ci		BUG_ON(port & 1);
2648c2ecf20Sopenharmony_ci	}
2658c2ecf20Sopenharmony_ci	return __raw_readw((void __iomem *)ISAIO_BASE + offset);
2668c2ecf20Sopenharmony_ci}
2678c2ecf20Sopenharmony_ci
2688c2ecf20Sopenharmony_ci/*
2698c2ecf20Sopenharmony_ci * Fake a 32-bit read with two 16-bit reads.  Needed for 3c589.
2708c2ecf20Sopenharmony_ci */
2718c2ecf20Sopenharmony_ciu32 __inl(unsigned int port)
2728c2ecf20Sopenharmony_ci{
2738c2ecf20Sopenharmony_ci	void __iomem *a;
2748c2ecf20Sopenharmony_ci
2758c2ecf20Sopenharmony_ci	if (SUPERIO_PORT(port) || port & 3)
2768c2ecf20Sopenharmony_ci		BUG();
2778c2ecf20Sopenharmony_ci
2788c2ecf20Sopenharmony_ci	a = (void __iomem *)ISAIO_BASE + ((port & ~1) << 1);
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_ci	return __raw_readw(a) | __raw_readw(a + 4) << 16;
2818c2ecf20Sopenharmony_ci}
2828c2ecf20Sopenharmony_ci
2838c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__inb8);
2848c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__inb16);
2858c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__inw);
2868c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__inl);
2878c2ecf20Sopenharmony_ci
2888c2ecf20Sopenharmony_civoid __outb8(u8 val, unsigned int port)
2898c2ecf20Sopenharmony_ci{
2908c2ecf20Sopenharmony_ci	/*
2918c2ecf20Sopenharmony_ci	 * The SuperIO registers use sane addressing techniques...
2928c2ecf20Sopenharmony_ci	 */
2938c2ecf20Sopenharmony_ci	if (SUPERIO_PORT(port))
2948c2ecf20Sopenharmony_ci		__raw_writeb(val, (void __iomem *)ISAIO_BASE + (port << 2));
2958c2ecf20Sopenharmony_ci	else {
2968c2ecf20Sopenharmony_ci		void __iomem *a = (void __iomem *)ISAIO_BASE + ((port & ~1) << 1);
2978c2ecf20Sopenharmony_ci
2988c2ecf20Sopenharmony_ci		/*
2998c2ecf20Sopenharmony_ci		 * Shame nothing else does
3008c2ecf20Sopenharmony_ci		 */
3018c2ecf20Sopenharmony_ci		if (port & 1)
3028c2ecf20Sopenharmony_ci			__raw_writel(val, a);
3038c2ecf20Sopenharmony_ci		else
3048c2ecf20Sopenharmony_ci			__raw_writeb(val, a);
3058c2ecf20Sopenharmony_ci	}
3068c2ecf20Sopenharmony_ci}
3078c2ecf20Sopenharmony_ci
3088c2ecf20Sopenharmony_civoid __outb16(u8 val, unsigned int port)
3098c2ecf20Sopenharmony_ci{
3108c2ecf20Sopenharmony_ci	unsigned int offset;
3118c2ecf20Sopenharmony_ci
3128c2ecf20Sopenharmony_ci	/*
3138c2ecf20Sopenharmony_ci	 * The SuperIO registers use sane addressing techniques...
3148c2ecf20Sopenharmony_ci	 */
3158c2ecf20Sopenharmony_ci	if (SUPERIO_PORT(port))
3168c2ecf20Sopenharmony_ci		offset = port << 2;
3178c2ecf20Sopenharmony_ci	else
3188c2ecf20Sopenharmony_ci		offset = (port & ~1) << 1 | (port & 1);
3198c2ecf20Sopenharmony_ci
3208c2ecf20Sopenharmony_ci	__raw_writeb(val, (void __iomem *)ISAIO_BASE + offset);
3218c2ecf20Sopenharmony_ci}
3228c2ecf20Sopenharmony_ci
3238c2ecf20Sopenharmony_civoid __outw(u16 val, unsigned int port)
3248c2ecf20Sopenharmony_ci{
3258c2ecf20Sopenharmony_ci	unsigned int offset;
3268c2ecf20Sopenharmony_ci
3278c2ecf20Sopenharmony_ci	/*
3288c2ecf20Sopenharmony_ci	 * The SuperIO registers use sane addressing techniques...
3298c2ecf20Sopenharmony_ci	 */
3308c2ecf20Sopenharmony_ci	if (SUPERIO_PORT(port))
3318c2ecf20Sopenharmony_ci		offset = port << 2;
3328c2ecf20Sopenharmony_ci	else {
3338c2ecf20Sopenharmony_ci		offset = port << 1;
3348c2ecf20Sopenharmony_ci		BUG_ON(port & 1);
3358c2ecf20Sopenharmony_ci	}
3368c2ecf20Sopenharmony_ci	__raw_writew(val, (void __iomem *)ISAIO_BASE + offset);
3378c2ecf20Sopenharmony_ci}
3388c2ecf20Sopenharmony_ci
3398c2ecf20Sopenharmony_civoid __outl(u32 val, unsigned int port)
3408c2ecf20Sopenharmony_ci{
3418c2ecf20Sopenharmony_ci	BUG();
3428c2ecf20Sopenharmony_ci}
3438c2ecf20Sopenharmony_ci
3448c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__outb8);
3458c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__outb16);
3468c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__outw);
3478c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__outl);
3488c2ecf20Sopenharmony_ci
3498c2ecf20Sopenharmony_civoid outsb(unsigned int port, const void *from, int len)
3508c2ecf20Sopenharmony_ci{
3518c2ecf20Sopenharmony_ci	u32 off;
3528c2ecf20Sopenharmony_ci
3538c2ecf20Sopenharmony_ci	if (SUPERIO_PORT(port))
3548c2ecf20Sopenharmony_ci		off = port << 2;
3558c2ecf20Sopenharmony_ci	else {
3568c2ecf20Sopenharmony_ci		off = (port & ~1) << 1;
3578c2ecf20Sopenharmony_ci		if (port & 1)
3588c2ecf20Sopenharmony_ci			BUG();
3598c2ecf20Sopenharmony_ci	}
3608c2ecf20Sopenharmony_ci
3618c2ecf20Sopenharmony_ci	__raw_writesb((void __iomem *)ISAIO_BASE + off, from, len);
3628c2ecf20Sopenharmony_ci}
3638c2ecf20Sopenharmony_ci
3648c2ecf20Sopenharmony_civoid insb(unsigned int port, void *from, int len)
3658c2ecf20Sopenharmony_ci{
3668c2ecf20Sopenharmony_ci	u32 off;
3678c2ecf20Sopenharmony_ci
3688c2ecf20Sopenharmony_ci	if (SUPERIO_PORT(port))
3698c2ecf20Sopenharmony_ci		off = port << 2;
3708c2ecf20Sopenharmony_ci	else {
3718c2ecf20Sopenharmony_ci		off = (port & ~1) << 1;
3728c2ecf20Sopenharmony_ci		if (port & 1)
3738c2ecf20Sopenharmony_ci			BUG();
3748c2ecf20Sopenharmony_ci	}
3758c2ecf20Sopenharmony_ci
3768c2ecf20Sopenharmony_ci	__raw_readsb((void __iomem *)ISAIO_BASE + off, from, len);
3778c2ecf20Sopenharmony_ci}
3788c2ecf20Sopenharmony_ci
3798c2ecf20Sopenharmony_ciEXPORT_SYMBOL(outsb);
3808c2ecf20Sopenharmony_ciEXPORT_SYMBOL(insb);
3818c2ecf20Sopenharmony_ci
3828c2ecf20Sopenharmony_civoid outsw(unsigned int port, const void *from, int len)
3838c2ecf20Sopenharmony_ci{
3848c2ecf20Sopenharmony_ci	u32 off;
3858c2ecf20Sopenharmony_ci
3868c2ecf20Sopenharmony_ci	if (SUPERIO_PORT(port))
3878c2ecf20Sopenharmony_ci		off = port << 2;
3888c2ecf20Sopenharmony_ci	else {
3898c2ecf20Sopenharmony_ci		off = (port & ~1) << 1;
3908c2ecf20Sopenharmony_ci		if (port & 1)
3918c2ecf20Sopenharmony_ci			BUG();
3928c2ecf20Sopenharmony_ci	}
3938c2ecf20Sopenharmony_ci
3948c2ecf20Sopenharmony_ci	__raw_writesw((void __iomem *)ISAIO_BASE + off, from, len);
3958c2ecf20Sopenharmony_ci}
3968c2ecf20Sopenharmony_ci
3978c2ecf20Sopenharmony_civoid insw(unsigned int port, void *from, int len)
3988c2ecf20Sopenharmony_ci{
3998c2ecf20Sopenharmony_ci	u32 off;
4008c2ecf20Sopenharmony_ci
4018c2ecf20Sopenharmony_ci	if (SUPERIO_PORT(port))
4028c2ecf20Sopenharmony_ci		off = port << 2;
4038c2ecf20Sopenharmony_ci	else {
4048c2ecf20Sopenharmony_ci		off = (port & ~1) << 1;
4058c2ecf20Sopenharmony_ci		if (port & 1)
4068c2ecf20Sopenharmony_ci			BUG();
4078c2ecf20Sopenharmony_ci	}
4088c2ecf20Sopenharmony_ci
4098c2ecf20Sopenharmony_ci	__raw_readsw((void __iomem *)ISAIO_BASE + off, from, len);
4108c2ecf20Sopenharmony_ci}
4118c2ecf20Sopenharmony_ci
4128c2ecf20Sopenharmony_ciEXPORT_SYMBOL(outsw);
4138c2ecf20Sopenharmony_ciEXPORT_SYMBOL(insw);
4148c2ecf20Sopenharmony_ci
4158c2ecf20Sopenharmony_ci/*
4168c2ecf20Sopenharmony_ci * We implement these as 16-bit insw/outsw, mainly for
4178c2ecf20Sopenharmony_ci * 3c589 cards.
4188c2ecf20Sopenharmony_ci */
4198c2ecf20Sopenharmony_civoid outsl(unsigned int port, const void *from, int len)
4208c2ecf20Sopenharmony_ci{
4218c2ecf20Sopenharmony_ci	u32 off = port << 1;
4228c2ecf20Sopenharmony_ci
4238c2ecf20Sopenharmony_ci	if (SUPERIO_PORT(port) || port & 3)
4248c2ecf20Sopenharmony_ci		BUG();
4258c2ecf20Sopenharmony_ci
4268c2ecf20Sopenharmony_ci	__raw_writesw((void __iomem *)ISAIO_BASE + off, from, len << 1);
4278c2ecf20Sopenharmony_ci}
4288c2ecf20Sopenharmony_ci
4298c2ecf20Sopenharmony_civoid insl(unsigned int port, void *from, int len)
4308c2ecf20Sopenharmony_ci{
4318c2ecf20Sopenharmony_ci	u32 off = port << 1;
4328c2ecf20Sopenharmony_ci
4338c2ecf20Sopenharmony_ci	if (SUPERIO_PORT(port) || port & 3)
4348c2ecf20Sopenharmony_ci		BUG();
4358c2ecf20Sopenharmony_ci
4368c2ecf20Sopenharmony_ci	__raw_readsw((void __iomem *)ISAIO_BASE + off, from, len << 1);
4378c2ecf20Sopenharmony_ci}
4388c2ecf20Sopenharmony_ci
4398c2ecf20Sopenharmony_ciEXPORT_SYMBOL(outsl);
4408c2ecf20Sopenharmony_ciEXPORT_SYMBOL(insl);
441