GNU Linux-libre 4.19.295-gnu1
[releases.git] / arch / hexagon / lib / io.c
1 /*
2  * I/O access functions for Hexagon
3  *
4  * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 and
8  * only version 2 as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18  * 02110-1301, USA.
19  */
20
21 #include <asm/io.h>
22
23 /*  These are all FIFO routines!  */
24
25 /*
26  * __raw_readsw - read words a short at a time
27  * @addr:  source address
28  * @data:  data address
29  * @len: number of shorts to read
30  */
31 void __raw_readsw(const void __iomem *addr, void *data, int len)
32 {
33         const volatile short int *src = (short int *) addr;
34         short int *dst = (short int *) data;
35
36         if ((u32)data & 0x1)
37                 panic("unaligned pointer to readsw");
38
39         while (len-- > 0)
40                 *dst++ = *src;
41
42 }
43 EXPORT_SYMBOL(__raw_readsw);
44
45 /*
46  * __raw_writesw - read words a short at a time
47  * @addr:  source address
48  * @data:  data address
49  * @len: number of shorts to read
50  */
51 void __raw_writesw(void __iomem *addr, const void *data, int len)
52 {
53         const short int *src = (short int *)data;
54         volatile short int *dst = (short int *)addr;
55
56         if ((u32)data & 0x1)
57                 panic("unaligned pointer to writesw");
58
59         while (len-- > 0)
60                 *dst = *src++;
61
62
63 }
64 EXPORT_SYMBOL(__raw_writesw);
65
66 /*  Pretty sure len is pre-adjusted for the length of the access already */
67 void __raw_readsl(const void __iomem *addr, void *data, int len)
68 {
69         const volatile long *src = (long *) addr;
70         long *dst = (long *) data;
71
72         if ((u32)data & 0x3)
73                 panic("unaligned pointer to readsl");
74
75         while (len-- > 0)
76                 *dst++ = *src;
77
78
79 }
80 EXPORT_SYMBOL(__raw_readsl);
81
82 void __raw_writesl(void __iomem *addr, const void *data, int len)
83 {
84         const long *src = (long *)data;
85         volatile long *dst = (long *)addr;
86
87         if ((u32)data & 0x3)
88                 panic("unaligned pointer to writesl");
89
90         while (len-- > 0)
91                 *dst = *src++;
92
93
94 }
95 EXPORT_SYMBOL(__raw_writesl);