aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/Kconfig1
-rw-r--r--drivers/i2c/busses/i2c-parport-light.c42
2 files changed, 40 insertions, 3 deletions
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 4d65546ede44..4cc3807bd31c 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -605,6 +605,7 @@ config I2C_PARPORT
605config I2C_PARPORT_LIGHT 605config I2C_PARPORT_LIGHT
606 tristate "Parallel port adapter (light)" 606 tristate "Parallel port adapter (light)"
607 select I2C_ALGOBIT 607 select I2C_ALGOBIT
608 select I2C_SMBUS
608 help 609 help
609 This supports parallel port I2C adapters such as the ones made by 610 This supports parallel port I2C adapters such as the ones made by
610 Philips or Velleman, Analog Devices evaluation boards, and more. 611 Philips or Velleman, Analog Devices evaluation boards, and more.
diff --git a/drivers/i2c/busses/i2c-parport-light.c b/drivers/i2c/busses/i2c-parport-light.c
index 5383f64c5372..5f41ec0f72d2 100644
--- a/drivers/i2c/busses/i2c-parport-light.c
+++ b/drivers/i2c/busses/i2c-parport-light.c
@@ -1,7 +1,7 @@
1/* ------------------------------------------------------------------------ * 1/* ------------------------------------------------------------------------ *
2 * i2c-parport-light.c I2C bus over parallel port * 2 * i2c-parport-light.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-velleman.c driver 6 Based on older i2c-velleman.c driver
7 Copyright (C) 1995-2000 Simon G. Vogl 7 Copyright (C) 1995-2000 Simon G. Vogl
@@ -32,6 +32,7 @@
32#include <linux/ioport.h> 32#include <linux/ioport.h>
33#include <linux/i2c.h> 33#include <linux/i2c.h>
34#include <linux/i2c-algo-bit.h> 34#include <linux/i2c-algo-bit.h>
35#include <linux/i2c-smbus.h>
35#include <asm/io.h> 36#include <asm/io.h>
36#include "i2c-parport.h" 37#include "i2c-parport.h"
37 38
@@ -44,6 +45,10 @@ static u16 base;
44module_param(base, ushort, 0); 45module_param(base, ushort, 0);
45MODULE_PARM_DESC(base, "Base I/O address"); 46MODULE_PARM_DESC(base, "Base I/O address");
46 47
48static int irq;
49module_param(irq, int, 0);
50MODULE_PARM_DESC(irq, "IRQ (optional)");
51
47/* ----- Low-level parallel port access ----------------------------------- */ 52/* ----- Low-level parallel port access ----------------------------------- */
48 53
49static inline void port_write(unsigned char p, unsigned char d) 54static inline void port_write(unsigned char p, unsigned char d)
@@ -120,6 +125,16 @@ static struct i2c_adapter parport_adapter = {
120 .name = "Parallel port adapter (light)", 125 .name = "Parallel port adapter (light)",
121}; 126};
122 127
128/* SMBus alert support */
129static struct i2c_smbus_alert_setup alert_data = {
130 .alert_edge_triggered = 1,
131};
132static struct i2c_client *ara;
133static struct lineop parport_ctrl_irq = {
134 .val = (1 << 4),
135 .port = CTRL,
136};
137
123static int __devinit i2c_parport_probe(struct platform_device *pdev) 138static int __devinit i2c_parport_probe(struct platform_device *pdev)
124{ 139{
125 int err; 140 int err;
@@ -136,13 +151,31 @@ static int __devinit i2c_parport_probe(struct platform_device *pdev)
136 151
137 parport_adapter.dev.parent = &pdev->dev; 152 parport_adapter.dev.parent = &pdev->dev;
138 err = i2c_bit_add_bus(&parport_adapter); 153 err = i2c_bit_add_bus(&parport_adapter);
139 if (err) 154 if (err) {
140 dev_err(&pdev->dev, "Unable to register with I2C\n"); 155 dev_err(&pdev->dev, "Unable to register with I2C\n");
141 return err; 156 return err;
157 }
158
159 /* Setup SMBus alert if supported */
160 if (adapter_parm[type].smbus_alert && irq) {
161 alert_data.irq = irq;
162 ara = i2c_setup_smbus_alert(&parport_adapter, &alert_data);
163 if (ara)
164 line_set(1, &parport_ctrl_irq);
165 else
166 dev_warn(&pdev->dev, "Failed to register ARA client\n");
167 }
168
169 return 0;
142} 170}
143 171
144static int __devexit i2c_parport_remove(struct platform_device *pdev) 172static int __devexit i2c_parport_remove(struct platform_device *pdev)
145{ 173{
174 if (ara) {
175 line_set(0, &parport_ctrl_irq);
176 i2c_unregister_device(ara);
177 ara = NULL;
178 }
146 i2c_del_adapter(&parport_adapter); 179 i2c_del_adapter(&parport_adapter);
147 180
148 /* Un-init if needed (power off...) */ 181 /* Un-init if needed (power off...) */
@@ -209,6 +242,9 @@ static int __init i2c_parport_init(void)
209 if (!request_region(base, 3, DRVNAME)) 242 if (!request_region(base, 3, DRVNAME))
210 return -EBUSY; 243 return -EBUSY;
211 244
245 if (irq != 0)
246 pr_info(DRVNAME ": using irq %d\n", irq);
247
212 if (!adapter_parm[type].getscl.val) 248 if (!adapter_parm[type].getscl.val)
213 parport_algo_data.getscl = NULL; 249 parport_algo_data.getscl = NULL;
214 250