WIP FPC-III support
[linux/fpc-iii.git] / drivers / i2c / busses / i2c-uniphier-f.c
blobcb4666c54a233023efb7663e89e51a1977a07f7b
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (C) 2015 Masahiro Yamada <yamada.masahiro@socionext.com>
4 */
6 #include <linux/clk.h>
7 #include <linux/i2c.h>
8 #include <linux/iopoll.h>
9 #include <linux/interrupt.h>
10 #include <linux/io.h>
11 #include <linux/module.h>
12 #include <linux/platform_device.h>
14 #define UNIPHIER_FI2C_CR 0x00 /* control register */
15 #define UNIPHIER_FI2C_CR_MST BIT(3) /* master mode */
16 #define UNIPHIER_FI2C_CR_STA BIT(2) /* start condition */
17 #define UNIPHIER_FI2C_CR_STO BIT(1) /* stop condition */
18 #define UNIPHIER_FI2C_CR_NACK BIT(0) /* do not return ACK */
19 #define UNIPHIER_FI2C_DTTX 0x04 /* TX FIFO */
20 #define UNIPHIER_FI2C_DTTX_CMD BIT(8) /* send command (slave addr) */
21 #define UNIPHIER_FI2C_DTTX_RD BIT(0) /* read transaction */
22 #define UNIPHIER_FI2C_DTRX 0x04 /* RX FIFO */
23 #define UNIPHIER_FI2C_SLAD 0x0c /* slave address */
24 #define UNIPHIER_FI2C_CYC 0x10 /* clock cycle control */
25 #define UNIPHIER_FI2C_LCTL 0x14 /* clock low period control */
26 #define UNIPHIER_FI2C_SSUT 0x18 /* restart/stop setup time control */
27 #define UNIPHIER_FI2C_DSUT 0x1c /* data setup time control */
28 #define UNIPHIER_FI2C_INT 0x20 /* interrupt status */
29 #define UNIPHIER_FI2C_IE 0x24 /* interrupt enable */
30 #define UNIPHIER_FI2C_IC 0x28 /* interrupt clear */
31 #define UNIPHIER_FI2C_INT_TE BIT(9) /* TX FIFO empty */
32 #define UNIPHIER_FI2C_INT_RF BIT(8) /* RX FIFO full */
33 #define UNIPHIER_FI2C_INT_TC BIT(7) /* send complete (STOP) */
34 #define UNIPHIER_FI2C_INT_RC BIT(6) /* receive complete (STOP) */
35 #define UNIPHIER_FI2C_INT_TB BIT(5) /* sent specified bytes */
36 #define UNIPHIER_FI2C_INT_RB BIT(4) /* received specified bytes */
37 #define UNIPHIER_FI2C_INT_NA BIT(2) /* no ACK */
38 #define UNIPHIER_FI2C_INT_AL BIT(1) /* arbitration lost */
39 #define UNIPHIER_FI2C_SR 0x2c /* status register */
40 #define UNIPHIER_FI2C_SR_DB BIT(12) /* device busy */
41 #define UNIPHIER_FI2C_SR_STS BIT(11) /* stop condition detected */
42 #define UNIPHIER_FI2C_SR_BB BIT(8) /* bus busy */
43 #define UNIPHIER_FI2C_SR_RFF BIT(3) /* RX FIFO full */
44 #define UNIPHIER_FI2C_SR_RNE BIT(2) /* RX FIFO not empty */
45 #define UNIPHIER_FI2C_SR_TNF BIT(1) /* TX FIFO not full */
46 #define UNIPHIER_FI2C_SR_TFE BIT(0) /* TX FIFO empty */
47 #define UNIPHIER_FI2C_RST 0x34 /* reset control */
48 #define UNIPHIER_FI2C_RST_TBRST BIT(2) /* clear TX FIFO */
49 #define UNIPHIER_FI2C_RST_RBRST BIT(1) /* clear RX FIFO */
50 #define UNIPHIER_FI2C_RST_RST BIT(0) /* forcible bus reset */
51 #define UNIPHIER_FI2C_BM 0x38 /* bus monitor */
52 #define UNIPHIER_FI2C_BM_SDAO BIT(3) /* output for SDA line */
53 #define UNIPHIER_FI2C_BM_SDAS BIT(2) /* readback of SDA line */
54 #define UNIPHIER_FI2C_BM_SCLO BIT(1) /* output for SCL line */
55 #define UNIPHIER_FI2C_BM_SCLS BIT(0) /* readback of SCL line */
56 #define UNIPHIER_FI2C_NOISE 0x3c /* noise filter control */
57 #define UNIPHIER_FI2C_TBC 0x40 /* TX byte count setting */
58 #define UNIPHIER_FI2C_RBC 0x44 /* RX byte count setting */
59 #define UNIPHIER_FI2C_TBCM 0x48 /* TX byte count monitor */
60 #define UNIPHIER_FI2C_RBCM 0x4c /* RX byte count monitor */
61 #define UNIPHIER_FI2C_BRST 0x50 /* bus reset */
62 #define UNIPHIER_FI2C_BRST_FOEN BIT(1) /* normal operation */
63 #define UNIPHIER_FI2C_BRST_RSCL BIT(0) /* release SCL */
65 #define UNIPHIER_FI2C_INT_FAULTS \
66 (UNIPHIER_FI2C_INT_NA | UNIPHIER_FI2C_INT_AL)
67 #define UNIPHIER_FI2C_INT_STOP \
68 (UNIPHIER_FI2C_INT_TC | UNIPHIER_FI2C_INT_RC)
70 #define UNIPHIER_FI2C_RD BIT(0)
71 #define UNIPHIER_FI2C_STOP BIT(1)
72 #define UNIPHIER_FI2C_MANUAL_NACK BIT(2)
73 #define UNIPHIER_FI2C_BYTE_WISE BIT(3)
74 #define UNIPHIER_FI2C_DEFER_STOP_COMP BIT(4)
76 #define UNIPHIER_FI2C_FIFO_SIZE 8
78 struct uniphier_fi2c_priv {
79 struct completion comp;
80 struct i2c_adapter adap;
81 void __iomem *membase;
82 struct clk *clk;
83 unsigned int len;
84 u8 *buf;
85 u32 enabled_irqs;
86 int error;
87 unsigned int flags;
88 unsigned int busy_cnt;
89 unsigned int clk_cycle;
90 spinlock_t lock; /* IRQ synchronization */
93 static void uniphier_fi2c_fill_txfifo(struct uniphier_fi2c_priv *priv,
94 bool first)
96 int fifo_space = UNIPHIER_FI2C_FIFO_SIZE;
99 * TX-FIFO stores slave address in it for the first access.
100 * Decrement the counter.
102 if (first)
103 fifo_space--;
105 while (priv->len) {
106 if (fifo_space-- <= 0)
107 break;
109 writel(*priv->buf++, priv->membase + UNIPHIER_FI2C_DTTX);
110 priv->len--;
114 static void uniphier_fi2c_drain_rxfifo(struct uniphier_fi2c_priv *priv)
116 int fifo_left = priv->flags & UNIPHIER_FI2C_BYTE_WISE ?
117 1 : UNIPHIER_FI2C_FIFO_SIZE;
119 while (priv->len) {
120 if (fifo_left-- <= 0)
121 break;
123 *priv->buf++ = readl(priv->membase + UNIPHIER_FI2C_DTRX);
124 priv->len--;
128 static void uniphier_fi2c_set_irqs(struct uniphier_fi2c_priv *priv)
130 writel(priv->enabled_irqs, priv->membase + UNIPHIER_FI2C_IE);
133 static void uniphier_fi2c_clear_irqs(struct uniphier_fi2c_priv *priv,
134 u32 mask)
136 writel(mask, priv->membase + UNIPHIER_FI2C_IC);
139 static void uniphier_fi2c_stop(struct uniphier_fi2c_priv *priv)
141 priv->enabled_irqs |= UNIPHIER_FI2C_INT_STOP;
142 uniphier_fi2c_set_irqs(priv);
143 writel(UNIPHIER_FI2C_CR_MST | UNIPHIER_FI2C_CR_STO,
144 priv->membase + UNIPHIER_FI2C_CR);
147 static irqreturn_t uniphier_fi2c_interrupt(int irq, void *dev_id)
149 struct uniphier_fi2c_priv *priv = dev_id;
150 u32 irq_status;
152 spin_lock(&priv->lock);
154 irq_status = readl(priv->membase + UNIPHIER_FI2C_INT);
155 irq_status &= priv->enabled_irqs;
157 if (irq_status & UNIPHIER_FI2C_INT_STOP)
158 goto complete;
160 if (unlikely(irq_status & UNIPHIER_FI2C_INT_AL)) {
161 priv->error = -EAGAIN;
162 goto complete;
165 if (unlikely(irq_status & UNIPHIER_FI2C_INT_NA)) {
166 priv->error = -ENXIO;
167 if (priv->flags & UNIPHIER_FI2C_RD) {
169 * work around a hardware bug:
170 * The receive-completed interrupt is never set even if
171 * STOP condition is detected after the address phase
172 * of read transaction fails to get ACK.
173 * To avoid time-out error, we issue STOP here,
174 * but do not wait for its completion.
175 * It should be checked after exiting this handler.
177 uniphier_fi2c_stop(priv);
178 priv->flags |= UNIPHIER_FI2C_DEFER_STOP_COMP;
179 goto complete;
181 goto stop;
184 if (irq_status & UNIPHIER_FI2C_INT_TE) {
185 if (!priv->len)
186 goto data_done;
188 uniphier_fi2c_fill_txfifo(priv, false);
189 goto handled;
192 if (irq_status & (UNIPHIER_FI2C_INT_RF | UNIPHIER_FI2C_INT_RB)) {
193 uniphier_fi2c_drain_rxfifo(priv);
195 * If the number of bytes to read is multiple of the FIFO size
196 * (msg->len == 8, 16, 24, ...), the INT_RF bit is set a little
197 * earlier than INT_RB. We wait for INT_RB to confirm the
198 * completion of the current message.
200 if (!priv->len && (irq_status & UNIPHIER_FI2C_INT_RB))
201 goto data_done;
203 if (unlikely(priv->flags & UNIPHIER_FI2C_MANUAL_NACK)) {
204 if (priv->len <= UNIPHIER_FI2C_FIFO_SIZE &&
205 !(priv->flags & UNIPHIER_FI2C_BYTE_WISE)) {
206 priv->enabled_irqs |= UNIPHIER_FI2C_INT_RB;
207 uniphier_fi2c_set_irqs(priv);
208 priv->flags |= UNIPHIER_FI2C_BYTE_WISE;
210 if (priv->len <= 1)
211 writel(UNIPHIER_FI2C_CR_MST |
212 UNIPHIER_FI2C_CR_NACK,
213 priv->membase + UNIPHIER_FI2C_CR);
216 goto handled;
219 spin_unlock(&priv->lock);
221 return IRQ_NONE;
223 data_done:
224 if (priv->flags & UNIPHIER_FI2C_STOP) {
225 stop:
226 uniphier_fi2c_stop(priv);
227 } else {
228 complete:
229 priv->enabled_irqs = 0;
230 uniphier_fi2c_set_irqs(priv);
231 complete(&priv->comp);
234 handled:
236 * This controller makes a pause while any bit of the IRQ status is
237 * asserted. Clear the asserted bit to kick the controller just before
238 * exiting the handler.
240 uniphier_fi2c_clear_irqs(priv, irq_status);
242 spin_unlock(&priv->lock);
244 return IRQ_HANDLED;
247 static void uniphier_fi2c_tx_init(struct uniphier_fi2c_priv *priv, u16 addr,
248 bool repeat)
250 priv->enabled_irqs |= UNIPHIER_FI2C_INT_TE;
251 uniphier_fi2c_set_irqs(priv);
253 /* do not use TX byte counter */
254 writel(0, priv->membase + UNIPHIER_FI2C_TBC);
255 /* set slave address */
256 writel(UNIPHIER_FI2C_DTTX_CMD | addr << 1,
257 priv->membase + UNIPHIER_FI2C_DTTX);
259 * First chunk of data. For a repeated START condition, do not write
260 * data to the TX fifo here to avoid the timing issue.
262 if (!repeat)
263 uniphier_fi2c_fill_txfifo(priv, true);
266 static void uniphier_fi2c_rx_init(struct uniphier_fi2c_priv *priv, u16 addr)
268 priv->flags |= UNIPHIER_FI2C_RD;
270 if (likely(priv->len < 256)) {
272 * If possible, use RX byte counter.
273 * It can automatically handle NACK for the last byte.
275 writel(priv->len, priv->membase + UNIPHIER_FI2C_RBC);
276 priv->enabled_irqs |= UNIPHIER_FI2C_INT_RF |
277 UNIPHIER_FI2C_INT_RB;
278 } else {
280 * The byte counter can not count over 256. In this case,
281 * do not use it at all. Drain data when FIFO gets full,
282 * but treat the last portion as a special case.
284 writel(0, priv->membase + UNIPHIER_FI2C_RBC);
285 priv->flags |= UNIPHIER_FI2C_MANUAL_NACK;
286 priv->enabled_irqs |= UNIPHIER_FI2C_INT_RF;
289 uniphier_fi2c_set_irqs(priv);
291 /* set slave address with RD bit */
292 writel(UNIPHIER_FI2C_DTTX_CMD | UNIPHIER_FI2C_DTTX_RD | addr << 1,
293 priv->membase + UNIPHIER_FI2C_DTTX);
296 static void uniphier_fi2c_reset(struct uniphier_fi2c_priv *priv)
298 writel(UNIPHIER_FI2C_RST_RST, priv->membase + UNIPHIER_FI2C_RST);
301 static void uniphier_fi2c_prepare_operation(struct uniphier_fi2c_priv *priv)
303 writel(UNIPHIER_FI2C_BRST_FOEN | UNIPHIER_FI2C_BRST_RSCL,
304 priv->membase + UNIPHIER_FI2C_BRST);
307 static void uniphier_fi2c_recover(struct uniphier_fi2c_priv *priv)
309 uniphier_fi2c_reset(priv);
310 i2c_recover_bus(&priv->adap);
313 static int uniphier_fi2c_master_xfer_one(struct i2c_adapter *adap,
314 struct i2c_msg *msg, bool repeat,
315 bool stop)
317 struct uniphier_fi2c_priv *priv = i2c_get_adapdata(adap);
318 bool is_read = msg->flags & I2C_M_RD;
319 unsigned long time_left, flags;
321 priv->len = msg->len;
322 priv->buf = msg->buf;
323 priv->enabled_irqs = UNIPHIER_FI2C_INT_FAULTS;
324 priv->error = 0;
325 priv->flags = 0;
327 if (stop)
328 priv->flags |= UNIPHIER_FI2C_STOP;
330 reinit_completion(&priv->comp);
331 uniphier_fi2c_clear_irqs(priv, U32_MAX);
332 writel(UNIPHIER_FI2C_RST_TBRST | UNIPHIER_FI2C_RST_RBRST,
333 priv->membase + UNIPHIER_FI2C_RST); /* reset TX/RX FIFO */
335 spin_lock_irqsave(&priv->lock, flags);
337 if (is_read)
338 uniphier_fi2c_rx_init(priv, msg->addr);
339 else
340 uniphier_fi2c_tx_init(priv, msg->addr, repeat);
343 * For a repeated START condition, writing a slave address to the FIFO
344 * kicks the controller. So, the UNIPHIER_FI2C_CR register should be
345 * written only for a non-repeated START condition.
347 if (!repeat)
348 writel(UNIPHIER_FI2C_CR_MST | UNIPHIER_FI2C_CR_STA,
349 priv->membase + UNIPHIER_FI2C_CR);
351 spin_unlock_irqrestore(&priv->lock, flags);
353 time_left = wait_for_completion_timeout(&priv->comp, adap->timeout);
355 spin_lock_irqsave(&priv->lock, flags);
356 priv->enabled_irqs = 0;
357 uniphier_fi2c_set_irqs(priv);
358 spin_unlock_irqrestore(&priv->lock, flags);
360 if (!time_left) {
361 dev_err(&adap->dev, "transaction timeout.\n");
362 uniphier_fi2c_recover(priv);
363 return -ETIMEDOUT;
366 if (unlikely(priv->flags & UNIPHIER_FI2C_DEFER_STOP_COMP)) {
367 u32 status;
368 int ret;
370 ret = readl_poll_timeout(priv->membase + UNIPHIER_FI2C_SR,
371 status,
372 (status & UNIPHIER_FI2C_SR_STS) &&
373 !(status & UNIPHIER_FI2C_SR_BB),
374 1, 20);
375 if (ret) {
376 dev_err(&adap->dev,
377 "stop condition was not completed.\n");
378 uniphier_fi2c_recover(priv);
379 return ret;
383 return priv->error;
386 static int uniphier_fi2c_check_bus_busy(struct i2c_adapter *adap)
388 struct uniphier_fi2c_priv *priv = i2c_get_adapdata(adap);
390 if (readl(priv->membase + UNIPHIER_FI2C_SR) & UNIPHIER_FI2C_SR_DB) {
391 if (priv->busy_cnt++ > 3) {
393 * If bus busy continues too long, it is probably
394 * in a wrong state. Try bus recovery.
396 uniphier_fi2c_recover(priv);
397 priv->busy_cnt = 0;
400 return -EAGAIN;
403 priv->busy_cnt = 0;
404 return 0;
407 static int uniphier_fi2c_master_xfer(struct i2c_adapter *adap,
408 struct i2c_msg *msgs, int num)
410 struct i2c_msg *msg, *emsg = msgs + num;
411 bool repeat = false;
412 int ret;
414 ret = uniphier_fi2c_check_bus_busy(adap);
415 if (ret)
416 return ret;
418 for (msg = msgs; msg < emsg; msg++) {
419 /* Emit STOP if it is the last message or I2C_M_STOP is set. */
420 bool stop = (msg + 1 == emsg) || (msg->flags & I2C_M_STOP);
422 ret = uniphier_fi2c_master_xfer_one(adap, msg, repeat, stop);
423 if (ret)
424 return ret;
426 repeat = !stop;
429 return num;
432 static u32 uniphier_fi2c_functionality(struct i2c_adapter *adap)
434 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
437 static const struct i2c_algorithm uniphier_fi2c_algo = {
438 .master_xfer = uniphier_fi2c_master_xfer,
439 .functionality = uniphier_fi2c_functionality,
442 static int uniphier_fi2c_get_scl(struct i2c_adapter *adap)
444 struct uniphier_fi2c_priv *priv = i2c_get_adapdata(adap);
446 return !!(readl(priv->membase + UNIPHIER_FI2C_BM) &
447 UNIPHIER_FI2C_BM_SCLS);
450 static void uniphier_fi2c_set_scl(struct i2c_adapter *adap, int val)
452 struct uniphier_fi2c_priv *priv = i2c_get_adapdata(adap);
454 writel(val ? UNIPHIER_FI2C_BRST_RSCL : 0,
455 priv->membase + UNIPHIER_FI2C_BRST);
458 static int uniphier_fi2c_get_sda(struct i2c_adapter *adap)
460 struct uniphier_fi2c_priv *priv = i2c_get_adapdata(adap);
462 return !!(readl(priv->membase + UNIPHIER_FI2C_BM) &
463 UNIPHIER_FI2C_BM_SDAS);
466 static void uniphier_fi2c_unprepare_recovery(struct i2c_adapter *adap)
468 uniphier_fi2c_prepare_operation(i2c_get_adapdata(adap));
471 static struct i2c_bus_recovery_info uniphier_fi2c_bus_recovery_info = {
472 .recover_bus = i2c_generic_scl_recovery,
473 .get_scl = uniphier_fi2c_get_scl,
474 .set_scl = uniphier_fi2c_set_scl,
475 .get_sda = uniphier_fi2c_get_sda,
476 .unprepare_recovery = uniphier_fi2c_unprepare_recovery,
479 static void uniphier_fi2c_hw_init(struct uniphier_fi2c_priv *priv)
481 unsigned int cyc = priv->clk_cycle;
482 u32 tmp;
484 tmp = readl(priv->membase + UNIPHIER_FI2C_CR);
485 tmp |= UNIPHIER_FI2C_CR_MST;
486 writel(tmp, priv->membase + UNIPHIER_FI2C_CR);
488 uniphier_fi2c_reset(priv);
491 * Standard-mode: tLOW + tHIGH = 10 us
492 * Fast-mode: tLOW + tHIGH = 2.5 us
494 writel(cyc, priv->membase + UNIPHIER_FI2C_CYC);
496 * Standard-mode: tLOW = 4.7 us, tHIGH = 4.0 us, tBUF = 4.7 us
497 * Fast-mode: tLOW = 1.3 us, tHIGH = 0.6 us, tBUF = 1.3 us
498 * "tLow/tHIGH = 5/4" meets both.
500 writel(cyc * 5 / 9, priv->membase + UNIPHIER_FI2C_LCTL);
502 * Standard-mode: tHD;STA = 4.0 us, tSU;STA = 4.7 us, tSU;STO = 4.0 us
503 * Fast-mode: tHD;STA = 0.6 us, tSU;STA = 0.6 us, tSU;STO = 0.6 us
505 writel(cyc / 2, priv->membase + UNIPHIER_FI2C_SSUT);
507 * Standard-mode: tSU;DAT = 250 ns
508 * Fast-mode: tSU;DAT = 100 ns
510 writel(cyc / 16, priv->membase + UNIPHIER_FI2C_DSUT);
512 uniphier_fi2c_prepare_operation(priv);
515 static int uniphier_fi2c_probe(struct platform_device *pdev)
517 struct device *dev = &pdev->dev;
518 struct uniphier_fi2c_priv *priv;
519 u32 bus_speed;
520 unsigned long clk_rate;
521 int irq, ret;
523 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
524 if (!priv)
525 return -ENOMEM;
527 priv->membase = devm_platform_ioremap_resource(pdev, 0);
528 if (IS_ERR(priv->membase))
529 return PTR_ERR(priv->membase);
531 irq = platform_get_irq(pdev, 0);
532 if (irq < 0)
533 return irq;
535 if (of_property_read_u32(dev->of_node, "clock-frequency", &bus_speed))
536 bus_speed = I2C_MAX_STANDARD_MODE_FREQ;
538 if (!bus_speed || bus_speed > I2C_MAX_FAST_MODE_FREQ) {
539 dev_err(dev, "invalid clock-frequency %d\n", bus_speed);
540 return -EINVAL;
543 priv->clk = devm_clk_get(dev, NULL);
544 if (IS_ERR(priv->clk)) {
545 dev_err(dev, "failed to get clock\n");
546 return PTR_ERR(priv->clk);
549 ret = clk_prepare_enable(priv->clk);
550 if (ret)
551 return ret;
553 clk_rate = clk_get_rate(priv->clk);
554 if (!clk_rate) {
555 dev_err(dev, "input clock rate should not be zero\n");
556 ret = -EINVAL;
557 goto disable_clk;
560 priv->clk_cycle = clk_rate / bus_speed;
561 init_completion(&priv->comp);
562 spin_lock_init(&priv->lock);
563 priv->adap.owner = THIS_MODULE;
564 priv->adap.algo = &uniphier_fi2c_algo;
565 priv->adap.dev.parent = dev;
566 priv->adap.dev.of_node = dev->of_node;
567 strlcpy(priv->adap.name, "UniPhier FI2C", sizeof(priv->adap.name));
568 priv->adap.bus_recovery_info = &uniphier_fi2c_bus_recovery_info;
569 i2c_set_adapdata(&priv->adap, priv);
570 platform_set_drvdata(pdev, priv);
572 uniphier_fi2c_hw_init(priv);
574 ret = devm_request_irq(dev, irq, uniphier_fi2c_interrupt, 0,
575 pdev->name, priv);
576 if (ret) {
577 dev_err(dev, "failed to request irq %d\n", irq);
578 goto disable_clk;
581 ret = i2c_add_adapter(&priv->adap);
582 disable_clk:
583 if (ret)
584 clk_disable_unprepare(priv->clk);
586 return ret;
589 static int uniphier_fi2c_remove(struct platform_device *pdev)
591 struct uniphier_fi2c_priv *priv = platform_get_drvdata(pdev);
593 i2c_del_adapter(&priv->adap);
594 clk_disable_unprepare(priv->clk);
596 return 0;
599 static int __maybe_unused uniphier_fi2c_suspend(struct device *dev)
601 struct uniphier_fi2c_priv *priv = dev_get_drvdata(dev);
603 clk_disable_unprepare(priv->clk);
605 return 0;
608 static int __maybe_unused uniphier_fi2c_resume(struct device *dev)
610 struct uniphier_fi2c_priv *priv = dev_get_drvdata(dev);
611 int ret;
613 ret = clk_prepare_enable(priv->clk);
614 if (ret)
615 return ret;
617 uniphier_fi2c_hw_init(priv);
619 return 0;
622 static const struct dev_pm_ops uniphier_fi2c_pm_ops = {
623 SET_SYSTEM_SLEEP_PM_OPS(uniphier_fi2c_suspend, uniphier_fi2c_resume)
626 static const struct of_device_id uniphier_fi2c_match[] = {
627 { .compatible = "socionext,uniphier-fi2c" },
628 { /* sentinel */ }
630 MODULE_DEVICE_TABLE(of, uniphier_fi2c_match);
632 static struct platform_driver uniphier_fi2c_drv = {
633 .probe = uniphier_fi2c_probe,
634 .remove = uniphier_fi2c_remove,
635 .driver = {
636 .name = "uniphier-fi2c",
637 .of_match_table = uniphier_fi2c_match,
638 .pm = &uniphier_fi2c_pm_ops,
641 module_platform_driver(uniphier_fi2c_drv);
643 MODULE_AUTHOR("Masahiro Yamada <yamada.masahiro@socionext.com>");
644 MODULE_DESCRIPTION("UniPhier FIFO-builtin I2C bus driver");
645 MODULE_LICENSE("GPL");