All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86: EuroBraille/Iris power off
@ 2010-08-25  9:49 Shérab
  2010-08-25 16:12 ` Andreas Mohr
  2010-08-26 18:11 ` Len Brown
  0 siblings, 2 replies; 31+ messages in thread
From: Shérab @ 2010-08-25  9:49 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, Andrew Morton,
	Frederic Weisbecker, Len Brown, Andres Salomon
  Cc: linux-kernel, Samuel Thibault

commit f5f96cdad153566dbca9dcfdcf36245319968b0a
Author: Shérab <Sebastien.Hinderer@ens-lyon.org>
Date:   Wed Aug 25 11:39:42 2010 +0200

    Eurobraille/Iris power off.
    
    The Iris machines from EuroBraille do not have APM or ACPI support
    to shut themselves down properly.  A special I/O sequence is
    needed to do so.  This modle runs this I/O sequence at
    kernel shutdown.
    
    This is only for Iris machines from EuroBraille.
    Signed-off-by: Shérab <Sebastien.Hinderer@ens-lyon.org>

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index ac7827f..88bf897 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -493,6 +493,19 @@ config X86_ES7000
 	  Support for Unisys ES7000 systems.  Say 'Y' here if this kernel is
 	  supposed to run on an IA32-based Unisys ES7000 system.
 
+config X86_32_IRIS
+	tristate "Eurobraille/Iris poweroff module"
+	depends on X86_32
+	---help---
+	  The Iris machines from EuroBraille do not have APM or ACPI support
+	  to shut themselves down properly.  A special I/O sequence is
+	  needed to do so, which is what this module does at
+	  kernel shutdown.
+
+	  This is only for Iris machines from EuroBraille.
+
+	  If unused, say N.
+
 config SCHED_OMIT_FRAME_POINTER
 	def_bool y
 	prompt "Single-depth WCHAN output"
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index 0925676..98dd1c8 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -115,6 +115,7 @@ obj-$(CONFIG_MICROCODE)			+= microcode.o
 obj-$(CONFIG_X86_CHECK_BIOS_CORRUPTION) += check.o
 
 obj-$(CONFIG_SWIOTLB)			+= pci-swiotlb.o
+obj-$(CONFIG_X86_32_IRIS)		+= iris.o
 
 ###
 # 64 bit specific files
diff --git a/arch/x86/kernel/iris.c b/arch/x86/kernel/iris.c
new file mode 100644
index 0000000..7c8a942
--- /dev/null
+++ b/arch/x86/kernel/iris.c
@@ -0,0 +1,66 @@
+/*
+ * Eurobraille/Iris power off support.
+ *
+ * Eurobraille's Iris machine is a PC with no APM or ACPI support.
+ * It is shutdown by a special I/O sequence which this module provides.
+ *
+ *  Copyright (C) Shérab <Sebastien.Hinderer@ens-lyon.org>
+ *
+ * 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 the program ; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/pm.h>
+#include <linux/delay.h>
+#include <asm/io.h>
+
+#define IRIS_GIO_BASE 0x340
+#define IRIS_GIO_OUTPUT (IRIS_GIO_BASE + 1)
+#define IRIS_GIO_PULSE 0x80 /* First byte to send */
+#define IRIS_GIO_REST 0x0 /* Second byte to send */
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Sébastien Hinderer <Sebastien.Hinderer@ens-lyon.org>");
+MODULE_DESCRIPTION("A power_off handler for Iris devices from EuroBraille");
+MODULE_SUPPORTED_DEVICE("Eurobraille/Iris");
+
+static void (*old_pm_power_off)(void);
+
+static void iris_power_off(void)
+{
+	outb(IRIS_GIO_PULSE, IRIS_GIO_OUTPUT);
+	msleep(850);
+	outb(IRIS_GIO_REST, IRIS_GIO_OUTPUT);
+}
+
+static int iris_init(void)
+{
+	old_pm_power_off = pm_power_off;
+	pm_power_off = &iris_power_off;
+	printk(KERN_INFO "Iris power_off handler installed.\n");
+	return 0;
+}
+
+static void iris_exit(void)
+{
+	pm_power_off = old_pm_power_off;
+	printk(KERN_INFO "Iris power_off handler uninstalled.\n");
+}
+
+module_init(iris_init);
+module_exit(iris_exit);
+

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCH] x86: EuroBraille/Iris power off
  2010-08-25  9:49 [PATCH] x86: EuroBraille/Iris power off Shérab
@ 2010-08-25 16:12 ` Andreas Mohr
  2010-08-25 21:12   ` Sebastien Hinderer
  2010-08-26 18:11 ` Len Brown
  1 sibling, 1 reply; 31+ messages in thread
From: Andreas Mohr @ 2010-08-25 16:12 UTC (permalink / raw)
  To: Sebastien.Hinderer, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
	x86, Andrew Morton, Frederic Weisbecker, Len Brown
  Cc: linux-kernel, Samuel Thibault

Hi,

excellent! Now if as the next step before inclusion you also add the usual DMI check
(as done by many drivers such as acerhdf etc.),
someone inexperienced who is dumb enough to enable it for his unrelated machine
will actually survive an otherwise raw I/O port access and poweroff vector change ;))

Unless these non-APM, non-ACPI machines don't have any DMI support
either and thus won't even have dmidecode work.....
(in which case I'd strongly suggest adding a 0x340+x port value read verification
to bail driver install in case the machine doesn't have this hardware).

Andreas Mohr

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] x86: EuroBraille/Iris power off
  2010-08-25 16:12 ` Andreas Mohr
@ 2010-08-25 21:12   ` Sebastien Hinderer
  2010-08-25 21:19     ` H. Peter Anvin
  0 siblings, 1 reply; 31+ messages in thread
From: Sebastien Hinderer @ 2010-08-25 21:12 UTC (permalink / raw)
  To: Andreas Mohr
  Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, Andrew Morton,
	Frederic Weisbecker, Len Brown, linux-kernel, Samuel Thibault

Hi,

> excellent! Now if as the next step before inclusion you also add the usual DMI check
> (as done by many drivers such as acerhdf etc.),
> someone inexperienced who is dumb enough to enable it for his unrelated machine
> will actually survive an otherwise raw I/O port access and poweroff
> vector change ;))

The machine does not support DMI, I have mentionned that in the module.

> Unless these non-APM, non-ACPI machines don't have any DMI support
> either and thus won't even have dmidecode work.....
> (in which case I'd strongly suggest adding a 0x340+x port value read verification
> to bail driver install in case the machine doesn't have this
> hardware).

I did that, but I have noprecise documentation about what the legitimate
values are, so I just compared the read value with 0xff. This prevents
the module from being loaded in qemu for instance.

Shérab.

commit 197e523553a791f97536143001f22abd36f7992c
Author: Shérab <Sebastien.Hinderer@ens-lyon.org>
Date:   Wed Aug 25 23:00:14 2010 +0200

    Eurobraille/Iris power off.
    
    The Iris machines from EuroBraille do not have APM or ACPI support
    to shut themselves down properly.  A special I/O sequence is
    needed to do so.  This modle runs this I/O sequence at
    kernel shutdown.
    
    This is only for Iris machines from EuroBraille.
    Signed-off-by: Shérab <Sebastien.Hinderer@ens-lyon.org>

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index ac7827f..88bf897 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -493,6 +493,19 @@ config X86_ES7000
 	  Support for Unisys ES7000 systems.  Say 'Y' here if this kernel is
 	  supposed to run on an IA32-based Unisys ES7000 system.
 
+config X86_32_IRIS
+	tristate "Eurobraille/Iris poweroff module"
+	depends on X86_32
+	---help---
+	  The Iris machines from EuroBraille do not have APM or ACPI support
+	  to shut themselves down properly.  A special I/O sequence is
+	  needed to do so, which is what this module does at
+	  kernel shutdown.
+
+	  This is only for Iris machines from EuroBraille.
+
+	  If unused, say N.
+
 config SCHED_OMIT_FRAME_POINTER
 	def_bool y
 	prompt "Single-depth WCHAN output"
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index 0925676..98dd1c8 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -115,6 +115,7 @@ obj-$(CONFIG_MICROCODE)			+= microcode.o
 obj-$(CONFIG_X86_CHECK_BIOS_CORRUPTION) += check.o
 
 obj-$(CONFIG_SWIOTLB)			+= pci-swiotlb.o
+obj-$(CONFIG_X86_32_IRIS)		+= iris.o
 
 ###
 # 64 bit specific files
diff --git a/arch/x86/kernel/iris.c b/arch/x86/kernel/iris.c
new file mode 100644
index 0000000..8856ef3
--- /dev/null
+++ b/arch/x86/kernel/iris.c
@@ -0,0 +1,80 @@
+/*
+ * Eurobraille/Iris power off support.
+ *
+ * Eurobraille's Iris machine is a PC with no APM or ACPI support.
+ * It is shutdown by a special I/O sequence which this module provides.
+ *
+ *  Copyright (C) Shérab <Sebastien.Hinderer@ens-lyon.org>
+ *
+ * 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 the program ; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/pm.h>
+#include <linux/delay.h>
+#include <asm/io.h>
+
+#define IRIS_GIO_BASE 0x340
+#define IRIS_GIO_INPUT IRIS_GIO_BASE
+#define IRIS_GIO_OUTPUT (IRIS_GIO_BASE + 1)
+#define IRIS_GIO_PULSE 0x80 /* First byte to send */
+#define IRIS_GIO_REST 0x0 /* Second byte to send */
+#define IRIS_GIO_NODEV 0xff /* Likely not an Iris */
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Sébastien Hinderer <Sebastien.Hinderer@ens-lyon.org>");
+MODULE_DESCRIPTION("A power_off handler for Iris devices from EuroBraille");
+MODULE_SUPPORTED_DEVICE("Eurobraille/Iris");
+
+static void (*old_pm_power_off)(void);
+
+static void iris_power_off(void)
+{
+	outb(IRIS_GIO_PULSE, IRIS_GIO_OUTPUT);
+	msleep(850);
+	outb(IRIS_GIO_REST, IRIS_GIO_OUTPUT);
+}
+
+/*
+ * Before installing the power_off handler, try to make sure the OS is
+ * running on an Iris.  Since Iris does not support DMI, this is done
+ * by reading its input port and seeing whether the read value is
+ * meaningful.
+ */
+static int iris_init(void)
+{
+	unsigned char status = inb(IRIS_GIO_INPUT);
+	if (status == IRIS_GIO_NODEV) {
+		printk(KERN_ERR "This machine does not seem to be an Iris. Power_off handler not installed.\n");
+		return -ENODEV;
+	}
+	old_pm_power_off = pm_power_off;
+	pm_power_off = &iris_power_off;
+	printk(KERN_INFO "Iris power_off handler installed.\n");
+	return 0;
+}
+
+static void iris_exit(void)
+{
+	pm_power_off = old_pm_power_off;
+	printk(KERN_INFO "Iris power_off handler uninstalled.\n");
+}
+
+module_init(iris_init);
+module_exit(iris_exit);
+

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCH] x86: EuroBraille/Iris power off
  2010-08-25 21:12   ` Sebastien Hinderer
@ 2010-08-25 21:19     ` H. Peter Anvin
  2010-08-25 22:50       ` Samuel Thibault
  0 siblings, 1 reply; 31+ messages in thread
From: H. Peter Anvin @ 2010-08-25 21:19 UTC (permalink / raw)
  To: Sebastien Hinderer
  Cc: Andreas Mohr, Thomas Gleixner, Ingo Molnar, x86, Andrew Morton,
	Frederic Weisbecker, Len Brown, linux-kernel, Samuel Thibault

On 08/25/2010 02:12 PM, Sebastien Hinderer wrote:
> Hi,
> 
>> excellent! Now if as the next step before inclusion you also add the usual DMI check
>> (as done by many drivers such as acerhdf etc.),
>> someone inexperienced who is dumb enough to enable it for his unrelated machine
>> will actually survive an otherwise raw I/O port access and poweroff
>> vector change ;))
> 
> The machine does not support DMI, I have mentionned that in the module.
> 

Perhaps a better questions is: what *do* they have?  I really don't feel
comfortable adding something like this which pokes at a random port in
the ISA range, especially with the Interrupt list listing 6 known other
uses of this particular port.

At that point I'd almost prefer doing something like a BIOS signature
check if we can't do anything better.

	-hpa

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] x86: EuroBraille/Iris power off
  2010-08-25 21:19     ` H. Peter Anvin
@ 2010-08-25 22:50       ` Samuel Thibault
  2010-08-26  0:06         ` H. Peter Anvin
  0 siblings, 1 reply; 31+ messages in thread
From: Samuel Thibault @ 2010-08-25 22:50 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Sebastien Hinderer, Andreas Mohr, Thomas Gleixner, Ingo Molnar,
	x86, Andrew Morton, Frederic Weisbecker, Len Brown, linux-kernel

H. Peter Anvin, le Wed 25 Aug 2010 14:19:55 -0700, a écrit :
> At that point I'd almost prefer doing something like a BIOS signature
> check if we can't do anything better.

Well, there will be several versions of the BIOS signature, which the
constructor is not likely to provide.

Just to make sure there's no misunderstanding: it was never planned that
this driver be loaded unless some manual intervention, like explicitly
loadling the module or setting some parameter, so that if bad effects
happen on the machine, the user can only get angry at himself for having
loaded by hand a random module without reading the documentation that
explicitly says (twice) it's only for a particular kind of hardware.

I however now realize that I don't find a way to force a driver to be
compiled only as a module.  If there isn't, I guess we can just add
a module parameter to enable/disable the driver, so that it won't be
active by default even compiled-in?

Samuel

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] x86: EuroBraille/Iris power off
  2010-08-25 22:50       ` Samuel Thibault
@ 2010-08-26  0:06         ` H. Peter Anvin
  2010-08-26  0:19           ` Samuel Thibault
  2010-08-26  6:45           ` Sebastien Hinderer
  0 siblings, 2 replies; 31+ messages in thread
From: H. Peter Anvin @ 2010-08-26  0:06 UTC (permalink / raw)
  To: Samuel Thibault, Sebastien Hinderer, Andreas Mohr,
	Thomas Gleixner, Ingo Molnar, x86, Andrew Morton,
	Frederic Weisbecker, Len Brown, linux-kernel

On 08/25/2010 03:50 PM, Samuel Thibault wrote:
> H. Peter Anvin, le Wed 25 Aug 2010 14:19:55 -0700, a écrit :
>> At that point I'd almost prefer doing something like a BIOS signature
>> check if we can't do anything better.
> 
> Well, there will be several versions of the BIOS signature, which the
> constructor is not likely to provide.
> 

Then we'll gather them up, or something.

> Just to make sure there's no misunderstanding: it was never planned that
> this driver be loaded unless some manual intervention, like explicitly
> loadling the module or setting some parameter, so that if bad effects
> happen on the machine, the user can only get angry at himself for having
> loaded by hand a random module without reading the documentation that
> explicitly says (twice) it's only for a particular kind of hardware.
> 
> I however now realize that I don't find a way to force a driver to be
> compiled only as a module.  If there isn't, I guess we can just add
> a module parameter to enable/disable the driver, so that it won't be
> active by default even compiled-in?

There is, but that is hardly a reasonable solution.

What other forms of enumerable hardware is on this machine?  PCI?

	-hpa

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] x86: EuroBraille/Iris power off
  2010-08-26  0:06         ` H. Peter Anvin
@ 2010-08-26  0:19           ` Samuel Thibault
  2010-08-26  6:45           ` Sebastien Hinderer
  1 sibling, 0 replies; 31+ messages in thread
From: Samuel Thibault @ 2010-08-26  0:19 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Sebastien Hinderer, Andreas Mohr, Thomas Gleixner, Ingo Molnar,
	x86, Andrew Morton, Frederic Weisbecker, Len Brown, linux-kernel

H. Peter Anvin, le Wed 25 Aug 2010 17:06:20 -0700, a écrit :
> On 08/25/2010 03:50 PM, Samuel Thibault wrote:
> > H. Peter Anvin, le Wed 25 Aug 2010 14:19:55 -0700, a écrit :
> >> At that point I'd almost prefer doing something like a BIOS signature
> >> check if we can't do anything better.
> > 
> > Well, there will be several versions of the BIOS signature, which the
> > constructor is not likely to provide.
> 
> Then we'll gather them up, or something.

Who?  This is a very particular kind of device, on which you can install
Linux only through some trick, thus machine coverage will most probably
be very low.  Having to activate a module by hand is really not a
problem here.

> What other forms of enumerable hardware is on this machine?  PCI?

I don't remember and will let Shérab answer.

Samuel

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] x86: EuroBraille/Iris power off
  2010-08-26  0:06         ` H. Peter Anvin
  2010-08-26  0:19           ` Samuel Thibault
@ 2010-08-26  6:45           ` Sebastien Hinderer
  2010-08-26  6:55             ` H. Peter Anvin
  1 sibling, 1 reply; 31+ messages in thread
From: Sebastien Hinderer @ 2010-08-26  6:45 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Samuel Thibault, Andreas Mohr, Thomas Gleixner, Ingo Molnar, x86,
	Andrew Morton, Frederic Weisbecker, Len Brown, linux-kernel

Hi,

> What other forms of enumerable hardware is on this machine?  PCI?

Yes, just PCI I think.

Below is the output of lspci -v if that helps.

Best wishes,
Shérab.

00:00.0 Host bridge: Cyrix Corporation PCI Master
	Flags: bus master, medium devsel, latency 0

00:02.0 Ethernet controller: Davicom Semiconductor, Inc. 21x4x DEC-Tulip compatible 10/100 Ethernet (rev 40)
	Subsystem: Davicom Semiconductor, Inc. DM9102A (DM9102AE, SM9102AF) Ethernet 100/10 MBit
	Flags: bus master, medium devsel, latency 165, IRQ 11
	I/O ports at 1000 [size=256]
	Memory at fedfe000 (32-bit, non-prefetchable) [size=256]
	[virtual] Expansion ROM at 08000000 [disabled] [size=256K]
	Capabilities: [50] Power Management version 2
	Kernel driver in use: dmfe

00:12.0 ISA bridge: Cyrix Corporation 5530 Legacy [Kahlua] (rev 30)
	Flags: bus master, medium devsel, latency 64

00:12.1 Bridge: Cyrix Corporation 5530 SMI [Kahlua]
	Flags: medium devsel
	Memory at 40012000 (32-bit, non-prefetchable) [size=256]

00:12.2 IDE interface: Cyrix Corporation 5530 IDE [Kahlua] (prog-if 80 [Master])
	Flags: bus master, medium devsel, latency 0
	[virtual] Memory at 000001f0 (32-bit, non-prefetchable) [size=8]
	[virtual] Memory at 000003f0 (type 3, non-prefetchable) [size=1]
	[virtual] Memory at 00000170 (32-bit, non-prefetchable) [size=8]
	[virtual] Memory at 00000370 (type 3, non-prefetchable) [size=1]
	I/O ports at 1400 [size=16]
	Kernel driver in use: CS5530 IDE

00:12.3 Multimedia audio controller: Cyrix Corporation 5530 Audio [Kahlua]
	Flags: bus master, medium devsel, latency 0
	Memory at 40011000 (32-bit, non-prefetchable) [size=128]
	Kernel driver in use: CS5530_Audio

00:12.4 VGA compatible controller: Cyrix Corporation 5530 Video [Kahlua] (prog-if 00 [VGA controller])
	Subsystem: Cyrix Corporation Device 0001
	Flags: medium devsel
	Memory at 40800000 (32-bit, non-prefetchable) [size=8M]
	Expansion ROM at <unassigned> [disabled]

00:13.0 USB Controller: Compaq Computer Corporation ZFMicro Chipset USB (rev 06) (prog-if 10 [OHCI])
	Subsystem: Compaq Computer Corporation ZFMicro Chipset USB
	Flags: bus master, medium devsel, latency 64, IRQ 9
	Memory at fedff000 (32-bit, non-prefetchable) [size=4K]
	Kernel driver in use: ohci_hcd


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] x86: EuroBraille/Iris power off
  2010-08-26  6:45           ` Sebastien Hinderer
@ 2010-08-26  6:55             ` H. Peter Anvin
  2010-08-26  7:09               ` Andreas Mohr
  2010-08-26  9:29               ` Sebastien Hinderer
  0 siblings, 2 replies; 31+ messages in thread
From: H. Peter Anvin @ 2010-08-26  6:55 UTC (permalink / raw)
  To: Sebastien Hinderer
  Cc: Samuel Thibault, Andreas Mohr, Thomas Gleixner, Ingo Molnar, x86,
	Andrew Morton, Frederic Weisbecker, Len Brown, linux-kernel

On 08/25/2010 11:45 PM, Sebastien Hinderer wrote:
> Hi,
> 
>> What other forms of enumerable hardware is on this machine?  PCI?
> 
> Yes, just PCI I think.
> 
> Below is the output of lspci -v if that helps.
> 
> Best wishes,
> Shérab.
> 
> 00:00.0 Host bridge: Cyrix Corporation PCI Master
> 	Flags: bus master, medium devsel, latency 0
> 

Good grief ... these clowns didn't even program the subsystem ID?  Could
you verify with lspci -vv -n?

	-hpa

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] x86: EuroBraille/Iris power off
  2010-08-26  6:55             ` H. Peter Anvin
@ 2010-08-26  7:09               ` Andreas Mohr
  2010-08-26  9:29               ` Sebastien Hinderer
  1 sibling, 0 replies; 31+ messages in thread
From: Andreas Mohr @ 2010-08-26  7:09 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Sebastien Hinderer, Samuel Thibault, Andreas Mohr,
	Thomas Gleixner, Ingo Molnar, x86, Andrew Morton,
	Frederic Weisbecker, Len Brown, linux-kernel

On Wed, Aug 25, 2010 at 11:55:42PM -0700, H. Peter Anvin wrote:
> On 08/25/2010 11:45 PM, Sebastien Hinderer wrote:
> > 00:00.0 Host bridge: Cyrix Corporation PCI Master
> > 	Flags: bus master, medium devsel, latency 0
> > 
> 
> Good grief ... these clowns didn't even program the subsystem ID?  Could
> you verify with lspci -vv -n?

Given the very non-standard environment as compared to a modern PC,
perhaps it's a good idea to tend towards establishing a standard
"pseudo-DMI" detection method for old-style "PC standard" hardware?
(which could support functions for checking a BIOS signature
at a defined, well-known BIOS memory location,
or functions for a VGA BIOS signature, or detecting certain standardized
BIOS flag words).
If a PC simply lacks all usual modern methods, then it's us (Linux)
who has to provide an utmost reliable fallback mechanism,
since that would still be much better than having raw, unverified
driver access.

Andreas Mohr

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] x86: EuroBraille/Iris power off
  2010-08-26  6:55             ` H. Peter Anvin
  2010-08-26  7:09               ` Andreas Mohr
@ 2010-08-26  9:29               ` Sebastien Hinderer
  1 sibling, 0 replies; 31+ messages in thread
From: Sebastien Hinderer @ 2010-08-26  9:29 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Samuel Thibault, Andreas Mohr, Thomas Gleixner, Ingo Molnar, x86,
	Andrew Morton, Frederic Weisbecker, Len Brown, linux-kernel

Hi again,

H. Peter Anvin (2010/08/25 23:55 -0700):
> > 00:00.0 Host bridge: Cyrix Corporation PCI Master
> > 	Flags: bus master, medium devsel, latency 0
> > 
> 
> Good grief ... these clowns didn't even program the subsystem ID?  Could
> you verify with lspci -vv -n?

It's included below.

Shérab.

00:00.0 0600: 1078:0001
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0

00:02.0 0200: 1282:9102 (rev 40)
	Subsystem: 0291:8212
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 165 (5000ns min, 10000ns max)
	Interrupt: pin A routed to IRQ 11
	Region 0: I/O ports at 1000 [size=256]
	Region 1: Memory at fedfe000 (32-bit, non-prefetchable) [size=256]
	[virtual] Expansion ROM at 08000000 [disabled] [size=256K]
	Capabilities: [50] Power Management version 2
		Flags: PMEClk- DSI- D1- D2- AuxCurrent=160mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
		Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
	Kernel driver in use: dmfe

00:12.0 0601: 1078:0100 (rev 30)
	Control: I/O+ Mem+ BusMaster+ SpecCycle+ MemWINV+ VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 64, Cache Line Size: 16 bytes

00:12.1 0680: 1078:0101
	Control: I/O- Mem+ BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Region 0: Memory at 40012000 (32-bit, non-prefetchable) [size=256]

00:12.2 0101: 1078:0102 (prog-if 80 [Master])
	Control: I/O+ Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0
	Region 0: [virtual] Memory at 000001f0 (32-bit, non-prefetchable) [size=8]
	Region 1: [virtual] Memory at 000003f0 (type 3, non-prefetchable) [size=1]
	Region 2: [virtual] Memory at 00000170 (32-bit, non-prefetchable) [size=8]
	Region 3: [virtual] Memory at 00000370 (type 3, non-prefetchable) [size=1]
	Region 4: I/O ports at 1400 [size=16]
	Kernel driver in use: CS5530 IDE

00:12.3 0401: 1078:0103
	Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0
	Region 0: Memory at 40011000 (32-bit, non-prefetchable) [size=128]
	Kernel driver in use: CS5530_Audio

00:12.4 0300: 1078:0104 (prog-if 00 [VGA controller])
	Subsystem: 1078:0001
	Control: I/O+ Mem+ BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Region 0: Memory at 40800000 (32-bit, non-prefetchable) [size=8M]
	Expansion ROM at <unassigned> [disabled]

00:13.0 0c03: 0e11:a0f8 (rev 06) (prog-if 10 [OHCI])
	Subsystem: 0e11:a0f8
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV+ VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 64 (20000ns max)
	Interrupt: pin A routed to IRQ 9
	Region 0: Memory at fedff000 (32-bit, non-prefetchable) [size=4K]
	Kernel driver in use: ohci_hcd


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] x86: EuroBraille/Iris power off
  2010-08-25  9:49 [PATCH] x86: EuroBraille/Iris power off Shérab
  2010-08-25 16:12 ` Andreas Mohr
@ 2010-08-26 18:11 ` Len Brown
  2010-08-26 21:08   ` Shérab
  1 sibling, 1 reply; 31+ messages in thread
From: Len Brown @ 2010-08-26 18:11 UTC (permalink / raw)
  To: Shérab
  Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, Andrew Morton,
	Frederic Weisbecker, Andres Salomon, Linux Kernel Mailing List,
	Samuel Thibault

[-- Attachment #1: Type: TEXT/PLAIN, Size: 719 bytes --]

>     The Iris machines from EuroBraille do not have APM or ACPI support
>     to shut themselves down properly.

According to
www.multitech.com/en_us/news/articles/success_stories/eurobraille.pdf :

"EURObraille’s latest invention is the IRIS portable assistant.
 The use of a powerful microprocessor coupled with the most advanced
 Microsoft Windows operating system provides the blind with a powerful
 computing solution"

What version of Microsoft Windows ships on this box?
Does it run in ACPI mode?  Does it power-off successfully?

Does Linux run in ACPI mode?
Please send along the dmesg from a Linux kernel built with:

CONFIG_ACPI=y
CONFIG_ACPI_DEBUG=y

thanks,
Len Brown, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] x86: EuroBraille/Iris power off
  2010-08-26 18:11 ` Len Brown
@ 2010-08-26 21:08   ` Shérab
  2010-08-26 21:16     ` H. Peter Anvin
  0 siblings, 1 reply; 31+ messages in thread
From: Shérab @ 2010-08-26 21:08 UTC (permalink / raw)
  To: Len Brown
  Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, Andrew Morton,
	Frederic Weisbecker, Andres Salomon, Linux Kernel Mailing List,
	Samuel Thibault

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

Hi,

> What version of Microsoft Windows ships on this box?

It's Windows CE but I can't give a more precise version number.

> Does it run in ACPI mode?

I don't know and I don't think it would be possible to determine it,
since one just has access to a dedicated application and not to the
interface of the operating system itself.

> Does it power-off successfully?

Yes, and most probably the same way the proposed module does.

> Does Linux run in ACPI mode?

I don't think so.

> Please send along the dmesg from a Linux kernel built with:
> 
> CONFIG_ACPI=y
> CONFIG_ACPI_DEBUG=y

It's attached.

Thanks,
Shérab.

[-- Attachment #2: dmesg-with-acpi-debugging.bz2 --]
[-- Type: application/octet-stream, Size: 5403 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] x86: EuroBraille/Iris power off
  2010-08-26 21:08   ` Shérab
@ 2010-08-26 21:16     ` H. Peter Anvin
  2010-08-27 17:35       ` Shérab
                         ` (2 more replies)
  0 siblings, 3 replies; 31+ messages in thread
From: H. Peter Anvin @ 2010-08-26 21:16 UTC (permalink / raw)
  To: Shérab
  Cc: Len Brown, Thomas Gleixner, Ingo Molnar, x86, Andrew Morton,
	Frederic Weisbecker, Andres Salomon, Linux Kernel Mailing List,
	Samuel Thibault

On 08/26/2010 02:08 PM, Shérab wrote:
> 
>> Does Linux run in ACPI mode?
> 
> I don't think so.
> 

No, doesn't look like it.

>> Please send along the dmesg from a Linux kernel built with:
>>
>> CONFIG_ACPI=y
>> CONFIG_ACPI_DEBUG=y
> 
> It's attached.
> 

What about APM?

	-hpa

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] x86: EuroBraille/Iris power off
  2010-08-26 21:16     ` H. Peter Anvin
@ 2010-08-27 17:35       ` Shérab
  2010-08-27 18:49         ` H. Peter Anvin
  2010-08-27 22:27       ` Shérab
  2010-08-29 20:59       ` Shérab
  2 siblings, 1 reply; 31+ messages in thread
From: Shérab @ 2010-08-27 17:35 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Len Brown, Thomas Gleixner, Ingo Molnar, x86, Andrew Morton,
	Frederic Weisbecker, Andres Salomon, Linux Kernel Mailing List,
	Samuel Thibault

Hi,

> 	-hpa
> 

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] x86: EuroBraille/Iris power off
  2010-08-27 17:35       ` Shérab
@ 2010-08-27 18:49         ` H. Peter Anvin
  0 siblings, 0 replies; 31+ messages in thread
From: H. Peter Anvin @ 2010-08-27 18:49 UTC (permalink / raw)
  To: Shérab
  Cc: Len Brown, Thomas Gleixner, Ingo Molnar, x86, Andrew Morton,
	Frederic Weisbecker, Andres Salomon, Linux Kernel Mailing List,
	Samuel Thibault

On 08/27/2010 10:35 AM, Shérab wrote:
> Hi,

Hello...

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] x86: EuroBraille/Iris power off
  2010-08-26 21:16     ` H. Peter Anvin
  2010-08-27 17:35       ` Shérab
@ 2010-08-27 22:27       ` Shérab
  2010-08-29 20:59       ` Shérab
  2 siblings, 0 replies; 31+ messages in thread
From: Shérab @ 2010-08-27 22:27 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Len Brown, Thomas Gleixner, Ingo Molnar, x86, Andrew Morton,
	Frederic Weisbecker, Andres Salomon, Linux Kernel Mailing List,
	Samuel Thibault

Hi,

Sorry for the previous message, certainly a wrong editing command.

> What about APM?

I couldn't compile the kernel with APM support.
I'm on master, APM depends on PM_SLEEP which I couldn't find in any
Kconfig file. So I added it by hand in.config and ran make menuconfig
again. This time the APM stuff was visible, so I could activate it,
but then compiling the kernel failed.
I'm sure I'm missing something and I'm sorry about that, if someone
could help that would be very appreciated.

Thanks,
Shérab.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] x86: EuroBraille/Iris power off
  2010-08-26 21:16     ` H. Peter Anvin
  2010-08-27 17:35       ` Shérab
  2010-08-27 22:27       ` Shérab
@ 2010-08-29 20:59       ` Shérab
  2010-09-13 10:07         ` Shérab
  2 siblings, 1 reply; 31+ messages in thread
From: Shérab @ 2010-08-29 20:59 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Len Brown, Thomas Gleixner, Ingo Molnar, x86, Andrew Morton,
	Frederic Weisbecker, Andres Salomon, Linux Kernel Mailing List,
	Samuel Thibault

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

Hi,

H. Peter Anvin (2010/08/26 14:16 -0700):
> What about APM?

Not either, I think.
See attached dmesg output.
Shérab.

[-- Attachment #2: dmesg-with-apm-debugging.bz2 --]
[-- Type: application/octet-stream, Size: 6605 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] x86: EuroBraille/Iris power off
  2010-08-29 20:59       ` Shérab
@ 2010-09-13 10:07         ` Shérab
  2010-09-13 15:10           ` Valdis.Kletnieks
  0 siblings, 1 reply; 31+ messages in thread
From: Shérab @ 2010-09-13 10:07 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Len Brown, Thomas Gleixner, Ingo Molnar, x86, Andrew Morton,
	Frederic Weisbecker, Andres Salomon, Linux Kernel Mailing List,
	Samuel Thibault

Dear all,

This thread has been sleeping for a few days now so I'm trying to wake
it up.

Brief summary: the included patch provides an iris module with a power
off function for a machine that, as has already been seen, has no APM,
no ACPI and no DMI.

The output of lspci -vv -n is included again.

Thanks for your attention,
Shérab.

00:00.0 0600: 1078:0001
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0

00:02.0 0200: 1282:9102 (rev 40)
	Subsystem: 0291:8212
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 165 (5000ns min, 10000ns max)
	Interrupt: pin A routed to IRQ 11
	Region 0: I/O ports at 1000 [size=256]
	Region 1: Memory at fedfe000 (32-bit, non-prefetchable) [size=256]
	[virtual] Expansion ROM at 08000000 [disabled] [size=256K]
	Capabilities: [50] Power Management version 2
		Flags: PMEClk- DSI- D1- D2- AuxCurrent=160mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
		Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
	Kernel driver in use: dmfe

00:12.0 0601: 1078:0100 (rev 30)
	Control: I/O+ Mem+ BusMaster+ SpecCycle+ MemWINV+ VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 64, Cache Line Size: 16 bytes

00:12.1 0680: 1078:0101
	Control: I/O- Mem+ BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Region 0: Memory at 40012000 (32-bit, non-prefetchable) [size=256]

00:12.2 0101: 1078:0102 (prog-if 80 [Master])
	Control: I/O+ Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0
	Region 0: [virtual] Memory at 000001f0 (32-bit, non-prefetchable) [size=8]
	Region 1: [virtual] Memory at 000003f0 (type 3, non-prefetchable) [size=1]
	Region 2: [virtual] Memory at 00000170 (32-bit, non-prefetchable) [size=8]
	Region 3: [virtual] Memory at 00000370 (type 3, non-prefetchable) [size=1]
	Region 4: I/O ports at 1400 [size=16]
	Kernel driver in use: CS5530 IDE

00:12.3 0401: 1078:0103
	Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0
	Region 0: Memory at 40011000 (32-bit, non-prefetchable) [size=128]
	Kernel driver in use: CS5530_Audio

00:12.4 0300: 1078:0104 (prog-if 00 [VGA controller])
	Subsystem: 1078:0001
	Control: I/O+ Mem+ BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Region 0: Memory at 40800000 (32-bit, non-prefetchable) [size=8M]
	Expansion ROM at <unassigned> [disabled]

00:13.0 0c03: 0e11:a0f8 (rev 06) (prog-if 10 [OHCI])
	Subsystem: 0e11:a0f8
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV+ VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 64 (20000ns max)
	Interrupt: pin A routed to IRQ 9
	Region 0: Memory at fedff000 (32-bit, non-prefetchable) [size=4K]
	Kernel driver in use: ohci_hcd

>From 197e523553a791f97536143001f22abd36f7992c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sh=C3=A9rab?= <Sebastien.Hinderer@ens-lyon.org>
Date: Wed, 25 Aug 2010 23:00:14 +0200
Subject: [PATCH] Eurobraille/Iris power off.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="utf-8"

The Iris machines from EuroBraille do not have APM or ACPI support
to shut themselves down properly.  A special I/O sequence is
needed to do so.  This modle runs this I/O sequence at
kernel shutdown.

This is only for Iris machines from EuroBraille.
Signed-off-by: Shérab <Sebastien.Hinderer@ens-lyon.org>
---
 arch/x86/Kconfig         |   13 +++++++
 arch/x86/kernel/Makefile |    1 +
 arch/x86/kernel/iris.c   |   80 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 94 insertions(+), 0 deletions(-)
 create mode 100644 arch/x86/kernel/iris.c

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index ac7827f..88bf897 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -493,6 +493,19 @@ config X86_ES7000
 	  Support for Unisys ES7000 systems.  Say 'Y' here if this kernel is
 	  supposed to run on an IA32-based Unisys ES7000 system.
 
+config X86_32_IRIS
+	tristate "Eurobraille/Iris poweroff module"
+	depends on X86_32
+	---help---
+	  The Iris machines from EuroBraille do not have APM or ACPI support
+	  to shut themselves down properly.  A special I/O sequence is
+	  needed to do so, which is what this module does at
+	  kernel shutdown.
+
+	  This is only for Iris machines from EuroBraille.
+
+	  If unused, say N.
+
 config SCHED_OMIT_FRAME_POINTER
 	def_bool y
 	prompt "Single-depth WCHAN output"
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index 0925676..98dd1c8 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -115,6 +115,7 @@ obj-$(CONFIG_MICROCODE)			+= microcode.o
 obj-$(CONFIG_X86_CHECK_BIOS_CORRUPTION) += check.o
 
 obj-$(CONFIG_SWIOTLB)			+= pci-swiotlb.o
+obj-$(CONFIG_X86_32_IRIS)		+= iris.o
 
 ###
 # 64 bit specific files
diff --git a/arch/x86/kernel/iris.c b/arch/x86/kernel/iris.c
new file mode 100644
index 0000000..8856ef3
--- /dev/null
+++ b/arch/x86/kernel/iris.c
@@ -0,0 +1,80 @@
+/*
+ * Eurobraille/Iris power off support.
+ *
+ * Eurobraille's Iris machine is a PC with no APM or ACPI support.
+ * It is shutdown by a special I/O sequence which this module provides.
+ *
+ *  Copyright (C) Shérab <Sebastien.Hinderer@ens-lyon.org>
+ *
+ * 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 the program ; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/pm.h>
+#include <linux/delay.h>
+#include <asm/io.h>
+
+#define IRIS_GIO_BASE 0x340
+#define IRIS_GIO_INPUT IRIS_GIO_BASE
+#define IRIS_GIO_OUTPUT (IRIS_GIO_BASE + 1)
+#define IRIS_GIO_PULSE 0x80 /* First byte to send */
+#define IRIS_GIO_REST 0x0 /* Second byte to send */
+#define IRIS_GIO_NODEV 0xff /* Likely not an Iris */
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Sébastien Hinderer <Sebastien.Hinderer@ens-lyon.org>");
+MODULE_DESCRIPTION("A power_off handler for Iris devices from EuroBraille");
+MODULE_SUPPORTED_DEVICE("Eurobraille/Iris");
+
+static void (*old_pm_power_off)(void);
+
+static void iris_power_off(void)
+{
+	outb(IRIS_GIO_PULSE, IRIS_GIO_OUTPUT);
+	msleep(850);
+	outb(IRIS_GIO_REST, IRIS_GIO_OUTPUT);
+}
+
+/*
+ * Before installing the power_off handler, try to make sure the OS is
+ * running on an Iris.  Since Iris does not support DMI, this is done
+ * by reading its input port and seeing whether the read value is
+ * meaningful.
+ */
+static int iris_init(void)
+{
+	unsigned char status = inb(IRIS_GIO_INPUT);
+	if (status == IRIS_GIO_NODEV) {
+		printk(KERN_ERR "This machine does not seem to be an Iris. Power_off handler not installed.\n");
+		return -ENODEV;
+	}
+	old_pm_power_off = pm_power_off;
+	pm_power_off = &iris_power_off;
+	printk(KERN_INFO "Iris power_off handler installed.\n");
+	return 0;
+}
+
+static void iris_exit(void)
+{
+	pm_power_off = old_pm_power_off;
+	printk(KERN_INFO "Iris power_off handler uninstalled.\n");
+}
+
+module_init(iris_init);
+module_exit(iris_exit);
+
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCH] x86: EuroBraille/Iris power off
  2010-09-13 10:07         ` Shérab
@ 2010-09-13 15:10           ` Valdis.Kletnieks
  2010-09-13 15:22             ` Samuel Thibault
  2010-09-13 15:25             ` Shérab
  0 siblings, 2 replies; 31+ messages in thread
From: Valdis.Kletnieks @ 2010-09-13 15:10 UTC (permalink / raw)
  To: Shérab
  Cc: H. Peter Anvin, Len Brown, Thomas Gleixner, Ingo Molnar, x86,
	Andrew Morton, Frederic Weisbecker, Andres Salomon,
	Linux Kernel Mailing List, Samuel Thibault

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

On Mon, 13 Sep 2010 12:07:19 +0200, Shérab said:

> +static int iris_init(void)
> +{
> +	unsigned char status = inb(IRIS_GIO_INPUT);
> +	if (status == IRIS_GIO_NODEV) {
> +		printk(KERN_ERR "This machine does not seem to be an Iris. Power_off handler not installed.\n");
> +		return -ENODEV;
> +	}

Is it actually safe to assume that this will do the right thing on a machine that
is a non-Iris that has something *else* at that I/O  address?  Any further sanity
checking we can do?  (For that matter, are there machines that will get indigestion
at this sort of unexpected inb() access?)

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

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] x86: EuroBraille/Iris power off
  2010-09-13 15:10           ` Valdis.Kletnieks
@ 2010-09-13 15:22             ` Samuel Thibault
  2010-09-13 16:06               ` H. Peter Anvin
  2010-09-14  1:45               ` Valdis.Kletnieks
  2010-09-13 15:25             ` Shérab
  1 sibling, 2 replies; 31+ messages in thread
From: Samuel Thibault @ 2010-09-13 15:22 UTC (permalink / raw)
  To: Valdis.Kletnieks
  Cc: Shérab, H. Peter Anvin, Len Brown, Thomas Gleixner,
	Ingo Molnar, x86, Andrew Morton, Frederic Weisbecker,
	Andres Salomon, Linux Kernel Mailing List

Valdis.Kletnieks@vt.edu, le Mon 13 Sep 2010 11:10:47 -0400, a écrit :
> On Mon, 13 Sep 2010 12:07:19 +0200, Shérab said:
> 
> > +static int iris_init(void)
> > +{
> > +	unsigned char status = inb(IRIS_GIO_INPUT);
> > +	if (status == IRIS_GIO_NODEV) {
> > +		printk(KERN_ERR "This machine does not seem to be an Iris. Power_off handler not installed.\n");
> > +		return -ENODEV;
> > +	}
> 
> Is it actually safe to assume that this will do the right thing on a machine that
> is a non-Iris that has something *else* at that I/O  address?

No.

> Any further sanity checking we can do?

No. The format of the value there is quite unknown, it's just quite sure
it won't be 0xff on the Iris.

Again, I'm not sure we really should try hard to make it automatically
detected (and thus always enabled).  Having to pass a kernel parameter
to enable the functionality is completely fine, since installing Linux
on this device requires quite some tinkering already.

Samuel

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] x86: EuroBraille/Iris power off
  2010-09-13 15:10           ` Valdis.Kletnieks
  2010-09-13 15:22             ` Samuel Thibault
@ 2010-09-13 15:25             ` Shérab
  2010-09-13 15:48               ` H. Peter Anvin
  1 sibling, 1 reply; 31+ messages in thread
From: Shérab @ 2010-09-13 15:25 UTC (permalink / raw)
  To: Valdis.Kletnieks
  Cc: H. Peter Anvin, Len Brown, Thomas Gleixner, Ingo Molnar, x86,
	Andrew Morton, Frederic Weisbecker, Andres Salomon,
	Linux Kernel Mailing List, Samuel Thibault

Hi,

> Is it actually safe to assume that this will do the right thing on a machine that
> is a non-Iris that has something *else* at that I/O  address?

No it's probably not safe.

> Any further sanity checking we can do?

I have asked the manufacturer and will be happy to provide patches to
implement them but I doubt there will be some.

> (For that matter, are there machines that will get indigestion
> at this sort of unexpected inb() access?)

That, I don't know.

Shérab.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] x86: EuroBraille/Iris power off
  2010-09-13 15:25             ` Shérab
