Lines Matching +full:ast2400 +full:- +full:scu
1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2012-2020 ASPEED Technology Inc.
50 scl_low = (divider_ratio >> 1) - 1; in get_clk_reg_val()
51 scl_high = divider_ratio - scl_low - 2; in get_clk_reg_val()
64 writel(~0, &priv->regs->isr); in ast_i2c_clear_interrupts()
72 writel(0, &priv->regs->fcr); in ast_i2c_init_bus()
73 /* Enable Master Mode. Assuming single-master */ in ast_i2c_init_bus()
77 &priv->regs->fcr); in ast_i2c_init_bus()
84 | I2CD_INTR_ABNORMAL, &priv->regs->icr); in ast_i2c_init_bus()
92 priv->regs = devfdt_get_addr_ptr(dev); in ast_i2c_ofdata_to_platdata()
93 if (IS_ERR(priv->regs)) in ast_i2c_ofdata_to_platdata()
94 return PTR_ERR(priv->regs); in ast_i2c_ofdata_to_platdata()
96 ret = clk_get_by_index(dev, 0, &priv->clk); in ast_i2c_ofdata_to_platdata()
98 debug("%s: Can't get clock for %s: %d\n", __func__, dev->name, in ast_i2c_ofdata_to_platdata()
108 // struct ast2500_scu *scu; in ast_i2c_probe()
110 debug("Enabling I2C%u\n", dev->seq); in ast_i2c_probe()
118 //TODO scu reset and get clk in ast_i2c_probe()
130 while (!(readl(&priv->regs->isr) & flag) && timeout > 0) { in ast_i2c_wait_isr()
132 timeout -= I2C_SLEEP_STEP_US; in ast_i2c_wait_isr()
137 return -ETIMEDOUT; in ast_i2c_wait_isr()
146 writel(I2CD_M_STOP_CMD, &priv->regs->csr); in ast_i2c_send_stop()
156 u32 status = readl(&priv->regs->isr) & flag; in ast_i2c_wait_tx()
160 status = readl(&priv->regs->isr) & flag; in ast_i2c_wait_tx()
162 timeout -= I2C_SLEEP_STEP_US; in ast_i2c_wait_tx()
166 ret = -EREMOTEIO; in ast_i2c_wait_tx()
169 ret = -ETIMEDOUT; in ast_i2c_wait_tx()
181 writel(devaddr, &priv->regs->trbbr); in ast_i2c_start_txn()
182 writel(I2CD_M_START_CMD | I2CD_M_TX_CMD, &priv->regs->csr); in ast_i2c_start_txn()
198 for (; len > 0; len--, buffer++) { in ast_i2c_read_data()
201 writel(i2c_cmd, &priv->regs->csr); in ast_i2c_read_data()
205 *buffer = (readl(&priv->regs->trbbr) & I2CD_RX_DATA_MASK) in ast_i2c_read_data()
226 for (; len > 0; len--, buffer++) { in ast_i2c_write_data()
227 writel(*buffer, &priv->regs->trbbr); in ast_i2c_write_data()
228 writel(I2CD_M_TX_CMD, &priv->regs->csr); in ast_i2c_write_data()
243 struct ast_i2c_regs *regs = priv->regs; in ast_i2c_deblock()
244 u32 csr = readl(®s->csr); in ast_i2c_deblock()
259 writel(I2CD_BUS_RECOVER_CMD, ®s->csr); in ast_i2c_deblock()
278 for (; nmsgs > 0; nmsgs--, msg++) { in ast_i2c_xfer()
279 if (msg->flags & I2C_M_RD) { in ast_i2c_xfer()
281 msg->addr, msg->len, msg->flags); in ast_i2c_xfer()
282 ret = ast_i2c_read_data(dev, msg->addr, msg->buf, in ast_i2c_xfer()
283 msg->len, (nmsgs == 1)); in ast_i2c_xfer()
286 msg->addr, msg->len, msg->flags); in ast_i2c_xfer()
287 ret = ast_i2c_write_data(dev, msg->addr, msg->buf, in ast_i2c_xfer()
288 msg->len, (nmsgs == 1)); in ast_i2c_xfer()
292 return -EREMOTEIO; in ast_i2c_xfer()
302 struct ast_i2c_regs *regs = priv->regs; in ast_i2c_set_speed()
305 debug("Setting speed for I2C%d to <%u>\n", dev->seq, speed); in ast_i2c_set_speed()
308 return -EINVAL; in ast_i2c_set_speed()
311 i2c_rate = clk_get_rate(&priv->clk); in ast_i2c_set_speed()
314 priv->speed = speed; in ast_i2c_set_speed()
317 setbits_le32(®s->fcr, I2CD_M_HIGH_SPEED_EN in ast_i2c_set_speed()
320 writel(HIGHSPEED_TTIMEOUT, ®s->cactcr2); in ast_i2c_set_speed()
323 writel(I2CD_NO_TIMEOUT_CTRL, ®s->cactcr2); in ast_i2c_set_speed()
326 writel(get_clk_reg_val(divider), ®s->cactcr1); in ast_i2c_set_speed()
339 { .compatible = "aspeed,ast2400-i2c-bus" },
340 { .compatible = "aspeed,ast2500-i2c-bus" },
341 { .compatible = "aspeed,ast2600-i2c-bus" },