board.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * board.c: STB225 board support.
  3. *
  4. * Copyright 2008 NXP Semiconductors
  5. * Chris Steel <chris.steel@nxp.com>
  6. * Daniel Laird <daniel.j.laird@nxp.com>
  7. *
  8. * Based on software written by:
  9. * Nikita Youshchenko <yoush@debian.org>, based on PNX8550 code.
  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 as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24. */
  25. #include <linux/init.h>
  26. #include <asm/bootinfo.h>
  27. #include <linux/mm.h>
  28. #include <pnx833x.h>
  29. #include <gpio.h>
  30. /* endianess twiddlers */
  31. #define PNX8335_DEBUG0 0x4400
  32. #define PNX8335_DEBUG1 0x4404
  33. #define PNX8335_DEBUG2 0x4408
  34. #define PNX8335_DEBUG3 0x440c
  35. #define PNX8335_DEBUG4 0x4410
  36. #define PNX8335_DEBUG5 0x4414
  37. #define PNX8335_DEBUG6 0x4418
  38. #define PNX8335_DEBUG7 0x441c
  39. int prom_argc;
  40. char **prom_argv, **prom_envp;
  41. extern void prom_init_cmdline(void);
  42. extern char *prom_getenv(char *envname);
  43. const char *get_system_type(void)
  44. {
  45. return "NXP STB22x";
  46. }
  47. static inline unsigned long env_or_default(char *env, unsigned long dfl)
  48. {
  49. char *str = prom_getenv(env);
  50. return str ? simple_strtol(str, 0, 0) : dfl;
  51. }
  52. void __init prom_init(void)
  53. {
  54. unsigned long memsize;
  55. prom_argc = fw_arg0;
  56. prom_argv = (char **)fw_arg1;
  57. prom_envp = (char **)fw_arg2;
  58. prom_init_cmdline();
  59. memsize = env_or_default("memsize", 0x02000000);
  60. add_memory_region(0, memsize, BOOT_MEM_RAM);
  61. }
  62. void __init pnx833x_board_setup(void)
  63. {
  64. pnx833x_gpio_select_function_alt(4);
  65. pnx833x_gpio_select_output(4);
  66. pnx833x_gpio_select_function_alt(5);
  67. pnx833x_gpio_select_input(5);
  68. pnx833x_gpio_select_function_alt(6);
  69. pnx833x_gpio_select_input(6);
  70. pnx833x_gpio_select_function_alt(7);
  71. pnx833x_gpio_select_output(7);
  72. pnx833x_gpio_select_function_alt(25);
  73. pnx833x_gpio_select_function_alt(26);
  74. pnx833x_gpio_select_function_alt(27);
  75. pnx833x_gpio_select_function_alt(28);
  76. pnx833x_gpio_select_function_alt(29);
  77. pnx833x_gpio_select_function_alt(30);
  78. pnx833x_gpio_select_function_alt(31);
  79. pnx833x_gpio_select_function_alt(32);
  80. pnx833x_gpio_select_function_alt(33);
  81. #if IS_ENABLED(CONFIG_MTD_NAND_PLATFORM)
  82. /* Setup MIU for NAND access on CS0...
  83. *
  84. * (it seems that we must also configure CS1 for reliable operation,
  85. * otherwise the first read ID command will fail if it's read as 4 bytes
  86. * but pass if it's read as 1 word.)
  87. */
  88. /* Setup MIU CS0 & CS1 timing */
  89. PNX833X_MIU_SEL0 = 0;
  90. PNX833X_MIU_SEL1 = 0;
  91. PNX833X_MIU_SEL0_TIMING = 0x50003081;
  92. PNX833X_MIU_SEL1_TIMING = 0x50003081;
  93. /* Setup GPIO 00 for use as MIU CS1 (CS0 is not multiplexed, so does not need this) */
  94. pnx833x_gpio_select_function_alt(0);
  95. /* Setup GPIO 04 to input NAND read/busy signal */
  96. pnx833x_gpio_select_function_io(4);
  97. pnx833x_gpio_select_input(4);
  98. /* Setup GPIO 05 to disable NAND write protect */
  99. pnx833x_gpio_select_function_io(5);
  100. pnx833x_gpio_select_output(5);
  101. pnx833x_gpio_write(1, 5);
  102. #elif IS_ENABLED(CONFIG_MTD_CFI)
  103. /* Set up MIU for 16-bit NOR access on CS0 and CS1... */
  104. /* Setup MIU CS0 & CS1 timing */
  105. PNX833X_MIU_SEL0 = 1;
  106. PNX833X_MIU_SEL1 = 1;
  107. PNX833X_MIU_SEL0_TIMING = 0x6A08D082;
  108. PNX833X_MIU_SEL1_TIMING = 0x6A08D082;
  109. /* Setup GPIO 00 for use as MIU CS1 (CS0 is not multiplexed, so does not need this) */
  110. pnx833x_gpio_select_function_alt(0);
  111. #endif
  112. }