onenand.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (C) 2008-2009 Samsung Electronics
  3. * Kyungmin Park <kyungmin.park@samsung.com>
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <common.h>
  24. #include <linux/mtd/compat.h>
  25. #include <linux/mtd/mtd.h>
  26. #include <linux/mtd/onenand.h>
  27. #include <linux/mtd/samsung_onenand.h>
  28. #include <onenand_uboot.h>
  29. #include <asm/io.h>
  30. #include <asm/arch/clock.h>
  31. void onenand_board_init(struct mtd_info *mtd)
  32. {
  33. struct onenand_chip *this = mtd->priv;
  34. struct s5pc100_clock *clk =
  35. (struct s5pc100_clock *)samsung_get_base_clock();
  36. struct samsung_onenand *onenand;
  37. int value;
  38. this->base = (void *)S5PC100_ONENAND_BASE;
  39. onenand = (struct samsung_onenand *)this->base;
  40. /* D0 Domain memory clock gating */
  41. value = readl(&clk->gate_d01);
  42. value &= ~(1 << 2); /* CLK_ONENANDC */
  43. value |= (1 << 2);
  44. writel(value, &clk->gate_d01);
  45. value = readl(&clk->src0);
  46. value &= ~(1 << 24); /* MUX_1nand: 0 from HCLKD0 */
  47. value &= ~(1 << 20); /* MUX_HREF: 0 from FIN_27M */
  48. writel(value, &clk->src0);
  49. value = readl(&clk->div1);
  50. value &= ~(3 << 16); /* PCLKD1_RATIO */
  51. value |= (1 << 16);
  52. writel(value, &clk->div1);
  53. writel(ONENAND_MEM_RESET_COLD, &onenand->mem_reset);
  54. while (!(readl(&onenand->int_err_stat) & RST_CMP))
  55. continue;
  56. writel(RST_CMP, &onenand->int_err_ack);
  57. /*
  58. * Access_Clock [2:0]
  59. * 166 MHz, 134 Mhz : 3
  60. * 100 Mhz, 60 Mhz : 2
  61. */
  62. writel(0x3, &onenand->acc_clock);
  63. writel(INT_ERR_ALL, &onenand->int_err_mask);
  64. writel(1 << 0, &onenand->int_pin_en); /* Enable */
  65. value = readl(&onenand->int_err_mask);
  66. value &= ~RDY_ACT;
  67. writel(value, &onenand->int_err_mask);
  68. s3c_onenand_init(mtd);
  69. }