ACPI / PMIC: xpower: Add depends on IOSF_MBI to Kconfig entry
[muen/linux.git] / drivers / i2c / busses / i2c-designware-baytrail.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Intel BayTrail PMIC I2C bus semaphore implementaion
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
11 #include <asm/iosf_mbi.h>
12
13 #include "i2c-designware-core.h"
14
15 int i2c_dw_probe_lock_support(struct dw_i2c_dev *dev)
16 {
17         acpi_status status;
18         unsigned long long shared_host = 0;
19         acpi_handle handle;
20
21         if (!dev || !dev->dev)
22                 return 0;
23
24         handle = ACPI_HANDLE(dev->dev);
25         if (!handle)
26                 return 0;
27
28         status = acpi_evaluate_integer(handle, "_SEM", NULL, &shared_host);
29         if (ACPI_FAILURE(status))
30                 return 0;
31
32         if (!shared_host)
33                 return 0;
34
35         if (!iosf_mbi_available())
36                 return -EPROBE_DEFER;
37
38         dev_info(dev->dev, "I2C bus managed by PUNIT\n");
39         dev->acquire_lock = iosf_mbi_block_punit_i2c_access;
40         dev->release_lock = iosf_mbi_unblock_punit_i2c_access;
41         dev->pm_disabled = true;
42
43         return 0;
44 }