diff options
Diffstat (limited to 'drivers/staging/olpc_dcon')
-rw-r--r-- | drivers/staging/olpc_dcon/Kconfig | 22 | ||||
-rw-r--r-- | drivers/staging/olpc_dcon/Makefile | 7 | ||||
-rw-r--r-- | drivers/staging/olpc_dcon/olpc_dcon.c | 599 | ||||
-rw-r--r-- | drivers/staging/olpc_dcon/olpc_dcon.h | 63 | ||||
-rw-r--r-- | drivers/staging/olpc_dcon/olpc_dcon_xo_1.c | 12 | ||||
-rw-r--r-- | drivers/staging/olpc_dcon/olpc_dcon_xo_1_5.c | 109 |
6 files changed, 425 insertions, 387 deletions
diff --git a/drivers/staging/olpc_dcon/Kconfig b/drivers/staging/olpc_dcon/Kconfig index 8be8716..f1082f5 100644 --- a/drivers/staging/olpc_dcon/Kconfig +++ b/drivers/staging/olpc_dcon/Kconfig @@ -1,8 +1,28 @@ config FB_OLPC_DCON tristate "One Laptop Per Child Display CONtroller support" - depends on OLPC && BROKEN + depends on OLPC && FB select I2C ---help--- Add support for the OLPC XO 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_OLPC_DCON_1 + bool "OLPC XO-1 DCON support" + depends on FB_OLPC_DCON + default y + ---help--- + Enable support for the DCON in XO-1 model laptops. The kernel + communicates with the DCON using model-specific code. If you + have an XO-1 (or if you're unsure what model you have), you should + say 'Y'. + +config FB_OLPC_DCON_1_5 + bool "OLPC XO-1.5 DCON support" + depends on FB_OLPC_DCON && ACPI + default y + ---help--- + Enable support for the DCON in XO-1.5 model laptops. The kernel + communicates with the DCON using model-specific code. If you + have an XO-1.5 (or if you're unsure what model you have), you + should say 'Y'. diff --git a/drivers/staging/olpc_dcon/Makefile b/drivers/staging/olpc_dcon/Makefile index cd8f289..36c7e67 100644 --- a/drivers/staging/olpc_dcon/Makefile +++ b/drivers/staging/olpc_dcon/Makefile @@ -1 +1,6 @@ -obj-$(CONFIG_FB_OLPC_DCON) += olpc_dcon.o +olpc-dcon-objs += olpc_dcon.o +olpc-dcon-$(CONFIG_FB_OLPC_DCON_1) += olpc_dcon_xo_1.o +olpc-dcon-$(CONFIG_FB_OLPC_DCON_1_5) += olpc_dcon_xo_1_5.o +obj-$(CONFIG_FB_OLPC_DCON) += olpc-dcon.o + + diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c b/drivers/staging/olpc_dcon/olpc_dcon.c index 56a283d..b90c2cf 100644 --- a/drivers/staging/olpc_dcon/olpc_dcon.c +++ b/drivers/staging/olpc_dcon/olpc_dcon.c @@ -4,7 +4,7 @@ * Copyright © 2006-2007 Red Hat, Inc. * Copyright © 2006-2007 Advanced Micro Devices, Inc. * Copyright © 2009 VIA Technology, Inc. - * Copyright (c) 2010 Andres Salomon <dilinger@queued.net> + * Copyright (c) 2010-2011 Andres Salomon <dilinger@queued.net> * * This program is free software. You can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public @@ -23,8 +23,7 @@ #include <linux/delay.h> #include <linux/backlight.h> #include <linux/device.h> -#include <linux/notifier.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <linux/ctype.h> #include <linux/reboot.h> #include <asm/tsc.h> @@ -44,65 +43,32 @@ module_param(noinit, int, 0444); static int useaa = 1; module_param(useaa, int, 0444); -struct dcon_platform_data { - int (*init)(void); - void (*bus_stabilize_wiggle)(void); - void (*set_dconload)(int); - u8 (*read_status)(void); -}; - static struct dcon_platform_data *pdata; /* I2C structures */ -static struct i2c_driver dcon_driver; -static struct i2c_client *dcon_client; - /* Platform devices */ static struct platform_device *dcon_device; -/* Backlight device */ -static struct backlight_device *dcon_bl_dev; - -static struct fb_info *fbinfo; - -/* set this to 1 while controlling fb blank state from this driver */ -static int ignore_fb_events = 0; - -/* Current source, initialized at probe time */ -static int dcon_source; - -/* Desired source */ -static int dcon_pending; - -/* Current output type */ -static int dcon_output = DCON_OUTPUT_COLOR; - -/* Current sleep status (not yet implemented) */ -static int dcon_sleep_val = DCON_ACTIVE; - -/* Shadow register for the DCON_REG_MODE register */ -static unsigned short dcon_disp_mode; - -/* Variables used during switches */ -static int dcon_switched; -static struct timespec dcon_irq_time; -static struct timespec dcon_load_time; - static DECLARE_WAIT_QUEUE_HEAD(dcon_wait_queue); static unsigned short normal_i2c[] = { 0x0d, I2C_CLIENT_END }; -#define dcon_write(reg,val) i2c_smbus_write_word_data(dcon_client,reg,val) -#define dcon_read(reg) i2c_smbus_read_word_data(dcon_client,reg) +static s32 dcon_write(struct dcon_priv *dcon, u8 reg, u16 val) +{ + return i2c_smbus_write_word_data(dcon->client, reg, val); +} -/* The current backlight value - this saves us some smbus traffic */ -static int bl_val = -1; +static s32 dcon_read(struct dcon_priv *dcon, u8 reg) +{ + return i2c_smbus_read_word_data(dcon->client, reg); +} /* ===== API functions - these are called by a variety of users ==== */ -static int dcon_hw_init(struct i2c_client *client, int is_init) +static int dcon_hw_init(struct dcon_priv *dcon, int is_init) { + struct i2c_client *client = dcon->client; uint16_t ver; int rc = 0; @@ -117,7 +83,8 @@ static int dcon_hw_init(struct i2c_client *client, int is_init) if (is_init) { printk(KERN_INFO "olpc-dcon: Discovered DCON version %x\n", ver & 0xFF); - if ((rc = pdata->init()) != 0) { + rc = pdata->init(dcon); + if (rc != 0) { printk(KERN_ERR "olpc-dcon: Unable to init.\n"); goto err; } @@ -133,14 +100,13 @@ static int dcon_hw_init(struct i2c_client *client, int is_init) i2c_smbus_write_word_data(client, 0x0b, 0x007a); i2c_smbus_write_word_data(client, 0x36, 0x025c); i2c_smbus_write_word_data(client, 0x37, 0x025e); - + /* Initialise SDRAM */ i2c_smbus_write_word_data(client, 0x3b, 0x002b); i2c_smbus_write_word_data(client, 0x41, 0x0101); i2c_smbus_write_word_data(client, 0x42, 0x0101); - } - else if (!noinit) { + } else if (!noinit) { /* SDRAM setup/hold time */ i2c_smbus_write_word_data(client, 0x3a, 0xc040); i2c_smbus_write_word_data(client, 0x41, 0x0000); @@ -150,11 +116,12 @@ static int dcon_hw_init(struct i2c_client *client, int is_init) /* Colour swizzle, AA, no passthrough, backlight */ if (is_init) { - dcon_disp_mode = MODE_PASSTHRU | MODE_BL_ENABLE | MODE_CSWIZZLE; + dcon->disp_mode = MODE_PASSTHRU | MODE_BL_ENABLE | + MODE_CSWIZZLE; if (useaa) - dcon_disp_mode |= MODE_COL_AA; + dcon->disp_mode |= MODE_COL_AA; } - i2c_smbus_write_word_data(client, DCON_REG_MODE, dcon_disp_mode); + i2c_smbus_write_word_data(client, DCON_REG_MODE, dcon->disp_mode); /* Set the scanline to interrupt on during resume */ @@ -173,7 +140,7 @@ err: * smbus. For newer models, we simply BUG(); we want to know if this * still happens despite the power fixes that have been made! */ -static int dcon_bus_stabilize(struct i2c_client *client, int is_powered_down) +static int dcon_bus_stabilize(struct dcon_priv *dcon, int is_powered_down) { unsigned long timeout; int x; @@ -181,19 +148,20 @@ static int dcon_bus_stabilize(struct i2c_client *client, int is_powered_down) power_up: if (is_powered_down) { x = 1; - if ((x = olpc_ec_cmd(0x26, (unsigned char *) &x, 1, NULL, 0))) { + x = olpc_ec_cmd(0x26, (unsigned char *) &x, 1, NULL, 0); + if (x) { printk(KERN_WARNING "olpc-dcon: unable to force dcon " "to power up: %d!\n", x); return x; } msleep(10); /* we'll be conservative */ } - + pdata->bus_stabilize_wiggle(); for (x = -1, timeout = 50; timeout && x < 0; timeout--) { msleep(1); - x = dcon_read(DCON_REG_ID); + x = dcon_read(dcon, DCON_REG_ID); } if (x < 0) { printk(KERN_ERR "olpc-dcon: unable to stabilize dcon's " @@ -207,69 +175,44 @@ power_up: } if (is_powered_down) - return dcon_hw_init(client, 0); + return dcon_hw_init(dcon, 0); return 0; } -static int dcon_get_backlight(void) +static void dcon_set_backlight(struct dcon_priv *dcon, u8 level) { - if (dcon_client == NULL) - return 0; - - if (bl_val == -1) - bl_val = dcon_read(DCON_REG_BRIGHT) & 0x0F; - - return bl_val; -} - - -static void dcon_set_backlight_hw(int level) -{ - bl_val = level & 0x0F; - dcon_write(DCON_REG_BRIGHT, bl_val); + dcon->bl_val = level; + dcon_write(dcon, DCON_REG_BRIGHT, dcon->bl_val); /* Purposely turn off the backlight when we go to level 0 */ - if (bl_val == 0) { - dcon_disp_mode &= ~MODE_BL_ENABLE; - dcon_write(DCON_REG_MODE, dcon_disp_mode); - } else if (!(dcon_disp_mode & MODE_BL_ENABLE)) { - dcon_disp_mode |= MODE_BL_ENABLE; - dcon_write(DCON_REG_MODE, dcon_disp_mode); + if (dcon->bl_val == 0) { + dcon->disp_mode &= ~MODE_BL_ENABLE; + dcon_write(dcon, DCON_REG_MODE, dcon->disp_mode); + } else if (!(dcon->disp_mode & MODE_BL_ENABLE)) { + dcon->disp_mode |= MODE_BL_ENABLE; + dcon_write(dcon, DCON_REG_MODE, dcon->disp_mode); } } -static void dcon_set_backlight(int level) -{ - if (dcon_client == NULL) - return; - - if (bl_val == (level & 0x0F)) - return; - - dcon_set_backlight_hw(level); -} - /* Set the output type to either color or mono */ - -static int dcon_set_output(int arg) +static int dcon_set_mono_mode(struct dcon_priv *dcon, bool enable_mono) { - if (dcon_output == arg) + if (dcon->mono == enable_mono) return 0; - dcon_output = arg; + dcon->mono = enable_mono; - if (arg == DCON_OUTPUT_MONO) { - dcon_disp_mode &= ~(MODE_CSWIZZLE | MODE_COL_AA); - dcon_disp_mode |= MODE_MONO_LUMA; - } - else { - dcon_disp_mode &= ~(MODE_MONO_LUMA); - dcon_disp_mode |= MODE_CSWIZZLE; + if (enable_mono) { + dcon->disp_mode &= ~(MODE_CSWIZZLE | MODE_COL_AA); + dcon->disp_mode |= MODE_MONO_LUMA; + } else { + dcon->disp_mode &= ~(MODE_MONO_LUMA); + dcon->disp_mode |= MODE_CSWIZZLE; if (useaa) - dcon_disp_mode |= MODE_COL_AA; + dcon->disp_mode |= MODE_COL_AA; } - dcon_write(DCON_REG_MODE, dcon_disp_mode); + dcon_write(dcon, DCON_REG_MODE, dcon->disp_mode); return 0; } @@ -277,55 +220,55 @@ static int dcon_set_output(int arg) * DCONLOAD works in a sleep and account for it accordingly */ -static void dcon_sleep(int state) +static void dcon_sleep(struct dcon_priv *dcon, bool sleep) { int x; /* Turn off the backlight and put the DCON to sleep */ - if (state == dcon_sleep_val) + if (dcon->asleep == sleep) return; if (!olpc_board_at_least(olpc_board(0xc2))) return; - if (state == DCON_SLEEP) { + if (sleep) { x = 0; - if ((x = olpc_ec_cmd(0x26, (unsigned char *) &x, 1, NULL, 0))) + x = olpc_ec_cmd(0x26, (unsigned char *) &x, 1, NULL, 0); + if (x) printk(KERN_WARNING "olpc-dcon: unable to force dcon " "to power down: %d!\n", x); else - dcon_sleep_val = state; - } - else { + dcon->asleep = sleep; + } else { /* Only re-enable the backlight if the backlight value is set */ - if (bl_val != 0) - dcon_disp_mode |= MODE_BL_ENABLE; - - if ((x=dcon_bus_stabilize(dcon_client, 1))) + if (dcon->bl_val != 0) + dcon->disp_mode |= MODE_BL_ENABLE; + x = dcon_bus_stabilize(dcon, 1); + if (x) printk(KERN_WARNING "olpc-dcon: unable to reinit dcon" " hardware: %d!\n", x); else - dcon_sleep_val = state; + dcon->asleep = sleep; /* Restore backlight */ - dcon_set_backlight_hw(bl_val); + dcon_set_backlight(dcon, dcon->bl_val); } /* We should turn off some stuff in the framebuffer - but what? */ } /* the DCON seems to get confused if we change DCONLOAD too - * frequently -- i.e., approximately faster than frame time. + * frequently -- i.e., approximately faster than frame time. * normally we don't change it this fast, so in general we won't * delay here. */ -void dcon_load_holdoff(void) +static void dcon_load_holdoff(struct dcon_priv *dcon) { struct timespec delta_t, now; - while(1) { + while (1) { getnstimeofday(&now); - delta_t = timespec_sub(now, dcon_load_time); + delta_t = timespec_sub(now, dcon->load_time); if (delta_t.tv_sec != 0 || delta_t.tv_nsec > NSEC_PER_MSEC * 20) { break; @@ -333,36 +276,65 @@ void dcon_load_holdoff(void) mdelay(4); } } -/* Set the source of the display (CPU or DCON) */ +static bool dcon_blank_fb(struct dcon_priv *dcon, bool blank) +{ + int err; + + if (!lock_fb_info(dcon->fbinfo)) { + dev_err(&dcon->client->dev, "unable to lock framebuffer\n"); + return false; + } + console_lock(); + dcon->ignore_fb_events = true; + err = fb_blank(dcon->fbinfo, + blank ? FB_BLANK_POWERDOWN : FB_BLANK_UNBLANK); + dcon->ignore_fb_events = false; + console_unlock(); + unlock_fb_info(dcon->fbinfo); + + if (err) { + dev_err(&dcon->client->dev, "couldn't %sblank framebuffer\n", + blank ? "" : "un"); + return false; + } + return true; +} + +/* Set the source of the display (CPU or DCON) */ static void dcon_source_switch(struct work_struct *work) { + struct dcon_priv *dcon = container_of(work, struct dcon_priv, + switch_source); DECLARE_WAITQUEUE(wait, current); - int source = dcon_pending; + int source = dcon->pending_src; - if (dcon_source == source) + if (dcon->curr_src == source) return; - dcon_load_holdoff(); + dcon_load_holdoff(dcon); - dcon_switched = 0; + dcon->switched = false; switch (source) { case DCON_SOURCE_CPU: printk("dcon_source_switch to CPU\n"); /* Enable the scanline interrupt bit */ - if (dcon_write(DCON_REG_MODE, dcon_disp_mode | MODE_SCAN_INT)) - printk(KERN_ERR "olpc-dcon: couldn't enable scanline interrupt!\n"); + if (dcon_write(dcon, DCON_REG_MODE, + dcon->disp_mode | MODE_SCAN_INT)) + printk(KERN_ERR + "olpc-dcon: couldn't enable scanline interrupt!\n"); else { /* Wait up to one second for the scanline interrupt */ - wait_event_timeout(dcon_wait_queue, dcon_switched == 1, HZ); + wait_event_timeout(dcon_wait_queue, + dcon->switched == true, HZ); } - if (!dcon_switched) + if (!dcon->switched) printk(KERN_ERR "olpc-dcon: Timeout entering CPU mode; expect a screen glitch.\n"); /* Turn off the scanline interrupt */ - if (dcon_write(DCON_REG_MODE, dcon_disp_mode)) + if (dcon_write(dcon, DCON_REG_MODE, dcon->disp_mode)) printk(KERN_ERR "olpc-dcon: couldn't disable scanline interrupt!\n"); /* @@ -373,21 +345,15 @@ static void dcon_source_switch(struct work_struct *work) * * For now, we just hope.. */ - console_lock(); - ignore_fb_events = 1; - if (fb_blank(fbinfo, FB_BLANK_UNBLANK)) { - ignore_fb_events = 0; - console_unlock(); + if (!dcon_blank_fb(dcon, false)) { printk(KERN_ERR "olpc-dcon: Failed to enter CPU mode\n"); - dcon_pending = DCON_SOURCE_DCON; + dcon->pending_src = DCON_SOURCE_DCON; return; } - ignore_fb_events = 0; - console_unlock(); /* And turn off the DCON */ pdata->set_dconload(1); - getnstimeofday(&dcon_load_time); + getnstimeofday(&dcon->load_time); printk(KERN_INFO "olpc-dcon: The CPU has control\n"); break; @@ -396,20 +362,20 @@ static void dcon_source_switch(struct work_struct *work) int t; struct timespec delta_t; - printk("dcon_source_switch to DCON\n"); + printk(KERN_INFO "dcon_source_switch to DCON\n"); add_wait_queue(&dcon_wait_queue, &wait); set_current_state(TASK_UNINTERRUPTIBLE); /* Clear DCONLOAD - this implies that the DCON is in control */ pdata->set_dconload(0); - getnstimeofday(&dcon_load_time); + getnstimeofday(&dcon->load_time); t = schedule_timeout(HZ/2); remove_wait_queue(&dcon_wait_queue, &wait); set_current_state(TASK_RUNNING); - if (!dcon_switched) { + if (!dcon->switched) { printk(KERN_ERR "olpc-dcon: Timeout entering DCON mode; expect a screen glitch.\n"); } else { /* sometimes the DCON doesn't follow its own rules, @@ -420,28 +386,22 @@ static void dcon_source_switch(struct work_struct *work) * the time between asserting DCONLOAD and the IRQ -- * if it's less than 20msec, then the DCON couldn't * have seen two VSYNC pulses. in that case we - * deassert and reassert, and hope for the best. + * deassert and reassert, and hope for the best. * see http://dev.laptop.org/ticket/9664 */ - delta_t = timespec_sub(dcon_irq_time, dcon_load_time); - if (dcon_switched && delta_t.tv_sec == 0 && + delta_t = timespec_sub(dcon->irq_time, dcon->load_time); + if (dcon->switched && delta_t.tv_sec == 0 && delta_t.tv_nsec < NSEC_PER_MSEC * 20) { printk(KERN_ERR "olpc-dcon: missed loading, retrying\n"); pdata->set_dconload(1); mdelay(41); pdata->set_dconload(0); - getnstimeofday(&dcon_load_time); + getnstimeofday(&dcon->load_time); mdelay(41); } } - console_lock(); - ignore_fb_events = 1; - if (fb_blank(fbinfo, FB_BLANK_POWERDOWN)) - printk(KERN_ERR "olpc-dcon: couldn't blank fb!\n"); - ignore_fb_events = 0; - console_unlock(); - + dcon_blank_fb(dcon, true); printk(KERN_INFO "olpc-dcon: The DCON has control\n"); break; } @@ -449,66 +409,53 @@ static void dcon_source_switch(struct work_struct *work) BUG(); } - dcon_source = source; + dcon->curr_src = source; } -static DECLARE_WORK(dcon_work, dcon_source_switch); - -static void dcon_set_source(int arg) +static void dcon_set_source(struct dcon_priv *dcon, int arg) { - if (dcon_pending == arg) + if (dcon->pending_src == arg) return; - dcon_pending = arg; + dcon->pending_src = arg; - if ((dcon_source != arg) && !work_pending(&dcon_work)) - schedule_work(&dcon_work); + if ((dcon->curr_src != arg) && !work_pending(&dcon->switch_source)) + schedule_work(&dcon->switch_source); } -static void dcon_set_source_sync(int arg) +static void dcon_set_source_sync(struct dcon_priv *dcon, int arg) { - dcon_set_source(arg); + dcon_set_source(dcon, arg); flush_scheduled_work(); } -static int dconbl_set(struct backlight_device *dev) { - - int level = dev->props.brightness; - - if (dev->props.power != FB_BLANK_UNBLANK) - level = 0; - - dcon_set_backlight(level); - return 0; -} - -static int dconbl_get(struct backlight_device *dev) { - return dcon_get_backlight(); -} - static ssize_t dcon_mode_show(struct device *dev, struct device_attribute *attr, char *buf) { - return sprintf(buf, "%4.4X\n", dcon_disp_mode); + struct dcon_priv *dcon = dev_get_drvdata(dev); + return sprintf(buf, "%4.4X\n", dcon->disp_mode); } static ssize_t dcon_sleep_show(struct device *dev, struct device_attribute *attr, char *buf) { - return sprintf(buf, "%d\n", dcon_sleep_val); + struct dcon_priv *dcon = dev_get_drvdata(dev); + return sprintf(buf, "%d\n", dcon->asleep); } static ssize_t dcon_freeze_show(struct device *dev, struct device_attribute *attr, char *buf) { - return sprintf(buf, "%d\n", dcon_source == DCON_SOURCE_DCON ? 1 : 0); + struct dcon_priv *dcon = dev_get_drvdata(dev); + return sprintf(buf, "%d\n", dcon->curr_src == DCON_SOURCE_DCON ? 1 : 0); } -static ssize_t dcon_output_show(struct device *dev, +static ssize_t dcon_mono_show(struct device *dev, struct device_attribute *attr, char *buf) { - return sprintf(buf, "%d\n", dcon_output); + struct dcon_priv *dcon = dev_get_drvdata(dev); + return sprintf(buf, "%d\n", dcon->mono); } static ssize_t dcon_resumeline_show(struct device *dev, @@ -517,59 +464,43 @@ static ssize_t dcon_resumeline_show(struct device *dev, return sprintf(buf, "%d\n", resumeline); } -static int _strtoul(const char *buf, int len, unsigned int *val) -{ - - char *endp; - unsigned int output = simple_strtoul(buf, &endp, 0); - int size = endp - buf; - - if (*endp && isspace(*endp)) - size++; - - if (size != len) - return -EINVAL; - - *val = output; - return 0; -} - -static ssize_t dcon_output_store(struct device *dev, +static ssize_t dcon_mono_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - int output; - int rc = -EINVAL; + unsigned long enable_mono; + int rc; - if (_strtoul(buf, count, &output)) - return -EINVAL; + rc = strict_strtoul(buf, 10, &enable_mono); + if (rc) + return rc; - if (output == DCON_OUTPUT_COLOR || output == DCON_OUTPUT_MONO) { - dcon_set_output(output); - rc = count; - } + dcon_set_mono_mode(dev_get_drvdata(dev), enable_mono ? true : false); - return rc; + return count; } static ssize_t dcon_freeze_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - int output; + struct dcon_priv *dcon = dev_get_drvdata(dev); + unsigned long output; + int ret; - if (_strtoul(buf, count, &output)) - return -EINVAL; + ret = strict_strtoul(buf, 10, &output); + if (ret) + return ret; - printk("dcon_freeze_store: %d\n", output); + printk(KERN_INFO "dcon_freeze_store: %lu\n", output); switch (output) { case 0: - dcon_set_source(DCON_SOURCE_CPU); + dcon_set_source(dcon, DCON_SOURCE_CPU); break; case 1: - dcon_set_source_sync(DCON_SOURCE_DCON); + dcon_set_source_sync(dcon, DCON_SOURCE_DCON); break; - case 2: // normally unused - dcon_set_source(DCON_SOURCE_DCON); + case 2: /* normally unused */ + dcon_set_source(dcon, DCON_SOURCE_DCON); break; default: return -EINVAL; @@ -581,28 +512,30 @@ static ssize_t dcon_freeze_store(struct device *dev, static ssize_t dcon_resumeline_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - int rl; - int rc = -EINVAL; + unsigned long rl; + int rc; - if (_strtoul(buf, count, &rl)) + rc = strict_strtoul(buf, 10, &rl); + if (rc) return rc; resumeline = rl; - dcon_write(DCON_REG_SCAN_INT, resumeline); - rc = count; + dcon_write(dev_get_drvdata(dev), DCON_REG_SCAN_INT, resumeline); - return rc; + return count; } static ssize_t dcon_sleep_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - int output; + unsigned long output; + int ret; - if (_strtoul(buf, count, &output)) - return -EINVAL; + ret = strict_strtoul(buf, 10, &output); + if (ret) + return ret; - dcon_sleep(output ? DCON_SLEEP : DCON_ACTIVE); + dcon_sleep(dev_get_drvdata(dev), output ? true : false); return count; } @@ -610,33 +543,56 @@ static struct device_attribute dcon_device_files[] = { __ATTR(mode, 0444, dcon_mode_show, NULL), __ATTR(sleep, 0644, dcon_sleep_show, dcon_sleep_store), __ATTR(freeze, 0644, dcon_freeze_show, dcon_freeze_store), - __ATTR(output, 0644, dcon_output_show, dcon_output_store), + __ATTR(monochrome, 0644, dcon_mono_show, dcon_mono_store), __ATTR(resumeline, 0644, dcon_resumeline_show, dcon_resumeline_store), }; +static int dcon_bl_update(struct backlight_device *dev) +{ + struct dcon_priv *dcon = bl_get_data(dev); + u8 level = dev->props.brightness & 0x0F; + + if (dev->props.power != FB_BLANK_UNBLANK) + level = 0; + + if (level != dcon->bl_val) + dcon_set_backlight(dcon, level); + + return 0; +} + +static int dcon_bl_get(struct backlight_device *dev) +{ + struct dcon_priv *dcon = bl_get_data(dev); + return dcon->bl_val; +} + static const struct backlight_ops dcon_bl_ops = { - .get_brightness = dconbl_get, - .update_status = dconbl_set + .update_status = dcon_bl_update, + .get_brightness = dcon_bl_get, }; +static struct backlight_properties dcon_bl_props = { + .max_brightness = 15, + .power = FB_BLANK_UNBLANK, +}; -static int dcon_reboot_notify(struct notifier_block *nb, unsigned long foo, void *bar) +static int dcon_reboot_notify(struct notifier_block *nb, + unsigned long foo, void *bar) { - if (dcon_client == NULL) + struct dcon_priv *dcon = container_of(nb, struct dcon_priv, reboot_nb); + + if (!dcon || !dcon->client) return 0; /* Turn off the DCON. Entirely. */ - dcon_write(DCON_REG_MODE, 0x39); - dcon_write(DCON_REG_MODE, 0x32); + dcon_write(dcon, DCON_REG_MODE, 0x39); + dcon_write(dcon, DCON_REG_MODE, 0x32); return 0; } -static struct notifier_block dcon_nb = { - .notifier_call = dcon_reboot_notify, - .priority = -1, -}; - -static int unfreeze_on_panic(struct notifier_block *nb, unsigned long e, void *p) +static int unfreeze_on_panic(struct notifier_block *nb, + unsigned long e, void *p) { pdata->set_dconload(1); return NOTIFY_DONE; @@ -650,21 +606,20 @@ static struct notifier_block dcon_panic_nb = { * When the framebuffer sleeps due to external sources (e.g. user idle), power * down the DCON as well. Power it back up when the fb comes back to life. */ -static int fb_notifier_callback(struct notifier_block *self, unsigned long event, void *data) +static int dcon_fb_notifier(struct notifier_block *self, + unsigned long event, void *data) { struct fb_event *evdata = data; + struct dcon_priv *dcon = container_of(self, struct dcon_priv, + fbevent_nb); int *blank = (int *) evdata->data; if (((event != FB_EVENT_BLANK) && (event != FB_EVENT_CONBLANK)) || - ignore_fb_events) + dcon->ignore_fb_events) return 0; - dcon_sleep((*blank) ? DCON_SLEEP : DCON_ACTIVE); + dcon_sleep(dcon, *blank ? true : false); return 0; } -static struct notifier_block fb_nb = { - .notifier_call = fb_notifier_callback, -}; - static int dcon_detect(struct i2c_client *client, struct i2c_board_info *info) { strlcpy(info->type, "olpc_dcon", I2C_NAME_SIZE); @@ -674,12 +629,32 @@ static int dcon_detect(struct i2c_client *client, struct i2c_board_info *info) static int dcon_probe(struct i2c_client *client, const struct i2c_device_id *id) { - int rc, i; + struct dcon_priv *dcon; + int rc, i, j; + + if (!pdata) + return -ENXIO; - if (num_registered_fb >= 1) - fbinfo = registered_fb[0]; + dcon = kzalloc(sizeof(*dcon), GFP_KERNEL); + if (!dcon) + return -ENOMEM; - rc = dcon_hw_init(client, 1); + dcon->client = client; + INIT_WORK(&dcon->switch_source, dcon_source_switch); + dcon->reboot_nb.notifier_call = dcon_reboot_notify; + dcon->reboot_nb.priority = -1; + dcon->fbevent_nb.notifier_call = dcon_fb_notifier; + + i2c_set_clientdata(client, dcon); + + if (num_registered_fb < 1) { + dev_err(&client->dev, "DCON driver requires a registered fb\n"); + rc = -EIO; + goto einit; + } + dcon->fbinfo = registered_fb[0]; + + rc = dcon_hw_init(dcon, 1); if (rc) goto einit; @@ -688,71 +663,79 @@ static int dcon_probe(struct i2c_client *client, const struct i2c_device_id *id) dcon_device = platform_device_alloc("dcon", -1); if (dcon_device == NULL) { - printk("dcon: Unable to create the DCON device\n"); + printk(KERN_ERR "dcon: Unable to create the DCON device\n"); rc = -ENOMEM; goto eirq; } - /* Place holder...*/ - i2c_set_clientdata(client, dcon_device); + rc = platform_device_add(dcon_device); + platform_set_drvdata(dcon_device, dcon); - if ((rc = platform_device_add(dcon_device))) { - printk("dcon: Unable to add the DCON device\n"); + if (rc) { + printk(KERN_ERR "dcon: Unable to add the DCON device\n"); goto edev; } - for(i = 0; i < ARRAY_SIZE(dcon_device_files); i++) - device_create_file(&dcon_device->dev, &dcon_device_files[i]); - - /* Add the backlight device for the DCON */ - - dcon_client = client; - - dcon_bl_dev = backlight_device_register("dcon-bl", &dcon_device->dev, - NULL, &dcon_bl_ops, NULL); - - if (IS_ERR(dcon_bl_dev)) { - printk("Could not register the backlight device for the DCON (%ld)\n", PTR_ERR(dcon_bl_dev)); - dcon_bl_dev = NULL; + for (i = 0; i < ARRAY_SIZE(dcon_device_files); i++) { + rc = device_create_file(&dcon_device->dev, + &dcon_device_files[i]); + if (rc) { + dev_err(&dcon_device->dev, "Cannot create sysfs file\n"); + goto ecreate; + } } - else { - dcon_bl_dev->props.max_brightness = 15; - dcon_bl_dev->props.power = FB_BLANK_UNBLANK; - dcon_bl_dev->props.brightness = dcon_get_backlight(); - backlight_update_status(dcon_bl_dev); + dcon->bl_val = dcon_read(dcon, DCON_REG_BRIGHT) & 0x0F; + + /* Add the backlight device for the DCON */ + dcon_bl_props.brightness = dcon->bl_val; + dcon->bl_dev = backlight_device_register("dcon-bl", &dcon_device->dev, + dcon, &dcon_bl_ops, &dcon_bl_props); + if (IS_ERR(dcon->bl_dev)) { + dev_err(&client->dev, "cannot register backlight dev (%ld)\n", + PTR_ERR(dcon->bl_dev)); + dcon->bl_dev = NULL; } - register_reboot_notifier(&dcon_nb); + register_reboot_notifier(&dcon->reboot_nb); atomic_notifier_chain_register(&panic_notifier_list, &dcon_panic_nb); - fb_register_client(&fb_nb); + fb_register_client(&dcon->fbevent_nb); return 0; + ecreate: + for (j = 0; j < i; j++) + device_remove_file(&dcon_device->dev, &dcon_device_files[j]); edev: platform_device_unregister(dcon_device); dcon_device = NULL; eirq: - free_irq(DCON_IRQ, &dcon_driver); + free_irq(DCON_IRQ, dcon); einit: + i2c_set_clientdata(client, NULL); + kfree(dcon); return rc; } static int dcon_remove(struct i2c_client *client) { - dcon_client = NULL; + struct dcon_priv *dcon = i2c_get_clientdata(client); + + i2c_set_clientdata(client, NULL); - fb_unregister_client(&fb_nb); - unregister_reboot_notifier(&dcon_nb); + fb_unregister_client(&dcon->fbevent_nb); + unregister_reboot_notifier(&dcon->reboot_nb); atomic_notifier_chain_unregister(&panic_notifier_list, &dcon_panic_nb); - free_irq(DCON_IRQ, &dcon_driver); + free_irq(DCON_IRQ, dcon); - if (dcon_bl_dev != NULL) - backlight_device_unregister(dcon_bl_dev); + if (dcon->bl_dev) + backlight_device_unregister(dcon->bl_dev); if (dcon_device != NULL) platform_device_unregister(dcon_device); - cancel_work_sync(&dcon_work); + cancel_work_sync(&dcon->switch_source); + + kfree(dcon); return 0; } @@ -760,9 +743,11 @@ static int dcon_remove(struct i2c_client *client) #ifdef CONFIG_PM static int dcon_suspend(struct i2c_client *client, pm_message_t state) { - if (dcon_sleep_val == DCON_ACTIVE) { + struct dcon_priv *dcon = i2c_get_clientdata(client); + + if (!dcon->asleep) { /* Set up the DCON to have the source */ - dcon_set_source_sync(DCON_SOURCE_DCON); + dcon_set_source_sync(dcon, DCON_SOURCE_DCON); } return 0; @@ -770,9 +755,11 @@ static int dcon_suspend(struct i2c_client *client, pm_message_t state) static int dcon_resume(struct i2c_client *client) { - if (dcon_sleep_val == DCON_ACTIVE) { - dcon_bus_stabilize(client, 0); - dcon_set_source(DCON_SOURCE_CPU); + struct dcon_priv *dcon = i2c_get_clientdata(client); + + if (!dcon->asleep) { + dcon_bus_stabilize(dcon, 0); + dcon_set_source(dcon, DCON_SOURCE_CPU); } return 0; @@ -781,8 +768,9 @@ static int dcon_resume(struct i2c_client *client) #endif -static irqreturn_t dcon_interrupt(int irq, void *id) +irqreturn_t dcon_interrupt(int irq, void *id) { + struct dcon_priv *dcon = id; int status = pdata->read_status(); if (status == -1) @@ -795,8 +783,8 @@ static irqreturn_t dcon_interrupt(int irq, void *id) case 2: /* switch to DCON mode */ case 1: /* switch to CPU mode */ - dcon_switched = 1; - getnstimeofday(&dcon_irq_time); + dcon->switched = true; + getnstimeofday(&dcon->irq_time); wake_up(&dcon_wait_queue); break; @@ -808,9 +796,9 @@ static irqreturn_t dcon_interrupt(int irq, void *id) * of the DCON happened long before this point. * see http://dev.laptop.org/ticket/9869 */ - if (dcon_source != dcon_pending && !dcon_switched) { - dcon_switched = 1; - getnstimeofday(&dcon_irq_time); + if (dcon->curr_src != dcon->pending_src && !dcon->switched) { + dcon->switched = true; + getnstimeofday(&dcon->irq_time); wake_up(&dcon_wait_queue); printk(KERN_DEBUG "olpc-dcon: switching w/ status 0/0\n"); } else { @@ -821,14 +809,14 @@ static irqreturn_t dcon_interrupt(int irq, void *id) return IRQ_HANDLED; } -static struct i2c_device_id dcon_idtable[] = { +static const struct i2c_device_id dcon_idtable[] = { { "olpc_dcon", 0 }, { } }; MODULE_DEVICE_TABLE(i2c, dcon_idtable); -static struct i2c_driver dcon_driver = { +struct i2c_driver dcon_driver = { .driver = { .name = "olpc_dcon", }, @@ -844,14 +832,19 @@ static struct i2c_driver dcon_driver = { #endif }; -#include "olpc_dcon_xo_1.c" - static int __init olpc_dcon_init(void) { - pdata = &dcon_pdata_xo_1; +#ifdef CONFIG_FB_OLPC_DCON_1_5 + /* XO-1.5 */ + if (olpc_board_at_least(olpc_board(0xd0))) + pdata = &dcon_pdata_xo_1_5; +#endif +#ifdef CONFIG_FB_OLPC_DCON_1 + if (!pdata) + pdata = &dcon_pdata_xo_1; +#endif - i2c_add_driver(&dcon_driver); - return 0; + return i2c_add_driver(&dcon_driver); } static void __exit olpc_dcon_exit(void) diff --git a/drivers/staging/olpc_dcon/olpc_dcon.h b/drivers/staging/olpc_dcon/olpc_dcon.h index e566d21..0264c94 100644 --- a/drivers/staging/olpc_dcon/olpc_dcon.h +++ b/drivers/staging/olpc_dcon/olpc_dcon.h @@ -1,6 +1,9 @@ #ifndef OLPC_DCON_H_ #define OLPC_DCON_H_ +#include <linux/notifier.h> +#include <linux/workqueue.h> + /* DCON registers */ #define DCON_REG_ID 0 @@ -41,15 +44,59 @@ #define DCON_SOURCE_DCON 0 #define DCON_SOURCE_CPU 1 -/* Output values */ -#define DCON_OUTPUT_COLOR 0 -#define DCON_OUTPUT_MONO 1 - -/* Sleep values */ -#define DCON_ACTIVE 0 -#define DCON_SLEEP 1 - /* Interrupt */ #define DCON_IRQ 6 +struct dcon_priv { + struct i2c_client *client; + struct fb_info *fbinfo; + struct backlight_device *bl_dev; + + struct work_struct switch_source; + struct notifier_block reboot_nb; + struct notifier_block fbevent_nb; + + /* Shadow register for the DCON_REG_MODE register */ + u8 disp_mode; + + /* The current backlight value - this saves us some smbus traffic */ + u8 bl_val; + + /* Current source, initialized at probe time */ + int curr_src; + + /* Desired source */ + int pending_src; + + /* Variables used during switches */ + bool switched; + struct timespec irq_time; + struct timespec load_time; + + /* Current output type; true == mono, false == color */ + bool mono; + bool asleep; + /* This get set while controlling fb blank state from the driver */ + bool ignore_fb_events; +}; + +struct dcon_platform_data { + int (*init)(struct dcon_priv *); + void (*bus_stabilize_wiggle)(void); + void (*set_dconload)(int); + u8 (*read_status)(void); +}; + +#include <linux/interrupt.h> + +extern irqreturn_t dcon_interrupt(int irq, void *id); + +#ifdef CONFIG_FB_OLPC_DCON_1 +extern struct dcon_platform_data dcon_pdata_xo_1; +#endif + +#ifdef CONFIG_FB_OLPC_DCON_1_5 +extern struct dcon_platform_data dcon_pdata_xo_1_5; +#endif + #endif diff --git a/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c b/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c index 043198d..b154be7 100644 --- a/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c +++ b/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c @@ -16,7 +16,7 @@ #include "olpc_dcon.h" -static int dcon_init_xo_1(void) +static int dcon_init_xo_1(struct dcon_priv *dcon) { unsigned char lob; @@ -54,10 +54,10 @@ static int dcon_init_xo_1(void) * then a value is set. So, future readings of the pin can use * READ_BACK, but the first one cannot. Awesome, huh? */ - dcon_source = cs5535_gpio_isset(OLPC_GPIO_DCON_LOAD, GPIO_OUTPUT_VAL) + dcon->curr_src = cs5535_gpio_isset(OLPC_GPIO_DCON_LOAD, GPIO_OUTPUT_VAL) ? DCON_SOURCE_CPU : DCON_SOURCE_DCON; - dcon_pending = dcon_source; + dcon->pending_src = dcon->curr_src; /* Set the directions for the GPIO pins */ gpio_direction_input(OLPC_GPIO_DCON_STAT0); @@ -65,7 +65,7 @@ static int dcon_init_xo_1(void) gpio_direction_input(OLPC_GPIO_DCON_IRQ); gpio_direction_input(OLPC_GPIO_DCON_BLANK); gpio_direction_output(OLPC_GPIO_DCON_LOAD, - dcon_source == DCON_SOURCE_CPU); + dcon->curr_src == DCON_SOURCE_CPU); /* Set up the interrupt mappings */ @@ -81,7 +81,7 @@ static int dcon_init_xo_1(void) outb(lob, 0x4d0); /* Register the interupt handler */ - if (request_irq(DCON_IRQ, &dcon_interrupt, 0, "DCON", &dcon_driver)) { + if (request_irq(DCON_IRQ, &dcon_interrupt, 0, "DCON", dcon)) { printk(KERN_ERR "olpc-dcon: failed to request DCON's irq\n"); goto err_req_irq; } @@ -195,7 +195,7 @@ static u8 dcon_read_status_xo_1(void) return status; } -static struct dcon_platform_data dcon_pdata_xo_1 = { +struct dcon_platform_data dcon_pdata_xo_1 = { .init = dcon_init_xo_1, .bus_stabilize_wiggle = dcon_wiggle_xo_1, .set_dconload = dcon_set_dconload_1, diff --git a/drivers/staging/olpc_dcon/olpc_dcon_xo_1_5.c b/drivers/staging/olpc_dcon/olpc_dcon_xo_1_5.c index 4f56098..e213b63 100644 --- a/drivers/staging/olpc_dcon/olpc_dcon_xo_1_5.c +++ b/drivers/staging/olpc_dcon/olpc_dcon_xo_1_5.c @@ -7,22 +7,32 @@ */ #include <linux/acpi.h> +#include <linux/pci.h> +#include <linux/gpio.h> +#include <asm/olpc.h> + +/* TODO: this eventually belongs in linux/vx855.h */ +#define NR_VX855_GPI 14 +#define NR_VX855_GPO 13 +#define NR_VX855_GPIO 15 + +#define VX855_GPI(n) (n) +#define VX855_GPO(n) (NR_VX855_GPI + (n)) +#define VX855_GPIO(n) (NR_VX855_GPI + NR_VX855_GPO + (n)) + +#include "olpc_dcon.h" /* Hardware setup on the XO 1.5: * DCONLOAD connects to - * VX855_GPO12 (not nCR_PWOFF) (rev A) - * VX855_GPIO1 (not SMBCK2) (rev B) + * VX855_GPIO1 (not SMBCK2) * DCONBLANK connects to VX855_GPIO8 (not SSPICLK) unused in driver * DCONSTAT0 connects to VX855_GPI10 (not SSPISDI) * DCONSTAT1 connects to VX855_GPI11 (not nSSPISS) - * DCONIRQ connects to VX855_GPIO12 (on B3. on B2, it goes to - * SMBALRT, which doesn't work.) + * DCONIRQ connects to VX855_GPIO12 * DCONSMBDATA connects to VX855 graphics CRTSPD * DCONSMBCLK connects to VX855 graphics CRTSPCLK */ -#define TEST_B2 0 // define to test B3 paths on a modded B2 board - #define VX855_GENL_PURPOSE_OUTPUT 0x44c // PMIO_Rx4c-4f #define VX855_GPI_STATUS_CHG 0x450 // PMIO_Rx50 #define VX855_GPI_SCI_SMI 0x452 // PMIO_Rx52 @@ -30,39 +40,24 @@ #define PREFIX "OLPC DCON:" -/* - there is no support here for DCONIRQ on 1.5 boards earlier than - B3. the issue is that the DCONIRQ signal on earlier boards is - routed to SMBALRT, which turns out to to be a level sensitive - interrupt. the DCONIRQ signal is far too short (11usec) to - be detected reliably in that case. including support for - DCONIRQ functions no better than none at all. -*/ - -static struct dcon_platform_data dcon_pdata_xo_1_5; - static void dcon_clear_irq(void) { - if (TEST_B2 || olpc_board_at_least(olpc_board(BOARD_XO_1_5_B3))) { - // irq status will appear in PMIO_Rx50[6] (RW1C) on gpio12 - outb(BIT_GPIO12, VX855_GPI_STATUS_CHG); - } + /* irq status will appear in PMIO_Rx50[6] (RW1C) on gpio12 */ + outb(BIT_GPIO12, VX855_GPI_STATUS_CHG); } static int dcon_was_irq(void) { u_int8_t tmp; - if (TEST_B2 || olpc_board_at_least(olpc_board(BOARD_XO_1_5_B3))) { - // irq status will appear in PMIO_Rx50[6] on gpio12 - tmp = inb(VX855_GPI_STATUS_CHG); - return !!(tmp & BIT_GPIO12); - } + /* irq status will appear in PMIO_Rx50[6] on gpio12 */ + tmp = inb(VX855_GPI_STATUS_CHG); + return !!(tmp & BIT_GPIO12); return 0; } -static int dcon_init_xo_1_5(void) +static int dcon_init_xo_1_5(struct dcon_priv *dcon) { unsigned int irq; u_int8_t tmp; @@ -76,14 +71,8 @@ static int dcon_init_xo_1_5(void) return 1; } - if (olpc_board_at_least(olpc_board(BOARD_XO_1_5_B1))) { - pci_read_config_byte(pdev, 0x95, &tmp); - pci_write_config_byte(pdev, 0x95, tmp|0x0c); - } else { - /* Set GPO12 to GPO mode, not nCR_PWOFF */ - pci_read_config_byte(pdev, 0x9b, &tmp); - pci_write_config_byte(pdev, 0x9b, tmp|0x01); - } + pci_read_config_byte(pdev, 0x95, &tmp); + pci_write_config_byte(pdev, 0x95, tmp|0x0c); /* Set GPIO8 to GPIO mode, not SSPICLK */ pci_read_config_byte(pdev, 0xe3, &tmp); @@ -93,43 +82,33 @@ static int dcon_init_xo_1_5(void) pci_read_config_byte(pdev, 0xe4, &tmp); pci_write_config_byte(pdev, 0xe4, tmp|0x08); - if (TEST_B2 || olpc_board_at_least(olpc_board(BOARD_XO_1_5_B3))) { - // clear PMU_RxE1[6] to select SCI on GPIO12 - // clear PMU_RxE0[6] to choose falling edge - pci_read_config_byte(pdev, 0xe1, &tmp); - pci_write_config_byte(pdev, 0xe1, tmp & ~BIT_GPIO12); - pci_read_config_byte(pdev, 0xe0, &tmp); - pci_write_config_byte(pdev, 0xe0, tmp & ~BIT_GPIO12); + /* clear PMU_RxE1[6] to select SCI on GPIO12 */ + /* clear PMU_RxE0[6] to choose falling edge */ + pci_read_config_byte(pdev, 0xe1, &tmp); + pci_write_config_byte(pdev, 0xe1, tmp & ~BIT_GPIO12); + pci_read_config_byte(pdev, 0xe0, &tmp); + pci_write_config_byte(pdev, 0xe0, tmp & ~BIT_GPIO12); - dcon_clear_irq(); + dcon_clear_irq(); - // set PMIO_Rx52[6] to enable SCI/SMI on gpio12 - outb(inb(VX855_GPI_SCI_SMI)|BIT_GPIO12, VX855_GPI_SCI_SMI); - - } + /* set PMIO_Rx52[6] to enable SCI/SMI on gpio12 */ + outb(inb(VX855_GPI_SCI_SMI)|BIT_GPIO12, VX855_GPI_SCI_SMI); /* Determine the current state of DCONLOAD, likely set by firmware */ - if (olpc_board_at_least(olpc_board(BOARD_XO_1_5_B1))) { - // GPIO1 - dcon_source = (inl(VX855_GENL_PURPOSE_OUTPUT) & 0x1000) ? - DCON_SOURCE_CPU : DCON_SOURCE_DCON; - } else { - // GPO12 - dcon_source = (inl(VX855_GENL_PURPOSE_OUTPUT) & 0x04000000) ? + /* GPIO1 */ + dcon->curr_src = (inl(VX855_GENL_PURPOSE_OUTPUT) & 0x1000) ? DCON_SOURCE_CPU : DCON_SOURCE_DCON; - } - dcon_pending = dcon_source; + dcon->pending_src = dcon->curr_src; pci_dev_put(pdev); /* we're sharing the IRQ with ACPI */ irq = acpi_gbl_FADT.sci_interrupt; - if (request_irq(irq, &dcon_interrupt, IRQF_SHARED, "DCON", &dcon_driver)) { + if (request_irq(irq, &dcon_interrupt, IRQF_SHARED, "DCON", dcon)) { printk(KERN_ERR PREFIX "DCON (IRQ%d) allocation failed\n", irq); return 1; } - return 0; } @@ -180,19 +159,13 @@ static void dcon_wiggle_xo_1_5(void) } udelay(5); - if (TEST_B2 || olpc_board_at_least(olpc_board(BOARD_XO_1_5_B3))) { - // set PMIO_Rx52[6] to enable SCI/SMI on gpio12 - outb(inb(VX855_GPI_SCI_SMI)|BIT_GPIO12, VX855_GPI_SCI_SMI); - } + /* set PMIO_Rx52[6] to enable SCI/SMI on gpio12 */ + outb(inb(VX855_GPI_SCI_SMI)|BIT_GPIO12, VX855_GPI_SCI_SMI); } static void dcon_set_dconload_xo_1_5(int val) { - if (olpc_board_at_least(olpc_board(BOARD_XO_1_5_B1))) { - gpio_set_value(VX855_GPIO(1), val); - } else { - gpio_set_value(VX855_GPO(12), val); - } + gpio_set_value(VX855_GPIO(1), val); } static u8 dcon_read_status_xo_1_5(void) @@ -211,7 +184,7 @@ static u8 dcon_read_status_xo_1_5(void) return status; } -static struct dcon_platform_data dcon_pdata_xo_1_5 = { +struct dcon_platform_data dcon_pdata_xo_1_5 = { .init = dcon_init_xo_1_5, .bus_stabilize_wiggle = dcon_wiggle_xo_1_5, .set_dconload = dcon_set_dconload_xo_1_5, |