Lines Matching +full:- +full:alert

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * i2c-smbus.c - SMBus extensions to the I2C protocol
6 * Copyright (C) 2010-2019 Jean Delvare <jdelvare@suse.de>
12 #include <linux/i2c-smbus.h>
21 struct work_struct alert; member
22 struct i2c_client *ara; /* Alert response address */
39 if (!client || client->addr != data->addr) in smbus_do_alert()
41 if (client->flags & I2C_CLIENT_TEN) in smbus_do_alert()
49 if (client->dev.driver) { in smbus_do_alert()
50 driver = to_i2c_driver(client->dev.driver); in smbus_do_alert()
51 if (driver->alert) { in smbus_do_alert()
53 driver->alert(client, data->type, data->data); in smbus_do_alert()
54 ret = -EBUSY; in smbus_do_alert()
56 dev_warn(&client->dev, "no driver alert()!\n"); in smbus_do_alert()
57 ret = -EOPNOTSUPP; in smbus_do_alert()
60 dev_dbg(&client->dev, "alert with no driver\n"); in smbus_do_alert()
61 ret = -ENODEV; in smbus_do_alert()
68 /* Same as above, but call back all drivers with alert handler */
76 if (!client || (client->flags & I2C_CLIENT_TEN)) in smbus_do_alert_force()
84 if (client->dev.driver) { in smbus_do_alert_force()
85 driver = to_i2c_driver(client->dev.driver); in smbus_do_alert_force()
86 if (driver->alert) in smbus_do_alert_force()
87 driver->alert(client, data->type, data->data); in smbus_do_alert_force()
95 * The alert IRQ handler needs to hand work off to a task which can issue
100 struct i2c_smbus_alert *alert = d; in smbus_alert() local
104 ara = alert->ara; in smbus_alert()
115 * Note that SMBus 2.0 reserves 10-bit addresses for future in smbus_alert()
126 dev_dbg(&ara->dev, "SMBALERT# from dev 0x%02x, flag %d\n", in smbus_alert()
129 /* Notify driver for the device which issued the alert */ in smbus_alert()
130 status = device_for_each_child(&ara->adapter->dev, &data, in smbus_alert()
133 * If we read the same address more than once, and the alert in smbus_alert()
136 * time calling the alert handlers of all devices connected to in smbus_alert()
140 * Note: This assumes that a driver with alert handler handles in smbus_alert()
141 * the alert properly and clears it if necessary. in smbus_alert()
143 if (data.addr == prev_addr && status != -EBUSY) { in smbus_alert()
144 device_for_each_child(&ara->adapter->dev, &data, in smbus_alert()
156 struct i2c_smbus_alert *alert; in smbalert_work() local
158 alert = container_of(work, struct i2c_smbus_alert, alert); in smbalert_work()
160 smbus_alert(0, alert); in smbalert_work()
167 struct i2c_smbus_alert_setup *setup = dev_get_platdata(&ara->dev); in smbalert_probe()
168 struct i2c_smbus_alert *alert; in smbalert_probe() local
169 struct i2c_adapter *adapter = ara->adapter; in smbalert_probe()
172 alert = devm_kzalloc(&ara->dev, sizeof(struct i2c_smbus_alert), in smbalert_probe()
174 if (!alert) in smbalert_probe()
175 return -ENOMEM; in smbalert_probe()
178 irq = setup->irq; in smbalert_probe()
180 irq = fwnode_irq_get_byname(dev_fwnode(adapter->dev.parent), in smbalert_probe()
186 INIT_WORK(&alert->alert, smbalert_work); in smbalert_probe()
187 alert->ara = ara; in smbalert_probe()
190 res = devm_request_threaded_irq(&ara->dev, irq, in smbalert_probe()
193 "smbus_alert", alert); in smbalert_probe()
198 i2c_set_clientdata(ara, alert); in smbalert_probe()
199 dev_info(&adapter->dev, "supports SMBALERT#\n"); in smbalert_probe()
207 struct i2c_smbus_alert *alert = i2c_get_clientdata(ara); in smbalert_remove() local
209 cancel_work_sync(&alert->alert); in smbalert_remove()
228 * i2c_handle_smbus_alert - Handle an SMBus alert
233 * handler. It will schedule the alert work, in turn calling the
234 * corresponding I2C device driver's alert function.
241 struct i2c_smbus_alert *alert = i2c_get_clientdata(ara); in i2c_handle_smbus_alert() local
243 return schedule_work(&alert->alert); in i2c_handle_smbus_alert()
259 struct i2c_slave_host_notify_status *status = client->dev.platform_data; in i2c_slave_host_notify_cb()
267 if (status->index == 0) in i2c_slave_host_notify_cb()
268 status->addr = *val; in i2c_slave_host_notify_cb()
269 if (status->index < U8_MAX) in i2c_slave_host_notify_cb()
270 status->index++; in i2c_slave_host_notify_cb()
273 if (status->index == SMBUS_HOST_NOTIFY_LEN) in i2c_slave_host_notify_cb()
274 i2c_handle_smbus_host_notify(client->adapter, in i2c_slave_host_notify_cb()
275 status->addr); in i2c_slave_host_notify_cb()
278 status->index = 0; in i2c_slave_host_notify_cb()
290 * i2c_new_slave_host_notify_device - get a client for SMBus host-notify support
294 * Setup handling of the SMBus host-notify protocol on a given I2C bus segment.
297 * received via the SMBus host-notify address (0x8)
315 return ERR_PTR(-ENOMEM); in i2c_new_slave_host_notify_device()
337 * i2c_free_slave_host_notify_device - free the client for SMBus host-notify
350 kfree(client->dev.platform_data); in i2c_free_slave_host_notify_device()
360 * - Only works if all filled slots have the same memory type
361 * - Only works for DDR2, DDR3 and DDR4 for now
362 * - Only works on systems with 1 to 4 memory slots
392 dev_warn(&adap->dev, in i2c_register_spd()
404 dev_info(&adap->dev, "%d/%d memory slots populated (from DMI)\n", in i2c_register_spd()
408 dev_warn(&adap->dev, in i2c_register_spd()
431 dev_info(&adap->dev, in i2c_register_spd()
453 dev_info(&adap->dev, in i2c_register_spd()
456 dimm_count--; in i2c_register_spd()