public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: u.kleine-koenig@pengutronix.de (Uwe Kleine-König)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: mxs/mx28evk: add flexcan devices
Date: Wed, 2 Mar 2011 14:14:25 +0100	[thread overview]
Message-ID: <20110302131425.GD22310@pengutronix.de> (raw)
In-Reply-To: <1299063284-21795-1-git-send-email-shawn.guo@freescale.com>

Hello,

On Wed, Mar 02, 2011 at 06:54:44PM +0800, Shawn Guo wrote:
> Signed-off-by: Shawn Guo <shawn.guo@freescale.com>
> ---
>  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/  |

  parent reply	other threads:[~2011-03-02 13:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-02 10:54 [PATCH] ARM: mxs/mx28evk: add flexcan devices Shawn Guo
2011-03-02 11:11 ` Sascha Hauer
2011-03-02 11:45   ` Shawn Guo
2011-03-02 12:09     ` Sascha Hauer
2011-03-02 12:55     ` Shawn Guo
2011-03-02 13:51       ` Sascha Hauer
2011-03-02 13:14 ` Uwe Kleine-König [this message]
2011-03-02 13:19   ` Shawn Guo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110302131425.GD22310@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox