#include <asm/system.h>
#include <asm/sections.h>
#include <asm/irq.h>
-#include <asm/hardirq.h>
#include <asm/pmac_feature.h>
#include <asm/uaccess.h>
#include <asm/mmu_context.h>
/* 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 */
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 unsigned char __iomem *gpio_reg = NULL;
static int gpio_irq = -1;
static int gpio_irq_enabled = -1;
static volatile int pmu_suspended = 0;
static int sleep_in_progress;
static int can_sleep;
#endif /* CONFIG_PMAC_PBOOK */
+static unsigned long async_req_locks;
static unsigned int pmu_irq_stats[11];
static struct proc_dir_entry *proc_pmu_root;
} else
pmu_kind = PMU_UNKNOWN;
- via = (volatile unsigned char *) ioremap(vias->addrs->address, 0x2000);
+ via = ioremap(vias->addrs->address, 0x2000);
out_8(&via[IER], IER_CLR | 0x7f); /* disable all intrs */
out_8(&via[IFR], 0x7f); /* clear IFR */
}
if (pmu_kind == PMU_KEYLARGO_BASED && gpio_irq != -1) {
- if (request_irq(gpio_irq, gpio1_interrupt, 0, "GPIO1/ADB", (void *)0))
+ 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;
}
}
#endif /* CONFIG_PMAC_PBOOK */
/* 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
+ int i;
+
for (i=0; i<pmu_battery_count; i++) {
char title[16];
sprintf(title, "battery_%d", i);
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;
}
if (pmu_state == idle)
adb_int_pending = 1;
- via_pmu_interrupt(0, 0, 0);
+ via_pmu_interrupt(0, NULL, NULL);
udelay(10);
}
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]) {
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;
return -EINVAL;
}
- req->next = 0;
+ req->next = NULL;
req->sent = 0;
req->complete = 0;
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);
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 */
return;
if (disable_poll)
return;
- via_pmu_interrupt(0, 0, 0);
+ via_pmu_interrupt(0, NULL, NULL);
}
void __openfirmware
/* Kicks ADB read when PMU is suspended */
adb_int_pending = 1;
do {
- via_pmu_interrupt(0, 0, 0);
+ via_pmu_interrupt(0, NULL, NULL);
} while (pmu_suspended && (adb_int_pending || pmu_state != idle
|| req_awaiting_reply));
}
if (!via)
return;
while((pmu_state != idle && pmu_state != locked) || !req->complete)
- via_pmu_interrupt(0, 0, 0);
+ via_pmu_interrupt(0, NULL, NULL);
}
/* This function loops until the PMU is idle and prevents it from
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, NULL);
spin_lock_irqsave(&pmu_lock, flags);
if (!adb_int_pending && pmu_state == idle && !req_awaiting_reply) {
#ifdef SUSPEND_USES_PMU
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 {
pmu_sr_intr(struct pt_regs *regs)
{
struct adb_request *req;
- int bite;
+ int bite = 0;
if (via[B] & TREQ) {
printk(KERN_ERR "PMU: spurious SR intr (%x)\n", via[B]);
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, NULL);
return IRQ_HANDLED;
}
return IRQ_NONE;
if (n->list.next == 0)
return -ENOENT;
list_del(&n->list);
- n->list.next = 0;
+ n->list.next = NULL;
return 0;
}
/* Force a poll of ADB interrupts */
adb_int_pending = 1;
- via_pmu_interrupt(0, 0, 0);
+ via_pmu_interrupt(0, NULL, NULL);
/* Restart jiffies & scheduling */
wakeup_decrementer();
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);
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();
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);
u_int cmd, u_long arg)
{
struct pmu_private *pp = filp->private_data;
+ __u32 __user *argp = (__u32 __user *)arg;
int error;
switch (cmd) {
sleep_in_progress = 0;
return error;
case PMU_IOC_CAN_SLEEP:
- return put_user((u32)can_sleep, (__u32 *)arg);
+ return put_user((u32)can_sleep, argp);
#ifdef CONFIG_PMAC_BACKLIGHT
/* Backlight should have its own device or go via
error = get_backlight_level();
if (error < 0)
return error;
- return put_user(error, (__u32 *)arg);
+ return put_user(error, argp);
case PMU_IOC_SET_BACKLIGHT:
{
__u32 value;
if (sleep_in_progress)
return -EBUSY;
- error = get_user(value, (__u32 *)arg);
+ error = get_user(value, argp);
if (!error)
error = set_backlight_level(value);
return error;
#endif /* CONFIG_INPUT_ADBHID */
#endif /* CONFIG_PMAC_BACKLIGHT */
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;
}
#ifdef DEBUG_SLEEP
static inline void __pmac
-polled_handshake(volatile unsigned char *via)
+polled_handshake(volatile unsigned char __iomem *via)
{
via[B] &= ~TREQ; eieio();
while ((via[B] & TACK) != 0)
}
static inline void __pmac
-polled_send_byte(volatile unsigned char *via, int x)
+polled_send_byte(volatile unsigned char __iomem *via, int x)
{
via[ACR] |= SR_OUT | SR_EXT; eieio();
via[SR] = x; eieio();
}
static inline int __pmac
-polled_recv_byte(volatile unsigned char *via)
+polled_recv_byte(volatile unsigned char __iomem *via)
{
int x;
{
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];