Lines Matching +full:num +full:- +full:domains
1 // SPDX-License-Identifier: GPL-2.0+
4 * Copyright 2017-2018 NXP
7 * Implementation of the SCU based Power Domains
10 * single global power domain and implement the ->attach|detach_dev()
12 * From within the ->attach_dev(), we could get the OF node for
13 * the device that is being attached and then parse the power-domain
18 * Additionally, we need to implement the ->stop() and ->start()
20 * rather than using the above ->power_on|off() callbacks.
23 * 1. The ->attach_dev() of power domain infrastructure still does
24 * not support multi domains case as the struct device *dev passed
32 * Update: Genpd assigns the ->of_node for the virtual device before it
33 * invokes ->attach_dev() callback, hence parsing for device resources via
37 * behavior changed if removing ->power_on|off() callback and use
38 * ->start() and ->stop() instead. genpd_dev_pm_attach will only power
54 #include <dt-bindings/firmware/imx/rsrc.h>
84 u8 num; member
119 { "audio-pll0", IMX_SC_R_AUDIO_PLL_0, 1, false, 0 },
120 { "audio-pll1", IMX_SC_R_AUDIO_PLL_1, 1, false, 0 },
121 { "audio-clk-0", IMX_SC_R_AUDIO_CLK_0, 1, false, 0 },
122 { "audio-clk-1", IMX_SC_R_AUDIO_CLK_1, 1, false, 0 },
123 { "dma0-ch", IMX_SC_R_DMA_0_CH0, 16, true, 0 },
124 { "dma1-ch", IMX_SC_R_DMA_1_CH0, 16, true, 0 },
125 { "dma2-ch", IMX_SC_R_DMA_2_CH0, 5, true, 0 },
140 { "dsp-ram", IMX_SC_R_DSP_RAM, 1, false, 0 },
148 { "lcd0-pwm", IMX_SC_R_LCD_0_PWM_0, 1, true, 0 },
155 { "vpu-pid", IMX_SC_R_VPU_PID0, 8, true, 0 },
156 { "vpu-dec0", IMX_SC_R_VPU_DEC_0, 1, false, 0 },
157 { "vpu-enc0", IMX_SC_R_VPU_ENC_0, 1, false, 0 },
158 { "vpu-enc1", IMX_SC_R_VPU_ENC_1, 1, false, 0 },
159 { "vpu-mu0", IMX_SC_R_VPU_MU_0, 1, false, 0 },
160 { "vpu-mu1", IMX_SC_R_VPU_MU_1, 1, false, 0 },
161 { "vpu-mu2", IMX_SC_R_VPU_MU_2, 1, false, 0 },
164 { "gpu0-pid", IMX_SC_R_GPU_0_PID0, 4, true, 0 },
167 { "pcie-b", IMX_SC_R_PCIE_B, 1, false, 0 },
168 { "serdes-1", IMX_SC_R_SERDES_1, 1, false, 0 },
169 { "hsio-gpio", IMX_SC_R_HSIO_GPIO, 1, false, 0 },
173 { "mipi0-pwm0", IMX_SC_R_MIPI_0_PWM_0, 1, false, 0 },
174 { "mipi0-i2c", IMX_SC_R_MIPI_0_I2C_0, 2, true, 0 },
177 { "mipi1-pwm0", IMX_SC_R_MIPI_1_PWM_0, 1, false, 0 },
178 { "mipi1-i2c", IMX_SC_R_MIPI_1_I2C_0, 2, true, 0 },
186 { "dc0-pll", IMX_SC_R_DC_0_PLL_0, 2, true, 0 },
187 { "dc0-video", IMX_SC_R_DC_0_VIDEO0, 2, true, 0 },
190 { "cm40-i2c", IMX_SC_R_M4_0_I2C, 1, false, 0 },
191 { "cm40-intmux", IMX_SC_R_M4_0_INTMUX, 1, false, 0 },
192 { "cm40-pid", IMX_SC_R_M4_0_PID0, 5, true, 0},
193 { "cm40-mu-a1", IMX_SC_R_M4_0_MU_1A, 1, false, 0},
194 { "cm40-lpuart", IMX_SC_R_M4_0_UART, 1, false, 0},
197 { "cm41-i2c", IMX_SC_R_M4_1_I2C, 1, false, 0 },
198 { "cm41-intmux", IMX_SC_R_M4_1_INTMUX, 1, false, 0 },
199 { "cm41-pid", IMX_SC_R_M4_1_PID0, 5, true, 0},
200 { "cm41-mu-a1", IMX_SC_R_M4_1_MU_1A, 1, false, 0},
201 { "cm41-lpuart", IMX_SC_R_M4_1_UART, 1, false, 0},
204 { "img-jpegdec-mp", IMX_SC_R_MJPEG_DEC_MP, 1, false, 0 },
205 { "img-jpegdec-s0", IMX_SC_R_MJPEG_DEC_S0, 4, true, 0 },
206 { "img-jpegenc-mp", IMX_SC_R_MJPEG_ENC_MP, 1, false, 0 },
207 { "img-jpegenc-s0", IMX_SC_R_MJPEG_ENC_S0, 4, true, 0 },
231 ret = of_parse_phandle_with_args(of_stdout, "power-domains", in imx_sc_pd_get_console_rsrc()
232 "#power-domain-cells", in imx_sc_pd_get_console_rsrc()
249 hdr->ver = IMX_SC_RPC_VERSION; in imx_sc_pd_power()
250 hdr->svc = IMX_SC_RPC_SVC_PM; in imx_sc_pd_power()
251 hdr->func = IMX_SC_PM_FUNC_SET_RESOURCE_POWER_MODE; in imx_sc_pd_power()
252 hdr->size = 2; in imx_sc_pd_power()
254 msg.resource = pd->rsrc; in imx_sc_pd_power()
259 dev_err(&domain->dev, "failed to power %s resource %d ret %d\n", in imx_sc_pd_power()
260 power_on ? "up" : "off", pd->rsrc, ret); in imx_sc_pd_power()
278 struct generic_pm_domain *domain = ERR_PTR(-ENOENT); in imx_scu_pd_xlate()
282 for (i = 0; i < pd_data->num_domains; i++) { in imx_scu_pd_xlate()
285 sc_pd = to_imx_sc_pd(pd_data->domains[i]); in imx_scu_pd_xlate()
286 if (sc_pd->rsrc == spec->args[0]) { in imx_scu_pd_xlate()
287 domain = &sc_pd->pd; in imx_scu_pd_xlate()
303 if (!imx_sc_rm_is_resource_owned(pm_ipc_handle, pd_ranges->rsrc + idx)) in imx_scu_add_pm_domain()
308 return ERR_PTR(-ENOMEM); in imx_scu_add_pm_domain()
310 sc_pd->rsrc = pd_ranges->rsrc + idx; in imx_scu_add_pm_domain()
311 sc_pd->pd.power_off = imx_sc_pd_power_off; in imx_scu_add_pm_domain()
312 sc_pd->pd.power_on = imx_sc_pd_power_on; in imx_scu_add_pm_domain()
314 if (pd_ranges->postfix) in imx_scu_add_pm_domain()
315 snprintf(sc_pd->name, sizeof(sc_pd->name), in imx_scu_add_pm_domain()
316 "%s%i", pd_ranges->name, pd_ranges->start_from + idx); in imx_scu_add_pm_domain()
318 snprintf(sc_pd->name, sizeof(sc_pd->name), in imx_scu_add_pm_domain()
319 "%s", pd_ranges->name); in imx_scu_add_pm_domain()
321 sc_pd->pd.name = sc_pd->name; in imx_scu_add_pm_domain()
322 if (imx_con_rsrc == sc_pd->rsrc) { in imx_scu_add_pm_domain()
323 sc_pd->pd.flags = GENPD_FLAG_RPM_ALWAYS_ON; in imx_scu_add_pm_domain()
327 if (sc_pd->rsrc >= IMX_SC_R_LAST) { in imx_scu_add_pm_domain()
329 sc_pd->name, sc_pd->rsrc); in imx_scu_add_pm_domain()
335 ret = pm_genpd_init(&sc_pd->pd, NULL, is_off); in imx_scu_add_pm_domain()
338 sc_pd->name, sc_pd->rsrc); in imx_scu_add_pm_domain()
349 const struct imx_sc_pd_range *pd_ranges = pd_soc->pd_ranges; in imx_scu_init_pm_domains()
350 struct generic_pm_domain **domains; in imx_scu_init_pm_domains() local
356 for (i = 0; i < pd_soc->num_ranges; i++) in imx_scu_init_pm_domains()
357 count += pd_ranges[i].num; in imx_scu_init_pm_domains()
359 domains = devm_kcalloc(dev, count, sizeof(*domains), GFP_KERNEL); in imx_scu_init_pm_domains()
360 if (!domains) in imx_scu_init_pm_domains()
361 return -ENOMEM; in imx_scu_init_pm_domains()
365 return -ENOMEM; in imx_scu_init_pm_domains()
368 for (i = 0; i < pd_soc->num_ranges; i++) { in imx_scu_init_pm_domains()
369 for (j = 0; j < pd_ranges[i].num; j++) { in imx_scu_init_pm_domains()
374 domains[count++] = &sc_pd->pd; in imx_scu_init_pm_domains()
375 dev_dbg(dev, "added power domain %s\n", sc_pd->pd.name); in imx_scu_init_pm_domains()
379 pd_data->domains = domains; in imx_scu_init_pm_domains()
380 pd_data->num_domains = count; in imx_scu_init_pm_domains()
381 pd_data->xlate = imx_scu_pd_xlate; in imx_scu_init_pm_domains()
383 of_genpd_add_provider_onecell(dev->of_node, pd_data); in imx_scu_init_pm_domains()
397 pd_soc = of_device_get_match_data(&pdev->dev); in imx_sc_pd_probe()
399 return -ENODEV; in imx_sc_pd_probe()
403 return imx_scu_init_pm_domains(&pdev->dev, pd_soc); in imx_sc_pd_probe()
407 { .compatible = "fsl,imx8qxp-scu-pd", &imx8qxp_scu_pd},
408 { .compatible = "fsl,scu-pd", &imx8qxp_scu_pd},
414 .name = "imx-scu-pd",