[RFC 0/2] powerpc: copy_4K_page tweaked for Cell

2008-08-14 Thread Mark Nelson
Hi All,

What follows is an updated version of copy_4K_page that has been tuned
for the Cell processor. With this new routine it was found that the
system time measured when compiling a 2.6.26 pseries_defconfig was
reduced by ~10s:

mainline (2.6.27-rc1-00632-g2e1e921):

real17m8.727s
user59m48.693s
sys 3m56.089s

real17m9.350s
user59m44.822s
sys 3m56.666s

new routine:

real17m7.311s
user59m51.339s
sys 3m47.043s

real17m7.863s
user59m49.028s
sys 3m46.608s

This same routine was also found to improve performance on 970 CPUs
too (but by a much smaller amount):

mainline (2.6.27-rc1-00632-g2e1e921):

real16m8.545s
user14m38.134s
sys 1m55.156s

real16m7.089s
user14m37.974s
sys 1m55.010s

new routine:

real16m11.641s
user14m37.251s
sys 1m52.618s

real16m6.139s
user14m38.282s
sys 1m53.184s


I also did testing on Power{3..6} and I found that Power3, Power5 and
Power6 did better with this new routine when the dcbt and dcbz
weren't used (in which case they achieved performance comparable to
the existing kernel copy_4K_page routine). Power4 on other hand
performed slightly better with the dcbt and dcbz included (still
comparable to the current kernel copy_4K_page).

So in order to get the best performance across the board I created a
new CPU feature that will govern whether the dcbt and dcbz are used
(and un-creatively named it CPU_FTR_CP_USE_DCBTZ). I added it to the
CPU features of Cell, Power4 and 970.
Unfortunately I don't have access to a PA6T but judging by the
marketing material I could find, it looks like it has a strong enough
hardware prefetcher that it probably wouldn't benefit from the dcbt
and dcbz...

Okay, that's probably enough prattling along - you can all go and look
at the code now.

All comments appreciated

[I decided to post the whole copy routine rather than a diff between
it and the current one because I found the diff quite unreadable. I'll post
a real patchset after I've addressed any comments.]

Many thanks!
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[RFC 1/2] powerpc: copy_4K_page tweaked for Cell

2008-08-14 Thread Mark Nelson
/*
 * Copyright (C) 2008 Mark Nelson, IBM Corp.
 *
 * 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.
 */
#include asm/processor.h
#include asm/ppc_asm.h
#include asm/asm-offsets.h

.section.toc,aw
PPC64_CACHES:
.tc ppc64_caches[TC],ppc64_caches
.section.text


_GLOBAL(copy_4K_page)
li  r5,4096 /* 4K page size */
ld  r10,[EMAIL PROTECTED](r2)
lwz r11,DCACHEL1LOGLINESIZE(r10)/* log2 of cache line size */
lwz r12,DCACHEL1LINESIZE(r10)   /* Get cache line size */
li  r9,0
srd r8,r5,r11

mtctr   r8
setup:
dcbtr9,r4
dcbzr9,r3
add r9,r9,r12
bdnzsetup

addir3,r3,-8
srdir8,r5,7 /* page is copied in 128 byte strides */
addir8,r8,-1/* one stride copied outside loop */

mtctr   r8

ld  r5,0(r4)
ld  r6,8(r4)
ld  r7,16(r4)
ldu r8,24(r4)
1:  std r5,8(r3)
ld  r9,8(r4)
std r6,16(r3)
ld  r10,16(r4)
std r7,24(r3)
ld  r11,24(r4)
std r8,32(r3)
ld  r12,32(r4)
std r9,40(r3)
ld  r5,40(r4)
std r10,48(r3)
ld  r6,48(r4)
std r11,56(r3)
ld  r7,56(r4)
std r12,64(r3)
ld  r8,64(r4)
std r5,72(r3)
ld  r9,72(r4)
std r6,80(r3)
ld  r10,80(r4)
std r7,88(r3)
ld  r11,88(r4)
std r8,96(r3)
ld  r12,96(r4)
std r9,104(r3)
ld  r5,104(r4)
std r10,112(r3)
ld  r6,112(r4)
std r11,120(r3)
ld  r7,120(r4)
stdur12,128(r3)
ldu r8,128(r4)
bdnz1b

std r5,8(r3)
ld  r9,8(r4)
std r6,16(r3)
ld  r10,16(r4)
std r7,24(r3)
ld  r11,24(r4)
std r8,32(r3)
ld  r12,32(r4)
std r9,40(r3)
ld  r5,40(r4)
std r10,48(r3)
ld  r6,48(r4)
std r11,56(r3)
ld  r7,56(r4)
std r12,64(r3)
ld  r8,64(r4)
std r5,72(r3)
ld  r9,72(r4)
std r6,80(r3)
ld  r10,80(r4)
std r7,88(r3)
ld  r11,88(r4)
std r8,96(r3)
ld  r12,96(r4)
std r9,104(r3)
std r10,112(r3)
std r11,120(r3)
std r12,128(r3)
blr
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[RFC 2/2] powerpc: copy_4K_page tweaked for Cell - add CPU feature

2008-08-14 Thread Mark Nelson
Add a new CPU feature, CPU_FTR_CP_USE_DCBTZ, to be added to the CPUs that 
benefit
from having dcbt and dcbz instructions used in copy_4K_page(). So far Cell, 
PPC970
and Power4 benefit.

This way all the other 64bit powerpc chips will have the whole prefetching loop
nop'ed out.

Signed-off-by: Mark Nelson [EMAIL PROTECTED]
---
 arch/powerpc/include/asm/cputable.h |9 ++---
 arch/powerpc/lib/copypage_64.S  |3 ++-
 2 files changed, 8 insertions(+), 4 deletions(-)

Index: upstream/arch/powerpc/include/asm/cputable.h
===
--- upstream.orig/arch/powerpc/include/asm/cputable.h
+++ upstream/arch/powerpc/include/asm/cputable.h
@@ -192,6 +192,7 @@ extern const char *powerpc_base_platform
 #define CPU_FTR_NO_SLBIE_B LONG_ASM_CONST(0x0008)
 #define CPU_FTR_VSXLONG_ASM_CONST(0x0010)
 #define CPU_FTR_SAOLONG_ASM_CONST(0x0020)
+#define CPU_FTR_CP_USE_DCBTZ   LONG_ASM_CONST(0x0040)
 
 #ifndef __ASSEMBLY__
 
@@ -387,10 +388,11 @@ extern const char *powerpc_base_platform
CPU_FTR_MMCRA | CPU_FTR_CTRL)
 #define CPU_FTRS_POWER4(CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \
CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \
-   CPU_FTR_MMCRA)
+   CPU_FTR_MMCRA | CPU_FTR_CP_USE_DCBTZ)
 #define CPU_FTRS_PPC970(CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \
CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \
-   CPU_FTR_ALTIVEC_COMP | CPU_FTR_CAN_NAP | CPU_FTR_MMCRA)
+   CPU_FTR_ALTIVEC_COMP | CPU_FTR_CAN_NAP | CPU_FTR_MMCRA | \
+   CPU_FTR_CP_USE_DCBTZ)
 #define CPU_FTRS_POWER5(CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \
CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \
CPU_FTR_MMCRA | CPU_FTR_SMT | \
@@ -411,7 +413,8 @@ extern const char *powerpc_base_platform
 #define CPU_FTRS_CELL  (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \
CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \
CPU_FTR_ALTIVEC_COMP | CPU_FTR_MMCRA | CPU_FTR_SMT | \
-   CPU_FTR_PAUSE_ZERO | CPU_FTR_CI_LARGE_PAGE | CPU_FTR_CELL_TB_BUG)
+   CPU_FTR_PAUSE_ZERO | CPU_FTR_CI_LARGE_PAGE | \
+   CPU_FTR_CELL_TB_BUG | CPU_FTR_CP_USE_DCBTZ)
 #define CPU_FTRS_PA6T (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \
CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | \
CPU_FTR_ALTIVEC_COMP | CPU_FTR_CI_LARGE_PAGE | \
Index: upstream/arch/powerpc/lib/copypage_64.S
===
--- upstream.orig/arch/powerpc/lib/copypage_64.S
+++ upstream/arch/powerpc/lib/copypage_64.S
@@ -18,6 +18,7 @@ PPC64_CACHES:
 
 _GLOBAL(copy_4K_page)
li  r5,4096 /* 4K page size */
+BEGIN_FTR_SECTION
ld  r10,[EMAIL PROTECTED](r2)
lwz r11,DCACHEL1LOGLINESIZE(r10)/* log2 of cache line size */
lwz r12,DCACHEL1LINESIZE(r10)   /* Get cache line size */
@@ -30,7 +31,7 @@ setup:
dcbzr9,r3
add r9,r9,r12
bdnzsetup
-
+END_FTR_SECTION_IFSET(CPU_FTR_CP_USE_DCBTZ)
addir3,r3,-8
srdir8,r5,7 /* page is copied in 128 byte strides */
addir8,r8,-1/* one stride copied outside loop */
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH / RFC] net: fix locking in ibm_newemac

2008-08-14 Thread Sebastian Siewior
* Benjamin Herrenschmidt | 2008-08-14 13:45:54 [+1000]:

 The fix is to defer phy init until netdevice is registered / initialized.

I think it's better instead to take the dev_mc_add() statement
out of emac_configure().
I looked yesterday into that code and I saw that dev_mc_add() was called
by the network core itself. Now I'm sure it was definitly too late for
writing patches :)

What about this patch instead, does it fix it for you ?
yep it does.

Sebastian
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


bug in lmb_enforce_memory_limit()

2008-08-14 Thread David Miller

I just mentioned this to Ben H. on IRC and promised I would report it
here. :-)

The first loop over lmb.memory in this function interprets the
memory_limit as a raw size limit, and that's fine so far.

But the second loop over lmb.reserved interprets this value
instead as an address limit.

I haven't cobbled together a fix myself, but probably the way to do
this is, when we're about break out of the first loop over lmb.memory,
walk through the now-trimmed memory blobs and trim those from
lmb.reserved, one by one.

This bug got introduced by:

   commit 2babf5c2ec2f2d5de3e38d20f7df7fd815fd10c9
   Author: Michael Ellerman [EMAIL PROTECTED]
   Date:   Wed May 17 18:00:46 2006 +1000

   [PATCH] powerpc: Unify mem= handling

back when LMB was still a powerpc local item. :-)

This led me to another bug which probably a lot of platforms are
effected by.

If you do this command line memory limiting, and the kernel was placed
by the boot loader into physical ram (say at the end of the available
physical memory) that gets trimmed out by the command line option, we
hang or crash right as we boot into userspace because freeing up
initmem ends up freeing invalid page structs.

I think, on sparc64, instead of adding all kinds of complicated logic
to free_initmem() I'm simply going to only poison the pages and
not free them at all if cmdline_memory_size has been set.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH] gianfar: Call gfar_halt_nodisable() from gfar_halt().

2008-08-14 Thread Jeff Garzik

Scott Wood wrote:

gfar_halt() was factored out into halting and disabling by commit
d87eb12785c14de1586e3bad86ca2c0991300339, as the suspend() method
only wants to do the former.  However, the call to gfar_halt_nodisable()
from gfar_halt() apparently got lost during the patch respin process.

This adds it back.

Signed-off-by: Scott Wood [EMAIL PROTECTED]
---
 drivers/net/gianfar.c |6 ++
 1 files changed, 2 insertions(+), 4 deletions(-)


applied


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


[PATCH 1/2][V3] powerpc: add support for dynamic reconfiguration memory in kexec/kdump kernels

2008-08-14 Thread Chandru
kdump kernel needs to use only those memory regions that it is allowed to use 
(crashkernel, rtas, tce ..etc ). Each of these regions have their own sizes and 
are currently added under  'linux,usable-memory' property under each memory@ 
node of the device tree.  ibm,dynamic-memory property of 
ibm,dynamic-reconfiguration-memory node now stores in it the representation for 
most of the logical memory blocks with the size of each memory block being a 
constant (lmb_size).  If one or more or part of the above mentioned regions lie 
under one of the lmb from ibm,dynamic-memory property, there is a need to 
identify those regions within the given lmb. Following patch recognizes a new 
property 'linux,drconf-usable-memory' property added by kexec-tools. Each entry 
in this property is of the form 'a counter'  followed by those many (base, 
size) duple for the above mentioned regions.

Signed-off-by: Chandru Siddalingappa [EMAIL PROTECTED]
---

These patches were sent earlier but these are V3 of the patches. Pls let me 
know your thoughts. Thanks. 

 arch/powerpc/kernel/prom.c |   40 +++--
 arch/powerpc/mm/numa.c |   79 +++
 2 files changed, 96 insertions(+), 23 deletions(-)

diff -Naurp powerpc-orig/arch/powerpc/kernel/prom.c 
powerpc/arch/powerpc/kernel/prom.c
--- powerpc-orig/arch/powerpc/kernel/prom.c 2008-08-14 08:23:25.0 
+0530
+++ powerpc/arch/powerpc/kernel/prom.c  2008-08-14 14:35:24.0 +0530
@@ -888,9 +888,10 @@ static u64 __init dt_mem_next_cell(int s
  */
 static int __init early_init_dt_scan_drconf_memory(unsigned long node)
 {
-   cell_t *dm, *ls;
+   cell_t *dm, *ls, *usm;
unsigned long l, n, flags;
u64 base, size, lmb_size;
+   unsigned int is_kexec_kdump = 0, rngs;
 
ls = (cell_t *)of_get_flat_dt_prop(node, ibm,lmb-size, l);
if (ls == NULL || l  dt_root_size_cells * sizeof(cell_t))
@@ -905,6 +906,12 @@ static int __init early_init_dt_scan_drc
if (l  (n * (dt_root_addr_cells + 4) + 1) * sizeof(cell_t))
return 0;
 
+   /* check if this is a kexec/kdump kernel. */
+   usm = (cell_t *)of_get_flat_dt_prop(node, linux,drconf-usable-memory,
+l);
+   if (usm != NULL)
+   is_kexec_kdump = 1;
+
for (; n != 0; --n) {
base = dt_mem_next_cell(dt_root_addr_cells, dm);
flags = dm[3];
@@ -915,13 +922,34 @@ static int __init early_init_dt_scan_drc
if ((flags  0x80) || !(flags  0x8))
continue;
size = lmb_size;
-   if (iommu_is_off) {
-   if (base = 0x8000ul)
+   rngs = 1;
+   if (is_kexec_kdump) {
+   /*
+* For each lmb in ibm,dynamic-memory, a corresponding
+* entry in linux,drconf-usable-memory property contains
+* a counter 'p' followed by 'p' (base, size) duple.
+* Now read the counter from
+* linux,drconf-usable-memory property
+*/
+   rngs = dt_mem_next_cell(dt_root_size_cells, usm);
+   if (!rngs) /* there are no (base, size) duple */
continue;
-   if ((base + size)  0x8000ul)
-   size = 0x8000ul - base;
}
-   lmb_add(base, size);
+   do {
+   if (is_kexec_kdump) {
+   base = dt_mem_next_cell(dt_root_addr_cells,
+usm);
+   size = dt_mem_next_cell(dt_root_size_cells,
+usm);
+   }
+   if (iommu_is_off) {
+   if (base = 0x8000ul)
+   continue;
+   if ((base + size)  0x8000ul)
+   size = 0x8000ul - base;
+   }
+   lmb_add(base, size);
+   } while (--rngs);
}
lmb_dump_all();
return 0;
diff -Naurp powerpc-orig/arch/powerpc/mm/numa.c powerpc/arch/powerpc/mm/numa.c
--- powerpc-orig/arch/powerpc/mm/numa.c 2008-08-14 08:23:25.0 +0530
+++ powerpc/arch/powerpc/mm/numa.c  2008-08-14 14:35:42.0 +0530
@@ -150,6 +150,21 @@ static const int *of_get_associativity(s
return of_get_property(dev, ibm,associativity, NULL);
 }
 
+/*
+ * Returns the property linux,drconf-usable-memory if
+ * it exists (the property exists only in kexec/kdump kernels,
+ * added by kexec-tools)
+ */
+static const u32 *of_get_usable_memory(struct device_node *memory)
+{
+   const u32 *prop;
+   

[PATCH 2/2][V3] kexec-tools: create a new linux, drconf-usable-memory property

2008-08-14 Thread Chandru
Add a new linux,drconf-usable-memory property to the device tree. This property 
stores the usable memory regions for kexec/kdump kernel. The other changes to 
kexec-tools which do not affect the kernel are not attached here.  These are 
the changes to kexec-tools. Patch 1/2 are the changes in kernel. 

Signed-off-by: Chandru Siddalingappa [EMAIL PROTECTED]
---

 kexec/arch/ppc64/fs2dt.c |   72 +
 1 file changed, 72 insertions(+)

--- kexec-tools-testing-orig/kexec/arch/ppc64/fs2dt.c   2008-08-14 
14:41:52.0 +0530
+++ kexec-tools-testing/kexec/arch/ppc64/fs2dt.c2008-08-14 
14:46:15.0 +0530
@@ -122,6 +122,74 @@ static unsigned propnum(const char *name
return offset;
 }
 
+static void add_dyn_reconf_usable_mem_property(int fd)
+{
+   char fname[MAXPATH], *bname;
+   uint64_t buf[32];
+   uint64_t ranges[2*MAX_MEMORY_RANGES];
+   uint64_t base, end, loc_base, loc_end;
+   int range, rlen = 0, i;
+   int rngs_cnt, tmp_indx;
+
+   strcpy(fname, pathname);
+   bname = strrchr(fname, '/');
+   bname[0] = '\0';
+   bname = strrchr(fname, '/');
+   if (strncmp(bname, /ibm,dynamic-reconfiguration-memory, 36))
+   return;
+
+   if (lseek(fd, 4, SEEK_SET)  0)
+   die(unrecoverable error: error seeking in \%s\: %s\n,
+   pathname, strerror(errno));
+
+   rlen = 0;
+   for (i = 0; i  num_of_lmbs; i++) {
+   if (read(fd, buf, 24)  0)
+   die(unrecoverable error: error reading \%s\: %s\n,
+   pathname, strerror(errno));
+
+   base = (uint64_t) buf[0];
+   end = base + lmb_size;
+   if (~0ULL - base  end)
+   die(unrecoverable error: mem property overflow\n);
+
+   tmp_indx = rlen++;
+
+   rngs_cnt = 0;
+   for (range = 0; range  usablemem_rgns.size; range++) {
+   loc_base = usablemem_rgns.ranges[range].start;
+   loc_end = usablemem_rgns.ranges[range].end;
+   if (loc_base = base  loc_end = end) {
+   ranges[rlen++] = loc_base;
+   ranges[rlen++] = loc_end - loc_base;
+   rngs_cnt++;
+   } else if (base  loc_end  end  loc_base) {
+   if (loc_base  base)
+   loc_base = base;
+   if (loc_end  end)
+   loc_end = end;
+   ranges[rlen++] = loc_base;
+   ranges[rlen++] = loc_end - loc_base;
+   rngs_cnt++;
+   }
+   }
+   /* Store the count of (base, size) duple */
+   ranges[tmp_indx] = rngs_cnt;
+   }
+   
+   rlen = rlen * sizeof(uint64_t);
+   /*
+* Add linux,drconf-usable-memory property.
+*/
+   *dt++ = 3;
+   *dt++ = rlen;
+   *dt++ = propnum(linux,drconf-usable-memory);
+   if ((rlen = 8)  ((unsigned long)dt  0x4))
+   dt++;
+   memcpy(dt, ranges, rlen);
+   dt += (rlen + 3)/4;
+}
+
 static void add_usable_mem_property(int fd, int len)
 {
char fname[MAXPATH], *bname;
@@ -267,6 +335,10 @@ static void putprops(char *fn, struct di
dt += (len + 3)/4;
if (!strcmp(dp-d_name, reg)  usablemem_rgns.size)
add_usable_mem_property(fd, len);
+   if (!strcmp(dp-d_name, ibm,dynamic-memory) 
+   usablemem_rgns.size)
+   add_dyn_reconf_usable_mem_property(fd);
+
close(fd);
}
 
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 1/2] port ndfc driver to of platform

2008-08-14 Thread Arnd Bergmann
On Wednesday 13 August 2008, Sean MacLennan wrote:
 Port of the ndfc driver to an of platform driver.

Look good overall, thanks for following up on this.

 +struct ndfc_ctrl {
 + struct device *dev;
 + void __iomem *ndfcbase;
 + struct mtd_info mtd;
 + struct nand_chip chip;
 + int chip_select;
 + struct nand_hw_control ndfc_control;
  };

conceptually, I would lint to the ofdev, not the dev, even if you
don't need the extra information.

  static void ndfc_select_chip(struct mtd_info *mtd, int chip)
  {
   uint32_t ccr;
 - struct ndfc_controller *ndfc = ndfc_ctrl;
 - struct nand_chip *nandchip = mtd-priv;
 - struct ndfc_nand_mtd *nandmtd = nandchip-priv;
 - struct platform_nand_chip *pchip = nandmtd-pl_chip;
 + struct ndfc_ctrl *ndfc = ndfc_ctrl;
  
   ccr = __raw_readl(ndfc-ndfcbase + NDFC_CCR);

This already exists, but I noticed it now: device drivers should
not user __raw_readl/__raw_writel for accessing ioremapped storage.
Instead, you should use ioread32_be or in_be32.

 @@ -83,7 +79,7 @@ static int ndfc_ready(struct mtd_info *mtd)
  static void ndfc_enable_hwecc(struct mtd_info *mtd, int mode)
  {
   uint32_t ccr;
 - struct ndfc_controller *ndfc = ndfc_ctrl;
 + struct ndfc_ctrl *ndfc = ndfc_ctrl;
  
   ccr = __raw_readl(ndfc-ndfcbase + NDFC_CCR);
   ccr |= NDFC_CCR_RESET_ECC;

You have lots of these changes, which do not appear necessary -- if you
just keep the struct ndfc_controller name, your patch will be a lot
smaller.

 -static int ndfc_nand_probe(struct platform_device *pdev)
 -{
 - struct platform_nand_ctrl *nc = pdev-dev.platform_data;
 - struct ndfc_controller_settings *settings = nc-priv;
 - struct resource *res = pdev-resource;
 - struct ndfc_controller *ndfc = ndfc_ctrl;
 - unsigned long long phys = settings-ndfc_erpn | res-start;
 + spin_lock_init(ndfc-ndfc_control.lock);
 + init_waitqueue_head(ndfc-ndfc_control.wq);
 + ndfc-dev = ofdev-dev;
 + dev_set_drvdata(ofdev-dev, ndfc);
 +
 + /* Read the reg property to get the chip select */
 + reg = of_get_property(ofdev-node, reg, len);
 + if (reg == NULL || len != 12) {
 + dev_err(ofdev-dev, unable read reg property (%d)\n, len);
 + return -ENOENT;
 + }
 + ndfc-chip_select = *reg;
  
 - ndfc-ndfcbase = ioremap((phys_addr_t)phys, res-end - res-start + 1);
 + ndfc-ndfcbase = ioremap(reg[1], reg[2]);

This could be better expressed as of_iomap().

 - platform_set_drvdata(pdev, ndfc);
 + __raw_writel(ccr, ndfc-ndfcbase + NDFC_CCR);
  
 - printk(NDFC NAND Driver initialized. Chip-Rev: 0x%08x\n,
 -__raw_readl(ndfc-ndfcbase + NDFC_REVID));
 + /* Set the bank settings */
 + reg = of_get_property(ofdev-node, bank_settings, NULL);
 + bank_settings = reg ? *reg : 0x8000;

Your device tree does have a bank_setting, so why not assume that
all others will have it as well? I would remove the default.

Arnd 
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 2/2] port ndfc driver to of platform

2008-08-14 Thread Arnd Bergmann
On Wednesday 13 August 2008, Sean MacLennan wrote:
 Changes to the warp platform with the ndfc as an of platform device.
 The main changes are:
 
 * moving the NAND information to the DTS
 * removing warp-nand.c
 * moving the NAND fixups to cuboot-warp.c

The device tree stuff looks good, but the significant fixups you still
need to for the old hw do look like an indication that we should really
have a different way of producing almost-identical dts files.
The cleanest solution for now would be to have two dts files for warp,
but I can understand that you don't want to do that.

Did we ever come to a conclusion on how this could be done, e.g. with
preprocessed dts files or simpler dynamic patching of binary device
trees?

Arnd 
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [RFC 2/2] powerpc: copy_4K_page tweaked for Cell - add CPU feature

2008-08-14 Thread Michael Ellerman
On Thu, 2008-08-14 at 16:18 +1000, Mark Nelson wrote:
 Add a new CPU feature, CPU_FTR_CP_USE_DCBTZ, to be added to the CPUs that 
 benefit
 from having dcbt and dcbz instructions used in copy_4K_page(). So far Cell, 
 PPC970
 and Power4 benefit.
 
 This way all the other 64bit powerpc chips will have the whole prefetching 
 loop
 nop'ed out.

 Index: upstream/arch/powerpc/lib/copypage_64.S
 ===
 --- upstream.orig/arch/powerpc/lib/copypage_64.S
 +++ upstream/arch/powerpc/lib/copypage_64.S
 @@ -18,6 +18,7 @@ PPC64_CACHES:
  
  _GLOBAL(copy_4K_page)
   li  r5,4096 /* 4K page size */
 +BEGIN_FTR_SECTION
   ld  r10,[EMAIL PROTECTED](r2)
   lwz r11,DCACHEL1LOGLINESIZE(r10)/* log2 of cache line size */
   lwz r12,DCACHEL1LINESIZE(r10)   /* Get cache line size */
 @@ -30,7 +31,7 @@ setup:
   dcbzr9,r3
   add r9,r9,r12
   bdnzsetup
 -
 +END_FTR_SECTION_IFSET(CPU_FTR_CP_USE_DCBTZ)
   addir3,r3,-8
   srdir8,r5,7 /* page is copied in 128 byte strides */
   addir8,r8,-1/* one stride copied outside loop */

Instead of nop'ing it out, we could use an alternative feature section
to either run it or jump over it. It would look something like:


_GLOBAL(copy_4K_page)
BEGIN_FTR_SECTION
li  r5,4096 /* 4K page size */
ld  r10,[EMAIL PROTECTED](r2)
lwz r11,DCACHEL1LOGLINESIZE(r10)/* log2 of cache line size */
lwz r12,DCACHEL1LINESIZE(r10)   /* Get cache line size */
li  r9,0
srd r8,r5,r11

mtctr   r8
setup:
dcbtr9,r4
dcbzr9,r3
add r9,r9,r12
bdnzsetup
FTR_SECTION_ELSE
b   1f
ALT_FTR_SECTION_END_IFSET(CPU_FTR_CP_USE_DCBTZ)
1:
addir3,r3,-8

So in the no-dcbtz case you'd get a branch instead of 11 nops.

Of course you'd need to benchmark it to see if skipping the nops is
better than executing them ;P

cheers

-- 
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person


signature.asc
Description: This is a digitally signed message part
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

Re: bug in lmb_enforce_memory_limit()

2008-08-14 Thread Michael Ellerman
On Thu, 2008-08-14 at 01:20 -0700, David Miller wrote:
 I just mentioned this to Ben H. on IRC and promised I would report it
 here. :-)
 
 The first loop over lmb.memory in this function interprets the
 memory_limit as a raw size limit, and that's fine so far.
 
 But the second loop over lmb.reserved interprets this value
 instead as an address limit.

 I haven't cobbled together a fix myself, but probably the way to do
 this is, when we're about break out of the first loop over lmb.memory,
 walk through the now-trimmed memory blobs and trim those from
 lmb.reserved, one by one.

Perhaps after the first loop we should set memory_limit to equal
lmb_end_of_DRAM(), then the second loop should work as it is.

I think that actually makes memory_limit (the variable) more useful, and
avoids more code like we have in numa_enforce_memory_limit(), which
doesn't use memory_limit exactly because it isn't the value we're
actually interested in (because of holes).


 This bug got introduced by:
 
commit 2babf5c2ec2f2d5de3e38d20f7df7fd815fd10c9
Author: Michael Ellerman [EMAIL PROTECTED]
Date:   Wed May 17 18:00:46 2006 +1000
 
[PATCH] powerpc: Unify mem= handling
 
 back when LMB was still a powerpc local item. :-)

Guilty as charged. I have some tests for that code, but clearly not
enough - and it gets very little exercise otherwise.

 This led me to another bug which probably a lot of platforms are
 effected by.
 
 If you do this command line memory limiting, and the kernel was placed
 by the boot loader into physical ram (say at the end of the available
 physical memory) that gets trimmed out by the command line option, we
 hang or crash right as we boot into userspace because freeing up
 initmem ends up freeing invalid page structs.
 
 I think, on sparc64, instead of adding all kinds of complicated logic
 to free_initmem() I'm simply going to only poison the pages and
 not free them at all if cmdline_memory_size has been set.

Would it be that much extra logic to check that the address is less than
the limit? Especially if we changed memory_limit to incorporate holes.

cheers

-- 
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person


signature.asc
Description: This is a digitally signed message part
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

Re: [RFC 2/2] powerpc: copy_4K_page tweaked for Cell - add CPU feature

2008-08-14 Thread Mark Nelson
Hi Michael,

On Thu, 14 Aug 2008 08:51:35 pm Michael Ellerman wrote:
 On Thu, 2008-08-14 at 16:18 +1000, Mark Nelson wrote:
  Add a new CPU feature, CPU_FTR_CP_USE_DCBTZ, to be added to the CPUs that 
  benefit
  from having dcbt and dcbz instructions used in copy_4K_page(). So far Cell, 
  PPC970
  and Power4 benefit.
  
  This way all the other 64bit powerpc chips will have the whole prefetching 
  loop
  nop'ed out.
 
  Index: upstream/arch/powerpc/lib/copypage_64.S
  ===
  --- upstream.orig/arch/powerpc/lib/copypage_64.S
  +++ upstream/arch/powerpc/lib/copypage_64.S
  @@ -18,6 +18,7 @@ PPC64_CACHES:
   
   _GLOBAL(copy_4K_page)
  li  r5,4096 /* 4K page size */
  +BEGIN_FTR_SECTION
  ld  r10,[EMAIL PROTECTED](r2)
  lwz r11,DCACHEL1LOGLINESIZE(r10)/* log2 of cache line size */
  lwz r12,DCACHEL1LINESIZE(r10)   /* Get cache line size */
  @@ -30,7 +31,7 @@ setup:
  dcbzr9,r3
  add r9,r9,r12
  bdnzsetup
  -
  +END_FTR_SECTION_IFSET(CPU_FTR_CP_USE_DCBTZ)
  addir3,r3,-8
  srdir8,r5,7 /* page is copied in 128 byte strides */
  addir8,r8,-1/* one stride copied outside loop */
 
 Instead of nop'ing it out, we could use an alternative feature section
 to either run it or jump over it. It would look something like:
 
 
 _GLOBAL(copy_4K_page)
 BEGIN_FTR_SECTION
 li  r5,4096 /* 4K page size */
 ld  r10,[EMAIL PROTECTED](r2)
 lwz r11,DCACHEL1LOGLINESIZE(r10)/* log2 of cache line size */
 lwz r12,DCACHEL1LINESIZE(r10)   /* Get cache line size */
 li  r9,0
 srd r8,r5,r11
 
 mtctr   r8
 setup:
 dcbtr9,r4
 dcbzr9,r3
 add r9,r9,r12
 bdnzsetup
 FTR_SECTION_ELSE
   b   1f
 ALT_FTR_SECTION_END_IFSET(CPU_FTR_CP_USE_DCBTZ)
 1:
 addir3,r3,-8
 
 So in the no-dcbtz case you'd get a branch instead of 11 nops.
 
 Of course you'd need to benchmark it to see if skipping the nops is
 better than executing them ;P

Thanks for looking through this.

That does look a lot better. In the first version there wasn't quite
as much to nop out (the cache line size was hardcoded to 128
bytes) so I wasn't so worried but I'll definitely try this with an
alternative section like you describe.

The jump probably will turn out to be better because I'd imagine
that the same chips that don't need the dcbt and dcbz because
they've got beefy enough hardware prefetchers also won't be
disturbed by the jump (but benchmarks tomorrow will confirm;
or prove me wrong :) )

Thanks!

Mark
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH] libfdt: Add support for using aliases in fdt_path_offset()

2008-08-14 Thread Kumar Gala


On Aug 13, 2008, at 11:15 PM, David Gibson wrote:


On Wed, Aug 13, 2008 at 10:52:26PM -0500, Kumar Gala wrote:
If the path doesn't start with '/' check to see if it matches some  
alias

under /aliases and substitute the matching alias value in the path
and retry the lookup.


Kumar, this is broken.  If you match an alias you only follow the path
one level down from there.  i.e. you will correctly resolve
'somealias' and 'somealias/foo', but not 'somealias/foo/bar'.


I'm not clear on what cases you are suggesting fail.

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


Re: [RFC 2/2] powerpc: copy_4K_page tweaked for Cell - add CPU feature

2008-08-14 Thread Michael Ellerman
On Thu, 2008-08-14 at 21:48 +1000, Mark Nelson wrote:
 Hi Michael,
 
 On Thu, 14 Aug 2008 08:51:35 pm Michael Ellerman wrote:
  On Thu, 2008-08-14 at 16:18 +1000, Mark Nelson wrote:
   Add a new CPU feature, CPU_FTR_CP_USE_DCBTZ, to be added to the CPUs that 
   benefit
   from having dcbt and dcbz instructions used in copy_4K_page(). So far 
   Cell, PPC970
   and Power4 benefit.
   
   This way all the other 64bit powerpc chips will have the whole 
   prefetching loop
   nop'ed out.
  
   Index: upstream/arch/powerpc/lib/copypage_64.S
   ===
   --- upstream.orig/arch/powerpc/lib/copypage_64.S
   +++ upstream/arch/powerpc/lib/copypage_64.S
   @@ -18,6 +18,7 @@ PPC64_CACHES:

_GLOBAL(copy_4K_page)
 li  r5,4096 /* 4K page size */
   +BEGIN_FTR_SECTION
 ld  r10,[EMAIL PROTECTED](r2)
 lwz r11,DCACHEL1LOGLINESIZE(r10)/* log2 of cache line size */
 lwz r12,DCACHEL1LINESIZE(r10)   /* Get cache line size */
   @@ -30,7 +31,7 @@ setup:
 dcbzr9,r3
 add r9,r9,r12
 bdnzsetup
   -
   +END_FTR_SECTION_IFSET(CPU_FTR_CP_USE_DCBTZ)
 addir3,r3,-8
 srdir8,r5,7 /* page is copied in 128 byte strides */
 addir8,r8,-1/* one stride copied outside loop */
  
  Instead of nop'ing it out, we could use an alternative feature section
  to either run it or jump over it. It would look something like:
  
  
  _GLOBAL(copy_4K_page)
  BEGIN_FTR_SECTION
  li  r5,4096 /* 4K page size */
  ld  r10,[EMAIL PROTECTED](r2)
  lwz r11,DCACHEL1LOGLINESIZE(r10)/* log2 of cache line size 
  */
  lwz r12,DCACHEL1LINESIZE(r10)   /* Get cache line size */
  li  r9,0
  srd r8,r5,r11
  
  mtctr   r8
  setup:
  dcbtr9,r4
  dcbzr9,r3
  add r9,r9,r12
  bdnzsetup
  FTR_SECTION_ELSE
  b   1f
  ALT_FTR_SECTION_END_IFSET(CPU_FTR_CP_USE_DCBTZ)
  1:
  addir3,r3,-8
  
  So in the no-dcbtz case you'd get a branch instead of 11 nops.
  
  Of course you'd need to benchmark it to see if skipping the nops is
  better than executing them ;P
 
 Thanks for looking through this.
 
 That does look a lot better. In the first version there wasn't quite
 as much to nop out (the cache line size was hardcoded to 128
 bytes) so I wasn't so worried but I'll definitely try this with an
 alternative section like you describe.
 
 The jump probably will turn out to be better because I'd imagine
 that the same chips that don't need the dcbt and dcbz because
 they've got beefy enough hardware prefetchers also won't be
 disturbed by the jump (but benchmarks tomorrow will confirm;
 or prove me wrong :) )

Yeah, that would make sense. But you never know :)

