aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/powerpc/platforms/512x/mpc512x_shared.c78
-rw-r--r--drivers/serial/mpc52xx_uart.c69
2 files changed, 78 insertions, 69 deletions
diff --git a/arch/powerpc/platforms/512x/mpc512x_shared.c b/arch/powerpc/platforms/512x/mpc512x_shared.c
index b7f518a60f03..707e572b7c40 100644
--- a/arch/powerpc/platforms/512x/mpc512x_shared.c
+++ b/arch/powerpc/platforms/512x/mpc512x_shared.c
@@ -22,6 +22,7 @@
22#include <asm/prom.h> 22#include <asm/prom.h>
23#include <asm/time.h> 23#include <asm/time.h>
24#include <asm/mpc5121.h> 24#include <asm/mpc5121.h>
25#include <asm/mpc52xx_psc.h>
25 26
26#include "mpc512x.h" 27#include "mpc512x.h"
27 28
@@ -95,9 +96,86 @@ void __init mpc512x_declare_of_platform_devices(void)
95 } 96 }
96} 97}
97 98
99#define DEFAULT_FIFO_SIZE 16
100
101static unsigned int __init get_fifo_size(struct device_node *np,
102 char *prop_name)
103{
104 const unsigned int *fp;
105
106 fp = of_get_property(np, prop_name, NULL);
107 if (fp)
108 return *fp;
109
110 pr_warning("no %s property in %s node, defaulting to %d\n",
111 prop_name, np->full_name, DEFAULT_FIFO_SIZE);
112
113 return DEFAULT_FIFO_SIZE;
114}
115
116#define FIFOC(_base) ((struct mpc512x_psc_fifo __iomem *) \
117 ((u32)(_base) + sizeof(struct mpc52xx_psc)))
118
119/* Init PSC FIFO space for TX and RX slices */
120void __init mpc512x_psc_fifo_init(void)
121{
122 struct device_node *np;
123 void __iomem *psc;
124 unsigned int tx_fifo_size;
125 unsigned int rx_fifo_size;
126 int fifobase = 0; /* current fifo address in 32 bit words */
127
128 for_each_compatible_node(np, NULL, "fsl,mpc5121-psc") {
129 tx_fifo_size = get_fifo_size(np, "fsl,tx-fifo-size");
130 rx_fifo_size = get_fifo_size(np, "fsl,rx-fifo-size");
131
132 /* size in register is in 4 byte units */
133 tx_fifo_size /= 4;
134 rx_fifo_size /= 4;
135 if (!tx_fifo_size)
136 tx_fifo_size = 1;
137 if (!rx_fifo_size)
138 rx_fifo_size = 1;
139
140 psc = of_iomap(np, 0);
141 if (!psc) {
142 pr_err("%s: Can't map %s device\n",
143 __func__, np->full_name);
144 continue;
145 }
146
147 /* FIFO space is 4KiB, check if requested size is available */
148 if ((fifobase + tx_fifo_size + rx_fifo_size) > 0x1000) {
149 pr_err("%s: no fifo space available for %s\n",
150 __func__, np->full_name);
151 iounmap(psc);
152 /*
153 * chances are that another device requests less
154 * fifo space, so we continue.
155 */
156 continue;
157 }
158
159 /* set tx and rx fifo size registers */
160 out_be32(&FIFOC(psc)->txsz, (fifobase << 16) | tx_fifo_size);
161 fifobase += tx_fifo_size;
162 out_be32(&FIFOC(psc)->rxsz, (fifobase << 16) | rx_fifo_size);
163 fifobase += rx_fifo_size;
164
165 /* reset and enable the slices */
166 out_be32(&FIFOC(psc)->txcmd, 0x80);
167 out_be32(&FIFOC(psc)->txcmd, 0x01);
168 out_be32(&FIFOC(psc)->rxcmd, 0x80);
169 out_be32(&FIFOC(psc)->rxcmd, 0x01);
170
171 iounmap(psc);
172 }
173}
174
98void __init mpc512x_init(void) 175void __init mpc512x_init(void)
99{ 176{
100 mpc512x_declare_of_platform_devices(); 177 mpc512x_declare_of_platform_devices();
101 mpc5121_clk_init(); 178 mpc5121_clk_init();
102 mpc512x_restart_init(); 179 mpc512x_restart_init();
180 mpc512x_psc_fifo_init();
103} 181}
diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c
index 02469c31bf0b..f0ca448a1ebf 100644
--- a/drivers/serial/mpc52xx_uart.c
+++ b/drivers/serial/mpc52xx_uart.c
@@ -397,34 +397,10 @@ static unsigned long mpc512x_getuartclk(void *p)
397 return mpc5xxx_get_bus_frequency(p); 397 return mpc5xxx_get_bus_frequency(p);
398} 398}
399 399
400#define DEFAULT_FIFO_SIZE 16
401
402static unsigned int __init get_fifo_size(struct device_node *np,
403 char *fifo_name)
404{
405 const unsigned int *fp;
406
407 fp = of_get_property(np, fifo_name, NULL);
408 if (fp)
409 return *fp;
410
411 pr_warning("no %s property in %s node, defaulting to %d\n",
412 fifo_name, np->full_name, DEFAULT_FIFO_SIZE);
413
414 return DEFAULT_FIFO_SIZE;
415}
416
417#define FIFOC(_base) ((struct mpc512x_psc_fifo __iomem *) \
418 ((u32)(_base) + sizeof(struct mpc52xx_psc)))
419
420/* Init PSC FIFO Controller */ 400/* Init PSC FIFO Controller */
421static int __init mpc512x_psc_fifoc_init(void) 401static int __init mpc512x_psc_fifoc_init(void)
422{ 402{
423 struct device_node *np; 403 struct device_node *np;
424 void __iomem *psc;
425 unsigned int tx_fifo_size;
426 unsigned int rx_fifo_size;
427 int fifobase = 0; /* current fifo address in 32 bit words */
428 404
429 np = of_find_compatible_node(NULL, NULL, 405 np = of_find_compatible_node(NULL, NULL,
430 "fsl,mpc5121-psc-fifo"); 406 "fsl,mpc5121-psc-fifo");
@@ -447,51 +423,6 @@ static int __init mpc512x_psc_fifoc_init(void)
447 return -ENODEV; 423 return -ENODEV;
448 } 424 }
449 425
450 for_each_compatible_node(np, NULL, "fsl,mpc5121-psc-uart") {
451 tx_fifo_size = get_fifo_size(np, "fsl,tx-fifo-size");
452 rx_fifo_size = get_fifo_size(np, "fsl,rx-fifo-size");
453
454 /* size in register is in 4 byte units */
455 tx_fifo_size /= 4;
456 rx_fifo_size /= 4;
457 if (!tx_fifo_size)
458 tx_fifo_size = 1;
459 if (!rx_fifo_size)
460 rx_fifo_size = 1;
461
462 psc = of_iomap(np, 0);
463 if (!psc) {
464 pr_err("%s: Can't map %s device\n",
465 __func__, np->full_name);
466 continue;
467 }
468
469 /* FIFO space is 4KiB, check if requested size is available */
470 if ((fifobase + tx_fifo_size + rx_fifo_size) > 0x1000) {
471 pr_err("%s: no fifo space available for %s\n",
472 __func__, np->full_name);
473 iounmap(psc);
474 /*
475 * chances are that another device requests less
476 * fifo space, so we continue.
477 */
478 continue;
479 }
480 /* set tx and rx fifo size registers */
481 out_be32(&FIFOC(psc)->txsz, (fifobase << 16) | tx_fifo_size);
482 fifobase += tx_fifo_size;
483 out_be32(&FIFOC(psc)->rxsz, (fifobase << 16) | rx_fifo_size);
484 fifobase += rx_fifo_size;
485
486 /* reset and enable the slices */
487 out_be32(&FIFOC(psc)->txcmd, 0x80);
488 out_be32(&FIFOC(psc)->txcmd, 0x01);
489 out_be32(&FIFOC(psc)->rxcmd, 0x80);
490 out_be32(&FIFOC(psc)->rxcmd, 0x01);
491
492 iounmap(psc);
493 }
494
495 return 0; 426 return 0;
496} 427}
497 428