Lines Matching +full:sun9i +full:- +full:a80 +full:- +full:mmc +full:- +full:config +full:- +full:clk

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright 2015 Chen-Yu Tsai
5 * Chen-Yu Tsai <wens@csie.org>
8 #include <linux/clk.h>
9 #include <linux/clk-provider.h>
16 #include <linux/reset-controller.h>
28 struct clk *clk; member
41 void __iomem *reg = data->membase + SUN9I_MMC_WIDTH * id; in sun9i_mmc_reset_assert()
44 clk_prepare_enable(data->clk); in sun9i_mmc_reset_assert()
45 spin_lock_irqsave(&data->lock, flags); in sun9i_mmc_reset_assert()
50 spin_unlock_irqrestore(&data->lock, flags); in sun9i_mmc_reset_assert()
51 clk_disable_unprepare(data->clk); in sun9i_mmc_reset_assert()
63 void __iomem *reg = data->membase + SUN9I_MMC_WIDTH * id; in sun9i_mmc_reset_deassert()
66 clk_prepare_enable(data->clk); in sun9i_mmc_reset_deassert()
67 spin_lock_irqsave(&data->lock, flags); in sun9i_mmc_reset_deassert()
72 spin_unlock_irqrestore(&data->lock, flags); in sun9i_mmc_reset_deassert()
73 clk_disable_unprepare(data->clk); in sun9i_mmc_reset_deassert()
96 struct device_node *np = pdev->dev.of_node; in sun9i_a80_mmc_config_clk_probe()
99 const char *clk_name = np->name; in sun9i_a80_mmc_config_clk_probe()
104 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); in sun9i_a80_mmc_config_clk_probe()
106 return -ENOMEM; in sun9i_a80_mmc_config_clk_probe()
108 spin_lock_init(&data->lock); in sun9i_a80_mmc_config_clk_probe()
110 data->membase = devm_platform_get_and_ioremap_resource(pdev, 0, &r); in sun9i_a80_mmc_config_clk_probe()
111 if (IS_ERR(data->membase)) in sun9i_a80_mmc_config_clk_probe()
112 return PTR_ERR(data->membase); in sun9i_a80_mmc_config_clk_probe()
117 clk_data = &data->clk_data; in sun9i_a80_mmc_config_clk_probe()
118 clk_data->clk_num = count; in sun9i_a80_mmc_config_clk_probe()
119 clk_data->clks = devm_kcalloc(&pdev->dev, count, sizeof(struct clk *), in sun9i_a80_mmc_config_clk_probe()
121 if (!clk_data->clks) in sun9i_a80_mmc_config_clk_probe()
122 return -ENOMEM; in sun9i_a80_mmc_config_clk_probe()
124 data->clk = devm_clk_get(&pdev->dev, NULL); in sun9i_a80_mmc_config_clk_probe()
125 if (IS_ERR(data->clk)) { in sun9i_a80_mmc_config_clk_probe()
126 dev_err(&pdev->dev, "Could not get clock\n"); in sun9i_a80_mmc_config_clk_probe()
127 return PTR_ERR(data->clk); in sun9i_a80_mmc_config_clk_probe()
130 data->reset = devm_reset_control_get_exclusive(&pdev->dev, NULL); in sun9i_a80_mmc_config_clk_probe()
131 if (IS_ERR(data->reset)) { in sun9i_a80_mmc_config_clk_probe()
132 dev_err(&pdev->dev, "Could not get reset control\n"); in sun9i_a80_mmc_config_clk_probe()
133 return PTR_ERR(data->reset); in sun9i_a80_mmc_config_clk_probe()
136 ret = reset_control_deassert(data->reset); in sun9i_a80_mmc_config_clk_probe()
138 dev_err(&pdev->dev, "Reset deassert err %d\n", ret); in sun9i_a80_mmc_config_clk_probe()
142 clk_parent = __clk_get_name(data->clk); in sun9i_a80_mmc_config_clk_probe()
144 of_property_read_string_index(np, "clock-output-names", in sun9i_a80_mmc_config_clk_probe()
147 clk_data->clks[i] = clk_register_gate(&pdev->dev, clk_name, in sun9i_a80_mmc_config_clk_probe()
149 data->membase + SUN9I_MMC_WIDTH * i, in sun9i_a80_mmc_config_clk_probe()
151 &data->lock); in sun9i_a80_mmc_config_clk_probe()
153 if (IS_ERR(clk_data->clks[i])) { in sun9i_a80_mmc_config_clk_probe()
154 ret = PTR_ERR(clk_data->clks[i]); in sun9i_a80_mmc_config_clk_probe()
163 data->rcdev.owner = THIS_MODULE; in sun9i_a80_mmc_config_clk_probe()
164 data->rcdev.nr_resets = count; in sun9i_a80_mmc_config_clk_probe()
165 data->rcdev.ops = &sun9i_mmc_reset_ops; in sun9i_a80_mmc_config_clk_probe()
166 data->rcdev.of_node = pdev->dev.of_node; in sun9i_a80_mmc_config_clk_probe()
168 ret = reset_controller_register(&data->rcdev); in sun9i_a80_mmc_config_clk_probe()
181 clk_unregister(clk_data->clks[i]); in sun9i_a80_mmc_config_clk_probe()
184 reset_control_assert(data->reset); in sun9i_a80_mmc_config_clk_probe()
190 { .compatible = "allwinner,sun9i-a80-mmc-config-clk" },
196 .name = "sun9i-a80-mmc-config-clk",