Skip to content

Commit 5d1765a

Browse files
committed
Merge tag 'i2c-for-6.19-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c fixes from Wolfram Sang: - riic, imx-lpi2c: suspend/resume fixes - qcom-geni: DMA handling fix - iproc: correct DT binding description * tag 'i2c-for-6.19-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: i2c: imx-lpi2c: change to PIO mode in system-wide suspend/resume progress i2c: qcom-geni: make sure I2C hub controllers can't use SE DMA i2c: riic: Move suspend handling to NOIRQ phase dt-bindings: i2c: brcm,iproc-i2c: Allow 2 reg entries for brcm,iproc-nic-i2c
2 parents 93fc4e0 + f2a3f51 commit 5d1765a

4 files changed

Lines changed: 62 additions & 12 deletions

File tree

Documentation/devicetree/bindings/i2c/brcm,iproc-i2c.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ properties:
1616
- brcm,iproc-nic-i2c
1717

1818
reg:
19-
maxItems: 1
19+
minItems: 1
20+
maxItems: 2
2021

2122
clock-frequency:
2223
enum: [ 100000, 400000 ]
@@ -41,8 +42,15 @@ allOf:
4142
contains:
4243
const: brcm,iproc-nic-i2c
4344
then:
45+
properties:
46+
reg:
47+
minItems: 2
4448
required:
4549
- brcm,ape-hsls-addr-mask
50+
else:
51+
properties:
52+
reg:
53+
maxItems: 1
4654

4755
unevaluatedProperties: false
4856

drivers/i2c/busses/i2c-imx-lpi2c.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,13 @@ static bool is_use_dma(struct lpi2c_imx_struct *lpi2c_imx, struct i2c_msg *msg)
592592
if (!lpi2c_imx->can_use_dma)
593593
return false;
594594

595+
/*
596+
* A system-wide suspend or resume transition is in progress. LPI2C should use PIO to
597+
* transfer data to avoid issue caused by no ready DMA HW resource.
598+
*/
599+
if (pm_suspend_in_progress())
600+
return false;
601+
595602
/*
596603
* When the length of data is less than I2C_DMA_THRESHOLD,
597604
* cpu mode is used directly to avoid low performance.

drivers/i2c/busses/i2c-qcom-geni.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ struct geni_i2c_dev {
116116
dma_addr_t dma_addr;
117117
struct dma_chan *tx_c;
118118
struct dma_chan *rx_c;
119+
bool no_dma;
119120
bool gpi_mode;
120121
bool abort_done;
121122
bool is_tx_multi_desc_xfer;
@@ -447,7 +448,7 @@ static int geni_i2c_rx_one_msg(struct geni_i2c_dev *gi2c, struct i2c_msg *msg,
447448
size_t len = msg->len;
448449
struct i2c_msg *cur;
449450

450-
dma_buf = i2c_get_dma_safe_msg_buf(msg, 32);
451+
dma_buf = gi2c->no_dma ? NULL : i2c_get_dma_safe_msg_buf(msg, 32);
451452
if (dma_buf)
452453
geni_se_select_mode(se, GENI_SE_DMA);
453454
else
@@ -486,7 +487,7 @@ static int geni_i2c_tx_one_msg(struct geni_i2c_dev *gi2c, struct i2c_msg *msg,
486487
size_t len = msg->len;
487488
struct i2c_msg *cur;
488489

489-
dma_buf = i2c_get_dma_safe_msg_buf(msg, 32);
490+
dma_buf = gi2c->no_dma ? NULL : i2c_get_dma_safe_msg_buf(msg, 32);
490491
if (dma_buf)
491492
geni_se_select_mode(se, GENI_SE_DMA);
492493
else
@@ -1080,10 +1081,12 @@ static int geni_i2c_probe(struct platform_device *pdev)
10801081
goto err_resources;
10811082
}
10821083

1083-
if (desc && desc->no_dma_support)
1084+
if (desc && desc->no_dma_support) {
10841085
fifo_disable = false;
1085-
else
1086+
gi2c->no_dma = true;
1087+
} else {
10861088
fifo_disable = readl_relaxed(gi2c->se.base + GENI_IF_DISABLE_RO) & FIFO_IF_DISABLE;
1089+
}
10871090

10881091
if (fifo_disable) {
10891092
/* FIFO is disabled, so we can only use GPI DMA */

drivers/i2c/busses/i2c-riic.c

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -670,25 +670,52 @@ static const struct riic_of_data riic_rz_t2h_info = {
670670

671671
static int riic_i2c_suspend(struct device *dev)
672672
{
673-
struct riic_dev *riic = dev_get_drvdata(dev);
674-
int ret;
673+
/*
674+
* Some I2C devices may need the I2C controller to remain active
675+
* during resume_noirq() or suspend_noirq(). If the controller is
676+
* autosuspended, there is no way to wake it up once runtime PM is
677+
* disabled (in suspend_late()).
678+
*
679+
* During system resume, the I2C controller will be available only
680+
* after runtime PM is re-enabled (in resume_early()). However, this
681+
* may be too late for some devices.
682+
*
683+
* Wake up the controller in the suspend() callback while runtime PM
684+
* is still enabled. The I2C controller will remain available until
685+
* the suspend_noirq() callback (pm_runtime_force_suspend()) is
686+
* called. During resume, the I2C controller can be restored by the
687+
* resume_noirq() callback (pm_runtime_force_resume()).
688+
*
689+
* Finally, the resume() callback re-enables autosuspend, ensuring
690+
* the I2C controller remains available until the system enters
691+
* suspend_noirq() and from resume_noirq().
692+
*/
693+
return pm_runtime_resume_and_get(dev);
694+
}
675695

676-
ret = pm_runtime_resume_and_get(dev);
677-
if (ret)
678-
return ret;
696+
static int riic_i2c_resume(struct device *dev)
697+
{
698+
pm_runtime_put_autosuspend(dev);
699+
700+
return 0;
701+
}
702+
703+
static int riic_i2c_suspend_noirq(struct device *dev)
704+
{
705+
struct riic_dev *riic = dev_get_drvdata(dev);
679706

680707
i2c_mark_adapter_suspended(&riic->adapter);
681708

682709
/* Disable output on SDA, SCL pins. */
683710
riic_clear_set_bit(riic, ICCR1_ICE, 0, RIIC_ICCR1);
684711

685712
pm_runtime_mark_last_busy(dev);
686-
pm_runtime_put_sync(dev);
713+
pm_runtime_force_suspend(dev);
687714

688715
return reset_control_assert(riic->rstc);
689716
}
690717

691-
static int riic_i2c_resume(struct device *dev)
718+
static int riic_i2c_resume_noirq(struct device *dev)
692719
{
693720
struct riic_dev *riic = dev_get_drvdata(dev);
694721
int ret;
@@ -697,6 +724,10 @@ static int riic_i2c_resume(struct device *dev)
697724
if (ret)
698725
return ret;
699726

727+
ret = pm_runtime_force_resume(dev);
728+
if (ret)
729+
return ret;
730+
700731
ret = riic_init_hw(riic);
701732
if (ret) {
702733
/*
@@ -714,6 +745,7 @@ static int riic_i2c_resume(struct device *dev)
714745
}
715746

716747
static const struct dev_pm_ops riic_i2c_pm_ops = {
748+
NOIRQ_SYSTEM_SLEEP_PM_OPS(riic_i2c_suspend_noirq, riic_i2c_resume_noirq)
717749
SYSTEM_SLEEP_PM_OPS(riic_i2c_suspend, riic_i2c_resume)
718750
};
719751

0 commit comments

Comments
 (0)