gpmc.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. /*
  2. * GPMC support functions
  3. *
  4. * Copyright (C) 2005-2006 Nokia Corporation
  5. *
  6. * Author: Juha Yrjola
  7. *
  8. * Copyright (C) 2009 Texas Instruments
  9. * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com>
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. */
  15. #undef DEBUG
  16. #include <linux/kernel.h>
  17. #include <linux/init.h>
  18. #include <linux/err.h>
  19. #include <linux/clk.h>
  20. #include <linux/ioport.h>
  21. #include <linux/spinlock.h>
  22. #include <linux/io.h>
  23. #include <linux/module.h>
  24. #include <asm/mach-types.h>
  25. #include <plat/gpmc.h>
  26. #include <plat/sdrc.h>
  27. /* GPMC register offsets */
  28. #define GPMC_REVISION 0x00
  29. #define GPMC_SYSCONFIG 0x10
  30. #define GPMC_SYSSTATUS 0x14
  31. #define GPMC_IRQSTATUS 0x18
  32. #define GPMC_IRQENABLE 0x1c
  33. #define GPMC_TIMEOUT_CONTROL 0x40
  34. #define GPMC_ERR_ADDRESS 0x44
  35. #define GPMC_ERR_TYPE 0x48
  36. #define GPMC_CONFIG 0x50
  37. #define GPMC_STATUS 0x54
  38. #define GPMC_PREFETCH_CONFIG1 0x1e0
  39. #define GPMC_PREFETCH_CONFIG2 0x1e4
  40. #define GPMC_PREFETCH_CONTROL 0x1ec
  41. #define GPMC_PREFETCH_STATUS 0x1f0
  42. #define GPMC_ECC_CONFIG 0x1f4
  43. #define GPMC_ECC_CONTROL 0x1f8
  44. #define GPMC_ECC_SIZE_CONFIG 0x1fc
  45. #define GPMC_CS0 0x60
  46. #define GPMC_CS_SIZE 0x30
  47. #define GPMC_MEM_START 0x00000000
  48. #define GPMC_MEM_END 0x3FFFFFFF
  49. #define BOOT_ROM_SPACE 0x100000 /* 1MB */
  50. #define GPMC_CHUNK_SHIFT 24 /* 16 MB */
  51. #define GPMC_SECTION_SHIFT 28 /* 128 MB */
  52. #define PREFETCH_FIFOTHRESHOLD (0x40 << 8)
  53. #define CS_NUM_SHIFT 24
  54. #define ENABLE_PREFETCH (0x1 << 7)
  55. #define DMA_MPU_MODE 2
  56. /* Structure to save gpmc cs context */
  57. struct gpmc_cs_config {
  58. u32 config1;
  59. u32 config2;
  60. u32 config3;
  61. u32 config4;
  62. u32 config5;
  63. u32 config6;
  64. u32 config7;
  65. int is_valid;
  66. };
  67. /*
  68. * Structure to save/restore gpmc context
  69. * to support core off on OMAP3
  70. */
  71. struct omap3_gpmc_regs {
  72. u32 sysconfig;
  73. u32 irqenable;
  74. u32 timeout_ctrl;
  75. u32 config;
  76. u32 prefetch_config1;
  77. u32 prefetch_config2;
  78. u32 prefetch_control;
  79. struct gpmc_cs_config cs_context[GPMC_CS_NUM];
  80. };
  81. static struct resource gpmc_mem_root;
  82. static struct resource gpmc_cs_mem[GPMC_CS_NUM];
  83. static DEFINE_SPINLOCK(gpmc_mem_lock);
  84. static unsigned gpmc_cs_map;
  85. static void __iomem *gpmc_base;
  86. static struct clk *gpmc_l3_clk;
  87. static void gpmc_write_reg(int idx, u32 val)
  88. {
  89. __raw_writel(val, gpmc_base + idx);
  90. }
  91. static u32 gpmc_read_reg(int idx)
  92. {
  93. return __raw_readl(gpmc_base + idx);
  94. }
  95. void gpmc_cs_write_reg(int cs, int idx, u32 val)
  96. {
  97. void __iomem *reg_addr;
  98. reg_addr = gpmc_base + GPMC_CS0 + (cs * GPMC_CS_SIZE) + idx;
  99. __raw_writel(val, reg_addr);
  100. }
  101. u32 gpmc_cs_read_reg(int cs, int idx)
  102. {
  103. void __iomem *reg_addr;
  104. reg_addr = gpmc_base + GPMC_CS0 + (cs * GPMC_CS_SIZE) + idx;
  105. return __raw_readl(reg_addr);
  106. }
  107. /* TODO: Add support for gpmc_fck to clock framework and use it */
  108. unsigned long gpmc_get_fclk_period(void)
  109. {
  110. unsigned long rate = clk_get_rate(gpmc_l3_clk);
  111. if (rate == 0) {
  112. printk(KERN_WARNING "gpmc_l3_clk not enabled\n");
  113. return 0;
  114. }
  115. rate /= 1000;
  116. rate = 1000000000 / rate; /* In picoseconds */
  117. return rate;
  118. }
  119. unsigned int gpmc_ns_to_ticks(unsigned int time_ns)
  120. {
  121. unsigned long tick_ps;
  122. /* Calculate in picosecs to yield more exact results */
  123. tick_ps = gpmc_get_fclk_period();
  124. return (time_ns * 1000 + tick_ps - 1) / tick_ps;
  125. }
  126. unsigned int gpmc_ticks_to_ns(unsigned int ticks)
  127. {
  128. return ticks * gpmc_get_fclk_period() / 1000;
  129. }
  130. unsigned int gpmc_round_ns_to_ticks(unsigned int time_ns)
  131. {
  132. unsigned long ticks = gpmc_ns_to_ticks(time_ns);
  133. return ticks * gpmc_get_fclk_period() / 1000;
  134. }
  135. #ifdef DEBUG
  136. static int set_gpmc_timing_reg(int cs, int reg, int st_bit, int end_bit,
  137. int time, const char *name)
  138. #else
  139. static int set_gpmc_timing_reg(int cs, int reg, int st_bit, int end_bit,
  140. int time)
  141. #endif
  142. {
  143. u32 l;
  144. int ticks, mask, nr_bits;
  145. if (time == 0)
  146. ticks = 0;
  147. else
  148. ticks = gpmc_ns_to_ticks(time);
  149. nr_bits = end_bit - st_bit + 1;
  150. if (ticks >= 1 << nr_bits) {
  151. #ifdef DEBUG
  152. printk(KERN_INFO "GPMC CS%d: %-10s* %3d ns, %3d ticks >= %d\n",
  153. cs, name, time, ticks, 1 << nr_bits);
  154. #endif
  155. return -1;
  156. }
  157. mask = (1 << nr_bits) - 1;
  158. l = gpmc_cs_read_reg(cs, reg);
  159. #ifdef DEBUG
  160. printk(KERN_INFO
  161. "GPMC CS%d: %-10s: %3d ticks, %3lu ns (was %3i ticks) %3d ns\n",
  162. cs, name, ticks, gpmc_get_fclk_period() * ticks / 1000,
  163. (l >> st_bit) & mask, time);
  164. #endif
  165. l &= ~(mask << st_bit);
  166. l |= ticks << st_bit;
  167. gpmc_cs_write_reg(cs, reg, l);
  168. return 0;
  169. }
  170. #ifdef DEBUG
  171. #define GPMC_SET_ONE(reg, st, end, field) \
  172. if (set_gpmc_timing_reg(cs, (reg), (st), (end), \
  173. t->field, #field) < 0) \
  174. return -1
  175. #else
  176. #define GPMC_SET_ONE(reg, st, end, field) \
  177. if (set_gpmc_timing_reg(cs, (reg), (st), (end), t->field) < 0) \
  178. return -1
  179. #endif
  180. int gpmc_cs_calc_divider(int cs, unsigned int sync_clk)
  181. {
  182. int div;
  183. u32 l;
  184. l = sync_clk * 1000 + (gpmc_get_fclk_period() - 1);
  185. div = l / gpmc_get_fclk_period();
  186. if (div > 4)
  187. return -1;
  188. if (div <= 0)
  189. div = 1;
  190. return div;
  191. }
  192. int gpmc_cs_set_timings(int cs, const struct gpmc_timings *t)
  193. {
  194. int div;
  195. u32 l;
  196. div = gpmc_cs_calc_divider(cs, t->sync_clk);
  197. if (div < 0)
  198. return -1;
  199. GPMC_SET_ONE(GPMC_CS_CONFIG2, 0, 3, cs_on);
  200. GPMC_SET_ONE(GPMC_CS_CONFIG2, 8, 12, cs_rd_off);
  201. GPMC_SET_ONE(GPMC_CS_CONFIG2, 16, 20, cs_wr_off);
  202. GPMC_SET_ONE(GPMC_CS_CONFIG3, 0, 3, adv_on);
  203. GPMC_SET_ONE(GPMC_CS_CONFIG3, 8, 12, adv_rd_off);
  204. GPMC_SET_ONE(GPMC_CS_CONFIG3, 16, 20, adv_wr_off);
  205. GPMC_SET_ONE(GPMC_CS_CONFIG4, 0, 3, oe_on);
  206. GPMC_SET_ONE(GPMC_CS_CONFIG4, 8, 12, oe_off);
  207. GPMC_SET_ONE(GPMC_CS_CONFIG4, 16, 19, we_on);
  208. GPMC_SET_ONE(GPMC_CS_CONFIG4, 24, 28, we_off);
  209. GPMC_SET_ONE(GPMC_CS_CONFIG5, 0, 4, rd_cycle);
  210. GPMC_SET_ONE(GPMC_CS_CONFIG5, 8, 12, wr_cycle);
  211. GPMC_SET_ONE(GPMC_CS_CONFIG5, 16, 20, access);
  212. GPMC_SET_ONE(GPMC_CS_CONFIG5, 24, 27, page_burst_access);
  213. if (cpu_is_omap34xx()) {
  214. GPMC_SET_ONE(GPMC_CS_CONFIG6, 16, 19, wr_data_mux_bus);
  215. GPMC_SET_ONE(GPMC_CS_CONFIG6, 24, 28, wr_access);
  216. }
  217. /* caller is expected to have initialized CONFIG1 to cover
  218. * at least sync vs async
  219. */
  220. l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
  221. if (l & (GPMC_CONFIG1_READTYPE_SYNC | GPMC_CONFIG1_WRITETYPE_SYNC)) {
  222. #ifdef DEBUG
  223. printk(KERN_INFO "GPMC CS%d CLK period is %lu ns (div %d)\n",
  224. cs, (div * gpmc_get_fclk_period()) / 1000, div);
  225. #endif
  226. l &= ~0x03;
  227. l |= (div - 1);
  228. gpmc_cs_write_reg(cs, GPMC_CS_CONFIG1, l);
  229. }
  230. return 0;
  231. }
  232. static void gpmc_cs_enable_mem(int cs, u32 base, u32 size)
  233. {
  234. u32 l;
  235. u32 mask;
  236. mask = (1 << GPMC_SECTION_SHIFT) - size;
  237. l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7);
  238. l &= ~0x3f;
  239. l = (base >> GPMC_CHUNK_SHIFT) & 0x3f;
  240. l &= ~(0x0f << 8);
  241. l |= ((mask >> GPMC_CHUNK_SHIFT) & 0x0f) << 8;
  242. l |= GPMC_CONFIG7_CSVALID;
  243. gpmc_cs_write_reg(cs, GPMC_CS_CONFIG7, l);
  244. }
  245. static void gpmc_cs_disable_mem(int cs)
  246. {
  247. u32 l;
  248. l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7);
  249. l &= ~GPMC_CONFIG7_CSVALID;
  250. gpmc_cs_write_reg(cs, GPMC_CS_CONFIG7, l);
  251. }
  252. static void gpmc_cs_get_memconf(int cs, u32 *base, u32 *size)
  253. {
  254. u32 l;
  255. u32 mask;
  256. l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7);
  257. *base = (l & 0x3f) << GPMC_CHUNK_SHIFT;
  258. mask = (l >> 8) & 0x0f;
  259. *size = (1 << GPMC_SECTION_SHIFT) - (mask << GPMC_CHUNK_SHIFT);
  260. }
  261. static int gpmc_cs_mem_enabled(int cs)
  262. {
  263. u32 l;
  264. l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7);
  265. return l & GPMC_CONFIG7_CSVALID;
  266. }
  267. int gpmc_cs_set_reserved(int cs, int reserved)
  268. {
  269. if (cs > GPMC_CS_NUM)
  270. return -ENODEV;
  271. gpmc_cs_map &= ~(1 << cs);
  272. gpmc_cs_map |= (reserved ? 1 : 0) << cs;
  273. return 0;
  274. }
  275. int gpmc_cs_reserved(int cs)
  276. {
  277. if (cs > GPMC_CS_NUM)
  278. return -ENODEV;
  279. return gpmc_cs_map & (1 << cs);
  280. }
  281. static unsigned long gpmc_mem_align(unsigned long size)
  282. {
  283. int order;
  284. size = (size - 1) >> (GPMC_CHUNK_SHIFT - 1);
  285. order = GPMC_CHUNK_SHIFT - 1;
  286. do {
  287. size >>= 1;
  288. order++;
  289. } while (size);
  290. size = 1 << order;
  291. return size;
  292. }
  293. static int gpmc_cs_insert_mem(int cs, unsigned long base, unsigned long size)
  294. {
  295. struct resource *res = &gpmc_cs_mem[cs];
  296. int r;
  297. size = gpmc_mem_align(size);
  298. spin_lock(&gpmc_mem_lock);
  299. res->start = base;
  300. res->end = base + size - 1;
  301. r = request_resource(&gpmc_mem_root, res);
  302. spin_unlock(&gpmc_mem_lock);
  303. return r;
  304. }
  305. int gpmc_cs_request(int cs, unsigned long size, unsigned long *base)
  306. {
  307. struct resource *res = &gpmc_cs_mem[cs];
  308. int r = -1;
  309. if (cs > GPMC_CS_NUM)
  310. return -ENODEV;
  311. size = gpmc_mem_align(size);
  312. if (size > (1 << GPMC_SECTION_SHIFT))
  313. return -ENOMEM;
  314. spin_lock(&gpmc_mem_lock);
  315. if (gpmc_cs_reserved(cs)) {
  316. r = -EBUSY;
  317. goto out;
  318. }
  319. if (gpmc_cs_mem_enabled(cs))
  320. r = adjust_resource(res, res->start & ~(size - 1), size);
  321. if (r < 0)
  322. r = allocate_resource(&gpmc_mem_root, res, size, 0, ~0,
  323. size, NULL, NULL);
  324. if (r < 0)
  325. goto out;
  326. gpmc_cs_enable_mem(cs, res->start, resource_size(res));
  327. *base = res->start;
  328. gpmc_cs_set_reserved(cs, 1);
  329. out:
  330. spin_unlock(&gpmc_mem_lock);
  331. return r;
  332. }
  333. EXPORT_SYMBOL(gpmc_cs_request);
  334. void gpmc_cs_free(int cs)
  335. {
  336. spin_lock(&gpmc_mem_lock);
  337. if (cs >= GPMC_CS_NUM || cs < 0 || !gpmc_cs_reserved(cs)) {
  338. printk(KERN_ERR "Trying to free non-reserved GPMC CS%d\n", cs);
  339. BUG();
  340. spin_unlock(&gpmc_mem_lock);
  341. return;
  342. }
  343. gpmc_cs_disable_mem(cs);
  344. release_resource(&gpmc_cs_mem[cs]);
  345. gpmc_cs_set_reserved(cs, 0);
  346. spin_unlock(&gpmc_mem_lock);
  347. }
  348. EXPORT_SYMBOL(gpmc_cs_free);
  349. /**
  350. * gpmc_prefetch_enable - configures and starts prefetch transfer
  351. * @cs: nand cs (chip select) number
  352. * @dma_mode: dma mode enable (1) or disable (0)
  353. * @u32_count: number of bytes to be transferred
  354. * @is_write: prefetch read(0) or write post(1) mode
  355. */
  356. int gpmc_prefetch_enable(int cs, int dma_mode,
  357. unsigned int u32_count, int is_write)
  358. {
  359. uint32_t prefetch_config1;
  360. if (!(gpmc_read_reg(GPMC_PREFETCH_CONTROL))) {
  361. /* Set the amount of bytes to be prefetched */
  362. gpmc_write_reg(GPMC_PREFETCH_CONFIG2, u32_count);
  363. /* Set dma/mpu mode, the prefetch read / post write and
  364. * enable the engine. Set which cs is has requested for.
  365. */
  366. prefetch_config1 = ((cs << CS_NUM_SHIFT) |
  367. PREFETCH_FIFOTHRESHOLD |
  368. ENABLE_PREFETCH |
  369. (dma_mode << DMA_MPU_MODE) |
  370. (0x1 & is_write));
  371. gpmc_write_reg(GPMC_PREFETCH_CONFIG1, prefetch_config1);
  372. } else {
  373. return -EBUSY;
  374. }
  375. /* Start the prefetch engine */
  376. gpmc_write_reg(GPMC_PREFETCH_CONTROL, 0x1);
  377. return 0;
  378. }
  379. EXPORT_SYMBOL(gpmc_prefetch_enable);
  380. /**
  381. * gpmc_prefetch_reset - disables and stops the prefetch engine
  382. */
  383. void gpmc_prefetch_reset(void)
  384. {
  385. /* Stop the PFPW engine */
  386. gpmc_write_reg(GPMC_PREFETCH_CONTROL, 0x0);
  387. /* Reset/disable the PFPW engine */
  388. gpmc_write_reg(GPMC_PREFETCH_CONFIG1, 0x0);
  389. }
  390. EXPORT_SYMBOL(gpmc_prefetch_reset);
  391. /**
  392. * gpmc_prefetch_status - reads prefetch status of engine
  393. */
  394. int gpmc_prefetch_status(void)
  395. {
  396. return gpmc_read_reg(GPMC_PREFETCH_STATUS);
  397. }
  398. EXPORT_SYMBOL(gpmc_prefetch_status);
  399. static void __init gpmc_mem_init(void)
  400. {
  401. int cs;
  402. unsigned long boot_rom_space = 0;
  403. /* never allocate the first page, to facilitate bug detection;
  404. * even if we didn't boot from ROM.
  405. */
  406. boot_rom_space = BOOT_ROM_SPACE;
  407. /* In apollon the CS0 is mapped as 0x0000 0000 */
  408. if (machine_is_omap_apollon())
  409. boot_rom_space = 0;
  410. gpmc_mem_root.start = GPMC_MEM_START + boot_rom_space;
  411. gpmc_mem_root.end = GPMC_MEM_END;
  412. /* Reserve all regions that has been set up by bootloader */
  413. for (cs = 0; cs < GPMC_CS_NUM; cs++) {
  414. u32 base, size;
  415. if (!gpmc_cs_mem_enabled(cs))
  416. continue;
  417. gpmc_cs_get_memconf(cs, &base, &size);
  418. if (gpmc_cs_insert_mem(cs, base, size) < 0)
  419. BUG();
  420. }
  421. }
  422. void __init gpmc_init(void)
  423. {
  424. u32 l;
  425. char *ck;
  426. if (cpu_is_omap24xx()) {
  427. ck = "core_l3_ck";
  428. if (cpu_is_omap2420())
  429. l = OMAP2420_GPMC_BASE;
  430. else
  431. l = OMAP34XX_GPMC_BASE;
  432. } else if (cpu_is_omap34xx()) {
  433. ck = "gpmc_fck";
  434. l = OMAP34XX_GPMC_BASE;
  435. } else if (cpu_is_omap44xx()) {
  436. ck = "gpmc_ck";
  437. l = OMAP44XX_GPMC_BASE;
  438. }
  439. gpmc_l3_clk = clk_get(NULL, ck);
  440. if (IS_ERR(gpmc_l3_clk)) {
  441. printk(KERN_ERR "Could not get GPMC clock %s\n", ck);
  442. BUG();
  443. }
  444. gpmc_base = ioremap(l, SZ_4K);
  445. if (!gpmc_base) {
  446. clk_put(gpmc_l3_clk);
  447. printk(KERN_ERR "Could not get GPMC register memory\n");
  448. BUG();
  449. }
  450. l = gpmc_read_reg(GPMC_REVISION);
  451. printk(KERN_INFO "GPMC revision %d.%d\n", (l >> 4) & 0x0f, l & 0x0f);
  452. /* Set smart idle mode and automatic L3 clock gating */
  453. l = gpmc_read_reg(GPMC_SYSCONFIG);
  454. l &= 0x03 << 3;
  455. l |= (0x02 << 3) | (1 << 0);
  456. gpmc_write_reg(GPMC_SYSCONFIG, l);
  457. gpmc_mem_init();
  458. }
  459. #ifdef CONFIG_ARCH_OMAP3
  460. static struct omap3_gpmc_regs gpmc_context;
  461. void omap3_gpmc_save_context()
  462. {
  463. int i;
  464. gpmc_context.sysconfig = gpmc_read_reg(GPMC_SYSCONFIG);
  465. gpmc_context.irqenable = gpmc_read_reg(GPMC_IRQENABLE);
  466. gpmc_context.timeout_ctrl = gpmc_read_reg(GPMC_TIMEOUT_CONTROL);
  467. gpmc_context.config = gpmc_read_reg(GPMC_CONFIG);
  468. gpmc_context.prefetch_config1 = gpmc_read_reg(GPMC_PREFETCH_CONFIG1);
  469. gpmc_context.prefetch_config2 = gpmc_read_reg(GPMC_PREFETCH_CONFIG2);
  470. gpmc_context.prefetch_control = gpmc_read_reg(GPMC_PREFETCH_CONTROL);
  471. for (i = 0; i < GPMC_CS_NUM; i++) {
  472. gpmc_context.cs_context[i].is_valid = gpmc_cs_mem_enabled(i);
  473. if (gpmc_context.cs_context[i].is_valid) {
  474. gpmc_context.cs_context[i].config1 =
  475. gpmc_cs_read_reg(i, GPMC_CS_CONFIG1);
  476. gpmc_context.cs_context[i].config2 =
  477. gpmc_cs_read_reg(i, GPMC_CS_CONFIG2);
  478. gpmc_context.cs_context[i].config3 =
  479. gpmc_cs_read_reg(i, GPMC_CS_CONFIG3);
  480. gpmc_context.cs_context[i].config4 =
  481. gpmc_cs_read_reg(i, GPMC_CS_CONFIG4);
  482. gpmc_context.cs_context[i].config5 =
  483. gpmc_cs_read_reg(i, GPMC_CS_CONFIG5);
  484. gpmc_context.cs_context[i].config6 =
  485. gpmc_cs_read_reg(i, GPMC_CS_CONFIG6);
  486. gpmc_context.cs_context[i].config7 =
  487. gpmc_cs_read_reg(i, GPMC_CS_CONFIG7);
  488. }
  489. }
  490. }
  491. void omap3_gpmc_restore_context()
  492. {
  493. int i;
  494. gpmc_write_reg(GPMC_SYSCONFIG, gpmc_context.sysconfig);
  495. gpmc_write_reg(GPMC_IRQENABLE, gpmc_context.irqenable);
  496. gpmc_write_reg(GPMC_TIMEOUT_CONTROL, gpmc_context.timeout_ctrl);
  497. gpmc_write_reg(GPMC_CONFIG, gpmc_context.config);
  498. gpmc_write_reg(GPMC_PREFETCH_CONFIG1, gpmc_context.prefetch_config1);
  499. gpmc_write_reg(GPMC_PREFETCH_CONFIG2, gpmc_context.prefetch_config2);
  500. gpmc_write_reg(GPMC_PREFETCH_CONTROL, gpmc_context.prefetch_control);
  501. for (i = 0; i < GPMC_CS_NUM; i++) {
  502. if (gpmc_context.cs_context[i].is_valid) {
  503. gpmc_cs_write_reg(i, GPMC_CS_CONFIG1,
  504. gpmc_context.cs_context[i].config1);
  505. gpmc_cs_write_reg(i, GPMC_CS_CONFIG2,
  506. gpmc_context.cs_context[i].config2);
  507. gpmc_cs_write_reg(i, GPMC_CS_CONFIG3,
  508. gpmc_context.cs_context[i].config3);
  509. gpmc_cs_write_reg(i, GPMC_CS_CONFIG4,
  510. gpmc_context.cs_context[i].config4);
  511. gpmc_cs_write_reg(i, GPMC_CS_CONFIG5,
  512. gpmc_context.cs_context[i].config5);
  513. gpmc_cs_write_reg(i, GPMC_CS_CONFIG6,
  514. gpmc_context.cs_context[i].config6);
  515. gpmc_cs_write_reg(i, GPMC_CS_CONFIG7,
  516. gpmc_context.cs_context[i].config7);
  517. }
  518. }
  519. }
  520. #endif /* CONFIG_ARCH_OMAP3 */