summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorEvan Lojewski <github@meklort.com>2019-02-24 07:51:35 -0700
committerEvan Lojewski <github@meklort.com>2019-02-24 07:51:35 -0700
commite4b5eefa2db933c2221edefd7f9974f776ee2259 (patch)
treee104435f73a627417cd3f0e654501458fa2e029b /libs
parenta204cc16f7d0daabc84677b100f5e6847219569e (diff)
downloadbcm5719-ortega-e4b5eefa2db933c2221edefd7f9974f776ee2259.tar.gz
bcm5719-ortega-e4b5eefa2db933c2221edefd7f9974f776ee2259.zip
Don't pass a pointer to the mii routines and then typecast, looks like it might break with the ABI.
Diffstat (limited to 'libs')
-rw-r--r--libs/MII/include/MII.h7
-rw-r--r--libs/MII/mii.c10
2 files changed, 11 insertions, 6 deletions
diff --git a/libs/MII/include/MII.h b/libs/MII/include/MII.h
index 1be6e04..9588e01 100644
--- a/libs/MII/include/MII.h
+++ b/libs/MII/include/MII.h
@@ -47,7 +47,12 @@
#include <stdint.h>
#include <bcm5719_MII.h>
-typedef volatile BCM5719_MII_H_uint16_t * mii_reg_t;
+#ifdef CXX_SIMULATOR
+typedef uint64_t mii_reg_t;
+#else
+typedef uint8_t mii_reg_t;
+#endif
+
/**
* @fn uint8_t MII_getPhy(void);
*
diff --git a/libs/MII/mii.c b/libs/MII/mii.c
index c33f366..9123242 100644
--- a/libs/MII/mii.c
+++ b/libs/MII/mii.c
@@ -44,7 +44,7 @@
#include <MII.h>
#include <bcm5719_DEVICE.h>
-static void MII_wait(void)
+static void __attribute__((noinline)) MII_wait(void)
{
// Wait for the status bit to be clear.
while (DEVICE.MiiCommunication.bits.Start_DIV_Busy)
@@ -97,7 +97,7 @@ uint16_t MII_readRegister(uint8_t phy, mii_reg_t reg)
void MII_writeRegister(uint8_t phy, mii_reg_t reg, uint16_t data)
{
union {
- uint8_t addr;
+ uint32_t addr;
mii_reg_t reg;
} caster;
caster.reg = reg;
@@ -107,7 +107,7 @@ void MII_writeRegister(uint8_t phy, mii_reg_t reg, uint16_t data)
regcontents.bits.Command = DEVICE_MII_COMMUNICATION_COMMAND_WRITE;
regcontents.bits.Start_DIV_Busy = 1;
regcontents.bits.PHYAddress = phy;
- regcontents.bits.RegisterAddress = caster.addr;
+ regcontents.bits.RegisterAddress = caster.addr * 16;
regcontents.bits.TransactionData = data;
// Ensure there are no active transactions
@@ -123,11 +123,11 @@ void MII_writeRegister(uint8_t phy, mii_reg_t reg, uint16_t data)
void MII_selectBlock(uint8_t phy, uint16_t block)
{
// Write register 0x1f with the block.
- MII_writeRegister(phy, REG_MII_BLOCK_SELECT, block);
+ MII_writeRegister(phy, (mii_reg_t)REG_MII_BLOCK_SELECT, block);
}
uint16_t MII_getBlock(uint8_t phy)
{
// Write register 0x1f with the block.
- return MII_readRegister(phy, REG_MII_BLOCK_SELECT);
+ return MII_readRegister(phy, (mii_reg_t)REG_MII_BLOCK_SELECT);
}
OpenPOWER on IntegriCloud