cheers

-- 
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person


signature.asc
Description: This is a digitally signed message part
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

Re: [PATCH 0/3] Patches to support QE USB Host Controller

2008-08-14 Thread Laurent Pinchart
On Friday 08 August 2008, Anton Vorontsov wrote:
 Hi all,
 
 Most patches that were needed to support QE USB Host were merged during
 2.6.27 merge window, and only three more patches left over. Here they
 are.
 
 David, could you bear with gpio_to_chip() exported function, just as
 a stopgap for a proper api?

I need gpio_to_chip() (or another 'proper API') as well for RTS/CTS based flow 
control in the CPM/CPM2 UART driver.

Best regards,

-- 
Laurent Pinchart
CSE Semaphore Belgium

Chaussee de Bruxelles, 732A
B-1410 Waterloo
Belgium

T +32 (2) 387 42 59
F +32 (2) 387 42 75


signature.asc
Description: This is a digitally signed message part.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

[PATCH v2] libfdt: Add support for using aliases in fdt_path_offset()

2008-08-14 Thread Kumar Gala
If the path doesn't start with '/' check to see if it matches some alias
under /aliases and substitute the matching alias value in the path
and retry the lookup.

Signed-off-by: Kumar Gala [EMAIL PROTECTED]
---

Fixed the bug pointed out by David Gibson and added tests.

- k

 libfdt/fdt_ro.c |   21 ++-
 tests/Makefile.tests|2 +-
 tests/aliases.dts   |   31 ++
 tests/path_offset_aliases.c |   59 +++
 tests/run_tests.sh  |4 +++
 5 files changed, 114 insertions(+), 3 deletions(-)
 create mode 100644 tests/aliases.dts
 create mode 100644 tests/path_offset_aliases.c

diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c
index ebd1260..2f3ff48 100644
--- a/libfdt/fdt_ro.c
+++ b/libfdt/fdt_ro.c
@@ -139,8 +139,25 @@ int fdt_path_offset(const void *fdt, const char *path)

FDT_CHECK_HEADER(fdt);

-   if (*path != '/')
-   return -FDT_ERR_BADPATH;
+   /* see if we have an alias */
+   if (*path != '/') {
+   const char *q;
+   int aliasoffset = fdt_path_offset(fdt, /aliases);
+
+   if (aliasoffset  0)
+   return -FDT_ERR_BADPATH;
+
+   q = strchr(path, '/');
+   if (!q)
+   q = end;
+
+   p = fdt_getprop_namelen(fdt, aliasoffset, path, q - p, NULL);
+   if (!p)
+   return -FDT_ERR_BADPATH;
+   offset = fdt_path_offset(fdt, p);
+
+   p = q;
+   }

while (*p) {
const char *q;
diff --git a/tests/Makefile.tests b/tests/Makefile.tests
index 704c95d..44021b0 100644
--- a/tests/Makefile.tests
+++ b/tests/Makefile.tests
@@ -11,7 +11,7 @@ LIB_TESTS_L = get_mem_rsv \
open_pack rw_tree1 set_name setprop del_property del_node \
string_escapes references path-references boot-cpuid incbin \
dtbs_equal_ordered \
-   add_subnode_with_nops
+   add_subnode_with_nops path_offset_aliases
 LIB_TESTS = $(LIB_TESTS_L:%=$(TESTS_PREFIX)%)

 LIBTREE_TESTS_L = truncated_property
diff --git a/tests/aliases.dts b/tests/aliases.dts
new file mode 100644
index 000..bd0e6bf
--- /dev/null
+++ b/tests/aliases.dts
@@ -0,0 +1,31 @@
+/dts-v1/;
+
+/memreserve/ 0xdeadbeef 0x10;
+/memreserve/ 123456789 01;
+
+/ {
+   compatible = test_tree1;
+   prop-int = 0xdeadbeef;
+   prop-str = hello world;
+
+   aliases {
+   s1 = sub1;
+   ss1 = subsub1;
+   sss1 = subsubsub1;
+   };
+
+   sub1: [EMAIL PROTECTED] {
+   compatible = subnode1;
+   prop-int = [deadbeef];
+
+   subsub1: subsubnode {
+   compatible = subsubnode1, subsubnode;
+   prop-int = 0xdeadbeef;
+
+   subsubsub1: subsubsubnode {
+   compatible = subsubsubnode1, subsubsubnode;
+   prop-int = 0xdeadbeef;
+   };
+   };
+   };
+};
diff --git a/tests/path_offset_aliases.c b/tests/path_offset_aliases.c
new file mode 100644
index 000..191edd2
--- /dev/null
+++ b/tests/path_offset_aliases.c
@@ -0,0 +1,59 @@
+/*
+ * libfdt - Flat Device Tree manipulation
+ * Testcase for fdt_path_offset()
+ * Copyright (C) 2006 David Gibson, IBM Corporation.
+ * Copyright 2008 Kumar Gala, Freescale Semiconductor, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include stdlib.h
+#include stdio.h
+#include string.h
+#include stdint.h
+
+#include fdt.h
+#include libfdt.h
+
+#include tests.h
+#include testdata.h
+
+void check_alias(void *fdt, const char *full_path, const char *alias_path)
+{
+   int offset, offset_a;
+
+   offset = fdt_path_offset(fdt, full_path);
+   offset_a = fdt_path_offset(fdt, alias_path);
+
+   if (offset != offset_a)
+   FAIL(Mismatch between %s path_offset (%d) and %s path_offset 
alias (%d),
+full_path, offset, alias_path, offset_a);
+}
+
+int main(int argc, char *argv[])
+{
+   void *fdt;
+
+   test_init(argc, argv);
+   fdt = load_blob_arg(argc, argv);
+
+   check_alias(fdt, /[EMAIL PROTECTED], s1);
+ 

Re: [RFC/PATCH v2] powerpc: add ioremap_early() function for mapping IO regions before MMU_init()

2008-08-14 Thread Kumar Gala


On Aug 12, 2008, at 10:03 PM, Grant Likely wrote:


+/**
+ * ioremap_early - Allow large persistant IO regions to be mapped  
early.

+ * @addr: physical address of region
+ * @size: size of region
+ *
+ * This routine uses setbat() to set up IO ranges before the MMU is
+ * fully configured.
+ *
+ * This routine can be called really early, before MMU_init() is  
called.  It
+ * is useful for setting up early debug output consoles and  
frequently
+ * accessed IO regions, like the internally memory mapped registers  
(IMMR)
+ * in an SoC.  Ranges mapped with this function persist even after  
MMU_init()

+ * is called and the MMU is turned on 'for real.'
+ *
+ * The region mapped is large (minimum size of 128k) and virtual  
mapping must
+ * be aligned against this boundary.  Therefore, to avoid  
fragmentation all

+ * calls to ioremap_early() are best made before any calls to ioremap
+ * for smaller regions.
+ */
+void __iomem * __init
+ioremap_early(phys_addr_t addr, unsigned long size)
+{
+   unsigned long v, p;
+   int i;
+
+   /* Be loud and annoying if someone calls this too late.
+* No need to crash the kernel though */
+   WARN_ON(mem_init_done);
+   if (mem_init_done)
+   return NULL;
+
+   /* Make sure request is sane */
+   if (size == 0)
+   return NULL;
+
+   /* If the region is already block mapped, then there is nothing
+* to do; just return the mapped address */
+   v = p_mapped_by_bats(addr);
+   if (v)
+   return (void __iomem *)v;
+
+   /* Adjust size to reflect aligned region */
+	p = _ALIGN_DOWN(addr, 128  10); /* BATs align on 128k boundaries  
*/

+   size = ALIGN(addr - p + size, 128  10);
+
+   /* Allocate the aligned virtual base address.  ALIGN_DOWN is used
+* to ensure no overlaps occur with normal 4k ioremaps. */
+   v = ioremap_bot = _ALIGN_DOWN(ioremap_bot, 128  10) - size;
+
+   /* Set up a BAT for this IO region */
+   i = loadbat(v, p, size, _PAGE_IO);


what happens if we run out of bats?


does this actually build on any non-BAT based ppc32 system?



+   if (i  0)
+   return NULL;
+
+   return (void __iomem *) (v + (addr - p));
+}
+


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


Re: [PATCH v2] libfdt: Add support for using aliases in fdt_path_offset()

2008-08-14 Thread David Gibson
On Thu, Aug 14, 2008 at 07:51:47AM -0500, Kumar Gala wrote:
 If the path doesn't start with '/' check to see if it matches some alias
 under /aliases and substitute the matching alias value in the path
 and retry the lookup.
 
 Signed-off-by: Kumar Gala [EMAIL PROTECTED]
 ---
 
 Fixed the bug pointed out by David Gibson and added tests.

Glad you spotted it in the end :)

