123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- // SPDX-License-Identifier: GPL-2.0-only
- /*
- * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
- */
- #include <linux/types.h>
- #include <linux/of_platform.h>
- #include "mmrm_internal.h"
- #include "mmrm_debug.h"
- static struct mmrm_common_data common_pt_data[] = {
- {
- .key = "qcom,mmrm_clk_mgr_scheme",
- .value = CLK_MGR_SCHEME_SW,
- },
- };
- /*throttle client list is as per fdd & resource availability*/
- static struct mmrm_throttle_clients_data common_pt_throttle_clients_data_pineapple[] = {
- {
- .domain = MMRM_CLIENT_DOMAIN_DISPLAY,
- .id = 0x3e,
- },
- {
- .domain = MMRM_CLIENT_DOMAIN_VIDEO,
- .id = 0x03,
- },
- {
- .domain = MMRM_CLIENT_DOMAIN_CAMERA,
- .id = 0x58,
- },
- {
- .domain = MMRM_CLIENT_DOMAIN_CVP,
- .id = 0x0a,
- },
- {
- .domain = MMRM_CLIENT_DOMAIN_CAMERA,
- .id = 0x02,
- },
- };
- static struct mmrm_throttle_clients_data common_pt_throttle_clients_data_cliffs[] = {
- {
- .domain = MMRM_CLIENT_DOMAIN_DISPLAY,
- .id = 0x3e,
- },
- {
- .domain = MMRM_CLIENT_DOMAIN_VIDEO,
- .id = 0x03,
- },
- {
- .domain = MMRM_CLIENT_DOMAIN_CAMERA,
- .id = 0x62,
- },
- {
- .domain = MMRM_CLIENT_DOMAIN_CVP,
- .id = 0x0a,
- },
- {
- .domain = MMRM_CLIENT_DOMAIN_CAMERA,
- .id = 0x17,
- },
- };
- static struct mmrm_platform_data commom_pt_platform_data_pineapple = {
- .common_data = common_pt_data,
- .common_data_length = ARRAY_SIZE(common_pt_data),
- .throttle_clk_clients_data = common_pt_throttle_clients_data_pineapple,
- .throttle_clk_clients_data_length = ARRAY_SIZE(common_pt_throttle_clients_data_pineapple),
- };
- static struct mmrm_platform_data commom_pt_platform_data_cliffs = {
- .common_data = common_pt_data,
- .common_data_length = ARRAY_SIZE(common_pt_data),
- .throttle_clk_clients_data = common_pt_throttle_clients_data_cliffs,
- .throttle_clk_clients_data_length = ARRAY_SIZE(common_pt_throttle_clients_data_cliffs),
- };
- static const struct of_device_id mmrm_dt_match[] = {
- {
- .compatible = "qcom,waipio-mmrm",
- .data = &commom_pt_platform_data_pineapple,
- },
- {
- .compatible = "qcom,kalama-mmrm",
- .data = &commom_pt_platform_data_pineapple,
- },
- {
- .compatible = "qcom,pineapple-mmrm",
- .data = &commom_pt_platform_data_pineapple,
- },
- {
- .compatible = "qcom,cliffs-mmrm",
- .data = &commom_pt_platform_data_cliffs,
- },
- {},
- };
- struct mmrm_platform_data *mmrm_get_platform_data(struct device *dev)
- {
- struct mmrm_platform_data *platform_data = NULL;
- const struct of_device_id *match;
- match = of_match_node(mmrm_dt_match, dev->of_node);
- if (match)
- platform_data = (struct mmrm_platform_data *)match->data;
- if (!platform_data)
- goto exit;
- /* add additional config checks for platform data */
- exit:
- return platform_data;
- }
- int mmrm_init(struct mmrm_driver_data *drv_data)
- {
- int rc = 0;
- /* get clk resource mgr ops */
- rc = mmrm_get_clk_mgr_ops(drv_data);
- if (rc) {
- d_mpr_e("%s: init clk mgr failed\n", __func__);
- goto err_get_clk_mgr_ops;
- }
- /* clock resource mgr */
- rc = drv_data->clk_mgr_ops->init_clk_mgr(drv_data);
- if (rc) {
- d_mpr_e("%s: init clk mgr failed\n", __func__);
- goto err_init_clk_mgr;
- }
- return rc;
- err_init_clk_mgr:
- err_get_clk_mgr_ops:
- return rc;
- }
- int mmrm_deinit(struct mmrm_driver_data *drv_data)
- {
- int rc = 0;
- if (!drv_data || !drv_data->clk_mgr_ops ||
- !drv_data->clk_mgr_ops->destroy_clk_mgr) {
- d_mpr_e("%s: invalid driver data or clk mgr ops\n", __func__);
- return -EINVAL;
- }
- /* destroy clock resource mgr */
- rc = drv_data->clk_mgr_ops->destroy_clk_mgr(drv_data->clk_mgr);
- if (rc) {
- d_mpr_e("%s: destroy clk mgr failed\n", __func__);
- drv_data->clk_mgr = NULL;
- }
- return rc;
- }
|