MIPS Boston support
Subsystems (5)
v4 cover MIPS Boston support
This series introduces support for the MIPS Boston development board, allowing generic kernels to run on it. Typically a Boston board will be running the U-Boot bootloader & we make use of the Flattened Image Tree (FIT) image format for the kernel.
If physical Boston hardware is unavailable this series can be tested using QEMU built from the master branch (or v2.9 onwards). To do so, configure the kernel for the generic 64r6el_defconfig & run QEMU like so:
$ make ARCH=mips 64r6el_defconfig
$ make ARCH=mips CROSS_COMPILE=my-toolchain-
$ qemu-system-mips64el -M boston \
-kernel arch/mips/boot/vmlinux.gz.itb \
serial stdioApplies atop v4.12-rc3.
Paul Burton (4):
dt-bindings: Document img,boston-clock binding
clk: boston: Add a driver for MIPS Boston board clocks
MIPS: DTS: img: Don't attempt to build-in all .dtb files
MIPS: generic: Support MIPS Boston development boards
.../devicetree/bindings/clock/img,boston-clock.txt | 31 +++ MAINTAINERS | 10 + arch/mips/boot/dts/img/Makefile | 5 +- arch/mips/boot/dts/img/boston.dts | 224 +++++++++++++++++++++ arch/mips/configs/generic/board-boston.config | 48 +++++ arch/mips/generic/Kconfig | 12 ++ arch/mips/generic/vmlinux.its.S | 25 +++ drivers/clk/Kconfig | 1 + drivers/clk/Makefile | 1 + drivers/clk/imgtec/Kconfig | 10 + drivers/clk/imgtec/Makefile | 1 + drivers/clk/imgtec/clk-boston.c | 101 ++++++++++ include/dt-bindings/clock/boston-clock.h | 14 ++ 13 files changed, 481 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/clock/img,boston-clock.txt create mode 100644 arch/mips/boot/dts/img/boston.dts create mode 100644 arch/mips/configs/generic/board-boston.config create mode 100644 drivers/clk/imgtec/Kconfig create mode 100644 drivers/clk/imgtec/Makefile create mode 100644 drivers/clk/imgtec/clk-boston.c create mode 100644 include/dt-bindings/clock/boston-clock.h
Signature · 1 line
2.13.0
PATCH v4 1/4 dt-bindings: Document img,boston-clock binding
Add device tree binding documentation for the clocks provided by the MIPS Boston development board from Imagination Technologies, and a header file describing the available clocks for use by device trees & driver.
---
Changes in v4:
- Move img,boston-clock node under platform register syscon node.
- Add MAINTAINERS entry.
Changes in v3: None
Changes in v2:
- Add BOSTON_CLK_INPUT to expose the input clock.
.../devicetree/bindings/clock/img,boston-clock.txt | 31 ++++++++++++++++++++++ MAINTAINERS | 7 +++++ include/dt-bindings/clock/boston-clock.h | 14 ++++++++++ 3 files changed, 52 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/img,boston-clock.txt create mode 100644 include/dt-bindings/clock/boston-clock.h
Documentation/devicetree/bindings/clock/img,boston-clock.txt new file +31 -0
@@ -0,0 +1,31 @@ +Binding for Imagination Technologies MIPS Boston clock sources. + +This binding uses the common clock binding[1]. + +[1] Documentation/devicetree/bindings/clock/clock-bindings.txt + +The device node must be a child node of the syscon node corresponding to the +Boston system's platform registers. + +Required properties: +- compatible : Should be "img,boston-clock". +- #clock-cells : Should be set to 1. + Values available for clock consumers can be found in the header file: + <dt-bindings/clock/boston-clock.h> + +Example: + + system-controller@17ffd000 { + compatible = "img,boston-platform-regs", "syscon"; + reg = <0x17ffd000 0x1000>; + + clk_boston: clock { + compatible = "img,boston-clock"; + #clock-cells = <1>; + }; + }; + + uart0: uart@17ffe000 { + /* ... */ + clocks = <&clk_boston BOSTON_CLK_SYS>; + };
MAINTAINERS +7 -0
@@ -8499,6 +8499,13 @@ F: arch/mips/include/asm/mach-loongson32/ F: drivers/*/*loongson1* F: drivers/*/*/*loongson1* +MIPS BOSTON DEVELOPMENT BOARD +M: Paul Burton <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/clock/img,boston-clock.txt +F: include/dt-bindings/clock/boston-clock.h + MIROSOUND PCM20 FM RADIO RECEIVER DRIVER M: Hans Verkuil <[email protected]> L: [email protected]
include/dt-bindings/clock/boston-clock.h new file +14 -0
@@ -0,0 +1,14 @@ +/* +* Copyright (C) 2016 Imagination Technologies +* +* SPDX-License-Identifier: GPL-2.0 +*/ + +#ifndef __DT_BINDINGS_CLOCK_BOSTON_CLOCK_H__ +#define __DT_BINDINGS_CLOCK_BOSTON_CLOCK_H__ + +#define BOSTON_CLK_INPUT 0 +#define BOSTON_CLK_SYS 1 +#define BOSTON_CLK_CPU 2 + +#endif /* __DT_BINDINGS_CLOCK_BOSTON_CLOCK_H__ */
Signature · 1 line
2.13.0
Re: [PATCH v4 1/4] dt-bindings: Document img,boston-clock binding
Quoted 26 lines · Paul Burton
Add device tree binding documentation for the clocks provided by the MIPS Boston development board from Imagination Technologies, and a header file describing the available clocks for use by device trees & driver.
Signed-off-by Paul Burton <[email protected]>Cc Frank Rowand <[email protected]>Cc Michael Turquette <[email protected]>Cc Ralf Baechle <[email protected]>Cc Rob Herring <[email protected]>Cc Stephen Boyd <[email protected]>---
Changes in v4:
- Move img,boston-clock node under platform register syscon node.
- AddMAINTAINERSentry.Changes in v3: None
Changes in v2:
- AddBOSTON_CLK_INPUTto expose the input clock.
Quoted 6 lines
.../devicetree/bindings/clock/img,boston-clock.txt | 31 ++++++++++++++++++++++ MAINTAINERS | 7 +++++ include/dt-bindings/clock/boston-clock.h | 14 ++++++++++ 3 files changed, 52 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/img,boston-clock.txt create mode 100644 include/dt-bindings/clock/boston-clock.h
PATCH v4 2/4 clk: boston: Add a driver for MIPS Boston board clocks
In reply to Paul BurtonAdd a driver for the clocks provided by the MIPS Boston board from Imagination Technologies. 2 clocks are provided - the system clock & the CPU clock - and each is a simple fixed rate clock whose frequency can be determined by reading a register provided by the board.
---
Changes in v4:
- Adjust to expect the parent node to be the syscon.
- Update MAINTAINERS entry.
Changes in v3: None
Changes in v2:
- Support BOSTON_CLK_INPUT.
- Register clocks with clk_register_fixed_rate during boot, removing need for clk_ops.
- s/uint32_t/u32/.
- Move driver to a vendor directory.
MAINTAINERS | 1 + drivers/clk/Kconfig | 1 + drivers/clk/Makefile | 1 + drivers/clk/imgtec/Kconfig | 10 ++++ drivers/clk/imgtec/Makefile | 1 + drivers/clk/imgtec/clk-boston.c | 101 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 115 insertions(+) create mode 100644 drivers/clk/imgtec/Kconfig create mode 100644 drivers/clk/imgtec/Makefile create mode 100644 drivers/clk/imgtec/clk-boston.c
MAINTAINERS +1 -0
@@ -8504,6 +8504,7 @@ M: Paul Burton <[email protected]> L: [email protected] S: Maintained F: Documentation/devicetree/bindings/clock/img,boston-clock.txt +F: drivers/clk/imgtec/clk-boston.c F: include/dt-bindings/clock/boston-clock.h MIROSOUND PCM20 FM RADIO RECEIVER DRIVER
drivers/clk/Kconfig +1 -0
@@ -219,6 +219,7 @@ config COMMON_CLK_VC5 source "drivers/clk/bcm/Kconfig" source "drivers/clk/hisilicon/Kconfig" +source "drivers/clk/imgtec/Kconfig" source "drivers/clk/mediatek/Kconfig" source "drivers/clk/meson/Kconfig" source "drivers/clk/mvebu/Kconfig"
drivers/clk/Makefile +1 -0
@@ -59,6 +59,7 @@ obj-y += bcm/ obj-$(CONFIG_ARCH_BERLIN) += berlin/ obj-$(CONFIG_H8300) += h8300/ obj-$(CONFIG_ARCH_HISI) += hisilicon/ +obj-y += imgtec/ obj-$(CONFIG_ARCH_MXC) += imx/ obj-$(CONFIG_MACH_INGENIC) += ingenic/ obj-$(CONFIG_COMMON_CLK_KEYSTONE) += keystone/
drivers/clk/imgtec/Kconfig new file +10 -0
@@ -0,0 +1,10 @@ +config COMMON_CLK_BOSTON + bool "Clock driver for MIPS Boston boards" + depends on MIPS || COMPILE_TEST + depends on OF + select MFD_SYSCON + ---help--- + Enable this to support the system & CPU clocks on the MIPS Boston + development board from Imagination Technologies. These are simple + fixed rate clocks whose rate is determined by reading a platform + provided register.
drivers/clk/imgtec/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_COMMON_CLK_BOSTON) += clk-boston.o
drivers/clk/imgtec/clk-boston.c new file +101 -0
101 lines not on this page · raw message
Signature · 1 line
2.13.0
Re: [PATCH v4 2/4] clk: boston: Add a driver for MIPS Boston board clocks
Ping?
Ralf
Quoted 205 lines · Paul Burton
Add a driver for the clocks provided by the MIPS Boston board from Imagination Technologies. 2 clocks are provided - the system clock & the CPU clock - and each is a simple fixed rate clock whose frequency can be determined by reading a register provided by the board.
Signed-off-by Paul Burton <[email protected]>Cc Michael Turquette <[email protected]>Cc Ralf Baechle <[email protected]>Cc Stephen Boyd <[email protected]>---
Changes in v4:
- Adjust to expect the parent node to be the syscon.
- UpdateMAINTAINERSentry.Changes in v3: None
Changes in v2:
- SupportBOSTON_CLK_INPUT.
- Register clocks withclk_register_fixed_rateduring boot, removing need forclk_ops.
- s/uint32_t/u32/.
- Move driver to a vendor directory.MAINTAINERS | 1 + drivers/clk/Kconfig | 1 + drivers/clk/Makefile | 1 + drivers/clk/imgtec/Kconfig | 10 ++++ drivers/clk/imgtec/Makefile | 1 + drivers/clk/imgtec/clk-boston.c | 101 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 115 insertions(+) create mode 100644 drivers/clk/imgtec/Kconfig create mode 100644 drivers/clk/imgtec/Makefile create mode 100644 drivers/clk/imgtec/clk-boston.cMAINTAINERS +1
-0@@ -8504,6 +8504,7 @@ M: Paul Burton <[email protected]> L: [email protected] S: Maintained F: Documentation/devicetree/bindings/clock/img,boston-clock.txt +F: drivers/clk/imgtec/clk-boston.c F: include/dt-bindings/clock/boston-clock.h MIROSOUND PCM20 FM RADIO RECEIVER DRIVERdrivers/clk/Kconfig +1
-0@@ -219,6 +219,7 @@ config COMMON_CLK_VC5 source "drivers/clk/bcm/Kconfig" source "drivers/clk/hisilicon/Kconfig" +source "drivers/clk/imgtec/Kconfig" source "drivers/clk/mediatek/Kconfig" source "drivers/clk/meson/Kconfig" source "drivers/clk/mvebu/Kconfig"drivers/clk/Makefile +1
-0@@ -59,6 +59,7 @@ obj-y += bcm/ obj-$(CONFIG_ARCH_BERLIN) += berlin/ obj-$(CONFIG_H8300) += h8300/ obj-$(CONFIG_ARCH_HISI) += hisilicon/ +obj-y += imgtec/ obj-$(CONFIG_ARCH_MXC) += imx/ obj-$(CONFIG_MACH_INGENIC) += ingenic/ obj-$(CONFIG_COMMON_CLK_KEYSTONE) += keystone/drivers/clk/imgtec/Kconfig new file +10
-0@@ -0,0 +1,10 @@ +config COMMON_CLK_BOSTON + bool "Clock driver for MIPS Boston boards" + depends on MIPS || COMPILE_TEST + depends on OF + select MFD_SYSCON + ---help--- + Enable this to support the system & CPU clocks on the MIPS Boston + development board from Imagination Technologies. These are simple + fixed rate clocks whose rate is determined by reading a platform + provided register.drivers/clk/imgtec/Makefile new file +1
-0@@ -0,0 +1 @@ +obj-$(CONFIG_COMMON_CLK_BOSTON) += clk-boston.odrivers/clk/imgtec/clk-boston.c new file +101
-0@@ -0,0 +1,101 @@ +/* +* Copyright (C) 2016-2017 Imagination Technologies +* Author: Paul Burton <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at your +* option) any later version. +*/ + +#include <linux/clk-provider.h> +#include <linux/kernel.h> +#include <linux/of.h> +#include <linux/regmap.h> +#include <linux/slab.h> +#include <linux/mfd/syscon.h> + +#include <dt-bindings/clock/boston-clock.h> + +#define BOSTON_PLAT_MMCMDIV 0x30 +# define BOSTON_PLAT_MMCMDIV_CLK0DIV (0xff << 0) +# define BOSTON_PLAT_MMCMDIV_INPUT (0xff << 8) +# define BOSTON_PLAT_MMCMDIV_MUL (0xff << 16) +# define BOSTON_PLAT_MMCMDIV_CLK1DIV (0xff << 24) + +#define BOSTON_CLK_COUNT 3 + +struct clk_boston_state { +struct clk *clks[BOSTON_CLK_COUNT ]; +struct clk_onecell_data onecell_data; +}; + +static u32 ext_field (u32 val,u32 mask) +{ +return (val & mask) >> (ffs (mask) -1 ); +} + +static void __init clk_boston_setup (struct device_node *np) +{ +unsigned long in_freq, cpu_freq, sys_freq; +uint mmcmdiv, mul, cpu_div, sys_div; +struct clk_boston_state *state; +struct regmap *regmap; +struct clk *clk; +int err; + + regmap =syscon_node_to_regmap (np->parent); +if (IS_ERR (regmap)) { +pr_err ("failed to find regmap\n" ); +return ; + } + + err =regmap_read (regmap,BOSTON_PLAT_MMCMDIV , &mmcmdiv); +if (err) { +pr_err ("failed to read mmcm_div register: %d\n" , err); +return ; + } + + in_freq =ext_field (mmcmdiv,BOSTON_PLAT_MMCMDIV_INPUT ) *1000000 ; + mul =ext_field (mmcmdiv,BOSTON_PLAT_MMCMDIV_MUL ); + + sys_div =ext_field (mmcmdiv,BOSTON_PLAT_MMCMDIV_CLK0DIV ); + sys_freq =mult_frac (in_freq, mul, sys_div); + + cpu_div =ext_field (mmcmdiv,BOSTON_PLAT_MMCMDIV_CLK1DIV ); + cpu_freq =mult_frac (in_freq, mul, cpu_div); + + state =kzalloc (sizeof (*state),GFP_KERNEL ); +if (!state) +return ; + + clk =clk_register_fixed_rate (NULL ,"input" ,NULL ,0 , in_freq); +if (IS_ERR (clk)) { +pr_err ("failed to register input clock: %ld\n" ,PTR_ERR (clk)); +return ; + } + state->clks[BOSTON_CLK_INPUT ] = clk; + + clk =clk_register_fixed_rate (NULL ,"sys" ,"input" ,0 , sys_freq); +if (IS_ERR (clk)) { +pr_err ("failed to register sys clock: %ld\n" ,PTR_ERR (clk)); +return ; + } + state->clks[BOSTON_CLK_SYS ] = clk; + + clk =clk_register_fixed_rate (NULL ,"cpu" ,"input" ,0 , cpu_freq); +if (IS_ERR (clk)) { +pr_err ("failed to register cpu clock: %ld\n" ,PTR_ERR (clk)); +return ; + } + state->clks[BOSTON_CLK_CPU ] = clk; + + state->onecell_data.clks = state->clks; + state->onecell_data.clk_num =BOSTON_CLK_COUNT ; + + err =of_clk_add_provider (np, of_clk_src_onecell_get, + &state->onecell_data); +if (err) +pr_err ("failed to add DT provider: %d\n" , err); +} +CLK_OF_DECLARE (clk_boston,"img,boston-clock" , clk_boston_setup);Signature · 1 line
2.13.0
Re: [PATCH v4 2/4] clk: boston: Add a driver for MIPS Boston board clocks
In reply to Paul Burtondrivers/clk/imgtec/Kconfig line 4
Quoted 10 lines · Paul Burton
drivers/clk/imgtec/Kconfig new file +4
-0@@ -0,0 +1,10 @@ +config COMMON_CLK_BOSTON + bool "Clock driver for MIPS Boston boards" + depends on MIPS || COMPILE_TEST + depends on OF
What's the OF build dependency?
Quoted 81 lines
drivers/clk/imgtec/Kconfig new file +6
-0+ select MFD_SYSCON + ---help--- + Enable this to support the system & CPU clocks on the MIPS Boston + development board from Imagination Technologies. These are simple + fixed rate clocks whose rate is determined by reading a platform + provided register.drivers/clk/imgtec/Makefile new file +1
-0@@ -0,0 +1 @@ +obj-$(CONFIG_COMMON_CLK_BOSTON) += clk-boston.odrivers/clk/imgtec/clk-boston.c new file +62
-0@@ -0,0 +1,101 @@ +/* +* Copyright (C) 2016-2017 Imagination Technologies +* Author: Paul Burton <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at your +* option) any later version. +*/ + +#include <linux/clk-provider.h> +#include <linux/kernel.h> +#include <linux/of.h> +#include <linux/regmap.h> +#include <linux/slab.h> +#include <linux/mfd/syscon.h> + +#include <dt-bindings/clock/boston-clock.h> + +#define BOSTON_PLAT_MMCMDIV 0x30 +# define BOSTON_PLAT_MMCMDIV_CLK0DIV (0xff << 0) +# define BOSTON_PLAT_MMCMDIV_INPUT (0xff << 8) +# define BOSTON_PLAT_MMCMDIV_MUL (0xff << 16) +# define BOSTON_PLAT_MMCMDIV_CLK1DIV (0xff << 24) + +#define BOSTON_CLK_COUNT 3 + +struct clk_boston_state { +struct clk *clks[BOSTON_CLK_COUNT ]; +struct clk_onecell_data onecell_data; +}; + +static u32 ext_field (u32 val,u32 mask) +{ +return (val & mask) >> (ffs (mask) -1 ); +} + +static void __init clk_boston_setup (struct device_node *np) +{ +unsigned long in_freq, cpu_freq, sys_freq; +uint mmcmdiv, mul, cpu_div, sys_div; +struct clk_boston_state *state; +struct regmap *regmap; +struct clk *clk; +int err; + + regmap =syscon_node_to_regmap (np->parent); +if (IS_ERR (regmap)) { +pr_err ("failed to find regmap\n" ); +return ; + } + + err =regmap_read (regmap,BOSTON_PLAT_MMCMDIV , &mmcmdiv); +if (err) { +pr_err ("failed to read mmcm_div register: %d\n" , err); +return ; + } + + in_freq =ext_field (mmcmdiv,BOSTON_PLAT_MMCMDIV_INPUT ) *1000000 ; + mul =ext_field (mmcmdiv,BOSTON_PLAT_MMCMDIV_MUL ); + + sys_div =ext_field (mmcmdiv,BOSTON_PLAT_MMCMDIV_CLK0DIV );
drivers/clk/imgtec/clk-boston.c line 72
Quoted 10 lines
drivers/clk/imgtec/clk-boston.c new file +10
-0+ sys_freq =mult_frac (in_freq, mul, sys_div); + + cpu_div =ext_field (mmcmdiv,BOSTON_PLAT_MMCMDIV_CLK1DIV ); + cpu_freq =mult_frac (in_freq, mul, cpu_div); + + state =kzalloc (sizeof (*state),GFP_KERNEL ); +if (!state) +return ; + + clk =clk_register_fixed_rate (NULL ,"input" ,NULL ,0 , in_freq);
Please use the clk_hw_register_*() APIs instead so that this driver only deals in clk_hw pointers.
Quoted 15 lines
drivers/clk/imgtec/clk-boston.c new file +15
-0+if (IS_ERR (clk)) { +pr_err ("failed to register input clock: %ld\n" ,PTR_ERR (clk)); +return ; + } + state->clks[BOSTON_CLK_INPUT ] = clk; + + clk =clk_register_fixed_rate (NULL ,"sys" ,"input" ,0 , sys_freq); +if (IS_ERR (clk)) { +pr_err ("failed to register sys clock: %ld\n" ,PTR_ERR (clk)); +return ; + } + state->clks[BOSTON_CLK_SYS ] = clk; + + clk =clk_register_fixed_rate (NULL ,"cpu" ,"input" ,0 , cpu_freq); +if (IS_ERR (clk)) {
drivers/clk/imgtec/clk-boston.c line 97
Quoted 10 lines
drivers/clk/imgtec/clk-boston.c new file +10
-0+pr_err ("failed to register cpu clock: %ld\n" ,PTR_ERR (clk)); +return ; + } + state->clks[BOSTON_CLK_CPU ] = clk; + + state->onecell_data.clks = state->clks; + state->onecell_data.clk_num =BOSTON_CLK_COUNT ; + + err =of_clk_add_provider (np, of_clk_src_onecell_get, + &state->onecell_data);
Same for here, of_clk_add_hw_provider()
drivers/clk/imgtec/clk-boston.c line 101
Quoted 4 lines
drivers/clk/imgtec/clk-boston.c new file +4
-0+if (err) +pr_err ("failed to add DT provider: %d\n" , err); +} +CLK_OF_DECLARE (clk_boston,"img,boston-clock" , clk_boston_setup);
Can this be a platform driver? The syscon mfd can populate child nodes and this could be a driver that binds to the clock child node.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH v4 2/4] clk: boston: Add a driver for MIPS Boston board clocks
Hi Stephen,
Quoted 13 lines · On Wednesday, 14 June 2017 09:01:06 PDT Stephen Boyd wrote:
drivers/clk/imgtec/Kconfig line 4
Quoted 10 lines · Paul Burton
drivers/clk/imgtec/Kconfig new file +4
-0@@ -0,0 +1,10 @@ +config COMMON_CLK_BOSTON + bool "Clock driver for MIPS Boston boards" + depends on MIPS || COMPILE_TEST + depends on OFWhat's the OF build dependency?
Dropped for v5, though the driver won't actually be used on systems without CONFIG_OF.
Quoted 87 lines
Quoted 87 lines
drivers/clk/imgtec/Kconfig new file +6
-0+ select MFD_SYSCON + ---help--- + Enable this to support the system & CPU clocks on the MIPS Boston + development board from Imagination Technologies. These are simple + fixed rate clocks whose rate is determined by reading a platform + provided register.drivers/clk/imgtec/Makefile new file +1
-0@@ -0,0 +1 @@ +obj-$(CONFIG_COMMON_CLK_BOSTON) += clk-boston.o(quoted diff) +0
-0
b/drivers/clk/imgtec/clk-boston.cnew file mode 100644 index 000000000000..98bb0b764d15drivers/clk/imgtec/clk-boston.c new file +5
-0@@ -0,0 +1,101 @@ +/* +* Copyright (C) 2016-2017 Imagination Technologies +* Author: Paul Burton <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version.
+ */drivers/clk/imgtec/clk-boston.c new file +58
-0+ +#include <linux/clk-provider.h> +#include <linux/kernel.h> +#include <linux/of.h> +#include <linux/regmap.h> +#include <linux/slab.h> +#include <linux/mfd/syscon.h> + +#include <dt-bindings/clock/boston-clock.h> + +#define BOSTON_PLAT_MMCMDIV 0x30 +# define BOSTON_PLAT_MMCMDIV_CLK0DIV (0xff << 0) +# define BOSTON_PLAT_MMCMDIV_INPUT (0xff << 8) +# define BOSTON_PLAT_MMCMDIV_MUL (0xff << 16) +# define BOSTON_PLAT_MMCMDIV_CLK1DIV (0xff << 24) + +#define BOSTON_CLK_COUNT 3 + +struct clk_boston_state { +struct clk *clks[BOSTON_CLK_COUNT ]; +struct clk_onecell_data onecell_data; +}; + +static u32 ext_field (u32 val,u32 mask) +{ +return (val & mask) >> (ffs (mask) -1 ); +} + +static void __init clk_boston_setup (struct device_node *np) +{ +unsigned long in_freq, cpu_freq, sys_freq; +uint mmcmdiv, mul, cpu_div, sys_div; +struct clk_boston_state *state; +struct regmap *regmap; +struct clk *clk; +int err; + + regmap =syscon_node_to_regmap (np->parent); +if (IS_ERR (regmap)) { +pr_err ("failed to find regmap\n" ); +return ; + } + + err =regmap_read (regmap,BOSTON_PLAT_MMCMDIV , &mmcmdiv); +if (err) { +pr_err ("failed to read mmcm_div register: %d\n" , err); +return ; + } + + in_freq =ext_field (mmcmdiv,BOSTON_PLAT_MMCMDIV_INPUT ) *1000000 ; + mul =ext_field (mmcmdiv,BOSTON_PLAT_MMCMDIV_MUL ); + + sys_div =ext_field (mmcmdiv,BOSTON_PLAT_MMCMDIV_CLK0DIV ); + sys_freq =mult_frac (in_freq, mul, sys_div); + + cpu_div =ext_field (mmcmdiv,BOSTON_PLAT_MMCMDIV_CLK1DIV ); + cpu_freq =mult_frac (in_freq, mul, cpu_div); +
Quoted 8 lines
drivers/clk/imgtec/clk-boston.c line 72
Quoted 5 lines
drivers/clk/imgtec/clk-boston.c new file +5
-0+ state =kzalloc (sizeof (*state),GFP_KERNEL ); +if (!state) +return ; + + clk =clk_register_fixed_rate (NULL ,"input" ,NULL ,0 , in_freq);Please use the clk_hw_register_*() APIs instead so that this driver only deals in
clk_hwpointers.
OK, done in v5.
Quoted 19 lines
Quoted 19 lines
drivers/clk/imgtec/clk-boston.c new file +19
-0+if (IS_ERR (clk)) { +pr_err ("failed to register input clock: %ld\n" ,PTR_ERR (clk)); +return ; + } + state->clks[BOSTON_CLK_INPUT ] = clk; + + clk =clk_register_fixed_rate (NULL ,"sys" ,"input" ,0 , sys_freq); +if (IS_ERR (clk)) { +pr_err ("failed to register sys clock: %ld\n" ,PTR_ERR (clk)); +return ; + } + state->clks[BOSTON_CLK_SYS ] = clk; + + clk =clk_register_fixed_rate (NULL ,"cpu" ,"input" ,0 , cpu_freq); +if (IS_ERR (clk)) { +pr_err ("failed to register cpu clock: %ld\n" ,PTR_ERR (clk)); +return ; + } + state->clks[BOSTON_CLK_CPU ] = clk;
Quoted 8 lines
drivers/clk/imgtec/clk-boston.c line 97
Quoted 6 lines
drivers/clk/imgtec/clk-boston.c new file +6
-0+ + state->onecell_data.clks = state->clks; + state->onecell_data.clk_num =BOSTON_CLK_COUNT ; + + err =of_clk_add_provider (np, of_clk_src_onecell_get, + &state->onecell_data);Same for here,
of_clk_add_hw_provider()
Done in v5.
Quoted 8 lines
drivers/clk/imgtec/clk-boston.c line 101
Quoted 4 lines
drivers/clk/imgtec/clk-boston.c new file +4
-0+if (err) +pr_err ("failed to add DT provider: %d\n" , err); +} +CLK_OF_DECLARE (clk_boston,"img,boston-clock" , clk_boston_setup);Can this be a platform driver? The syscon mfd can populate child nodes and this could be a driver that binds to the clock child node.
Sadly no, it can't. This driver provides the CPU frequency which we need early on. I've added a comment to that effect in v5.
Thanks,
Paul
PATCH v4 3/4 MIPS: DTS: img: Don't attempt to build-in all .dtb files
In reply to Paul BurtonWhen building a FIT image we may want the kernel to build multiple .dtb files, but we don't want to build them all into the kernel binary as object files since they'll instead be included in the FIT image.
Commit daa10170da27 ("MIPS: DTS: img: add device tree for Marduk board") however created arch/mips/boot/dts/img/Makefile with a line that builds any enabled .dtb files into the kernel. Remove this & build the pistachio object specifically, in preparation for adding .dtb targets which we don't want to build into the kernel.
---
Changes in v4:
- New patch.
Changes in v3: None
Changes in v2: None
arch/mips/boot/dts/img/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/mips/boot/dts/img/Makefile +1 -2
@@ -1,6 +1,5 @@ dtb-$(CONFIG_MACH_PISTACHIO) += pistachio_marduk.dtb - -obj-y += $(patsubst %.dtb, %.dtb.o, $(dtb-y)) +obj-$(CONFIG_MACH_PISTACHIO) += pistachio_marduk.dtb.o # Force kbuild to make empty built-in.o if necessary obj- += dummy.o
Signature · 1 line
2.13.0
Re: [PATCH v4 3/4] MIPS: DTS: img: Don't attempt to build-in all .dtb files
Hi Paul,
Quoted 17 lines · Paul Burton
When building a FIT image we may want the kernel to build multiple .dtb files, but we don't want to build them all into the kernel binary as object files since they'll instead be included in the FIT image.
Commit
daa10170da27("MIPS: DTS: img: add device tree for Marduk board") however createdarch/mips/boot/dts/img/Makefilewith a line that builds any enabled .dtb files into the kernel. Remove this & build the pistachio object specifically, in preparation for adding .dtb targets which we don't want to build into the kernel.Signed-off-by Paul Burton <[email protected]>Cc Rahul Bedarkar <[email protected]>Cc Ralf Baechle <[email protected]>---
Quoted 9 lines
Changes in v4:
- New patch.Changes in v3: None
Changes in v2: Nonearch/mips/boot/dts/img/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
It looks good to me.
arch/mips/boot/dts/img/Makefile line 3
Quoted 8 lines
arch/mips/boot/dts/img/Makefile +0
-2@@ -1,6 +1,5 @@ dtb-$(CONFIG_MACH_PISTACHIO) += pistachio_marduk.dtb - -obj-y += $(patsubst %.dtb, %.dtb.o, $(dtb-y))
It was probably copy/paste from other board Makefiles. But If I understand it correctly, please correct me if I am wrong, linking of object file of device tree to kernel image is useful if boot loader doesn't support loading external device tree and in that case kernel can use inbuilt device tree.
Thanks,
Rahul
Re: [PATCH v4 3/4] MIPS: DTS: img: Don't attempt to build-in all .dtb files
Hi Rahul,
Quoted 26 lines · On Tuesday, 13 June 2017 09:13:12 PDT Rahul Bedarkar wrote:
Hi Paul,
Quoted 23 lines · Paul Burton
When building a FIT image we may want the kernel to build multiple .dtb files, but we don't want to build them all into the kernel binary as object files since they'll instead be included in the FIT image.
Commit
daa10170da27("MIPS: DTS: img: add device tree for Marduk board") however createdarch/mips/boot/dts/img/Makefilewith a line that builds any enabled .dtb files into the kernel. Remove this & build the pistachio object specifically, in preparation for adding .dtb targets which we don't want to build into the kernel.Signed-off-by Paul Burton <[email protected]>Cc Rahul Bedarkar <[email protected]>Cc Ralf Baechle <[email protected]>---
Changes in v4:
- New patch.Changes in v3: None
Changes in v2: None
Quoted 6 lines
Quoted 2 lines
arch/mips/boot/dts/img/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)It looks good to me.
Reviewed-by Rahul Bedarkar <[email protected]>
Thanks for reviewing :)
Quoted 17 lines
arch/mips/boot/dts/img/Makefile line 5
Quoted 10 lines
(quoted diff) +0
-0b/arch/mips/boot/dts/img/Makefile index
69a65f0f82d2..c178cf56f5b8100644arch/mips/boot/dts/img/Makefile +0
-2@@ -1,6 +1,5 @@ dtb-$(CONFIG_MACH_PISTACHIO) += pistachio_marduk.dtb - -obj-y += $(patsubst %.dtb, %.dtb.o, $(dtb-y))It was probably copy/paste from other board Makefiles. But If I understand it correctly, please correct me if I am wrong, linking of object file of device tree to kernel image is useful if boot loader doesn't support loading external device tree and in that case kernel can use inbuilt device tree.
Quoted 2 lines
Thanks,
Rahul
Yes, it can be useful & there's nothing wrong with building in the .dtb for a platform like pistachio. For the generic kernel however we put the various device tree binaries into the FIT image so that the bootloader can pick out the right one, so building them into the kernel is unnecessary.
Thanks,
Paul
PATCH v4 4/4 MIPS: generic: Support MIPS Boston development boards
In reply to Paul BurtonAdd support for the MIPS Boston development board to generic kernels, which essentially amounts to:
- Adding the device tree source for the MIPS Boston board.
- Adding a Kconfig fragment which enables the appropriate drivers for the MIPS Boston board.
With these changes in place generic kernels will support the board by default, and kernels with only the drivers needed for Boston enabled can be configured by setting BOARDS=boston during configuration. For example:
$ make ARCH=mips 64r6el_defconfig BOARDS=boston
---
Changes in v4:
- Most of the series already went in, rebase on v4.12-rc3.
- Adjust DT to move img,boston-clock under the plat_regs syscon node.
- Enable CONFIG_BLK_DEV_SD in board-boston.cfg to SATA disk access.
- Enable CONFIG_GPIOLIB so that the GPIO driver is actually enabled.
- Update MAINTAINERS entry.
Changes in v3: None
Changes in v2: None
MAINTAINERS | 2 + arch/mips/boot/dts/img/Makefile | 2 + arch/mips/boot/dts/img/boston.dts | 224 ++++++++++++++++++++++++++ arch/mips/configs/generic/board-boston.config | 48 ++++++ arch/mips/generic/Kconfig | 12 ++ arch/mips/generic/vmlinux.its.S | 25 +++ 6 files changed, 313 insertions(+) create mode 100644 arch/mips/boot/dts/img/boston.dts create mode 100644 arch/mips/configs/generic/board-boston.config
MAINTAINERS +2 -0
@@ -8504,6 +8504,8 @@ M: Paul Burton <[email protected]> L: [email protected] S: Maintained F: Documentation/devicetree/bindings/clock/img,boston-clock.txt +F: arch/mips/boot/dts/img/boston.dts +F: arch/mips/configs/generic/board-boston.config F: drivers/clk/imgtec/clk-boston.c F: include/dt-bindings/clock/boston-clock.h
arch/mips/boot/dts/img/Makefile +2 -0
@@ -1,3 +1,5 @@ +dtb-$(CONFIG_FIT_IMAGE_FDT_BOSTON) += boston.dtb + dtb-$(CONFIG_MACH_PISTACHIO) += pistachio_marduk.dtb obj-$(CONFIG_MACH_PISTACHIO) += pistachio_marduk.dtb.o
arch/mips/boot/dts/img/boston.dts new file +224 -0
224 lines not on this page · raw message
arch/mips/configs/generic/board-boston.config new file +48 -0
48 lines not on this page · raw message
arch/mips/generic/Kconfig +12 -0
@@ -9,6 +9,8 @@ config LEGACY_BOARDS kernel is booted without being provided with an FDT via the UHI boot protocol. +comment "Legacy (non-UHI/non-FIT) Boards" + config LEGACY_BOARD_SEAD3 bool "Support MIPS SEAD-3 boards" select LEGACY_BOARDS
@@ -16,4 +18,14 @@ config LEGACY_BOARD_SEAD3 Enable this to include support for booting on MIPS SEAD-3 FPGA-based development boards, which boot using a legacy boot protocol. +comment "FIT/UHI Boards" + +config FIT_IMAGE_FDT_BOSTON + bool "Include FDT for MIPS Boston boards" + help + Enable this to include the FDT for the MIPS Boston development board + from Imagination Technologies in the FIT kernel image. You should + enable this if you wish to boot on a MIPS Boston board, as it is + expected by the bootloader. + endif
arch/mips/generic/vmlinux.its.S +25 -0
@@ -29,3 +29,28 @@ }; }; }; + +#ifdef CONFIG_FIT_IMAGE_FDT_BOSTON +/ { + images { + fdt@boston { + description = "img,boston Device Tree"; + data = /incbin/("boot/dts/img/boston.dtb"); + type = "flat_dt"; + arch = "mips"; + compression = "none"; + hash@0 { + algo = "sha1"; + }; + }; + }; + + configurations { + conf@boston { + description = "Boston Linux kernel"; + kernel = "kernel@0"; + fdt = "fdt@boston"; + }; + }; +}; +#endif /* CONFIG_FIT_IMAGE_FDT_BOSTON */
Signature · 1 line
2.13.0