Home | History | Annotate | Line # | Download | only in rockchip
rk_cru.c revision 1.2.2.5
      1  1.2.2.5  pgoyette /* $NetBSD: rk_cru.c,v 1.2.2.5 2018/09/30 01:45:38 pgoyette Exp $ */
      2  1.2.2.2  pgoyette 
      3  1.2.2.2  pgoyette /*-
      4  1.2.2.2  pgoyette  * Copyright (c) 2018 Jared McNeill <jmcneill (at) invisible.ca>
      5  1.2.2.2  pgoyette  * All rights reserved.
      6  1.2.2.2  pgoyette  *
      7  1.2.2.2  pgoyette  * Redistribution and use in source and binary forms, with or without
      8  1.2.2.2  pgoyette  * modification, are permitted provided that the following conditions
      9  1.2.2.2  pgoyette  * are met:
     10  1.2.2.2  pgoyette  * 1. Redistributions of source code must retain the above copyright
     11  1.2.2.2  pgoyette  *    notice, this list of conditions and the following disclaimer.
     12  1.2.2.2  pgoyette  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.2.2.2  pgoyette  *    notice, this list of conditions and the following disclaimer in the
     14  1.2.2.2  pgoyette  *    documentation and/or other materials provided with the distribution.
     15  1.2.2.2  pgoyette  *
     16  1.2.2.2  pgoyette  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17  1.2.2.2  pgoyette  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18  1.2.2.2  pgoyette  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19  1.2.2.2  pgoyette  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     20  1.2.2.2  pgoyette  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     21  1.2.2.2  pgoyette  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     22  1.2.2.2  pgoyette  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     23  1.2.2.2  pgoyette  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     24  1.2.2.2  pgoyette  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25  1.2.2.2  pgoyette  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26  1.2.2.2  pgoyette  * SUCH DAMAGE.
     27  1.2.2.2  pgoyette  */
     28  1.2.2.2  pgoyette 
     29  1.2.2.2  pgoyette #include "opt_soc.h"
     30  1.2.2.5  pgoyette #include "opt_console.h"
     31  1.2.2.2  pgoyette 
     32  1.2.2.2  pgoyette #include <sys/cdefs.h>
     33  1.2.2.5  pgoyette __KERNEL_RCSID(0, "$NetBSD: rk_cru.c,v 1.2.2.5 2018/09/30 01:45:38 pgoyette Exp $");
     34  1.2.2.2  pgoyette 
     35  1.2.2.2  pgoyette #include <sys/param.h>
     36  1.2.2.2  pgoyette #include <sys/bus.h>
     37  1.2.2.2  pgoyette #include <sys/cpu.h>
     38  1.2.2.2  pgoyette #include <sys/device.h>
     39  1.2.2.2  pgoyette 
     40  1.2.2.2  pgoyette #include <dev/fdt/fdtvar.h>
     41  1.2.2.2  pgoyette 
     42  1.2.2.2  pgoyette #include <dev/clk/clk_backend.h>
     43  1.2.2.2  pgoyette 
     44  1.2.2.2  pgoyette #include <arm/rockchip/rk_cru.h>
     45  1.2.2.2  pgoyette 
     46  1.2.2.2  pgoyette static void *
     47  1.2.2.2  pgoyette rk_cru_reset_acquire(device_t dev, const void *data, size_t len)
     48  1.2.2.2  pgoyette {
     49  1.2.2.2  pgoyette 	if (len != 4)
     50  1.2.2.2  pgoyette 		return NULL;
     51  1.2.2.2  pgoyette 
     52  1.2.2.2  pgoyette 	return (void *)(uintptr_t)be32dec(data);
     53  1.2.2.2  pgoyette }
     54  1.2.2.2  pgoyette 
     55  1.2.2.2  pgoyette static void
     56  1.2.2.2  pgoyette rk_cru_reset_release(device_t dev, void *priv)
     57  1.2.2.2  pgoyette {
     58  1.2.2.2  pgoyette }
     59  1.2.2.2  pgoyette 
     60  1.2.2.2  pgoyette static int
     61  1.2.2.2  pgoyette rk_cru_reset_assert(device_t dev, void *priv)
     62  1.2.2.2  pgoyette {
     63  1.2.2.2  pgoyette 	struct rk_cru_softc * const sc = device_private(dev);
     64  1.2.2.2  pgoyette 	const uintptr_t reset_id = (uintptr_t)priv;
     65  1.2.2.4  pgoyette 	const bus_size_t reg = sc->sc_softrst_base + (reset_id / 16) * 4;
     66  1.2.2.2  pgoyette 	const u_int shift = reset_id % 16;
     67  1.2.2.2  pgoyette 
     68  1.2.2.2  pgoyette 	CRU_WRITE(sc, reg, (1 << (shift + 16)) | (1 << shift));
     69  1.2.2.2  pgoyette 
     70  1.2.2.2  pgoyette 	return 0;
     71  1.2.2.2  pgoyette }
     72  1.2.2.2  pgoyette 
     73  1.2.2.2  pgoyette static int
     74  1.2.2.2  pgoyette rk_cru_reset_deassert(device_t dev, void *priv)
     75  1.2.2.2  pgoyette {
     76  1.2.2.2  pgoyette 	struct rk_cru_softc * const sc = device_private(dev);
     77  1.2.2.2  pgoyette 	const uintptr_t reset_id = (uintptr_t)priv;
     78  1.2.2.4  pgoyette 	const bus_size_t reg = sc->sc_softrst_base + (reset_id / 16) * 4;
     79  1.2.2.2  pgoyette 	const u_int shift = reset_id % 16;
     80  1.2.2.2  pgoyette 
     81  1.2.2.2  pgoyette 	CRU_WRITE(sc, reg, (1 << (shift + 16)) | (0 << shift));
     82  1.2.2.2  pgoyette 
     83  1.2.2.2  pgoyette 	return 0;
     84  1.2.2.2  pgoyette }
     85  1.2.2.2  pgoyette 
     86  1.2.2.2  pgoyette static const struct fdtbus_reset_controller_func rk_cru_fdtreset_funcs = {
     87  1.2.2.2  pgoyette 	.acquire = rk_cru_reset_acquire,
     88  1.2.2.2  pgoyette 	.release = rk_cru_reset_release,
     89  1.2.2.2  pgoyette 	.reset_assert = rk_cru_reset_assert,
     90  1.2.2.2  pgoyette 	.reset_deassert = rk_cru_reset_deassert,
     91  1.2.2.2  pgoyette };
     92  1.2.2.2  pgoyette 
     93  1.2.2.2  pgoyette static struct clk *
     94  1.2.2.5  pgoyette rk_cru_clock_decode(device_t dev, int cc_phandle, const void *data, size_t len)
     95  1.2.2.2  pgoyette {
     96  1.2.2.2  pgoyette 	struct rk_cru_softc * const sc = device_private(dev);
     97  1.2.2.2  pgoyette 	struct rk_cru_clk *clk;
     98  1.2.2.2  pgoyette 
     99  1.2.2.2  pgoyette 	if (len != 4)
    100  1.2.2.2  pgoyette 		return NULL;
    101  1.2.2.2  pgoyette 
    102  1.2.2.2  pgoyette 	const u_int clock_id = be32dec(data);
    103  1.2.2.2  pgoyette 
    104  1.2.2.2  pgoyette 	for (int i = 0; i < sc->sc_nclks; i++) {
    105  1.2.2.2  pgoyette 		clk = &sc->sc_clks[i];
    106  1.2.2.2  pgoyette 		if (clk->id == clock_id)
    107  1.2.2.2  pgoyette 			return &clk->base;
    108  1.2.2.2  pgoyette 	}
    109  1.2.2.2  pgoyette 
    110  1.2.2.2  pgoyette 	return NULL;
    111  1.2.2.2  pgoyette }
    112  1.2.2.2  pgoyette 
    113  1.2.2.2  pgoyette static const struct fdtbus_clock_controller_func rk_cru_fdtclock_funcs = {
    114  1.2.2.2  pgoyette 	.decode = rk_cru_clock_decode,
    115  1.2.2.2  pgoyette };
    116  1.2.2.2  pgoyette 
    117  1.2.2.2  pgoyette static struct clk *
    118  1.2.2.2  pgoyette rk_cru_clock_get(void *priv, const char *name)
    119  1.2.2.2  pgoyette {
    120  1.2.2.2  pgoyette 	struct rk_cru_softc * const sc = priv;
    121  1.2.2.2  pgoyette 	struct rk_cru_clk *clk;
    122  1.2.2.2  pgoyette 
    123  1.2.2.2  pgoyette 	clk = rk_cru_clock_find(sc, name);
    124  1.2.2.2  pgoyette 	if (clk == NULL)
    125  1.2.2.2  pgoyette 		return NULL;
    126  1.2.2.2  pgoyette 
    127  1.2.2.2  pgoyette 	return &clk->base;
    128  1.2.2.2  pgoyette }
    129  1.2.2.2  pgoyette 
    130  1.2.2.2  pgoyette static void
    131  1.2.2.2  pgoyette rk_cru_clock_put(void *priv, struct clk *clk)
    132  1.2.2.2  pgoyette {
    133  1.2.2.2  pgoyette }
    134  1.2.2.2  pgoyette 
    135  1.2.2.2  pgoyette static u_int
    136  1.2.2.2  pgoyette rk_cru_clock_get_rate(void *priv, struct clk *clkp)
    137  1.2.2.2  pgoyette {
    138  1.2.2.2  pgoyette 	struct rk_cru_softc * const sc = priv;
    139  1.2.2.2  pgoyette 	struct rk_cru_clk *clk = (struct rk_cru_clk *)clkp;
    140  1.2.2.2  pgoyette 	struct clk *clkp_parent;
    141  1.2.2.2  pgoyette 
    142  1.2.2.2  pgoyette 	if (clk->get_rate)
    143  1.2.2.2  pgoyette 		return clk->get_rate(sc, clk);
    144  1.2.2.2  pgoyette 
    145  1.2.2.2  pgoyette 	clkp_parent = clk_get_parent(clkp);
    146  1.2.2.2  pgoyette 	if (clkp_parent == NULL) {
    147  1.2.2.2  pgoyette 		aprint_error("%s: no parent for %s\n", __func__, clk->base.name);
    148  1.2.2.2  pgoyette 		return 0;
    149  1.2.2.2  pgoyette 	}
    150  1.2.2.2  pgoyette 
    151  1.2.2.2  pgoyette 	return clk_get_rate(clkp_parent);
    152  1.2.2.2  pgoyette }
    153  1.2.2.2  pgoyette 
    154  1.2.2.2  pgoyette static int
    155  1.2.2.2  pgoyette rk_cru_clock_set_rate(void *priv, struct clk *clkp, u_int rate)
    156  1.2.2.2  pgoyette {
    157  1.2.2.2  pgoyette 	struct rk_cru_softc * const sc = priv;
    158  1.2.2.2  pgoyette 	struct rk_cru_clk *clk = (struct rk_cru_clk *)clkp;
    159  1.2.2.2  pgoyette 	struct clk *clkp_parent;
    160  1.2.2.2  pgoyette 
    161  1.2.2.2  pgoyette 	if (clkp->flags & CLK_SET_RATE_PARENT) {
    162  1.2.2.2  pgoyette 		clkp_parent = clk_get_parent(clkp);
    163  1.2.2.2  pgoyette 		if (clkp_parent == NULL) {
    164  1.2.2.2  pgoyette 			aprint_error("%s: no parent for %s\n", __func__, clk->base.name);
    165  1.2.2.2  pgoyette 			return ENXIO;
    166  1.2.2.2  pgoyette 		}
    167  1.2.2.2  pgoyette 		return clk_set_rate(clkp_parent, rate);
    168  1.2.2.2  pgoyette 	}
    169  1.2.2.2  pgoyette 
    170  1.2.2.2  pgoyette 	if (clk->set_rate)
    171  1.2.2.2  pgoyette 		return clk->set_rate(sc, clk, rate);
    172  1.2.2.2  pgoyette 
    173  1.2.2.2  pgoyette 	return ENXIO;
    174  1.2.2.2  pgoyette }
    175  1.2.2.2  pgoyette 
    176  1.2.2.2  pgoyette static u_int
    177  1.2.2.2  pgoyette rk_cru_clock_round_rate(void *priv, struct clk *clkp, u_int rate)
    178  1.2.2.2  pgoyette {
    179  1.2.2.2  pgoyette 	struct rk_cru_softc * const sc = priv;
    180  1.2.2.2  pgoyette 	struct rk_cru_clk *clk = (struct rk_cru_clk *)clkp;
    181  1.2.2.2  pgoyette 	struct clk *clkp_parent;
    182  1.2.2.2  pgoyette 
    183  1.2.2.2  pgoyette 	if (clkp->flags & CLK_SET_RATE_PARENT) {
    184  1.2.2.2  pgoyette 		clkp_parent = clk_get_parent(clkp);
    185  1.2.2.2  pgoyette 		if (clkp_parent == NULL) {
    186  1.2.2.2  pgoyette 			aprint_error("%s: no parent for %s\n", __func__, clk->base.name);
    187  1.2.2.2  pgoyette 			return 0;
    188  1.2.2.2  pgoyette 		}
    189  1.2.2.2  pgoyette 		return clk_round_rate(clkp_parent, rate);
    190  1.2.2.2  pgoyette 	}
    191  1.2.2.2  pgoyette 
    192  1.2.2.2  pgoyette 	if (clk->round_rate)
    193  1.2.2.2  pgoyette 		return clk->round_rate(sc, clk, rate);
    194  1.2.2.2  pgoyette 
    195  1.2.2.2  pgoyette 	return 0;
    196  1.2.2.2  pgoyette }
    197  1.2.2.2  pgoyette 
    198  1.2.2.2  pgoyette static int
    199  1.2.2.2  pgoyette rk_cru_clock_enable(void *priv, struct clk *clkp)
    200  1.2.2.2  pgoyette {
    201  1.2.2.2  pgoyette 	struct rk_cru_softc * const sc = priv;
    202  1.2.2.2  pgoyette 	struct rk_cru_clk *clk = (struct rk_cru_clk *)clkp;
    203  1.2.2.2  pgoyette 	struct clk *clkp_parent;
    204  1.2.2.2  pgoyette 	int error = 0;
    205  1.2.2.2  pgoyette 
    206  1.2.2.2  pgoyette 	clkp_parent = clk_get_parent(clkp);
    207  1.2.2.2  pgoyette 	if (clkp_parent != NULL) {
    208  1.2.2.2  pgoyette 		error = clk_enable(clkp_parent);
    209  1.2.2.2  pgoyette 		if (error != 0)
    210  1.2.2.2  pgoyette 			return error;
    211  1.2.2.2  pgoyette 	}
    212  1.2.2.2  pgoyette 
    213  1.2.2.2  pgoyette 	if (clk->enable)
    214  1.2.2.2  pgoyette 		error = clk->enable(sc, clk, 1);
    215  1.2.2.2  pgoyette 
    216  1.2.2.2  pgoyette 	return error;
    217  1.2.2.2  pgoyette }
    218  1.2.2.2  pgoyette 
    219  1.2.2.2  pgoyette static int
    220  1.2.2.2  pgoyette rk_cru_clock_disable(void *priv, struct clk *clkp)
    221  1.2.2.2  pgoyette {
    222  1.2.2.2  pgoyette 	struct rk_cru_softc * const sc = priv;
    223  1.2.2.2  pgoyette 	struct rk_cru_clk *clk = (struct rk_cru_clk *)clkp;
    224  1.2.2.2  pgoyette 	int error = EINVAL;
    225  1.2.2.2  pgoyette 
    226  1.2.2.2  pgoyette 	if (clk->enable)
    227  1.2.2.2  pgoyette 		error = clk->enable(sc, clk, 0);
    228  1.2.2.2  pgoyette 
    229  1.2.2.2  pgoyette 	return error;
    230  1.2.2.2  pgoyette }
    231  1.2.2.2  pgoyette 
    232  1.2.2.2  pgoyette static int
    233  1.2.2.2  pgoyette rk_cru_clock_set_parent(void *priv, struct clk *clkp,
    234  1.2.2.2  pgoyette     struct clk *clkp_parent)
    235  1.2.2.2  pgoyette {
    236  1.2.2.2  pgoyette 	struct rk_cru_softc * const sc = priv;
    237  1.2.2.2  pgoyette 	struct rk_cru_clk *clk = (struct rk_cru_clk *)clkp;
    238  1.2.2.2  pgoyette 
    239  1.2.2.2  pgoyette 	if (clk->set_parent == NULL)
    240  1.2.2.2  pgoyette 		return EINVAL;
    241  1.2.2.2  pgoyette 
    242  1.2.2.2  pgoyette 	return clk->set_parent(sc, clk, clkp_parent->name);
    243  1.2.2.2  pgoyette }
    244  1.2.2.2  pgoyette 
    245  1.2.2.2  pgoyette static struct clk *
    246  1.2.2.2  pgoyette rk_cru_clock_get_parent(void *priv, struct clk *clkp)
    247  1.2.2.2  pgoyette {
    248  1.2.2.2  pgoyette 	struct rk_cru_softc * const sc = priv;
    249  1.2.2.2  pgoyette 	struct rk_cru_clk *clk = (struct rk_cru_clk *)clkp;
    250  1.2.2.2  pgoyette 	struct rk_cru_clk *clk_parent;
    251  1.2.2.2  pgoyette 	const char *parent;
    252  1.2.2.2  pgoyette 
    253  1.2.2.2  pgoyette 	if (clk->get_parent == NULL)
    254  1.2.2.2  pgoyette 		return NULL;
    255  1.2.2.2  pgoyette 
    256  1.2.2.2  pgoyette 	parent = clk->get_parent(sc, clk);
    257  1.2.2.2  pgoyette 	if (parent == NULL)
    258  1.2.2.2  pgoyette 		return NULL;
    259  1.2.2.2  pgoyette 
    260  1.2.2.2  pgoyette 	clk_parent = rk_cru_clock_find(sc, parent);
    261  1.2.2.2  pgoyette 	if (clk_parent != NULL)
    262  1.2.2.2  pgoyette 		return &clk_parent->base;
    263  1.2.2.2  pgoyette 
    264  1.2.2.2  pgoyette 	/* No parent in this domain, try FDT */
    265  1.2.2.2  pgoyette 	return fdtbus_clock_byname(parent);
    266  1.2.2.2  pgoyette }
    267  1.2.2.2  pgoyette 
    268  1.2.2.2  pgoyette static const struct clk_funcs rk_cru_clock_funcs = {
    269  1.2.2.2  pgoyette 	.get = rk_cru_clock_get,
    270  1.2.2.2  pgoyette 	.put = rk_cru_clock_put,
    271  1.2.2.2  pgoyette 	.get_rate = rk_cru_clock_get_rate,
    272  1.2.2.2  pgoyette 	.set_rate = rk_cru_clock_set_rate,
    273  1.2.2.2  pgoyette 	.round_rate = rk_cru_clock_round_rate,
    274  1.2.2.2  pgoyette 	.enable = rk_cru_clock_enable,
    275  1.2.2.2  pgoyette 	.disable = rk_cru_clock_disable,
    276  1.2.2.2  pgoyette 	.set_parent = rk_cru_clock_set_parent,
    277  1.2.2.2  pgoyette 	.get_parent = rk_cru_clock_get_parent,
    278  1.2.2.2  pgoyette };
    279  1.2.2.2  pgoyette 
    280  1.2.2.2  pgoyette struct rk_cru_clk *
    281  1.2.2.2  pgoyette rk_cru_clock_find(struct rk_cru_softc *sc, const char *name)
    282  1.2.2.2  pgoyette {
    283  1.2.2.2  pgoyette 	for (int i = 0; i < sc->sc_nclks; i++) {
    284  1.2.2.2  pgoyette 		if (sc->sc_clks[i].base.name == NULL)
    285  1.2.2.2  pgoyette 			continue;
    286  1.2.2.2  pgoyette 		if (strcmp(sc->sc_clks[i].base.name, name) == 0)
    287  1.2.2.2  pgoyette 			return &sc->sc_clks[i];
    288  1.2.2.2  pgoyette 	}
    289  1.2.2.2  pgoyette 
    290  1.2.2.2  pgoyette 	return NULL;
    291  1.2.2.2  pgoyette }
    292  1.2.2.2  pgoyette 
    293  1.2.2.2  pgoyette int
    294  1.2.2.2  pgoyette rk_cru_attach(struct rk_cru_softc *sc)
    295  1.2.2.2  pgoyette {
    296  1.2.2.2  pgoyette 	bus_addr_t addr;
    297  1.2.2.2  pgoyette 	bus_size_t size;
    298  1.2.2.2  pgoyette 	int i;
    299  1.2.2.2  pgoyette 
    300  1.2.2.2  pgoyette 	if (of_hasprop(sc->sc_phandle, "rockchip,grf")) {
    301  1.2.2.3  pgoyette 		sc->sc_grf = fdtbus_syscon_acquire(sc->sc_phandle, "rockchip,grf");
    302  1.2.2.3  pgoyette 		if (sc->sc_grf == NULL) {
    303  1.2.2.3  pgoyette 			aprint_error(": couldn't get grf syscon\n");
    304  1.2.2.2  pgoyette 			return ENXIO;
    305  1.2.2.2  pgoyette 		}
    306  1.2.2.2  pgoyette 	}
    307  1.2.2.2  pgoyette 
    308  1.2.2.2  pgoyette 	if (fdtbus_get_reg(sc->sc_phandle, 0, &addr, &size) != 0) {
    309  1.2.2.2  pgoyette 		aprint_error(": couldn't get registers\n");
    310  1.2.2.2  pgoyette 		return ENXIO;
    311  1.2.2.2  pgoyette 	}
    312  1.2.2.2  pgoyette 	if (bus_space_map(sc->sc_bst, addr, size, 0, &sc->sc_bsh) != 0) {
    313  1.2.2.2  pgoyette 		aprint_error(": couldn't map registers\n");
    314  1.2.2.2  pgoyette 		return ENXIO;
    315  1.2.2.2  pgoyette 	}
    316  1.2.2.2  pgoyette 
    317  1.2.2.2  pgoyette 	sc->sc_clkdom.name = device_xname(sc->sc_dev);
    318  1.2.2.2  pgoyette 	sc->sc_clkdom.funcs = &rk_cru_clock_funcs;
    319  1.2.2.2  pgoyette 	sc->sc_clkdom.priv = sc;
    320  1.2.2.2  pgoyette 	for (i = 0; i < sc->sc_nclks; i++) {
    321  1.2.2.2  pgoyette 		sc->sc_clks[i].base.domain = &sc->sc_clkdom;
    322  1.2.2.2  pgoyette 		clk_attach(&sc->sc_clks[i].base);
    323  1.2.2.2  pgoyette 	}
    324  1.2.2.2  pgoyette 
    325  1.2.2.2  pgoyette 	fdtbus_register_clock_controller(sc->sc_dev, sc->sc_phandle,
    326  1.2.2.2  pgoyette 	    &rk_cru_fdtclock_funcs);
    327  1.2.2.2  pgoyette 
    328  1.2.2.2  pgoyette 	fdtbus_register_reset_controller(sc->sc_dev, sc->sc_phandle,
    329  1.2.2.2  pgoyette 	    &rk_cru_fdtreset_funcs);
    330  1.2.2.2  pgoyette 
    331  1.2.2.2  pgoyette 	return 0;
    332  1.2.2.2  pgoyette }
    333  1.2.2.2  pgoyette 
    334  1.2.2.2  pgoyette void
    335  1.2.2.2  pgoyette rk_cru_print(struct rk_cru_softc *sc)
    336  1.2.2.2  pgoyette {
    337  1.2.2.2  pgoyette 	struct rk_cru_clk *clk;
    338  1.2.2.2  pgoyette 	struct clk *clkp_parent;
    339  1.2.2.2  pgoyette 	const char *type;
    340  1.2.2.2  pgoyette 	int i;
    341  1.2.2.2  pgoyette 
    342  1.2.2.2  pgoyette 	for (i = 0; i < sc->sc_nclks; i++) {
    343  1.2.2.2  pgoyette 		clk = &sc->sc_clks[i];
    344  1.2.2.2  pgoyette 		if (clk->type == RK_CRU_UNKNOWN)
    345  1.2.2.2  pgoyette 			continue;
    346  1.2.2.2  pgoyette 
    347  1.2.2.2  pgoyette 		clkp_parent = clk_get_parent(&clk->base);
    348  1.2.2.2  pgoyette 
    349  1.2.2.2  pgoyette 		switch (clk->type) {
    350  1.2.2.2  pgoyette 		case RK_CRU_PLL:		type = "pll"; break;
    351  1.2.2.2  pgoyette 		case RK_CRU_ARM:		type = "arm"; break;
    352  1.2.2.2  pgoyette 		case RK_CRU_COMPOSITE:		type = "comp"; break;
    353  1.2.2.2  pgoyette 		case RK_CRU_GATE:		type = "gate"; break;
    354  1.2.2.2  pgoyette 		case RK_CRU_MUX:		type = "mux"; break;
    355  1.2.2.2  pgoyette 		default:			type = "???"; break;
    356  1.2.2.2  pgoyette 		}
    357  1.2.2.2  pgoyette 
    358  1.2.2.3  pgoyette         	aprint_debug_dev(sc->sc_dev,
    359  1.2.2.2  pgoyette 		    "%3d %-14s %2s %-14s %-7s ",
    360  1.2.2.2  pgoyette 		    clk->id,
    361  1.2.2.2  pgoyette         	    clk->base.name,
    362  1.2.2.2  pgoyette         	    clkp_parent ? "<-" : "",
    363  1.2.2.2  pgoyette         	    clkp_parent ? clkp_parent->name : "",
    364  1.2.2.2  pgoyette         	    type);
    365  1.2.2.3  pgoyette 		aprint_debug("%10d Hz\n", clk_get_rate(&clk->base));
    366  1.2.2.2  pgoyette 	}
    367  1.2.2.2  pgoyette }
    368