@ 2010-09-13 15:48               ` H. Peter Anvin
  0 siblings, 0 replies; 31+ messages in thread
From: H. Peter Anvin @ 2010-09-13 15:48 UTC (permalink / raw)
  To: Shérab
  Cc: Valdis.Kletnieks, Len Brown, Thomas Gleixner, Ingo Molnar, x86,
	Andrew Morton, Frederic Weisbecker, Andres Salomon,
	Linux Kernel Mailing List, Samuel Thibault

On 09/13/2010 08:25 AM, Shérab wrote:
> 
>> (For that matter, are there machines that will get indigestion
>> at this sort of unexpected inb() access?)
> 

Yes, there are... since it's an address which can contain any kind of
I/O device.

	-hpa

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] x86: EuroBraille/Iris power off
  2010-09-13 15:22             ` Samuel Thibault
@ 2010-09-13 16:06               ` H. Peter Anvin
  2010-09-13 16:12                 ` Samuel Thibault
  2010-09-14  1:45               ` Valdis.Kletnieks
  1 sibling, 1 reply; 31+ messages in thread
From: H. Peter Anvin @ 2010-09-13 16:06 UTC (permalink / raw)
  To: Samuel Thibault, Valdis.Kletnieks, Shérab, Len Brown,
	Thomas Gleixner, Ingo Molnar, x86, Andrew Morton,
	Frederic Weisbecker, Andres Salomon, Linux Kernel Mailing List

On 09/13/2010 08:22 AM, Samuel Thibault wrote:
> 
> Again, I'm not sure we really should try hard to make it automatically
> detected (and thus always enabled).  Having to pass a kernel parameter
> to enable the functionality is completely fine, since installing Linux
> on this device requires quite some tinkering already.
> 

Could you describe this kind of tinkering?

	-hpa

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] x86: EuroBraille/Iris power off
  2010-09-13 16:06               ` H. Peter Anvin
@ 2010-09-13 16:12                 ` Samuel Thibault
  0 siblings, 0 replies; 31+ messages in thread
From: Samuel Thibault @ 2010-09-13 16:12 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Valdis.Kletnieks, Shérab, Len Brown, Thomas Gleixner,
	Ingo Molnar, x86, Andrew Morton, Frederic Weisbecker,
	Andres Salomon, Linux Kernel Mailing List

H. Peter Anvin, le Mon 13 Sep 2010 09:06:37 -0700, a écrit :
> On 09/13/2010 08:22 AM, Samuel Thibault wrote:
> > Again, I'm not sure we really should try hard to make it automatically
> > detected (and thus always enabled).  Having to pass a kernel parameter
> > to enable the functionality is completely fine, since installing Linux
> > on this device requires quite some tinkering already.
> > 
> 
> Could you describe this kind of tinkering?

Basically, opening the device to select boot on the external
CompactFlash reader.

Samuel

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] x86: EuroBraille/Iris power off
  2010-09-13 15:22             ` Samuel Thibault
  2010-09-13 16:06               ` H. Peter Anvin
@ 2010-09-14  1:45               ` Valdis.Kletnieks
  2010-09-14  5:16                 ` Shérab
  2010-09-20  8:22                 ` Shérab
  1 sibling, 2 replies; 31+ messages in thread
From: Valdis.Kletnieks @ 2010-09-14  1:45 UTC (permalink / raw)
  To: Samuel Thibault
  Cc: Shérab, H. Peter Anvin, Len Brown, Thomas Gleixner,
	Ingo Molnar, x86, Andrew Morton, Frederic Weisbecker,
	Andres Salomon, Linux Kernel Mailing List

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

On Mon, 13 Sep 2010 17:22:49 +0200, Samuel Thibault said:

> Again, I'm not sure we really should try hard to make it automatically
> detected (and thus always enabled).  Having to pass a kernel parameter
> to enable the functionality is completely fine, since installing Linux
> on this device requires quite some tinkering already.

I'm agreeing that if iris_init() checks that the user passed 'irisinit.force=1'
on the command line or as a module parameter, and bailed immediately if it
wasn't passed, then doing the inb() and testing it should be safe enough. Doing
stuff that's only known safe on an Iris is no great sin if the user has said
"Yes, you're on a Iris" - at that point it's the user's fault.

static int iris_init(void)
{
	unsigned char status;

	if (!irisinit.force) return; /* or whatever the appropriate test is */

	status = inb(IRIS_GIO_INPUT);
	if (status == IRIS_GIO_NODEV) {
		printk(KERN_ERR "This machine does not seem to be an Iris. Power_off handler not installed.\n");
		return -ENODEV;
	}

That look safe enough to everybody?  That way, even if a distro turns on every
CONFIG_FOO that compiles (you guys know who you are ;), it should still DTRT on
all platforms.


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

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] x86: EuroBraille/Iris power off
  2010-09-14  1:45               ` Valdis.Kletnieks
@ 2010-09-14  5:16                 ` Shérab
  2010-09-20  8:22                 ` Shérab
  1 sibling, 0 replies; 31+ messages in thread
From: Shérab @ 2010-09-14  5:16 UTC (permalink / raw)
  To: Valdis.Kletnieks
  Cc: Samuel Thibault, H. Peter Anvin, Len Brown, Thomas Gleixner,
	Ingo Molnar, x86, Andrew Morton, Frederic Weisbecker,
	Andres Salomon, Linux Kernel Mailing List

Hi,

Valdis.Kletnieks@vt.edu (2010/09/13 21:45 -0400):
> I'm agreeing that if iris_init() checks that the user passed 'irisinit.force=1'
> on the command line or as a module parameter, and bailed immediately if it
> wasn't passed, then doing the inb() and testing it should be safe enough. Doing
> stuff that's only known safe on an Iris is no great sin if the user has said
> "Yes, you're on a Iris" - at that point it's the user's fault.

Fine. I'd be happy to submit another patch where the module takes a
force argument if that's okay to you guys.

Shérab.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] x86: EuroBraille/Iris power off
  2010-09-14  1:45               ` Valdis.Kletnieks
  2010-09-14  5:16                 ` Shérab
@ 2010-09-20  8:22                 ` Shérab
  2010-09-26 17:54                   ` Shérab
  1 sibling, 1 reply; 31+ messages in thread
From: Shérab @ 2010-09-20  8:22 UTC (permalink / raw)
  To: Valdis.Kletnieks
  Cc: Samuel Thibault, H. Peter Anvin, Len Brown, Thomas Gleixner,
	Ingo Molnar, x86, Andrew Morton, Frederic Weisbecker,
	Andres Salomon, Linux Kernel Mailing List

Dear all,

Valdis.Kletnieks@vt.edu (2010/09/13 21:45 -0400):
> On Mon, 13 Sep 2010 17:22:49 +0200, Samuel Thibault said:
> 
> > Again, I'm not sure we really should try hard to make it automatically
> > detected (and thus always enabled).  Having to pass a kernel parameter
> > to enable the functionality is completely fine, since installing Linux
> > on this device requires quite some tinkering already.
> 
> I'm agreeing that if iris_init() checks that the user passed 'irisinit.force=1'
> on the command line or as a module parameter, and bailed immediately if it
> wasn't passed, then doing the inb() and testing it should be safe
> enough. [...]

Please find below a revised version of the module that does what has
been asked.

Cheers,
Shérab.

>From c7d27a83ba8ec5e5c18f1ef02af4f740f4db1b7b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sh=C3=A9rab?= <Sebastien.Hinderer@ens-lyon.org>
Date: Mon, 20 Sep 2010 10:15:16 +0200
Subject: [PATCH] Eurobraille/Iris power off.
 The Iris machines from EuroBraille do not have APM or ACPI support
 to shut themselves down properly.  A special I/O sequence is
 needed to do so.  This modle runs this I/O sequence at
 kernel shutdown when its force parameter is set to 1.
Content-Type: text/plain; charset="utf-8"

---
 arch/x86/Kconfig         |   13 +++++++
 arch/x86/kernel/Makefile |    1 +
 arch/x86/kernel/iris.c   |   90 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 104 insertions(+), 0 deletions(-)
 create mode 100644 arch/x86/kernel/iris.c

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index cea0cd9..7c8e261 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -493,6 +493,19 @@ config X86_ES7000
 	  Support for Unisys ES7000 systems.  Say 'Y' here if this kernel is
 	  supposed to run on an IA32-based Unisys ES7000 system.
 
+config X86_32_IRIS
+	tristate "Eurobraille/Iris poweroff module"
+	depends on X86_32
+	---help---
+	  The Iris machines from EuroBraille do not have APM or ACPI support
+	  to shut themselves down properly.  A special I/O sequence is
+	  needed to do so, which is what this module does at
+	  kernel shutdown.
+
+	  This is only for Iris machines from EuroBraille.
+
+	  If unused, say N.
+
 config SCHED_OMIT_FRAME_POINTER
 	def_bool y
 	prompt "Single-depth WCHAN output"
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index 0925676..98dd1c8 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -115,6 +115,7 @@ obj-$(CONFIG_MICROCODE)			+= microcode.o
 obj-$(CONFIG_X86_CHECK_BIOS_CORRUPTION) += check.o
 
 obj-$(CONFIG_SWIOTLB)			+= pci-swiotlb.o
+obj-$(CONFIG_X86_32_IRIS)		+= iris.o
 
 ###
 # 64 bit specific files
diff --git a/arch/x86/kernel/iris.c b/arch/x86/kernel/iris.c
new file mode 100644
index 0000000..83a913b
--- /dev/null
+++ b/arch/x86/kernel/iris.c
@@ -0,0 +1,90 @@
+/*
+ * Eurobraille/Iris power off support.
+ *
+ * Eurobraille's Iris machine is a PC with no APM or ACPI support.
+ * It is shutdown by a special I/O sequence which this module provides.
+ *
+ *  Copyright (C) Shérab <Sebastien.Hinderer@ens-lyon.org>
+ *
+ * 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 the program ; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/pm.h>
+#include <linux/delay.h>
+#include <asm/io.h>
+
+#define IRIS_GIO_BASE 0x340
+#define IRIS_GIO_INPUT IRIS_GIO_BASE
+#define IRIS_GIO_OUTPUT (IRIS_GIO_BASE + 1)
+#define IRIS_GIO_PULSE 0x80 /* First byte to send */
+#define IRIS_GIO_REST 0x0 /* Second byte to send */
+#define IRIS_GIO_NODEV 0xff /* Likely not an Iris */
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Sébastien Hinderer <Sebastien.Hinderer@ens-lyon.org>");
+MODULE_DESCRIPTION("A power_off handler for Iris devices from EuroBraille");
+MODULE_SUPPORTED_DEVICE("Eurobraille/Iris");
+
+static int force;
+module_param(force, bool, 0);
+MODULE_PARM_DESC(force, "Set to one to force poweroff handler installation.");
+
+static void (*old_pm_power_off)(void);
+
+static void iris_power_off(void)
+{
+	outb(IRIS_GIO_PULSE, IRIS_GIO_OUTPUT);
+	msleep(850);
+	outb(IRIS_GIO_REST, IRIS_GIO_OUTPUT);
+}
+
+/*
+ * Before installing the power_off handler, try to make sure the OS is
+ * running on an Iris.  Since Iris does not support DMI, this is done
+ * by reading its input port and seeing whether the read value is
+ * meaningful.
+ */
+static int iris_init(void)
+{
+	unsigned char status;
+	if (force != 1 )
+	{
+		printk(KERN_ERR "The force parameter has not been set to 1 so the Iris poweroff handler will not be installed.\n");
+		return -ENODEV;
+	}
+	status = inb(IRIS_GIO_INPUT);
+	if (status == IRIS_GIO_NODEV) {
+		printk(KERN_ERR "This machine does not seem to be an Iris. Power_off handler not installed.\n");
+		return -ENODEV;
+	}
+	old_pm_power_off = pm_power_off;
+	pm_power_off = &iris_power_off;
+	printk(KERN_INFO "Iris power_off handler installed.\n");
+	return 0;
+}
+
+static void iris_exit(void)
+{
+	pm_power_off = old_pm_power_off;
+	printk(KERN_INFO "Iris power_off handler uninstalled.\n");
+}
+
+module_init(iris_init);
+module_exit(iris_exit);
+
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCH] x86: EuroBraille/Iris power off
  2010-09-20  8:22                 ` Shérab
