From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 2/3] animeo_ip: ensure the phy is reset correctly
Date: Fri, 20 Sep 2013 07:47:44 +0200 [thread overview]
Message-ID: <1379656065-23690-2-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <1379656065-23690-1-git-send-email-plagnioj@jcrosoft.com>
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
arch/arm/boards/animeo_ip/init.c | 38 +++++++++++++++++++++++++++++++++++++-
1 file changed, 37 insertions(+), 1 deletion(-)
diff --git a/arch/arm/boards/animeo_ip/init.c b/arch/arm/boards/animeo_ip/init.c
index 5419ddb..65fc0e6 100644
--- a/arch/arm/boards/animeo_ip/init.c
+++ b/arch/arm/boards/animeo_ip/init.c
@@ -19,6 +19,7 @@
#include <nand.h>
#include <sizes.h>
#include <linux/mtd/nand.h>
+#include <linux/clk.h>
#include <mach/board.h>
#include <mach/at91sam9_smc.h>
#include <gpio.h>
@@ -225,12 +226,45 @@ static void animeo_ip_power_control(void)
animeo_export_gpio_out(AT91_PIN_PC4, "power_save");
}
+static void animeo_ip_phy_reset(void)
+{
+ unsigned long rstc;
+ int i;
+ struct clk *clk = clk_get(NULL, "macb_clk");
+
+ clk_enable(clk);
+
+ for (i = AT91_PIN_PA12; i <= AT91_PIN_PA29; i++)
+ at91_set_gpio_input(i, 0);
+
+ rstc = at91_sys_read(AT91_RSTC_MR) & AT91_RSTC_ERSTL;
+
+ /* Need to reset PHY -> 500ms reset */
+ at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY |
+ (AT91_RSTC_ERSTL & (0x0d << 8)) |
+ AT91_RSTC_URSTEN);
+
+ at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_EXTRST);
+
+ /* Wait for end hardware reset */
+ while (!(at91_sys_read(AT91_RSTC_SR) & AT91_RSTC_NRSTL))
+ ;
+
+ /* Restore NRST value */
+ at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY | (rstc) | AT91_RSTC_URSTEN);
+}
+
+static void animeo_ip_add_device_eth(void)
+{
+ animeo_ip_phy_reset();
+ at91_add_device_eth(0, &macb_pdata);
+}
+
static int animeo_ip_devices_init(void)
{
animeo_ip_detect_version();
animeo_ip_power_control();
animeo_ip_add_device_nand();
- at91_add_device_eth(0, &macb_pdata);
animeo_ip_add_device_usb();
animeo_ip_add_device_mci();
animeo_ip_add_device_buttons();
@@ -250,6 +284,8 @@ static int animeo_ip_devices_init(void)
devfs_add_partition("nand0", SZ_256K + SZ_32K, SZ_32K, DEVFS_PARTITION_FIXED, "env_raw");
dev_add_bb_dev("env_raw", "env0");
+ animeo_ip_add_device_eth();
+
return 0;
}
--
1.8.4.rc1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2013-09-20 5:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-20 5:46 [PATCH 0/3 v2] Animeo IP: macb support improvement Jean-Christophe PLAGNIOL-VILLARD
2013-09-20 5:47 ` [PATCH 1/3] introduce helper to generate mac address with OUI Jean-Christophe PLAGNIOL-VILLARD
2013-09-20 5:47 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2013-09-23 4:38 ` [PATCH 2/3] animeo_ip: ensure the phy is reset correctly Jean-Christophe PLAGNIOL-VILLARD
2013-09-23 6:42 ` Sascha Hauer
2013-09-20 5:47 ` [PATCH 3/3] animeo_ip: retrieve the mac from the macb and set private mac to asix Jean-Christophe PLAGNIOL-VILLARD
2013-09-20 7:04 ` [PATCH 1/3] introduce helper to generate mac address with OUI Sascha Hauer
2013-09-20 7:44 ` Jean-Christophe PLAGNIOL-VILLARD
2013-09-22 18:28 ` Sascha Hauer
-- strict thread matches above, loose matches on Subject: below --
2013-09-20 5:39 [PATCH 0/3] Animeo IP: macb support improvement Jean-Christophe PLAGNIOL-VILLARD
2013-09-20 5:40 ` [PATCH 1/3] introduce helper to generate mac address with OUI Jean-Christophe PLAGNIOL-VILLARD
2013-09-20 5:40 ` [PATCH 2/3] animeo_ip: ensure the phy is reset correctly Jean-Christophe PLAGNIOL-VILLARD
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=1379656065-23690-2-git-send-email-plagnioj@jcrosoft.com \
--to=plagnioj@jcrosoft.com \
--cc=barebox@lists.infradead.org \
/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