| 159 | } |
| 160 | |
| 161 | static 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 | { |
nothing calls this directly
no test coverage detected