From: Vikram Narayanan <vikram186@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/3] tx25: Use generic gpio_* calls
Date: Sun, 10 Jun 2012 18:33:43 +0530 [thread overview]
Message-ID: <4FD49B2F.8090706@gmail.com> (raw)
In-Reply-To: <4FD49AA5.7000303@gmail.com>
Instead of manipulating gpio registers directly, use the calls
from the gpio library.
Signed-off-by: Vikram Narayanan <vikram186@gmail.com>
Cc: John Rigby <jcrigby@gmail.com>
Cc: Stefano Babic <sbabic@denx.de>
---
board/karo/tx25/tx25.c | 28 ++++++++++++----------------
1 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/board/karo/tx25/tx25.c b/board/karo/tx25/tx25.c
index 2a29943..6d03130 100644
--- a/board/karo/tx25/tx25.c
+++ b/board/karo/tx25/tx25.c
@@ -34,14 +34,13 @@
DECLARE_GLOBAL_DATA_PTR;
#ifdef CONFIG_FEC_MXC
+#define GPIO_FEC_RESET_B MXC_GPIO_PORT_TO_NUM(4, 7)
+#define GPIO_FEC_ENABLE_B MXC_GPIO_PORT_TO_NUM(4, 9)
void tx25_fec_init(void)
{
struct iomuxc_mux_ctl *muxctl;
struct iomuxc_pad_ctl *padctl;
- u32 val;
u32 gpio_mux_mode = MX25_PIN_MUX_MODE(5);
- struct gpio_regs *gpio4 = (struct gpio_regs *)IMX_GPIO4_BASE;
- struct gpio_regs *gpio3 = (struct gpio_regs *)IMX_GPIO3_BASE;
u32 saved_rdata0_mode, saved_rdata1_mode, saved_rx_dv_mode;
debug("tx25_fec_init\n");
@@ -66,18 +65,18 @@ void tx25_fec_init(void)
writel(0x0, &padctl->pad_d11);
/* drop PHY power and assert reset (low) */
- val = readl(&gpio4->gpio_dr) & ~((1 << 7) | (1 << 9));
- writel(val, &gpio4->gpio_dr);
- val = readl(&gpio4->gpio_dir) | (1 << 7) | (1 << 9);
- writel(val, &gpio4->gpio_dir);
+ gpio_direction_output(GPIO_FEC_RESET_B, 0);
+ gpio_direction_output(GPIO_FEC_ENABLE_B, 0);
+
+ gpio_direction_output(GPIO_FEC_RESET_B, 1);
+ gpio_direction_output(GPIO_FEC_ENABLE_B, 1);
mdelay(5);
debug("resetting phy\n");
/* turn on PHY power leaving reset asserted */
- val = readl(&gpio4->gpio_dr) | 1 << 9;
- writel(val, &gpio4->gpio_dr);
+ gpio_direction_output(GPIO_FEC_ENABLE_B, 1);
mdelay(10);
@@ -107,19 +106,16 @@ void tx25_fec_init(void)
/*
* set each to 1 and make each an output
*/
- val = readl(&gpio3->gpio_dr) | (1 << 10) | (1 << 11) | (1 << 12);
- writel(val, &gpio3->gpio_dr);
- val = readl(&gpio3->gpio_dir) | (1 << 10) | (1 << 11) | (1 << 12);
- writel(val, &gpio3->gpio_dir);
+ gpio_direction_output(MXC_GPIO_PORT_TO_NUM(3, 10), 1);
+ gpio_direction_output(MXC_GPIO_PORT_TO_NUM(3, 11), 1);
+ gpio_direction_output(MXC_GPIO_PORT_TO_NUM(3, 12), 1);
mdelay(22); /* this value came from RedBoot */
/*
* deassert PHY reset
*/
- val = readl(&gpio4->gpio_dr) | 1 << 7;
- writel(val, &gpio4->gpio_dr);
- writel(val, &gpio4->gpio_dr);
+ gpio_direction_output(GPIO_FEC_RESET_B, 1);
mdelay(5);
--
1.7.4.1
next prev parent reply other threads:[~2012-06-10 13:03 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-10 13:01 [U-Boot] imx: gpio cleanups Vikram Narayanan
2012-06-10 13:02 ` [U-Boot] [PATCH 1/3] imx25: Move MXC_GPIO_PORT_TO_NUM to imx-regs.h Vikram Narayanan
2012-06-10 14:33 ` Fabio Estevam
2012-06-11 15:00 ` Vikram Narayanan
2012-06-11 19:56 ` Troy Kisky
2012-06-10 15:03 ` Fabio Estevam
2012-06-11 15:02 ` Vikram Narayanan
2012-06-13 11:37 ` Fabio Estevam
2012-06-15 14:55 ` Stefano Babic
2012-06-15 18:10 ` Vikram Narayanan
2012-06-15 18:13 ` Fabio Estevam
2012-06-10 13:03 ` Vikram Narayanan [this message]
2012-06-10 14:38 ` [U-Boot] [PATCH 2/3] tx25: Use generic gpio_* calls Fabio Estevam
2012-06-11 14:58 ` Vikram Narayanan
2012-06-11 15:01 ` Fabio Estevam
2012-06-10 13:04 ` [U-Boot] [PATCH 3/3] imx: Define a common header file for gpio.h Vikram Narayanan
2012-06-10 13:06 ` [U-Boot] imx: gpio cleanups Vikram Narayanan
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=4FD49B2F.8090706@gmail.com \
--to=vikram186@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.