LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] [POWERPC][RFC] MPC8360E-RDK: Device tree and board file
From: Vitaly Bordug @ 2007-12-17 20:55 UTC (permalink / raw)
  To: Scott Wood, David Gibson; +Cc: Stephen Rothwell, linuxppc-dev
In-Reply-To: <4766C471.6050703@freescale.com>

On Mon, 17 Dec 2007 12:48:17 -0600
Scott Wood wrote:

> Vitaly Bordug wrote:
> > On Mon, 17 Dec 2007 11:03:04 -0600 Scott Wood wrote:
> >>> These phy nodes have basically no information in them.  PHY nodes
> >>>  are optional -
> >> If they are truly optional, then several Linux drivers (including 
> >> ucc_geth, which this board uses) are broken, as they'll error out
> >> if there's no phy-handle (gianfar is even worse -- it looks like
> >> the fsl_soc code will crash in that case).  But what do you propose
> >> they do in the absence of a phy-handle?  Hope that probing only
> >> finds one phy?
> > 
> > up-to-date fixed phy patch solves it in gianfar and fs_enet case. it
> > is implied, that either there *are* phy nodes (and the code will
> > look up their reg and phandle) or there should be fixed-link
> > property in NIC node, that describes to what link stuff is really
> > connected.
> 
> There's a difference between the phy *node* being optional and phy 
> *usage* being optional. :-)
> 
And I am telling exactly that :) [added David to the loop since it was his issue].

currently phy nodes are required by the drivers (referring phy-handle), and I'd tell it looks pretty
settled. We got rid of "pretend" phy nodes, but I don't think it makes sense to
change the things for this particular board, especially since there is no example,
how  to do that in correct way.

Addition of compatible prop may be useful though, at least one may just look into dts to memorize
what type of phys board has..


-- 
Sincerely, Vitaly

^ permalink raw reply

* Re: [PATCH] drivers/net/: Spelling fixes
From: Stefano Brivio @ 2007-12-17 20:56 UTC (permalink / raw)
  To: Joe Perches
  Cc: Manish, Jay, David Gibson, orinoco-devel, Roskin, Corey Thomas,
	linuxppc-dev, Daniel, Paul Mackerras, Peter De Shrijver, Pavel,
	Rastapur Santosh, John, bonding-devel, Andy Gospodarek, Eugene,
	Amit S. Kale, ipw2100-devel, ipw3945-devel, libertas-dev,
	Dan Williams, Jesse Brandeburg, Lachwani, Jean Tourrilhes, Zhu,
	Jeff Kirsher, Arnaldo Carvalho de Melo, Francois Romieu, Drake,
	Li Yang, Jeff Garzik, Jeb Cramer, Chad Tindel, Dale, Jay Cliburn,
	Samuel Ortiz, Sivakumar Subramani, Jesse Huang, Mike Phillips,
	rt2400-devel, Ulrich Kunitz, Jaroslav Kysela, Chris Snook,
	cbe-oss-dev, Alexander Indenbaum, Adam Fritzler, Auke Kok,
	Haavard Skinnemoen, tulip-users, linux-ppp, Ramkrishna Vepa,
	linux-wireless, linux-kernel, Sreenivasa Honnur, e1000-devel,
	Geoff, Ronciak, orinoco-users, Yi, atl1-devel, Ron Mercer,
	James Ketrenos, Andrew Morton, Sorbica Shieh, netdev,
	Larry Finger
In-Reply-To: <1197920439-5455-2-git-send-email-joe@perches.com>

On Mon, 17 Dec 2007 11:40:08 -0800
Joe Perches <joe@perches.com> wrote:

> diff --git a/drivers/net/ucc_geth_ethtool.c b/drivers/net/ucc_geth_ethtool.c
> index 9a9622c..f8d319b 100644
> --- a/drivers/net/ucc_geth_ethtool.c
> +++ b/drivers/net/ucc_geth_ethtool.c
> @@ -7,7 +7,7 @@
>   *
>   * Limitation: 
>   * Can only get/set setttings of the first queue.
                         ^^^


-- 
Ciao
Stefano

^ permalink raw reply

* Re: [PATCH] [NET][POWERPC] ucc_geth: really fix section mismatch
From: Jeff Garzik @ 2007-12-17 21:03 UTC (permalink / raw)
  To: Anton Vorontsov; +Cc: netdev, Li Yang, linuxppc-dev
In-Reply-To: <20071217115435.GA29857@localhost.localdomain>

Anton Vorontsov wrote:
> Commit ed7e63a51d46e835422d89c687b8a3e419a4212a has tried to fix
> section mismatch:
> 
> WARNING: vmlinux.o(.init.text+0x17278): Section mismatch: reference to
> .exit.text:uec_mdio_exit (between 'ucc_geth_init' and 'uec_mdio_init')
> 
> But that mismatch still happens.
> 
> This patch actually fixing section mismatch by removing __exit from
> the header file.
> 
> Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
> ---
>  drivers/net/ucc_geth_mii.h |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/net/ucc_geth_mii.h b/drivers/net/ucc_geth_mii.h
> index d834370..1e45b20 100644
> --- a/drivers/net/ucc_geth_mii.h
> +++ b/drivers/net/ucc_geth_mii.h
> @@ -96,5 +96,5 @@ enum enet_tbi_mii_reg {
>  int uec_mdio_read(struct mii_bus *bus, int mii_id, int regnum);
>  int uec_mdio_write(struct mii_bus *bus, int mii_id, int regnum, u16 value);
>  int __init uec_mdio_init(void);
> -void __exit uec_mdio_exit(void);

applied #upstream-fixes

^ permalink raw reply

* Re: [PATCH] drivers/net/: Spelling fixes
From: David Woodhouse @ 2007-12-17 21:15 UTC (permalink / raw)
  To: Joe Perches
  Cc: Pavel Roskin, David Gibson, orinoco-devel, Yi Zhu,
	Jaroslav Kysela, linuxppc-dev, Paul Mackerras, Peter De Shrijver,
	Rastapur Santosh, bonding-devel, Andy Gospodarek, Amit S. Kale,
	ipw2100-devel, atl1-devel, Chris Snook, libertas-dev,
	Dan Williams, Jesse Brandeburg, Manish Lachwani, Jean Tourrilhes,
	Jeff Kirsher, Arnaldo Carvalho de Melo, Francois Romieu,
	Daniel Drake, Li Yang, Jeff Garzik, Jeb Cramer, Chad Tindel,
	orinoco-users, Jay Cliburn, Samuel Ortiz, Sivakumar Subramani,
	Jesse Huang, Mike Phillips, rt2400-devel, Ulrich Kunitz,
	ipw3945-devel, cbe-oss-dev, Alexander Indenbaum, Adam Fritzler,
	Auke Kok, James Ketrenos, Stefano Brivio, Haavard Skinnemoen,
	tulip-users, netdev, Ramkrishna Vepa, linux-wireless,
	linux-kernel, Corey Thomas, e1000-devel, John Ronciak, linux-ppp,
	Ron Mercer, Sreenivasa Honnur, Andrew Morton, Sorbica Shieh,
	Larry Finger
In-Reply-To: <5703e57f925f31fc0eb38873bd7f10fc44f99cb4.1197918891.git.joe@perches.com>

On Mon, 2007-12-17 at 11:40 -0800, Joe Perches wrote:
>  drivers/net/wireless/libertas/cmd.c            |    4 ++--
>  drivers/net/wireless/libertas/scan.c           |    4 ++--

I will apply these to the libertas tree; please remove them from any
resend of this patch.

If we were using git properly, it wouldn't matter -- I could just let
the patch go in upstream and when it gets merged, it'll be fine. But for
some reason we don't use git for network driver development; we pretend
it's the 1990s and we deal with sets of patches instead. So having this
simple change applied in an upstream tree would cause lots of pain, as
far as I can tell.

-- 
dwmw2

^ permalink raw reply

* Re: 1st version of azfs
From: Bodo Eggert @ 2007-12-17 21:24 UTC (permalink / raw)
  To: Maxim Shchetynin, linuxppc-dev, linux-mm, linux-kernel, arnd
In-Reply-To: <9Btcy-1LS-23@gated-at.bofh.it>

Maxim Shchetynin <maxim@de.ibm.com> wrote:

> +config AZ_FS
> +            tristate "AZFS filesystem support"
> +            default m
                       ^
STRONG NACK, I hate digging in the menu tree and hunting for things I
don't need.

> +            help
> +              Non-buffered filesystem for block devices with a gendisk and
> +              with direct_access() method in gendisk->fops.
> +              AZFS does not buffer outgoing traffic and is doing no read
> ahead.
> +              AZFS uses block-size and sector-size provided by block
> device
> +              and gendisk's queue. Though mmap() method is available only
> if
> +              block-size equals to or is greater than system page size.

What is the benefit or intended use of this filesystem? Will your intended
user say "gendisk->fops->direct_access? I wanted to use it all my life"?

AZFZ seems to be an acronym. AirZound File System?
http://globetrotter.de/de/shop/detail.php?mod_nr=ex_35001&GTID=7c553060901a873c5bd29a1846ff39a3a32

^ permalink raw reply

* Re: [PATCH] drivers/net/: Spelling fixes
From: Joe Perches @ 2007-12-17 21:15 UTC (permalink / raw)
  To: Stefano Brivio
  Cc: Sivakumar Subramani, netdev, Ramkrishna Vepa, linux-kernel,
	linuxppc-dev, Sreenivasa Honnur, Rastapur Santosh, Andrew Morton,
	Li Yang, Jeff Garzik
In-Reply-To: <20071217215635.16fe17af@morte>

On Mon, 2007-12-17 at 21:56 +0100, Stefano Brivio wrote:
> On Mon, 17 Dec 2007 11:40:08 -0800
> Joe Perches <joe@perches.com> wrote:
> > diff --git a/drivers/net/ucc_geth_ethtool.c
> b/drivers/net/ucc_geth_ethtool.c
> > index 9a9622c..f8d319b 100644
> > --- a/drivers/net/ucc_geth_ethtool.c
> > +++ b/drivers/net/ucc_geth_ethtool.c
> > @@ -7,7 +7,7 @@
> >   *
> >   * Limitation: 
> >   * Can only get/set setttings of the first queue.
>                          ^^^

Good eyes...  Unrelated to what I changed too.
cheers, Joe

Signed-off-by: Joe Perches <joe@perches.com>
---
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index 121cb10..cdfb2b0 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -6823,8 +6823,8 @@ static void do_s2io_card_down(struct s2io_nic * sp, int do_io)
 	while(do_io) {
 		/* As per the HW requirement we need to replenish the
 		 * receive buffer to avoid the ring bump. Since there is
-		 * no intention of processing the Rx frame at this pointwe are
-		 * just settting the ownership bit of rxd in Each Rx
+		 * no intention of processing the Rx frame at this point we are
+		 * just setting the ownership bit of rxd in each Rx
 		 * ring to HW and set the appropriate buffer size
 		 * based on the ring mode
 		 */
diff --git a/drivers/net/ucc_geth_ethtool.c b/drivers/net/ucc_geth_ethtool.c
index f8d319b..3e50df8 100644
--- a/drivers/net/ucc_geth_ethtool.c
+++ b/drivers/net/ucc_geth_ethtool.c
@@ -6,7 +6,7 @@
  * Author: Li Yang <leoli@freescale.com>
  *
  * Limitation: 
- * Can only get/set setttings of the first queue.
+ * Can only get/set settings of the first queue.
  * Need to re-open the interface manually after changing some parameters.
  *
  * This program is free software; you can redistribute  it and/or modify it

^ permalink raw reply related

* Re: [PATCH] Fix build break caused by "ide: remove ideprobe_init()"
From: Olof Johansson @ 2007-12-17 22:56 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: linux-ide, akpm, linuxppc-dev
In-Reply-To: <200712172153.31427.bzolnier@gmail.com>

On Mon, Dec 17, 2007 at 09:53:31PM +0100, Bartlomiej Zolnierkiewicz wrote:
> 
> Hi,
> 
> applied but...
> 
> > ---
> > 
> > On Sun, Nov 18, 2007 at 11:25:09PM +0100, Bartlomiej Zolnierkiewicz wrote:
> > > 
> > > * Rename ide_device_add() to ide_device_add_all() and make it accept
> > >   'u8 idx[MAX_HWIFS]' instead of 'u8 idx[4]' as an argument.
> > > 
> > > * Add ide_device_add() wrapper for ide_device_add_all().
> > > 
> > > * Convert ide_generic_init() to use ide_device_add_all().
> > > 
> > > * Remove no longer needed ideprobe_init().
> > > 
> > > There should be no functionality changes caused by this patch.
> > 
> > This patch broke builds of powerpc holly_defconfig in -mm. It has
> > CONFIG_EMBEDDED=y, CONFIG_IDE=n but includes linux/ide.h:
>                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> ...could you also fix the root source of the problem so the similar issue
> won't re-appear in the future?
> 
> <linux/ide.h> is IDE subsystem specific in the same way that <linux/libata.h>
> is libata specific, <linux/ata.h> is the place to put subsystem independent
> defines, inlines and co.
> 
> There are some powerpc abusers of the above rule but they should at least cover
> references to <linux/ide.h> and IDE subsystem specific code with #ifdef/#endif
> CONFIG_BLK_DEV_IDE.
> 
> In arch/powerpc/platforms/embedded6xx/holly.c case it seems that <linux/ide.h>
> include is actually not needed and may be just removed?

Yep, that was my original simple fix to the problem, but when I looked
closer I wanted to get the include file fixed as well.

Turns out I never posted the powerpc patch :), I'll do so (and audit
other platforms for the same).


