diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2018-11-05 15:44:14 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-11-05 15:53:42 +0100 |
commit | 21d3a53a4f7573a15fb719d49771641c5cf0bb34 (patch) | |
tree | 50693427a33f85149cf68bd7997a76f9afe6f03d /arch/arm/boards | |
parent | 4f9e24935c78c1c13613054e024ea75446dcb4a4 (diff) | |
download | barebox-21d3a53a4f7573a15fb719d49771641c5cf0bb34.tar.gz barebox-21d3a53a4f7573a15fb719d49771641c5cf0bb34.tar.xz |
ARM: at91: consolidate phy reset functions
Many boards have the same ethernet phy reset function, so share the code
in a common function.
While at it remove the AT91_RSTC offset from the rstc register defines.
AT91_RSTC was the offset between the AT91_SYSTEM_BASE and the reset
controller.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/boards')
-rw-r--r-- | arch/arm/boards/animeo_ip/init.c | 20 | ||||
-rw-r--r-- | arch/arm/boards/at91sam9260ek/init.c | 21 | ||||
-rw-r--r-- | arch/arm/boards/dss11/init.c | 22 | ||||
-rw-r--r-- | arch/arm/boards/haba-knx/init.c | 23 | ||||
-rw-r--r-- | arch/arm/boards/qil-a926x/init.c | 22 | ||||
-rw-r--r-- | arch/arm/boards/telit-evk-pro3/init.c | 21 | ||||
-rw-r--r-- | arch/arm/boards/usb-a926x/init.c | 24 |
7 files changed, 9 insertions, 144 deletions
diff --git a/arch/arm/boards/animeo_ip/init.c b/arch/arm/boards/animeo_ip/init.c index 847417398a..775c818df6 100644 --- a/arch/arm/boards/animeo_ip/init.c +++ b/arch/arm/boards/animeo_ip/init.c @@ -231,30 +231,12 @@ static void animeo_ip_power_control(void) static void animeo_ip_phy_reset(void) { - unsigned long rstc; int i; - struct clk *clk = clk_get(NULL, "macb_clk"); - - clk_enable(clk); for (i = AT91_PIN_PA12; i <= AT91_PIN_PA29; i++) at91_set_gpio_input(i, 0); - rstc = at91_sys_read(AT91_RSTC_MR) & AT91_RSTC_ERSTL; - - /* Need to reset PHY -> 500ms reset */ - at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY | - (AT91_RSTC_ERSTL & (0x0d << 8)) | - AT91_RSTC_URSTEN); - - at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_EXTRST); - - /* Wait for end hardware reset */ - while (!(at91_sys_read(AT91_RSTC_SR) & AT91_RSTC_NRSTL)) - ; - - /* Restore NRST value */ - at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY | (rstc) | AT91_RSTC_URSTEN); + at91sam_phy_reset(IOMEM(AT91SAM9260_BASE_RSTC)); } #define MACB_SA1B 0x0098 diff --git a/arch/arm/boards/at91sam9260ek/init.c b/arch/arm/boards/at91sam9260ek/init.c index 5a21ac12fe..de74835d78 100644 --- a/arch/arm/boards/at91sam9260ek/init.c +++ b/arch/arm/boards/at91sam9260ek/init.c @@ -125,11 +125,6 @@ static struct macb_platform_data macb_pdata = { static void at91sam9260ek_phy_reset(void) { - unsigned long rstc; - struct clk *clk = clk_get(NULL, "macb_clk"); - - clk_enable(clk); - at91_set_gpio_input(AT91_PIN_PA14, 0); at91_set_gpio_input(AT91_PIN_PA15, 0); at91_set_gpio_input(AT91_PIN_PA17, 0); @@ -137,21 +132,7 @@ static void at91sam9260ek_phy_reset(void) at91_set_gpio_input(AT91_PIN_PA26, 0); at91_set_gpio_input(AT91_PIN_PA28, 0); - rstc = at91_sys_read(AT91_RSTC_MR) & AT91_RSTC_ERSTL; - - /* Need to reset PHY -> 500ms reset */ - at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY | - (AT91_RSTC_ERSTL & (0x0d << 8)) | - AT91_RSTC_URSTEN); - - at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_EXTRST); - - /* Wait for end hardware reset */ - while (!(at91_sys_read(AT91_RSTC_SR) & AT91_RSTC_NRSTL)) - ; - - /* Restore NRST value */ - at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY | (rstc) | AT91_RSTC_URSTEN); + at91sam_phy_reset(IOMEM(AT91SAM9260_BASE_RSTC)); } /* diff --git a/arch/arm/boards/dss11/init.c b/arch/arm/boards/dss11/init.c index 321c383ffc..432613ff4a 100644 --- a/arch/arm/boards/dss11/init.c +++ b/arch/arm/boards/dss11/init.c @@ -80,11 +80,6 @@ static struct macb_platform_data macb_pdata = { static void dss11_phy_reset(void) { - unsigned long rstc; - struct clk *clk = clk_get(NULL, "macb_clk"); - - clk_enable(clk); - at91_set_gpio_input(AT91_PIN_PA14, 0); at91_set_gpio_input(AT91_PIN_PA15, 0); at91_set_gpio_input(AT91_PIN_PA17, 0); @@ -92,22 +87,7 @@ static void dss11_phy_reset(void) at91_set_gpio_input(AT91_PIN_PA26, 0); at91_set_gpio_input(AT91_PIN_PA28, 0); - rstc = at91_sys_read(AT91_RSTC_MR) & AT91_RSTC_ERSTL; - - /* Need to reset PHY -> 500ms reset */ - at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY | - (AT91_RSTC_ERSTL & (0x0d << 8)) | - AT91_RSTC_URSTEN); - - at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_EXTRST); - - /* Wait for end hardware reset */ - while (!(at91_sys_read(AT91_RSTC_SR) & AT91_RSTC_NRSTL)); - - /* Restore NRST value */ - at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY | - (rstc) | - AT91_RSTC_URSTEN); + at91sam_phy_reset(IOMEM(AT91SAM9260_BASE_RSTC)); } static struct atmel_mci_platform_data dss11_mci_data = { diff --git a/arch/arm/boards/haba-knx/init.c b/arch/arm/boards/haba-knx/init.c index 36f1e8b741..4a000d9aed 100644 --- a/arch/arm/boards/haba-knx/init.c +++ b/arch/arm/boards/haba-knx/init.c @@ -91,33 +91,12 @@ static struct macb_platform_data macb_pdata = { static void haba_knx_phy_reset(void) { - unsigned long rstc; - struct clk *clk = clk_get(NULL, "macb_clk"); - - clk_enable(clk); - at91_set_gpio_input(AT91_PIN_PA14, 0); at91_set_gpio_input(AT91_PIN_PA15, 0); at91_set_gpio_input(AT91_PIN_PA17, 0); at91_set_gpio_input(AT91_PIN_PA18, 0); - rstc = at91_sys_read(AT91_RSTC_MR) & AT91_RSTC_ERSTL; - - /* Need to reset PHY -> 500ms reset */ - at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY | - (AT91_RSTC_ERSTL & (0x0d << 8)) | - AT91_RSTC_URSTEN); - - at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_EXTRST); - - /* Wait for end hardware reset */ - while (!(at91_sys_read(AT91_RSTC_SR) & AT91_RSTC_NRSTL)) - ; - - /* Restore NRST value */ - at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY | - (rstc) | - AT91_RSTC_URSTEN); + at91sam_phy_reset(IOMEM(AT91SAM9260_BASE_RSTC)); } #define MACB_SA1B 0x0098 diff --git a/arch/arm/boards/qil-a926x/init.c b/arch/arm/boards/qil-a926x/init.c index 3ef9872797..6fa0df033e 100644 --- a/arch/arm/boards/qil-a926x/init.c +++ b/arch/arm/boards/qil-a926x/init.c @@ -118,11 +118,6 @@ static struct macb_platform_data macb_pdata = { static void qil_a9260_phy_reset(void) { - unsigned long rstc; - struct clk *clk = clk_get(NULL, "macb_clk"); - - clk_enable(clk); - at91_set_gpio_input(AT91_PIN_PA14, 0); at91_set_gpio_input(AT91_PIN_PA15, 0); at91_set_gpio_input(AT91_PIN_PA17, 0); @@ -130,22 +125,7 @@ static void qil_a9260_phy_reset(void) at91_set_gpio_input(AT91_PIN_PA26, 0); at91_set_gpio_input(AT91_PIN_PA28, 0); - rstc = at91_sys_read(AT91_RSTC_MR) & AT91_RSTC_ERSTL; - - /* Need to reset PHY -> 500ms reset */ - at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY | - (AT91_RSTC_ERSTL & (0x0d << 8)) | - AT91_RSTC_URSTEN); - - at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_EXTRST); - - /* Wait for end hardware reset */ - while (!(at91_sys_read(AT91_RSTC_SR) & AT91_RSTC_NRSTL)); - - /* Restore NRST value */ - at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY | - (rstc) | - AT91_RSTC_URSTEN); + at91sam_phy_reset(IOMEM(AT91SAM9260_BASE_RSTC)); } /* diff --git a/arch/arm/boards/telit-evk-pro3/init.c b/arch/arm/boards/telit-evk-pro3/init.c index ea63b1a094..4f536079cc 100644 --- a/arch/arm/boards/telit-evk-pro3/init.c +++ b/arch/arm/boards/telit-evk-pro3/init.c @@ -72,11 +72,6 @@ static struct macb_platform_data macb_pdata = { static void evk_phy_reset(void) { - unsigned long rstc; - struct clk *clk = clk_get(NULL, "macb_clk"); - - clk_enable(clk); - at91_set_gpio_input(AT91_PIN_PA14, 0); at91_set_gpio_input(AT91_PIN_PA15, 0); at91_set_gpio_input(AT91_PIN_PA17, 0); @@ -84,21 +79,7 @@ static void evk_phy_reset(void) at91_set_gpio_input(AT91_PIN_PA26, 0); at91_set_gpio_input(AT91_PIN_PA28, 0); - rstc = at91_sys_read(AT91_RSTC_MR) & AT91_RSTC_ERSTL; - - /* Need to reset PHY -> 500ms reset */ - at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY | - (AT91_RSTC_ERSTL & (0x0d << 8)) | - AT91_RSTC_URSTEN); - - at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_EXTRST); - - /* Wait for end hardware reset */ - while (!(at91_sys_read(AT91_RSTC_SR) & AT91_RSTC_NRSTL)) - ; - - /* Restore NRST value */ - at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY | (rstc) | AT91_RSTC_URSTEN); + at91sam_phy_reset(IOMEM(AT91SAM9260_BASE_RSTC)); } /* diff --git a/arch/arm/boards/usb-a926x/init.c b/arch/arm/boards/usb-a926x/init.c index 12e8f4e0d6..e431cd4603 100644 --- a/arch/arm/boards/usb-a926x/init.c +++ b/arch/arm/boards/usb-a926x/init.c @@ -26,6 +26,7 @@ #include <io.h> #include <envfs.h> #include <mach/hardware.h> +#include <mach/at91sam926x.h> #include <nand.h> #include <linux/sizes.h> #include <linux/mtd/nand.h> @@ -128,11 +129,6 @@ static struct macb_platform_data macb_pdata = { static void usb_a9260_phy_reset(void) { - unsigned long rstc; - struct clk *clk = clk_get(NULL, "macb_clk"); - - clk_enable(clk); - at91_set_gpio_input(AT91_PIN_PA14, 0); at91_set_gpio_input(AT91_PIN_PA15, 0); at91_set_gpio_input(AT91_PIN_PA17, 0); @@ -140,22 +136,8 @@ static void usb_a9260_phy_reset(void) at91_set_gpio_input(AT91_PIN_PA26, 0); at91_set_gpio_input(AT91_PIN_PA28, 0); - rstc = at91_sys_read(AT91_RSTC_MR) & AT91_RSTC_ERSTL; - - /* Need to reset PHY -> 500ms reset */ - at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY | - (AT91_RSTC_ERSTL & (0x0d << 8)) | - AT91_RSTC_URSTEN); - - at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_EXTRST); - - /* Wait for end hardware reset */ - while (!(at91_sys_read(AT91_RSTC_SR) & AT91_RSTC_NRSTL)); - - /* Restore NRST value */ - at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY | - (rstc) | - AT91_RSTC_URSTEN); + /* same address for the different supported SoCs */ + at91sam_phy_reset(IOMEM(AT91SAM926X_BASE_RSTC)); } static void usb_a9260_add_device_eth(void) |