sun4i_a10_ccu.c revision 1.16.16.1       1  1.16.16.1    bouyer /* $NetBSD: sun4i_a10_ccu.c,v 1.16.16.1 2022/10/02 10:37:12 bouyer Exp $ */
      2        1.1  jmcneill 
      3        1.1  jmcneill /*-
      4        1.1  jmcneill  * Copyright (c) 2017 Jared McNeill <jmcneill (at) invisible.ca>
      5        1.1  jmcneill  * All rights reserved.
      6        1.1  jmcneill  *
      7        1.1  jmcneill  * Redistribution and use in source and binary forms, with or without
      8        1.1  jmcneill  * modification, are permitted provided that the following conditions
      9        1.1  jmcneill  * are met:
     10        1.1  jmcneill  * 1. Redistributions of source code must retain the above copyright
     11        1.1  jmcneill  *    notice, this list of conditions and the following disclaimer.
     12        1.1  jmcneill  * 2. Redistributions in binary form must reproduce the above copyright
     13        1.1  jmcneill  *    notice, this list of conditions and the following disclaimer in the
     14        1.1  jmcneill  *    documentation and/or other materials provided with the distribution.
     15        1.1  jmcneill  *
     16        1.1  jmcneill  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17        1.1  jmcneill  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18        1.1  jmcneill  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19        1.1  jmcneill  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     20        1.1  jmcneill  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     21        1.1  jmcneill  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     22        1.1  jmcneill  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     23        1.1  jmcneill  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     24        1.1  jmcneill  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25        1.1  jmcneill  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26        1.1  jmcneill  * SUCH DAMAGE.
     27        1.1  jmcneill  */
     28        1.1  jmcneill 
     29        1.1  jmcneill #include <sys/cdefs.h>
     30        1.1  jmcneill 
     31  1.16.16.1    bouyer __KERNEL_RCSID(1, "$NetBSD: sun4i_a10_ccu.c,v 1.16.16.1 2022/10/02 10:37:12 bouyer Exp $");
     32        1.1  jmcneill 
     33        1.1  jmcneill #include <sys/param.h>
     34        1.1  jmcneill #include <sys/bus.h>
     35        1.1  jmcneill #include <sys/device.h>
     36        1.1  jmcneill #include <sys/systm.h>
     37        1.1  jmcneill 
     38        1.1  jmcneill #include <dev/fdt/fdtvar.h>
     39        1.1  jmcneill 
     40        1.1  jmcneill #include <arm/sunxi/sunxi_ccu.h>
     41        1.1  jmcneill #include <arm/sunxi/sun4i_a10_ccu.h>
     42        1.1  jmcneill #include <arm/sunxi/sun7i_a20_ccu.h>
     43        1.1  jmcneill 
     44        1.1  jmcneill #define	PLL1_CFG_REG		0x000
     45        1.1  jmcneill #define	PLL2_CFG_REG		0x008
     46        1.7    bouyer #define	PLL3_CFG_REG		0x010
     47        1.7    bouyer #define	PLL5_CFG_REG		0x020
     48        1.1  jmcneill #define	PLL6_CFG_REG		0x028
     49        1.7    bouyer #define	PLL7_CFG_REG		0x030
     50  1.16.16.1    bouyer #define	PLL8_CFG_REG		0x040
     51        1.1  jmcneill #define	OSC24M_CFG_REG		0x050
     52        1.1  jmcneill #define	CPU_AHB_APB0_CFG_REG	0x054
     53        1.1  jmcneill #define	APB1_CLK_DIV_REG	0x058
     54        1.1  jmcneill #define	AHB_GATING_REG0		0x060
     55        1.1  jmcneill #define	AHB_GATING_REG1		0x064
     56        1.1  jmcneill #define	APB0_GATING_REG		0x068
     57        1.1  jmcneill #define	APB1_GATING_REG		0x06c
     58        1.5  jmcneill #define	NAND_SCLK_CFG_REG	0x080
     59        1.1  jmcneill #define	SD0_SCLK_CFG_REG        0x088
     60        1.1  jmcneill #define	SD1_SCLK_CFG_REG        0x08c
     61        1.1  jmcneill #define	SD2_SCLK_CFG_REG        0x090
     62        1.1  jmcneill #define	SD3_SCLK_CFG_REG	0x094
     63       1.11       tnn #define	SPI0_CLK_CFG_REG	0x0a0
     64       1.11       tnn #define	SPI1_CLK_CFG_REG	0x0a4
     65       1.11       tnn #define	SPI2_CLK_CFG_REG	0x0a8
     66        1.3  jmcneill #define	SATA_CFG_REG		0x0c8
     67        1.1  jmcneill #define	USBPHY_CFG_REG		0x0cc
     68       1.11       tnn #define	SPI3_CLK_CFG_REG	0x0d4
     69        1.7    bouyer #define	DRAM_GATING_REG		0x100
     70        1.7    bouyer #define	BE0_CFG_REG		0x104
     71        1.7    bouyer #define	BE1_CFG_REG		0x108
     72        1.7    bouyer #define	FE0_CFG_REG		0x10c
     73        1.7    bouyer #define	FE1_CFG_REG		0x110
     74        1.7    bouyer #define	MP_CFG_REG		0x114
     75        1.7    bouyer #define	LCD0CH0_CFG_REG		0x118
     76        1.7    bouyer #define	LCD1CH0_CFG_REG		0x11c
     77        1.7    bouyer #define LCD0CH1_CFG_REG		0x12c
     78        1.7    bouyer #define LCD1CH1_CFG_REG		0x130
     79        1.1  jmcneill #define	CSI_CFG_REG		0x134
     80        1.1  jmcneill #define	VE_CFG_REG		0x13c
     81        1.1  jmcneill #define	AUDIO_CODEC_SCLK_CFG_REG 0x140
     82        1.9    bouyer #define	LVDS_CFG_REG 		0x14c
     83        1.7    bouyer #define	HDMI_CLOCK_CFG_REG	0x150
     84  1.16.16.1    bouyer #define	MALI_CFG_REG		0x154
     85        1.1  jmcneill #define	IEP_SCLK_CFG_REG	0x160
     86       1.12  jmcneill #define	CLK_OUTA_REG		0x1f0
     87       1.12  jmcneill #define	CLK_OUTB_REG		0x1f4
     88        1.1  jmcneill 
     89        1.1  jmcneill static int sun4i_a10_ccu_match(device_t, cfdata_t, void *);
     90        1.1  jmcneill static void sun4i_a10_ccu_attach(device_t, device_t, void *);
     91        1.1  jmcneill 
     92        1.1  jmcneill enum sun4i_a10_ccu_type {
     93        1.1  jmcneill 	CCU_A10 = 1,
     94        1.1  jmcneill 	CCU_A20,
     95        1.1  jmcneill };
     96        1.1  jmcneill 
     97       1.13   thorpej static const struct device_compatible_entry compat_data[] = {
     98       1.13   thorpej 	{ .compat = "allwinner,sun4i-a10-ccu",	.value = CCU_A10 },
     99       1.13   thorpej 	{ .compat = "allwinner,sun7i-a20-ccu",	.value = CCU_A20 },
    100       1.15   thorpej 	DEVICE_COMPAT_EOL
    101        1.1  jmcneill };
    102        1.1  jmcneill 
    103        1.1  jmcneill CFATTACH_DECL_NEW(sunxi_a10_ccu, sizeof(struct sunxi_ccu_softc),
    104        1.1  jmcneill 	sun4i_a10_ccu_match, sun4i_a10_ccu_attach, NULL, NULL);
    105        1.1  jmcneill 
    106        1.1  jmcneill static struct sunxi_ccu_reset sun4i_a10_ccu_resets[] = {
    107        1.1  jmcneill 	SUNXI_CCU_RESET(A10_RST_USB_PHY0, USBPHY_CFG_REG, 0),
    108        1.1  jmcneill 	SUNXI_CCU_RESET(A10_RST_USB_PHY1, USBPHY_CFG_REG, 1),
    109        1.1  jmcneill 	SUNXI_CCU_RESET(A10_RST_USB_PHY2, USBPHY_CFG_REG, 2),
    110        1.7    bouyer 	SUNXI_CCU_RESET(A10_RST_DE_BE0, BE0_CFG_REG, 30),
    111        1.7    bouyer 	SUNXI_CCU_RESET(A10_RST_DE_BE1, BE1_CFG_REG, 30),
    112        1.7    bouyer 	SUNXI_CCU_RESET(A10_RST_DE_FE0, FE0_CFG_REG, 30),
    113        1.7    bouyer 	SUNXI_CCU_RESET(A10_RST_DE_FE1, FE1_CFG_REG, 30),
    114        1.7    bouyer 	SUNXI_CCU_RESET(A10_RST_DE_MP, MP_CFG_REG, 30),
    115        1.7    bouyer 	SUNXI_CCU_RESET(A10_RST_TCON0, LCD0CH0_CFG_REG, 30),
    116        1.7    bouyer 	SUNXI_CCU_RESET(A10_RST_TCON1, LCD1CH0_CFG_REG, 30),
    117        1.9    bouyer 	SUNXI_CCU_RESET(A10_RST_LVDS, LVDS_CFG_REG, 0),
    118  1.16.16.1    bouyer 	SUNXI_CCU_RESET(A10_RST_GPU, MALI_CFG_REG, 30),
    119        1.1  jmcneill };
    120        1.1  jmcneill 
    121        1.1  jmcneill static const char *cpu_parents[] = { "losc", "osc24m", "pll_core", "pll_periph" };
    122        1.1  jmcneill static const char *axi_parents[] = { "cpu" };
    123        1.1  jmcneill static const char *ahb_parents[] = { "axi", "pll_periph", "pll_periph_base" };
    124        1.1  jmcneill static const char *apb0_parents[] = { "ahb" };
    125        1.1  jmcneill static const char *apb1_parents[] = { "osc24m", "pll_periph", "losc" };
    126        1.7    bouyer static const char *mod_parents[] = { "osc24m", "pll_periph", "pll_ddr_other" };
    127        1.3  jmcneill static const char *sata_parents[] = { "pll6_periph_sata", "external" };
    128        1.7    bouyer static const char *de_parents[] = { "pll_video0", "pll_video1", "pll_ddr_other" };
    129        1.8    bouyer static const char *lcd_parents[] = { "pll_video0", "pll_video1", "pll_video0x2", "pll_video1x2" };
    130       1.12  jmcneill static const char *out_parents[] = { "losc" /* really OSC24MHz/750 */, "losc", "osc24m" };
    131  1.16.16.1    bouyer static const char *gpu_parents[] = { "pll_gpu" };
    132        1.1  jmcneill 
    133        1.4  jmcneill static const struct sunxi_ccu_nkmp_tbl sun4i_a10_pll1_table[] = {
    134        1.4  jmcneill 	{ 1008000000, 21, 1, 0, 0 },
    135        1.4  jmcneill 	{  960000000, 20, 1, 0, 0 },
    136        1.4  jmcneill 	{  912000000, 19, 1, 0, 0 },
    137        1.4  jmcneill 	{  864000000, 18, 1, 0, 0 },
    138        1.4  jmcneill 	{  720000000, 30, 0, 0, 0 },
    139        1.6  jmcneill 	{  624000000, 26, 0, 0, 0 },
    140        1.4  jmcneill 	{  528000000, 22, 0, 0, 0 },
    141        1.4  jmcneill 	{  312000000, 13, 0, 0, 0 },
    142        1.4  jmcneill 	{  144000000, 12, 0, 0, 1 },
    143        1.4  jmcneill 	{          0 }
    144        1.4  jmcneill };
    145        1.4  jmcneill 
    146        1.1  jmcneill static const struct sunxi_ccu_nkmp_tbl sun4i_a10_ac_dig_table[] = {
    147        1.9    bouyer 	{ 24576000, 86, 0, 21, 4 },
    148        1.1  jmcneill 	{ 0 }
    149        1.1  jmcneill };
    150        1.1  jmcneill 
    151        1.8    bouyer /*
    152        1.8    bouyer  * some special cases
    153        1.8    bouyer  * hardcode lcd0 (tcon0) to pll3 and lcd1 (tcon1) to pll7.
    154        1.8    bouyer  * compute pll rate based on desired pixel clock
    155        1.8    bouyer  */
    156        1.8    bouyer 
    157        1.8    bouyer static int sun4i_a10_ccu_lcd0ch0_set_rate(struct sunxi_ccu_softc *,
    158        1.8    bouyer     struct sunxi_ccu_clk *, u_int);
    159        1.8    bouyer static int sun4i_a10_ccu_lcd1ch0_set_rate(struct sunxi_ccu_softc *,
    160        1.8    bouyer     struct sunxi_ccu_clk *, u_int);
    161        1.8    bouyer static u_int sun4i_a10_ccu_lcd0ch0_round_rate(struct sunxi_ccu_softc *,
    162        1.8    bouyer     struct sunxi_ccu_clk *, u_int);
    163        1.8    bouyer static u_int sun4i_a10_ccu_lcd1ch0_round_rate(struct sunxi_ccu_softc *,
    164        1.8    bouyer     struct sunxi_ccu_clk *, u_int);
    165        1.8    bouyer static int sun4i_a10_ccu_lcd0ch1_set_rate(struct sunxi_ccu_softc *,
    166        1.8    bouyer     struct sunxi_ccu_clk *, u_int);
    167        1.8    bouyer static int sun4i_a10_ccu_lcd1ch1_set_rate(struct sunxi_ccu_softc *,
    168        1.8    bouyer     struct sunxi_ccu_clk *, u_int);
    169        1.8    bouyer 
    170        1.1  jmcneill static struct sunxi_ccu_clk sun4i_a10_ccu_clks[] = {
    171        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_HOSC, "osc24m", "hosc",
    172        1.1  jmcneill 	    OSC24M_CFG_REG, 0),
    173        1.1  jmcneill 
    174        1.4  jmcneill 	SUNXI_CCU_NKMP_TABLE(A10_CLK_PLL_CORE, "pll_core", "osc24m",
    175        1.1  jmcneill 	    PLL1_CFG_REG,		/* reg */
    176        1.1  jmcneill 	    __BITS(12,8),		/* n */
    177        1.1  jmcneill 	    __BITS(5,4), 		/* k */
    178        1.1  jmcneill 	    __BITS(1,0),		/* m */
    179        1.1  jmcneill 	    __BITS(17,16),		/* p */
    180        1.1  jmcneill 	    __BIT(31),			/* enable */
    181        1.4  jmcneill 	    0,				/* lock */
    182        1.4  jmcneill 	    sun4i_a10_pll1_table,	/* table */
    183        1.1  jmcneill 	    SUNXI_CCU_NKMP_FACTOR_P_POW2 | SUNXI_CCU_NKMP_FACTOR_N_EXACT |
    184        1.4  jmcneill 	    SUNXI_CCU_NKMP_FACTOR_N_ZERO_IS_ONE | SUNXI_CCU_NKMP_SCALE_CLOCK),
    185        1.1  jmcneill 
    186        1.1  jmcneill 	SUNXI_CCU_NKMP_TABLE(A10_CLK_PLL_AUDIO_BASE, "pll_audio", "osc24m",
    187        1.1  jmcneill 	    PLL2_CFG_REG,		/* reg */
    188        1.1  jmcneill 	    __BITS(14,8),		/* n */
    189        1.1  jmcneill 	    0,				/* k */
    190        1.1  jmcneill 	    __BITS(4,0),		/* m */
    191        1.1  jmcneill 	    __BITS(29,26),		/* p */
    192        1.1  jmcneill 	    __BIT(31),			/* enable */
    193        1.1  jmcneill 	    0,				/* lock */
    194        1.1  jmcneill 	    sun4i_a10_ac_dig_table,	/* table */
    195        1.1  jmcneill 	    0),
    196        1.1  jmcneill 
    197        1.1  jmcneill 	SUNXI_CCU_NKMP(A10_CLK_PLL_PERIPH_BASE, "pll_periph_base", "osc24m",
    198        1.1  jmcneill 	    PLL6_CFG_REG,		/* reg */
    199        1.1  jmcneill 	    __BITS(12,8),		/* n */
    200        1.1  jmcneill 	    __BITS(5,4), 		/* k */
    201        1.1  jmcneill 	    0,				/* m */
    202        1.1  jmcneill 	    0,				/* p */
    203        1.1  jmcneill 	    __BIT(31),			/* enable */
    204        1.1  jmcneill 	    SUNXI_CCU_NKMP_FACTOR_N_EXACT),
    205        1.1  jmcneill 
    206        1.1  jmcneill 	SUNXI_CCU_FIXED_FACTOR(A10_CLK_PLL_PERIPH, "pll_periph", "pll_periph_base",
    207        1.1  jmcneill 	    2, 1),
    208        1.1  jmcneill 
    209        1.1  jmcneill 	SUNXI_CCU_NKMP(A10_CLK_PLL_PERIPH_SATA, "pll_periph_sata", "pll_periph_base",
    210        1.1  jmcneill 	    PLL6_CFG_REG,		/* reg */
    211        1.1  jmcneill 	    0,				/* n */
    212        1.1  jmcneill 	    0,				/* k */
    213        1.1  jmcneill 	    __BITS(1,0),		/* m */
    214        1.1  jmcneill 	    0,				/* p */
    215        1.1  jmcneill 	    __BIT(14),			/* enable */
    216        1.1  jmcneill 	    0),
    217        1.1  jmcneill 
    218        1.3  jmcneill 	SUNXI_CCU_DIV_GATE(A10_CLK_SATA, "sata", sata_parents,
    219        1.3  jmcneill 	    SATA_CFG_REG,		/* reg */
    220        1.3  jmcneill 	    0,				/* div */
    221        1.3  jmcneill 	    __BIT(24),			/* sel */
    222        1.3  jmcneill 	    __BIT(31),			/* enable */
    223        1.3  jmcneill 	    0),
    224        1.3  jmcneill 
    225        1.7    bouyer 	SUNXI_CCU_NKMP(A10_CLK_PLL_DDR_BASE, "pll_ddr_other", "osc24m",
    226        1.7    bouyer 	    PLL5_CFG_REG,		/* reg */
    227        1.7    bouyer 	    __BITS(12, 8),		/* n */
    228        1.7    bouyer 	    __BITS(5,4),		/* k */
    229        1.7    bouyer 	    0,				/* m */
    230        1.7    bouyer 	    __BITS(17,16),		/* p */
    231        1.7    bouyer 	    __BIT(31),			/* enable */
    232        1.7    bouyer 	    SUNXI_CCU_NKMP_FACTOR_N_EXACT | SUNXI_CCU_NKMP_FACTOR_P_POW2),
    233        1.7    bouyer 
    234        1.7    bouyer 	SUNXI_CCU_NKMP(A10_CLK_PLL_DDR, "pll_ddr", "osc24m",
    235        1.7    bouyer 	    PLL5_CFG_REG,		/* reg */
    236        1.7    bouyer 	    __BITS(12, 8),		/* n */
    237        1.7    bouyer 	    __BITS(5,4),		/* k */
    238        1.7    bouyer 	    __BITS(1,0),		/* m */
    239        1.7    bouyer 	    0,				/* p */
    240        1.7    bouyer 	    __BIT(31),			/* enable */
    241        1.7    bouyer 	    SUNXI_CCU_NKMP_FACTOR_N_EXACT),
    242        1.7    bouyer 
    243        1.1  jmcneill 	SUNXI_CCU_DIV(A10_CLK_CPU, "cpu", cpu_parents,
    244        1.1  jmcneill 	    CPU_AHB_APB0_CFG_REG,	/* reg */
    245        1.1  jmcneill 	    0,				/* div */
    246        1.1  jmcneill 	    __BITS(17,16),		/* sel */
    247        1.4  jmcneill 	    SUNXI_CCU_DIV_SET_RATE_PARENT),
    248        1.1  jmcneill 
    249        1.1  jmcneill 	SUNXI_CCU_DIV(A10_CLK_AXI, "axi", axi_parents,
    250        1.1  jmcneill 	    CPU_AHB_APB0_CFG_REG,	/* reg */
    251        1.1  jmcneill 	    __BITS(1,0),		/* div */
    252        1.1  jmcneill 	    0,				/* sel */
    253        1.1  jmcneill 	    0),
    254        1.1  jmcneill 
    255        1.1  jmcneill 	SUNXI_CCU_DIV(A10_CLK_AHB, "ahb", ahb_parents,
    256        1.1  jmcneill 	    CPU_AHB_APB0_CFG_REG,	/* reg */
    257        1.1  jmcneill 	    __BITS(5,4),		/* div */
    258        1.1  jmcneill 	    __BITS(7,6),		/* sel */
    259        1.1  jmcneill 	    SUNXI_CCU_DIV_POWER_OF_TWO),
    260        1.1  jmcneill 
    261        1.1  jmcneill 	SUNXI_CCU_DIV(A10_CLK_APB0, "apb0", apb0_parents,
    262        1.1  jmcneill 	    CPU_AHB_APB0_CFG_REG,	/* reg */
    263        1.1  jmcneill 	    __BITS(9,8),		/* div */
    264        1.1  jmcneill 	    0,				/* sel */
    265        1.1  jmcneill 	    SUNXI_CCU_DIV_ZERO_IS_ONE | SUNXI_CCU_DIV_POWER_OF_TWO),
    266        1.1  jmcneill 
    267        1.1  jmcneill 	SUNXI_CCU_NM(A10_CLK_APB1, "apb1", apb1_parents,
    268        1.1  jmcneill 	    APB1_CLK_DIV_REG,		/* reg */
    269        1.1  jmcneill 	    __BITS(17,16),		/* n */
    270        1.1  jmcneill 	    __BITS(4,0),		/* m */
    271        1.1  jmcneill 	    __BITS(25,24),		/* sel */
    272        1.1  jmcneill 	    0,				/* enable */
    273        1.1  jmcneill 	    SUNXI_CCU_NM_POWER_OF_TWO),
    274        1.1  jmcneill 
    275        1.5  jmcneill 	SUNXI_CCU_NM(A10_CLK_NAND, "nand", mod_parents,
    276        1.5  jmcneill 	    NAND_SCLK_CFG_REG,		/* reg */
    277        1.5  jmcneill 	    __BITS(17,16),		/* n */
    278        1.5  jmcneill 	    __BITS(3,0),		/* m */
    279        1.5  jmcneill 	    __BITS(25,24),		/* sel */
    280        1.5  jmcneill 	    __BIT(31),			/* enable */
    281        1.5  jmcneill 	    SUNXI_CCU_NM_POWER_OF_TWO),
    282        1.5  jmcneill 
    283       1.11       tnn 	SUNXI_CCU_NM(A10_CLK_SPI0, "spi0", mod_parents,
    284       1.11       tnn 	    SPI0_CLK_CFG_REG,		/* reg */
    285       1.11       tnn 	    __BITS(17,16),		/* n */
    286       1.11       tnn 	    __BITS(3,0),		/* m */
    287       1.11       tnn 	    __BITS(25,24),		/* sel */
    288       1.11       tnn 	    __BIT(31),			/* enable */
    289       1.11       tnn 	    SUNXI_CCU_NM_POWER_OF_TWO),
    290       1.11       tnn 
    291       1.11       tnn 	SUNXI_CCU_NM(A10_CLK_SPI1, "spi1", mod_parents,
    292       1.11       tnn 	    SPI1_CLK_CFG_REG,		/* reg */
    293       1.11       tnn 	    __BITS(17,16),		/* n */
    294       1.11       tnn 	    __BITS(3,0),		/* m */
    295       1.11       tnn 	    __BITS(25,24),		/* sel */
    296       1.11       tnn 	    __BIT(31),			/* enable */
    297       1.11       tnn 	    SUNXI_CCU_NM_POWER_OF_TWO),
    298       1.11       tnn 
    299       1.11       tnn 	SUNXI_CCU_NM(A10_CLK_SPI2, "spi2", mod_parents,
    300       1.11       tnn 	    SPI2_CLK_CFG_REG,		/* reg */
    301       1.11       tnn 	    __BITS(17,16),		/* n */
    302       1.11       tnn 	    __BITS(3,0),		/* m */
    303       1.11       tnn 	    __BITS(25,24),		/* sel */
    304       1.11       tnn 	    __BIT(31),			/* enable */
    305       1.11       tnn 	    SUNXI_CCU_NM_POWER_OF_TWO),
    306       1.11       tnn 
    307       1.11       tnn 	SUNXI_CCU_NM(A10_CLK_SPI3, "spi3", mod_parents,
    308       1.11       tnn 	    SPI3_CLK_CFG_REG,		/* reg */
    309       1.11       tnn 	    __BITS(17,16),		/* n */
    310       1.11       tnn 	    __BITS(3,0),		/* m */
    311       1.11       tnn 	    __BITS(25,24),		/* sel */
    312       1.11       tnn 	    __BIT(31),			/* enable */
    313       1.11       tnn 	    SUNXI_CCU_NM_POWER_OF_TWO),
    314       1.11       tnn 
    315        1.1  jmcneill 	SUNXI_CCU_NM(A10_CLK_MMC0, "mmc0", mod_parents,
    316        1.1  jmcneill 	    SD0_SCLK_CFG_REG,		/* reg */
    317        1.1  jmcneill 	    __BITS(17,16),		/* n */
    318        1.1  jmcneill 	    __BITS(3,0),		/* m */
    319        1.1  jmcneill 	    __BITS(25,24),		/* sel */
    320        1.1  jmcneill 	    __BIT(31),			/* enable */
    321        1.1  jmcneill 	    SUNXI_CCU_NM_POWER_OF_TWO),
    322        1.2  jmcneill 	SUNXI_CCU_PHASE(A10_CLK_MMC0_SAMPLE, "mmc0_sample", "mmc0",
    323        1.2  jmcneill 	    SD0_SCLK_CFG_REG, __BITS(22,20)),
    324        1.2  jmcneill 	SUNXI_CCU_PHASE(A10_CLK_MMC0_OUTPUT, "mmc0_output", "mmc0",
    325        1.2  jmcneill 	    SD0_SCLK_CFG_REG, __BITS(10,8)),
    326        1.1  jmcneill 	SUNXI_CCU_NM(A10_CLK_MMC1, "mmc1", mod_parents,
    327        1.1  jmcneill 	    SD1_SCLK_CFG_REG,		/* reg */
    328        1.1  jmcneill 	    __BITS(17,16),		/* n */
    329        1.1  jmcneill 	    __BITS(3,0),		/* m */
    330        1.1  jmcneill 	    __BITS(25,24),		/* sel */
    331        1.1  jmcneill 	    __BIT(31),			/* enable */
    332        1.1  jmcneill 	    SUNXI_CCU_NM_POWER_OF_TWO),
    333        1.2  jmcneill 	SUNXI_CCU_PHASE(A10_CLK_MMC1_SAMPLE, "mmc1_sample", "mmc1",
    334        1.2  jmcneill 	    SD1_SCLK_CFG_REG, __BITS(22,20)),
    335        1.2  jmcneill 	SUNXI_CCU_PHASE(A10_CLK_MMC1_OUTPUT, "mmc1_output", "mmc1",
    336        1.2  jmcneill 	    SD1_SCLK_CFG_REG, __BITS(10,8)),
    337        1.1  jmcneill 	SUNXI_CCU_NM(A10_CLK_MMC2, "mmc2", mod_parents,
    338        1.1  jmcneill 	    SD2_SCLK_CFG_REG,		/* reg */
    339        1.1  jmcneill 	    __BITS(17,16),		/* n */
    340        1.1  jmcneill 	    __BITS(3,0),		/* m */
    341        1.1  jmcneill 	    __BITS(25,24),		/* sel */
    342        1.1  jmcneill 	    __BIT(31),			/* enable */
    343        1.1  jmcneill 	    SUNXI_CCU_NM_POWER_OF_TWO),
    344        1.2  jmcneill 	SUNXI_CCU_PHASE(A10_CLK_MMC2_SAMPLE, "mmc2_sample", "mmc2",
    345        1.2  jmcneill 	    SD2_SCLK_CFG_REG, __BITS(22,20)),
    346        1.2  jmcneill 	SUNXI_CCU_PHASE(A10_CLK_MMC2_OUTPUT, "mmc2_output", "mmc2",
    347        1.2  jmcneill 	    SD2_SCLK_CFG_REG, __BITS(10,8)),
    348        1.1  jmcneill 	SUNXI_CCU_NM(A10_CLK_MMC3, "mmc3", mod_parents,
    349        1.1  jmcneill 	    SD3_SCLK_CFG_REG,		/* reg */
    350        1.1  jmcneill 	    __BITS(17,16),		/* n */
    351        1.1  jmcneill 	    __BITS(3,0),		/* m */
    352        1.1  jmcneill 	    __BITS(25,24),		/* sel */
    353        1.1  jmcneill 	    __BIT(31),			/* enable */
    354        1.1  jmcneill 	    SUNXI_CCU_NM_POWER_OF_TWO),
    355        1.2  jmcneill 	SUNXI_CCU_PHASE(A10_CLK_MMC3_SAMPLE, "mmc3_sample", "mmc3",
    356        1.2  jmcneill 	    SD3_SCLK_CFG_REG, __BITS(22,20)),
    357        1.2  jmcneill 	SUNXI_CCU_PHASE(A10_CLK_MMC3_OUTPUT, "mmc3_output", "mmc3",
    358        1.2  jmcneill 	    SD3_SCLK_CFG_REG, __BITS(10,8)),
    359        1.1  jmcneill 
    360        1.7    bouyer 	SUNXI_CCU_FRACTIONAL(A10_CLK_PLL_VIDEO0, "pll_video0", "osc24m",
    361        1.7    bouyer 	    PLL3_CFG_REG,		/* reg */
    362        1.7    bouyer 	    __BITS(7,0),		/* m */
    363        1.7    bouyer 	    9,				/* m_min */
    364        1.7    bouyer 	    127,			/* m_max */
    365        1.8    bouyer 	    __BIT(15),			/* div_en */
    366        1.7    bouyer 	    __BIT(14),			/* frac_sel */
    367        1.7    bouyer 	    270000000, 297000000,	/* frac values */
    368       1.10  jmcneill 	    0,				/* prediv */
    369       1.10  jmcneill 	    8,				/* prediv_val */
    370       1.10  jmcneill 	    __BIT(31),			/* enable */
    371       1.10  jmcneill 	    0),
    372        1.7    bouyer 	SUNXI_CCU_FRACTIONAL(A10_CLK_PLL_VIDEO1, "pll_video1", "osc24m",
    373        1.7    bouyer 	    PLL7_CFG_REG,		/* reg */
    374        1.7    bouyer 	    __BITS(7,0),		/* m */
    375        1.7    bouyer 	    9,				/* m_min */
    376        1.7    bouyer 	    127,			/* m_max */
    377        1.8    bouyer 	    __BIT(15),			/* div_en */
    378        1.7    bouyer 	    __BIT(14),			/* frac_sel */
    379        1.7    bouyer 	    270000000, 297000000,	/* frac values */
    380       1.10  jmcneill 	    0,				/* prediv */
    381       1.10  jmcneill 	    8,				/* prediv_val */
    382       1.10  jmcneill 	    __BIT(31),			/* enable */
    383       1.10  jmcneill 	    0),
    384        1.7    bouyer 	SUNXI_CCU_FIXED_FACTOR(A10_CLK_PLL_VIDEO0_2X,
    385        1.7    bouyer 	    "pll_video0x2", "pll_video0",
    386        1.7    bouyer 	    1, 2),
    387        1.7    bouyer 	SUNXI_CCU_FIXED_FACTOR(A10_CLK_PLL_VIDEO1_2X,
    388        1.7    bouyer 	    "pll_video1x2", "pll_video1",
    389        1.7    bouyer 	    1, 2),
    390  1.16.16.1    bouyer 	SUNXI_CCU_NKMP(A10_CLK_PLL_GPU, "pll_gpu", "osc24m",
    391  1.16.16.1    bouyer 	    PLL8_CFG_REG,		/* reg */
    392  1.16.16.1    bouyer 	    __BITS(12, 8),		/* n */
    393  1.16.16.1    bouyer 	    __BITS(5,4),		/* k */
    394  1.16.16.1    bouyer 	    0,				/* m */
    395  1.16.16.1    bouyer 	    0,				/* p */
    396  1.16.16.1    bouyer 	    __BIT(31),			/* enable */
    397  1.16.16.1    bouyer 	    SUNXI_CCU_NKMP_FACTOR_N_EXACT),
    398        1.7    bouyer 
    399        1.7    bouyer 	SUNXI_CCU_DIV_GATE(A10_CLK_DE_BE0, "debe0-mod", de_parents,
    400        1.7    bouyer 	    BE0_CFG_REG,		/* reg */
    401        1.7    bouyer 	    __BITS(3,0),		/* div */
    402        1.7    bouyer 	    __BITS(25,24),		/* sel */
    403        1.7    bouyer 	    __BIT(31),			/* enable */
    404        1.7    bouyer 	    0				/* flags */
    405        1.7    bouyer 	    ),
    406        1.7    bouyer 	SUNXI_CCU_DIV_GATE(A10_CLK_DE_BE1, "debe1-mod", de_parents,
    407        1.7    bouyer 	    BE1_CFG_REG,		/* reg */
    408        1.7    bouyer 	    __BITS(3,0),		/* div */
    409        1.7    bouyer 	    __BITS(25,24),		/* sel */
    410        1.7    bouyer 	    __BIT(31),			/* enable */
    411        1.7    bouyer 	    0				/* flags */
    412        1.7    bouyer 	    ),
    413        1.7    bouyer 	SUNXI_CCU_DIV_GATE(A10_CLK_DE_FE0, "defe0-mod", de_parents,
    414        1.7    bouyer 	    FE0_CFG_REG,		/* reg */
    415        1.7    bouyer 	    __BITS(3,0),		/* div */
    416        1.7    bouyer 	    __BITS(25,24),		/* sel */
    417        1.7    bouyer 	    __BIT(31),			/* enable */
    418        1.7    bouyer 	    0				/* flags */
    419        1.7    bouyer 	    ),
    420        1.7    bouyer 	SUNXI_CCU_DIV_GATE(A10_CLK_DE_FE1, "defe1-mod", de_parents,
    421        1.7    bouyer 	    FE1_CFG_REG,		/* reg */
    422        1.7    bouyer 	    __BITS(3,0),		/* div */
    423        1.7    bouyer 	    __BITS(25,24),		/* sel */
    424        1.7    bouyer 	    __BIT(31),			/* enable */
    425        1.7    bouyer 	    0				/* flags */
    426        1.7    bouyer 	    ),
    427        1.8    bouyer 	[A10_CLK_TCON0_CH0] = {
    428        1.8    bouyer 	    .type = SUNXI_CCU_DIV,
    429        1.8    bouyer 	    .base.name = "tcon0-ch0",
    430        1.8    bouyer 	    .u.div.reg = LCD0CH0_CFG_REG,
    431        1.8    bouyer 	    .u.div.parents = lcd_parents,
    432        1.8    bouyer 	    .u.div.nparents = __arraycount(lcd_parents),
    433        1.8    bouyer 	    .u.div.div = 0,
    434        1.8    bouyer 	    .u.div.sel = __BITS(25,24),
    435        1.8    bouyer 	    .u.div.enable = __BIT(31),
    436        1.8    bouyer 	    .u.div.flags = 0,
    437        1.8    bouyer 	    .enable = sunxi_ccu_div_enable,
    438        1.8    bouyer 	    .get_rate = sunxi_ccu_div_get_rate,
    439        1.8    bouyer 	    .set_rate = sun4i_a10_ccu_lcd0ch0_set_rate,
    440        1.8    bouyer 	    .round_rate = sun4i_a10_ccu_lcd0ch0_round_rate,
    441        1.8    bouyer 	    .set_parent = sunxi_ccu_div_set_parent,
    442        1.8    bouyer 	    .get_parent = sunxi_ccu_div_get_parent,
    443        1.8    bouyer 	    },
    444        1.8    bouyer 	[A10_CLK_TCON1_CH0] = {
    445        1.8    bouyer 	    .type = SUNXI_CCU_DIV,
    446        1.8    bouyer 	    .base.name = "tcon1-ch0",
    447        1.8    bouyer 	    .u.div.reg = LCD1CH0_CFG_REG,
    448        1.8    bouyer 	    .u.div.parents = lcd_parents,
    449        1.8    bouyer 	    .u.div.nparents = __arraycount(lcd_parents),
    450        1.8    bouyer 	    .u.div.div = 0,
    451        1.8    bouyer 	    .u.div.sel = __BITS(25,24),
    452        1.8    bouyer 	    .u.div.enable = __BIT(31),
    453        1.8    bouyer 	    .u.div.flags = 0,
    454        1.8    bouyer 	    .enable = sunxi_ccu_div_enable,
    455        1.8    bouyer 	    .get_rate = sunxi_ccu_div_get_rate,
    456        1.8    bouyer 	    .set_rate = sun4i_a10_ccu_lcd1ch0_set_rate,
    457        1.8    bouyer 	    .round_rate = sun4i_a10_ccu_lcd1ch0_round_rate,
    458        1.8    bouyer 	    .set_parent = sunxi_ccu_div_set_parent,
    459        1.8    bouyer 	    .get_parent = sunxi_ccu_div_get_parent,
    460        1.8    bouyer 	    },
    461        1.8    bouyer 	[A10_CLK_TCON0_CH1] = {
    462        1.8    bouyer 	    .type = SUNXI_CCU_DIV,
    463        1.8    bouyer 	    .base.name = "tcon0-ch1",
    464        1.8    bouyer 	    .u.div.reg = LCD0CH1_CFG_REG,
    465        1.8    bouyer 	    .u.div.parents = lcd_parents,
    466        1.8    bouyer 	    .u.div.nparents = __arraycount(lcd_parents),
    467        1.8    bouyer 	    .u.div.div = __BITS(3,0),
    468        1.8    bouyer 	    .u.div.sel = __BITS(25,24),
    469        1.8    bouyer 	    .u.div.enable = __BIT(15) | __BIT(31),
    470        1.8    bouyer 	    .u.div.flags = 0,
    471        1.8    bouyer 	    .enable = sunxi_ccu_div_enable,
    472        1.8    bouyer 	    .get_rate = sunxi_ccu_div_get_rate,
    473        1.8    bouyer 	    .set_rate = sun4i_a10_ccu_lcd0ch1_set_rate,
    474        1.8    bouyer 	    .set_parent = sunxi_ccu_div_set_parent,
    475        1.8    bouyer 	    .get_parent = sunxi_ccu_div_get_parent,
    476        1.8    bouyer 	    },
    477        1.8    bouyer 	[A10_CLK_TCON1_CH1] = {
    478        1.8    bouyer 	    .type = SUNXI_CCU_DIV,
    479        1.8    bouyer 	    .base.name = "tcon1-ch1",
    480        1.8    bouyer 	    .u.div.reg = LCD1CH1_CFG_REG,
    481        1.8    bouyer 	    .u.div.parents = lcd_parents,
    482        1.8    bouyer 	    .u.div.nparents = __arraycount(lcd_parents),
    483        1.8    bouyer 	    .u.div.div = __BITS(3,0),
    484        1.8    bouyer 	    .u.div.sel = __BITS(25,24),
    485        1.8    bouyer 	    .u.div.enable = __BIT(15) | __BIT(31),
    486        1.8    bouyer 	    .u.div.flags = 0,
    487        1.8    bouyer 	    .enable = sunxi_ccu_div_enable,
    488        1.8    bouyer 	    .get_rate = sunxi_ccu_div_get_rate,
    489        1.8    bouyer 	    .set_rate = sun4i_a10_ccu_lcd1ch1_set_rate,
    490        1.8    bouyer 	    .set_parent = sunxi_ccu_div_set_parent,
    491        1.8    bouyer 	    .get_parent = sunxi_ccu_div_get_parent,
    492        1.8    bouyer 	    },
    493        1.8    bouyer 	SUNXI_CCU_DIV_GATE(A10_CLK_HDMI, "hdmi-mod", lcd_parents,
    494        1.7    bouyer 	    HDMI_CLOCK_CFG_REG,		/* reg */
    495        1.7    bouyer 	    __BITS(3,0),		/* div */
    496        1.7    bouyer 	    __BITS(25,24),		/* sel */
    497        1.7    bouyer 	    __BIT(31),			/* enable */
    498        1.7    bouyer 	    0				/* flags */
    499        1.7    bouyer 	    ),
    500  1.16.16.1    bouyer 	SUNXI_CCU_DIV_GATE(A10_CLK_GPU, "gpu", gpu_parents,
    501  1.16.16.1    bouyer 	    MALI_CFG_REG,		/* reg */
    502  1.16.16.1    bouyer 	    __BITS(3,0),		/* div */
    503  1.16.16.1    bouyer 	    __BITS(25,24),		/* sel */
    504  1.16.16.1    bouyer 	    __BIT(31),			/* enable */
    505  1.16.16.1    bouyer 	    0				/* flags */
    506  1.16.16.1    bouyer 	    ),
    507        1.7    bouyer 
    508       1.12  jmcneill 	/* A20 specific */
    509       1.12  jmcneill 	SUNXI_CCU_NM(A20_CLK_OUT_A, "outa", out_parents,
    510       1.12  jmcneill 	    CLK_OUTA_REG,		/* reg */
    511       1.12  jmcneill 	    __BITS(21,20),		/* n */
    512       1.12  jmcneill 	    __BITS(12,8),		/* m */
    513       1.12  jmcneill 	    __BITS(25,24),		/* sel */
    514       1.12  jmcneill 	    __BIT(31),			/* enable */
    515       1.12  jmcneill 	    SUNXI_CCU_NM_POWER_OF_TWO),
    516       1.12  jmcneill 
    517       1.12  jmcneill 	SUNXI_CCU_NM(A20_CLK_OUT_B, "outb", out_parents,
    518       1.12  jmcneill 	    CLK_OUTB_REG,		/* reg */
    519       1.12  jmcneill 	    __BITS(21,20),		/* n */
    520       1.12  jmcneill 	    __BITS(12,8),		/* m */
    521       1.12  jmcneill 	    __BITS(25,24),		/* sel */
    522       1.12  jmcneill 	    __BIT(31),			/* enable */
    523       1.12  jmcneill 	    SUNXI_CCU_NM_POWER_OF_TWO),
    524       1.12  jmcneill 
    525        1.1  jmcneill 	/* AHB_GATING_REG0 */
    526        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_OTG, "ahb-otg", "ahb",
    527        1.1  jmcneill 	    AHB_GATING_REG0, 0),
    528        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_EHCI0, "ahb-ehci0", "ahb",
    529        1.1  jmcneill 	    AHB_GATING_REG0, 1),
    530        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_OHCI0, "ahb-ohci0", "ahb",
    531        1.1  jmcneill 	    AHB_GATING_REG0, 2),
    532        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_EHCI1, "ahb-ehci1", "ahb",
    533        1.1  jmcneill 	    AHB_GATING_REG0, 3),
    534        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_OHCI1, "ahb-ohci1", "ahb",
    535        1.1  jmcneill 	    AHB_GATING_REG0, 4),
    536        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_SS, "ahb-ss", "ahb",
    537        1.1  jmcneill 	    AHB_GATING_REG0, 5),
    538        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_DMA, "ahb-dma", "ahb",
    539        1.1  jmcneill 	    AHB_GATING_REG0, 6),
    540        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_BIST, "ahb-bist", "ahb",
    541        1.1  jmcneill 	    AHB_GATING_REG0, 7),
    542        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_MMC0, "ahb-mmc0", "ahb",
    543        1.1  jmcneill 	    AHB_GATING_REG0, 8),
    544        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_MMC1, "ahb-mmc1", "ahb",
    545        1.1  jmcneill 	    AHB_GATING_REG0, 9),
    546        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_MMC2, "ahb-mmc2", "ahb",
    547        1.1  jmcneill 	    AHB_GATING_REG0, 10),
    548        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_MMC3, "ahb-mmc3", "ahb",
    549        1.1  jmcneill 	    AHB_GATING_REG0, 11),
    550        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_MS, "ahb-ms", "ahb",
    551        1.1  jmcneill 	    AHB_GATING_REG0, 12),
    552        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_NAND, "ahb-nand", "ahb",
    553        1.1  jmcneill 	    AHB_GATING_REG0, 13),
    554        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_SDRAM, "ahb-sdram", "ahb",
    555        1.1  jmcneill 	    AHB_GATING_REG0, 14),
    556        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_ACE, "ahb-ace", "ahb",
    557        1.1  jmcneill 	    AHB_GATING_REG0, 16),
    558        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_EMAC, "ahb-emac", "ahb",
    559        1.1  jmcneill 	    AHB_GATING_REG0, 17),
    560        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_TS, "ahb-ts", "ahb",
    561        1.1  jmcneill 	    AHB_GATING_REG0, 18),
    562        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_SPI0, "ahb-spi0", "ahb",
    563        1.1  jmcneill 	    AHB_GATING_REG0, 20),
    564        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_SPI1, "ahb-spi1", "ahb",
    565        1.1  jmcneill 	    AHB_GATING_REG0, 21),
    566        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_SPI2, "ahb-spi2", "ahb",
    567        1.1  jmcneill 	    AHB_GATING_REG0, 22),
    568        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_SPI3, "ahb-spi3", "ahb",
    569        1.1  jmcneill 	    AHB_GATING_REG0, 23),
    570        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_SATA, "ahb-sata", "ahb",
    571        1.1  jmcneill 	    AHB_GATING_REG0, 25),
    572        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_HSTIMER, "ahb-hstimer", "ahb",
    573        1.1  jmcneill 	    AHB_GATING_REG0, 28),
    574        1.1  jmcneill 
    575        1.1  jmcneill 	/* AHB_GATING_REG1. Missing: TVE, HDMI */
    576        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_VE, "ahb-ve", "ahb",
    577        1.1  jmcneill 	    AHB_GATING_REG1, 0),
    578        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_TVD, "ahb-tvd", "ahb",
    579        1.1  jmcneill 	    AHB_GATING_REG1, 1),
    580        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_TVE0, "ahb-tve0", "ahb",
    581        1.1  jmcneill 	    AHB_GATING_REG1, 2),
    582        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_TVE1, "ahb-tve1", "ahb",
    583        1.1  jmcneill 	    AHB_GATING_REG1, 3),
    584        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_LCD0, "ahb-lcd0", "ahb",
    585        1.1  jmcneill 	    AHB_GATING_REG1, 4),
    586        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_LCD1, "ahb-lcd1", "ahb",
    587        1.1  jmcneill 	    AHB_GATING_REG1, 5),
    588        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_CSI0, "ahb-csi0", "ahb",
    589        1.1  jmcneill 	    AHB_GATING_REG1, 8),
    590        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_CSI1, "ahb-csi1", "ahb",
    591        1.1  jmcneill 	    AHB_GATING_REG1, 9),
    592        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_HDMI1, "ahb-hdmi1", "ahb",
    593        1.1  jmcneill 	    AHB_GATING_REG1, 10),
    594        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_HDMI0, "ahb-hdmi0", "ahb",
    595        1.1  jmcneill 	    AHB_GATING_REG1, 11),
    596        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_DE_BE0, "ahb-de_be0", "ahb",
    597        1.1  jmcneill 	    AHB_GATING_REG1, 12),
    598        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_DE_BE1, "ahb-de_be1", "ahb",
    599        1.1  jmcneill 	    AHB_GATING_REG1, 13),
    600        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_DE_FE0, "ahb-de_fe0", "ahb",
    601        1.1  jmcneill 	    AHB_GATING_REG1, 14),
    602        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_DE_FE1, "ahb-de_fe1", "ahb",
    603        1.1  jmcneill 	    AHB_GATING_REG1, 15),
    604        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_GMAC, "ahb-gmac", "ahb",
    605        1.1  jmcneill 	    AHB_GATING_REG1, 17),
    606        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_MP, "ahb-mp", "ahb",
    607        1.1  jmcneill 	    AHB_GATING_REG1, 18),
    608        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_AHB_GPU, "ahb-gpu", "ahb",
    609        1.1  jmcneill 	    AHB_GATING_REG1, 20),
    610        1.1  jmcneill 
    611        1.1  jmcneill 	/* APB0_GATING_REG */
    612        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_APB0_CODEC, "apb0-codec", "apb0",
    613        1.1  jmcneill 	    APB0_GATING_REG, 0),
    614        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_APB0_SPDIF, "apb0-spdif", "apb0",
    615        1.1  jmcneill 	    APB0_GATING_REG, 1),
    616        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_APB0_AC97, "apb0-ac97", "apb0",
    617        1.1  jmcneill 	    APB0_GATING_REG, 2),
    618        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_APB0_I2S0, "apb0-i2s0", "apb0",
    619        1.1  jmcneill 	    APB0_GATING_REG, 3),
    620        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_APB0_I2S1, "apb0-i2s1", "apb0",
    621        1.1  jmcneill 	    APB0_GATING_REG, 4),
    622        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_APB0_PIO, "apb0-pio", "apb0",
    623        1.1  jmcneill 	    APB0_GATING_REG, 5),
    624        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_APB0_IR0, "apb0-ir0", "apb0",
    625        1.1  jmcneill 	    APB0_GATING_REG, 6),
    626        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_APB0_IR1, "apb0-ir1", "apb0",
    627        1.1  jmcneill 	    APB0_GATING_REG, 7),
    628        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_APB0_I2S2, "apb0-i2s2", "apb0",
    629        1.1  jmcneill 	    APB0_GATING_REG, 8),
    630        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_APB0_KEYPAD, "apb0-keypad", "apb0",
    631        1.1  jmcneill 	    APB0_GATING_REG, 10),
    632        1.1  jmcneill 
    633        1.1  jmcneill 	/* APB1_GATING_REG */
    634        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_APB1_I2C0, "apb1-i2c0", "apb1",
    635        1.1  jmcneill 	    APB1_GATING_REG, 0),
    636        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_APB1_I2C1, "apb1-i2c1", "apb1",
    637        1.1  jmcneill 	    APB1_GATING_REG, 1),
    638        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_APB1_I2C2, "apb1-i2c2", "apb1",
    639        1.1  jmcneill 	    APB1_GATING_REG, 2),
    640        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_APB1_I2C3, "apb1-i2c3", "apb1",
    641        1.1  jmcneill 	    APB1_GATING_REG, 3),
    642        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_APB1_CAN, "apb1-can", "apb1",
    643        1.1  jmcneill 	    APB1_GATING_REG, 4),
    644        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_APB1_SCR, "apb1-scr", "apb1",
    645        1.1  jmcneill 	    APB1_GATING_REG, 5),
    646        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_APB1_PS20, "apb1-ps20", "apb1",
    647        1.1  jmcneill 	    APB1_GATING_REG, 6),
    648        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_APB1_PS21, "apb1-ps21", "apb1",
    649        1.1  jmcneill 	    APB1_GATING_REG, 7),
    650        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_APB1_I2C4, "apb1-i2c4", "apb1",
    651        1.1  jmcneill 	    APB1_GATING_REG, 15),
    652        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_APB1_UART0, "apb1-uart0", "apb1",
    653        1.1  jmcneill 	    APB1_GATING_REG, 16),
    654        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_APB1_UART1, "apb1-uart1", "apb1",
    655        1.1  jmcneill 	    APB1_GATING_REG, 17),
    656        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_APB1_UART2, "apb1-uart2", "apb1",
    657        1.1  jmcneill 	    APB1_GATING_REG, 18),
    658        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_APB1_UART3, "apb1-uart3", "apb1",
    659        1.1  jmcneill 	    APB1_GATING_REG, 19),
    660        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_APB1_UART4, "apb1-uart4", "apb1",
    661        1.1  jmcneill 	    APB1_GATING_REG, 20),
    662        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_APB1_UART5, "apb1-uart5", "apb1",
    663        1.1  jmcneill 	    APB1_GATING_REG, 21),
    664        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_APB1_UART6, "apb1-uart6", "apb1",
    665        1.1  jmcneill 	    APB1_GATING_REG, 22),
    666        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_APB1_UART7, "apb1-uart7", "apb1",
    667        1.1  jmcneill 	    APB1_GATING_REG, 23),
    668        1.1  jmcneill 
    669        1.7    bouyer 	/* DRAM GATING */
    670        1.7    bouyer 	SUNXI_CCU_GATE(A10_CLK_DRAM_DE_BE0, "dram-de-be0", "pll_ddr_other",
    671        1.7    bouyer 	    DRAM_GATING_REG, 26),
    672        1.7    bouyer 	SUNXI_CCU_GATE(A10_CLK_DRAM_DE_BE1, "dram-de-be1", "pll_ddr_other",
    673        1.7    bouyer 	    DRAM_GATING_REG, 27),
    674        1.7    bouyer 	SUNXI_CCU_GATE(A10_CLK_DRAM_DE_FE0, "dram-de-fe0", "pll_ddr_other",
    675        1.7    bouyer 	    DRAM_GATING_REG, 25),
    676        1.7    bouyer 	SUNXI_CCU_GATE(A10_CLK_DRAM_DE_FE1, "dram-de-fe1", "pll_ddr_other",
    677        1.7    bouyer 	    DRAM_GATING_REG, 24),
    678        1.7    bouyer 
    679        1.1  jmcneill 	/* AUDIO_CODEC_SCLK_CFG_REG */
    680        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_CODEC, "codec", "pll_audio",
    681        1.1  jmcneill 	    AUDIO_CODEC_SCLK_CFG_REG, 31),
    682        1.1  jmcneill 
    683        1.1  jmcneill 	/* USBPHY_CFG_REG */
    684        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_USB_OHCI0, "usb-ohci0", "osc24m",
    685        1.1  jmcneill 	    USBPHY_CFG_REG, 6),
    686        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_USB_OHCI1, "usb-ohci1", "osc24m",
    687        1.1  jmcneill 	    USBPHY_CFG_REG, 7),
    688        1.1  jmcneill 	SUNXI_CCU_GATE(A10_CLK_USB_PHY, "usb-phy", "osc24m",
    689        1.1  jmcneill 	    USBPHY_CFG_REG, 8),
    690        1.1  jmcneill };
    691        1.1  jmcneill 
    692        1.8    bouyer /*
    693        1.8    bouyer  * some special cases
    694        1.8    bouyer  * hardcode lcd0 (tcon0) to pll3 and lcd1 (tcon1) to pll7.
    695        1.8    bouyer  * compute pll rate based on desired pixel clock
    696        1.8    bouyer  */
    697        1.8    bouyer 
    698        1.8    bouyer static int
    699        1.8    bouyer sun4i_a10_ccu_lcd0ch0_set_rate(struct sunxi_ccu_softc *sc,
    700        1.8    bouyer     struct sunxi_ccu_clk * clk, u_int rate)
    701        1.8    bouyer {
    702        1.8    bouyer 	int error;
    703        1.8    bouyer 	error = sunxi_ccu_lcdxch0_set_rate(sc, clk,
    704        1.8    bouyer 	    &sun4i_a10_ccu_clks[A10_CLK_PLL_VIDEO0],
    705        1.8    bouyer 	    &sun4i_a10_ccu_clks[A10_CLK_PLL_VIDEO0_2X],
    706        1.8    bouyer 	    rate);
    707        1.8    bouyer 	return error;
    708        1.8    bouyer }
    709        1.8    bouyer 
    710        1.8    bouyer static int
    711        1.8    bouyer sun4i_a10_ccu_lcd1ch0_set_rate(struct sunxi_ccu_softc *sc,
    712        1.8    bouyer     struct sunxi_ccu_clk * clk, u_int rate)
    713        1.8    bouyer {
    714        1.8    bouyer 	return sunxi_ccu_lcdxch0_set_rate(sc, clk,
    715        1.8    bouyer 	    &sun4i_a10_ccu_clks[A10_CLK_PLL_VIDEO1],
    716        1.8    bouyer 	    &sun4i_a10_ccu_clks[A10_CLK_PLL_VIDEO1_2X],
    717        1.8    bouyer 	    rate);
    718        1.8    bouyer }
    719        1.8    bouyer 
    720        1.8    bouyer static u_int
    721        1.8    bouyer sun4i_a10_ccu_lcd0ch0_round_rate(struct sunxi_ccu_softc *sc,
    722        1.8    bouyer     struct sunxi_ccu_clk * clk, u_int rate)
    723        1.8    bouyer {
    724        1.8    bouyer 	return sunxi_ccu_lcdxch0_round_rate(sc, clk,
    725        1.8    bouyer 	    &sun4i_a10_ccu_clks[A10_CLK_PLL_VIDEO0],
    726        1.8    bouyer 	    &sun4i_a10_ccu_clks[A10_CLK_PLL_VIDEO0_2X],
    727        1.8    bouyer 	    rate);
    728        1.8    bouyer }
    729        1.8    bouyer 
    730        1.8    bouyer static u_int
    731        1.8    bouyer sun4i_a10_ccu_lcd1ch0_round_rate(struct sunxi_ccu_softc *sc,
    732        1.8    bouyer     struct sunxi_ccu_clk * clk, u_int rate)
    733        1.8    bouyer {
    734        1.8    bouyer 	return sunxi_ccu_lcdxch0_round_rate(sc, clk,
    735        1.8    bouyer 	    &sun4i_a10_ccu_clks[A10_CLK_PLL_VIDEO1],
    736        1.8    bouyer 	    &sun4i_a10_ccu_clks[A10_CLK_PLL_VIDEO1_2X],
    737        1.8    bouyer 	    rate);
    738        1.8    bouyer }
    739        1.8    bouyer 
    740        1.8    bouyer static int
    741        1.8    bouyer sun4i_a10_ccu_lcd0ch1_set_rate(struct sunxi_ccu_softc *sc,
    742        1.8    bouyer     struct sunxi_ccu_clk * clk, u_int rate)
    743        1.8    bouyer {
    744        1.8    bouyer 	return sunxi_ccu_lcdxch1_set_rate(sc, clk,
    745        1.8    bouyer 	    &sun4i_a10_ccu_clks[A10_CLK_PLL_VIDEO0],
    746        1.8    bouyer 	    &sun4i_a10_ccu_clks[A10_CLK_PLL_VIDEO0_2X],
    747        1.8    bouyer 	    rate);
    748        1.8    bouyer }
    749        1.8    bouyer 
    750        1.8    bouyer static int
    751        1.8    bouyer sun4i_a10_ccu_lcd1ch1_set_rate(struct sunxi_ccu_softc *sc,
    752        1.8    bouyer     struct sunxi_ccu_clk * clk, u_int rate)
    753        1.8    bouyer {
    754        1.8    bouyer 	return sunxi_ccu_lcdxch1_set_rate(sc, clk,
    755        1.8    bouyer 	    &sun4i_a10_ccu_clks[A10_CLK_PLL_VIDEO1],
    756        1.8    bouyer 	    &sun4i_a10_ccu_clks[A10_CLK_PLL_VIDEO1_2X],
    757        1.8    bouyer 	    rate);
    758        1.8    bouyer }
    759        1.8    bouyer 
    760        1.8    bouyer #if 0
    761        1.8    bouyer static int
    762        1.8    bouyer sun4i_a10_ccu_lcdxch0_set_rate(struct sunxi_ccu_softc *sc,
    763        1.8    bouyer     struct sunxi_ccu_clk * clk, u_int rate, int unit)
    764        1.8    bouyer {
    765        1.8    bouyer 	int parent_index;
    766        1.8    bouyer 	struct clk *clkp;
    767        1.8    bouyer 	int error;
    768        1.8    bouyer 
    769        1.8    bouyer 	parent_index = (unit == 0) ? A10_CLK_PLL_VIDEO0 : A10_CLK_PLL_VIDEO1;
    770        1.8    bouyer 	clkp = &sun4i_a10_ccu_clks[parent_index].base;
    771        1.8    bouyer 	error = clk_set_rate(clkp, rate);
    772        1.8    bouyer 	if (error) {
    773        1.8    bouyer 		error = clk_set_rate(clkp, rate / 2);
    774        1.8    bouyer 		if (error != 0)
    775        1.8    bouyer 			return error;
    776        1.8    bouyer 		parent_index =
    777        1.8    bouyer 		    (unit == 0) ? A10_CLK_PLL_VIDEO0_2X : A10_CLK_PLL_VIDEO1_2X;
    778        1.8    bouyer 		clkp = &sun4i_a10_ccu_clks[parent_index].base;
    779        1.8    bouyer 	}
    780        1.8    bouyer 	error = clk_set_parent(&clk->base, clkp);
    781        1.8    bouyer 	KASSERT(error == 0);
    782        1.8    bouyer 	return error;
    783        1.8    bouyer }
    784        1.8    bouyer 
    785        1.8    bouyer static u_int
    786        1.8    bouyer sun4i_a10_ccu_lcdxch0_round_rate(struct sunxi_ccu_softc *sc,
    787        1.8    bouyer     struct sunxi_ccu_clk * clk, u_int try_rate, int unit)
    788        1.8    bouyer {
    789        1.8    bouyer 	int parent_index;
    790        1.8    bouyer 	struct clk *clkp;
    791        1.8    bouyer 	int diff, diff_x2;
    792        1.8    bouyer 	int rate, rate_x2;
    793        1.8    bouyer 
    794        1.8    bouyer 	parent_index = (unit == 0) ? A10_CLK_PLL_VIDEO0 : A10_CLK_PLL_VIDEO1;
    795        1.8    bouyer 	clkp = &sun4i_a10_ccu_clks[parent_index].base;
    796        1.8    bouyer 	rate = clk_round_rate(clkp, try_rate);
    797        1.8    bouyer 	diff = abs(try_rate - rate);
    798        1.8    bouyer 
    799        1.8    bouyer 	rate_x2 = (clk_round_rate(clkp, try_rate / 2) * 2);
    800        1.8    bouyer 	diff_x2 = abs(try_rate - rate_x2);
    801        1.8    bouyer 
    802        1.8    bouyer 	if (diff_x2 < diff)
    803        1.8    bouyer 		return rate_x2;
    804        1.8    bouyer 	return rate;
    805        1.8    bouyer }
    806        1.8    bouyer 
    807        1.8    bouyer static void
    808        1.8    bouyer sun4i_a10_tcon_calc_pll(int f_ref, int f_out, int *pm, int *pn, int *pd)
    809        1.8    bouyer {
    810        1.8    bouyer 	int best = INT_MAX;
    811        1.8    bouyer 	for (int d = 1; d <= 2 && best != 0; d++) {
    812        1.8    bouyer 		for (int m = 1; m <= 16 && best != 0; m++) {
    813        1.8    bouyer 			for (int n = 9; n <= 127 && best != 0; n++) {
    814        1.8    bouyer 				int f_cur = (n * f_ref * d) / m;
    815        1.8    bouyer 				int diff = abs(f_out - f_cur);
    816        1.8    bouyer 				if (diff < best) {
    817        1.8    bouyer 					best = diff;
    818        1.8    bouyer 					*pm = m;
    819        1.8    bouyer 					*pn = n;
    820        1.8    bouyer 					*pd = d;
    821        1.8    bouyer 					if (diff == 0)
    822        1.8    bouyer 						return;
    823        1.8    bouyer 				}
    824        1.8    bouyer 			}
    825        1.8    bouyer 		}
    826        1.8    bouyer 	}
    827        1.8    bouyer }
    828        1.8    bouyer 
    829        1.8    bouyer static int
    830        1.8    bouyer sun4i_a10_ccu_lcdxch1_set_rate(struct sunxi_ccu_softc *sc,
    831        1.8    bouyer     struct sunxi_ccu_clk *clk, u_int rate, int unit)
    832        1.8    bouyer {
    833        1.8    bouyer 	int parent_index;
    834        1.8    bouyer 	struct clk *clkp, *pllclk;
    835        1.8    bouyer 	int error;
    836        1.8    bouyer         int n = 0, m = 0, d = 0;
    837        1.8    bouyer 
    838        1.8    bouyer 	parent_index = (unit == 0) ? A10_CLK_PLL_VIDEO0 : A10_CLK_PLL_VIDEO1;
    839        1.8    bouyer 	clkp = &sun4i_a10_ccu_clks[parent_index].base;
    840        1.8    bouyer 	pllclk = clkp;
    841        1.8    bouyer 
    842        1.8    bouyer         sun4i_a10_tcon_calc_pll(3000000, rate, &m, &n, &d);
    843        1.8    bouyer 
    844        1.8    bouyer         if (n == 0 || m == 0 || d == 0)
    845        1.8    bouyer 		return ERANGE;
    846        1.8    bouyer 
    847        1.8    bouyer         if (d == 2) {
    848        1.8    bouyer 		parent_index =
    849        1.8    bouyer 		    (unit == 0) ? A10_CLK_PLL_VIDEO0_2X : A10_CLK_PLL_VIDEO1_2X;
    850        1.8    bouyer 		clkp = &sun4i_a10_ccu_clks[parent_index].base;
    851        1.8    bouyer         }
    852        1.8    bouyer 
    853        1.8    bouyer 	error = clk_set_rate(pllclk, 3000000 * n);
    854        1.8    bouyer 	KASSERT(error == 0);
    855        1.8    bouyer 	error = clk_set_parent(&clk->base, clkp);
    856        1.8    bouyer 	KASSERT(error == 0);
    857        1.8    bouyer 	error = sunxi_ccu_div_set_rate(sc, clk, rate);
    858        1.8    bouyer 	KASSERT(error == 0);
    859        1.8    bouyer 	return error;
    860        1.8    bouyer }
    861        1.8    bouyer #endif
    862        1.8    bouyer 
    863        1.1  jmcneill static int
    864        1.1  jmcneill sun4i_a10_ccu_match(device_t parent, cfdata_t cf, void *aux)
    865        1.1  jmcneill {
    866        1.1  jmcneill 	struct fdt_attach_args * const faa = aux;
    867        1.1  jmcneill 
    868       1.16   thorpej 	return of_compatible_match(faa->faa_phandle, compat_data);
    869        1.1  jmcneill }
    870        1.1  jmcneill 
    871        1.8    bouyer static struct sunxi_ccu_softc *sc0;
    872        1.1  jmcneill static void
    873        1.1  jmcneill sun4i_a10_ccu_attach(device_t parent, device_t self, void *aux)
    874        1.1  jmcneill {
    875        1.1  jmcneill 	struct sunxi_ccu_softc * const sc = device_private(self);
    876        1.1  jmcneill 	struct fdt_attach_args * const faa = aux;
    877        1.1  jmcneill 	enum sun4i_a10_ccu_type type;
    878        1.8    bouyer 	struct clk *clk, *clkp;
    879        1.8    bouyer 	int error;
    880        1.1  jmcneill 
    881        1.1  jmcneill 	sc->sc_dev = self;
    882        1.1  jmcneill 	sc->sc_phandle = faa->faa_phandle;
    883        1.1  jmcneill 	sc->sc_bst = faa->faa_bst;
    884        1.1  jmcneill 
    885        1.1  jmcneill 	sc->sc_resets = sun4i_a10_ccu_resets;
    886        1.1  jmcneill 	sc->sc_nresets = __arraycount(sun4i_a10_ccu_resets);
    887        1.1  jmcneill 
    888        1.1  jmcneill 	sc->sc_clks = sun4i_a10_ccu_clks;
    889        1.1  jmcneill 	sc->sc_nclks = __arraycount(sun4i_a10_ccu_clks);
    890        1.1  jmcneill 
    891        1.1  jmcneill 	if (sunxi_ccu_attach(sc) != 0)
    892        1.1  jmcneill 		return;
    893        1.1  jmcneill 
    894        1.1  jmcneill 	aprint_naive("\n");
    895        1.1  jmcneill 
    896       1.16   thorpej 	type = of_compatible_lookup(faa->faa_phandle, compat_data)->value;
    897        1.1  jmcneill 
    898        1.1  jmcneill 	switch (type) {
    899        1.1  jmcneill 	case CCU_A10:
    900        1.1  jmcneill 		aprint_normal(": A10 CCU\n");
    901        1.1  jmcneill 		break;
    902        1.1  jmcneill 	case CCU_A20:
    903        1.1  jmcneill 		aprint_normal(": A20 CCU\n");
    904        1.1  jmcneill 		break;
    905        1.1  jmcneill 	}
    906        1.8    bouyer 	/* hardcode debe clocks parent to PLL5 */
    907        1.8    bouyer 	clkp = &sun4i_a10_ccu_clks[A10_CLK_PLL_DDR_BASE].base;
    908        1.8    bouyer 	clk =  &sun4i_a10_ccu_clks[A10_CLK_DE_BE0].base;
    909        1.8    bouyer 	error = clk_set_parent(clk, clkp);
    910        1.8    bouyer 	KASSERT(error == 0);
    911        1.8    bouyer 	clk =  &sun4i_a10_ccu_clks[A10_CLK_DE_BE1].base;
    912        1.8    bouyer 	error = clk_set_parent(clk, clkp);
    913        1.8    bouyer 	KASSERT(error == 0);
    914        1.1  jmcneill 
    915        1.8    bouyer 	(void)error;
    916        1.1  jmcneill 	sunxi_ccu_print(sc);
    917        1.8    bouyer 	sc0 = sc;
    918        1.8    bouyer }
    919        1.8    bouyer 
    920        1.8    bouyer void sun4i_ccu_print(void);
    921        1.8    bouyer void
    922        1.8    bouyer sun4i_ccu_print(void)
    923        1.8    bouyer {
    924        1.8    bouyer 	sunxi_ccu_print(sc0);
    925        1.1  jmcneill }
    926