LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Re: Warp patches for 2.6.26
From: Josh Boyer @ 2008-04-13  0:50 UTC (permalink / raw)
  To: Stephen Rothwell; +Cc: Sean MacLennan, linuxppc-dev
In-Reply-To: <20080413104430.c98244d2.sfr@canb.auug.org.au>

On Sun, 2008-04-13 at 10:44 +1000, Stephen Rothwell wrote:
> Hi Sean,
> 
> First comment is that you need reasonable changelogs i.e. explain why you
> are making changes as well as what they do.  Also the first line of each
> changelog (which becomes the subject of any mail generated from git)
> should be a useful and relatively unique summary.

Yes, what Stephen said.

josh

^ permalink raw reply

* Re: [PATCH 1/5] Boot code
From: Josh Boyer @ 2008-04-13  0:49 UTC (permalink / raw)
  To: Sean MacLennan; +Cc: linuxppc-dev
In-Reply-To: <20080412140140.6c75cee5@lappy.seanm.ca>

On Sat, 2008-04-12 at 14:01 -0400, Sean MacLennan wrote:
> Signed-off-by: Sean MacLennan <smaclennan@pikatech.com>
> 

This patch is word wrapped.


> diff --git a/arch/powerpc/boot/cuboot-warp.c
> b/arch/powerpc/boot/cuboot-warp.c index eb108a8..43d7ad9 100644
> --- a/arch/powerpc/boot/cuboot-warp.c
> +++ b/arch/powerpc/boot/cuboot-warp.c
> @@ -10,6 +10,7 @@
>  #include "ops.h"
>  #include "4xx.h"
>  #include "cuboot.h"
> +#include "stdio.h"
>  
>  #define TARGET_4xx
>  #define TARGET_44x
> @@ -17,14 +18,54 @@
>  
>  static bd_t bd;
>  
> -static void warp_fixups(void)
> +static void warp_fixup_one_nor(u32 from, u32 to)
>  {
> -	unsigned long sysclk = 66000000;
> +	void *devp;
> +	char name[40];
> +	u32 v[2];
> +
> +	sprintf(name, "/plb/opb/ebc/nor_flash@0,0/partition@%x", from);

Unless I can't count (which could very well be the case), you have a
buffer overflow here.  The fixed string is 37 characters, and the values
you are passing in for "from" will extend the string past the 40 bytes
you have allocated for "name".

josh

^ permalink raw reply

* Re: Warp patches for 2.6.26
From: Stephen Rothwell @ 2008-04-13  0:44 UTC (permalink / raw)
  To: Sean MacLennan; +Cc: linuxppc-dev
In-Reply-To: <20080412134831.424480cf@lappy.seanm.ca>

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

Hi Sean,

First comment is that you need reasonable changelogs i.e. explain why you
are making changes as well as what they do.  Also the first line of each
changelog (which becomes the subject of any mail generated from git)
should be a useful and relatively unique summary.

-- 
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 4/5] LED driver
From: Josh Boyer @ 2008-04-13  0:41 UTC (permalink / raw)
  To: Sean MacLennan; +Cc: linuxppc-dev
In-Reply-To: <20080412141039.25e14fae@lappy.seanm.ca>

On Sat, 2008-04-12 at 14:10 -0400, Sean MacLennan wrote:
> Signed-off-by: Sean MacLennan <smaclennan@pikatech.com>

This should be sent to Richard Purdie.

josh
> 
> diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
> index 859814f..31e1746 100644
> --- a/drivers/leds/Kconfig
> +++ b/drivers/leds/Kconfig
> @@ -145,6 +145,12 @@ config LEDS_CLEVO_MAIL
>  	  To compile this driver as a module, choose M here: the
>  	  module will be called leds-clevo-mail.
>  
> +config LEDS_WARP
> +	tristate "LED Support for the PIKA Warp LEDs"
> +	depends on LEDS_CLASS && WARP
> +	help
> +	  This option enables support for the PIKA Warp LEDs.
> +
>  comment "LED Triggers"
>  
>  config LEDS_TRIGGERS
> diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
> index 84ced3b..eb60fb1 100644
> --- a/drivers/leds/Makefile
> +++ b/drivers/leds/Makefile
> @@ -21,6 +21,7 @@ obj-$(CONFIG_LEDS_GPIO)			+= leds-gpio.o
>  obj-$(CONFIG_LEDS_CM_X270)              += leds-cm-x270.o
>  obj-$(CONFIG_LEDS_CLEVO_MAIL)		+= leds-clevo-mail.o
>  obj-$(CONFIG_LEDS_HP6XX)		+= leds-hp6xx.o
> +obj-$(CONFIG_LEDS_WARP)			+= leds-warp.o
>  
>  # LED Triggers
>  obj-$(CONFIG_LEDS_TRIGGER_TIMER)	+= ledtrig-timer.o
> diff --git a/drivers/leds/leds-warp.c b/drivers/leds/leds-warp.c
> new file mode 100644
> index 0000000..0fbe0b7
> --- /dev/null
> +++ b/drivers/leds/leds-warp.c
> @@ -0,0 +1,148 @@
> +/*
> + * Copyright (c) 2008 PIKA Technologies
> + *   Sean MacLennan <smaclennan at pikatech.com>
> + *
> + * This is just a temporary driver until the GPIO/GPIO_OF_LEDS drivers
> + * get sorted out.
> + */
> +#include <linux/module.h>
> +#include <linux/leds.h>
> +#include <linux/of_platform.h>
> +#include <asm/machdep.h>
> +
> +
> +#define LED_GREEN (0x80000000 >> 0)
> +#define LED_RED   (0x80000000 >> 1)
> +
> +static void __iomem *gpio_base;
> +
> +
> +static void warp_green_set(struct led_classdev *led_cdev,
> +			   enum led_brightness brightness)
> +{
> +	unsigned leds = in_be32(gpio_base);
> +
> +	if (brightness)
> +		leds |=  LED_GREEN;
> +	else
> +		leds &= ~LED_GREEN;
> +
> +	out_be32(gpio_base, leds);
> +}
> +
> +static void warp_red_set(struct led_classdev *led_cdev,
> +			 enum led_brightness brightness)
> +{
> +	unsigned leds = in_be32(gpio_base);
> +
> +	if (brightness)
> +		leds |=  LED_RED;
> +	else
> +		leds &= ~LED_RED;
> +
> +	out_be32(gpio_base, leds);
> +}
> +
> +static struct led_classdev warp_green_led = {
> +	.name = "warp-green",
> +	.brightness_set = warp_green_set,
> +};
> +
> +static struct led_classdev warp_red_led = {
> +	.name = "warp-red",
> +	.brightness_set = warp_red_set,
> +};
> +
> +static int __devinit warp_led_probe(struct platform_device *pdev)
> +{
> +	struct device_node *np;
> +	int rc;
> +
> +	/* Power LEDS are on the second GPIO controller */
> +	np = of_find_compatible_node(NULL, NULL, "ibm,gpio-440EP");
> +	if (np)
> +		np = of_find_compatible_node(np, NULL, "ibm,gpio-440EP");
> +	if (np == NULL) {
> +		printk(KERN_ERR __FILE__ ": Unable to find gpio\n");
> +		return -ENOENT;
> +	}
> +
> +	gpio_base = of_iomap(np, 0);
> +	of_node_put(np);
> +	if (gpio_base == NULL) {
> +		printk(KERN_ERR __FILE__ ": Unable to map gpio");
> +		return -ENOMEM;
> +	}
> +
> +	rc = led_classdev_register(&pdev->dev, &warp_green_led);
> +	if (rc) {
> +		iounmap(gpio_base);
> +		return rc;
> +	}
> +
> +	rc = led_classdev_register(&pdev->dev, &warp_red_led);
> +	if (rc) {
> +		led_classdev_unregister(&warp_green_led);
> +		iounmap(gpio_base);
> +		return rc;
> +	}
> +
> +	return 0;
> +}
> +
> +static int __devexit warp_led_remove(struct platform_device *pdev)
> +{
> +	led_classdev_unregister(&warp_green_led);
> +	led_classdev_unregister(&warp_red_led);
> +
> +	iounmap(gpio_base);
> +
> +	return 0;
> +}
> +
> +/* We *must* have a release. */
> +static void warp_led_release(struct device *dev) {}
> +
> +static struct platform_driver warp_led_driver = {
> +	.probe	 = warp_led_probe,
> +	.remove	 = __devexit_p(warp_led_remove),
> +	.driver	 = {
> +		.name	= "warp-led",
> +	},
> +};
> +
> +static struct platform_device warp_led_device = {
> +	.name   = "warp-led",
> +	.id     = 0,
> +	.dev = {
> +		.release = warp_led_release,
> +	},
> +};
> +
> +static int __init warp_led_init(void)
> +{
> +	int rc;
> +
> +	rc = platform_device_register(&warp_led_device);
> +	if (rc)
> +		return rc;
> +	rc = platform_driver_register(&warp_led_driver);
> +	if (rc) {
> +		platform_device_unregister(&warp_led_device);
> +		return rc;
> +	}
> +
> +	return 0;
> +}
> +
> +static void __exit warp_led_exit(void)
> +{
> +	platform_driver_unregister(&warp_led_driver);
> +	platform_device_unregister(&warp_led_device);
> +}
> +
> +module_init(warp_led_init);
> +module_exit(warp_led_exit);
> +
> +MODULE_LICENSE("GPL");
> +MODULE_AUTHOR("Sean MacLennan <smaclennan@pikatech.com>");
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev

^ permalink raw reply

* Re: [PATCH 5/5] WDT driver
From: Josh Boyer @ 2008-04-13  0:40 UTC (permalink / raw)
  To: Sean MacLennan; +Cc: linuxppc-dev
In-Reply-To: <20080412141146.3050e521@lappy.seanm.ca>

On Sat, 2008-04-12 at 14:11 -0400, Sean MacLennan wrote:
> Signed-off-by: Sean MacLennan <smaclennan@pikatech.com>

This should be sent to Wim as he maintains the watchdog drivers tree.

