From: Akhil R <akhilrajeev@nvidia.com>
To: <robh+dt@kernel.org>, <devicetree@vger.kernel.org>,
<christian.koenig@amd.com>, <digetx@gmail.com>,
<=jonathanh@nvidia.com>, <ldewangan@nvidia.com>,
<linux-i2c@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-tegra@vger.kernel.org>, <sumit.semwal@linaro.org>,
<thierry.reding@gmail.com>, <wsa@kernel.org>
Cc: <akhilrajeev@nvidia.com>
Subject: [PATCH RESEND 1/2] i2c: tegra: Add GPCDMA support
Date: Fri, 19 Aug 2022 17:53:12 +0530 [thread overview]
Message-ID: <20220819122313.40445-2-akhilrajeev@nvidia.com> (raw)
In-Reply-To: <20220819122313.40445-1-akhilrajeev@nvidia.com>
Update the DMA initialization and checks to support GPCDMA.
Also add a mechanism to fall back to PIO mode, if DMA is
not available or if initialization returns error.
Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
---
drivers/i2c/busses/i2c-tegra.c | 39 ++++++++++++++++------------------
1 file changed, 18 insertions(+), 21 deletions(-)
diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index 031c78ac42e6..8c4610c78b54 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -188,7 +188,6 @@ enum msg_end_type {
* allowing 0 length transfers.
* @supports_bus_clear: Bus Clear support to recover from bus hang during
* SDA stuck low from device for some unknown reasons.
- * @has_apb_dma: Support of APBDMA on corresponding Tegra chip.
* @tlow_std_mode: Low period of the clock in standard mode.
* @thigh_std_mode: High period of the clock in standard mode.
* @tlow_fast_fastplus_mode: Low period of the clock in fast/fast-plus modes.
@@ -215,7 +214,6 @@ struct tegra_i2c_hw_feature {
bool has_mst_fifo;
const struct i2c_adapter_quirks *quirks;
bool supports_bus_clear;
- bool has_apb_dma;
u32 tlow_std_mode;
u32 thigh_std_mode;
u32 tlow_fast_fastplus_mode;
@@ -253,6 +251,7 @@ struct tegra_i2c_hw_feature {
* @dma_phys: handle to DMA resources
* @dma_buf: pointer to allocated DMA buffer
* @dma_buf_size: DMA buffer size
+ * @dma_support: indicates if DMA can be enabled
* @dma_mode: indicates active DMA transfer
* @dma_complete: DMA completion notifier
* @atomic_mode: indicates active atomic transfer
@@ -289,6 +288,7 @@ struct tegra_i2c_dev {
bool multimaster_mode;
bool atomic_mode;
+ bool dma_support;
bool dma_mode;
bool msg_read;
bool is_dvc;
@@ -443,13 +443,8 @@ static int tegra_i2c_init_dma(struct tegra_i2c_dev *i2c_dev)
u32 *dma_buf;
int err;
- if (!i2c_dev->hw->has_apb_dma || i2c_dev->is_vi)
- return 0;
-
- if (!IS_ENABLED(CONFIG_TEGRA20_APB_DMA)) {
- dev_dbg(i2c_dev->dev, "DMA support not enabled\n");
- return 0;
- }
+ if (!i2c_dev->dma_support)
+ return -EOPNOTSUPP;
chan = dma_request_chan(i2c_dev->dev, "rx");
if (IS_ERR(chan)) {
@@ -486,6 +481,7 @@ static int tegra_i2c_init_dma(struct tegra_i2c_dev *i2c_dev)
err_out:
tegra_i2c_release_dma(i2c_dev);
if (err != -EPROBE_DEFER) {
+ i2c_dev->dma_support = false;
dev_err(i2c_dev->dev, "cannot use DMA: %d\n", err);
dev_err(i2c_dev->dev, "falling back to PIO\n");
return 0;
@@ -1251,7 +1247,16 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
xfer_size = ALIGN(xfer_size, BYTES_PER_FIFO_WORD);
i2c_dev->dma_mode = xfer_size > I2C_PIO_MODE_PREFERRED_LEN &&
- i2c_dev->dma_buf && !i2c_dev->atomic_mode;
+ i2c_dev->dma_support && !i2c_dev->atomic_mode;
+
+ /* If DMA is not initialized, initialize it now.
+ * Fall back to PIO mode, if it fails.
+ */
+ if (i2c_dev->dma_mode && !i2c_dev->dma_buf) {
+ err = tegra_i2c_init_dma(i2c_dev);
+ if (err)
+ i2c_dev->dma_mode = false;
+ }
tegra_i2c_config_fifo_trig(i2c_dev, xfer_size);
@@ -1473,7 +1478,6 @@ static const struct tegra_i2c_hw_feature tegra20_i2c_hw = {
.has_mst_fifo = false,
.quirks = &tegra_i2c_quirks,
.supports_bus_clear = false,
- .has_apb_dma = true,
.tlow_std_mode = 0x4,
.thigh_std_mode = 0x2,
.tlow_fast_fastplus_mode = 0x4,
@@ -1497,7 +1501,6 @@ static const struct tegra_i2c_hw_feature tegra30_i2c_hw = {
.has_mst_fifo = false,
.quirks = &tegra_i2c_quirks,
.supports_bus_clear = false,
- .has_apb_dma = true,
.tlow_std_mode = 0x4,
.thigh_std_mode = 0x2,
.tlow_fast_fastplus_mode = 0x4,
@@ -1521,7 +1524,6 @@ static const struct tegra_i2c_hw_feature tegra114_i2c_hw = {
.has_mst_fifo = false,
.quirks = &tegra_i2c_quirks,
.supports_bus_clear = true,
- .has_apb_dma = true,
.tlow_std_mode = 0x4,
.thigh_std_mode = 0x2,
.tlow_fast_fastplus_mode = 0x4,
@@ -1545,7 +1547,6 @@ static const struct tegra_i2c_hw_feature tegra124_i2c_hw = {
.has_mst_fifo = false,
.quirks = &tegra_i2c_quirks,
.supports_bus_clear = true,
- .has_apb_dma = true,
.tlow_std_mode = 0x4,
.thigh_std_mode = 0x2,
.tlow_fast_fastplus_mode = 0x4,
@@ -1569,7 +1570,6 @@ static const struct tegra_i2c_hw_feature tegra210_i2c_hw = {
.has_mst_fifo = false,
.quirks = &tegra_i2c_quirks,
.supports_bus_clear = true,
- .has_apb_dma = true,
.tlow_std_mode = 0x4,
.thigh_std_mode = 0x2,
.tlow_fast_fastplus_mode = 0x4,
@@ -1593,7 +1593,6 @@ static const struct tegra_i2c_hw_feature tegra186_i2c_hw = {
.has_mst_fifo = false,
.quirks = &tegra_i2c_quirks,
.supports_bus_clear = true,
- .has_apb_dma = false,
.tlow_std_mode = 0x4,
.thigh_std_mode = 0x3,
.tlow_fast_fastplus_mode = 0x4,
@@ -1617,7 +1616,6 @@ static const struct tegra_i2c_hw_feature tegra194_i2c_hw = {
.has_mst_fifo = true,
.quirks = &tegra194_i2c_quirks,
.supports_bus_clear = true,
- .has_apb_dma = false,
.tlow_std_mode = 0x8,
.thigh_std_mode = 0x7,
.tlow_fast_fastplus_mode = 0x2,
@@ -1657,6 +1655,8 @@ static void tegra_i2c_parse_dt(struct tegra_i2c_dev *i2c_dev)
if (of_device_is_compatible(np, "nvidia,tegra210-i2c-vi"))
i2c_dev->is_vi = true;
+ else
+ i2c_dev->dma_support = !!(of_find_property(np, "dmas", NULL));
}
static int tegra_i2c_init_reset(struct tegra_i2c_dev *i2c_dev)
@@ -1789,9 +1789,7 @@ static int tegra_i2c_probe(struct platform_device *pdev)
if (err)
return err;
- err = tegra_i2c_init_dma(i2c_dev);
- if (err)
- goto release_clocks;
+ tegra_i2c_init_dma(i2c_dev);
/*
* VI I2C is in VE power domain which is not always ON and not
@@ -1838,7 +1836,6 @@ static int tegra_i2c_probe(struct platform_device *pdev)
pm_runtime_disable(i2c_dev->dev);
tegra_i2c_release_dma(i2c_dev);
-release_clocks:
tegra_i2c_release_clocks(i2c_dev);
return err;
--
2.17.1
next prev parent reply other threads:[~2022-08-19 12:23 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-19 12:23 [PATCH RESEND 0/2] Add GPCDMA support to Tegra234 I2C Akhil R
2022-08-19 12:23 ` Akhil R [this message]
2022-08-19 15:15 ` [PATCH RESEND 1/2] i2c: tegra: Add GPCDMA support Dmitry Osipenko
2022-08-19 15:27 ` Dmitry Osipenko
2022-08-22 6:56 ` Akhil R
2022-08-22 9:45 ` Dmitry Osipenko
2022-08-22 10:29 ` Akhil R
2022-08-22 20:33 ` Dmitry Osipenko
2022-08-22 21:08 ` Dmitry Osipenko
2022-08-23 5:17 ` Akhil R
2022-08-23 8:39 ` Dmitry Osipenko
2022-08-23 8:45 ` Dmitry Osipenko
2022-08-23 12:55 ` Akhil R
2022-08-23 13:32 ` Dmitry Osipenko
2022-08-25 16:41 ` Akhil R
2022-09-01 14:40 ` Thierry Reding
2022-09-02 11:25 ` Dmitry Osipenko
2022-08-19 12:23 ` [PATCH RESEND 2/2] arm64: tegra: Add GPCDMA support for Tegra234 I2C Akhil R
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220819122313.40445-2-akhilrajeev@nvidia.com \
--to=akhilrajeev@nvidia.com \
--cc==jonathanh@nvidia.com \
--cc=christian.koenig@amd.com \
--cc=devicetree@vger.kernel.org \
--cc=digetx@gmail.com \
--cc=ldewangan@nvidia.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=sumit.semwal@linaro.org \
--cc=thierry.reding@gmail.com \
--cc=wsa@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.