Skip to contentSkip to conversation

am33xx: add a pulldown macro to pinmux config

PATCH Superseded Lars Poeschel 4 participants 7 messages Jan 8, 2013 – Jan 10, 2013 Arm (32-bit)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 am33xx: add a pulldown macro to pinmux config

From: Lars Poeschel <[email protected]>

---
 arch/arm/include/asm/arch-am33xx/mux.h |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/include/asm/arch-am33xx/mux.h +2 -1
index aed6b00..460ac1c 100644
@@ -25,7 +25,8 @@
 /* PAD Control Fields */
 #define SLEWCTRL	(0x1 << 6)
 #define RXACTIVE	(0x1 << 5)
-#define PULLUP_EN	(0x1 << 4) /* Pull UP Selection */
+#define PULLDOWN_EN	(0x0 << 4) /* Pull Down Selection */
+#define PULLUP_EN	(0x1 << 4) /* Pull Up Selection */
 #define PULLUDEN	(0x0 << 3) /* Pull up enabled */
 #define PULLUDDIS	(0x1 << 3) /* Pull up disabled */
 #define MODE(val)	val	/* used for Readability */
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 2/2 pcm051: Add support for Phytec phyCORE-AM335x

From: Lars Poeschel <[email protected]>

The board is named pcm051 and has this hardware:
SOC: TI AM3359
DDR3-RAM: 2x MT41J256M8HX-15EIT:D 512MiB
ETH 1: LAN8710AI
SPI-Flash: W25Q64BVSSIG
RTC: RV-4162-C7
I2C-EEPROM: CAT32WC32
NAND: MT29F4G08_VFPGA63
PMIC: TPS65910A3
LCD

Supported:
UART 1
MMC/SD
ETH 1
USB
I2C
SPI

Not yet supported:
NAND
RTC
LCD

---
 arch/arm/include/asm/arch-am33xx/ddr_defs.h |   18 ++
 board/phytec/pcm051/Makefile                |   46 ++++
 board/phytec/pcm051/board.c                 |  271 +++++++++++++++++++++++
 board/phytec/pcm051/board.h                 |   33 +++
 board/phytec/pcm051/mux.c                   |  133 ++++++++++++
 boards.cfg                                  |    1 +
 include/configs/pcm051.h                    |  308 +++++++++++++++++++++++++++
 7 files changed, 810 insertions(+)
 create mode 100644 board/phytec/pcm051/Makefile
 create mode 100644 board/phytec/pcm051/board.c
 create mode 100644 board/phytec/pcm051/board.h
 create mode 100644 board/phytec/pcm051/mux.c
 create mode 100644 include/configs/pcm051.h
arch/arm/include/asm/arch-am33xx/ddr_defs.h +18 -0
index 8e69fb6..f95b332 100644
@@ -65,6 +65,24 @@
 #define MT41J128MJT125_PHY_FIFO_WE		0x100
 #define MT41J128MJT125_IOCTRL_VALUE		0x18B
 
+/* Micron MT41J256M8HX-15E */
+#define MT41J256M8HX15E_EMIF_READ_LATENCY	0x06
+#define MT41J256M8HX15E_EMIF_TIM1		0x0888A39B
+#define MT41J256M8HX15E_EMIF_TIM2		0x26337FDA
+#define MT41J256M8HX15E_EMIF_TIM3		0x501F830F
+#define MT41J256M8HX15E_EMIF_SDCFG		0x61C04B32
+#define MT41J256M8HX15E_EMIF_SDREF		0x0000093B
+#define MT41J256M8HX15E_ZQ_CFG			0x50074BE4
+#define MT41J256M8HX15E_DLL_LOCK_DIFF		0x1
+#define MT41J256M8HX15E_RATIO			0x40
+#define MT41J256M8HX15E_INVERT_CLKOUT		0x1
+#define MT41J256M8HX15E_RD_DQS			0x3B
+#define MT41J256M8HX15E_WR_DQS			0x85
+#define MT41J256M8HX15E_PHY_WR_DATA		0xC1
+#define MT41J256M8HX15E_PHY_FIFO_WE		0x100
+#define MT41J256M8HX15E_IOCTRL_VALUE		0x18B
+
+
 /**
  * Configure SDRAM
  */
board/phytec/pcm051/Makefile new file +46 -0

46 lines not on this page · raw message

board/phytec/pcm051/board.c new file +271 -0

271 lines not on this page · raw message

board/phytec/pcm051/board.h new file +33 -0
new file mode 100644
index 0000000..c2630d7
@@ -0,0 +1,33 @@
+/*
+ * board.h
+ *
+ * Phytec phyCORE-AM335x (pcm051) boards information header
+ *
+ * Copyright (C) 2013, Lemonage Software GmbH
+ * Author Lars Poeschel <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef _BOARD_H_
+#define _BOARD_H_
+
+/*
+ * We have three pin mux functions that must exist.  We must be able to enable
+ * uart0, for initial output and i2c0 to read the main EEPROM.  We then have a
+ * main pinmux function that can be overridden to enable all other pinmux that
+ * is required on the board.
+ */
+void enable_uart0_pin_mux(void);
+void enable_i2c0_pin_mux(void);
+void enable_board_pin_mux(void);
+void enable_cbmux_pin_mux(void);
+#endif
board/phytec/pcm051/mux.c new file +133 -0

133 lines not on this page · raw message

boards.cfg +1 -0
index 91504c0..f471556 100644
@@ -234,6 +234,7 @@ am335x_evm_uart2             arm         armv7       am335x              ti
 am335x_evm_uart3             arm         armv7       am335x              ti             am33xx      am335x_evm:SERIAL4,CONS_INDEX=4
 am335x_evm_uart4             arm         armv7       am335x              ti             am33xx      am335x_evm:SERIAL5,CONS_INDEX=5
 am335x_evm_uart5             arm         armv7       am335x              ti             am33xx      am335x_evm:SERIAL6,CONS_INDEX=6
+pcm051                       arm         armv7       pcm051              phytec         am33xx      pcm051
 highbank                     arm         armv7       highbank            -              highbank
 mx51_efikamx                 arm         armv7       mx51_efikamx        genesi         mx5		mx51_efikamx:MACH_TYPE=MACH_TYPE_MX51_EFIKAMX,IMX_CONFIG=board/genesi/mx51_efikamx/imximage_mx.cfg
 mx51_efikasb                 arm         armv7       mx51_efikamx        genesi         mx5		mx51_efikamx:MACH_TYPE=MACH_TYPE_MX51_EFIKASB,IMX_CONFIG=board/genesi/mx51_efikamx/imximage_sb.cfg
include/configs/pcm051.h new file +308 -0

308 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#2 lore raw

PATCH 2/2 pcm051: Add support for Phytec phyCORE-AM335x

Dear Lars,

In message <[email protected]> you wrote:
...

Quoted 7 lines
 arch/arm/include/asm/arch-am33xx/ddr_defs.h |   18 ++
 board/phytec/pcm051/Makefile                |   46 ++++
 board/phytec/pcm051/board.c                 |  271 +++++++++++++++++++++++
 board/phytec/pcm051/board.h                 |   33 +++
 board/phytec/pcm051/mux.c                   |  133 ++++++++++++
 boards.cfg                                  |    1 +
 include/configs/pcm051.h                    |  308 +++++++++++++++++++++++++++

Please add an entry to the MAINTAINERS file.

Also, please run your patch through checkpatch - it complains about a number of style errors:

WARNING: Whitespace before semicolon

board/phytec/pcm051/board.c line 60

Quoted 2 lines
board/phytec/pcm051/board.c new file +2 -0
+/* DDR RAM defines */
+#define DDR_CLK_MHZ		303

Is this really correct? 303 ??

board/phytec/pcm051/board.c line 72

Quoted 11 lines
board/phytec/pcm051/board.c new file +11 -0
+static void rtc32k_enable(void)
+{
+	struct rtc_regs *rtc = (struct rtc_regs *)AM335X_RTC_BASE;
+
+	/*
+	 * Unlock the RTC's registers.  For more details please see the
+	 * RTC_SS section of the TRM.  In order to unlock we need to
+	 * write these specific values (keys) in this order.
+	 */
+	writel(0x83e70b13, &rtc->kick0r);
+	writel(0x95a4f1e0, &rtc->kick1r);

These magic numbers should probbly be moved to some header file ?

board/phytec/pcm051/board.c line 118

Quoted 5 lines
board/phytec/pcm051/board.c new file +5 -0
+void s_init(void)
+{
+	/* WDT1 is already running when the bootloader gets control
+	 * Disable it to avoid "random" resets
+	 */

Incorrect multiline comment style.

board/phytec/pcm051/board.c line 119

Quoted 1 line
board/phytec/pcm051/board.c new file +1 -0
+	writel(0xAAAA, &wdtimer->wdtwspr);

More hard-wired magic values?

Review

Quoted 2 lines
(quoted diff) +2 -0
+	while (readl(&wdtimer->wdtwwps) != 0x0)
+		;

No timeout?

board/phytec/pcm051/board.c line 122

Quoted 1 line
board/phytec/pcm051/board.c new file +1 -0
+	writel(0x5555, &wdtimer->wdtwspr);

More hard-wired magic values?

Review

Quoted 2 lines
(quoted diff) +2 -0
+	while (readl(&wdtimer->wdtwwps) != 0x0)
+		;

No timeout?

board/phytec/pcm051/board.c line 143

Quoted 3 lines
board/phytec/pcm051/board.c new file +3 -0
+	while ((readl(&uart_base->uartsyssts) &
+		UART_CLK_RUNNING_MASK) != UART_CLK_RUNNING_MASK)
+		;

Braces needed for multiline statement.

board/phytec/pcm051/board.c line 182

Quoted 6 lines
board/phytec/pcm051/board.c new file +6 -0
+#ifdef CONFIG_BOARD_LATE_INIT
+int board_late_init(void)
+{
+	return 0;
+}
+#endif

Do you plan to use this? Otherwise please just omit such dead code.

board/phytec/pcm051/board.c line 190

Quoted 7 lines
board/phytec/pcm051/board.c new file +7 -0
+#ifdef CONFIG_DRIVER_TI_CPSW
+static void cpsw_control(int enabled)
+{
+	/* VTP can be added here */
+
+	return;
+}

Ditto...

board/phytec/pcm051/board.c line 236

Quoted 2 lines
board/phytec/pcm051/board.c new file +2 -0
+	if (!eth_getenv_enetaddr("ethaddr", mac_addr)) {
+		debug("<ethaddr> not set. Reading from E-fuse\n");

This should be a printf(). Any such automatic changes are always worth to be told explicitly.

Quoted 1 line
board/phytec/pcm051/board.c new file +1 -0
+			goto try_usbether;

...

Review

Quoted 2 lines
(quoted diff) +2 -0
+#endif
+try_usbether:

Did you ever try building without CONFIG_DRIVER_TI_CPSW set? I bet this causes a few compiler warnings. [Hint: You define a label, but don't use it anywhere.]

Quoted 1 line

+#define CONFIG_ENV_SIZE (128 << 10) /* 128 KiB */

Does this really make sense? I doubt you will ever need more than 10% of this size - so you are just wasting a lot of time for checksumming unused memory...

Quoted 1 line

+#define CONFIG_ENV_OVERWRITE 1

Please do not define values for logical variables like this one; please fix globally.

Quoted 1 line

+#define CONFIG_ENV_IS_NOWHERE

Really?

Thanks!

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Crash programs fail because they are based on the theory  that,  with
nine women pregnant, you can get a baby a month.  - Wernher von Braun
#3 lore raw

PATCH 2/2 pcm051: Add support for Phytec phyCORE-AM335x

Hello Wolfgang,

thank you for your fast review!

Quoted 4 lines · Wolfgang Denk

board/phytec/pcm051/board.c line 60

Quoted 2 lines
board/phytec/pcm051/board.c new file +2 -0
+/* DDR RAM defines */
+#define DDR_CLK_MHZ		303

Is this really correct? 303 ??

I am quite sure, I read this in a datasheet, but I can not find it anymore. I set this to 333 now. mtest still works.

...

Quoted 11 lines

Do you plan to use this? Otherwise please just omit such dead code.

board/phytec/pcm051/board.c line 190

Quoted 7 lines
board/phytec/pcm051/board.c new file +7 -0
+#ifdef CONFIG_DRIVER_TI_CPSW
+static void cpsw_control(int enabled)
+{
+	/* VTP can be added here */
+
+	return;
+}

Ditto...

The cpsw driver needs a control function, otherwise the board crashes when network initializes. On my board this is empty like on am335x_evm.

Quoted 4 lines
Quoted 1 line

+#define CONFIG_ENV_OVERWRITE 1

Please do not define values for logical variables like this one; please fix globally.

Fix globally ? Do you mean, I have to fix that for EVERY board that is in u- boot, that defines CONFIG_ENV_OVERWRITE with a value to get my patch in? There are a number of boards doing this wrong!

Quoted 3 lines
Quoted 1 line

+#define CONFIG_ENV_IS_NOWHERE

Really?

Uuhm. Yes. At the moment I use this uEnv.txt file on sd-card, as I am not able to use the NAND yet. The env should go to nand later.

Thanks for the other hints you gave. I will address this and send a version 2 soon.

Regards,
Lars

#4 lore raw

PATCH 2/2 pcm051: Add support for Phytec phyCORE-AM335x

In reply to Wolfgang Denk
Quoted 17 lines · Wolfgang Denk

Dear Lars,

In message <[email protected]> you wrote:
...

Quoted 7 lines
 arch/arm/include/asm/arch-am33xx/ddr_defs.h |   18 ++
 board/phytec/pcm051/Makefile                |   46 ++++
 board/phytec/pcm051/board.c                 |  271 +++++++++++++++++++++++
 board/phytec/pcm051/board.h                 |   33 +++
 board/phytec/pcm051/mux.c                   |  133 ++++++++++++
 boards.cfg                                  |    1 +
 include/configs/pcm051.h                    |  308 +++++++++++++++++++++++++++

Please add an entry to the MAINTAINERS file.

Also, please run your patch through checkpatch - it complains about a number of style errors:

Quoted 6 lines

WARNING: Whitespace before semicolon

board/phytec/pcm051/board.c line 60

Quoted 2 lines
board/phytec/pcm051/board.c new file +2 -0
+/* DDR RAM defines */
+#define DDR_CLK_MHZ		303

Is this really correct? 303 ??

Yes, it's really correct.

Quoted 5 lines
Quoted 5 lines
board/phytec/pcm051/board.c new file +5 -0
+static void rtc32k_enable(void)
+{
+	struct rtc_regs *rtc = (struct rtc_regs *)AM335X_RTC_BASE;
+
+	/*
Quoted 8 lines

board/phytec/pcm051/board.c line 72

Quoted 6 lines
board/phytec/pcm051/board.c new file +6 -0
+	 * Unlock the RTC's registers.  For more details please see the
+	 * RTC_SS section of the TRM.  In order to unlock we need to
+	 * write these specific values (keys) in this order.
+	 */
+	writel(0x83e70b13, &rtc->kick0r);
+	writel(0x95a4f1e0, &rtc->kick1r);

These magic numbers should probbly be moved to some header file ?

This is a copy/paste from the am335x board.c file. I specifically did a long comment to explain what / where these values come from because that (to me) is more helpful than
#define AM33X_RTC_KICK0R_KEY 0x...
#define AM33X_RTC_KICK1R_KEY 0x...

[snip]

Quoted 4 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+	while (readl(&wdtimer->wdtwwps) != 0x0)
+		;

No timeout?

No. I argued with Marek about some of these before too. In short, if we don't suceed here, there's a catastrophic failure of the hardware.

Quoted 5 lines

board/phytec/pcm051/board.c line 236

Quoted 2 lines
board/phytec/pcm051/board.c new file +2 -0
+	if (!eth_getenv_enetaddr("ethaddr", mac_addr)) {
+		debug("<ethaddr> not set. Reading from E-fuse\n");

This should be a printf(). Any such automatic changes are always worth to be told explicitly.

This is the normal case of asking the hardware what MAC it shipped with. Why do we want to tell the user the expected has happened?

Quoted 8 lines
Quoted 1 line
board/phytec/pcm051/board.c new file +1 -0
+			goto try_usbether;

...

Review

Quoted 2 lines
(quoted diff) +2 -0
+#endif
+try_usbether:

Did you ever try building without CONFIG_DRIVER_TI_CPSW set? I bet this causes a few compiler warnings. [Hint: You define a label, but don't use it anywhere.]

It's a valid question if this board uses the CPSW eth or not, yes.

Quoted 5 lines
Quoted 1 line

+#define CONFIG_ENV_SIZE (128 << 10) /* 128 KiB */

Does this really make sense? I doubt you will ever need more than 10% of this size - so you are just wasting a lot of time for checksumming unused memory...

ENV stored in NAND with page size of 128KiB is probably the reason for this.

Quoted 3 lines
Quoted 1 line

+#define CONFIG_ENV_IS_NOWHERE

Really?

Until they add NAND (which just now hit mainline), yes.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130109/156148d8/attachment.pgp>
#5 lore raw

PATCH 2/2 pcm051: Add support for Phytec phyCORE-AM335x

Hi Wolfgang, hi Tom,

as I almost have the changes requested by Wolfgang in place, you two can choose, which version I should resubmit. ;)

Am 09.01.2013 um 20:34 schrieb Tom Rini:

Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
board/phytec/pcm051/board.c new file +5 -0
+static void rtc32k_enable(void)
+{
+	struct rtc_regs *rtc = (struct rtc_regs *)AM335X_RTC_BASE;
+
+	/*
Quoted 8 lines

board/phytec/pcm051/board.c line 72

Quoted 6 lines
board/phytec/pcm051/board.c new file +6 -0
+	 * Unlock the RTC's registers.  For more details please see the
+	 * RTC_SS section of the TRM.  In order to unlock we need to
+	 * write these specific values (keys) in this order.
+	 */
+	writel(0x83e70b13, &rtc->kick0r);
+	writel(0x95a4f1e0, &rtc->kick1r);

These magic numbers should probbly be moved to some header file ?

Quoted 5 lines

This is a copy/paste from the am335x board.c file. I specifically did a long comment to explain what / where these values come from because that (to me) is more helpful than
#define AM33X_RTC_KICK0R_KEY 0x...
#define AM33X_RTC_KICK1R_KEY 0x...

davinci does it this way. I would prefer Tom's variant having the values right in place.

Quoted 8 lines
Quoted 5 lines

board/phytec/pcm051/board.c line 236

Quoted 2 lines
board/phytec/pcm051/board.c new file +2 -0
+	if (!eth_getenv_enetaddr("ethaddr", mac_addr)) {
+		debug("<ethaddr> not set. Reading from E-fuse\n");

This should be a printf(). Any such automatic changes are always worth to be told explicitly.

This is the normal case of asking the hardware what MAC it shipped with. Why do we want to tell the user the expected has happened?

Here I'd prefer the printf variant, because for a common user it is not obivous, that it is reading the MAC from efuse. So this message is helpful.

Quoted 10 lines
Quoted 8 lines
Quoted 1 line
board/phytec/pcm051/board.c new file +1 -0
+			goto try_usbether;

...

Review

Quoted 2 lines
(quoted diff) +2 -0
+#endif
+try_usbether:

Did you ever try building without CONFIG_DRIVER_TI_CPSW set? I bet this causes a few compiler warnings. [Hint: You define a label, but don't use it anywhere.]

It's a valid question if this board uses the CPSW eth or not, yes.

Yes, the board uses CPSW, but here I would prefer having the try_usbether label inside the ifdef.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

+#define CONFIG_ENV_IS_NOWHERE

Really?

Until they add NAND (which just now hit mainline), yes.

This is a very valuable information, thanks!

Regards,
Lars

#6 lore raw

PATCH 2/2 pcm051: Add support for Phytec phyCORE-AM335x

Quoted 5 lines · Lars Poeschel

Hi Wolfgang, hi Tom,

as I almost have the changes requested by Wolfgang in place, you two can choose, which version I should resubmit. ;)

Am 09.01.2013 um 20:34 schrieb Tom Rini:

[snip]

Quoted 10 lines
Quoted 8 lines
Quoted 5 lines

board/phytec/pcm051/board.c line 236

Quoted 2 lines
board/phytec/pcm051/board.c new file +2 -0
+	if (!eth_getenv_enetaddr("ethaddr", mac_addr)) {
+		debug("<ethaddr> not set. Reading from E-fuse\n");

This should be a printf(). Any such automatic changes are always worth to be told explicitly.

This is the normal case of asking the hardware what MAC it shipped with. Why do we want to tell the user the expected has happened?

Here I'd prefer the printf variant, because for a common user it is not obivous, that it is reading the MAC from efuse. So this message is helpful.

OK, please also patch board/ti/am335x/board.c to also printf here then. Other than that, yes, I'd be happy to see you make the other changes you said. Just partially trying to help explain the SoC to Wolfgang :)

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130110/003c1cbc/attachment.pgp>