Re: [PATCH 09/10] ppc64: Convert cpu_sibling_map to a per_cpu data array (v3)

2007-09-16 Thread Stephen Rothwell
On Mon, 17 Sep 2007 16:28:31 +1000 Stephen Rothwell <[EMAIL PROTECTED]> wrote:
>
>   the topology (on my POWERPC5+ box) is not correct:
> 
> cpu0/topology/thread_siblings:000f
> cpu1/topology/thread_siblings:000f
> cpu2/topology/thread_siblings:000f
> cpu3/topology/thread_siblings:000f
> 
> it used to be:
> 
> cpu0/topology/thread_siblings:0003
> cpu1/topology/thread_siblings:0003
> cpu2/topology/thread_siblings:000c
> cpu3/topology/thread_siblings:000c

This would be because we are setting up the cpu_sibling map before we
call setup_per_cpu_areas().

-- 
Cheers,
Stephen Rothwell[EMAIL PROTECTED]
http://www.canb.auug.org.au/~sfr/


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

Re: [PATCH 09/10] ppc64: Convert cpu_sibling_map to a per_cpu data array (v3)

2007-09-16 Thread Stephen Rothwell
On Tue, 11 Sep 2007 18:56:53 -0700 [EMAIL PROTECTED] wrote:
>
> Convert cpu_sibling_map to a per_cpu cpumask_t array for the ppc64
> architecture.  This fixes build errors in block/blktrace.c and
> kernel/sched.c when CONFIG_SCHED_SMT is defined.
> 
> Note: these changes have not been built nor tested.

After applying all 10 patches, the ppc64_defconfig builds but:

vmlinux is larger:

   textdata bss dec hex filename
7705776 1756984  504624 9967384  981718 ppc64/vmlinux
7706228 1757120  504624 9967972  981964 trav.bld/vmlinux

the topology (on my POWERPC5+ box) is not correct:

cpu0/topology/thread_siblings:000f
cpu1/topology/thread_siblings:000f
cpu2/topology/thread_siblings:000f
cpu3/topology/thread_siblings:000f

it used to be:

cpu0/topology/thread_siblings:0003
cpu1/topology/thread_siblings:0003
cpu2/topology/thread_siblings:000c
cpu3/topology/thread_siblings:000c

Similarly on my iSeries box, the topology is displayed as above
while it used to be:

cpu0/topology/thread_siblings:0001
cpu1/topology/thread_siblings:0002
cpu2/topology/thread_siblings:0004
cpu3/topology/thread_siblings:0008

-- 
Cheers,
Stephen Rothwell[EMAIL PROTECTED]
http://www.canb.auug.org.au/~sfr/


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

Re: [PATCH] i2c: devtree-aware iic support for PPC4xx

2007-09-16 Thread Eugene Surovegin
On Mon, Sep 17, 2007 at 07:34:08AM +0200, Stefan Roese wrote:
> 
> My understanding was, that adding many #ifdef's into the code was not the 
> preferred way. 

But just making a copy seems to be a proffered one? Wow.

OCP and/or OF part is quite small part of the driver; another approach 
would been completely splitting OCP and OF specific part out 
(e.g. i2c-ibm_iic.c + i2c-ibm_iic_ocp.c / i2c_ibm_iic_of.c). I 
personally thing it's not worth the effort and just adding couple of 
ifdef'ed code is good enough, especially as a transitional thing.

> I could of course change this patch to not add an additional 
> driver but extend the existing driver with a bunch of #ifdef's to support 
> both versions.
> 
> This approach of multiple drivers seems to be common in the kernel right now:
> 
> drivers/mtd/maps/physmap.c
> drivers/mtd/maps/physmap_of.c
> 
> or
> 
> drivers/usb/host/ohci-ppc-soc.c
> drivers/usb/host/ohci-ppc-of.c

I don't think these are good examples, physmap.c seems to differ from 
physmap_of.c significantly. These drivers are mostly a glue, and it 
makes sense to have different versions, because there isn't much there 
except for platform/bus/glue specific code.

> Any other opinions on this? How should this be handled to get accepted 
> upstream? Two different drivers with removing the "old" one later when 
> arch/ppc is gone,

ppc has been going away for the last two years at least and still 
isn't gone. What makes you think this isn't gonna take another year or 
two :) ?

> 
> The "old" name "i2c-ibm_iic" is kind of redundant. Nearly all bus drivers are 
> named "i2c-platform". Perhaps a better name would be "i2c-ppc4xx" then. 

Sure, that'd be a much better choice.

-- 
Eugene

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


[PATCH 7/7] Remove msic_dcr_read() and use dcr_map_reg() in axon_msi.c

2007-09-16 Thread Michael Ellerman
msic_dcr_read() doesn't really do anything useful, just replace it with
direct calls to dcr_read().

Use dcr_map_reg() in the axon_msi setup code, rather than essentially doing
it by hand.

Signed-off-by: Michael Ellerman <[EMAIL PROTECTED]>
---
 arch/powerpc/platforms/cell/axon_msi.c |   22 +++---
 1 files changed, 3 insertions(+), 19 deletions(-)

diff --git a/arch/powerpc/platforms/cell/axon_msi.c 
b/arch/powerpc/platforms/cell/axon_msi.c
index 26a5e88..57a6149 100644
--- a/arch/powerpc/platforms/cell/axon_msi.c
+++ b/arch/powerpc/platforms/cell/axon_msi.c
@@ -80,18 +80,13 @@ static void msic_dcr_write(struct axon_msic *msic, unsigned 
int dcr_n, u32 val)
dcr_write(msic->dcr_host, dcr_n, val);
 }
 
-static u32 msic_dcr_read(struct axon_msic *msic, unsigned int dcr_n)
-{
-   return dcr_read(msic->dcr_host, dcr_n);
-}
-
 static void axon_msi_cascade(unsigned int irq, struct irq_desc *desc)
 {
struct axon_msic *msic = get_irq_data(irq);
u32 write_offset, msi;
int idx;
 
-   write_offset = msic_dcr_read(msic, MSIC_WRITE_OFFSET_REG);
+   write_offset = dcr_read(msic->dcr_host, MSIC_WRITE_OFFSET_REG);
pr_debug("axon_msi: original write_offset 0x%x\n", write_offset);
 
/* write_offset doesn't wrap properly, so we have to mask it */
@@ -306,7 +301,7 @@ static int axon_msi_notify_reboot(struct notifier_block *nb,
list_for_each_entry(msic, &axon_msic_list, list) {
pr_debug("axon_msi: disabling %s\n",
  msic->irq_host->of_node->full_name);
-   tmp  = msic_dcr_read(msic, MSIC_CTRL_REG);
+   tmp  = dcr_read(msic->dcr_host, MSIC_CTRL_REG);
tmp &= ~MSIC_CTRL_ENABLE & ~MSIC_CTRL_IRQ_ENABLE;
msic_dcr_write(msic, MSIC_CTRL_REG, tmp);
}
@@ -323,7 +318,6 @@ static int axon_msi_setup_one(struct device_node *dn)
struct page *page;
struct axon_msic *msic;
unsigned int virq;
-   int dcr_base, dcr_len;
 
pr_debug("axon_msi: setting up dn %s\n", dn->full_name);
 
@@ -334,17 +328,7 @@ static int axon_msi_setup_one(struct device_node *dn)
goto out;
}
 
-   dcr_base = dcr_resource_start(dn, 0);
-   dcr_len = dcr_resource_len(dn, 0);
-
-   if (dcr_base == 0 || dcr_len == 0) {
-   printk(KERN_ERR
-  "axon_msi: couldn't parse dcr properties on %s\n",
-   dn->full_name);
-   goto out;
-   }
-
-   msic->dcr_host = dcr_map(dn, dcr_base, dcr_len);
+   msic->dcr_host = dcr_map_reg(dn, 0);
if (!DCR_MAP_OK(msic->dcr_host)) {
printk(KERN_ERR "axon_msi: dcr_map failed for %s\n",
   dn->full_name);
-- 
1.5.1.3.g7a33b

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


[PATCH 6/7] Add dcr_map_reg() helper

2007-09-16 Thread Michael Ellerman
Add a helper routine to map dcr's based on the "dcr-reg" property of
a device node.

Signed-off-by: Michael Ellerman <[EMAIL PROTECTED]>
---
 arch/powerpc/sysdev/dcr.c |   17 +
 include/asm-powerpc/dcr.h |1 +
 2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/sysdev/dcr.c b/arch/powerpc/sysdev/dcr.c
index ab11c0b..da4f9c6 100644
--- a/arch/powerpc/sysdev/dcr.c
+++ b/arch/powerpc/sysdev/dcr.c
@@ -126,6 +126,23 @@ dcr_host_t dcr_map(struct device_node *dev, unsigned int 
dcr_n,
 }
 EXPORT_SYMBOL_GPL(dcr_map);
 
+dcr_host_t dcr_map_reg(struct device_node *dev, unsigned int index)
+{
+   dcr_host_t ret = { .token = NULL };
+
+   unsigned int dcr_n, dcr_c;
+
+   dcr_n = dcr_resource_start(dev, index);
+   if (!dcr_n)
+   return ret;
+
+   dcr_c = dcr_resource_len(dev, index);
+   if (!dcr_c)
+   return ret;
+
+   return dcr_map(dev, dcr_n, dcr_c);
+}
+
 void dcr_unmap(dcr_host_t host, unsigned int dcr_n, unsigned int dcr_c)
 {
dcr_host_t h = host;
diff --git a/include/asm-powerpc/dcr.h b/include/asm-powerpc/dcr.h
index 9338d50..4d42f01 100644
--- a/include/asm-powerpc/dcr.h
+++ b/include/asm-powerpc/dcr.h
@@ -38,6 +38,7 @@ extern unsigned int dcr_resource_start(struct device_node *np,
   unsigned int index);
 extern unsigned int dcr_resource_len(struct device_node *np,
 unsigned int index);
+extern dcr_host_t dcr_map_reg(struct device_node *np, unsigned int index);
 #endif /* CONFIG_PPC_MERGE */
 
 #endif /* CONFIG_PPC_DCR */
-- 
1.5.1.3.g7a33b

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


[PATCH 5/7] Add dcr_host_t.base in dcr_read()/dcr_write()

2007-09-16 Thread Michael Ellerman
Now that all users of dcr_read()/dcr_write() add the dcr_host_t.base, we can
save them the trouble and do it in dcr_read()/dcr_write().

Signed-off-by: Michael Ellerman <[EMAIL PROTECTED]>
---
 arch/powerpc/platforms/cell/axon_msi.c |4 ++--
 arch/powerpc/sysdev/mpic.c |4 ++--
 drivers/net/ibm_emac/ibm_emac_mal.h|4 ++--
 include/asm-powerpc/dcr-mmio.h |4 ++--
 include/asm-powerpc/dcr-native.h   |4 ++--
 5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/platforms/cell/axon_msi.c 
b/arch/powerpc/platforms/cell/axon_msi.c
index 23e039a..26a5e88 100644
--- a/arch/powerpc/platforms/cell/axon_msi.c
+++ b/arch/powerpc/platforms/cell/axon_msi.c
@@ -77,12 +77,12 @@ static void msic_dcr_write(struct axon_msic *msic, unsigned 
int dcr_n, u32 val)
 {
pr_debug("axon_msi: dcr_write(0x%x, 0x%x)\n", val, dcr_n);
 
-   dcr_write(msic->dcr_host, msic->dcr_host.base + dcr_n, val);
+   dcr_write(msic->dcr_host, dcr_n, val);
 }
 
 static u32 msic_dcr_read(struct axon_msic *msic, unsigned int dcr_n)
 {
-   return dcr_read(msic->dcr_host, msic->dcr_host.base + dcr_n);
+   return dcr_read(msic->dcr_host, dcr_n);
 }
 
 static void axon_msi_cascade(unsigned int irq, struct irq_desc *desc)
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 16b1f4b..61f5730 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -156,7 +156,7 @@ static inline u32 _mpic_read(enum mpic_reg_type type,
switch(type) {
 #ifdef CONFIG_PPC_DCR
case mpic_access_dcr:
-   return dcr_read(rb->dhost, rb->dhost.base + reg);
+   return dcr_read(rb->dhost, reg);
 #endif
case mpic_access_mmio_be:
return in_be32(rb->base + (reg >> 2));
@@ -173,7 +173,7 @@ static inline void _mpic_write(enum mpic_reg_type type,
switch(type) {
 #ifdef CONFIG_PPC_DCR
case mpic_access_dcr:
-   return dcr_write(rb->dhost, rb->dhost.base + reg, value);
+   return dcr_write(rb->dhost, reg, value);
 #endif
case mpic_access_mmio_be:
return out_be32(rb->base + (reg >> 2), value);
diff --git a/drivers/net/ibm_emac/ibm_emac_mal.h 
b/drivers/net/ibm_emac/ibm_emac_mal.h
index 6b1fbeb..10dc978 100644
--- a/drivers/net/ibm_emac/ibm_emac_mal.h
+++ b/drivers/net/ibm_emac/ibm_emac_mal.h
@@ -208,12 +208,12 @@ struct ibm_ocp_mal {
 
 static inline u32 get_mal_dcrn(struct ibm_ocp_mal *mal, int reg)
 {
-   return dcr_read(mal->dcrhost, mal->dcrhost.base + reg);
+   return dcr_read(mal->dcrhost, reg);
 }
 
 static inline void set_mal_dcrn(struct ibm_ocp_mal *mal, int reg, u32 val)
 {
-   dcr_write(mal->dcrhost, mal->dcrhost.base + reg, val);
+   dcr_write(mal->dcrhost, reg, val);
 }
 
 /* Register MAL devices */
diff --git a/include/asm-powerpc/dcr-mmio.h b/include/asm-powerpc/dcr-mmio.h
index 6b82c3b..a7d9eaf 100644
--- a/include/asm-powerpc/dcr-mmio.h
+++ b/include/asm-powerpc/dcr-mmio.h
@@ -37,12 +37,12 @@ extern void dcr_unmap(dcr_host_t host, unsigned int dcr_n, 
unsigned int dcr_c);
 
 static inline u32 dcr_read(dcr_host_t host, unsigned int dcr_n)
 {
-   return in_be32(host.token + dcr_n * host.stride);
+   return in_be32(host.token + ((host.base + dcr_n) * host.stride));
 }
 
 static inline void dcr_write(dcr_host_t host, unsigned int dcr_n, u32 value)
 {
-   out_be32(host.token + dcr_n * host.stride, value);
+   out_be32(host.token + ((host.base + dcr_n) * host.stride), value);
 }
 
 extern u64 of_translate_dcr_address(struct device_node *dev,
diff --git a/include/asm-powerpc/dcr-native.h b/include/asm-powerpc/dcr-native.h
index f41058c..3bc780f 100644
--- a/include/asm-powerpc/dcr-native.h
+++ b/include/asm-powerpc/dcr-native.h
@@ -30,8 +30,8 @@ typedef struct {
 
 #define dcr_map(dev, dcr_n, dcr_c) ((dcr_host_t){ .base = (dcr_n) })
 #define dcr_unmap(host, dcr_n, dcr_c)  do {} while (0)
-#define dcr_read(host, dcr_n)  mfdcr(dcr_n)
-#define dcr_write(host, dcr_n, value)  mtdcr(dcr_n, value)
+#define dcr_read(host, dcr_n)  mfdcr(dcr_n + host.base)
+#define dcr_write(host, dcr_n, value)  mtdcr(dcr_n + host.base, value)
 
 /* Device Control Registers */
 void __mtdcr(int reg, unsigned int val);
-- 
1.5.1.3.g7a33b

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


[PATCH 4/7] Update axon_msi to use dcr_host_t.base

2007-09-16 Thread Michael Ellerman
Now that dcr_host_t contains the base address, we can use that in the
axon_msi code, rather than storing it separately.

Signed-off-by: Michael Ellerman <[EMAIL PROTECTED]>
---
 arch/powerpc/platforms/cell/axon_msi.c |   13 ++---
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/platforms/cell/axon_msi.c 
b/arch/powerpc/platforms/cell/axon_msi.c
index 74407af..23e039a 100644
--- a/arch/powerpc/platforms/cell/axon_msi.c
+++ b/arch/powerpc/platforms/cell/axon_msi.c
@@ -69,7 +69,6 @@ struct axon_msic {
dcr_host_t dcr_host;
struct list_head list;
u32 read_offset;
-   u32 dcr_base;
 };
 
 static LIST_HEAD(axon_msic_list);
@@ -78,12 +77,12 @@ static void msic_dcr_write(struct axon_msic *msic, unsigned 
int dcr_n, u32 val)
 {
pr_debug("axon_msi: dcr_write(0x%x, 0x%x)\n", val, dcr_n);
 
-   dcr_write(msic->dcr_host, msic->dcr_base + dcr_n, val);
+   dcr_write(msic->dcr_host, msic->dcr_host.base + dcr_n, val);
 }
 
 static u32 msic_dcr_read(struct axon_msic *msic, unsigned int dcr_n)
 {
-   return dcr_read(msic->dcr_host, msic->dcr_base + dcr_n);
+   return dcr_read(msic->dcr_host, msic->dcr_host.base + dcr_n);
 }
 
 static void axon_msi_cascade(unsigned int irq, struct irq_desc *desc)
@@ -324,7 +323,7 @@ static int axon_msi_setup_one(struct device_node *dn)
struct page *page;
struct axon_msic *msic;
unsigned int virq;
-   int dcr_len;
+   int dcr_base, dcr_len;
 
pr_debug("axon_msi: setting up dn %s\n", dn->full_name);
 
@@ -335,17 +334,17 @@ static int axon_msi_setup_one(struct device_node *dn)
goto out;
}
 
-   msic->dcr_base = dcr_resource_start(dn, 0);
+   dcr_base = dcr_resource_start(dn, 0);
dcr_len = dcr_resource_len(dn, 0);
 
-   if (msic->dcr_base == 0 || dcr_len == 0) {
+   if (dcr_base == 0 || dcr_len == 0) {
printk(KERN_ERR
   "axon_msi: couldn't parse dcr properties on %s\n",
dn->full_name);
goto out;
}
 
-   msic->dcr_host = dcr_map(dn, msic->dcr_base, dcr_len);
+   msic->dcr_host = dcr_map(dn, dcr_base, dcr_len);
if (!DCR_MAP_OK(msic->dcr_host)) {
printk(KERN_ERR "axon_msi: dcr_map failed for %s\n",
   dn->full_name);
-- 
1.5.1.3.g7a33b

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


[PATCH 3/7] Use dcr_host_t.base in ibm_emac_mal

2007-09-16 Thread Michael Ellerman
This requires us to do a sort-of fake dcr_map(), so that base is set
properly. This will be fixed/removed when the device-tree-aware emac driver
is merged.

Signed-off-by: Michael Ellerman <[EMAIL PROTECTED]>
---
 drivers/net/ibm_emac/ibm_emac_mal.c |5 -
 drivers/net/ibm_emac/ibm_emac_mal.h |5 ++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ibm_emac/ibm_emac_mal.c 
b/drivers/net/ibm_emac/ibm_emac_mal.c
index cabd984..b08da96 100644
--- a/drivers/net/ibm_emac/ibm_emac_mal.c
+++ b/drivers/net/ibm_emac/ibm_emac_mal.c
@@ -421,7 +421,10 @@ static int __init mal_probe(struct ocp_device *ocpdev)
   ocpdev->def->index);
return -ENOMEM;
}
-   mal->dcrbase = maldata->dcr_base;
+
+   /* XXX This only works for native dcr for now */
+   mal->dcrhost = dcr_map(NULL, maldata->dcr_base, 0);
+
mal->def = ocpdev->def;
 
INIT_LIST_HEAD(&mal->poll_list);
diff --git a/drivers/net/ibm_emac/ibm_emac_mal.h 
b/drivers/net/ibm_emac/ibm_emac_mal.h
index 64bc338..6b1fbeb 100644
--- a/drivers/net/ibm_emac/ibm_emac_mal.h
+++ b/drivers/net/ibm_emac/ibm_emac_mal.h
@@ -191,7 +191,6 @@ struct mal_commac {
 };
 
 struct ibm_ocp_mal {
-   int dcrbase;
dcr_host_t  dcrhost;
 
struct list_headpoll_list;
@@ -209,12 +208,12 @@ struct ibm_ocp_mal {
 
 static inline u32 get_mal_dcrn(struct ibm_ocp_mal *mal, int reg)
 {
-   return dcr_read(mal->dcrhost, mal->dcrbase + reg);
+   return dcr_read(mal->dcrhost, mal->dcrhost.base + reg);
 }
 
 static inline void set_mal_dcrn(struct ibm_ocp_mal *mal, int reg, u32 val)
 {
-   dcr_write(mal->dcrhost, mal->dcrbase + reg, val);
+   dcr_write(mal->dcrhost, mal->dcrhost.base + reg, val);
 }
 
 /* Register MAL devices */
-- 
1.5.1.3.g7a33b

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


[PATCH 2/7] Update mpic to use dcr_host_t.base

2007-09-16 Thread Michael Ellerman
Now that dcr_host_t contains the base address, we can use that in the mpic
code, rather than storing it separately.

Signed-off-by: Michael Ellerman <[EMAIL PROTECTED]>
---
 arch/powerpc/sysdev/mpic.c |   28 +++-
 include/asm-powerpc/mpic.h |6 --
 2 files changed, 11 insertions(+), 23 deletions(-)

diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 8de29f2..16b1f4b 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -156,8 +156,7 @@ static inline u32 _mpic_read(enum mpic_reg_type type,
switch(type) {
 #ifdef CONFIG_PPC_DCR
case mpic_access_dcr:
-   return dcr_read(rb->dhost,
-   rb->dbase + reg + rb->doff);
+   return dcr_read(rb->dhost, rb->dhost.base + reg);
 #endif
case mpic_access_mmio_be:
return in_be32(rb->base + (reg >> 2));
@@ -174,8 +173,7 @@ static inline void _mpic_write(enum mpic_reg_type type,
switch(type) {
 #ifdef CONFIG_PPC_DCR
case mpic_access_dcr:
-   return dcr_write(rb->dhost,
-rb->dbase + reg + rb->doff, value);
+   return dcr_write(rb->dhost, rb->dhost.base + reg, value);
 #endif
case mpic_access_mmio_be:
return out_be32(rb->base + (reg >> 2), value);
@@ -279,9 +277,11 @@ static void _mpic_map_mmio(struct mpic *mpic, unsigned 
long phys_addr,
 static void _mpic_map_dcr(struct mpic *mpic, struct mpic_reg_bank *rb,
  unsigned int offset, unsigned int size)
 {
-   rb->dbase = mpic->dcr_base;
-   rb->doff = offset;
-   rb->dhost = dcr_map(mpic->irqhost->of_node, rb->dbase + rb->doff, size);
+   const u32 *dbasep;
+
+   dbasep = of_get_property(mpic->irqhost->of_node, "dcr-reg", NULL);
+
+   rb->dhost = dcr_map(mpic->irqhost->of_node, *dbasep + offset, size);
BUG_ON(!DCR_MAP_OK(rb->dhost));
 }
 
@@ -1075,20 +1075,14 @@ struct mpic * __init mpic_alloc(struct device_node 
*node,
BUG_ON(paddr == 0 && node == NULL);
 
/* If no physical address passed in, check if it's dcr based */
-   if (paddr == 0 && of_get_property(node, "dcr-reg", NULL) != NULL)
-   mpic->flags |= MPIC_USES_DCR;
-
+   if (paddr == 0 && of_get_property(node, "dcr-reg", NULL) != NULL) {
 #ifdef CONFIG_PPC_DCR
-   if (mpic->flags & MPIC_USES_DCR) {
-   const u32 *dbasep;
-   dbasep = of_get_property(node, "dcr-reg", NULL);
-   BUG_ON(dbasep == NULL);
-   mpic->dcr_base = *dbasep;
+   mpic->flags |= MPIC_USES_DCR;
mpic->reg_type = mpic_access_dcr;
-   }
 #else
-   BUG_ON (mpic->flags & MPIC_USES_DCR);
+   BUG();
 #endif /* CONFIG_PPC_DCR */
+   }
 
/* If the MPIC is not DCR based, and no physical address was passed
 * in, try to obtain one
diff --git a/include/asm-powerpc/mpic.h b/include/asm-powerpc/mpic.h
index edb4a7c..ae84dde 100644
--- a/include/asm-powerpc/mpic.h
+++ b/include/asm-powerpc/mpic.h
@@ -224,8 +224,6 @@ struct mpic_reg_bank {
u32 __iomem *base;
 #ifdef CONFIG_PPC_DCR
dcr_host_t  dhost;
-   unsigned intdbase;
-   unsigned intdoff;
 #endif /* CONFIG_PPC_DCR */
 };
 
@@ -289,10 +287,6 @@ struct mpic
struct mpic_reg_bankcpuregs[MPIC_MAX_CPUS];
struct mpic_reg_bankisus[MPIC_MAX_ISU];
 
-#ifdef CONFIG_PPC_DCR
-   unsigned intdcr_base;
-#endif
-
/* Protected sources */
unsigned long   *protected;
 
-- 
1.5.1.3.g7a33b

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


[PATCH 1/7] Store the base address in dcr_host_t

2007-09-16 Thread Michael Ellerman
In its current form, dcr_map() doesn't remember the base address you passed
it, which means you need to store it somewhere else. Rather than adding the
base to another struct it seems simpler to store it in the dcr_host_t.

Signed-off-by: Michael Ellerman <[EMAIL PROTECTED]>
---
 arch/powerpc/sysdev/dcr.c|2 +-
 include/asm-powerpc/dcr-mmio.h   |6 +-
 include/asm-powerpc/dcr-native.h |6 --
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/sysdev/dcr.c b/arch/powerpc/sysdev/dcr.c
index e82d54d..ab11c0b 100644
--- a/arch/powerpc/sysdev/dcr.c
+++ b/arch/powerpc/sysdev/dcr.c
@@ -104,7 +104,7 @@ u64 of_translate_dcr_address(struct device_node *dev,
 dcr_host_t dcr_map(struct device_node *dev, unsigned int dcr_n,
   unsigned int dcr_c)
 {
-   dcr_host_t ret = { .token = NULL, .stride = 0 };
+   dcr_host_t ret = { .token = NULL, .stride = 0, .base = dcr_n };
u64 addr;
 
pr_debug("dcr_map(%s, 0x%x, 0x%x)\n",
diff --git a/include/asm-powerpc/dcr-mmio.h b/include/asm-powerpc/dcr-mmio.h
index 5dbfca8..6b82c3b 100644
--- a/include/asm-powerpc/dcr-mmio.h
+++ b/include/asm-powerpc/dcr-mmio.h
@@ -23,7 +23,11 @@
 
 #include 
 
-typedef struct { void __iomem *token; unsigned int stride; } dcr_host_t;
+typedef struct {
+   void __iomem *token;
+   unsigned int stride;
+   unsigned int base;
+} dcr_host_t;
 
 #define DCR_MAP_OK(host)   ((host).token != NULL)
 
diff --git a/include/asm-powerpc/dcr-native.h b/include/asm-powerpc/dcr-native.h
index 05af081..f41058c 100644
--- a/include/asm-powerpc/dcr-native.h
+++ b/include/asm-powerpc/dcr-native.h
@@ -22,11 +22,13 @@
 #ifdef __KERNEL__
 #ifndef __ASSEMBLY__
 
-typedef struct {} dcr_host_t;
+typedef struct {
+   unsigned int base;
+} dcr_host_t;
 
 #define DCR_MAP_OK(host)   (1)
 
-#define dcr_map(dev, dcr_n, dcr_c) ((dcr_host_t){})
+#define dcr_map(dev, dcr_n, dcr_c) ((dcr_host_t){ .base = (dcr_n) })
 #define dcr_unmap(host, dcr_n, dcr_c)  do {} while (0)
 #define dcr_read(host, dcr_n)  mfdcr(dcr_n)
 #define dcr_write(host, dcr_n, value)  mtdcr(dcr_n, value)
-- 
1.5.1.3.g7a33b

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


[PATCH] Make sure to of_node_get() the result of pci_device_to_OF_node()

2007-09-16 Thread Michael Ellerman
pci_device_to_OF_node() returns the device node attached to a PCI device,
but doesn't actually grab a reference - we need to do it ourselves.

Signed-off-by: Michael Ellerman <[EMAIL PROTECTED]>
---
 arch/powerpc/platforms/cell/axon_msi.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/platforms/cell/axon_msi.c 
b/arch/powerpc/platforms/cell/axon_msi.c
index 57a6149..2b2dfcc 100644
--- a/arch/powerpc/platforms/cell/axon_msi.c
+++ b/arch/powerpc/platforms/cell/axon_msi.c
@@ -119,7 +119,7 @@ static struct axon_msic *find_msi_translator(struct pci_dev 
*dev)
const phandle *ph;
struct axon_msic *msic = NULL;
 
-   dn = pci_device_to_OF_node(dev);
+   dn = of_node_get(pci_device_to_OF_node(dev));
if (!dn) {
dev_dbg(&dev->dev, "axon_msi: no pci_dn found\n");
return NULL;
@@ -176,7 +176,7 @@ static int setup_msi_msg_address(struct pci_dev *dev, 
struct msi_msg *msg)
int len;
const u32 *prop;
 
-   dn = pci_device_to_OF_node(dev);
+   dn = of_node_get(pci_device_to_OF_node(dev));
if (!dn) {
dev_dbg(&dev->dev, "axon_msi: no pci_dn found\n");
return -ENODEV;
-- 
1.5.1.3.g7a33b

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


Re: [PATCH] i2c: devtree-aware iic support for PPC4xx

2007-09-16 Thread David Gibson
On Mon, Sep 17, 2007 at 07:34:08AM +0200, Stefan Roese wrote:
> On Sunday 16 September 2007, Eugene Surovegin wrote:
> > Hmm, I just noticed that you basically added a copy of existing
> > driver with small changes to support OF while keeping OCP one.
> >
> > Why not just add OF support to the existing code (under some ifdef),
> > and then remove OCP support as soon as ppc -> powerpc transition is
> > finished? Why have two almost identical code in the tree?
> 
> My understanding was, that adding many #ifdef's into the code was not the 
> preferred way. I could of course change this patch to not add an additional 
> driver but extend the existing driver with a bunch of #ifdef's to support 
> both versions.

#ifdefs are yucky, but so is duplication.  I'm not sure which is the
lesser evil in this case.

> This approach of multiple drivers seems to be common in the kernel right now:
> 
> drivers/mtd/maps/physmap.c
> drivers/mtd/maps/physmap_of.c

Not a relevant example.  Despite the names, physmap and physmap_of
don't really do the same thing at all.  I've been meaning to rename
physmap_of...

> 
> or
> 
> drivers/usb/host/ohci-ppc-soc.c
> drivers/usb/host/ohci-ppc-of.c

Also ibm_emac vs. ibm_new_emac (not merged yet).

> Any other opinions on this? How should this be handled to get accepted 
> upstream? Two different drivers with removing the "old" one later when 
> arch/ppc is gone, or one driver which supports both versions and removing the 
> ocp support in this driver later?
> 
> > I also personally don't like this _iic -> _of name change (you
> > removed peripheral name and added something which has nothing to do
> > with iic, I never heard of OF peripheral in 4xx chips). Whether you
> > use OCP or OF to pass a little information is quite irrelevant to the
> > iic driver operation.
> 
> The "old" name "i2c-ibm_iic" is kind of redundant. Nearly all bus drivers are 
> named "i2c-platform". Perhaps a better name would be "i2c-ppc4xx" then. 
> This "of" name was borrowed from already existing device-tree aware drivers 
> like drivers/mtd/maps/physmap_of.c or drivers/usb/host/ohci-ppc-of.c.

'ibm' is not specific enough - it's not like it's used on even a very
large fraction of ibm platforms - and 'of' is verging on misleading
(since OF != device tree, although they're related).  'iic' isn't
arbitrary - it comes from the name used in the documentation.
Although 'i2c-ppc4xx' probably is a better name, in any case.

-- 
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


libfdt: Consistently use big-endian property data in testcases

2007-09-16 Thread David Gibson
Flat device trees always have integers in their structure stored as
big-endian.  From this point of view, property values are
bags-of-bytes and any endianness is up to users of the device tree to
determine.

The libfdt testcases which use properties with integer values,
currently use native endian format for the architecture on which the
testcases are run.  This works ok for now, since both the creation and
checking of the example device trees happen in the same endianness.

This will become a problem, however, for tests of dtc which we want to
add in the nearish future.  dtc always uses big-endian format for
'cell' format data in properties; as it needs to in order to produce
powerpc-usable device trees when hosted on a little-endian
architecture.

This patch, therefore, changes the libfdt testsuite to use big-endian
format always for integer format data, in order to interoperate sanely
with future dtc testcases.  This also means that the example trees
created by the testsuite should now be byte-for-byte identical
regardless of dtc and libfdt's host platform, which is arguably an
advantage.

Signed-off-by: David Gibson <[EMAIL PROTECTED]>

Index: dtc/tests/testdata.h
===
--- dtc.orig/tests/testdata.h   2007-09-17 11:50:21.0 +1000
+++ dtc/tests/testdata.h2007-09-17 15:41:10.0 +1000
@@ -1,5 +1,16 @@
-#define TEST_VALUE_1   0xdeadbeef
-#define TEST_VALUE_2   0xabcd1234
+#include 
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define cell_to_fdt(x) (x)
+#else
+/* We do this as a big hairy expression instead of using bswap_32()
+ * because we need it to work in asm as well as C. */
+#define cell_to_fdt(x) x) >> 24) & 0xff) | (((x) >> 8) & 0xff00) \
+| (((x) << 8) & 0xff) | (((x) << 24) & 0xff00))
+#endif
+
+#define TEST_VALUE_1   cell_to_fdt(0xdeadbeef)
+#define TEST_VALUE_2   cell_to_fdt(0xabcd1234)
 
 #define TEST_STRING_1  "hello world"
 


-- 
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] i2c: devtree-aware iic support for PPC4xx

2007-09-16 Thread Stefan Roese
On Sunday 16 September 2007, Eugene Surovegin wrote:
> Hmm, I just noticed that you basically added a copy of existing
> driver with small changes to support OF while keeping OCP one.
>
> Why not just add OF support to the existing code (under some ifdef),
> and then remove OCP support as soon as ppc -> powerpc transition is
> finished? Why have two almost identical code in the tree?

My understanding was, that adding many #ifdef's into the code was not the 
preferred way. I could of course change this patch to not add an additional 
driver but extend the existing driver with a bunch of #ifdef's to support 
both versions.

This approach of multiple drivers seems to be common in the kernel right now:

drivers/mtd/maps/physmap.c
drivers/mtd/maps/physmap_of.c

or

drivers/usb/host/ohci-ppc-soc.c
drivers/usb/host/ohci-ppc-of.c

Any other opinions on this? How should this be handled to get accepted 
upstream? Two different drivers with removing the "old" one later when 
arch/ppc is gone, or one driver which supports both versions and removing the 
ocp support in this driver later?

> I also personally don't like this _iic -> _of name change (you
> removed peripheral name and added something which has nothing to do
> with iic, I never heard of OF peripheral in 4xx chips). Whether you
> use OCP or OF to pass a little information is quite irrelevant to the
> iic driver operation.

The "old" name "i2c-ibm_iic" is kind of redundant. Nearly all bus drivers are 
named "i2c-platform". Perhaps a better name would be "i2c-ppc4xx" then. 
This "of" name was borrowed from already existing device-tree aware drivers 
like drivers/mtd/maps/physmap_of.c or drivers/usb/host/ohci-ppc-of.c.

> If you insist on this approach, please add yourself as a maintainer of
> this code, because I'm not going to support two identical copies of my
> code in the kernel tree.

I "insist" in nothing. I'm just trying to get this device-tree aware I2C 
driver support upstream.

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


[PATCH] [POWERPC] Remove cmd_line from head*.S

2007-09-16 Thread Stephen Rothwell
It is just a C char array, so declare it thusly.

Signed-off-by: Stephen Rothwell <[EMAIL PROTECTED]>
---
 arch/powerpc/kernel/head_32.S|8 
 arch/powerpc/kernel/head_40x.S   |7 ---
 arch/powerpc/kernel/head_44x.S   |8 
 arch/powerpc/kernel/head_64.S|8 
 arch/powerpc/kernel/head_8xx.S   |8 
 arch/powerpc/kernel/head_fsl_booke.S |8 
 arch/powerpc/kernel/setup-common.c   |2 ++
 7 files changed, 2 insertions(+), 47 deletions(-)

This version has the definition in setup-common.c.

-- 
Cheers,
Stephen Rothwell[EMAIL PROTECTED]

diff --git a/arch/powerpc/kernel/head_32.S b/arch/powerpc/kernel/head_32.S
index 0e3df1f..a2e4df0 100644
--- a/arch/powerpc/kernel/head_32.S
+++ b/arch/powerpc/kernel/head_32.S
@@ -1300,14 +1300,6 @@ empty_zero_page:
 swapper_pg_dir:
.space  4096
 
-/*
- * This space gets a copy of optional info passed to us by the bootstrap
- * Used to pass parameters into the kernel like root=/dev/sda1, etc.
- */
-   .globl  cmd_line
-cmd_line:
-   .space  512
-
.globl intercept_table
 intercept_table:
.long 0, 0, i0x200, i0x300, i0x400, 0, i0x600, i0x700
diff --git a/arch/powerpc/kernel/head_40x.S b/arch/powerpc/kernel/head_40x.S
index a8e0457..8a69eec 100644
--- a/arch/powerpc/kernel/head_40x.S
+++ b/arch/powerpc/kernel/head_40x.S
@@ -1006,13 +1006,6 @@ critical_stack_top:
.globl  exception_stack_top
 exception_stack_top:
 
-/* This space gets a copy of optional info passed to us by the bootstrap
- * which is used to pass parameters into the kernel like root=/dev/sda1, etc.
- */
-   .globl  cmd_line
-cmd_line:
-   .space  512
-
 /* Room for two PTE pointers, usually the kernel and current user pointers
  * to their respective root page table.
  */
diff --git a/arch/powerpc/kernel/head_44x.S b/arch/powerpc/kernel/head_44x.S
index e26d26e..e405c59 100644
--- a/arch/powerpc/kernel/head_44x.S
+++ b/arch/powerpc/kernel/head_44x.S
@@ -744,14 +744,6 @@ exception_stack_bottom:
 exception_stack_top:
 
 /*
- * This space gets a copy of optional info passed to us by the bootstrap
- * which is used to pass parameters into the kernel like root=/dev/sda1, etc.
- */
-   .globl  cmd_line
-cmd_line:
-   .space  512
-
-/*
  * Room for two PTE pointers, usually the kernel and current user pointers
  * to their respective root page table.
  */
diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
index cec5908..f4ae82e 100644
--- a/arch/powerpc/kernel/head_64.S
+++ b/arch/powerpc/kernel/head_64.S
@@ -1540,11 +1540,3 @@ empty_zero_page:
.globl  swapper_pg_dir
 swapper_pg_dir:
.space  PAGE_SIZE
-
-/*
- * This space gets a copy of optional info passed to us by the bootstrap
- * Used to pass parameters into the kernel like root=/dev/sda1, etc.
- */
-   .globl  cmd_line
-cmd_line:
-   .space  COMMAND_LINE_SIZE
diff --git a/arch/powerpc/kernel/head_8xx.S b/arch/powerpc/kernel/head_8xx.S
index 901be47..22e1a3c 100644
--- a/arch/powerpc/kernel/head_8xx.S
+++ b/arch/powerpc/kernel/head_8xx.S
@@ -835,14 +835,6 @@ empty_zero_page:
 swapper_pg_dir:
.space  4096
 
-/*
- * This space gets a copy of optional info passed to us by the bootstrap
- * Used to pass parameters into the kernel like root=/dev/sda1, etc.
- */
-   .globl  cmd_line
-cmd_line:
-   .space  512
-
 /* Room for two PTE table poiners, usually the kernel and current user
  * pointer to their respective root page table (pgdir).
  */
diff --git a/arch/powerpc/kernel/head_fsl_booke.S 
b/arch/powerpc/kernel/head_fsl_booke.S
index 1f155d3..5f47adb 100644
--- a/arch/powerpc/kernel/head_fsl_booke.S
+++ b/arch/powerpc/kernel/head_fsl_booke.S
@@ -1050,14 +1050,6 @@ exception_stack_bottom:
 exception_stack_top:
 
 /*
- * This space gets a copy of optional info passed to us by the bootstrap
- * which is used to pass parameters into the kernel like root=/dev/sda1, etc.
- */
-   .globl  cmd_line
-cmd_line:
-   .space  512
-
-/*
  * Room for two PTE pointers, usually the kernel and current user pointers
  * to their respective root page table.
  */
diff --git a/arch/powerpc/kernel/setup-common.c 
b/arch/powerpc/kernel/setup-common.c
index 50ef38c..36c90ba 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -76,6 +76,8 @@ EXPORT_SYMBOL(machine_id);
 
 unsigned long klimit = (unsigned long) _end;
 
+char cmd_line[COMMAND_LINE_SIZE];
+
 /*
  * This still seems to be needed... -- paulus
  */ 
-- 
1.5.3.1

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


dtc: Cleanup testsuite organization

2007-09-16 Thread David Gibson
run_tests.sh from the dtc testsuite currently has a facility ro run
just "functional" or just "stress" tests.  This distinction is carried
over from libhugetlbfs where the test framework originated, and where
it made sense.

In dtc, we have no stress tests, so running these subsections isn't
particularly interesting.  This patch removes these test subsets,
instead defining a single "libfdt" test subset for testcases related
to libfdt (and not dtc proper only.  Currently that's all of the
testcases, but with any luck we'll have some dtc testcases in the
future.

Signed-off-by: David Gibson <[EMAIL PROTECTED]>

Index: dtc/tests/Makefile.tests
===
--- dtc.orig/tests/Makefile.tests   2007-09-04 14:17:32.0 +1000
+++ dtc/tests/Makefile.tests2007-09-04 14:17:36.0 +1000
@@ -49,18 +49,6 @@
 checkv:tests
cd $(TESTS_PREFIX); ./run_tests.sh -v
 
-func:  tests
-   cd $(TESTS_PREFIX); ./run_tests.sh -t func
-
-funcv: tests
-   cd $(TESTS_PREFIX); ./run_tests.sh -t func -v
-
-stress:tests
-   cd $(TESTS_PREFIX); ./run_tests.sh -t stress
-
-stressv: tests
-   cd $(TESTS_PREFIX); ./run_tests.sh -t stress -v
-
 ifneq ($(DEPTARGETS),)
 -include $(TESTS_DEPFILES)
 endif
Index: dtc/tests/run_tests.sh
===
--- dtc.orig/tests/run_tests.sh 2007-09-04 14:16:22.0 +1000
+++ dtc/tests/run_tests.sh  2007-09-04 14:55:29.0 +1000
@@ -49,7 +49,7 @@
 run_test nop_node $TREE
 }
 
-functional_tests () {
+libfdt_tests () {
 # Make sure we don't have stale blobs lying around
 rm -f *.test.dtb
 
@@ -86,10 +86,6 @@
 run_test truncated_property
 }
 
-stress_tests () {
-ITERATIONS=10   # Number of iterations for looping tests
-}
-
 while getopts "vdt:" ARG ; do
 case $ARG in
"v")
@@ -102,16 +98,13 @@
 done
 
 if [ -z "$TESTSETS" ]; then
-TESTSETS="func stress"
+TESTSETS="libfdt"
 fi
 
 for set in $TESTSETS; do
 case $set in
-   "func")
-   functional_tests
-   ;;
-   "stress")
-   stress_tests
+   "libfdt")
+   libfdt_tests
;;
 esac
 done

-- 
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


libfdt: Add fdt_node_offset_by_prop_value()

2007-09-16 Thread David Gibson
This patch adds a function to libfdt to locate nodes containing a
property with a specific value.

Signed-off-by: David Gibson <[EMAIL PROTECTED]>

Index: dtc/libfdt/fdt_ro.c
===
--- dtc.orig/libfdt/fdt_ro.c2007-09-17 14:00:22.0 +1000
+++ dtc/libfdt/fdt_ro.c 2007-09-17 14:04:18.0 +1000
@@ -407,3 +407,54 @@ int fdt_parent_offset(const void *fdt, i
return fdt_supernode_atdepth_offset(fdt, nodeoffset,
nodedepth - 1, NULL);
 }
+
+int fdt_node_offset_by_prop_value(const void *fdt, int startoffset,
+ const char *propname,
+ const void *propval, int proplen)
+{
+   uint32_t tag;
+   int offset, nextoffset;
+   const void *val;
+   int len;
+
+   CHECK_HEADER(fdt);
+
+   if (startoffset >= 0) {
+   tag = _fdt_next_tag(fdt, startoffset, &nextoffset);
+   if (tag != FDT_BEGIN_NODE)
+   return -FDT_ERR_BADOFFSET;
+   } else {
+   nextoffset = 0;
+   }
+
+   /* FIXME: The algorithm here is pretty horrible: we scan each
+* property of a node in fdt_getprop(), then if that didn't
+* find what we want, we scan over them again making our way
+* to the next node.  Still it's the easiest to implement
+* approach; performance can come later. */
+   do {
+   offset = nextoffset;
+   tag = _fdt_next_tag(fdt, offset, &nextoffset);
+
+   switch (tag) {
+   case FDT_BEGIN_NODE:
+   val = fdt_getprop(fdt, offset, propname, &len);
+   if (val
+   && (len == proplen)
+   && (memcmp(val, propval, len) == 0))
+   return offset;
+   break;
+
+   case FDT_PROP:
+   case FDT_END:
+   case FDT_END_NODE:
+   case FDT_NOP:
+   break;
+
+   default:
+   return -FDT_ERR_BADSTRUCTURE;
+   }
+   } while (tag != FDT_END);
+
+   return -FDT_ERR_NOTFOUND;
+}
Index: dtc/libfdt/libfdt.h
===
--- dtc.orig/libfdt/libfdt.h2007-09-17 14:00:04.0 +1000
+++ dtc/libfdt/libfdt.h 2007-09-17 14:00:23.0 +1000
@@ -146,6 +146,10 @@ int fdt_supernode_atdepth_offset(const v
 int fdt_node_depth(const void *fdt, int nodeoffset);
 int fdt_parent_offset(const void *fdt, int nodeoffset);
 
+int fdt_node_offset_by_prop_value(const void *fdt, int startoffset,
+ const char *propname,
+ const void *propval, int proplen);
+
 /* Write-in-place functions */
 int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
const void *val, int len);
Index: dtc/tests/Makefile.tests
===
--- dtc.orig/tests/Makefile.tests   2007-09-17 14:00:04.0 +1000
+++ dtc/tests/Makefile.tests2007-09-17 14:00:23.0 +1000
@@ -1,5 +1,6 @@
 LIB_TESTS_L = root_node find_property subnode_offset path_offset \
get_name getprop get_path supernode_atdepth_offset parent_offset \
+   node_offset_by_prop_value \
notfound \
setprop_inplace nop_property nop_node \
sw_tree1 \
Index: dtc/tests/node_offset_by_prop_value.c
===
--- /dev/null   1970-01-01 00:00:00.0 +
+++ dtc/tests/node_offset_by_prop_value.c   2007-09-17 14:00:23.0 
+1000
@@ -0,0 +1,110 @@
+/*
+ * libfdt - Flat Device Tree manipulation
+ * Testcase for fdt_path_offset()
+ * Copyright (C) 2006 David Gibson, IBM Corporation.
+ *
+ * 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 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "tests.h"
+#include "testdata.h"
+
+void vcheck_search(void *fdt, const char *propname, const void *propval,
+ int proplen, va_list ap)
+{
+   int offset = -1, target;
+
+   

Re: [PATCH] fix xmon input on 440

2007-09-16 Thread Hollis Blanchard
On Sun, 2007-09-16 at 22:39 -0500, Olof Johansson wrote:
> On Sun, Sep 16, 2007 at 10:26:37PM -0500, Josh Boyer wrote:
> > On Mon, 2007-09-17 at 12:52 +1000, David Gibson wrote:
> > > On Fri, Sep 14, 2007 at 03:44:47PM -0500, Hollis Blanchard wrote:
> > > > Implement udbg_getc() for 440, which fixes xmon input.
> > > > Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]>
> > > Acked-by: David Gibson <[EMAIL PROTECTED]>
> > > 
> > 
> > I fixed up the whitespace issues and applied it to my tree.  Oh, and
> > comments don't need semi-colons ;)
> 
> Well, there's a big difference between:
> 
>   while (foo)
>   /* moof */;
>   return bar;
> 
> and:
>   while (foo)
>   /* moof */
>   return bar;

Right, so this commit is broken:
http://git.infradead.org/?p=users/jwboyer/powerpc.git;a=commitdiff;h=81ec428065c01e37fb143ad31dc04fea27fddcac

-- 
Hollis Blanchard
IBM Linux Technology Center

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


[PATCH] [POWERPC] Fix section mismatch in pci code

2007-09-16 Thread Stephen Rothwell
Create a helper function (alloc_maybe_bootmem) that is marked __init_refok
to limit the chances of mistakenly refferring to other __init routines.

WARNING: vmlinux.o(.text+0x2a9c4): Section mismatch: reference to 
.init.text:.__alloc_bootmem (between '.update_dn_pci_info' and 
'.pci_dn_reconfig_notifier')
WARNING: vmlinux.o(.text+0x36430): Section mismatch: reference to 
.init.text:.__alloc_bootmem (between '.mpic_msi_init_allocator' and 
'.find_ht_magic_addr')
WARNING: vmlinux.o(.text+0x5e804): Section mismatch: reference to 
.init.text:.__alloc_bootmem (between '.celleb_setup_phb' and 
'.celleb_fake_pci_write_config')
WARNING: vmlinux.o(.text+0x5e8e8): Section mismatch: reference to 
.init.text:.__alloc_bootmem (between '.celleb_setup_phb' and 
'.celleb_fake_pci_write_config')
WARNING: vmlinux.o(.text+0x5e968): Section mismatch: reference to 
.init.text:.__alloc_bootmem (between '.celleb_setup_phb' and 
'.celleb_fake_pci_write_config')

Signed-off-by: Stephen Rothwell <[EMAIL PROTECTED]>
---
 arch/powerpc/kernel/pci_dn.c|7 +--
 arch/powerpc/lib/Makefile   |2 +-
 arch/powerpc/lib/alloc.c|   14 ++
 arch/powerpc/platforms/celleb/pci.c |   19 +--
 arch/powerpc/sysdev/mpic_msi.c  |6 +-
 include/asm-powerpc/system.h|2 ++
 6 files changed, 24 insertions(+), 26 deletions(-)
 create mode 100644 arch/powerpc/lib/alloc.c

-- 
Cheers,
Stephen Rothwell[EMAIL PROTECTED]

diff --git a/arch/powerpc/kernel/pci_dn.c b/arch/powerpc/kernel/pci_dn.c
index d7d36df..b483903 100644
--- a/arch/powerpc/kernel/pci_dn.c
+++ b/arch/powerpc/kernel/pci_dn.c
@@ -23,8 +23,6 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 
 #include 
 #include 
@@ -45,10 +43,7 @@ static void * __devinit update_dn_pci_info(struct 
device_node *dn, void *data)
const u32 *regs;
struct pci_dn *pdn;
 
-   if (mem_init_done)
-   pdn = kmalloc(sizeof(*pdn), GFP_KERNEL);
-   else
-   pdn = alloc_bootmem(sizeof(*pdn));
+   pdn = alloc_maybe_bootmem(sizeof(*pdn), GFP_KERNEL);
if (pdn == NULL)
return NULL;
memset(pdn, 0, sizeof(*pdn));
diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
index 0a486d4..23bbb1e 100644
--- a/arch/powerpc/lib/Makefile
+++ b/arch/powerpc/lib/Makefile
@@ -7,7 +7,7 @@ EXTRA_CFLAGS+= -mno-minimal-toc
 endif
 
 ifeq ($(CONFIG_PPC_MERGE),y)
-obj-y  := string.o
+obj-y  := string.o alloc.o
 obj-$(CONFIG_PPC32)+= div64.o copy_32.o checksum_32.o
 endif
 
diff --git a/arch/powerpc/lib/alloc.c b/arch/powerpc/lib/alloc.c
new file mode 100644
index 000..e58c805
--- /dev/null
+++ b/arch/powerpc/lib/alloc.c
@@ -0,0 +1,14 @@
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+void * __init_refok alloc_maybe_bootmem(size_t size, gfp_t mask)
+{
+   if (mem_init_done)
+   return kmalloc(size, mask);
+   else
+   return alloc_bootmem(size);
+}
diff --git a/arch/powerpc/platforms/celleb/pci.c 
b/arch/powerpc/platforms/celleb/pci.c
index 11336b4..1348b23 100644
--- a/arch/powerpc/platforms/celleb/pci.c
+++ b/arch/powerpc/platforms/celleb/pci.c
@@ -327,10 +327,7 @@ static int __init celleb_setup_fake_pci_device(struct 
device_node *node,
 
size = 256;
config = &private->fake_config[devno][fn];
-   if (mem_init_done)
-   *config = kzalloc(size, GFP_KERNEL);
-   else
-   *config = alloc_bootmem(size);
+   *config = alloc_maybe_bootmem(size, GFP_KERNEL);
if (*config == NULL) {
printk(KERN_ERR "PCI: "
   "not enough memory for fake configuration space\n");
@@ -341,10 +338,7 @@ static int __init celleb_setup_fake_pci_device(struct 
device_node *node,
 
size = sizeof(struct celleb_pci_resource);
res = &private->res[devno][fn];
-   if (mem_init_done)
-   *res = kzalloc(size, GFP_KERNEL);
-   else
-   *res = alloc_bootmem(size);
+   *res = alloc_maybe_bootmem(size, GFP_KERNEL);
if (*res == NULL) {
printk(KERN_ERR
   "PCI: not enough memory for resource data space\n");
@@ -436,12 +430,9 @@ static int __init phb_set_bus_ranges(struct device_node 
*dev,
 
 static void __init celleb_alloc_private_mem(struct pci_controller *hose)
 {
-   if (mem_init_done)
-   hose->private_data =
-   kzalloc(sizeof(struct celleb_pci_private), GFP_KERNEL);
-   else
-   hose->private_data =
-   alloc_bootmem(sizeof(struct celleb_pci_private));
+   hose->private_data =
+   alloc_maybe_bootmem(sizeof(struct celleb_pci_private),
+   GFP_KERNEL);
 }
 
 int __init celleb_setup_phb(struct pci_controller *phb)
diff --git a/arch/powerpc/sysdev/mpic_msi.c b/arch/powerpc/sysdev/mpic_msi.c
index 9c

[PATCH] [POWERPC] Remove unused variabls from drivers/ide/ppc/pmac.c

2007-09-16 Thread Stephen Rothwell
Removes these warnings:

/home/sfr/kernels/linus/drivers/ide/ppc/pmac.c: In function 
'pmac_ide_dma_check':
/home/sfr/kernels/linus/drivers/ide/ppc/pmac.c:1807: warning: unused variable 
'map'
/home/sfr/kernels/linus/drivers/ide/ppc/pmac.c:1805: warning: unused variable 
'pmif'

Signed-off-by: Stephen Rothwell <[EMAIL PROTECTED]>
---
 drivers/ide/ppc/pmac.c |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

-- 
Cheers,
Stephen Rothwell[EMAIL PROTECTED]

diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index 4b13cd9..f19eb6d 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -1802,9 +1802,7 @@ pmac_ide_dma_check(ide_drive_t *drive)
 {
struct hd_driveid *id = drive->id;
ide_hwif_t *hwif = HWIF(drive);
-   pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)hwif->hwif_data;
int enable = 1;
-   int map;
drive->using_dma = 0;

if (drive->media == ide_floppy)
-- 
1.5.3.1

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


Re: [PATCH] fix xmon input on 440

2007-09-16 Thread Olof Johansson
On Sun, Sep 16, 2007 at 10:26:37PM -0500, Josh Boyer wrote:
> On Mon, 2007-09-17 at 12:52 +1000, David Gibson wrote:
> > On Fri, Sep 14, 2007 at 03:44:47PM -0500, Hollis Blanchard wrote:
> > > Implement udbg_getc() for 440, which fixes xmon input.
> > > Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]>
> > Acked-by: David Gibson <[EMAIL PROTECTED]>
> > 
> 
> I fixed up the whitespace issues and applied it to my tree.  Oh, and
> comments don't need semi-colons ;)

Well, there's a big difference between:

while (foo)
/* moof */;
return bar;

and:
while (foo)
/* moof */
return bar;

:-)

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


Re: [PATCH] fix xmon input on 440

2007-09-16 Thread Josh Boyer
On Mon, 2007-09-17 at 12:52 +1000, David Gibson wrote:
> On Fri, Sep 14, 2007 at 03:44:47PM -0500, Hollis Blanchard wrote:
> > Implement udbg_getc() for 440, which fixes xmon input.
> > Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]>
> Acked-by: David Gibson <[EMAIL PROTECTED]>
> 

I fixed up the whitespace issues and applied it to my tree.  Oh, and
comments don't need semi-colons ;)

josh

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


Re: [PATCH] [POWERPC] DTS cleanup

2007-09-16 Thread David Gibson
On Fri, Sep 14, 2007 at 01:11:07PM -0500, Kumar Gala wrote:
> 
> On Sep 14, 2007, at 11:28 AM, Jon Loeliger wrote:
> 
> > Kumar Gala wrote:
> >
> >> Someone really needs to add some macro/preprocessor magic into DTC  
> >> so  this is made a lot simpler.
> >> - k
> >
> > Kumar,
> >
> > I am seriously contemplating this problem.
> > The trick is, I need to quit with the whole
> > Power Point Programmer job title for a bit...
> 
> I'm all for both of these things.  You working on getting DTC to have  
> some macro/include ability and you not being a powerpoint
> programmer.

Maybe we should make some time for all of us to get on IRC together to
discuss this?

I had some thoughts on what I think is a reasonably sane variable /
expression system for dtc.  Not quite the same thing as a macro
system, but a good start on one.

Although I also think we should still consider if using m4 as a
preprocessor (with some preloaded macros) could be sufficient.  Adding
expression and macro functions to dtc itself would be rather a lot of
work.

-- 
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] fix xmon input on 440

2007-09-16 Thread David Gibson
On Fri, Sep 14, 2007 at 03:44:47PM -0500, Hollis Blanchard wrote:
> Implement udbg_getc() for 440, which fixes xmon input.
> Signed-off-by: Hollis Blanchard <[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 3/4] 4xx: Convert Walnut flash mappings to new binding

2007-09-16 Thread David Gibson
On Sat, Sep 15, 2007 at 09:20:10PM +0200, Segher Boessenkool wrote:
> >> Maybe we can have  U-Boot  add  the  partition  information  if  it's
> >> missing in the device tree, and extend the mtdparts command in U-Boot
> >> to add / adjust settings so they match what is defined in U-Boot.
> >
> > That would be great for newer U-Boots.  For existing older ones, it
> > doesn't really solve the problem.  But then again, there's no way to
> > possibly define all the partitioning schemes people may have adopted to
> > their needs on their boards.  And I believe that is why David has
> > RedBoot and command line partitioning override what is in the DTS 
> > today.
> 
> Yeah, partitioning information really doesn't belong in the device
> tree -- with the possible exception of the partitions that the
> firmware (uboot in this case) needs to know about anyway.

Indeed - but we had just the same problem, only worse, with the old
approach of hardcoded, configured-in flash maps.

> You *can* put all partitioning info in the device tree, but that
> doesn't mean you *should* :-)

-- 
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 3/4] 4xx: Convert Walnut flash mappings to new binding

2007-09-16 Thread David Gibson
On Sat, Sep 15, 2007 at 05:09:01PM +0200, Wolfgang Denk wrote:
> In message <[EMAIL PROTECTED]> Josh Boyer wrote:
> > On Sat, 2007-09-15 at 05:23 +0200, Stefan Roese wrote:
> ...
> > > There are not only Bamboo board running PIBS, but running U-Boot too. How 
> > > should we handle this different FLASH partitioning? Same goes for Ebony 
> > > too 
> > > btw.
> > 
> > That's a good question.  I'm working on making the NOR flash show up for
> > Bamboo right now, and I had intended to just leave the partition
> > subnodes missing.
> 
> Maybe we can have  U-Boot  add  the  partition  information  if  it's
> missing in the device tree, and extend the mtdparts command in U-Boot
> to add / adjust settings so they match what is defined in U-Boot.
> 
> Stefan, what do you think?

If U-Boot is supplying a device tree, it should certainly make the
partition information match its own idea of the partitions.

For older non-device-tree away u-boot, I guess we'll have to make the
cuboot and treeboot wrappers mangle the device tree differently to
correct the partition information.

I suspect the easiest way to do this will be for the dts to contain
both treeboot and u-boot partition info, and have the wrapper delete
or nop the nodes for the other firmware.

-- 
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] i2c: devtree-aware iic support for PPC4xx

2007-09-16 Thread David Gibson
On Sun, Sep 16, 2007 at 06:27:47PM +0200, Robert Schwebel wrote:
> On Sun, Sep 16, 2007 at 01:52:02PM +0200, Stefan Roese wrote:
> > diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
> > index 9f3a4cd..12453e2 100644
> > --- a/drivers/i2c/busses/Kconfig
> > +++ b/drivers/i2c/busses/Kconfig
> > @@ -220,7 +220,17 @@ config I2C_PIIX4
> >  
> >  config I2C_IBM_IIC
> > tristate "IBM PPC 4xx on-chip I2C interface"
> > -   depends on IBM_OCP
> > +   depends on !PPC_MERGE
> > +   help
> > + Say Y here if you want to use IIC peripheral found on 
> > + embedded IBM PPC 4xx based systems. 
> 
> Can we agree on one nomenclature - either i2c or iic?

The dual nomenclature comes because linux uses i2c throughout the
subsystem, but all the hardware documentation refers to the controller
ASIC in question as 'IIC'.  So I think the convention is that 'i2c' is
used to refer to the type of bus in general, 'iic' is used to refer to
this particular type of bus controller.

-- 
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] i2c: devtree-aware iic support for PPC4xx

2007-09-16 Thread David Gibson
On Sun, Sep 16, 2007 at 11:53:30AM -0700, Eugene Surovegin wrote:
> On Sun, Sep 16, 2007 at 01:52:02PM +0200, Stefan Roese wrote:
> > This patch reworks existing ibm-iic driver to an of_platform_device
> > and enables it to talk to device tree directly. The ocp quirks are
> > completely removed by this patch.
> > 
> > This is done to enable I2C support for the PPC4xx platforms now
> > being moved from arch/ppc (OCP) to arch/powerpc (of). The first board
> > using this driver will be the AMCC Sequoia (PPC440EPx).
> > 
> > Signed-off-by: Stefan Roese <[EMAIL PROTECTED]>
> > 
> > ---
> > 2nd try with some cleanups. Please let me know if there still are some
> > problems.
> > 
> > Thanks.
> > 
> > commit 5748f81ff53277fa5c16de815b7d6b172ca284e9
> > tree 8284b3f1c836eb6eb06ee6882ee13b9e8f6cbb6b
> > parent d0174640eedc1cd756754f03afe2dbb3d56de74e
> > author Stefan Roese <[EMAIL PROTECTED]> Sun, 16 Sep 2007 13:46:40 +0200
> > committer Stefan Roese <[EMAIL PROTECTED]> Sun, 16 Sep 2007 13:46:40 +0200
> > 
> >  drivers/i2c/busses/Kconfig   |   12 -
> >  drivers/i2c/busses/Makefile  |1 
> >  drivers/i2c/busses/i2c-ibm_iic.h |3 
> >  drivers/i2c/busses/i2c-ibm_of.c  |  858 
> > ++
> >  4 files changed, 873 insertions(+), 1 deletions(-)
> > 
> > diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
> > index 9f3a4cd..12453e2 100644
> > --- a/drivers/i2c/busses/Kconfig
> > +++ b/drivers/i2c/busses/Kconfig
> > @@ -220,7 +220,17 @@ config I2C_PIIX4
> >  
> >  config I2C_IBM_IIC
> > tristate "IBM PPC 4xx on-chip I2C interface"
> > -   depends on IBM_OCP
> > +   depends on !PPC_MERGE
> > +   help
> > + Say Y here if you want to use IIC peripheral found on 
> > + embedded IBM PPC 4xx based systems. 
> > +
> > + This driver can also be built as a module.  If so, the module
> > + will be called i2c-ibm_iic.
> > +
> > +config I2C_IBM_OF
> > +   tristate "IBM PPC 4xx on-chip I2C interface"
> > +   depends on PPC_MERGE
> > help
> >   Say Y here if you want to use IIC peripheral found on 
> >   embedded IBM PPC 4xx based systems. 
> > diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
> > index 5b752e4..0cd0bac 100644
> > --- a/drivers/i2c/busses/Makefile
> > +++ b/drivers/i2c/busses/Makefile
> > @@ -17,6 +17,7 @@ obj-$(CONFIG_I2C_HYDRA)   += i2c-hydra.o
> >  obj-$(CONFIG_I2C_I801) += i2c-i801.o
> >  obj-$(CONFIG_I2C_I810) += i2c-i810.o
> >  obj-$(CONFIG_I2C_IBM_IIC)  += i2c-ibm_iic.o
> > +obj-$(CONFIG_I2C_IBM_OF)   += i2c-ibm_of.o
> >  obj-$(CONFIG_I2C_IOP3XX)   += i2c-iop3xx.o
> >  obj-$(CONFIG_I2C_IXP2000)  += i2c-ixp2000.o
> >  obj-$(CONFIG_I2C_IXP4XX)   += i2c-ixp4xx.o
> 
> Hmm, I just noticed that you basically added a copy of existing 
> driver with small changes to support OF while keeping OCP one.
> 
> Why not just add OF support to the existing code (under some ifdef), 
> and then remove OCP support as soon as ppc -> powerpc transition is 
> finished? Why have two almost identical code in the tree?
> 
> I also personally don't like this _iic -> _of name change (you 
> removed peripheral name and added something which has nothing to do 
> with iic, I never heard of OF peripheral in 4xx chips). Whether you 
> use OCP or OF to pass a little information is quite irrelevant to the 
> iic driver operation.

I concur on this point.  Especially since on 4xx the device tree will
generally be a flattened device tree which is vaguely OF-like, but not
from an actual Open Firmware.

> If you insist on this approach, please add yourself as a maintainer of 
> this code, because I'm not going to support two identical copies of my 
> code in the kernel tree.
> 

-- 
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: FDT for Microblaze and PPC405

2007-09-16 Thread Michal Simek
Hi,
I made EDK tcl script for generation DTS test scructure for FDT. Script 
support Microblaze and PowerPC 405.
Script was primary built for generation U-BOOT configs files for Microblaze.
For Microblaze can you generate both files (FDT and U-BOOT).
For PowerPC can you generate only DTS file. Generation U-BOOT configs files 
aren't supported yet. Script ends after generation DTS.
Script has 2.00.a mark.
It is available at www.monstr.eu.

Cheers,
Michal Simek


> On 9/11/07, Michal Simek <[EMAIL PROTECTED]> wrote:
>> Hi Grant,
>
> (Adding linuxppc-dev mailing list to CC list because we're discussing
> FDT issues)
>
>> I made EDK repository file for generation dts file from Xilinx design. I 
>> sent it to Wolfgang and Steve this week.
>> It is in the same config file as I use for configuration Microblaze for 
>> U-BOOT. If you want I can send you this repository files.
>
> Yes, please do.
>
>> And I start with redesigning Linux kernel for Microblaze. I ported some 
>> peripherals as timer and intc etc.
>> But for some peripherals I need better configuration.
>>
>> I have no time to read information about fdt. Can you tell me what labels 
>> I can use?
>
> Steve has already done a bunch of work in this direction on
> microblaze, I would converse with him.
>
>>
>> For example emaclite driver needs information about turning on/off ping 
>> pong buffer...
>>
>> I would like to make this properly.
>
> FDT design is just as much art as it is science.  It takes taste and
> judgement to desgin a nice set of bindings.  Your best option is to
> draft something and post it to the linuxppc-embedded mailing list for
> review.
>
>>
>> And second question is on early console logs and timers setting. I read 
>> about aliases in FDT. I think that aliases can cover this setting.
>> For example my design contain 4 serial line and I would like to know 
>> which serial line is set on early console.
>
> You use the chosen node for this.  In the chosen node, you add a
> property called "linux,stdout-path" which holds the path to your
> console.  You can look at examples under arch/powerpc/boot/dts/*
>
> Cheers,
> g.
>
>
> -- 
> Grant Likely, B.Sc., P.Eng.
> Secret Lab Technologies Ltd.
> [EMAIL PROTECTED]
> (403) 399-0195
>
>
> -- 
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.485 / Virus Database: 269.13.15/1002 - Release Date: 
> 11.9.2007 05:46
>
> 

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


Re: [PATCH] i2c: devtree-aware iic support for PPC4xx

2007-09-16 Thread Eugene Surovegin
On Sun, Sep 16, 2007 at 11:07:23AM +0200, Stefan Roese wrote:
> On Saturday 15 September 2007, Vitaly Bordug wrote:
> > > Where is dev->clkdiv initialized?
> > >
> > > My original version used iic_clkdiv() to calculate correct devider
> > > based on OPB frequency. Did you even test this code?
> 
> Yes, I tested it successfully on the Sequoia eval board.

I meant with the scope attached to i2c lines to verify correct i2c 
speed.

-- 
Eugene


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


Re: [PATCH] i2c: devtree-aware iic support for PPC4xx

2007-09-16 Thread Eugene Surovegin
On Sun, Sep 16, 2007 at 01:52:02PM +0200, Stefan Roese wrote:
> This patch reworks existing ibm-iic driver to an of_platform_device
> and enables it to talk to device tree directly. The ocp quirks are
> completely removed by this patch.
> 
> This is done to enable I2C support for the PPC4xx platforms now
> being moved from arch/ppc (OCP) to arch/powerpc (of). The first board
> using this driver will be the AMCC Sequoia (PPC440EPx).
> 
> Signed-off-by: Stefan Roese <[EMAIL PROTECTED]>
> 
> ---
> 2nd try with some cleanups. Please let me know if there still are some
> problems.
> 
> Thanks.
> 
> commit 5748f81ff53277fa5c16de815b7d6b172ca284e9
> tree 8284b3f1c836eb6eb06ee6882ee13b9e8f6cbb6b
> parent d0174640eedc1cd756754f03afe2dbb3d56de74e
> author Stefan Roese <[EMAIL PROTECTED]> Sun, 16 Sep 2007 13:46:40 +0200
> committer Stefan Roese <[EMAIL PROTECTED]> Sun, 16 Sep 2007 13:46:40 +0200
> 
>  drivers/i2c/busses/Kconfig   |   12 -
>  drivers/i2c/busses/Makefile  |1 
>  drivers/i2c/busses/i2c-ibm_iic.h |3 
>  drivers/i2c/busses/i2c-ibm_of.c  |  858 
> ++
>  4 files changed, 873 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
> index 9f3a4cd..12453e2 100644
> --- a/drivers/i2c/busses/Kconfig
> +++ b/drivers/i2c/busses/Kconfig
> @@ -220,7 +220,17 @@ config I2C_PIIX4
>  
>  config I2C_IBM_IIC
>   tristate "IBM PPC 4xx on-chip I2C interface"
> - depends on IBM_OCP
> + depends on !PPC_MERGE
> + help
> +   Say Y here if you want to use IIC peripheral found on 
> +   embedded IBM PPC 4xx based systems. 
> +
> +   This driver can also be built as a module.  If so, the module
> +   will be called i2c-ibm_iic.
> +
> +config I2C_IBM_OF
> + tristate "IBM PPC 4xx on-chip I2C interface"
> + depends on PPC_MERGE
>   help
> Say Y here if you want to use IIC peripheral found on 
> embedded IBM PPC 4xx based systems. 
> diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
> index 5b752e4..0cd0bac 100644
> --- a/drivers/i2c/busses/Makefile
> +++ b/drivers/i2c/busses/Makefile
> @@ -17,6 +17,7 @@ obj-$(CONFIG_I2C_HYDRA) += i2c-hydra.o
>  obj-$(CONFIG_I2C_I801)   += i2c-i801.o
>  obj-$(CONFIG_I2C_I810)   += i2c-i810.o
>  obj-$(CONFIG_I2C_IBM_IIC)+= i2c-ibm_iic.o
> +obj-$(CONFIG_I2C_IBM_OF) += i2c-ibm_of.o
>  obj-$(CONFIG_I2C_IOP3XX) += i2c-iop3xx.o
>  obj-$(CONFIG_I2C_IXP2000)+= i2c-ixp2000.o
>  obj-$(CONFIG_I2C_IXP4XX) += i2c-ixp4xx.o

Hmm, I just noticed that you basically added a copy of existing 
driver with small changes to support OF while keeping OCP one.

Why not just add OF support to the existing code (under some ifdef), 
and then remove OCP support as soon as ppc -> powerpc transition is 
finished? Why have two almost identical code in the tree?

I also personally don't like this _iic -> _of name change (you 
removed peripheral name and added something which has nothing to do 
with iic, I never heard of OF peripheral in 4xx chips). Whether you 
use OCP or OF to pass a little information is quite irrelevant to the 
iic driver operation.

If you insist on this approach, please add yourself as a maintainer of 
this code, because I'm not going to support two identical copies of my 
code in the kernel tree.

-- 
Eugene



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


Re: [PATCH] i2c: devtree-aware iic support for PPC4xx

2007-09-16 Thread Robert Schwebel
On Sun, Sep 16, 2007 at 01:52:02PM +0200, Stefan Roese wrote:
> diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
> index 9f3a4cd..12453e2 100644
> --- a/drivers/i2c/busses/Kconfig
> +++ b/drivers/i2c/busses/Kconfig
> @@ -220,7 +220,17 @@ config I2C_PIIX4
>  
>  config I2C_IBM_IIC
>   tristate "IBM PPC 4xx on-chip I2C interface"
> - depends on IBM_OCP
> + depends on !PPC_MERGE
> + help
> +   Say Y here if you want to use IIC peripheral found on 
> +   embedded IBM PPC 4xx based systems. 

Can we agree on one nomenclature - either i2c or iic?

> +   This driver can also be built as a module.  If so, the module
> +   will be called i2c-ibm_iic.

Are these drivers the same functionality (host i2c driver for 4xx)? If
yes, shouldn't all in-tree users be migrated over and the old style
driver be removed (with deprecation period)?

> +#define DBG_LEVEL 0
> +
> +#ifdef DBG
> +#undef DBG
> +#endif
> +
> +#ifdef DBG2
> +#undef DBG2
> +#endif
> +
> +#if DBG_LEVEL > 0
> +#  define DBG(f,x...)printk(KERN_DEBUG "ibm-iic" f, ##x)
> +#else
> +#  define DBG(f,x...)((void)0)
> +#endif
> +#if DBG_LEVEL > 1
> +#  define DBG2(f,x...)   DBG(f, ##x)
> +#else
> +#  define DBG2(f,x...)   ((void)0)
> +#endif

Any reason why you can't use pr_debug?

Robert
-- 
Pengutronix - Linux Solutions for Science and Industry
Entwicklungszentrum Nord http://www.pengutronix.de
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH] i2c: devtree-aware iic support for PPC4xx

2007-09-16 Thread Josh Boyer
On Sun, 16 Sep 2007 18:27:47 +0200
Robert Schwebel <[EMAIL PROTECTED]> wrote:

> On Sun, Sep 16, 2007 at 01:52:02PM +0200, Stefan Roese wrote:
> > diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
> > index 9f3a4cd..12453e2 100644
> > --- a/drivers/i2c/busses/Kconfig
> > +++ b/drivers/i2c/busses/Kconfig
> > @@ -220,7 +220,17 @@ config I2C_PIIX4
> >  
> >  config I2C_IBM_IIC
> > tristate "IBM PPC 4xx on-chip I2C interface"
> > -   depends on IBM_OCP
> > +   depends on !PPC_MERGE
> > +   help
> > + Say Y here if you want to use IIC peripheral found on 
> > + embedded IBM PPC 4xx based systems. 
> 
> Can we agree on one nomenclature - either i2c or iic?
> 
> > + This driver can also be built as a module.  If so, the module
> > + will be called i2c-ibm_iic.
> 
> Are these drivers the same functionality (host i2c driver for 4xx)? If
> yes, shouldn't all in-tree users be migrated over and the old style
> driver be removed (with deprecation period)?

They are the same functionality, but for two different versions of the
arch.  The old one is arch/ppc, the new one is arch/powerpc.  4xx is
being migrated to arch/powerpc so eventually what you say will happen.
The arch/ppc tree is scheduled for removal in June of 2008.  For now,
we need both drivers since not everything in 4xx has moved yet.

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


Re: [PATCH 4/7] powerpc: BestComm core support for Freescale MPC5200

2007-09-16 Thread Kumar Gala

On Sep 16, 2007, at 5:53 AM, Sylvain Munaut wrote:

> This patch adds support for the core of the BestComm API
> for the Freescale MPC5200(b). The BestComm engine is a
> microcode-controlled / tasks-based DMA used by several
> of the onchip devices.
>
> Setting up the tasks / memory allocation and all common
> low level functions are handled by this patch.
> The specifics details of each tasks and their microcode
> are split-out in separate patches.
>
> This is not the official API, but a much cleaner one.
> (hopefully)
>
> Signed-off-by: Sylvain Munaut <[EMAIL PROTECTED]>
> ---
>  arch/powerpc/platforms/Kconfig   |2 +
>  arch/powerpc/sysdev/Makefile |1 +
>  arch/powerpc/sysdev/bestcomm/Kconfig |   18 +
>  arch/powerpc/sysdev/bestcomm/Makefile|8 +
>  arch/powerpc/sysdev/bestcomm/bestcomm.c  |  657 +++ 
> +++
>  arch/powerpc/sysdev/bestcomm/bestcomm.h  |  136 ++
>  arch/powerpc/sysdev/bestcomm/bestcomm_priv.h |  325 +
>  arch/powerpc/sysdev/bestcomm/sram.c  |  177 +++
>  arch/powerpc/sysdev/bestcomm/sram.h  |   54 +++
>  9 files changed, 1378 insertions(+), 0 deletions(-)
>  create mode 100644 arch/powerpc/sysdev/bestcomm/Kconfig
>  create mode 100644 arch/powerpc/sysdev/bestcomm/Makefile
>  create mode 100644 arch/powerpc/sysdev/bestcomm/bestcomm.c
>  create mode 100644 arch/powerpc/sysdev/bestcomm/bestcomm.h
>  create mode 100644 arch/powerpc/sysdev/bestcomm/bestcomm_priv.h
>  create mode 100644 arch/powerpc/sysdev/bestcomm/sram.c
>  create mode 100644 arch/powerpc/sysdev/bestcomm/sram.h

this version still doesn't address comments made back in may:

http://ozlabs.org/pipermail/linuxppc-dev/2007-May/036224.html

Also, what about splitting bestcomm.c into bestcomm_task.c &  
bestcomm_drv.c (or just bestcomm.c) or something like that.  It seems  
'private API' isn't really the proper term.

- k



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


Re: [PATCH 2/7] powerpc: Changes the config mechanism for rheap

2007-09-16 Thread Kumar Gala

On Sep 16, 2007, at 5:53 AM, Sylvain Munaut wrote:

> Instead of having in the makefile all the option that
> requires rheap, we define a configuration symbol
> and when needed we make sure it's selected.
>
> Signed-off-by: Sylvain Munaut <[EMAIL PROTECTED]>
> ---
>  arch/powerpc/Kconfig   |2 ++
>  arch/powerpc/lib/Kconfig   |3 +++
>  arch/powerpc/lib/Makefile  |5 +
>  arch/powerpc/platforms/Kconfig |2 ++
>  arch/powerpc/platforms/Kconfig.cputype |1 +
>  5 files changed, 9 insertions(+), 4 deletions(-)
>  create mode 100644 arch/powerpc/lib/Kconfig

This probably breaks arch/ppc in that you'll need to add the proper  
select PPC_LIB_RHEAP to its Kconfig(s) for 8xx & CPM2.

> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 00099ef..76063b9 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -634,6 +634,8 @@ source "fs/Kconfig"
>
>  source "arch/powerpc/sysdev/qe_lib/Kconfig"
>
> +source "arch/powerpc/lib/Kconfig"
> +
>  source "lib/Kconfig"
>
>  menu "Instrumentation Support"
> diff --git a/arch/powerpc/lib/Kconfig b/arch/powerpc/lib/Kconfig
> new file mode 100644
> index 000..f383ad4

why not just stick this in the toplevel powerpc/Kconfig

> --- /dev/null
> +++ b/arch/powerpc/lib/Kconfig
> @@ -0,0 +1,3 @@
> +config PPC_LIB_RHEAP
> + bool
> + default n

Please add a help description here.

[snip]

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


Re: [PATCH 4/7] powerpc: BestComm core support for Freescale MPC5200

2007-09-16 Thread Stephen Rothwell
On Sun, 16 Sep 2007 12:53:27 +0200 Sylvain Munaut <[EMAIL PROTECTED]> wrote:
>
> +++ b/arch/powerpc/sysdev/bestcomm/Makefile
> @@ -0,0 +1,8 @@
> +#
> +# Makefile for BestComm & co
> +#
> +
> +bestcomm-core-objs   := bestcomm.o sram.o
> +
> +obj-$(CONFIG_PPC_BESTCOMM)   += bestcomm-core.o

Or just obj-y since the whole makefile is dependent on CONFIG_PPC_BESTCOMM.

> +++ b/arch/powerpc/sysdev/bestcomm/bestcomm.c
>
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 

Please include linux/of_device.h and linux/of_platform.h instead.
And linux/of.h instead of asm/prom.h.

> + ofn_bcom = op->node;
> + of_node_get(ofn_bcom);

The usual idiom is ofn_bcom = of_get_node(op->node);

> + /* Save the node */
> + bcom_eng->ofnode = ofn_bcom;
> +
> + /* Get, reserve & map io */
> + if (of_address_to_resource(bcom_eng->ofnode, 0, &res_bcom)) {
   
Any reason not to use ofn_bcom here?

> + /* Error path */
> +error_unmap:
> + iounmap(bcom_eng->regs);
> +error_release:
> + release_mem_region(res_bcom.start, sizeof(struct mpc52xx_sdma));
> +error_sramclean:
> + bcom_sram_cleanup();
> +error_ofput:
> + of_node_put(bcom_eng->ofnode);

And here?  Also bcom_eng doesn't get freed in the error path.

> +++ b/arch/powerpc/sysdev/bestcomm/bestcomm_priv.h
> +#include 
> +#include 
> +#include 

Again please include linux/of.h instead of asm/prom.h

> +++ b/arch/powerpc/sysdev/bestcomm/sram.c
> +
> +#include 
> +#include 
> +#include 

And again.

-- 
Cheers,
Stephen Rothwell[EMAIL PROTECTED]
http://www.canb.auug.org.au/~sfr/


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

[PATCH] i2c: devtree-aware iic support for PPC4xx

2007-09-16 Thread Stefan Roese
This patch reworks existing ibm-iic driver to an of_platform_device
and enables it to talk to device tree directly. The ocp quirks are
completely removed by this patch.

This is done to enable I2C support for the PPC4xx platforms now
being moved from arch/ppc (OCP) to arch/powerpc (of). The first board
using this driver will be the AMCC Sequoia (PPC440EPx).

Signed-off-by: Stefan Roese <[EMAIL PROTECTED]>

---
2nd try with some cleanups. Please let me know if there still are some
problems.

Thanks.

commit 5748f81ff53277fa5c16de815b7d6b172ca284e9
tree 8284b3f1c836eb6eb06ee6882ee13b9e8f6cbb6b
parent d0174640eedc1cd756754f03afe2dbb3d56de74e
author Stefan Roese <[EMAIL PROTECTED]> Sun, 16 Sep 2007 13:46:40 +0200
committer Stefan Roese <[EMAIL PROTECTED]> Sun, 16 Sep 2007 13:46:40 +0200

 drivers/i2c/busses/Kconfig   |   12 -
 drivers/i2c/busses/Makefile  |1 
 drivers/i2c/busses/i2c-ibm_iic.h |3 
 drivers/i2c/busses/i2c-ibm_of.c  |  858 ++
 4 files changed, 873 insertions(+), 1 deletions(-)

diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 9f3a4cd..12453e2 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -220,7 +220,17 @@ config I2C_PIIX4
 
 config I2C_IBM_IIC
tristate "IBM PPC 4xx on-chip I2C interface"
-   depends on IBM_OCP
+   depends on !PPC_MERGE
+   help
+ Say Y here if you want to use IIC peripheral found on 
+ embedded IBM PPC 4xx based systems. 
+
+ This driver can also be built as a module.  If so, the module
+ will be called i2c-ibm_iic.
+
+config I2C_IBM_OF
+   tristate "IBM PPC 4xx on-chip I2C interface"
+   depends on PPC_MERGE
help
  Say Y here if you want to use IIC peripheral found on 
  embedded IBM PPC 4xx based systems. 
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 5b752e4..0cd0bac 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -17,6 +17,7 @@ obj-$(CONFIG_I2C_HYDRA)   += i2c-hydra.o
 obj-$(CONFIG_I2C_I801) += i2c-i801.o
 obj-$(CONFIG_I2C_I810) += i2c-i810.o
 obj-$(CONFIG_I2C_IBM_IIC)  += i2c-ibm_iic.o
+obj-$(CONFIG_I2C_IBM_OF)   += i2c-ibm_of.o
 obj-$(CONFIG_I2C_IOP3XX)   += i2c-iop3xx.o
 obj-$(CONFIG_I2C_IXP2000)  += i2c-ixp2000.o
 obj-$(CONFIG_I2C_IXP4XX)   += i2c-ixp4xx.o
diff --git a/drivers/i2c/busses/i2c-ibm_iic.h b/drivers/i2c/busses/i2c-ibm_iic.h
index 59d7b43..485c72c 100644
--- a/drivers/i2c/busses/i2c-ibm_iic.h
+++ b/drivers/i2c/busses/i2c-ibm_iic.h
@@ -23,6 +23,7 @@
 #define __I2C_IBM_IIC_H_
 
 #include  
+#include 
 
 struct iic_regs {
u16 mdbuf;
@@ -50,6 +51,8 @@ struct ibm_iic_private {
int irq;
int fast_mode;
u8  clckdiv;
+   struct device_node *np;
+   phys_addr_t paddr;
 };
 
 /* IICx_CNTL register */
diff --git a/drivers/i2c/busses/i2c-ibm_of.c b/drivers/i2c/busses/i2c-ibm_of.c
new file mode 100644
index 000..5e5b3e5
--- /dev/null
+++ b/drivers/i2c/busses/i2c-ibm_of.c
@@ -0,0 +1,858 @@
+/*
+ * drivers/i2c/busses/i2c-ibm_of.c
+ *
+ * Support for the IIC peripheral on IBM PPC 4xx
+ *
+ * Copyright (c) 2003, 2004 Zultys Technologies.
+ * Eugene Surovegin <[EMAIL PROTECTED]> or <[EMAIL PROTECTED]>
+ *
+ * Based on original work by
+ * Ian DaSilva  <[EMAIL PROTECTED]>
+ *  Armin Kuster <[EMAIL PROTECTED]>
+ * Matt Porter  <[EMAIL PROTECTED]>
+ *
+ *  Copyright 2000-2003 MontaVista Software Inc.
+ *
+ * Original driver version was highly leveraged from i2c-elektor.c
+ *
+ * Copyright 1995-97 Simon G. Vogl
+ *1998-99 Hans Berglund
+ *
+ * With some changes from Ky�sti M�lkki <[EMAIL PROTECTED]>
+ * and even Frodo Looijaard <[EMAIL PROTECTED]>
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "i2c-ibm_iic.h"
+
+#define DRIVER_VERSION "2.1"
+
+MODULE_DESCRIPTION("IBM IIC driver v" DRIVER_VERSION);
+MODULE_LICENSE("GPL");
+
+static int device_idx = -1;
+
+static int iic_force_poll;
+module_param(iic_force_poll, bool, 0);
+MODULE_PARM_DESC(iic_force_poll, "Force polling mode");
+
+static int iic_force_fast;
+module_param(iic_force_fast, bool, 0);
+MODULE_PARM_DESC(iic_fast_poll, "Force fast mode (400 kHz)");
+
+#define DBG_LEVEL 0
+
+#ifdef DBG
+#undef DBG
+#endif
+
+#ifdef DBG2
+#undef DBG2
+#endif
+
+#if DBG_LEVEL > 0
+#  define DBG(f,x...)  printk(KERN_DEBUG "ibm-iic" f, ##x)
+#else
+#  define DBG(f,x...)  ((void)0)
+#endif
+#if DBG_LEVEL > 1
+#  define DBG2(f,x...) DBG(f, ##x)
+#else
+#  define DBG2(f,x...) ((void)0

[PATCH 7/7] powerpc: BestComm GenBD task support

2007-09-16 Thread Sylvain Munaut
This is the microcode for the GenBD task and the associated
support code. This is a generic task that copy data to/from
a hardware FIFO. This is currently locked to 32bits wide
access but could be extended as needed.

The microcode itself comes directly from the offical
API (v2.2)

Signed-off-by: Sylvain Munaut <[EMAIL PROTECTED]>
---
 arch/powerpc/sysdev/bestcomm/Kconfig   |7 +
 arch/powerpc/sysdev/bestcomm/Makefile  |2 +
 arch/powerpc/sysdev/bestcomm/bcom_gen_bd_rx_task.c |   63 +
 arch/powerpc/sysdev/bestcomm/bcom_gen_bd_tx_task.c |   69 +
 arch/powerpc/sysdev/bestcomm/gen_bd.c  |  260 
 arch/powerpc/sysdev/bestcomm/gen_bd.h  |   48 
 6 files changed, 449 insertions(+), 0 deletions(-)
 create mode 100644 arch/powerpc/sysdev/bestcomm/bcom_gen_bd_rx_task.c
 create mode 100644 arch/powerpc/sysdev/bestcomm/bcom_gen_bd_tx_task.c
 create mode 100644 arch/powerpc/sysdev/bestcomm/gen_bd.c
 create mode 100644 arch/powerpc/sysdev/bestcomm/gen_bd.h

diff --git a/arch/powerpc/sysdev/bestcomm/Kconfig 
b/arch/powerpc/sysdev/bestcomm/Kconfig
index 831763b..57cc565 100644
--- a/arch/powerpc/sysdev/bestcomm/Kconfig
+++ b/arch/powerpc/sysdev/bestcomm/Kconfig
@@ -30,3 +30,10 @@ config PPC_BESTCOMM_FEC
help
  This option enables the support for the FEC tasks.
 
+config PPC_BESTCOMM_GEN_BD
+   tristate "Bestcomm GenBD tasks support"
+   depends on PPC_BESTCOMM
+   default n
+   help
+ This option enables the support for the GenBD tasks.
+
diff --git a/arch/powerpc/sysdev/bestcomm/Makefile 
b/arch/powerpc/sysdev/bestcomm/Makefile
index 537d174..aed2df2 100644
--- a/arch/powerpc/sysdev/bestcomm/Makefile
+++ b/arch/powerpc/sysdev/bestcomm/Makefile
@@ -5,8 +5,10 @@
 bestcomm-core-objs := bestcomm.o sram.o
 bestcomm-ata-objs  := ata.o bcom_ata_task.o
 bestcomm-fec-objs  := fec.o bcom_fec_rx_task.o bcom_fec_tx_task.o
+bestcomm-gen-bd-objs   := gen_bd.o bcom_gen_bd_rx_task.o bcom_gen_bd_tx_task.o
 
 obj-$(CONFIG_PPC_BESTCOMM) += bestcomm-core.o
 obj-$(CONFIG_PPC_BESTCOMM_ATA) += bestcomm-ata.o
 obj-$(CONFIG_PPC_BESTCOMM_FEC) += bestcomm-fec.o
+obj-$(CONFIG_PPC_BESTCOMM_GEN_BD)  += bestcomm-gen-bd.o
  
diff --git a/arch/powerpc/sysdev/bestcomm/bcom_gen_bd_rx_task.c 
b/arch/powerpc/sysdev/bestcomm/bcom_gen_bd_rx_task.c
new file mode 100644
index 000..efee022
--- /dev/null
+++ b/arch/powerpc/sysdev/bestcomm/bcom_gen_bd_rx_task.c
@@ -0,0 +1,63 @@
+/*
+ * Bestcomm GenBD RX task microcode
+ *
+ * Copyright (C) 2006 AppSpec Computer Technologies Corp.
+ *Jeff Gibbons <[EMAIL PROTECTED]>
+ * Copyright (c) 2004 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ * Based on BestCommAPI-2.2/code_dma/image_rtos1/dma_image.hex
+ * on Tue Mar 4 10:14:12 2006 GMT
+ *
+ */
+
+#include 
+
+/*
+ * The header consists of the following fields:
+ * u32 magic;
+ * u8  desc_size;
+ * u8  var_size;
+ * u8  inc_size;
+ * u8  first_var;
+ * u8  reserved[8];
+ *
+ * The size fields contain the number of 32-bit words.
+ */
+
+u32 bcom_gen_bd_rx_task[] = {
+   /* header */
+   0x4243544b,
+   0x0d020409,
+   0x,
+   0x,
+
+   /* Task descriptors */
+   0x808220da, /* LCD: idx0 = var1, idx1 = var4; idx1 <= var3; idx0 += 
inc3, idx1 += inc2 */
+   0x13e01010, /*   DRD1A: var4 = var2; FN=0 MORE init=31 WS=0 RS=0 */
+   0xb880025b, /*   LCD: idx2 = *idx1, idx3 = var0; idx2 < var9; idx2 += 
inc3, idx3 += inc3 */
+   0x10001308, /* DRD1A: var4 = idx1; FN=0 MORE init=0 WS=0 RS=0 */
+   0x60140002, /* DRD2A: EU0=0 EU1=0 EU2=0 EU3=2 EXT init=0 WS=2 RS=2 
*/
+   0x0cccfcca, /* DRD2B1: *idx3 = EU3(); EU3(*idx3,var10)  */
+   0xd9190240, /*   LCDEXT: idx2 = idx2; idx2 > var9; idx2 += inc0 */
+   0xb8c5e009, /*   LCD: idx3 = *(idx1 + var0015); ; idx3 += inc1 */
+   0x07fecf80, /* DRD1A: *idx3 = *idx0; FN=0 INT init=31 WS=3 RS=3 */
+   0x99190024, /*   LCD: idx2 = idx2; idx2 once var0; idx2 += inc4 */
+   0x6005, /* DRD2A: EU0=0 EU1=0 EU2=0 EU3=5 EXT init=0 WS=0 RS=0 
*/
+   0x0c4cf889, /* DRD2B1: *idx1 = EU3(); EU3(idx2,var9)  */
+   0x01f8, /*   NOP */
+
+   /* VAR[9]-VAR[10] */
+   0x4000,
+   0x7fff7fff,
+
+   /* INC[0]-INC[3] */
+   0x4000,
+   0xe000,
+   0xa008,
+   0x2000,
+};
+
diff --git a/arch/powerpc/sysdev/bestcomm/bcom_gen_bd_tx_task.c 
b/arch/powerpc/sysdev/bestcomm/bcom_gen_bd_tx_task.c
new file mode 100644
index 000..c605aa4
--- /dev/null
+++ b/arch/powerpc/sysdev/bestcomm/bcom_gen_bd_tx_task.c
@@ -0,0 +1,69 @@
+/*
+ * Bestcomm GenBD TX task microcode
+ *
+ * C

[PATCH 6/7] powerpc: BestComm FEC task support

2007-09-16 Thread Sylvain Munaut
This is the microcode for the FEC task and the associated
support code.

The microcode itself comes directly from the offical
API (v2.2)

Signed-off-by: Sylvain Munaut <[EMAIL PROTECTED]>
---
 arch/powerpc/sysdev/bestcomm/Kconfig|7 +
 arch/powerpc/sysdev/bestcomm/Makefile   |2 +
 arch/powerpc/sysdev/bestcomm/bcom_fec_rx_task.c |   78 +++
 arch/powerpc/sysdev/bestcomm/bcom_fec_tx_task.c |   91 
 arch/powerpc/sysdev/bestcomm/fec.c  |  270 +++
 arch/powerpc/sysdev/bestcomm/fec.h  |   48 
 6 files changed, 496 insertions(+), 0 deletions(-)
 create mode 100644 arch/powerpc/sysdev/bestcomm/bcom_fec_rx_task.c
 create mode 100644 arch/powerpc/sysdev/bestcomm/bcom_fec_tx_task.c
 create mode 100644 arch/powerpc/sysdev/bestcomm/fec.c
 create mode 100644 arch/powerpc/sysdev/bestcomm/fec.h

diff --git a/arch/powerpc/sysdev/bestcomm/Kconfig 
b/arch/powerpc/sysdev/bestcomm/Kconfig
index 9d087ce..831763b 100644
--- a/arch/powerpc/sysdev/bestcomm/Kconfig
+++ b/arch/powerpc/sysdev/bestcomm/Kconfig
@@ -23,3 +23,10 @@ config PPC_BESTCOMM_ATA
help
  This option enables the support for the ATA task.
 
+config PPC_BESTCOMM_FEC
+   tristate "Bestcomm FEC tasks support"
+   depends on PPC_BESTCOMM
+   default n
+   help
+ This option enables the support for the FEC tasks.
+
diff --git a/arch/powerpc/sysdev/bestcomm/Makefile 
b/arch/powerpc/sysdev/bestcomm/Makefile
index b7a6a40..537d174 100644
--- a/arch/powerpc/sysdev/bestcomm/Makefile
+++ b/arch/powerpc/sysdev/bestcomm/Makefile
@@ -4,7 +4,9 @@
 
 bestcomm-core-objs := bestcomm.o sram.o
 bestcomm-ata-objs  := ata.o bcom_ata_task.o
+bestcomm-fec-objs  := fec.o bcom_fec_rx_task.o bcom_fec_tx_task.o
 
 obj-$(CONFIG_PPC_BESTCOMM) += bestcomm-core.o
 obj-$(CONFIG_PPC_BESTCOMM_ATA) += bestcomm-ata.o
+obj-$(CONFIG_PPC_BESTCOMM_FEC) += bestcomm-fec.o
  
diff --git a/arch/powerpc/sysdev/bestcomm/bcom_fec_rx_task.c 
b/arch/powerpc/sysdev/bestcomm/bcom_fec_rx_task.c
new file mode 100644
index 000..a1ad6a0
--- /dev/null
+++ b/arch/powerpc/sysdev/bestcomm/bcom_fec_rx_task.c
@@ -0,0 +1,78 @@
+/*
+ * Bestcomm FEC RX task microcode
+ *
+ * Copyright (c) 2004 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ * Automatically created based on 
BestCommAPI-2.2/code_dma/image_rtos1/dma_image.hex
+ * on Tue Mar 22 11:19:38 2005 GMT
+ */
+
+#include 
+
+/*
+ * The header consists of the following fields:
+ * u32 magic;
+ * u8  desc_size;
+ * u8  var_size;
+ * u8  inc_size;
+ * u8  first_var;
+ * u8  reserved[8];
+ *
+ * The size fields contain the number of 32-bit words.
+ */
+
+u32 bcom_fec_rx_task[] = {
+   /* header */
+   0x4243544b,
+   0x18060709,
+   0x,
+   0x,
+
+   /* Task descriptors */
+   0x808220e3, /* LCD: idx0 = var1, idx1 = var4; idx1 <= var3; idx0 += 
inc4, idx1 += inc3 */
+   0x10601010, /*   DRD1A: var4 = var2; FN=0 MORE init=3 WS=0 RS=0 */
+   0xb8800264, /*   LCD: idx2 = *idx1, idx3 = var0; idx2 < var9; idx2 += 
inc4, idx3 += inc4 */
+   0x10001308, /* DRD1A: var4 = idx1; FN=0 MORE init=0 WS=0 RS=0 */
+   0x60140002, /* DRD2A: EU0=0 EU1=0 EU2=0 EU3=2 EXT init=0 WS=2 RS=2 
*/
+   0x0cccfcca, /* DRD2B1: *idx3 = EU3(); EU3(*idx3,var10)  */
+   0x80004000, /*   LCDEXT: idx2 = 0x; ; */
+   0xb8c58029, /*   LCD: idx3 = *(idx1 + var0015); idx3 once var0; 
idx3 += inc5 */
+   0x6002, /* DRD2A: EU0=0 EU1=0 EU2=0 EU3=2 EXT init=0 WS=0 RS=0 
*/
+   0x088cf8cc, /* DRD2B1: idx2 = EU3(); EU3(idx3,var12)  */
+   0x991982f2, /*   LCD: idx2 = idx2, idx3 = idx3; idx2 > var11; idx2 += 
inc6, idx3 += inc2 */
+   0x006acf80, /* DRD1A: *idx3 = *idx0; FN=0 init=3 WS=1 RS=1 */
+   0x80004000, /*   LCDEXT: idx2 = 0x; ; */
+   0x802d, /*   LCD: idx3 = idx3; idx3 once var0; idx3 += inc5 */
+   0x7002, /* DRD2A: EU0=0 EU1=0 EU2=0 EU3=2 EXT MORE init=0 WS=0 
RS=0 */
+   0x034cfc4e, /* DRD2B1: var13 = EU3(); EU3(*idx1,var14)  */
+   0x8868, /* DRD1A: idx2 = var13; FN=0 init=0 WS=0 RS=0 */
+   0x99198341, /*   LCD: idx2 = idx2, idx3 = idx3; idx2 > var13; idx2 += 
inc0, idx3 += inc1 */
+   0x007ecf80, /* DRD1A: *idx3 = *idx0; FN=0 init=3 WS=3 RS=3 */
+   0x99198272, /*   LCD: idx2 = idx2, idx3 = idx3; idx2 > var9; idx2 += 
inc6, idx3 += inc2 */
+   0x046acf80, /* DRD1A: *idx3 = *idx0; FN=0 INT init=3 WS=1 RS=1 */
+   0x9819002d, /*   LCD: idx2 = idx0; idx2 once var0; idx2 += inc5 */
+   0x0060c790, /* DRD1A: *idx1 = *idx2; FN=0 init=3 WS=0 RS=0 */
+   0x01f8, /*   NOP */
+
+   /* VAR[9]-VAR[14] 

[PATCH 4/7] powerpc: BestComm core support for Freescale MPC5200

2007-09-16 Thread Sylvain Munaut
This patch adds support for the core of the BestComm API
for the Freescale MPC5200(b). The BestComm engine is a
microcode-controlled / tasks-based DMA used by several
of the onchip devices.

Setting up the tasks / memory allocation and all common
low level functions are handled by this patch.
The specifics details of each tasks and their microcode
are split-out in separate patches.

This is not the official API, but a much cleaner one.
(hopefully)

Signed-off-by: Sylvain Munaut <[EMAIL PROTECTED]>
---
 arch/powerpc/platforms/Kconfig   |2 +
 arch/powerpc/sysdev/Makefile |1 +
 arch/powerpc/sysdev/bestcomm/Kconfig |   18 +
 arch/powerpc/sysdev/bestcomm/Makefile|8 +
 arch/powerpc/sysdev/bestcomm/bestcomm.c  |  657 ++
 arch/powerpc/sysdev/bestcomm/bestcomm.h  |  136 ++
 arch/powerpc/sysdev/bestcomm/bestcomm_priv.h |  325 +
 arch/powerpc/sysdev/bestcomm/sram.c  |  177 +++
 arch/powerpc/sysdev/bestcomm/sram.h  |   54 +++
 9 files changed, 1378 insertions(+), 0 deletions(-)
 create mode 100644 arch/powerpc/sysdev/bestcomm/Kconfig
 create mode 100644 arch/powerpc/sysdev/bestcomm/Makefile
 create mode 100644 arch/powerpc/sysdev/bestcomm/bestcomm.c
 create mode 100644 arch/powerpc/sysdev/bestcomm/bestcomm.h
 create mode 100644 arch/powerpc/sysdev/bestcomm/bestcomm_priv.h
 create mode 100644 arch/powerpc/sysdev/bestcomm/sram.c
 create mode 100644 arch/powerpc/sysdev/bestcomm/sram.h

diff --git a/arch/powerpc/platforms/Kconfig b/arch/powerpc/platforms/Kconfig
index 9189ba5..99d48be 100644
--- a/arch/powerpc/platforms/Kconfig
+++ b/arch/powerpc/platforms/Kconfig
@@ -293,4 +293,6 @@ config FSL_ULI1575
  Freescale reference boards. The boards all use the ULI in pretty
  much the same way.
 
+source "arch/powerpc/sysdev/bestcomm/Kconfig"
+
 endmenu
diff --git a/arch/powerpc/sysdev/Makefile b/arch/powerpc/sysdev/Makefile
index 08ce31e..0c8a29d 100644
--- a/arch/powerpc/sysdev/Makefile
+++ b/arch/powerpc/sysdev/Makefile
@@ -15,6 +15,7 @@ obj-$(CONFIG_FSL_SOC) += fsl_soc.o
 obj-$(CONFIG_FSL_PCI)  += fsl_pci.o
 obj-$(CONFIG_TSI108_BRIDGE)+= tsi108_pci.o tsi108_dev.o
 obj-$(CONFIG_QUICC_ENGINE) += qe_lib/
+obj-$(CONFIG_PPC_BESTCOMM) += bestcomm/
 mv64x60-$(CONFIG_PCI)  += mv64x60_pci.o
 obj-$(CONFIG_MV64X60)  += $(mv64x60-y) mv64x60_pic.o mv64x60_dev.o
 obj-$(CONFIG_RTC_DRV_CMOS) += rtc_cmos_setup.o
diff --git a/arch/powerpc/sysdev/bestcomm/Kconfig 
b/arch/powerpc/sysdev/bestcomm/Kconfig
new file mode 100644
index 000..3366e24
--- /dev/null
+++ b/arch/powerpc/sysdev/bestcomm/Kconfig
@@ -0,0 +1,18 @@
+#
+# Kconfig options for Bestcomm
+#
+
+config PPC_BESTCOMM
+   tristate "Bestcomm DMA engine support"
+   depends on PPC_MPC52xx
+   default n
+   select PPC_LIB_RHEAP
+   help
+ BestComm is the name of the communication coprocessor found
+ on the Freescale MPC5200 family of processor. It's usage is
+ optionnal for some drivers (like ATA), but required for
+ others (like FEC).
+
+ If you want to use drivers that require DMA operations,
+ answer Y or M. Otherwise say N.
+
diff --git a/arch/powerpc/sysdev/bestcomm/Makefile 
b/arch/powerpc/sysdev/bestcomm/Makefile
new file mode 100644
index 000..a24aa06
--- /dev/null
+++ b/arch/powerpc/sysdev/bestcomm/Makefile
@@ -0,0 +1,8 @@
+#
+# Makefile for BestComm & co
+#
+
+bestcomm-core-objs := bestcomm.o sram.o
+
+obj-$(CONFIG_PPC_BESTCOMM) += bestcomm-core.o
+ 
diff --git a/arch/powerpc/sysdev/bestcomm/bestcomm.c 
b/arch/powerpc/sysdev/bestcomm/bestcomm.c
new file mode 100644
index 000..10fb476
--- /dev/null
+++ b/arch/powerpc/sysdev/bestcomm/bestcomm.c
@@ -0,0 +1,657 @@
+/*
+ * Driver for MPC52xx processor BestComm peripheral controller
+ *
+ *
+ * Copyright (C) 2006-2007 Sylvain Munaut <[EMAIL PROTECTED]>
+ * Copyright (C) 2005  Varma Electronics Oy,
+ * ( by Andrey Volkov <[EMAIL PROTECTED]> )
+ * Copyright (C) 2003-2004 MontaVista, Software, Inc.
+ * ( by Dale Farnsworth <[EMAIL PROTECTED]> )
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "sram.h"
+#include "bestcomm_priv.h"
+#include "bestcomm.h"
+
+#define DRIVER_NAME "bestcomm-core"
+
+
+struct bcom_engine *bcom_eng = NULL;
+EXPORT_SYMBOL_GPL(bcom_eng);   /* needed for inline functions */
+
+
+/*  */
+/* Public and private API   */
+/*  */
+
+/* Debug Du

[PATCH 5/7] powerpc: BestComm ATA task support

2007-09-16 Thread Sylvain Munaut
This is the microcode for the ATA task and the associated
support code.

The microcode itself comes directly from the offical
API (v2.2)

Signed-off-by: Sylvain Munaut <[EMAIL PROTECTED]>
---
 arch/powerpc/sysdev/bestcomm/Kconfig |7 +
 arch/powerpc/sysdev/bestcomm/Makefile|2 +
 arch/powerpc/sysdev/bestcomm/ata.c   |  154 ++
 arch/powerpc/sysdev/bestcomm/ata.h   |   37 ++
 arch/powerpc/sysdev/bestcomm/bcom_ata_task.c |   67 +++
 5 files changed, 267 insertions(+), 0 deletions(-)
 create mode 100644 arch/powerpc/sysdev/bestcomm/ata.c
 create mode 100644 arch/powerpc/sysdev/bestcomm/ata.h
 create mode 100644 arch/powerpc/sysdev/bestcomm/bcom_ata_task.c

diff --git a/arch/powerpc/sysdev/bestcomm/Kconfig 
b/arch/powerpc/sysdev/bestcomm/Kconfig
index 3366e24..9d087ce 100644
--- a/arch/powerpc/sysdev/bestcomm/Kconfig
+++ b/arch/powerpc/sysdev/bestcomm/Kconfig
@@ -16,3 +16,10 @@ config PPC_BESTCOMM
  If you want to use drivers that require DMA operations,
  answer Y or M. Otherwise say N.
 
+config PPC_BESTCOMM_ATA
+   tristate "Bestcomm ATA task support"
+   depends on PPC_BESTCOMM
+   default n
+   help
+ This option enables the support for the ATA task.
+
diff --git a/arch/powerpc/sysdev/bestcomm/Makefile 
b/arch/powerpc/sysdev/bestcomm/Makefile
index a24aa06..b7a6a40 100644
--- a/arch/powerpc/sysdev/bestcomm/Makefile
+++ b/arch/powerpc/sysdev/bestcomm/Makefile
@@ -3,6 +3,8 @@
 #
 
 bestcomm-core-objs := bestcomm.o sram.o
+bestcomm-ata-objs  := ata.o bcom_ata_task.o
 
 obj-$(CONFIG_PPC_BESTCOMM) += bestcomm-core.o
+obj-$(CONFIG_PPC_BESTCOMM_ATA) += bestcomm-ata.o
  
diff --git a/arch/powerpc/sysdev/bestcomm/ata.c 
b/arch/powerpc/sysdev/bestcomm/ata.c
new file mode 100644
index 000..4b213b1
--- /dev/null
+++ b/arch/powerpc/sysdev/bestcomm/ata.c
@@ -0,0 +1,154 @@
+/*
+ * Bestcomm ATA task driver
+ *
+ *
+ * Patterned after bestcomm/fec.c by Dale Farnsworth <[EMAIL PROTECTED]>
+ *   2003-2004 (c) MontaVista, Software, Inc.
+ *
+ * Copyright (C) 2006-2007 Sylvain Munaut <[EMAIL PROTECTED]>
+ * Copyright (C) 2006  Freescale - John Rigby
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include "bestcomm.h"
+#include "bestcomm_priv.h"
+#include "ata.h"
+
+
+/*  */
+/* Task image/var/inc   */
+/*  */
+
+/* ata task image */
+extern u32 bcom_ata_task[];
+
+/* ata task vars that need to be set before enabling the task */
+struct bcom_ata_var {
+   u32 enable; /* (u16*) address of task's control register */
+   u32 bd_base;/* (struct bcom_bd*) beginning of ring buffer */
+   u32 bd_last;/* (struct bcom_bd*) end of ring buffer */
+   u32 bd_start;   /* (struct bcom_bd*) current bd */
+   u32 buffer_size;/* size of receive buffer */
+};
+
+/* ata task incs that need to be set before enabling the task */
+struct bcom_ata_inc {
+   u16 pad0;
+   s16 incr_bytes;
+   u16 pad1;
+   s16 incr_dst;
+   u16 pad2;
+   s16 incr_src;
+};
+
+
+/*  */
+/* Task support code*/
+/*  */
+
+struct bcom_task *
+bcom_ata_init(int queue_len, int maxbufsize)
+{
+   struct bcom_task *tsk;
+   struct bcom_ata_var *var;
+   struct bcom_ata_inc *inc;
+
+   tsk = bcom_task_alloc(queue_len, sizeof(struct bcom_ata_bd), 0);
+   if (!tsk)
+   return NULL;
+
+   tsk->flags = BCOM_FLAGS_NONE;
+
+   bcom_ata_reset_bd(tsk);
+
+   var = (struct bcom_ata_var *) bcom_task_var(tsk->tasknum);
+   inc = (struct bcom_ata_inc *) bcom_task_inc(tsk->tasknum);
+
+   if (bcom_load_image(tsk->tasknum, bcom_ata_task)) {
+   bcom_task_release(tsk);
+   return NULL;
+   }
+
+   var->enable = bcom_eng->regs_base +
+   offsetof(struct mpc52xx_sdma, 
tcr[tsk->tasknum]);
+   var->bd_base= tsk->bd_pa;
+   var->bd_last= tsk->bd_pa + ((tsk->num_bd-1) * tsk->bd_size);
+   var->bd_start   = tsk->bd_pa;
+   var->buffer_size = maxbufsize;
+
+   /* Configure some stuff */
+   bcom_set_task_pragma(tsk->tasknum, BCOM_ATA_PRAGMA);
+   bcom_set_task_auto_start(tsk->tasknum, tsk->tasknum);
+
+   out_8(&bcom_eng->regs->ipr[BCOM_INITIATOR_ATA_RX], BCOM_IPR_ATA_RX);
+   out_8(&b

[PATCH 3/7] powerpc/ppc32: Update mpc52xx_psc structure with B revision changes

2007-09-16 Thread Sylvain Munaut
On the mpc5200b the ccr register is 32 bits wide while on the
mpc5200 it's only 16 bits. It's up to the driver to use the
correct format depending on the chip it's running on.

The 5200b also offers some more registers & status in AC97
mode. Again, if not running on a 5200b the driver should not
use those.

Signed-off-by: Sylvain Munaut <[EMAIL PROTECTED]>
---
 include/asm-ppc/mpc52xx_psc.h |   10 --
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/include/asm-ppc/mpc52xx_psc.h b/include/asm-ppc/mpc52xx_psc.h
index 9d850b2..c82b8d4 100644
--- a/include/asm-ppc/mpc52xx_psc.h
+++ b/include/asm-ppc/mpc52xx_psc.h
@@ -28,6 +28,10 @@
 #define MPC52xx_PSC_MAXNUM 6
 
 /* Programmable Serial Controller (PSC) status register bits */
+#define MPC52xx_PSC_SR_UNEX_RX 0x0001
+#define MPC52xx_PSC_SR_DATA_VAL0x0002
+#define MPC52xx_PSC_SR_DATA_OVR0x0004
+#define MPC52xx_PSC_SR_CMDSEND 0x0008
 #define MPC52xx_PSC_SR_CDE 0x0080
 #define MPC52xx_PSC_SR_RXRDY   0x0100
 #define MPC52xx_PSC_SR_RXFULL  0x0200
@@ -132,8 +136,10 @@ struct mpc52xx_psc {
u8  reserved5[3];
u8  ctlr;   /* PSC + 0x1c */
u8  reserved6[3];
-   u16 ccr;/* PSC + 0x20 */
-   u8  reserved7[14];
+   u32 ccr;/* PSC + 0x20 */
+   u32 ac97_slots; /* PSC + 0x24 */
+   u32 ac97_cmd;   /* PSC + 0x28 */
+   u32 ac97_data;  /* PSC + 0x2c */
u8  ivr;/* PSC + 0x30 */
u8  reserved8[3];
u8  ip; /* PSC + 0x34 */
-- 
1.5.3
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 2/7] powerpc: Changes the config mechanism for rheap

2007-09-16 Thread Sylvain Munaut
Instead of having in the makefile all the option that
requires rheap, we define a configuration symbol
and when needed we make sure it's selected.

Signed-off-by: Sylvain Munaut <[EMAIL PROTECTED]>
---
 arch/powerpc/Kconfig   |2 ++
 arch/powerpc/lib/Kconfig   |3 +++
 arch/powerpc/lib/Makefile  |5 +
 arch/powerpc/platforms/Kconfig |2 ++
 arch/powerpc/platforms/Kconfig.cputype |1 +
 5 files changed, 9 insertions(+), 4 deletions(-)
 create mode 100644 arch/powerpc/lib/Kconfig

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 00099ef..76063b9 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -634,6 +634,8 @@ source "fs/Kconfig"
 
 source "arch/powerpc/sysdev/qe_lib/Kconfig"
 
+source "arch/powerpc/lib/Kconfig"
+
 source "lib/Kconfig"
 
 menu "Instrumentation Support"
diff --git a/arch/powerpc/lib/Kconfig b/arch/powerpc/lib/Kconfig
new file mode 100644
index 000..f383ad4
--- /dev/null
+++ b/arch/powerpc/lib/Kconfig
@@ -0,0 +1,3 @@
+config PPC_LIB_RHEAP
+   bool
+   default n
diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
index 0a486d4..f75c2a1 100644
--- a/arch/powerpc/lib/Makefile
+++ b/arch/powerpc/lib/Makefile
@@ -13,7 +13,6 @@ endif
 
 obj-$(CONFIG_PPC64)+= checksum_64.o copypage_64.o copyuser_64.o \
   memcpy_64.o usercopy_64.o mem_64.o string.o
-obj-$(CONFIG_QUICC_ENGINE) += rheap.o
 obj-$(CONFIG_XMON) += sstep.o
 obj-$(CONFIG_KPROBES)  += sstep.o
 obj-$(CONFIG_NOT_COHERENT_CACHE)   += dma-noncoherent.o
@@ -22,6 +21,4 @@ ifeq ($(CONFIG_PPC64),y)
 obj-$(CONFIG_SMP)  += locks.o
 endif
 
-# Temporary hack until we have migrated to asm-powerpc
-obj-$(CONFIG_8xx)  += rheap.o
-obj-$(CONFIG_CPM2) += rheap.o
+obj-$(CONFIG_PPC_LIB_RHEAP) += rheap.o
diff --git a/arch/powerpc/platforms/Kconfig b/arch/powerpc/platforms/Kconfig
index 19d4628..9189ba5 100644
--- a/arch/powerpc/platforms/Kconfig
+++ b/arch/powerpc/platforms/Kconfig
@@ -257,6 +257,7 @@ config TAU_AVERAGE
 
 config QUICC_ENGINE
bool
+   select PPC_LIB_RHEAP
help
  The QUICC Engine (QE) is a new generation of communications
  coprocessors on Freescale embedded CPUs (akin to CPM in older chips).
@@ -266,6 +267,7 @@ config QUICC_ENGINE
 config CPM2
bool
default n
+   select PPC_LIB_RHEAP
help
  The CPM2 (Communications Processor Module) is a coprocessor on
  embedded CPUs made by Freescale.  Selecting this option means that
diff --git a/arch/powerpc/platforms/Kconfig.cputype 
b/arch/powerpc/platforms/Kconfig.cputype
index e4b2aee..29d8eff 100644
--- a/arch/powerpc/platforms/Kconfig.cputype
+++ b/arch/powerpc/platforms/Kconfig.cputype
@@ -36,6 +36,7 @@ config PPC_8xx
bool "Freescale 8xx"
select FSL_SOC
select 8xx
+   select PPC_LIB_RHEAP
 
 config 40x
bool "AMCC 40x"
-- 
1.5.3
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 1/7] powerpc: exports rheap symbol to modules

2007-09-16 Thread Sylvain Munaut
Theses can be useful in modules too. So we export them.

Signed-off-by: Sylvain Munaut <[EMAIL PROTECTED]>
---
 arch/powerpc/lib/rheap.c |   15 +++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/lib/rheap.c b/arch/powerpc/lib/rheap.c
index ada5b42..22c3b4f 100644
--- a/arch/powerpc/lib/rheap.c
+++ b/arch/powerpc/lib/rheap.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -275,6 +276,7 @@ rh_info_t *rh_create(unsigned int alignment)
 
return info;
 }
+EXPORT_SYMBOL_GPL(rh_create);
 
 /*
  * Destroy a dynamically created remote heap.  Deallocate only if the areas
@@ -288,6 +290,7 @@ void rh_destroy(rh_info_t * info)
if ((info->flags & RHIF_STATIC_INFO) == 0)
kfree(info);
 }
+EXPORT_SYMBOL_GPL(rh_destroy);
 
 /*
  * Initialize in place a remote heap info block.  This is needed to support
@@ -320,6 +323,7 @@ void rh_init(rh_info_t * info, unsigned int alignment, int 
max_blocks,
for (i = 0, blk = block; i < max_blocks; i++, blk++)
list_add(&blk->list, &info->empty_list);
 }
+EXPORT_SYMBOL_GPL(rh_init);
 
 /* Attach a free memory region, coalesces regions if adjuscent */
 int rh_attach_region(rh_info_t * info, unsigned long start, int size)
@@ -360,6 +364,7 @@ int rh_attach_region(rh_info_t * info, unsigned long start, 
int size)
 
return 0;
 }
+EXPORT_SYMBOL_GPL(rh_attach_region);
 
 /* Detatch given address range, splits free block if needed. */
 unsigned long rh_detach_region(rh_info_t * info, unsigned long start, int size)
@@ -428,6 +433,7 @@ unsigned long rh_detach_region(rh_info_t * info, unsigned 
long start, int size)
 
return s;
 }
+EXPORT_SYMBOL_GPL(rh_detach_region);
 
 /* Allocate a block of memory at the specified alignment.  The value returned
  * is an offset into the buffer initialized by rh_init(), or a negative number
@@ -502,6 +508,7 @@ unsigned long rh_alloc_align(rh_info_t * info, int size, 
int alignment, const ch
 
return start;
 }
+EXPORT_SYMBOL_GPL(rh_alloc_align);
 
 /* Allocate a block of memory at the default alignment.  The value returned is
  * an offset into the buffer initialized by rh_init(), or a negative number if
@@ -511,6 +518,7 @@ unsigned long rh_alloc(rh_info_t * info, int size, const 
char *owner)
 {
return rh_alloc_align(info, size, info->alignment, owner);
 }
+EXPORT_SYMBOL_GPL(rh_alloc);
 
 /* Allocate a block of memory at the given offset, rounded up to the default
  * alignment.  The value returned is an offset into the buffer initialized by
@@ -594,6 +602,7 @@ unsigned long rh_alloc_fixed(rh_info_t * info, unsigned 
long start, int size, co
 
return start;
 }
+EXPORT_SYMBOL_GPL(rh_alloc_fixed);
 
 /* Deallocate the memory previously allocated by one of the rh_alloc functions.
  * The return value is the size of the deallocated block, or a negative number
@@ -626,6 +635,7 @@ int rh_free(rh_info_t * info, unsigned long start)
 
return size;
 }
+EXPORT_SYMBOL_GPL(rh_free);
 
 int rh_get_stats(rh_info_t * info, int what, int max_stats, rh_stats_t * stats)
 {
@@ -663,6 +673,7 @@ int rh_get_stats(rh_info_t * info, int what, int max_stats, 
rh_stats_t * stats)
 
return nr;
 }
+EXPORT_SYMBOL_GPL(rh_get_stats);
 
 int rh_set_owner(rh_info_t * info, unsigned long start, const char *owner)
 {
@@ -687,6 +698,7 @@ int rh_set_owner(rh_info_t * info, unsigned long start, 
const char *owner)
 
return size;
 }
+EXPORT_SYMBOL_GPL(rh_set_owner);
 
 void rh_dump(rh_info_t * info)
 {
@@ -722,6 +734,7 @@ void rh_dump(rh_info_t * info)
   st[i].size, st[i].owner != NULL ? st[i].owner : "");
printk(KERN_INFO "\n");
 }
+EXPORT_SYMBOL_GPL(rh_dump);
 
 void rh_dump_blk(rh_info_t * info, rh_block_t * blk)
 {
@@ -729,3 +742,5 @@ void rh_dump_blk(rh_info_t * info, rh_block_t * blk)
   "blk @0x%p: 0x%lx-0x%lx (%u)\n",
   blk, blk->start, blk->start + blk->size, blk->size);
 }
+EXPORT_SYMBOL_GPL(rh_dump_blk);
+
-- 
1.5.3
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 0/7] MPC52xx Bestcomm submission for 2.6.24

2007-09-16 Thread Sylvain Munaut
Hello Paul, Hi everyone,

This series of patch is mainly the bestcomm support for
the mpc5200. It was posted a while ago and received some
comments. Theses are all addressed here (afaik).

The first few patch are more a preparation for what
follows. (rheap module support & extended fields in psc
structure).

The rest is the core support followed by each specific
microcode support. (Previous emails explained the stucture
better, I'm not gonna repeat it here)

This particular version has been tested on the EFIKA and
works fine. Previous versions have been tested on a lot
of different platforms by numerous people. (and since the
changes since last version are cosmetic ...).

This series _doesn_t_ include any driver that actually make
use of bestcomm support. Hopefully theses will come. I
think Domen Puncer sent a cleaned up driver for ethernet.


Sylvain


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


Re: [PATCH] i2c: devtree-aware iic support for PPC4xx

2007-09-16 Thread Stefan Roese
On Saturday 15 September 2007, Stephen Rothwell wrote:
> [Just some trivial things]

Thanks for the feedback. I'll change those things and resubmit.

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


Re: [PATCH] i2c: devtree-aware iic support for PPC4xx

2007-09-16 Thread Stefan Roese
On Saturday 15 September 2007, Vitaly Bordug wrote:
> > Where is dev->clkdiv initialized?
> >
> > My original version used iic_clkdiv() to calculate correct devider
> > based on OPB frequency. Did you even test this code?

Yes, I tested it successfully on the Sequoia eval board.

> heh, just my $0.02: the upper clearly shows one like missing, maybe during
> cleanup (since there is opb freq pulled in quote):
>
> dev->clckdiv = iic_clckdiv(*prop); or smth like that

Could be. Thanks for the hint. I'll take a look at it an resubmit.

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