intel_i2c.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright (c) 2015 Google, Inc
  3. * Written by Simon Glass <sjg@chromium.org>
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #include <common.h>
  8. #include <dm.h>
  9. #include <i2c.h>
  10. #include <asm/io.h>
  11. #include <asm/arch/pch.h>
  12. int intel_i2c_xfer(struct udevice *bus, struct i2c_msg *msg, int nmsgs)
  13. {
  14. return -ENOSYS;
  15. }
  16. int intel_i2c_probe_chip(struct udevice *bus, uint chip_addr, uint chip_flags)
  17. {
  18. return -ENOSYS;
  19. }
  20. int intel_i2c_set_bus_speed(struct udevice *bus, unsigned int speed)
  21. {
  22. return 0;
  23. }
  24. static int intel_i2c_probe(struct udevice *dev)
  25. {
  26. /*
  27. * So far this is just setup code for ivybridge SMbus. When we have
  28. * a full I2C driver this may need to be moved, generalised or made
  29. * dependant on a particular compatible string.
  30. *
  31. * Set SMBus I/O base
  32. */
  33. dm_pci_write_config32(dev, SMB_BASE,
  34. SMBUS_IO_BASE | PCI_BASE_ADDRESS_SPACE_IO);
  35. /* Set SMBus enable. */
  36. dm_pci_write_config8(dev, HOSTC, HST_EN);
  37. /* Set SMBus I/O space enable. */
  38. dm_pci_write_config16(dev, PCI_COMMAND, PCI_COMMAND_IO);
  39. /* Disable interrupt generation. */
  40. outb(0, SMBUS_IO_BASE + SMBHSTCTL);
  41. /* Clear any lingering errors, so transactions can run. */
  42. outb(inb(SMBUS_IO_BASE + SMBHSTSTAT), SMBUS_IO_BASE + SMBHSTSTAT);
  43. debug("SMBus controller enabled\n");
  44. return 0;
  45. }
  46. static const struct dm_i2c_ops intel_i2c_ops = {
  47. .xfer = intel_i2c_xfer,
  48. .probe_chip = intel_i2c_probe_chip,
  49. .set_bus_speed = intel_i2c_set_bus_speed,
  50. };
  51. static const struct udevice_id intel_i2c_ids[] = {
  52. { .compatible = "intel,ich-i2c" },
  53. { }
  54. };
  55. U_BOOT_DRIVER(intel_i2c) = {
  56. .name = "i2c_intel",
  57. .id = UCLASS_I2C,
  58. .of_match = intel_i2c_ids,
  59. .per_child_auto_alloc_size = sizeof(struct dm_i2c_chip),
  60. .ops = &intel_i2c_ops,
  61. .probe = intel_i2c_probe,
  62. };