LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] ppc: fix #ifdef-s in mediabay driver
From: Benjamin Herrenschmidt @ 2008-01-22 23:59 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: linux-ide, linux-kernel, linuxppc-dev
In-Reply-To: <200801230012.38516.bzolnier@gmail.com>


On Wed, 2008-01-23 at 00:12 +0100, Bartlomiej Zolnierkiewicz wrote:
> * Replace incorrect CONFIG_BLK_DEV_IDE #ifdef in
>   check_media_bay() by CONFIG_MAC_FLOPPY one.
> 
> * Replace incorrect CONFIG_BLK_DEV_IDE #ifdef-s by
>   CONFIG_BLK_DEV_IDE_PMAC ones.
> 
> * check_media_bay() is used only by drivers/block/swim3.c
>   so make this function available only if CONFIG_MAC_FLOPPY
>   is defined.
> 
> * check_media_bay_by_base() and media_bay_set_ide_infos()
>   are used only by drivers/ide/ppc/pmac.c so so make these
>   functions available only if CONFIG_MAC_FLOPPY is defined.
> 
> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
> ---
> Ben, IMO this patch is safe for 2.6.24 (assuming that it builds fine :),
> otherwise I would like to ask for permission to merge it through IDE
> tree since I have other pending IDE patches depending on this one.

I'd rather avoid touching 2.6.24 unless it actually fixes a bug or
regression...

I'm tempted to actually remove all ifdef's ... if you have a media-bay,
then there are about 99% chances it contains an IDE device, with the
remaining percent being split with putting a floppy or a battery in. I
doubt anybody will care building a kernel without the support for these
and with the mediabay support, and still want to save a handful of bytes
in that driver.

Ben.

^ permalink raw reply

* Re: [MPC5200] problem running FEC and ATA
From: Wolfgang Denk @ 2008-01-23  0:20 UTC (permalink / raw)
  To: Juergen Beisert; +Cc: linuxppc-dev, Mehlan, Markus (Ritter Elektronik)
In-Reply-To: <200801211728.22817.jbe@pengutronix.de>

In message <200801211728.22817.jbe@pengutronix.de> you wrote:
>
> Is anybody out there with more MPC5200B experience? Can someone tell me why
> some MPC5200B are need this patch and others not? We have two different
> systems here (cards from different vendors) with the same processor, one
> needs this BSDIS-patch and the other not. ???????????????

Is it really exactly the same CPU revision? My guess is that one is
rev. B and the other one is older...

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de
It would be illogical to assume that all conditions remain stable
	-- Spock, "The Enterprise" Incident", stardate 5027.3

^ permalink raw reply

* Re: [PATCH 1/3 v3] Add StorCenter DTS first draft.
From: Benjamin Herrenschmidt @ 2008-01-23  0:33 UTC (permalink / raw)
  To: Grant Likely; +Cc: linuxppc-dev, Jon Loeliger
In-Reply-To: <fa686aa40801221449p28889ea5r68bd726726558dc0@mail.gmail.com>


> > +
> > +               mpic: interrupt-controller@40000 {
> > +                       #interrupt-cells = <2>;
> > +                       #address-cells = <0>;
> 
> Is #address-cells needed?  There are no child nodes.

It's preferrable for interrupt controllers as #address-cells of the
parent interrupt controller defines the size of the interrupt unit
specifier in the child in the interrupt tree.

I think there's an ongoing argument as to whether the absence of
#address-cells should be the same as #address-cells = 0 in that specific
case but I'm not sure the code does the right thing so let's have it
explicit.

Ben.

^ permalink raw reply

* Re: [PATCH 0/6] PS3: gelic: gelic updates for 2.6.25
From: Benjamin Herrenschmidt @ 2008-01-23  0:40 UTC (permalink / raw)
  To: John W. Linville; +Cc: Geert.Uytterhoeven, netdev, Linux/PPC Development
In-Reply-To: <20080122211239.GC3206@tuxdriver.com>


On Tue, 2008-01-22 at 16:12 -0500, John W. Linville wrote:
> On Thu, Dec 13, 2007 at 07:38:28PM +0900, Masakazu Mokuno wrote:
> 
> > Here is a set of updates for PS3 gelic network driver.
> > This patch set requires other patches which were already submitted by
> > Geert (http://marc.info/?l=linux-kernel&m=119626095605487).
> > 
> > 	[1] PS3: gelic: Fix the wrong dev_id passed
> > 	[2] PS3: gelic: Add endianness macros
> > 	[3] PS3: gelic: Code cleanup
> > 	[4] PS3: gelic: Remove duplicated ethtool handers
> > 	[5] PS3: gelic: Add support for port link status
> > 	[6] PS3: gelic: Add support for dual network interface
> > 
> > This is also a set of prerequisite for new wireless driver for PS3, which
> > I'll submit later. 
> 
> These seem to not have been applied, but I couldn't find any stated
> reason.  Did they just get lost?  Withdrawn?
> 
> Will these be applied?  There is a wireless patch that depends on them.
> If not, will the wireless portion be refactored to not require these
> patches?

The list of 6 patches above are the patches that Masakazu Mukono is
submitting, the pre-reqs are different patches (see the linked URL),
though I can't see them in either (they should probably go through
paulus for-2.6.25). Geert, what's up with these ?

Cheers,
Ben.

^ permalink raw reply

* Re: [PATCH] ppc: fix #ifdef-s in mediabay driver
From: Bartlomiej Zolnierkiewicz @ 2008-01-23  0:58 UTC (permalink / raw)
  To: benh; +Cc: linux-ide, linux-kernel, linuxppc-dev
In-Reply-To: <1201046394.6807.49.camel@pasglop>


Hi,

On Wednesday 23 January 2008, Benjamin Herrenschmidt wrote:
> 
> On Wed, 2008-01-23 at 00:12 +0100, Bartlomiej Zolnierkiewicz wrote:
> > * Replace incorrect CONFIG_BLK_DEV_IDE #ifdef in
> >   check_media_bay() by CONFIG_MAC_FLOPPY one.
> > 
> > * Replace incorrect CONFIG_BLK_DEV_IDE #ifdef-s by
> >   CONFIG_BLK_DEV_IDE_PMAC ones.
> > 
> > * check_media_bay() is used only by drivers/block/swim3.c
> >   so make this function available only if CONFIG_MAC_FLOPPY
> >   is defined.
> > 
> > * check_media_bay_by_base() and media_bay_set_ide_infos()
> >   are used only by drivers/ide/ppc/pmac.c so so make these
> >   functions available only if CONFIG_MAC_FLOPPY is defined.
> > 
> > Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
> > ---
> > Ben, IMO this patch is safe for 2.6.24 (assuming that it builds fine :),
> > otherwise I would like to ask for permission to merge it through IDE
> > tree since I have other pending IDE patches depending on this one.
> 
> I'd rather avoid touching 2.6.24 unless it actually fixes a bug or
> regression...

Well, it is a bugfix for PMAC_MEDIABAY=y && BLK_DEV_IDE=n && MAC_FLOPPY=y. :)

> I'm tempted to actually remove all ifdef's ... if you have a media-bay,
> then there are about 99% chances it contains an IDE device, with the
> remaining percent being split with putting a floppy or a battery in. I
> doubt anybody will care building a kernel without the support for these
> and with the mediabay support, and still want to save a handful of bytes
> in that driver.

I'm more worried about breaking automatic build checking (make randconfig)
than a few extra bytes so if you remove all #ifdefs you'll have to either
make BLK_DEV_IDE_PMAC select PMAC_MEDIABAY or make PMAC_MEDIABAY depend
on BLK_DEV_IDE_PMAC (otherwise BLK_DEV_IDE=n && PMAC_MEDIABAY=y will fail
since mediabay.c is referencing IDE code).

Thanks,
Bart

^ permalink raw reply

* Re: [PATCH 0/6] PS3: gelic: gelic updates for 2.6.25
From: John W. Linville @ 2008-01-23  0:58 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: Geert.Uytterhoeven, netdev, Linux/PPC Development
In-Reply-To: <1201048834.6807.55.camel@pasglop>

On Wed, Jan 23, 2008 at 11:40:34AM +1100, Benjamin Herrenschmidt wrote:
> 
> On Tue, 2008-01-22 at 16:12 -0500, John W. Linville wrote:
> > On Thu, Dec 13, 2007 at 07:38:28PM +0900, Masakazu Mokuno wrote:
> > 
> > > Here is a set of updates for PS3 gelic network driver.
> > > This patch set requires other patches which were already submitted by
> > > Geert (http://marc.info/?l=linux-kernel&m=119626095605487).
> > > 
> > > 	[1] PS3: gelic: Fix the wrong dev_id passed
> > > 	[2] PS3: gelic: Add endianness macros
> > > 	[3] PS3: gelic: Code cleanup
> > > 	[4] PS3: gelic: Remove duplicated ethtool handers
> > > 	[5] PS3: gelic: Add support for port link status
> > > 	[6] PS3: gelic: Add support for dual network interface
> > > 
> > > This is also a set of prerequisite for new wireless driver for PS3, which
> > > I'll submit later. 
> > 
> > These seem to not have been applied, but I couldn't find any stated
> > reason.  Did they just get lost?  Withdrawn?
> > 
> > Will these be applied?  There is a wireless patch that depends on them.
> > If not, will the wireless portion be refactored to not require these
> > patches?
> 
> The list of 6 patches above are the patches that Masakazu Mukono is
> submitting, the pre-reqs are different patches (see the linked URL),
> though I can't see them in either (they should probably go through
> paulus for-2.6.25). Geert, what's up with these ?

The wireless patch depends on the patches 1-6, which then depend on
Geert's patches.

I thought Geert's had been applied, but I guess I was looking at
it wrong.  Is there a powerpc tree that has them?  Perhaps 1-6 above
and the wireless patch should just be applied to that tree (if there
is one) and all merged together?

John
-- 
John W. Linville
linville@tuxdriver.com

^ permalink raw reply

* Re: [PATCH 1/3 v3] Add StorCenter DTS first draft.
From: Josh Boyer @ 2008-01-23  1:39 UTC (permalink / raw)
  To: benh; +Cc: linuxppc-dev, Loeliger, Jon
In-Reply-To: <1201048396.6807.52.camel@pasglop>

On Wed, 23 Jan 2008 11:33:16 +1100
Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:

