hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/drivers/i2c/busses/i2c-brcmstb.c
....@@ -165,12 +165,10 @@
165165 struct brcmstb_i2c_dev {
166166 struct device *device;
167167 void __iomem *base;
168
- void __iomem *irq_base;
169168 int irq;
170169 struct bsc_regs *bsc_regmap;
171170 struct i2c_adapter adapter;
172171 struct completion done;
173
- bool is_suspended;
174172 u32 clk_freq_hz;
175173 int data_regsz;
176174 };
....@@ -467,9 +465,6 @@
467465 int xfersz = brcmstb_i2c_get_xfersz(dev);
468466 u32 cond, cond_per_msg;
469467
470
- if (dev->is_suspended)
471
- return -EBUSY;
472
-
473468 /* Loop through all messages */
474469 for (i = 0; i < num; i++) {
475470 pmsg = &msgs[i];
....@@ -585,6 +580,31 @@
585580 brcmstb_i2c_set_bus_speed(dev);
586581 }
587582
583
+#define AUTOI2C_CTRL0 0x26c
584
+#define AUTOI2C_CTRL0_RELEASE_BSC BIT(1)
585
+
586
+static int bcm2711_release_bsc(struct brcmstb_i2c_dev *dev)
587
+{
588
+ struct platform_device *pdev = to_platform_device(dev->device);
589
+ struct resource *iomem;
590
+ void __iomem *autoi2c;
591
+
592
+ /* Map hardware registers */
593
+ iomem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "auto-i2c");
594
+ autoi2c = devm_ioremap_resource(&pdev->dev, iomem);
595
+ if (IS_ERR(autoi2c))
596
+ return PTR_ERR(autoi2c);
597
+
598
+ writel(AUTOI2C_CTRL0_RELEASE_BSC, autoi2c + AUTOI2C_CTRL0);
599
+ devm_iounmap(&pdev->dev, autoi2c);
600
+
601
+ /* We need to reset the controller after the release */
602
+ dev->bsc_regmap->iic_enable = 0;
603
+ bsc_writel(dev, dev->bsc_regmap->iic_enable, iic_enable);
604
+
605
+ return 0;
606
+}
607
+
588608 static int brcmstb_i2c_probe(struct platform_device *pdev)
589609 {
590610 int rc = 0;
....@@ -614,26 +634,35 @@
614634 goto probe_errorout;
615635 }
616636
637
+ if (of_device_is_compatible(dev->device->of_node,
638
+ "brcm,bcm2711-hdmi-i2c")) {
639
+ rc = bcm2711_release_bsc(dev);
640
+ if (rc)
641
+ goto probe_errorout;
642
+ }
643
+
617644 rc = of_property_read_string(dev->device->of_node, "interrupt-names",
618645 &int_name);
619646 if (rc < 0)
620647 int_name = NULL;
621648
622649 /* Get the interrupt number */
623
- dev->irq = platform_get_irq(pdev, 0);
650
+ dev->irq = platform_get_irq_optional(pdev, 0);
624651
625652 /* disable the bsc interrupt line */
626653 brcmstb_i2c_enable_disable_irq(dev, INT_DISABLE);
627654
628655 /* register the ISR handler */
629
- rc = devm_request_irq(&pdev->dev, dev->irq, brcmstb_i2c_isr,
630
- IRQF_SHARED,
631
- int_name ? int_name : pdev->name,
632
- dev);
656
+ if (dev->irq >= 0) {
657
+ rc = devm_request_irq(&pdev->dev, dev->irq, brcmstb_i2c_isr,
658
+ IRQF_SHARED,
659
+ int_name ? int_name : pdev->name,
660
+ dev);
633661
634
- if (rc) {
635
- dev_dbg(dev->device, "falling back to polling mode");
636
- dev->irq = -1;
662
+ if (rc) {
663
+ dev_dbg(dev->device, "falling back to polling mode");
664
+ dev->irq = -1;
665
+ }
637666 }
638667
639668 if (of_property_read_u32(dev->device->of_node,
....@@ -689,10 +718,7 @@
689718 {
690719 struct brcmstb_i2c_dev *i2c_dev = dev_get_drvdata(dev);
691720
692
- i2c_lock_bus(&i2c_dev->adapter, I2C_LOCK_ROOT_ADAPTER);
693
- i2c_dev->is_suspended = true;
694
- i2c_unlock_bus(&i2c_dev->adapter, I2C_LOCK_ROOT_ADAPTER);
695
-
721
+ i2c_mark_adapter_suspended(&i2c_dev->adapter);
696722 return 0;
697723 }
698724
....@@ -700,10 +726,8 @@
700726 {
701727 struct brcmstb_i2c_dev *i2c_dev = dev_get_drvdata(dev);
702728
703
- i2c_lock_bus(&i2c_dev->adapter, I2C_LOCK_ROOT_ADAPTER);
704729 brcmstb_i2c_set_bsc_reg_defaults(i2c_dev);
705
- i2c_dev->is_suspended = false;
706
- i2c_unlock_bus(&i2c_dev->adapter, I2C_LOCK_ROOT_ADAPTER);
730
+ i2c_mark_adapter_resumed(&i2c_dev->adapter);
707731
708732 return 0;
709733 }
....@@ -715,6 +739,7 @@
715739 static const struct of_device_id brcmstb_i2c_of_match[] = {
716740 {.compatible = "brcm,brcmstb-i2c"},
717741 {.compatible = "brcm,brcmper-i2c"},
742
+ {.compatible = "brcm,bcm2711-hdmi-i2c"},
718743 {},
719744 };
720745 MODULE_DEVICE_TABLE(of, brcmstb_i2c_of_match);