josh
> 
> diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
> index 254d115..e73a3ea 100644
> --- a/drivers/watchdog/Kconfig
> +++ b/drivers/watchdog/Kconfig
> @@ -697,6 +697,14 @@ config BOOKE_WDT
>  	  Please see Documentation/watchdog/watchdog-api.txt for
>  	  more information.
>  
> +config PIKA_WDT
> +	tristate "PIKA FPGA Watchdog"
> +	depends on WARP
> +	default y
> +	help
> +	 This enables the watchdog in the PIKA FPGA. Currently used on
> +	 the Warp platform.
> +
>  # PPC64 Architecture
>  
>  config WATCHDOG_RTAS
> diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
> index f3fb170..09758c5 100644
> --- a/drivers/watchdog/Makefile
> +++ b/drivers/watchdog/Makefile
> @@ -105,6 +105,7 @@ obj-$(CONFIG_MPC5200_WDT) += mpc5200_wdt.o
>  obj-$(CONFIG_83xx_WDT) += mpc83xx_wdt.o
>  obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o
>  obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o
> +obj-$(CONFIG_PIKA_WDT) += pika_wdt.o
>  
>  # PPC64 Architecture
>  obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o
> diff --git a/drivers/watchdog/pika_wdt.c b/drivers/watchdog/pika_wdt.c
> new file mode 100644
> index 0000000..b84ac07
> --- /dev/null
> +++ b/drivers/watchdog/pika_wdt.c
> @@ -0,0 +1,113 @@
> +/*
> + * PIKA FPGA based Watchdog Timer
> + *
> + * Copyright (c) 2008 PIKA Technologies
> + *   Sean MacLennan <smaclennan at pikatech.com>
> + */
> +
> +#include <linux/module.h>
> +#include <linux/fs.h>
> +#include <linux/miscdevice.h>
> +#include <linux/reboot.h>
> +#include <linux/uaccess.h>
> +#include <linux/io.h>
> +#include <linux/of_platform.h>
> +#include <linux/watchdog.h>
> +
> +
> +static void __iomem *pikawdt_fpga;
> +
> +
> +static inline void pikawdt_ping(void)
> +{
> +	unsigned reset = in_be32(pikawdt_fpga + 0x14);
> +	reset |= 0xf80; /* enable with max timeout - 15 seconds */
> +	out_be32(pikawdt_fpga + 0x14, reset);
> +}
> +
> +static int pikawdt_open(struct inode *inode, struct file *file)
> +{
> +	printk(KERN_INFO "PIKA WDT started...\n");
> +
> +	pikawdt_ping();
> +
> +	return 0;
> +}
> +
> +static int pikawdt_release(struct inode *inode, struct file *file)
> +{
> +	pikawdt_ping(); /* one last time */
> +	return 0;
> +}
> +
> +static ssize_t pikawdt_write(struct file *file, const char __user *buf,
> +			     size_t count, loff_t *ppos)
> +{
> +	pikawdt_ping();
> +	return count;
> +}
> +
> +/* We support the bare minimum to be conformant. */
> +static int pikawdt_ioctl(struct inode *inode, struct file *file,
> +			 unsigned int cmd, unsigned long arg)
> +{
> +	if (cmd == WDIOC_KEEPALIVE) {
> +		pikawdt_ping();
> +		return 0;
> +	} else
> +		return -EINVAL;
> +}
> +
> +static const struct file_operations pikawdt_fops = {
> +	.owner		= THIS_MODULE,
> +	.open		= pikawdt_open,
> +	.release	= pikawdt_release,
> +	.write		= pikawdt_write,
> +	.ioctl		= pikawdt_ioctl,
> +};
> +
> +static struct miscdevice pikawdt_miscdev = {
> +	.minor	= WATCHDOG_MINOR,
> +	.name	= "watchdog",
> +	.fops	= &pikawdt_fops,
> +};
> +
> +static int __init pikawdt_init(void)
> +{
> +	struct device_node *np;
> +	int ret;
> +
> +	np = of_find_compatible_node(NULL, NULL, "pika,fpga");
> +	if (np == NULL) {
> +		printk(KERN_ERR "pikawdt: Unable to find fpga.\n");
> +		return -ENOENT;
> +	}
> +
> +	pikawdt_fpga = of_iomap(np, 0);
> +
> +	of_node_put(np);
> +
> +	if (pikawdt_fpga == NULL) {
> +		printk(KERN_ERR "pikawdt: Unable to map fpga.\n");
> +		return -ENOENT;
> +	}
> +
> +	ret = misc_register(&pikawdt_miscdev);
> +	if (ret) {
> +		iounmap(pikawdt_fpga);
> +		printk(KERN_ERR "pikawdt: Unable to register miscdev.\n");
> +		return ret;
> +	}
> +
> +	return 0;
> +}
> +module_init(pikawdt_init);
> +
> +
> +static void __exit pikawdt_exit(void)
> +{
> +	misc_deregister(&pikawdt_miscdev);
> +
> +	iounmap(pikawdt_fpga);
> +}
> +module_exit(pikawdt_exit);
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev

^ permalink raw reply

* Re: [PATCH 1/2] ibm_newemac: PowerPC 440GX EMAC PHY clock workaround
From: Jeff Garzik @ 2008-04-12 21:13 UTC (permalink / raw)
  To: jwboyer; +Cc: linuxppc-dev, netdev
In-Reply-To: <1208033230.5869.18.camel@vader.jdub.homelinux.org>

Josh Boyer wrote:
> On Sat, 2008-04-12 at 16:28 -0400, Jeff Garzik wrote:
>> I had queried the status of these patches, and didn't receive any reply 
>> initially from my query...
> 
> Erm...  you did.
> 
> http://ozlabs.org/pipermail/linuxppc-dev/2008-March/053737.html
> 
> No worries though.  I lose email all the time.

Whoops, sorry about that!

	Jeff

^ permalink raw reply

* Re: [PATCH 1/2] ibm_newemac: PowerPC 440GX EMAC PHY clock workaround
From: Josh Boyer @ 2008-04-12 20:47 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: linuxppc-dev, netdev
In-Reply-To: <48011B70.1020102@garzik.org>

On Sat, 2008-04-12 at 16:28 -0400, Jeff Garzik wrote:
> Josh Boyer wrote:
> > On Fri, 28 Mar 2008 22:18:25 -0400
> > Jeff Garzik <jeff@garzik.org> wrote:
> > 
> >> Valentine Barshak wrote:
> >>> The PowerPC 440GX Taishan board fails to reset EMAC3 (reset timeout error)
> >>> if there's no link. Because of that it fails to find PHY chip. The older ibm_emac
> >>> driver had a workaround for that: the EMAC_CLK_INTERNAL/EMAC_CLK_EXTERNAL macros,
> >>> which toggle the Ethernet Clock Select bit in the SDR0_MFR register. This patch
> >>> does the same for "ibm,emac-440gx" compatible chips. The workaround forces
> >>> clock on -all- EMACs, so we select clock under global emac_phy_map_lock.
> >>>
> >>> Signed-off-by: Valentine Barshak <vbarshak@ru.mvista.com>
> >>> ---
> >>>  drivers/net/ibm_newemac/core.c |   16 +++++++++++++++-
> >>>  drivers/net/ibm_newemac/core.h |    8 ++++++--
> >>>  2 files changed, 21 insertions(+), 3 deletions(-)
> >> is this for 2.6.25-rc?
> > 
> > Jeff, can I get an ack from you on this patch, and patch 2 in this
> > set?  They depend on a patch in my tree and I'd like to include them in
> > my next push to Paul for 2.6.26.
> 
> ACK

Many thanks.

> I had queried the status of these patches, and didn't receive any reply 
> initially from my query...

Erm...  you did.

http://ozlabs.org/pipermail/linuxppc-dev/2008-March/053737.html

No worries though.  I lose email all the time.

josh

^ permalink raw reply

* Re: [PATCH 1/2] ibm_newemac: PowerPC 440GX EMAC PHY clock workaround
From: Jeff Garzik @ 2008-04-12 20:28 UTC (permalink / raw)
  To: Josh Boyer; +Cc: linuxppc-dev, netdev
In-Reply-To: <20080411092417.57825115@zod.rchland.ibm.com>

Josh Boyer wrote:
> On Fri, 28 Mar 2008 22:18:25 -0400
> Jeff Garzik <jeff@garzik.org> wrote:
> 
>> Valentine Barshak wrote:
>>> The PowerPC 440GX Taishan board fails to reset EMAC3 (reset timeout error)
>>> if there's no link. Because of that it fails to find PHY chip. The older ibm_emac
>>> driver had a workaround for that: the EMAC_CLK_INTERNAL/EMAC_CLK_EXTERNAL macros,
>>> which toggle the Ethernet Clock Select bit in the SDR0_MFR register. This patch
>>> does the same for "ibm,emac-440gx" compatible chips. The workaround forces
>>> clock on -all- EMACs, so we select clock under global emac_phy_map_lock.
>>>
>>> Signed-off-by: Valentine Barshak <vbarshak@ru.mvista.com>
>>> ---
>>>  drivers/net/ibm_newemac/core.c |   16 +++++++++++++++-
>>>  drivers/net/ibm_newemac/core.h |    8 ++++++--
>>>  2 files changed, 21 insertions(+), 3 deletions(-)
>> is this for 2.6.25-rc?
> 
> Jeff, can I get an ack from you on this patch, and patch 2 in this
> set?  They depend on a patch in my tree and I'd like to include them in
> my next push to Paul for 2.6.26.

ACK

I had queried the status of these patches, and didn't receive any reply 
initially from my query...

^ permalink raw reply

* [PATCH 5/5] WDT driver
From: Sean MacLennan @ 2008-04-12 18:11 UTC (permalink / raw)
  To: linuxppc-dev
In-Reply-To: <20080412134831.424480cf@lappy.seanm.ca>

Signed-off-by: Sean MacLennan <smaclennan@pikatech.com>

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 254d115..e73a3ea 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -697,6 +697,14 @@ config BOOKE_WDT
 	  Please see Documentation/watchdog/watchdog-api.txt for
 	  more information.
 
+config PIKA_WDT
+	tristate "PIKA FPGA Watchdog"
+	depends on WARP
+	default y
+	help
+	 This enables the watchdog in the PIKA FPGA. Currently used on
+	 the Warp platform.
+
 # PPC64 Architecture
 
 config WATCHDOG_RTAS
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index f3fb170..09758c5 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -105,6 +105,7 @@ obj-$(CONFIG_MPC5200_WDT) += mpc5200_wdt.o
 obj-$(CONFIG_83xx_WDT) += mpc83xx_wdt.o
 obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o
 obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o
+obj-$(CONFIG_PIKA_WDT) += pika_wdt.o
 
 # PPC64 Architecture
 obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o
