diff options
author | Fabio Estevam <fabio.estevam@freescale.com> | 2013-06-10 22:12:57 -0400 |
---|---|---|
committer | Marc Kleine-Budde <mkl@pengutronix.de> | 2013-06-27 09:15:25 -0400 |
commit | b7c4114b07bbacfe0aee1d04ad1ade9e42309620 (patch) | |
tree | c21e4f17d4149674db3761dd782c3f8056662f81 /arch/arm | |
parent | 30caa4b763bf5973800633de55bae586ab443f78 (diff) |
can: flexcan: Use a regulator to control the CAN transceiver
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.
Acked-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/boot/dts/imx28-evk.dts | 12 | ||||
-rw-r--r-- | arch/arm/mach-mxs/mach-mxs.c | 50 |
2 files changed, 13 insertions, 49 deletions
diff --git a/arch/arm/boot/dts/imx28-evk.dts b/arch/arm/boot/dts/imx28-evk.dts index 3637bf3b1d59..1f0d38d7b16f 100644 --- a/arch/arm/boot/dts/imx28-evk.dts +++ b/arch/arm/boot/dts/imx28-evk.dts | |||
@@ -155,12 +155,14 @@ | |||
155 | can0: can@80032000 { | 155 | can0: can@80032000 { |
156 | pinctrl-names = "default"; | 156 | pinctrl-names = "default"; |
157 | pinctrl-0 = <&can0_pins_a>; | 157 | pinctrl-0 = <&can0_pins_a>; |
158 | xceiver-supply = <®_can_3v3>; | ||
158 | status = "okay"; | 159 | status = "okay"; |
159 | }; | 160 | }; |
160 | 161 | ||
161 | can1: can@80034000 { | 162 | can1: can@80034000 { |
162 | pinctrl-names = "default"; | 163 | pinctrl-names = "default"; |
163 | pinctrl-0 = <&can1_pins_a>; | 164 | pinctrl-0 = <&can1_pins_a>; |
165 | xceiver-supply = <®_can_3v3>; | ||
164 | status = "okay"; | 166 | status = "okay"; |
165 | }; | 167 | }; |
166 | }; | 168 | }; |
@@ -319,6 +321,16 @@ | |||
319 | gpio = <&gpio3 30 0>; | 321 | gpio = <&gpio3 30 0>; |
320 | enable-active-high; | 322 | enable-active-high; |
321 | }; | 323 | }; |
324 | |||
325 | reg_can_3v3: can-3v3 { | ||
326 | compatible = "regulator-fixed"; | ||
327 | regulator-name = "can-3v3"; | ||
328 | regulator-min-microvolt = <3300000>; | ||
329 | regulator-max-microvolt = <3300000>; | ||
330 | gpio = <&gpio2 13 0>; | ||
331 | enable-active-high; | ||
332 | }; | ||
333 | |||
322 | }; | 334 | }; |
323 | 335 | ||
324 | sound { | 336 | sound { |
diff --git a/arch/arm/mach-mxs/mach-mxs.c b/arch/arm/mach-mxs/mach-mxs.c index 5b62b6489d4b..97b8a44101cd 100644 --- a/arch/arm/mach-mxs/mach-mxs.c +++ b/arch/arm/mach-mxs/mach-mxs.c | |||
@@ -14,7 +14,6 @@ | |||
14 | #include <linux/clk/mxs.h> | 14 | #include <linux/clk/mxs.h> |
15 | #include <linux/clkdev.h> | 15 | #include <linux/clkdev.h> |
16 | #include <linux/clocksource.h> | 16 | #include <linux/clocksource.h> |
17 | #include <linux/can/platform/flexcan.h> | ||
18 | #include <linux/delay.h> | 17 | #include <linux/delay.h> |
19 | #include <linux/err.h> | 18 | #include <linux/err.h> |
20 | #include <linux/gpio.h> | 19 | #include <linux/gpio.h> |
@@ -60,41 +59,6 @@ static inline void __mxs_togl(u32 mask, void __iomem *reg) | |||
60 | __raw_writel(mask, reg + MXS_TOG_ADDR); | 59 | __raw_writel(mask, reg + MXS_TOG_ADDR); |
61 | } | 60 | } |
62 | 61 | ||
63 | /* | ||
64 | * MX28EVK_FLEXCAN_SWITCH is shared between both flexcan controllers | ||
65 | */ | ||
66 | #define MX28EVK_FLEXCAN_SWITCH MXS_GPIO_NR(2, 13) | ||
67 | |||
68 | static int flexcan0_en, flexcan1_en; | ||
69 | |||
70 | static void mx28evk_flexcan_switch(void) | ||
71 | { | ||
72 | if (flexcan0_en || flexcan1_en) | ||
73 | gpio_set_value(MX28EVK_FLEXCAN_SWITCH, 1); | ||
74 | else | ||
75 | gpio_set_value(MX28EVK_FLEXCAN_SWITCH, 0); | ||
76 | } | ||
77 | |||
78 | static void mx28evk_flexcan0_switch(int enable) | ||
79 | { | ||
80 | flexcan0_en = enable; | ||
81 | mx28evk_flexcan_switch(); | ||
82 | } | ||
83 | |||
84 | static void mx28evk_flexcan1_switch(int enable) | ||
85 | { | ||
86 | flexcan1_en = enable; | ||
87 | mx28evk_flexcan_switch(); | ||
88 | } | ||
89 | |||
90 | static struct flexcan_platform_data flexcan_pdata[2]; | ||
91 | |||
92 | static struct of_dev_auxdata mxs_auxdata_lookup[] __initdata = { | ||
93 | OF_DEV_AUXDATA("fsl,imx28-flexcan", 0x80032000, NULL, &flexcan_pdata[0]), | ||
94 | OF_DEV_AUXDATA("fsl,imx28-flexcan", 0x80034000, NULL, &flexcan_pdata[1]), | ||
95 | { /* sentinel */ } | ||
96 | }; | ||
97 | |||
98 | #define OCOTP_WORD_OFFSET 0x20 | 62 | #define OCOTP_WORD_OFFSET 0x20 |
99 | #define OCOTP_WORD_COUNT 0x20 | 63 | #define OCOTP_WORD_COUNT 0x20 |
100 | 64 | ||
@@ -254,15 +218,6 @@ static void __init imx28_evk_init(void) | |||
254 | mxs_saif_clkmux_select(MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR0); | 218 | mxs_saif_clkmux_select(MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR0); |
255 | } | 219 | } |
256 | 220 | ||
257 | static void __init imx28_evk_post_init(void) | ||
258 | { | ||
259 | if (!gpio_request_one(MX28EVK_FLEXCAN_SWITCH, GPIOF_DIR_OUT, | ||
260 | "flexcan-switch")) { | ||
261 | flexcan_pdata[0].transceiver_switch = mx28evk_flexcan0_switch; | ||
262 | flexcan_pdata[1].transceiver_switch = mx28evk_flexcan1_switch; | ||
263 | } | ||
264 | } | ||
265 | |||
266 | static int apx4devkit_phy_fixup(struct phy_device *phy) | 221 | static int apx4devkit_phy_fixup(struct phy_device *phy) |
267 | { | 222 | { |
268 | phy->dev_flags |= MICREL_PHY_50MHZ_CLK; | 223 | phy->dev_flags |= MICREL_PHY_50MHZ_CLK; |
@@ -374,13 +329,10 @@ static void __init mxs_machine_init(void) | |||
374 | cfa10049_init(); | 329 | cfa10049_init(); |
375 | 330 | ||
376 | of_platform_populate(NULL, of_default_bus_match_table, | 331 | of_platform_populate(NULL, of_default_bus_match_table, |
377 | mxs_auxdata_lookup, NULL); | 332 | NULL, NULL); |
378 | 333 | ||
379 | if (of_machine_is_compatible("karo,tx28")) | 334 | if (of_machine_is_compatible("karo,tx28")) |
380 | tx28_post_init(); | 335 | tx28_post_init(); |
381 | |||
382 | if (of_machine_is_compatible("fsl,imx28-evk")) | ||
383 | imx28_evk_post_init(); | ||
384 | } | 336 | } |
385 | 337 | ||
386 | #define MX23_CLKCTRL_RESET_OFFSET 0x120 | 338 | #define MX23_CLKCTRL_RESET_OFFSET 0x120 |