All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch V3 0/5] I2C ACPI operation region handler
@ 2014-05-20 12:59 Lan Tianyu
       [not found] ` <1400590764-11108-1-git-send-email-tianyu.lan-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
                   ` (3 more replies)
  0 siblings, 4 replies; 34+ messages in thread
From: Lan Tianyu @ 2014-05-20 12:59 UTC (permalink / raw)
  To: wsa, rjw, mika.westerberg, awilliam, lenb
  Cc: Lan Tianyu, linux-i2c, linux-kernel, linux-acpi

ACPI 5.0 spec(5.5.2.4.5) defines GenericSerialBus(i2c, spi, uart) operation
region. It allows ACPI aml code able to access such kind of devices to
implement some ACPI standard method.

On the Asus T100TA, Bios use GenericSerialBus operation region to access
i2c device to get battery info. So battery function depends on the I2C
operation region support. Here is the bug link.
https://bugzilla.kernel.org/show_bug.cgi?id=69011

Change since V2:
        Drop patchs of adding I2C smbus quick read/write and word/block
process call functions because not find machines supporting such protocols
so far and can't test these functions.
        Merge patchs of "I2C ACPI related code clear up" and "Add CONFIG_I2C_ACPI
config"
	Patch 2: Add acpi_bus_detach_private_data() function to detach data from
ACPI handle and replace ACPI_ERROR() with acpi_handle_debug() to avoid some redundant
error log.  

Change since V1:
       Fix some code style issues. Change prefix i2c_acpi to acpi_i2c.
Move ACPI related code in the i2c core to i2c-acpi.c. Add CONFIG_I2C_ACPI
and make i2c core built-in when it's set to avoid i2c ACPI operation region
being removed.

Lan Tianyu (5):
  ACPICA: Export acpi_buffer_to_resource symbol
  ACPI: Add acpi_bus_attach_private_data() to facilitate to attach data
    to ACPI handle
  ACPI/Thermal: Use acpi_bus_attach_private_data() to attach private
    data
  I2C/ACPI: Add i2c ACPI operation region support
  I2C/ACPI: Clean up I2C ACPI code and Add CONFIG_I2C_ACPI config

 drivers/acpi/acpica/rscreate.c |   1 +
 drivers/acpi/bus.c             |  28 +++-
 drivers/acpi/thermal.c         |  11 +-
 drivers/i2c/Kconfig            |  18 +-
 drivers/i2c/Makefile           |   5 +-
 drivers/i2c/i2c-acpi.c         | 362 +++++++++++++++++++++++++++++++++++++++++
 drivers/i2c/i2c-core.c         |  97 +----------
 include/acpi/acpi_bus.h        |   2 +
 include/linux/acpi.h           |  11 ++
 include/linux/i2c.h            |  12 ++
 10 files changed, 439 insertions(+), 108 deletions(-)
 create mode 100644 drivers/i2c/i2c-acpi.c

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [Patch V3 1/5] ACPICA: Export acpi_buffer_to_resource symbol
  2014-05-20 12:59 [Patch V3 0/5] I2C ACPI operation region handler Lan Tianyu
@ 2014-05-20 12:59     ` Lan Tianyu
  2014-05-20 12:59 ` [Patch V3 2/5] ACPI: Add acpi_bus_attach_private_data() to facilitate to attach data to ACPI handle Lan Tianyu
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 34+ messages in thread
From: Lan Tianyu @ 2014-05-20 12:59 UTC (permalink / raw)
  To: wsa-z923LK4zBo2bacvFa/9K2g, rjw-LthD3rsA81gm4RdzfppkhA,
	mika.westerberg-VuQAYsv1563Yd54FQh9/CA,
	awilliam-H+wXaHxf7aLQT0dZR+AlfA, lenb-DgEjT+Ai2ygdnm+yROfE0A
  Cc: Lan Tianyu, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-acpi-u79uwXL29TY76Z2rM5mHXA

The acpi_buffer_to_resource is needed in i2c module
to convert aml buffer to struct acpi_resource

Reviewed-by: Mika Westerberg <mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Signed-off-by: Lan Tianyu <tianyu.lan-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 drivers/acpi/acpica/rscreate.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/acpi/acpica/rscreate.c b/drivers/acpi/acpica/rscreate.c
index 75d3690..5828649 100644
--- a/drivers/acpi/acpica/rscreate.c
+++ b/drivers/acpi/acpica/rscreate.c
@@ -112,6 +112,7 @@ acpi_buffer_to_resource(u8 *aml_buffer,
 
 	return (status);
 }
+ACPI_EXPORT_SYMBOL(acpi_buffer_to_resource);
 
 /*******************************************************************************
  *
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [Patch V3 1/5] ACPICA: Export acpi_buffer_to_resource symbol
@ 2014-05-20 12:59     ` Lan Tianyu
  0 siblings, 0 replies; 34+ messages in thread
From: Lan Tianyu @ 2014-05-20 12:59 UTC (permalink / raw)
  To: wsa, rjw, mika.westerberg, awilliam, lenb
  Cc: Lan Tianyu, linux-i2c, linux-kernel, linux-acpi

The acpi_buffer_to_resource is needed in i2c module
to convert aml buffer to struct acpi_resource

Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
---
 drivers/acpi/acpica/rscreate.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/acpi/acpica/rscreate.c b/drivers/acpi/acpica/rscreate.c
index 75d3690..5828649 100644
--- a/drivers/acpi/acpica/rscreate.c
+++ b/drivers/acpi/acpica/rscreate.c
@@ -112,6 +112,7 @@ acpi_buffer_to_resource(u8 *aml_buffer,
 
 	return (status);
 }
+ACPI_EXPORT_SYMBOL(acpi_buffer_to_resource);
 
 /*******************************************************************************
  *
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [Patch V3 2/5] ACPI: Add acpi_bus_attach_private_data() to facilitate to attach data to ACPI handle
  2014-05-20 12:59 [Patch V3 0/5] I2C ACPI operation region handler Lan Tianyu
       [not found] ` <1400590764-11108-1-git-send-email-tianyu.lan-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
@ 2014-05-20 12:59 ` Lan Tianyu
  2014-05-20 12:59 ` [Patch V3 4/5] I2C/ACPI: Add i2c ACPI operation region support Lan Tianyu
  2014-05-20 12:59 ` [Patch V3 5/5] I2C/ACPI: Clean up I2C ACPI code and Add CONFIG_I2C_ACPI config Lan Tianyu
  3 siblings, 0 replies; 34+ messages in thread
From: Lan Tianyu @ 2014-05-20 12:59 UTC (permalink / raw)
  To: wsa, rjw, mika.westerberg, awilliam, lenb
  Cc: Lan Tianyu, linux-i2c, linux-kernel, linux-acpi

There is already acpi_bus_get_private_data() to get ACPI handle data
which is associated with acpi_bus_private_data_handler(). This patch
is to add acpi_bus_attach_private_data() to make a pair and facilitate
to attach and get data to/from ACPI handle.

Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
---
 drivers/acpi/bus.c      | 28 ++++++++++++++++++++++++----
 include/acpi/acpi_bus.h |  2 ++
 2 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index cf925c4..8445d57 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -132,6 +132,21 @@ void acpi_bus_private_data_handler(acpi_handle handle,
 }
 EXPORT_SYMBOL(acpi_bus_private_data_handler);
 
+int acpi_bus_attach_private_data(acpi_handle handle, void *data)
+{
+	acpi_status status;
+
+	status = acpi_attach_data(handle,
+			acpi_bus_private_data_handler, data);
+	if (ACPI_FAILURE(status)) {
+		acpi_handle_debug(handle, "Error attaching device data\n");
+		return -ENODEV;
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(acpi_bus_attach_private_data);
+
 int acpi_bus_get_private_data(acpi_handle handle, void **data)
 {
 	acpi_status status;
@@ -140,15 +155,20 @@ int acpi_bus_get_private_data(acpi_handle handle, void **data)
 		return -EINVAL;
 
 	status = acpi_get_data(handle, acpi_bus_private_data_handler, data);
-	if (ACPI_FAILURE(status) || !*data) {
-		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No context for object [%p]\n",
-				handle));
+	if (ACPI_FAILURE(status)) {
+		acpi_handle_debug(handle, "No context for object\n");
 		return -ENODEV;
 	}
 
 	return 0;
 }
-EXPORT_SYMBOL(acpi_bus_get_private_data);
+EXPORT_SYMBOL_GPL(acpi_bus_get_private_data);
+
+void acpi_bus_detach_private_data(acpi_handle handle)
+{
+	acpi_detach_data(handle, acpi_bus_private_data_handler);
+}
+EXPORT_SYMBOL_GPL(acpi_bus_detach_private_data);
 
 void acpi_bus_no_hotplug(acpi_handle handle)
 {
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 84a2e29..d2006ca 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -406,6 +406,8 @@ extern struct kobject *acpi_kobj;
 extern int acpi_bus_generate_netlink_event(const char*, const char*, u8, int);
 void acpi_bus_private_data_handler(acpi_handle, void *);
 int acpi_bus_get_private_data(acpi_handle, void **);
+int acpi_bus_attach_private_data(acpi_handle, void *);
+void acpi_bus_detach_private_data(acpi_handle);
 void acpi_bus_no_hotplug(acpi_handle handle);
 extern int acpi_notifier_call_chain(struct acpi_device *, u32, u32);
 extern int register_acpi_notifier(struct notifier_block *);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [Patch V3 3/5] ACPI/Thermal: Use acpi_bus_attach_private_data() to attach private data
  2014-05-20 12:59 [Patch V3 0/5] I2C ACPI operation region handler Lan Tianyu
@ 2014-05-20 12:59     ` Lan Tianyu
  2014-05-20 12:59 ` [Patch V3 2/5] ACPI: Add acpi_bus_attach_private_data() to facilitate to attach data to ACPI handle Lan Tianyu
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 34+ messages in thread
From: Lan Tianyu @ 2014-05-20 12:59 UTC (permalink / raw)
  To: wsa-z923LK4zBo2bacvFa/9K2g, rjw-LthD3rsA81gm4RdzfppkhA,
	mika.westerberg-VuQAYsv1563Yd54FQh9/CA,
	awilliam-H+wXaHxf7aLQT0dZR+AlfA, lenb-DgEjT+Ai2ygdnm+yROfE0A
  Cc: Lan Tianyu, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-acpi-u79uwXL29TY76Z2rM5mHXA

Use acpi_bus_attach_private_data() to attach private data
instead of acpi_attach_data().

Reviewed-by: Mika Westerberg <mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Signed-off-by: Lan Tianyu <tianyu.lan-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 drivers/acpi/thermal.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index c1e31a4..ae195fd 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -925,13 +925,10 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
 	if (result)
 		return result;
 
-	status = acpi_attach_data(tz->device->handle,
-				  acpi_bus_private_data_handler,
-				  tz->thermal_zone);
-	if (ACPI_FAILURE(status)) {
-		pr_err(PREFIX "Error attaching device data\n");
+	status =  acpi_bus_attach_private_data(tz->device->handle,
+					       tz->thermal_zone);
+	if (ACPI_FAILURE(status))
 		return -ENODEV;
-	}
 
 	tz->tz_enabled = 1;
 
@@ -946,7 +943,7 @@ static void acpi_thermal_unregister_thermal_zone(struct acpi_thermal *tz)
 	sysfs_remove_link(&tz->thermal_zone->device.kobj, "device");
 	thermal_zone_device_unregister(tz->thermal_zone);
 	tz->thermal_zone = NULL;
-	acpi_detach_data(tz->device->handle, acpi_bus_private_data_handler);
+	acpi_bus_detach_private_data(tz->device->handle);
 }
 
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [Patch V3 3/5] ACPI/Thermal: Use acpi_bus_attach_private_data() to attach private data
@ 2014-05-20 12:59     ` Lan Tianyu
  0 siblings, 0 replies; 34+ messages in thread
From: Lan Tianyu @ 2014-05-20 12:59 UTC (permalink / raw)
  To: wsa, rjw, mika.westerberg, awilliam, lenb
  Cc: Lan Tianyu, linux-i2c, linux-kernel, linux-acpi

Use acpi_bus_attach_private_data() to attach private data
instead of acpi_attach_data().

Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
---
 drivers/acpi/thermal.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index c1e31a4..ae195fd 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -925,13 +925,10 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
 	if (result)
 		return result;
 
-	status = acpi_attach_data(tz->device->handle,
-				  acpi_bus_private_data_handler,
-				  tz->thermal_zone);
-	if (ACPI_FAILURE(status)) {
-		pr_err(PREFIX "Error attaching device data\n");
+	status =  acpi_bus_attach_private_data(tz->device->handle,
+					       tz->thermal_zone);
+	if (ACPI_FAILURE(status))
 		return -ENODEV;
-	}
 
 	tz->tz_enabled = 1;
 
@@ -946,7 +943,7 @@ static void acpi_thermal_unregister_thermal_zone(struct acpi_thermal *tz)
 	sysfs_remove_link(&tz->thermal_zone->device.kobj, "device");
 	thermal_zone_device_unregister(tz->thermal_zone);
 	tz->thermal_zone = NULL;
-	acpi_detach_data(tz->device->handle, acpi_bus_private_data_handler);
+	acpi_bus_detach_private_data(tz->device->handle);
 }
 
 
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [Patch V3 4/5] I2C/ACPI: Add i2c ACPI operation region support
  2014-05-20 12:59 [Patch V3 0/5] I2C ACPI operation region handler Lan Tianyu
       [not found] ` <1400590764-11108-1-git-send-email-tianyu.lan-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
  2014-05-20 12:59 ` [Patch V3 2/5] ACPI: Add acpi_bus_attach_private_data() to facilitate to attach data to ACPI handle Lan Tianyu
@ 2014-05-20 12:59 ` Lan Tianyu
  2014-06-06 22:48   ` Rafael J. Wysocki
  2014-06-27 11:03   ` Wolfram Sang
  2014-05-20 12:59 ` [Patch V3 5/5] I2C/ACPI: Clean up I2C ACPI code and Add CONFIG_I2C_ACPI config Lan Tianyu
  3 siblings, 2 replies; 34+ messages in thread
From: Lan Tianyu @ 2014-05-20 12:59 UTC (permalink / raw)
  To: wsa, rjw, mika.westerberg, awilliam, lenb
  Cc: Lan Tianyu, linux-i2c, linux-kernel, linux-acpi

ACPI 5.0 spec(5.5.2.4.5) defines GenericSerialBus(i2c, spi, uart) operation region.
It allows ACPI aml code able to access such kind of devices to implement
some ACPI standard method.

ACPI Spec defines some access attribute to associate with i2c protocol.
AttribQuick 	       	       		Read/Write Quick Protocol
AttribSendReceive			Send/Receive Byte Protocol
AttribByte 			 	Read/Write Byte Protocol
AttribWord				Read/Write Word Protocol
AttribBlock				Read/Write Block Protocol
AttribBytes				Read/Write N-Bytes Protocol
AttribProcessCall			Process Call Protocol
AttribBlockProcessCall			Write Block-Read Block Process Call Protocol
AttribRawBytes 				Raw Read/Write N-BytesProtocol
AttribRawProcessBytes			Raw Process Call Protocol

On the Asus T100TA, Bios use GenericSerialBus operation region to access
i2c device to get battery info.

Sample code From Asus T100TA

    Scope (_SB.I2C1)
    {
        Name (UMPC, ResourceTemplate ()
        {
            I2cSerialBus (0x0066, ControllerInitiated, 0x00061A80,
                AddressingMode7Bit, "\\_SB.I2C1",
                0x00, ResourceConsumer, ,
                )
        })

	...

        OperationRegion (DVUM, GenericSerialBus, Zero, 0x0100)
        Field (DVUM, BufferAcc, NoLock, Preserve)
        {
            Connection (UMPC),
            Offset (0x81),
            AccessAs (BufferAcc, AttribBytes (0x3E)),
            FGC0,   8
        }
	...
     }

     Device (BATC)
     {
         Name (_HID, EisaId ("PNP0C0A"))  // _HID: Hardware ID
         Name (_UID, One)  // _UID: Unique ID
	 ...

            Method (_BST, 0, NotSerialized)  // _BST: Battery Status
            {
                If (LEqual (AVBL, One))
                {
                    Store (FGC0, BFFG)
                    If (LNotEqual (STAT, One))
                    {
                        ShiftRight (CHST, 0x04, Local0)
                        And (Local0, 0x03, Local0)
                        If (LOr (LEqual (Local0, One), LEqual (Local0, 0x02)))
                        {
                            Store (0x02, Local1)
                        }
	...

    }

The i2c operation region is defined under I2C1 scope. _BST method under
battery device BATC read battery status from the field "FCG0". The request
would be sent to i2c operation region handler.

This patch is to add i2c ACPI operation region support. Due to there are
only "Byte" and "Bytes" protocol access on the Asus T100TA, other protocols
have not been tested.

About RawBytes and RawProcessBytes protocol, they needs specific drivers to interpret
reference data from AML code according ACPI 5.0 SPEC(5.5.2.4.5.3.9 and 5.5.2.4.5.3.10).
So far, not found such case and will add when find real case.

Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
---
 drivers/i2c/Makefile   |   5 +-
 drivers/i2c/i2c-acpi.c | 273 +++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/i2c/i2c-core.c |   2 +
 include/linux/acpi.h   |  11 ++
 include/linux/i2c.h    |  10 ++
 5 files changed, 300 insertions(+), 1 deletion(-)
 create mode 100644 drivers/i2c/i2c-acpi.c

diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index 1722f50..80db307 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -2,8 +2,11 @@
 # Makefile for the i2c core.
 #
 
+i2ccore-y := i2c-core.o
+i2ccore-$(CONFIG_ACPI)		+= i2c-acpi.o
+
 obj-$(CONFIG_I2C_BOARDINFO)	+= i2c-boardinfo.o
-obj-$(CONFIG_I2C)		+= i2c-core.o
+obj-$(CONFIG_I2C)		+= i2ccore.o
 obj-$(CONFIG_I2C_SMBUS)		+= i2c-smbus.o
 obj-$(CONFIG_I2C_CHARDEV)	+= i2c-dev.o
 obj-$(CONFIG_I2C_MUX)		+= i2c-mux.o
diff --git a/drivers/i2c/i2c-acpi.c b/drivers/i2c/i2c-acpi.c
new file mode 100644
index 0000000..f7f4c89
--- /dev/null
+++ b/drivers/i2c/i2c-acpi.c
@@ -0,0 +1,273 @@
+/*
+ * I2C ACPI code
+ *
+ * Copyright (C) 2014 Intel Corp
+ *
+ * Author: Lan Tianyu <tianyu.lan@intel.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ */
+#define pr_fmt(fmt) "I2C/ACPI : " fmt
+
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/err.h>
+#include <linux/i2c.h>
+#include <linux/acpi.h>
+
+struct acpi_i2c_handler_data {
+	struct acpi_connection_info info;
+	struct i2c_adapter *adapter;
+};
+
+struct gsb_buffer {
+	u8	status;
+	u8	len;
+	union {
+		u16	wdata;
+		u8	bdata;
+		u8	data[0];
+	};
+} __packed;
+
+static int acpi_gsb_i2c_read_bytes(struct i2c_client *client,
+		u8 cmd, u8 *data, u8 data_len)
+{
+
+	struct i2c_msg msgs[2];
+	int ret;
+	u8 *buffer;
+
+	buffer = kzalloc(data_len, GFP_KERNEL);
+	if (!buffer)
+		return AE_NO_MEMORY;
+
+	msgs[0].addr = client->addr;
+	msgs[0].flags = client->flags;
+	msgs[0].len = 1;
+	msgs[0].buf = &cmd;
+
+	msgs[1].addr = client->addr;
+	msgs[1].flags = client->flags | I2C_M_RD;
+	msgs[1].len = data_len;
+	msgs[1].buf = buffer;
+
+	ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
+	if (ret < 0)
+		dev_err(&client->adapter->dev, "i2c read failed\n");
+	else
+		memcpy(data, buffer, data_len);
+
+	kfree(buffer);
+	return ret;
+}
+
+static int acpi_gsb_i2c_write_bytes(struct i2c_client *client,
+		u8 cmd, u8 *data, u8 data_len)
+{
+
+	struct i2c_msg msgs[1];
+	u8 *buffer;
+	int ret = AE_OK;
+
+	buffer = kzalloc(data_len + 1, GFP_KERNEL);
+	if (!buffer)
+		return AE_NO_MEMORY;
+
+	buffer[0] = cmd;
+	memcpy(buffer + 1, data, data_len);
+
+	msgs[0].addr = client->addr;
+	msgs[0].flags = client->flags;
+	msgs[0].len = data_len + 1;
+	msgs[0].buf = buffer;
+
+	ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
+	if (ret < 0)
+		dev_err(&client->adapter->dev, "i2c write failed\n");
+
+	kfree(buffer);
+	return ret;
+}
+
+static acpi_status
+acpi_i2c_space_handler(u32 function, acpi_physical_address command,
+			u32 bits, u64 *value64,
+			void *handler_context, void *region_context)
+{
+	struct gsb_buffer *gsb = (struct gsb_buffer *)value64;
+	struct acpi_i2c_handler_data *data = handler_context;
+	struct acpi_connection_info *info = &data->info;
+	struct acpi_resource_i2c_serialbus *sb;
+	struct i2c_adapter *adapter = data->adapter;
+	struct i2c_client client;
+	struct acpi_resource *ares;
+	u32 accessor_type = function >> 16;
+	u8 action = function & ACPI_IO_MASK;
+	acpi_status ret = AE_OK;
+	int status;
+
+	ret = acpi_buffer_to_resource(info->connection, info->length, &ares);
+	if (ACPI_FAILURE(ret))
+		return ret;
+
+	if (!value64 || ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS) {
+		ret = AE_BAD_PARAMETER;
+		goto err;
+	}
+
+	sb = &ares->data.i2c_serial_bus;
+	if (sb->type != ACPI_RESOURCE_SERIAL_TYPE_I2C) {
+		ret = AE_BAD_PARAMETER;
+		goto err;
+	}
+
+	memset(&client, 0, sizeof(client));
+	client.adapter = adapter;
+	client.addr = sb->slave_address;
+	client.flags = 0;
+
+	if (sb->access_mode == ACPI_I2C_10BIT_MODE)
+		client.flags |= I2C_CLIENT_TEN;
+
+	switch (accessor_type) {
+	case ACPI_GSB_ACCESS_ATTRIB_SEND_RCV:
+		if (action == ACPI_READ) {
+			status = i2c_smbus_read_byte(&client);
+			if (status >= 0) {
+				gsb->bdata = status;
+				status = 0;
+			}
+		} else {
+			status = i2c_smbus_write_byte(&client, gsb->bdata);
+		}
+		break;
+
+	case ACPI_GSB_ACCESS_ATTRIB_BYTE:
+		if (action == ACPI_READ) {
+			status = i2c_smbus_read_byte_data(&client, command);
+			if (status >= 0) {
+				gsb->bdata = status;
+				status = 0;
+			}
+		} else {
+			status = i2c_smbus_write_byte_data(&client, command,
+					gsb->bdata);
+		}
+		break;
+
+	case ACPI_GSB_ACCESS_ATTRIB_WORD:
+		if (action == ACPI_READ) {
+			status = i2c_smbus_read_word_data(&client, command);
+			if (status >= 0) {
+				gsb->wdata = status;
+				status = 0;
+			}
+		} else {
+			status = i2c_smbus_write_word_data(&client, command,
+					gsb->wdata);
+		}
+		break;
+
+	case ACPI_GSB_ACCESS_ATTRIB_BLOCK:
+		if (action == ACPI_READ) {
+			status = i2c_smbus_read_block_data(&client, command,
+					gsb->data);
+			if (status >= 0) {
+				gsb->len = status;
+				status = 0;
+			}
+		} else {
+			status = i2c_smbus_write_block_data(&client, command,
+					gsb->len, gsb->data);
+		}
+		break;
+
+	case ACPI_GSB_ACCESS_ATTRIB_MULTIBYTE:
+		if (action == ACPI_READ) {
+			status = acpi_gsb_i2c_read_bytes(&client, command,
+					gsb->data, info->access_length);
+			if (status > 0)
+				status = 0;
+		} else {
+			status = acpi_gsb_i2c_write_bytes(&client, command,
+					gsb->data, info->access_length);
+		}
+		break;
+
+	default:
+		pr_info("protocol(0x%02x) is not supported.\n", accessor_type);
+		ret = AE_BAD_PARAMETER;
+		goto err;
+	}
+
+	gsb->status = status;
+
+ err:
+	ACPI_FREE(ares);
+	return ret;
+}
+
+
+int acpi_i2c_install_space_handler(struct i2c_adapter *adapter)
+{
+	acpi_handle handle = ACPI_HANDLE(adapter->dev.parent);
+	struct acpi_i2c_handler_data *data;
+	acpi_status status;
+
+	if (!handle)
+		return -ENODEV;
+
+	data = kzalloc(sizeof(struct acpi_i2c_handler_data),
+			    GFP_KERNEL);
+	if (!data)
+		return -ENOMEM;
+
+	data->adapter = adapter;
+	status = acpi_bus_attach_private_data(handle, (void *)data);
+	if (ACPI_FAILURE(status)) {
+		kfree(data);
+		return -ENOMEM;
+	}
+
+	status = acpi_install_address_space_handler(handle,
+				ACPI_ADR_SPACE_GSBUS,
+				&acpi_i2c_space_handler,
+				NULL,
+				data);
+	if (ACPI_FAILURE(status)) {
+		dev_err(&adapter->dev, "Error installing i2c space handler\n");
+		acpi_bus_detach_private_data(handle);
+		kfree(data);
+		return -ENOMEM;
+	}
+
+	return 0;
+}
+
+void acpi_i2c_remove_space_handler(struct i2c_adapter *adapter)
+{
+	acpi_handle handle = ACPI_HANDLE(adapter->dev.parent);
+	struct acpi_i2c_handler_data *data;
+	acpi_status status;
+
+	if (!handle)
+		return;
+
+	acpi_remove_address_space_handler(handle,
+				ACPI_ADR_SPACE_GSBUS,
+				&acpi_i2c_space_handler);
+
+	status = acpi_bus_get_private_data(handle, (void **)&data);
+	if (ACPI_SUCCESS(status))
+		kfree(data);
+
+	acpi_bus_detach_private_data(handle);
+}
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 7c7f4b8..e25cb84 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -1293,6 +1293,7 @@ exit_recovery:
 	/* create pre-declared device nodes */
 	of_i2c_register_devices(adap);
 	acpi_i2c_register_devices(adap);
