803-cpufreq-support-layerscape.patch 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030
  1. From d78d78ccbaded757e8bea0d13c4120518bdd4660 Mon Sep 17 00:00:00 2001
  2. From: Yangbo Lu <[email protected]>
  3. Date: Thu, 5 Jul 2018 17:21:38 +0800
  4. Subject: [PATCH 15/32] cpufreq: support layerscape
  5. This is an integrated patch for layerscape pm support.
  6. Signed-off-by: Tang Yuantian <[email protected]>
  7. Signed-off-by: Yangbo Lu <[email protected]>
  8. ---
  9. .../devicetree/bindings/powerpc/fsl/pmc.txt | 59 ++--
  10. drivers/cpufreq/Kconfig | 2 +-
  11. drivers/cpufreq/qoriq-cpufreq.c | 176 +++++------
  12. drivers/firmware/psci.c | 12 +-
  13. drivers/soc/fsl/rcpm.c | 158 ++++++++++
  14. drivers/soc/fsl/sleep_fsm.c | 279 ++++++++++++++++++
  15. drivers/soc/fsl/sleep_fsm.h | 130 ++++++++
  16. 7 files changed, 678 insertions(+), 138 deletions(-)
  17. create mode 100644 drivers/soc/fsl/rcpm.c
  18. create mode 100644 drivers/soc/fsl/sleep_fsm.c
  19. create mode 100644 drivers/soc/fsl/sleep_fsm.h
  20. --- a/Documentation/devicetree/bindings/powerpc/fsl/pmc.txt
  21. +++ b/Documentation/devicetree/bindings/powerpc/fsl/pmc.txt
  22. @@ -9,15 +9,20 @@ Properties:
  23. "fsl,mpc8548-pmc" should be listed for any chip whose PMC is
  24. compatible. "fsl,mpc8536-pmc" should also be listed for any chip
  25. - whose PMC is compatible, and implies deep-sleep capability.
  26. + whose PMC is compatible, and implies deep-sleep capability and
  27. + wake on user defined packet(wakeup on ARP).
  28. +
  29. + "fsl,p1022-pmc" should be listed for any chip whose PMC is
  30. + compatible, and implies lossless Ethernet capability during sleep.
  31. "fsl,mpc8641d-pmc" should be listed for any chip whose PMC is
  32. compatible; all statements below that apply to "fsl,mpc8548-pmc" also
  33. apply to "fsl,mpc8641d-pmc".
  34. Compatibility does not include bit assignments in SCCR/PMCDR/DEVDISR; these
  35. - bit assignments are indicated via the sleep specifier in each device's
  36. - sleep property.
  37. + bit assignments are indicated via the clock nodes. Device which has a
  38. + controllable clock source should have a "fsl,pmc-handle" property pointing
  39. + to the clock node.
  40. - reg: For devices compatible with "fsl,mpc8349-pmc", the first resource
  41. is the PMC block, and the second resource is the Clock Configuration
  42. @@ -33,31 +38,35 @@ Properties:
  43. this is a phandle to an "fsl,gtm" node on which timer 4 can be used as
  44. a wakeup source from deep sleep.
  45. -Sleep specifiers:
  46. -
  47. - fsl,mpc8349-pmc: Sleep specifiers consist of one cell. For each bit
  48. - that is set in the cell, the corresponding bit in SCCR will be saved
  49. - and cleared on suspend, and restored on resume. This sleep controller
  50. - supports disabling and resuming devices at any time.
  51. -
  52. - fsl,mpc8536-pmc: Sleep specifiers consist of three cells, the third of
  53. - which will be ORed into PMCDR upon suspend, and cleared from PMCDR
  54. - upon resume. The first two cells are as described for fsl,mpc8578-pmc.
  55. - This sleep controller only supports disabling devices during system
  56. - sleep, or permanently.
  57. -
  58. - fsl,mpc8548-pmc: Sleep specifiers consist of one or two cells, the
  59. - first of which will be ORed into DEVDISR (and the second into
  60. - DEVDISR2, if present -- this cell should be zero or absent if the
  61. - hardware does not have DEVDISR2) upon a request for permanent device
  62. - disabling. This sleep controller does not support configuring devices
  63. - to disable during system sleep (unless supported by another compatible
  64. - match), or dynamically.
  65. +Clock nodes:
  66. +The clock nodes are to describe the masks in PM controller registers for each
  67. +soc clock.
  68. +- fsl,pmcdr-mask: For "fsl,mpc8548-pmc"-compatible devices, the mask will be
  69. + ORed into PMCDR before suspend if the device using this clock is the wake-up
  70. + source and need to be running during low power mode; clear the mask if
  71. + otherwise.
  72. +
  73. +- fsl,sccr-mask: For "fsl,mpc8349-pmc"-compatible devices, the corresponding
  74. + bit specified by the mask in SCCR will be saved and cleared on suspend, and
  75. + restored on resume.
  76. +
  77. +- fsl,devdisr-mask: Contain one or two cells, depending on the availability of
  78. + DEVDISR2 register. For compatible devices, the mask will be ORed into DEVDISR
  79. + or DEVDISR2 when the clock should be permenently disabled.
  80. Example:
  81. - power@b00 {
  82. - compatible = "fsl,mpc8313-pmc", "fsl,mpc8349-pmc";
  83. - reg = <0xb00 0x100 0xa00 0x100>;
  84. - interrupts = <80 8>;
  85. + power@e0070 {
  86. + compatible = "fsl,mpc8536-pmc", "fsl,mpc8548-pmc";
  87. + reg = <0xe0070 0x20>;
  88. +
  89. + etsec1_clk: soc-clk@24 {
  90. + fsl,pmcdr-mask = <0x00000080>;
  91. + };
  92. + etsec2_clk: soc-clk@25 {
  93. + fsl,pmcdr-mask = <0x00000040>;
  94. + };
  95. + etsec3_clk: soc-clk@26 {
  96. + fsl,pmcdr-mask = <0x00000020>;
  97. + };
  98. };
  99. --- a/drivers/cpufreq/Kconfig
  100. +++ b/drivers/cpufreq/Kconfig
  101. @@ -334,7 +334,7 @@ endif
  102. config QORIQ_CPUFREQ
  103. tristate "CPU frequency scaling driver for Freescale QorIQ SoCs"
  104. - depends on OF && COMMON_CLK && (PPC_E500MC || ARM)
  105. + depends on OF && COMMON_CLK && (PPC_E500MC || ARM || ARM64)
  106. depends on !CPU_THERMAL || THERMAL
  107. select CLK_QORIQ
  108. help
  109. --- a/drivers/cpufreq/qoriq-cpufreq.c
  110. +++ b/drivers/cpufreq/qoriq-cpufreq.c
  111. @@ -11,6 +11,7 @@
  112. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  113. #include <linux/clk.h>
  114. +#include <linux/clk-provider.h>
  115. #include <linux/cpufreq.h>
  116. #include <linux/cpu_cooling.h>
  117. #include <linux/errno.h>
  118. @@ -22,10 +23,6 @@
  119. #include <linux/slab.h>
  120. #include <linux/smp.h>
  121. -#if !defined(CONFIG_ARM)
  122. -#include <asm/smp.h> /* for get_hard_smp_processor_id() in UP configs */
  123. -#endif
  124. -
  125. /**
  126. * struct cpu_data
  127. * @pclk: the parent clock of cpu
  128. @@ -37,73 +34,51 @@ struct cpu_data {
  129. struct thermal_cooling_device *cdev;
  130. };
  131. +/*
  132. + * Don't use cpufreq on this SoC -- used when the SoC would have otherwise
  133. + * matched a more generic compatible.
  134. + */
  135. +#define SOC_BLACKLIST 1
  136. +
  137. /**
  138. * struct soc_data - SoC specific data
  139. - * @freq_mask: mask the disallowed frequencies
  140. - * @flag: unique flags
  141. + * @flags: SOC_xxx
  142. */
  143. struct soc_data {
  144. - u32 freq_mask[4];
  145. - u32 flag;
  146. -};
  147. -
  148. -#define FREQ_MASK 1
  149. -/* see hardware specification for the allowed frqeuencies */
  150. -static const struct soc_data sdata[] = {
  151. - { /* used by p2041 and p3041 */
  152. - .freq_mask = {0x8, 0x8, 0x2, 0x2},
  153. - .flag = FREQ_MASK,
  154. - },
  155. - { /* used by p5020 */
  156. - .freq_mask = {0x8, 0x2},
  157. - .flag = FREQ_MASK,
  158. - },
  159. - { /* used by p4080, p5040 */
  160. - .freq_mask = {0},
  161. - .flag = 0,
  162. - },
  163. + u32 flags;
  164. };
  165. -/*
  166. - * the minimum allowed core frequency, in Hz
  167. - * for chassis v1.0, >= platform frequency
  168. - * for chassis v2.0, >= platform frequency / 2
  169. - */
  170. -static u32 min_cpufreq;
  171. -static const u32 *fmask;
  172. -
  173. -#if defined(CONFIG_ARM)
  174. -static int get_cpu_physical_id(int cpu)
  175. -{
  176. - return topology_core_id(cpu);
  177. -}
  178. -#else
  179. -static int get_cpu_physical_id(int cpu)
  180. -{
  181. - return get_hard_smp_processor_id(cpu);
  182. -}
  183. -#endif
  184. -
  185. static u32 get_bus_freq(void)
  186. {
  187. struct device_node *soc;
  188. u32 sysfreq;
  189. + struct clk *pltclk;
  190. + int ret;
  191. + /* get platform freq by searching bus-frequency property */
  192. soc = of_find_node_by_type(NULL, "soc");
  193. - if (!soc)
  194. - return 0;
  195. -
  196. - if (of_property_read_u32(soc, "bus-frequency", &sysfreq))
  197. - sysfreq = 0;
  198. + if (soc) {
  199. + ret = of_property_read_u32(soc, "bus-frequency", &sysfreq);
  200. + of_node_put(soc);
  201. + if (!ret)
  202. + return sysfreq;
  203. + }
  204. - of_node_put(soc);
  205. + /* get platform freq by its clock name */
  206. + pltclk = clk_get(NULL, "cg-pll0-div1");
  207. + if (IS_ERR(pltclk)) {
  208. + pr_err("%s: can't get bus frequency %ld\n",
  209. + __func__, PTR_ERR(pltclk));
  210. + return PTR_ERR(pltclk);
  211. + }
  212. - return sysfreq;
  213. + return clk_get_rate(pltclk);
  214. }
  215. -static struct device_node *cpu_to_clk_node(int cpu)
  216. +static struct clk *cpu_to_clk(int cpu)
  217. {
  218. - struct device_node *np, *clk_np;
  219. + struct device_node *np;
  220. + struct clk *clk;
  221. if (!cpu_present(cpu))
  222. return NULL;
  223. @@ -112,37 +87,28 @@ static struct device_node *cpu_to_clk_no
  224. if (!np)
  225. return NULL;
  226. - clk_np = of_parse_phandle(np, "clocks", 0);
  227. - if (!clk_np)
  228. - return NULL;
  229. -
  230. + clk = of_clk_get(np, 0);
  231. of_node_put(np);
  232. -
  233. - return clk_np;
  234. + return clk;
  235. }
  236. /* traverse cpu nodes to get cpu mask of sharing clock wire */
  237. static void set_affected_cpus(struct cpufreq_policy *policy)
  238. {
  239. - struct device_node *np, *clk_np;
  240. struct cpumask *dstp = policy->cpus;
  241. + struct clk *clk;
  242. int i;
  243. - np = cpu_to_clk_node(policy->cpu);
  244. - if (!np)
  245. - return;
  246. -
  247. for_each_present_cpu(i) {
  248. - clk_np = cpu_to_clk_node(i);
  249. - if (!clk_np)
  250. + clk = cpu_to_clk(i);
  251. + if (IS_ERR(clk)) {
  252. + pr_err("%s: no clock for cpu %d\n", __func__, i);
  253. continue;
  254. + }
  255. - if (clk_np == np)
  256. + if (clk_is_match(policy->clk, clk))
  257. cpumask_set_cpu(i, dstp);
  258. -
  259. - of_node_put(clk_np);
  260. }
  261. - of_node_put(np);
  262. }
  263. /* reduce the duplicated frequencies in frequency table */
  264. @@ -198,10 +164,11 @@ static void freq_table_sort(struct cpufr
  265. static int qoriq_cpufreq_cpu_init(struct cpufreq_policy *policy)
  266. {
  267. - struct device_node *np, *pnode;
  268. + struct device_node *np;
  269. int i, count, ret;
  270. - u32 freq, mask;
  271. + u32 freq;
  272. struct clk *clk;
  273. + const struct clk_hw *hwclk;
  274. struct cpufreq_frequency_table *table;
  275. struct cpu_data *data;
  276. unsigned int cpu = policy->cpu;
  277. @@ -221,17 +188,13 @@ static int qoriq_cpufreq_cpu_init(struct
  278. goto err_nomem2;
  279. }
  280. - pnode = of_parse_phandle(np, "clocks", 0);
  281. - if (!pnode) {
  282. - pr_err("%s: could not get clock information\n", __func__);
  283. - goto err_nomem2;
  284. - }
  285. + hwclk = __clk_get_hw(policy->clk);
  286. + count = clk_hw_get_num_parents(hwclk);
  287. - count = of_property_count_strings(pnode, "clock-names");
  288. data->pclk = kcalloc(count, sizeof(struct clk *), GFP_KERNEL);
  289. if (!data->pclk) {
  290. pr_err("%s: no memory\n", __func__);
  291. - goto err_node;
  292. + goto err_nomem2;
  293. }
  294. table = kcalloc(count + 1, sizeof(*table), GFP_KERNEL);
  295. @@ -240,23 +203,11 @@ static int qoriq_cpufreq_cpu_init(struct
  296. goto err_pclk;
  297. }
  298. - if (fmask)
  299. - mask = fmask[get_cpu_physical_id(cpu)];
  300. - else
  301. - mask = 0x0;
  302. -
  303. for (i = 0; i < count; i++) {
  304. - clk = of_clk_get(pnode, i);
  305. + clk = clk_hw_get_parent_by_index(hwclk, i)->clk;
  306. data->pclk[i] = clk;
  307. freq = clk_get_rate(clk);
  308. - /*
  309. - * the clock is valid if its frequency is not masked
  310. - * and large than minimum allowed frequency.
  311. - */
  312. - if (freq < min_cpufreq || (mask & (1 << i)))
  313. - table[i].frequency = CPUFREQ_ENTRY_INVALID;
  314. - else
  315. - table[i].frequency = freq / 1000;
  316. + table[i].frequency = freq / 1000;
  317. table[i].driver_data = i;
  318. }
  319. freq_table_redup(table, count);
  320. @@ -282,7 +233,6 @@ static int qoriq_cpufreq_cpu_init(struct
  321. policy->cpuinfo.transition_latency = u64temp + 1;
  322. of_node_put(np);
  323. - of_node_put(pnode);
  324. return 0;
  325. @@ -290,10 +240,7 @@ err_nomem1:
  326. kfree(table);
  327. err_pclk:
  328. kfree(data->pclk);
  329. -err_node:
  330. - of_node_put(pnode);
  331. err_nomem2:
  332. - policy->driver_data = NULL;
  333. kfree(data);
  334. err_np:
  335. of_node_put(np);
  336. @@ -357,12 +304,25 @@ static struct cpufreq_driver qoriq_cpufr
  337. .attr = cpufreq_generic_attr,
  338. };
  339. +static const struct soc_data blacklist = {
  340. + .flags = SOC_BLACKLIST,
  341. +};
  342. +
  343. static const struct of_device_id node_matches[] __initconst = {
  344. - { .compatible = "fsl,p2041-clockgen", .data = &sdata[0], },
  345. - { .compatible = "fsl,p3041-clockgen", .data = &sdata[0], },
  346. - { .compatible = "fsl,p5020-clockgen", .data = &sdata[1], },
  347. - { .compatible = "fsl,p4080-clockgen", .data = &sdata[2], },
  348. - { .compatible = "fsl,p5040-clockgen", .data = &sdata[2], },
  349. + /* e6500 cannot use cpufreq due to erratum A-008083 */
  350. + { .compatible = "fsl,b4420-clockgen", &blacklist },
  351. + { .compatible = "fsl,b4860-clockgen", &blacklist },
  352. + { .compatible = "fsl,t2080-clockgen", &blacklist },
  353. + { .compatible = "fsl,t4240-clockgen", &blacklist },
  354. +
  355. + { .compatible = "fsl,ls1012a-clockgen", },
  356. + { .compatible = "fsl,ls1021a-clockgen", },
  357. + { .compatible = "fsl,ls1043a-clockgen", },
  358. + { .compatible = "fsl,ls1046a-clockgen", },
  359. + { .compatible = "fsl,ls1088a-clockgen", },
  360. + { .compatible = "fsl,ls2080a-clockgen", },
  361. + { .compatible = "fsl,p4080-clockgen", },
  362. + { .compatible = "fsl,qoriq-clockgen-1.0", },
  363. { .compatible = "fsl,qoriq-clockgen-2.0", },
  364. {}
  365. };
  366. @@ -380,16 +340,12 @@ static int __init qoriq_cpufreq_init(voi
  367. match = of_match_node(node_matches, np);
  368. data = match->data;
  369. - if (data) {
  370. - if (data->flag)
  371. - fmask = data->freq_mask;
  372. - min_cpufreq = get_bus_freq();
  373. - } else {
  374. - min_cpufreq = get_bus_freq() / 2;
  375. - }
  376. of_node_put(np);
  377. + if (data && data->flags & SOC_BLACKLIST)
  378. + return -ENODEV;
  379. +
  380. ret = cpufreq_register_driver(&qoriq_cpufreq_driver);
  381. if (!ret)
  382. pr_info("Freescale QorIQ CPU frequency scaling driver\n");
  383. --- a/drivers/firmware/psci.c
  384. +++ b/drivers/firmware/psci.c
  385. @@ -437,8 +437,12 @@ CPUIDLE_METHOD_OF_DECLARE(psci, "psci",
  386. static int psci_system_suspend(unsigned long unused)
  387. {
  388. - return invoke_psci_fn(PSCI_FN_NATIVE(1_0, SYSTEM_SUSPEND),
  389. - virt_to_phys(cpu_resume), 0, 0);
  390. + u32 state;
  391. +
  392. + state = ( 2 << PSCI_0_2_POWER_STATE_AFFL_SHIFT) |
  393. + (1 << PSCI_0_2_POWER_STATE_TYPE_SHIFT);
  394. +
  395. + return psci_cpu_suspend(state, virt_to_phys(cpu_resume));
  396. }
  397. static int psci_system_suspend_enter(suspend_state_t state)
  398. @@ -458,6 +462,8 @@ static void __init psci_init_system_susp
  399. if (!IS_ENABLED(CONFIG_SUSPEND))
  400. return;
  401. + suspend_set_ops(&psci_suspend_ops);
  402. +
  403. ret = psci_features(PSCI_FN_NATIVE(1_0, SYSTEM_SUSPEND));
  404. if (ret != PSCI_RET_NOT_SUPPORTED)
  405. @@ -562,6 +568,8 @@ static void __init psci_0_2_set_function
  406. arm_pm_restart = psci_sys_reset;
  407. pm_power_off = psci_sys_poweroff;
  408. + psci_init_system_suspend();
  409. + suspend_set_ops(&psci_suspend_ops);
  410. }
  411. /*
  412. --- /dev/null
  413. +++ b/drivers/soc/fsl/rcpm.c
  414. @@ -0,0 +1,158 @@
  415. +/*
  416. + * Run Control and Power Management (RCPM) driver
  417. + *
  418. + * Copyright 2016 NXP
  419. + *
  420. + * This program is free software; you can redistribute it and/or modify
  421. + * it under the terms of the GNU General Public License as published by
  422. + * the Free Software Foundation; either version 2 of the License, or
  423. + * (at your option) any later version.
  424. + *
  425. + * This program is distributed in the hope that it will be useful,
  426. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  427. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  428. + * GNU General Public License for more details.
  429. + *
  430. + */
  431. +#define pr_fmt(fmt) "RCPM: %s: " fmt, __func__
  432. +
  433. +#include <linux/kernel.h>
  434. +#include <linux/io.h>
  435. +#include <linux/of_platform.h>
  436. +#include <linux/of_address.h>
  437. +#include <linux/suspend.h>
  438. +
  439. +/* RCPM register offset */
  440. +#define RCPM_IPPDEXPCR0 0x140
  441. +
  442. +#define RCPM_WAKEUP_CELL_SIZE 2
  443. +
  444. +struct rcpm_config {
  445. + int ipp_num;
  446. + int ippdexpcr_offset;
  447. + u32 ippdexpcr[2];
  448. + void *rcpm_reg_base;
  449. +};
  450. +
  451. +static struct rcpm_config *rcpm;
  452. +
  453. +static inline void rcpm_reg_write(u32 offset, u32 value)
  454. +{
  455. + iowrite32be(value, rcpm->rcpm_reg_base + offset);
  456. +}
  457. +
  458. +static inline u32 rcpm_reg_read(u32 offset)
  459. +{
  460. + return ioread32be(rcpm->rcpm_reg_base + offset);
  461. +}
  462. +
  463. +static void rcpm_wakeup_fixup(struct device *dev, void *data)
  464. +{
  465. + struct device_node *node = dev ? dev->of_node : NULL;
  466. + u32 value[RCPM_WAKEUP_CELL_SIZE];
  467. + int ret, i;
  468. +
  469. + if (!dev || !node || !device_may_wakeup(dev))
  470. + return;
  471. +
  472. + /*
  473. + * Get the values in the "rcpm-wakeup" property.
  474. + * Three values are:
  475. + * The first is a pointer to the RCPM node.
  476. + * The second is the value of the ippdexpcr0 register.
  477. + * The third is the value of the ippdexpcr1 register.
  478. + */
  479. + ret = of_property_read_u32_array(node, "fsl,rcpm-wakeup",
  480. + value, RCPM_WAKEUP_CELL_SIZE);
  481. + if (ret)
  482. + return;
  483. +
  484. + pr_debug("wakeup source: the device %s\n", node->full_name);
  485. +
  486. + for (i = 0; i < rcpm->ipp_num; i++)
  487. + rcpm->ippdexpcr[i] |= value[i + 1];
  488. +}
  489. +
  490. +static int rcpm_suspend_prepare(void)
  491. +{
  492. + int i;
  493. + u32 val;
  494. +
  495. + BUG_ON(!rcpm);
  496. +
  497. + for (i = 0; i < rcpm->ipp_num; i++)
  498. + rcpm->ippdexpcr[i] = 0;
  499. +
  500. + dpm_for_each_dev(NULL, rcpm_wakeup_fixup);
  501. +
  502. + for (i = 0; i < rcpm->ipp_num; i++) {
  503. + if (rcpm->ippdexpcr[i]) {
  504. + val = rcpm_reg_read(rcpm->ippdexpcr_offset + 4 * i);
  505. + rcpm_reg_write(rcpm->ippdexpcr_offset + 4 * i,
  506. + val | rcpm->ippdexpcr[i]);
  507. + pr_debug("ippdexpcr%d = 0x%x\n", i, rcpm->ippdexpcr[i]);
  508. + }
  509. + }
  510. +
  511. + return 0;
  512. +}
  513. +
  514. +static int rcpm_suspend_notifier_call(struct notifier_block *bl,
  515. + unsigned long state,
  516. + void *unused)
  517. +{
  518. + switch (state) {
  519. + case PM_SUSPEND_PREPARE:
  520. + rcpm_suspend_prepare();
  521. + break;
  522. + }
  523. +
  524. + return NOTIFY_DONE;
  525. +}
  526. +
  527. +static struct rcpm_config rcpm_default_config = {
  528. + .ipp_num = 1,
  529. + .ippdexpcr_offset = RCPM_IPPDEXPCR0,
  530. +};
  531. +
  532. +static const struct of_device_id rcpm_matches[] = {
  533. + {
  534. + .compatible = "fsl,qoriq-rcpm-2.1",
  535. + .data = &rcpm_default_config,
  536. + },
  537. + {}
  538. +};
  539. +
  540. +static struct notifier_block rcpm_suspend_notifier = {
  541. + .notifier_call = rcpm_suspend_notifier_call,
  542. +};
  543. +
  544. +static int __init layerscape_rcpm_init(void)
  545. +{
  546. + const struct of_device_id *match;
  547. + struct device_node *np;
  548. +
  549. + np = of_find_matching_node_and_match(NULL, rcpm_matches, &match);
  550. + if (!np) {
  551. + pr_err("Can't find the RCPM node.\n");
  552. + return -EINVAL;
  553. + }
  554. +
  555. + if (match->data)
  556. + rcpm = (struct rcpm_config *)match->data;
  557. + else
  558. + return -EINVAL;
  559. +
  560. + rcpm->rcpm_reg_base = of_iomap(np, 0);
  561. + of_node_put(np);
  562. + if (!rcpm->rcpm_reg_base)
  563. + return -ENOMEM;
  564. +
  565. + register_pm_notifier(&rcpm_suspend_notifier);
  566. +
  567. + pr_info("The RCPM driver initialized.\n");
  568. +
  569. + return 0;
  570. +}
  571. +
  572. +subsys_initcall(layerscape_rcpm_init);
  573. --- /dev/null
  574. +++ b/drivers/soc/fsl/sleep_fsm.c
  575. @@ -0,0 +1,279 @@
  576. +/*
  577. + * deep sleep FSM (finite-state machine) configuration
  578. + *
  579. + * Copyright 2018 NXP
  580. + *
  581. + * Author: Hongbo Zhang <[email protected]>
  582. + * Chenhui Zhao <[email protected]>
  583. + *
  584. + * Redistribution and use in source and binary forms, with or without
  585. + * modification, are permitted provided that the following conditions are met:
  586. + * * Redistributions of source code must retain the above copyright
  587. + * notice, this list of conditions and the following disclaimer.
  588. + * * Redistributions in binary form must reproduce the above copyright
  589. + * notice, this list of conditions and the following disclaimer in the
  590. + * documentation and/or other materials provided with the distribution.
  591. + * * Neither the name of the above-listed copyright holders nor the
  592. + * names of any contributors may be used to endorse or promote products
  593. + * derived from this software without specific prior written permission.
  594. + *
  595. + * ALTERNATIVELY, this software may be distributed under the terms of the
  596. + * GNU General Public License ("GPL") as published by the Free Software
  597. + * Foundation, either version 2 of that License or (at your option) any
  598. + * later version.
  599. + *
  600. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  601. + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  602. + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  603. + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
  604. + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  605. + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  606. + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  607. + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  608. + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  609. + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  610. + * POSSIBILITY OF SUCH DAMAGE.
  611. + */
  612. +
  613. +#include <linux/kernel.h>
  614. +#include <linux/io.h>
  615. +#include <linux/types.h>
  616. +
  617. +#include "sleep_fsm.h"
  618. +/*
  619. + * These values are from chip's reference manual. For example,
  620. + * the values for T1040 can be found in "8.4.3.8 Programming
  621. + * supporting deep sleep mode" of Chapter 8 "Run Control and
  622. + * Power Management (RCPM)".
  623. + * The default value can be applied to T104x, LS1021.
  624. + */
  625. +struct fsm_reg_vals epu_default_val[] = {
  626. + /* EPGCR (Event Processor Global Control Register) */
  627. + {EPGCR, 0},
  628. + /* EPECR (Event Processor Event Control Registers) */
  629. + {EPECR0 + EPECR_STRIDE * 0, 0},
  630. + {EPECR0 + EPECR_STRIDE * 1, 0},
  631. + {EPECR0 + EPECR_STRIDE * 2, 0xF0004004},
  632. + {EPECR0 + EPECR_STRIDE * 3, 0x80000084},
  633. + {EPECR0 + EPECR_STRIDE * 4, 0x20000084},
  634. + {EPECR0 + EPECR_STRIDE * 5, 0x08000004},
  635. + {EPECR0 + EPECR_STRIDE * 6, 0x80000084},
  636. + {EPECR0 + EPECR_STRIDE * 7, 0x80000084},
  637. + {EPECR0 + EPECR_STRIDE * 8, 0x60000084},
  638. + {EPECR0 + EPECR_STRIDE * 9, 0x08000084},
  639. + {EPECR0 + EPECR_STRIDE * 10, 0x42000084},
  640. + {EPECR0 + EPECR_STRIDE * 11, 0x90000084},
  641. + {EPECR0 + EPECR_STRIDE * 12, 0x80000084},
  642. + {EPECR0 + EPECR_STRIDE * 13, 0x08000084},
  643. + {EPECR0 + EPECR_STRIDE * 14, 0x02000084},
  644. + {EPECR0 + EPECR_STRIDE * 15, 0x00000004},
  645. + /*
  646. + * EPEVTCR (Event Processor EVT Pin Control Registers)
  647. + * SCU8 triger EVT2, and SCU11 triger EVT9
  648. + */
  649. + {EPEVTCR0 + EPEVTCR_STRIDE * 0, 0},
  650. + {EPEVTCR0 + EPEVTCR_STRIDE * 1, 0},
  651. + {EPEVTCR0 + EPEVTCR_STRIDE * 2, 0x80000001},
  652. + {EPEVTCR0 + EPEVTCR_STRIDE * 3, 0},
  653. + {EPEVTCR0 + EPEVTCR_STRIDE * 4, 0},
  654. + {EPEVTCR0 + EPEVTCR_STRIDE * 5, 0},
  655. + {EPEVTCR0 + EPEVTCR_STRIDE * 6, 0},
  656. + {EPEVTCR0 + EPEVTCR_STRIDE * 7, 0},
  657. + {EPEVTCR0 + EPEVTCR_STRIDE * 8, 0},
  658. + {EPEVTCR0 + EPEVTCR_STRIDE * 9, 0xB0000001},
  659. + /* EPCMPR (Event Processor Counter Compare Registers) */
  660. + {EPCMPR0 + EPCMPR_STRIDE * 0, 0},
  661. + {EPCMPR0 + EPCMPR_STRIDE * 1, 0},
  662. + {EPCMPR0 + EPCMPR_STRIDE * 2, 0x000000FF},
  663. + {EPCMPR0 + EPCMPR_STRIDE * 3, 0},
  664. + {EPCMPR0 + EPCMPR_STRIDE * 4, 0x000000FF},
  665. + {EPCMPR0 + EPCMPR_STRIDE * 5, 0x00000020},
  666. + {EPCMPR0 + EPCMPR_STRIDE * 6, 0},
  667. + {EPCMPR0 + EPCMPR_STRIDE * 7, 0},
  668. + {EPCMPR0 + EPCMPR_STRIDE * 8, 0x000000FF},
  669. + {EPCMPR0 + EPCMPR_STRIDE * 9, 0x000000FF},
  670. + {EPCMPR0 + EPCMPR_STRIDE * 10, 0x000000FF},
  671. + {EPCMPR0 + EPCMPR_STRIDE * 11, 0x000000FF},
  672. + {EPCMPR0 + EPCMPR_STRIDE * 12, 0x000000FF},
  673. + {EPCMPR0 + EPCMPR_STRIDE * 13, 0},
  674. + {EPCMPR0 + EPCMPR_STRIDE * 14, 0x000000FF},
  675. + {EPCMPR0 + EPCMPR_STRIDE * 15, 0x000000FF},
  676. + /* EPCCR (Event Processor Counter Control Registers) */
  677. + {EPCCR0 + EPCCR_STRIDE * 0, 0},
  678. + {EPCCR0 + EPCCR_STRIDE * 1, 0},
  679. + {EPCCR0 + EPCCR_STRIDE * 2, 0x92840000},
  680. + {EPCCR0 + EPCCR_STRIDE * 3, 0},
  681. + {EPCCR0 + EPCCR_STRIDE * 4, 0x92840000},
  682. + {EPCCR0 + EPCCR_STRIDE * 5, 0x92840000},
  683. + {EPCCR0 + EPCCR_STRIDE * 6, 0},
  684. + {EPCCR0 + EPCCR_STRIDE * 7, 0},
  685. + {EPCCR0 + EPCCR_STRIDE * 8, 0x92840000},
  686. + {EPCCR0 + EPCCR_STRIDE * 9, 0x92840000},
  687. + {EPCCR0 + EPCCR_STRIDE * 10, 0x92840000},
  688. + {EPCCR0 + EPCCR_STRIDE * 11, 0x92840000},
  689. + {EPCCR0 + EPCCR_STRIDE * 12, 0x92840000},
  690. + {EPCCR0 + EPCCR_STRIDE * 13, 0},
  691. + {EPCCR0 + EPCCR_STRIDE * 14, 0x92840000},
  692. + {EPCCR0 + EPCCR_STRIDE * 15, 0x92840000},
  693. + /* EPSMCR (Event Processor SCU Mux Control Registers) */
  694. + {EPSMCR0 + EPSMCR_STRIDE * 0, 0},
  695. + {EPSMCR0 + EPSMCR_STRIDE * 1, 0},
  696. + {EPSMCR0 + EPSMCR_STRIDE * 2, 0x6C700000},
  697. + {EPSMCR0 + EPSMCR_STRIDE * 3, 0x2F000000},
  698. + {EPSMCR0 + EPSMCR_STRIDE * 4, 0x002F0000},
  699. + {EPSMCR0 + EPSMCR_STRIDE * 5, 0x00002E00},
  700. + {EPSMCR0 + EPSMCR_STRIDE * 6, 0x7C000000},
  701. + {EPSMCR0 + EPSMCR_STRIDE * 7, 0x30000000},
  702. + {EPSMCR0 + EPSMCR_STRIDE * 8, 0x64300000},
  703. + {EPSMCR0 + EPSMCR_STRIDE * 9, 0x00003000},
  704. + {EPSMCR0 + EPSMCR_STRIDE * 10, 0x65000030},
  705. + {EPSMCR0 + EPSMCR_STRIDE * 11, 0x31740000},
  706. + {EPSMCR0 + EPSMCR_STRIDE * 12, 0x7F000000},
  707. + {EPSMCR0 + EPSMCR_STRIDE * 13, 0x00003100},
  708. + {EPSMCR0 + EPSMCR_STRIDE * 14, 0x00000031},
  709. + {EPSMCR0 + EPSMCR_STRIDE * 15, 0x76000000},
  710. + /* EPACR (Event Processor Action Control Registers) */
  711. + {EPACR0 + EPACR_STRIDE * 0, 0},
  712. + {EPACR0 + EPACR_STRIDE * 1, 0},
  713. + {EPACR0 + EPACR_STRIDE * 2, 0},
  714. + {EPACR0 + EPACR_STRIDE * 3, 0x00000080},
  715. + {EPACR0 + EPACR_STRIDE * 4, 0},
  716. + {EPACR0 + EPACR_STRIDE * 5, 0x00000040},
  717. + {EPACR0 + EPACR_STRIDE * 6, 0},
  718. + {EPACR0 + EPACR_STRIDE * 7, 0},
  719. + {EPACR0 + EPACR_STRIDE * 8, 0},
  720. + {EPACR0 + EPACR_STRIDE * 9, 0x0000001C},
  721. + {EPACR0 + EPACR_STRIDE * 10, 0x00000020},
  722. + {EPACR0 + EPACR_STRIDE * 11, 0},
  723. + {EPACR0 + EPACR_STRIDE * 12, 0x00000003},
  724. + {EPACR0 + EPACR_STRIDE * 13, 0x06000000},
  725. + {EPACR0 + EPACR_STRIDE * 14, 0x04000000},
  726. + {EPACR0 + EPACR_STRIDE * 15, 0x02000000},
  727. + /* EPIMCR (Event Processor Input Mux Control Registers) */
  728. + {EPIMCR0 + EPIMCR_STRIDE * 0, 0},
  729. + {EPIMCR0 + EPIMCR_STRIDE * 1, 0},
  730. + {EPIMCR0 + EPIMCR_STRIDE * 2, 0},
  731. + {EPIMCR0 + EPIMCR_STRIDE * 3, 0},
  732. + {EPIMCR0 + EPIMCR_STRIDE * 4, 0x44000000},
  733. + {EPIMCR0 + EPIMCR_STRIDE * 5, 0x40000000},
  734. + {EPIMCR0 + EPIMCR_STRIDE * 6, 0},
  735. + {EPIMCR0 + EPIMCR_STRIDE * 7, 0},
  736. + {EPIMCR0 + EPIMCR_STRIDE * 8, 0},
  737. + {EPIMCR0 + EPIMCR_STRIDE * 9, 0},
  738. + {EPIMCR0 + EPIMCR_STRIDE * 10, 0},
  739. + {EPIMCR0 + EPIMCR_STRIDE * 11, 0},
  740. + {EPIMCR0 + EPIMCR_STRIDE * 12, 0x44000000},
  741. + {EPIMCR0 + EPIMCR_STRIDE * 13, 0},
  742. + {EPIMCR0 + EPIMCR_STRIDE * 14, 0},
  743. + {EPIMCR0 + EPIMCR_STRIDE * 15, 0},
  744. + {EPIMCR0 + EPIMCR_STRIDE * 16, 0x6A000000},
  745. + {EPIMCR0 + EPIMCR_STRIDE * 17, 0},
  746. + {EPIMCR0 + EPIMCR_STRIDE * 18, 0},
  747. + {EPIMCR0 + EPIMCR_STRIDE * 19, 0},
  748. + {EPIMCR0 + EPIMCR_STRIDE * 20, 0x48000000},
  749. + {EPIMCR0 + EPIMCR_STRIDE * 21, 0},
  750. + {EPIMCR0 + EPIMCR_STRIDE * 22, 0x6C000000},
  751. + {EPIMCR0 + EPIMCR_STRIDE * 23, 0},
  752. + {EPIMCR0 + EPIMCR_STRIDE * 24, 0},
  753. + {EPIMCR0 + EPIMCR_STRIDE * 25, 0},
  754. + {EPIMCR0 + EPIMCR_STRIDE * 26, 0},
  755. + {EPIMCR0 + EPIMCR_STRIDE * 27, 0},
  756. + {EPIMCR0 + EPIMCR_STRIDE * 28, 0x76000000},
  757. + {EPIMCR0 + EPIMCR_STRIDE * 29, 0},
  758. + {EPIMCR0 + EPIMCR_STRIDE * 30, 0},
  759. + {EPIMCR0 + EPIMCR_STRIDE * 31, 0x76000000},
  760. + /* EPXTRIGCR (Event Processor Crosstrigger Control Register) */
  761. + {EPXTRIGCR, 0x0000FFDF},
  762. + /* end */
  763. + {FSM_END_FLAG, 0},
  764. +};
  765. +
  766. +struct fsm_reg_vals npc_default_val[] = {
  767. + /* NPC triggered Memory-Mapped Access Registers */
  768. + {NCR, 0x80000000},
  769. + {MCCR1, 0},
  770. + {MCSR1, 0},
  771. + {MMAR1LO, 0},
  772. + {MMAR1HI, 0},
  773. + {MMDR1, 0},
  774. + {MCSR2, 0},
  775. + {MMAR2LO, 0},
  776. + {MMAR2HI, 0},
  777. + {MMDR2, 0},
  778. + {MCSR3, 0x80000000},
  779. + {MMAR3LO, 0x000E2130},
  780. + {MMAR3HI, 0x00030000},
  781. + {MMDR3, 0x00020000},
  782. + /* end */
  783. + {FSM_END_FLAG, 0},
  784. +};
  785. +
  786. +/**
  787. + * fsl_fsm_setup - Configure EPU's FSM registers
  788. + * @base: the base address of registers
  789. + * @val: Pointer to address-value pairs for FSM registers
  790. + */
  791. +void fsl_fsm_setup(void __iomem *base, struct fsm_reg_vals *val)
  792. +{
  793. + struct fsm_reg_vals *data = val;
  794. +
  795. + WARN_ON(!base || !data);
  796. + while (data->offset != FSM_END_FLAG) {
  797. + iowrite32be(data->value, base + data->offset);
  798. + data++;
  799. + }
  800. +}
  801. +
  802. +void fsl_epu_setup_default(void __iomem *epu_base)
  803. +{
  804. + fsl_fsm_setup(epu_base, epu_default_val);
  805. +}
  806. +
  807. +void fsl_npc_setup_default(void __iomem *npc_base)
  808. +{
  809. + fsl_fsm_setup(npc_base, npc_default_val);
  810. +}
  811. +
  812. +void fsl_epu_clean_default(void __iomem *epu_base)
  813. +{
  814. + u32 offset;
  815. +
  816. + /* follow the exact sequence to clear the registers */
  817. + /* Clear EPACRn */
  818. + for (offset = EPACR0; offset <= EPACR15; offset += EPACR_STRIDE)
  819. + iowrite32be(0, epu_base + offset);
  820. +
  821. + /* Clear EPEVTCRn */
  822. + for (offset = EPEVTCR0; offset <= EPEVTCR9; offset += EPEVTCR_STRIDE)
  823. + iowrite32be(0, epu_base + offset);
  824. +
  825. + /* Clear EPGCR */
  826. + iowrite32be(0, epu_base + EPGCR);
  827. +
  828. + /* Clear EPSMCRn */
  829. + for (offset = EPSMCR0; offset <= EPSMCR15; offset += EPSMCR_STRIDE)
  830. + iowrite32be(0, epu_base + offset);
  831. +
  832. + /* Clear EPCCRn */
  833. + for (offset = EPCCR0; offset <= EPCCR31; offset += EPCCR_STRIDE)
  834. + iowrite32be(0, epu_base + offset);
  835. +
  836. + /* Clear EPCMPRn */
  837. + for (offset = EPCMPR0; offset <= EPCMPR31; offset += EPCMPR_STRIDE)
  838. + iowrite32be(0, epu_base + offset);
  839. +
  840. + /* Clear EPCTRn */
  841. + for (offset = EPCTR0; offset <= EPCTR31; offset += EPCTR_STRIDE)
  842. + iowrite32be(0, epu_base + offset);
  843. +
  844. + /* Clear EPIMCRn */
  845. + for (offset = EPIMCR0; offset <= EPIMCR31; offset += EPIMCR_STRIDE)
  846. + iowrite32be(0, epu_base + offset);
  847. +
  848. + /* Clear EPXTRIGCRn */
  849. + iowrite32be(0, epu_base + EPXTRIGCR);
  850. +
  851. + /* Clear EPECRn */
  852. + for (offset = EPECR0; offset <= EPECR15; offset += EPECR_STRIDE)
  853. + iowrite32be(0, epu_base + offset);
  854. +}
  855. --- /dev/null
  856. +++ b/drivers/soc/fsl/sleep_fsm.h
  857. @@ -0,0 +1,130 @@
  858. +/*
  859. + * deep sleep FSM (finite-state machine) configuration
  860. + *
  861. + * Copyright 2018 NXP
  862. + *
  863. + * Redistribution and use in source and binary forms, with or without
  864. + * modification, are permitted provided that the following conditions are met:
  865. + * * Redistributions of source code must retain the above copyright
  866. + * notice, this list of conditions and the following disclaimer.
  867. + * * Redistributions in binary form must reproduce the above copyright
  868. + * notice, this list of conditions and the following disclaimer in the
  869. + * documentation and/or other materials provided with the distribution.
  870. + * * Neither the name of the above-listed copyright holders nor the
  871. + * names of any contributors may be used to endorse or promote products
  872. + * derived from this software without specific prior written permission.
  873. + *
  874. + *
  875. + * ALTERNATIVELY, this software may be distributed under the terms of the
  876. + * GNU General Public License ("GPL") as published by the Free Software
  877. + * Foundation, either version 2 of that License or (at your option) any
  878. + * later version.
  879. + *
  880. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  881. + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  882. + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  883. + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
  884. + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  885. + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  886. + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  887. + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  888. + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  889. + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  890. + * POSSIBILITY OF SUCH DAMAGE.
  891. + */
  892. +
  893. +#ifndef _FSL_SLEEP_FSM_H
  894. +#define _FSL_SLEEP_FSM_H
  895. +
  896. +#define FSL_STRIDE_4B 4
  897. +#define FSL_STRIDE_8B 8
  898. +
  899. +/* End flag */
  900. +#define FSM_END_FLAG 0xFFFFFFFFUL
  901. +
  902. +/* Block offsets */
  903. +#define RCPM_BLOCK_OFFSET 0x00022000
  904. +#define EPU_BLOCK_OFFSET 0x00000000
  905. +#define NPC_BLOCK_OFFSET 0x00001000
  906. +
  907. +/* EPGCR (Event Processor Global Control Register) */
  908. +#define EPGCR 0x000
  909. +
  910. +/* EPEVTCR0-9 (Event Processor EVT Pin Control Registers) */
  911. +#define EPEVTCR0 0x050
  912. +#define EPEVTCR9 0x074
  913. +#define EPEVTCR_STRIDE FSL_STRIDE_4B
  914. +
  915. +/* EPXTRIGCR (Event Processor Crosstrigger Control Register) */
  916. +#define EPXTRIGCR 0x090
  917. +
  918. +/* EPIMCR0-31 (Event Processor Input Mux Control Registers) */
  919. +#define EPIMCR0 0x100
  920. +#define EPIMCR31 0x17C
  921. +#define EPIMCR_STRIDE FSL_STRIDE_4B
  922. +
  923. +/* EPSMCR0-15 (Event Processor SCU Mux Control Registers) */
  924. +#define EPSMCR0 0x200
  925. +#define EPSMCR15 0x278
  926. +#define EPSMCR_STRIDE FSL_STRIDE_8B
  927. +
  928. +/* EPECR0-15 (Event Processor Event Control Registers) */
  929. +#define EPECR0 0x300
  930. +#define EPECR15 0x33C
  931. +#define EPECR_STRIDE FSL_STRIDE_4B
  932. +
  933. +/* EPACR0-15 (Event Processor Action Control Registers) */
  934. +#define EPACR0 0x400
  935. +#define EPACR15 0x43C
  936. +#define EPACR_STRIDE FSL_STRIDE_4B
  937. +
  938. +/* EPCCRi0-15 (Event Processor Counter Control Registers) */
  939. +#define EPCCR0 0x800
  940. +#define EPCCR15 0x83C
  941. +#define EPCCR31 0x87C
  942. +#define EPCCR_STRIDE FSL_STRIDE_4B
  943. +
  944. +/* EPCMPR0-15 (Event Processor Counter Compare Registers) */
  945. +#define EPCMPR0 0x900
  946. +#define EPCMPR15 0x93C
  947. +#define EPCMPR31 0x97C
  948. +#define EPCMPR_STRIDE FSL_STRIDE_4B
  949. +
  950. +/* EPCTR0-31 (Event Processor Counter Register) */
  951. +#define EPCTR0 0xA00
  952. +#define EPCTR31 0xA7C
  953. +#define EPCTR_STRIDE FSL_STRIDE_4B
  954. +
  955. +/* NPC triggered Memory-Mapped Access Registers */
  956. +#define NCR 0x000
  957. +#define MCCR1 0x0CC
  958. +#define MCSR1 0x0D0
  959. +#define MMAR1LO 0x0D4
  960. +#define MMAR1HI 0x0D8
  961. +#define MMDR1 0x0DC
  962. +#define MCSR2 0x0E0
  963. +#define MMAR2LO 0x0E4
  964. +#define MMAR2HI 0x0E8
  965. +#define MMDR2 0x0EC
  966. +#define MCSR3 0x0F0
  967. +#define MMAR3LO 0x0F4
  968. +#define MMAR3HI 0x0F8
  969. +#define MMDR3 0x0FC
  970. +
  971. +/* RCPM Core State Action Control Register 0 */
  972. +#define CSTTACR0 0xB00
  973. +
  974. +/* RCPM Core Group 1 Configuration Register 0 */
  975. +#define CG1CR0 0x31C
  976. +
  977. +struct fsm_reg_vals {
  978. + u32 offset;
  979. + u32 value;
  980. +};
  981. +
  982. +void fsl_fsm_setup(void __iomem *base, struct fsm_reg_vals *val);
  983. +void fsl_epu_setup_default(void __iomem *epu_base);
  984. +void fsl_npc_setup_default(void __iomem *npc_base);
  985. +void fsl_epu_clean_default(void __iomem *epu_base);
  986. +
  987. +#endif /* _FSL_SLEEP_FSM_H */