Home | History | Annotate | Line # | Download | only in sunxi
sun6i_a31_ccu.c revision 1.2
      1  1.2  jmcneill /* $NetBSD: sun6i_a31_ccu.c,v 1.2 2017/07/02 13:36:46 jmcneill 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  * Copyright (c) 2017 Emmanuel Vadot <manu (at) freebsd.org>
      6  1.1  jmcneill  * All rights reserved.
      7  1.1  jmcneill  *
      8  1.1  jmcneill  * Redistribution and use in source and binary forms, with or without
      9  1.1  jmcneill  * modification, are permitted provided that the following conditions
     10  1.1  jmcneill  * are met:
     11  1.1  jmcneill  * 1. Redistributions of source code must retain the above copyright
     12  1.1  jmcneill  *    notice, this list of conditions and the following disclaimer.
     13  1.1  jmcneill  * 2. Redistributions in binary form must reproduce the above copyright
     14  1.1  jmcneill  *    notice, this list of conditions and the following disclaimer in the
     15  1.1  jmcneill  *    documentation and/or other materials provided with the distribution.
     16  1.1  jmcneill  *
     17  1.1  jmcneill  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18  1.1  jmcneill  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19  1.1  jmcneill  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20  1.1  jmcneill  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21  1.1  jmcneill  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     22  1.1  jmcneill  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     23  1.1  jmcneill  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     24  1.1  jmcneill  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     25  1.1  jmcneill  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     26  1.1  jmcneill  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     27  1.1  jmcneill  * SUCH DAMAGE.
     28  1.1  jmcneill  */
     29  1.1  jmcneill 
     30  1.1  jmcneill #include <sys/cdefs.h>
     31  1.1  jmcneill 
     32  1.2  jmcneill __KERNEL_RCSID(1, "$NetBSD: sun6i_a31_ccu.c,v 1.2 2017/07/02 13:36:46 jmcneill Exp $");
     33  1.1  jmcneill 
     34  1.1  jmcneill #include <sys/param.h>
     35  1.1  jmcneill #include <sys/bus.h>
     36  1.1  jmcneill #include <sys/device.h>
     37  1.1  jmcneill #include <sys/systm.h>
     38  1.1  jmcneill 
     39  1.1  jmcneill #include <dev/fdt/fdtvar.h>
     40  1.1  jmcneill 
     41  1.1  jmcneill #include <arm/sunxi/sunxi_ccu.h>
     42  1.1  jmcneill #include <arm/sunxi/sun6i_a31_ccu.h>
     43  1.1  jmcneill 
     44  1.1  jmcneill #define	PLL_PERIPH_CTRL_REG	0x028
     45  1.1  jmcneill #define	AHB1_APB1_CFG_REG	0x054
     46  1.1  jmcneill #define	APB2_CLK_DIV_REG	0x058
     47  1.1  jmcneill #define	AHB1_GATING_REG0	0x060
     48  1.1  jmcneill #define	AHB1_GATING_REG1	0x064
     49  1.1  jmcneill #define	APB1_GATING_REG		0x068
     50  1.1  jmcneill #define	APB2_GATING_REG		0x06c
     51  1.1  jmcneill #define	SD0_CLK_REG		0x088
     52  1.1  jmcneill #define	SD1_CLK_REG		0x08c
     53  1.1  jmcneill #define	SD2_CLK_REG		0x090
     54  1.1  jmcneill #define	SD3_CLK_REG		0x094
     55  1.1  jmcneill #define	USBPHY_CFG_REG		0x0cc
     56  1.1  jmcneill #define	BUS_SOFT_RST_REG0	0x2c0
     57  1.1  jmcneill #define	BUS_SOFT_RST_REG1	0x2c4
     58  1.1  jmcneill #define	BUS_SOFT_RST_REG2	0x2c8
     59  1.1  jmcneill #define	BUS_SOFT_RST_REG3	0x2d0
     60  1.1  jmcneill #define	BUS_SOFT_RST_REG4	0x2d8
     61  1.1  jmcneill 
     62  1.1  jmcneill static int sun6i_a31_ccu_match(device_t, cfdata_t, void *);
     63  1.1  jmcneill static void sun6i_a31_ccu_attach(device_t, device_t, void *);
     64  1.1  jmcneill 
     65  1.1  jmcneill static const char * const compatible[] = {
     66  1.1  jmcneill 	"allwinner,sun6i-a31-ccu",
     67  1.1  jmcneill 	NULL
     68  1.1  jmcneill };
     69  1.1  jmcneill 
     70  1.1  jmcneill CFATTACH_DECL_NEW(sunxi_a31_ccu, sizeof(struct sunxi_ccu_softc),
     71  1.1  jmcneill 	sun6i_a31_ccu_match, sun6i_a31_ccu_attach, NULL, NULL);
     72  1.1  jmcneill 
     73  1.1  jmcneill static struct sunxi_ccu_reset sun6i_a31_ccu_resets[] = {
     74  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_USB_PHY0, USBPHY_CFG_REG, 0),
     75  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_USB_PHY1, USBPHY_CFG_REG, 1),
     76  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_USB_PHY2, USBPHY_CFG_REG, 2),
     77  1.1  jmcneill 
     78  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_MIPI_DSI, BUS_SOFT_RST_REG0, 1),
     79  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_SS, BUS_SOFT_RST_REG0, 5),
     80  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_DMA, BUS_SOFT_RST_REG0, 6),
     81  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_MMC0, BUS_SOFT_RST_REG0, 8),
     82  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_MMC1, BUS_SOFT_RST_REG0, 9),
     83  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_MMC2, BUS_SOFT_RST_REG0, 10),
     84  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_MMC3, BUS_SOFT_RST_REG0, 11),
     85  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_NAND1, BUS_SOFT_RST_REG0, 12),
     86  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_NAND0, BUS_SOFT_RST_REG0, 13),
     87  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_SDRAM, BUS_SOFT_RST_REG0, 14),
     88  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_EMAC, BUS_SOFT_RST_REG0, 17),
     89  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_TS, BUS_SOFT_RST_REG0, 18),
     90  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_HSTIMER, BUS_SOFT_RST_REG0, 19),
     91  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_SPI0, BUS_SOFT_RST_REG0, 20),
     92  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_SPI1, BUS_SOFT_RST_REG0, 21),
     93  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_SPI2, BUS_SOFT_RST_REG0, 22),
     94  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_SPI3, BUS_SOFT_RST_REG0, 23),
     95  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_OTG, BUS_SOFT_RST_REG0, 24),
     96  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_EHCI0, BUS_SOFT_RST_REG0, 26),
     97  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_EHCI1, BUS_SOFT_RST_REG0, 27),
     98  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_OHCI0, BUS_SOFT_RST_REG0, 29),
     99  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_OHCI1, BUS_SOFT_RST_REG0, 30),
    100  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_OHCI2, BUS_SOFT_RST_REG0, 31),
    101  1.1  jmcneill 
    102  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_VE, BUS_SOFT_RST_REG1, 0),
    103  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_LCD0, BUS_SOFT_RST_REG1, 4),
    104  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_LCD1, BUS_SOFT_RST_REG1, 5),
    105  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_CSI, BUS_SOFT_RST_REG1, 8),
    106  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_HDMI, BUS_SOFT_RST_REG1, 11),
    107  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_BE0, BUS_SOFT_RST_REG1, 12),
    108  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_BE1, BUS_SOFT_RST_REG1, 13),
    109  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_FE0, BUS_SOFT_RST_REG1, 14),
    110  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_FE1, BUS_SOFT_RST_REG1, 15),
    111  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_MP, BUS_SOFT_RST_REG1, 16),
    112  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_GPU, BUS_SOFT_RST_REG1, 20),
    113  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_DEU0, BUS_SOFT_RST_REG1, 23),
    114  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_DEU1, BUS_SOFT_RST_REG1, 24),
    115  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_DRC0, BUS_SOFT_RST_REG1, 25),
    116  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_DRC1, BUS_SOFT_RST_REG1, 26),
    117  1.1  jmcneill 
    118  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_AHB1_LVDS, BUS_SOFT_RST_REG2, 0),
    119  1.1  jmcneill 
    120  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_APB1_CODEC, BUS_SOFT_RST_REG3, 0),
    121  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_APB1_SPDIF, BUS_SOFT_RST_REG3, 1),
    122  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_APB1_DIGITAL_MIC, BUS_SOFT_RST_REG3, 4),
    123  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_APB1_DAUDIO0, BUS_SOFT_RST_REG3, 12),
    124  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_APB1_DAUDIO1, BUS_SOFT_RST_REG3, 13),
    125  1.1  jmcneill 
    126  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_APB2_I2C0, BUS_SOFT_RST_REG4, 0),
    127  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_APB2_I2C1, BUS_SOFT_RST_REG4, 1),
    128  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_APB2_I2C2, BUS_SOFT_RST_REG4, 2),
    129  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_APB2_I2C3, BUS_SOFT_RST_REG4, 3),
    130  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_APB2_UART0, BUS_SOFT_RST_REG4, 16),
    131  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_APB2_UART1, BUS_SOFT_RST_REG4, 17),
    132  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_APB2_UART2, BUS_SOFT_RST_REG4, 18),
    133  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_APB2_UART3, BUS_SOFT_RST_REG4, 19),
    134  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_APB2_UART4, BUS_SOFT_RST_REG4, 20),
    135  1.1  jmcneill 	SUNXI_CCU_RESET(A31_RST_APB2_UART5, BUS_SOFT_RST_REG4, 21),
    136  1.1  jmcneill };
    137  1.1  jmcneill 
    138  1.1  jmcneill static const char *ahb1_parents[] = { "losc", "hosc", "axi", "pll_periph" };
    139  1.1  jmcneill static const char *apb1_parents[] = { "ahb1" };
    140  1.1  jmcneill static const char *apb2_parents[] = { "losc", "hosc", "pll_periph", "pll_periph" };
    141  1.1  jmcneill static const char *mod_parents[] = { "hosc", "pll_periph" };
    142  1.1  jmcneill 
    143  1.1  jmcneill static struct sunxi_ccu_clk sun6i_a31_ccu_clks[] = {
    144  1.1  jmcneill 	SUNXI_CCU_NKMP(A31_CLK_PLL_PERIPH, "pll_periph", "hosc",
    145  1.1  jmcneill 	    PLL_PERIPH_CTRL_REG,	/* reg */
    146  1.1  jmcneill 	    __BITS(12,8),		/* n */
    147  1.1  jmcneill 	    __BITS(5,4), 		/* k */
    148  1.1  jmcneill 	    0,				/* m */
    149  1.1  jmcneill 	    0,				/* p */
    150  1.1  jmcneill 	    __BIT(31),			/* enable */
    151  1.1  jmcneill 	    SUNXI_CCU_NKMP_DIVIDE_BY_TWO),
    152  1.1  jmcneill 
    153  1.1  jmcneill 	SUNXI_CCU_DIV(A31_CLK_APB1, "apb1", apb1_parents,
    154  1.1  jmcneill 	    AHB1_APB1_CFG_REG,	/* reg */
    155  1.1  jmcneill 	    __BITS(9,8),	/* div */
    156  1.1  jmcneill 	    0,			/* sel */
    157  1.1  jmcneill 	    SUNXI_CCU_DIV_POWER_OF_TWO|SUNXI_CCU_DIV_ZERO_IS_ONE),
    158  1.1  jmcneill 
    159  1.1  jmcneill 	SUNXI_CCU_PREDIV(A31_CLK_AHB1, "ahb1", ahb1_parents,
    160  1.1  jmcneill 	    AHB1_APB1_CFG_REG,	/* reg */
    161  1.1  jmcneill 	    __BITS(7,6),	/* prediv */
    162  1.1  jmcneill 	    __BIT(3),		/* prediv_sel */
    163  1.1  jmcneill 	    __BITS(5,4),	/* div */
    164  1.1  jmcneill 	    __BITS(13,12),	/* sel */
    165  1.1  jmcneill 	    SUNXI_CCU_PREDIV_POWER_OF_TWO),
    166  1.1  jmcneill 
    167  1.1  jmcneill 	SUNXI_CCU_NM(A31_CLK_APB2, "apb2", apb2_parents,
    168  1.1  jmcneill 	    APB2_CLK_DIV_REG,	/* reg */
    169  1.1  jmcneill 	    __BITS(17,16),	/* n */
    170  1.1  jmcneill 	    __BITS(4,0),	/* m */
    171  1.1  jmcneill 	    __BITS(25,24),	/* sel */
    172  1.1  jmcneill 	    0,			/* enable */
    173  1.1  jmcneill 	    SUNXI_CCU_NM_POWER_OF_TWO),
    174  1.1  jmcneill 
    175  1.1  jmcneill 	SUNXI_CCU_NM(A31_CLK_MMC0, "mmc0", mod_parents,
    176  1.1  jmcneill 	    SD0_CLK_REG, __BITS(17, 16), __BITS(3,0), __BITS(25, 24), __BIT(31),
    177  1.1  jmcneill 	    SUNXI_CCU_NM_POWER_OF_TWO|SUNXI_CCU_NM_ROUND_DOWN),
    178  1.1  jmcneill 	SUNXI_CCU_NM(A31_CLK_MMC1, "mmc1", mod_parents,
    179  1.1  jmcneill 	    SD1_CLK_REG, __BITS(17, 16), __BITS(3,0), __BITS(25, 24), __BIT(31),
    180  1.1  jmcneill 	    SUNXI_CCU_NM_POWER_OF_TWO|SUNXI_CCU_NM_ROUND_DOWN),
    181  1.1  jmcneill 	SUNXI_CCU_NM(A31_CLK_MMC2, "mmc2", mod_parents,
    182  1.1  jmcneill 	    SD2_CLK_REG, __BITS(17, 16), __BITS(3,0), __BITS(25, 24), __BIT(31),
    183  1.1  jmcneill 	    SUNXI_CCU_NM_POWER_OF_TWO|SUNXI_CCU_NM_ROUND_DOWN),
    184  1.1  jmcneill 	SUNXI_CCU_NM(A31_CLK_MMC3, "mmc3", mod_parents,
    185  1.1  jmcneill 	    SD3_CLK_REG, __BITS(17, 16), __BITS(3,0), __BITS(25, 24), __BIT(31),
    186  1.1  jmcneill 	    SUNXI_CCU_NM_POWER_OF_TWO|SUNXI_CCU_NM_ROUND_DOWN),
    187  1.1  jmcneill 
    188  1.1  jmcneill 	SUNXI_CCU_GATE(A31_CLK_AHB1_MMC0, "ahb1-mmc0", "ahb1",
    189  1.1  jmcneill 	    AHB1_GATING_REG0, 8),
    190  1.1  jmcneill 	SUNXI_CCU_GATE(A31_CLK_AHB1_MMC1, "ahb1-mmc1", "ahb1",
    191  1.1  jmcneill 	    AHB1_GATING_REG0, 9),
    192  1.1  jmcneill 	SUNXI_CCU_GATE(A31_CLK_AHB1_MMC2, "ahb1-mmc2", "ahb1",
    193  1.1  jmcneill 	    AHB1_GATING_REG0, 10),
    194  1.1  jmcneill 	SUNXI_CCU_GATE(A31_CLK_AHB1_MMC3, "ahb1-mmc3", "ahb1",
    195  1.1  jmcneill 	    AHB1_GATING_REG0, 11),
    196  1.1  jmcneill 	SUNXI_CCU_GATE(A31_CLK_AHB1_EMAC, "ahb1-emac", "ahb1",
    197  1.1  jmcneill 	    AHB1_GATING_REG0, 17),
    198  1.1  jmcneill 	SUNXI_CCU_GATE(A31_CLK_AHB1_OTG, "ahb1-otg", "ahb1",
    199  1.1  jmcneill 	    AHB1_GATING_REG0, 24),
    200  1.1  jmcneill 	SUNXI_CCU_GATE(A31_CLK_AHB1_EHCI0, "ahb1-ehci0", "ahb1",
    201  1.1  jmcneill 	    AHB1_GATING_REG0, 26),
    202  1.1  jmcneill 	SUNXI_CCU_GATE(A31_CLK_AHB1_EHCI1, "ahb1-ehci1", "ahb1",
    203  1.1  jmcneill 	    AHB1_GATING_REG0, 27),
    204  1.1  jmcneill 	SUNXI_CCU_GATE(A31_CLK_AHB1_OHCI0, "ahb1-ohci0", "ahb1",
    205  1.1  jmcneill 	    AHB1_GATING_REG0, 29),
    206  1.1  jmcneill 	SUNXI_CCU_GATE(A31_CLK_AHB1_OHCI1, "ahb1-ohci1", "ahb1",
    207  1.1  jmcneill 	    AHB1_GATING_REG0, 30),
    208  1.1  jmcneill 	SUNXI_CCU_GATE(A31_CLK_AHB1_OHCI2, "ahb1-ohci2", "ahb1",
    209  1.1  jmcneill 	    AHB1_GATING_REG0, 31),
    210  1.1  jmcneill 
    211  1.2  jmcneill 	SUNXI_CCU_GATE(A31_CLK_APB1_PIO, "ahb1-pio", "apb1",
    212  1.2  jmcneill 	    APB1_GATING_REG, 5),
    213  1.2  jmcneill 
    214  1.1  jmcneill 	SUNXI_CCU_GATE(A31_CLK_APB2_I2C0, "apb2-i2c0", "apb2",
    215  1.1  jmcneill 	    APB2_GATING_REG, 0),
    216  1.1  jmcneill 	SUNXI_CCU_GATE(A31_CLK_APB2_I2C1, "apb2-i2c1", "apb2",
    217  1.1  jmcneill 	    APB2_GATING_REG, 1),
    218  1.1  jmcneill 	SUNXI_CCU_GATE(A31_CLK_APB2_I2C2, "apb2-i2c2", "apb2",
    219  1.1  jmcneill 	    APB2_GATING_REG, 2),
    220  1.1  jmcneill 	SUNXI_CCU_GATE(A31_CLK_APB2_I2C3, "apb2-i2c3", "apb2",
    221  1.1  jmcneill 	    APB2_GATING_REG, 3),
    222  1.1  jmcneill 	SUNXI_CCU_GATE(A31_CLK_APB2_UART0, "apb2-uart0", "apb2",
    223  1.1  jmcneill 	    APB2_GATING_REG, 16),
    224  1.1  jmcneill 	SUNXI_CCU_GATE(A31_CLK_APB2_UART1, "apb2-uart1", "apb2",
    225  1.1  jmcneill 	    APB2_GATING_REG, 17),
    226  1.1  jmcneill 	SUNXI_CCU_GATE(A31_CLK_APB2_UART2, "apb2-uart2", "apb2",
    227  1.1  jmcneill 	    APB2_GATING_REG, 18),
    228  1.1  jmcneill 	SUNXI_CCU_GATE(A31_CLK_APB2_UART3, "apb2-uart3", "apb2",
    229  1.1  jmcneill 	    APB2_GATING_REG, 19),
    230  1.1  jmcneill 	SUNXI_CCU_GATE(A31_CLK_APB2_UART4, "apb2-uart4", "apb2",
    231  1.1  jmcneill 	    APB2_GATING_REG, 20),
    232  1.1  jmcneill 	SUNXI_CCU_GATE(A31_CLK_APB2_UART5, "apb2-uart5", "apb2",
    233  1.1  jmcneill 	    APB2_GATING_REG, 21),
    234  1.1  jmcneill 
    235  1.1  jmcneill 	SUNXI_CCU_GATE(A31_CLK_USB_PHY0, "usb-phy0", "hosc",
    236  1.1  jmcneill 	    USBPHY_CFG_REG, 8),
    237  1.1  jmcneill 	SUNXI_CCU_GATE(A31_CLK_USB_PHY1, "usb-phy1", "hosc",
    238  1.1  jmcneill 	    USBPHY_CFG_REG, 9),
    239  1.1  jmcneill 	SUNXI_CCU_GATE(A31_CLK_USB_PHY2, "usb-phy2", "hosc",
    240  1.1  jmcneill 	    USBPHY_CFG_REG, 10),
    241  1.1  jmcneill 	SUNXI_CCU_GATE(A31_CLK_USB_OHCI0, "usb-ohci0", "hosc",
    242  1.1  jmcneill 	    USBPHY_CFG_REG, 16),
    243  1.1  jmcneill 	SUNXI_CCU_GATE(A31_CLK_USB_OHCI1, "usb-ohci1", "hosc",
    244  1.1  jmcneill 	    USBPHY_CFG_REG, 17),
    245  1.1  jmcneill 	SUNXI_CCU_GATE(A31_CLK_USB_OHCI2, "usb-ohci2", "hosc",
    246  1.1  jmcneill 	    USBPHY_CFG_REG, 18),
    247  1.1  jmcneill };
    248  1.1  jmcneill 
    249  1.1  jmcneill static int
    250  1.1  jmcneill sun6i_a31_ccu_match(device_t parent, cfdata_t cf, void *aux)
    251  1.1  jmcneill {
    252  1.1  jmcneill 	struct fdt_attach_args * const faa = aux;
    253  1.1  jmcneill 
    254  1.1  jmcneill 	return of_match_compatible(faa->faa_phandle, compatible);
    255  1.1  jmcneill }
    256  1.1  jmcneill 
    257  1.1  jmcneill static void
    258  1.1  jmcneill sun6i_a31_ccu_attach(device_t parent, device_t self, void *aux)
    259  1.1  jmcneill {
    260  1.1  jmcneill 	struct sunxi_ccu_softc * const sc = device_private(self);
    261  1.1  jmcneill 	struct fdt_attach_args * const faa = aux;
    262  1.1  jmcneill 
    263  1.1  jmcneill 	sc->sc_dev = self;
    264  1.1  jmcneill 	sc->sc_phandle = faa->faa_phandle;
    265  1.1  jmcneill 	sc->sc_bst = faa->faa_bst;
    266  1.1  jmcneill 
    267  1.1  jmcneill 	sc->sc_resets = sun6i_a31_ccu_resets;
    268  1.1  jmcneill 	sc->sc_nresets = __arraycount(sun6i_a31_ccu_resets);
    269  1.1  jmcneill 
    270  1.1  jmcneill 	sc->sc_clks = sun6i_a31_ccu_clks;
    271  1.1  jmcneill 	sc->sc_nclks = __arraycount(sun6i_a31_ccu_clks);
    272  1.1  jmcneill 
    273  1.1  jmcneill 	if (sunxi_ccu_attach(sc) != 0)
    274  1.1  jmcneill 		return;
    275  1.1  jmcneill 
    276  1.1  jmcneill 	aprint_naive("\n");
    277  1.1  jmcneill 	aprint_normal(": A31 CCU\n");
    278  1.1  jmcneill 
    279  1.1  jmcneill 	sunxi_ccu_print(sc);
    280  1.1  jmcneill }
    281