MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / pic_mbox_probe

Function pic_mbox_probe

components/drivers/mailbox/mailbox-pic.c:161–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159}
160
161static rt_err_t pic_mbox_probe(struct rt_platform_device *pdev)
162{
163 rt_err_t err;
164 rt_uint64_t size;
165 rt_uint32_t value;
166 char dev_name[RT_NAME_MAX];
167 struct rt_ofw_node *pic_np;
168 struct rt_device *dev = &pdev->parent;
169 struct pic_mbox *pic_mbox = rt_calloc(1, sizeof(*pic_mbox));
170
171 if (!pic_mbox)
172 {
173 return -RT_ENOMEM;
174 }
175
176 if ((err = rt_dm_dev_get_address(dev, 0, RT_NULL, &size)))
177 {
178 goto _fail;
179 }
180
181 if ((err = rt_dm_dev_prop_read_u32(dev, "position", &value)))
182 {
183 goto _fail;
184 }
185
186 if (!value)
187 {
188 pic_mbox->regs = rt_dm_dev_iomap(dev, 0);
189
190 if (!pic_mbox->regs)
191 {
192 goto _fail;
193 }
194
195 pic_mbox->peer_regs = pic_mbox->regs + size / 2;
196
197 /* Init by the captain */
198 HWREG32(pic_mbox->regs + MAILBOX_IMASK) = 0xffffffff;
199 HWREG32(pic_mbox->regs + MAILBOX_ISTATE) = 0;
200 HWREG32(pic_mbox->peer_regs + MAILBOX_IMASK) = 0xffffffff;
201 HWREG32(pic_mbox->peer_regs + MAILBOX_ISTATE) = 0;
202 }
203 else
204 {
205 pic_mbox->peer_regs = rt_dm_dev_iomap(dev, 0);
206
207 if (!pic_mbox->peer_regs)
208 {
209 goto _fail;
210 }
211
212 pic_mbox->regs = pic_mbox->peer_regs + size / 2;
213 }
214
215 pic_mbox->irq = rt_dm_dev_get_irq(dev, 0);
216
217 if (pic_mbox->irq < 0)
218 {

Callers

nothing calls this directly

Calls 13

rt_callocFunction · 0.85
rt_dm_dev_get_addressFunction · 0.85
rt_dm_dev_prop_read_u32Function · 0.85
rt_dm_dev_iomapFunction · 0.85
rt_dm_dev_get_irqFunction · 0.85
rt_ofw_find_irq_parentFunction · 0.85
rt_ofw_node_putFunction · 0.85
rt_snprintfFunction · 0.85
pic_mbox_free_resourceFunction · 0.85
rt_spin_lock_initFunction · 0.50
rt_hw_interrupt_installFunction · 0.50

Tested by

no test coverage detected