Skip to content

Commit c206085

Browse files
Marek Vasutbebarino
authored andcommitted
clk: fsl-sai: Add i.MX8M support with 8 byte register offset
The i.MX8M/Mini/Nano/Plus variant of the SAI IP has control registers shifted by +8 bytes and requires additional bus clock. Add support for the i.MX8M variant of the IP with this register shift and additional clock. Reviewed-by: Brian Masney <bmasney@redhat.com> Reviewed-by: Peng Fan <peng.fan@nxp.com> Signed-off-by: Marek Vasut <marex@nabladev.com> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent d0a4d58 commit c206085

2 files changed

Lines changed: 25 additions & 5 deletions

File tree

drivers/clk/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ config COMMON_CLK_FSL_FLEXSPI
255255

256256
config COMMON_CLK_FSL_SAI
257257
bool "Clock driver for BCLK of Freescale SAI cores"
258-
depends on ARCH_LAYERSCAPE || COMPILE_TEST
258+
depends on ARCH_LAYERSCAPE || ARCH_MXC || COMPILE_TEST
259259
help
260260
This driver supports the Freescale SAI (Synchronous Audio Interface)
261261
to be used as a generic clock output. Some SoCs have restrictions

drivers/clk/clk-fsl-sai.c

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
#include <linux/clk-provider.h>
9+
#include <linux/clk.h>
910
#include <linux/err.h>
1011
#include <linux/module.h>
1112
#include <linux/of.h>
@@ -20,6 +21,10 @@
2021
#define CR2_DIV_SHIFT 0
2122
#define CR2_DIV_WIDTH 8
2223

24+
struct fsl_sai_data {
25+
unsigned int offset; /* Register offset */
26+
};
27+
2328
struct fsl_sai_clk {
2429
struct clk_divider div;
2530
struct clk_gate gate;
@@ -29,8 +34,10 @@ struct fsl_sai_clk {
2934
static int fsl_sai_clk_probe(struct platform_device *pdev)
3035
{
3136
struct device *dev = &pdev->dev;
37+
const struct fsl_sai_data *data = device_get_match_data(dev);
3238
struct fsl_sai_clk *sai_clk;
3339
struct clk_parent_data pdata = { .index = 0 };
40+
struct clk *clk_bus;
3441
void __iomem *base;
3542
struct clk_hw *hw;
3643

@@ -42,19 +49,23 @@ static int fsl_sai_clk_probe(struct platform_device *pdev)
4249
if (IS_ERR(base))
4350
return PTR_ERR(base);
4451

52+
clk_bus = devm_clk_get_optional_enabled(dev, "bus");
53+
if (IS_ERR(clk_bus))
54+
return PTR_ERR(clk_bus);
55+
4556
spin_lock_init(&sai_clk->lock);
4657

47-
sai_clk->gate.reg = base + I2S_CSR;
58+
sai_clk->gate.reg = base + data->offset + I2S_CSR;
4859
sai_clk->gate.bit_idx = CSR_BCE_BIT;
4960
sai_clk->gate.lock = &sai_clk->lock;
5061

51-
sai_clk->div.reg = base + I2S_CR2;
62+
sai_clk->div.reg = base + data->offset + I2S_CR2;
5263
sai_clk->div.shift = CR2_DIV_SHIFT;
5364
sai_clk->div.width = CR2_DIV_WIDTH;
5465
sai_clk->div.lock = &sai_clk->lock;
5566

5667
/* set clock direction, we are the BCLK master */
57-
writel(CR2_BCD, base + I2S_CR2);
68+
writel(CR2_BCD, base + data->offset + I2S_CR2);
5869

5970
hw = devm_clk_hw_register_composite_pdata(dev, dev->of_node->name,
6071
&pdata, 1, NULL, NULL,
@@ -69,8 +80,17 @@ static int fsl_sai_clk_probe(struct platform_device *pdev)
6980
return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, hw);
7081
}
7182

83+
static const struct fsl_sai_data fsl_sai_vf610_data = {
84+
.offset = 0,
85+
};
86+
87+
static const struct fsl_sai_data fsl_sai_imx8mq_data = {
88+
.offset = 8,
89+
};
90+
7291
static const struct of_device_id of_fsl_sai_clk_ids[] = {
73-
{ .compatible = "fsl,vf610-sai-clock" },
92+
{ .compatible = "fsl,vf610-sai-clock", .data = &fsl_sai_vf610_data },
93+
{ .compatible = "fsl,imx8mq-sai-clock", .data = &fsl_sai_imx8mq_data },
7494
{ }
7595
};
7696
MODULE_DEVICE_TABLE(of, of_fsl_sai_clk_ids);

0 commit comments

Comments
 (0)