[POWERPC] fsl_spi: stop using device_type = "spi"
authorAnton Vorontsov <avorontsov@ru.mvista.com>
Thu, 24 Jan 2008 15:40:07 +0000 (18:40 +0300)
committerKumar Gala <galak@kernel.crashing.org>
Mon, 28 Jan 2008 14:32:58 +0000 (08:32 -0600)
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>
14 files changed:
Documentation/powerpc/booting-without-of.txt
arch/powerpc/boot/dts/mpc8313erdb.dts
arch/powerpc/boot/dts/mpc832x_mds.dts
arch/powerpc/boot/dts/mpc832x_rdb.dts
arch/powerpc/boot/dts/mpc8349emitx.dts
arch/powerpc/boot/dts/mpc8349emitxgp.dts
arch/powerpc/boot/dts/mpc834x_mds.dts
arch/powerpc/boot/dts/mpc836x_mds.dts
arch/powerpc/boot/dts/mpc8377_mds.dts
arch/powerpc/boot/dts/mpc8378_mds.dts
arch/powerpc/boot/dts/mpc8379_mds.dts
arch/powerpc/boot/dts/mpc8568mds.dts
arch/powerpc/boot/dts/sbc8349.dts
arch/powerpc/sysdev/fsl_soc.c

index 470cbc0cfcebfe45e20e5eda44f37ddc4ae01a10..b5e46efeba84bd3715cfea3cf5d4c84be6010332 100644 (file)
@@ -1568,8 +1568,8 @@ platforms are moved over to use the flattened-device-tree model.
    ii) SPI (Serial Peripheral Interface)
 
    Required properties:
-   - device_type : should be "spi".
-   - compatible : should be "fsl_spi".
+   - cell-index : SPI controller index.
+   - compatible : should be "fsl,spi".
    - mode : the SPI operation mode, it can be "cpu" or "cpu-qe".
    - reg : Offset and length of the register set for the device
    - interrupts : <a b> where a is the interrupt number and b is a
