aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/sysdev
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/sysdev')
-rw-r--r--arch/powerpc/sysdev/Makefile4
-rw-r--r--arch/powerpc/sysdev/commproc.h12
-rw-r--r--arch/powerpc/sysdev/cpm1.c (renamed from arch/powerpc/sysdev/commproc.c)42
-rw-r--r--arch/powerpc/sysdev/cpm2.c (renamed from arch/powerpc/sysdev/cpm2_common.c)3
-rw-r--r--arch/powerpc/sysdev/fsl_soc.c99
-rw-r--r--arch/powerpc/sysdev/ipic.c6
-rw-r--r--arch/powerpc/sysdev/micropatch.c2
-rw-r--r--arch/powerpc/sysdev/mpc8xx_pic.c1
-rw-r--r--arch/powerpc/sysdev/qe_lib/qe.c63
9 files changed, 128 insertions, 104 deletions
diff --git a/arch/powerpc/sysdev/Makefile b/arch/powerpc/sysdev/Makefile
index 702916bf28fa..15f3e8527d77 100644
--- a/arch/powerpc/sysdev/Makefile
+++ b/arch/powerpc/sysdev/Makefile
@@ -37,8 +37,8 @@ endif
37# Temporary hack until we have migrated to asm-powerpc 37# Temporary hack until we have migrated to asm-powerpc
38ifeq ($(ARCH),powerpc) 38ifeq ($(ARCH),powerpc)
39obj-$(CONFIG_CPM) += cpm_common.o 39obj-$(CONFIG_CPM) += cpm_common.o
40obj-$(CONFIG_CPM2) += cpm2_common.o cpm2_pic.o 40obj-$(CONFIG_CPM2) += cpm2.o cpm2_pic.o
41obj-$(CONFIG_PPC_DCR) += dcr.o 41obj-$(CONFIG_PPC_DCR) += dcr.o
42obj-$(CONFIG_8xx) += mpc8xx_pic.o commproc.o 42obj-$(CONFIG_8xx) += mpc8xx_pic.o cpm1.o
43obj-$(CONFIG_UCODE_PATCH) += micropatch.o 43obj-$(CONFIG_UCODE_PATCH) += micropatch.o
44endif 44endif
diff --git a/arch/powerpc/sysdev/commproc.h b/arch/powerpc/sysdev/commproc.h
deleted file mode 100644
index 9155ba467274..000000000000
--- a/arch/powerpc/sysdev/commproc.h
+++ /dev/null
@@ -1,12 +0,0 @@
1#ifndef _POWERPC_SYSDEV_COMMPROC_H
2#define _POWERPC_SYSDEV_COMMPROC_H
3
4extern void cpm_reset(void);
5extern void mpc8xx_restart(char *cmd);
6extern void mpc8xx_calibrate_decr(void);
7extern int mpc8xx_set_rtc_time(struct rtc_time *tm);
8extern void mpc8xx_get_rtc_time(struct rtc_time *tm);
9extern void m8xx_pic_init(void);
10extern unsigned int mpc8xx_get_irq(void);
11
12#endif
diff --git a/arch/powerpc/sysdev/commproc.c b/arch/powerpc/sysdev/cpm1.c
index 621bc6c1d408..df8bd2b64796 100644
--- a/arch/powerpc/sysdev/commproc.c
+++ b/arch/powerpc/sysdev/cpm1.c
@@ -30,11 +30,10 @@
30#include <linux/interrupt.h> 30#include <linux/interrupt.h>
31#include <linux/irq.h> 31#include <linux/irq.h>
32#include <linux/module.h> 32#include <linux/module.h>
33#include <asm/mpc8xx.h>
34#include <asm/page.h> 33#include <asm/page.h>
35#include <asm/pgtable.h> 34#include <asm/pgtable.h>
36#include <asm/8xx_immap.h> 35#include <asm/8xx_immap.h>
37#include <asm/commproc.h> 36#include <asm/cpm1.h>
38#include <asm/io.h> 37#include <asm/io.h>
39#include <asm/tlbflush.h> 38#include <asm/tlbflush.h>
40#include <asm/rheap.h> 39#include <asm/rheap.h>
@@ -48,8 +47,6 @@
48#ifndef CONFIG_PPC_CPM_NEW_BINDING 47#ifndef CONFIG_PPC_CPM_NEW_BINDING
49static void m8xx_cpm_dpinit(void); 48static void m8xx_cpm_dpinit(void);
50#endif 49#endif
51static uint host_buffer; /* One page of host buffer */
52static uint host_end; /* end + 1 */
53cpm8xx_t __iomem *cpmp; /* Pointer to comm processor space */ 50cpm8xx_t __iomem *cpmp; /* Pointer to comm processor space */
54immap_t __iomem *mpc8xx_immr; 51immap_t __iomem *mpc8xx_immr;
55static cpic8xx_t __iomem *cpic_reg; 52static cpic8xx_t __iomem *cpic_reg;
@@ -268,41 +265,6 @@ out:
268} 265}
269EXPORT_SYMBOL(cpm_command); 266EXPORT_SYMBOL(cpm_command);
270 267
271/* We used to do this earlier, but have to postpone as long as possible
272 * to ensure the kernel VM is now running.
273 */
274static void
275alloc_host_memory(void)
276{
277 dma_addr_t physaddr;
278
279 /* Set the host page for allocation.
280 */
281 host_buffer = (uint)dma_alloc_coherent(NULL, PAGE_SIZE, &physaddr,
282 GFP_KERNEL);
283 host_end = host_buffer + PAGE_SIZE;
284}
285
286/* We also own one page of host buffer space for the allocation of
287 * UART "fifos" and the like.
288 */
289uint
290m8xx_cpm_hostalloc(uint size)
291{
292 uint retloc;
293
294 if (host_buffer == 0)
295 alloc_host_memory();
296
297 if ((host_buffer + size) >= host_end)
298 return(0);
299
300 retloc = host_buffer;
301 host_buffer += size;
302
303 return(retloc);
304}
305
306/* Set a baud rate generator. This needs lots of work. There are 268/* Set a baud rate generator. This needs lots of work. There are
307 * four BRGs, any of which can be wired to any channel. 269 * four BRGs, any of which can be wired to any channel.
308 * The internal baud rate clock is the system clock divided by 16. 270 * The internal baud rate clock is the system clock divided by 16.
@@ -328,7 +290,7 @@ cpm_setbrg(uint brg, uint rate)
328 out_be32(bp, (((BRG_UART_CLK / rate) - 1) << 1) | CPM_BRG_EN); 290 out_be32(bp, (((BRG_UART_CLK / rate) - 1) << 1) | CPM_BRG_EN);
329 else 291 else
330 out_be32(bp, (((BRG_UART_CLK_DIV16 / rate) - 1) << 1) | 292 out_be32(bp, (((BRG_UART_CLK_DIV16 / rate) - 1) << 1) |
331 CPM_BRG_EN | CPM_BRG_DIV16); 293 CPM_BRG_EN | CPM_BRG_DIV16);
332} 294}
333 295
334#ifndef CONFIG_PPC_CPM_NEW_BINDING 296#ifndef CONFIG_PPC_CPM_NEW_BINDING
diff --git a/arch/powerpc/sysdev/cpm2_common.c b/arch/powerpc/sysdev/cpm2.c
index f7188e2ba669..7be711232124 100644
--- a/arch/powerpc/sysdev/cpm2_common.c
+++ b/arch/powerpc/sysdev/cpm2.c
@@ -153,8 +153,7 @@ cpm2_fastbrg(uint brg, uint rate, int div16)
153 153
154 if (brg < 4) { 154 if (brg < 4) {
155 bp = cpm2_map_size(im_brgc1, 16); 155 bp = cpm2_map_size(im_brgc1, 16);
156 } 156 } else {
157 else {
158 bp = cpm2_map_size(im_brgc5, 16); 157 bp = cpm2_map_size(im_brgc5, 16);
159 brg -= 4; 158 brg -= 4;
160 } 159 }
diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index f2c0988a03b8..e48b20e934ca 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -75,7 +75,7 @@ phys_addr_t get_immrbase(void)
75 75
76EXPORT_SYMBOL(get_immrbase); 76EXPORT_SYMBOL(get_immrbase);
77 77
78#if defined(CONFIG_CPM2) || defined(CONFIG_8xx) 78#if defined(CONFIG_CPM2) || defined(CONFIG_QUICC_ENGINE) || defined(CONFIG_8xx)
79 79
80static u32 brgfreq = -1; 80static u32 brgfreq = -1;
81 81
@@ -100,11 +100,21 @@ u32 get_brgfreq(void)
100 100
101 /* Legacy device binding -- will go away when no users are left. */ 101 /* Legacy device binding -- will go away when no users are left. */
102 node = of_find_node_by_type(NULL, "cpm"); 102 node = of_find_node_by_type(NULL, "cpm");
103 if (!node)
104 node = of_find_compatible_node(NULL, NULL, "fsl,qe");
105 if (!node)
106 node = of_find_node_by_type(NULL, "qe");
107
103 if (node) { 108 if (node) {
104 prop = of_get_property(node, "brg-frequency", &size); 109 prop = of_get_property(node, "brg-frequency", &size);
105 if (prop && size == 4) 110 if (prop && size == 4)
106 brgfreq = *prop; 111 brgfreq = *prop;
107 112
113 if (brgfreq == -1 || brgfreq == 0) {
114 prop = of_get_property(node, "bus-frequency", &size);
115 if (prop && size == 4)
116 brgfreq = *prop / 2;
117 }
108 of_node_put(node); 118 of_node_put(node);
109 } 119 }
110 120
@@ -1266,31 +1276,17 @@ arch_initcall(cpm_smc_uart_of_init);
1266#endif /* CONFIG_8xx */ 1276#endif /* CONFIG_8xx */
1267#endif /* CONFIG_PPC_CPM_NEW_BINDING */ 1277#endif /* CONFIG_PPC_CPM_NEW_BINDING */
1268 1278
1269int __init fsl_spi_init(struct spi_board_info *board_infos, 1279static int __init of_fsl_spi_probe(char *type, char *compatible, u32 sysclk,
1270 unsigned int num_board_infos, 1280 struct spi_board_info *board_infos,
1271 void (*activate_cs)(u8 cs, u8 polarity), 1281 unsigned int num_board_infos,
1272 void (*deactivate_cs)(u8 cs, u8 polarity)) 1282 void (*activate_cs)(u8 cs, u8 polarity),
1283 void (*deactivate_cs)(u8 cs, u8 polarity))
1273{ 1284{
1274 struct device_node *np; 1285 struct device_node *np;
1275 unsigned int i; 1286 unsigned int i = 0;
1276 const u32 *sysclk;
1277
1278 /* SPI controller is either clocked from QE or SoC clock */
1279 np = of_find_node_by_type(NULL, "qe");
1280 if (!np)
1281 np = of_find_node_by_type(NULL, "soc");
1282
1283 if (!np)
1284 return -ENODEV;
1285
1286 sysclk = of_get_property(np, "bus-frequency", NULL);
1287 if (!sysclk)
1288 return -ENODEV;
1289 1287
1290 for (np = NULL, i = 1; 1288 for_each_compatible_node(np, type, compatible) {
1291 (np = of_find_compatible_node(np, "spi", "fsl_spi")) != NULL; 1289 int ret;
1292 i++) {
1293 int ret = 0;
1294 unsigned int j; 1290 unsigned int j;
1295 const void *prop; 1291 const void *prop;
1296 struct resource res[2]; 1292 struct resource res[2];
@@ -1302,13 +1298,17 @@ int __init fsl_spi_init(struct spi_board_info *board_infos,
1302 1298
1303 memset(res, 0, sizeof(res)); 1299 memset(res, 0, sizeof(res));
1304 1300
1305 pdata.sysclk = *sysclk; 1301 pdata.sysclk = sysclk;
1306 1302
1307 prop = of_get_property(np, "reg", NULL); 1303 prop = of_get_property(np, "reg", NULL);
1308 if (!prop) 1304 if (!prop)
1309 goto err; 1305 goto err;
1310 pdata.bus_num = *(u32 *)prop; 1306 pdata.bus_num = *(u32 *)prop;
1311 1307
1308 prop = of_get_property(np, "cell-index", NULL);
1309 if (prop)
1310 i = *(u32 *)prop;
1311
1312 prop = of_get_property(np, "mode", NULL); 1312 prop = of_get_property(np, "mode", NULL);
1313 if (prop && !strcmp(prop, "cpu-qe")) 1313 if (prop && !strcmp(prop, "cpu-qe"))
1314 pdata.qe_mode = 1; 1314 pdata.qe_mode = 1;
@@ -1319,7 +1319,7 @@ int __init fsl_spi_init(struct spi_board_info *board_infos,
1319 } 1319 }
1320 1320
1321 if (!pdata.max_chipselect) 1321 if (!pdata.max_chipselect)
1322 goto err; 1322 continue;
1323 1323
1324 ret = of_address_to_resource(np, 0, &res[0]); 1324 ret = of_address_to_resource(np, 0, &res[0]);
1325 if (ret) 1325 if (ret)
@@ -1346,13 +1346,58 @@ int __init fsl_spi_init(struct spi_board_info *board_infos,
1346 if (ret) 1346 if (ret)
1347 goto unreg; 1347 goto unreg;
1348 1348
1349 continue; 1349 goto next;
1350unreg: 1350unreg:
1351 platform_device_del(pdev); 1351 platform_device_del(pdev);
1352err: 1352err:
1353 continue; 1353 pr_err("%s: registration failed\n", np->full_name);
1354next:
1355 i++;
1354 } 1356 }
1355 1357
1358 return i;
1359}
1360
1361int __init fsl_spi_init(struct spi_board_info *board_infos,
1362 unsigned int num_board_infos,
1363 void (*activate_cs)(u8 cs, u8 polarity),
1364 void (*deactivate_cs)(u8 cs, u8 polarity))
1365{
1366 u32 sysclk = -1;
1367 int ret;
1368
1369#ifdef CONFIG_QUICC_ENGINE
1370 /* SPI controller is either clocked from QE or SoC clock */
1371 sysclk = get_brgfreq();
1372#endif
1373 if (sysclk == -1) {
1374 struct device_node *np;
1375 const u32 *freq;
1376 int size;
1377
1378 np = of_find_node_by_type(NULL, "soc");
1379 if (!np)
1380 return -ENODEV;
1381
1382 freq = of_get_property(np, "clock-frequency", &size);
1383 if (!freq || size != sizeof(*freq) || *freq == 0) {
1384 freq = of_get_property(np, "bus-frequency", &size);
1385 if (!freq || size != sizeof(*freq) || *freq == 0) {
1386 of_node_put(np);
1387 return -ENODEV;
1388 }
1389 }
1390
1391 sysclk = *freq;
1392 of_node_put(np);
1393 }
1394
1395 ret = of_fsl_spi_probe(NULL, "fsl,spi", sysclk, board_infos,
1396 num_board_infos, activate_cs, deactivate_cs);
1397 if (!ret)
1398 of_fsl_spi_probe("spi", "fsl_spi", sysclk, board_infos,
1399 num_board_infos, activate_cs, deactivate_cs);
1400
1356 return spi_register_board_info(board_infos, num_board_infos); 1401 return spi_register_board_info(board_infos, num_board_infos);
1357} 1402}
1358 1403
diff --git a/arch/powerpc/sysdev/ipic.c b/arch/powerpc/sysdev/ipic.c
index 4c016da68426..d7f6a70e78df 100644
--- a/arch/powerpc/sysdev/ipic.c
+++ b/arch/powerpc/sysdev/ipic.c
@@ -497,6 +497,12 @@ static struct ipic_info ipic_info[] = {
497 .force = IPIC_SIFCR_L, 497 .force = IPIC_SIFCR_L,
498 .bit = 27, 498 .bit = 27,
499 }, 499 },
500 [94] = {
501 .mask = IPIC_SIMSR_L,
502 .prio = 0,
503 .force = IPIC_SIFCR_L,
504 .bit = 30,
505 },
500}; 506};
501 507
502static inline u32 ipic_read(volatile u32 __iomem *base, unsigned int reg) 508static inline u32 ipic_read(volatile u32 __iomem *base, unsigned int reg)
diff --git a/arch/powerpc/sysdev/micropatch.c b/arch/powerpc/sysdev/micropatch.c
index 712b10a55f87..d8d602840757 100644
--- a/arch/powerpc/sysdev/micropatch.c
+++ b/arch/powerpc/sysdev/micropatch.c
@@ -16,7 +16,7 @@
16#include <asm/page.h> 16#include <asm/page.h>
17#include <asm/pgtable.h> 17#include <asm/pgtable.h>
18#include <asm/8xx_immap.h> 18#include <asm/8xx_immap.h>
19#include <asm/commproc.h> 19#include <asm/cpm1.h>
20 20
21/* 21/*
22 * I2C/SPI relocation patch arrays. 22 * I2C/SPI relocation patch arrays.
diff --git a/arch/powerpc/sysdev/mpc8xx_pic.c b/arch/powerpc/sysdev/mpc8xx_pic.c
index 7aa4ff5f5ec8..0e74a4bd9827 100644
--- a/arch/powerpc/sysdev/mpc8xx_pic.c
+++ b/arch/powerpc/sysdev/mpc8xx_pic.c
@@ -10,7 +10,6 @@
10#include <asm/irq.h> 10#include <asm/irq.h>
11#include <asm/io.h> 11#include <asm/io.h>
12#include <asm/8xx_immap.h> 12#include <asm/8xx_immap.h>
13#include <asm/mpc8xx.h>
14 13
15#include "mpc8xx_pic.h" 14#include "mpc8xx_pic.h"
16 15
diff --git a/arch/powerpc/sysdev/qe_lib/qe.c b/arch/powerpc/sysdev/qe_lib/qe.c
index 3925eae9b0f5..5ef844da9355 100644
--- a/arch/powerpc/sysdev/qe_lib/qe.c
+++ b/arch/powerpc/sysdev/qe_lib/qe.c
@@ -65,17 +65,22 @@ static phys_addr_t qebase = -1;
65phys_addr_t get_qe_base(void) 65phys_addr_t get_qe_base(void)
66{ 66{
67 struct device_node *qe; 67 struct device_node *qe;
68 unsigned int size;
69 const void *prop;
68 70
69 if (qebase != -1) 71 if (qebase != -1)
70 return qebase; 72 return qebase;
71 73
72 qe = of_find_node_by_type(NULL, "qe"); 74 qe = of_find_compatible_node(NULL, NULL, "fsl,qe");
73 if (qe) { 75 if (!qe) {
74 unsigned int size; 76 qe = of_find_node_by_type(NULL, "qe");
75 const void *prop = of_get_property(qe, "reg", &size); 77 if (!qe)
76 qebase = of_translate_address(qe, prop); 78 return qebase;
77 of_node_put(qe); 79 }
78 }; 80
81 prop = of_get_property(qe, "reg", &size);
82 qebase = of_translate_address(qe, prop);
83 of_node_put(qe);
79 84
80 return qebase; 85 return qebase;
81} 86}
@@ -153,16 +158,26 @@ static unsigned int brg_clk = 0;
153unsigned int get_brg_clk(void) 158unsigned int get_brg_clk(void)
154{ 159{
155 struct device_node *qe; 160 struct device_node *qe;
161 unsigned int size;
162 const u32 *prop;
163
156 if (brg_clk) 164 if (brg_clk)
157 return brg_clk; 165 return brg_clk;
158 166
159 qe = of_find_node_by_type(NULL, "qe"); 167 qe = of_find_compatible_node(NULL, NULL, "fsl,qe");
160 if (qe) { 168 if (!qe) {
161 unsigned int size; 169 qe = of_find_node_by_type(NULL, "qe");
162 const u32 *prop = of_get_property(qe, "brg-frequency", &size); 170 if (!qe)
163 brg_clk = *prop; 171 return brg_clk;
164 of_node_put(qe); 172 }
165 }; 173
174 prop = of_get_property(qe, "brg-frequency", &size);
175 if (!prop || size != sizeof(*prop))
176 return brg_clk;
177
178 brg_clk = *prop;
179 of_node_put(qe);
180
166 return brg_clk; 181 return brg_clk;
167} 182}
168 183
@@ -322,7 +337,7 @@ static rh_info_t qe_muram_info;
322static void qe_muram_init(void) 337static void qe_muram_init(void)
323{ 338{
324 struct device_node *np; 339 struct device_node *np;
325 u32 address; 340 const u32 *address;
326 u64 size; 341 u64 size;
327 unsigned int flags; 342 unsigned int flags;
328 343
@@ -335,11 +350,21 @@ static void qe_muram_init(void)
335 /* XXX: This is a subset of the available muram. It 350 /* XXX: This is a subset of the available muram. It
336 * varies with the processor and the microcode patches activated. 351 * varies with the processor and the microcode patches activated.
337 */ 352 */
338 if ((np = of_find_node_by_name(NULL, "data-only")) != NULL) { 353 np = of_find_compatible_node(NULL, NULL, "fsl,qe-muram-data");
339 address = *of_get_address(np, 0, &size, &flags); 354 if (!np) {
340 of_node_put(np); 355 np = of_find_node_by_name(NULL, "data-only");
341 rh_attach_region(&qe_muram_info, address, (int) size); 356 if (!np) {
357 WARN_ON(1);
358 return;
359 }
342 } 360 }
361
362 address = of_get_address(np, 0, &size, &flags);
363 WARN_ON(!address);
364
365 of_node_put(np);
366 if (address)
367 rh_attach_region(&qe_muram_info, *address, (int)size);
343} 368}
344 369
345/* This function returns an index into the MURAM area. 370/* This function returns an index into the MURAM area.