[PATCH] ARM: mxs/mx28evk: add flexcan devices
Subsystems:
arm port , the rest
STALE5644d
8 messages,
3 authors,
2011-03-02 · open the first message on its own page
Signed-off-by: Shawn Guo <redacted>
---
arch/arm/mach-mxs/Kconfig | 1 +
arch/arm/mach-mxs/mach-mx28evk.c | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-mxs/Kconfig b/arch/arm/mach-mxs/Kconfig
index 55bf075..9a1f2cb 100644
--- a/arch/arm/mach-mxs/Kconfig
+++ b/arch/arm/mach-mxs/Kconfig @@ -31,6 +31,7 @@ config MACH_MX28EVK
select MXS_HAVE_AMBA_DUART
select MXS_HAVE_PLATFORM_AUART
select MXS_HAVE_PLATFORM_FEC
+ select MXS_HAVE_PLATFORM_FLEXCAN
select MXS_OCOTP
default y
help diff --git a/arch/arm/mach-mxs/mach-mx28evk.c b/arch/arm/mach-mxs/mach-mx28evk.c
index 1f0b708..3cefb73 100644
--- a/arch/arm/mach-mxs/mach-mx28evk.c
+++ b/arch/arm/mach-mxs/mach-mx28evk.c @@ -28,6 +28,7 @@
#include "devices-mx28.h"
#include "gpio.h"
+ #define MX28EVK_FLEXCAN_SWITCH MXS_GPIO_NR(2, 13)
#define MX28EVK_FEC_PHY_POWER MXS_GPIO_NR(2, 15)
#define MX28EVK_FEC_PHY_RESET MXS_GPIO_NR(4, 13)
@@ -95,6 +96,15 @@ static const iomux_cfg_t mx28evk_pads[] __initconst = {
/* phy reset line */
MX28_PAD_ENET0_RX_CLK__GPIO_4_13 |
( MXS_PAD_4MA | MXS_PAD_3V3 | MXS_PAD_NOPULL ),
+
+ /* flexcan0 */
+ MX28_PAD_GPMI_RDY2__CAN0_TX ,
+ MX28_PAD_GPMI_RDY3__CAN0_RX ,
+ /* flexcan1 */
+ MX28_PAD_GPMI_CE2N__CAN1_TX ,
+ MX28_PAD_GPMI_CE3N__CAN1_RX ,
+ /* transceiver power control */
+ MX28_PAD_SSP1_CMD__GPIO_2_13 ,
};
/* fec */ @@ -178,8 +188,28 @@ error:
return - ETIMEDOUT ;
}
+ /* flexcan */
+ static void mx28evk_flexcan_switch ( int enable )
+ {
+ static int count ;
+
+ if ( enable ) {
+ if ( ! count ++ )
+ gpio_set_value ( MX28EVK_FLEXCAN_SWITCH , 1 );
+ } else {
+ if ( !-- count )
+ gpio_set_value ( MX28EVK_FLEXCAN_SWITCH , 0 );
+ }
+ }
+
+ static const struct flexcan_platform_data mx28evk_flexcan_pdata __initconst = {
+ . transceiver_switch = mx28evk_flexcan_switch ,
+ };
+
static void __init mx28evk_init ( void )
{
+ int ret ;
+
mxs_iomux_setup_multiple_pads ( mx28evk_pads , ARRAY_SIZE ( mx28evk_pads ));
mx28_add_duart (); @@ -192,6 +222,13 @@ static void __init mx28evk_init(void)
mx28evk_fec_reset ();
mx28_add_fec ( 0 , & mx28_fec_pdata [ 0 ]);
mx28_add_fec ( 1 , & mx28_fec_pdata [ 1 ]);
+
+ ret = gpio_request_one ( MX28EVK_FLEXCAN_SWITCH , GPIOF_DIR_OUT ,
+ "flexcan-switch" );
+ if ( ret )
+ pr_warn ( "failed to request gpio flexcan-switch: %d \n " , ret );
+ mx28_add_flexcan ( 0 , & mx28evk_flexcan_pdata );
+ mx28_add_flexcan ( 1 , & mx28evk_flexcan_pdata );
}
static void __init mx28evk_timer_init ( void ) --
1.7.1
Hi Shawn,
On Wed, Mar 02, 2011 at 06:54:44PM +0800, Shawn Guo wrote: quoted hunk Signed-off-by: Shawn Guo <redacted>
---
arch/arm/mach-mxs/Kconfig | 1 +
arch/arm/mach-mxs/mach-mx28evk.c | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-mxs/Kconfig b/arch/arm/mach-mxs/Kconfig
index 55bf075..9a1f2cb 100644
--- a/arch/arm/mach-mxs/Kconfig
+++ b/arch/arm/mach-mxs/Kconfig @@ -31,6 +31,7 @@ config MACH_MX28EVK
select MXS_HAVE_AMBA_DUART
select MXS_HAVE_PLATFORM_AUART
select MXS_HAVE_PLATFORM_FEC
+ select MXS_HAVE_PLATFORM_FLEXCAN
select MXS_OCOTP
default y
help diff --git a/arch/arm/mach-mxs/mach-mx28evk.c b/arch/arm/mach-mxs/mach-mx28evk.c
index 1f0b708..3cefb73 100644
--- a/arch/arm/mach-mxs/mach-mx28evk.c
+++ b/arch/arm/mach-mxs/mach-mx28evk.c @@ -28,6 +28,7 @@
#include "devices-mx28.h"
#include "gpio.h"
+ #define MX28EVK_FLEXCAN_SWITCH MXS_GPIO_NR(2, 13)
#define MX28EVK_FEC_PHY_POWER MXS_GPIO_NR(2, 15)
#define MX28EVK_FEC_PHY_RESET MXS_GPIO_NR(4, 13)
@@ -95,6 +96,15 @@ static const iomux_cfg_t mx28evk_pads[] __initconst = {
/* phy reset line */
MX28_PAD_ENET0_RX_CLK__GPIO_4_13 |
( MXS_PAD_4MA | MXS_PAD_3V3 | MXS_PAD_NOPULL ),
+
+ /* flexcan0 */
+ MX28_PAD_GPMI_RDY2__CAN0_TX ,
+ MX28_PAD_GPMI_RDY3__CAN0_RX ,
+ /* flexcan1 */
+ MX28_PAD_GPMI_CE2N__CAN1_TX ,
+ MX28_PAD_GPMI_CE3N__CAN1_RX ,
+ /* transceiver power control */
+ MX28_PAD_SSP1_CMD__GPIO_2_13 ,
};
/* fec */ @@ -178,8 +188,28 @@ error:
return - ETIMEDOUT ;
}
+ /* flexcan */
+ static void mx28evk_flexcan_switch ( int enable )
+ {
+ static int count ;
+
+ if ( enable ) {
+ if ( ! count ++ )
+ gpio_set_value ( MX28EVK_FLEXCAN_SWITCH , 1 );
+ } else {
+ if ( !-- count )
+ gpio_set_value ( MX28EVK_FLEXCAN_SWITCH , 0 );
+ }
+ }
Why this count variable? It shouldn't hurt to call gpio_set_value
multiple times.
Sascha
quoted hunk +
+static const struct flexcan_platform_data mx28evk_flexcan_pdata __initconst = {
+ .transceiver_switch = mx28evk_flexcan_switch,
+};
+
static void __init mx28evk_init(void)
{
+ int ret;
+
mxs_iomux_setup_multiple_pads(mx28evk_pads, ARRAY_SIZE(mx28evk_pads));
mx28_add_duart(); @@ -192,6 +222,13 @@ static void __init mx28evk_init(void)
mx28evk_fec_reset();
mx28_add_fec(0, &mx28_fec_pdata[0]);
mx28_add_fec(1, &mx28_fec_pdata[1]);
+
+ ret = gpio_request_one(MX28EVK_FLEXCAN_SWITCH, GPIOF_DIR_OUT,
+ "flexcan-switch");
+ if (ret)
+ pr_warn("failed to request gpio flexcan-switch: %d\n", ret);
+ mx28_add_flexcan(0, &mx28evk_flexcan_pdata);
+ mx28_add_flexcan(1, &mx28evk_flexcan_pdata);
}
static void __init mx28evk_timer_init(void) --
1.7.1
--
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 |
On Wed, Mar 02, 2011 at 12:11:48PM +0100, Sascha Hauer wrote: Hi Shawn, Hi Sascha,
On Wed, Mar 02, 2011 at 06:54:44PM +0800, Shawn Guo wrote: quoted Signed-off-by: Shawn Guo <redacted>
---
arch/arm/mach-mxs/Kconfig | 1 +
arch/arm/mach-mxs/mach-mx28evk.c | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-mxs/Kconfig b/arch/arm/mach-mxs/Kconfig
index 55bf075..9a1f2cb 100644
--- a/arch/arm/mach-mxs/Kconfig
+++ b/arch/arm/mach-mxs/Kconfig @@ -31,6 +31,7 @@ config MACH_MX28EVK
select MXS_HAVE_AMBA_DUART
select MXS_HAVE_PLATFORM_AUART
select MXS_HAVE_PLATFORM_FEC
+ select MXS_HAVE_PLATFORM_FLEXCAN
select MXS_OCOTP
default y
help diff --git a/arch/arm/mach-mxs/mach-mx28evk.c b/arch/arm/mach-mxs/mach-mx28evk.c
index 1f0b708..3cefb73 100644
--- a/arch/arm/mach-mxs/mach-mx28evk.c
+++ b/arch/arm/mach-mxs/mach-mx28evk.c @@ -28,6 +28,7 @@
#include "devices-mx28.h"
#include "gpio.h"
+ #define MX28EVK_FLEXCAN_SWITCH MXS_GPIO_NR(2, 13)
#define MX28EVK_FEC_PHY_POWER MXS_GPIO_NR(2, 15)
#define MX28EVK_FEC_PHY_RESET MXS_GPIO_NR(4, 13)
@@ -95,6 +96,15 @@ static const iomux_cfg_t mx28evk_pads[] __initconst = {
/* phy reset line */
MX28_PAD_ENET0_RX_CLK__GPIO_4_13 |
( MXS_PAD_4MA | MXS_PAD_3V3 | MXS_PAD_NOPULL ),
+
+ /* flexcan0 */
+ MX28_PAD_GPMI_RDY2__CAN0_TX ,
+ MX28_PAD_GPMI_RDY3__CAN0_RX ,
+ /* flexcan1 */
+ MX28_PAD_GPMI_CE2N__CAN1_TX ,
+ MX28_PAD_GPMI_CE3N__CAN1_RX ,
+ /* transceiver power control */
+ MX28_PAD_SSP1_CMD__GPIO_2_13 ,
};
/* fec */ @@ -178,8 +188,28 @@ error:
return - ETIMEDOUT ;
}
+ /* flexcan */
+ static void mx28evk_flexcan_switch ( int enable )
+ {
+ static int count ;
+
+ if ( enable ) {
+ if ( ! count ++ )
+ gpio_set_value ( MX28EVK_FLEXCAN_SWITCH , 1 );
+ } else {
+ if ( !-- count )
+ gpio_set_value ( MX28EVK_FLEXCAN_SWITCH , 0 );
+ }
+ }
Why this count variable? It shouldn't hurt to call gpio_set_value
multiple times. This gpio controls the power of both flexcan0 and flexcan1
transceivers, and we do not want one power-off really shut the power
down if the other is still on.
--
Regards,
Shawn
On Wed, Mar 02, 2011 at 07:45:50PM +0800, Shawn Guo wrote: On Wed, Mar 02, 2011 at 12:11:48PM +0100, Sascha Hauer wrote: quoted Hi Shawn, Hi Sascha,
quoted On Wed, Mar 02, 2011 at 06:54:44PM +0800, Shawn Guo wrote: quoted Signed-off-by: Shawn Guo <redacted>
---
arch/arm/mach-mxs/Kconfig | 1 +
arch/arm/mach-mxs/mach-mx28evk.c | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-mxs/Kconfig b/arch/arm/mach-mxs/Kconfig
index 55bf075..9a1f2cb 100644
--- a/arch/arm/mach-mxs/Kconfig
+++ b/arch/arm/mach-mxs/Kconfig @@ -31,6 +31,7 @@ config MACH_MX28EVK
select MXS_HAVE_AMBA_DUART
select MXS_HAVE_PLATFORM_AUART
select MXS_HAVE_PLATFORM_FEC
+ select MXS_HAVE_PLATFORM_FLEXCAN
select MXS_OCOTP
default y
help diff --git a/arch/arm/mach-mxs/mach-mx28evk.c b/arch/arm/mach-mxs/mach-mx28evk.c
index 1f0b708..3cefb73 100644
--- a/arch/arm/mach-mxs/mach-mx28evk.c
+++ b/arch/arm/mach-mxs/mach-mx28evk.c @@ -28,6 +28,7 @@
#include "devices-mx28.h"
#include "gpio.h"
+ #define MX28EVK_FLEXCAN_SWITCH MXS_GPIO_NR(2, 13)
#define MX28EVK_FEC_PHY_POWER MXS_GPIO_NR(2, 15)
#define MX28EVK_FEC_PHY_RESET MXS_GPIO_NR(4, 13)
@@ -95,6 +96,15 @@ static const iomux_cfg_t mx28evk_pads[] __initconst = {
/* phy reset line */
MX28_PAD_ENET0_RX_CLK__GPIO_4_13 |
( MXS_PAD_4MA | MXS_PAD_3V3 | MXS_PAD_NOPULL ),
+
+ /* flexcan0 */
+ MX28_PAD_GPMI_RDY2__CAN0_TX ,
+ MX28_PAD_GPMI_RDY3__CAN0_RX ,
+ /* flexcan1 */
+ MX28_PAD_GPMI_CE2N__CAN1_TX ,
+ MX28_PAD_GPMI_CE3N__CAN1_RX ,
+ /* transceiver power control */
+ MX28_PAD_SSP1_CMD__GPIO_2_13 ,
};
/* fec */ @@ -178,8 +188,28 @@ error:
return - ETIMEDOUT ;
}
+ /* flexcan */
+ static void mx28evk_flexcan_switch ( int enable )
+ {
+ static int count ;
+
+ if ( enable ) {
+ if ( ! count ++ )
+ gpio_set_value ( MX28EVK_FLEXCAN_SWITCH , 1 );
+ } else {
+ if ( !-- count )
+ gpio_set_value ( MX28EVK_FLEXCAN_SWITCH , 0 );
+ }
+ }
Why this count variable? It shouldn't hurt to call gpio_set_value
multiple times. This gpio controls the power of both flexcan0 and flexcan1
transceivers, and we do not want one power-off really shut the power
down if the other is still on.
Ok, I see. You should add a comment making this clear. Or maybe even
better, add a switch function for each controller and do the actual
switching based on "both off" instead of a counter. This even will
work when the flexcan driver has unbalanced switch calls.
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 |
On Wed, Mar 02, 2011 at 07:45:50PM +0800, Shawn Guo wrote: On Wed, Mar 02, 2011 at 12:11:48PM +0100, Sascha Hauer wrote: quoted Hi Shawn, Hi Sascha,
quoted On Wed, Mar 02, 2011 at 06:54:44PM +0800, Shawn Guo wrote: quoted Signed-off-by: Shawn Guo <redacted>
---
arch/arm/mach-mxs/Kconfig | 1 +
arch/arm/mach-mxs/mach-mx28evk.c | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-mxs/Kconfig b/arch/arm/mach-mxs/Kconfig
index 55bf075..9a1f2cb 100644
--- a/arch/arm/mach-mxs/Kconfig
+++ b/arch/arm/mach-mxs/Kconfig @@ -31,6 +31,7 @@ config MACH_MX28EVK
select MXS_HAVE_AMBA_DUART
select MXS_HAVE_PLATFORM_AUART
select MXS_HAVE_PLATFORM_FEC
+ select MXS_HAVE_PLATFORM_FLEXCAN
select MXS_OCOTP
default y
help diff --git a/arch/arm/mach-mxs/mach-mx28evk.c b/arch/arm/mach-mxs/mach-mx28evk.c
index 1f0b708..3cefb73 100644
--- a/arch/arm/mach-mxs/mach-mx28evk.c
+++ b/arch/arm/mach-mxs/mach-mx28evk.c @@ -28,6 +28,7 @@
#include "devices-mx28.h"
#include "gpio.h"
+ #define MX28EVK_FLEXCAN_SWITCH MXS_GPIO_NR(2, 13)
#define MX28EVK_FEC_PHY_POWER MXS_GPIO_NR(2, 15)
#define MX28EVK_FEC_PHY_RESET MXS_GPIO_NR(4, 13)
@@ -95,6 +96,15 @@ static const iomux_cfg_t mx28evk_pads[] __initconst = {
/* phy reset line */
MX28_PAD_ENET0_RX_CLK__GPIO_4_13 |
( MXS_PAD_4MA | MXS_PAD_3V3 | MXS_PAD_NOPULL ),
+
+ /* flexcan0 */
+ MX28_PAD_GPMI_RDY2__CAN0_TX ,
+ MX28_PAD_GPMI_RDY3__CAN0_RX ,
+ /* flexcan1 */
+ MX28_PAD_GPMI_CE2N__CAN1_TX ,
+ MX28_PAD_GPMI_CE3N__CAN1_RX ,
+ /* transceiver power control */
+ MX28_PAD_SSP1_CMD__GPIO_2_13 ,
};
/* fec */ @@ -178,8 +188,28 @@ error:
return - ETIMEDOUT ;
}
+ /* flexcan */
+ static void mx28evk_flexcan_switch ( int enable )
+ {
+ static int count ;
+
+ if ( enable ) {
+ if ( ! count ++ )
+ gpio_set_value ( MX28EVK_FLEXCAN_SWITCH , 1 );
+ } else {
+ if ( !-- count )
+ gpio_set_value ( MX28EVK_FLEXCAN_SWITCH , 0 );
+ }
+ }
Why this count variable? It shouldn't hurt to call gpio_set_value
multiple times. Something like this?
/*
* On mx28evk board, two flexcan transceivers are controlled
* by one power switch gpio.
*/
#define FLEXCAN0_SWITCH_ON (1 << 0)
#define FLEXCAN1_SWITCH_ON (1 << 1)
static int flexcan_switch_on;
static void mx28evk_flexcan0_switch(int enable)
{
if (enable) {
flexcan_switch_on |= FLEXCAN0_SWITCH_ON;
gpio_set_value(MX28EVK_FLEXCAN_SWITCH, 1);
} else {
flexcan_switch_on &= ~FLEXCAN0_SWITCH_ON;
if (!flexcan_switch_on)
gpio_set_value(MX28EVK_FLEXCAN_SWITCH, 0);
}
}
static void mx28evk_flexcan1_switch(int enable)
{
if (enable) {
flexcan_switch_on |= FLEXCAN1_SWITCH_ON;
gpio_set_value(MX28EVK_FLEXCAN_SWITCH, 1);
} else {
flexcan_switch_on &= ~FLEXCAN1_SWITCH_ON;
if (!flexcan_switch_on)
gpio_set_value(MX28EVK_FLEXCAN_SWITCH, 0);
}
}
static const struct flexcan_platform_data
mx28evk_flexcan_pdata[] __initconst = {
{
.transceiver_switch = mx28evk_flexcan0_switch,
}, {
.transceiver_switch = mx28evk_flexcan1_switch,
}
};
--
Regards,
Shawn
Hello,
On Wed, Mar 02, 2011 at 06:54:44PM +0800, Shawn Guo wrote: quoted hunk Signed-off-by: Shawn Guo <redacted>
---
arch/arm/mach-mxs/Kconfig | 1 +
arch/arm/mach-mxs/mach-mx28evk.c | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-mxs/Kconfig b/arch/arm/mach-mxs/Kconfig
index 55bf075..9a1f2cb 100644
--- a/arch/arm/mach-mxs/Kconfig
+++ b/arch/arm/mach-mxs/Kconfig @@ -31,6 +31,7 @@ config MACH_MX28EVK
select MXS_HAVE_AMBA_DUART
select MXS_HAVE_PLATFORM_AUART
select MXS_HAVE_PLATFORM_FEC
+ select MXS_HAVE_PLATFORM_FLEXCAN
select MXS_OCOTP
default y
help diff --git a/arch/arm/mach-mxs/mach-mx28evk.c b/arch/arm/mach-mxs/mach-mx28evk.c
index 1f0b708..3cefb73 100644
--- a/arch/arm/mach-mxs/mach-mx28evk.c
+++ b/arch/arm/mach-mxs/mach-mx28evk.c @@ -28,6 +28,7 @@
#include "devices-mx28.h"
#include "gpio.h"
+ #define MX28EVK_FLEXCAN_SWITCH MXS_GPIO_NR(2, 13)
#define MX28EVK_FEC_PHY_POWER MXS_GPIO_NR(2, 15)
#define MX28EVK_FEC_PHY_RESET MXS_GPIO_NR(4, 13)
@@ -95,6 +96,15 @@ static const iomux_cfg_t mx28evk_pads[] __initconst = {
/* phy reset line */
MX28_PAD_ENET0_RX_CLK__GPIO_4_13 |
( MXS_PAD_4MA | MXS_PAD_3V3 | MXS_PAD_NOPULL ),
+
+ /* flexcan0 */
+ MX28_PAD_GPMI_RDY2__CAN0_TX ,
+ MX28_PAD_GPMI_RDY3__CAN0_RX ,
+ /* flexcan1 */
+ MX28_PAD_GPMI_CE2N__CAN1_TX ,
+ MX28_PAD_GPMI_CE3N__CAN1_RX ,
+ /* transceiver power control */
+ MX28_PAD_SSP1_CMD__GPIO_2_13 ,
};
/* fec */ @@ -178,8 +188,28 @@ error:
return - ETIMEDOUT ;
}
+ /* flexcan */
+ static void mx28evk_flexcan_switch ( int enable )
+ {
+ static int count ;
+
+ if ( enable ) {
+ if ( ! count ++ )
+ gpio_set_value ( MX28EVK_FLEXCAN_SWITCH , 1 );
+ } else {
+ if ( !-- count )
+ gpio_set_value ( MX28EVK_FLEXCAN_SWITCH , 0 );
+ }
+ }
+
+ static const struct flexcan_platform_data mx28evk_flexcan_pdata __initconst = {
+ . transceiver_switch = mx28evk_flexcan_switch ,
+ };
+
static void __init mx28evk_init ( void )
{
+ int ret ;
+
mxs_iomux_setup_multiple_pads ( mx28evk_pads , ARRAY_SIZE ( mx28evk_pads ));
mx28_add_duart (); @@ -192,6 +222,13 @@ static void __init mx28evk_init(void)
mx28evk_fec_reset ();
mx28_add_fec ( 0 , & mx28_fec_pdata [ 0 ]);
mx28_add_fec ( 1 , & mx28_fec_pdata [ 1 ]);
+
+ ret = gpio_request_one ( MX28EVK_FLEXCAN_SWITCH , GPIOF_DIR_OUT ,
+ "flexcan-switch" );
+ if ( ret )
+ pr_warn ( "failed to request gpio flexcan-switch: %d \n " , ret );
+ mx28_add_flexcan ( 0 , & mx28evk_flexcan_pdata );
+ mx28_add_flexcan ( 1 , & mx28evk_flexcan_pdata ); You must not add the flexcan devices if gpio_request failed. Otherwise
you use the gpio anyhow.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |
On Wed, Mar 02, 2011 at 02:14:25PM +0100, Uwe Kleine-K?nig wrote: Hello,
On Wed, Mar 02, 2011 at 06:54:44PM +0800, Shawn Guo wrote: quoted Signed-off-by: Shawn Guo <redacted>
---
arch/arm/mach-mxs/Kconfig | 1 +
arch/arm/mach-mxs/mach-mx28evk.c | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-mxs/Kconfig b/arch/arm/mach-mxs/Kconfig
index 55bf075..9a1f2cb 100644
--- a/arch/arm/mach-mxs/Kconfig
+++ b/arch/arm/mach-mxs/Kconfig @@ -31,6 +31,7 @@ config MACH_MX28EVK
select MXS_HAVE_AMBA_DUART
select MXS_HAVE_PLATFORM_AUART
select MXS_HAVE_PLATFORM_FEC
+ select MXS_HAVE_PLATFORM_FLEXCAN
select MXS_OCOTP
default y
help diff --git a/arch/arm/mach-mxs/mach-mx28evk.c b/arch/arm/mach-mxs/mach-mx28evk.c
index 1f0b708..3cefb73 100644
--- a/arch/arm/mach-mxs/mach-mx28evk.c
+++ b/arch/arm/mach-mxs/mach-mx28evk.c @@ -28,6 +28,7 @@
#include "devices-mx28.h"
#include "gpio.h"
+ #define MX28EVK_FLEXCAN_SWITCH MXS_GPIO_NR(2, 13)
#define MX28EVK_FEC_PHY_POWER MXS_GPIO_NR(2, 15)
#define MX28EVK_FEC_PHY_RESET MXS_GPIO_NR(4, 13)
@@ -95,6 +96,15 @@ static const iomux_cfg_t mx28evk_pads[] __initconst = {
/* phy reset line */
MX28_PAD_ENET0_RX_CLK__GPIO_4_13 |
( MXS_PAD_4MA | MXS_PAD_3V3 | MXS_PAD_NOPULL ),
+
+ /* flexcan0 */
+ MX28_PAD_GPMI_RDY2__CAN0_TX ,
+ MX28_PAD_GPMI_RDY3__CAN0_RX ,
+ /* flexcan1 */
+ MX28_PAD_GPMI_CE2N__CAN1_TX ,
+ MX28_PAD_GPMI_CE3N__CAN1_RX ,
+ /* transceiver power control */
+ MX28_PAD_SSP1_CMD__GPIO_2_13 ,
};
/* fec */ @@ -178,8 +188,28 @@ error:
return - ETIMEDOUT ;
}
+ /* flexcan */
+ static void mx28evk_flexcan_switch ( int enable )
+ {
+ static int count ;
+
+ if ( enable ) {
+ if ( ! count ++ )
+ gpio_set_value ( MX28EVK_FLEXCAN_SWITCH , 1 );
+ } else {
+ if ( !-- count )
+ gpio_set_value ( MX28EVK_FLEXCAN_SWITCH , 0 );
+ }
+ }
+
+ static const struct flexcan_platform_data mx28evk_flexcan_pdata __initconst = {
+ . transceiver_switch = mx28evk_flexcan_switch ,
+ };
+
static void __init mx28evk_init ( void )
{
+ int ret ;
+
mxs_iomux_setup_multiple_pads ( mx28evk_pads , ARRAY_SIZE ( mx28evk_pads ));
mx28_add_duart (); @@ -192,6 +222,13 @@ static void __init mx28evk_init(void)
mx28evk_fec_reset ();
mx28_add_fec ( 0 , & mx28_fec_pdata [ 0 ]);
mx28_add_fec ( 1 , & mx28_fec_pdata [ 1 ]);
+
+ ret = gpio_request_one ( MX28EVK_FLEXCAN_SWITCH , GPIOF_DIR_OUT ,
+ "flexcan-switch" );
+ if ( ret )
+ pr_warn ( "failed to request gpio flexcan-switch: %d \n " , ret );
+ mx28_add_flexcan ( 0 , & mx28evk_flexcan_pdata );
+ mx28_add_flexcan ( 1 , & mx28evk_flexcan_pdata ); You must not add the flexcan devices if gpio_request failed. Otherwise
you use the gpio anyhow. Ah, yes.
--
Regards,
Shawn
On Wed, Mar 02, 2011 at 08:55:25PM +0800, Shawn Guo wrote: On Wed, Mar 02, 2011 at 07:45:50PM +0800, Shawn Guo wrote: quoted On Wed, Mar 02, 2011 at 12:11:48PM +0100, Sascha Hauer wrote: quoted Hi Shawn, Hi Sascha,
quoted On Wed, Mar 02, 2011 at 06:54:44PM +0800, Shawn Guo wrote: quoted Signed-off-by: Shawn Guo <redacted>
---
arch/arm/mach-mxs/Kconfig | 1 +
arch/arm/mach-mxs/mach-mx28evk.c | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-mxs/Kconfig b/arch/arm/mach-mxs/Kconfig
index 55bf075..9a1f2cb 100644
--- a/arch/arm/mach-mxs/Kconfig
+++ b/arch/arm/mach-mxs/Kconfig @@ -31,6 +31,7 @@ config MACH_MX28EVK
select MXS_HAVE_AMBA_DUART
select MXS_HAVE_PLATFORM_AUART
select MXS_HAVE_PLATFORM_FEC
+ select MXS_HAVE_PLATFORM_FLEXCAN
select MXS_OCOTP
default y
help diff --git a/arch/arm/mach-mxs/mach-mx28evk.c b/arch/arm/mach-mxs/mach-mx28evk.c
index 1f0b708..3cefb73 100644
--- a/arch/arm/mach-mxs/mach-mx28evk.c
+++ b/arch/arm/mach-mxs/mach-mx28evk.c @@ -28,6 +28,7 @@
#include "devices-mx28.h"
#include "gpio.h"
+ #define MX28EVK_FLEXCAN_SWITCH MXS_GPIO_NR(2, 13)
#define MX28EVK_FEC_PHY_POWER MXS_GPIO_NR(2, 15)
#define MX28EVK_FEC_PHY_RESET MXS_GPIO_NR(4, 13)
@@ -95,6 +96,15 @@ static const iomux_cfg_t mx28evk_pads[] __initconst = {
/* phy reset line */
MX28_PAD_ENET0_RX_CLK__GPIO_4_13 |
( MXS_PAD_4MA | MXS_PAD_3V3 | MXS_PAD_NOPULL ),
+
+ /* flexcan0 */
+ MX28_PAD_GPMI_RDY2__CAN0_TX ,
+ MX28_PAD_GPMI_RDY3__CAN0_RX ,
+ /* flexcan1 */
+ MX28_PAD_GPMI_CE2N__CAN1_TX ,
+ MX28_PAD_GPMI_CE3N__CAN1_RX ,
+ /* transceiver power control */
+ MX28_PAD_SSP1_CMD__GPIO_2_13 ,
};
/* fec */ @@ -178,8 +188,28 @@ error:
return - ETIMEDOUT ;
}
+ /* flexcan */
+ static void mx28evk_flexcan_switch ( int enable )
+ {
+ static int count ;
+
+ if ( enable ) {
+ if ( ! count ++ )
+ gpio_set_value ( MX28EVK_FLEXCAN_SWITCH , 1 );
+ } else {
+ if ( !-- count )
+ gpio_set_value ( MX28EVK_FLEXCAN_SWITCH , 0 );
+ }
+ }
Why this count variable? It shouldn't hurt to call gpio_set_value
multiple times. Something like this?
/*
* On mx28evk board, two flexcan transceivers are controlled
* by one power switch gpio.
*/
#define FLEXCAN0_SWITCH_ON (1 << 0)
#define FLEXCAN1_SWITCH_ON (1 << 1)
static int flexcan_switch_on;
static void mx28evk_flexcan0_switch(int enable)
{
if (enable) {
flexcan_switch_on |= FLEXCAN0_SWITCH_ON;
gpio_set_value(MX28EVK_FLEXCAN_SWITCH, 1);
} else {
flexcan_switch_on &= ~FLEXCAN0_SWITCH_ON;
if (!flexcan_switch_on)
gpio_set_value(MX28EVK_FLEXCAN_SWITCH, 0);
}
}
static void mx28evk_flexcan1_switch(int enable)
{
if (enable) {
flexcan_switch_on |= FLEXCAN1_SWITCH_ON;
gpio_set_value(MX28EVK_FLEXCAN_SWITCH, 1);
} else {
flexcan_switch_on &= ~FLEXCAN1_SWITCH_ON;
if (!flexcan_switch_on)
gpio_set_value(MX28EVK_FLEXCAN_SWITCH, 0);
}
}
static const struct flexcan_platform_data
mx28evk_flexcan_pdata[] __initconst = {
{
.transceiver_switch = mx28evk_flexcan0_switch,
}, {
.transceiver_switch = mx28evk_flexcan1_switch,
}
};
More like this, which is slightly easier to read, but the effect is the
same.
static int flexcan0_en, flexcan0_en;
/*
* MX28EVK_FLEXCAN_SWITCH is shared between both can controllers
*/
static void mx28evk_flexcan_switch(void)
{
if (flexcan0_en || flexcan1_en)
gpio_set_value(MX28EVK_FLEXCAN_SWITCH, 1);
else
gpio_set_value(MX28EVK_FLEXCAN_SWITCH, 0);
}
static void mx28evk_flexcan0_switch(int enable)
{
flexcan0_en = enable;
mx28evk_flexcan_switch();
}
static void mx28evk_flexcan1_switch(int enable)
{
flexcan1_en = enable;
mx28evk_flexcan_switch();
}
static const struct flexcan_platform_data
mx28evk_flexcan_pdata[] __initconst = {
{
.transceiver_switch = mx28evk_flexcan0_switch,
}, {
.transceiver_switch = mx28evk_flexcan1_switch,
}
};
--
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 |