lpc.c 1.4 KB

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