@ 2010-09-26 17:54                   ` Shérab
  2010-10-10 16:22                     ` Shérab
  0 siblings, 1 reply; 31+ messages in thread
From: Shérab @ 2010-09-26 17:54 UTC (permalink / raw)
  To: Valdis.Kletnieks
  Cc: Samuel Thibault, H. Peter Anvin, Len Brown, Thomas Gleixner,
	Ingo Molnar, x86, Andrew Morton, Frederic Weisbecker,
	Andres Salomon, Linux Kernel Mailing List

Hello,

Shérab (2010/09/20 10:22 +0200):
> Dear all,
> 
> Valdis.Kletnieks@vt.edu (2010/09/13 21:45 -0400):
> > On Mon, 13 Sep 2010 17:22:49 +0200, Samuel Thibault said:
> > 
> > > Again, I'm not sure we really should try hard to make it automatically
> > > detected (and thus always enabled).  Having to pass a kernel parameter
> > > to enable the functionality is completely fine, since installing Linux
> > > on this device requires quite some tinkering already.
> > 
> > I'm agreeing that if iris_init() checks that the user passed 'irisinit.force=1'
> > on the command line or as a module parameter, and bailed immediately if it
> > wasn't passed, then doing the inb() and testing it should be safe
> > enough. [...]
> 
> Please find below a revised version of the module that does what has
> been asked.

The previous patch had a few style problem and the moduleparam.h header
was not included whereas it should have been.
The version below passes ./script/checkpatch and the missing header has
been included, so the patch should be correct now.
Moreover the patch has been updated to apply on top of current master.

Shérab.

>From 2af50581bb591cd25ac59a7cf16902ea50f766db Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sh=C3=A9rab?= <Sebastien.Hinderer@ens-lyon.org>
Date: Sat, 25 Sep 2010 06:06:57 +0200
Subject: [PATCH] Eurobraille/Iris power off.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="utf-8"

The Iris machines from Eurobraille do not have APM or ACPI support
to shut themselves down properly.  A special I/O sequence is
needed to do so.  This modle runs this I/O sequence at
kernel shutdown when its force parameter is set to 1.
Signed-off-by: Shérab <Sebastien.Hinderer@ens-lyon.org>
---
 arch/x86/Kconfig         |   13 +++++++
 arch/x86/kernel/Makefile |    1 +
 arch/x86/kernel/iris.c   |   90 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 104 insertions(+), 0 deletions(-)
 create mode 100644 arch/x86/kernel/iris.c

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index cea0cd9..7c8e261 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -493,6 +493,19 @@ config X86_ES7000
 	  Support for Unisys ES7000 systems.  Say 'Y' here if this kernel is
 	  supposed to run on an IA32-based Unisys ES7000 system.
 
+config X86_32_IRIS
+	tristate "Eurobraille/Iris poweroff module"
+	depends on X86_32
+	---help---
+	  The Iris machines from EuroBraille do not have APM or ACPI support
+	  to shut themselves down properly.  A special I/O sequence is
+	  needed to do so, which is what this module does at
+	  kernel shutdown.
+
+	  This is only for Iris machines from EuroBraille.
+
+	  If unused, say N.
+
 config SCHED_OMIT_FRAME_POINTER
 	def_bool y
 	prompt "Single-depth WCHAN output"
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index 0925676..98dd1c8 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -115,6 +115,7 @@ obj-$(CONFIG_MICROCODE)			+= microcode.o
 obj-$(CONFIG_X86_CHECK_BIOS_CORRUPTION) += check.o
 
 obj-$(CONFIG_SWIOTLB)			+= pci-swiotlb.o
+obj-$(CONFIG_X86_32_IRIS)		+= iris.o
 
 ###
 # 64 bit specific files
