4046-mtd-ifc-Segregate-IFC-fcm-and-runtime-registers.patch 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  1. From 1c62b9982b7f6cb560d1237d2658945c070c91d4 Mon Sep 17 00:00:00 2001
  2. From: Raghav Dogra <raghav@freescale.com>
  3. Date: Wed, 20 Jan 2016 13:06:32 +0530
  4. Subject: [PATCH 46/70] mtd/ifc: Segregate IFC fcm and runtime registers
  5. IFC has two set of registers viz FCM (Flash control machine)
  6. aka global and run time registers. These set are defined in two
  7. memory map PAGES. Upto IFC 1.4 PAGE size is 4 KB and from IFC2.0
  8. PAGE size is 64KB
  9. Signed-off-by: Jaiprakash Singh <b44839@freescale.com>
  10. Signed-off-by: Raghav Dogra <raghav@freescale.com>
  11. ---
  12. drivers/memory/fsl_ifc.c | 251 ++++++++++++++++++++-------------------
  13. drivers/mtd/nand/fsl_ifc_nand.c | 72 ++++++-----
  14. include/linux/fsl_ifc.h | 48 +++++---
  15. 3 files changed, 203 insertions(+), 168 deletions(-)
  16. --- a/drivers/memory/fsl_ifc.c
  17. +++ b/drivers/memory/fsl_ifc.c
  18. @@ -64,11 +64,11 @@ int fsl_ifc_find(phys_addr_t addr_base)
  19. {
  20. int i = 0;
  21. - if (!fsl_ifc_ctrl_dev || !fsl_ifc_ctrl_dev->regs)
  22. + if (!fsl_ifc_ctrl_dev || !fsl_ifc_ctrl_dev->gregs)
  23. return -ENODEV;
  24. for (i = 0; i < fsl_ifc_ctrl_dev->banks; i++) {
  25. - u32 cspr = ifc_in32(&fsl_ifc_ctrl_dev->regs->cspr_cs[i].cspr);
  26. + u32 cspr = ifc_in32(&fsl_ifc_ctrl_dev->gregs->cspr_cs[i].cspr);
  27. if (cspr & CSPR_V && (cspr & CSPR_BA) ==
  28. convert_ifc_address(addr_base))
  29. return i;
  30. @@ -80,7 +80,7 @@ EXPORT_SYMBOL(fsl_ifc_find);
  31. static int fsl_ifc_ctrl_init(struct fsl_ifc_ctrl *ctrl)
  32. {
  33. - struct fsl_ifc_regs __iomem *ifc = ctrl->regs;
  34. + struct fsl_ifc_fcm __iomem *ifc = ctrl->gregs;
  35. /*
  36. * Clear all the common status and event registers
  37. @@ -109,7 +109,7 @@ static int fsl_ifc_ctrl_remove(struct pl
  38. irq_dispose_mapping(ctrl->nand_irq);
  39. irq_dispose_mapping(ctrl->irq);
  40. - iounmap(ctrl->regs);
  41. + iounmap(ctrl->gregs);
  42. dev_set_drvdata(&dev->dev, NULL);
  43. kfree(ctrl);
  44. @@ -127,7 +127,7 @@ static DEFINE_SPINLOCK(nand_irq_lock);
  45. static u32 check_nand_stat(struct fsl_ifc_ctrl *ctrl)
  46. {
  47. - struct fsl_ifc_regs __iomem *ifc = ctrl->regs;
  48. + struct fsl_ifc_runtime __iomem *ifc = ctrl->rregs;
  49. unsigned long flags;
  50. u32 stat;
  51. @@ -162,7 +162,7 @@ static irqreturn_t fsl_ifc_nand_irq(int
  52. static irqreturn_t fsl_ifc_ctrl_irq(int irqno, void *data)
  53. {
  54. struct fsl_ifc_ctrl *ctrl = data;
  55. - struct fsl_ifc_regs __iomem *ifc = ctrl->regs;
  56. + struct fsl_ifc_fcm __iomem *ifc = ctrl->gregs;
  57. u32 err_axiid, err_srcid, status, cs_err, err_addr;
  58. irqreturn_t ret = IRQ_NONE;
  59. @@ -220,6 +220,7 @@ static int fsl_ifc_ctrl_probe(struct pla
  60. {
  61. int ret = 0;
  62. int version, banks;
  63. + void __iomem *addr;
  64. dev_info(&dev->dev, "Freescale Integrated Flash Controller\n");
  65. @@ -230,22 +231,13 @@ static int fsl_ifc_ctrl_probe(struct pla
  66. dev_set_drvdata(&dev->dev, fsl_ifc_ctrl_dev);
  67. /* IOMAP the entire IFC region */
  68. - fsl_ifc_ctrl_dev->regs = of_iomap(dev->dev.of_node, 0);
  69. - if (!fsl_ifc_ctrl_dev->regs) {
  70. + fsl_ifc_ctrl_dev->gregs = of_iomap(dev->dev.of_node, 0);
  71. + if (!fsl_ifc_ctrl_dev->gregs) {
  72. dev_err(&dev->dev, "failed to get memory region\n");
  73. ret = -ENODEV;
  74. goto err;
  75. }
  76. - version = ifc_in32(&fsl_ifc_ctrl_dev->regs->ifc_rev) &
  77. - FSL_IFC_VERSION_MASK;
  78. - banks = (version == FSL_IFC_VERSION_1_0_0) ? 4 : 8;
  79. - dev_info(&dev->dev, "IFC version %d.%d, %d banks\n",
  80. - version >> 24, (version >> 16) & 0xf, banks);
  81. -
  82. - fsl_ifc_ctrl_dev->version = version;
  83. - fsl_ifc_ctrl_dev->banks = banks;
  84. -
  85. if (of_property_read_bool(dev->dev.of_node, "little-endian")) {
  86. fsl_ifc_ctrl_dev->little_endian = true;
  87. dev_dbg(&dev->dev, "IFC REGISTERS are LITTLE endian\n");
  88. @@ -254,8 +246,9 @@ static int fsl_ifc_ctrl_probe(struct pla
  89. dev_dbg(&dev->dev, "IFC REGISTERS are BIG endian\n");
  90. }
  91. - version = ioread32be(&fsl_ifc_ctrl_dev->regs->ifc_rev) &
  92. + version = ifc_in32(&fsl_ifc_ctrl_dev->gregs->ifc_rev) &
  93. FSL_IFC_VERSION_MASK;
  94. +
  95. banks = (version == FSL_IFC_VERSION_1_0_0) ? 4 : 8;
  96. dev_info(&dev->dev, "IFC version %d.%d, %d banks\n",
  97. version >> 24, (version >> 16) & 0xf, banks);
  98. @@ -263,6 +256,14 @@ static int fsl_ifc_ctrl_probe(struct pla
  99. fsl_ifc_ctrl_dev->version = version;
  100. fsl_ifc_ctrl_dev->banks = banks;
  101. + addr = fsl_ifc_ctrl_dev->gregs;
  102. + if (version >= FSL_IFC_VERSION_2_0_0)
  103. + fsl_ifc_ctrl_dev->rregs =
  104. + (struct fsl_ifc_runtime *)(addr + PGOFFSET_64K);
  105. + else
  106. + fsl_ifc_ctrl_dev->rregs =
  107. + (struct fsl_ifc_runtime *)(addr + PGOFFSET_4K);
  108. +
  109. /* get the Controller level irq */
  110. fsl_ifc_ctrl_dev->irq = irq_of_parse_and_map(dev->dev.of_node, 0);
  111. if (fsl_ifc_ctrl_dev->irq == 0) {
  112. @@ -319,33 +320,39 @@ err:
  113. static int fsl_ifc_suspend(struct device *dev)
  114. {
  115. struct fsl_ifc_ctrl *ctrl = dev_get_drvdata(dev);
  116. - struct fsl_ifc_regs __iomem *ifc = ctrl->regs;
  117. + struct fsl_ifc_fcm __iomem *fcm = ctrl->gregs;
  118. + struct fsl_ifc_runtime __iomem *runtime = ctrl->rregs;
  119. __be32 nand_evter_intr_en, cm_evter_intr_en, nor_evter_intr_en,
  120. gpcm_evter_intr_en;
  121. - ctrl->saved_regs = kzalloc(sizeof(struct fsl_ifc_regs), GFP_KERNEL);
  122. - if (!ctrl->saved_regs)
  123. + ctrl->saved_gregs = kzalloc(sizeof(struct fsl_ifc_fcm), GFP_KERNEL);
  124. + if (!ctrl->saved_gregs)
  125. + return -ENOMEM;
  126. + ctrl->saved_rregs = kzalloc(sizeof(struct fsl_ifc_runtime), GFP_KERNEL);
  127. + if (!ctrl->saved_rregs)
  128. return -ENOMEM;
  129. - cm_evter_intr_en = ifc_in32(&ifc->cm_evter_intr_en);
  130. - nand_evter_intr_en = ifc_in32(&ifc->ifc_nand.nand_evter_intr_en);
  131. - nor_evter_intr_en = ifc_in32(&ifc->ifc_nor.nor_evter_intr_en);
  132. - gpcm_evter_intr_en = ifc_in32(&ifc->ifc_gpcm.gpcm_evter_intr_en);
  133. + cm_evter_intr_en = ifc_in32(&fcm->cm_evter_intr_en);
  134. + nand_evter_intr_en = ifc_in32(&runtime->ifc_nand.nand_evter_intr_en);
  135. + nor_evter_intr_en = ifc_in32(&runtime->ifc_nor.nor_evter_intr_en);
  136. + gpcm_evter_intr_en = ifc_in32(&runtime->ifc_gpcm.gpcm_evter_intr_en);
  137. /* IFC interrupts disabled */
  138. - ifc_out32(0x0, &ifc->cm_evter_intr_en);
  139. - ifc_out32(0x0, &ifc->ifc_nand.nand_evter_intr_en);
  140. - ifc_out32(0x0, &ifc->ifc_nor.nor_evter_intr_en);
  141. - ifc_out32(0x0, &ifc->ifc_gpcm.gpcm_evter_intr_en);
  142. -
  143. - memcpy_fromio(ctrl->saved_regs, ifc, sizeof(struct fsl_ifc_regs));
  144. + ifc_out32(0x0, &fcm->cm_evter_intr_en);
  145. + ifc_out32(0x0, &runtime->ifc_nand.nand_evter_intr_en);
  146. + ifc_out32(0x0, &runtime->ifc_nor.nor_evter_intr_en);
  147. + ifc_out32(0x0, &runtime->ifc_gpcm.gpcm_evter_intr_en);
  148. +
  149. + memcpy_fromio(ctrl->saved_gregs, fcm, sizeof(struct fsl_ifc_fcm));
  150. + memcpy_fromio(ctrl->saved_rregs, runtime,
  151. + sizeof(struct fsl_ifc_runtime));
  152. /* save the interrupt values */
  153. - ctrl->saved_regs->cm_evter_intr_en = cm_evter_intr_en;
  154. - ctrl->saved_regs->ifc_nand.nand_evter_intr_en = nand_evter_intr_en;
  155. - ctrl->saved_regs->ifc_nor.nor_evter_intr_en = nor_evter_intr_en;
  156. - ctrl->saved_regs->ifc_gpcm.gpcm_evter_intr_en = gpcm_evter_intr_en;
  157. + ctrl->saved_gregs->cm_evter_intr_en = cm_evter_intr_en;
  158. + ctrl->saved_rregs->ifc_nand.nand_evter_intr_en = nand_evter_intr_en;
  159. + ctrl->saved_rregs->ifc_nor.nor_evter_intr_en = nor_evter_intr_en;
  160. + ctrl->saved_rregs->ifc_gpcm.gpcm_evter_intr_en = gpcm_evter_intr_en;
  161. return 0;
  162. }
  163. @@ -354,110 +361,116 @@ static int fsl_ifc_suspend(struct device
  164. static int fsl_ifc_resume(struct device *dev)
  165. {
  166. struct fsl_ifc_ctrl *ctrl = dev_get_drvdata(dev);
  167. - struct fsl_ifc_regs __iomem *ifc = ctrl->regs;
  168. - struct fsl_ifc_regs *savd_regs = ctrl->saved_regs;
  169. + struct fsl_ifc_fcm __iomem *fcm = ctrl->gregs;
  170. + struct fsl_ifc_runtime __iomem *runtime = ctrl->rregs;
  171. + struct fsl_ifc_fcm *savd_gregs = ctrl->saved_gregs;
  172. + struct fsl_ifc_runtime *savd_rregs = ctrl->saved_rregs;
  173. uint32_t ver = 0, ncfgr, status, ifc_bank, i;
  174. /*
  175. * IFC interrupts disabled
  176. */
  177. - ifc_out32(0x0, &ifc->cm_evter_intr_en);
  178. - ifc_out32(0x0, &ifc->ifc_nand.nand_evter_intr_en);
  179. - ifc_out32(0x0, &ifc->ifc_nor.nor_evter_intr_en);
  180. - ifc_out32(0x0, &ifc->ifc_gpcm.gpcm_evter_intr_en);
  181. + ifc_out32(0x0, &fcm->cm_evter_intr_en);
  182. + ifc_out32(0x0, &runtime->ifc_nand.nand_evter_intr_en);
  183. + ifc_out32(0x0, &runtime->ifc_nor.nor_evter_intr_en);
  184. + ifc_out32(0x0, &runtime->ifc_gpcm.gpcm_evter_intr_en);
  185. - if (ctrl->saved_regs) {
  186. + if (ctrl->saved_gregs) {
  187. for (ifc_bank = 0; ifc_bank < FSL_IFC_BANK_COUNT; ifc_bank++) {
  188. - ifc_out32(savd_regs->cspr_cs[ifc_bank].cspr_ext,
  189. - &ifc->cspr_cs[ifc_bank].cspr_ext);
  190. - ifc_out32(savd_regs->cspr_cs[ifc_bank].cspr,
  191. - &ifc->cspr_cs[ifc_bank].cspr);
  192. - ifc_out32(savd_regs->amask_cs[ifc_bank].amask,
  193. - &ifc->amask_cs[ifc_bank].amask);
  194. - ifc_out32(savd_regs->csor_cs[ifc_bank].csor_ext,
  195. - &ifc->csor_cs[ifc_bank].csor_ext);
  196. - ifc_out32(savd_regs->csor_cs[ifc_bank].csor,
  197. - &ifc->csor_cs[ifc_bank].csor);
  198. + ifc_out32(savd_gregs->cspr_cs[ifc_bank].cspr_ext,
  199. + &fcm->cspr_cs[ifc_bank].cspr_ext);
  200. + ifc_out32(savd_gregs->cspr_cs[ifc_bank].cspr,
  201. + &fcm->cspr_cs[ifc_bank].cspr);
  202. + ifc_out32(savd_gregs->amask_cs[ifc_bank].amask,
  203. + &fcm->amask_cs[ifc_bank].amask);
  204. + ifc_out32(savd_gregs->csor_cs[ifc_bank].csor_ext,
  205. + &fcm->csor_cs[ifc_bank].csor_ext);
  206. + ifc_out32(savd_gregs->csor_cs[ifc_bank].csor,
  207. + &fcm->csor_cs[ifc_bank].csor);
  208. for (i = 0; i < 4; i++) {
  209. - ifc_out32(savd_regs->ftim_cs[ifc_bank].ftim[i],
  210. - &ifc->ftim_cs[ifc_bank].ftim[i]);
  211. + ifc_out32(savd_gregs->ftim_cs[ifc_bank].ftim[i],
  212. + &fcm->ftim_cs[ifc_bank].ftim[i]);
  213. }
  214. }
  215. - ifc_out32(savd_regs->ifc_gcr, &ifc->ifc_gcr);
  216. - ifc_out32(savd_regs->cm_evter_en, &ifc->cm_evter_en);
  217. -
  218. -/*
  219. -* IFC controller NAND machine registers
  220. -*/
  221. - ifc_out32(savd_regs->ifc_nand.ncfgr, &ifc->ifc_nand.ncfgr);
  222. - ifc_out32(savd_regs->ifc_nand.nand_fcr0,
  223. - &ifc->ifc_nand.nand_fcr0);
  224. - ifc_out32(savd_regs->ifc_nand.nand_fcr1,
  225. - &ifc->ifc_nand.nand_fcr1);
  226. - ifc_out32(savd_regs->ifc_nand.row0, &ifc->ifc_nand.row0);
  227. - ifc_out32(savd_regs->ifc_nand.row1, &ifc->ifc_nand.row1);
  228. - ifc_out32(savd_regs->ifc_nand.col0, &ifc->ifc_nand.col0);
  229. - ifc_out32(savd_regs->ifc_nand.col1, &ifc->ifc_nand.col1);
  230. - ifc_out32(savd_regs->ifc_nand.row2, &ifc->ifc_nand.row2);
  231. - ifc_out32(savd_regs->ifc_nand.col2, &ifc->ifc_nand.col2);
  232. - ifc_out32(savd_regs->ifc_nand.row3, &ifc->ifc_nand.row3);
  233. - ifc_out32(savd_regs->ifc_nand.col3, &ifc->ifc_nand.col3);
  234. - ifc_out32(savd_regs->ifc_nand.nand_fbcr,
  235. - &ifc->ifc_nand.nand_fbcr);
  236. - ifc_out32(savd_regs->ifc_nand.nand_fir0,
  237. - &ifc->ifc_nand.nand_fir0);
  238. - ifc_out32(savd_regs->ifc_nand.nand_fir1,
  239. - &ifc->ifc_nand.nand_fir1);
  240. - ifc_out32(savd_regs->ifc_nand.nand_fir2,
  241. - &ifc->ifc_nand.nand_fir2);
  242. - ifc_out32(savd_regs->ifc_nand.nand_csel,
  243. - &ifc->ifc_nand.nand_csel);
  244. - ifc_out32(savd_regs->ifc_nand.nandseq_strt,
  245. - &ifc->ifc_nand.nandseq_strt);
  246. - ifc_out32(savd_regs->ifc_nand.nand_evter_en,
  247. - &ifc->ifc_nand.nand_evter_en);
  248. - ifc_out32(savd_regs->ifc_nand.nanndcr, &ifc->ifc_nand.nanndcr);
  249. -
  250. -/*
  251. -* IFC controller NOR machine registers
  252. -*/
  253. - ifc_out32(savd_regs->ifc_nor.nor_evter_en,
  254. - &ifc->ifc_nor.nor_evter_en);
  255. - ifc_out32(savd_regs->ifc_nor.norcr, &ifc->ifc_nor.norcr);
  256. -
  257. -/*
  258. - * IFC controller GPCM Machine registers
  259. - */
  260. - ifc_out32(savd_regs->ifc_gpcm.gpcm_evter_en,
  261. - &ifc->ifc_gpcm.gpcm_evter_en);
  262. -
  263. -
  264. -
  265. -/*
  266. - * IFC interrupts enabled
  267. - */
  268. - ifc_out32(ctrl->saved_regs->cm_evter_intr_en, &ifc->cm_evter_intr_en);
  269. - ifc_out32(ctrl->saved_regs->ifc_nand.nand_evter_intr_en,
  270. - &ifc->ifc_nand.nand_evter_intr_en);
  271. - ifc_out32(ctrl->saved_regs->ifc_nor.nor_evter_intr_en,
  272. - &ifc->ifc_nor.nor_evter_intr_en);
  273. - ifc_out32(ctrl->saved_regs->ifc_gpcm.gpcm_evter_intr_en,
  274. - &ifc->ifc_gpcm.gpcm_evter_intr_en);
  275. + ifc_out32(savd_gregs->rb_map, &fcm->rb_map);
  276. + ifc_out32(savd_gregs->wb_map, &fcm->wb_map);
  277. + ifc_out32(savd_gregs->ifc_gcr, &fcm->ifc_gcr);
  278. + ifc_out32(savd_gregs->ddr_ccr_low, &fcm->ddr_ccr_low);
  279. + ifc_out32(savd_gregs->cm_evter_en, &fcm->cm_evter_en);
  280. + }
  281. - kfree(ctrl->saved_regs);
  282. - ctrl->saved_regs = NULL;
  283. + if (ctrl->saved_rregs) {
  284. + /* IFC controller NAND machine registers */
  285. + ifc_out32(savd_rregs->ifc_nand.ncfgr,
  286. + &runtime->ifc_nand.ncfgr);
  287. + ifc_out32(savd_rregs->ifc_nand.nand_fcr0,
  288. + &runtime->ifc_nand.nand_fcr0);
  289. + ifc_out32(savd_rregs->ifc_nand.nand_fcr1,
  290. + &runtime->ifc_nand.nand_fcr1);
  291. + ifc_out32(savd_rregs->ifc_nand.row0, &runtime->ifc_nand.row0);
  292. + ifc_out32(savd_rregs->ifc_nand.row1, &runtime->ifc_nand.row1);
  293. + ifc_out32(savd_rregs->ifc_nand.col0, &runtime->ifc_nand.col0);
  294. + ifc_out32(savd_rregs->ifc_nand.col1, &runtime->ifc_nand.col1);
  295. + ifc_out32(savd_rregs->ifc_nand.row2, &runtime->ifc_nand.row2);
  296. + ifc_out32(savd_rregs->ifc_nand.col2, &runtime->ifc_nand.col2);
  297. + ifc_out32(savd_rregs->ifc_nand.row3, &runtime->ifc_nand.row3);
  298. + ifc_out32(savd_rregs->ifc_nand.col3, &runtime->ifc_nand.col3);
  299. + ifc_out32(savd_rregs->ifc_nand.nand_fbcr,
  300. + &runtime->ifc_nand.nand_fbcr);
  301. + ifc_out32(savd_rregs->ifc_nand.nand_fir0,
  302. + &runtime->ifc_nand.nand_fir0);
  303. + ifc_out32(savd_rregs->ifc_nand.nand_fir1,
  304. + &runtime->ifc_nand.nand_fir1);
  305. + ifc_out32(savd_rregs->ifc_nand.nand_fir2,
  306. + &runtime->ifc_nand.nand_fir2);
  307. + ifc_out32(savd_rregs->ifc_nand.nand_csel,
  308. + &runtime->ifc_nand.nand_csel);
  309. + ifc_out32(savd_rregs->ifc_nand.nandseq_strt,
  310. + &runtime->ifc_nand.nandseq_strt);
  311. + ifc_out32(savd_rregs->ifc_nand.nand_evter_en,
  312. + &runtime->ifc_nand.nand_evter_en);
  313. + ifc_out32(savd_rregs->ifc_nand.nanndcr,
  314. + &runtime->ifc_nand.nanndcr);
  315. + ifc_out32(savd_rregs->ifc_nand.nand_dll_lowcfg0,
  316. + &runtime->ifc_nand.nand_dll_lowcfg0);
  317. + ifc_out32(savd_rregs->ifc_nand.nand_dll_lowcfg1,
  318. + &runtime->ifc_nand.nand_dll_lowcfg1);
  319. +
  320. + /* IFC controller NOR machine registers */
  321. + ifc_out32(savd_rregs->ifc_nor.nor_evter_en,
  322. + &runtime->ifc_nor.nor_evter_en);
  323. + ifc_out32(savd_rregs->ifc_nor.norcr, &runtime->ifc_nor.norcr);
  324. +
  325. + /* IFC controller GPCM Machine registers */
  326. + ifc_out32(savd_rregs->ifc_gpcm.gpcm_evter_en,
  327. + &runtime->ifc_gpcm.gpcm_evter_en);
  328. +
  329. + /* IFC interrupts enabled */
  330. + ifc_out32(ctrl->saved_gregs->cm_evter_intr_en,
  331. + &fcm->cm_evter_intr_en);
  332. + ifc_out32(ctrl->saved_rregs->ifc_nand.nand_evter_intr_en,
  333. + &runtime->ifc_nand.nand_evter_intr_en);
  334. + ifc_out32(ctrl->saved_rregs->ifc_nor.nor_evter_intr_en,
  335. + &runtime->ifc_nor.nor_evter_intr_en);
  336. + ifc_out32(ctrl->saved_rregs->ifc_gpcm.gpcm_evter_intr_en,
  337. + &runtime->ifc_gpcm.gpcm_evter_intr_en);
  338. +
  339. + kfree(ctrl->saved_gregs);
  340. + kfree(ctrl->saved_rregs);
  341. + ctrl->saved_gregs = NULL;
  342. + ctrl->saved_rregs = NULL;
  343. }
  344. - ver = ifc_in32(&ctrl->regs->ifc_rev);
  345. - ncfgr = ifc_in32(&ifc->ifc_nand.ncfgr);
  346. + ver = ifc_in32(&fcm->ifc_rev);
  347. + ncfgr = ifc_in32(&runtime->ifc_nand.ncfgr);
  348. if (ver >= FSL_IFC_V1_3_0) {
  349. ifc_out32(ncfgr | IFC_NAND_SRAM_INIT_EN,
  350. - &ifc->ifc_nand.ncfgr);
  351. + &runtime->ifc_nand.ncfgr);
  352. /* wait for SRAM_INIT bit to be clear or timeout */
  353. status = spin_event_timeout(
  354. - !(ifc_in32(&ifc->ifc_nand.ncfgr)
  355. + !(ifc_in32(&runtime->ifc_nand.ncfgr)
  356. & IFC_NAND_SRAM_INIT_EN),
  357. IFC_TIMEOUT_MSECS, 0);
  358. --- a/drivers/mtd/nand/fsl_ifc_nand.c
  359. +++ b/drivers/mtd/nand/fsl_ifc_nand.c
  360. @@ -233,7 +233,7 @@ static void set_addr(struct mtd_info *mt
  361. struct nand_chip *chip = mtd->priv;
  362. struct fsl_ifc_mtd *priv = chip->priv;
  363. struct fsl_ifc_ctrl *ctrl = priv->ctrl;
  364. - struct fsl_ifc_regs __iomem *ifc = ctrl->regs;
  365. + struct fsl_ifc_runtime __iomem *ifc = ctrl->rregs;
  366. int buf_num;
  367. ifc_nand_ctrl->page = page_addr;
  368. @@ -296,7 +296,7 @@ static void fsl_ifc_run_command(struct m
  369. struct fsl_ifc_mtd *priv = chip->priv;
  370. struct fsl_ifc_ctrl *ctrl = priv->ctrl;
  371. struct fsl_ifc_nand_ctrl *nctrl = ifc_nand_ctrl;
  372. - struct fsl_ifc_regs __iomem *ifc = ctrl->regs;
  373. + struct fsl_ifc_runtime __iomem *ifc = ctrl->rregs;
  374. u32 eccstat[4];
  375. int i;
  376. @@ -372,7 +372,7 @@ static void fsl_ifc_do_read(struct nand_
  377. {
  378. struct fsl_ifc_mtd *priv = chip->priv;
  379. struct fsl_ifc_ctrl *ctrl = priv->ctrl;
  380. - struct fsl_ifc_regs __iomem *ifc = ctrl->regs;
  381. + struct fsl_ifc_runtime __iomem *ifc = ctrl->rregs;
  382. /* Program FIR/IFC_NAND_FCR0 for Small/Large page */
  383. if (mtd->writesize > 512) {
  384. @@ -412,7 +412,7 @@ static void fsl_ifc_cmdfunc(struct mtd_i
  385. struct nand_chip *chip = mtd->priv;
  386. struct fsl_ifc_mtd *priv = chip->priv;
  387. struct fsl_ifc_ctrl *ctrl = priv->ctrl;
  388. - struct fsl_ifc_regs __iomem *ifc = ctrl->regs;
  389. + struct fsl_ifc_runtime __iomem *ifc = ctrl->rregs;
  390. /* clear the read buffer */
  391. ifc_nand_ctrl->read_bytes = 0;
  392. @@ -727,7 +727,7 @@ static int fsl_ifc_wait(struct mtd_info
  393. {
  394. struct fsl_ifc_mtd *priv = chip->priv;
  395. struct fsl_ifc_ctrl *ctrl = priv->ctrl;
  396. - struct fsl_ifc_regs __iomem *ifc = ctrl->regs;
  397. + struct fsl_ifc_runtime __iomem *ifc = ctrl->rregs;
  398. u32 nand_fsr;
  399. int status;
  400. @@ -830,39 +830,42 @@ static int fsl_ifc_chip_init_tail(struct
  401. static void fsl_ifc_sram_init(struct fsl_ifc_mtd *priv)
  402. {
  403. struct fsl_ifc_ctrl *ctrl = priv->ctrl;
  404. - struct fsl_ifc_regs __iomem *ifc = ctrl->regs;
  405. + struct fsl_ifc_runtime __iomem *ifc_runtime = ctrl->rregs;
  406. + struct fsl_ifc_fcm __iomem *ifc_global = ctrl->gregs;
  407. uint32_t csor = 0, csor_8k = 0, csor_ext = 0;
  408. uint32_t cs = priv->bank;
  409. /* Save CSOR and CSOR_ext */
  410. - csor = ifc_in32(&ifc->csor_cs[cs].csor);
  411. - csor_ext = ifc_in32(&ifc->csor_cs[cs].csor_ext);
  412. + csor = ifc_in32(&ifc_global->csor_cs[cs].csor);
  413. + csor_ext = ifc_in32(&ifc_global->csor_cs[cs].csor_ext);
  414. /* chage PageSize 8K and SpareSize 1K*/
  415. csor_8k = (csor & ~(CSOR_NAND_PGS_MASK)) | 0x0018C000;
  416. - ifc_out32(csor_8k, &ifc->csor_cs[cs].csor);
  417. - ifc_out32(0x0000400, &ifc->csor_cs[cs].csor_ext);
  418. + ifc_out32(csor_8k, &ifc_global->csor_cs[cs].csor);
  419. + ifc_out32(0x0000400, &ifc_global->csor_cs[cs].csor_ext);
  420. /* READID */
  421. ifc_out32((IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) |
  422. - (IFC_FIR_OP_UA << IFC_NAND_FIR0_OP1_SHIFT) |
  423. - (IFC_FIR_OP_RB << IFC_NAND_FIR0_OP2_SHIFT),
  424. - &ifc->ifc_nand.nand_fir0);
  425. + (IFC_FIR_OP_UA << IFC_NAND_FIR0_OP1_SHIFT) |
  426. + (IFC_FIR_OP_RB << IFC_NAND_FIR0_OP2_SHIFT),
  427. + &ifc_runtime->ifc_nand.nand_fir0);
  428. ifc_out32(NAND_CMD_READID << IFC_NAND_FCR0_CMD0_SHIFT,
  429. - &ifc->ifc_nand.nand_fcr0);
  430. - ifc_out32(0x0, &ifc->ifc_nand.row3);
  431. + &ifc_runtime->ifc_nand.nand_fcr0);
  432. + ifc_out32(0x0, &ifc_runtime->ifc_nand.row3);
  433. - ifc_out32(0x0, &ifc->ifc_nand.nand_fbcr);
  434. + ifc_out32(0x0, &ifc_runtime->ifc_nand.nand_fbcr);
  435. /* Program ROW0/COL0 */
  436. - ifc_out32(0x0, &ifc->ifc_nand.row0);
  437. - ifc_out32(0x0, &ifc->ifc_nand.col0);
  438. + ifc_out32(0x0, &ifc_runtime->ifc_nand.row0);
  439. + ifc_out32(0x0, &ifc_runtime->ifc_nand.col0);
  440. /* set the chip select for NAND Transaction */
  441. - ifc_out32(cs << IFC_NAND_CSEL_SHIFT, &ifc->ifc_nand.nand_csel);
  442. + ifc_out32(cs << IFC_NAND_CSEL_SHIFT,
  443. + &ifc_runtime->ifc_nand.nand_csel);
  444. /* start read seq */
  445. - ifc_out32(IFC_NAND_SEQ_STRT_FIR_STRT, &ifc->ifc_nand.nandseq_strt);
  446. + ifc_out32(IFC_NAND_SEQ_STRT_FIR_STRT,
  447. + &ifc_runtime->ifc_nand.nandseq_strt);
  448. /* wait for command complete flag or timeout */
  449. wait_event_timeout(ctrl->nand_wait, ctrl->nand_stat,
  450. @@ -872,14 +875,15 @@ static void fsl_ifc_sram_init(struct fsl
  451. printk(KERN_ERR "fsl-ifc: Failed to Initialise SRAM\n");
  452. /* Restore CSOR and CSOR_ext */
  453. - ifc_out32(csor, &ifc->csor_cs[cs].csor);
  454. - ifc_out32(csor_ext, &ifc->csor_cs[cs].csor_ext);
  455. + ifc_out32(csor, &ifc_global->csor_cs[cs].csor);
  456. + ifc_out32(csor_ext, &ifc_global->csor_cs[cs].csor_ext);
  457. }
  458. static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv)
  459. {
  460. struct fsl_ifc_ctrl *ctrl = priv->ctrl;
  461. - struct fsl_ifc_regs __iomem *ifc = ctrl->regs;
  462. + struct fsl_ifc_fcm __iomem *ifc_global = ctrl->gregs;
  463. + struct fsl_ifc_runtime __iomem *ifc_runtime = ctrl->rregs;
  464. struct nand_chip *chip = &priv->chip;
  465. struct nand_ecclayout *layout;
  466. u32 csor;
  467. @@ -890,7 +894,8 @@ static int fsl_ifc_chip_init(struct fsl_
  468. /* fill in nand_chip structure */
  469. /* set up function call table */
  470. - if ((ifc_in32(&ifc->cspr_cs[priv->bank].cspr)) & CSPR_PORT_SIZE_16)
  471. + if ((ifc_in32(&ifc_global->cspr_cs[priv->bank].cspr))
  472. + & CSPR_PORT_SIZE_16)
  473. chip->read_byte = fsl_ifc_read_byte16;
  474. else
  475. chip->read_byte = fsl_ifc_read_byte;
  476. @@ -904,13 +909,14 @@ static int fsl_ifc_chip_init(struct fsl_
  477. chip->bbt_td = &bbt_main_descr;
  478. chip->bbt_md = &bbt_mirror_descr;
  479. - ifc_out32(0x0, &ifc->ifc_nand.ncfgr);
  480. + ifc_out32(0x0, &ifc_runtime->ifc_nand.ncfgr);
  481. /* set up nand options */
  482. chip->bbt_options = NAND_BBT_USE_FLASH;
  483. chip->options = NAND_NO_SUBPAGE_WRITE;
  484. - if (ifc_in32(&ifc->cspr_cs[priv->bank].cspr) & CSPR_PORT_SIZE_16) {
  485. + if (ifc_in32(&ifc_global->cspr_cs[priv->bank].cspr)
  486. + & CSPR_PORT_SIZE_16) {
  487. chip->read_byte = fsl_ifc_read_byte16;
  488. chip->options |= NAND_BUSWIDTH_16;
  489. } else {
  490. @@ -923,7 +929,7 @@ static int fsl_ifc_chip_init(struct fsl_
  491. chip->ecc.read_page = fsl_ifc_read_page;
  492. chip->ecc.write_page = fsl_ifc_write_page;
  493. - csor = ifc_in32(&ifc->csor_cs[priv->bank].csor);
  494. + csor = ifc_in32(&ifc_global->csor_cs[priv->bank].csor);
  495. /* Hardware generates ECC per 512 Bytes */
  496. chip->ecc.size = 512;
  497. @@ -1009,10 +1015,10 @@ static int fsl_ifc_chip_remove(struct fs
  498. return 0;
  499. }
  500. -static int match_bank(struct fsl_ifc_regs __iomem *ifc, int bank,
  501. +static int match_bank(struct fsl_ifc_fcm __iomem *ifc_global, int bank,
  502. phys_addr_t addr)
  503. {
  504. - u32 cspr = ifc_in32(&ifc->cspr_cs[bank].cspr);
  505. + u32 cspr = ifc_in32(&ifc_global->cspr_cs[bank].cspr);
  506. if (!(cspr & CSPR_V))
  507. return 0;
  508. @@ -1026,7 +1032,7 @@ static DEFINE_MUTEX(fsl_ifc_nand_mutex);
  509. static int fsl_ifc_nand_probe(struct platform_device *dev)
  510. {
  511. - struct fsl_ifc_regs __iomem *ifc;
  512. + struct fsl_ifc_runtime __iomem *ifc;
  513. struct fsl_ifc_mtd *priv;
  514. struct resource res;
  515. static const char *part_probe_types[]
  516. @@ -1037,9 +1043,9 @@ static int fsl_ifc_nand_probe(struct pla
  517. struct mtd_part_parser_data ppdata;
  518. ppdata.of_node = dev->dev.of_node;
  519. - if (!fsl_ifc_ctrl_dev || !fsl_ifc_ctrl_dev->regs)
  520. + if (!fsl_ifc_ctrl_dev || !fsl_ifc_ctrl_dev->rregs)
  521. return -ENODEV;
  522. - ifc = fsl_ifc_ctrl_dev->regs;
  523. + ifc = fsl_ifc_ctrl_dev->rregs;
  524. /* get, allocate and map the memory resource */
  525. ret = of_address_to_resource(node, 0, &res);
  526. @@ -1050,7 +1056,7 @@ static int fsl_ifc_nand_probe(struct pla
  527. /* find which chip select it is connected to */
  528. for (bank = 0; bank < fsl_ifc_ctrl_dev->banks; bank++) {
  529. - if (match_bank(ifc, bank, res.start))
  530. + if (match_bank(fsl_ifc_ctrl_dev->gregs, bank, res.start))
  531. break;
  532. }
  533. --- a/include/linux/fsl_ifc.h
  534. +++ b/include/linux/fsl_ifc.h
  535. @@ -39,6 +39,10 @@
  536. #define FSL_IFC_VERSION_MASK 0x0F0F0000
  537. #define FSL_IFC_VERSION_1_0_0 0x01000000
  538. #define FSL_IFC_VERSION_1_1_0 0x01010000
  539. +#define FSL_IFC_VERSION_2_0_0 0x02000000
  540. +
  541. +#define PGOFFSET_64K (64*1024)
  542. +#define PGOFFSET_4K (4*1024)
  543. /*
  544. * CSPR - Chip Select Property Register
  545. @@ -725,20 +729,26 @@ struct fsl_ifc_nand {
  546. __be32 nand_evter_en;
  547. u32 res17[0x2];
  548. __be32 nand_evter_intr_en;
  549. - u32 res18[0x2];
  550. + __be32 nand_vol_addr_stat;
  551. + u32 res18;
  552. __be32 nand_erattr0;
  553. __be32 nand_erattr1;
  554. u32 res19[0x10];
  555. __be32 nand_fsr;
  556. - u32 res20;
  557. - __be32 nand_eccstat[4];
  558. - u32 res21[0x20];
  559. + u32 res20[0x3];
  560. + __be32 nand_eccstat[6];
  561. + u32 res21[0x1c];
  562. __be32 nanndcr;
  563. u32 res22[0x2];
  564. __be32 nand_autoboot_trgr;
  565. u32 res23;
  566. __be32 nand_mdr;
  567. - u32 res24[0x5C];
  568. + u32 res24[0x1C];
  569. + __be32 nand_dll_lowcfg0;
  570. + __be32 nand_dll_lowcfg1;
  571. + u32 res25;
  572. + __be32 nand_dll_lowstat;
  573. + u32 res26[0x3c];
  574. };
  575. /*
  576. @@ -773,13 +783,12 @@ struct fsl_ifc_gpcm {
  577. __be32 gpcm_erattr1;
  578. __be32 gpcm_erattr2;
  579. __be32 gpcm_stat;
  580. - u32 res4[0x1F3];
  581. };
  582. /*
  583. * IFC Controller Registers
  584. */
  585. -struct fsl_ifc_regs {
  586. +struct fsl_ifc_fcm {
  587. __be32 ifc_rev;
  588. u32 res1[0x2];
  589. struct {
  590. @@ -805,21 +814,26 @@ struct fsl_ifc_regs {
  591. } ftim_cs[FSL_IFC_BANK_COUNT];
  592. u32 res9[0x30];
  593. __be32 rb_stat;
  594. - u32 res10[0x2];
  595. + __be32 rb_map;
  596. + __be32 wb_map;
  597. __be32 ifc_gcr;
  598. - u32 res11[0x2];
  599. + u32 res10[0x2];
  600. __be32 cm_evter_stat;
  601. - u32 res12[0x2];
  602. + u32 res11[0x2];
  603. __be32 cm_evter_en;
  604. - u32 res13[0x2];
  605. + u32 res12[0x2];
  606. __be32 cm_evter_intr_en;
  607. - u32 res14[0x2];
  608. + u32 res13[0x2];
  609. __be32 cm_erattr0;
  610. __be32 cm_erattr1;
  611. - u32 res15[0x2];
  612. + u32 res14[0x2];
  613. __be32 ifc_ccr;
  614. __be32 ifc_csr;
  615. - u32 res16[0x2EB];
  616. + __be32 ddr_ccr_low;
  617. +};
  618. +
  619. +
  620. +struct fsl_ifc_runtime {
  621. struct fsl_ifc_nand ifc_nand;
  622. struct fsl_ifc_nor ifc_nor;
  623. struct fsl_ifc_gpcm ifc_gpcm;
  624. @@ -833,7 +847,8 @@ extern int fsl_ifc_find(phys_addr_t addr
  625. struct fsl_ifc_ctrl {
  626. /* device info */
  627. struct device *dev;
  628. - struct fsl_ifc_regs __iomem *regs;
  629. + struct fsl_ifc_fcm __iomem *gregs;
  630. + struct fsl_ifc_runtime __iomem *rregs;
  631. int irq;
  632. int nand_irq;
  633. spinlock_t lock;
  634. @@ -846,7 +861,8 @@ struct fsl_ifc_ctrl {
  635. bool little_endian;
  636. #ifdef CONFIG_PM_SLEEP
  637. /*save regs when system goes to deep sleep*/
  638. - struct fsl_ifc_regs *saved_regs;
  639. + struct fsl_ifc_fcm *saved_gregs;
  640. + struct fsl_ifc_runtime *saved_rregs;
  641. #endif
  642. };