Lines Matching +full:state +full:- +full:of +full:- +full:charge
6 * This file is available to you under your choice of the following two
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 2 of the License, or (at
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
21 * You should have received a copy of the GNU General Public License
27 * (hereinafter "Software") is an unsupported proprietary work of Synopsys,
31 * The Software IS NOT an item of Licensed Software or Licensed Product
34 * granted, free of charge, to any person obtaining a copy of this software
38 * of the Software, and to permit persons to whom the Software is furnished
42 * in all copies or substantial portions of the Software.
46 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
49 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
50 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
51 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
53 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
54 * THE POSSIBILITY OF SUCH DAMAGE.
61 * * Redistributions of source code must retain the above copyright
62 * notice, this list of conditions and the following disclaimer.
64 * notice, this list of conditions and the following disclaimer in the
66 * * Neither the name of Advanced Micro Devices, Inc. nor the
67 * names of its contributors may be used to endorse or promote products
72 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
75 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
76 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
77 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
78 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
79 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
84 * (hereinafter "Software") is an unsupported proprietary work of Synopsys,
88 * The Software IS NOT an item of Licensed Software or Licensed Product
91 * granted, free of charge, to any person obtaining a copy of this software
95 * of the Software, and to permit persons to whom the Software is furnished
99 * in all copies or substantial portions of the Software.
103 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
106 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
107 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
108 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
110 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
111 * THE POSSIBILITY OF SUCH DAMAGE.
116 #include "xgbe-common.h"
146 while (wait--) {
153 return (-EBUSY);
162 while (wait--) {
170 return (-EBUSY);
222 struct xgbe_i2c_op_state *state = &pdata->i2c.op_state;
226 tx_slots = pdata->i2c.tx_fifo_size - XI2C_IOREAD(pdata, IC_TXFLR);
228 state->tx_len);
230 while (tx_slots && state->tx_len) {
231 if (state->op->cmd == XGBE_I2C_CMD_READ)
234 cmd = *state->tx_buf++;
237 state->tx_len);
239 if (state->tx_len == 1)
244 tx_slots--;
245 state->tx_len--;
249 if (!state->tx_len)
256 struct xgbe_i2c_op_state *state = &pdata->i2c.op_state;
260 axgbe_printf(3, "%s: op cmd %d\n", __func__, state->op->cmd);
261 if (state->op->cmd != XGBE_I2C_CMD_READ)
266 state->rx_len);
268 while (rx_slots && state->rx_len) {
269 *state->rx_buf++ = XI2C_IOREAD(pdata, IC_DATA_CMD);
270 state->rx_len--;
271 rx_slots--;
278 struct xgbe_i2c_op_state *state = &pdata->i2c.op_state;
281 state->tx_abort_source = XI2C_IOREAD(pdata, IC_TX_ABRT_SOURCE);
293 struct xgbe_i2c_op_state *state = &pdata->i2c.op_state;
307 "%#04x\n", __func__, state->tx_abort_source,
308 state->op->target);
312 state->ret = -EIO;
324 axgbe_printf(3, "%s: ret %d stop %d\n", __func__, state->ret,
327 if (state->ret || XI2C_GET_BITS(isr, IC_RAW_INTR_STAT, STOP_DET))
328 pdata->i2c_complete = true;
332 if (pdata->vdata->irq_reissue_support)
353 struct xgbe_i2c *i2c = &pdata->i2c;
357 i2c->max_speed_mode = XI2C_GET_BITS(reg, IC_COMP_PARAM_1,
359 i2c->rx_fifo_size = XI2C_GET_BITS(reg, IC_COMP_PARAM_1,
361 i2c->tx_fifo_size = XI2C_GET_BITS(reg, IC_COMP_PARAM_1,
365 "MAX_SPEED_MODE", i2c->max_speed_mode,
366 "RX_BUFFER_DEPTH", i2c->rx_fifo_size,
367 "TX_BUFFER_DEPTH", i2c->tx_fifo_size);
385 struct xgbe_i2c_op_state *state = &pdata->i2c.op_state;
389 mtx_lock(&pdata->i2c_mutex);
391 axgbe_printf(3, "i2c xfer started ---->>>\n");
399 xgbe_i2c_set_target(pdata, op->target);
401 memset(state, 0, sizeof(*state));
402 state->op = op;
403 state->tx_len = op->len;
404 state->tx_buf = op->buf;
405 state->rx_len = op->len;
406 state->rx_buf = op->buf;
423 if (!pdata->i2c_complete) {
432 if ((ticks >= timeout) && !pdata->i2c_complete) {
434 ret = -ETIMEDOUT;
438 ret = state->ret;
440 ret, state->tx_abort_source);
443 ret, state->tx_abort_source);
444 if (state->tx_abort_source & IC_TX_ABRT_7B_ADDR_NOACK)
445 ret = -ENOTCONN;
446 else if (state->tx_abort_source & IC_TX_ABRT_ARB_LOST)
447 ret = -EAGAIN;
450 axgbe_printf(3, "i2c xfer finished ---->>>\n");
453 pdata->i2c_complete = false;
458 mtx_unlock(&pdata->i2c_mutex);
465 if (!pdata->i2c.started)
470 pdata->i2c.started = 0;
480 if (pdata->i2c.started)
483 pdata->i2c.started = 1;
494 mtx_init(&pdata->i2c_mutex, "xgbe i2c mutex lock", NULL, MTX_DEF);
495 pdata->i2c_complete = false;
519 i2c_if->i2c_init = xgbe_i2c_init;
521 i2c_if->i2c_start = xgbe_i2c_start;
522 i2c_if->i2c_stop = xgbe_i2c_stop;
524 i2c_if->i2c_xfer = xgbe_i2c_xfer;
526 i2c_if->i2c_isr = xgbe_i2c_combined_isr;