Thanks,

-Olof

^ permalink raw reply

* [PATCH] [POWERPC] holly.c: Remove unneccessary include of linux/ide.h
From: Olof Johansson @ 2007-12-17 23:04 UTC (permalink / raw)
  To: galak; +Cc: linuxppc-dev

There's nothing in holly.c that needs linux/ide.h, just remove it from
the list of includes.

Signed-off-by: Olof Johansson <olof@lixom.net>


Index: mm/arch/powerpc/platforms/embedded6xx/holly.c
===================================================================
--- mm.orig/arch/powerpc/platforms/embedded6xx/holly.c	2007-12-14 02:41:24.000000000 -0600
+++ mm/arch/powerpc/platforms/embedded6xx/holly.c	2007-12-14 02:42:11.000000000 -0600
@@ -20,7 +20,6 @@
 #include <linux/console.h>
 #include <linux/delay.h>
 #include <linux/irq.h>
-#include <linux/ide.h>
 #include <linux/seq_file.h>
 #include <linux/root_dev.h>
 #include <linux/serial.h>

^ permalink raw reply

* Re: [PATCH/RFC] [POWERPC] Add fixed-phy support for fs_enet
From: Jeff Garzik @ 2007-12-17 23:20 UTC (permalink / raw)
  To: Jochen Friedrich; +Cc: netdev, linux-kernel, linuxppc-dev
In-Reply-To: <47601027.2080104@scram.de>

Jochen Friedrich wrote:
> This patch adds support to use the fixed-link property
> of an ethernet node to fs_enet for the
> CONFIG_PPC_CPM_NEW_BINDING case.
> 
> Signed-off-by: Jochen Friedrich <jochen@scram.de>
> ---
>  drivers/net/fs_enet/fs_enet-main.c |    9 ++++++++-
>  1 files changed, 8 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
> index f2a4d39..8220c70 100644
> --- a/drivers/net/fs_enet/fs_enet-main.c
> +++ b/drivers/net/fs_enet/fs_enet-main.c
> @@ -1174,8 +1174,15 @@ static int __devinit find_phy(struct device_node *np,
>  	struct device_node *phynode, *mdionode;
>  	struct resource res;
>  	int ret = 0, len;
> +	const u32 *data;
> +
> +	data  = of_get_property(np, "fixed-link", NULL);
> +	if (data) {
> +		snprintf(fpi->bus_id, 16, PHY_ID_FMT, 0, *data);
> +		return 0;
> +	}
> 
> -	const u32 *data = of_get_property(np, "phy-handle", &len);
> +	data = of_get_property(np, "phy-handle", &len);
>  	if (!data || len != 4)

ACK, pass this through paulus?

^ permalink raw reply

* Re: [PATCH] [POWERPC] pasemi: export pasemi_dma_init()
From: Jeff Garzik @ 2007-12-17 23:24 UTC (permalink / raw)
  To: Olof Johansson; +Cc: linuxppc-dev
In-Reply-To: <20071214080655.GA27284@lixom.net>

Olof Johansson wrote:
> Forgot to export this one. Needed when pasemi_mac is compiled as a module.
> 
> Signed-off-by: Olof Johansson <olof@lixom.net>
> 
> ---
> 
> Jeff, since the dma_lib stuff went up through netdev-2.6, please apply and
> feed this one up with the rest.
> 
> 
> Thanks,
> 
> Olof
> 
> Index: 2.6.24/arch/powerpc/platforms/pasemi/dma_lib.c
> ===================================================================
> --- 2.6.24.orig/arch/powerpc/platforms/pasemi/dma_lib.c
> +++ 2.6.24/arch/powerpc/platforms/pasemi/dma_lib.c
> @@ -485,3 +485,4 @@ out:
>  	spin_unlock(&init_lock);
>  	return err;
>  }
> +EXPORT_SYMBOL(pasemi_dma_init);