diff --git a/drivers/watchdog/pika_wdt.c b/drivers/watchdog/pika_wdt.c
new file mode 100644
index 0000000..b84ac07
--- /dev/null
+++ b/drivers/watchdog/pika_wdt.c
@@ -0,0 +1,113 @@
+/*
+ * PIKA FPGA based Watchdog Timer
+ *
+ * Copyright (c) 2008 PIKA Technologies
+ *   Sean MacLennan <smaclennan at pikatech.com>
+ */
+
+#include <linux/module.h>
+#include <linux/fs.h>
+#include <linux/miscdevice.h>
+#include <linux/reboot.h>
+#include <linux/uaccess.h>
+#include <linux/io.h>
+#include <linux/of_platform.h>
+#include <linux/watchdog.h>
+
+
+static void __iomem *pikawdt_fpga;
+
+
+static inline void pikawdt_ping(void)
+{
+	unsigned reset = in_be32(pikawdt_fpga + 0x14);
+	reset |= 0xf80; /* enable with max timeout - 15 seconds */
+	out_be32(pikawdt_fpga + 0x14, reset);
+}
+
+static int pikawdt_open(struct inode *inode, struct file *file)
+{
+	printk(KERN_INFO "PIKA WDT started...\n");
+
+	pikawdt_ping();
+
+	return 0;
+}
+
+static int pikawdt_release(struct inode *inode, struct file *file)
+{
+	pikawdt_ping(); /* one last time */
+	return 0;
+}
+
+static ssize_t pikawdt_write(struct file *file, const char __user *buf,
+			     size_t count, loff_t *ppos)
+{
+	pikawdt_ping();
+	return count;
+}
+
+/* We support the bare minimum to be conformant. */
+static int pikawdt_ioctl(struct inode *inode, struct file *file,
+			 unsigned int cmd, unsigned long arg)
+{
+	if (cmd == WDIOC_KEEPALIVE) {
+		pikawdt_ping();
+		return 0;
+	} else
+		return -EINVAL;
+}
+
+static const struct file_operations pikawdt_fops = {
+	.owner		= THIS_MODULE,
+	.open		= pikawdt_open,
+	.release	= pikawdt_release,
+	.write		= pikawdt_write,
+	.ioctl		= pikawdt_ioctl,
+};
+
+static struct miscdevice pikawdt_miscdev = {
+	.minor	= WATCHDOG_MINOR,
+	.name	= "watchdog",
+	.fops	= &pikawdt_fops,
+};
+
+static int __init pikawdt_init(void)
+{
+	struct device_node *np;
+	int ret;
+
+	np = of_find_compatible_node(NULL, NULL, "pika,fpga");
+	if (np == NULL) {
+		printk(KERN_ERR "pikawdt: Unable to find fpga.\n");
+		return -ENOENT;
+	}
+
+	pikawdt_fpga = of_iomap(np, 0);
+
+	of_node_put(np);
+
+	if (pikawdt_fpga == NULL) {
+		printk(KERN_ERR "pikawdt: Unable to map fpga.\n");
+		return -ENOENT;
+	}
+
+	ret = misc_register(&pikawdt_miscdev);
+	if (ret) {
+		iounmap(pikawdt_fpga);
+		printk(KERN_ERR "pikawdt: Unable to register miscdev.\n");
+		return ret;
+	}
+
+	return 0;
+}
+module_init(pikawdt_init);
+
+
+static void __exit pikawdt_exit(void)
+{
+	misc_deregister(&pikawdt_miscdev);
+
+	iounmap(pikawdt_fpga);
+}
+module_exit(pikawdt_exit);

^ permalink raw reply related

* [PATCH 4/5] LED driver
From: Sean MacLennan @ 2008-04-12 18:10 UTC (permalink / raw)
  To: linuxppc-dev
In-Reply-To: <20080412134831.424480cf@lappy.seanm.ca>

Signed-off-by: Sean MacLennan <smaclennan@pikatech.com>

diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 859814f..31e1746 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -145,6 +145,12 @@ config LEDS_CLEVO_MAIL
 	  To compile this driver as a module, choose M here: the
 	  module will be called leds-clevo-mail.
 
+config LEDS_WARP
+	tristate "LED Support for the PIKA Warp LEDs"
+	depends on LEDS_CLASS && WARP
+	help
+	  This option enables support for the PIKA Warp LEDs.
+
 comment "LED Triggers"
 
 config LEDS_TRIGGERS
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index 84ced3b..eb60fb1 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -21,6 +21,7 @@ obj-$(CONFIG_LEDS_GPIO)			+= leds-gpio.o
 obj-$(CONFIG_LEDS_CM_X270)              += leds-cm-x270.o
 obj-$(CONFIG_LEDS_CLEVO_MAIL)		+= leds-clevo-mail.o
 obj-$(CONFIG_LEDS_HP6XX)		+= leds-hp6xx.o
+obj-$(CONFIG_LEDS_WARP)			+= leds-warp.o
 
 # LED Triggers
 obj-$(CONFIG_LEDS_TRIGGER_TIMER)	+= ledtrig-timer.o
diff --git a/drivers/leds/leds-warp.c b/drivers/leds/leds-warp.c
new file mode 100644
index 0000000..0fbe0b7
--- /dev/null
+++ b/drivers/leds/leds-warp.c
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2008 PIKA Technologies
+ *   Sean MacLennan <smaclennan at pikatech.com>
+ *
+ * This is just a temporary driver until the GPIO/GPIO_OF_LEDS drivers
+ * get sorted out.
+ */
+#include <linux/module.h>
+#include <linux/leds.h>
+#include <linux/of_platform.h>
+#include <asm/machdep.h>
+
+
+#define LED_GREEN (0x80000000 >> 0)
+#define LED_RED   (0x80000000 >> 1)
+
+static void __iomem *gpio_base;
+
+
+static void warp_green_set(struct led_classdev *led_cdev,
+			   enum led_brightness brightness)
+{
+	unsigned leds = in_be32(gpio_base);
+
+	if (brightness)
+		leds |=  LED_GREEN;
+	else
+		leds &= ~LED_GREEN;
+
+	out_be32(gpio_base, leds);
+}
+
+static void warp_red_set(struct led_classdev *led_cdev,
+			 enum led_brightness brightness)
+{
+	unsigned leds = in_be32(gpio_base);
+
+	if (brightness)
+		leds |=  LED_RED;
+	else
+		leds &= ~LED_RED;
+
+	out_be32(gpio_base, leds);
+}
+
+static struct led_classdev warp_green_led = {
+	.name = "warp-green",
+	.brightness_set = warp_green_set,
+};
+
+static struct led_classdev warp_red_led = {
+	.name = "warp-red",
+	.brightness_set = warp_red_set,
+};
+
+static int __devinit warp_led_probe(struct platform_device *pdev)
+{
+	struct device_node *np;
+	int rc;
+
+	/* Power LEDS are on the second GPIO controller */
+	np = of_find_compatible_node(NULL, NULL, "ibm,gpio-440EP");
+	if (np)
+		np = of_find_compatible_node(np, NULL, "ibm,gpio-440EP");
+	if (np == NULL) {
+		printk(KERN_ERR __FILE__ ": Unable to find gpio\n");
+		return -ENOENT;
+	}
+
+	gpio_base = of_iomap(np, 0);
+	of_node_put(np);
+	if (gpio_base == NULL) {
+		printk(KERN_ERR __FILE__ ": Unable to map gpio");
+		return -ENOMEM;
+	}
+
+	rc = led_classdev_register(&pdev->dev, &warp_green_led);
+	if (rc) {
+		iounmap(gpio_base);
+		return rc;
+	}
+
+	rc = led_classdev_register(&pdev->dev, &warp_red_led);
+	if (rc) {
+		led_classdev_unregister(&warp_green_led);
+		iounmap(gpio_base);
+		return rc;
+	}
+
+	return 0;
+}
+
+static int __devexit warp_led_remove(struct platform_device *pdev)
+{
+	led_classdev_unregister(&warp_green_led);
+	led_classdev_unregister(&warp_red_led);
+
+	iounmap(gpio_base);
+
+	return 0;
+}
+
+/* We *must* have a release. */
+static void warp_led_release(struct device *dev) {}
+
+static struct platform_driver warp_led_driver = {
+	.probe	 = warp_led_probe,
+	.remove	 = __devexit_p(warp_led_remove),
+	.driver	 = {
+		.name	= "warp-led",
+	},
+};
+
+static struct platform_device warp_led_device = {
+	.name   = "warp-led",
+	.id     = 0,
+	.dev = {
+		.release = warp_led_release,
+	},
+};
+
+static int __init warp_led_init(void)
+{
+	int rc;
+
+	rc = platform_device_register(&warp_led_device);
+	if (rc)
+		return rc;
+	rc = platform_driver_register(&warp_led_driver);
+	if (rc) {
+		platform_device_unregister(&warp_led_device);
+		return rc;
+	}
+
+	return 0;
+}
+
+static void __exit warp_led_exit(void)
+{
+	platform_driver_unregister(&warp_led_driver);
+	platform_device_unregister(&warp_led_device);
+}
+
+module_init(warp_led_init);
+module_exit(warp_led_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Sean MacLennan <smaclennan@pikatech.com>");

^ permalink raw reply related

* [PATCH 3/5] Defconfig
From: Sean MacLennan @ 2008-04-12 18:09 UTC (permalink / raw)
  To: linuxppc-dev
In-Reply-To: <20080412134831.424480cf@lappy.seanm.ca>

Signed-off-by: Sean MacLennan <smaclennan@pikatech.com>

diff --git a/arch/powerpc/configs/warp_defconfig b/arch/powerpc/configs/warp_defconfig
index 2313c3e..91b9fb1 100644
--- a/arch/powerpc/configs/warp_defconfig
+++ b/arch/powerpc/configs/warp_defconfig
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.25-rc2
-# Fri Feb 15 21:54:43 2008
+# Linux kernel version: 2.6.25-rc6
+# Tue Apr  8 02:27:53 2008
 #
 # CONFIG_PPC64 is not set
 
@@ -79,6 +79,7 @@ CONFIG_FAIR_GROUP_SCHED=y
 CONFIG_USER_SCHED=y
 # CONFIG_CGROUP_SCHED is not set
 CONFIG_SYSFS_DEPRECATED=y
+CONFIG_SYSFS_DEPRECATED_V2=y
 # CONFIG_RELAY is not set
 # CONFIG_NAMESPACES is not set
 CONFIG_BLK_DEV_INITRD=y
@@ -112,6 +113,7 @@ CONFIG_SLAB=y
 CONFIG_HAVE_OPROFILE=y
 # CONFIG_KPROBES is not set
 CONFIG_HAVE_KPROBES=y
+CONFIG_HAVE_KRETPROBES=y
 CONFIG_PROC_PAGE_MONITOR=y
 CONFIG_SLABINFO=y
 CONFIG_RT_MUTEXES=y
@@ -142,7 +144,6 @@ CONFIG_DEFAULT_AS=y
 # CONFIG_DEFAULT_NOOP is not set
 CONFIG_DEFAULT_IOSCHED="anticipatory"
 CONFIG_CLASSIC_RCU=y
-# CONFIG_PREEMPT_RCU is not set
 
 #
 # Platform support
@@ -159,6 +160,8 @@ CONFIG_CLASSIC_RCU=y
 # CONFIG_KATMAI is not set
 # CONFIG_RAINIER is not set
 CONFIG_WARP=y
+# CONFIG_CANYONLANDS is not set
+# CONFIG_YOSEMITE is not set
 CONFIG_440EP=y
 CONFIG_IBM440EP_ERR42=y
 # CONFIG_IPIC is not set
@@ -191,7 +194,6 @@ CONFIG_HZ=1000
 CONFIG_PREEMPT_NONE=y
 # CONFIG_PREEMPT_VOLUNTARY is not set
 # CONFIG_PREEMPT is not set
-CONFIG_RCU_TRACE=y
 CONFIG_BINFMT_ELF=y
 # CONFIG_BINFMT_MISC is not set
 # CONFIG_MATH_EMULATION is not set
@@ -224,6 +226,7 @@ CONFIG_ISA_DMA_API=y
 # Bus options
 #
 CONFIG_ZONE_DMA=y
+CONFIG_4xx_SOC=y
 # CONFIG_PCI is not set
 # CONFIG_PCI_DOMAINS is not set
 # CONFIG_PCI_SYSCALL is not set
@@ -380,7 +383,7 @@ CONFIG_MTD_BLOCK=y
 # CONFIG_INFTL is not set
 # CONFIG_RFD_FTL is not set
 # CONFIG_SSFDC is not set
-CONFIG_MTD_OOPS=m
+# CONFIG_MTD_OOPS is not set
 
 #
 # RAM/ROM/Flash chip drivers
@@ -434,6 +437,7 @@ CONFIG_MTD_NAND=y
 CONFIG_MTD_NAND_ECC_SMC=y
 # CONFIG_MTD_NAND_MUSEUM_IDS is not set
 CONFIG_MTD_NAND_IDS=y
+CONFIG_MTD_NAND_NDFC=y
 # CONFIG_MTD_NAND_DISKONCHIP is not set
 # CONFIG_MTD_NAND_NANDSIM is not set
 # CONFIG_MTD_NAND_PLATFORM is not set
@@ -493,7 +497,7 @@ CONFIG_BLK_DEV_SD=y
 # CONFIG_SCSI_CONSTANTS is not set
 # CONFIG_SCSI_LOGGING is not set
 # CONFIG_SCSI_SCAN_ASYNC is not set
-CONFIG_SCSI_WAIT_SCAN=m
+# CONFIG_SCSI_WAIT_SCAN is not set
 
 #
 # SCSI Transports
@@ -617,6 +621,7 @@ CONFIG_I2C_BOARDINFO=y
 #
 # I2C Hardware Bus support
 #
+CONFIG_I2C_IBM_IIC=y
 # CONFIG_I2C_MPC is not set
 # CONFIG_I2C_OCORES is not set
 # CONFIG_I2C_PARPORT_LIGHT is not set
@@ -650,6 +655,7 @@ CONFIG_SENSORS_EEPROM=y
 # CONFIG_POWER_SUPPLY is not set
 CONFIG_HWMON=y
 # CONFIG_HWMON_VID is not set
+CONFIG_SENSORS_AD7414=y
 # CONFIG_SENSORS_AD7418 is not set
 # CONFIG_SENSORS_ADM1021 is not set
 # CONFIG_SENSORS_ADM1025 is not set
@@ -658,6 +664,7 @@ CONFIG_HWMON=y
 # CONFIG_SENSORS_ADM1031 is not set
 # CONFIG_SENSORS_ADM9240 is not set
 # CONFIG_SENSORS_ADT7470 is not set
+# CONFIG_SENSORS_ADT7473 is not set
 # CONFIG_SENSORS_ATXP1 is not set
 # CONFIG_SENSORS_DS1621 is not set
 # CONFIG_SENSORS_F71805F is not set
@@ -698,7 +705,20 @@ CONFIG_HWMON=y
 # CONFIG_SENSORS_W83627EHF is not set
 # CONFIG_HWMON_DEBUG_CHIP is not set
 CONFIG_THERMAL=y
-# CONFIG_WATCHDOG is not set
+CONFIG_WATCHDOG=y
+# CONFIG_WATCHDOG_NOWAYOUT is not set
+
+#
+# Watchdog Device Drivers
+#
+# CONFIG_SOFT_WATCHDOG is not set
+# CONFIG_BOOKE_WDT is not set
+CONFIG_PIKA_WDT=y
+
+#
+# USB-based Watchdog Cards
+#
+# CONFIG_USBPCWATCHDOG is not set
 
 #
 # Sonics Silicon Backplane
@@ -826,14 +846,14 @@ CONFIG_USB_MON=y
 # CONFIG_USB_TRANCEVIBRATOR is not set
 # CONFIG_USB_IOWARRIOR is not set
 # CONFIG_USB_GADGET is not set
-CONFIG_MMC=m
+CONFIG_MMC=y
 # CONFIG_MMC_DEBUG is not set
 # CONFIG_MMC_UNSAFE_RESUME is not set
 
 #
 # MMC/SD Card Drivers
 #
-CONFIG_MMC_BLOCK=m
+CONFIG_MMC_BLOCK=y
 CONFIG_MMC_BLOCK_BOUNCE=y
 # CONFIG_SDIO_UART is not set
 
@@ -841,10 +861,23 @@ CONFIG_MMC_BLOCK_BOUNCE=y
 # MMC/SD Host Controller Drivers
 #
 # CONFIG_MMC_WBSD is not set
+CONFIG_MMC_PIKASD=y
 # CONFIG_MEMSTICK is not set
-# CONFIG_NEW_LEDS is not set
+CONFIG_NEW_LEDS=y
+CONFIG_LEDS_CLASS=y
+
+#
+# LED drivers
+#
+CONFIG_LEDS_WARP=y
+
+#
+# LED Triggers
+#
+# CONFIG_LEDS_TRIGGERS is not set
 # CONFIG_EDAC is not set
 # CONFIG_RTC_CLASS is not set
+# CONFIG_DMADEVICES is not set
 
 #
 # Userspace I/O
@@ -896,7 +929,8 @@ CONFIG_PROC_FS=y
 CONFIG_PROC_KCORE=y
 CONFIG_PROC_SYSCTL=y
 CONFIG_SYSFS=y
-# CONFIG_TMPFS is not set
+CONFIG_TMPFS=y
+# CONFIG_TMPFS_POSIX_ACL is not set
 # CONFIG_HUGETLB_PAGE is not set
 # CONFIG_CONFIGFS_FS is not set
 
@@ -1013,6 +1047,7 @@ CONFIG_PLIST=y
 CONFIG_HAS_IOMEM=y
 CONFIG_HAS_IOPORT=y
 CONFIG_HAS_DMA=y
+CONFIG_HAVE_LMB=y
 
 #
 # Kernel hacking
@@ -1022,7 +1057,7 @@ CONFIG_ENABLE_WARN_DEPRECATED=y
 CONFIG_ENABLE_MUST_CHECK=y
 CONFIG_MAGIC_SYSRQ=y
 # CONFIG_UNUSED_SYMBOLS is not set
-CONFIG_DEBUG_FS=y
+# CONFIG_DEBUG_FS is not set
 # CONFIG_HEADERS_CHECK is not set
 CONFIG_DEBUG_KERNEL=y
 # CONFIG_DEBUG_SHIRQ is not set
@@ -1052,7 +1087,6 @@ CONFIG_DEBUG_INFO=y
 # CONFIG_DEBUG_STACK_USAGE is not set
 # CONFIG_DEBUG_PAGEALLOC is not set
 # CONFIG_DEBUGGER is not set
-# CONFIG_VIRQ_DEBUG is not set
 CONFIG_BDI_SWITCH=y
 # CONFIG_PPC_EARLY_DEBUG is not set
 

^ permalink raw reply related

* PATCH 2/5] Platform code
From: Sean MacLennan @ 2008-04-12 18:03 UTC (permalink / raw)
  To: linuxppc-dev
In-Reply-To: <20080412134831.424480cf@lappy.seanm.ca>

Signed-off-by: Sean MacLennan <smaclennan@pikatech.com>

diff --git a/arch/powerpc/platforms/44x/warp-nand.c b/arch/powerpc/platforms/44x/warp-nand.c
index 9150318..f70019d 100644
--- a/arch/powerpc/platforms/44x/warp-nand.c
+++ b/arch/powerpc/platforms/44x/warp-nand.c
@@ -2,7 +2,7 @@
  * PIKA Warp(tm) NAND flash specific routines
  *
  * Copyright (c) 2008 PIKA Technologies
- *   Sean MacLennan <smaclennan@pikatech.com>
+ *   Sean MacLennan <smaclennan at pikatech.com>
  */
 
 #include <linux/platform_device.h>
@@ -11,8 +11,10 @@
 #include <linux/mtd/partitions.h>
 #include <linux/mtd/nand.h>
 #include <linux/mtd/ndfc.h>
+#include <linux/of_platform.h>
 #include <asm/machdep.h>
 
+
 #ifdef CONFIG_MTD_NAND_NDFC
 
 #define CS_NAND_0	1	/* use chip select 1 for NAND device 0 */
@@ -35,13 +37,23 @@ static struct mtd_partition nand_parts[] = {
 	{
 		.name   = "root",
 		.offset = 0x0200000,
-		.size   = 0x3400000
+		.size   = 0x3E00000
+	},
+	{
+		.name   = "persistent",
+		.offset = 0x4000000,
+		.size   = 0x4000000
 	},
 	{
-		.name   = "user",
-		.offset = 0x3600000,
-		.size   = 0x0A00000
+		.name   = "persistent1",
+		.offset = 0x8000000,
+		.size   = 0x4000000
 	},
+	{
+		.name   = "persistent2",
+		.offset = 0xC000000,
+		.size   = 0x4000000
+	}
 };
 
 struct ndfc_controller_settings warp_ndfc_settings = {
@@ -67,19 +79,15 @@ static struct platform_device warp_ndfc_device = {
 	.resource = &warp_ndfc,
 };
 
-static struct nand_ecclayout nand_oob_16 = {
-	.eccbytes = 3,
-	.eccpos = { 0, 1, 2, 3, 6, 7 },
-	.oobfree = { {.offset = 8, .length = 16} }
-};
-
+/* Do NOT set the ecclayout: let it default so it is correct for both
+ * 64M and 256M flash chips.
+ */
 static struct platform_nand_chip warp_nand_chip0 = {
 	.nr_chips = 1,
 	.chip_offset = CS_NAND_0,
 	.nr_partitions = ARRAY_SIZE(nand_parts),
 	.partitions = nand_parts,
-	.chip_delay = 50,
-	.ecclayout = &nand_oob_16,
+	.chip_delay = 20,
 	.priv = &warp_chip0_settings,
 };
 
@@ -96,6 +104,23 @@ static struct platform_device warp_nand_device = {
 
 static int warp_setup_nand_flash(void)
 {
+	struct device_node *np;
+
+	/* Try to detect a rev A based on NOR size. */
+	np = of_find_compatible_node(NULL, NULL, "cfi-flash");
+	if (np) {
+		struct property *pp;
+
+		pp = of_find_property(np, "reg", NULL);
+		if (pp && (pp->length == 12)) {
+			u32 *v = pp->value;
+			if (v[2] == 0x4000000)
+				/* Rev A = 64M NAND */
+				warp_nand_chip0.nr_partitions = 2;
+		}
+		of_node_put(np);
+	}
+
 	platform_device_register(&warp_ndfc_device);
 	platform_device_register(&warp_nand_device);
 
diff --git a/arch/powerpc/platforms/44x/warp.c b/arch/powerpc/platforms/44x/warp.c
index 39cf615..6deffad 100644
--- a/arch/powerpc/platforms/44x/warp.c
+++ b/arch/powerpc/platforms/44x/warp.c
@@ -2,7 +2,7 @@
  * PIKA Warp(tm) board specific routines
  *
  * Copyright (c) 2008 PIKA Technologies
- *   Sean MacLennan <smaclennan@pikatech.com>
+ *   Sean MacLennan <smaclennan at pikatech.com>
  *
  * 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
@@ -12,6 +12,9 @@
 #include <linux/init.h>
 #include <linux/of_platform.h>
 #include <linux/kthread.h>
+#include <linux/i2c.h>
+#include <linux/interrupt.h>
+#include <linux/pika.h>
 
 #include <asm/machdep.h>
 #include <asm/prom.h>
@@ -27,6 +30,18 @@ static __initdata struct of_device_id warp_of_bus[] = {
 	{},
 };
 
+static __initdata struct i2c_board_info warp_i2c_info[] = {
+	{ I2C_BOARD_INFO("ad7414", 0x4a) }
+};
+
+static int __init warp_arch_init(void)
+{
+	/* This should go away once support is moved to the dts. */
+	i2c_register_board_info(0, warp_i2c_info, ARRAY_SIZE(warp_i2c_info));
+	return 0;
+}
+machine_arch_initcall(warp, warp_arch_init);
+
 static int __init warp_device_probe(void)
 {
 	of_platform_bus_probe(NULL, warp_of_bus, NULL);
@@ -52,61 +67,183 @@ define_machine(warp) {
 };
 
 
-#define LED_GREEN (0x80000000 >> 0)
-#define LED_RED   (0x80000000 >> 1)
+/* I am not sure this is the best place for this... */
+static int __init warp_post_info(void)
+{
+	struct device_node *np;
+	void __iomem *fpga;
+	u32 post1, post2;
+
+	/* Sighhhh... POST information is in the sd area. */
+	np = of_find_compatible_node(NULL, NULL, "pika,fpga-sd");
+	if (np == NULL)
+		return -ENOENT;
+
+	fpga = of_iomap(np, 0);
+	of_node_put(np);
+	if (fpga == NULL)
+		return -ENOENT;
+
+	post1 = in_be32(fpga + 0x40);
+	post2 = in_be32(fpga + 0x44);
+
+	iounmap(fpga);
+
+	if (post1 || post2)
+		printk(KERN_INFO "Warp POST %08x %08x\n", post1, post2);
+	else
+		printk(KERN_INFO "Warp POST OK\n");
+
+	return 0;
+}
+machine_late_initcall(warp, warp_post_info);
+
+
+#ifdef CONFIG_SENSORS_AD7414
+
+static LIST_HEAD(dtm_shutdown_list);
+static void __iomem *dtm_fpga;
+
+struct dtm_shutdown {
+	struct list_head list;
+	void (*func)(void *arg);
+	void *arg;
+};
+
+
+int dtm_register_shutdown(void (*func)(void *arg), void *arg)
+{
+	struct dtm_shutdown *shutdown;
+
+	shutdown = kmalloc(sizeof(struct dtm_shutdown), GFP_KERNEL);
+	if (shutdown == NULL)
+		return -ENOMEM;
+
+	shutdown->func = func;
+	shutdown->arg = arg;
 
+	list_add(&shutdown->list, &dtm_shutdown_list);
+
+	return 0;
+}
+EXPORT_SYMBOL(dtm_register_shutdown);
 
-/* This is for the power LEDs 1 = on, 0 = off, -1 = leave alone */
-void warp_set_power_leds(int green, int red)
+int dtm_unregister_shutdown(void (*func)(void *arg), void *arg)
 {
-	static void __iomem *gpio_base = NULL;
-	unsigned leds;
-
-	if (gpio_base == NULL) {
-		struct device_node *np;
-
-		/* Power LEDS are on the second GPIO controller */
-		np = of_find_compatible_node(NULL, NULL, "ibm,gpio-440EP");
-		if (np)
-			np = of_find_compatible_node(np, NULL, "ibm,gpio-440EP");
-		if (np == NULL) {
-			printk(KERN_ERR __FILE__ ": Unable to find gpio\n");
-			return;
-		}
+	struct dtm_shutdown *shutdown;
 
-		gpio_base = of_iomap(np, 0);
-		of_node_put(np);
-		if (gpio_base == NULL) {
-			printk(KERN_ERR __FILE__ ": Unable to map gpio");
-			return;
+	list_for_each_entry(shutdown, &dtm_shutdown_list, list)
+		if (shutdown->func == func && shutdown->arg == arg) {
+			list_del(&shutdown->list);
+			kfree(shutdown);
+			return 0;
 		}
+
+	return -EINVAL;
+}
+EXPORT_SYMBOL(dtm_unregister_shutdown);
+
+static long wdt_keepalive(long time)
+{
+	if (dtm_fpga) {
+		unsigned reset = in_be32(dtm_fpga + 0x14);
+		out_be32(dtm_fpga + 0x14, reset);
 	}
 
-	leds = in_be32(gpio_base);
+	return 0;
+}
+
+static irqreturn_t temp_isr(int irq, void *context)
+{
+	struct dtm_shutdown *shutdown;
+
+	/* Run through the shutdown list. */
+	list_for_each_entry(shutdown, &dtm_shutdown_list, list)
+		shutdown->func(shutdown->arg);
+
+	panic_timeout = 1800;
+	panic_blink = wdt_keepalive;
+	panic("Critical Temperature Shutdown");
+	return IRQ_HANDLED;
+}
+
+static void pika_setup_critical_temp(struct i2c_client *client)
+{
+	struct device_node *np;
+	int irq, rc;
+
+	/* These registers are in 1 degree increments. */
+	i2c_smbus_write_byte_data(client, 2, 55); /* Thigh */
+	i2c_smbus_write_byte_data(client, 3, 50); /* Tlow */
 
-	switch (green) {
-	case 0: leds &= ~LED_GREEN; break;
-	case 1: leds |=  LED_GREEN; break;
+	np = of_find_compatible_node(NULL, NULL, "adi,ad7414");
+	if (np == NULL) {
+		printk(KERN_ERR __FILE__ ": Unable to find ad7414\n");
+		return;
 	}
-	switch (red) {
-	case 0: leds &= ~LED_RED; break;
-	case 1: leds |=  LED_RED; break;
+
+	irq = irq_of_parse_and_map(np, 0);
+	of_node_put(np);
+	if (irq  == NO_IRQ) {
+		printk(KERN_ERR __FILE__ ": Unable to get ad7414 irq\n");
+		return;
 	}
 
-	out_be32(gpio_base, leds);
+	rc = request_irq(irq, temp_isr, 0, "ad7414", NULL);
+	if (rc) {
+		printk(KERN_ERR __FILE__
+		       ": Unable to request ad7414 irq %d = %d\n", irq, rc);
+		return;
+	}
 }
-EXPORT_SYMBOL(warp_set_power_leds);
 
+static inline void pika_dtm_check_fan(void __iomem *fpga)
+{
+	static int fan_state;
+	u32 fan = in_be32(fpga + 0x34) & (1 << 14);
+
+	if (fan_state != fan) {
+		fan_state = fan;
+		if (fan)
+			printk(KERN_WARNING "Fan rotation error detected."
+				   " Please check hardware.\n");
+	}
+}
 
-#ifdef CONFIG_SENSORS_AD7414
 static int pika_dtm_thread(void __iomem *fpga)
 {
-	extern int ad7414_get_temp(int index);
+	struct i2c_adapter *adap;
+	struct i2c_client *client;
+
+	/* We loop in case either driver was compiled as a module and
+	 * has not been insmoded yet.
+	 */
+	while (!(adap = i2c_get_adapter(0))) {
+		set_current_state(TASK_INTERRUPTIBLE);
+		schedule_timeout(HZ);
+	}
+
+	while (1) {
+		list_for_each_entry(client, &adap->clients, list)
+			if (client->addr == 0x4a)
+				goto found_it;
+
+		set_current_state(TASK_INTERRUPTIBLE);
+		schedule_timeout(HZ);
+	}
+
+found_it:
+	i2c_put_adapter(adap);
+
+	pika_setup_critical_temp(client);
+
+	printk(KERN_INFO "PIKA DTM thread running.\n");
 
 	while (!kthread_should_stop()) {
-		int temp = ad7414_get_temp(0);
+		u16 temp = swab16(i2c_smbus_read_word_data(client, 0));
+		out_be32(fpga + 0x20, temp);
 
-		out_be32(fpga, temp);
+		pika_dtm_check_fan(fpga);
 
 		set_current_state(TASK_INTERRUPTIBLE);
 		schedule_timeout(HZ);
@@ -115,37 +252,28 @@ static int pika_dtm_thread(void __iomem *fpga)
 	return 0;
 }
 
+
 static int __init pika_dtm_start(void)
 {
 	struct task_struct *dtm_thread;
 	struct device_node *np;
-	struct resource res;
-	void __iomem *fpga;
 
 	np = of_find_compatible_node(NULL, NULL, "pika,fpga");
 	if (np == NULL)
 		return -ENOENT;
 
-	/* We do not call of_iomap here since it would map in the entire
-	 * fpga space, which is over 8k.
-	 */
-	if (of_address_to_resource(np, 0, &res)) {
-		of_node_put(np);
-		return -ENOENT;
-	}
+	dtm_fpga = of_iomap(np, 0);
 	of_node_put(np);
-
-	fpga = ioremap(res.start, 0x24);
-	if (fpga == NULL)
+	if (dtm_fpga == NULL)
 		return -ENOENT;
 
-	dtm_thread = kthread_run(pika_dtm_thread, fpga + 0x20, "pika-dtm");
+	dtm_thread = kthread_run(pika_dtm_thread, dtm_fpga, "pika-dtm");
 	if (IS_ERR(dtm_thread)) {
-		iounmap(fpga);
+		iounmap(dtm_fpga);
 		return PTR_ERR(dtm_thread);
 	}
 
 	return 0;
 }
-device_initcall(pika_dtm_start);
+machine_late_initcall(warp, pika_dtm_start);
 #endif

^ permalink raw reply related

* [PATCH 1/5] Boot code
From: Sean MacLennan @ 2008-04-12 18:01 UTC (permalink / raw)
  To: linuxppc-dev
In-Reply-To: <20080412134831.424480cf@lappy.seanm.ca>

Signed-off-by: Sean MacLennan <smaclennan@pikatech.com>

diff --git a/arch/powerpc/boot/cuboot-warp.c
b/arch/powerpc/boot/cuboot-warp.c index eb108a8..43d7ad9 100644
--- a/arch/powerpc/boot/cuboot-warp.c
+++ b/arch/powerpc/boot/cuboot-warp.c
@@ -10,6 +10,7 @@
 #include "ops.h"
 #include "4xx.h"
 #include "cuboot.h"
+#include "stdio.h"
 
 #define TARGET_4xx
 #define TARGET_44x
@@ -17,14 +18,54 @@
 
 static bd_t bd;
 
-static void warp_fixups(void)
+static void warp_fixup_one_nor(u32 from, u32 to)
 {
-	unsigned long sysclk = 66000000;
+	void *devp;
+	char name[40];
+	u32 v[2];
+
+	sprintf(name, "/plb/opb/ebc/nor_flash@0,0/partition@%x", from);
+
+	devp = finddevice(name);
+	if (!devp)
+		return;
+
+	if (getprop(devp, "reg", v, sizeof(v)) == sizeof(v)) {
+		v[0] = to;
+		setprop(devp, "reg", v, sizeof(v));
+
+		printf("NOR 64M fixup %x -> %x\r\n", from, to);
+	}
+}
+
 
-	ibm440ep_fixup_clocks(sysclk, 11059200, 50000000);
+static void warp_fixups(void)
+{
+	ibm440ep_fixup_clocks(66000000, 11059200, 50000000);
 	ibm4xx_sdram_fixup_memsize();
 	ibm4xx_fixup_ebc_ranges("/plb/opb/ebc");
 	dt_fixup_mac_address_by_alias("ethernet0", bd.bi_enetaddr);
+
+	/* Fixup for 64M flash on Rev A boards. */
+	if (bd.bi_flashsize == 0x4000000) {
+		void *devp;
+		u32 v[3];
+
+		devp = finddevice("/plb/opb/ebc/nor_flash@0,0");
+		if (!devp)
+			return;
+
+		/* Fixup the size */
+		if (getprop(devp, "reg", v, sizeof(v)) == sizeof(v)) {
+			v[2] = bd.bi_flashsize;
+			setprop(devp, "reg", v, sizeof(v));
+		}
+
+		/* Fixup parition offsets */
+		warp_fixup_one_nor(0x300000, 0x3f00000);
+		warp_fixup_one_nor(0x340000, 0x3f40000);
+		warp_fixup_one_nor(0x380000, 0x3f80000);
+	}
 }
 
 
diff --git a/arch/powerpc/boot/dts/warp.dts
b/arch/powerpc/boot/dts/warp.dts index b04a52e..fa070b0 100644
--- a/arch/powerpc/boot/dts/warp.dts
+++ b/arch/powerpc/boot/dts/warp.dts
@@ -132,40 +132,33 @@
 
 				fpga@2,0 {
 					compatible = "pika,fpga";
-			   		reg = <2 0 2200>;
+			   		reg = <2 0 1000>;
 					interrupts = <18 8>;
 					interrupt-parent = <&UIC0>;
 				};
 
+				fpga@2,4000 {
+					compatible = "pika,fpga-sd";
+					reg = <2 4000 A00>;
+				};
+
 				nor_flash@0,0 {
-					compatible = "amd,s29gl512n",
"cfi-flash";
+					compatible = "amd,s29gl032a",
"cfi-flash"; bank-width = <2>;
-					reg = <0 0 4000000>;
+					reg = <0 0 400000>;
 					#address-cells = <1>;
 					#size-cells = <1>;
-					partition@0 {
-						label = "kernel";
-						reg = <0 180000>;
-					};
-					partition@180000 {
-						label = "root";
-						reg = <180000 3480000>;
-					};
-					partition@3600000 {
-						label = "user";
-						reg = <3600000 900000>;
-					};
-					partition@3f00000 {
+					partition@300000 {
 						label = "fpga";
-						reg = <3f00000 40000>;
+						reg = <300000 40000>;
 					};
-					partition@3f40000 {
+					partition@340000 {
 						label = "env";
-						reg = <3f40000 40000>;
+						reg = <340000 40000>;
 					};
-					partition@3f80000 {
+					partition@380000 {
 						label = "u-boot";
-						reg = <3f80000 80000>;
+						reg = <380000 80000>;
 					};
 				};
 			};
@@ -186,6 +179,16 @@
 				reg = <ef600700 14>;
 				interrupt-parent = <&UIC0>;
 				interrupts = <2 4>;
+				index = <0>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				ad7414@4a {
+					compatible = "adi,ad7414";
+					reg = <4a>;
+					interrupts = <19 8>;
+					interrupt-parent = <&UIC0>;
+				};
 			};
 
 			GPIO0: gpio@ef600b00 {

^ permalink raw reply

* Warp patches for 2.6.26
From: Sean MacLennan @ 2008-04-12 17:48 UTC (permalink / raw)
  To: linuxppc-dev

I was going to hold off until the warp was officially released, but we
might miss the merge window. So here they are. A lot of work has been
done since 2.6.25 and I haven't been submitting patches to keep down on
the churn.

We standardized on a 4M NOR flash and a 256M NAND flash. But there is
still support for the original Rev A boards which where 64M NOR and 64M
NAND. You will see fixups for the Rev A. The Rev A is considered
obsolete and the fixups are only there for me to use good ol' Tigger.

ftp://ftp.seanm.ca/stuff/tigger.jpg

Here is the full list of files that need to be patched for a warp,
basically git diff --name-only origin/for-2.6.26:

arch/powerpc/boot/cuboot-warp.c
arch/powerpc/boot/dts/warp.dts
arch/powerpc/configs/warp_defconfig
arch/powerpc/platforms/44x/warp-nand.c
arch/powerpc/platforms/44x/warp.c

drivers/hwmon/Kconfig
drivers/hwmon/Makefile
drivers/hwmon/ad7414.c

drivers/i2c/busses/Kconfig
drivers/i2c/busses/i2c-ibm_iic.c

drivers/leds/Kconfig
drivers/leds/Makefile
drivers/leds/leds-warp.c

drivers/mmc/core/sd.c
drivers/mmc/host/Kconfig
drivers/mmc/host/Makefile
drivers/mmc/host/pikasd.c

drivers/mtd/nand/Kconfig
drivers/mtd/nand/ndfc.c

drivers/net/ibm_newemac/mal.c
drivers/net/ibm_newemac/zmii.c

drivers/scsi/Kconfig

drivers/watchdog/Kconfig
drivers/watchdog/Makefile
drivers/watchdog/pika_wdt.c

include/linux/mmc/host.h
include/linux/pika.h

I will not include patches for all of them since many haven't changed
and/or are waiting for submission to the kernel. So I have broken it up
into five patches.

I will submit any other patches people are interested in.

Cheers,
   Sean

^ permalink raw reply

* [PATCH] tg3: fix MMIO for PPC 44x platforms
From: Sergei Shtylyov @ 2008-04-12 17:01 UTC (permalink / raw)
  To: jgarzik; +Cc: netdev, linuxppc-dev

The driver stores the PCI resource addresses into 'unsigned long' variable
before calling ioremap_nocache() on them. This warrants kernel oops when the
registers are accessed on PPC 44x platforms which (being 32-bit) have PCI
memory space mapped beyond 4 GB.

The arch/ppc/ kernel has a fixup in ioremap() that creates an illusion that
the PCI memory resource is mapped below 4 GB, but arch/powerpc/ code got rid
of this trick, having instead CONFIG_RESOURCES_64BIT enabled.

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>

---
Reposting the patch with the log and summary corrected.
This is the same issue as the one that has been recently addressed by commits
3c34ac36ac1084e571ef9b6fb1d6a5b10ccc1fd0 (e1000: Fix for 32 bits platforms with
64 bits resources) and c976816b6e901341ec3c4653147316c15549a1c4 (siimage: fix
kernel oops on PPC 44x).  The patch has only been compile tested though...

 drivers/net/tg3.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)

Index: linux-2.6/drivers/net/tg3.c
===================================================================
--- linux-2.6.orig/drivers/net/tg3.c
+++ linux-2.6/drivers/net/tg3.c
@@ -12578,7 +12578,8 @@ static int __devinit tg3_init_one(struct
 				  const struct pci_device_id *ent)
 {
 	static int tg3_version_printed = 0;
-	unsigned long tg3reg_base, tg3reg_len;
+	resource_size_t tg3reg_base;
+	unsigned long tg3reg_len;
 	struct net_device *dev;
 	struct tg3 *tp;
 	int err, pm_cap;

^ permalink raw reply

* [PATCH] natsemi: fix MMIO for PPC 44x platforms
From: Sergei Shtylyov @ 2008-04-12 16:58 UTC (permalink / raw)
  To: jgarzik; +Cc: netdev, linuxppc-dev

The driver stores the PCI resource address into 'unsigned long' variable before
calling ioremap()  on it. This warrants a kernel oops when the registers are
accessed on PPC 44x platforms which (being 32-bit) have PCI memory space mapped
beyond 4 GB.

The arch/ppc/ kernel has a fixup in ioremap() that creates an illusion of the
PCI memory resources are mapped below 4 GB, but arch/powerpc/ code got rid of
this trick, having instead CONFIG_RESOURCES_64BIT enabled.

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>

---
Reposting the patch with the typecast, log, and summary corrected.
This is the same issue as the one that has been recently addressed by commits
3c34ac36ac1084e571ef9b6fb1d6a5b10ccc1fd0 (e1000: Fix for 32 bits platforms with
64 bits resources) and c976816b6e901341ec3c4653147316c15549a1c4 (siimage: fix
kernel oops on PPC 44x).  The patch has only been compile tested though...

 drivers/net/natsemi.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

Index: linux-2.6/drivers/net/natsemi.c
===================================================================
--- linux-2.6.orig/drivers/net/natsemi.c
+++ linux-2.6/drivers/net/natsemi.c
@@ -786,7 +786,8 @@ static int __devinit natsemi_probe1 (str
 	struct netdev_private *np;
 	int i, option, irq, chip_idx = ent->driver_data;
 	static int find_cnt = -1;
-	unsigned long iostart, iosize;
+	resource_size_t iostart;
+	unsigned long iosize;
 	void __iomem *ioaddr;
 	const int pcibar = 1; /* PCI base address register */
 	int prev_eedata;
@@ -946,10 +947,11 @@ static int __devinit natsemi_probe1 (str
 		goto err_create_file;
 
 	if (netif_msg_drv(np)) {
-		printk(KERN_INFO "natsemi %s: %s at %#08lx "
+		printk(KERN_INFO "natsemi %s: %s at %#08llx "
 		       "(%s), %s, IRQ %d",
-		       dev->name, natsemi_pci_info[chip_idx].name, iostart,
-		       pci_name(np->pci_dev), print_mac(mac, dev->dev_addr), irq);
+		       dev->name, natsemi_pci_info[chip_idx].name,
+		       (unsigned long long)iostart, pci_name(np->pci_dev),
+		       print_mac(mac, dev->dev_addr), irq);
 		if (dev->if_port == PORT_TP)
 			printk(", port TP.\n");
 		else if (np->ignore_phy)

^ permalink raw reply

* Re: [LMB][1/2] Fix some whitespace and other formatting issues, use pr_debug
From: Nick Andrew @ 2008-04-12 16:29 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev, linux-kernel, davem
In-Reply-To: <18432.18107.29491.115996@cargo.ozlabs.ibm.com>

On Sat, Apr 12, 2008 at 03:20:59PM +1000, Paul Mackerras wrote:
> +	pr_debug("\n    reserved.cnt	  = 0x%lx\n", lmb.reserved.cnt);

This will only output an empty line at KERN_DEBUG level and the rest
will be at default_message_loglevel. Problem is fixed my my patch in msg
<20080412161733.24882.30930.stgit@marcab.local.tull.net>

However, is a blank line in the log necessary?

Nick.

^ permalink raw reply

* Re: Flash on LocalBus @ MPC8343
From: André Schwarz @ 2008-04-12  8:58 UTC (permalink / raw)
  To: Scott Wood; +Cc: linux-ppc list
In-Reply-To: <47FFC397.9040200@freescale.com>

Scott,

thanks , but ... can't find "of_bus_ids[]" entry.
I'm obviously out of sync. My last git-pull from denx is 3 days old, now=20
- need to update on monday.

It seems hard for "normal" people to keep up these days !


Cheers,
Andr=C3=A9


Scott Wood wrote:
> Andr=C3=A9 Schwarz wrote:
>> Scott,
>>
>> thanks for your help ... but
>>
>> Scott Wood wrote:
>>> On Fri, Apr 11, 2008 at 05:13:47PM +0200, Andre Schwarz wrote:
>>> =20
>>>> To me it looks like there's a problem regarding the local bus in=20
>>>> general.
>>>>
>>>> Am I missing a "compatible" or anything else ? "reg" or "ranges" ?
>>>>    =20
>>>
>>> Do you have an of_bus_ids[] entry that covers the localbus?
>>>
>>>  =20
>> what's this ?
>> Where do I need to define this ? In dts or platform code ?
>
> Platform code.
>
>>
>> Can you give an example ?
>
> mpc8313erdb.  simple-bus is listed as a compatible for the localbus in=20
> the dts, and it is listed of_bus_ids[] in the platform file.
>
> -Scott


MATRIX VISION GmbH, Talstra=DFe 16, DE-71570 Oppenweiler  - Registergeric=
ht: Amtsgericht Stuttgart, HRB 271090
Gesch=E4ftsf=FChrer: Gerhard Thullner, Werner Armingeon, Uwe Furtner

^ permalink raw reply

* Re: [PATCH] ehea: Fix DLPAR memory add support
From: Jeff Garzik @ 2008-04-12  8:49 UTC (permalink / raw)
  To: Thomas Klein
  Cc: Jan-Bernd Themann, netdev, Hannes Hering, linux-kernel, linux-ppc,
	Christoph Raisch, Stefan Roscher
In-Reply-To: <200804041504.54130.osstklei@de.ibm.com>

Thomas Klein wrote:
> This patch fixes two weaknesses in send/receive packet handling which may
> lead to kernel panics during DLPAR memory add operations.
> 
> Signed-off-by: Thomas Klein <tklein@de.ibm.com>

applied

^ permalink raw reply

* Re: [PATCH] natsemi: fix for PPC 44x platforms
From: Jeff Garzik @ 2008-04-12  8:36 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: netdev, linuxppc-dev
In-Reply-To: <200804082331.23270.sshtylyov@ru.mvista.com>

Sergei Shtylyov wrote:
> The driver stores the the PCI resource address into 'unsigned long' variable
> before calling ioremap() on it. This warrants kernel oops when the registers
> are accessed on PPC 44x platforms which (being 32-bit) have PCI memory space
> mapped beyond 4 GB.
> 
> The arch/ppc/ kernel has a fixup in ioremap() that creates an illusion of the
> PCI I/O and memory resources are mapped below 4 GB, but arch/powerpc/ code got
> rid of this trick, having instead CONFIG_RESOURCES_64BIT enabled.
> 
> Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
> 
> ---
> This is the same issue as the one that has been recently addressed by commits
> 3c34ac36ac1084e571ef9b6fb1d6a5b10ccc1fd0 (e1000: Fix for 32 bits platforms with
> 64 bits resources) and c976816b6e901341ec3c4653147316c15549a1c4 (siimage: fix
> kernel oops on PPC 44x).  The patch has only been compile tested though...
> 
>  drivers/net/natsemi.c |    7 ++++---
>  1 files changed, 4 insertions(+), 3 deletions(-)
> 
> Index: linux-2.6/drivers/net/natsemi.c
> ===================================================================
> --- linux-2.6.orig/drivers/net/natsemi.c
> +++ linux-2.6/drivers/net/natsemi.c
> @@ -786,7 +786,8 @@ static int __devinit natsemi_probe1 (str
>  	struct netdev_private *np;
>  	int i, option, irq, chip_idx = ent->driver_data;
>  	static int find_cnt = -1;
> -	unsigned long iostart, iosize;
> +	resource_size_t iostart;
> +	unsigned long iosize;
>  	void __iomem *ioaddr;
>  	const int pcibar = 1; /* PCI base address register */
>  	int prev_eedata;
> @@ -946,9 +947,9 @@ static int __devinit natsemi_probe1 (str
>  		goto err_create_file;
>  
>  	if (netif_msg_drv(np)) {
> -		printk(KERN_INFO "natsemi %s: %s at %#08lx "
> +		printk(KERN_INFO "natsemi %s: %s at %#08llx "
>  		       "(%s), %s, IRQ %d",
> -		       dev->name, natsemi_pci_info[chip_idx].name, iostart,
> +		       dev->name, natsemi_pci_info[chip_idx].name, (u64)iostart,
>  		       pci_name(np->pci_dev), print_mac(mac, dev->dev_addr), irq);
>  		if (dev->if_port == PORT_TP)

ACK, with the cast fixed (to long long)

^ permalink raw reply

* Re: [PATCH] fs_enet: Don't call NAPI functions when NAPI is not used.
From: Jeff Garzik @ 2008-04-12  5:53 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: netdev, linuxppc-dev
In-Reply-To: <200804111405.50896.laurentp@cse-semaphore.com>

Laurent Pinchart wrote:
> fs_enet_close() calls napi_disable() unconditionally. This patch skips the
> call when use_napi isn't set.
> 
> Signed-off-by: Laurent Pinchart <laurentp@cse-semaphore.com>
> ---
>  drivers/net/fs_enet/fs_enet-main.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
> index c83bd65..1801ce3 100644
> --- a/drivers/net/fs_enet/fs_enet-main.c
> +++ b/drivers/net/fs_enet/fs_enet-main.c
> @@ -835,7 +835,8 @@ static int fs_enet_close(struct net_device *dev)
>  
>  	netif_stop_queue(dev);
>  	netif_carrier_off(dev);
> -	napi_disable(&fep->napi);
> +	if (fep->fpi->use_napi)
> +		napi_disable(&fep->napi);
>  	phy_stop(fep->phydev);

applied

^ permalink raw reply

* [LMB][1/2] Fix some whitespace and other formatting issues, use pr_debug
From: Paul Mackerras @ 2008-04-12  5:20 UTC (permalink / raw)
  To: linuxppc-dev, linux-kernel; +Cc: davem

This makes no semantic changes.  It fixes the whitespace and formatting
a bit, gets rid of a local DBG macro and uses the equivalent pr_debug
instead, and restructures one while loop that had a function call and
assignment in the condition to be a bit more readable.  Some comments
about functions being called with relocation disabled were also removed
as they would just be confusing to most readers now that the code is
in lib/.

Signed-off-by: Paul Mackerras <paulus@samba.org>
---
This goes on top of Dave Miller's "LMB: Add lmb_alloc_nid()" patch.

diff --git a/lib/lmb.c b/lib/lmb.c
index 549fbb3..265daf5 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -15,14 +15,6 @@
 #include <linux/bitops.h>
 #include <linux/lmb.h>
 
-#undef DEBUG
-
-#ifdef DEBUG
-#define DBG(fmt...) LMB_DBG(fmt)
-#else
-#define DBG(fmt...)
-#endif
-
 #define LMB_ALLOC_ANYWHERE	0
 
 struct lmb lmb;
@@ -32,32 +24,32 @@ void lmb_dump_all(void)
 #ifdef DEBUG
 	unsigned long i;
 
-	DBG("lmb_dump_all:\n");
-	DBG("    memory.cnt		  = 0x%lx\n", lmb.memory.cnt);
-	DBG("    memory.size		  = 0x%llx\n",
+	pr_debug("lmb_dump_all:\n");
+	pr_debug("    memory.cnt		  = 0x%lx\n", lmb.memory.cnt);
+	pr_debug("    memory.size		  = 0x%llx\n",
 	    (unsigned long long)lmb.memory.size);
 	for (i=0; i < lmb.memory.cnt ;i++) {
-		DBG("    memory.region[0x%x].base       = 0x%llx\n",
+		pr_debug("    memory.region[0x%x].base       = 0x%llx\n",
 		    i, (unsigned long long)lmb.memory.region[i].base);
-		DBG("		      .size     = 0x%llx\n",
+		pr_debug("		      .size     = 0x%llx\n",
 		    (unsigned long long)lmb.memory.region[i].size);
 	}
 
-	DBG("\n    reserved.cnt	  = 0x%lx\n", lmb.reserved.cnt);
-	DBG("    reserved.size	  = 0x%lx\n", lmb.reserved.size);
+	pr_debug("\n    reserved.cnt	  = 0x%lx\n", lmb.reserved.cnt);
+	pr_debug("    reserved.size	  = 0x%lx\n", lmb.reserved.size);
 	for (i=0; i < lmb.reserved.cnt ;i++) {
-		DBG("    reserved.region[0x%x].base       = 0x%llx\n",
+		pr_debug("    reserved.region[0x%x].base       = 0x%llx\n",
 		    i, (unsigned long long)lmb.reserved.region[i].base);
-		DBG("		      .size     = 0x%llx\n",
+		pr_debug("		      .size     = 0x%llx\n",
 		    (unsigned long long)lmb.reserved.region[i].size);
 	}
 #endif /* DEBUG */
 }
 
-static unsigned long __init lmb_addrs_overlap(u64 base1,
-		u64 size1, u64 base2, u64 size2)
+static unsigned long __init lmb_addrs_overlap(u64 base1, u64 size1,
+		u64 base2, u64 size2)
 {
-	return ((base1 < (base2+size2)) && (base2 < (base1+size1)));
+	return ((base1 < (base2 + size2)) && (base2 < (base1 + size1)));
 }
 
 static long __init lmb_addrs_adjacent(u64 base1, u64 size1,
@@ -101,7 +93,6 @@ static void __init lmb_coalesce_regions(struct lmb_region *rgn,
 	lmb_remove_region(rgn, r2);
 }
 
-/* This routine called with relocation disabled. */
 void __init lmb_init(void)
 {
 	/* Create a dummy zero size LMB which will get coalesced away later.
@@ -117,7 +108,6 @@ void __init lmb_init(void)
 	lmb.reserved.cnt = 1;
 }
 
-/* This routine may be called with relocation disabled. */
 void __init lmb_analyze(void)
 {
 	int i;
@@ -128,7 +118,6 @@ void __init lmb_analyze(void)
 		lmb.memory.size += lmb.memory.region[i].size;
 }
 
-/* This routine called with relocation disabled. */
 static long __init lmb_add_region(struct lmb_region *rgn, u64 base, u64 size)
 {
 	unsigned long coalesced = 0;
@@ -141,7 +130,7 @@ static long __init lmb_add_region(struct lmb_region *rgn, u64 base, u64 size)
 	}
 
 	/* First try and coalesce this LMB with another. */
-	for (i=0; i < rgn->cnt; i++) {
+	for (i = 0; i < rgn->cnt; i++) {
 		u64 rgnbase = rgn->region[i].base;
 		u64 rgnsize = rgn->region[i].size;
 
@@ -149,21 +138,20 @@ static long __init lmb_add_region(struct lmb_region *rgn, u64 base, u64 size)
 			/* Already have this region, so we're done */
 			return 0;
 
-		adjacent = lmb_addrs_adjacent(base,size,rgnbase,rgnsize);
-		if ( adjacent > 0 ) {
+		adjacent = lmb_addrs_adjacent(base, size, rgnbase, rgnsize);
+		if (adjacent > 0) {
 			rgn->region[i].base -= size;
 			rgn->region[i].size += size;
 			coalesced++;
 			break;
-		}
-		else if ( adjacent < 0 ) {
+		} else if (adjacent < 0) {
 			rgn->region[i].size += size;
 			coalesced++;
 			break;
 		}
 	}
 
-	if ((i < rgn->cnt-1) && lmb_regions_adjacent(rgn, i, i+1) ) {
+	if ((i < rgn->cnt - 1) && lmb_regions_adjacent(rgn, i, i+1)) {
 		lmb_coalesce_regions(rgn, i, i+1);
 		coalesced++;
 	}
@@ -174,7 +162,7 @@ static long __init lmb_add_region(struct lmb_region *rgn, u64 base, u64 size)
 		return -1;
 
 	/* Couldn't coalesce the LMB, so add it to the sorted table. */
-	for (i = rgn->cnt-1; i >= 0; i--) {
+	for (i = rgn->cnt - 1; i >= 0; i--) {
 		if (base < rgn->region[i].base) {
 			rgn->region[i+1].base = rgn->region[i].base;
 			rgn->region[i+1].size = rgn->region[i].size;
@@ -194,10 +182,9 @@ static long __init lmb_add_region(struct lmb_region *rgn, u64 base, u64 size)
 	return 0;
 }
 
-/* This routine may be called with relocation disabled. */
 long __init lmb_add(u64 base, u64 size)
 {
-	struct lmb_region *_rgn = &(lmb.memory);
+	struct lmb_region *_rgn = &lmb.memory;
 
 	/* On pSeries LPAR systems, the first LMB is our RMO region. */
 	if (base == 0)
@@ -209,24 +196,22 @@ long __init lmb_add(u64 base, u64 size)
 
 long __init lmb_reserve(u64 base, u64 size)
 {
-	struct lmb_region *_rgn = &(lmb.reserved);
+	struct lmb_region *_rgn = &lmb.reserved;
 
 	BUG_ON(0 == size);
 
 	return lmb_add_region(_rgn, base, size);
 }
 
-long __init lmb_overlaps_region(struct lmb_region *rgn, u64 base,
-				u64 size)
+long __init lmb_overlaps_region(struct lmb_region *rgn, u64 base, u64 size)
 {
 	unsigned long i;
 
-	for (i=0; i < rgn->cnt; i++) {
+	for (i = 0; i < rgn->cnt; i++) {
 		u64 rgnbase = rgn->region[i].base;
 		u64 rgnsize = rgn->region[i].size;
-		if ( lmb_addrs_overlap(base,size,rgnbase,rgnsize) ) {
+		if (lmb_addrs_overlap(base, size, rgnbase, rgnsize))
 			break;
-		}
 	}
 
 	return (i < rgn->cnt) ? i : -1;
@@ -337,7 +322,7 @@ u64 __init __lmb_alloc_base(u64 size, u64 align, u64 max_addr)
 	if (max_addr == LMB_ALLOC_ANYWHERE)
 		max_addr = LMB_REAL_LIMIT;
 
-	for (i = lmb.memory.cnt-1; i >= 0; i--) {
+	for (i = lmb.memory.cnt - 1; i >= 0; i--) {
 		u64 lmbbase = lmb.memory.region[i].base;
 		u64 lmbsize = lmb.memory.region[i].size;
 
@@ -349,10 +334,13 @@ u64 __init __lmb_alloc_base(u64 size, u64 align, u64 max_addr)
 		} else
 			continue;
 
-		while ((lmbbase <= base) &&
-		       ((j = lmb_overlaps_region(&lmb.reserved, base, size)) >= 0) )
+		while (lmbbase <= base) {
+			j = lmb_overlaps_region(&lmb.reserved, base, size);
+			if (j < 0)
+				break;
 			base = lmb_align_down(lmb.reserved.region[j].base - size,
 					      align);
+		}
 
 		if ((base != 0) && (lmbbase <= base))
 			break;
@@ -387,7 +375,7 @@ void __init lmb_enforce_memory_limit(u64 memory_limit)
 	u64 limit;
 	struct lmb_property *p;
 
-	if (! memory_limit)
+	if (!memory_limit)
 		return;
 
 	/* Truncate the lmb regions to satisfy the memory limit. */

^ permalink raw reply related

* [LMB][2/2] Restructure allocation loops to avoid unsigned underflow
From: Paul Mackerras @ 2008-04-12  5:20 UTC (permalink / raw)
  To: linuxppc-dev, linux-kernel; +Cc: davem

There is a potential bug in __lmb_alloc_base where we subtract `size'
from the base address of a reserved region without checking whether
the subtraction could wrap around and produce a very large unsigned
value.  In fact it probably isn't possible to hit the bug in practice
since it would only occur in the situation where we can't satisfy the
allocation request and there is a reserved region starting at 0.

This fixes the potential bug by breaking out of the loop when we get
to the point where the base of the reserved region is less than the
size requested.  This also restructures the loop to be a bit easier to
follow. 

The same logic got copied into lmb_alloc_nid_unreserved, so this makes
a similar change there.  Here the bug is more likely to be hit because
the outer loop  (in lmb_alloc_nid) goes through the memory regions in
increasing order rather than decreasing order as __lmb_alloc_base
does, and we are therefore more likely to hit the case where we are
testing against a reserved region with a base address of 0.

Signed-off-by: Paul Mackerras <paulus@samba.org>
---
diff --git a/lib/lmb.c b/lib/lmb.c
index 265daf5..cabb942 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -230,20 +230,23 @@ static u64 lmb_align_up(u64 addr, u64 size)
 static u64 __init lmb_alloc_nid_unreserved(u64 start, u64 end,
 					   u64 size, u64 align)
 {
-	u64 base;
+	u64 base, res_base;
 	long j;
 
 	base = lmb_align_down((end - size), align);
-	while (start <= base &&
-	       ((j = lmb_overlaps_region(&lmb.reserved, base, size)) >= 0))
-		base = lmb_align_down(lmb.reserved.region[j].base - size,
-				      align);
-
-	if (base != 0 && start <= base) {
-		if (lmb_add_region(&lmb.reserved, base,
-				   lmb_align_up(size, align)) < 0)
-			base = ~(u64)0;
-		return base;
+	while (start <= base) {
+		j = lmb_overlaps_region(&lmb.reserved, base, size);
+		if (j < 0) {
+			/* this area isn't reserved, take it */
+			if (lmb_add_region(&lmb.reserved, base,
+					   lmb_align_up(size, align)) < 0)
+				base = ~(u64)0;
+			return base;
+		}
+		res_base = lmb.reserved.region[j].base;
+		if (res_base < size)
+			break;
+		base = lmb_align_down(res_base - size, align);
 	}
 
 	return ~(u64)0;
@@ -315,10 +318,12 @@ u64 __init __lmb_alloc_base(u64 size, u64 align, u64 max_addr)
 {
 	long i, j;
 	u64 base = 0;
+	u64 res_base;
 
 	BUG_ON(0 == size);
 
 	/* On some platforms, make sure we allocate lowmem */
+	/* Note that LMB_REAL_LIMIT may be LMB_ALLOC_ANYWHERE */
 	if (max_addr == LMB_ALLOC_ANYWHERE)
 		max_addr = LMB_REAL_LIMIT;
 
@@ -326,6 +331,8 @@ u64 __init __lmb_alloc_base(u64 size, u64 align, u64 max_addr)
 		u64 lmbbase = lmb.memory.region[i].base;
 		u64 lmbsize = lmb.memory.region[i].size;
 
+		if (lmbsize < size)
+			continue;
 		if (max_addr == LMB_ALLOC_ANYWHERE)
 			base = lmb_align_down(lmbbase + lmbsize - size, align);
 		else if (lmbbase < max_addr) {
@@ -334,25 +341,22 @@ u64 __init __lmb_alloc_base(u64 size, u64 align, u64 max_addr)
 		} else
 			continue;
 
-		while (lmbbase <= base) {
+		while (base && lmbbase <= base) {
 			j = lmb_overlaps_region(&lmb.reserved, base, size);
-			if (j < 0)
+			if (j < 0) {
+				/* this area isn't reserved, take it */
+				if (lmb_add_region(&lmb.reserved, base,
+						   size) < 0)
+					return 0;
+				return base;
+			}
+			res_base = lmb.reserved.region[j].base;
+			if (res_base < size)
 				break;
-			base = lmb_align_down(lmb.reserved.region[j].base - size,
-					      align);
+			base = lmb_align_down(res_base - size, align);
 		}
-
-		if ((base != 0) && (lmbbase <= base))
-			break;
 	}
-
-	if (i < 0)
-		return 0;
-
-	if (lmb_add_region(&lmb.reserved, base, lmb_align_up(size, align)) < 0)
-		return 0;
-
-	return base;
+	return 0;
 }
 
 /* You must call lmb_analyze() before this. */

^ permalink raw reply related

* Re: [PATCH 1/2] Driver for Freescale 8610 and 5121 DIU
From: Andrew Morton @ 2008-04-12  5:18 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: linuxppc-dev, York Sun, linux-kernel
In-Reply-To: <47FFDBFF.1030809@gmail.com>

On Fri, 11 Apr 2008 23:45:35 +0200 Jiri Slaby <jirislaby@gmail.com> wrote:

> On 03/12/2008 11:20 PM, Jiri Slaby wrote:
> > On 03/12/2008 10:43 PM, York Sun wrote:
> >> +static int fsl_diu_open(struct fb_info *info, int user)
> >> +{
> >> +    struct mfb_info *mfbi = info->par;
> >> +    int res = 0;
> >> +
> >> +    spin_lock(&diu_lock);
> >> +    mfbi->count++;
> >> +    if (mfbi->count == 1) {
> >> +        DPRINTK("open plane index %d\n", mfbi->index);
> >> +        fsl_diu_check_var(&info->var, info);
> >> +        fsl_diu_set_par(info);
> > 
> > Please retest your code (at least) with sleep-inside spinlock debug 
> > option. If I see correctly you call GFP_KERNEL allocation somewhere 
> > deeper in this function, which might sleep.
> > 
>
> ...
>
> ping.
> 
> Seeing this in -mm yet. Are those comments all wrong? Are you working on it?
> 

(top-posting repaired)

Thanks.  I've made a note that this patch has outstanding issues.  Usually
this means that I'll defer merging it until they have been addressed:
either by fixing them or by successfully arguing against the objections.  

^ permalink raw reply

* Re: [PATCH 2/8] [POWERPC] fsl_lbc: implement few routines to manage FSL UPMs
From: Paul Mackerras @ 2008-04-12  4:09 UTC (permalink / raw)
  To: avorontsov; +Cc: Scott Wood, linuxppc-dev
In-Reply-To: <20080411170340.GA2649@polina.dev.rtsoft.ru>

Anton Vorontsov writes:

> Ok. Updated patch follows.
> 
> Thanks!
> 
> - - - -
> From: Anton Vorontsov <avorontsov@ru.mvista.com>
> Subject: [POWERPC] fsl_lbc: implement few UPM routines

Just a hint: your patches are less likely to get overlooked if you
change the subject of your email to describe the new patch rather than
just leaving it as Re: some old patch.

Paul.

^ 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