Skip to contentSkip to conversation

ARM: socfpga: Enable soft reset

PATCH New dinguyen at altera.com 3 participants 8 messages Apr 11, 2013 – Apr 15, 2013

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/3 ARM: socfpga: Enable soft reset

From: Dinh Nguyen <[email protected]>

Enable a cold or warm reset to the HW from userspace.

Also fix a few sparse errors:

warning: symbol 'sys_manager_base_addr' was not declared. Should it be static?
warning: symbol 'rst_manager_base_addr' was not declared. Should it be static?

v3:
- Use regular readl/writel

v2:
- Remove hotplug support while investigating on how implement PSCI

---
 arch/arm/mach-socfpga/core.h    |   11 +++++++++++
 arch/arm/mach-socfpga/platsmp.c |    3 ---
 arch/arm/mach-socfpga/socfpga.c |   10 +++++++++-
 3 files changed, 20 insertions(+), 4 deletions(-)
arch/arm/mach-socfpga/core.h +11 -0
index 315edff..572b8f7 100644
@@ -20,12 +20,23 @@
 #ifndef __MACH_CORE_H
 #define __MACH_CORE_H
 
+#define SOCFPGA_RSTMGR_CTRL	0x04
+#define SOCFPGA_RSTMGR_MODPERRST	0x14
+#define SOCFPGA_RSTMGR_BRGMODRST	0x1c
+
+/* System Manager bits */
+#define RSTMGR_CTRL_SWCOLDRSTREQ	0x1	/* Cold Reset */
+#define RSTMGR_CTRL_SWWARMRSTREQ	0x2	/* Warm Reset */
+
 extern void socfpga_secondary_startup(void);
 extern void __iomem *socfpga_scu_base_addr;
 
 extern void socfpga_init_clocks(void);
 extern void socfpga_sysmgr_init(void);
 
+extern void __iomem *sys_manager_base_addr;
+extern void __iomem *rst_manager_base_addr;
+
 extern struct smp_operations socfpga_smp_ops;
 extern char secondary_trampoline, secondary_trampoline_end;
 
arch/arm/mach-socfpga/platsmp.c +0 -3
index 84c60fa..b907fb9 100644
@@ -30,9 +30,6 @@
 
 #include "core.h"
 
-extern void __iomem *sys_manager_base_addr;
-extern void __iomem *rst_manager_base_addr;
-
 static void __cpuinit socfpga_secondary_init(unsigned int cpu)
 {
 	/*
arch/arm/mach-socfpga/socfpga.c +9 -1
index 1042c02..2cae16c 100644
@@ -87,7 +87,15 @@ static void __init socfpga_init_irq(void)
 
 static void socfpga_cyclone5_restart(char mode, const char *cmd)
 {
-	/* TODO: */
+	u32 temp;
+
+	temp = readl(rst_manager_base_addr + SOCFPGA_RSTMGR_CTRL);
+
+	if (mode == 'h')
+		temp |= RSTMGR_CTRL_SWCOLDRSTREQ;
+	else
+		temp |= RSTMGR_CTRL_SWWARMRSTREQ;
+	writel(temp, rst_manager_base_addr + SOCFPGA_RSTMGR_CTRL);
 }
 
 static void __init socfpga_cyclone5_init(void)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v3 2/3 ARM: socfpga: Add clock entries into device tree

From: Dinh Nguyen <[email protected]>

Adds the main PLL clock groups for SOCFPGA into device tree file so that the clock framework to query the clock and clock rates appropriately.

