diff options
author | Maciej W. Rozycki <macro@linux-mips.org> | 2006-10-23 08:53:17 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2006-12-02 00:12:01 -0500 |
commit | b2e68aa337f950e4a8c893a82b95b1755309bc56 (patch) | |
tree | 4f7696e09d08cb173306e68bfdc4dc98aa97ef0b | |
parent | c3a9392e4f3b9d97803b067871d66bc143369dbf (diff) |
[PATCH] defxx: Big-endian hosts support
The PDQ DMA engine requires a different byte-swapping mode for big-endian
hosts; also the MAC address which is read from a register through PIO has
to be byte-swapped. These changes have been verified with DEFPA-DC (PCI)
boards and a Broadcom BCM91250A (MIPS CPU based) host.
Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
-rw-r--r-- | drivers/net/defxx.c | 39 | ||||
-rw-r--r-- | drivers/net/defxx.h | 15 |
2 files changed, 31 insertions, 23 deletions
diff --git a/drivers/net/defxx.c b/drivers/net/defxx.c index 8f514cc0deb..dc3ab3b5c8c 100644 --- a/drivers/net/defxx.c +++ b/drivers/net/defxx.c | |||
@@ -192,6 +192,7 @@ | |||
192 | * 04 Aug 2003 macro Converted to the DMA API. | 192 | * 04 Aug 2003 macro Converted to the DMA API. |
193 | * 14 Aug 2004 macro Fix device names reported. | 193 | * 14 Aug 2004 macro Fix device names reported. |
194 | * 14 Jun 2005 macro Use irqreturn_t. | 194 | * 14 Jun 2005 macro Use irqreturn_t. |
195 | * 23 Oct 2006 macro Big-endian host support. | ||
195 | */ | 196 | */ |
196 | 197 | ||
197 | /* Include files */ | 198 | /* Include files */ |
@@ -218,8 +219,8 @@ | |||
218 | 219 | ||
219 | /* Version information string should be updated prior to each new release! */ | 220 | /* Version information string should be updated prior to each new release! */ |
220 | #define DRV_NAME "defxx" | 221 | #define DRV_NAME "defxx" |
221 | #define DRV_VERSION "v1.08" | 222 | #define DRV_VERSION "v1.09" |
222 | #define DRV_RELDATE "2005/06/14" | 223 | #define DRV_RELDATE "2006/10/23" |
223 | 224 | ||
224 | static char version[] __devinitdata = | 225 | static char version[] __devinitdata = |
225 | DRV_NAME ": " DRV_VERSION " " DRV_RELDATE | 226 | DRV_NAME ": " DRV_VERSION " " DRV_RELDATE |
@@ -859,6 +860,7 @@ static int __devinit dfx_driver_init(struct net_device *dev, | |||
859 | print_name); | 860 | print_name); |
860 | return(DFX_K_FAILURE); | 861 | return(DFX_K_FAILURE); |
861 | } | 862 | } |
863 | data = cpu_to_le32(data); | ||
862 | memcpy(&bp->factory_mac_addr[0], &data, sizeof(u32)); | 864 | memcpy(&bp->factory_mac_addr[0], &data, sizeof(u32)); |
863 | 865 | ||
864 | if (dfx_hw_port_ctrl_req(bp, PI_PCTRL_M_MLA, PI_PDATA_A_MLA_K_HI, 0, | 866 | if (dfx_hw_port_ctrl_req(bp, PI_PCTRL_M_MLA, PI_PDATA_A_MLA_K_HI, 0, |
@@ -867,6 +869,7 @@ static int __devinit dfx_driver_init(struct net_device *dev, | |||
867 | print_name); | 869 | print_name); |
868 | return(DFX_K_FAILURE); | 870 | return(DFX_K_FAILURE); |
869 | } | 871 | } |
872 | data = cpu_to_le32(data); | ||
870 | memcpy(&bp->factory_mac_addr[4], &data, sizeof(u16)); | 873 | memcpy(&bp->factory_mac_addr[4], &data, sizeof(u16)); |
871 | 874 | ||
872 | /* | 875 | /* |
@@ -1085,27 +1088,23 @@ static int dfx_adap_init(DFX_board_t *bp, int get_buffers) | |||
1085 | } | 1088 | } |
1086 | 1089 | ||
1087 | /* | 1090 | /* |
1088 | * Set base address of Descriptor Block and bring adapter to DMA_AVAILABLE state | 1091 | * Set the base address of Descriptor Block and bring adapter |
1092 | * to DMA_AVAILABLE state. | ||
1089 | * | 1093 | * |
1090 | * Note: We also set the literal and data swapping requirements in this | 1094 | * Note: We also set the literal and data swapping requirements |
1091 | * command. Since this driver presently runs on Intel platforms | 1095 | * in this command. |
1092 | * which are Little Endian, we'll tell the adapter to byte swap | ||
1093 | * data only. This code will need to change when we support | ||
1094 | * Big Endian systems (eg. PowerPC). | ||
1095 | * | 1096 | * |
1096 | * Assumption: 32-bit physical address of descriptor block is 8Kbyte | 1097 | * Assumption: 32-bit physical address of descriptor block |
1097 | * aligned. That is, bits 0-12 of the address must be zero. | 1098 | * is 8Kbyte aligned. |
1098 | */ | 1099 | */ |
1099 | 1100 | if (dfx_hw_port_ctrl_req(bp, PI_PCTRL_M_INIT, | |
1100 | if (dfx_hw_port_ctrl_req(bp, | 1101 | (u32)(bp->descr_block_phys | |
1101 | PI_PCTRL_M_INIT, | 1102 | PI_PDATA_A_INIT_M_BSWAP_INIT), |
1102 | (u32) (bp->descr_block_phys | PI_PDATA_A_INIT_M_BSWAP_DATA), | 1103 | 0, NULL) != DFX_K_SUCCESS) { |
1103 | 0, | 1104 | printk("%s: Could not set descriptor block address!\n", |
1104 | NULL) != DFX_K_SUCCESS) | 1105 | bp->dev->name); |
1105 | { | 1106 | return DFX_K_FAILURE; |
1106 | printk("%s: Could not set descriptor block address!\n", bp->dev->name); | 1107 | } |
1107 | return(DFX_K_FAILURE); | ||
1108 | } | ||
1109 | 1108 | ||
1110 | /* Set transmit flush timeout value */ | 1109 | /* Set transmit flush timeout value */ |
1111 | 1110 | ||
diff --git a/drivers/net/defxx.h b/drivers/net/defxx.h index 8b1e9a11ca2..2ce8f97253e 100644 --- a/drivers/net/defxx.h +++ b/drivers/net/defxx.h | |||
@@ -25,6 +25,7 @@ | |||
25 | * macros to DEFXX.C. | 25 | * macros to DEFXX.C. |
26 | * 12-Sep-96 LVS Removed packet request header pointers. | 26 | * 12-Sep-96 LVS Removed packet request header pointers. |
27 | * 04 Aug 2003 macro Converted to the DMA API. | 27 | * 04 Aug 2003 macro Converted to the DMA API. |
28 | * 23 Oct 2006 macro Big-endian host support. | ||
28 | */ | 29 | */ |
29 | 30 | ||
30 | #ifndef _DEFXX_H_ | 31 | #ifndef _DEFXX_H_ |
@@ -1344,7 +1345,7 @@ typedef struct | |||
1344 | 1345 | ||
1345 | /* Register definition structures are defined for both big and little endian systems */ | 1346 | /* Register definition structures are defined for both big and little endian systems */ |
1346 | 1347 | ||
1347 | #ifndef BIG_ENDIAN | 1348 | #ifndef __BIG_ENDIAN |
1348 | 1349 | ||
1349 | /* Little endian format of Type 1 Producer register */ | 1350 | /* Little endian format of Type 1 Producer register */ |
1350 | 1351 | ||
@@ -1402,7 +1403,11 @@ typedef union | |||
1402 | } index; | 1403 | } index; |
1403 | } PI_TYPE_2_CONSUMER; | 1404 | } PI_TYPE_2_CONSUMER; |
1404 | 1405 | ||
1405 | #else | 1406 | /* Define swapping required by DMA transfers. */ |
1407 | #define PI_PDATA_A_INIT_M_BSWAP_INIT \ | ||
1408 | (PI_PDATA_A_INIT_M_BSWAP_DATA) | ||
1409 | |||
1410 | #else /* __BIG_ENDIAN */ | ||
1406 | 1411 | ||
1407 | /* Big endian format of Type 1 Producer register */ | 1412 | /* Big endian format of Type 1 Producer register */ |
1408 | 1413 | ||
@@ -1460,7 +1465,11 @@ typedef union | |||
1460 | } index; | 1465 | } index; |
1461 | } PI_TYPE_2_CONSUMER; | 1466 | } PI_TYPE_2_CONSUMER; |
1462 | 1467 | ||
1463 | #endif /* #ifndef BIG_ENDIAN */ | 1468 | /* Define swapping required by DMA transfers. */ |
1469 | #define PI_PDATA_A_INIT_M_BSWAP_INIT \ | ||
1470 | (PI_PDATA_A_INIT_M_BSWAP_DATA | PI_PDATA_A_INIT_M_BSWAP_LITERAL) | ||
1471 | |||
1472 | #endif /* __BIG_ENDIAN */ | ||
1464 | 1473 | ||
1465 | /* Define EISA controller register offsets */ | 1474 | /* Define EISA controller register offsets */ |
1466 | 1475 | ||