aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2013-06-29 01:13:14 -0400
committerDavid S. Miller <davem@davemloft.net>2013-06-29 01:13:14 -0400
commit6be44b1f0bdaa9b8e57b4e62045302cabcbbb636 (patch)
tree9bf9ec1d22a8480c147c069fa4d80a2bd20fc9de /drivers
parentd36a21da415b8e6545ae8b4eb6b23eea2ce001c8 (diff)
parent1f3e4b0cc4deb9d740261273fbbf5ea95c8434d0 (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 Fabio Estevam and me, which convert the flexcan transceiver switching to DT[1] and a patch by Sachin Kamat, which cleans up the at91_can driver a bit. [1] These patches touch arch/arm/mach-imx, so I collected Acked-bys from Shawn Guo and Sascha Hauer. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/can/at91_can.c4
-rw-r--r--drivers/net/can/flexcan.c25
2 files changed, 14 insertions, 15 deletions
diff --git a/drivers/net/can/at91_can.c b/drivers/net/can/at91_can.c
index ce8421ac453a..dbbe97ae121e 100644
--- a/drivers/net/can/at91_can.c
+++ b/drivers/net/can/at91_can.c
@@ -1264,8 +1264,6 @@ static const struct of_device_id at91_can_dt_ids[] = {
1264 } 1264 }
1265}; 1265};
1266MODULE_DEVICE_TABLE(of, at91_can_dt_ids); 1266MODULE_DEVICE_TABLE(of, at91_can_dt_ids);
1267#else
1268#define at91_can_dt_ids NULL
1269#endif 1267#endif
1270 1268
1271static const struct at91_devtype_data *at91_can_get_driver_data(struct platform_device *pdev) 1269static const struct at91_devtype_data *at91_can_get_driver_data(struct platform_device *pdev)
@@ -1424,7 +1422,7 @@ static struct platform_driver at91_can_driver = {
1424 .driver = { 1422 .driver = {
1425 .name = KBUILD_MODNAME, 1423 .name = KBUILD_MODNAME,
1426 .owner = THIS_MODULE, 1424 .owner = THIS_MODULE,
1427 .of_match_table = at91_can_dt_ids, 1425 .of_match_table = of_match_ptr(at91_can_dt_ids),
1428 }, 1426 },
1429 .id_table = at91_can_id_table, 1427 .id_table = at91_can_id_table,
1430}; 1428};
diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index f873b9f8d4d4..7b0be0910f4b 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -24,7 +24,6 @@
24#include <linux/can/dev.h> 24#include <linux/can/dev.h>
25#include <linux/can/error.h> 25#include <linux/can/error.h>
26#include <linux/can/led.h> 26#include <linux/can/led.h>
27#include <linux/can/platform/flexcan.h>
28#include <linux/clk.h> 27#include <linux/clk.h>
29#include <linux/delay.h> 28#include <linux/delay.h>
30#include <linux/if_arp.h> 29#include <linux/if_arp.h>
@@ -37,6 +36,7 @@
37#include <linux/of.h> 36#include <linux/of.h>
38#include <linux/of_device.h> 37#include <linux/of_device.h>
39#include <linux/platform_device.h> 38#include <linux/platform_device.h>
39#include <linux/regulator/consumer.h>
40 40
41#define DRV_NAME "flexcan" 41#define DRV_NAME "flexcan"
42 42
@@ -211,6 +211,7 @@ struct flexcan_priv {
211 struct clk *clk_per; 211 struct clk *clk_per;
212 struct flexcan_platform_data *pdata; 212 struct flexcan_platform_data *pdata;
213 const struct flexcan_devtype_data *devtype_data; 213 const struct flexcan_devtype_data *devtype_data;
214 struct regulator *reg_xceiver;
214}; 215};
215 216
216static struct flexcan_devtype_data fsl_p1010_devtype_data = { 217static struct flexcan_devtype_data fsl_p1010_devtype_data = {
@@ -258,15 +259,6 @@ static inline void flexcan_write(u32 val, void __iomem *addr)
258} 259}
259#endif 260#endif
260 261
261/*
262 * Swtich transceiver on or off
263 */
264static void flexcan_transceiver_switch(const struct flexcan_priv *priv, int on)
265{
266 if (priv->pdata && priv->pdata->transceiver_switch)
267 priv->pdata->transceiver_switch(on);
268}
269
270static inline int flexcan_has_and_handle_berr(const struct flexcan_priv *priv, 262static inline int flexcan_has_and_handle_berr(const struct flexcan_priv *priv,
271 u32 reg_esr) 263 u32 reg_esr)
272{ 264{
@@ -799,7 +791,11 @@ static int flexcan_chip_start(struct net_device *dev)
799 if (priv->devtype_data->features & FLEXCAN_HAS_V10_FEATURES) 791 if (priv->devtype_data->features & FLEXCAN_HAS_V10_FEATURES)
800 flexcan_write(0x0, &regs->rxfgmask); 792 flexcan_write(0x0, &regs->rxfgmask);
801 793
802 flexcan_transceiver_switch(priv, 1); 794 if (priv->reg_xceiver) {
795 err = regulator_enable(priv->reg_xceiver);
796 if (err)
797 goto out;
798 }
803 799
804 /* synchronize with the can bus */ 800 /* synchronize with the can bus */
805 reg_mcr = flexcan_read(&regs->mcr); 801 reg_mcr = flexcan_read(&regs->mcr);
@@ -842,7 +838,8 @@ static void flexcan_chip_stop(struct net_device *dev)
842 reg |= FLEXCAN_MCR_MDIS | FLEXCAN_MCR_HALT; 838 reg |= FLEXCAN_MCR_MDIS | FLEXCAN_MCR_HALT;
843 flexcan_write(reg, &regs->mcr); 839 flexcan_write(reg, &regs->mcr);
844 840
845 flexcan_transceiver_switch(priv, 0); 841 if (priv->reg_xceiver)
842 regulator_disable(priv->reg_xceiver);
846 priv->can.state = CAN_STATE_STOPPED; 843 priv->can.state = CAN_STATE_STOPPED;
847 844
848 return; 845 return;
@@ -1084,6 +1081,10 @@ static int flexcan_probe(struct platform_device *pdev)
1084 priv->pdata = pdev->dev.platform_data; 1081 priv->pdata = pdev->dev.platform_data;
1085 priv->devtype_data = devtype_data; 1082 priv->devtype_data = devtype_data;
1086 1083
1084 priv->reg_xceiver = devm_regulator_get(&pdev->dev, "xceiver");
1085 if (IS_ERR(priv->reg_xceiver))
1086 priv->reg_xceiver = NULL;
1087
1087 netif_napi_add(dev, &priv->napi, flexcan_poll, FLEXCAN_NAPI_WEIGHT); 1088 netif_napi_add(dev, &priv->napi, flexcan_poll, FLEXCAN_NAPI_WEIGHT);
1088 1089
1089 dev_set_drvdata(&pdev->dev, dev); 1090 dev_set_drvdata(&pdev->dev, dev);