ppc4xx: Add 405EP based PMC405DE board
PATCH v2 1/1 ppc4xx: Add 405EP based PMC405DE board
--- MAINTAINERS | 1 + MAKEALL | 1 + Makefile | 3 + board/esd/pmc405de/Makefile | 51 ++++ board/esd/pmc405de/config.mk | 23 ++ board/esd/pmc405de/pmc405de.c | 590 +++++++++++++++++++++++++++++++++++++++++ board/esd/pmc405de/u-boot.lds | 133 +++++++++ include/configs/PMC405DE.h | 373 ++++++++++++++++++++++++++ 8 files changed, 1175 insertions(+), 0 deletions(-) create mode 100644 board/esd/pmc405de/Makefile create mode 100644 board/esd/pmc405de/config.mk create mode 100644 board/esd/pmc405de/pmc405de.c create mode 100644 board/esd/pmc405de/u-boot.lds create mode 100644 include/configs/PMC405DE.h
MAINTAINERS +1 -0
@@ -171,6 +171,7 @@ Matthias Fuchs <[email protected]> PCI405 PPC405GP PLU405 PPC405EP PMC405 PPC405GP + PMC405DE PPC405EP PMC440 PPC440EPx VOH405 PPC405EP VOM405 PPC405EP
MAKEALL +1 -0
@@ -237,6 +237,7 @@ LIST_4xx=" \ PIP405 \ PLU405 \ PMC405 \ + PMC405DE \ PMC440 \ PPChameleonEVB \ quad100hd \
Makefile +3 -0
@@ -1492,6 +1492,9 @@ PLU405_config: unconfig PMC405_config: unconfig @$(MKCONFIG) $(@:_config=) ppc ppc4xx pmc405 esd +PMC405DE_config: unconfig + @$(MKCONFIG) $(@:_config=) ppc ppc4xx pmc405de esd + PMC440_config: unconfig @$(MKCONFIG) $(@:_config=) ppc ppc4xx pmc440 esd
board/esd/pmc405de/Makefile new file +51 -0
51 lines not on this page · raw message
board/esd/pmc405de/config.mk new file +23 -0
@@ -0,0 +1,23 @@ +# +# (C) Copyright 2000 +# Wolfgang Denk, DENX Software Engineering, wd at denx.de. +# +# See file CREDITS for list of people who contributed to this +# project. +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +TEXT_BASE = 0xFFFC0000
board/esd/pmc405de/pmc405de.c new file +590 -0
590 lines not on this page · raw message
board/esd/pmc405de/u-boot.lds new file +133 -0
133 lines not on this page · raw message
include/configs/PMC405DE.h new file +373 -0
373 lines not on this page · raw message
Signature · 1 line
1.6.1
PATCH v2 1/1 ppc4xx: Add 405EP based PMC405DE board
Dear Matthias Fuchs,
Quoted 2 lines · In message <[email protected]> you wrote:
Signed-off-by Matthias Fuchs <[email protected]>---
...
Quoted 5 lines
board/esd/pmc405de/pmc405de.c new file +0
-0
...
Quoted 21 lines
board/esd/pmc405de/pmc405de.c new file +21
-0+if ((pllmr0 &PLLMR0_CPU_TO_PLB_MASK ) ==PLLMR0_CPU_PLB_DIV_3 ) { +/* fCPU=333MHz, fPLB=111MHz */ +if (pci_is_66mhz ()) { +if ((pllmr0 &PLLMR0_PCI_TO_PLB_MASK ) != +PLLMR0_PCI_PLB_DIV_1 ) { +pll_write ((pllmr0 & ~PLLMR0_PCI_TO_PLB_MASK ) | +PLLMR0_PCI_PLB_DIV_1 , pllmr1); + } + }else { +if ((pllmr0 &PLLMR0_PCI_TO_PLB_MASK ) != +PLLMR0_PCI_PLB_DIV_2 ) { +pll_write ((pllmr0 & ~PLLMR0_PCI_TO_PLB_MASK ) | +PLLMR0_PCI_PLB_DIV_2 , pllmr1); + } + } + }else { +/* fCPU=133|266MHz, fPLB=133MHz */ +if (pci_is_66mhz ()) { +if ((pllmr0 &PLLMR0_PCI_TO_PLB_MASK ) != +PLLMR0_PCI_PLB_DIV_2 ) { + pll_write((pllmr0 & ~PLLMR0_PCI_TO_PLB_MASK) |
board/esd/pmc405de/pmc405de.c line 102
Quoted 10 lines
board/esd/pmc405de/pmc405de.c new file +10
-0+ PLLMR0_PCI_PLB_DIV_2, pllmr1); + } + }else { +if ((pllmr0 &PLLMR0_PCI_TO_PLB_MASK ) != +PLLMR0_PCI_PLB_DIV_3 ) { +pll_write ((pllmr0 & ~PLLMR0_PCI_TO_PLB_MASK ) | +PLLMR0_PCI_PLB_DIV_3 , pllmr1); + } + } + }
Please try to factor out repeated code like here.
How about:
if ((pllmr0 & PLLMR0_CPU_TO_PLB_MASK) == PLLMR0_CPU_PLB_DIV_3) {
/* fCPU=333MHz, fPLB=111MHz */
if (pci_is_66mhz())
foo(PLLMR0_PCI_PLB_DIV_1);
else
foo(PLLMR0_PCI_PLB_DIV_2);
} else {
/* fCPU=133|266MHz, fPLB=133MHz */
if (pci_is_66mhz())
foo(PLLMR0_PCI_PLB_DIV_2);
else
foo(PLLMR0_PCI_PLB_DIV_3);
}void foo(int i)
{
if ((pllmr0 & PLLMR0_PCI_TO_PLB_MASK) != PLLMR0_PCI_PLB_DIV_2)
pll_write((pllmr0 & ~PLLMR0_PCI_TO_PLB_MASK) | i, pllmr1);
}board/esd/pmc405de/pmc405de.c line 170
Quoted 5 lines
board/esd/pmc405de/pmc405de.c new file +5
-0+static int is_monarch (void ) +{ +if (in_be32 ((void *)GPIO0_IR ) &CONFIG_SYS_GPIO_MONARCH_N ) +return 0 ; +return 1 ;
or:
return (in_be32((void*)GPIO0_IR) & CONFIG_SYS_GPIO_MONARCH_N) == 0;
Umm... and why do we need a cast here? This should be fixed.
board/esd/pmc405de/pmc405de.c line 177
Quoted 7 lines
board/esd/pmc405de/pmc405de.c new file +7
-0+} + +static int pci_is_66mhz (void ) +{ +if (in_be32 ((void *)GPIO0_IR ) &CONFIG_SYS_GPIO_M66EN ) +return 1 ; +return 0 ;
Ditto.
board/esd/pmc405de/pmc405de.c line 184
Quoted 7 lines
board/esd/pmc405de/pmc405de.c new file +7
-0+} + +static int board_revision (void ) +{ +return ((in_be32 ((void *)GPIO0_IR ) &CONFIG_SYS_GPIO_HWREV_MASK ) >> +CONFIG_SYS_GPIO_HWREV_SHIFT ); +}
and again.
board/esd/pmc405de/pmc405de.c line 189
Quoted 4 lines
board/esd/pmc405de/pmc405de.c new file +4
-0+static int cpld_revision (void ) +{ +return ((in_8 ((void *)CPLD_VERSION ) &CPLD_VERSION_MASK )); +}
and again.
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 Children are natural mimics who act like their parents despite every effort to teach them good manners.
PATCH v2 1/1 ppc4xx: Add 405EP based PMC405DE board
Hi Wolfgang,
Quoted 37 lines · Wolfgang Denk
Dear Matthias Fuchs,
Quoted 2 lines · In message <[email protected]> you wrote:
Signed-off-by Matthias Fuchs <[email protected]>---
...
Quoted 5 lines
board/esd/pmc405de/pmc405de.c new file +0
-0...
Quoted 25 lines
board/esd/pmc405de/pmc405de.c new file +25
-0+if ((pllmr0 &PLLMR0_CPU_TO_PLB_MASK ) ==PLLMR0_CPU_PLB_DIV_3 ) { +/* fCPU=333MHz, fPLB=111MHz */ +if (pci_is_66mhz ()) { +if ((pllmr0 &PLLMR0_PCI_TO_PLB_MASK ) != +PLLMR0_PCI_PLB_DIV_1 ) { +pll_write ((pllmr0 & ~PLLMR0_PCI_TO_PLB_MASK ) | +PLLMR0_PCI_PLB_DIV_1 , pllmr1); + } + }else { +if ((pllmr0 &PLLMR0_PCI_TO_PLB_MASK ) != +PLLMR0_PCI_PLB_DIV_2 ) { +pll_write ((pllmr0 & ~PLLMR0_PCI_TO_PLB_MASK ) | +PLLMR0_PCI_PLB_DIV_2 , pllmr1); + } + } + }else { +/* fCPU=133|266MHz, fPLB=133MHz */ +if (pci_is_66mhz ()) { +if ((pllmr0 &PLLMR0_PCI_TO_PLB_MASK ) != +PLLMR0_PCI_PLB_DIV_2 ) { +pll_write ((pllmr0 & ~PLLMR0_PCI_TO_PLB_MASK ) | +PLLMR0_PCI_PLB_DIV_2 , pllmr1); + } + }else { + if ((pllmr0 & PLLMR0_PCI_TO_PLB_MASK) !=
Quoted 8 lines
board/esd/pmc405de/pmc405de.c line 102
Quoted 6 lines
board/esd/pmc405de/pmc405de.c new file +6
-0+ PLLMR0_PCI_PLB_DIV_3) { +pll_write ((pllmr0 & ~PLLMR0_PCI_TO_PLB_MASK ) | +PLLMR0_PCI_PLB_DIV_3 , pllmr1); + } + } + }Please try to factor out repeated code like here.
Ack.
Quoted 8 lines
board/esd/pmc405de/pmc405de.c line 170
Quoted 5 lines
board/esd/pmc405de/pmc405de.c new file +5
-0+static int is_monarch (void ) +{ +if (in_be32 ((void *)GPIO0_IR ) &CONFIG_SYS_GPIO_MONARCH_N ) +return 0 ; +return 1 ;or:
return (in_be32((void*)GPIO0_IR) & CONFIG_SYS_GPIO_MONARCH_N) == 0;
Ack.
Quoted 2 lines
Umm... and why do we need a cast here? This should be fixed.
The in/out_be16/32 functions expect a pointer. When you grep over the U-Boot sources you will find tons of places with this cast. So I will and cannot fix this with my patch.
We could put the cast into the GPIO_IR (and friends) definitions. Do you want me to remove the cast and life with a compiler warning until this has been globally fixed?
Because this is not a particular problem with this patch it should be addressed in a separate discussion. But you are rigth - this cast is a little bit nerving :-)
Quoted 32 lines
board/esd/pmc405de/pmc405de.c line 177
Quoted 8 lines
board/esd/pmc405de/pmc405de.c new file +7
-0+} + +static int pci_is_66mhz (void ) +{ +if (in_be32 ((void *)GPIO0_IR ) &CONFIG_SYS_GPIO_M66EN ) +return 1 ; +return 0 ;Ditto.
board/esd/pmc405de/pmc405de.c line 184
Quoted 7 lines
board/esd/pmc405de/pmc405de.c new file +7
-0+} + +static int board_revision (void ) +{ +return ((in_be32 ((void *)GPIO0_IR ) &CONFIG_SYS_GPIO_HWREV_MASK ) >> +CONFIG_SYS_GPIO_HWREV_SHIFT ); +}and again.
board/esd/pmc405de/pmc405de.c line 189
Quoted 4 lines
board/esd/pmc405de/pmc405de.c new file +4
-0+static int cpld_revision (void ) +{ +return ((in_8 ((void *)CPLD_VERSION ) &CPLD_VERSION_MASK )); +}and again.
Best regards,
Wolfgang Denk
PATCH v2 1/1 ppc4xx: Add 405EP based PMC405DE board
Dear Matthias Fuchs,
Quoted 7 lines · In message <[email protected]> you wrote:
Quoted 2 lines
return (in_be32((void*)GPIO0_IR) & CONFIG_SYS_GPIO_MONARCH_N) == 0;Ack.
Quoted 2 lines
Umm... and why do we need a cast here? This should be fixed.
The in/out_be16/32 functions expect a pointer. When you grep over the U-Boot sources you will find tons of places with this cast.
Right you are. These all should be fixed, too.
Quoted 1 line
So I will and cannot fix this with my patch.
Of course you can. The cure is simple:
Fix "include/ppc405.h" so we get rid of this silly "base address + offset" notation and use proper C structures instead.
Oh, and while we are at it - "include/ppc440.h" has more of this stuff that is waiting for cleanup. But that is another story, not related to your patch - maybe Stefan picks up this ball :-)
Quoted 1 line
We could put the cast into the
GPIO_IR(and friends) definitions.
No cast is needed. Just use proper C structs.
Quoted 2 lines
Do you want me to remove the cast and life with a compiler warning until this has been globally fixed?
No, of course not.
Quoted 3 lines
Because this is not a particular problem with this patch it should be addressed in a separate discussion. But you are rigth - this cast is a little bit nerving :-)
I agree - the cleanup patch should be submitted first.
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 For those who like this sort of thing, this is the sort of thing they like. - Abraham Lincoln
PATCH v2 1/1 ppc4xx: Add 405EP based PMC405DE board
Hi Wolfgang and Stefan,
Quoted 18 lines · Wolfgang Denk
Of course you can. The cure is simple:
Fix "
include/ppc405.h" so we get rid of this silly "base address + offset" notation and use proper C structures instead.Oh, and while we are at it - "
include/ppc440.h" has more of this stuff that is waiting for cleanup. But that is another story, not related to your patch - maybe Stefan picks up this ball :-)Quoted 1 line
We could put the cast into the
GPIO_IR(and friends) definitions.No cast is needed. Just use proper C structs.
Quoted 2 lines
Do you want me to remove the cast and life with a compiler warning until this has been globally fixed?
Quoted 7 lines
No, of course not.
Quoted 3 lines
Because this is not a particular problem with this patch it should be addressed in a separate discussion. But you are rigth - this cast is a little bit nerving :-)
I agree - the cleanup patch should be submitted first.
Do you want to see something like this (see below)?
I ran into the problem that include/ppc405.h defines a macro "tcr". This conflicts with tcr in my gpio_controller struct.
When this kind of structure and it's usage is ok, I will provide a clean patch that adds the struct and a revised path for adding the PMC405DE board support.
I hope you do make adding PMC405DE board support dependant from fixing all casts with io accessor macros :-(
Matthias
--- board/esd/pmc405de/pmc405de.c | 30 +++++++++++++++++++++--------- include/asm-ppc/gpio.h | 24 ++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 9 deletions(-)
board/esd/pmc405de/pmc405de.c +10 -0
@@ -26,10 +26,20 @@#include <fdt_support.h> #include <asm/processor.h> #include <asm/io.h> +#include <asm/gpio.h> #include <asm/4xx_pci.h> #include <command.h> #include <malloc.h> +struct pmc405de_cpld { +u8 version; +u8 reserved0[3 ]; +u8 status; +u8 reserved1[3 ]; +u8 control; +u8 reserved2[3 ]; +}; +#define CPLD_VERSION (CONFIG_SYS_CPLD_BASE + 0)#define CPLD_VERSION_MASK 0x0f#define CPLD_STATUS (CONFIG_SYS_CPLD_BASE + 4)
@@ -120,22 +130,24 @@ static void upd_plb_pci_div(u32 pllmr0, u32
pllmr1, u32 div)
int misc_init_r(void)
{
int i;
+ struct ppc4xx_gpio_controller *gpio0 = (struct ppc4xx_gpio_controller
*)GPIO_BASE;
+ struct pmc405de_cpld *cpld = (struct pmc405de_cpld *)CONFIG_SYS_CPLD_BASE;
if (!is_monarch()) {
/* PCI configuration done: release EREADY */
- out_be32((void*)GPIO0_OR,
- in_be32((void*)GPIO0_OR) | CONFIG_SYS_GPIO_EREADY);
- out_be32((void*)GPIO0_TCR,
- in_be32((void*)GPIO0_TCR) | CONFIG_SYS_GPIO_EREADY);
+ out_be32(&gpio0->or,
+ in_be32(&gpio0->or) | CONFIG_SYS_GPIO_EREADY);
+ out_be32(&gpio0->_tcr,
+ in_be32(&gpio0->_tcr) | CONFIG_SYS_GPIO_EREADY);
}
/* turn off POST LED */
- out_8((void*)CPLD_CONTROL,
+ out_8(&cpld->control,
CPLD_CONTROL_POSTLED_N | CPLD_CONTROL_POSTLED_GATE);
/* turn on LEDs: RUN, A, B */
- out_be32((void*)GPIO0_OR,
- in_be32((void*)GPIO0_OR) &
+ out_be32(&gpio0->or,
+ in_be32(&gpio0->or) &
~(CONFIG_SYS_GPIO_LEDRUN_N |
CONFIG_SYS_GPIO_LEDA_N |
CONFIG_SYS_GPIO_LEDB_N));
@@ -144,8 +156,8 @@ int misc_init_r(void)
udelay(1000);
/* turn off LEDs: A, B */
- out_be32((void*)GPIO0_OR,
- in_be32((void*)GPIO0_OR) |
+ out_be32(&gpio0->or,
+ in_be32(&gpio0->or) |
(CONFIG_SYS_GPIO_LEDA_N |
CONFIG_SYS_GPIO_LEDB_N));
include/asm-ppc/gpio.h +24 -0
@@ -24,6 +24,8 @@#ifndef __ASM_PPC_GPIO_H#define __ASM_PPC_GPIO_H +#include <asm/types.h> +/* 4xx PPC's have 2 GPIO controllers */ #if defined(CONFIG_405EZ) || \ defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
@@ -34,6 +36,28 @@#define GPIO_GROUP_MAX 1#endif +/* GPIO controller */ +struct ppc4xx_gpio_controller { +u32 or; +u32 _tcr; +u32 osl; +u32 osh; +u32 tsl; +u32 tsh; +u32 odr; +u32 ir; +u32 rr1; +u32 rr2; +u32 rr3; +u32 reserved; +u32 is1l; +u32 is1h; +u32 is2l; +u32 is2h; +u32 is3l; +u32 is3h; +}; +/* Offsets */ #define GPIOx_OR 0x00/* GPIO Output Register */ #define GPIOx_TCR 0x04/* GPIO Three-State Control Register */
Signature · 1 line
1.6.1
PATCH v2 1/1 ppc4xx: Add 405EP based PMC405DE board
Dear Matthias Fuchs,
Quoted 2 lines · In message <[email protected]> you wrote:
Do you want to see something like this (see below)?
Basicly yes, but see comments below.
Quoted 2 lines
I ran into the problem that
include/ppc405.hdefines a macro "tcr". This conflicts with tcr in mygpio_controllerstruct.
Indeed - this is one of the resons we sreally should clean this up.
Quoted 2 lines
I hope you do make adding PMC405DE board support dependant from fixing all casts with io accessor macros :-(
If you really like and kindly ask for it, we can certainly do that :-) [Or did was a "not" missing somewhere in this sentence? :-) ]
board/esd/pmc405de/pmc405de.c line 32
Quoted 11 lines
index 9c1a119..789e326 100644
board/esd/pmc405de/pmc405de.c +1
-0@@ -26,10 +26,20 @@#include <fdt_support.h> #include <asm/processor.h> #include <asm/io.h> +#include <asm/gpio.h> #include <asm/4xx_pci.h> #include <command.h> #include <malloc.h>
Patch is white space corrupted.
board/esd/pmc405de/pmc405de.c line 41
Quoted 8 lines
board/esd/pmc405de/pmc405de.c +8
-0+struct pmc405de_cpld { +u8 version; +u8 reserved0[3 ]; +u8 status; +u8 reserved1[3 ]; +u8 control; +u8 reserved2[3 ]; +};
Are you sure these are 8 bit registers?
And some comments would be nice, too.
board/esd/pmc405de/pmc405de.c line 44
Quoted 8 lines
board/esd/pmc405de/pmc405de.c +4
-4-out_be32 ((void *)GPIO0_OR , -in_be32 ((void *)GPIO0_OR ) |CONFIG_SYS_GPIO_EREADY ); -out_be32 ((void *)GPIO0_TCR , -in_be32 ((void *)GPIO0_TCR ) |CONFIG_SYS_GPIO_EREADY ); +out_be32 (&gpio0->or, +in_be32 (&gpio0->or) |CONFIG_SYS_GPIO_EREADY ); +out_be32 (&gpio0->_tcr, +in_be32 (&gpio0->_tcr) |CONFIG_SYS_GPIO_EREADY );
Something is wrong here- either it's 8 bit registers, nd you should use 8 bit accessor functions, or it's 32 bit in both cases.
And instead of
out_be32(&gpio0->or, in_be32(&gpio0->or) | CONFIG_SYS_GPIO_EREADY); you better use setbits_be32(&gpio0->or, CONFIG_SYS_GPIO_EREADY);
[See also clrbits_*() and clrsetbits_*()]
Quoted 11 lines
board/esd/pmc405de/pmc405de.c +11
-0+/* GPIO controller */ +struct ppc4xx_gpio_controller { +u32 or; +u32 _tcr; +u32 osl; +u32 osh; +u32 tsl; +u32 tsh; +u32 odr; +u32 ir; +u32 rr1;
board/esd/pmc405de/pmc405de.c
Quoted 10 lines
board/esd/pmc405de/pmc405de.c +10
-0+u32 rr2; +u32 rr3; +u32 reserved; +u32 is1l; +u32 is1h; +u32 is2l; +u32 is2h; +u32 is3l; +u32 is3h; +};
Some comments might be helpful here, too.
Best regards,
Wolfgang Denk
Signature · 6 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
Perfection is reached, not when there is no longer anything to add,
but when there is no longer anything to take away.
- Antoine de Saint-Exupery