[snip[]
 diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c
 index ebd1260..2f3ff48 100644
 --- a/libfdt/fdt_ro.c
 +++ b/libfdt/fdt_ro.c
 @@ -139,8 +139,25 @@ int fdt_path_offset(const void *fdt, const char *path)
 
   FDT_CHECK_HEADER(fdt);
 
 - if (*path != '/')
 - return -FDT_ERR_BADPATH;
 + /* see if we have an alias */
 + if (*path != '/') {
 + const char *q;
 + int aliasoffset = fdt_path_offset(fdt, /aliases);
 +
 + if (aliasoffset  0)
 + return -FDT_ERR_BADPATH;
 +
 + q = strchr(path, '/');
 + if (!q)
 + q = end;
 +
 + p = fdt_getprop_namelen(fdt, aliasoffset, path, q - p, NULL);
 + if (!p)
 + return -FDT_ERR_BADPATH;
 + offset = fdt_path_offset(fdt, p);
 +
 + p = q;
 + }

Much better.  It would be quite nice to have an explicit way of
retreiving the aliases too, but I can factor that out easily enough in
a later patch.

[snip]
 --- /dev/null
 +++ b/tests/aliases.dts
 @@ -0,0 +1,31 @@
 +/dts-v1/;
 +
 +/memreserve/ 0xdeadbeef 0x10;
 +/memreserve/ 123456789 01;

I'd drop these /memreserve/s, they're not relevant to the test.

 +
 +/ {
 + compatible = test_tree1;
 + prop-int = 0xdeadbeef;
 + prop-str = hello world;

Likewise the various prop-int and prop-str properties.

-- 
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@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH v3] libfdt: Add support for using aliases in fdt_path_offset()

2008-08-14 Thread Kumar Gala
If the path doesn't start with '/' check to see if it matches some alias
under /aliases and substitute the matching alias value in the path
and retry the lookup.

Signed-off-by: Kumar Gala [EMAIL PROTECTED]
---

Simplify down the aliases.dts to only whats needed for the test.

- k

 libfdt/fdt_ro.c |   21 ++-
 tests/Makefile.tests|2 +-
 tests/aliases.dts   |   21 +++
 tests/path_offset_aliases.c |   59 +++
 tests/run_tests.sh  |4 +++
 5 files changed, 104 insertions(+), 3 deletions(-)
 create mode 100644 tests/aliases.dts
 create mode 100644 tests/path_offset_aliases.c

diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c
index ebd1260..2f3ff48 100644
--- a/libfdt/fdt_ro.c
+++ b/libfdt/fdt_ro.c
@@ -139,8 +139,25 @@ int fdt_path_offset(const void *fdt, const char *path)

FDT_CHECK_HEADER(fdt);

-   if (*path != '/')
-   return -FDT_ERR_BADPATH;
+   /* see if we have an alias */
+   if (*path != '/') {
+   const char *q;
+   int aliasoffset = fdt_path_offset(fdt, /aliases);
+
+   if (aliasoffset  0)
+   return -FDT_ERR_BADPATH;
+
+   q = strchr(path, '/');
+   if (!q)
+   q = end;
+
+   p = fdt_getprop_namelen(fdt, aliasoffset, path, q - p, NULL);
+   if (!p)
+   return -FDT_ERR_BADPATH;
+   offset = fdt_path_offset(fdt, p);
+
+   p = q;
+   }

while (*p) {
const char *q;
diff --git a/tests/Makefile.tests b/tests/Makefile.tests
index 704c95d..44021b0 100644
--- a/tests/Makefile.tests
+++ b/tests/Makefile.tests
@@ -11,7 +11,7 @@ LIB_TESTS_L = get_mem_rsv \
open_pack rw_tree1 set_name setprop del_property del_node \
string_escapes references path-references boot-cpuid incbin \
dtbs_equal_ordered \
-   add_subnode_with_nops
+   add_subnode_with_nops path_offset_aliases
 LIB_TESTS = $(LIB_TESTS_L:%=$(TESTS_PREFIX)%)

 LIBTREE_TESTS_L = truncated_property
diff --git a/tests/aliases.dts b/tests/aliases.dts
new file mode 100644
index 000..39d88ff
--- /dev/null
+++ b/tests/aliases.dts
@@ -0,0 +1,21 @@
+/dts-v1/;
+
+/ {
+   aliases {
+   s1 = sub1;
+   ss1 = subsub1;
+   sss1 = subsubsub1;
+   };
+
+   sub1: [EMAIL PROTECTED] {
+   compatible = subnode1;
+
+   subsub1: subsubnode {
+   compatible = subsubnode1, subsubnode;
+
+   subsubsub1: subsubsubnode {
+   compatible = subsubsubnode1, subsubsubnode;
+   };
+   };
+   };
+};
diff --git a/tests/path_offset_aliases.c b/tests/path_offset_aliases.c
new file mode 100644
index 000..191edd2
--- /dev/null
+++ b/tests/path_offset_aliases.c
@@ -0,0 +1,59 @@
+/*
+ * libfdt - Flat Device Tree manipulation
+ * Testcase for fdt_path_offset()
+ * Copyright (C) 2006 David Gibson, IBM Corporation.
+ * Copyright 2008 Kumar Gala, Freescale Semiconductor, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include stdlib.h
+#include stdio.h
+#include string.h
+#include stdint.h
+
+#include fdt.h
+#include libfdt.h
+
+#include tests.h
+#include testdata.h
+
+void check_alias(void *fdt, const char *full_path, const char *alias_path)
+{
+   int offset, offset_a;
+
+   offset = fdt_path_offset(fdt, full_path);
+   offset_a = fdt_path_offset(fdt, alias_path);
+
+   if (offset != offset_a)
+   FAIL(Mismatch between %s path_offset (%d) and %s path_offset 
alias (%d),
+full_path, offset, alias_path, offset_a);
+}
+
+int main(int argc, char *argv[])
+{
+   void *fdt;
+
+   test_init(argc, argv);
+   fdt = load_blob_arg(argc, argv);
+
+   check_alias(fdt, /[EMAIL PROTECTED], s1);
+   check_alias(fdt, /[EMAIL PROTECTED]/subsubnode, ss1);
+   check_alias(fdt, /[EMAIL PROTECTED]/subsubnode, s1/subsubnode);
+   check_alias(fdt, /[EMAIL PROTECTED]/subsubnode/subsubsubnode, sss1);
+   check_alias(fdt, /[EMAIL PROTECTED]/subsubnode/subsubsubnode, 
ss1/subsubsubnode);
+   

Re: [PATCH v3] libfdt: Add support for using aliases in fdt_path_offset()

2008-08-14 Thread David Gibson
On Thu, Aug 14, 2008 at 08:28:19AM -0500, Kumar Gala wrote:
 If the path doesn't start with '/' check to see if it matches some alias
 under /aliases and substitute the matching alias value in the path
 and retry the lookup.
 
 Signed-off-by: Kumar Gala [EMAIL PROTECTED]

Acked-by: David Gibson [EMAIL PROTECTED]

-- 
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@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 1/3] gpiolib: make gpio_to_chip() public

2008-08-14 Thread Laurent Pinchart
On Friday 08 August 2008, Anton Vorontsov wrote:
 We'll need this function to write platform-specific hooks to deal
 with pin's dedicated functions. Quite obviously this will work only
 for the platforms with 1-to-1 GPIO to PIN mapping.
 
 This is stopgap solution till we think out and implement a proper
 api (pinlib?).

How do you support reverting the GPIO mode to non-dedicated ?

 Signed-off-by: Anton Vorontsov [EMAIL PROTECTED]
 ---
  drivers/gpio/gpiolib.c |3 ++-
  include/asm-generic/gpio.h |1 +
  2 files changed, 3 insertions(+), 1 deletions(-)
 
 diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
 index 8d29405..9536fa8 100644
 --- a/drivers/gpio/gpiolib.c
 +++ b/drivers/gpio/gpiolib.c
 @@ -81,10 +81,11 @@ static void gpio_ensure_requested(struct gpio_desc *desc)
  }
  
  /* caller holds gpio_lock *OR* gpio is marked as requested */
 -static inline struct gpio_chip *gpio_to_chip(unsigned gpio)
 +struct gpio_chip *gpio_to_chip(unsigned gpio)
  {
   return gpio_desc[gpio].chip;
  }
 +EXPORT_SYMBOL_GPL(gpio_to_chip);
  
  /* dynamic allocation of GPIOs, e.g. on a hotplugged device */
  static int gpiochip_find_base(int ngpio)
 diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
 index 0f99ad3..d70ee45 100644
 --- a/include/asm-generic/gpio.h
 +++ b/include/asm-generic/gpio.h
 @@ -81,6 +81,7 @@ struct gpio_chip {
   unsignedexported:1;
  };
  
 +extern struct gpio_chip *gpio_to_chip(unsigned gpio);
  extern const char *gpiochip_is_requested(struct gpio_chip *chip,
   unsigned offset);
  extern int __must_check gpiochip_reserve(int start, int ngpio);

-- 
Laurent Pinchart
CSE Semaphore Belgium

Chaussee de Bruxelles, 732A
B-1410 Waterloo
Belgium

T +32 (2) 387 42 59
F +32 (2) 387 42 75


signature.asc
Description: This is a digitally signed message part.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

Re: [PATCH 1/3] gpiolib: make gpio_to_chip() public

2008-08-14 Thread Anton Vorontsov
On Thu, Aug 14, 2008 at 04:04:18PM +0200, Laurent Pinchart wrote:
 On Friday 08 August 2008, Anton Vorontsov wrote:
  We'll need this function to write platform-specific hooks to deal
  with pin's dedicated functions. Quite obviously this will work only
  for the platforms with 1-to-1 GPIO to PIN mapping.
  
  This is stopgap solution till we think out and implement a proper
  api (pinlib?).
 
 How do you support reverting the GPIO mode to non-dedicated ?

As we always do with the GPIO API: gpio_direction_*() calls.

-- 
Anton Vorontsov
email: [EMAIL PROTECTED]
irc://irc.freenode.net/bd2
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 1/3] gpiolib: make gpio_to_chip() public

2008-08-14 Thread Laurent Pinchart
On Thursday 14 August 2008, Anton Vorontsov wrote:
 On Thu, Aug 14, 2008 at 04:04:18PM +0200, Laurent Pinchart wrote:
  On Friday 08 August 2008, Anton Vorontsov wrote:
   We'll need this function to write platform-specific hooks to deal
   with pin's dedicated functions. Quite obviously this will work only
   for the platforms with 1-to-1 GPIO to PIN mapping.
   
   This is stopgap solution till we think out and implement a proper
   api (pinlib?).
  
  How do you support reverting the GPIO mode to non-dedicated ?
 
 As we always do with the GPIO API: gpio_direction_*() calls.

So the proper sequence to configure a pin in dedicated mode is to set the 
direction first (which will unset the dedicated mode bit) and then set 
dedicated mode (which will not touch the direction bit) ?

-- 
Laurent Pinchart
CSE Semaphore Belgium

Chaussee de Bruxelles, 732A
B-1410 Waterloo
Belgium

T +32 (2) 387 42 59
F +32 (2) 387 42 75


signature.asc
Description: This is a digitally signed message part.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

Re: [RFC/PATCH v2] powerpc: add ioremap_early() function for mapping IO regions before MMU_init()

2008-08-14 Thread Grant Likely
On Thu, Aug 14, 2008 at 7:00 AM, Kumar Gala [EMAIL PROTECTED] wrote:

 On Aug 12, 2008, at 10:03 PM, Grant Likely wrote:

 +/**
 + * ioremap_early - Allow large persistant IO regions to be mapped early.
 + * @addr: physical address of region
 + * @size: size of region
 + *
 + * This routine uses setbat() to set up IO ranges before the MMU is
 + * fully configured.
 + *
 + * This routine can be called really early, before MMU_init() is called.
  It
 + * is useful for setting up early debug output consoles and frequently
 + * accessed IO regions, like the internally memory mapped registers
 (IMMR)
 + * in an SoC.  Ranges mapped with this function persist even after
 MMU_init()
 + * is called and the MMU is turned on 'for real.'
 + *
 + * The region mapped is large (minimum size of 128k) and virtual mapping
 must
 + * be aligned against this boundary.  Therefore, to avoid fragmentation
 all
 + * calls to ioremap_early() are best made before any calls to ioremap
 + * for smaller regions.
 + */
 +void __iomem * __init
 +ioremap_early(phys_addr_t addr, unsigned long size)
 +{
 +   unsigned long v, p;
 +   int i;
 +
 +   /* Be loud and annoying if someone calls this too late.
 +* No need to crash the kernel though */
 +   WARN_ON(mem_init_done);
 +   if (mem_init_done)
 +   return NULL;
 +
 +   /* Make sure request is sane */
 +   if (size == 0)
 +   return NULL;
 +
 +   /* If the region is already block mapped, then there is nothing
 +* to do; just return the mapped address */
 +   v = p_mapped_by_bats(addr);
 +   if (v)
 +   return (void __iomem *)v;
 +
 +   /* Adjust size to reflect aligned region */
 +   p = _ALIGN_DOWN(addr, 128  10); /* BATs align on 128k boundaries
 */
 +   size = ALIGN(addr - p + size, 128  10);
 +
 +   /* Allocate the aligned virtual base address.  ALIGN_DOWN is used
 +* to ensure no overlaps occur with normal 4k ioremaps. */
 +   v = ioremap_bot = _ALIGN_DOWN(ioremap_bot, 128  10) - size;
 +
 +   /* Set up a BAT for this IO region */
 +   i = loadbat(v, p, size, _PAGE_IO);

 what happens if we run out of bats?

Then it returns NULL and the caller must handle it.  The board port
maintainer needs understand the board/CPU/SoC and not depend on more
BATs than are available.  They also need to understand that there is a
tradeoff between BATs for IO and BATs for RAM.  If the board port uses
up all the BATs for IO, then RAM above 256MB ends up getting mapped
with PTEs and there is a performance hit.  My expectation is that only
platform code will use this facility.  Device drivers should continue
to use ioremap() and will gain the benefit of the BATs if platform
code already set them up.  I can add some text to the documentation to
describe this.

I'm not going to make any attempt to fallback to PTEs for IO when
there isn't enough BATs.  Doing so adds an order of magnitude more
complexity.

 does this actually build on any non-BAT based ppc32 system?

Heh, oops.  I had built the older version of this on 4xx, but I didn't
do this one.  I'll fix it in v3

g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH v3] libfdt: Add support for using aliases in fdt_path_offset()

2008-08-14 Thread Jon Loeliger
 If the path doesn't start with '/' check to see if it matches some alias
 under /aliases and substitute the matching alias value in the path
 and retry the lookup.
 
 Signed-off-by: Kumar Gala [EMAIL PROTECTED]

Applied.

jdl
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 1/3] gpiolib: make gpio_to_chip() public

2008-08-14 Thread Anton Vorontsov
On Thu, Aug 14, 2008 at 04:45:52PM +0200, Laurent Pinchart wrote:
 On Thursday 14 August 2008, Anton Vorontsov wrote:
  On Thu, Aug 14, 2008 at 04:04:18PM +0200, Laurent Pinchart wrote:
   On Friday 08 August 2008, Anton Vorontsov wrote:
We'll need this function to write platform-specific hooks to deal
with pin's dedicated functions. Quite obviously this will work only
for the platforms with 1-to-1 GPIO to PIN mapping.

This is stopgap solution till we think out and implement a proper
api (pinlib?).
   
   How do you support reverting the GPIO mode to non-dedicated ?
  
  As we always do with the GPIO API: gpio_direction_*() calls.
 
 So the proper sequence to configure a pin in dedicated mode is to set
 the direction first (which will unset the dedicated mode bit) and
 then set dedicated mode (which will not touch the direction bit) ?

Not exactly. But you can do this way, if you need to preserve
a direction. What I did is a bit different though.

qe_gpio_set_dedicated() actually just restores a mode that
firmware had set up, including direction (since direction could
be a part of dedicated configuration).

That is, upon GPIO controller registration, we save all registers,
then driver can set up a pin to a GPIO mode via standard API, and
then it can _revert_ a pin to a dedicated function via
qe_gpio_set_dedicated() call. Dedicated function is specified by
the firmware (or board file), we're just restoring it.

-- 
Anton Vorontsov
email: [EMAIL PROTECTED]
irc://irc.freenode.net/bd2
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 1/2] port ndfc driver to of platform

2008-08-14 Thread Sean MacLennan
On Thu, 14 Aug 2008 11:53:07 +0200
Arnd Bergmann [EMAIL PROTECTED] wrote:

  +   ndfc-ndfcbase = ioremap(reg[1], reg[2]);
 
 This could be better expressed as of_iomap().

I tried of_iomap(), but it doesn't seem to like the 3 value reg. i.e.
It doesn't skip the chip select. And since I need to read the reg
property to get the chip select any way, I just used the value directly.

 
  -   platform_set_drvdata(pdev, ndfc);
  +   __raw_writel(ccr, ndfc-ndfcbase + NDFC_CCR);
   
  -   printk(NDFC NAND Driver initialized. Chip-Rev: 0x%08x\n,
  -  __raw_readl(ndfc-ndfcbase + NDFC_REVID));
  +   /* Set the bank settings */
  +   reg = of_get_property(ofdev-node, bank_settings, NULL);
  +   bank_settings = reg ? *reg : 0x8000;
 
 Your device tree does have a bank_setting, so why not assume that
 all others will have it as well? I would remove the default.

I am thinking of making the bank settings an optional value. I assume
most people with 44x chips with NAND will be using u-boot. If you
enable NAND in u-boot, it should configure the bank settings for you.

I put the bank setting in my dts just to show a complete
configuration.

Cheers,
   Sean
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [RFC/PATCH v2] powerpc: add ioremap_early() function for mapping IO regions before MMU_init()

2008-08-14 Thread Kumar Gala

what happens if we run out of bats?


Then it returns NULL and the caller must handle it.  The board port
maintainer needs understand the board/CPU/SoC and not depend on more
BATs than are available.  They also need to understand that there is a
tradeoff between BATs for IO and BATs for RAM.  If the board port uses
up all the BATs for IO, then RAM above 256MB ends up getting mapped
with PTEs and there is a performance hit.  My expectation is that only
platform code will use this facility.  Device drivers should continue
to use ioremap() and will gain the benefit of the BATs if platform
code already set them up.  I can add some text to the documentation to
describe this.

I'm not going to make any attempt to fallback to PTEs for IO when
there isn't enough BATs.  Doing so adds an order of magnitude more
complexity.


that's fine.. I just didn't look at setbat() to see it errors out.

Also can we get rid of LOAD_BAT in head_32.S?

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


Re: [PATCH 2/2] port ndfc driver to of platform

2008-08-14 Thread Jon Loeliger

Arnd Bergmann wrote:


Did we ever come to a conclusion on how this could be done, e.g. with
preprocessed dts files or simpler dynamic patching of binary device
trees?



I am working on it.

jdl
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [RFC/PATCH v2] powerpc: add ioremap_early() function for mapping IO regions before MMU_init()

2008-08-14 Thread Grant Likely
On Thu, Aug 14, 2008 at 10:24 AM, Kumar Gala [EMAIL PROTECTED] wrote:
 what happens if we run out of bats?

 Then it returns NULL and the caller must handle it.  The board port
 maintainer needs understand the board/CPU/SoC and not depend on more
 BATs than are available.  They also need to understand that there is a
 tradeoff between BATs for IO and BATs for RAM.  If the board port uses
 up all the BATs for IO, then RAM above 256MB ends up getting mapped
 with PTEs and there is a performance hit.  My expectation is that only
 platform code will use this facility.  Device drivers should continue
 to use ioremap() and will gain the benefit of the BATs if platform
 code already set them up.  I can add some text to the documentation to
 describe this.

 I'm not going to make any attempt to fallback to PTEs for IO when
 there isn't enough BATs.  Doing so adds an order of magnitude more
 complexity.

 that's fine.. I just didn't look at setbat() to see it errors out.

 Also can we get rid of LOAD_BAT in head_32.S?

Mostly.  It is still needed for BAT0 when setting up RAM, but the rest
of it can be dumped.

g.


-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH] powerpc/83xx: mpc836x_mds: add support for the nor flash

2008-08-14 Thread Anton Vorontsov
This patch adds the localbus node, moves the bcsr node into the
localbus node, and adds the flash node.

Also enable MTD support in the defconfig.

Signed-off-by: Anton Vorontsov [EMAIL PROTECTED]
---
 arch/powerpc/boot/dts/mpc836x_mds.dts   |   23 ++-
 arch/powerpc/configs/83xx/mpc836x_mds_defconfig |   79 ++-
 2 files changed, 98 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/boot/dts/mpc836x_mds.dts 
b/arch/powerpc/boot/dts/mpc836x_mds.dts
index a3b76a7..ada8446 100644
--- a/arch/powerpc/boot/dts/mpc836x_mds.dts
+++ b/arch/powerpc/boot/dts/mpc836x_mds.dts
@@ -52,9 +52,26 @@
reg = 0x 0x1000;
};
 
-   [EMAIL PROTECTED] {
-   device_type = board-control;
-   reg = 0xf800 0x8000;
+   [EMAIL PROTECTED] {
+   #address-cells = 2;
+   #size-cells = 1;
+   compatible = fsl,mpc8360-localbus, fsl,pq2pro-localbus,
+simple-bus;
+   reg = 0xe0005000 0xd8;
+   ranges = 0 0 0xfe00 0x0200
+ 1 0 0xf800 0x8000;
+
+   [EMAIL PROTECTED],0 {
+   compatible = cfi-flash;
+   reg = 0 0 0x200;
+   bank-width = 2;
+   device-width = 1;
+   };
+
+   [EMAIL PROTECTED],0 {
+   device_type = board-control;
+   reg = 1 0 0x8000;
+   };
};
 
[EMAIL PROTECTED] {
diff --git a/arch/powerpc/configs/83xx/mpc836x_mds_defconfig 
b/arch/powerpc/configs/83xx/mpc836x_mds_defconfig
index 20fd9f5..c76194b 100644
--- a/arch/powerpc/configs/83xx/mpc836x_mds_defconfig
+++ b/arch/powerpc/configs/83xx/mpc836x_mds_defconfig
@@ -357,7 +357,84 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
 # CONFIG_FW_LOADER is not set
 # CONFIG_SYS_HYPERVISOR is not set
 # CONFIG_CONNECTOR is not set
-# CONFIG_MTD is not set
+CONFIG_MTD=y
+# CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_CONCAT is not set
+CONFIG_MTD_PARTITIONS=y
+# CONFIG_MTD_REDBOOT_PARTS is not set
+CONFIG_MTD_CMDLINE_PARTS=y
+# CONFIG_MTD_OF_PARTS is not set
+# CONFIG_MTD_AR7_PARTS is not set
+
+#
+# User Modules And Translation Layers
+#
+CONFIG_MTD_CHAR=y
+CONFIG_MTD_BLKDEVS=y
+CONFIG_MTD_BLOCK=y
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
+# CONFIG_RFD_FTL is not set
+# CONFIG_SSFDC is not set
+# CONFIG_MTD_OOPS is not set
+
+#
+# RAM/ROM/Flash chip drivers
+#
+CONFIG_MTD_CFI=y
+# CONFIG_MTD_JEDECPROBE is not set
+CONFIG_MTD_GEN_PROBE=y
+# CONFIG_MTD_CFI_ADV_OPTIONS is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+# CONFIG_MTD_CFI_INTELEXT is not set
+CONFIG_MTD_CFI_AMDSTD=y
+# CONFIG_MTD_CFI_STAA is not set
+CONFIG_MTD_CFI_UTIL=y
+# CONFIG_MTD_RAM is not set
+# CONFIG_MTD_ROM is not set
+# CONFIG_MTD_ABSENT is not set
+
+#
+# Mapping drivers for chip access
+#
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
+# CONFIG_MTD_PHYSMAP is not set
+CONFIG_MTD_PHYSMAP_OF=y
+# CONFIG_MTD_INTEL_VR_NOR is not set
+# CONFIG_MTD_PLATRAM is not set
+
+#
+# Self-contained MTD device drivers
+#
+# CONFIG_MTD_PMC551 is not set
+# CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
+# CONFIG_MTD_MTDRAM is not set
+# CONFIG_MTD_BLOCK2MTD is not set
+
+#
+# Disk-On-Chip Device Drivers
+#
+# CONFIG_MTD_DOC2000 is not set
+# CONFIG_MTD_DOC2001 is not set
+# CONFIG_MTD_DOC2001PLUS is not set
+# CONFIG_MTD_NAND is not set
+# CONFIG_MTD_ONENAND is not set
+
+#
+# UBI - Unsorted block images
+#
+# CONFIG_MTD_UBI is not set
 CONFIG_OF_DEVICE=y
 CONFIG_OF_I2C=y
 # CONFIG_PARPORT is not set
-- 
1.5.6.3
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 1/2] port ndfc driver to of platform

2008-08-14 Thread Sean MacLennan
Second version of patch with cleanups. Note that this patch is slightly
different I diffed the last patch against my master git rather than
Linus' master git :( The difference is that my git already had the
ports to arch/powerpc.

Cheers,
   Sean

Port of the ndfc driver to an of platform driver.

Signed-off-by: Sean MacLennan [EMAIL PROTECTED]
---
diff --git a/drivers/mtd/nand/ndfc.c b/drivers/mtd/nand/ndfc.c
index 955959e..f09cd27 100644
--- a/drivers/mtd/nand/ndfc.c
+++ b/drivers/mtd/nand/ndfc.c
@@ -5,9 +5,13 @@
  *   Platform independend driver for NDFC (NanD Flash Controller)
  *   integrated into EP440 cores
  *
+ *   Ported to an OF platform driver by Sean MacLennan
+ *
  *  Author: Thomas Gleixner
  *
  *  Copyright 2006 IBM
+ *  Copyright 2008 PIKA Technologies
+ *Sean MacLennan [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
@@ -21,27 +25,17 @@
 #include linux/mtd/partitions.h
 #include linux/mtd/ndfc.h
 #include linux/mtd/mtd.h
-#include linux/platform_device.h
-
+#include linux/of_platform.h
 #include asm/io.h
-#ifdef CONFIG_40x
-#include asm/ibm405.h
-#else
-#include asm/ibm44x.h
-#endif
-
-struct ndfc_nand_mtd {
-   struct mtd_info mtd;
-   struct nand_chipchip;
-   struct platform_nand_chip   *pl_chip;
-};
 
-static struct ndfc_nand_mtd ndfc_mtd[NDFC_MAX_BANKS];
 
 struct ndfc_controller {
-   void __iomem*ndfcbase;
-   struct nand_hw_control  ndfc_control;
-   atomic_tchilds_active;
+   struct of_device *ofdev;
+   void __iomem *ndfcbase;
+   struct mtd_info mtd;
+   struct nand_chip chip;
+   int chip_select;
+   struct nand_hw_control ndfc_control;
 };
 
 static struct ndfc_controller ndfc_ctrl;
@@ -50,17 +44,14 @@ static void ndfc_select_chip(struct mtd_info *mtd, int chip)
 {
uint32_t ccr;
struct ndfc_controller *ndfc = ndfc_ctrl;
-   struct nand_chip *nandchip = mtd-priv;
-   struct ndfc_nand_mtd *nandmtd = nandchip-priv;
-   struct platform_nand_chip *pchip = nandmtd-pl_chip;
 
-   ccr = __raw_readl(ndfc-ndfcbase + NDFC_CCR);
+   ccr = in_be32(ndfc-ndfcbase + NDFC_CCR);
if (chip = 0) {
ccr = ~NDFC_CCR_BS_MASK;
-   ccr |= NDFC_CCR_BS(chip + pchip-chip_offset);
+   ccr |= NDFC_CCR_BS(chip + ndfc-chip_select);
} else
ccr |= NDFC_CCR_RESET_CE;
-   __raw_writel(ccr, ndfc-ndfcbase + NDFC_CCR);
+   out_be32(ndfc-ndfcbase + NDFC_CCR, ccr);
 }
 
 static void ndfc_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
@@ -80,7 +71,7 @@ static int ndfc_ready(struct mtd_info *mtd)
 {
struct ndfc_controller *ndfc = ndfc_ctrl;
 
-   return __raw_readl(ndfc-ndfcbase + NDFC_STAT)  NDFC_STAT_IS_READY;
+   return in_be32(ndfc-ndfcbase + NDFC_STAT)  NDFC_STAT_IS_READY;
 }
 
 static void ndfc_enable_hwecc(struct mtd_info *mtd, int mode)
@@ -88,9 +79,9 @@ static void ndfc_enable_hwecc(struct mtd_info *mtd, int mode)
uint32_t ccr;
struct ndfc_controller *ndfc = ndfc_ctrl;
 
-   ccr = __raw_readl(ndfc-ndfcbase + NDFC_CCR);
+   ccr = in_be32(ndfc-ndfcbase + NDFC_CCR);
ccr |= NDFC_CCR_RESET_ECC;
-   __raw_writel(ccr, ndfc-ndfcbase + NDFC_CCR);
+   out_be32(ndfc-ndfcbase + NDFC_CCR, ccr);
wmb();
 }
 
@@ -102,9 +93,10 @@ static int ndfc_calculate_ecc(struct mtd_info *mtd,
uint8_t *p = (uint8_t *)ecc;
 
wmb();
-   ecc = __raw_readl(ndfc-ndfcbase + NDFC_ECC);
-   ecc_code[0] = p[1];
-   ecc_code[1] = p[2];
+   ecc = in_be32(ndfc-ndfcbase + NDFC_ECC);
+   /* The NDFC uses Smart Media (SMC) bytes order */
+   ecc_code[0] = p[2];
+   ecc_code[1] = p[1];
ecc_code[2] = p[3];
 
return 0;
@@ -123,7 +115,7 @@ static void ndfc_read_buf(struct mtd_info *mtd, uint8_t 
*buf, int len)
uint32_t *p = (uint32_t *) buf;
 
for(;len  0; len -= 4)
-   *p++ = __raw_readl(ndfc-ndfcbase + NDFC_DATA);
+   *p++ = in_be32(ndfc-ndfcbase + NDFC_DATA);
 }
 
 static void ndfc_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
@@ -132,7 +124,7 @@ static void ndfc_write_buf(struct mtd_info *mtd, const 
uint8_t *buf, int len)
uint32_t *p = (uint32_t *) buf;
 
for(;len  0; len -= 4)
-   __raw_writel(*p++, ndfc-ndfcbase + NDFC_DATA);
+   out_be32(ndfc-ndfcbase + NDFC_DATA, *p++);
 }
 
 static int ndfc_verify_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
@@ -141,7 +133,7 @@ static int ndfc_verify_buf(struct mtd_info *mtd, const 
uint8_t *buf, int len)
uint32_t *p = (uint32_t *) buf;
 
