lpc.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2016 Google, Inc
  4. *
  5. * From coreboot broadwell support
  6. */
  7. #include <common.h>
  8. #include <dm.h>
  9. #include <pch.h>
  10. #include <asm/intel_regs.h>
  11. #include <asm/io.h>
  12. #include <asm/lpc_common.h>
  13. #include <asm/arch/pch.h>
  14. #include <asm/arch/spi.h>
  15. static void set_spi_speed(void)
  16. {
  17. u32 fdod;
  18. u8 ssfc;
  19. /* Observe SPI Descriptor Component Section 0 */
  20. writel(0x1000, SPI_REG(SPIBAR_FDOC));
  21. /* Extract the Write/Erase SPI Frequency from descriptor */
  22. fdod = readl(SPI_REG(SPIBAR_FDOD));
  23. fdod >>= 24;
  24. fdod &= 7;
  25. /* Set Software Sequence frequency to match */
  26. ssfc = readb(SPI_REG(SPIBAR_SSFC + 2));
  27. ssfc &= ~7;
  28. ssfc |= fdod;
  29. writeb(ssfc, SPI_REG(SPIBAR_SSFC + 2));
  30. }
  31. static int broadwell_lpc_early_init(struct udevice *dev)
  32. {
  33. set_spi_speed();
  34. return 0;
  35. }
  36. static int lpc_init_extra(struct udevice *dev)
  37. {
  38. return 0;
  39. }
  40. static int broadwell_lpc_probe(struct udevice *dev)
  41. {
  42. int ret;
  43. if (!(gd->flags & GD_FLG_RELOC)) {
  44. ret = lpc_common_early_init(dev);
  45. if (ret) {
  46. debug("%s: lpc_early_init() failed\n", __func__);
  47. return ret;
  48. }
  49. return broadwell_lpc_early_init(dev);
  50. }
  51. return lpc_init_extra(dev);
  52. }
  53. static const struct udevice_id broadwell_lpc_ids[] = {
  54. { .compatible = "intel,broadwell-lpc" },
  55. { }
  56. };
  57. U_BOOT_DRIVER(broadwell_lpc_drv) = {
  58. .name = "lpc",
  59. .id = UCLASS_LPC,
  60. .of_match = broadwell_lpc_ids,
  61. .probe = broadwell_lpc_probe,
  62. };