18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci#include <linux/clk-provider.h> 38c2ecf20Sopenharmony_ci#include <linux/mfd/syscon.h> 48c2ecf20Sopenharmony_ci#include <linux/slab.h> 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#include <dt-bindings/clock/at91.h> 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#include "pmc.h" 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_cistatic DEFINE_SPINLOCK(pmc_pll_lock); 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_cistatic const struct clk_master_characteristics mck_characteristics = { 138c2ecf20Sopenharmony_ci .output = { .min = 140000000, .max = 200000000 }, 148c2ecf20Sopenharmony_ci .divisors = { 1, 2, 4, 3 }, 158c2ecf20Sopenharmony_ci .have_div3_pres = 1, 168c2ecf20Sopenharmony_ci}; 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_cistatic const struct clk_master_layout sam9x60_master_layout = { 198c2ecf20Sopenharmony_ci .mask = 0x373, 208c2ecf20Sopenharmony_ci .pres_shift = 4, 218c2ecf20Sopenharmony_ci .offset = 0x28, 228c2ecf20Sopenharmony_ci}; 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_cistatic const struct clk_range plla_outputs[] = { 258c2ecf20Sopenharmony_ci { .min = 2343750, .max = 1200000000 }, 268c2ecf20Sopenharmony_ci}; 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_cistatic const struct clk_pll_characteristics plla_characteristics = { 298c2ecf20Sopenharmony_ci .input = { .min = 12000000, .max = 48000000 }, 308c2ecf20Sopenharmony_ci .num_output = ARRAY_SIZE(plla_outputs), 318c2ecf20Sopenharmony_ci .output = plla_outputs, 328c2ecf20Sopenharmony_ci}; 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_cistatic const struct clk_range upll_outputs[] = { 358c2ecf20Sopenharmony_ci { .min = 300000000, .max = 500000000 }, 368c2ecf20Sopenharmony_ci}; 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_cistatic const struct clk_pll_characteristics upll_characteristics = { 398c2ecf20Sopenharmony_ci .input = { .min = 12000000, .max = 48000000 }, 408c2ecf20Sopenharmony_ci .num_output = ARRAY_SIZE(upll_outputs), 418c2ecf20Sopenharmony_ci .output = upll_outputs, 428c2ecf20Sopenharmony_ci .upll = true, 438c2ecf20Sopenharmony_ci}; 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_cistatic const struct clk_pll_layout pll_frac_layout = { 468c2ecf20Sopenharmony_ci .mul_mask = GENMASK(31, 24), 478c2ecf20Sopenharmony_ci .frac_mask = GENMASK(21, 0), 488c2ecf20Sopenharmony_ci .mul_shift = 24, 498c2ecf20Sopenharmony_ci .frac_shift = 0, 508c2ecf20Sopenharmony_ci}; 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_cistatic const struct clk_pll_layout pll_div_layout = { 538c2ecf20Sopenharmony_ci .div_mask = GENMASK(7, 0), 548c2ecf20Sopenharmony_ci .endiv_mask = BIT(29), 558c2ecf20Sopenharmony_ci .div_shift = 0, 568c2ecf20Sopenharmony_ci .endiv_shift = 29, 578c2ecf20Sopenharmony_ci}; 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_cistatic const struct clk_programmable_layout sam9x60_programmable_layout = { 608c2ecf20Sopenharmony_ci .pres_mask = 0xff, 618c2ecf20Sopenharmony_ci .pres_shift = 8, 628c2ecf20Sopenharmony_ci .css_mask = 0x1f, 638c2ecf20Sopenharmony_ci .have_slck_mck = 0, 648c2ecf20Sopenharmony_ci .is_pres_direct = 1, 658c2ecf20Sopenharmony_ci}; 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_cistatic const struct clk_pcr_layout sam9x60_pcr_layout = { 688c2ecf20Sopenharmony_ci .offset = 0x88, 698c2ecf20Sopenharmony_ci .cmd = BIT(31), 708c2ecf20Sopenharmony_ci .gckcss_mask = GENMASK(12, 8), 718c2ecf20Sopenharmony_ci .pid_mask = GENMASK(6, 0), 728c2ecf20Sopenharmony_ci}; 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_cistatic const struct { 758c2ecf20Sopenharmony_ci char *n; 768c2ecf20Sopenharmony_ci char *p; 778c2ecf20Sopenharmony_ci u8 id; 788c2ecf20Sopenharmony_ci} sam9x60_systemck[] = { 798c2ecf20Sopenharmony_ci { .n = "ddrck", .p = "masterck", .id = 2 }, 808c2ecf20Sopenharmony_ci { .n = "uhpck", .p = "usbck", .id = 6 }, 818c2ecf20Sopenharmony_ci { .n = "pck0", .p = "prog0", .id = 8 }, 828c2ecf20Sopenharmony_ci { .n = "pck1", .p = "prog1", .id = 9 }, 838c2ecf20Sopenharmony_ci { .n = "qspick", .p = "masterck", .id = 19 }, 848c2ecf20Sopenharmony_ci}; 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_cistatic const struct { 878c2ecf20Sopenharmony_ci char *n; 888c2ecf20Sopenharmony_ci u8 id; 898c2ecf20Sopenharmony_ci} sam9x60_periphck[] = { 908c2ecf20Sopenharmony_ci { .n = "pioA_clk", .id = 2, }, 918c2ecf20Sopenharmony_ci { .n = "pioB_clk", .id = 3, }, 928c2ecf20Sopenharmony_ci { .n = "pioC_clk", .id = 4, }, 938c2ecf20Sopenharmony_ci { .n = "flex0_clk", .id = 5, }, 948c2ecf20Sopenharmony_ci { .n = "flex1_clk", .id = 6, }, 958c2ecf20Sopenharmony_ci { .n = "flex2_clk", .id = 7, }, 968c2ecf20Sopenharmony_ci { .n = "flex3_clk", .id = 8, }, 978c2ecf20Sopenharmony_ci { .n = "flex6_clk", .id = 9, }, 988c2ecf20Sopenharmony_ci { .n = "flex7_clk", .id = 10, }, 998c2ecf20Sopenharmony_ci { .n = "flex8_clk", .id = 11, }, 1008c2ecf20Sopenharmony_ci { .n = "sdmmc0_clk", .id = 12, }, 1018c2ecf20Sopenharmony_ci { .n = "flex4_clk", .id = 13, }, 1028c2ecf20Sopenharmony_ci { .n = "flex5_clk", .id = 14, }, 1038c2ecf20Sopenharmony_ci { .n = "flex9_clk", .id = 15, }, 1048c2ecf20Sopenharmony_ci { .n = "flex10_clk", .id = 16, }, 1058c2ecf20Sopenharmony_ci { .n = "tcb0_clk", .id = 17, }, 1068c2ecf20Sopenharmony_ci { .n = "pwm_clk", .id = 18, }, 1078c2ecf20Sopenharmony_ci { .n = "adc_clk", .id = 19, }, 1088c2ecf20Sopenharmony_ci { .n = "dma0_clk", .id = 20, }, 1098c2ecf20Sopenharmony_ci { .n = "matrix_clk", .id = 21, }, 1108c2ecf20Sopenharmony_ci { .n = "uhphs_clk", .id = 22, }, 1118c2ecf20Sopenharmony_ci { .n = "udphs_clk", .id = 23, }, 1128c2ecf20Sopenharmony_ci { .n = "macb0_clk", .id = 24, }, 1138c2ecf20Sopenharmony_ci { .n = "lcd_clk", .id = 25, }, 1148c2ecf20Sopenharmony_ci { .n = "sdmmc1_clk", .id = 26, }, 1158c2ecf20Sopenharmony_ci { .n = "macb1_clk", .id = 27, }, 1168c2ecf20Sopenharmony_ci { .n = "ssc_clk", .id = 28, }, 1178c2ecf20Sopenharmony_ci { .n = "can0_clk", .id = 29, }, 1188c2ecf20Sopenharmony_ci { .n = "can1_clk", .id = 30, }, 1198c2ecf20Sopenharmony_ci { .n = "flex11_clk", .id = 32, }, 1208c2ecf20Sopenharmony_ci { .n = "flex12_clk", .id = 33, }, 1218c2ecf20Sopenharmony_ci { .n = "i2s_clk", .id = 34, }, 1228c2ecf20Sopenharmony_ci { .n = "qspi_clk", .id = 35, }, 1238c2ecf20Sopenharmony_ci { .n = "gfx2d_clk", .id = 36, }, 1248c2ecf20Sopenharmony_ci { .n = "pit64b_clk", .id = 37, }, 1258c2ecf20Sopenharmony_ci { .n = "trng_clk", .id = 38, }, 1268c2ecf20Sopenharmony_ci { .n = "aes_clk", .id = 39, }, 1278c2ecf20Sopenharmony_ci { .n = "tdes_clk", .id = 40, }, 1288c2ecf20Sopenharmony_ci { .n = "sha_clk", .id = 41, }, 1298c2ecf20Sopenharmony_ci { .n = "classd_clk", .id = 42, }, 1308c2ecf20Sopenharmony_ci { .n = "isi_clk", .id = 43, }, 1318c2ecf20Sopenharmony_ci { .n = "pioD_clk", .id = 44, }, 1328c2ecf20Sopenharmony_ci { .n = "tcb1_clk", .id = 45, }, 1338c2ecf20Sopenharmony_ci { .n = "dbgu_clk", .id = 47, }, 1348c2ecf20Sopenharmony_ci { .n = "mpddr_clk", .id = 49, }, 1358c2ecf20Sopenharmony_ci}; 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_cistatic const struct { 1388c2ecf20Sopenharmony_ci char *n; 1398c2ecf20Sopenharmony_ci u8 id; 1408c2ecf20Sopenharmony_ci struct clk_range r; 1418c2ecf20Sopenharmony_ci} sam9x60_gck[] = { 1428c2ecf20Sopenharmony_ci { .n = "flex0_gclk", .id = 5, }, 1438c2ecf20Sopenharmony_ci { .n = "flex1_gclk", .id = 6, }, 1448c2ecf20Sopenharmony_ci { .n = "flex2_gclk", .id = 7, }, 1458c2ecf20Sopenharmony_ci { .n = "flex3_gclk", .id = 8, }, 1468c2ecf20Sopenharmony_ci { .n = "flex6_gclk", .id = 9, }, 1478c2ecf20Sopenharmony_ci { .n = "flex7_gclk", .id = 10, }, 1488c2ecf20Sopenharmony_ci { .n = "flex8_gclk", .id = 11, }, 1498c2ecf20Sopenharmony_ci { .n = "sdmmc0_gclk", .id = 12, .r = { .min = 0, .max = 105000000 }, }, 1508c2ecf20Sopenharmony_ci { .n = "flex4_gclk", .id = 13, }, 1518c2ecf20Sopenharmony_ci { .n = "flex5_gclk", .id = 14, }, 1528c2ecf20Sopenharmony_ci { .n = "flex9_gclk", .id = 15, }, 1538c2ecf20Sopenharmony_ci { .n = "flex10_gclk", .id = 16, }, 1548c2ecf20Sopenharmony_ci { .n = "tcb0_gclk", .id = 17, }, 1558c2ecf20Sopenharmony_ci { .n = "adc_gclk", .id = 19, }, 1568c2ecf20Sopenharmony_ci { .n = "lcd_gclk", .id = 25, .r = { .min = 0, .max = 140000000 }, }, 1578c2ecf20Sopenharmony_ci { .n = "sdmmc1_gclk", .id = 26, .r = { .min = 0, .max = 105000000 }, }, 1588c2ecf20Sopenharmony_ci { .n = "flex11_gclk", .id = 32, }, 1598c2ecf20Sopenharmony_ci { .n = "flex12_gclk", .id = 33, }, 1608c2ecf20Sopenharmony_ci { .n = "i2s_gclk", .id = 34, .r = { .min = 0, .max = 105000000 }, }, 1618c2ecf20Sopenharmony_ci { .n = "pit64b_gclk", .id = 37, }, 1628c2ecf20Sopenharmony_ci { .n = "classd_gclk", .id = 42, .r = { .min = 0, .max = 100000000 }, }, 1638c2ecf20Sopenharmony_ci { .n = "tcb1_gclk", .id = 45, }, 1648c2ecf20Sopenharmony_ci { .n = "dbgu_gclk", .id = 47, }, 1658c2ecf20Sopenharmony_ci}; 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_cistatic void __init sam9x60_pmc_setup(struct device_node *np) 1688c2ecf20Sopenharmony_ci{ 1698c2ecf20Sopenharmony_ci struct clk_range range = CLK_RANGE(0, 0); 1708c2ecf20Sopenharmony_ci const char *td_slck_name, *md_slck_name, *mainxtal_name; 1718c2ecf20Sopenharmony_ci struct pmc_data *sam9x60_pmc; 1728c2ecf20Sopenharmony_ci const char *parent_names[6]; 1738c2ecf20Sopenharmony_ci struct clk_hw *main_osc_hw; 1748c2ecf20Sopenharmony_ci struct regmap *regmap; 1758c2ecf20Sopenharmony_ci struct clk_hw *hw; 1768c2ecf20Sopenharmony_ci int i; 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_ci i = of_property_match_string(np, "clock-names", "td_slck"); 1798c2ecf20Sopenharmony_ci if (i < 0) 1808c2ecf20Sopenharmony_ci return; 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_ci td_slck_name = of_clk_get_parent_name(np, i); 1838c2ecf20Sopenharmony_ci 1848c2ecf20Sopenharmony_ci i = of_property_match_string(np, "clock-names", "md_slck"); 1858c2ecf20Sopenharmony_ci if (i < 0) 1868c2ecf20Sopenharmony_ci return; 1878c2ecf20Sopenharmony_ci 1888c2ecf20Sopenharmony_ci md_slck_name = of_clk_get_parent_name(np, i); 1898c2ecf20Sopenharmony_ci 1908c2ecf20Sopenharmony_ci i = of_property_match_string(np, "clock-names", "main_xtal"); 1918c2ecf20Sopenharmony_ci if (i < 0) 1928c2ecf20Sopenharmony_ci return; 1938c2ecf20Sopenharmony_ci mainxtal_name = of_clk_get_parent_name(np, i); 1948c2ecf20Sopenharmony_ci 1958c2ecf20Sopenharmony_ci regmap = device_node_to_regmap(np); 1968c2ecf20Sopenharmony_ci if (IS_ERR(regmap)) 1978c2ecf20Sopenharmony_ci return; 1988c2ecf20Sopenharmony_ci 1998c2ecf20Sopenharmony_ci sam9x60_pmc = pmc_data_allocate(PMC_PLLACK + 1, 2008c2ecf20Sopenharmony_ci nck(sam9x60_systemck), 2018c2ecf20Sopenharmony_ci nck(sam9x60_periphck), 2028c2ecf20Sopenharmony_ci nck(sam9x60_gck), 8); 2038c2ecf20Sopenharmony_ci if (!sam9x60_pmc) 2048c2ecf20Sopenharmony_ci return; 2058c2ecf20Sopenharmony_ci 2068c2ecf20Sopenharmony_ci hw = at91_clk_register_main_rc_osc(regmap, "main_rc_osc", 12000000, 2078c2ecf20Sopenharmony_ci 50000000); 2088c2ecf20Sopenharmony_ci if (IS_ERR(hw)) 2098c2ecf20Sopenharmony_ci goto err_free; 2108c2ecf20Sopenharmony_ci 2118c2ecf20Sopenharmony_ci hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name, 0); 2128c2ecf20Sopenharmony_ci if (IS_ERR(hw)) 2138c2ecf20Sopenharmony_ci goto err_free; 2148c2ecf20Sopenharmony_ci main_osc_hw = hw; 2158c2ecf20Sopenharmony_ci 2168c2ecf20Sopenharmony_ci parent_names[0] = "main_rc_osc"; 2178c2ecf20Sopenharmony_ci parent_names[1] = "main_osc"; 2188c2ecf20Sopenharmony_ci hw = at91_clk_register_sam9x5_main(regmap, "mainck", parent_names, 2); 2198c2ecf20Sopenharmony_ci if (IS_ERR(hw)) 2208c2ecf20Sopenharmony_ci goto err_free; 2218c2ecf20Sopenharmony_ci 2228c2ecf20Sopenharmony_ci sam9x60_pmc->chws[PMC_MAIN] = hw; 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_ci hw = sam9x60_clk_register_frac_pll(regmap, &pmc_pll_lock, "pllack_fracck", 2258c2ecf20Sopenharmony_ci "mainck", sam9x60_pmc->chws[PMC_MAIN], 2268c2ecf20Sopenharmony_ci 0, &plla_characteristics, 2278c2ecf20Sopenharmony_ci &pll_frac_layout, true); 2288c2ecf20Sopenharmony_ci if (IS_ERR(hw)) 2298c2ecf20Sopenharmony_ci goto err_free; 2308c2ecf20Sopenharmony_ci 2318c2ecf20Sopenharmony_ci hw = sam9x60_clk_register_div_pll(regmap, &pmc_pll_lock, "pllack_divck", 2328c2ecf20Sopenharmony_ci "pllack_fracck", 0, &plla_characteristics, 2338c2ecf20Sopenharmony_ci &pll_div_layout, true); 2348c2ecf20Sopenharmony_ci if (IS_ERR(hw)) 2358c2ecf20Sopenharmony_ci goto err_free; 2368c2ecf20Sopenharmony_ci 2378c2ecf20Sopenharmony_ci sam9x60_pmc->chws[PMC_PLLACK] = hw; 2388c2ecf20Sopenharmony_ci 2398c2ecf20Sopenharmony_ci hw = sam9x60_clk_register_frac_pll(regmap, &pmc_pll_lock, "upllck_fracck", 2408c2ecf20Sopenharmony_ci "main_osc", main_osc_hw, 1, 2418c2ecf20Sopenharmony_ci &upll_characteristics, 2428c2ecf20Sopenharmony_ci &pll_frac_layout, false); 2438c2ecf20Sopenharmony_ci if (IS_ERR(hw)) 2448c2ecf20Sopenharmony_ci goto err_free; 2458c2ecf20Sopenharmony_ci 2468c2ecf20Sopenharmony_ci hw = sam9x60_clk_register_div_pll(regmap, &pmc_pll_lock, "upllck_divck", 2478c2ecf20Sopenharmony_ci "upllck_fracck", 1, &upll_characteristics, 2488c2ecf20Sopenharmony_ci &pll_div_layout, false); 2498c2ecf20Sopenharmony_ci if (IS_ERR(hw)) 2508c2ecf20Sopenharmony_ci goto err_free; 2518c2ecf20Sopenharmony_ci 2528c2ecf20Sopenharmony_ci sam9x60_pmc->chws[PMC_UTMI] = hw; 2538c2ecf20Sopenharmony_ci 2548c2ecf20Sopenharmony_ci parent_names[0] = md_slck_name; 2558c2ecf20Sopenharmony_ci parent_names[1] = "mainck"; 2568c2ecf20Sopenharmony_ci parent_names[2] = "pllack_divck"; 2578c2ecf20Sopenharmony_ci hw = at91_clk_register_master(regmap, "masterck", 3, parent_names, 2588c2ecf20Sopenharmony_ci &sam9x60_master_layout, 2598c2ecf20Sopenharmony_ci &mck_characteristics); 2608c2ecf20Sopenharmony_ci if (IS_ERR(hw)) 2618c2ecf20Sopenharmony_ci goto err_free; 2628c2ecf20Sopenharmony_ci 2638c2ecf20Sopenharmony_ci sam9x60_pmc->chws[PMC_MCK] = hw; 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ci parent_names[0] = "pllack_divck"; 2668c2ecf20Sopenharmony_ci parent_names[1] = "upllck_divck"; 2678c2ecf20Sopenharmony_ci parent_names[2] = "main_osc"; 2688c2ecf20Sopenharmony_ci hw = sam9x60_clk_register_usb(regmap, "usbck", parent_names, 3); 2698c2ecf20Sopenharmony_ci if (IS_ERR(hw)) 2708c2ecf20Sopenharmony_ci goto err_free; 2718c2ecf20Sopenharmony_ci 2728c2ecf20Sopenharmony_ci parent_names[0] = md_slck_name; 2738c2ecf20Sopenharmony_ci parent_names[1] = td_slck_name; 2748c2ecf20Sopenharmony_ci parent_names[2] = "mainck"; 2758c2ecf20Sopenharmony_ci parent_names[3] = "masterck"; 2768c2ecf20Sopenharmony_ci parent_names[4] = "pllack_divck"; 2778c2ecf20Sopenharmony_ci parent_names[5] = "upllck_divck"; 2788c2ecf20Sopenharmony_ci for (i = 0; i < 2; i++) { 2798c2ecf20Sopenharmony_ci char name[6]; 2808c2ecf20Sopenharmony_ci 2818c2ecf20Sopenharmony_ci snprintf(name, sizeof(name), "prog%d", i); 2828c2ecf20Sopenharmony_ci 2838c2ecf20Sopenharmony_ci hw = at91_clk_register_programmable(regmap, name, 2848c2ecf20Sopenharmony_ci parent_names, 6, i, 2858c2ecf20Sopenharmony_ci &sam9x60_programmable_layout, 2868c2ecf20Sopenharmony_ci NULL); 2878c2ecf20Sopenharmony_ci if (IS_ERR(hw)) 2888c2ecf20Sopenharmony_ci goto err_free; 2898c2ecf20Sopenharmony_ci 2908c2ecf20Sopenharmony_ci sam9x60_pmc->pchws[i] = hw; 2918c2ecf20Sopenharmony_ci } 2928c2ecf20Sopenharmony_ci 2938c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(sam9x60_systemck); i++) { 2948c2ecf20Sopenharmony_ci hw = at91_clk_register_system(regmap, sam9x60_systemck[i].n, 2958c2ecf20Sopenharmony_ci sam9x60_systemck[i].p, 2968c2ecf20Sopenharmony_ci sam9x60_systemck[i].id); 2978c2ecf20Sopenharmony_ci if (IS_ERR(hw)) 2988c2ecf20Sopenharmony_ci goto err_free; 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_ci sam9x60_pmc->shws[sam9x60_systemck[i].id] = hw; 3018c2ecf20Sopenharmony_ci } 3028c2ecf20Sopenharmony_ci 3038c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(sam9x60_periphck); i++) { 3048c2ecf20Sopenharmony_ci hw = at91_clk_register_sam9x5_peripheral(regmap, &pmc_pcr_lock, 3058c2ecf20Sopenharmony_ci &sam9x60_pcr_layout, 3068c2ecf20Sopenharmony_ci sam9x60_periphck[i].n, 3078c2ecf20Sopenharmony_ci "masterck", 3088c2ecf20Sopenharmony_ci sam9x60_periphck[i].id, 3098c2ecf20Sopenharmony_ci &range, INT_MIN); 3108c2ecf20Sopenharmony_ci if (IS_ERR(hw)) 3118c2ecf20Sopenharmony_ci goto err_free; 3128c2ecf20Sopenharmony_ci 3138c2ecf20Sopenharmony_ci sam9x60_pmc->phws[sam9x60_periphck[i].id] = hw; 3148c2ecf20Sopenharmony_ci } 3158c2ecf20Sopenharmony_ci 3168c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(sam9x60_gck); i++) { 3178c2ecf20Sopenharmony_ci hw = at91_clk_register_generated(regmap, &pmc_pcr_lock, 3188c2ecf20Sopenharmony_ci &sam9x60_pcr_layout, 3198c2ecf20Sopenharmony_ci sam9x60_gck[i].n, 3208c2ecf20Sopenharmony_ci parent_names, NULL, 6, 3218c2ecf20Sopenharmony_ci sam9x60_gck[i].id, 3228c2ecf20Sopenharmony_ci &sam9x60_gck[i].r, INT_MIN); 3238c2ecf20Sopenharmony_ci if (IS_ERR(hw)) 3248c2ecf20Sopenharmony_ci goto err_free; 3258c2ecf20Sopenharmony_ci 3268c2ecf20Sopenharmony_ci sam9x60_pmc->ghws[sam9x60_gck[i].id] = hw; 3278c2ecf20Sopenharmony_ci } 3288c2ecf20Sopenharmony_ci 3298c2ecf20Sopenharmony_ci of_clk_add_hw_provider(np, of_clk_hw_pmc_get, sam9x60_pmc); 3308c2ecf20Sopenharmony_ci 3318c2ecf20Sopenharmony_ci return; 3328c2ecf20Sopenharmony_ci 3338c2ecf20Sopenharmony_cierr_free: 3348c2ecf20Sopenharmony_ci kfree(sam9x60_pmc); 3358c2ecf20Sopenharmony_ci} 3368c2ecf20Sopenharmony_ci/* Some clks are used for a clocksource */ 3378c2ecf20Sopenharmony_ciCLK_OF_DECLARE(sam9x60_pmc, "microchip,sam9x60-pmc", sam9x60_pmc_setup); 338