Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 74834
b: refs/heads/master
c: 58d784a
h: refs/heads/master
v: v3
  • Loading branch information
Martin Habets authored and David S. Miller committed Dec 12, 2007
1 parent c63401d commit eee861b
Show file tree
Hide file tree
Showing 13 changed files with 107 additions and 90 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 02ec96be2b45d9f2712687ad107038ef390b24c2
refs/heads/master: 58d784a5c754cd66ecd4791222162504d3c16c74
45 changes: 41 additions & 4 deletions trunk/Documentation/i2c/summary
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
This is an explanation of what i2c is, and what is supported in this package.

I2C and SMBus
=============

Expand Down Expand Up @@ -31,17 +33,52 @@ When we talk about I2C, we use the following terms:
Client

An Algorithm driver contains general code that can be used for a whole class
of I2C adapters. Each specific adapter driver either depends on one algorithm
driver, or includes its own implementation.
of I2C adapters. Each specific adapter driver depends on one algorithm
driver.

A Driver driver (yes, this sounds ridiculous, sorry) contains the general
code to access some type of device. Each detected device gets its own
data in the Client structure. Usually, Driver and Client are more closely
integrated than Algorithm and Adapter.

For a given configuration, you will need a driver for your I2C bus, and
drivers for your I2C devices (usually one driver for each device).
For a given configuration, you will need a driver for your I2C bus (usually
a separate Adapter and Algorithm driver), and drivers for your I2C devices
(usually one driver for each device). There are no I2C device drivers
in this package. See the lm_sensors project http://www.lm-sensors.nu
for device drivers.

At this time, Linux only operates I2C (or SMBus) in master mode; you can't
use these APIs to make a Linux system behave as a slave/device, either to
speak a custom protocol or to emulate some other device.


Included Bus Drivers
====================
Note that only stable drivers are patched into the kernel by 'mkpatch'.


Base modules
------------

i2c-core: The basic I2C code, including the /proc/bus/i2c* interface
i2c-dev: The /dev/i2c-* interface
i2c-proc: The /proc/sys/dev/sensors interface for device (client) drivers

Algorithm drivers
-----------------

i2c-algo-bit: A bit-banging algorithm
i2c-algo-pcf: A PCF 8584 style algorithm
i2c-algo-ibm_ocp: An algorithm for the I2C device in IBM 4xx processors (NOT BUILT BY DEFAULT)

Adapter drivers
---------------

i2c-elektor: Elektor ISA card (uses i2c-algo-pcf)
i2c-elv: ELV parallel port adapter (uses i2c-algo-bit)
i2c-pcf-epp: PCF8584 on a EPP parallel port (uses i2c-algo-pcf) (NOT mkpatched)
i2c-philips-par: Philips style parallel port adapter (uses i2c-algo-bit)
i2c-adap-ibm_ocp: IBM 4xx processor I2C device (uses i2c-algo-ibm_ocp) (NOT BUILT BY DEFAULT)
i2c-pport: Primitive parallel port adapter (uses i2c-algo-bit)
i2c-velleman: Velleman K8000 parallel port adapter (uses i2c-algo-bit)

