#include <linux/delay.h>
#include <linux/backlight.h>
#include <linux/device.h>
-#include <linux/notifier.h>
#include <linux/uaccess.h>
#include <linux/ctype.h>
#include <linux/reboot.h>
static struct dcon_platform_data *pdata;
-struct dcon_priv {
- struct i2c_client *client;
- struct fb_info *fbinfo;
-
- 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;
-
- /* 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;
-};
-
/* I2C structures */
/* Platform devices */
/* Backlight device */
static struct backlight_device *dcon_bl_dev;
-/* Current source, initialized at probe time */
-int dcon_source;
-
-/* Desired source */
-int dcon_pending;
-
/* Variables used during switches */
static int dcon_switched;
static struct timespec dcon_irq_time;
if (is_init) {
printk(KERN_INFO "olpc-dcon: Discovered DCON version %x\n",
ver & 0xFF);
- rc = pdata->init();
+ rc = pdata->init(dcon);
if (rc != 0) {
printk(KERN_ERR "olpc-dcon: Unable to init.\n");
goto err;
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();
*/
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;
}
BUG();
}
- dcon_source = source;
+ dcon->curr_src = source;
}
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->switch_source))
+ if ((dcon->curr_src != arg) && !work_pending(&dcon->switch_source))
schedule_work(&dcon->switch_source);
}
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_mono_show(struct device *dev,
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);
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);
irqreturn_t dcon_interrupt(int irq, void *id)
{
+ struct dcon_priv *dcon = id;
int status = pdata->read_status();
if (status == -1)
* of the DCON happened long before this point.
* see http://dev.laptop.org/ticket/9869
*/
- if (dcon_source != dcon_pending && !dcon_switched) {
+ if (dcon->curr_src != dcon->pending_src && !dcon_switched) {
dcon_switched = 1;
getnstimeofday(&dcon_irq_time);
wake_up(&dcon_wait_queue);
#ifndef OLPC_DCON_H_
#define OLPC_DCON_H_
+#include <linux/notifier.h>
+#include <linux/workqueue.h>
+
/* DCON registers */
#define DCON_REG_ID 0
/* Interrupt */
#define DCON_IRQ 6
+struct dcon_priv {
+ struct i2c_client *client;
+ struct fb_info *fbinfo;
+
+ 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;
+
+ /* Current source, initialized at probe time */
+ int curr_src;
+
+ /* Desired source */
+ int pending_src;
+
+ /* 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)(void);
+ int (*init)(struct dcon_priv *);
void (*bus_stabilize_wiggle)(void);
void (*set_dconload)(int);
u8 (*read_status)(void);
#include <linux/interrupt.h>
-extern int dcon_source;
-extern int dcon_pending;
extern irqreturn_t dcon_interrupt(int irq, void *id);
-extern struct i2c_driver dcon_driver;
#ifdef CONFIG_FB_OLPC_DCON_1
extern struct dcon_platform_data dcon_pdata_xo_1;
#include "olpc_dcon.h"
-static int dcon_init_xo_1(void)
+static int dcon_init_xo_1(struct dcon_priv *dcon)
{
unsigned char lob;
* 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);
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 */
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;
}
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;
/* Determine the current state of DCONLOAD, likely set by firmware */
/* GPIO1 */
- dcon_source = (inl(VX855_GENL_PURPOSE_OUTPUT) & 0x1000) ?
+ 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;
}