actually, this will probably work on any kernel, process.c doesn't change
much. 

These are tested, working, patches for process.c so that soft poweroff and
reset work. I grabbed some code Ollie sent for the 630, but have set it up
so we can extend it at will for other chipsets. 

This will patch arch/i386/kernel/process.c

ron
*** arch/i386/kernel/process.c  Thu Dec 21 10:12:22 2000
--- ../linux-2.4.0-test11/arch/i386/kernel/process.c    Sun Oct  1 21:35:15 2000
***************
*** 48,193 ****
  
  #include <linux/irq.h>
  
- #define CONFIG_LINUXBIOS_PM
- #ifdef CONFIG_LINUXBIOS_PM
- #include <linux/pci.h>
- void
- sis503_reset(struct pci_dev *dev)
- {
-         unsigned char b;
-         unsigned short w;
-         unsigned short acpi_base;
- 
-       printk(KERN_ERR __FUNCTION__ ": starting reset operation. \n");
-         /* Enable ACPI by set B7 on Reg 0x40, LPC */
-         outl(0x80000840, 0x0cf8);
-         b = inb(0x0cfc) | 0x80;
-         outb(b, 0xcfc);
- 
-       printk(KERN_ERR __FUNCTION__ ": enabled ACPI. \n");
-         /* get the ACPI base address for register 0x74,0x75 of LPC */
-         outl(0x80000874, 0x0cf8);
-         w = inw(0x0cfc);
-         acpi_base = w;
- 
-         printk (KERN_ERR __FUNCTION__ ":acpi base: %x\n", acpi_base);
- 
-         /* Set software watchdog timer init value */
-         outb(0x03, 0x4a + acpi_base);
-       printk(KERN_ERR __FUNCTION__ ": set the dog. \n");
- 
-       printk(KERN_ERR __FUNCTION__ ": enabling dog. \n");
-         /* Software watchdog enable, issue PCIRST# when time expire */
-         outb(0x8f, 0x4b + acpi_base);
- 
-       printk(KERN_ERR __FUNCTION__ ": We should reset soon. \n");
- }
- void
- sis503_off(struct pci_dev *dev)
- {
-         unsigned char b;
-         unsigned short w;
-         unsigned short acpi_base;
- 
-       printk(KERN_ERR __FUNCTION__ ": starting reset operation. \n");
-         /* Enable ACPI by set B7 on Reg 0x40, LPC */
-         outl(0x80000840, 0x0cf8);
-         b = inb(0x0cfc) | 0x80;
-         outb(b, 0xcfc);
-       printk(KERN_ERR __FUNCTION__ ": enabled ACPI. \n");
- 
-         /* get the ACPI base address for register 0x74,0x75 of LPC */
-         outl(0x80000874, 0x0cf8);
-         w = inw(0x0cfc);
-         acpi_base = w;
- 
-         printk (KERN_ERR __FUNCTION__ ":acpi base: %x\n", acpi_base);
- 
-         /* ACPI Register 5, Bit 10-12, Sleeping Type,
-            set to 101 -> S5, soft_off */
-         outb(0x14, 0x05 + acpi_base);
-       printk(KERN_ERR __FUNCTION__ ": DONE setting sleep type. \n");
- 
-         /* ACPI Register 5, Bit 13, Sleep Enable */
-         outb(0x20 | 0x14, 0x05 + acpi_base);
-       printk(KERN_ERR __FUNCTION__ ": DONE sleep enable. \n");
- 
- }
- struct pci_dev *
- pci_find_device(unsigned int vendor, unsigned int device, 
- const struct pci_dev *from);
- 
- struct linuxbios_control {
-   u_short vendor, device;
-   void (*poweroff)(struct pci_dev *);
-   void (*reset)(struct pci_dev *);
- };
- 
- /* not in pci_ids.h yet? */
- #define PCI_VENDOR_ID_SI                0x1039
- #define PCI_DEVICE_ID_SI_503            0x8
- 
- struct linuxbios_control controls[] = {
-       {PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503, sis503_off, sis503_reset}
- };
- 
- struct linuxbios_control *findcontrol(struct pci_dev **d)
- {
-   struct linuxbios_control *lb = controls, *retval = 0;
-   int i;
- 
-   printk(KERN_ERR __FUNCTION__ ": Find vendor 0x%x device 0x%x\n", 
-                               lb->vendor, lb->device);
-   for(lb = controls, i = 0; 
-       (i < sizeof(controls)/sizeof(controls[0])) && (! retval); 
-               i++, lb++)
-     {
-       *d = pci_find_device(lb->vendor, lb->device, 0);
-       if (*d)
-       retval = lb;
-     }
- 
-   printk(KERN_ERR __FUNCTION__ ": result of find is %p\n", retval);
-   return retval;
- }
- 
- void
- linuxbios_poweroff(void)
- {
-   struct linuxbios_control *lb = 0;
-   struct pci_dev *dev;
- 
-   printk(KERN_ERR __FUNCTION__ ": find an lb\n");
-   lb = findcontrol(&dev);
- 
-   printk(KERN_ERR __FUNCTION__ ": found lb %p, call %p\n", 
-               lb, lb ? lb->poweroff : 0);
-   if (lb && (lb->poweroff))
-     lb->poweroff(dev);
-   printk(KERN_ERR __FUNCTION__ ": Returning? Can't happen, I thought?\n");
- }
- 
- void
- linuxbios_reset(void)
- {
-   struct linuxbios_control *lb = 0;
-   struct pci_dev *dev;
- 
-   printk(KERN_ERR __FUNCTION__ ": find an lb\n");
-   lb = findcontrol(&dev);
- 
-   printk(KERN_ERR __FUNCTION__ ": found lb %p, call %p\n", 
-               lb, lb ? lb->reset : 0);
-   if (lb && (lb->reset))
-     lb->reset(dev);
-   printk(KERN_ERR __FUNCTION__ ": Returning? Can't happen, I thought?\n");
- 
- }
- 
- 
- #endif
- 
- 
  asmlinkage void ret_from_fork(void) __asm__("ret_from_fork");
  
  int hlt_counter;
--- 48,53 ----
***************
*** 488,496 ****
        smp_send_stop();
        disable_IO_APIC();
  #endif
- #ifdef CONFIG_LINUXBIOS_PM
-       linuxbios_reset();
- #endif
  
        if(!reboot_thru_bios) {
                /* rebooting needs to touch the page at absolute addr 0 */
--- 348,353 ----
***************
*** 518,528 ****
  
  void machine_power_off(void)
  {
-       printk("MACHINE_POWER_OFF\n");
- #ifdef CONFIG_LINUXBIOS_PM
-       linuxbios_poweroff();
- #endif
- 
        if (pm_power_off)
                pm_power_off();
  }
--- 375,380 ----

Reply via email to