4 changes: 2 additions & 2 deletions trunk/drivers/i2c/busses/i2c-davinci.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ static irqreturn_t i2c_davinci_isr(int this_irq, void *dev_id)
DAVINCI_I2C_STR_REG,
w);
} else
dev_err(dev->dev, "RDR IRQ while no "
dev_err(dev->dev, "RDR IRQ while no"
"data requested\n");
break;

Expand All @@ -423,7 +423,7 @@ static irqreturn_t i2c_davinci_isr(int this_irq, void *dev_id)
DAVINCI_I2C_IMR_REG,
w);
} else
dev_err(dev->dev, "TDR IRQ while no data to "
dev_err(dev->dev, "TDR IRQ while no data to"
"send\n");
break;

Expand Down
1 change: 0 additions & 1 deletion trunk/drivers/i2c/busses/i2c-gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ static int __init i2c_gpio_probe(struct platform_device *pdev)
adap->owner = THIS_MODULE;
snprintf(adap->name, sizeof(adap->name), "i2c-gpio%d", pdev->id);
adap->algo_data = bit_data;
adap->class = I2C_CLASS_HWMON;
adap->dev.parent = &pdev->dev;

/*
Expand Down
6 changes: 3 additions & 3 deletions trunk/drivers/i2c/busses/i2c-omap.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
while (!(omap_i2c_read_reg(dev, OMAP_I2C_SYSS_REG) &
OMAP_I2C_SYSS_RDONE)) {
if (time_after(jiffies, timeout)) {
dev_warn(dev->dev, "timeout waiting "
dev_warn(dev->dev, "timeout waiting"
"for controller reset\n");
return -ETIMEDOUT;
}
Expand Down Expand Up @@ -483,7 +483,7 @@ omap_i2c_isr(int this_irq, void *dev_id)
dev->buf_len--;
}
} else
dev_err(dev->dev, "RRDY IRQ while no data "
dev_err(dev->dev, "RRDY IRQ while no data"
"requested\n");
omap_i2c_ack_stat(dev, OMAP_I2C_STAT_RRDY);
continue;
Expand All @@ -498,7 +498,7 @@ omap_i2c_isr(int this_irq, void *dev_id)
dev->buf_len--;
}
} else
dev_err(dev->dev, "XRDY IRQ while no "
dev_err(dev->dev, "XRDY IRQ while no"
"data to send\n");
omap_i2c_write_reg(dev, OMAP_I2C_DATA_REG, w);
omap_i2c_ack_stat(dev, OMAP_I2C_STAT_XRDY);
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/i2c/chips/isp1301_omap.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <linux/interrupt.h>
#include <linux/platform_device.h>
#include <linux/usb/ch9.h>
#include <linux/usb/gadget.h>
#include <linux/usb_gadget.h>
#include <linux/usb.h>
#include <linux/usb/otg.h>
#include <linux/i2c.h>
Expand Down
14 changes: 1 addition & 13 deletions trunk/drivers/media/video/videobuf-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
}

/* Locking: Caller holds q->lock */
int __videobuf_read_start(struct videobuf_queue *q)
int videobuf_read_start(struct videobuf_queue *q)
{
enum v4l2_field field;
unsigned long flags=0;
Expand Down Expand Up @@ -862,17 +862,6 @@ static void __videobuf_read_stop(struct videobuf_queue *q)

}

int videobuf_read_start(struct videobuf_queue *q)
{
int rc;

mutex_lock(&q->lock);
rc = __videobuf_read_start(q);
mutex_unlock(&q->lock);

return rc;
}

void videobuf_read_stop(struct videobuf_queue *q)
{
mutex_lock(&q->lock);
Expand Down Expand Up @@ -1069,7 +1058,6 @@ EXPORT_SYMBOL_GPL(videobuf_dqbuf);
EXPORT_SYMBOL_GPL(videobuf_streamon);
EXPORT_SYMBOL_GPL(videobuf_streamoff);

EXPORT_SYMBOL_GPL(videobuf_read_start);
EXPORT_SYMBOL_GPL(videobuf_read_stop);
EXPORT_SYMBOL_GPL(videobuf_stop);
EXPORT_SYMBOL_GPL(videobuf_read_stream);
Expand Down
33 changes: 28 additions & 5 deletions trunk/drivers/serial/suncore.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,36 @@

#include "suncore.h"

int sunserial_current_minor = 64;
static int sunserial_current_minor = 64;

EXPORT_SYMBOL(sunserial_current_minor);
int sunserial_register_minors(struct uart_driver *drv, int count)
{
int err = 0;

drv->minor = sunserial_current_minor;
drv->nr += count;
/* Register the driver on the first call */
if (drv->nr == count)
err = uart_register_driver(drv);
if (err == 0) {
sunserial_current_minor += count;
drv->tty_driver->name_base = drv->minor - 64;
}
return err;
}
EXPORT_SYMBOL(sunserial_register_minors);

void sunserial_unregister_minors(struct uart_driver *drv, int count)
{
drv->nr -= count;
sunserial_current_minor -= count;

if (drv->nr == 0)
uart_unregister_driver(drv);
}
EXPORT_SYMBOL(sunserial_unregister_minors);

int sunserial_console_match(struct console *con, struct device_node *dp,
int __init sunserial_console_match(struct console *con, struct device_node *dp,
struct uart_driver *drv, int line)
{
int off;
Expand Down Expand Up @@ -133,8 +158,6 @@ sunserial_console_termios(struct console *con)
con->cflag = cflag;
}

EXPORT_SYMBOL(sunserial_console_termios);

/* Sun serial MOUSE auto baud rate detection. */
static struct mouse_baud_cflag {
int baud;
Expand Down
3 changes: 2 additions & 1 deletion trunk/drivers/serial/suncore.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
extern unsigned int suncore_mouse_baud_cflag_next(unsigned int, int *);
extern int suncore_mouse_baud_detection(unsigned char, int);

extern int sunserial_current_minor;
extern int sunserial_register_minors(struct uart_driver *, int);
extern void sunserial_unregister_minors(struct uart_driver *, int);

extern int sunserial_console_match(struct console *, struct device_node *,
struct uart_driver *, int);
Expand Down
14 changes: 3 additions & 11 deletions trunk/drivers/serial/sunhv.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,16 +562,10 @@ static int __devinit hv_probe(struct of_device *op, const struct of_device_id *m

port->dev = &op->dev;

sunhv_reg.minor = sunserial_current_minor;
sunhv_reg.nr = 1;

err = uart_register_driver(&sunhv_reg);
err = sunserial_register_minors(&sunhv_reg, 1);
if (err)
goto out_free_con_read_page;

sunhv_reg.tty_driver->name_base = sunhv_reg.minor - 64;
sunserial_current_minor += 1;

sunserial_console_match(&sunhv_console, op->node,
&sunhv_reg, port->line);

Expand All @@ -591,8 +585,7 @@ static int __devinit hv_probe(struct of_device *op, const struct of_device_id *m
uart_remove_one_port(&sunhv_reg, port);

out_unregister_driver:
sunserial_current_minor -= 1;
uart_unregister_driver(&sunhv_reg);
sunserial_unregister_minors(&sunhv_reg, 1);

out_free_con_read_page:
kfree(con_read_page);
Expand All @@ -614,8 +607,7 @@ static int __devexit hv_remove(struct of_device *dev)

uart_remove_one_port(&sunhv_reg, port);

sunserial_current_minor -= 1;
uart_unregister_driver(&sunhv_reg);
sunserial_unregister_minors(&sunhv_reg, 1);

kfree(port);
sunhv_port = NULL;
Expand Down
16 changes: 4 additions & 12 deletions trunk/drivers/serial/sunsab.c
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,6 @@ static struct uart_driver sunsab_reg = {
};

static struct uart_sunsab_port *sunsab_ports;
static int num_channels;

#ifdef CONFIG_SERIAL_SUNSAB_CONSOLE

Expand Down Expand Up @@ -1102,8 +1101,8 @@ static int __init sunsab_init(void)
{
struct device_node *dp;
int err;
int num_channels = 0;

num_channels = 0;
for_each_node_by_name(dp, "se")
num_channels += 2;
for_each_node_by_name(dp, "serial") {
Expand All @@ -1117,20 +1116,14 @@ static int __init sunsab_init(void)
if (!sunsab_ports)
return -ENOMEM;

sunsab_reg.minor = sunserial_current_minor;
sunsab_reg.nr = num_channels;
sunsab_reg.cons = SUNSAB_CONSOLE();

err = uart_register_driver(&sunsab_reg);
err = sunserial_register_minors(&sunsab_reg, num_channels);
if (err) {
kfree(sunsab_ports);
sunsab_ports = NULL;

return err;
}

sunsab_reg.tty_driver->name_base = sunsab_reg.minor - 64;
sunserial_current_minor += num_channels;
}

return of_register_driver(&sab_driver, &of_bus_type);
Expand All @@ -1139,9 +1132,8 @@ static int __init sunsab_init(void)
static void __exit sunsab_exit(void)
{
of_unregister_driver(&sab_driver);
if (num_channels) {
sunserial_current_minor -= num_channels;
uart_unregister_driver(&sunsab_reg);
if (sunsab_reg.nr) {
sunserial_unregister_minors(&sunsab_reg, sunsab_reg.nr);
}

kfree(sunsab_ports);
Expand Down
16 changes: 5 additions & 11 deletions trunk/drivers/serial/sunsu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1528,14 +1528,12 @@ static struct of_platform_driver su_driver = {
.remove = __devexit_p(su_remove),
};

static int num_uart;

static int __init sunsu_init(void)
{
struct device_node *dp;
int err;
int num_uart = 0;

num_uart = 0;
for_each_node_by_name(dp, "su") {
if (su_get_type(dp) == SU_PORT_PORT)
num_uart++;
Expand All @@ -1552,26 +1550,22 @@ static int __init sunsu_init(void)
}

if (num_uart) {
sunsu_reg.minor = sunserial_current_minor;
sunsu_reg.nr = num_uart;
err = uart_register_driver(&sunsu_reg);
err = sunserial_register_minors(&sunsu_reg, num_uart);
if (err)
return err;
sunsu_reg.tty_driver->name_base = sunsu_reg.minor - 64;
sunserial_current_minor += num_uart;
}

err = of_register_driver(&su_driver, &of_bus_type);
if (err && num_uart)
uart_unregister_driver(&sunsu_reg);
sunserial_unregister_minors(&sunsu_reg, num_uart);

return err;
}

static void __exit sunsu_exit(void)
{
if (num_uart)
uart_unregister_driver(&sunsu_reg);
if (sunsu_reg.nr)
sunserial_unregister_minors(&sunsu_reg, sunsu_reg.nr);
}

module_init(sunsu_init);
Expand Down
Loading

0 comments on commit eee861b

Please sign in to comment.