For .24 (#upstream-fixes) or .25 (#upstream)?

	Jeff

^ permalink raw reply

* Re: [PATCH] [POWERPC] pasemi: export pasemi_dma_init()
From: Olof Johansson @ 2007-12-17 23:37 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: linuxppc-dev
In-Reply-To: <47670547.7000701@pobox.com>

On Mon, Dec 17, 2007 at 06:24:55PM -0500, Jeff Garzik wrote:
> > Index: 2.6.24/arch/powerpc/platforms/pasemi/dma_lib.c
> > ===================================================================
> > --- 2.6.24.orig/arch/powerpc/platforms/pasemi/dma_lib.c
> > +++ 2.6.24/arch/powerpc/platforms/pasemi/dma_lib.c
> > @@ -485,3 +485,4 @@ out:
> >  	spin_unlock(&init_lock);
> >  	return err;
> >  }
> > +EXPORT_SYMBOL(pasemi_dma_init);
> 
> For .24 (#upstream-fixes) or .25 (#upstream)?

.25, the code isn't there in .24.


Thanks,

Olof

^ permalink raw reply

* Re: [PATCH] [POWERPC] holly.c: Remove unneccessary include of linux/ide.h
From: Josh Boyer @ 2007-12-17 23:54 UTC (permalink / raw)
  To: Olof Johansson; +Cc: linuxppc-dev
In-Reply-To: <20071217230434.GB22779@lixom.net>

On Mon, 17 Dec 2007 17:04:34 -0600
Olof Johansson <olof@lixom.net> wrote:

> There's nothing in holly.c that needs linux/ide.h, just remove it from
> the list of includes.
> 
> Signed-off-by: Olof Johansson <olof@lixom.net>
Acked-by: Josh Boyer <jwboyer@linux.vnet.ibm.com>

josh

^ permalink raw reply

* RE: [PATCH 7/7] [POWERPC] Xilinx: Update booting-without-of.
From: Stephen Neuendorffer @ 2007-12-18  0:22 UTC (permalink / raw)
  To: Grant Likely; +Cc: linuxppc-dev, David Gibson, simekm2
In-Reply-To: <fa686aa40712170719o29da3caew43d65225feea9ba@mail.gmail.com>


I've updated the generator based on the below feedback.  I'll also send
around the updated patch for this section briefly.  Comments below.

> -----Original Message-----
> From: glikely@secretlab.ca [mailto:glikely@secretlab.ca] On Behalf Of
> Grant Likely
> Sent: Monday, December 17, 2007 7:20 AM
> To: Stephen Neuendorffer
> Cc: simekm2@fel.cvut.cz; jwilliams@itee.uq.edu.au; linuxppc-
> dev@ozlabs.org; David Gibson
> Subject: Re: [PATCH 7/7] [POWERPC] Xilinx: Update booting-without-of.
>=20
> > -       (name)@(base-address) {
> > +       (name): (ip-core-name)@(base-address) {
>=20
> (name): (generic-name)@(base-address) {

In most cases it now does this.  In the default case for ip which is not
recognized, it falls back to the ip-core-name.

> > -       opb_ps2_dual_ref_0@a9000000 {
> > +       opb_ps2_dual_ref_0: opb-ps2-dual-ref@a9000000 {
> > +               #address-cells =3D <1>;
> > +               #size-cells =3D <1>;
> > +               compatible =3D "xlnx,compound";
> >                 ranges =3D <0 a9000000 2000>;
> >                 // If this device had extra parameters, then they
would
> >                 // go here.
> > -               ps2@0 {
> > +               opb-ps2-dual-ref@0 {
>=20
> According to the generic names recommendation, this should be either
> "keyboard@0" or "mouse@0", but of course the two interfaces are
> identical and EDK doesn't have any information about how they are
> used.  Perhaps the node name should be: "ps2@0".  David, thoughts?

I don't think keyboard or mouse really makes sense here.  Went with ps2.

> > -       plb-v34-0 {
> > +       plb_v34 {
>=20
> Steve, when I wrote this I was lazy and I didn't add the bus address.
> However, if we don't have the base address I think we'll end up with
> name collisions (especially in the MPMC case).  So, based on generic
> names convention, this should probably simply be "plb@<baseaddr>".

I wondered at one point if this would be a problem... in any event, you
now get the baseaddress.

> >                 #address-cells =3D <1>;
> >                 #size-cells =3D <1>;
> > +               compatible =3D "xlnx,plb-v34-1.02.a";
> >                 device_type =3D "ibm,plb";
> >                 ranges; // 1:1 translation
> >
> > -               plb-bram-if-cntrl-0@ffff0000 {
> > +               plb_bram_if_cntrl_0: plb-bram-if-cntrl@ffff0000 {
>=20
> Node name should probably just be "bram@ffff0000" here.

What actually gets generated is a memory node at the toplevel, which is
currently suppressed, since it appears that having disjoint memory
locations doesn't work.  If you have more than one 'real' memory
controller, such as an plb_emc connected to flash, then you currently
get the warning:

"Warning!: More than one memory found.  Note that most platforms don't
support non-contiguous memory maps!"

So, there is some divergence here, but I'm not too concerned about it
since the way that such memory might get used is still up for
discussion.

Also note that memory nodes which are not at the toplevel don't appear
to be detected.  Is this by intention or omission?

Obviously there is room for improvement here.  Having a some way to
leverage brams, in particular the dummy bram that you have to have at
high memory in order to get the ppc to boot would be nice!

Steve

^ permalink raw reply

* [PATCH 7/7] [POWERPC] [v2] Xilinx: Update booting-without-of.
From: Stephen Neuendorffer @ 2007-12-18  0:23 UTC (permalink / raw)
  To: simekm2, jwilliams, linuxppc-dev, david, grant.likely

This now better describes what the UBoot device tree generator
actually does.  In particular:

1) Nodes have a label derived from the device name, and a node name
derived from a generic version of the device type, e.g. 'ethernet',
'serial', etc.

2) Usage of compound nodes (representing more than one device in the
same IP) which actually works.  This requires having a valid
compatible node, and all the other things that a bus normally has.
I've chosen 'xlnx,compound' as the bus name to describe these compound
nodes.

In addition, I've clarified some of the language relating to how mhs
nodes should be represent in the device tree.

Signed-off-by: Stephen Neuendorffer <stephen.neuendorffer@xilinx.com>
---
 Documentation/powerpc/booting-without-of.txt |   56 +++++++++++++++-----------
 1 files changed, 33 insertions(+), 23 deletions(-)

diff --git a/Documentation/powerpc/booting-without-of.txt b/Documentation/powerpc/booting-without-of.txt
index e9a3cb1..e393e1d 100644
--- a/Documentation/powerpc/booting-without-of.txt
+++ b/Documentation/powerpc/booting-without-of.txt
@@ -2276,7 +2276,7 @@ platforms are moved over to use the flattened-device-tree model.
    properties of the device node.  In general, device nodes for IP-cores
    will take the following form:
 
-	(name)@(base-address) {
+	(name): (generic-name)@(base-address) {
 		compatible = "xlnx,(ip-core-name)-(HW_VER)"
 			     [, (list of compatible devices), ...];
 		reg = <(baseaddr) (size)>;
@@ -2286,6 +2286,9 @@ platforms are moved over to use the flattened-device-tree model.
 		xlnx,(parameter2) = <(int-value)>;
 	};
 
+	(generic-name):   an open firmware-style name that describes the 
+			generic class of device.  Preferably, this is one word, such
+			as 'serial' or 'ethernet'.
 	(ip-core-name):	the name of the ip block (given after the BEGIN
 			directive in system.mhs).  Should be in lowercase
 			and all underscores '_' converted to dashes '-'.
@@ -2294,9 +2297,9 @@ platforms are moved over to use the flattened-device-tree model.
 			dropped from the parameter name, the name is converted
 			to lowercase and all underscore '_' characters are
 			converted to dashes '-'.
-	(baseaddr):	the C_BASEADDR parameter.
+	(baseaddr):	the baseaddr parameter value (often named C_BASEADDR).
 	(HW_VER):	from the HW_VER parameter.
-	(size):		equals C_HIGHADDR - C_BASEADDR + 1
+	(size):		the address range size (often C_HIGHADDR - C_BASEADDR + 1).
 
    Typically, the compatible list will include the exact IP core version
    followed by an older IP core version which implements the same
@@ -2326,11 +2329,11 @@ platforms are moved over to use the flattened-device-tree model.
 
    becomes the following device tree node:
 
-	opb-uartlite-0@ec100000 {
+	opb_uartlite_0: serial@ec100000 {
 		device_type = "serial";
 		compatible = "xlnx,opb-uartlite-1.00.b";
 		reg = <ec100000 10000>;
-		interrupt-parent = <&opb-intc>;
+		interrupt-parent = <&opb_intc_0>;
 		interrupts = <1 0>; // got this from the opb_intc parameters
 		current-speed = <d#115200>;	// standard serial device prop
 		clock-frequency = <d#50000000>;	// standard serial device prop
@@ -2339,16 +2342,19 @@ platforms are moved over to use the flattened-device-tree model.
 		xlnx,use-parity = <0>;
 	};
 
-   Some IP cores actually implement 2 or more logical devices.  In this case,
-   the device should still describe the whole IP core with a single node
-   and add a child node for each logical device.  The ranges property can
-   be used to translate from parent IP-core to the registers of each device.
-   (Note: this makes the assumption that both logical devices have the same
-   bus binding.  If this is not true, then separate nodes should be used for
-   each logical device).  The 'cell-index' property can be used to enumerate
-   logical devices within an IP core.  For example, the following is the
-   system.mhs entry for the dual ps2 controller found on the ml403 reference
-   design.
+   Some IP cores actually implement 2 or more logical devices.  In
+   this case, the device should still describe the whole IP core with
+   a single node and add a child node for each logical device.  The
+   ranges property can be used to translate from parent IP-core to the
+   registers of each device.  In addition, the parent node should be
+   compatible with the bus type 'xlnx,compound', and should contain
+   #address-cells and #size-cells, as with any other bus.  (Note: this
+   makes the assumption that both logical devices have the same bus
+   binding.  If this is not true, then separate nodes should be used
+   for each logical device).  The 'cell-index' property can be used to
+   enumerate logical devices within an IP core.  For example, the
+   following is the system.mhs entry for the dual ps2 controller found
+   on the ml403 reference design.
 
 	BEGIN opb_ps2_dual_ref
 		PARAMETER INSTANCE = opb_ps2_dual_ref_0
@@ -2370,21 +2376,24 @@ platforms are moved over to use the flattened-device-tree model.
 
    It would result in the following device tree nodes:
 
-	opb_ps2_dual_ref_0@a9000000 {
+	opb_ps2_dual_ref_0: opb-ps2-dual-ref@a9000000 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "xlnx,compound";
 		ranges = <0 a9000000 2000>;
 		// If this device had extra parameters, then they would
 		// go here.
 		ps2@0 {
 			compatible = "xlnx,opb-ps2-dual-ref-1.00.a";
 			reg = <0 40>;
-			interrupt-parent = <&opb-intc>;
+			interrupt-parent = <&opb_intc_0>;
 			interrupts = <3 0>;
 			cell-index = <0>;
 		};
 		ps2@1000 {
 			compatible = "xlnx,opb-ps2-dual-ref-1.00.a";
 			reg = <1000 40>;
-			interrupt-parent = <&opb-intc>;
+			interrupt-parent = <&opb_intc_0>;
 			interrupts = <3 0>;
 			cell-index = <0>;
 		};
@@ -2447,17 +2456,18 @@ platforms are moved over to use the flattened-device-tree model.
 
    Gives this device tree (some properties removed for clarity):
 
-	plb-v34-0 {
+	plb@0 {
 		#address-cells = <1>;
 		#size-cells = <1>;
+		compatible = "xlnx,plb-v34-1.02.a";
 		device_type = "ibm,plb";
 		ranges; // 1:1 translation
 
-		plb-bram-if-cntrl-0@ffff0000 {
+		plb_bram_if_cntrl_0: bram@ffff0000 {
 			reg = <ffff0000 10000>;
 		}
 
-		opb-v20-0 {
+		opb@20000000 {
 			#address-cells = <1>;
 			#size-cells = <1>;
 			ranges = <20000000 20000000 20000000
@@ -2465,11 +2475,11 @@ platforms are moved over to use the flattened-device-tree model.
 				  80000000 80000000 40000000
 				  c0000000 c0000000 20000000>;
 
-			opb-uart16550-0@a0000000 {
+			opb_uart16550_0: serial@a0000000 {
 				reg = <a00000000 2000>;
 			};
 
-			opb-intc-0@d1000fc0 {
+			opb_intc_0: interrupt-controller@d1000fc0 {
 				reg = <d1000fc0 20>;
 			};
 		};
-- 
1.5.3.4

^ permalink raw reply related

* Re: [PATCH] Implement pci_set_dma_mask() in terms of the dma_ops
From: Benjamin Herrenschmidt @ 2007-12-18  0:40 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linuxppc-dev, Paul Mackerras
In-Reply-To: <20071217100248.GA8433@lst.de>


On Mon, 2007-12-17 at 11:02 +0100, Christoph Hellwig wrote:
> On Mon, Dec 17, 2007 at 05:35:53PM +1100, Michael Ellerman wrote:
> > To save adding a hook to the dma mapping ops, pci-set_consistent_dma_mask()
> > simply calls the dma_set_mask() hook and then copies the new mask into
> > dev.coherenet_dma_mask.
> 
> How is this supposed to work?  There are various devices around that
> want different mask for coherent vs streaming dma mappings, and we need
> to tell the iommu that we're setting it for either the former or the
> latter.

I don't think we ever supported that difference. Too broken HW for us.

We don't use coherent_dma_mask for anything at the moment on powerpc.

Ben.

^ permalink raw reply

* Re: [PATCH v2 1/3] 8xx: Analogue & Micro Adder875 board support.
From: David Gibson @ 2007-12-18  0:43 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev
In-Reply-To: <47669285.8010707@freescale.com>

On Mon, Dec 17, 2007 at 09:15:17AM -0600, Scott Wood wrote:
> David Gibson wrote:
> > On Wed, Dec 12, 2007 at 04:54:27PM -0600, Scott Wood wrote:
> >> Signed-off-by: Scott Wood <scottwood@freescale.com>
> > [snip]
> >> diff --git a/arch/powerpc/boot/dts/adder875-redboot.dts b/arch/powerpc/boot/dts/adder875-redboot.dts
> >> new file mode 100644
> >> index 0000000..4d28220
> >> --- /dev/null
> >> +++ b/arch/powerpc/boot/dts/adder875-redboot.dts
> > [snip]
> >> diff --git a/arch/powerpc/boot/dts/adder875-uboot.dts b/arch/powerpc/boot/dts/adder875-uboot.dts
> >> new file mode 100644
> >> index 0000000..33d198c
> >> --- /dev/null
> >> +++ b/arch/powerpc/boot/dts/adder875-uboot.dts
> > 
> > Having two different device trees for the different firmwares is
> > pretty yucky, and could be a pain in the bum for synchronization of
> > fixes.
> 
> Yes, that's why we need some sort of macro/template facility in dtc. :-)
> 
> > Can't you have a common tree, and just poke the places that
> > are differently configured by the two firmwares from the bootwrapper.
> 
> Enh.  That can get icky as well, and the bootwrapper isn't necessarily 
> even used for u-boot, and I'd rather not require it be used just for this.

So make the template in the u-boot form, and poke it as necessary from
the redboot wrapper.

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

^ permalink raw reply

* Re: [PATCH v2 2/3] mpc82xx: Embedded Planet EP8248E support
From: David Gibson @ 2007-12-18  0:53 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev
In-Reply-To: <47669335.4050405@freescale.com>

On Mon, Dec 17, 2007 at 09:18:13AM -0600, Scott Wood wrote:
> David Gibson wrote:
> > As I think I said about another tree, this mdio-under-bcsr arrangement
> > is pretty strange.  What's going on here.
> 
> As I answered then, it's just the way the hardware is.  I didn't design 
> it. :-P

I obviously missed when you answered this before, I was hoping for
some more detail.

I mean, obviously the MDIO bus is accessed via some of the
board-control registers.  What I'm questioning is whether it makes
sense to have a distinct node to represent the mdio bus, or whether
the phys should just hang straight of the bcsr node.

> >> +	soc@f0000000 {
> >> +		#address-cells = <1>;
> >> +		#size-cells = <1>;
> >> +		device_type = "soc";
> > 
> > Ditch the device_type.
> 
> No, it's used by the bootwrapper.  I'll get rid of it if you want to 
> write a find_node_by_compatible() function. :-)

Well, now that libfdt is merged, there is one :-p.

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

^ permalink raw reply

* Re: [PATCH] [POWERPC] pasemi: export pasemi_dma_init()
From: Jeff Garzik @ 2007-12-18  1:22 UTC (permalink / raw)
  To: Olof Johansson; +Cc: linuxppc-dev
In-Reply-To: <20071214080655.GA27284@lixom.net>

Olof Johansson wrote:
> Forgot to export this one. Needed when pasemi_mac is compiled as a module.
> 
> Signed-off-by: Olof Johansson <olof@lixom.net>
> 
> ---
> 
> Jeff, since the dma_lib stuff went up through netdev-2.6, please apply and
> feed this one up with the rest.
> 
> 
> Thanks,
> 
> Olof
> 
> Index: 2.6.24/arch/powerpc/platforms/pasemi/dma_lib.c
> ===================================================================
> --- 2.6.24.orig/arch/powerpc/platforms/pasemi/dma_lib.c
> +++ 2.6.24/arch/powerpc/platforms/pasemi/dma_lib.c
> @@ -485,3 +485,4 @@ out:
>  	spin_unlock(&init_lock);
>  	return err;
>  }
> +EXPORT_SYMBOL(pasemi_dma_init);

applied #upstream

^ permalink raw reply

* [PATCH 0/7] Series to add device tree naming to i2c
From: Jon Smirl @ 2007-12-18  2:39 UTC (permalink / raw)
  To: i2c, linuxppc-dev, linux-kernel

Another rework of the i2c for powerpc device tree patch. This version implements standard alias naming only on the powerpc platform and only for the device tree names. The old naming mechanism of i2c_client.name,driver_name is left in place and not changed for non-powerpc platforms. This patch is fully capable of dynamically loading the i2c modules. You can modprobe in the i2c-mpc driver and the i2c modules described in the device tree will be automatically loaded. Modules also work if compiled in.

The follow on patch to module-init-tools is also needed since the i2c subsystem has never implemented dynamic loading.

Since the i2c-mpc driver also supports the ppc architecture the i2c-mpc driver was copied to i2c-mpc-ppc before changes were made. The i2c-mpc-ppc driver should be deleted in six months when the rest of the ppc architecture is removed.

The following series implements standard linux module aliasing for i2c modules on arch=powerpc. It then converts the mpc i2c driver from being a platform driver to an open firmware one. I2C device names are picked up from the device tree. Module aliasing is used to translate from device tree names into to linux kernel names. Several i2c drivers are updated to use the new aliasing. 

--
Jon Smirl
jonsmirl@gmail.com 

^ permalink raw reply

* [PATCH 1/7] Copy mpc-i2c to preserve support for ARCH=ppc and allow changes on ARCH=powerpc
From: Jon Smirl @ 2007-12-18  2:39 UTC (permalink / raw)
  To: i2c, linuxppc-dev, linux-kernel
In-Reply-To: <20071218023913.8530.46661.stgit@terra.home>

Temporarily copy the mpc-i2c driver to continue support for the ppc architecture until it is removed in mid-2008. This file should be deleted as part of ppc's final removal.

Signed-off-by: Jon Smirl <jonsmirl@gmail.com>

Signed-off-by: Jon Smirl <jonsmirl@gmail.com>

Signed-off-by: Jon Smirl <jonsmirl@gmail.com>
---

 arch/ppc/configs/TQM8540_defconfig     |    2 
 arch/ppc/configs/TQM8541_defconfig     |    2 
 arch/ppc/configs/TQM8555_defconfig     |    2 
 arch/ppc/configs/TQM8560_defconfig     |    2 
 arch/ppc/configs/mpc834x_sys_defconfig |    2 
 arch/ppc/configs/mpc8540_ads_defconfig |    2 
 arch/ppc/configs/mpc8548_cds_defconfig |    2 
 arch/ppc/configs/mpc8555_cds_defconfig |    2 
 arch/ppc/configs/mpc8560_ads_defconfig |    2 
 drivers/i2c/busses/Kconfig             |   16 +
 drivers/i2c/busses/Makefile            |    1 
 drivers/i2c/busses/i2c-mpc-ppc.c       |  418 ++++++++++++++++++++++++++++++++
 12 files changed, 443 insertions(+), 10 deletions(-)
 create mode 100644 drivers/i2c/busses/i2c-mpc-ppc.c


diff --git a/arch/ppc/configs/TQM8540_defconfig b/arch/ppc/configs/TQM8540_defconfig
index f33f0e7..7098ed0 100644
--- a/arch/ppc/configs/TQM8540_defconfig
+++ b/arch/ppc/configs/TQM8540_defconfig
@@ -684,7 +684,7 @@ CONFIG_I2C_CHARDEV=y
 # CONFIG_I2C_I801 is not set
 # CONFIG_I2C_I810 is not set
 # CONFIG_I2C_PIIX4 is not set
-CONFIG_I2C_MPC=y
+CONFIG_I2C_MPC_PPC=y
 # CONFIG_I2C_NFORCE2 is not set
 # CONFIG_I2C_PARPORT_LIGHT is not set
 # CONFIG_I2C_PROSAVAGE is not set
diff --git a/arch/ppc/configs/TQM8541_defconfig b/arch/ppc/configs/TQM8541_defconfig
index e00cd62..2137d01 100644
--- a/arch/ppc/configs/TQM8541_defconfig
+++ b/arch/ppc/configs/TQM8541_defconfig
@@ -687,7 +687,7 @@ CONFIG_I2C_CHARDEV=y
 # CONFIG_I2C_I801 is not set
 # CONFIG_I2C_I810 is not set
 # CONFIG_I2C_PIIX4 is not set
-CONFIG_I2C_MPC=y
+CONFIG_I2C_MPC_PPC=y
 # CONFIG_I2C_MPC8260 is not set
 # CONFIG_I2C_NFORCE2 is not set
 # CONFIG_I2C_PARPORT_LIGHT is not set
diff --git a/arch/ppc/configs/TQM8555_defconfig b/arch/ppc/configs/TQM8555_defconfig
index 43a0d9d..f2317b6 100644
--- a/arch/ppc/configs/TQM8555_defconfig
+++ b/arch/ppc/configs/TQM8555_defconfig
@@ -687,7 +687,7 @@ CONFIG_I2C_CHARDEV=y
 # CONFIG_I2C_I801 is not set
 # CONFIG_I2C_I810 is not set
 # CONFIG_I2C_PIIX4 is not set
-CONFIG_I2C_MPC=y
+CONFIG_I2C_MPC_PPC=y
 # CONFIG_I2C_NFORCE2 is not set
 # CONFIG_I2C_PARPORT_LIGHT is not set
 # CONFIG_I2C_PROSAVAGE is not set
diff --git a/arch/ppc/configs/TQM8560_defconfig b/arch/ppc/configs/TQM8560_defconfig
index a814d17..6c19121 100644
--- a/arch/ppc/configs/TQM8560_defconfig
+++ b/arch/ppc/configs/TQM8560_defconfig
@@ -694,7 +694,7 @@ CONFIG_I2C_CHARDEV=y
 # CONFIG_I2C_I801 is not set
 # CONFIG_I2C_I810 is not set
 # CONFIG_I2C_PIIX4 is not set
-CONFIG_I2C_MPC=y
+CONFIG_I2C_MPC_PPC=y
 # CONFIG_I2C_MPC8260 is not set
 # CONFIG_I2C_NFORCE2 is not set
 # CONFIG_I2C_PARPORT_LIGHT is not set
diff --git a/arch/ppc/configs/mpc834x_sys_defconfig b/arch/ppc/configs/mpc834x_sys_defconfig
index d90c8a7..cd568d2 100644
--- a/arch/ppc/configs/mpc834x_sys_defconfig
+++ b/arch/ppc/configs/mpc834x_sys_defconfig
@@ -562,7 +562,7 @@ CONFIG_I2C_CHARDEV=y
 # CONFIG_I2C_I801 is not set
 # CONFIG_I2C_I810 is not set
 # CONFIG_I2C_PIIX4 is not set
-CONFIG_I2C_MPC=y
+CONFIG_I2C_MPC_PPC=y
 # CONFIG_I2C_NFORCE2 is not set
 # CONFIG_I2C_PARPORT_LIGHT is not set
 # CONFIG_I2C_PROSAVAGE is not set
diff --git a/arch/ppc/configs/mpc8540_ads_defconfig b/arch/ppc/configs/mpc8540_ads_defconfig
index bf676eb..5819835 100644
--- a/arch/ppc/configs/mpc8540_ads_defconfig
+++ b/arch/ppc/configs/mpc8540_ads_defconfig
@@ -452,7 +452,7 @@ CONFIG_I2C_CHARDEV=y
 # CONFIG_I2C_AMD8111 is not set
 # CONFIG_I2C_I801 is not set
 # CONFIG_I2C_I810 is not set
-CONFIG_I2C_MPC=y
+CONFIG_I2C_MPC_PPC=y
 # CONFIG_I2C_NFORCE2 is not set
 # CONFIG_I2C_PARPORT_LIGHT is not set
 # CONFIG_I2C_PIIX4 is not set
diff --git a/arch/ppc/configs/mpc8548_cds_defconfig b/arch/ppc/configs/mpc8548_cds_defconfig
index f36fc5d..e5b5071 100644
--- a/arch/ppc/configs/mpc8548_cds_defconfig
+++ b/arch/ppc/configs/mpc8548_cds_defconfig
@@ -413,7 +413,7 @@ CONFIG_I2C_CHARDEV=y
 #
 # I2C Hardware Bus support
 #
-CONFIG_I2C_MPC=y
+CONFIG_I2C_MPC_PPC=y
 # CONFIG_I2C_PARPORT_LIGHT is not set
 # CONFIG_I2C_PCA_ISA is not set
 
diff --git a/arch/ppc/configs/mpc8555_cds_defconfig b/arch/ppc/configs/mpc8555_cds_defconfig
index 4f1e320..08dbab0 100644
--- a/arch/ppc/configs/mpc8555_cds_defconfig
+++ b/arch/ppc/configs/mpc8555_cds_defconfig
@@ -518,7 +518,7 @@ CONFIG_I2C_CHARDEV=y
 # CONFIG_I2C_I801 is not set
 # CONFIG_I2C_I810 is not set
 # CONFIG_I2C_PIIX4 is not set
-CONFIG_I2C_MPC=y
+CONFIG_I2C_MPC_PPC=y
 # CONFIG_I2C_NFORCE2 is not set
 # CONFIG_I2C_PARPORT_LIGHT is not set
 # CONFIG_I2C_PROSAVAGE is not set
diff --git a/arch/ppc/configs/mpc8560_ads_defconfig b/arch/ppc/configs/mpc8560_ads_defconfig
index f12d48f..0e0080b 100644
--- a/arch/ppc/configs/mpc8560_ads_defconfig
+++ b/arch/ppc/configs/mpc8560_ads_defconfig
@@ -489,7 +489,7 @@ CONFIG_I2C_CHARDEV=y
 # CONFIG_I2C_I801 is not set
 # CONFIG_I2C_I810 is not set
 # CONFIG_I2C_PIIX4 is not set
-CONFIG_I2C_MPC=y
+CONFIG_I2C_MPC_PPC=y
 # CONFIG_I2C_NFORCE2 is not set
 # CONFIG_I2C_PARPORT_LIGHT is not set
 # CONFIG_I2C_PROSAVAGE is not set
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index c466c6c..c5ad557 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -301,7 +301,7 @@ config I2C_POWERMAC
 
 config I2C_MPC
 	tristate "MPC107/824x/85xx/52xx/86xx"
-	depends on PPC32
+	depends on PPC32 && PPC_MERGE
 	help
 	  If you say yes to this option, support will be included for the
 	  built-in I2C interface on the MPC107/Tsi107/MPC8240/MPC8245 and
@@ -311,6 +311,20 @@ config I2C_MPC
 	  This driver can also be built as a module.  If so, the module
 	  will be called i2c-mpc.
 
+config I2C_MPC_PPC
+	tristate "MPC107/824x/85xx/52xx/86xx"
+	depends on PPC32 && !PPC_MERGE
+	help
+	  If you say yes to this option, support will be included for the
+	  built-in I2C interface on the MPC107/Tsi107/MPC8240/MPC8245 and
+	  MPC85xx/MPC8641 family processors. The driver may also work on 52xx
+	  family processors, though interrupts are known not to work.
+ 
+	  This version of the driver is scheduled for deletion with the PPC architecture.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called i2c-mpc.
+
 config I2C_NFORCE2
 	tristate "Nvidia nForce2, nForce3 and nForce4"
 	depends on PCI
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 81d43c2..b7fe095 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -23,6 +23,7 @@ obj-$(CONFIG_I2C_IXP2000)	+= i2c-ixp2000.o
 obj-$(CONFIG_I2C_IXP4XX)	+= i2c-ixp4xx.o
 obj-$(CONFIG_I2C_POWERMAC)	+= i2c-powermac.o
 obj-$(CONFIG_I2C_MPC)		+= i2c-mpc.o
+obj-$(CONFIG_I2C_MPC_PPC)	+= i2c-mpc-ppc.o
 obj-$(CONFIG_I2C_MV64XXX)	+= i2c-mv64xxx.o
 obj-$(CONFIG_I2C_NFORCE2)	+= i2c-nforce2.o
 obj-$(CONFIG_I2C_OCORES)	+= i2c-ocores.o
diff --git a/drivers/i2c/busses/i2c-mpc-ppc.c b/drivers/i2c/busses/i2c-mpc-ppc.c
new file mode 100644
index 0000000..d8de4ac
--- /dev/null
+++ b/drivers/i2c/busses/i2c-mpc-ppc.c
@@ -0,0 +1,418 @@
+/*
+ * (C) Copyright 2003-2004
+ * Humboldt Solutions Ltd, adrian@humboldt.co.uk.
+
+ * This is a combined i2c adapter and algorithm driver for the
+ * MPC107/Tsi107 PowerPC northbridge and processors that include
+ * the same I2C unit (8240, 8245, 85xx).
+ *
+ * Release 0.8
+ *
+ * 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 <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/sched.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+
+#include <asm/io.h>
+#include <linux/fsl_devices.h>
+#include <linux/i2c.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+
+#define MPC_I2C_ADDR  0x00
+#define MPC_I2C_FDR 	0x04
+#define MPC_I2C_CR	0x08
+#define MPC_I2C_SR	0x0c
+#define MPC_I2C_DR	0x10
+#define MPC_I2C_DFSRR 0x14
+#define MPC_I2C_REGION 0x20
+
+#define CCR_MEN  0x80
+#define CCR_MIEN 0x40
+#define CCR_MSTA 0x20
+#define CCR_MTX  0x10
+#define CCR_TXAK 0x08
+#define CCR_RSTA 0x04
+
+#define CSR_MCF  0x80
+#define CSR_MAAS 0x40
+#define CSR_MBB  0x20
+#define CSR_MAL  0x10
+#define CSR_SRW  0x04
+#define CSR_MIF  0x02
+#define CSR_RXAK 0x01
+
+struct mpc_i2c {
+	void __iomem *base;
+	u32 interrupt;
+	wait_queue_head_t queue;
+	struct i2c_adapter adap;
+	int irq;
+	u32 flags;
+};
+
+static __inline__ void writeccr(struct mpc_i2c *i2c, u32 x)
+{
+	writeb(x, i2c->base + MPC_I2C_CR);
+}
+
+static irqreturn_t mpc_i2c_isr(int irq, void *dev_id)
+{
+	struct mpc_i2c *i2c = dev_id;
+	if (readb(i2c->base + MPC_I2C_SR) & CSR_MIF) {
+		/* Read again to allow register to stabilise */
+		i2c->interrupt = readb(i2c->base + MPC_I2C_SR);
+		writeb(0, i2c->base + MPC_I2C_SR);
+		wake_up_interruptible(&i2c->queue);
+	}
+	return IRQ_HANDLED;
+}
+
+/* Sometimes 9th clock pulse isn't generated, and slave doesn't release
+ * the bus, because it wants to send ACK.
+ * Following sequence of enabling/disabling and sending start/stop generates
+ * the pulse, so it's all OK.
+ */
+static void mpc_i2c_fixup(struct mpc_i2c *i2c)
+{
+	writeccr(i2c, 0);
+	udelay(30);
+	writeccr(i2c, CCR_MEN);
+	udelay(30);
+	writeccr(i2c, CCR_MSTA | CCR_MTX);
+	udelay(30);
+	writeccr(i2c, CCR_MSTA | CCR_MTX | CCR_MEN);
+	udelay(30);
+	writeccr(i2c, CCR_MEN);
+	udelay(30);
+}
+
+static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
+{
+	unsigned long orig_jiffies = jiffies;
+	u32 x;
+	int result = 0;
+
+	if (i2c->irq == 0)
+	{
+		while (!(readb(i2c->base + MPC_I2C_SR) & CSR_MIF)) {
+			schedule();
+			if (time_after(jiffies, orig_jiffies + timeout)) {
+				pr_debug("I2C: timeout\n");
+				writeccr(i2c, 0);
+				result = -EIO;
+				break;
+			}
+		}
+		x = readb(i2c->base + MPC_I2C_SR);
+		writeb(0, i2c->base + MPC_I2C_SR);
+	} else {
+		/* Interrupt mode */
+		result = wait_event_interruptible_timeout(i2c->queue,
+			(i2c->interrupt & CSR_MIF), timeout * HZ);
+
+		if (unlikely(result < 0)) {
+			pr_debug("I2C: wait interrupted\n");
+			writeccr(i2c, 0);
+		} else if (unlikely(!(i2c->interrupt & CSR_MIF))) {
+			pr_debug("I2C: wait timeout\n");
+			writeccr(i2c, 0);
+			result = -ETIMEDOUT;
+		}
+
+		x = i2c->interrupt;
+		i2c->interrupt = 0;
+	}
+
+	if (result < 0)
+		return result;
+
+	if (!(x & CSR_MCF)) {
+		pr_debug("I2C: unfinished\n");
+		return -EIO;
+	}
+
+	if (x & CSR_MAL) {
+		pr_debug("I2C: MAL\n");
+		return -EIO;
+	}
+
+	if (writing && (x & CSR_RXAK)) {
+		pr_debug("I2C: No RXAK\n");
+		/* generate stop */
+		writeccr(i2c, CCR_MEN);
+		return -EIO;
+	}
+	return 0;
+}
+
+static void mpc_i2c_setclock(struct mpc_i2c *i2c)
+{
+	/* Set clock and filters */
+	if (i2c->flags & FSL_I2C_DEV_SEPARATE_DFSRR) {
+		writeb(0x31, i2c->base + MPC_I2C_FDR);
+		writeb(0x10, i2c->base + MPC_I2C_DFSRR);
+	} else if (i2c->flags & FSL_I2C_DEV_CLOCK_5200)
+		writeb(0x3f, i2c->base + MPC_I2C_FDR);
+	else
+		writel(0x1031, i2c->base + MPC_I2C_FDR);
+}
+
+static void mpc_i2c_start(struct mpc_i2c *i2c)
+{
+	/* Clear arbitration */
+	writeb(0, i2c->base + MPC_I2C_SR);
+	/* Start with MEN */
+	writeccr(i2c, CCR_MEN);
+}
+
+static void mpc_i2c_stop(struct mpc_i2c *i2c)
+{
+	writeccr(i2c, CCR_MEN);
+}
+
+static int mpc_write(struct mpc_i2c *i2c, int target,
+		     const u8 * data, int length, int restart)
+{
+	int i;
+	unsigned timeout = i2c->adap.timeout;
+	u32 flags = restart ? CCR_RSTA : 0;
+
+	/* Start with MEN */
+	if (!restart)
+		writeccr(i2c, CCR_MEN);
+	/* Start as master */
+	writeccr(i2c, CCR_MIEN | CCR_MEN | CCR_MSTA | CCR_MTX | flags);
+	/* Write target byte */
+	writeb((target << 1), i2c->base + MPC_I2C_DR);
+
+	if (i2c_wait(i2c, timeout, 1) < 0)
+		return -1;
+
+	for (i = 0; i < length; i++) {
+		/* Write data byte */
+		writeb(data[i], i2c->base + MPC_I2C_DR);
+
+		if (i2c_wait(i2c, timeout, 1) < 0)
+			return -1;
+	}
+
+	return 0;
+}
+
+static int mpc_read(struct mpc_i2c *i2c, int target,
+		    u8 * data, int length, int restart)
+{
+	unsigned timeout = i2c->adap.timeout;
+	int i;
+	u32 flags = restart ? CCR_RSTA : 0;
+
+	/* Start with MEN */
+	if (!restart)
+		writeccr(i2c, CCR_MEN);
+	/* Switch to read - restart */
+	writeccr(i2c, CCR_MIEN | CCR_MEN | CCR_MSTA | CCR_MTX | flags);
+	/* Write target address byte - this time with the read flag set */
+	writeb((target << 1) | 1, i2c->base + MPC_I2C_DR);
+
+	if (i2c_wait(i2c, timeout, 1) < 0)
+		return -1;
+
+	if (length) {
+		if (length == 1)
+			writeccr(i2c, CCR_MIEN | CCR_MEN | CCR_MSTA | CCR_TXAK);
+		else
+			writeccr(i2c, CCR_MIEN | CCR_MEN | CCR_MSTA);
+		/* Dummy read */
+		readb(i2c->base + MPC_I2C_DR);
+	}
+
+	for (i = 0; i < length; i++) {
+		if (i2c_wait(i2c, timeout, 0) < 0)
+			return -1;
+
+		/* Generate txack on next to last byte */
+		if (i == length - 2)
+			writeccr(i2c, CCR_MIEN | CCR_MEN | CCR_MSTA | CCR_TXAK);
+		/* Generate stop on last byte */
+		if (i == length - 1)
+			writeccr(i2c, CCR_MIEN | CCR_MEN | CCR_TXAK);
+		data[i] = readb(i2c->base + MPC_I2C_DR);
+	}
+
+	return length;
+}
+
+static int mpc_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
+{
+	struct i2c_msg *pmsg;
+	int i;
+	int ret = 0;
+	unsigned long orig_jiffies = jiffies;
+	struct mpc_i2c *i2c = i2c_get_adapdata(adap);
+
+	mpc_i2c_start(i2c);
+
+	/* Allow bus up to 1s to become not busy */
+	while (readb(i2c->base + MPC_I2C_SR) & CSR_MBB) {
+		if (signal_pending(current)) {
+			pr_debug("I2C: Interrupted\n");
+			writeccr(i2c, 0);
+			return -EINTR;
+		}
+		if (time_after(jiffies, orig_jiffies + HZ)) {
+			pr_debug("I2C: timeout\n");
+			if (readb(i2c->base + MPC_I2C_SR) ==
+			    (CSR_MCF | CSR_MBB | CSR_RXAK))
+				mpc_i2c_fixup(i2c);
+			return -EIO;
+		}
+		schedule();
+	}
+
+	for (i = 0; ret >= 0 && i < num; i++) {
+		pmsg = &msgs[i];
+		pr_debug("Doing %s %d bytes to 0x%02x - %d of %d messages\n",
+			 pmsg->flags & I2C_M_RD ? "read" : "write",
+			 pmsg->len, pmsg->addr, i + 1, num);
+		if (pmsg->flags & I2C_M_RD)
+			ret =
+			    mpc_read(i2c, pmsg->addr, pmsg->buf, pmsg->len, i);
+		else
+			ret =
+			    mpc_write(i2c, pmsg->addr, pmsg->buf, pmsg->len, i);
+	}
+	mpc_i2c_stop(i2c);
+	return (ret < 0) ? ret : num;
+}
+
+static u32 mpc_functionality(struct i2c_adapter *adap)
+{
+	return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
+}
+
+static const struct i2c_algorithm mpc_algo = {
+	.master_xfer = mpc_xfer,
+	.functionality = mpc_functionality,
+};
+
+static struct i2c_adapter mpc_ops = {
+	.owner = THIS_MODULE,
+	.name = "MPC adapter",
+	.id = I2C_HW_MPC107,
+	.algo = &mpc_algo,
+	.class = I2C_CLASS_HWMON,
+	.timeout = 1,
+	.retries = 1
+};
+
+static int fsl_i2c_probe(struct platform_device *pdev)
+{
+	int result = 0;
+	struct mpc_i2c *i2c;
+	struct fsl_i2c_platform_data *pdata;
+	struct resource *r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+
+	pdata = (struct fsl_i2c_platform_data *) pdev->dev.platform_data;
+
+	if (!(i2c = kzalloc(sizeof(*i2c), GFP_KERNEL))) {
+		return -ENOMEM;
+	}
+
+	i2c->irq = platform_get_irq(pdev, 0);
+	if (i2c->irq < 0) {
+		result = -ENXIO;
+		goto fail_get_irq;
+	}
+	i2c->flags = pdata->device_flags;
+	init_waitqueue_head(&i2c->queue);
+
+	i2c->base = ioremap((phys_addr_t)r->start, MPC_I2C_REGION);
+
+	if (!i2c->base) {
+		printk(KERN_ERR "i2c-mpc - failed to map controller\n");
+		result = -ENOMEM;
+		goto fail_map;
+	}
+
+	if (i2c->irq != 0)
+		if ((result = request_irq(i2c->irq, mpc_i2c_isr,
+					  IRQF_SHARED, "i2c-mpc", i2c)) < 0) {
+			printk(KERN_ERR
+			       "i2c-mpc - failed to attach interrupt\n");
+			goto fail_irq;
+		}
+
+	mpc_i2c_setclock(i2c);
+	platform_set_drvdata(pdev, i2c);
+
+	i2c->adap = mpc_ops;
+	i2c->adap.nr = pdev->id;
+	i2c_set_adapdata(&i2c->adap, i2c);
+	i2c->adap.dev.parent = &pdev->dev;
+	if ((result = i2c_add_numbered_adapter(&i2c->adap)) < 0) {
+		printk(KERN_ERR "i2c-mpc - failed to add adapter\n");
+		goto fail_add;
+	}
+
+	return result;
+
+      fail_add:
+	if (i2c->irq != 0)
+		free_irq(i2c->irq, i2c);
+      fail_irq:
+	iounmap(i2c->base);
+      fail_map:
+      fail_get_irq:
+	kfree(i2c);
+	return result;
+};
+
+static int fsl_i2c_remove(struct platform_device *pdev)
+{
+	struct mpc_i2c *i2c = platform_get_drvdata(pdev);
+
+	i2c_del_adapter(&i2c->adap);
+	platform_set_drvdata(pdev, NULL);
+
+	if (i2c->irq != 0)
+		free_irq(i2c->irq, i2c);
+
+	iounmap(i2c->base);
+	kfree(i2c);
+	return 0;
+};
+
+/* Structure for a device driver */
+static struct platform_driver fsl_i2c_driver = {
+	.probe = fsl_i2c_probe,
+	.remove = fsl_i2c_remove,
+	.driver	= {
+		.owner = THIS_MODULE,
+		.name = "fsl-i2c",
+	},
+};
+
+static int __init fsl_i2c_init(void)
+{
+	return platform_driver_register(&fsl_i2c_driver);
+}
+
+static void __exit fsl_i2c_exit(void)
+{
+	platform_driver_unregister(&fsl_i2c_driver);
+}
+
+module_init(fsl_i2c_init);
+module_exit(fsl_i2c_exit);
+
+MODULE_AUTHOR("Adrian Cox <adrian@humboldt.co.uk>");
+MODULE_DESCRIPTION
+    ("I2C-Bus adapter for MPC107 bridge and MPC824x/85xx/52xx processors");
+MODULE_LICENSE("GPL");

^ permalink raw reply related

* [PATCH 5/7] Convert PowerPC MPC i2c to of_platform_driver from platform_driver
From: Jon Smirl @ 2007-12-18  2:39 UTC (permalink / raw)
  To: i2c, linuxppc-dev, linux-kernel
In-Reply-To: <20071218023913.8530.46661.stgit@terra.home>

Convert MPC i2c driver from being a platform_driver to an open firmware version. Error returns were improved. Routine names were changed from fsl_ to mpc_ to make them match the file name.

Signed-off-by: Jon Smirl <jonsmirl@gmail.com>

Signed-off-by: Jon Smirl <jonsmirl@gmail.com>

Signed-off-by: Jon Smirl <jonsmirl@gmail.com>
---

 arch/powerpc/sysdev/fsl_soc.c |   96 ------------------------
 drivers/i2c/busses/i2c-mpc.c  |  167 +++++++++++++++++++++++++++++------------
 2 files changed, 119 insertions(+), 144 deletions(-)


diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index 268638a..d6ef264 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -318,102 +318,6 @@ err:
 
 arch_initcall(gfar_of_init);
 
-#ifdef CONFIG_I2C_BOARDINFO
-#include <linux/i2c.h>
-
-static void __init of_register_i2c_devices(struct device_node *adap_node,
-					   int bus_num)
-{
-	struct device_node *node = NULL;
-	const char *compatible;
-
-	while ((node = of_get_next_child(adap_node, node))) {
-		struct i2c_board_info info = {};
-		const u32 *addr;
-		int len;
-
-		addr = of_get_property(node, "reg", &len);
-		if (!addr || len < sizeof(int) || *addr > (1 << 10) - 1) {
-			printk(KERN_WARNING "fsl_soc.c: invalid i2c device entry\n");
-			continue;
-		}
-
-		info.irq = irq_of_parse_and_map(node, 0);
-		if (info.irq == NO_IRQ)
-			info.irq = -1;
-
-		compatible = of_get_property(node, "compatible", &len);
-		if (!compatible) {
-			printk(KERN_WARNING "i2c-mpc.c: invalid entry, missing compatible attribute\n");
-			continue;
-		}
-		strncpy(info.driver_name, compatible, sizeof(info.driver_name));
-
-		info.addr = *addr;
-
-		i2c_register_board_info(bus_num, &info, 1);
-	}
-}
-
-static int __init fsl_i2c_of_init(void)
-{
-	struct device_node *np;
-	unsigned int i;
-	struct platform_device *i2c_dev;
-	int ret;
-
-	for (np = NULL, i = 0;
-	     (np = of_find_compatible_node(np, "i2c", "fsl-i2c")) != NULL;
-	     i++) {
-		struct resource r[2];
-		struct fsl_i2c_platform_data i2c_data;
-		const unsigned char *flags = NULL;
-
-		memset(&r, 0, sizeof(r));
-		memset(&i2c_data, 0, sizeof(i2c_data));
-
-		ret = of_address_to_resource(np, 0, &r[0]);
-		if (ret)
-			goto err;
-
-		of_irq_to_resource(np, 0, &r[1]);
-
-		i2c_dev = platform_device_register_simple("fsl-i2c", i, r, 2);
-		if (IS_ERR(i2c_dev)) {
-			ret = PTR_ERR(i2c_dev);
-			goto err;
-		}
-
-		i2c_data.device_flags = 0;
-		flags = of_get_property(np, "dfsrr", NULL);
-		if (flags)
-			i2c_data.device_flags |= FSL_I2C_DEV_SEPARATE_DFSRR;
-
-		flags = of_get_property(np, "fsl5200-clocking", NULL);
-		if (flags)
-			i2c_data.device_flags |= FSL_I2C_DEV_CLOCK_5200;
-
-		ret =
-		    platform_device_add_data(i2c_dev, &i2c_data,
-					     sizeof(struct
-						    fsl_i2c_platform_data));
-		if (ret)
-			goto unreg;
-
-		of_register_i2c_devices(np, i);
-	}
-
-	return 0;
-
-unreg:
-	platform_device_unregister(i2c_dev);
-err:
-	return ret;
-}
-
-arch_initcall(fsl_i2c_of_init);
-#endif
-
 #ifdef CONFIG_PPC_83xx
 static int __init mpc83xx_wdt_init(void)
 {
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 7c35a8f..fc46207 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -17,7 +17,7 @@
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <linux/init.h>
-#include <linux/platform_device.h>
+#include <linux/of_platform.h>
 
 #include <asm/io.h>
 #include <linux/fsl_devices.h>
@@ -25,13 +25,13 @@
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 
-#define MPC_I2C_ADDR  0x00
+#define DRV_NAME "mpc-i2c"
+
 #define MPC_I2C_FDR 	0x04
 #define MPC_I2C_CR	0x08
 #define MPC_I2C_SR	0x0c
 #define MPC_I2C_DR	0x10
 #define MPC_I2C_DFSRR 0x14
-#define MPC_I2C_REGION 0x20
 
 #define CCR_MEN  0x80
 #define CCR_MIEN 0x40
@@ -316,105 +316,176 @@ static struct i2c_adapter mpc_ops = {
 	.retries = 1
 };
 
-static int fsl_i2c_probe(struct platform_device *pdev)
+struct i2c_driver_device {
+	char	*of_device;
+	char	*i2c_driver;
+	char	*i2c_type;
+};
+
+static void of_register_i2c_devices(struct i2c_adapter *adap, struct device_node *adap_node)
+{
+	struct device_node *node = NULL;
+
+	while ((node = of_get_next_child(adap_node, node))) {
+		struct i2c_board_info info;
+		const u32 *addr;
+		const char *compatible;
+		int len;
+
+		addr = of_get_property(node, "reg", &len);
+		if (!addr || len < sizeof(int) || *addr > (1 << 10) - 1) {
+			printk(KERN_ERR "i2c-mpc.c: invalid entry, missing reg attribute\n");
+			continue;
+		}
+
+		info.irq = irq_of_parse_and_map(node, 0);
+		if (info.irq == NO_IRQ)
+			info.irq = -1;
+
+		compatible = of_get_property(node, "compatible", &len);
+		if (!compatible) {
+			printk(KERN_ERR "i2c-mpc.c: invalid entry, missing compatible attribute\n");
+			continue;
+		}
+		
+		/* need full alias i2c:NOF,vendor,device */
+		strcpy(info.driver_name, I2C_OF_MODULE_PREFIX);
+		strncat(info.driver_name, compatible, sizeof(info.driver_name));
+		request_module(info.driver_name);
+		
+		/* need module alias OF,vendor,device */
+		strcpy(info.driver_name, OF_I2C_PREFIX);
+		strncat(info.driver_name, compatible, sizeof(info.driver_name));
+		
+		info.type[0] = '\0';
+		info.platform_data = NULL;
+		info.addr = *addr;
+
+		if (!i2c_new_device(adap, &info)) {
+			printk(KERN_ERR "i2c-mpc.c: Failed to load driver for %s\n", info.driver_name);
+			continue;
+		}
+	}
+}
+
+static int mpc_i2c_probe(struct of_device *op, const struct of_device_id *match)
 {
 	int result = 0;
 	struct mpc_i2c *i2c;
-	struct fsl_i2c_platform_data *pdata;
-	struct resource *r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-
-	pdata = (struct fsl_i2c_platform_data *) pdev->dev.platform_data;
 
 	i2c = kzalloc(sizeof(*i2c), GFP_KERNEL);
 	if (!i2c)
 		return -ENOMEM;
 
-	i2c->irq = platform_get_irq(pdev, 0);
-	if (i2c->irq < 0) {
-		result = -ENXIO;
-		goto fail_get_irq;
-	}
-	i2c->flags = pdata->device_flags;
-	init_waitqueue_head(&i2c->queue);
+	if (of_get_property(op->node, "dfsrr", NULL))
+		i2c->flags |= FSL_I2C_DEV_SEPARATE_DFSRR;
 
-	i2c->base = ioremap((phys_addr_t)r->start, MPC_I2C_REGION);
+	if (of_device_is_compatible(op->node, "mpc5200-i2c"))
+		i2c->flags |= FSL_I2C_DEV_CLOCK_5200;
 
+	init_waitqueue_head(&i2c->queue);
+
+	i2c->base = of_iomap(op->node, 0);
 	if (!i2c->base) {
 		printk(KERN_ERR "i2c-mpc - failed to map controller\n");
 		result = -ENOMEM;
 		goto fail_map;
 	}
 
-	if (i2c->irq != 0)
-		if ((result = request_irq(i2c->irq, mpc_i2c_isr,
-					  IRQF_SHARED, "i2c-mpc", i2c)) < 0) {
-			printk(KERN_ERR
-			       "i2c-mpc - failed to attach interrupt\n");
-			goto fail_irq;
-		}
+	i2c->irq = irq_of_parse_and_map(op->node, 0);
+	if (i2c->irq == NO_IRQ) {
+		result = -ENXIO;
+		goto fail_irq;
+	}
+
+	result = request_irq(i2c->irq, mpc_i2c_isr, IRQF_SHARED, "i2c-mpc", i2c);
+	if (result < 0) {
+		printk(KERN_ERR "i2c-mpc - failed to attach interrupt\n");
+		goto fail_request;
+	}
 
 	mpc_i2c_setclock(i2c);
-	platform_set_drvdata(pdev, i2c);
+
+	dev_set_drvdata(&op->dev, i2c);
 
 	i2c->adap = mpc_ops;
-	i2c->adap.nr = pdev->id;
 	i2c_set_adapdata(&i2c->adap, i2c);
-	i2c->adap.dev.parent = &pdev->dev;
-	if ((result = i2c_add_numbered_adapter(&i2c->adap)) < 0) {
+	i2c->adap.dev.parent = &op->dev;
+
+	result = i2c_add_adapter(&i2c->adap);
+	if (result < 0) {
 		printk(KERN_ERR "i2c-mpc - failed to add adapter\n");
 		goto fail_add;
 	}
 
+	of_register_i2c_devices(&i2c->adap, op->node);
+
 	return result;
 
-      fail_add:
-	if (i2c->irq != 0)
-		free_irq(i2c->irq, i2c);
-      fail_irq:
+fail_add:
+	free_irq(i2c->irq, i2c);
+fail_request:
+	irq_dispose_mapping(i2c->irq);
+fail_irq:
 	iounmap(i2c->base);
-      fail_map:
-      fail_get_irq:
+fail_map:
 	kfree(i2c);
 	return result;
 };
 
-static int fsl_i2c_remove(struct platform_device *pdev)
+static int mpc_i2c_remove(struct of_device *op)
 {
-	struct mpc_i2c *i2c = platform_get_drvdata(pdev);
+	struct mpc_i2c *i2c = dev_get_drvdata(&op->dev);
 
 	i2c_del_adapter(&i2c->adap);
-	platform_set_drvdata(pdev, NULL);
+	dev_set_drvdata(&op->dev, NULL);
 
 	if (i2c->irq != NO_IRQ)
 		free_irq(i2c->irq, i2c);
 
+	irq_dispose_mapping(i2c->irq);
 	iounmap(i2c->base);
 	kfree(i2c);
 	return 0;
 };
 
+static struct of_device_id mpc_i2c_of_match[] = {
+	{
+		.compatible	= "fsl-i2c",
+	},
+	{},
+};
+MODULE_DEVICE_TABLE(of, mpc_i2c_of_match);
+
+
 /* Structure for a device driver */
-static struct platform_driver fsl_i2c_driver = {
-	.probe = fsl_i2c_probe,
-	.remove = fsl_i2c_remove,
-	.driver	= {
-		.owner = THIS_MODULE,
-		.name = "fsl-i2c",
+static struct of_platform_driver mpc_i2c_driver = {
+	.match_table	= mpc_i2c_of_match,
+	.probe		= mpc_i2c_probe,
+	.remove		= __devexit_p(mpc_i2c_remove),
+	.driver		= {
+		.owner	= THIS_MODULE,
+		.name	= DRV_NAME,
 	},
 };
 
-static int __init fsl_i2c_init(void)
+static int __init mpc_i2c_init(void)
 {
-	return platform_driver_register(&fsl_i2c_driver);
+	int rv;
+
+	rv = of_register_platform_driver(&mpc_i2c_driver);
+	if (rv)
+		printk(KERN_ERR DRV_NAME " of_register_platform_driver failed (%i)\n", rv);
+	return rv;
 }
 
-static void __exit fsl_i2c_exit(void)
+static void __exit mpc_i2c_exit(void)
 {
-	platform_driver_unregister(&fsl_i2c_driver);
+	of_unregister_platform_driver(&mpc_i2c_driver);
 }
 
-module_init(fsl_i2c_init);
-module_exit(fsl_i2c_exit);
+module_init(mpc_i2c_init);
+module_exit(mpc_i2c_exit);
 
 MODULE_AUTHOR("Adrian Cox <adrian@humboldt.co.uk>");
 MODULE_DESCRIPTION

^ permalink raw reply related

* [PATCH 2/7] Implement module aliasing for i2c to translate from device tree names
From: Jon Smirl @ 2007-12-18  2:39 UTC (permalink / raw)
  To: i2c, linuxppc-dev, linux-kernel
In-Reply-To: <20071218023913.8530.46661.stgit@terra.home>

This patch allows new style i2c chip drivers to have alias names using
the official kernel aliasing system and MODULE_DEVICE_TABLE(). I've
tested it on PowerPC and x86. This change is required for PowerPC
device tree support.

Signed-off-by: Jon Smirl <jonsmirl@gmail.com>

Signed-off-by: Jon Smirl <jonsmirl@gmail.com>

Signed-off-by: Jon Smirl <jonsmirl@gmail.com>
---

 drivers/i2c/i2c-core.c          |   32 ++++++++++++++++++++++++++------
 include/linux/i2c.h             |    9 ++++-----
 include/linux/mod_devicetable.h |   20 ++++++++++++++++++++
 scripts/mod/file2alias.c        |   19 +++++++++++++++++++
 4 files changed, 69 insertions(+), 11 deletions(-)


diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index b5e13e4..fce06fd 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -47,10 +47,25 @@ static DEFINE_IDR(i2c_adapter_idr);
 
 /* ------------------------------------------------------------------------- */
 
-static int i2c_device_match(struct device *dev, struct device_driver *drv)
+static const struct i2c_device_id *i2c_device_match(const struct i2c_device_id *id, struct i2c_client *client)
+{
+	/* only powerpc drivers implement the id_table,
+	 * it is empty on other platforms */
+	if (id) {
+		while (id->name[0]) {
+			if (strcmp(client->driver_name, id->name) == 0)
+				return id;
+			id++;
+		}
+	}
+	return NULL;
+}
+
+static int i2c_bus_match(struct device *dev, struct device_driver *drv)
 {
 	struct i2c_client	*client = to_i2c_client(dev);
 	struct i2c_driver	*driver = to_i2c_driver(drv);
+	const struct i2c_device_id *found_id;
 
 	/* make legacy i2c drivers bypass driver model probing entirely;
 	 * such drivers scan each i2c adapter/bus themselves.
@@ -58,9 +73,11 @@ static int i2c_device_match(struct device *dev, struct device_driver *drv)
 	if (!is_newstyle_driver(driver))
 		return 0;
 
-	/* new style drivers use the same kind of driver matching policy
-	 * as platform devices or SPI:  compare device and driver IDs.
-	 */
+	/* match on an id table if there is one */
+	found_id = i2c_device_match(driver->id_table, client);
+	if (found_id)
+		return 1;
+
 	return strcmp(client->driver_name, drv->name) == 0;
 }
 
@@ -89,12 +106,15 @@ static int i2c_device_probe(struct device *dev)
 {
 	struct i2c_client	*client = to_i2c_client(dev);
 	struct i2c_driver	*driver = to_i2c_driver(dev->driver);
+	const struct i2c_device_id *id;
 
 	if (!driver->probe)
 		return -ENODEV;
 	client->driver = driver;
 	dev_dbg(dev, "probe\n");
-	return driver->probe(client);
+
+	id = i2c_device_match(driver->id_table, client);
+	return driver->probe(client, id);
 }
 
 static int i2c_device_remove(struct device *dev)
@@ -189,7 +209,7 @@ static struct device_attribute i2c_dev_attrs[] = {
 static struct bus_type i2c_bus_type = {
 	.name		= "i2c",
 	.dev_attrs	= i2c_dev_attrs,
-	.match		= i2c_device_match,
+	.match		= i2c_bus_match,
 	.uevent		= i2c_device_uevent,
 	.probe		= i2c_device_probe,
 	.remove		= i2c_device_remove,
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index a100c9f..49fc682 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -126,7 +126,7 @@ struct i2c_driver {
 	 * With the driver model, device enumeration is NEVER done by drivers;
 	 * it's done by infrastructure.  (NEW STYLE DRIVERS ONLY)
 	 */
-	int (*probe)(struct i2c_client *);
+	int (*probe)(struct i2c_client *, const struct i2c_device_id *id);
 	int (*remove)(struct i2c_client *);
 
 	/* driver model interfaces that don't relate to enumeration  */
@@ -141,11 +141,10 @@ struct i2c_driver {
 
 	struct device_driver driver;
 	struct list_head list;
+	struct i2c_device_id *id_table;
 };
 #define to_i2c_driver(d) container_of(d, struct i2c_driver, driver)
 
-#define I2C_NAME_SIZE	20
-
 /**
  * struct i2c_client - represent an I2C slave device
  * @flags: I2C_CLIENT_TEN indicates the device uses a ten bit chip address;
@@ -179,7 +178,7 @@ struct i2c_client {
 					/* to the client		*/
 	struct device dev;		/* the device structure		*/
 	int irq;			/* irq issued by device (or -1) */
-	char driver_name[KOBJ_NAME_LEN];
+	char driver_name[I2C_NAME_SIZE];
 	struct list_head list;
 	struct completion released;
 };
@@ -223,7 +222,7 @@ static inline void i2c_set_clientdata (struct i2c_client *dev, void *data)
  * with the adapter already known.
  */
 struct i2c_board_info {
-	char		driver_name[KOBJ_NAME_LEN];
+	char		driver_name[I2C_NAME_SIZE];
 	char		type[I2C_NAME_SIZE];
 	unsigned short	flags;
 	unsigned short	addr;
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index e9fddb4..d66038a 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -367,4 +367,24 @@ struct virtio_device_id {
 };
 #define VIRTIO_DEV_ANY_ID	0xffffffff
 
+/* i2c */
+
+/* These defines are used to separate PowerPC open firmware
+ * drivers into their own namespace */
+#define I2C_NAME_SIZE	(16*3)
+#define I2C_MODULE_PREFIX "i2c:N"
+#ifdef CONFIG_OF
+#define OF_I2C_PREFIX "OF,"
+#define I2C_OF_MODULE_PREFIX I2C_MODULE_PREFIX OF_I2C_PREFIX
+#define OF_I2C_ID(s,d) {OF_I2C_PREFIX s, (d) },
+#else
+#define OF_I2C_ID(s,d)
+#endif
+
+struct i2c_device_id {
+	char name[I2C_NAME_SIZE];
+	kernel_ulong_t driver_data;	/* Data private to the driver */
+};
+
+
 #endif /* LINUX_MOD_DEVICETABLE_H */
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index d802b5a..da43742 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -539,6 +539,21 @@ static int do_virtio_entry(const char *filename, struct virtio_device_id *id,
 	return 1;
 }
 
+/* Looks like: i2c:Ns */
+static int do_i2c_entry(const char *filename, struct i2c_device_id *id,
+			   char *alias)
+{
+    char *tmp;
+    sprintf (alias, I2C_MODULE_PREFIX "%s", id->name);
+
+    /* Replace all whitespace with underscores */
+    for (tmp = alias; tmp && *tmp; tmp++)
+        if (isspace (*tmp))
+            *tmp = '_';
+
+    return 1;
+}
+
 /* Ignore any prefix, eg. v850 prepends _ */
 static inline int sym_is(const char *symbol, const char *name)
 {
@@ -669,6 +684,10 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
 		do_table(symval, sym->st_size,
 			 sizeof(struct virtio_device_id), "virtio",
 			 do_virtio_entry, mod);
+	else if (sym_is(symname, "__mod_i2c_device_table"))
+		do_table(symval, sym->st_size,
+			 sizeof(struct i2c_device_id), "i2c",
+			 do_i2c_entry, mod);
 	free(zeros);
 }
 

^ permalink raw reply related

* [PATCH 4/7] Clean up error returns
From: Jon Smirl @ 2007-12-18  2:39 UTC (permalink / raw)
  To: i2c, linuxppc-dev, linux-kernel
In-Reply-To: <20071218023913.8530.46661.stgit@terra.home>

Return errors that were being ignored in the mpc-i2c driver

Signed-off-by: Jon Smirl <jonsmirl@gmail.com>

Signed-off-by: Jon Smirl <jonsmirl@gmail.com>

Signed-off-by: Jon Smirl <jonsmirl@gmail.com>
---

 drivers/i2c/busses/i2c-mpc.c |   30 +++++++++++++++++-------------
 1 files changed, 17 insertions(+), 13 deletions(-)


diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index d8de4ac..7c35a8f 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -180,7 +180,7 @@ static void mpc_i2c_stop(struct mpc_i2c *i2c)
 static int mpc_write(struct mpc_i2c *i2c, int target,
 		     const u8 * data, int length, int restart)
 {
-	int i;
+	int i, result;
 	unsigned timeout = i2c->adap.timeout;
 	u32 flags = restart ? CCR_RSTA : 0;
 
@@ -192,15 +192,17 @@ static int mpc_write(struct mpc_i2c *i2c, int target,
 	/* Write target byte */
 	writeb((target << 1), i2c->base + MPC_I2C_DR);
 
-	if (i2c_wait(i2c, timeout, 1) < 0)
-		return -1;
+	result = i2c_wait(i2c, timeout, 1);
+	if (result < 0)
+		return result;
 
 	for (i = 0; i < length; i++) {
 		/* Write data byte */
 		writeb(data[i], i2c->base + MPC_I2C_DR);
 
-		if (i2c_wait(i2c, timeout, 1) < 0)
-			return -1;
+		result = i2c_wait(i2c, timeout, 1);
+		if (result < 0)
+			return result;
 	}
 
 	return 0;
@@ -210,7 +212,7 @@ static int mpc_read(struct mpc_i2c *i2c, int target,
 		    u8 * data, int length, int restart)
 {
 	unsigned timeout = i2c->adap.timeout;
-	int i;
+	int i, result;
 	u32 flags = restart ? CCR_RSTA : 0;
 
 	/* Start with MEN */
@@ -221,8 +223,9 @@ static int mpc_read(struct mpc_i2c *i2c, int target,
 	/* Write target address byte - this time with the read flag set */
 	writeb((target << 1) | 1, i2c->base + MPC_I2C_DR);
 
-	if (i2c_wait(i2c, timeout, 1) < 0)
-		return -1;
+	result = i2c_wait(i2c, timeout, 1);
+	if (result < 0)
+		return result;
 
 	if (length) {
 		if (length == 1)
@@ -234,8 +237,9 @@ static int mpc_read(struct mpc_i2c *i2c, int target,
 	}
 
 	for (i = 0; i < length; i++) {
-		if (i2c_wait(i2c, timeout, 0) < 0)
-			return -1;
+		result = i2c_wait(i2c, timeout, 0);
+		if (result < 0)
+			return result;
 
 		/* Generate txack on next to last byte */
 		if (i == length - 2)
@@ -321,9 +325,9 @@ static int fsl_i2c_probe(struct platform_device *pdev)
 
 	pdata = (struct fsl_i2c_platform_data *) pdev->dev.platform_data;
 
-	if (!(i2c = kzalloc(sizeof(*i2c), GFP_KERNEL))) {
+	i2c = kzalloc(sizeof(*i2c), GFP_KERNEL);
+	if (!i2c)
 		return -ENOMEM;
-	}
 
 	i2c->irq = platform_get_irq(pdev, 0);
 	if (i2c->irq < 0) {
@@ -381,7 +385,7 @@ static int fsl_i2c_remove(struct platform_device *pdev)
 	i2c_del_adapter(&i2c->adap);
 	platform_set_drvdata(pdev, NULL);
 
-	if (i2c->irq != 0)
+	if (i2c->irq != NO_IRQ)
 		free_irq(i2c->irq, i2c);
 
 	iounmap(i2c->base);

^ permalink raw reply related

* [PATCH] update module-init-tools to support the i2c subsystem
From: Jon Smirl @ 2007-12-18  2:39 UTC (permalink / raw)
  To: i2c, linuxppc-dev, linux-kernel

Follow on to: "Series to add device tree naming to i2c"
Teach module-init-tools about the i2c subsystem.

diff --git a/depmod.c b/depmod.c
index 0281c79..209eb0c 100644
--- a/depmod.c
+++ b/depmod.c
@@ -793,6 +793,7 @@ static struct depfile depfiles[] = {
 	{ "modules.inputmap", output_input_table },
 	{ "modules.ofmap", output_of_table },
 	{ "modules.seriomap", output_serio_table },
+	{ "modules.i2cmap", output_i2c_table },
 	{ "modules.alias", output_aliases },
 	{ "modules.symbols", output_symbols },
 };
diff --git a/depmod.h b/depmod.h
index 6cea36e..1040214 100644
--- a/depmod.h
+++ b/depmod.h
@@ -55,6 +55,8 @@ struct module
 	unsigned int input_table_size;
 	unsigned int serio_size;
 	void *serio_table;
+	unsigned int i2c_size;
+	void *i2c_table;
 	unsigned int of_size;
 	void *of_table;

diff --git a/moduleops_core.c b/moduleops_core.c
index 56c85d3..a7ca350 100644
--- a/moduleops_core.c
+++ b/moduleops_core.c
@@ -230,6 +230,11 @@ static void PERBIT(fetch_tables)(struct module *module)
 					"__mod_serio_device_table",
 					NULL, module->conv);

+	module->i2c_size = PERBIT(I2C_DEVICE_SIZE);
+	module->i2c_table = PERBIT(deref_sym)(module->data,
+					"__mod_i2c_device_table",
+					NULL, module->conv);
+
 	module->of_size = PERBIT(OF_DEVICE_SIZE);
 	module->of_table = PERBIT(deref_sym)(module->data,
 					"__mod_of_device_table",
diff --git a/tables.c b/tables.c
index 6dfd165..82e162d 100644
--- a/tables.c
+++ b/tables.c
@@ -496,6 +496,35 @@ void output_serio_table(struct module *modules, FILE *out)
 }


+static void output_i2c_entry(struct i2c_device_id *i2c, char *name, FILE *out)
+{
+	fprintf(out,
+		"%-20s %-20s\n",
+		name,
+		i2c->name);
+}
+
+
+void output_i2c_table(struct module *modules, FILE *out)
+{
+	struct module *i;
+
+	fprintf(out, "# i2c module         name\n");
+
+	for (i = modules; i; i = i->next) {
+		struct i2c_device_id *e;
+		char shortname[strlen(i->pathname) + 1];
+
+		if (!i->i2c_table)
+			continue;
+
+		make_shortname(shortname, i->pathname);
+		for (e = i->i2c_table; e->name[0]; e = (void *)e + i->i2c_size)
+			output_i2c_entry(e, shortname, out);
+	}
+}
+
+
 static void
 strip_whitespace (char *str, char chr)
 {
diff --git a/tables.h b/tables.h
index e5f6f35..263369d 100644
--- a/tables.h
+++ b/tables.h
@@ -164,6 +164,12 @@ struct serio_device_id {
 #define SERIO_DEVICE_SIZE32 (4 * 1)
 #define SERIO_DEVICE_SIZE64 (4 * 1 + 4)

+struct i2c_device_id {
+	char name[48];
+};
+#define I2C_DEVICE_SIZE32 (48 + 4)
+#define I2C_DEVICE_SIZE64 (48 + 8)
+
 struct of_device_id {
 	char name[32];
 	char type[32];
@@ -182,6 +188,7 @@ void output_ccw_table(struct module *modules, FILE *out);
 void output_isapnp_table(struct module *modules, FILE *out);
 void output_input_table(struct module *modules, FILE *out);
 void output_serio_table(struct module *modules, FILE *out);
+void output_i2c_table(struct module *modules, FILE *out);
 void output_of_table(struct module *modules, FILE *out);

 #endif /* MODINITTOOLS_TABLES_H */

-- 
Jon Smirl
jonsmirl@gmail.com

^ permalink raw reply related

* [PATCH 7/7] Makefile
From: Jon Smirl @ 2007-12-18  2:39 UTC (permalink / raw)
  To: i2c, linuxppc-dev, linux-kernel
In-Reply-To: <20071218023913.8530.46661.stgit@terra.home>

Signed-off-by: Jon Smirl <jonsmirl@gmail.com>

Signed-off-by: Jon Smirl <jonsmirl@gmail.com>
---

 Makefile |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)


diff --git a/Makefile b/Makefile
index c1825aa..15ada3f 100644
--- a/Makefile
+++ b/Makefile
@@ -35,6 +35,9 @@ MAKEFLAGS += -rR --no-print-directory
 # To put more focus on warnings, be less verbose as default
 # Use 'make V=1' to see the full commands
 
+ARCH=powerpc
+CROSS_COMPILE=powerpc-603e-linux-gnu-
+
 ifdef V
   ifeq ("$(origin V)", "command line")
     KBUILD_VERBOSE = $(V)

^ permalink raw reply related


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