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
11#include <asm/iosf_mbi.h>
12
13#include "i2c-designware-core.h"
14
15int i2c_dw_baytrail_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)
22 return -ENODEV;
23
24 handle = ACPI_HANDLE(dev->dev);
25 if (!handle)
26 return -ENODEV;
27
28 status = acpi_evaluate_integer(handle, pathname: "_SEM", NULL, data: &shared_host);
29 if (ACPI_FAILURE(status))
30 return -ENODEV;
31
32 if (!shared_host)
33 return -ENODEV;
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->shared_with_punit = true;
42
43 return 0;
44}
45

source code of linux/drivers/i2c/busses/i2c-designware-baytrail.c