pch7.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright (C) 2014 Google, Inc
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <dm.h>
  8. #include <pch.h>
  9. #define BIOS_CTRL 0xd8
  10. static int pch7_get_sbase(struct udevice *dev, ulong *sbasep)
  11. {
  12. u32 rcba;
  13. dm_pci_read_config32(dev, PCH_RCBA, &rcba);
  14. /* Bits 31-14 are the base address, 13-1 are reserved, 0 is enable */
  15. rcba = rcba & 0xffffc000;
  16. *sbasep = rcba + 0x3020;
  17. return 0;
  18. }
  19. static int pch7_set_spi_protect(struct udevice *dev, bool protect)
  20. {
  21. uint8_t bios_cntl;
  22. /* Adjust the BIOS write protect to dis/allow write commands */
  23. dm_pci_read_config8(dev, BIOS_CTRL, &bios_cntl);
  24. if (protect)
  25. bios_cntl &= ~BIOS_CTRL_BIOSWE;
  26. else
  27. bios_cntl |= BIOS_CTRL_BIOSWE;
  28. dm_pci_write_config8(dev, BIOS_CTRL, bios_cntl);
  29. return 0;
  30. }
  31. static const struct pch_ops pch7_ops = {
  32. .get_sbase = pch7_get_sbase,
  33. .set_spi_protect = pch7_set_spi_protect,
  34. };
  35. static const struct udevice_id pch7_ids[] = {
  36. { .compatible = "intel,pch7" },
  37. { }
  38. };
  39. U_BOOT_DRIVER(pch7_drv) = {
  40. .name = "intel-pch7",
  41. .id = UCLASS_PCH,
  42. .of_match = pch7_ids,
  43. .ops = &pch7_ops,
  44. };