1 // SPDX-License-Identifier: GPL-2.0-only
2 // Copyright (C) 2014 Broadcom Corporation
5 #include <linux/delay.h>
6 #include <linux/device.h>
8 #include <linux/interrupt.h>
10 #include <linux/kernel.h>
11 #include <linux/module.h>
12 #include <linux/platform_device.h>
13 #include <linux/sched.h>
14 #include <linux/slab.h>
19 * PER_I2C/BSC count register mask depends on 1 byte/4 byte data register
20 * size. Cable modem and DSL SoCs with Peripheral i2c cores use 1 byte per
21 * data register whereas STB SoCs use 4 byte per data register transfer,
22 * account for this difference in total count per transaction and mask to
25 #define BSC_CNT_REG1_MASK(nb) (nb == 1 ? GENMASK(3, 0) : GENMASK(5, 0))
26 #define BSC_CNT_REG1_SHIFT 0
28 /* BSC CTL register field definitions */
29 #define BSC_CTL_REG_DTF_MASK 0x00000003
30 #define BSC_CTL_REG_SCL_SEL_MASK 0x00000030
31 #define BSC_CTL_REG_SCL_SEL_SHIFT 4
32 #define BSC_CTL_REG_INT_EN_MASK 0x00000040
33 #define BSC_CTL_REG_INT_EN_SHIFT 6
34 #define BSC_CTL_REG_DIV_CLK_MASK 0x00000080
36 /* BSC_IIC_ENABLE r/w enable and interrupt field definitions */
37 #define BSC_IIC_EN_RESTART_MASK 0x00000040
38 #define BSC_IIC_EN_NOSTART_MASK 0x00000020
39 #define BSC_IIC_EN_NOSTOP_MASK 0x00000010
40 #define BSC_IIC_EN_NOACK_MASK 0x00000004
41 #define BSC_IIC_EN_INTRP_MASK 0x00000002
42 #define BSC_IIC_EN_ENABLE_MASK 0x00000001
44 /* BSC_CTLHI control register field definitions */
45 #define BSC_CTLHI_REG_INPUT_SWITCHING_LEVEL_MASK 0x00000080
46 #define BSC_CTLHI_REG_DATAREG_SIZE_MASK 0x00000040
47 #define BSC_CTLHI_REG_IGNORE_ACK_MASK 0x00000002
48 #define BSC_CTLHI_REG_WAIT_DIS_MASK 0x00000001
50 #define I2C_TIMEOUT 100 /* msecs */
52 /* Condition mask used for non combined transfer */
53 #define COND_RESTART BSC_IIC_EN_RESTART_MASK
54 #define COND_NOSTART BSC_IIC_EN_NOSTART_MASK
55 #define COND_NOSTOP BSC_IIC_EN_NOSTOP_MASK
56 #define COND_START_STOP (COND_RESTART | COND_NOSTART | COND_NOSTOP)
58 /* BSC data transfer direction */
59 #define DTF_WR_MASK 0x00000000
60 #define DTF_RD_MASK 0x00000001
61 /* BSC data transfer direction combined format */
62 #define DTF_RD_WR_MASK 0x00000002
63 #define DTF_WR_RD_MASK 0x00000003
65 #define INT_ENABLE true
66 #define INT_DISABLE false
68 /* BSC block register map structure to cache fields to be written */
70 u32 chip_address
; /* target address */
71 u32 data_in
[N_DATA_REGS
]; /* tx data buffer*/
72 u32 cnt_reg
; /* rx/tx data length */
73 u32 ctl_reg
; /* control register */
74 u32 iic_enable
; /* xfer enable and status */
75 u32 data_out
[N_DATA_REGS
]; /* rx data buffer */
76 u32 ctlhi_reg
; /* more control fields */
77 u32 scl_param
; /* reserved */
80 struct bsc_clk_param
{
93 static char const *cmd_string
[] = {
96 [CMD_WR_NOACK
] = "WR NOACK",
97 [CMD_RD_NOACK
] = "RD NOACK",
111 static const struct bsc_clk_param bsc_clk
[] = {
114 .scl_mask
= SPD_375K
<< BSC_CTL_REG_SCL_SEL_SHIFT
,
119 .scl_mask
= SPD_390K
<< BSC_CTL_REG_SCL_SEL_SHIFT
,
124 .scl_mask
= SPD_187K
<< BSC_CTL_REG_SCL_SEL_SHIFT
,
129 .scl_mask
= SPD_200K
<< BSC_CTL_REG_SCL_SEL_SHIFT
,
134 .scl_mask
= SPD_375K
<< BSC_CTL_REG_SCL_SEL_SHIFT
,
135 .div_mask
= BSC_CTL_REG_DIV_CLK_MASK
139 .scl_mask
= SPD_390K
<< BSC_CTL_REG_SCL_SEL_SHIFT
,
140 .div_mask
= BSC_CTL_REG_DIV_CLK_MASK
144 .scl_mask
= SPD_187K
<< BSC_CTL_REG_SCL_SEL_SHIFT
,
145 .div_mask
= BSC_CTL_REG_DIV_CLK_MASK
149 .scl_mask
= SPD_200K
<< BSC_CTL_REG_SCL_SEL_SHIFT
,
150 .div_mask
= BSC_CTL_REG_DIV_CLK_MASK
154 struct brcmstb_i2c_dev
{
155 struct device
*device
;
158 struct bsc_regs
*bsc_regmap
;
159 struct i2c_adapter adapter
;
160 struct completion done
;
166 /* register accessors for both be and le cpu arch */
167 #ifdef CONFIG_CPU_BIG_ENDIAN
168 #define __bsc_readl(_reg) ioread32be(_reg)
169 #define __bsc_writel(_val, _reg) iowrite32be(_val, _reg)
171 #define __bsc_readl(_reg) ioread32(_reg)
172 #define __bsc_writel(_val, _reg) iowrite32(_val, _reg)
175 #define bsc_readl(_dev, _reg) \
176 __bsc_readl(_dev->base + offsetof(struct bsc_regs, _reg))
178 #define bsc_writel(_dev, _val, _reg) \
179 __bsc_writel(_val, _dev->base + offsetof(struct bsc_regs, _reg))
181 static inline int brcmstb_i2c_get_xfersz(struct brcmstb_i2c_dev
*dev
)
183 return (N_DATA_REGS
* dev
->data_regsz
);
186 static inline int brcmstb_i2c_get_data_regsz(struct brcmstb_i2c_dev
*dev
)
188 return dev
->data_regsz
;
191 static void brcmstb_i2c_enable_disable_irq(struct brcmstb_i2c_dev
*dev
,
196 /* Enable BSC CTL interrupt line */
197 dev
->bsc_regmap
->ctl_reg
|= BSC_CTL_REG_INT_EN_MASK
;
199 /* Disable BSC CTL interrupt line */
200 dev
->bsc_regmap
->ctl_reg
&= ~BSC_CTL_REG_INT_EN_MASK
;
203 bsc_writel(dev
, dev
->bsc_regmap
->ctl_reg
, ctl_reg
);
206 static irqreturn_t
brcmstb_i2c_isr(int irq
, void *devid
)
208 struct brcmstb_i2c_dev
*dev
= devid
;
209 u32 status_bsc_ctl
= bsc_readl(dev
, ctl_reg
);
210 u32 status_iic_intrp
= bsc_readl(dev
, iic_enable
);
212 dev_dbg(dev
->device
, "isr CTL_REG %x IIC_EN %x\n",
213 status_bsc_ctl
, status_iic_intrp
);
215 if (!(status_bsc_ctl
& BSC_CTL_REG_INT_EN_MASK
))
218 brcmstb_i2c_enable_disable_irq(dev
, INT_DISABLE
);
219 complete(&dev
->done
);
221 dev_dbg(dev
->device
, "isr handled");
225 /* Wait for device to be ready */
226 static int brcmstb_i2c_wait_if_busy(struct brcmstb_i2c_dev
*dev
)
228 unsigned long timeout
= jiffies
+ msecs_to_jiffies(I2C_TIMEOUT
);
230 while ((bsc_readl(dev
, iic_enable
) & BSC_IIC_EN_INTRP_MASK
)) {
231 if (time_after(jiffies
, timeout
))
238 /* i2c xfer completion function, handles both irq and polling mode */
239 static int brcmstb_i2c_wait_for_completion(struct brcmstb_i2c_dev
*dev
)
242 unsigned long timeout
= msecs_to_jiffies(I2C_TIMEOUT
);
244 if (dev
->irq
>= 0 && !dev
->atomic
) {
245 if (!wait_for_completion_timeout(&dev
->done
, timeout
))
248 /* we are in polling mode */
250 unsigned long time_left
= jiffies
+ timeout
;
253 bsc_intrp
= bsc_readl(dev
, iic_enable
) &
254 BSC_IIC_EN_INTRP_MASK
;
255 if (time_after(jiffies
, time_left
)) {
260 } while (!bsc_intrp
);
263 if (dev
->irq
< 0 || ret
== -ETIMEDOUT
)
264 brcmstb_i2c_enable_disable_irq(dev
, INT_DISABLE
);
269 /* Set xfer START/STOP conditions for subsequent transfer */
270 static void brcmstb_set_i2c_start_stop(struct brcmstb_i2c_dev
*dev
,
273 u32 regval
= dev
->bsc_regmap
->iic_enable
;
275 dev
->bsc_regmap
->iic_enable
= (regval
& ~COND_START_STOP
) | cond_flag
;
278 /* Send I2C request check completion */
279 static int brcmstb_send_i2c_cmd(struct brcmstb_i2c_dev
*dev
,
280 enum bsc_xfer_cmd cmd
)
283 struct bsc_regs
*pi2creg
= dev
->bsc_regmap
;
285 /* Make sure the hardware is ready */
286 rc
= brcmstb_i2c_wait_if_busy(dev
);
290 /* only if we are in interrupt mode */
291 if (dev
->irq
>= 0 && !dev
->atomic
)
292 reinit_completion(&dev
->done
);
294 /* enable BSC CTL interrupt line */
295 brcmstb_i2c_enable_disable_irq(dev
, INT_ENABLE
);
297 /* initiate transfer by setting iic_enable */
298 pi2creg
->iic_enable
|= BSC_IIC_EN_ENABLE_MASK
;
299 bsc_writel(dev
, pi2creg
->iic_enable
, iic_enable
);
301 /* Wait for transaction to finish or timeout */
302 rc
= brcmstb_i2c_wait_for_completion(dev
);
304 dev_dbg(dev
->device
, "intr timeout for cmd %s\n",
309 if ((cmd
== CMD_RD
|| cmd
== CMD_WR
) &&
310 bsc_readl(dev
, iic_enable
) & BSC_IIC_EN_NOACK_MASK
) {
312 dev_dbg(dev
->device
, "controller received NOACK intr for %s\n",
317 bsc_writel(dev
, 0, cnt_reg
);
318 bsc_writel(dev
, 0, iic_enable
);
323 /* Actual data transfer through the BSC controller */
324 static int brcmstb_i2c_xfer_bsc_data(struct brcmstb_i2c_dev
*dev
,
325 u8
*buf
, unsigned int len
,
326 struct i2c_msg
*pmsg
)
328 int cnt
, byte
, i
, rc
;
329 enum bsc_xfer_cmd cmd
;
331 struct bsc_regs
*pi2creg
= dev
->bsc_regmap
;
332 int no_ack
= pmsg
->flags
& I2C_M_IGNORE_NAK
;
333 int data_regsz
= brcmstb_i2c_get_data_regsz(dev
);
335 /* see if the transaction needs to check NACK conditions */
337 cmd
= (pmsg
->flags
& I2C_M_RD
) ? CMD_RD_NOACK
339 pi2creg
->ctlhi_reg
|= BSC_CTLHI_REG_IGNORE_ACK_MASK
;
341 cmd
= (pmsg
->flags
& I2C_M_RD
) ? CMD_RD
: CMD_WR
;
342 pi2creg
->ctlhi_reg
&= ~BSC_CTLHI_REG_IGNORE_ACK_MASK
;
344 bsc_writel(dev
, pi2creg
->ctlhi_reg
, ctlhi_reg
);
346 /* set data transfer direction */
347 ctl_reg
= pi2creg
->ctl_reg
& ~BSC_CTL_REG_DTF_MASK
;
348 if (cmd
== CMD_WR
|| cmd
== CMD_WR_NOACK
)
349 pi2creg
->ctl_reg
= ctl_reg
| DTF_WR_MASK
;
351 pi2creg
->ctl_reg
= ctl_reg
| DTF_RD_MASK
;
353 /* set the read/write length */
354 bsc_writel(dev
, BSC_CNT_REG1_MASK(data_regsz
) &
355 (len
<< BSC_CNT_REG1_SHIFT
), cnt_reg
);
357 /* Write data into data_in register */
359 if (cmd
== CMD_WR
|| cmd
== CMD_WR_NOACK
) {
360 for (cnt
= 0, i
= 0; cnt
< len
; cnt
+= data_regsz
, i
++) {
363 for (byte
= 0; byte
< data_regsz
; byte
++) {
364 word
>>= BITS_PER_BYTE
;
365 if ((cnt
+ byte
) < len
)
366 word
|= buf
[cnt
+ byte
] <<
367 (BITS_PER_BYTE
* (data_regsz
- 1));
369 bsc_writel(dev
, word
, data_in
[i
]);
373 /* Initiate xfer, the function will return on completion */
374 rc
= brcmstb_send_i2c_cmd(dev
, cmd
);
377 dev_dbg(dev
->device
, "%s failure", cmd_string
[cmd
]);
381 /* Read data from data_out register */
382 if (cmd
== CMD_RD
|| cmd
== CMD_RD_NOACK
) {
383 for (cnt
= 0, i
= 0; cnt
< len
; cnt
+= data_regsz
, i
++) {
384 u32 data
= bsc_readl(dev
, data_out
[i
]);
386 for (byte
= 0; byte
< data_regsz
&&
387 (byte
+ cnt
) < len
; byte
++) {
388 buf
[cnt
+ byte
] = data
& 0xff;
389 data
>>= BITS_PER_BYTE
;
397 /* Write a single byte of data to the i2c bus */
398 static int brcmstb_i2c_write_data_byte(struct brcmstb_i2c_dev
*dev
,
399 u8
*buf
, unsigned int nak_expected
)
401 enum bsc_xfer_cmd cmd
= nak_expected
? CMD_WR
: CMD_WR_NOACK
;
403 bsc_writel(dev
, 1, cnt_reg
);
404 bsc_writel(dev
, *buf
, data_in
);
406 return brcmstb_send_i2c_cmd(dev
, cmd
);
409 /* Send i2c address */
410 static int brcmstb_i2c_do_addr(struct brcmstb_i2c_dev
*dev
,
415 if (msg
->flags
& I2C_M_TEN
) {
416 /* First byte is 11110XX0 where XX is upper 2 bits */
417 addr
= 0xF0 | ((msg
->addr
& 0x300) >> 7);
418 bsc_writel(dev
, addr
, chip_address
);
420 /* Second byte is the remaining 8 bits */
421 addr
= msg
->addr
& 0xFF;
422 if (brcmstb_i2c_write_data_byte(dev
, &addr
, 0) < 0)
425 if (msg
->flags
& I2C_M_RD
) {
426 /* For read, send restart without stop condition */
427 brcmstb_set_i2c_start_stop(dev
, COND_RESTART
429 /* Then re-send the first byte with the read bit set */
430 addr
= 0xF0 | ((msg
->addr
& 0x300) >> 7) | 0x01;
431 if (brcmstb_i2c_write_data_byte(dev
, &addr
, 0) < 0)
436 addr
= i2c_8bit_addr_from_msg(msg
);
438 bsc_writel(dev
, addr
, chip_address
);
444 static int brcmstb_i2c_xfer(struct i2c_adapter
*adapter
,
445 struct i2c_msg msgs
[], int num
)
447 struct brcmstb_i2c_dev
*dev
= i2c_get_adapdata(adapter
);
448 struct i2c_msg
*pmsg
;
454 int xfersz
= brcmstb_i2c_get_xfersz(dev
);
455 u32 cond
, cond_per_msg
;
457 /* Loop through all messages */
458 for (i
= 0; i
< num
; i
++) {
464 "msg# %d/%d flg %x buf %x len %d\n", i
,
465 num
- 1, pmsg
->flags
,
466 pmsg
->buf
? pmsg
->buf
[0] : '0', pmsg
->len
);
468 if (i
< (num
- 1) && (msgs
[i
+ 1].flags
& I2C_M_NOSTART
))
469 cond
= ~COND_START_STOP
;
471 cond
= COND_RESTART
| COND_NOSTOP
;
473 brcmstb_set_i2c_start_stop(dev
, cond
);
475 /* Send target address */
476 if (!(pmsg
->flags
& I2C_M_NOSTART
)) {
477 rc
= brcmstb_i2c_do_addr(dev
, pmsg
);
480 "NACK for addr %2.2x msg#%d rc = %d\n",
488 /* Perform data transfer */
490 bytes_to_xfer
= min(len
, xfersz
);
494 cond_per_msg
= cond_per_msg
&
495 ~(COND_RESTART
| COND_NOSTOP
);
499 cond_per_msg
= (cond_per_msg
& ~COND_RESTART
) |
503 brcmstb_set_i2c_start_stop(dev
, cond_per_msg
);
505 rc
= brcmstb_i2c_xfer_bsc_data(dev
, tmp_buf
,
506 bytes_to_xfer
, pmsg
);
510 len
-= bytes_to_xfer
;
511 tmp_buf
+= bytes_to_xfer
;
513 cond_per_msg
= COND_NOSTART
| COND_NOSTOP
;
523 static int brcmstb_i2c_xfer_atomic(struct i2c_adapter
*adapter
,
524 struct i2c_msg msgs
[], int num
)
526 struct brcmstb_i2c_dev
*dev
= i2c_get_adapdata(adapter
);
530 disable_irq(dev
->irq
);
532 ret
= brcmstb_i2c_xfer(adapter
, msgs
, num
);
535 enable_irq(dev
->irq
);
540 static u32
brcmstb_i2c_functionality(struct i2c_adapter
*adap
)
542 return I2C_FUNC_I2C
| I2C_FUNC_SMBUS_EMUL
| I2C_FUNC_10BIT_ADDR
543 | I2C_FUNC_NOSTART
| I2C_FUNC_PROTOCOL_MANGLING
;
546 static const struct i2c_algorithm brcmstb_i2c_algo
= {
547 .xfer
= brcmstb_i2c_xfer
,
548 .xfer_atomic
= brcmstb_i2c_xfer_atomic
,
549 .functionality
= brcmstb_i2c_functionality
,
552 static void brcmstb_i2c_set_bus_speed(struct brcmstb_i2c_dev
*dev
)
554 int i
= 0, num_speeds
= ARRAY_SIZE(bsc_clk
);
555 u32 clk_freq_hz
= dev
->clk_freq_hz
;
557 for (i
= 0; i
< num_speeds
; i
++) {
558 if (bsc_clk
[i
].hz
== clk_freq_hz
) {
559 dev
->bsc_regmap
->ctl_reg
&= ~(BSC_CTL_REG_SCL_SEL_MASK
560 | BSC_CTL_REG_DIV_CLK_MASK
);
561 dev
->bsc_regmap
->ctl_reg
|= (bsc_clk
[i
].scl_mask
|
562 bsc_clk
[i
].div_mask
);
563 bsc_writel(dev
, dev
->bsc_regmap
->ctl_reg
, ctl_reg
);
568 /* in case we did not get find a valid speed */
569 if (i
== num_speeds
) {
570 i
= (bsc_readl(dev
, ctl_reg
) & BSC_CTL_REG_SCL_SEL_MASK
) >>
571 BSC_CTL_REG_SCL_SEL_SHIFT
;
572 dev_warn(dev
->device
, "leaving current clock-frequency @ %dHz\n",
577 static void brcmstb_i2c_set_bsc_reg_defaults(struct brcmstb_i2c_dev
*dev
)
579 if (brcmstb_i2c_get_data_regsz(dev
) == sizeof(u32
))
580 /* set 4 byte data in/out xfers */
581 dev
->bsc_regmap
->ctlhi_reg
= BSC_CTLHI_REG_DATAREG_SIZE_MASK
;
583 dev
->bsc_regmap
->ctlhi_reg
&= ~BSC_CTLHI_REG_DATAREG_SIZE_MASK
;
585 bsc_writel(dev
, dev
->bsc_regmap
->ctlhi_reg
, ctlhi_reg
);
587 brcmstb_i2c_set_bus_speed(dev
);
590 #define AUTOI2C_CTRL0 0x26c
591 #define AUTOI2C_CTRL0_RELEASE_BSC BIT(1)
593 static int bcm2711_release_bsc(struct brcmstb_i2c_dev
*dev
)
595 struct platform_device
*pdev
= to_platform_device(dev
->device
);
596 void __iomem
*autoi2c
;
598 /* Map hardware registers */
599 autoi2c
= devm_platform_ioremap_resource_byname(pdev
, "auto-i2c");
601 return PTR_ERR(autoi2c
);
603 writel(AUTOI2C_CTRL0_RELEASE_BSC
, autoi2c
+ AUTOI2C_CTRL0
);
604 devm_iounmap(&pdev
->dev
, autoi2c
);
606 /* We need to reset the controller after the release */
607 dev
->bsc_regmap
->iic_enable
= 0;
608 bsc_writel(dev
, dev
->bsc_regmap
->iic_enable
, iic_enable
);
613 static int brcmstb_i2c_probe(struct platform_device
*pdev
)
615 struct brcmstb_i2c_dev
*dev
;
616 struct i2c_adapter
*adap
;
617 const char *int_name
;
620 /* Allocate memory for private data structure */
621 dev
= devm_kzalloc(&pdev
->dev
, sizeof(*dev
), GFP_KERNEL
);
625 dev
->bsc_regmap
= devm_kzalloc(&pdev
->dev
, sizeof(*dev
->bsc_regmap
), GFP_KERNEL
);
626 if (!dev
->bsc_regmap
)
629 platform_set_drvdata(pdev
, dev
);
630 dev
->device
= &pdev
->dev
;
631 init_completion(&dev
->done
);
633 /* Map hardware registers */
634 dev
->base
= devm_platform_ioremap_resource(pdev
, 0);
635 if (IS_ERR(dev
->base
))
636 return PTR_ERR(dev
->base
);
638 if (of_device_is_compatible(dev
->device
->of_node
,
639 "brcm,bcm2711-hdmi-i2c")) {
640 rc
= bcm2711_release_bsc(dev
);
645 rc
= of_property_read_string(dev
->device
->of_node
, "interrupt-names",
650 /* Get the interrupt number */
651 dev
->irq
= platform_get_irq_optional(pdev
, 0);
653 /* disable the bsc interrupt line */
654 brcmstb_i2c_enable_disable_irq(dev
, INT_DISABLE
);
656 /* register the ISR handler */
658 rc
= devm_request_irq(&pdev
->dev
, dev
->irq
, brcmstb_i2c_isr
,
660 int_name
? int_name
: pdev
->name
,
664 dev_dbg(dev
->device
, "falling back to polling mode");
669 if (of_property_read_u32(dev
->device
->of_node
,
670 "clock-frequency", &dev
->clk_freq_hz
)) {
671 dev_warn(dev
->device
, "setting clock-frequency@%dHz\n",
673 dev
->clk_freq_hz
= bsc_clk
[0].hz
;
676 /* set the data in/out register size for compatible SoCs */
677 if (of_device_is_compatible(dev
->device
->of_node
,
679 dev
->data_regsz
= sizeof(u8
);
681 dev
->data_regsz
= sizeof(u32
);
683 brcmstb_i2c_set_bsc_reg_defaults(dev
);
685 /* Add the i2c adapter */
686 adap
= &dev
->adapter
;
687 i2c_set_adapdata(adap
, dev
);
688 adap
->owner
= THIS_MODULE
;
689 strscpy(adap
->name
, dev_name(&pdev
->dev
), sizeof(adap
->name
));
690 adap
->algo
= &brcmstb_i2c_algo
;
691 adap
->dev
.parent
= &pdev
->dev
;
692 adap
->dev
.of_node
= pdev
->dev
.of_node
;
693 rc
= i2c_add_adapter(adap
);
697 dev_info(dev
->device
, "%s@%dhz registered in %s mode\n",
698 int_name
? int_name
: " ", dev
->clk_freq_hz
,
699 (dev
->irq
>= 0) ? "interrupt" : "polling");
704 static void brcmstb_i2c_remove(struct platform_device
*pdev
)
706 struct brcmstb_i2c_dev
*dev
= platform_get_drvdata(pdev
);
708 i2c_del_adapter(&dev
->adapter
);
711 static int brcmstb_i2c_suspend(struct device
*dev
)
713 struct brcmstb_i2c_dev
*i2c_dev
= dev_get_drvdata(dev
);
715 i2c_mark_adapter_suspended(&i2c_dev
->adapter
);
719 static int brcmstb_i2c_resume(struct device
*dev
)
721 struct brcmstb_i2c_dev
*i2c_dev
= dev_get_drvdata(dev
);
723 brcmstb_i2c_set_bsc_reg_defaults(i2c_dev
);
724 i2c_mark_adapter_resumed(&i2c_dev
->adapter
);
729 static DEFINE_SIMPLE_DEV_PM_OPS(brcmstb_i2c_pm
, brcmstb_i2c_suspend
,
732 static const struct of_device_id brcmstb_i2c_of_match
[] = {
733 {.compatible
= "brcm,brcmstb-i2c"},
734 {.compatible
= "brcm,brcmper-i2c"},
735 {.compatible
= "brcm,bcm2711-hdmi-i2c"},
738 MODULE_DEVICE_TABLE(of
, brcmstb_i2c_of_match
);
740 static struct platform_driver brcmstb_i2c_driver
= {
742 .name
= "brcmstb-i2c",
743 .of_match_table
= brcmstb_i2c_of_match
,
744 .pm
= pm_sleep_ptr(&brcmstb_i2c_pm
),
746 .probe
= brcmstb_i2c_probe
,
747 .remove
= brcmstb_i2c_remove
,
749 module_platform_driver(brcmstb_i2c_driver
);
751 MODULE_AUTHOR("Kamal Dasu <kdasu@broadcom.com>");
752 MODULE_DESCRIPTION("Broadcom Settop I2C Driver");
753 MODULE_LICENSE("GPL v2");