diff mbox

[3/4] clk: hix5hd2: change ethernet clock type

Message ID 1470906115-155569-4-git-send-email-lidongpo@hisilicon.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Dongpo Li Aug. 11, 2016, 9:01 a.m. UTC
Because the clock and reset signals share the same register,
we initialize reset controller when initializing clock controller.
So the ethernet driver will control the reset signal instead of
the clock driver.
All the ethernet clock is changed from complex clock to gate clock.
The original ethernet clock is really a "complex" clock because
it's obscure and hard to understand.

Signed-off-by: Dongpo Li <lidongpo@hisilicon.com>
---
 drivers/clk/hisilicon/clk-hix5hd2.c       | 72 +++++++------------------------
 include/dt-bindings/clock/hix5hd2-clock.h |  6 ++-
 2 files changed, 20 insertions(+), 58 deletions(-)

Comments

kernel test robot Aug. 11, 2016, 12:09 p.m. UTC | #1
Hi Dongpo,

[auto build test ERROR on robh/for-next]
[also build test ERROR on v4.8-rc1 next-20160811]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Dongpo-Li/net-hix5hd2_gmac-add-tx-sg-feature-and-reset-clock-control-signals/20160811-170826
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
config: arm-multi_v7_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 5.4.0-6) 5.4.0 20160609
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=arm 

All errors (new ones prefixed by >>):

   drivers/clk/hisilicon/clk-hix5hd2.c: In function 'hix5hd2_clk_init':
>> drivers/clk/hisilicon/clk-hix5hd2.c:260:25: error: passing argument 1 of 'hisi_reset_init' from incompatible pointer type [-Werror=incompatible-pointer-types]
     rstc = hisi_reset_init(np);
                            ^
   In file included from drivers/clk/hisilicon/clk-hix5hd2.c:15:0:
   drivers/clk/hisilicon/reset.h:25:31: note: expected 'struct platform_device *' but argument is of type 'struct device_node *'
    struct hisi_reset_controller *hisi_reset_init(struct platform_device *pdev);
                                  ^
   cc1: some warnings being treated as errors

vim +/hisi_reset_init +260 drivers/clk/hisilicon/clk-hix5hd2.c

   254	
   255	static void __init hix5hd2_clk_init(struct device_node *np)
   256	{
   257		struct hisi_clock_data *clk_data;
   258		struct hisi_reset_controller *rstc;
   259	
 > 260		rstc = hisi_reset_init(np);
   261		if (!rstc)
   262			return;
   263	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
Dongpo Li Aug. 15, 2016, 7:49 a.m. UTC | #2
Hi all,

On 2016/8/11 20:09, kbuild test robot wrote:
> Hi Dongpo,
> 
> [auto build test ERROR on robh/for-next]
> [also build test ERROR on v4.8-rc1 next-20160811]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
> 
> url:    https://github.com/0day-ci/linux/commits/Dongpo-Li/net-hix5hd2_gmac-add-tx-sg-feature-and-reset-clock-control-signals/20160811-170826
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
> config: arm-multi_v7_defconfig (attached as .config)
> compiler: arm-linux-gnueabi-gcc (Debian 5.4.0-6) 5.4.0 20160609
> reproduce:
>         wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # save the attached .config to linux build tree
>         make.cross ARCH=arm 
> 
> All errors (new ones prefixed by >>):
> 
>    drivers/clk/hisilicon/clk-hix5hd2.c: In function 'hix5hd2_clk_init':
>>> drivers/clk/hisilicon/clk-hix5hd2.c:260:25: error: passing argument 1 of 'hisi_reset_init' from incompatible pointer type [-Werror=incompatible-pointer-types]
>      rstc = hisi_reset_init(np);
>                             ^
>    In file included from drivers/clk/hisilicon/clk-hix5hd2.c:15:0:
>    drivers/clk/hisilicon/reset.h:25:31: note: expected 'struct platform_device *' but argument is of type 'struct device_node *'
>     struct hisi_reset_controller *hisi_reset_init(struct platform_device *pdev);
>                                   ^

Sorry for my mistake, the interface changes in newer patch. I will fix my problem in the next patch version.


    Regards,
    Dongpo

.
diff mbox

Patch

diff --git a/drivers/clk/hisilicon/clk-hix5hd2.c b/drivers/clk/hisilicon/clk-hix5hd2.c
index 14b05ef..f9689e3 100644
--- a/drivers/clk/hisilicon/clk-hix5hd2.c
+++ b/drivers/clk/hisilicon/clk-hix5hd2.c
@@ -12,6 +12,7 @@ 
 #include <linux/slab.h>
 #include <linux/delay.h>
 #include "clk.h"
+#include "reset.h"
 
 static struct hisi_fixed_rate_clock hix5hd2_fixed_rate_clks[] __initdata = {
 	{ HIX5HD2_FIXED_1200M, "1200m", NULL, 0, 1200000000, },
@@ -93,8 +94,12 @@  static struct hisi_gate_clock hix5hd2_gate_clks[] __initdata = {
 	/* gsf */
 	{ HIX5HD2_FWD_BUS_CLK, "clk_fwd_bus", NULL, 0, 0xcc, 0, 0, },
 	{ HIX5HD2_FWD_SYS_CLK, "clk_fwd_sys", "clk_fwd_bus", 0, 0xcc, 5, 0, },
-	{ HIX5HD2_MAC0_PHY_CLK, "clk_fephy", "clk_fwd_sys",
-		 CLK_SET_RATE_PARENT, 0x120, 0, 0, },
+	{ HIX5HD2_MAC0_CLK, "clk_mac0", "clk_fwd_sys", 0, 0xcc, 1, 0, },
+	{ HIX5HD2_MAC_IFC0_CLK, "clk_mac_ifc0", "clk_fwd_sys", 0, 0xcc, 3, 0, },
+	{ HIX5HD2_MAC1_CLK, "clk_mac1", "clk_fwd_sys", 0, 0xcc, 2, 0, },
+	{ HIX5HD2_MAC_IFC1_CLK, "clk_mac_ifc1", "clk_fwd_sys", 0, 0xcc, 4, 0, },
+	{ HIX5HD2_MAC0_PHY_CLK, "clk_fephy", NULL,
+		 CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, 0x120, 0, 0, },
 	/* wdg0 */
 	{ HIX5HD2_WDG0_CLK, "clk_wdg0", "24m",
 		CLK_SET_RATE_PARENT, 0x178, 0, 0, },
@@ -129,7 +134,6 @@  static struct hisi_gate_clock hix5hd2_gate_clks[] __initdata = {
 
 enum hix5hd2_clk_type {
 	TYPE_COMPLEX,
-	TYPE_ETHER,
 };
 
 struct hix5hd2_complex_clock {
@@ -157,10 +161,6 @@  struct hix5hd2_clk_complex {
 };
 
 static struct hix5hd2_complex_clock hix5hd2_complex_clks[] __initdata = {
-	{"clk_mac0", "clk_fephy", HIX5HD2_MAC0_CLK,
-		0xcc, 0xa, 0x500, 0x120, 0, 0x10, TYPE_ETHER},
-	{"clk_mac1", "clk_fwd_sys", HIX5HD2_MAC1_CLK,
-		0xcc, 0x14, 0xa00, 0x168, 0x2, 0, TYPE_ETHER},
 	{"clk_sata", NULL, HIX5HD2_SATA_CLK,
 		0xa8, 0x1f, 0x300, 0xac, 0x1, 0x0, TYPE_COMPLEX},
 	{"clk_usb", NULL, HIX5HD2_USB_CLK,
@@ -169,50 +169,6 @@  static struct hix5hd2_complex_clock hix5hd2_complex_clks[] __initdata = {
 
 #define to_complex_clk(_hw) container_of(_hw, struct hix5hd2_clk_complex, hw)
 
-static int clk_ether_prepare(struct clk_hw *hw)
-{
-	struct hix5hd2_clk_complex *clk = to_complex_clk(hw);
-	u32 val;
-
-	val = readl_relaxed(clk->ctrl_reg);
-	val |= clk->ctrl_clk_mask | clk->ctrl_rst_mask;
-	writel_relaxed(val, clk->ctrl_reg);
-	val &= ~(clk->ctrl_rst_mask);
-	writel_relaxed(val, clk->ctrl_reg);
-
-	val = readl_relaxed(clk->phy_reg);
-	val |= clk->phy_clk_mask;
-	val &= ~(clk->phy_rst_mask);
-	writel_relaxed(val, clk->phy_reg);
-	mdelay(10);
-
-	val &= ~(clk->phy_clk_mask);
-	val |= clk->phy_rst_mask;
-	writel_relaxed(val, clk->phy_reg);
-	mdelay(10);
-
-	val |= clk->phy_clk_mask;
-	val &= ~(clk->phy_rst_mask);
-	writel_relaxed(val, clk->phy_reg);
-	mdelay(30);
-	return 0;
-}
-
-static void clk_ether_unprepare(struct clk_hw *hw)
-{
-	struct hix5hd2_clk_complex *clk = to_complex_clk(hw);
-	u32 val;
-
-	val = readl_relaxed(clk->ctrl_reg);
-	val &= ~(clk->ctrl_clk_mask);
-	writel_relaxed(val, clk->ctrl_reg);
-}
-
-static struct clk_ops clk_ether_ops = {
-	.prepare = clk_ether_prepare,
-	.unprepare = clk_ether_unprepare,
-};
-
 static int clk_complex_enable(struct clk_hw *hw)
 {
 	struct hix5hd2_clk_complex *clk = to_complex_clk(hw);
@@ -269,10 +225,7 @@  hix5hd2_clk_register_complex(struct hix5hd2_complex_clock *clks, int nums,
 			return;
 
 		init.name = clks[i].name;
-		if (clks[i].type == TYPE_ETHER)
-			init.ops = &clk_ether_ops;
-		else
-			init.ops = &clk_complex_ops;
+		init.ops = &clk_complex_ops;
 
 		init.flags = CLK_IS_BASIC;
 		init.parent_names =
@@ -302,10 +255,17 @@  hix5hd2_clk_register_complex(struct hix5hd2_complex_clock *clks, int nums,
 static void __init hix5hd2_clk_init(struct device_node *np)
 {
 	struct hisi_clock_data *clk_data;
+	struct hisi_reset_controller *rstc;
+
+	rstc = hisi_reset_init(np);
+	if (!rstc)
+		return;
 
 	clk_data = hisi_clk_init(np, HIX5HD2_NR_CLKS);
-	if (!clk_data)
+	if (!clk_data) {
+		hisi_reset_exit(rstc);
 		return;
+	}
 
 	hisi_clk_register_fixed_rate(hix5hd2_fixed_rate_clks,
 				     ARRAY_SIZE(hix5hd2_fixed_rate_clks),
diff --git a/include/dt-bindings/clock/hix5hd2-clock.h b/include/dt-bindings/clock/hix5hd2-clock.h
index fd29c17..90f0731 100644
--- a/include/dt-bindings/clock/hix5hd2-clock.h
+++ b/include/dt-bindings/clock/hix5hd2-clock.h
@@ -74,10 +74,12 @@ 
 #define HIX5HD2_I2C4_RST		150
 #define HIX5HD2_I2C5_CLK		151
 #define HIX5HD2_I2C5_RST		152
+#define HIX5HD2_MAC0_CLK		153
+#define HIX5HD2_MAC1_CLK		154
+#define HIX5HD2_MAC_IFC0_CLK		155
+#define HIX5HD2_MAC_IFC1_CLK		156
 
 /* complex */
-#define HIX5HD2_MAC0_CLK		192
-#define HIX5HD2_MAC1_CLK		193
 #define HIX5HD2_SATA_CLK		194
 #define HIX5HD2_USB_CLK			195