for(;len  0; len -= 4)
-   if (*p++ != __raw_readl(ndfc-ndfcbase + NDFC_DATA))
+   if (*p++ != in_be32(ndfc-ndfcbase + 

Re: [PATCH v3] libfdt: Add support for using aliases in fdt_path_offset()

2008-08-14 Thread Scott Wood
On Thu, Aug 14, 2008 at 08:28:19AM -0500, Kumar Gala wrote:
 - if (*path != '/')
 - return -FDT_ERR_BADPATH;
 + /* see if we have an alias */
 + if (*path != '/') {
 + const char *q;
 + int aliasoffset = fdt_path_offset(fdt, /aliases);
 +
 + if (aliasoffset  0)
 + return -FDT_ERR_BADPATH;
 +
 + q = strchr(path, '/');
 + if (!q)
 + q = end;
 +
 + p = fdt_getprop_namelen(fdt, aliasoffset, path, q - p, NULL);
 + if (!p)
 + return -FDT_ERR_BADPATH;
 + offset = fdt_path_offset(fdt, p);
 +
 + p = q;
 + }

Can we limit the recursion depth to avoid falling off the stack if an
alias points to itself?  Or if aliases pointing to aliases are
disallowed, check for a leading '/' before recursively calling
fdt_path_offset.

-Scott
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


oops in proc_sys_compare

2008-08-14 Thread Hugh Dickins
I got this oops below, after several hours of swap-heavy kernel builds
in tmpfs, on 2.6.27-rc1-mm1 a couple of weeks ago.  Tried to reproduce
it without success, then got a very similar trace (not saved) from
2.6.27-rc3 itself doing the same test yesterday: again oopsing in
proc_sys_compare on address -16, looks like it's trying for
PROC_I(dentry-d_inode)-sysctl but d_inode is NULL.

I looked to see what's been going on in fs/proc recently, and your
[PATCH] sanitize proc_sysctl 9043476f726802f4b00c96d0c4f418dde48d1304
does sound like it might be implicated.  I've only seen this on
PowerPC G5, similar tests on x86_32 and _64 haven't shown it:
maybe a memory barrier needed somewhere?

Hugh

Unable to handle kernel paging request for data at address 0xfff0
Faulting instruction address: 0xc0121ec4
Oops: Kernel access of bad area, sig: 11 [#1]
PREEMPT SMP NR_CPUS=4 PowerMac
Modules linked in:
NIP: c0121ec4 LR: c0121eb4 CTR: 
REGS: c2af33f0 TRAP: 0300   Not tainted  (2.6.27-rc1-mm1)
MSR: 90009032 EE,ME,IR,DR  CR: 24222482  XER: 
DAR: fff0, DSISR: 4000
TASK = c2d22500[26561] 'sh' THREAD: c2af CPU: 3
GPR00: 0078 c2af3670 c05cf520  
GPR04: c21ba01b 000b c00015e63596 c21ba011 
GPR08: 0001f59632fdb346  0001  
GPR12: 20222424 c05ec800   
GPR16: 200be41c  c2af38d0 c2af38b0 
GPR20: c2af38c0 c2af3bf8 0101 0024 
GPR24: c21ba011 32fdb346 000b c2af38c0 
GPR28: c00015e634f8 c00015e634e0 c0562498 c00015e63510 
NIP [c0121ec4] .proc_sys_compare+0x48/0x7c
LR [c0121eb4] .proc_sys_compare+0x38/0x7c
Call Trace:
[c2af3670] [c0522620] root_table_header+0x0/0x58 (unreliable)
[c2af36f0] [c00dabdc] .__d_lookup+0xf4/0x1f0
[c2af37a0] [c00d0978] .do_lookup+0x38/0x128
[c2af3840] [c00d1438] .__link_path_walk+0x9d0/0xf30
[c2af3950] [c00d19f0] .path_walk+0x58/0xc4
[c2af3a00] [c00d1b94] .do_path_lookup+0x138/0x17c
[c2af3ab0] [c00d1cc8] .__path_lookup_intent_open+0x78/0xdc
[c2af3b60] [c00d2960] .do_filp_open+0xcc/0x764
[c2af3d00] [c00c5454] .do_sys_open+0x80/0x14c
[c2af3db0] [c0108378] .compat_sys_open+0x24/0x38
[c2af3e30] [c00076ac] syscall_exit+0x0/0x40
Instruction dump:
6000 80a40004 80090004 7f802800 409e003c e8890008 e87f0008 4bf0aa45 
6000 2fa3 409e0024 e93fffe0 e869fff0 4bf2f84d 6000 7c630034 
---[ end trace ac14ee183d55eec5 ]---
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [RFC/PATCH v2] powerpc: add ioremap_early() function for mapping IO regions before MMU_init()

2008-08-14 Thread Kumar Gala


On Aug 14, 2008, at 11:43 AM, Grant Likely wrote:

On Thu, Aug 14, 2008 at 10:24 AM, Kumar Gala [EMAIL PROTECTED] 
 wrote:

what happens if we run out of bats?


Then it returns NULL and the caller must handle it.  The board port
maintainer needs understand the board/CPU/SoC and not depend on more
BATs than are available.  They also need to understand that there  
is a
tradeoff between BATs for IO and BATs for RAM.  If the board port  
uses

up all the BATs for IO, then RAM above 256MB ends up getting mapped
with PTEs and there is a performance hit.  My expectation is that  
only
platform code will use this facility.  Device drivers should  
continue

to use ioremap() and will gain the benefit of the BATs if platform
code already set them up.  I can add some text to the  
documentation to

describe this.

I'm not going to make any attempt to fallback to PTEs for IO when
there isn't enough BATs.  Doing so adds an order of magnitude more
complexity.


that's fine.. I just didn't look at setbat() to see it errors out.

Also can we get rid of LOAD_BAT in head_32.S?


Mostly.  It is still needed for BAT0 when setting up RAM, but the rest
of it can be dumped.


Can we not do BAT0 in C code?

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


__attribute_used__ in 2.6.24

2008-08-14 Thread Kevin Diggs

Hi,

	Something in a function signature called __attribute_used__ would 
compile in 2.6.24. This does not compile in 2.6.26. Using the 
store_##NAME template from arch/powerpc/kernel/sysfs.c as a guide, 
this appears to have changed to __used. Anything work in both? 
__used seems to have compiled in 2.6.24?


kevin
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [RFC/PATCH v2] powerpc: add ioremap_early() function for mapping IO regions before MMU_init()

2008-08-14 Thread Grant Likely
On Thu, Aug 14, 2008 at 1:59 PM, Kumar Gala [EMAIL PROTECTED] wrote:

 On Aug 14, 2008, at 11:43 AM, Grant Likely wrote:

 On Thu, Aug 14, 2008 at 10:24 AM, Kumar Gala [EMAIL PROTECTED]
 wrote:

 what happens if we run out of bats?

 Then it returns NULL and the caller must handle it.  The board port
 maintainer needs understand the board/CPU/SoC and not depend on more
 BATs than are available.  They also need to understand that there is a
 tradeoff between BATs for IO and BATs for RAM.  If the board port uses
 up all the BATs for IO, then RAM above 256MB ends up getting mapped
 with PTEs and there is a performance hit.  My expectation is that only
 platform code will use this facility.  Device drivers should continue
 to use ioremap() and will gain the benefit of the BATs if platform
 code already set them up.  I can add some text to the documentation to
 describe this.

 I'm not going to make any attempt to fallback to PTEs for IO when
 there isn't enough BATs.  Doing so adds an order of magnitude more
 complexity.

 that's fine.. I just didn't look at setbat() to see it errors out.

 Also can we get rid of LOAD_BAT in head_32.S?

 Mostly.  It is still needed for BAT0 when setting up RAM, but the rest
 of it can be dumped.

 Can we not do BAT0 in C code?

Not easily.  Currently BAT0 gives us the first 16M of RAM during early
boot.  The new code protects BAT0 and makes sure it can only be used
for mapping RAM.  If it got chosen for an IO mapping, then it would
get blown away immediately and the kernel would crash.  Its okay for
BAT0 to be used for RAM because RAM doesn't need to be immediately
mapped.  It can wait just setup the data and wait for LOAD_BAT to fix
it up.

An alternate solution is to reserve a second BAT higher up to use as
the 'real' RAM mapping so that 'real' mapping of RAM could be
performed immediately while leaving the old one intact.  That would
eliminate the need for LOAD_BAT, but it also leaves only 2 BAT slots
available for IO and memory above 256M.  On the other hand, it might
be okay to release the reserved BATs after the first real RAM mapping
is established, but doing so adds some complexity to the handling of
__map_without_bats because the initial mapping still needs to be
disabled in head_32.S.

g.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 1/2] port ndfc driver to of platform

2008-08-14 Thread Sean MacLennan
On Thu, 14 Aug 2008 22:16:45 +0200
Arnd Bergmann [EMAIL PROTECTED] wrote:

 If of_iomap and of_address_to_resource don't work properly, there
 is probably something wrong in your device tree, maybe an incorrect
 #size-cells or #address-cells or ranges property in one of
 the parents. You need to fix this anyway.

Ga, no my dts is wrong. I must have looked at it a dozen times
before I clued in that now that ndfc is a proper of driver I need to
specify the chip select and the *offset*, not the chip select and the
*address*.

New patches soon.

Cheers,
   Sean
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH] DTC: Remove support for the legacy DTS source file format.

2008-08-14 Thread Jon Loeliger

Now that all in-kernel-tree DTS files are properly /dts-v1/,
remove direct support for the older, un-numbered DTS
source file format.

Convert existing tests to /dts-v1/ and remove support
for the conversion tests themselves.

For now, though, the conversion tool still exists.

Signed-off-by: Jon Loeliger [EMAIL PROTECTED]
---
 dtc-lexer.l   |   15 ---
 dtc-parser.y  |   28 
 tests/base01.dts  |   24 +---
 tests/empty.dts   |2 ++
 tests/escapes.dts |2 ++
 tests/label01.dts |   38 --
 tests/references_dts0.dts |   12 +++-
 tests/run_tests.sh|   27 +--
 tests/test01.dts  |   38 --
 tests/test_tree1_dts0.dts |   18 ++
 10 files changed, 75 insertions(+), 129 deletions(-)

diff --git a/dtc-lexer.l b/dtc-lexer.l
index 6f8b7dd..87380be 100644
--- a/dtc-lexer.l
+++ b/dtc-lexer.l
@@ -110,21 +110,6 @@ static int pop_input_file(void);
return DT_LABEL;
}
 
-INITIAL[bodh]# {
-   yylloc.file = srcpos_file;
-   yylloc.first_line = yylineno;
-   if (*yytext == 'b')
-   yylval.cbase = 2;
-   else if (*yytext == 'o')
-   yylval.cbase = 8;
-   else if (*yytext == 'd')
-   yylval.cbase = 10;
-   else
-   yylval.cbase = 16;
-   DPRINT(Base: %d\n, yylval.cbase);
-   return DT_BASE;
-   }
-
 INITIAL[0-9a-fA-F]+  {
yylloc.file = srcpos_file;
yylloc.first_line = yylineno;
diff --git a/dtc-parser.y b/dtc-parser.y
index b2ab562..7f2e00a 100644
--- a/dtc-parser.y
+++ b/dtc-parser.y
@@ -67,8 +67,6 @@ static unsigned long long eval_literal(const char *s, int 
base, int bits);
 %type data propdataprefix
 %type re memreserve
 %type re memreserves
-%type re v0_memreserve
-%type re v0_memreserves
 %type addr addr
 %type data celllist
 %type cbase cellbase
@@ -90,10 +88,6 @@ sourcefile:
{
the_boot_info = build_boot_info($3, $4, 0);
}
-   | v0_memreserves devicetree
-   {
-   the_boot_info = build_boot_info($1, $2, 0);
-   }
;
 
 memreserves:
@@ -114,28 +108,6 @@ memreserve:
}
;
 
-v0_memreserves:
- /* empty */
-   {
-   $$ = NULL;
-   }
-   | v0_memreserve v0_memreserves
-   {
-   $$ = chain_reserve_entry($1, $2);
-   };
-   ;
-
-v0_memreserve:
- memreserve
-   {
-   $$ = $1;
-   }
-   | label DT_MEMRESERVE addr '-' addr ';'
-   {
-   $$ = build_reserve_entry($3, $5 - $3 + 1, $1);
-   }
-   ;
-
 addr:
  DT_LITERAL
{
diff --git a/tests/base01.dts b/tests/base01.dts
index f84bc49..97a5dd5 100644
--- a/tests/base01.dts
+++ b/tests/base01.dts
@@ -1,3 +1,5 @@
+/dts-v1/;
+
 / {
model = SomeModel;
compatible = Nothing;
@@ -6,26 +8,26 @@
 
 [EMAIL PROTECTED] {
 device_type = memory;
-   reg =    2000;
+   reg = 0x 0x 0x 0x2000;
 };
 
cpus {
#address-cells = 1;
#size-cells = 0;
-   d10 = d# 10;  // hex: 0xa
-   d23 = d# 23;  // hex: 0x17
-   b101 = b# 101;// hex: 0x5
-   o17 = o# 17;  // hex: 0xf
-   hd00d = h# d00d;  // hex: 0xd00d
+   d10 =  10;// hex: 0xa
+   d23 =  23;// hex: 0x17
+   b101 =  0x5;  // hex: 0x5
+   o17 =  017;   // hex: 0xf
+   hd00d =  0xd00d;  // hex: 0xd00d
 
//   hex:  0x4d20x163e  0x23340xd80
-   stuff = d# 1234d# 5678d# 9012d# 3456;
+   stuff =  1234 5678 9012 3456;
 
 
-   bad-d-1 = d# abc123;  // Hrm. 0
-   bad-d-2 = d# 123456789012345;
-   bad-o-1 = o# 891;
-   bad-o-2 = o# 123456123456;
+   bad-d-1 =  0; // Hrm. 0
+   bad-d-2 =  123456789012345;
+   bad-o-1 =  00;
+   bad-o-2 =  0123456123456;
};
 
 };
diff --git a/tests/empty.dts b/tests/empty.dts
index 336d7a2..e160dad 100644
--- a/tests/empty.dts
+++ b/tests/empty.dts
@@ -1,2 +1,4 @@
+/dts-v1/;
+
 / {
 };
diff --git a/tests/escapes.dts 

Re: [PATCH 2.6.27] [POWERPC] Invalidate all TLB entries in a specified range

2008-08-14 Thread Benjamin Herrenschmidt
On Thu, 2008-08-14 at 07:11 -0600, Rocky Craig wrote:
 From: Rocky Craig [EMAIL PROTECTED]
 
 The apparent intent of flush_tlbs is to invalidate TLB entries that
 might match in the address range 0 to 0x0040.  A loop counter is 
 set up at the high value and decremented by page size.  However, the 
 loop is only done once as the sense of the conditional branch at the
 loop end does not match the setup/decrement.
 
 Signed-off-by: Rocky Craig [EMAIL PROTECTED]
 ---
 
 Source is from 2.6.27 development, but the bug appears as far back as 2.4.0.
 The small user-space program below demonstrates the loop behavior.  It was
 compiled via crosstool gcc 3.4.5 / glibc 2.3.6 for an MPC8347 target.

Heh nice, that's a bug as old as the port I would say :-)

Ben.
 
 int main()
 {
   long endval;// 16(r31)
 
   __asm__ __volatile__(
  lis 10,0x40\n
   1: addic. 10,10,-0x1000\n
  bgt 1b\n
  stw 10,16(31)\n);  // endval
 
   printf(end value = 0x%08lx\n, endval);
 }
 
 This might win the prize for Smallest actual code patch ever.
 
 --- a/arch/powerpc/kernel/head_32.S.orig  2008-07-24 19:25:09.0 
 -0600
 +++ a/arch/powerpc/kernel/head_32.S   2008-07-24 19:25:22.0 -0600
 @@ -1155,7 +1155,7 @@ flush_tlbs:
   lis r10, 0x40
  1:   addic.  r10, r10, -0x1000
   tlbie   r10
 - blt 1b
 + bgt 1b
   sync
   blr
  
 
 

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


[PATCH V2] DTC: Remove support for the legacy DTS source file format.

2008-08-14 Thread Jon Loeliger
Now that all in-kernel-tree DTS files are properly /dts-v1/,
remove direct support for the older, un-numbered DTS
source file format.

Convert existing tests to /dts-v1/ and remove support
for the conversion tests themselves.

For now, though, the conversion tool still exists.

Signed-off-by: Jon Loeliger [EMAIL PROTECTED]

---

Bah.  Forgot to eliminate the legacy BASE and
LITERAL tokens in the first version of this patch.

There's still a bit more improvement possible WRT
the initial dts_versio value and lexer state.  Later.

 dtc-lexer.l   |   23 --
 dtc-parser.y  |   46 -
 tests/base01.dts  |   24 --
 tests/empty.dts   |2 +
 tests/escapes.dts |2 +
 tests/label01.dts |   38 +++-
 tests/references_dts0.dts |   12 ++
 tests/run_tests.sh|   27 +-
 tests/test01.dts  |   38 +++-
 tests/test_tree1_dts0.dts |   18 +---
 10 files changed, 75 insertions(+), 155 deletions(-)

diff --git a/dtc-lexer.l b/dtc-lexer.l
index 6f8b7dd..e12a4ef 100644
--- a/dtc-lexer.l
+++ b/dtc-lexer.l
@@ -110,29 +110,6 @@ static int pop_input_file(void);
return DT_LABEL;
}
 
-INITIAL[bodh]# {
-   yylloc.file = srcpos_file;
-   yylloc.first_line = yylineno;
-   if (*yytext == 'b')
-   yylval.cbase = 2;
-   else if (*yytext == 'o')
-   yylval.cbase = 8;
-   else if (*yytext == 'd')
-   yylval.cbase = 10;
-   else
-   yylval.cbase = 16;
-   DPRINT(Base: %d\n, yylval.cbase);
-   return DT_BASE;
-   }
-
-INITIAL[0-9a-fA-F]+  {
-   yylloc.file = srcpos_file;
-   yylloc.first_line = yylineno;
-   yylval.literal = strdup(yytext);
-   DPRINT(Literal: '%s'\n, yylval.literal);
-   return DT_LEGACYLITERAL;
-   }
-
 V1[0-9]+|0[xX][0-9a-fA-F]+  {
yylloc.file = srcpos_file;
yylloc.first_line = yylineno;
diff --git a/dtc-parser.y b/dtc-parser.y
index b2ab562..3762181 100644
--- a/dtc-parser.y
+++ b/dtc-parser.y
@@ -55,7 +55,6 @@ static unsigned long long eval_literal(const char *s, int 
base, int bits);
 %token DT_MEMRESERVE
 %token propnodename DT_PROPNODENAME
 %token literal DT_LITERAL
-%token literal DT_LEGACYLITERAL
 %token cbase DT_BASE
 %token byte DT_BYTE
 %token data DT_STRING
@@ -67,11 +66,8 @@ static unsigned long long eval_literal(const char *s, int 
base, int bits);
 %type data propdataprefix
 %type re memreserve
 %type re memreserves
-%type re v0_memreserve
-%type re v0_memreserves
 %type addr addr
 %type data celllist
-%type cbase cellbase
 %type cell cellval
 %type data bytestring
 %type prop propdef
@@ -90,10 +86,6 @@ sourcefile:
{
the_boot_info = build_boot_info($3, $4, 0);
}
-   | v0_memreserves devicetree
-   {
-   the_boot_info = build_boot_info($1, $2, 0);
-   }
;
 
 memreserves:
@@ -114,37 +106,11 @@ memreserve:
}
;
 
-v0_memreserves:
- /* empty */
-   {
-   $$ = NULL;
-   }
-   | v0_memreserve v0_memreserves
-   {
-   $$ = chain_reserve_entry($1, $2);
-   };
-   ;
-
-v0_memreserve:
- memreserve
-   {
-   $$ = $1;
-   }
-   | label DT_MEMRESERVE addr '-' addr ';'
-   {
-   $$ = build_reserve_entry($3, $5 - $3 + 1, $1);
-   }
-   ;
-
 addr:
  DT_LITERAL
{
$$ = eval_literal($1, 0, 64);
}
-   | DT_LEGACYLITERAL
-   {
-   $$ = eval_literal($1, 16, 64);
-   }
  ;
 
 devicetree:
@@ -269,23 +235,11 @@ celllist:
}
;
 
-cellbase:
- /* empty */
-   {
-   $$ = 16;
-   }
-   | DT_BASE
-   ;
-
 cellval:
  DT_LITERAL
{
$$ = eval_literal($1, 0, 32);
}
-   | cellbase DT_LEGACYLITERAL
-   {
-   $$ = eval_literal($2, $1, 32);
-   }
;
 
 bytestring:
diff --git a/tests/base01.dts b/tests/base01.dts
index f84bc49..97a5dd5 100644
--- a/tests/base01.dts
+++ b/tests/base01.dts
@@ -1,3 +1,5 @@
+/dts-v1/;
+
 / {
model = SomeModel;

Re: [PATCH 1/2] port ndfc driver to of platform

2008-08-14 Thread Sean MacLennan
Port the ndfc driver to an OF platform driver.

Signed-off-by: Sean MacLennan [EMAIL PROTECTED]
---
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 41f361c..ab0d77e 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -165,7 +165,7 @@ config MTD_NAND_S3C2410_HWECC
 
 config MTD_NAND_NDFC
tristate NDFC NanD Flash Controller
-   depends on 4xx  !PPC_MERGE
+   depends on 4xx
select MTD_NAND_ECC_SMC
help
 NDFC Nand Flash Controllers are integrated in IBM/AMCC's 4xx SoCs
diff --git a/drivers/mtd/nand/ndfc.c b/drivers/mtd/nand/ndfc.c
index 955959e..75a3bf0 100644
--- a/drivers/mtd/nand/ndfc.c
+++ b/drivers/mtd/nand/ndfc.c
@@ -5,9 +5,13 @@
  *   Platform independend driver for NDFC (NanD Flash Controller)
  *   integrated into EP440 cores
  *
+ *   Ported to an OF platform driver by Sean MacLennan
+ *
  *  Author: Thomas Gleixner
  *
  *  Copyright 2006 IBM
+ *  Copyright 2008 PIKA Technologies
+ *Sean MacLennan [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
@@ -21,27 +25,17 @@
 #include linux/mtd/partitions.h
 #include linux/mtd/ndfc.h
 #include linux/mtd/mtd.h
-#include linux/platform_device.h
-
+#include linux/of_platform.h
 #include asm/io.h
-#ifdef CONFIG_40x
-#include asm/ibm405.h
-#else
-#include asm/ibm44x.h
-#endif
-
-struct ndfc_nand_mtd {
-   struct mtd_info mtd;
-   struct nand_chipchip;
-   struct platform_nand_chip   *pl_chip;
-};
 
-static struct ndfc_nand_mtd ndfc_mtd[NDFC_MAX_BANKS];
 
 struct ndfc_controller {
-   void __iomem*ndfcbase;
-   struct nand_hw_control  ndfc_control;
-   atomic_tchilds_active;
+   struct of_device *ofdev;
+   void __iomem *ndfcbase;
+   struct mtd_info mtd;
+   struct nand_chip chip;
+   int chip_select;
+   struct nand_hw_control ndfc_control;
 };
 
 static struct ndfc_controller ndfc_ctrl;
@@ -50,17 +44,14 @@ static void ndfc_select_chip(struct mtd_info *mtd, int chip)
 {
uint32_t ccr;
struct ndfc_controller *ndfc = ndfc_ctrl;
-   struct nand_chip *nandchip = mtd-priv;
-   struct ndfc_nand_mtd *nandmtd = nandchip-priv;
-   struct platform_nand_chip *pchip = nandmtd-pl_chip;
 
-   ccr = __raw_readl(ndfc-ndfcbase + NDFC_CCR);
+   ccr = in_be32(ndfc-ndfcbase + NDFC_CCR);
if (chip = 0) {
ccr = ~NDFC_CCR_BS_MASK;
-   ccr |= NDFC_CCR_BS(chip + pchip-chip_offset);
+   ccr |= NDFC_CCR_BS(chip + ndfc-chip_select);
} else
ccr |= NDFC_CCR_RESET_CE;
-   __raw_writel(ccr, ndfc-ndfcbase + NDFC_CCR);
+   out_be32(ndfc-ndfcbase + NDFC_CCR, ccr);
 }
 
 static void ndfc_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
@@ -80,7 +71,7 @@ static int ndfc_ready(struct mtd_info *mtd)
 {
struct ndfc_controller *ndfc = ndfc_ctrl;
 
-   return __raw_readl(ndfc-ndfcbase + NDFC_STAT)  NDFC_STAT_IS_READY;
+   return in_be32(ndfc-ndfcbase + NDFC_STAT)  NDFC_STAT_IS_READY;
 }
 
 static void ndfc_enable_hwecc(struct mtd_info *mtd, int mode)
@@ -88,9 +79,9 @@ static void ndfc_enable_hwecc(struct mtd_info *mtd, int mode)
uint32_t ccr;
struct ndfc_controller *ndfc = ndfc_ctrl;
 
-   ccr = __raw_readl(ndfc-ndfcbase + NDFC_CCR);
+   ccr = in_be32(ndfc-ndfcbase + NDFC_CCR);
ccr |= NDFC_CCR_RESET_ECC;
-   __raw_writel(ccr, ndfc-ndfcbase + NDFC_CCR);
+   out_be32(ndfc-ndfcbase + NDFC_CCR, ccr);
wmb();
 }
 
@@ -102,9 +93,10 @@ static int ndfc_calculate_ecc(struct mtd_info *mtd,
uint8_t *p = (uint8_t *)ecc;
 
wmb();
-   ecc = __raw_readl(ndfc-ndfcbase + NDFC_ECC);
-   ecc_code[0] = p[1];
-   ecc_code[1] = p[2];
+   ecc = in_be32(ndfc-ndfcbase + NDFC_ECC);
+   /* The NDFC uses Smart Media (SMC) bytes order */
+   ecc_code[0] = p[2];
+   ecc_code[1] = p[1];
ecc_code[2] = p[3];
 
return 0;
@@ -123,7 +115,7 @@ static void ndfc_read_buf(struct mtd_info *mtd, uint8_t 
*buf, int len)
uint32_t *p = (uint32_t *) buf;
 
for(;len  0; len -= 4)
-   *p++ = __raw_readl(ndfc-ndfcbase + NDFC_DATA);
+   *p++ = in_be32(ndfc-ndfcbase + NDFC_DATA);
 }
 
 static void ndfc_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
@@ -132,7 +124,7 @@ static void ndfc_write_buf(struct mtd_info *mtd, const 
uint8_t *buf, int len)
uint32_t *p = (uint32_t *) buf;
 
for(;len  0; len -= 4)
-   __raw_writel(*p++, ndfc-ndfcbase + NDFC_DATA);
+   out_be32(ndfc-ndfcbase + NDFC_DATA, *p++);
 }
 
 static int ndfc_verify_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
@@ -141,7 +133,7 @@ static int ndfc_verify_buf(struct mtd_info *mtd, const 
uint8_t *buf, int len)

Re: [PATCH 2/2] port ndfc driver to of platform

2008-08-14 Thread Sean MacLennan
The only real change from the last version was the updating of the dts
to use the chip select and offset for the NAND address rather than the
chip select and address.

Cheers,
   Sean


Changes to the warp platform with the ndfc as an of platform device.
The main changes are:

* moving the NAND information to the DTS
* removing warp-nand.c
* moving the NAND fixups to cuboot-warp.c

Signed-off-by: Sean MacLennan [EMAIL PROTECTED]
---
diff --git a/arch/powerpc/boot/cuboot-warp.c b/arch/powerpc/boot/cuboot-warp.c
index 2178021..6d20a46 100644
--- a/arch/powerpc/boot/cuboot-warp.c
+++ b/arch/powerpc/boot/cuboot-warp.c
@@ -34,10 +34,30 @@ static void warp_fixup_one_nor(u32 from, u32 to)
v[0] = to;
setprop(devp, reg, v, sizeof(v));
 
-   printf(NOR 64M fixup %x - %x\r\n, from, to);
+   printf(NOR  64M fixup %x - %x\r\n, from, to);
}
 }
 
+static void warp_fixup_one_nand(u32 from, u32 to, u32 size)
+{
+   void *devp;
+   char name[50];
+   u32 v[2];
+
+   sprintf(name, /plb/opb/ebc/[EMAIL PROTECTED],d000/[EMAIL 
PROTECTED], from);
+
+   devp = finddevice(name);
+   if (!devp)
+   return;
+
+   if (getprop(devp, reg, v, sizeof(v)) == sizeof(v)) {
+   v[0] = to;
+   v[1] = size;
+   setprop(devp, reg, v, sizeof(v));
+
+   printf(NAND 64M fixup %x - %x\r\n, from, to);
+   }
+}
 
 static void warp_fixups(void)
 {
@@ -46,25 +66,39 @@ static void warp_fixups(void)
ibm4xx_fixup_ebc_ranges(/plb/opb/ebc);
dt_fixup_mac_address_by_alias(ethernet0, bd.bi_enetaddr);
 
-   /* Fixup for 64M flash on Rev A boards. */
+   /* Fixup flash on Rev A boards. */
if (bd.bi_flashsize == 0x400) {
void *devp;
u32 v[3];
 
+   /* NOR */
devp = finddevice(/plb/opb/ebc/[EMAIL PROTECTED],0);
-   if (!devp)
-   return;
-
-   /* Fixup the size */
-   if (getprop(devp, reg, v, sizeof(v)) == sizeof(v)) {
-   v[2] = bd.bi_flashsize;
-   setprop(devp, reg, v, sizeof(v));
+   if (devp) {
+   /* Fixup the size */
+   if (getprop(devp, reg, v, sizeof(v)) == sizeof(v)) {
+   v[2] = bd.bi_flashsize;
+   setprop(devp, reg, v, sizeof(v));
+   }
+
+   /* Fixup parition offsets */
+   warp_fixup_one_nor(0x30, 0x3f0);
+   warp_fixup_one_nor(0x34, 0x3f4);
+   warp_fixup_one_nor(0x38, 0x3f8);
}
 
-   /* Fixup parition offsets */
-   warp_fixup_one_nor(0x30, 0x3f0);
-   warp_fixup_one_nor(0x34, 0x3f4);
-   warp_fixup_one_nor(0x38, 0x3f8);
+   /* NAND */
+   devp = finddevice(/plb/opb/ebc/[EMAIL PROTECTED],d000);
+   if (devp) {
+   /* Fixup the size */
+   if (getprop(devp, reg, v, sizeof(v)) == sizeof(v)) {
+   v[2] = bd.bi_flashsize;
+   setprop(devp, reg, v, sizeof(v));
+   }
+
+   /* Fixup parition offsets */
+   warp_fixup_one_nand(0x0020, 0x020, 0x300);
+   warp_fixup_one_nand(0x4000, 0x320, 0x0e0);
+   }
}
 }
 
diff --git a/arch/powerpc/boot/dts/warp.dts b/arch/powerpc/boot/dts/warp.dts
index f4e4ba6..81a 100644
--- a/arch/powerpc/boot/dts/warp.dts
+++ b/arch/powerpc/boot/dts/warp.dts
@@ -155,6 +155,11 @@
reg = 0x 0x 
0x0040;
#address-cells = 1;
#size-cells = 1;
+
+   [EMAIL PROTECTED] {
+   label = splash;
+   reg = 0x 0x0002;
+   };
[EMAIL PROTECTED] {
label = fpga;
reg = 0x030 0x0004;
@@ -168,6 +173,36 @@
reg = 0x038 0x0008;
};
};
+
+   [EMAIL PROTECTED],0 {
+   compatible = amcc,ndfc;
+   reg = 0x0001 0x 
0x2000;
+   ccr = 0x1000;
+   bank-settings = 0x8000;
+  

mpc52xx_uart and rs485

2008-08-14 Thread Sinisa Denic
From bf050adbc092043c1ba6e43373563bb761bb2e40 Mon Sep 17 00:00:00 2001
From: Sinisa Denic [EMAIL PROTECTED]
Date: Wed, 13 Aug 2008 15:57:52 +0200
Subject: [PATCH] mpc52xx_uart RS485 support added

Hi Wolfgang and others, 
below is patch for mpc52xx_usrt.c which add software rs485 support to 
this driver.
It has worked for me and if you think it is good enough it might be 
useful for someone else.
Regards, 
Sinisa Denic
System and software  engineer
tel: +381(0)112016142
ABS Control Systems
bul.Zorana Djindjica 8a
Belgrade,Serbia
---
 drivers/serial/mpc52xx_uart.c |   47 +
+---
 1 files changed, 39 insertions(+), 8 deletions(-)

diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c
index 7a3625f..38b2751 100644
--- a/drivers/serial/mpc52xx_uart.c
+++ b/drivers/serial/mpc52xx_uart.c
@@ -62,7 +62,7 @@
  * by the bootloader or in the platform init code.
  */
 
-#undef DEBUG
+//#undef DEBUG
 
 #include linux/device.h
 #include linux/module.h
@@ -142,11 +142,13 @@ struct psc_ops {
int (*rx_rdy)(struct uart_port *port);
int (*tx_rdy)(struct uart_port *port);
int (*tx_empty)(struct uart_port *port);
+   int (*tx_empty_enabled)(struct uart_port *port);
void(*stop_rx)(struct uart_port *port);
void(*start_tx)(struct uart_port *port);
void(*stop_tx)(struct uart_port *port);
void(*rx_clr_irq)(struct uart_port *port);
void(*tx_clr_irq)(struct uart_port *port);
+   void(*tx_empty_clr_irq)(struct uart_port *port);
void(*write_char)(struct uart_port *port, unsigned 
char c);
unsigned char   (*read_char)(struct uart_port *port);
void(*cw_disable_ints)(struct uart_port *port);
@@ -169,7 +171,7 @@ static void mpc52xx_psc_fifo_init(struct uart_port 
*port)
out_8(fifo-tfcntl, 0x07);
out_be16(fifo-tfalarm, 0x80);
 
-   port-read_status_mask |= MPC52xx_PSC_IMR_RXRDY | 
MPC52xx_PSC_IMR_TXRDY;
+   port-read_status_mask |= MPC52xx_PSC_IMR_RXRDY | 
MPC52xx_PSC_IMR_TXRDY | MPC52xx_PSC_IMR_TXEMP; 
out_be16(psc-mpc52xx_psc_imr, port-read_status_mask);
 }
 
@@ -200,6 +202,13 @@ static int mpc52xx_psc_tx_rdy(struct uart_port *port)
 MPC52xx_PSC_IMR_TXRDY;
 }
 