$cat /sys/kernel/debug/clk/clk_summary
clock enable_cnt prepare_cnt rate
---------------------------------------------------------------------

 osc1                           2           2            25000000
    sdram_pll                   0           0            400000000
       s2f_usr2_clk             0           0            66666666
       ddr_dq_clk               0           0            200000000
       ddr_2x_dqs_clk           0           0            400000000
       ddr_dqs_clk              0           0            200000000
    periph_pll                  2           2            500000000
       s2f_usr1_clk             0           0            50000000
       per_base_clk             4           4            100000000
       per_nand_mmc_clk         0           0            25000000
       per_qsi_clk              0           0            250000000
       emac1_clk                1           1            125000000
       emac0_clk                0           0            125000000
    main_pll                    1           1            1600000000
       cfg_s2f_usr0_clk         0           0            100000000
       main_nand_sdmmc_clk      0           0            100000000
       main_qspi_clk            0           0            400000000
       dbg_base_clk             0           0            400000000
       mainclk                  0           0            400000000
       mpuclk                   1           1            800000000
          smp_twd               1           1            200000000

v3:
- Use basic clk_gate structure and reuse clk_gate_ops
- Split out patches between dts and source

v2:
- Add copyright from Calxeda for clk.c
- Add device tree "fixed-divider" for clocks with fixed dividers
- Fix space and tab issues

---
 .../bindings/arm/altera/socfpga-clk-manager.txt    |   11 ++
 .../devicetree/bindings/clock/altr_socfpga.txt     |   18 +++
 arch/arm/boot/dts/socfpga.dtsi                     |  157 ++++++++++++++++++++
 arch/arm/boot/dts/socfpga_cyclone5.dts             |    8 +
 arch/arm/boot/dts/socfpga_vt.dts                   |    8 +
 5 files changed, 202 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/altera/socfpga-clk-manager.txt
 create mode 100644 Documentation/devicetree/bindings/clock/altr_socfpga.txt
Documentation/devicetree/bindings/arm/altera/socfpga-clk-manager.txt new file +11 -0
new file mode 100644
index 0000000..2c28f1d
@@ -0,0 +1,11 @@
+Altera SOCFPGA Clock Manager
+
+Required properties:
+- compatible : "altr,clk-mgr"
+- reg : Should contain base address and length for Clock Manager
+
+Example:
+	 clkmgr at ffd04000 {
+		compatible = "altr,clk-mgr";
+		reg = <0xffd04000 0x1000>;
+	};
Documentation/devicetree/bindings/clock/altr_socfpga.txt new file +18 -0
new file mode 100644
index 0000000..bd0c841
@@ -0,0 +1,18 @@
+Device Tree Clock bindings for Altera's SoCFPGA platform
+
+This binding uses the common clock binding[1].
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+Required properties:
+- compatible : shall be one of the following:
+	"altr,socfpga-pll-clock" - for a PLL clock
+	"altr,socfpga-perip-clock" - The peripheral clock divided from the
+		PLL clock.
+- reg : shall be the control register offset from CLOCK_MANAGER's base for the clock.
+- clocks : shall be the input parent clock phandle for the clock. This is
+	either an oscillator or a pll output.
+- #clock-cells : from common clock binding, shall be set to 0.
+
+Optional properties:
+- fixed-divider : If clocks have a fixed divider value, use this property.
arch/arm/boot/dts/socfpga.dtsi +157 -0

163 lines not on this page · raw message

