mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] PowerPC/MPC5200
@ 2015-07-24 13:42 Juergen Borleis
  2015-07-24 13:42 ` [PATCH 1/5] PPC/MPC52xx: add some useful GPIO definitions Juergen Borleis
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Juergen Borleis @ 2015-07-24 13:42 UTC (permalink / raw)
  To: barebox

While at it, fix a few things within the PowerPC/MPC5200 support in Barebox:
some clean up, some new useful definitions, a fix to be able to boot a
Linux/devicetree pair again and a correct clock and port setup for the PCM030
platform.

Comments are welcome.

jbe


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/5] PPC/MPC52xx: add some useful GPIO definitions
  2015-07-24 13:42 [PATCH] PowerPC/MPC5200 Juergen Borleis
@ 2015-07-24 13:42 ` Juergen Borleis
  2015-07-24 13:42 ` [PATCH 2/5] Devicetree/PPC: fix devicetree's fixup Juergen Borleis
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Juergen Borleis @ 2015-07-24 13:42 UTC (permalink / raw)
  To: barebox

When using GPIOs its useful to define them generically.

Signed-off-by: Juergen Borleis <jbe@pengutronix.de>
---
 arch/ppc/mach-mpc5xxx/include/mach/mpc5xxx.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/ppc/mach-mpc5xxx/include/mach/mpc5xxx.h b/arch/ppc/mach-mpc5xxx/include/mach/mpc5xxx.h
index f2cae90..a2129a1 100644
--- a/arch/ppc/mach-mpc5xxx/include/mach/mpc5xxx.h
+++ b/arch/ppc/mach-mpc5xxx/include/mach/mpc5xxx.h
@@ -192,8 +192,10 @@
 
 /* GPIO pins */
 #define GPIO_WKUP_7		0x80000000UL
+#define GPIO_WKUP_6		0x40000000UL
 #define GPIO_PSC6_0		0x10000000UL
 #define GPIO_PSC3_9		0x04000000UL
+#define GPIO_PSC2_4		0x02000000UL
 #define GPIO_PSC1_4		0x01000000UL
 
 /* PCI registers */
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/5] Devicetree/PPC: fix devicetree's fixup
  2015-07-24 13:42 [PATCH] PowerPC/MPC5200 Juergen Borleis
  2015-07-24 13:42 ` [PATCH 1/5] PPC/MPC52xx: add some useful GPIO definitions Juergen Borleis
@ 2015-07-24 13:42 ` Juergen Borleis
  2015-07-24 13:42 ` [PATCH 3/5] PPC/PCM030: remove nowhere used definitions Juergen Borleis
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Juergen Borleis @ 2015-07-24 13:42 UTC (permalink / raw)
  To: barebox

Currently Barebox fails to boot a kernel/devicetree pair on PowerPC.

With of_find_node_by_path() the framework uses a global variable to find
the root node and fails. With of_find_node_by_path_from() and forwarding
the 'root' parameter it works again as expected.

This fixes the following error message at run-time:

Loading U-Boot uImage '/tmp/tftpcmd/kernel'
Loading devicetree from '/tmp/tftpcmd/oftree'
bootm: No devicetree given.
handler failed with: Invalid argument

Signed-off-by: Juergen Borleis <jbe@pengutronix.de>
---
 arch/ppc/mach-mpc5xxx/cpu.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/arch/ppc/mach-mpc5xxx/cpu.c b/arch/ppc/mach-mpc5xxx/cpu.c
index c860e70..a53af63 100644
--- a/arch/ppc/mach-mpc5xxx/cpu.c
+++ b/arch/ppc/mach-mpc5xxx/cpu.c
@@ -83,17 +83,21 @@ static int of_mpc5200_fixup(struct device_node *root, void *unused)
 
 	int div = in_8((void*)CFG_MBAR + 0x204) & 0x0020 ? 8 : 4;
 
-	node = of_find_node_by_path("/cpus/PowerPC,5200@0");
-	if (!node)
+	node = of_find_node_by_path_from(root, "/cpus/PowerPC,5200@0");
+	if (!node) {
+		pr_err("Cannot find node '/cpus/PowerPC,5200@0' for proper CPU frequency fixup\n");
 		return -EINVAL;
+	}
 
 	of_property_write_u32(node, "timebase-frequency", get_timebase_clock());
 	of_property_write_u32(node, "bus-frequency", get_bus_clock());
 	of_property_write_u32(node, "clock-frequency", get_cpu_clock());
 
-	node = of_find_node_by_path("/soc5200@f0000000");
-	if (!node)
+	node = of_find_node_by_path_from(root, "/soc5200@f0000000");
+	if (!node) {
+		pr_err("Cannot find node '/soc5200@f0000000' for proper SOC frequency fixup\n");
 		return -EINVAL;
+	}
 
 	of_property_write_u32(node, "bus-frequency", get_ipb_clock());
 	of_property_write_u32(node, "system-frequency", get_bus_clock() * div);
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 3/5] PPC/PCM030: remove nowhere used definitions
  2015-07-24 13:42 [PATCH] PowerPC/MPC5200 Juergen Borleis
  2015-07-24 13:42 ` [PATCH 1/5] PPC/MPC52xx: add some useful GPIO definitions Juergen Borleis
  2015-07-24 13:42 ` [PATCH 2/5] Devicetree/PPC: fix devicetree's fixup Juergen Borleis
@ 2015-07-24 13:42 ` Juergen Borleis
  2015-07-24 13:42 ` [PATCH 4/5] PPC/PCM030: fix reference clock Juergen Borleis
  2015-07-24 13:42 ` [PATCH 5/5] PPC/PCM030: enable USB/OHCI pin support Juergen Borleis
  4 siblings, 0 replies; 8+ messages in thread
From: Juergen Borleis @ 2015-07-24 13:42 UTC (permalink / raw)
  To: barebox

Signed-off-by: Juergen Borleis <jbe@pengutronix.de>
---
 arch/ppc/boards/pcm030/config.h | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/arch/ppc/boards/pcm030/config.h b/arch/ppc/boards/pcm030/config.h
index 6e74964..1521811 100644
--- a/arch/ppc/boards/pcm030/config.h
+++ b/arch/ppc/boards/pcm030/config.h
@@ -27,16 +27,7 @@
 
 #define CFG_MPC5XXX_CLKIN	33333333 /* ... running at 33.333333MHz */
 
-#define CFG_GPS_PORT_CONFIG	0x00558c10 /* PSC6=UART, PSC3=UART ; Ether=100MBit with MD */
-
 #define CFG_HID0_INIT		HID0_ICE | HID0_ICFI
 #define CFG_HID0_FINAL		HID0_ICE
 
-
-#define CFG_BOOTMAPSZ		(8 << 20) /* Initial Memory map for Linux */
-
-#define OF_CPU			"PowerPC,5200@0"
-#define OF_TBCLK		CFG_MPC5XXX_CLKIN
-#define OF_SOC                  "soc5200@f0000000"
-
 #endif /* __CONFIG_H */
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 4/5] PPC/PCM030: fix reference clock
  2015-07-24 13:42 [PATCH] PowerPC/MPC5200 Juergen Borleis
                   ` (2 preceding siblings ...)
  2015-07-24 13:42 ` [PATCH 3/5] PPC/PCM030: remove nowhere used definitions Juergen Borleis
@ 2015-07-24 13:42 ` Juergen Borleis
  2015-07-27  5:42   ` Sascha Hauer
  2015-07-24 13:42 ` [PATCH 5/5] PPC/PCM030: enable USB/OHCI pin support Juergen Borleis
  4 siblings, 1 reply; 8+ messages in thread
From: Juergen Borleis @ 2015-07-24 13:42 UTC (permalink / raw)
  To: barebox

The PCM030 CPU module comes with a 33.333 MHz instead of a 33.333333 MHz
crystal reference. If such a special reference is in use, the USB PLL
needs a tweak to create a correct frequency. Without this tweak the USB
does not work correctly.

Signed-off-by: Juergen Borleis <jbe@pengutronix.de>
---
 arch/ppc/boards/pcm030/config.h | 2 +-
 arch/ppc/boards/pcm030/pcm030.c | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/arch/ppc/boards/pcm030/config.h b/arch/ppc/boards/pcm030/config.h
index 1521811..3fe1f28 100644
--- a/arch/ppc/boards/pcm030/config.h
+++ b/arch/ppc/boards/pcm030/config.h
@@ -25,7 +25,7 @@
 
 #include <mach/mpc5xxx.h>
 
-#define CFG_MPC5XXX_CLKIN	33333333 /* ... running at 33.333333MHz */
+#define CFG_MPC5XXX_CLKIN	33333000 /* ... running at 33.333MHz */
 
 #define CFG_HID0_INIT		HID0_ICE | HID0_ICFI
 #define CFG_HID0_FINAL		HID0_ICE
diff --git a/arch/ppc/boards/pcm030/pcm030.c b/arch/ppc/boards/pcm030/pcm030.c
index a7fa21d..376891a 100644
--- a/arch/ppc/boards/pcm030/pcm030.c
+++ b/arch/ppc/boards/pcm030/pcm030.c
@@ -32,6 +32,7 @@
 #include <memory.h>
 #include <linux/sizes.h>
 #include <linux/stat.h>
