fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / macintosh / via-pmu.c
index b983167..8ca75e5 100644 (file)
  *    a sleep or a freq. switch
  *  - Move sleep code out of here to pmac_pm, merge into new
  *    common PM infrastructure
- *  - Move backlight code out as well
  *  - Save/Restore PCI space properly
  *
  */
 #include <stdarg.h>
-#include <linux/config.h>
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/device.h>
-#include <linux/suspend.h>
+#include <linux/sysdev.h>
+#include <linux/freezer.h>
 #include <linux/syscalls.h>
+#include <linux/suspend.h>
+#include <linux/cpu.h>
 #include <asm/prom.h>
 #include <asm/machdep.h>
 #include <asm/io.h>
 #include <asm/system.h>
 #include <asm/sections.h>
 #include <asm/irq.h>
-#include <asm/hardirq.h>
 #include <asm/pmac_feature.h>
+#include <asm/pmac_pfunc.h>
+#include <asm/pmac_low_i2c.h>
 #include <asm/uaccess.h>
 #include <asm/mmu_context.h>
 #include <asm/cputable.h>
 #include <asm/time.h>
-#ifdef CONFIG_PMAC_BACKLIGHT
 #include <asm/backlight.h>
-#endif
+
+#include "via-pmu-event.h"
 
 /* Some compile options */
 #undef SUSPEND_USES_PMU
@@ -73,7 +75,7 @@
 /* How many iterations between battery polls */
 #define BATTERY_POLLING_COUNT  2
 
-static volatile unsigned char *via;
+static volatile unsigned char __iomem *via;
 
 /* VIA registers - spaced 0x200 bytes apart */
 #define RS             0x200           /* skip between registers */
@@ -137,25 +139,26 @@ static int data_index;
 static int data_len;
 static volatile int adb_int_pending;
 static volatile int disable_poll;
-static struct adb_request bright_req_1, bright_req_2;
-static unsigned long async_req_locks;
 static struct device_node *vias;
 static int pmu_kind = PMU_UNKNOWN;
 static int pmu_fully_inited = 0;
 static int pmu_has_adb;
-static unsigned char *gpio_reg = NULL;
-static int gpio_irq = -1;
+static struct device_node *gpio_node;
+static unsigned char __iomem *gpio_reg = NULL;
+static int gpio_irq = NO_IRQ;
 static int gpio_irq_enabled = -1;
 static volatile int pmu_suspended = 0;
 static spinlock_t pmu_lock;
 static u8 pmu_intr_mask;
 static int pmu_version;
 static int drop_interrupts;
-#ifdef CONFIG_PMAC_PBOOK
+#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
 static int option_lid_wakeup = 1;
+#endif /* CONFIG_PM && CONFIG_PPC32 */
+#if (defined(CONFIG_PM)&&defined(CONFIG_PPC32))||defined(CONFIG_PMAC_BACKLIGHT_LEGACY)
 static int sleep_in_progress;
-static int can_sleep;
-#endif /* CONFIG_PMAC_PBOOK */
+#endif
+static unsigned long async_req_locks;
 static unsigned int pmu_irq_stats[11];
 
 static struct proc_dir_entry *proc_pmu_root;
@@ -164,7 +167,6 @@ static struct proc_dir_entry *proc_pmu_irqstats;
 static struct proc_dir_entry *proc_pmu_options;
 static int option_server_mode;
 
-#ifdef CONFIG_PMAC_PBOOK
 int pmu_battery_count;
 int pmu_cur_battery;
 unsigned int pmu_power_flags;
@@ -172,15 +174,10 @@ struct pmu_battery_info pmu_batteries[PMU_MAX_BATTERIES];
 static int query_batt_timer = BATTERY_POLLING_COUNT;
 static struct adb_request batt_req;
 static struct proc_dir_entry *proc_pmu_batt[PMU_MAX_BATTERIES];
-#endif /* CONFIG_PMAC_PBOOK */
-
-#if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT)
-extern int disable_kernel_backlight;
-#endif /* defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) */
 
 int __fake_sleep;
 int asleep;
-struct notifier_block *sleep_notifier_list;
+BLOCKING_NOTIFIER_HEAD(sleep_notifier_list);
 
 #ifdef CONFIG_ADB
 static int adb_dev_map = 0;
@@ -194,23 +191,16 @@ static int pmu_adb_reset_bus(void);
 #endif /* CONFIG_ADB */
 
 static int init_pmu(void);
-static int pmu_queue_request(struct adb_request *req);
 static void pmu_start(void);
-static irqreturn_t via_pmu_interrupt(int irq, void *arg, struct pt_regs *regs);
-static irqreturn_t gpio1_interrupt(int irq, void *arg, struct pt_regs *regs);
+static irqreturn_t via_pmu_interrupt(int irq, void *arg);
+static irqreturn_t gpio1_interrupt(int irq, void *arg);
 static int proc_get_info(char *page, char **start, off_t off,
                          int count, int *eof, void *data);
 static int proc_get_irqstats(char *page, char **start, off_t off,
                          int count, int *eof, void *data);
-#ifdef CONFIG_PMAC_BACKLIGHT
-static int pmu_set_backlight_level(int level, void* data);
-static int pmu_set_backlight_enable(int on, int level, void* data);
-#endif /* CONFIG_PMAC_BACKLIGHT */
-#ifdef CONFIG_PMAC_PBOOK
 static void pmu_pass_intr(unsigned char *data, int len);
 static int proc_get_batt(char *page, char **start, off_t off,
                        int count, int *eof, void *data);
