lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 09 Sep 2013 10:34:27 +0200
From:	Marc Kleine-Budde <mkl@...gutronix.de>
To:	Benedikt Spranger <b.spranger@...utronix.de>
CC:	netdev@...r.kernel.org,
	Alexander Frank <Alexander.Frank@...rspaecher.com>,
	Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
	Holger Dengler <dengler@...utronix.de>,
	AnilKumar Ch <anilkumar@...com>,
	"linux-can@...r.kernel.org" <linux-can@...r.kernel.org>
Subject: Re: [PATCH 02/16] c_can: add generic D-CAN RAM initialization support

On 09/09/2013 09:24 AM, Benedikt Spranger wrote:
> D-CAN provides an automatic RAM initialization. The initialization can be
> executed while D-CAN is in the init state.
> 
> It should be checked if this is compatible with TI's d_can implementation
> which does not have or does not use this bit which is here according to the
> d_can specification.

Added AnilKumar Ch to the loop, who contributed the d_can support for
TI. Bene please collect a Tested-by for this patch.

Marc

> Signed-off-by: Benedikt Spranger <b.spranger@...utronix.de>
> ---
>  drivers/net/can/c_can/c_can.c | 38 ++++++++++++++++++++++++++++++++++++--
>  drivers/net/can/c_can/c_can.h |  2 ++
>  2 files changed, 38 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
> index a668cd4..081620b 100644
> --- a/drivers/net/can/c_can/c_can.c
> +++ b/drivers/net/can/c_can/c_can.c
> @@ -68,6 +68,8 @@
>  #define TEST_SILENT		BIT(3)
>  #define TEST_BASIC		BIT(2)
>  
> +#define FUNC_RAMINIT		BIT(3)
> +
>  /* status register */
>  #define STATUS_PDA		BIT(10)
>  #define STATUS_BOFF		BIT(7)
> @@ -573,6 +575,7 @@ static int c_can_set_bittiming(struct net_device *dev)
>  	u32 ten_bit_brp;
>  	struct c_can_priv *priv = netdev_priv(dev);
>  	const struct can_bittiming *bt = &priv->can.bittiming;
> +	int retry;
>  
>  	/* c_can provides a 6-bit brp and 4-bit brpe fields */
>  	ten_bit_brp = bt->brp - 1;
> @@ -590,11 +593,42 @@ static int c_can_set_bittiming(struct net_device *dev)
>  		"setting BTR=%04x BRPE=%04x\n", reg_btr, reg_brpe);
>  
>  	ctrl_save = priv->read_reg(priv, C_CAN_CTRL_REG);
> -	priv->write_reg(priv, C_CAN_CTRL_REG,
> -			ctrl_save | CONTROL_CCE | CONTROL_INIT);
> +	ctrl_save &= ~CONTROL_INIT;
> +
> +	priv->write_reg(priv, C_CAN_CTRL_REG, CONTROL_CCE | CONTROL_INIT);
> +	retry = 1000;
> +	while (!(priv->read_reg(priv, C_CAN_CTRL_REG) & CONTROL_INIT)) {
> +		if (!retry) {
> +			netdev_info(dev, "CCTRL: set CONTROL_INIT failed\n");
> +			return -EIO;
> +		}
> +		udelay(10);
> +		retry--;
> +	}
>  	priv->write_reg(priv, C_CAN_BTR_REG, reg_btr);
>  	priv->write_reg(priv, C_CAN_BRPEXT_REG, reg_brpe);
> +
> +	priv->write_reg(priv, C_CAN_FUNC_REG, FUNC_RAMINIT);
> +	retry = 1000;
> +	while (priv->read_reg(priv, C_CAN_FUNC_REG) & FUNC_RAMINIT) {
> +		if (!retry) {
> +			netdev_info(dev, "CFR: FUNC_RAMINIT failed\n");
> +			return -EIO;
> +		}
> +		udelay(10);
> +		retry--;
> +	}
> +
>  	priv->write_reg(priv, C_CAN_CTRL_REG, ctrl_save);
> +	retry = 1000;
> +	while (priv->read_reg(priv, C_CAN_CTRL_REG) & CONTROL_INIT) {
> +		if (!retry) {
> +			netdev_info(dev, "CCTRL: clear CONTROL_INIT failed\n");
> +			return -EIO;
> +		}
> +		udelay(10);
> +		retry--;
> +	}
>  
>  	return 0;
>  }
> diff --git a/drivers/net/can/c_can/c_can.h b/drivers/net/can/c_can/c_can.h
> index d2e2d20..9f0eda8 100644
> --- a/drivers/net/can/c_can/c_can.h
> +++ b/drivers/net/can/c_can/c_can.h
> @@ -61,6 +61,7 @@ enum reg {
>  	C_CAN_INTPND2_REG,
>  	C_CAN_MSGVAL1_REG,
>  	C_CAN_MSGVAL2_REG,
> +	C_CAN_FUNC_REG,
>  };
>  
>  static const u16 reg_map_c_can[] = {
> @@ -112,6 +113,7 @@ static const u16 reg_map_d_can[] = {
>  	[C_CAN_BRPEXT_REG]	= 0x0E,
>  	[C_CAN_INT_REG]		= 0x10,
>  	[C_CAN_TEST_REG]	= 0x14,
> +	[C_CAN_FUNC_REG]	= 0x18,
>  	[C_CAN_TXRQST1_REG]	= 0x88,
>  	[C_CAN_TXRQST2_REG]	= 0x8A,
>  	[C_CAN_NEWDAT1_REG]	= 0x9C,
> 


-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


Download attachment "signature.asc" of type "application/pgp-signature" (260 bytes)

Powered by blists - more mailing lists