diff options
author | Anton Vorontsov <avorontsov@ru.mvista.com> | 2008-01-24 10:40:03 -0500 |
---|---|---|
committer | Kumar Gala <galak@kernel.crashing.org> | 2008-01-28 09:32:57 -0500 |
commit | 59a0ea5091d309fa8338954b84cf5307dbd83ec9 (patch) | |
tree | c1e1f43de7cdfa3ddde7d8f445eac008b08c60de | |
parent | d0a2f82da949283027a7da6a8b2a70ada46e7b55 (diff) |
spi_mpc83xx: use brg-frequency for SPI in QE
In case of QE we can use brg-frequency (which is qeclk/2).
Thus no need to divide sysclk in the spi_mpc83xx.
This patch also adds code to use get_brgfreq() on QE chips.
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
-rw-r--r-- | arch/powerpc/sysdev/fsl_soc.c | 46 | ||||
-rw-r--r-- | drivers/spi/spi_mpc83xx.c | 6 |
2 files changed, 34 insertions, 18 deletions
diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c index 26f7d83c4be5..6f81dd5eb6d4 100644 --- a/arch/powerpc/sysdev/fsl_soc.c +++ b/arch/powerpc/sysdev/fsl_soc.c | |||
@@ -75,7 +75,7 @@ phys_addr_t get_immrbase(void) | |||
75 | 75 | ||
76 | EXPORT_SYMBOL(get_immrbase); | 76 | EXPORT_SYMBOL(get_immrbase); |
77 | 77 | ||
78 | #if defined(CONFIG_CPM2) || defined(CONFIG_8xx) | 78 | #if defined(CONFIG_CPM2) || defined(CONFIG_QUICC_ENGINE) || defined(CONFIG_8xx) |
79 | 79 | ||
80 | static u32 brgfreq = -1; | 80 | static u32 brgfreq = -1; |
81 | 81 | ||
@@ -100,11 +100,21 @@ u32 get_brgfreq(void) | |||
100 | 100 | ||
101 | /* Legacy device binding -- will go away when no users are left. */ | 101 | /* Legacy device binding -- will go away when no users are left. */ |
102 | node = of_find_node_by_type(NULL, "cpm"); | 102 | node = of_find_node_by_type(NULL, "cpm"); |
103 | if (!node) | ||
104 | node = of_find_compatible_node(NULL, NULL, "fsl,qe"); | ||
105 | if (!node) | ||
106 | node = of_find_node_by_type(NULL, "qe"); | ||
107 | |||
103 | if (node) { | 108 | if (node) { |
104 | prop = of_get_property(node, "brg-frequency", &size); | 109 | prop = of_get_property(node, "brg-frequency", &size); |
105 | if (prop && size == 4) | 110 | if (prop && size == 4) |
106 | brgfreq = *prop; | 111 | brgfreq = *prop; |
107 | 112 | ||
113 | if (brgfreq == -1 || brgfreq == 0) { | ||
114 | prop = of_get_property(node, "bus-frequency", &size); | ||
115 | if (prop && size == 4) | ||
116 | brgfreq = *prop / 2; | ||
117 | } | ||
108 | of_node_put(node); | 118 | of_node_put(node); |
109 | } | 119 | } |
110 | 120 | ||
@@ -1273,22 +1283,32 @@ int __init fsl_spi_init(struct spi_board_info *board_infos, | |||
1273 | { | 1283 | { |
1274 | struct device_node *np; | 1284 | struct device_node *np; |
1275 | unsigned int i; | 1285 | unsigned int i; |
1276 | const u32 *sysclk; | 1286 | u32 sysclk = -1; |
1277 | 1287 | ||
1278 | /* SPI controller is either clocked from QE or SoC clock */ | 1288 | /* SPI controller is either clocked from QE or SoC clock */ |
1279 | np = of_find_compatible_node(NULL, NULL, "fsl,qe"); | 1289 | #ifdef CONFIG_QUICC_ENGINE |
1280 | if (!np) | 1290 | sysclk = get_brgfreq(); |
1281 | np = of_find_node_by_type(NULL, "qe"); | 1291 | #endif |
1292 | if (sysclk == -1) { | ||
1293 | const u32 *freq; | ||
1294 | int size; | ||
1282 | 1295 | ||
1283 | if (!np) | ||
1284 | np = of_find_node_by_type(NULL, "soc"); | 1296 | np = of_find_node_by_type(NULL, "soc"); |
1297 | if (!np) | ||
1298 | return -ENODEV; | ||
1299 | |||
1300 | freq = of_get_property(np, "clock-frequency", &size); | ||
1301 | if (!freq || size != sizeof(*freq) || *freq == 0) { | ||
1302 | freq = of_get_property(np, "bus-frequency", &size); | ||
1303 | if (!freq || size != sizeof(*freq) || *freq == 0) { | ||
1304 | of_node_put(np); | ||
1305 | return -ENODEV; | ||
1306 | } | ||
1307 | } | ||
1285 | 1308 | ||
1286 | if (!np) | 1309 | sysclk = *freq; |
1287 | return -ENODEV; | 1310 | of_node_put(np); |
1288 | 1311 | } | |
1289 | sysclk = of_get_property(np, "bus-frequency", NULL); | ||
1290 | if (!sysclk) | ||
1291 | return -ENODEV; | ||
1292 | 1312 | ||
1293 | for (np = NULL, i = 1; | 1313 | for (np = NULL, i = 1; |
1294 | (np = of_find_compatible_node(np, "spi", "fsl_spi")) != NULL; | 1314 | (np = of_find_compatible_node(np, "spi", "fsl_spi")) != NULL; |
@@ -1305,7 +1325,7 @@ int __init fsl_spi_init(struct spi_board_info *board_infos, | |||
1305 | 1325 | ||
1306 | memset(res, 0, sizeof(res)); | 1326 | memset(res, 0, sizeof(res)); |
1307 | 1327 | ||
1308 | pdata.sysclk = *sysclk; | 1328 | pdata.sysclk = sysclk; |
1309 | 1329 | ||
1310 | prop = of_get_property(np, "reg", NULL); | 1330 | prop = of_get_property(np, "reg", NULL); |
1311 | if (!prop) | 1331 | if (!prop) |
diff --git a/drivers/spi/spi_mpc83xx.c b/drivers/spi/spi_mpc83xx.c index 4580b9cf625d..04f7cd9fc261 100644 --- a/drivers/spi/spi_mpc83xx.c +++ b/drivers/spi/spi_mpc83xx.c | |||
@@ -436,11 +436,7 @@ static int __init mpc83xx_spi_probe(struct platform_device *dev) | |||
436 | mpc83xx_spi->qe_mode = pdata->qe_mode; | 436 | mpc83xx_spi->qe_mode = pdata->qe_mode; |
437 | mpc83xx_spi->get_rx = mpc83xx_spi_rx_buf_u8; | 437 | mpc83xx_spi->get_rx = mpc83xx_spi_rx_buf_u8; |
438 | mpc83xx_spi->get_tx = mpc83xx_spi_tx_buf_u8; | 438 | mpc83xx_spi->get_tx = mpc83xx_spi_tx_buf_u8; |
439 | 439 | mpc83xx_spi->spibrg = pdata->sysclk; | |
440 | if (mpc83xx_spi->qe_mode) | ||
441 | mpc83xx_spi->spibrg = pdata->sysclk / 2; | ||
442 | else | ||
443 | mpc83xx_spi->spibrg = pdata->sysclk; | ||
444 | 440 | ||
445 | mpc83xx_spi->rx_shift = 0; | 441 | mpc83xx_spi->rx_shift = 0; |
446 | mpc83xx_spi->tx_shift = 0; | 442 | mpc83xx_spi->tx_shift = 0; |