+#include <asm/io.h>
 #include <fs.h>
 
 static struct fec_platform_data fec_info = {
@@ -43,6 +44,14 @@ static int devices_init (void)
 	struct stat s;
 	int ret;
 
+#if CFG_MPC5XXX_CLKIN == 33333000
+	/*
+	 * Make USB work due to the special base crystal frequency:
+	 * 33,3330MHz * 16 = 533,328MHz main clock, but should be 528 MHz Clock
+	 */
+	out_be32((void *)MPC5XXX_CDM_48_FDC, 0x00015555);
+#endif
+
 	/*
 	 * Flash can be 16MB or 32MB, setup for the last 32MB no matter
 	 * what we find later.
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 5/5] PPC/PCM030: enable USB/OHCI pin support
  2015-07-24 13:42 [PATCH] PowerPC/MPC5200 Juergen Borleis
                   ` (3 preceding siblings ...)
  2015-07-24 13:42 ` [PATCH 4/5] PPC/PCM030: fix reference clock Juergen Borleis
@ 2015-07-24 13:42 ` Juergen Borleis
  4 siblings, 0 replies; 8+ messages in thread
From: Juergen Borleis @ 2015-07-24 13:42 UTC (permalink / raw)
  To: barebox

This change in the port config register enables the USB/OHCI support and
makes USB work on the PCM030's regular development baseboard.

Signed-off-by: Juergen Borleis <jbe@pengutronix.de>
---
 arch/ppc/boards/pcm030/pcm030.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/ppc/boards/pcm030/pcm030.c b/arch/ppc/boards/pcm030/pcm030.c
index 376891a..0bfe9ff 100644
--- a/arch/ppc/boards/pcm030/pcm030.c
+++ b/arch/ppc/boards/pcm030/pcm030.c
@@ -150,7 +150,7 @@ void initdram (int board_type)
 	/* Setup pin multiplexing */
 
 	/* PSC6=UART, PSC3=UART ; Ether=100MBit with MD */
-	*(vu_long *)MPC5XXX_GPS_PORT_CONFIG = 0x00558c10;
+	*(vu_long *)MPC5XXX_GPS_PORT_CONFIG = 0x00559c10;
 	*(vu_long *)MPC5XXX_CS_BURST = 0x00000000;
 	*(vu_long *)MPC5XXX_CS_DEADCYCLE = 0x33333333;
 
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 4/5] PPC/PCM030: fix reference clock
  2015-07-24 13:42 ` [PATCH 4/5] PPC/PCM030: fix reference clock Juergen Borleis
@ 2015-07-27  5:42   ` Sascha Hauer
  2015-07-27  7:55     ` Juergen Borleis
  0 siblings, 1 reply; 8+ messages in thread
From: Sascha Hauer @ 2015-07-27  5:42 UTC (permalink / raw)
  To: Juergen Borleis; +Cc: barebox

On Fri, Jul 24, 2015 at 03:42:05PM +0200, Juergen Borleis wrote:
> The PCM030 CPU module comes with a 33.333 MHz instead of a 33.333333 MHz
> crystal reference. If such a special reference is in use, the USB PLL
> needs a tweak to create a correct frequency. Without this tweak the USB
> does not work correctly.
> 
> Signed-off-by: Juergen Borleis <jbe@pengutronix.de>
> ---
>  arch/ppc/boards/pcm030/config.h | 2 +-
>  arch/ppc/boards/pcm030/pcm030.c | 9 +++++++++
>  2 files changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/ppc/boards/pcm030/config.h b/arch/ppc/boards/pcm030/config.h
> index 1521811..3fe1f28 100644
> --- a/arch/ppc/boards/pcm030/config.h
> +++ b/arch/ppc/boards/pcm030/config.h
> @@ -25,7 +25,7 @@
>  
>  #include <mach/mpc5xxx.h>
>  
> -#define CFG_MPC5XXX_CLKIN	33333333 /* ... running at 33.333333MHz */
> +#define CFG_MPC5XXX_CLKIN	33333000 /* ... running at 33.333MHz */
>  
>  #define CFG_HID0_INIT		HID0_ICE | HID0_ICFI
>  #define CFG_HID0_FINAL		HID0_ICE
> diff --git a/arch/ppc/boards/pcm030/pcm030.c b/arch/ppc/boards/pcm030/pcm030.c
> index a7fa21d..376891a 100644
> --- a/arch/ppc/boards/pcm030/pcm030.c
> +++ b/arch/ppc/boards/pcm030/pcm030.c
> @@ -32,6 +32,7 @@
>  #include <memory.h>
>  #include <linux/sizes.h>
>  #include <linux/stat.h>
> +#include <asm/io.h>
>  #include <fs.h>
>  
>  static struct fec_platform_data fec_info = {
> @@ -43,6 +44,14 @@ static int devices_init (void)
>  	struct stat s;
>  	int ret;
>  
> +#if CFG_MPC5XXX_CLKIN == 33333000
> +	/*
> +	 * Make USB work due to the special base crystal frequency:
> +	 * 33,3330MHz * 16 = 533,328MHz main clock, but should be 528 MHz Clock
> +	 */
> +	out_be32((void *)MPC5XXX_CDM_48_FDC, 0x00015555);
> +#endif

What's the point of having this #if? It's always true.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 4/5] PPC/PCM030: fix reference clock
  2015-07-27  5:42   ` Sascha Hauer
