2012-11-25 20:17:35

by Philippe Reynes

[permalink] [raw]
Subject: [PATCH 0/4] apf27: enable Ethernet PHY and add support of ds1374 rtc

This patch series enable Ethernet PHY at startup, and add
the support of ds1374 rtc on armadeus apf27.

Philippe Reynes (4):
apf27: enable Ethernet PHY
ds1374: add support of device tree
imx27-dt: configure i2c1 gpio on armadeus apf27
apf27: add rtc ds1374 to the device tree

arch/arm/boot/dts/imx27-apf27.dts | 10 ++++++++++
arch/arm/mach-imx/imx27-dt.c | 26 ++++++++++++++++++++++++++
drivers/rtc/rtc-ds1374.c | 8 ++++++++
3 files changed, 44 insertions(+), 0 deletions(-)

--
1.7.4.4


2012-11-25 20:17:40

by Philippe Reynes

[permalink] [raw]
Subject: [PATCH 1/4] apf27: enable Ethernet PHY

At startup the Ethernet PHY is in power down mode, so we need
to force the "all capable" mode to activate it.

Signed-off-by: Philippe Reynes <[email protected]>
---
arch/arm/mach-imx/imx27-dt.c | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-imx/imx27-dt.c b/arch/arm/mach-imx/imx27-dt.c
index e80d523..f212f81 100644
--- a/arch/arm/mach-imx/imx27-dt.c
+++ b/arch/arm/mach-imx/imx27-dt.c
@@ -12,6 +12,8 @@
#include <linux/irq.h>
#include <linux/of_irq.h>
#include <linux/of_platform.h>
+#include <linux/delay.h>
+#include <linux/phy.h>
#include <asm/mach/arch.h>
#include <asm/mach/time.h>
#include <mach/common.h>
@@ -32,8 +34,27 @@ static const struct of_dev_auxdata imx27_auxdata_lookup[] __initconst = {
{ /* sentinel */ }
};

+int apf27_lan8700_wakeup(struct phy_device *phydev)
+{
+ int rc = phy_read(phydev, MII_DCOUNTER);
+
+ phy_write(phydev, MII_DCOUNTER, rc | 0xE0);
+ phy_write(phydev, MII_BMCR, BMCR_RESET);
+ udelay(1000);
+
+ return 0;
+}
+
+static void __init apf27_init(void)
+{
+ phy_register_fixup_for_id("imx27-fec.0-1:1f", apf27_lan8700_wakeup);
+}
+
static void __init imx27_dt_init(void)
{
+ if (of_machine_is_compatible("armadeus,imx27-apf27"))
+ apf27_init();
+
of_platform_populate(NULL, of_default_bus_match_table,
imx27_auxdata_lookup, NULL);
}
--
1.7.4.4

2012-11-25 20:17:47

by Philippe Reynes

[permalink] [raw]
Subject: [PATCH 3/4] imx27-dt: configure i2c1 gpio on armadeus apf27

Signed-off-by: Philippe Reynes <[email protected]>
---
arch/arm/mach-imx/imx27-dt.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-imx/imx27-dt.c b/arch/arm/mach-imx/imx27-dt.c
index f212f81..2eb7014 100644
--- a/arch/arm/mach-imx/imx27-dt.c
+++ b/arch/arm/mach-imx/imx27-dt.c
@@ -17,6 +17,7 @@
#include <asm/mach/arch.h>
#include <asm/mach/time.h>
#include <mach/common.h>
+#include <mach/iomux-mx27.h>
#include <mach/mx27.h>

