Lines Matching +full:1 +full:ac
3 * AC driver for 7th-generation Microsoft Surface devices via Surface System
67 static int spwr_ac_update_unlocked(struct spwr_ac_device *ac) in spwr_ac_update_unlocked() argument
69 __le32 old = ac->state; in spwr_ac_update_unlocked()
72 lockdep_assert_held(&ac->lock); in spwr_ac_update_unlocked()
74 status = ssam_retry(ssam_bat_get_psrc, ac->sdev, &ac->state); in spwr_ac_update_unlocked()
78 return old != ac->state; in spwr_ac_update_unlocked()
81 static int spwr_ac_update(struct spwr_ac_device *ac) in spwr_ac_update() argument
85 mutex_lock(&ac->lock); in spwr_ac_update()
86 status = spwr_ac_update_unlocked(ac); in spwr_ac_update()
87 mutex_unlock(&ac->lock); in spwr_ac_update()
92 static int spwr_ac_recheck(struct spwr_ac_device *ac) in spwr_ac_recheck() argument
96 status = spwr_ac_update(ac); in spwr_ac_recheck()
98 power_supply_changed(ac->psy); in spwr_ac_recheck()
105 struct spwr_ac_device *ac; in spwr_notify_ac() local
108 ac = container_of(nf, struct spwr_ac_device, notif); in spwr_notify_ac()
110 dev_dbg(&ac->sdev->dev, "power event (cid = %#04x, iid = %#04x, tid = %#04x)\n", in spwr_notify_ac()
115 * seems to be handled via target=1 and instance=1, but events are in spwr_notify_ac()
118 * While it should be enough to just listen on 1/1, listen everywhere to in spwr_notify_ac()
124 status = spwr_ac_recheck(ac); in spwr_notify_ac()
142 struct spwr_ac_device *ac = power_supply_get_drvdata(psy); in spwr_ac_get_property() local
145 mutex_lock(&ac->lock); in spwr_ac_get_property()
147 status = spwr_ac_update_unlocked(ac); in spwr_ac_get_property()
153 val->intval = !!le32_to_cpu(ac->state); in spwr_ac_get_property()
162 mutex_unlock(&ac->lock); in spwr_ac_get_property()
174 static void spwr_ac_init(struct spwr_ac_device *ac, struct ssam_device *sdev, in spwr_ac_init() argument
177 mutex_init(&ac->lock); in spwr_ac_init()
178 strncpy(ac->name, name, ARRAY_SIZE(ac->name) - 1); in spwr_ac_init()
180 ac->sdev = sdev; in spwr_ac_init()
182 ac->notif.base.priority = 1; in spwr_ac_init()
183 ac->notif.base.fn = spwr_notify_ac; in spwr_ac_init()
184 ac->notif.event.reg = registry; in spwr_ac_init()
185 ac->notif.event.id.target_category = sdev->uid.category; in spwr_ac_init()
186 ac->notif.event.id.instance = 0; in spwr_ac_init()
187 ac->notif.event.mask = SSAM_EVENT_MASK_NONE; in spwr_ac_init()
188 ac->notif.event.flags = SSAM_EVENT_SEQUENCED; in spwr_ac_init()
190 ac->psy_desc.name = ac->name; in spwr_ac_init()
191 ac->psy_desc.type = POWER_SUPPLY_TYPE_MAINS; in spwr_ac_init()
192 ac->psy_desc.properties = spwr_ac_props; in spwr_ac_init()
193 ac->psy_desc.num_properties = ARRAY_SIZE(spwr_ac_props); in spwr_ac_init()
194 ac->psy_desc.get_property = spwr_ac_get_property; in spwr_ac_init()
197 static int spwr_ac_register(struct spwr_ac_device *ac) in spwr_ac_register() argument
204 status = ssam_retry(ssam_bat_get_sta, ac->sdev, &sta); in spwr_ac_register()
211 psy_cfg.drv_data = ac; in spwr_ac_register()
215 ac->psy = devm_power_supply_register(&ac->sdev->dev, &ac->psy_desc, &psy_cfg); in spwr_ac_register()
216 if (IS_ERR(ac->psy)) in spwr_ac_register()
217 return PTR_ERR(ac->psy); in spwr_ac_register()
219 return ssam_device_notifier_register(ac->sdev, &ac->notif); in spwr_ac_register()
234 struct spwr_ac_device *ac; in surface_ac_probe() local
240 ac = devm_kzalloc(&sdev->dev, sizeof(*ac), GFP_KERNEL); in surface_ac_probe()
241 if (!ac) in surface_ac_probe()
244 spwr_ac_init(ac, sdev, p->registry, p->name); in surface_ac_probe()
245 ssam_device_set_drvdata(sdev, ac); in surface_ac_probe()
247 return spwr_ac_register(ac); in surface_ac_probe()
252 struct spwr_ac_device *ac = ssam_device_get_drvdata(sdev); in surface_ac_remove() local
254 ssam_device_notifier_unregister(sdev, &ac->notif); in surface_ac_remove()
281 MODULE_DESCRIPTION("AC driver for Surface System Aggregator Module");