diff mbox series

[02/22] arm: kirkwood: 88f6281: Detect CONFIG_SYS_TCLK from SAR register

Message ID 20220817193809.1059688-3-michael@walle.cc
State Awaiting Upstream
Delegated to: Stefan Roese
Headers show
Series board: lsxl: major update and DM conversion | expand

Commit Message

Michael Walle Aug. 17, 2022, 7:37 p.m. UTC
From: Pali Rohár <pali@kernel.org>

Bit 21 in SAR register specifies if TCLK is running at 166 MHz or 200 MHz.
This information is undocumented in public Marvell Kirkwood Functional
Specifications [2], but is available in Linux v3.15 kirkwood code [1].

Commit 8ac303d49f89 ("arm: kirkwood: Do not overwrite CONFIG_SYS_TCLK")
broke support for Marvell 88F6281 SoCs because it was expected that all
those SoCs have TCLK running at 200 MHz as specified in Marvell 88F6281
Hardware Specifications [3].

Fix broken support for 88F6281 by detecting CONFIG_SYS_TCLK from SAR
register, like it was doing Linux v3.15.

[1] - https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/arch/arm/mach-kirkwood/common.c?h=v3.15#n542
[2] - https://web.archive.org/web/20130730091033/http://www.marvell.com/embedded-processors/kirkwood/assets/FS_88F6180_9x_6281_OpenSource.pdf
[3] - https://web.archive.org/web/20120620073511/http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F6281_OpenSource.pdf

Fixes: 8ac303d49f89 ("arm: kirkwood: Do not overwrite CONFIG_SYS_TCLK")
Signed-off-by: Pali Rohár <pali@kernel.org>
---
 arch/arm/mach-kirkwood/include/mach/kw88f6281.h | 3 ++-
 arch/arm/mach-kirkwood/include/mach/soc.h       | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

Comments

Stefan Roese Aug. 23, 2022, 5:02 a.m. UTC | #1
Hi Michael,

On 17.08.22 21:37, Michael Walle wrote:
> From: Pali Rohár <pali@kernel.org>
> 
> Bit 21 in SAR register specifies if TCLK is running at 166 MHz or 200 MHz.
> This information is undocumented in public Marvell Kirkwood Functional
> Specifications [2], but is available in Linux v3.15 kirkwood code [1].
> 
> Commit 8ac303d49f89 ("arm: kirkwood: Do not overwrite CONFIG_SYS_TCLK")
> broke support for Marvell 88F6281 SoCs because it was expected that all
> those SoCs have TCLK running at 200 MHz as specified in Marvell 88F6281
> Hardware Specifications [3].
> 
> Fix broken support for 88F6281 by detecting CONFIG_SYS_TCLK from SAR
> register, like it was doing Linux v3.15.
> 
> [1] - https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/arch/arm/mach-kirkwood/common.c?h=v3.15#n542
> [2] - https://web.archive.org/web/20130730091033/http://www.marvell.com/embedded-processors/kirkwood/assets/FS_88F6180_9x_6281_OpenSource.pdf
> [3] - https://web.archive.org/web/20120620073511/http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F6281_OpenSource.pdf
> 
> Fixes: 8ac303d49f89 ("arm: kirkwood: Do not overwrite CONFIG_SYS_TCLK")
> Signed-off-by: Pali Rohár <pali@kernel.org>

I've applied your patch series on master (from yesterday) and see
these error(s):

$ make ds109_defconfig
$ make -sj
...
In file included from ./arch/arm/include/asm/arch/config.h:18,
                  from include/configs/mv-common.h:58,
                  from include/configs/ds109.h:14,
                  from include/config.h:4,
                  from include/common.h:16,
                  from board/Synology/ds109/ds109.c:8:
board/Synology/ds109/ds109.c: In function 'reset_misc':
./arch/arm/include/asm/arch/kw88f6281.h:18:43: warning: implicit 
declaration of function 'readl' [-Wimplicit-function-declaration]
    18 | #define CONFIG_SYS_TCLK                 ((readl(CONFIG_SAR_REG) 
& BIT(21)) ? \
       |                                           ^~~~~
include/configs/mv-common.h:36:41: note: in expansion of macro 
'CONFIG_SYS_TCLK'
    36 | #define CONFIG_SYS_NS16550_CLK          CONFIG_SYS_TCLK
       |                                         ^~~~~~~~~~~~~~~
board/Synology/ds109/ds109.c:111:36: note: in expansion of macro 
'CONFIG_SYS_NS16550_CLK'
   111 |                                    CONFIG_SYS_NS16550_CLK, 9600);
       |                                    ^~~~~~~~~~~~~~~~~~~~~~
/opt/kernel.org/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-ld.bfd: 
board/Synology/ds109/ds109.o: in function `reset_misc':
/home/stefan/git/u-boot/u-boot-marvell/board/Synology/ds109/ds109.c:111: 
undefined reference to `readl'
make: *** [Makefile:1823: u-boot] Error 1

Could you please take a look and fix this?

Thanks,
Stefan

> ---
>   arch/arm/mach-kirkwood/include/mach/kw88f6281.h | 3 ++-
>   arch/arm/mach-kirkwood/include/mach/soc.h       | 2 ++
>   2 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/mach-kirkwood/include/mach/kw88f6281.h b/arch/arm/mach-kirkwood/include/mach/kw88f6281.h
> index 87406081cf..f86cd0bb60 100644
> --- a/arch/arm/mach-kirkwood/include/mach/kw88f6281.h
> +++ b/arch/arm/mach-kirkwood/include/mach/kw88f6281.h
> @@ -15,6 +15,7 @@
>   #define KW_REGS_PHY_BASE		KW88F6281_REGS_PHYS_BASE
>   
>   /* TCLK Core Clock definition */
> -#define CONFIG_SYS_TCLK	200000000 /* 200MHz */
> +#define CONFIG_SYS_TCLK			((readl(CONFIG_SAR_REG) & BIT(21)) ? \
> +					166666667 : 200000000)
>   
>   #endif /* _ASM_ARCH_KW88F6281_H */
> diff --git a/arch/arm/mach-kirkwood/include/mach/soc.h b/arch/arm/mach-kirkwood/include/mach/soc.h
> index 1d7f2828cd..5f545c6f43 100644
> --- a/arch/arm/mach-kirkwood/include/mach/soc.h
> +++ b/arch/arm/mach-kirkwood/include/mach/soc.h
> @@ -62,6 +62,8 @@
>   #define MVCPU_WIN_ENABLE	KWCPU_WIN_ENABLE
>   #define MVCPU_WIN_DISABLE	KWCPU_WIN_DISABLE
>   
> +#define CONFIG_SAR_REG		(KW_MPP_BASE + 0x0030)
> +
>   #if defined (CONFIG_KW88F6281)
>   #include <asm/arch/kw88f6281.h>
>   #elif defined (CONFIG_KW88F6192)

Viele Grüße,
Stefan Roese
Michael Walle Aug. 23, 2022, 8:17 a.m. UTC | #2
Am 2022-08-23 07:02, schrieb Stefan Roese:
> Hi Michael,
> 
> On 17.08.22 21:37, Michael Walle wrote:
>> From: Pali Rohár <pali@kernel.org>
>> 
>> Bit 21 in SAR register specifies if TCLK is running at 166 MHz or 200 
>> MHz.
>> This information is undocumented in public Marvell Kirkwood Functional
>> Specifications [2], but is available in Linux v3.15 kirkwood code [1].
>> 
>> Commit 8ac303d49f89 ("arm: kirkwood: Do not overwrite 
>> CONFIG_SYS_TCLK")
>> broke support for Marvell 88F6281 SoCs because it was expected that 
>> all
>> those SoCs have TCLK running at 200 MHz as specified in Marvell 
>> 88F6281
>> Hardware Specifications [3].
>> 
>> Fix broken support for 88F6281 by detecting CONFIG_SYS_TCLK from SAR
>> register, like it was doing Linux v3.15.
>> 
>> [1] - 
>> https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/arch/arm/mach-kirkwood/common.c?h=v3.15#n542
>> [2] - 
>> https://web.archive.org/web/20130730091033/http://www.marvell.com/embedded-processors/kirkwood/assets/FS_88F6180_9x_6281_OpenSource.pdf
>> [3] - 
>> https://web.archive.org/web/20120620073511/http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F6281_OpenSource.pdf
>> 
>> Fixes: 8ac303d49f89 ("arm: kirkwood: Do not overwrite 
>> CONFIG_SYS_TCLK")
>> Signed-off-by: Pali Rohár <pali@kernel.org>
> 
> I've applied your patch series on master (from yesterday) and see
> these error(s):
> 
> $ make ds109_defconfig
> $ make -sj
> ...
> In file included from ./arch/arm/include/asm/arch/config.h:18,
>                  from include/configs/mv-common.h:58,
>                  from include/configs/ds109.h:14,
>                  from include/config.h:4,
>                  from include/common.h:16,
>                  from board/Synology/ds109/ds109.c:8:
> board/Synology/ds109/ds109.c: In function 'reset_misc':
> ./arch/arm/include/asm/arch/kw88f6281.h:18:43: warning: implicit
> declaration of function 'readl' [-Wimplicit-function-declaration]
>    18 | #define CONFIG_SYS_TCLK
> ((readl(CONFIG_SAR_REG) & BIT(21)) ? \
>       |                                           ^~~~~
> include/configs/mv-common.h:36:41: note: in expansion of macro 
> 'CONFIG_SYS_TCLK'
>    36 | #define CONFIG_SYS_NS16550_CLK          CONFIG_SYS_TCLK
>       |                                         ^~~~~~~~~~~~~~~
> board/Synology/ds109/ds109.c:111:36: note: in expansion of macro
> 'CONFIG_SYS_NS16550_CLK'
>   111 |                                    CONFIG_SYS_NS16550_CLK, 
> 9600);
>       |                                    ^~~~~~~~~~~~~~~~~~~~~~
> /opt/kernel.org/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-ld.bfd:
> board/Synology/ds109/ds109.o: in function `reset_misc':
> /home/stefan/git/u-boot/u-boot-marvell/board/Synology/ds109/ds109.c:111:
> undefined reference to `readl'
> make: *** [Makefile:1823: u-boot] Error 1
> 
> Could you please take a look and fix this?

I guess soc.h should also include <asm/io.h> because now it is
using that hidden readl().

Pali?

-michael
Michael Walle Aug. 23, 2022, 8:24 a.m. UTC | #3
Am 2022-08-23 10:17, schrieb michael@walle.cc:
> Am 2022-08-23 07:02, schrieb Stefan Roese:
>> Hi Michael,
>> 
>> On 17.08.22 21:37, Michael Walle wrote:
>>> From: Pali Rohár <pali@kernel.org>
>>> 
>>> Bit 21 in SAR register specifies if TCLK is running at 166 MHz or 200 
>>> MHz.
>>> This information is undocumented in public Marvell Kirkwood 
>>> Functional
>>> Specifications [2], but is available in Linux v3.15 kirkwood code 
>>> [1].
>>> 
>>> Commit 8ac303d49f89 ("arm: kirkwood: Do not overwrite 
>>> CONFIG_SYS_TCLK")
>>> broke support for Marvell 88F6281 SoCs because it was expected that 
>>> all
>>> those SoCs have TCLK running at 200 MHz as specified in Marvell 
>>> 88F6281
>>> Hardware Specifications [3].
>>> 
>>> Fix broken support for 88F6281 by detecting CONFIG_SYS_TCLK from SAR
>>> register, like it was doing Linux v3.15.
>>> 
>>> [1] - 
>>> https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/arch/arm/mach-kirkwood/common.c?h=v3.15#n542
>>> [2] - 
>>> https://web.archive.org/web/20130730091033/http://www.marvell.com/embedded-processors/kirkwood/assets/FS_88F6180_9x_6281_OpenSource.pdf
>>> [3] - 
>>> https://web.archive.org/web/20120620073511/http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F6281_OpenSource.pdf
>>> 
>>> Fixes: 8ac303d49f89 ("arm: kirkwood: Do not overwrite 
>>> CONFIG_SYS_TCLK")
>>> Signed-off-by: Pali Rohár <pali@kernel.org>
>> 
>> I've applied your patch series on master (from yesterday) and see
>> these error(s):
>> 
>> $ make ds109_defconfig
>> $ make -sj
>> ...
>> In file included from ./arch/arm/include/asm/arch/config.h:18,
>>                  from include/configs/mv-common.h:58,
>>                  from include/configs/ds109.h:14,
>>                  from include/config.h:4,
>>                  from include/common.h:16,
>>                  from board/Synology/ds109/ds109.c:8:
>> board/Synology/ds109/ds109.c: In function 'reset_misc':
>> ./arch/arm/include/asm/arch/kw88f6281.h:18:43: warning: implicit
>> declaration of function 'readl' [-Wimplicit-function-declaration]
>>    18 | #define CONFIG_SYS_TCLK
>> ((readl(CONFIG_SAR_REG) & BIT(21)) ? \
>>       |                                           ^~~~~
>> include/configs/mv-common.h:36:41: note: in expansion of macro 
>> 'CONFIG_SYS_TCLK'
>>    36 | #define CONFIG_SYS_NS16550_CLK          CONFIG_SYS_TCLK
>>       |                                         ^~~~~~~~~~~~~~~
>> board/Synology/ds109/ds109.c:111:36: note: in expansion of macro
>> 'CONFIG_SYS_NS16550_CLK'
>>   111 |                                    CONFIG_SYS_NS16550_CLK, 
>> 9600);
>>       |                                    ^~~~~~~~~~~~~~~~~~~~~~
>> /opt/kernel.org/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-ld.bfd:
>> board/Synology/ds109/ds109.o: in function `reset_misc':
>> /home/stefan/git/u-boot/u-boot-marvell/board/Synology/ds109/ds109.c:111:
>> undefined reference to `readl'
>> make: *** [Makefile:1823: u-boot] Error 1
>> 
>> Could you please take a look and fix this?
> 
> I guess soc.h should also include <asm/io.h> because now it is
> using that hidden readl().

..which isn't working because it somehow finds its way to the
hosttools. Hum.

In the meantime, Stefan, could you just drop patch 1 and 2 and still
take this series. The rest of the series doesn't really depend
on them. lschlv2 will just be broken until the TCLK issue is fixed.
This way, I don't have to repost all the patches.

-michael
Pali Rohár Aug. 23, 2022, 8:46 a.m. UTC | #4
On Tuesday 23 August 2022 10:17:31 michael@walle.cc wrote:
> Am 2022-08-23 07:02, schrieb Stefan Roese:
> > Hi Michael,
> > 
> > On 17.08.22 21:37, Michael Walle wrote:
> > > From: Pali Rohár <pali@kernel.org>
> > > 
> > > Bit 21 in SAR register specifies if TCLK is running at 166 MHz or
> > > 200 MHz.
> > > This information is undocumented in public Marvell Kirkwood Functional
> > > Specifications [2], but is available in Linux v3.15 kirkwood code [1].
> > > 
> > > Commit 8ac303d49f89 ("arm: kirkwood: Do not overwrite
> > > CONFIG_SYS_TCLK")
> > > broke support for Marvell 88F6281 SoCs because it was expected that
> > > all
> > > those SoCs have TCLK running at 200 MHz as specified in Marvell
> > > 88F6281
> > > Hardware Specifications [3].
> > > 
> > > Fix broken support for 88F6281 by detecting CONFIG_SYS_TCLK from SAR
> > > register, like it was doing Linux v3.15.
> > > 
> > > [1] - https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/arch/arm/mach-kirkwood/common.c?h=v3.15#n542
> > > [2] - https://web.archive.org/web/20130730091033/http://www.marvell.com/embedded-processors/kirkwood/assets/FS_88F6180_9x_6281_OpenSource.pdf
> > > [3] - https://web.archive.org/web/20120620073511/http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F6281_OpenSource.pdf
> > > 
> > > Fixes: 8ac303d49f89 ("arm: kirkwood: Do not overwrite
> > > CONFIG_SYS_TCLK")
> > > Signed-off-by: Pali Rohár <pali@kernel.org>
> > 
> > I've applied your patch series on master (from yesterday) and see
> > these error(s):
> > 
> > $ make ds109_defconfig
> > $ make -sj
> > ...
> > In file included from ./arch/arm/include/asm/arch/config.h:18,
> >                  from include/configs/mv-common.h:58,
> >                  from include/configs/ds109.h:14,
> >                  from include/config.h:4,
> >                  from include/common.h:16,
> >                  from board/Synology/ds109/ds109.c:8:
> > board/Synology/ds109/ds109.c: In function 'reset_misc':
> > ./arch/arm/include/asm/arch/kw88f6281.h:18:43: warning: implicit
> > declaration of function 'readl' [-Wimplicit-function-declaration]
> >    18 | #define CONFIG_SYS_TCLK
> > ((readl(CONFIG_SAR_REG) & BIT(21)) ? \
> >       |                                           ^~~~~
> > include/configs/mv-common.h:36:41: note: in expansion of macro
> > 'CONFIG_SYS_TCLK'
> >    36 | #define CONFIG_SYS_NS16550_CLK          CONFIG_SYS_TCLK
> >       |                                         ^~~~~~~~~~~~~~~
> > board/Synology/ds109/ds109.c:111:36: note: in expansion of macro
> > 'CONFIG_SYS_NS16550_CLK'
> >   111 |                                    CONFIG_SYS_NS16550_CLK,
> > 9600);
> >       |                                    ^~~~~~~~~~~~~~~~~~~~~~
> > /opt/kernel.org/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-ld.bfd:
> > board/Synology/ds109/ds109.o: in function `reset_misc':
> > /home/stefan/git/u-boot/u-boot-marvell/board/Synology/ds109/ds109.c:111:
> > undefined reference to `readl'
> > make: *** [Makefile:1823: u-boot] Error 1
> > 
> > Could you please take a look and fix this?
> 
> I guess soc.h should also include <asm/io.h> because now it is
> using that hidden readl().
> 
> Pali?
> 
> -michael

Yes!
Pali Rohár Aug. 23, 2022, 8:47 a.m. UTC | #5
On Tuesday 23 August 2022 10:24:10 michael@walle.cc wrote:
> Am 2022-08-23 10:17, schrieb michael@walle.cc:
> > Am 2022-08-23 07:02, schrieb Stefan Roese:
> > > Hi Michael,
> > > 
> > > On 17.08.22 21:37, Michael Walle wrote:
> > > > From: Pali Rohár <pali@kernel.org>
> > > > 
> > > > Bit 21 in SAR register specifies if TCLK is running at 166 MHz
> > > > or 200 MHz.
> > > > This information is undocumented in public Marvell Kirkwood
> > > > Functional
> > > > Specifications [2], but is available in Linux v3.15 kirkwood
> > > > code [1].
> > > > 
> > > > Commit 8ac303d49f89 ("arm: kirkwood: Do not overwrite
> > > > CONFIG_SYS_TCLK")
> > > > broke support for Marvell 88F6281 SoCs because it was expected
> > > > that all
> > > > those SoCs have TCLK running at 200 MHz as specified in Marvell
> > > > 88F6281
> > > > Hardware Specifications [3].
> > > > 
> > > > Fix broken support for 88F6281 by detecting CONFIG_SYS_TCLK from SAR
> > > > register, like it was doing Linux v3.15.
> > > > 
> > > > [1] - https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/arch/arm/mach-kirkwood/common.c?h=v3.15#n542
> > > > [2] - https://web.archive.org/web/20130730091033/http://www.marvell.com/embedded-processors/kirkwood/assets/FS_88F6180_9x_6281_OpenSource.pdf
> > > > [3] - https://web.archive.org/web/20120620073511/http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F6281_OpenSource.pdf
> > > > 
> > > > Fixes: 8ac303d49f89 ("arm: kirkwood: Do not overwrite
> > > > CONFIG_SYS_TCLK")
> > > > Signed-off-by: Pali Rohár <pali@kernel.org>
> > > 
> > > I've applied your patch series on master (from yesterday) and see
> > > these error(s):
> > > 
> > > $ make ds109_defconfig
> > > $ make -sj
> > > ...
> > > In file included from ./arch/arm/include/asm/arch/config.h:18,
> > >                  from include/configs/mv-common.h:58,
> > >                  from include/configs/ds109.h:14,
> > >                  from include/config.h:4,
> > >                  from include/common.h:16,
> > >                  from board/Synology/ds109/ds109.c:8:
> > > board/Synology/ds109/ds109.c: In function 'reset_misc':
> > > ./arch/arm/include/asm/arch/kw88f6281.h:18:43: warning: implicit
> > > declaration of function 'readl' [-Wimplicit-function-declaration]
> > >    18 | #define CONFIG_SYS_TCLK
> > > ((readl(CONFIG_SAR_REG) & BIT(21)) ? \
> > >       |                                           ^~~~~
> > > include/configs/mv-common.h:36:41: note: in expansion of macro
> > > 'CONFIG_SYS_TCLK'
> > >    36 | #define CONFIG_SYS_NS16550_CLK          CONFIG_SYS_TCLK
> > >       |                                         ^~~~~~~~~~~~~~~
> > > board/Synology/ds109/ds109.c:111:36: note: in expansion of macro
> > > 'CONFIG_SYS_NS16550_CLK'
> > >   111 |                                    CONFIG_SYS_NS16550_CLK,
> > > 9600);
> > >       |                                    ^~~~~~~~~~~~~~~~~~~~~~
> > > /opt/kernel.org/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-ld.bfd:
> > > board/Synology/ds109/ds109.o: in function `reset_misc':
> > > /home/stefan/git/u-boot/u-boot-marvell/board/Synology/ds109/ds109.c:111:
> > > undefined reference to `readl'
> > > make: *** [Makefile:1823: u-boot] Error 1
> > > 
> > > Could you please take a look and fix this?
> > 
> > I guess soc.h should also include <asm/io.h> because now it is
> > using that hidden readl().
> 
> ..which isn't working because it somehow finds its way to the
> hosttools. Hum.

Or you can include it in ds109/ds109.c file.

> In the meantime, Stefan, could you just drop patch 1 and 2 and still
> take this series. The rest of the series doesn't really depend
> on them. lschlv2 will just be broken until the TCLK issue is fixed.
> This way, I don't have to repost all the patches.
> 
> -michael
Stefan Roese Aug. 23, 2022, 8:51 a.m. UTC | #6
On 23.08.22 10:47, Pali Rohár wrote:
> On Tuesday 23 August 2022 10:24:10 michael@walle.cc wrote:
>> Am 2022-08-23 10:17, schrieb michael@walle.cc:
>>> Am 2022-08-23 07:02, schrieb Stefan Roese:
>>>> Hi Michael,
>>>>
>>>> On 17.08.22 21:37, Michael Walle wrote:
>>>>> From: Pali Rohár <pali@kernel.org>
>>>>>
>>>>> Bit 21 in SAR register specifies if TCLK is running at 166 MHz
>>>>> or 200 MHz.
>>>>> This information is undocumented in public Marvell Kirkwood
>>>>> Functional
>>>>> Specifications [2], but is available in Linux v3.15 kirkwood
>>>>> code [1].
>>>>>
>>>>> Commit 8ac303d49f89 ("arm: kirkwood: Do not overwrite
>>>>> CONFIG_SYS_TCLK")
>>>>> broke support for Marvell 88F6281 SoCs because it was expected
>>>>> that all
>>>>> those SoCs have TCLK running at 200 MHz as specified in Marvell
>>>>> 88F6281
>>>>> Hardware Specifications [3].
>>>>>
>>>>> Fix broken support for 88F6281 by detecting CONFIG_SYS_TCLK from SAR
>>>>> register, like it was doing Linux v3.15.
>>>>>
>>>>> [1] - https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/arch/arm/mach-kirkwood/common.c?h=v3.15#n542
>>>>> [2] - https://web.archive.org/web/20130730091033/http://www.marvell.com/embedded-processors/kirkwood/assets/FS_88F6180_9x_6281_OpenSource.pdf
>>>>> [3] - https://web.archive.org/web/20120620073511/http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F6281_OpenSource.pdf
>>>>>
>>>>> Fixes: 8ac303d49f89 ("arm: kirkwood: Do not overwrite
>>>>> CONFIG_SYS_TCLK")
>>>>> Signed-off-by: Pali Rohár <pali@kernel.org>
>>>>
>>>> I've applied your patch series on master (from yesterday) and see
>>>> these error(s):
>>>>
>>>> $ make ds109_defconfig
>>>> $ make -sj
>>>> ...
>>>> In file included from ./arch/arm/include/asm/arch/config.h:18,
>>>>                   from include/configs/mv-common.h:58,
>>>>                   from include/configs/ds109.h:14,
>>>>                   from include/config.h:4,
>>>>                   from include/common.h:16,
>>>>                   from board/Synology/ds109/ds109.c:8:
>>>> board/Synology/ds109/ds109.c: In function 'reset_misc':
>>>> ./arch/arm/include/asm/arch/kw88f6281.h:18:43: warning: implicit
>>>> declaration of function 'readl' [-Wimplicit-function-declaration]
>>>>     18 | #define CONFIG_SYS_TCLK
>>>> ((readl(CONFIG_SAR_REG) & BIT(21)) ? \
>>>>        |                                           ^~~~~
>>>> include/configs/mv-common.h:36:41: note: in expansion of macro
>>>> 'CONFIG_SYS_TCLK'
>>>>     36 | #define CONFIG_SYS_NS16550_CLK          CONFIG_SYS_TCLK
>>>>        |                                         ^~~~~~~~~~~~~~~
>>>> board/Synology/ds109/ds109.c:111:36: note: in expansion of macro
>>>> 'CONFIG_SYS_NS16550_CLK'
>>>>    111 |                                    CONFIG_SYS_NS16550_CLK,
>>>> 9600);
>>>>        |                                    ^~~~~~~~~~~~~~~~~~~~~~
>>>> /opt/kernel.org/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-ld.bfd:
>>>> board/Synology/ds109/ds109.o: in function `reset_misc':
>>>> /home/stefan/git/u-boot/u-boot-marvell/board/Synology/ds109/ds109.c:111:
>>>> undefined reference to `readl'
>>>> make: *** [Makefile:1823: u-boot] Error 1
>>>>
>>>> Could you please take a look and fix this?
>>>
>>> I guess soc.h should also include <asm/io.h> because now it is
>>> using that hidden readl().
>>
>> ..which isn't working because it somehow finds its way to the
>> hosttools. Hum.
> 
> Or you can include it in ds109/ds109.c file.

Yes, this works. I'll squash this in, while applying - if everything
else is okay.

Thanks,
Stefan
Michael Walle Aug. 23, 2022, 8:51 a.m. UTC | #7
Am 2022-08-23 10:47, schrieb Pali Rohár:
> On Tuesday 23 August 2022 10:24:10 michael@walle.cc wrote:
>> Am 2022-08-23 10:17, schrieb michael@walle.cc:
>> > Am 2022-08-23 07:02, schrieb Stefan Roese:
>> > > Hi Michael,
>> > >
>> > > On 17.08.22 21:37, Michael Walle wrote:
>> > > > From: Pali Rohár <pali@kernel.org>
>> > > >
>> > > > Bit 21 in SAR register specifies if TCLK is running at 166 MHz
>> > > > or 200 MHz.
>> > > > This information is undocumented in public Marvell Kirkwood
>> > > > Functional
>> > > > Specifications [2], but is available in Linux v3.15 kirkwood
>> > > > code [1].
>> > > >
>> > > > Commit 8ac303d49f89 ("arm: kirkwood: Do not overwrite
>> > > > CONFIG_SYS_TCLK")
>> > > > broke support for Marvell 88F6281 SoCs because it was expected
>> > > > that all
>> > > > those SoCs have TCLK running at 200 MHz as specified in Marvell
>> > > > 88F6281
>> > > > Hardware Specifications [3].
>> > > >
>> > > > Fix broken support for 88F6281 by detecting CONFIG_SYS_TCLK from SAR
>> > > > register, like it was doing Linux v3.15.
>> > > >
>> > > > [1] - https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/arch/arm/mach-kirkwood/common.c?h=v3.15#n542
>> > > > [2] - https://web.archive.org/web/20130730091033/http://www.marvell.com/embedded-processors/kirkwood/assets/FS_88F6180_9x_6281_OpenSource.pdf
>> > > > [3] - https://web.archive.org/web/20120620073511/http://www.marvell.com/embedded-processors/kirkwood/assets/HW_88F6281_OpenSource.pdf
>> > > >
>> > > > Fixes: 8ac303d49f89 ("arm: kirkwood: Do not overwrite
>> > > > CONFIG_SYS_TCLK")
>> > > > Signed-off-by: Pali Rohár <pali@kernel.org>
>> > >
>> > > I've applied your patch series on master (from yesterday) and see
>> > > these error(s):
>> > >
>> > > $ make ds109_defconfig
>> > > $ make -sj
>> > > ...
>> > > In file included from ./arch/arm/include/asm/arch/config.h:18,
>> > >                  from include/configs/mv-common.h:58,
>> > >                  from include/configs/ds109.h:14,
>> > >                  from include/config.h:4,
>> > >                  from include/common.h:16,
>> > >                  from board/Synology/ds109/ds109.c:8:
>> > > board/Synology/ds109/ds109.c: In function 'reset_misc':
>> > > ./arch/arm/include/asm/arch/kw88f6281.h:18:43: warning: implicit
>> > > declaration of function 'readl' [-Wimplicit-function-declaration]
>> > >    18 | #define CONFIG_SYS_TCLK
>> > > ((readl(CONFIG_SAR_REG) & BIT(21)) ? \
>> > >       |                                           ^~~~~
>> > > include/configs/mv-common.h:36:41: note: in expansion of macro
>> > > 'CONFIG_SYS_TCLK'
>> > >    36 | #define CONFIG_SYS_NS16550_CLK          CONFIG_SYS_TCLK
>> > >       |                                         ^~~~~~~~~~~~~~~
>> > > board/Synology/ds109/ds109.c:111:36: note: in expansion of macro
>> > > 'CONFIG_SYS_NS16550_CLK'
>> > >   111 |                                    CONFIG_SYS_NS16550_CLK,
>> > > 9600);
>> > >       |                                    ^~~~~~~~~~~~~~~~~~~~~~
>> > > /opt/kernel.org/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-ld.bfd:
>> > > board/Synology/ds109/ds109.o: in function `reset_misc':
>> > > /home/stefan/git/u-boot/u-boot-marvell/board/Synology/ds109/ds109.c:111:
>> > > undefined reference to `readl'
>> > > make: *** [Makefile:1823: u-boot] Error 1
>> > >
>> > > Could you please take a look and fix this?
>> >
>> > I guess soc.h should also include <asm/io.h> because now it is
>> > using that hidden readl().
>> 
>> ..which isn't working because it somehow finds its way to the
>> hosttools. Hum.
> 
> Or you can include it in ds109/ds109.c file.

And maybe other files, too. Mh. Somehow this feels wrong, but as we
cannot include it in the soc.h I don't see another possibility.

-michael
diff mbox series

Patch

diff --git a/arch/arm/mach-kirkwood/include/mach/kw88f6281.h b/arch/arm/mach-kirkwood/include/mach/kw88f6281.h
index 87406081cf..f86cd0bb60 100644
--- a/arch/arm/mach-kirkwood/include/mach/kw88f6281.h
+++ b/arch/arm/mach-kirkwood/include/mach/kw88f6281.h
@@ -15,6 +15,7 @@ 
 #define KW_REGS_PHY_BASE		KW88F6281_REGS_PHYS_BASE
 
 /* TCLK Core Clock definition */
-#define CONFIG_SYS_TCLK	200000000 /* 200MHz */
+#define CONFIG_SYS_TCLK			((readl(CONFIG_SAR_REG) & BIT(21)) ? \
+					166666667 : 200000000)
 
 #endif /* _ASM_ARCH_KW88F6281_H */
diff --git a/arch/arm/mach-kirkwood/include/mach/soc.h b/arch/arm/mach-kirkwood/include/mach/soc.h
index 1d7f2828cd..5f545c6f43 100644
--- a/arch/arm/mach-kirkwood/include/mach/soc.h
+++ b/arch/arm/mach-kirkwood/include/mach/soc.h
@@ -62,6 +62,8 @@ 
 #define MVCPU_WIN_ENABLE	KWCPU_WIN_ENABLE
 #define MVCPU_WIN_DISABLE	KWCPU_WIN_DISABLE
 
+#define CONFIG_SAR_REG		(KW_MPP_BASE + 0x0030)
+
 #if defined (CONFIG_KW88F6281)
 #include <asm/arch/kw88f6281.h>
 #elif defined (CONFIG_KW88F6192)