> 
> > > +
> > > +               mpic: interrupt-controller@40000 {
> > > +                       #interrupt-cells = <2>;
> > > +                       #address-cells = <0>;
> > 
> > Is #address-cells needed?  There are no child nodes.
> 
> It's preferrable for interrupt controllers as #address-cells of the
> parent interrupt controller defines the size of the interrupt unit
> specifier in the child in the interrupt tree.
> 
> I think there's an ongoing argument as to whether the absence of
> #address-cells should be the same as #address-cells = 0 in that specific
> case but I'm not sure the code does the right thing so let's have it
> explicit.

The code doesn't handle the lack of #address-cells in nodes where
there is an interrupt-map. It pukes if there is no reg property and
addrsize != 0. In the absence of the #address-cells property, it will
try to look at the parent's #address-cells, and if that lacks it, it
will assign 2 which it then merrily decides is incorrect.

josh

^ permalink raw reply

* Re: [PATCH 1/3 v3] Add StorCenter DTS first draft.
From: Scott Wood @ 2008-01-23  0:47 UTC (permalink / raw)
  To: benh; +Cc: linuxppc-dev, Jon Loeliger
In-Reply-To: <1201048396.6807.52.camel@pasglop>

Benjamin Herrenschmidt wrote:
> I think there's an ongoing argument as to whether the absence of
> #address-cells should be the same as #address-cells = 0 in that specific
> case but I'm not sure the code does the right thing so let's have it
> explicit.

I've had no problems leaving it out.

-Scott

^ permalink raw reply

* BDI Problems
From: Zhou Rui @ 2008-01-23  1:50 UTC (permalink / raw)
  To: linuxppc-embedded

Hi, all:
I am using BDI2000 with PowerPC. Sometimes, when I try
to change configuration of BDI2000 for different
PowerPC boards, the configuring procedure may meet the
following errors:

root@laz:/home/zhour/bdi2000sw/bdisetup2007#
./bdisetup -v -p/dev/ttyS0 -b115
Connecting to BDI loader failed (-1201)

I also have tried /dev/ttyS1 and got the same result,
and I am sure there is not any other programs
occupying the serial ports. So would anyone give me
some advice about this?

Another problem is "PPC: JTAG instruction stuff
overrun" during debugging. For this error, I found an
explanation (http://www.ultsol.com/faq_p202.htm):
"When in debug mode the PPC4xx fetches normal PPC
instructions from the JTAG port. The error "# PPC:
JTAG instruction stuff overrun" is raised when the
processor stops fetching from the JTAG port, possibly
because the processor hangs at an un-terminated memory
transfer." The proposed resolution is based on the
modification of configuration file. However, I have
tried that but it seems to have no effect.

Best wishes

Best wishes

Zhou Rui
Distributed and Embedded System Lab
Room 532, Information Building
School of Information Science
Lanzhou University, P. R. China
Tel: 86-0931-8912025
Zip Code: 730000


      ___________________________________________________________ 
雅虎邮箱传递新年祝福,个性贺卡送亲朋! 
http://cn.mail.yahoo.com/gc/index.html?entry=5&souce=mail_mailletter_tagline

^ permalink raw reply

* [PATCH 2/3] Convert PowerPC MPC i2c to of_platform_driver from platform_driver
From: Jon Smirl @ 2008-01-23  2:09 UTC (permalink / raw)
  To: i2c, linuxppc-dev
In-Reply-To: <20080123020912.31675.48787.stgit@terra.home>

Convert MPC i2c driver from a platform_driver to a of_platform_driver. Add the ability to dynamically load i2c drivers based on device tree names. Routine names were changed from fsl_ to mpc_ to make them match the file name. Common code moved to powerpc-common.* Orginal ppc driver left intact for deletion when ppc arch is removed.

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

 arch/powerpc/sysdev/fsl_soc.c       |  125 ---------------------------
 drivers/i2c/busses/Makefile         |    2 
 drivers/i2c/busses/i2c-mpc-drv.c    |  165 ++++++++++++++++++++++++++++++++---
 drivers/i2c/busses/powerpc-common.c |   81 +++++++++++++++++
 drivers/i2c/busses/powerpc-common.h |   23 +++++
 include/linux/mod_devicetable.h     |    9 ++
 6 files changed, 263 insertions(+), 142 deletions(-)
 create mode 100644 drivers/i2c/busses/powerpc-common.c
 create mode 100644 drivers/i2c/busses/powerpc-common.h


diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index e4b14a5..d6ef264 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -318,131 +318,6 @@ err:
 
 arch_initcall(gfar_of_init);
 
-#ifdef CONFIG_I2C_BOARDINFO
-#include <linux/i2c.h>
-struct i2c_driver_device {
-	char	*of_device;
-	char	*i2c_type;
-};
-
-static struct i2c_driver_device i2c_devices[] __initdata = {
-	{"ricoh,rs5c372a", "rs5c372a",},
-	{"ricoh,rs5c372b", "rs5c372b",},
-	{"ricoh,rv5c386",  "rv5c386",},
-	{"ricoh,rv5c387a", "rv5c387a",},
-	{"dallas,ds1307",  "ds1307",},
-	{"dallas,ds1337",  "ds1337",},
-	{"dallas,ds1338",  "ds1338",},
-	{"dallas,ds1339",  "ds1339",},
-	{"dallas,ds1340",  "ds1340",},
-	{"stm,m41t00",     "m41t00"},
-	{"dallas,ds1374",  "rtc-ds1374",},
-};
-
-static int __init of_find_i2c_driver(struct device_node *node,
-				     struct i2c_board_info *info)
-{
-	int i;
-
-	for (i = 0; i < ARRAY_SIZE(i2c_devices); i++) {
-		if (!of_device_is_compatible(node, i2c_devices[i].of_device))
-			continue;
-		if (strlcpy(info->type, i2c_devices[i].i2c_type,
-			    I2C_NAME_SIZE) >= I2C_NAME_SIZE)
-			return -ENOMEM;
-		return 0;
-	}
-	return -ENODEV;
-}
-
-static void __init of_register_i2c_devices(struct device_node *adap_node,
-					   int bus_num)
-{
-	struct device_node *node = NULL;
-
-	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;
-
-		if (of_find_i2c_driver(node, &info) < 0)
-			continue;
-
-		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/Makefile b/drivers/i2c/busses/Makefile
index 171800d..e94241f 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -2,7 +2,7 @@
 # Makefile for the i2c bus drivers.
 #
 
-i2c-mpc-objs	:= i2c-mpc-drv.o
+i2c-mpc-objs	:= i2c-mpc-drv.o powerpc-common.o
 
 obj-$(CONFIG_I2C_ALI1535)	+= i2c-ali1535.o
 obj-$(CONFIG_I2C_ALI1563)	+= i2c-ali1563.o
diff --git a/drivers/i2c/busses/i2c-mpc-drv.c b/drivers/i2c/busses/i2c-mpc-drv.c
index d20959d..fd66814 100644
--- a/drivers/i2c/busses/i2c-mpc-drv.c
+++ b/drivers/i2c/busses/i2c-mpc-drv.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,15 @@
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 
-#define MPC_I2C_ADDR  0x00
+#include "powerpc-common.h"
+
+#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
@@ -57,7 +59,7 @@ struct mpc_i2c {
 	u32 flags;
 };
 
-static __inline__ void writeccr(struct mpc_i2c *i2c, u32 x)
+static inline void writeccr(struct mpc_i2c *i2c, u32 x)
 {
 	writeb(x, i2c->base + MPC_I2C_CR);
 }
@@ -99,8 +101,7 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
 	u32 x;
 	int result = 0;
 
-	if (i2c->irq == NO_IRQ)
-	{
+	if (i2c->irq == NO_IRQ) {
 		while (!(readb(i2c->base + MPC_I2C_SR) & CSR_MIF)) {
 			schedule();
 			if (time_after(jiffies, orig_jiffies + timeout)) {
@@ -178,7 +179,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)
+		     const u8 *data, int length, int restart)
 {
 	int i, result;
 	unsigned timeout = i2c->adap.timeout;
@@ -209,7 +210,7 @@ static int mpc_write(struct mpc_i2c *i2c, int target,
 }
 
 static int mpc_read(struct mpc_i2c *i2c, int target,
-		    u8 * data, int length, int restart)
+		    u8 *data, int length, int restart)
 {
 	unsigned timeout = i2c->adap.timeout;
 	int i, result;
@@ -315,6 +316,137 @@ static struct i2c_adapter mpc_ops = {
 	.timeout = 1,
 };
 
+#ifdef CONFIG_PPC_MERGE
+
+struct i2c_driver_device {
+	char	*of_device;
+	char	*i2c_driver;
+	char	*i2c_type;
+};
+
+static int mpc_i2c_probe(struct of_device *op, const struct of_device_id *match)
+{
+	int result = 0;
+	struct mpc_i2c *i2c;
+
+	i2c = kzalloc(sizeof(*i2c), GFP_KERNEL);
+	if (!i2c)
+		return -ENOMEM;
+
+	if (of_get_property(op->node, "dfsrr", NULL))
+		i2c->flags |= FSL_I2C_DEV_SEPARATE_DFSRR;
+
+	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;
+	}
+
+	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);
+
+	dev_set_drvdata(&op->dev, i2c);
+
+	i2c->adap = mpc_ops;
+	i2c_set_adapdata(&i2c->adap, i2c);
+	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:
+	dev_set_drvdata(&op->dev, NULL);
+	free_irq(i2c->irq, i2c);
+fail_request:
+	irq_dispose_mapping(i2c->irq);
+fail_irq:
+	iounmap(i2c->base);
+fail_map:
+	kfree(i2c);
+	return result;
+};
+
+static int mpc_i2c_remove(struct of_device *op)
+{
+	struct mpc_i2c *i2c = dev_get_drvdata(&op->dev);
+
+	i2c_del_adapter(&i2c->adap);
+	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 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 mpc_i2c_init(void)
+{
+	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 mpc_i2c_exit(void)
+{
+	of_unregister_platform_driver(&mpc_i2c_driver);
+}
+
+module_init(mpc_i2c_init);
+module_exit(mpc_i2c_exit);
+
+#else
+
 static int fsl_i2c_probe(struct platform_device *pdev)
 {
 	int result = 0;
@@ -345,8 +477,8 @@ static int fsl_i2c_probe(struct platform_device *pdev)
 	}
 
 	if (i2c->irq != NO_IRQ)
-		if ((result = request_irq(i2c->irq, mpc_i2c_isr,
-					  IRQF_SHARED, "i2c-mpc", i2c)) < 0) {
+		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_irq;
@@ -359,20 +491,21 @@ static int fsl_i2c_probe(struct platform_device *pdev)
 	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) {
+	result = i2c_add_numbered_adapter(&i2c->adap);
+	if (result < 0) {
 		printk(KERN_ERR "i2c-mpc - failed to add adapter\n");
 		goto fail_add;
 	}
 
 	return result;
 
-      fail_add:
+fail_add:
 	if (i2c->irq != NO_IRQ)
 		free_irq(i2c->irq, i2c);
-      fail_irq:
+fail_irq:
 	iounmap(i2c->base);
-      fail_map:
-      fail_get_irq:
+fail_map:
+fail_get_irq:
 	kfree(i2c);
 	return result;
 };
@@ -415,6 +548,8 @@ static void __exit fsl_i2c_exit(void)
 module_init(fsl_i2c_init);
 module_exit(fsl_i2c_exit);
 
+#endif
+
 MODULE_AUTHOR("Adrian Cox <adrian@humboldt.co.uk>");
 MODULE_DESCRIPTION
     ("I2C-Bus adapter for MPC107 bridge and MPC824x/85xx/52xx processors");
diff --git a/drivers/i2c/busses/powerpc-common.c b/drivers/i2c/busses/powerpc-common.c
new file mode 100644
index 0000000..833131b
--- /dev/null
+++ b/drivers/i2c/busses/powerpc-common.c
@@ -0,0 +1,81 @@
+/*
+ * powerpc-common.c - routines common to device tree parsing for all
+ *                    powerpc based i2c hosts
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * (C) Copyright 2008 Jon Smirl <jonsmirl@gmail.com>
+ *
+ */
+
+#include <linux/interrupt.h>
+#include <linux/i2c.h>
+#include <linux/of_platform.h>
+
+#include "powerpc-common.h"
+
+#ifdef CONFIG_PPC_MERGE
+
+void of_register_i2c_devices(struct i2c_adapter *adap, struct device_node *adap_node)
+{
+	void *result;
+	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;
+
+		compatible = of_get_property(node, "compatible", &len);
+		if (!compatible) {
+			printk(KERN_ERR "i2c-mpc.c: invalid entry, missing compatible attribute\n");
+			continue;
+		}
+
+		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 for %s\n", compatible);
+			continue;
+		}
+
+		info.irq = irq_of_parse_and_map(node, 0);
+		if (info.irq < NO_IRQ) {
+			printk(KERN_ERR "i2c-mpc.c: invalid irq attribute for %s\n", compatible);
+			continue;
+		}
+
+		/* need full alias i2c:OF,vendor,device */
+		strcpy(info.type, I2C_OF_MODULE_PREFIX);
+		strncat(info.type, compatible, sizeof(info.type));
+		request_module(info.type);
+
+		/* need module alias OF,vendor,device */
+		strcpy(info.type, OF_PREFIX);
+		strncat(info.type, compatible, sizeof(info.type));
+
+		info.platform_data = NULL;
+		info.addr = *addr;
+
+		result = PTR_ERR(i2c_new_device(adap, &info));
+		if (result == NULL) {
+			printk(KERN_ERR "i2c-mpc.c: Failed to load driver for %s, err %d\n", compatible);
+			irq_dispose_mapping(info.irq);
+			continue;
+		}
+	}
+}
+
+#endif
diff --git a/drivers/i2c/busses/powerpc-common.h b/drivers/i2c/busses/powerpc-common.h
new file mode 100644
index 0000000..95f1347
--- /dev/null
+++ b/drivers/i2c/busses/powerpc-common.h
@@ -0,0 +1,23 @@
+/*
+ * powerpc-common.h - routines common to device tree parsing for all
+ *                    powerpc based i2c hosts
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * (C) Copyright 2008 Jon Smirl <jonsmirl@gmail.com>
+ *
+ */
+
+void of_register_i2c_devices(struct i2c_adapter *adap, struct device_node *adap_node);
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index d1488a0..2e53b39 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -371,8 +371,15 @@ struct virtio_device_id {
 
 /* These defines are used to separate PowerPC open firmware
  * drivers into their own namespace */
-#define I2C_NAME_SIZE	20
+#define I2C_NAME_SIZE	48  /* Needs to be large enough to hold device tree style names */
 #define I2C_MODULE_PREFIX "i2c:"
+#ifdef CONFIG_OF
+#define OF_PREFIX "OF," /* Used to put OF device tree names into their own namespace */
+#define I2C_OF_MODULE_PREFIX I2C_MODULE_PREFIX OF_PREFIX
+#define OF_ID(s, d) { OF_PREFIX s, (d) },
+#else
+#define OF_ID(s, d)
+#endif
 
 struct i2c_device_id {
 	char name[I2C_NAME_SIZE];

^ permalink raw reply related

* [PATCH 1/3] Rename i2c-mpc to i2c-mpc-drv in preparation for breaking out common code.
From: Jon Smirl @ 2008-01-23  2:09 UTC (permalink / raw)
  To: i2c, linuxppc-dev

Rename i2c-mpc to i2c-mpc-drv in preparation for breaking out common code.

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

 drivers/i2c/busses/Makefile      |    2 
 drivers/i2c/busses/i2c-mpc-drv.c |  421 ++++++++++++++++++++++++++++++++++++++
 drivers/i2c/busses/i2c-mpc.c     |  421 --------------------------------------
 3 files changed, 423 insertions(+), 421 deletions(-)
 create mode 100644 drivers/i2c/busses/i2c-mpc-drv.c
 delete mode 100644 drivers/i2c/busses/i2c-mpc.c


diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index ea7068f..171800d 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -2,6 +2,8 @@
 # Makefile for the i2c bus drivers.
 #
 
+i2c-mpc-objs	:= i2c-mpc-drv.o
+
 obj-$(CONFIG_I2C_ALI1535)	+= i2c-ali1535.o
 obj-$(CONFIG_I2C_ALI1563)	+= i2c-ali1563.o
 obj-$(CONFIG_I2C_ALI15X3)	+= i2c-ali15x3.o
diff --git a/drivers/i2c/busses/i2c-mpc-drv.c b/drivers/i2c/busses/i2c-mpc-drv.c
new file mode 100644
index 0000000..d20959d
--- /dev/null
+++ b/drivers/i2c/busses/i2c-mpc-drv.c
@@ -0,0 +1,421 @@
+/*
+ * (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 == NO_IRQ)
+	{
+		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, result;
+	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);
+
+	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);
+
+		result = i2c_wait(i2c, timeout, 1);
+		if (result < 0)
+			return result;
+	}
+
+	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, result;
+	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);
+
+	result = i2c_wait(i2c, timeout, 1);
+	if (result < 0)
+		return result;
+
+	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++) {
+		result = i2c_wait(i2c, timeout, 0);
+		if (result < 0)
+			return result;
+
+		/* 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,
+};
+
+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;
+
+	i2c = kzalloc(sizeof(*i2c), GFP_KERNEL);
+	if (!i2c)
+		return -ENOMEM;
+
+	i2c->irq = platform_get_irq(pdev, 0);
+	if (i2c->irq < NO_IRQ) {
+		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 != NO_IRQ)
+		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 != NO_IRQ)
+		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 != NO_IRQ)
+		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");
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
deleted file mode 100644
index d20959d..0000000
--- a/drivers/i2c/busses/i2c-mpc.c
+++ /dev/null
@@ -1,421 +0,0 @@
-/*
- * (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 == NO_IRQ)
-	{
-		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, result;
-	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);
-
-	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);
-
-		result = i2c_wait(i2c, timeout, 1);
-		if (result < 0)
-			return result;
-	}
-
-	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, result;
-	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);
-
-	result = i2c_wait(i2c, timeout, 1);
-	if (result < 0)
-		return result;
-
-	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++) {
-		result = i2c_wait(i2c, timeout, 0);
-		if (result < 0)
-			return result;
-
-		/* 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,
-};
-
-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;
-
-	i2c = kzalloc(sizeof(*i2c), GFP_KERNEL);
-	if (!i2c)
-		return -ENOMEM;
-
-	i2c->irq = platform_get_irq(pdev, 0);
-	if (i2c->irq < NO_IRQ) {
-		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 != NO_IRQ)
-		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 != NO_IRQ)
-		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 != NO_IRQ)
-		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 3/3] Add device tree compatible aliases to i2c drivers
From: Jon Smirl @ 2008-01-23  2:09 UTC (permalink / raw)
  To: i2c, linuxppc-dev
In-Reply-To: <20080123020912.31675.48787.stgit@terra.home>

PowerPC device trees use a different naming convention than the Linux kernel.  Provide alias names for i2c drivers in order to allow them to be loaded by device tree name. The OF_ID macro ensures that the aliases are only present in powerpc builds and separated into their own namespace.

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

 drivers/hwmon/f75375s.c      |    2 ++
 drivers/i2c/chips/ds1682.c   |    1 +
 drivers/i2c/chips/menelaus.c |    1 +
 drivers/i2c/chips/tps65010.c |    4 ++++
 drivers/i2c/chips/tsl2550.c  |    1 +
 drivers/rtc/rtc-ds1307.c     |    6 ++++++
 drivers/rtc/rtc-ds1374.c     |    1 +
 drivers/rtc/rtc-m41t80.c     |    8 ++++++++
 drivers/rtc/rtc-pcf8563.c    |    2 ++
 drivers/rtc/rtc-rs5c372.c    |    4 ++++
 10 files changed, 30 insertions(+), 0 deletions(-)


diff --git a/drivers/hwmon/f75375s.c b/drivers/hwmon/f75375s.c
index 4cb4db4..dd548e7 100644
--- a/drivers/hwmon/f75375s.c
+++ b/drivers/hwmon/f75375s.c
@@ -132,6 +132,8 @@ static struct i2c_driver f75375_legacy_driver = {
 static const struct i2c_device_id f75375_id[] = {
 	{ "f75373", f75373 },
 	{ "f75375", f75375 },
+	OF_ID("fintek,f75373", f75373)
+	OF_ID("fintek,f75375", f75375)
 	{ },
 };
 MODULE_DEVICE_TABLE(i2c, f75375_id);
diff --git a/drivers/i2c/chips/ds1682.c b/drivers/i2c/chips/ds1682.c
index 51ff518..817ad1f 100644
--- a/drivers/i2c/chips/ds1682.c
+++ b/drivers/i2c/chips/ds1682.c
@@ -237,6 +237,7 @@ static int ds1682_remove(struct i2c_client *client)
 
 static const struct i2c_device_id ds1682_id[] = {
 	{ "ds1682", 0 },
+	OF_ID("dallas,ds1682", 0)
 	{ },
 };
 MODULE_DEVICE_TABLE(i2c, ds1682_id);
diff --git a/drivers/i2c/chips/menelaus.c b/drivers/i2c/chips/menelaus.c
index 1f9ac5e..ba7d619 100644
--- a/drivers/i2c/chips/menelaus.c
+++ b/drivers/i2c/chips/menelaus.c
@@ -1245,6 +1245,7 @@ static int __exit menelaus_remove(struct i2c_client *client)
 
 static const struct i2c_device_id menelaus_id[] = {
 	{ "menelaus", 0 },
+	OF_ID("ti,twl92330", 0)
 	{ },
 };
 MODULE_DEVICE_TABLE(i2c, menelaus_id);
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c
index e07274d..67fd30f 100644
--- a/drivers/i2c/chips/tps65010.c
+++ b/drivers/i2c/chips/tps65010.c
@@ -571,6 +571,10 @@ static const struct i2c_device_id tps65010_id[] = {
 	{ "tps65011", TPS65011 },
 	{ "tps65012", TPS65012 },
 	{ "tps65013", TPS65013 },
+	OF_ID("ti,tps65010", TPS65010)
+	OF_ID("ti,tps65011", TPS65011)
+	OF_ID("ti,tps65012", TPS65012)
+	OF_ID("ri,tps65013", TPS65013)
 	{ },
 };
 MODULE_DEVICE_TABLE(i2c, tps65010_id);
diff --git a/drivers/i2c/chips/tsl2550.c b/drivers/i2c/chips/tsl2550.c
index 2add8be..8071d6d 100644
--- a/drivers/i2c/chips/tsl2550.c
+++ b/drivers/i2c/chips/tsl2550.c
@@ -454,6 +454,7 @@ static int tsl2550_resume(struct i2c_client *client)
 
 static const struct i2c_device_id tsl2550_id[] = {
 	{ "tsl2550", 0 },
+	OF_ID("taos,tsl2550", 0)
 	{ },
 };
 MODULE_DEVICE_TABLE(i2c, tsl2550_id);
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index a5614ab..e363a5f 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -129,6 +129,12 @@ static const struct i2c_device_id ds1307_id[] = {
 	{ "ds1339", ds_1339 },
 	{ "ds1340", ds_1340 },
 	{ "m41t00", m41t00 },
+	OF_ID("dallas,ds1307", ds_1307)
+	OF_ID("dallas,ds1337", ds_1337)
+	OF_ID("dallas,ds1338", ds_1338)
+	OF_ID("dallas,ds1339", ds_1339)
+	OF_ID("dallas,ds1340", ds_1340)
+	OF_ID("stm,m41t00", m41t00)
 	{},
 };
 MODULE_DEVICE_TABLE(i2c, ds1307_id);
diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
index 376ceeb..e4f680a 100644
--- a/drivers/rtc/rtc-ds1374.c
+++ b/drivers/rtc/rtc-ds1374.c
@@ -43,6 +43,7 @@
 
 static const struct i2c_device_id ds1374_id[] = {
 	{ "ds1374", 0 },
+	OF_ID("dallas,ds1374", 0)
 	{},
 };
 MODULE_DEVICE_TABLE(i2c, ds1374_id);
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index c672557..663f8b5 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -69,6 +69,14 @@ static const struct i2c_device_id m41t80_id[] = {
 	{ "m41st84", M41T80_FEATURE_HT | M41T80_FEATURE_BL },
 	{ "m41st85", M41T80_FEATURE_HT | M41T80_FEATURE_BL },
 	{ "m41st87", M41T80_FEATURE_HT | M41T80_FEATURE_BL },
+	OF_ID("stm,m41t80", 0)
+	OF_ID("stm,m41t81", M41T80_FEATURE_HT)
+	OF_ID("stm,m41t81s", M41T80_FEATURE_HT | M41T80_FEATURE_BL)
+	OF_ID("stm,m41t82", M41T80_FEATURE_HT | M41T80_FEATURE_BL)
+	OF_ID("stm,m41t83", M41T80_FEATURE_HT | M41T80_FEATURE_BL)
+	OF_ID("stm,m41st84", M41T80_FEATURE_HT | M41T80_FEATURE_BL)
+	OF_ID("stm,m41st85", M41T80_FEATURE_HT | M41T80_FEATURE_BL)
+	OF_ID("stm,m41st87", M41T80_FEATURE_HT | M41T80_FEATURE_BL)
 	{},
 };
 MODULE_DEVICE_TABLE(i2c, m41t80_id);
diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
index 8eff549..51d7471 100644
--- a/drivers/rtc/rtc-pcf8563.c
+++ b/drivers/rtc/rtc-pcf8563.c
@@ -263,6 +263,8 @@ static int pcf8563_remove(struct i2c_client *client)
 static struct i2c_device_id pcf8563_id[] = {
 	{"pcf8563", 0},
 	{"rtc8564", 0},
+	OF_ID("phillips,pcf8563", 0)
+	OF_ID("epson,rtc8564", 0)
 	{},
 };
 MODULE_DEVICE_TABLE(i2c, pcf8563_id);
diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c
index a3e4f8d..cdd26c3 100644
--- a/drivers/rtc/rtc-rs5c372.c
+++ b/drivers/rtc/rtc-rs5c372.c
@@ -74,6 +74,10 @@ static const struct i2c_device_id rs5c372_id[] = {
 	{ "rs5c372b", rtc_rs5c372b },
 	{ "rv5c386", rtc_rv5c386 },
 	{ "rv5c387a", rtc_rv5c387a },
+	OF_ID("ricoh,rs5c372a", rtc_rs5c372a)
+	OF_ID("ricoh,rs5c372b", rtc_rs5c372b)
+	OF_ID("ricoh,rv5c386", rtc_rv5c386)
+	OF_ID("ricoh,rv5c387a", rtc_rv5c387a)
 	{},
 };
 MODULE_DEVICE_TABLE(i2c, rs5c372_id);

^ permalink raw reply related

* Re: [PATCH 1/3] Rename i2c-mpc to i2c-mpc-drv in preparation for breaking out common code.
From: Stephen Rothwell @ 2008-01-23  2:46 UTC (permalink / raw)
  To: Jon Smirl; +Cc: linuxppc-dev, i2c
In-Reply-To: <20080123020912.31675.48787.stgit@terra.home>

[-- Attachment #1: Type: text/plain, Size: 829 bytes --]

Hi Jon,

On Tue, 22 Jan 2008 21:09:12 -0500 Jon Smirl <jonsmirl@gmail.com> wrote:
>
> Rename i2c-mpc to i2c-mpc-drv in preparation for breaking out common code.
> 
> Signed-off-by: Jon Smirl <jonsmirl@gmail.com>
> ---
> 
>  drivers/i2c/busses/Makefile      |    2 
>  drivers/i2c/busses/i2c-mpc-drv.c |  421 ++++++++++++++++++++++++++++++++++++++
>  drivers/i2c/busses/i2c-mpc.c     |  421 --------------------------------------
>  3 files changed, 423 insertions(+), 421 deletions(-)
>  create mode 100644 drivers/i2c/busses/i2c-mpc-drv.c
>  delete mode 100644 drivers/i2c/busses/i2c-mpc.c

Adding -M or -C to the "git diff" should identify renames and
makes this sort of patch much easier to review.

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply

* Re: [PATCH 1/3] Rename i2c-mpc to i2c-mpc-drv in preparation for breaking out common code.
From: Jon Smirl @ 2008-01-23  2:50 UTC (permalink / raw)
  To: Stephen Rothwell; +Cc: linuxppc-dev, i2c
In-Reply-To: <20080123134654.cb5e249d.sfr@canb.auug.org.au>

On 1/22/08, Stephen Rothwell <sfr@canb.auug.org.au> wrote:
> Hi Jon,
>
> On Tue, 22 Jan 2008 21:09:12 -0500 Jon Smirl <jonsmirl@gmail.com> wrote:
> >
> > Rename i2c-mpc to i2c-mpc-drv in preparation for breaking out common code.
> >
> > Signed-off-by: Jon Smirl <jonsmirl@gmail.com>
> > ---
> >
> >  drivers/i2c/busses/Makefile      |    2
> >  drivers/i2c/busses/i2c-mpc-drv.c |  421 ++++++++++++++++++++++++++++++++++++++
> >  drivers/i2c/busses/i2c-mpc.c     |  421 --------------------------------------
> >  3 files changed, 423 insertions(+), 421 deletions(-)
> >  create mode 100644 drivers/i2c/busses/i2c-mpc-drv.c
> >  delete mode 100644 drivers/i2c/busses/i2c-mpc.c
>
> Adding -M or -C to the "git diff" should identify renames and
> makes this sort of patch much easier to review.

I use stgit, I'll ask them how to generate rename patches. The actual
git diff is buried inside stgit somewhere.

>
> --
> Cheers,
> Stephen Rothwell                    sfr@canb.auug.org.au
> http://www.canb.auug.org.au/~sfr/
>
>


-- 
Jon Smirl
jonsmirl@gmail.com

^ permalink raw reply

* Re: BDI Problems
From: Grant Likely @ 2008-01-23  2:59 UTC (permalink / raw)
  To: Zhou Rui; +Cc: linuxppc-embedded
In-Reply-To: <986902.37818.qm@web15601.mail.cnb.yahoo.com>

On 1/22/08, Zhou Rui <vancasperz@yahoo.com.cn> wrote:
> Hi, all:
> I am using BDI2000 with PowerPC. Sometimes, when I try
> to change configuration of BDI2000 for different
> PowerPC boards, the configuring procedure may meet the
> following errors:

These questions are off-topic for this list.  You'd be better off
contacting Abatron technical support.

Cheers,
g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

^ permalink raw reply

* Re: [PATCH 1/3] Rename i2c-mpc to i2c-mpc-drv in preparation for breaking out common code.
From: Grant Likely @ 2008-01-23  3:02 UTC (permalink / raw)
  To: Jon Smirl; +Cc: Stephen Rothwell, i2c, linuxppc-dev
In-Reply-To: <9e4733910801221850k406f0985jd072876b681299da@mail.gmail.com>

On 1/22/08, Jon Smirl <jonsmirl@gmail.com> wrote:
> On 1/22/08, Stephen Rothwell <sfr@canb.auug.org.au> wrote:
> > Adding -M or -C to the "git diff" should identify renames and
> > makes this sort of patch much easier to review.
>
> I use stgit, I'll ask them how to generate rename patches. The actual
> git diff is buried inside stgit somewhere.

>From the "stg mail --help" output:

  -O DIFF_OPTS, --diff-opts=DIFF_OPTS
                        options to pass to git-diff

g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

^ permalink raw reply

* Re: [PATCH 1/3] Rename i2c-mpc to i2c-mpc-drv in preparation for breaking out common code.
From: Jon Smirl @ 2008-01-23  3:09 UTC (permalink / raw)
  To: Grant Likely; +Cc: Stephen Rothwell, i2c, linuxppc-dev
In-Reply-To: <fa686aa40801221902u21856724ob146bf5ff8de8f78@mail.gmail.com>

On 1/22/08, Grant Likely <grant.likely@secretlab.ca> wrote:
> On 1/22/08, Jon Smirl <jonsmirl@gmail.com> wrote:
> > On 1/22/08, Stephen Rothwell <sfr@canb.auug.org.au> wrote:
> > > Adding -M or -C to the "git diff" should identify renames and
> > > makes this sort of patch much easier to review.
> >
> > I use stgit, I'll ask them how to generate rename patches. The actual
> > git diff is buried inside stgit somewhere.
>
> From the "stg mail --help" output:
>
>   -O DIFF_OPTS, --diff-opts=DIFF_OPTS
>                         options to pass to git-diff

I found that one, there doesn't appear to be a way to set it
permanently via the config file. I asked them to add the option.
Here's the patch with -M set, I'll make sure and set it on the final
version. These patches apply on top of Jean's patch adding module
loading to i2c, which apply on top of his 2.6.25 tree.

Rename i2c-mpc to i2c-mpc-drv in preparation for breaking out common code.

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

 drivers/i2c/busses/Makefile      |    2
 drivers/i2c/busses/i2c-mpc-drv.c |  421 ++++++++++++++++++++++++++++++++++++++
 drivers/i2c/busses/i2c-mpc.c     |  421 --------------------------------------
 3 files changed, 423 insertions(+), 421 deletions(-)
 create mode 100644 drivers/i2c/busses/i2c-mpc-drv.c
 delete mode 100644 drivers/i2c/busses/i2c-mpc.c


diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index ea7068f..171800d 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -2,6 +2,8 @@
 # Makefile for the i2c bus drivers.
 #

+i2c-mpc-objs	:= i2c-mpc-drv.o
+
 obj-$(CONFIG_I2C_ALI1535)	+= i2c-ali1535.o
 obj-$(CONFIG_I2C_ALI1563)	+= i2c-ali1563.o
 obj-$(CONFIG_I2C_ALI15X3)	+= i2c-ali15x3.o
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc-drv.c
similarity index 100%
rename from drivers/i2c/busses/i2c-mpc.c
rename to drivers/i2c/busses/i2c-mpc-drv.c

-- 
Jon Smirl
jonsmirl@gmail.com

^ permalink raw reply related

* Re: [PATCH 2/3] Convert PowerPC MPC i2c to of_platform_driver from platform_driver
From: Stephen Rothwell @ 2008-01-23  3:11 UTC (permalink / raw)
  To: Jon Smirl; +Cc: linuxppc-dev, i2c
In-Reply-To: <20080123020914.31675.35659.stgit@terra.home>

[-- Attachment #1: Type: text/plain, Size: 1051 bytes --]

On Tue, 22 Jan 2008 21:09:14 -0500 Jon Smirl <jonsmirl@gmail.com> wrote:
>
> +static struct of_device_id mpc_i2c_of_match[] = {

(sfr winds up his broken record :-))  const, please.

> +#else
> +
>  static int fsl_i2c_probe(struct platform_device *pdev)

While this code is still here, you should still explicitly include
<linux/platform.h>

> -      fail_add:
> +fail_add:

If you are going to move labels, many people leave a single space in
front of them so that "diff -p" picks up the function name instead of the
label name.

> +void of_register_i2c_devices(struct i2c_adapter *adap, struct device_node *adap_node)

> +		compatible = of_get_property(node, "compatible", &len);

You can specify NULL instead of &len since you don't use the returned value.

> +		if (!compatible) {
> +			printk(KERN_ERR "i2c-mpc.c: invalid entry, missing compatible attribute\n");

Some of these printk lines are a bit long.

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply

* Re: [PATCH 0/6] PS3: gelic: gelic updates for 2.6.25
From: Geoff Levand @ 2008-01-23  3:12 UTC (permalink / raw)
  To: John W. Linville
  Cc: Geert.Uytterhoeven, Paul Mackerras, Linux/PPC Development, netdev
In-Reply-To: <20080123005845.GE3206@tuxdriver.com>

On 01/22/2008 04:58 PM, John W. Linville wrote:
> On Wed, Jan 23, 2008 at 11:40:34AM +1100, Benjamin Herrenschmidt wrote:
>> 
>> On Tue, 2008-01-22 at 16:12 -0500, John W. Linville wrote:
>> > On Thu, Dec 13, 2007 at 07:38:28PM +0900, Masakazu Mokuno wrote:
>> > 
>> > > Here is a set of updates for PS3 gelic network driver.
>> > > This patch set requires other patches which were already submitted by
>> > > Geert (http://marc.info/?l=linux-kernel&m=119626095605487).
>> > > 
>> > > 	[1] PS3: gelic: Fix the wrong dev_id passed
>> > > 	[2] PS3: gelic: Add endianness macros
>> > > 	[3] PS3: gelic: Code cleanup
>> > > 	[4] PS3: gelic: Remove duplicated ethtool handers
>> > > 	[5] PS3: gelic: Add support for port link status
>> > > 	[6] PS3: gelic: Add support for dual network interface
>> > > 
>> > > This is also a set of prerequisite for new wireless driver for PS3, which
>> > > I'll submit later. 
>> > 
>> > These seem to not have been applied, but I couldn't find any stated
>> > reason.  Did they just get lost?  Withdrawn?
>> > 
>> > Will these be applied?  There is a wireless patch that depends on them.
>> > If not, will the wireless portion be refactored to not require these
>> > patches?
>> 
>> The list of 6 patches above are the patches that Masakazu Mukono is
>> submitting, the pre-reqs are different patches (see the linked URL),
>> though I can't see them in either (they should probably go through
>> paulus for-2.6.25). Geert, what's up with these ?
> 
> The wireless patch depends on the patches 1-6, which then depend on
> Geert's patches.
> 
> I thought Geert's had been applied, but I guess I was looking at
> it wrong.  Is there a powerpc tree that has them?

Not yet, they are now only in ps3-linux.git.  I sent them out to
Paul last Friday the 18th for inclusion in 2.6.25.  Here is a link
to the message:

  http://ozlabs.org/pipermail/linuxppc-dev/2008-January/050213.html

> Perhaps 1-6 above
> and the wireless patch should just be applied to that tree (if there
> is one) and all merged together?

I think Paul will accept them if they have the Sign-off-by's of
the proper network maintainers.

-Geoff

^ permalink raw reply

* Re: [PATCH] ppc: fix #ifdef-s in mediabay driver
From: Benjamin Herrenschmidt @ 2008-01-23  4:17 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: linux-ide, linux-kernel, linuxppc-dev
In-Reply-To: <200801230158.42017.bzolnier@gmail.com>


On Wed, 2008-01-23 at 01:58 +0100, Bartlomiej Zolnierkiewicz wrote:
> I'm more worried about breaking automatic build checking (make randconfig)
> than a few extra bytes so if you remove all #ifdefs you'll have to either
> make BLK_DEV_IDE_PMAC select PMAC_MEDIABAY or make PMAC_MEDIABAY depend
> on BLK_DEV_IDE_PMAC (otherwise BLK_DEV_IDE=n && PMAC_MEDIABAY=y will fail
> since mediabay.c is referencing IDE code).

I was thinking about having the pmac arch code provide an exported
function pointer to put the hook in to avoid that problem.

Ben.

^ permalink raw reply

* Re: [PATCH 2/3] Convert PowerPC MPC i2c to of_platform_driver from platform_driver
From: Jon Smirl @ 2008-01-23  4:18 UTC (permalink / raw)
  To: Stephen Rothwell; +Cc: linuxppc-dev, i2c
In-Reply-To: <20080123141121.02c69526.sfr@canb.auug.org.au>

On 1/22/08, Stephen Rothwell <sfr@canb.auug.org.au> wrote:
> On Tue, 22 Jan 2008 21:09:14 -0500 Jon Smirl <jonsmirl@gmail.com> wrote:
> >
> > +static struct of_device_id mpc_i2c_of_match[] = {
>
> (sfr winds up his broken record :-))  const, please.

Fixed this

>
> > +#else
> > +
> >  static int fsl_i2c_probe(struct platform_device *pdev)
>
> While this code is still here, you should still explicitly include
> <linux/platform.h>

Fixed this

>
> > -      fail_add:
> > +fail_add:
>
> If you are going to move labels, many people leave a single space in
> front of them so that "diff -p" picks up the function name instead of the
> label name.

checkpatch told me to get rid of the spaces.

>
> > +void of_register_i2c_devices(struct i2c_adapter *adap, struct device_node *adap_node)
>
> > +             compatible = of_get_property(node, "compatible", &len);
>
> You can specify NULL instead of &len since you don't use the returned value.

fixed

>
> > +             if (!compatible) {
> > +                     printk(KERN_ERR "i2c-mpc.c: invalid entry, missing compatible attribute\n");
>
> Some of these printk lines are a bit long.

i got rid of "invalid entry,"

>
> --
> Cheers,
> Stephen Rothwell                    sfr@canb.auug.org.au
> http://www.canb.auug.org.au/~sfr/
>
>


-- 
Jon Smirl
jonsmirl@gmail.com

^ permalink raw reply

* Re: [MPC5200] problem running FEC and ATA
From: Mehlan, Markus (Ritter Elektronik) @ 2008-01-23  6:53 UTC (permalink / raw)
  To: linuxppc-dev
In-Reply-To: <20080123002040.5049F24781@gemini.denx.de>

Hello Wolfgang,

> -----Urspr=FCngliche Nachricht-----
> Von: wd@denx.de [mailto:wd@denx.de]=20
> Gesendet: Mittwoch, 23. Januar 2008 01:21
> An: Juergen Beisert
> Cc: linuxppc-dev@ozlabs.org; Mehlan, Markus (Ritter Elektronik)
> Betreff: Re: [MPC5200] problem running FEC and ATA
>=20
> In message <200801211728.22817.jbe@pengutronix.de> you wrote:
> >
> > Is anybody out there with more MPC5200B experience? Can=20
> someone tell=20
> > me why some MPC5200B are need this patch and others not? We=20
> have two=20
> > different systems here (cards from different vendors) with the same=20
> > processor, one needs this BSDIS-patch and the other not.=20
> ???????????????
>=20
> Is it really exactly the same CPU revision? My guess is that=20
> one is rev. B and the other one is older...
>=20
The processor on my board which needs the BSDIS-patch has following
label:

MPC5200CVR400B
M62C
REV 1
QAZ0637J

Best regards,
Markus

^ permalink raw reply

* RE: Xilinx XPS_LL_TEMAC vs PLB_TEMAC
From: Mohammad Sadegh Sadri @ 2008-01-23  7:35 UTC (permalink / raw)
  To: Koss, Mike (Mission Systems), David Baird, linuxppc-embedded
In-Reply-To: <EDAE140DF1B2FC42B5867C22CA0B333F0A5952@XMBIL132.northgrum.com>

[-- Attachment #1: Type: text/plain, Size: 2727 bytes --]


Hi

Well, As you know, we now need a PLB version, XPS_LL_TEMAC is connected to PLB not MPMC2...yes I remember those days of Xilinx GSRD and MPMC2 however it seems that the current architecture has slight changes. 

about the git repository of Xilinx, Although I do not believe on it, I'll give it a try...thanks for info.

well, what about Grant Likely... and his git tree?

Subject: RE: Xilinx XPS_LL_TEMAC vs PLB_TEMAC
Date: Mon, 21 Jan 2008 11:44:14 -0600
From: mike.koss@ngc.com
To: mamsadegh@hotmail.com; dhbaird@gmail.com; linuxppc-embedded@ozlabs.org










In case anyone is interested, I'm currently working on 
an almost-kernel-ready version that will be self-contained based on the LL-DMA 
version (the native MPMC port, not the PLB). It's based upon the old adapter 
from MontaVista, that I originally ported to 2.6 and the MPMC2. Unfortunately, 
it won't be ready for another few weeks since I'm working on hardware images 
currently.
 
-- Mike



From: Mohammad Sadegh Sadri 
[mailto:mamsadegh@hotmail.com] 
Sent: Monday, January 21, 2008 3:54 
AM
To: David Baird; linuxppc-embedded@ozlabs.org
Subject: 
RE: Xilinx XPS_LL_TEMAC vs PLB_TEMAC


thanks for you reply david,

As far as I know the Linux driver 
for Xilinx PLB TEMAC was two parts : 1- adapter.c and 2- the rest of the driver 
files

Only adapter.c was really a linux related file and the rest of the 
files were Xilinx generic driver code for PLB TEMAC.

correct?

then 
now, I know EDK 9.2 generates the needed Linux support package and needed 
related files, so if this is the case can we use these files as the needed 
driver in our linux kernel?

by the way, i did never hear about this git 
repository before...can you describe us, where is it and how we can access it 
and which projects are now hosted by it?


thanks


> Date: 
Mon, 21 Jan 2008 00:54:30 -0700
> From: dhbaird@gmail.com
> To: 
mamsadegh@hotmail.com
> Subject: Re: Xilinx XPS_LL_TEMAC vs 
PLB_TEMAC
> 
> On Jan 21, 2008 12:36 AM, Mohammad Sadegh Sadri 
<mamsadegh@hotmail.com> wrote:
> > As you know Xilinx PLB TEMAC 
is a module which connects Hard TEMAC in
> > Virtex-4 FX devices to PLB 
bus,
> > now, in the new release of EDK , EDK 9.2 Xilinx has added a 
new interface
> > core , which is called XPS_LL_TEMAC and has a 
different structure than
> > normal PLB TEMAC. spacially it has some 
additional data transfer buses.
> >
> > Now the question 
is,... is there any linux driver available for this new
> > 
core?
> 
> Yes there is, but I had to use the git sources 
at:
> 
> git.xilinx.com





_________________________________________________________________


[-- Attachment #2: Type: text/html, Size: 4020 bytes --]

^ permalink raw reply

* Re: framebuffer swap endianess
From: Roman Fietze @ 2008-01-23  7:39 UTC (permalink / raw)
  To: linuxppc-embedded
In-Reply-To: <323144.65236.qm@web23105.mail.ird.yahoo.com>

Hello ANgelo,

On Tuesday 22 January 2008 16:46:47 Angelo wrote:

> I have just create a framebuffer for an embedded system:
> - powerpc (little endian)  with  a GPU (big endian).

Are you sure? Isn't it the other way around?

> When i try to execute Xfbdev, it starts but with wrong colors.  I
> need to swap the RGB format (RRRRRGGGGGGBBBBB) to BGR, respecting
> the endianess (GGGRRRRRBBBBBGGG).

We modified the X Server and swapped when transferring from the shadow
buffer to the video buffer. That cured all our problems. This was on
the 2.4.25 from DENX and with Xfree86.

Other modifications like changing the RGB masks for the display/screen
only helped partwise, because some applications just ignored that when
using some image formats.


Roman

=2D-=20
Roman Fietze Telemotive AG B=FCro M=FChlhausen

^ permalink raw reply

* Re: crash in kmem_cache_init
From: Olaf Hering @ 2008-01-23  7:58 UTC (permalink / raw)
  To: Christoph Lameter
  Cc: lee.schermerhorn, Linux MM, Mel Gorman, linux-kernel,
	linuxppc-dev, Pekka Enberg, Aneesh Kumar K.V, hanth Aravamudan,
	akpm, KAMEZAWA Hiroyuki
In-Reply-To: <Pine.LNX.4.64.0801221417480.1912@schroedinger.engr.sgi.com>

On Tue, Jan 22, Christoph Lameter wrote:

> > 0xc0000000000fe018 is in setup_cpu_cache (/home/olaf/kernel/git/linux-2.6-numa/mm/slab.c:2111).
> > 2106                                    BUG_ON(!cachep->nodelists[node]);
> > 2107                                    kmem_list3_init(cachep->nodelists[node]);
> > 2108                            }
> > 2109                    }
> > 2110            }
> 
> if (cachep->nodelists[numa_node_id()])
> 	return;

Does not help.


Linux version 2.6.24-rc8-ppc64 (olaf@lingonberry) (gcc version 4.1.2 20070115 (prerelease) (SUSE Linux)) #48 SMP Wed Jan 23 08:54:23 CET 2008
[boot]0012 Setup Arch
EEH: PCI Enhanced I/O Error Handling Enabled
PPC64 nvram contains 8192 bytes
Zone PFN ranges:
  DMA             0 ->   892928
  Normal     892928 ->   892928
Movable zone start PFN for each node
early_node_map[1] active PFN ranges
    1:        0 ->   892928
Could not find start_pfn for node 0
[boot]0015 Setup Done
Built 2 zonelists in Node order, mobility grouping on.  Total pages: 880720
Policy zone: DMA
Kernel command line: debug xmon=on panic=1  
[boot]0020 XICS Init
xics: no ISA interrupt controller
[boot]0021 XICS Done
PID hash table entries: 4096 (order: 12, 32768 bytes)
time_init: decrementer frequency = 275.070000 MHz
time_init: processor frequency   = 2197.800000 MHz
clocksource: timebase mult[e8ab05] shift[22] registered
clockevent: decrementer mult[466a] shift[16] cpu[0]
Console: colour dummy device 80x25
console handover: boot [udbg-1] -> real [hvc0]
Dentry cache hash table entries: 524288 (order: 10, 4194304 bytes)
Inode-cache hash table entries: 262144 (order: 9, 2097152 bytes)
freeing bootmem node 1
Memory: 3496632k/3571712k available (6188k kernel code, 75080k reserved, 1324k data, 1220k bss, 304k init)
Kernel panic - not syncing: kmem_cache_create(): failed to create slab `size-32(DMA)'

Rebooting in 1 seconds..

---
 mm/slab.c |   17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1590,7 +1590,7 @@ void __init kmem_cache_init(void)
 		/* Replace the static kmem_list3 structures for the boot cpu */
 		init_list(&cache_cache, &initkmem_list3[CACHE_CACHE], node);
 
-		for_each_node_state(nid, N_NORMAL_MEMORY) {
+		for_each_online_node(nid) {
 			init_list(malloc_sizes[INDEX_AC].cs_cachep,
 				  &initkmem_list3[SIZE_AC + nid], nid);
 
@@ -1968,7 +1968,7 @@ static void __init set_up_list3s(struct 
 {
 	int node;
 
-	for_each_node_state(node, N_NORMAL_MEMORY) {
+	for_each_online_node(node) {
 		cachep->nodelists[node] = &initkmem_list3[index + node];
 		cachep->nodelists[node]->next_reap = jiffies +
 		    REAPTIMEOUT_LIST3 +
@@ -2108,6 +2108,8 @@ static int __init_refok setup_cpu_cache(
 			}
 		}
 	}
+	if (!cachep->nodelists[numa_node_id()])
+		return -ENODEV;
 	cachep->nodelists[numa_node_id()]->next_reap =
 			jiffies + REAPTIMEOUT_LIST3 +
 			((unsigned long)cachep) % REAPTIMEOUT_LIST3;
@@ -2775,6 +2777,11 @@ static int cache_grow(struct kmem_cache 
 	/* Take the l3 list lock to change the colour_next on this node */
 	check_irq_off();
 	l3 = cachep->nodelists[nodeid];
+	if (!l3) {
+		nodeid = numa_node_id();
+		l3 = cachep->nodelists[nodeid];
+	}
+	BUG_ON(!l3);
 	spin_lock(&l3->list_lock);
 
 	/* Get colour for the slab, and cal the next value. */
@@ -3317,6 +3324,10 @@ static void *____cache_alloc_node(struct
 	int x;
 
 	l3 = cachep->nodelists[nodeid];
+	if (!l3) {
+		nodeid = numa_node_id();
+		l3 = cachep->nodelists[nodeid];
+	}
 	BUG_ON(!l3);
 
 retry:
@@ -3815,7 +3826,7 @@ static int alloc_kmemlist(struct kmem_ca
 	struct array_cache *new_shared;
 	struct array_cache **new_alien = NULL;
 
-	for_each_node_state(node, N_NORMAL_MEMORY) {
+	for_each_online_node(node) {
 
                 if (use_alien_caches) {
                         new_alien = alloc_alien_cache(node, cachep->limit);

^ permalink raw reply


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