mirror of
https://github.com/Dasharo/linux.git
synced 2026-03-06 15:25:10 -08:00
net/can: add driver for mscan family & mpc52xx_mscan
Taken from socketcan-svn, fixed remaining todos, cleaned up, tested with a phyCORE-MPC5200B-IO and a custom board. Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Cc: Wolfgang Grandegger <wg@grandegger.com> Cc: Grant Likely <grant.likely@secretlab.ca> Cc: David Miller <davem@davemloft.net> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
888801357f
commit
afa17a500a
@@ -178,3 +178,12 @@ External interrupts:
|
||||
external irq3: interrupts = <1 3 n>;
|
||||
'n' is sense (0: level high, 1: edge rising, 2: edge falling 3: level low)
|
||||
|
||||
fsl,mpc5200-mscan nodes
|
||||
-----------------------
|
||||
In addition to the required compatible-, reg- and interrupt-properites, you can
|
||||
also specify which clock shall be used for the bus:
|
||||
|
||||
- fsl,mscan-clk-src - a string describing the clock source. Valid values
|
||||
are "ip" for IP_CLK and "sys" for SYS_XTAL.
|
||||
"sys" is the default in case the property is not
|
||||
present.
|
||||
|
||||
@@ -108,6 +108,25 @@ config CAN_MCP251X
|
||||
---help---
|
||||
Driver for the Microchip MCP251x SPI CAN controllers.
|
||||
|
||||
config CAN_MSCAN
|
||||
depends on CAN_DEV && (PPC || M68K || M68KNOMMU)
|
||||
tristate "Support for Freescale MSCAN based chips"
|
||||
---help---
|
||||
The Motorola Scalable Controller Area Network (MSCAN) definition
|
||||
is based on the MSCAN12 definition which is the specific
|
||||
implementation of the Motorola Scalable CAN concept targeted for
|
||||
the Motorola MC68HC12 Microcontroller Family.
|
||||
|
||||
config CAN_MPC52XX
|
||||
tristate "Freescale MPC5xxx onboard CAN controller"
|
||||
depends on CAN_MSCAN && PPC_MPC52xx
|
||||
---help---
|
||||
If you say yes here you get support for Freescale's MPC52xx
|
||||
onboard dualCAN controller.
|
||||
|
||||
This driver can also be built as a module. If so, the module
|
||||
will be called mpc5xxx_can.
|
||||
|
||||
config CAN_DEBUG_DEVICES
|
||||
bool "CAN devices debugging messages"
|
||||
depends on CAN
|
||||
|
||||
@@ -10,6 +10,7 @@ can-dev-y := dev.o
|
||||
obj-y += usb/
|
||||
|
||||
obj-$(CONFIG_CAN_SJA1000) += sja1000/
|
||||
obj-$(CONFIG_CAN_MSCAN) += mscan/
|
||||
obj-$(CONFIG_CAN_AT91) += at91_can.o
|
||||
obj-$(CONFIG_CAN_TI_HECC) += ti_hecc.o
|
||||
obj-$(CONFIG_CAN_MCP251X) += mcp251x.o
|
||||
|
||||
5
drivers/net/can/mscan/Makefile
Normal file
5
drivers/net/can/mscan/Makefile
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
obj-$(CONFIG_CAN_MPC52XX) += mscan-mpc52xx.o
|
||||
mscan-mpc52xx-objs := mscan.o mpc52xx_can.o
|
||||
|
||||
ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG
|
||||
279
drivers/net/can/mscan/mpc52xx_can.c
Normal file
279
drivers/net/can/mscan/mpc52xx_can.c
Normal file
@@ -0,0 +1,279 @@
|
||||
/*
|
||||
* CAN bus driver for the Freescale MPC5xxx embedded CPU.
|
||||
*
|
||||
* Copyright (C) 2004-2005 Andrey Volkov <avolkov@varma-el.com>,
|
||||
* Varma Electronics Oy
|
||||
* Copyright (C) 2008-2009 Wolfgang Grandegger <wg@grandegger.com>
|
||||
* Copyright (C) 2009 Wolfram Sang, Pengutronix <w.sang@pengutronix.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the version 2 of the GNU General Public License
|
||||
* as published by the Free Software Foundation
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/can.h>
|
||||
#include <linux/can/dev.h>
|
||||
#include <linux/of_platform.h>
|
||||
#include <sysdev/fsl_soc.h>
|
||||
#include <linux/io.h>
|
||||
#include <asm/mpc52xx.h>
|
||||
|
||||
#include "mscan.h"
|
||||
|
||||
|
||||
#define DRV_NAME "mpc5xxx_can"
|
||||
|
||||
static struct of_device_id mpc52xx_cdm_ids[] __devinitdata = {
|
||||
{ .compatible = "fsl,mpc5200-cdm", },
|
||||
{ .compatible = "fsl,mpc5200b-cdm", },
|
||||
{}
|
||||
};
|
||||
|
||||
/*
|
||||
* Get the frequency of the external oscillator clock connected
|
||||
* to the SYS_XTAL_IN pin, or return 0 if it cannot be determined.
|
||||
*/
|
||||
static unsigned int __devinit mpc52xx_can_xtal_freq(struct of_device *of)
|
||||
{
|
||||
struct mpc52xx_cdm __iomem *cdm;
|
||||
struct device_node *np_cdm;
|
||||
unsigned int freq;
|
||||
u32 val;
|
||||
|
||||
freq = mpc5xxx_get_bus_frequency(of->node);
|
||||
if (!freq)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* Determine SYS_XTAL_IN frequency from the clock domain settings
|
||||
*/
|
||||
np_cdm = of_find_matching_node(NULL, mpc52xx_cdm_ids);
|
||||
if (!np_cdm) {
|
||||
dev_err(&of->dev, "can't get clock node!\n");
|
||||
return 0;
|
||||
}
|
||||
cdm = of_iomap(np_cdm, 0);
|
||||
of_node_put(np_cdm);
|
||||
|
||||
if (in_8(&cdm->ipb_clk_sel) & 0x1)
|
||||
freq *= 2;
|
||||
val = in_be32(&cdm->rstcfg);
|
||||
if (val & (1 << 5))
|
||||
freq *= 8;
|
||||
else
|
||||
freq *= 4;
|
||||
if (val & (1 << 6))
|
||||
freq /= 12;
|
||||
else
|
||||
freq /= 16;
|
||||
|
||||
iounmap(cdm);
|
||||
|
||||
return freq;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get frequency of the MSCAN clock source
|
||||
*
|
||||
* Either the oscillator clock (SYS_XTAL_IN) or the IP bus clock (IP_CLK)
|
||||
* can be selected. According to the MPC5200 user's manual, the oscillator
|
||||
* clock is the better choice as it has less jitter but due to a hardware
|
||||
* bug, it can not be selected for the old MPC5200 Rev. A chips.
|
||||
*/
|
||||
|
||||
static unsigned int __devinit mpc52xx_can_clock_freq(struct of_device *of,
|
||||
int clock_src)
|
||||
{
|
||||
unsigned int pvr;
|
||||
|
||||
pvr = mfspr(SPRN_PVR);
|
||||
|
||||
if (clock_src == MSCAN_CLKSRC_BUS || pvr == 0x80822011)
|
||||
return mpc5xxx_get_bus_frequency(of->node);
|
||||
|
||||
return mpc52xx_can_xtal_freq(of);
|
||||
}
|
||||
|
||||
static int __devinit mpc5xxx_can_probe(struct of_device *ofdev,
|
||||
const struct of_device_id *id)
|
||||
{
|
||||
struct device_node *np = ofdev->node;
|
||||
struct net_device *dev;
|
||||
struct mscan_priv *priv;
|
||||
void __iomem *base;
|
||||
const char *clk_src;
|
||||
int err, irq, clock_src;
|
||||
|
||||
base = of_iomap(ofdev->node, 0);
|
||||
if (!base) {
|
||||
dev_err(&ofdev->dev, "couldn't ioremap\n");
|
||||
err = -ENOMEM;
|
||||
goto exit_release_mem;
|
||||
}
|
||||
|
||||
irq = irq_of_parse_and_map(np, 0);
|
||||
if (!irq) {
|
||||
dev_err(&ofdev->dev, "no irq found\n");
|
||||
err = -ENODEV;
|
||||
goto exit_unmap_mem;
|
||||
}
|
||||
|
||||
dev = alloc_mscandev();
|
||||
if (!dev) {
|
||||
err = -ENOMEM;
|
||||
goto exit_dispose_irq;
|
||||
}
|
||||
|
||||
priv = netdev_priv(dev);
|
||||
priv->reg_base = base;
|
||||
dev->irq = irq;
|
||||
|
||||
/*
|
||||
* Either the oscillator clock (SYS_XTAL_IN) or the IP bus clock
|
||||
* (IP_CLK) can be selected as MSCAN clock source. According to
|
||||
* the MPC5200 user's manual, the oscillator clock is the better
|
||||
* choice as it has less jitter. For this reason, it is selected
|
||||
* by default.
|
||||
*/
|
||||
clk_src = of_get_property(np, "fsl,mscan-clk-src", NULL);
|
||||
if (clk_src && strcmp(clk_src, "ip") == 0)
|
||||
clock_src = MSCAN_CLKSRC_BUS;
|
||||
else
|
||||
clock_src = MSCAN_CLKSRC_XTAL;
|
||||
priv->can.clock.freq = mpc52xx_can_clock_freq(ofdev, clock_src);
|
||||
if (!priv->can.clock.freq) {
|
||||
dev_err(&ofdev->dev, "couldn't get MSCAN clock frequency\n");
|
||||
err = -ENODEV;
|
||||
goto exit_free_mscan;
|
||||
}
|
||||
|
||||
SET_NETDEV_DEV(dev, &ofdev->dev);
|
||||
|
||||
err = register_mscandev(dev, clock_src);
|
||||
if (err) {
|
||||
dev_err(&ofdev->dev, "registering %s failed (err=%d)\n",
|
||||
DRV_NAME, err);
|
||||
goto exit_free_mscan;
|
||||
}
|
||||
|
||||
dev_set_drvdata(&ofdev->dev, dev);
|
||||
|
||||
dev_info(&ofdev->dev, "MSCAN at 0x%p, irq %d, clock %d Hz\n",
|
||||
priv->reg_base, dev->irq, priv->can.clock.freq);
|
||||
|
||||
return 0;
|
||||
|
||||
exit_free_mscan:
|
||||
free_candev(dev);
|
||||
exit_dispose_irq:
|
||||
irq_dispose_mapping(irq);
|
||||
exit_unmap_mem:
|
||||
iounmap(base);
|
||||
exit_release_mem:
|
||||
return err;
|
||||
}
|
||||
|
||||
static int __devexit mpc5xxx_can_remove(struct of_device *ofdev)
|
||||
{
|
||||
struct net_device *dev = dev_get_drvdata(&ofdev->dev);
|
||||
struct mscan_priv *priv = netdev_priv(dev);
|
||||
|
||||
dev_set_drvdata(&ofdev->dev, NULL);
|
||||
|
||||
unregister_mscandev(dev);
|
||||
iounmap(priv->reg_base);
|
||||
irq_dispose_mapping(dev->irq);
|
||||
free_candev(dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static struct mscan_regs saved_regs;
|
||||
static int mpc5xxx_can_suspend(struct of_device *ofdev, pm_message_t state)
|
||||
{
|
||||
struct net_device *dev = dev_get_drvdata(&ofdev->dev);
|
||||
struct mscan_priv *priv = netdev_priv(dev);
|
||||
struct mscan_regs *regs = (struct mscan_regs *)priv->reg_base;
|
||||
|
||||
_memcpy_fromio(&saved_regs, regs, sizeof(*regs));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mpc5xxx_can_resume(struct of_device *ofdev)
|
||||
{
|
||||
struct net_device *dev = dev_get_drvdata(&ofdev->dev);
|
||||
struct mscan_priv *priv = netdev_priv(dev);
|
||||
struct mscan_regs *regs = (struct mscan_regs *)priv->reg_base;
|
||||
|
||||
regs->canctl0 |= MSCAN_INITRQ;
|
||||
while ((regs->canctl1 & MSCAN_INITAK) == 0)
|
||||
udelay(10);
|
||||
|
||||
regs->canctl1 = saved_regs.canctl1;
|
||||
regs->canbtr0 = saved_regs.canbtr0;
|
||||
regs->canbtr1 = saved_regs.canbtr1;
|
||||
regs->canidac = saved_regs.canidac;
|
||||
|
||||
/* restore masks, buffers etc. */
|
||||
_memcpy_toio(®s->canidar1_0, (void *)&saved_regs.canidar1_0,
|
||||
sizeof(*regs) - offsetof(struct mscan_regs, canidar1_0));
|
||||
|
||||
regs->canctl0 &= ~MSCAN_INITRQ;
|
||||
regs->cantbsel = saved_regs.cantbsel;
|
||||
regs->canrier = saved_regs.canrier;
|
||||
regs->cantier = saved_regs.cantier;
|
||||
regs->canctl0 = saved_regs.canctl0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static struct of_device_id __devinitdata mpc5xxx_can_table[] = {
|
||||
{.compatible = "fsl,mpc5200-mscan"},
|
||||
{.compatible = "fsl,mpc5200b-mscan"},
|
||||
{},
|
||||
};
|
||||
|
||||
static struct of_platform_driver mpc5xxx_can_driver = {
|
||||
.owner = THIS_MODULE,
|
||||
.name = "mpc5xxx_can",
|
||||
.probe = mpc5xxx_can_probe,
|
||||
.remove = __devexit_p(mpc5xxx_can_remove),
|
||||
#ifdef CONFIG_PM
|
||||
.suspend = mpc5xxx_can_suspend,
|
||||
.resume = mpc5xxx_can_resume,
|
||||
#endif
|
||||
.match_table = mpc5xxx_can_table,
|
||||
};
|
||||
|
||||
static int __init mpc5xxx_can_init(void)
|
||||
{
|
||||
return of_register_platform_driver(&mpc5xxx_can_driver);
|
||||
}
|
||||
module_init(mpc5xxx_can_init);
|
||||
|
||||
static void __exit mpc5xxx_can_exit(void)
|
||||
{
|
||||
return of_unregister_platform_driver(&mpc5xxx_can_driver);
|
||||
};
|
||||
module_exit(mpc5xxx_can_exit);
|
||||
|
||||
MODULE_AUTHOR("Wolfgang Grandegger <wg@grandegger.com>");
|
||||
MODULE_DESCRIPTION("Freescale MPC5200 CAN driver");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
699
drivers/net/can/mscan/mscan.c
Normal file
699
drivers/net/can/mscan/mscan.c
Normal file
File diff suppressed because it is too large
Load Diff
262
drivers/net/can/mscan/mscan.h
Normal file
262
drivers/net/can/mscan/mscan.h
Normal file
@@ -0,0 +1,262 @@
|
||||
/*
|
||||
* Definitions of consts/structs to drive the Freescale MSCAN.
|
||||
*
|
||||
* Copyright (C) 2005-2006 Andrey Volkov <avolkov@varma-el.com>,
|
||||
* Varma Electronics Oy
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the version 2 of the GNU General Public License
|
||||
* as published by the Free Software Foundation
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef __MSCAN_H__
|
||||
#define __MSCAN_H__
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
/* MSCAN control register 0 (CANCTL0) bits */
|
||||
#define MSCAN_RXFRM 0x80
|
||||
#define MSCAN_RXACT 0x40
|
||||
#define MSCAN_CSWAI 0x20
|
||||
#define MSCAN_SYNCH 0x10
|
||||
#define MSCAN_TIME 0x08
|
||||
#define MSCAN_WUPE 0x04
|
||||
#define MSCAN_SLPRQ 0x02
|
||||
#define MSCAN_INITRQ 0x01
|
||||
|
||||
/* MSCAN control register 1 (CANCTL1) bits */
|
||||
#define MSCAN_CANE 0x80
|
||||
#define MSCAN_CLKSRC 0x40
|
||||
#define MSCAN_LOOPB 0x20
|
||||
#define MSCAN_LISTEN 0x10
|
||||
#define MSCAN_WUPM 0x04
|
||||
#define MSCAN_SLPAK 0x02
|
||||
#define MSCAN_INITAK 0x01
|
||||
|
||||
/* Use the MPC5200 MSCAN variant? */
|
||||
#ifdef CONFIG_PPC
|
||||
#define MSCAN_FOR_MPC5200
|
||||
#endif
|
||||
|
||||
#ifdef MSCAN_FOR_MPC5200
|
||||
#define MSCAN_CLKSRC_BUS 0
|
||||
#define MSCAN_CLKSRC_XTAL MSCAN_CLKSRC
|
||||
#else
|
||||
#define MSCAN_CLKSRC_BUS MSCAN_CLKSRC
|
||||
#define MSCAN_CLKSRC_XTAL 0
|
||||
#endif
|
||||
|
||||
/* MSCAN receiver flag register (CANRFLG) bits */
|
||||
#define MSCAN_WUPIF 0x80
|
||||
#define MSCAN_CSCIF 0x40
|
||||
#define MSCAN_RSTAT1 0x20
|
||||
#define MSCAN_RSTAT0 0x10
|
||||
#define MSCAN_TSTAT1 0x08
|
||||
#define MSCAN_TSTAT0 0x04
|
||||
#define MSCAN_OVRIF 0x02
|
||||
#define MSCAN_RXF 0x01
|
||||
#define MSCAN_ERR_IF (MSCAN_OVRIF | MSCAN_CSCIF)
|
||||
#define MSCAN_RSTAT_MSK (MSCAN_RSTAT1 | MSCAN_RSTAT0)
|
||||
#define MSCAN_TSTAT_MSK (MSCAN_TSTAT1 | MSCAN_TSTAT0)
|
||||
#define MSCAN_STAT_MSK (MSCAN_RSTAT_MSK | MSCAN_TSTAT_MSK)
|
||||
|
||||
#define MSCAN_STATE_BUS_OFF (MSCAN_RSTAT1 | MSCAN_RSTAT0 | \
|
||||
MSCAN_TSTAT1 | MSCAN_TSTAT0)
|
||||
#define MSCAN_STATE_TX(canrflg) (((canrflg)&MSCAN_TSTAT_MSK)>>2)
|
||||
#define MSCAN_STATE_RX(canrflg) (((canrflg)&MSCAN_RSTAT_MSK)>>4)
|
||||
#define MSCAN_STATE_ACTIVE 0
|
||||
#define MSCAN_STATE_WARNING 1
|
||||
#define MSCAN_STATE_PASSIVE 2
|
||||
#define MSCAN_STATE_BUSOFF 3
|
||||
|
||||
/* MSCAN receiver interrupt enable register (CANRIER) bits */
|
||||
#define MSCAN_WUPIE 0x80
|
||||
#define MSCAN_CSCIE 0x40
|
||||
#define MSCAN_RSTATE1 0x20
|
||||
#define MSCAN_RSTATE0 0x10
|
||||
#define MSCAN_TSTATE1 0x08
|
||||
#define MSCAN_TSTATE0 0x04
|
||||
#define MSCAN_OVRIE 0x02
|
||||
#define MSCAN_RXFIE 0x01
|
||||
|
||||
/* MSCAN transmitter flag register (CANTFLG) bits */
|
||||
#define MSCAN_TXE2 0x04
|
||||
#define MSCAN_TXE1 0x02
|
||||
#define MSCAN_TXE0 0x01
|
||||
#define MSCAN_TXE (MSCAN_TXE2 | MSCAN_TXE1 | MSCAN_TXE0)
|
||||
|
||||
/* MSCAN transmitter interrupt enable register (CANTIER) bits */
|
||||
#define MSCAN_TXIE2 0x04
|
||||
#define MSCAN_TXIE1 0x02
|
||||
#define MSCAN_TXIE0 0x01
|
||||
#define MSCAN_TXIE (MSCAN_TXIE2 | MSCAN_TXIE1 | MSCAN_TXIE0)
|
||||
|
||||
/* MSCAN transmitter message abort request (CANTARQ) bits */
|
||||
#define MSCAN_ABTRQ2 0x04
|
||||
#define MSCAN_ABTRQ1 0x02
|
||||
#define MSCAN_ABTRQ0 0x01
|
||||
|
||||
/* MSCAN transmitter message abort ack (CANTAAK) bits */
|
||||
#define MSCAN_ABTAK2 0x04
|
||||
#define MSCAN_ABTAK1 0x02
|
||||
#define MSCAN_ABTAK0 0x01
|
||||
|
||||
/* MSCAN transmit buffer selection (CANTBSEL) bits */
|
||||
#define MSCAN_TX2 0x04
|
||||
#define MSCAN_TX1 0x02
|
||||
#define MSCAN_TX0 0x01
|
||||
|
||||
/* MSCAN ID acceptance control register (CANIDAC) bits */
|
||||
#define MSCAN_IDAM1 0x20
|
||||
#define MSCAN_IDAM0 0x10
|
||||
#define MSCAN_IDHIT2 0x04
|
||||
#define MSCAN_IDHIT1 0x02
|
||||
#define MSCAN_IDHIT0 0x01
|
||||
|
||||
#define MSCAN_AF_32BIT 0x00
|
||||
#define MSCAN_AF_16BIT MSCAN_IDAM0
|
||||
#define MSCAN_AF_8BIT MSCAN_IDAM1
|
||||
#define MSCAN_AF_CLOSED (MSCAN_IDAM0|MSCAN_IDAM1)
|
||||
#define MSCAN_AF_MASK (~(MSCAN_IDAM0|MSCAN_IDAM1))
|
||||
|
||||
/* MSCAN Miscellaneous Register (CANMISC) bits */
|
||||
#define MSCAN_BOHOLD 0x01
|
||||
|
||||
#ifdef MSCAN_FOR_MPC5200
|
||||
#define _MSCAN_RESERVED_(n, num) u8 _res##n[num]
|
||||
#define _MSCAN_RESERVED_DSR_SIZE 2
|
||||
#else
|
||||
#define _MSCAN_RESERVED_(n, num)
|
||||
#define _MSCAN_RESERVED_DSR_SIZE 0
|
||||
#endif
|
||||
|
||||
/* Structure of the hardware registers */
|
||||
struct mscan_regs {
|
||||
/* (see doc S12MSCANV3/D) MPC5200 MSCAN */
|
||||
u8 canctl0; /* + 0x00 0x00 */
|
||||
u8 canctl1; /* + 0x01 0x01 */
|
||||
_MSCAN_RESERVED_(1, 2); /* + 0x02 */
|
||||
u8 canbtr0; /* + 0x04 0x02 */
|
||||
u8 canbtr1; /* + 0x05 0x03 */
|
||||
_MSCAN_RESERVED_(2, 2); /* + 0x06 */
|
||||
u8 canrflg; /* + 0x08 0x04 */
|
||||
u8 canrier; /* + 0x09 0x05 */
|
||||
_MSCAN_RESERVED_(3, 2); /* + 0x0a */
|
||||
u8 cantflg; /* + 0x0c 0x06 */
|
||||
u8 cantier; /* + 0x0d 0x07 */
|
||||
_MSCAN_RESERVED_(4, 2); /* + 0x0e */
|
||||
u8 cantarq; /* + 0x10 0x08 */
|
||||
u8 cantaak; /* + 0x11 0x09 */
|
||||
_MSCAN_RESERVED_(5, 2); /* + 0x12 */
|
||||
u8 cantbsel; /* + 0x14 0x0a */
|
||||
u8 canidac; /* + 0x15 0x0b */
|
||||
u8 reserved; /* + 0x16 0x0c */
|
||||
_MSCAN_RESERVED_(6, 5); /* + 0x17 */
|
||||
#ifndef MSCAN_FOR_MPC5200
|
||||
u8 canmisc; /* 0x0d */
|
||||
#endif
|
||||
u8 canrxerr; /* + 0x1c 0x0e */
|
||||
u8 cantxerr; /* + 0x1d 0x0f */
|
||||
_MSCAN_RESERVED_(7, 2); /* + 0x1e */
|
||||
u16 canidar1_0; /* + 0x20 0x10 */
|
||||
_MSCAN_RESERVED_(8, 2); /* + 0x22 */
|
||||
u16 canidar3_2; /* + 0x24 0x12 */
|
||||
_MSCAN_RESERVED_(9, 2); /* + 0x26 */
|
||||
u16 canidmr1_0; /* + 0x28 0x14 */
|
||||
_MSCAN_RESERVED_(10, 2); /* + 0x2a */
|
||||
u16 canidmr3_2; /* + 0x2c 0x16 */
|
||||
_MSCAN_RESERVED_(11, 2); /* + 0x2e */
|
||||
u16 canidar5_4; /* + 0x30 0x18 */
|
||||
_MSCAN_RESERVED_(12, 2); /* + 0x32 */
|
||||
u16 canidar7_6; /* + 0x34 0x1a */
|
||||
_MSCAN_RESERVED_(13, 2); /* + 0x36 */
|
||||
u16 canidmr5_4; /* + 0x38 0x1c */
|
||||
_MSCAN_RESERVED_(14, 2); /* + 0x3a */
|
||||
u16 canidmr7_6; /* + 0x3c 0x1e */
|
||||
_MSCAN_RESERVED_(15, 2); /* + 0x3e */
|
||||
struct {
|
||||
u16 idr1_0; /* + 0x40 0x20 */
|
||||
_MSCAN_RESERVED_(16, 2); /* + 0x42 */
|
||||
u16 idr3_2; /* + 0x44 0x22 */
|
||||
_MSCAN_RESERVED_(17, 2); /* + 0x46 */
|
||||
u16 dsr1_0; /* + 0x48 0x24 */
|
||||
_MSCAN_RESERVED_(18, 2); /* + 0x4a */
|
||||
u16 dsr3_2; /* + 0x4c 0x26 */
|
||||
_MSCAN_RESERVED_(19, 2); /* + 0x4e */
|
||||
u16 dsr5_4; /* + 0x50 0x28 */
|
||||
_MSCAN_RESERVED_(20, 2); /* + 0x52 */
|
||||
u16 dsr7_6; /* + 0x54 0x2a */
|
||||
_MSCAN_RESERVED_(21, 2); /* + 0x56 */
|
||||
u8 dlr; /* + 0x58 0x2c */
|
||||
u8:8; /* + 0x59 0x2d */
|
||||
_MSCAN_RESERVED_(22, 2); /* + 0x5a */
|
||||
u16 time; /* + 0x5c 0x2e */
|
||||
} rx;
|
||||
_MSCAN_RESERVED_(23, 2); /* + 0x5e */
|
||||
struct {
|
||||
u16 idr1_0; /* + 0x60 0x30 */
|
||||
_MSCAN_RESERVED_(24, 2); /* + 0x62 */
|
||||
u16 idr3_2; /* + 0x64 0x32 */
|
||||
_MSCAN_RESERVED_(25, 2); /* + 0x66 */
|
||||
u16 dsr1_0; /* + 0x68 0x34 */
|
||||
_MSCAN_RESERVED_(26, 2); /* + 0x6a */
|
||||
u16 dsr3_2; /* + 0x6c 0x36 */
|
||||
_MSCAN_RESERVED_(27, 2); /* + 0x6e */
|
||||
u16 dsr5_4; /* + 0x70 0x38 */
|
||||
_MSCAN_RESERVED_(28, 2); /* + 0x72 */
|
||||
u16 dsr7_6; /* + 0x74 0x3a */
|
||||
_MSCAN_RESERVED_(29, 2); /* + 0x76 */
|
||||
u8 dlr; /* + 0x78 0x3c */
|
||||
u8 tbpr; /* + 0x79 0x3d */
|
||||
_MSCAN_RESERVED_(30, 2); /* + 0x7a */
|
||||
u16 time; /* + 0x7c 0x3e */
|
||||
} tx;
|
||||
_MSCAN_RESERVED_(31, 2); /* + 0x7e */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#undef _MSCAN_RESERVED_
|
||||
#define MSCAN_REGION sizeof(struct mscan)
|
||||
|
||||
#define TX_QUEUE_SIZE 3
|
||||
|
||||
struct tx_queue_entry {
|
||||
struct list_head list;
|
||||
u8 mask;
|
||||
u8 id;
|
||||
};
|
||||
|
||||
struct mscan_priv {
|
||||
struct can_priv can; /* must be the first member */
|
||||
long open_time;
|
||||
unsigned long flags;
|
||||
void __iomem *reg_base; /* ioremap'ed address to registers */
|
||||
u8 shadow_statflg;
|
||||
u8 shadow_canrier;
|
||||
u8 cur_pri;
|
||||
u8 prev_buf_id;
|
||||
u8 tx_active;
|
||||
|
||||
struct list_head tx_head;
|
||||
struct tx_queue_entry tx_queue[TX_QUEUE_SIZE];
|
||||
struct napi_struct napi;
|
||||
};
|
||||
|
||||
struct net_device *alloc_mscandev(void);
|
||||
/*
|
||||
* clock_src:
|
||||
* 1 = The MSCAN clock source is the onchip Bus Clock.
|
||||
* 0 = The MSCAN clock source is the chip Oscillator Clock.
|
||||
*/
|
||||
extern int register_mscandev(struct net_device *dev, int clock_src);
|
||||
extern void unregister_mscandev(struct net_device *dev);
|
||||
|
||||
#endif /* __MSCAN_H__ */
|
||||
Reference in New Issue
Block a user