Lines Matching full:ps
55 struct apple_pmgr_ps *ps = genpd_to_apple_pmgr_ps(genpd); in apple_pmgr_ps_set() local
58 ret = regmap_read(ps->regmap, ps->offset, ®); in apple_pmgr_ps_set()
64 dev_err(ps->dev, "PS %s: powering off with RESET active\n", in apple_pmgr_ps_set()
70 dev_dbg(ps->dev, "PS %s: pwrstate = 0x%x: 0x%x\n", genpd->name, pstate, reg); in apple_pmgr_ps_set()
72 regmap_write(ps->regmap, ps->offset, reg); in apple_pmgr_ps_set()
75 ps->regmap, ps->offset, reg, in apple_pmgr_ps_set()
79 dev_err(ps->dev, "PS %s: Failed to reach power state 0x%x (now: 0x%x)\n", in apple_pmgr_ps_set()
86 regmap_write(ps->regmap, ps->offset, reg); in apple_pmgr_ps_set()
92 static bool apple_pmgr_ps_is_active(struct apple_pmgr_ps *ps) in apple_pmgr_ps_is_active() argument
96 regmap_read(ps->regmap, ps->offset, ®); in apple_pmgr_ps_is_active()
118 struct apple_pmgr_ps *ps = rcdev_to_apple_pmgr_ps(rcdev); in apple_pmgr_reset_assert() local
121 spin_lock_irqsave(&ps->genpd.slock, flags); in apple_pmgr_reset_assert()
123 if (ps->genpd.status == GENPD_STATE_OFF) in apple_pmgr_reset_assert()
124 dev_err(ps->dev, "PS 0x%x: asserting RESET while powered down\n", ps->offset); in apple_pmgr_reset_assert()
126 dev_dbg(ps->dev, "PS 0x%x: assert reset\n", ps->offset); in apple_pmgr_reset_assert()
128 regmap_update_bits(ps->regmap, ps->offset, APPLE_PMGR_FLAGS | APPLE_PMGR_DEV_DISABLE, in apple_pmgr_reset_assert()
130 regmap_update_bits(ps->regmap, ps->offset, APPLE_PMGR_FLAGS | APPLE_PMGR_RESET, in apple_pmgr_reset_assert()
133 spin_unlock_irqrestore(&ps->genpd.slock, flags); in apple_pmgr_reset_assert()
140 struct apple_pmgr_ps *ps = rcdev_to_apple_pmgr_ps(rcdev); in apple_pmgr_reset_deassert() local
143 spin_lock_irqsave(&ps->genpd.slock, flags); in apple_pmgr_reset_deassert()
145 dev_dbg(ps->dev, "PS 0x%x: deassert reset\n", ps->offset); in apple_pmgr_reset_deassert()
146 regmap_update_bits(ps->regmap, ps->offset, APPLE_PMGR_FLAGS | APPLE_PMGR_RESET, 0); in apple_pmgr_reset_deassert()
147 regmap_update_bits(ps->regmap, ps->offset, APPLE_PMGR_FLAGS | APPLE_PMGR_DEV_DISABLE, 0); in apple_pmgr_reset_deassert()
149 if (ps->genpd.status == GENPD_STATE_OFF) in apple_pmgr_reset_deassert()
150 dev_err(ps->dev, "PS 0x%x: RESET was deasserted while powered down\n", ps->offset); in apple_pmgr_reset_deassert()
152 spin_unlock_irqrestore(&ps->genpd.slock, flags); in apple_pmgr_reset_deassert()
172 struct apple_pmgr_ps *ps = rcdev_to_apple_pmgr_ps(rcdev); in apple_pmgr_reset_status() local
175 regmap_read(ps->regmap, ps->offset, ®); in apple_pmgr_reset_status()
197 struct apple_pmgr_ps *ps; in apple_pmgr_ps_probe() local
208 ps = devm_kzalloc(dev, sizeof(*ps), GFP_KERNEL); in apple_pmgr_ps_probe()
209 if (!ps) in apple_pmgr_ps_probe()
212 ps->dev = dev; in apple_pmgr_ps_probe()
213 ps->regmap = regmap; in apple_pmgr_ps_probe()
221 ret = of_property_read_u32(node, "reg", &ps->offset); in apple_pmgr_ps_probe()
227 ps->genpd.flags |= GENPD_FLAG_IRQ_SAFE; in apple_pmgr_ps_probe()
228 ps->genpd.name = name; in apple_pmgr_ps_probe()
229 ps->genpd.power_on = apple_pmgr_ps_power_on; in apple_pmgr_ps_probe()
230 ps->genpd.power_off = apple_pmgr_ps_power_off; in apple_pmgr_ps_probe()
232 ret = of_property_read_u32(node, "apple,min-state", &ps->min_state); in apple_pmgr_ps_probe()
233 if (ret == 0 && ps->min_state <= APPLE_PMGR_PS_ACTIVE) in apple_pmgr_ps_probe()
234 regmap_update_bits(regmap, ps->offset, APPLE_PMGR_FLAGS | APPLE_PMGR_PS_MIN, in apple_pmgr_ps_probe()
235 FIELD_PREP(APPLE_PMGR_PS_MIN, ps->min_state)); in apple_pmgr_ps_probe()
237 active = apple_pmgr_ps_is_active(ps); in apple_pmgr_ps_probe()
239 ps->genpd.flags |= GENPD_FLAG_ALWAYS_ON; in apple_pmgr_ps_probe()
243 active = apple_pmgr_ps_power_on(&ps->genpd) == 0; in apple_pmgr_ps_probe()
249 regmap_update_bits(regmap, ps->offset, APPLE_PMGR_FLAGS | APPLE_PMGR_AUTO_ENABLE, in apple_pmgr_ps_probe()
252 ret = pm_genpd_init(&ps->genpd, NULL, !active); in apple_pmgr_ps_probe()
258 ret = of_genpd_add_provider_simple(node, &ps->genpd); in apple_pmgr_ps_probe()
290 ps->rcdev.owner = THIS_MODULE; in apple_pmgr_ps_probe()
291 ps->rcdev.nr_resets = 1; in apple_pmgr_ps_probe()
292 ps->rcdev.ops = &apple_pmgr_reset_ops; in apple_pmgr_ps_probe()
293 ps->rcdev.of_node = dev->of_node; in apple_pmgr_ps_probe()
294 ps->rcdev.of_reset_n_cells = 0; in apple_pmgr_ps_probe()
295 ps->rcdev.of_xlate = apple_pmgr_reset_xlate; in apple_pmgr_ps_probe()
297 ret = devm_reset_controller_register(dev, &ps->rcdev); in apple_pmgr_ps_probe()
304 pm_genpd_remove(&ps->genpd); in apple_pmgr_ps_probe()