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>
This commit is contained in:
commit
6be44b1f0b
14 changed files with 44 additions and 102 deletions
|
@ -16,6 +16,8 @@ Optional properties:
|
||||||
|
|
||||||
- clock-frequency : The oscillator frequency driving the flexcan device
|
- clock-frequency : The oscillator frequency driving the flexcan device
|
||||||
|
|
||||||
|
- xceiver-supply: Regulator that powers the CAN transceiver
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
can@1c000 {
|
can@1c000 {
|
||||||
|
|
|
@ -155,12 +155,14 @@
|
||||||
can0: can@80032000 {
|
can0: can@80032000 {
|
||||||
pinctrl-names = "default";
|
pinctrl-names = "default";
|
||||||
pinctrl-0 = <&can0_pins_a>;
|
pinctrl-0 = <&can0_pins_a>;
|
||||||
|
xceiver-supply = <®_can_3v3>;
|
||||||
status = "okay";
|
status = "okay";
|
||||||
};
|
};
|
||||||
|
|
||||||
can1: can@80034000 {
|
can1: can@80034000 {
|
||||||
pinctrl-names = "default";
|
pinctrl-names = "default";
|
||||||
pinctrl-0 = <&can1_pins_a>;
|
pinctrl-0 = <&can1_pins_a>;
|
||||||
|
xceiver-supply = <®_can_3v3>;
|
||||||
status = "okay";
|
status = "okay";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -319,6 +321,16 @@
|
||||||
gpio = <&gpio3 30 0>;
|
gpio = <&gpio3 30 0>;
|
||||||
enable-active-high;
|
enable-active-high;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
reg_can_3v3: can-3v3 {
|
||||||
|
compatible = "regulator-fixed";
|
||||||
|
regulator-name = "can-3v3";
|
||||||
|
regulator-min-microvolt = <3300000>;
|
||||||
|
regulator-max-microvolt = <3300000>;
|
||||||
|
gpio = <&gpio2 13 0>;
|
||||||
|
enable-active-high;
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
sound {
|
sound {
|
||||||
|
|
|
@ -13,10 +13,10 @@ extern const struct imx_fec_data imx25_fec_data;
|
||||||
imx_add_fec(&imx25_fec_data, pdata)
|
imx_add_fec(&imx25_fec_data, pdata)
|
||||||
|
|
||||||
extern const struct imx_flexcan_data imx25_flexcan_data[];
|
extern const struct imx_flexcan_data imx25_flexcan_data[];
|
||||||
#define imx25_add_flexcan(id, pdata) \
|
#define imx25_add_flexcan(id) \
|
||||||
imx_add_flexcan(&imx25_flexcan_data[id], pdata)
|
imx_add_flexcan(&imx25_flexcan_data[id])
|
||||||
#define imx25_add_flexcan0(pdata) imx25_add_flexcan(0, pdata)
|
#define imx25_add_flexcan0() imx25_add_flexcan(0)
|
||||||
#define imx25_add_flexcan1(pdata) imx25_add_flexcan(1, pdata)
|
#define imx25_add_flexcan1() imx25_add_flexcan(1)
|
||||||
|
|
||||||
extern const struct imx_fsl_usb2_udc_data imx25_fsl_usb2_udc_data;
|
extern const struct imx_fsl_usb2_udc_data imx25_fsl_usb2_udc_data;
|
||||||
#define imx25_add_fsl_usb2_udc(pdata) \
|
#define imx25_add_fsl_usb2_udc(pdata) \
|
||||||
|
|
|
@ -17,10 +17,10 @@ extern const struct imx_fsl_usb2_udc_data imx35_fsl_usb2_udc_data;
|
||||||
imx_add_fsl_usb2_udc(&imx35_fsl_usb2_udc_data, pdata)
|
imx_add_fsl_usb2_udc(&imx35_fsl_usb2_udc_data, pdata)
|
||||||
|
|
||||||
extern const struct imx_flexcan_data imx35_flexcan_data[];
|
extern const struct imx_flexcan_data imx35_flexcan_data[];
|
||||||
#define imx35_add_flexcan(id, pdata) \
|
#define imx35_add_flexcan(id) \
|
||||||
imx_add_flexcan(&imx35_flexcan_data[id], pdata)
|
imx_add_flexcan(&imx35_flexcan_data[id])
|
||||||
#define imx35_add_flexcan0(pdata) imx35_add_flexcan(0, pdata)
|
#define imx35_add_flexcan0() imx35_add_flexcan(0)
|
||||||
#define imx35_add_flexcan1(pdata) imx35_add_flexcan(1, pdata)
|
#define imx35_add_flexcan1() imx35_add_flexcan(1)
|
||||||
|
|
||||||
extern const struct imx_imx2_wdt_data imx35_imx2_wdt_data;
|
extern const struct imx_imx2_wdt_data imx35_imx2_wdt_data;
|
||||||
#define imx35_add_imx2_wdt() \
|
#define imx35_add_imx2_wdt() \
|
||||||
|
|
|
@ -50,7 +50,6 @@ struct platform_device *__init imx_add_fec(
|
||||||
const struct imx_fec_data *data,
|
const struct imx_fec_data *data,
|
||||||
const struct fec_platform_data *pdata);
|
const struct fec_platform_data *pdata);
|
||||||
|
|
||||||
#include <linux/can/platform/flexcan.h>
|
|
||||||
struct imx_flexcan_data {
|
struct imx_flexcan_data {
|
||||||
int id;
|
int id;
|
||||||
resource_size_t iobase;
|
resource_size_t iobase;
|
||||||
|
@ -58,8 +57,7 @@ struct imx_flexcan_data {
|
||||||
resource_size_t irq;
|
resource_size_t irq;
|
||||||
};
|
};
|
||||||
struct platform_device *__init imx_add_flexcan(
|
struct platform_device *__init imx_add_flexcan(
|
||||||
const struct imx_flexcan_data *data,
|
const struct imx_flexcan_data *data);
|
||||||
const struct flexcan_platform_data *pdata);
|
|
||||||
|
|
||||||
#include <linux/fsl_devices.h>
|
#include <linux/fsl_devices.h>
|
||||||
struct imx_fsl_usb2_udc_data {
|
struct imx_fsl_usb2_udc_data {
|
||||||
|
|
|
@ -38,8 +38,7 @@ const struct imx_flexcan_data imx35_flexcan_data[] __initconst = {
|
||||||
#endif /* ifdef CONFIG_SOC_IMX35 */
|
#endif /* ifdef CONFIG_SOC_IMX35 */
|
||||||
|
|
||||||
struct platform_device *__init imx_add_flexcan(
|
struct platform_device *__init imx_add_flexcan(
|
||||||
const struct imx_flexcan_data *data,
|
const struct imx_flexcan_data *data)
|
||||||
const struct flexcan_platform_data *pdata)
|
|
||||||
{
|
{
|
||||||
struct resource res[] = {
|
struct resource res[] = {
|
||||||
{
|
{
|
||||||
|
@ -54,5 +53,5 @@ struct platform_device *__init imx_add_flexcan(
|
||||||
};
|
};
|
||||||
|
|
||||||
return imx_add_platform_device("flexcan", data->id,
|
return imx_add_platform_device("flexcan", data->id,
|
||||||
res, ARRAY_SIZE(res), pdata, sizeof(*pdata));
|
res, ARRAY_SIZE(res), NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,7 +279,7 @@ void __init eukrea_mbimxsd25_baseboard_init(void)
|
||||||
imx25_add_imx_fb(&eukrea_mximxsd_fb_pdata);
|
imx25_add_imx_fb(&eukrea_mximxsd_fb_pdata);
|
||||||
imx25_add_imx_ssi(0, &eukrea_mbimxsd_ssi_pdata);
|
imx25_add_imx_ssi(0, &eukrea_mbimxsd_ssi_pdata);
|
||||||
|
|
||||||
imx25_add_flexcan1(NULL);
|
imx25_add_flexcan1();
|
||||||
imx25_add_sdhci_esdhc_imx(0, &sd1_pdata);
|
imx25_add_sdhci_esdhc_imx(0, &sd1_pdata);
|
||||||
|
|
||||||
gpio_request(GPIO_LED1, "LED1");
|
gpio_request(GPIO_LED1, "LED1");
|
||||||
|
|
|
@ -287,7 +287,7 @@ void __init eukrea_mbimxsd35_baseboard_init(void)
|
||||||
|
|
||||||
imx35_add_imx_ssi(0, &eukrea_mbimxsd_ssi_pdata);
|
imx35_add_imx_ssi(0, &eukrea_mbimxsd_ssi_pdata);
|
||||||
|
|
||||||
imx35_add_flexcan1(NULL);
|
imx35_add_flexcan1();
|
||||||
imx35_add_sdhci_esdhc_imx(0, &sd1_pdata);
|
imx35_add_sdhci_esdhc_imx(0, &sd1_pdata);
|
||||||
|
|
||||||
gpio_request(GPIO_LED1, "LED1");
|
gpio_request(GPIO_LED1, "LED1");
|
||||||
|
|
|
@ -249,7 +249,7 @@ static void __init mx25pdk_init(void)
|
||||||
imx25_add_imx_i2c0(&mx25_3ds_i2c0_data);
|
imx25_add_imx_i2c0(&mx25_3ds_i2c0_data);
|
||||||
|
|
||||||
gpio_request_one(MX25PDK_CAN_PWDN, GPIOF_OUT_INIT_LOW, "can-pwdn");
|
gpio_request_one(MX25PDK_CAN_PWDN, GPIOF_OUT_INIT_LOW, "can-pwdn");
|
||||||
imx25_add_flexcan0(NULL);
|
imx25_add_flexcan0();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __init mx25pdk_timer_init(void)
|
static void __init mx25pdk_timer_init(void)
|
||||||
|
|
|
@ -385,7 +385,7 @@ static void __init pcm043_init(void)
|
||||||
if (!otg_mode_host)
|
if (!otg_mode_host)
|
||||||
imx35_add_fsl_usb2_udc(&otg_device_pdata);
|
imx35_add_fsl_usb2_udc(&otg_device_pdata);
|
||||||
|
|
||||||
imx35_add_flexcan1(NULL);
|
imx35_add_flexcan1();
|
||||||
imx35_add_sdhci_esdhc_imx(0, &sd1_pdata);
|
imx35_add_sdhci_esdhc_imx(0, &sd1_pdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#include <linux/clk/mxs.h>
|
#include <linux/clk/mxs.h>
|
||||||
#include <linux/clkdev.h>
|
#include <linux/clkdev.h>
|
||||||
#include <linux/clocksource.h>
|
#include <linux/clocksource.h>
|
||||||
#include <linux/can/platform/flexcan.h>
|
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
#include <linux/err.h>
|
#include <linux/err.h>
|
||||||
#include <linux/gpio.h>
|
#include <linux/gpio.h>
|
||||||
|
@ -60,41 +59,6 @@ static inline void __mxs_togl(u32 mask, void __iomem *reg)
|
||||||
__raw_writel(mask, reg + MXS_TOG_ADDR);
|
__raw_writel(mask, reg + MXS_TOG_ADDR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* MX28EVK_FLEXCAN_SWITCH is shared between both flexcan controllers
|
|
||||||
*/
|
|
||||||
#define MX28EVK_FLEXCAN_SWITCH MXS_GPIO_NR(2, 13)
|
|
||||||
|
|
||||||
static int flexcan0_en, flexcan1_en;
|
|
||||||
|
|
||||||
static void mx28evk_flexcan_switch(void)
|
|
||||||
{
|
|
||||||
if (flexcan0_en || flexcan1_en)
|
|
||||||
gpio_set_value(MX28EVK_FLEXCAN_SWITCH, 1);
|
|
||||||
else
|
|
||||||
gpio_set_value(MX28EVK_FLEXCAN_SWITCH, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mx28evk_flexcan0_switch(int enable)
|
|
||||||
{
|
|
||||||
flexcan0_en = enable;
|
|
||||||
mx28evk_flexcan_switch();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mx28evk_flexcan1_switch(int enable)
|
|
||||||
{
|
|
||||||
flexcan1_en = enable;
|
|
||||||
mx28evk_flexcan_switch();
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct flexcan_platform_data flexcan_pdata[2];
|
|
||||||
|
|
||||||
static struct of_dev_auxdata mxs_auxdata_lookup[] __initdata = {
|
|
||||||
OF_DEV_AUXDATA("fsl,imx28-flexcan", 0x80032000, NULL, &flexcan_pdata[0]),
|
|
||||||
OF_DEV_AUXDATA("fsl,imx28-flexcan", 0x80034000, NULL, &flexcan_pdata[1]),
|
|
||||||
{ /* sentinel */ }
|
|
||||||
};
|
|
||||||
|
|
||||||
#define OCOTP_WORD_OFFSET 0x20
|
#define OCOTP_WORD_OFFSET 0x20
|
||||||
#define OCOTP_WORD_COUNT 0x20
|
#define OCOTP_WORD_COUNT 0x20
|
||||||
|
|
||||||
|
@ -254,15 +218,6 @@ static void __init imx28_evk_init(void)
|
||||||
mxs_saif_clkmux_select(MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR0);
|
mxs_saif_clkmux_select(MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __init imx28_evk_post_init(void)
|
|
||||||
{
|
|
||||||
if (!gpio_request_one(MX28EVK_FLEXCAN_SWITCH, GPIOF_DIR_OUT,
|
|
||||||
"flexcan-switch")) {
|
|
||||||
flexcan_pdata[0].transceiver_switch = mx28evk_flexcan0_switch;
|
|
||||||
flexcan_pdata[1].transceiver_switch = mx28evk_flexcan1_switch;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int apx4devkit_phy_fixup(struct phy_device *phy)
|
static int apx4devkit_phy_fixup(struct phy_device *phy)
|
||||||
{
|
{
|
||||||
phy->dev_flags |= MICREL_PHY_50MHZ_CLK;
|
phy->dev_flags |= MICREL_PHY_50MHZ_CLK;
|
||||||
|
@ -374,13 +329,10 @@ static void __init mxs_machine_init(void)
|
||||||
cfa10049_init();
|
cfa10049_init();
|
||||||
|
|
||||||
of_platform_populate(NULL, of_default_bus_match_table,
|
of_platform_populate(NULL, of_default_bus_match_table,
|
||||||
mxs_auxdata_lookup, NULL);
|
NULL, NULL);
|
||||||
|
|
||||||
if (of_machine_is_compatible("karo,tx28"))
|
if (of_machine_is_compatible("karo,tx28"))
|
||||||
tx28_post_init();
|
tx28_post_init();
|
||||||
|
|
||||||
if (of_machine_is_compatible("fsl,imx28-evk"))
|
|
||||||
imx28_evk_post_init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MX23_CLKCTRL_RESET_OFFSET 0x120
|
#define MX23_CLKCTRL_RESET_OFFSET 0x120
|
||||||
|
|
|
@ -1264,8 +1264,6 @@ static const struct of_device_id at91_can_dt_ids[] = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
MODULE_DEVICE_TABLE(of, at91_can_dt_ids);
|
MODULE_DEVICE_TABLE(of, at91_can_dt_ids);
|
||||||
#else
|
|
||||||
#define at91_can_dt_ids NULL
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const struct at91_devtype_data *at91_can_get_driver_data(struct platform_device *pdev)
|
static 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 = {
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = KBUILD_MODNAME,
|
.name = KBUILD_MODNAME,
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
.of_match_table = at91_can_dt_ids,
|
.of_match_table = of_match_ptr(at91_can_dt_ids),
|
||||||
},
|
},
|
||||||
.id_table = at91_can_id_table,
|
.id_table = at91_can_id_table,
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#include <linux/can/dev.h>
|
#include <linux/can/dev.h>
|
||||||
#include <linux/can/error.h>
|
#include <linux/can/error.h>
|
||||||
#include <linux/can/led.h>
|
#include <linux/can/led.h>
|
||||||
#include <linux/can/platform/flexcan.h>
|
|
||||||
#include <linux/clk.h>
|
#include <linux/clk.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
#include <linux/if_arp.h>
|
#include <linux/if_arp.h>
|
||||||
|
@ -37,6 +36,7 @@
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
#include <linux/of_device.h>
|
#include <linux/of_device.h>
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
|
#include <linux/regulator/consumer.h>
|
||||||
|
|
||||||
#define DRV_NAME "flexcan"
|
#define DRV_NAME "flexcan"
|
||||||
|
|
||||||
|
@ -211,6 +211,7 @@ struct flexcan_priv {
|
||||||
struct clk *clk_per;
|
struct clk *clk_per;
|
||||||
struct flexcan_platform_data *pdata;
|
struct flexcan_platform_data *pdata;
|
||||||
const struct flexcan_devtype_data *devtype_data;
|
const struct flexcan_devtype_data *devtype_data;
|
||||||
|
struct regulator *reg_xceiver;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct flexcan_devtype_data fsl_p1010_devtype_data = {
|
static struct flexcan_devtype_data fsl_p1010_devtype_data = {
|
||||||
|
@ -258,15 +259,6 @@ static inline void flexcan_write(u32 val, void __iomem *addr)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
|
||||||
* Swtich transceiver on or off
|
|
||||||
*/
|
|
||||||
static void flexcan_transceiver_switch(const struct flexcan_priv *priv, int on)
|
|
||||||
{
|
|
||||||
if (priv->pdata && priv->pdata->transceiver_switch)
|
|
||||||
priv->pdata->transceiver_switch(on);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int flexcan_has_and_handle_berr(const struct flexcan_priv *priv,
|
static inline int flexcan_has_and_handle_berr(const struct flexcan_priv *priv,
|
||||||
u32 reg_esr)
|
u32 reg_esr)
|
||||||
{
|
{
|
||||||
|
@ -799,7 +791,11 @@ static int flexcan_chip_start(struct net_device *dev)
|
||||||
if (priv->devtype_data->features & FLEXCAN_HAS_V10_FEATURES)
|
if (priv->devtype_data->features & FLEXCAN_HAS_V10_FEATURES)
|
||||||
flexcan_write(0x0, ®s->rxfgmask);
|
flexcan_write(0x0, ®s->rxfgmask);
|
||||||
|
|
||||||
flexcan_transceiver_switch(priv, 1);
|
if (priv->reg_xceiver) {
|
||||||
|
err = regulator_enable(priv->reg_xceiver);
|
||||||
|
if (err)
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
/* synchronize with the can bus */
|
/* synchronize with the can bus */
|
||||||
reg_mcr = flexcan_read(®s->mcr);
|
reg_mcr = flexcan_read(®s->mcr);
|
||||||
|
@ -842,7 +838,8 @@ static void flexcan_chip_stop(struct net_device *dev)
|
||||||
reg |= FLEXCAN_MCR_MDIS | FLEXCAN_MCR_HALT;
|
reg |= FLEXCAN_MCR_MDIS | FLEXCAN_MCR_HALT;
|
||||||
flexcan_write(reg, ®s->mcr);
|
flexcan_write(reg, ®s->mcr);
|
||||||
|
|
||||||
flexcan_transceiver_switch(priv, 0);
|
if (priv->reg_xceiver)
|
||||||
|
regulator_disable(priv->reg_xceiver);
|
||||||
priv->can.state = CAN_STATE_STOPPED;
|
priv->can.state = CAN_STATE_STOPPED;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -1084,6 +1081,10 @@ static int flexcan_probe(struct platform_device *pdev)
|
||||||
priv->pdata = pdev->dev.platform_data;
|
priv->pdata = pdev->dev.platform_data;
|
||||||
priv->devtype_data = devtype_data;
|
priv->devtype_data = devtype_data;
|
||||||
|
|
||||||
|
priv->reg_xceiver = devm_regulator_get(&pdev->dev, "xceiver");
|
||||||
|
if (IS_ERR(priv->reg_xceiver))
|
||||||
|
priv->reg_xceiver = NULL;
|
||||||
|
|
||||||
netif_napi_add(dev, &priv->napi, flexcan_poll, FLEXCAN_NAPI_WEIGHT);
|
netif_napi_add(dev, &priv->napi, flexcan_poll, FLEXCAN_NAPI_WEIGHT);
|
||||||
|
|
||||||
dev_set_drvdata(&pdev->dev, dev);
|
dev_set_drvdata(&pdev->dev, dev);
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2010 Marc Kleine-Budde <kernel@pengutronix.de>
|
|
||||||
*
|
|
||||||
* This file is released under the GPLv2
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __CAN_PLATFORM_FLEXCAN_H
|
|
||||||
#define __CAN_PLATFORM_FLEXCAN_H
|
|
||||||
|
|
||||||
/**
|
|
||||||
* struct flexcan_platform_data - flex CAN controller platform data
|
|
||||||
* @transceiver_enable: - called to power on/off the transceiver
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
struct flexcan_platform_data {
|
|
||||||
void (*transceiver_switch)(int enable);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* __CAN_PLATFORM_FLEXCAN_H */
|
|
Loading…
Add table
Reference in a new issue