@@ -1582,8 +1582,8 @@ platforms are moved over to use the flattened-device-tree model.
 
    Example:
        spi@4c0 {
-               device_type = "spi";
-               compatible = "fsl_spi";
+               cell-index = <0>;
+               compatible = "fsl,spi";
                reg = <4c0 40>;
                interrupts = <82 0>;
                interrupt-parent = <700>;
index 9bcf2c92541f60665fa77e051a72a6f3713458be..20a03f5b5bb7f45164e7f5d0d34e92b209737bda 100644 (file)
                };
 
                spi@7000 {
-                       device_type = "spi";
-                       compatible = "fsl_spi";
+                       cell-index = <0>;
+                       compatible = "fsl,spi";
                        reg = <7000 1000>;
                        interrupts = <10 8>;
                        interrupt-parent = < &ipic >;
index 1bb75ef389ff53655e8c8d41082a77da6da97a65..15bb3459ff8a8e6d505643bd1e1062f087d8d654 100644 (file)
                };
 
                spi@4c0 {
-                       device_type = "spi";
-                       compatible = "fsl_spi";
+                       cell-index = <0>;
+                       compatible = "fsl,spi";
                        reg = <4c0 40>;
                        interrupts = <2>;
                        interrupt-parent = < &qeic >;
                };
 
                spi@500 {
-                       device_type = "spi";
-                       compatible = "fsl_spi";
+                       cell-index = <1>;
+                       compatible = "fsl,spi";
                        reg = <500 40>;
                        interrupts = <1>;
                        interrupt-parent = < &qeic >;
index f6a86336c8e0700149478cea13b18e6500e89dae..f086fac5921995a9c3f178516adc0a5e1b48eba5 100644 (file)
                };
 
                spi@4c0 {
-                       device_type = "spi";
-                       compatible = "fsl_spi";
+                       cell-index = <0>;
+                       compatible = "fsl,spi";
                        reg = <4c0 40>;
                        interrupts = <2>;
                        interrupt-parent = <&qeic>;
                };
 
                spi@500 {
-                       device_type = "spi";
-                       compatible = "fsl_spi";
+                       cell-index = <1>;
+                       compatible = "fsl,spi";
                        reg = <500 40>;
                        interrupts = <1>;
                        interrupt-parent = <&qeic>;
index 04b8da4deb6059247162bd888799f1cb928daf25..4a4ddea2d99c74be6f021e22f17f8b2e71d464b5 100644 (file)
@@ -82,8 +82,8 @@
                };
 
                spi@7000 {
-                       device_type = "spi";
-                       compatible = "fsl_spi";
+                       cell-index = <0>;
+                       compatible = "fsl,spi";
                        reg = <7000 1000>;
                        interrupts = <10 8>;
                        interrupt-parent = < &ipic >;
index a06ff92cf0b117d1d64c2a1361d1bf877da572e9..79983d74eee486be90ec8db6464e7b22c0cfb38b 100644 (file)
@@ -80,8 +80,8 @@
                };
 
                spi@7000 {
-                       device_type = "spi";
-                       compatible = "fsl_spi";
+                       cell-index = <0>;
+                       compatible = "fsl,spi";
                        reg = <7000 1000>;
                        interrupts = <10 8>;
                        interrupt-parent = < &ipic >;
index d2c0e8ab8b7c282b423c3bbdd2ee0e5d8262385b..8faa8bd6ed64aada0cb2af3fa9fff3c65ee2eb7b 100644 (file)
@@ -95,8 +95,8 @@
                };
 
                spi@7000 {
-                       device_type = "spi";
-                       compatible = "fsl_spi";
+                       cell-index = <0>;
+                       compatible = "fsl,spi";
                        reg = <0x7000 0x1000>;
                        interrupts = <16 8>;
                        interrupt-parent = <&ipic>;
index fa98bdf0de8c089c210e2ab3e2ff55574eb72827..d3b8262df686b830ba921297bb1ba46d87ad9590 100644 (file)
                };
 
                spi@4c0 {
-                       device_type = "spi";
-                       compatible = "fsl_spi";
+                       cell-index = <0>;
+                       compatible = "fsl,spi";
                        reg = <4c0 40>;
                        interrupts = <2>;
                        interrupt-parent = < &qeic >;
                };
 
                spi@500 {
-                       device_type = "spi";
-                       compatible = "fsl_spi";
+                       cell-index = <1>;
+                       compatible = "fsl,spi";
                        reg = <500 40>;
                        interrupts = <1>;
                        interrupt-parent = < &qeic >;
index 98b46065f45adbd16cbe191b219c311744064a39..3b9611f189e1db7a1a5067a1f1eb420179ff4937 100644 (file)
@@ -83,7 +83,8 @@
                };
 
                spi@7000 {
-                       compatible = "fsl_spi";
+                       cell-index = <0>;
+                       compatible = "fsl,spi";
                        reg = <0x7000 0x1000>;
                        interrupts = <0x10 0x8>;
                        interrupt-parent = < &ipic >;
index c117a6a3a8e6319a7fcd28420549f1e918cb0ac7..386f4a037b339b58510904edab0187ea298023e2 100644 (file)
@@ -83,7 +83,8 @@
                };
 
                spi@7000 {
-                       compatible = "fsl_spi";
+                       cell-index = <0>;
+                       compatible = "fsl,spi";
                        reg = <0x7000 0x1000>;
                        interrupts = <0x10 0x8>;
                        interrupt-parent = < &ipic >;
index fc3ba79fb684ba83dc80306ba53c9d47d42f144d..da9931b6c5c03e865356f681cda827bfce083dd4 100644 (file)
@@ -83,7 +83,8 @@
                };
 
                spi@7000 {
-                       compatible = "fsl_spi";
+                       cell-index = <0>;
+                       compatible = "fsl,spi";
                        reg = <0x7000 0x1000>;
                        interrupts = <0x10 0x8>;
                        interrupt-parent = < &ipic >;
index 692d5bd81e70b1aea7c922f9846905ee9d480aff..c929fba7f39941661dda561c9d74191604f35bf6 100644 (file)
                };
 
                spi@4c0 {
-                       device_type = "spi";
-                       compatible = "fsl_spi";
+                       cell-index = <0>;
+                       compatible = "fsl,spi";
                        reg = <4c0 40>;
                        interrupts = <2>;
                        interrupt-parent = <&qeic>;
                };
 
                spi@500 {
-                       device_type = "spi";
-                       compatible = "fsl_spi";
+                       cell-index = <1>;
+                       compatible = "fsl,spi";
                        reg = <500 40>;
                        interrupts = <1>;
                        interrupt-parent = <&qeic>;
index 9c13c1a996406eb4485bbfd700bef81463c06a51..0934f54b2b43bb1108d34edc8d6e34ffa1b118d7 100644 (file)
@@ -87,7 +87,8 @@
                };
 
                spi@7000 {
-                       compatible = "fsl_spi";
+                       cell-index = <0>;
+                       compatible = "fsl,spi";
                        reg = <0x7000 0x1000>;
                        interrupts = <0x10 0x8>;
                        interrupt-parent = <&ipic>;
index 6f81dd5eb6d44ae2cd61cf46f3ea983abd3e8363..e48b20e934ca233e744be83b36744a15cbd7d6ad 100644 (file)
@@ -1276,44 +1276,17 @@ arch_initcall(cpm_smc_uart_of_init);
 #endif /* CONFIG_8xx */
 #endif /* CONFIG_PPC_CPM_NEW_BINDING */
 
-int __init fsl_spi_init(struct spi_board_info *board_infos,
-                       unsigned int num_board_infos,
-                       void (*activate_cs)(u8 cs, u8 polarity),
-                       void (*deactivate_cs)(u8 cs, u8 polarity))
+static int __init of_fsl_spi_probe(char *type, char *compatible, u32 sysclk,
+                                  struct spi_board_info *board_infos,
+                                  unsigned int num_board_infos,
+                                  void (*activate_cs)(u8 cs, u8 polarity),
+                                  void (*deactivate_cs)(u8 cs, u8 polarity))
 {
        struct device_node *np;
-       unsigned int i;
-       u32 sysclk = -1;
-
-       /* SPI controller is either clocked from QE or SoC clock */
-#ifdef CONFIG_QUICC_ENGINE
-       sysclk = get_brgfreq();
-#endif
-       if (sysclk == -1) {
-               const u32 *freq;
-               int size;
-
-               np = of_find_node_by_type(NULL, "soc");
-               if (!np)
-                       return -ENODEV;
-
-               freq = of_get_property(np, "clock-frequency", &size);
-               if (!freq || size != sizeof(*freq) || *freq == 0) {
-                       freq = of_get_property(np, "bus-frequency", &size);
-                       if (!freq || size != sizeof(*freq) || *freq == 0) {
-                               of_node_put(np);
-                               return -ENODEV;
-                       }
-               }
-
-               sysclk = *freq;
-               of_node_put(np);
-       }
+       unsigned int i = 0;
 
-       for (np = NULL, i = 1;
-            (np = of_find_compatible_node(np, "spi", "fsl_spi")) != NULL;
-            i++) {
-               int ret = 0;
+       for_each_compatible_node(np, type, compatible) {
+               int ret;
                unsigned int j;
                const void *prop;
                struct resource res[2];
@@ -1332,6 +1305,10 @@ int __init fsl_spi_init(struct spi_board_info *board_infos,
                        goto err;
                pdata.bus_num = *(u32 *)prop;
 
+               prop = of_get_property(np, "cell-index", NULL);
+               if (prop)
+                       i = *(u32 *)prop;
+
                prop = of_get_property(np, "mode", NULL);
                if (prop && !strcmp(prop, "cpu-qe"))
                        pdata.qe_mode = 1;
@@ -1342,7 +1319,7 @@ int __init fsl_spi_init(struct spi_board_info *board_infos,
                }
 
                if (!pdata.max_chipselect)
-                       goto err;
+                       continue;
 
                ret = of_address_to_resource(np, 0, &res[0]);
                if (ret)
@@ -1369,13 +1346,58 @@ int __init fsl_spi_init(struct spi_board_info *board_infos,
                if (ret)
                        goto unreg;
 
-               continue;
+               goto next;
 unreg:
                platform_device_del(pdev);
 err:
-               continue;
+               pr_err("%s: registration failed\n", np->full_name);
+next:
+               i++;
        }
 
+       return i;
+}
+
+int __init fsl_spi_init(struct spi_board_info *board_infos,
+                       unsigned int num_board_infos,
+                       void (*activate_cs)(u8 cs, u8 polarity),
+                       void (*deactivate_cs)(u8 cs, u8 polarity))
+{
+       u32 sysclk = -1;
+       int ret;
+
+#ifdef CONFIG_QUICC_ENGINE
+       /* SPI controller is either clocked from QE or SoC clock */
+       sysclk = get_brgfreq();
+#endif
+       if (sysclk == -1) {
+               struct device_node *np;
+               const u32 *freq;
+               int size;
+
+               np = of_find_node_by_type(NULL, "soc");
+               if (!np)
+                       return -ENODEV;
+
+               freq = of_get_property(np, "clock-frequency", &size);
+               if (!freq || size != sizeof(*freq) || *freq == 0) {
+                       freq = of_get_property(np, "bus-frequency", &size);
+                       if (!freq || size != sizeof(*freq) || *freq == 0) {
+                               of_node_put(np);
+                               return -ENODEV;
+                       }
+               }
+
+               sysclk = *freq;
+               of_node_put(np);
+       }
+
+       ret = of_fsl_spi_probe(NULL, "fsl,spi", sysclk, board_infos,
+                              num_board_infos, activate_cs, deactivate_cs);
+       if (!ret)
+               of_fsl_spi_probe("spi", "fsl_spi", sysclk, board_infos,
+                                num_board_infos, activate_cs, deactivate_cs);
+
        return spi_register_board_info(board_infos, num_board_infos);
 }