Lines Matching refs:hc
88 static inline int smb_hc_read(struct acpi_smb_hc *hc, u8 address, u8 *data) in smb_hc_read() argument
90 return ec_read(hc->offset + address, data); in smb_hc_read()
93 static inline int smb_hc_write(struct acpi_smb_hc *hc, u8 address, u8 data) in smb_hc_write() argument
95 return ec_write(hc->offset + address, data); in smb_hc_write()
98 static int wait_transaction_complete(struct acpi_smb_hc *hc, int timeout) in wait_transaction_complete() argument
100 if (wait_event_timeout(hc->wait, hc->done, msecs_to_jiffies(timeout))) in wait_transaction_complete()
105 static int acpi_smbus_transaction(struct acpi_smb_hc *hc, u8 protocol, in acpi_smbus_transaction() argument
111 if (!hc) { in acpi_smbus_transaction()
116 mutex_lock(&hc->lock); in acpi_smbus_transaction()
117 hc->done = false; in acpi_smbus_transaction()
118 if (smb_hc_read(hc, ACPI_SMB_PROTOCOL, &temp)) in acpi_smbus_transaction()
124 smb_hc_write(hc, ACPI_SMB_COMMAND, command); in acpi_smbus_transaction()
126 smb_hc_write(hc, ACPI_SMB_BLOCK_COUNT, length); in acpi_smbus_transaction()
128 smb_hc_write(hc, ACPI_SMB_DATA + i, data[i]); in acpi_smbus_transaction()
130 smb_hc_write(hc, ACPI_SMB_ADDRESS, address << 1); in acpi_smbus_transaction()
131 smb_hc_write(hc, ACPI_SMB_PROTOCOL, protocol); in acpi_smbus_transaction()
136 ret = wait_transaction_complete(hc, 1000); in acpi_smbus_transaction()
148 if (smb_hc_read(hc, ACPI_SMB_BLOCK_COUNT, &sz)) { in acpi_smbus_transaction()
156 smb_hc_read(hc, ACPI_SMB_DATA + i, &data[i]); in acpi_smbus_transaction()
158 mutex_unlock(&hc->lock); in acpi_smbus_transaction()
162 int acpi_smbus_read(struct acpi_smb_hc *hc, u8 protocol, u8 address, in acpi_smbus_read() argument
165 return acpi_smbus_transaction(hc, protocol, address, command, data, 0); in acpi_smbus_read()
170 int acpi_smbus_write(struct acpi_smb_hc *hc, u8 protocol, u8 address, in acpi_smbus_write() argument
173 return acpi_smbus_transaction(hc, protocol, address, command, data, length); in acpi_smbus_write()
178 int acpi_smbus_register_callback(struct acpi_smb_hc *hc, in acpi_smbus_register_callback() argument
181 mutex_lock(&hc->lock); in acpi_smbus_register_callback()
182 hc->callback = callback; in acpi_smbus_register_callback()
183 hc->context = context; in acpi_smbus_register_callback()
184 mutex_unlock(&hc->lock); in acpi_smbus_register_callback()
190 int acpi_smbus_unregister_callback(struct acpi_smb_hc *hc) in acpi_smbus_unregister_callback() argument
192 mutex_lock(&hc->lock); in acpi_smbus_unregister_callback()
193 hc->callback = NULL; in acpi_smbus_unregister_callback()
194 hc->context = NULL; in acpi_smbus_unregister_callback()
195 mutex_unlock(&hc->lock); in acpi_smbus_unregister_callback()
204 struct acpi_smb_hc *hc = context; in acpi_smbus_callback() local
205 if (hc->callback) in acpi_smbus_callback()
206 hc->callback(hc->context); in acpi_smbus_callback()
211 struct acpi_smb_hc *hc = context; in smbus_alarm() local
214 if (smb_hc_read(hc, ACPI_SMB_STATUS, &status.raw)) in smbus_alarm()
218 hc->done = true; in smbus_alarm()
219 wake_up(&hc->wait); in smbus_alarm()
223 mutex_lock(&hc->lock); in smbus_alarm()
224 smb_hc_read(hc, ACPI_SMB_ALARM_ADDRESS, &address); in smbus_alarm()
226 smb_hc_write(hc, ACPI_SMB_STATUS, status.raw); in smbus_alarm()
233 acpi_smbus_callback, hc); in smbus_alarm()
235 mutex_unlock(&hc->lock); in smbus_alarm()
249 struct acpi_smb_hc *hc; in acpi_smbus_hc_add() local
263 hc = kzalloc(sizeof(struct acpi_smb_hc), GFP_KERNEL); in acpi_smbus_hc_add()
264 if (!hc) in acpi_smbus_hc_add()
266 mutex_init(&hc->lock); in acpi_smbus_hc_add()
267 init_waitqueue_head(&hc->wait); in acpi_smbus_hc_add()
269 hc->ec = acpi_driver_data(acpi_dev_parent(device)); in acpi_smbus_hc_add()
270 hc->offset = (val >> 8) & 0xff; in acpi_smbus_hc_add()
271 hc->query_bit = val & 0xff; in acpi_smbus_hc_add()
272 device->driver_data = hc; in acpi_smbus_hc_add()
274 acpi_ec_add_query_handler(hc->ec, hc->query_bit, NULL, smbus_alarm, hc); in acpi_smbus_hc_add()
276 hc->offset, hc->query_bit); in acpi_smbus_hc_add()
285 struct acpi_smb_hc *hc; in acpi_smbus_hc_remove() local
290 hc = acpi_driver_data(device); in acpi_smbus_hc_remove()
291 acpi_ec_remove_query_handler(hc->ec, hc->query_bit); in acpi_smbus_hc_remove()
293 kfree(hc); in acpi_smbus_hc_remove()