Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 1 | /* |
| 2 | * ti-sysc.c - Texas Instruments sysc interconnect target driver |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License version 2 as |
| 6 | * published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any |
| 9 | * kind, whether express or implied; without even the implied warranty |
| 10 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | */ |
| 13 | |
| 14 | #include <linux/io.h> |
| 15 | #include <linux/clk.h> |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 16 | #include <linux/clkdev.h> |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 17 | #include <linux/delay.h> |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 18 | #include <linux/module.h> |
| 19 | #include <linux/platform_device.h> |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 20 | #include <linux/pm_domain.h> |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 21 | #include <linux/pm_runtime.h> |
Tony Lindgren | 5062236 | 2018-04-16 10:20:27 -0700 | [diff] [blame] | 22 | #include <linux/reset.h> |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 23 | #include <linux/of_address.h> |
| 24 | #include <linux/of_platform.h> |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 25 | #include <linux/slab.h> |
Faiz Abbas | 596e795 | 2018-07-09 22:18:39 +0530 | [diff] [blame] | 26 | #include <linux/iopoll.h> |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 27 | |
Tony Lindgren | 70a6524 | 2017-12-15 09:41:09 -0800 | [diff] [blame] | 28 | #include <linux/platform_data/ti-sysc.h> |
| 29 | |
| 30 | #include <dt-bindings/bus/ti-sysc.h> |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 31 | |
Faiz Abbas | 596e795 | 2018-07-09 22:18:39 +0530 | [diff] [blame] | 32 | #define MAX_MODULE_SOFTRESET_WAIT 10000 |
| 33 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 34 | static const char * const reg_names[] = { "rev", "sysc", "syss", }; |
| 35 | |
| 36 | enum sysc_clocks { |
| 37 | SYSC_FCK, |
| 38 | SYSC_ICK, |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 39 | SYSC_OPTFCK0, |
| 40 | SYSC_OPTFCK1, |
| 41 | SYSC_OPTFCK2, |
| 42 | SYSC_OPTFCK3, |
| 43 | SYSC_OPTFCK4, |
| 44 | SYSC_OPTFCK5, |
| 45 | SYSC_OPTFCK6, |
| 46 | SYSC_OPTFCK7, |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 47 | SYSC_MAX_CLOCKS, |
| 48 | }; |
| 49 | |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 50 | static const char * const clock_names[SYSC_ICK + 1] = { "fck", "ick", }; |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 51 | |
Tony Lindgren | c5a2de9 | 2017-12-15 09:41:23 -0800 | [diff] [blame] | 52 | #define SYSC_IDLEMODE_MASK 3 |
| 53 | #define SYSC_CLOCKACTIVITY_MASK 3 |
| 54 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 55 | /** |
| 56 | * struct sysc - TI sysc interconnect target module registers and capabilities |
| 57 | * @dev: struct device pointer |
| 58 | * @module_pa: physical address of the interconnect target module |
| 59 | * @module_size: size of the interconnect target module |
| 60 | * @module_va: virtual address of the interconnect target module |
| 61 | * @offsets: register offsets from module base |
| 62 | * @clocks: clocks used by the interconnect target module |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 63 | * @clock_roles: clock role names for the found clocks |
| 64 | * @nr_clocks: number of clocks used by the interconnect target module |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 65 | * @legacy_mode: configured for legacy mode if set |
Tony Lindgren | 70a6524 | 2017-12-15 09:41:09 -0800 | [diff] [blame] | 66 | * @cap: interconnect target module capabilities |
| 67 | * @cfg: interconnect target module configuration |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 68 | * @name: name if available |
| 69 | * @revision: interconnect target module revision |
Tony Lindgren | 62020f2 | 2018-02-22 13:59:44 -0800 | [diff] [blame] | 70 | * @needs_resume: runtime resume needed on resume from suspend |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 71 | */ |
| 72 | struct sysc { |
| 73 | struct device *dev; |
| 74 | u64 module_pa; |
| 75 | u32 module_size; |
| 76 | void __iomem *module_va; |
| 77 | int offsets[SYSC_MAX_REGS]; |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 78 | struct clk **clocks; |
| 79 | const char **clock_roles; |
| 80 | int nr_clocks; |
Tony Lindgren | 5062236 | 2018-04-16 10:20:27 -0700 | [diff] [blame] | 81 | struct reset_control *rsts; |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 82 | const char *legacy_mode; |
Tony Lindgren | 70a6524 | 2017-12-15 09:41:09 -0800 | [diff] [blame] | 83 | const struct sysc_capabilities *cap; |
| 84 | struct sysc_config cfg; |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 85 | struct ti_sysc_cookie cookie; |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 86 | const char *name; |
| 87 | u32 revision; |
Tony Lindgren | 62020f2 | 2018-02-22 13:59:44 -0800 | [diff] [blame] | 88 | bool enabled; |
| 89 | bool needs_resume; |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 90 | bool child_needs_resume; |
Tony Lindgren | 76f0f77 | 2018-02-23 08:28:45 -0800 | [diff] [blame] | 91 | struct delayed_work idle_work; |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 92 | }; |
| 93 | |
Tony Lindgren | 4014c08 | 2018-12-10 14:11:26 -0800 | [diff] [blame] | 94 | static void sysc_parse_dts_quirks(struct sysc *ddata, struct device_node *np, |
| 95 | bool is_child); |
| 96 | |
Tony Lindgren | b7182b4 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 97 | static void sysc_write(struct sysc *ddata, int offset, u32 value) |
Faiz Abbas | 596e795 | 2018-07-09 22:18:39 +0530 | [diff] [blame] | 98 | { |
| 99 | writel_relaxed(value, ddata->module_va + offset); |
| 100 | } |
| 101 | |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 102 | static u32 sysc_read(struct sysc *ddata, int offset) |
| 103 | { |
| 104 | if (ddata->cfg.quirks & SYSC_QUIRK_16BIT) { |
| 105 | u32 val; |
| 106 | |
| 107 | val = readw_relaxed(ddata->module_va + offset); |
| 108 | val |= (readw_relaxed(ddata->module_va + offset + 4) << 16); |
| 109 | |
| 110 | return val; |
| 111 | } |
| 112 | |
| 113 | return readl_relaxed(ddata->module_va + offset); |
| 114 | } |
| 115 | |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 116 | static bool sysc_opt_clks_needed(struct sysc *ddata) |
| 117 | { |
| 118 | return !!(ddata->cfg.quirks & SYSC_QUIRK_OPT_CLKS_NEEDED); |
| 119 | } |
| 120 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 121 | static u32 sysc_read_revision(struct sysc *ddata) |
| 122 | { |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 123 | int offset = ddata->offsets[SYSC_REVISION]; |
| 124 | |
| 125 | if (offset < 0) |
| 126 | return 0; |
| 127 | |
| 128 | return sysc_read(ddata, offset); |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 129 | } |
| 130 | |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 131 | static int sysc_get_one_clock(struct sysc *ddata, const char *name) |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 132 | { |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 133 | int error, i, index = -ENODEV; |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 134 | |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 135 | if (!strncmp(clock_names[SYSC_FCK], name, 3)) |
| 136 | index = SYSC_FCK; |
| 137 | else if (!strncmp(clock_names[SYSC_ICK], name, 3)) |
| 138 | index = SYSC_ICK; |
| 139 | |
| 140 | if (index < 0) { |
| 141 | for (i = SYSC_OPTFCK0; i < SYSC_MAX_CLOCKS; i++) { |
Tony Lindgren | c97c862 | 2018-05-18 07:54:44 -0700 | [diff] [blame] | 142 | if (!ddata->clocks[i]) { |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 143 | index = i; |
| 144 | break; |
| 145 | } |
| 146 | } |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 147 | } |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 148 | |
| 149 | if (index < 0) { |
| 150 | dev_err(ddata->dev, "clock %s not added\n", name); |
| 151 | return index; |
| 152 | } |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 153 | |
| 154 | ddata->clocks[index] = devm_clk_get(ddata->dev, name); |
| 155 | if (IS_ERR(ddata->clocks[index])) { |
| 156 | if (PTR_ERR(ddata->clocks[index]) == -ENOENT) |
| 157 | return 0; |
| 158 | |
| 159 | dev_err(ddata->dev, "clock get error for %s: %li\n", |
| 160 | name, PTR_ERR(ddata->clocks[index])); |
| 161 | |
| 162 | return PTR_ERR(ddata->clocks[index]); |
| 163 | } |
| 164 | |
| 165 | error = clk_prepare(ddata->clocks[index]); |
| 166 | if (error) { |
| 167 | dev_err(ddata->dev, "clock prepare error for %s: %i\n", |
| 168 | name, error); |
| 169 | |
| 170 | return error; |
| 171 | } |
| 172 | |
| 173 | return 0; |
| 174 | } |
| 175 | |
| 176 | static int sysc_get_clocks(struct sysc *ddata) |
| 177 | { |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 178 | struct device_node *np = ddata->dev->of_node; |
| 179 | struct property *prop; |
| 180 | const char *name; |
| 181 | int nr_fck = 0, nr_ick = 0, i, error = 0; |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 182 | |
Kees Cook | 2074905 | 2018-06-18 10:45:49 -0700 | [diff] [blame] | 183 | ddata->clock_roles = devm_kcalloc(ddata->dev, |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 184 | SYSC_MAX_CLOCKS, |
Kees Cook | 2074905 | 2018-06-18 10:45:49 -0700 | [diff] [blame] | 185 | sizeof(*ddata->clock_roles), |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 186 | GFP_KERNEL); |
| 187 | if (!ddata->clock_roles) |
| 188 | return -ENOMEM; |
| 189 | |
| 190 | of_property_for_each_string(np, "clock-names", prop, name) { |
| 191 | if (!strncmp(clock_names[SYSC_FCK], name, 3)) |
| 192 | nr_fck++; |
| 193 | if (!strncmp(clock_names[SYSC_ICK], name, 3)) |
| 194 | nr_ick++; |
| 195 | ddata->clock_roles[ddata->nr_clocks] = name; |
| 196 | ddata->nr_clocks++; |
| 197 | } |
| 198 | |
| 199 | if (ddata->nr_clocks < 1) |
| 200 | return 0; |
| 201 | |
| 202 | if (ddata->nr_clocks > SYSC_MAX_CLOCKS) { |
| 203 | dev_err(ddata->dev, "too many clocks for %pOF\n", np); |
| 204 | |
| 205 | return -EINVAL; |
| 206 | } |
| 207 | |
| 208 | if (nr_fck > 1 || nr_ick > 1) { |
| 209 | dev_err(ddata->dev, "max one fck and ick for %pOF\n", np); |
| 210 | |
| 211 | return -EINVAL; |
| 212 | } |
| 213 | |
Kees Cook | 2074905 | 2018-06-18 10:45:49 -0700 | [diff] [blame] | 214 | ddata->clocks = devm_kcalloc(ddata->dev, |
| 215 | ddata->nr_clocks, sizeof(*ddata->clocks), |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 216 | GFP_KERNEL); |
| 217 | if (!ddata->clocks) |
| 218 | return -ENOMEM; |
| 219 | |
Tony Lindgren | 7b4f8ac | 2018-11-15 14:46:52 -0800 | [diff] [blame] | 220 | for (i = 0; i < SYSC_MAX_CLOCKS; i++) { |
| 221 | const char *name = ddata->clock_roles[i]; |
| 222 | |
| 223 | if (!name) |
| 224 | continue; |
| 225 | |
| 226 | error = sysc_get_one_clock(ddata, name); |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 227 | if (error && error != -ENOENT) |
| 228 | return error; |
| 229 | } |
| 230 | |
| 231 | return 0; |
| 232 | } |
| 233 | |
Tony Lindgren | d878970 | 2019-03-21 11:00:21 -0700 | [diff] [blame^] | 234 | static int sysc_enable_main_clocks(struct sysc *ddata) |
| 235 | { |
| 236 | struct clk *clock; |
| 237 | int i, error; |
| 238 | |
| 239 | if (!ddata->clocks) |
| 240 | return 0; |
| 241 | |
| 242 | for (i = 0; i < SYSC_OPTFCK0; i++) { |
| 243 | clock = ddata->clocks[i]; |
| 244 | |
| 245 | /* Main clocks may not have ick */ |
| 246 | if (IS_ERR_OR_NULL(clock)) |
| 247 | continue; |
| 248 | |
| 249 | error = clk_enable(clock); |
| 250 | if (error) |
| 251 | goto err_disable; |
| 252 | } |
| 253 | |
| 254 | return 0; |
| 255 | |
| 256 | err_disable: |
| 257 | for (i--; i >= 0; i--) { |
| 258 | clock = ddata->clocks[i]; |
| 259 | |
| 260 | /* Main clocks may not have ick */ |
| 261 | if (IS_ERR_OR_NULL(clock)) |
| 262 | continue; |
| 263 | |
| 264 | clk_disable(clock); |
| 265 | } |
| 266 | |
| 267 | return error; |
| 268 | } |
| 269 | |
| 270 | static void sysc_disable_main_clocks(struct sysc *ddata) |
| 271 | { |
| 272 | struct clk *clock; |
| 273 | int i; |
| 274 | |
| 275 | if (!ddata->clocks) |
| 276 | return; |
| 277 | |
| 278 | for (i = 0; i < SYSC_OPTFCK0; i++) { |
| 279 | clock = ddata->clocks[i]; |
| 280 | if (IS_ERR_OR_NULL(clock)) |
| 281 | continue; |
| 282 | |
| 283 | clk_disable(clock); |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | static int sysc_enable_opt_clocks(struct sysc *ddata) |
| 288 | { |
| 289 | struct clk *clock; |
| 290 | int i, error; |
| 291 | |
| 292 | if (!ddata->clocks) |
| 293 | return 0; |
| 294 | |
| 295 | for (i = SYSC_OPTFCK0; i < SYSC_MAX_CLOCKS; i++) { |
| 296 | clock = ddata->clocks[i]; |
| 297 | |
| 298 | /* Assume no holes for opt clocks */ |
| 299 | if (IS_ERR_OR_NULL(clock)) |
| 300 | return 0; |
| 301 | |
| 302 | error = clk_enable(clock); |
| 303 | if (error) |
| 304 | goto err_disable; |
| 305 | } |
| 306 | |
| 307 | return 0; |
| 308 | |
| 309 | err_disable: |
| 310 | for (i--; i >= 0; i--) { |
| 311 | clock = ddata->clocks[i]; |
| 312 | if (IS_ERR_OR_NULL(clock)) |
| 313 | continue; |
| 314 | |
| 315 | clk_disable(clock); |
| 316 | } |
| 317 | |
| 318 | return error; |
| 319 | } |
| 320 | |
| 321 | static void sysc_disable_opt_clocks(struct sysc *ddata) |
| 322 | { |
| 323 | struct clk *clock; |
| 324 | int i; |
| 325 | |
| 326 | if (!ddata->clocks) |
| 327 | return; |
| 328 | |
| 329 | for (i = SYSC_OPTFCK0; i < SYSC_MAX_CLOCKS; i++) { |
| 330 | clock = ddata->clocks[i]; |
| 331 | |
| 332 | /* Assume no holes for opt clocks */ |
| 333 | if (IS_ERR_OR_NULL(clock)) |
| 334 | return; |
| 335 | |
| 336 | clk_disable(clock); |
| 337 | } |
| 338 | } |
| 339 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 340 | /** |
Tony Lindgren | 5062236 | 2018-04-16 10:20:27 -0700 | [diff] [blame] | 341 | * sysc_init_resets - reset module on init |
| 342 | * @ddata: device driver data |
| 343 | * |
| 344 | * A module can have both OCP softreset control and external rstctrl. |
| 345 | * If more complicated rstctrl resets are needed, please handle these |
| 346 | * directly from the child device driver and map only the module reset |
| 347 | * for the parent interconnect target module device. |
| 348 | * |
| 349 | * Automatic reset of the module on init can be skipped with the |
| 350 | * "ti,no-reset-on-init" device tree property. |
| 351 | */ |
| 352 | static int sysc_init_resets(struct sysc *ddata) |
| 353 | { |
| 354 | int error; |
| 355 | |
| 356 | ddata->rsts = |
| 357 | devm_reset_control_array_get_optional_exclusive(ddata->dev); |
| 358 | if (IS_ERR(ddata->rsts)) |
| 359 | return PTR_ERR(ddata->rsts); |
| 360 | |
| 361 | if (ddata->cfg.quirks & SYSC_QUIRK_NO_RESET_ON_INIT) |
| 362 | goto deassert; |
| 363 | |
| 364 | error = reset_control_assert(ddata->rsts); |
| 365 | if (error) |
| 366 | return error; |
| 367 | |
| 368 | deassert: |
| 369 | error = reset_control_deassert(ddata->rsts); |
| 370 | if (error) |
| 371 | return error; |
| 372 | |
| 373 | return 0; |
| 374 | } |
| 375 | |
| 376 | /** |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 377 | * sysc_parse_and_check_child_range - parses module IO region from ranges |
| 378 | * @ddata: device driver data |
| 379 | * |
| 380 | * In general we only need rev, syss, and sysc registers and not the whole |
| 381 | * module range. But we do want the offsets for these registers from the |
| 382 | * module base. This allows us to check them against the legacy hwmod |
| 383 | * platform data. Let's also check the ranges are configured properly. |
| 384 | */ |
| 385 | static int sysc_parse_and_check_child_range(struct sysc *ddata) |
| 386 | { |
| 387 | struct device_node *np = ddata->dev->of_node; |
| 388 | const __be32 *ranges; |
| 389 | u32 nr_addr, nr_size; |
| 390 | int len, error; |
| 391 | |
| 392 | ranges = of_get_property(np, "ranges", &len); |
| 393 | if (!ranges) { |
| 394 | dev_err(ddata->dev, "missing ranges for %pOF\n", np); |
| 395 | |
| 396 | return -ENOENT; |
| 397 | } |
| 398 | |
| 399 | len /= sizeof(*ranges); |
| 400 | |
| 401 | if (len < 3) { |
| 402 | dev_err(ddata->dev, "incomplete ranges for %pOF\n", np); |
| 403 | |
| 404 | return -EINVAL; |
| 405 | } |
| 406 | |
| 407 | error = of_property_read_u32(np, "#address-cells", &nr_addr); |
| 408 | if (error) |
| 409 | return -ENOENT; |
| 410 | |
| 411 | error = of_property_read_u32(np, "#size-cells", &nr_size); |
| 412 | if (error) |
| 413 | return -ENOENT; |
| 414 | |
| 415 | if (nr_addr != 1 || nr_size != 1) { |
| 416 | dev_err(ddata->dev, "invalid ranges for %pOF\n", np); |
| 417 | |
| 418 | return -EINVAL; |
| 419 | } |
| 420 | |
| 421 | ranges++; |
| 422 | ddata->module_pa = of_translate_address(np, ranges++); |
| 423 | ddata->module_size = be32_to_cpup(ranges); |
| 424 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 425 | return 0; |
| 426 | } |
| 427 | |
Tony Lindgren | 3bb37c8 | 2018-02-22 14:05:14 -0800 | [diff] [blame] | 428 | static struct device_node *stdout_path; |
| 429 | |
| 430 | static void sysc_init_stdout_path(struct sysc *ddata) |
| 431 | { |
| 432 | struct device_node *np = NULL; |
| 433 | const char *uart; |
| 434 | |
| 435 | if (IS_ERR(stdout_path)) |
| 436 | return; |
| 437 | |
| 438 | if (stdout_path) |
| 439 | return; |
| 440 | |
| 441 | np = of_find_node_by_path("/chosen"); |
| 442 | if (!np) |
| 443 | goto err; |
| 444 | |
| 445 | uart = of_get_property(np, "stdout-path", NULL); |
| 446 | if (!uart) |
| 447 | goto err; |
| 448 | |
| 449 | np = of_find_node_by_path(uart); |
| 450 | if (!np) |
| 451 | goto err; |
| 452 | |
| 453 | stdout_path = np; |
| 454 | |
| 455 | return; |
| 456 | |
| 457 | err: |
| 458 | stdout_path = ERR_PTR(-ENODEV); |
| 459 | } |
| 460 | |
| 461 | static void sysc_check_quirk_stdout(struct sysc *ddata, |
| 462 | struct device_node *np) |
| 463 | { |
| 464 | sysc_init_stdout_path(ddata); |
| 465 | if (np != stdout_path) |
| 466 | return; |
| 467 | |
| 468 | ddata->cfg.quirks |= SYSC_QUIRK_NO_IDLE_ON_INIT | |
| 469 | SYSC_QUIRK_NO_RESET_ON_INIT; |
| 470 | } |
| 471 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 472 | /** |
| 473 | * sysc_check_one_child - check child configuration |
| 474 | * @ddata: device driver data |
| 475 | * @np: child device node |
| 476 | * |
| 477 | * Let's avoid messy situations where we have new interconnect target |
| 478 | * node but children have "ti,hwmods". These belong to the interconnect |
| 479 | * target node and are managed by this driver. |
| 480 | */ |
| 481 | static int sysc_check_one_child(struct sysc *ddata, |
| 482 | struct device_node *np) |
| 483 | { |
| 484 | const char *name; |
| 485 | |
| 486 | name = of_get_property(np, "ti,hwmods", NULL); |
| 487 | if (name) |
| 488 | dev_warn(ddata->dev, "really a child ti,hwmods property?"); |
| 489 | |
Tony Lindgren | 3bb37c8 | 2018-02-22 14:05:14 -0800 | [diff] [blame] | 490 | sysc_check_quirk_stdout(ddata, np); |
Tony Lindgren | 4014c08 | 2018-12-10 14:11:26 -0800 | [diff] [blame] | 491 | sysc_parse_dts_quirks(ddata, np, true); |
Tony Lindgren | 3bb37c8 | 2018-02-22 14:05:14 -0800 | [diff] [blame] | 492 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 493 | return 0; |
| 494 | } |
| 495 | |
| 496 | static int sysc_check_children(struct sysc *ddata) |
| 497 | { |
| 498 | struct device_node *child; |
| 499 | int error; |
| 500 | |
| 501 | for_each_child_of_node(ddata->dev->of_node, child) { |
| 502 | error = sysc_check_one_child(ddata, child); |
| 503 | if (error) |
| 504 | return error; |
| 505 | } |
| 506 | |
| 507 | return 0; |
| 508 | } |
| 509 | |
Tony Lindgren | a7199e2 | 2017-12-15 09:41:14 -0800 | [diff] [blame] | 510 | /* |
| 511 | * So far only I2C uses 16-bit read access with clockactivity with revision |
| 512 | * in two registers with stride of 4. We can detect this based on the rev |
| 513 | * register size to configure things far enough to be able to properly read |
| 514 | * the revision register. |
| 515 | */ |
| 516 | static void sysc_check_quirk_16bit(struct sysc *ddata, struct resource *res) |
| 517 | { |
Tony Lindgren | dd57ac1 | 2018-02-22 14:09:57 -0800 | [diff] [blame] | 518 | if (resource_size(res) == 8) |
Tony Lindgren | a7199e2 | 2017-12-15 09:41:14 -0800 | [diff] [blame] | 519 | ddata->cfg.quirks |= SYSC_QUIRK_16BIT | SYSC_QUIRK_USE_CLOCKACT; |
Tony Lindgren | a7199e2 | 2017-12-15 09:41:14 -0800 | [diff] [blame] | 520 | } |
| 521 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 522 | /** |
| 523 | * sysc_parse_one - parses the interconnect target module registers |
| 524 | * @ddata: device driver data |
| 525 | * @reg: register to parse |
| 526 | */ |
| 527 | static int sysc_parse_one(struct sysc *ddata, enum sysc_registers reg) |
| 528 | { |
| 529 | struct resource *res; |
| 530 | const char *name; |
| 531 | |
| 532 | switch (reg) { |
| 533 | case SYSC_REVISION: |
| 534 | case SYSC_SYSCONFIG: |
| 535 | case SYSC_SYSSTATUS: |
| 536 | name = reg_names[reg]; |
| 537 | break; |
| 538 | default: |
| 539 | return -EINVAL; |
| 540 | } |
| 541 | |
| 542 | res = platform_get_resource_byname(to_platform_device(ddata->dev), |
| 543 | IORESOURCE_MEM, name); |
| 544 | if (!res) { |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 545 | ddata->offsets[reg] = -ENODEV; |
| 546 | |
| 547 | return 0; |
| 548 | } |
| 549 | |
| 550 | ddata->offsets[reg] = res->start - ddata->module_pa; |
Tony Lindgren | a7199e2 | 2017-12-15 09:41:14 -0800 | [diff] [blame] | 551 | if (reg == SYSC_REVISION) |
| 552 | sysc_check_quirk_16bit(ddata, res); |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 553 | |
| 554 | return 0; |
| 555 | } |
| 556 | |
| 557 | static int sysc_parse_registers(struct sysc *ddata) |
| 558 | { |
| 559 | int i, error; |
| 560 | |
| 561 | for (i = 0; i < SYSC_MAX_REGS; i++) { |
| 562 | error = sysc_parse_one(ddata, i); |
| 563 | if (error) |
| 564 | return error; |
| 565 | } |
| 566 | |
| 567 | return 0; |
| 568 | } |
| 569 | |
| 570 | /** |
| 571 | * sysc_check_registers - check for misconfigured register overlaps |
| 572 | * @ddata: device driver data |
| 573 | */ |
| 574 | static int sysc_check_registers(struct sysc *ddata) |
| 575 | { |
| 576 | int i, j, nr_regs = 0, nr_matches = 0; |
| 577 | |
| 578 | for (i = 0; i < SYSC_MAX_REGS; i++) { |
| 579 | if (ddata->offsets[i] < 0) |
| 580 | continue; |
| 581 | |
| 582 | if (ddata->offsets[i] > (ddata->module_size - 4)) { |
| 583 | dev_err(ddata->dev, "register outside module range"); |
| 584 | |
| 585 | return -EINVAL; |
| 586 | } |
| 587 | |
| 588 | for (j = 0; j < SYSC_MAX_REGS; j++) { |
| 589 | if (ddata->offsets[j] < 0) |
| 590 | continue; |
| 591 | |
| 592 | if (ddata->offsets[i] == ddata->offsets[j]) |
| 593 | nr_matches++; |
| 594 | } |
| 595 | nr_regs++; |
| 596 | } |
| 597 | |
| 598 | if (nr_regs < 1) { |
| 599 | dev_err(ddata->dev, "missing registers\n"); |
| 600 | |
| 601 | return -EINVAL; |
| 602 | } |
| 603 | |
| 604 | if (nr_matches > nr_regs) { |
| 605 | dev_err(ddata->dev, "overlapping registers: (%i/%i)", |
| 606 | nr_regs, nr_matches); |
| 607 | |
| 608 | return -EINVAL; |
| 609 | } |
| 610 | |
| 611 | return 0; |
| 612 | } |
| 613 | |
| 614 | /** |
| 615 | * syc_ioremap - ioremap register space for the interconnect target module |
Tony Lindgren | 0ef8e3b | 2018-08-08 01:07:05 -0700 | [diff] [blame] | 616 | * @ddata: device driver data |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 617 | * |
| 618 | * Note that the interconnect target module registers can be anywhere |
Tony Lindgren | 0ef8e3b | 2018-08-08 01:07:05 -0700 | [diff] [blame] | 619 | * within the interconnect target module range. For example, SGX has |
| 620 | * them at offset 0x1fc00 in the 32MB module address space. And cpsw |
| 621 | * has them at offset 0x1200 in the CPSW_WR child. Usually the |
| 622 | * the interconnect target module registers are at the beginning of |
| 623 | * the module range though. |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 624 | */ |
| 625 | static int sysc_ioremap(struct sysc *ddata) |
| 626 | { |
Tony Lindgren | 0ef8e3b | 2018-08-08 01:07:05 -0700 | [diff] [blame] | 627 | int size; |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 628 | |
Tony Lindgren | 0ef8e3b | 2018-08-08 01:07:05 -0700 | [diff] [blame] | 629 | size = max3(ddata->offsets[SYSC_REVISION], |
| 630 | ddata->offsets[SYSC_SYSCONFIG], |
| 631 | ddata->offsets[SYSC_SYSSTATUS]); |
| 632 | |
| 633 | if (size < 0 || (size + sizeof(u32)) > ddata->module_size) |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 634 | return -EINVAL; |
| 635 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 636 | ddata->module_va = devm_ioremap(ddata->dev, |
| 637 | ddata->module_pa, |
Tony Lindgren | 0ef8e3b | 2018-08-08 01:07:05 -0700 | [diff] [blame] | 638 | size + sizeof(u32)); |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 639 | if (!ddata->module_va) |
| 640 | return -EIO; |
| 641 | |
| 642 | return 0; |
| 643 | } |
| 644 | |
| 645 | /** |
| 646 | * sysc_map_and_check_registers - ioremap and check device registers |
| 647 | * @ddata: device driver data |
| 648 | */ |
| 649 | static int sysc_map_and_check_registers(struct sysc *ddata) |
| 650 | { |
| 651 | int error; |
| 652 | |
| 653 | error = sysc_parse_and_check_child_range(ddata); |
| 654 | if (error) |
| 655 | return error; |
| 656 | |
| 657 | error = sysc_check_children(ddata); |
| 658 | if (error) |
| 659 | return error; |
| 660 | |
| 661 | error = sysc_parse_registers(ddata); |
| 662 | if (error) |
| 663 | return error; |
| 664 | |
| 665 | error = sysc_ioremap(ddata); |
| 666 | if (error) |
| 667 | return error; |
| 668 | |
| 669 | error = sysc_check_registers(ddata); |
| 670 | if (error) |
| 671 | return error; |
| 672 | |
| 673 | return 0; |
| 674 | } |
| 675 | |
| 676 | /** |
| 677 | * sysc_show_rev - read and show interconnect target module revision |
| 678 | * @bufp: buffer to print the information to |
| 679 | * @ddata: device driver data |
| 680 | */ |
| 681 | static int sysc_show_rev(char *bufp, struct sysc *ddata) |
| 682 | { |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 683 | int len; |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 684 | |
| 685 | if (ddata->offsets[SYSC_REVISION] < 0) |
| 686 | return sprintf(bufp, ":NA"); |
| 687 | |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 688 | len = sprintf(bufp, ":%08x", ddata->revision); |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 689 | |
| 690 | return len; |
| 691 | } |
| 692 | |
| 693 | static int sysc_show_reg(struct sysc *ddata, |
| 694 | char *bufp, enum sysc_registers reg) |
| 695 | { |
| 696 | if (ddata->offsets[reg] < 0) |
| 697 | return sprintf(bufp, ":NA"); |
| 698 | |
| 699 | return sprintf(bufp, ":%x", ddata->offsets[reg]); |
| 700 | } |
| 701 | |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 702 | static int sysc_show_name(char *bufp, struct sysc *ddata) |
| 703 | { |
| 704 | if (!ddata->name) |
| 705 | return 0; |
| 706 | |
| 707 | return sprintf(bufp, ":%s", ddata->name); |
| 708 | } |
| 709 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 710 | /** |
| 711 | * sysc_show_registers - show information about interconnect target module |
| 712 | * @ddata: device driver data |
| 713 | */ |
| 714 | static void sysc_show_registers(struct sysc *ddata) |
| 715 | { |
| 716 | char buf[128]; |
| 717 | char *bufp = buf; |
| 718 | int i; |
| 719 | |
| 720 | for (i = 0; i < SYSC_MAX_REGS; i++) |
| 721 | bufp += sysc_show_reg(ddata, bufp, i); |
| 722 | |
| 723 | bufp += sysc_show_rev(bufp, ddata); |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 724 | bufp += sysc_show_name(bufp, ddata); |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 725 | |
| 726 | dev_dbg(ddata->dev, "%llx:%x%s\n", |
| 727 | ddata->module_pa, ddata->module_size, |
| 728 | buf); |
| 729 | } |
| 730 | |
Tony Lindgren | ff43728 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 731 | static int __maybe_unused sysc_runtime_suspend_legacy(struct device *dev, |
| 732 | struct sysc *ddata) |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 733 | { |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 734 | struct ti_sysc_platform_data *pdata; |
Tony Lindgren | ff43728 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 735 | int error; |
| 736 | |
| 737 | pdata = dev_get_platdata(ddata->dev); |
| 738 | if (!pdata) |
| 739 | return 0; |
| 740 | |
| 741 | if (!pdata->idle_module) |
| 742 | return -ENODEV; |
| 743 | |
| 744 | error = pdata->idle_module(dev, &ddata->cookie); |
| 745 | if (error) |
| 746 | dev_err(dev, "%s: could not idle: %i\n", |
| 747 | __func__, error); |
| 748 | |
| 749 | return 0; |
| 750 | } |
| 751 | |
| 752 | static int __maybe_unused sysc_runtime_resume_legacy(struct device *dev, |
| 753 | struct sysc *ddata) |
| 754 | { |
| 755 | struct ti_sysc_platform_data *pdata; |
| 756 | int error; |
| 757 | |
| 758 | pdata = dev_get_platdata(ddata->dev); |
| 759 | if (!pdata) |
| 760 | return 0; |
| 761 | |
| 762 | if (!pdata->enable_module) |
| 763 | return -ENODEV; |
| 764 | |
| 765 | error = pdata->enable_module(dev, &ddata->cookie); |
| 766 | if (error) |
| 767 | dev_err(dev, "%s: could not enable: %i\n", |
| 768 | __func__, error); |
| 769 | |
| 770 | return 0; |
| 771 | } |
| 772 | |
| 773 | static int __maybe_unused sysc_runtime_suspend(struct device *dev) |
| 774 | { |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 775 | struct sysc *ddata; |
Tony Lindgren | d878970 | 2019-03-21 11:00:21 -0700 | [diff] [blame^] | 776 | int error = 0; |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 777 | |
| 778 | ddata = dev_get_drvdata(dev); |
| 779 | |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 780 | if (!ddata->enabled) |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 781 | return 0; |
| 782 | |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 783 | if (ddata->legacy_mode) { |
Tony Lindgren | ff43728 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 784 | error = sysc_runtime_suspend_legacy(dev, ddata); |
| 785 | if (!error) |
| 786 | ddata->enabled = false; |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 787 | |
Tony Lindgren | ff43728 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 788 | return error; |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 789 | } |
| 790 | |
Tony Lindgren | d878970 | 2019-03-21 11:00:21 -0700 | [diff] [blame^] | 791 | sysc_disable_main_clocks(ddata); |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 792 | |
Tony Lindgren | d878970 | 2019-03-21 11:00:21 -0700 | [diff] [blame^] | 793 | if (sysc_opt_clks_needed(ddata)) |
| 794 | sysc_disable_opt_clocks(ddata); |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 795 | |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 796 | ddata->enabled = false; |
| 797 | |
| 798 | return error; |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 799 | } |
| 800 | |
Arnd Bergmann | a4a5d49 | 2017-10-13 11:25:32 +0200 | [diff] [blame] | 801 | static int __maybe_unused sysc_runtime_resume(struct device *dev) |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 802 | { |
| 803 | struct sysc *ddata; |
Tony Lindgren | d878970 | 2019-03-21 11:00:21 -0700 | [diff] [blame^] | 804 | int error = 0; |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 805 | |
| 806 | ddata = dev_get_drvdata(dev); |
| 807 | |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 808 | if (ddata->enabled) |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 809 | return 0; |
| 810 | |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 811 | if (ddata->legacy_mode) { |
Tony Lindgren | ff43728 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 812 | error = sysc_runtime_resume_legacy(dev, ddata); |
| 813 | if (!error) |
| 814 | ddata->enabled = true; |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 815 | |
Tony Lindgren | ff43728 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 816 | return error; |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 817 | } |
| 818 | |
Tony Lindgren | d878970 | 2019-03-21 11:00:21 -0700 | [diff] [blame^] | 819 | if (sysc_opt_clks_needed(ddata)) { |
| 820 | error = sysc_enable_opt_clocks(ddata); |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 821 | if (error) |
| 822 | return error; |
| 823 | } |
| 824 | |
Tony Lindgren | d878970 | 2019-03-21 11:00:21 -0700 | [diff] [blame^] | 825 | error = sysc_enable_main_clocks(ddata); |
| 826 | if (error) |
| 827 | goto err_main_clocks; |
| 828 | |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 829 | ddata->enabled = true; |
| 830 | |
Tony Lindgren | d878970 | 2019-03-21 11:00:21 -0700 | [diff] [blame^] | 831 | return 0; |
| 832 | |
| 833 | err_main_clocks: |
| 834 | if (sysc_opt_clks_needed(ddata)) |
| 835 | sysc_disable_opt_clocks(ddata); |
| 836 | |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 837 | return error; |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 838 | } |
| 839 | |
Tony Lindgren | f5e80203 | 2018-10-01 09:33:28 -0700 | [diff] [blame] | 840 | static int __maybe_unused sysc_noirq_suspend(struct device *dev) |
Tony Lindgren | 62020f2 | 2018-02-22 13:59:44 -0800 | [diff] [blame] | 841 | { |
| 842 | struct sysc *ddata; |
| 843 | |
| 844 | ddata = dev_get_drvdata(dev); |
| 845 | |
Tony Lindgren | 40d9f91 | 2018-09-24 12:16:54 -0700 | [diff] [blame] | 846 | if (ddata->cfg.quirks & SYSC_QUIRK_LEGACY_IDLE) |
Tony Lindgren | e7420c2 | 2018-04-16 10:26:46 -0700 | [diff] [blame] | 847 | return 0; |
| 848 | |
Tony Lindgren | f5e80203 | 2018-10-01 09:33:28 -0700 | [diff] [blame] | 849 | return pm_runtime_force_suspend(dev); |
Tony Lindgren | 62020f2 | 2018-02-22 13:59:44 -0800 | [diff] [blame] | 850 | } |
| 851 | |
Tony Lindgren | f5e80203 | 2018-10-01 09:33:28 -0700 | [diff] [blame] | 852 | static int __maybe_unused sysc_noirq_resume(struct device *dev) |
Tony Lindgren | 62020f2 | 2018-02-22 13:59:44 -0800 | [diff] [blame] | 853 | { |
| 854 | struct sysc *ddata; |
| 855 | |
| 856 | ddata = dev_get_drvdata(dev); |
Tony Lindgren | e7420c2 | 2018-04-16 10:26:46 -0700 | [diff] [blame] | 857 | |
Tony Lindgren | 40d9f91 | 2018-09-24 12:16:54 -0700 | [diff] [blame] | 858 | if (ddata->cfg.quirks & SYSC_QUIRK_LEGACY_IDLE) |
Tony Lindgren | e7420c2 | 2018-04-16 10:26:46 -0700 | [diff] [blame] | 859 | return 0; |
| 860 | |
Tony Lindgren | f5e80203 | 2018-10-01 09:33:28 -0700 | [diff] [blame] | 861 | return pm_runtime_force_resume(dev); |
Tony Lindgren | e7420c2 | 2018-04-16 10:26:46 -0700 | [diff] [blame] | 862 | } |
| 863 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 864 | static const struct dev_pm_ops sysc_pm_ops = { |
Tony Lindgren | e7420c2 | 2018-04-16 10:26:46 -0700 | [diff] [blame] | 865 | SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(sysc_noirq_suspend, sysc_noirq_resume) |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 866 | SET_RUNTIME_PM_OPS(sysc_runtime_suspend, |
| 867 | sysc_runtime_resume, |
| 868 | NULL) |
| 869 | }; |
| 870 | |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 871 | /* Module revision register based quirks */ |
| 872 | struct sysc_revision_quirk { |
| 873 | const char *name; |
| 874 | u32 base; |
| 875 | int rev_offset; |
| 876 | int sysc_offset; |
| 877 | int syss_offset; |
| 878 | u32 revision; |
| 879 | u32 revision_mask; |
| 880 | u32 quirks; |
| 881 | }; |
| 882 | |
| 883 | #define SYSC_QUIRK(optname, optbase, optrev, optsysc, optsyss, \ |
| 884 | optrev_val, optrevmask, optquirkmask) \ |
| 885 | { \ |
| 886 | .name = (optname), \ |
| 887 | .base = (optbase), \ |
| 888 | .rev_offset = (optrev), \ |
| 889 | .sysc_offset = (optsysc), \ |
| 890 | .syss_offset = (optsyss), \ |
| 891 | .revision = (optrev_val), \ |
| 892 | .revision_mask = (optrevmask), \ |
| 893 | .quirks = (optquirkmask), \ |
| 894 | } |
| 895 | |
| 896 | static const struct sysc_revision_quirk sysc_revision_quirks[] = { |
| 897 | /* These drivers need to be fixed to not use pm_runtime_irq_safe() */ |
Tony Lindgren | 3a3d802 | 2018-09-27 13:33:58 -0700 | [diff] [blame] | 898 | SYSC_QUIRK("gpio", 0, 0, 0x10, 0x114, 0x50600801, 0xffff00ff, |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 899 | SYSC_QUIRK_LEGACY_IDLE | SYSC_QUIRK_OPT_CLKS_IN_RESET), |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 900 | SYSC_QUIRK("mmu", 0, 0, 0x10, 0x14, 0x00000020, 0xffffffff, |
| 901 | SYSC_QUIRK_LEGACY_IDLE), |
| 902 | SYSC_QUIRK("mmu", 0, 0, 0x10, 0x14, 0x00000030, 0xffffffff, |
| 903 | SYSC_QUIRK_LEGACY_IDLE), |
| 904 | SYSC_QUIRK("sham", 0, 0x100, 0x110, 0x114, 0x40000c03, 0xffffffff, |
| 905 | SYSC_QUIRK_LEGACY_IDLE), |
| 906 | SYSC_QUIRK("smartreflex", 0, -1, 0x24, -1, 0x00000000, 0xffffffff, |
| 907 | SYSC_QUIRK_LEGACY_IDLE), |
| 908 | SYSC_QUIRK("smartreflex", 0, -1, 0x38, -1, 0x00000000, 0xffffffff, |
| 909 | SYSC_QUIRK_LEGACY_IDLE), |
| 910 | SYSC_QUIRK("timer", 0, 0, 0x10, 0x14, 0x00000015, 0xffffffff, |
Tony Lindgren | 9bd34c6 | 2019-01-22 09:03:08 -0800 | [diff] [blame] | 911 | 0), |
Tony Lindgren | 8cde5d5 | 2018-04-16 10:25:15 -0700 | [diff] [blame] | 912 | /* Some timers on omap4 and later */ |
Tony Lindgren | 3a3d802 | 2018-09-27 13:33:58 -0700 | [diff] [blame] | 913 | SYSC_QUIRK("timer", 0, 0, 0x10, -1, 0x50002100, 0xffffffff, |
Tony Lindgren | 072167d | 2019-01-29 07:53:47 -0800 | [diff] [blame] | 914 | 0), |
Tony Lindgren | 3a3d802 | 2018-09-27 13:33:58 -0700 | [diff] [blame] | 915 | SYSC_QUIRK("timer", 0, 0, 0x10, -1, 0x4fff1301, 0xffff00ff, |
Tony Lindgren | 9bd34c6 | 2019-01-22 09:03:08 -0800 | [diff] [blame] | 916 | 0), |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 917 | SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x00000052, 0xffffffff, |
| 918 | SYSC_QUIRK_LEGACY_IDLE), |
Tony Lindgren | d708bb1 | 2018-04-16 10:25:32 -0700 | [diff] [blame] | 919 | /* Uarts on omap4 and later */ |
Tony Lindgren | b82beef | 2018-09-24 12:16:59 -0700 | [diff] [blame] | 920 | SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x50411e03, 0xffff00ff, |
| 921 | SYSC_QUIRK_LEGACY_IDLE), |
| 922 | SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x47422e03, 0xffffffff, |
Tony Lindgren | d708bb1 | 2018-04-16 10:25:32 -0700 | [diff] [blame] | 923 | SYSC_QUIRK_LEGACY_IDLE), |
Tony Lindgren | 7e27e5d | 2018-04-20 14:54:16 -0700 | [diff] [blame] | 924 | |
Tony Lindgren | dc4c85e | 2018-04-16 10:26:25 -0700 | [diff] [blame] | 925 | #ifdef DEBUG |
Tony Lindgren | 1ba3069 | 2018-09-24 12:17:05 -0700 | [diff] [blame] | 926 | SYSC_QUIRK("adc", 0, 0, 0x10, -1, 0x47300001, 0xffffffff, 0), |
Tony Lindgren | c6eb4af | 2018-09-27 13:34:27 -0700 | [diff] [blame] | 927 | SYSC_QUIRK("atl", 0, 0, -1, -1, 0x0a070100, 0xffffffff, 0), |
Tony Lindgren | dc4c85e | 2018-04-16 10:26:25 -0700 | [diff] [blame] | 928 | SYSC_QUIRK("aess", 0, 0, 0x10, -1, 0x40000000, 0xffffffff, 0), |
Tony Lindgren | c6eb4af | 2018-09-27 13:34:27 -0700 | [diff] [blame] | 929 | SYSC_QUIRK("cm", 0, 0, -1, -1, 0x40000301, 0xffffffff, 0), |
Tony Lindgren | 40d9f91 | 2018-09-24 12:16:54 -0700 | [diff] [blame] | 930 | SYSC_QUIRK("control", 0, 0, 0x10, -1, 0x40000900, 0xffffffff, 0), |
Tony Lindgren | 1ba3069 | 2018-09-24 12:17:05 -0700 | [diff] [blame] | 931 | SYSC_QUIRK("cpgmac", 0, 0x1200, 0x1208, 0x1204, 0x4edb1902, |
Tony Lindgren | 23731ea | 2018-09-24 12:17:09 -0700 | [diff] [blame] | 932 | 0xffff00f0, 0), |
| 933 | SYSC_QUIRK("dcan", 0, 0, -1, -1, 0xffffffff, 0xffffffff, 0), |
Tony Lindgren | 1ba3069 | 2018-09-24 12:17:05 -0700 | [diff] [blame] | 934 | SYSC_QUIRK("dcan", 0, 0, -1, -1, 0x00001401, 0xffffffff, 0), |
| 935 | SYSC_QUIRK("dwc3", 0, 0, 0x10, -1, 0x500a0200, 0xffffffff, 0), |
| 936 | SYSC_QUIRK("epwmss", 0, 0, 0x4, -1, 0x47400001, 0xffffffff, 0), |
Tony Lindgren | dc4c85e | 2018-04-16 10:26:25 -0700 | [diff] [blame] | 937 | SYSC_QUIRK("gpu", 0, 0x1fc00, 0x1fc10, -1, 0, 0, 0), |
| 938 | SYSC_QUIRK("hdq1w", 0, 0, 0x14, 0x18, 0x00000006, 0xffffffff, 0), |
Tony Lindgren | 1ba3069 | 2018-09-24 12:17:05 -0700 | [diff] [blame] | 939 | SYSC_QUIRK("hdq1w", 0, 0, 0x14, 0x18, 0x0000000a, 0xffffffff, 0), |
Tony Lindgren | dc4c85e | 2018-04-16 10:26:25 -0700 | [diff] [blame] | 940 | SYSC_QUIRK("hsi", 0, 0, 0x10, 0x14, 0x50043101, 0xffffffff, 0), |
| 941 | SYSC_QUIRK("iss", 0, 0, 0x10, -1, 0x40000101, 0xffffffff, 0), |
Tony Lindgren | c6eb4af | 2018-09-27 13:34:27 -0700 | [diff] [blame] | 942 | SYSC_QUIRK("i2c", 0, 0, 0x10, 0x90, 0x5040000a, 0xfffff0f0, 0), |
Tony Lindgren | 23731ea | 2018-09-24 12:17:09 -0700 | [diff] [blame] | 943 | SYSC_QUIRK("lcdc", 0, 0, 0x54, -1, 0x4f201000, 0xffffffff, 0), |
Tony Lindgren | dc4c85e | 2018-04-16 10:26:25 -0700 | [diff] [blame] | 944 | SYSC_QUIRK("mcasp", 0, 0, 0x4, -1, 0x44306302, 0xffffffff, 0), |
Tony Lindgren | 1ba3069 | 2018-09-24 12:17:05 -0700 | [diff] [blame] | 945 | SYSC_QUIRK("mcasp", 0, 0, 0x4, -1, 0x44307b02, 0xffffffff, 0), |
Tony Lindgren | dc4c85e | 2018-04-16 10:26:25 -0700 | [diff] [blame] | 946 | SYSC_QUIRK("mcbsp", 0, -1, 0x8c, -1, 0, 0, 0), |
Tony Lindgren | c6eb4af | 2018-09-27 13:34:27 -0700 | [diff] [blame] | 947 | SYSC_QUIRK("mcspi", 0, 0, 0x10, -1, 0x40300a0b, 0xffff00ff, 0), |
Tony Lindgren | 1ba3069 | 2018-09-24 12:17:05 -0700 | [diff] [blame] | 948 | SYSC_QUIRK("mcspi", 0, 0, 0x110, 0x114, 0x40300a0b, 0xffffffff, 0), |
Tony Lindgren | dc4c85e | 2018-04-16 10:26:25 -0700 | [diff] [blame] | 949 | SYSC_QUIRK("mailbox", 0, 0, 0x10, -1, 0x00000400, 0xffffffff, 0), |
Tony Lindgren | 1ba3069 | 2018-09-24 12:17:05 -0700 | [diff] [blame] | 950 | SYSC_QUIRK("m3", 0, 0, -1, -1, 0x5f580105, 0x0fff0f00, 0), |
Tony Lindgren | c6eb4af | 2018-09-27 13:34:27 -0700 | [diff] [blame] | 951 | SYSC_QUIRK("ocp2scp", 0, 0, 0x10, 0x14, 0x50060005, 0xfffffff0, 0), |
Tony Lindgren | 1ba3069 | 2018-09-24 12:17:05 -0700 | [diff] [blame] | 952 | SYSC_QUIRK("ocp2scp", 0, 0, -1, -1, 0x50060007, 0xffffffff, 0), |
Tony Lindgren | 40d9f91 | 2018-09-24 12:16:54 -0700 | [diff] [blame] | 953 | SYSC_QUIRK("padconf", 0, 0, 0x10, -1, 0x4fff0800, 0xffffffff, 0), |
Tony Lindgren | f010670 | 2018-11-15 14:46:53 -0800 | [diff] [blame] | 954 | SYSC_QUIRK("padconf", 0, 0, -1, -1, 0x40001100, 0xffffffff, 0), |
Tony Lindgren | 40d9f91 | 2018-09-24 12:16:54 -0700 | [diff] [blame] | 955 | SYSC_QUIRK("prcm", 0, 0, -1, -1, 0x40000100, 0xffffffff, 0), |
Tony Lindgren | 23731ea | 2018-09-24 12:17:09 -0700 | [diff] [blame] | 956 | SYSC_QUIRK("prcm", 0, 0, -1, -1, 0x00004102, 0xffffffff, 0), |
Tony Lindgren | 1ba3069 | 2018-09-24 12:17:05 -0700 | [diff] [blame] | 957 | SYSC_QUIRK("prcm", 0, 0, -1, -1, 0x40000400, 0xffffffff, 0), |
Tony Lindgren | 40d9f91 | 2018-09-24 12:16:54 -0700 | [diff] [blame] | 958 | SYSC_QUIRK("scm", 0, 0, 0x10, -1, 0x40000900, 0xffffffff, 0), |
Tony Lindgren | 23731ea | 2018-09-24 12:17:09 -0700 | [diff] [blame] | 959 | SYSC_QUIRK("scm", 0, 0, -1, -1, 0x4e8b0100, 0xffffffff, 0), |
Tony Lindgren | 1ba3069 | 2018-09-24 12:17:05 -0700 | [diff] [blame] | 960 | SYSC_QUIRK("scm", 0, 0, -1, -1, 0x4f000100, 0xffffffff, 0), |
Tony Lindgren | c6eb4af | 2018-09-27 13:34:27 -0700 | [diff] [blame] | 961 | SYSC_QUIRK("scm", 0, 0, -1, -1, 0x40000900, 0xffffffff, 0), |
Tony Lindgren | 40d9f91 | 2018-09-24 12:16:54 -0700 | [diff] [blame] | 962 | SYSC_QUIRK("scrm", 0, 0, -1, -1, 0x00000010, 0xffffffff, 0), |
Tony Lindgren | c6eb4af | 2018-09-27 13:34:27 -0700 | [diff] [blame] | 963 | SYSC_QUIRK("sdio", 0, 0, 0x10, -1, 0x40202301, 0xffff0ff0, 0), |
Tony Lindgren | 1ba3069 | 2018-09-24 12:17:05 -0700 | [diff] [blame] | 964 | SYSC_QUIRK("sdio", 0, 0x2fc, 0x110, 0x114, 0x31010000, 0xffffffff, 0), |
Tony Lindgren | 40d9f91 | 2018-09-24 12:16:54 -0700 | [diff] [blame] | 965 | SYSC_QUIRK("sdma", 0, 0, 0x2c, 0x28, 0x00010900, 0xffffffff, 0), |
Tony Lindgren | dc4c85e | 2018-04-16 10:26:25 -0700 | [diff] [blame] | 966 | SYSC_QUIRK("slimbus", 0, 0, 0x10, -1, 0x40000902, 0xffffffff, 0), |
| 967 | SYSC_QUIRK("slimbus", 0, 0, 0x10, -1, 0x40002903, 0xffffffff, 0), |
| 968 | SYSC_QUIRK("spinlock", 0, 0, 0x10, -1, 0x50020000, 0xffffffff, 0), |
Tony Lindgren | 1ba3069 | 2018-09-24 12:17:05 -0700 | [diff] [blame] | 969 | SYSC_QUIRK("rng", 0, 0x1fe0, 0x1fe4, -1, 0x00000020, 0xffffffff, 0), |
Tony Lindgren | c6eb4af | 2018-09-27 13:34:27 -0700 | [diff] [blame] | 970 | SYSC_QUIRK("rtc", 0, 0x74, 0x78, -1, 0x4eb01908, 0xffff00f0, 0), |
Tony Lindgren | 1ba3069 | 2018-09-24 12:17:05 -0700 | [diff] [blame] | 971 | SYSC_QUIRK("timer32k", 0, 0, 0x4, -1, 0x00000060, 0xffffffff, 0), |
Tony Lindgren | dc4c85e | 2018-04-16 10:26:25 -0700 | [diff] [blame] | 972 | SYSC_QUIRK("usbhstll", 0, 0, 0x10, 0x14, 0x00000004, 0xffffffff, 0), |
Tony Lindgren | f010670 | 2018-11-15 14:46:53 -0800 | [diff] [blame] | 973 | SYSC_QUIRK("usbhstll", 0, 0, 0x10, 0x14, 0x00000008, 0xffffffff, 0), |
Tony Lindgren | dc4c85e | 2018-04-16 10:26:25 -0700 | [diff] [blame] | 974 | SYSC_QUIRK("usb_host_hs", 0, 0, 0x10, 0x14, 0x50700100, 0xffffffff, 0), |
Tony Lindgren | f010670 | 2018-11-15 14:46:53 -0800 | [diff] [blame] | 975 | SYSC_QUIRK("usb_host_hs", 0, 0, 0x10, -1, 0x50700101, 0xffffffff, 0), |
Tony Lindgren | dc4c85e | 2018-04-16 10:26:25 -0700 | [diff] [blame] | 976 | SYSC_QUIRK("usb_otg_hs", 0, 0x400, 0x404, 0x408, 0x00000050, |
| 977 | 0xffffffff, 0), |
Tony Lindgren | 1ba3069 | 2018-09-24 12:17:05 -0700 | [diff] [blame] | 978 | SYSC_QUIRK("wdt", 0, 0, 0x10, 0x14, 0x502a0500, 0xfffff0f0, 0), |
| 979 | SYSC_QUIRK("vfpe", 0, 0, 0x104, -1, 0x4d001200, 0xffffffff, 0), |
Tony Lindgren | dc4c85e | 2018-04-16 10:26:25 -0700 | [diff] [blame] | 980 | #endif |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 981 | }; |
| 982 | |
| 983 | static void sysc_init_revision_quirks(struct sysc *ddata) |
| 984 | { |
| 985 | const struct sysc_revision_quirk *q; |
| 986 | int i; |
| 987 | |
| 988 | for (i = 0; i < ARRAY_SIZE(sysc_revision_quirks); i++) { |
| 989 | q = &sysc_revision_quirks[i]; |
| 990 | |
| 991 | if (q->base && q->base != ddata->module_pa) |
| 992 | continue; |
| 993 | |
| 994 | if (q->rev_offset >= 0 && |
| 995 | q->rev_offset != ddata->offsets[SYSC_REVISION]) |
| 996 | continue; |
| 997 | |
| 998 | if (q->sysc_offset >= 0 && |
| 999 | q->sysc_offset != ddata->offsets[SYSC_SYSCONFIG]) |
| 1000 | continue; |
| 1001 | |
| 1002 | if (q->syss_offset >= 0 && |
| 1003 | q->syss_offset != ddata->offsets[SYSC_SYSSTATUS]) |
| 1004 | continue; |
| 1005 | |
| 1006 | if (q->revision == ddata->revision || |
| 1007 | (q->revision & q->revision_mask) == |
| 1008 | (ddata->revision & q->revision_mask)) { |
| 1009 | ddata->name = q->name; |
| 1010 | ddata->cfg.quirks |= q->quirks; |
| 1011 | } |
| 1012 | } |
| 1013 | } |
| 1014 | |
Faiz Abbas | 596e795 | 2018-07-09 22:18:39 +0530 | [diff] [blame] | 1015 | static int sysc_reset(struct sysc *ddata) |
| 1016 | { |
| 1017 | int offset = ddata->offsets[SYSC_SYSCONFIG]; |
| 1018 | int val; |
| 1019 | |
| 1020 | if (ddata->legacy_mode || offset < 0 || |
| 1021 | ddata->cfg.quirks & SYSC_QUIRK_NO_RESET_ON_INIT) |
| 1022 | return 0; |
| 1023 | |
| 1024 | /* |
| 1025 | * Currently only support reset status in sysstatus. |
| 1026 | * Warn and return error in all other cases |
| 1027 | */ |
| 1028 | if (!ddata->cfg.syss_mask) { |
| 1029 | dev_err(ddata->dev, "No ti,syss-mask. Reset failed\n"); |
| 1030 | return -EINVAL; |
| 1031 | } |
| 1032 | |
| 1033 | val = sysc_read(ddata, offset); |
| 1034 | val |= (0x1 << ddata->cap->regbits->srst_shift); |
| 1035 | sysc_write(ddata, offset, val); |
| 1036 | |
| 1037 | /* Poll on reset status */ |
| 1038 | offset = ddata->offsets[SYSC_SYSSTATUS]; |
| 1039 | |
| 1040 | return readl_poll_timeout(ddata->module_va + offset, val, |
| 1041 | (val & ddata->cfg.syss_mask) == 0x0, |
| 1042 | 100, MAX_MODULE_SOFTRESET_WAIT); |
| 1043 | } |
| 1044 | |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 1045 | /* At this point the module is configured enough to read the revision */ |
| 1046 | static int sysc_init_module(struct sysc *ddata) |
| 1047 | { |
| 1048 | int error; |
| 1049 | |
Tony Lindgren | 386cb76 | 2019-03-22 07:49:30 -0700 | [diff] [blame] | 1050 | if (ddata->cfg.quirks & |
| 1051 | (SYSC_QUIRK_NO_IDLE | SYSC_QUIRK_NO_IDLE_ON_INIT)) { |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1052 | ddata->revision = sysc_read_revision(ddata); |
| 1053 | goto rev_quirks; |
| 1054 | } |
| 1055 | |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 1056 | error = pm_runtime_get_sync(ddata->dev); |
| 1057 | if (error < 0) { |
| 1058 | pm_runtime_put_noidle(ddata->dev); |
| 1059 | |
| 1060 | return 0; |
| 1061 | } |
Tony Lindgren | 5062236 | 2018-04-16 10:20:27 -0700 | [diff] [blame] | 1062 | |
Faiz Abbas | 596e795 | 2018-07-09 22:18:39 +0530 | [diff] [blame] | 1063 | error = sysc_reset(ddata); |
| 1064 | if (error) { |
| 1065 | dev_err(ddata->dev, "Reset failed with %d\n", error); |
| 1066 | pm_runtime_put_sync(ddata->dev); |
| 1067 | |
| 1068 | return error; |
| 1069 | } |
| 1070 | |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 1071 | ddata->revision = sysc_read_revision(ddata); |
| 1072 | pm_runtime_put_sync(ddata->dev); |
| 1073 | |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1074 | rev_quirks: |
| 1075 | sysc_init_revision_quirks(ddata); |
| 1076 | |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 1077 | return 0; |
| 1078 | } |
| 1079 | |
Tony Lindgren | c5a2de9 | 2017-12-15 09:41:23 -0800 | [diff] [blame] | 1080 | static int sysc_init_sysc_mask(struct sysc *ddata) |
| 1081 | { |
| 1082 | struct device_node *np = ddata->dev->of_node; |
| 1083 | int error; |
| 1084 | u32 val; |
| 1085 | |
| 1086 | error = of_property_read_u32(np, "ti,sysc-mask", &val); |
| 1087 | if (error) |
| 1088 | return 0; |
| 1089 | |
| 1090 | if (val) |
| 1091 | ddata->cfg.sysc_val = val & ddata->cap->sysc_mask; |
| 1092 | else |
| 1093 | ddata->cfg.sysc_val = ddata->cap->sysc_mask; |
| 1094 | |
| 1095 | return 0; |
| 1096 | } |
| 1097 | |
| 1098 | static int sysc_init_idlemode(struct sysc *ddata, u8 *idlemodes, |
| 1099 | const char *name) |
| 1100 | { |
| 1101 | struct device_node *np = ddata->dev->of_node; |
| 1102 | struct property *prop; |
| 1103 | const __be32 *p; |
| 1104 | u32 val; |
| 1105 | |
| 1106 | of_property_for_each_u32(np, name, prop, p, val) { |
| 1107 | if (val >= SYSC_NR_IDLEMODES) { |
| 1108 | dev_err(ddata->dev, "invalid idlemode: %i\n", val); |
| 1109 | return -EINVAL; |
| 1110 | } |
| 1111 | *idlemodes |= (1 << val); |
| 1112 | } |
| 1113 | |
| 1114 | return 0; |
| 1115 | } |
| 1116 | |
| 1117 | static int sysc_init_idlemodes(struct sysc *ddata) |
| 1118 | { |
| 1119 | int error; |
| 1120 | |
| 1121 | error = sysc_init_idlemode(ddata, &ddata->cfg.midlemodes, |
| 1122 | "ti,sysc-midle"); |
| 1123 | if (error) |
| 1124 | return error; |
| 1125 | |
| 1126 | error = sysc_init_idlemode(ddata, &ddata->cfg.sidlemodes, |
| 1127 | "ti,sysc-sidle"); |
| 1128 | if (error) |
| 1129 | return error; |
| 1130 | |
| 1131 | return 0; |
| 1132 | } |
| 1133 | |
| 1134 | /* |
| 1135 | * Only some devices on omap4 and later have SYSCONFIG reset done |
| 1136 | * bit. We can detect this if there is no SYSSTATUS at all, or the |
| 1137 | * SYSTATUS bit 0 is not used. Note that some SYSSTATUS registers |
| 1138 | * have multiple bits for the child devices like OHCI and EHCI. |
| 1139 | * Depends on SYSC being parsed first. |
| 1140 | */ |
| 1141 | static int sysc_init_syss_mask(struct sysc *ddata) |
| 1142 | { |
| 1143 | struct device_node *np = ddata->dev->of_node; |
| 1144 | int error; |
| 1145 | u32 val; |
| 1146 | |
| 1147 | error = of_property_read_u32(np, "ti,syss-mask", &val); |
| 1148 | if (error) { |
| 1149 | if ((ddata->cap->type == TI_SYSC_OMAP4 || |
| 1150 | ddata->cap->type == TI_SYSC_OMAP4_TIMER) && |
| 1151 | (ddata->cfg.sysc_val & SYSC_OMAP4_SOFTRESET)) |
| 1152 | ddata->cfg.quirks |= SYSC_QUIRK_RESET_STATUS; |
| 1153 | |
| 1154 | return 0; |
| 1155 | } |
| 1156 | |
| 1157 | if (!(val & 1) && (ddata->cfg.sysc_val & SYSC_OMAP4_SOFTRESET)) |
| 1158 | ddata->cfg.quirks |= SYSC_QUIRK_RESET_STATUS; |
| 1159 | |
| 1160 | ddata->cfg.syss_mask = val; |
| 1161 | |
| 1162 | return 0; |
| 1163 | } |
| 1164 | |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 1165 | /* |
Tony Lindgren | 8b2830ba | 2018-04-16 10:26:09 -0700 | [diff] [blame] | 1166 | * Many child device drivers need to have fck and opt clocks available |
| 1167 | * to get the clock rate for device internal configuration etc. |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 1168 | */ |
Tony Lindgren | 8b2830ba | 2018-04-16 10:26:09 -0700 | [diff] [blame] | 1169 | static int sysc_child_add_named_clock(struct sysc *ddata, |
| 1170 | struct device *child, |
| 1171 | const char *name) |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 1172 | { |
Tony Lindgren | 8b2830ba | 2018-04-16 10:26:09 -0700 | [diff] [blame] | 1173 | struct clk *clk; |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 1174 | struct clk_lookup *l; |
Tony Lindgren | 8b2830ba | 2018-04-16 10:26:09 -0700 | [diff] [blame] | 1175 | int error = 0; |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 1176 | |
Tony Lindgren | 8b2830ba | 2018-04-16 10:26:09 -0700 | [diff] [blame] | 1177 | if (!name) |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 1178 | return 0; |
| 1179 | |
Tony Lindgren | 8b2830ba | 2018-04-16 10:26:09 -0700 | [diff] [blame] | 1180 | clk = clk_get(child, name); |
| 1181 | if (!IS_ERR(clk)) { |
| 1182 | clk_put(clk); |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 1183 | |
| 1184 | return -EEXIST; |
| 1185 | } |
| 1186 | |
Tony Lindgren | 8b2830ba | 2018-04-16 10:26:09 -0700 | [diff] [blame] | 1187 | clk = clk_get(ddata->dev, name); |
| 1188 | if (IS_ERR(clk)) |
| 1189 | return -ENODEV; |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 1190 | |
Tony Lindgren | 8b2830ba | 2018-04-16 10:26:09 -0700 | [diff] [blame] | 1191 | l = clkdev_create(clk, name, dev_name(child)); |
| 1192 | if (!l) |
| 1193 | error = -ENOMEM; |
| 1194 | |
| 1195 | clk_put(clk); |
| 1196 | |
| 1197 | return error; |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 1198 | } |
| 1199 | |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 1200 | static int sysc_child_add_clocks(struct sysc *ddata, |
| 1201 | struct device *child) |
| 1202 | { |
| 1203 | int i, error; |
| 1204 | |
| 1205 | for (i = 0; i < ddata->nr_clocks; i++) { |
| 1206 | error = sysc_child_add_named_clock(ddata, |
| 1207 | child, |
| 1208 | ddata->clock_roles[i]); |
| 1209 | if (error && error != -EEXIST) { |
| 1210 | dev_err(ddata->dev, "could not add child clock %s: %i\n", |
| 1211 | ddata->clock_roles[i], error); |
| 1212 | |
| 1213 | return error; |
| 1214 | } |
| 1215 | } |
| 1216 | |
| 1217 | return 0; |
| 1218 | } |
| 1219 | |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 1220 | static struct device_type sysc_device_type = { |
| 1221 | }; |
| 1222 | |
| 1223 | static struct sysc *sysc_child_to_parent(struct device *dev) |
| 1224 | { |
| 1225 | struct device *parent = dev->parent; |
| 1226 | |
| 1227 | if (!parent || parent->type != &sysc_device_type) |
| 1228 | return NULL; |
| 1229 | |
| 1230 | return dev_get_drvdata(parent); |
| 1231 | } |
| 1232 | |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1233 | static int __maybe_unused sysc_child_runtime_suspend(struct device *dev) |
| 1234 | { |
| 1235 | struct sysc *ddata; |
| 1236 | int error; |
| 1237 | |
| 1238 | ddata = sysc_child_to_parent(dev); |
| 1239 | |
| 1240 | error = pm_generic_runtime_suspend(dev); |
| 1241 | if (error) |
| 1242 | return error; |
| 1243 | |
| 1244 | if (!ddata->enabled) |
| 1245 | return 0; |
| 1246 | |
| 1247 | return sysc_runtime_suspend(ddata->dev); |
| 1248 | } |
| 1249 | |
| 1250 | static int __maybe_unused sysc_child_runtime_resume(struct device *dev) |
| 1251 | { |
| 1252 | struct sysc *ddata; |
| 1253 | int error; |
| 1254 | |
| 1255 | ddata = sysc_child_to_parent(dev); |
| 1256 | |
| 1257 | if (!ddata->enabled) { |
| 1258 | error = sysc_runtime_resume(ddata->dev); |
| 1259 | if (error < 0) |
| 1260 | dev_err(ddata->dev, |
| 1261 | "%s error: %i\n", __func__, error); |
| 1262 | } |
| 1263 | |
| 1264 | return pm_generic_runtime_resume(dev); |
| 1265 | } |
| 1266 | |
| 1267 | #ifdef CONFIG_PM_SLEEP |
| 1268 | static int sysc_child_suspend_noirq(struct device *dev) |
| 1269 | { |
| 1270 | struct sysc *ddata; |
| 1271 | int error; |
| 1272 | |
| 1273 | ddata = sysc_child_to_parent(dev); |
| 1274 | |
Tony Lindgren | ef55f82 | 2018-04-16 10:27:15 -0700 | [diff] [blame] | 1275 | dev_dbg(ddata->dev, "%s %s\n", __func__, |
| 1276 | ddata->name ? ddata->name : ""); |
| 1277 | |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1278 | error = pm_generic_suspend_noirq(dev); |
Tony Lindgren | ef55f82 | 2018-04-16 10:27:15 -0700 | [diff] [blame] | 1279 | if (error) { |
| 1280 | dev_err(dev, "%s error at %i: %i\n", |
| 1281 | __func__, __LINE__, error); |
| 1282 | |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1283 | return error; |
Tony Lindgren | ef55f82 | 2018-04-16 10:27:15 -0700 | [diff] [blame] | 1284 | } |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1285 | |
| 1286 | if (!pm_runtime_status_suspended(dev)) { |
| 1287 | error = pm_generic_runtime_suspend(dev); |
Tony Lindgren | ef55f82 | 2018-04-16 10:27:15 -0700 | [diff] [blame] | 1288 | if (error) { |
Tony Lindgren | f949078 | 2018-09-28 15:21:50 -0700 | [diff] [blame] | 1289 | dev_dbg(dev, "%s busy at %i: %i\n", |
| 1290 | __func__, __LINE__, error); |
Tony Lindgren | ef55f82 | 2018-04-16 10:27:15 -0700 | [diff] [blame] | 1291 | |
Tony Lindgren | 4f3530f | 2018-08-08 01:07:06 -0700 | [diff] [blame] | 1292 | return 0; |
Tony Lindgren | ef55f82 | 2018-04-16 10:27:15 -0700 | [diff] [blame] | 1293 | } |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1294 | |
| 1295 | error = sysc_runtime_suspend(ddata->dev); |
Tony Lindgren | ef55f82 | 2018-04-16 10:27:15 -0700 | [diff] [blame] | 1296 | if (error) { |
| 1297 | dev_err(dev, "%s error at %i: %i\n", |
| 1298 | __func__, __LINE__, error); |
| 1299 | |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1300 | return error; |
Tony Lindgren | ef55f82 | 2018-04-16 10:27:15 -0700 | [diff] [blame] | 1301 | } |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1302 | |
| 1303 | ddata->child_needs_resume = true; |
| 1304 | } |
| 1305 | |
| 1306 | return 0; |
| 1307 | } |
| 1308 | |
| 1309 | static int sysc_child_resume_noirq(struct device *dev) |
| 1310 | { |
| 1311 | struct sysc *ddata; |
| 1312 | int error; |
| 1313 | |
| 1314 | ddata = sysc_child_to_parent(dev); |
| 1315 | |
Tony Lindgren | ef55f82 | 2018-04-16 10:27:15 -0700 | [diff] [blame] | 1316 | dev_dbg(ddata->dev, "%s %s\n", __func__, |
| 1317 | ddata->name ? ddata->name : ""); |
| 1318 | |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1319 | if (ddata->child_needs_resume) { |
| 1320 | ddata->child_needs_resume = false; |
| 1321 | |
| 1322 | error = sysc_runtime_resume(ddata->dev); |
| 1323 | if (error) |
| 1324 | dev_err(ddata->dev, |
| 1325 | "%s runtime resume error: %i\n", |
| 1326 | __func__, error); |
| 1327 | |
| 1328 | error = pm_generic_runtime_resume(dev); |
| 1329 | if (error) |
| 1330 | dev_err(ddata->dev, |
| 1331 | "%s generic runtime resume: %i\n", |
| 1332 | __func__, error); |
| 1333 | } |
| 1334 | |
| 1335 | return pm_generic_resume_noirq(dev); |
| 1336 | } |
| 1337 | #endif |
| 1338 | |
Tony Lindgren | b7182b4 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1339 | static struct dev_pm_domain sysc_child_pm_domain = { |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1340 | .ops = { |
| 1341 | SET_RUNTIME_PM_OPS(sysc_child_runtime_suspend, |
| 1342 | sysc_child_runtime_resume, |
| 1343 | NULL) |
| 1344 | USE_PLATFORM_PM_SLEEP_OPS |
| 1345 | SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(sysc_child_suspend_noirq, |
| 1346 | sysc_child_resume_noirq) |
| 1347 | } |
| 1348 | }; |
| 1349 | |
| 1350 | /** |
| 1351 | * sysc_legacy_idle_quirk - handle children in omap_device compatible way |
| 1352 | * @ddata: device driver data |
| 1353 | * @child: child device driver |
| 1354 | * |
| 1355 | * Allow idle for child devices as done with _od_runtime_suspend(). |
| 1356 | * Otherwise many child devices will not idle because of the permanent |
| 1357 | * parent usecount set in pm_runtime_irq_safe(). |
| 1358 | * |
| 1359 | * Note that the long term solution is to just modify the child device |
| 1360 | * drivers to not set pm_runtime_irq_safe() and then this can be just |
| 1361 | * dropped. |
| 1362 | */ |
| 1363 | static void sysc_legacy_idle_quirk(struct sysc *ddata, struct device *child) |
| 1364 | { |
| 1365 | if (!ddata->legacy_mode) |
| 1366 | return; |
| 1367 | |
| 1368 | if (ddata->cfg.quirks & SYSC_QUIRK_LEGACY_IDLE) |
| 1369 | dev_pm_domain_set(child, &sysc_child_pm_domain); |
| 1370 | } |
| 1371 | |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 1372 | static int sysc_notifier_call(struct notifier_block *nb, |
| 1373 | unsigned long event, void *device) |
| 1374 | { |
| 1375 | struct device *dev = device; |
| 1376 | struct sysc *ddata; |
| 1377 | int error; |
| 1378 | |
| 1379 | ddata = sysc_child_to_parent(dev); |
| 1380 | if (!ddata) |
| 1381 | return NOTIFY_DONE; |
| 1382 | |
| 1383 | switch (event) { |
| 1384 | case BUS_NOTIFY_ADD_DEVICE: |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 1385 | error = sysc_child_add_clocks(ddata, dev); |
| 1386 | if (error) |
| 1387 | return error; |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1388 | sysc_legacy_idle_quirk(ddata, dev); |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 1389 | break; |
| 1390 | default: |
| 1391 | break; |
| 1392 | } |
| 1393 | |
| 1394 | return NOTIFY_DONE; |
| 1395 | } |
| 1396 | |
| 1397 | static struct notifier_block sysc_nb = { |
| 1398 | .notifier_call = sysc_notifier_call, |
| 1399 | }; |
| 1400 | |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 1401 | /* Device tree configured quirks */ |
| 1402 | struct sysc_dts_quirk { |
| 1403 | const char *name; |
| 1404 | u32 mask; |
| 1405 | }; |
| 1406 | |
| 1407 | static const struct sysc_dts_quirk sysc_dts_quirks[] = { |
| 1408 | { .name = "ti,no-idle-on-init", |
| 1409 | .mask = SYSC_QUIRK_NO_IDLE_ON_INIT, }, |
| 1410 | { .name = "ti,no-reset-on-init", |
| 1411 | .mask = SYSC_QUIRK_NO_RESET_ON_INIT, }, |
Tony Lindgren | 386cb76 | 2019-03-22 07:49:30 -0700 | [diff] [blame] | 1412 | { .name = "ti,no-idle", |
| 1413 | .mask = SYSC_QUIRK_NO_IDLE, }, |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 1414 | }; |
| 1415 | |
Tony Lindgren | 4014c08 | 2018-12-10 14:11:26 -0800 | [diff] [blame] | 1416 | static void sysc_parse_dts_quirks(struct sysc *ddata, struct device_node *np, |
| 1417 | bool is_child) |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 1418 | { |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 1419 | const struct property *prop; |
Tony Lindgren | 4014c08 | 2018-12-10 14:11:26 -0800 | [diff] [blame] | 1420 | int i, len; |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 1421 | |
| 1422 | for (i = 0; i < ARRAY_SIZE(sysc_dts_quirks); i++) { |
Tony Lindgren | 4014c08 | 2018-12-10 14:11:26 -0800 | [diff] [blame] | 1423 | const char *name = sysc_dts_quirks[i].name; |
| 1424 | |
| 1425 | prop = of_get_property(np, name, &len); |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 1426 | if (!prop) |
Tony Lindgren | d39b6ea | 2018-02-15 09:18:55 -0800 | [diff] [blame] | 1427 | continue; |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 1428 | |
| 1429 | ddata->cfg.quirks |= sysc_dts_quirks[i].mask; |
Tony Lindgren | 4014c08 | 2018-12-10 14:11:26 -0800 | [diff] [blame] | 1430 | if (is_child) { |
| 1431 | dev_warn(ddata->dev, |
| 1432 | "dts flag should be at module level for %s\n", |
| 1433 | name); |
| 1434 | } |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 1435 | } |
Tony Lindgren | 4014c08 | 2018-12-10 14:11:26 -0800 | [diff] [blame] | 1436 | } |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 1437 | |
Tony Lindgren | 4014c08 | 2018-12-10 14:11:26 -0800 | [diff] [blame] | 1438 | static int sysc_init_dts_quirks(struct sysc *ddata) |
| 1439 | { |
| 1440 | struct device_node *np = ddata->dev->of_node; |
| 1441 | int error; |
| 1442 | u32 val; |
| 1443 | |
| 1444 | ddata->legacy_mode = of_get_property(np, "ti,hwmods", NULL); |
| 1445 | |
| 1446 | sysc_parse_dts_quirks(ddata, np, false); |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 1447 | error = of_property_read_u32(np, "ti,sysc-delay-us", &val); |
| 1448 | if (!error) { |
| 1449 | if (val > 255) { |
| 1450 | dev_warn(ddata->dev, "bad ti,sysc-delay-us: %i\n", |
| 1451 | val); |
| 1452 | } |
| 1453 | |
| 1454 | ddata->cfg.srst_udelay = (u8)val; |
| 1455 | } |
| 1456 | |
| 1457 | return 0; |
| 1458 | } |
| 1459 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 1460 | static void sysc_unprepare(struct sysc *ddata) |
| 1461 | { |
| 1462 | int i; |
| 1463 | |
Tony Lindgren | aaa29bb | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1464 | if (!ddata->clocks) |
| 1465 | return; |
| 1466 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 1467 | for (i = 0; i < SYSC_MAX_CLOCKS; i++) { |
| 1468 | if (!IS_ERR_OR_NULL(ddata->clocks[i])) |
| 1469 | clk_unprepare(ddata->clocks[i]); |
| 1470 | } |
| 1471 | } |
| 1472 | |
Tony Lindgren | 70a6524 | 2017-12-15 09:41:09 -0800 | [diff] [blame] | 1473 | /* |
| 1474 | * Common sysc register bits found on omap2, also known as type1 |
| 1475 | */ |
| 1476 | static const struct sysc_regbits sysc_regbits_omap2 = { |
| 1477 | .dmadisable_shift = -ENODEV, |
| 1478 | .midle_shift = 12, |
| 1479 | .sidle_shift = 3, |
| 1480 | .clkact_shift = 8, |
| 1481 | .emufree_shift = 5, |
| 1482 | .enwkup_shift = 2, |
| 1483 | .srst_shift = 1, |
| 1484 | .autoidle_shift = 0, |
| 1485 | }; |
| 1486 | |
| 1487 | static const struct sysc_capabilities sysc_omap2 = { |
| 1488 | .type = TI_SYSC_OMAP2, |
| 1489 | .sysc_mask = SYSC_OMAP2_CLOCKACTIVITY | SYSC_OMAP2_EMUFREE | |
| 1490 | SYSC_OMAP2_ENAWAKEUP | SYSC_OMAP2_SOFTRESET | |
| 1491 | SYSC_OMAP2_AUTOIDLE, |
| 1492 | .regbits = &sysc_regbits_omap2, |
| 1493 | }; |
| 1494 | |
| 1495 | /* All omap2 and 3 timers, and timers 1, 2 & 10 on omap 4 and 5 */ |
| 1496 | static const struct sysc_capabilities sysc_omap2_timer = { |
| 1497 | .type = TI_SYSC_OMAP2_TIMER, |
| 1498 | .sysc_mask = SYSC_OMAP2_CLOCKACTIVITY | SYSC_OMAP2_EMUFREE | |
| 1499 | SYSC_OMAP2_ENAWAKEUP | SYSC_OMAP2_SOFTRESET | |
| 1500 | SYSC_OMAP2_AUTOIDLE, |
| 1501 | .regbits = &sysc_regbits_omap2, |
| 1502 | .mod_quirks = SYSC_QUIRK_USE_CLOCKACT, |
| 1503 | }; |
| 1504 | |
| 1505 | /* |
| 1506 | * SHAM2 (SHA1/MD5) sysc found on omap3, a variant of sysc_regbits_omap2 |
| 1507 | * with different sidle position |
| 1508 | */ |
| 1509 | static const struct sysc_regbits sysc_regbits_omap3_sham = { |
| 1510 | .dmadisable_shift = -ENODEV, |
| 1511 | .midle_shift = -ENODEV, |
| 1512 | .sidle_shift = 4, |
| 1513 | .clkact_shift = -ENODEV, |
| 1514 | .enwkup_shift = -ENODEV, |
| 1515 | .srst_shift = 1, |
| 1516 | .autoidle_shift = 0, |
| 1517 | .emufree_shift = -ENODEV, |
| 1518 | }; |
| 1519 | |
| 1520 | static const struct sysc_capabilities sysc_omap3_sham = { |
| 1521 | .type = TI_SYSC_OMAP3_SHAM, |
| 1522 | .sysc_mask = SYSC_OMAP2_SOFTRESET | SYSC_OMAP2_AUTOIDLE, |
| 1523 | .regbits = &sysc_regbits_omap3_sham, |
| 1524 | }; |
| 1525 | |
| 1526 | /* |
| 1527 | * AES register bits found on omap3 and later, a variant of |
| 1528 | * sysc_regbits_omap2 with different sidle position |
| 1529 | */ |
| 1530 | static const struct sysc_regbits sysc_regbits_omap3_aes = { |
| 1531 | .dmadisable_shift = -ENODEV, |
| 1532 | .midle_shift = -ENODEV, |
| 1533 | .sidle_shift = 6, |
| 1534 | .clkact_shift = -ENODEV, |
| 1535 | .enwkup_shift = -ENODEV, |
| 1536 | .srst_shift = 1, |
| 1537 | .autoidle_shift = 0, |
| 1538 | .emufree_shift = -ENODEV, |
| 1539 | }; |
| 1540 | |
| 1541 | static const struct sysc_capabilities sysc_omap3_aes = { |
| 1542 | .type = TI_SYSC_OMAP3_AES, |
| 1543 | .sysc_mask = SYSC_OMAP2_SOFTRESET | SYSC_OMAP2_AUTOIDLE, |
| 1544 | .regbits = &sysc_regbits_omap3_aes, |
| 1545 | }; |
| 1546 | |
| 1547 | /* |
| 1548 | * Common sysc register bits found on omap4, also known as type2 |
| 1549 | */ |
| 1550 | static const struct sysc_regbits sysc_regbits_omap4 = { |
| 1551 | .dmadisable_shift = 16, |
| 1552 | .midle_shift = 4, |
| 1553 | .sidle_shift = 2, |
| 1554 | .clkact_shift = -ENODEV, |
| 1555 | .enwkup_shift = -ENODEV, |
| 1556 | .emufree_shift = 1, |
| 1557 | .srst_shift = 0, |
| 1558 | .autoidle_shift = -ENODEV, |
| 1559 | }; |
| 1560 | |
| 1561 | static const struct sysc_capabilities sysc_omap4 = { |
| 1562 | .type = TI_SYSC_OMAP4, |
| 1563 | .sysc_mask = SYSC_OMAP4_DMADISABLE | SYSC_OMAP4_FREEEMU | |
| 1564 | SYSC_OMAP4_SOFTRESET, |
| 1565 | .regbits = &sysc_regbits_omap4, |
| 1566 | }; |
| 1567 | |
| 1568 | static const struct sysc_capabilities sysc_omap4_timer = { |
| 1569 | .type = TI_SYSC_OMAP4_TIMER, |
| 1570 | .sysc_mask = SYSC_OMAP4_DMADISABLE | SYSC_OMAP4_FREEEMU | |
| 1571 | SYSC_OMAP4_SOFTRESET, |
| 1572 | .regbits = &sysc_regbits_omap4, |
| 1573 | }; |
| 1574 | |
| 1575 | /* |
| 1576 | * Common sysc register bits found on omap4, also known as type3 |
| 1577 | */ |
| 1578 | static const struct sysc_regbits sysc_regbits_omap4_simple = { |
| 1579 | .dmadisable_shift = -ENODEV, |
| 1580 | .midle_shift = 2, |
| 1581 | .sidle_shift = 0, |
| 1582 | .clkact_shift = -ENODEV, |
| 1583 | .enwkup_shift = -ENODEV, |
| 1584 | .srst_shift = -ENODEV, |
| 1585 | .emufree_shift = -ENODEV, |
| 1586 | .autoidle_shift = -ENODEV, |
| 1587 | }; |
| 1588 | |
| 1589 | static const struct sysc_capabilities sysc_omap4_simple = { |
| 1590 | .type = TI_SYSC_OMAP4_SIMPLE, |
| 1591 | .regbits = &sysc_regbits_omap4_simple, |
| 1592 | }; |
| 1593 | |
| 1594 | /* |
| 1595 | * SmartReflex sysc found on omap34xx |
| 1596 | */ |
| 1597 | static const struct sysc_regbits sysc_regbits_omap34xx_sr = { |
| 1598 | .dmadisable_shift = -ENODEV, |
| 1599 | .midle_shift = -ENODEV, |
| 1600 | .sidle_shift = -ENODEV, |
| 1601 | .clkact_shift = 20, |
| 1602 | .enwkup_shift = -ENODEV, |
| 1603 | .srst_shift = -ENODEV, |
| 1604 | .emufree_shift = -ENODEV, |
| 1605 | .autoidle_shift = -ENODEV, |
| 1606 | }; |
| 1607 | |
| 1608 | static const struct sysc_capabilities sysc_34xx_sr = { |
| 1609 | .type = TI_SYSC_OMAP34XX_SR, |
| 1610 | .sysc_mask = SYSC_OMAP2_CLOCKACTIVITY, |
| 1611 | .regbits = &sysc_regbits_omap34xx_sr, |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1612 | .mod_quirks = SYSC_QUIRK_USE_CLOCKACT | SYSC_QUIRK_UNCACHED | |
| 1613 | SYSC_QUIRK_LEGACY_IDLE, |
Tony Lindgren | 70a6524 | 2017-12-15 09:41:09 -0800 | [diff] [blame] | 1614 | }; |
| 1615 | |
| 1616 | /* |
| 1617 | * SmartReflex sysc found on omap36xx and later |
| 1618 | */ |
| 1619 | static const struct sysc_regbits sysc_regbits_omap36xx_sr = { |
| 1620 | .dmadisable_shift = -ENODEV, |
| 1621 | .midle_shift = -ENODEV, |
| 1622 | .sidle_shift = 24, |
| 1623 | .clkact_shift = -ENODEV, |
| 1624 | .enwkup_shift = 26, |
| 1625 | .srst_shift = -ENODEV, |
| 1626 | .emufree_shift = -ENODEV, |
| 1627 | .autoidle_shift = -ENODEV, |
| 1628 | }; |
| 1629 | |
| 1630 | static const struct sysc_capabilities sysc_36xx_sr = { |
| 1631 | .type = TI_SYSC_OMAP36XX_SR, |
Tony Lindgren | 3267c08 | 2018-01-22 09:32:53 -0800 | [diff] [blame] | 1632 | .sysc_mask = SYSC_OMAP3_SR_ENAWAKEUP, |
Tony Lindgren | 70a6524 | 2017-12-15 09:41:09 -0800 | [diff] [blame] | 1633 | .regbits = &sysc_regbits_omap36xx_sr, |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1634 | .mod_quirks = SYSC_QUIRK_UNCACHED | SYSC_QUIRK_LEGACY_IDLE, |
Tony Lindgren | 70a6524 | 2017-12-15 09:41:09 -0800 | [diff] [blame] | 1635 | }; |
| 1636 | |
| 1637 | static const struct sysc_capabilities sysc_omap4_sr = { |
| 1638 | .type = TI_SYSC_OMAP4_SR, |
| 1639 | .regbits = &sysc_regbits_omap36xx_sr, |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1640 | .mod_quirks = SYSC_QUIRK_LEGACY_IDLE, |
Tony Lindgren | 70a6524 | 2017-12-15 09:41:09 -0800 | [diff] [blame] | 1641 | }; |
| 1642 | |
| 1643 | /* |
| 1644 | * McASP register bits found on omap4 and later |
| 1645 | */ |
| 1646 | static const struct sysc_regbits sysc_regbits_omap4_mcasp = { |
| 1647 | .dmadisable_shift = -ENODEV, |
| 1648 | .midle_shift = -ENODEV, |
| 1649 | .sidle_shift = 0, |
| 1650 | .clkact_shift = -ENODEV, |
| 1651 | .enwkup_shift = -ENODEV, |
| 1652 | .srst_shift = -ENODEV, |
| 1653 | .emufree_shift = -ENODEV, |
| 1654 | .autoidle_shift = -ENODEV, |
| 1655 | }; |
| 1656 | |
| 1657 | static const struct sysc_capabilities sysc_omap4_mcasp = { |
| 1658 | .type = TI_SYSC_OMAP4_MCASP, |
| 1659 | .regbits = &sysc_regbits_omap4_mcasp, |
Tony Lindgren | 2c63a83 | 2018-11-15 14:46:53 -0800 | [diff] [blame] | 1660 | .mod_quirks = SYSC_QUIRK_OPT_CLKS_NEEDED, |
| 1661 | }; |
| 1662 | |
| 1663 | /* |
| 1664 | * McASP found on dra7 and later |
| 1665 | */ |
| 1666 | static const struct sysc_capabilities sysc_dra7_mcasp = { |
| 1667 | .type = TI_SYSC_OMAP4_SIMPLE, |
| 1668 | .regbits = &sysc_regbits_omap4_simple, |
| 1669 | .mod_quirks = SYSC_QUIRK_OPT_CLKS_NEEDED, |
Tony Lindgren | 70a6524 | 2017-12-15 09:41:09 -0800 | [diff] [blame] | 1670 | }; |
| 1671 | |
| 1672 | /* |
| 1673 | * FS USB host found on omap4 and later |
| 1674 | */ |
| 1675 | static const struct sysc_regbits sysc_regbits_omap4_usb_host_fs = { |
| 1676 | .dmadisable_shift = -ENODEV, |
| 1677 | .midle_shift = -ENODEV, |
| 1678 | .sidle_shift = 24, |
| 1679 | .clkact_shift = -ENODEV, |
| 1680 | .enwkup_shift = 26, |
| 1681 | .srst_shift = -ENODEV, |
| 1682 | .emufree_shift = -ENODEV, |
| 1683 | .autoidle_shift = -ENODEV, |
| 1684 | }; |
| 1685 | |
| 1686 | static const struct sysc_capabilities sysc_omap4_usb_host_fs = { |
| 1687 | .type = TI_SYSC_OMAP4_USB_HOST_FS, |
| 1688 | .sysc_mask = SYSC_OMAP2_ENAWAKEUP, |
| 1689 | .regbits = &sysc_regbits_omap4_usb_host_fs, |
| 1690 | }; |
| 1691 | |
Faiz Abbas | 7f35e63 | 2018-07-09 22:18:38 +0530 | [diff] [blame] | 1692 | static const struct sysc_regbits sysc_regbits_dra7_mcan = { |
| 1693 | .dmadisable_shift = -ENODEV, |
| 1694 | .midle_shift = -ENODEV, |
| 1695 | .sidle_shift = -ENODEV, |
| 1696 | .clkact_shift = -ENODEV, |
| 1697 | .enwkup_shift = 4, |
| 1698 | .srst_shift = 0, |
| 1699 | .emufree_shift = -ENODEV, |
| 1700 | .autoidle_shift = -ENODEV, |
| 1701 | }; |
| 1702 | |
| 1703 | static const struct sysc_capabilities sysc_dra7_mcan = { |
| 1704 | .type = TI_SYSC_DRA7_MCAN, |
| 1705 | .sysc_mask = SYSC_DRA7_MCAN_ENAWAKEUP | SYSC_OMAP4_SOFTRESET, |
| 1706 | .regbits = &sysc_regbits_dra7_mcan, |
| 1707 | }; |
| 1708 | |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 1709 | static int sysc_init_pdata(struct sysc *ddata) |
| 1710 | { |
| 1711 | struct ti_sysc_platform_data *pdata = dev_get_platdata(ddata->dev); |
| 1712 | struct ti_sysc_module_data mdata; |
| 1713 | int error = 0; |
| 1714 | |
| 1715 | if (!pdata || !ddata->legacy_mode) |
| 1716 | return 0; |
| 1717 | |
| 1718 | mdata.name = ddata->legacy_mode; |
| 1719 | mdata.module_pa = ddata->module_pa; |
| 1720 | mdata.module_size = ddata->module_size; |
| 1721 | mdata.offsets = ddata->offsets; |
| 1722 | mdata.nr_offsets = SYSC_MAX_REGS; |
| 1723 | mdata.cap = ddata->cap; |
| 1724 | mdata.cfg = &ddata->cfg; |
| 1725 | |
| 1726 | if (!pdata->init_module) |
| 1727 | return -ENODEV; |
| 1728 | |
| 1729 | error = pdata->init_module(ddata->dev, &mdata, &ddata->cookie); |
| 1730 | if (error == -EEXIST) |
| 1731 | error = 0; |
| 1732 | |
| 1733 | return error; |
| 1734 | } |
| 1735 | |
Tony Lindgren | 70a6524 | 2017-12-15 09:41:09 -0800 | [diff] [blame] | 1736 | static int sysc_init_match(struct sysc *ddata) |
| 1737 | { |
| 1738 | const struct sysc_capabilities *cap; |
| 1739 | |
| 1740 | cap = of_device_get_match_data(ddata->dev); |
| 1741 | if (!cap) |
| 1742 | return -EINVAL; |
| 1743 | |
| 1744 | ddata->cap = cap; |
| 1745 | if (ddata->cap) |
| 1746 | ddata->cfg.quirks |= ddata->cap->mod_quirks; |
| 1747 | |
| 1748 | return 0; |
| 1749 | } |
| 1750 | |
Tony Lindgren | 76f0f77 | 2018-02-23 08:28:45 -0800 | [diff] [blame] | 1751 | static void ti_sysc_idle(struct work_struct *work) |
| 1752 | { |
| 1753 | struct sysc *ddata; |
| 1754 | |
| 1755 | ddata = container_of(work, struct sysc, idle_work.work); |
| 1756 | |
| 1757 | if (pm_runtime_active(ddata->dev)) |
| 1758 | pm_runtime_put_sync(ddata->dev); |
| 1759 | } |
| 1760 | |
Tony Lindgren | c4bebea | 2018-04-16 10:24:54 -0700 | [diff] [blame] | 1761 | static const struct of_device_id sysc_match_table[] = { |
| 1762 | { .compatible = "simple-bus", }, |
| 1763 | { /* sentinel */ }, |
| 1764 | }; |
| 1765 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 1766 | static int sysc_probe(struct platform_device *pdev) |
| 1767 | { |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 1768 | struct ti_sysc_platform_data *pdata = dev_get_platdata(&pdev->dev); |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 1769 | struct sysc *ddata; |
| 1770 | int error; |
| 1771 | |
| 1772 | ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL); |
| 1773 | if (!ddata) |
| 1774 | return -ENOMEM; |
| 1775 | |
| 1776 | ddata->dev = &pdev->dev; |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 1777 | platform_set_drvdata(pdev, ddata); |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 1778 | |
Tony Lindgren | 70a6524 | 2017-12-15 09:41:09 -0800 | [diff] [blame] | 1779 | error = sysc_init_match(ddata); |
| 1780 | if (error) |
| 1781 | return error; |
| 1782 | |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 1783 | error = sysc_init_dts_quirks(ddata); |
| 1784 | if (error) |
| 1785 | goto unprepare; |
| 1786 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 1787 | error = sysc_get_clocks(ddata); |
| 1788 | if (error) |
| 1789 | return error; |
| 1790 | |
| 1791 | error = sysc_map_and_check_registers(ddata); |
| 1792 | if (error) |
| 1793 | goto unprepare; |
| 1794 | |
Tony Lindgren | c5a2de9 | 2017-12-15 09:41:23 -0800 | [diff] [blame] | 1795 | error = sysc_init_sysc_mask(ddata); |
| 1796 | if (error) |
| 1797 | goto unprepare; |
| 1798 | |
| 1799 | error = sysc_init_idlemodes(ddata); |
| 1800 | if (error) |
| 1801 | goto unprepare; |
| 1802 | |
| 1803 | error = sysc_init_syss_mask(ddata); |
| 1804 | if (error) |
| 1805 | goto unprepare; |
| 1806 | |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 1807 | error = sysc_init_pdata(ddata); |
| 1808 | if (error) |
| 1809 | goto unprepare; |
| 1810 | |
Tony Lindgren | 5062236 | 2018-04-16 10:20:27 -0700 | [diff] [blame] | 1811 | error = sysc_init_resets(ddata); |
| 1812 | if (error) |
| 1813 | return error; |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 1814 | |
Tony Lindgren | 5062236 | 2018-04-16 10:20:27 -0700 | [diff] [blame] | 1815 | pm_runtime_enable(ddata->dev); |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 1816 | error = sysc_init_module(ddata); |
| 1817 | if (error) |
| 1818 | goto unprepare; |
| 1819 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 1820 | error = pm_runtime_get_sync(ddata->dev); |
| 1821 | if (error < 0) { |
| 1822 | pm_runtime_put_noidle(ddata->dev); |
| 1823 | pm_runtime_disable(ddata->dev); |
| 1824 | goto unprepare; |
| 1825 | } |
| 1826 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 1827 | sysc_show_registers(ddata); |
| 1828 | |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 1829 | ddata->dev->type = &sysc_device_type; |
Tony Lindgren | c4bebea | 2018-04-16 10:24:54 -0700 | [diff] [blame] | 1830 | error = of_platform_populate(ddata->dev->of_node, sysc_match_table, |
| 1831 | pdata ? pdata->auxdata : NULL, |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 1832 | ddata->dev); |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 1833 | if (error) |
| 1834 | goto err; |
| 1835 | |
Tony Lindgren | 76f0f77 | 2018-02-23 08:28:45 -0800 | [diff] [blame] | 1836 | INIT_DELAYED_WORK(&ddata->idle_work, ti_sysc_idle); |
| 1837 | |
| 1838 | /* At least earlycon won't survive without deferred idle */ |
| 1839 | if (ddata->cfg.quirks & (SYSC_QUIRK_NO_IDLE_ON_INIT | |
| 1840 | SYSC_QUIRK_NO_RESET_ON_INIT)) { |
| 1841 | schedule_delayed_work(&ddata->idle_work, 3000); |
| 1842 | } else { |
| 1843 | pm_runtime_put(&pdev->dev); |
| 1844 | } |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 1845 | |
Tony Lindgren | 5062236 | 2018-04-16 10:20:27 -0700 | [diff] [blame] | 1846 | if (!of_get_available_child_count(ddata->dev->of_node)) |
| 1847 | reset_control_assert(ddata->rsts); |
| 1848 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 1849 | return 0; |
| 1850 | |
| 1851 | err: |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 1852 | pm_runtime_put_sync(&pdev->dev); |
| 1853 | pm_runtime_disable(&pdev->dev); |
| 1854 | unprepare: |
| 1855 | sysc_unprepare(ddata); |
| 1856 | |
| 1857 | return error; |
| 1858 | } |
| 1859 | |
Tony Lindgren | 684be5a | 2017-10-13 10:48:40 -0700 | [diff] [blame] | 1860 | static int sysc_remove(struct platform_device *pdev) |
| 1861 | { |
| 1862 | struct sysc *ddata = platform_get_drvdata(pdev); |
| 1863 | int error; |
| 1864 | |
Tony Lindgren | 76f0f77 | 2018-02-23 08:28:45 -0800 | [diff] [blame] | 1865 | cancel_delayed_work_sync(&ddata->idle_work); |
| 1866 | |
Tony Lindgren | 684be5a | 2017-10-13 10:48:40 -0700 | [diff] [blame] | 1867 | error = pm_runtime_get_sync(ddata->dev); |
| 1868 | if (error < 0) { |
| 1869 | pm_runtime_put_noidle(ddata->dev); |
| 1870 | pm_runtime_disable(ddata->dev); |
| 1871 | goto unprepare; |
| 1872 | } |
| 1873 | |
| 1874 | of_platform_depopulate(&pdev->dev); |
| 1875 | |
Tony Lindgren | 684be5a | 2017-10-13 10:48:40 -0700 | [diff] [blame] | 1876 | pm_runtime_put_sync(&pdev->dev); |
| 1877 | pm_runtime_disable(&pdev->dev); |
Tony Lindgren | 5062236 | 2018-04-16 10:20:27 -0700 | [diff] [blame] | 1878 | reset_control_assert(ddata->rsts); |
Tony Lindgren | 684be5a | 2017-10-13 10:48:40 -0700 | [diff] [blame] | 1879 | |
| 1880 | unprepare: |
| 1881 | sysc_unprepare(ddata); |
| 1882 | |
| 1883 | return 0; |
| 1884 | } |
| 1885 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 1886 | static const struct of_device_id sysc_match[] = { |
Tony Lindgren | 70a6524 | 2017-12-15 09:41:09 -0800 | [diff] [blame] | 1887 | { .compatible = "ti,sysc-omap2", .data = &sysc_omap2, }, |
| 1888 | { .compatible = "ti,sysc-omap2-timer", .data = &sysc_omap2_timer, }, |
| 1889 | { .compatible = "ti,sysc-omap4", .data = &sysc_omap4, }, |
| 1890 | { .compatible = "ti,sysc-omap4-timer", .data = &sysc_omap4_timer, }, |
| 1891 | { .compatible = "ti,sysc-omap4-simple", .data = &sysc_omap4_simple, }, |
| 1892 | { .compatible = "ti,sysc-omap3430-sr", .data = &sysc_34xx_sr, }, |
| 1893 | { .compatible = "ti,sysc-omap3630-sr", .data = &sysc_36xx_sr, }, |
| 1894 | { .compatible = "ti,sysc-omap4-sr", .data = &sysc_omap4_sr, }, |
| 1895 | { .compatible = "ti,sysc-omap3-sham", .data = &sysc_omap3_sham, }, |
| 1896 | { .compatible = "ti,sysc-omap-aes", .data = &sysc_omap3_aes, }, |
| 1897 | { .compatible = "ti,sysc-mcasp", .data = &sysc_omap4_mcasp, }, |
Tony Lindgren | 2c63a83 | 2018-11-15 14:46:53 -0800 | [diff] [blame] | 1898 | { .compatible = "ti,sysc-dra7-mcasp", .data = &sysc_dra7_mcasp, }, |
Tony Lindgren | 70a6524 | 2017-12-15 09:41:09 -0800 | [diff] [blame] | 1899 | { .compatible = "ti,sysc-usb-host-fs", |
| 1900 | .data = &sysc_omap4_usb_host_fs, }, |
Faiz Abbas | 7f35e63 | 2018-07-09 22:18:38 +0530 | [diff] [blame] | 1901 | { .compatible = "ti,sysc-dra7-mcan", .data = &sysc_dra7_mcan, }, |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 1902 | { }, |
| 1903 | }; |
| 1904 | MODULE_DEVICE_TABLE(of, sysc_match); |
| 1905 | |
| 1906 | static struct platform_driver sysc_driver = { |
| 1907 | .probe = sysc_probe, |
Tony Lindgren | 684be5a | 2017-10-13 10:48:40 -0700 | [diff] [blame] | 1908 | .remove = sysc_remove, |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 1909 | .driver = { |
| 1910 | .name = "ti-sysc", |
| 1911 | .of_match_table = sysc_match, |
| 1912 | .pm = &sysc_pm_ops, |
| 1913 | }, |
| 1914 | }; |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 1915 | |
| 1916 | static int __init sysc_init(void) |
| 1917 | { |
| 1918 | bus_register_notifier(&platform_bus_type, &sysc_nb); |
| 1919 | |
| 1920 | return platform_driver_register(&sysc_driver); |
| 1921 | } |
| 1922 | module_init(sysc_init); |
| 1923 | |
| 1924 | static void __exit sysc_exit(void) |
| 1925 | { |
| 1926 | bus_unregister_notifier(&platform_bus_type, &sysc_nb); |
| 1927 | platform_driver_unregister(&sysc_driver); |
| 1928 | } |
| 1929 | module_exit(sysc_exit); |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 1930 | |
| 1931 | MODULE_DESCRIPTION("TI sysc interconnect target driver"); |
| 1932 | MODULE_LICENSE("GPL v2"); |