Re: [PATCH 6/6] 44x/currituck: Add support for the new IBM currituck platform

2011-11-30 Thread Kumar Gala

On Nov 29, 2011, at 11:24 PM, Tony Breeds wrote:

 Based on original work by David 'Shaggy' Kliekamp.
 
 Signed-off-by: Tony Breeds t...@bakeyournoodle.com
 ---
 arch/powerpc/boot/Makefile   |5 +-
 arch/powerpc/boot/dts/currituck.dts  |  240 ++
 arch/powerpc/boot/treeboot-currituck.c   |  129 ++
 arch/powerpc/boot/wrapper|3 +
 arch/powerpc/configs/44x/currituck_defconfig |  110 
 arch/powerpc/include/asm/reg.h   |1 +
 arch/powerpc/kernel/cputable.c   |   14 ++
 arch/powerpc/kernel/head_44x.S   |2 +
 arch/powerpc/platforms/44x/Kconfig   |   10 +
 arch/powerpc/platforms/44x/Makefile  |1 +
 arch/powerpc/platforms/44x/ppc47x.c  |  198 +
 arch/powerpc/sysdev/ppc4xx_pci.c |   57 ++-
 arch/powerpc/sysdev/ppc4xx_pci.h |7 +
 13 files changed, 775 insertions(+), 2 deletions(-)
 create mode 100644 arch/powerpc/boot/dts/currituck.dts
 create mode 100644 arch/powerpc/boot/treeboot-currituck.c
 create mode 100644 arch/powerpc/configs/44x/currituck_defconfig
 create mode 100644 arch/powerpc/platforms/44x/ppc47x.c

Split the board support patches from the SoC support.



 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
 index 559da19..aa38de6 100644
 --- a/arch/powerpc/include/asm/reg.h
 +++ b/arch/powerpc/include/asm/reg.h
 @@ -951,6 +951,7 @@
 #define PVR_403GCX0x00201400
 #define PVR_405GP 0x4011
 #define PVR_476   0x11a52000
 +#define PVR_476CURRITUCK 0x7ff5

This seems like it should be PVR_476FPE

 #define PVR_STB03XXX  0x4031
 #define PVR_NP405H0x4141
 #define PVR_NP405L0x4161
 diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c
 index edae5bb..02e0749 100644
 --- a/arch/powerpc/kernel/cputable.c
 +++ b/arch/powerpc/kernel/cputable.c
 @@ -1830,6 +1830,20 @@ static struct cpu_spec __initdata cpu_specs[] = {
   .machine_check  = machine_check_47x,
   .platform   = ppc470,
   },
 + { /* 476 core Currituck */

comment should probably be:
 /* 476FPE */

 + .pvr_mask   = 0x,
 + .pvr_value  = 0x7ff5,
 + .cpu_name   = 476,

should probably be 476FPE

 + .cpu_features   = CPU_FTRS_47X | CPU_FTR_476_DD2,
 + .cpu_user_features  = COMMON_USER_BOOKE |
 + PPC_FEATURE_HAS_FPU,
 + .mmu_features   = MMU_FTR_TYPE_47x |
 + MMU_FTR_USE_TLBIVAX_BCAST | MMU_FTR_LOCK_BCAST_INVAL,
 + .icache_bsize   = 32,
 + .dcache_bsize   = 128,
 + .machine_check  = machine_check_47x,
 + .platform   = ppc470,
 + },
   { /* 476 iss */
   .pvr_mask   = 0x,
   .pvr_value  = 0x0005,
 diff --git a/arch/powerpc/kernel/head_44x.S b/arch/powerpc/kernel/head_44x.S
 index b725dab..3aca1e2 100644
 --- a/arch/powerpc/kernel/head_44x.S
 +++ b/arch/powerpc/kernel/head_44x.S
 @@ -732,6 +732,8 @@ _GLOBAL(init_cpu_state)
   /* We use the PVR to differenciate 44x cores from 476 */
   mfspr   r3,SPRN_PVR
   srwir3,r3,16
 + cmplwi  cr0,r3,PVR_476CURRITUCK@h
 + beq head_start_47x
   cmplwi  cr0,r3,PVR_476@h
   beq head_start_47x
   cmplwi  cr0,r3,PVR_476_ISS@h

- k
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 6/6] 44x/currituck: Add support for the new IBM currituck platform

