2018-08-10 18:26:49 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2015-01-15 17:12:17 +08:00
|
|
|
/*
|
2020-03-19 23:30:12 +08:00
|
|
|
* Intel BayTrail PMIC I2C bus semaphore implementation
|
2015-01-15 17:12:17 +08:00
|
|
|
* Copyright (c) 2014, Intel Corporation.
|
|
|
|
*/
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/acpi.h>
|
|
|
|
#include <linux/i2c.h>
|
|
|
|
#include <linux/interrupt.h>
|
2015-02-11 01:06:08 +08:00
|
|
|
|
2015-01-15 17:12:17 +08:00
|
|
|
#include <asm/iosf_mbi.h>
|
2015-02-11 01:06:08 +08:00
|
|
|
|
2015-01-15 17:12:17 +08:00
|
|
|
#include "i2c-designware-core.h"
|
|
|
|
|
2017-02-10 18:27:56 +08:00
|
|
|
int i2c_dw_probe_lock_support(struct dw_i2c_dev *dev)
|
2015-01-15 17:12:17 +08:00
|
|
|
{
|
|
|
|
acpi_status status;
|
|
|
|
unsigned long long shared_host = 0;
|
|
|
|
acpi_handle handle;
|
|
|
|
|
|
|
|
if (!dev || !dev->dev)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
handle = ACPI_HANDLE(dev->dev);
|
|
|
|
if (!handle)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
status = acpi_evaluate_integer(handle, "_SEM", NULL, &shared_host);
|
|
|
|
if (ACPI_FAILURE(status))
|
|
|
|
return 0;
|
|
|
|
|
2017-02-10 18:27:55 +08:00
|
|
|
if (!shared_host)
|
|
|
|
return 0;
|
2015-01-15 17:12:17 +08:00
|
|
|
|
|
|
|
if (!iosf_mbi_available())
|
|
|
|
return -EPROBE_DEFER;
|
|
|
|
|
2017-02-10 18:27:55 +08:00
|
|
|
dev_info(dev->dev, "I2C bus managed by PUNIT\n");
|
2018-10-11 22:29:11 +08:00
|
|
|
dev->acquire_lock = iosf_mbi_block_punit_i2c_access;
|
|
|
|
dev->release_lock = iosf_mbi_unblock_punit_i2c_access;
|
2018-09-06 03:51:31 +08:00
|
|
|
dev->shared_with_punit = true;
|
2017-02-10 18:27:55 +08:00
|
|
|
|
2015-01-15 17:12:17 +08:00
|
|
|
return 0;
|
|
|
|
}
|