diff options
author | Wolfram Sang <w.sang@pengutronix.de> | 2009-11-16 07:57:50 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-11-17 06:54:03 -0500 |
commit | 3f158c253214bb783e7072f6848b61c1999631e7 (patch) | |
tree | dd0cb414b696df9c6a65d302621f142c44389708 /drivers/net/can | |
parent | 68bd7422a2e07a4e5502137cd4bddb8c2774a912 (diff) |
net/can/mpc52xx_can: refactor clock-get routine
Merge two functions into one. The result is smaller as they can now share some
variables.
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/can')
-rw-r--r-- | drivers/net/can/mscan/mpc52xx_can.c | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/drivers/net/can/mscan/mpc52xx_can.c b/drivers/net/can/mscan/mpc52xx_can.c index 34ae2baec5d1..a915959b6b36 100644 --- a/drivers/net/can/mscan/mpc52xx_can.c +++ b/drivers/net/can/mscan/mpc52xx_can.c | |||
@@ -38,28 +38,37 @@ | |||
38 | 38 | ||
39 | static struct of_device_id mpc52xx_cdm_ids[] __devinitdata = { | 39 | static struct of_device_id mpc52xx_cdm_ids[] __devinitdata = { |
40 | { .compatible = "fsl,mpc5200-cdm", }, | 40 | { .compatible = "fsl,mpc5200-cdm", }, |
41 | { .compatible = "fsl,mpc5200b-cdm", }, | ||
42 | {} | 41 | {} |
43 | }; | 42 | }; |
44 | 43 | ||
45 | /* | 44 | /* |
46 | * Get the frequency of the external oscillator clock connected | 45 | * Get frequency of the MSCAN clock source |
47 | * to the SYS_XTAL_IN pin, or return 0 if it cannot be determined. | 46 | * |
47 | * Either the oscillator clock (SYS_XTAL_IN) or the IP bus clock (IP_CLK) | ||
48 | * can be selected. According to the MPC5200 user's manual, the oscillator | ||
49 | * clock is the better choice as it has less jitter but due to a hardware | ||
50 | * bug, it can not be selected for the old MPC5200 Rev. A chips. | ||
48 | */ | 51 | */ |
49 | static unsigned int __devinit mpc52xx_can_xtal_freq(struct of_device *of) | 52 | |
53 | static unsigned int __devinit mpc52xx_can_clock_freq(struct of_device *of, | ||
54 | int clock_src) | ||
50 | { | 55 | { |
56 | unsigned int pvr; | ||
51 | struct mpc52xx_cdm __iomem *cdm; | 57 | struct mpc52xx_cdm __iomem *cdm; |
52 | struct device_node *np_cdm; | 58 | struct device_node *np_cdm; |
53 | unsigned int freq; | 59 | unsigned int freq; |
54 | u32 val; | 60 | u32 val; |
55 | 61 | ||
62 | pvr = mfspr(SPRN_PVR); | ||
63 | |||
56 | freq = mpc5xxx_get_bus_frequency(of->node); | 64 | freq = mpc5xxx_get_bus_frequency(of->node); |
57 | if (!freq) | 65 | if (!freq) |
58 | return 0; | 66 | return 0; |
59 | 67 | ||
60 | /* | 68 | if (clock_src == MSCAN_CLKSRC_BUS || pvr == 0x80822011) |
61 | * Determine SYS_XTAL_IN frequency from the clock domain settings | 69 | return freq; |
62 | */ | 70 | |
71 | /* Determine SYS_XTAL_IN frequency from the clock domain settings */ | ||
63 | np_cdm = of_find_matching_node(NULL, mpc52xx_cdm_ids); | 72 | np_cdm = of_find_matching_node(NULL, mpc52xx_cdm_ids); |
64 | if (!np_cdm) { | 73 | if (!np_cdm) { |
65 | dev_err(&of->dev, "can't get clock node!\n"); | 74 | dev_err(&of->dev, "can't get clock node!\n"); |
@@ -80,28 +89,6 @@ static unsigned int __devinit mpc52xx_can_xtal_freq(struct of_device *of) | |||
80 | return freq; | 89 | return freq; |
81 | } | 90 | } |
82 | 91 | ||
83 | /* | ||
84 | * Get frequency of the MSCAN clock source | ||
85 | * | ||
86 | * Either the oscillator clock (SYS_XTAL_IN) or the IP bus clock (IP_CLK) | ||
87 | * can be selected. According to the MPC5200 user's manual, the oscillator | ||
88 | * clock is the better choice as it has less jitter but due to a hardware | ||
89 | * bug, it can not be selected for the old MPC5200 Rev. A chips. | ||
90 | */ | ||
91 | |||
92 | static unsigned int __devinit mpc52xx_can_clock_freq(struct of_device *of, | ||
93 | int clock_src) | ||
94 | { | ||
95 | unsigned int pvr; | ||
96 | |||
97 | pvr = mfspr(SPRN_PVR); | ||
98 | |||
99 | if (clock_src == MSCAN_CLKSRC_BUS || pvr == 0x80822011) | ||
100 | return mpc5xxx_get_bus_frequency(of->node); | ||
101 | |||
102 | return mpc52xx_can_xtal_freq(of); | ||
103 | } | ||
104 | |||
105 | static int __devinit mpc5xxx_can_probe(struct of_device *ofdev, | 92 | static int __devinit mpc5xxx_can_probe(struct of_device *ofdev, |
106 | const struct of_device_id *id) | 93 | const struct of_device_id *id) |
107 | { | 94 | { |