aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/sysdev/mpic.c
diff options
context:
space:
mode:
authorHongtao Jia <hongtao.jia@freescale.com>2013-04-09 22:52:55 -0400
committerScott Wood <scottwood@freescale.com>2013-07-01 19:38:28 -0400
commit86d379690c3b005418fafc9afdcdfc731a043862 (patch)
treed57e6453daf9352acdfb6588c6a8f3a7dd4b6c67 /arch/powerpc/sysdev/mpic.c
parent3978bdb4ed653342b0be66c031bf61b72cc55d60 (diff)
powerpc/mpic: Add get_version API both for internal and external use
MPIC version is useful information for both mpic_alloc() and mpic_init(). The patch provide an API to get MPIC version for reusing the code. Also, some other IP block may need MPIC version for their own use. The API for external use is also provided. Signed-off-by: Jia Hongtao <hongtao.jia@freescale.com> Signed-off-by: Li Yang <leoli@freescale.com> Signed-off-by: Scott Wood <scottwood@freescale.com>
Diffstat (limited to 'arch/powerpc/sysdev/mpic.c')
-rw-r--r--arch/powerpc/sysdev/mpic.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 3cc2f9159ab1..1a4e19c6a688 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -1173,10 +1173,33 @@ static struct irq_domain_ops mpic_host_ops = {
1173 .xlate = mpic_host_xlate, 1173 .xlate = mpic_host_xlate,
1174}; 1174};
1175 1175
1176static u32 fsl_mpic_get_version(struct mpic *mpic)
1177{
1178 u32 brr1;
1179
1180 if (!(mpic->flags & MPIC_FSL))
1181 return 0;
1182
1183 brr1 = _mpic_read(mpic->reg_type, &mpic->thiscpuregs,
1184 MPIC_FSL_BRR1);
1185
1186 return brr1 & MPIC_FSL_BRR1_VER;
1187}
1188
1176/* 1189/*
1177 * Exported functions 1190 * Exported functions
1178 */ 1191 */
1179 1192
1193u32 fsl_mpic_primary_get_version(void)
1194{
1195 struct mpic *mpic = mpic_primary;
1196
1197 if (mpic)
1198 return fsl_mpic_get_version(mpic);
1199
1200 return 0;
1201}
1202
1180struct mpic * __init mpic_alloc(struct device_node *node, 1203struct mpic * __init mpic_alloc(struct device_node *node,
1181 phys_addr_t phys_addr, 1204 phys_addr_t phys_addr,
1182 unsigned int flags, 1205 unsigned int flags,
@@ -1323,7 +1346,6 @@ struct mpic * __init mpic_alloc(struct device_node *node,
1323 mpic_map(mpic, mpic->paddr, &mpic->tmregs, MPIC_INFO(TIMER_BASE), 0x1000); 1346 mpic_map(mpic, mpic->paddr, &mpic->tmregs, MPIC_INFO(TIMER_BASE), 0x1000);
1324 1347
1325 if (mpic->flags & MPIC_FSL) { 1348 if (mpic->flags & MPIC_FSL) {
1326 u32 brr1;
1327 int ret; 1349 int ret;
1328 1350
1329 /* 1351 /*
@@ -1334,9 +1356,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
1334 mpic_map(mpic, mpic->paddr, &mpic->thiscpuregs, 1356 mpic_map(mpic, mpic->paddr, &mpic->thiscpuregs,
1335 MPIC_CPU_THISBASE, 0x1000); 1357 MPIC_CPU_THISBASE, 0x1000);
1336 1358
1337 brr1 = _mpic_read(mpic->reg_type, &mpic->thiscpuregs, 1359 fsl_version = fsl_mpic_get_version(mpic);
1338 MPIC_FSL_BRR1);
1339 fsl_version = brr1 & MPIC_FSL_BRR1_VER;
1340 1360
1341 /* Error interrupt mask register (EIMR) is required for 1361 /* Error interrupt mask register (EIMR) is required for
1342 * handling individual device error interrupts. EIMR 1362 * handling individual device error interrupts. EIMR
@@ -1526,9 +1546,7 @@ void __init mpic_init(struct mpic *mpic)
1526 mpic_cpu_write(MPIC_INFO(CPU_CURRENT_TASK_PRI), 0xf); 1546 mpic_cpu_write(MPIC_INFO(CPU_CURRENT_TASK_PRI), 0xf);
1527 1547
1528 if (mpic->flags & MPIC_FSL) { 1548 if (mpic->flags & MPIC_FSL) {
1529 u32 brr1 = _mpic_read(mpic->reg_type, &mpic->thiscpuregs, 1549 u32 version = fsl_mpic_get_version(mpic);
1530 MPIC_FSL_BRR1);
1531 u32 version = brr1 & MPIC_FSL_BRR1_VER;
1532 1550
1533 /* 1551 /*
1534 * Timer group B is present at the latest in MPIC 3.1 (e.g. 1552 * Timer group B is present at the latest in MPIC 3.1 (e.g.