Lines Matching +full:ast2400 +full:- +full:scu
2 * Copyright (C) 2012-2020 ASPEED Technology Inc.
6 * SPDX-License-Identifier: GPL-2.0+
53 scl_low = (divider_ratio >> 1) - 1; in get_clk_reg_val()
54 scl_high = divider_ratio - scl_low - 2; in get_clk_reg_val()
67 writel(~0, &priv->regs->isr); in ast_i2c_clear_interrupts()
75 writel(0, &priv->regs->fcr); in ast_i2c_init_bus()
76 /* Enable Master Mode. Assuming single-master */ in ast_i2c_init_bus()
80 &priv->regs->fcr); in ast_i2c_init_bus()
87 | I2CD_INTR_ABNORMAL, &priv->regs->icr); in ast_i2c_init_bus()
95 priv->regs = devfdt_get_addr_ptr(dev); in ast_i2c_ofdata_to_platdata()
96 if (IS_ERR(priv->regs)) in ast_i2c_ofdata_to_platdata()
97 return PTR_ERR(priv->regs); in ast_i2c_ofdata_to_platdata()
99 ret = clk_get_by_index(dev, 0, &priv->clk); in ast_i2c_ofdata_to_platdata()
101 debug("%s: Can't get clock for %s: %d\n", __func__, dev->name, in ast_i2c_ofdata_to_platdata()
111 struct ast2500_scu *scu; in ast_i2c_probe() local
113 debug("Enabling I2C%u\n", dev->seq); in ast_i2c_probe()
120 scu = ast_get_scu(); in ast_i2c_probe()
121 ast_scu_unlock(scu); in ast_i2c_probe()
122 clrbits_le32(&scu->sysreset_ctrl1, SCU_SYSRESET_I2C); in ast_i2c_probe()
123 ast_scu_lock(scu); in ast_i2c_probe()
135 while (!(readl(&priv->regs->isr) & flag) && timeout > 0) { in ast_i2c_wait_isr()
137 timeout -= I2C_SLEEP_STEP_US; in ast_i2c_wait_isr()
142 return -ETIMEDOUT; in ast_i2c_wait_isr()
151 writel(I2CD_M_STOP_CMD, &priv->regs->csr); in ast_i2c_send_stop()
161 u32 status = readl(&priv->regs->isr) & flag; in ast_i2c_wait_tx()
165 status = readl(&priv->regs->isr) & flag; in ast_i2c_wait_tx()
167 timeout -= I2C_SLEEP_STEP_US; in ast_i2c_wait_tx()
171 ret = -EREMOTEIO; in ast_i2c_wait_tx()
174 ret = -ETIMEDOUT; in ast_i2c_wait_tx()
186 writel(devaddr, &priv->regs->trbbr); in ast_i2c_start_txn()
187 writel(I2CD_M_START_CMD | I2CD_M_TX_CMD, &priv->regs->csr); in ast_i2c_start_txn()
203 for (; len > 0; len--, buffer++) { in ast_i2c_read_data()
206 writel(i2c_cmd, &priv->regs->csr); in ast_i2c_read_data()
210 *buffer = (readl(&priv->regs->trbbr) & I2CD_RX_DATA_MASK) in ast_i2c_read_data()
231 for (; len > 0; len--, buffer++) { in ast_i2c_write_data()
232 writel(*buffer, &priv->regs->trbbr); in ast_i2c_write_data()
233 writel(I2CD_M_TX_CMD, &priv->regs->csr); in ast_i2c_write_data()
248 struct ast_i2c_regs *regs = priv->regs; in ast_i2c_deblock()
249 u32 csr = readl(®s->csr); in ast_i2c_deblock()
264 writel(I2CD_BUS_RECOVER_CMD, ®s->csr); in ast_i2c_deblock()
283 for (; nmsgs > 0; nmsgs--, msg++) { in ast_i2c_xfer()
284 if (msg->flags & I2C_M_RD) { in ast_i2c_xfer()
286 msg->addr, msg->len, msg->flags); in ast_i2c_xfer()
287 ret = ast_i2c_read_data(dev, msg->addr, msg->buf, in ast_i2c_xfer()
288 msg->len, (nmsgs == 1)); in ast_i2c_xfer()
291 msg->addr, msg->len, msg->flags); in ast_i2c_xfer()
292 ret = ast_i2c_write_data(dev, msg->addr, msg->buf, in ast_i2c_xfer()
293 msg->len, (nmsgs == 1)); in ast_i2c_xfer()
297 return -EREMOTEIO; in ast_i2c_xfer()
307 struct ast_i2c_regs *regs = priv->regs; in ast_i2c_set_speed()
310 debug("Setting speed for I2C%d to <%u>\n", dev->seq, speed); in ast_i2c_set_speed()
313 return -EINVAL; in ast_i2c_set_speed()
316 i2c_rate = clk_get_rate(&priv->clk); in ast_i2c_set_speed()
319 priv->speed = speed; in ast_i2c_set_speed()
322 setbits_le32(®s->fcr, I2CD_M_HIGH_SPEED_EN in ast_i2c_set_speed()
325 writel(HIGHSPEED_TTIMEOUT, ®s->cactcr2); in ast_i2c_set_speed()
328 writel(I2CD_NO_TIMEOUT_CTRL, ®s->cactcr2); in ast_i2c_set_speed()
331 writel(get_clk_reg_val(divider), ®s->cactcr1); in ast_i2c_set_speed()
344 { .compatible = "aspeed,ast2400-i2c-bus" },
345 { .compatible = "aspeed,ast2500-i2c-bus" },