Commit 15151090 authored by Roger Quadros's avatar Roger Quadros Committed by Marc Kleine-Budde

can: c_can: Introduce c_can_driver_data structure

We want to have more data than just can_dev_id to be present
in the driver data e.g. TI platforms need RAMINIT register
description. Introduce the c_can_driver_data structure and move
the can_dev_id into it.

Tidy up the way it is used on probe().
Signed-off-by: default avatarRoger Quadros <rogerq@ti.com>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent e7e26bc7
...@@ -169,6 +169,10 @@ enum c_can_dev_id { ...@@ -169,6 +169,10 @@ enum c_can_dev_id {
BOSCH_D_CAN, BOSCH_D_CAN,
}; };
struct c_can_driver_data {
enum c_can_dev_id id;
};
/* c_can private data structure */ /* c_can private data structure */
struct c_can_priv { struct c_can_priv {
struct can_priv can; /* must be the first member */ struct can_priv can; /* must be the first member */
......
...@@ -168,26 +168,34 @@ static void c_can_hw_raminit(const struct c_can_priv *priv, bool enable) ...@@ -168,26 +168,34 @@ static void c_can_hw_raminit(const struct c_can_priv *priv, bool enable)
} }
} }
static const struct c_can_driver_data c_can_drvdata = {
.id = BOSCH_C_CAN,
};
static const struct c_can_driver_data d_can_drvdata = {
.id = BOSCH_D_CAN,
};
static struct platform_device_id c_can_id_table[] = { static struct platform_device_id c_can_id_table[] = {
[BOSCH_C_CAN_PLATFORM] = { {
.name = KBUILD_MODNAME, .name = KBUILD_MODNAME,
.driver_data = BOSCH_C_CAN, .driver_data = (kernel_ulong_t)&c_can_drvdata,
}, },
[BOSCH_C_CAN] = { {
.name = "c_can", .name = "c_can",
.driver_data = BOSCH_C_CAN, .driver_data = (kernel_ulong_t)&c_can_drvdata,
}, },
[BOSCH_D_CAN] = { {
.name = "d_can", .name = "d_can",
.driver_data = BOSCH_D_CAN, .driver_data = (kernel_ulong_t)&d_can_drvdata,
}, { },
} { /* sentinel */ },
}; };
MODULE_DEVICE_TABLE(platform, c_can_id_table); MODULE_DEVICE_TABLE(platform, c_can_id_table);
static const struct of_device_id c_can_of_table[] = { static const struct of_device_id c_can_of_table[] = {
{ .compatible = "bosch,c_can", .data = &c_can_id_table[BOSCH_C_CAN] }, { .compatible = "bosch,c_can", .data = &c_can_drvdata },
{ .compatible = "bosch,d_can", .data = &c_can_id_table[BOSCH_D_CAN] }, { .compatible = "bosch,d_can", .data = &d_can_drvdata },
{ /* sentinel */ }, { /* sentinel */ },
}; };
MODULE_DEVICE_TABLE(of, c_can_of_table); MODULE_DEVICE_TABLE(of, c_can_of_table);
...@@ -199,21 +207,19 @@ static int c_can_plat_probe(struct platform_device *pdev) ...@@ -199,21 +207,19 @@ static int c_can_plat_probe(struct platform_device *pdev)
struct net_device *dev; struct net_device *dev;
struct c_can_priv *priv; struct c_can_priv *priv;
const struct of_device_id *match; const struct of_device_id *match;
const struct platform_device_id *id;
struct resource *mem, *res; struct resource *mem, *res;
int irq; int irq;
struct clk *clk; struct clk *clk;
const struct c_can_driver_data *drvdata;
if (pdev->dev.of_node) {
match = of_match_device(c_can_of_table, &pdev->dev); match = of_match_device(c_can_of_table, &pdev->dev);
if (!match) { if (match) {
dev_err(&pdev->dev, "Failed to find matching dt id\n"); drvdata = match->data;
ret = -EINVAL; } else if (pdev->id_entry->driver_data) {
goto exit; drvdata = (struct c_can_driver_data *)
} platform_get_device_id(pdev)->driver_data;
id = match->data;
} else { } else {
id = platform_get_device_id(pdev); return -ENODEV;
} }
/* get the appropriate clk */ /* get the appropriate clk */
...@@ -245,7 +251,7 @@ static int c_can_plat_probe(struct platform_device *pdev) ...@@ -245,7 +251,7 @@ static int c_can_plat_probe(struct platform_device *pdev)
} }
priv = netdev_priv(dev); priv = netdev_priv(dev);
switch (id->driver_data) { switch (drvdata->id) {
case BOSCH_C_CAN: case BOSCH_C_CAN:
priv->regs = reg_map_c_can; priv->regs = reg_map_c_can;
switch (mem->flags & IORESOURCE_MEM_TYPE_MASK) { switch (mem->flags & IORESOURCE_MEM_TYPE_MASK) {
...@@ -304,7 +310,7 @@ static int c_can_plat_probe(struct platform_device *pdev) ...@@ -304,7 +310,7 @@ static int c_can_plat_probe(struct platform_device *pdev)
priv->device = &pdev->dev; priv->device = &pdev->dev;
priv->can.clock.freq = clk_get_rate(clk); priv->can.clock.freq = clk_get_rate(clk);
priv->priv = clk; priv->priv = clk;
priv->type = id->driver_data; priv->type = drvdata->id;
platform_set_drvdata(pdev, dev); platform_set_drvdata(pdev, dev);
SET_NETDEV_DEV(dev, &pdev->dev); SET_NETDEV_DEV(dev, &pdev->dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment