summaryrefslogtreecommitdiffstats
path: root/drivers/net/e1000/eeprom.c
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2017-11-22 11:22:28 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2017-11-24 10:06:14 +0100
commit8c9f6705e5140260c479ee32e98ac95747e2ad1d (patch)
tree771d3c79f39c2bfbca8466c6229d123869674019 /drivers/net/e1000/eeprom.c
parenteed09e73f335dc4ceb809a783b6be3fe78225257 (diff)
downloadbarebox-8c9f6705e5140260c479ee32e98ac95747e2ad1d.tar.gz
barebox-8c9f6705e5140260c479ee32e98ac95747e2ad1d.tar.xz
net/e1000: reorder functions
Bring functions in a more natural order which allows to drop a few forward declarations. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/net/e1000/eeprom.c')
-rw-r--r--drivers/net/e1000/eeprom.c137
1 files changed, 67 insertions, 70 deletions
diff --git a/drivers/net/e1000/eeprom.c b/drivers/net/e1000/eeprom.c
index 150e4147c4..9948a8c952 100644
--- a/drivers/net/e1000/eeprom.c
+++ b/drivers/net/e1000/eeprom.c
@@ -6,18 +6,14 @@
#include "e1000.h"
-static void e1000_release_eeprom_spi(struct e1000_hw *hw);
static int32_t e1000_read_eeprom_spi(struct e1000_hw *hw, uint16_t offset,
uint16_t words, uint16_t *data);
-static void e1000_release_eeprom_microwire(struct e1000_hw *hw);
static int32_t e1000_read_eeprom_microwire(struct e1000_hw *hw, uint16_t offset,
uint16_t words, uint16_t *data);
static int32_t e1000_read_eeprom_eerd(struct e1000_hw *hw, uint16_t offset,
uint16_t words, uint16_t *data);
static int32_t e1000_spi_eeprom_ready(struct e1000_hw *hw);
-static void e1000_release_eeprom(struct e1000_hw *hw);
-static int32_t e1000_acquire_eeprom_flash(struct e1000_hw *hw);
static void e1000_release_eeprom_flash(struct e1000_hw *hw);
@@ -252,6 +248,19 @@ e1000_acquire_eeprom_spi_microwire_prologue(struct e1000_hw *hw)
return E1000_SUCCESS;
}
+static void
+e1000_release_eeprom_spi_microwire_epilogue(struct e1000_hw *hw)
+{
+ uint32_t eecd = e1000_read_reg(hw, E1000_EECD);
+
+ /* Stop requesting EEPROM access */
+ if (hw->mac_type > e1000_82544) {
+ eecd &= ~E1000_EECD_REQ;
+ e1000_write_reg(hw, E1000_EECD, eecd);
+ }
+}
+
+
static int32_t e1000_acquire_eeprom_spi(struct e1000_hw *hw)
{
int32_t ret;
@@ -271,6 +280,19 @@ static int32_t e1000_acquire_eeprom_spi(struct e1000_hw *hw)
return E1000_SUCCESS;
}
+static void e1000_release_eeprom_spi(struct e1000_hw *hw)
+{
+ uint32_t eecd = e1000_read_reg(hw, E1000_EECD);
+
+ eecd |= E1000_EECD_CS; /* Pull CS high */
+ eecd &= ~E1000_EECD_SK; /* Lower SCK */
+
+ e1000_write_reg(hw, E1000_EECD, eecd);
+ udelay(hw->eeprom.delay_usec);
+
+ e1000_release_eeprom_spi_microwire_epilogue(hw);
+}
+
static int32_t e1000_acquire_eeprom_microwire(struct e1000_hw *hw)
{
int ret;
@@ -292,11 +314,46 @@ static int32_t e1000_acquire_eeprom_microwire(struct e1000_hw *hw)
return E1000_SUCCESS;
}
+static void e1000_release_eeprom_microwire(struct e1000_hw *hw)
+{
+ uint32_t eecd = e1000_read_reg(hw, E1000_EECD);
+
+ /* cleanup eeprom */
+
+ /* CS on Microwire is active-high */
+ eecd &= ~(E1000_EECD_CS | E1000_EECD_DI);
+
+ e1000_write_reg(hw, E1000_EECD, eecd);
+
+ /* Rising edge of clock */
+ eecd |= E1000_EECD_SK;
+ e1000_write_reg(hw, E1000_EECD, eecd);
+ e1000_write_flush(hw);
+ udelay(hw->eeprom.delay_usec);
+
+ /* Falling edge of clock */
+ eecd &= ~E1000_EECD_SK;
+ e1000_write_reg(hw, E1000_EECD, eecd);
+ e1000_write_flush(hw);
+ udelay(hw->eeprom.delay_usec);
+
+
+ e1000_release_eeprom_spi_microwire_epilogue(hw);
+}
+
static int32_t e1000_acquire_eeprom_flash(struct e1000_hw *hw)
{
return e1000_swfw_sync_acquire(hw, E1000_SWFW_EEP_SM);
}
+static void e1000_release_eeprom_flash(struct e1000_hw *hw)
+{
+ if (e1000_swfw_sync_release(hw, E1000_SWFW_EEP_SM) < 0)
+ dev_warn(hw->dev,
+ "Timeout while releasing SWFW_SYNC bits (0x%08x)\n",
+ E1000_SWFW_EEP_SM);
+}
+
static int32_t e1000_acquire_eeprom(struct e1000_hw *hw)
{
if (hw->eeprom.acquire)
@@ -305,6 +362,12 @@ static int32_t e1000_acquire_eeprom(struct e1000_hw *hw)
return E1000_SUCCESS;
}
+static void e1000_release_eeprom(struct e1000_hw *hw)
+{
+ if (hw->eeprom.release)
+ hw->eeprom.release(hw);
+}
+
static void e1000_eeprom_uses_spi(struct e1000_eeprom_info *eeprom,
uint32_t eecd)
{
@@ -600,72 +663,6 @@ static int32_t e1000_read_eeprom_microwire(struct e1000_hw *hw,
return E1000_SUCCESS;
}
-static void
-e1000_release_eeprom_spi_microwire_epilogue(struct e1000_hw *hw)
-{
- uint32_t eecd = e1000_read_reg(hw, E1000_EECD);
-
- /* Stop requesting EEPROM access */
- if (hw->mac_type > e1000_82544) {
- eecd &= ~E1000_EECD_REQ;
- e1000_write_reg(hw, E1000_EECD, eecd);
- }
-}
-
-static void e1000_release_eeprom_microwire(struct e1000_hw *hw)
-{
- uint32_t eecd = e1000_read_reg(hw, E1000_EECD);
-
- /* cleanup eeprom */
-
- /* CS on Microwire is active-high */
- eecd &= ~(E1000_EECD_CS | E1000_EECD_DI);
-
- e1000_write_reg(hw, E1000_EECD, eecd);
-
- /* Rising edge of clock */
- eecd |= E1000_EECD_SK;
- e1000_write_reg(hw, E1000_EECD, eecd);
- e1000_write_flush(hw);
- udelay(hw->eeprom.delay_usec);
-
- /* Falling edge of clock */
- eecd &= ~E1000_EECD_SK;
- e1000_write_reg(hw, E1000_EECD, eecd);
- e1000_write_flush(hw);
- udelay(hw->eeprom.delay_usec);
-
-
- e1000_release_eeprom_spi_microwire_epilogue(hw);
-}
-
-static void e1000_release_eeprom_spi(struct e1000_hw *hw)
-{
- uint32_t eecd = e1000_read_reg(hw, E1000_EECD);
-
- eecd |= E1000_EECD_CS; /* Pull CS high */
- eecd &= ~E1000_EECD_SK; /* Lower SCK */
-
- e1000_write_reg(hw, E1000_EECD, eecd);
- udelay(hw->eeprom.delay_usec);
-
- e1000_release_eeprom_spi_microwire_epilogue(hw);
-}
-
-static void e1000_release_eeprom_flash(struct e1000_hw *hw)
-{
- if (e1000_swfw_sync_release(hw, E1000_SWFW_EEP_SM) < 0)
- dev_warn(hw->dev,
- "Timeout while releasing SWFW_SYNC bits (0x%08x)\n",
- E1000_SWFW_EEP_SM);
-}
-
-static void e1000_release_eeprom(struct e1000_hw *hw)
-{
- if (hw->eeprom.release)
- hw->eeprom.release(hw);
-}
-
/******************************************************************************
* Reads a 16 bit word from the EEPROM.
*