diff options
author | Haiying Wang <Haiying.Wang@freescale.com> | 2009-05-01 15:40:48 -0400 |
---|---|---|
committer | Kumar Gala <galak@kernel.crashing.org> | 2009-05-19 01:50:24 -0400 |
commit | 98ca77af23da6682bb3e34961a3f32e2c064a4ce (patch) | |
tree | 7c022d718c8933d25cf59c71ace2683731f905e9 | |
parent | 345f84227b50e90329dd303499024603596566f4 (diff) |
powerpc/qe: update QE Serial Number
The latest QE chip may have more Serial Number(SNUM)s of thread to use. We
will get the number of SNUMs from device tree by reading the new property
"fsl,qe-num-snums", and set 28 as the default number of SNUMs so that it is
compatible with the old QE chips' device trees which don't have this new
property. The macro QE_NUM_OF_SNUM is defined as the maximum number in QE
snum table which is 256.
Also we update the snum_init[] array with 18 more new SNUMs which are
confirmed to be useful on new chip.
Signed-off-by: Haiying Wang <Haiying.Wang@freescale.com>
Acked-by: Timur Tabi <timur@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
-rw-r--r-- | Documentation/powerpc/dts-bindings/fsl/cpm_qe/qe.txt | 2 | ||||
-rw-r--r-- | arch/powerpc/include/asm/qe.h | 3 | ||||
-rw-r--r-- | arch/powerpc/sysdev/qe_lib/qe.c | 47 |
3 files changed, 47 insertions, 5 deletions
diff --git a/Documentation/powerpc/dts-bindings/fsl/cpm_qe/qe.txt b/Documentation/powerpc/dts-bindings/fsl/cpm_qe/qe.txt index 39b5d1f0bbe0..6e37be1eeb2d 100644 --- a/Documentation/powerpc/dts-bindings/fsl/cpm_qe/qe.txt +++ b/Documentation/powerpc/dts-bindings/fsl/cpm_qe/qe.txt | |||
@@ -18,6 +18,8 @@ Required properties: | |||
18 | - reg : offset and length of the device registers. | 18 | - reg : offset and length of the device registers. |
19 | - bus-frequency : the clock frequency for QUICC Engine. | 19 | - bus-frequency : the clock frequency for QUICC Engine. |
20 | - fsl,qe-num-riscs: define how many RISC engines the QE has. | 20 | - fsl,qe-num-riscs: define how many RISC engines the QE has. |
21 | - fsl,qe-num-snums: define how many serial number(SNUM) the QE can use for the | ||
22 | threads. | ||
21 | 23 | ||
22 | Recommended properties | 24 | Recommended properties |
23 | - brg-frequency : the internal clock source frequency for baud-rate | 25 | - brg-frequency : the internal clock source frequency for baud-rate |
diff --git a/arch/powerpc/include/asm/qe.h b/arch/powerpc/include/asm/qe.h index 60314ef58d11..e0faf332c9c9 100644 --- a/arch/powerpc/include/asm/qe.h +++ b/arch/powerpc/include/asm/qe.h | |||
@@ -22,7 +22,7 @@ | |||
22 | #include <asm/cpm.h> | 22 | #include <asm/cpm.h> |
23 | #include <asm/immap_qe.h> | 23 | #include <asm/immap_qe.h> |
24 | 24 | ||
25 | #define QE_NUM_OF_SNUM 28 | 25 | #define QE_NUM_OF_SNUM 256 /* There are 256 serial number in QE */ |
26 | #define QE_NUM_OF_BRGS 16 | 26 | #define QE_NUM_OF_BRGS 16 |
27 | #define QE_NUM_OF_PORTS 1024 | 27 | #define QE_NUM_OF_PORTS 1024 |
28 | 28 | ||
@@ -153,6 +153,7 @@ int qe_setbrg(enum qe_clock brg, unsigned int rate, unsigned int multiplier); | |||
153 | int qe_get_snum(void); | 153 | int qe_get_snum(void); |
154 | void qe_put_snum(u8 snum); | 154 | void qe_put_snum(u8 snum); |
155 | unsigned int qe_get_num_of_risc(void); | 155 | unsigned int qe_get_num_of_risc(void); |
156 | unsigned int qe_get_num_of_snums(void); | ||
156 | 157 | ||
157 | /* we actually use cpm_muram implementation, define this for convenience */ | 158 | /* we actually use cpm_muram implementation, define this for convenience */ |
158 | #define qe_muram_init cpm_muram_init | 159 | #define qe_muram_init cpm_muram_init |
diff --git a/arch/powerpc/sysdev/qe_lib/qe.c b/arch/powerpc/sysdev/qe_lib/qe.c index 2533677ae5eb..b28b0e512d67 100644 --- a/arch/powerpc/sysdev/qe_lib/qe.c +++ b/arch/powerpc/sysdev/qe_lib/qe.c | |||
@@ -61,6 +61,7 @@ struct qe_immap __iomem *qe_immr; | |||
61 | EXPORT_SYMBOL(qe_immr); | 61 | EXPORT_SYMBOL(qe_immr); |
62 | 62 | ||
63 | static struct qe_snum snums[QE_NUM_OF_SNUM]; /* Dynamically allocated SNUMs */ | 63 | static struct qe_snum snums[QE_NUM_OF_SNUM]; /* Dynamically allocated SNUMs */ |
64 | static unsigned int qe_num_of_snum; | ||
64 | 65 | ||
65 | static phys_addr_t qebase = -1; | 66 | static phys_addr_t qebase = -1; |
66 | 67 | ||
@@ -264,10 +265,14 @@ static void qe_snums_init(void) | |||
264 | 0x04, 0x05, 0x0C, 0x0D, 0x14, 0x15, 0x1C, 0x1D, | 265 | 0x04, 0x05, 0x0C, 0x0D, 0x14, 0x15, 0x1C, 0x1D, |
265 | 0x24, 0x25, 0x2C, 0x2D, 0x34, 0x35, 0x88, 0x89, | 266 | 0x24, 0x25, 0x2C, 0x2D, 0x34, 0x35, 0x88, 0x89, |
266 | 0x98, 0x99, 0xA8, 0xA9, 0xB8, 0xB9, 0xC8, 0xC9, | 267 | 0x98, 0x99, 0xA8, 0xA9, 0xB8, 0xB9, 0xC8, 0xC9, |
267 | 0xD8, 0xD9, 0xE8, 0xE9, | 268 | 0xD8, 0xD9, 0xE8, 0xE9, 0x08, 0x09, 0x18, 0x19, |
269 | 0x28, 0x29, 0x38, 0x39, 0x48, 0x49, 0x58, 0x59, | ||
270 | 0x68, 0x69, 0x78, 0x79, 0x80, 0x81, | ||
268 | }; | 271 | }; |
269 | 272 | ||
270 | for (i = 0; i < QE_NUM_OF_SNUM; i++) { | 273 | qe_num_of_snum = qe_get_num_of_snums(); |
274 | |||
275 | for (i = 0; i < qe_num_of_snum; i++) { | ||
271 | snums[i].num = snum_init[i]; | 276 | snums[i].num = snum_init[i]; |
272 | snums[i].state = QE_SNUM_STATE_FREE; | 277 | snums[i].state = QE_SNUM_STATE_FREE; |
273 | } | 278 | } |
@@ -280,7 +285,7 @@ int qe_get_snum(void) | |||
280 | int i; | 285 | int i; |
281 | 286 | ||
282 | spin_lock_irqsave(&qe_lock, flags); | 287 | spin_lock_irqsave(&qe_lock, flags); |
283 | for (i = 0; i < QE_NUM_OF_SNUM; i++) { | 288 | for (i = 0; i < qe_num_of_snum; i++) { |
284 | if (snums[i].state == QE_SNUM_STATE_FREE) { | 289 | if (snums[i].state == QE_SNUM_STATE_FREE) { |
285 | snums[i].state = QE_SNUM_STATE_USED; | 290 | snums[i].state = QE_SNUM_STATE_USED; |
286 | snum = snums[i].num; | 291 | snum = snums[i].num; |
@@ -297,7 +302,7 @@ void qe_put_snum(u8 snum) | |||
297 | { | 302 | { |
298 | int i; | 303 | int i; |
299 | 304 | ||
300 | for (i = 0; i < QE_NUM_OF_SNUM; i++) { | 305 | for (i = 0; i < qe_num_of_snum; i++) { |
301 | if (snums[i].num == snum) { | 306 | if (snums[i].num == snum) { |
302 | snums[i].state = QE_SNUM_STATE_FREE; | 307 | snums[i].state = QE_SNUM_STATE_FREE; |
303 | break; | 308 | break; |
@@ -603,3 +608,37 @@ unsigned int qe_get_num_of_risc(void) | |||
603 | } | 608 | } |
604 | EXPORT_SYMBOL(qe_get_num_of_risc); | 609 | EXPORT_SYMBOL(qe_get_num_of_risc); |
605 | 610 | ||
611 | unsigned int qe_get_num_of_snums(void) | ||
612 | { | ||
613 | struct device_node *qe; | ||
614 | int size; | ||
615 | unsigned int num_of_snums; | ||
616 | const u32 *prop; | ||
617 | |||
618 | num_of_snums = 28; /* The default number of snum for threads is 28 */ | ||
619 | qe = of_find_compatible_node(NULL, NULL, "fsl,qe"); | ||
620 | if (!qe) { | ||
621 | /* Older devices trees did not have an "fsl,qe" | ||
622 | * compatible property, so we need to look for | ||
623 | * the QE node by name. | ||
624 | */ | ||
625 | qe = of_find_node_by_type(NULL, "qe"); | ||
626 | if (!qe) | ||
627 | return num_of_snums; | ||
628 | } | ||
629 | |||
630 | prop = of_get_property(qe, "fsl,qe-num-snums", &size); | ||
631 | if (prop && size == sizeof(*prop)) { | ||
632 | num_of_snums = *prop; | ||
633 | if ((num_of_snums < 28) || (num_of_snums > QE_NUM_OF_SNUM)) { | ||
634 | /* No QE ever has fewer than 28 SNUMs */ | ||
635 | pr_err("QE: number of snum is invalid\n"); | ||
636 | return -EINVAL; | ||
637 | } | ||
638 | } | ||
639 | |||
640 | of_node_put(qe); | ||
641 | |||
642 | return num_of_snums; | ||
643 | } | ||
644 | EXPORT_SYMBOL(qe_get_num_of_snums); | ||