108dbd0f8SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
2013bf24cSRichard Kuo /*
3013bf24cSRichard Kuo * I/O access functions for Hexagon
4013bf24cSRichard Kuo *
5e1858b2aSRichard Kuo * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
6013bf24cSRichard Kuo */
7013bf24cSRichard Kuo
8013bf24cSRichard Kuo #include <asm/io.h>
9013bf24cSRichard Kuo
10013bf24cSRichard Kuo /* These are all FIFO routines! */
11013bf24cSRichard Kuo
12013bf24cSRichard Kuo /*
13013bf24cSRichard Kuo * __raw_readsw - read words a short at a time
14013bf24cSRichard Kuo * @addr: source address
15013bf24cSRichard Kuo * @data: data address
16013bf24cSRichard Kuo * @len: number of shorts to read
17013bf24cSRichard Kuo */
__raw_readsw(const void __iomem * addr,void * data,int len)18013bf24cSRichard Kuo void __raw_readsw(const void __iomem *addr, void *data, int len)
19013bf24cSRichard Kuo {
20013bf24cSRichard Kuo const volatile short int *src = (short int *) addr;
21013bf24cSRichard Kuo short int *dst = (short int *) data;
22013bf24cSRichard Kuo
23013bf24cSRichard Kuo if ((u32)data & 0x1)
24013bf24cSRichard Kuo panic("unaligned pointer to readsw");
25013bf24cSRichard Kuo
26013bf24cSRichard Kuo while (len-- > 0)
27013bf24cSRichard Kuo *dst++ = *src;
28013bf24cSRichard Kuo
29013bf24cSRichard Kuo }
30*ffb92ce8SNathan Chancellor EXPORT_SYMBOL(__raw_readsw);
31013bf24cSRichard Kuo
32013bf24cSRichard Kuo /*
33013bf24cSRichard Kuo * __raw_writesw - read words a short at a time
34013bf24cSRichard Kuo * @addr: source address
35013bf24cSRichard Kuo * @data: data address
36013bf24cSRichard Kuo * @len: number of shorts to read
37013bf24cSRichard Kuo */
__raw_writesw(void __iomem * addr,const void * data,int len)38013bf24cSRichard Kuo void __raw_writesw(void __iomem *addr, const void *data, int len)
39013bf24cSRichard Kuo {
40013bf24cSRichard Kuo const short int *src = (short int *)data;
41013bf24cSRichard Kuo volatile short int *dst = (short int *)addr;
42013bf24cSRichard Kuo
43013bf24cSRichard Kuo if ((u32)data & 0x1)
44013bf24cSRichard Kuo panic("unaligned pointer to writesw");
45013bf24cSRichard Kuo
46013bf24cSRichard Kuo while (len-- > 0)
47013bf24cSRichard Kuo *dst = *src++;
48013bf24cSRichard Kuo
49013bf24cSRichard Kuo
50013bf24cSRichard Kuo }
51*ffb92ce8SNathan Chancellor EXPORT_SYMBOL(__raw_writesw);
52013bf24cSRichard Kuo
53013bf24cSRichard Kuo /* Pretty sure len is pre-adjusted for the length of the access already */
__raw_readsl(const void __iomem * addr,void * data,int len)54013bf24cSRichard Kuo void __raw_readsl(const void __iomem *addr, void *data, int len)
55013bf24cSRichard Kuo {
56013bf24cSRichard Kuo const volatile long *src = (long *) addr;
57013bf24cSRichard Kuo long *dst = (long *) data;
58013bf24cSRichard Kuo
59013bf24cSRichard Kuo if ((u32)data & 0x3)
60013bf24cSRichard Kuo panic("unaligned pointer to readsl");
61013bf24cSRichard Kuo
62013bf24cSRichard Kuo while (len-- > 0)
63013bf24cSRichard Kuo *dst++ = *src;
64013bf24cSRichard Kuo
65013bf24cSRichard Kuo
66013bf24cSRichard Kuo }
67*ffb92ce8SNathan Chancellor EXPORT_SYMBOL(__raw_readsl);
68013bf24cSRichard Kuo
__raw_writesl(void __iomem * addr,const void * data,int len)69013bf24cSRichard Kuo void __raw_writesl(void __iomem *addr, const void *data, int len)
70013bf24cSRichard Kuo {
71013bf24cSRichard Kuo const long *src = (long *)data;
72013bf24cSRichard Kuo volatile long *dst = (long *)addr;
73013bf24cSRichard Kuo
74013bf24cSRichard Kuo if ((u32)data & 0x3)
75013bf24cSRichard Kuo panic("unaligned pointer to writesl");
76013bf24cSRichard Kuo
77013bf24cSRichard Kuo while (len-- > 0)
78013bf24cSRichard Kuo *dst = *src++;
79013bf24cSRichard Kuo
80013bf24cSRichard Kuo
81013bf24cSRichard Kuo }
82*ffb92ce8SNathan Chancellor EXPORT_SYMBOL(__raw_writesl);
83