1dea3101eS /*******************************************************************
2dea3101eS * This file is part of the Emulex Linux Device Driver for *
3c44ce173SJames.Smart@Emulex.Com * Fibre Channel Host Bus Adapters. *
44ae2ebdeSJames Smart * Copyright (C) 2017-2018 Broadcom. All Rights Reserved. The term *
54ae2ebdeSJames Smart * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. *
62e90f4b5SJames Smart * Copyright (C) 2004-2011 Emulex. All rights reserved. *
7c44ce173SJames.Smart@Emulex.Com * EMULEX and SLI are trademarks of Emulex. *
8d080abe0SJames Smart * www.broadcom.com *
9dea3101eS * *
10dea3101eS * This program is free software; you can redistribute it and/or *
11c44ce173SJames.Smart@Emulex.Com * modify it under the terms of version 2 of the GNU General *
12c44ce173SJames.Smart@Emulex.Com * Public License as published by the Free Software Foundation. *
13c44ce173SJames.Smart@Emulex.Com * This program is distributed in the hope that it will be useful. *
14c44ce173SJames.Smart@Emulex.Com * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
15c44ce173SJames.Smart@Emulex.Com * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
16c44ce173SJames.Smart@Emulex.Com * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
17c44ce173SJames.Smart@Emulex.Com * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
18c44ce173SJames.Smart@Emulex.Com * TO BE LEGALLY INVALID. See the GNU General Public License for *
19c44ce173SJames.Smart@Emulex.Com * more details, a copy of which can be found in the file COPYING *
20c44ce173SJames.Smart@Emulex.Com * included with this package. *
21dea3101eS *******************************************************************/
22dea3101eS
23dea3101eS /*
24dea3101eS * This file provides macros to aid compilation in the Linux 2.4 kernel
25dea3101eS * over various platform architectures.
26dea3101eS */
27dea3101eS
28dea3101eS /*******************************************************************
29dea3101eS Note: HBA's SLI memory contains little-endian LW.
30dea3101eS Thus to access it from a little-endian host,
31dea3101eS memcpy_toio() and memcpy_fromio() can be used.
32dea3101eS However on a big-endian host, copy 4 bytes at a time,
33dea3101eS using writel() and readl().
34dea3101eS *******************************************************************/
3544456d37SOlaf Hering #include <asm/byteorder.h>
36dea3101eS
3744456d37SOlaf Hering #ifdef __BIG_ENDIAN
38dea3101eS
39dea3101eS static inline void
lpfc_memcpy_to_slim(void __iomem * dest,void * src,unsigned int bytes)40dea3101eS lpfc_memcpy_to_slim(void __iomem *dest, void *src, unsigned int bytes)
41dea3101eS {
42dea3101eS uint32_t __iomem *dest32;
43dea3101eS uint32_t *src32;
44dea3101eS unsigned int four_bytes;
45dea3101eS
46dea3101eS
47dea3101eS dest32 = (uint32_t __iomem *) dest;
48dea3101eS src32 = (uint32_t *) src;
49dea3101eS
50dea3101eS /* write input bytes, 4 bytes at a time */
51dea3101eS for (four_bytes = bytes /4; four_bytes > 0; four_bytes--) {
52dea3101eS writel( *src32, dest32);
53dea3101eS readl(dest32); /* flush */
54dea3101eS dest32++;
55dea3101eS src32++;
56dea3101eS }
57dea3101eS
58dea3101eS return;
59dea3101eS }
60dea3101eS
61dea3101eS static inline void
lpfc_memcpy_from_slim(void * dest,void __iomem * src,unsigned int bytes)62dea3101eS lpfc_memcpy_from_slim( void *dest, void __iomem *src, unsigned int bytes)
63dea3101eS {
64dea3101eS uint32_t *dest32;
65dea3101eS uint32_t __iomem *src32;
66dea3101eS unsigned int four_bytes;
67dea3101eS
68dea3101eS
69dea3101eS dest32 = (uint32_t *) dest;
70dea3101eS src32 = (uint32_t __iomem *) src;
71dea3101eS
72dea3101eS /* read input bytes, 4 bytes at a time */
73dea3101eS for (four_bytes = bytes /4; four_bytes > 0; four_bytes--) {
74dea3101eS *dest32 = readl( src32);
75dea3101eS dest32++;
76dea3101eS src32++;
77dea3101eS }
78dea3101eS
79dea3101eS return;
80dea3101eS }
81dea3101eS
82dea3101eS #else
83dea3101eS
84dea3101eS static inline void
lpfc_memcpy_to_slim(void __iomem * dest,void * src,unsigned int bytes)85dea3101eS lpfc_memcpy_to_slim( void __iomem *dest, void *src, unsigned int bytes)
86dea3101eS {
872e90f4b5SJames Smart /* convert bytes in argument list to word count for copy function */
882e90f4b5SJames Smart __iowrite32_copy(dest, src, bytes / sizeof(uint32_t));
89dea3101eS }
90dea3101eS
91dea3101eS static inline void
lpfc_memcpy_from_slim(void * dest,void __iomem * src,unsigned int bytes)92dea3101eS lpfc_memcpy_from_slim( void *dest, void __iomem *src, unsigned int bytes)
93dea3101eS {
94dea3101eS /* actually returns 1 byte past dest */
95dea3101eS memcpy_fromio( dest, src, bytes);
96dea3101eS }
97dea3101eS
98dea3101eS #endif /* __BIG_ENDIAN */
99