+	acpi_i2c_install_space_handler(adap);
 
 	if (adap->nr < __i2c_first_dynamic_bus_num)
 		i2c_scan_static_board_info(adap);
@@ -1466,6 +1467,7 @@ void i2c_del_adapter(struct i2c_adapter *adap)
 		return;
 	}
 
+	acpi_i2c_remove_space_handler(adap);
 	/* Tell drivers about this removal */
 	mutex_lock(&core_lock);
 	bus_for_each_drv(&i2c_bus_type, NULL, adap,
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 7a8f2cd..ea53b9b 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -361,6 +361,17 @@ extern bool osc_sb_apei_support_acked;
 #define OSC_PCI_EXPRESS_CAPABILITY_CONTROL	0x00000010
 #define OSC_PCI_CONTROL_MASKS			0x0000001f
 
+#define ACPI_GSB_ACCESS_ATTRIB_QUICK		0x00000002
+#define ACPI_GSB_ACCESS_ATTRIB_SEND_RCV         0x00000004
+#define ACPI_GSB_ACCESS_ATTRIB_BYTE		0x00000006
+#define ACPI_GSB_ACCESS_ATTRIB_WORD		0x00000008
+#define ACPI_GSB_ACCESS_ATTRIB_BLOCK		0x0000000A
+#define ACPI_GSB_ACCESS_ATTRIB_MULTIBYTE	0x0000000B
+#define ACPI_GSB_ACCESS_ATTRIB_WORD_CALL	0x0000000C
+#define ACPI_GSB_ACCESS_ATTRIB_BLOCK_CALL	0x0000000D
+#define ACPI_GSB_ACCESS_ATTRIB_RAW_BYTES	0x0000000E
+#define ACPI_GSB_ACCESS_ATTRIB_RAW_PROCESS	0x0000000F
+
 extern acpi_status acpi_pci_osc_control_set(acpi_handle handle,
 					     u32 *mask, u32 req);
 
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index b556e0a..f7a939a 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -577,4 +577,14 @@ static inline struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node
 }
 #endif /* CONFIG_OF */
 
+#ifdef CONFIG_ACPI
+int acpi_i2c_install_space_handler(struct i2c_adapter *adapter);
+void acpi_i2c_remove_space_handler(struct i2c_adapter *adapter);
+#else
+static inline void acpi_i2c_remove_space_handler(struct i2c_adapter *adapter)
+{ }
+static inline int acpi_i2c_install_space_handler(struct i2c_adapter *adapter)
+{ return 0; }
+#endif
+
 #endif /* _LINUX_I2C_H */
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [Patch V3 5/5] I2C/ACPI: Clean up I2C ACPI code and Add CONFIG_I2C_ACPI config
  2014-05-20 12:59 [Patch V3 0/5] I2C ACPI operation region handler Lan Tianyu
                   ` (2 preceding siblings ...)
  2014-05-20 12:59 ` [Patch V3 4/5] I2C/ACPI: Add i2c ACPI operation region support Lan Tianyu
@ 2014-05-20 12:59 ` Lan Tianyu
  2014-06-27 11:03   ` Wolfram Sang
  3 siblings, 1 reply; 34+ messages in thread
From: Lan Tianyu @ 2014-05-20 12:59 UTC (permalink / raw)
  To: wsa, rjw, mika.westerberg, awilliam, lenb
  Cc: Lan Tianyu, linux-i2c, linux-kernel, linux-acpi

Clean up ACPI related code in the i2c core and add CONFIG_I2C_ACPI
to enable I2C ACPI code.

Current there is a race between removing I2C ACPI operation region
and ACPI AML code accessing. So make i2c core built-in if CONFIG_I2C_ACPI
is set.

Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
---
 drivers/i2c/Kconfig    | 18 +++++++++-
 drivers/i2c/Makefile   |  2 +-
 drivers/i2c/i2c-acpi.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++
 drivers/i2c/i2c-core.c | 95 --------------------------------------------------
 include/linux/i2c.h    |  4 ++-
 5 files changed, 110 insertions(+), 98 deletions(-)

diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
index 7b7ea32..3e3b680 100644
--- a/drivers/i2c/Kconfig
+++ b/drivers/i2c/Kconfig
@@ -2,7 +2,9 @@
 # I2C subsystem configuration
 #
 
-menuconfig I2C
+menu "I2C support"
+
+config I2C
 	tristate "I2C support"
 	select RT_MUTEXES
 	---help---
@@ -21,6 +23,18 @@ menuconfig I2C
 	  This I2C support can also be built as a module.  If so, the module
 	  will be called i2c-core.
 
+config I2C_ACPI
+	bool "I2C ACPI support"
+	select I2C
+	depends on ACPI
+	default y
+	help
+	  Say Y here if you want to enable ACPI I2C support. This includes support
+	  for automatic enumeration of I2C slave devices and support for ACPI I2C
+	  Operation Regions. Operation Regions allow firmware (BIOS) code to
+	  access I2C slave devices, such as smart batteries through an I2C host
+	  controller driver.
+
 if I2C
 
 config I2C_BOARDINFO
@@ -124,3 +138,5 @@ config I2C_DEBUG_BUS
 	  on.
 
 endif # I2C
+
+endmenu
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index 80db307..a1f590c 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -3,7 +3,7 @@
 #
 
 i2ccore-y := i2c-core.o
-i2ccore-$(CONFIG_ACPI)		+= i2c-acpi.o
+i2ccore-$(CONFIG_I2C_ACPI)	+= i2c-acpi.o
 
 obj-$(CONFIG_I2C_BOARDINFO)	+= i2c-boardinfo.o
 obj-$(CONFIG_I2C)		+= i2ccore.o
diff --git a/drivers/i2c/i2c-acpi.c b/drivers/i2c/i2c-acpi.c
index f7f4c89..e8b6196 100644
--- a/drivers/i2c/i2c-acpi.c
+++ b/drivers/i2c/i2c-acpi.c
@@ -37,6 +37,95 @@ struct gsb_buffer {
 	};
 } __packed;
 
+static int acpi_i2c_add_resource(struct acpi_resource *ares, void *data)
+{
+	struct i2c_board_info *info = data;
+
+	if (ares->type == ACPI_RESOURCE_TYPE_SERIAL_BUS) {
+		struct acpi_resource_i2c_serialbus *sb;
+
+		sb = &ares->data.i2c_serial_bus;
+		if (sb->type == ACPI_RESOURCE_SERIAL_TYPE_I2C) {
+			info->addr = sb->slave_address;
+			if (sb->access_mode == ACPI_I2C_10BIT_MODE)
+				info->flags |= I2C_CLIENT_TEN;
+		}
+	} else if (info->irq < 0) {
+		struct resource r;
+
+		if (acpi_dev_resource_interrupt(ares, 0, &r))
+			info->irq = r.start;
+	}
+
+	/* Tell the ACPI core to skip this resource */
+	return 1;
+}
+
+static acpi_status acpi_i2c_add_device(acpi_handle handle, u32 level,
+				       void *data, void **return_value)
+{
+	struct i2c_adapter *adapter = data;
+	struct list_head resource_list;
+	struct i2c_board_info info;
+	struct acpi_device *adev;
+	int ret;
+
+	if (acpi_bus_get_device(handle, &adev))
+		return AE_OK;
+	if (acpi_bus_get_status(adev) || !adev->status.present)
+		return AE_OK;
+
+	memset(&info, 0, sizeof(info));
+	info.acpi_node.companion = adev;
+	info.irq = -1;
+
+	INIT_LIST_HEAD(&resource_list);
+	ret = acpi_dev_get_resources(adev, &resource_list,
+				     acpi_i2c_add_resource, &info);
+	acpi_dev_free_resource_list(&resource_list);
+
+	if (ret < 0 || !info.addr)
+		return AE_OK;
+
+	adev->power.flags.ignore_parent = true;
+	strlcpy(info.type, dev_name(&adev->dev), sizeof(info.type));
+	if (!i2c_new_device(adapter, &info)) {
+		adev->power.flags.ignore_parent = false;
+		dev_err(&adapter->dev,
+			"failed to add I2C device %s from ACPI\n",
+			dev_name(&adev->dev));
+	}
+
+	return AE_OK;
+}
+
+/**
+ * acpi_i2c_register_devices - enumerate I2C slave devices behind adapter
+ * @adap: pointer to adapter
+ *
+ * Enumerate all I2C slave devices behind this adapter by walking the ACPI
+ * namespace. When a device is found it will be added to the Linux device
+ * model and bound to the corresponding ACPI handle.
+ */
+void acpi_i2c_register_devices(struct i2c_adapter *adap)
+{
+	acpi_handle handle;
+	acpi_status status;
+
+	if (!adap->dev.parent)
+		return;
+
+	handle = ACPI_HANDLE(adap->dev.parent);
+	if (!handle)
+		return;
+
+	status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 1,
+				     acpi_i2c_add_device, NULL,
+				     adap, NULL);
+	if (ACPI_FAILURE(status))
+		dev_warn(&adap->dev, "failed to enumerate I2C slaves\n");
+}
+
 static int acpi_gsb_i2c_read_bytes(struct i2c_client *client,
 		u8 cmd, u8 *data, u8 data_len)
 {
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index e25cb84..4ccff11 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -1092,101 +1092,6 @@ EXPORT_SYMBOL(of_find_i2c_adapter_by_node);
 static void of_i2c_register_devices(struct i2c_adapter *adap) { }
 #endif /* CONFIG_OF */
 
-/* ACPI support code */
-
-#if IS_ENABLED(CONFIG_ACPI)
-static int acpi_i2c_add_resource(struct acpi_resource *ares, void *data)
-{
-	struct i2c_board_info *info = data;
-
-	if (ares->type == ACPI_RESOURCE_TYPE_SERIAL_BUS) {
-		struct acpi_resource_i2c_serialbus *sb;
-
-		sb = &ares->data.i2c_serial_bus;
-		if (sb->type == ACPI_RESOURCE_SERIAL_TYPE_I2C) {
-			info->addr = sb->slave_address;
-			if (sb->access_mode == ACPI_I2C_10BIT_MODE)
-				info->flags |= I2C_CLIENT_TEN;
-		}
-	} else if (info->irq < 0) {
-		struct resource r;
-
-		if (acpi_dev_resource_interrupt(ares, 0, &r))
-			info->irq = r.start;
-	}
-
-	/* Tell the ACPI core to skip this resource */
-	return 1;
-}
-
-static acpi_status acpi_i2c_add_device(acpi_handle handle, u32 level,
-				       void *data, void **return_value)
-{
-	struct i2c_adapter *adapter = data;
-	struct list_head resource_list;
-	struct i2c_board_info info;
-	struct acpi_device *adev;
-	int ret;
-
-	if (acpi_bus_get_device(handle, &adev))
-		return AE_OK;
-	if (acpi_bus_get_status(adev) || !adev->status.present)
-		return AE_OK;
-
-	memset(&info, 0, sizeof(info));
-	info.acpi_node.companion = adev;
-	info.irq = -1;
-
-	INIT_LIST_HEAD(&resource_list);
-	ret = acpi_dev_get_resources(adev, &resource_list,
-				     acpi_i2c_add_resource, &info);
-	acpi_dev_free_resource_list(&resource_list);
-
-	if (ret < 0 || !info.addr)
-		return AE_OK;
-
-	adev->power.flags.ignore_parent = true;
-	strlcpy(info.type, dev_name(&adev->dev), sizeof(info.type));
-	if (!i2c_new_device(adapter, &info)) {
-		adev->power.flags.ignore_parent = false;
-		dev_err(&adapter->dev,
-			"failed to add I2C device %s from ACPI\n",
-			dev_name(&adev->dev));
-	}
-
-	return AE_OK;
-}
-
-/**
- * acpi_i2c_register_devices - enumerate I2C slave devices behind adapter
- * @adap: pointer to adapter
- *
- * Enumerate all I2C slave devices behind this adapter by walking the ACPI
- * namespace. When a device is found it will be added to the Linux device
- * model and bound to the corresponding ACPI handle.
- */
-static void acpi_i2c_register_devices(struct i2c_adapter *adap)
-{
-	acpi_handle handle;
-	acpi_status status;
-
-	if (!adap->dev.parent)
-		return;
-
-	handle = ACPI_HANDLE(adap->dev.parent);
-	if (!handle)
-		return;
-
-	status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 1,
-				     acpi_i2c_add_device, NULL,
-				     adap, NULL);
-	if (ACPI_FAILURE(status))
-		dev_warn(&adap->dev, "failed to enumerate I2C slaves\n");
-}
-#else
-static inline void acpi_i2c_register_devices(struct i2c_adapter *adap) {}
-#endif /* CONFIG_ACPI */
-
 static int i2c_do_add_adapter(struct i2c_driver *driver,
 			      struct i2c_adapter *adap)
 {
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index f7a939a..ea50766 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -577,10 +577,12 @@ static inline struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node
 }
 #endif /* CONFIG_OF */
 
-#ifdef CONFIG_ACPI
+#ifdef CONFIG_I2C_ACPI
 int acpi_i2c_install_space_handler(struct i2c_adapter *adapter);
 void acpi_i2c_remove_space_handler(struct i2c_adapter *adapter);
+void acpi_i2c_register_devices(struct i2c_adapter *adap);
 #else
+static inline void acpi_i2c_register_devices(struct i2c_adapter *adap) { }
 static inline void acpi_i2c_remove_space_handler(struct i2c_adapter *adapter)
 { }
 static inline int acpi_i2c_install_space_handler(struct i2c_adapter *adapter)
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* Re: [Patch V3 1/5] ACPICA: Export acpi_buffer_to_resource symbol
  2014-05-20 12:59     ` Lan Tianyu
@ 2014-05-20 21:24         ` Rafael J. Wysocki
  -1 siblings, 0 replies; 34+ messages in thread
From: Rafael J. Wysocki @ 2014-05-20 21:24 UTC (permalink / raw)
  To: Lan Tianyu
  Cc: wsa-z923LK4zBo2bacvFa/9K2g,
	mika.westerberg-VuQAYsv1563Yd54FQh9/CA,
	awilliam-H+wXaHxf7aLQT0dZR+AlfA, lenb-DgEjT+Ai2ygdnm+yROfE0A,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-acpi-u79uwXL29TY76Z2rM5mHXA

On Tuesday, May 20, 2014 08:59:20 PM Lan Tianyu wrote:
> The acpi_buffer_to_resource is needed in i2c module
> to convert aml buffer to struct acpi_resource
> 
> Reviewed-by: Mika Westerberg <mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> Signed-off-by: Lan Tianyu <tianyu.lan-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

This isn't necessary on top of current linux-next I believe?  If so,
please do not resend it any more.

> ---
>  drivers/acpi/acpica/rscreate.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/acpi/acpica/rscreate.c b/drivers/acpi/acpica/rscreate.c
> index 75d3690..5828649 100644
> --- a/drivers/acpi/acpica/rscreate.c
> +++ b/drivers/acpi/acpica/rscreate.c
> @@ -112,6 +112,7 @@ acpi_buffer_to_resource(u8 *aml_buffer,
>  
>  	return (status);
>  }
> +ACPI_EXPORT_SYMBOL(acpi_buffer_to_resource);
>  
>  /*******************************************************************************
>   *
> 

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [Patch V3 1/5] ACPICA: Export acpi_buffer_to_resource symbol
@ 2014-05-20 21:24         ` Rafael J. Wysocki
  0 siblings, 0 replies; 34+ messages in thread
From: Rafael J. Wysocki @ 2014-05-20 21:24 UTC (permalink / raw)
  To: Lan Tianyu
  Cc: wsa, mika.westerberg, awilliam, lenb, linux-i2c, linux-kernel,
	linux-acpi

On Tuesday, May 20, 2014 08:59:20 PM Lan Tianyu wrote:
> The acpi_buffer_to_resource is needed in i2c module
> to convert aml buffer to struct acpi_resource
> 
> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>

This isn't necessary on top of current linux-next I believe?  If so,
please do not resend it any more.

> ---
>  drivers/acpi/acpica/rscreate.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/acpi/acpica/rscreate.c b/drivers/acpi/acpica/rscreate.c
> index 75d3690..5828649 100644
> --- a/drivers/acpi/acpica/rscreate.c
> +++ b/drivers/acpi/acpica/rscreate.c
> @@ -112,6 +112,7 @@ acpi_buffer_to_resource(u8 *aml_buffer,
>  
>  	return (status);
>  }
> +ACPI_EXPORT_SYMBOL(acpi_buffer_to_resource);
>  
>  /*******************************************************************************
>   *
> 

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [Patch V3 0/5] I2C ACPI operation region handler
  2014-05-20 12:59 [Patch V3 0/5] I2C ACPI operation region handler Lan Tianyu
@ 2014-05-20 21:25     ` Rafael J. Wysocki
  2014-05-20 12:59 ` [Patch V3 2/5] ACPI: Add acpi_bus_attach_private_data() to facilitate to attach data to ACPI handle Lan Tianyu
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 34+ messages in thread
From: Rafael J. Wysocki @ 2014-05-20 21:25 UTC (permalink / raw)
  To: Lan Tianyu
  Cc: wsa-z923LK4zBo2bacvFa/9K2g,
	mika.westerberg-VuQAYsv1563Yd54FQh9/CA,
	awilliam-H+wXaHxf7aLQT0dZR+AlfA, lenb-DgEjT+Ai2ygdnm+yROfE0A,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-acpi-u79uwXL29TY76Z2rM5mHXA

On Tuesday, May 20, 2014 08:59:19 PM Lan Tianyu wrote:
> ACPI 5.0 spec(5.5.2.4.5) defines GenericSerialBus(i2c, spi, uart) operation
> region. It allows ACPI aml code able to access such kind of devices to
> implement some ACPI standard method.
> 
> On the Asus T100TA, Bios use GenericSerialBus operation region to access
> i2c device to get battery info. So battery function depends on the I2C
> operation region support. Here is the bug link.
> https://bugzilla.kernel.org/show_bug.cgi?id=69011
> 
> Change since V2:
>         Drop patchs of adding I2C smbus quick read/write and word/block
> process call functions because not find machines supporting such protocols
> so far and can't test these functions.
>         Merge patchs of "I2C ACPI related code clear up" and "Add CONFIG_I2C_ACPI
> config"
> 	Patch 2: Add acpi_bus_detach_private_data() function to detach data from
> ACPI handle and replace ACPI_ERROR() with acpi_handle_debug() to avoid some redundant
> error log.  
> 
> Change since V1:
>        Fix some code style issues. Change prefix i2c_acpi to acpi_i2c.
> Move ACPI related code in the i2c core to i2c-acpi.c. Add CONFIG_I2C_ACPI
> and make i2c core built-in when it's set to avoid i2c ACPI operation region
> being removed.
> 
> Lan Tianyu (5):
>   ACPICA: Export acpi_buffer_to_resource symbol

Redundant?

>   ACPI: Add acpi_bus_attach_private_data() to facilitate to attach data
>     to ACPI handle
>   ACPI/Thermal: Use acpi_bus_attach_private_data() to attach private
>     data

I can take the above two regardless of the I2C material below I guess?

>   I2C/ACPI: Add i2c ACPI operation region support
>   I2C/ACPI: Clean up I2C ACPI code and Add CONFIG_I2C_ACPI config
> 
>  drivers/acpi/acpica/rscreate.c |   1 +
>  drivers/acpi/bus.c             |  28 +++-
>  drivers/acpi/thermal.c         |  11 +-
>  drivers/i2c/Kconfig            |  18 +-
>  drivers/i2c/Makefile           |   5 +-
>  drivers/i2c/i2c-acpi.c         | 362 +++++++++++++++++++++++++++++++++++++++++
>  drivers/i2c/i2c-core.c         |  97 +----------
>  include/acpi/acpi_bus.h        |   2 +
>  include/linux/acpi.h           |  11 ++
>  include/linux/i2c.h            |  12 ++
>  10 files changed, 439 insertions(+), 108 deletions(-)
>  create mode 100644 drivers/i2c/i2c-acpi.c
> 
> 

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [Patch V3 0/5] I2C ACPI operation region handler
@ 2014-05-20 21:25     ` Rafael J. Wysocki
  0 siblings, 0 replies; 34+ messages in thread
From: Rafael J. Wysocki @ 2014-05-20 21:25 UTC (permalink / raw)
  To: Lan Tianyu
  Cc: wsa, mika.westerberg, awilliam, lenb, linux-i2c, linux-kernel,
	linux-acpi

On Tuesday, May 20, 2014 08:59:19 PM Lan Tianyu wrote:
> ACPI 5.0 spec(5.5.2.4.5) defines GenericSerialBus(i2c, spi, uart) operation
> region. It allows ACPI aml code able to access such kind of devices to
> implement some ACPI standard method.
> 
> On the Asus T100TA, Bios use GenericSerialBus operation region to access
> i2c device to get battery info. So battery function depends on the I2C
> operation region support. Here is the bug link.
> https://bugzilla.kernel.org/show_bug.cgi?id=69011
> 
> Change since V2:
>         Drop patchs of adding I2C smbus quick read/write and word/block
> process call functions because not find machines supporting such protocols
> so far and can't test these functions.
>         Merge patchs of "I2C ACPI related code clear up" and "Add CONFIG_I2C_ACPI
> config"
> 	Patch 2: Add acpi_bus_detach_private_data() function to detach data from
> ACPI handle and replace ACPI_ERROR() with acpi_handle_debug() to avoid some redundant
> error log.  
> 
> Change since V1:
>        Fix some code style issues. Change prefix i2c_acpi to acpi_i2c.
> Move ACPI related code in the i2c core to i2c-acpi.c. Add CONFIG_I2C_ACPI
> and make i2c core built-in when it's set to avoid i2c ACPI operation region
> being removed.
> 
> Lan Tianyu (5):
>   ACPICA: Export acpi_buffer_to_resource symbol

Redundant?

>   ACPI: Add acpi_bus_attach_private_data() to facilitate to attach data
>     to ACPI handle
>   ACPI/Thermal: Use acpi_bus_attach_private_data() to attach private
>     data

I can take the above two regardless of the I2C material below I guess?

>   I2C/ACPI: Add i2c ACPI operation region support
>   I2C/ACPI: Clean up I2C ACPI code and Add CONFIG_I2C_ACPI config
> 
>  drivers/acpi/acpica/rscreate.c |   1 +
>  drivers/acpi/bus.c             |  28 +++-
>  drivers/acpi/thermal.c         |  11 +-
>  drivers/i2c/Kconfig            |  18 +-
>  drivers/i2c/Makefile           |   5 +-
>  drivers/i2c/i2c-acpi.c         | 362 +++++++++++++++++++++++++++++++++++++++++
>  drivers/i2c/i2c-core.c         |  97 +----------
>  include/acpi/acpi_bus.h        |   2 +
>  include/linux/acpi.h           |  11 ++
>  include/linux/i2c.h            |  12 ++
>  10 files changed, 439 insertions(+), 108 deletions(-)
>  create mode 100644 drivers/i2c/i2c-acpi.c
> 
> 

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [Patch V3 1/5] ACPICA: Export acpi_buffer_to_resource symbol
  2014-05-20 21:24         ` Rafael J. Wysocki
@ 2014-05-21  2:06           ` Lan Tianyu
  -1 siblings, 0 replies; 34+ messages in thread
From: Lan Tianyu @ 2014-05-21  2:06 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: wsa, mika.westerberg, awilliam, lenb, linux-i2c, linux-kernel,
	linux-acpi

On 2014年05月21日 05:24, Rafael J. Wysocki wrote:
> On Tuesday, May 20, 2014 08:59:20 PM Lan Tianyu wrote:
>> The acpi_buffer_to_resource is needed in i2c module
>> to convert aml buffer to struct acpi_resource
>>
>> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
>> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
> 
> This isn't necessary on top of current linux-next I believe?  If so,
> please do not resend it any more.

Yes, please ignore it and resending it is to facilitate some testers to
the patchset. Ok. I will not resend it.

> 
>> ---
>>  drivers/acpi/acpica/rscreate.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/acpi/acpica/rscreate.c b/drivers/acpi/acpica/rscreate.c
>> index 75d3690..5828649 100644
>> --- a/drivers/acpi/acpica/rscreate.c
>> +++ b/drivers/acpi/acpica/rscreate.c
>> @@ -112,6 +112,7 @@ acpi_buffer_to_resource(u8 *aml_buffer,
>>  
>>  	return (status);
>>  }
>> +ACPI_EXPORT_SYMBOL(acpi_buffer_to_resource);
>>  
>>  /*******************************************************************************
>>   *
>>
> 


-- 
Best regards
Tianyu Lan
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [Patch V3 1/5] ACPICA: Export acpi_buffer_to_resource symbol
@ 2014-05-21  2:06           ` Lan Tianyu
  0 siblings, 0 replies; 34+ messages in thread
From: Lan Tianyu @ 2014-05-21  2:06 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: wsa, mika.westerberg, awilliam, lenb, linux-i2c, linux-kernel,
	linux-acpi

On 2014年05月21日 05:24, Rafael J. Wysocki wrote:
> On Tuesday, May 20, 2014 08:59:20 PM Lan Tianyu wrote:
>> The acpi_buffer_to_resource is needed in i2c module
>> to convert aml buffer to struct acpi_resource
>>
>> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
>> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
> 
> This isn't necessary on top of current linux-next I believe?  If so,
> please do not resend it any more.

Yes, please ignore it and resending it is to facilitate some testers to
the patchset. Ok. I will not resend it.

> 
>> ---
>>  drivers/acpi/acpica/rscreate.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/acpi/acpica/rscreate.c b/drivers/acpi/acpica/rscreate.c
>> index 75d3690..5828649 100644
>> --- a/drivers/acpi/acpica/rscreate.c
>> +++ b/drivers/acpi/acpica/rscreate.c
>> @@ -112,6 +112,7 @@ acpi_buffer_to_resource(u8 *aml_buffer,
>>  
>>  	return (status);
>>  }
>> +ACPI_EXPORT_SYMBOL(acpi_buffer_to_resource);
>>  
>>  /*******************************************************************************
>>   *
>>
> 


-- 
Best regards
Tianyu Lan

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [Patch V3 0/5] I2C ACPI operation region handler
  2014-05-20 21:25     ` Rafael J. Wysocki
@ 2014-05-21  2:16       ` Lan Tianyu
  -1 siblings, 0 replies; 34+ messages in thread
From: Lan Tianyu @ 2014-05-21  2:16 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: wsa, mika.westerberg, awilliam, lenb, linux-i2c, linux-kernel,
	linux-acpi

On 2014年05月21日 05:25, Rafael J. Wysocki wrote:
> On Tuesday, May 20, 2014 08:59:19 PM Lan Tianyu wrote:
>> ACPI 5.0 spec(5.5.2.4.5) defines GenericSerialBus(i2c, spi, uart) operation
>> region. It allows ACPI aml code able to access such kind of devices to
>> implement some ACPI standard method.
>>
>> On the Asus T100TA, Bios use GenericSerialBus operation region to access
>> i2c device to get battery info. So battery function depends on the I2C
>> operation region support. Here is the bug link.
>> https://bugzilla.kernel.org/show_bug.cgi?id=69011
>>
>> Change since V2:
>>         Drop patchs of adding I2C smbus quick read/write and word/block
>> process call functions because not find machines supporting such protocols
>> so far and can't test these functions.
>>         Merge patchs of "I2C ACPI related code clear up" and "Add CONFIG_I2C_ACPI
>> config"
>> 	Patch 2: Add acpi_bus_detach_private_data() function to detach data from
>> ACPI handle and replace ACPI_ERROR() with acpi_handle_debug() to avoid some redundant
>> error log.  
>>
>> Change since V1:
>>        Fix some code style issues. Change prefix i2c_acpi to acpi_i2c.
>> Move ACPI related code in the i2c core to i2c-acpi.c. Add CONFIG_I2C_ACPI
>> and make i2c core built-in when it's set to avoid i2c ACPI operation region
>> being removed.
>>
>> Lan Tianyu (5):
>>   ACPICA: Export acpi_buffer_to_resource symbol
> 
> Redundant?

Yes.

> 
>>   ACPI: Add acpi_bus_attach_private_data() to facilitate to attach data
>>     to ACPI handle
>>   ACPI/Thermal: Use acpi_bus_attach_private_data() to attach private
>>     data
> 
> I can take the above two regardless of the I2C material below I guess?

Yes.

> 
>>   I2C/ACPI: Add i2c ACPI operation region support
>>   I2C/ACPI: Clean up I2C ACPI code and Add CONFIG_I2C_ACPI config
>>
>>  drivers/acpi/acpica/rscreate.c |   1 +
>>  drivers/acpi/bus.c             |  28 +++-
>>  drivers/acpi/thermal.c         |  11 +-
>>  drivers/i2c/Kconfig            |  18 +-
>>  drivers/i2c/Makefile           |   5 +-
>>  drivers/i2c/i2c-acpi.c         | 362 +++++++++++++++++++++++++++++++++++++++++
>>  drivers/i2c/i2c-core.c         |  97 +----------
>>  include/acpi/acpi_bus.h        |   2 +
>>  include/linux/acpi.h           |  11 ++
>>  include/linux/i2c.h            |  12 ++
>>  10 files changed, 439 insertions(+), 108 deletions(-)
>>  create mode 100644 drivers/i2c/i2c-acpi.c
>>
>>
> 


-- 
Best regards
Tianyu Lan
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [Patch V3 0/5] I2C ACPI operation region handler
@ 2014-05-21  2:16       ` Lan Tianyu
  0 siblings, 0 replies; 34+ messages in thread
From: Lan Tianyu @ 2014-05-21  2:16 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: wsa, mika.westerberg, awilliam, lenb, linux-i2c, linux-kernel,
	linux-acpi

On 2014年05月21日 05:25, Rafael J. Wysocki wrote:
> On Tuesday, May 20, 2014 08:59:19 PM Lan Tianyu wrote:
>> ACPI 5.0 spec(5.5.2.4.5) defines GenericSerialBus(i2c, spi, uart) operation
>> region. It allows ACPI aml code able to access such kind of devices to
>> implement some ACPI standard method.
>>
>> On the Asus T100TA, Bios use GenericSerialBus operation region to access
>> i2c device to get battery info. So battery function depends on the I2C
>> operation region support. Here is the bug link.
>> https://bugzilla.kernel.org/show_bug.cgi?id=69011
>>
>> Change since V2:
>>         Drop patchs of adding I2C smbus quick read/write and word/block
>> process call functions because not find machines supporting such protocols
>> so far and can't test these functions.
>>         Merge patchs of "I2C ACPI related code clear up" and "Add CONFIG_I2C_ACPI
>> config"
>> 	Patch 2: Add acpi_bus_detach_private_data() function to detach data from
>> ACPI handle and replace ACPI_ERROR() with acpi_handle_debug() to avoid some redundant
>> error log.  
>>
>> Change since V1:
>>        Fix some code style issues. Change prefix i2c_acpi to acpi_i2c.
>> Move ACPI related code in the i2c core to i2c-acpi.c. Add CONFIG_I2C_ACPI
>> and make i2c core built-in when it's set to avoid i2c ACPI operation region
>> being removed.
>>
>> Lan Tianyu (5):
>>   ACPICA: Export acpi_buffer_to_resource symbol
> 
> Redundant?

Yes.

> 
>>   ACPI: Add acpi_bus_attach_private_data() to facilitate to attach data
>>     to ACPI handle
>>   ACPI/Thermal: Use acpi_bus_attach_private_data() to attach private
>>     data
> 
> I can take the above two regardless of the I2C material below I guess?

Yes.

> 
>>   I2C/ACPI: Add i2c ACPI operation region support
>>   I2C/ACPI: Clean up I2C ACPI code and Add CONFIG_I2C_ACPI config
>>
>>  drivers/acpi/acpica/rscreate.c |   1 +
>>  drivers/acpi/bus.c             |  28 +++-
>>  drivers/acpi/thermal.c         |  11 +-
>>  drivers/i2c/Kconfig            |  18 +-
>>  drivers/i2c/Makefile           |   5 +-
>>  drivers/i2c/i2c-acpi.c         | 362 +++++++++++++++++++++++++++++++++++++++++
>>  drivers/i2c/i2c-core.c         |  97 +----------
>>  include/acpi/acpi_bus.h        |   2 +
>>  include/linux/acpi.h           |  11 ++
>>  include/linux/i2c.h            |  12 ++
>>  10 files changed, 439 insertions(+), 108 deletions(-)
>>  create mode 100644 drivers/i2c/i2c-acpi.c
>>
>>
> 


-- 
Best regards
Tianyu Lan

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [Patch V3 0/5] I2C ACPI operation region handler
  2014-05-20 12:59 [Patch V3 0/5] I2C ACPI operation region handler Lan Tianyu
@ 2014-05-30  6:00     ` Lan Tianyu
  2014-05-20 12:59 ` [Patch V3 2/5] ACPI: Add acpi_bus_attach_private_data() to facilitate to attach data to ACPI handle Lan Tianyu
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 34+ messages in thread
From: Lan Tianyu @ 2014-05-30  6:00 UTC (permalink / raw)
  To: wsa-z923LK4zBo2bacvFa/9K2g, rjw-LthD3rsA81gm4RdzfppkhA,
	mika.westerberg-VuQAYsv1563Yd54FQh9/CA,
	awilliam-H+wXaHxf7aLQT0dZR+AlfA, lenb-DgEjT+Ai2ygdnm+yROfE0A
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-acpi-u79uwXL29TY76Z2rM5mHXA

On 05/20/2014 08:59 PM, Lan Tianyu wrote:
> ACPI 5.0 spec(5.5.2.4.5) defines GenericSerialBus(i2c, spi, uart) operation
> region. It allows ACPI aml code able to access such kind of devices to
> implement some ACPI standard method.
>
> On the Asus T100TA, Bios use GenericSerialBus operation region to access
> i2c device to get battery info. So battery function depends on the I2C
> operation region support. Here is the bug link.
> https://bugzilla.kernel.org/show_bug.cgi?id=69011
>

Hi Wolfram:
	Since this version resolved all comments, it's ok for you?

> Change since V2:
>          Drop patchs of adding I2C smbus quick read/write and word/block
> process call functions because not find machines supporting such protocols
> so far and can't test these functions.
>          Merge patchs of "I2C ACPI related code clear up" and "Add CONFIG_I2C_ACPI
> config"
> 	Patch 2: Add acpi_bus_detach_private_data() function to detach data from
> ACPI handle and replace ACPI_ERROR() with acpi_handle_debug() to avoid some redundant
> error log.
>
> Change since V1:
>         Fix some code style issues. Change prefix i2c_acpi to acpi_i2c.
> Move ACPI related code in the i2c core to i2c-acpi.c. Add CONFIG_I2C_ACPI
> and make i2c core built-in when it's set to avoid i2c ACPI operation region
> being removed.
>
> Lan Tianyu (5):
>    ACPICA: Export acpi_buffer_to_resource symbol
>    ACPI: Add acpi_bus_attach_private_data() to facilitate to attach data
>      to ACPI handle
>    ACPI/Thermal: Use acpi_bus_attach_private_data() to attach private
>      data
>    I2C/ACPI: Add i2c ACPI operation region support
>    I2C/ACPI: Clean up I2C ACPI code and Add CONFIG_I2C_ACPI config
>
>   drivers/acpi/acpica/rscreate.c |   1 +
>   drivers/acpi/bus.c             |  28 +++-
>   drivers/acpi/thermal.c         |  11 +-
>   drivers/i2c/Kconfig            |  18 +-
>   drivers/i2c/Makefile           |   5 +-
>   drivers/i2c/i2c-acpi.c         | 362 +++++++++++++++++++++++++++++++++++++++++
>   drivers/i2c/i2c-core.c         |  97 +----------
>   include/acpi/acpi_bus.h        |   2 +
>   include/linux/acpi.h           |  11 ++
>   include/linux/i2c.h            |  12 ++
>   10 files changed, 439 insertions(+), 108 deletions(-)
>   create mode 100644 drivers/i2c/i2c-acpi.c
>

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [Patch V3 0/5] I2C ACPI operation region handler
@ 2014-05-30  6:00     ` Lan Tianyu
  0 siblings, 0 replies; 34+ messages in thread
From: Lan Tianyu @ 2014-05-30  6:00 UTC (permalink / raw)
  To: wsa, rjw, mika.westerberg, awilliam, lenb
  Cc: linux-i2c, linux-kernel, linux-acpi

On 05/20/2014 08:59 PM, Lan Tianyu wrote:
> ACPI 5.0 spec(5.5.2.4.5) defines GenericSerialBus(i2c, spi, uart) operation
> region. It allows ACPI aml code able to access such kind of devices to
> implement some ACPI standard method.
>
> On the Asus T100TA, Bios use GenericSerialBus operation region to access
> i2c device to get battery info. So battery function depends on the I2C
> operation region support. Here is the bug link.
> https://bugzilla.kernel.org/show_bug.cgi?id=69011
>

Hi Wolfram:
	Since this version resolved all comments, it's ok for you?

> Change since V2:
>          Drop patchs of adding I2C smbus quick read/write and word/block
> process call functions because not find machines supporting such protocols
> so far and can't test these functions.
>          Merge patchs of "I2C ACPI related code clear up" and "Add CONFIG_I2C_ACPI
> config"
> 	Patch 2: Add acpi_bus_detach_private_data() function to detach data from
> ACPI handle and replace ACPI_ERROR() with acpi_handle_debug() to avoid some redundant
> error log.
>
> Change since V1:
>         Fix some code style issues. Change prefix i2c_acpi to acpi_i2c.
> Move ACPI related code in the i2c core to i2c-acpi.c. Add CONFIG_I2C_ACPI
> and make i2c core built-in when it's set to avoid i2c ACPI operation region
> being removed.
>
> Lan Tianyu (5):
>    ACPICA: Export acpi_buffer_to_resource symbol
>    ACPI: Add acpi_bus_attach_private_data() to facilitate to attach data
>      to ACPI handle
>    ACPI/Thermal: Use acpi_bus_attach_private_data() to attach private
>      data
>    I2C/ACPI: Add i2c ACPI operation region support
>    I2C/ACPI: Clean up I2C ACPI code and Add CONFIG_I2C_ACPI config
>
>   drivers/acpi/acpica/rscreate.c |   1 +
>   drivers/acpi/bus.c             |  28 +++-
>   drivers/acpi/thermal.c         |  11 +-
>   drivers/i2c/Kconfig            |  18 +-
>   drivers/i2c/Makefile           |   5 +-
>   drivers/i2c/i2c-acpi.c         | 362 +++++++++++++++++++++++++++++++++++++++++
>   drivers/i2c/i2c-core.c         |  97 +----------
>   include/acpi/acpi_bus.h        |   2 +
>   include/linux/acpi.h           |  11 ++
>   include/linux/i2c.h            |  12 ++
>   10 files changed, 439 insertions(+), 108 deletions(-)
>   create mode 100644 drivers/i2c/i2c-acpi.c
>


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [Patch V3 0/5] I2C ACPI operation region handler
  2014-05-30 12:24     ` Rafael J. Wysocki
@ 2014-05-30 12:10           ` Wolfram Sang
  0 siblings, 0 replies; 34+ messages in thread
From: Wolfram Sang @ 2014-05-30 12:10 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Lan Tianyu, mika.westerberg-VuQAYsv1563Yd54FQh9/CA,
	awilliam-H+wXaHxf7aLQT0dZR+AlfA, lenb-DgEjT+Ai2ygdnm+yROfE0A,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-acpi-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 185 bytes --]

> > Hi Wolfram:
> > 	Since this version resolved all comments, it's ok for you?

Sorry, I misunderstood. I thought a V4 was needed, but it isn't. I'll
try to have a look this weekend.


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [Patch V3 0/5] I2C ACPI operation region handler
@ 2014-05-30 12:10           ` Wolfram Sang
  0 siblings, 0 replies; 34+ messages in thread
From: Wolfram Sang @ 2014-05-30 12:10 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Lan Tianyu, mika.westerberg, awilliam, lenb, linux-i2c,
	linux-kernel, linux-acpi

[-- Attachment #1: Type: text/plain, Size: 185 bytes --]

> > Hi Wolfram:
> > 	Since this version resolved all comments, it's ok for you?

Sorry, I misunderstood. I thought a V4 was needed, but it isn't. I'll
try to have a look this weekend.


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [Patch V3 0/5] I2C ACPI operation region handler
  2014-05-30  6:00     ` Lan Tianyu
  (?)
@ 2014-05-30 12:24     ` Rafael J. Wysocki
       [not found]       ` <10091506.iBigojlNVE-sKB8Sp2ER+y1GS7QM15AGw@public.gmane.org>
  -1 siblings, 1 reply; 34+ messages in thread
From: Rafael J. Wysocki @ 2014-05-30 12:24 UTC (permalink / raw)
  To: Lan Tianyu
  Cc: wsa, mika.westerberg, awilliam, lenb, linux-i2c, linux-kernel,
	linux-acpi

On Friday, May 30, 2014 02:00:39 PM Lan Tianyu wrote:
> On 05/20/2014 08:59 PM, Lan Tianyu wrote:
> > ACPI 5.0 spec(5.5.2.4.5) defines GenericSerialBus(i2c, spi, uart) operation
> > region. It allows ACPI aml code able to access such kind of devices to
> > implement some ACPI standard method.
> >
> > On the Asus T100TA, Bios use GenericSerialBus operation region to access
> > i2c device to get battery info. So battery function depends on the I2C
> > operation region support. Here is the bug link.
> > https://bugzilla.kernel.org/show_bug.cgi?id=69011
> >
> 
> Hi Wolfram:
> 	Since this version resolved all comments, it's ok for you?

BTW, patches [2-3/5] are already queued up for 3.16 as they are independent of
the i2c changes.

> 
> > Change since V2:
> >          Drop patchs of adding I2C smbus quick read/write and word/block
> > process call functions because not find machines supporting such protocols
> > so far and can't test these functions.
> >          Merge patchs of "I2C ACPI related code clear up" and "Add CONFIG_I2C_ACPI
> > config"
> > 	Patch 2: Add acpi_bus_detach_private_data() function to detach data from
> > ACPI handle and replace ACPI_ERROR() with acpi_handle_debug() to avoid some redundant
> > error log.
> >
> > Change since V1:
> >         Fix some code style issues. Change prefix i2c_acpi to acpi_i2c.
> > Move ACPI related code in the i2c core to i2c-acpi.c. Add CONFIG_I2C_ACPI
> > and make i2c core built-in when it's set to avoid i2c ACPI operation region
> > being removed.
> >
> > Lan Tianyu (5):
> >    ACPICA: Export acpi_buffer_to_resource symbol
> >    ACPI: Add acpi_bus_attach_private_data() to facilitate to attach data
> >      to ACPI handle
> >    ACPI/Thermal: Use acpi_bus_attach_private_data() to attach private
> >      data
> >    I2C/ACPI: Add i2c ACPI operation region support
> >    I2C/ACPI: Clean up I2C ACPI code and Add CONFIG_I2C_ACPI config
> >
> >   drivers/acpi/acpica/rscreate.c |   1 +
> >   drivers/acpi/bus.c             |  28 +++-
> >   drivers/acpi/thermal.c         |  11 +-
> >   drivers/i2c/Kconfig            |  18 +-
> >   drivers/i2c/Makefile           |   5 +-
> >   drivers/i2c/i2c-acpi.c         | 362 +++++++++++++++++++++++++++++++++++++++++
> >   drivers/i2c/i2c-core.c         |  97 +----------
> >   include/acpi/acpi_bus.h        |   2 +
> >   include/linux/acpi.h           |  11 ++
> >   include/linux/i2c.h            |  12 ++
> >   10 files changed, 439 insertions(+), 108 deletions(-)
> >   create mode 100644 drivers/i2c/i2c-acpi.c
> >
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [Patch V3 0/5] I2C ACPI operation region handler
  2014-05-30 12:10           ` Wolfram Sang
  (?)
@ 2014-05-30 12:37           ` Lan Tianyu
  2014-06-06 12:28             ` Wolfram Sang
  -1 siblings, 1 reply; 34+ messages in thread
From: Lan Tianyu @ 2014-05-30 12:37 UTC (permalink / raw)
  To: Wolfram Sang, Rafael J. Wysocki
  Cc: mika.westerberg, awilliam, lenb, linux-i2c, linux-kernel, linux-acpi

On 05/30/2014 08:10 PM, Wolfram Sang wrote:
>>> Hi Wolfram:
>>> 	Since this version resolved all comments, it's ok for you?
>
> Sorry, I misunderstood. I thought a V4 was needed, but it isn't. I'll
> try to have a look this weekend.
>
OK. Thanks.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [Patch V3 0/5] I2C ACPI operation region handler
  2014-05-30 12:37           ` Lan Tianyu
@ 2014-06-06 12:28             ` Wolfram Sang
  2014-06-06 22:42                 ` Rafael J. Wysocki
  0 siblings, 1 reply; 34+ messages in thread
From: Wolfram Sang @ 2014-06-06 12:28 UTC (permalink / raw)
  To: Lan Tianyu
  Cc: Rafael J. Wysocki, mika.westerberg, awilliam, lenb, linux-i2c,
	linux-kernel, linux-acpi

[-- Attachment #1: Type: text/plain, Size: 488 bytes --]

On Fri, May 30, 2014 at 08:37:11PM +0800, Lan Tianyu wrote:
> On 05/30/2014 08:10 PM, Wolfram Sang wrote:
> >>>Hi Wolfram:
> >>>	Since this version resolved all comments, it's ok for you?
> >
> >Sorry, I misunderstood. I thought a V4 was needed, but it isn't. I'll
> >try to have a look this weekend.
> >
> OK. Thanks.

Sorry, I didn't manage to get a deeper look into this as I wanted. Let
me assure that your (and the other) ACPI changes have high priority for
the next release cycle.


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [Patch V3 0/5] I2C ACPI operation region handler
  2014-06-06 12:28             ` Wolfram Sang
@ 2014-06-06 22:42                 ` Rafael J. Wysocki
  0 siblings, 0 replies; 34+ messages in thread
From: Rafael J. Wysocki @ 2014-06-06 22:42 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Lan Tianyu, mika.westerberg-VuQAYsv1563Yd54FQh9/CA,
	awilliam-H+wXaHxf7aLQT0dZR+AlfA, lenb-DgEjT+Ai2ygdnm+yROfE0A,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-acpi-u79uwXL29TY76Z2rM5mHXA

On Friday, June 06, 2014 02:28:58 PM Wolfram Sang wrote:
> 
> --azLHFNyN32YCQGCU
> Content-Type: text/plain; charset=us-ascii
> Content-Disposition: inline
> 
> On Fri, May 30, 2014 at 08:37:11PM +0800, Lan Tianyu wrote:
> > On 05/30/2014 08:10 PM, Wolfram Sang wrote:
> > >>>Hi Wolfram:
> > >>>	Since this version resolved all comments, it's ok for you?
> > >
> > >Sorry, I misunderstood. I thought a V4 was needed, but it isn't. I'll
> > >try to have a look this weekend.
> > >
> > OK. Thanks.
> 
> Sorry, I didn't manage to get a deeper look into this as I wanted. Let
> me assure that your (and the other) ACPI changes have high priority for
> the next release cycle.

Well, can you review patches [4-5/5] when you have the time, please?

I'd like to queue them up for 3.17 as soon as possible if you are
OK with them.

Rafael

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [Patch V3 0/5] I2C ACPI operation region handler
@ 2014-06-06 22:42                 ` Rafael J. Wysocki
  0 siblings, 0 replies; 34+ messages in thread
From: Rafael J. Wysocki @ 2014-06-06 22:42 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Lan Tianyu, mika.westerberg, awilliam, lenb, linux-i2c,
	linux-kernel, linux-acpi

On Friday, June 06, 2014 02:28:58 PM Wolfram Sang wrote:
> 
> --azLHFNyN32YCQGCU
> Content-Type: text/plain; charset=us-ascii
> Content-Disposition: inline
> 
> On Fri, May 30, 2014 at 08:37:11PM +0800, Lan Tianyu wrote:
> > On 05/30/2014 08:10 PM, Wolfram Sang wrote:
> > >>>Hi Wolfram:
> > >>>	Since this version resolved all comments, it's ok for you?
> > >
> > >Sorry, I misunderstood. I thought a V4 was needed, but it isn't. I'll
> > >try to have a look this weekend.
> > >
> > OK. Thanks.
> 
> Sorry, I didn't manage to get a deeper look into this as I wanted. Let
> me assure that your (and the other) ACPI changes have high priority for
> the next release cycle.

Well, can you review patches [4-5/5] when you have the time, please?

I'd like to queue them up for 3.17 as soon as possible if you are
OK with them.

Rafael


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [Patch V3 4/5] I2C/ACPI: Add i2c ACPI operation region support
  2014-05-20 12:59 ` [Patch V3 4/5] I2C/ACPI: Add i2c ACPI operation region support Lan Tianyu
@ 2014-06-06 22:48   ` Rafael J. Wysocki
       [not found]     ` <17324514.CZVTFJVpea-sKB8Sp2ER+y1GS7QM15AGw@public.gmane.org>
  2014-06-27 11:03   ` Wolfram Sang
  1 sibling, 1 reply; 34+ messages in thread
From: Rafael J. Wysocki @ 2014-06-06 22:48 UTC (permalink / raw)
  To: Lan Tianyu, mika.westerberg
  Cc: wsa, awilliam, lenb, linux-i2c, linux-kernel, linux-acpi

Hi Mika,

Do I believe correctly that you have reviewed this patch already?

Rafael


On Tuesday, May 20, 2014 08:59:23 PM Lan Tianyu wrote:
> ACPI 5.0 spec(5.5.2.4.5) defines GenericSerialBus(i2c, spi, uart) operation region.
> It allows ACPI aml code able to access such kind of devices to implement
> some ACPI standard method.
> 
> ACPI Spec defines some access attribute to associate with i2c protocol.
> AttribQuick 	       	       		Read/Write Quick Protocol
> AttribSendReceive			Send/Receive Byte Protocol
> AttribByte 			 	Read/Write Byte Protocol
> AttribWord				Read/Write Word Protocol
> AttribBlock				Read/Write Block Protocol
> AttribBytes				Read/Write N-Bytes Protocol
> AttribProcessCall			Process Call Protocol
> AttribBlockProcessCall			Write Block-Read Block Process Call Protocol
> AttribRawBytes 				Raw Read/Write N-BytesProtocol
> AttribRawProcessBytes			Raw Process Call Protocol
> 
> On the Asus T100TA, Bios use GenericSerialBus operation region to access
> i2c device to get battery info.
> 
> Sample code From Asus T100TA
> 
>     Scope (_SB.I2C1)
>     {
>         Name (UMPC, ResourceTemplate ()
>         {
>             I2cSerialBus (0x0066, ControllerInitiated, 0x00061A80,
>                 AddressingMode7Bit, "\\_SB.I2C1",
>                 0x00, ResourceConsumer, ,
>                 )
>         })
> 
> 	...
> 
>         OperationRegion (DVUM, GenericSerialBus, Zero, 0x0100)
>         Field (DVUM, BufferAcc, NoLock, Preserve)
>         {
>             Connection (UMPC),
>             Offset (0x81),
>             AccessAs (BufferAcc, AttribBytes (0x3E)),
>             FGC0,   8
>         }
> 	...
>      }
> 
>      Device (BATC)
>      {
>          Name (_HID, EisaId ("PNP0C0A"))  // _HID: Hardware ID
>          Name (_UID, One)  // _UID: Unique ID
> 	 ...
> 
>             Method (_BST, 0, NotSerialized)  // _BST: Battery Status
>             {
>                 If (LEqual (AVBL, One))
>                 {
>                     Store (FGC0, BFFG)
>                     If (LNotEqual (STAT, One))
>                     {
>                         ShiftRight (CHST, 0x04, Local0)
>                         And (Local0, 0x03, Local0)
>                         If (LOr (LEqual (Local0, One), LEqual (Local0, 0x02)))
>                         {
>                             Store (0x02, Local1)
>                         }
> 	...
> 
>     }
> 
> The i2c operation region is defined under I2C1 scope. _BST method under
> battery device BATC read battery status from the field "FCG0". The request
> would be sent to i2c operation region handler.
> 
> This patch is to add i2c ACPI operation region support. Due to there are
> only "Byte" and "Bytes" protocol access on the Asus T100TA, other protocols
> have not been tested.
> 
> About RawBytes and RawProcessBytes protocol, they needs specific drivers to interpret
> reference data from AML code according ACPI 5.0 SPEC(5.5.2.4.5.3.9 and 5.5.2.4.5.3.10).
> So far, not found such case and will add when find real case.
> 
> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
> ---
>  drivers/i2c/Makefile   |   5 +-
>  drivers/i2c/i2c-acpi.c | 273 +++++++++++++++++++++++++++++++++++++++++++++++++
>  drivers/i2c/i2c-core.c |   2 +
>  include/linux/acpi.h   |  11 ++
>  include/linux/i2c.h    |  10 ++
>  5 files changed, 300 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/i2c/i2c-acpi.c
> 
> diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
> index 1722f50..80db307 100644
> --- a/drivers/i2c/Makefile
> +++ b/drivers/i2c/Makefile
> @@ -2,8 +2,11 @@
>  # Makefile for the i2c core.
>  #
>  
> +i2ccore-y := i2c-core.o
> +i2ccore-$(CONFIG_ACPI)		+= i2c-acpi.o
> +
>  obj-$(CONFIG_I2C_BOARDINFO)	+= i2c-boardinfo.o
> -obj-$(CONFIG_I2C)		+= i2c-core.o
> +obj-$(CONFIG_I2C)		+= i2ccore.o
>  obj-$(CONFIG_I2C_SMBUS)		+= i2c-smbus.o
>  obj-$(CONFIG_I2C_CHARDEV)	+= i2c-dev.o
>  obj-$(CONFIG_I2C_MUX)		+= i2c-mux.o
> diff --git a/drivers/i2c/i2c-acpi.c b/drivers/i2c/i2c-acpi.c
> new file mode 100644
> index 0000000..f7f4c89
> --- /dev/null
> +++ b/drivers/i2c/i2c-acpi.c
> @@ -0,0 +1,273 @@
> +/*
> + * I2C ACPI code
> + *
> + * Copyright (C) 2014 Intel Corp
> + *
> + * Author: Lan Tianyu <tianyu.lan@intel.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful, but
> + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
> + * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
> + * for more details.
> + */
> +#define pr_fmt(fmt) "I2C/ACPI : " fmt
> +
> +#include <linux/kernel.h>
> +#include <linux/errno.h>
> +#include <linux/err.h>
> +#include <linux/i2c.h>
> +#include <linux/acpi.h>
> +
> +struct acpi_i2c_handler_data {
> +	struct acpi_connection_info info;
> +	struct i2c_adapter *adapter;
> +};
> +
> +struct gsb_buffer {
> +	u8	status;
> +	u8	len;
> +	union {
> +		u16	wdata;
> +		u8	bdata;
> +		u8	data[0];
> +	};
> +} __packed;
> +
> +static int acpi_gsb_i2c_read_bytes(struct i2c_client *client,
> +		u8 cmd, u8 *data, u8 data_len)
> +{
> +
> +	struct i2c_msg msgs[2];
> +	int ret;
> +	u8 *buffer;
> +
> +	buffer = kzalloc(data_len, GFP_KERNEL);
> +	if (!buffer)
> +		return AE_NO_MEMORY;
> +
> +	msgs[0].addr = client->addr;
> +	msgs[0].flags = client->flags;
> +	msgs[0].len = 1;
> +	msgs[0].buf = &cmd;
> +
> +	msgs[1].addr = client->addr;
> +	msgs[1].flags = client->flags | I2C_M_RD;
> +	msgs[1].len = data_len;
> +	msgs[1].buf = buffer;
> +
> +	ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
> +	if (ret < 0)
> +		dev_err(&client->adapter->dev, "i2c read failed\n");
> +	else
> +		memcpy(data, buffer, data_len);
> +
> +	kfree(buffer);
> +	return ret;
> +}
> +
> +static int acpi_gsb_i2c_write_bytes(struct i2c_client *client,
> +		u8 cmd, u8 *data, u8 data_len)
> +{
> +
> +	struct i2c_msg msgs[1];
> +	u8 *buffer;
> +	int ret = AE_OK;
> +
> +	buffer = kzalloc(data_len + 1, GFP_KERNEL);
> +	if (!buffer)
> +		return AE_NO_MEMORY;
> +
> +	buffer[0] = cmd;
> +	memcpy(buffer + 1, data, data_len);
> +
> +	msgs[0].addr = client->addr;
> +	msgs[0].flags = client->flags;
> +	msgs[0].len = data_len + 1;
> +	msgs[0].buf = buffer;
> +
> +	ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
> +	if (ret < 0)
> +		dev_err(&client->adapter->dev, "i2c write failed\n");
> +
> +	kfree(buffer);
> +	return ret;
> +}
> +
> +static acpi_status
> +acpi_i2c_space_handler(u32 function, acpi_physical_address command,
> +			u32 bits, u64 *value64,
> +			void *handler_context, void *region_context)
> +{
> +	struct gsb_buffer *gsb = (struct gsb_buffer *)value64;
> +	struct acpi_i2c_handler_data *data = handler_context;
> +	struct acpi_connection_info *info = &data->info;
> +	struct acpi_resource_i2c_serialbus *sb;
> +	struct i2c_adapter *adapter = data->adapter;
> +	struct i2c_client client;
> +	struct acpi_resource *ares;
> +	u32 accessor_type = function >> 16;
> +	u8 action = function & ACPI_IO_MASK;
> +	acpi_status ret = AE_OK;
> +	int status;
> +
> +	ret = acpi_buffer_to_resource(info->connection, info->length, &ares);
> +	if (ACPI_FAILURE(ret))
> +		return ret;
> +
> +	if (!value64 || ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS) {
> +		ret = AE_BAD_PARAMETER;
> +		goto err;
> +	}
> +
> +	sb = &ares->data.i2c_serial_bus;
> +	if (sb->type != ACPI_RESOURCE_SERIAL_TYPE_I2C) {
> +		ret = AE_BAD_PARAMETER;
> +		goto err;
> +	}
> +
> +	memset(&client, 0, sizeof(client));
> +	client.adapter = adapter;
> +	client.addr = sb->slave_address;
> +	client.flags = 0;
> +
> +	if (sb->access_mode == ACPI_I2C_10BIT_MODE)
> +		client.flags |= I2C_CLIENT_TEN;
> +
> +	switch (accessor_type) {
> +	case ACPI_GSB_ACCESS_ATTRIB_SEND_RCV:
> +		if (action == ACPI_READ) {
> +			status = i2c_smbus_read_byte(&client);
> +			if (status >= 0) {
> +				gsb->bdata = status;
> +				status = 0;
> +			}
> +		} else {
> +			status = i2c_smbus_write_byte(&client, gsb->bdata);
> +		}
> +		break;
> +
> +	case ACPI_GSB_ACCESS_ATTRIB_BYTE:
> +		if (action == ACPI_READ) {
> +			status = i2c_smbus_read_byte_data(&client, command);
> +			if (status >= 0) {
> +				gsb->bdata = status;
> +				status = 0;
> +			}
> +		} else {
> +			status = i2c_smbus_write_byte_data(&client, command,
> +					gsb->bdata);
> +		}
> +		break;
> +
> +	case ACPI_GSB_ACCESS_ATTRIB_WORD:
> +		if (action == ACPI_READ) {
> +			status = i2c_smbus_read_word_data(&client, command);
> +			if (status >= 0) {
> +				gsb->wdata = status;
> +				status = 0;
> +			}
> +		} else {
> +			status = i2c_smbus_write_word_data(&client, command,
> +					gsb->wdata);
> +		}
> +		break;
> +
> +	case ACPI_GSB_ACCESS_ATTRIB_BLOCK:
> +		if (action == ACPI_READ) {
> +			status = i2c_smbus_read_block_data(&client, command,
> +					gsb->data);
> +			if (status >= 0) {
> +				gsb->len = status;
> +				status = 0;
> +			}
> +		} else {
> +			status = i2c_smbus_write_block_data(&client, command,
> +					gsb->len, gsb->data);
> +		}
> +		break;
> +
> +	case ACPI_GSB_ACCESS_ATTRIB_MULTIBYTE:
> +		if (action == ACPI_READ) {
> +			status = acpi_gsb_i2c_read_bytes(&client, command,
> +					gsb->data, info->access_length);
> +			if (status > 0)
> +				status = 0;
> +		} else {
> +			status = acpi_gsb_i2c_write_bytes(&client, command,
> +					gsb->data, info->access_length);
> +		}
> +		break;
> +
> +	default:
> +		pr_info("protocol(0x%02x) is not supported.\n", accessor_type);
> +		ret = AE_BAD_PARAMETER;
> +		goto err;
> +	}
> +
> +	gsb->status = status;
> +
> + err:
> +	ACPI_FREE(ares);
> +	return ret;
> +}
> +
> +
> +int acpi_i2c_install_space_handler(struct i2c_adapter *adapter)
> +{
> +	acpi_handle handle = ACPI_HANDLE(adapter->dev.parent);
> +	struct acpi_i2c_handler_data *data;
> +	acpi_status status;
> +
> +	if (!handle)
> +		return -ENODEV;
> +
> +	data = kzalloc(sizeof(struct acpi_i2c_handler_data),
> +			    GFP_KERNEL);
> +	if (!data)
> +		return -ENOMEM;
> +
> +	data->adapter = adapter;
> +	status = acpi_bus_attach_private_data(handle, (void *)data);
> +	if (ACPI_FAILURE(status)) {
> +		kfree(data);
> +		return -ENOMEM;
> +	}
> +
> +	status = acpi_install_address_space_handler(handle,
> +				ACPI_ADR_SPACE_GSBUS,
> +				&acpi_i2c_space_handler,
> +				NULL,
> +				data);
> +	if (ACPI_FAILURE(status)) {
> +		dev_err(&adapter->dev, "Error installing i2c space handler\n");
> +		acpi_bus_detach_private_data(handle);
> +		kfree(data);
> +		return -ENOMEM;
> +	}
> +
> +	return 0;
> +}
> +
> +void acpi_i2c_remove_space_handler(struct i2c_adapter *adapter)
> +{
> +	acpi_handle handle = ACPI_HANDLE(adapter->dev.parent);
> +	struct acpi_i2c_handler_data *data;
> +	acpi_status status;
> +
> +	if (!handle)
> +		return;
> +
> +	acpi_remove_address_space_handler(handle,
> +				ACPI_ADR_SPACE_GSBUS,
> +				&acpi_i2c_space_handler);
> +
> +	status = acpi_bus_get_private_data(handle, (void **)&data);
> +	if (ACPI_SUCCESS(status))
> +		kfree(data);
> +
> +	acpi_bus_detach_private_data(handle);
> +}
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index 7c7f4b8..e25cb84 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -1293,6 +1293,7 @@ exit_recovery:
>  	/* create pre-declared device nodes */
>  	of_i2c_register_devices(adap);
>  	acpi_i2c_register_devices(adap);
> +	acpi_i2c_install_space_handler(adap);
>  
>  	if (adap->nr < __i2c_first_dynamic_bus_num)
>  		i2c_scan_static_board_info(adap);
> @@ -1466,6 +1467,7 @@ void i2c_del_adapter(struct i2c_adapter *adap)
>  		return;
>  	}
>  
> +	acpi_i2c_remove_space_handler(adap);
>  	/* Tell drivers about this removal */
>  	mutex_lock(&core_lock);
>  	bus_for_each_drv(&i2c_bus_type, NULL, adap,
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index 7a8f2cd..ea53b9b 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -361,6 +361,17 @@ extern bool osc_sb_apei_support_acked;
>  #define OSC_PCI_EXPRESS_CAPABILITY_CONTROL	0x00000010
>  #define OSC_PCI_CONTROL_MASKS			0x0000001f
>  
> +#define ACPI_GSB_ACCESS_ATTRIB_QUICK		0x00000002
> +#define ACPI_GSB_ACCESS_ATTRIB_SEND_RCV         0x00000004
> +#define ACPI_GSB_ACCESS_ATTRIB_BYTE		0x00000006
> +#define ACPI_GSB_ACCESS_ATTRIB_WORD		0x00000008
> +#define ACPI_GSB_ACCESS_ATTRIB_BLOCK		0x0000000A
> +#define ACPI_GSB_ACCESS_ATTRIB_MULTIBYTE	0x0000000B
> +#define ACPI_GSB_ACCESS_ATTRIB_WORD_CALL	0x0000000C
> +#define ACPI_GSB_ACCESS_ATTRIB_BLOCK_CALL	0x0000000D
> +#define ACPI_GSB_ACCESS_ATTRIB_RAW_BYTES	0x0000000E
> +#define ACPI_GSB_ACCESS_ATTRIB_RAW_PROCESS	0x0000000F
> +
>  extern acpi_status acpi_pci_osc_control_set(acpi_handle handle,
>  					     u32 *mask, u32 req);
>  
> diff --git a/include/linux/i2c.h b/include/linux/i2c.h
> index b556e0a..f7a939a 100644
> --- a/include/linux/i2c.h
> +++ b/include/linux/i2c.h
> @@ -577,4 +577,14 @@ static inline struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node
>  }
>  #endif /* CONFIG_OF */
>  
> +#ifdef CONFIG_ACPI
> +int acpi_i2c_install_space_handler(struct i2c_adapter *adapter);
> +void acpi_i2c_remove_space_handler(struct i2c_adapter *adapter);
> +#else
> +static inline void acpi_i2c_remove_space_handler(struct i2c_adapter *adapter)
> +{ }
> +static inline int acpi_i2c_install_space_handler(struct i2c_adapter *adapter)
> +{ return 0; }
> +#endif
> +
>  #endif /* _LINUX_I2C_H */
> 

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [Patch V3 4/5] I2C/ACPI: Add i2c ACPI operation region support
  2014-06-06 22:48   ` Rafael J. Wysocki
@ 2014-06-09  7:56         ` Mika Westerberg
  0 siblings, 0 replies; 34+ messages in thread
From: Mika Westerberg @ 2014-06-09  7:56 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Lan Tianyu, wsa-z923LK4zBo2bacvFa/9K2g,
	awilliam-H+wXaHxf7aLQT0dZR+AlfA, lenb-DgEjT+Ai2ygdnm+yROfE0A,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-acpi-u79uwXL29TY76Z2rM5mHXA

On Sat, Jun 07, 2014 at 12:48:13AM +0200, Rafael J. Wysocki wrote:
> Do I believe correctly that you have reviewed this patch already?

Yes, I did :)

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [Patch V3 4/5] I2C/ACPI: Add i2c ACPI operation region support
@ 2014-06-09  7:56         ` Mika Westerberg
  0 siblings, 0 replies; 34+ messages in thread
From: Mika Westerberg @ 2014-06-09  7:56 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Lan Tianyu, wsa, awilliam, lenb, linux-i2c, linux-kernel, linux-acpi

On Sat, Jun 07, 2014 at 12:48:13AM +0200, Rafael J. Wysocki wrote:
> Do I believe correctly that you have reviewed this patch already?

Yes, I did :)

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [Patch V3 0/5] I2C ACPI operation region handler
  2014-05-30 12:10           ` Wolfram Sang
@ 2014-06-24  7:02             ` Lan Tianyu
  -1 siblings, 0 replies; 34+ messages in thread
From: Lan Tianyu @ 2014-06-24  7:02 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Rafael J. Wysocki, mika.westerberg, awilliam, lenb, linux-i2c,
	linux-kernel, linux-acpi

On 2014年05月30日 20:10, Wolfram Sang wrote:
>>> Hi Wolfram:
>>> 	Since this version resolved all comments, it's ok for you?
> 
> Sorry, I misunderstood. I thought a V4 was needed, but it isn't. I'll
> try to have a look this weekend.
> 

Hi Wolfram:
	Sorry to bother you. Could you have a look at patch 4 and patch 5?

-- 
Best regards
Tianyu Lan
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [Patch V3 0/5] I2C ACPI operation region handler
@ 2014-06-24  7:02             ` Lan Tianyu
  0 siblings, 0 replies; 34+ messages in thread
