Skip to content

Commit

Permalink
Merge branch 'for-davem' of git://gitorious.org/linux-can/linux-can-next
Browse files Browse the repository at this point in the history
  • Loading branch information
David S. Miller committed Jul 7, 2012
2 parents 95162d6 + f057bbb commit 8f961fa
Show file tree
Hide file tree
Showing 11 changed files with 320 additions and 23 deletions.
3 changes: 3 additions & 0 deletions Documentation/devicetree/bindings/net/can/fsl-flexcan.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ Required properties:

- reg : Offset and length of the register set for this device
- interrupts : Interrupt tuple for this device

Optional properties:

- clock-frequency : The oscillator frequency driving the flexcan device

Example:
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/can/cc770/cc770.c
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ static void cc770_tx_interrupt(struct net_device *dev, unsigned int o)
netif_wake_queue(dev);
}

irqreturn_t cc770_interrupt(int irq, void *dev_id)
static irqreturn_t cc770_interrupt(int irq, void *dev_id)
{
struct net_device *dev = (struct net_device *)dev_id;
struct cc770_priv *priv = netdev_priv(dev);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/can/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ EXPORT_SYMBOL_GPL(can_free_echo_skb);
/*
* CAN device restart for bus-off recovery
*/
void can_restart(unsigned long data)
static void can_restart(unsigned long data)
{
struct net_device *dev = (struct net_device *)data;
struct can_priv *priv = netdev_priv(dev);
Expand Down
71 changes: 55 additions & 16 deletions drivers/net/can/flexcan.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <linux/list.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/pinctrl/consumer.h>

Expand Down Expand Up @@ -165,10 +166,21 @@ struct flexcan_regs {
u32 imask1; /* 0x28 */
u32 iflag2; /* 0x2c */
u32 iflag1; /* 0x30 */
u32 _reserved2[19];
u32 crl2; /* 0x34 */
u32 esr2; /* 0x38 */
u32 imeur; /* 0x3c */
u32 lrfr; /* 0x40 */
u32 crcr; /* 0x44 */
u32 rxfgmask; /* 0x48 */
u32 rxfir; /* 0x4c */
u32 _reserved3[12];
struct flexcan_mb cantxfg[64];
};

struct flexcan_devtype_data {
u32 hw_ver; /* hardware controller version */
};

struct flexcan_priv {
struct can_priv can;
struct net_device *dev;
Expand All @@ -180,6 +192,15 @@ struct flexcan_priv {

struct clk *clk;
struct flexcan_platform_data *pdata;
struct flexcan_devtype_data *devtype_data;
};

static struct flexcan_devtype_data fsl_p1010_devtype_data = {
.hw_ver = 3,
};

static struct flexcan_devtype_data fsl_imx6q_devtype_data = {
.hw_ver = 10,
};

static struct can_bittiming_const flexcan_bittiming_const = {
Expand Down Expand Up @@ -750,6 +771,9 @@ static int flexcan_chip_start(struct net_device *dev)
flexcan_write(0x0, &regs->rx14mask);
flexcan_write(0x0, &regs->rx15mask);

if (priv->devtype_data->hw_ver >= 10)
flexcan_write(0x0, &regs->rxfgmask);

flexcan_transceiver_switch(priv, 1);

/* synchronize with the can bus */
Expand Down Expand Up @@ -922,8 +946,21 @@ static void __devexit unregister_flexcandev(struct net_device *dev)
unregister_candev(dev);
}

static const struct of_device_id flexcan_of_match[] = {
{ .compatible = "fsl,p1010-flexcan", .data = &fsl_p1010_devtype_data, },
{ .compatible = "fsl,imx6q-flexcan", .data = &fsl_imx6q_devtype_data, },
{ /* sentinel */ },
};

static const struct platform_device_id flexcan_id_table[] = {
{ .name = "flexcan", .driver_data = (kernel_ulong_t)&fsl_p1010_devtype_data, },
{ /* sentinel */ },
};

static int __devinit flexcan_probe(struct platform_device *pdev)
{
const struct of_device_id *of_id;
struct flexcan_devtype_data *devtype_data;
struct net_device *dev;
struct flexcan_priv *priv;
struct resource *mem;
Expand All @@ -938,14 +975,9 @@ static int __devinit flexcan_probe(struct platform_device *pdev)
if (IS_ERR(pinctrl))
return PTR_ERR(pinctrl);

if (pdev->dev.of_node) {
const __be32 *clock_freq_p;

clock_freq_p = of_get_property(pdev->dev.of_node,
"clock-frequency", NULL);
if (clock_freq_p)
clock_freq = be32_to_cpup(clock_freq_p);
}
if (pdev->dev.of_node)
of_property_read_u32(pdev->dev.of_node,
"clock-frequency", &clock_freq);

if (!clock_freq) {
clk = clk_get(&pdev->dev, NULL);
Expand Down Expand Up @@ -982,6 +1014,17 @@ static int __devinit flexcan_probe(struct platform_device *pdev)
goto failed_alloc;
}

of_id = of_match_device(flexcan_of_match, &pdev->dev);
if (of_id) {
devtype_data = of_id->data;
} else if (pdev->id_entry->driver_data) {
devtype_data = (struct flexcan_devtype_data *)
pdev->id_entry->driver_data;
} else {
err = -ENODEV;
goto failed_devtype;
}

dev->netdev_ops = &flexcan_netdev_ops;
dev->irq = irq;
dev->flags |= IFF_ECHO;
Expand All @@ -998,6 +1041,7 @@ static int __devinit flexcan_probe(struct platform_device *pdev)
priv->dev = dev;
priv->clk = clk;
priv->pdata = pdev->dev.platform_data;
priv->devtype_data = devtype_data;

netif_napi_add(dev, &priv->napi, flexcan_poll, FLEXCAN_NAPI_WEIGHT);

Expand All @@ -1016,6 +1060,7 @@ static int __devinit flexcan_probe(struct platform_device *pdev)
return 0;

failed_register:
failed_devtype:
free_candev(dev);
failed_alloc:
iounmap(base);
Expand Down Expand Up @@ -1049,13 +1094,6 @@ static int __devexit flexcan_remove(struct platform_device *pdev)
return 0;
}

static struct of_device_id flexcan_of_match[] = {
{
.compatible = "fsl,p1010-flexcan",
},
{},
};

#ifdef CONFIG_PM
static int flexcan_suspend(struct platform_device *pdev, pm_message_t state)
{
Expand Down Expand Up @@ -1102,6 +1140,7 @@ static struct platform_driver flexcan_driver = {
.remove = __devexit_p(flexcan_remove),
.suspend = flexcan_suspend,
.resume = flexcan_resume,
.id_table = flexcan_id_table,
};

module_platform_driver(flexcan_driver);
Expand Down
3 changes: 3 additions & 0 deletions include/linux/can.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
*/
typedef __u32 canid_t;

#define CAN_SFF_ID_BITS 11
#define CAN_EFF_ID_BITS 29

/*
* Controller Area Network Error Message Frame Mask structure
*
Expand Down
5 changes: 3 additions & 2 deletions include/linux/pkt_cls.h
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,9 @@ enum {
#define TCF_EM_U32 3
#define TCF_EM_META 4
#define TCF_EM_TEXT 5
#define TCF_EM_VLAN 6
#define TCF_EM_MAX 6
#define TCF_EM_VLAN 6
#define TCF_EM_CANID 7
#define TCF_EM_MAX 7

enum {
TCF_EM_PROG_TC
Expand Down
3 changes: 3 additions & 0 deletions net/can/af_can.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ struct s_pstats {
unsigned long rcv_entries_max;
};

/* receive filters subscribed for 'all' CAN devices */
extern struct dev_rcv_lists can_rx_alldev_list;

/* function prototypes for the CAN networklayer procfs (proc.c) */
extern void can_init_proc(void);
extern void can_remove_proc(void);
Expand Down
3 changes: 0 additions & 3 deletions net/can/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ static const char rx_list_name[][8] = {
[RX_EFF] = "rx_eff",
};

/* receive filters subscribed for 'all' CAN devices */
extern struct dev_rcv_lists can_rx_alldev_list;

/*
* af_can statistics stuff
*/
Expand Down
10 changes: 10 additions & 0 deletions net/sched/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,16 @@ config NET_EMATCH_TEXT
To compile this code as a module, choose M here: the
module will be called em_text.

config NET_EMATCH_CANID
tristate "CAN Identifier"
depends on NET_EMATCH && CAN
---help---
Say Y here if you want to be able to classify CAN frames based
on CAN Identifier.

To compile this code as a module, choose M here: the
module will be called em_canid.

config NET_CLS_ACT
bool "Actions"
---help---
Expand Down
1 change: 1 addition & 0 deletions net/sched/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ obj-$(CONFIG_NET_EMATCH_NBYTE) += em_nbyte.o
obj-$(CONFIG_NET_EMATCH_U32) += em_u32.o
obj-$(CONFIG_NET_EMATCH_META) += em_meta.o
obj-$(CONFIG_NET_EMATCH_TEXT) += em_text.o
obj-$(CONFIG_NET_EMATCH_CANID) += em_canid.o
Loading

0 comments on commit 8f961fa

Please sign in to comment.