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