@ 2015-07-27  7:55     ` Juergen Borleis
  0 siblings, 0 replies; 8+ messages in thread
From: Juergen Borleis @ 2015-07-27  7:55 UTC (permalink / raw)
  To: barebox

Hi Sascha,

On Monday 27 July 2015 07:42:40 Sascha Hauer wrote:
> On Fri, Jul 24, 2015 at 03:42:05PM +0200, Juergen Borleis wrote:
> > The PCM030 CPU module comes with a 33.333 MHz instead of a 33.333333 MHz
> > crystal reference. If such a special reference is in use, the USB PLL
> > needs a tweak to create a correct frequency. Without this tweak the USB
> > does not work correctly.
> >
> > Signed-off-by: Juergen Borleis <jbe@pengutronix.de>
> > ---
> >  arch/ppc/boards/pcm030/config.h | 2 +-
> >  arch/ppc/boards/pcm030/pcm030.c | 9 +++++++++
> >  2 files changed, 10 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/ppc/boards/pcm030/config.h
> > b/arch/ppc/boards/pcm030/config.h index 1521811..3fe1f28 100644
> > --- a/arch/ppc/boards/pcm030/config.h
> > +++ b/arch/ppc/boards/pcm030/config.h
> > @@ -25,7 +25,7 @@
> >
> >  #include <mach/mpc5xxx.h>
> >
> > -#define CFG_MPC5XXX_CLKIN	33333333 /* ... running at 33.333333MHz */
> > +#define CFG_MPC5XXX_CLKIN	33333000 /* ... running at 33.333MHz */
> >
> >  #define CFG_HID0_INIT		HID0_ICE | HID0_ICFI
> >  #define CFG_HID0_FINAL		HID0_ICE
> > diff --git a/arch/ppc/boards/pcm030/pcm030.c
> > b/arch/ppc/boards/pcm030/pcm030.c index a7fa21d..376891a 100644
> > --- a/arch/ppc/boards/pcm030/pcm030.c
> > +++ b/arch/ppc/boards/pcm030/pcm030.c
> > @@ -32,6 +32,7 @@
> >  #include <memory.h>
> >  #include <linux/sizes.h>
> >  #include <linux/stat.h>
> > +#include <asm/io.h>
> >  #include <fs.h>
> >
> >  static struct fec_platform_data fec_info = {
> > @@ -43,6 +44,14 @@ static int devices_init (void)
> >  	struct stat s;
> >  	int ret;
> >
> > +#if CFG_MPC5XXX_CLKIN == 33333000
> > +	/*
> > +	 * Make USB work due to the special base crystal frequency:
> > +	 * 33,3330MHz * 16 = 533,328MHz main clock, but should be 528 MHz Clock
> > +	 */
> > +	out_be32((void *)MPC5XXX_CDM_48_FDC, 0x00015555);
> > +#endif
>
> What's the point of having this #if? It's always true.

From my notes back from 2008 this tweak is only required if the reference 
frequency is 33,333 MHz. And AFAIK there are 33,333333 MHz variants of the 
PCM030 out in the wild (or 33,0 MHz?).

But checking other platform's code the value written seems more or less random. 
The only important thing seems to be: this register must be setup. Its reset 
value is 0x00000000 and the kernel does not touch this register.

I will remove the #if/#endif in v2.

jbe

-- 
Pengutronix e.K.                              | Juergen Borleis             |
Industrial Linux Solutions                    | http://www.pengutronix.de/  |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-07-27  7:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-24 13:42 [PATCH] PowerPC/MPC5200 Juergen Borleis
2015-07-24 13:42 ` [PATCH 1/5] PPC/MPC52xx: add some useful GPIO definitions Juergen Borleis
2015-07-24 13:42 ` [PATCH 2/5] Devicetree/PPC: fix devicetree's fixup Juergen Borleis
2015-07-24 13:42 ` [PATCH 3/5] PPC/PCM030: remove nowhere used definitions Juergen Borleis
2015-07-24 13:42 ` [PATCH 4/5] PPC/PCM030: fix reference clock Juergen Borleis
2015-07-27  5:42   ` Sascha Hauer
2015-07-27  7:55     ` Juergen Borleis
2015-07-24 13:42 ` [PATCH 5/5] PPC/PCM030: enable USB/OHCI pin support Juergen Borleis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox