aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
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
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')
-rw-r--r--drivers/i2c/busses/Kconfig1
-rw-r--r--drivers/i2c/busses/i2c-parport.c37
-rw-r--r--drivers/i2c/busses/i2c-parport.h4
3 files changed, 39 insertions, 3 deletions
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 7c382f9d81c3..4d65546ede44 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -581,6 +581,7 @@ config I2C_PARPORT
581 tristate "Parallel port adapter" 581 tristate "Parallel port adapter"
582 depends on PARPORT 582 depends on PARPORT
583 select I2C_ALGOBIT 583 select I2C_ALGOBIT
584 select I2C_SMBUS
584 help 585 help
585 This supports parallel port I2C adapters such as the ones made by 586 This supports parallel port I2C adapters such as the ones made by
586 Philips or Velleman, Analog Devices evaluation boards, and more. 587 Philips or Velleman, Analog Devices evaluation boards, and more.
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...) */
diff --git a/drivers/i2c/busses/i2c-parport.h b/drivers/i2c/busses/i2c-parport.h
index ed69d846cb95..a9f66816546c 100644
--- a/drivers/i2c/busses/i2c-parport.h
+++ b/drivers/i2c/busses/i2c-parport.h
@@ -1,7 +1,7 @@
1/* ------------------------------------------------------------------------ * 1/* ------------------------------------------------------------------------ *
2 * i2c-parport.h I2C bus over parallel port * 2 * i2c-parport.h I2C bus over parallel port *
3 * ------------------------------------------------------------------------ * 3 * ------------------------------------------------------------------------ *
4 Copyright (C) 2003-2004 Jean Delvare <khali@linux-fr.org> 4 Copyright (C) 2003-2010 Jean Delvare <khali@linux-fr.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
@@ -38,6 +38,7 @@ struct adapter_parm {
38 struct lineop getsda; 38 struct lineop getsda;
39 struct lineop getscl; 39 struct lineop getscl;
40 struct lineop init; 40 struct lineop init;
41 unsigned int smbus_alert:1;
41}; 42};
42 43
43static struct adapter_parm adapter_parm[] = { 44static struct adapter_parm adapter_parm[] = {
@@ -73,6 +74,7 @@ static struct adapter_parm adapter_parm[] = {
73 .setscl = { 0x01, DATA, 1 }, 74 .setscl = { 0x01, DATA, 1 },
74 .getsda = { 0x10, STAT, 1 }, 75 .getsda = { 0x10, STAT, 1 },
75 .init = { 0xf0, DATA, 0 }, 76 .init = { 0xf0, DATA, 0 },
77 .smbus_alert = 1,
76 }, 78 },
77 /* type 5: ADM1025, ADM1030 and ADM1031 evaluation boards */ 79 /* type 5: ADM1025, ADM1030 and ADM1031 evaluation boards */
78 { 80 {