[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [MiNT] [PATCH] Firebee software poweroff
On 15/12/2013 19:26, Jo Even Skarstein wrote:
This patch enables MiNT to power off the Firebee when
Shutdown(SHUT_POWER) is called. It requires the latest (january 2012)
PIC firmware to work, but does no harm with previous versions.
Excellent! It works perfectly, with both FireTOS and EmuTOS.
I didn't knew that a poweroff function was implemented in the PIC.
I have slightly improved Jo Even's patch.
Alan, please commit this one instead.
It is really good news that communicating with the PIC is so easy from
FreeMiNT. It means that when new features are added to the PIC (battery
monitor, etc.), they will be easily available in the kernel.
--
Vincent Rivière
diff -aurN -x CVS freemint.orig/sys/arch/halt.c freemint/sys/arch/halt.c
--- freemint.orig/sys/arch/halt.c 2007-07-13 23:32:49.000000000 +0200
+++ freemint/sys/arch/halt.c 2013-12-15 21:43:15.750000000 +0100
@@ -49,6 +49,35 @@
# include "aranym.h"
+# ifdef __mcoldfire__
+
+/* FireBee defines */
+# define __MBAR ((volatile uchar*)0xff000000)
+# define MCF_UART_USR3 (*(volatile uchar*)(&__MBAR[0x8904]))
+# define MCF_UART_UTB3 (*(volatile uchar*)(&__MBAR[0x890c]))
+# define MCF_UART_USR_TXRDY 0x04
+
+static bool
+firebee_pic_can_write(void)
+{
+ /* Check if space is available in the FIFO */
+ return MCF_UART_USR3 & MCF_UART_USR_TXRDY;
+}
+
+static void
+firebee_pic_write_byte(uchar b)
+{
+ while (!firebee_pic_can_write())
+ {
+ /* Wait */
+ }
+
+ /* Send the byte */
+ MCF_UART_UTB3 = b;
+}
+
+# endif /* __mcoldfire__ */
+
void
hw_poweroff(void)
{
@@ -65,6 +94,18 @@
/* does not return */
}
+
+# ifdef __mcoldfire__
+ /* Firebee poweroff */
+ if (machine == machine_firebee)
+ {
+ firebee_pic_write_byte(0x0c); /* Header */
+ firebee_pic_write_byte('O');
+ firebee_pic_write_byte('F');
+ firebee_pic_write_byte('F');
+ }
+# endif /* __mcoldfire__ */
+
# endif
}