i2c-designware-baytrail.c 959 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Intel BayTrail PMIC I2C bus semaphore implementation
  4. * Copyright (c) 2014, Intel Corporation.
  5. */
  6. #include <linux/device.h>
  7. #include <linux/acpi.h>
  8. #include <linux/i2c.h>
  9. #include <linux/interrupt.h>
  10. #include <asm/iosf_mbi.h>
  11. #include "i2c-designware-core.h"
  12. int i2c_dw_baytrail_probe_lock_support(struct dw_i2c_dev *dev)
  13. {
  14. acpi_status status;
  15. unsigned long long shared_host = 0;
  16. acpi_handle handle;
  17. if (!dev)
  18. return -ENODEV;
  19. handle = ACPI_HANDLE(dev->dev);
  20. if (!handle)
  21. return -ENODEV;
  22. status = acpi_evaluate_integer(handle, "_SEM", NULL, &shared_host);
  23. if (ACPI_FAILURE(status))
  24. return -ENODEV;
  25. if (!shared_host)
  26. return -ENODEV;
  27. if (!iosf_mbi_available())
  28. return -EPROBE_DEFER;
  29. dev_info(dev->dev, "I2C bus managed by PUNIT\n");
  30. dev->acquire_lock = iosf_mbi_block_punit_i2c_access;
  31. dev->release_lock = iosf_mbi_unblock_punit_i2c_access;
  32. dev->shared_with_punit = true;
  33. return 0;
  34. }