[PATCH] ppc64: do not return from maple halt, power off, restart

Frank Rowand frowand at mvista.com
Tue Jun 7 11:52:55 EST 2005


David Gibson wrote:
> On Fri, Jun 03, 2005 at 04:34:41PM -0700, Frank Rowand wrote:
> 
>>The Maple board currently returns from a request to halt, power off, or
>>restart.  This patch causes all processors to instead spin in these cases
>>so that the system appears to have halted.
>>
>>This patch applies against linux-2.6.12-rc5.
> 
> 
> This one is probably a better way to go, though.  This came from Matt
> Dharm some time ago, but was never merged due to a miscommunication.
> It implements the actual board-level reboot and powerdown by
> communicating with the service processor.

David,

I tried this patch on linux-2.6.12-rc5.  The maple_restart() worked fine.
The maple_halt() did not power off the board.  The maintenance processor
PIBS reports:

   PIBS $ Message received: Power off.
   Powering down 970s and the CPC925 ...
   Power down complete.

but the board remains powered on.

Some other comments:

maple_halt() should do the same thing as maple_power_off().  (It could
even just call maple_power_off().)

maple_restart(), maple_power_off(), and maple_halt() should not ever
return.  The returns could be replaced with the code from my patch
that started this thread.

I don't know if smp_send_stop() is necesary (there seems to be a lack
of consistency among the different architectures) but it seems like a
good idea.

Do you want me to rework the patch with these suggestions?  (But I'm
not sure how to resolve the failure to power off.)

> 
> Andrew, please apply.
> 
> Signed-off-by: David Gibson <dwg at au1.ibm.com>
> 
> ===== maple_setup.c 1.5 vs edited =====
> --- 1.5/arch/ppc64/kernel/maple_setup.c	2005-01-07 21:43:52 -08:00
> +++ edited/maple_setup.c	2005-01-28 18:58:39 -08:00
> @@ -78,13 +78,72 @@
>  extern void generic_find_legacy_serial_ports(u64 *physport,
>  		unsigned int *default_speed);
>  
> -
>  static void maple_restart(char *cmd)
>  {
> +	unsigned int maple_nvram_base;
> +	unsigned int maple_nvram_offset;
> +	unsigned int maple_nvram_command;
> +	struct device_node *rtcs;
> +
> +	/* find NVRAM device */
> +	rtcs = find_compatible_devices("nvram", "AMD8111");
> +	if (rtcs && rtcs->addrs) {
> +		maple_nvram_base = rtcs->addrs[0].address;
> +	} else {
> +		printk(KERN_INFO "Maple: Unable to find NVRAM\n");
> +		printk(KERN_INFO "Maple: Manual Restart Required\n");
> +		return;
> +	}
> +
> +	/* find service processor device */
> +	rtcs = find_devices("service-processor");
> +	if (!rtcs) {
> +		printk(KERN_INFO "Maple: Unable to find Service Processor\n");
> +		printk(KERN_INFO "Maple: Manual Restart Required\n");
> +		return;
> +	}
> +	maple_nvram_offset = *(unsigned int*) get_property(rtcs,
> +			"restart-addr", NULL);
> +	maple_nvram_command = *(unsigned int*) get_property(rtcs,
> +			"restart-value", NULL);
> +
> +	/* send command */
> +	outb_p(maple_nvram_command, maple_nvram_base + maple_nvram_offset);
> +	for (;;) ;
>  }
>  
>  static void maple_power_off(void)
>  {
> +	unsigned int maple_nvram_base;
> +	unsigned int maple_nvram_offset;
> +	unsigned int maple_nvram_command;
> +	struct device_node *rtcs;
> +
> +	/* find NVRAM device */
> +	rtcs = find_compatible_devices("nvram", "AMD8111");
> +	if (rtcs && rtcs->addrs) {
> +		maple_nvram_base = rtcs->addrs[0].address;
> +	} else {
> +		printk(KERN_INFO "Maple: Unable to find NVRAM\n");
> +		printk(KERN_INFO "Maple: Manual Power-Down Required\n");
> +		return;
> +	}
> +
> +	/* find service processor device */
> +	rtcs = find_devices("service-processor");
> +	if (!rtcs) {
> +		printk(KERN_INFO "Maple: Unable to find Service Processor\n");
> +		printk(KERN_INFO "Maple: Manual Power-Down Required\n");
> +		return;
> +	}
> +	maple_nvram_offset = *(unsigned int*) get_property(rtcs,
> +			"power-off-addr", NULL);
> +	maple_nvram_command = *(unsigned int*) get_property(rtcs,
> +			"power-off-value", NULL);
> +
> +	/* send command */
> +	outb_p(maple_nvram_command, maple_nvram_base + maple_nvram_offset);
> +	for (;;) ;
>  }
>  
>  static void maple_halt(void)
> 
> 
> 

-Frank
-- 
Frank Rowand <frank_rowand at mvista.com>
MontaVista Software, Inc




More information about the Linuxppc64-dev mailing list