1992a56e4SMaxime Ripard /* 2992a56e4SMaxime Ripard * Copyright 2013 Emilio López 3992a56e4SMaxime Ripard * 4992a56e4SMaxime Ripard * Emilio López <emilio@elopez.com.ar> 5992a56e4SMaxime Ripard * 6992a56e4SMaxime Ripard * This program is free software; you can redistribute it and/or modify 7992a56e4SMaxime Ripard * it under the terms of the GNU General Public License as published by 8992a56e4SMaxime Ripard * the Free Software Foundation; either version 2 of the License, or 9992a56e4SMaxime Ripard * (at your option) any later version. 10992a56e4SMaxime Ripard * 11992a56e4SMaxime Ripard * This program is distributed in the hope that it will be useful, 12992a56e4SMaxime Ripard * but WITHOUT ANY WARRANTY; without even the implied warranty of 13992a56e4SMaxime Ripard * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14992a56e4SMaxime Ripard * GNU General Public License for more details. 15992a56e4SMaxime Ripard */ 16992a56e4SMaxime Ripard 17*9dfefe8cSStephen Boyd #include <linux/clk.h> 18992a56e4SMaxime Ripard #include <linux/clk-provider.h> 1937e1041fSMaxime Ripard #include <linux/of_address.h> 206ea3953dSHans de Goede #include <linux/platform_device.h> 21*9dfefe8cSStephen Boyd #include <linux/slab.h> 22992a56e4SMaxime Ripard 23992a56e4SMaxime Ripard #include "clk-factors.h" 24992a56e4SMaxime Ripard 25992a56e4SMaxime Ripard /** 26992a56e4SMaxime Ripard * sun4i_get_mod0_factors() - calculates m, n factors for MOD0-style clocks 27992a56e4SMaxime Ripard * MOD0 rate is calculated as follows 28992a56e4SMaxime Ripard * rate = (parent_rate >> p) / (m + 1); 29992a56e4SMaxime Ripard */ 30992a56e4SMaxime Ripard 31992a56e4SMaxime Ripard static void sun4i_a10_get_mod0_factors(u32 *freq, u32 parent_rate, 32992a56e4SMaxime Ripard u8 *n, u8 *k, u8 *m, u8 *p) 33992a56e4SMaxime Ripard { 34992a56e4SMaxime Ripard u8 div, calcm, calcp; 35992a56e4SMaxime Ripard 36992a56e4SMaxime Ripard /* These clocks can only divide, so we will never be able to achieve 37992a56e4SMaxime Ripard * frequencies higher than the parent frequency */ 38992a56e4SMaxime Ripard if (*freq > parent_rate) 39992a56e4SMaxime Ripard *freq = parent_rate; 40992a56e4SMaxime Ripard 41992a56e4SMaxime Ripard div = DIV_ROUND_UP(parent_rate, *freq); 42992a56e4SMaxime Ripard 43992a56e4SMaxime Ripard if (div < 16) 44992a56e4SMaxime Ripard calcp = 0; 45992a56e4SMaxime Ripard else if (div / 2 < 16) 46992a56e4SMaxime Ripard calcp = 1; 47992a56e4SMaxime Ripard else if (div / 4 < 16) 48992a56e4SMaxime Ripard calcp = 2; 49992a56e4SMaxime Ripard else 50992a56e4SMaxime Ripard calcp = 3; 51992a56e4SMaxime Ripard 52992a56e4SMaxime Ripard calcm = DIV_ROUND_UP(div, 1 << calcp); 53992a56e4SMaxime Ripard 54992a56e4SMaxime Ripard *freq = (parent_rate >> calcp) / calcm; 55992a56e4SMaxime Ripard 56992a56e4SMaxime Ripard /* we were called to round the frequency, we can now return */ 57992a56e4SMaxime Ripard if (n == NULL) 58992a56e4SMaxime Ripard return; 59992a56e4SMaxime Ripard 60992a56e4SMaxime Ripard *m = calcm - 1; 61992a56e4SMaxime Ripard *p = calcp; 62992a56e4SMaxime Ripard } 63992a56e4SMaxime Ripard 64992a56e4SMaxime Ripard /* user manual says "n" but it's really "p" */ 65992a56e4SMaxime Ripard static struct clk_factors_config sun4i_a10_mod0_config = { 66992a56e4SMaxime Ripard .mshift = 0, 67992a56e4SMaxime Ripard .mwidth = 4, 68992a56e4SMaxime Ripard .pshift = 16, 69992a56e4SMaxime Ripard .pwidth = 2, 70992a56e4SMaxime Ripard }; 71992a56e4SMaxime Ripard 726ea3953dSHans de Goede static const struct factors_data sun4i_a10_mod0_data = { 73992a56e4SMaxime Ripard .enable = 31, 74992a56e4SMaxime Ripard .mux = 24, 75e94f8cb3SChen-Yu Tsai .muxmask = BIT(1) | BIT(0), 76992a56e4SMaxime Ripard .table = &sun4i_a10_mod0_config, 77992a56e4SMaxime Ripard .getter = sun4i_a10_get_mod0_factors, 78992a56e4SMaxime Ripard }; 79992a56e4SMaxime Ripard 80992a56e4SMaxime Ripard static DEFINE_SPINLOCK(sun4i_a10_mod0_lock); 81992a56e4SMaxime Ripard 82992a56e4SMaxime Ripard static void __init sun4i_a10_mod0_setup(struct device_node *node) 83992a56e4SMaxime Ripard { 847c74c220SHans de Goede void __iomem *reg; 857c74c220SHans de Goede 867c74c220SHans de Goede reg = of_iomap(node, 0); 877c74c220SHans de Goede if (!reg) { 886ea3953dSHans de Goede /* 896ea3953dSHans de Goede * This happens with mod0 clk nodes instantiated through 906ea3953dSHans de Goede * mfd, as those do not have their resources assigned at 916ea3953dSHans de Goede * CLK_OF_DECLARE time yet, so do not print an error. 926ea3953dSHans de Goede */ 937c74c220SHans de Goede return; 947c74c220SHans de Goede } 957c74c220SHans de Goede 967c74c220SHans de Goede sunxi_factors_register(node, &sun4i_a10_mod0_data, 977c74c220SHans de Goede &sun4i_a10_mod0_lock, reg); 98992a56e4SMaxime Ripard } 99992a56e4SMaxime Ripard CLK_OF_DECLARE(sun4i_a10_mod0, "allwinner,sun4i-a10-mod0-clk", sun4i_a10_mod0_setup); 100eaa18f5dSMaxime Ripard 1016ea3953dSHans de Goede static int sun4i_a10_mod0_clk_probe(struct platform_device *pdev) 1026ea3953dSHans de Goede { 1036ea3953dSHans de Goede struct device_node *np = pdev->dev.of_node; 1046ea3953dSHans de Goede struct resource *r; 1056ea3953dSHans de Goede void __iomem *reg; 1066ea3953dSHans de Goede 1076ea3953dSHans de Goede if (!np) 1086ea3953dSHans de Goede return -ENODEV; 1096ea3953dSHans de Goede 1106ea3953dSHans de Goede r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1116ea3953dSHans de Goede reg = devm_ioremap_resource(&pdev->dev, r); 1126ea3953dSHans de Goede if (IS_ERR(reg)) 1136ea3953dSHans de Goede return PTR_ERR(reg); 1146ea3953dSHans de Goede 1156ea3953dSHans de Goede sunxi_factors_register(np, &sun4i_a10_mod0_data, 1166ea3953dSHans de Goede &sun4i_a10_mod0_lock, reg); 1176ea3953dSHans de Goede return 0; 1186ea3953dSHans de Goede } 1196ea3953dSHans de Goede 1206ea3953dSHans de Goede static const struct of_device_id sun4i_a10_mod0_clk_dt_ids[] = { 1216ea3953dSHans de Goede { .compatible = "allwinner,sun4i-a10-mod0-clk" }, 1226ea3953dSHans de Goede { /* sentinel */ } 1236ea3953dSHans de Goede }; 1246ea3953dSHans de Goede 1256ea3953dSHans de Goede static struct platform_driver sun4i_a10_mod0_clk_driver = { 1266ea3953dSHans de Goede .driver = { 1276ea3953dSHans de Goede .name = "sun4i-a10-mod0-clk", 1286ea3953dSHans de Goede .of_match_table = sun4i_a10_mod0_clk_dt_ids, 1296ea3953dSHans de Goede }, 1306ea3953dSHans de Goede .probe = sun4i_a10_mod0_clk_probe, 1316ea3953dSHans de Goede }; 13277459a0fSPaul Gortmaker builtin_platform_driver(sun4i_a10_mod0_clk_driver); 1336ea3953dSHans de Goede 13461af4d8dSChen-Yu Tsai static const struct factors_data sun9i_a80_mod0_data __initconst = { 13561af4d8dSChen-Yu Tsai .enable = 31, 13661af4d8dSChen-Yu Tsai .mux = 24, 13761af4d8dSChen-Yu Tsai .muxmask = BIT(3) | BIT(2) | BIT(1) | BIT(0), 13861af4d8dSChen-Yu Tsai .table = &sun4i_a10_mod0_config, 13961af4d8dSChen-Yu Tsai .getter = sun4i_a10_get_mod0_factors, 14061af4d8dSChen-Yu Tsai }; 14161af4d8dSChen-Yu Tsai 14261af4d8dSChen-Yu Tsai static void __init sun9i_a80_mod0_setup(struct device_node *node) 14361af4d8dSChen-Yu Tsai { 14461af4d8dSChen-Yu Tsai void __iomem *reg; 14561af4d8dSChen-Yu Tsai 14661af4d8dSChen-Yu Tsai reg = of_io_request_and_map(node, 0, of_node_full_name(node)); 14761af4d8dSChen-Yu Tsai if (IS_ERR(reg)) { 14861af4d8dSChen-Yu Tsai pr_err("Could not get registers for mod0-clk: %s\n", 14961af4d8dSChen-Yu Tsai node->name); 15061af4d8dSChen-Yu Tsai return; 15161af4d8dSChen-Yu Tsai } 15261af4d8dSChen-Yu Tsai 15361af4d8dSChen-Yu Tsai sunxi_factors_register(node, &sun9i_a80_mod0_data, 15461af4d8dSChen-Yu Tsai &sun4i_a10_mod0_lock, reg); 15561af4d8dSChen-Yu Tsai } 15661af4d8dSChen-Yu Tsai CLK_OF_DECLARE(sun9i_a80_mod0, "allwinner,sun9i-a80-mod0-clk", sun9i_a80_mod0_setup); 15761af4d8dSChen-Yu Tsai 158eaa18f5dSMaxime Ripard static DEFINE_SPINLOCK(sun5i_a13_mbus_lock); 159eaa18f5dSMaxime Ripard 160eaa18f5dSMaxime Ripard static void __init sun5i_a13_mbus_setup(struct device_node *node) 161eaa18f5dSMaxime Ripard { 1627c74c220SHans de Goede struct clk *mbus; 1637c74c220SHans de Goede void __iomem *reg; 1647c74c220SHans de Goede 1657c74c220SHans de Goede reg = of_iomap(node, 0); 1667c74c220SHans de Goede if (!reg) { 1677c74c220SHans de Goede pr_err("Could not get registers for a13-mbus-clk\n"); 1687c74c220SHans de Goede return; 1697c74c220SHans de Goede } 1707c74c220SHans de Goede 1717c74c220SHans de Goede mbus = sunxi_factors_register(node, &sun4i_a10_mod0_data, 1727c74c220SHans de Goede &sun5i_a13_mbus_lock, reg); 173eaa18f5dSMaxime Ripard 174eaa18f5dSMaxime Ripard /* The MBUS clocks needs to be always enabled */ 175eaa18f5dSMaxime Ripard __clk_get(mbus); 176eaa18f5dSMaxime Ripard clk_prepare_enable(mbus); 177eaa18f5dSMaxime Ripard } 178eaa18f5dSMaxime Ripard CLK_OF_DECLARE(sun5i_a13_mbus, "allwinner,sun5i-a13-mbus-clk", sun5i_a13_mbus_setup); 17937e1041fSMaxime Ripard 18037e1041fSMaxime Ripard struct mmc_phase { 18137e1041fSMaxime Ripard struct clk_hw hw; 1826b0b8ccfSMaxime Ripard u8 offset; 18337e1041fSMaxime Ripard void __iomem *reg; 18437e1041fSMaxime Ripard spinlock_t *lock; 18537e1041fSMaxime Ripard }; 18637e1041fSMaxime Ripard 18737e1041fSMaxime Ripard #define to_mmc_phase(_hw) container_of(_hw, struct mmc_phase, hw) 18837e1041fSMaxime Ripard 18937e1041fSMaxime Ripard static int mmc_get_phase(struct clk_hw *hw) 19037e1041fSMaxime Ripard { 19137e1041fSMaxime Ripard struct clk *mmc, *mmc_parent, *clk = hw->clk; 19237e1041fSMaxime Ripard struct mmc_phase *phase = to_mmc_phase(hw); 19337e1041fSMaxime Ripard unsigned int mmc_rate, mmc_parent_rate; 19437e1041fSMaxime Ripard u16 step, mmc_div; 19537e1041fSMaxime Ripard u32 value; 19637e1041fSMaxime Ripard u8 delay; 19737e1041fSMaxime Ripard 19837e1041fSMaxime Ripard value = readl(phase->reg); 1996b0b8ccfSMaxime Ripard delay = (value >> phase->offset) & 0x3; 20037e1041fSMaxime Ripard 20137e1041fSMaxime Ripard if (!delay) 20237e1041fSMaxime Ripard return 180; 20337e1041fSMaxime Ripard 20437e1041fSMaxime Ripard /* Get the main MMC clock */ 20537e1041fSMaxime Ripard mmc = clk_get_parent(clk); 20637e1041fSMaxime Ripard if (!mmc) 20737e1041fSMaxime Ripard return -EINVAL; 20837e1041fSMaxime Ripard 20937e1041fSMaxime Ripard /* And its rate */ 21037e1041fSMaxime Ripard mmc_rate = clk_get_rate(mmc); 21137e1041fSMaxime Ripard if (!mmc_rate) 21237e1041fSMaxime Ripard return -EINVAL; 21337e1041fSMaxime Ripard 21437e1041fSMaxime Ripard /* Now, get the MMC parent (most likely some PLL) */ 21537e1041fSMaxime Ripard mmc_parent = clk_get_parent(mmc); 21637e1041fSMaxime Ripard if (!mmc_parent) 21737e1041fSMaxime Ripard return -EINVAL; 21837e1041fSMaxime Ripard 21937e1041fSMaxime Ripard /* And its rate */ 22037e1041fSMaxime Ripard mmc_parent_rate = clk_get_rate(mmc_parent); 22137e1041fSMaxime Ripard if (!mmc_parent_rate) 22237e1041fSMaxime Ripard return -EINVAL; 22337e1041fSMaxime Ripard 22437e1041fSMaxime Ripard /* Get MMC clock divider */ 22537e1041fSMaxime Ripard mmc_div = mmc_parent_rate / mmc_rate; 22637e1041fSMaxime Ripard 22737e1041fSMaxime Ripard step = DIV_ROUND_CLOSEST(360, mmc_div); 22837e1041fSMaxime Ripard return delay * step; 22937e1041fSMaxime Ripard } 23037e1041fSMaxime Ripard 23137e1041fSMaxime Ripard static int mmc_set_phase(struct clk_hw *hw, int degrees) 23237e1041fSMaxime Ripard { 23337e1041fSMaxime Ripard struct clk *mmc, *mmc_parent, *clk = hw->clk; 23437e1041fSMaxime Ripard struct mmc_phase *phase = to_mmc_phase(hw); 23537e1041fSMaxime Ripard unsigned int mmc_rate, mmc_parent_rate; 23637e1041fSMaxime Ripard unsigned long flags; 23737e1041fSMaxime Ripard u32 value; 23837e1041fSMaxime Ripard u8 delay; 23937e1041fSMaxime Ripard 24037e1041fSMaxime Ripard /* Get the main MMC clock */ 24137e1041fSMaxime Ripard mmc = clk_get_parent(clk); 24237e1041fSMaxime Ripard if (!mmc) 24337e1041fSMaxime Ripard return -EINVAL; 24437e1041fSMaxime Ripard 24537e1041fSMaxime Ripard /* And its rate */ 24637e1041fSMaxime Ripard mmc_rate = clk_get_rate(mmc); 24737e1041fSMaxime Ripard if (!mmc_rate) 24837e1041fSMaxime Ripard return -EINVAL; 24937e1041fSMaxime Ripard 25037e1041fSMaxime Ripard /* Now, get the MMC parent (most likely some PLL) */ 25137e1041fSMaxime Ripard mmc_parent = clk_get_parent(mmc); 25237e1041fSMaxime Ripard if (!mmc_parent) 25337e1041fSMaxime Ripard return -EINVAL; 25437e1041fSMaxime Ripard 25537e1041fSMaxime Ripard /* And its rate */ 25637e1041fSMaxime Ripard mmc_parent_rate = clk_get_rate(mmc_parent); 25737e1041fSMaxime Ripard if (!mmc_parent_rate) 25837e1041fSMaxime Ripard return -EINVAL; 25937e1041fSMaxime Ripard 26037e1041fSMaxime Ripard if (degrees != 180) { 26137e1041fSMaxime Ripard u16 step, mmc_div; 26237e1041fSMaxime Ripard 26337e1041fSMaxime Ripard /* Get MMC clock divider */ 26437e1041fSMaxime Ripard mmc_div = mmc_parent_rate / mmc_rate; 26537e1041fSMaxime Ripard 26637e1041fSMaxime Ripard /* 26737e1041fSMaxime Ripard * We can only outphase the clocks by multiple of the 26837e1041fSMaxime Ripard * PLL's period. 26937e1041fSMaxime Ripard * 27037e1041fSMaxime Ripard * Since the MMC clock in only a divider, and the 27137e1041fSMaxime Ripard * formula to get the outphasing in degrees is deg = 27237e1041fSMaxime Ripard * 360 * delta / period 27337e1041fSMaxime Ripard * 27437e1041fSMaxime Ripard * If we simplify this formula, we can see that the 27537e1041fSMaxime Ripard * only thing that we're concerned about is the number 27637e1041fSMaxime Ripard * of period we want to outphase our clock from, and 27737e1041fSMaxime Ripard * the divider set by the MMC clock. 27837e1041fSMaxime Ripard */ 27937e1041fSMaxime Ripard step = DIV_ROUND_CLOSEST(360, mmc_div); 28037e1041fSMaxime Ripard delay = DIV_ROUND_CLOSEST(degrees, step); 28137e1041fSMaxime Ripard } else { 28237e1041fSMaxime Ripard delay = 0; 28337e1041fSMaxime Ripard } 28437e1041fSMaxime Ripard 28537e1041fSMaxime Ripard spin_lock_irqsave(phase->lock, flags); 28637e1041fSMaxime Ripard value = readl(phase->reg); 2876b0b8ccfSMaxime Ripard value &= ~GENMASK(phase->offset + 3, phase->offset); 2886b0b8ccfSMaxime Ripard value |= delay << phase->offset; 28937e1041fSMaxime Ripard writel(value, phase->reg); 29037e1041fSMaxime Ripard spin_unlock_irqrestore(phase->lock, flags); 29137e1041fSMaxime Ripard 29237e1041fSMaxime Ripard return 0; 29337e1041fSMaxime Ripard } 29437e1041fSMaxime Ripard 29537e1041fSMaxime Ripard static const struct clk_ops mmc_clk_ops = { 29637e1041fSMaxime Ripard .get_phase = mmc_get_phase, 29737e1041fSMaxime Ripard .set_phase = mmc_set_phase, 29837e1041fSMaxime Ripard }; 29937e1041fSMaxime Ripard 300eb378df7SChen-Yu Tsai /* 301eb378df7SChen-Yu Tsai * sunxi_mmc_setup - Common setup function for mmc module clocks 302eb378df7SChen-Yu Tsai * 303eb378df7SChen-Yu Tsai * The only difference between module clocks on different platforms is the 304eb378df7SChen-Yu Tsai * width of the mux register bits and the valid values, which are passed in 305eb378df7SChen-Yu Tsai * through struct factors_data. The phase clocks parts are identical. 306eb378df7SChen-Yu Tsai */ 307eb378df7SChen-Yu Tsai static void __init sunxi_mmc_setup(struct device_node *node, 308eb378df7SChen-Yu Tsai const struct factors_data *data, 309eb378df7SChen-Yu Tsai spinlock_t *lock) 31037e1041fSMaxime Ripard { 3116b0b8ccfSMaxime Ripard struct clk_onecell_data *clk_data; 3126b0b8ccfSMaxime Ripard const char *parent; 3136b0b8ccfSMaxime Ripard void __iomem *reg; 3146b0b8ccfSMaxime Ripard int i; 3156b0b8ccfSMaxime Ripard 3166b0b8ccfSMaxime Ripard reg = of_io_request_and_map(node, 0, of_node_full_name(node)); 3176b0b8ccfSMaxime Ripard if (IS_ERR(reg)) { 3186b0b8ccfSMaxime Ripard pr_err("Couldn't map the %s clock registers\n", node->name); 3196b0b8ccfSMaxime Ripard return; 3206b0b8ccfSMaxime Ripard } 3216b0b8ccfSMaxime Ripard 3226b0b8ccfSMaxime Ripard clk_data = kmalloc(sizeof(*clk_data), GFP_KERNEL); 3236b0b8ccfSMaxime Ripard if (!clk_data) 3246b0b8ccfSMaxime Ripard return; 3256b0b8ccfSMaxime Ripard 3266b0b8ccfSMaxime Ripard clk_data->clks = kcalloc(3, sizeof(*clk_data->clks), GFP_KERNEL); 3276b0b8ccfSMaxime Ripard if (!clk_data->clks) 3286b0b8ccfSMaxime Ripard goto err_free_data; 3296b0b8ccfSMaxime Ripard 3306b0b8ccfSMaxime Ripard clk_data->clk_num = 3; 331eb378df7SChen-Yu Tsai clk_data->clks[0] = sunxi_factors_register(node, data, lock, reg); 3326b0b8ccfSMaxime Ripard if (!clk_data->clks[0]) 3336b0b8ccfSMaxime Ripard goto err_free_clks; 3346b0b8ccfSMaxime Ripard 3356b0b8ccfSMaxime Ripard parent = __clk_get_name(clk_data->clks[0]); 3366b0b8ccfSMaxime Ripard 3376b0b8ccfSMaxime Ripard for (i = 1; i < 3; i++) { 33837e1041fSMaxime Ripard struct clk_init_data init = { 33937e1041fSMaxime Ripard .num_parents = 1, 3406b0b8ccfSMaxime Ripard .parent_names = &parent, 34137e1041fSMaxime Ripard .ops = &mmc_clk_ops, 34237e1041fSMaxime Ripard }; 34337e1041fSMaxime Ripard struct mmc_phase *phase; 34437e1041fSMaxime Ripard 34537e1041fSMaxime Ripard phase = kmalloc(sizeof(*phase), GFP_KERNEL); 34637e1041fSMaxime Ripard if (!phase) 3476b0b8ccfSMaxime Ripard continue; 34837e1041fSMaxime Ripard 34937e1041fSMaxime Ripard phase->hw.init = &init; 3506b0b8ccfSMaxime Ripard phase->reg = reg; 351eb378df7SChen-Yu Tsai phase->lock = lock; 35237e1041fSMaxime Ripard 3536b0b8ccfSMaxime Ripard if (i == 1) 3546b0b8ccfSMaxime Ripard phase->offset = 8; 3556b0b8ccfSMaxime Ripard else 3566b0b8ccfSMaxime Ripard phase->offset = 20; 35737e1041fSMaxime Ripard 3586b0b8ccfSMaxime Ripard if (of_property_read_string_index(node, "clock-output-names", 3596b0b8ccfSMaxime Ripard i, &init.name)) 36037e1041fSMaxime Ripard init.name = node->name; 36137e1041fSMaxime Ripard 3626b0b8ccfSMaxime Ripard clk_data->clks[i] = clk_register(NULL, &phase->hw); 3636b0b8ccfSMaxime Ripard if (IS_ERR(clk_data->clks[i])) { 3646b0b8ccfSMaxime Ripard kfree(phase); 3656b0b8ccfSMaxime Ripard continue; 3666b0b8ccfSMaxime Ripard } 3676b0b8ccfSMaxime Ripard } 36837e1041fSMaxime Ripard 3696b0b8ccfSMaxime Ripard of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); 37037e1041fSMaxime Ripard 37137e1041fSMaxime Ripard return; 37237e1041fSMaxime Ripard 3736b0b8ccfSMaxime Ripard err_free_clks: 3746b0b8ccfSMaxime Ripard kfree(clk_data->clks); 3756b0b8ccfSMaxime Ripard err_free_data: 3766b0b8ccfSMaxime Ripard kfree(clk_data); 37737e1041fSMaxime Ripard } 378eb378df7SChen-Yu Tsai 379eb378df7SChen-Yu Tsai static DEFINE_SPINLOCK(sun4i_a10_mmc_lock); 380eb378df7SChen-Yu Tsai 381eb378df7SChen-Yu Tsai static void __init sun4i_a10_mmc_setup(struct device_node *node) 382eb378df7SChen-Yu Tsai { 383eb378df7SChen-Yu Tsai sunxi_mmc_setup(node, &sun4i_a10_mod0_data, &sun4i_a10_mmc_lock); 384eb378df7SChen-Yu Tsai } 3856b0b8ccfSMaxime Ripard CLK_OF_DECLARE(sun4i_a10_mmc, "allwinner,sun4i-a10-mmc-clk", sun4i_a10_mmc_setup); 38661af4d8dSChen-Yu Tsai 38761af4d8dSChen-Yu Tsai static DEFINE_SPINLOCK(sun9i_a80_mmc_lock); 38861af4d8dSChen-Yu Tsai 38961af4d8dSChen-Yu Tsai static void __init sun9i_a80_mmc_setup(struct device_node *node) 39061af4d8dSChen-Yu Tsai { 39161af4d8dSChen-Yu Tsai sunxi_mmc_setup(node, &sun9i_a80_mod0_data, &sun9i_a80_mmc_lock); 39261af4d8dSChen-Yu Tsai } 39361af4d8dSChen-Yu Tsai CLK_OF_DECLARE(sun9i_a80_mmc, "allwinner,sun9i-a80-mmc-clk", sun9i_a80_mmc_setup); 394