From: Lan Tianyu @ 2014-06-24  7:02 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Rafael J. Wysocki, mika.westerberg, awilliam, lenb, linux-i2c,
	linux-kernel, linux-acpi

On 2014年05月30日 20:10, Wolfram Sang wrote:
>>> Hi Wolfram:
>>> 	Since this version resolved all comments, it's ok for you?
> 
> Sorry, I misunderstood. I thought a V4 was needed, but it isn't. I'll
> try to have a look this weekend.
> 

Hi Wolfram:
	Sorry to bother you. Could you have a look at patch 4 and patch 5?

-- 
Best regards
Tianyu Lan

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [Patch V3 4/5] I2C/ACPI: Add i2c ACPI operation region support
  2014-05-20 12:59 ` [Patch V3 4/5] I2C/ACPI: Add i2c ACPI operation region support Lan Tianyu
  2014-06-06 22:48   ` Rafael J. Wysocki
@ 2014-06-27 11:03   ` Wolfram Sang
  1 sibling, 0 replies; 34+ messages in thread
From: Wolfram Sang @ 2014-06-27 11:03 UTC (permalink / raw)
  To: Lan Tianyu
  Cc: rjw, mika.westerberg, awilliam, lenb, linux-i2c, linux-kernel,
	linux-acpi

[-- Attachment #1: Type: text/plain, Size: 3132 bytes --]

On Tue, May 20, 2014 at 08:59:23PM +0800, Lan Tianyu wrote:
> ACPI 5.0 spec(5.5.2.4.5) defines GenericSerialBus(i2c, spi, uart) operation region.
> It allows ACPI aml code able to access such kind of devices to implement
> some ACPI standard method.
> 
> ACPI Spec defines some access attribute to associate with i2c protocol.
> AttribQuick 	       	       		Read/Write Quick Protocol
> AttribSendReceive			Send/Receive Byte Protocol
> AttribByte 			 	Read/Write Byte Protocol
> AttribWord				Read/Write Word Protocol
> AttribBlock				Read/Write Block Protocol
> AttribBytes				Read/Write N-Bytes Protocol
> AttribProcessCall			Process Call Protocol
> AttribBlockProcessCall			Write Block-Read Block Process Call Protocol
> AttribRawBytes 				Raw Read/Write N-BytesProtocol
> AttribRawProcessBytes			Raw Process Call Protocol
> 
> On the Asus T100TA, Bios use GenericSerialBus operation region to access
> i2c device to get battery info.
> 
> Sample code From Asus T100TA
> 
>     Scope (_SB.I2C1)
>     {
>         Name (UMPC, ResourceTemplate ()
>         {
>             I2cSerialBus (0x0066, ControllerInitiated, 0x00061A80,
>                 AddressingMode7Bit, "\\_SB.I2C1",
>                 0x00, ResourceConsumer, ,
>                 )
>         })
> 
> 	...
> 
>         OperationRegion (DVUM, GenericSerialBus, Zero, 0x0100)
>         Field (DVUM, BufferAcc, NoLock, Preserve)
>         {
>             Connection (UMPC),
>             Offset (0x81),
>             AccessAs (BufferAcc, AttribBytes (0x3E)),
>             FGC0,   8
>         }
> 	...
>      }
> 
>      Device (BATC)
>      {
>          Name (_HID, EisaId ("PNP0C0A"))  // _HID: Hardware ID
>          Name (_UID, One)  // _UID: Unique ID
> 	 ...
> 
>             Method (_BST, 0, NotSerialized)  // _BST: Battery Status
>             {
>                 If (LEqual (AVBL, One))
>                 {
>                     Store (FGC0, BFFG)
>                     If (LNotEqual (STAT, One))
>                     {
>                         ShiftRight (CHST, 0x04, Local0)
>                         And (Local0, 0x03, Local0)
>                         If (LOr (LEqual (Local0, One), LEqual (Local0, 0x02)))
>                         {
>                             Store (0x02, Local1)
>                         }
> 	...
> 
>     }
> 
> The i2c operation region is defined under I2C1 scope. _BST method under
> battery device BATC read battery status from the field "FCG0". The request
> would be sent to i2c operation region handler.
> 
> This patch is to add i2c ACPI operation region support. Due to there are
> only "Byte" and "Bytes" protocol access on the Asus T100TA, other protocols
> have not been tested.
> 
> About RawBytes and RawProcessBytes protocol, they needs specific drivers to interpret
> reference data from AML code according ACPI 5.0 SPEC(5.5.2.4.5.3.9 and 5.5.2.4.5.3.10).
> So far, not found such case and will add when find real case.
> 
> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>

Added Mika's review tag and applied to for-next, thanks!


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [Patch V3 5/5] I2C/ACPI: Clean up I2C ACPI code and Add CONFIG_I2C_ACPI config
  2014-05-20 12:59 ` [Patch V3 5/5] I2C/ACPI: Clean up I2C ACPI code and Add CONFIG_I2C_ACPI config Lan Tianyu
