xref: /linux/drivers/bus/qcom-ssc-block-bus.c (revision ea7964a660aee352f6dedaea28e1eb05c8b51efe)
197d485edSMichael Srba // SPDX-License-Identifier: GPL-2.0-only
297d485edSMichael Srba // Copyright (c) 2021, Michael Srba
397d485edSMichael Srba 
497d485edSMichael Srba #include <linux/clk.h>
597d485edSMichael Srba #include <linux/delay.h>
697d485edSMichael Srba #include <linux/io.h>
797d485edSMichael Srba #include <linux/mfd/syscon.h>
897d485edSMichael Srba #include <linux/module.h>
997d485edSMichael Srba #include <linux/of_platform.h>
1097d485edSMichael Srba #include <linux/platform_device.h>
1197d485edSMichael Srba #include <linux/pm_clock.h>
1297d485edSMichael Srba #include <linux/pm_domain.h>
1397d485edSMichael Srba #include <linux/pm_runtime.h>
1497d485edSMichael Srba #include <linux/regmap.h>
1597d485edSMichael Srba #include <linux/reset.h>
1697d485edSMichael Srba 
1797d485edSMichael Srba /* AXI Halt Register Offsets */
1897d485edSMichael Srba #define AXI_HALTREQ_REG			0x0
1997d485edSMichael Srba #define AXI_HALTACK_REG			0x4
2097d485edSMichael Srba #define AXI_IDLE_REG			0x8
2197d485edSMichael Srba 
2297d485edSMichael Srba #define SSCAON_CONFIG0_CLAMP_EN_OVRD		BIT(4)
2397d485edSMichael Srba #define SSCAON_CONFIG0_CLAMP_EN_OVRD_VAL	BIT(5)
2497d485edSMichael Srba 
2597d485edSMichael Srba static const char *const qcom_ssc_block_pd_names[] = {
2697d485edSMichael Srba 	"ssc_cx",
2797d485edSMichael Srba 	"ssc_mx"
2897d485edSMichael Srba };
2997d485edSMichael Srba 
3097d485edSMichael Srba struct qcom_ssc_block_bus_data {
3197d485edSMichael Srba 	const char *const *pd_names;
3297d485edSMichael Srba 	struct device *pds[ARRAY_SIZE(qcom_ssc_block_pd_names)];
3397d485edSMichael Srba 	char __iomem *reg_mpm_sscaon_config0;
3497d485edSMichael Srba 	char __iomem *reg_mpm_sscaon_config1;
3597d485edSMichael Srba 	struct regmap *halt_map;
3697d485edSMichael Srba 	struct clk *xo_clk;
3797d485edSMichael Srba 	struct clk *aggre2_clk;
3897d485edSMichael Srba 	struct clk *gcc_im_sleep_clk;
3997d485edSMichael Srba 	struct clk *aggre2_north_clk;
4097d485edSMichael Srba 	struct clk *ssc_xo_clk;
4197d485edSMichael Srba 	struct clk *ssc_ahbs_clk;
4297d485edSMichael Srba 	struct reset_control *ssc_bcr;
4397d485edSMichael Srba 	struct reset_control *ssc_reset;
4497d485edSMichael Srba 	u32 ssc_axi_halt;
4597d485edSMichael Srba 	int num_pds;
4697d485edSMichael Srba };
4797d485edSMichael Srba 
4897d485edSMichael Srba static void reg32_set_bits(char __iomem *reg, u32 value)
4997d485edSMichael Srba {
5097d485edSMichael Srba 	u32 tmp = ioread32(reg);
5197d485edSMichael Srba 
5297d485edSMichael Srba 	iowrite32(tmp | value, reg);
5397d485edSMichael Srba }
5497d485edSMichael Srba 
5597d485edSMichael Srba static void reg32_clear_bits(char __iomem *reg, u32 value)
5697d485edSMichael Srba {
5797d485edSMichael Srba 	u32 tmp = ioread32(reg);
5897d485edSMichael Srba 
5997d485edSMichael Srba 	iowrite32(tmp & (~value), reg);
6097d485edSMichael Srba }
6197d485edSMichael Srba 
6297d485edSMichael Srba static int qcom_ssc_block_bus_init(struct device *dev)
6397d485edSMichael Srba {
6497d485edSMichael Srba 	int ret;
6597d485edSMichael Srba 
6697d485edSMichael Srba 	struct qcom_ssc_block_bus_data *data = dev_get_drvdata(dev);
6797d485edSMichael Srba 
6897d485edSMichael Srba 	ret = clk_prepare_enable(data->xo_clk);
6997d485edSMichael Srba 	if (ret) {
7097d485edSMichael Srba 		dev_err(dev, "error enabling xo_clk: %d\n", ret);
7197d485edSMichael Srba 		goto err_xo_clk;
7297d485edSMichael Srba 	}
7397d485edSMichael Srba 
7497d485edSMichael Srba 	ret = clk_prepare_enable(data->aggre2_clk);
7597d485edSMichael Srba 	if (ret) {
7697d485edSMichael Srba 		dev_err(dev, "error enabling aggre2_clk: %d\n", ret);
7797d485edSMichael Srba 		goto err_aggre2_clk;
7897d485edSMichael Srba 	}
7997d485edSMichael Srba 
8097d485edSMichael Srba 	ret = clk_prepare_enable(data->gcc_im_sleep_clk);
8197d485edSMichael Srba 	if (ret) {
8297d485edSMichael Srba 		dev_err(dev, "error enabling gcc_im_sleep_clk: %d\n", ret);
8397d485edSMichael Srba 		goto err_gcc_im_sleep_clk;
8497d485edSMichael Srba 	}
8597d485edSMichael Srba 
8697d485edSMichael Srba 	/*
8797d485edSMichael Srba 	 * We need to intervene here because the HW logic driving these signals cannot handle
8897d485edSMichael Srba 	 * initialization after power collapse by itself.
8997d485edSMichael Srba 	 */
9097d485edSMichael Srba 	reg32_clear_bits(data->reg_mpm_sscaon_config0,
9197d485edSMichael Srba 			 SSCAON_CONFIG0_CLAMP_EN_OVRD | SSCAON_CONFIG0_CLAMP_EN_OVRD_VAL);
9297d485edSMichael Srba 	/* override few_ack/rest_ack */
9397d485edSMichael Srba 	reg32_clear_bits(data->reg_mpm_sscaon_config1, BIT(31));
9497d485edSMichael Srba 
9597d485edSMichael Srba 	ret = clk_prepare_enable(data->aggre2_north_clk);
9697d485edSMichael Srba 	if (ret) {
9797d485edSMichael Srba 		dev_err(dev, "error enabling aggre2_north_clk: %d\n", ret);
9897d485edSMichael Srba 		goto err_aggre2_north_clk;
9997d485edSMichael Srba 	}
10097d485edSMichael Srba 
10197d485edSMichael Srba 	ret = reset_control_deassert(data->ssc_reset);
10297d485edSMichael Srba 	if (ret) {
10397d485edSMichael Srba 		dev_err(dev, "error deasserting ssc_reset: %d\n", ret);
10497d485edSMichael Srba 		goto err_ssc_reset;
10597d485edSMichael Srba 	}
10697d485edSMichael Srba 
10797d485edSMichael Srba 	ret = reset_control_deassert(data->ssc_bcr);
10897d485edSMichael Srba 	if (ret) {
10997d485edSMichael Srba 		dev_err(dev, "error deasserting ssc_bcr: %d\n", ret);
11097d485edSMichael Srba 		goto err_ssc_bcr;
11197d485edSMichael Srba 	}
11297d485edSMichael Srba 
11397d485edSMichael Srba 	regmap_write(data->halt_map, data->ssc_axi_halt + AXI_HALTREQ_REG, 0);
11497d485edSMichael Srba 
11597d485edSMichael Srba 	ret = clk_prepare_enable(data->ssc_xo_clk);
11697d485edSMichael Srba 	if (ret) {
11797d485edSMichael Srba 		dev_err(dev, "error deasserting ssc_xo_clk: %d\n", ret);
11897d485edSMichael Srba 		goto err_ssc_xo_clk;
11997d485edSMichael Srba 	}
12097d485edSMichael Srba 
12197d485edSMichael Srba 	ret = clk_prepare_enable(data->ssc_ahbs_clk);
12297d485edSMichael Srba 	if (ret) {
12397d485edSMichael Srba 		dev_err(dev, "error deasserting ssc_ahbs_clk: %d\n", ret);
12497d485edSMichael Srba 		goto err_ssc_ahbs_clk;
12597d485edSMichael Srba 	}
12697d485edSMichael Srba 
12797d485edSMichael Srba 	return 0;
12897d485edSMichael Srba 
12997d485edSMichael Srba err_ssc_ahbs_clk:
13097d485edSMichael Srba 	clk_disable(data->ssc_xo_clk);
13197d485edSMichael Srba 
13297d485edSMichael Srba err_ssc_xo_clk:
13397d485edSMichael Srba 	regmap_write(data->halt_map, data->ssc_axi_halt + AXI_HALTREQ_REG, 1);
13497d485edSMichael Srba 
13597d485edSMichael Srba 	reset_control_assert(data->ssc_bcr);
13697d485edSMichael Srba 
13797d485edSMichael Srba err_ssc_bcr:
13897d485edSMichael Srba 	reset_control_assert(data->ssc_reset);
13997d485edSMichael Srba 
14097d485edSMichael Srba err_ssc_reset:
14197d485edSMichael Srba 	clk_disable(data->aggre2_north_clk);
14297d485edSMichael Srba 
14397d485edSMichael Srba err_aggre2_north_clk:
14497d485edSMichael Srba 	reg32_set_bits(data->reg_mpm_sscaon_config0, BIT(4) | BIT(5));
14597d485edSMichael Srba 	reg32_set_bits(data->reg_mpm_sscaon_config1, BIT(31));
14697d485edSMichael Srba 
14797d485edSMichael Srba 	clk_disable(data->gcc_im_sleep_clk);
14897d485edSMichael Srba 
14997d485edSMichael Srba err_gcc_im_sleep_clk:
15097d485edSMichael Srba 	clk_disable(data->aggre2_clk);
15197d485edSMichael Srba 
15297d485edSMichael Srba err_aggre2_clk:
15397d485edSMichael Srba 	clk_disable(data->xo_clk);
15497d485edSMichael Srba 
15597d485edSMichael Srba err_xo_clk:
15697d485edSMichael Srba 	return ret;
15797d485edSMichael Srba }
15897d485edSMichael Srba 
15997d485edSMichael Srba static void qcom_ssc_block_bus_deinit(struct device *dev)
16097d485edSMichael Srba {
16197d485edSMichael Srba 	int ret;
16297d485edSMichael Srba 
16397d485edSMichael Srba 	struct qcom_ssc_block_bus_data *data = dev_get_drvdata(dev);
16497d485edSMichael Srba 
16597d485edSMichael Srba 	clk_disable(data->ssc_xo_clk);
16697d485edSMichael Srba 	clk_disable(data->ssc_ahbs_clk);
16797d485edSMichael Srba 
16897d485edSMichael Srba 	ret = reset_control_assert(data->ssc_bcr);
16997d485edSMichael Srba 	if (ret)
17097d485edSMichael Srba 		dev_err(dev, "error asserting ssc_bcr: %d\n", ret);
17197d485edSMichael Srba 
17297d485edSMichael Srba 	regmap_write(data->halt_map, data->ssc_axi_halt + AXI_HALTREQ_REG, 1);
17397d485edSMichael Srba 
17497d485edSMichael Srba 	reg32_set_bits(data->reg_mpm_sscaon_config1, BIT(31));
17597d485edSMichael Srba 	reg32_set_bits(data->reg_mpm_sscaon_config0, BIT(4) | BIT(5));
17697d485edSMichael Srba 
17797d485edSMichael Srba 	ret = reset_control_assert(data->ssc_reset);
17897d485edSMichael Srba 	if (ret)
17997d485edSMichael Srba 		dev_err(dev, "error asserting ssc_reset: %d\n", ret);
18097d485edSMichael Srba 
18197d485edSMichael Srba 	clk_disable(data->gcc_im_sleep_clk);
18297d485edSMichael Srba 
18397d485edSMichael Srba 	clk_disable(data->aggre2_north_clk);
18497d485edSMichael Srba 
18597d485edSMichael Srba 	clk_disable(data->aggre2_clk);
18697d485edSMichael Srba 	clk_disable(data->xo_clk);
18797d485edSMichael Srba }
18897d485edSMichael Srba 
18997d485edSMichael Srba static int qcom_ssc_block_bus_pds_attach(struct device *dev, struct device **pds,
19097d485edSMichael Srba 					 const char *const *pd_names, size_t num_pds)
19197d485edSMichael Srba {
19297d485edSMichael Srba 	int ret;
19397d485edSMichael Srba 	int i;
19497d485edSMichael Srba 
19597d485edSMichael Srba 	for (i = 0; i < num_pds; i++) {
19697d485edSMichael Srba 		pds[i] = dev_pm_domain_attach_by_name(dev, pd_names[i]);
19797d485edSMichael Srba 		if (IS_ERR_OR_NULL(pds[i])) {
19897d485edSMichael Srba 			ret = PTR_ERR(pds[i]) ? : -ENODATA;
19997d485edSMichael Srba 			goto unroll_attach;
20097d485edSMichael Srba 		}
20197d485edSMichael Srba 	}
20297d485edSMichael Srba 
20397d485edSMichael Srba 	return num_pds;
20497d485edSMichael Srba 
20597d485edSMichael Srba unroll_attach:
20697d485edSMichael Srba 	for (i--; i >= 0; i--)
20797d485edSMichael Srba 		dev_pm_domain_detach(pds[i], false);
20897d485edSMichael Srba 
20997d485edSMichael Srba 	return ret;
21097d485edSMichael Srba };
21197d485edSMichael Srba 
21297d485edSMichael Srba static void qcom_ssc_block_bus_pds_detach(struct device *dev, struct device **pds, size_t num_pds)
21397d485edSMichael Srba {
21497d485edSMichael Srba 	int i;
21597d485edSMichael Srba 
21697d485edSMichael Srba 	for (i = 0; i < num_pds; i++)
21797d485edSMichael Srba 		dev_pm_domain_detach(pds[i], false);
21897d485edSMichael Srba }
21997d485edSMichael Srba 
22097d485edSMichael Srba static int qcom_ssc_block_bus_pds_enable(struct device **pds, size_t num_pds)
22197d485edSMichael Srba {
22297d485edSMichael Srba 	int ret;
22397d485edSMichael Srba 	int i;
22497d485edSMichael Srba 
22597d485edSMichael Srba 	for (i = 0; i < num_pds; i++) {
22697d485edSMichael Srba 		dev_pm_genpd_set_performance_state(pds[i], INT_MAX);
22797d485edSMichael Srba 		ret = pm_runtime_get_sync(pds[i]);
22897d485edSMichael Srba 		if (ret < 0)
22997d485edSMichael Srba 			goto unroll_pd_votes;
23097d485edSMichael Srba 	}
23197d485edSMichael Srba 
23297d485edSMichael Srba 	return 0;
23397d485edSMichael Srba 
23497d485edSMichael Srba unroll_pd_votes:
23597d485edSMichael Srba 	for (i--; i >= 0; i--) {
23697d485edSMichael Srba 		dev_pm_genpd_set_performance_state(pds[i], 0);
23797d485edSMichael Srba 		pm_runtime_put(pds[i]);
23897d485edSMichael Srba 	}
23997d485edSMichael Srba 
24097d485edSMichael Srba 	return ret;
24197d485edSMichael Srba };
24297d485edSMichael Srba 
24397d485edSMichael Srba static void qcom_ssc_block_bus_pds_disable(struct device **pds, size_t num_pds)
24497d485edSMichael Srba {
24597d485edSMichael Srba 	int i;
24697d485edSMichael Srba 
24797d485edSMichael Srba 	for (i = 0; i < num_pds; i++) {
24897d485edSMichael Srba 		dev_pm_genpd_set_performance_state(pds[i], 0);
24997d485edSMichael Srba 		pm_runtime_put(pds[i]);
25097d485edSMichael Srba 	}
25197d485edSMichael Srba }
25297d485edSMichael Srba 
25397d485edSMichael Srba static int qcom_ssc_block_bus_probe(struct platform_device *pdev)
25497d485edSMichael Srba {
25597d485edSMichael Srba 	struct qcom_ssc_block_bus_data *data;
25697d485edSMichael Srba 	struct device_node *np = pdev->dev.of_node;
25797d485edSMichael Srba 	struct of_phandle_args halt_args;
25897d485edSMichael Srba 	struct resource *res;
25997d485edSMichael Srba 	int ret;
26097d485edSMichael Srba 
26197d485edSMichael Srba 	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
26297d485edSMichael Srba 	if (!data)
26397d485edSMichael Srba 		return -ENOMEM;
26497d485edSMichael Srba 
26597d485edSMichael Srba 	platform_set_drvdata(pdev, data);
26697d485edSMichael Srba 
26797d485edSMichael Srba 	data->pd_names = qcom_ssc_block_pd_names;
26897d485edSMichael Srba 	data->num_pds = ARRAY_SIZE(qcom_ssc_block_pd_names);
26997d485edSMichael Srba 
27097d485edSMichael Srba 	/* power domains */
27197d485edSMichael Srba 	ret = qcom_ssc_block_bus_pds_attach(&pdev->dev, data->pds, data->pd_names, data->num_pds);
27297d485edSMichael Srba 	if (ret < 0)
27397d485edSMichael Srba 		return dev_err_probe(&pdev->dev, ret, "error when attaching power domains\n");
27497d485edSMichael Srba 
27597d485edSMichael Srba 	ret = qcom_ssc_block_bus_pds_enable(data->pds, data->num_pds);
27697d485edSMichael Srba 	if (ret < 0)
27797d485edSMichael Srba 		return dev_err_probe(&pdev->dev, ret, "error when enabling power domains\n");
27897d485edSMichael Srba 
27997d485edSMichael Srba 	/* low level overrides for when the HW logic doesn't "just work" */
28097d485edSMichael Srba 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpm_sscaon_config0");
28197d485edSMichael Srba 	data->reg_mpm_sscaon_config0 = devm_ioremap_resource(&pdev->dev, res);
28297d485edSMichael Srba 	if (IS_ERR(data->reg_mpm_sscaon_config0))
28397d485edSMichael Srba 		return dev_err_probe(&pdev->dev, PTR_ERR(data->reg_mpm_sscaon_config0),
28497d485edSMichael Srba 				     "Failed to ioremap mpm_sscaon_config0\n");
28597d485edSMichael Srba 
28697d485edSMichael Srba 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpm_sscaon_config1");
28797d485edSMichael Srba 	data->reg_mpm_sscaon_config1 = devm_ioremap_resource(&pdev->dev, res);
28897d485edSMichael Srba 	if (IS_ERR(data->reg_mpm_sscaon_config1))
28997d485edSMichael Srba 		return dev_err_probe(&pdev->dev, PTR_ERR(data->reg_mpm_sscaon_config1),
29097d485edSMichael Srba 				     "Failed to ioremap mpm_sscaon_config1\n");
29197d485edSMichael Srba 
29297d485edSMichael Srba 	/* resets */
29397d485edSMichael Srba 	data->ssc_bcr = devm_reset_control_get_exclusive(&pdev->dev, "ssc_bcr");
29497d485edSMichael Srba 	if (IS_ERR(data->ssc_bcr))
29597d485edSMichael Srba 		return dev_err_probe(&pdev->dev, PTR_ERR(data->ssc_bcr),
29697d485edSMichael Srba 				     "Failed to acquire reset: scc_bcr\n");
29797d485edSMichael Srba 
29897d485edSMichael Srba 	data->ssc_reset = devm_reset_control_get_exclusive(&pdev->dev, "ssc_reset");
29997d485edSMichael Srba 	if (IS_ERR(data->ssc_reset))
30097d485edSMichael Srba 		return dev_err_probe(&pdev->dev, PTR_ERR(data->ssc_reset),
30197d485edSMichael Srba 				     "Failed to acquire reset: ssc_reset:\n");
30297d485edSMichael Srba 
30397d485edSMichael Srba 	/* clocks */
30497d485edSMichael Srba 	data->xo_clk = devm_clk_get(&pdev->dev, "xo");
30597d485edSMichael Srba 	if (IS_ERR(data->xo_clk))
30697d485edSMichael Srba 		return dev_err_probe(&pdev->dev, PTR_ERR(data->xo_clk),
30797d485edSMichael Srba 				     "Failed to get clock: xo\n");
30897d485edSMichael Srba 
30997d485edSMichael Srba 	data->aggre2_clk = devm_clk_get(&pdev->dev, "aggre2");
31097d485edSMichael Srba 	if (IS_ERR(data->aggre2_clk))
31197d485edSMichael Srba 		return dev_err_probe(&pdev->dev, PTR_ERR(data->aggre2_clk),
31297d485edSMichael Srba 				     "Failed to get clock: aggre2\n");
31397d485edSMichael Srba 
31497d485edSMichael Srba 	data->gcc_im_sleep_clk = devm_clk_get(&pdev->dev, "gcc_im_sleep");
31597d485edSMichael Srba 	if (IS_ERR(data->gcc_im_sleep_clk))
31697d485edSMichael Srba 		return dev_err_probe(&pdev->dev, PTR_ERR(data->gcc_im_sleep_clk),
31797d485edSMichael Srba 				     "Failed to get clock: gcc_im_sleep\n");
31897d485edSMichael Srba 
31997d485edSMichael Srba 	data->aggre2_north_clk = devm_clk_get(&pdev->dev, "aggre2_north");
32097d485edSMichael Srba 	if (IS_ERR(data->aggre2_north_clk))
32197d485edSMichael Srba 		return dev_err_probe(&pdev->dev, PTR_ERR(data->aggre2_north_clk),
32297d485edSMichael Srba 				     "Failed to get clock: aggre2_north\n");
32397d485edSMichael Srba 
32497d485edSMichael Srba 	data->ssc_xo_clk = devm_clk_get(&pdev->dev, "ssc_xo");
32597d485edSMichael Srba 	if (IS_ERR(data->ssc_xo_clk))
32697d485edSMichael Srba 		return dev_err_probe(&pdev->dev, PTR_ERR(data->ssc_xo_clk),
32797d485edSMichael Srba 				     "Failed to get clock: ssc_xo\n");
32897d485edSMichael Srba 
32997d485edSMichael Srba 	data->ssc_ahbs_clk = devm_clk_get(&pdev->dev, "ssc_ahbs");
33097d485edSMichael Srba 	if (IS_ERR(data->ssc_ahbs_clk))
33197d485edSMichael Srba 		return dev_err_probe(&pdev->dev, PTR_ERR(data->ssc_ahbs_clk),
33297d485edSMichael Srba 				     "Failed to get clock: ssc_ahbs\n");
33397d485edSMichael Srba 
33497d485edSMichael Srba 	ret = of_parse_phandle_with_fixed_args(pdev->dev.of_node, "qcom,halt-regs", 1, 0,
33597d485edSMichael Srba 					       &halt_args);
33697d485edSMichael Srba 	if (ret < 0)
33797d485edSMichael Srba 		return dev_err_probe(&pdev->dev, ret, "Failed to parse qcom,halt-regs\n");
33897d485edSMichael Srba 
33997d485edSMichael Srba 	data->halt_map = syscon_node_to_regmap(halt_args.np);
34097d485edSMichael Srba 	of_node_put(halt_args.np);
34197d485edSMichael Srba 	if (IS_ERR(data->halt_map))
34297d485edSMichael Srba 		return PTR_ERR(data->halt_map);
34397d485edSMichael Srba 
34497d485edSMichael Srba 	data->ssc_axi_halt = halt_args.args[0];
34597d485edSMichael Srba 
34697d485edSMichael Srba 	qcom_ssc_block_bus_init(&pdev->dev);
34797d485edSMichael Srba 
34897d485edSMichael Srba 	of_platform_populate(np, NULL, NULL, &pdev->dev);
34997d485edSMichael Srba 
35097d485edSMichael Srba 	return 0;
35197d485edSMichael Srba }
35297d485edSMichael Srba 
353*ea7964a6SUwe Kleine-König static void qcom_ssc_block_bus_remove(struct platform_device *pdev)
35497d485edSMichael Srba {
35597d485edSMichael Srba 	struct qcom_ssc_block_bus_data *data = platform_get_drvdata(pdev);
35697d485edSMichael Srba 
35797d485edSMichael Srba 	qcom_ssc_block_bus_deinit(&pdev->dev);
35897d485edSMichael Srba 
35997d485edSMichael Srba 	iounmap(data->reg_mpm_sscaon_config0);
36097d485edSMichael Srba 	iounmap(data->reg_mpm_sscaon_config1);
36197d485edSMichael Srba 
36297d485edSMichael Srba 	qcom_ssc_block_bus_pds_disable(data->pds, data->num_pds);
36397d485edSMichael Srba 	qcom_ssc_block_bus_pds_detach(&pdev->dev, data->pds, data->num_pds);
36497d485edSMichael Srba 	pm_runtime_disable(&pdev->dev);
36597d485edSMichael Srba 	pm_clk_destroy(&pdev->dev);
36697d485edSMichael Srba }
36797d485edSMichael Srba 
36897d485edSMichael Srba static const struct of_device_id qcom_ssc_block_bus_of_match[] = {
36997d485edSMichael Srba 	{ .compatible = "qcom,ssc-block-bus", },
37097d485edSMichael Srba 	{ /* sentinel */ }
37197d485edSMichael Srba };
37297d485edSMichael Srba MODULE_DEVICE_TABLE(of, qcom_ssc_block_bus_of_match);
37397d485edSMichael Srba 
37497d485edSMichael Srba static struct platform_driver qcom_ssc_block_bus_driver = {
37597d485edSMichael Srba 	.probe = qcom_ssc_block_bus_probe,
376*ea7964a6SUwe Kleine-König 	.remove_new = qcom_ssc_block_bus_remove,
37797d485edSMichael Srba 	.driver = {
37897d485edSMichael Srba 		.name = "qcom-ssc-block-bus",
37997d485edSMichael Srba 		.of_match_table = qcom_ssc_block_bus_of_match,
38097d485edSMichael Srba 	},
38197d485edSMichael Srba };
38297d485edSMichael Srba 
38397d485edSMichael Srba module_platform_driver(qcom_ssc_block_bus_driver);
38497d485edSMichael Srba 
38597d485edSMichael Srba MODULE_DESCRIPTION("A driver for handling the init sequence needed for accessing the SSC block on (some) qcom SoCs over AHB");
38697d485edSMichael Srba MODULE_AUTHOR("Michael Srba <Michael.Srba@seznam.cz>");
387