arch/arm/boot/dts/socfpga_cyclone5.dts +8 -0
index 3ae8a83..2495958 100644
@@ -33,6 +33,14 @@
 	};
 
 	soc {
+		clkmgr at ffd04000 {
+			clocks {
+				osc1 {
+					clock-frequency = <25000000>;
+				};
+			};
+		};
+
 		timer0 at ffc08000 {
 			clock-frequency = <100000000>;
 		};
arch/arm/boot/dts/socfpga_vt.dts +8 -0
index 1036eba..0bf035d 100644
@@ -33,6 +33,14 @@
 	};
 
 	soc {
+		clkmgr at ffd04000 {
+			clocks {
+				osc1 {
+					clock-frequency = <10000000>;
+				};
+			};
+		};
+
 		timer0 at ffc08000 {
 			clock-frequency = <7000000>;
 		};
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH v3 3/3 ARM: socfpga: Upgrade clk driver for socfpga to make use of dts clock entries

In reply to dinguyen at altera.com

From: Dinh Nguyen <[email protected]>

With this patch, the socfpga clk driver is able to query the clock and clock rates appropriately.

---
 arch/arm/mach-socfpga/socfpga.c |    6 ++
 drivers/clk/socfpga/clk.c       |  163 ++++++++++++++++++++++++++++++++++-----
 2 files changed, 148 insertions(+), 21 deletions(-)
arch/arm/mach-socfpga/socfpga.c +6 -0
index 2cae16c..46a0513 100644
@@ -15,6 +15,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 #include <linux/dw_apb_timer.h>
+#include <linux/clk-provider.h>
 #include <linux/irqchip.h>
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
@@ -29,6 +30,7 @@
 void __iomem *socfpga_scu_base_addr = ((void __iomem *)(SOCFPGA_SCU_VIRT_BASE));
 void __iomem *sys_manager_base_addr;
 void __iomem *rst_manager_base_addr;
+void __iomem *clk_mgr_base_addr;
 unsigned long cpu1start_addr;
 
 static struct map_desc scu_io_desc __initdata = {
@@ -77,6 +79,9 @@ void __init socfpga_sysmgr_init(void)
 
 	np = of_find_compatible_node(NULL, NULL, "altr,rst-mgr");
 	rst_manager_base_addr = of_iomap(np, 0);
+
+	np = of_find_compatible_node(NULL, NULL, "altr,clk-mgr");
+	clk_mgr_base_addr = of_iomap(np, 0);
 }
 
 static void __init socfpga_init_irq(void)
@@ -102,6 +107,7 @@ static void __init socfpga_cyclone5_init(void)
 {
 	l2x0_of_init(0, ~0UL);
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
+	of_clk_init(NULL);
 	socfpga_init_clocks();
 }
 
drivers/clk/socfpga/clk.c +142 -21

188 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#4 lore raw

PATCH v3 3/3 ARM: socfpga: Upgrade clk driver for socfpga to make use of dts clock entries

Quoted 6 lines · dinguyen at altera.com

From: Dinh Nguyen <[email protected]>

With this patch, the socfpga clk driver is able to query the clock and clock rates appropriately.

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#5 lore raw

PATCH v3 1/3 ARM: socfpga: Enable soft reset

In reply to dinguyen at altera.com
Quoted 10 lines · dinguyen at altera.com

From: Dinh Nguyen <[email protected]>

Enable a cold or warm reset to the HW from userspace.

Also fix a few sparse errors:

warning: symbol 'sys_manager_base_addr' was not declared. Should it be static?
warning: symbol 'rst_manager_base_addr' was not declared. Should it be static?

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#6 lore raw

PATCH v3 1/3 ARM: socfpga: Enable soft reset

Quoted 5 lines · Pavel Machek
Quoted 4 lines · dinguyen at altera.com

From: Dinh Nguyen <[email protected]>

Enable a cold or warm reset to the HW from userspace.

Quoted 8 lines
Quoted 6 lines

Also fix a few sparse errors:

warning: symbol 'sys_manager_base_addr' was not declared. Should it be static?
warning: symbol 'rst_manager_base_addr' was not declared. Should it be static?

Applied 1-3 to next/soc in arm-soc.

Thanks!

-Olof

#7 lore raw

PATCH v3 1/3 ARM: socfpga: Enable soft reset

Hi Olof,

Quoted 8 lines · Olof Johansson
Quoted 7 lines · Pavel Machek
Quoted 6 lines · dinguyen at altera.com

From: Dinh Nguyen <[email protected]>

Enable a cold or warm reset to the HW from userspace.

Also fix a few sparse errors:

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

warning: symbol 'sys_manager_base_addr' was not declared. Should it be static?
warning: symbol 'rst_manager_base_addr' was not declared. Should it be static?

Applied 1-3 to next/soc in arm-soc.

Thanks alot!

Dinh

Quoted 5 lines

Thanks!

-Olof