aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses/i2c-parport.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2010-03-02 06:23:44 -0500
committerJean Delvare <khali@linux-fr.org>2010-03-02 06:23:44 -0500
commit35859254483bce479024781885bc02d860552995 (patch)
tree85ab025d778694c8784b2c43584406523c572fe7 /drivers/i2c/busses/i2c-parport.c
parente2ca307439fb9df922c3e8891289a2ac05812fb7 (diff)
i2c-parport: Add SMBus alert support
Add support for the SMBus alert mechanism to the i2c-parport driver. The ADM1032 evaluation board at least is properly wired for this. Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: David Brownell <dbrownell@users.sourceforge.net> Cc: Trent Piepho <tpiepho@freescale.com>
Diffstat (limited to 'drivers/i2c/busses/i2c-parport.c')
-rw-r--r--drivers/i2c/busses/i2c-parport.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/drivers/i2c/busses/i2c-parport.c b/drivers/i2c/busses/i2c-parport.c
index 056af1820993..220fca7f23a6 100644
--- a/drivers/i2c/busses/i2c-parport.c
+++ b/drivers/i2c/busses/i2c-parport.c
@@ -1,7 +1,7 @@
1/* ------------------------------------------------------------------------ * 1/* ------------------------------------------------------------------------ *
2 * i2c-parport.c I2C bus over parallel port * 2 * i2c-parport.c I2C bus over parallel port *
3 * ------------------------------------------------------------------------ * 3 * ------------------------------------------------------------------------ *
4 Copyright (C) 2003-2007 Jean Delvare <khali@linux-fr.org> 4 Copyright (C) 2003-2010 Jean Delvare <khali@linux-fr.org>
5 5
6 Based on older i2c-philips-par.c driver 6 Based on older i2c-philips-par.c driver
7 Copyright (C) 1995-2000 Simon G. Vogl 7 Copyright (C) 1995-2000 Simon G. Vogl
@@ -31,6 +31,7 @@
31#include <linux/parport.h> 31#include <linux/parport.h>
32#include <linux/i2c.h> 32#include <linux/i2c.h>
33#include <linux/i2c-algo-bit.h> 33#include <linux/i2c-algo-bit.h>
34#include <linux/i2c-smbus.h>
34#include "i2c-parport.h" 35#include "i2c-parport.h"
35 36
36/* ----- Device list ------------------------------------------------------ */ 37/* ----- Device list ------------------------------------------------------ */
@@ -39,6 +40,8 @@ struct i2c_par {
39 struct pardevice *pdev; 40 struct pardevice *pdev;
40 struct i2c_adapter adapter; 41 struct i2c_adapter adapter;
41 struct i2c_algo_bit_data algo_data; 42 struct i2c_algo_bit_data algo_data;
43 struct i2c_smbus_alert_setup alert_data;
44 struct i2c_client *ara;
42 struct i2c_par *next; 45 struct i2c_par *next;
43}; 46};
44 47
@@ -144,6 +147,19 @@ static struct i2c_algo_bit_data parport_algo_data = {
144 147
145/* ----- I2c and parallel port call-back functions and structures --------- */ 148/* ----- I2c and parallel port call-back functions and structures --------- */
146 149
150void i2c_parport_irq(void *data)
151{
152 struct i2c_par *adapter = data;
153 struct i2c_client *ara = adapter->ara;
154
155 if (ara) {
156 dev_dbg(&ara->dev, "SMBus alert received\n");
157 i2c_handle_smbus_alert(ara);
158 } else
159 dev_dbg(&adapter->adapter.dev,
160 "SMBus alert received but no ARA client!\n");
161}
162
147static void i2c_parport_attach (struct parport *port) 163static void i2c_parport_attach (struct parport *port)
148{ 164{
149 struct i2c_par *adapter; 165 struct i2c_par *adapter;
@@ -155,8 +171,9 @@ static void i2c_parport_attach (struct parport *port)
155 } 171 }
156 172
157 pr_debug("i2c-parport: attaching to %s\n", port->name); 173 pr_debug("i2c-parport: attaching to %s\n", port->name);
174 parport_disable_irq(port);
158 adapter->pdev = parport_register_device(port, "i2c-parport", 175 adapter->pdev = parport_register_device(port, "i2c-parport",
159 NULL, NULL, NULL, PARPORT_FLAG_EXCL, NULL); 176 NULL, NULL, i2c_parport_irq, PARPORT_FLAG_EXCL, adapter);
160 if (!adapter->pdev) { 177 if (!adapter->pdev) {
161 printk(KERN_ERR "i2c-parport: Unable to register with parport\n"); 178 printk(KERN_ERR "i2c-parport: Unable to register with parport\n");
162 goto ERROR0; 179 goto ERROR0;
@@ -197,6 +214,18 @@ static void i2c_parport_attach (struct parport *port)
197 goto ERROR1; 214 goto ERROR1;
198 } 215 }
199 216
217 /* Setup SMBus alert if supported */
218 if (adapter_parm[type].smbus_alert) {
219 adapter->alert_data.alert_edge_triggered = 1;
220 adapter->ara = i2c_setup_smbus_alert(&adapter->adapter,
221 &adapter->alert_data);
222 if (adapter->ara)
223 parport_enable_irq(port);
224 else
225 printk(KERN_WARNING "i2c-parport: Failed to register "
226 "ARA client\n");
227 }
228
200 /* Add the new adapter to the list */ 229 /* Add the new adapter to the list */
201 adapter->next = adapter_list; 230 adapter->next = adapter_list;
202 adapter_list = adapter; 231 adapter_list = adapter;
@@ -217,6 +246,10 @@ static void i2c_parport_detach (struct parport *port)
217 for (prev = NULL, adapter = adapter_list; adapter; 246 for (prev = NULL, adapter = adapter_list; adapter;
218 prev = adapter, adapter = adapter->next) { 247 prev = adapter, adapter = adapter->next) {
219 if (adapter->pdev->port == port) { 248 if (adapter->pdev->port == port) {
249 if (adapter->ara) {
250 parport_disable_irq(port);
251 i2c_unregister_device(adapter->ara);
252 }
220 i2c_del_adapter(&adapter->adapter); 253 i2c_del_adapter(&adapter->adapter);
221 254
222 /* Un-init if needed (power off...) */ 255 /* Un-init if needed (power off...) */