Lines Matching +full:meson +full:- +full:g12a +full:- +full:usb

1 // SPDX-License-Identifier: GPL-2.0+
14 #include <linux/reset-controller.h>
17 #include <dt-bindings/power/meson8-power.h>
18 #include <dt-bindings/power/meson-axg-power.h>
19 #include <dt-bindings/power/meson-g12a-power.h>
20 #include <dt-bindings/power/meson-gxbb-power.h>
21 #include <dt-bindings/power/meson-sm1-power.h>
30 * AO-bus as syscon. 0x3a from GX translates to 0x02, 0x3b translates to 0x03
288 [PWRC_SM1_USB_ID] = TOP_PD("USB", &sm1_pwrc_usb, sm1_pwrc_mem_usb,
320 regmap_read(pwrc_domain->pwrc->regmap_ao, in pwrc_ee_get_power()
321 pwrc_domain->desc.top_pd->sleep_reg, &reg); in pwrc_ee_get_power()
323 return (reg & pwrc_domain->desc.top_pd->sleep_mask); in pwrc_ee_get_power()
332 if (pwrc_domain->desc.top_pd) in meson_ee_pwrc_off()
333 regmap_update_bits(pwrc_domain->pwrc->regmap_ao, in meson_ee_pwrc_off()
334 pwrc_domain->desc.top_pd->sleep_reg, in meson_ee_pwrc_off()
335 pwrc_domain->desc.top_pd->sleep_mask, in meson_ee_pwrc_off()
336 pwrc_domain->desc.top_pd->sleep_mask); in meson_ee_pwrc_off()
339 for (i = 0 ; i < pwrc_domain->desc.mem_pd_count ; ++i) in meson_ee_pwrc_off()
340 regmap_update_bits(pwrc_domain->pwrc->regmap_hhi, in meson_ee_pwrc_off()
341 pwrc_domain->desc.mem_pd[i].reg, in meson_ee_pwrc_off()
342 pwrc_domain->desc.mem_pd[i].mask, in meson_ee_pwrc_off()
343 pwrc_domain->desc.mem_pd[i].mask); in meson_ee_pwrc_off()
347 if (pwrc_domain->desc.top_pd) in meson_ee_pwrc_off()
348 regmap_update_bits(pwrc_domain->pwrc->regmap_ao, in meson_ee_pwrc_off()
349 pwrc_domain->desc.top_pd->iso_reg, in meson_ee_pwrc_off()
350 pwrc_domain->desc.top_pd->iso_mask, in meson_ee_pwrc_off()
351 pwrc_domain->desc.top_pd->iso_mask); in meson_ee_pwrc_off()
353 if (pwrc_domain->num_clks) { in meson_ee_pwrc_off()
355 clk_bulk_disable_unprepare(pwrc_domain->num_clks, in meson_ee_pwrc_off()
356 pwrc_domain->clks); in meson_ee_pwrc_off()
368 if (pwrc_domain->desc.top_pd) in meson_ee_pwrc_on()
369 regmap_update_bits(pwrc_domain->pwrc->regmap_ao, in meson_ee_pwrc_on()
370 pwrc_domain->desc.top_pd->sleep_reg, in meson_ee_pwrc_on()
371 pwrc_domain->desc.top_pd->sleep_mask, 0); in meson_ee_pwrc_on()
374 for (i = 0 ; i < pwrc_domain->desc.mem_pd_count ; ++i) in meson_ee_pwrc_on()
375 regmap_update_bits(pwrc_domain->pwrc->regmap_hhi, in meson_ee_pwrc_on()
376 pwrc_domain->desc.mem_pd[i].reg, in meson_ee_pwrc_on()
377 pwrc_domain->desc.mem_pd[i].mask, 0); in meson_ee_pwrc_on()
381 ret = reset_control_assert(pwrc_domain->rstc); in meson_ee_pwrc_on()
385 if (pwrc_domain->desc.top_pd) in meson_ee_pwrc_on()
386 regmap_update_bits(pwrc_domain->pwrc->regmap_ao, in meson_ee_pwrc_on()
387 pwrc_domain->desc.top_pd->iso_reg, in meson_ee_pwrc_on()
388 pwrc_domain->desc.top_pd->iso_mask, 0); in meson_ee_pwrc_on()
390 ret = reset_control_deassert(pwrc_domain->rstc); in meson_ee_pwrc_on()
394 return clk_bulk_prepare_enable(pwrc_domain->num_clks, in meson_ee_pwrc_on()
395 pwrc_domain->clks); in meson_ee_pwrc_on()
404 dom->pwrc = pwrc; in meson_ee_pwrc_init_domain()
405 dom->num_rstc = dom->desc.reset_names_count; in meson_ee_pwrc_init_domain()
406 dom->num_clks = dom->desc.clk_names_count; in meson_ee_pwrc_init_domain()
408 if (dom->num_rstc) { in meson_ee_pwrc_init_domain()
409 int count = reset_control_get_count(&pdev->dev); in meson_ee_pwrc_init_domain()
411 if (count != dom->num_rstc) in meson_ee_pwrc_init_domain()
412 dev_warn(&pdev->dev, "Invalid resets count %d for domain %s\n", in meson_ee_pwrc_init_domain()
413 count, dom->desc.name); in meson_ee_pwrc_init_domain()
415 dom->rstc = devm_reset_control_array_get(&pdev->dev, false, in meson_ee_pwrc_init_domain()
417 if (IS_ERR(dom->rstc)) in meson_ee_pwrc_init_domain()
418 return PTR_ERR(dom->rstc); in meson_ee_pwrc_init_domain()
421 if (dom->num_clks) { in meson_ee_pwrc_init_domain()
422 int ret = devm_clk_bulk_get_all(&pdev->dev, &dom->clks); in meson_ee_pwrc_init_domain()
426 if (dom->num_clks != ret) { in meson_ee_pwrc_init_domain()
427 dev_warn(&pdev->dev, "Invalid clocks count %d for domain %s\n", in meson_ee_pwrc_init_domain()
428 ret, dom->desc.name); in meson_ee_pwrc_init_domain()
429 dom->num_clks = ret; in meson_ee_pwrc_init_domain()
433 dom->base.name = dom->desc.name; in meson_ee_pwrc_init_domain()
434 dom->base.power_on = meson_ee_pwrc_on; in meson_ee_pwrc_init_domain()
435 dom->base.power_off = meson_ee_pwrc_off; in meson_ee_pwrc_init_domain()
448 if (dom->num_clks && dom->desc.get_power && !dom->desc.get_power(dom)) { in meson_ee_pwrc_init_domain()
449 ret = clk_bulk_prepare_enable(dom->num_clks, dom->clks); in meson_ee_pwrc_init_domain()
453 dom->base.flags = GENPD_FLAG_ALWAYS_ON; in meson_ee_pwrc_init_domain()
454 ret = pm_genpd_init(&dom->base, NULL, false); in meson_ee_pwrc_init_domain()
458 ret = pm_genpd_init(&dom->base, NULL, in meson_ee_pwrc_init_domain()
459 (dom->desc.get_power ? in meson_ee_pwrc_init_domain()
460 dom->desc.get_power(dom) : true)); in meson_ee_pwrc_init_domain()
475 match = of_device_get_match_data(&pdev->dev); in meson_ee_pwrc_probe()
477 dev_err(&pdev->dev, "failed to get match data\n"); in meson_ee_pwrc_probe()
478 return -ENODEV; in meson_ee_pwrc_probe()
481 pwrc = devm_kzalloc(&pdev->dev, sizeof(*pwrc), GFP_KERNEL); in meson_ee_pwrc_probe()
483 return -ENOMEM; in meson_ee_pwrc_probe()
485 pwrc->xlate.domains = devm_kcalloc(&pdev->dev, match->count, in meson_ee_pwrc_probe()
486 sizeof(*pwrc->xlate.domains), in meson_ee_pwrc_probe()
488 if (!pwrc->xlate.domains) in meson_ee_pwrc_probe()
489 return -ENOMEM; in meson_ee_pwrc_probe()
491 pwrc->domains = devm_kcalloc(&pdev->dev, match->count, in meson_ee_pwrc_probe()
492 sizeof(*pwrc->domains), GFP_KERNEL); in meson_ee_pwrc_probe()
493 if (!pwrc->domains) in meson_ee_pwrc_probe()
494 return -ENOMEM; in meson_ee_pwrc_probe()
496 pwrc->xlate.num_domains = match->count; in meson_ee_pwrc_probe()
498 regmap_hhi = syscon_node_to_regmap(of_get_parent(pdev->dev.of_node)); in meson_ee_pwrc_probe()
500 dev_err(&pdev->dev, "failed to get HHI regmap\n"); in meson_ee_pwrc_probe()
504 regmap_ao = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, in meson_ee_pwrc_probe()
505 "amlogic,ao-sysctrl"); in meson_ee_pwrc_probe()
507 dev_err(&pdev->dev, "failed to get AO regmap\n"); in meson_ee_pwrc_probe()
511 pwrc->regmap_ao = regmap_ao; in meson_ee_pwrc_probe()
512 pwrc->regmap_hhi = regmap_hhi; in meson_ee_pwrc_probe()
516 for (i = 0 ; i < match->count ; ++i) { in meson_ee_pwrc_probe()
517 struct meson_ee_pwrc_domain *dom = &pwrc->domains[i]; in meson_ee_pwrc_probe()
519 memcpy(&dom->desc, &match->domains[i], sizeof(dom->desc)); in meson_ee_pwrc_probe()
525 pwrc->xlate.domains[i] = &dom->base; in meson_ee_pwrc_probe()
528 return of_genpd_add_provider_onecell(pdev->dev.of_node, &pwrc->xlate); in meson_ee_pwrc_probe()
536 for (i = 0 ; i < pwrc->xlate.num_domains ; ++i) { in meson_ee_pwrc_shutdown()
537 struct meson_ee_pwrc_domain *dom = &pwrc->domains[i]; in meson_ee_pwrc_shutdown()
539 if (dom->desc.get_power && !dom->desc.get_power(dom)) in meson_ee_pwrc_shutdown()
540 meson_ee_pwrc_off(&dom->base); in meson_ee_pwrc_shutdown()
576 .compatible = "amlogic,meson8-pwrc",
580 .compatible = "amlogic,meson8b-pwrc",
584 .compatible = "amlogic,meson8m2-pwrc",
588 .compatible = "amlogic,meson-axg-pwrc",
592 .compatible = "amlogic,meson-gxbb-pwrc",
596 .compatible = "amlogic,meson-g12a-pwrc",
600 .compatible = "amlogic,meson-sm1-pwrc",