[PATCH] of: add bus-number specification to spi_mpc8xxx
Ernst Schwab
eschwab at online.de
Wed Feb 17 01:08:50 EST 2010
From: Ernst Schwab <eschwab at online.de>
Added devicetree parsing for SPI bus number. If no bus number is specified,
a dynamically assigned bus number will be used (typically 32766).
Signed-off-by: Ernst Schwab <eschwab at online.de>
---
diff -upr a/Documentation/powerpc/dts-bindings/fsl/spi.txt b/Documentation/powerpc/dts-bindings/fsl/spi.txt
--- a/Documentation/powerpc/dts-bindings/fsl/spi.txt
+++ b/Documentation/powerpc/dts-bindings/fsl/spi.txt
@@ -4,6 +4,8 @@ Required properties:
- cell-index : SPI controller index.
- compatible : should be "fsl,spi".
- mode : the SPI operation mode, it can be "cpu" or "cpu-qe".
+- bus-number : number of the SPI bus. If unspecified, a dynamically
+ assigned bus number will be used.
- reg : Offset and length of the register set for the device
- interrupts : <a b> where a is the interrupt number and b is a
field that represents an encoding of the sense and level
@@ -21,4 +23,5 @@ Example:
interrupts = <82 0>;
interrupt-parent = <700>;
mode = "cpu";
+ bus-number = <0>;
};
diff -upr a/drivers/spi/spi_mpc8xxx.c b/drivers/spi/spi_mpc8xxx.c
--- a/drivers/spi/spi_mpc8xxx.c
+++ b/drivers/spi/spi_mpc8xxx.c
@@ -1230,6 +1230,8 @@ static int __devinit of_mpc8xxx_spi_prob
struct resource mem;
struct resource irq;
const void *prop;
+ const int *bus_num;
+ int len;
int ret = -ENOMEM;
pinfo = kzalloc(sizeof(*pinfo), GFP_KERNEL);
@@ -1239,8 +1241,16 @@ static int __devinit of_mpc8xxx_spi_prob
pdata = &pinfo->pdata;
dev->platform_data = pdata;
- /* Allocate bus num dynamically. */
- pdata->bus_num = -1;
+
+ bus_num = of_get_property(np, "bus-number", &len);
+ if (bus_num && len == sizeof(*bus_num)) {
+ /* bus number is specified in node */
+ pdata->bus_num = *bus_num;
+ } else {
+ /* Allocate bus num dynamically. */
+ pdata->bus_num = -1;
+ }
+
/* SPI controller is either clocked from QE or SoC clock. */
pdata->sysclk = get_brgfreq();
More information about the devicetree-discuss
mailing list