| 162 | } |
| 163 | |
| 164 | static rt_err_t syscon_probe(struct rt_platform_device *pdev) |
| 165 | { |
| 166 | rt_err_t err; |
| 167 | rt_ubase_t level; |
| 168 | struct rt_ofw_node *np; |
| 169 | rt_uint64_t iomem_range[2]; |
| 170 | struct rt_syscon *syscon = rt_calloc(1, sizeof(*syscon)); |
| 171 | |
| 172 | if (!syscon) |
| 173 | { |
| 174 | return -RT_ENOMEM; |
| 175 | } |
| 176 | |
| 177 | np = pdev->parent.ofw_node; |
| 178 | |
| 179 | if ((err = rt_ofw_get_address(np, 0, &iomem_range[0], &iomem_range[1]))) |
| 180 | { |
| 181 | goto _fail; |
| 182 | } |
| 183 | |
| 184 | syscon->iomem_size = (rt_size_t)iomem_range[1]; |
| 185 | syscon->iomem_base = rt_ioremap((void *)iomem_range[0], syscon->iomem_size); |
| 186 | |
| 187 | if (!syscon->iomem_base) |
| 188 | { |
| 189 | goto _fail; |
| 190 | } |
| 191 | |
| 192 | rt_list_init(&syscon->list); |
| 193 | level = rt_spin_lock_irqsave(&_syscon_nodes_lock); |
| 194 | rt_list_insert_after(&_syscon_nodes, &syscon->list); |
| 195 | rt_spin_unlock_irqrestore(&_syscon_nodes_lock, level); |
| 196 | |
| 197 | rt_spin_lock_init(&syscon->rw_lock); |
| 198 | |
| 199 | pdev->parent.user_data = syscon; |
| 200 | |
| 201 | syscon->np = pdev->parent.ofw_node; |
| 202 | rt_ofw_data(np) = syscon; |
| 203 | |
| 204 | return RT_EOK; |
| 205 | |
| 206 | _fail: |
| 207 | rt_free(syscon); |
| 208 | |
| 209 | return err; |
| 210 | } |
| 211 | |
| 212 | static rt_err_t syscon_remove(struct rt_platform_device *pdev) |
| 213 | { |
no test coverage detected