Lines Matching +full:on +full:- +full:the +full:- +full:go
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2005-2006 Micronas USA Inc.
17 #include "go7007-priv.h"
19 /********************* Driver for on-board I2C adapter *********************/
34 /* There is only one I2C port on the TW2804 that feeds all four GO7007 VIPs
35 * on the Adlink PCI-MPG24, so access is shared between all of them. */
38 static inline void adlink_mpg24_i2c_lock(struct go7007 *go) in adlink_mpg24_i2c_lock() argument
40 /* Bridge the I2C port on this GO7007 to the shared bus */ in adlink_mpg24_i2c_lock()
42 go7007_write_addr(go, 0x3c82, 0x0020); in adlink_mpg24_i2c_lock()
45 static inline void adlink_mpg24_i2c_unlock(struct go7007 *go) in adlink_mpg24_i2c_unlock() argument
47 /* Isolate the I2C port on this GO7007 from the shared bus */ in adlink_mpg24_i2c_unlock()
48 go7007_write_addr(go, 0x3c82, 0x0000); in adlink_mpg24_i2c_unlock()
52 static int go7007_i2c_xfer(struct go7007 *go, u16 addr, int read, in go7007_i2c_xfer() argument
55 int i, ret = -EIO; in go7007_i2c_xfer()
58 if (go->status == STATUS_SHUTDOWN) in go7007_i2c_xfer()
59 return -ENODEV; in go7007_i2c_xfer()
63 dev_dbg(go->dev, "go7007-i2c: reading 0x%02x on 0x%02x\n", in go7007_i2c_xfer()
66 dev_dbg(go->dev, in go7007_i2c_xfer()
67 "go7007-i2c: writing 0x%02x to 0x%02x on 0x%02x\n", in go7007_i2c_xfer()
71 mutex_lock(&go->hw_lock); in go7007_i2c_xfer()
73 if (go->board_id == GO7007_BOARDID_ADLINK_MPG24) in go7007_i2c_xfer()
74 adlink_mpg24_i2c_lock(go); in go7007_i2c_xfer()
78 if (go7007_read_addr(go, STATUS_REG_ADDR, &val) < 0) in go7007_i2c_xfer()
85 dev_err(go->dev, "go7007-i2c: I2C adapter is hung\n"); in go7007_i2c_xfer()
90 go7007_write_addr(go, I2C_CTRL_REG_ADDR, flags); in go7007_i2c_xfer()
91 go7007_write_addr(go, I2C_LO_ADDR_REG_ADDR, command); in go7007_i2c_xfer()
93 /* If we're writing, send the data and target address and we're done */ in go7007_i2c_xfer()
95 go7007_write_addr(go, I2C_DATA_REG_ADDR, *data); in go7007_i2c_xfer()
96 go7007_write_addr(go, I2C_DEV_UP_ADDR_REG_ADDR, in go7007_i2c_xfer()
103 if (go7007_read_addr(go, I2C_DATA_REG_ADDR, &val) < 0) in go7007_i2c_xfer()
106 /* Send the target address plus read flag */ in go7007_i2c_xfer()
107 go7007_write_addr(go, I2C_DEV_UP_ADDR_REG_ADDR, in go7007_i2c_xfer()
112 if (go7007_read_addr(go, STATUS_REG_ADDR, &val) < 0) in go7007_i2c_xfer()
119 dev_err(go->dev, "go7007-i2c: I2C adapter is hung\n"); in go7007_i2c_xfer()
123 /* Retrieve the read byte */ in go7007_i2c_xfer()
124 if (go7007_read_addr(go, I2C_DATA_REG_ADDR, &val) < 0) in go7007_i2c_xfer()
130 if (go->board_id == GO7007_BOARDID_ADLINK_MPG24) in go7007_i2c_xfer()
131 adlink_mpg24_i2c_unlock(go); in go7007_i2c_xfer()
132 mutex_unlock(&go->hw_lock); in go7007_i2c_xfer()
140 struct go7007 *go = i2c_get_adapdata(adapter); in go7007_smbus_xfer() local
143 return -EIO; in go7007_smbus_xfer()
144 return go7007_i2c_xfer(go, addr, read_write == I2C_SMBUS_READ, command, in go7007_smbus_xfer()
145 flags & I2C_CLIENT_SCCB ? 0x10 : 0x00, &data->byte); in go7007_smbus_xfer()
148 /* VERY LIMITED I2C master xfer function -- only needed because the
149 * SMBus functions only support 8-bit commands and the SAA7135 uses
150 * 16-bit commands. The I2C interface on the GO7007, as limited as
156 struct go7007 *go = i2c_get_adapdata(adapter); in go7007_i2c_master_xfer() local
160 /* We can only do two things here -- write three bytes, or in go7007_i2c_master_xfer()
167 return -EIO; in go7007_i2c_master_xfer()
168 if (go7007_i2c_xfer(go, msgs[i].addr, 1, in go7007_i2c_master_xfer()
171 return -EIO; in go7007_i2c_master_xfer()
175 return -EIO; in go7007_i2c_master_xfer()
176 if (go7007_i2c_xfer(go, msgs[i].addr, 0, in go7007_i2c_master_xfer()
179 return -EIO; in go7007_i2c_master_xfer()
181 return -EIO; in go7007_i2c_master_xfer()
204 int go7007_i2c_init(struct go7007 *go) in go7007_i2c_init() argument
206 memcpy(&go->i2c_adapter, &go7007_adap_templ, in go7007_i2c_init()
208 go->i2c_adapter.dev.parent = go->dev; in go7007_i2c_init()
209 i2c_set_adapdata(&go->i2c_adapter, go); in go7007_i2c_init()
210 if (i2c_add_adapter(&go->i2c_adapter) < 0) { in go7007_i2c_init()
211 dev_err(go->dev, in go7007_i2c_init()
212 "go7007-i2c: error: i2c_add_adapter failed\n"); in go7007_i2c_init()
213 return -1; in go7007_i2c_init()