-+ /* Set PME group 6 to fire the SCI interrupt */
-+ geode_gpio_set_irq(6, sci_irq);
-+ }
-+
-+ geode_gpio_set(OLPC_GPIO_ECSCI, GPIO_INPUT_ENABLE);
-+
-+ /* Clear pending events */
-+
-+ geode_gpio_set(OLPC_GPIO_ECSCI, GPIO_NEGATIVE_EDGE_STS);
-+ geode_gpio_set(OLPC_GPIO_ECSCI, GPIO_POSITIVE_EDGE_STS);
-+
-+ //geode_gpio_set(OLPC_GPIO_ECSCI, GPIO_NEGATIVE_EDGE_EN);
-+ geode_gpio_set(OLPC_GPIO_ECSCI, GPIO_EVENTS_ENABLE);
-+
-+ /* Set the SCI to cause a PME event on group 7 */
-+ geode_gpio_event_pme(OLPC_GPIO_ECSCI, 7);
-+
-+ /* And have group 6 also fire the SCI interrupt */
-+ geode_gpio_set_irq(7, sci_irq);
-+}
-+
-+/* This provides a control file for setting up testing of the
-+ power management system. For now, there is just one setting:
-+ "test" which means that we don't actually enter the power
-+ off routine.
-+*/
-+
-+static const char * const pm_states[] = {
-+ [PM_MODE_NORMAL] = "normal",
-+ [PM_MODE_TEST] = "test",
-+};
-+
-+extern struct mutex pm_mutex;
-+extern struct kset power_subsys;
-+
-+static ssize_t control_show(struct kset *s, char *buf)
-+{
-+ return sprintf(buf, "%s\n", pm_states[olpc_pm_mode]);
-+}
-+
-+static ssize_t control_store(struct kset *s, const char *buf, size_t n)
-+{
-+ int i, len;
-+ char *p;
-+
-+ p = memchr(buf, '\n', n);
-+ len = p ? p - buf : n;
-+
-+ /* Grab the mutex */
-+ mutex_lock(&pm_mutex);
-+
-+ for(i = 0; i < PM_MODE_MAX; i++) {
-+ if (!strncmp(buf, pm_states[i], len)) {
-+ olpc_pm_mode = i;
-+ break;
-+ }
-+ }
-+
-+ mutex_unlock(&pm_mutex);
-+
-+ return (i == PM_MODE_MAX) ? -EINVAL : n;
-+}
-+
-+static struct subsys_attribute control_attr = {
-+ .attr = {
-+ .name = "olpc-pm",
-+ .mode = 0644,
-+ },
-+ .show = control_show,
-+ .store = control_store,
-+};
-+
-+static struct attribute * olpc_attributes[] = {
-+ &control_attr.attr,
-+ NULL
-+};
-+
-+static struct attribute_group olpc_attrs = {
-+ .attrs = olpc_attributes,
-+};
-+
-+static int __init alloc_inputdevs(void)
-+{
-+ int ret = -ENOMEM;
-+
-+ pm_inputdev = input_allocate_device();
-+ if (!pm_inputdev)
-+ goto err;
-+
-+ pm_inputdev->name = "OLPC PM";
-+ pm_inputdev->phys = "olpc_pm/input0";
-+ set_bit(EV_KEY, pm_inputdev->evbit);
-+ set_bit(KEY_POWER, pm_inputdev->keybit);
-+
-+ ret = input_register_device(pm_inputdev);
-+ if (ret) {
-+ printk(KERN_ERR "olpc-pm: failed to register PM input device: %d\n", ret);
-+ goto err;
-+ }
-+
-+ lid_inputdev = input_allocate_device();
-+ if (!lid_inputdev)
-+ goto err;
-+
-+ lid_inputdev->name = "OLPC lid switch";
-+ lid_inputdev->phys = "olpc_pm/input1";
-+ set_bit(EV_SW, lid_inputdev->evbit);
-+ set_bit(SW_LID, lid_inputdev->swbit);
-+
-+ ret = input_register_device(lid_inputdev);
-+ if (ret) {
-+ printk(KERN_ERR "olpc-pm: failed to register lid input device: %d\n", ret);
-+ goto err;
-+ }
-+
-+ ebook_inputdev = input_allocate_device();
-+ if (!ebook_inputdev)
-+ goto err;
-+
-+ ebook_inputdev->name = "OLPC ebook switch";
-+ ebook_inputdev->phys = "olpc_pm/input2";
-+ set_bit(EV_SW, ebook_inputdev->evbit);
-+ set_bit(SW_TABLET_MODE, ebook_inputdev->swbit);
-+
-+ ret = input_register_device(ebook_inputdev);
-+ if (ret) {
-+ printk(KERN_ERR "olpc-pm: failed to register ebook input device: %d\n", ret);
-+ goto err;
-+ }
-+
-+ return ret;
-+err:
-+ if (ebook_inputdev) {
-+ input_unregister_device(ebook_inputdev);
-+ ebook_inputdev = NULL;
-+ }
-+ if (lid_inputdev) {
-+ input_unregister_device(lid_inputdev);
-+ lid_inputdev = NULL;
-+ }
-+ if (pm_inputdev) {
-+ input_unregister_device(pm_inputdev);
-+ pm_inputdev = NULL;
-+ }
-+
-+ return ret;
-+}
-+
-+static int __init olpc_pm_init(void)
-+{
-+ uint32_t lo, hi;
-+ int ret;
-+ uint8_t ec_byte;
-+
-+ if (!machine_is_olpc())
-+ return -ENODEV;
-+
-+ acpi_base = geode_acpi_base();
-+ pms_base = geode_pms_base();
-+
-+ if (!acpi_base || !pms_base)
-+ return -ENODEV;
-+
-+ ret = alloc_inputdevs();
-+ if (ret)
-+ return ret;
-+
-+ rdmsr(0x51400020, lo, hi);
-+ sci_irq = (lo >> 20) & 15;
-+
-+ if (sci_irq) {
-+ printk(KERN_INFO "SCI is mapped to IRQ %d\n", sci_irq);
-+ } else {
-+ /* Zero doesn't mean zero -- it means masked */
-+ printk(KERN_INFO "SCI unmapped. Mapping to IRQ 3\n");
-+ sci_irq = 3;
-+ lo |= 0x00300000;
-+ wrmsrl(0x51400020, lo);
-+ }
-+
-+ olpc_fixup_bios();
-+
-+ lo = inl(pms_base + PM_FSD);
-+
-+ /* Lock, enable failsafe, 4 seconds */
-+ outl(0xc001f400, pms_base + PM_FSD);
-+
-+ /* Here we set up the SCI events we're interested in during
-+ * real-time. We have no sleep button, and the RTC doesn't make
-+ * sense, so set up the power button
-+ */
-+
-+ outl(inl(acpi_base) | ((CS5536_PM_PWRBTN) << 16), acpi_base);
-+
-+ if (olpc_get_rev() >= OLPC_REV_B2) {
-+ gpio_wake_events |= GPIO_WAKEUP_LID;
-+
-+ /* Get the current value of the GPIO, and set up the edges */
-+ olpc_lid_flag = geode_gpio_isset(OLPC_GPIO_LID, GPIO_READ_BACK);
-+
-+ /* Watch for the opposite edge */
-+
-+ if (olpc_lid_flag)
-+ geode_gpio_set(OLPC_GPIO_LID, GPIO_NEGATIVE_EDGE_EN);
-+ else
-+ geode_gpio_set(OLPC_GPIO_LID, GPIO_POSITIVE_EDGE_EN);
-+
-+ /* Enable the event */
-+ geode_gpio_set(OLPC_GPIO_LID, GPIO_EVENTS_ENABLE);
-+ }
-+
-+ /* Set up the mask for wakeups the EC will generate SCIs on */
-+
-+ ret = olpc_ec_cmd(EC_READ_SCI_MASK, NULL, 0, &ec_byte, 1);
-+ if (ret)
-+ printk(KERN_ERR "Error getting the EC SCI mask: %d\n", ret);
-+
-+ /* Disable battery 1% charge wakeups */
-+ ec_byte &= ~EC_SCI_SRC_BATSOC;
-+
-+ ret = olpc_ec_cmd(EC_WRITE_SCI_MASK, &ec_byte, 1, NULL, 0);
-+ if (ret)
-+ printk(KERN_ERR "Error setting the EC SCI mask: %d\n", ret);
-+
-+ /* Set up the EC SCI */
-+
-+ gpio_wake_events |= GPIO_WAKEUP_EC;
-+
-+ outl(gpio_wake_events, acpi_base + PM_GPE0_EN);
-+ outl(0xFFFFFFFF, acpi_base + PM_GPE0_STS);
-+
-+ /* Select level triggered in PIC */
-+
-+ if (sci_irq < 8) {
-+ lo = inb(0x4d0);
-+ lo |= 1 << sci_irq;
-+ outb(lo, 0x4d0);
-+ } else {
-+ lo = inb(0x4d1);
-+ lo |= 1 << (sci_irq - 8);
-+ outb(lo, 0x4d1);
-+ }
-+ /* Clear pending interrupt */
-+ outl(inl(acpi_base) | 0xFFFF, acpi_base);
-+ process_sci_queue(0); /* we just want to flush the queue here */
-+ init_ebook_state();
-+
-+ /* Enable the interrupt */
-+
-+ ret = request_irq(sci_irq, &olpc_pm_interrupt, 0, "SCI", &acpi_base);
-+
-+ if (ret) {
-+ printk(KERN_ERR "Error registering SCI: %d\n", ret);
-+ return ret;
-+ }
-+
-+ ofw_bios_entry.address = 0xF0000 + PAGE_OFFSET;
-+ pm_set_ops(&olpc_pm_ops);
-+
-+ sysfs_create_group(&power_subsys.kobj, &olpc_attrs);
-+
-+ return 0;
-+}
-+
-+
-+#if defined (CONFIG_RTC_DRV_CMOS) || defined (CONFIG_RTC_DRV_CMOS_MODULE)
-+struct resource rtc_platform_resource[2] = {
-+ {
-+ .flags = IORESOURCE_IO,
-+ .start = RTC_PORT(0),
-+ .end = RTC_PORT(0) + RTC_IO_EXTENT
-+ },
-+ {
-+ .flags = IORESOURCE_IRQ,
-+ .start = 8,
-+ .end = 8,
-+ },
-+};
-+
-+
-+static void rtc_wake_on(struct device *dev)
-+{
-+ olpc_wakeup_mask |= CS5536_PM_RTC;
-+}
-+
-+static void rtc_wake_off(struct device *dev)
-+{
-+ olpc_wakeup_mask &= ~(CS5536_PM_RTC);
-+}
-+
-+static struct cmos_rtc_board_info rtc_info = {
-+ .rtc_day_alarm = 0,
-+ .rtc_mon_alarm = 0,
-+ .rtc_century = 0,
-+ .wake_on = rtc_wake_on,
-+ .wake_off = rtc_wake_off,
-+};
-+
-+struct platform_device olpc_rtc_device = {
-+ .name = "rtc_cmos",
-+ .id = -1,
-+ .num_resources = ARRAY_SIZE(rtc_platform_resource),
-+ .dev.platform_data = &rtc_info,
-+ .resource = rtc_platform_resource,
-+};
-+
-+static int __init olpc_platform_init(void)
-+{
-+ (void)platform_device_register(&olpc_rtc_device);
-+ device_init_wakeup(&olpc_rtc_device.dev, 1);
-+
-+ (void)platform_device_register(&olpc_powerbutton_dev);
-+ device_init_wakeup(&olpc_powerbutton_dev.dev, 1);
-+
-+ (void)platform_device_register(&olpc_lid_dev);
-+ device_init_wakeup(&olpc_lid_dev.dev, 1);
-+
-+ return 0;
-+}
-+arch_initcall(olpc_platform_init);
-+#endif /* CONFIG_RTC_DRV_CMOS */
-+
-+static void olpc_pm_exit(void)
-+{
-+ /* Clear any pending events, and disable them */
-+ outl(0xFFFF, acpi_base+2);
-+
-+ free_irq(sci_irq, &acpi_base);
-+ input_unregister_device(pm_inputdev);
-+ input_unregister_device(lid_inputdev);
-+ input_unregister_device(ebook_inputdev);
-+}
-+
-+static struct pm_ops olpc_pm_ops = {
-+ .valid = olpc_pm_state_valid,
-+ .enter = olpc_pm_enter,
-+};
-+
-+module_init(olpc_pm_init);
-+module_exit(olpc_pm_exit);
-+
-+MODULE_LICENSE("GPL");
-+MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
-+MODULE_DESCRIPTION("AMD Geode power management for OLPC CL1");
-diff --git a/arch/i386/kernel/olpc-sleep.S b/arch/i386/kernel/olpc-sleep.S
-new file mode 100644
-index 0000000..9535c9a
---- /dev/null
-+++ b/arch/i386/kernel/olpc-sleep.S
-@@ -0,0 +1,39 @@
-+.text
-+
-+ENTRY(olpc_sleep_asm)
-+olpc_sleep:
-+ ;; Get the value of PM1_CNT and store it off
-+
-+ add 08h, ax
-+ mov bx,dx
-+ in dx,eax
-+ or 2000h, ax
-+ mov ax,di
-+
-+ ;; flush the cache
-+ wbinvd
-+
-+ ;; GX2 must disable refresh before going into self-refresh
-+ mov 2000000180xh, ecx
-+ rdmsr
-+ mov eax, esi
-+ and 0FF0000FFh, eax
-+ wrmsr
-+
-+ ;; Now, put the memory into self refresh
-+ mov 2004, cx
-+ xor edx, edx
-+ xor eax, eax
-+ mov 04h, al
-+ wrmsr
-+
-+ ;; Thats all she wrote - time to go to sleep
-+
-+ mov bx, dx
-+ movzx di, eax
-+ out eax, dx
-+
-+ ;;
-+
-+
-+
-diff --git a/arch/i386/kernel/olpc-wakeup.S b/arch/i386/kernel/olpc-wakeup.S
-new file mode 100644
-index 0000000..a92cc61
---- /dev/null
-+++ b/arch/i386/kernel/olpc-wakeup.S
-@@ -0,0 +1,122 @@
-+.text
-+#include <linux/linkage.h>
-+#include <asm/segment.h>
-+#include <asm/page.h>
-+
-+ALIGN
-+ .align 4096
-+
-+wakeup_start:
-+# jmp wakeup_start
-+
-+ cli
-+ cld
-+
-+ # Clear any dangerous flags
-+
-+ pushl $0
-+ popfl
-+
-+ # Set up %cr3
-+ movl $swsusp_pg_dir - __PAGE_OFFSET, %eax
-+ movl %eax, %cr3
-+
-+ movl saved_cr4, %eax
-+ movl %eax, %cr4
-+
-+ movl saved_cr0, %eax
-+ movl %eax, %cr0
-+
-+ jmp 1f
-+1:
-+ ljmpl $__KERNEL_CS,$wakeup_return
-+
-+
-+.org 0x1000
-+
-+wakeup_return:
-+ movw $__KERNEL_DS, %ax
-+ movw %ax, %ss
-+ movw %ax, %ds
-+ movw %ax, %es
-+ movw %ax, %fs
-+ movw %ax, %gs
-+
-+ lgdt saved_gdt
-+ lidt saved_idt
-+ lldt saved_ldt
-+ ljmp $(__KERNEL_CS),$1f
-+1:
-+ movl %cr3, %eax
-+ movl %eax, %cr3
-+ wbinvd
-+
-+ # Go back to the return point
-+ jmp ret_point
-+
-+save_registers:
-+ sgdt saved_gdt
-+ sidt saved_idt
-+ sldt saved_ldt
-+
-+ pushl %edx
-+ movl %cr4, %edx
-+ movl %edx, saved_cr4
-+
-+ movl %cr0, %edx
-+ movl %edx, saved_cr0
-+
-+ popl %edx
-+
-+
-+ movl %ebx, saved_context_ebx
-+ movl %ebp, saved_context_ebp
-+ movl %esi, saved_context_esi
-+ movl %edi, saved_context_edi
-+
-+ pushfl
-+ popl saved_context_eflags
-+
-+ ret
-+
-+
-+restore_registers:
-+ movl saved_context_ebp, %ebp
-+ movl saved_context_ebx, %ebx
-+ movl saved_context_esi, %esi
-+ movl saved_context_edi, %edi
-+
-+ pushl saved_context_eflags
-+ popfl
-+
-+ ret
-+
-+
-+ENTRY(do_olpc_suspend_lowlevel)
-+ call save_processor_state
-+ call save_registers
-+
-+ # This is the stack context we want to remember
-+ movl %esp, saved_context_esp
-+
-+ pushl $3
-+ call olpc_do_sleep
-+
-+ jmp wakeup_start
-+ .p2align 4,,7
-+ret_point:
-+ movl saved_context_esp, %esp
-+
-+ call restore_registers
-+ call restore_processor_state
-+ ret
-+
-+.data
-+ALIGN
-+
-+saved_gdt: .long 0,0
-+saved_idt: .long 0,0
-+saved_ldt: .long 0
-+saved_cr4: .long 0
-+saved_cr0: .long 0
-+
-diff --git a/arch/i386/kernel/olpc.c b/arch/i386/kernel/olpc.c
-new file mode 100644
-index 0000000..d540cb0
---- /dev/null
-+++ b/arch/i386/kernel/olpc.c
-@@ -0,0 +1,320 @@
-+/* Support for the OLPC DCON and OLPC EC access
-+ * Copyright (C) 2006, Advanced Micro Devices, Inc.
-+ *
-+ * 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.
-+ */
-+
-+#include <linux/autoconf.h>
-+#include <linux/kernel.h>
-+#include <linux/init.h>
-+#include <linux/mc146818rtc.h>
-+#include <linux/delay.h>
-+#include <linux/spinlock.h>
-+
-+#include <asm/olpc.h>
-+#include <asm/ofw.h>
-+
-+/* This is our new multi-purpose structure used to contain the
-+ * information about the platform that we detect
-+ */
-+
-+struct olpc_platform_t olpc_platform_info;
-+EXPORT_SYMBOL_GPL(olpc_platform_info);
-+
-+/*********************************************************************
-+ * EC locking and access
-+ *********************************************************************/
-+
-+static DEFINE_SPINLOCK(ec_lock);
-+
-+/* what the timeout *should* be (in ms) */
-+#define EC_BASE_TIMEOUT 20
-+
-+/* the timeout that bugs in the EC might force us to actually use */
-+static int ec_timeout = EC_BASE_TIMEOUT;
-+
-+static int __init olpc_ec_timeout_set(char *str)
-+{
-+ if (get_option(&str, &ec_timeout) != 1) {
-+ ec_timeout = EC_BASE_TIMEOUT;
-+ printk(KERN_ERR "olpc-ec: invalid argument to "
-+ "'olpc_ec_timeout=', ignoring!\n");
-+ }
-+ printk(KERN_DEBUG "olpc-ec: using %d ms delay for EC commands.\n",
-+ ec_timeout);
-+ return 1;
-+}
-+__setup("olpc_ec_timeout=", olpc_ec_timeout_set);
-+
-+/*
-+ * These *bf_status functions return whether the buffers are full or not.
-+ */
-+
-+static inline unsigned int ibf_status(unsigned int port)
-+{
-+ return inb(port) & 0x02;
-+}
-+
-+static inline unsigned int obf_status(unsigned int port)
-+{
-+ return inb(port) & 0x01;
-+}
-+
-+#define wait_on_ibf(p, d) __wait_on_ibf(__LINE__, (p), (d))
-+static int __wait_on_ibf(unsigned int line, unsigned int port, int desired)
-+{
-+ unsigned int timeo;
-+ int state = ibf_status(port);
-+
-+ for (timeo = ec_timeout; state != desired && timeo; timeo--) {
-+ mdelay(1);
-+ state = ibf_status(port);
-+ }
-+
-+ if ((state == desired) && (ec_timeout > EC_BASE_TIMEOUT) &&
-+ timeo < (ec_timeout - EC_BASE_TIMEOUT)) {
-+ printk(KERN_WARNING "olpc-ec: waited %u ms for IBF (%d)!\n",
-+ EC_BASE_TIMEOUT-timeo, line);
-+ }
-+
-+ return !(state == desired);
-+}
-+
-+#define wait_on_obf(p, d) __wait_on_obf(__LINE__, (p), (d))
-+static int __wait_on_obf(unsigned int line, unsigned int port, int desired)
-+{
-+ unsigned int timeo;
-+ int state = obf_status(port);
-+
-+ for (timeo = ec_timeout; state != desired && timeo; timeo--) {
-+ mdelay(1);
-+ state = obf_status(port);
-+ }
-+
-+ if ((state == desired) && (ec_timeout > EC_BASE_TIMEOUT) &&
-+ timeo < (ec_timeout - EC_BASE_TIMEOUT)) {
-+ printk(KERN_WARNING "olpc-ec: waited %u ms for OBF (%d)!\n",
-+ EC_BASE_TIMEOUT-timeo, line);
-+ }
-+
-+ return !(state == desired);
-+}
-+
-+int olpc_ec_cmd(unsigned char cmd, unsigned char *inbuf, size_t inlen,
-+ unsigned char *outbuf, size_t outlen)
-+{
-+ unsigned long flags;
-+ int ret = -EIO;
-+ int i;
-+
-+ spin_lock_irqsave(&ec_lock, flags);
-+
-+ if (wait_on_ibf(0x6c, 0)) {
-+ printk(KERN_ERR "olpc-ec: timeout waiting for EC to "
-+ "quiesce!\n");
-+ goto err;
-+ }
-+
-+restart:
-+ /*
-+ * Note that if we time out during any IBF checks, that's a failure;
-+ * we have to return. There's no way for the kernel to clear that.
-+ *
-+ * If we time out during an OBF check, we can restart the command;
-+ * reissuing it will clear the OBF flag, and we should be alright.
-+ * The OBF flag will sometimes misbehave due to what we believe
-+ * is a hardware quirk..
-+ */
-+ printk(KERN_DEBUG "olpc-ec: running cmd 0x%x\n", cmd);
-+ outb(cmd, 0x6c);
-+
-+ if (wait_on_ibf(0x6c, 0)) {
-+ printk(KERN_ERR "olpc-ec: timeout waiting for EC to read "
-+ "command!\n");
-+ goto err;
-+ }
-+
-+ if (inbuf && inlen) {
-+ /* write data to EC */
-+ for (i = 0; i < inlen; i++) {
-+ if (wait_on_ibf(0x6c, 0)) {
-+ printk(KERN_ERR "olpc-ec: timeout waiting for"
-+ " EC accept data!\n");
-+ goto err;
-+ }
-+ printk(KERN_DEBUG "olpc-ec: sending cmd arg 0x%x\n",
-+ inbuf[i]);
-+ outb(inbuf[i], 0x68);
-+ }
-+ }
-+ if (outbuf && outlen) {
-+ /* read data from EC */
-+ for (i = 0; i < outlen; i++) {
-+ if (wait_on_obf(0x6c, 1)) {
-+ printk(KERN_ERR "olpc-ec: timeout waiting for"
-+ " EC to provide data!\n");
-+ goto restart;
-+ }
-+ outbuf[i] = inb(0x68);
-+ printk(KERN_DEBUG "olpc-ec: received 0x%x\n",
-+ outbuf[i]);
-+ }
-+ }
-+
-+ ret = 0;
-+err:
-+ spin_unlock_irqrestore(&ec_lock, flags);
-+ return ret;
-+}
-+EXPORT_SYMBOL_GPL(olpc_ec_cmd);
-+
-+/*********************************************************************
-+ * DCON stuff
-+ *********************************************************************/
-+
-+static void olpc_power_off(void)
-+{
-+ printk(KERN_INFO "OLPC power off sequence...\n");
-+ outb(0xff, 0x381);
-+ outb(0x14, 0x382);
-+ outb(0x01, 0x383);
-+ outb(0xff, 0x381);
-+ outb(0x14, 0x382);
-+ outb(0x00, 0x383);
-+}
-+
-+static void __init
-+ec_detect(void)
-+{
-+ olpc_ec_cmd(0x08, NULL, 0, (unsigned char *) &olpc_platform_info.ecver, 1);
-+}
-+
-+/* Check to see if this version of the OLPC board has VSA built
-+ * in, and set a flag
-+ */
-+
-+static void __init vsa_detect(void)
-+{
-+ u16 rev;
-+
-+ outw(0xFC53, 0xAC1C);
-+ outw(0x0003, 0xAC1C);
-+
-+ rev = inw(0xAC1E);
-+
-+ if (rev == 0x4132)
-+ olpc_platform_info.flags |= OLPC_F_VSA;
-+}
-+
-+/* Map OFW revisions to what OLPC_REV_* */
-+static const char __initdata *olpc_boardrev_str[] = {
-+ "A1",
-+ "preB1",
-+ "B1",
-+ "preB2",
-+ "B2",
-+ "preB3",
-+ "B3",
-+ "B4",
-+ "C1",
-+ "R1",
-+};
-+
-+static void __init platform_detect(char *revision, size_t len)
-+{
-+ size_t propsize;
-+ int i;
-+
-+ BUG_ON(ARRAY_SIZE(olpc_boardrev_str) != OLPC_REV_UNKNOWN);
-+
-+ if (ofw("getprop", 4, 1, NULL, "model", revision, len, &propsize)) {
-+ printk(KERN_ERR "ofw: getprop call failed!\n");
-+ goto failed;
-+ }
-+ if (len < propsize) {
-+ printk(KERN_ERR "ofw: revision string is too long!\n");
-+ goto failed;
-+ }
-+
-+ for (i=0; i < ARRAY_SIZE(olpc_boardrev_str); i++) {
-+ if (strcmp(revision, olpc_boardrev_str[i]) == 0) {
-+ olpc_platform_info.boardrev = i;
-+ return;
-+ }
-+ }
-+
-+failed:
-+ strncpy(revision, "Unknown", len);
-+ olpc_platform_info.boardrev = OLPC_REV_UNKNOWN;
-+}
-+
-+static int olpc_dcon_present = -1;
-+module_param(olpc_dcon_present, int, 0444);
-+
-+/* REV_A CMOS map:
-+ * bit 440; DCON present bit
-+ */
-+
-+#define OLPC_CMOS_DCON_OFFSET (440 / 8)
-+#define OLPC_CMOS_DCON_MASK 0x01
-+
-+static int __init olpc_init(void)
-+{
-+ unsigned char *romsig;
-+ char revision[10];
-+
-+ spin_lock_init(&ec_lock);
-+
-+ romsig = ioremap(0xffffffc0, 16);
-+
-+ if (!romsig)
-+ return 0;
-+
-+ if (strncmp(romsig, "CL1 Q", 7))
-+ goto unmap;
-+ if (strncmp(romsig+6, romsig+13, 3)) {
-+ printk(KERN_INFO "OLPC BIOS signature looks invalid. Assuming not OLPC\n");
-+ goto unmap;
-+ }
-+ printk(KERN_INFO "OLPC board with OpenFirmware: %.16s\n", romsig);
-+
-+ olpc_platform_info.flags |= OLPC_F_PRESENT;
-+
-+ pm_power_off = olpc_power_off;
-+
-+ /* Get the platform revision */
-+ platform_detect(revision, sizeof(revision));
-+
-+ /* If olpc_dcon_present isn't set by the command line, then
-+ * "detect" it
-+ */
-+
-+ if (olpc_dcon_present == -1) {
-+ /* B1 and greater always has a DCON */
-+ if (olpc_platform_info.boardrev >= OLPC_REV_B1 &&
-+ olpc_platform_info.boardrev < OLPC_REV_UNKNOWN)
-+ olpc_dcon_present = 1;
-+ }
-+
-+ if (olpc_dcon_present)
-+ olpc_platform_info.flags |= OLPC_F_DCON;
-+
-+ /* Get the EC revision */
-+ ec_detect();
-+
-+ /* Check to see if the VSA exists */
-+ vsa_detect();
-+
-+ printk(KERN_INFO "OLPC board revision: %s (EC=%x)\n", revision,
-+ olpc_platform_info.ecver);
-+
-+ unmap:
-+ iounmap(romsig);
-+
-+ return 0;
-+}
-+
-+postcore_initcall(olpc_init);
-diff --git a/arch/i386/kernel/prom.c b/arch/i386/kernel/prom.c
-new file mode 100644
-index 0000000..d64bb27
---- /dev/null
-+++ b/arch/i386/kernel/prom.c
-@@ -0,0 +1,478 @@
-+/*
-+ * Procedures for creating, accessing and interpreting the device tree.
-+ *
-+ * Paul Mackerras August 1996.
-+ * Copyright (C) 1996-2005 Paul Mackerras.
-+ *
-+ * Adapted for 64bit PowerPC by Dave Engebretsen and Peter Bergner.
-+ * {engebret|bergner}@us.ibm.com
-+ *
-+ * Adapted for sparc64 by David S. Miller davem@davemloft.net
-+ *
-+ * Adapter for i386/OLPC by Andres Salomon <dilinger@debian.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.
-+ */
-+
-+#include <linux/kernel.h>
-+#include <linux/types.h>
-+#include <linux/string.h>
-+#include <linux/mm.h>
-+#include <linux/bootmem.h>
-+#include <linux/module.h>
-+#include <asm/prom.h>
-+#include <asm/ofw.h>
-+
-+/*
-+ * XXX: This is very much a stub; right now we're keeping 2 device trees
-+ * in memory (one for promfs, and one here). That will not remain
-+ * for long!
-+ */
-+
-+static struct device_node *allnodes;
-+
-+/* use when traversing tree through the allnext, child, sibling,
-+ * or parent members of struct device_node.
-+ */
-+static DEFINE_RWLOCK(devtree_lock);
-+
-+int of_device_is_compatible(const struct device_node *device,
-+ const char *compat)
-+{
-+ const char* cp;
-+ int cplen, l;
-+
-+ cp = of_get_property(device, "compatible", &cplen);
-+ if (cp == NULL)
-+ return 0;
-+ while (cplen > 0) {
-+ if (strncmp(cp, compat, strlen(compat)) == 0)
-+ return 1;
-+ l = strlen(cp) + 1;
-+ cp += l;
-+ cplen -= l;
-+ }
-+
-+ return 0;
-+}
-+EXPORT_SYMBOL(of_device_is_compatible);
-+
-+struct device_node *of_get_parent(const struct device_node *node)
-+{
-+ struct device_node *np;
-+
-+ if (!node)
-+ return NULL;
-+
-+ np = node->parent;
-+
-+ return np;
-+}
-+EXPORT_SYMBOL(of_get_parent);
-+
-+struct device_node *of_get_next_child(const struct device_node *node,
-+ struct device_node *prev)
-+{
-+ struct device_node *next;
-+
-+ next = prev ? prev->sibling : node->child;
-+ for (; next != 0; next = next->sibling) {
-+ break;
-+ }
-+
-+ return next;
-+}
-+EXPORT_SYMBOL(of_get_next_child);
-+
-+struct device_node *of_find_node_by_path(const char *path)
-+{
-+ struct device_node *np = allnodes;
-+
-+ for (; np != 0; np = np->allnext) {
-+ if (np->full_name != 0 && strcmp(np->full_name, path) == 0)
-+ break;
-+ }
-+
-+ return np;
-+}
-+EXPORT_SYMBOL(of_find_node_by_path);
-+
-+struct device_node *of_find_node_by_phandle(phandle handle)
-+{
-+ struct device_node *np;
-+
-+ for (np = allnodes; np != 0; np = np->allnext)
-+ if (np->node == handle)
-+ break;
-+
-+ return np;
-+}
-+EXPORT_SYMBOL(of_find_node_by_phandle);
-+
-+struct device_node *of_find_node_by_name(struct device_node *from,
-+ const char *name)
-+{
-+ struct device_node *np;
-+
-+ np = from ? from->allnext : allnodes;
-+ for (; np != NULL; np = np->allnext)
-+ if (np->name != NULL && strcmp(np->name, name) == 0)
-+ break;
-+
-+ return np;
-+}
-+EXPORT_SYMBOL(of_find_node_by_name);
-+
-+struct device_node *of_find_node_by_type(struct device_node *from,
-+ const char *type)
-+{
-+ struct device_node *np;
-+
-+ np = from ? from->allnext : allnodes;
-+ for (; np != 0; np = np->allnext)
-+ if (np->type != 0 && strcmp(np->type, type) == 0)
-+ break;
-+
-+ return np;
-+}
-+EXPORT_SYMBOL(of_find_node_by_type);
-+
-+struct device_node *of_find_compatible_node(struct device_node *from,
-+ const char *type, const char *compatible)
-+{
-+ struct device_node *np;
-+
-+ np = from ? from->allnext : allnodes;
-+ for (; np != 0; np = np->allnext) {
-+ if (type != NULL
-+ && !(np->type != 0 && strcmp(np->type, type) == 0))
-+ continue;
-+ if (of_device_is_compatible(np, compatible))
-+ break;
-+ }
-+
-+ return np;
-+}
-+EXPORT_SYMBOL(of_find_compatible_node);
-+
-+struct property *of_find_property(const struct device_node *np,
-+ const char *name,
-+ int *lenp)
-+{
-+ struct property *pp;
-+
-+ for (pp = np->properties; pp != 0; pp = pp->next) {
-+ if (strcasecmp(pp->name, name) == 0) {
-+ if (lenp != 0)
-+ *lenp = pp->length;
-+ break;
-+ }
-+ }
-+ return pp;
-+}
-+EXPORT_SYMBOL(of_find_property);
-+
-+/*
-+ * Find a property with a given name for a given node
-+ * and return the value.
-+ */
-+const void *of_get_property(const struct device_node *np, const char *name,
-+ int *lenp)
-+{
-+ struct property *pp = of_find_property(np,name,lenp);
-+ return pp ? pp->value : NULL;
-+}
-+EXPORT_SYMBOL(of_get_property);
-+
-+int of_getintprop_default(struct device_node *np, const char *name, int def)
-+{
-+ struct property *prop;
-+ int len;
-+
-+ prop = of_find_property(np, name, &len);
-+ if (!prop || len != 4)
-+ return def;
-+
-+ return *(int *) prop->value;
-+}
-+EXPORT_SYMBOL(of_getintprop_default);
-+
-+int of_n_addr_cells(struct device_node *np)
-+{
-+ const int* ip;
-+ do {
-+ if (np->parent)
-+ np = np->parent;
-+ ip = of_get_property(np, "#address-cells", NULL);
-+ if (ip != NULL)
-+ return *ip;
-+ } while (np->parent);
-+ /* No #address-cells property for the root node, default to 2 */
-+ return 2;
-+}
-+EXPORT_SYMBOL(of_n_addr_cells);
-+
-+int of_n_size_cells(struct device_node *np)
-+{
-+ const int* ip;
-+ do {
-+ if (np->parent)
-+ np = np->parent;
-+ ip = of_get_property(np, "#size-cells", NULL);
-+ if (ip != NULL)
-+ return *ip;
-+ } while (np->parent);
-+ /* No #size-cells property for the root node, default to 1 */
-+ return 1;
-+}
-+EXPORT_SYMBOL(of_n_size_cells);
-+
-+int of_set_property(struct device_node *dp, const char *name, void *val, int len)
-+{
-+ return -EIO;
-+}
-+EXPORT_SYMBOL(of_set_property);
-+
-+static unsigned int prom_early_allocated;
-+
-+static void * __init prom_early_alloc(unsigned long size)
-+{
-+ void *ret;
-+
-+ ret = kmalloc(size, GFP_KERNEL);
-+ if (ret != NULL)
-+ memset(ret, 0, size);
-+ else
-+ printk(KERN_ERR "ACK! couldn't allocate prom memory!\n");
-+
-+ prom_early_allocated += size;
-+
-+ return ret;
-+}
-+
-+static int is_root_node(const struct device_node *dp)
-+{
-+ if (!dp)
-+ return 0;
-+
-+ return (dp->parent == NULL);
-+}
-+
-+static char * __init build_path_component(struct device_node *dp)
-+{
-+ int pathlen;
-+ char *n, *i;
-+
-+ if (ofw("package-to-path", 3, 1, dp->node, NULL, 0, &pathlen)) {
-+ printk(KERN_ERR "PROM: unable to get path name from OFW!\n");
-+ return "ERROR";
-+ }
-+ n = prom_early_alloc(pathlen + 1);
-+ if (ofw("package-to-path", 3, 1, dp->node, n, pathlen+1, &pathlen))
-+ printk(KERN_ERR "PROM: unable to get path name from OFW\n");
-+
-+ if ((i = strrchr(n, '/')))
-+ n = ++i; /* we only want the file name */
-+ return n;
-+}
-+
-+static char * __init build_full_name(struct device_node *dp)
-+{
-+ int len, ourlen, plen;
-+ char *n;
-+
-+ plen = strlen(dp->parent->full_name);
-+ ourlen = strlen(dp->path_component_name);
-+ len = ourlen + plen + 2;
-+
-+ n = prom_early_alloc(len);
-+ strcpy(n, dp->parent->full_name);
-+ if (!is_root_node(dp->parent)) {
-+ strcpy(n + plen, "/");
-+ plen++;
-+ }
-+ strcpy(n + plen, dp->path_component_name);
-+
-+ return n;
-+}
-+
-+static struct property * __init build_one_prop(phandle node, char *prev, char *special_name, void *special_val, int special_len)
-+{
-+ static struct property *tmp = NULL;
-+ struct property *p;
-+
-+ if (tmp) {
-+ p = tmp;
-+ memset(p, 0, sizeof(*p) + 32);
-+ tmp = NULL;
-+ } else {
-+ p = prom_early_alloc(sizeof(struct property) + 32);
-+ }
-+
-+ p->name = (char *) (p + 1);
-+ if (special_name) {
-+ strcpy(p->name, special_name);
-+ p->length = special_len;
-+ p->value = prom_early_alloc(special_len);
-+ memcpy(p->value, special_val, special_len);
-+ } else {
-+ int fl;
-+ if (prev == NULL) {
-+ if (ofw("nextprop", 3, 1, node, "", p->name, &fl)) {
-+ printk(KERN_ERR "PROM: %s: nextprop failed!\n", __func__);
-+ return NULL;
-+ }
-+ } else {
-+ if (ofw("nextprop", 3, 1, node, prev, p->name, &fl)) {
-+ printk(KERN_ERR "PROM: %s: nextprop failed!\n", __func__);
-+ return NULL;
-+ }
-+ }
-+ if (strlen(p->name) == 0 || fl != 1) {
-+ tmp = p;
-+ return NULL;
-+ }
-+ if (ofw("getproplen", 2, 1, node, p->name, &p->length)) {
-+ printk(KERN_ERR "PROM: %s: getproplen failed!\n", __func__);
-+ return NULL;
-+ }
-+ if (p->length <= 0) {
-+ p->length = 0;
-+ } else {
-+ p->value = prom_early_alloc(p->length + 1);
-+ if (ofw("getprop", 4, 1, node, p->name, p->value, p->length, &p->length)) {
-+ printk(KERN_ERR "PROM: %s: getprop failed!\n", __func__);
-+ return NULL;
-+ }
-+ ((unsigned char *)p->value)[p->length] = '\0';
-+ }
-+ }
-+ return p;
-+}
-+
-+static struct property * __init build_prop_list(phandle node)
-+{
-+ struct property *head, *tail;
-+
-+ head = tail = build_one_prop(node, NULL,
-+ ".node", &node, sizeof(node));
-+
-+ tail->next = build_one_prop(node, NULL, NULL, NULL, 0);
-+ tail = tail->next;
-+ while(tail) {
-+ tail->next = build_one_prop(node, tail->name,
-+ NULL, NULL, 0);
-+ tail = tail->next;
-+ }
-+
-+ return head;
-+}
-+
-+static char * __init get_one_property(phandle node, const char *name)
-+{
-+ char *buf = "<NULL>";
-+ int len;
-+
-+ if (ofw("getproplen", 2, 1, node, name, &len)) {
-+ printk(KERN_ERR "PROM: %s: getproplen failed!\n", __func__);
-+ return NULL;
-+ }
-+ if (len > 0) {
-+ buf = prom_early_alloc(len);
-+ if (ofw("getprop", 4, 1, node, name, buf, len, &len)) {
-+ printk(KERN_ERR "PROM: %s: getprop failed!\n", __func__);
-+ return NULL;
-+ }
-+ }
-+
-+ return buf;
-+}
-+
-+static struct device_node * __init create_node(phandle node, struct device_node *parent)
-+{
-+ struct device_node *dp;
-+
-+ if (!node)
-+ return NULL;
-+
-+ dp = prom_early_alloc(sizeof(*dp));
-+ dp->parent = parent;
-+
-+ kref_init(&dp->kref);
-+
-+ dp->name = get_one_property(node, "name");
-+ dp->type = get_one_property(node, "device_type");
-+ dp->node = node;
-+
-+ dp->properties = build_prop_list(node);
-+
-+ return dp;
-+}
-+
-+static struct device_node * __init build_tree(struct device_node *parent, phandle node, struct device_node ***nextp)
-+{
-+ struct device_node *ret = NULL, *prev_sibling = NULL;
-+ struct device_node *dp;
-+ u32 child;
-+
-+ while (1) {
-+ dp = create_node(node, parent);
-+ if (!dp)
-+ break;
-+
-+ if (prev_sibling)
-+ prev_sibling->sibling = dp;
-+
-+ if (!ret)
-+ ret = dp;
-+ prev_sibling = dp;
-+
-+ *(*nextp) = dp;
-+ *nextp = &dp->allnext;
-+
-+ dp->path_component_name = build_path_component(dp);
-+ dp->full_name = build_full_name(dp);
-+
-+ if (ofw("child", 1, 1, node, &child)) {
-+ printk(KERN_ERR "PROM: %s: fetching child failed!\n", __func__);
-+ return NULL;
-+ }
-+ dp->child = build_tree(dp, child, nextp);
-+
-+ if (ofw("peer", 1, 1, node, &node)) {
-+ printk(KERN_ERR "PROM: %s: fetching peer failed!\n", __func__);
-+ return NULL;
-+ }
-+ }
-+
-+ return ret;
-+}
-+
-+static phandle root_node;
-+
-+void __init prom_build_devicetree(void)
-+{
-+ struct device_node **nextp;
-+ u32 child;
-+
-+ if (ofw("peer", 1, 1, 0, &root_node)) {
-+ printk(KERN_ERR "PROM: unable to get root node from OFW!\n");
-+ return;
-+ }
-+
-+ allnodes = create_node(root_node, NULL);
-+ allnodes->path_component_name = "";
-+ allnodes->full_name = "/";
-+
-+ nextp = &allnodes->allnext;
-+ if (ofw("child", 1, 1, allnodes->node, &child)) {
-+ printk(KERN_ERR "PROM: unable to get child node from OFW!\n");
-+ return;
-+ }
-+ allnodes->child = build_tree(allnodes, child, &nextp);
-+ printk("PROM: Built device tree with %u bytes of memory.\n",
-+ prom_early_allocated);
-+}
-diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
-index d474cd6..c4b26ba 100644
---- a/arch/i386/kernel/setup.c
-+++ b/arch/i386/kernel/setup.c
-@@ -362,8 +362,10 @@ void __init zone_sizes_init(void)
- {
- unsigned long max_zone_pfns[MAX_NR_ZONES];
- memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
-+#ifdef CONFIG_ZONE_DMA
- max_zone_pfns[ZONE_DMA] =
- virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
-+#endif
- max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
- #ifdef CONFIG_HIGHMEM
- max_zone_pfns[ZONE_HIGHMEM] = highend_pfn;
-@@ -428,6 +430,9 @@ void __init setup_bootmem_allocator(void)
- */
- acpi_reserve_bootmem();
- #endif
-+#ifdef CONFIG_OLPC_PM
-+ reserve_bootmem(0xf0000, PAGE_SIZE);
-+#endif
- #ifdef CONFIG_X86_FIND_SMP_CONFIG
- /*
- * Find and reserve possible boot-time SMP configuration:
-diff --git a/arch/i386/pci/Makefile b/arch/i386/pci/Makefile
-index 44650e0..1250a7b 100644
---- a/arch/i386/pci/Makefile
-+++ b/arch/i386/pci/Makefile
-@@ -3,6 +3,7 @@ obj-y := i386.o init.o
- obj-$(CONFIG_PCI_BIOS) += pcbios.o
- obj-$(CONFIG_PCI_MMCONFIG) += mmconfig.o direct.o mmconfig-shared.o
- obj-$(CONFIG_PCI_DIRECT) += direct.o
-+obj-$(CONFIG_PCI_OLPC) += olpc.o
-
- pci-y := fixup.o
- pci-$(CONFIG_ACPI) += acpi.o
-diff --git a/arch/i386/pci/init.c b/arch/i386/pci/init.c
-index 3de9f9b..0f5f7dd 100644
---- a/arch/i386/pci/init.c
-+++ b/arch/i386/pci/init.c
-@@ -14,6 +14,9 @@ static __init int pci_access_init(void)
- #ifdef CONFIG_PCI_MMCONFIG
- pci_mmcfg_init(type);
- #endif
-+#ifdef CONFIG_PCI_OLPC
-+ pci_olpc_init();
-+#endif
- if (raw_pci_ops)
- return 0;
- #ifdef CONFIG_PCI_BIOS
-diff --git a/arch/i386/pci/olpc.c b/arch/i386/pci/olpc.c
-new file mode 100644
-index 0000000..1518d25
---- /dev/null
-+++ b/arch/i386/pci/olpc.c
-@@ -0,0 +1,298 @@
-+/*
-+ * olpcpci.c - Low-level PCI config space access for OLPC systems
-+ * without the VSA PCI virtualization software.
-+ *
-+ * The AMD Geode chipset (GX2 processor, cs5536 I/O companion device)
-+ * has some I/O functions (display, southbridge, sound, USB HCIs, etc)
-+ * that more or less behave like PCI devices, but the hardware doesn't
-+ * directly implement the PCI configuration space headers. AMD provides
-+ * "VSA" (Virtual System Architecture) software that emulates PCI config
-+ * space for these devices, by trapping I/O accesses to PCI config register
-+ * (CF8/CFC) and running some code in System Management Mode interrupt state.
-+ * On the OLPC platform, we don't want to use that VSA code because
-+ * (a) it slows down suspend/resume, and (b) recompiling it requires special
-+ * compilers that are hard to get. So instead of letting the complex VSA
-+ * code simulate the PCI config registers for the on-chip devices, we
-+ * just simulate them the easy way, by inserting the code into the
-+ * pci_write_config and pci_read_config path. Most of the config registers
-+ * are read-only anyway, so the bulk of the simulation is just table lookup.
-+ */
-+
-+#include <linux/pci.h>
-+#include <linux/init.h>
-+#include <asm/olpc.h>
-+#include <asm/geode.h>
-+#include "pci.h"
-+
-+static int is_lx;
-+
-+/*
-+ * In the tables below, the first two line (8 longwords) are the
-+ * size masks that are used when the higher level PCI code determines
-+ * the size of the region by writing ~0 to a base address register
-+ * and reading back the result.
-+ *
-+ * The following lines are the values that are read during normal
-+ * PCI config access cycles, i.e. not after just having written
-+ * ~0 to a base address register.
-+ */
-+
-+static const u32 lxnb_hdr[] = { /* dev 1 function 0 - devfn = 8 */
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+
-+ 0x281022 , 0x2200005 , 0x6000021 , 0x80f808 , /* AMD Vendor ID */
-+ 0x0 , 0x0 , 0x0 , 0x0 , /* No virtual registers, hence no BAR for them */
-+ 0x0 , 0x0 , 0x0 , 0x28100b ,
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+};
-+
-+static const u32 gxnb_hdr[] = { /* dev 1 function 0 - devfn = 8 */
-+ 0xfffffffd , 0x0 , 0x0 , 0x0 ,
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+
-+ 0x28100b , 0x2200005 , 0x6000021 , 0x80f808 , /* NSC Vendor ID */
-+ 0xac1d , 0x0 , 0x0 , 0x0 , /* I/O BAR - base of virtual registers */
-+ 0x0 , 0x0 , 0x0 , 0x28100b ,
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+};
-+
-+static const u32 lxfb_hdr[] = { /* dev 1 function 1 - devfn = 9 */
-+ 0xff800008 , 0xffffc000 , 0xffffc000 , 0xffffc000 ,
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+
-+ 0x20811022 , 0x2200003 , 0x3000000 , 0x0 , /* AMD Vendor ID */
-+ 0xfd000000 , 0xfe000000 , 0xfe004000 , 0xfe008000 , /* FB, GP, VG, DF */
-+ 0xfe00c000 , 0x0 , 0x0 , 0x30100b , /* VIP */
-+ 0x0 , 0x0 , 0x0 , 0x10e , /* INTA, IRQ14 for graphics accel */
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+ 0x3d0 , 0x3c0 , 0xa0000 , 0x0 , /* VG IO, VG IO, EGA FB, MONO FB */
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+};
-+
-+static const u32 gxfb_hdr[] = { /* dev 1 function 1 - devfn = 9 */
-+ 0xff800008 , 0xffffc000 , 0xffffc000 , 0xffffc000 ,
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+
-+ 0x30100b , 0x2200003 , 0x3000000 , 0x0 , /* NSC Vendor ID */
-+ 0xfd000000 , 0xfe000000 , 0xfe004000 , 0xfe008000 , /* FB, GP, VG, DF */
-+ 0x0 , 0x0 , 0x0 , 0x30100b ,
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+ 0x3d0 , 0x3c0 , 0xa0000 , 0x0 , /* VG IO, VG IO, EGA FB, MONO FB */
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+};
-+
-+static const u32 aes_hdr[] = { /* dev 1 function 2 - devfn = 0xa */
-+ 0xffffc000 , 0x0 , 0x0 , 0x0 ,
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+
-+ 0x20821022 , 0x2a00006 , 0x10100000 , 0x8 , /* NSC Vendor ID */
-+ 0xfe010000 , 0x0 , 0x0 , 0x0 , /* AES registers */
-+ 0x0 , 0x0 , 0x0 , 0x20821022 ,
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+};
-+
-+
-+static const u32 isa_hdr[] = { /* dev f function 0 - devfn = 78 */
-+ 0xfffffff9 , 0xffffff01 , 0xffffffc1 , 0xffffffe1 ,
-+ 0xffffff81 , 0xffffffc1 , 0x0 , 0x0 ,
-+
-+ 0x20901022 , 0x2a00049 , 0x6010003 , 0x802000 ,
-+ 0x18b1 , 0x1001 , 0x1801 , 0x1881 , /* SMB-8 GPIO-256 MFGPT-64 IRQ-32 */
-+ 0x1401 , 0x1841 , 0x0 , 0x20901022 , /* PMS-128 ACPI-64 */
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+ 0x0 , 0x0 , 0x0 , 0xaa5b , /* interrupt steering */
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+};
-+
-+static const u32 ac97_hdr[] = { /* dev f function 3 - devfn = 7b */
-+ 0xffffff81 , 0x0 , 0x0 , 0x0 ,
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+
-+ 0x20931022 , 0x2a00041 , 0x4010001 , 0x0 ,
-+ 0x1481 , 0x0 , 0x0 , 0x0 , /* I/O BAR-128 */
-+ 0x0 , 0x0 , 0x0 , 0x20931022 ,
-+ 0x0 , 0x0 , 0x0 , 0x205 , /* IntB , IRQ5 */
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+};
-+
-+static const u32 ohci_hdr[] = { /* dev f function 4 - devfn = 7c */
-+ 0xfffff000 , 0x0 , 0x0 , 0x0 ,
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+
-+ 0x20941022 , 0x2300006 , 0xc031002 , 0x0 ,
-+ 0xfe01a000 , 0x0 , 0x0 , 0x0 , /* MEMBAR-1000 */
-+ 0x0 , 0x0 , 0x0 , 0x20941022 ,
-+ 0x0 , 0x40 , 0x0 , 0x40a , /* CapPtr INT-D, IRQ A */
-+ 0xc8020001 , 0x0 , 0x0 , 0x0 , /* Capabilities - 40 is R/O, 44 is mask 8103 (power control) */
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+};
-+
-+static const u32 ehci_hdr[] = { /* dev f function 4 - devfn = 7d */
-+ 0xfffff000 , 0x0 , 0x0 , 0x0 ,
-+ 0x0 , 0x0 , 0x0 , 0x0 ,
-+
-+ 0x20951022 , 0x2300006 , 0xc032002 , 0x0 ,
-+ 0xfe01b000 , 0x0 , 0x0 , 0x0 , /* MEMBAR-1000 */
-+ 0x0 , 0x0 , 0x0 , 0x20951022 ,
-+ 0x0 , 0x40 , 0x0 , 0x40a , /* CapPtr INT-D, IRQ A */
-+ 0xc8020001 , 0x0 , 0x0 , 0x0 , /* Capabilities - 40 is R/O, 44 is mask 8103 (power control) */
-+#if 0
-+ 0x1 , 0x40080000 , 0x0 , 0x0 , /* EECP - see section 2.1.7 of EHCI spec */
-+#endif
-+ 0x01000001 , 0x00000000 , 0x0 , 0x0 , /* EECP - see section 2.1.7 of EHCI spec */
-+ 0x2020 , 0x0 , 0x0 , 0x0 , /* (EHCI page 8) 60 SBRN (R/O), 61 FLADJ (R/W), PORTWAKECAP */
-+};
-+
-+static u32 ff_loc = ~0;
-+static u32 zero_loc = 0;
-+
-+static int bar_probing = 0; /* Set after a write of ~0 to a BAR */
-+
-+#define NB_SLOT 0x1 /* Northbridge - GX chip - Device 1 */
-+#define SB_SLOT 0xf /* Southbridge - CS5536 chip - Device F */
-+#define SIMULATED(bus, devfn) (((bus) == 0) && ((PCI_SLOT(devfn) == NB_SLOT) || (PCI_SLOT(devfn) == SB_SLOT)))
-+
-+static u32 *hdr_addr(const u32 *hdr, int reg)
-+{
-+ u32 addr;
-+
-+ /*
-+ * This is a little bit tricky. The header maps consist of
-+ * 0x20 bytes of size masks, followed by 0x70 bytes of header data.
-+ * In the normal case, when not probing a BAR's size, we want
-+ * to access the header data, so we add 0x20 to the reg offset,
-+ * thus skipping the size mask area.
-+ * In the BAR probing case, we want to access the size mask for
-+ * the BAR, so we subtract 0x10 (the config header offset for
-+ * BAR0), and don't skip the size mask area.
-+ */
-+
-+ addr = (u32)hdr + reg + (bar_probing ? -0x10 : 0x20);
-+
-+ bar_probing = 0;
-+ return (u32 *)addr;
-+}
-+
-+static int pci_olpc_read(unsigned int seg, unsigned int bus,
-+ unsigned int devfn, int reg, int len, u32 *value)
-+{
-+ u32 *addr;
-+
-+ /* Use the hardware mechanism for non-simulated devices */
-+ if (!SIMULATED(bus, devfn))
-+ return pci_conf1_read(seg, bus, devfn, reg, len, value);
-+
-+ /*
-+ * No device has config registers past 0x70, so we save table space
-+ * by not storing entries for the nonexistent registers
-+ */
-+ if (reg >= 0x70)
-+ addr = &zero_loc;
-+ else {
-+ switch (devfn) {
-+ case 0x8:
-+ addr = hdr_addr(is_lx ? lxnb_hdr : gxnb_hdr, reg);
-+ break;
-+ case 0x9:
-+ addr = hdr_addr(is_lx ? lxfb_hdr : gxfb_hdr, reg);
-+ break;
-+ case 0xa:
-+ addr = is_lx ? hdr_addr(aes_hdr, reg) : &ff_loc;
-+ break;
-+ case 0x78:
-+ addr = hdr_addr(isa_hdr, reg);
-+ break;
-+ case 0x7b:
-+ addr = hdr_addr(ac97_hdr, reg);
-+ break;
-+ case 0x7c:
-+ addr = hdr_addr(ohci_hdr, reg);
-+ break;
-+ case 0x7d:
-+ addr = hdr_addr(ehci_hdr, reg);
-+ break;
-+ default:
-+ addr = &ff_loc;
-+ break;
-+ }
-+ }
-+ switch (len) {
-+ case 1:
-+ *value = *(u8 *) addr;
-+ break;
-+ case 2:
-+ *value = *(u16 *) addr;
-+ break;
-+ case 4:
-+ *value = *addr;
-+ break;
-+ default:
-+ BUG();
-+ }
-+
-+ return 0;
-+}
-+
-+static int pci_olpc_write(unsigned int seg, unsigned int bus,
-+ unsigned int devfn, int reg, int len, u32 value)
-+{
-+ /* Use the hardware mechanism for non-simulated devices */
-+ if (!SIMULATED(bus, devfn))
-+ return pci_conf1_write(seg, bus, devfn, reg, len, value);
-+
-+ /* XXX we may want to extend this to simulate EHCI power management */
-+
-+ /*
-+ * Mostly we just discard writes, but if the write is a size probe
-+ * (i.e. writing ~0 to a BAR), we remember it and arrange to return
-+ * the appropriate size mask on the next read. This is cheating
-+ * to some extent, because it depends on the fact that the next
-+ * access after such a write will always be a read to the same BAR.
-+ */
-+
-+ if ((reg >= 0x10) && (reg < 0x2c)) {
-+ /* Write is to a BAR */
-+ if (value == ~0)
-+ bar_probing = 1;
-+ } else {
-+ /*
-+ * No warning on writes to ROM BAR, CMD, LATENCY_TIMER,
-+ * CACHE_LINE_SIZE, or PM registers.
-+ */
-+ if ((reg != 0x30) && (reg != 0x04) && (reg != 0x0d) &&
-+ (reg != 0x0c) && (reg != 0x44))
-+ printk(KERN_WARNING "OLPC PCI: Config write to devfn %x reg %x value %x\n", devfn, reg, value);
-+ }
-+
-+ return 0;
-+}
-+
-+static struct pci_raw_ops pci_olpc_conf = {
-+ .read = pci_olpc_read,
-+ .write = pci_olpc_write,
-+};
-+
-+void __init pci_olpc_init(void)
-+{
-+ if (!machine_is_olpc() || olpc_has_vsa())
-+ return;
-+
-+ printk(KERN_INFO "PCI: Using configuration type OLPC\n");
-+ raw_pci_ops = &pci_olpc_conf;
-+ is_lx = is_geode_lx();
-+}
-diff --git a/arch/i386/pci/pci.h b/arch/i386/pci/pci.h
-index 8c66f27..a67e617 100644
---- a/arch/i386/pci/pci.h
-+++ b/arch/i386/pci/pci.h
-@@ -93,6 +93,7 @@ extern void pci_direct_init(int type);
- extern void pci_pcbios_init(void);
- extern void pci_mmcfg_init(int type);
- extern void pcibios_sort(void);
-+extern void pci_olpc_init(void);
-
- /* pci-mmconfig.c */
-
-diff --git a/drivers/Makefile b/drivers/Makefile
-index f0878b2..c033d30 100644
---- a/drivers/Makefile
-+++ b/drivers/Makefile
-@@ -23,6 +23,8 @@ obj-y += char/
-
- obj-$(CONFIG_CONNECTOR) += connector/
-
-+obj-$(CONFIG_SYSPROF) += sysprof/
-+
- # i810fb and intelfb depend on char/agp/
- obj-$(CONFIG_FB_I810) += video/i810/
- obj-$(CONFIG_FB_INTEL) += video/intelfb/
-diff --git a/drivers/char/vt_ioctl.c b/drivers/char/vt_ioctl.c
-index c6f6f42..55ae42c 100644
---- a/drivers/char/vt_ioctl.c
-+++ b/drivers/char/vt_ioctl.c
-@@ -37,6 +37,9 @@
- char vt_dont_switch;
- extern struct tty_driver *console_driver;
-
-+/* Add a notifier chain to inform drivers of a VT_TEXT/VT_GRAPHICS switch */
-+RAW_NOTIFIER_HEAD(console_notifier_list);
-+
- #define VT_IS_IN_USE(i) (console_driver->ttys[i] && console_driver->ttys[i]->count)
- #define VT_BUSY(i) (VT_IS_IN_USE(i) || i == fg_console || vc_cons[i].d == sel_cons)
-
-@@ -491,6 +494,14 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
- vc->vc_mode = (unsigned char) arg;
- if (console != fg_console)
- return 0;
-+
-+ /* Notify listeners if the current fg_console has switched */
-+
-+ raw_notifier_call_chain(&console_notifier_list,
-+ (arg == KD_TEXT) ?
-+ CONSOLE_EVENT_SWITCH_TEXT :
-+ CONSOLE_EVENT_SWITCH_GRAPHICS, 0);
-+
- /*
- * explicitly blank/unblank the screen if switching modes
- */
-diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c
-index e6c4a2b..874d623 100644
---- a/drivers/i2c/busses/scx200_acb.c
-+++ b/drivers/i2c/busses/scx200_acb.c
-@@ -46,6 +46,10 @@ static int base[MAX_DEVICES] = { 0x820, 0x840 };
- module_param_array(base, int, NULL, 0);
- MODULE_PARM_DESC(base, "Base addresses for the ACCESS.bus controllers");
-
-+static unsigned int smbclk = 0x70;
-+module_param(smbclk, uint, 0);
-+MODULE_PARM_DESC(smbclk, "Specify the SMB_CLK value");
-+
- #define POLL_TIMEOUT (HZ/5)
-
- enum scx200_acb_state {
-@@ -108,6 +112,7 @@ struct scx200_acb_iface {
- #define ACBADDR (iface->base + 4)
- #define ACBCTL2 (iface->base + 5)
- #define ACBCTL2_ENABLE 0x01
-+#define ACBCTL3 (iface->base + 6)
-
- /************************************************************************/
-
-@@ -392,11 +397,13 @@ static __init int scx200_acb_probe(struct scx200_acb_iface *iface)
- {
- u8 val;
-
-- /* Disable the ACCESS.bus device and Configure the SCL
-- frequency: 16 clock cycles */
-- outb(0x70, ACBCTL2);
-+ /* Disable the ACCESS.bus device and Configure the SCL */
-+
-+ outb((smbclk & 0x7F) << 1, ACBCTL2);
-+
-+ outb((smbclk >> 7) & 0xFF, ACBCTL3);
-
-- if (inb(ACBCTL2) != 0x70) {
-+ if (inb(ACBCTL2) != ((smbclk & 0x7F) << 1)) {
- pr_debug(NAME ": ACBCTL2 readback failed\n");
- return -ENXIO;
- }
-diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
-index 41fc3d0..a15e7a9 100644
---- a/drivers/input/keyboard/atkbd.c
-+++ b/drivers/input/keyboard/atkbd.c
-@@ -63,12 +63,25 @@ static int atkbd_extra;
- module_param_named(extra, atkbd_extra, bool, 0);
- MODULE_PARM_DESC(extra, "Enable extra LEDs and keys on IBM RapidAcces, EzKey and similar keyboards");
-
-+#define ATKBD_KEY_UNKNOWN 0
-+#define ATKBD_KEY_NULL 0xFF0000FF
-+
-+#define ATKBD_SCR_1 0xFF0000FE
-+#define ATKBD_SCR_2 0xFF0000FD
-+#define ATKBD_SCR_4 0xFF0000FC
-+#define ATKBD_SCR_8 0xFF0000FB
-+#define ATKBD_SCR_CLICK 0xFF0000FA
-+#define ATKBD_SCR_LEFT 0xFF0000F9
-+#define ATKBD_SCR_RIGHT 0xFF0000F8
-+
-+#define ATKBD_SPECIAL 0xFF0000F8
-+
- /*
- * Scancode to keycode tables. These are just the default setting, and
- * are loadable via an userland utility.
- */
-
--static unsigned char atkbd_set2_keycode[512] = {
-+static unsigned int atkbd_set2_keycode[512] = {
-
- #ifdef CONFIG_KEYBOARD_ATKBD_HP_KEYCODES
-
-@@ -87,11 +100,17 @@ static unsigned char atkbd_set2_keycode[512] = {
- 82, 83, 80, 76, 77, 72, 1, 69, 87, 78, 81, 74, 55, 73, 70, 99,
-
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-- 217,100,255, 0, 97,165, 0, 0,156, 0, 0, 0, 0, 0, 0,125,
-+
-+ 217,100,ATKBD_KEY_NULL, 0, 97,165, 0, 0,
-+ 156, 0, 0, 0, 0, 0, 0,125,
-+
- 173,114, 0,113, 0, 0, 0,126,128, 0, 0,140, 0, 0, 0,127,
- 159, 0,115, 0,164, 0, 0,116,158, 0,172,166, 0, 0, 0,142,
- 157, 0, 0, 0, 0, 0, 0, 0,155, 0, 98, 0, 0,163, 0, 0,
-- 226, 0, 0, 0, 0, 0, 0, 0, 0,255, 96, 0, 0, 0,143, 0,
-+
-+ 226, 0, 0, 0, 0, 0, 0, 0,
-+ 0,ATKBD_KEY_NULL, 96, 0, 0, 0,143, 0,
-+
- 0, 0, 0, 0, 0, 0, 0, 0, 0,107, 0,105,102, 0, 0,112,
- 110,111,108,112,106,103, 0,119, 0,118,109, 0, 99,104,119, 0,
-
-@@ -150,19 +169,6 @@ static unsigned char atkbd_unxlate_table[128] = {
- #define ATKBD_RET_HANGEUL 0xf2
- #define ATKBD_RET_ERR 0xff
-
--#define ATKBD_KEY_UNKNOWN 0
--#define ATKBD_KEY_NULL 255
--
--#define ATKBD_SCR_1 254
--#define ATKBD_SCR_2 253
--#define ATKBD_SCR_4 252
--#define ATKBD_SCR_8 251
--#define ATKBD_SCR_CLICK 250
--#define ATKBD_SCR_LEFT 249
--#define ATKBD_SCR_RIGHT 248
--
--#define ATKBD_SPECIAL 248
--
- #define ATKBD_LED_EVENT_BIT 0
- #define ATKBD_REP_EVENT_BIT 1
-
-@@ -174,7 +180,7 @@ static unsigned char atkbd_unxlate_table[128] = {
- #define ATKBD_XL_HANJA 0x20
-
- static struct {
-- unsigned char keycode;
-+ unsigned int keycode;
- unsigned char set2;
- } atkbd_scroll_keys[] = {
- { ATKBD_SCR_1, 0xc5 },
-@@ -200,7 +206,7 @@ struct atkbd {
- char phys[32];
-
- unsigned short id;
-- unsigned char keycode[512];
-+ unsigned int keycode[512];
- unsigned char set;
- unsigned char translated;
- unsigned char extra;
-@@ -351,7 +357,7 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data,
- unsigned int code = data;
- int scroll = 0, hscroll = 0, click = -1, add_release_event = 0;
- int value;
-- unsigned char keycode;
-+ unsigned int keycode;
-
- #ifdef ATKBD_DEBUG
- printk(KERN_DEBUG "atkbd.c: Received %02x flags %02x\n", data, flags);
-@@ -856,9 +862,11 @@ static void atkbd_set_keycode_table(struct atkbd *atkbd)
- atkbd->keycode[i | 0x80] = atkbd_scroll_keys[j].keycode;
- }
- } else if (atkbd->set == 3) {
-- memcpy(atkbd->keycode, atkbd_set3_keycode, sizeof(atkbd->keycode));
-+ for (i = 0; i < ARRAY_SIZE(atkbd_set3_keycode); i++)
-+ atkbd->keycode[i] = atkbd_set3_keycode[i];
- } else {
-- memcpy(atkbd->keycode, atkbd_set2_keycode, sizeof(atkbd->keycode));
-+ for (i = 0; i < ARRAY_SIZE(atkbd_set2_keycode); i++)
-+ atkbd->keycode[i] = atkbd_set2_keycode[i];
-
- if (atkbd->scroll)
- for (i = 0; i < ARRAY_SIZE(atkbd_scroll_keys); i++)
-@@ -925,8 +933,8 @@ static void atkbd_set_device_attrs(struct atkbd *atkbd)
- }
-
- input_dev->keycode = atkbd->keycode;
-- input_dev->keycodesize = sizeof(unsigned char);
-- input_dev->keycodemax = ARRAY_SIZE(atkbd_set2_keycode);
-+ input_dev->keycodesize = sizeof(unsigned int);
-+ input_dev->keycodemax = ARRAY_SIZE(atkbd->keycode);
-
- for (i = 0; i < 512; i++)
- if (atkbd->keycode[i] && atkbd->keycode[i] < ATKBD_SPECIAL)
-@@ -1017,6 +1025,10 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv)
- return err;
- }
-
-+#ifdef CONFIG_OLPC
-+#include <asm/olpc.h>
-+#endif
-+
- /*
- * atkbd_reconnect() tries to restore keyboard into a sane state and is
- * most likely called on resume.
-@@ -1027,6 +1039,12 @@ static int atkbd_reconnect(struct serio *serio)
- struct atkbd *atkbd = serio_get_drvdata(serio);
- struct serio_driver *drv = serio->drv;
-
-+#ifdef CONFIG_OLPC
-+ if (olpc_rev_after(OLPC_REV_B2))
-+ if (serio->dev.power.power_state.event != PM_EVENT_ON)
-+ return 0;
-+#endif
-+
- if (!atkbd || !drv) {
- printk(KERN_DEBUG "atkbd: reconnect request, but serio is disconnected, ignoring...\n");
- return -1;
-diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig
-index 7bbea09..6febbc5 100644
---- a/drivers/input/mouse/Kconfig
-+++ b/drivers/input/mouse/Kconfig
-@@ -96,6 +96,16 @@ config MOUSE_PS2_TOUCHKIT
-
- If unsure, say N.
-
-+config MOUSE_PS2_OLPC
-+ bool "OLPC PS/2 mouse protocol extension" if EMBEDDED
-+ default n
-+ depends on MOUSE_PS2 && OLPC
-+ ---help---
-+ Say Y here if you have an OLPC PS/2 touchpad connected to
-+ your system.
-+
-+ If unsure, say N.
-+
- config MOUSE_SERIAL
- tristate "Serial mouse"
- select SERIO
-diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile
-index 9e6e363..f4654ce 100644
---- a/drivers/input/mouse/Makefile
-+++ b/drivers/input/mouse/Makefile
-@@ -24,3 +24,4 @@ psmouse-$(CONFIG_MOUSE_PS2_LOGIPS2PP) += logips2pp.o
- psmouse-$(CONFIG_MOUSE_PS2_LIFEBOOK) += lifebook.o
- psmouse-$(CONFIG_MOUSE_PS2_TRACKPOINT) += trackpoint.o
- psmouse-$(CONFIG_MOUSE_PS2_TOUCHKIT) += touchkit_ps2.o
-+psmouse-$(CONFIG_MOUSE_PS2_OLPC) += olpc.o
-diff --git a/drivers/input/mouse/olpc.c b/drivers/input/mouse/olpc.c
-new file mode 100644
-index 0000000..dc575ac
---- /dev/null
-+++ b/drivers/input/mouse/olpc.c
-@@ -0,0 +1,554 @@
-+/*
-+ * OLPC touchpad PS/2 mouse driver
-+ *
-+ * Copyright (c) 2006 One Laptop Per Child, inc.
-+ * Authors Zephaniah E. Hull and Andres Salomon <dilinger@laptop.org>
-+ *
-+ * This driver is partly based on the ALPS driver, which is:
-+ *
-+ * Copyright (c) 2003 Neil Brown <neilb@cse.unsw.edu.au>
-+ * Copyright (c) 2003-2005 Peter Osterlund <petero2@telia.com>
-+ * Copyright (c) 2004 Dmitry Torokhov <dtor@mail.ru>
-+ * Copyright (c) 2005 Vojtech Pavlik <vojtech@suse.cz>
-+ *
-+ * This program is free software; you can redistribute it and/or modify
-+ * it under the terms of the GNU General Public License version 2 as
-+ * published by the Free Software Foundation.
-+ */
-+
-+/*
-+ * The touchpad on the OLPC is fairly wide, with the entire area usable
-+ * as a tablet ("PT mode"), and the center 1/3rd also usable as a touchpad
-+ * ("GS mode").
-+ *
-+ * Earlier version of the device had simultaneous reporting; however, that
-+ * was removed. Instead, the device now reports packets in one mode, and
-+ * tells the driver when a mode switch needs to happen.
-+ */
-+
-+#include <linux/input.h>
-+#include <linux/serio.h>
-+#include <linux/libps2.h>
-+#include <linux/delay.h>
-+#include <asm/olpc.h>
-+
-+#include "psmouse.h"
-+#include "olpc.h"
-+
-+static int tpdebug;
-+module_param(tpdebug, int, 0644);
-+
-+#define OLPC_GS 1 /* The GS sensor. */
-+#define OLPC_PT 2 /* The PT sensor. */
-+
-+static struct olpc_model_info olpc_model_data[] = {
-+ { { 0x67, 0x00, 0x00 }, OLPC_GS | OLPC_PT }, /* unknown ID */
-+ { { 0x67, 0x00, 0x0a }, OLPC_GS | OLPC_PT }, /* pre-B1 */
-+ { { 0x67, 0x00, 0x14 }, OLPC_GS }, /* B1.*/
-+ { { 0x67, 0x00, 0x28 }, OLPC_GS | OLPC_PT }, /* B2 */
-+ { { 0x67, 0x00, 0x3c }, OLPC_GS | OLPC_PT }, /* B2-2 */
-+ { { 0x67, 0x00, 0x50 }, OLPC_GS | OLPC_PT }, /* C1 */
-+};
-+
-+#define OLPC_PKT_PT 0xcf
-+#define OLPC_PKT_GS 0xff
-+
-+static int olpc_absolute_mode(struct psmouse *psmouse, int mode);
-+
-+/*
-+ * OLPC absolute Mode - single-mode format
-+ *
-+ * byte 0: 1 1 0 0 1 1 1 1
-+ * byte 1: 0 x6 x5 x4 x3 x2 x1 x0
-+ * byte 2(PT): 0 0 x9 x8 x7 ? pt-dsw gs-dsw
-+ * byte 2(GS): 0 x10 x9 x8 x7 ? gs-dsw pt-dsw
-+ * byte 3: 0 y9 y8 y7 1 0 swr swl
-+ * byte 4: 0 y6 y5 y4 y3 y2 y1 y0
-+ * byte 5: 0 z6 z5 z4 z3 z2 z1 z0
-+ *
-+ * ?'s are not defined in the protocol spec, may vary between models.
-+ *
-+ * swr/swl are the left/right buttons.
-+ *
-+ * pt-dsw/gs-dsw indicate that the pt/gs sensor is detecting a
-+ * pen/finger
-+ */
-+
-+static void olpc_process_packet_gspt(struct psmouse *psmouse)
-+{
-+ struct olpc_data *priv = psmouse->private;
-+ unsigned char *packet = psmouse->packet;
-+ struct input_dev *dev = psmouse->dev;
-+ struct input_dev *dev2 = priv->dev2;
-+ int x, y, z, gs_down = 0, pt_down = 0, left, right;
-+ struct timeval now_tv;
-+ s64 now_ns;
-+
-+ left = packet[3] & 1;
-+ right = packet[3] & 2;
-+ x = packet[1] | ((packet[2] & 0x78) << 4);
-+ y = packet[4] | ((packet[3] & 0x70) << 3);
-+ z = packet[5];
-+
-+ if (psmouse->packet[0] == OLPC_PKT_GS) {
-+ pt_down = !!(packet[2] & 1);
-+ gs_down = !!(packet[2] & 2);
-+ } else if (psmouse->packet[0] == OLPC_PKT_PT) {
-+ gs_down = !!(packet[2] & 1);
-+ pt_down = !!(packet[2] & 2);
-+ }
-+
-+ /*
-+ * XXX: Kludge.
-+ * If it's been more than 30ms since the last packet,
-+ * assume that there was a lift we were never told about.
-+ */
-+ do_gettimeofday(&now_tv);
-+ now_ns = timeval_to_ns (&now_tv);
-+ if (now_ns >= priv->late) {
-+ input_report_key(dev, BTN_TOUCH, 0);
-+ input_report_key(dev, BTN_TOOL_PEN, 0);
-+ input_report_key(dev2, BTN_TOUCH, 0);
-+ input_report_key(dev2, BTN_TOOL_FINGER, 0);
-+
-+ input_sync(dev);
-+ input_sync(dev2);
-+ }
-+
-+ priv->late = now_ns + (30 * NSEC_PER_MSEC);
-+
-+
-+ if (tpdebug) {
-+ printk(KERN_DEBUG "%s %02x %02x %02x %02x %02x %02x\n",
-+ __FUNCTION__, psmouse->packet[0], psmouse->packet[1],
-+ psmouse->packet[2], psmouse->packet[3], psmouse->packet[4],
-+ psmouse->packet[5]);
-+ printk(KERN_DEBUG "l=%d r=%d p=%d g=%d x=%d y=%d z=%d\n",
-+ left, right, pt_down, gs_down, x, y, z);
-+ }
-+
-+ if (psmouse->packet[0] == OLPC_PKT_PT) {
-+ input_report_key(dev, BTN_LEFT, left);
-+ input_report_key(dev, BTN_RIGHT, right);
-+ } else if (psmouse->packet[0] == OLPC_PKT_GS) {
-+ input_report_key(dev, BTN_LEFT, left);
-+ input_report_key(dev, BTN_RIGHT, right);
-+ input_report_key(dev2, BTN_LEFT, left);
-+ input_report_key(dev2, BTN_RIGHT, right);
-+ }
-+
-+ input_report_key(dev, BTN_TOUCH, pt_down);
-+ input_report_key(dev, BTN_TOOL_PEN, pt_down);
-+ input_report_key(dev2, BTN_TOUCH, gs_down);
-+ input_report_key(dev2, BTN_TOOL_FINGER, gs_down);
-+
-+ input_report_abs(dev2, ABS_PRESSURE, z);
-+
-+ if (psmouse->packet[0] == OLPC_PKT_PT && pt_down) {
-+ input_report_abs(dev, ABS_X, x);
-+ input_report_abs(dev, ABS_Y, y);
-+ } else if (psmouse->packet[0] == OLPC_PKT_GS && gs_down) {
-+ input_report_abs(dev2, ABS_X, x);
-+ input_report_abs(dev2, ABS_Y, y);
-+ }
-+
-+ input_sync(dev);
-+ input_sync(dev2);
-+
-+ if (priv->pending_mode == OLPC_GS &&
-+ psmouse->packet[0] == OLPC_PKT_PT && pt_down) {
-+ priv->pending_mode = 0;
-+ cancel_delayed_work(&priv->mode_switch);
-+ }
-+
-+ if (priv->i->flags & (OLPC_PT|OLPC_GS)) {
-+ int pending = 0;
-+ if (psmouse->packet[0] == OLPC_PKT_PT && !pt_down)
-+ pending = OLPC_GS;
-+ else if (psmouse->packet[0] == OLPC_PKT_GS && pt_down)
-+ pending = OLPC_PT;
-+
-+ if (priv->current_mode == pending) {
-+ priv->pending_mode = 0;
-+ pending = priv->current_mode;
-+ }
-+ else if (priv->pending_mode != pending) {
-+ priv->pending_mode = pending;
-+ if (tpdebug)
-+ printk(KERN_WARNING "Scheduling mode switch to %s.\n",
-+ pending == OLPC_GS ? "GS" : "PT");
-+
-+ /*
-+ * Apply a de-bounce when switching from PT to GS, to allow for
-+ * spurious PT-up packets.
-+ */
-+ if (priv->pending_mode == OLPC_GS)
-+ queue_delayed_work(kpsmoused_wq, &priv->mode_switch, msecs_to_jiffies(50));
-+ else
-+ queue_delayed_work(kpsmoused_wq, &priv->mode_switch, 0);
-+ }
-+ }
-+}
-+
-+static psmouse_ret_t olpc_process_byte(struct psmouse *psmouse)
-+{
-+ psmouse_ret_t ret = PSMOUSE_BAD_DATA;
-+
-+ if (psmouse->packet[0] != OLPC_PKT_PT &&
-+ psmouse->packet[0] != OLPC_PKT_GS)
-+ goto out;
-+
-+ /* Bytes 2 - 6 should have 0 in the highest bit */
-+ if (psmouse->pktcnt >= 2 && psmouse->pktcnt <= 6 &&
-+ (psmouse->packet[psmouse->pktcnt - 1] & 0x80))
-+ goto out;
-+
-+ if (psmouse->pktcnt == 6) {
-+ olpc_process_packet_gspt(psmouse);
-+ ret = PSMOUSE_FULL_PACKET;
-+ goto out;
-+ }
-+
-+ ret = PSMOUSE_GOOD_DATA;
-+out:
-+ if (ret != PSMOUSE_GOOD_DATA && ret != PSMOUSE_FULL_PACKET)
-+ printk(KERN_DEBUG "%s: (%d) %02x %02x %02x %02x %02x %02x\n",
-+ __FUNCTION__, psmouse->pktcnt, psmouse->packet[0],
-+ psmouse->packet[1], psmouse->packet[2],
-+ psmouse->packet[3], psmouse->packet[4],
-+ psmouse->packet[5]);
-+ return ret;
-+}
-+
-+static struct olpc_model_info *olpc_get_model(struct psmouse *psmouse)
-+{
-+ struct ps2dev *ps2dev = &psmouse->ps2dev;
-+ unsigned char param[4];
-+ int i;
-+
-+ /*
-+ * Now try "E7 report". Allowed responses are in
-+ * olpc_model_data[].signature
-+ */
-+ if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) ||
-+ ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) ||
-+ ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21))
-+ return NULL;
-+
-+ param[0] = param[1] = param[2] = 0xff;
-+ if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO))
-+ return NULL;
-+
-+ pr_debug("olpc.c(%d): E7 report: %2.2x %2.2x %2.2x",
-+ __LINE__, param[0], param[1], param[2]);
-+
-+ for (i = 0; i < ARRAY_SIZE(olpc_model_data); i++) {
-+ if (!memcmp(param, olpc_model_data[i].signature,
-+ sizeof(olpc_model_data[i].signature))) {
-+ printk(KERN_INFO __FILE__ ": OLPC touchpad revision 0x%x.\n", param[2]);
-+ return olpc_model_data + i;
-+ }
-+ }
-+
-+ /*
-+ * ALPS creates new IDs pretty frequently; rather than listing them
-+ * all, just assume they support the defaults. We've set aside the
-+ * first entry of olpc_model_data as the catch-all.
-+ */
-+ if (!memcmp(param, olpc_model_data[0].signature, 2)) {
-+ printk(KERN_INFO __FILE__ ": unknown ALPS revision %x, assuming default flags.\n", param[2]);
-+ return &olpc_model_data[0];
-+ }
-+
-+ return NULL;
-+}
-+
-+static int olpc_find_mode(struct psmouse *psmouse)
-+{
-+ struct olpc_data *priv = psmouse->private;
-+ int mode = priv->i->flags;
-+
-+ if (mode & OLPC_GS)
-+ mode = OLPC_GS;
-+ else if (mode & OLPC_PT)
-+ mode = OLPC_PT;
-+ else
-+ mode = -1;
-+
-+ return mode;
-+}
-+
-+/*
-+ * Touchpad should be disabled before calling this!
-+ */
-+static int olpc_new_mode(struct psmouse *psmouse, int mode)
-+{
-+ struct ps2dev *ps2dev = &psmouse->ps2dev;
-+ struct olpc_data *priv = psmouse->private;
-+ unsigned char param;
-+ int ret;
-+
-+ if (tpdebug)
-+ printk(KERN_WARNING __FILE__ ": Switching to %d. [%lu]\n", mode, jiffies);
-+
-+ if ((ret = ps2_command(ps2dev, ¶m, 0x01F2)))
-+ goto failed;
-+ if ((ret = ps2_command(ps2dev, ¶m, 0x01F2)))
-+ goto failed;
-+ if ((ret = ps2_command(ps2dev, ¶m, 0x01F2)))
-+ goto failed;
-+
-+ switch (mode) {
-+ default:
-+ printk(KERN_WARNING __FILE__ ": Invalid mode %d. Defaulting to OLPC_GS.\n", mode);
-+ case OLPC_GS:
-+ ret = ps2_command(ps2dev, NULL, 0xE6);
-+ break;
-+ case OLPC_PT:
-+ ret = ps2_command(ps2dev, NULL, 0xE7);
-+ break;
-+ }
-+ if (ret)
-+ goto failed;
-+
-+ /* XXX: This is a bit hacky, make sure this isn't screwing stuff up. */
-+ psmouse->pktcnt = psmouse->out_of_sync = 0;
-+ psmouse->last = jiffies;
-+ psmouse->state = PSMOUSE_ACTIVATED;
-+
-+ if ((ret = ps2_command(ps2dev, NULL, PSMOUSE_CMD_ENABLE)))
-+ goto failed;
-+
-+ priv->current_mode = mode;
-+ priv->pending_mode = 0;
-+ if (tpdebug)
-+ printk(KERN_WARNING __FILE__ ": Switched to mode %d successful.\n", mode);
-+
-+failed:
-+ if (ret)
-+ printk(KERN_WARNING __FILE__ ": Mode switch to %d failed! (%d) [%lu]\n", mode, ret, jiffies);
-+ return ret;
-+}
-+
-+static int olpc_absolute_mode(struct psmouse *psmouse, int mode)
-+{
-+ struct ps2dev *ps2dev = &psmouse->ps2dev;
-+
-+ /* Switch to 'Advanced mode.', four disables in a row. */
-+ if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) ||
-+ ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) ||
-+ ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) ||
-+ ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE))
-+ return -1;
-+
-+ return olpc_new_mode(psmouse, mode);
-+}
-+
-+/*
-+ * olpc_poll() - poll the touchpad for current motion packet.
-+ * Used in resync.
-+ * Note: We can't poll, so always return failure.
-+ */
-+static int olpc_poll(struct psmouse *psmouse)
-+{
-+ return -1;
-+}
-+
-+static int olpc_reconnect(struct psmouse *psmouse)
-+{
-+ struct olpc_data *priv = psmouse->private;
-+ int mode;
-+
-+ if (olpc_rev_after(OLPC_REV_B2))
-+ if (psmouse->ps2dev.serio->dev.power.power_state.event != PM_EVENT_ON)
-+ return 0;
-+
-+ psmouse_reset(psmouse);
-+
-+ if (!(priv->i = olpc_get_model(psmouse)))
-+ return -1;
-+
-+ mode = olpc_find_mode(psmouse);
-+ if (mode < 0)
-+ return -1;
-+
-+ if (olpc_absolute_mode(psmouse, mode)) {
-+ printk(KERN_ERR __FILE__ ": Failed to reenable absolute mode.\n");
-+ return -1;
-+ }
-+
-+ return 0;
-+}
-+
-+static void olpc_disconnect(struct psmouse *psmouse)
-+{
-+ struct olpc_data *priv = psmouse->private;
-+
-+ psmouse_reset(psmouse);
-+ input_unregister_device(priv->dev2);
-+ kfree(priv);
-+}
-+
-+static void olpc_mode_switch(struct work_struct *w)
-+{
-+ struct delayed_work *work = container_of(w, struct delayed_work, work);
-+ struct olpc_data *priv = container_of(work, struct olpc_data, mode_switch);
-+ struct psmouse *psmouse = priv->psmouse;
-+ struct ps2dev *ps2dev = &psmouse->ps2dev;
-+ int pending_mode, ret;
-+
-+ if (priv->pending_mode == priv->current_mode) {
-+ priv->pending_mode = 0;
-+ printk (KERN_DEBUG __FILE__ ": In switch_mode, no target mode.\n");
-+ return;
-+ }
-+
-+ if (tpdebug)
-+ printk(KERN_WARNING __FILE__ ": Disable for switch to %d. [%lu]\n", priv->pending_mode, jiffies);
-+
-+ /* XXX: This is a bit hacky, make sure this isn't screwing stuff up. */
-+ psmouse->state = PSMOUSE_INITIALIZING;
-+
-+ ret = ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE);
-+ if (ret) {
-+ /* XXX: if this ever fails, we need to do a full reset! */
-+ printk(KERN_WARNING __FILE__ ": Disable failed for switch to %d. (%d) [%lu]\n", priv->pending_mode, ret, jiffies);
-+ return;
-+ }
-+
-+ /*
-+ * ALPS tells us that it may take up to 20msec for the disable to
-+ * take effect; however, ps2_command() will wait up to 200msec for
-+ * the ACK to come back (and I'm assuming that by the time the
-+ * hardware sends back its ACK, it has stopped sending bytes).
-+ */
-+ pending_mode = priv->pending_mode;
-+
-+ if (olpc_new_mode(psmouse, priv->pending_mode))
-+ goto bad;
-+
-+ /*
-+ * Deal with a potential race condition.
-+ *
-+ * If there is a brief tap of a stylus or a fingernail that
-+ * triggers a mode switch to PT mode, and the stylus/fingernail is
-+ * lifted after the DISABLE above, but before we reenable in the new mode,
-+ * then we can get stuck in PT mode.
-+ */
-+ if (pending_mode == OLPC_PT) {
-+ priv->pending_mode = OLPC_GS;
-+ queue_delayed_work(kpsmoused_wq, &priv->mode_switch, msecs_to_jiffies(50));
-+ }
-+
-+ return;
-+
-+bad:
-+ printk(KERN_WARNING __FILE__ ": Failure to switch modes, resetting device...\n");
-+ olpc_reconnect(psmouse);
-+}
-+
-+int olpc_init(struct psmouse *psmouse)
-+{
-+ struct olpc_data *priv;
-+ struct input_dev *dev = psmouse->dev;
-+ struct input_dev *dev2;
-+ int mode;
-+
-+ priv = kzalloc(sizeof(struct olpc_data), GFP_KERNEL);
-+ dev2 = input_allocate_device();
-+ if (!priv || !dev2)
-+ goto init_fail;
-+
-+ psmouse->private = priv;
-+ priv->dev2 = dev2;
-+ priv->psmouse = psmouse;
-+
-+ psmouse_reset(psmouse);
-+ if (!(priv->i = olpc_get_model(psmouse)))
-+ goto init_fail;
-+
-+ mode = olpc_find_mode(psmouse);
-+ if (mode < 0) {
-+ printk(KERN_ERR __FILE__ ": Failed to identify proper mode\n");
-+ goto init_fail;
-+ }
-+
-+ if (olpc_absolute_mode(psmouse, mode)) {
-+ printk(KERN_ERR __FILE__ ": Failed to enable absolute mode\n");
-+ goto init_fail;
-+ }
-+
-+ /*
-+ * Unset some of the default bits for things we don't have.
-+ */
-+ dev->evbit[LONG(EV_REL)] &= ~BIT(EV_REL);
-+ dev->relbit[LONG(REL_X)] &= ~(BIT(REL_X) | BIT(REL_Y));
-+ dev->keybit[LONG(BTN_MIDDLE)] &= ~BIT(BTN_MIDDLE);
-+
-+ dev->evbit[LONG(EV_KEY)] |= BIT(EV_KEY);
-+ dev->keybit[LONG(BTN_TOUCH)] |= BIT(BTN_TOUCH);
-+ dev->keybit[LONG(BTN_TOOL_PEN)] |= BIT(BTN_TOOL_PEN);
-+ dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT);
-+
-+ dev->evbit[LONG(EV_ABS)] |= BIT(EV_ABS);
-+ input_set_abs_params(dev, ABS_X, 2, 1000, 0, 0);
-+ input_set_abs_params(dev, ABS_Y, 0, 717, 0, 0);
-+
-+ snprintf(priv->phys, sizeof(priv->phys),
-+ "%s/input1", psmouse->ps2dev.serio->phys);
-+ dev2->phys = priv->phys;
-+ dev2->name = "OLPC ALPS GlideSensor";
-+ dev2->id.bustype = BUS_I8042;
-+ dev2->id.vendor = 0x0002;
-+ dev2->id.product = PSMOUSE_OLPC;
-+ dev2->id.version = 0x0000;
-+
-+ dev2->evbit[LONG(EV_KEY)] |= BIT(EV_KEY);
-+ dev2->keybit[LONG(BTN_TOUCH)] |= BIT(BTN_TOUCH);
-+ dev2->keybit[LONG(BTN_TOOL_FINGER)] |= BIT(BTN_TOOL_FINGER);
-+ dev2->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT);
-+
-+ dev2->evbit[LONG(EV_ABS)] |= BIT(EV_ABS);
-+ input_set_abs_params(dev2, ABS_X, 350, 512, 0, 0);
-+ input_set_abs_params(dev2, ABS_Y, 70, 325, 0, 0);
-+ input_set_abs_params(dev2, ABS_PRESSURE, 0, 63, 0, 0);
-+
-+ if (input_register_device(dev2)) {
-+ printk(KERN_ERR __FILE__ ": Failed to register GlideSensor\n");
-+ goto init_fail;
-+ }
-+
-+ psmouse->protocol_handler = olpc_process_byte;
-+ psmouse->poll = olpc_poll;
-+ psmouse->disconnect = olpc_disconnect;
-+ psmouse->reconnect = olpc_reconnect;
-+ psmouse->pktsize = 6;
-+
-+ /* Disable the idle resync. */
-+ psmouse->resync_time = 0;
-+ /* Reset after a lot of bad bytes. */
-+ psmouse->resetafter = 1024;
-+
-+ INIT_DELAYED_WORK(&priv->mode_switch, olpc_mode_switch);
-+
-+ return 0;
-+
-+init_fail:
-+ input_free_device(dev2);
-+ kfree(priv);
-+ return -1;
-+}
-+
-+int olpc_detect(struct psmouse *psmouse, int set_properties)
-+{
-+ if (!olpc_get_model(psmouse))
-+ return -1;
-+
-+ if (set_properties) {
-+ psmouse->vendor = "ALPS";
-+ psmouse->name = "PenTablet";
-+ psmouse->model = 0;
-+ }
-+ return 0;
-+}
-+
-diff --git a/drivers/input/mouse/olpc.h b/drivers/input/mouse/olpc.h
-new file mode 100644
-index 0000000..426f8b4
---- /dev/null
-+++ b/drivers/input/mouse/olpc.h
-@@ -0,0 +1,49 @@
-+/*
-+ * OLPC touchpad PS/2 mouse driver
-+ *
-+ * Copyright (c) 2006 One Laptop Per Child, inc.
-+ *
-+ * This driver is partly based on the ALPS driver.
-+ * Copyright (c) 2003 Peter Osterlund <petero2@telia.com>
-+ * Copyright (c) 2005 Vojtech Pavlik <vojtech@suse.cz>
-+ *
-+ * This program is free software; you can redistribute it and/or modify it
-+ * under the terms of the GNU General Public License version 2 as published by
-+ * the Free Software Foundation.
-+ */
-+
-+#ifndef _OLPC_H
-+#define _OLPC_H
-+
-+struct olpc_model_info {
-+ unsigned char signature[3];
-+ unsigned char flags;
-+};
-+
-+struct olpc_data {
-+ struct input_dev *dev2; /* Relative device */
-+ struct psmouse *psmouse;
-+ char name[32]; /* Name */
-+ char phys[32]; /* Phys */
-+ struct olpc_model_info *i; /* Info */
-+ int pending_mode;
-+ int current_mode;
-+ s64 late;
-+ struct delayed_work mode_switch;
-+};
-+
-+#ifdef CONFIG_MOUSE_PS2_OLPC
-+int olpc_detect(struct psmouse *psmouse, int set_properties);
-+int olpc_init(struct psmouse *psmouse);
-+#else
-+inline int olpc_detect(struct psmouse *psmouse, int set_properties)
-+{
-+ return -ENOSYS;
-+}
-+inline int olpc_init(struct psmouse *psmouse)
-+{
-+ return -ENOSYS;
-+}
-+#endif
-+
-+#endif
-diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
-index b9f0fb2..edcdb68 100644
---- a/drivers/input/mouse/psmouse-base.c
-+++ b/drivers/input/mouse/psmouse-base.c
-@@ -26,6 +26,7 @@
- #include "synaptics.h"
- #include "logips2pp.h"
- #include "alps.h"
-+#include "olpc.h"
- #include "lifebook.h"
- #include "trackpoint.h"
- #include "touchkit_ps2.h"
-@@ -103,7 +104,7 @@ static struct attribute_group psmouse_attribute_group = {
- */
- static DEFINE_MUTEX(psmouse_mutex);
-
--static struct workqueue_struct *kpsmoused_wq;
-+struct workqueue_struct *kpsmoused_wq;
-
- struct psmouse_protocol {
- enum psmouse_type type;
-@@ -320,7 +321,7 @@ static irqreturn_t psmouse_interrupt(struct serio *serio,
- goto out;
- }
-
-- if (psmouse->packet[1] == PSMOUSE_RET_ID) {
-+ if (psmouse->packet[1] == PSMOUSE_RET_ID || psmouse->packet[1] == PSMOUSE_RET_BAT) {
- __psmouse_set_state(psmouse, PSMOUSE_IGNORE);
- serio_reconnect(serio);
- goto out;
-@@ -631,8 +632,21 @@ static int psmouse_extensions(struct psmouse *psmouse,
- }
- }
-
-+/*
-+ * Try OLPC touchpad.
-+ */
- if (max_proto > PSMOUSE_IMEX) {
-+ if (olpc_detect(psmouse, set_properties) == 0) {
-+ if (!set_properties || olpc_init(psmouse) == 0)
-+ return PSMOUSE_OLPC;
-+/*
-+ * Init failed, try basic relative protocols
-+ */
-+ max_proto = PSMOUSE_IMEX;
-+ }
-+ }
-
-+ if (max_proto > PSMOUSE_IMEX) {
- if (genius_detect(psmouse, set_properties) == 0)
- return PSMOUSE_GENPS;
-
-@@ -762,6 +776,14 @@ static const struct psmouse_protocol psmouse_protocols[] = {
- .detect = touchkit_ps2_detect,
- },
- #endif
-+#ifdef CONFIG_MOUSE_PS2_OLPC
-+ {
-+ .type = PSMOUSE_OLPC,
-+ .name = "OLPC",
-+ .alias = "olpc",
-+ .detect = olpc_detect,
-+ },
-+#endif
- {
- .type = PSMOUSE_CORTRON,
- .name = "CortronPS/2",
-diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
-index 1317bdd..c4857df 100644
---- a/drivers/input/mouse/psmouse.h
-+++ b/drivers/input/mouse/psmouse.h
-@@ -89,6 +89,7 @@ enum psmouse_type {
- PSMOUSE_TRACKPOINT,
- PSMOUSE_TOUCHKIT_PS2,
- PSMOUSE_CORTRON,
-+ PSMOUSE_OLPC,
- PSMOUSE_AUTO /* This one should always be last */
- };
-
-@@ -96,6 +97,7 @@ int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command);
- int psmouse_reset(struct psmouse *psmouse);
- void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution);
-
-+extern struct workqueue_struct *kpsmoused_wq;
-
- struct psmouse_attribute {
- struct device_attribute dattr;
-diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
-index c2eea27..3510726 100644
---- a/drivers/input/serio/i8042.c
-+++ b/drivers/input/serio/i8042.c
-@@ -868,6 +868,11 @@ static long i8042_panic_blink(long count)
- #undef DELAY
-
- #ifdef CONFIG_PM
-+
-+#ifdef CONFIG_OLPC
-+#include <asm/olpc.h>
-+#endif
-+
- /*
- * Here we try to restore the original BIOS settings. We only want to
- * do that once, when we really suspend, not when we taking memory
-@@ -878,8 +883,15 @@ static long i8042_panic_blink(long count)
- static int i8042_suspend(struct platform_device *dev, pm_message_t state)
- {
- if (dev->dev.power.power_state.event != state.event) {
-+#ifdef CONFIG_OLPC
-+ /* Anything newer than B2 remains powered; no reset needed */
-+ if (olpc_rev_before(OLPC_REV_PRE_B3)) {
-+#endif
- if (state.event == PM_EVENT_SUSPEND)
- i8042_controller_reset();
-+#ifdef CONFIG_OLPC
-+ }
-+#endif
-
- dev->dev.power.power_state = state;
- }
-@@ -902,9 +914,15 @@ static int i8042_resume(struct platform_device *dev)
- if (dev->dev.power.power_state.event == PM_EVENT_ON)
- return 0;
-
-+#ifdef CONFIG_OLPC
-+ if (olpc_rev_before(OLPC_REV_PRE_B3)) {
-+#endif
- error = i8042_controller_check();
- if (error)
- return error;
-+#ifdef CONFIG_OLPC
-+ }
-+#endif
-
- error = i8042_controller_selftest();
- if (error)
-diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
-index 372ca49..c9e5308 100644
---- a/drivers/input/serio/serio.c
-+++ b/drivers/input/serio/serio.c
-@@ -916,11 +916,22 @@ static int serio_uevent(struct device *dev, char **envp, int num_envp, char *buf
- #endif /* CONFIG_HOTPLUG */
-
- #ifdef CONFIG_PM
-+
-+#ifdef CONFIG_OLPC
-+#include <asm/olpc.h>
-+#endif
-+
- static int serio_suspend(struct device *dev, pm_message_t state)
- {
- if (dev->power.power_state.event != state.event) {
-+#ifdef CONFIG_OLPC
-+ if (olpc_rev_before(OLPC_REV_PRE_B3)) {
-+#endif
- if (state.event == PM_EVENT_SUSPEND)
- serio_cleanup(to_serio_port(dev));
-+#ifdef CONFIG_OLPC
-+ }
-+#endif
-
- dev->power.power_state = state;
- }
-diff --git a/drivers/media/video/cafe_ccic.c b/drivers/media/video/cafe_ccic.c
-index ef53618..47881d2 100644
---- a/drivers/media/video/cafe_ccic.c
-+++ b/drivers/media/video/cafe_ccic.c
-@@ -63,13 +63,13 @@ MODULE_SUPPORTED_DEVICE("Video");
- */
-
- #define MAX_DMA_BUFS 3
--static int alloc_bufs_at_load = 0;
--module_param(alloc_bufs_at_load, bool, 0444);
--MODULE_PARM_DESC(alloc_bufs_at_load,
-- "Non-zero value causes DMA buffers to be allocated at module "
-- "load time. This increases the chances of successfully getting "
-- "those buffers, but at the cost of nailing down the memory from "
-- "the outset.");
-+static int alloc_bufs_at_read = 0;
-+module_param(alloc_bufs_at_read, bool, 0444);
-+MODULE_PARM_DESC(alloc_bufs_at_read,
-+ "Non-zero value causes DMA buffers to be allocated when the "
-+ "video capture device is read, rather than at module load "
-+ "time. This saves memory, but decreases the chances of "
-+ "successfully getting those buffers.");
-
- static int n_dma_bufs = 3;
- module_param(n_dma_bufs, uint, 0644);
-@@ -370,6 +370,10 @@ static int cafe_smbus_write_data(struct cafe_camera *cam,
- rval = value | ((command << TWSIC1_ADDR_SHIFT) & TWSIC1_ADDR);
- cafe_reg_write(cam, REG_TWSIC1, rval);
- spin_unlock_irqrestore(&cam->dev_lock, flags);
-+ mdelay(2); /* It'll probably take about 900µs anyway, and the
-+ CAFÉ is apparently quite sensitive to being poked
-+ at this point. If we can work out precisely what's
-+ going on and reduce this delay, it would be nice. */
-
- /*
- * Time to wait for the write to complete. THIS IS A RACY
-@@ -1503,7 +1507,7 @@ static int cafe_v4l_release(struct inode *inode, struct file *filp)
- }
- if (cam->users == 0) {
- cafe_ctlr_power_down(cam);
-- if (! alloc_bufs_at_load)
-+ if (alloc_bufs_at_read)
- cafe_free_dma_bufs(cam);
- }
- mutex_unlock(&cam->s_mutex);
-@@ -2162,7 +2166,7 @@ static int cafe_pci_probe(struct pci_dev *pdev,
- /*
- * If so requested, try to get our DMA buffers now.
- */
-- if (alloc_bufs_at_load) {
-+ if (!alloc_bufs_at_read) {
- if (cafe_alloc_dma_bufs(cam, 1))
- cam_warn(cam, "Unable to alloc DMA buffers at load"
- " will try again later.");
-diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
-index 73e248f..f7afde3 100644
---- a/drivers/misc/Kconfig
-+++ b/drivers/misc/Kconfig
-@@ -202,5 +202,10 @@ config THINKPAD_ACPI_BAY
-
- If you are not sure, say Y here.
-
-+config EEPROM_93CX6
-+ tristate "EEPROM 93CX6 support"
-+ ---help---
-+ This is a driver for the EEPROM chipsets 93c46 and 93c66.
-+ The driver supports both read as well as write commands.
-
- endif # MISC_DEVICES
-diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
-index 93fe2e5..e17eb8e 100644
---- a/drivers/mmc/card/block.c
-+++ b/drivers/mmc/card/block.c
-@@ -229,6 +229,11 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
- if (brq.data.blocks > card->host->max_blk_count)
- brq.data.blocks = card->host->max_blk_count;
-
-+ if (mmc_card_sd(card) && !card->host->ios.clock) {
-+ printk(KERN_ERR "%s: I/O to stopped card\n",
-+ req->rq_disk->disk_name);
-+ goto cmd_err;
-+ }
- mmc_set_data_timeout(&brq.data, card, rq_data_dir(req) != READ);
-
- /*
-diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
-index 20a7d89..9abbb58 100644
---- a/drivers/mmc/host/sdhci.c
-+++ b/drivers/mmc/host/sdhci.c
-@@ -411,6 +411,12 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data)
- break;
- }
-
-+ /*
-+ * There's an off-by-one error in the hw that we need to
-+ * compensate for.
-+ */
-+ count++;
-+
- if (count >= 0xF) {
- printk(KERN_WARNING "%s: Too large timeout requested!\n",
- mmc_hostname(host->mmc));
-@@ -676,19 +682,17 @@ static void sdhci_set_power(struct sdhci_host *host, unsigned short power)
- if (!(host->chip->quirks & SDHCI_QUIRK_SINGLE_POWER_WRITE))
- writeb(0, host->ioaddr + SDHCI_POWER_CONTROL);
-
-- pwr = SDHCI_POWER_ON;
--
- switch (1 << power) {
- case MMC_VDD_165_195:
-- pwr |= SDHCI_POWER_180;
-+ pwr = SDHCI_POWER_180;
- break;
- case MMC_VDD_29_30:
- case MMC_VDD_30_31:
-- pwr |= SDHCI_POWER_300;
-+ pwr = SDHCI_POWER_300;
- break;
- case MMC_VDD_32_33:
- case MMC_VDD_33_34:
-- pwr |= SDHCI_POWER_330;
-+ pwr = SDHCI_POWER_330;
- break;
- default:
- BUG();
-@@ -696,6 +700,10 @@ static void sdhci_set_power(struct sdhci_host *host, unsigned short power)
-
- writeb(pwr, host->ioaddr + SDHCI_POWER_CONTROL);
-
-+ pwr |= SDHCI_POWER_ON;
-+
-+ writeb(pwr, host->ioaddr + SDHCI_POWER_CONTROL);
-+
- out:
- host->power = power;
- }
-diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
-index fbec8cd..8848e8a 100644
---- a/drivers/mtd/Kconfig
-+++ b/drivers/mtd/Kconfig
-@@ -278,6 +278,14 @@ config SSFDC
- This enables read only access to SmartMedia formatted NAND
- flash. You can mount it with FAT file system.
-
-+config MTD_OOPS
-+ tristate "Log panic/oops to an MTD buffer"
-+ depends on MTD
-+ help
-+ This enables panic and oops messages to be logged to a circular
-+ buffer in a flash partition where it can be read back at some
-+ later point.
-+
- source "drivers/mtd/chips/Kconfig"
-
- source "drivers/mtd/maps/Kconfig"
-diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile
-index 6d958a4..7f0b04b 100644
---- a/drivers/mtd/Makefile
-+++ b/drivers/mtd/Makefile
-@@ -22,6 +22,7 @@ obj-$(CONFIG_NFTL) += nftl.o
- obj-$(CONFIG_INFTL) += inftl.o
- obj-$(CONFIG_RFD_FTL) += rfd_ftl.o
- obj-$(CONFIG_SSFDC) += ssfdc.o
-+obj-$(CONFIG_MTD_OOPS) += mtdoops.o
-
- nftl-objs := nftlcore.o nftlmount.o
- inftl-objs := inftlcore.o inftlmount.o
-diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
-index 2f19fa7..39eff9f 100644
---- a/drivers/mtd/chips/cfi_cmdset_0001.c
-+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
-@@ -526,7 +526,7 @@ static int cfi_intelext_partition_fixup(struct mtd_info *mtd,
- struct cfi_pri_intelext *extp = cfi->cmdset_priv;
-
- /*
-- * Probing of multi-partition flash ships.
-+ * Probing of multi-partition flash chips.
- *
- * To support multiple partitions when available, we simply arrange
- * for each of them to have their own flchip structure even if they
-@@ -1780,7 +1780,7 @@ static int __xipram do_erase_oneblock(struct map_info *map, struct flchip *chip,
- return ret;
- }
-
--int cfi_intelext_erase_varsize(struct mtd_info *mtd, struct erase_info *instr)
-+static int cfi_intelext_erase_varsize(struct mtd_info *mtd, struct erase_info *instr)
- {
- unsigned long ofs, len;
- int ret;
-@@ -1930,7 +1930,7 @@ static int cfi_intelext_lock(struct mtd_info *mtd, loff_t ofs, size_t len)
- printk(KERN_DEBUG "%s: lock status before, ofs=0x%08llx, len=0x%08X\n",
- __FUNCTION__, ofs, len);
- cfi_varsize_frob(mtd, do_printlockstatus_oneblock,
-- ofs, len, 0);
-+ ofs, len, NULL);
- #endif
-
- ret = cfi_varsize_frob(mtd, do_xxlock_oneblock,
-@@ -1940,7 +1940,7 @@ static int cfi_intelext_lock(struct mtd_info *mtd, loff_t ofs, size_t len)
- printk(KERN_DEBUG "%s: lock status after, ret=%d\n",
- __FUNCTION__, ret);
- cfi_varsize_frob(mtd, do_printlockstatus_oneblock,
-- ofs, len, 0);
-+ ofs, len, NULL);
- #endif
-
- return ret;
-@@ -1954,7 +1954,7 @@ static int cfi_intelext_unlock(struct mtd_info *mtd, loff_t ofs, size_t len)
- printk(KERN_DEBUG "%s: lock status before, ofs=0x%08llx, len=0x%08X\n",
- __FUNCTION__, ofs, len);
- cfi_varsize_frob(mtd, do_printlockstatus_oneblock,
-- ofs, len, 0);
-+ ofs, len, NULL);
- #endif
-
- ret = cfi_varsize_frob(mtd, do_xxlock_oneblock,
-@@ -1964,7 +1964,7 @@ static int cfi_intelext_unlock(struct mtd_info *mtd, loff_t ofs, size_t len)
- printk(KERN_DEBUG "%s: lock status after, ret=%d\n",
- __FUNCTION__, ret);
- cfi_varsize_frob(mtd, do_printlockstatus_oneblock,
-- ofs, len, 0);
-+ ofs, len, NULL);
- #endif
-
- return ret;
-@@ -2255,7 +2255,7 @@ static void cfi_intelext_save_locks(struct mtd_info *mtd)
- adr = region->offset + block * len;
-
- status = cfi_varsize_frob(mtd,
-- do_getlockstatus_oneblock, adr, len, 0);
-+ do_getlockstatus_oneblock, adr, len, NULL);
- if (status)
- set_bit(block, region->lockmap);
- else
-diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
-index 1f64458..389acc6 100644
---- a/drivers/mtd/chips/cfi_cmdset_0002.c
-+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
-@@ -1609,7 +1609,7 @@ static int __xipram do_erase_oneblock(struct map_info *map, struct flchip *chip,
- }
-
-
--int cfi_amdstd_erase_varsize(struct mtd_info *mtd, struct erase_info *instr)
-+static int cfi_amdstd_erase_varsize(struct mtd_info *mtd, struct erase_info *instr)
- {
- unsigned long ofs, len;
- int ret;
-diff --git a/drivers/mtd/chips/jedec_probe.c b/drivers/mtd/chips/jedec_probe.c
-index 58e561e..593e9d6 100644
---- a/drivers/mtd/chips/jedec_probe.c
-+++ b/drivers/mtd/chips/jedec_probe.c
-@@ -70,6 +70,7 @@
-
- /* Fujitsu */
- #define MBM29F040C 0x00A4
-+#define MBM29F800BA 0x2258
- #define MBM29LV650UE 0x22D7
- #define MBM29LV320TE 0x22F6
- #define MBM29LV320BE 0x22F9
-@@ -129,6 +130,7 @@
- #define LH28F640BF 0x00b0
-
- /* ST - www.st.com */
-+#define M29F800AB 0x0058
- #define M29W800DT 0x00D7
- #define M29W800DB 0x005B
- #define M29W160DT 0x22C4
-@@ -646,6 +648,23 @@ static const struct amd_flash_info jedec_table[] = {
- }
- }, {
- .mfr_id = MANUFACTURER_FUJITSU,
-+ .dev_id = MBM29F800BA,
-+ .name = "Fujitsu MBM29F800BA",
-+ .uaddr = {
-+ [0] = MTD_UADDR_0x0AAA_0x0555, /* x8 */
-+ [1] = MTD_UADDR_0x0555_0x02AA, /* x16 */
-+ },
-+ .DevSize = SIZE_1MiB,
-+ .CmdSet = P_ID_AMD_STD,
-+ .NumEraseRegions= 4,
-+ .regions = {
-+ ERASEINFO(0x04000,1),
-+ ERASEINFO(0x02000,2),
-+ ERASEINFO(0x08000,1),
-+ ERASEINFO(0x10000,15),
-+ }
-+ }, {
-+ .mfr_id = MANUFACTURER_FUJITSU,
- .dev_id = MBM29LV650UE,
- .name = "Fujitsu MBM29LV650UE",
- .uaddr = {
-@@ -1510,6 +1529,23 @@ static const struct amd_flash_info jedec_table[] = {
- ERASEINFO(0x1000,256)
- }
-
-+ }, {
-+ .mfr_id = MANUFACTURER_ST,
-+ .dev_id = M29F800AB,
-+ .name = "ST M29F800AB",
-+ .uaddr = {
-+ [0] = MTD_UADDR_0x0AAA_0x0555, /* x8 */
-+ [1] = MTD_UADDR_0x0555_0x02AA, /* x16 */
-+ },
-+ .DevSize = SIZE_1MiB,
-+ .CmdSet = P_ID_AMD_STD,
-+ .NumEraseRegions= 4,
-+ .regions = {
-+ ERASEINFO(0x04000,1),
-+ ERASEINFO(0x02000,2),
-+ ERASEINFO(0x08000,1),
-+ ERASEINFO(0x10000,15),
-+ }
- }, {
- .mfr_id = MANUFACTURER_ST, /* FIXME - CFI device? */
- .dev_id = M29W800DT,
-diff --git a/drivers/mtd/devices/Kconfig b/drivers/mtd/devices/Kconfig
-index ff642f8..b4ea64d 100644
---- a/drivers/mtd/devices/Kconfig
-+++ b/drivers/mtd/devices/Kconfig
-@@ -69,12 +69,21 @@ config MTD_DATAFLASH26
- If you have such a board and such a DataFlash, say 'Y'.
-
- config MTD_M25P80
-- tristate "Support for M25 SPI Flash"
-+ tristate "Support most SPI Flash chips (AT26DF, M25P, W25X, ...)"
- depends on SPI_MASTER && EXPERIMENTAL
- help
-- This enables access to ST M25P80 and similar SPI flash chips,
-- used for program and data storage. Set up your spi devices
-- with the right board-specific platform data.
-+ This enables access to most modern SPI flash chips, used for
-+ program and data storage. Series supported include Atmel AT26DF,
-+ Spansion S25SL, SST 25VF, ST M25P, and Winbond W25X. Other chips
-+ are supported as well. See the driver source for the current list,
-+ or to add other chips.
-+
-+ Note that the original DataFlash chips (AT45 series, not AT26DF),
-+ need an entirely different driver.
-+
-+ Set up your spi devices with the right board-specific platform data,
-+ if you want to specify device partitioning or to use a device which
-+ doesn't support the JEDEC ID instruction.
-
- config MTD_SLRAM
- tristate "Uncached system RAM"
-diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
-index 78c2511..98df5bc 100644
---- a/drivers/mtd/devices/m25p80.c
-+++ b/drivers/mtd/devices/m25p80.c
-@@ -1,5 +1,5 @@
- /*
-- * MTD SPI driver for ST M25Pxx flash chips
-+ * MTD SPI driver for ST M25Pxx (and similar) serial flash chips
- *
- * Author: Mike Lavender, mike@steroidmicros.com
- *
-@@ -19,33 +19,32 @@
- #include <linux/module.h>
- #include <linux/device.h>
- #include <linux/interrupt.h>
--#include <linux/interrupt.h>
-+#include <linux/mutex.h>
-+
- #include <linux/mtd/mtd.h>
- #include <linux/mtd/partitions.h>
-+
- #include <linux/spi/spi.h>
- #include <linux/spi/flash.h>
-
--#include <asm/semaphore.h>
--
--
--/* NOTE: AT 25F and SST 25LF series are very similar,
-- * but commands for sector erase and chip id differ...
-- */
-
- #define FLASH_PAGESIZE 256
-
- /* Flash opcodes. */
--#define OPCODE_WREN 6 /* Write enable */
--#define OPCODE_RDSR 5 /* Read status register */
--#define OPCODE_READ 3 /* Read data bytes */
--#define OPCODE_PP 2 /* Page program */
--#define OPCODE_SE 0xd8 /* Sector erase */
--#define OPCODE_RES 0xab /* Read Electronic Signature */
-+#define OPCODE_WREN 0x06 /* Write enable */
-+#define OPCODE_RDSR 0x05 /* Read status register */
-+#define OPCODE_READ 0x03 /* Read data bytes (low frequency) */
-+#define OPCODE_FAST_READ 0x0b /* Read data bytes (high frequency) */
-+#define OPCODE_PP 0x02 /* Page program (up to 256 bytes) */
-+#define OPCODE_BE_4K 0x20 /* Erase 4KiB block */
-+#define OPCODE_BE_32K 0x52 /* Erase 32KiB block */
-+#define OPCODE_SE 0xd8 /* Sector erase (usually 64KiB) */
- #define OPCODE_RDID 0x9f /* Read JEDEC ID */
-
- /* Status Register bits. */
- #define SR_WIP 1 /* Write in progress */
- #define SR_WEL 2 /* Write enable latch */
-+/* meaning of other SR_* bits may differ between vendors */
- #define SR_BP0 4 /* Block protect 0 */
- #define SR_BP1 8 /* Block protect 1 */
- #define SR_BP2 0x10 /* Block protect 2 */
-@@ -65,9 +64,10 @@
-
- struct m25p {
- struct spi_device *spi;
-- struct semaphore lock;
-+ struct mutex lock;
- struct mtd_info mtd;
-- unsigned partitioned;
-+ unsigned partitioned:1;
-+ u8 erase_opcode;
- u8 command[4];
- };
-
-@@ -150,8 +150,9 @@ static int wait_till_ready(struct m25p *flash)
- */
- static int erase_sector(struct m25p *flash, u32 offset)
- {
-- DEBUG(MTD_DEBUG_LEVEL3, "%s: %s at 0x%08x\n", flash->spi->dev.bus_id,
-- __FUNCTION__, offset);
-+ DEBUG(MTD_DEBUG_LEVEL3, "%s: %s %dKiB at 0x%08x\n",
-+ flash->spi->dev.bus_id, __FUNCTION__,
-+ flash->mtd.erasesize / 1024, offset);
-
- /* Wait until finished previous write command. */
- if (wait_till_ready(flash))
-@@ -161,7 +162,7 @@ static int erase_sector(struct m25p *flash, u32 offset)
- write_enable(flash);
-
- /* Set up command buffer. */
-- flash->command[0] = OPCODE_SE;
-+ flash->command[0] = flash->erase_opcode;
- flash->command[1] = offset >> 16;
- flash->command[2] = offset >> 8;
- flash->command[3] = offset;
-@@ -201,13 +202,17 @@ static int m25p80_erase(struct mtd_info *mtd, struct erase_info *instr)
- addr = instr->addr;
- len = instr->len;
-
-- down(&flash->lock);
-+ mutex_lock(&flash->lock);
-+
-+ /* REVISIT in some cases we could speed up erasing large regions
-+ * by using OPCODE_SE instead of OPCODE_BE_4K
-+ */
-
- /* now erase those sectors */
- while (len) {
- if (erase_sector(flash, addr)) {
- instr->state = MTD_ERASE_FAILED;
-- up(&flash->lock);
-+ mutex_unlock(&flash->lock);
- return -EIO;
- }
-
-@@ -215,7 +220,7 @@ static int m25p80_erase(struct mtd_info *mtd, struct erase_info *instr)
- len -= mtd->erasesize;
- }
-
-- up(&flash->lock);
-+ mutex_unlock(&flash->lock);
-
- instr->state = MTD_ERASE_DONE;
- mtd_erase_callback(instr);
-@@ -260,16 +265,19 @@ static int m25p80_read(struct mtd_info *mtd, loff_t from, size_t len,
- if (retlen)
- *retlen = 0;
-
-- down(&flash->lock);
-+ mutex_lock(&flash->lock);
-
- /* Wait till previous write/erase is done. */
- if (wait_till_ready(flash)) {
- /* REVISIT status return?? */
-- up(&flash->lock);
-+ mutex_unlock(&flash->lock);
- return 1;
- }
-
-- /* NOTE: OPCODE_FAST_READ (if available) is faster... */
-+ /* FIXME switch to OPCODE_FAST_READ. It's required for higher
-+ * clocks; and at this writing, every chip this driver handles
-+ * supports that opcode.
-+ */
-
- /* Set up the write data buffer. */
- flash->command[0] = OPCODE_READ;
-@@ -281,7 +289,7 @@ static int m25p80_read(struct mtd_info *mtd, loff_t from, size_t len,
-
- *retlen = m.actual_length - sizeof(flash->command);
-
-- up(&flash->lock);
-+ mutex_unlock(&flash->lock);
-
- return 0;
- }
-@@ -323,7 +331,7 @@ static int m25p80_write(struct mtd_info *mtd, loff_t to, size_t len,
- t[1].tx_buf = buf;
- spi_message_add_tail(&t[1], &m);
-
-- down(&flash->lock);
-+ mutex_lock(&flash->lock);
-
- /* Wait until finished previous write command. */
- if (wait_till_ready(flash))
-@@ -381,10 +389,10 @@ static int m25p80_write(struct mtd_info *mtd, loff_t to, size_t len,
- if (retlen)
- *retlen += m.actual_length
- - sizeof(flash->command);
-- }
-- }
-+ }
-+ }
-
-- up(&flash->lock);
-+ mutex_unlock(&flash->lock);
-
- return 0;
- }
-@@ -398,24 +406,118 @@ static int m25p80_write(struct mtd_info *mtd, loff_t to, size_t len,
-
- struct flash_info {
- char *name;
-- u8 id;
-- u16 jedec_id;
-+
-+ /* JEDEC id zero means "no ID" (most older chips); otherwise it has
-+ * a high byte of zero plus three data bytes: the manufacturer id,
-+ * then a two byte device id.
-+ */
-+ u32 jedec_id;
-+
-+ /* The size listed here is what works with OPCODE_SE, which isn't
-+ * necessarily called a "sector" by the vendor.
-+ */
- unsigned sector_size;
-- unsigned n_sectors;
-+ u16 n_sectors;
-+
-+ u16 flags;
-+#define SECT_4K 0x01 /* OPCODE_BE_4K works uniformly */
- };
-
-+
-+/* NOTE: double check command sets and memory organization when you add
-+ * more flash chips. This current list focusses on newer chips, which
-+ * have been converging on command sets which including JEDEC ID.
-+ */
- static struct flash_info __devinitdata m25p_data [] = {
-- /* REVISIT: fill in JEDEC ids, for parts that have them */
-- { "m25p05", 0x05, 0x2010, 32 * 1024, 2 },
-- { "m25p10", 0x10, 0x2011, 32 * 1024, 4 },
-- { "m25p20", 0x11, 0x2012, 64 * 1024, 4 },
-- { "m25p40", 0x12, 0x2013, 64 * 1024, 8 },
-- { "m25p80", 0x13, 0x0000, 64 * 1024, 16 },
-- { "m25p16", 0x14, 0x2015, 64 * 1024, 32 },
-- { "m25p32", 0x15, 0x2016, 64 * 1024, 64 },
-- { "m25p64", 0x16, 0x2017, 64 * 1024, 128 },
-+
-+ /* Atmel -- some are (confusingly) marketed as "DataFlash" */
-+ { "at25fs010", 0x1f6601, 32 * 1024, 4, SECT_4K, },
-+ { "at25fs040", 0x1f6604, 64 * 1024, 8, SECT_4K, },
-+
-+ { "at25df041a", 0x1f4401, 64 * 1024, 8, SECT_4K, },
-+
-+ { "at26f004", 0x1f0400, 64 * 1024, 8, SECT_4K, },
-+ { "at26df081a", 0x1f4501, 64 * 1024, 16, SECT_4K, },
-+ { "at26df161a", 0x1f4601, 64 * 1024, 32, SECT_4K, },
-+ { "at26df321", 0x1f4701, 64 * 1024, 64, SECT_4K, },
-+
-+ /* Spansion -- single (large) sector size only, at least
-+ * for the chips listed here (without boot sectors).
-+ */
-+ { "s25sl004a", 0x010212, 64 * 1024, 8, },
-+ { "s25sl008a", 0x010213, 64 * 1024, 16, },
-+ { "s25sl016a", 0x010214, 64 * 1024, 32, },
-+ { "s25sl032a", 0x010215, 64 * 1024, 64, },
-+ { "s25sl064a", 0x010216, 64 * 1024, 128, },
-+
-+ /* SST -- large erase sizes are "overlays", "sectors" are 4K */
-+ { "sst25vf040b", 0xbf258d, 64 * 1024, 8, SECT_4K, },
-+ { "sst25vf080b", 0xbf258e, 64 * 1024, 16, SECT_4K, },
-+ { "sst25vf016b", 0xbf2541, 64 * 1024, 32, SECT_4K, },
-+ { "sst25vf032b", 0xbf254a, 64 * 1024, 64, SECT_4K, },
-+
-+ /* ST Microelectronics -- newer production may have feature updates */
-+ { "m25p05", 0x202010, 32 * 1024, 2, },
-+ { "m25p10", 0x202011, 32 * 1024, 4, },
-+ { "m25p20", 0x202012, 64 * 1024, 4, },
-+ { "m25p40", 0x202013, 64 * 1024, 8, },
-+ { "m25p80", 0, 64 * 1024, 16, },
-+ { "m25p16", 0x202015, 64 * 1024, 32, },
-+ { "m25p32", 0x202016, 64 * 1024, 64, },
-+ { "m25p64", 0x202017, 64 * 1024, 128, },
-+ { "m25p128", 0x202018, 256 * 1024, 64, },
-+
-+ { "m45pe80", 0x204014, 64 * 1024, 16, },
-+ { "m45pe16", 0x204015, 64 * 1024, 32, },
-+
-+ { "m25pe80", 0x208014, 64 * 1024, 16, },
-+ { "m25pe16", 0x208015, 64 * 1024, 32, SECT_4K, },
-+
-+ /* Winbond -- w25x "blocks" are 64K, "sectors" are 4KiB */
-+ { "w25x10", 0xef3011, 64 * 1024, 2, SECT_4K, },
-+ { "w25x20", 0xef3012, 64 * 1024, 4, SECT_4K, },
-+ { "w25x40", 0xef3013, 64 * 1024, 8, SECT_4K, },
-+ { "w25x80", 0xef3014, 64 * 1024, 16, SECT_4K, },
-+ { "w25x16", 0xef3015, 64 * 1024, 32, SECT_4K, },
-+ { "w25x32", 0xef3016, 64 * 1024, 64, SECT_4K, },
-+ { "w25x64", 0xef3017, 64 * 1024, 128, SECT_4K, },
- };
-
-+static struct flash_info *__devinit jedec_probe(struct spi_device *spi)
-+{
-+ int tmp;
-+ u8 code = OPCODE_RDID;
-+ u8 id[3];
-+ u32 jedec;
-+ struct flash_info *info;
-+
-+ /* JEDEC also defines an optional "extended device information"
-+ * string for after vendor-specific data, after the three bytes
-+ * we use here. Supporting some chips might require using it.
-+ */
-+ tmp = spi_write_then_read(spi, &code, 1, id, 3);
-+ if (tmp < 0) {
-+ DEBUG(MTD_DEBUG_LEVEL0, "%s: error %d reading JEDEC ID\n",
-+ spi->dev.bus_id, tmp);
-+ return NULL;
-+ }
-+ jedec = id[0];
-+ jedec = jedec << 8;
-+ jedec |= id[1];
-+ jedec = jedec << 8;
-+ jedec |= id[2];
-+
-+ for (tmp = 0, info = m25p_data;
-+ tmp < ARRAY_SIZE(m25p_data);
-+ tmp++, info++) {
-+ if (info->jedec_id == jedec)
-+ return info;
-+ }
-+ dev_err(&spi->dev, "unrecognized JEDEC id %06x\n", jedec);
-+ return NULL;
-+}
-+
-+
- /*
- * board specific setup should have ensured the SPI clock used here
- * matches what the READ command supports, at least until this driver
-@@ -429,37 +531,51 @@ static int __devinit m25p_probe(struct spi_device *spi)
- unsigned i;
-
- /* Platform data helps sort out which chip type we have, as
-- * well as how this board partitions it.
-+ * well as how this board partitions it. If we don't have
-+ * a chip ID, try the JEDEC id commands; they'll work for most
-+ * newer chips, even if we don't recognize the particular chip.
- */
- data = spi->dev.platform_data;
-- if (!data || !data->type) {
-- /* FIXME some chips can identify themselves with RES
-- * or JEDEC get-id commands. Try them ...
-- */
-- DEBUG(MTD_DEBUG_LEVEL1, "%s: no chip id\n",
-- spi->dev.bus_id);
-- return -ENODEV;
-- }
-+ if (data && data->type) {
-+ for (i = 0, info = m25p_data;
-+ i < ARRAY_SIZE(m25p_data);
-+ i++, info++) {
-+ if (strcmp(data->type, info->name) == 0)
-+ break;
-+ }
-
-- for (i = 0, info = m25p_data; i < ARRAY_SIZE(m25p_data); i++, info++) {
-- if (strcmp(data->type, info->name) == 0)
-- break;
-- }
-- if (i == ARRAY_SIZE(m25p_data)) {
-- DEBUG(MTD_DEBUG_LEVEL1, "%s: unrecognized id %s\n",
-- spi->dev.bus_id, data->type);
-+ /* unrecognized chip? */
-+ if (i == ARRAY_SIZE(m25p_data)) {
-+ DEBUG(MTD_DEBUG_LEVEL0, "%s: unrecognized id %s\n",
-+ spi->dev.bus_id, data->type);
-+ info = NULL;
-+
-+ /* recognized; is that chip really what's there? */
-+ } else if (info->jedec_id) {
-+ struct flash_info *chip = jedec_probe(spi);
-+
-+ if (!chip || chip != info) {
-+ dev_warn(&spi->dev, "found %s, expected %s\n",
-+ chip ? chip->name : "UNKNOWN",
-+ info->name);
-+ info = NULL;
-+ }
-+ }
-+ } else
-+ info = jedec_probe(spi);
-+
-+ if (!info)
- return -ENODEV;
-- }
-
- flash = kzalloc(sizeof *flash, GFP_KERNEL);
- if (!flash)
- return -ENOMEM;
-
- flash->spi = spi;
-- init_MUTEX(&flash->lock);
-+ mutex_init(&flash->lock);
- dev_set_drvdata(&spi->dev, flash);
-
-- if (data->name)
-+ if (data && data->name)
- flash->mtd.name = data->name;
- else
- flash->mtd.name = spi->dev.bus_id;
-@@ -468,17 +584,25 @@ static int __devinit m25p_probe(struct spi_device *spi)
- flash->mtd.writesize = 1;
- flash->mtd.flags = MTD_CAP_NORFLASH;
- flash->mtd.size = info->sector_size * info->n_sectors;
-- flash->mtd.erasesize = info->sector_size;
- flash->mtd.erase = m25p80_erase;
- flash->mtd.read = m25p80_read;
- flash->mtd.write = m25p80_write;
-
-+ /* prefer "small sector" erase if possible */
-+ if (info->flags & SECT_4K) {
-+ flash->erase_opcode = OPCODE_BE_4K;
-+ flash->mtd.erasesize = 4096;
-+ } else {
-+ flash->erase_opcode = OPCODE_SE;
-+ flash->mtd.erasesize = info->sector_size;
-+ }
-+
- dev_info(&spi->dev, "%s (%d Kbytes)\n", info->name,
- flash->mtd.size / 1024);
-
- DEBUG(MTD_DEBUG_LEVEL2,
-- "mtd .name = %s, .size = 0x%.8x (%uM) "
-- ".erasesize = 0x%.8x (%uK) .numeraseregions = %d\n",
-+ "mtd .name = %s, .size = 0x%.8x (%uMiB) "
-+ ".erasesize = 0x%.8x (%uKiB) .numeraseregions = %d\n",
- flash->mtd.name,
- flash->mtd.size, flash->mtd.size / (1024*1024),
- flash->mtd.erasesize, flash->mtd.erasesize / 1024,
-@@ -488,7 +612,7 @@ static int __devinit m25p_probe(struct spi_device *spi)
- for (i = 0; i < flash->mtd.numeraseregions; i++)
- DEBUG(MTD_DEBUG_LEVEL2,
- "mtd.eraseregions[%d] = { .offset = 0x%.8x, "
-- ".erasesize = 0x%.8x (%uK), "
-+ ".erasesize = 0x%.8x (%uKiB), "
- ".numblocks = %d }\n",
- i, flash->mtd.eraseregions[i].offset,
- flash->mtd.eraseregions[i].erasesize,
-@@ -516,14 +640,14 @@ static int __devinit m25p_probe(struct spi_device *spi)
- }
-
- if (nr_parts > 0) {
-- for (i = 0; i < data->nr_parts; i++) {
-+ for (i = 0; i < nr_parts; i++) {
- DEBUG(MTD_DEBUG_LEVEL2, "partitions[%d] = "
- "{.name = %s, .offset = 0x%.8x, "
-- ".size = 0x%.8x (%uK) }\n",
-- i, data->parts[i].name,
-- data->parts[i].offset,
-- data->parts[i].size,
-- data->parts[i].size / 1024);
-+ ".size = 0x%.8x (%uKiB) }\n",
-+ i, parts[i].name,
-+ parts[i].offset,
-+ parts[i].size,
-+ parts[i].size / 1024);
- }
- flash->partitioned = 1;
- return add_mtd_partitions(&flash->mtd, parts, nr_parts);
-@@ -560,6 +684,11 @@ static struct spi_driver m25p80_driver = {
- },
- .probe = m25p_probe,
- .remove = __devexit_p(m25p_remove),
-+
-+ /* REVISIT: many of these chips have deep power-down modes, which
-+ * should clearly be entered on suspend() to minimize power use.
-+ * And also when they're otherwise idle...
-+ */
- };
-
-
-diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c
-index a987e91..a5ed6d2 100644
---- a/drivers/mtd/devices/mtd_dataflash.c
-+++ b/drivers/mtd/devices/mtd_dataflash.c
-@@ -14,6 +14,7 @@
- #include <linux/slab.h>
- #include <linux/delay.h>
- #include <linux/device.h>
-+#include <linux/mutex.h>
- #include <linux/spi/spi.h>
- #include <linux/spi/flash.h>
-
-@@ -89,7 +90,7 @@ struct dataflash {
- unsigned short page_offset; /* offset in flash address */
- unsigned int page_size; /* of bytes per page */
-
-- struct semaphore lock;
-+ struct mutex lock;
- struct spi_device *spi;
-
- struct mtd_info mtd;
-@@ -167,7 +168,7 @@ static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr)
- x.len = 4;
- spi_message_add_tail(&x, &msg);
-
-- down(&priv->lock);
-+ mutex_lock(&priv->lock);
- while (instr->len > 0) {
- unsigned int pageaddr;
- int status;
-@@ -210,7 +211,7 @@ static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr)
- instr->len -= priv->page_size;
- }
- }
-- up(&priv->lock);
-+ mutex_unlock(&priv->lock);
-
- /* Inform MTD subsystem that erase is complete */
- instr->state = MTD_ERASE_DONE;
-@@ -266,7 +267,7 @@ static int dataflash_read(struct mtd_info *mtd, loff_t from, size_t len,
- x[1].len = len;
- spi_message_add_tail(&x[1], &msg);
-
-- down(&priv->lock);
-+ mutex_lock(&priv->lock);
-
- /* Continuous read, max clock = f(car) which may be less than
- * the peak rate available. Some chips support commands with
-@@ -279,7 +280,7 @@ static int dataflash_read(struct mtd_info *mtd, loff_t from, size_t len,
- /* plus 4 "don't care" bytes */
-
- status = spi_sync(priv->spi, &msg);
-- up(&priv->lock);
-+ mutex_unlock(&priv->lock);
-
- if (status >= 0) {
- *retlen = msg.actual_length - 8;
-@@ -336,7 +337,7 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len,
- else
- writelen = len;
-
-- down(&priv->lock);
-+ mutex_lock(&priv->lock);
- while (remaining > 0) {
- DEBUG(MTD_DEBUG_LEVEL3, "write @ %i:%i len=%i\n",
- pageaddr, offset, writelen);
-@@ -441,7 +442,7 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len,
- else
- writelen = remaining;
- }
-- up(&priv->lock);
-+ mutex_unlock(&priv->lock);
-
- return status;
- }
-@@ -463,7 +464,7 @@ add_dataflash(struct spi_device *spi, char *name,
- if (!priv)
- return -ENOMEM;
-
-- init_MUTEX(&priv->lock);
-+ mutex_init(&priv->lock);
- priv->spi = spi;
- priv->page_size = pagesize;
- priv->page_offset = pageoffset;
-diff --git a/drivers/mtd/devices/pmc551.c b/drivers/mtd/devices/pmc551.c
-index e8f686f..7060a08 100644
---- a/drivers/mtd/devices/pmc551.c
-+++ b/drivers/mtd/devices/pmc551.c
-@@ -30,8 +30,8 @@
- *
- * Notes:
- * Due to what I assume is more buggy SROM, the 64M PMC551 I
-- * have available claims that all 4 of it's DRAM banks have 64M
-- * of ram configured (making a grand total of 256M onboard).
-+ * have available claims that all 4 of its DRAM banks have 64MiB
-+ * of ram configured (making a grand total of 256MiB onboard).
- * This is slightly annoying since the BAR0 size reflects the
- * aperture size, not the dram size, and the V370PDC supplies no
- * other method for memory size discovery. This problem is
-@@ -70,7 +70,7 @@
- * made the memory unusable, added a fix to code to touch up
- * the DRAM some.
- *
-- * Bugs/FIXME's:
-+ * Bugs/FIXMEs:
- * * MUST fix the init function to not spin on a register
- * waiting for it to set .. this does not safely handle busted
- * devices that never reset the register correctly which will
-@@ -562,10 +562,10 @@ static u32 fixup_pmc551(struct pci_dev *dev)
- /*
- * Some screen fun
- */
-- printk(KERN_DEBUG "pmc551: %d%c (0x%x) of %sprefetchable memory at "
-+ printk(KERN_DEBUG "pmc551: %d%sB (0x%x) of %sprefetchable memory at "
- "0x%llx\n", (size < 1024) ? size : (size < 1048576) ?
- size >> 10 : size >> 20,
-- (size < 1024) ? 'B' : (size < 1048576) ? 'K' : 'M', size,
-+ (size < 1024) ? "" : (size < 1048576) ? "Ki" : "Mi", size,
- ((dcmd & (0x1 << 3)) == 0) ? "non-" : "",
- (unsigned long long)pci_resource_start(dev, 0));
-
-@@ -649,14 +649,10 @@ MODULE_DESCRIPTION(PMC551_VERSION);
- * Stuff these outside the ifdef so as to not bust compiled in driver support
- */
- static int msize = 0;
--#if defined(CONFIG_MTD_PMC551_APERTURE_SIZE)
--static int asize = CONFIG_MTD_PMC551_APERTURE_SIZE;
--#else
- static int asize = 0;
--#endif
-
- module_param(msize, int, 0);
--MODULE_PARM_DESC(msize, "memory size in Megabytes [1 - 1024]");
-+MODULE_PARM_DESC(msize, "memory size in MiB [1 - 1024]");
- module_param(asize, int, 0);
- MODULE_PARM_DESC(asize, "aperture size, must be <= memsize [1-1024]");
-
-@@ -799,8 +795,7 @@ static int __init init_pmc551(void)
- mtd->owner = THIS_MODULE;
-
- if (add_mtd_device(mtd)) {
-- printk(KERN_NOTICE "pmc551: Failed to register new "
-- "device\n");
-+ printk(KERN_NOTICE "pmc551: Failed to register new device\n");
- pci_iounmap(PCI_Device, priv->start);
- kfree(mtd->priv);
- kfree(mtd);
-@@ -811,13 +806,13 @@ static int __init init_pmc551(void)
- pci_dev_get(PCI_Device);
-
- printk(KERN_NOTICE "Registered pmc551 memory device.\n");
-- printk(KERN_NOTICE "Mapped %dM of memory from 0x%p to 0x%p\n",
-+ printk(KERN_NOTICE "Mapped %dMiB of memory from 0x%p to 0x%p\n",
- priv->asize >> 20,
- priv->start, priv->start + priv->asize);
-- printk(KERN_NOTICE "Total memory is %d%c\n",
-+ printk(KERN_NOTICE "Total memory is %d%sB\n",
- (length < 1024) ? length :
- (length < 1048576) ? length >> 10 : length >> 20,
-- (length < 1024) ? 'B' : (length < 1048576) ? 'K' : 'M');
-+ (length < 1024) ? "" : (length < 1048576) ? "Ki" : "Mi");
- priv->nextpmc551 = pmc551list;
- pmc551list = mtd;
- found++;
-@@ -850,7 +845,7 @@ static void __exit cleanup_pmc551(void)
- pmc551list = priv->nextpmc551;
-
- if (priv->start) {
-- printk(KERN_DEBUG "pmc551: unmapping %dM starting at "
-+ printk(KERN_DEBUG "pmc551: unmapping %dMiB starting at "
- "0x%p\n", priv->asize >> 20, priv->start);
- pci_iounmap(priv->dev, priv->start);
- }
-diff --git a/drivers/mtd/maps/nettel.c b/drivers/mtd/maps/nettel.c
-index 7b96cd0..0c9b305 100644
---- a/drivers/mtd/maps/nettel.c
-+++ b/drivers/mtd/maps/nettel.c
-@@ -158,68 +158,11 @@ static struct notifier_block nettel_notifier_block = {
- nettel_reboot_notifier, NULL, 0
- };
-
--/*
-- * Erase the configuration file system.
-- * Used to support the software reset button.
-- */
--static void nettel_erasecallback(struct erase_info *done)
--{
-- wait_queue_head_t *wait_q = (wait_queue_head_t *)done->priv;
-- wake_up(wait_q);
--}
--
--static struct erase_info nettel_erase;
--
--int nettel_eraseconfig(void)
--{
-- struct mtd_info *mtd;
-- DECLARE_WAITQUEUE(wait, current);
-- wait_queue_head_t wait_q;
-- int ret;
--
-- init_waitqueue_head(&wait_q);
-- mtd = get_mtd_device(NULL, 2);
-- if (!IS_ERR(mtd)) {
-- nettel_erase.mtd = mtd;
-- nettel_erase.callback = nettel_erasecallback;
-- nettel_erase.callback = NULL;
-- nettel_erase.addr = 0;
-- nettel_erase.len = mtd->size;
-- nettel_erase.priv = (u_long) &wait_q;
-- nettel_erase.priv = 0;
--
-- set_current_state(TASK_INTERRUPTIBLE);
-- add_wait_queue(&wait_q, &wait);
--
-- ret = mtd->erase(mtd, &nettel_erase);
-- if (ret) {
-- set_current_state(TASK_RUNNING);
-- remove_wait_queue(&wait_q, &wait);
-- put_mtd_device(mtd);
-- return(ret);
-- }
--
-- schedule(); /* Wait for erase to finish. */
-- remove_wait_queue(&wait_q, &wait);
--
-- put_mtd_device(mtd);
-- }
--
-- return(0);
--}
--
--#else
--
--int nettel_eraseconfig(void)
--{
-- return(0);
--}
--
- #endif
-
- /****************************************************************************/
-
--int __init nettel_init(void)
-+static int __init nettel_init(void)
- {
- volatile unsigned long *amdpar;
- unsigned long amdaddr, maxsize;
-@@ -421,10 +364,6 @@ int __init nettel_init(void)
-
- intel_mtd->owner = THIS_MODULE;
-
--#ifndef CONFIG_BLK_DEV_INITRD
-- ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, 1);
--#endif
--
- num_intel_partitions = sizeof(nettel_intel_partitions) /
- sizeof(nettel_intel_partitions[0]);
-
-@@ -477,7 +416,7 @@ out_unmap2:
-
- /****************************************************************************/
-
--void __exit nettel_cleanup(void)
-+static void __exit nettel_cleanup(void)
- {
- #ifdef CONFIG_MTD_CFI_INTELEXT
- unregister_reboot_notifier(&nettel_notifier_block);
-diff --git a/drivers/mtd/maps/pmcmsp-ramroot.c b/drivers/mtd/maps/pmcmsp-ramroot.c
-index 18049bc..30de5c0 100644
---- a/drivers/mtd/maps/pmcmsp-ramroot.c
-+++ b/drivers/mtd/maps/pmcmsp-ramroot.c
-@@ -79,7 +79,6 @@ static int __init init_rrmap(void)
- rr_mtd->owner = THIS_MODULE;
-
- add_mtd_device(rr_mtd);
-- ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, rr_mtd->index);
-
- return 0;
- }
-diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
-index ef89780..74d9d30 100644
---- a/drivers/mtd/mtd_blkdevs.c
-+++ b/drivers/mtd/mtd_blkdevs.c
-@@ -24,10 +24,9 @@
- #include <linux/kthread.h>
- #include <asm/uaccess.h>
-
--static LIST_HEAD(blktrans_majors);
-+#include "mtdcore.h"
-
--extern struct mutex mtd_table_mutex;
--extern struct mtd_info *mtd_table[];
-+static LIST_HEAD(blktrans_majors);
-
- struct mtd_blkcore_priv {
- struct task_struct *thread;
-@@ -202,7 +201,7 @@ static int blktrans_ioctl(struct inode *inode, struct file *file,
- }
- }
-
--struct block_device_operations mtd_blktrans_ops = {
-+static struct block_device_operations mtd_blktrans_ops = {
- .owner = THIS_MODULE,
- .open = blktrans_open,
- .release = blktrans_release,
-diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
-index d091b24..22ed96c 100644
---- a/drivers/mtd/mtdchar.c
-+++ b/drivers/mtd/mtdchar.c
-@@ -136,7 +136,8 @@ static int mtd_close(struct inode *inode, struct file *file)
-
- DEBUG(MTD_DEBUG_LEVEL0, "MTD_close\n");
-
-- if (mtd->sync)
-+ /* Only sync if opened RW */
-+ if ((file->f_mode & 2) && mtd->sync)
- mtd->sync(mtd);
-
- put_mtd_device(mtd);
-diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
-index c153b64..6c2645e 100644
---- a/drivers/mtd/mtdcore.c
-+++ b/drivers/mtd/mtdcore.c
-@@ -22,6 +22,8 @@
-
- #include <linux/mtd/mtd.h>
-
-+#include "mtdcore.h"
-+
- /* These are exported solely for the purpose of mtd_blkdevs.c. You
- should not use them for _anything_ else */
- DEFINE_MUTEX(mtd_table_mutex);
-diff --git a/drivers/mtd/mtdcore.h b/drivers/mtd/mtdcore.h
-new file mode 100644
-index 0000000..a33251f
---- /dev/null
-+++ b/drivers/mtd/mtdcore.h
-@@ -0,0 +1,11 @@
-+/* linux/drivers/mtd/mtdcore.h
-+ *
-+ * Header file for driver private mtdcore exports
-+ *
-+ */
-+
-+/* These are exported solely for the purpose of mtd_blkdevs.c. You
-+ should not use them for _anything_ else */
-+
-+extern struct mutex mtd_table_mutex;
-+extern struct mtd_info *mtd_table[MAX_MTD_DEVICES];
-diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c
-new file mode 100644
-index 0000000..cfc28ab
---- /dev/null
-+++ b/drivers/mtd/mtdoops.c
-@@ -0,0 +1,365 @@
-+/*
-+ * MTD Oops/Panic logger
-+ *
-+ * Copyright (C) 2007 Nokia Corporation. All rights reserved.
-+ *
-+ * Author: Richard Purdie <rpurdie@openedhand.com>
-+ *
-+ * This program is free software; you can redistribute it and/or
-+ * modify it under the terms of the GNU General Public License
-+ * version 2 as published by the Free Software Foundation.
-+ *
-+ * 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 this program; if not, write to the Free Software
-+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-+ * 02110-1301 USA
-+ *
-+ */
-+
-+#include <linux/kernel.h>
-+#include <linux/module.h>
-+#include <linux/console.h>
-+#include <linux/vmalloc.h>
-+#include <linux/workqueue.h>
-+#include <linux/sched.h>
-+#include <linux/wait.h>
-+#include <linux/mtd/mtd.h>
-+
-+#define OOPS_PAGE_SIZE 4096
-+
-+static struct mtdoops_context {
-+ int mtd_index;
-+ struct work_struct work;
-+ struct mtd_info *mtd;
-+ int oops_pages;
-+ int nextpage;
-+ int nextcount;
-+
-+ void *oops_buf;
-+ int ready;
-+ int writecount;
-+} oops_cxt;
-+
-+static void mtdoops_erase_callback(struct erase_info *done)
-+{
-+ wait_queue_head_t *wait_q = (wait_queue_head_t *)done->priv;
-+ wake_up(wait_q);
-+}
-+
-+static int mtdoops_erase_block(struct mtd_info *mtd, int offset)
-+{
-+ struct erase_info erase;
-+ DECLARE_WAITQUEUE(wait, current);
-+ wait_queue_head_t wait_q;
-+ int ret;
-+
-+ init_waitqueue_head(&wait_q);
-+ erase.mtd = mtd;
-+ erase.callback = mtdoops_erase_callback;
-+ erase.addr = offset;
-+ if (mtd->erasesize < OOPS_PAGE_SIZE)
-+ erase.len = OOPS_PAGE_SIZE;
-+ else
-+ erase.len = mtd->erasesize;
-+ erase.priv = (u_long)&wait_q;
-+
-+ set_current_state(TASK_INTERRUPTIBLE);
-+ add_wait_queue(&wait_q, &wait);
-+
-+ ret = mtd->erase(mtd, &erase);
-+ if (ret) {
-+ set_current_state(TASK_RUNNING);
-+ remove_wait_queue(&wait_q, &wait);
-+ printk (KERN_WARNING "mtdoops: erase of region [0x%x, 0x%x] "
-+ "on \"%s\" failed\n",
-+ erase.addr, erase.len, mtd->name);
-+ return ret;
-+ }
-+
-+ schedule(); /* Wait for erase to finish. */
-+ remove_wait_queue(&wait_q, &wait);
-+
-+ return 0;
-+}
-+
-+static int mtdoops_inc_counter(struct mtdoops_context *cxt)
-+{
-+ struct mtd_info *mtd = cxt->mtd;
-+ size_t retlen;
-+ u32 count;
-+ int ret;
-+
-+ cxt->nextpage++;
-+ if (cxt->nextpage > cxt->oops_pages)
-+ cxt->nextpage = 0;
-+ cxt->nextcount++;
-+ if (cxt->nextcount == 0xffffffff)
-+ cxt->nextcount = 0;
-+
-+ ret = mtd->read(mtd, cxt->nextpage * OOPS_PAGE_SIZE, 4,
-+ &retlen, (u_char *) &count);
-+ if ((retlen != 4) || (ret < 0)) {
-+ printk(KERN_ERR "mtdoops: Read failure at %d (%d of 4 read)"
-+ ", err %d.\n", cxt->nextpage * OOPS_PAGE_SIZE,
-+ retlen, ret);
-+ return 1;
-+ }
-+
-+ /* See if we need to erase the next block */
-+ if (count != 0xffffffff)
-+ return 1;
-+
-+ printk(KERN_DEBUG "mtdoops: Ready %d, %d (no erase)\n",
-+ cxt->nextpage, cxt->nextcount);
-+ cxt->ready = 1;
-+ return 0;
-+}
-+
-+static void mtdoops_prepare(struct mtdoops_context *cxt)
-+{
-+ struct mtd_info *mtd = cxt->mtd;
-+ int i = 0, j, ret, mod;
-+
-+ /* We were unregistered */
-+ if (!mtd)
-+ return;
-+
-+ mod = (cxt->nextpage * OOPS_PAGE_SIZE) % mtd->erasesize;
-+ if (mod != 0) {
-+ cxt->nextpage = cxt->nextpage + ((mtd->erasesize - mod) / OOPS_PAGE_SIZE);
-+ if (cxt->nextpage > cxt->oops_pages)
-+ cxt->nextpage = 0;
-+ }
-+
-+ while (mtd->block_isbad &&
-+ mtd->block_isbad(mtd, cxt->nextpage * OOPS_PAGE_SIZE)) {
-+badblock:
-+ printk(KERN_WARNING "mtdoops: Bad block at %08x\n",
-+ cxt->nextpage * OOPS_PAGE_SIZE);
-+ i++;
-+ cxt->nextpage = cxt->nextpage + (mtd->erasesize / OOPS_PAGE_SIZE);
-+ if (cxt->nextpage > cxt->oops_pages)
-+ cxt->nextpage = 0;
-+ if (i == (cxt->oops_pages / (mtd->erasesize / OOPS_PAGE_SIZE))) {
-+ printk(KERN_ERR "mtdoops: All blocks bad!\n");
-+ return;
-+ }
-+ }
-+
-+ for (j = 0, ret = -1; (j < 3) && (ret < 0); j++)
-+ ret = mtdoops_erase_block(mtd, cxt->nextpage * OOPS_PAGE_SIZE);
-+
-+ if (ret < 0) {
-+ if (mtd->block_markbad)
-+ mtd->block_markbad(mtd, cxt->nextpage * OOPS_PAGE_SIZE);
-+ goto badblock;
-+ }
-+
-+ printk(KERN_DEBUG "mtdoops: Ready %d, %d \n", cxt->nextpage, cxt->nextcount);
-+
-+ cxt->ready = 1;
-+}
-+
-+static void mtdoops_workfunc(struct work_struct *work)
-+{
-+ struct mtdoops_context *cxt =
-+ container_of(work, struct mtdoops_context, work);
-+
-+ mtdoops_prepare(cxt);
-+}
-+
-+static int find_next_position(struct mtdoops_context *cxt)
-+{
-+ struct mtd_info *mtd = cxt->mtd;
-+ int page, maxpos = 0;
-+ u32 count, maxcount = 0xffffffff;
-+ size_t retlen;
-+
-+ for (page = 0; page < cxt->oops_pages; page++) {
-+ mtd->read(mtd, page * OOPS_PAGE_SIZE, 4, &retlen, (u_char *) &count);
-+ if (count == 0xffffffff)
-+ continue;
-+ if (maxcount == 0xffffffff) {
-+ maxcount = count;
-+ maxpos = page;
-+ } else if ((count < 0x40000000) && (maxcount > 0xc0000000)) {
-+ maxcount = count;
-+ maxpos = page;
-+ } else if ((count > maxcount) && (count < 0xc0000000)) {
-+ maxcount = count;
-+ maxpos = page;
-+ } else if ((count > maxcount) && (count > 0xc0000000)
-+ && (maxcount > 0x80000000)) {
-+ maxcount = count;
-+ maxpos = page;
-+ }
-+ }
-+ if (maxcount == 0xffffffff) {
-+ cxt->nextpage = 0;
-+ cxt->nextcount = 1;
-+ cxt->ready = 1;
-+ printk(KERN_DEBUG "mtdoops: Ready %d, %d (first init)\n",
-+ cxt->nextpage, cxt->nextcount);
-+ return 0;
-+ }
-+
-+ cxt->nextpage = maxpos;
-+ cxt->nextcount = maxcount;
-+
-+ return mtdoops_inc_counter(cxt);
-+}
-+
-+
-+static void mtdoops_notify_add(struct mtd_info *mtd)
-+{
-+ struct mtdoops_context *cxt = &oops_cxt;
-+ int ret;
-+
-+ if ((mtd->index != cxt->mtd_index) || cxt->mtd_index < 0)
-+ return;
-+
-+ if (mtd->size < (mtd->erasesize * 2)) {
-+ printk(KERN_ERR "MTD partition %d not big enough for mtdoops\n",
-+ mtd->index);
-+ return;
-+ }
-+
-+ cxt->mtd = mtd;
-+ cxt->oops_pages = mtd->size / OOPS_PAGE_SIZE;
-+
-+ ret = find_next_position(cxt);
-+ if (ret == 1)
-+ mtdoops_prepare(cxt);
-+
-+ printk(KERN_DEBUG "mtdoops: Attached to MTD device %d\n", mtd->index);
-+}
-+
-+static void mtdoops_notify_remove(struct mtd_info *mtd)
-+{
-+ struct mtdoops_context *cxt = &oops_cxt;
-+
-+ if ((mtd->index != cxt->mtd_index) || cxt->mtd_index < 0)
-+ return;
-+
-+ cxt->mtd = NULL;
-+ flush_scheduled_work();
-+}
-+
-+
-+static void
-+mtdoops_console_write(struct console *co, const char *s, unsigned int count)
-+{
-+ struct mtdoops_context *cxt = co->data;
-+ struct mtd_info *mtd = cxt->mtd;
-+ int i, ret;
-+
-+ if (!cxt->ready || !mtd)
-+ return;
-+
-+ if (!oops_in_progress && cxt->writecount != 0) {
-+ size_t retlen;
-+ if (cxt->writecount < OOPS_PAGE_SIZE)
-+ memset(cxt->oops_buf + cxt->writecount, 0xff,
-+ OOPS_PAGE_SIZE - cxt->writecount);
-+
-+ ret = mtd->write(mtd, cxt->nextpage * OOPS_PAGE_SIZE,
-+ OOPS_PAGE_SIZE, &retlen, cxt->oops_buf);
-+ cxt->ready = 0;
-+ cxt->writecount = 0;
-+
-+ if ((retlen != OOPS_PAGE_SIZE) || (ret < 0))
-+ printk(KERN_ERR "mtdoops: Write failure at %d (%d of %d"
-+ " written), err %d.\n",
-+ cxt->nextpage * OOPS_PAGE_SIZE, retlen,
-+ OOPS_PAGE_SIZE, ret);
-+
-+ ret = mtdoops_inc_counter(cxt);
-+ if (ret == 1)
-+ schedule_work(&cxt->work);
-+ }
-+
-+ if (!oops_in_progress)
-+ return;
-+
-+ if (cxt->writecount == 0) {
-+ u32 *stamp = cxt->oops_buf;
-+ *stamp = cxt->nextcount;
-+ cxt->writecount = 4;
-+ }
-+
-+ if ((count + cxt->writecount) > OOPS_PAGE_SIZE)
-+ count = OOPS_PAGE_SIZE - cxt->writecount;
-+
-+ for (i = 0; i < count; i++, s++)
-+ *((char *)(cxt->oops_buf) + cxt->writecount + i) = *s;
-+
-+ cxt->writecount = cxt->writecount + count;
-+}
-+
-+static int __init mtdoops_console_setup(struct console *co, char *options)
-+{
-+ struct mtdoops_context *cxt = co->data;
-+
-+ if (cxt->mtd_index != -1)
-+ return -EBUSY;
-+ if (co->index == -1)
-+ return -EINVAL;
-+
-+ cxt->mtd_index = co->index;
-+ return 0;
-+}
-+
-+static struct mtd_notifier mtdoops_notifier = {
-+ .add = mtdoops_notify_add,
-+ .remove = mtdoops_notify_remove,
-+};
-+
-+static struct console mtdoops_console = {
-+ .name = "ttyMTD",
-+ .write = mtdoops_console_write,
-+ .setup = mtdoops_console_setup,
-+ .flags = CON_PRINTBUFFER,
-+ .index = -1,
-+ .data = &oops_cxt,
-+};
-+
-+static int __init mtdoops_console_init(void)
-+{
-+ struct mtdoops_context *cxt = &oops_cxt;
-+
-+ cxt->mtd_index = -1;
-+ cxt->oops_buf = vmalloc(OOPS_PAGE_SIZE);
-+
-+ if (!cxt->oops_buf) {
-+ printk(KERN_ERR "Failed to allocate oops buffer workspace\n");
-+ return -ENOMEM;
-+ }
-+
-+ INIT_WORK(&cxt->work, mtdoops_workfunc);
-+
-+ register_console(&mtdoops_console);
-+ register_mtd_user(&mtdoops_notifier);
-+ return 0;
-+}
-+
-+static void __exit mtdoops_console_exit(void)
-+{
-+ struct mtdoops_context *cxt = &oops_cxt;
-+
-+ unregister_mtd_user(&mtdoops_notifier);
-+ unregister_console(&mtdoops_console);
-+ vfree(cxt->oops_buf);
-+}
-+
-+
-+subsys_initcall(mtdoops_console_init);
-+module_exit(mtdoops_console_exit);
-+
-+MODULE_LICENSE("GPL");
-+MODULE_AUTHOR("Richard Purdie <rpurdie@openedhand.com>");
-+MODULE_DESCRIPTION("MTD Oops/Panic console logger/driver");
-diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
-index f1d60b6..df25cab 100644
---- a/drivers/mtd/nand/Kconfig
-+++ b/drivers/mtd/nand/Kconfig
-@@ -134,10 +134,10 @@ config MTD_NAND_S3C2410_HWECC
-
- config MTD_NAND_NDFC
- tristate "NDFC NanD Flash Controller"
-- depends on 44x
-+ depends on 4xx
- select MTD_NAND_ECC_SMC
- help
-- NDFC Nand Flash Controllers are integrated in EP44x SoCs
-+ NDFC Nand Flash Controllers are integrated in IBM/AMCC's 4xx SoCs
-
- config MTD_NAND_S3C2410_CLKSTOP
- bool "S3C2410 NAND IDLE clock stop"
-@@ -237,7 +237,7 @@ config MTD_NAND_CAFE
- select REED_SOLOMON
- select REED_SOLOMON_DEC16
- help
-- Use NAND flash attached to the CAFÉ chip designed for the $100
-+ Use NAND flash attached to the CAFÉ chip designed for the OLPC
- laptop.
-
- config MTD_NAND_CS553X
-diff --git a/drivers/mtd/nand/cafe_nand.c b/drivers/mtd/nand/cafe_nand.c
-index cff969d..cca69b3 100644
---- a/drivers/mtd/nand/cafe_nand.c
-+++ b/drivers/mtd/nand/cafe_nand.c
-@@ -821,14 +821,53 @@ static struct pci_device_id cafe_nand_tbl[] = {
-
- MODULE_DEVICE_TABLE(pci, cafe_nand_tbl);
-
-+static int cafe_nand_resume(struct pci_dev *pdev)
-+{
-+ uint32_t timing1, timing2, timing3;
-+ uint32_t ctrl;
-+ struct mtd_info *mtd = pci_get_drvdata(pdev);
-+ struct cafe_priv *cafe = mtd->priv;
-+
-+ timing1 = timing2 = timing3 = 0xffffffff;
-+ /* Start off by resetting the NAND controller completely */
-+ cafe_writel(cafe, 1, NAND_RESET);
-+ cafe_writel(cafe, 0, NAND_RESET);
-+ cafe_writel(cafe, timing1, NAND_TIMING1);
-+ cafe_writel(cafe, timing2, NAND_TIMING2);
-+ cafe_writel(cafe, timing3, NAND_TIMING3);
-+ cafe_writel(cafe, 0xffffffff, NAND_IRQ_MASK);
-+
-+ /* Disable master reset, enable NAND clock */
-+ ctrl = cafe_readl(cafe, GLOBAL_CTRL);
-+ ctrl &= 0xffffeff0;
-+ ctrl |= 0x00007000;
-+ cafe_writel(cafe, ctrl | 0x05, GLOBAL_CTRL);
-+ cafe_writel(cafe, ctrl | 0x0a, GLOBAL_CTRL);
-+ cafe_writel(cafe, 0, NAND_DMA_CTRL);
-+ cafe_writel(cafe, 0x7006, GLOBAL_CTRL);
-+ cafe_writel(cafe, 0x700a, GLOBAL_CTRL);
-+
-+ /* Set up DMA address */
-+ cafe_writel(cafe, cafe->dmaaddr & 0xffffffff, NAND_DMA_ADDR0);
-+ if (sizeof(cafe->dmaaddr) > 4)
-+ /* Shift in two parts to shut the compiler up */
-+ cafe_writel(cafe, (cafe->dmaaddr >> 16) >> 16, NAND_DMA_ADDR1);
-+ else
-+ cafe_writel(cafe, 0, NAND_DMA_ADDR1);
-+
-+ /* Enable NAND IRQ in global IRQ mask register */
-+ cafe_writel(cafe, 0x80000007, GLOBAL_IRQ_MASK);
-+ return 0;
-+}
-+
- static struct pci_driver cafe_nand_pci_driver = {
- .name = "CAFÉ NAND",
- .id_table = cafe_nand_tbl,
- .probe = cafe_nand_probe,
- .remove = __devexit_p(cafe_nand_remove),
-+ .resume = cafe_nand_resume,
- #ifdef CONFIG_PMx
- .suspend = cafe_nand_suspend,
-- .resume = cafe_nand_resume,
- #endif
- };
-
-diff --git a/drivers/mtd/nand/ndfc.c b/drivers/mtd/nand/ndfc.c
-index fd7a8d5..1c0e89f 100644
---- a/drivers/mtd/nand/ndfc.c
-+++ b/drivers/mtd/nand/ndfc.c
-@@ -24,7 +24,11 @@
- #include <linux/platform_device.h>
-
- #include <asm/io.h>
-+#ifdef CONFIG_40x
-+#include <asm/ibm405.h>
-+#else
- #include <asm/ibm44x.h>
-+#endif
-
- struct ndfc_nand_mtd {
- struct mtd_info mtd;
-@@ -230,7 +234,11 @@ static int ndfc_nand_probe(struct platform_device *pdev)
- struct ndfc_controller *ndfc = &ndfc_ctrl;
- unsigned long long phys = settings->ndfc_erpn | res->start;
-
-+#ifndef CONFIG_PHYS_64BIT
-+ ndfc->ndfcbase = ioremap((phys_addr_t)phys, res->end - res->start + 1);
-+#else
- ndfc->ndfcbase = ioremap64(phys, res->end - res->start + 1);
-+#endif
- if (!ndfc->ndfcbase) {
- printk(KERN_ERR "NDFC: ioremap failed\n");
- return -EIO;
-diff --git a/drivers/mtd/onenand/Kconfig b/drivers/mtd/onenand/Kconfig
-index c257d39..cb41cbc 100644
---- a/drivers/mtd/onenand/Kconfig
-+++ b/drivers/mtd/onenand/Kconfig
-@@ -40,4 +40,27 @@ config MTD_ONENAND_OTP
-
- OTP block is fully-guaranteed to be a valid block.
-
-+config MTD_ONENAND_2X_PROGRAM
-+ bool "OneNAND 2X program support"
-+ help
-+ The 2X Program is an extension of Program Operation.
-+ Since the device is equipped with two DataRAMs, and two-plane NAND
-+ Flash memory array, these two component enables simultaneous program
-+ of 4KiB. Plane1 has only even blocks such as block0, block2, block4
-+ while Plane2 has only odd blocks such as block1, block3, block5.
-+ So MTD regards it as 4KiB page size and 256KiB block size
-+
-+ Now the following chips support it. (KFXXX16Q2M)
-+ Demux: KFG2G16Q2M, KFH4G16Q2M, KFW8G16Q2M,
-+ Mux: KFM2G16Q2M, KFN4G16Q2M,
-+
-+ And more recent chips
-+
-+config MTD_ONENAND_SIM
-+ tristate "OneNAND simulator support"
-+ depends on MTD_PARTITIONS
-+ help
-+ The simulator may simulate various OneNAND flash chips for the
-+ OneNAND MTD layer.
-+
- endif # MTD_ONENAND
-diff --git a/drivers/mtd/onenand/Makefile b/drivers/mtd/onenand/Makefile
-index 269cfe4..4d2eacf 100644
---- a/drivers/mtd/onenand/Makefile
-+++ b/drivers/mtd/onenand/Makefile
-@@ -8,4 +8,7 @@ obj-$(CONFIG_MTD_ONENAND) += onenand.o
- # Board specific.
- obj-$(CONFIG_MTD_ONENAND_GENERIC) += generic.o
-
-+# Simulator
-+obj-$(CONFIG_MTD_ONENAND_SIM) += onenand_sim.o
-+
- onenand-objs = onenand_base.o onenand_bbt.o
-diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c
-index 0537fac..7d194cf 100644
---- a/drivers/mtd/onenand/onenand_base.c
-+++ b/drivers/mtd/onenand/onenand_base.c
-@@ -206,6 +206,15 @@ static int onenand_command(struct mtd_info *mtd, int cmd, loff_t addr, size_t le
- default:
- block = (int) (addr >> this->erase_shift);
- page = (int) (addr >> this->page_shift);
-+
-+ if (ONENAND_IS_2PLANE(this)) {
-+ /* Make the even block number */
-+ block &= ~1;
-+ /* Is it the odd plane? */
-+ if (addr & this->writesize)
-+ block++;
-+ page >>= 1;
-+ }
- page &= this->page_mask;
- break;
- }
-@@ -216,8 +225,12 @@ static int onenand_command(struct mtd_info *mtd, int cmd, loff_t addr, size_t le
- value = onenand_bufferram_address(this, block);
- this->write_word(value, this->base + ONENAND_REG_START_ADDRESS2);
-
-- /* Switch to the next data buffer */
-- ONENAND_SET_NEXT_BUFFERRAM(this);
-+ if (ONENAND_IS_2PLANE(this))
-+ /* It is always BufferRAM0 */
-+ ONENAND_SET_BUFFERRAM0(this);
-+ else
-+ /* Switch to the next data buffer */
-+ ONENAND_SET_NEXT_BUFFERRAM(this);
-
- return 0;
- }
-@@ -247,6 +260,8 @@ static int onenand_command(struct mtd_info *mtd, int cmd, loff_t addr, size_t le
- break;
-
- default:
-+ if (ONENAND_IS_2PLANE(this) && cmd == ONENAND_CMD_PROG)
-+ cmd = ONENAND_CMD_2X_PROG;
- dataram = ONENAND_CURRENT_BUFFERRAM(this);
- break;
- }
-@@ -445,8 +460,9 @@ static inline int onenand_bufferram_offset(struct mtd_info *mtd, int area)
- struct onenand_chip *this = mtd->priv;
-
- if (ONENAND_CURRENT_BUFFERRAM(this)) {
-+ /* Note: the 'this->writesize' is a real page size */
- if (area == ONENAND_DATARAM)
-- return mtd->writesize;
-+ return this->writesize;
- if (area == ONENAND_SPARERAM)
- return mtd->oobsize;
- }
-@@ -572,6 +588,30 @@ static int onenand_write_bufferram(struct mtd_info *mtd, int area,
- }
-
- /**
-+ * onenand_get_2x_blockpage - [GENERIC] Get blockpage at 2x program mode
-+ * @param mtd MTD data structure
-+ * @param addr address to check
-+ * @return blockpage address
-+ *
-+ * Get blockpage address at 2x program mode
-+ */
-+static int onenand_get_2x_blockpage(struct mtd_info *mtd, loff_t addr)
-+{
-+ struct onenand_chip *this = mtd->priv;
-+ int blockpage, block, page;
-+
-+ /* Calculate the even block number */
-+ block = (int) (addr >> this->erase_shift) & ~1;
-+ /* Is it the odd plane? */
-+ if (addr & this->writesize)
-+ block++;
-+ page = (int) (addr >> (this->page_shift + 1)) & this->page_mask;
-+ blockpage = (block << 7) | page;
-+
-+ return blockpage;
-+}
-+
-+/**
- * onenand_check_bufferram - [GENERIC] Check BufferRAM information
- * @param mtd MTD data structure
- * @param addr address to check
-@@ -585,7 +625,10 @@ static int onenand_check_bufferram(struct mtd_info *mtd, loff_t addr)
- int blockpage, found = 0;
- unsigned int i;
-
-- blockpage = (int) (addr >> this->page_shift);
-+ if (ONENAND_IS_2PLANE(this))
-+ blockpage = onenand_get_2x_blockpage(mtd, addr);
-+ else
-+ blockpage = (int) (addr >> this->page_shift);
-
- /* Is there valid data? */
- i = ONENAND_CURRENT_BUFFERRAM(this);
-@@ -625,7 +668,10 @@ static void onenand_update_bufferram(struct mtd_info *mtd, loff_t addr,
- int blockpage;
- unsigned int i;
-
-- blockpage = (int) (addr >> this->page_shift);
-+ if (ONENAND_IS_2PLANE(this))
-+ blockpage = onenand_get_2x_blockpage(mtd, addr);
-+ else
-+ blockpage = (int) (addr >> this->page_shift);
-
- /* Invalidate another BufferRAM */
- i = ONENAND_NEXT_BUFFERRAM(this);
-@@ -734,6 +780,7 @@ static int onenand_read(struct mtd_info *mtd, loff_t from, size_t len,
- int read = 0, column;
- int thislen;
- int ret = 0, boundary = 0;
-+ int writesize = this->writesize;
-
- DEBUG(MTD_DEBUG_LEVEL3, "onenand_read: from = 0x%08x, len = %i\n", (unsigned int) from, (int) len);
-
-@@ -754,22 +801,22 @@ static int onenand_read(struct mtd_info *mtd, loff_t from, size_t len,
- /* Do first load to bufferRAM */
- if (read < len) {
- if (!onenand_check_bufferram(mtd, from)) {
-- this->command(mtd, ONENAND_CMD_READ, from, mtd->writesize);
-+ this->command(mtd, ONENAND_CMD_READ, from, writesize);
- ret = this->wait(mtd, FL_READING);
- onenand_update_bufferram(mtd, from, !ret);
- }
- }
-
-- thislen = min_t(int, mtd->writesize, len - read);
-- column = from & (mtd->writesize - 1);
-- if (column + thislen > mtd->writesize)
-- thislen = mtd->writesize - column;
-+ thislen = min_t(int, writesize, len - read);
-+ column = from & (writesize - 1);
-+ if (column + thislen > writesize)
-+ thislen = writesize - column;
-
- while (!ret) {
- /* If there is more to load then start next load */
- from += thislen;
- if (read + thislen < len) {
-- this->command(mtd, ONENAND_CMD_READ, from, mtd->writesize);
-+ this->command(mtd, ONENAND_CMD_READ, from, writesize);
- /*
- * Chip boundary handling in DDP
- * Now we issued chip 1 read and pointed chip 1
-@@ -794,7 +841,7 @@ static int onenand_read(struct mtd_info *mtd, loff_t from, size_t len,
- this->write_word(ONENAND_DDP_CHIP1, this->base + ONENAND_REG_START_ADDRESS2);
- ONENAND_SET_NEXT_BUFFERRAM(this);
- buf += thislen;
-- thislen = min_t(int, mtd->writesize, len - read);
-+ thislen = min_t(int, writesize, len - read);
- column = 0;
- cond_resched();
- /* Now wait for load */
-@@ -1079,7 +1126,7 @@ int onenand_bbt_read_oob(struct mtd_info *mtd, loff_t from,
- /* Read more? */
- if (read < len) {
- /* Update Page size */
-- from += mtd->writesize;
-+ from += this->writesize;
- column = 0;
- }
- }
-@@ -1135,12 +1182,12 @@ static int onenand_verify(struct mtd_info *mtd, const u_char *buf, loff_t addr,
- int thislen, column;
-
- while (len != 0) {
-- thislen = min_t(int, mtd->writesize, len);
-- column = addr & (mtd->writesize - 1);
-- if (column + thislen > mtd->writesize)
-- thislen = mtd->writesize - column;
-+ thislen = min_t(int, this->writesize, len);
-+ column = addr & (this->writesize - 1);
-+ if (column + thislen > this->writesize)
-+ thislen = this->writesize - column;
-
-- this->command(mtd, ONENAND_CMD_READ, addr, mtd->writesize);
-+ this->command(mtd, ONENAND_CMD_READ, addr, this->writesize);
-
- onenand_update_bufferram(mtd, addr, 0);
-
-@@ -1236,6 +1283,10 @@ static int onenand_write(struct mtd_info *mtd, loff_t to, size_t len,
-
- /* In partial page write we don't update bufferram */
- onenand_update_bufferram(mtd, to, !ret && !subpage);
-+ if (ONENAND_IS_2PLANE(this)) {
-+ ONENAND_SET_BUFFERRAM1(this);
-+ onenand_update_bufferram(mtd, to + this->writesize, !ret && !subpage);
-+ }
-
- if (ret) {
- printk(KERN_ERR "onenand_write: write filaed %d\n", ret);
-@@ -1384,6 +1435,10 @@ static int onenand_do_write_oob(struct mtd_info *mtd, loff_t to, size_t len,
- this->command(mtd, ONENAND_CMD_PROGOOB, to, mtd->oobsize);
-
- onenand_update_bufferram(mtd, to, 0);
-+ if (ONENAND_IS_2PLANE(this)) {
-+ ONENAND_SET_BUFFERRAM1(this);
-+ onenand_update_bufferram(mtd, to + this->writesize, 0);
-+ }
-
- ret = this->wait(mtd, FL_WRITING);
- if (ret) {
-@@ -2107,6 +2162,7 @@ static int onenand_lock_user_prot_reg(struct mtd_info *mtd, loff_t from,
- *
- * Check and set OneNAND features
- * - lock scheme
-+ * - two plane
- */
- static void onenand_check_features(struct mtd_info *mtd)
- {
-@@ -2118,19 +2174,35 @@ static void onenand_check_features(struct mtd_info *mtd)
- process = this->version_id >> ONENAND_VERSION_PROCESS_SHIFT;
-
- /* Lock scheme */
-- if (density >= ONENAND_DEVICE_DENSITY_1Gb) {
-+ switch (density) {
-+ case ONENAND_DEVICE_DENSITY_4Gb:
-+ this->options |= ONENAND_HAS_2PLANE;
-+
-+ case ONENAND_DEVICE_DENSITY_2Gb:
-+ /* 2Gb DDP don't have 2 plane */
-+ if (!ONENAND_IS_DDP(this))
-+ this->options |= ONENAND_HAS_2PLANE;
-+ this->options |= ONENAND_HAS_UNLOCK_ALL;
-+
-+ case ONENAND_DEVICE_DENSITY_1Gb:
- /* A-Die has all block unlock */
-- if (process) {
-- printk(KERN_DEBUG "Chip support all block unlock\n");
-+ if (process)
- this->options |= ONENAND_HAS_UNLOCK_ALL;
-- }
-- } else {
-- /* Some OneNAND has continues lock scheme */
-- if (!process) {
-- printk(KERN_DEBUG "Lock scheme is Continues Lock\n");
-+ break;
-+
-+ default:
-+ /* Some OneNAND has continuous lock scheme */
-+ if (!process)
- this->options |= ONENAND_HAS_CONT_LOCK;
-- }
-+ break;
- }
-+
-+ if (this->options & ONENAND_HAS_CONT_LOCK)
-+ printk(KERN_DEBUG "Lock scheme is Continuous Lock\n");
-+ if (this->options & ONENAND_HAS_UNLOCK_ALL)
-+ printk(KERN_DEBUG "Chip support all block unlock\n");
-+ if (this->options & ONENAND_HAS_2PLANE)
-+ printk(KERN_DEBUG "Chip has 2 plane\n");
- }
-
- /**
-@@ -2257,6 +2329,8 @@ static int onenand_probe(struct mtd_info *mtd)
- this->erase_shift = ffs(mtd->erasesize) - 1;
- this->page_shift = ffs(mtd->writesize) - 1;
- this->page_mask = (1 << (this->erase_shift - this->page_shift)) - 1;
-+ /* It's real page size */
-+ this->writesize = mtd->writesize;
-
- /* REVIST: Multichip handling */
-
-@@ -2265,6 +2339,17 @@ static int onenand_probe(struct mtd_info *mtd)
- /* Check OneNAND features */
- onenand_check_features(mtd);
-
-+ /*
-+ * We emulate the 4KiB page and 256KiB erase block size
-+ * But oobsize is still 64 bytes.
-+ * It is only valid if you turn on 2X program support,
-+ * Otherwise it will be ignored by compiler.
-+ */
-+ if (ONENAND_IS_2PLANE(this)) {
-+ mtd->writesize <<= 1;
-+ mtd->erasesize <<= 1;
-+ }
-+
- return 0;
- }
-
-diff --git a/drivers/mtd/onenand/onenand_sim.c b/drivers/mtd/onenand/onenand_sim.c
-new file mode 100644
-index 0000000..b806673
---- /dev/null
-+++ b/drivers/mtd/onenand/onenand_sim.c
-@@ -0,0 +1,495 @@
-+/*
-+ * linux/drivers/mtd/onenand/onenand_sim.c
-+ *
-+ * The OneNAND simulator
-+ *
-+ * Copyright © 2005-2007 Samsung Electronics
-+ * Kyungmin Park <kyungmin.park@samsung.com>
-+ *
-+ * This program is free software; you can redistribute it and/or modify
-+ * it under the terms of the GNU General Public License version 2 as
-+ * published by the Free Software Foundation.
-+ */
-+
-+#include <linux/kernel.h>
-+#include <linux/module.h>
-+#include <linux/init.h>
-+#include <linux/vmalloc.h>
-+#include <linux/mtd/mtd.h>
-+#include <linux/mtd/partitions.h>
-+#include <linux/mtd/onenand.h>
-+
-+#include <linux/io.h>
-+
-+#ifndef CONFIG_ONENAND_SIM_MANUFACTURER
-+#define CONFIG_ONENAND_SIM_MANUFACTURER 0xec
-+#endif
-+#ifndef CONFIG_ONENAND_SIM_DEVICE_ID
-+#define CONFIG_ONENAND_SIM_DEVICE_ID 0x04
-+#endif
-+#ifndef CONFIG_ONENAND_SIM_VERSION_ID
-+#define CONFIG_ONENAND_SIM_VERSION_ID 0x1e
-+#endif
-+
-+static int manuf_id = CONFIG_ONENAND_SIM_MANUFACTURER;
-+static int device_id = CONFIG_ONENAND_SIM_DEVICE_ID;
-+static int version_id = CONFIG_ONENAND_SIM_VERSION_ID;
-+
-+struct onenand_flash {
-+ void __iomem *base;
-+ void __iomem *data;
-+};
-+
-+#define ONENAND_CORE(flash) (flash->data)
-+#define ONENAND_CORE_SPARE(flash, this, offset) \
-+ ((flash->data) + (this->chipsize) + (offset >> 5))
-+
-+#define ONENAND_MAIN_AREA(this, offset) \
-+ (this->base + ONENAND_DATARAM + offset)
-+
-+#define ONENAND_SPARE_AREA(this, offset) \
-+ (this->base + ONENAND_SPARERAM + offset)
-+
-+#define ONENAND_GET_WP_STATUS(this) \
-+ (readw(this->base + ONENAND_REG_WP_STATUS))
-+
-+#define ONENAND_SET_WP_STATUS(v, this) \
-+ (writew(v, this->base + ONENAND_REG_WP_STATUS))
-+
-+/* It has all 0xff chars */
-+#define MAX_ONENAND_PAGESIZE (2048 + 64)
-+static unsigned char *ffchars;
-+
-+static struct mtd_partition os_partitions[] = {
-+ {
-+ .name = "OneNAND simulator partition",
-+ .offset = 0,
-+ .size = MTDPART_SIZ_FULL,
-+ },
-+};
-+
-+/*
-+ * OneNAND simulator mtd
-+ */
-+struct onenand_info {
-+ struct mtd_info mtd;
-+ struct mtd_partition *parts;
-+ struct onenand_chip onenand;
-+ struct onenand_flash flash;
-+};
-+
-+struct onenand_info *info;
-+
-+#define DPRINTK(format, args...) \
-+do { \
-+ printk(KERN_DEBUG "%s[%d]: " format "\n", __func__, \
-+ __LINE__, ##args); \
-+} while (0)
-+
-+/**
-+ * onenand_lock_handle - Handle Lock scheme
-+ * @param this OneNAND device structure
-+ * @param cmd The command to be sent
-+ *
-+ * Send lock command to OneNAND device.
-+ * The lock scheme is depends on chip type.
-+ */
-+static void onenand_lock_handle(struct onenand_chip *this, int cmd)
-+{
-+ int block_lock_scheme;
-+ int status;
-+
-+ status = ONENAND_GET_WP_STATUS(this);
-+ block_lock_scheme = !(this->options & ONENAND_HAS_CONT_LOCK);
-+
-+ switch (cmd) {
-+ case ONENAND_CMD_UNLOCK:
-+ if (block_lock_scheme)
-+ ONENAND_SET_WP_STATUS(ONENAND_WP_US, this);
-+ else
-+ ONENAND_SET_WP_STATUS(status | ONENAND_WP_US, this);
-+ break;
-+
-+ case ONENAND_CMD_LOCK:
-+ if (block_lock_scheme)
-+ ONENAND_SET_WP_STATUS(ONENAND_WP_LS, this);
-+ else
-+ ONENAND_SET_WP_STATUS(status | ONENAND_WP_LS, this);
-+ break;
-+
-+ case ONENAND_CMD_LOCK_TIGHT:
-+ if (block_lock_scheme)
-+ ONENAND_SET_WP_STATUS(ONENAND_WP_LTS, this);
-+ else
-+ ONENAND_SET_WP_STATUS(status | ONENAND_WP_LTS, this);
-+ break;
-+
-+ default:
-+ break;
-+ }
-+}
-+
-+/**
-+ * onenand_bootram_handle - Handle BootRAM area
-+ * @param this OneNAND device structure
-+ * @param cmd The command to be sent
-+ *
-+ * Emulate BootRAM area. It is possible to do basic operation using BootRAM.
-+ */
-+static void onenand_bootram_handle(struct onenand_chip *this, int cmd)
-+{
-+ switch (cmd) {
-+ case ONENAND_CMD_READID:
-+ writew(manuf_id, this->base);
-+ writew(device_id, this->base + 2);
-+ writew(version_id, this->base + 4);
-+ break;
-+
-+ default:
-+ /* REVIST: Handle other commands */
-+ break;
-+ }
-+}
-+
-+/**
-+ * onenand_update_interrupt - Set interrupt register
-+ * @param this OneNAND device structure
-+ * @param cmd The command to be sent
-+ *
-+ * Update interrupt register. The status is depends on command.
-+ */
-+static void onenand_update_interrupt(struct onenand_chip *this, int cmd)
-+{
-+ int interrupt = ONENAND_INT_MASTER;
-+
-+ switch (cmd) {
-+ case ONENAND_CMD_READ:
-+ case ONENAND_CMD_READOOB:
-+ interrupt |= ONENAND_INT_READ;
-+ break;
-+
-+ case ONENAND_CMD_PROG:
-+ case ONENAND_CMD_PROGOOB:
-+ interrupt |= ONENAND_INT_WRITE;
-+ break;
-+
-+ case ONENAND_CMD_ERASE:
-+ interrupt |= ONENAND_INT_ERASE;
-+ break;
-+
-+ case ONENAND_CMD_RESET:
-+ interrupt |= ONENAND_INT_RESET;
-+ break;
-+
-+ default:
-+ break;
-+ }
-+
-+ writew(interrupt, this->base + ONENAND_REG_INTERRUPT);
-+}
-+
-+/**
-+ * onenand_check_overwrite - Check over-write if happend
-+ * @param dest The destination pointer
-+ * @param src The source pointer
-+ * @param count The length to be check
-+ * @return 0 on same, otherwise 1
-+ *
-+ * Compare the source with destination
-+ */
-+static int onenand_check_overwrite(void *dest, void *src, size_t count)
-+{
-+ unsigned int *s = (unsigned int *) src;
-+ unsigned int *d = (unsigned int *) dest;
-+ int i;
-+
-+ count >>= 2;
-+ for (i = 0; i < count; i++)
-+ if ((*s++ ^ *d++) != 0)
-+ return 1;
-+
-+ return 0;
-+}
-+
-+/**
-+ * onenand_data_handle - Handle OneNAND Core and DataRAM
-+ * @param this OneNAND device structure
-+ * @param cmd The command to be sent
-+ * @param dataram Which dataram used
-+ * @param offset The offset to OneNAND Core
-+ *
-+ * Copy data from OneNAND Core to DataRAM (read)
-+ * Copy data from DataRAM to OneNAND Core (write)
-+ * Erase the OneNAND Core (erase)
-+ */
-+static void onenand_data_handle(struct onenand_chip *this, int cmd,
-+ int dataram, unsigned int offset)
-+{
-+ struct mtd_info *mtd = &info->mtd;
-+ struct onenand_flash *flash = this->priv;
-+ int main_offset, spare_offset;
-+ void __iomem *src;
-+ void __iomem *dest;
-+ unsigned int i;
-+
-+ if (dataram) {
-+ main_offset = mtd->writesize;
-+ spare_offset = mtd->oobsize;
-+ } else {
-+ main_offset = 0;
-+ spare_offset = 0;
-+ }
-+
-+ switch (cmd) {
-+ case ONENAND_CMD_READ:
-+ src = ONENAND_CORE(flash) + offset;
-+ dest = ONENAND_MAIN_AREA(this, main_offset);
-+ memcpy(dest, src, mtd->writesize);
-+ /* Fall through */
-+
-+ case ONENAND_CMD_READOOB:
-+ src = ONENAND_CORE_SPARE(flash, this, offset);
-+ dest = ONENAND_SPARE_AREA(this, spare_offset);
-+ memcpy(dest, src, mtd->oobsize);
-+ break;
-+
-+ case ONENAND_CMD_PROG:
-+ src = ONENAND_MAIN_AREA(this, main_offset);
-+ dest = ONENAND_CORE(flash) + offset;
-+ /* To handle partial write */
-+ for (i = 0; i < (1 << mtd->subpage_sft); i++) {
-+ int off = i * this->subpagesize;
-+ if (!memcmp(src + off, ffchars, this->subpagesize))
-+ continue;
-+ if (memcmp(dest + off, ffchars, this->subpagesize) &&
-+ onenand_check_overwrite(dest + off, src + off, this->subpagesize))
-+ printk(KERN_ERR "over-write happend at 0x%08x\n", offset);
-+ memcpy(dest + off, src + off, this->subpagesize);
-+ }
-+ /* Fall through */
-+
-+ case ONENAND_CMD_PROGOOB:
-+ src = ONENAND_SPARE_AREA(this, spare_offset);
-+ /* Check all data is 0xff chars */
-+ if (!memcmp(src, ffchars, mtd->oobsize))
-+ break;
-+
-+ dest = ONENAND_CORE_SPARE(flash, this, offset);
-+ if (memcmp(dest, ffchars, mtd->oobsize) &&
-+ onenand_check_overwrite(dest, src, mtd->oobsize))
-+ printk(KERN_ERR "OOB: over-write happend at 0x%08x\n",
-+ offset);
-+ memcpy(dest, src, mtd->oobsize);
-+ break;
-+
-+ case ONENAND_CMD_ERASE:
-+ memset(ONENAND_CORE(flash) + offset, 0xff, mtd->erasesize);
-+ memset(ONENAND_CORE_SPARE(flash, this, offset), 0xff,
-+ (mtd->erasesize >> 5));
-+ break;
-+
-+ default:
-+ break;
-+ }
-+}
-+
-+/**
-+ * onenand_command_handle - Handle command
-+ * @param this OneNAND device structure
-+ * @param cmd The command to be sent
-+ *
-+ * Emulate OneNAND command.
-+ */
-+static void onenand_command_handle(struct onenand_chip *this, int cmd)
-+{
-+ unsigned long offset = 0;
-+ int block = -1, page = -1, bufferram = -1;
-+ int dataram = 0;
-+
-+ switch (cmd) {
-+ case ONENAND_CMD_UNLOCK:
-+ case ONENAND_CMD_LOCK:
-+ case ONENAND_CMD_LOCK_TIGHT:
-+ case ONENAND_CMD_UNLOCK_ALL:
-+ onenand_lock_handle(this, cmd);
-+ break;
-+
-+ case ONENAND_CMD_BUFFERRAM:
-+ /* Do nothing */
-+ return;
-+
-+ default:
-+ block = (int) readw(this->base + ONENAND_REG_START_ADDRESS1);
-+ if (block & (1 << ONENAND_DDP_SHIFT)) {
-+ block &= ~(1 << ONENAND_DDP_SHIFT);
-+ /* The half of chip block */
-+ block += this->chipsize >> (this->erase_shift + 1);
-+ }
-+ if (cmd == ONENAND_CMD_ERASE)
-+ break;
-+
-+ page = (int) readw(this->base + ONENAND_REG_START_ADDRESS8);
-+ page = (page >> ONENAND_FPA_SHIFT);
-+ bufferram = (int) readw(this->base + ONENAND_REG_START_BUFFER);
-+ bufferram >>= ONENAND_BSA_SHIFT;
-+ bufferram &= ONENAND_BSA_DATARAM1;
-+ dataram = (bufferram == ONENAND_BSA_DATARAM1) ? 1 : 0;
-+ break;
-+ }
-+
-+ if (block != -1)
-+ offset += block << this->erase_shift;
-+
-+ if (page != -1)
-+ offset += page << this->page_shift;
-+
-+ onenand_data_handle(this, cmd, dataram, offset);
-+
-+ onenand_update_interrupt(this, cmd);
-+}
-+
-+/**
-+ * onenand_writew - [OneNAND Interface] Emulate write operation
-+ * @param value value to write
-+ * @param addr address to write
-+ *
-+ * Write OneNAND register with value
-+ */
-+static void onenand_writew(unsigned short value, void __iomem * addr)
-+{
-+ struct onenand_chip *this = info->mtd.priv;
-+
-+ /* BootRAM handling */
-+ if (addr < this->base + ONENAND_DATARAM) {
-+ onenand_bootram_handle(this, value);
-+ return;
-+ }
-+ /* Command handling */
-+ if (addr == this->base + ONENAND_REG_COMMAND)
-+ onenand_command_handle(this, value);
-+
-+ writew(value, addr);
-+}
-+
-+/**
-+ * flash_init - Initialize OneNAND simulator
-+ * @param flash OneNAND simulaotr data strucutres
-+ *
-+ * Initialize OneNAND simulator.
-+ */
-+static int __init flash_init(struct onenand_flash *flash)
-+{
-+ int density, size;
-+ int buffer_size;
-+
-+ flash->base = kzalloc(131072, GFP_KERNEL);
-+ if (!flash->base) {
-+ printk(KERN_ERR "Unable to allocate base address.\n");
-+ return -ENOMEM;
-+ }
-+
-+ density = device_id >> ONENAND_DEVICE_DENSITY_SHIFT;
-+ size = ((16 << 20) << density);
-+
-+ ONENAND_CORE(flash) = vmalloc(size + (size >> 5));
-+ if (!ONENAND_CORE(flash)) {
-+ printk(KERN_ERR "Unable to allocate nand core address.\n");
-+ kfree(flash->base);
-+ return -ENOMEM;
-+ }
-+
-+ memset(ONENAND_CORE(flash), 0xff, size + (size >> 5));
-+
-+ /* Setup registers */
-+ writew(manuf_id, flash->base + ONENAND_REG_MANUFACTURER_ID);
-+ writew(device_id, flash->base + ONENAND_REG_DEVICE_ID);
-+ writew(version_id, flash->base + ONENAND_REG_VERSION_ID);
-+
-+ if (density < 2)
-+ buffer_size = 0x0400; /* 1KiB page */
-+ else
-+ buffer_size = 0x0800; /* 2KiB page */
-+ writew(buffer_size, flash->base + ONENAND_REG_DATA_BUFFER_SIZE);
-+
-+ return 0;
-+}
-+
-+/**
-+ * flash_exit - Clean up OneNAND simulator
-+ * @param flash OneNAND simulaotr data strucutres
-+ *
-+ * Clean up OneNAND simulator.
-+ */
-+static void flash_exit(struct onenand_flash *flash)
-+{
-+ vfree(ONENAND_CORE(flash));
-+ kfree(flash->base);
-+ kfree(flash);
-+}
-+
-+static int __init onenand_sim_init(void)
-+{
-+ /* Allocate all 0xff chars pointer */
-+ ffchars = kmalloc(MAX_ONENAND_PAGESIZE, GFP_KERNEL);
-+ if (!ffchars) {
-+ printk(KERN_ERR "Unable to allocate ff chars.\n");
-+ return -ENOMEM;
-+ }
-+ memset(ffchars, 0xff, MAX_ONENAND_PAGESIZE);
-+
-+ /* Allocate OneNAND simulator mtd pointer */
-+ info = kzalloc(sizeof(struct onenand_info), GFP_KERNEL);
-+ if (!info) {
-+ printk(KERN_ERR "Unable to allocate core structures.\n");
-+ kfree(ffchars);
-+ return -ENOMEM;
-+ }
-+
-+ /* Override write_word function */
-+ info->onenand.write_word = onenand_writew;
-+
-+ if (flash_init(&info->flash)) {
-+ printk(KERN_ERR "Unable to allocat flash.\n");
-+ kfree(ffchars);
-+ kfree(info);
-+ return -ENOMEM;
-+ }
-+
-+ info->parts = os_partitions;
-+
-+ info->onenand.base = info->flash.base;
-+ info->onenand.priv = &info->flash;
-+
-+ info->mtd.name = "OneNAND simulator";
-+ info->mtd.priv = &info->onenand;
-+ info->mtd.owner = THIS_MODULE;
-+
-+ if (onenand_scan(&info->mtd, 1)) {
-+ flash_exit(&info->flash);
-+ kfree(ffchars);
-+ kfree(info);
-+ return -ENXIO;
-+ }
-+
-+ add_mtd_partitions(&info->mtd, info->parts, ARRAY_SIZE(os_partitions));
-+
-+ return 0;
-+}
-+
-+static void __exit onenand_sim_exit(void)
-+{
-+ struct onenand_chip *this = info->mtd.priv;
-+ struct onenand_flash *flash = this->priv;
-+
-+ onenand_release(&info->mtd);
-+ flash_exit(flash);
-+ kfree(ffchars);
-+ kfree(info);
-+}
-+
-+module_init(onenand_sim_init);
-+module_exit(onenand_sim_exit);
-+
-+MODULE_AUTHOR("Kyungmin Park <kyungmin.park@samsung.com>");
-+MODULE_DESCRIPTION("The OneNAND flash simulator");
-+MODULE_LICENSE("GPL");
-diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
-index 1938d6d..cc01dbd 100644
---- a/drivers/net/forcedeth.c
-+++ b/drivers/net/forcedeth.c
-@@ -3556,10 +3556,12 @@ static int nv_request_irq(struct net_device *dev, int intr_test)
- }
- if (ret != 0 && np->msi_flags & NV_MSI_CAPABLE) {
- if ((ret = pci_enable_msi(np->pci_dev)) == 0) {
-+ pci_intx(np->pci_dev, 0);
- np->msi_flags |= NV_MSI_ENABLED;
- if (request_irq(np->pci_dev->irq, handler, IRQF_SHARED, dev->name, dev) != 0) {
- printk(KERN_INFO "forcedeth: request_irq failed %d\n", ret);
- pci_disable_msi(np->pci_dev);
-+ pci_intx(np->pci_dev, 1);
- np->msi_flags &= ~NV_MSI_ENABLED;
- goto out_err;
- }
-@@ -3601,6 +3603,7 @@ static void nv_free_irq(struct net_device *dev)
- free_irq(np->pci_dev->irq, dev);
- if (np->msi_flags & NV_MSI_ENABLED) {
- pci_disable_msi(np->pci_dev);
-+ pci_intx(np->pci_dev, 1);
- np->msi_flags &= ~NV_MSI_ENABLED;
- }
- }
-diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
-index 7dcaa09..eb69d4d 100644
---- a/drivers/pci/quirks.c
-+++ b/drivers/pci/quirks.c
-@@ -1390,6 +1390,17 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x260a, quirk_intel_pcie_pm);
- DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x260b, quirk_intel_pcie_pm);
-
- /*
-+ * According to Tom Sylla, the Geode does not support PCI power management
-+ * transition, so we shouldn't need the D3hot delay.
-+ */
-+static void __init quirk_geode_pci_pm(struct pci_dev *dev)
-+{
-+ pci_pm_d3_delay = 0;
-+}
-+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5530_LEGACY, quirk_geode_pci_pm);
-+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA, quirk_geode_pci_pm);
-+
-+/*
- * Toshiba TC86C001 IDE controller reports the standard 8-byte BAR0 size
- * but the PIO transfers won't work if BAR0 falls at the odd 8 bytes.
- * Re-allocate the region if needed...
-diff --git a/drivers/sysprof/Kconfig b/drivers/sysprof/Kconfig
-new file mode 100644
-index 0000000..b99c13a
---- /dev/null
-+++ b/drivers/sysprof/Kconfig
-@@ -0,0 +1,12 @@
-+
-+menu "Sysprof"
-+
-+config SYSPROF
-+ tristate "Sysprof support"
-+ help
-+ Say M here to include the sysprof-module.
-+
-+ Sysprof is a sampling profiler that uses a kernel module,
-+ sysprof-module, to generate stacktraces which are then interpreted by
-+ the userspace program "sysprof".
-+endmenu
-diff --git a/drivers/sysprof/Makefile b/drivers/sysprof/Makefile
-new file mode 100644
-index 0000000..cd465e9
---- /dev/null
-+++ b/drivers/sysprof/Makefile
-@@ -0,0 +1 @@
-+obj-$(CONFIG_SYSPROF) += sysprof-module.o
-diff --git a/drivers/sysprof/config.h b/drivers/sysprof/config.h
-new file mode 100644
-index 0000000..bb62689
---- /dev/null
-+++ b/drivers/sysprof/config.h
-@@ -0,0 +1,23 @@
-+/* config.h. Generated by configure. */
-+/* config.h.in. Generated from configure.ac by autoheader. */
-+
-+/* Look for global separate debug info in this path */
-+#define DEBUGDIR "/usr/local/lib/debug"
-+
-+/* Define to 1 if you have the `iberty' library (-liberty). */
-+/* #undef HAVE_LIBIBERTY */
-+
-+/* Define to the address where bug reports for this package should be sent. */
-+#define PACKAGE_BUGREPORT ""
-+
-+/* Define to the full name of this package. */
-+#define PACKAGE_NAME "sysprof"
-+
-+/* Define to the full name and version of this package. */
-+#define PACKAGE_STRING "sysprof 1.0.8"
-+
-+/* Define to the one symbol short name of this package. */
-+#define PACKAGE_TARNAME "sysprof"
-+
-+/* Define to the version of this package. */
-+#define PACKAGE_VERSION "1.0.8"
-diff --git a/drivers/sysprof/sysprof-module.c b/drivers/sysprof/sysprof-module.c
-new file mode 100644
-index 0000000..36e0b51
---- /dev/null
-+++ b/drivers/sysprof/sysprof-module.c
-@@ -0,0 +1,271 @@
-+/* -*- c-basic-offset: 8 -*- */
-+
-+/* Sysprof -- Sampling, systemwide CPU profiler
-+ * Copyright 2004, Red Hat, Inc.
-+ * Copyright 2004, 2005, Soeren Sandmann
-+ *
-+ * 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 this program; if not, write to the Free Software
-+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-+ */
-+
-+#ifdef CONFIG_SMP
-+# define __SMP__
-+#endif
-+#include <asm/atomic.h>
-+#include <linux/kernel.h> /* Needed for KERN_ALERT */
-+#include <linux/module.h> /* Needed by all modules */
-+#include <linux/sched.h>
-+
-+#include <linux/proc_fs.h>
-+#include <asm/uaccess.h>
-+#include <linux/poll.h>
-+#include <linux/highmem.h>
-+#include <linux/pagemap.h>
-+#include <linux/profile.h>
-+
-+#include "sysprof-module.h"
-+
-+#include "config.h"
-+
-+#include <linux/version.h>
-+
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
-+#include <linux/config.h>
-+#endif
-+
-+#if !CONFIG_PROFILING
-+# error Sysprof needs a kernel with profiling support compiled in.
-+#endif
-+
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)
-+# error Sysprof needs a Linux 2.6.11 kernel or later
-+#endif
-+#include <linux/kallsyms.h>
-+
-+MODULE_LICENSE("GPL");
-+MODULE_AUTHOR("Soeren Sandmann (sandmann@daimi.au.dk)");
-+
-+#define SAMPLES_PER_SECOND (200)
-+#define INTERVAL ((HZ <= SAMPLES_PER_SECOND)? 1 : (HZ / SAMPLES_PER_SECOND))
-+#define N_TRACES 256
-+
-+static SysprofStackTrace stack_traces[N_TRACES];
-+static SysprofStackTrace * head = &stack_traces[0];
-+static SysprofStackTrace * tail = &stack_traces[0];
-+DECLARE_WAIT_QUEUE_HEAD (wait_for_trace);
-+DECLARE_WAIT_QUEUE_HEAD (wait_for_exit);
-+
-+/* Macro the names of the registers that are used on each architecture */
-+#if defined(CONFIG_X86_64)
-+# define REG_FRAME_PTR rbp
-+# define REG_INS_PTR rip
-+# define REG_STACK_PTR rsp
-+#elif defined(CONFIG_X86)
-+# define REG_FRAME_PTR ebp
-+# define REG_INS_PTR eip
-+# define REG_STACK_PTR esp
-+#else
-+# error Sysprof only supports the i386 and x86-64 architectures
-+#endif
-+
-+typedef struct userspace_reader userspace_reader;
-+struct userspace_reader
-+{
-+ struct task_struct *task;
-+ unsigned long cache_address;
-+ unsigned long *cache;
-+};
-+
-+typedef struct StackFrame StackFrame;
-+struct StackFrame {
-+ unsigned long next;
-+ unsigned long return_address;
-+};
-+
-+struct work_struct work;
-+
-+static int
-+read_frame (void *frame_pointer, StackFrame *frame)
-+{
-+#if 0
-+ /* This is commented out because we seem to be called with
-+ * (current_thread_info()->addr_limit.seg)) == 0
-+ * which means access_ok() _always_ fails.
-+ *
-+ * Not sure why (or if) this isn't the case for oprofile
-+ */
-+ if (!access_ok(VERIFY_READ, frame_pointer, sizeof(StackFrame)))
-+ return 1;
-+#endif
-+
-+ if (__copy_from_user_inatomic (
-+ frame, frame_pointer, sizeof (StackFrame)))
-+ return 1;
-+
-+ return 0;
-+}
-+
-+DEFINE_PER_CPU(int, n_samples);
-+
-+static int
-+timer_notify (struct pt_regs *regs)
-+{
-+ SysprofStackTrace *trace = head;
-+ int i;
-+ int is_user;
-+ static atomic_t in_timer_notify = ATOMIC_INIT(1);
-+ int n;
-+
-+ n = ++get_cpu_var(n_samples);
-+ put_cpu_var(n_samples);
-+
-+ if (n % INTERVAL != 0)
-+ return 0;
-+
-+ /* 0: locked, 1: unlocked */
-+
-+ if (!atomic_dec_and_test(&in_timer_notify))
-+ goto out;
-+
-+ is_user = user_mode(regs);
-+
-+ if (!current || current->pid == 0)
-+ goto out;
-+
-+ if (is_user && current->state != TASK_RUNNING)
-+ goto out;
-+
-+ if (!is_user)
-+ {
-+ /* kernel */
-+
-+ trace->pid = current->pid;
-+ trace->truncated = 0;
-+ trace->n_addresses = 1;
-+
-+ /* 0x1 is taken by sysprof to mean "in kernel" */
-+ trace->addresses[0] = (void *)0x1;
-+ }
-+ else
-+ {
-+ StackFrame *frame_pointer;
-+ StackFrame frame;
-+ memset(trace, 0, sizeof (SysprofStackTrace));
-+
-+ trace->pid = current->pid;
-+ trace->truncated = 0;
-+
-+ i = 0;
-+
-+ trace->addresses[i++] = (void *)regs->REG_INS_PTR;
-+
-+ frame_pointer = (void *)regs->REG_FRAME_PTR;
-+
-+ while (read_frame (frame_pointer, &frame) == 0 &&
-+ i < SYSPROF_MAX_ADDRESSES &&
-+ (unsigned long)frame_pointer >= regs->REG_STACK_PTR)
-+ {
-+ trace->addresses[i++] = (void *)frame.return_address;
-+ frame_pointer = (StackFrame *)frame.next;
-+ }
-+
-+ trace->n_addresses = i;
-+
-+ if (i == SYSPROF_MAX_ADDRESSES)
-+ trace->truncated = 1;
-+ else
-+ trace->truncated = 0;
-+ }
-+
-+ if (head++ == &stack_traces[N_TRACES - 1])
-+ head = &stack_traces[0];
-+
-+ wake_up (&wait_for_trace);
-+
-+out:
-+ atomic_inc(&in_timer_notify);
-+ return 0;
-+}
-+
-+static int
-+procfile_read(char *buffer,
-+ char **buffer_location,
-+ off_t offset,
-+ int buffer_len,
-+ int *eof,
-+ void *data)
-+{
-+ if (head == tail)
-+ return -EWOULDBLOCK;
-+
-+ *buffer_location = (char *)tail;
-+
-+ BUG_ON(tail->pid == 0);
-+
-+ if (tail++ == &stack_traces[N_TRACES - 1])
-+ tail = &stack_traces[0];
-+
-+ return sizeof (SysprofStackTrace);
-+}
-+
-+struct proc_dir_entry *trace_proc_file;
-+static unsigned int
-+procfile_poll(struct file *filp, poll_table *poll_table)
-+{
-+ if (head != tail)
-+ return POLLIN | POLLRDNORM;
-+
-+ poll_wait(filp, &wait_for_trace, poll_table);
-+
-+ if (head != tail)
-+ return POLLIN | POLLRDNORM;
-+
-+ return 0;
-+}
-+
-+int
-+init_module(void)
-+{
-+ static struct file_operations fops;
-+
-+ trace_proc_file =
-+ create_proc_entry ("sysprof-trace", S_IFREG | S_IRUGO, &proc_root);
-+
-+ if (!trace_proc_file)
-+ return 1;
-+
-+ fops = *trace_proc_file->proc_fops;
-+ fops.poll = procfile_poll;
-+
-+ trace_proc_file->read_proc = procfile_read;
-+ trace_proc_file->proc_fops = &fops;
-+ trace_proc_file->size = sizeof (SysprofStackTrace);
-+
-+ register_timer_hook (timer_notify);
-+
-+ printk(KERN_ALERT "sysprof: loaded (%s)\n", PACKAGE_VERSION);
-+
-+ return 0;
-+}
-+
-+void
-+cleanup_module(void)
-+{
-+ unregister_timer_hook (timer_notify);
-+
-+ remove_proc_entry("sysprof-trace", &proc_root);
-+
-+ printk(KERN_ALERT "sysprof: unloaded\n");
-+}
-+
-diff --git a/drivers/sysprof/sysprof-module.h b/drivers/sysprof/sysprof-module.h
-new file mode 100644
-index 0000000..66a11ae
---- /dev/null
-+++ b/drivers/sysprof/sysprof-module.h
-@@ -0,0 +1,37 @@
-+/* Sysprof -- Sampling, systemwide CPU profiler
-+ * Copyright 2004, Red Hat, Inc.
-+ * Copyright 2004, 2005, Soeren Sandmann
-+ *
-+ * 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 this program; if not, write to the Free Software
-+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-+ */
-+
-+#ifndef SYSPROF_MODULE_H
-+#define SYSPROF_MODULE_H
-+
-+typedef struct SysprofStackTrace SysprofStackTrace;
-+
-+#define SYSPROF_MAX_ADDRESSES 512
-+
-+struct SysprofStackTrace
-+{
-+ int pid; /* -1 if in kernel */
-+ int truncated;
-+ int n_addresses; /* note: this can be 1 if the process was compiled
-+ * with -fomit-frame-pointer or is otherwise weird
-+ */
-+ void *addresses[SYSPROF_MAX_ADDRESSES];
-+};
-+
-+#endif
-diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
-index 5216c11..3e3df7e 100644
---- a/drivers/video/Kconfig
-+++ b/drivers/video/Kconfig
-@@ -594,7 +594,7 @@ config FB_TGA
-
- config FB_VESA
- bool "VESA VGA graphics support"
-- depends on (FB = y) && X86
-+ depends on (FB = y) && X86 && !VGA_NOPROBE
- select FB_CFB_FILLRECT
- select FB_CFB_COPYAREA
- select FB_CFB_IMAGEBLIT
-@@ -1028,7 +1028,7 @@ config FB_CARILLO_RANCH
-
- config FB_INTEL
- tristate "Intel 830M/845G/852GM/855GM/865G/915G/945G support (EXPERIMENTAL)"
-- depends on FB && EXPERIMENTAL && PCI && X86
-+ depends on FB && EXPERIMENTAL && PCI && X86 && !VGA_NOPROBE
- select AGP
- select AGP_INTEL
- select FB_MODE_HELPERS
-@@ -1383,7 +1383,7 @@ config FB_SAVAGE_ACCEL
-
- config FB_SIS
- tristate "SiS/XGI display support"
-- depends on FB && PCI
-+ depends on FB && PCI && !VGA_NOPROBE
- select FB_CFB_FILLRECT
- select FB_CFB_COPYAREA
- select FB_CFB_IMAGEBLIT
-@@ -1822,6 +1822,15 @@ config FB_PS3_DEFAULT_SIZE_M
- The default value can be overridden on the kernel command line
- using the "ps3fb" option (e.g. "ps3fb=9M");
-
-+config FB_OLPC_DCON
-+ tristate "One Laptop Per Child Display CONtroller support"
-+ depends on OLPC
-+ select I2C
-+ ---help---
-+ Add support for the OLPC DCON controller. This controller is only
-+ available on OLPC platforms. Unless you have one of these
-+ platforms, you will want to say 'N'.
-+
- config FB_XILINX
- tristate "Xilinx frame buffer support"
- depends on FB && XILINX_VIRTEX
-diff --git a/drivers/video/Makefile b/drivers/video/Makefile
-index 06eec7b..fc535fb 100644
---- a/drivers/video/Makefile
-+++ b/drivers/video/Makefile
-@@ -111,6 +111,7 @@ obj-$(CONFIG_FB_PNX4008_DUM_RGB) += pnx4008/
- obj-$(CONFIG_FB_IBM_GXT4500) += gxt4500.o
- obj-$(CONFIG_FB_PS3) += ps3fb.o
- obj-$(CONFIG_FB_SM501) += sm501fb.o
-+obj-$(CONFIG_FB_OLPC_DCON) += olpc_dcon.o
- obj-$(CONFIG_FB_XILINX) += xilinxfb.o
- obj-$(CONFIG_FB_OMAP) += omap/
-
-diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
-index 0740272..4ac6a95 100644
---- a/drivers/video/fbmem.c
-+++ b/drivers/video/fbmem.c
-@@ -820,6 +820,53 @@ static void try_to_load(int fb)
- #endif /* CONFIG_KMOD */
-
- int
-+fb_powerup(struct fb_info *info)
-+{
-+ int ret = 0;
-+
-+ if (!info || info->state == FBINFO_STATE_RUNNING)
-+ return 0;
-+
-+ if (info->fbops->fb_powerup)
-+ ret = info->fbops->fb_powerup(info);
-+
-+ if (!ret) {
-+ acquire_console_sem();
-+ fb_set_suspend(info, 0);
-+ release_console_sem();
-+ }
-+
-+ return ret;
-+}
-+
-+int
-+fb_powerdown(struct fb_info *info)
-+{
-+ int ret = 0;
-+
-+ if (!info || info->state == FBINFO_STATE_SUSPENDED)
-+ return 0;
-+
-+ /* Tell everybody that the fbdev is going down */
-+ acquire_console_sem();
-+ fb_set_suspend(info, 1);
-+ release_console_sem();
-+
-+ if (info->fbops->fb_powerdown)
-+ ret = info->fbops->fb_powerdown(info);
-+
-+ /* If the power down failed, then un-notify */
-+
-+ if (ret) {
-+ acquire_console_sem();
-+ fb_set_suspend(info, 0);
-+ release_console_sem();
-+ }
-+
-+ return ret;
-+}
-+
-+int
- fb_pan_display(struct fb_info *info, struct fb_var_screeninfo *var)
- {
- struct fb_fix_screeninfo *fix = &info->fix;
-diff --git a/drivers/video/geode/Makefile b/drivers/video/geode/Makefile
-index 957304b..5c98da1 100644
---- a/drivers/video/geode/Makefile
-+++ b/drivers/video/geode/Makefile
-@@ -5,5 +5,5 @@ obj-$(CONFIG_FB_GEODE_GX) += gxfb.o
- obj-$(CONFIG_FB_GEODE_LX) += lxfb.o
-
- gx1fb-objs := gx1fb_core.o display_gx1.o video_cs5530.o
--gxfb-objs := gxfb_core.o display_gx.o video_gx.o
-+gxfb-objs := gxfb_core.o display_gx.o video_gx.o suspend_gx.o
- lxfb-objs := lxfb_core.o lxfb_ops.o
-diff --git a/drivers/video/geode/display_gx.c b/drivers/video/geode/display_gx.c
-index 0f16e4b..a432b99 100644
---- a/drivers/video/geode/display_gx.c
-+++ b/drivers/video/geode/display_gx.c
-@@ -11,26 +11,44 @@
- * Free Software Foundation; either version 2 of the License, or * (at your
- * option) any later version.
- */
-+
-+#include <linux/kernel.h>
- #include <linux/spinlock.h>
- #include <linux/fb.h>
- #include <linux/delay.h>
- #include <asm/io.h>
- #include <asm/div64.h>
- #include <asm/delay.h>
-+#include <asm/olpc.h>
-
- #include "geodefb.h"
- #include "display_gx.h"
-
--#ifdef CONFIG_FB_GEODE_GX_SET_FBSIZE
--unsigned int gx_frame_buffer_size(void)
-+static inline void rmwl(u32 val, u32 *reg)
- {
-- return CONFIG_FB_GEODE_GX_FBSIZE;
-+ u32 in = readl(reg);
-+ if (in != val)
-+ writel(val, reg);
- }
--#else
-+
- unsigned int gx_frame_buffer_size(void)
- {
- unsigned int val;
-
-+#ifdef CONFIG_OLPC
-+ if (machine_is_olpc() && !olpc_has_vsa()) {
-+ u32 hi,lo;
-+ rdmsr(GLIU0_P2D_RO0, lo, hi);
-+
-+ /* Top page number */
-+ val = ((hi & 0xff) << 12) | ((lo & 0xfff00000) >> 20);
-+
-+ val -= (lo & 0x000fffff); /* Subtract bottom page number */
-+ val += 1; /* Adjust page count */
-+ return (val << 12);
-+ }
-+#endif
-+
- /* FB size is reported by a virtual register */
- /* Virtual register class = 0x02 */
- /* VG_MEM_SIZE(512Kb units) = 0x00 */
-@@ -41,7 +59,6 @@ unsigned int gx_frame_buffer_size(void)
- val = (unsigned int)(inw(0xAC1E)) & 0xFFl;
- return (val << 19);
- }
--#endif
-
- int gx_line_delta(int xres, int bpp)
- {
-@@ -63,23 +80,23 @@ static void gx_set_mode(struct fb_info *info)
- gcfg = readl(par->dc_regs + DC_GENERAL_CFG);
- dcfg = readl(par->dc_regs + DC_DISPLAY_CFG);
-
-- /* Disable the timing generator. */
-- dcfg &= ~(DC_DCFG_TGEN);
-- writel(dcfg, par->dc_regs + DC_DISPLAY_CFG);
-+ /* Programming the clock is costly and ugly, so avoid if if we can */
-
-- /* Wait for pending memory requests before disabling the FIFO load. */
-- udelay(100);
-+ if (par->curdclk != info->var.pixclock) {
-+ /* Disable the timing generator. */
-+ dcfg &= ~(DC_DCFG_TGEN);
-+ writel(dcfg, par->dc_regs + DC_DISPLAY_CFG);
-
-- /* Disable FIFO load and compression. */
-- gcfg &= ~(DC_GCFG_DFLE | DC_GCFG_CMPE | DC_GCFG_DECE);
-- writel(gcfg, par->dc_regs + DC_GENERAL_CFG);
-+ /* Wait for pending memory requests before disabling the FIFO load. */
-+ udelay(100);
-
-- /* Setup DCLK and its divisor. */
-- par->vid_ops->set_dclk(info);
-+ /* Disable FIFO load and compression. */
-+ gcfg &= ~(DC_GCFG_DFLE | DC_GCFG_CMPE | DC_GCFG_DECE);
-+ writel(gcfg, par->dc_regs + DC_GENERAL_CFG);
-
-- /*
-- * Setup new mode.
-- */
-+ /* Setup DCLK and its divisor. */
-+ par->vid_ops->set_dclk(info);
-+ }
-
- /* Clear all unused feature bits. */
- gcfg &= DC_GCFG_YUVM | DC_GCFG_VDSE;
-@@ -90,12 +107,13 @@ static void gx_set_mode(struct fb_info *info)
- gcfg |= (6 << DC_GCFG_DFHPEL_POS) | (5 << DC_GCFG_DFHPSL_POS) | DC_GCFG_DFLE;
-
- /* Framebuffer start offset. */
-- writel(0, par->dc_regs + DC_FB_ST_OFFSET);
-+ rmwl(0, par->dc_regs + DC_FB_ST_OFFSET);
-
- /* Line delta and line buffer length. */
-- writel(info->fix.line_length >> 3, par->dc_regs + DC_GFX_PITCH);
-- writel(((info->var.xres * info->var.bits_per_pixel/8) >> 3) + 2,
-- par->dc_regs + DC_LINE_SIZE);
-+ rmwl(info->fix.line_length >> 3, par->dc_regs + DC_GFX_PITCH);
-+
-+ rmwl(((info->var.xres * info->var.bits_per_pixel/8) >> 3) + 2,
-+ par->dc_regs + DC_LINE_SIZE);
-
-
- /* Enable graphics and video data and unmask address lines. */
-@@ -134,17 +152,16 @@ static void gx_set_mode(struct fb_info *info)
- vblankend = vsyncend + info->var.upper_margin;
- vtotal = vblankend;
-
-- writel((hactive - 1) | ((htotal - 1) << 16), par->dc_regs + DC_H_ACTIVE_TIMING);
-- writel((hblankstart - 1) | ((hblankend - 1) << 16), par->dc_regs + DC_H_BLANK_TIMING);
-- writel((hsyncstart - 1) | ((hsyncend - 1) << 16), par->dc_regs + DC_H_SYNC_TIMING);
--
-- writel((vactive - 1) | ((vtotal - 1) << 16), par->dc_regs + DC_V_ACTIVE_TIMING);
-- writel((vblankstart - 1) | ((vblankend - 1) << 16), par->dc_regs + DC_V_BLANK_TIMING);
-- writel((vsyncstart - 1) | ((vsyncend - 1) << 16), par->dc_regs + DC_V_SYNC_TIMING);
-+ rmwl((hactive - 1) | ((htotal - 1) << 16), par->dc_regs + DC_H_ACTIVE_TIMING);
-+ rmwl((hblankstart - 1) | ((hblankend - 1) << 16), par->dc_regs + DC_H_BLANK_TIMING);
-+ rmwl((hsyncstart - 1) | ((hsyncend - 1) << 16), par->dc_regs + DC_H_SYNC_TIMING);
-+ rmwl((vactive - 1) | ((vtotal - 1) << 16), par->dc_regs + DC_V_ACTIVE_TIMING);
-+ rmwl((vblankstart - 1) | ((vblankend - 1) << 16), par->dc_regs + DC_V_BLANK_TIMING);
-+ rmwl((vsyncstart - 1) | ((vsyncend - 1) << 16), par->dc_regs + DC_V_SYNC_TIMING);
-
- /* Write final register values. */
-- writel(dcfg, par->dc_regs + DC_DISPLAY_CFG);
-- writel(gcfg, par->dc_regs + DC_GENERAL_CFG);
-+ rmwl(dcfg, par->dc_regs + DC_DISPLAY_CFG);
-+ rmwl(gcfg, par->dc_regs + DC_GENERAL_CFG);
-
- par->vid_ops->configure_display(info);
-
-diff --git a/drivers/video/geode/display_gx.h b/drivers/video/geode/display_gx.h
-index 0af33f3..d20b877 100644
---- a/drivers/video/geode/display_gx.h
-+++ b/drivers/video/geode/display_gx.h
-@@ -20,6 +20,9 @@ extern struct geode_dc_ops gx_dc_ops;
- #define GLD_MSR_CONFIG 0xC0002001
- #define GLD_MSR_CONFIG_DM_FP 0x40
-
-+/* Used for memory dection on the OLPC */
-+#define GLIU0_P2D_RO0 0x10000029
-+
- /* Display controller registers */
-
- #define DC_UNLOCK 0x00
-diff --git a/drivers/video/geode/geode_regs.h b/drivers/video/geode/geode_regs.h
-new file mode 100644
-index 0000000..9e75505
---- /dev/null
-+++ b/drivers/video/geode/geode_regs.h
-@@ -0,0 +1,242 @@
-+/* This header file defines the registers and suspend/resume
-+ structures for the Geode GX and LX. The lxfb driver defines
-+ _GEODELX_ before including this file, which will unlock the
-+ extra registers that are only valid for LX.
-+*/
-+
-+#ifndef _GEODE_REGS_H_
-+#define _GEODE_REGS_H_
-+
-+/* MSRs */
-+
-+#define GX_VP_MSR_PAD_SELECT 0xC0002011
-+#define LX_VP_MSR_PAD_SELECT 0x48000011
-+
-+#define GEODE_MSR_GLCP_DOTPLL 0x4c000015
-+
-+#define GLCP_DOTPLL_RESET (1 << 0)
-+#define GLCP_DOTPLL_BYPASS (1 << 15)
-+#define GLCP_DOTPLL_HALFPIX (1 << 24)
-+#define GLCP_DOTPLL_LOCK (1 << 25)
-+
-+/* Registers */
-+#define VP_FP_START 0x400
-+
-+
-+#ifdef _GEODELX_
-+
-+#define GP_REG_SIZE 0x7C
-+#define DC_REG_SIZE 0xF0
-+#define VP_REG_SIZE 0x158
-+#define FP_REG_SIZE 0x70
-+
-+#else
-+
-+#define GP_REG_SIZE 0x50
-+#define DC_REG_SIZE 0x90
-+#define VP_REG_SIZE 0x138
-+#define FP_REG_SIZE 0x70
-+
-+#endif
-+
-+#define DC_PAL_SIZE 0x105
-+
-+struct geoderegs {
-+
-+ struct {
-+ u64 padsel;
-+ u64 dotpll;
-+
-+#ifdef _GEODELX_
-+ u64 dfglcfg;
-+ u64 dcspare;
-+#else
-+ u64 rstpll;
-+#endif
-+ } msr;
-+
-+ union {
-+ unsigned char b[GP_REG_SIZE];
-+ struct {
-+ u32 dst_offset; /* 0x00 */
-+ u32 src_offset; /* 0x04 */
-+ u32 stride; /* 0x08 */
-+ u32 wid_height; /* 0x0C */
-+ u32 src_color_fg; /* 0x10 */
-+ u32 src_color_bg; /* 0x14 */
-+ u32 pat_color_0; /* 0x18 */
-+ u32 pat_color_1; /* 0x1C */
-+ u32 pat_color_2; /* 0x20 */
-+ u32 pat_color_3; /* 0x24 */
-+ u32 pat_color_4; /* 0x28 */
-+ u32 pat_color_5; /* 0x2C */
-+ u32 pat_data_0; /* 0x30 */
-+ u32 pat_data_1; /* 0x34 */
-+ u32 raster_mode; /* 0x38 */
-+ u32 vector_mode; /* 0x3C */
-+ u32 blt_mode; /* 0x40 */
-+ u32 blit_status; /* 0x4C */
-+ u32 hst_src; /* 0x48 */
-+ u32 base_offset; /* 0x4C */
-+
-+#ifdef _GEODELX_
-+ u32 cmd_top; /* 0x50 */
-+ u32 cmd_bot; /* 0x54 */
-+ u32 cmd_read; /* 0x58 */
-+ u32 cmd_write; /* 0x5C */
-+ u32 ch3_offset; /* 0x60 */
-+ u32 ch3_mode_str; /* 0x64 */
-+ u32 ch3_width; /* 0x68 */
-+ u32 ch3_hsrc; /* 0x6C */
-+ u32 lut_index; /* 0x70 */
-+ u32 lut_data; /* 0x74 */
-+ u32 int_cntrl; /* 0x78 */
-+#endif
-+ } r;
-+ } gp;
-+
-+ union {
-+ unsigned char b[DC_REG_SIZE];
-+
-+ struct {
-+ u32 unlock; /* 0x00 */
-+ u32 gcfg; /* 0x04 */
-+ u32 dcfg; /* 0x08 */
-+ u32 arb; /* 0x0C */
-+ u32 fb_st_offset; /* 0x10 */
-+ u32 cb_st_offset; /* 0x14 */
-+ u32 curs_st_offset; /* 0x18 */
-+ u32 icon_st_offset; /* 0x1C */
-+ u32 vid_y_st_offset; /* 0x20 */
-+ u32 vid_u_st_offset; /* 0x24 */
-+ u32 vid_v_st_offset; /* 0x28 */
-+ u32 dctop; /* 0x2c */
-+ u32 line_size; /* 0x30 */
-+ u32 gfx_pitch; /* 0x34 */
-+ u32 vid_yuv_pitch; /* 0x38 */
-+ u32 rsvd2; /* 0x3C */
-+ u32 h_active_timing; /* 0x40 */
-+ u32 h_blank_timing; /* 0x44 */
-+ u32 h_sync_timing; /* 0x48 */
-+ u32 rsvd3; /* 0x4C */
-+ u32 v_active_timing; /* 0x50 */
-+ u32 v_blank_timing; /* 0x54 */
-+ u32 v_sync_timing; /* 0x58 */
-+ u32 fbactive; /* 0x5C */
-+ u32 dc_cursor_x; /* 0x60 */
-+ u32 dc_cursor_y; /* 0x64 */
-+ u32 dc_icon_x; /* 0x68 */
-+ u32 dc_line_cnt; /* 0x6C */
-+ u32 rsvd5; /* 0x70 - palette address */
-+ u32 rsvd6; /* 0x74 - palette data */
-+ u32 dfifo_diag; /* 0x78 */
-+ u32 cfifo_diag; /* 0x7C */
-+ u32 dc_vid_ds_delta; /* 0x80 */
-+ u32 gliu0_mem_offset; /* 0x84 */
-+ u32 dv_ctl; /* 0x88 - added by LX */
-+ u32 dv_acc; /* 0x8C */
-+
-+#ifdef _GEODELX_
-+ u32 gfx_scale;
-+ u32 irq_filt_ctl;
-+ u32 filt_coeff1;
-+ u32 filt_coeff2;
-+ u32 vbi_event_ctl;
-+ u32 vbi_odd_ctl;
-+ u32 vbi_hor;
-+ u32 vbi_ln_odd;
-+ u32 vbi_ln_event;
-+ u32 vbi_pitch;
-+ u32 clr_key;
-+ u32 clr_key_mask;
-+ u32 clr_key_x;
-+ u32 clr_key_y;
-+ u32 irq;
-+ u32 rsvd8;
-+ u32 genlk_ctrl;
-+ u32 vid_even_y_st_offset; /* 0xD8 */
-+ u32 vid_even_u_st_offset; /* 0xDC */
-+ u32 vid_even_v_st_offset; /* 0xE0 */
-+ u32 v_active_even_timing; /* 0xE4 */
-+ u32 v_blank_even_timing; /* 0xE8 */
-+ u32 v_sync_even_timing; /* 0xEC */
-+#endif
-+ } r;
-+ } dc;
-+
-+ union {
-+ unsigned char b[VP_REG_SIZE];
-+
-+ struct {
-+ u64 vcfg; /* 0x00 */
-+ u64 dcfg; /* 0x08 */
-+ u64 vx; /* 0x10 */
-+ u64 vy; /* 0x18 */
-+ u64 vs; /* 0x20 */
-+ u64 vck; /* 0x28 */
-+ u64 vcm; /* 0x30 */
-+ u64 rsvd1; /* 0x38 - Gamma address*/
-+ u64 rsvd2; /* 0x40 - Gamma data*/
-+ u64 rsvd3; /* 0x48 */
-+ u64 misc; /* 0x50 */
-+ u64 ccs; /* 0x58 */
-+ u64 rsvd4[3]; /* 0x60-0x70 */
-+ u64 vdc; /* 0x78 */
-+ u64 vco; /* 0x80 */
-+ u64 crc; /* 0x88 */
-+ u64 crc32; /* 0x90 */
-+ u64 vde; /* 0x98 */
-+ u64 cck; /* 0xA0 */
-+ u64 ccm; /* 0xA8 */
-+ u64 cc1; /* 0xB0 */
-+ u64 cc2; /* 0xB8 */
-+ u64 a1x; /* 0xC0 */
-+ u64 a1y; /* 0xC8 */
-+ u64 a1c; /* 0xD0 */
-+ u64 a1t; /* 0xD8 */
-+ u64 a2x; /* 0xE0 */
-+ u64 a2y; /* 0xE8 */
-+ u64 a2c; /* 0xF0 */
-+ u64 a2t; /* 0xF8 */
-+ u64 a3x; /* 0x100 */
-+ u64 a3y; /* 0x108 */
-+ u64 a3c; /* 0x110 */
-+ u64 a3t; /* 0x118 */
-+ u64 vrr; /* 0x120 */
-+ u64 awt; /* 0x128 */
-+ u64 vtm; /* 0x130 */
-+#ifdef _GEODELX_
-+ u64 vye; /* 0x138 */
-+ u64 a1ye; /* 0x140 */
-+ u32 a2ye; /* 0x148 */
-+ u32 a3ye; /* 0x150 */
-+#endif
-+ } r;
-+ } vp;
-+
-+ union {
-+ unsigned char b[FP_REG_SIZE];
-+
-+ struct {
-+ u64 pt1; /* 0x400 */
-+ u64 pt2; /* 0x408 */
-+ u64 pm; /* 0x410 */
-+ u64 dfc; /* 0x418 */
-+ u64 blfsr; /* 0x420 */
-+ u64 rlfsr; /* 0x428 */
-+ u64 fmi; /* 0x430 */
-+ u64 fmd; /* 0x438 */
-+ u64 rsvd; /* 0x440 */
-+ u64 dca; /* 0x448 */
-+ u64 dmd; /* 0x450 */
-+ u64 crc; /* 0x458 */
-+ u64 fbb; /* 0x460 */
-+ u64 crc32; /* 0x468 */
-+ } r;
-+ } fp;
-+
-+ u32 pal[DC_PAL_SIZE];
-+ u32 gamma[256];
-+};
-+
-+#endif
-diff --git a/drivers/video/geode/geodefb.h b/drivers/video/geode/geodefb.h
-index ae04820..0214d11 100644
---- a/drivers/video/geode/geodefb.h
-+++ b/drivers/video/geode/geodefb.h
-@@ -12,6 +12,10 @@
- #ifndef __GEODEFB_H__
- #define __GEODEFB_H__
-
-+#define FB_POWER_STATE_OFF 0
-+#define FB_POWER_STATE_SUSPEND 1
-+#define FB_POWER_STATE_ON 2
-+
- struct geodefb_info;
-
- struct geode_dc_ops {
-@@ -21,18 +25,24 @@ struct geode_dc_ops {
-
- struct geode_vid_ops {
- void (*set_dclk)(struct fb_info *);
-+ unsigned int (*get_dclk)(struct fb_info *);
- void (*configure_display)(struct fb_info *);
- int (*blank_display)(struct fb_info *, int blank_mode);
- };
-
- struct geodefb_par {
- int enable_crt;
-+ int fbactive; /* True if the current console is in KD_GRAPHICS mode */
- int panel_x; /* dimensions of an attached flat panel, non-zero => enable panel */
- int panel_y;
-+ unsigned int curdclk; /* Used by GX to avoid unnessesary clock switching */
- void __iomem *dc_regs;
- void __iomem *vid_regs;
-+ void __iomem *gp_regs;
- struct geode_dc_ops *dc_ops;
- struct geode_vid_ops *vid_ops;
-+
-+ int state;
- };
-
- #endif /* !__GEODEFB_H__ */
-diff --git a/drivers/video/geode/gxfb_core.c b/drivers/video/geode/gxfb_core.c
-index cf841ef..3eabc53 100644
---- a/drivers/video/geode/gxfb_core.c
-+++ b/drivers/video/geode/gxfb_core.c
-@@ -30,12 +30,31 @@
- #include <linux/fb.h>
- #include <linux/init.h>
- #include <linux/pci.h>
-+#include <linux/notifier.h>
-+#include <linux/vt_kern.h>
-+#include <linux/console.h>
-+#include <asm/uaccess.h>
-+#include <asm/olpc.h>
-
- #include "geodefb.h"
- #include "display_gx.h"
- #include "video_gx.h"
-
-+#define FBIOSGAMMA _IOW('F', 0x20, void *)
-+#define FBIOGGAMMA _IOW('F', 0x21, void *)
-+
-+#ifdef DEBUG
-+
-+#define FBIODUMPGP _IOW('F', 0x22, void *)
-+#define FBIODUMPDC _IOW('F', 0x23, void *)
-+#define FBIODUMPVP _IOW('F', 0x24, void *)
-+#define FBIODUMPFP _IOW('F', 0x25, void *)
-+
-+#endif
-+
- static char *mode_option;
-+static int noclear;
-+struct fb_info *gxfb_info;
-
- /* Modes relevant to the GX (taken from modedb.c) */
- static const struct fb_videomode gx_modedb[] __initdata = {
-@@ -103,8 +122,20 @@ static const struct fb_videomode gx_modedb[] __initdata = {
- { NULL, 85, 1600, 1200, 4357, 304, 64, 46, 1, 192, 3,
- FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
- FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
-+ /* 1200x900-75 - CRT timings for the OLPC mode */
-+ { NULL, 75, 1200, 900, 8049, 104, 240, 29, 54, 136, 3,
-+ 0, FB_VMODE_NONINTERLACED, 0 }
- };
-
-+#ifdef CONFIG_OLPC
-+static const struct fb_videomode gx_dcon_modedb[] __initdata = {
-+ /* The only mode the DCON has is 1200x900 */
-+ { NULL, 50, 1200, 900, 17460, 24, 8, 4, 5, 8, 3,
-+ 0, FB_VMODE_NONINTERLACED, 0 }
-+};
-+#endif
-+
-+
- static int gxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
- {
- if (var->xres > 1600 || var->yres > 1200)
-@@ -137,7 +168,7 @@ static int gxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
- return 0;
- }
-
--static int gxfb_set_par(struct fb_info *info)
-+int gxfb_set_par(struct fb_info *info)
- {
- struct geodefb_par *par = info->par;
-
-@@ -204,16 +235,26 @@ static int gxfb_blank(int blank_mode, struct fb_info *info)
- return par->vid_ops->blank_display(info, blank_mode);
- }
-
-+static int fbsize;
-+
- static int __init gxfb_map_video_memory(struct fb_info *info, struct pci_dev *dev)
- {
- struct geodefb_par *par = info->par;
-- int fb_len;
- int ret;
-
- ret = pci_enable_device(dev);
- if (ret < 0)
- return ret;
-
-+ ret = pci_request_region(dev, 1, "gxfb (graphics processor)");
-+ if (ret < 0)
-+ return ret;
-+
-+ par->gp_regs = ioremap(pci_resource_start(dev, 1),
-+ pci_resource_len(dev, 1));
-+ if (!par->gp_regs)
-+ return -ENOMEM;
-+
- ret = pci_request_region(dev, 3, "gxfb (video processor)");
- if (ret < 0)
- return ret;
-@@ -232,36 +273,118 @@ static int __init gxfb_map_video_memory(struct fb_info *info, struct pci_dev *de
- ret = pci_request_region(dev, 0, "gxfb (framebuffer)");
- if (ret < 0)
- return ret;
-- if ((fb_len = gx_frame_buffer_size()) < 0)
-- return -ENOMEM;
-+
-+ /* If the fbsize wasn't specified then try to probe it */
-+
-+ if (!fbsize) {
-+ fbsize = gx_frame_buffer_size();
-+ if (fbsize == 0)
-+ return -ENOMEM;
-+ }
-+
- info->fix.smem_start = pci_resource_start(dev, 0);
-- info->fix.smem_len = fb_len;
-+ info->fix.smem_len = fbsize;
- info->screen_base = ioremap(info->fix.smem_start, info->fix.smem_len);
- if (!info->screen_base)
- return -ENOMEM;
-
-- /* Set the 16MB aligned base address of the graphics memory region
-+ /* Set the 16MiB aligned base address of the graphics memory region
- * in the display controller */
-
- writel(info->fix.smem_start & 0xFF000000,
- par->dc_regs + DC_GLIU0_MEM_OFFSET);
-
-- dev_info(&dev->dev, "%d Kibyte of video memory at 0x%lx\n",
-+ dev_info(&dev->dev, "%d KiB of video memory at 0x%lx\n",
- info->fix.smem_len / 1024, info->fix.smem_start);
-
- return 0;
- }
-
-+static int gxfb_ioctl( struct fb_info *info, unsigned int cmd,
-+ unsigned long arg)
-+{
-+ unsigned int gamma[GXFB_GAMMA_DWORDS];
-+ int ret = -EINVAL;
-+ struct geodefb_par *par = info->par;
-+ int i;
-+
-+ switch(cmd) {
-+ case FBIOSGAMMA:
-+ /* Read the gamma information from the user - 256 dwords */
-+
-+ if (copy_from_user(gamma, (void * __user) arg, GXFB_GAMMA_SIZE))
-+ return -EFAULT;
-+
-+ writel(0, par->vid_regs + GX_GAR);
-+
-+ /* Sequential writes to the data register will increment the
-+ address automatically */
-+
-+ for(i = 0; i < GXFB_GAMMA_DWORDS; i++)
-+ writel(gamma[i] & 0xFFFFFF, par->vid_regs + GX_GDR);
-+
-+ writel(readl(par->vid_regs + GX_MISC) & ~GX_MISC_GAM_EN,
-+ par->vid_regs + GX_MISC);
-+
-+ ret = 0;
-+ break;
-+
-+ case FBIOGGAMMA:
-+ if (readl(par->vid_regs + GX_MISC) & GX_MISC_GAM_EN)
-+ return -EINVAL;
-+
-+ memset(gamma, 0, GXFB_GAMMA_SIZE);
-+ writel(0, par->vid_regs + GX_GAR);
-+
-+ for(i = 0; i < GXFB_GAMMA_DWORDS;i++)
-+ gamma[i] = readl(par->vid_regs + GX_GDR);
-+
-+ if (copy_to_user((void * __user) arg, gamma, GXFB_GAMMA_SIZE))
-+ ret = -EFAULT;
-+ else
-+ ret = 0;
-+
-+ break;
-+
-+#ifdef DEBUG
-+ case FBIODUMPGP:
-+ ret = 0;
-+ dump_regs(info, 0);
-+ break;
-+
-+ case FBIODUMPDC:
-+ ret = 0;
-+ dump_regs(info, 1);
-+ break;
-+
-+ case FBIODUMPVP:
-+ ret = 0;
-+ dump_regs(info, 2);
-+ break;
-+
-+ case FBIODUMPFP:
-+ ret = 0;
-+ dump_regs(info, 3);
-+ break;
-+#endif
-+ }
-+
-+ return ret;
-+}
-+
- static struct fb_ops gxfb_ops = {
- .owner = THIS_MODULE,
- .fb_check_var = gxfb_check_var,
- .fb_set_par = gxfb_set_par,
- .fb_setcolreg = gxfb_setcolreg,
- .fb_blank = gxfb_blank,
-+ .fb_ioctl = gxfb_ioctl,
- /* No HW acceleration for now. */
- .fb_fillrect = cfb_fillrect,
- .fb_copyarea = cfb_copyarea,
- .fb_imageblit = cfb_imageblit,
-+ .fb_powerdown = gxfb_powerdown,
-+ .fb_powerup = gxfb_powerup,
- };
-
- static struct fb_info * __init gxfb_init_fbinfo(struct device *dev)
-@@ -303,23 +426,86 @@ static struct fb_info * __init gxfb_init_fbinfo(struct device *dev)
- return info;
- }
-
--static int __init gxfb_probe(struct pci_dev *pdev, const struct pci_device_id *id)
-+static int gxfb_console_notify(struct notifier_block *self,
-+ unsigned long action, void *data)
-+{
-+ if (gxfb_info != NULL) {
-+ struct geodefb_par *par = gxfb_info->par;
-+ par->fbactive = (action == CONSOLE_EVENT_SWITCH_TEXT) ? 0 : 1;
-+ }
-+
-+ return NOTIFY_OK;
-+}
-+
-+static struct notifier_block gxfb_console_notifier = {
-+ .notifier_call = gxfb_console_notify
-+};
-+
-+#ifdef CONFIG_PM
-+
-+static int gxfb_suspend(struct pci_dev *pdev, pm_message_t state)
-+{
-+ struct fb_info *info = pci_get_drvdata(pdev);
-+ struct geodefb_par *par = info->par;
-+
-+ if (pdev->dev.power.power_state.event == state.event)
-+ return 0;
-+
-+ if (state.event == PM_EVENT_SUSPEND) {
-+
-+ acquire_console_sem();
-+ gxfb_powerdown(info);
-+
-+ par->state = FB_POWER_STATE_OFF;
-+ fb_set_suspend(info, 1);
-+
-+ release_console_sem();
-+ }
-+
-+ pdev->dev.power.power_state = state;
-+ return 0;
-+}
-+
-+static int gxfb_resume(struct pci_dev *pdev)
-+{
-+ struct fb_info *info = pci_get_drvdata(pdev);
-+
-+ acquire_console_sem();
-+
-+ /* Turn the engine completely on */
-+
-+ if (gxfb_powerup(info))
-+ printk(KERN_ERR "gxfb: Powerup failed\n");
-+
-+ fb_set_suspend(info, 0);
-+ release_console_sem();
-+
-+ pdev->dev.power.power_state = PMSG_ON;
-+ return 0;
-+}
-+#endif
-+
-+static int __init gxfb_probe(struct pci_dev *pdev,
-+ const struct pci_device_id *id)
- {
- struct geodefb_par *par;
-- struct fb_info *info;
- int ret;
- unsigned long val;
-
-- info = gxfb_init_fbinfo(&pdev->dev);
-- if (!info)
-+ struct fb_videomode *modedb_ptr;
-+ int modedb_size;
-+
-+ gxfb_info = gxfb_init_fbinfo(&pdev->dev);
-+ if (gxfb_info == NULL)
- return -ENOMEM;
-- par = info->par;
-+
-+ par = gxfb_info->par;
-
- /* GX display controller and GX video device. */
- par->dc_ops = &gx_dc_ops;
- par->vid_ops = &gx_vid_ops;
-
-- if ((ret = gxfb_map_video_memory(info, pdev)) < 0) {
-+ if ((ret = gxfb_map_video_memory(gxfb_info, pdev)) < 0) {
- dev_err(&pdev->dev, "failed to map frame buffer or controller registers\n");
- goto err;
- }
-@@ -333,32 +519,60 @@ static int __init gxfb_probe(struct pci_dev *pdev, const struct pci_device_id *i
- else
- par->enable_crt = 1;
-
-- ret = fb_find_mode(&info->var, info, mode_option,
-- gx_modedb, ARRAY_SIZE(gx_modedb), NULL, 16);
-+ /* Get the current dotclock */
-+
-+ par->curdclk = (par->vid_ops->get_dclk) ? par->vid_ops->get_dclk(gxfb_info) : 0;
-+
-+ /* We need to determine a display mode right now, so we will
-+ * check to see if the DCON was previously detected by the BIOS
-+ * and use that to make our mode database decision.
-+ */
-+
-+ modedb_ptr = (struct fb_videomode *) gx_modedb;
-+ modedb_size = ARRAY_SIZE(gx_modedb);
-+
-+#ifdef CONFIG_OLPC
-+ if (olpc_has_dcon()) {
-+ modedb_ptr = (struct fb_videomode *) gx_dcon_modedb;
-+ modedb_size = ARRAY_SIZE(gx_dcon_modedb);
-+ }
-+#endif
-+
-+ ret = fb_find_mode(&gxfb_info->var, gxfb_info, mode_option,
-+ modedb_ptr, modedb_size, NULL, 16);
-+
- if (ret == 0 || ret == 4) {
- dev_err(&pdev->dev, "could not find valid video mode\n");
- ret = -EINVAL;
- goto err;
- }
-
-+ /* Clear the screen of garbage, unless noclear was specified,
-+ * in which case we assume the user knows what he is doing */
-+
-+ if (!noclear)
-+ memset_io(gxfb_info->screen_base, 0, gxfb_info->fix.smem_len);
-+
-+ gxfb_check_var(&gxfb_info->var, gxfb_info);
-+ gxfb_set_par(gxfb_info);
-+
-+ /* We are powered up */
-+ par->state = FB_POWER_STATE_ON;
-
-- /* Clear the frame buffer of garbage. */
-- memset_io(info->screen_base, 0, info->fix.smem_len);
-
-- gxfb_check_var(&info->var, info);
-- gxfb_set_par(info);
-+ console_event_register(&gxfb_console_notifier);
-
-- if (register_framebuffer(info) < 0) {
-+ if (register_framebuffer(gxfb_info) < 0) {
- ret = -EINVAL;
- goto err;
- }
-- pci_set_drvdata(pdev, info);
-- printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node, info->fix.id);
-+ pci_set_drvdata(pdev, gxfb_info);
-+ printk(KERN_INFO "fb%d: %s frame buffer device\n", gxfb_info->node, gxfb_info->fix.id);
- return 0;
-
- err:
-- if (info->screen_base) {
-- iounmap(info->screen_base);
-+ if (gxfb_info->screen_base) {
-+ iounmap(gxfb_info->screen_base);
- pci_release_region(pdev, 0);
- }
- if (par->vid_regs) {
-@@ -370,8 +584,9 @@ static int __init gxfb_probe(struct pci_dev *pdev, const struct pci_device_id *i
- pci_release_region(pdev, 2);
- }
-
-- if (info)
-- framebuffer_release(info);
-+ if (gxfb_info)
-+ framebuffer_release(gxfb_info);
-+
- return ret;
- }
-
-@@ -397,9 +612,7 @@ static void gxfb_remove(struct pci_dev *pdev)
- }
-
- static struct pci_device_id gxfb_id_table[] = {
-- { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_GX_VIDEO,
-- PCI_ANY_ID, PCI_ANY_ID, PCI_BASE_CLASS_DISPLAY << 16,
-- 0xff0000, 0 },
-+ { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_GX_VIDEO) },
- { 0, }
- };
-
-@@ -410,22 +623,30 @@ static struct pci_driver gxfb_driver = {
- .id_table = gxfb_id_table,
- .probe = gxfb_probe,
- .remove = gxfb_remove,
-+#ifdef CONFIG_PM
-+ .suspend = gxfb_suspend,
-+ .resume = gxfb_resume
-+#endif
- };
-
- #ifndef MODULE
--static int __init gxfb_setup(char *options)
--{
-+static int __init gxfb_setup(char *options) {
-
- char *opt;
-
- if (!options || !*options)
- return 0;
-
-- while ((opt = strsep(&options, ",")) != NULL) {
-+ while((opt = strsep(&options, ",")) != NULL) {
- if (!*opt)
- continue;
-
-- mode_option = opt;
-+ if (!strncmp(opt, "fbsize:", 7))
-+ fbsize = simple_strtoul(opt+7, NULL, 0);
-+ else if (!strcmp(opt, "noclear"))
-+ noclear = 1;
-+ else
-+ mode_option = opt;
- }
-
- return 0;
-@@ -444,7 +665,6 @@ static int __init gxfb_init(void)
- #endif
- return pci_register_driver(&gxfb_driver);
- }
--
- static void __exit gxfb_cleanup(void)
- {
- pci_unregister_driver(&gxfb_driver);
-@@ -456,5 +676,8 @@ module_exit(gxfb_cleanup);
- module_param(mode_option, charp, 0);
- MODULE_PARM_DESC(mode_option, "video mode (<x>x<y>[-<bpp>][@<refr>])");
-
-+module_param(fbsize, int, 0);
-+MODULE_PARM_DESC(fbsize, "video memory size");
-+
- MODULE_DESCRIPTION("Framebuffer driver for the AMD Geode GX");
- MODULE_LICENSE("GPL");
-diff --git a/drivers/video/geode/lxfb.h b/drivers/video/geode/lxfb.h
-index 6c227f9..5be8a4d 100644
---- a/drivers/video/geode/lxfb.h
-+++ b/drivers/video/geode/lxfb.h
-@@ -25,10 +25,23 @@ void lx_set_mode(struct fb_info *);
- void lx_get_gamma(struct fb_info *, unsigned int *, int);
- void lx_set_gamma(struct fb_info *, unsigned int *, int);
- unsigned int lx_framebuffer_size(void);
-+int lx_shutdown(struct fb_info *);
-+int lx_powerup(struct fb_info *);
- int lx_blank_display(struct fb_info *, int);
- void lx_set_palette_reg(struct fb_info *, unsigned int, unsigned int,
- unsigned int, unsigned int);
-
-+
-+
-+/* ioctl() defines */
-+
-+#define FBIOSGAMMA _IOW('F', 0x20, void *)
-+#define FBIOGGAMMA _IOW('F', 0x21, void *)
-+
-+/* General definitions */
-+#define LXFB_GAMMA_DWORDS 256 /* number of dwords in the gamma ram */
-+#define LXFB_GAMMA_SIZE (LXFB_GAMMA_DWORDS * sizeof(unsigned int))
-+
- /* MSRS */
-
- #define MSR_LX_GLD_CONFIG 0x48002001
-diff --git a/drivers/video/geode/lxfb_core.c b/drivers/video/geode/lxfb_core.c
-index 5e30b40..c9060ed 100644
---- a/drivers/video/geode/lxfb_core.c
-+++ b/drivers/video/geode/lxfb_core.c
-@@ -22,6 +22,7 @@
- #include <linux/init.h>
- #include <linux/pci.h>
- #include <linux/uaccess.h>
-+#include <asm/olpc.h>
-
- #include "lxfb.h"
-
-@@ -35,186 +36,84 @@ static int fbsize;
- */
-
- const struct fb_videomode geode_modedb[] __initdata = {
-- /* 640x480-60 */
-- { NULL, 60, 640, 480, 39682, 48, 8, 25, 2, 88, 2,
-+ /* 640x480-60 VESA */
-+ { NULL, 60, 640, 480, 39682, 48, 16, 33, 10, 96, 2,
-+ 0, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
-+ /* 640x480-75 VESA */
-+ { NULL, 75, 640, 480, 31746, 120, 16, 16, 01, 64, 3,
-+ 0, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
-+ /* 640x480-85 VESA */
-+ { NULL, 85, 640, 480, 27777, 80, 56, 25, 01, 56, 3,
-+ 0, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
-+ /* 800x600-60 VESA */
-+ { NULL, 60, 800, 600, 25000, 88, 40, 23, 01, 128, 4,
- FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
-- FB_VMODE_NONINTERLACED, 0 },
-- /* 640x400-70 */
-- { NULL, 70, 640, 400, 39770, 40, 8, 28, 5, 96, 2,
-- FB_SYNC_HOR_HIGH_ACT,
-- FB_VMODE_NONINTERLACED, 0 },
-- /* 640x480-70 */
-- { NULL, 70, 640, 480, 35014, 88, 24, 15, 2, 64, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 640x480-72 */
-- { NULL, 72, 640, 480, 32102, 120, 16, 20, 1, 40, 3,
-+ FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
-+ /* 800x600-75 VESA */
-+ { NULL, 75, 800, 600, 20202, 160, 16, 21, 01, 80, 3,
- FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
-- FB_VMODE_NONINTERLACED, 0 },
-- /* 640x480-75 */
-- { NULL, 75, 640, 480, 31746, 120, 16, 16, 1, 64, 3,
-+ FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
-+ /* 800x600-85 VESA */
-+ { NULL, 85, 800, 600, 17761, 152, 32, 27, 01, 64, 3,
- FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
-- FB_VMODE_NONINTERLACED, 0 },
-- /* 640x480-85 */
-- { NULL, 85, 640, 480, 27780, 80, 56, 25, 1, 56, 3,
-+ FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
-+ /* 1024x768-60 VESA */
-+ { NULL, 60, 1024, 768, 15384, 160, 24, 29, 3, 136, 6,
-+ 0, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
-+ /* 1024x768-75 VESA */
-+ { NULL, 75, 1024, 768, 12690, 176, 16, 28, 1, 96, 3,
- FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
-- FB_VMODE_NONINTERLACED, 0 },
-- /* 640x480-90 */
-- { NULL, 90, 640, 480, 26392, 96, 32, 22, 1, 64, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 640x480-100 */
-- { NULL, 100, 640, 480, 23167, 104, 40, 25, 1, 64, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 640x480-60 */
-- { NULL, 60, 640, 480, 39682, 48, 16, 25, 10, 88, 2,
-+ FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
-+ /* 1024x768-85 VESA */
-+ { NULL, 85, 1024, 768, 10582, 208, 48, 36, 1, 96, 3,
- FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
-- FB_VMODE_NONINTERLACED, 0 },
-- /* 800x600-56 */
-- { NULL, 56, 800, 600, 27901, 128, 24, 22, 1, 72, 2,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 800x600-60 */
-- { NULL, 60, 800, 600, 25131, 72, 32, 23, 1, 136, 4,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 800x600-70 */
-- { NULL, 70, 800, 600, 21873, 120, 40, 21, 4, 80, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 800x600-72 */
-- { NULL, 72, 800, 600, 20052, 64, 56, 23, 37, 120, 6,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 800x600-75 */
-- { NULL, 75, 800, 600, 20202, 160, 16, 21, 1, 80, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 800x600-85 */
-- { NULL, 85, 800, 600, 17790, 152, 32, 27, 1, 64, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 800x600-90 */
-- { NULL, 90, 800, 600, 16648, 128, 40, 28, 1, 88, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 800x600-100 */
-- { NULL, 100, 800, 600, 14667, 136, 48, 27, 1, 88, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 800x600-60 */
-- { NULL, 60, 800, 600, 25131, 88, 40, 23, 1, 128, 4,
-+ FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
-+ /* 1280x960-60 VESA */
-+ { NULL, 60, 1280, 960, 9259, 312, 96, 36, 1, 112, 3,
- FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
-- FB_VMODE_NONINTERLACED, 0 },
-- /* 1024x768-60 */
-- { NULL, 60, 1024, 768, 15385, 160, 24, 29, 3, 136, 6,
-+ FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
-+ /* 1280x960-85 VESA */
-+ { NULL, 85, 1280, 960, 6734, 224, 64, 47, 1, 160, 3,
- FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
-- FB_VMODE_NONINTERLACED, 0 },
-- /* 1024x768-70 */
-- { NULL, 70, 1024, 768, 13346, 144, 24, 29, 3, 136, 6,
-+ FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
-+ /* 1280x1024-60 VESA */
-+ { NULL, 60, 1280, 1024, 9259, 248, 48, 38, 1, 112, 3,
- FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
-- FB_VMODE_NONINTERLACED, 0 },
-- /* 1024x768-72 */
-- { NULL, 72, 1024, 768, 12702, 168, 56, 29, 4, 112, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 1024x768-75 */
-- { NULL, 75, 1024, 768, 12703, 176, 16, 28, 1, 96, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 1024x768-85 */
-- { NULL, 85, 1024, 768, 10581, 208, 48, 36, 1, 96, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 1024x768-90 */
-- { NULL, 90, 1024, 768, 9981, 176, 64, 37, 1, 112, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 1024x768-100 */
-- { NULL, 100, 1024, 768, 8825, 184, 72, 42, 1, 112, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 1024x768-60 */
-- { NULL, 60, 1024, 768, 15385, 160, 24, 29, 3, 136, 6,
-+ FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
-+ /* 1280x1024-75 VESA */
-+ { NULL, 75, 1280, 1024, 7407, 248, 16, 38, 1, 144, 3,
- FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
-- FB_VMODE_NONINTERLACED, 0 },
-- /* 1152x864-60 */
-- { NULL, 60, 1152, 864, 12251, 184, 64, 27, 1, 120, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 1152x864-70 */
-- { NULL, 70, 1152, 864, 10254, 192, 72, 32, 8, 120, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 1152x864-72 */
-- { NULL, 72, 1152, 864, 9866, 200, 72, 33, 7, 128, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 1152x864-75 */
-- { NULL, 75, 1152, 864, 9259, 256, 64, 32, 1, 128, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 1152x864-85 */
-- { NULL, 85, 1152, 864, 8357, 200, 72, 37, 3, 128, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 1152x864-90 */
-- { NULL, 90, 1152, 864, 7719, 208, 80, 42, 9, 128, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 1152x864-100 */
-- { NULL, 100, 1152, 864, 6947, 208, 80, 48, 3, 128, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 1152x864-60 */
-- { NULL, 60, 1152, 864, 12251, 184, 64, 27, 1, 120, 3,
-+ FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
-+ /* 1280x1024-85 VESA */
-+ { NULL, 85, 1280, 1024, 6349, 224, 64, 44, 1, 160, 3,
- FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
-- FB_VMODE_NONINTERLACED, 0 },
-- /* 1280x1024-60 */
-- { NULL, 60, 1280, 1024, 9262, 248, 48, 38, 1, 112, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 1280x1024-70 */
-- { NULL, 70, 1280, 1024, 7719, 224, 88, 38, 6, 136, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 1280x1024-72 */
-- { NULL, 72, 1280, 1024, 7490, 224, 88, 39, 7, 136, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 1280x1024-75 */
-- { NULL, 75, 1280, 1024, 7409, 248, 16, 38, 1, 144, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 1280x1024-85 */
-- { NULL, 85, 1280, 1024, 6351, 224, 64, 44, 1, 160, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 1280x1024-90 */
-- { NULL, 90, 1280, 1024, 5791, 240, 96, 51, 12, 144, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 1280x1024-100 */
-- { NULL, 100, 1280, 1024, 5212, 240, 96, 57, 6, 144, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 1280x1024-60 */
-- { NULL, 60, 1280, 1024, 9262, 248, 48, 38, 1, 112, 3,
-- FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
-- FB_VMODE_NONINTERLACED, 0 },
-- /* 1600x1200-60 */
-+ FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
-+ /* 1600x1200-60 VESA */
- { NULL, 60, 1600, 1200, 6172, 304, 64, 46, 1, 192, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 1600x1200-70 */
-- { NULL, 70, 1600, 1200, 5291, 304, 64, 46, 1, 192, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 1600x1200-72 */
-- { NULL, 72, 1600, 1200, 5053, 288, 112, 47, 13, 176, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 1600x1200-75 */
-+ FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
-+ FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
-+ /* 1600x1200-75 VESA */
- { NULL, 75, 1600, 1200, 4938, 304, 64, 46, 1, 192, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 1600x1200-85 */
-+ FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
-+ FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
-+ /* 1600x1200-85 VESA */
- { NULL, 85, 1600, 1200, 4357, 304, 64, 46, 1, 192, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 1600x1200-90 */
-- { NULL, 90, 1600, 1200, 3981, 304, 128, 60, 1, 176, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 1600x1200-100 */
-- { NULL, 100, 1600, 1200, 3563, 304, 128, 67, 1, 176, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 1600x1200-60 */
-- { NULL, 60, 1600, 1200, 6172, 304, 64, 46, 1, 192, 3,
- FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
-- FB_VMODE_NONINTERLACED, 0 },
-- /* 1920x1440-60 */
-- { NULL, 60, 1920, 1440, 4273, 344, 128, 56, 1, 208, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 1920x1440-70 */
-- { NULL, 70, 1920, 1440, 3593, 360, 152, 55, 8, 208, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 1920x1440-72 */
-- { NULL, 72, 1920, 1440, 3472, 360, 152, 68, 4, 208, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 1920x1440-75 */
-- { NULL, 75, 1920, 1440, 3367, 352, 144, 56, 1, 224, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-- /* 1920x1440-85 */
-- { NULL, 85, 1920, 1440, 2929, 368, 152, 68, 1, 216, 3,
-- 0, FB_VMODE_NONINTERLACED, 0 },
-+ FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
-+ /* 1200x900-75 - CRT timings for the OLPC mode */
-+ { NULL, 75, 1200, 900, 8049, 104, 240, 29, 54, 136, 3,
-+ 0, FB_VMODE_NONINTERLACED, 0 }