WIP FPC-III support
[linux/fpc-iii.git] / drivers / i2c / busses / i2c-designware-baytrail.c
blobc6a7a00e1d5296ae126c0d804856a10d1e8832dc
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>
11 #include <asm/iosf_mbi.h>
13 #include "i2c-designware-core.h"
15 int i2c_dw_probe_lock_support(struct dw_i2c_dev *dev)
17 acpi_status status;
18 unsigned long long shared_host = 0;
19 acpi_handle handle;
21 if (!dev || !dev->dev)
22 return 0;
24 handle = ACPI_HANDLE(dev->dev);
25 if (!handle)
26 return 0;
28 status = acpi_evaluate_integer(handle, "_SEM", NULL, &shared_host);
29 if (ACPI_FAILURE(status))
30 return 0;
32 if (!shared_host)
33 return 0;
35 if (!iosf_mbi_available())
36 return -EPROBE_DEFER;
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->shared_with_punit = true;
43 return 0;