mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2 0/3] e1000: fix access to companion flash chip
@ 2017-10-09 19:06 Uwe Kleine-König
  2017-10-09 19:06 ` [PATCH v2 1/3] e1000: implement register mapping for E1000_FLSW{CTL, DATA, CNT} Uwe Kleine-König
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2017-10-09 19:06 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Hello,

this is v2 of the series. Compared to (implicit) v1 I worked in Andrey's
feedback and updated the commit logs. The third patch is not marked as
HACK any more (and got some reformatting). In the mean time I also
tested successfully the write support. For NDA reasons I don't have
access to firmware, so making full use of a i210 after flashing is not
tested yet.

Even though I changed a few bits in the first two patches, I already
added the acks by Andrey that I got for v1.

Best regards
Uwe

Uwe Kleine-König (3):
  e1000: implement register mapping for E1000_FLSW{CTL,DATA,CNT}
  e1000: implement support for smaller flash chips
  e1000: Don't poll for FLSWCTL.GLDONE before starting a flash
    transaction

 drivers/net/e1000/e1000.h  |  9 +++------
 drivers/net/e1000/eeprom.c | 27 +++++----------------------
 drivers/net/e1000/regio.c  |  9 +++++++++
 3 files changed, 17 insertions(+), 28 deletions(-)

-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/3] e1000: implement register mapping for E1000_FLSW{CTL, DATA, CNT}
  2017-10-09 19:06 [PATCH v2 0/3] e1000: fix access to companion flash chip Uwe Kleine-König
@ 2017-10-09 19:06 ` Uwe Kleine-König
  2017-10-09 19:06 ` [PATCH v2 2/3] e1000: implement support for smaller flash chips Uwe Kleine-König
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2017-10-09 19:06 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Fixes: 4ff3269a70b5 ("e1000: Expose i210's external flash as MTD")
Acked-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/net/e1000/e1000.h | 6 +++---
 drivers/net/e1000/regio.c | 9 +++++++++
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/net/e1000/e1000.h b/drivers/net/e1000/e1000.h
index e6b493c84cc1..45514629dd72 100644
--- a/drivers/net/e1000/e1000.h
+++ b/drivers/net/e1000/e1000.h
@@ -447,11 +447,11 @@ struct e1000_tx_desc {
 #define E1000_FLASHT   0x01028  /* FLASH Timer Register */
 #define E1000_EEWR     (E1000_MIGHT_BE_REMAPPED | 0x0102C)  /* EEPROM Write Register - RW */
 #define E1000_I210_EEWR     0x12018  /* EEPROM Write Register - RW */
-#define E1000_FLSWCTL  0x01030  /* FLASH control register */
+#define E1000_FLSWCTL  (E1000_MIGHT_BE_REMAPPED | 0x01030)  /* FLASH control register */
 #define E1000_I210_FLSWCTL 0x12048  /* FLASH control register */
-#define E1000_FLSWDATA 0x01034  /* FLASH data register */
+#define E1000_FLSWDATA (E1000_MIGHT_BE_REMAPPED | 0x01034)  /* FLASH data register */
 #define E1000_I210_FLSWDATA 0x1204C  /* FLASH data register */
-#define E1000_FLSWCNT  0x01038  /* FLASH Access Counter */
+#define E1000_FLSWCNT  (E1000_MIGHT_BE_REMAPPED | 0x01038)  /* FLASH Access Counter */
 #define E1000_I210_FLSWCNT  0x12050  /* FLASH Access Counter */
 #define E1000_FLOP     0x0103C  /* FLASH Opcode Register */
 #define E1000_ERT      0x02008  /* Early Rx Threshold - RW */
diff --git a/drivers/net/e1000/regio.c b/drivers/net/e1000/regio.c
index 1610d5851f05..5b2740fbc289 100644
--- a/drivers/net/e1000/regio.c
+++ b/drivers/net/e1000/regio.c
@@ -16,6 +16,15 @@ static uint32_t e1000_true_offset(struct e1000_hw *hw, uint32_t reg)
 			case E1000_EEMNGCTL:
 				reg = E1000_I210_EEMNGCTL;
 				break;
+			case E1000_FLSWCTL:
+				reg = E1000_I210_FLSWCTL;
+				break;
+			case E1000_FLSWCNT:
+				reg = E1000_I210_FLSWCNT;
+				break;
+			case E1000_FLSWDATA:
+				reg = E1000_I210_FLSWDATA;
+				break;
 			}
 		}
 		reg &= ~E1000_MIGHT_BE_REMAPPED;
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 2/3] e1000: implement support for smaller flash chips
  2017-10-09 19:06 [PATCH v2 0/3] e1000: fix access to companion flash chip Uwe Kleine-König
  2017-10-09 19:06 ` [PATCH v2 1/3] e1000: implement register mapping for E1000_FLSW{CTL, DATA, CNT} Uwe Kleine-König
