All of lore.kernel.org
 help / color / mirror / Atom feed
From: Detlev Zundel <dzu@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 6/7] inka4x0: Add hardware diagnosis and RTC in configuration.
Date: Wed, 25 Mar 2009 17:27:57 +0100	[thread overview]
Message-ID: <1237998478-18452-7-git-send-email-dzu@denx.de> (raw)
In-Reply-To: <1237998478-18452-6-git-send-email-dzu@denx.de>

This patch adds the board specific communication routines needed by
the external 4543 RTC.

Signed-off-by: Detlev Zundel <dzu@denx.de>
Signed-off-by: Andreas Pfefferle <ap@denx.de>
---
 board/inka4x0/inka4x0.c   |   20 ++++++++++
 include/configs/inka4x0.h |   90 ++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 105 insertions(+), 5 deletions(-)

diff --git a/board/inka4x0/inka4x0.c b/board/inka4x0/inka4x0.c
index bb5c25d..a8bc3b3 100644
--- a/board/inka4x0/inka4x0.c
+++ b/board/inka4x0/inka4x0.c
@@ -33,6 +33,7 @@
  * MA 02111-1307 USA
  */
 
+#include <asm/io.h>
 #include <common.h>
 #include <mpc5xxx.h>
 #include <pci.h>
@@ -189,6 +190,8 @@ int misc_init_r (void) {
 
 int misc_init_f (void)
 {
+	struct mpc5xxx_gpio *gpio = (struct mpc5xxx_gpio *)MPC5XXX_GPIO;
+	struct mpc5xxx_wu_gpio *wu_gpio = (struct mpc5xxx_wu_gpio *)MPC5XXX_WU_GPIO;
 	char tmp[10];
 	int i, br;
 
@@ -236,6 +239,23 @@ int misc_init_f (void)
 	*(vu_long *) MPC5XXX_WU_GPIO_ENABLE |= GPIO_PSC3_9;
 	*(vu_long *) MPC5XXX_WU_GPIO_DIR    |= GPIO_PSC3_9;
 	*(vu_long *) MPC5XXX_WU_GPIO_DATA_O   |= GPIO_PSC3_9;
+
+	/*
+	 * Configure three wire serial interface to RTC (PSC1_4,
+	 * PSC2_4, PSC3_4, PSC3_5)
+	 */
+	setbits_8(&wu_gpio->enable,  MPC5XXX_GPIO_WKUP_PSC1_4 |
+				     MPC5XXX_GPIO_WKUP_PSC2_4);
+	setbits_8(&wu_gpio->ddr,     MPC5XXX_GPIO_WKUP_PSC1_4 |
+				     MPC5XXX_GPIO_WKUP_PSC2_4);
+	clrbits_8(&wu_gpio->dvo,     MPC5XXX_GPIO_WKUP_PSC1_4);
+	clrbits_8(&gpio->sint_inten, MPC5XXX_GPIO_SINT_PSC3_4 |
+				     MPC5XXX_GPIO_SINT_PSC3_5);
+	setbits_8(&gpio->sint_gpioe, MPC5XXX_GPIO_SINT_PSC3_4 |
+				     MPC5XXX_GPIO_SINT_PSC3_5);
+	setbits_8(&gpio->sint_ddr,   MPC5XXX_GPIO_SINT_PSC3_5);
+	clrbits_8(&gpio->sint_dvo,   MPC5XXX_GPIO_SINT_PSC3_5);
+
 	return 0;
 }
 
diff --git a/include/configs/inka4x0.h b/include/configs/inka4x0.h
index b80796d..5f06b09 100644
--- a/include/configs/inka4x0.h
+++ b/include/configs/inka4x0.h
@@ -1,4 +1,7 @@
 /*
+ * (C) Copyright 2009
+ * Detlev Zundel, DENX Software Engineering, dzu at denx.de.
+ *
  * (C) Copyright 2003-2005
  * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
  *
@@ -90,16 +93,17 @@
  */
 #include <config_cmd_default.h>
 
+#define CONFIG_CMD_DATE
 #define CONFIG_CMD_DHCP
 #define CONFIG_CMD_EXT2
 #define CONFIG_CMD_FAT
 #define CONFIG_CMD_IDE
 #define CONFIG_CMD_NFS
 #define CONFIG_CMD_PCI
+#define CONFIG_CMD_PING
 #define CONFIG_CMD_SNTP
 #define CONFIG_CMD_USB
 
-
 #define	CONFIG_TIMESTAMP	1	/* Print image info with timestamp */
 
 #if (TEXT_BASE == 0xFFE00000)		/* Boot low */
@@ -240,15 +244,91 @@
  *	01 -> CAN1 on I2C1, CAN2 on Tmr0/1 do not use on TQM5200 with onboard
  *	      EEPROM
  * use PSC1 as UART: Bits 28-31 (mask: 0x00000007): 0100
- * use PSC6_1 and PSC6_3 as GPIO: Bits 9:11 (mask: 0x07000000):
- *	011 -> PSC6 could not be used as UART or CODEC. IrDA still possible.
+ * use PSC2 as UART: Bits 24-27 (mask: 0x00000070): 0100
+ * use PSC3 as UART: Bits 20-23 (mask: 0x00000700): 0100
+ * use PSC6 as UART: Bits  9-11 (mask: 0x00700000): 0101
  */
-#define CONFIG_SYS_GPS_PORT_CONFIG	0x01001004
+#define CONFIG_SYS_GPS_PORT_CONFIG	0x01501444
 
 /*
  * RTC configuration
  */
-#define CONFIG_RTC_MPC5200	1	/* use internal MPC5200 RTC */
+#define CONFIG_RTC_RTC4543 	1	/* use external RTC */
+
+/*
+ * Software (bit-bang) three wire serial configuration
+ *
+ * Note that we need the ifdefs because otherwise compilation of
+ * mkimage.c fails.
+ */
+#define CONFIG_SOFT_TWS		1
+
+#ifdef TWS_IMPLEMENTATION
+#include <mpc5xxx.h>
+#include <asm/io.h>
+
+#define TWS_CE		MPC5XXX_GPIO_WKUP_PSC1_4 /* GPIO_WKUP_0 */
+#define TWS_WR		MPC5XXX_GPIO_WKUP_PSC2_4 /* GPIO_WKUP_1 */
+#define TWS_DATA	MPC5XXX_GPIO_SINT_PSC3_4 /* GPIO_SINT_0 */
+#define TWS_CLK		MPC5XXX_GPIO_SINT_PSC3_5 /* GPIO_SINT_1 */
+
+static inline void tws_ce(unsigned bit)
+{
+	struct mpc5xxx_wu_gpio *wu_gpio =
+		(struct mpc5xxx_wu_gpio *)MPC5XXX_WU_GPIO;
+	if (bit)
+		setbits_8(&wu_gpio->dvo, TWS_CE);
+	else
+		clrbits_8(&wu_gpio->dvo, TWS_CE);
+}
+
+static inline void tws_wr(unsigned bit)
+{
+	struct mpc5xxx_wu_gpio *wu_gpio =
+		(struct mpc5xxx_wu_gpio *)MPC5XXX_WU_GPIO;
+	if (bit)
+		setbits_8(&wu_gpio->dvo, TWS_WR);
+	else
+		clrbits_8(&wu_gpio->dvo, TWS_WR);
+}
+
+static inline void tws_clk(unsigned bit)
+{
+	struct mpc5xxx_gpio *gpio =
+		(struct mpc5xxx_gpio *)MPC5XXX_GPIO;
+	if (bit)
+		setbits_8(&gpio->sint_dvo, TWS_CLK);
+	else
+		clrbits_8(&gpio->sint_dvo, TWS_CLK);
+}
+
+static inline void tws_data(unsigned bit)
+{
+	struct mpc5xxx_gpio *gpio =
+		(struct mpc5xxx_gpio *)MPC5XXX_GPIO;
+	if (bit)
+		setbits_8(&gpio->sint_dvo, TWS_DATA);
+	else
+		clrbits_8(&gpio->sint_dvo, TWS_DATA);
+}
+
+static inline unsigned tws_data_read(void)
+{
+	struct mpc5xxx_gpio *gpio =
+			(struct mpc5xxx_gpio *)MPC5XXX_GPIO;
+	return !!(in_8(&gpio->sint_ival) & TWS_DATA);
+}
+
+static inline void tws_data_config_output(unsigned output)
+{
+	struct mpc5xxx_gpio *gpio =
+		(struct mpc5xxx_gpio *)MPC5XXX_GPIO;
+	if (output)
+		setbits_8(&gpio->sint_ddr, TWS_DATA);
+	else
+		clrbits_8(&gpio->sint_ddr, TWS_DATA);
+}
+#endif /* TWS_IMPLEMENTATION */
 
 /*
  * Miscellaneous configurable options
-- 
1.6.0.6

  reply	other threads:[~2009-03-25 16:27 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-25 16:27 [U-Boot] [PATCH v2 0/7] Update for inka4x0 plus some new features Detlev Zundel
2009-03-25 16:27 ` [U-Boot] [PATCH v2 1/7] command.c: Expose the core of do_help as _do_help to the rest of u-boot Detlev Zundel
2009-03-25 16:27   ` [U-Boot] [PATCH v2 2/7] mpc5xxx: Add structure definition for several more register blocks Detlev Zundel
2009-03-25 16:27     ` [U-Boot] [PATCH v2 3/7] drivers/twserial: Add protocol driver for "three wire serial" interface Detlev Zundel
2009-03-25 16:27       ` [U-Boot] [PATCH v2 4/7] rtc: add support for 4543 RTC (manufactured by e.g. EPSON) Detlev Zundel
2009-03-25 16:27         ` [U-Boot] [PATCH v2 5/7] inka4x0: Add hardware diagnosis functions for inka4x0 Detlev Zundel
2009-03-25 16:27           ` Detlev Zundel [this message]
2009-03-25 16:27             ` [U-Boot] [PATCH v2 7/7] inka4x0: Use proper accessor macros for memory mapped registers Detlev Zundel
2009-03-27 10:33         ` [U-Boot] [PATCH v2 4/7] rtc: add support for 4543 RTC (manufactured by e.g. EPSON) Anatolij Gustschin
2009-03-27 10:51           ` Wolfgang Denk
2009-03-27 11:13           ` Detlev Zundel
2009-03-27 12:43             ` Anatolij Gustschin
2009-03-27 12:53               ` Jerry Van Baren
2009-03-27 13:00                 ` Detlev Zundel
2009-03-27 16:06                 ` Scott Wood
2009-03-25 19:19       ` [U-Boot] [PATCH v2 3/7] drivers/twserial: Add protocol driver for "three wire serial" interface Wolfgang Denk
2009-03-26  9:33         ` Detlev Zundel
2009-03-26 15:23           ` Detlev Zundel
2009-03-27 20:08             ` Wolfgang Denk
2009-03-27 10:02       ` Anatolij Gustschin
2009-03-27 10:33         ` Detlev Zundel
2009-03-27 20:06   ` [U-Boot] [PATCH v2 1/7] command.c: Expose the core of do_help as _do_help to the rest of u-boot Wolfgang Denk
2009-03-25 16:36 ` [U-Boot] [PATCH v2 0/7] Update for inka4x0 plus some new features Detlev Zundel

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=1237998478-18452-7-git-send-email-dzu@denx.de \
    --to=dzu@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 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.