+static int mpc52xx_psc_tx_empty_enabled(struct uart_port *port)
+{
+   return in_be16(PSC(port)-mpc52xx_psc_isr)
+port-read_status_mask
+MPC52xx_PSC_IMR_TXEMP;
+}
+
 static int mpc52xx_psc_tx_empty(struct uart_port *port)
 {
return in_be16(PSC(port)-mpc52xx_psc_status)
@@ -209,6 +218,7 @@ static int mpc52xx_psc_tx_empty(struct uart_port 
*port)
 static void mpc52xx_psc_start_tx(struct uart_port *port)
 {
port-read_status_mask |= MPC52xx_PSC_IMR_TXRDY;
+   port-read_status_mask |= MPC52xx_PSC_IMR_TXEMP;
out_be16(PSC(port)-mpc52xx_psc_imr, port-read_status_mask);
 }
 
@@ -232,6 +242,11 @@ static void mpc52xx_psc_tx_clr_irq(struct uart_port 
*port)
 {
 }
 
+static void mpc52xx_psc_tx_empty_clr_irq(struct uart_port *port)
+{
+   port-read_status_mask = ~MPC52xx_PSC_IMR_TXEMP;
+   out_be16(PSC(port)-mpc52xx_psc_imr, port-read_status_mask);
+}
 static void mpc52xx_psc_write_char(struct uart_port *port, unsigned char 
c)
 {
out_8(PSC(port)-mpc52xx_psc_buffer_8, c);
@@ -275,11 +290,13 @@ static struct psc_ops mpc52xx_psc_ops = {
.rx_rdy = mpc52xx_psc_rx_rdy,
.tx_rdy = mpc52xx_psc_tx_rdy,
.tx_empty = mpc52xx_psc_tx_empty,
+   .tx_empty_enabled = mpc52xx_psc_tx_empty_enabled,
.stop_rx = mpc52xx_psc_stop_rx,
.start_tx = mpc52xx_psc_start_tx,
.stop_tx = mpc52xx_psc_stop_tx,
.rx_clr_irq = mpc52xx_psc_rx_clr_irq,
.tx_clr_irq = mpc52xx_psc_tx_clr_irq,
+   .tx_empty_clr_irq = mpc52xx_psc_tx_empty_clr_irq,
.write_char = mpc52xx_psc_write_char,
.read_char = mpc52xx_psc_read_char,
.cw_disable_ints = mpc52xx_psc_cw_disable_ints,
@@ -583,7 +600,7 @@ mpc52xx_uart_set_termios(struct uart_port *port, 
struct ktermios *new,
 
 
mr2 = 0;
-
+   
if (new-c_cflag  CSTOPB)
mr2 |= MPC52xx_PSC_MODE_TWO_STOP;
else
@@ -591,7 +608,6 @@ mpc52xx_uart_set_termios(struct uart_port *port, 
struct ktermios *new,
MPC52xx_PSC_MODE_ONE_STOP_5_BITS :
MPC52xx_PSC_MODE_ONE_STOP;
 
-
baud = uart_get_baud_rate(port, new, old, 0, port-uartclk/16);
quot = uart_get_divisor(port, baud);
ctr = quot  0x;
@@ -735,7 +751,7 @@ mpc52xx_uart_int_rx_chars(struct uart_port *port)
struct tty_struct *tty = port-info-tty;
unsigned char ch, flag;
unsigned short status;
-
+   //printk(Int. citanje...\n);
/* While we can read, do so ! */
while (psc_ops-raw_rx_rdy(port)) {

mpc52xx localplus bus and dm9000

2008-08-14 Thread Sinisa Denic
Hi,I have mpc52xx based board very similar to lite5200b.
There is Davicom DM9000 connected to Local Plus Bus CS0.
Does anybody have idea how should DTS part look like in order to add this 
resource in system.
I've written something like this:

lpb {
device_type = network;
compatible = fsl,lpb;
ranges = 0 0 ff00 100;

[EMAIL PROTECTED],0 {
compatible = dm9000;
reg = 0 0 10;
#size-cells = 1;
#address-cells = 1;
};
};

but it's not working.
Is it enough to have right dts record for default dm9000 driver working
or I have to change something more?
Thank you in andvance.

Sinisa Denic
System and software  engineer
tel: +381(0)112016142
ABS Control Systems
bul.Zorana Djindjica 8a
Belgrade,Serbia


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


[PATCH 2.6.27] [POWERPC] Invalidate all TLB entries in a specified range

2008-08-14 Thread Rocky Craig
From: Rocky Craig [EMAIL PROTECTED]

The apparent intent of flush_tlbs is to invalidate TLB entries that
might match in the address range 0 to 0x0040.  A loop counter is 
set up at the high value and decremented by page size.  However, the 
loop is only done once as the sense of the conditional branch at the
loop end does not match the setup/decrement.

Signed-off-by: Rocky Craig [EMAIL PROTECTED]
---

Source is from 2.6.27 development, but the bug appears as far back as 2.4.0.
The small user-space program below demonstrates the loop behavior.  It was
compiled via crosstool gcc 3.4.5 / glibc 2.3.6 for an MPC8347 target.

int main()
{
long endval;// 16(r31)

__asm__ __volatile__(
   lis 10,0x40\n
1: addic. 10,10,-0x1000\n
   bgt 1b\n
   stw 10,16(31)\n);  // endval

printf(end value = 0x%08lx\n, endval);
}

This might win the prize for Smallest actual code patch ever.

--- a/arch/powerpc/kernel/head_32.S.orig2008-07-24 19:25:09.0 
-0600
+++ a/arch/powerpc/kernel/head_32.S 2008-07-24 19:25:22.0 -0600
@@ -1155,7 +1155,7 @@ flush_tlbs:
lis r10, 0x40
 1: addic.  r10, r10, -0x1000
tlbie   r10
-   blt 1b
+   bgt 1b
sync
blr
 



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


Re: [PATCH V2] DTC: Remove support for the legacy DTS source file format.

2008-08-14 Thread David Gibson
On Thu, Aug 14, 2008 at 06:02:43PM -0500, Jon Loeliger wrote:
 Now that all in-kernel-tree DTS files are properly /dts-v1/,
 remove direct support for the older, un-numbered DTS
 source file format.

Um.. why?  I just don't see a compelling reason to remove this
backwards compatibility.  It costs us very little to keep it around
indefinitely.

 Convert existing tests to /dts-v1/ and remove support
 for the conversion tests themselves.
 
 For now, though, the conversion tool still exists.

-- 
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@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH v3] libfdt: Add support for using aliases in fdt_path_offset()

2008-08-14 Thread David Gibson
On Thu, Aug 14, 2008 at 12:43:48PM -0500, Scott Wood wrote:
 On Thu, Aug 14, 2008 at 08:28:19AM -0500, Kumar Gala wrote:
  -   if (*path != '/')
  -   return -FDT_ERR_BADPATH;
  +   /* see if we have an alias */
  +   if (*path != '/') {
  +   const char *q;
  +   int aliasoffset = fdt_path_offset(fdt, /aliases);
  +
  +   if (aliasoffset  0)
  +   return -FDT_ERR_BADPATH;
  +
  +   q = strchr(path, '/');
  +   if (!q)
  +   q = end;
  +
  +   p = fdt_getprop_namelen(fdt, aliasoffset, path, q - p, NULL);
  +   if (!p)
  +   return -FDT_ERR_BADPATH;
  +   offset = fdt_path_offset(fdt, p);
  +
  +   p = q;
  +   }
 
 Can we limit the recursion depth to avoid falling off the stack if an
 alias points to itself?  Or if aliases pointing to aliases are
 disallowed, check for a leading '/' before recursively calling
 fdt_path_offset.

Hmm.. my reading of 1275 says that an alias pointing to another alias
is not permitted, but I'm not terribly confident I'm not misreading
it.  Segher, do you know whether this is allowed?

If that's the case then, yes, we should not recurse if the alias value
doesn't start with a /.  In fact, if I factor out a fdt_get_alias()
function, it should probably check the alias and return an error if
it's not an absolute path.

-- 
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@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH v3] libfdt: Add support for using aliases in fdt_path_offset()

2008-08-14 Thread Mitch Bradley



David Gibson wrote:

On Thu, Aug 14, 2008 at 12:43:48PM -0500, Scott Wood wrote:
  

On Thu, Aug 14, 2008 at 08:28:19AM -0500, Kumar Gala wrote:


-   if (*path != '/')
-   return -FDT_ERR_BADPATH;
+   /* see if we have an alias */
+   if (*path != '/') {
+   const char *q;
+   int aliasoffset = fdt_path_offset(fdt, /aliases);
+
+   if (aliasoffset  0)
+   return -FDT_ERR_BADPATH;
+
+   q = strchr(path, '/');
+   if (!q)
+   q = end;
+
+   p = fdt_getprop_namelen(fdt, aliasoffset, path, q - p, NULL);
+   if (!p)
+   return -FDT_ERR_BADPATH;
+   offset = fdt_path_offset(fdt, p);
+
+   p = q;
+   }
  

Can we limit the recursion depth to avoid falling off the stack if an
alias points to itself?  Or if aliases pointing to aliases are
disallowed, check for a leading '/' before recursively calling
fdt_path_offset.



Hmm.. my reading of 1275 says that an alias pointing to another alias
is not permitted, but I'm not terribly confident I'm not misreading
it.  Segher, do you know whether this is allowed?
  


The 1275 spec doesn't require multiple levels of aliasing, but my 
current implementation allows it and uses it for things like components 
of the network stack.




If that's the case then, yes, we should not recurse if the alias value
doesn't start with a /.  In fact, if I factor out a fdt_get_alias()
function, it should probably check the alias and return an error if
it's not an absolute path.

  

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


Re: oops in proc_sys_compare

2008-08-14 Thread Al Viro
On Thu, Aug 14, 2008 at 07:31:06PM +0100, Hugh Dickins wrote:
 I got this oops below, after several hours of swap-heavy kernel builds
 in tmpfs, on 2.6.27-rc1-mm1 a couple of weeks ago.  Tried to reproduce
 it without success, then got a very similar trace (not saved) from
 2.6.27-rc3 itself doing the same test yesterday: again oopsing in
 proc_sys_compare on address -16, looks like it's trying for
 PROC_I(dentry-d_inode)-sysctl but d_inode is NULL.
 
 I looked to see what's been going on in fs/proc recently, and your
 [PATCH] sanitize proc_sysctl 9043476f726802f4b00c96d0c4f418dde48d1304
 does sound like it might be implicated.  I've only seen this on
 PowerPC G5, similar tests on x86_32 and _64 haven't shown it:
 maybe a memory barrier needed somewhere?
 
Bloody interesting.  We never create negative hashed dentries in there and
AFAICS we should never get d_delete() called on those...  Missing barrier
would mean serious trouble in dcache.c and not just for /proc/sys...

Are you sure about oops decoding?  At least disassembly of proc_sys_compare()
in the kernel image in question would be nice to see...
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 2/2] port ndfc driver to of platform

2008-08-14 Thread Sean MacLennan
Hopefully the last change. I decided to remove all the rev A fixups
from the cuboot-warp file. I am the only person using a rev A, and I
can use the command line to specify any needed partitions. There is
really only one partition needed to boot from nand since u-boot can be
used to flash the images.

Note the patch is now smaller since we don't need the NAND fixups!

Cheers,
   Sean


Changes to the warp platform with the ndfc as an of platform device.
The main changes are:

* move the NAND information to the DTS
* remove warp-nand.c
* remove rev A fixups from cuboot-warp.c

Signed-off-by: Sean MacLennan [EMAIL PROTECTED]
---
diff --git a/arch/powerpc/boot/cuboot-warp.c b/arch/powerpc/boot/cuboot-warp.c
index 2178021..806df69 100644
--- a/arch/powerpc/boot/cuboot-warp.c
+++ b/arch/powerpc/boot/cuboot-warp.c
@@ -18,57 +18,14 @@
 
 static bd_t bd;
 
-static void warp_fixup_one_nor(u32 from, u32 to)
-{
-   void *devp;
-   char name[50];
-   u32 v[2];
-
-   sprintf(name, /plb/opb/ebc/[EMAIL PROTECTED],0/[EMAIL PROTECTED], 
from);
-
-   devp = finddevice(name);
-   if (!devp)
-   return;
-
-   if (getprop(devp, reg, v, sizeof(v)) == sizeof(v)) {
-   v[0] = to;
-   setprop(devp, reg, v, sizeof(v));
-
-   printf(NOR 64M fixup %x - %x\r\n, from, to);
-   }
-}
-
-
 static void warp_fixups(void)
 {
ibm440ep_fixup_clocks(6600, 11059200, 5000);
ibm4xx_sdram_fixup_memsize();
ibm4xx_fixup_ebc_ranges(/plb/opb/ebc);
dt_fixup_mac_address_by_alias(ethernet0, bd.bi_enetaddr);
-
-   /* Fixup for 64M flash on Rev A boards. */
-   if (bd.bi_flashsize == 0x400) {
-   void *devp;
-   u32 v[3];
-
-   devp = finddevice(/plb/opb/ebc/[EMAIL PROTECTED],0);
-   if (!devp)
-   return;
-
-   /* Fixup the size */
-   if (getprop(devp, reg, v, sizeof(v)) == sizeof(v)) {
-   v[2] = bd.bi_flashsize;
-   setprop(devp, reg, v, sizeof(v));
-   }
-
-   /* Fixup parition offsets */
-   warp_fixup_one_nor(0x30, 0x3f0);
-   warp_fixup_one_nor(0x34, 0x3f4);
-   warp_fixup_one_nor(0x38, 0x3f8);
-   }
 }
 
-
 void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
   unsigned long r6, unsigned long r7)
 {
diff --git a/arch/powerpc/boot/dts/warp.dts b/arch/powerpc/boot/dts/warp.dts
index f4e4ba6..b92089c 100644
--- a/arch/powerpc/boot/dts/warp.dts
+++ b/arch/powerpc/boot/dts/warp.dts
@@ -149,12 +149,17 @@
reg = 0x0002 0x4000 
0x0A00;
};
 
-   [EMAIL PROTECTED],0 {
+   [EMAIL PROTECTED],0 {
compatible = amd,s29gl032a, 
cfi-flash;
bank-width = 2;
reg = 0x 0x 
0x0040;
#address-cells = 1;
#size-cells = 1;
+
+   [EMAIL PROTECTED] {
+   label = splash;
+   reg = 0x 0x0002;
+   };
[EMAIL PROTECTED] {
label = fpga;
reg = 0x030 0x0004;
@@ -168,6 +173,36 @@
reg = 0x038 0x0008;
};
};
+
+   [EMAIL PROTECTED],0 {
+   compatible = amcc,ndfc;
+   reg = 0x0001 0x 
0x2000;
+   ccr = 0x1000;
+   bank-settings = 0x8000;
+   #address-cells = 1;
+   #size-cells = 1;
+
+   [EMAIL PROTECTED] {
+   label = kernel;
+   reg = 0x 0x0020;
+   };
+   [EMAIL PROTECTED] {
+   label = root;
+   reg = 0x0020 0x03E0;
+   };
+   [EMAIL PROTECTED] {
+   label = persistent;
+   reg = 0x0400