Skip to content

Commit 35a9f93

Browse files
spectrum70Greg Ungerer
authored andcommitted
m68k: m5441x: add flexcan support
Add flexcan support. Signed-off-by: Angelo Dureghello <[email protected]> Made the flexcan resource inclusion conditional based on the enablement of the flexcan driver. This commit is no longer dependant on the presence of the updated driver in mainline. Signed-off-by: Greg Ungerer <[email protected]>
1 parent 40cff49 commit 35a9f93

File tree

3 files changed

+67
-4
lines changed

3 files changed

+67
-4
lines changed

arch/m68k/coldfire/device.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,47 @@ static struct platform_device mcf_esdhc = {
581581
};
582582
#endif /* MCFSDHC_BASE */
583583

584+
#if IS_ENABLED(CONFIG_CAN_FLEXCAN)
585+
586+
#include <linux/can/platform/flexcan.h>
587+
588+
static struct flexcan_platform_data mcf5441x_flexcan_info = {
589+
.clk_src = 1,
590+
.clock_frequency = 120000000,
591+
};
592+
593+
static struct resource mcf5441x_flexcan0_resource[] = {
594+
{
595+
.start = MCFFLEXCAN_BASE0,
596+
.end = MCFFLEXCAN_BASE0 + MCFFLEXCAN_SIZE,
597+
.flags = IORESOURCE_MEM,
598+
},
599+
{
600+
.start = MCF_IRQ_IFL0,
601+
.end = MCF_IRQ_IFL0,
602+
.flags = IORESOURCE_IRQ,
603+
},
604+
{
605+
.start = MCF_IRQ_BOFF0,
606+
.end = MCF_IRQ_BOFF0,
607+
.flags = IORESOURCE_IRQ,
608+
},
609+
{
610+
.start = MCF_IRQ_ERR0,
611+
.end = MCF_IRQ_ERR0,
612+
.flags = IORESOURCE_IRQ,
613+
},
614+
};
615+
616+
static struct platform_device mcf_flexcan0 = {
617+
.name = "flexcan-mcf5441x",
618+
.id = 0,
619+
.num_resources = ARRAY_SIZE(mcf5441x_flexcan0_resource),
620+
.resource = mcf5441x_flexcan0_resource,
621+
.dev.platform_data = &mcf5441x_flexcan_info,
622+
};
623+
#endif /* IS_ENABLED(CONFIG_CAN_FLEXCAN) */
624+
584625
static struct platform_device *mcf_devices[] __initdata = {
585626
&mcf_uart,
586627
#if IS_ENABLED(CONFIG_FEC)
@@ -616,6 +657,9 @@ static struct platform_device *mcf_devices[] __initdata = {
616657
#ifdef MCFSDHC_BASE
617658
&mcf_esdhc,
618659
#endif
660+
#if IS_ENABLED(CONFIG_CAN_FLEXCAN)
661+
&mcf_flexcan0,
662+
#endif
619663
};
620664

621665
/*

arch/m68k/coldfire/m5441x.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#include <asm/mcfclk.h>
2020

2121
DEFINE_CLK(0, "flexbus", 2, MCF_CLK);
22-
DEFINE_CLK(0, "mcfcan.0", 8, MCF_CLK);
23-
DEFINE_CLK(0, "mcfcan.1", 9, MCF_CLK);
22+
DEFINE_CLK(0, "flexcan.0", 8, MCF_CLK);
23+
DEFINE_CLK(0, "flexcan.1", 9, MCF_CLK);
2424
DEFINE_CLK(0, "imx1-i2c.1", 14, MCF_CLK);
2525
DEFINE_CLK(0, "mcfdspi.1", 15, MCF_CLK);
2626
DEFINE_CLK(0, "edma", 17, MCF_CLK);
@@ -142,6 +142,8 @@ static struct clk_lookup m5411x_clk_lookup[] = {
142142

143143
static struct clk * const enable_clks[] __initconst = {
144144
/* make sure these clocks are enabled */
145+
&__clk_0_8, /* flexcan.0 */
146+
&__clk_0_9, /* flexcan.1 */
145147
&__clk_0_15, /* dspi.1 */
146148
&__clk_0_17, /* eDMA */
147149
&__clk_0_18, /* intc0 */
@@ -162,8 +164,6 @@ static struct clk * const enable_clks[] __initconst = {
162164
&__clk_1_37, /* gpio */
163165
};
164166
static struct clk * const disable_clks[] __initconst = {
165-
&__clk_0_8, /* can.0 */
166-
&__clk_0_9, /* can.1 */
167167
&__clk_0_14, /* i2c.1 */
168168
&__clk_0_22, /* i2c.0 */
169169
&__clk_0_23, /* dspi.0 */

arch/m68k/include/asm/m5441xsim.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@
7373
#define MCFINT0_FECENTC1 55
7474

7575
/* on interrupt controller 1 */
76+
#define MCFINT1_FLEXCAN0_IFL 0
77+
#define MCFINT1_FLEXCAN0_BOFF 1
78+
#define MCFINT1_FLEXCAN0_ERR 3
79+
#define MCFINT1_FLEXCAN1_IFL 4
80+
#define MCFINT1_FLEXCAN1_BOFF 5
81+
#define MCFINT1_FLEXCAN1_ERR 7
7682
#define MCFINT1_UART4 48
7783
#define MCFINT1_UART5 49
7884
#define MCFINT1_UART6 50
@@ -314,4 +320,17 @@
314320
#define MCF_IRQ_SDHC (MCFINT2_VECBASE + MCFINT2_SDHC)
315321
#define MCFSDHC_CLK (MCFSDHC_BASE + 0x2c)
316322

323+
/*
324+
* Flexcan module
325+
*/
326+
#define MCFFLEXCAN_BASE0 0xfc020000
327+
#define MCFFLEXCAN_BASE1 0xfc024000
328+
#define MCFFLEXCAN_SIZE 0x4000
329+
#define MCF_IRQ_IFL0 (MCFINT1_VECBASE + MCFINT1_FLEXCAN0_IFL)
330+
#define MCF_IRQ_BOFF0 (MCFINT1_VECBASE + MCFINT1_FLEXCAN0_BOFF)
331+
#define MCF_IRQ_ERR0 (MCFINT1_VECBASE + MCFINT1_FLEXCAN0_ERR)
332+
#define MCF_IRQ_IFL1 (MCFINT1_VECBASE + MCFINT1_FLEXCAN1_IFL)
333+
#define MCF_IRQ_BOFF1 (MCFINT1_VECBASE + MCFINT1_FLEXCAN1_BOFF)
334+
#define MCF_IRQ_ERR1 (MCFINT1_VECBASE + MCFINT1_FLEXCAN1_ERR)
335+
317336
#endif /* m5441xsim_h */

0 commit comments

Comments
 (0)