PRCM: OMAP3: Fix to wrongly modified omap2_clk_wait_ready
[linux-ginger.git] / drivers / i2c / chips / gpio_expander_omap.c
blobdfe7f040fac261cf5983015a613541273b62f3a4
1 /*
2 * drivers/i2c/chips/gpio_expander_omap.c
4 * Copyright (C) 2004 Texas Instruments Inc
5 * Author:
7 * gpio expander is used to configure IrDA, camera and audio devices on omap 1710 processor.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
15 #include <linux/types.h>
16 #include <linux/i2c.h>
17 #include <linux/errno.h>
19 int read_gpio_expa(u8 * val, int addr);
20 int write_gpio_expa(u8 val, int addr);
22 int write_gpio_expa(u8 val, int addr)
24 struct i2c_adapter *adap;
25 int err;
26 struct i2c_msg msg[1];
27 unsigned char data[1];
29 adap = i2c_get_adapter(1);
30 if (!adap)
31 return -ENODEV;
32 msg->addr = addr; /* I2C address of GPIO EXPA */
33 msg->flags = 0;
34 msg->len = 1;
35 msg->buf = data;
36 data[0] = val;
37 err = i2c_transfer(adap, msg, 1);
38 if (err >= 0)
39 return 0;
40 return err;
43 /* Read from I/O EXPANDER on the H3 board.
44 * The IO expanders need an independent I2C client driver.
47 int read_gpio_expa(u8 * val, int addr)
49 struct i2c_adapter *adap;
50 int err;
51 struct i2c_msg msg[1];
52 unsigned char data[1];
54 adap = i2c_get_adapter(1);
55 if (!adap)
56 return -ENODEV;
57 msg->addr = addr; /* I2C address of GPIO EXPA */
58 msg->flags = I2C_M_RD;
59 msg->len = 2;
60 msg->buf = data;
61 err = i2c_transfer(adap, msg, 1);
62 *val = data[0];
64 if (err >= 0)
65 return 0;
66 return err;
69 EXPORT_SYMBOL(read_gpio_expa);
70 EXPORT_SYMBOL(write_gpio_expa);