Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.37 KB | None | 0 0
  1. /*
  2. * This file is part of the coreboot project.
  3. *
  4. * Copyright (C) 2012 Advanced Micro Devices, Inc.
  5. * Copyright (C) 2015 Sergej Ivanov <getinaks@gmail.com>
  6. * Copyright (C) 2018 Gergely Kiss <mail.gery@gmail.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; version 2 of the License.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. */
  17.  
  18. #include <arch/io.h>
  19. #include <device/pnp_ops.h>
  20. #include <device/pci_ops.h>
  21. #include <northbridge/amd/agesa/state_machine.h>
  22. #include <southbridge/amd/common/amd_defs.h>
  23. #include <southbridge/amd/agesa/hudson/hudson.h>
  24. #include <superio/ite/common/ite.h>
  25. #include <superio/ite/it8623e/it8623e.h>
  26.  
  27. #define ITE_CONFIG_REG_CC 0x02
  28.  
  29. #if CONFIG_UART_FOR_CONSOLE == 0
  30. #define SERIAL_DEV PNP_DEV(0x2e, IT8623E_SP1)
  31. #elif CONFIG_UART_FOR_CONSOLE == 1
  32. #define SERIAL_DEV PNP_DEV(0x2e, IT8623E_SP2)
  33. #else
  34. #error "Invalid value for CONFIG_UART_FOR_CONSOLE"
  35. #endif
  36.  
  37. #define GPIO_DEV PNP_DEV(0x2e, IT8623E_GPIO)
  38. #define CLKIN_DEV PNP_DEV(0x2e, IT8623E_GPIO)
  39. #define ENVC_DEV PNP_DEV(0x2e, IT8623E_EC)
  40.  
  41. /* Sets up EC configuration as per vendor defaults */
  42. static void ite_evc_conf(pnp_devfn_t dev)
  43. {
  44. pnp_set_enable(dev, 0);
  45. ite_reg_write(dev, 0x70, 0x00);
  46. ite_reg_write(dev, 0xf0, 0x00);
  47. ite_reg_write(dev, 0xf1, 0x00);
  48. ite_reg_write(dev, 0xf2, 0x06);
  49. ite_reg_write(dev, 0xf3, 0x00);
  50. ite_reg_write(dev, 0xf4, 0x00);
  51. ite_reg_write(dev, 0xf5, 0x36);
  52. ite_reg_write(dev, 0xf6, 0x03);
  53. ite_reg_write(dev, 0xf9, 0x48);
  54. ite_reg_write(dev, 0xfa, 0x00);
  55. ite_reg_write(dev, 0xfb, 0x10);
  56. pnp_set_enable(dev, 1);
  57. }
  58.  
  59. /*
  60. * Sets up GPIO configuration as per vendor defaults
  61. * SIO defaults are unknown therefore all GPIO pins are configured
  62. */
  63. static void ite_gpio_conf(pnp_devfn_t dev)
  64. {
  65. ite_reg_write(dev, 0x23, 0x08);
  66. ite_reg_write(dev, 0x25, 0x10);
  67. ite_reg_write(dev, 0x26, 0x00);
  68. ite_reg_write(dev, 0x27, 0x80);
  69. ite_reg_write(dev, 0x28, 0x45);
  70. ite_reg_write(dev, 0x29, 0x00);
  71. ite_reg_write(dev, 0x2a, 0x00);
  72. ite_reg_write(dev, 0x2b, 0x48);
  73. ite_reg_write(dev, 0x2c, 0x10);
  74. ite_reg_write(dev, 0x2d, 0x80);
  75. ite_reg_write(dev, 0x71, 0x00);
  76. ite_reg_write(dev, 0x72, 0x00);
  77. ite_reg_write(dev, 0x73, 0x38);
  78. ite_reg_write(dev, 0x74, 0x00);
  79. ite_reg_write(dev, 0xb0, 0x00);
  80. ite_reg_write(dev, 0xb1, 0x00);
  81. ite_reg_write(dev, 0xb2, 0x00);
  82. ite_reg_write(dev, 0xb3, 0x00);
  83. ite_reg_write(dev, 0xb4, 0x00);
  84. ite_reg_write(dev, 0xb8, 0x00);
  85. ite_reg_write(dev, 0xb9, 0x00);
  86. ite_reg_write(dev, 0xba, 0x00);
  87. ite_reg_write(dev, 0xbb, 0x00);
  88. ite_reg_write(dev, 0xbc, 0x00);
  89. ite_reg_write(dev, 0xbd, 0x00);
  90. ite_reg_write(dev, 0xc0, 0x01);
  91. ite_reg_write(dev, 0xc1, 0x00);
  92. ite_reg_write(dev, 0xc2, 0x00);
  93. ite_reg_write(dev, 0xc3, 0x00);
  94. ite_reg_write(dev, 0xc4, 0x00);
  95. ite_reg_write(dev, 0xc8, 0x01);
  96. ite_reg_write(dev, 0xc9, 0x00);
  97. ite_reg_write(dev, 0xca, 0x00);
  98. ite_reg_write(dev, 0xcb, 0x00);
  99. ite_reg_write(dev, 0xcc, 0x00);
  100. ite_reg_write(dev, 0xcd, 0x20);
  101. ite_reg_write(dev, 0xce, 0x00);
  102. ite_reg_write(dev, 0xcf, 0x00);
  103. ite_reg_write(dev, 0xe0, 0x00);
  104. ite_reg_write(dev, 0xe1, 0x00);
  105. ite_reg_write(dev, 0xe2, 0x00);
  106. ite_reg_write(dev, 0xe3, 0x00);
  107. ite_reg_write(dev, 0xe4, 0x00);
  108. ite_reg_write(dev, 0xe9, 0x21);
  109. ite_reg_write(dev, 0xf0, 0x00);
  110. ite_reg_write(dev, 0xf1, 0x00);
  111. ite_reg_write(dev, 0xf2, 0x00);
  112. ite_reg_write(dev, 0xf3, 0x00);
  113. ite_reg_write(dev, 0xf4, 0x00);
  114. ite_reg_write(dev, 0xf5, 0x00);
  115. ite_reg_write(dev, 0xf6, 0x00);
  116. ite_reg_write(dev, 0xf7, 0x00);
  117. ite_reg_write(dev, 0xf8, 0x00);
  118. ite_reg_write(dev, 0xf9, 0x00);
  119. ite_reg_write(dev, 0xfa, 0x00);
  120. ite_reg_write(dev, 0xfb, 0x00);
  121. }
  122.  
  123. void board_BeforeAgesa(struct sysinfo *cb)
  124. {
  125. int i;
  126. u32 val;
  127. u8 byte;
  128. pci_devfn_t dev;
  129. u32 *addr32;
  130.  
  131. /* In Hudson RRG, PMIOxD2[5:4] is "Drive strength control for
  132. * LpcClk[1:0]". To be consistent with Parmer, setting to 4mA
  133. * even though the register is not documented in the Kabini BKDG.
  134. * Otherwise the serial output is bad code.
  135. */
  136. outb(0xD2, 0xcd6);
  137. outb(0x00, 0xcd7);
  138.  
  139. /* Disable PCI-PCI bridge and release GPIO32/33 for other uses. */
  140. outb(0xEA, 0xcd6);
  141. outb(0x1, 0xcd7);
  142.  
  143. /* Set LPC decode enables. */
  144. pci_devfn_t dev2 = PCI_DEV(0, 0x14, 3);
  145. pci_write_config32(dev2, 0x44, 0xff03ffd5);
  146.  
  147. hudson_lpc_port80();
  148.  
  149. /* Enable the AcpiMmio space */
  150. outb(0x24, 0xcd6);
  151. outb(0x1, 0xcd7);
  152.  
  153. /* Configure ClkDrvStr1 settings */
  154. addr32 = (u32 *)0xfed80e24;
  155. *addr32 = 0x030800aa;
  156.  
  157. /* Configure MiscClkCntl1 settings */
  158. addr32 = (u32 *)0xfed80e40;
  159. *addr32 = 0x000c4050;
  160.  
  161. /* enable SIO LPC decode */
  162. dev = PCI_DEV(0, 0x14, 3);
  163. byte = pci_read_config8(dev, 0x48);
  164. byte |= 3; /* 2e, 2f & 4e, 4f */
  165. pci_write_config8(dev, 0x48, byte);
  166.  
  167. ite_gpio_conf(GPIO_DEV);
  168. ite_evc_conf(ENVC_DEV);
  169.  
  170. ite_conf_clkin(CLKIN_DEV, ITE_UART_CLK_PREDIVIDE_48);
  171. ite_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
  172. ite_kill_watchdog(GPIO_DEV);
  173.  
  174. /*
  175. * On Larne, after LpcClkDrvSth is set, it needs some time to be stable,
  176. * because of the buffer ICS551M
  177. */
  178. for (i = 0; i < 200000; i++)
  179. val = inb(0xcd6);
  180. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement