Lines Matching +full:meson +full:- +full:g12a +full:- +full:usb
1 // SPDX-License-Identifier: GPL-2.0+
13 #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
321 [PWRC_SM1_USB_ID] = TOP_PD("USB", &sm1_pwrc_usb, sm1_pwrc_mem_usb,
353 regmap_read(pwrc_domain->pwrc->regmap_ao, in pwrc_ee_is_powered_off()
354 pwrc_domain->desc.top_pd->sleep_reg, ®); in pwrc_ee_is_powered_off()
356 return (reg & pwrc_domain->desc.top_pd->sleep_mask); in pwrc_ee_is_powered_off()
365 if (pwrc_domain->desc.top_pd) in meson_ee_pwrc_off()
366 regmap_update_bits(pwrc_domain->pwrc->regmap_ao, in meson_ee_pwrc_off()
367 pwrc_domain->desc.top_pd->sleep_reg, in meson_ee_pwrc_off()
368 pwrc_domain->desc.top_pd->sleep_mask, in meson_ee_pwrc_off()
369 pwrc_domain->desc.top_pd->sleep_mask); in meson_ee_pwrc_off()
372 for (i = 0 ; i < pwrc_domain->desc.mem_pd_count ; ++i) in meson_ee_pwrc_off()
373 regmap_update_bits(pwrc_domain->pwrc->regmap_hhi, in meson_ee_pwrc_off()
374 pwrc_domain->desc.mem_pd[i].reg, in meson_ee_pwrc_off()
375 pwrc_domain->desc.mem_pd[i].mask, in meson_ee_pwrc_off()
376 pwrc_domain->desc.mem_pd[i].mask); in meson_ee_pwrc_off()
380 if (pwrc_domain->desc.top_pd) in meson_ee_pwrc_off()
381 regmap_update_bits(pwrc_domain->pwrc->regmap_ao, in meson_ee_pwrc_off()
382 pwrc_domain->desc.top_pd->iso_reg, in meson_ee_pwrc_off()
383 pwrc_domain->desc.top_pd->iso_mask, in meson_ee_pwrc_off()
384 pwrc_domain->desc.top_pd->iso_mask); in meson_ee_pwrc_off()
386 if (pwrc_domain->num_clks) { in meson_ee_pwrc_off()
388 clk_bulk_disable_unprepare(pwrc_domain->num_clks, in meson_ee_pwrc_off()
389 pwrc_domain->clks); in meson_ee_pwrc_off()
401 if (pwrc_domain->desc.top_pd) in meson_ee_pwrc_on()
402 regmap_update_bits(pwrc_domain->pwrc->regmap_ao, in meson_ee_pwrc_on()
403 pwrc_domain->desc.top_pd->sleep_reg, in meson_ee_pwrc_on()
404 pwrc_domain->desc.top_pd->sleep_mask, 0); in meson_ee_pwrc_on()
407 for (i = 0 ; i < pwrc_domain->desc.mem_pd_count ; ++i) in meson_ee_pwrc_on()
408 regmap_update_bits(pwrc_domain->pwrc->regmap_hhi, in meson_ee_pwrc_on()
409 pwrc_domain->desc.mem_pd[i].reg, in meson_ee_pwrc_on()
410 pwrc_domain->desc.mem_pd[i].mask, 0); in meson_ee_pwrc_on()
414 ret = reset_control_assert(pwrc_domain->rstc); in meson_ee_pwrc_on()
418 if (pwrc_domain->desc.top_pd) in meson_ee_pwrc_on()
419 regmap_update_bits(pwrc_domain->pwrc->regmap_ao, in meson_ee_pwrc_on()
420 pwrc_domain->desc.top_pd->iso_reg, in meson_ee_pwrc_on()
421 pwrc_domain->desc.top_pd->iso_mask, 0); in meson_ee_pwrc_on()
423 ret = reset_control_deassert(pwrc_domain->rstc); in meson_ee_pwrc_on()
427 return clk_bulk_prepare_enable(pwrc_domain->num_clks, in meson_ee_pwrc_on()
428 pwrc_domain->clks); in meson_ee_pwrc_on()
437 dom->pwrc = pwrc; in meson_ee_pwrc_init_domain()
438 dom->num_rstc = dom->desc.reset_names_count; in meson_ee_pwrc_init_domain()
439 dom->num_clks = dom->desc.clk_names_count; in meson_ee_pwrc_init_domain()
441 if (dom->num_rstc) { in meson_ee_pwrc_init_domain()
442 int count = reset_control_get_count(&pdev->dev); in meson_ee_pwrc_init_domain()
444 if (count != dom->num_rstc) in meson_ee_pwrc_init_domain()
445 dev_warn(&pdev->dev, "Invalid resets count %d for domain %s\n", in meson_ee_pwrc_init_domain()
446 count, dom->desc.name); in meson_ee_pwrc_init_domain()
448 dom->rstc = devm_reset_control_array_get_exclusive(&pdev->dev); in meson_ee_pwrc_init_domain()
449 if (IS_ERR(dom->rstc)) in meson_ee_pwrc_init_domain()
450 return PTR_ERR(dom->rstc); in meson_ee_pwrc_init_domain()
453 if (dom->num_clks) { in meson_ee_pwrc_init_domain()
454 int ret = devm_clk_bulk_get_all(&pdev->dev, &dom->clks); in meson_ee_pwrc_init_domain()
458 if (dom->num_clks != ret) { in meson_ee_pwrc_init_domain()
459 dev_warn(&pdev->dev, "Invalid clocks count %d for domain %s\n", in meson_ee_pwrc_init_domain()
460 ret, dom->desc.name); in meson_ee_pwrc_init_domain()
461 dom->num_clks = ret; in meson_ee_pwrc_init_domain()
465 dom->base.name = dom->desc.name; in meson_ee_pwrc_init_domain()
466 dom->base.power_on = meson_ee_pwrc_on; in meson_ee_pwrc_init_domain()
467 dom->base.power_off = meson_ee_pwrc_off; in meson_ee_pwrc_init_domain()
480 if (dom->num_clks && dom->desc.is_powered_off && !dom->desc.is_powered_off(dom)) { in meson_ee_pwrc_init_domain()
481 ret = clk_bulk_prepare_enable(dom->num_clks, dom->clks); in meson_ee_pwrc_init_domain()
485 dom->base.flags = GENPD_FLAG_ALWAYS_ON; in meson_ee_pwrc_init_domain()
486 ret = pm_genpd_init(&dom->base, NULL, false); in meson_ee_pwrc_init_domain()
490 ret = pm_genpd_init(&dom->base, NULL, in meson_ee_pwrc_init_domain()
491 (dom->desc.is_powered_off ? in meson_ee_pwrc_init_domain()
492 dom->desc.is_powered_off(dom) : true)); in meson_ee_pwrc_init_domain()
508 match = of_device_get_match_data(&pdev->dev); in meson_ee_pwrc_probe()
510 dev_err(&pdev->dev, "failed to get match data\n"); in meson_ee_pwrc_probe()
511 return -ENODEV; in meson_ee_pwrc_probe()
514 pwrc = devm_kzalloc(&pdev->dev, sizeof(*pwrc), GFP_KERNEL); in meson_ee_pwrc_probe()
516 return -ENOMEM; in meson_ee_pwrc_probe()
518 pwrc->xlate.domains = devm_kcalloc(&pdev->dev, match->count, in meson_ee_pwrc_probe()
519 sizeof(*pwrc->xlate.domains), in meson_ee_pwrc_probe()
521 if (!pwrc->xlate.domains) in meson_ee_pwrc_probe()
522 return -ENOMEM; in meson_ee_pwrc_probe()
524 pwrc->domains = devm_kcalloc(&pdev->dev, match->count, in meson_ee_pwrc_probe()
525 sizeof(*pwrc->domains), GFP_KERNEL); in meson_ee_pwrc_probe()
526 if (!pwrc->domains) in meson_ee_pwrc_probe()
527 return -ENOMEM; in meson_ee_pwrc_probe()
529 pwrc->xlate.num_domains = match->count; in meson_ee_pwrc_probe()
531 parent_np = of_get_parent(pdev->dev.of_node); in meson_ee_pwrc_probe()
535 dev_err(&pdev->dev, "failed to get HHI regmap\n"); in meson_ee_pwrc_probe()
539 regmap_ao = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, in meson_ee_pwrc_probe()
540 "amlogic,ao-sysctrl"); in meson_ee_pwrc_probe()
542 dev_err(&pdev->dev, "failed to get AO regmap\n"); in meson_ee_pwrc_probe()
546 pwrc->regmap_ao = regmap_ao; in meson_ee_pwrc_probe()
547 pwrc->regmap_hhi = regmap_hhi; in meson_ee_pwrc_probe()
551 for (i = 0 ; i < match->count ; ++i) { in meson_ee_pwrc_probe()
552 struct meson_ee_pwrc_domain *dom = &pwrc->domains[i]; in meson_ee_pwrc_probe()
554 memcpy(&dom->desc, &match->domains[i], sizeof(dom->desc)); in meson_ee_pwrc_probe()
560 pwrc->xlate.domains[i] = &dom->base; in meson_ee_pwrc_probe()
563 return of_genpd_add_provider_onecell(pdev->dev.of_node, &pwrc->xlate); in meson_ee_pwrc_probe()
571 for (i = 0 ; i < pwrc->xlate.num_domains ; ++i) { in meson_ee_pwrc_shutdown()
572 struct meson_ee_pwrc_domain *dom = &pwrc->domains[i]; in meson_ee_pwrc_shutdown()
574 if (dom->desc.is_powered_off && !dom->desc.is_powered_off(dom)) in meson_ee_pwrc_shutdown()
575 meson_ee_pwrc_off(&dom->base); in meson_ee_pwrc_shutdown()
611 .compatible = "amlogic,meson8-pwrc",
615 .compatible = "amlogic,meson8b-pwrc",
619 .compatible = "amlogic,meson8m2-pwrc",
623 .compatible = "amlogic,meson-axg-pwrc",
627 .compatible = "amlogic,meson-gxbb-pwrc",
631 .compatible = "amlogic,meson-g12a-pwrc",
635 .compatible = "amlogic,meson-sm1-pwrc",
651 MODULE_DESCRIPTION("Amlogic Meson Everything-Else Power Domains driver");