Suman Anna | 54d6622 | 2019-08-13 04:13:32 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 2 | /* |
| 3 | * ti-sysc.c - Texas Instruments sysc interconnect target driver |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <linux/io.h> |
| 7 | #include <linux/clk.h> |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 8 | #include <linux/clkdev.h> |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 9 | #include <linux/delay.h> |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 10 | #include <linux/module.h> |
| 11 | #include <linux/platform_device.h> |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 12 | #include <linux/pm_domain.h> |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 13 | #include <linux/pm_runtime.h> |
Tony Lindgren | 5062236 | 2018-04-16 10:20:27 -0700 | [diff] [blame] | 14 | #include <linux/reset.h> |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 15 | #include <linux/of_address.h> |
| 16 | #include <linux/of_platform.h> |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 17 | #include <linux/slab.h> |
Faiz Abbas | 596e795 | 2018-07-09 22:18:39 +0530 | [diff] [blame] | 18 | #include <linux/iopoll.h> |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 19 | |
Tony Lindgren | 70a6524 | 2017-12-15 09:41:09 -0800 | [diff] [blame] | 20 | #include <linux/platform_data/ti-sysc.h> |
| 21 | |
| 22 | #include <dt-bindings/bus/ti-sysc.h> |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 23 | |
Faiz Abbas | 596e795 | 2018-07-09 22:18:39 +0530 | [diff] [blame] | 24 | #define MAX_MODULE_SOFTRESET_WAIT 10000 |
| 25 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 26 | static const char * const reg_names[] = { "rev", "sysc", "syss", }; |
| 27 | |
| 28 | enum sysc_clocks { |
| 29 | SYSC_FCK, |
| 30 | SYSC_ICK, |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 31 | SYSC_OPTFCK0, |
| 32 | SYSC_OPTFCK1, |
| 33 | SYSC_OPTFCK2, |
| 34 | SYSC_OPTFCK3, |
| 35 | SYSC_OPTFCK4, |
| 36 | SYSC_OPTFCK5, |
| 37 | SYSC_OPTFCK6, |
| 38 | SYSC_OPTFCK7, |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 39 | SYSC_MAX_CLOCKS, |
| 40 | }; |
| 41 | |
Tony Lindgren | a54275f | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 42 | static const char * const clock_names[SYSC_MAX_CLOCKS] = { |
| 43 | "fck", "ick", "opt0", "opt1", "opt2", "opt3", "opt4", |
| 44 | "opt5", "opt6", "opt7", |
| 45 | }; |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 46 | |
Tony Lindgren | c5a2de9 | 2017-12-15 09:41:23 -0800 | [diff] [blame] | 47 | #define SYSC_IDLEMODE_MASK 3 |
| 48 | #define SYSC_CLOCKACTIVITY_MASK 3 |
| 49 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 50 | /** |
| 51 | * struct sysc - TI sysc interconnect target module registers and capabilities |
| 52 | * @dev: struct device pointer |
| 53 | * @module_pa: physical address of the interconnect target module |
| 54 | * @module_size: size of the interconnect target module |
| 55 | * @module_va: virtual address of the interconnect target module |
| 56 | * @offsets: register offsets from module base |
Suman Anna | b58056d | 2019-08-13 04:13:32 -0700 | [diff] [blame^] | 57 | * @mdata: ti-sysc to hwmod translation data for a module |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 58 | * @clocks: clocks used by the interconnect target module |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 59 | * @clock_roles: clock role names for the found clocks |
| 60 | * @nr_clocks: number of clocks used by the interconnect target module |
Suman Anna | b58056d | 2019-08-13 04:13:32 -0700 | [diff] [blame^] | 61 | * @rsts: resets used by the interconnect target module |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 62 | * @legacy_mode: configured for legacy mode if set |
Tony Lindgren | 70a6524 | 2017-12-15 09:41:09 -0800 | [diff] [blame] | 63 | * @cap: interconnect target module capabilities |
| 64 | * @cfg: interconnect target module configuration |
Suman Anna | b58056d | 2019-08-13 04:13:32 -0700 | [diff] [blame^] | 65 | * @cookie: data used by legacy platform callbacks |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 66 | * @name: name if available |
| 67 | * @revision: interconnect target module revision |
Suman Anna | b58056d | 2019-08-13 04:13:32 -0700 | [diff] [blame^] | 68 | * @enabled: sysc runtime enabled status |
Tony Lindgren | 62020f2 | 2018-02-22 13:59:44 -0800 | [diff] [blame] | 69 | * @needs_resume: runtime resume needed on resume from suspend |
Suman Anna | b58056d | 2019-08-13 04:13:32 -0700 | [diff] [blame^] | 70 | * @child_needs_resume: runtime resume needed for child on resume from suspend |
| 71 | * @disable_on_idle: status flag used for disabling modules with resets |
| 72 | * @idle_work: work structure used to perform delayed idle on a module |
Tony Lindgren | 4e23be4 | 2019-06-10 04:48:05 -0700 | [diff] [blame] | 73 | * @clk_enable_quirk: module specific clock enable quirk |
| 74 | * @clk_disable_quirk: module specific clock disable quirk |
| 75 | * @reset_done_quirk: module specific reset done quirk |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 76 | */ |
| 77 | struct sysc { |
| 78 | struct device *dev; |
| 79 | u64 module_pa; |
| 80 | u32 module_size; |
| 81 | void __iomem *module_va; |
| 82 | int offsets[SYSC_MAX_REGS]; |
Tony Lindgren | a3e92e7 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 83 | struct ti_sysc_module_data *mdata; |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 84 | struct clk **clocks; |
| 85 | const char **clock_roles; |
| 86 | int nr_clocks; |
Tony Lindgren | 5062236 | 2018-04-16 10:20:27 -0700 | [diff] [blame] | 87 | struct reset_control *rsts; |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 88 | const char *legacy_mode; |
Tony Lindgren | 70a6524 | 2017-12-15 09:41:09 -0800 | [diff] [blame] | 89 | const struct sysc_capabilities *cap; |
| 90 | struct sysc_config cfg; |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 91 | struct ti_sysc_cookie cookie; |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 92 | const char *name; |
| 93 | u32 revision; |
Tony Lindgren | 8383e25 | 2019-05-27 04:51:56 -0700 | [diff] [blame] | 94 | unsigned int enabled:1; |
| 95 | unsigned int needs_resume:1; |
| 96 | unsigned int child_needs_resume:1; |
| 97 | unsigned int disable_on_idle:1; |
Tony Lindgren | 76f0f77 | 2018-02-23 08:28:45 -0800 | [diff] [blame] | 98 | struct delayed_work idle_work; |
Tony Lindgren | 4e23be4 | 2019-06-10 04:48:05 -0700 | [diff] [blame] | 99 | void (*clk_enable_quirk)(struct sysc *sysc); |
| 100 | void (*clk_disable_quirk)(struct sysc *sysc); |
| 101 | void (*reset_done_quirk)(struct sysc *sysc); |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 102 | }; |
| 103 | |
Tony Lindgren | 4014c08 | 2018-12-10 14:11:26 -0800 | [diff] [blame] | 104 | static void sysc_parse_dts_quirks(struct sysc *ddata, struct device_node *np, |
| 105 | bool is_child); |
| 106 | |
Tony Lindgren | b7182b4 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 107 | static void sysc_write(struct sysc *ddata, int offset, u32 value) |
Faiz Abbas | 596e795 | 2018-07-09 22:18:39 +0530 | [diff] [blame] | 108 | { |
Tony Lindgren | 5aa9129 | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 109 | if (ddata->cfg.quirks & SYSC_QUIRK_16BIT) { |
| 110 | writew_relaxed(value & 0xffff, ddata->module_va + offset); |
| 111 | |
| 112 | /* Only i2c revision has LO and HI register with stride of 4 */ |
| 113 | if (ddata->offsets[SYSC_REVISION] >= 0 && |
| 114 | offset == ddata->offsets[SYSC_REVISION]) { |
| 115 | u16 hi = value >> 16; |
| 116 | |
| 117 | writew_relaxed(hi, ddata->module_va + offset + 4); |
| 118 | } |
| 119 | |
| 120 | return; |
| 121 | } |
| 122 | |
Faiz Abbas | 596e795 | 2018-07-09 22:18:39 +0530 | [diff] [blame] | 123 | writel_relaxed(value, ddata->module_va + offset); |
| 124 | } |
| 125 | |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 126 | static u32 sysc_read(struct sysc *ddata, int offset) |
| 127 | { |
| 128 | if (ddata->cfg.quirks & SYSC_QUIRK_16BIT) { |
| 129 | u32 val; |
| 130 | |
| 131 | val = readw_relaxed(ddata->module_va + offset); |
Tony Lindgren | 5aa9129 | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 132 | |
| 133 | /* Only i2c revision has LO and HI register with stride of 4 */ |
| 134 | if (ddata->offsets[SYSC_REVISION] >= 0 && |
| 135 | offset == ddata->offsets[SYSC_REVISION]) { |
| 136 | u16 tmp = readw_relaxed(ddata->module_va + offset + 4); |
| 137 | |
| 138 | val |= tmp << 16; |
| 139 | } |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 140 | |
| 141 | return val; |
| 142 | } |
| 143 | |
| 144 | return readl_relaxed(ddata->module_va + offset); |
| 145 | } |
| 146 | |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 147 | static bool sysc_opt_clks_needed(struct sysc *ddata) |
| 148 | { |
| 149 | return !!(ddata->cfg.quirks & SYSC_QUIRK_OPT_CLKS_NEEDED); |
| 150 | } |
| 151 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 152 | static u32 sysc_read_revision(struct sysc *ddata) |
| 153 | { |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 154 | int offset = ddata->offsets[SYSC_REVISION]; |
| 155 | |
| 156 | if (offset < 0) |
| 157 | return 0; |
| 158 | |
| 159 | return sysc_read(ddata, offset); |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 160 | } |
| 161 | |
Tony Lindgren | e0db94f | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 162 | static u32 sysc_read_sysconfig(struct sysc *ddata) |
| 163 | { |
| 164 | int offset = ddata->offsets[SYSC_SYSCONFIG]; |
| 165 | |
| 166 | if (offset < 0) |
| 167 | return 0; |
| 168 | |
| 169 | return sysc_read(ddata, offset); |
| 170 | } |
| 171 | |
| 172 | static u32 sysc_read_sysstatus(struct sysc *ddata) |
| 173 | { |
| 174 | int offset = ddata->offsets[SYSC_SYSSTATUS]; |
| 175 | |
| 176 | if (offset < 0) |
| 177 | return 0; |
| 178 | |
| 179 | return sysc_read(ddata, offset); |
| 180 | } |
| 181 | |
Tony Lindgren | a54275f | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 182 | static int sysc_add_named_clock_from_child(struct sysc *ddata, |
| 183 | const char *name, |
| 184 | const char *optfck_name) |
| 185 | { |
| 186 | struct device_node *np = ddata->dev->of_node; |
| 187 | struct device_node *child; |
| 188 | struct clk_lookup *cl; |
| 189 | struct clk *clock; |
| 190 | const char *n; |
| 191 | |
| 192 | if (name) |
| 193 | n = name; |
| 194 | else |
| 195 | n = optfck_name; |
| 196 | |
| 197 | /* Does the clock alias already exist? */ |
| 198 | clock = of_clk_get_by_name(np, n); |
| 199 | if (!IS_ERR(clock)) { |
| 200 | clk_put(clock); |
| 201 | |
| 202 | return 0; |
| 203 | } |
| 204 | |
| 205 | child = of_get_next_available_child(np, NULL); |
| 206 | if (!child) |
| 207 | return -ENODEV; |
| 208 | |
| 209 | clock = devm_get_clk_from_child(ddata->dev, child, name); |
| 210 | if (IS_ERR(clock)) |
| 211 | return PTR_ERR(clock); |
| 212 | |
| 213 | /* |
| 214 | * Use clkdev_add() instead of clkdev_alloc() to avoid the MAX_DEV_ID |
| 215 | * limit for clk_get(). If cl ever needs to be freed, it should be done |
| 216 | * with clkdev_drop(). |
| 217 | */ |
| 218 | cl = kcalloc(1, sizeof(*cl), GFP_KERNEL); |
| 219 | if (!cl) |
| 220 | return -ENOMEM; |
| 221 | |
| 222 | cl->con_id = n; |
| 223 | cl->dev_id = dev_name(ddata->dev); |
| 224 | cl->clk = clock; |
| 225 | clkdev_add(cl); |
| 226 | |
| 227 | clk_put(clock); |
| 228 | |
| 229 | return 0; |
| 230 | } |
| 231 | |
| 232 | static int sysc_init_ext_opt_clock(struct sysc *ddata, const char *name) |
| 233 | { |
| 234 | const char *optfck_name; |
| 235 | int error, index; |
| 236 | |
| 237 | if (ddata->nr_clocks < SYSC_OPTFCK0) |
| 238 | index = SYSC_OPTFCK0; |
| 239 | else |
| 240 | index = ddata->nr_clocks; |
| 241 | |
| 242 | if (name) |
| 243 | optfck_name = name; |
| 244 | else |
| 245 | optfck_name = clock_names[index]; |
| 246 | |
| 247 | error = sysc_add_named_clock_from_child(ddata, name, optfck_name); |
| 248 | if (error) |
| 249 | return error; |
| 250 | |
| 251 | ddata->clock_roles[index] = optfck_name; |
| 252 | ddata->nr_clocks++; |
| 253 | |
| 254 | return 0; |
| 255 | } |
| 256 | |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 257 | static int sysc_get_one_clock(struct sysc *ddata, const char *name) |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 258 | { |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 259 | int error, i, index = -ENODEV; |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 260 | |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 261 | if (!strncmp(clock_names[SYSC_FCK], name, 3)) |
| 262 | index = SYSC_FCK; |
| 263 | else if (!strncmp(clock_names[SYSC_ICK], name, 3)) |
| 264 | index = SYSC_ICK; |
| 265 | |
| 266 | if (index < 0) { |
| 267 | for (i = SYSC_OPTFCK0; i < SYSC_MAX_CLOCKS; i++) { |
Tony Lindgren | c97c862 | 2018-05-18 07:54:44 -0700 | [diff] [blame] | 268 | if (!ddata->clocks[i]) { |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 269 | index = i; |
| 270 | break; |
| 271 | } |
| 272 | } |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 273 | } |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 274 | |
| 275 | if (index < 0) { |
| 276 | dev_err(ddata->dev, "clock %s not added\n", name); |
| 277 | return index; |
| 278 | } |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 279 | |
| 280 | ddata->clocks[index] = devm_clk_get(ddata->dev, name); |
| 281 | if (IS_ERR(ddata->clocks[index])) { |
| 282 | if (PTR_ERR(ddata->clocks[index]) == -ENOENT) |
| 283 | return 0; |
| 284 | |
| 285 | dev_err(ddata->dev, "clock get error for %s: %li\n", |
| 286 | name, PTR_ERR(ddata->clocks[index])); |
| 287 | |
| 288 | return PTR_ERR(ddata->clocks[index]); |
| 289 | } |
| 290 | |
| 291 | error = clk_prepare(ddata->clocks[index]); |
| 292 | if (error) { |
| 293 | dev_err(ddata->dev, "clock prepare error for %s: %i\n", |
| 294 | name, error); |
| 295 | |
| 296 | return error; |
| 297 | } |
| 298 | |
| 299 | return 0; |
| 300 | } |
| 301 | |
| 302 | static int sysc_get_clocks(struct sysc *ddata) |
| 303 | { |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 304 | struct device_node *np = ddata->dev->of_node; |
| 305 | struct property *prop; |
| 306 | const char *name; |
| 307 | int nr_fck = 0, nr_ick = 0, i, error = 0; |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 308 | |
Kees Cook | 2074905 | 2018-06-18 10:45:49 -0700 | [diff] [blame] | 309 | ddata->clock_roles = devm_kcalloc(ddata->dev, |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 310 | SYSC_MAX_CLOCKS, |
Kees Cook | 2074905 | 2018-06-18 10:45:49 -0700 | [diff] [blame] | 311 | sizeof(*ddata->clock_roles), |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 312 | GFP_KERNEL); |
| 313 | if (!ddata->clock_roles) |
| 314 | return -ENOMEM; |
| 315 | |
| 316 | of_property_for_each_string(np, "clock-names", prop, name) { |
| 317 | if (!strncmp(clock_names[SYSC_FCK], name, 3)) |
| 318 | nr_fck++; |
| 319 | if (!strncmp(clock_names[SYSC_ICK], name, 3)) |
| 320 | nr_ick++; |
| 321 | ddata->clock_roles[ddata->nr_clocks] = name; |
| 322 | ddata->nr_clocks++; |
| 323 | } |
| 324 | |
| 325 | if (ddata->nr_clocks < 1) |
| 326 | return 0; |
| 327 | |
Tony Lindgren | a54275f | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 328 | if ((ddata->cfg.quirks & SYSC_QUIRK_EXT_OPT_CLOCK)) { |
| 329 | error = sysc_init_ext_opt_clock(ddata, NULL); |
| 330 | if (error) |
| 331 | return error; |
| 332 | } |
| 333 | |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 334 | if (ddata->nr_clocks > SYSC_MAX_CLOCKS) { |
| 335 | dev_err(ddata->dev, "too many clocks for %pOF\n", np); |
| 336 | |
| 337 | return -EINVAL; |
| 338 | } |
| 339 | |
| 340 | if (nr_fck > 1 || nr_ick > 1) { |
| 341 | dev_err(ddata->dev, "max one fck and ick for %pOF\n", np); |
| 342 | |
| 343 | return -EINVAL; |
| 344 | } |
| 345 | |
Kees Cook | 2074905 | 2018-06-18 10:45:49 -0700 | [diff] [blame] | 346 | ddata->clocks = devm_kcalloc(ddata->dev, |
| 347 | ddata->nr_clocks, sizeof(*ddata->clocks), |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 348 | GFP_KERNEL); |
| 349 | if (!ddata->clocks) |
| 350 | return -ENOMEM; |
| 351 | |
Tony Lindgren | 7b4f8ac | 2018-11-15 14:46:52 -0800 | [diff] [blame] | 352 | for (i = 0; i < SYSC_MAX_CLOCKS; i++) { |
| 353 | const char *name = ddata->clock_roles[i]; |
| 354 | |
| 355 | if (!name) |
| 356 | continue; |
| 357 | |
| 358 | error = sysc_get_one_clock(ddata, name); |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 359 | if (error && error != -ENOENT) |
| 360 | return error; |
| 361 | } |
| 362 | |
| 363 | return 0; |
| 364 | } |
| 365 | |
Tony Lindgren | d878970 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 366 | static int sysc_enable_main_clocks(struct sysc *ddata) |
| 367 | { |
| 368 | struct clk *clock; |
| 369 | int i, error; |
| 370 | |
| 371 | if (!ddata->clocks) |
| 372 | return 0; |
| 373 | |
| 374 | for (i = 0; i < SYSC_OPTFCK0; i++) { |
| 375 | clock = ddata->clocks[i]; |
| 376 | |
| 377 | /* Main clocks may not have ick */ |
| 378 | if (IS_ERR_OR_NULL(clock)) |
| 379 | continue; |
| 380 | |
| 381 | error = clk_enable(clock); |
| 382 | if (error) |
| 383 | goto err_disable; |
| 384 | } |
| 385 | |
| 386 | return 0; |
| 387 | |
| 388 | err_disable: |
| 389 | for (i--; i >= 0; i--) { |
| 390 | clock = ddata->clocks[i]; |
| 391 | |
| 392 | /* Main clocks may not have ick */ |
| 393 | if (IS_ERR_OR_NULL(clock)) |
| 394 | continue; |
| 395 | |
| 396 | clk_disable(clock); |
| 397 | } |
| 398 | |
| 399 | return error; |
| 400 | } |
| 401 | |
| 402 | static void sysc_disable_main_clocks(struct sysc *ddata) |
| 403 | { |
| 404 | struct clk *clock; |
| 405 | int i; |
| 406 | |
| 407 | if (!ddata->clocks) |
| 408 | return; |
| 409 | |
| 410 | for (i = 0; i < SYSC_OPTFCK0; i++) { |
| 411 | clock = ddata->clocks[i]; |
| 412 | if (IS_ERR_OR_NULL(clock)) |
| 413 | continue; |
| 414 | |
| 415 | clk_disable(clock); |
| 416 | } |
| 417 | } |
| 418 | |
| 419 | static int sysc_enable_opt_clocks(struct sysc *ddata) |
| 420 | { |
| 421 | struct clk *clock; |
| 422 | int i, error; |
| 423 | |
| 424 | if (!ddata->clocks) |
| 425 | return 0; |
| 426 | |
| 427 | for (i = SYSC_OPTFCK0; i < SYSC_MAX_CLOCKS; i++) { |
| 428 | clock = ddata->clocks[i]; |
| 429 | |
| 430 | /* Assume no holes for opt clocks */ |
| 431 | if (IS_ERR_OR_NULL(clock)) |
| 432 | return 0; |
| 433 | |
| 434 | error = clk_enable(clock); |
| 435 | if (error) |
| 436 | goto err_disable; |
| 437 | } |
| 438 | |
| 439 | return 0; |
| 440 | |
| 441 | err_disable: |
| 442 | for (i--; i >= 0; i--) { |
| 443 | clock = ddata->clocks[i]; |
| 444 | if (IS_ERR_OR_NULL(clock)) |
| 445 | continue; |
| 446 | |
| 447 | clk_disable(clock); |
| 448 | } |
| 449 | |
| 450 | return error; |
| 451 | } |
| 452 | |
| 453 | static void sysc_disable_opt_clocks(struct sysc *ddata) |
| 454 | { |
| 455 | struct clk *clock; |
| 456 | int i; |
| 457 | |
| 458 | if (!ddata->clocks) |
| 459 | return; |
| 460 | |
| 461 | for (i = SYSC_OPTFCK0; i < SYSC_MAX_CLOCKS; i++) { |
| 462 | clock = ddata->clocks[i]; |
| 463 | |
| 464 | /* Assume no holes for opt clocks */ |
| 465 | if (IS_ERR_OR_NULL(clock)) |
| 466 | return; |
| 467 | |
| 468 | clk_disable(clock); |
| 469 | } |
| 470 | } |
| 471 | |
Tony Lindgren | 2b2f7de | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 472 | static void sysc_clkdm_deny_idle(struct sysc *ddata) |
| 473 | { |
| 474 | struct ti_sysc_platform_data *pdata; |
| 475 | |
| 476 | if (ddata->legacy_mode) |
| 477 | return; |
| 478 | |
| 479 | pdata = dev_get_platdata(ddata->dev); |
| 480 | if (pdata && pdata->clkdm_deny_idle) |
| 481 | pdata->clkdm_deny_idle(ddata->dev, &ddata->cookie); |
| 482 | } |
| 483 | |
| 484 | static void sysc_clkdm_allow_idle(struct sysc *ddata) |
| 485 | { |
| 486 | struct ti_sysc_platform_data *pdata; |
| 487 | |
| 488 | if (ddata->legacy_mode) |
| 489 | return; |
| 490 | |
| 491 | pdata = dev_get_platdata(ddata->dev); |
| 492 | if (pdata && pdata->clkdm_allow_idle) |
| 493 | pdata->clkdm_allow_idle(ddata->dev, &ddata->cookie); |
| 494 | } |
| 495 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 496 | /** |
Tony Lindgren | b11c1ea | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 497 | * sysc_init_resets - init rstctrl reset line if configured |
Tony Lindgren | 5062236 | 2018-04-16 10:20:27 -0700 | [diff] [blame] | 498 | * @ddata: device driver data |
| 499 | * |
Tony Lindgren | b11c1ea | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 500 | * See sysc_rstctrl_reset_deassert(). |
Tony Lindgren | 5062236 | 2018-04-16 10:20:27 -0700 | [diff] [blame] | 501 | */ |
| 502 | static int sysc_init_resets(struct sysc *ddata) |
| 503 | { |
Tony Lindgren | 5062236 | 2018-04-16 10:20:27 -0700 | [diff] [blame] | 504 | ddata->rsts = |
Tony Lindgren | ea5a2e4 | 2019-05-27 04:51:56 -0700 | [diff] [blame] | 505 | devm_reset_control_get_optional(ddata->dev, "rstctrl"); |
Tony Lindgren | 5062236 | 2018-04-16 10:20:27 -0700 | [diff] [blame] | 506 | if (IS_ERR(ddata->rsts)) |
| 507 | return PTR_ERR(ddata->rsts); |
| 508 | |
Tony Lindgren | 5062236 | 2018-04-16 10:20:27 -0700 | [diff] [blame] | 509 | return 0; |
| 510 | } |
| 511 | |
| 512 | /** |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 513 | * sysc_parse_and_check_child_range - parses module IO region from ranges |
| 514 | * @ddata: device driver data |
| 515 | * |
| 516 | * In general we only need rev, syss, and sysc registers and not the whole |
| 517 | * module range. But we do want the offsets for these registers from the |
| 518 | * module base. This allows us to check them against the legacy hwmod |
| 519 | * platform data. Let's also check the ranges are configured properly. |
| 520 | */ |
| 521 | static int sysc_parse_and_check_child_range(struct sysc *ddata) |
| 522 | { |
| 523 | struct device_node *np = ddata->dev->of_node; |
| 524 | const __be32 *ranges; |
| 525 | u32 nr_addr, nr_size; |
| 526 | int len, error; |
| 527 | |
| 528 | ranges = of_get_property(np, "ranges", &len); |
| 529 | if (!ranges) { |
| 530 | dev_err(ddata->dev, "missing ranges for %pOF\n", np); |
| 531 | |
| 532 | return -ENOENT; |
| 533 | } |
| 534 | |
| 535 | len /= sizeof(*ranges); |
| 536 | |
| 537 | if (len < 3) { |
| 538 | dev_err(ddata->dev, "incomplete ranges for %pOF\n", np); |
| 539 | |
| 540 | return -EINVAL; |
| 541 | } |
| 542 | |
| 543 | error = of_property_read_u32(np, "#address-cells", &nr_addr); |
| 544 | if (error) |
| 545 | return -ENOENT; |
| 546 | |
| 547 | error = of_property_read_u32(np, "#size-cells", &nr_size); |
| 548 | if (error) |
| 549 | return -ENOENT; |
| 550 | |
| 551 | if (nr_addr != 1 || nr_size != 1) { |
| 552 | dev_err(ddata->dev, "invalid ranges for %pOF\n", np); |
| 553 | |
| 554 | return -EINVAL; |
| 555 | } |
| 556 | |
| 557 | ranges++; |
| 558 | ddata->module_pa = of_translate_address(np, ranges++); |
| 559 | ddata->module_size = be32_to_cpup(ranges); |
| 560 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 561 | return 0; |
| 562 | } |
| 563 | |
Tony Lindgren | 3bb37c8 | 2018-02-22 14:05:14 -0800 | [diff] [blame] | 564 | static struct device_node *stdout_path; |
| 565 | |
| 566 | static void sysc_init_stdout_path(struct sysc *ddata) |
| 567 | { |
| 568 | struct device_node *np = NULL; |
| 569 | const char *uart; |
| 570 | |
| 571 | if (IS_ERR(stdout_path)) |
| 572 | return; |
| 573 | |
| 574 | if (stdout_path) |
| 575 | return; |
| 576 | |
| 577 | np = of_find_node_by_path("/chosen"); |
| 578 | if (!np) |
| 579 | goto err; |
| 580 | |
| 581 | uart = of_get_property(np, "stdout-path", NULL); |
| 582 | if (!uart) |
| 583 | goto err; |
| 584 | |
| 585 | np = of_find_node_by_path(uart); |
| 586 | if (!np) |
| 587 | goto err; |
| 588 | |
| 589 | stdout_path = np; |
| 590 | |
| 591 | return; |
| 592 | |
| 593 | err: |
| 594 | stdout_path = ERR_PTR(-ENODEV); |
| 595 | } |
| 596 | |
| 597 | static void sysc_check_quirk_stdout(struct sysc *ddata, |
| 598 | struct device_node *np) |
| 599 | { |
| 600 | sysc_init_stdout_path(ddata); |
| 601 | if (np != stdout_path) |
| 602 | return; |
| 603 | |
| 604 | ddata->cfg.quirks |= SYSC_QUIRK_NO_IDLE_ON_INIT | |
| 605 | SYSC_QUIRK_NO_RESET_ON_INIT; |
| 606 | } |
| 607 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 608 | /** |
| 609 | * sysc_check_one_child - check child configuration |
| 610 | * @ddata: device driver data |
| 611 | * @np: child device node |
| 612 | * |
| 613 | * Let's avoid messy situations where we have new interconnect target |
| 614 | * node but children have "ti,hwmods". These belong to the interconnect |
| 615 | * target node and are managed by this driver. |
| 616 | */ |
| 617 | static int sysc_check_one_child(struct sysc *ddata, |
| 618 | struct device_node *np) |
| 619 | { |
| 620 | const char *name; |
| 621 | |
| 622 | name = of_get_property(np, "ti,hwmods", NULL); |
| 623 | if (name) |
| 624 | dev_warn(ddata->dev, "really a child ti,hwmods property?"); |
| 625 | |
Tony Lindgren | 3bb37c8 | 2018-02-22 14:05:14 -0800 | [diff] [blame] | 626 | sysc_check_quirk_stdout(ddata, np); |
Tony Lindgren | 4014c08 | 2018-12-10 14:11:26 -0800 | [diff] [blame] | 627 | sysc_parse_dts_quirks(ddata, np, true); |
Tony Lindgren | 3bb37c8 | 2018-02-22 14:05:14 -0800 | [diff] [blame] | 628 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 629 | return 0; |
| 630 | } |
| 631 | |
| 632 | static int sysc_check_children(struct sysc *ddata) |
| 633 | { |
| 634 | struct device_node *child; |
| 635 | int error; |
| 636 | |
| 637 | for_each_child_of_node(ddata->dev->of_node, child) { |
| 638 | error = sysc_check_one_child(ddata, child); |
| 639 | if (error) |
| 640 | return error; |
| 641 | } |
| 642 | |
| 643 | return 0; |
| 644 | } |
| 645 | |
Tony Lindgren | a7199e2 | 2017-12-15 09:41:14 -0800 | [diff] [blame] | 646 | /* |
| 647 | * So far only I2C uses 16-bit read access with clockactivity with revision |
| 648 | * in two registers with stride of 4. We can detect this based on the rev |
| 649 | * register size to configure things far enough to be able to properly read |
| 650 | * the revision register. |
| 651 | */ |
| 652 | static void sysc_check_quirk_16bit(struct sysc *ddata, struct resource *res) |
| 653 | { |
Tony Lindgren | dd57ac1 | 2018-02-22 14:09:57 -0800 | [diff] [blame] | 654 | if (resource_size(res) == 8) |
Tony Lindgren | a7199e2 | 2017-12-15 09:41:14 -0800 | [diff] [blame] | 655 | ddata->cfg.quirks |= SYSC_QUIRK_16BIT | SYSC_QUIRK_USE_CLOCKACT; |
Tony Lindgren | a7199e2 | 2017-12-15 09:41:14 -0800 | [diff] [blame] | 656 | } |
| 657 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 658 | /** |
| 659 | * sysc_parse_one - parses the interconnect target module registers |
| 660 | * @ddata: device driver data |
| 661 | * @reg: register to parse |
| 662 | */ |
| 663 | static int sysc_parse_one(struct sysc *ddata, enum sysc_registers reg) |
| 664 | { |
| 665 | struct resource *res; |
| 666 | const char *name; |
| 667 | |
| 668 | switch (reg) { |
| 669 | case SYSC_REVISION: |
| 670 | case SYSC_SYSCONFIG: |
| 671 | case SYSC_SYSSTATUS: |
| 672 | name = reg_names[reg]; |
| 673 | break; |
| 674 | default: |
| 675 | return -EINVAL; |
| 676 | } |
| 677 | |
| 678 | res = platform_get_resource_byname(to_platform_device(ddata->dev), |
| 679 | IORESOURCE_MEM, name); |
| 680 | if (!res) { |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 681 | ddata->offsets[reg] = -ENODEV; |
| 682 | |
| 683 | return 0; |
| 684 | } |
| 685 | |
| 686 | ddata->offsets[reg] = res->start - ddata->module_pa; |
Tony Lindgren | a7199e2 | 2017-12-15 09:41:14 -0800 | [diff] [blame] | 687 | if (reg == SYSC_REVISION) |
| 688 | sysc_check_quirk_16bit(ddata, res); |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 689 | |
| 690 | return 0; |
| 691 | } |
| 692 | |
| 693 | static int sysc_parse_registers(struct sysc *ddata) |
| 694 | { |
| 695 | int i, error; |
| 696 | |
| 697 | for (i = 0; i < SYSC_MAX_REGS; i++) { |
| 698 | error = sysc_parse_one(ddata, i); |
| 699 | if (error) |
| 700 | return error; |
| 701 | } |
| 702 | |
| 703 | return 0; |
| 704 | } |
| 705 | |
| 706 | /** |
| 707 | * sysc_check_registers - check for misconfigured register overlaps |
| 708 | * @ddata: device driver data |
| 709 | */ |
| 710 | static int sysc_check_registers(struct sysc *ddata) |
| 711 | { |
| 712 | int i, j, nr_regs = 0, nr_matches = 0; |
| 713 | |
| 714 | for (i = 0; i < SYSC_MAX_REGS; i++) { |
| 715 | if (ddata->offsets[i] < 0) |
| 716 | continue; |
| 717 | |
| 718 | if (ddata->offsets[i] > (ddata->module_size - 4)) { |
| 719 | dev_err(ddata->dev, "register outside module range"); |
| 720 | |
| 721 | return -EINVAL; |
| 722 | } |
| 723 | |
| 724 | for (j = 0; j < SYSC_MAX_REGS; j++) { |
| 725 | if (ddata->offsets[j] < 0) |
| 726 | continue; |
| 727 | |
| 728 | if (ddata->offsets[i] == ddata->offsets[j]) |
| 729 | nr_matches++; |
| 730 | } |
| 731 | nr_regs++; |
| 732 | } |
| 733 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 734 | if (nr_matches > nr_regs) { |
| 735 | dev_err(ddata->dev, "overlapping registers: (%i/%i)", |
| 736 | nr_regs, nr_matches); |
| 737 | |
| 738 | return -EINVAL; |
| 739 | } |
| 740 | |
| 741 | return 0; |
| 742 | } |
| 743 | |
| 744 | /** |
| 745 | * syc_ioremap - ioremap register space for the interconnect target module |
Tony Lindgren | 0ef8e3b | 2018-08-08 01:07:05 -0700 | [diff] [blame] | 746 | * @ddata: device driver data |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 747 | * |
| 748 | * Note that the interconnect target module registers can be anywhere |
Tony Lindgren | 0ef8e3b | 2018-08-08 01:07:05 -0700 | [diff] [blame] | 749 | * within the interconnect target module range. For example, SGX has |
| 750 | * them at offset 0x1fc00 in the 32MB module address space. And cpsw |
| 751 | * has them at offset 0x1200 in the CPSW_WR child. Usually the |
| 752 | * the interconnect target module registers are at the beginning of |
| 753 | * the module range though. |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 754 | */ |
| 755 | static int sysc_ioremap(struct sysc *ddata) |
| 756 | { |
Tony Lindgren | 0ef8e3b | 2018-08-08 01:07:05 -0700 | [diff] [blame] | 757 | int size; |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 758 | |
Tony Lindgren | e4f50c8 | 2019-05-01 14:24:57 -0700 | [diff] [blame] | 759 | if (ddata->offsets[SYSC_REVISION] < 0 && |
| 760 | ddata->offsets[SYSC_SYSCONFIG] < 0 && |
| 761 | ddata->offsets[SYSC_SYSSTATUS] < 0) { |
| 762 | size = ddata->module_size; |
| 763 | } else { |
| 764 | size = max3(ddata->offsets[SYSC_REVISION], |
| 765 | ddata->offsets[SYSC_SYSCONFIG], |
| 766 | ddata->offsets[SYSC_SYSSTATUS]); |
Tony Lindgren | 0ef8e3b | 2018-08-08 01:07:05 -0700 | [diff] [blame] | 767 | |
Tony Lindgren | 4e23be4 | 2019-06-10 04:48:05 -0700 | [diff] [blame] | 768 | if (size < SZ_1K) |
| 769 | size = SZ_1K; |
| 770 | |
Tony Lindgren | e4f50c8 | 2019-05-01 14:24:57 -0700 | [diff] [blame] | 771 | if ((size + sizeof(u32)) > ddata->module_size) |
Tony Lindgren | 4e23be4 | 2019-06-10 04:48:05 -0700 | [diff] [blame] | 772 | size = ddata->module_size; |
Tony Lindgren | e4f50c8 | 2019-05-01 14:24:57 -0700 | [diff] [blame] | 773 | } |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 774 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 775 | ddata->module_va = devm_ioremap(ddata->dev, |
| 776 | ddata->module_pa, |
Tony Lindgren | 0ef8e3b | 2018-08-08 01:07:05 -0700 | [diff] [blame] | 777 | size + sizeof(u32)); |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 778 | if (!ddata->module_va) |
| 779 | return -EIO; |
| 780 | |
| 781 | return 0; |
| 782 | } |
| 783 | |
| 784 | /** |
| 785 | * sysc_map_and_check_registers - ioremap and check device registers |
| 786 | * @ddata: device driver data |
| 787 | */ |
| 788 | static int sysc_map_and_check_registers(struct sysc *ddata) |
| 789 | { |
| 790 | int error; |
| 791 | |
| 792 | error = sysc_parse_and_check_child_range(ddata); |
| 793 | if (error) |
| 794 | return error; |
| 795 | |
| 796 | error = sysc_check_children(ddata); |
| 797 | if (error) |
| 798 | return error; |
| 799 | |
| 800 | error = sysc_parse_registers(ddata); |
| 801 | if (error) |
| 802 | return error; |
| 803 | |
| 804 | error = sysc_ioremap(ddata); |
| 805 | if (error) |
| 806 | return error; |
| 807 | |
| 808 | error = sysc_check_registers(ddata); |
| 809 | if (error) |
| 810 | return error; |
| 811 | |
| 812 | return 0; |
| 813 | } |
| 814 | |
| 815 | /** |
| 816 | * sysc_show_rev - read and show interconnect target module revision |
| 817 | * @bufp: buffer to print the information to |
| 818 | * @ddata: device driver data |
| 819 | */ |
| 820 | static int sysc_show_rev(char *bufp, struct sysc *ddata) |
| 821 | { |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 822 | int len; |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 823 | |
| 824 | if (ddata->offsets[SYSC_REVISION] < 0) |
| 825 | return sprintf(bufp, ":NA"); |
| 826 | |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 827 | len = sprintf(bufp, ":%08x", ddata->revision); |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 828 | |
| 829 | return len; |
| 830 | } |
| 831 | |
| 832 | static int sysc_show_reg(struct sysc *ddata, |
| 833 | char *bufp, enum sysc_registers reg) |
| 834 | { |
| 835 | if (ddata->offsets[reg] < 0) |
| 836 | return sprintf(bufp, ":NA"); |
| 837 | |
| 838 | return sprintf(bufp, ":%x", ddata->offsets[reg]); |
| 839 | } |
| 840 | |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 841 | static int sysc_show_name(char *bufp, struct sysc *ddata) |
| 842 | { |
| 843 | if (!ddata->name) |
| 844 | return 0; |
| 845 | |
| 846 | return sprintf(bufp, ":%s", ddata->name); |
| 847 | } |
| 848 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 849 | /** |
| 850 | * sysc_show_registers - show information about interconnect target module |
| 851 | * @ddata: device driver data |
| 852 | */ |
| 853 | static void sysc_show_registers(struct sysc *ddata) |
| 854 | { |
| 855 | char buf[128]; |
| 856 | char *bufp = buf; |
| 857 | int i; |
| 858 | |
| 859 | for (i = 0; i < SYSC_MAX_REGS; i++) |
| 860 | bufp += sysc_show_reg(ddata, bufp, i); |
| 861 | |
| 862 | bufp += sysc_show_rev(bufp, ddata); |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 863 | bufp += sysc_show_name(bufp, ddata); |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 864 | |
| 865 | dev_dbg(ddata->dev, "%llx:%x%s\n", |
| 866 | ddata->module_pa, ddata->module_size, |
| 867 | buf); |
| 868 | } |
| 869 | |
Roger Quadros | d59b605 | 2019-04-08 12:52:39 +0300 | [diff] [blame] | 870 | #define SYSC_IDLE_MASK (SYSC_NR_IDLEMODES - 1) |
Tony Lindgren | ae9ae12 | 2019-05-27 04:51:54 -0700 | [diff] [blame] | 871 | #define SYSC_CLOCACT_ICK 2 |
Roger Quadros | d59b605 | 2019-04-08 12:52:39 +0300 | [diff] [blame] | 872 | |
Tony Lindgren | 2b2f7de | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 873 | /* Caller needs to manage sysc_clkdm_deny_idle() and sysc_clkdm_allow_idle() */ |
Roger Quadros | d59b605 | 2019-04-08 12:52:39 +0300 | [diff] [blame] | 874 | static int sysc_enable_module(struct device *dev) |
| 875 | { |
| 876 | struct sysc *ddata; |
| 877 | const struct sysc_regbits *regbits; |
| 878 | u32 reg, idlemodes, best_mode; |
| 879 | |
| 880 | ddata = dev_get_drvdata(dev); |
| 881 | if (ddata->offsets[SYSC_SYSCONFIG] == -ENODEV) |
| 882 | return 0; |
| 883 | |
Roger Quadros | d59b605 | 2019-04-08 12:52:39 +0300 | [diff] [blame] | 884 | regbits = ddata->cap->regbits; |
| 885 | reg = sysc_read(ddata, ddata->offsets[SYSC_SYSCONFIG]); |
| 886 | |
Tony Lindgren | ae9ae12 | 2019-05-27 04:51:54 -0700 | [diff] [blame] | 887 | /* Set CLOCKACTIVITY, we only use it for ick */ |
| 888 | if (regbits->clkact_shift >= 0 && |
| 889 | (ddata->cfg.quirks & SYSC_QUIRK_USE_CLOCKACT || |
| 890 | ddata->cfg.sysc_val & BIT(regbits->clkact_shift))) |
| 891 | reg |= SYSC_CLOCACT_ICK << regbits->clkact_shift; |
| 892 | |
Roger Quadros | d59b605 | 2019-04-08 12:52:39 +0300 | [diff] [blame] | 893 | /* Set SIDLE mode */ |
| 894 | idlemodes = ddata->cfg.sidlemodes; |
| 895 | if (!idlemodes || regbits->sidle_shift < 0) |
| 896 | goto set_midle; |
| 897 | |
Tony Lindgren | fb685f1 | 2019-05-27 04:51:55 -0700 | [diff] [blame] | 898 | if (ddata->cfg.quirks & (SYSC_QUIRK_SWSUP_SIDLE | |
| 899 | SYSC_QUIRK_SWSUP_SIDLE_ACT)) { |
| 900 | best_mode = SYSC_IDLE_NO; |
| 901 | } else { |
| 902 | best_mode = fls(ddata->cfg.sidlemodes) - 1; |
| 903 | if (best_mode > SYSC_IDLE_MASK) { |
| 904 | dev_err(dev, "%s: invalid sidlemode\n", __func__); |
| 905 | return -EINVAL; |
| 906 | } |
Tony Lindgren | 6e09f49 | 2019-05-27 04:51:55 -0700 | [diff] [blame] | 907 | |
| 908 | /* Set WAKEUP */ |
| 909 | if (regbits->enwkup_shift >= 0 && |
| 910 | ddata->cfg.sysc_val & BIT(regbits->enwkup_shift)) |
| 911 | reg |= BIT(regbits->enwkup_shift); |
Roger Quadros | d59b605 | 2019-04-08 12:52:39 +0300 | [diff] [blame] | 912 | } |
| 913 | |
| 914 | reg &= ~(SYSC_IDLE_MASK << regbits->sidle_shift); |
| 915 | reg |= best_mode << regbits->sidle_shift; |
| 916 | sysc_write(ddata, ddata->offsets[SYSC_SYSCONFIG], reg); |
| 917 | |
| 918 | set_midle: |
| 919 | /* Set MIDLE mode */ |
| 920 | idlemodes = ddata->cfg.midlemodes; |
| 921 | if (!idlemodes || regbits->midle_shift < 0) |
Tony Lindgren | eec2655 | 2019-05-27 04:51:54 -0700 | [diff] [blame] | 922 | goto set_autoidle; |
Roger Quadros | d59b605 | 2019-04-08 12:52:39 +0300 | [diff] [blame] | 923 | |
| 924 | best_mode = fls(ddata->cfg.midlemodes) - 1; |
| 925 | if (best_mode > SYSC_IDLE_MASK) { |
| 926 | dev_err(dev, "%s: invalid midlemode\n", __func__); |
| 927 | return -EINVAL; |
| 928 | } |
| 929 | |
| 930 | reg &= ~(SYSC_IDLE_MASK << regbits->midle_shift); |
| 931 | reg |= best_mode << regbits->midle_shift; |
| 932 | sysc_write(ddata, ddata->offsets[SYSC_SYSCONFIG], reg); |
| 933 | |
Tony Lindgren | eec2655 | 2019-05-27 04:51:54 -0700 | [diff] [blame] | 934 | set_autoidle: |
| 935 | /* Autoidle bit must enabled separately if available */ |
| 936 | if (regbits->autoidle_shift >= 0 && |
| 937 | ddata->cfg.sysc_val & BIT(regbits->autoidle_shift)) { |
| 938 | reg |= 1 << regbits->autoidle_shift; |
| 939 | sysc_write(ddata, ddata->offsets[SYSC_SYSCONFIG], reg); |
| 940 | } |
| 941 | |
Roger Quadros | d59b605 | 2019-04-08 12:52:39 +0300 | [diff] [blame] | 942 | return 0; |
| 943 | } |
| 944 | |
| 945 | static int sysc_best_idle_mode(u32 idlemodes, u32 *best_mode) |
| 946 | { |
| 947 | if (idlemodes & BIT(SYSC_IDLE_SMART_WKUP)) |
| 948 | *best_mode = SYSC_IDLE_SMART_WKUP; |
| 949 | else if (idlemodes & BIT(SYSC_IDLE_SMART)) |
| 950 | *best_mode = SYSC_IDLE_SMART; |
Tony Lindgren | 6ee8241 | 2019-07-22 03:44:42 -0700 | [diff] [blame] | 951 | else if (idlemodes & BIT(SYSC_IDLE_FORCE)) |
Roger Quadros | d59b605 | 2019-04-08 12:52:39 +0300 | [diff] [blame] | 952 | *best_mode = SYSC_IDLE_FORCE; |
| 953 | else |
| 954 | return -EINVAL; |
| 955 | |
| 956 | return 0; |
| 957 | } |
| 958 | |
Tony Lindgren | 2b2f7de | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 959 | /* Caller needs to manage sysc_clkdm_deny_idle() and sysc_clkdm_allow_idle() */ |
Roger Quadros | d59b605 | 2019-04-08 12:52:39 +0300 | [diff] [blame] | 960 | static int sysc_disable_module(struct device *dev) |
| 961 | { |
| 962 | struct sysc *ddata; |
| 963 | const struct sysc_regbits *regbits; |
| 964 | u32 reg, idlemodes, best_mode; |
| 965 | int ret; |
| 966 | |
| 967 | ddata = dev_get_drvdata(dev); |
| 968 | if (ddata->offsets[SYSC_SYSCONFIG] == -ENODEV) |
| 969 | return 0; |
| 970 | |
Roger Quadros | d59b605 | 2019-04-08 12:52:39 +0300 | [diff] [blame] | 971 | regbits = ddata->cap->regbits; |
| 972 | reg = sysc_read(ddata, ddata->offsets[SYSC_SYSCONFIG]); |
| 973 | |
| 974 | /* Set MIDLE mode */ |
| 975 | idlemodes = ddata->cfg.midlemodes; |
| 976 | if (!idlemodes || regbits->midle_shift < 0) |
| 977 | goto set_sidle; |
| 978 | |
| 979 | ret = sysc_best_idle_mode(idlemodes, &best_mode); |
| 980 | if (ret) { |
| 981 | dev_err(dev, "%s: invalid midlemode\n", __func__); |
| 982 | return ret; |
| 983 | } |
| 984 | |
| 985 | reg &= ~(SYSC_IDLE_MASK << regbits->midle_shift); |
| 986 | reg |= best_mode << regbits->midle_shift; |
| 987 | sysc_write(ddata, ddata->offsets[SYSC_SYSCONFIG], reg); |
| 988 | |
| 989 | set_sidle: |
| 990 | /* Set SIDLE mode */ |
| 991 | idlemodes = ddata->cfg.sidlemodes; |
| 992 | if (!idlemodes || regbits->sidle_shift < 0) |
| 993 | return 0; |
| 994 | |
Tony Lindgren | fb685f1 | 2019-05-27 04:51:55 -0700 | [diff] [blame] | 995 | if (ddata->cfg.quirks & SYSC_QUIRK_SWSUP_SIDLE) { |
| 996 | best_mode = SYSC_IDLE_FORCE; |
| 997 | } else { |
| 998 | ret = sysc_best_idle_mode(idlemodes, &best_mode); |
| 999 | if (ret) { |
| 1000 | dev_err(dev, "%s: invalid sidlemode\n", __func__); |
| 1001 | return ret; |
| 1002 | } |
Roger Quadros | d59b605 | 2019-04-08 12:52:39 +0300 | [diff] [blame] | 1003 | } |
| 1004 | |
| 1005 | reg &= ~(SYSC_IDLE_MASK << regbits->sidle_shift); |
| 1006 | reg |= best_mode << regbits->sidle_shift; |
Tony Lindgren | eec2655 | 2019-05-27 04:51:54 -0700 | [diff] [blame] | 1007 | if (regbits->autoidle_shift >= 0 && |
| 1008 | ddata->cfg.sysc_val & BIT(regbits->autoidle_shift)) |
| 1009 | reg |= 1 << regbits->autoidle_shift; |
Roger Quadros | d59b605 | 2019-04-08 12:52:39 +0300 | [diff] [blame] | 1010 | sysc_write(ddata, ddata->offsets[SYSC_SYSCONFIG], reg); |
| 1011 | |
| 1012 | return 0; |
| 1013 | } |
| 1014 | |
Tony Lindgren | ff43728 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1015 | static int __maybe_unused sysc_runtime_suspend_legacy(struct device *dev, |
| 1016 | struct sysc *ddata) |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 1017 | { |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 1018 | struct ti_sysc_platform_data *pdata; |
Tony Lindgren | ff43728 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1019 | int error; |
| 1020 | |
| 1021 | pdata = dev_get_platdata(ddata->dev); |
| 1022 | if (!pdata) |
| 1023 | return 0; |
| 1024 | |
| 1025 | if (!pdata->idle_module) |
| 1026 | return -ENODEV; |
| 1027 | |
| 1028 | error = pdata->idle_module(dev, &ddata->cookie); |
| 1029 | if (error) |
| 1030 | dev_err(dev, "%s: could not idle: %i\n", |
| 1031 | __func__, error); |
| 1032 | |
Tony Lindgren | 8383e25 | 2019-05-27 04:51:56 -0700 | [diff] [blame] | 1033 | if (ddata->disable_on_idle) |
| 1034 | reset_control_assert(ddata->rsts); |
| 1035 | |
Tony Lindgren | ff43728 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1036 | return 0; |
| 1037 | } |
| 1038 | |
| 1039 | static int __maybe_unused sysc_runtime_resume_legacy(struct device *dev, |
| 1040 | struct sysc *ddata) |
| 1041 | { |
| 1042 | struct ti_sysc_platform_data *pdata; |
| 1043 | int error; |
| 1044 | |
Tony Lindgren | 8383e25 | 2019-05-27 04:51:56 -0700 | [diff] [blame] | 1045 | if (ddata->disable_on_idle) |
| 1046 | reset_control_deassert(ddata->rsts); |
| 1047 | |
Tony Lindgren | ff43728 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1048 | pdata = dev_get_platdata(ddata->dev); |
| 1049 | if (!pdata) |
| 1050 | return 0; |
| 1051 | |
| 1052 | if (!pdata->enable_module) |
| 1053 | return -ENODEV; |
| 1054 | |
| 1055 | error = pdata->enable_module(dev, &ddata->cookie); |
| 1056 | if (error) |
| 1057 | dev_err(dev, "%s: could not enable: %i\n", |
| 1058 | __func__, error); |
| 1059 | |
| 1060 | return 0; |
| 1061 | } |
| 1062 | |
| 1063 | static int __maybe_unused sysc_runtime_suspend(struct device *dev) |
| 1064 | { |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 1065 | struct sysc *ddata; |
Tony Lindgren | d878970 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1066 | int error = 0; |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 1067 | |
| 1068 | ddata = dev_get_drvdata(dev); |
| 1069 | |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 1070 | if (!ddata->enabled) |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 1071 | return 0; |
| 1072 | |
Tony Lindgren | 2b2f7de | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 1073 | sysc_clkdm_deny_idle(ddata); |
| 1074 | |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 1075 | if (ddata->legacy_mode) { |
Tony Lindgren | ff43728 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1076 | error = sysc_runtime_suspend_legacy(dev, ddata); |
Tony Lindgren | 93de83a | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1077 | if (error) |
Tony Lindgren | 2b2f7de | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 1078 | goto err_allow_idle; |
Roger Quadros | d59b605 | 2019-04-08 12:52:39 +0300 | [diff] [blame] | 1079 | } else { |
| 1080 | error = sysc_disable_module(dev); |
| 1081 | if (error) |
Tony Lindgren | 2b2f7de | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 1082 | goto err_allow_idle; |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 1083 | } |
| 1084 | |
Tony Lindgren | d878970 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1085 | sysc_disable_main_clocks(ddata); |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 1086 | |
Tony Lindgren | d878970 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1087 | if (sysc_opt_clks_needed(ddata)) |
| 1088 | sysc_disable_opt_clocks(ddata); |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 1089 | |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 1090 | ddata->enabled = false; |
| 1091 | |
Tony Lindgren | 2b2f7de | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 1092 | err_allow_idle: |
| 1093 | sysc_clkdm_allow_idle(ddata); |
| 1094 | |
Tony Lindgren | 8383e25 | 2019-05-27 04:51:56 -0700 | [diff] [blame] | 1095 | if (ddata->disable_on_idle) |
| 1096 | reset_control_assert(ddata->rsts); |
| 1097 | |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 1098 | return error; |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 1099 | } |
| 1100 | |
Arnd Bergmann | a4a5d49 | 2017-10-13 11:25:32 +0200 | [diff] [blame] | 1101 | static int __maybe_unused sysc_runtime_resume(struct device *dev) |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 1102 | { |
| 1103 | struct sysc *ddata; |
Tony Lindgren | d878970 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1104 | int error = 0; |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 1105 | |
| 1106 | ddata = dev_get_drvdata(dev); |
| 1107 | |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 1108 | if (ddata->enabled) |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 1109 | return 0; |
| 1110 | |
Tony Lindgren | 8383e25 | 2019-05-27 04:51:56 -0700 | [diff] [blame] | 1111 | if (ddata->disable_on_idle) |
| 1112 | reset_control_deassert(ddata->rsts); |
| 1113 | |
Tony Lindgren | 2b2f7de | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 1114 | sysc_clkdm_deny_idle(ddata); |
| 1115 | |
Tony Lindgren | d878970 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1116 | if (sysc_opt_clks_needed(ddata)) { |
| 1117 | error = sysc_enable_opt_clocks(ddata); |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 1118 | if (error) |
Tony Lindgren | 2b2f7de | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 1119 | goto err_allow_idle; |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 1120 | } |
| 1121 | |
Tony Lindgren | d878970 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1122 | error = sysc_enable_main_clocks(ddata); |
| 1123 | if (error) |
Tony Lindgren | 93de83a | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1124 | goto err_opt_clocks; |
| 1125 | |
| 1126 | if (ddata->legacy_mode) { |
| 1127 | error = sysc_runtime_resume_legacy(dev, ddata); |
| 1128 | if (error) |
| 1129 | goto err_main_clocks; |
Roger Quadros | d59b605 | 2019-04-08 12:52:39 +0300 | [diff] [blame] | 1130 | } else { |
| 1131 | error = sysc_enable_module(dev); |
| 1132 | if (error) |
| 1133 | goto err_main_clocks; |
Tony Lindgren | 93de83a | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1134 | } |
Tony Lindgren | d878970 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1135 | |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 1136 | ddata->enabled = true; |
| 1137 | |
Tony Lindgren | 2b2f7de | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 1138 | sysc_clkdm_allow_idle(ddata); |
| 1139 | |
Tony Lindgren | d878970 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1140 | return 0; |
| 1141 | |
| 1142 | err_main_clocks: |
Tony Lindgren | 93de83a | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1143 | sysc_disable_main_clocks(ddata); |
| 1144 | err_opt_clocks: |
Tony Lindgren | d878970 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1145 | if (sysc_opt_clks_needed(ddata)) |
| 1146 | sysc_disable_opt_clocks(ddata); |
Tony Lindgren | 2b2f7de | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 1147 | err_allow_idle: |
| 1148 | sysc_clkdm_allow_idle(ddata); |
Tony Lindgren | d878970 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1149 | |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 1150 | return error; |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 1151 | } |
| 1152 | |
Tony Lindgren | f5e80203 | 2018-10-01 09:33:28 -0700 | [diff] [blame] | 1153 | static int __maybe_unused sysc_noirq_suspend(struct device *dev) |
Tony Lindgren | 62020f2 | 2018-02-22 13:59:44 -0800 | [diff] [blame] | 1154 | { |
| 1155 | struct sysc *ddata; |
| 1156 | |
| 1157 | ddata = dev_get_drvdata(dev); |
| 1158 | |
Tony Lindgren | 40d9f91 | 2018-09-24 12:16:54 -0700 | [diff] [blame] | 1159 | if (ddata->cfg.quirks & SYSC_QUIRK_LEGACY_IDLE) |
Tony Lindgren | e7420c2 | 2018-04-16 10:26:46 -0700 | [diff] [blame] | 1160 | return 0; |
| 1161 | |
Tony Lindgren | f5e80203 | 2018-10-01 09:33:28 -0700 | [diff] [blame] | 1162 | return pm_runtime_force_suspend(dev); |
Tony Lindgren | 62020f2 | 2018-02-22 13:59:44 -0800 | [diff] [blame] | 1163 | } |
| 1164 | |
Tony Lindgren | f5e80203 | 2018-10-01 09:33:28 -0700 | [diff] [blame] | 1165 | static int __maybe_unused sysc_noirq_resume(struct device *dev) |
Tony Lindgren | 62020f2 | 2018-02-22 13:59:44 -0800 | [diff] [blame] | 1166 | { |
| 1167 | struct sysc *ddata; |
| 1168 | |
| 1169 | ddata = dev_get_drvdata(dev); |
Tony Lindgren | e7420c2 | 2018-04-16 10:26:46 -0700 | [diff] [blame] | 1170 | |
Tony Lindgren | 40d9f91 | 2018-09-24 12:16:54 -0700 | [diff] [blame] | 1171 | if (ddata->cfg.quirks & SYSC_QUIRK_LEGACY_IDLE) |
Tony Lindgren | e7420c2 | 2018-04-16 10:26:46 -0700 | [diff] [blame] | 1172 | return 0; |
| 1173 | |
Tony Lindgren | f5e80203 | 2018-10-01 09:33:28 -0700 | [diff] [blame] | 1174 | return pm_runtime_force_resume(dev); |
Tony Lindgren | e7420c2 | 2018-04-16 10:26:46 -0700 | [diff] [blame] | 1175 | } |
| 1176 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 1177 | static const struct dev_pm_ops sysc_pm_ops = { |
Tony Lindgren | e7420c2 | 2018-04-16 10:26:46 -0700 | [diff] [blame] | 1178 | SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(sysc_noirq_suspend, sysc_noirq_resume) |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 1179 | SET_RUNTIME_PM_OPS(sysc_runtime_suspend, |
| 1180 | sysc_runtime_resume, |
| 1181 | NULL) |
| 1182 | }; |
| 1183 | |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1184 | /* Module revision register based quirks */ |
| 1185 | struct sysc_revision_quirk { |
| 1186 | const char *name; |
| 1187 | u32 base; |
| 1188 | int rev_offset; |
| 1189 | int sysc_offset; |
| 1190 | int syss_offset; |
| 1191 | u32 revision; |
| 1192 | u32 revision_mask; |
| 1193 | u32 quirks; |
| 1194 | }; |
| 1195 | |
| 1196 | #define SYSC_QUIRK(optname, optbase, optrev, optsysc, optsyss, \ |
| 1197 | optrev_val, optrevmask, optquirkmask) \ |
| 1198 | { \ |
| 1199 | .name = (optname), \ |
| 1200 | .base = (optbase), \ |
| 1201 | .rev_offset = (optrev), \ |
| 1202 | .sysc_offset = (optsysc), \ |
| 1203 | .syss_offset = (optsyss), \ |
| 1204 | .revision = (optrev_val), \ |
| 1205 | .revision_mask = (optrevmask), \ |
| 1206 | .quirks = (optquirkmask), \ |
| 1207 | } |
| 1208 | |
| 1209 | static const struct sysc_revision_quirk sysc_revision_quirks[] = { |
| 1210 | /* 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] | 1211 | SYSC_QUIRK("gpio", 0, 0, 0x10, 0x114, 0x50600801, 0xffff00ff, |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 1212 | SYSC_QUIRK_LEGACY_IDLE | SYSC_QUIRK_OPT_CLKS_IN_RESET), |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1213 | SYSC_QUIRK("mmu", 0, 0, 0x10, 0x14, 0x00000020, 0xffffffff, |
| 1214 | SYSC_QUIRK_LEGACY_IDLE), |
| 1215 | SYSC_QUIRK("mmu", 0, 0, 0x10, 0x14, 0x00000030, 0xffffffff, |
| 1216 | SYSC_QUIRK_LEGACY_IDLE), |
| 1217 | SYSC_QUIRK("sham", 0, 0x100, 0x110, 0x114, 0x40000c03, 0xffffffff, |
| 1218 | SYSC_QUIRK_LEGACY_IDLE), |
| 1219 | SYSC_QUIRK("smartreflex", 0, -1, 0x24, -1, 0x00000000, 0xffffffff, |
| 1220 | SYSC_QUIRK_LEGACY_IDLE), |
| 1221 | SYSC_QUIRK("smartreflex", 0, -1, 0x38, -1, 0x00000000, 0xffffffff, |
| 1222 | SYSC_QUIRK_LEGACY_IDLE), |
| 1223 | SYSC_QUIRK("timer", 0, 0, 0x10, 0x14, 0x00000015, 0xffffffff, |
Tony Lindgren | 9bd34c6 | 2019-01-22 09:03:08 -0800 | [diff] [blame] | 1224 | 0), |
Tony Lindgren | 8cde5d5 | 2018-04-16 10:25:15 -0700 | [diff] [blame] | 1225 | /* Some timers on omap4 and later */ |
Tony Lindgren | 3a3d802 | 2018-09-27 13:33:58 -0700 | [diff] [blame] | 1226 | SYSC_QUIRK("timer", 0, 0, 0x10, -1, 0x50002100, 0xffffffff, |
Tony Lindgren | 072167d | 2019-01-29 07:53:47 -0800 | [diff] [blame] | 1227 | 0), |
Tony Lindgren | 3a3d802 | 2018-09-27 13:33:58 -0700 | [diff] [blame] | 1228 | SYSC_QUIRK("timer", 0, 0, 0x10, -1, 0x4fff1301, 0xffff00ff, |
Tony Lindgren | 9bd34c6 | 2019-01-22 09:03:08 -0800 | [diff] [blame] | 1229 | 0), |
Tony Lindgren | b6a53c4 | 2019-05-27 04:51:57 -0700 | [diff] [blame] | 1230 | SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x00000046, 0xffffffff, |
| 1231 | SYSC_QUIRK_SWSUP_SIDLE | SYSC_QUIRK_LEGACY_IDLE), |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1232 | SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x00000052, 0xffffffff, |
Tony Lindgren | b6a53c4 | 2019-05-27 04:51:57 -0700 | [diff] [blame] | 1233 | SYSC_QUIRK_SWSUP_SIDLE | SYSC_QUIRK_LEGACY_IDLE), |
Tony Lindgren | d708bb1 | 2018-04-16 10:25:32 -0700 | [diff] [blame] | 1234 | /* Uarts on omap4 and later */ |
Tony Lindgren | b82beef | 2018-09-24 12:16:59 -0700 | [diff] [blame] | 1235 | SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x50411e03, 0xffff00ff, |
Tony Lindgren | b4a9a7a | 2019-03-21 13:27:08 -0700 | [diff] [blame] | 1236 | SYSC_QUIRK_SWSUP_SIDLE_ACT | SYSC_QUIRK_LEGACY_IDLE), |
Tony Lindgren | b82beef | 2018-09-24 12:16:59 -0700 | [diff] [blame] | 1237 | SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x47422e03, 0xffffffff, |
Tony Lindgren | b4a9a7a | 2019-03-21 13:27:08 -0700 | [diff] [blame] | 1238 | SYSC_QUIRK_SWSUP_SIDLE_ACT | SYSC_QUIRK_LEGACY_IDLE), |
Tony Lindgren | 7e27e5d | 2018-04-20 14:54:16 -0700 | [diff] [blame] | 1239 | |
Tony Lindgren | a54275f | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1240 | /* Quirks that need to be set based on the module address */ |
| 1241 | SYSC_QUIRK("mcpdm", 0x40132000, 0, 0x10, -1, 0x50000800, 0xffffffff, |
| 1242 | SYSC_QUIRK_EXT_OPT_CLOCK | SYSC_QUIRK_NO_RESET_ON_INIT | |
| 1243 | SYSC_QUIRK_SWSUP_SIDLE), |
| 1244 | |
Tony Lindgren | 4e23be4 | 2019-06-10 04:48:05 -0700 | [diff] [blame] | 1245 | /* Quirks that need to be set based on detected module */ |
| 1246 | SYSC_QUIRK("hdq1w", 0, 0, 0x14, 0x18, 0x00000006, 0xffffffff, |
| 1247 | SYSC_MODULE_QUIRK_HDQ1W), |
| 1248 | SYSC_QUIRK("hdq1w", 0, 0, 0x14, 0x18, 0x0000000a, 0xffffffff, |
| 1249 | SYSC_MODULE_QUIRK_HDQ1W), |
| 1250 | SYSC_QUIRK("i2c", 0, 0, 0x20, 0x10, 0x00000036, 0x000000ff, |
| 1251 | SYSC_MODULE_QUIRK_I2C), |
| 1252 | SYSC_QUIRK("i2c", 0, 0, 0x20, 0x10, 0x0000003c, 0x000000ff, |
| 1253 | SYSC_MODULE_QUIRK_I2C), |
| 1254 | SYSC_QUIRK("i2c", 0, 0, 0x20, 0x10, 0x00000040, 0x000000ff, |
| 1255 | SYSC_MODULE_QUIRK_I2C), |
| 1256 | SYSC_QUIRK("i2c", 0, 0, 0x10, 0x90, 0x5040000a, 0xfffff0f0, |
| 1257 | SYSC_MODULE_QUIRK_I2C), |
| 1258 | SYSC_QUIRK("wdt", 0, 0, 0x10, 0x14, 0x502a0500, 0xfffff0f0, |
| 1259 | SYSC_MODULE_QUIRK_WDT), |
| 1260 | |
Tony Lindgren | dc4c85e | 2018-04-16 10:26:25 -0700 | [diff] [blame] | 1261 | #ifdef DEBUG |
Tony Lindgren | 1ba3069 | 2018-09-24 12:17:05 -0700 | [diff] [blame] | 1262 | SYSC_QUIRK("adc", 0, 0, 0x10, -1, 0x47300001, 0xffffffff, 0), |
Tony Lindgren | c6eb4af | 2018-09-27 13:34:27 -0700 | [diff] [blame] | 1263 | SYSC_QUIRK("atl", 0, 0, -1, -1, 0x0a070100, 0xffffffff, 0), |
Tony Lindgren | dc4c85e | 2018-04-16 10:26:25 -0700 | [diff] [blame] | 1264 | SYSC_QUIRK("aess", 0, 0, 0x10, -1, 0x40000000, 0xffffffff, 0), |
Tony Lindgren | c6eb4af | 2018-09-27 13:34:27 -0700 | [diff] [blame] | 1265 | SYSC_QUIRK("cm", 0, 0, -1, -1, 0x40000301, 0xffffffff, 0), |
Tony Lindgren | 40d9f91 | 2018-09-24 12:16:54 -0700 | [diff] [blame] | 1266 | SYSC_QUIRK("control", 0, 0, 0x10, -1, 0x40000900, 0xffffffff, 0), |
Tony Lindgren | 1ba3069 | 2018-09-24 12:17:05 -0700 | [diff] [blame] | 1267 | SYSC_QUIRK("cpgmac", 0, 0x1200, 0x1208, 0x1204, 0x4edb1902, |
Tony Lindgren | 23731ea | 2018-09-24 12:17:09 -0700 | [diff] [blame] | 1268 | 0xffff00f0, 0), |
Tony Lindgren | 89bbc6f | 2019-07-22 03:44:42 -0700 | [diff] [blame] | 1269 | SYSC_QUIRK("dcan", 0, 0x20, -1, -1, 0xa3170504, 0xffffffff, 0), |
| 1270 | SYSC_QUIRK("dcan", 0, 0x20, -1, -1, 0x4edb1902, 0xffffffff, 0), |
Tony Lindgren | 13aad51 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1271 | SYSC_QUIRK("dmic", 0, 0, 0x10, -1, 0x50010000, 0xffffffff, 0), |
Tony Lindgren | 1ba3069 | 2018-09-24 12:17:05 -0700 | [diff] [blame] | 1272 | SYSC_QUIRK("dwc3", 0, 0, 0x10, -1, 0x500a0200, 0xffffffff, 0), |
| 1273 | SYSC_QUIRK("epwmss", 0, 0, 0x4, -1, 0x47400001, 0xffffffff, 0), |
Tony Lindgren | dc4c85e | 2018-04-16 10:26:25 -0700 | [diff] [blame] | 1274 | SYSC_QUIRK("gpu", 0, 0x1fc00, 0x1fc10, -1, 0, 0, 0), |
Tony Lindgren | dc4c85e | 2018-04-16 10:26:25 -0700 | [diff] [blame] | 1275 | SYSC_QUIRK("hsi", 0, 0, 0x10, 0x14, 0x50043101, 0xffffffff, 0), |
| 1276 | SYSC_QUIRK("iss", 0, 0, 0x10, -1, 0x40000101, 0xffffffff, 0), |
Tony Lindgren | 23731ea | 2018-09-24 12:17:09 -0700 | [diff] [blame] | 1277 | SYSC_QUIRK("lcdc", 0, 0, 0x54, -1, 0x4f201000, 0xffffffff, 0), |
Tony Lindgren | dc4c85e | 2018-04-16 10:26:25 -0700 | [diff] [blame] | 1278 | SYSC_QUIRK("mcasp", 0, 0, 0x4, -1, 0x44306302, 0xffffffff, 0), |
Tony Lindgren | 1ba3069 | 2018-09-24 12:17:05 -0700 | [diff] [blame] | 1279 | SYSC_QUIRK("mcasp", 0, 0, 0x4, -1, 0x44307b02, 0xffffffff, 0), |
Tony Lindgren | dc4c85e | 2018-04-16 10:26:25 -0700 | [diff] [blame] | 1280 | SYSC_QUIRK("mcbsp", 0, -1, 0x8c, -1, 0, 0, 0), |
Tony Lindgren | c6eb4af | 2018-09-27 13:34:27 -0700 | [diff] [blame] | 1281 | SYSC_QUIRK("mcspi", 0, 0, 0x10, -1, 0x40300a0b, 0xffff00ff, 0), |
Tony Lindgren | 1ba3069 | 2018-09-24 12:17:05 -0700 | [diff] [blame] | 1282 | SYSC_QUIRK("mcspi", 0, 0, 0x110, 0x114, 0x40300a0b, 0xffffffff, 0), |
Tony Lindgren | dc4c85e | 2018-04-16 10:26:25 -0700 | [diff] [blame] | 1283 | SYSC_QUIRK("mailbox", 0, 0, 0x10, -1, 0x00000400, 0xffffffff, 0), |
Tony Lindgren | 1ba3069 | 2018-09-24 12:17:05 -0700 | [diff] [blame] | 1284 | SYSC_QUIRK("m3", 0, 0, -1, -1, 0x5f580105, 0x0fff0f00, 0), |
Tony Lindgren | c6eb4af | 2018-09-27 13:34:27 -0700 | [diff] [blame] | 1285 | SYSC_QUIRK("ocp2scp", 0, 0, 0x10, 0x14, 0x50060005, 0xfffffff0, 0), |
Tony Lindgren | 1ba3069 | 2018-09-24 12:17:05 -0700 | [diff] [blame] | 1286 | SYSC_QUIRK("ocp2scp", 0, 0, -1, -1, 0x50060007, 0xffffffff, 0), |
Tony Lindgren | 40d9f91 | 2018-09-24 12:16:54 -0700 | [diff] [blame] | 1287 | SYSC_QUIRK("padconf", 0, 0, 0x10, -1, 0x4fff0800, 0xffffffff, 0), |
Tony Lindgren | f010670 | 2018-11-15 14:46:53 -0800 | [diff] [blame] | 1288 | SYSC_QUIRK("padconf", 0, 0, -1, -1, 0x40001100, 0xffffffff, 0), |
Tony Lindgren | 40d9f91 | 2018-09-24 12:16:54 -0700 | [diff] [blame] | 1289 | SYSC_QUIRK("prcm", 0, 0, -1, -1, 0x40000100, 0xffffffff, 0), |
Tony Lindgren | 23731ea | 2018-09-24 12:17:09 -0700 | [diff] [blame] | 1290 | SYSC_QUIRK("prcm", 0, 0, -1, -1, 0x00004102, 0xffffffff, 0), |
Tony Lindgren | 1ba3069 | 2018-09-24 12:17:05 -0700 | [diff] [blame] | 1291 | SYSC_QUIRK("prcm", 0, 0, -1, -1, 0x40000400, 0xffffffff, 0), |
Tony Lindgren | 40d9f91 | 2018-09-24 12:16:54 -0700 | [diff] [blame] | 1292 | SYSC_QUIRK("scm", 0, 0, 0x10, -1, 0x40000900, 0xffffffff, 0), |
Tony Lindgren | 23731ea | 2018-09-24 12:17:09 -0700 | [diff] [blame] | 1293 | SYSC_QUIRK("scm", 0, 0, -1, -1, 0x4e8b0100, 0xffffffff, 0), |
Tony Lindgren | 1ba3069 | 2018-09-24 12:17:05 -0700 | [diff] [blame] | 1294 | SYSC_QUIRK("scm", 0, 0, -1, -1, 0x4f000100, 0xffffffff, 0), |
Tony Lindgren | c6eb4af | 2018-09-27 13:34:27 -0700 | [diff] [blame] | 1295 | SYSC_QUIRK("scm", 0, 0, -1, -1, 0x40000900, 0xffffffff, 0), |
Tony Lindgren | 40d9f91 | 2018-09-24 12:16:54 -0700 | [diff] [blame] | 1296 | SYSC_QUIRK("scrm", 0, 0, -1, -1, 0x00000010, 0xffffffff, 0), |
Tony Lindgren | c6eb4af | 2018-09-27 13:34:27 -0700 | [diff] [blame] | 1297 | SYSC_QUIRK("sdio", 0, 0, 0x10, -1, 0x40202301, 0xffff0ff0, 0), |
Tony Lindgren | 1ba3069 | 2018-09-24 12:17:05 -0700 | [diff] [blame] | 1298 | SYSC_QUIRK("sdio", 0, 0x2fc, 0x110, 0x114, 0x31010000, 0xffffffff, 0), |
Tony Lindgren | 40d9f91 | 2018-09-24 12:16:54 -0700 | [diff] [blame] | 1299 | SYSC_QUIRK("sdma", 0, 0, 0x2c, 0x28, 0x00010900, 0xffffffff, 0), |
Tony Lindgren | dc4c85e | 2018-04-16 10:26:25 -0700 | [diff] [blame] | 1300 | SYSC_QUIRK("slimbus", 0, 0, 0x10, -1, 0x40000902, 0xffffffff, 0), |
| 1301 | SYSC_QUIRK("slimbus", 0, 0, 0x10, -1, 0x40002903, 0xffffffff, 0), |
| 1302 | SYSC_QUIRK("spinlock", 0, 0, 0x10, -1, 0x50020000, 0xffffffff, 0), |
Tony Lindgren | 1ba3069 | 2018-09-24 12:17:05 -0700 | [diff] [blame] | 1303 | SYSC_QUIRK("rng", 0, 0x1fe0, 0x1fe4, -1, 0x00000020, 0xffffffff, 0), |
Tony Lindgren | c6eb4af | 2018-09-27 13:34:27 -0700 | [diff] [blame] | 1304 | SYSC_QUIRK("rtc", 0, 0x74, 0x78, -1, 0x4eb01908, 0xffff00f0, 0), |
Tony Lindgren | 1ba3069 | 2018-09-24 12:17:05 -0700 | [diff] [blame] | 1305 | SYSC_QUIRK("timer32k", 0, 0, 0x4, -1, 0x00000060, 0xffffffff, 0), |
Tony Lindgren | dc4c85e | 2018-04-16 10:26:25 -0700 | [diff] [blame] | 1306 | SYSC_QUIRK("usbhstll", 0, 0, 0x10, 0x14, 0x00000004, 0xffffffff, 0), |
Tony Lindgren | f010670 | 2018-11-15 14:46:53 -0800 | [diff] [blame] | 1307 | SYSC_QUIRK("usbhstll", 0, 0, 0x10, 0x14, 0x00000008, 0xffffffff, 0), |
Tony Lindgren | dc4c85e | 2018-04-16 10:26:25 -0700 | [diff] [blame] | 1308 | SYSC_QUIRK("usb_host_hs", 0, 0, 0x10, 0x14, 0x50700100, 0xffffffff, 0), |
Tony Lindgren | f010670 | 2018-11-15 14:46:53 -0800 | [diff] [blame] | 1309 | SYSC_QUIRK("usb_host_hs", 0, 0, 0x10, -1, 0x50700101, 0xffffffff, 0), |
Tony Lindgren | dc4c85e | 2018-04-16 10:26:25 -0700 | [diff] [blame] | 1310 | SYSC_QUIRK("usb_otg_hs", 0, 0x400, 0x404, 0x408, 0x00000050, |
| 1311 | 0xffffffff, 0), |
Tony Lindgren | 1ba3069 | 2018-09-24 12:17:05 -0700 | [diff] [blame] | 1312 | SYSC_QUIRK("vfpe", 0, 0, 0x104, -1, 0x4d001200, 0xffffffff, 0), |
Tony Lindgren | dc4c85e | 2018-04-16 10:26:25 -0700 | [diff] [blame] | 1313 | #endif |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1314 | }; |
| 1315 | |
Tony Lindgren | 42b9c5c | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1316 | /* |
| 1317 | * Early quirks based on module base and register offsets only that are |
| 1318 | * needed before the module revision can be read |
| 1319 | */ |
| 1320 | static void sysc_init_early_quirks(struct sysc *ddata) |
| 1321 | { |
| 1322 | const struct sysc_revision_quirk *q; |
| 1323 | int i; |
| 1324 | |
| 1325 | for (i = 0; i < ARRAY_SIZE(sysc_revision_quirks); i++) { |
| 1326 | q = &sysc_revision_quirks[i]; |
| 1327 | |
| 1328 | if (!q->base) |
| 1329 | continue; |
| 1330 | |
| 1331 | if (q->base != ddata->module_pa) |
| 1332 | continue; |
| 1333 | |
| 1334 | if (q->rev_offset >= 0 && |
| 1335 | q->rev_offset != ddata->offsets[SYSC_REVISION]) |
| 1336 | continue; |
| 1337 | |
| 1338 | if (q->sysc_offset >= 0 && |
| 1339 | q->sysc_offset != ddata->offsets[SYSC_SYSCONFIG]) |
| 1340 | continue; |
| 1341 | |
| 1342 | if (q->syss_offset >= 0 && |
| 1343 | q->syss_offset != ddata->offsets[SYSC_SYSSTATUS]) |
| 1344 | continue; |
| 1345 | |
| 1346 | ddata->name = q->name; |
| 1347 | ddata->cfg.quirks |= q->quirks; |
| 1348 | } |
| 1349 | } |
| 1350 | |
| 1351 | /* Quirks that also consider the revision register value */ |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1352 | static void sysc_init_revision_quirks(struct sysc *ddata) |
| 1353 | { |
| 1354 | const struct sysc_revision_quirk *q; |
| 1355 | int i; |
| 1356 | |
| 1357 | for (i = 0; i < ARRAY_SIZE(sysc_revision_quirks); i++) { |
| 1358 | q = &sysc_revision_quirks[i]; |
| 1359 | |
| 1360 | if (q->base && q->base != ddata->module_pa) |
| 1361 | continue; |
| 1362 | |
| 1363 | if (q->rev_offset >= 0 && |
| 1364 | q->rev_offset != ddata->offsets[SYSC_REVISION]) |
| 1365 | continue; |
| 1366 | |
| 1367 | if (q->sysc_offset >= 0 && |
| 1368 | q->sysc_offset != ddata->offsets[SYSC_SYSCONFIG]) |
| 1369 | continue; |
| 1370 | |
| 1371 | if (q->syss_offset >= 0 && |
| 1372 | q->syss_offset != ddata->offsets[SYSC_SYSSTATUS]) |
| 1373 | continue; |
| 1374 | |
| 1375 | if (q->revision == ddata->revision || |
| 1376 | (q->revision & q->revision_mask) == |
| 1377 | (ddata->revision & q->revision_mask)) { |
| 1378 | ddata->name = q->name; |
| 1379 | ddata->cfg.quirks |= q->quirks; |
| 1380 | } |
| 1381 | } |
| 1382 | } |
| 1383 | |
Tony Lindgren | 4e23be4 | 2019-06-10 04:48:05 -0700 | [diff] [blame] | 1384 | /* 1-wire needs module's internal clocks enabled for reset */ |
| 1385 | static void sysc_clk_enable_quirk_hdq1w(struct sysc *ddata) |
| 1386 | { |
| 1387 | int offset = 0x0c; /* HDQ_CTRL_STATUS */ |
| 1388 | u16 val; |
| 1389 | |
| 1390 | val = sysc_read(ddata, offset); |
| 1391 | val |= BIT(5); |
| 1392 | sysc_write(ddata, offset, val); |
| 1393 | } |
| 1394 | |
| 1395 | /* I2C needs extra enable bit toggling for reset */ |
| 1396 | static void sysc_clk_quirk_i2c(struct sysc *ddata, bool enable) |
| 1397 | { |
| 1398 | int offset; |
| 1399 | u16 val; |
| 1400 | |
| 1401 | /* I2C_CON, omap2/3 is different from omap4 and later */ |
| 1402 | if ((ddata->revision & 0xffffff00) == 0x001f0000) |
| 1403 | offset = 0x24; |
| 1404 | else |
| 1405 | offset = 0xa4; |
| 1406 | |
| 1407 | /* I2C_EN */ |
| 1408 | val = sysc_read(ddata, offset); |
| 1409 | if (enable) |
| 1410 | val |= BIT(15); |
| 1411 | else |
| 1412 | val &= ~BIT(15); |
| 1413 | sysc_write(ddata, offset, val); |
| 1414 | } |
| 1415 | |
| 1416 | static void sysc_clk_enable_quirk_i2c(struct sysc *ddata) |
| 1417 | { |
| 1418 | sysc_clk_quirk_i2c(ddata, true); |
| 1419 | } |
| 1420 | |
| 1421 | static void sysc_clk_disable_quirk_i2c(struct sysc *ddata) |
| 1422 | { |
| 1423 | sysc_clk_quirk_i2c(ddata, false); |
| 1424 | } |
| 1425 | |
| 1426 | /* Watchdog timer needs a disable sequence after reset */ |
| 1427 | static void sysc_reset_done_quirk_wdt(struct sysc *ddata) |
| 1428 | { |
| 1429 | int wps, spr, error; |
| 1430 | u32 val; |
| 1431 | |
| 1432 | wps = 0x34; |
| 1433 | spr = 0x48; |
| 1434 | |
| 1435 | sysc_write(ddata, spr, 0xaaaa); |
| 1436 | error = readl_poll_timeout(ddata->module_va + wps, val, |
| 1437 | !(val & 0x10), 100, |
| 1438 | MAX_MODULE_SOFTRESET_WAIT); |
| 1439 | if (error) |
| 1440 | dev_warn(ddata->dev, "wdt disable spr failed\n"); |
| 1441 | |
| 1442 | sysc_write(ddata, wps, 0x5555); |
| 1443 | error = readl_poll_timeout(ddata->module_va + wps, val, |
| 1444 | !(val & 0x10), 100, |
| 1445 | MAX_MODULE_SOFTRESET_WAIT); |
| 1446 | if (error) |
| 1447 | dev_warn(ddata->dev, "wdt disable wps failed\n"); |
| 1448 | } |
| 1449 | |
| 1450 | static void sysc_init_module_quirks(struct sysc *ddata) |
| 1451 | { |
| 1452 | if (ddata->legacy_mode || !ddata->name) |
| 1453 | return; |
| 1454 | |
| 1455 | if (ddata->cfg.quirks & SYSC_MODULE_QUIRK_HDQ1W) { |
| 1456 | ddata->clk_enable_quirk = sysc_clk_enable_quirk_hdq1w; |
| 1457 | |
| 1458 | return; |
| 1459 | } |
| 1460 | |
| 1461 | if (ddata->cfg.quirks & SYSC_MODULE_QUIRK_I2C) { |
| 1462 | ddata->clk_enable_quirk = sysc_clk_enable_quirk_i2c; |
| 1463 | ddata->clk_disable_quirk = sysc_clk_disable_quirk_i2c; |
| 1464 | |
| 1465 | return; |
| 1466 | } |
| 1467 | |
| 1468 | if (ddata->cfg.quirks & SYSC_MODULE_QUIRK_WDT) |
| 1469 | ddata->reset_done_quirk = sysc_reset_done_quirk_wdt; |
| 1470 | } |
| 1471 | |
Tony Lindgren | 2b2f7de | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 1472 | static int sysc_clockdomain_init(struct sysc *ddata) |
| 1473 | { |
| 1474 | struct ti_sysc_platform_data *pdata = dev_get_platdata(ddata->dev); |
| 1475 | struct clk *fck = NULL, *ick = NULL; |
| 1476 | int error; |
| 1477 | |
| 1478 | if (!pdata || !pdata->init_clockdomain) |
| 1479 | return 0; |
| 1480 | |
| 1481 | switch (ddata->nr_clocks) { |
| 1482 | case 2: |
| 1483 | ick = ddata->clocks[SYSC_ICK]; |
| 1484 | /* fallthrough */ |
| 1485 | case 1: |
| 1486 | fck = ddata->clocks[SYSC_FCK]; |
| 1487 | break; |
| 1488 | case 0: |
| 1489 | return 0; |
| 1490 | } |
| 1491 | |
| 1492 | error = pdata->init_clockdomain(ddata->dev, fck, ick, &ddata->cookie); |
| 1493 | if (!error || error == -ENODEV) |
| 1494 | return 0; |
| 1495 | |
| 1496 | return error; |
| 1497 | } |
| 1498 | |
Tony Lindgren | a3e92e7 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1499 | /* |
| 1500 | * Note that pdata->init_module() typically does a reset first. After |
| 1501 | * pdata->init_module() is done, PM runtime can be used for the interconnect |
| 1502 | * target module. |
| 1503 | */ |
| 1504 | static int sysc_legacy_init(struct sysc *ddata) |
| 1505 | { |
| 1506 | struct ti_sysc_platform_data *pdata = dev_get_platdata(ddata->dev); |
| 1507 | int error; |
| 1508 | |
Tony Lindgren | 2b2f7de | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 1509 | if (!pdata || !pdata->init_module) |
Tony Lindgren | a3e92e7 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1510 | return 0; |
| 1511 | |
| 1512 | error = pdata->init_module(ddata->dev, ddata->mdata, &ddata->cookie); |
| 1513 | if (error == -EEXIST) |
| 1514 | error = 0; |
| 1515 | |
| 1516 | return error; |
| 1517 | } |
| 1518 | |
Tony Lindgren | b11c1ea | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1519 | /** |
| 1520 | * sysc_rstctrl_reset_deassert - deassert rstctrl reset |
| 1521 | * @ddata: device driver data |
| 1522 | * @reset: reset before deassert |
| 1523 | * |
| 1524 | * A module can have both OCP softreset control and external rstctrl. |
| 1525 | * If more complicated rstctrl resets are needed, please handle these |
| 1526 | * directly from the child device driver and map only the module reset |
| 1527 | * for the parent interconnect target module device. |
| 1528 | * |
| 1529 | * Automatic reset of the module on init can be skipped with the |
| 1530 | * "ti,no-reset-on-init" device tree property. |
| 1531 | */ |
| 1532 | static int sysc_rstctrl_reset_deassert(struct sysc *ddata, bool reset) |
| 1533 | { |
Tony Lindgren | ea5a2e4 | 2019-05-27 04:51:56 -0700 | [diff] [blame] | 1534 | int error, val; |
Tony Lindgren | b11c1ea | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1535 | |
| 1536 | if (!ddata->rsts) |
| 1537 | return 0; |
| 1538 | |
| 1539 | if (reset) { |
| 1540 | error = reset_control_assert(ddata->rsts); |
| 1541 | if (error) |
| 1542 | return error; |
| 1543 | } |
| 1544 | |
Tony Lindgren | ea5a2e4 | 2019-05-27 04:51:56 -0700 | [diff] [blame] | 1545 | error = reset_control_deassert(ddata->rsts); |
| 1546 | if (error == -EEXIST) |
| 1547 | return 0; |
| 1548 | |
| 1549 | error = readx_poll_timeout(reset_control_status, ddata->rsts, val, |
| 1550 | val == 0, 100, MAX_MODULE_SOFTRESET_WAIT); |
| 1551 | |
| 1552 | return error; |
Tony Lindgren | b11c1ea | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1553 | } |
| 1554 | |
Tony Lindgren | e0db94f | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 1555 | /* |
| 1556 | * Note that the caller must ensure the interconnect target module is enabled |
| 1557 | * before calling reset. Otherwise reset will not complete. |
| 1558 | */ |
Faiz Abbas | 596e795 | 2018-07-09 22:18:39 +0530 | [diff] [blame] | 1559 | static int sysc_reset(struct sysc *ddata) |
| 1560 | { |
Tony Lindgren | e0db94f | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 1561 | int sysc_offset, syss_offset, sysc_val, rstval, quirks, error = 0; |
| 1562 | u32 sysc_mask, syss_done; |
Faiz Abbas | 596e795 | 2018-07-09 22:18:39 +0530 | [diff] [blame] | 1563 | |
Tony Lindgren | e0db94f | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 1564 | sysc_offset = ddata->offsets[SYSC_SYSCONFIG]; |
| 1565 | syss_offset = ddata->offsets[SYSC_SYSSTATUS]; |
| 1566 | quirks = ddata->cfg.quirks; |
| 1567 | |
| 1568 | if (ddata->legacy_mode || sysc_offset < 0 || |
| 1569 | ddata->cap->regbits->srst_shift < 0 || |
Faiz Abbas | 596e795 | 2018-07-09 22:18:39 +0530 | [diff] [blame] | 1570 | ddata->cfg.quirks & SYSC_QUIRK_NO_RESET_ON_INIT) |
| 1571 | return 0; |
| 1572 | |
Tony Lindgren | e0db94f | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 1573 | sysc_mask = BIT(ddata->cap->regbits->srst_shift); |
Faiz Abbas | 596e795 | 2018-07-09 22:18:39 +0530 | [diff] [blame] | 1574 | |
Tony Lindgren | e0db94f | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 1575 | if (ddata->cfg.quirks & SYSS_QUIRK_RESETDONE_INVERTED) |
| 1576 | syss_done = 0; |
| 1577 | else |
| 1578 | syss_done = ddata->cfg.syss_mask; |
| 1579 | |
Tony Lindgren | 4e23be4 | 2019-06-10 04:48:05 -0700 | [diff] [blame] | 1580 | if (ddata->clk_disable_quirk) |
| 1581 | ddata->clk_disable_quirk(ddata); |
| 1582 | |
Tony Lindgren | e0db94f | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 1583 | sysc_val = sysc_read_sysconfig(ddata); |
| 1584 | sysc_val |= sysc_mask; |
| 1585 | sysc_write(ddata, sysc_offset, sysc_val); |
Faiz Abbas | 596e795 | 2018-07-09 22:18:39 +0530 | [diff] [blame] | 1586 | |
Tony Lindgren | 4e23be4 | 2019-06-10 04:48:05 -0700 | [diff] [blame] | 1587 | if (ddata->clk_enable_quirk) |
| 1588 | ddata->clk_enable_quirk(ddata); |
| 1589 | |
Faiz Abbas | 596e795 | 2018-07-09 22:18:39 +0530 | [diff] [blame] | 1590 | /* Poll on reset status */ |
Tony Lindgren | e0db94f | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 1591 | if (syss_offset >= 0) { |
| 1592 | error = readx_poll_timeout(sysc_read_sysstatus, ddata, rstval, |
| 1593 | (rstval & ddata->cfg.syss_mask) == |
| 1594 | syss_done, |
| 1595 | 100, MAX_MODULE_SOFTRESET_WAIT); |
Faiz Abbas | 596e795 | 2018-07-09 22:18:39 +0530 | [diff] [blame] | 1596 | |
Tony Lindgren | e0db94f | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 1597 | } else if (ddata->cfg.quirks & SYSC_QUIRK_RESET_STATUS) { |
| 1598 | error = readx_poll_timeout(sysc_read_sysconfig, ddata, rstval, |
| 1599 | !(rstval & sysc_mask), |
| 1600 | 100, MAX_MODULE_SOFTRESET_WAIT); |
| 1601 | } |
| 1602 | |
Tony Lindgren | 4e23be4 | 2019-06-10 04:48:05 -0700 | [diff] [blame] | 1603 | if (ddata->reset_done_quirk) |
| 1604 | ddata->reset_done_quirk(ddata); |
| 1605 | |
Tony Lindgren | e0db94f | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 1606 | return error; |
Faiz Abbas | 596e795 | 2018-07-09 22:18:39 +0530 | [diff] [blame] | 1607 | } |
| 1608 | |
Tony Lindgren | 1a5cd7c | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1609 | /* |
| 1610 | * At this point the module is configured enough to read the revision but |
| 1611 | * module may not be completely configured yet to use PM runtime. Enable |
| 1612 | * all clocks directly during init to configure the quirks needed for PM |
| 1613 | * runtime based on the revision register. |
| 1614 | */ |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 1615 | static int sysc_init_module(struct sysc *ddata) |
| 1616 | { |
Tony Lindgren | 1a5cd7c | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1617 | int error = 0; |
| 1618 | bool manage_clocks = true; |
Tony Lindgren | b11c1ea | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1619 | |
Tony Lindgren | ea5a2e4 | 2019-05-27 04:51:56 -0700 | [diff] [blame] | 1620 | error = sysc_rstctrl_reset_deassert(ddata, false); |
Tony Lindgren | b11c1ea | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1621 | if (error) |
| 1622 | return error; |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 1623 | |
Tony Lindgren | 386cb76 | 2019-03-22 07:49:30 -0700 | [diff] [blame] | 1624 | if (ddata->cfg.quirks & |
Tony Lindgren | 1a5cd7c | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1625 | (SYSC_QUIRK_NO_IDLE | SYSC_QUIRK_NO_IDLE_ON_INIT)) |
| 1626 | manage_clocks = false; |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1627 | |
Tony Lindgren | 2b2f7de | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 1628 | error = sysc_clockdomain_init(ddata); |
| 1629 | if (error) |
| 1630 | return error; |
| 1631 | |
Tony Lindgren | 1a5cd7c | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1632 | if (manage_clocks) { |
Tony Lindgren | 2b2f7de | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 1633 | sysc_clkdm_deny_idle(ddata); |
| 1634 | |
Tony Lindgren | 1a5cd7c | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1635 | error = sysc_enable_opt_clocks(ddata); |
| 1636 | if (error) |
| 1637 | return error; |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 1638 | |
Tony Lindgren | 1a5cd7c | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1639 | error = sysc_enable_main_clocks(ddata); |
| 1640 | if (error) |
| 1641 | goto err_opt_clocks; |
Faiz Abbas | 596e795 | 2018-07-09 22:18:39 +0530 | [diff] [blame] | 1642 | } |
| 1643 | |
Tony Lindgren | ea5a2e4 | 2019-05-27 04:51:56 -0700 | [diff] [blame] | 1644 | if (!(ddata->cfg.quirks & SYSC_QUIRK_NO_RESET_ON_INIT)) { |
| 1645 | error = sysc_rstctrl_reset_deassert(ddata, true); |
| 1646 | if (error) |
| 1647 | goto err_main_clocks; |
| 1648 | } |
| 1649 | |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 1650 | ddata->revision = sysc_read_revision(ddata); |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1651 | sysc_init_revision_quirks(ddata); |
Tony Lindgren | 4e23be4 | 2019-06-10 04:48:05 -0700 | [diff] [blame] | 1652 | sysc_init_module_quirks(ddata); |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1653 | |
Tony Lindgren | 2b2f7de | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 1654 | if (ddata->legacy_mode) { |
| 1655 | error = sysc_legacy_init(ddata); |
| 1656 | if (error) |
| 1657 | goto err_main_clocks; |
| 1658 | } |
| 1659 | |
| 1660 | if (!ddata->legacy_mode && manage_clocks) { |
| 1661 | error = sysc_enable_module(ddata->dev); |
| 1662 | if (error) |
| 1663 | goto err_main_clocks; |
| 1664 | } |
Tony Lindgren | a3e92e7 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1665 | |
Tony Lindgren | 1a5cd7c | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1666 | error = sysc_reset(ddata); |
| 1667 | if (error) |
| 1668 | dev_err(ddata->dev, "Reset failed with %d\n", error); |
| 1669 | |
Tony Lindgren | 2b2f7de | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 1670 | if (!ddata->legacy_mode && manage_clocks) |
| 1671 | sysc_disable_module(ddata->dev); |
| 1672 | |
Tony Lindgren | a3e92e7 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1673 | err_main_clocks: |
Tony Lindgren | 1a5cd7c | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1674 | if (manage_clocks) |
| 1675 | sysc_disable_main_clocks(ddata); |
| 1676 | err_opt_clocks: |
Tony Lindgren | 2b2f7de | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 1677 | if (manage_clocks) { |
Tony Lindgren | 1a5cd7c | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1678 | sysc_disable_opt_clocks(ddata); |
Tony Lindgren | 2b2f7de | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 1679 | sysc_clkdm_allow_idle(ddata); |
| 1680 | } |
Tony Lindgren | 1a5cd7c | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1681 | |
| 1682 | return error; |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 1683 | } |
| 1684 | |
Tony Lindgren | c5a2de9 | 2017-12-15 09:41:23 -0800 | [diff] [blame] | 1685 | static int sysc_init_sysc_mask(struct sysc *ddata) |
| 1686 | { |
| 1687 | struct device_node *np = ddata->dev->of_node; |
| 1688 | int error; |
| 1689 | u32 val; |
| 1690 | |
| 1691 | error = of_property_read_u32(np, "ti,sysc-mask", &val); |
| 1692 | if (error) |
| 1693 | return 0; |
| 1694 | |
Tony Lindgren | e212abd | 2019-07-22 03:44:52 -0700 | [diff] [blame] | 1695 | ddata->cfg.sysc_val = val & ddata->cap->sysc_mask; |
Tony Lindgren | c5a2de9 | 2017-12-15 09:41:23 -0800 | [diff] [blame] | 1696 | |
| 1697 | return 0; |
| 1698 | } |
| 1699 | |
| 1700 | static int sysc_init_idlemode(struct sysc *ddata, u8 *idlemodes, |
| 1701 | const char *name) |
| 1702 | { |
| 1703 | struct device_node *np = ddata->dev->of_node; |
| 1704 | struct property *prop; |
| 1705 | const __be32 *p; |
| 1706 | u32 val; |
| 1707 | |
| 1708 | of_property_for_each_u32(np, name, prop, p, val) { |
| 1709 | if (val >= SYSC_NR_IDLEMODES) { |
| 1710 | dev_err(ddata->dev, "invalid idlemode: %i\n", val); |
| 1711 | return -EINVAL; |
| 1712 | } |
| 1713 | *idlemodes |= (1 << val); |
| 1714 | } |
| 1715 | |
| 1716 | return 0; |
| 1717 | } |
| 1718 | |
| 1719 | static int sysc_init_idlemodes(struct sysc *ddata) |
| 1720 | { |
| 1721 | int error; |
| 1722 | |
| 1723 | error = sysc_init_idlemode(ddata, &ddata->cfg.midlemodes, |
| 1724 | "ti,sysc-midle"); |
| 1725 | if (error) |
| 1726 | return error; |
| 1727 | |
| 1728 | error = sysc_init_idlemode(ddata, &ddata->cfg.sidlemodes, |
| 1729 | "ti,sysc-sidle"); |
| 1730 | if (error) |
| 1731 | return error; |
| 1732 | |
| 1733 | return 0; |
| 1734 | } |
| 1735 | |
| 1736 | /* |
| 1737 | * Only some devices on omap4 and later have SYSCONFIG reset done |
| 1738 | * bit. We can detect this if there is no SYSSTATUS at all, or the |
| 1739 | * SYSTATUS bit 0 is not used. Note that some SYSSTATUS registers |
| 1740 | * have multiple bits for the child devices like OHCI and EHCI. |
| 1741 | * Depends on SYSC being parsed first. |
| 1742 | */ |
| 1743 | static int sysc_init_syss_mask(struct sysc *ddata) |
| 1744 | { |
| 1745 | struct device_node *np = ddata->dev->of_node; |
| 1746 | int error; |
| 1747 | u32 val; |
| 1748 | |
| 1749 | error = of_property_read_u32(np, "ti,syss-mask", &val); |
| 1750 | if (error) { |
| 1751 | if ((ddata->cap->type == TI_SYSC_OMAP4 || |
| 1752 | ddata->cap->type == TI_SYSC_OMAP4_TIMER) && |
| 1753 | (ddata->cfg.sysc_val & SYSC_OMAP4_SOFTRESET)) |
| 1754 | ddata->cfg.quirks |= SYSC_QUIRK_RESET_STATUS; |
| 1755 | |
| 1756 | return 0; |
| 1757 | } |
| 1758 | |
| 1759 | if (!(val & 1) && (ddata->cfg.sysc_val & SYSC_OMAP4_SOFTRESET)) |
| 1760 | ddata->cfg.quirks |= SYSC_QUIRK_RESET_STATUS; |
| 1761 | |
| 1762 | ddata->cfg.syss_mask = val; |
| 1763 | |
| 1764 | return 0; |
| 1765 | } |
| 1766 | |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 1767 | /* |
Tony Lindgren | 8b2830ba | 2018-04-16 10:26:09 -0700 | [diff] [blame] | 1768 | * Many child device drivers need to have fck and opt clocks available |
| 1769 | * to get the clock rate for device internal configuration etc. |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 1770 | */ |
Tony Lindgren | 8b2830ba | 2018-04-16 10:26:09 -0700 | [diff] [blame] | 1771 | static int sysc_child_add_named_clock(struct sysc *ddata, |
| 1772 | struct device *child, |
| 1773 | const char *name) |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 1774 | { |
Tony Lindgren | 8b2830ba | 2018-04-16 10:26:09 -0700 | [diff] [blame] | 1775 | struct clk *clk; |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 1776 | struct clk_lookup *l; |
Tony Lindgren | 8b2830ba | 2018-04-16 10:26:09 -0700 | [diff] [blame] | 1777 | int error = 0; |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 1778 | |
Tony Lindgren | 8b2830ba | 2018-04-16 10:26:09 -0700 | [diff] [blame] | 1779 | if (!name) |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 1780 | return 0; |
| 1781 | |
Tony Lindgren | 8b2830ba | 2018-04-16 10:26:09 -0700 | [diff] [blame] | 1782 | clk = clk_get(child, name); |
| 1783 | if (!IS_ERR(clk)) { |
| 1784 | clk_put(clk); |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 1785 | |
| 1786 | return -EEXIST; |
| 1787 | } |
| 1788 | |
Tony Lindgren | 8b2830ba | 2018-04-16 10:26:09 -0700 | [diff] [blame] | 1789 | clk = clk_get(ddata->dev, name); |
| 1790 | if (IS_ERR(clk)) |
| 1791 | return -ENODEV; |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 1792 | |
Tony Lindgren | 8b2830ba | 2018-04-16 10:26:09 -0700 | [diff] [blame] | 1793 | l = clkdev_create(clk, name, dev_name(child)); |
| 1794 | if (!l) |
| 1795 | error = -ENOMEM; |
| 1796 | |
| 1797 | clk_put(clk); |
| 1798 | |
| 1799 | return error; |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 1800 | } |
| 1801 | |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 1802 | static int sysc_child_add_clocks(struct sysc *ddata, |
| 1803 | struct device *child) |
| 1804 | { |
| 1805 | int i, error; |
| 1806 | |
| 1807 | for (i = 0; i < ddata->nr_clocks; i++) { |
| 1808 | error = sysc_child_add_named_clock(ddata, |
| 1809 | child, |
| 1810 | ddata->clock_roles[i]); |
| 1811 | if (error && error != -EEXIST) { |
| 1812 | dev_err(ddata->dev, "could not add child clock %s: %i\n", |
| 1813 | ddata->clock_roles[i], error); |
| 1814 | |
| 1815 | return error; |
| 1816 | } |
| 1817 | } |
| 1818 | |
| 1819 | return 0; |
| 1820 | } |
| 1821 | |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 1822 | static struct device_type sysc_device_type = { |
| 1823 | }; |
| 1824 | |
| 1825 | static struct sysc *sysc_child_to_parent(struct device *dev) |
| 1826 | { |
| 1827 | struct device *parent = dev->parent; |
| 1828 | |
| 1829 | if (!parent || parent->type != &sysc_device_type) |
| 1830 | return NULL; |
| 1831 | |
| 1832 | return dev_get_drvdata(parent); |
| 1833 | } |
| 1834 | |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1835 | static int __maybe_unused sysc_child_runtime_suspend(struct device *dev) |
| 1836 | { |
| 1837 | struct sysc *ddata; |
| 1838 | int error; |
| 1839 | |
| 1840 | ddata = sysc_child_to_parent(dev); |
| 1841 | |
| 1842 | error = pm_generic_runtime_suspend(dev); |
| 1843 | if (error) |
| 1844 | return error; |
| 1845 | |
| 1846 | if (!ddata->enabled) |
| 1847 | return 0; |
| 1848 | |
| 1849 | return sysc_runtime_suspend(ddata->dev); |
| 1850 | } |
| 1851 | |
| 1852 | static int __maybe_unused sysc_child_runtime_resume(struct device *dev) |
| 1853 | { |
| 1854 | struct sysc *ddata; |
| 1855 | int error; |
| 1856 | |
| 1857 | ddata = sysc_child_to_parent(dev); |
| 1858 | |
| 1859 | if (!ddata->enabled) { |
| 1860 | error = sysc_runtime_resume(ddata->dev); |
| 1861 | if (error < 0) |
| 1862 | dev_err(ddata->dev, |
| 1863 | "%s error: %i\n", __func__, error); |
| 1864 | } |
| 1865 | |
| 1866 | return pm_generic_runtime_resume(dev); |
| 1867 | } |
| 1868 | |
| 1869 | #ifdef CONFIG_PM_SLEEP |
| 1870 | static int sysc_child_suspend_noirq(struct device *dev) |
| 1871 | { |
| 1872 | struct sysc *ddata; |
| 1873 | int error; |
| 1874 | |
| 1875 | ddata = sysc_child_to_parent(dev); |
| 1876 | |
Tony Lindgren | ef55f82 | 2018-04-16 10:27:15 -0700 | [diff] [blame] | 1877 | dev_dbg(ddata->dev, "%s %s\n", __func__, |
| 1878 | ddata->name ? ddata->name : ""); |
| 1879 | |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1880 | error = pm_generic_suspend_noirq(dev); |
Tony Lindgren | ef55f82 | 2018-04-16 10:27:15 -0700 | [diff] [blame] | 1881 | if (error) { |
| 1882 | dev_err(dev, "%s error at %i: %i\n", |
| 1883 | __func__, __LINE__, error); |
| 1884 | |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1885 | return error; |
Tony Lindgren | ef55f82 | 2018-04-16 10:27:15 -0700 | [diff] [blame] | 1886 | } |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1887 | |
| 1888 | if (!pm_runtime_status_suspended(dev)) { |
| 1889 | error = pm_generic_runtime_suspend(dev); |
Tony Lindgren | ef55f82 | 2018-04-16 10:27:15 -0700 | [diff] [blame] | 1890 | if (error) { |
Tony Lindgren | f949078 | 2018-09-28 15:21:50 -0700 | [diff] [blame] | 1891 | dev_dbg(dev, "%s busy at %i: %i\n", |
| 1892 | __func__, __LINE__, error); |
Tony Lindgren | ef55f82 | 2018-04-16 10:27:15 -0700 | [diff] [blame] | 1893 | |
Tony Lindgren | 4f3530f | 2018-08-08 01:07:06 -0700 | [diff] [blame] | 1894 | return 0; |
Tony Lindgren | ef55f82 | 2018-04-16 10:27:15 -0700 | [diff] [blame] | 1895 | } |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1896 | |
| 1897 | error = sysc_runtime_suspend(ddata->dev); |
Tony Lindgren | ef55f82 | 2018-04-16 10:27:15 -0700 | [diff] [blame] | 1898 | if (error) { |
| 1899 | dev_err(dev, "%s error at %i: %i\n", |
| 1900 | __func__, __LINE__, error); |
| 1901 | |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1902 | return error; |
Tony Lindgren | ef55f82 | 2018-04-16 10:27:15 -0700 | [diff] [blame] | 1903 | } |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1904 | |
| 1905 | ddata->child_needs_resume = true; |
| 1906 | } |
| 1907 | |
| 1908 | return 0; |
| 1909 | } |
| 1910 | |
| 1911 | static int sysc_child_resume_noirq(struct device *dev) |
| 1912 | { |
| 1913 | struct sysc *ddata; |
| 1914 | int error; |
| 1915 | |
| 1916 | ddata = sysc_child_to_parent(dev); |
| 1917 | |
Tony Lindgren | ef55f82 | 2018-04-16 10:27:15 -0700 | [diff] [blame] | 1918 | dev_dbg(ddata->dev, "%s %s\n", __func__, |
| 1919 | ddata->name ? ddata->name : ""); |
| 1920 | |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1921 | if (ddata->child_needs_resume) { |
| 1922 | ddata->child_needs_resume = false; |
| 1923 | |
| 1924 | error = sysc_runtime_resume(ddata->dev); |
| 1925 | if (error) |
| 1926 | dev_err(ddata->dev, |
| 1927 | "%s runtime resume error: %i\n", |
| 1928 | __func__, error); |
| 1929 | |
| 1930 | error = pm_generic_runtime_resume(dev); |
| 1931 | if (error) |
| 1932 | dev_err(ddata->dev, |
| 1933 | "%s generic runtime resume: %i\n", |
| 1934 | __func__, error); |
| 1935 | } |
| 1936 | |
| 1937 | return pm_generic_resume_noirq(dev); |
| 1938 | } |
| 1939 | #endif |
| 1940 | |
Tony Lindgren | b7182b4 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 1941 | static struct dev_pm_domain sysc_child_pm_domain = { |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1942 | .ops = { |
| 1943 | SET_RUNTIME_PM_OPS(sysc_child_runtime_suspend, |
| 1944 | sysc_child_runtime_resume, |
| 1945 | NULL) |
| 1946 | USE_PLATFORM_PM_SLEEP_OPS |
| 1947 | SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(sysc_child_suspend_noirq, |
| 1948 | sysc_child_resume_noirq) |
| 1949 | } |
| 1950 | }; |
| 1951 | |
| 1952 | /** |
| 1953 | * sysc_legacy_idle_quirk - handle children in omap_device compatible way |
| 1954 | * @ddata: device driver data |
| 1955 | * @child: child device driver |
| 1956 | * |
| 1957 | * Allow idle for child devices as done with _od_runtime_suspend(). |
| 1958 | * Otherwise many child devices will not idle because of the permanent |
| 1959 | * parent usecount set in pm_runtime_irq_safe(). |
| 1960 | * |
| 1961 | * Note that the long term solution is to just modify the child device |
| 1962 | * drivers to not set pm_runtime_irq_safe() and then this can be just |
| 1963 | * dropped. |
| 1964 | */ |
| 1965 | static void sysc_legacy_idle_quirk(struct sysc *ddata, struct device *child) |
| 1966 | { |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1967 | if (ddata->cfg.quirks & SYSC_QUIRK_LEGACY_IDLE) |
| 1968 | dev_pm_domain_set(child, &sysc_child_pm_domain); |
| 1969 | } |
| 1970 | |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 1971 | static int sysc_notifier_call(struct notifier_block *nb, |
| 1972 | unsigned long event, void *device) |
| 1973 | { |
| 1974 | struct device *dev = device; |
| 1975 | struct sysc *ddata; |
| 1976 | int error; |
| 1977 | |
| 1978 | ddata = sysc_child_to_parent(dev); |
| 1979 | if (!ddata) |
| 1980 | return NOTIFY_DONE; |
| 1981 | |
| 1982 | switch (event) { |
| 1983 | case BUS_NOTIFY_ADD_DEVICE: |
Tony Lindgren | 09dfe58 | 2018-04-16 10:25:52 -0700 | [diff] [blame] | 1984 | error = sysc_child_add_clocks(ddata, dev); |
| 1985 | if (error) |
| 1986 | return error; |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 1987 | sysc_legacy_idle_quirk(ddata, dev); |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 1988 | break; |
| 1989 | default: |
| 1990 | break; |
| 1991 | } |
| 1992 | |
| 1993 | return NOTIFY_DONE; |
| 1994 | } |
| 1995 | |
| 1996 | static struct notifier_block sysc_nb = { |
| 1997 | .notifier_call = sysc_notifier_call, |
| 1998 | }; |
| 1999 | |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 2000 | /* Device tree configured quirks */ |
| 2001 | struct sysc_dts_quirk { |
| 2002 | const char *name; |
| 2003 | u32 mask; |
| 2004 | }; |
| 2005 | |
| 2006 | static const struct sysc_dts_quirk sysc_dts_quirks[] = { |
| 2007 | { .name = "ti,no-idle-on-init", |
| 2008 | .mask = SYSC_QUIRK_NO_IDLE_ON_INIT, }, |
| 2009 | { .name = "ti,no-reset-on-init", |
| 2010 | .mask = SYSC_QUIRK_NO_RESET_ON_INIT, }, |
Tony Lindgren | 386cb76 | 2019-03-22 07:49:30 -0700 | [diff] [blame] | 2011 | { .name = "ti,no-idle", |
| 2012 | .mask = SYSC_QUIRK_NO_IDLE, }, |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 2013 | }; |
| 2014 | |
Tony Lindgren | 4014c08 | 2018-12-10 14:11:26 -0800 | [diff] [blame] | 2015 | static void sysc_parse_dts_quirks(struct sysc *ddata, struct device_node *np, |
| 2016 | bool is_child) |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 2017 | { |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 2018 | const struct property *prop; |
Tony Lindgren | 4014c08 | 2018-12-10 14:11:26 -0800 | [diff] [blame] | 2019 | int i, len; |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 2020 | |
| 2021 | for (i = 0; i < ARRAY_SIZE(sysc_dts_quirks); i++) { |
Tony Lindgren | 4014c08 | 2018-12-10 14:11:26 -0800 | [diff] [blame] | 2022 | const char *name = sysc_dts_quirks[i].name; |
| 2023 | |
| 2024 | prop = of_get_property(np, name, &len); |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 2025 | if (!prop) |
Tony Lindgren | d39b6ea | 2018-02-15 09:18:55 -0800 | [diff] [blame] | 2026 | continue; |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 2027 | |
| 2028 | ddata->cfg.quirks |= sysc_dts_quirks[i].mask; |
Tony Lindgren | 4014c08 | 2018-12-10 14:11:26 -0800 | [diff] [blame] | 2029 | if (is_child) { |
| 2030 | dev_warn(ddata->dev, |
| 2031 | "dts flag should be at module level for %s\n", |
| 2032 | name); |
| 2033 | } |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 2034 | } |
Tony Lindgren | 4014c08 | 2018-12-10 14:11:26 -0800 | [diff] [blame] | 2035 | } |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 2036 | |
Tony Lindgren | 4014c08 | 2018-12-10 14:11:26 -0800 | [diff] [blame] | 2037 | static int sysc_init_dts_quirks(struct sysc *ddata) |
| 2038 | { |
| 2039 | struct device_node *np = ddata->dev->of_node; |
| 2040 | int error; |
| 2041 | u32 val; |
| 2042 | |
| 2043 | ddata->legacy_mode = of_get_property(np, "ti,hwmods", NULL); |
| 2044 | |
| 2045 | sysc_parse_dts_quirks(ddata, np, false); |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 2046 | error = of_property_read_u32(np, "ti,sysc-delay-us", &val); |
| 2047 | if (!error) { |
| 2048 | if (val > 255) { |
| 2049 | dev_warn(ddata->dev, "bad ti,sysc-delay-us: %i\n", |
| 2050 | val); |
| 2051 | } |
| 2052 | |
| 2053 | ddata->cfg.srst_udelay = (u8)val; |
| 2054 | } |
| 2055 | |
| 2056 | return 0; |
| 2057 | } |
| 2058 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 2059 | static void sysc_unprepare(struct sysc *ddata) |
| 2060 | { |
| 2061 | int i; |
| 2062 | |
Tony Lindgren | aaa29bb | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 2063 | if (!ddata->clocks) |
| 2064 | return; |
| 2065 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 2066 | for (i = 0; i < SYSC_MAX_CLOCKS; i++) { |
| 2067 | if (!IS_ERR_OR_NULL(ddata->clocks[i])) |
| 2068 | clk_unprepare(ddata->clocks[i]); |
| 2069 | } |
| 2070 | } |
| 2071 | |
Tony Lindgren | 70a6524 | 2017-12-15 09:41:09 -0800 | [diff] [blame] | 2072 | /* |
| 2073 | * Common sysc register bits found on omap2, also known as type1 |
| 2074 | */ |
| 2075 | static const struct sysc_regbits sysc_regbits_omap2 = { |
| 2076 | .dmadisable_shift = -ENODEV, |
| 2077 | .midle_shift = 12, |
| 2078 | .sidle_shift = 3, |
| 2079 | .clkact_shift = 8, |
| 2080 | .emufree_shift = 5, |
| 2081 | .enwkup_shift = 2, |
| 2082 | .srst_shift = 1, |
| 2083 | .autoidle_shift = 0, |
| 2084 | }; |
| 2085 | |
| 2086 | static const struct sysc_capabilities sysc_omap2 = { |
| 2087 | .type = TI_SYSC_OMAP2, |
| 2088 | .sysc_mask = SYSC_OMAP2_CLOCKACTIVITY | SYSC_OMAP2_EMUFREE | |
| 2089 | SYSC_OMAP2_ENAWAKEUP | SYSC_OMAP2_SOFTRESET | |
| 2090 | SYSC_OMAP2_AUTOIDLE, |
| 2091 | .regbits = &sysc_regbits_omap2, |
| 2092 | }; |
| 2093 | |
| 2094 | /* All omap2 and 3 timers, and timers 1, 2 & 10 on omap 4 and 5 */ |
| 2095 | static const struct sysc_capabilities sysc_omap2_timer = { |
| 2096 | .type = TI_SYSC_OMAP2_TIMER, |
| 2097 | .sysc_mask = SYSC_OMAP2_CLOCKACTIVITY | SYSC_OMAP2_EMUFREE | |
| 2098 | SYSC_OMAP2_ENAWAKEUP | SYSC_OMAP2_SOFTRESET | |
| 2099 | SYSC_OMAP2_AUTOIDLE, |
| 2100 | .regbits = &sysc_regbits_omap2, |
| 2101 | .mod_quirks = SYSC_QUIRK_USE_CLOCKACT, |
| 2102 | }; |
| 2103 | |
| 2104 | /* |
| 2105 | * SHAM2 (SHA1/MD5) sysc found on omap3, a variant of sysc_regbits_omap2 |
| 2106 | * with different sidle position |
| 2107 | */ |
| 2108 | static const struct sysc_regbits sysc_regbits_omap3_sham = { |
| 2109 | .dmadisable_shift = -ENODEV, |
| 2110 | .midle_shift = -ENODEV, |
| 2111 | .sidle_shift = 4, |
| 2112 | .clkact_shift = -ENODEV, |
| 2113 | .enwkup_shift = -ENODEV, |
| 2114 | .srst_shift = 1, |
| 2115 | .autoidle_shift = 0, |
| 2116 | .emufree_shift = -ENODEV, |
| 2117 | }; |
| 2118 | |
| 2119 | static const struct sysc_capabilities sysc_omap3_sham = { |
| 2120 | .type = TI_SYSC_OMAP3_SHAM, |
| 2121 | .sysc_mask = SYSC_OMAP2_SOFTRESET | SYSC_OMAP2_AUTOIDLE, |
| 2122 | .regbits = &sysc_regbits_omap3_sham, |
| 2123 | }; |
| 2124 | |
| 2125 | /* |
| 2126 | * AES register bits found on omap3 and later, a variant of |
| 2127 | * sysc_regbits_omap2 with different sidle position |
| 2128 | */ |
| 2129 | static const struct sysc_regbits sysc_regbits_omap3_aes = { |
| 2130 | .dmadisable_shift = -ENODEV, |
| 2131 | .midle_shift = -ENODEV, |
| 2132 | .sidle_shift = 6, |
| 2133 | .clkact_shift = -ENODEV, |
| 2134 | .enwkup_shift = -ENODEV, |
| 2135 | .srst_shift = 1, |
| 2136 | .autoidle_shift = 0, |
| 2137 | .emufree_shift = -ENODEV, |
| 2138 | }; |
| 2139 | |
| 2140 | static const struct sysc_capabilities sysc_omap3_aes = { |
| 2141 | .type = TI_SYSC_OMAP3_AES, |
| 2142 | .sysc_mask = SYSC_OMAP2_SOFTRESET | SYSC_OMAP2_AUTOIDLE, |
| 2143 | .regbits = &sysc_regbits_omap3_aes, |
| 2144 | }; |
| 2145 | |
| 2146 | /* |
| 2147 | * Common sysc register bits found on omap4, also known as type2 |
| 2148 | */ |
| 2149 | static const struct sysc_regbits sysc_regbits_omap4 = { |
| 2150 | .dmadisable_shift = 16, |
| 2151 | .midle_shift = 4, |
| 2152 | .sidle_shift = 2, |
| 2153 | .clkact_shift = -ENODEV, |
| 2154 | .enwkup_shift = -ENODEV, |
| 2155 | .emufree_shift = 1, |
| 2156 | .srst_shift = 0, |
| 2157 | .autoidle_shift = -ENODEV, |
| 2158 | }; |
| 2159 | |
| 2160 | static const struct sysc_capabilities sysc_omap4 = { |
| 2161 | .type = TI_SYSC_OMAP4, |
| 2162 | .sysc_mask = SYSC_OMAP4_DMADISABLE | SYSC_OMAP4_FREEEMU | |
| 2163 | SYSC_OMAP4_SOFTRESET, |
| 2164 | .regbits = &sysc_regbits_omap4, |
| 2165 | }; |
| 2166 | |
| 2167 | static const struct sysc_capabilities sysc_omap4_timer = { |
| 2168 | .type = TI_SYSC_OMAP4_TIMER, |
| 2169 | .sysc_mask = SYSC_OMAP4_DMADISABLE | SYSC_OMAP4_FREEEMU | |
| 2170 | SYSC_OMAP4_SOFTRESET, |
| 2171 | .regbits = &sysc_regbits_omap4, |
| 2172 | }; |
| 2173 | |
| 2174 | /* |
| 2175 | * Common sysc register bits found on omap4, also known as type3 |
| 2176 | */ |
| 2177 | static const struct sysc_regbits sysc_regbits_omap4_simple = { |
| 2178 | .dmadisable_shift = -ENODEV, |
| 2179 | .midle_shift = 2, |
| 2180 | .sidle_shift = 0, |
| 2181 | .clkact_shift = -ENODEV, |
| 2182 | .enwkup_shift = -ENODEV, |
| 2183 | .srst_shift = -ENODEV, |
| 2184 | .emufree_shift = -ENODEV, |
| 2185 | .autoidle_shift = -ENODEV, |
| 2186 | }; |
| 2187 | |
| 2188 | static const struct sysc_capabilities sysc_omap4_simple = { |
| 2189 | .type = TI_SYSC_OMAP4_SIMPLE, |
| 2190 | .regbits = &sysc_regbits_omap4_simple, |
| 2191 | }; |
| 2192 | |
| 2193 | /* |
| 2194 | * SmartReflex sysc found on omap34xx |
| 2195 | */ |
| 2196 | static const struct sysc_regbits sysc_regbits_omap34xx_sr = { |
| 2197 | .dmadisable_shift = -ENODEV, |
| 2198 | .midle_shift = -ENODEV, |
| 2199 | .sidle_shift = -ENODEV, |
| 2200 | .clkact_shift = 20, |
| 2201 | .enwkup_shift = -ENODEV, |
| 2202 | .srst_shift = -ENODEV, |
| 2203 | .emufree_shift = -ENODEV, |
| 2204 | .autoidle_shift = -ENODEV, |
| 2205 | }; |
| 2206 | |
| 2207 | static const struct sysc_capabilities sysc_34xx_sr = { |
| 2208 | .type = TI_SYSC_OMAP34XX_SR, |
| 2209 | .sysc_mask = SYSC_OMAP2_CLOCKACTIVITY, |
| 2210 | .regbits = &sysc_regbits_omap34xx_sr, |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 2211 | .mod_quirks = SYSC_QUIRK_USE_CLOCKACT | SYSC_QUIRK_UNCACHED | |
| 2212 | SYSC_QUIRK_LEGACY_IDLE, |
Tony Lindgren | 70a6524 | 2017-12-15 09:41:09 -0800 | [diff] [blame] | 2213 | }; |
| 2214 | |
| 2215 | /* |
| 2216 | * SmartReflex sysc found on omap36xx and later |
| 2217 | */ |
| 2218 | static const struct sysc_regbits sysc_regbits_omap36xx_sr = { |
| 2219 | .dmadisable_shift = -ENODEV, |
| 2220 | .midle_shift = -ENODEV, |
| 2221 | .sidle_shift = 24, |
| 2222 | .clkact_shift = -ENODEV, |
| 2223 | .enwkup_shift = 26, |
| 2224 | .srst_shift = -ENODEV, |
| 2225 | .emufree_shift = -ENODEV, |
| 2226 | .autoidle_shift = -ENODEV, |
| 2227 | }; |
| 2228 | |
| 2229 | static const struct sysc_capabilities sysc_36xx_sr = { |
| 2230 | .type = TI_SYSC_OMAP36XX_SR, |
Tony Lindgren | 3267c08 | 2018-01-22 09:32:53 -0800 | [diff] [blame] | 2231 | .sysc_mask = SYSC_OMAP3_SR_ENAWAKEUP, |
Tony Lindgren | 70a6524 | 2017-12-15 09:41:09 -0800 | [diff] [blame] | 2232 | .regbits = &sysc_regbits_omap36xx_sr, |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 2233 | .mod_quirks = SYSC_QUIRK_UNCACHED | SYSC_QUIRK_LEGACY_IDLE, |
Tony Lindgren | 70a6524 | 2017-12-15 09:41:09 -0800 | [diff] [blame] | 2234 | }; |
| 2235 | |
| 2236 | static const struct sysc_capabilities sysc_omap4_sr = { |
| 2237 | .type = TI_SYSC_OMAP4_SR, |
| 2238 | .regbits = &sysc_regbits_omap36xx_sr, |
Tony Lindgren | a885f0f | 2018-02-22 14:03:48 -0800 | [diff] [blame] | 2239 | .mod_quirks = SYSC_QUIRK_LEGACY_IDLE, |
Tony Lindgren | 70a6524 | 2017-12-15 09:41:09 -0800 | [diff] [blame] | 2240 | }; |
| 2241 | |
| 2242 | /* |
| 2243 | * McASP register bits found on omap4 and later |
| 2244 | */ |
| 2245 | static const struct sysc_regbits sysc_regbits_omap4_mcasp = { |
| 2246 | .dmadisable_shift = -ENODEV, |
| 2247 | .midle_shift = -ENODEV, |
| 2248 | .sidle_shift = 0, |
| 2249 | .clkact_shift = -ENODEV, |
| 2250 | .enwkup_shift = -ENODEV, |
| 2251 | .srst_shift = -ENODEV, |
| 2252 | .emufree_shift = -ENODEV, |
| 2253 | .autoidle_shift = -ENODEV, |
| 2254 | }; |
| 2255 | |
| 2256 | static const struct sysc_capabilities sysc_omap4_mcasp = { |
| 2257 | .type = TI_SYSC_OMAP4_MCASP, |
| 2258 | .regbits = &sysc_regbits_omap4_mcasp, |
Tony Lindgren | 2c63a83 | 2018-11-15 14:46:53 -0800 | [diff] [blame] | 2259 | .mod_quirks = SYSC_QUIRK_OPT_CLKS_NEEDED, |
| 2260 | }; |
| 2261 | |
| 2262 | /* |
| 2263 | * McASP found on dra7 and later |
| 2264 | */ |
| 2265 | static const struct sysc_capabilities sysc_dra7_mcasp = { |
| 2266 | .type = TI_SYSC_OMAP4_SIMPLE, |
| 2267 | .regbits = &sysc_regbits_omap4_simple, |
| 2268 | .mod_quirks = SYSC_QUIRK_OPT_CLKS_NEEDED, |
Tony Lindgren | 70a6524 | 2017-12-15 09:41:09 -0800 | [diff] [blame] | 2269 | }; |
| 2270 | |
| 2271 | /* |
| 2272 | * FS USB host found on omap4 and later |
| 2273 | */ |
| 2274 | static const struct sysc_regbits sysc_regbits_omap4_usb_host_fs = { |
| 2275 | .dmadisable_shift = -ENODEV, |
| 2276 | .midle_shift = -ENODEV, |
| 2277 | .sidle_shift = 24, |
| 2278 | .clkact_shift = -ENODEV, |
| 2279 | .enwkup_shift = 26, |
| 2280 | .srst_shift = -ENODEV, |
| 2281 | .emufree_shift = -ENODEV, |
| 2282 | .autoidle_shift = -ENODEV, |
| 2283 | }; |
| 2284 | |
| 2285 | static const struct sysc_capabilities sysc_omap4_usb_host_fs = { |
| 2286 | .type = TI_SYSC_OMAP4_USB_HOST_FS, |
| 2287 | .sysc_mask = SYSC_OMAP2_ENAWAKEUP, |
| 2288 | .regbits = &sysc_regbits_omap4_usb_host_fs, |
| 2289 | }; |
| 2290 | |
Faiz Abbas | 7f35e63 | 2018-07-09 22:18:38 +0530 | [diff] [blame] | 2291 | static const struct sysc_regbits sysc_regbits_dra7_mcan = { |
| 2292 | .dmadisable_shift = -ENODEV, |
| 2293 | .midle_shift = -ENODEV, |
| 2294 | .sidle_shift = -ENODEV, |
| 2295 | .clkact_shift = -ENODEV, |
| 2296 | .enwkup_shift = 4, |
| 2297 | .srst_shift = 0, |
| 2298 | .emufree_shift = -ENODEV, |
| 2299 | .autoidle_shift = -ENODEV, |
| 2300 | }; |
| 2301 | |
| 2302 | static const struct sysc_capabilities sysc_dra7_mcan = { |
| 2303 | .type = TI_SYSC_DRA7_MCAN, |
| 2304 | .sysc_mask = SYSC_DRA7_MCAN_ENAWAKEUP | SYSC_OMAP4_SOFTRESET, |
| 2305 | .regbits = &sysc_regbits_dra7_mcan, |
Tony Lindgren | e0db94f | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 2306 | .mod_quirks = SYSS_QUIRK_RESETDONE_INVERTED, |
Faiz Abbas | 7f35e63 | 2018-07-09 22:18:38 +0530 | [diff] [blame] | 2307 | }; |
| 2308 | |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 2309 | static int sysc_init_pdata(struct sysc *ddata) |
| 2310 | { |
| 2311 | struct ti_sysc_platform_data *pdata = dev_get_platdata(ddata->dev); |
Tony Lindgren | a3e92e7 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 2312 | struct ti_sysc_module_data *mdata; |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 2313 | |
Tony Lindgren | 2b2f7de | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 2314 | if (!pdata) |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 2315 | return 0; |
| 2316 | |
Tony Lindgren | a3e92e7 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 2317 | mdata = devm_kzalloc(ddata->dev, sizeof(*mdata), GFP_KERNEL); |
| 2318 | if (!mdata) |
| 2319 | return -ENOMEM; |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 2320 | |
Tony Lindgren | 2b2f7de | 2019-05-27 04:51:53 -0700 | [diff] [blame] | 2321 | if (ddata->legacy_mode) { |
| 2322 | mdata->name = ddata->legacy_mode; |
| 2323 | mdata->module_pa = ddata->module_pa; |
| 2324 | mdata->module_size = ddata->module_size; |
| 2325 | mdata->offsets = ddata->offsets; |
| 2326 | mdata->nr_offsets = SYSC_MAX_REGS; |
| 2327 | mdata->cap = ddata->cap; |
| 2328 | mdata->cfg = &ddata->cfg; |
| 2329 | } |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 2330 | |
Tony Lindgren | a3e92e7 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 2331 | ddata->mdata = mdata; |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 2332 | |
Tony Lindgren | a3e92e7 | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 2333 | return 0; |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 2334 | } |
| 2335 | |
Tony Lindgren | 70a6524 | 2017-12-15 09:41:09 -0800 | [diff] [blame] | 2336 | static int sysc_init_match(struct sysc *ddata) |
| 2337 | { |
| 2338 | const struct sysc_capabilities *cap; |
| 2339 | |
| 2340 | cap = of_device_get_match_data(ddata->dev); |
| 2341 | if (!cap) |
| 2342 | return -EINVAL; |
| 2343 | |
| 2344 | ddata->cap = cap; |
| 2345 | if (ddata->cap) |
| 2346 | ddata->cfg.quirks |= ddata->cap->mod_quirks; |
| 2347 | |
| 2348 | return 0; |
| 2349 | } |
| 2350 | |
Tony Lindgren | 76f0f77 | 2018-02-23 08:28:45 -0800 | [diff] [blame] | 2351 | static void ti_sysc_idle(struct work_struct *work) |
| 2352 | { |
| 2353 | struct sysc *ddata; |
| 2354 | |
| 2355 | ddata = container_of(work, struct sysc, idle_work.work); |
| 2356 | |
| 2357 | if (pm_runtime_active(ddata->dev)) |
| 2358 | pm_runtime_put_sync(ddata->dev); |
| 2359 | } |
| 2360 | |
Tony Lindgren | c4bebea | 2018-04-16 10:24:54 -0700 | [diff] [blame] | 2361 | static const struct of_device_id sysc_match_table[] = { |
| 2362 | { .compatible = "simple-bus", }, |
| 2363 | { /* sentinel */ }, |
| 2364 | }; |
| 2365 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 2366 | static int sysc_probe(struct platform_device *pdev) |
| 2367 | { |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 2368 | struct ti_sysc_platform_data *pdata = dev_get_platdata(&pdev->dev); |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 2369 | struct sysc *ddata; |
| 2370 | int error; |
| 2371 | |
| 2372 | ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL); |
| 2373 | if (!ddata) |
| 2374 | return -ENOMEM; |
| 2375 | |
| 2376 | ddata->dev = &pdev->dev; |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 2377 | platform_set_drvdata(pdev, ddata); |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 2378 | |
Tony Lindgren | 70a6524 | 2017-12-15 09:41:09 -0800 | [diff] [blame] | 2379 | error = sysc_init_match(ddata); |
| 2380 | if (error) |
| 2381 | return error; |
| 2382 | |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 2383 | error = sysc_init_dts_quirks(ddata); |
| 2384 | if (error) |
Suman Anna | a304f48 | 2019-06-25 18:33:15 -0500 | [diff] [blame] | 2385 | return error; |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 2386 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 2387 | error = sysc_map_and_check_registers(ddata); |
| 2388 | if (error) |
Suman Anna | a304f48 | 2019-06-25 18:33:15 -0500 | [diff] [blame] | 2389 | return error; |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 2390 | |
Tony Lindgren | c5a2de9 | 2017-12-15 09:41:23 -0800 | [diff] [blame] | 2391 | error = sysc_init_sysc_mask(ddata); |
| 2392 | if (error) |
Suman Anna | a304f48 | 2019-06-25 18:33:15 -0500 | [diff] [blame] | 2393 | return error; |
Tony Lindgren | c5a2de9 | 2017-12-15 09:41:23 -0800 | [diff] [blame] | 2394 | |
| 2395 | error = sysc_init_idlemodes(ddata); |
| 2396 | if (error) |
Suman Anna | a304f48 | 2019-06-25 18:33:15 -0500 | [diff] [blame] | 2397 | return error; |
Tony Lindgren | c5a2de9 | 2017-12-15 09:41:23 -0800 | [diff] [blame] | 2398 | |
| 2399 | error = sysc_init_syss_mask(ddata); |
| 2400 | if (error) |
Suman Anna | a304f48 | 2019-06-25 18:33:15 -0500 | [diff] [blame] | 2401 | return error; |
Tony Lindgren | c5a2de9 | 2017-12-15 09:41:23 -0800 | [diff] [blame] | 2402 | |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 2403 | error = sysc_init_pdata(ddata); |
| 2404 | if (error) |
Suman Anna | a304f48 | 2019-06-25 18:33:15 -0500 | [diff] [blame] | 2405 | return error; |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 2406 | |
Tony Lindgren | 42b9c5c | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 2407 | sysc_init_early_quirks(ddata); |
| 2408 | |
| 2409 | error = sysc_get_clocks(ddata); |
| 2410 | if (error) |
| 2411 | return error; |
| 2412 | |
Tony Lindgren | 5062236 | 2018-04-16 10:20:27 -0700 | [diff] [blame] | 2413 | error = sysc_init_resets(ddata); |
| 2414 | if (error) |
Suman Anna | a304f48 | 2019-06-25 18:33:15 -0500 | [diff] [blame] | 2415 | goto unprepare; |
Tony Lindgren | 566a9b05 | 2017-12-15 09:41:19 -0800 | [diff] [blame] | 2416 | |
| 2417 | error = sysc_init_module(ddata); |
| 2418 | if (error) |
| 2419 | goto unprepare; |
| 2420 | |
Tony Lindgren | 1a5cd7c | 2019-03-21 11:00:21 -0700 | [diff] [blame] | 2421 | pm_runtime_enable(ddata->dev); |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 2422 | error = pm_runtime_get_sync(ddata->dev); |
| 2423 | if (error < 0) { |
| 2424 | pm_runtime_put_noidle(ddata->dev); |
| 2425 | pm_runtime_disable(ddata->dev); |
| 2426 | goto unprepare; |
| 2427 | } |
| 2428 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 2429 | sysc_show_registers(ddata); |
| 2430 | |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 2431 | ddata->dev->type = &sysc_device_type; |
Tony Lindgren | c4bebea | 2018-04-16 10:24:54 -0700 | [diff] [blame] | 2432 | error = of_platform_populate(ddata->dev->of_node, sysc_match_table, |
| 2433 | pdata ? pdata->auxdata : NULL, |
Tony Lindgren | ef70b0b | 2018-02-22 14:00:25 -0800 | [diff] [blame] | 2434 | ddata->dev); |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 2435 | if (error) |
| 2436 | goto err; |
| 2437 | |
Tony Lindgren | 76f0f77 | 2018-02-23 08:28:45 -0800 | [diff] [blame] | 2438 | INIT_DELAYED_WORK(&ddata->idle_work, ti_sysc_idle); |
| 2439 | |
| 2440 | /* At least earlycon won't survive without deferred idle */ |
| 2441 | if (ddata->cfg.quirks & (SYSC_QUIRK_NO_IDLE_ON_INIT | |
| 2442 | SYSC_QUIRK_NO_RESET_ON_INIT)) { |
| 2443 | schedule_delayed_work(&ddata->idle_work, 3000); |
| 2444 | } else { |
| 2445 | pm_runtime_put(&pdev->dev); |
| 2446 | } |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 2447 | |
Tony Lindgren | 5062236 | 2018-04-16 10:20:27 -0700 | [diff] [blame] | 2448 | if (!of_get_available_child_count(ddata->dev->of_node)) |
Tony Lindgren | 8383e25 | 2019-05-27 04:51:56 -0700 | [diff] [blame] | 2449 | ddata->disable_on_idle = true; |
Tony Lindgren | 5062236 | 2018-04-16 10:20:27 -0700 | [diff] [blame] | 2450 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 2451 | return 0; |
| 2452 | |
| 2453 | err: |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 2454 | pm_runtime_put_sync(&pdev->dev); |
| 2455 | pm_runtime_disable(&pdev->dev); |
| 2456 | unprepare: |
| 2457 | sysc_unprepare(ddata); |
| 2458 | |
| 2459 | return error; |
| 2460 | } |
| 2461 | |
Tony Lindgren | 684be5a | 2017-10-13 10:48:40 -0700 | [diff] [blame] | 2462 | static int sysc_remove(struct platform_device *pdev) |
| 2463 | { |
| 2464 | struct sysc *ddata = platform_get_drvdata(pdev); |
| 2465 | int error; |
| 2466 | |
Tony Lindgren | 76f0f77 | 2018-02-23 08:28:45 -0800 | [diff] [blame] | 2467 | cancel_delayed_work_sync(&ddata->idle_work); |
| 2468 | |
Tony Lindgren | 684be5a | 2017-10-13 10:48:40 -0700 | [diff] [blame] | 2469 | error = pm_runtime_get_sync(ddata->dev); |
| 2470 | if (error < 0) { |
| 2471 | pm_runtime_put_noidle(ddata->dev); |
| 2472 | pm_runtime_disable(ddata->dev); |
| 2473 | goto unprepare; |
| 2474 | } |
| 2475 | |
| 2476 | of_platform_depopulate(&pdev->dev); |
| 2477 | |
Tony Lindgren | 684be5a | 2017-10-13 10:48:40 -0700 | [diff] [blame] | 2478 | pm_runtime_put_sync(&pdev->dev); |
| 2479 | pm_runtime_disable(&pdev->dev); |
Tony Lindgren | 5062236 | 2018-04-16 10:20:27 -0700 | [diff] [blame] | 2480 | reset_control_assert(ddata->rsts); |
Tony Lindgren | 684be5a | 2017-10-13 10:48:40 -0700 | [diff] [blame] | 2481 | |
| 2482 | unprepare: |
| 2483 | sysc_unprepare(ddata); |
| 2484 | |
| 2485 | return 0; |
| 2486 | } |
| 2487 | |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 2488 | static const struct of_device_id sysc_match[] = { |
Tony Lindgren | 70a6524 | 2017-12-15 09:41:09 -0800 | [diff] [blame] | 2489 | { .compatible = "ti,sysc-omap2", .data = &sysc_omap2, }, |
| 2490 | { .compatible = "ti,sysc-omap2-timer", .data = &sysc_omap2_timer, }, |
| 2491 | { .compatible = "ti,sysc-omap4", .data = &sysc_omap4, }, |
| 2492 | { .compatible = "ti,sysc-omap4-timer", .data = &sysc_omap4_timer, }, |
| 2493 | { .compatible = "ti,sysc-omap4-simple", .data = &sysc_omap4_simple, }, |
| 2494 | { .compatible = "ti,sysc-omap3430-sr", .data = &sysc_34xx_sr, }, |
| 2495 | { .compatible = "ti,sysc-omap3630-sr", .data = &sysc_36xx_sr, }, |
| 2496 | { .compatible = "ti,sysc-omap4-sr", .data = &sysc_omap4_sr, }, |
| 2497 | { .compatible = "ti,sysc-omap3-sham", .data = &sysc_omap3_sham, }, |
| 2498 | { .compatible = "ti,sysc-omap-aes", .data = &sysc_omap3_aes, }, |
| 2499 | { .compatible = "ti,sysc-mcasp", .data = &sysc_omap4_mcasp, }, |
Tony Lindgren | 2c63a83 | 2018-11-15 14:46:53 -0800 | [diff] [blame] | 2500 | { .compatible = "ti,sysc-dra7-mcasp", .data = &sysc_dra7_mcasp, }, |
Tony Lindgren | 70a6524 | 2017-12-15 09:41:09 -0800 | [diff] [blame] | 2501 | { .compatible = "ti,sysc-usb-host-fs", |
| 2502 | .data = &sysc_omap4_usb_host_fs, }, |
Faiz Abbas | 7f35e63 | 2018-07-09 22:18:38 +0530 | [diff] [blame] | 2503 | { .compatible = "ti,sysc-dra7-mcan", .data = &sysc_dra7_mcan, }, |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 2504 | { }, |
| 2505 | }; |
| 2506 | MODULE_DEVICE_TABLE(of, sysc_match); |
| 2507 | |
| 2508 | static struct platform_driver sysc_driver = { |
| 2509 | .probe = sysc_probe, |
Tony Lindgren | 684be5a | 2017-10-13 10:48:40 -0700 | [diff] [blame] | 2510 | .remove = sysc_remove, |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 2511 | .driver = { |
| 2512 | .name = "ti-sysc", |
| 2513 | .of_match_table = sysc_match, |
| 2514 | .pm = &sysc_pm_ops, |
| 2515 | }, |
| 2516 | }; |
Tony Lindgren | 2c355ff | 2018-02-22 13:58:03 -0800 | [diff] [blame] | 2517 | |
| 2518 | static int __init sysc_init(void) |
| 2519 | { |
| 2520 | bus_register_notifier(&platform_bus_type, &sysc_nb); |
| 2521 | |
| 2522 | return platform_driver_register(&sysc_driver); |
| 2523 | } |
| 2524 | module_init(sysc_init); |
| 2525 | |
| 2526 | static void __exit sysc_exit(void) |
| 2527 | { |
| 2528 | bus_unregister_notifier(&platform_bus_type, &sysc_nb); |
| 2529 | platform_driver_unregister(&sysc_driver); |
| 2530 | } |
| 2531 | module_exit(sysc_exit); |
Tony Lindgren | 0eecc63 | 2017-10-10 14:23:43 -0700 | [diff] [blame] | 2532 | |
| 2533 | MODULE_DESCRIPTION("TI sysc interconnect target driver"); |
| 2534 | MODULE_LICENSE("GPL v2"); |