Yegor Yefremov wrote:
> I borrowed this code from LinCAN project. It helped me a lot by investigating
> the problem with memory access. I don't know if it is worth committing it to
> the repository, but it was nice to use it.
>
> Yegor
>
> diff --git a/drivers/net/can/sja1000/sja1000.c
> b/drivers/net/can/sja1000/sja1000.c
> index 145b1a7..86ef501 100644
> --- a/drivers/net/can/sja1000/sja1000.c
> +++ b/drivers/net/can/sja1000/sja1000.c
> @@ -229,6 +229,8 @@ static int sja1000_get_berr_counter(const struct
> net_device *dev,
> static void chipset_init(struct net_device *dev)
> {
> struct sja1000_priv *priv = netdev_priv(dev);
> + int i;
> + unsigned char n, r;
>
> /* set clock divider and output control register */
> priv->write_reg(priv, REG_CDR, priv->cdr | CDR_PELICAN);
> @@ -245,6 +247,18 @@ static void chipset_init(struct net_device *dev)
> priv->write_reg(priv, REG_ACCM3, 0xFF);
>
> priv->write_reg(priv, REG_OCR, priv->ocr | OCR_MODE_NORMAL);
> +
> + /* Simple check for chip presence */
> + for (i=0, n=0x5a; i<8; i++, n+=0xf) {
> + priv->write_reg(priv, REG_ACCC0 + i, n);
> + }
> + for (i=0, n=0x5a; i<8; i++, n+=0xf) {
> + r = n ^ priv->read_reg(priv, REG_ACCC0 + i);
> + if (r) {
> + printk("sja1000p_chip_config: chip connection broken,"
> + " readback differ 0x%02x\n", r);
> + }
> + }
> }
This would work on any memory location, right? The plx_pci driver does
have a proper chip identification out of the reset. But I'm not sure if
it's worth adding it.
Wolfgang.
_______________________________________________
Socketcan-core mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-core