2011-11-30 Thread Tony Breeds
On Wed, Nov 30, 2011 at 05:20:22PM +1100, Benjamin Herrenschmidt wrote:
 On Wed, 2011-11-30 at 16:24 +1100, Tony Breeds wrote:
  +   plb {
  +   compatible = ibm,plb-4xx, ibm,plb4; /* Could be PLB6, 
  doesn't matter */
 
 Then make it plb6 and add it to the probe list. Might have to whack it's
 configuration registers one day etc...

Done.

  +* XXX: 1 TB address space, do we really care past
  +* 4 GB and should we expand cell width?
  +*/
 
 For OPB probably not :-)

Fixed.

 That doesn't seem like a very useful pair of statements or useful debug
 message

All the DBG cruft is gone.
 
  +   for(i = 0; i  MAX_RANKS; i++){
  +   reg = mfdcrx(DDR3_MR0CF + i);
  +   printf(%s: reg=0x%08x\r\n, __func__, reg);
 
 All that debug is pretty gross, keep it if you wish but make it a bit
 neater and/or wrap it in DBG

Yeah that was an oversight.
 
  +   if (reg  0x01) {
 
   if (!(reg  1))
   continue;
 
 avoids too much indent

Done.

  +   dt_fixup_memory(0x0ULL,  ibm_currituck_memsize);
 
 Ok, I see why the global... I'd still prefer if the detect function just
 returned the value and the caller whacks the global.

Fixed.
 
  +   while ((devp = find_node_by_devtype(devp, pci))) {
  +   if (getprop(devp, dma-ranges, dma_ranges[0], 
  sizeof(dma_ranges))  0) {
 
 Can't you replace dma_ranges[0] with just dma_ranges ?

Yes, Fixed.

  +#define SPRN_PIR   0x11E   /* Processor Indentification Register */
 
 That should go elsewhere along with the other SPR definitions.

There isn't a std. place in the bootwrapper.
 
  +void platform_init(void)
  +{
  +   /* Cap the zImage to 512MB */
 
 Any reason ? If yes, please document it a bit more.

XXX

  +   node = fdt_node_offset_by_prop_value(_dtb_start, -1, device_type,
  +cpu, sizeof(cpu));
  +   if (!node)
  +   fatal(Cannot find cpu node\n);
 
 The above will return -a- CPU node... you have several and you don't
 know which one. You should probably iterate accross all of them.

I'm just trying to get the timebase-frequency, this willbe the same on
all CPUs (at least I hope so ;P) so I don't really care which CPU node I
get.
 
  +   /* FIXME: Check this works */

Grr that comment shouldn't be there.  It does work :)

  +#define PVR_476CURRITUCK   0x7ff5
 
 My understanding is that the currituck was the platform, not the chip,
 and that the chip was called something like 476FPE, am I wrong ?

No you're correct, I was confused about the boundry between 476fpe and
currituck.

  +   cmplwi  cr0,r3,PVR_476CURRITUCK@h
  +   beq head_start_47x
 
 So at some point, they gave us the magic foo to do with the PVR to
 identify any 476... I'll try to dig that out of my email archives.

Yeah I have that I'll work out the correct way to the the mask and
test.

  +++ b/arch/powerpc/platforms/44x/ppc47x.c
 
 Call the file currituck.c

Sure.
 
  +static void __devinit quirk_ppc_currituck_usb_fixup(struct pci_dev *dev)
  +{
  +   pci_write_config_dword(dev, 0xe0, 0x0114231f);
  +   pci_write_config_dword(dev, 0xe4, 0x6c40);
  +}
 
 Pleae document better what you are doing here and also test
 that you are indeed on the right platform so you don't end up
 whacking bits on USB controllers on other platforms that happen
 to be compiled in the same binary.

Sure, no problem.
 
 Ok, I'll have to fixup that vs. Kyle patches but the good thing is that
 it will make things even simpler.

Thanks.
 
 Now pretty much everything in this platform file is generic I believe.
 We could move it all to ppc44x_simple.c. The only things that are not
 are the USB quirk and the interrupt fixup.
 
 The USB quirk which should have a compatible test for the platform to
 make sure we don't run it on something else. For such a simple quirk, I
 think it's fine ot have it in ppc44x_simple.c or in drivers/pci/quirk.c
 
 For the interrupt fixup, we can probably address it entirely in the
 device-tree, though that means exposing a bunch of on-board bridges
 which is only midly annoying.
 
 Anyways, we can discuss that (or maybe an even better option)
 tomorrow :-) 

Okay I look forward to it :)
 
 Again, you are mixing the SoC with the board here. afaik, currituck is
 the board, not the SoC.

Fixed.

Yours Tony


pgpRHmTjNPrYI.pgp
Description: PGP signature
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH 6/6] 44x/currituck: Add support for the new IBM currituck platform

2011-11-30 Thread Tony Breeds
On Wed, Nov 30, 2011 at 07:23:40AM -0600, Kumar Gala wrote:

 Split the board support patches from the SoC support.

Will do, as I said to Ben I was confused.

 This seems like it should be PVR_476FPE

Yup.  Fixed.

Yours Tony


pgpmujvrlooRf.pgp
Description: PGP signature
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH 6/6] 44x/currituck: Add support for the new IBM currituck platform

2011-11-30 Thread Tony Breeds
On Thu, Dec 01, 2011 at 03:05:24PM +1100, Tony Breeds wrote:
 On Wed, Nov 30, 2011 at 05:20:22PM +1100, Benjamin Herrenschmidt wrote:
  On Wed, 2011-11-30 at 16:24 +1100, Tony Breeds wrote:

snip

   +void platform_init(void)
   +{
   + /* Cap the zImage to 512MB */
  
  Any reason ? If yes, please document it a bit more.
 
 XXX
 
Where 'XXX' means come back and anser this point /before/ hitting send.

Basically is was lazyness.

Now that I know the memsize I'll allow the zImage to use it all but
512MB should be enought for anywone right?

Yours Tony


pgpfieYQLsLud.pgp
Description: PGP signature
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH 6/6] 44x/currituck: Add support for the new IBM currituck platform

2011-11-29 Thread Benjamin Herrenschmidt
On Wed, 2011-11-30 at 16:24 +1100, Tony Breeds wrote:

 + cpu@1 {
 + device_type = cpu;
 + model = PowerPC,476;
 + reg = 1;
 + clock-frequency = 16; // 1.6 GHz
 + timebase-frequency = 1; // 100Mhz
 + i-cache-line-size = 32;
 + d-cache-line-size = 32;
 + i-cache-size = 32768;
 + d-cache-size = 32768;
 + dcr-controller;
 + dcr-access-method = native;
 + status = disabled;

disabled ? really ?

 + enable-method = spin-table;
 + cpu-release-addr = 0x0 0x01f0;
 + };
 + };
 +
 + memory {
 + device_type = memory;
 + reg = 0x0 0x0 0x0 0x0; // filled in by zImage
 + };
 +
 + MPIC: interrupt-controller {
 + compatible = chrp,open-pic;
 + interrupt-controller;
 + dcr-reg = 0xffc0 0x0004;
 + #address-cells = 0;
 + #size-cells = 0;
 + #interrupt-cells = 2;
 +
 + };
 +
 + plb {
 + compatible = ibm,plb-4xx, ibm,plb4; /* Could be PLB6, 
 doesn't matter */

Then make it plb6 and add it to the probe list. Might have to whack it's
configuration registers one day etc...

 + #address-cells = 2;
 + #size-cells = 2;
 + ranges;
 + clock-frequency = 2; // 200Mhz
 +
 + POB0: opb {
 + compatible = ibm,opb-4xx, ibm,opb;
 + #address-cells = 1;
 + #size-cells = 1;
 + /* Wish there was a nicer way of specifying a full
 +  * 32-bit range
 +  *
 +  * XXX: 1 TB address space, do we really care past
 +  * 4 GB and should we expand cell width?
 +  */

For OPB probably not :-)

  .../...

 +#define DBG(fmt...)
 +
 +BSS_STACK(4096);
 +
 +#define MAX_RANKS0x4
 +#define DDR3_MR0CF   0x80010011U
 +
 +static unsigned long long ibm_currituck_memsize;
 +static void ibm_currituck_detect_memsize(void)
 +{
 + u32 reg;
 + unsigned i;
 +
 + ibm_currituck_memsize = 0;
 + DBG(%s: initial memsize=0x%016llx\r\n, __func__,
 + ibm_currituck_memsize);

That doesn't seem like a very useful pair of statements or useful debug
message

Any reason why you aren't returning what you detect rather than using a
global ?

 + for(i = 0; i  MAX_RANKS; i++){
 + reg = mfdcrx(DDR3_MR0CF + i);
 + printf(%s: reg=0x%08x\r\n, __func__, reg);

All that debug is pretty gross, keep it if you wish but make it a bit
neater and/or wrap it in DBG

 + if (reg  0x01) {

if (!(reg  1))
continue;

avoids too much indent

 + reg = 0xf000;
 + reg = 12;
 + DBG(%s: reg=0x%08x, mem=0x%016llx\r\n,
 + __func__, reg, (0x80ULL  reg));

Similar comment about making the debug output neater

 + ibm_currituck_memsize += (0x80ULL  reg);
 + DBG(%s: memsize=0x%016llx\r\n, __func__, 
 ibm_currituck_memsize);
 + }
 + }
 +
 + DBG(\r\n\r\n);
 +}
 +
 +static void ibm_currituck_fixups(void)
 +{
 + int i;
 + void *devp = finddevice(/);
 + u32 dma_ranges[7];
 +
 + dt_fixup_memory(0x0ULL,  ibm_currituck_memsize);

Ok, I see why the global... I'd still prefer if the detect function just
returned the value and the caller whacks the global.

 + while ((devp = find_node_by_devtype(devp, pci))) {
 + if (getprop(devp, dma-ranges, dma_ranges[0], 
 sizeof(dma_ranges))  0) {

Can't you replace dma_ranges[0] with just dma_ranges ?

 + printf(%s: Failed to get dma-ranges\r\n, __func__);
 + continue;
 + }
 +
 + dma_ranges[5] = ibm_currituck_memsize  32;
 + dma_ranges[6] = ibm_currituck_memsize  0xUL;
 +
 + setprop(devp, dma-ranges, dma_ranges[0], sizeof(dma_ranges));

Ditto.

 + DBG(%s: Setting DMA-ranges to 0x%x, __func__, dma_ranges[0]);
 + for (i = 1; i  7; i++)
 + DBG( 0x%x, dma_ranges[i]);
 + DBG(\n\r);

Do you really need that added debug ? Once you've displayed the memory
size and tested that code once it doesn't look like you really care much
anymore

 + }
 +}
 +
 +#define SPRN_PIR 0x11E   /* Processor Indentification Register */

That should go elsewhere along with the other SPR definitions.

 +void platform_init(void)
 +{
 + /* Cap the zImage to 512MB */

Any reason ? If yes, please document it a bit more.

 + unsigned long end_of_ram = 0x2000;
 + unsigned long 

Re: [PATCH 6/6] 44x/currituck: Add support for the new IBM currituck platform

2011-11-29 Thread David Gibson
On Wed, Nov 30, 2011 at 05:20:22PM +1100, Benjamin Herrenschmidt wrote:
 On Wed, 2011-11-30 at 16:24 +1100, Tony Breeds wrote:
 
  +   cpu@1 {
  +   device_type = cpu;
  +   model = PowerPC,476;
  +   reg = 1;
  +   clock-frequency = 16; // 1.6 GHz
  +   timebase-frequency = 1; // 100Mhz
  +   i-cache-line-size = 32;
  +   d-cache-line-size = 32;
  +   i-cache-size = 32768;
  +   d-cache-size = 32768;
  +   dcr-controller;
  +   dcr-access-method = native;
  +   status = disabled;
 
 disabled ? really ?

This is ePAPR.  All non-boot CPUs are supposed to have status =
disabled to indicate that they won't be available until explicitly
enabled via the enable-method.

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev