From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 0/2] arm nomadik: gpio and i2c
Date: Mon, 20 Jul 2009 09:40:43 +0200 [thread overview]
Message-ID: <4A641F7B.1000508@denx.de> (raw)
In-Reply-To: <cover.1247999841.git.rubini@unipv.it>
Hello Alessandro,
Alessandro Rubini wrote:
> This adds gpio and i2c support for the Nomadik evaluation kit. They
> are needed to turn on the LCD backlight in order to later add LCD
> support.
>
> I have one doubt and some questions on gpio:
>
> To use soft_i2c I need to define some macros in the config file.
> Instead of writing hard numbers there I called the gpio functions, but
> the config file is inluded from asm sources as well. I don't think my
> approach is beautiful at all (both #ifndef __ASSEMBLY__ and #include
> "../board/"), but I didn't find a better solution.
Yes, thats a problem ... if we had a GPIO Framework it would be solved
by including gpio.h ...
Or, maybe, we can make a soft_i2c.h which which gets only included
if saying CONFIG_I2C_SOFT_INCLUDE is defined. soft_i2c.h defines for
example:
#define I2C_SDA(x) i2c_soft_sda(bit)
void i2c_soft_sda(int pin);
and you can define this function i2c_soft_sda(int pin) in your board
specific code ... maybe a cleaner option?
to speak in c, I tried the following patch on the suen3 plattform,
where I have actually a similiar problem, and this worked fine :-)
[PATCH] i2c, soft: added soft_i2c.h
In case you must define functions for the I2C_XXX
defines, it is necessary to have a soft_i2c.h, which
defines functions for this macros. This functions can
then be programmed in board specific code. To activate
this it must be CONFIG_I2C_SOFT_INCLUDE defined in the
board config file.
Signed-off-by: Heiko Schocher <hs@denx.de>
---
drivers/i2c/soft_i2c.c | 3 +++
include/soft_i2c.h | 16 ++++++++++++++++
2 files changed, 19 insertions(+), 0 deletions(-)
create mode 100644 include/soft_i2c.h
diff --git a/drivers/i2c/soft_i2c.c b/drivers/i2c/soft_i2c.c
index 59883a5..30e24f3 100644
--- a/drivers/i2c/soft_i2c.c
+++ b/drivers/i2c/soft_i2c.c
@@ -43,6 +43,9 @@
#if defined(CONFIG_MPC852T) || defined(CONFIG_MPC866)
#include <asm/io.h>
#endif
+#if defined(CONFIG_SOFT_I2C_INCLUDE)
+#include <soft_i2c.h>
+#endif
#include <i2c.h>
/* #define DEBUG_I2C */
diff --git a/include/soft_i2c.h b/include/soft_i2c.h
new file mode 100644
index 0000000..39f9a35
--- /dev/null
+++ b/include/soft_i2c.h
@@ -0,0 +1,16 @@
+#ifndef _CONFIG_SOFT_I2C
+#define _CONFIG_SOFT_I2C
+#define I2C_ACTIVE i2c_soft_active();
+#define I2C_TRISTATE i2c_soft_tristate();
+#define I2C_READ i2c_soft_read();
+#define I2C_SDA(bit) i2c_soft_sda(bit);
+#define I2C_SCL(bit) i2c_soft_scl(bit);
+#define I2C_DELAY i2c_soft_delay();
+
+void i2c_soft_active(void);
+void i2c_soft_tristate(void);
+int i2c_soft_read(void);
+void i2c_soft_sda(int value);
+void i2c_soft_scl(int value);
+void i2c_soft_delay(void);
+#endif
--
1.6.0.GIT
Maybe you can try it too?
> I would like to add a gpio command, and I've found no generic gpio
> stuff. Only one board (cm-bf527) has a gpio commands, but quite a few
> have similar commands to set leds or other bits. Is time ripe for a
> generic gpio driver with board-specific limits and operations? Would
> that be interesting for u-boot-next? Should I process with a board-specific
> gpio command by now?
I vote for making a gpio framework, but that will take a while I think ...
Hmm.. maybe we use my proposal for such a soft_i2c.h, so I think, it is
okay for such a board specific gpio (unless we have a gpio framework).
bye
Heiko
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
next prev parent reply other threads:[~2009-07-20 7:40 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-19 11:01 [U-Boot] [PATCH 0/2] arm nomadik: gpio and i2c Alessandro Rubini
2009-07-19 17:13 ` Wolfgang Denk
2009-07-20 7:55 ` Heiko Schocher
2009-07-20 8:09 ` Alessandro Rubini
2009-07-20 9:23 ` Heiko Schocher
2009-07-20 9:31 ` Alessandro Rubini
2009-07-20 9:48 ` Heiko Schocher
2009-07-20 15:14 ` Wolfgang Denk
2009-07-21 6:31 ` Heiko Schocher
2009-07-20 15:12 ` Wolfgang Denk
2009-07-21 6:11 ` Heiko Schocher
2009-07-21 7:19 ` Wolfgang Denk
2009-07-20 7:40 ` Heiko Schocher [this message]
2009-07-28 7:16 ` Daniel Gorsulowski
2009-07-28 9:39 ` Jean-Christophe PLAGNIOL-VILLARD
2009-07-28 10:25 ` Heiko Schocher
2009-07-28 10:55 ` Wolfgang Denk
2009-07-28 13:02 ` Heiko Schocher
2009-07-28 13:22 ` Wolfgang Denk
2009-07-28 13:49 ` Heiko Schocher
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=4A641F7B.1000508@denx.de \
--to=hs@denx.de \
--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