Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: sirf: re-arch to make the codes support both prima2 and atlas6

sirfprima2 and sirfatlas6 are two different SoCs in CSR SiRF series. for
prima2 and atlas6, there are many shared clocks but there are still
some different register layout and hardware clocks, then result in
different clock table.

here we re-arch the driver to
1. clk-common.c provides common clocks for prima2 and atlas6,
2. clk-prima2.h describles registers of prima2 and clk-prima2.c provides
prima2 specific clocks and clock table.
3. clk-atlas6.h describles registers of atlas6 and clk-atlas6.c provides
atlas6 specific clocks and clock table.
4. clk.h and clk.c expose external interfaces and provide uniform entry
for both prima2 and atlas6.

so both prima2 and atlas6 will get support by drivers/clk/sirf.

Signed-off-by: Barry Song <Baohua.Song@csr.com>
Signed-off-by: Rongjun Ying <Rongjun.Ying@csr.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>

authored by

Barry Song and committed by
Mike Turquette
7bf21bc8 5d2043fb

+458 -172
+1 -1
drivers/clk/Makefile
··· 21 21 obj-$(CONFIG_PLAT_SPEAR) += spear/ 22 22 obj-$(CONFIG_ARCH_U300) += clk-u300.o 23 23 obj-$(CONFIG_COMMON_CLK_VERSATILE) += versatile/ 24 - obj-$(CONFIG_ARCH_SIRF) += clk-prima2.o 25 24 obj-$(CONFIG_PLAT_ORION) += mvebu/ 26 25 ifeq ($(CONFIG_COMMON_CLK), y) 27 26 obj-$(CONFIG_ARCH_MMP) += mmp/ ··· 30 31 obj-$(CONFIG_ARCH_SUNXI) += sunxi/ 31 32 obj-$(CONFIG_ARCH_U8500) += ux500/ 32 33 obj-$(CONFIG_ARCH_VT8500) += clk-vt8500.o 34 + obj-$(CONFIG_ARCH_SIRF) += sirf/ 33 35 obj-$(CONFIG_ARCH_ZYNQ) += zynq/ 34 36 obj-$(CONFIG_ARCH_TEGRA) += tegra/ 35 37 obj-$(CONFIG_PLAT_SAMSUNG) += samsung/
+93 -171
drivers/clk/clk-prima2.c drivers/clk/sirf/clk-common.c
··· 1 1 /* 2 - * Clock tree for CSR SiRFprimaII 2 + * common clks module for all SiRF SoCs 3 3 * 4 4 * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company. 5 5 * 6 6 * Licensed under GPLv2 or later. 7 7 */ 8 8 9 - #include <linux/module.h> 10 - #include <linux/bitops.h> 11 - #include <linux/io.h> 12 - #include <linux/clk.h> 13 - #include <linux/clkdev.h> 14 - #include <linux/clk-provider.h> 15 - #include <linux/of_address.h> 16 - #include <linux/syscore_ops.h> 17 - 18 - #define SIRFSOC_CLKC_CLK_EN0 0x0000 19 - #define SIRFSOC_CLKC_CLK_EN1 0x0004 20 - #define SIRFSOC_CLKC_REF_CFG 0x0014 21 - #define SIRFSOC_CLKC_CPU_CFG 0x0018 22 - #define SIRFSOC_CLKC_MEM_CFG 0x001c 23 - #define SIRFSOC_CLKC_SYS_CFG 0x0020 24 - #define SIRFSOC_CLKC_IO_CFG 0x0024 25 - #define SIRFSOC_CLKC_DSP_CFG 0x0028 26 - #define SIRFSOC_CLKC_GFX_CFG 0x002c 27 - #define SIRFSOC_CLKC_MM_CFG 0x0030 28 - #define SIRFSOC_CLKC_LCD_CFG 0x0034 29 - #define SIRFSOC_CLKC_MMC_CFG 0x0038 30 - #define SIRFSOC_CLKC_PLL1_CFG0 0x0040 31 - #define SIRFSOC_CLKC_PLL2_CFG0 0x0044 32 - #define SIRFSOC_CLKC_PLL3_CFG0 0x0048 33 - #define SIRFSOC_CLKC_PLL1_CFG1 0x004c 34 - #define SIRFSOC_CLKC_PLL2_CFG1 0x0050 35 - #define SIRFSOC_CLKC_PLL3_CFG1 0x0054 36 - #define SIRFSOC_CLKC_PLL1_CFG2 0x0058 37 - #define SIRFSOC_CLKC_PLL2_CFG2 0x005c 38 - #define SIRFSOC_CLKC_PLL3_CFG2 0x0060 39 - #define SIRFSOC_USBPHY_PLL_CTRL 0x0008 40 - #define SIRFSOC_USBPHY_PLL_POWERDOWN BIT(1) 41 - #define SIRFSOC_USBPHY_PLL_BYPASS BIT(2) 42 - #define SIRFSOC_USBPHY_PLL_LOCK BIT(3) 43 - 44 - static void *sirfsoc_clk_vbase, *sirfsoc_rsc_vbase; 45 - 46 9 #define KHZ 1000 47 10 #define MHZ (KHZ * KHZ) 11 + 12 + static void *sirfsoc_clk_vbase; 13 + static void *sirfsoc_rsc_vbase; 14 + static struct clk_onecell_data clk_data; 48 15 49 16 /* 50 17 * SiRFprimaII clock controller ··· 94 127 unsigned long *parent_rate) 95 128 { 96 129 unsigned long fin, nf, nr, od; 130 + u64 dividend; 97 131 98 132 /* 99 133 * fout = fin * nf / (nr * od); ··· 115 147 nr = BIT(6); 116 148 od = 1; 117 149 118 - return fin * nf / (nr * od); 150 + dividend = (u64)fin * nf; 151 + do_div(dividend, nr * od); 152 + 153 + return (long)dividend; 119 154 } 120 155 121 156 static int pll_clk_set_rate(struct clk_hw *hw, unsigned long rate, ··· 155 184 cpu_relax(); 156 185 157 186 return 0; 187 + } 188 + 189 + static long cpu_clk_round_rate(struct clk_hw *hw, unsigned long rate, 190 + unsigned long *parent_rate) 191 + { 192 + /* 193 + * SiRF SoC has not cpu clock control, 194 + * So bypass to it's parent pll. 195 + */ 196 + struct clk *parent_clk = clk_get_parent(hw->clk); 197 + struct clk *pll_parent_clk = clk_get_parent(parent_clk); 198 + unsigned long pll_parent_rate = clk_get_rate(pll_parent_clk); 199 + return pll_clk_round_rate(__clk_get_hw(parent_clk), rate, &pll_parent_rate); 200 + } 201 + 202 + static unsigned long cpu_clk_recalc_rate(struct clk_hw *hw, 203 + unsigned long parent_rate) 204 + { 205 + /* 206 + * SiRF SoC has not cpu clock control, 207 + * So return the parent pll rate. 208 + */ 209 + struct clk *parent_clk = clk_get_parent(hw->clk); 210 + return __clk_get_rate(parent_clk); 158 211 } 159 212 160 213 static struct clk_ops std_pll_ops = { ··· 398 403 return 0; 399 404 } 400 405 406 + static int cpu_clk_set_rate(struct clk_hw *hw, unsigned long rate, 407 + unsigned long parent_rate) 408 + { 409 + int ret1, ret2; 410 + struct clk *cur_parent; 411 + 412 + if (rate == clk_get_rate(clk_pll1.hw.clk)) { 413 + ret1 = clk_set_parent(hw->clk, clk_pll1.hw.clk); 414 + return ret1; 415 + } 416 + 417 + if (rate == clk_get_rate(clk_pll2.hw.clk)) { 418 + ret1 = clk_set_parent(hw->clk, clk_pll2.hw.clk); 419 + return ret1; 420 + } 421 + 422 + if (rate == clk_get_rate(clk_pll3.hw.clk)) { 423 + ret1 = clk_set_parent(hw->clk, clk_pll3.hw.clk); 424 + return ret1; 425 + } 426 + 427 + cur_parent = clk_get_parent(hw->clk); 428 + 429 + /* switch to tmp pll before setting parent clock's rate */ 430 + if (cur_parent == clk_pll1.hw.clk) { 431 + ret1 = clk_set_parent(hw->clk, clk_pll2.hw.clk); 432 + BUG_ON(ret1); 433 + } 434 + 435 + ret2 = clk_set_rate(clk_pll1.hw.clk, rate); 436 + 437 + ret1 = clk_set_parent(hw->clk, clk_pll1.hw.clk); 438 + 439 + return ret2 ? ret2 : ret1; 440 + } 441 + 401 442 static struct clk_ops msi_ops = { 402 443 .set_rate = dmn_clk_set_rate, 403 444 .round_rate = dmn_clk_round_rate, ··· 488 457 static struct clk_ops cpu_ops = { 489 458 .set_parent = dmn_clk_set_parent, 490 459 .get_parent = dmn_clk_get_parent, 460 + .set_rate = cpu_clk_set_rate, 461 + .round_rate = cpu_clk_round_rate, 462 + .recalc_rate = cpu_clk_recalc_rate, 491 463 }; 492 464 493 465 static struct clk_init_data clk_cpu_init = { ··· 566 532 }, 567 533 }; 568 534 535 + /* 536 + * for atlas6, gfx2d holds the bit of prima2's clk_mm 537 + */ 538 + #define clk_gfx2d clk_mm 539 + 569 540 static struct clk_init_data clk_lcd_init = { 570 541 .name = "lcd", 571 542 .ops = &dmn_ops, ··· 608 569 .num_parents = ARRAY_SIZE(dmn_clk_parents), 609 570 }; 610 571 611 - static struct clk_dmn clk_mmc01 = { 612 - .regofs = SIRFSOC_CLKC_MMC_CFG, 613 - .enable_bit = 59, 614 - .hw = { 615 - .init = &clk_mmc01_init, 616 - }, 617 - }; 618 - 619 572 static struct clk_init_data clk_mmc23_init = { 620 573 .name = "mmc23", 621 574 .ops = &dmn_ops, ··· 615 584 .num_parents = ARRAY_SIZE(dmn_clk_parents), 616 585 }; 617 586 618 - static struct clk_dmn clk_mmc23 = { 619 - .regofs = SIRFSOC_CLKC_MMC_CFG, 620 - .enable_bit = 60, 621 - .hw = { 622 - .init = &clk_mmc23_init, 623 - }, 624 - }; 625 - 626 587 static struct clk_init_data clk_mmc45_init = { 627 588 .name = "mmc45", 628 589 .ops = &dmn_ops, 629 590 .parent_names = dmn_clk_parents, 630 591 .num_parents = ARRAY_SIZE(dmn_clk_parents), 631 - }; 632 - 633 - static struct clk_dmn clk_mmc45 = { 634 - .regofs = SIRFSOC_CLKC_MMC_CFG, 635 - .enable_bit = 61, 636 - .hw = { 637 - .init = &clk_mmc45_init, 638 - }, 639 592 }; 640 593 641 594 /* ··· 682 667 .disable = std_clk_disable, 683 668 }; 684 669 670 + static struct clk_init_data clk_cphif_init = { 671 + .name = "cphif", 672 + .ops = &ios_ops, 673 + .parent_names = std_clk_io_parents, 674 + .num_parents = ARRAY_SIZE(std_clk_io_parents), 675 + }; 676 + 677 + static struct clk_std clk_cphif = { 678 + .enable_bit = 20, 679 + .hw = { 680 + .init = &clk_cphif_init, 681 + }, 682 + }; 683 + 685 684 static struct clk_init_data clk_dmac0_init = { 686 685 .name = "dmac0", 687 686 .ops = &ios_ops, ··· 721 692 .enable_bit = 33, 722 693 .hw = { 723 694 .init = &clk_dmac1_init, 724 - }, 725 - }; 726 - 727 - static struct clk_init_data clk_nand_init = { 728 - .name = "nand", 729 - .ops = &ios_ops, 730 - .parent_names = std_clk_io_parents, 731 - .num_parents = ARRAY_SIZE(std_clk_io_parents), 732 - }; 733 - 734 - static struct clk_std clk_nand = { 735 - .enable_bit = 34, 736 - .hw = { 737 - .init = &clk_nand_init, 738 695 }, 739 696 }; 740 697 ··· 985 970 }; 986 971 987 972 static struct clk_init_data clk_security_init = { 988 - .name = "mf", 973 + .name = "security", 989 974 .ops = &ios_ops, 990 975 .parent_names = std_clk_sys_parents, 991 976 .num_parents = ARRAY_SIZE(std_clk_sys_parents), ··· 1029 1014 .init = &clk_usb1_init, 1030 1015 }, 1031 1016 }; 1032 - 1033 - enum prima2_clk_index { 1034 - /* 0 1 2 3 4 5 6 7 8 9 */ 1035 - rtc, osc, pll1, pll2, pll3, mem, sys, security, dsp, gps, 1036 - mf, io, cpu, uart0, uart1, uart2, tsc, i2c0, i2c1, spi0, 1037 - spi1, pwmc, efuse, pulse, dmac0, dmac1, nand, audio, usp0, usp1, 1038 - usp2, vip, gfx, mm, lcd, vpp, mmc01, mmc23, mmc45, usbpll, 1039 - usb0, usb1, maxclk, 1040 - }; 1041 - 1042 - static struct clk_hw *prima2_clk_hw_array[maxclk] __initdata = { 1043 - NULL, /* dummy */ 1044 - NULL, 1045 - &clk_pll1.hw, 1046 - &clk_pll2.hw, 1047 - &clk_pll3.hw, 1048 - &clk_mem.hw, 1049 - &clk_sys.hw, 1050 - &clk_security.hw, 1051 - &clk_dsp.hw, 1052 - &clk_gps.hw, 1053 - &clk_mf.hw, 1054 - &clk_io.hw, 1055 - &clk_cpu.hw, 1056 - &clk_uart0.hw, 1057 - &clk_uart1.hw, 1058 - &clk_uart2.hw, 1059 - &clk_tsc.hw, 1060 - &clk_i2c0.hw, 1061 - &clk_i2c1.hw, 1062 - &clk_spi0.hw, 1063 - &clk_spi1.hw, 1064 - &clk_pwmc.hw, 1065 - &clk_efuse.hw, 1066 - &clk_pulse.hw, 1067 - &clk_dmac0.hw, 1068 - &clk_dmac1.hw, 1069 - &clk_nand.hw, 1070 - &clk_audio.hw, 1071 - &clk_usp0.hw, 1072 - &clk_usp1.hw, 1073 - &clk_usp2.hw, 1074 - &clk_vip.hw, 1075 - &clk_gfx.hw, 1076 - &clk_mm.hw, 1077 - &clk_lcd.hw, 1078 - &clk_vpp.hw, 1079 - &clk_mmc01.hw, 1080 - &clk_mmc23.hw, 1081 - &clk_mmc45.hw, 1082 - &usb_pll_clk_hw, 1083 - &clk_usb0.hw, 1084 - &clk_usb1.hw, 1085 - }; 1086 - 1087 - static struct clk *prima2_clks[maxclk]; 1088 - static struct clk_onecell_data clk_data; 1089 - 1090 - static void __init sirfsoc_clk_init(struct device_node *np) 1091 - { 1092 - struct device_node *rscnp; 1093 - int i; 1094 - 1095 - rscnp = of_find_compatible_node(NULL, NULL, "sirf,prima2-rsc"); 1096 - sirfsoc_rsc_vbase = of_iomap(rscnp, 0); 1097 - if (!sirfsoc_rsc_vbase) 1098 - panic("unable to map rsc registers\n"); 1099 - of_node_put(rscnp); 1100 - 1101 - sirfsoc_clk_vbase = of_iomap(np, 0); 1102 - if (!sirfsoc_clk_vbase) 1103 - panic("unable to map clkc registers\n"); 1104 - 1105 - /* These are always available (RTC and 26MHz OSC)*/ 1106 - prima2_clks[rtc] = clk_register_fixed_rate(NULL, "rtc", NULL, 1107 - CLK_IS_ROOT, 32768); 1108 - prima2_clks[osc]= clk_register_fixed_rate(NULL, "osc", NULL, 1109 - CLK_IS_ROOT, 26000000); 1110 - 1111 - for (i = pll1; i < maxclk; i++) { 1112 - prima2_clks[i] = clk_register(NULL, prima2_clk_hw_array[i]); 1113 - BUG_ON(IS_ERR(prima2_clks[i])); 1114 - } 1115 - clk_register_clkdev(prima2_clks[cpu], NULL, "cpu"); 1116 - clk_register_clkdev(prima2_clks[io], NULL, "io"); 1117 - clk_register_clkdev(prima2_clks[mem], NULL, "mem"); 1118 - 1119 - clk_data.clks = prima2_clks; 1120 - clk_data.clk_num = maxclk; 1121 - 1122 - of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data); 1123 - } 1124 - CLK_OF_DECLARE(sirfsoc_clk, "sirf,prima2-clkc", sirfsoc_clk_init);
+5
drivers/clk/sirf/Makefile
··· 1 + # 2 + # Makefile for sirf specific clk 3 + # 4 + 5 + obj-$(CONFIG_ARCH_SIRF) += clk-prima2.o clk-atlas6.o
+31
drivers/clk/sirf/atlas6.h
··· 1 + #define SIRFSOC_CLKC_CLK_EN0 0x0000 2 + #define SIRFSOC_CLKC_CLK_EN1 0x0004 3 + #define SIRFSOC_CLKC_REF_CFG 0x0020 4 + #define SIRFSOC_CLKC_CPU_CFG 0x0024 5 + #define SIRFSOC_CLKC_MEM_CFG 0x0028 6 + #define SIRFSOC_CLKC_MEMDIV_CFG 0x002C 7 + #define SIRFSOC_CLKC_SYS_CFG 0x0030 8 + #define SIRFSOC_CLKC_IO_CFG 0x0034 9 + #define SIRFSOC_CLKC_DSP_CFG 0x0038 10 + #define SIRFSOC_CLKC_GFX_CFG 0x003c 11 + #define SIRFSOC_CLKC_MM_CFG 0x0040 12 + #define SIRFSOC_CLKC_GFX2D_CFG 0x0040 13 + #define SIRFSOC_CLKC_LCD_CFG 0x0044 14 + #define SIRFSOC_CLKC_MMC01_CFG 0x0048 15 + #define SIRFSOC_CLKC_MMC23_CFG 0x004C 16 + #define SIRFSOC_CLKC_MMC45_CFG 0x0050 17 + #define SIRFSOC_CLKC_NAND_CFG 0x0054 18 + #define SIRFSOC_CLKC_NANDDIV_CFG 0x0058 19 + #define SIRFSOC_CLKC_PLL1_CFG0 0x0080 20 + #define SIRFSOC_CLKC_PLL2_CFG0 0x0084 21 + #define SIRFSOC_CLKC_PLL3_CFG0 0x0088 22 + #define SIRFSOC_CLKC_PLL1_CFG1 0x008c 23 + #define SIRFSOC_CLKC_PLL2_CFG1 0x0090 24 + #define SIRFSOC_CLKC_PLL3_CFG1 0x0094 25 + #define SIRFSOC_CLKC_PLL1_CFG2 0x0098 26 + #define SIRFSOC_CLKC_PLL2_CFG2 0x009c 27 + #define SIRFSOC_CLKC_PLL3_CFG2 0x00A0 28 + #define SIRFSOC_USBPHY_PLL_CTRL 0x0008 29 + #define SIRFSOC_USBPHY_PLL_POWERDOWN BIT(1) 30 + #define SIRFSOC_USBPHY_PLL_BYPASS BIT(2) 31 + #define SIRFSOC_USBPHY_PLL_LOCK BIT(3)
+152
drivers/clk/sirf/clk-atlas6.c
··· 1 + /* 2 + * Clock tree for CSR SiRFatlasVI 3 + * 4 + * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company. 5 + * 6 + * Licensed under GPLv2 or later. 7 + */ 8 + 9 + #include <linux/module.h> 10 + #include <linux/bitops.h> 11 + #include <linux/io.h> 12 + #include <linux/clk.h> 13 + #include <linux/clkdev.h> 14 + #include <linux/clk-provider.h> 15 + #include <linux/of_address.h> 16 + #include <linux/syscore_ops.h> 17 + 18 + #include "atlas6.h" 19 + #include "clk-common.c" 20 + 21 + static struct clk_dmn clk_mmc01 = { 22 + .regofs = SIRFSOC_CLKC_MMC01_CFG, 23 + .enable_bit = 59, 24 + .hw = { 25 + .init = &clk_mmc01_init, 26 + }, 27 + }; 28 + 29 + static struct clk_dmn clk_mmc23 = { 30 + .regofs = SIRFSOC_CLKC_MMC23_CFG, 31 + .enable_bit = 60, 32 + .hw = { 33 + .init = &clk_mmc23_init, 34 + }, 35 + }; 36 + 37 + static struct clk_dmn clk_mmc45 = { 38 + .regofs = SIRFSOC_CLKC_MMC45_CFG, 39 + .enable_bit = 61, 40 + .hw = { 41 + .init = &clk_mmc45_init, 42 + }, 43 + }; 44 + 45 + static struct clk_init_data clk_nand_init = { 46 + .name = "nand", 47 + .ops = &dmn_ops, 48 + .parent_names = dmn_clk_parents, 49 + .num_parents = ARRAY_SIZE(dmn_clk_parents), 50 + }; 51 + 52 + static struct clk_dmn clk_nand = { 53 + .regofs = SIRFSOC_CLKC_NAND_CFG, 54 + .enable_bit = 34, 55 + .hw = { 56 + .init = &clk_nand_init, 57 + }, 58 + }; 59 + 60 + enum atlas6_clk_index { 61 + /* 0 1 2 3 4 5 6 7 8 9 */ 62 + rtc, osc, pll1, pll2, pll3, mem, sys, security, dsp, gps, 63 + mf, io, cpu, uart0, uart1, uart2, tsc, i2c0, i2c1, spi0, 64 + spi1, pwmc, efuse, pulse, dmac0, dmac1, nand, audio, usp0, usp1, 65 + usp2, vip, gfx, gfx2d, lcd, vpp, mmc01, mmc23, mmc45, usbpll, 66 + usb0, usb1, cphif, maxclk, 67 + }; 68 + 69 + static __initdata struct clk_hw *atlas6_clk_hw_array[maxclk] = { 70 + NULL, /* dummy */ 71 + NULL, 72 + &clk_pll1.hw, 73 + &clk_pll2.hw, 74 + &clk_pll3.hw, 75 + &clk_mem.hw, 76 + &clk_sys.hw, 77 + &clk_security.hw, 78 + &clk_dsp.hw, 79 + &clk_gps.hw, 80 + &clk_mf.hw, 81 + &clk_io.hw, 82 + &clk_cpu.hw, 83 + &clk_uart0.hw, 84 + &clk_uart1.hw, 85 + &clk_uart2.hw, 86 + &clk_tsc.hw, 87 + &clk_i2c0.hw, 88 + &clk_i2c1.hw, 89 + &clk_spi0.hw, 90 + &clk_spi1.hw, 91 + &clk_pwmc.hw, 92 + &clk_efuse.hw, 93 + &clk_pulse.hw, 94 + &clk_dmac0.hw, 95 + &clk_dmac1.hw, 96 + &clk_nand.hw, 97 + &clk_audio.hw, 98 + &clk_usp0.hw, 99 + &clk_usp1.hw, 100 + &clk_usp2.hw, 101 + &clk_vip.hw, 102 + &clk_gfx.hw, 103 + &clk_gfx2d.hw, 104 + &clk_lcd.hw, 105 + &clk_vpp.hw, 106 + &clk_mmc01.hw, 107 + &clk_mmc23.hw, 108 + &clk_mmc45.hw, 109 + &usb_pll_clk_hw, 110 + &clk_usb0.hw, 111 + &clk_usb1.hw, 112 + &clk_cphif.hw, 113 + }; 114 + 115 + static struct clk *atlas6_clks[maxclk]; 116 + 117 + static void __init atlas6_clk_init(struct device_node *np) 118 + { 119 + struct device_node *rscnp; 120 + int i; 121 + 122 + rscnp = of_find_compatible_node(NULL, NULL, "sirf,prima2-rsc"); 123 + sirfsoc_rsc_vbase = of_iomap(rscnp, 0); 124 + if (!sirfsoc_rsc_vbase) 125 + panic("unable to map rsc registers\n"); 126 + of_node_put(rscnp); 127 + 128 + sirfsoc_clk_vbase = of_iomap(np, 0); 129 + if (!sirfsoc_clk_vbase) 130 + panic("unable to map clkc registers\n"); 131 + 132 + /* These are always available (RTC and 26MHz OSC)*/ 133 + atlas6_clks[rtc] = clk_register_fixed_rate(NULL, "rtc", NULL, 134 + CLK_IS_ROOT, 32768); 135 + atlas6_clks[osc] = clk_register_fixed_rate(NULL, "osc", NULL, 136 + CLK_IS_ROOT, 26000000); 137 + 138 + for (i = pll1; i < maxclk; i++) { 139 + atlas6_clks[i] = clk_register(NULL, atlas6_clk_hw_array[i]); 140 + BUG_ON(!atlas6_clks[i]); 141 + } 142 + clk_register_clkdev(atlas6_clks[cpu], NULL, "cpu"); 143 + clk_register_clkdev(atlas6_clks[io], NULL, "io"); 144 + clk_register_clkdev(atlas6_clks[mem], NULL, "mem"); 145 + clk_register_clkdev(atlas6_clks[mem], NULL, "osc"); 146 + 147 + clk_data.clks = atlas6_clks; 148 + clk_data.clk_num = maxclk; 149 + 150 + of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data); 151 + } 152 + CLK_OF_DECLARE(atlas6_clk, "sirf,atlas6-clkc", atlas6_clk_init);
+151
drivers/clk/sirf/clk-prima2.c
··· 1 + /* 2 + * Clock tree for CSR SiRFprimaII 3 + * 4 + * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company. 5 + * 6 + * Licensed under GPLv2 or later. 7 + */ 8 + 9 + #include <linux/module.h> 10 + #include <linux/bitops.h> 11 + #include <linux/io.h> 12 + #include <linux/clk.h> 13 + #include <linux/clkdev.h> 14 + #include <linux/clk-provider.h> 15 + #include <linux/of_address.h> 16 + #include <linux/syscore_ops.h> 17 + 18 + #include "prima2.h" 19 + #include "clk-common.c" 20 + 21 + static struct clk_dmn clk_mmc01 = { 22 + .regofs = SIRFSOC_CLKC_MMC_CFG, 23 + .enable_bit = 59, 24 + .hw = { 25 + .init = &clk_mmc01_init, 26 + }, 27 + }; 28 + 29 + static struct clk_dmn clk_mmc23 = { 30 + .regofs = SIRFSOC_CLKC_MMC_CFG, 31 + .enable_bit = 60, 32 + .hw = { 33 + .init = &clk_mmc23_init, 34 + }, 35 + }; 36 + 37 + static struct clk_dmn clk_mmc45 = { 38 + .regofs = SIRFSOC_CLKC_MMC_CFG, 39 + .enable_bit = 61, 40 + .hw = { 41 + .init = &clk_mmc45_init, 42 + }, 43 + }; 44 + 45 + static struct clk_init_data clk_nand_init = { 46 + .name = "nand", 47 + .ops = &ios_ops, 48 + .parent_names = std_clk_io_parents, 49 + .num_parents = ARRAY_SIZE(std_clk_io_parents), 50 + }; 51 + 52 + static struct clk_std clk_nand = { 53 + .enable_bit = 34, 54 + .hw = { 55 + .init = &clk_nand_init, 56 + }, 57 + }; 58 + 59 + enum prima2_clk_index { 60 + /* 0 1 2 3 4 5 6 7 8 9 */ 61 + rtc, osc, pll1, pll2, pll3, mem, sys, security, dsp, gps, 62 + mf, io, cpu, uart0, uart1, uart2, tsc, i2c0, i2c1, spi0, 63 + spi1, pwmc, efuse, pulse, dmac0, dmac1, nand, audio, usp0, usp1, 64 + usp2, vip, gfx, mm, lcd, vpp, mmc01, mmc23, mmc45, usbpll, 65 + usb0, usb1, cphif, maxclk, 66 + }; 67 + 68 + static __initdata struct clk_hw *prima2_clk_hw_array[maxclk] = { 69 + NULL, /* dummy */ 70 + NULL, 71 + &clk_pll1.hw, 72 + &clk_pll2.hw, 73 + &clk_pll3.hw, 74 + &clk_mem.hw, 75 + &clk_sys.hw, 76 + &clk_security.hw, 77 + &clk_dsp.hw, 78 + &clk_gps.hw, 79 + &clk_mf.hw, 80 + &clk_io.hw, 81 + &clk_cpu.hw, 82 + &clk_uart0.hw, 83 + &clk_uart1.hw, 84 + &clk_uart2.hw, 85 + &clk_tsc.hw, 86 + &clk_i2c0.hw, 87 + &clk_i2c1.hw, 88 + &clk_spi0.hw, 89 + &clk_spi1.hw, 90 + &clk_pwmc.hw, 91 + &clk_efuse.hw, 92 + &clk_pulse.hw, 93 + &clk_dmac0.hw, 94 + &clk_dmac1.hw, 95 + &clk_nand.hw, 96 + &clk_audio.hw, 97 + &clk_usp0.hw, 98 + &clk_usp1.hw, 99 + &clk_usp2.hw, 100 + &clk_vip.hw, 101 + &clk_gfx.hw, 102 + &clk_mm.hw, 103 + &clk_lcd.hw, 104 + &clk_vpp.hw, 105 + &clk_mmc01.hw, 106 + &clk_mmc23.hw, 107 + &clk_mmc45.hw, 108 + &usb_pll_clk_hw, 109 + &clk_usb0.hw, 110 + &clk_usb1.hw, 111 + &clk_cphif.hw, 112 + }; 113 + 114 + static struct clk *prima2_clks[maxclk]; 115 + 116 + static void __init prima2_clk_init(struct device_node *np) 117 + { 118 + struct device_node *rscnp; 119 + int i; 120 + 121 + rscnp = of_find_compatible_node(NULL, NULL, "sirf,prima2-rsc"); 122 + sirfsoc_rsc_vbase = of_iomap(rscnp, 0); 123 + if (!sirfsoc_rsc_vbase) 124 + panic("unable to map rsc registers\n"); 125 + of_node_put(rscnp); 126 + 127 + sirfsoc_clk_vbase = of_iomap(np, 0); 128 + if (!sirfsoc_clk_vbase) 129 + panic("unable to map clkc registers\n"); 130 + 131 + /* These are always available (RTC and 26MHz OSC)*/ 132 + prima2_clks[rtc] = clk_register_fixed_rate(NULL, "rtc", NULL, 133 + CLK_IS_ROOT, 32768); 134 + prima2_clks[osc] = clk_register_fixed_rate(NULL, "osc", NULL, 135 + CLK_IS_ROOT, 26000000); 136 + 137 + for (i = pll1; i < maxclk; i++) { 138 + prima2_clks[i] = clk_register(NULL, prima2_clk_hw_array[i]); 139 + BUG_ON(!prima2_clks[i]); 140 + } 141 + clk_register_clkdev(prima2_clks[cpu], NULL, "cpu"); 142 + clk_register_clkdev(prima2_clks[io], NULL, "io"); 143 + clk_register_clkdev(prima2_clks[mem], NULL, "mem"); 144 + clk_register_clkdev(prima2_clks[mem], NULL, "osc"); 145 + 146 + clk_data.clks = prima2_clks; 147 + clk_data.clk_num = maxclk; 148 + 149 + of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data); 150 + } 151 + CLK_OF_DECLARE(prima2_clk, "sirf,prima2-clkc", prima2_clk_init);
+25
drivers/clk/sirf/prima2.h
··· 1 + #define SIRFSOC_CLKC_CLK_EN0 0x0000 2 + #define SIRFSOC_CLKC_CLK_EN1 0x0004 3 + #define SIRFSOC_CLKC_REF_CFG 0x0014 4 + #define SIRFSOC_CLKC_CPU_CFG 0x0018 5 + #define SIRFSOC_CLKC_MEM_CFG 0x001c 6 + #define SIRFSOC_CLKC_SYS_CFG 0x0020 7 + #define SIRFSOC_CLKC_IO_CFG 0x0024 8 + #define SIRFSOC_CLKC_DSP_CFG 0x0028 9 + #define SIRFSOC_CLKC_GFX_CFG 0x002c 10 + #define SIRFSOC_CLKC_MM_CFG 0x0030 11 + #define SIRFSOC_CLKC_LCD_CFG 0x0034 12 + #define SIRFSOC_CLKC_MMC_CFG 0x0038 13 + #define SIRFSOC_CLKC_PLL1_CFG0 0x0040 14 + #define SIRFSOC_CLKC_PLL2_CFG0 0x0044 15 + #define SIRFSOC_CLKC_PLL3_CFG0 0x0048 16 + #define SIRFSOC_CLKC_PLL1_CFG1 0x004c 17 + #define SIRFSOC_CLKC_PLL2_CFG1 0x0050 18 + #define SIRFSOC_CLKC_PLL3_CFG1 0x0054 19 + #define SIRFSOC_CLKC_PLL1_CFG2 0x0058 20 + #define SIRFSOC_CLKC_PLL2_CFG2 0x005c 21 + #define SIRFSOC_CLKC_PLL3_CFG2 0x0060 22 + #define SIRFSOC_USBPHY_PLL_CTRL 0x0008 23 + #define SIRFSOC_USBPHY_PLL_POWERDOWN BIT(1) 24 + #define SIRFSOC_USBPHY_PLL_BYPASS BIT(2) 25 + #define SIRFSOC_USBPHY_PLL_LOCK BIT(3)