diff --git a/arch/x86/kernel/iris.c b/arch/x86/kernel/iris.c
new file mode 100644
index 0000000..c6d8137
--- /dev/null
+++ b/arch/x86/kernel/iris.c
@@ -0,0 +1,90 @@
+/*
+ * Eurobraille/Iris power off support.
+ *
+ * Eurobraille's Iris machine is a PC with no APM or ACPI support.
+ * It is shutdown by a special I/O sequence which this module provides.
+ *
+ *  Copyright (C) Shérab <Sebastien.Hinderer@ens-lyon.org>
+ *
+ * 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 the program ; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/pm.h>
+#include <linux/delay.h>
+#include <asm/io.h>
+
+#define IRIS_GIO_BASE 0x340
+#define IRIS_GIO_INPUT IRIS_GIO_BASE
+#define IRIS_GIO_OUTPUT (IRIS_GIO_BASE + 1)
+#define IRIS_GIO_PULSE 0x80 /* First byte to send */
+#define IRIS_GIO_REST 0x0 /* Second byte to send */
+#define IRIS_GIO_NODEV 0xff /* Likely not an Iris */
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Sébastien Hinderer <Sebastien.Hinderer@ens-lyon.org>");
+MODULE_DESCRIPTION("A power_off handler for Iris devices from EuroBraille");
+MODULE_SUPPORTED_DEVICE("Eurobraille/Iris");
+
+static int force;
+module_param(force, bool, 0);
+MODULE_PARM_DESC(force, "Set to one to force poweroff handler installation.");
+
+static void (*old_pm_power_off)(void);
+
+static void iris_power_off(void)
+{
+	outb(IRIS_GIO_PULSE, IRIS_GIO_OUTPUT);
+	msleep(850);
+	outb(IRIS_GIO_REST, IRIS_GIO_OUTPUT);
+}
+
+/*
+ * Before installing the power_off handler, try to make sure the OS is
+ * running on an Iris.  Since Iris does not support DMI, this is done
+ * by reading its input port and seeing whether the read value is
+ * meaningful.
+ */
+static int iris_init(void)
+{
+	unsigned char status;
+	if (force != 1) {
+		printk(KERN_ERR "The force parameter has not been set to 1 so the Iris poweroff handler will not be installed.\n");
+		return -ENODEV;
+	}
+	status = inb(IRIS_GIO_INPUT);
+	if (status == IRIS_GIO_NODEV) {
+		printk(KERN_ERR "This machine does not seem to be an Iris. Power_off handler not installed.\n");
+		return -ENODEV;
+	}
+	old_pm_power_off = pm_power_off;
+	pm_power_off = &iris_power_off;
+	printk(KERN_INFO "Iris power_off handler installed.\n");
+	return 0;
+}
+
+static void iris_exit(void)
+{
+	pm_power_off = old_pm_power_off;
+	printk(KERN_INFO "Iris power_off handler uninstalled.\n");
+}
+
+module_init(iris_init);
+module_exit(iris_exit);
+
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCH] x86: EuroBraille/Iris power off
  2010-09-26 17:54                   ` Shérab
@ 2010-10-10 16:22                     ` Shérab
  2010-11-13 19:22                       ` Shérab
  0 siblings, 1 reply; 31+ messages in thread
From: Shérab @ 2010-10-10 16:22 UTC (permalink / raw)
  To: Valdis.Kletnieks
  Cc: Samuel Thibault, H. Peter Anvin, Len Brown, Thomas Gleixner,
	Ingo Molnar, x86, Andrew Morton, Frederic Weisbecker,
	Andres Salomon, Linux Kernel Mailing List

Hi,

I'm resending and would appreciate it very much if someone good have a
lookto it.
Thanks,
Shérab.

Shérab (2010/09/26 19:54 +0200):
> Hello,
> 
> Shérab (2010/09/20 10:22 +0200):
> > Dear all,
> > 
> > Valdis.Kletnieks@vt.edu (2010/09/13 21:45 -0400):
> > > On Mon, 13 Sep 2010 17:22:49 +0200, Samuel Thibault said:
> > > 
> > > > Again, I'm not sure we really should try hard to make it automatically
> > > > detected (and thus always enabled).  Having to pass a kernel parameter
> > > > to enable the functionality is completely fine, since installing Linux
> > > > on this device requires quite some tinkering already.
> > > 
> > > I'm agreeing that if iris_init() checks that the user passed 'irisinit.force=1'
> > > on the command line or as a module parameter, and bailed immediately if it
> > > wasn't passed, then doing the inb() and testing it should be safe
> > > enough. [...]
> > 
> > Please find below a revised version of the module that does what has
> > been asked.
> 
> The previous patch had a few style problem and the moduleparam.h header
> was not included whereas it should have been.
> The version below passes ./script/checkpatch and the missing header has
> been included, so the patch should be correct now.
> Moreover the patch has been updated to apply on top of current master.
> 
> Shérab.
> 
> From 2af50581bb591cd25ac59a7cf16902ea50f766db Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Sh=C3=A9rab?= <Sebastien.Hinderer@ens-lyon.org>
> Date: Sat, 25 Sep 2010 06:06:57 +0200
> Subject: [PATCH] Eurobraille/Iris power off.
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
> Content-Type: text/plain; charset="utf-8"
> 
> The Iris machines from Eurobraille do not have APM or ACPI support
> to shut themselves down properly.  A special I/O sequence is
> needed to do so.  This modle runs this I/O sequence at
> kernel shutdown when its force parameter is set to 1.
> Signed-off-by: Shérab <Sebastien.Hinderer@ens-lyon.org>
> ---
>  arch/x86/Kconfig         |   13 +++++++
>  arch/x86/kernel/Makefile |    1 +
>  arch/x86/kernel/iris.c   |   90 ++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 104 insertions(+), 0 deletions(-)
>  create mode 100644 arch/x86/kernel/iris.c
> 
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index cea0cd9..7c8e261 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -493,6 +493,19 @@ config X86_ES7000
>  	  Support for Unisys ES7000 systems.  Say 'Y' here if this kernel is
>  	  supposed to run on an IA32-based Unisys ES7000 system.
>  
> +config X86_32_IRIS
> +	tristate "Eurobraille/Iris poweroff module"
> +	depends on X86_32
> +	---help---
> +	  The Iris machines from EuroBraille do not have APM or ACPI support
> +	  to shut themselves down properly.  A special I/O sequence is
> +	  needed to do so, which is what this module does at
> +	  kernel shutdown.
> +
> +	  This is only for Iris machines from EuroBraille.
> +
> +	  If unused, say N.
> +
>  config SCHED_OMIT_FRAME_POINTER
>  	def_bool y
>  	prompt "Single-depth WCHAN output"
> diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
> index 0925676..98dd1c8 100644
> --- a/arch/x86/kernel/Makefile
> +++ b/arch/x86/kernel/Makefile
> @@ -115,6 +115,7 @@ obj-$(CONFIG_MICROCODE)			+= microcode.o
>  obj-$(CONFIG_X86_CHECK_BIOS_CORRUPTION) += check.o
>  
>  obj-$(CONFIG_SWIOTLB)			+= pci-swiotlb.o
> +obj-$(CONFIG_X86_32_IRIS)		+= iris.o
>  
>  ###
>  # 64 bit specific files
> diff --git a/arch/x86/kernel/iris.c b/arch/x86/kernel/iris.c
> new file mode 100644
> index 0000000..c6d8137
> --- /dev/null
> +++ b/arch/x86/kernel/iris.c
> @@ -0,0 +1,90 @@
> +/*
> + * Eurobraille/Iris power off support.
> + *
> + * Eurobraille's Iris machine is a PC with no APM or ACPI support.
> + * It is shutdown by a special I/O sequence which this module provides.
> + *
> + *  Copyright (C) Shérab <Sebastien.Hinderer@ens-lyon.org>
> + *
> + * 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 the program ; if not, write to the Free Software
> + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> + */
> +
> +#include <linux/module.h>
> +#include <linux/moduleparam.h>
> +#include <linux/kernel.h>
> +#include <linux/errno.h>
> +#include <linux/init.h>
> +#include <linux/pm.h>
> +#include <linux/delay.h>
> +#include <asm/io.h>
> +
> +#define IRIS_GIO_BASE 0x340
> +#define IRIS_GIO_INPUT IRIS_GIO_BASE
> +#define IRIS_GIO_OUTPUT (IRIS_GIO_BASE + 1)
> +#define IRIS_GIO_PULSE 0x80 /* First byte to send */
> +#define IRIS_GIO_REST 0x0 /* Second byte to send */
> +#define IRIS_GIO_NODEV 0xff /* Likely not an Iris */
> +
> +MODULE_LICENSE("GPL");
> +MODULE_AUTHOR("Sébastien Hinderer <Sebastien.Hinderer@ens-lyon.org>");
> +MODULE_DESCRIPTION("A power_off handler for Iris devices from EuroBraille");
> +MODULE_SUPPORTED_DEVICE("Eurobraille/Iris");
> +
> +static int force;
> +module_param(force, bool, 0);
> +MODULE_PARM_DESC(force, "Set to one to force poweroff handler installation.");
> +
> +static void (*old_pm_power_off)(void);
> +
> +static void iris_power_off(void)
> +{
> +	outb(IRIS_GIO_PULSE, IRIS_GIO_OUTPUT);
> +	msleep(850);
> +	outb(IRIS_GIO_REST, IRIS_GIO_OUTPUT);
> +}
> +
> +/*
> + * Before installing the power_off handler, try to make sure the OS is
> + * running on an Iris.  Since Iris does not support DMI, this is done
> + * by reading its input port and seeing whether the read value is
> + * meaningful.
> + */
> +static int iris_init(void)
> +{
> +	unsigned char status;
> +	if (force != 1) {
> +		printk(KERN_ERR "The force parameter has not been set to 1 so the Iris poweroff handler will not be installed.\n");
> +		return -ENODEV;
> +	}
> +	status = inb(IRIS_GIO_INPUT);
> +	if (status == IRIS_GIO_NODEV) {
> +		printk(KERN_ERR "This machine does not seem to be an Iris. Power_off handler not installed.\n");
> +		return -ENODEV;
> +	}
> +	old_pm_power_off = pm_power_off;
> +	pm_power_off = &iris_power_off;
> +	printk(KERN_INFO "Iris power_off handler installed.\n");
> +	return 0;
> +}
> +
> +static void iris_exit(void)
> +{
> +	pm_power_off = old_pm_power_off;
> +	printk(KERN_INFO "Iris power_off handler uninstalled.\n");
> +}
> +
> +module_init(iris_init);
> +module_exit(iris_exit);
> +

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] x86: EuroBraille/Iris power off
  2010-10-10 16:22                     ` Shérab
