clk-bcm2835.c 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600
  1. /*
  2. * Copyright (C) 2010,2015 Broadcom
  3. * Copyright (C) 2012 Stephen Warren
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. /**
  20. * DOC: BCM2835 CPRMAN (clock manager for the "audio" domain)
  21. *
  22. * The clock tree on the 2835 has several levels. There's a root
  23. * oscillator running at 19.2Mhz. After the oscillator there are 5
  24. * PLLs, roughly divided as "camera", "ARM", "core", "DSI displays",
  25. * and "HDMI displays". Those 5 PLLs each can divide their output to
  26. * produce up to 4 channels. Finally, there is the level of clocks to
  27. * be consumed by other hardware components (like "H264" or "HDMI
  28. * state machine"), which divide off of some subset of the PLL
  29. * channels.
  30. *
  31. * All of the clocks in the tree are exposed in the DT, because the DT
  32. * may want to make assignments of the final layer of clocks to the
  33. * PLL channels, and some components of the hardware will actually
  34. * skip layers of the tree (for example, the pixel clock comes
  35. * directly from the PLLH PIX channel without using a CM_*CTL clock
  36. * generator).
  37. */
  38. #include <linux/clk-provider.h>
  39. #include <linux/clkdev.h>
  40. #include <linux/clk/bcm2835.h>
  41. #include <linux/module.h>
  42. #include <linux/of.h>
  43. #include <linux/platform_device.h>
  44. #include <linux/slab.h>
  45. #include <dt-bindings/clock/bcm2835.h>
  46. #define CM_PASSWORD 0x5a000000
  47. #define CM_GNRICCTL 0x000
  48. #define CM_GNRICDIV 0x004
  49. # define CM_DIV_FRAC_BITS 12
  50. #define CM_VPUCTL 0x008
  51. #define CM_VPUDIV 0x00c
  52. #define CM_SYSCTL 0x010
  53. #define CM_SYSDIV 0x014
  54. #define CM_PERIACTL 0x018
  55. #define CM_PERIADIV 0x01c
  56. #define CM_PERIICTL 0x020
  57. #define CM_PERIIDIV 0x024
  58. #define CM_H264CTL 0x028
  59. #define CM_H264DIV 0x02c
  60. #define CM_ISPCTL 0x030
  61. #define CM_ISPDIV 0x034
  62. #define CM_V3DCTL 0x038
  63. #define CM_V3DDIV 0x03c
  64. #define CM_CAM0CTL 0x040
  65. #define CM_CAM0DIV 0x044
  66. #define CM_CAM1CTL 0x048
  67. #define CM_CAM1DIV 0x04c
  68. #define CM_CCP2CTL 0x050
  69. #define CM_CCP2DIV 0x054
  70. #define CM_DSI0ECTL 0x058
  71. #define CM_DSI0EDIV 0x05c
  72. #define CM_DSI0PCTL 0x060
  73. #define CM_DSI0PDIV 0x064
  74. #define CM_DPICTL 0x068
  75. #define CM_DPIDIV 0x06c
  76. #define CM_GP0CTL 0x070
  77. #define CM_GP0DIV 0x074
  78. #define CM_GP1CTL 0x078
  79. #define CM_GP1DIV 0x07c
  80. #define CM_GP2CTL 0x080
  81. #define CM_GP2DIV 0x084
  82. #define CM_HSMCTL 0x088
  83. #define CM_HSMDIV 0x08c
  84. #define CM_OTPCTL 0x090
  85. #define CM_OTPDIV 0x094
  86. #define CM_PWMCTL 0x0a0
  87. #define CM_PWMDIV 0x0a4
  88. #define CM_SMICTL 0x0b0
  89. #define CM_SMIDIV 0x0b4
  90. #define CM_TSENSCTL 0x0e0
  91. #define CM_TSENSDIV 0x0e4
  92. #define CM_TIMERCTL 0x0e8
  93. #define CM_TIMERDIV 0x0ec
  94. #define CM_UARTCTL 0x0f0
  95. #define CM_UARTDIV 0x0f4
  96. #define CM_VECCTL 0x0f8
  97. #define CM_VECDIV 0x0fc
  98. #define CM_PULSECTL 0x190
  99. #define CM_PULSEDIV 0x194
  100. #define CM_SDCCTL 0x1a8
  101. #define CM_SDCDIV 0x1ac
  102. #define CM_ARMCTL 0x1b0
  103. #define CM_EMMCCTL 0x1c0
  104. #define CM_EMMCDIV 0x1c4
  105. /* General bits for the CM_*CTL regs */
  106. # define CM_ENABLE BIT(4)
  107. # define CM_KILL BIT(5)
  108. # define CM_GATE_BIT 6
  109. # define CM_GATE BIT(CM_GATE_BIT)
  110. # define CM_BUSY BIT(7)
  111. # define CM_BUSYD BIT(8)
  112. # define CM_SRC_SHIFT 0
  113. # define CM_SRC_BITS 4
  114. # define CM_SRC_MASK 0xf
  115. # define CM_SRC_GND 0
  116. # define CM_SRC_OSC 1
  117. # define CM_SRC_TESTDEBUG0 2
  118. # define CM_SRC_TESTDEBUG1 3
  119. # define CM_SRC_PLLA_CORE 4
  120. # define CM_SRC_PLLA_PER 4
  121. # define CM_SRC_PLLC_CORE0 5
  122. # define CM_SRC_PLLC_PER 5
  123. # define CM_SRC_PLLC_CORE1 8
  124. # define CM_SRC_PLLD_CORE 6
  125. # define CM_SRC_PLLD_PER 6
  126. # define CM_SRC_PLLH_AUX 7
  127. # define CM_SRC_PLLC_CORE1 8
  128. # define CM_SRC_PLLC_CORE2 9
  129. #define CM_OSCCOUNT 0x100
  130. #define CM_PLLA 0x104
  131. # define CM_PLL_ANARST BIT(8)
  132. # define CM_PLLA_HOLDPER BIT(7)
  133. # define CM_PLLA_LOADPER BIT(6)
  134. # define CM_PLLA_HOLDCORE BIT(5)
  135. # define CM_PLLA_LOADCORE BIT(4)
  136. # define CM_PLLA_HOLDCCP2 BIT(3)
  137. # define CM_PLLA_LOADCCP2 BIT(2)
  138. # define CM_PLLA_HOLDDSI0 BIT(1)
  139. # define CM_PLLA_LOADDSI0 BIT(0)
  140. #define CM_PLLC 0x108
  141. # define CM_PLLC_HOLDPER BIT(7)
  142. # define CM_PLLC_LOADPER BIT(6)
  143. # define CM_PLLC_HOLDCORE2 BIT(5)
  144. # define CM_PLLC_LOADCORE2 BIT(4)
  145. # define CM_PLLC_HOLDCORE1 BIT(3)
  146. # define CM_PLLC_LOADCORE1 BIT(2)
  147. # define CM_PLLC_HOLDCORE0 BIT(1)
  148. # define CM_PLLC_LOADCORE0 BIT(0)
  149. #define CM_PLLD 0x10c
  150. # define CM_PLLD_HOLDPER BIT(7)
  151. # define CM_PLLD_LOADPER BIT(6)
  152. # define CM_PLLD_HOLDCORE BIT(5)
  153. # define CM_PLLD_LOADCORE BIT(4)
  154. # define CM_PLLD_HOLDDSI1 BIT(3)
  155. # define CM_PLLD_LOADDSI1 BIT(2)
  156. # define CM_PLLD_HOLDDSI0 BIT(1)
  157. # define CM_PLLD_LOADDSI0 BIT(0)
  158. #define CM_PLLH 0x110
  159. # define CM_PLLH_LOADRCAL BIT(2)
  160. # define CM_PLLH_LOADAUX BIT(1)
  161. # define CM_PLLH_LOADPIX BIT(0)
  162. #define CM_LOCK 0x114
  163. # define CM_LOCK_FLOCKH BIT(12)
  164. # define CM_LOCK_FLOCKD BIT(11)
  165. # define CM_LOCK_FLOCKC BIT(10)
  166. # define CM_LOCK_FLOCKB BIT(9)
  167. # define CM_LOCK_FLOCKA BIT(8)
  168. #define CM_EVENT 0x118
  169. #define CM_DSI1ECTL 0x158
  170. #define CM_DSI1EDIV 0x15c
  171. #define CM_DSI1PCTL 0x160
  172. #define CM_DSI1PDIV 0x164
  173. #define CM_DFTCTL 0x168
  174. #define CM_DFTDIV 0x16c
  175. #define CM_PLLB 0x170
  176. # define CM_PLLB_HOLDARM BIT(1)
  177. # define CM_PLLB_LOADARM BIT(0)
  178. #define A2W_PLLA_CTRL 0x1100
  179. #define A2W_PLLC_CTRL 0x1120
  180. #define A2W_PLLD_CTRL 0x1140
  181. #define A2W_PLLH_CTRL 0x1160
  182. #define A2W_PLLB_CTRL 0x11e0
  183. # define A2W_PLL_CTRL_PRST_DISABLE BIT(17)
  184. # define A2W_PLL_CTRL_PWRDN BIT(16)
  185. # define A2W_PLL_CTRL_PDIV_MASK 0x000007000
  186. # define A2W_PLL_CTRL_PDIV_SHIFT 12
  187. # define A2W_PLL_CTRL_NDIV_MASK 0x0000003ff
  188. # define A2W_PLL_CTRL_NDIV_SHIFT 0
  189. #define A2W_PLLA_ANA0 0x1010
  190. #define A2W_PLLC_ANA0 0x1030
  191. #define A2W_PLLD_ANA0 0x1050
  192. #define A2W_PLLH_ANA0 0x1070
  193. #define A2W_PLLB_ANA0 0x10f0
  194. #define A2W_PLL_KA_SHIFT 7
  195. #define A2W_PLL_KA_MASK GENMASK(9, 7)
  196. #define A2W_PLL_KI_SHIFT 19
  197. #define A2W_PLL_KI_MASK GENMASK(21, 19)
  198. #define A2W_PLL_KP_SHIFT 15
  199. #define A2W_PLL_KP_MASK GENMASK(18, 15)
  200. #define A2W_PLLH_KA_SHIFT 19
  201. #define A2W_PLLH_KA_MASK GENMASK(21, 19)
  202. #define A2W_PLLH_KI_LOW_SHIFT 22
  203. #define A2W_PLLH_KI_LOW_MASK GENMASK(23, 22)
  204. #define A2W_PLLH_KI_HIGH_SHIFT 0
  205. #define A2W_PLLH_KI_HIGH_MASK GENMASK(0, 0)
  206. #define A2W_PLLH_KP_SHIFT 1
  207. #define A2W_PLLH_KP_MASK GENMASK(4, 1)
  208. #define A2W_XOSC_CTRL 0x1190
  209. # define A2W_XOSC_CTRL_PLLB_ENABLE BIT(7)
  210. # define A2W_XOSC_CTRL_PLLA_ENABLE BIT(6)
  211. # define A2W_XOSC_CTRL_PLLD_ENABLE BIT(5)
  212. # define A2W_XOSC_CTRL_DDR_ENABLE BIT(4)
  213. # define A2W_XOSC_CTRL_CPR1_ENABLE BIT(3)
  214. # define A2W_XOSC_CTRL_USB_ENABLE BIT(2)
  215. # define A2W_XOSC_CTRL_HDMI_ENABLE BIT(1)
  216. # define A2W_XOSC_CTRL_PLLC_ENABLE BIT(0)
  217. #define A2W_PLLA_FRAC 0x1200
  218. #define A2W_PLLC_FRAC 0x1220
  219. #define A2W_PLLD_FRAC 0x1240
  220. #define A2W_PLLH_FRAC 0x1260
  221. #define A2W_PLLB_FRAC 0x12e0
  222. # define A2W_PLL_FRAC_MASK ((1 << A2W_PLL_FRAC_BITS) - 1)
  223. # define A2W_PLL_FRAC_BITS 20
  224. #define A2W_PLL_CHANNEL_DISABLE BIT(8)
  225. #define A2W_PLL_DIV_BITS 8
  226. #define A2W_PLL_DIV_SHIFT 0
  227. #define A2W_PLLA_DSI0 0x1300
  228. #define A2W_PLLA_CORE 0x1400
  229. #define A2W_PLLA_PER 0x1500
  230. #define A2W_PLLA_CCP2 0x1600
  231. #define A2W_PLLC_CORE2 0x1320
  232. #define A2W_PLLC_CORE1 0x1420
  233. #define A2W_PLLC_PER 0x1520
  234. #define A2W_PLLC_CORE0 0x1620
  235. #define A2W_PLLD_DSI0 0x1340
  236. #define A2W_PLLD_CORE 0x1440
  237. #define A2W_PLLD_PER 0x1540
  238. #define A2W_PLLD_DSI1 0x1640
  239. #define A2W_PLLH_AUX 0x1360
  240. #define A2W_PLLH_RCAL 0x1460
  241. #define A2W_PLLH_PIX 0x1560
  242. #define A2W_PLLH_STS 0x1660
  243. #define A2W_PLLH_CTRLR 0x1960
  244. #define A2W_PLLH_FRACR 0x1a60
  245. #define A2W_PLLH_AUXR 0x1b60
  246. #define A2W_PLLH_RCALR 0x1c60
  247. #define A2W_PLLH_PIXR 0x1d60
  248. #define A2W_PLLH_STSR 0x1e60
  249. #define A2W_PLLB_ARM 0x13e0
  250. #define A2W_PLLB_SP0 0x14e0
  251. #define A2W_PLLB_SP1 0x15e0
  252. #define A2W_PLLB_SP2 0x16e0
  253. #define LOCK_TIMEOUT_NS 100000000
  254. #define BCM2835_MAX_FB_RATE 1750000000u
  255. struct bcm2835_cprman {
  256. struct device *dev;
  257. void __iomem *regs;
  258. spinlock_t regs_lock;
  259. const char *osc_name;
  260. struct clk_onecell_data onecell;
  261. struct clk *clks[BCM2835_CLOCK_COUNT];
  262. };
  263. static inline void cprman_write(struct bcm2835_cprman *cprman, u32 reg, u32 val)
  264. {
  265. writel(CM_PASSWORD | val, cprman->regs + reg);
  266. }
  267. static inline u32 cprman_read(struct bcm2835_cprman *cprman, u32 reg)
  268. {
  269. return readl(cprman->regs + reg);
  270. }
  271. /*
  272. * These are fixed clocks. They're probably not all root clocks and it may
  273. * be possible to turn them on and off but until this is mapped out better
  274. * it's the only way they can be used.
  275. */
  276. void __init bcm2835_init_clocks(void)
  277. {
  278. struct clk *clk;
  279. int ret;
  280. clk = clk_register_fixed_rate(NULL, "apb_pclk", NULL, CLK_IS_ROOT,
  281. 126000000);
  282. if (IS_ERR(clk))
  283. pr_err("apb_pclk not registered\n");
  284. clk = clk_register_fixed_rate(NULL, "uart0_pclk", NULL, CLK_IS_ROOT,
  285. 3000000);
  286. if (IS_ERR(clk))
  287. pr_err("uart0_pclk not registered\n");
  288. ret = clk_register_clkdev(clk, NULL, "20201000.uart");
  289. if (ret)
  290. pr_err("uart0_pclk alias not registered\n");
  291. clk = clk_register_fixed_rate(NULL, "uart1_pclk", NULL, CLK_IS_ROOT,
  292. 125000000);
  293. if (IS_ERR(clk))
  294. pr_err("uart1_pclk not registered\n");
  295. ret = clk_register_clkdev(clk, NULL, "20215000.uart");
  296. if (ret)
  297. pr_err("uart1_pclk alias not registered\n");
  298. }
  299. struct bcm2835_pll_data {
  300. const char *name;
  301. u32 cm_ctrl_reg;
  302. u32 a2w_ctrl_reg;
  303. u32 frac_reg;
  304. u32 ana_reg_base;
  305. u32 reference_enable_mask;
  306. /* Bit in CM_LOCK to indicate when the PLL has locked. */
  307. u32 lock_mask;
  308. const struct bcm2835_pll_ana_bits *ana;
  309. unsigned long min_rate;
  310. unsigned long max_rate;
  311. /*
  312. * Highest rate for the VCO before we have to use the
  313. * pre-divide-by-2.
  314. */
  315. unsigned long max_fb_rate;
  316. };
  317. struct bcm2835_pll_ana_bits {
  318. u32 mask0;
  319. u32 set0;
  320. u32 mask1;
  321. u32 set1;
  322. u32 mask3;
  323. u32 set3;
  324. u32 fb_prediv_mask;
  325. };
  326. static const struct bcm2835_pll_ana_bits bcm2835_ana_default = {
  327. .mask0 = 0,
  328. .set0 = 0,
  329. .mask1 = ~(A2W_PLL_KI_MASK | A2W_PLL_KP_MASK),
  330. .set1 = (2 << A2W_PLL_KI_SHIFT) | (8 << A2W_PLL_KP_SHIFT),
  331. .mask3 = ~A2W_PLL_KA_MASK,
  332. .set3 = (2 << A2W_PLL_KA_SHIFT),
  333. .fb_prediv_mask = BIT(14),
  334. };
  335. static const struct bcm2835_pll_ana_bits bcm2835_ana_pllh = {
  336. .mask0 = ~(A2W_PLLH_KA_MASK | A2W_PLLH_KI_LOW_MASK),
  337. .set0 = (2 << A2W_PLLH_KA_SHIFT) | (2 << A2W_PLLH_KI_LOW_SHIFT),
  338. .mask1 = ~(A2W_PLLH_KI_HIGH_MASK | A2W_PLLH_KP_MASK),
  339. .set1 = (6 << A2W_PLLH_KP_SHIFT),
  340. .mask3 = 0,
  341. .set3 = 0,
  342. .fb_prediv_mask = BIT(11),
  343. };
  344. /*
  345. * PLLA is the auxiliary PLL, used to drive the CCP2 (Compact Camera
  346. * Port 2) transmitter clock.
  347. *
  348. * It is in the PX LDO power domain, which is on when the AUDIO domain
  349. * is on.
  350. */
  351. static const struct bcm2835_pll_data bcm2835_plla_data = {
  352. .name = "plla",
  353. .cm_ctrl_reg = CM_PLLA,
  354. .a2w_ctrl_reg = A2W_PLLA_CTRL,
  355. .frac_reg = A2W_PLLA_FRAC,
  356. .ana_reg_base = A2W_PLLA_ANA0,
  357. .reference_enable_mask = A2W_XOSC_CTRL_PLLA_ENABLE,
  358. .lock_mask = CM_LOCK_FLOCKA,
  359. .ana = &bcm2835_ana_default,
  360. .min_rate = 600000000u,
  361. .max_rate = 2400000000u,
  362. .max_fb_rate = BCM2835_MAX_FB_RATE,
  363. };
  364. /* PLLB is used for the ARM's clock. */
  365. static const struct bcm2835_pll_data bcm2835_pllb_data = {
  366. .name = "pllb",
  367. .cm_ctrl_reg = CM_PLLB,
  368. .a2w_ctrl_reg = A2W_PLLB_CTRL,
  369. .frac_reg = A2W_PLLB_FRAC,
  370. .ana_reg_base = A2W_PLLB_ANA0,
  371. .reference_enable_mask = A2W_XOSC_CTRL_PLLB_ENABLE,
  372. .lock_mask = CM_LOCK_FLOCKB,
  373. .ana = &bcm2835_ana_default,
  374. .min_rate = 600000000u,
  375. .max_rate = 3000000000u,
  376. .max_fb_rate = BCM2835_MAX_FB_RATE,
  377. };
  378. /*
  379. * PLLC is the core PLL, used to drive the core VPU clock.
  380. *
  381. * It is in the PX LDO power domain, which is on when the AUDIO domain
  382. * is on.
  383. */
  384. static const struct bcm2835_pll_data bcm2835_pllc_data = {
  385. .name = "pllc",
  386. .cm_ctrl_reg = CM_PLLC,
  387. .a2w_ctrl_reg = A2W_PLLC_CTRL,
  388. .frac_reg = A2W_PLLC_FRAC,
  389. .ana_reg_base = A2W_PLLC_ANA0,
  390. .reference_enable_mask = A2W_XOSC_CTRL_PLLC_ENABLE,
  391. .lock_mask = CM_LOCK_FLOCKC,
  392. .ana = &bcm2835_ana_default,
  393. .min_rate = 600000000u,
  394. .max_rate = 3000000000u,
  395. .max_fb_rate = BCM2835_MAX_FB_RATE,
  396. };
  397. /*
  398. * PLLD is the display PLL, used to drive DSI display panels.
  399. *
  400. * It is in the PX LDO power domain, which is on when the AUDIO domain
  401. * is on.
  402. */
  403. static const struct bcm2835_pll_data bcm2835_plld_data = {
  404. .name = "plld",
  405. .cm_ctrl_reg = CM_PLLD,
  406. .a2w_ctrl_reg = A2W_PLLD_CTRL,
  407. .frac_reg = A2W_PLLD_FRAC,
  408. .ana_reg_base = A2W_PLLD_ANA0,
  409. .reference_enable_mask = A2W_XOSC_CTRL_DDR_ENABLE,
  410. .lock_mask = CM_LOCK_FLOCKD,
  411. .ana = &bcm2835_ana_default,
  412. .min_rate = 600000000u,
  413. .max_rate = 2400000000u,
  414. .max_fb_rate = BCM2835_MAX_FB_RATE,
  415. };
  416. /*
  417. * PLLH is used to supply the pixel clock or the AUX clock for the TV
  418. * encoder.
  419. *
  420. * It is in the HDMI power domain.
  421. */
  422. static const struct bcm2835_pll_data bcm2835_pllh_data = {
  423. "pllh",
  424. .cm_ctrl_reg = CM_PLLH,
  425. .a2w_ctrl_reg = A2W_PLLH_CTRL,
  426. .frac_reg = A2W_PLLH_FRAC,
  427. .ana_reg_base = A2W_PLLH_ANA0,
  428. .reference_enable_mask = A2W_XOSC_CTRL_PLLC_ENABLE,
  429. .lock_mask = CM_LOCK_FLOCKH,
  430. .ana = &bcm2835_ana_pllh,
  431. .min_rate = 600000000u,
  432. .max_rate = 3000000000u,
  433. .max_fb_rate = BCM2835_MAX_FB_RATE,
  434. };
  435. struct bcm2835_pll_divider_data {
  436. const char *name;
  437. const struct bcm2835_pll_data *source_pll;
  438. u32 cm_reg;
  439. u32 a2w_reg;
  440. u32 load_mask;
  441. u32 hold_mask;
  442. u32 fixed_divider;
  443. };
  444. static const struct bcm2835_pll_divider_data bcm2835_plla_core_data = {
  445. .name = "plla_core",
  446. .source_pll = &bcm2835_plla_data,
  447. .cm_reg = CM_PLLA,
  448. .a2w_reg = A2W_PLLA_CORE,
  449. .load_mask = CM_PLLA_LOADCORE,
  450. .hold_mask = CM_PLLA_HOLDCORE,
  451. .fixed_divider = 1,
  452. };
  453. static const struct bcm2835_pll_divider_data bcm2835_plla_per_data = {
  454. .name = "plla_per",
  455. .source_pll = &bcm2835_plla_data,
  456. .cm_reg = CM_PLLA,
  457. .a2w_reg = A2W_PLLA_PER,
  458. .load_mask = CM_PLLA_LOADPER,
  459. .hold_mask = CM_PLLA_HOLDPER,
  460. .fixed_divider = 1,
  461. };
  462. static const struct bcm2835_pll_divider_data bcm2835_pllb_arm_data = {
  463. .name = "pllb_arm",
  464. .source_pll = &bcm2835_pllb_data,
  465. .cm_reg = CM_PLLB,
  466. .a2w_reg = A2W_PLLB_ARM,
  467. .load_mask = CM_PLLB_LOADARM,
  468. .hold_mask = CM_PLLB_HOLDARM,
  469. .fixed_divider = 1,
  470. };
  471. static const struct bcm2835_pll_divider_data bcm2835_pllc_core0_data = {
  472. .name = "pllc_core0",
  473. .source_pll = &bcm2835_pllc_data,
  474. .cm_reg = CM_PLLC,
  475. .a2w_reg = A2W_PLLC_CORE0,
  476. .load_mask = CM_PLLC_LOADCORE0,
  477. .hold_mask = CM_PLLC_HOLDCORE0,
  478. .fixed_divider = 1,
  479. };
  480. static const struct bcm2835_pll_divider_data bcm2835_pllc_core1_data = {
  481. .name = "pllc_core1", .source_pll = &bcm2835_pllc_data,
  482. .cm_reg = CM_PLLC, A2W_PLLC_CORE1,
  483. .load_mask = CM_PLLC_LOADCORE1,
  484. .hold_mask = CM_PLLC_HOLDCORE1,
  485. .fixed_divider = 1,
  486. };
  487. static const struct bcm2835_pll_divider_data bcm2835_pllc_core2_data = {
  488. .name = "pllc_core2",
  489. .source_pll = &bcm2835_pllc_data,
  490. .cm_reg = CM_PLLC,
  491. .a2w_reg = A2W_PLLC_CORE2,
  492. .load_mask = CM_PLLC_LOADCORE2,
  493. .hold_mask = CM_PLLC_HOLDCORE2,
  494. .fixed_divider = 1,
  495. };
  496. static const struct bcm2835_pll_divider_data bcm2835_pllc_per_data = {
  497. .name = "pllc_per",
  498. .source_pll = &bcm2835_pllc_data,
  499. .cm_reg = CM_PLLC,
  500. .a2w_reg = A2W_PLLC_PER,
  501. .load_mask = CM_PLLC_LOADPER,
  502. .hold_mask = CM_PLLC_HOLDPER,
  503. .fixed_divider = 1,
  504. };
  505. static const struct bcm2835_pll_divider_data bcm2835_plld_core_data = {
  506. .name = "plld_core",
  507. .source_pll = &bcm2835_plld_data,
  508. .cm_reg = CM_PLLD,
  509. .a2w_reg = A2W_PLLD_CORE,
  510. .load_mask = CM_PLLD_LOADCORE,
  511. .hold_mask = CM_PLLD_HOLDCORE,
  512. .fixed_divider = 1,
  513. };
  514. static const struct bcm2835_pll_divider_data bcm2835_plld_per_data = {
  515. .name = "plld_per",
  516. .source_pll = &bcm2835_plld_data,
  517. .cm_reg = CM_PLLD,
  518. .a2w_reg = A2W_PLLD_PER,
  519. .load_mask = CM_PLLD_LOADPER,
  520. .hold_mask = CM_PLLD_HOLDPER,
  521. .fixed_divider = 1,
  522. };
  523. static const struct bcm2835_pll_divider_data bcm2835_pllh_rcal_data = {
  524. .name = "pllh_rcal",
  525. .source_pll = &bcm2835_pllh_data,
  526. .cm_reg = CM_PLLH,
  527. .a2w_reg = A2W_PLLH_RCAL,
  528. .load_mask = CM_PLLH_LOADRCAL,
  529. .hold_mask = 0,
  530. .fixed_divider = 10,
  531. };
  532. static const struct bcm2835_pll_divider_data bcm2835_pllh_aux_data = {
  533. .name = "pllh_aux",
  534. .source_pll = &bcm2835_pllh_data,
  535. .cm_reg = CM_PLLH,
  536. .a2w_reg = A2W_PLLH_AUX,
  537. .load_mask = CM_PLLH_LOADAUX,
  538. .hold_mask = 0,
  539. .fixed_divider = 10,
  540. };
  541. static const struct bcm2835_pll_divider_data bcm2835_pllh_pix_data = {
  542. .name = "pllh_pix",
  543. .source_pll = &bcm2835_pllh_data,
  544. .cm_reg = CM_PLLH,
  545. .a2w_reg = A2W_PLLH_PIX,
  546. .load_mask = CM_PLLH_LOADPIX,
  547. .hold_mask = 0,
  548. .fixed_divider = 10,
  549. };
  550. struct bcm2835_clock_data {
  551. const char *name;
  552. const char *const *parents;
  553. int num_mux_parents;
  554. u32 ctl_reg;
  555. u32 div_reg;
  556. /* Number of integer bits in the divider */
  557. u32 int_bits;
  558. /* Number of fractional bits in the divider */
  559. u32 frac_bits;
  560. bool is_vpu_clock;
  561. };
  562. static const char *const bcm2835_clock_per_parents[] = {
  563. "gnd",
  564. "xosc",
  565. "testdebug0",
  566. "testdebug1",
  567. "plla_per",
  568. "pllc_per",
  569. "plld_per",
  570. "pllh_aux",
  571. };
  572. static const char *const bcm2835_clock_vpu_parents[] = {
  573. "gnd",
  574. "xosc",
  575. "testdebug0",
  576. "testdebug1",
  577. "plla_core",
  578. "pllc_core0",
  579. "plld_core",
  580. "pllh_aux",
  581. "pllc_core1",
  582. "pllc_core2",
  583. };
  584. static const char *const bcm2835_clock_osc_parents[] = {
  585. "gnd",
  586. "xosc",
  587. "testdebug0",
  588. "testdebug1"
  589. };
  590. /*
  591. * Used for a 1Mhz clock for the system clocksource, and also used by
  592. * the watchdog timer and the camera pulse generator.
  593. */
  594. static const struct bcm2835_clock_data bcm2835_clock_timer_data = {
  595. .name = "timer",
  596. .num_mux_parents = ARRAY_SIZE(bcm2835_clock_osc_parents),
  597. .parents = bcm2835_clock_osc_parents,
  598. .ctl_reg = CM_TIMERCTL,
  599. .div_reg = CM_TIMERDIV,
  600. .int_bits = 6,
  601. .frac_bits = 12,
  602. };
  603. /* One Time Programmable Memory clock. Maximum 10Mhz. */
  604. static const struct bcm2835_clock_data bcm2835_clock_otp_data = {
  605. .name = "otp",
  606. .num_mux_parents = ARRAY_SIZE(bcm2835_clock_osc_parents),
  607. .parents = bcm2835_clock_osc_parents,
  608. .ctl_reg = CM_OTPCTL,
  609. .div_reg = CM_OTPDIV,
  610. .int_bits = 4,
  611. .frac_bits = 0,
  612. };
  613. /*
  614. * VPU clock. This doesn't have an enable bit, since it drives the
  615. * bus for everything else, and is special so it doesn't need to be
  616. * gated for rate changes. It is also known as "clk_audio" in various
  617. * hardware documentation.
  618. */
  619. static const struct bcm2835_clock_data bcm2835_clock_vpu_data = {
  620. .name = "vpu",
  621. .num_mux_parents = ARRAY_SIZE(bcm2835_clock_vpu_parents),
  622. .parents = bcm2835_clock_vpu_parents,
  623. .ctl_reg = CM_VPUCTL,
  624. .div_reg = CM_VPUDIV,
  625. .int_bits = 12,
  626. .frac_bits = 8,
  627. .is_vpu_clock = true,
  628. };
  629. static const struct bcm2835_clock_data bcm2835_clock_v3d_data = {
  630. .name = "v3d",
  631. .num_mux_parents = ARRAY_SIZE(bcm2835_clock_vpu_parents),
  632. .parents = bcm2835_clock_vpu_parents,
  633. .ctl_reg = CM_V3DCTL,
  634. .div_reg = CM_V3DDIV,
  635. .int_bits = 4,
  636. .frac_bits = 8,
  637. };
  638. static const struct bcm2835_clock_data bcm2835_clock_isp_data = {
  639. .name = "isp",
  640. .num_mux_parents = ARRAY_SIZE(bcm2835_clock_vpu_parents),
  641. .parents = bcm2835_clock_vpu_parents,
  642. .ctl_reg = CM_ISPCTL,
  643. .div_reg = CM_ISPDIV,
  644. .int_bits = 4,
  645. .frac_bits = 8,
  646. };
  647. static const struct bcm2835_clock_data bcm2835_clock_h264_data = {
  648. .name = "h264",
  649. .num_mux_parents = ARRAY_SIZE(bcm2835_clock_vpu_parents),
  650. .parents = bcm2835_clock_vpu_parents,
  651. .ctl_reg = CM_H264CTL,
  652. .div_reg = CM_H264DIV,
  653. .int_bits = 4,
  654. .frac_bits = 8,
  655. };
  656. /* TV encoder clock. Only operating frequency is 108Mhz. */
  657. static const struct bcm2835_clock_data bcm2835_clock_vec_data = {
  658. .name = "vec",
  659. .num_mux_parents = ARRAY_SIZE(bcm2835_clock_per_parents),
  660. .parents = bcm2835_clock_per_parents,
  661. .ctl_reg = CM_VECCTL,
  662. .div_reg = CM_VECDIV,
  663. .int_bits = 4,
  664. .frac_bits = 0,
  665. };
  666. static const struct bcm2835_clock_data bcm2835_clock_uart_data = {
  667. .name = "uart",
  668. .num_mux_parents = ARRAY_SIZE(bcm2835_clock_per_parents),
  669. .parents = bcm2835_clock_per_parents,
  670. .ctl_reg = CM_UARTCTL,
  671. .div_reg = CM_UARTDIV,
  672. .int_bits = 10,
  673. .frac_bits = 12,
  674. };
  675. /* HDMI state machine */
  676. static const struct bcm2835_clock_data bcm2835_clock_hsm_data = {
  677. .name = "hsm",
  678. .num_mux_parents = ARRAY_SIZE(bcm2835_clock_per_parents),
  679. .parents = bcm2835_clock_per_parents,
  680. .ctl_reg = CM_HSMCTL,
  681. .div_reg = CM_HSMDIV,
  682. .int_bits = 4,
  683. .frac_bits = 8,
  684. };
  685. /*
  686. * Secondary SDRAM clock. Used for low-voltage modes when the PLL in
  687. * the SDRAM controller can't be used.
  688. */
  689. static const struct bcm2835_clock_data bcm2835_clock_sdram_data = {
  690. .name = "sdram",
  691. .num_mux_parents = ARRAY_SIZE(bcm2835_clock_vpu_parents),
  692. .parents = bcm2835_clock_vpu_parents,
  693. .ctl_reg = CM_SDCCTL,
  694. .div_reg = CM_SDCDIV,
  695. .int_bits = 6,
  696. .frac_bits = 0,
  697. };
  698. /* Clock for the temperature sensor. Generally run at 2Mhz, max 5Mhz. */
  699. static const struct bcm2835_clock_data bcm2835_clock_tsens_data = {
  700. .name = "tsens",
  701. .num_mux_parents = ARRAY_SIZE(bcm2835_clock_osc_parents),
  702. .parents = bcm2835_clock_osc_parents,
  703. .ctl_reg = CM_TSENSCTL,
  704. .div_reg = CM_TSENSDIV,
  705. .int_bits = 5,
  706. .frac_bits = 0,
  707. };
  708. /* Arasan EMMC clock */
  709. static const struct bcm2835_clock_data bcm2835_clock_emmc_data = {
  710. .name = "emmc",
  711. .num_mux_parents = ARRAY_SIZE(bcm2835_clock_per_parents),
  712. .parents = bcm2835_clock_per_parents,
  713. .ctl_reg = CM_EMMCCTL,
  714. .div_reg = CM_EMMCDIV,
  715. .int_bits = 4,
  716. .frac_bits = 8,
  717. };
  718. struct bcm2835_pll {
  719. struct clk_hw hw;
  720. struct bcm2835_cprman *cprman;
  721. const struct bcm2835_pll_data *data;
  722. };
  723. static int bcm2835_pll_is_on(struct clk_hw *hw)
  724. {
  725. struct bcm2835_pll *pll = container_of(hw, struct bcm2835_pll, hw);
  726. struct bcm2835_cprman *cprman = pll->cprman;
  727. const struct bcm2835_pll_data *data = pll->data;
  728. return cprman_read(cprman, data->a2w_ctrl_reg) &
  729. A2W_PLL_CTRL_PRST_DISABLE;
  730. }
  731. static void bcm2835_pll_choose_ndiv_and_fdiv(unsigned long rate,
  732. unsigned long parent_rate,
  733. u32 *ndiv, u32 *fdiv)
  734. {
  735. u64 div;
  736. div = (u64)rate << A2W_PLL_FRAC_BITS;
  737. do_div(div, parent_rate);
  738. *ndiv = div >> A2W_PLL_FRAC_BITS;
  739. *fdiv = div & ((1 << A2W_PLL_FRAC_BITS) - 1);
  740. }
  741. static long bcm2835_pll_rate_from_divisors(unsigned long parent_rate,
  742. u32 ndiv, u32 fdiv, u32 pdiv)
  743. {
  744. u64 rate;
  745. if (pdiv == 0)
  746. return 0;
  747. rate = (u64)parent_rate * ((ndiv << A2W_PLL_FRAC_BITS) + fdiv);
  748. do_div(rate, pdiv);
  749. return rate >> A2W_PLL_FRAC_BITS;
  750. }
  751. static long bcm2835_pll_round_rate(struct clk_hw *hw, unsigned long rate,
  752. unsigned long *parent_rate)
  753. {
  754. u32 ndiv, fdiv;
  755. bcm2835_pll_choose_ndiv_and_fdiv(rate, *parent_rate, &ndiv, &fdiv);
  756. return bcm2835_pll_rate_from_divisors(*parent_rate, ndiv, fdiv, 1);
  757. }
  758. static unsigned long bcm2835_pll_get_rate(struct clk_hw *hw,
  759. unsigned long parent_rate)
  760. {
  761. struct bcm2835_pll *pll = container_of(hw, struct bcm2835_pll, hw);
  762. struct bcm2835_cprman *cprman = pll->cprman;
  763. const struct bcm2835_pll_data *data = pll->data;
  764. u32 a2wctrl = cprman_read(cprman, data->a2w_ctrl_reg);
  765. u32 ndiv, pdiv, fdiv;
  766. bool using_prediv;
  767. if (parent_rate == 0)
  768. return 0;
  769. fdiv = cprman_read(cprman, data->frac_reg) & A2W_PLL_FRAC_MASK;
  770. ndiv = (a2wctrl & A2W_PLL_CTRL_NDIV_MASK) >> A2W_PLL_CTRL_NDIV_SHIFT;
  771. pdiv = (a2wctrl & A2W_PLL_CTRL_PDIV_MASK) >> A2W_PLL_CTRL_PDIV_SHIFT;
  772. using_prediv = cprman_read(cprman, data->ana_reg_base + 4) &
  773. data->ana->fb_prediv_mask;
  774. if (using_prediv)
  775. ndiv *= 2;
  776. return bcm2835_pll_rate_from_divisors(parent_rate, ndiv, fdiv, pdiv);
  777. }
  778. static void bcm2835_pll_off(struct clk_hw *hw)
  779. {
  780. struct bcm2835_pll *pll = container_of(hw, struct bcm2835_pll, hw);
  781. struct bcm2835_cprman *cprman = pll->cprman;
  782. const struct bcm2835_pll_data *data = pll->data;
  783. spin_lock(&cprman->regs_lock);
  784. cprman_write(cprman, data->cm_ctrl_reg, CM_PLL_ANARST);
  785. cprman_write(cprman, data->a2w_ctrl_reg,
  786. cprman_read(cprman, data->a2w_ctrl_reg) |
  787. A2W_PLL_CTRL_PWRDN);
  788. spin_unlock(&cprman->regs_lock);
  789. }
  790. static int bcm2835_pll_on(struct clk_hw *hw)
  791. {
  792. struct bcm2835_pll *pll = container_of(hw, struct bcm2835_pll, hw);
  793. struct bcm2835_cprman *cprman = pll->cprman;
  794. const struct bcm2835_pll_data *data = pll->data;
  795. ktime_t timeout;
  796. cprman_write(cprman, data->a2w_ctrl_reg,
  797. cprman_read(cprman, data->a2w_ctrl_reg) &
  798. ~A2W_PLL_CTRL_PWRDN);
  799. /* Take the PLL out of reset. */
  800. spin_lock(&cprman->regs_lock);
  801. cprman_write(cprman, data->cm_ctrl_reg,
  802. cprman_read(cprman, data->cm_ctrl_reg) & ~CM_PLL_ANARST);
  803. spin_unlock(&cprman->regs_lock);
  804. /* Wait for the PLL to lock. */
  805. timeout = ktime_add_ns(ktime_get(), LOCK_TIMEOUT_NS);
  806. while (!(cprman_read(cprman, CM_LOCK) & data->lock_mask)) {
  807. if (ktime_after(ktime_get(), timeout)) {
  808. dev_err(cprman->dev, "%s: couldn't lock PLL\n",
  809. clk_hw_get_name(hw));
  810. return -ETIMEDOUT;
  811. }
  812. cpu_relax();
  813. }
  814. cprman_write(cprman, data->a2w_ctrl_reg,
  815. cprman_read(cprman, data->a2w_ctrl_reg) |
  816. A2W_PLL_CTRL_PRST_DISABLE);
  817. return 0;
  818. }
  819. static void
  820. bcm2835_pll_write_ana(struct bcm2835_cprman *cprman, u32 ana_reg_base, u32 *ana)
  821. {
  822. int i;
  823. /*
  824. * ANA register setup is done as a series of writes to
  825. * ANA3-ANA0, in that order. This lets us write all 4
  826. * registers as a single cycle of the serdes interface (taking
  827. * 100 xosc clocks), whereas if we were to update ana0, 1, and
  828. * 3 individually through their partial-write registers, each
  829. * would be their own serdes cycle.
  830. */
  831. for (i = 3; i >= 0; i--)
  832. cprman_write(cprman, ana_reg_base + i * 4, ana[i]);
  833. }
  834. static int bcm2835_pll_set_rate(struct clk_hw *hw,
  835. unsigned long rate, unsigned long parent_rate)
  836. {
  837. struct bcm2835_pll *pll = container_of(hw, struct bcm2835_pll, hw);
  838. struct bcm2835_cprman *cprman = pll->cprman;
  839. const struct bcm2835_pll_data *data = pll->data;
  840. bool was_using_prediv, use_fb_prediv, do_ana_setup_first;
  841. u32 ndiv, fdiv, a2w_ctl;
  842. u32 ana[4];
  843. int i;
  844. if (rate < data->min_rate || rate > data->max_rate) {
  845. dev_err(cprman->dev, "%s: rate out of spec: %lu vs (%lu, %lu)\n",
  846. clk_hw_get_name(hw), rate,
  847. data->min_rate, data->max_rate);
  848. return -EINVAL;
  849. }
  850. if (rate > data->max_fb_rate) {
  851. use_fb_prediv = true;
  852. rate /= 2;
  853. } else {
  854. use_fb_prediv = false;
  855. }
  856. bcm2835_pll_choose_ndiv_and_fdiv(rate, parent_rate, &ndiv, &fdiv);
  857. for (i = 3; i >= 0; i--)
  858. ana[i] = cprman_read(cprman, data->ana_reg_base + i * 4);
  859. was_using_prediv = ana[1] & data->ana->fb_prediv_mask;
  860. ana[0] &= ~data->ana->mask0;
  861. ana[0] |= data->ana->set0;
  862. ana[1] &= ~data->ana->mask1;
  863. ana[1] |= data->ana->set1;
  864. ana[3] &= ~data->ana->mask3;
  865. ana[3] |= data->ana->set3;
  866. if (was_using_prediv && !use_fb_prediv) {
  867. ana[1] &= ~data->ana->fb_prediv_mask;
  868. do_ana_setup_first = true;
  869. } else if (!was_using_prediv && use_fb_prediv) {
  870. ana[1] |= data->ana->fb_prediv_mask;
  871. do_ana_setup_first = false;
  872. } else {
  873. do_ana_setup_first = true;
  874. }
  875. /* Unmask the reference clock from the oscillator. */
  876. spin_lock(&cprman->regs_lock);
  877. cprman_write(cprman, A2W_XOSC_CTRL,
  878. cprman_read(cprman, A2W_XOSC_CTRL) |
  879. data->reference_enable_mask);
  880. spin_unlock(&cprman->regs_lock);
  881. if (do_ana_setup_first)
  882. bcm2835_pll_write_ana(cprman, data->ana_reg_base, ana);
  883. /* Set the PLL multiplier from the oscillator. */
  884. cprman_write(cprman, data->frac_reg, fdiv);
  885. a2w_ctl = cprman_read(cprman, data->a2w_ctrl_reg);
  886. a2w_ctl &= ~A2W_PLL_CTRL_NDIV_MASK;
  887. a2w_ctl |= ndiv << A2W_PLL_CTRL_NDIV_SHIFT;
  888. a2w_ctl &= ~A2W_PLL_CTRL_PDIV_MASK;
  889. a2w_ctl |= 1 << A2W_PLL_CTRL_PDIV_SHIFT;
  890. cprman_write(cprman, data->a2w_ctrl_reg, a2w_ctl);
  891. if (!do_ana_setup_first)
  892. bcm2835_pll_write_ana(cprman, data->ana_reg_base, ana);
  893. return 0;
  894. }
  895. static const struct clk_ops bcm2835_pll_clk_ops = {
  896. .is_prepared = bcm2835_pll_is_on,
  897. .prepare = bcm2835_pll_on,
  898. .unprepare = bcm2835_pll_off,
  899. .recalc_rate = bcm2835_pll_get_rate,
  900. .set_rate = bcm2835_pll_set_rate,
  901. .round_rate = bcm2835_pll_round_rate,
  902. };
  903. struct bcm2835_pll_divider {
  904. struct clk_divider div;
  905. struct bcm2835_cprman *cprman;
  906. const struct bcm2835_pll_divider_data *data;
  907. };
  908. static struct bcm2835_pll_divider *
  909. bcm2835_pll_divider_from_hw(struct clk_hw *hw)
  910. {
  911. return container_of(hw, struct bcm2835_pll_divider, div.hw);
  912. }
  913. static int bcm2835_pll_divider_is_on(struct clk_hw *hw)
  914. {
  915. struct bcm2835_pll_divider *divider = bcm2835_pll_divider_from_hw(hw);
  916. struct bcm2835_cprman *cprman = divider->cprman;
  917. const struct bcm2835_pll_divider_data *data = divider->data;
  918. return !(cprman_read(cprman, data->a2w_reg) & A2W_PLL_CHANNEL_DISABLE);
  919. }
  920. static long bcm2835_pll_divider_round_rate(struct clk_hw *hw,
  921. unsigned long rate,
  922. unsigned long *parent_rate)
  923. {
  924. return clk_divider_ops.round_rate(hw, rate, parent_rate);
  925. }
  926. static unsigned long bcm2835_pll_divider_get_rate(struct clk_hw *hw,
  927. unsigned long parent_rate)
  928. {
  929. struct bcm2835_pll_divider *divider = bcm2835_pll_divider_from_hw(hw);
  930. struct bcm2835_cprman *cprman = divider->cprman;
  931. const struct bcm2835_pll_divider_data *data = divider->data;
  932. u32 div = cprman_read(cprman, data->a2w_reg);
  933. div &= (1 << A2W_PLL_DIV_BITS) - 1;
  934. if (div == 0)
  935. div = 256;
  936. return parent_rate / div;
  937. }
  938. static void bcm2835_pll_divider_off(struct clk_hw *hw)
  939. {
  940. struct bcm2835_pll_divider *divider = bcm2835_pll_divider_from_hw(hw);
  941. struct bcm2835_cprman *cprman = divider->cprman;
  942. const struct bcm2835_pll_divider_data *data = divider->data;
  943. spin_lock(&cprman->regs_lock);
  944. cprman_write(cprman, data->cm_reg,
  945. (cprman_read(cprman, data->cm_reg) &
  946. ~data->load_mask) | data->hold_mask);
  947. cprman_write(cprman, data->a2w_reg,
  948. cprman_read(cprman, data->a2w_reg) |
  949. A2W_PLL_CHANNEL_DISABLE);
  950. spin_unlock(&cprman->regs_lock);
  951. }
  952. static int bcm2835_pll_divider_on(struct clk_hw *hw)
  953. {
  954. struct bcm2835_pll_divider *divider = bcm2835_pll_divider_from_hw(hw);
  955. struct bcm2835_cprman *cprman = divider->cprman;
  956. const struct bcm2835_pll_divider_data *data = divider->data;
  957. spin_lock(&cprman->regs_lock);
  958. cprman_write(cprman, data->a2w_reg,
  959. cprman_read(cprman, data->a2w_reg) &
  960. ~A2W_PLL_CHANNEL_DISABLE);
  961. cprman_write(cprman, data->cm_reg,
  962. cprman_read(cprman, data->cm_reg) & ~data->hold_mask);
  963. spin_unlock(&cprman->regs_lock);
  964. return 0;
  965. }
  966. static int bcm2835_pll_divider_set_rate(struct clk_hw *hw,
  967. unsigned long rate,
  968. unsigned long parent_rate)
  969. {
  970. struct bcm2835_pll_divider *divider = bcm2835_pll_divider_from_hw(hw);
  971. struct bcm2835_cprman *cprman = divider->cprman;
  972. const struct bcm2835_pll_divider_data *data = divider->data;
  973. u32 cm, div, max_div = 1 << A2W_PLL_DIV_BITS;
  974. div = DIV_ROUND_UP_ULL(parent_rate, rate);
  975. div = min(div, max_div);
  976. if (div == max_div)
  977. div = 0;
  978. cprman_write(cprman, data->a2w_reg, div);
  979. cm = cprman_read(cprman, data->cm_reg);
  980. cprman_write(cprman, data->cm_reg, cm | data->load_mask);
  981. cprman_write(cprman, data->cm_reg, cm & ~data->load_mask);
  982. return 0;
  983. }
  984. static const struct clk_ops bcm2835_pll_divider_clk_ops = {
  985. .is_prepared = bcm2835_pll_divider_is_on,
  986. .prepare = bcm2835_pll_divider_on,
  987. .unprepare = bcm2835_pll_divider_off,
  988. .recalc_rate = bcm2835_pll_divider_get_rate,
  989. .set_rate = bcm2835_pll_divider_set_rate,
  990. .round_rate = bcm2835_pll_divider_round_rate,
  991. };
  992. /*
  993. * The CM dividers do fixed-point division, so we can't use the
  994. * generic integer divider code like the PLL dividers do (and we can't
  995. * fake it by having some fixed shifts preceding it in the clock tree,
  996. * because we'd run out of bits in a 32-bit unsigned long).
  997. */
  998. struct bcm2835_clock {
  999. struct clk_hw hw;
  1000. struct bcm2835_cprman *cprman;
  1001. const struct bcm2835_clock_data *data;
  1002. };
  1003. static struct bcm2835_clock *bcm2835_clock_from_hw(struct clk_hw *hw)
  1004. {
  1005. return container_of(hw, struct bcm2835_clock, hw);
  1006. }
  1007. static int bcm2835_clock_is_on(struct clk_hw *hw)
  1008. {
  1009. struct bcm2835_clock *clock = bcm2835_clock_from_hw(hw);
  1010. struct bcm2835_cprman *cprman = clock->cprman;
  1011. const struct bcm2835_clock_data *data = clock->data;
  1012. return (cprman_read(cprman, data->ctl_reg) & CM_ENABLE) != 0;
  1013. }
  1014. static u32 bcm2835_clock_choose_div(struct clk_hw *hw,
  1015. unsigned long rate,
  1016. unsigned long parent_rate)
  1017. {
  1018. struct bcm2835_clock *clock = bcm2835_clock_from_hw(hw);
  1019. const struct bcm2835_clock_data *data = clock->data;
  1020. u32 unused_frac_mask = GENMASK(CM_DIV_FRAC_BITS - data->frac_bits, 0);
  1021. u64 temp = (u64)parent_rate << CM_DIV_FRAC_BITS;
  1022. u32 div;
  1023. do_div(temp, rate);
  1024. div = temp;
  1025. /* Round and mask off the unused bits */
  1026. if (unused_frac_mask != 0) {
  1027. div += unused_frac_mask >> 1;
  1028. div &= ~unused_frac_mask;
  1029. }
  1030. /* clamp to min divider of 1 */
  1031. div = max_t(u32, div, 1 << CM_DIV_FRAC_BITS);
  1032. /* clamp to the highest possible fractional divider */
  1033. div = min_t(u32, div, GENMASK(data->int_bits + CM_DIV_FRAC_BITS - 1,
  1034. CM_DIV_FRAC_BITS - data->frac_bits));
  1035. return div;
  1036. }
  1037. static long bcm2835_clock_rate_from_divisor(struct bcm2835_clock *clock,
  1038. unsigned long parent_rate,
  1039. u32 div)
  1040. {
  1041. const struct bcm2835_clock_data *data = clock->data;
  1042. u64 temp;
  1043. /*
  1044. * The divisor is a 12.12 fixed point field, but only some of
  1045. * the bits are populated in any given clock.
  1046. */
  1047. div >>= CM_DIV_FRAC_BITS - data->frac_bits;
  1048. div &= (1 << (data->int_bits + data->frac_bits)) - 1;
  1049. if (div == 0)
  1050. return 0;
  1051. temp = (u64)parent_rate << data->frac_bits;
  1052. do_div(temp, div);
  1053. return temp;
  1054. }
  1055. static long bcm2835_clock_round_rate(struct clk_hw *hw,
  1056. unsigned long rate,
  1057. unsigned long *parent_rate)
  1058. {
  1059. struct bcm2835_clock *clock = bcm2835_clock_from_hw(hw);
  1060. u32 div = bcm2835_clock_choose_div(hw, rate, *parent_rate);
  1061. return bcm2835_clock_rate_from_divisor(clock, *parent_rate, div);
  1062. }
  1063. static unsigned long bcm2835_clock_get_rate(struct clk_hw *hw,
  1064. unsigned long parent_rate)
  1065. {
  1066. struct bcm2835_clock *clock = bcm2835_clock_from_hw(hw);
  1067. struct bcm2835_cprman *cprman = clock->cprman;
  1068. const struct bcm2835_clock_data *data = clock->data;
  1069. u32 div = cprman_read(cprman, data->div_reg);
  1070. return bcm2835_clock_rate_from_divisor(clock, parent_rate, div);
  1071. }
  1072. static void bcm2835_clock_wait_busy(struct bcm2835_clock *clock)
  1073. {
  1074. struct bcm2835_cprman *cprman = clock->cprman;
  1075. const struct bcm2835_clock_data *data = clock->data;
  1076. ktime_t timeout = ktime_add_ns(ktime_get(), LOCK_TIMEOUT_NS);
  1077. while (cprman_read(cprman, data->ctl_reg) & CM_BUSY) {
  1078. if (ktime_after(ktime_get(), timeout)) {
  1079. dev_err(cprman->dev, "%s: couldn't lock PLL\n",
  1080. clk_hw_get_name(&clock->hw));
  1081. return;
  1082. }
  1083. cpu_relax();
  1084. }
  1085. }
  1086. static void bcm2835_clock_off(struct clk_hw *hw)
  1087. {
  1088. struct bcm2835_clock *clock = bcm2835_clock_from_hw(hw);
  1089. struct bcm2835_cprman *cprman = clock->cprman;
  1090. const struct bcm2835_clock_data *data = clock->data;
  1091. spin_lock(&cprman->regs_lock);
  1092. cprman_write(cprman, data->ctl_reg,
  1093. cprman_read(cprman, data->ctl_reg) & ~CM_ENABLE);
  1094. spin_unlock(&cprman->regs_lock);
  1095. /* BUSY will remain high until the divider completes its cycle. */
  1096. bcm2835_clock_wait_busy(clock);
  1097. }
  1098. static int bcm2835_clock_on(struct clk_hw *hw)
  1099. {
  1100. struct bcm2835_clock *clock = bcm2835_clock_from_hw(hw);
  1101. struct bcm2835_cprman *cprman = clock->cprman;
  1102. const struct bcm2835_clock_data *data = clock->data;
  1103. spin_lock(&cprman->regs_lock);
  1104. cprman_write(cprman, data->ctl_reg,
  1105. cprman_read(cprman, data->ctl_reg) |
  1106. CM_ENABLE |
  1107. CM_GATE);
  1108. spin_unlock(&cprman->regs_lock);
  1109. return 0;
  1110. }
  1111. static int bcm2835_clock_set_rate(struct clk_hw *hw,
  1112. unsigned long rate, unsigned long parent_rate)
  1113. {
  1114. struct bcm2835_clock *clock = bcm2835_clock_from_hw(hw);
  1115. struct bcm2835_cprman *cprman = clock->cprman;
  1116. const struct bcm2835_clock_data *data = clock->data;
  1117. u32 div = bcm2835_clock_choose_div(hw, rate, parent_rate);
  1118. cprman_write(cprman, data->div_reg, div);
  1119. return 0;
  1120. }
  1121. static const struct clk_ops bcm2835_clock_clk_ops = {
  1122. .is_prepared = bcm2835_clock_is_on,
  1123. .prepare = bcm2835_clock_on,
  1124. .unprepare = bcm2835_clock_off,
  1125. .recalc_rate = bcm2835_clock_get_rate,
  1126. .set_rate = bcm2835_clock_set_rate,
  1127. .round_rate = bcm2835_clock_round_rate,
  1128. };
  1129. static int bcm2835_vpu_clock_is_on(struct clk_hw *hw)
  1130. {
  1131. return true;
  1132. }
  1133. /*
  1134. * The VPU clock can never be disabled (it doesn't have an ENABLE
  1135. * bit), so it gets its own set of clock ops.
  1136. */
  1137. static const struct clk_ops bcm2835_vpu_clock_clk_ops = {
  1138. .is_prepared = bcm2835_vpu_clock_is_on,
  1139. .recalc_rate = bcm2835_clock_get_rate,
  1140. .set_rate = bcm2835_clock_set_rate,
  1141. .round_rate = bcm2835_clock_round_rate,
  1142. };
  1143. static struct clk *bcm2835_register_pll(struct bcm2835_cprman *cprman,
  1144. const struct bcm2835_pll_data *data)
  1145. {
  1146. struct bcm2835_pll *pll;
  1147. struct clk_init_data init;
  1148. memset(&init, 0, sizeof(init));
  1149. /* All of the PLLs derive from the external oscillator. */
  1150. init.parent_names = &cprman->osc_name;
  1151. init.num_parents = 1;
  1152. init.name = data->name;
  1153. init.ops = &bcm2835_pll_clk_ops;
  1154. init.flags = CLK_IGNORE_UNUSED;
  1155. pll = kzalloc(sizeof(*pll), GFP_KERNEL);
  1156. if (!pll)
  1157. return NULL;
  1158. pll->cprman = cprman;
  1159. pll->data = data;
  1160. pll->hw.init = &init;
  1161. return devm_clk_register(cprman->dev, &pll->hw);
  1162. }
  1163. static struct clk *
  1164. bcm2835_register_pll_divider(struct bcm2835_cprman *cprman,
  1165. const struct bcm2835_pll_divider_data *data)
  1166. {
  1167. struct bcm2835_pll_divider *divider;
  1168. struct clk_init_data init;
  1169. struct clk *clk;
  1170. const char *divider_name;
  1171. if (data->fixed_divider != 1) {
  1172. divider_name = devm_kasprintf(cprman->dev, GFP_KERNEL,
  1173. "%s_prediv", data->name);
  1174. if (!divider_name)
  1175. return NULL;
  1176. } else {
  1177. divider_name = data->name;
  1178. }
  1179. memset(&init, 0, sizeof(init));
  1180. init.parent_names = &data->source_pll->name;
  1181. init.num_parents = 1;
  1182. init.name = divider_name;
  1183. init.ops = &bcm2835_pll_divider_clk_ops;
  1184. init.flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED;
  1185. divider = devm_kzalloc(cprman->dev, sizeof(*divider), GFP_KERNEL);
  1186. if (!divider)
  1187. return NULL;
  1188. divider->div.reg = cprman->regs + data->a2w_reg;
  1189. divider->div.shift = A2W_PLL_DIV_SHIFT;
  1190. divider->div.width = A2W_PLL_DIV_BITS;
  1191. divider->div.flags = 0;
  1192. divider->div.lock = &cprman->regs_lock;
  1193. divider->div.hw.init = &init;
  1194. divider->div.table = NULL;
  1195. divider->cprman = cprman;
  1196. divider->data = data;
  1197. clk = devm_clk_register(cprman->dev, &divider->div.hw);
  1198. if (IS_ERR(clk))
  1199. return clk;
  1200. /*
  1201. * PLLH's channels have a fixed divide by 10 afterwards, which
  1202. * is what our consumers are actually using.
  1203. */
  1204. if (data->fixed_divider != 1) {
  1205. return clk_register_fixed_factor(cprman->dev, data->name,
  1206. divider_name,
  1207. CLK_SET_RATE_PARENT,
  1208. 1,
  1209. data->fixed_divider);
  1210. }
  1211. return clk;
  1212. }
  1213. static struct clk *bcm2835_register_clock(struct bcm2835_cprman *cprman,
  1214. const struct bcm2835_clock_data *data)
  1215. {
  1216. struct bcm2835_clock *clock;
  1217. struct clk_init_data init;
  1218. const char *parent;
  1219. /*
  1220. * Most of the clock generators have a mux field, so we
  1221. * instantiate a generic mux as our parent to handle it.
  1222. */
  1223. if (data->num_mux_parents) {
  1224. const char *parents[1 << CM_SRC_BITS];
  1225. int i;
  1226. parent = devm_kasprintf(cprman->dev, GFP_KERNEL,
  1227. "mux_%s", data->name);
  1228. if (!parent)
  1229. return NULL;
  1230. /*
  1231. * Replace our "xosc" references with the oscillator's
  1232. * actual name.
  1233. */
  1234. for (i = 0; i < data->num_mux_parents; i++) {
  1235. if (strcmp(data->parents[i], "xosc") == 0)
  1236. parents[i] = cprman->osc_name;
  1237. else
  1238. parents[i] = data->parents[i];
  1239. }
  1240. clk_register_mux(cprman->dev, parent,
  1241. parents, data->num_mux_parents,
  1242. CLK_SET_RATE_PARENT,
  1243. cprman->regs + data->ctl_reg,
  1244. CM_SRC_SHIFT, CM_SRC_BITS,
  1245. 0, &cprman->regs_lock);
  1246. } else {
  1247. parent = data->parents[0];
  1248. }
  1249. memset(&init, 0, sizeof(init));
  1250. init.parent_names = &parent;
  1251. init.num_parents = 1;
  1252. init.name = data->name;
  1253. init.flags = CLK_IGNORE_UNUSED;
  1254. if (data->is_vpu_clock) {
  1255. init.ops = &bcm2835_vpu_clock_clk_ops;
  1256. } else {
  1257. init.ops = &bcm2835_clock_clk_ops;
  1258. init.flags |= CLK_SET_RATE_GATE | CLK_SET_PARENT_GATE;
  1259. }
  1260. clock = devm_kzalloc(cprman->dev, sizeof(*clock), GFP_KERNEL);
  1261. if (!clock)
  1262. return NULL;
  1263. clock->cprman = cprman;
  1264. clock->data = data;
  1265. clock->hw.init = &init;
  1266. return devm_clk_register(cprman->dev, &clock->hw);
  1267. }
  1268. static int bcm2835_clk_probe(struct platform_device *pdev)
  1269. {
  1270. struct device *dev = &pdev->dev;
  1271. struct clk **clks;
  1272. struct bcm2835_cprman *cprman;
  1273. struct resource *res;
  1274. cprman = devm_kzalloc(dev, sizeof(*cprman), GFP_KERNEL);
  1275. if (!cprman)
  1276. return -ENOMEM;
  1277. spin_lock_init(&cprman->regs_lock);
  1278. cprman->dev = dev;
  1279. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  1280. cprman->regs = devm_ioremap_resource(dev, res);
  1281. if (IS_ERR(cprman->regs))
  1282. return PTR_ERR(cprman->regs);
  1283. cprman->osc_name = of_clk_get_parent_name(dev->of_node, 0);
  1284. if (!cprman->osc_name)
  1285. return -ENODEV;
  1286. platform_set_drvdata(pdev, cprman);
  1287. cprman->onecell.clk_num = BCM2835_CLOCK_COUNT;
  1288. cprman->onecell.clks = cprman->clks;
  1289. clks = cprman->clks;
  1290. clks[BCM2835_PLLA] = bcm2835_register_pll(cprman, &bcm2835_plla_data);
  1291. clks[BCM2835_PLLB] = bcm2835_register_pll(cprman, &bcm2835_pllb_data);
  1292. clks[BCM2835_PLLC] = bcm2835_register_pll(cprman, &bcm2835_pllc_data);
  1293. clks[BCM2835_PLLD] = bcm2835_register_pll(cprman, &bcm2835_plld_data);
  1294. clks[BCM2835_PLLH] = bcm2835_register_pll(cprman, &bcm2835_pllh_data);
  1295. clks[BCM2835_PLLA_CORE] =
  1296. bcm2835_register_pll_divider(cprman, &bcm2835_plla_core_data);
  1297. clks[BCM2835_PLLA_PER] =
  1298. bcm2835_register_pll_divider(cprman, &bcm2835_plla_per_data);
  1299. clks[BCM2835_PLLC_CORE0] =
  1300. bcm2835_register_pll_divider(cprman, &bcm2835_pllc_core0_data);
  1301. clks[BCM2835_PLLC_CORE1] =
  1302. bcm2835_register_pll_divider(cprman, &bcm2835_pllc_core1_data);
  1303. clks[BCM2835_PLLC_CORE2] =
  1304. bcm2835_register_pll_divider(cprman, &bcm2835_pllc_core2_data);
  1305. clks[BCM2835_PLLC_PER] =
  1306. bcm2835_register_pll_divider(cprman, &bcm2835_pllc_per_data);
  1307. clks[BCM2835_PLLD_CORE] =
  1308. bcm2835_register_pll_divider(cprman, &bcm2835_plld_core_data);
  1309. clks[BCM2835_PLLD_PER] =
  1310. bcm2835_register_pll_divider(cprman, &bcm2835_plld_per_data);
  1311. clks[BCM2835_PLLH_RCAL] =
  1312. bcm2835_register_pll_divider(cprman, &bcm2835_pllh_rcal_data);
  1313. clks[BCM2835_PLLH_AUX] =
  1314. bcm2835_register_pll_divider(cprman, &bcm2835_pllh_aux_data);
  1315. clks[BCM2835_PLLH_PIX] =
  1316. bcm2835_register_pll_divider(cprman, &bcm2835_pllh_pix_data);
  1317. clks[BCM2835_CLOCK_TIMER] =
  1318. bcm2835_register_clock(cprman, &bcm2835_clock_timer_data);
  1319. clks[BCM2835_CLOCK_OTP] =
  1320. bcm2835_register_clock(cprman, &bcm2835_clock_otp_data);
  1321. clks[BCM2835_CLOCK_TSENS] =
  1322. bcm2835_register_clock(cprman, &bcm2835_clock_tsens_data);
  1323. clks[BCM2835_CLOCK_VPU] =
  1324. bcm2835_register_clock(cprman, &bcm2835_clock_vpu_data);
  1325. clks[BCM2835_CLOCK_V3D] =
  1326. bcm2835_register_clock(cprman, &bcm2835_clock_v3d_data);
  1327. clks[BCM2835_CLOCK_ISP] =
  1328. bcm2835_register_clock(cprman, &bcm2835_clock_isp_data);
  1329. clks[BCM2835_CLOCK_H264] =
  1330. bcm2835_register_clock(cprman, &bcm2835_clock_h264_data);
  1331. clks[BCM2835_CLOCK_V3D] =
  1332. bcm2835_register_clock(cprman, &bcm2835_clock_v3d_data);
  1333. clks[BCM2835_CLOCK_SDRAM] =
  1334. bcm2835_register_clock(cprman, &bcm2835_clock_sdram_data);
  1335. clks[BCM2835_CLOCK_UART] =
  1336. bcm2835_register_clock(cprman, &bcm2835_clock_uart_data);
  1337. clks[BCM2835_CLOCK_VEC] =
  1338. bcm2835_register_clock(cprman, &bcm2835_clock_vec_data);
  1339. clks[BCM2835_CLOCK_HSM] =
  1340. bcm2835_register_clock(cprman, &bcm2835_clock_hsm_data);
  1341. clks[BCM2835_CLOCK_EMMC] =
  1342. bcm2835_register_clock(cprman, &bcm2835_clock_emmc_data);
  1343. /*
  1344. * CM_PERIICTL (and CM_PERIACTL, CM_SYSCTL and CM_VPUCTL if
  1345. * you have the debug bit set in the power manager, which we
  1346. * don't bother exposing) are individual gates off of the
  1347. * non-stop vpu clock.
  1348. */
  1349. clks[BCM2835_CLOCK_PERI_IMAGE] =
  1350. clk_register_gate(dev, "peri_image", "vpu",
  1351. CLK_IGNORE_UNUSED | CLK_SET_RATE_GATE,
  1352. cprman->regs + CM_PERIICTL, CM_GATE_BIT,
  1353. 0, &cprman->regs_lock);
  1354. return of_clk_add_provider(dev->of_node, of_clk_src_onecell_get,
  1355. &cprman->onecell);
  1356. }
  1357. static const struct of_device_id bcm2835_clk_of_match[] = {
  1358. { .compatible = "brcm,bcm2835-cprman", },
  1359. {}
  1360. };
  1361. MODULE_DEVICE_TABLE(of, bcm2835_clk_of_match);
  1362. static struct platform_driver bcm2835_clk_driver = {
  1363. .driver = {
  1364. .name = "bcm2835-clk",
  1365. .of_match_table = bcm2835_clk_of_match,
  1366. },
  1367. .probe = bcm2835_clk_probe,
  1368. };
  1369. builtin_platform_driver(bcm2835_clk_driver);
  1370. MODULE_AUTHOR("Eric Anholt <eric@anholt.net>");
  1371. MODULE_DESCRIPTION("BCM2835 clock driver");
  1372. MODULE_LICENSE("GPL v2");