@ 2014-06-27 11:03   ` Wolfram Sang
  2014-06-30  1:32       ` Lan Tianyu
  0 siblings, 1 reply; 34+ messages in thread
From: Wolfram Sang @ 2014-06-27 11:03 UTC (permalink / raw)
  To: Lan Tianyu
  Cc: rjw, mika.westerberg, awilliam, lenb, linux-i2c, linux-kernel,
	linux-acpi

[-- Attachment #1: Type: text/plain, Size: 477 bytes --]

On Tue, May 20, 2014 at 08:59:24PM +0800, Lan Tianyu wrote:
> Clean up ACPI related code in the i2c core and add CONFIG_I2C_ACPI
> to enable I2C ACPI code.
> 
> Current there is a race between removing I2C ACPI operation region
> and ACPI AML code accessing. So make i2c core built-in if CONFIG_I2C_ACPI
> is set.
> 
> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>

Applied to for-next, thanks!


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [Patch V3 5/5] I2C/ACPI: Clean up I2C ACPI code and Add CONFIG_I2C_ACPI config
  2014-06-27 11:03   ` Wolfram Sang
@ 2014-06-30  1:32       ` Lan Tianyu
  0 siblings, 0 replies; 34+ messages in thread
From: Lan Tianyu @ 2014-06-30  1:32 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: rjw-LthD3rsA81gm4RdzfppkhA,
	mika.westerberg-VuQAYsv1563Yd54FQh9/CA,
	awilliam-H+wXaHxf7aLQT0dZR+AlfA, lenb-DgEjT+Ai2ygdnm+yROfE0A,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-acpi-u79uwXL29TY76Z2rM5mHXA

On 2014年06月27日 19:03, Wolfram Sang wrote:
> On Tue, May 20, 2014 at 08:59:24PM +0800, Lan Tianyu wrote:
>> Clean up ACPI related code in the i2c core and add CONFIG_I2C_ACPI
>> to enable I2C ACPI code.
>>
>> Current there is a race between removing I2C ACPI operation region
>> and ACPI AML code accessing. So make i2c core built-in if CONFIG_I2C_ACPI
>> is set.
>>
>> Reviewed-by: Mika Westerberg <mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
>> Signed-off-by: Lan Tianyu <tianyu.lan-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> 
> Applied to for-next, thanks!
> 

Great. Thanks :)


-- 
Best regards
Tianyu Lan

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [Patch V3 5/5] I2C/ACPI: Clean up I2C ACPI code and Add CONFIG_I2C_ACPI config
@ 2014-06-30  1:32       ` Lan Tianyu
  0 siblings, 0 replies; 34+ messages in thread
From: Lan Tianyu @ 2014-06-30  1:32 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: rjw, mika.westerberg, awilliam, lenb, linux-i2c, linux-kernel,
	linux-acpi

On 2014年06月27日 19:03, Wolfram Sang wrote:
> On Tue, May 20, 2014 at 08:59:24PM +0800, Lan Tianyu wrote:
>> Clean up ACPI related code in the i2c core and add CONFIG_I2C_ACPI
>> to enable I2C ACPI code.
>>
>> Current there is a race between removing I2C ACPI operation region
>> and ACPI AML code accessing. So make i2c core built-in if CONFIG_I2C_ACPI
>> is set.
>>
>> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
>> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
> 
> Applied to for-next, thanks!
> 

Great. Thanks :)


-- 
Best regards
Tianyu Lan

^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2014-06-30  1:34 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-20 12:59 [Patch V3 0/5] I2C ACPI operation region handler Lan Tianyu
     [not found] ` <1400590764-11108-1-git-send-email-tianyu.lan-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-05-20 12:59   ` [Patch V3 1/5] ACPICA: Export acpi_buffer_to_resource symbol Lan Tianyu
2014-05-20 12:59     ` Lan Tianyu
     [not found]     ` <1400590764-11108-2-git-send-email-tianyu.lan-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-05-20 21:24       ` Rafael J. Wysocki
2014-05-20 21:24         ` Rafael J. Wysocki
2014-05-21  2:06         ` Lan Tianyu
2014-05-21  2:06           ` Lan Tianyu
2014-05-20 12:59   ` [Patch V3 3/5] ACPI/Thermal: Use acpi_bus_attach_private_data() to attach private data Lan Tianyu
2014-05-20 12:59     ` Lan Tianyu
2014-05-20 21:25   ` [Patch V3 0/5] I2C ACPI operation region handler Rafael J. Wysocki
2014-05-20 21:25     ` Rafael J. Wysocki
2014-05-21  2:16     ` Lan Tianyu
2014-05-21  2:16       ` Lan Tianyu
2014-05-30  6:00   ` Lan Tianyu
2014-05-30  6:00     ` Lan Tianyu
2014-05-30 12:24     ` Rafael J. Wysocki
     [not found]       ` <10091506.iBigojlNVE-sKB8Sp2ER+y1GS7QM15AGw@public.gmane.org>
2014-05-30 12:10         ` Wolfram Sang
2014-05-30 12:10           ` Wolfram Sang
2014-05-30 12:37           ` Lan Tianyu
2014-06-06 12:28             ` Wolfram Sang
2014-06-06 22:42               ` Rafael J. Wysocki
2014-06-06 22:42                 ` Rafael J. Wysocki
2014-06-24  7:02           ` Lan Tianyu
2014-06-24  7:02             ` Lan Tianyu
2014-05-20 12:59 ` [Patch V3 2/5] ACPI: Add acpi_bus_attach_private_data() to facilitate to attach data to ACPI handle Lan Tianyu
2014-05-20 12:59 ` [Patch V3 4/5] I2C/ACPI: Add i2c ACPI operation region support Lan Tianyu
2014-06-06 22:48   ` Rafael J. Wysocki
     [not found]     ` <17324514.CZVTFJVpea-sKB8Sp2ER+y1GS7QM15AGw@public.gmane.org>
2014-06-09  7:56       ` Mika Westerberg
2014-06-09  7:56         ` Mika Westerberg
2014-06-27 11:03   ` Wolfram Sang
2014-05-20 12:59 ` [Patch V3 5/5] I2C/ACPI: Clean up I2C ACPI code and Add CONFIG_I2C_ACPI config Lan Tianyu
2014-06-27 11:03   ` Wolfram Sang
2014-06-30  1:32     ` Lan Tianyu
2014-06-30  1:32       ` Lan Tianyu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.