clk: uniphier: rework UniPhier clk driver

The initial design of the UniPhier clk driver for U-Boot was not
very nice.  Here is a re-work to sync it with Linux's clk and reset
drivers, maximizing the code reuse from Linux's clk data.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
diff --git a/drivers/clk/uniphier/clk-uniphier.h b/drivers/clk/uniphier/clk-uniphier.h
index 0b60337..f9a560e 100644
--- a/drivers/clk/uniphier/clk-uniphier.h
+++ b/drivers/clk/uniphier/clk-uniphier.h
@@ -10,36 +10,46 @@
 
 #include <linux/kernel.h>
 
+#define UNIPHIER_CLK_MAX_NR_MUXS	8
+
 struct uniphier_clk_gate_data {
-	int index;
+	unsigned int id;
 	unsigned int reg;
-	u32 mask;
-	u32 data;
+	unsigned int bit;
 };
 
-struct uniphier_clk_rate_data {
-	int index;
+struct uniphier_clk_mux_data {
+	unsigned int id;
+	unsigned int nr_muxs;
 	unsigned int reg;
-#define UNIPHIER_CLK_RATE_IS_FIXED		UINT_MAX
-	u32 mask;
-	u32 data;
-	unsigned long rate;
+	unsigned int masks[UNIPHIER_CLK_MAX_NR_MUXS];
+	unsigned int vals[UNIPHIER_CLK_MAX_NR_MUXS];
+	unsigned long rates[UNIPHIER_CLK_MAX_NR_MUXS];
 };
 
-struct uniphier_clk_soc_data {
+struct uniphier_clk_data {
 	const struct uniphier_clk_gate_data *gate;
-	unsigned int nr_gate;
-	const struct uniphier_clk_rate_data *rate;
-	unsigned int nr_rate;
+	const struct uniphier_clk_mux_data *mux;
 };
 
+#define UNIPHIER_CLK_ID_END		(unsigned int)(-1)
+
+#define UNIPHIER_CLK_END				\
+	{ .id = UNIPHIER_CLK_ID_END }
+
-#define UNIPHIER_CLK_FIXED_RATE(i, f)			\
+#define UNIPHIER_CLK_GATE(_id, _reg, _bit)		\
 	{						\
-		.index = i,				\
-		.reg = UNIPHIER_CLK_RATE_IS_FIXED,	\
-		.rate = f,				\
+		.id = (_id),				\
+		.reg = (_reg),				\
+		.bit = (_bit),				\
 	}
 
-extern const struct uniphier_clk_soc_data uniphier_mio_clk_data;
+#define UNIPHIER_CLK_FIXED_RATE(_id, _rate)		\
+	{						\
+		.id = (_id),				\
+		.rates = {(_reg),},			\
+	}
+
+extern const struct uniphier_clk_data uniphier_mio_clk_data;
 
 #endif /* __CLK_UNIPHIER_H__ */