Lines Matching +full:aspire1 +full:- +full:ec
1 // SPDX-License-Identifier: GPL-2.0-only
94 struct aspire_ec *ec = data; in aspire_ec_irq_handler() local
108 id = i2c_smbus_read_byte_data(ec->client, ASPIRE_EC_EVENT); in aspire_ec_irq_handler()
110 dev_err(&ec->client->dev, "Failed to read event id: %pe\n", ERR_PTR(id)); in aspire_ec_irq_handler()
124 aspire_ec_ram_read(ec->client, ASPIRE_EC_RAM_WATCHDOG, &tmp, sizeof(tmp)); in aspire_ec_irq_handler()
126 aspire_ec_ram_write(ec->client, ASPIRE_EC_RAM_WATCHDOG, tmp); in aspire_ec_irq_handler()
131 input_report_switch(ec->idev, SW_LID, 1); in aspire_ec_irq_handler()
132 input_sync(ec->idev); in aspire_ec_irq_handler()
137 input_report_switch(ec->idev, SW_LID, 0); in aspire_ec_irq_handler()
138 input_sync(ec->idev); in aspire_ec_irq_handler()
146 power_supply_changed(ec->bat_psy); in aspire_ec_irq_handler()
147 power_supply_changed(ec->adp_psy); in aspire_ec_irq_handler()
151 if (ec->bridge_configured) in aspire_ec_irq_handler()
152 drm_bridge_hpd_notify(&ec->bridge, connector_status_disconnected); in aspire_ec_irq_handler()
156 if (ec->bridge_configured) in aspire_ec_irq_handler()
157 drm_bridge_hpd_notify(&ec->bridge, connector_status_connected); in aspire_ec_irq_handler()
176 dev_warn(&ec->client->dev, "Unknown event id=0x%x\n", id); in aspire_ec_irq_handler()
234 struct aspire_ec *ec = power_supply_get_drvdata(psy); in aspire_ec_bat_psy_get_property() local
239 i2c_smbus_read_i2c_block_data(ec->client, ASPIRE_EC_FG_STATIC, sizeof(sdat), (u8 *)&sdat); in aspire_ec_bat_psy_get_property()
240 i2c_smbus_read_i2c_block_data(ec->client, ASPIRE_EC_FG_DYNAMIC, sizeof(ddat), (u8 *)&ddat); in aspire_ec_bat_psy_get_property()
244 val->intval = POWER_SUPPLY_STATUS_UNKNOWN; in aspire_ec_bat_psy_get_property()
246 val->intval = POWER_SUPPLY_STATUS_CHARGING; in aspire_ec_bat_psy_get_property()
248 val->intval = POWER_SUPPLY_STATUS_DISCHARGING; in aspire_ec_bat_psy_get_property()
250 val->intval = POWER_SUPPLY_STATUS_FULL; in aspire_ec_bat_psy_get_property()
254 val->intval = get_unaligned_le16(&ddat.voltage_now) * MILLI_TO_MICRO; in aspire_ec_bat_psy_get_property()
258 val->intval = le16_to_cpu(sdat.voltage_design) * MILLI_TO_MICRO; in aspire_ec_bat_psy_get_property()
262 val->intval = get_unaligned_le16(&ddat.capacity_now) * MILLI_TO_MICRO; in aspire_ec_bat_psy_get_property()
266 val->intval = le16_to_cpu(sdat.capacity_full) * MILLI_TO_MICRO; in aspire_ec_bat_psy_get_property()
270 val->intval = get_unaligned_le16(&ddat.capacity_now) * 100; in aspire_ec_bat_psy_get_property()
271 val->intval /= le16_to_cpu(sdat.capacity_full); in aspire_ec_bat_psy_get_property()
275 val->intval = (s16)get_unaligned_le16(&ddat.current_now) * MILLI_TO_MICRO; in aspire_ec_bat_psy_get_property()
279 val->intval = !!(ddat.flags & ASPIRE_EC_FG_FLAG_PRESENT); in aspire_ec_bat_psy_get_property()
283 val->intval = POWER_SUPPLY_SCOPE_SYSTEM; in aspire_ec_bat_psy_get_property()
287 str_index = sdat.model_id - 1; in aspire_ec_bat_psy_get_property()
290 val->strval = aspire_ec_bat_psy_battery_model[str_index]; in aspire_ec_bat_psy_get_property()
292 val->strval = "Unknown"; in aspire_ec_bat_psy_get_property()
296 str_index = sdat.vendor_id - 3; /* ACPI uses 3 as an offset here. */ in aspire_ec_bat_psy_get_property()
299 val->strval = aspire_ec_bat_psy_battery_vendor[str_index]; in aspire_ec_bat_psy_get_property()
301 val->strval = "Unknown"; in aspire_ec_bat_psy_get_property()
305 return -EINVAL; in aspire_ec_bat_psy_get_property()
326 .name = "aspire-ec-bat",
337 struct aspire_ec *ec = power_supply_get_drvdata(psy); in aspire_ec_adp_psy_get_property() local
342 aspire_ec_ram_read(ec->client, ASPIRE_EC_RAM_ADP, &tmp, sizeof(tmp)); in aspire_ec_adp_psy_get_property()
343 val->intval = !!(tmp & ASPIRE_EC_AC_STATUS); in aspire_ec_adp_psy_get_property()
347 return -EINVAL; in aspire_ec_adp_psy_get_property()
358 .name = "aspire-ec-adp",
366 * USB-C DP Alt mode HPD.
371 return flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR ? 0 : -EINVAL; in aspire_ec_bridge_attach()
376 struct aspire_ec *ec = container_of(work, struct aspire_ec, work); in aspire_ec_bridge_update_hpd_work() local
379 aspire_ec_ram_read(ec->client, ASPIRE_EC_RAM_HPD_STATUS, &tmp, sizeof(tmp)); in aspire_ec_bridge_update_hpd_work()
381 drm_bridge_hpd_notify(&ec->bridge, connector_status_connected); in aspire_ec_bridge_update_hpd_work()
383 drm_bridge_hpd_notify(&ec->bridge, connector_status_disconnected); in aspire_ec_bridge_update_hpd_work()
388 struct aspire_ec *ec = container_of(bridge, struct aspire_ec, bridge); in aspire_ec_bridge_hpd_enable() local
390 schedule_work(&ec->work); in aspire_ec_bridge_hpd_enable()
404 struct aspire_ec *ec = i2c_get_clientdata(to_i2c_client(dev)); in fn_lock_show() local
407 aspire_ec_ram_read(ec->client, ASPIRE_EC_RAM_KBD_MODE, &tmp, sizeof(tmp)); in fn_lock_show()
415 struct aspire_ec *ec = i2c_get_clientdata(to_i2c_client(dev)); in fn_lock_store() local
425 aspire_ec_ram_read(ec->client, ASPIRE_EC_RAM_KBD_MODE, &tmp, sizeof(tmp)); in fn_lock_store()
432 aspire_ec_ram_write(ec->client, ASPIRE_EC_RAM_KBD_MODE, tmp); in fn_lock_store()
448 struct device *dev = &client->dev; in aspire_ec_probe()
450 struct aspire_ec *ec; in aspire_ec_probe() local
454 ec = devm_kzalloc(dev, sizeof(*ec), GFP_KERNEL); in aspire_ec_probe()
455 if (!ec) in aspire_ec_probe()
456 return -ENOMEM; in aspire_ec_probe()
458 ec->client = client; in aspire_ec_probe()
459 i2c_set_clientdata(client, ec); in aspire_ec_probe()
462 psy_cfg.drv_data = ec; in aspire_ec_probe()
463 ec->bat_psy = devm_power_supply_register(dev, &aspire_ec_bat_psy_desc, &psy_cfg); in aspire_ec_probe()
464 if (IS_ERR(ec->bat_psy)) in aspire_ec_probe()
465 return dev_err_probe(dev, PTR_ERR(ec->bat_psy), in aspire_ec_probe()
468 ec->adp_psy = devm_power_supply_register(dev, &aspire_ec_adp_psy_desc, &psy_cfg); in aspire_ec_probe()
469 if (IS_ERR(ec->adp_psy)) in aspire_ec_probe()
470 return dev_err_probe(dev, PTR_ERR(ec->adp_psy), in aspire_ec_probe()
474 ec->idev = devm_input_allocate_device(dev); in aspire_ec_probe()
475 if (!ec->idev) in aspire_ec_probe()
476 return -ENOMEM; in aspire_ec_probe()
478 ec->idev->name = "aspire-ec"; in aspire_ec_probe()
479 ec->idev->phys = "aspire-ec/input0"; in aspire_ec_probe()
480 input_set_capability(ec->idev, EV_SW, SW_LID); in aspire_ec_probe()
482 ret = input_register_device(ec->idev); in aspire_ec_probe()
495 /* External Type-C display attach reports */ in aspire_ec_probe()
498 INIT_WORK(&ec->work, aspire_ec_bridge_update_hpd_work); in aspire_ec_probe()
499 ec->bridge.funcs = &aspire_ec_bridge_funcs; in aspire_ec_probe()
500 ec->bridge.of_node = to_of_node(fwnode); in aspire_ec_probe()
501 ec->bridge.ops = DRM_BRIDGE_OP_HPD; in aspire_ec_probe()
502 ec->bridge.type = DRM_MODE_CONNECTOR_USB; in aspire_ec_probe()
504 ret = devm_drm_bridge_add(dev, &ec->bridge); in aspire_ec_probe()
510 ec->bridge_configured = true; in aspire_ec_probe()
513 ret = devm_request_threaded_irq(dev, client->irq, NULL, in aspire_ec_probe()
515 dev_name(dev), ec); in aspire_ec_probe()
524 struct aspire_ec *ec = i2c_get_clientdata(to_i2c_client(dev)); in aspire_ec_resume() local
527 aspire_ec_ram_read(ec->client, ASPIRE_EC_RAM_LID_STATUS, &tmp, sizeof(tmp)); in aspire_ec_resume()
528 input_report_switch(ec->idev, SW_LID, !!(tmp & ASPIRE_EC_LID_OPEN)); in aspire_ec_resume()
529 input_sync(ec->idev); in aspire_ec_resume()
535 { "aspire1-ec", },
541 { .compatible = "acer,aspire1-ec", },
550 .name = "aspire-ec",