Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 81396
b: refs/heads/master
c: f3a2b29
h: refs/heads/master
v: v3
  • Loading branch information
Anton Vorontsov authored and Kumar Gala committed Jan 28, 2008
1 parent f3d786f commit ce778ef
Show file tree
Hide file tree
Showing 15 changed files with 97 additions and 71 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 59a0ea5091d309fa8338954b84cf5307dbd83ec9
refs/heads/master: f3a2b29d932fbf92e133d814c4873fd15be51abc
8 changes: 4 additions & 4 deletions trunk/Documentation/powerpc/booting-without-of.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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>;
Expand Down
4 changes: 2 additions & 2 deletions trunk/arch/powerpc/boot/dts/mpc8313erdb.dts
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@
};

spi@7000 {
device_type = "spi";
compatible = "fsl_spi";
cell-index = <0>;
compatible = "fsl,spi";
reg = <7000 1000>;
interrupts = <10 8>;
interrupt-parent = < &ipic >;
Expand Down
8 changes: 4 additions & 4 deletions trunk/arch/powerpc/boot/dts/mpc832x_mds.dts
Original file line number Diff line number Diff line change
Expand Up @@ -223,17 +223,17 @@
};

spi@4c0 {
device_type = "spi";
compatible = "fsl_spi";
cell-index = <0>;
compatible = "fsl,spi";
reg = <4c0 40>;
interrupts = <2>;
interrupt-parent = < &qeic >;
mode = "cpu";
};

spi@500 {
device_type = "spi";
compatible = "fsl_spi";
cell-index = <1>;
compatible = "fsl,spi";
reg = <500 40>;
interrupts = <1>;
interrupt-parent = < &qeic >;
Expand Down
8 changes: 4 additions & 4 deletions trunk/arch/powerpc/boot/dts/mpc832x_rdb.dts
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,17 @@
};

spi@4c0 {
device_type = "spi";
compatible = "fsl_spi";
cell-index = <0>;
compatible = "fsl,spi";
reg = <4c0 40>;
interrupts = <2>;
interrupt-parent = <&qeic>;
mode = "cpu-qe";
};

spi@500 {
device_type = "spi";
compatible = "fsl_spi";
cell-index = <1>;
compatible = "fsl,spi";
reg = <500 40>;
interrupts = <1>;
interrupt-parent = <&qeic>;
Expand Down
4 changes: 2 additions & 2 deletions trunk/arch/powerpc/boot/dts/mpc8349emitx.dts
Original file line number Diff line number Diff line change
Expand Up @@ -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 >;
Expand Down
4 changes: 2 additions & 2 deletions trunk/arch/powerpc/boot/dts/mpc8349emitxgp.dts
Original file line number Diff line number Diff line change
Expand Up @@ -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 >;
Expand Down
4 changes: 2 additions & 2 deletions trunk/arch/powerpc/boot/dts/mpc834x_mds.dts
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand Down
8 changes: 4 additions & 4 deletions trunk/arch/powerpc/boot/dts/mpc836x_mds.dts
Original file line number Diff line number Diff line change
Expand Up @@ -225,17 +225,17 @@
};

spi@4c0 {
device_type = "spi";
compatible = "fsl_spi";
cell-index = <0>;
compatible = "fsl,spi";
reg = <4c0 40>;
interrupts = <2>;
interrupt-parent = < &qeic >;
mode = "cpu";
};

spi@500 {
device_type = "spi";
compatible = "fsl_spi";
cell-index = <1>;
compatible = "fsl,spi";
reg = <500 40>;
interrupts = <1>;
interrupt-parent = < &qeic >;
Expand Down
3 changes: 2 additions & 1 deletion trunk/arch/powerpc/boot/dts/mpc8377_mds.dts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@
};

spi@7000 {
compatible = "fsl_spi";
cell-index = <0>;
compatible = "fsl,spi";
reg = <0x7000 0x1000>;
interrupts = <0x10 0x8>;
interrupt-parent = < &ipic >;
Expand Down
3 changes: 2 additions & 1 deletion trunk/arch/powerpc/boot/dts/mpc8378_mds.dts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@
};

spi@7000 {
compatible = "fsl_spi";
cell-index = <0>;
compatible = "fsl,spi";
reg = <0x7000 0x1000>;
interrupts = <0x10 0x8>;
interrupt-parent = < &ipic >;
Expand Down
3 changes: 2 additions & 1 deletion trunk/arch/powerpc/boot/dts/mpc8379_mds.dts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@
};

spi@7000 {
compatible = "fsl_spi";
cell-index = <0>;
compatible = "fsl,spi";
reg = <0x7000 0x1000>;
interrupts = <0x10 0x8>;
interrupt-parent = < &ipic >;
Expand Down
8 changes: 4 additions & 4 deletions trunk/arch/powerpc/boot/dts/mpc8568mds.dts
Original file line number Diff line number Diff line change
Expand Up @@ -302,17 +302,17 @@
};

spi@4c0 {
device_type = "spi";
compatible = "fsl_spi";
cell-index = <0>;
compatible = "fsl,spi";
reg = <4c0 40>;
interrupts = <2>;
interrupt-parent = <&qeic>;
mode = "cpu";
};

spi@500 {
device_type = "spi";
compatible = "fsl_spi";
cell-index = <1>;
compatible = "fsl,spi";
reg = <500 40>;
interrupts = <1>;
interrupt-parent = <&qeic>;
Expand Down
3 changes: 2 additions & 1 deletion trunk/arch/powerpc/boot/dts/sbc8349.dts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@
};

spi@7000 {
compatible = "fsl_spi";
cell-index = <0>;
compatible = "fsl,spi";
reg = <0x7000 0x1000>;
interrupts = <0x10 0x8>;
interrupt-parent = <&ipic>;
Expand Down
98 changes: 60 additions & 38 deletions trunk/arch/powerpc/sysdev/fsl_soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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;
Expand All @@ -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)
Expand All @@ -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);
}

Expand Down

0 comments on commit ce778ef

Please sign in to comment.