Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
linux
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
2
Pull requests
0
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
205b9c9
Documentation
arch
alpha
arm
avr32
blackfin
c6x
cris
frv
h8300
hexagon
ia64
m32r
m68k
microblaze
mips
mn10300
openrisc
parisc
powerpc
boot
configs
include
kernel
kvm
lib
math-emu
mm
net
oprofile
perf
platforms
sysdev
bestcomm
ge
qe_lib
xics
6xx-suspend.S
Kconfig
Makefile
axonram.c
cpm1.c
cpm2.c
cpm2_pic.c
cpm2_pic.h
cpm_common.c
dart.h
dart_iommu.c
dcr-low.S
dcr.c
ehv_pic.c
fsl_85xx_cache_ctlr.h
fsl_85xx_cache_sram.c
fsl_85xx_l2ctlr.c
fsl_gtm.c
fsl_ifc.c
fsl_lbc.c
fsl_msi.c
fsl_msi.h
fsl_pci.c
fsl_pci.h
fsl_pmc.c
fsl_rio.c
fsl_rio.h
fsl_rmu.c
fsl_soc.c
fsl_soc.h
grackle.c
i8259.c
indirect_pci.c
ipic.c
ipic.h
micropatch.c
mmio_nvram.c
mpc5xxx_clocks.c
mpc8xx_pic.c
mpc8xx_pic.h
mpic.c
mpic.h
mpic_msgr.c
mpic_msi.c
mpic_pasemi_msi.c
mpic_u3msi.c
msi_bitmap.c
mv64x60.h
mv64x60_dev.c
mv64x60_pci.c
mv64x60_pic.c
mv64x60_udbg.c
of_rtc.c
pmi.c
ppc4xx_cpm.c
ppc4xx_gpio.c
ppc4xx_msi.c
ppc4xx_pci.c
ppc4xx_pci.h
ppc4xx_soc.c
rtc_cmos_setup.c
scom.c
simple_gpio.c
simple_gpio.h
tsi108_dev.c
tsi108_pci.c
uic.c
xilinx_intc.c
xilinx_pci.c
xmon
Kconfig
Kconfig.debug
Makefile
relocs_check.pl
s390
score
sh
sparc
tile
um
unicore32
x86
xtensa
.gitignore
Kconfig
block
crypto
drivers
firmware
fs
include
init
ipc
kernel
lib
mm
net
samples
scripts
security
sound
tools
usr
virt
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
REPORTING-BUGS
Breadcrumbs
linux
/
arch
/
powerpc
/
sysdev
/
mpic_msgr.c
Copy path
Blame
Blame
Latest commit
History
History
282 lines (234 loc) · 6.81 KB
Breadcrumbs
linux
/
arch
/
powerpc
/
sysdev
/
mpic_msgr.c
Top
File metadata and controls
Code
Blame
282 lines (234 loc) · 6.81 KB
Raw
/* * Copyright 2011-2012, Meador Inge, Mentor Graphics Corporation. * * Some ideas based on un-pushed work done by Vivek Mahajan, Jason Jin, and * Mingkai Hu from Freescale Semiconductor, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 of the * License. * */ #include <linux/list.h> #include <linux/of_platform.h> #include <linux/errno.h> #include <asm/prom.h> #include <asm/hw_irq.h> #include <asm/ppc-pci.h> #include <asm/mpic_msgr.h> #define MPIC_MSGR_REGISTERS_PER_BLOCK 4 #define MPIC_MSGR_STRIDE 0x10 #define MPIC_MSGR_MER_OFFSET 0x100 #define MSGR_INUSE 0 #define MSGR_FREE 1 static struct mpic_msgr **mpic_msgrs; static unsigned int mpic_msgr_count; static DEFINE_RAW_SPINLOCK(msgrs_lock); static inline void _mpic_msgr_mer_write(struct mpic_msgr *msgr, u32 value) { out_be32(msgr->mer, value); } static inline u32 _mpic_msgr_mer_read(struct mpic_msgr *msgr) { return in_be32(msgr->mer); } static inline void _mpic_msgr_disable(struct mpic_msgr *msgr) { u32 mer = _mpic_msgr_mer_read(msgr); _mpic_msgr_mer_write(msgr, mer & ~(1 << msgr->num)); } struct mpic_msgr *mpic_msgr_get(unsigned int reg_num) { unsigned long flags; struct mpic_msgr *msgr; /* Assume busy until proven otherwise. */ msgr = ERR_PTR(-EBUSY); if (reg_num >= mpic_msgr_count) return ERR_PTR(-ENODEV); raw_spin_lock_irqsave(&msgrs_lock, flags); msgr = mpic_msgrs[reg_num]; if (msgr->in_use == MSGR_FREE) msgr->in_use = MSGR_INUSE; raw_spin_unlock_irqrestore(&msgrs_lock, flags); return msgr; } EXPORT_SYMBOL_GPL(mpic_msgr_get); void mpic_msgr_put(struct mpic_msgr *msgr) { unsigned long flags; raw_spin_lock_irqsave(&msgr->lock, flags); msgr->in_use = MSGR_FREE; _mpic_msgr_disable(msgr); raw_spin_unlock_irqrestore(&msgr->lock, flags); } EXPORT_SYMBOL_GPL(mpic_msgr_put); void mpic_msgr_enable(struct mpic_msgr *msgr) { unsigned long flags; u32 mer; raw_spin_lock_irqsave(&msgr->lock, flags); mer = _mpic_msgr_mer_read(msgr); _mpic_msgr_mer_write(msgr, mer | (1 << msgr->num)); raw_spin_unlock_irqrestore(&msgr->lock, flags); } EXPORT_SYMBOL_GPL(mpic_msgr_enable); void mpic_msgr_disable(struct mpic_msgr *msgr) { unsigned long flags; raw_spin_lock_irqsave(&msgr->lock, flags); _mpic_msgr_disable(msgr); raw_spin_unlock_irqrestore(&msgr->lock, flags); } EXPORT_SYMBOL_GPL(mpic_msgr_disable); /* The following three functions are used to compute the order and number of * the message register blocks. They are clearly very inefficent. However, * they are called *only* a few times during device initialization. */ static unsigned int mpic_msgr_number_of_blocks(void) { unsigned int count; struct device_node *aliases; count = 0; aliases = of_find_node_by_name(NULL, "aliases"); if (aliases) { char buf[32]; for (;;) { snprintf(buf, sizeof(buf), "mpic-msgr-block%d", count); if (!of_find_property(aliases, buf, NULL)) break; count += 1; } } return count; } static unsigned int mpic_msgr_number_of_registers(void) { return mpic_msgr_number_of_blocks() * MPIC_MSGR_REGISTERS_PER_BLOCK; } static int mpic_msgr_block_number(struct device_node *node) { struct device_node *aliases; unsigned int index, number_of_blocks; char buf[64]; number_of_blocks = mpic_msgr_number_of_blocks(); aliases = of_find_node_by_name(NULL, "aliases"); if (!aliases) return -1; for (index = 0; index < number_of_blocks; ++index) { struct property *prop; snprintf(buf, sizeof(buf), "mpic-msgr-block%d", index); prop = of_find_property(aliases, buf, NULL); if (node == of_find_node_by_path(prop->value)) break; } return index == number_of_blocks ? -1 : index; } /* The probe function for a single message register block. */ static __devinit int mpic_msgr_probe(struct platform_device *dev) { void __iomem *msgr_block_addr; int block_number; struct resource rsrc; unsigned int i; unsigned int irq_index; struct device_node *np = dev->dev.of_node; unsigned int receive_mask; const unsigned int *prop; if (!np) { dev_err(&dev->dev, "Device OF-Node is NULL"); return -EFAULT; } /* Allocate the message register array upon the first device * registered. */ if (!mpic_msgrs) { mpic_msgr_count = mpic_msgr_number_of_registers(); dev_info(&dev->dev, "Found %d message registers\n", mpic_msgr_count); mpic_msgrs = kzalloc(sizeof(struct mpic_msgr) * mpic_msgr_count, GFP_KERNEL); if (!mpic_msgrs) { dev_err(&dev->dev, "No memory for message register blocks\n"); return -ENOMEM; } } dev_info(&dev->dev, "Of-device full name %s\n", np->full_name); /* IO map the message register block. */ of_address_to_resource(np, 0, &rsrc); msgr_block_addr = ioremap(rsrc.start, rsrc.end - rsrc.start); if (!msgr_block_addr) { dev_err(&dev->dev, "Failed to iomap MPIC message registers"); return -EFAULT; } /* Ensure the block has a defined order. */ block_number = mpic_msgr_block_number(np); if (block_number < 0) { dev_err(&dev->dev, "Failed to find message register block alias\n"); return -ENODEV; } dev_info(&dev->dev, "Setting up message register block %d\n", block_number); /* Grab the receive mask which specifies what registers can receive * interrupts. */ prop = of_get_property(np, "mpic-msgr-receive-mask", NULL); receive_mask = (prop) ? *prop : 0xF; /* Build up the appropriate message register data structures. */ for (i = 0, irq_index = 0; i < MPIC_MSGR_REGISTERS_PER_BLOCK; ++i) { struct mpic_msgr *msgr; unsigned int reg_number; msgr = kzalloc(sizeof(struct mpic_msgr), GFP_KERNEL); if (!msgr) { dev_err(&dev->dev, "No memory for message register\n"); return -ENOMEM; } reg_number = block_number * MPIC_MSGR_REGISTERS_PER_BLOCK + i; msgr->base = msgr_block_addr + i * MPIC_MSGR_STRIDE; msgr->mer = (u32 *)((u8 *)msgr->base + MPIC_MSGR_MER_OFFSET); msgr->in_use = MSGR_FREE; msgr->num = i; raw_spin_lock_init(&msgr->lock); if (receive_mask & (1 << i)) { struct resource irq; if (of_irq_to_resource(np, irq_index, &irq) == NO_IRQ) { dev_err(&dev->dev, "Missing interrupt specifier"); kfree(msgr); return -EFAULT; } msgr->irq = irq.start; irq_index += 1; } else { msgr->irq = NO_IRQ; } mpic_msgrs[reg_number] = msgr; mpic_msgr_disable(msgr); dev_info(&dev->dev, "Register %d initialized: irq %d\n", reg_number, msgr->irq); } return 0; } static const struct of_device_id mpic_msgr_ids[] = { { .compatible = "fsl,mpic-v3.1-msgr", .data = NULL, }, {} }; static struct platform_driver mpic_msgr_driver = { .driver = { .name = "mpic-msgr", .owner = THIS_MODULE, .of_match_table = mpic_msgr_ids, }, .probe = mpic_msgr_probe, }; static __init int mpic_msgr_init(void) { return platform_driver_register(&mpic_msgr_driver); } subsys_initcall(mpic_msgr_init);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
You can’t perform that action at this time.