Lines Matching +full:scu +full:- +full:index
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
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
41 * not up before running driver probe function. For SCU enabled
54 #include <dt-bindings/firmware/imx/rsrc.h>
67 /* SCU Power Mode Protocol definition */
86 /* add domain index */
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 },
160 { "gpu0-pid", IMX_SC_R_GPU_0_PID0, 4, true, 0 },
163 { "pcie-b", IMX_SC_R_PCIE_B, 1, false, 0 },
164 { "serdes-1", IMX_SC_R_SERDES_1, 1, false, 0 },
165 { "hsio-gpio", IMX_SC_R_HSIO_GPIO, 1, false, 0 },
169 { "mipi0-pwm0", IMX_SC_R_MIPI_0_PWM_0, 1, false, 0 },
170 { "mipi0-i2c", IMX_SC_R_MIPI_0_I2C_0, 2, true, 0 },
173 { "mipi1-pwm0", IMX_SC_R_MIPI_1_PWM_0, 1, false, 0 },
174 { "mipi1-i2c", IMX_SC_R_MIPI_1_I2C_0, 2, true, 0 },
182 { "dc0-pll", IMX_SC_R_DC_0_PLL_0, 2, true, 0 },
183 { "dc0-video", IMX_SC_R_DC_0_VIDEO0, 2, true, 0 },
186 { "cm40-i2c", IMX_SC_R_M4_0_I2C, 1, false, 0 },
187 { "cm40-intmux", IMX_SC_R_M4_0_INTMUX, 1, false, 0 },
188 { "cm40-pid", IMX_SC_R_M4_0_PID0, 5, true, 0},
189 { "cm40-mu-a1", IMX_SC_R_M4_0_MU_1A, 1, false, 0},
190 { "cm40-lpuart", IMX_SC_R_M4_0_UART, 1, false, 0},
193 { "cm41-i2c", IMX_SC_R_M4_1_I2C, 1, false, 0 },
194 { "cm41-intmux", IMX_SC_R_M4_1_INTMUX, 1, false, 0 },
195 { "cm41-pid", IMX_SC_R_M4_1_PID0, 5, true, 0},
196 { "cm41-mu-a1", IMX_SC_R_M4_1_MU_1A, 1, false, 0},
197 { "cm41-lpuart", IMX_SC_R_M4_1_UART, 1, false, 0},
200 { "img-jpegdec-mp", IMX_SC_R_MJPEG_DEC_MP, 1, false, 0 },
201 { "img-jpegdec-s0", IMX_SC_R_MJPEG_DEC_S0, 4, true, 0 },
202 { "img-jpegenc-mp", IMX_SC_R_MJPEG_ENC_MP, 1, false, 0 },
203 { "img-jpegenc-s0", IMX_SC_R_MJPEG_ENC_S0, 4, true, 0 },
227 ret = of_parse_phandle_with_args(of_stdout, "power-domains", in imx_sc_pd_get_console_rsrc()
228 "#power-domain-cells", in imx_sc_pd_get_console_rsrc()
245 hdr->ver = IMX_SC_RPC_VERSION; in imx_sc_pd_power()
246 hdr->svc = IMX_SC_RPC_SVC_PM; in imx_sc_pd_power()
247 hdr->func = IMX_SC_PM_FUNC_SET_RESOURCE_POWER_MODE; in imx_sc_pd_power()
248 hdr->size = 2; in imx_sc_pd_power()
250 msg.resource = pd->rsrc; in imx_sc_pd_power()
255 dev_err(&domain->dev, "failed to power %s resource %d ret %d\n", in imx_sc_pd_power()
256 power_on ? "up" : "off", pd->rsrc, ret); in imx_sc_pd_power()
274 struct generic_pm_domain *domain = ERR_PTR(-ENOENT); in imx_scu_pd_xlate()
278 for (i = 0; i < pd_data->num_domains; i++) { in imx_scu_pd_xlate()
281 sc_pd = to_imx_sc_pd(pd_data->domains[i]); in imx_scu_pd_xlate()
282 if (sc_pd->rsrc == spec->args[0]) { in imx_scu_pd_xlate()
283 domain = &sc_pd->pd; in imx_scu_pd_xlate()
299 if (!imx_sc_rm_is_resource_owned(pm_ipc_handle, pd_ranges->rsrc + idx)) in imx_scu_add_pm_domain()
304 return ERR_PTR(-ENOMEM); in imx_scu_add_pm_domain()
306 sc_pd->rsrc = pd_ranges->rsrc + idx; in imx_scu_add_pm_domain()
307 sc_pd->pd.power_off = imx_sc_pd_power_off; in imx_scu_add_pm_domain()
308 sc_pd->pd.power_on = imx_sc_pd_power_on; in imx_scu_add_pm_domain()
310 if (pd_ranges->postfix) in imx_scu_add_pm_domain()
311 snprintf(sc_pd->name, sizeof(sc_pd->name), in imx_scu_add_pm_domain()
312 "%s%i", pd_ranges->name, pd_ranges->start_from + idx); in imx_scu_add_pm_domain()
314 snprintf(sc_pd->name, sizeof(sc_pd->name), in imx_scu_add_pm_domain()
315 "%s", pd_ranges->name); in imx_scu_add_pm_domain()
317 sc_pd->pd.name = sc_pd->name; in imx_scu_add_pm_domain()
318 if (imx_con_rsrc == sc_pd->rsrc) { in imx_scu_add_pm_domain()
319 sc_pd->pd.flags = GENPD_FLAG_RPM_ALWAYS_ON; in imx_scu_add_pm_domain()
323 if (sc_pd->rsrc >= IMX_SC_R_LAST) { in imx_scu_add_pm_domain()
325 sc_pd->name, sc_pd->rsrc); in imx_scu_add_pm_domain()
331 ret = pm_genpd_init(&sc_pd->pd, NULL, is_off); in imx_scu_add_pm_domain()
334 sc_pd->name, sc_pd->rsrc); in imx_scu_add_pm_domain()
345 const struct imx_sc_pd_range *pd_ranges = pd_soc->pd_ranges; in imx_scu_init_pm_domains()
352 for (i = 0; i < pd_soc->num_ranges; i++) in imx_scu_init_pm_domains()
357 return -ENOMEM; in imx_scu_init_pm_domains()
361 return -ENOMEM; in imx_scu_init_pm_domains()
364 for (i = 0; i < pd_soc->num_ranges; i++) { in imx_scu_init_pm_domains()
370 domains[count++] = &sc_pd->pd; in imx_scu_init_pm_domains()
371 dev_dbg(dev, "added power domain %s\n", sc_pd->pd.name); in imx_scu_init_pm_domains()
375 pd_data->domains = domains; in imx_scu_init_pm_domains()
376 pd_data->num_domains = count; in imx_scu_init_pm_domains()
377 pd_data->xlate = imx_scu_pd_xlate; in imx_scu_init_pm_domains()
379 of_genpd_add_provider_onecell(dev->of_node, pd_data); in imx_scu_init_pm_domains()
393 pd_soc = of_device_get_match_data(&pdev->dev); in imx_sc_pd_probe()
395 return -ENODEV; in imx_sc_pd_probe()
399 return imx_scu_init_pm_domains(&pdev->dev, pd_soc); in imx_sc_pd_probe()
403 { .compatible = "fsl,imx8qxp-scu-pd", &imx8qxp_scu_pd},
404 { .compatible = "fsl,scu-pd", &imx8qxp_scu_pd},
410 .name = "imx-scu-pd",
418 MODULE_DESCRIPTION("IMX SCU Power Domain driver");