aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/sysdev
diff options
context:
space:
mode:
authorAnton Vorontsov <avorontsov@ru.mvista.com>2008-01-24 10:40:07 -0500
committerKumar Gala <galak@kernel.crashing.org>2008-01-28 09:32:58 -0500
commitf3a2b29d932fbf92e133d814c4873fd15be51abc (patch)
treedf6c2c960540b0f648d2ae3e3648111d500b97c0 /arch/powerpc/sysdev
parent59a0ea5091d309fa8338954b84cf5307dbd83ec9 (diff)
[POWERPC] fsl_spi: stop using device_type = "spi"
Also: - rename "fsl_spi" to "fsl,spi"; - add and use cell-index property, if found; - split probing code out of fsl_spi_init, thus we can call it for legacy device_type probing and new "compatible" probing. Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/sysdev')
-rw-r--r--arch/powerpc/sysdev/fsl_soc.c98
1 files changed, 60 insertions, 38 deletions
diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index 6f81dd5eb6d4..e48b20e934ca 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -1276,44 +1276,17 @@ arch_initcall(cpm_smc_uart_of_init);
1276#endif /* CONFIG_8xx */ 1276#endif /* CONFIG_8xx */
1277#endif /* CONFIG_PPC_CPM_NEW_BINDING */ 1277#endif /* CONFIG_PPC_CPM_NEW_BINDING */
1278 1278
1279int __init fsl_spi_init(struct spi_board_info *board_infos, 1279static int __init of_fsl_spi_probe(char *type, char *compatible, u32 sysclk,
1280 unsigned int num_board_infos, 1280 struct spi_board_info *board_infos,
1281 void (*activate_cs)(u8 cs, u8 polarity), 1281 unsigned int num_board_infos,
1282 void (*deactivate_cs)(u8 cs, u8 polarity)) 1282 void (*activate_cs)(u8 cs, u8 polarity),
1283 void (*deactivate_cs)(u8 cs, u8 polarity))
1283{ 1284{
1284 struct device_node *np; 1285 struct device_node *np;
1285 unsigned int i; 1286 unsigned int i = 0;
1286 u32 sysclk = -1;
1287
1288 /* SPI controller is either clocked from QE or SoC clock */
1289#ifdef CONFIG_QUICC_ENGINE
1290 sysclk = get_brgfreq();
1291#endif
1292 if (sysclk == -1) {
1293 const u32 *freq;
1294 int size;
1295
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 }
1308
1309 sysclk = *freq;
1310 of_node_put(np);
1311 }
1312 1287
1313 for (np = NULL, i = 1; 1288 for_each_compatible_node(np, type, compatible) {
1314 (np = of_find_compatible_node(np, "spi", "fsl_spi")) != NULL; 1289 int ret;
1315 i++) {
1316 int ret = 0;
1317 unsigned int j; 1290 unsigned int j;
1318 const void *prop; 1291 const void *prop;
1319 struct resource res[2]; 1292 struct resource res[2];
@@ -1332,6 +1305,10 @@ int __init fsl_spi_init(struct spi_board_info *board_infos,
1332 goto err; 1305 goto err;
1333 pdata.bus_num = *(u32 *)prop; 1306 pdata.bus_num = *(u32 *)prop;
1334 1307
1308 prop = of_get_property(np, "cell-index", NULL);
1309 if (prop)
1310 i = *(u32 *)prop;
1311
1335 prop = of_get_property(np, "mode", NULL); 1312 prop = of_get_property(np, "mode", NULL);
1336 if (prop && !strcmp(prop, "cpu-qe")) 1313 if (prop && !strcmp(prop, "cpu-qe"))
1337 pdata.qe_mode = 1; 1314 pdata.qe_mode = 1;
@@ -1342,7 +1319,7 @@ int __init fsl_spi_init(struct spi_board_info *board_infos,
1342 } 1319 }
1343 1320
1344 if (!pdata.max_chipselect) 1321 if (!pdata.max_chipselect)
1345 goto err; 1322 continue;
1346 1323
1347 ret = of_address_to_resource(np, 0, &res[0]); 1324 ret = of_address_to_resource(np, 0, &res[0]);
1348 if (ret) 1325 if (ret)
@@ -1369,13 +1346,58 @@ int __init fsl_spi_init(struct spi_board_info *board_infos,
1369 if (ret) 1346 if (ret)
1370 goto unreg; 1347 goto unreg;
1371 1348
1372 continue; 1349 goto next;
1373unreg: 1350unreg:
1374 platform_device_del(pdev); 1351 platform_device_del(pdev);
1375err: 1352err:
1376 continue; 1353 pr_err("%s: registration failed\n", np->full_name);
1354next:
1355 i++;
1377 } 1356 }
1378 1357
1358 return i;
1359}
1360
1361int __init fsl_spi_init(struct spi_board_info *board_infos,
1362 unsigned int num_board_infos,
1363 void (*activate_cs)(u8 cs, u8 polarity),
1364 void (*deactivate_cs)(u8 cs, u8 polarity))
1365{
1366 u32 sysclk = -1;
1367 int ret;
1368
1369#ifdef CONFIG_QUICC_ENGINE
1370 /* SPI controller is either clocked from QE or SoC clock */
1371 sysclk = get_brgfreq();
1372#endif
1373 if (sysclk == -1) {
1374 struct device_node *np;
1375 const u32 *freq;
1376 int size;
1377
1378 np = of_find_node_by_type(NULL, "soc");
1379 if (!np)
1380 return -ENODEV;
1381
1382 freq = of_get_property(np, "clock-frequency", &size);
1383 if (!freq || size != sizeof(*freq) || *freq == 0) {
1384 freq = of_get_property(np, "bus-frequency", &size);
1385 if (!freq || size != sizeof(*freq) || *freq == 0) {
1386 of_node_put(np);
1387 return -ENODEV;
1388 }
1389 }
1390
1391 sysclk = *freq;
1392 of_node_put(np);
1393 }
1394
1395 ret = of_fsl_spi_probe(NULL, "fsl,spi", sysclk, board_infos,
1396 num_board_infos, activate_cs, deactivate_cs);
1397 if (!ret)
1398 of_fsl_spi_probe("spi", "fsl_spi", sysclk, board_infos,
1399 num_board_infos, activate_cs, deactivate_cs);
1400
1379 return spi_register_board_info(board_infos, num_board_infos); 1401 return spi_register_board_info(board_infos, num_board_infos);
1380} 1402}
1381 1403