@ 2017-10-09 19:06 ` Uwe Kleine-König
  2017-10-09 19:06 ` [PATCH v2 3/3] e1000: Don't poll for FLSWCTL.GLDONE before starting a flash transaction Uwe Kleine-König
  2017-10-16  8:26 ` [PATCH v2 0/3] e1000: fix access to companion flash chip Sascha Hauer
  3 siblings, 0 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2017-10-09 19:06 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Even though the register description of the FLA register suggests (on
page 386 of the i210 datasheet (rev. 3.1)) that 2 MB, 4 MB and 8 MB are
the only supported flash sizes, the list of supported flashes (on page
794 of the same document) lists for example a Micron M25PE80 which only
has a size of 1 MB.

Also in general it seems sensible to stick to the formula given for the
meaning of the values that are not explicitly listed.

Acked-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/net/e1000/e1000.h  |  3 ---
 drivers/net/e1000/eeprom.c | 14 +++-----------
 2 files changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/net/e1000/e1000.h b/drivers/net/e1000/e1000.h
index 45514629dd72..f2da08b4d5c1 100644
--- a/drivers/net/e1000/e1000.h
+++ b/drivers/net/e1000/e1000.h
@@ -2105,9 +2105,6 @@ struct e1000_eeprom_info {
 #define E1000_FLA			0x1201C
 #define E1000_FLA_FL_SIZE_SHIFT		17
 #define E1000_FLA_FL_SIZE_MASK		(0b111 << E1000_FLA_FL_SIZE_SHIFT) /* EEprom Size */
-#define E1000_FLA_FL_SIZE_2MB		0b101
-#define E1000_FLA_FL_SIZE_4MB		0b110
-#define E1000_FLA_FL_SIZE_8MB		0b111
 
 
 #define E1000_FLSWCTL_ADDR(a)		((a) & 0x00FFFFFF)
diff --git a/drivers/net/e1000/eeprom.c b/drivers/net/e1000/eeprom.c
index 1a0c6e15abef..739bc17a519e 100644
--- a/drivers/net/e1000/eeprom.c
+++ b/drivers/net/e1000/eeprom.c
@@ -414,17 +414,9 @@ int32_t e1000_init_eeprom_params(struct e1000_hw *hw)
 			fla &= E1000_FLA_FL_SIZE_MASK;
 			fla >>= E1000_FLA_FL_SIZE_SHIFT;
 
-			switch (fla) {
-			case E1000_FLA_FL_SIZE_8MB:
-				eeprom->word_size = SZ_8M / 2;
-				break;
-			case E1000_FLA_FL_SIZE_4MB:
-				eeprom->word_size = SZ_4M / 2;
-				break;
-			case E1000_FLA_FL_SIZE_2MB:
-				eeprom->word_size = SZ_2M / 2;
-				break;
-			default:
+			if (fla) {
+				eeprom->word_size = (SZ_64K << fla) / 2;
+			} else {
 				eeprom->word_size = 2048;
 				dev_info(hw->dev, "Unprogrammed Flash detected, "
 					 "limiting access to first 4KB\n");
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 3/3] e1000: Don't poll for FLSWCTL.GLDONE before starting a flash transaction
  2017-10-09 19:06 [PATCH v2 0/3] e1000: fix access to companion flash chip Uwe Kleine-König
  2017-10-09 19:06 ` [PATCH v2 1/3] e1000: implement register mapping for E1000_FLSW{CTL, DATA, CNT} Uwe Kleine-König
  2017-10-09 19:06 ` [PATCH v2 2/3] e1000: implement support for smaller flash chips Uwe Kleine-König
@ 2017-10-09 19:06 ` Uwe Kleine-König
  2017-10-16  8:26 ` [PATCH v2 0/3] e1000: fix access to companion flash chip Sascha Hauer
  3 siblings, 0 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2017-10-09 19:06 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

While FLSWCTL.GLDONE is set when the last transaction was fully
completed, there is no good reason to depend on this. According to the
i210 datasheet having FLSWCTL.DONE is enough.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/net/e1000/eeprom.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/net/e1000/eeprom.c b/drivers/net/e1000/eeprom.c
index 739bc17a519e..2a71fb1b159c 100644
--- a/drivers/net/e1000/eeprom.c
+++ b/drivers/net/e1000/eeprom.c
@@ -701,17 +701,8 @@ static int32_t e1000_spi_eeprom_ready(struct e1000_hw *hw)
 
 static int e1000_flash_mode_wait_for_idle(struct e1000_hw *hw)
 {
-	/* Strictly speaking we need to poll FLSWCTL.DONE only if we
-	 * are executing this code after a reset event, but it
-	 * shouldn't hurt to do this everytime, besided we need to
-	 * poll got FLSWCTL.GLDONE to make sure that back to back
-	 * calls to that function work correctly, since we finish
-	 * execution by polling only FLSWCTL.DONE */
-
-	const int ret = e1000_poll_reg(hw, E1000_FLSWCTL,
-				       E1000_FLSWCTL_DONE | E1000_FLSWCTL_GLDONE,
-				       E1000_FLSWCTL_DONE | E1000_FLSWCTL_GLDONE,
-				       SECOND);
+	const int ret = e1000_poll_reg(hw, E1000_FLSWCTL, E1000_FLSWCTL_DONE,
+				       E1000_FLSWCTL_DONE, SECOND);
 	if (ret < 0)
 		dev_err(hw->dev,
 			"Timeout waiting for FLSWCTL.DONE to be set\n");
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 0/3] e1000: fix access to companion flash chip
  2017-10-09 19:06 [PATCH v2 0/3] e1000: fix access to companion flash chip Uwe Kleine-König
                   ` (2 preceding siblings ...)
  2017-10-09 19:06 ` [PATCH v2 3/3] e1000: Don't poll for FLSWCTL.GLDONE before starting a flash transaction Uwe Kleine-König
@ 2017-10-16  8:26 ` Sascha Hauer
  3 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2017-10-16  8:26 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: Andrey Smirnov, barebox

On Mon, Oct 09, 2017 at 09:06:24PM +0200, Uwe Kleine-König wrote:
> Hello,
> 
> this is v2 of the series. Compared to (implicit) v1 I worked in Andrey's
> feedback and updated the commit logs. The third patch is not marked as
> HACK any more (and got some reformatting). In the mean time I also
> tested successfully the write support. For NDA reasons I don't have
> access to firmware, so making full use of a i210 after flashing is not
> tested yet.
> 
> Even though I changed a few bits in the first two patches, I already
> added the acks by Andrey that I got for v1.
> 
> Best regards
> Uwe
> 
> Uwe Kleine-König (3):
>   e1000: implement register mapping for E1000_FLSW{CTL,DATA,CNT}
>   e1000: implement support for smaller flash chips
>   e1000: Don't poll for FLSWCTL.GLDONE before starting a flash
>     transaction

Applied, thanks

Sascha

> 
>  drivers/net/e1000/e1000.h  |  9 +++------
>  drivers/net/e1000/eeprom.c | 27 +++++----------------------
>  drivers/net/e1000/regio.c  |  9 +++++++++
>  3 files changed, 17 insertions(+), 28 deletions(-)
> 
> -- 
> 2.11.0
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-10-16  8:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-09 19:06 [PATCH v2 0/3] e1000: fix access to companion flash chip Uwe Kleine-König
2017-10-09 19:06 ` [PATCH v2 1/3] e1000: implement register mapping for E1000_FLSW{CTL, DATA, CNT} Uwe Kleine-König
2017-10-09 19:06 ` [PATCH v2 2/3] e1000: implement support for smaller flash chips Uwe Kleine-König
2017-10-09 19:06 ` [PATCH v2 3/3] e1000: Don't poll for FLSWCTL.GLDONE before starting a flash transaction Uwe Kleine-König
2017-10-16  8:26 ` [PATCH v2 0/3] e1000: fix access to companion flash chip Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox