diff options
author | Peter Robinson <pbrobinson@gmail.com> | 2018-06-04 07:24:58 +0100 |
---|---|---|
committer | Peter Robinson <pbrobinson@gmail.com> | 2018-06-04 07:24:58 +0100 |
commit | e8f4892e53e98464af631aaa7d79d8c50a2933eb (patch) | |
tree | e2de97e81518774ff8a68d278af5033a4be5638e | |
parent | 7ac993721d08d31bd5657e2bf1b4642527ee6bbd (diff) | |
download | kernel-e8f4892e53e98464af631aaa7d79d8c50a2933eb.tar.gz kernel-e8f4892e53e98464af631aaa7d79d8c50a2933eb.tar.xz kernel-e8f4892e53e98464af631aaa7d79d8c50a2933eb.zip |
Initial support for Raspberry Pi cpufreq driver
-rw-r--r-- | bcm2835-cpufreq-add-CPU-frequency-control-driver.patch | 273 | ||||
-rw-r--r-- | kernel-aarch64-debug.config | 1 | ||||
-rw-r--r-- | kernel-aarch64.config | 1 | ||||
-rw-r--r-- | kernel-armv7hl-debug.config | 1 | ||||
-rw-r--r-- | kernel-armv7hl-lpae-debug.config | 1 | ||||
-rw-r--r-- | kernel-armv7hl-lpae.config | 1 | ||||
-rw-r--r-- | kernel-armv7hl.config | 1 | ||||
-rw-r--r-- | kernel.spec | 5 | ||||
-rw-r--r-- | rebase-notes.txt | 1 |
9 files changed, 285 insertions, 0 deletions
diff --git a/bcm2835-cpufreq-add-CPU-frequency-control-driver.patch b/bcm2835-cpufreq-add-CPU-frequency-control-driver.patch new file mode 100644 index 000000000..b087998cb --- /dev/null +++ b/bcm2835-cpufreq-add-CPU-frequency-control-driver.patch @@ -0,0 +1,273 @@ +From 624e057827435de39274c34e20c2d937cb9d4ac3 Mon Sep 17 00:00:00 2001 +From: Peter Robinson <pbrobinson@gmail.com> +Date: Thu, 31 May 2018 19:08:12 +0100 +Subject: [PATCH] bcm2835: cpufreq: add CPU frequency control driver + +Signed-off-by: Peter Robinson <pbrobinson@gmail.com> +--- + arch/arm/boot/dts/bcm2835-rpi.dtsi | 7 ++ + arch/arm/boot/dts/bcm2837.dtsi | 33 +++++++ + drivers/clk/bcm/Kconfig | 8 ++ + drivers/clk/bcm/Makefile | 1 + + drivers/clk/bcm/clk-raspberrypi.c | 138 +++++++++++++++++++++++++++++ + 5 files changed, 187 insertions(+) + create mode 100644 drivers/clk/bcm/clk-raspberrypi.c + +diff --git a/arch/arm/boot/dts/bcm2835-rpi.dtsi b/arch/arm/boot/dts/bcm2835-rpi.dtsi +index 6c3cfaa77f3d..e6d1627ec421 100644 +--- a/arch/arm/boot/dts/bcm2835-rpi.dtsi ++++ b/arch/arm/boot/dts/bcm2835-rpi.dtsi +@@ -35,6 +35,13 @@ + reg = <0x7e00b840 0xf>; + interrupts = <0 2>; + }; ++ ++ arm_clk: arm_clk { ++ compatible = "raspberrypi,bcm2835-cpu"; ++ clocks = <&clocks BCM2835_CLOCK_VPU>; ++ #clock-cells = <0>; ++ clock-output-names = "arm"; ++ }; + }; + }; + +diff --git a/arch/arm/boot/dts/bcm2837.dtsi b/arch/arm/boot/dts/bcm2837.dtsi +index 7704bb029605..c24176282a1f 100644 +--- a/arch/arm/boot/dts/bcm2837.dtsi ++++ b/arch/arm/boot/dts/bcm2837.dtsi +@@ -38,6 +38,9 @@ + reg = <0>; + enable-method = "spin-table"; + cpu-release-addr = <0x0 0x000000d8>; ++ clocks = <&arm_clk>; ++ clock-names = "cpu"; ++ operating-points-v2 = <&cpu0_opp_table>; + }; + + cpu1: cpu@1 { +@@ -46,6 +49,9 @@ + reg = <1>; + enable-method = "spin-table"; + cpu-release-addr = <0x0 0x000000e0>; ++ clocks = <&arm_clk>; ++ clock-names = "cpu"; ++ operating-points-v2 = <&cpu0_opp_table>; + }; + + cpu2: cpu@2 { +@@ -54,6 +60,9 @@ + reg = <2>; + enable-method = "spin-table"; + cpu-release-addr = <0x0 0x000000e8>; ++ clocks = <&arm_clk>; ++ clock-names = "cpu"; ++ operating-points-v2 = <&cpu0_opp_table>; + }; + + cpu3: cpu@3 { +@@ -62,6 +71,30 @@ + reg = <3>; + enable-method = "spin-table"; + cpu-release-addr = <0x0 0x000000f0>; ++ clocks = <&arm_clk>; ++ clock-names = "cpu"; ++ operating-points-v2 = <&cpu0_opp_table>; ++ }; ++ }; ++ ++ cpu0_opp_table: opp_table0 { ++ compatible = "operating-points-v2"; ++ opp-shared; ++ ++ opp@600000000 { ++ opp-hz = /bits/ 64 <600000000>; ++ clock-latency-ns = <355000>; ++ opp-suspend; ++ }; ++ ++ opp@900000000 { ++ opp-hz = /bits/ 64 <900000000>; ++ clock-latency-ns = <355000>; ++ }; ++ ++ opp@1200000000 { ++ opp-hz = /bits/ 64 <1200000000>; ++ clock-latency-ns = <355000>; + }; + }; + }; +diff --git a/drivers/clk/bcm/Kconfig b/drivers/clk/bcm/Kconfig +index 4c4bd85f707c..e40bd19da22b 100644 +--- a/drivers/clk/bcm/Kconfig ++++ b/drivers/clk/bcm/Kconfig +@@ -63,3 +63,11 @@ config CLK_BCM_SR + default ARCH_BCM_IPROC + help + Enable common clock framework support for the Broadcom Stingray SoC ++ ++config CLK_RASPBERRYPI_CPU ++ bool "Raspberry Pi CPU clock driver" ++ depends on ARCH_BCM2835 || (COMPILE_TEST && OF) ++ depends on RASPBERRYPI_FIRMWARE=y ++ help ++ This enables support for the RPi CPU clock which can be adjusted ++ via the RPi firmware. +diff --git a/drivers/clk/bcm/Makefile b/drivers/clk/bcm/Makefile +index 002661d39128..a028b0a90b6e 100644 +--- a/drivers/clk/bcm/Makefile ++++ b/drivers/clk/bcm/Makefile +@@ -8,6 +8,7 @@ obj-$(CONFIG_COMMON_CLK_IPROC) += clk-iproc-armpll.o clk-iproc-pll.o clk-iproc-a + obj-$(CONFIG_ARCH_BCM2835) += clk-bcm2835.o + obj-$(CONFIG_ARCH_BCM2835) += clk-bcm2835-aux.o + obj-$(CONFIG_ARCH_BCM_53573) += clk-bcm53573-ilp.o ++obj-$(CONFIG_CLK_RASPBERRYPI_CPU) += clk-raspberrypi.o + obj-$(CONFIG_CLK_BCM_CYGNUS) += clk-cygnus.o + obj-$(CONFIG_CLK_BCM_HR2) += clk-hr2.o + obj-$(CONFIG_CLK_BCM_NSP) += clk-nsp.o +diff --git a/drivers/clk/bcm/clk-raspberrypi.c b/drivers/clk/bcm/clk-raspberrypi.c +new file mode 100644 +index 000000000000..046efc822a59 +--- /dev/null ++++ b/drivers/clk/bcm/clk-raspberrypi.c +@@ -0,0 +1,138 @@ ++// SPDX-License-Identifier: GPL-2.0+ ++/* ++ * Raspberry Pi CPU clock driver ++ * ++ * Copyright (C) 2018 Stefan Wahren <stefan.wahren@i2se.com> ++ */ ++ ++#include <linux/clk.h> ++#include <linux/clk-provider.h> ++#include <linux/device.h> ++#include <linux/err.h> ++#include <linux/module.h> ++#include <linux/of_device.h> ++#include <linux/platform_device.h> ++#include <linux/slab.h> ++#include <soc/bcm2835/raspberrypi-firmware.h> ++ ++#define VCMSG_ID_ARM_CLOCK 0x000000003 /* Clock/Voltage ID's */ ++ ++struct rpi_cpu_clkgen { ++ struct clk_hw hw; ++ struct rpi_firmware *fw; ++}; ++ ++/* tag part of the message */ ++struct prop { ++ u32 id; /* the ID of the clock/voltage to get or set */ ++ u32 val; /* the value (e.g. rate (in Hz)) to set */ ++} __packed; ++ ++static int rpi_cpu_clock_property(struct rpi_firmware *fw, u32 tag, u32 *val) ++{ ++ int ret; ++ struct prop msg = { ++ .id = VCMSG_ID_ARM_CLOCK, ++ .val = *val, ++ }; ++ ++ ret = rpi_firmware_property(fw, tag, &msg, sizeof(msg)); ++ if (ret) ++ return ret; ++ ++ *val = msg.val; ++ ++ return 0; ++} ++ ++static unsigned long rpi_cpu_get_rate(struct clk_hw *hw, ++ unsigned long parent_rate) ++{ ++ struct rpi_cpu_clkgen *cpu = container_of(hw, struct rpi_cpu_clkgen, hw); ++ u32 rate = 0; ++ ++ rpi_cpu_clock_property(cpu->fw, RPI_FIRMWARE_GET_CLOCK_RATE, &rate); ++ ++ return rate; ++} ++ ++static long rpi_cpu_round_rate(struct clk_hw *hw, unsigned long rate, ++ unsigned long *parent_rate) ++{ ++ return rate; ++} ++ ++static int rpi_cpu_set_rate(struct clk_hw *hw, unsigned long rate, ++ unsigned long parent_rate) ++{ ++ struct rpi_cpu_clkgen *cpu = container_of(hw, struct rpi_cpu_clkgen, hw); ++ u32 new_rate = rate; ++ ++ return rpi_cpu_clock_property(cpu->fw, RPI_FIRMWARE_SET_CLOCK_RATE, ++ &new_rate); ++} ++ ++static const struct clk_ops rpi_cpu_ops = { ++ .recalc_rate = rpi_cpu_get_rate, ++ .round_rate = rpi_cpu_round_rate, ++ .set_rate = rpi_cpu_set_rate, ++}; ++ ++static int rpi_cpu_probe(struct platform_device *pdev) ++{ ++ struct device *dev = &pdev->dev; ++ struct device_node *fw_node; ++ struct rpi_cpu_clkgen *cpu; ++ struct clk_init_data *init; ++ int ret; ++ ++ cpu = devm_kzalloc(dev, sizeof(*cpu), GFP_KERNEL); ++ if (!cpu) ++ return -ENOMEM; ++ ++ init = devm_kzalloc(dev, sizeof(*init), GFP_KERNEL); ++ if (!init) ++ return -ENOMEM; ++ ++ fw_node = of_find_compatible_node(NULL, NULL, ++ "raspberrypi,bcm2835-firmware"); ++ if (!fw_node) { ++ dev_err(dev, "Missing firmware node\n"); ++ return -ENOENT; ++ } ++ ++ cpu->fw = rpi_firmware_get(fw_node); ++ of_node_put(fw_node); ++ if (!cpu->fw) ++ return -EPROBE_DEFER; ++ ++ init->name = dev->of_node->name; ++ init->ops = &rpi_cpu_ops; ++ ++ cpu->hw.init = init; ++ ret = devm_clk_hw_register(dev, &cpu->hw); ++ if (ret) ++ return ret; ++ ++ return of_clk_add_hw_provider(dev->of_node, of_clk_hw_simple_get, ++ &cpu->hw); ++} ++ ++static const struct of_device_id rpi_cpu_of_match[] = { ++ { .compatible = "raspberrypi,bcm2835-cpu", }, ++ {}, ++}; ++MODULE_DEVICE_TABLE(of, rpi_cpu_of_match); ++ ++static struct platform_driver rpi_cpu_driver = { ++ .driver = { ++ .name = "raspberrypi-cpu", ++ .of_match_table = rpi_cpu_of_match, ++ }, ++ .probe = rpi_cpu_probe, ++}; ++builtin_platform_driver(rpi_cpu_driver); ++ ++MODULE_AUTHOR("Stefan Wahren <stefan.wahren@i2se.com>"); ++MODULE_DESCRIPTION("Raspberry Pi CPU clock driver"); ++MODULE_LICENSE("GPL v2"); +-- +2.17.0 + diff --git a/kernel-aarch64-debug.config b/kernel-aarch64-debug.config index 79872f45a..3fd70ca24 100644 --- a/kernel-aarch64-debug.config +++ b/kernel-aarch64-debug.config @@ -918,6 +918,7 @@ CONFIG_CLEANCACHE=y CONFIG_CLKDEV_LOOKUP=y # CONFIG_CLK_HSDK is not set # CONFIG_CLK_QORIQ is not set +CONFIG_CLK_RASPBERRYPI_CPU=y CONFIG_CLK_SP810=y CONFIG_CLKSRC_VERSATILE=y CONFIG_CLK_VEXPRESS_OSC=y diff --git a/kernel-aarch64.config b/kernel-aarch64.config index b635706df..dd0ff6467 100644 --- a/kernel-aarch64.config +++ b/kernel-aarch64.config @@ -918,6 +918,7 @@ CONFIG_CLEANCACHE=y CONFIG_CLKDEV_LOOKUP=y # CONFIG_CLK_HSDK is not set # CONFIG_CLK_QORIQ is not set +CONFIG_CLK_RASPBERRYPI_CPU=y CONFIG_CLK_SP810=y CONFIG_CLKSRC_VERSATILE=y CONFIG_CLK_VEXPRESS_OSC=y diff --git a/kernel-armv7hl-debug.config b/kernel-armv7hl-debug.config index ab8a752bf..61c6171b2 100644 --- a/kernel-armv7hl-debug.config +++ b/kernel-armv7hl-debug.config @@ -958,6 +958,7 @@ CONFIG_CIFS_XATTR=y CONFIG_CLEANCACHE=y # CONFIG_CLK_HSDK is not set # CONFIG_CLK_QORIQ is not set +CONFIG_CLK_RASPBERRYPI_CPU=y CONFIG_CLK_SP810=y CONFIG_CLKSRC_VERSATILE=y CONFIG_CLK_TWL6040=m diff --git a/kernel-armv7hl-lpae-debug.config b/kernel-armv7hl-lpae-debug.config index 171bce527..8cf12a5a6 100644 --- a/kernel-armv7hl-lpae-debug.config +++ b/kernel-armv7hl-lpae-debug.config @@ -929,6 +929,7 @@ CONFIG_CIFS_XATTR=y CONFIG_CLEANCACHE=y # CONFIG_CLK_HSDK is not set # CONFIG_CLK_QORIQ is not set +CONFIG_CLK_RASPBERRYPI_CPU=y CONFIG_CLK_SP810=y CONFIG_CLKSRC_VERSATILE=y CONFIG_CLK_VEXPRESS_OSC=y diff --git a/kernel-armv7hl-lpae.config b/kernel-armv7hl-lpae.config index 652cebfb8..40507ccba 100644 --- a/kernel-armv7hl-lpae.config +++ b/kernel-armv7hl-lpae.config @@ -928,6 +928,7 @@ CONFIG_CIFS_XATTR=y CONFIG_CLEANCACHE=y # CONFIG_CLK_HSDK is not set # CONFIG_CLK_QORIQ is not set +CONFIG_CLK_RASPBERRYPI_CPU=y CONFIG_CLK_SP810=y CONFIG_CLKSRC_VERSATILE=y CONFIG_CLK_VEXPRESS_OSC=y diff --git a/kernel-armv7hl.config b/kernel-armv7hl.config index 5aa160c69..5418f671f 100644 --- a/kernel-armv7hl.config +++ b/kernel-armv7hl.config @@ -957,6 +957,7 @@ CONFIG_CIFS_XATTR=y CONFIG_CLEANCACHE=y # CONFIG_CLK_HSDK is not set # CONFIG_CLK_QORIQ is not set +CONFIG_CLK_RASPBERRYPI_CPU=y CONFIG_CLK_SP810=y CONFIG_CLKSRC_VERSATILE=y CONFIG_CLK_TWL6040=m diff --git a/kernel.spec b/kernel.spec index 3376abbc2..671215dd5 100644 --- a/kernel.spec +++ b/kernel.spec @@ -605,6 +605,8 @@ Patch330: bcm2837-rpi-initial-3plus-support.patch Patch332: bcm2837-enable-pmu.patch Patch333: bcm2837-lan78xx-fixes.patch +Patch335: bcm2835-cpufreq-add-CPU-frequency-control-driver.patch + # 400 - IBM (ppc/s390x) patches # 500 - Temp fixes/CVEs etc @@ -1854,6 +1856,9 @@ fi # # %changelog +* Sun Jun 3 2018 Peter Robinson <pbrobinson@fedoraproject.org> +- Initial support for Raspberry Pi cpufreq driver + * Thu May 31 2018 Justin M. Forbes <jforbes@fedoraproject.org> - 4.17.0-0.rc7.git2.1 - Linux v4.17-rc7-43-gdd52cb879063 diff --git a/rebase-notes.txt b/rebase-notes.txt index 27c0aeb92..ce643d917 100644 --- a/rebase-notes.txt +++ b/rebase-notes.txt @@ -1,6 +1,7 @@ Linux 4.17 rebase notes: - Turn off MTD + JFFS2 + extra infiniband options - Back out kernel-bootwrapper changes for power commit f360f7278a753796aec58ade5b149d12e49f8bc1 +- Drop CONFIG_CLK_RASPBERRYPI_CPU and bcm2835-cpufreq-add-CPU-frequency-control-driver.patch Linux 4.16 rebase notes: - Consider turning off all the IMA features? |