linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c: slave framework support for SMBus Alert
@ 2016-08-10  0:02 Brendan Higgins
  2016-08-10  0:02 ` Brendan Higgins
  2016-08-10  8:26 ` Wolfram Sang
  0 siblings, 2 replies; 3+ messages in thread
From: Brendan Higgins @ 2016-08-10  0:02 UTC (permalink / raw)
  To: linux-i2c

This adds support for an SMBus Alert to be requested from a slave mode Linux
I2C driver.

It appears that there is an attempt to keep master mode SMBus framework code
separate from raw I2C framework code, but that only appears to apply to master
mode I2C code. This seemed to make the most sense as part of i2c_algorithm.

This will not affect any existing drivers.

This has been tested with a slave mode driver I am currently working which I
can provide upon request (I am planning on submitting the driver as well, but
it part of a larger upstream submission).

My apologies in advance for any mistakes I might have made in the submission
process (I am new to the kernel mailing list).

Thanks!

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

* [PATCH] i2c: slave framework support for SMBus Alert
  2016-08-10  0:02 [PATCH] i2c: slave framework support for SMBus Alert Brendan Higgins
@ 2016-08-10  0:02 ` Brendan Higgins
  2016-08-10  8:26 ` Wolfram Sang
  1 sibling, 0 replies; 3+ messages in thread
From: Brendan Higgins @ 2016-08-10  0:02 UTC (permalink / raw)
  To: linux-i2c; +Cc: Brendan Higgins

Currently, only handling SMBus alerts as a SMBus master is supported.
This adds support for the generation of SMBus Alerts as a slave.

Signed-off-by: Brendan Higgins <brendanhiggins@google.com>
---
 drivers/i2c/i2c-core.c | 22 ++++++++++++++++++++++
 include/linux/i2c.h    |  5 +++++
 2 files changed, 27 insertions(+)

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index e584d88..9d49cee 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -3252,6 +3252,28 @@ int i2c_slave_unregister(struct i2c_client *client)
 	return ret;
 }
 EXPORT_SYMBOL_GPL(i2c_slave_unregister);
+
+int i2c_slave_smbus_alert(struct i2c_client *client)
+{
+	int ret;
+
+	if (!client->adapter->algo->smbus_alert_slave) {
+		dev_err(&client->dev, "%s: not supported by adapter\n",
+			__func__);
+		return -EOPNOTSUPP;
+	}
+
+	i2c_lock_adapter(client->adapter);
+	ret = client->adapter->algo->smbus_alert_slave(client);
+	i2c_unlock_adapter(client->adapter);
+
+	if (ret != 0)
+		dev_err(&client->dev, "%s: adapter returned error %d\n",
+			__func__, ret);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(i2c_slave_smbus_alert);
 #endif
 
 MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>");
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 200cf13b..43b98f5 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -271,6 +271,8 @@ static inline int i2c_slave_event(struct i2c_client *client,
 {
 	return client->slave_cb(client, event, val);
 }
+
+extern int i2c_slave_smbus_alert(struct i2c_client *client);
 #endif
 
 /**
@@ -381,6 +383,8 @@ i2c_register_board_info(int busnum, struct i2c_board_info const *info,
  *   from the I2C_FUNC_* flags.
  * @reg_slave: Register given client to I2C slave mode of this adapter
  * @unreg_slave: Unregister given client from I2C slave mode of this adapter
+ * @smbus_alert_slave: Create an smbus alert from the I2C slave mode of this
+ *   adapter
  *
  * The following structs are for those who like to implement new bus drivers:
  * i2c_algorithm is the interface to a class of hardware solutions which can
@@ -410,6 +414,7 @@ struct i2c_algorithm {
 #if IS_ENABLED(CONFIG_I2C_SLAVE)
 	int (*reg_slave)(struct i2c_client *client);
 	int (*unreg_slave)(struct i2c_client *client);
+	int (*smbus_alert_slave)(struct i2c_client *client);
 #endif
 };
 
-- 
2.8.0.rc3.226.g39d4020

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

* Re: [PATCH] i2c: slave framework support for SMBus Alert
  2016-08-10  0:02 [PATCH] i2c: slave framework support for SMBus Alert Brendan Higgins
  2016-08-10  0:02 ` Brendan Higgins
@ 2016-08-10  8:26 ` Wolfram Sang
  1 sibling, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2016-08-10  8:26 UTC (permalink / raw)
  To: Brendan Higgins; +Cc: linux-i2c

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


> This has been tested with a slave mode driver I am currently working which I
> can provide upon request (I am planning on submitting the driver as well, but
> it part of a larger upstream submission).

Thanks for the patch.

When adding features to the core, I need a user for this feature
upstream. So, I noticed what you need, yet the patch needs to be resend
together with the i2c slave driver for a full review.

Regards,

   Wolfram


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

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

end of thread, other threads:[~2016-08-10 18:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-10  0:02 [PATCH] i2c: slave framework support for SMBus Alert Brendan Higgins
2016-08-10  0:02 ` Brendan Higgins
2016-08-10  8:26 ` Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).