-#endif /* CONFIG_PMAC_PBOOK */
 static int proc_read_options(char *page, char **start, off_t off,
                        int count, int *eof, void *data);
 static int proc_write_options(struct file *file, const char __user *buffer,
@@ -244,7 +234,7 @@ int pmu_wink(struct adb_request *req);
  * - the number of response bytes which the PMU will return, or
  *   -1 if it will send a length byte.
  */
-static const s8 pmu_data_len[256][2] __openfirmwaredata = {
+static const s8 pmu_data_len[256][2] = {
 /*        0       1       2       3       4       5       6       7  */
 /*00*/ {-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0},{-1, 0},
 /*08*/ {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
@@ -288,29 +278,26 @@ static char *pbook_type[] = {
        "Core99"
 };
 
-#ifdef CONFIG_PMAC_BACKLIGHT
-static struct backlight_controller pmu_backlight_controller = {
-       pmu_set_backlight_enable,
-       pmu_set_backlight_level
-};
-#endif /* CONFIG_PMAC_BACKLIGHT */
-
-int __openfirmware
-find_via_pmu(void)
+int __init find_via_pmu(void)
 {
+       u64 taddr;
+       const u32 *reg;
+
        if (via != 0)
                return 1;
-       vias = find_devices("via-pmu");
-       if (vias == 0)
+       vias = of_find_node_by_name(NULL, "via-pmu");
+       if (vias == NULL)
                return 0;
-       if (vias->next != 0)
-               printk(KERN_WARNING "Warning: only using 1st via-pmu\n");
 
-       if (vias->n_addrs < 1 || vias->n_intrs < 1) {
-               printk(KERN_ERR "via-pmu: %d addresses, %d interrupts!\n",
-                      vias->n_addrs, vias->n_intrs);
-               if (vias->n_addrs < 1 || vias->n_intrs < 1)
-                       return 0;
+       reg = get_property(vias, "reg", NULL);
+       if (reg == NULL) {
+               printk(KERN_ERR "via-pmu: No \"reg\" property !\n");
+               goto fail;
+       }
+       taddr = of_translate_address(vias, reg);
+       if (taddr == OF_BAD_ADDR) {
+               printk(KERN_ERR "via-pmu: Can't translate address !\n");
+               goto fail;
        }
 
        spin_lock_init(&pmu_lock);
@@ -331,7 +318,8 @@ find_via_pmu(void)
                pmu_kind = PMU_HEATHROW_BASED;
        else if (device_is_compatible(vias->parent, "Keylargo")
                 || device_is_compatible(vias->parent, "K2-Keylargo")) {
-               struct device_node *gpio, *gpiop;
+               struct device_node *gpiop;
+               u64 gaddr = OF_BAD_ADDR;
 
                pmu_kind = PMU_KEYLARGO_BASED;
                pmu_has_adb = (find_type_devices("adb") != NULL);
@@ -341,19 +329,26 @@ find_via_pmu(void)
                                PMU_INT_TICK |
                                PMU_INT_ENVIRONMENT;
                
-               gpiop = find_devices("gpio");
-               if (gpiop && gpiop->n_addrs) {
-                       gpio_reg = ioremap(gpiop->addrs->address, 0x10);
-                       gpio = find_devices("extint-gpio1");
-                       if (gpio == NULL)
-                               gpio = find_devices("pmu-interrupt");
-                       if (gpio && gpio->parent == gpiop && gpio->n_intrs)
-                               gpio_irq = gpio->intrs[0].line;
+               gpiop = of_find_node_by_name(NULL, "gpio");
+               if (gpiop) {
+                       reg = get_property(gpiop, "reg", NULL);
+                       if (reg)
+                               gaddr = of_translate_address(gpiop, reg);
+                       if (gaddr != OF_BAD_ADDR)
+                               gpio_reg = ioremap(gaddr, 0x10);
+               }
+               if (gpio_reg == NULL) {
+                       printk(KERN_ERR "via-pmu: Can't find GPIO reg !\n");
+                       goto fail_gpio;
                }
        } else
                pmu_kind = PMU_UNKNOWN;
 
-       via = (volatile unsigned char *) ioremap(vias->addrs->address, 0x2000);
+       via = ioremap(taddr, 0x2000);
+       if (via == NULL) {
+               printk(KERN_ERR "via-pmu: Can't map address !\n");
+               goto fail;
+       }
        
        out_8(&via[IER], IER_CLR | 0x7f);       /* disable all intrs */
        out_8(&via[IFR], 0x7f);                 /* clear IFR */
@@ -365,25 +360,28 @@ find_via_pmu(void)
                return 0;
        }
 
-       printk(KERN_INFO "PMU driver %d initialized for %s, firmware: %02x\n",
+       printk(KERN_INFO "PMU driver v%d initialized for %s, firmware: %02x\n",
               PMU_DRIVER_VERSION, pbook_type[pmu_kind], pmu_version);
               
-#ifndef CONFIG_PPC64
        sys_ctrler = SYS_CTRLER_PMU;
-#endif
        
        return 1;
+ fail:
+       of_node_put(vias);
+       iounmap(gpio_reg);
+       gpio_reg = NULL;
+ fail_gpio:
+       vias = NULL;
+       return 0;
 }
 
 #ifdef CONFIG_ADB
-static int __openfirmware
-pmu_probe(void)
+static int pmu_probe(void)
 {
        return vias == NULL? -ENODEV: 0;
 }
 
-static int __init
-pmu_init(void)
+static int __init pmu_init(void)
 {
        if (vias == NULL)
                return -ENODEV;
@@ -400,28 +398,39 @@ pmu_init(void)
  */
 static int __init via_pmu_start(void)
 {
+       unsigned int irq;
+
        if (vias == NULL)
                return -ENODEV;
 
-       bright_req_1.complete = 1;
-       bright_req_2.complete = 1;
-#ifdef CONFIG_PMAC_PBOOK
        batt_req.complete = 1;
-       if (pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,-1) >= 0)
-               can_sleep = 1;
-#endif
 
-       if (request_irq(vias->intrs[0].line, via_pmu_interrupt, 0, "VIA-PMU",
-                       (void *)0)) {
-               printk(KERN_ERR "VIA-PMU: can't get irq %d\n",
-                      vias->intrs[0].line);
-               return -EAGAIN;
+       irq = irq_of_parse_and_map(vias, 0);
+       if (irq == NO_IRQ) {
+               printk(KERN_ERR "via-pmu: can't map interruptn");
+               return -ENODEV;
+       }
+       if (request_irq(irq, via_pmu_interrupt, 0, "VIA-PMU", (void *)0)) {
+               printk(KERN_ERR "via-pmu: can't request irq %d\n", irq);
+               return -ENODEV;
        }
 
-       if (pmu_kind == PMU_KEYLARGO_BASED && gpio_irq != -1) {
-               if (request_irq(gpio_irq, gpio1_interrupt, 0, "GPIO1/ADB", (void *)0))
-                       printk(KERN_ERR "pmu: can't get irq %d (GPIO1)\n", gpio_irq);
-               gpio_irq_enabled = 1;
+       if (pmu_kind == PMU_KEYLARGO_BASED) {
+               gpio_node = of_find_node_by_name(NULL, "extint-gpio1");
+               if (gpio_node == NULL)
+                       gpio_node = of_find_node_by_name(NULL,
+                                                        "pmu-interrupt");
+               if (gpio_node)
+                       gpio_irq = irq_of_parse_and_map(gpio_node, 0);
+
+               if (gpio_irq != NO_IRQ) {
+                       if (request_irq(gpio_irq, gpio1_interrupt, 0,
+                                       "GPIO1 ADB", (void *)0))
+                               printk(KERN_ERR "pmu: can't get irq %d"
+                                      " (GPIO1)\n", gpio_irq);
+                       else
+                               gpio_irq_enabled = 1;
+               }
        }
 
        /* Enable interrupts */
@@ -454,15 +463,12 @@ static int __init via_pmu_dev_init(void)
        if (vias == NULL)
                return -ENODEV;
 
-#ifndef CONFIG_PPC64
-       request_OF_resource(vias, 0, NULL);
-#endif
 #ifdef CONFIG_PMAC_BACKLIGHT
-       /* Enable backlight */
-       register_backlight_controller(&pmu_backlight_controller, NULL, "pmu");
-#endif /* CONFIG_PMAC_BACKLIGHT */
+       /* Initialize backlight */
+       pmu_backlight_init();
+#endif
 
-#ifdef CONFIG_PMAC_PBOOK
+#ifdef CONFIG_PPC32
        if (machine_is_compatible("AAPL,3400/2400") ||
                machine_is_compatible("AAPL,3500")) {
                int mb = pmac_call_feature(PMAC_FTR_GET_MB_INFO,
@@ -479,9 +485,9 @@ static int __init via_pmu_dev_init(void)
                pmu_batteries[1].flags |= PMU_BATT_TYPE_SMART;
        } else {
                struct device_node* prim = find_devices("power-mgt");
-               u32 *prim_info = NULL;
+               const u32 *prim_info = NULL;
                if (prim)
-                       prim_info = (u32 *)get_property(prim, "prim-info", NULL);
+                       prim_info = get_property(prim, "prim-info", NULL);
                if (prim_info) {
                        /* Other stuffs here yet unknown */
                        pmu_battery_count = (prim_info[6] >> 16) & 0xff;
@@ -490,23 +496,24 @@ static int __init via_pmu_dev_init(void)
                                pmu_batteries[1].flags |= PMU_BATT_TYPE_SMART;
                }
        }
-#endif /* CONFIG_PMAC_PBOOK */
+#endif /* CONFIG_PPC32 */
+
        /* Create /proc/pmu */
-       proc_pmu_root = proc_mkdir("pmu", 0);
+       proc_pmu_root = proc_mkdir("pmu", NULL);
        if (proc_pmu_root) {
-               int i;
-               proc_pmu_info = create_proc_read_entry("info", 0, proc_pmu_root,
-                                       proc_get_info, NULL);
-               proc_pmu_irqstats = create_proc_read_entry("interrupts", 0, proc_pmu_root,
-                                       proc_get_irqstats, NULL);
-#ifdef CONFIG_PMAC_PBOOK
+               long i;
+
                for (i=0; i<pmu_battery_count; i++) {
                        char title[16];
-                       sprintf(title, "battery_%d", i);
+                       sprintf(title, "battery_%ld", i);
                        proc_pmu_batt[i] = create_proc_read_entry(title, 0, proc_pmu_root,
                                                proc_get_batt, (void *)i);
                }
-#endif /* CONFIG_PMAC_PBOOK */
+
+               proc_pmu_info = create_proc_read_entry("info", 0, proc_pmu_root,
+                                       proc_get_info, NULL);
+               proc_pmu_irqstats = create_proc_read_entry("interrupts", 0, proc_pmu_root,
+                                       proc_get_irqstats, NULL);
                proc_pmu_options = create_proc_entry("options", 0600, proc_pmu_root);
                if (proc_pmu_options) {
                        proc_pmu_options->nlink = 1;
@@ -519,7 +526,7 @@ static int __init via_pmu_dev_init(void)
 
 device_initcall(via_pmu_dev_init);
 
-static int __openfirmware
+static int
 init_pmu(void)
 {
        int timeout;
@@ -549,7 +556,7 @@ init_pmu(void)
                }
                if (pmu_state == idle)
                        adb_int_pending = 1;
-               via_pmu_interrupt(0, 0, 0);
+               via_pmu_interrupt(0, NULL);
                udelay(10);
        }
 
@@ -587,17 +594,6 @@ pmu_get_model(void)
        return pmu_kind;
 }
 
-#ifndef CONFIG_PPC64
-static inline void wakeup_decrementer(void)
-{
-       set_dec(tb_ticks_per_jiffy);
-       /* No currently-supported powerbook has a 601,
-        * so use get_tbl, not native
-        */
-       last_jiffy_stamp(0) = tb_last_stamp = get_tbl();
-}
-#endif
-
 static void pmu_set_server_mode(int server_mode)
 {
        struct adb_request req;
@@ -621,12 +617,10 @@ static void pmu_set_server_mode(int server_mode)
        pmu_wait_complete(&req);
 }
 
-#ifdef CONFIG_PMAC_PBOOK
-
 /* This new version of the code for 2400/3400/3500 powerbooks
  * is inspired from the implementation in gkrellm-pmu
  */
-static void __pmac
+static void
 done_battery_state_ohare(struct adb_request* req)
 {
        /* format:
@@ -714,7 +708,7 @@ done_battery_state_ohare(struct adb_request* req)
        clear_bit(0, &async_req_locks);
 }
 
-static void __pmac
+static void
 done_battery_state_smart(struct adb_request* req)
 {
        /* format:
@@ -746,6 +740,8 @@ done_battery_state_smart(struct adb_request* req)
                pmu_power_flags &= ~PMU_PWR_AC_PRESENT;
 
 
+       capa = max = amperage = voltage = 0;
+       
        if (req->reply[1] & 0x04) {
                bat_flags |= PMU_BATT_PRESENT;
                switch(req->reply[0]) {
@@ -765,8 +761,7 @@ done_battery_state_smart(struct adb_request* req)
                                        req->reply_len, req->reply[0], req->reply[1], req->reply[2], req->reply[3]);
                                break;
                }
-       } else
-               capa = max = amperage = voltage = 0;
+       }
 
        if ((req->reply[1] & 0x01) && (amperage > 0))
                bat_flags |= PMU_BATT_CHARGING;
@@ -791,7 +786,7 @@ done_battery_state_smart(struct adb_request* req)
        clear_bit(0, &async_req_locks);
 }
 
-static void __pmac
+static void
 query_battery_state(void)
 {
        if (test_and_set_bit(0, &async_req_locks))
@@ -804,9 +799,7 @@ query_battery_state(void)
                        2, PMU_SMART_BATTERY_STATE, pmu_cur_battery+1);
 }
 
-#endif /* CONFIG_PMAC_PBOOK */
-
-static int __pmac
+static int
 proc_get_info(char *page, char **start, off_t off,
                int count, int *eof, void *data)
 {
@@ -814,16 +807,14 @@ proc_get_info(char *page, char **start, off_t off,
 
        p += sprintf(p, "PMU driver version     : %d\n", PMU_DRIVER_VERSION);
        p += sprintf(p, "PMU firmware version   : %02x\n", pmu_version);
-#ifdef CONFIG_PMAC_PBOOK
        p += sprintf(p, "AC Power               : %d\n",
-               ((pmu_power_flags & PMU_PWR_AC_PRESENT) != 0));
+               ((pmu_power_flags & PMU_PWR_AC_PRESENT) != 0) || pmu_battery_count == 0);
        p += sprintf(p, "Battery count          : %d\n", pmu_battery_count);
-#endif /* CONFIG_PMAC_PBOOK */
 
        return p - page;
 }
 
-static int __pmac
+static int
 proc_get_irqstats(char *page, char **start, off_t off,
                  int count, int *eof, void *data)
 {
@@ -850,12 +841,11 @@ proc_get_irqstats(char *page, char **start, off_t off,
        return p - page;
 }
 
-#ifdef CONFIG_PMAC_PBOOK
-static int __pmac
+static int
 proc_get_batt(char *page, char **start, off_t off,
                int count, int *eof, void *data)
 {
-       int batnum = (int)data;
+       long batnum = (long)data;
        char *p = page;
        
        p += sprintf(p, "\n");
@@ -874,25 +864,25 @@ proc_get_batt(char *page, char **start, off_t off,
 
        return p - page;
 }
-#endif /* CONFIG_PMAC_PBOOK */
 
-static int __pmac
+static int
 proc_read_options(char *page, char **start, off_t off,
                        int count, int *eof, void *data)
 {
        char *p = page;
 
-#ifdef CONFIG_PMAC_PBOOK
-       if (pmu_kind == PMU_KEYLARGO_BASED && can_sleep)
+#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
+       if (pmu_kind == PMU_KEYLARGO_BASED &&
+           pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,-1) >= 0)
                p += sprintf(p, "lid_wakeup=%d\n", option_lid_wakeup);
-#endif /* CONFIG_PMAC_PBOOK */
+#endif
        if (pmu_kind == PMU_KEYLARGO_BASED)
                p += sprintf(p, "server_mode=%d\n", option_server_mode);
 
        return p - page;
 }
                        
-static int __pmac
+static int
 proc_write_options(struct file *file, const char __user *buffer,
                        unsigned long count, void *data)
 {
@@ -922,11 +912,12 @@ proc_write_options(struct file *file, const char __user *buffer,
        *(val++) = 0;
        while(*val == ' ')
                val++;
-#ifdef CONFIG_PMAC_PBOOK
-       if (pmu_kind == PMU_KEYLARGO_BASED && can_sleep)
+#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
+       if (pmu_kind == PMU_KEYLARGO_BASED &&
+           pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,-1) >= 0)
                if (!strcmp(label, "lid_wakeup"))
                        option_lid_wakeup = ((*val) == '1');
-#endif /* CONFIG_PMAC_PBOOK */
+#endif
        if (pmu_kind == PMU_KEYLARGO_BASED && !strcmp(label, "server_mode")) {
                int new_value;
                new_value = ((*val) == '1');
@@ -938,7 +929,7 @@ proc_write_options(struct file *file, const char __user *buffer,
 
 #ifdef CONFIG_ADB
 /* Send an ADB command */
-static int __pmac
+static int
 pmu_send_request(struct adb_request *req, int sync)
 {
        int i, ret;
@@ -1018,7 +1009,7 @@ pmu_send_request(struct adb_request *req, int sync)
 }
 
 /* Enable/disable autopolling */
-static int __pmac
+static int
 pmu_adb_autopoll(int devs)
 {
        struct adb_request req;
@@ -1041,7 +1032,7 @@ pmu_adb_autopoll(int devs)
 }
 
 /* Reset the ADB bus */
-static int __pmac
+static int
 pmu_adb_reset_bus(void)
 {
        struct adb_request req;
@@ -1076,7 +1067,7 @@ pmu_adb_reset_bus(void)
 #endif /* CONFIG_ADB */
 
 /* Construct and send a pmu request */
-int __openfirmware
+int
 pmu_request(struct adb_request *req, void (*done)(struct adb_request *),
            int nbytes, ...)
 {
@@ -1102,7 +1093,7 @@ pmu_request(struct adb_request *req, void (*done)(struct adb_request *),
        return pmu_queue_request(req);
 }
 
-int __pmac
+int
 pmu_queue_request(struct adb_request *req)
 {
        unsigned long flags;
@@ -1122,7 +1113,7 @@ pmu_queue_request(struct adb_request *req)
                return -EINVAL;
        }
 
-       req->next = 0;
+       req->next = NULL;
        req->sent = 0;
        req->complete = 0;
 
@@ -1162,7 +1153,7 @@ wait_for_ack(void)
 static inline void
 send_byte(int x)
 {
-       volatile unsigned char *v = via;
+       volatile unsigned char __iomem *v = via;
 
        out_8(&v[ACR], in_8(&v[ACR]) | SR_OUT | SR_EXT);
        out_8(&v[SR], x);
@@ -1173,7 +1164,7 @@ send_byte(int x)
 static inline void
 recv_byte(void)
 {
-       volatile unsigned char *v = via;
+       volatile unsigned char __iomem *v = via;
 
        out_8(&v[ACR], (in_8(&v[ACR]) & ~SR_OUT) | SR_EXT);
        in_8(&v[SR]);           /* resets SR */
@@ -1194,7 +1185,7 @@ pmu_done(struct adb_request *req)
                (*done)(req);
 }
 
-static void __pmac
+static void
 pmu_start(void)
 {
        struct adb_request *req;
@@ -1218,17 +1209,17 @@ pmu_start(void)
        send_byte(req->data[0]);
 }
 
-void __openfirmware
+void
 pmu_poll(void)
 {
        if (!via)
                return;
        if (disable_poll)
                return;
-       via_pmu_interrupt(0, 0, 0);
+       via_pmu_interrupt(0, NULL);
 }
 
-void __openfirmware
+void
 pmu_poll_adb(void)
 {
        if (!via)
@@ -1238,18 +1229,18 @@ pmu_poll_adb(void)
        /* Kicks ADB read when PMU is suspended */
        adb_int_pending = 1;
        do {
-               via_pmu_interrupt(0, 0, 0);
+               via_pmu_interrupt(0, NULL);
        } while (pmu_suspended && (adb_int_pending || pmu_state != idle
                || req_awaiting_reply));
 }
 
-void __openfirmware
+void
 pmu_wait_complete(struct adb_request *req)
 {
        if (!via)
                return;
        while((pmu_state != idle && pmu_state != locked) || !req->complete)
-               via_pmu_interrupt(0, 0, 0);
+               via_pmu_interrupt(0, NULL);
 }
 
 /* This function loops until the PMU is idle and prevents it from
@@ -1257,7 +1248,7 @@ pmu_wait_complete(struct adb_request *req)
  * This is done to avoid spurrious shutdowns when we know we'll have
  * interrupts switched off for a long time
  */
-void __openfirmware
+void
 pmu_suspend(void)
 {
        unsigned long flags;
@@ -1278,7 +1269,7 @@ pmu_suspend(void)
                spin_unlock_irqrestore(&pmu_lock, flags);
                if (req_awaiting_reply)
                        adb_int_pending = 1;
-               via_pmu_interrupt(0, 0, 0);
+               via_pmu_interrupt(0, NULL);
                spin_lock_irqsave(&pmu_lock, flags);
                if (!adb_int_pending && pmu_state == idle && !req_awaiting_reply) {
 #ifdef SUSPEND_USES_PMU
@@ -1297,7 +1288,7 @@ pmu_suspend(void)
        } while (1);
 }
 
-void __openfirmware
+void
 pmu_resume(void)
 {
        unsigned long flags;
@@ -1327,8 +1318,8 @@ pmu_resume(void)
 }
 
 /* Interrupt data could be the result data from an ADB cmd */
-static void __pmac
-pmu_handle_data(unsigned char *data, int len, struct pt_regs *regs)
+static void
+pmu_handle_data(unsigned char *data, int len)
 {
        unsigned char ints, pirq;
        int i = 0;
@@ -1377,7 +1368,7 @@ next:
                                printk(KERN_ERR "PMU: extra ADB reply\n");
                                return;
                        }
-                       req_awaiting_reply = 0;
+                       req_awaiting_reply = NULL;
                        if (len <= 2)
                                req->reply_len = 0;
                        else {
@@ -1386,7 +1377,6 @@ next:
                        }
                        pmu_done(req);
                } else {
-#if defined(CONFIG_XMON) && !defined(CONFIG_PPC64)
                        if (len == 4 && data[1] == 0x2c) {
                                extern int xmon_wants_key, xmon_adb_keycode;
                                if (xmon_wants_key) {
@@ -1394,7 +1384,6 @@ next:
                                        return;
                                }
                        }
-#endif /* defined(CONFIG_XMON) && !defined(CONFIG_PPC64) */
 #ifdef CONFIG_ADB
                        /*
                         * XXX On the [23]400 the PMU gives us an up
@@ -1405,7 +1394,7 @@ next:
                        if (!(pmu_kind == PMU_OHARE_BASED && len == 4
                              && data[1] == 0x2c && data[3] == 0xff
                              && (data[2] & ~1) == 0xf4))
-                               adb_input(data+1, len-1, regs, 1);
+                               adb_input(data+1, len-1, 1);
 #endif /* CONFIG_ADB */                
                }
        }
@@ -1413,15 +1402,11 @@ next:
        else if ((1 << pirq) & PMU_INT_SNDBRT) {
 #ifdef CONFIG_PMAC_BACKLIGHT
                if (len == 3)
-#ifdef CONFIG_INPUT_ADBHID
-                       if (!disable_kernel_backlight)
-#endif /* CONFIG_INPUT_ADBHID */
-                               set_backlight_level(data[1] >> 4);
-#endif /* CONFIG_PMAC_BACKLIGHT */
+                       pmac_backlight_set_legacy_brightness_pmu(data[1] >> 4);
+#endif
        }
        /* Tick interrupt */
        else if ((1 << pirq) & PMU_INT_TICK) {
-#ifdef CONFIG_PMAC_PBOOK
                /* Environement or tick interrupt, query batteries */
                if (pmu_battery_count) {
                        if ((--query_batt_timer) == 0) {
@@ -1434,18 +1419,23 @@ next:
                if (pmu_battery_count)
                        query_battery_state();
                pmu_pass_intr(data, len);
+               /* len == 6 is probably a bad check. But how do I
+                * know what PMU versions send what events here? */
+               if (len == 6) {
+                       via_pmu_event(PMU_EVT_POWER, !!(data[1]&8));
+                       via_pmu_event(PMU_EVT_LID, data[1]&1);
+               }
        } else {
               pmu_pass_intr(data, len);
-#endif /* CONFIG_PMAC_PBOOK */
        }
        goto next;
 }
 
-static struct adb_request* __pmac
-pmu_sr_intr(struct pt_regs *regs)
+static struct adb_request*
+pmu_sr_intr(void)
 {
        struct adb_request *req;
-       int bite;
+       int bite = 0;
 
        if (via[B] & TREQ) {
                printk(KERN_ERR "PMU: spurious SR intr (%x)\n", via[B]);
@@ -1547,8 +1537,8 @@ pmu_sr_intr(struct pt_regs *regs)
        return NULL;
 }
 
-static irqreturn_t __pmac
-via_pmu_interrupt(int irq, void *arg, struct pt_regs *regs)
+static irqreturn_t
+via_pmu_interrupt(int irq, void *arg)
 {
        unsigned long flags;
        int intr;
@@ -1578,7 +1568,7 @@ via_pmu_interrupt(int irq, void *arg, struct pt_regs *regs)
                        pmu_irq_stats[0]++;
                }
                if (intr & SR_INT) {
-                       req = pmu_sr_intr(regs);
+                       req = pmu_sr_intr();
                        if (req)
                                break;
                }
@@ -1624,7 +1614,7 @@ no_free_slot:
                
        /* Deal with interrupt datas outside of the lock */
        if (int_data >= 0) {
-               pmu_handle_data(interrupt_data[int_data], interrupt_data_len[int_data], regs);
+               pmu_handle_data(interrupt_data[int_data], interrupt_data_len[int_data]);
                spin_lock_irqsave(&pmu_lock, flags);
                ++disable_poll;
                int_data_state[int_data] = int_data_empty;
@@ -1635,7 +1625,7 @@ no_free_slot:
        return IRQ_RETVAL(handled);
 }
 
-void __pmac
+void
 pmu_unlock(void)
 {
        unsigned long flags;
@@ -1648,8 +1638,8 @@ pmu_unlock(void)
 }
 
 
-static irqreturn_t __pmac
-gpio1_interrupt(int irq, void *arg, struct pt_regs *regs)
+static irqreturn_t
+gpio1_interrupt(int irq, void *arg)
 {
        unsigned long flags;
 
@@ -1662,68 +1652,13 @@ gpio1_interrupt(int irq, void *arg, struct pt_regs *regs)
                pmu_irq_stats[1]++;
                adb_int_pending = 1;
                spin_unlock_irqrestore(&pmu_lock, flags);
-               via_pmu_interrupt(0, 0, 0);
+               via_pmu_interrupt(0, NULL);
                return IRQ_HANDLED;
        }
        return IRQ_NONE;
 }
 
-#ifdef CONFIG_PMAC_BACKLIGHT
-static int backlight_to_bright[] __pmacdata = {
-       0x7f, 0x46, 0x42, 0x3e, 0x3a, 0x36, 0x32, 0x2e,
-       0x2a, 0x26, 0x22, 0x1e, 0x1a, 0x16, 0x12, 0x0e
-};
-static int __openfirmware
-pmu_set_backlight_enable(int on, int level, void* data)
-{
-       struct adb_request req;
-       
-       if (vias == NULL)
-               return -ENODEV;
-
-       if (on) {
-               pmu_request(&req, NULL, 2, PMU_BACKLIGHT_BRIGHT,
-                           backlight_to_bright[level]);
-               pmu_wait_complete(&req);
-       }
-       pmu_request(&req, NULL, 2, PMU_POWER_CTRL,
-                   PMU_POW_BACKLIGHT | (on ? PMU_POW_ON : PMU_POW_OFF));
-               pmu_wait_complete(&req);
-
-       return 0;
-}
-
-static void __openfirmware
-pmu_bright_complete(struct adb_request *req)
-{
-       if (req == &bright_req_1)
-               clear_bit(1, &async_req_locks);
-       if (req == &bright_req_2)
-               clear_bit(2, &async_req_locks);
-}
-
-static int __openfirmware
-pmu_set_backlight_level(int level, void* data)
-{
-       if (vias == NULL)
-               return -ENODEV;
-
-       if (test_and_set_bit(1, &async_req_locks))
-               return -EAGAIN;
-       pmu_request(&bright_req_1, pmu_bright_complete, 2, PMU_BACKLIGHT_BRIGHT,
-               backlight_to_bright[level]);
-       if (test_and_set_bit(2, &async_req_locks))
-               return -EAGAIN;
-       pmu_request(&bright_req_2, pmu_bright_complete, 2, PMU_POWER_CTRL,
-                   PMU_POW_BACKLIGHT | (level > BACKLIGHT_OFF ?
-                                        PMU_POW_ON : PMU_POW_OFF));
-
-       return 0;
-}
-#endif /* CONFIG_PMAC_BACKLIGHT */
-
-void __pmac
+void
 pmu_enable_irled(int on)
 {
        struct adb_request req;
@@ -1738,11 +1673,14 @@ pmu_enable_irled(int on)
        pmu_wait_complete(&req);
 }
 
-void __pmac
+void
 pmu_restart(void)
 {
        struct adb_request req;
 
+       if (via == NULL)
+               return;
+
        local_irq_disable();
 
        drop_interrupts = 1;
@@ -1760,11 +1698,14 @@ pmu_restart(void)
                ;
 }
 
-void __pmac
+void
 pmu_shutdown(void)
 {
        struct adb_request req;
 
+       if (via == NULL)
+               return;
+
        local_irq_disable();
 
        drop_interrupts = 1;
@@ -1793,259 +1734,7 @@ pmu_present(void)
        return via != 0;
 }
 
-struct pmu_i2c_hdr {
-       u8      bus;
-       u8      mode;
-       u8      bus2;
-       u8      address;
-       u8      sub_addr;
-       u8      comb_addr;
-       u8      count;
-};
-
-int
-pmu_i2c_combined_read(int bus, int addr, int subaddr,  u8* data, int len)
-{
-       struct adb_request      req;
-       struct pmu_i2c_hdr      *hdr = (struct pmu_i2c_hdr *)&req.data[1];
-       int retry;
-       int rc;
-
-       for (retry=0; retry<16; retry++) {
-               memset(&req, 0, sizeof(req));
-
-               hdr->bus = bus;
-               hdr->address = addr & 0xfe;
-               hdr->mode = PMU_I2C_MODE_COMBINED;
-               hdr->bus2 = 0;
-               hdr->sub_addr = subaddr;
-               hdr->comb_addr = addr | 1;
-               hdr->count = len;
-               
-               req.nbytes = sizeof(struct pmu_i2c_hdr) + 1;
-               req.reply_expected = 0;
-               req.reply_len = 0;
-               req.data[0] = PMU_I2C_CMD;
-               req.reply[0] = 0xff;
-               rc = pmu_queue_request(&req);
-               if (rc)
-                       return rc;
-               while(!req.complete)
-                       pmu_poll();
-               if (req.reply[0] == PMU_I2C_STATUS_OK)
-                       break;
-               mdelay(15);
-       }
-       if (req.reply[0] != PMU_I2C_STATUS_OK)
-               return -1;
-
-       for (retry=0; retry<16; retry++) {
-               memset(&req, 0, sizeof(req));
-
-               mdelay(15);
-
-               hdr->bus = PMU_I2C_BUS_STATUS;
-               req.reply[0] = 0xff;
-               
-               req.nbytes = 2;
-               req.reply_expected = 0;
-               req.reply_len = 0;
-               req.data[0] = PMU_I2C_CMD;
-               rc = pmu_queue_request(&req);
-               if (rc)
-                       return rc;
-               while(!req.complete)
-                       pmu_poll();
-               if (req.reply[0] == PMU_I2C_STATUS_DATAREAD) {
-                       memcpy(data, &req.reply[1], req.reply_len - 1);
-                       return req.reply_len - 1;
-               }
-       }
-       return -1;
-}
-
-int
-pmu_i2c_stdsub_write(int bus, int addr, int subaddr,  u8* data, int len)
-{
-       struct adb_request      req;
-       struct pmu_i2c_hdr      *hdr = (struct pmu_i2c_hdr *)&req.data[1];
-       int retry;
-       int rc;
-
-       for (retry=0; retry<16; retry++) {
-               memset(&req, 0, sizeof(req));
-
-               hdr->bus = bus;
-               hdr->address = addr & 0xfe;
-               hdr->mode = PMU_I2C_MODE_STDSUB;
-               hdr->bus2 = 0;
-               hdr->sub_addr = subaddr;
-               hdr->comb_addr = addr & 0xfe;
-               hdr->count = len;
-
-               req.data[0] = PMU_I2C_CMD;
-               memcpy(&req.data[sizeof(struct pmu_i2c_hdr) + 1], data, len);
-               req.nbytes = sizeof(struct pmu_i2c_hdr) + len + 1;
-               req.reply_expected = 0;
-               req.reply_len = 0;
-               req.reply[0] = 0xff;
-               rc = pmu_queue_request(&req);
-               if (rc)
-                       return rc;
-               while(!req.complete)
-                       pmu_poll();
-               if (req.reply[0] == PMU_I2C_STATUS_OK)
-                       break;
-               mdelay(15);
-       }
-       if (req.reply[0] != PMU_I2C_STATUS_OK)
-               return -1;
-
-       for (retry=0; retry<16; retry++) {
-               memset(&req, 0, sizeof(req));
-
-               mdelay(15);
-
-               hdr->bus = PMU_I2C_BUS_STATUS;
-               req.reply[0] = 0xff;
-               
-               req.nbytes = 2;
-               req.reply_expected = 0;
-               req.reply_len = 0;
-               req.data[0] = PMU_I2C_CMD;
-               rc = pmu_queue_request(&req);
-               if (rc)
-                       return rc;
-               while(!req.complete)
-                       pmu_poll();
-               if (req.reply[0] == PMU_I2C_STATUS_OK)
-                       return len;
-       }
-       return -1;
-}
-
-int
-pmu_i2c_simple_read(int bus, int addr,  u8* data, int len)
-{
-       struct adb_request      req;
-       struct pmu_i2c_hdr      *hdr = (struct pmu_i2c_hdr *)&req.data[1];
-       int retry;
-       int rc;
-
-       for (retry=0; retry<16; retry++) {
-               memset(&req, 0, sizeof(req));
-
-               hdr->bus = bus;
-               hdr->address = addr | 1;
-               hdr->mode = PMU_I2C_MODE_SIMPLE;
-               hdr->bus2 = 0;
-               hdr->sub_addr = 0;
-               hdr->comb_addr = 0;
-               hdr->count = len;
-
-               req.data[0] = PMU_I2C_CMD;
-               req.nbytes = sizeof(struct pmu_i2c_hdr) + 1;
-               req.reply_expected = 0;
-               req.reply_len = 0;
-               req.reply[0] = 0xff;
-               rc = pmu_queue_request(&req);
-               if (rc)
-                       return rc;
-               while(!req.complete)
-                       pmu_poll();
-               if (req.reply[0] == PMU_I2C_STATUS_OK)
-                       break;
-               mdelay(15);
-       }
-       if (req.reply[0] != PMU_I2C_STATUS_OK)
-               return -1;
-
-       for (retry=0; retry<16; retry++) {
-               memset(&req, 0, sizeof(req));
-
-               mdelay(15);
-
-               hdr->bus = PMU_I2C_BUS_STATUS;
-               req.reply[0] = 0xff;
-               
-               req.nbytes = 2;
-               req.reply_expected = 0;
-               req.reply_len = 0;
-               req.data[0] = PMU_I2C_CMD;
-               rc = pmu_queue_request(&req);
-               if (rc)
-                       return rc;
-               while(!req.complete)
-                       pmu_poll();
-               if (req.reply[0] == PMU_I2C_STATUS_DATAREAD) {
-                       memcpy(data, &req.reply[1], req.reply_len - 1);
-                       return req.reply_len - 1;
-               }
-       }
-       return -1;
-}
-
-int
-pmu_i2c_simple_write(int bus, int addr,  u8* data, int len)
-{
-       struct adb_request      req;
-       struct pmu_i2c_hdr      *hdr = (struct pmu_i2c_hdr *)&req.data[1];
-       int retry;
-       int rc;
-
-       for (retry=0; retry<16; retry++) {
-               memset(&req, 0, sizeof(req));
-
-               hdr->bus = bus;
-               hdr->address = addr & 0xfe;
-               hdr->mode = PMU_I2C_MODE_SIMPLE;
-               hdr->bus2 = 0;
-               hdr->sub_addr = 0;
-               hdr->comb_addr = 0;
-               hdr->count = len;
-
-               req.data[0] = PMU_I2C_CMD;
-               memcpy(&req.data[sizeof(struct pmu_i2c_hdr) + 1], data, len);
-               req.nbytes = sizeof(struct pmu_i2c_hdr) + len + 1;
-               req.reply_expected = 0;
-               req.reply_len = 0;
-               req.reply[0] = 0xff;
-               rc = pmu_queue_request(&req);
-               if (rc)
-                       return rc;
-               while(!req.complete)
-                       pmu_poll();
-               if (req.reply[0] == PMU_I2C_STATUS_OK)
-                       break;
-               mdelay(15);
-       }
-       if (req.reply[0] != PMU_I2C_STATUS_OK)
-               return -1;
-
-       for (retry=0; retry<16; retry++) {
-               memset(&req, 0, sizeof(req));
-
-               mdelay(15);
-
-               hdr->bus = PMU_I2C_BUS_STATUS;
-               req.reply[0] = 0xff;
-               
-               req.nbytes = 2;
-               req.reply_expected = 0;
-               req.reply_len = 0;
-               req.data[0] = PMU_I2C_CMD;
-               rc = pmu_queue_request(&req);
-               if (rc)
-                       return rc;
-               while(!req.complete)
-                       pmu_poll();
-               if (req.reply[0] == PMU_I2C_STATUS_OK)
-                       return len;
-       }
-       return -1;
-}
-
-#ifdef CONFIG_PMAC_PBOOK
+#ifdef CONFIG_PM
 
 static LIST_HEAD(sleep_notifiers);
 
@@ -2064,6 +1753,7 @@ pmu_register_sleep_notifier(struct pmu_sleep_notifier *n)
        __list_add(&n->list, list->prev, list);
        return 0;
 }
+EXPORT_SYMBOL(pmu_register_sleep_notifier);
 
 int
 pmu_unregister_sleep_notifier(struct pmu_sleep_notifier* n)
@@ -2071,12 +1761,16 @@ pmu_unregister_sleep_notifier(struct pmu_sleep_notifier* n)
        if (n->list.next == 0)
                return -ENOENT;
        list_del(&n->list);
-       n->list.next = 0;
+       n->list.next = NULL;
        return 0;
 }
+EXPORT_SYMBOL(pmu_unregister_sleep_notifier);
+#endif /* CONFIG_PM */
+
+#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
 
 /* Sleep is broadcast last-to-first */
-static int __pmac
+static int
 broadcast_sleep(int when, int fallback)
 {
        int ret = PBOOK_SLEEP_OK;
@@ -2101,7 +1795,7 @@ broadcast_sleep(int when, int fallback)
 }
 
 /* Wake is broadcast first-to-last */
-static int __pmac
+static int
 broadcast_wake(void)
 {
        int ret = PBOOK_SLEEP_OK;
@@ -2132,14 +1826,14 @@ static struct pci_save {
 } *pbook_pci_saves;
 static int pbook_npci_saves;
 
-static void __pmac
+static void
 pbook_alloc_pci_save(void)
 {
        int npci;
        struct pci_dev *pd = NULL;
 
        npci = 0;
-       while ((pd = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pd)) != NULL) {
+       while ((pd = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pd)) != NULL) {
                ++npci;
        }
        if (npci == 0)
@@ -2149,7 +1843,7 @@ pbook_alloc_pci_save(void)
        pbook_npci_saves = npci;
 }
 
-static void __pmac
+static void
 pbook_free_pci_save(void)
 {
        if (pbook_pci_saves == NULL)
@@ -2159,7 +1853,7 @@ pbook_free_pci_save(void)
        pbook_npci_saves = 0;
 }
 
-static void __pmac
+static void
 pbook_pci_save(void)
 {
        struct pci_save *ps = pbook_pci_saves;
@@ -2169,9 +1863,11 @@ pbook_pci_save(void)
        if (ps == NULL)
                return;
 
-       while ((pd = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pd)) != NULL) {
-               if (npci-- == 0)
+       while ((pd = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pd)) != NULL) {
+               if (npci-- == 0) {
+                       pci_dev_put(pd);
                        return;
+               }
 #ifndef HACKED_PCI_SAVE
                pci_read_config_word(pd, PCI_COMMAND, &ps->command);
                pci_read_config_word(pd, PCI_CACHE_LINE_SIZE, &ps->cache_lat);
@@ -2190,7 +1886,7 @@ pbook_pci_save(void)
  * during boot, it will be in the pci dev list. If it's disabled at this point
  * (and it will probably be), then you can't access it's config space.
  */
-static void __pmac
+static void
 pbook_pci_restore(void)
 {
        u16 cmd;
@@ -2199,11 +1895,13 @@ pbook_pci_restore(void)
        int npci = pbook_npci_saves;
        int j;
 
-       while ((pd = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pd)) != NULL) {
+       while ((pd = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pd)) != NULL) {
 #ifdef HACKED_PCI_SAVE
                int i;
-               if (npci-- == 0)
+               if (npci-- == 0) {
+                       pci_dev_put(pd);
                        return;
+               }
                ps++;
                for (i=2;i<16;i++)
                        pci_write_config_dword(pd, i<<4, ps->config[i]);
@@ -2238,7 +1936,7 @@ pbook_pci_restore(void)
 
 #ifdef DEBUG_SLEEP
 /* N.B. This doesn't work on the 3400 */
-void  __pmac
+void 
 pmu_blink(int n)
 {
        struct adb_request req;
@@ -2277,9 +1975,9 @@ pmu_blink(int n)
  * Put the powerbook to sleep.
  */
  
-static u32 save_via[8] __pmacdata;
+static u32 save_via[8];
 
-static void __pmac
+static void
 save_via_state(void)
 {
        save_via[0] = in_8(&via[ANH]);
@@ -2291,7 +1989,7 @@ save_via_state(void)
        save_via[6] = in_8(&via[T1CL]);
        save_via[7] = in_8(&via[T1CH]);
 }
-static void __pmac
+static void
 restore_via_state(void)
 {
        out_8(&via[ANH], save_via[0]);
@@ -2307,11 +2005,13 @@ restore_via_state(void)
        out_8(&via[IER], IER_SET | SR_INT | CB1_INT);
 }
 
-static int __pmac
+extern void pmu_backlight_set_sleep(int sleep);
+
+static int
 pmac_suspend_devices(void)
 {
        int ret;
-       
+
        pm_prepare_console();
        
        /* Notify old-style device drivers & userland */
@@ -2324,7 +2024,7 @@ pmac_suspend_devices(void)
        /* Sync the disks. */
        /* XXX It would be nice to have some way to ensure that
         * nobody is dirtying any new buffers while we wait. That
-        * could be acheived using the refrigerator for processes
+        * could be achieved using the refrigerator for processes
         * that swsusp uses
         */
        sys_sync();
@@ -2337,15 +2037,25 @@ pmac_suspend_devices(void)
        }
 
        /* Send suspend call to devices, hold the device core's dpm_sem */
-       ret = device_suspend(PM_SUSPEND_MEM);
+       ret = device_suspend(PMSG_SUSPEND);
        if (ret) {
-               printk(KERN_ERR "Driver sleep failed\n");
                broadcast_wake();
+               printk(KERN_ERR "Driver sleep failed\n");
                return -EBUSY;
        }
-       
+
+#ifdef CONFIG_PMAC_BACKLIGHT
+       /* Tell backlight code not to muck around with the chip anymore */
+       pmu_backlight_set_sleep(1);
+#endif
+
+       /* Call platform functions marked "on sleep" */
+       pmac_pfunc_i2c_suspend();
+       pmac_pfunc_base_suspend();
+
+       /* Stop preemption */
        preempt_disable();
-       
+
        /* Make sure the decrementer won't interrupt us */
        asm volatile("mtdec %0" : : "r" (0x7fffffff));
        /* Make sure any pending DEC interrupt occurring while we did
@@ -2364,7 +2074,7 @@ pmac_suspend_devices(void)
         * use this but still... This will take care of sysdev's as well, so
         * we exit from here with local irqs disabled and PIC off.
         */
-       ret = device_power_down(PM_SUSPEND_MEM);
+       ret = device_power_down(PMSG_SUSPEND);
        if (ret) {
                wakeup_decrementer();
                local_irq_enable();
@@ -2375,10 +2085,8 @@ pmac_suspend_devices(void)
                return -EBUSY;
        }
 
-       /* Wait for completion of async backlight requests */
-       while (!bright_req_1.complete || !bright_req_2.complete ||
-
-                       !batt_req.complete)
+       /* Wait for completion of async requests */
+       while (!batt_req.complete)
                pmu_poll();
 
        /* Giveup the lazy FPU & vec so we don't have to back them
@@ -2387,37 +2095,42 @@ pmac_suspend_devices(void)
        enable_kernel_fp();
 
 #ifdef CONFIG_ALTIVEC
-       if (cur_cpu_spec[0]->cpu_features & CPU_FTR_ALTIVEC)
+       if (cpu_has_feature(CPU_FTR_ALTIVEC))
                enable_kernel_altivec();
 #endif /* CONFIG_ALTIVEC */
 
        return 0;
 }
 
-static int __pmac
+static int
 pmac_wakeup_devices(void)
 {
        mdelay(100);
 
+#ifdef CONFIG_PMAC_BACKLIGHT
+       /* Tell backlight code it can use the chip again */
+       pmu_backlight_set_sleep(0);
+#endif
+
        /* Power back up system devices (including the PIC) */
        device_power_up();
 
-       pmu_blink(1);
-
        /* Force a poll of ADB interrupts */
        adb_int_pending = 1;
-       via_pmu_interrupt(0, 0, 0);
+       via_pmu_interrupt(0, NULL);
 
        /* Restart jiffies & scheduling */
        wakeup_decrementer();
 
        /* Re-enable local CPU interrupts */
        local_irq_enable();
-
-       pmu_blink(1);
-
+       mdelay(10);
        preempt_enable();
 
+       /* Call platform functions marked "on wake" */
+       pmac_pfunc_base_resume();
+       pmac_pfunc_i2c_resume();
+
        /* Resume devices */
        device_resume();
 
@@ -2434,8 +2147,7 @@ pmac_wakeup_devices(void)
 #define        GRACKLE_NAP     (1<<4)
 #define        GRACKLE_SLEEP   (1<<3)
 
-int __pmac
-powerbook_sleep_grackle(void)
+static int powerbook_sleep_grackle(void)
 {
        unsigned long save_l2cr;
        unsigned short pmcr1;
@@ -2462,8 +2174,6 @@ powerbook_sleep_grackle(void)
 
        /* For 750, save backside cache setting and disable it */
        save_l2cr = _get_L2CR();        /* (returns -1 if not available) */
-       if (save_l2cr != 0xffffffff && (save_l2cr & L2CR_L2E) != 0)
-               _set_L2CR(save_l2cr & 0x7fffffff);
 
        if (!__fake_sleep) {
                /* Ask the PMU to put us to sleep */
@@ -2502,7 +2212,7 @@ powerbook_sleep_grackle(void)
                _set_L2CR(save_l2cr);
        
        /* Restore userland MMU context */
-       set_context(current->active_mm->context, current->active_mm->pgd);
+       set_context(current->active_mm->context.id, current->active_mm->pgd);
 
        /* Power things up */
        pmu_unlock();
@@ -2520,7 +2230,7 @@ powerbook_sleep_grackle(void)
        return 0;
 }
 
-static int __pmac
+static int
 powerbook_sleep_Core99(void)
 {
        unsigned long save_l2cr;
@@ -2528,17 +2238,24 @@ powerbook_sleep_Core99(void)
        struct adb_request req;
        int ret;
        
-       if (!can_sleep) {
+       if (pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,-1) < 0) {
                printk(KERN_ERR "Sleep mode not supported on this machine\n");
                return -ENOSYS;
        }
-       
+
+       if (num_online_cpus() > 1 || cpu_is_offline(0))
+               return -EAGAIN;
+
        ret = pmac_suspend_devices();
        if (ret) {
                printk(KERN_ERR "Sleep rejected by devices\n");
                return ret;
        }
-       
+
+       /* Stop environment and ADB interrupts */
+       pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, 0);
+       pmu_wait_complete(&req);
+
        /* Tell PMU what events will wake us up */
        pmu_request(&req, NULL, 4, PMU_POWER_EVENTS, PMU_PWR_CLR_WAKEUP_EVENTS,
                0xff, 0xff);
@@ -2548,16 +2265,9 @@ powerbook_sleep_Core99(void)
                (option_lid_wakeup ? PMU_PWR_WAKEUP_LID_OPEN : 0));
        pmu_wait_complete(&req);
 
-       /* Save & disable L2 and L3 caches*/
+       /* Save the state of the L2 and L3 caches */
        save_l3cr = _get_L3CR();        /* (returns -1 if not available) */
        save_l2cr = _get_L2CR();        /* (returns -1 if not available) */
-       if (save_l3cr != 0xffffffff && (save_l3cr & L3CR_L3E) != 0)
-               _set_L3CR(save_l3cr & 0x7fffffff);
-       if (save_l2cr != 0xffffffff && (save_l2cr & L2CR_L2E) != 0)
-               _set_L2CR(save_l2cr & 0x7fffffff);
-
-       /* Save the state of PCI config space for some slots */
-       //pbook_pci_save();
 
        if (!__fake_sleep) {
                /* Ask the PMU to put us to sleep */
@@ -2572,7 +2282,7 @@ powerbook_sleep_Core99(void)
         * talk to the PMU after this, so I moved it to _after_ sending the
         * sleep command to it. Still need to be checked.
         */
-       pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,1);
+       pmac_call_feature(PMAC_FTR_SLEEP_STATE, NULL, 0, 1);
 
        /* Call low-level ASM sleep handler */
        if (__fake_sleep)
@@ -2581,18 +2291,16 @@ powerbook_sleep_Core99(void)
                low_sleep_handler();
 
        /* Restore Apple core ASICs state */
-       pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,0);
+       pmac_call_feature(PMAC_FTR_SLEEP_STATE, NULL, 0, 0);
 
        /* Restore VIA */
        restore_via_state();
 
-       /* Restore PCI config space. This should be overridable by PCI device
-        * drivers as some of them may need special restore code. That's yet
-        * another issue that should be handled by the common code properly,
-        * maybe one day ?
-        */
-       /* Don't restore PCI for now, it crashes. Maybe unnecessary on pbook */
-       //pbook_pci_restore();
+       /* tweak LPJ before cpufreq is there */
+       loops_per_jiffy *= 2;
+
+       /* Restore video */
+       pmac_call_early_video_resume();
 
        /* Restore L2 cache */
        if (save_l2cr != 0xffffffff && (save_l2cr & L2CR_L2E) != 0)
@@ -2602,7 +2310,7 @@ powerbook_sleep_Core99(void)
                _set_L3CR(save_l3cr);
        
        /* Restore userland MMU context */
-       set_context(current->active_mm->context, current->active_mm->pgd);
+       set_context(current->active_mm->context.id, current->active_mm->pgd);
 
        /* Tell PMU we are ready */
        pmu_unlock();
@@ -2611,7 +2319,8 @@ powerbook_sleep_Core99(void)
        pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, pmu_intr_mask);
        pmu_wait_complete(&req);
 
-       pmu_blink(1);
+       /* Restore LPJ, cpufreq will adjust the cpu frequency */
+       loops_per_jiffy /= 2;
 
        pmac_wakeup_devices();
 
@@ -2621,15 +2330,15 @@ powerbook_sleep_Core99(void)
 #define PB3400_MEM_CTRL                0xf8000000
 #define PB3400_MEM_CTRL_SLEEP  0x70
 
-static int __pmac
+static int
 powerbook_sleep_3400(void)
 {
        int ret, i, x;
        unsigned int hid0;
        unsigned long p;
        struct adb_request sleep_req;
-       char *mem_ctrl;
-       unsigned int *mem_ctrl_sleep;
+       void __iomem *mem_ctrl;
+       unsigned int __iomem *mem_ctrl_sleep;
 
        /* first map in the memory controller registers */
        mem_ctrl = ioremap(PB3400_MEM_CTRL, 0x100);
@@ -2637,7 +2346,7 @@ powerbook_sleep_3400(void)
                printk("powerbook_sleep_3400: ioremap failed\n");
                return -ENOMEM;
        }
-       mem_ctrl_sleep = (unsigned int *) (mem_ctrl + PB3400_MEM_CTRL_SLEEP);
+       mem_ctrl_sleep = mem_ctrl + PB3400_MEM_CTRL_SLEEP;
 
        /* Allocate room for PCI save */
        pbook_alloc_pci_save();
@@ -2676,10 +2385,10 @@ powerbook_sleep_3400(void)
        asleep = 1;
 
        /* Put the CPU into sleep mode */
-       asm volatile("mfspr %0,1008" : "=r" (hid0) :);
+       hid0 = mfspr(SPRN_HID0);
        hid0 = (hid0 & ~(HID0_NAP | HID0_DOZE)) | HID0_SLEEP;
-       asm volatile("mtspr 1008,%0" : : "r" (hid0));
-       _nmask_and_or_msr(0, MSR_POW | MSR_EE);
+       mtspr(SPRN_HID0, hid0);
+       mtmsr(mfmsr() | MSR_POW | MSR_EE);
        udelay(10);
 
        /* OK, we're awake again, start restoring things */
@@ -2699,6 +2408,8 @@ powerbook_sleep_3400(void)
        return 0;
 }
 
+#endif /* CONFIG_PM && CONFIG_PPC32 */
+
 /*
  * Support for /dev/pmu device
  */
@@ -2715,13 +2426,13 @@ struct pmu_private {
        spinlock_t lock;
 #if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT)
        int     backlight_locker;
-#endif /* defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) */    
+#endif
 };
 
 static LIST_HEAD(all_pmu_pvt);
-static spinlock_t all_pvt_lock __pmacdata = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(all_pvt_lock);
 
-static void __pmac
+static void
 pmu_pass_intr(unsigned char *data, int len)
 {
        struct pmu_private *pp;
@@ -2750,7 +2461,7 @@ pmu_pass_intr(unsigned char *data, int len)
        spin_unlock_irqrestore(&all_pvt_lock, flags);
 }
 
-static int __pmac
+static int
 pmu_open(struct inode *inode, struct file *file)
 {
        struct pmu_private *pp;
@@ -2765,27 +2476,26 @@ pmu_open(struct inode *inode, struct file *file)
        spin_lock_irqsave(&all_pvt_lock, flags);
 #if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT)
        pp->backlight_locker = 0;
-#endif /* defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) */    
+#endif
        list_add(&pp->list, &all_pmu_pvt);
        spin_unlock_irqrestore(&all_pvt_lock, flags);
        file->private_data = pp;
        return 0;
 }
 
-static ssize_t  __pmac
+static ssize_t 
 pmu_read(struct file *file, char __user *buf,
                        size_t count, loff_t *ppos)
 {
        struct pmu_private *pp = file->private_data;
        DECLARE_WAITQUEUE(wait, current);
        unsigned long flags;
-       int ret;
+       int ret = 0;
 
        if (count < 1 || pp == 0)
                return -EINVAL;
-       ret = verify_area(VERIFY_WRITE, buf, count);
-       if (ret)
-               return ret;
+       if (!access_ok(VERIFY_WRITE, buf, count))
+               return -EFAULT;
 
        spin_lock_irqsave(&pp->lock, flags);
        add_wait_queue(&pp->wait, &wait);
@@ -2825,14 +2535,14 @@ pmu_read(struct file *file, char __user *buf,
        return ret;
 }
 
-static ssize_t __pmac
+static ssize_t
 pmu_write(struct file *file, const char __user *buf,
                         size_t count, loff_t *ppos)
 {
        return 0;
 }
 
-static unsigned int __pmac
+static unsigned int
 pmu_fpoll(struct file *filp, poll_table *wait)
 {
        struct pmu_private *pp = filp->private_data;
@@ -2849,7 +2559,7 @@ pmu_fpoll(struct file *filp, poll_table *wait)
        return mask;
 }
 
-static int __pmac
+static int
 pmu_release(struct inode *inode, struct file *file)
 {
        struct pmu_private *pp = file->private_data;
@@ -2857,32 +2567,31 @@ pmu_release(struct inode *inode, struct file *file)
 
        lock_kernel();
        if (pp != 0) {
-               file->private_data = 0;
+               file->private_data = NULL;
                spin_lock_irqsave(&all_pvt_lock, flags);
                list_del(&pp->list);
                spin_unlock_irqrestore(&all_pvt_lock, flags);
+
 #if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT)
-               if (pp->backlight_locker) {
-                       spin_lock_irqsave(&pmu_lock, flags);
-                       disable_kernel_backlight--;
-                       spin_unlock_irqrestore(&pmu_lock, flags);
-               }
-#endif /* defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) */
+               if (pp->backlight_locker)
+                       pmac_backlight_enable();
+#endif
+
                kfree(pp);
        }
        unlock_kernel();
        return 0;
 }
 
-/* Note: removed __openfirmware here since it causes link errors */
-static int __pmac
+static int
 pmu_ioctl(struct inode * inode, struct file *filp,
                     u_int cmd, u_long arg)
 {
-       struct pmu_private *pp = filp->private_data;
-       int error;
+       __u32 __user *argp = (__u32 __user *)arg;
+       int error = -EINVAL;
 
        switch (cmd) {
+#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
        case PMU_IOC_SLEEP:
                if (!capable(CAP_SYS_ADMIN))
                        return -EACCES;
@@ -2904,53 +2613,67 @@ pmu_ioctl(struct inode * inode, struct file *filp,
                        error = -ENOSYS;
                }
                sleep_in_progress = 0;
-               return error;
+               break;
        case PMU_IOC_CAN_SLEEP:
-               return put_user((u32)can_sleep, (__u32 *)arg);
+               if (pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,-1) < 0)
+                       return put_user(0, argp);
+               else
+                       return put_user(1, argp);
+#endif /* CONFIG_PM && CONFIG_PPC32 */
 
-#ifdef CONFIG_PMAC_BACKLIGHT
-       /* Backlight should have its own device or go via
-        * the fbdev
-        */
+#ifdef CONFIG_PMAC_BACKLIGHT_LEGACY
+       /* Compatibility ioctl's for backlight */
        case PMU_IOC_GET_BACKLIGHT:
+       {
+               int brightness;
+
                if (sleep_in_progress)
                        return -EBUSY;
-               error = get_backlight_level();
-               if (error < 0)
-                       return error;
-               return put_user(error, (__u32 *)arg);
+
+               brightness = pmac_backlight_get_legacy_brightness();
+               if (brightness < 0)
+                       return brightness;
+               else
+                       return put_user(brightness, argp);
+
+       }
        case PMU_IOC_SET_BACKLIGHT:
        {
-               __u32 value;
+               int brightness;
+
                if (sleep_in_progress)
                        return -EBUSY;
-               error = get_user(value, (__u32 *)arg);
-               if (!error)
-                       error = set_backlight_level(value);
-               return error;
+
+               error = get_user(brightness, argp);
+               if (error)
+                       return error;
+
+               return pmac_backlight_set_legacy_brightness(brightness);
        }
 #ifdef CONFIG_INPUT_ADBHID
        case PMU_IOC_GRAB_BACKLIGHT: {
-               unsigned long flags;
+               struct pmu_private *pp = filp->private_data;
+
                if (pp->backlight_locker)
                        return 0;
+
                pp->backlight_locker = 1;
-               spin_lock_irqsave(&pmu_lock, flags);
-               disable_kernel_backlight++;
-               spin_unlock_irqrestore(&pmu_lock, flags);
+               pmac_backlight_disable();
+
                return 0;
        }
 #endif /* CONFIG_INPUT_ADBHID */
-#endif /* CONFIG_PMAC_BACKLIGHT */
+#endif /* CONFIG_PMAC_BACKLIGHT_LEGACY */
+
        case PMU_IOC_GET_MODEL:
-               return put_user(pmu_kind, (__u32 *)arg);
+               return put_user(pmu_kind, argp);
        case PMU_IOC_HAS_ADB:
-               return put_user(pmu_has_adb, (__u32 *)arg);
+               return put_user(pmu_has_adb, argp);
        }
-       return -EINVAL;
+       return error;
 }
 
-static struct file_operations pmu_device_fops __pmacdata = {
+static struct file_operations pmu_device_fops = {
        .read           = pmu_read,
        .write          = pmu_write,
        .poll           = pmu_fpoll,
@@ -2959,22 +2682,24 @@ static struct file_operations pmu_device_fops __pmacdata = {
        .release        = pmu_release,
 };
 
-static struct miscdevice pmu_device __pmacdata = {
+static struct miscdevice pmu_device = {
        PMU_MINOR, "pmu", &pmu_device_fops
 };
 
-void pmu_device_init(void)
+static int pmu_device_init(void)
 {
        if (!via)
-               return;
+               return 0;
        if (misc_register(&pmu_device) < 0)
                printk(KERN_ERR "via-pmu: cannot register misc device.\n");
+       return 0;
 }
-#endif /* CONFIG_PMAC_PBOOK */
+device_initcall(pmu_device_init);
+
 
 #ifdef DEBUG_SLEEP
-static inline void  __pmac
-polled_handshake(volatile unsigned char *via)
+static inline void 
+polled_handshake(volatile unsigned char __iomem *via)
 {
        via[B] &= ~TREQ; eieio();
        while ((via[B] & TACK) != 0)
@@ -2984,16 +2709,16 @@ polled_handshake(volatile unsigned char *via)
                ;
 }
 
-static inline void  __pmac
-polled_send_byte(volatile unsigned char *via, int x)
+static inline void 
+polled_send_byte(volatile unsigned char __iomem *via, int x)
 {
        via[ACR] |= SR_OUT | SR_EXT; eieio();
        via[SR] = x; eieio();
        polled_handshake(via);
 }
 
-static inline int __pmac
-polled_recv_byte(volatile unsigned char *via)
+static inline int
+polled_recv_byte(volatile unsigned char __iomem *via)
 {
        int x;
 
@@ -3004,12 +2729,12 @@ polled_recv_byte(volatile unsigned char *via)
        return x;
 }
 
-int __pmac
+int
 pmu_polled_request(struct adb_request *req)
 {
        unsigned long flags;
        int i, l, c;
-       volatile unsigned char *v = via;
+       volatile unsigned char __iomem *v = via;
 
        req->complete = 1;
        c = req->data[0];
@@ -3045,23 +2770,100 @@ pmu_polled_request(struct adb_request *req)
 }
 #endif /* DEBUG_SLEEP */
 
+
+/* FIXME: This is a temporary set of callbacks to enable us
+ * to do suspend-to-disk.
+ */
+
+#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
+
+static int pmu_sys_suspended = 0;
+
+static int pmu_sys_suspend(struct sys_device *sysdev, pm_message_t state)
+{
+       if (state.event != PM_EVENT_SUSPEND || pmu_sys_suspended)
+               return 0;
+
+       /* Suspend PMU event interrupts */
+       pmu_suspend();
+
+       pmu_sys_suspended = 1;
+       return 0;
+}
+
+static int pmu_sys_resume(struct sys_device *sysdev)
+{
+       struct adb_request req;
+
+       if (!pmu_sys_suspended)
+               return 0;
+
+       /* Tell PMU we are ready */
+       pmu_request(&req, NULL, 2, PMU_SYSTEM_READY, 2);
+       pmu_wait_complete(&req);
+
+       /* Resume PMU event interrupts */
+       pmu_resume();
+
+       pmu_sys_suspended = 0;
+
+       return 0;
+}
+
+#endif /* CONFIG_PM && CONFIG_PPC32 */
+
+static struct sysdev_class pmu_sysclass = {
+       set_kset_name("pmu"),
+};
+
+static struct sys_device device_pmu = {
+       .id             = 0,
+       .cls            = &pmu_sysclass,
+};
+
+static struct sysdev_driver driver_pmu = {
+#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
+       .suspend        = &pmu_sys_suspend,
+       .resume         = &pmu_sys_resume,
+#endif /* CONFIG_PM && CONFIG_PPC32 */
+};
+
+static int __init init_pmu_sysfs(void)
+{
+       int rc;
+
+       rc = sysdev_class_register(&pmu_sysclass);
+       if (rc) {
+               printk(KERN_ERR "Failed registering PMU sys class\n");
+               return -ENODEV;
+       }
+       rc = sysdev_register(&device_pmu);
+       if (rc) {
+               printk(KERN_ERR "Failed registering PMU sys device\n");
+               return -ENODEV;
+       }
+       rc = sysdev_driver_register(&pmu_sysclass, &driver_pmu);
+       if (rc) {
+               printk(KERN_ERR "Failed registering PMU sys driver\n");
+               return -ENODEV;
+       }
+       return 0;
+}
+
+subsys_initcall(init_pmu_sysfs);
+
 EXPORT_SYMBOL(pmu_request);
+EXPORT_SYMBOL(pmu_queue_request);
 EXPORT_SYMBOL(pmu_poll);
 EXPORT_SYMBOL(pmu_poll_adb);
 EXPORT_SYMBOL(pmu_wait_complete);
 EXPORT_SYMBOL(pmu_suspend);
 EXPORT_SYMBOL(pmu_resume);
 EXPORT_SYMBOL(pmu_unlock);
-EXPORT_SYMBOL(pmu_i2c_combined_read);
-EXPORT_SYMBOL(pmu_i2c_stdsub_write);
-EXPORT_SYMBOL(pmu_i2c_simple_read);
-EXPORT_SYMBOL(pmu_i2c_simple_write);
-#ifdef CONFIG_PMAC_PBOOK
-EXPORT_SYMBOL(pmu_register_sleep_notifier);
-EXPORT_SYMBOL(pmu_unregister_sleep_notifier);
+#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
 EXPORT_SYMBOL(pmu_enable_irled);
 EXPORT_SYMBOL(pmu_battery_count);
 EXPORT_SYMBOL(pmu_batteries);
 EXPORT_SYMBOL(pmu_power_flags);
-#endif /* CONFIG_PMAC_PBOOK */
+#endif /* CONFIG_PM && CONFIG_PPC32 */