Thread (17 messages) 17 messages, 6 authors, 2018-10-23

Re: [PATCH v3 5/5] clk: RK808: add RK809 and RK817 support.

From: Stephen Boyd <sboyd@kernel.org>
Date: 2018-08-31 17:34:25
Also in: linux-arm-kernel, linux-clk, linux-devicetree, linux-rockchip, lkml

Quoting Tony Xie (2018-08-23 20:36:02)
quoted hunk ↗ jump to hunk
diff --git a/drivers/clk/clk-rk808.c b/drivers/clk/clk-rk808.c
index 6461f28..c5d3492 100644
--- a/drivers/clk/clk-rk808.c
+++ b/drivers/clk/clk-rk808.c
@@ -96,6 +96,66 @@ static int rk808_clkout2_is_prepared(struct clk_hw *hw)
+
+static int rk817_clkout2_is_prepared(struct clk_hw *hw)
+{
+       struct rk808_clkout *rk808_clkout =3D container_of(hw,
+                                                        struct rk808_clk=
out,
+                                                        clkout2_hw);
+       struct rk808 *rk808 =3D rk808_clkout->rk808;
+       unsigned int val;
+
+       int ret =3D regmap_read(rk808->regmap, RK817_SYS_CFG(1), &val);
+
+       if (ret < 0)
+               return ret;
The clk core handles the return value here as true or false. Probably
should return 0 here.
+
+       return (val & RK817_CLK32KOUT2_EN) ? 1 : 0;
+}
+
+static const struct clk_ops rk817_clkout2_ops =3D {
+       .prepare =3D rk817_clkout2_prepare,
+       .unprepare =3D rk817_clkout2_unprepare,
+       .is_prepared =3D rk817_clkout2_is_prepared,
+       .recalc_rate =3D rk808_clkout_recalc_rate,
+};
+
+static const struct clk_ops *rkpmic_get_ops(long variant)
Use the enum here for 'variant'? Then the case statement here will
complain loudly for unhandled cases.
quoted hunk ↗ jump to hunk
+{
+       switch (variant) {
+       case RK809_ID:
+       case RK817_ID:
+               return &rk817_clkout2_ops;
+       case RK805_ID:
+       case RK808_ID:
+       case RK818_ID:
+               return &rk808_clkout2_ops;
+       }
+
+       return &rk808_clkout2_ops;
+}
+
 static int rk808_clkout_probe(struct platform_device *pdev)
 {
        struct rk808 *rk808 =3D dev_get_drvdata(pdev->dev.parent);
@@ -127,7 +187,7 @@ static int rk808_clkout_probe(struct platform_device =
*pdev)
                return ret;
 =
        init.name =3D "rk808-clkout2";
-       init.ops =3D &rk808_clkout2_ops;
+       init.ops =3D rkpmic_get_ops(rk808->variant);
        rk808_clkout->clkout2_hw.init =3D &init;
 =
        /* optional override of the clockname */
-- =
1.9.1
=
=20
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help