| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2015 Freescale Semiconductor, Inc. All rights reserved. |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 5 | 6 | * |
|---|
| 6 | 7 | * Description: |
|---|
| 7 | 8 | * QE TDM API Set - TDM specific routines implementations. |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 10 | | - * under the terms of the GNU General Public License as published by the |
|---|
| 11 | | - * Free Software Foundation; either version 2 of the License, or (at your |
|---|
| 12 | | - * option) any later version. |
|---|
| 13 | 9 | */ |
|---|
| 14 | 10 | #include <linux/io.h> |
|---|
| 15 | 11 | #include <linux/kernel.h> |
|---|
| .. | .. |
|---|
| 44 | 40 | const char *sprop; |
|---|
| 45 | 41 | int ret = 0; |
|---|
| 46 | 42 | u32 val; |
|---|
| 47 | | - struct resource *res; |
|---|
| 48 | | - struct device_node *np2; |
|---|
| 49 | | - static int siram_init_flag; |
|---|
| 50 | | - struct platform_device *pdev; |
|---|
| 51 | 43 | |
|---|
| 52 | 44 | sprop = of_get_property(np, "fsl,rx-sync-clock", NULL); |
|---|
| 53 | 45 | if (sprop) { |
|---|
| .. | .. |
|---|
| 124 | 116 | utdm->siram_entry_id = val; |
|---|
| 125 | 117 | |
|---|
| 126 | 118 | set_si_param(utdm, ut_info); |
|---|
| 127 | | - |
|---|
| 128 | | - np2 = of_find_compatible_node(NULL, NULL, "fsl,t1040-qe-si"); |
|---|
| 129 | | - if (!np2) |
|---|
| 130 | | - return -EINVAL; |
|---|
| 131 | | - |
|---|
| 132 | | - pdev = of_find_device_by_node(np2); |
|---|
| 133 | | - if (!pdev) { |
|---|
| 134 | | - pr_err("%s: failed to lookup pdev\n", np2->name); |
|---|
| 135 | | - of_node_put(np2); |
|---|
| 136 | | - return -EINVAL; |
|---|
| 137 | | - } |
|---|
| 138 | | - |
|---|
| 139 | | - of_node_put(np2); |
|---|
| 140 | | - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
|---|
| 141 | | - utdm->si_regs = devm_ioremap_resource(&pdev->dev, res); |
|---|
| 142 | | - if (IS_ERR(utdm->si_regs)) { |
|---|
| 143 | | - ret = PTR_ERR(utdm->si_regs); |
|---|
| 144 | | - goto err_miss_siram_property; |
|---|
| 145 | | - } |
|---|
| 146 | | - |
|---|
| 147 | | - np2 = of_find_compatible_node(NULL, NULL, "fsl,t1040-qe-siram"); |
|---|
| 148 | | - if (!np2) { |
|---|
| 149 | | - ret = -EINVAL; |
|---|
| 150 | | - goto err_miss_siram_property; |
|---|
| 151 | | - } |
|---|
| 152 | | - |
|---|
| 153 | | - pdev = of_find_device_by_node(np2); |
|---|
| 154 | | - if (!pdev) { |
|---|
| 155 | | - ret = -EINVAL; |
|---|
| 156 | | - pr_err("%s: failed to lookup pdev\n", np2->name); |
|---|
| 157 | | - of_node_put(np2); |
|---|
| 158 | | - goto err_miss_siram_property; |
|---|
| 159 | | - } |
|---|
| 160 | | - |
|---|
| 161 | | - of_node_put(np2); |
|---|
| 162 | | - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
|---|
| 163 | | - utdm->siram = devm_ioremap_resource(&pdev->dev, res); |
|---|
| 164 | | - if (IS_ERR(utdm->siram)) { |
|---|
| 165 | | - ret = PTR_ERR(utdm->siram); |
|---|
| 166 | | - goto err_miss_siram_property; |
|---|
| 167 | | - } |
|---|
| 168 | | - |
|---|
| 169 | | - if (siram_init_flag == 0) { |
|---|
| 170 | | - memset_io(utdm->siram, 0, resource_size(res)); |
|---|
| 171 | | - siram_init_flag = 1; |
|---|
| 172 | | - } |
|---|
| 173 | | - |
|---|
| 174 | | - return ret; |
|---|
| 175 | | - |
|---|
| 176 | | -err_miss_siram_property: |
|---|
| 177 | | - devm_iounmap(&pdev->dev, utdm->si_regs); |
|---|
| 178 | 119 | return ret; |
|---|
| 179 | 120 | } |
|---|
| 180 | 121 | EXPORT_SYMBOL(ucc_of_parse_tdm); |
|---|
| .. | .. |
|---|
| 228 | 169 | &siram[siram_entry_id * 32 + 0x200 + i]); |
|---|
| 229 | 170 | } |
|---|
| 230 | 171 | |
|---|
| 231 | | - setbits16(&siram[(siram_entry_id * 32) + (utdm->num_of_ts - 1)], |
|---|
| 232 | | - SIR_LAST); |
|---|
| 233 | | - setbits16(&siram[(siram_entry_id * 32) + 0x200 + (utdm->num_of_ts - 1)], |
|---|
| 234 | | - SIR_LAST); |
|---|
| 172 | + qe_setbits_be16(&siram[(siram_entry_id * 32) + (utdm->num_of_ts - 1)], |
|---|
| 173 | + SIR_LAST); |
|---|
| 174 | + qe_setbits_be16(&siram[(siram_entry_id * 32) + 0x200 + (utdm->num_of_ts - 1)], |
|---|
| 175 | + SIR_LAST); |
|---|
| 235 | 176 | |
|---|
| 236 | 177 | /* Set SIxMR register */ |
|---|
| 237 | 178 | sixmr = SIMR_SAD(siram_entry_id); |
|---|