0048-BCM2708-Migrate-to-the-Common-Clock-Framework.patch 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. From 466743ec93a99240c1a5a04d65f490fd8370fbc3 Mon Sep 17 00:00:00 2001
  2. From: notro <notro@tronnes.org>
  3. Date: Sun, 6 Jul 2014 12:09:30 +0200
  4. Subject: [PATCH 048/114] BCM2708: Migrate to the Common Clock Framework
  5. As part of moving towards using Device Tree, the Common Clock Framework
  6. has to be used instead of the BCM2708 clock implementation.
  7. Selecting COMMON_CLK removes the need to set CLKDEV_LOOKUP and HAVE_CLK explicitly.
  8. CONFIG_ARCH_BCM2708_CHIPIT #ifdef's are removed. They are no longer in use.
  9. Signed-off-by: Noralf Tronnes <notro@tronnes.org>
  10. ---
  11. arch/arm/Kconfig | 3 +-
  12. arch/arm/mach-bcm2708/Makefile | 2 +-
  13. arch/arm/mach-bcm2708/bcm2708.c | 79 +++++++++++++++++------------------------
  14. arch/arm/mach-bcm2708/clock.c | 61 -------------------------------
  15. arch/arm/mach-bcm2708/clock.h | 24 -------------
  16. 5 files changed, 34 insertions(+), 135 deletions(-)
  17. delete mode 100644 arch/arm/mach-bcm2708/clock.c
  18. delete mode 100644 arch/arm/mach-bcm2708/clock.h
  19. --- a/arch/arm/Kconfig
  20. +++ b/arch/arm/Kconfig
  21. @@ -385,11 +385,10 @@ config ARCH_BCM2708
  22. bool "Broadcom BCM2708 family"
  23. select CPU_V6
  24. select ARM_AMBA
  25. - select HAVE_CLK
  26. select HAVE_SCHED_CLOCK
  27. select NEED_MACH_GPIO_H
  28. select NEED_MACH_MEMORY_H
  29. - select CLKDEV_LOOKUP
  30. + select COMMON_CLK
  31. select ARCH_HAS_CPUFREQ
  32. select GENERIC_CLOCKEVENTS
  33. select ARM_ERRATA_411920
  34. --- a/arch/arm/mach-bcm2708/Makefile
  35. +++ b/arch/arm/mach-bcm2708/Makefile
  36. @@ -2,6 +2,6 @@
  37. # Makefile for the linux kernel.
  38. #
  39. -obj-$(CONFIG_MACH_BCM2708) += clock.o bcm2708.o armctrl.o vcio.o power.o dma.o
  40. +obj-$(CONFIG_MACH_BCM2708) += bcm2708.o armctrl.o vcio.o power.o dma.o
  41. obj-$(CONFIG_BCM2708_GPIO) += bcm2708_gpio.o
  42. obj-$(CONFIG_BCM2708_VCMEM) += vc_mem.o
  43. --- a/arch/arm/mach-bcm2708/bcm2708.c
  44. +++ b/arch/arm/mach-bcm2708/bcm2708.c
  45. @@ -27,6 +27,8 @@
  46. #include <linux/interrupt.h>
  47. #include <linux/amba/bus.h>
  48. #include <linux/amba/clcd.h>
  49. +#include <linux/clk-provider.h>
  50. +#include <linux/clkdev.h>
  51. #include <linux/clockchips.h>
  52. #include <linux/cnt32_to_63.h>
  53. #include <linux/io.h>
  54. @@ -58,7 +60,6 @@
  55. #include "bcm2708.h"
  56. #include "armctrl.h"
  57. -#include "clock.h"
  58. #ifdef CONFIG_BCM_VC_CMA
  59. #include <linux/broadcom/vc_cma.h>
  60. @@ -84,7 +85,7 @@
  61. /* command line parameters */
  62. static unsigned boardrev, serial;
  63. -static unsigned uart_clock;
  64. +static unsigned uart_clock = UART0_CLOCK;
  65. static unsigned disk_led_gpio = 16;
  66. static unsigned disk_led_active_low = 1;
  67. static unsigned reboot_part = 0;
  68. @@ -196,51 +197,39 @@ static void __init bcm2708_clocksource_i
  69. }
  70. }
  71. +struct clk __init *bcm2708_clk_register(const char *name, unsigned long fixed_rate)
  72. +{
  73. + struct clk *clk;
  74. -/*
  75. - * These are fixed clocks.
  76. - */
  77. -static struct clk ref24_clk = {
  78. - .rate = UART0_CLOCK, /* The UART is clocked at 3MHz via APB_CLK */
  79. -};
  80. + clk = clk_register_fixed_rate(NULL, name, NULL, CLK_IS_ROOT,
  81. + fixed_rate);
  82. + if (IS_ERR(clk))
  83. + pr_err("%s not registered\n", name);
  84. -static struct clk osc_clk = {
  85. -#ifdef CONFIG_ARCH_BCM2708_CHIPIT
  86. - .rate = 27000000,
  87. -#else
  88. - .rate = 500000000, /* ARM clock is set from the VideoCore booter */
  89. -#endif
  90. -};
  91. + return clk;
  92. +}
  93. -/* warning - the USB needs a clock > 34MHz */
  94. +void __init bcm2708_register_clkdev(struct clk *clk, const char *name)
  95. +{
  96. + int ret;
  97. -static struct clk sdhost_clk = {
  98. -#ifdef CONFIG_ARCH_BCM2708_CHIPIT
  99. - .rate = 4000000, /* 4MHz */
  100. -#else
  101. - .rate = 250000000, /* 250MHz */
  102. -#endif
  103. -};
  104. + ret = clk_register_clkdev(clk, NULL, name);
  105. + if (ret)
  106. + pr_err("%s alias not registered\n", name);
  107. +}
  108. -static struct clk_lookup lookups[] = {
  109. - { /* UART0 */
  110. - .dev_id = "dev:f1",
  111. - .clk = &ref24_clk,
  112. - },
  113. - { /* USB */
  114. - .dev_id = "bcm2708_usb",
  115. - .clk = &osc_clk,
  116. - }, { /* SPI */
  117. - .dev_id = "bcm2708_spi.0",
  118. - .clk = &sdhost_clk,
  119. - }, { /* BSC0 */
  120. - .dev_id = "bcm2708_i2c.0",
  121. - .clk = &sdhost_clk,
  122. - }, { /* BSC1 */
  123. - .dev_id = "bcm2708_i2c.1",
  124. - .clk = &sdhost_clk,
  125. - }
  126. -};
  127. +void __init bcm2708_init_clocks(void)
  128. +{
  129. + struct clk *clk;
  130. +
  131. + clk = bcm2708_clk_register("uart0_clk", uart_clock);
  132. + bcm2708_register_clkdev(clk, "dev:f1");
  133. +
  134. + clk = bcm2708_clk_register("sdhost_clk", 250000000);
  135. + bcm2708_register_clkdev(clk, "bcm2708_spi.0");
  136. + bcm2708_register_clkdev(clk, "bcm2708_i2c.0");
  137. + bcm2708_register_clkdev(clk, "bcm2708_i2c.1");
  138. +}
  139. #define UART0_IRQ { IRQ_UART, 0 /*NO_IRQ*/ }
  140. #define UART0_DMA { 15, 14 }
  141. @@ -755,11 +744,7 @@ void __init bcm2708_init(void)
  142. printk("bcm2708.uart_clock = %d\n", uart_clock);
  143. pm_power_off = bcm2708_power_off;
  144. - if (uart_clock)
  145. - lookups[0].clk->rate = uart_clock;
  146. -
  147. - for (i = 0; i < ARRAY_SIZE(lookups); i++)
  148. - clkdev_add(&lookups[i]);
  149. + bcm2708_init_clocks();
  150. bcm_register_device(&bcm2708_dmaman_device);
  151. bcm_register_device(&bcm2708_vcio_device);
  152. --- a/arch/arm/mach-bcm2708/clock.c
  153. +++ /dev/null
  154. @@ -1,61 +0,0 @@
  155. -/*
  156. - * linux/arch/arm/mach-bcm2708/clock.c
  157. - *
  158. - * Copyright (C) 2010 Broadcom
  159. - *
  160. - * This program is free software; you can redistribute it and/or modify
  161. - * it under the terms of the GNU General Public License as published by
  162. - * the Free Software Foundation; either version 2 of the License, or
  163. - * (at your option) any later version.
  164. - *
  165. - * This program is distributed in the hope that it will be useful,
  166. - * but WITHOUT ANY WARRANTY; without even the implied warranty of
  167. - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  168. - * GNU General Public License for more details.
  169. - *
  170. - * You should have received a copy of the GNU General Public License
  171. - * along with this program; if not, write to the Free Software
  172. - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  173. - */
  174. -#include <linux/module.h>
  175. -#include <linux/kernel.h>
  176. -#include <linux/device.h>
  177. -#include <linux/list.h>
  178. -#include <linux/errno.h>
  179. -#include <linux/err.h>
  180. -#include <linux/string.h>
  181. -#include <linux/clk.h>
  182. -#include <linux/mutex.h>
  183. -
  184. -#include <asm/clkdev.h>
  185. -
  186. -#include "clock.h"
  187. -
  188. -int clk_enable(struct clk *clk)
  189. -{
  190. - return 0;
  191. -}
  192. -EXPORT_SYMBOL(clk_enable);
  193. -
  194. -void clk_disable(struct clk *clk)
  195. -{
  196. -}
  197. -EXPORT_SYMBOL(clk_disable);
  198. -
  199. -unsigned long clk_get_rate(struct clk *clk)
  200. -{
  201. - return clk->rate;
  202. -}
  203. -EXPORT_SYMBOL(clk_get_rate);
  204. -
  205. -long clk_round_rate(struct clk *clk, unsigned long rate)
  206. -{
  207. - return clk->rate;
  208. -}
  209. -EXPORT_SYMBOL(clk_round_rate);
  210. -
  211. -int clk_set_rate(struct clk *clk, unsigned long rate)
  212. -{
  213. - return -EIO;
  214. -}
  215. -EXPORT_SYMBOL(clk_set_rate);
  216. --- a/arch/arm/mach-bcm2708/clock.h
  217. +++ /dev/null
  218. @@ -1,24 +0,0 @@
  219. -/*
  220. - * linux/arch/arm/mach-bcm2708/clock.h
  221. - *
  222. - * Copyright (C) 2010 Broadcom
  223. - *
  224. - * This program is free software; you can redistribute it and/or modify
  225. - * it under the terms of the GNU General Public License as published by
  226. - * the Free Software Foundation; either version 2 of the License, or
  227. - * (at your option) any later version.
  228. - *
  229. - * This program is distributed in the hope that it will be useful,
  230. - * but WITHOUT ANY WARRANTY; without even the implied warranty of
  231. - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  232. - * GNU General Public License for more details.
  233. - *
  234. - * You should have received a copy of the GNU General Public License
  235. - * along with this program; if not, write to the Free Software
  236. - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  237. - */
  238. -struct module;
  239. -
  240. -struct clk {
  241. - unsigned long rate;
  242. -};