Lines Matching refs: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
120 mutex_lock(&ps->genpd.mlock); in apple_pmgr_reset_assert()
122 if (ps->genpd.status == GENPD_STATE_OFF) in apple_pmgr_reset_assert()
123 dev_err(ps->dev, "PS 0x%x: asserting RESET while powered down\n", ps->offset); in apple_pmgr_reset_assert()
125 dev_dbg(ps->dev, "PS 0x%x: assert reset\n", ps->offset); in apple_pmgr_reset_assert()
127 regmap_update_bits(ps->regmap, ps->offset, APPLE_PMGR_FLAGS | APPLE_PMGR_DEV_DISABLE, in apple_pmgr_reset_assert()
129 regmap_update_bits(ps->regmap, ps->offset, APPLE_PMGR_FLAGS | APPLE_PMGR_RESET, in apple_pmgr_reset_assert()
132 mutex_unlock(&ps->genpd.mlock); in apple_pmgr_reset_assert()
139 struct apple_pmgr_ps *ps = rcdev_to_apple_pmgr_ps(rcdev); in apple_pmgr_reset_deassert() local
141 mutex_lock(&ps->genpd.mlock); in apple_pmgr_reset_deassert()
143 dev_dbg(ps->dev, "PS 0x%x: deassert reset\n", ps->offset); in apple_pmgr_reset_deassert()
144 regmap_update_bits(ps->regmap, ps->offset, APPLE_PMGR_FLAGS | APPLE_PMGR_RESET, 0); in apple_pmgr_reset_deassert()
145 regmap_update_bits(ps->regmap, ps->offset, APPLE_PMGR_FLAGS | APPLE_PMGR_DEV_DISABLE, 0); in apple_pmgr_reset_deassert()
147 if (ps->genpd.status == GENPD_STATE_OFF) in apple_pmgr_reset_deassert()
148 dev_err(ps->dev, "PS 0x%x: RESET was deasserted while powered down\n", ps->offset); in apple_pmgr_reset_deassert()
150 mutex_unlock(&ps->genpd.mlock); in apple_pmgr_reset_deassert()
170 struct apple_pmgr_ps *ps = rcdev_to_apple_pmgr_ps(rcdev); in apple_pmgr_reset_status() local
173 regmap_read(ps->regmap, ps->offset, ®); in apple_pmgr_reset_status()
195 struct apple_pmgr_ps *ps; in apple_pmgr_ps_probe() local
206 ps = devm_kzalloc(dev, sizeof(*ps), GFP_KERNEL); in apple_pmgr_ps_probe()
207 if (!ps) in apple_pmgr_ps_probe()
210 ps->dev = dev; in apple_pmgr_ps_probe()
211 ps->regmap = regmap; in apple_pmgr_ps_probe()
219 ret = of_property_read_u32(node, "reg", &ps->offset); in apple_pmgr_ps_probe()
225 ps->genpd.name = name; in apple_pmgr_ps_probe()
226 ps->genpd.power_on = apple_pmgr_ps_power_on; in apple_pmgr_ps_probe()
227 ps->genpd.power_off = apple_pmgr_ps_power_off; in apple_pmgr_ps_probe()
229 ret = of_property_read_u32(node, "apple,min-state", &ps->min_state); in apple_pmgr_ps_probe()
230 if (ret == 0 && ps->min_state <= APPLE_PMGR_PS_ACTIVE) in apple_pmgr_ps_probe()
231 regmap_update_bits(regmap, ps->offset, APPLE_PMGR_FLAGS | APPLE_PMGR_PS_MIN, in apple_pmgr_ps_probe()
232 FIELD_PREP(APPLE_PMGR_PS_MIN, ps->min_state)); in apple_pmgr_ps_probe()
234 active = apple_pmgr_ps_is_active(ps); in apple_pmgr_ps_probe()
236 ps->genpd.flags |= GENPD_FLAG_ALWAYS_ON; in apple_pmgr_ps_probe()
240 active = apple_pmgr_ps_power_on(&ps->genpd) == 0; in apple_pmgr_ps_probe()
246 regmap_update_bits(regmap, ps->offset, APPLE_PMGR_FLAGS | APPLE_PMGR_AUTO_ENABLE, in apple_pmgr_ps_probe()
249 ret = pm_genpd_init(&ps->genpd, NULL, !active); in apple_pmgr_ps_probe()
255 ret = of_genpd_add_provider_simple(node, &ps->genpd); in apple_pmgr_ps_probe()
287 ps->rcdev.owner = THIS_MODULE; in apple_pmgr_ps_probe()
288 ps->rcdev.nr_resets = 1; in apple_pmgr_ps_probe()
289 ps->rcdev.ops = &apple_pmgr_reset_ops; in apple_pmgr_ps_probe()
290 ps->rcdev.of_node = dev->of_node; in apple_pmgr_ps_probe()
291 ps->rcdev.of_reset_n_cells = 0; in apple_pmgr_ps_probe()
292 ps->rcdev.of_xlate = apple_pmgr_reset_xlate; in apple_pmgr_ps_probe()
294 ret = devm_reset_controller_register(dev, &ps->rcdev); in apple_pmgr_ps_probe()
301 pm_genpd_remove(&ps->genpd); in apple_pmgr_ps_probe()