^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #include <linux/clk-provider.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #include <linux/mfd/syscon.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <dt-bindings/clock/at91.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include "pmc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) static const struct clk_master_characteristics mck_characteristics = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) .output = { .min = 0, .max = 133333333 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) .divisors = { 1, 2, 4, 3 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) .have_div3_pres = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) static u8 plla_out[] = { 0, 1, 2, 3, 0, 1, 2, 3 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) static u16 plla_icpll[] = { 0, 0, 0, 0, 1, 1, 1, 1 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) static const struct clk_range plla_outputs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) { .min = 745000000, .max = 800000000 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) { .min = 695000000, .max = 750000000 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) { .min = 645000000, .max = 700000000 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) { .min = 595000000, .max = 650000000 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) { .min = 545000000, .max = 600000000 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) { .min = 495000000, .max = 555000000 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) { .min = 445000000, .max = 500000000 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) { .min = 400000000, .max = 450000000 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) static const struct clk_pll_characteristics plla_characteristics = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) .input = { .min = 2000000, .max = 32000000 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) .num_output = ARRAY_SIZE(plla_outputs),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) .output = plla_outputs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) .icpll = plla_icpll,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) .out = plla_out,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) static const struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) char *n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) char *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) u8 id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) } at91sam9x5_systemck[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) { .n = "ddrck", .p = "masterck", .id = 2 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) { .n = "smdck", .p = "smdclk", .id = 4 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) { .n = "uhpck", .p = "usbck", .id = 6 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) { .n = "udpck", .p = "usbck", .id = 7 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) { .n = "pck0", .p = "prog0", .id = 8 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) { .n = "pck1", .p = "prog1", .id = 9 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) static const struct clk_pcr_layout at91sam9x5_pcr_layout = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) .offset = 0x10c,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) .cmd = BIT(12),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) .pid_mask = GENMASK(5, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) .div_mask = GENMASK(17, 16),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) struct pck {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) char *n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) u8 id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) static const struct pck at91sam9x5_periphck[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) { .n = "pioAB_clk", .id = 2, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) { .n = "pioCD_clk", .id = 3, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) { .n = "smd_clk", .id = 4, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) { .n = "usart0_clk", .id = 5, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) { .n = "usart1_clk", .id = 6, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) { .n = "usart2_clk", .id = 7, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) { .n = "twi0_clk", .id = 9, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) { .n = "twi1_clk", .id = 10, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) { .n = "twi2_clk", .id = 11, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) { .n = "mci0_clk", .id = 12, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) { .n = "spi0_clk", .id = 13, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) { .n = "spi1_clk", .id = 14, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) { .n = "uart0_clk", .id = 15, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) { .n = "uart1_clk", .id = 16, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) { .n = "tcb0_clk", .id = 17, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) { .n = "pwm_clk", .id = 18, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) { .n = "adc_clk", .id = 19, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) { .n = "dma0_clk", .id = 20, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) { .n = "dma1_clk", .id = 21, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) { .n = "uhphs_clk", .id = 22, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) { .n = "udphs_clk", .id = 23, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) { .n = "mci1_clk", .id = 26, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) { .n = "ssc0_clk", .id = 28, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) static const struct pck at91sam9g15_periphck[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) { .n = "lcdc_clk", .id = 25, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) { /* sentinel */}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) static const struct pck at91sam9g25_periphck[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) { .n = "usart3_clk", .id = 8, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) { .n = "macb0_clk", .id = 24, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) { .n = "isi_clk", .id = 25, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) { /* sentinel */}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) static const struct pck at91sam9g35_periphck[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) { .n = "macb0_clk", .id = 24, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) { .n = "lcdc_clk", .id = 25, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) { /* sentinel */}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) static const struct pck at91sam9x25_periphck[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) { .n = "usart3_clk", .id = 8, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) { .n = "macb0_clk", .id = 24, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) { .n = "macb1_clk", .id = 27, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) { .n = "can0_clk", .id = 29, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) { .n = "can1_clk", .id = 30, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) { /* sentinel */}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) static const struct pck at91sam9x35_periphck[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) { .n = "macb0_clk", .id = 24, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) { .n = "lcdc_clk", .id = 25, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) { .n = "can0_clk", .id = 29, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) { .n = "can1_clk", .id = 30, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) { /* sentinel */}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) static void __init at91sam9x5_pmc_setup(struct device_node *np,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) const struct pck *extra_pcks,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) bool has_lcdck)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) struct clk_range range = CLK_RANGE(0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) const char *slck_name, *mainxtal_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) struct pmc_data *at91sam9x5_pmc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) const char *parent_names[6];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) struct regmap *regmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) struct clk_hw *hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) bool bypass;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) i = of_property_match_string(np, "clock-names", "slow_clk");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) if (i < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) slck_name = of_clk_get_parent_name(np, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) i = of_property_match_string(np, "clock-names", "main_xtal");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) if (i < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) mainxtal_name = of_clk_get_parent_name(np, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) regmap = device_node_to_regmap(np);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) if (IS_ERR(regmap))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) at91sam9x5_pmc = pmc_data_allocate(PMC_PLLACK + 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) nck(at91sam9x5_systemck), 31, 0, 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) if (!at91sam9x5_pmc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) hw = at91_clk_register_main_rc_osc(regmap, "main_rc_osc", 12000000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 50000000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) if (IS_ERR(hw))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) goto err_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) bypass = of_property_read_bool(np, "atmel,osc-bypass");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) bypass);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) if (IS_ERR(hw))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) goto err_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) parent_names[0] = "main_rc_osc";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) parent_names[1] = "main_osc";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) hw = at91_clk_register_sam9x5_main(regmap, "mainck", parent_names, 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) if (IS_ERR(hw))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) goto err_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) at91sam9x5_pmc->chws[PMC_MAIN] = hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) hw = at91_clk_register_pll(regmap, "pllack", "mainck", 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) &at91rm9200_pll_layout, &plla_characteristics);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) if (IS_ERR(hw))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) goto err_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) hw = at91_clk_register_plldiv(regmap, "plladivck", "pllack");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) if (IS_ERR(hw))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) goto err_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) at91sam9x5_pmc->chws[PMC_PLLACK] = hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) if (IS_ERR(hw))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) goto err_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) at91sam9x5_pmc->chws[PMC_UTMI] = hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) parent_names[0] = slck_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) parent_names[1] = "mainck";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) parent_names[2] = "plladivck";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) parent_names[3] = "utmick";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) hw = at91_clk_register_master(regmap, "masterck", 4, parent_names,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) &at91sam9x5_master_layout,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) &mck_characteristics);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) if (IS_ERR(hw))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) goto err_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) at91sam9x5_pmc->chws[PMC_MCK] = hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) parent_names[0] = "plladivck";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) parent_names[1] = "utmick";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) hw = at91sam9x5_clk_register_usb(regmap, "usbck", parent_names, 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) if (IS_ERR(hw))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) goto err_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) hw = at91sam9x5_clk_register_smd(regmap, "smdclk", parent_names, 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) if (IS_ERR(hw))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) goto err_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) parent_names[0] = slck_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) parent_names[1] = "mainck";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) parent_names[2] = "plladivck";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) parent_names[3] = "utmick";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) parent_names[4] = "masterck";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) for (i = 0; i < 2; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) char name[6];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) snprintf(name, sizeof(name), "prog%d", i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) hw = at91_clk_register_programmable(regmap, name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) parent_names, 5, i,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) &at91sam9x5_programmable_layout,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) if (IS_ERR(hw))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) goto err_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) at91sam9x5_pmc->pchws[i] = hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) for (i = 0; i < ARRAY_SIZE(at91sam9x5_systemck); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) hw = at91_clk_register_system(regmap, at91sam9x5_systemck[i].n,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) at91sam9x5_systemck[i].p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) at91sam9x5_systemck[i].id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) if (IS_ERR(hw))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) goto err_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) at91sam9x5_pmc->shws[at91sam9x5_systemck[i].id] = hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) if (has_lcdck) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) hw = at91_clk_register_system(regmap, "lcdck", "masterck", 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) if (IS_ERR(hw))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) goto err_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) at91sam9x5_pmc->shws[3] = hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) for (i = 0; i < ARRAY_SIZE(at91sam9x5_periphck); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) hw = at91_clk_register_sam9x5_peripheral(regmap, &pmc_pcr_lock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) &at91sam9x5_pcr_layout,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) at91sam9x5_periphck[i].n,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) "masterck",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) at91sam9x5_periphck[i].id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) &range, INT_MIN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) if (IS_ERR(hw))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) goto err_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) at91sam9x5_pmc->phws[at91sam9x5_periphck[i].id] = hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) for (i = 0; extra_pcks[i].id; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) hw = at91_clk_register_sam9x5_peripheral(regmap, &pmc_pcr_lock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) &at91sam9x5_pcr_layout,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) extra_pcks[i].n,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) "masterck",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) extra_pcks[i].id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) &range, INT_MIN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) if (IS_ERR(hw))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) goto err_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) at91sam9x5_pmc->phws[extra_pcks[i].id] = hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) of_clk_add_hw_provider(np, of_clk_hw_pmc_get, at91sam9x5_pmc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) err_free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) kfree(at91sam9x5_pmc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) static void __init at91sam9g15_pmc_setup(struct device_node *np)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) at91sam9x5_pmc_setup(np, at91sam9g15_periphck, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) CLK_OF_DECLARE_DRIVER(at91sam9g15_pmc, "atmel,at91sam9g15-pmc",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) at91sam9g15_pmc_setup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) static void __init at91sam9g25_pmc_setup(struct device_node *np)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) at91sam9x5_pmc_setup(np, at91sam9g25_periphck, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) CLK_OF_DECLARE_DRIVER(at91sam9g25_pmc, "atmel,at91sam9g25-pmc",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) at91sam9g25_pmc_setup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) static void __init at91sam9g35_pmc_setup(struct device_node *np)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) at91sam9x5_pmc_setup(np, at91sam9g35_periphck, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) CLK_OF_DECLARE_DRIVER(at91sam9g35_pmc, "atmel,at91sam9g35-pmc",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) at91sam9g35_pmc_setup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) static void __init at91sam9x25_pmc_setup(struct device_node *np)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) at91sam9x5_pmc_setup(np, at91sam9x25_periphck, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) CLK_OF_DECLARE_DRIVER(at91sam9x25_pmc, "atmel,at91sam9x25-pmc",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) at91sam9x25_pmc_setup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) static void __init at91sam9x35_pmc_setup(struct device_node *np)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) at91sam9x5_pmc_setup(np, at91sam9x35_periphck, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) CLK_OF_DECLARE_DRIVER(at91sam9x35_pmc, "atmel,at91sam9x35-pmc",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) at91sam9x35_pmc_setup);