@ 2010-11-13 19:22                       ` Shérab
  0 siblings, 0 replies; 31+ messages in thread
From: Shérab @ 2010-11-13 19:22 UTC (permalink / raw)
  To: Valdis.Kletnieks
  Cc: Samuel Thibault, H. Peter Anvin, Len Brown, Thomas Gleixner,
	Ingo Molnar, x86, Andrew Morton, Frederic Weisbecker,
	Andres Salomon, Linux Kernel Mailing List

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

Dear all,

I am resending this patch which got no criticisms and has stillnot been
integrated so far.

Many thanks in advance for examining it.

Cheers,

Shérab.

Shérab (2010/10/10 18:22 +0200):
> Hi,
> 
> I'm resending and would appreciate it very much if someone good have a
> lookto it.
> Thanks,
> Shérab.
> 
> Shérab (2010/09/26 19:54 +0200):
> > Hello,
> > 
> > Shérab (2010/09/20 10:22 +0200):
> > > Dear all,
> > > 
> > > Valdis.Kletnieks@vt.edu (2010/09/13 21:45 -0400):
> > > > On Mon, 13 Sep 2010 17:22:49 +0200, Samuel Thibault said:
> > > > 
> > > > > Again, I'm not sure we really should try hard to make it automatically
> > > > > detected (and thus always enabled).  Having to pass a kernel parameter
> > > > > to enable the functionality is completely fine, since installing Linux
> > > > > on this device requires quite some tinkering already.
> > > > 
> > > > I'm agreeing that if iris_init() checks that the user passed 'irisinit.force=1'
> > > > on the command line or as a module parameter, and bailed immediately if it
> > > > wasn't passed, then doing the inb() and testing it should be safe
> > > > enough. [...]
> > > 
> > > Please find below a revised version of the module that does what has
> > > been asked.
> > 
> > The previous patch had a few style problem and the moduleparam.h header
> > was not included whereas it should have been.
> > The version below passes ./script/checkpatch and the missing header has
> > been included, so the patch should be correct now.
> > Moreover the patch has been updated to apply on top of current master.
> > 
> > Shérab.
> > 
> > From 2af50581bb591cd25ac59a7cf16902ea50f766db Mon Sep 17 00:00:00 2001
> > From: =?UTF-8?q?Sh=C3=A9rab?= <Sebastien.Hinderer@ens-lyon.org>
> > Date: Sat, 25 Sep 2010 06:06:57 +0200
> > Subject: [PATCH] Eurobraille/Iris power off.
> > MIME-Version: 1.0
> > Content-Type: text/plain; charset=UTF-8
> > Content-Transfer-Encoding: 8bit
> > Content-Type: text/plain; charset="utf-8"
> > 
> > The Iris machines from Eurobraille do not have APM or ACPI support
> > to shut themselves down properly.  A special I/O sequence is
> > needed to do so.  This modle runs this I/O sequence at
> > kernel shutdown when its force parameter is set to 1.
> > Signed-off-by: Shérab <Sebastien.Hinderer@ens-lyon.org>
> > ---
> >  arch/x86/Kconfig         |   13 +++++++
> >  arch/x86/kernel/Makefile |    1 +
> >  arch/x86/kernel/iris.c   |   90 ++++++++++++++++++++++++++++++++++++++++++++++
> >  3 files changed, 104 insertions(+), 0 deletions(-)
> >  create mode 100644 arch/x86/kernel/iris.c
> > 
> > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> > index cea0cd9..7c8e261 100644
> > --- a/arch/x86/Kconfig
> > +++ b/arch/x86/Kconfig
> > @@ -493,6 +493,19 @@ config X86_ES7000
> >  	  Support for Unisys ES7000 systems.  Say 'Y' here if this kernel is
> >  	  supposed to run on an IA32-based Unisys ES7000 system.
> >  
> > +config X86_32_IRIS
> > +	tristate "Eurobraille/Iris poweroff module"
> > +	depends on X86_32
> > +	---help---
> > +	  The Iris machines from EuroBraille do not have APM or ACPI support
> > +	  to shut themselves down properly.  A special I/O sequence is
> > +	  needed to do so, which is what this module does at
> > +	  kernel shutdown.
> > +
> > +	  This is only for Iris machines from EuroBraille.
> > +
> > +	  If unused, say N.
> > +
> >  config SCHED_OMIT_FRAME_POINTER
> >  	def_bool y
> >  	prompt "Single-depth WCHAN output"
> > diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
> > index 0925676..98dd1c8 100644
> > --- a/arch/x86/kernel/Makefile
> > +++ b/arch/x86/kernel/Makefile
> > @@ -115,6 +115,7 @@ obj-$(CONFIG_MICROCODE)			+= microcode.o
> >  obj-$(CONFIG_X86_CHECK_BIOS_CORRUPTION) += check.o
> >  
> >  obj-$(CONFIG_SWIOTLB)			+= pci-swiotlb.o
> > +obj-$(CONFIG_X86_32_IRIS)		+= iris.o
> >  
> >  ###
> >  # 64 bit specific files
> > diff --git a/arch/x86/kernel/iris.c b/arch/x86/kernel/iris.c
> > new file mode 100644
> > index 0000000..c6d8137
> > --- /dev/null
> > +++ b/arch/x86/kernel/iris.c
> > @@ -0,0 +1,90 @@
> > +/*
> > + * Eurobraille/Iris power off support.
> > + *
> > + * Eurobraille's Iris machine is a PC with no APM or ACPI support.
> > + * It is shutdown by a special I/O sequence which this module provides.
> > + *
> > + *  Copyright (C) Shérab <Sebastien.Hinderer@ens-lyon.org>
> > + *
> > + * 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 the program ; if not, write to the Free Software
> > + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> > + */
> > +
> > +#include <linux/module.h>
> > +#include <linux/moduleparam.h>
> > +#include <linux/kernel.h>
> > +#include <linux/errno.h>
> > +#include <linux/init.h>
> > +#include <linux/pm.h>
> > +#include <linux/delay.h>
> > +#include <asm/io.h>
> > +
> > +#define IRIS_GIO_BASE 0x340
> > +#define IRIS_GIO_INPUT IRIS_GIO_BASE
> > +#define IRIS_GIO_OUTPUT (IRIS_GIO_BASE + 1)
> > +#define IRIS_GIO_PULSE 0x80 /* First byte to send */
> > +#define IRIS_GIO_REST 0x0 /* Second byte to send */
> > +#define IRIS_GIO_NODEV 0xff /* Likely not an Iris */
> > +
> > +MODULE_LICENSE("GPL");
> > +MODULE_AUTHOR("Sébastien Hinderer <Sebastien.Hinderer@ens-lyon.org>");
> > +MODULE_DESCRIPTION("A power_off handler for Iris devices from EuroBraille");
> > +MODULE_SUPPORTED_DEVICE("Eurobraille/Iris");
> > +
> > +static int force;
> > +module_param(force, bool, 0);
> > +MODULE_PARM_DESC(force, "Set to one to force poweroff handler installation.");
> > +
> > +static void (*old_pm_power_off)(void);
> > +
> > +static void iris_power_off(void)
> > +{
> > +	outb(IRIS_GIO_PULSE, IRIS_GIO_OUTPUT);
> > +	msleep(850);
> > +	outb(IRIS_GIO_REST, IRIS_GIO_OUTPUT);
> > +}
> > +
> > +/*
> > + * Before installing the power_off handler, try to make sure the OS is
> > + * running on an Iris.  Since Iris does not support DMI, this is done
> > + * by reading its input port and seeing whether the read value is
> > + * meaningful.
> > + */
> > +static int iris_init(void)
> > +{
> > +	unsigned char status;
> > +	if (force != 1) {
> > +		printk(KERN_ERR "The force parameter has not been set to 1 so the Iris poweroff handler will not be installed.\n");
> > +		return -ENODEV;
> > +	}
> > +	status = inb(IRIS_GIO_INPUT);
> > +	if (status == IRIS_GIO_NODEV) {
> > +		printk(KERN_ERR "This machine does not seem to be an Iris. Power_off handler not installed.\n");
> > +		return -ENODEV;
> > +	}
> > +	old_pm_power_off = pm_power_off;
> > +	pm_power_off = &iris_power_off;
> > +	printk(KERN_INFO "Iris power_off handler installed.\n");
> > +	return 0;
> > +}
> > +
> > +static void iris_exit(void)
> > +{
> > +	pm_power_off = old_pm_power_off;
> > +	printk(KERN_INFO "Iris power_off handler uninstalled.\n");
> > +}
> > +
> > +module_init(iris_init);
> > +module_exit(iris_exit);
> > +

[-- Attachment #2: 0001-Eurobraille-Iris-power-off.patch --]
[-- Type: text/x-diff, Size: 5197 bytes --]

>From 2af50581bb591cd25ac59a7cf16902ea50f766db Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sh=C3=A9rab?= <Sebastien.Hinderer@ens-lyon.org>
Date: Sat, 25 Sep 2010 06:06:57 +0200
Subject: [PATCH] Eurobraille/Iris power off.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="utf-8"

The Iris machines from Eurobraille do not have APM or ACPI support
to shut themselves down properly.  A special I/O sequence is
needed to do so.  This modle runs this I/O sequence at
kernel shutdown when its force parameter is set to 1.
Signed-off-by: Shérab <Sebastien.Hinderer@ens-lyon.org>
---
 arch/x86/Kconfig         |   13 +++++++
 arch/x86/kernel/Makefile |    1 +
 arch/x86/kernel/iris.c   |   90 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 104 insertions(+), 0 deletions(-)
 create mode 100644 arch/x86/kernel/iris.c

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index cea0cd9..7c8e261 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -493,6 +493,19 @@ config X86_ES7000
 	  Support for Unisys ES7000 systems.  Say 'Y' here if this kernel is
 	  supposed to run on an IA32-based Unisys ES7000 system.
 
+config X86_32_IRIS
+	tristate "Eurobraille/Iris poweroff module"
+	depends on X86_32
+	---help---
+	  The Iris machines from EuroBraille do not have APM or ACPI support
+	  to shut themselves down properly.  A special I/O sequence is
+	  needed to do so, which is what this module does at
+	  kernel shutdown.
+
+	  This is only for Iris machines from EuroBraille.
+
+	  If unused, say N.
+
 config SCHED_OMIT_FRAME_POINTER
 	def_bool y
 	prompt "Single-depth WCHAN output"
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index 0925676..98dd1c8 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -115,6 +115,7 @@ obj-$(CONFIG_MICROCODE)			+= microcode.o
 obj-$(CONFIG_X86_CHECK_BIOS_CORRUPTION) += check.o
 
 obj-$(CONFIG_SWIOTLB)			+= pci-swiotlb.o
+obj-$(CONFIG_X86_32_IRIS)		+= iris.o
 
 ###
 # 64 bit specific files
diff --git a/arch/x86/kernel/iris.c b/arch/x86/kernel/iris.c
new file mode 100644
index 0000000..c6d8137
--- /dev/null
+++ b/arch/x86/kernel/iris.c
@@ -0,0 +1,90 @@
+/*
+ * Eurobraille/Iris power off support.
+ *
+ * Eurobraille's Iris machine is a PC with no APM or ACPI support.
+ * It is shutdown by a special I/O sequence which this module provides.
+ *
+ *  Copyright (C) Shérab <Sebastien.Hinderer@ens-lyon.org>
+ *
+ * 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 the program ; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/pm.h>
+#include <linux/delay.h>
+#include <asm/io.h>
+
+#define IRIS_GIO_BASE 0x340
+#define IRIS_GIO_INPUT IRIS_GIO_BASE
+#define IRIS_GIO_OUTPUT (IRIS_GIO_BASE + 1)
+#define IRIS_GIO_PULSE 0x80 /* First byte to send */
+#define IRIS_GIO_REST 0x0 /* Second byte to send */
+#define IRIS_GIO_NODEV 0xff /* Likely not an Iris */
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Sébastien Hinderer <Sebastien.Hinderer@ens-lyon.org>");
+MODULE_DESCRIPTION("A power_off handler for Iris devices from EuroBraille");
+MODULE_SUPPORTED_DEVICE("Eurobraille/Iris");
+
+static int force;
+module_param(force, bool, 0);
+MODULE_PARM_DESC(force, "Set to one to force poweroff handler installation.");
+
+static void (*old_pm_power_off)(void);
+
+static void iris_power_off(void)
+{
+	outb(IRIS_GIO_PULSE, IRIS_GIO_OUTPUT);
+	msleep(850);
+	outb(IRIS_GIO_REST, IRIS_GIO_OUTPUT);
+}
+
+/*
+ * Before installing the power_off handler, try to make sure the OS is
+ * running on an Iris.  Since Iris does not support DMI, this is done
+ * by reading its input port and seeing whether the read value is
+ * meaningful.
+ */
+static int iris_init(void)
+{
+	unsigned char status;
+	if (force != 1) {
+		printk(KERN_ERR "The force parameter has not been set to 1 so the Iris poweroff handler will not be installed.\n");
+		return -ENODEV;
+	}
+	status = inb(IRIS_GIO_INPUT);
+	if (status == IRIS_GIO_NODEV) {
+		printk(KERN_ERR "This machine does not seem to be an Iris. Power_off handler not installed.\n");
+		return -ENODEV;
+	}
+	old_pm_power_off = pm_power_off;
+	pm_power_off = &iris_power_off;
+	printk(KERN_INFO "Iris power_off handler installed.\n");
+	return 0;
+}
+
+static void iris_exit(void)
+{
+	pm_power_off = old_pm_power_off;
+	printk(KERN_INFO "Iris power_off handler uninstalled.\n");
+}
+
+module_init(iris_init);
+module_exit(iris_exit);
+
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2010-11-13 19:23 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-25  9:49 [PATCH] x86: EuroBraille/Iris power off Shérab
2010-08-25 16:12 ` Andreas Mohr
2010-08-25 21:12   ` Sebastien Hinderer
2010-08-25 21:19     ` H. Peter Anvin
2010-08-25 22:50       ` Samuel Thibault
2010-08-26  0:06         ` H. Peter Anvin
2010-08-26  0:19           ` Samuel Thibault
2010-08-26  6:45           ` Sebastien Hinderer
2010-08-26  6:55             ` H. Peter Anvin
2010-08-26  7:09               ` Andreas Mohr
2010-08-26  9:29               ` Sebastien Hinderer
2010-08-26 18:11 ` Len Brown
2010-08-26 21:08   ` Shérab
2010-08-26 21:16     ` H. Peter Anvin
2010-08-27 17:35       ` Shérab
2010-08-27 18:49         ` H. Peter Anvin
2010-08-27 22:27       ` Shérab
2010-08-29 20:59       ` Shérab
2010-09-13 10:07         ` Shérab
2010-09-13 15:10           ` Valdis.Kletnieks
2010-09-13 15:22             ` Samuel Thibault
2010-09-13 16:06               ` H. Peter Anvin
2010-09-13 16:12                 ` Samuel Thibault
2010-09-14  1:45               ` Valdis.Kletnieks
2010-09-14  5:16                 ` Shérab
2010-09-20  8:22                 ` Shérab
2010-09-26 17:54                   ` Shérab
2010-10-10 16:22                     ` Shérab
2010-11-13 19:22                       ` Shérab
2010-09-13 15:25             ` Shérab
2010-09-13 15:48               ` H. Peter Anvin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.