aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSoren Brinkmann <soren.brinkmann@xilinx.com>2013-05-13 13:46:38 -0400
committerMichal Simek <michal.simek@xilinx.com>2013-05-27 03:21:22 -0400
commit30e1e28598c2674c133148d8aec6d431d7acd314 (patch)
treee17a5fba2151cf6d32d0f39b9d69910f85b71a9f
parent0ee52b157b8ed88550ddd6291e54bb4bfabde364 (diff)
arm: zynq: Migrate platform to clock controller
Migrate the Zynq platform and its drivers to use the new clock controller driver. Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com> Cc: John Stultz <john.stultz@linaro.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jiri Slaby <jslaby@suse.cz> Cc: linux-serial@vger.kernel.org Signed-off-by: Michal Simek <michal.simek@xilinx.com> Acked-by: Mike Turquette <mturquette@linaro.org>
-rw-r--r--arch/arm/boot/dts/zynq-7000.dtsi71
-rw-r--r--arch/arm/boot/dts/zynq-zc702.dts4
-rw-r--r--arch/arm/mach-zynq/slcr.c2
-rw-r--r--drivers/clk/Makefile2
-rw-r--r--drivers/clk/zynq/Makefile3
-rw-r--r--drivers/clocksource/cadence_ttc_timer.c23
-rw-r--r--drivers/tty/serial/xilinx_uartps.c85
-rw-r--r--include/linux/clk/zynq.h8
8 files changed, 118 insertions, 80 deletions
diff --git a/arch/arm/boot/dts/zynq-7000.dtsi b/arch/arm/boot/dts/zynq-7000.dtsi
index 14fb2e609bab..0dbee2c23905 100644
--- a/arch/arm/boot/dts/zynq-7000.dtsi
+++ b/arch/arm/boot/dts/zynq-7000.dtsi
@@ -49,16 +49,18 @@
49 49
50 uart0: uart@e0000000 { 50 uart0: uart@e0000000 {
51 compatible = "xlnx,xuartps"; 51 compatible = "xlnx,xuartps";
52 clocks = <&clkc 23>, <&clkc 40>;
53 clock-names = "ref_clk", "aper_clk";
52 reg = <0xE0000000 0x1000>; 54 reg = <0xE0000000 0x1000>;
53 interrupts = <0 27 4>; 55 interrupts = <0 27 4>;
54 clocks = <&uart_clk 0>;
55 }; 56 };
56 57
57 uart1: uart@e0001000 { 58 uart1: uart@e0001000 {
58 compatible = "xlnx,xuartps"; 59 compatible = "xlnx,xuartps";
60 clocks = <&clkc 24>, <&clkc 41>;
61 clock-names = "ref_clk", "aper_clk";
59 reg = <0xE0001000 0x1000>; 62 reg = <0xE0001000 0x1000>;
60 interrupts = <0 50 4>; 63 interrupts = <0 50 4>;
61 clocks = <&uart_clk 1>;
62 }; 64 };
63 65
64 slcr: slcr@f8000000 { 66 slcr: slcr@f8000000 {
@@ -69,50 +71,21 @@
69 #address-cells = <1>; 71 #address-cells = <1>;
70 #size-cells = <0>; 72 #size-cells = <0>;
71 73
72 ps_clk: ps_clk { 74 clkc: clkc {
73 #clock-cells = <0>;
74 compatible = "fixed-clock";
75 /* clock-frequency set in board-specific file */
76 clock-output-names = "ps_clk";
77 };
78 armpll: armpll {
79 #clock-cells = <0>;
80 compatible = "xlnx,zynq-pll";
81 clocks = <&ps_clk>;
82 reg = <0x100 0x110>;
83 clock-output-names = "armpll";
84 };
85 ddrpll: ddrpll {
86 #clock-cells = <0>;
87 compatible = "xlnx,zynq-pll";
88 clocks = <&ps_clk>;
89 reg = <0x104 0x114>;
90 clock-output-names = "ddrpll";
91 };
92 iopll: iopll {
93 #clock-cells = <0>;
94 compatible = "xlnx,zynq-pll";
95 clocks = <&ps_clk>;
96 reg = <0x108 0x118>;
97 clock-output-names = "iopll";
98 };
99 uart_clk: uart_clk {
100 #clock-cells = <1>;
101 compatible = "xlnx,zynq-periph-clock";
102 clocks = <&iopll &armpll &ddrpll>;
103 reg = <0x154>;
104 clock-output-names = "uart0_ref_clk",
105 "uart1_ref_clk";
106 };
107 cpu_clk: cpu_clk {
108 #clock-cells = <1>; 75 #clock-cells = <1>;
109 compatible = "xlnx,zynq-cpu-clock"; 76 compatible = "xlnx,ps7-clkc";
110 clocks = <&iopll &armpll &ddrpll>; 77 ps-clk-frequency = <33333333>;
111 reg = <0x120 0x1C4>; 78 clock-output-names = "armpll", "ddrpll", "iopll", "cpu_6or4x",
112 clock-output-names = "cpu_6x4x", 79 "cpu_3or2x", "cpu_2x", "cpu_1x", "ddr2x", "ddr3x",
113 "cpu_3x2x", 80 "dci", "lqspi", "smc", "pcap", "gem0", "gem1",
114 "cpu_2x", 81 "fclk0", "fclk1", "fclk2", "fclk3", "can0", "can1",
115 "cpu_1x"; 82 "sdio0", "sdio1", "uart0", "uart1", "spi0", "spi1",
83 "dma", "usb0_aper", "usb1_aper", "gem0_aper",
84 "gem1_aper", "sdio0_aper", "sdio1_aper",
85 "spi0_aper", "spi1_aper", "can0_aper", "can1_aper",
86 "i2c0_aper", "i2c1_aper", "uart0_aper", "uart1_aper",
87 "gpio_aper", "lqspi_aper", "smc_aper", "swdt",
88 "dbg_trc", "dbg_apb";
116 }; 89 };
117 }; 90 };
118 }; 91 };
@@ -121,9 +94,8 @@
121 interrupt-parent = <&intc>; 94 interrupt-parent = <&intc>;
122 interrupts = < 0 10 4 0 11 4 0 12 4 >; 95 interrupts = < 0 10 4 0 11 4 0 12 4 >;
123 compatible = "cdns,ttc"; 96 compatible = "cdns,ttc";
97 clocks = <&clkc 6>;
124 reg = <0xF8001000 0x1000>; 98 reg = <0xF8001000 0x1000>;
125 clocks = <&cpu_clk 3>;
126 clock-names = "cpu_1x";
127 clock-ranges; 99 clock-ranges;
128 }; 100 };
129 101
@@ -131,9 +103,8 @@
131 interrupt-parent = <&intc>; 103 interrupt-parent = <&intc>;
132 interrupts = < 0 37 4 0 38 4 0 39 4 >; 104 interrupts = < 0 37 4 0 38 4 0 39 4 >;
133 compatible = "cdns,ttc"; 105 compatible = "cdns,ttc";
106 clocks = <&clkc 6>;
134 reg = <0xF8002000 0x1000>; 107 reg = <0xF8002000 0x1000>;
135 clocks = <&cpu_clk 3>;
136 clock-names = "cpu_1x";
137 clock-ranges; 108 clock-ranges;
138 }; 109 };
139 scutimer: scutimer@f8f00600 { 110 scutimer: scutimer@f8f00600 {
@@ -141,7 +112,7 @@
141 interrupts = < 1 13 0x301 >; 112 interrupts = < 1 13 0x301 >;
142 compatible = "arm,cortex-a9-twd-timer"; 113 compatible = "arm,cortex-a9-twd-timer";
143 reg = < 0xf8f00600 0x20 >; 114 reg = < 0xf8f00600 0x20 >;
144 clocks = <&cpu_clk 1>; 115 clocks = <&clkc 4>;
145 } ; 116 } ;
146 }; 117 };
147}; 118};
diff --git a/arch/arm/boot/dts/zynq-zc702.dts b/arch/arm/boot/dts/zynq-zc702.dts
index 86f44d5b0265..e25a307438ad 100644
--- a/arch/arm/boot/dts/zynq-zc702.dts
+++ b/arch/arm/boot/dts/zynq-zc702.dts
@@ -28,7 +28,3 @@
28 }; 28 };
29 29
30}; 30};
31
32&ps_clk {
33 clock-frequency = <33333330>;
34};
diff --git a/arch/arm/mach-zynq/slcr.c b/arch/arm/mach-zynq/slcr.c
index c70969b9c258..50d008d8f87f 100644
--- a/arch/arm/mach-zynq/slcr.c
+++ b/arch/arm/mach-zynq/slcr.c
@@ -117,7 +117,7 @@ int __init zynq_slcr_init(void)
117 117
118 pr_info("%s mapped to %p\n", np->name, zynq_slcr_base); 118 pr_info("%s mapped to %p\n", np->name, zynq_slcr_base);
119 119
120 xilinx_zynq_clocks_init(zynq_slcr_base); 120 zynq_clock_init(zynq_slcr_base);
121 121
122 of_node_put(np); 122 of_node_put(np);
123 123
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 137d3e730f86..fa435bcf9f1a 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -27,7 +27,7 @@ obj-$(CONFIG_MACH_LOONGSON1) += clk-ls1x.o
27obj-$(CONFIG_ARCH_SUNXI) += sunxi/ 27obj-$(CONFIG_ARCH_SUNXI) += sunxi/
28obj-$(CONFIG_ARCH_U8500) += ux500/ 28obj-$(CONFIG_ARCH_U8500) += ux500/
29obj-$(CONFIG_ARCH_VT8500) += clk-vt8500.o 29obj-$(CONFIG_ARCH_VT8500) += clk-vt8500.o
30obj-$(CONFIG_ARCH_ZYNQ) += clk-zynq.o 30obj-$(CONFIG_ARCH_ZYNQ) += zynq/
31obj-$(CONFIG_ARCH_TEGRA) += tegra/ 31obj-$(CONFIG_ARCH_TEGRA) += tegra/
32obj-$(CONFIG_PLAT_SAMSUNG) += samsung/ 32obj-$(CONFIG_PLAT_SAMSUNG) += samsung/
33 33
diff --git a/drivers/clk/zynq/Makefile b/drivers/clk/zynq/Makefile
new file mode 100644
index 000000000000..156d923f4fa9
--- /dev/null
+++ b/drivers/clk/zynq/Makefile
@@ -0,0 +1,3 @@
1# Zynq clock specific Makefile
2
3obj-$(CONFIG_ARCH_ZYNQ) += clkc.o pll.o
diff --git a/drivers/clocksource/cadence_ttc_timer.c b/drivers/clocksource/cadence_ttc_timer.c
index 685bc60e210a..4cbe28c74631 100644
--- a/drivers/clocksource/cadence_ttc_timer.c
+++ b/drivers/clocksource/cadence_ttc_timer.c
@@ -51,6 +51,8 @@
51 51
52#define TTC_CNT_CNTRL_DISABLE_MASK 0x1 52#define TTC_CNT_CNTRL_DISABLE_MASK 0x1
53 53
54#define TTC_CLK_CNTRL_CSRC_MASK (1 << 5) /* clock source */
55
54/* 56/*
55 * Setup the timers to use pre-scaling, using a fixed value for now that will 57 * Setup the timers to use pre-scaling, using a fixed value for now that will
56 * work across most input frequency, but it may need to be more dynamic 58 * work across most input frequency, but it may need to be more dynamic
@@ -396,8 +398,9 @@ static void __init ttc_timer_init(struct device_node *timer)
396{ 398{
397 unsigned int irq; 399 unsigned int irq;
398 void __iomem *timer_baseaddr; 400 void __iomem *timer_baseaddr;
399 struct clk *clk; 401 struct clk *clk_cs, *clk_ce;
400 static int initialized; 402 static int initialized;
403 int clksel;
401 404
402 if (initialized) 405 if (initialized)
403 return; 406 return;
@@ -421,14 +424,24 @@ static void __init ttc_timer_init(struct device_node *timer)
421 BUG(); 424 BUG();
422 } 425 }
423 426
424 clk = of_clk_get_by_name(timer, "cpu_1x"); 427 clksel = __raw_readl(timer_baseaddr + TTC_CLK_CNTRL_OFFSET);
425 if (IS_ERR(clk)) { 428 clksel = !!(clksel & TTC_CLK_CNTRL_CSRC_MASK);
429 clk_cs = of_clk_get(timer, clksel);
430 if (IS_ERR(clk_cs)) {
431 pr_err("ERROR: timer input clock not found\n");
432 BUG();
433 }
434
435 clksel = __raw_readl(timer_baseaddr + 4 + TTC_CLK_CNTRL_OFFSET);
436 clksel = !!(clksel & TTC_CLK_CNTRL_CSRC_MASK);
437 clk_ce = of_clk_get(timer, clksel);
438 if (IS_ERR(clk_ce)) {
426 pr_err("ERROR: timer input clock not found\n"); 439 pr_err("ERROR: timer input clock not found\n");
427 BUG(); 440 BUG();
428 } 441 }
429 442
430 ttc_setup_clocksource(clk, timer_baseaddr); 443 ttc_setup_clocksource(clk_cs, timer_baseaddr);
431 ttc_setup_clockevent(clk, timer_baseaddr + 4, irq); 444 ttc_setup_clockevent(clk_ce, timer_baseaddr + 4, irq);
432 445
433 pr_info("%s #0 at %p, irq=%d\n", timer->name, timer_baseaddr, irq); 446 pr_info("%s #0 at %p, irq=%d\n", timer->name, timer_baseaddr, irq);
434} 447}
diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c
index 4e5c77834c50..a4a3028103e3 100644
--- a/drivers/tty/serial/xilinx_uartps.c
+++ b/drivers/tty/serial/xilinx_uartps.c
@@ -14,6 +14,7 @@
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <linux/serial.h> 15#include <linux/serial.h>
16#include <linux/serial_core.h> 16#include <linux/serial_core.h>
17#include <linux/slab.h>
17#include <linux/tty.h> 18#include <linux/tty.h>
18#include <linux/tty_flip.h> 19#include <linux/tty_flip.h>
19#include <linux/console.h> 20#include <linux/console.h>
@@ -139,6 +140,16 @@
139#define XUARTPS_SR_RXTRIG 0x00000001 /* Rx Trigger */ 140#define XUARTPS_SR_RXTRIG 0x00000001 /* Rx Trigger */
140 141
141/** 142/**
143 * struct xuartps - device data
144 * @refclk Reference clock
145 * @aperclk APB clock
146 */
147struct xuartps {
148 struct clk *refclk;
149 struct clk *aperclk;
150};
151
152/**
142 * xuartps_isr - Interrupt handler 153 * xuartps_isr - Interrupt handler
143 * @irq: Irq number 154 * @irq: Irq number
144 * @dev_id: Id of the port 155 * @dev_id: Id of the port
@@ -936,34 +947,55 @@ static int xuartps_probe(struct platform_device *pdev)
936 int rc; 947 int rc;
937 struct uart_port *port; 948 struct uart_port *port;
938 struct resource *res, *res2; 949 struct resource *res, *res2;
939 struct clk *clk; 950 struct xuartps *xuartps_data;
940 951
941 clk = of_clk_get(pdev->dev.of_node, 0); 952 xuartps_data = kzalloc(sizeof(*xuartps_data), GFP_KERNEL);
942 if (IS_ERR(clk)) { 953 if (!xuartps_data)
943 dev_err(&pdev->dev, "no clock specified\n"); 954 return -ENOMEM;
944 return PTR_ERR(clk); 955
956 xuartps_data->aperclk = clk_get(&pdev->dev, "aper_clk");
957 if (IS_ERR(xuartps_data->aperclk)) {
958 dev_err(&pdev->dev, "aper_clk clock not found.\n");
959 rc = PTR_ERR(xuartps_data->aperclk);
960 goto err_out_free;
961 }
962 xuartps_data->refclk = clk_get(&pdev->dev, "ref_clk");
963 if (IS_ERR(xuartps_data->refclk)) {
964 dev_err(&pdev->dev, "ref_clk clock not found.\n");
965 rc = PTR_ERR(xuartps_data->refclk);
966 goto err_out_clk_put_aper;
945 } 967 }
946 968
947 rc = clk_prepare_enable(clk); 969 rc = clk_prepare_enable(xuartps_data->aperclk);
970 if (rc) {
971 dev_err(&pdev->dev, "Unable to enable APER clock.\n");
972 goto err_out_clk_put;
973 }
974 rc = clk_prepare_enable(xuartps_data->refclk);
948 if (rc) { 975 if (rc) {
949 dev_err(&pdev->dev, "could not enable clock\n"); 976 dev_err(&pdev->dev, "Unable to enable device clock.\n");
950 return -EBUSY; 977 goto err_out_clk_dis_aper;
951 } 978 }
952 979
953 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 980 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
954 if (!res) 981 if (!res) {
955 return -ENODEV; 982 rc = -ENODEV;
983 goto err_out_clk_disable;
984 }
956 985
957 res2 = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 986 res2 = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
958 if (!res2) 987 if (!res2) {
959 return -ENODEV; 988 rc = -ENODEV;
989 goto err_out_clk_disable;
990 }
960 991
961 /* Initialize the port structure */ 992 /* Initialize the port structure */
962 port = xuartps_get_port(); 993 port = xuartps_get_port();
963 994
964 if (!port) { 995 if (!port) {
965 dev_err(&pdev->dev, "Cannot get uart_port structure\n"); 996 dev_err(&pdev->dev, "Cannot get uart_port structure\n");
966 return -ENODEV; 997 rc = -ENODEV;
998 goto err_out_clk_disable;
967 } else { 999 } else {
968 /* Register the port. 1000 /* Register the port.
969 * This function also registers this device with the tty layer 1001 * This function also registers this device with the tty layer
@@ -972,18 +1004,31 @@ static int xuartps_probe(struct platform_device *pdev)
972 port->mapbase = res->start; 1004 port->mapbase = res->start;
973 port->irq = res2->start; 1005 port->irq = res2->start;
974 port->dev = &pdev->dev; 1006 port->dev = &pdev->dev;
975 port->uartclk = clk_get_rate(clk); 1007 port->uartclk = clk_get_rate(xuartps_data->refclk);
976 port->private_data = clk; 1008 port->private_data = xuartps_data;
977 dev_set_drvdata(&pdev->dev, port); 1009 dev_set_drvdata(&pdev->dev, port);
978 rc = uart_add_one_port(&xuartps_uart_driver, port); 1010 rc = uart_add_one_port(&xuartps_uart_driver, port);
979 if (rc) { 1011 if (rc) {
980 dev_err(&pdev->dev, 1012 dev_err(&pdev->dev,
981 "uart_add_one_port() failed; err=%i\n", rc); 1013 "uart_add_one_port() failed; err=%i\n", rc);
982 dev_set_drvdata(&pdev->dev, NULL); 1014 dev_set_drvdata(&pdev->dev, NULL);
983 return rc; 1015 goto err_out_clk_disable;
984 } 1016 }
985 return 0; 1017 return 0;
986 } 1018 }
1019
1020err_out_clk_disable:
1021 clk_disable_unprepare(xuartps_data->refclk);
1022err_out_clk_dis_aper:
1023 clk_disable_unprepare(xuartps_data->aperclk);
1024err_out_clk_put:
1025 clk_put(xuartps_data->refclk);
1026err_out_clk_put_aper:
1027 clk_put(xuartps_data->aperclk);
1028err_out_free:
1029 kfree(xuartps_data);
1030
1031 return rc;
987} 1032}
988 1033
989/** 1034/**
@@ -995,14 +1040,18 @@ static int xuartps_probe(struct platform_device *pdev)
995static int xuartps_remove(struct platform_device *pdev) 1040static int xuartps_remove(struct platform_device *pdev)
996{ 1041{
997 struct uart_port *port = dev_get_drvdata(&pdev->dev); 1042 struct uart_port *port = dev_get_drvdata(&pdev->dev);
998 struct clk *clk = port->private_data; 1043 struct xuartps *xuartps_data = port->private_data;
999 int rc; 1044 int rc;
1000 1045
1001 /* Remove the xuartps port from the serial core */ 1046 /* Remove the xuartps port from the serial core */
1002 rc = uart_remove_one_port(&xuartps_uart_driver, port); 1047 rc = uart_remove_one_port(&xuartps_uart_driver, port);
1003 dev_set_drvdata(&pdev->dev, NULL); 1048 dev_set_drvdata(&pdev->dev, NULL);
1004 port->mapbase = 0; 1049 port->mapbase = 0;
1005 clk_disable_unprepare(clk); 1050 clk_disable_unprepare(xuartps_data->refclk);
1051 clk_disable_unprepare(xuartps_data->aperclk);
1052 clk_put(xuartps_data->refclk);
1053 clk_put(xuartps_data->aperclk);
1054 kfree(xuartps_data);
1006 return rc; 1055 return rc;
1007} 1056}
1008 1057
diff --git a/include/linux/clk/zynq.h b/include/linux/clk/zynq.h
index 56be7cd9aa8b..e062d317ccce 100644
--- a/include/linux/clk/zynq.h
+++ b/include/linux/clk/zynq.h
@@ -1,4 +1,5 @@
1/* 1/*
2 * Copyright (C) 2013 Xilinx Inc.
2 * Copyright (C) 2012 National Instruments 3 * Copyright (C) 2012 National Instruments
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
@@ -19,6 +20,11 @@
19#ifndef __LINUX_CLK_ZYNQ_H_ 20#ifndef __LINUX_CLK_ZYNQ_H_
20#define __LINUX_CLK_ZYNQ_H_ 21#define __LINUX_CLK_ZYNQ_H_
21 22
22void __init xilinx_zynq_clocks_init(void __iomem *slcr); 23#include <linux/spinlock.h>
23 24
25void zynq_clock_init(void __iomem *slcr);
26
27struct clk *clk_register_zynq_pll(const char *name, const char *parent,
28 void __iomem *pll_ctrl, void __iomem *pll_status, u8 lock_index,
29 spinlock_t *lock);
24#endif 30#endif