static const struct of_dev_auxdata imx27_auxdata_lookup[] __initconst = {
@@ -48,6 +49,10 @@ int apf27_lan8700_wakeup(struct phy_device *phydev)
static void __init apf27_init(void)
{
phy_register_fixup_for_id("imx27-fec.0-1:1f", apf27_lan8700_wakeup);
+
+ /* configure i2c1 gpio */
+ mxc_gpio_mode((GPIO_PORTD | GPIO_OUT | GPIO_PF | 17));
+ mxc_gpio_mode((GPIO_PORTD | GPIO_OUT | GPIO_PF | 18));
}

static void __init imx27_dt_init(void)
--
1.7.4.4

2012-11-25 20:17:43

by Philippe Reynes

[permalink] [raw]
Subject: [PATCH 2/4] ds1374: add support of device tree

Signed-off-by: Philippe Reynes <[email protected]>
---
drivers/rtc/rtc-ds1374.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
index 9663160..174c532 100644
--- a/drivers/rtc/rtc-ds1374.c
+++ b/drivers/rtc/rtc-ds1374.c
@@ -49,6 +49,14 @@ static const struct i2c_device_id ds1374_id[] = {
};
MODULE_DEVICE_TABLE(i2c, ds1374_id);

+#ifdef CONFIG_OF
+static const struct of_device_id ds1374_of_match[] __devinitconst = {
+ { .compatible = "dallas,ds1374" },
+ {}
+};
+MODULE_DEVICE_TABLE(of, ds1374_of_match);
+#endif
+
struct ds1374 {
struct i2c_client *client;
struct rtc_device *rtc;
--
1.7.4.4

2012-11-25 20:17:53

by Philippe Reynes

[permalink] [raw]
Subject: [PATCH 4/4] apf27: add rtc ds1374 to the device tree

Signed-off-by: Philippe Reynes <[email protected]>
---
arch/arm/boot/dts/imx27-apf27.dts | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/imx27-apf27.dts b/arch/arm/boot/dts/imx27-apf27.dts
index c0327c0..20b8ef2 100644
--- a/arch/arm/boot/dts/imx27-apf27.dts
+++ b/arch/arm/boot/dts/imx27-apf27.dts
@@ -42,6 +42,16 @@
ethernet@1002b000 {
status = "okay";
};
+
+ i2c1: i2c@10012000 {
+ clock-frequency = <400000>;
+ status = "okay";
+
+ rtc@68 {
+ compatible = "dallas,ds1374";
+ reg = <0x68>;
+ };
+ };
};

nand@d8000000 {
--
1.7.4.4

2012-11-26 09:08:35

by Thomas Petazzoni

[permalink] [raw]
Subject: Re: [PATCH 2/4] ds1374: add support of device tree

Dear Philippe Reynes,

On Sun, 25 Nov 2012 21:17:03 +0100, Philippe Reynes wrote:
> Signed-off-by: Philippe Reynes <[email protected]>
> ---
> drivers/rtc/rtc-ds1374.c | 8 ++++++++
> 1 files changed, 8 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
> index 9663160..174c532 100644
> --- a/drivers/rtc/rtc-ds1374.c
> +++ b/drivers/rtc/rtc-ds1374.c
> @@ -49,6 +49,14 @@ static const struct i2c_device_id ds1374_id[] = {
> };
> MODULE_DEVICE_TABLE(i2c, ds1374_id);
>
> +#ifdef CONFIG_OF
> +static const struct of_device_id ds1374_of_match[] __devinitconst = {
> + { .compatible = "dallas,ds1374" },
> + {}
> +};
> +MODULE_DEVICE_TABLE(of, ds1374_of_match);
> +#endif
> +

Don't we need a Device Tree binding documentation in
Documentation/devicetree/bindings/rtc/ ?

Thomas
--
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

2012-11-26 09:29:13

by Thomas Petazzoni

[permalink] [raw]
Subject: Re: [PATCH 3/4] imx27-dt: configure i2c1 gpio on armadeus apf27

Dear Philippe Reynes,

On Sun, 25 Nov 2012 21:17:04 +0100, Philippe Reynes wrote:

> static const struct of_dev_auxdata imx27_auxdata_lookup[] __initconst = {
> @@ -48,6 +49,10 @@ int apf27_lan8700_wakeup(struct phy_device *phydev)
> static void __init apf27_init(void)
> {
> phy_register_fixup_for_id("imx27-fec.0-1:1f", apf27_lan8700_wakeup);
> +
> + /* configure i2c1 gpio */
> + mxc_gpio_mode((GPIO_PORTD | GPIO_OUT | GPIO_PF | 17));
> + mxc_gpio_mode((GPIO_PORTD | GPIO_OUT | GPIO_PF | 18));
> }

I haven't followed i.MX 27 support lately, but this surely should be
done using a pinctrl driver. I see that there is a general pinctrl
driver for i.MX, but a drivers/pinctrl/pinctrl-imx27.c might be
missing. It would probably be a better idea to implement the missing
pinctrl driver, if not already available?

Best regards,

Thomas
--
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

2012-11-26 10:00:00

by Sascha Hauer

[permalink] [raw]
Subject: Re: [PATCH 3/4] imx27-dt: configure i2c1 gpio on armadeus apf27

On Mon, Nov 26, 2012 at 10:28:58AM +0100, Thomas Petazzoni wrote:
> Dear Philippe Reynes,
>
> On Sun, 25 Nov 2012 21:17:04 +0100, Philippe Reynes wrote:
>
> > static const struct of_dev_auxdata imx27_auxdata_lookup[] __initconst = {
> > @@ -48,6 +49,10 @@ int apf27_lan8700_wakeup(struct phy_device *phydev)
> > static void __init apf27_init(void)
> > {
> > phy_register_fixup_for_id("imx27-fec.0-1:1f", apf27_lan8700_wakeup);
> > +
> > + /* configure i2c1 gpio */
> > + mxc_gpio_mode((GPIO_PORTD | GPIO_OUT | GPIO_PF | 17));
> > + mxc_gpio_mode((GPIO_PORTD | GPIO_OUT | GPIO_PF | 18));
> > }
>
> I haven't followed i.MX 27 support lately, but this surely should be
> done using a pinctrl driver. I see that there is a general pinctrl
> driver for i.MX, but a drivers/pinctrl/pinctrl-imx27.c might be
> missing. It would probably be a better idea to implement the missing
> pinctrl driver, if not already available?

It's not available, and yes, it should be implemented. Adding the iomux
setup to a i.MX27 SoC specific file is not a good idea.

Sascha

--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |