public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Peng Fan <Peng.Fan@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 3/4] dm:gpio:mxc add a bank_index entry in platdata
Date: Wed, 21 Jan 2015 19:09:55 +0800	[thread overview]
Message-ID: <1421838596-4176-4-git-send-email-Peng.Fan@freescale.com> (raw)
In-Reply-To: <1421838596-4176-1-git-send-email-Peng.Fan@freescale.com>

Add a new entry in platdata structure and intialize
bank_index in mxc_plat array.
This new entry can avoid using `plat - mxc_plat` by using
`plat->bank_index`.

Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
---
 drivers/gpio/mxc_gpio.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/gpio/mxc_gpio.c b/drivers/gpio/mxc_gpio.c
index 8bb9e39..c52dd19 100644
--- a/drivers/gpio/mxc_gpio.c
+++ b/drivers/gpio/mxc_gpio.c
@@ -23,6 +23,7 @@ enum mxc_gpio_direction {
 #define GPIO_PER_BANK			32
 
 struct mxc_gpio_plat {
+	int bank_index;
 	struct gpio_regs *regs;
 };
 
@@ -259,19 +260,19 @@ static const struct dm_gpio_ops gpio_mxc_ops = {
 };
 
 static const struct mxc_gpio_plat mxc_plat[] = {
-	{ (struct gpio_regs *)GPIO1_BASE_ADDR },
-	{ (struct gpio_regs *)GPIO2_BASE_ADDR },
-	{ (struct gpio_regs *)GPIO3_BASE_ADDR },
+	{ 0, (struct gpio_regs *)GPIO1_BASE_ADDR },
+	{ 1, (struct gpio_regs *)GPIO2_BASE_ADDR },
+	{ 2, (struct gpio_regs *)GPIO3_BASE_ADDR },
 #if defined(CONFIG_MX25) || defined(CONFIG_MX27) || defined(CONFIG_MX51) || \
 		defined(CONFIG_MX53) || defined(CONFIG_MX6)
-	{ (struct gpio_regs *)GPIO4_BASE_ADDR },
+	{ 3, (struct gpio_regs *)GPIO4_BASE_ADDR },
 #endif
 #if defined(CONFIG_MX27) || defined(CONFIG_MX53) || defined(CONFIG_MX6)
-	{ (struct gpio_regs *)GPIO5_BASE_ADDR },
-	{ (struct gpio_regs *)GPIO6_BASE_ADDR },
+	{ 4, (struct gpio_regs *)GPIO5_BASE_ADDR },
+	{ 5, (struct gpio_regs *)GPIO6_BASE_ADDR },
 #endif
 #if defined(CONFIG_MX53) || defined(CONFIG_MX6)
-	{ (struct gpio_regs *)GPIO7_BASE_ADDR },
+	{ 6, (struct gpio_regs *)GPIO7_BASE_ADDR },
 #endif
 };
 
@@ -283,7 +284,7 @@ static int mxc_gpio_probe(struct udevice *dev)
 	int banknum;
 	char name[18], *str;
 
-	banknum = plat - mxc_plat;
+	banknum = plat->bank_index;
 	sprintf(name, "GPIO%d_", banknum + 1);
 	str = strdup(name);
 	if (!str)
-- 
1.8.4

  parent reply	other threads:[~2015-01-21 11:09 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-21 11:09 [U-Boot] [PATCH v3 0/4] dm:gpio:mxc add DT support Peng Fan
2015-01-21 11:09 ` [U-Boot] [PATCH v3 1/4] dm: introduce dev_get_addr interface Peng Fan
2015-01-21 11:58   ` Igor Grinberg
2015-01-22 21:25   ` Simon Glass
2015-02-06  6:44     ` Peng Fan
2015-02-06 15:45       ` Simon Glass
2015-01-21 11:09 ` [U-Boot] [PATCH v3 2/4] dm: add dev_get_addr prototype Peng Fan
2015-01-21 11:59   ` Igor Grinberg
2015-01-21 11:09 ` Peng Fan [this message]
2015-01-21 12:01   ` [U-Boot] [PATCH v3 3/4] dm:gpio:mxc add a bank_index entry in platdata Igor Grinberg
2015-01-22 21:27   ` Simon Glass
2015-01-21 11:09 ` [U-Boot] [PATCH v3 4/4] dm:gpio:mxc add DT support Peng Fan
2015-01-22  1:06   ` Peng Fan
2015-01-22  8:38     ` Igor Grinberg
2015-01-22 18:56       ` Peng Fan
2015-01-22 21:26   ` Simon Glass
2015-01-24 14:34     ` Peng Fan
2015-01-26 13:38       ` Simon Glass

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=1421838596-4176-4-git-send-email-Peng.Fan@freescale.com \
    --to=peng.fan@freescale.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