aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2013-03-27 13:14:03 -0400
committerDavid S. Miller <davem@davemloft.net>2013-03-27 13:14:03 -0400
commit7559d97993ae7d552c96313155286f372cf4cf7c (patch)
treefe9a82b65e5a32b0cd16f0b93e40c9425e20719a
parenta33e6112d9b0c1ab4fb55bb538832ec789200a10 (diff)
parent21c11bc5d016ede062843cb3f98ee6824e6bcae2 (diff)
Merge branch 'for-davem' of git://gitorious.org/linux-can/linux-can-next
Marc Kleine-Budde says: =================== this is a pull-request for net-next/master. It consists of three patches by Lars-Peter Clausen to clean up the mcp251x spi-can driver, two patches from Ludovic Desroches to bring device tree support to the at91_can driver and a patch by me to fix a sparse warning in the blackfin driver. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--Documentation/devicetree/bindings/net/can/atmel-can.txt14
-rw-r--r--drivers/net/can/Kconfig2
-rw-r--r--drivers/net/can/at91_can.c76
-rw-r--r--drivers/net/can/bfin_can.c4
-rw-r--r--drivers/net/can/mcp251x.c35
5 files changed, 88 insertions, 43 deletions
diff --git a/Documentation/devicetree/bindings/net/can/atmel-can.txt b/Documentation/devicetree/bindings/net/can/atmel-can.txt
new file mode 100644
index 000000000000..72cf0c5daff4
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/can/atmel-can.txt
@@ -0,0 +1,14 @@
1* AT91 CAN *
2
3Required properties:
4 - compatible: Should be "atmel,at91sam9263-can" or "atmel,at91sam9x5-can"
5 - reg: Should contain CAN controller registers location and length
6 - interrupts: Should contain IRQ line for the CAN controller
7
8Example:
9
10 can0: can@f000c000 {
11 compatbile = "atmel,at91sam9x5-can";
12 reg = <0xf000c000 0x300>;
13 interrupts = <40 4 5>
14 };
diff --git a/drivers/net/can/Kconfig b/drivers/net/can/Kconfig
index 9862b2e07644..e456b70933c2 100644
--- a/drivers/net/can/Kconfig
+++ b/drivers/net/can/Kconfig
@@ -65,7 +65,7 @@ config CAN_LEDS
65 65
66config CAN_AT91 66config CAN_AT91
67 tristate "Atmel AT91 onchip CAN controller" 67 tristate "Atmel AT91 onchip CAN controller"
68 depends on ARCH_AT91SAM9263 || ARCH_AT91SAM9X5 68 depends on ARM
69 ---help--- 69 ---help---
70 This is a driver for the SoC CAN controller in Atmel's AT91SAM9263 70 This is a driver for the SoC CAN controller in Atmel's AT91SAM9263
71 and AT91SAM9X5 processors. 71 and AT91SAM9X5 processors.
diff --git a/drivers/net/can/at91_can.c b/drivers/net/can/at91_can.c
index 44f363792b59..db52f4414def 100644
--- a/drivers/net/can/at91_can.c
+++ b/drivers/net/can/at91_can.c
@@ -27,6 +27,7 @@
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/netdevice.h> 29#include <linux/netdevice.h>
30#include <linux/of.h>
30#include <linux/platform_device.h> 31#include <linux/platform_device.h>
31#include <linux/rtnetlink.h> 32#include <linux/rtnetlink.h>
32#include <linux/skbuff.h> 33#include <linux/skbuff.h>
@@ -155,19 +156,20 @@ struct at91_priv {
155 canid_t mb0_id; 156 canid_t mb0_id;
156}; 157};
157 158
158static const struct at91_devtype_data at91_devtype_data[] = { 159static const struct at91_devtype_data at91_at91sam9263_data = {
159 [AT91_DEVTYPE_SAM9263] = { 160 .rx_first = 1,
160 .rx_first = 1, 161 .rx_split = 8,
161 .rx_split = 8, 162 .rx_last = 11,
162 .rx_last = 11, 163 .tx_shift = 2,
163 .tx_shift = 2, 164 .type = AT91_DEVTYPE_SAM9263,
164 }, 165};
165 [AT91_DEVTYPE_SAM9X5] = { 166
166 .rx_first = 0, 167static const struct at91_devtype_data at91_at91sam9x5_data = {
167 .rx_split = 4, 168 .rx_first = 0,
168 .rx_last = 5, 169 .rx_split = 4,
169 .tx_shift = 1, 170 .rx_last = 5,
170 }, 171 .tx_shift = 1,
172 .type = AT91_DEVTYPE_SAM9X5,
171}; 173};
172 174
173static const struct can_bittiming_const at91_bittiming_const = { 175static const struct can_bittiming_const at91_bittiming_const = {
@@ -1249,10 +1251,42 @@ static struct attribute_group at91_sysfs_attr_group = {
1249 .attrs = at91_sysfs_attrs, 1251 .attrs = at91_sysfs_attrs,
1250}; 1252};
1251 1253
1254#if defined(CONFIG_OF)
1255static const struct of_device_id at91_can_dt_ids[] = {
1256 {
1257 .compatible = "atmel,at91sam9x5-can",
1258 .data = &at91_at91sam9x5_data,
1259 }, {
1260 .compatible = "atmel,at91sam9263-can",
1261 .data = &at91_at91sam9263_data,
1262 }, {
1263 /* sentinel */
1264 }
1265};
1266MODULE_DEVICE_TABLE(of, at91_can_dt_ids);
1267#else
1268#define at91_can_dt_ids NULL
1269#endif
1270
1271static const struct at91_devtype_data *at91_can_get_driver_data(struct platform_device *pdev)
1272{
1273 if (pdev->dev.of_node) {
1274 const struct of_device_id *match;
1275
1276 match = of_match_node(at91_can_dt_ids, pdev->dev.of_node);
1277 if (!match) {
1278 dev_err(&pdev->dev, "no matching node found in dtb\n");
1279 return NULL;
1280 }
1281 return (const struct at91_devtype_data *)match->data;
1282 }
1283 return (const struct at91_devtype_data *)
1284 platform_get_device_id(pdev)->driver_data;
1285}
1286
1252static int at91_can_probe(struct platform_device *pdev) 1287static int at91_can_probe(struct platform_device *pdev)
1253{ 1288{
1254 const struct at91_devtype_data *devtype_data; 1289 const struct at91_devtype_data *devtype_data;
1255 enum at91_devtype devtype;
1256 struct net_device *dev; 1290 struct net_device *dev;
1257 struct at91_priv *priv; 1291 struct at91_priv *priv;
1258 struct resource *res; 1292 struct resource *res;
@@ -1260,8 +1294,12 @@ static int at91_can_probe(struct platform_device *pdev)
1260 void __iomem *addr; 1294 void __iomem *addr;
1261 int err, irq; 1295 int err, irq;
1262 1296
1263 devtype = pdev->id_entry->driver_data; 1297 devtype_data = at91_can_get_driver_data(pdev);
1264 devtype_data = &at91_devtype_data[devtype]; 1298 if (!devtype_data) {
1299 dev_err(&pdev->dev, "no driver data\n");
1300 err = -ENODEV;
1301 goto exit;
1302 }
1265 1303
1266 clk = clk_get(&pdev->dev, "can_clk"); 1304 clk = clk_get(&pdev->dev, "can_clk");
1267 if (IS_ERR(clk)) { 1305 if (IS_ERR(clk)) {
@@ -1310,7 +1348,6 @@ static int at91_can_probe(struct platform_device *pdev)
1310 priv->dev = dev; 1348 priv->dev = dev;
1311 priv->reg_base = addr; 1349 priv->reg_base = addr;
1312 priv->devtype_data = *devtype_data; 1350 priv->devtype_data = *devtype_data;
1313 priv->devtype_data.type = devtype;
1314 priv->clk = clk; 1351 priv->clk = clk;
1315 priv->pdata = pdev->dev.platform_data; 1352 priv->pdata = pdev->dev.platform_data;
1316 priv->mb0_id = 0x7ff; 1353 priv->mb0_id = 0x7ff;
@@ -1373,10 +1410,10 @@ static int at91_can_remove(struct platform_device *pdev)
1373static const struct platform_device_id at91_can_id_table[] = { 1410static const struct platform_device_id at91_can_id_table[] = {
1374 { 1411 {
1375 .name = "at91_can", 1412 .name = "at91_can",
1376 .driver_data = AT91_DEVTYPE_SAM9263, 1413 .driver_data = (kernel_ulong_t)&at91_at91sam9x5_data,
1377 }, { 1414 }, {
1378 .name = "at91sam9x5_can", 1415 .name = "at91sam9x5_can",
1379 .driver_data = AT91_DEVTYPE_SAM9X5, 1416 .driver_data = (kernel_ulong_t)&at91_at91sam9263_data,
1380 }, { 1417 }, {
1381 /* sentinel */ 1418 /* sentinel */
1382 } 1419 }
@@ -1389,6 +1426,7 @@ static struct platform_driver at91_can_driver = {
1389 .driver = { 1426 .driver = {
1390 .name = KBUILD_MODNAME, 1427 .name = KBUILD_MODNAME,
1391 .owner = THIS_MODULE, 1428 .owner = THIS_MODULE,
1429 .of_match_table = at91_can_dt_ids,
1392 }, 1430 },
1393 .id_table = at91_can_id_table, 1431 .id_table = at91_can_id_table,
1394}; 1432};
diff --git a/drivers/net/can/bfin_can.c b/drivers/net/can/bfin_can.c
index 6a0532176b69..d4a15e82bfc0 100644
--- a/drivers/net/can/bfin_can.c
+++ b/drivers/net/can/bfin_can.c
@@ -412,7 +412,7 @@ static int bfin_can_err(struct net_device *dev, u16 isrc, u16 status)
412 return 0; 412 return 0;
413} 413}
414 414
415irqreturn_t bfin_can_interrupt(int irq, void *dev_id) 415static irqreturn_t bfin_can_interrupt(int irq, void *dev_id)
416{ 416{
417 struct net_device *dev = dev_id; 417 struct net_device *dev = dev_id;
418 struct bfin_can_priv *priv = netdev_priv(dev); 418 struct bfin_can_priv *priv = netdev_priv(dev);
@@ -504,7 +504,7 @@ static int bfin_can_close(struct net_device *dev)
504 return 0; 504 return 0;
505} 505}
506 506
507struct net_device *alloc_bfin_candev(void) 507static struct net_device *alloc_bfin_candev(void)
508{ 508{
509 struct net_device *dev; 509 struct net_device *dev;
510 struct bfin_can_priv *priv; 510 struct bfin_can_priv *priv;
diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c
index f32b9fc6a983..2b620c8aa13a 100644
--- a/drivers/net/can/mcp251x.c
+++ b/drivers/net/can/mcp251x.c
@@ -1138,9 +1138,11 @@ static int mcp251x_can_remove(struct spi_device *spi)
1138 return 0; 1138 return 0;
1139} 1139}
1140 1140
1141#ifdef CONFIG_PM 1141#ifdef CONFIG_PM_SLEEP
1142static int mcp251x_can_suspend(struct spi_device *spi, pm_message_t state) 1142
1143static int mcp251x_can_suspend(struct device *dev)
1143{ 1144{
1145 struct spi_device *spi = to_spi_device(dev);
1144 struct mcp251x_platform_data *pdata = spi->dev.platform_data; 1146 struct mcp251x_platform_data *pdata = spi->dev.platform_data;
1145 struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev); 1147 struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev);
1146 struct net_device *net = priv->net; 1148 struct net_device *net = priv->net;
@@ -1170,8 +1172,9 @@ static int mcp251x_can_suspend(struct spi_device *spi, pm_message_t state)
1170 return 0; 1172 return 0;
1171} 1173}
1172 1174
1173static int mcp251x_can_resume(struct spi_device *spi) 1175static int mcp251x_can_resume(struct device *dev)
1174{ 1176{
1177 struct spi_device *spi = to_spi_device(dev);
1175 struct mcp251x_platform_data *pdata = spi->dev.platform_data; 1178 struct mcp251x_platform_data *pdata = spi->dev.platform_data;
1176 struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev); 1179 struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev);
1177 1180
@@ -1191,9 +1194,13 @@ static int mcp251x_can_resume(struct spi_device *spi)
1191 enable_irq(spi->irq); 1194 enable_irq(spi->irq);
1192 return 0; 1195 return 0;
1193} 1196}
1197
1198static SIMPLE_DEV_PM_OPS(mcp251x_can_pm_ops, mcp251x_can_suspend,
1199 mcp251x_can_resume);
1200#define MCP251X_PM_OPS (&mcp251x_can_pm_ops)
1201
1194#else 1202#else
1195#define mcp251x_can_suspend NULL 1203#define MCP251X_PM_OPS NULL
1196#define mcp251x_can_resume NULL
1197#endif 1204#endif
1198 1205
1199static const struct spi_device_id mcp251x_id_table[] = { 1206static const struct spi_device_id mcp251x_id_table[] = {
@@ -1207,29 +1214,15 @@ MODULE_DEVICE_TABLE(spi, mcp251x_id_table);
1207static struct spi_driver mcp251x_can_driver = { 1214static struct spi_driver mcp251x_can_driver = {
1208 .driver = { 1215 .driver = {
1209 .name = DEVICE_NAME, 1216 .name = DEVICE_NAME,
1210 .bus = &spi_bus_type,
1211 .owner = THIS_MODULE, 1217 .owner = THIS_MODULE,
1218 .pm = MCP251X_PM_OPS,
1212 }, 1219 },
1213 1220
1214 .id_table = mcp251x_id_table, 1221 .id_table = mcp251x_id_table,
1215 .probe = mcp251x_can_probe, 1222 .probe = mcp251x_can_probe,
1216 .remove = mcp251x_can_remove, 1223 .remove = mcp251x_can_remove,
1217 .suspend = mcp251x_can_suspend,
1218 .resume = mcp251x_can_resume,
1219}; 1224};
1220 1225module_spi_driver(mcp251x_can_driver);
1221static int __init mcp251x_can_init(void)
1222{
1223 return spi_register_driver(&mcp251x_can_driver);
1224}
1225
1226static void __exit mcp251x_can_exit(void)
1227{
1228 spi_unregister_driver(&mcp251x_can_driver);
1229}
1230
1231module_init(mcp251x_can_init);
1232module_exit(mcp251x_can_exit);
1233 1226
1234MODULE_AUTHOR("Chris Elston <celston@katalix.com>, " 1227MODULE_AUTHOR("Chris Elston <celston@katalix.com>, "
1235 "Christian Pellegrin <chripell@evolware.org>"); 1228 "Christian Pellegrin <chripell@evolware.org>");