From: Chris Packham <judge.packham@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] i2c: mvtwsi: avoid writing to twsi_control_flags prior to relocation
Date: Thu, 12 May 2016 14:55:59 +1200 [thread overview]
Message-ID: <1463021759-9966-2-git-send-email-judge.packham@gmail.com> (raw)
In-Reply-To: <1463021759-9966-1-git-send-email-judge.packham@gmail.com>
In a system where the initial u-boot location is genuinely NOR flash (as
opposed to RAM or a cache-line setup by a pre-bootloader) writes to the
data section are problematic. At best these writes have no effect at
worse they put the flash memory into a status mode which changes the
executable code underneath us.
Only write to twsi_control_flags once we know we've relocated to RAM.
Signed-off-by: Chris Packham <judge.packham@gmail.com>
---
drivers/i2c/mvtwsi.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/mvtwsi.c b/drivers/i2c/mvtwsi.c
index 221ff4f..aee28c4 100644
--- a/drivers/i2c/mvtwsi.c
+++ b/drivers/i2c/mvtwsi.c
@@ -28,6 +28,8 @@
#error Driver mvtwsi not supported by SoC or board
#endif
+DECLARE_GLOBAL_DATA_PTR;
+
/*
* TWSI register structure
*/
@@ -297,7 +299,8 @@ static void twsi_reset(struct i2c_adapter *adap)
{
struct mvtwsi_registers *twsi = twsi_get_base(adap);
/* ensure controller will be enabled by any twsi*() function */
- twsi_control_flags = MVTWSI_CONTROL_TWSIEN;
+ if (gd->flags & GD_FLG_RELOC)
+ twsi_control_flags = MVTWSI_CONTROL_TWSIEN;
/* reset controller */
writel(0, &twsi->soft_reset);
/* wait 2 ms -- this is what the Marvell LSP does */
--
2.8.2
next prev parent reply other threads:[~2016-05-12 2:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-12 2:55 [U-Boot] [PATCH 0/1] i2c: mvtwsi: running from flash ROM Chris Packham
2016-05-12 2:55 ` Chris Packham [this message]
2016-05-12 9:50 ` [U-Boot] [PATCH] i2c: mvtwsi: avoid writing to twsi_control_flags prior to relocation Stefan Roese
2016-05-12 22:35 ` Chris Packham
2016-05-13 1:20 ` Chris Packham
2016-05-13 5:49 ` Stefan Roese
2016-05-13 3:19 ` [U-Boot] [PATCH v2] i2c: mvtwsi: Eliminate twsi_control_flags Chris Packham
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1463021759-9966-2-git-send-email-judge.packham@gmail.com \
--to=judge.packham@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox