RE: [PATCH v2] clk: imx8mm: Switch to platform driver
From: Peng Fan
Date: Mon Mar 16 2020 - 23:56:55 EST
> Subject: Re: [PATCH v2] clk: imx8mm: Switch to platform driver
>
> On 06.02.20 11:37, Frieder Schrempf wrote:
> > On 06.02.20 11:34, Schrempf Frieder wrote:
> >> Hi,
> >>
> >> On 09.07.19 16:20, Abel Vesa wrote:
> >>> There is no strong reason for this to use CLK_OF_DECLARE instead of
> >>> being a platform driver. Plus, this will now be aligned with the
> >>> other i.MX8M clock drivers which are platform drivers.
> >>>
> >>> In order to make the clock provider a platform driver all the data
> >>> and code needs to be outside of .init section.
> >>>
> >>> Signed-off-by: Abel Vesa <abel.vesa@xxxxxxx>
> >>> Acked-by: Stephen Boyd <sboyd@xxxxxxxxxx>
> >>
> >> This has been upstream for quite some time now, but somehow I have an
> >> issue with SPI on the i.MX8MM that gets resolved when I revert this
> >> patch.
> >>
> >> When I try to probe an SPI NOR flash with latest 5.4 or even 5.5:
> >>
> >> ÂÂÂÂspi_imx 30820000.spi: dma setup error -19, use pio
> >> ÂÂÂÂspi-nor spi0.0: unrecognized JEDEC id bytes: 00 00 00 00 00 00
> >> ÂÂÂÂspi_imx 30820000.spi: probed
> >>
> >> When I revert this patch:
> >>
> >> ÂÂÂÂspi_imx 30820000.spi: dma setup error -19, use pio
> >> ÂÂÂÂspi-nor spi0.0: mx25r1635f (2048 Kbytes)
> >> ÂÂÂÂspi_imx 30820000.spi: probed
> >>
> >> Please note, that in both cases I have disabled DMA, as this causes
> >> even more trouble (see [1]). But even with DMA enabled and ignoring
> >> the DMA errors, the issue described above occurs.
> >>
> >> Does someone have an idea what's wrong?
> >> Am I the only user of SPI on i.MX8MM as this issue seems to exist
> >> upstream since v5.4-rc1?
>
> This issue still persists in v5.6-rc6. Can someone please have a look?
Would you post your full boot log somewhere?
With success/fail case, are there any differences in spi controller registers?
I suppose no.
Did you measure the signal saying data in when cs is low?
Anyway it is a bit wired since this patch just delayed the probe for a while.
Regards,
Peng.
>
> Thanks,
> Frieder
>
> >
> > Sorry forgot the link:
> >
> > [1]:
> > https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore
> > .kernel.org%2Fpatchwork%2Fpatch%2F1086459%2F&data=02%7C01%
> 7Cpeng.f
> >
> an%40nxp.com%7C2317765357144c4b8a7e08d7c9ad2e7e%7C686ea1d3bc2
> b4c6fa92c
> >
> d99c5c301635%7C0%7C0%7C637199617967685983&sdata=p2zTgZph6
> %2F6ULb%2
> > F8ACJv4x0%2Bov09ZtLLbvoadhsRiI8%3D&reserved=0
> >
> >>
> >>> ---
> >>>
> >>> Changes since v1:
> >>> ÂÂ * Switched to platform driver memory mapping API
> >>> ÂÂ * Removed extra newline
> >>> ÂÂ * Added an explanation of why this change is done
> >>> ÂÂÂÂ in the commit message
> >>>
> >>> ÂÂ drivers/clk/imx/clk-imx8mm.c | 57
> >>> ++++++++++++++++++++++++++++----------------
> >>> ÂÂ 1 file changed, 36 insertions(+), 21 deletions(-)
> >>>
> >>> diff --git a/drivers/clk/imx/clk-imx8mm.c
> >>> b/drivers/clk/imx/clk-imx8mm.c index 6b8e75d..7a8e713 100644
> >>> --- a/drivers/clk/imx/clk-imx8mm.c
> >>> +++ b/drivers/clk/imx/clk-imx8mm.c
> >>> @@ -68,43 +68,43 @@ static const struct imx_pll14xx_rate_table
> >>> imx8mm_drampll_tbl[] = {
> >>> ÂÂÂÂÂÂ PLL_1443X_RATE(650000000U, 325, 3, 2, 0),
> >>> ÂÂ };
> >>> -static struct imx_pll14xx_clk imx8mm_audio_pll __initdata = {
> >>> +static struct imx_pll14xx_clk imx8mm_audio_pll = {
> >>> ÂÂÂÂÂÂÂÂÂÂ .type = PLL_1443X,
> >>> ÂÂÂÂÂÂÂÂÂÂ .rate_table = imx8mm_audiopll_tbl,
> >>> ÂÂÂÂÂÂÂÂÂÂ .rate_count = ARRAY_SIZE(imx8mm_audiopll_tbl),
> >>> ÂÂ };
> >>> -static struct imx_pll14xx_clk imx8mm_video_pll __initdata = {
> >>> +static struct imx_pll14xx_clk imx8mm_video_pll = {
> >>> ÂÂÂÂÂÂÂÂÂÂ .type = PLL_1443X,
> >>> ÂÂÂÂÂÂÂÂÂÂ .rate_table = imx8mm_videopll_tbl,
> >>> ÂÂÂÂÂÂÂÂÂÂ .rate_count = ARRAY_SIZE(imx8mm_videopll_tbl),
> >>> ÂÂ };
> >>> -static struct imx_pll14xx_clk imx8mm_dram_pll __initdata = {
> >>> +static struct imx_pll14xx_clk imx8mm_dram_pll = {
> >>> ÂÂÂÂÂÂÂÂÂÂ .type = PLL_1443X,
> >>> ÂÂÂÂÂÂÂÂÂÂ .rate_table = imx8mm_drampll_tbl,
> >>> ÂÂÂÂÂÂÂÂÂÂ .rate_count = ARRAY_SIZE(imx8mm_drampll_tbl),
> >>> ÂÂ };
> >>> -static struct imx_pll14xx_clk imx8mm_arm_pll __initdata = {
> >>> +static struct imx_pll14xx_clk imx8mm_arm_pll = {
> >>> ÂÂÂÂÂÂÂÂÂÂ .type = PLL_1416X,
> >>> ÂÂÂÂÂÂÂÂÂÂ .rate_table = imx8mm_pll1416x_tbl,
> >>> ÂÂÂÂÂÂÂÂÂÂ .rate_count = ARRAY_SIZE(imx8mm_pll1416x_tbl),
> >>> ÂÂ };
> >>> -static struct imx_pll14xx_clk imx8mm_gpu_pll __initdata = {
> >>> +static struct imx_pll14xx_clk imx8mm_gpu_pll = {
> >>> ÂÂÂÂÂÂÂÂÂÂ .type = PLL_1416X,
> >>> ÂÂÂÂÂÂÂÂÂÂ .rate_table = imx8mm_pll1416x_tbl,
> >>> ÂÂÂÂÂÂÂÂÂÂ .rate_count = ARRAY_SIZE(imx8mm_pll1416x_tbl),
> >>> ÂÂ };
> >>> -static struct imx_pll14xx_clk imx8mm_vpu_pll __initdata = {
> >>> +static struct imx_pll14xx_clk imx8mm_vpu_pll = {
> >>> ÂÂÂÂÂÂÂÂÂÂ .type = PLL_1416X,
> >>> ÂÂÂÂÂÂÂÂÂÂ .rate_table = imx8mm_pll1416x_tbl,
> >>> ÂÂÂÂÂÂÂÂÂÂ .rate_count = ARRAY_SIZE(imx8mm_pll1416x_tbl),
> >>> ÂÂ };
> >>> -static struct imx_pll14xx_clk imx8mm_sys_pll __initdata = {
> >>> +static struct imx_pll14xx_clk imx8mm_sys_pll = {
> >>> ÂÂÂÂÂÂÂÂÂÂ .type = PLL_1416X,
> >>> ÂÂÂÂÂÂÂÂÂÂ .rate_table = imx8mm_pll1416x_tbl,
> >>> ÂÂÂÂÂÂÂÂÂÂ .rate_count = ARRAY_SIZE(imx8mm_pll1416x_tbl), @@
> -374,7
> >>> +374,7 @@ static const char *imx8mm_clko1_sels[] = {"osc_24m",
> >>> "sys_pll1_800m", "osc_27m",
> >>> ÂÂ static struct clk *clks[IMX8MM_CLK_END];
> >>> ÂÂ static struct clk_onecell_data clk_data; -static struct clk **
> >>> const uart_clks[] __initconst = {
> >>> +static struct clk ** const uart_clks[] = {
> >>> ÂÂÂÂÂÂ &clks[IMX8MM_CLK_UART1_ROOT],
> >>> ÂÂÂÂÂÂ &clks[IMX8MM_CLK_UART2_ROOT],
> >>> ÂÂÂÂÂÂ &clks[IMX8MM_CLK_UART3_ROOT], @@ -382,19 +382,20
> @@ static
> >>> struct clk ** const uart_clks[] __initconst = {
> >>> ÂÂÂÂÂÂ NULL
> >>> ÂÂ };
> >>> -static int __init imx8mm_clocks_init(struct device_node *ccm_node)
> >>> +static int imx8mm_clocks_probe(struct platform_device *pdev)
> >>> ÂÂ {
> >>> -ÂÂÂ struct device_node *np;
> >>> +ÂÂÂ struct device *dev = &pdev->dev;
> >>> +ÂÂÂ struct device_node *np = dev->of_node;
> >>> ÂÂÂÂÂÂ void __iomem *base;
> >>> ÂÂÂÂÂÂ int ret;
> >>> ÂÂÂÂÂÂ clks[IMX8MM_CLK_DUMMY] = imx_clk_fixed("dummy", 0);
> >>> -ÂÂÂ clks[IMX8MM_CLK_24M] = of_clk_get_by_name(ccm_node,
> "osc_24m");
> >>> -ÂÂÂ clks[IMX8MM_CLK_32K] = of_clk_get_by_name(ccm_node,
> "osc_32k");
> >>> -ÂÂÂ clks[IMX8MM_CLK_EXT1] = of_clk_get_by_name(ccm_node,
> >>> "clk_ext1");
> >>> -ÂÂÂ clks[IMX8MM_CLK_EXT2] = of_clk_get_by_name(ccm_node,
> >>> "clk_ext2");
> >>> -ÂÂÂ clks[IMX8MM_CLK_EXT3] = of_clk_get_by_name(ccm_node,
> >>> "clk_ext3");
> >>> -ÂÂÂ clks[IMX8MM_CLK_EXT4] = of_clk_get_by_name(ccm_node,
> >>> "clk_ext4");
> >>> +ÂÂÂ clks[IMX8MM_CLK_24M] = of_clk_get_by_name(np, "osc_24m");
> >>> +ÂÂÂ clks[IMX8MM_CLK_32K] = of_clk_get_by_name(np, "osc_32k");
> >>> +ÂÂÂ clks[IMX8MM_CLK_EXT1] = of_clk_get_by_name(np, "clk_ext1");
> >>> +ÂÂÂ clks[IMX8MM_CLK_EXT2] = of_clk_get_by_name(np, "clk_ext2");
> >>> +ÂÂÂ clks[IMX8MM_CLK_EXT3] = of_clk_get_by_name(np, "clk_ext3");
> >>> +ÂÂÂ clks[IMX8MM_CLK_EXT4] = of_clk_get_by_name(np, "clk_ext4");
> >>> ÂÂÂÂÂÂ np = of_find_compatible_node(NULL, NULL,
> >>> "fsl,imx8mm-anatop");
> >>> ÂÂÂÂÂÂ base = of_iomap(np, 0);
> >>> @@ -480,10 +481,10 @@ static int __init imx8mm_clocks_init(struct
> >>> device_node *ccm_node)
> >>> ÂÂÂÂÂÂ clks[IMX8MM_SYS_PLL2_500M] =
> >>> imx_clk_fixed_factor("sys_pll2_500m", "sys_pll2_out", 1, 2);
> >>> ÂÂÂÂÂÂ clks[IMX8MM_SYS_PLL2_1000M] =
> >>> imx_clk_fixed_factor("sys_pll2_1000m", "sys_pll2_out", 1, 1);
> >>> -ÂÂÂ np = ccm_node;
> >>> -ÂÂÂ base = of_iomap(np, 0);
> >>> -ÂÂÂ if (WARN_ON(!base))
> >>> -ÂÂÂÂÂÂÂ return -ENOMEM;
> >>> +ÂÂÂ np = dev->of_node;
> >>> +ÂÂÂ base = devm_platform_ioremap_resource(pdev, 0);
> >>> +ÂÂÂ if (WARN_ON(IS_ERR(base)))
> >>> +ÂÂÂÂÂÂÂ return PTR_ERR(base);
> >>> ÂÂÂÂÂÂ /* Core Slice */
> >>> ÂÂÂÂÂÂ clks[IMX8MM_CLK_A53_SRC] =
> imx_clk_mux2("arm_a53_src", base +
> >>> 0x8000, 24, 3, imx8mm_a53_sels, ARRAY_SIZE(imx8mm_a53_sels)); @@
> >>> -682,4 +683,18 @@ static int __init imx8mm_clocks_init(struct
> >>> device_node *ccm_node)
> >>> ÂÂÂÂÂÂ return 0;
> >>> ÂÂ }
> >>> -CLK_OF_DECLARE_DRIVER(imx8mm, "fsl,imx8mm-ccm",
> >>> imx8mm_clocks_init);
> >>> +
> >>> +static const struct of_device_id imx8mm_clk_of_match[] = {
> >>> +ÂÂÂ { .compatible = "fsl,imx8mm-ccm" },
> >>> +ÂÂÂ { /* Sentinel */ },
> >>> +};
> >>> +MODULE_DEVICE_TABLE(of, imx8mm_clk_of_match);
> >>> +
> >>> +static struct platform_driver imx8mm_clk_driver = {
> >>> +ÂÂÂ .probe = imx8mm_clocks_probe,
> >>> +ÂÂÂ .driver = {
> >>> +ÂÂÂÂÂÂÂ .name = "imx8mm-ccm",
> >>> +ÂÂÂÂÂÂÂ .of_match_table = of_match_ptr(imx8mm_clk_of_match),
> >>> +ÂÂÂ },
> >>> +};
> >>> +module_platform_driver(imx8mm_clk_driver);
> >>>
> >> _______________________________________________
> >> linux-arm-kernel mailing list
> >> linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
> >> https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Flist
> >>
> s.infradead.org%2Fmailman%2Flistinfo%2Flinux-arm-kernel&data=02%7
> >>
> C01%7Cpeng.fan%40nxp.com%7C2317765357144c4b8a7e08d7c9ad2e7e%7
> C686ea1d
> >>
> 3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637199617967685983&sd
> ata=PmRi
> >>
> GsJKcmN59MpWWQWoA%2BWo5rX7XLoaiChV5%2FOGvVI%3D&reserv
> ed=0
> >>