ARM: imx: prepare for removal of flexcan_platform_data
Subsystems (5)
Fabio Estevam
reviewerPATCH 1/3 ARM: imx: prepare for removal of flexcan_platform_data
From: Marc Kleine-Budde <[email protected]>
As there are no imx in-tree users of flexcan_platform_data, this patch removes the possibility to register a flexcan device with platform data.
The functionality to swith on/off CAN transceivers is added to DT via regulators on a later patch.
Compile time tested with imx_v4_v5_defconfig and imx_v6_v7_defconfig.
--- arch/arm/mach-imx/devices-imx25.h | 8 ++++---- arch/arm/mach-imx/devices-imx35.h | 8 ++++---- arch/arm/mach-imx/devices/devices-common.h | 4 +--- arch/arm/mach-imx/devices/platform-flexcan.c | 5 ++--- arch/arm/mach-imx/eukrea_mbimxsd25-baseboard.c | 2 +- arch/arm/mach-imx/eukrea_mbimxsd35-baseboard.c | 2 +- arch/arm/mach-imx/mach-mx25_3ds.c | 2 +- arch/arm/mach-imx/mach-pcm043.c | 2 +- 8 files changed, 15 insertions(+), 18 deletions(-)
arch/arm/mach-imx/devices-imx25.h +4 -4
@@ -13,10 +13,10 @@ extern const struct imx_fec_data imx25_fec_data; imx_add_fec(&imx25_fec_data, pdata)extern const struct imx_flexcan_data imx25_flexcan_data[]; -#define imx25_add_flexcan (id, pdata) \ - imx_add_flexcan(&imx25_flexcan_data[id], pdata) -#define imx25_add_flexcan0 (pdata) imx25_add_flexcan(0, pdata) -#define imx25_add_flexcan1 (pdata) imx25_add_flexcan(1, pdata) +#define imx25_add_flexcan (id) \ + imx_add_flexcan(&imx25_flexcan_data[id]) +#define imx25_add_flexcan0 () imx25_add_flexcan(0) +#define imx25_add_flexcan1 () imx25_add_flexcan(1)extern const struct imx_fsl_usb2_udc_data imx25_fsl_usb2_udc_data;#define imx25_add_fsl_usb2_udc (pdata) \
arch/arm/mach-imx/devices-imx35.h +4 -4
@@ -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)extern const struct imx_flexcan_data imx35_flexcan_data[]; -#define imx35_add_flexcan (id, pdata) \ - imx_add_flexcan(&imx35_flexcan_data[id], pdata) -#define imx35_add_flexcan0 (pdata) imx35_add_flexcan(0, pdata) -#define imx35_add_flexcan1 (pdata) imx35_add_flexcan(1, pdata) +#define imx35_add_flexcan (id) \ + imx_add_flexcan(&imx35_flexcan_data[id]) +#define imx35_add_flexcan0 () imx35_add_flexcan(0) +#define imx35_add_flexcan1 () imx35_add_flexcan(1)extern const struct imx_imx2_wdt_data imx35_imx2_wdt_data;#define imx35_add_imx2_wdt () \
arch/arm/mach-imx/devices/devices-common.h +1 -3
@@ -50,7 +50,6 @@ struct platform_device *__init imx_add_fec(const struct imx_fec_data *data, const struct fec_platform_data *pdata); -#include <linux/can/platform/flexcan.h> struct imx_flexcan_data {int id;resource_size_t iobase;
@@ -58,8 +57,7 @@ struct imx_flexcan_data {resource_size_t irq; };struct platform_device *__init imx_add_flexcan ( -const struct imx_flexcan_data *data, -const struct flexcan_platform_data *pdata); +const struct imx_flexcan_data *data);#include <linux/fsl_devices.h> struct imx_fsl_usb2_udc_data {
arch/arm/mach-imx/devices/platform-flexcan.c +2 -3
@@ -38,8 +38,7 @@ const struct imx_flexcan_data imx35_flexcan_data[] __initconst = {#endif /* ifdef CONFIG_SOC_IMX35 */ struct platform_device *__init imx_add_flexcan ( -const struct imx_flexcan_data *data, -const struct flexcan_platform_data *pdata) +const struct imx_flexcan_data *data) {struct resource res[] = { {
@@ -54,5 +53,5 @@ struct platform_device *__init imx_add_flexcan( };return imx_add_platform_device ("flexcan" , data->id, - res,ARRAY_SIZE (res), pdata,sizeof (*pdata)); + res,ARRAY_SIZE (res),NULL ,0 ); }
arch/arm/mach-imx/eukrea_mbimxsd25-baseboard.c +1 -1
@@ -279,7 +279,7 @@ void __init eukrea_mbimxsd25_baseboard_init(void)imx25_add_imx_fb (&eukrea_mximxsd_fb_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);gpio_request (GPIO_LED1 ,"LED1" );
arch/arm/mach-imx/eukrea_mbimxsd35-baseboard.c +1 -1
@@ -287,7 +287,7 @@ void __init eukrea_mbimxsd35_baseboard_init(void)imx35_add_imx_ssi (0 , &eukrea_mbimxsd_ssi_pdata); -imx35_add_flexcan1 (NULL ); +imx35_add_flexcan1 ();imx35_add_sdhci_esdhc_imx (0 , &sd1_pdata);gpio_request (GPIO_LED1 ,"LED1" );
arch/arm/mach-imx/mach-mx25_3ds.c +1 -1
@@ -249,7 +249,7 @@ static void __init mx25pdk_init(void)imx25_add_imx_i2c0 (&mx25_3ds_i2c0_data);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 )
arch/arm/mach-imx/mach-pcm043.c +1 -1
@@ -385,7 +385,7 @@ static void __init pcm043_init(void)if (!otg_mode_host)imx35_add_fsl_usb2_udc (&otg_device_pdata); -imx35_add_flexcan1 (NULL ); +imx35_add_flexcan1 ();imx35_add_sdhci_esdhc_imx (0 , &sd1_pdata); }
Signature · 1 line
1.8.1.2
Fabio Estevam
reviewerPATCH 2/3 flexcan: Use a regulator to control the CAN transceiver
From: Fabio Estevam <[email protected]>
Instead of using a GPIO to turn on/off the CAN transceiver, it is better to use a regulator as some systems may use a PMIC to power the CAN transceiver.
---
Marc/Shawn,
Only boot tested. I haven't tested CAN operation.
.../devicetree/bindings/net/can/fsl-flexcan.txt | 2 + arch/arm/boot/dts/imx28-evk.dts | 12 ++++++ arch/arm/mach-mxs/mach-mxs.c | 50 +--------------------- drivers/net/can/flexcan.c | 25 +++++------ 4 files changed, 28 insertions(+), 61 deletions(-)
Documentation/devicetree/bindings/net/can/fsl-flexcan.txt +2 -0
@@ -16,6 +16,8 @@ Optional properties: - clock-frequency : The oscillator frequency driving the flexcan device +- xceiver-supply: Regulator that powers the CAN transceiver + Example: can@1c000 {
arch/arm/boot/dts/imx28-evk.dts +12 -0
@@ -155,12 +155,14 @@ can0: can@80032000 { pinctrl-names = "default"; pinctrl-0 = <&can0_pins_a>; + xceiver-supply = <®_can_3v3>; status = "okay"; }; can1: can@80034000 { pinctrl-names = "default"; pinctrl-0 = <&can1_pins_a>; + xceiver-supply = <®_can_3v3>; status = "okay"; }; };
@@ -320,6 +322,16 @@ gpio = <&gpio3 30 0>; 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 {
arch/arm/mach-mxs/mach-mxs.c +1 -49
77 lines not on this page · raw message
drivers/net/can/flexcan.c +13 -12
@@ -24,7 +24,6 @@#include <linux/can/dev.h> #include <linux/can/error.h> #include <linux/can/led.h> -#include <linux/can/platform/flexcan.h> #include <linux/clk.h> #include <linux/delay.h> #include <linux/if_arp.h>
@@ -37,6 +36,7 @@#include <linux/of.h> #include <linux/of_device.h> #include <linux/platform_device.h> +#include <linux/regulator/consumer.h> #define DRV_NAME "flexcan"
@@ -211,6 +211,7 @@ struct flexcan_priv {struct clk *clk_per;struct flexcan_platform_data *pdata;const struct flexcan_devtype_data *devtype_data; +struct regulator *reg_xceiver; };static struct flexcan_devtype_data fsl_p1010_devtype_data = {
@@ -258,15 +259,6 @@ static inline void flexcan_write(u32 val, void __iomem *addr) }#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,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 )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 */ 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 ;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 ;return ;
@@ -1084,6 +1081,10 @@ static int flexcan_probe(struct platform_device *pdev) priv->pdata = pdev->dev.platform_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 );dev_set_drvdata (&pdev->dev, dev);
Signature · 1 line
1.8.1.2
Marc Kleine-Budde
maintainerRe: [PATCH 2/3] flexcan: Use a regulator to control the CAN transceiver
Quoted 10 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
Instead of using a GPIO to turn on/off the CAN transceiver, it is better to use a regulator as some systems may use a PMIC to power the CAN transceiver.
Signed-off-by Fabio Estevam <[email protected]>---
Marc/Shawn,Only boot tested. I haven't tested CAN operation.
Can you test on real hardware? I don't have access to an evk until Monday.
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
Fabio Estevam
reviewerRe: [PATCH 2/3] flexcan: Use a regulator to control the CAN transceiver
Hi Marc,
Quoted 6 lines · Marc Kleine-Budde
Quoted 5 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
Instead of using a GPIO to turn on/off the CAN transceiver, it is better to use a regulator as some systems may use a PMIC to power the CAN transceiver.
Quoted 7 lines
Quoted 5 lines
Signed-off-by Fabio Estevam <[email protected]>---
Marc/Shawn,Only boot tested. I haven't tested CAN operation.
Can you test on real hardware? I don't have access to an evk until Monday.
I am currently working on another customer issue and not able to work on this during this week.
Regards,
Fabio Estevam
Fabio Estevam
reviewerPATCH 3/3 flexcan: Remove platform file
In reply to Fabio EstevamFrom: Fabio Estevam <[email protected]>
As there are no more users of the flexcan platform file, let's remove it.
--- include/linux/can/platform/flexcan.h | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 include/linux/can/platform/flexcan.h
include/linux/can/platform/flexcan.h deleted +0 -0
Signature · 1 line
1.8.1.2
Marc Kleine-Budde
maintainerQuoted 11 lines · Fabio Estevam
From: Marc Kleine-Budde <[email protected]>
As there are no imx in-tree users of
flexcan_platform_data, this patch removes the possibility to register a flexcan device with platform data.The functionality to swith on/off CAN transceivers is added to DT via regulators on a later patch.
Compile time tested with
imx_v4_v5_defconfigandimx_v6_v7_defconfig.Signed-off-by Marc Kleine-Budde <[email protected]>
Nitpick: Don't forget to add your S-o-b when posting patches from other people ;)
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |