1 // SPDX-License-Identifier: GPL-2.0
3 * arch/sh/kernel/io.c - Machine independent I/O functions.
5 * Copyright (C) 2000 - 2009 Stuart Menefy
6 * Copyright (C) 2005 Paul Mundt
8 #include <linux/module.h>
10 #include <asm/machvec.h>
14 * Copy data from IO memory space to "real" memory space.
16 void memcpy_fromio(void *to
, const volatile void __iomem
*from
, unsigned long count
)
19 * Would it be worthwhile doing byte and long transfers first
20 * to try and get aligned?
23 if ((count
>= 0x20) &&
24 (((u32
)to
& 0x1f) == 0) && (((u32
)from
& 0x3) == 0)) {
25 int tmp2
, tmp3
, tmp4
, tmp5
, tmp6
;
31 "movca.l r0, @%0 \n\t"
38 "mov.l %2, @(0x04,%0) \n\t"
40 "mov.l %3, @(0x08,%0) \n\t"
42 "mov.l %4, @(0x0c,%0) \n\t"
43 "cmp/hi %1, %2 ! T if 32 > count \n\t"
44 "mov.l %5, @(0x10,%0) \n\t"
45 "mov.l %6, @(0x14,%0) \n\t"
46 "mov.l r7, @(0x18,%0) \n\t"
47 "mov.l r0, @(0x1c,%0) \n\t"
50 : "=&r" (to
), "=&r" (count
),
51 "=&r" (tmp2
), "=&r" (tmp3
), "=&r" (tmp4
),
52 "=&r" (tmp5
), "=&r" (tmp6
), "=&r" (from
)
53 : "7"(from
), "0" (to
), "1" (count
)
54 : "r0", "r7", "t", "memory");
58 if ((((u32
)to
| (u32
)from
) & 0x3) == 0) {
59 for (; count
> 3; count
-= 4) {
60 *(u32
*)to
= *(volatile u32
*)from
;
66 for (; count
> 0; count
--) {
67 *(u8
*)to
= *(volatile u8
*)from
;
74 EXPORT_SYMBOL(memcpy_fromio
);
77 * Copy data from "real" memory space to IO memory space.
79 void memcpy_toio(volatile void __iomem
*to
, const void *from
, unsigned long count
)
81 if ((((u32
)to
| (u32
)from
) & 0x3) == 0) {
82 for ( ; count
> 3; count
-= 4) {
83 *(volatile u32
*)to
= *(u32
*)from
;
89 for (; count
> 0; count
--) {
90 *(volatile u8
*)to
= *(u8
*)from
;
97 EXPORT_SYMBOL(memcpy_toio
);
100 * "memset" on IO memory space.
101 * This needs to be optimized.
103 void memset_io(volatile void __iomem
*dst
, int c
, unsigned long count
)
111 EXPORT_SYMBOL(memset_io
);