Lines Matching +full:imx8mq +full:- +full:pcie
1 // SPDX-License-Identifier: GPL-2.0+
8 * Copyright 2015-2017 Pengutronix, Lucas Stach <kernel@pengutronix.de>
20 #include <dt-bindings/power/imx7-power.h>
21 #include <dt-bindings/power/imx8mq-power.h>
22 #include <dt-bindings/power/imx8mm-power.h>
23 #include <dt-bindings/power/imx8mn-power.h>
24 #include <dt-bindings/power/imx8mp-power.h>
322 ret = pm_runtime_get_sync(domain->dev); in imx_pgc_power_up()
324 pm_runtime_put_noidle(domain->dev); in imx_pgc_power_up()
328 if (!IS_ERR(domain->regulator)) { in imx_pgc_power_up()
329 ret = regulator_enable(domain->regulator); in imx_pgc_power_up()
331 dev_err(domain->dev, in imx_pgc_power_up()
338 reset_control_assert(domain->reset); in imx_pgc_power_up()
341 ret = clk_bulk_prepare_enable(domain->num_clks, domain->clks); in imx_pgc_power_up()
343 dev_err(domain->dev, "failed to enable reset clocks\n"); in imx_pgc_power_up()
350 if (domain->bits.pxx) { in imx_pgc_power_up()
352 regmap_update_bits(domain->regmap, domain->regs->pup, in imx_pgc_power_up()
353 domain->bits.pxx, domain->bits.pxx); in imx_pgc_power_up()
358 ret = regmap_read_poll_timeout(domain->regmap, in imx_pgc_power_up()
359 domain->regs->pup, reg_val, in imx_pgc_power_up()
360 !(reg_val & domain->bits.pxx), in imx_pgc_power_up()
363 dev_err(domain->dev, "failed to command PGC\n"); in imx_pgc_power_up()
368 for_each_set_bit(pgc, &domain->pgc, 32) { in imx_pgc_power_up()
369 regmap_clear_bits(domain->regmap, GPC_PGC_CTRL(pgc), in imx_pgc_power_up()
377 reset_control_deassert(domain->reset); in imx_pgc_power_up()
380 if (domain->bits.hskreq) { in imx_pgc_power_up()
381 regmap_update_bits(domain->regmap, domain->regs->hsk, in imx_pgc_power_up()
382 domain->bits.hskreq, domain->bits.hskreq); in imx_pgc_power_up()
385 * ret = regmap_read_poll_timeout(domain->regmap, domain->regs->hsk, reg_val, in imx_pgc_power_up()
386 * (reg_val & domain->bits.hskack), 0, in imx_pgc_power_up()
389 * the BLK-CTL module BUS clk-en bit being set. in imx_pgc_power_up()
391 * There is a separate BLK-CTL module and we will have such a driver for it, in imx_pgc_power_up()
392 * that driver will set the BUS clk-en bit and handshake will be triggered in imx_pgc_power_up()
399 if (!domain->keep_clocks) in imx_pgc_power_up()
400 clk_bulk_disable_unprepare(domain->num_clks, domain->clks); in imx_pgc_power_up()
405 clk_bulk_disable_unprepare(domain->num_clks, domain->clks); in imx_pgc_power_up()
407 if (!IS_ERR(domain->regulator)) in imx_pgc_power_up()
408 regulator_disable(domain->regulator); in imx_pgc_power_up()
410 pm_runtime_put(domain->dev); in imx_pgc_power_up()
422 if (!domain->keep_clocks) { in imx_pgc_power_down()
423 ret = clk_bulk_prepare_enable(domain->num_clks, domain->clks); in imx_pgc_power_down()
425 dev_err(domain->dev, "failed to enable reset clocks\n"); in imx_pgc_power_down()
431 if (domain->bits.hskreq) { in imx_pgc_power_down()
432 regmap_clear_bits(domain->regmap, domain->regs->hsk, in imx_pgc_power_down()
433 domain->bits.hskreq); in imx_pgc_power_down()
435 ret = regmap_read_poll_timeout(domain->regmap, domain->regs->hsk, in imx_pgc_power_down()
437 !(reg_val & domain->bits.hskack), in imx_pgc_power_down()
440 dev_err(domain->dev, "failed to power down ADB400\n"); in imx_pgc_power_down()
445 if (domain->bits.pxx) { in imx_pgc_power_down()
447 for_each_set_bit(pgc, &domain->pgc, 32) { in imx_pgc_power_down()
448 regmap_update_bits(domain->regmap, GPC_PGC_CTRL(pgc), in imx_pgc_power_down()
453 regmap_update_bits(domain->regmap, domain->regs->pdn, in imx_pgc_power_down()
454 domain->bits.pxx, domain->bits.pxx); in imx_pgc_power_down()
459 ret = regmap_read_poll_timeout(domain->regmap, in imx_pgc_power_down()
460 domain->regs->pdn, reg_val, in imx_pgc_power_down()
461 !(reg_val & domain->bits.pxx), in imx_pgc_power_down()
464 dev_err(domain->dev, "failed to command PGC\n"); in imx_pgc_power_down()
470 clk_bulk_disable_unprepare(domain->num_clks, domain->clks); in imx_pgc_power_down()
472 if (!IS_ERR(domain->regulator)) { in imx_pgc_power_down()
473 ret = regulator_disable(domain->regulator); in imx_pgc_power_down()
475 dev_err(domain->dev, in imx_pgc_power_down()
482 pm_runtime_put_sync_suspend(domain->dev); in imx_pgc_power_down()
487 if (!domain->keep_clocks) in imx_pgc_power_down()
488 clk_bulk_disable_unprepare(domain->num_clks, domain->clks); in imx_pgc_power_down()
496 .name = "mipi-phy",
508 .name = "pcie-phy",
520 .name = "usb-hsic-phy",
586 .name = "usb-otg1",
597 .name = "usb-otg2",
659 .name = "mipi-csi1",
670 .name = "mipi-csi2",
746 .name = "pcie",
757 .name = "usb-otg1",
769 .name = "usb-otg2",
822 .name = "vpu-g1",
833 .name = "vpu-g2",
844 .name = "vpu-h1",
926 .name = "mipi-phy1",
937 .name = "pcie-phy1",
948 .name = "usb-otg1",
959 .name = "usb-otg2",
1062 .name = "vpu-g1",
1073 .name = "vpu-g2",
1084 .name = "vpu-h1",
1109 .name = "hdmi-phy",
1120 .name = "mipi-phy2",
1145 .name = "mediamix-isp-dwp",
1236 .name = "usb-otg1",
1315 struct imx_pgc_domain *domain = pdev->dev.platform_data; in imx_pgc_domain_probe()
1318 domain->dev = &pdev->dev; in imx_pgc_domain_probe()
1320 domain->regulator = devm_regulator_get_optional(domain->dev, "power"); in imx_pgc_domain_probe()
1321 if (IS_ERR(domain->regulator)) { in imx_pgc_domain_probe()
1322 if (PTR_ERR(domain->regulator) != -ENODEV) in imx_pgc_domain_probe()
1323 return dev_err_probe(domain->dev, PTR_ERR(domain->regulator), in imx_pgc_domain_probe()
1325 } else if (domain->voltage) { in imx_pgc_domain_probe()
1326 regulator_set_voltage(domain->regulator, in imx_pgc_domain_probe()
1327 domain->voltage, domain->voltage); in imx_pgc_domain_probe()
1330 domain->num_clks = devm_clk_bulk_get_all(domain->dev, &domain->clks); in imx_pgc_domain_probe()
1331 if (domain->num_clks < 0) in imx_pgc_domain_probe()
1332 return dev_err_probe(domain->dev, domain->num_clks, in imx_pgc_domain_probe()
1335 domain->reset = devm_reset_control_array_get_optional_exclusive(domain->dev); in imx_pgc_domain_probe()
1336 if (IS_ERR(domain->reset)) in imx_pgc_domain_probe()
1337 return dev_err_probe(domain->dev, PTR_ERR(domain->reset), in imx_pgc_domain_probe()
1340 pm_runtime_enable(domain->dev); in imx_pgc_domain_probe()
1342 if (domain->bits.map) in imx_pgc_domain_probe()
1343 regmap_update_bits(domain->regmap, domain->regs->map, in imx_pgc_domain_probe()
1344 domain->bits.map, domain->bits.map); in imx_pgc_domain_probe()
1346 ret = pm_genpd_init(&domain->genpd, NULL, true); in imx_pgc_domain_probe()
1348 dev_err(domain->dev, "Failed to init power domain\n"); in imx_pgc_domain_probe()
1353 of_property_read_bool(domain->dev->of_node, "power-domains")) in imx_pgc_domain_probe()
1354 lockdep_set_subclass(&domain->genpd.mlock, 1); in imx_pgc_domain_probe()
1356 ret = of_genpd_add_provider_simple(domain->dev->of_node, in imx_pgc_domain_probe()
1357 &domain->genpd); in imx_pgc_domain_probe()
1359 dev_err(domain->dev, "Failed to add genpd provider\n"); in imx_pgc_domain_probe()
1366 pm_genpd_remove(&domain->genpd); in imx_pgc_domain_probe()
1368 if (domain->bits.map) in imx_pgc_domain_probe()
1369 regmap_update_bits(domain->regmap, domain->regs->map, in imx_pgc_domain_probe()
1370 domain->bits.map, 0); in imx_pgc_domain_probe()
1371 pm_runtime_disable(domain->dev); in imx_pgc_domain_probe()
1378 struct imx_pgc_domain *domain = pdev->dev.platform_data; in imx_pgc_domain_remove()
1380 of_genpd_del_provider(domain->dev->of_node); in imx_pgc_domain_remove()
1381 pm_genpd_remove(&domain->genpd); in imx_pgc_domain_remove()
1383 if (domain->bits.map) in imx_pgc_domain_remove()
1384 regmap_update_bits(domain->regmap, domain->regs->map, in imx_pgc_domain_remove()
1385 domain->bits.map, 0); in imx_pgc_domain_remove()
1387 pm_runtime_disable(domain->dev); in imx_pgc_domain_remove()
1423 { "imx-pgc-domain", },
1429 .name = "imx-pgc",
1441 of_device_get_match_data(&pdev->dev); in builtin_platform_driver()
1447 .rd_table = domain_data->reg_access_table, in builtin_platform_driver()
1448 .wr_table = domain_data->reg_access_table, in builtin_platform_driver()
1451 struct device *dev = &pdev->dev; in builtin_platform_driver()
1457 pgc_np = of_get_child_by_name(dev->of_node, "pgc"); in builtin_platform_driver()
1460 return -EINVAL; in builtin_platform_driver()
1489 if (domain_index >= domain_data->domains_num) { in builtin_platform_driver()
1496 pd_pdev = platform_device_alloc("imx-pgc-domain", in builtin_platform_driver()
1501 return -ENOMEM; in builtin_platform_driver()
1505 &domain_data->domains[domain_index], in builtin_platform_driver()
1506 sizeof(domain_data->domains[domain_index])); in builtin_platform_driver()
1513 domain = pd_pdev->dev.platform_data; in builtin_platform_driver()
1514 domain->regmap = regmap; in builtin_platform_driver()
1515 domain->regs = domain_data->pgc_regs; in builtin_platform_driver()
1517 domain->genpd.power_on = imx_pgc_power_up; in builtin_platform_driver()
1518 domain->genpd.power_off = imx_pgc_power_down; in builtin_platform_driver()
1520 pd_pdev->dev.parent = dev; in builtin_platform_driver()
1521 device_set_node(&pd_pdev->dev, of_fwnode_handle(np)); in builtin_platform_driver()
1535 { .compatible = "fsl,imx7d-gpc", .data = &imx7_pgc_domain_data, },
1536 { .compatible = "fsl,imx8mm-gpc", .data = &imx8mm_pgc_domain_data, },
1537 { .compatible = "fsl,imx8mn-gpc", .data = &imx8mn_pgc_domain_data, },
1538 { .compatible = "fsl,imx8mp-gpc", .data = &imx8mp_pgc_domain_data, },
1539 { .compatible = "fsl,imx8mq-gpc", .data = &imx8m_pgc_domain_data, },
1545 .name = "imx-gpcv2",