• Home
  • Raw
  • Download

Lines Matching refs:siic

89 static void i2c_sirfsoc_read_data(struct sirfsoc_i2c *siic)  in i2c_sirfsoc_read_data()  argument
94 for (i = 0; i < siic->read_cmd_len; i++) { in i2c_sirfsoc_read_data()
96 data = readl(siic->base + SIRFSOC_I2C_DATA_BUF + i); in i2c_sirfsoc_read_data()
97 siic->buf[siic->finished_len++] = in i2c_sirfsoc_read_data()
103 static void i2c_sirfsoc_queue_cmd(struct sirfsoc_i2c *siic) in i2c_sirfsoc_queue_cmd() argument
108 if (siic->msg_read) { in i2c_sirfsoc_queue_cmd()
109 while (((siic->finished_len + i) < siic->msg_len) in i2c_sirfsoc_queue_cmd()
110 && (siic->cmd_ptr < SIRFSOC_I2C_CMD_BUF_MAX)) { in i2c_sirfsoc_queue_cmd()
112 if (((siic->finished_len + i) == in i2c_sirfsoc_queue_cmd()
113 (siic->msg_len - 1)) && siic->last) in i2c_sirfsoc_queue_cmd()
116 siic->base + SIRFSOC_I2C_CMD(siic->cmd_ptr++)); in i2c_sirfsoc_queue_cmd()
120 siic->read_cmd_len = i; in i2c_sirfsoc_queue_cmd()
122 while ((siic->cmd_ptr < SIRFSOC_I2C_CMD_BUF_MAX - 1) in i2c_sirfsoc_queue_cmd()
123 && (siic->finished_len < siic->msg_len)) { in i2c_sirfsoc_queue_cmd()
125 if ((siic->finished_len == (siic->msg_len - 1)) in i2c_sirfsoc_queue_cmd()
126 && siic->last) in i2c_sirfsoc_queue_cmd()
129 siic->base + SIRFSOC_I2C_CMD(siic->cmd_ptr++)); in i2c_sirfsoc_queue_cmd()
130 writel(siic->buf[siic->finished_len++], in i2c_sirfsoc_queue_cmd()
131 siic->base + SIRFSOC_I2C_CMD(siic->cmd_ptr++)); in i2c_sirfsoc_queue_cmd()
134 siic->cmd_ptr = 0; in i2c_sirfsoc_queue_cmd()
137 writel(SIRFSOC_I2C_START_CMD, siic->base + SIRFSOC_I2C_CMD_START); in i2c_sirfsoc_queue_cmd()
142 struct sirfsoc_i2c *siic = (struct sirfsoc_i2c *)dev_id; in i2c_sirfsoc_irq() local
143 u32 i2c_stat = readl(siic->base + SIRFSOC_I2C_STATUS); in i2c_sirfsoc_irq()
147 siic->err_status = SIRFSOC_I2C_ERR_NOACK; in i2c_sirfsoc_irq()
148 writel(SIRFSOC_I2C_STAT_ERR, siic->base + SIRFSOC_I2C_STATUS); in i2c_sirfsoc_irq()
151 dev_dbg(&siic->adapter.dev, "ACK not received\n"); in i2c_sirfsoc_irq()
153 dev_err(&siic->adapter.dev, "I2C error\n"); in i2c_sirfsoc_irq()
160 writel(readl(siic->base + SIRFSOC_I2C_CTRL) | SIRFSOC_I2C_RESET, in i2c_sirfsoc_irq()
161 siic->base + SIRFSOC_I2C_CTRL); in i2c_sirfsoc_irq()
162 while (readl(siic->base + SIRFSOC_I2C_CTRL) & SIRFSOC_I2C_RESET) in i2c_sirfsoc_irq()
165 complete(&siic->done); in i2c_sirfsoc_irq()
168 if (siic->msg_read) in i2c_sirfsoc_irq()
169 i2c_sirfsoc_read_data(siic); in i2c_sirfsoc_irq()
170 if (siic->finished_len == siic->msg_len) in i2c_sirfsoc_irq()
171 complete(&siic->done); in i2c_sirfsoc_irq()
173 i2c_sirfsoc_queue_cmd(siic); in i2c_sirfsoc_irq()
175 writel(SIRFSOC_I2C_STAT_CMD_DONE, siic->base + SIRFSOC_I2C_STATUS); in i2c_sirfsoc_irq()
181 static void i2c_sirfsoc_set_address(struct sirfsoc_i2c *siic, in i2c_sirfsoc_set_address() argument
188 if (siic->last && (msg->len == 0)) in i2c_sirfsoc_set_address()
191 writel(regval, siic->base + SIRFSOC_I2C_CMD(siic->cmd_ptr++)); in i2c_sirfsoc_set_address()
201 writel(addr, siic->base + SIRFSOC_I2C_CMD(siic->cmd_ptr++)); in i2c_sirfsoc_set_address()
204 static int i2c_sirfsoc_xfer_msg(struct sirfsoc_i2c *siic, struct i2c_msg *msg) in i2c_sirfsoc_xfer_msg() argument
206 u32 regval = readl(siic->base + SIRFSOC_I2C_CTRL); in i2c_sirfsoc_xfer_msg()
210 i2c_sirfsoc_set_address(siic, msg); in i2c_sirfsoc_xfer_msg()
213 siic->base + SIRFSOC_I2C_CTRL); in i2c_sirfsoc_xfer_msg()
214 i2c_sirfsoc_queue_cmd(siic); in i2c_sirfsoc_xfer_msg()
216 if (wait_for_completion_timeout(&siic->done, timeout) == 0) { in i2c_sirfsoc_xfer_msg()
217 siic->err_status = SIRFSOC_I2C_ERR_TIMEOUT; in i2c_sirfsoc_xfer_msg()
218 dev_err(&siic->adapter.dev, "Transfer timeout\n"); in i2c_sirfsoc_xfer_msg()
222 siic->base + SIRFSOC_I2C_CTRL); in i2c_sirfsoc_xfer_msg()
223 writel(0, siic->base + SIRFSOC_I2C_CMD_START); in i2c_sirfsoc_xfer_msg()
226 if (siic->err_status == SIRFSOC_I2C_ERR_TIMEOUT) { in i2c_sirfsoc_xfer_msg()
227 writel(readl(siic->base + SIRFSOC_I2C_CTRL) | SIRFSOC_I2C_RESET, in i2c_sirfsoc_xfer_msg()
228 siic->base + SIRFSOC_I2C_CTRL); in i2c_sirfsoc_xfer_msg()
229 while (readl(siic->base + SIRFSOC_I2C_CTRL) & SIRFSOC_I2C_RESET) in i2c_sirfsoc_xfer_msg()
232 return siic->err_status ? -EAGAIN : 0; in i2c_sirfsoc_xfer_msg()
243 struct sirfsoc_i2c *siic = adap->algo_data; in i2c_sirfsoc_xfer() local
246 clk_enable(siic->clk); in i2c_sirfsoc_xfer()
249 siic->buf = msgs[i].buf; in i2c_sirfsoc_xfer()
250 siic->msg_len = msgs[i].len; in i2c_sirfsoc_xfer()
251 siic->msg_read = !!(msgs[i].flags & I2C_M_RD); in i2c_sirfsoc_xfer()
252 siic->err_status = 0; in i2c_sirfsoc_xfer()
253 siic->cmd_ptr = 0; in i2c_sirfsoc_xfer()
254 siic->finished_len = 0; in i2c_sirfsoc_xfer()
255 siic->last = (i == (num - 1)); in i2c_sirfsoc_xfer()
257 ret = i2c_sirfsoc_xfer_msg(siic, &msgs[i]); in i2c_sirfsoc_xfer()
259 clk_disable(siic->clk); in i2c_sirfsoc_xfer()
264 clk_disable(siic->clk); in i2c_sirfsoc_xfer()
276 struct sirfsoc_i2c *siic; in i2c_sirfsoc_probe() local
308 siic = devm_kzalloc(&pdev->dev, sizeof(*siic), GFP_KERNEL); in i2c_sirfsoc_probe()
309 if (!siic) { in i2c_sirfsoc_probe()
313 adap = &siic->adapter; in i2c_sirfsoc_probe()
317 siic->base = devm_ioremap_resource(&pdev->dev, mem_res); in i2c_sirfsoc_probe()
318 if (IS_ERR(siic->base)) { in i2c_sirfsoc_probe()
319 err = PTR_ERR(siic->base); in i2c_sirfsoc_probe()
329 dev_name(&pdev->dev), siic); in i2c_sirfsoc_probe()
334 adap->algo_data = siic; in i2c_sirfsoc_probe()
344 init_completion(&siic->done); in i2c_sirfsoc_probe()
348 writel(SIRFSOC_I2C_RESET, siic->base + SIRFSOC_I2C_CTRL); in i2c_sirfsoc_probe()
349 while (readl(siic->base + SIRFSOC_I2C_CTRL) & SIRFSOC_I2C_RESET) in i2c_sirfsoc_probe()
352 siic->base + SIRFSOC_I2C_CTRL); in i2c_sirfsoc_probe()
354 siic->clk = clk; in i2c_sirfsoc_probe()
385 writel(regval, siic->base + SIRFSOC_I2C_CLK_CTRL); in i2c_sirfsoc_probe()
387 writel(0xFF, siic->base + SIRFSOC_I2C_SDA_DELAY); in i2c_sirfsoc_probe()
389 writel(regval, siic->base + SIRFSOC_I2C_SDA_DELAY); in i2c_sirfsoc_probe()
416 struct sirfsoc_i2c *siic = adapter->algo_data; in i2c_sirfsoc_remove() local
418 writel(SIRFSOC_I2C_RESET, siic->base + SIRFSOC_I2C_CTRL); in i2c_sirfsoc_remove()
420 clk_unprepare(siic->clk); in i2c_sirfsoc_remove()
421 clk_put(siic->clk); in i2c_sirfsoc_remove()
430 struct sirfsoc_i2c *siic = adapter->algo_data; in i2c_sirfsoc_suspend() local
432 clk_enable(siic->clk); in i2c_sirfsoc_suspend()
433 siic->sda_delay = readl(siic->base + SIRFSOC_I2C_SDA_DELAY); in i2c_sirfsoc_suspend()
434 siic->clk_div = readl(siic->base + SIRFSOC_I2C_CLK_CTRL); in i2c_sirfsoc_suspend()
435 clk_disable(siic->clk); in i2c_sirfsoc_suspend()
443 struct sirfsoc_i2c *siic = adapter->algo_data; in i2c_sirfsoc_resume() local
445 clk_enable(siic->clk); in i2c_sirfsoc_resume()
446 writel(SIRFSOC_I2C_RESET, siic->base + SIRFSOC_I2C_CTRL); in i2c_sirfsoc_resume()
447 while (readl(siic->base + SIRFSOC_I2C_CTRL) & SIRFSOC_I2C_RESET) in i2c_sirfsoc_resume()
450 siic->base + SIRFSOC_I2C_CTRL); in i2c_sirfsoc_resume()
451 writel(siic->clk_div, siic->base + SIRFSOC_I2C_CLK_CTRL); in i2c_sirfsoc_resume()
452 writel(siic->sda_delay, siic->base + SIRFSOC_I2C_SDA_DELAY); in i2c_sirfsoc_resume()
453 clk_disable(siic->clk); in i2c_sirfsoc_resume()