aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses/i2c-frodo.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c/busses/i2c-frodo.c')
-rw-r--r--drivers/i2c/busses/i2c-frodo.c86
1 files changed, 86 insertions, 0 deletions
diff --git a/drivers/i2c/busses/i2c-frodo.c b/drivers/i2c/busses/i2c-frodo.c
new file mode 100644
index 000000000000..e093829a0bf7
--- /dev/null
+++ b/drivers/i2c/busses/i2c-frodo.c
@@ -0,0 +1,86 @@
1
2/*
3 * linux/drivers/i2c/i2c-frodo.c
4 *
5 * Author: Abraham van der Merwe <abraham@2d3d.co.za>
6 *
7 * An I2C adapter driver for the 2d3D, Inc. StrongARM SA-1110
8 * Development board (Frodo).
9 *
10 * This source code is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * version 2 as published by the Free Software Foundation.
13 */
14
15#include <linux/config.h>
16#include <linux/module.h>
17#include <linux/kernel.h>
18#include <linux/init.h>
19#include <linux/delay.h>
20#include <linux/i2c.h>
21#include <linux/i2c-algo-bit.h>
22#include <asm/hardware.h>
23
24
25static void frodo_setsda (void *data,int state)
26{
27 if (state)
28 FRODO_CPLD_I2C |= FRODO_I2C_SDA_OUT;
29 else
30 FRODO_CPLD_I2C &= ~FRODO_I2C_SDA_OUT;
31}
32
33static void frodo_setscl (void *data,int state)
34{
35 if (state)
36 FRODO_CPLD_I2C |= FRODO_I2C_SCL_OUT;
37 else
38 FRODO_CPLD_I2C &= ~FRODO_I2C_SCL_OUT;
39}
40
41static int frodo_getsda (void *data)
42{
43 return ((FRODO_CPLD_I2C & FRODO_I2C_SDA_IN) != 0);
44}
45
46static int frodo_getscl (void *data)
47{
48 return ((FRODO_CPLD_I2C & FRODO_I2C_SCL_IN) != 0);
49}
50
51static struct i2c_algo_bit_data bit_frodo_data = {
52 .setsda = frodo_setsda,
53 .setscl = frodo_setscl,
54 .getsda = frodo_getsda,
55 .getscl = frodo_getscl,
56 .udelay = 80,
57 .mdelay = 80,
58 .timeout = HZ
59};
60
61static struct i2c_adapter frodo_ops = {
62 .owner = THIS_MODULE,
63 .id = I2C_HW_B_FRODO,
64 .algo_data = &bit_frodo_data,
65 .dev = {
66 .name = "Frodo adapter driver",
67 },
68};
69
70static int __init i2c_frodo_init (void)
71{
72 return i2c_bit_add_bus(&frodo_ops);
73}
74
75static void __exit i2c_frodo_exit (void)
76{
77 i2c_bit_del_bus(&frodo_ops);
78}
79
80MODULE_AUTHOR ("Abraham van der Merwe <abraham@2d3d.co.za>");
81MODULE_DESCRIPTION ("I2C-Bus adapter routines for Frodo");
82MODULE_LICENSE ("GPL");
83
84module_init (i2c_frodo_init);
85module_exit (i2c_frodo_exit);
86