Lines Matching refs:lpss

143 static void intel_lpss_cache_ltr(struct intel_lpss *lpss)  in intel_lpss_cache_ltr()  argument
145 lpss->active_ltr = readl(lpss->priv + LPSS_PRIV_ACTIVELTR); in intel_lpss_cache_ltr()
146 lpss->idle_ltr = readl(lpss->priv + LPSS_PRIV_IDLELTR); in intel_lpss_cache_ltr()
149 static int intel_lpss_debugfs_add(struct intel_lpss *lpss) in intel_lpss_debugfs_add() argument
153 dir = debugfs_create_dir(dev_name(lpss->dev), intel_lpss_debugfs); in intel_lpss_debugfs_add()
158 intel_lpss_cache_ltr(lpss); in intel_lpss_debugfs_add()
160 debugfs_create_x32("capabilities", S_IRUGO, dir, &lpss->caps); in intel_lpss_debugfs_add()
161 debugfs_create_x32("active_ltr", S_IRUGO, dir, &lpss->active_ltr); in intel_lpss_debugfs_add()
162 debugfs_create_x32("idle_ltr", S_IRUGO, dir, &lpss->idle_ltr); in intel_lpss_debugfs_add()
164 lpss->debugfs = dir; in intel_lpss_debugfs_add()
168 static void intel_lpss_debugfs_remove(struct intel_lpss *lpss) in intel_lpss_debugfs_remove() argument
170 debugfs_remove_recursive(lpss->debugfs); in intel_lpss_debugfs_remove()
175 struct intel_lpss *lpss = dev_get_drvdata(dev); in intel_lpss_ltr_set() local
183 ltr = readl(lpss->priv + LPSS_PRIV_ACTIVELTR); in intel_lpss_ltr_set()
198 if (ltr == lpss->active_ltr) in intel_lpss_ltr_set()
201 writel(ltr, lpss->priv + LPSS_PRIV_ACTIVELTR); in intel_lpss_ltr_set()
202 writel(ltr, lpss->priv + LPSS_PRIV_IDLELTR); in intel_lpss_ltr_set()
205 intel_lpss_cache_ltr(lpss); in intel_lpss_ltr_set()
208 static void intel_lpss_ltr_expose(struct intel_lpss *lpss) in intel_lpss_ltr_expose() argument
210 lpss->dev->power.set_latency_tolerance = intel_lpss_ltr_set; in intel_lpss_ltr_expose()
211 dev_pm_qos_expose_latency_tolerance(lpss->dev); in intel_lpss_ltr_expose()
214 static void intel_lpss_ltr_hide(struct intel_lpss *lpss) in intel_lpss_ltr_hide() argument
216 dev_pm_qos_hide_latency_tolerance(lpss->dev); in intel_lpss_ltr_hide()
217 lpss->dev->power.set_latency_tolerance = NULL; in intel_lpss_ltr_hide()
220 static int intel_lpss_assign_devs(struct intel_lpss *lpss) in intel_lpss_assign_devs() argument
224 type = lpss->caps & LPSS_PRIV_CAPS_TYPE_MASK; in intel_lpss_assign_devs()
229 lpss->cell = &intel_lpss_i2c_cell; in intel_lpss_assign_devs()
232 lpss->cell = &intel_lpss_uart_cell; in intel_lpss_assign_devs()
235 lpss->cell = &intel_lpss_spi_cell; in intel_lpss_assign_devs()
241 lpss->type = type; in intel_lpss_assign_devs()
246 static bool intel_lpss_has_idma(const struct intel_lpss *lpss) in intel_lpss_has_idma() argument
248 return (lpss->caps & LPSS_PRIV_CAPS_NO_IDMA) == 0; in intel_lpss_has_idma()
251 static void intel_lpss_set_remap_addr(const struct intel_lpss *lpss) in intel_lpss_set_remap_addr() argument
253 resource_size_t addr = lpss->info->mem->start; in intel_lpss_set_remap_addr()
255 lo_hi_writeq(addr, lpss->priv + LPSS_PRIV_REMAP_ADDR); in intel_lpss_set_remap_addr()
258 static void intel_lpss_deassert_reset(const struct intel_lpss *lpss) in intel_lpss_deassert_reset() argument
263 writel(value, lpss->priv + LPSS_PRIV_RESETS); in intel_lpss_deassert_reset()
266 static void intel_lpss_init_dev(const struct intel_lpss *lpss) in intel_lpss_init_dev() argument
270 intel_lpss_deassert_reset(lpss); in intel_lpss_init_dev()
272 if (!intel_lpss_has_idma(lpss)) in intel_lpss_init_dev()
275 intel_lpss_set_remap_addr(lpss); in intel_lpss_init_dev()
278 if (lpss->type == LPSS_DEV_SPI) in intel_lpss_init_dev()
279 writel(value, lpss->priv + LPSS_PRIV_SSP_REG); in intel_lpss_init_dev()
293 static int intel_lpss_register_clock_divider(struct intel_lpss *lpss, in intel_lpss_register_clock_divider() argument
302 lpss->priv, 0, 0, NULL); in intel_lpss_register_clock_divider()
308 0, lpss->priv, 1, 15, 16, 15, 0, in intel_lpss_register_clock_divider()
316 CLK_SET_RATE_PARENT, lpss->priv, 31, 0, NULL); in intel_lpss_register_clock_divider()
324 static int intel_lpss_register_clock(struct intel_lpss *lpss) in intel_lpss_register_clock() argument
326 const struct mfd_cell *cell = lpss->cell; in intel_lpss_register_clock()
331 if (!lpss->info->clk_rate) in intel_lpss_register_clock()
335 clk = clk_register_fixed_rate(NULL, dev_name(lpss->dev), NULL, in intel_lpss_register_clock()
336 CLK_IS_ROOT, lpss->info->clk_rate); in intel_lpss_register_clock()
340 snprintf(devname, sizeof(devname), "%s.%d", cell->name, lpss->devid); in intel_lpss_register_clock()
346 if (lpss->type != LPSS_DEV_I2C) { in intel_lpss_register_clock()
347 ret = intel_lpss_register_clock_divider(lpss, devname, &clk); in intel_lpss_register_clock()
355 lpss->clock = clkdev_create(clk, lpss->info->clk_con_id, "%s", devname); in intel_lpss_register_clock()
356 if (!lpss->clock) in intel_lpss_register_clock()
359 lpss->clk = clk; in intel_lpss_register_clock()
369 static void intel_lpss_unregister_clock(struct intel_lpss *lpss) in intel_lpss_unregister_clock() argument
371 if (IS_ERR_OR_NULL(lpss->clk)) in intel_lpss_unregister_clock()
374 clkdev_drop(lpss->clock); in intel_lpss_unregister_clock()
375 intel_lpss_unregister_clock_tree(lpss->clk); in intel_lpss_unregister_clock()
381 struct intel_lpss *lpss; in intel_lpss_probe() local
387 lpss = devm_kzalloc(dev, sizeof(*lpss), GFP_KERNEL); in intel_lpss_probe()
388 if (!lpss) in intel_lpss_probe()
391 lpss->priv = devm_ioremap(dev, info->mem->start + LPSS_PRIV_OFFSET, in intel_lpss_probe()
393 if (!lpss->priv) in intel_lpss_probe()
396 lpss->info = info; in intel_lpss_probe()
397 lpss->dev = dev; in intel_lpss_probe()
398 lpss->caps = readl(lpss->priv + LPSS_PRIV_CAPS); in intel_lpss_probe()
400 dev_set_drvdata(dev, lpss); in intel_lpss_probe()
402 ret = intel_lpss_assign_devs(lpss); in intel_lpss_probe()
406 intel_lpss_init_dev(lpss); in intel_lpss_probe()
408 lpss->devid = ida_simple_get(&intel_lpss_devid_ida, 0, 0, GFP_KERNEL); in intel_lpss_probe()
409 if (lpss->devid < 0) in intel_lpss_probe()
410 return lpss->devid; in intel_lpss_probe()
412 ret = intel_lpss_register_clock(lpss); in intel_lpss_probe()
416 intel_lpss_ltr_expose(lpss); in intel_lpss_probe()
418 ret = intel_lpss_debugfs_add(lpss); in intel_lpss_probe()
422 if (intel_lpss_has_idma(lpss)) { in intel_lpss_probe()
433 ret = mfd_add_devices(dev, lpss->devid, &intel_lpss_idma64_cell, in intel_lpss_probe()
440 ret = mfd_add_devices(dev, lpss->devid, lpss->cell, in intel_lpss_probe()
448 intel_lpss_debugfs_remove(lpss); in intel_lpss_probe()
449 intel_lpss_ltr_hide(lpss); in intel_lpss_probe()
450 intel_lpss_unregister_clock(lpss); in intel_lpss_probe()
453 ida_simple_remove(&intel_lpss_devid_ida, lpss->devid); in intel_lpss_probe()
461 struct intel_lpss *lpss = dev_get_drvdata(dev); in intel_lpss_remove() local
464 intel_lpss_debugfs_remove(lpss); in intel_lpss_remove()
465 intel_lpss_ltr_hide(lpss); in intel_lpss_remove()
466 intel_lpss_unregister_clock(lpss); in intel_lpss_remove()
467 ida_simple_remove(&intel_lpss_devid_ida, lpss->devid); in intel_lpss_remove()
490 struct intel_lpss *lpss = dev_get_drvdata(dev); in intel_lpss_suspend() local
495 lpss->priv_ctx[i] = readl(lpss->priv + i * 4); in intel_lpss_suspend()
498 writel(0, lpss->priv + LPSS_PRIV_RESETS); in intel_lpss_suspend()
506 struct intel_lpss *lpss = dev_get_drvdata(dev); in intel_lpss_resume() local
509 intel_lpss_deassert_reset(lpss); in intel_lpss_resume()
513 writel(lpss->priv_ctx[i], lpss->priv + i * 4); in intel_lpss_resume()