Lines Matching +full:pwm +full:- +full:off +full:- +full:delay +full:- +full:ms
1 // SPDX-License-Identifier: GPL-2.0-only
12 #include <linux/clk-provider.h>
19 #include <linux/platform_data/x86/clk-lpss.h>
23 #include <linux/pwm.h>
26 #include <linux/delay.h>
33 #include <asm/intel-family.h>
70 * For some devices the DSDT AML code for another device turns off the device
71 * before our suspend handler runs, causing us to read/save all 1-s (0xffffffff)
115 * it can be powered off automatically whenever the last LPSS device goes down.
134 offset = pdata->dev_desc->prv_offset + LPSS_TX_INT; in lpss_uart_setup()
135 val = readl(pdata->mmio_base + offset); in lpss_uart_setup()
136 writel(val | LPSS_TX_INT_MASK, pdata->mmio_base + offset); in lpss_uart_setup()
138 val = readl(pdata->mmio_base + LPSS_UART_CPR); in lpss_uart_setup()
140 offset = pdata->dev_desc->prv_offset + LPSS_GENERAL; in lpss_uart_setup()
141 val = readl(pdata->mmio_base + offset); in lpss_uart_setup()
143 writel(val, pdata->mmio_base + offset); in lpss_uart_setup()
152 offset = pdata->dev_desc->prv_offset + LPSS_RESETS; in lpss_deassert_reset()
153 val = readl(pdata->mmio_base + offset); in lpss_deassert_reset()
155 writel(val, pdata->mmio_base + offset); in lpss_deassert_reset()
159 * BYT PWM used for backlight control by the i915 driver on systems without
165 "pwm-lpss-platform"),
172 /* Only call pwm_add_table for the first PWM controller */ in byt_pwm_setup()
173 if (acpi_dev_uid_to_integer(pdata->adev, &uid) || uid != 1) in byt_pwm_setup()
183 acpi_handle handle = pdata->adev->handle; in byt_i2c_setup()
189 if (!acpi_dev_uid_to_integer(pdata->adev, &uid) && uid) { in byt_i2c_setup()
193 pmc_atom_d3_mask &= ~(BIT_LPSS2_F1_I2C1 << (uid - 1)); in byt_i2c_setup()
198 if (readl(pdata->mmio_base + pdata->dev_desc->prv_offset)) in byt_i2c_setup()
199 pdata->fixed_clk_rate = 133000000; in byt_i2c_setup()
201 writel(0, pdata->mmio_base + LPSS_I2C_ENABLE); in byt_i2c_setup()
207 * touch controls on some models. These touch-controls have specialized
208 * drivers which know they need the "pwm_soc_lpss_2" con-id.
213 "pwm-lpss-platform"),
216 "pwm-lpss-platform"),
223 /* Only call pwm_add_table for the first PWM controller */ in bsw_pwm_setup()
224 if (acpi_dev_uid_to_integer(pdata->adev, &uid) || uid != 1) in bsw_pwm_setup()
231 PROPERTY_ENTRY_U32("intel,spi-pxa2xx-type", LPSS_LPT_SSP),
248 PROPERTY_ENTRY_U32("reg-io-width", 4),
249 PROPERTY_ENTRY_U32("reg-shift", 2),
250 PROPERTY_ENTRY_BOOL("snps,uart-16550-compatible"),
306 PROPERTY_ENTRY_U32("intel,spi-pxa2xx-type", LPSS_BYT_SSP),
335 PROPERTY_ENTRY_U32("intel,spi-pxa2xx-type", LPSS_BSW_SSP),
336 PROPERTY_ENTRY_U32("num-cs", 2),
415 lpss_clk_dev = platform_device_register_simple("clk-lpss-atom", in lpt_register_clock_device()
423 const struct lpss_device_desc *dev_desc = pdata->dev_desc; in register_device_clock()
424 const char *devname = dev_name(&adev->dev); in register_device_clock()
438 return -ENODEV; in register_device_clock()
439 clk = clk_data->clk; in register_device_clock()
441 if (!pdata->mmio_base in register_device_clock()
442 || pdata->mmio_size < dev_desc->prv_offset + LPSS_CLK_SIZE) in register_device_clock()
443 return -ENODATA; in register_device_clock()
445 parent = clk_data->name; in register_device_clock()
446 prv_base = pdata->mmio_base + dev_desc->prv_offset; in register_device_clock()
448 if (pdata->fixed_clk_rate) { in register_device_clock()
450 pdata->fixed_clk_rate); in register_device_clock()
454 if (dev_desc->flags & LPSS_CLK_GATE) { in register_device_clock()
460 if (dev_desc->flags & LPSS_CLK_DIVIDER) { in register_device_clock()
465 clk_name = kasprintf(GFP_KERNEL, "%s-div", devname); in register_device_clock()
467 return -ENOMEM; in register_device_clock()
474 clk_name = kasprintf(GFP_KERNEL, "%s-update", devname); in register_device_clock()
477 return -ENOMEM; in register_device_clock()
489 pdata->clk = clk; in register_device_clock()
490 clk_register_clkdev(clk, dev_desc->clk_con_id, devname); in register_device_clock()
538 return acpi_dev_hid_uid_match(adev, link->supplier_hid, link->supplier_uid); in acpi_lpss_is_supplier()
544 return acpi_dev_hid_uid_match(adev, link->consumer_hid, link->consumer_uid); in acpi_lpss_is_consumer()
560 return acpi_dev_hid_uid_match(adev, id->hid, id->uid); in match_hid_uid()
585 if (!acpi_has_method(adev->handle, "_DEP")) in acpi_lpss_dep()
588 status = acpi_evaluate_reference(adev->handle, "_DEP", NULL, in acpi_lpss_dep()
591 dev_dbg(&adev->dev, "Failed to evaluate _DEP.\n"); in acpi_lpss_dep()
608 dev2 = acpi_lpss_find_device(link->consumer_hid, link->consumer_uid); in acpi_lpss_link_consumer()
612 if ((link->dep_missing_ids && dmi_check_system(link->dep_missing_ids)) in acpi_lpss_link_consumer()
614 device_link_add(dev2, dev1, link->flags); in acpi_lpss_link_consumer()
624 dev2 = acpi_lpss_find_device(link->supplier_hid, link->supplier_uid); in acpi_lpss_link_supplier()
628 if ((link->dep_missing_ids && dmi_check_system(link->dep_missing_ids)) in acpi_lpss_link_supplier()
630 device_link_add(dev1, dev2, link->flags); in acpi_lpss_link_supplier()
644 acpi_lpss_link_consumer(&pdev->dev, link); in acpi_lpss_create_device_links()
647 acpi_lpss_link_supplier(&pdev->dev, link); in acpi_lpss_create_device_links()
661 dev_desc = (const struct lpss_device_desc *)id->driver_data; in acpi_lpss_create_device()
668 return -ENOMEM; in acpi_lpss_create_device()
677 if (dev_desc->prv_size_override) in acpi_lpss_create_device()
678 pdata->mmio_size = dev_desc->prv_size_override; in acpi_lpss_create_device()
680 pdata->mmio_size = resource_size(rentry->res); in acpi_lpss_create_device()
681 pdata->mmio_base = ioremap(rentry->res->start, pdata->mmio_size); in acpi_lpss_create_device()
686 if (!pdata->mmio_base) { in acpi_lpss_create_device()
688 adev->pnp.type.platform_id = 0; in acpi_lpss_create_device()
692 pdata->adev = adev; in acpi_lpss_create_device()
693 pdata->dev_desc = dev_desc; in acpi_lpss_create_device()
695 if (dev_desc->setup) in acpi_lpss_create_device()
696 dev_desc->setup(pdata); in acpi_lpss_create_device()
698 if (dev_desc->flags & LPSS_CLK) { in acpi_lpss_create_device()
711 adev->driver_data = pdata; in acpi_lpss_create_device()
712 pdev = acpi_create_platform_device(adev, dev_desc->properties); in acpi_lpss_create_device()
714 adev->driver_data = NULL; in acpi_lpss_create_device()
732 return readl(pdata->mmio_base + pdata->dev_desc->prv_offset + reg); in __lpss_reg_read()
738 writel(val, pdata->mmio_base + pdata->dev_desc->prv_offset + reg); in __lpss_reg_write()
749 return -ENODEV; in lpss_reg_read()
751 spin_lock_irqsave(&dev->power.lock, flags); in lpss_reg_read()
753 ret = -EAGAIN; in lpss_reg_read()
757 if (WARN_ON(!pdata || !pdata->mmio_base)) { in lpss_reg_read()
758 ret = -ENODEV; in lpss_reg_read()
765 spin_unlock_irqrestore(&dev->power.lock, flags); in lpss_reg_read()
776 reg = strcmp(attr->attr.name, "auto_ltr") ? LPSS_SW_LTR : LPSS_AUTO_LTR; in lpss_ltr_show()
848 * acpi_lpss_save_ctx() - Save the private registers of LPSS device
864 pdata->prv_reg_ctx[i] = __lpss_reg_read(pdata, offset); in acpi_lpss_save_ctx()
866 pdata->prv_reg_ctx[i], offset); in acpi_lpss_save_ctx()
871 * acpi_lpss_restore_ctx() - Restore the private registers of LPSS device
885 __lpss_reg_write(pdata->prv_reg_ctx[i], pdata, offset); in acpi_lpss_restore_ctx()
887 pdata->prv_reg_ctx[i], offset); in acpi_lpss_restore_ctx()
894 * The following delay is needed or the subsequent write operations may in acpi_lpss_d3_to_d0_delay()
896 * expects 10ms delay before the device can be accessed after D3 to D0 in acpi_lpss_d3_to_d0_delay()
897 * transition. However some platforms like BSW does not need this delay. in acpi_lpss_d3_to_d0_delay()
899 unsigned int delay = 10; /* default 10ms delay */ in acpi_lpss_d3_to_d0_delay() local
901 if (pdata->dev_desc->flags & LPSS_NO_D3_DELAY) in acpi_lpss_d3_to_d0_delay()
902 delay = 0; in acpi_lpss_d3_to_d0_delay()
904 msleep(delay); in acpi_lpss_d3_to_d0_delay()
919 * This is called only on ->probe() stage where a device is either in in acpi_lpss_activate()
920 * known state defined by BIOS or most likely powered off. Due to this in acpi_lpss_activate()
921 * we have to deassert reset line to be sure that ->probe() will in acpi_lpss_activate()
924 if (pdata->dev_desc->flags & (LPSS_SAVE_CTX | LPSS_SAVE_CTX_ONCE)) in acpi_lpss_activate()
928 if (pdata->dev_desc->flags & LPSS_SAVE_CTX_ONCE) in acpi_lpss_activate()
1040 if (pdata->dev_desc->flags & LPSS_SAVE_CTX) in acpi_lpss_suspend()
1047 * wrong status for devices being about to be powered off. See in acpi_lpss_suspend()
1075 if (pdata->dev_desc->flags & (LPSS_SAVE_CTX | LPSS_SAVE_CTX_ONCE)) in acpi_lpss_resume()
1097 if (pdata->dev_desc->resume_from_noirq) in acpi_lpss_suspend_late()
1108 if (pdata->dev_desc->resume_from_noirq) { in acpi_lpss_suspend_noirq()
1110 * The driver's ->suspend_late callback will be invoked by in acpi_lpss_suspend_noirq()
1112 * driver really wanted to run that code in ->suspend_noirq, but in acpi_lpss_suspend_noirq()
1135 if (pdata->dev_desc->resume_from_noirq) in acpi_lpss_resume_early()
1157 if (!pdata->dev_desc->resume_from_noirq) in acpi_lpss_resume_noirq()
1161 * The driver's ->resume_early callback will be invoked by in acpi_lpss_resume_noirq()
1163 * really wanted to run that code in ->resume_noirq, but it could not in acpi_lpss_resume_noirq()
1181 if (pdata->dev_desc->resume_from_noirq) in acpi_lpss_restore_early()
1196 if (!pdata->dev_desc->resume_from_noirq) in acpi_lpss_restore_noirq()
1217 if (pdata->dev_desc->resume_from_noirq) in acpi_lpss_poweroff_late()
1230 if (pdata->dev_desc->resume_from_noirq) { in acpi_lpss_poweroff_noirq()
1293 id = acpi_match_device(acpi_lpss_device_ids, &pdev->dev); in acpi_lpss_platform_notify()
1294 if (!id || !id->driver_data) in acpi_lpss_platform_notify()
1297 adev = ACPI_COMPANION(&pdev->dev); in acpi_lpss_platform_notify()
1305 if (pdata->mmio_base && in acpi_lpss_platform_notify()
1306 pdata->mmio_size < pdata->dev_desc->prv_offset + LPSS_LTR_SIZE) { in acpi_lpss_platform_notify()
1307 dev_err(&pdev->dev, "MMIO size insufficient to access LTR\n"); in acpi_lpss_platform_notify()
1313 dev_pm_domain_set(&pdev->dev, &acpi_lpss_pm_domain); in acpi_lpss_platform_notify()
1317 dev_pm_domain_set(&pdev->dev, NULL); in acpi_lpss_platform_notify()
1320 dev_pm_domain_set(&pdev->dev, &acpi_lpss_pm_domain); in acpi_lpss_platform_notify()
1321 if (pdata->dev_desc->flags & LPSS_LTR) in acpi_lpss_platform_notify()
1322 return sysfs_create_group(&pdev->dev.kobj, in acpi_lpss_platform_notify()
1326 if (pdata->dev_desc->flags & LPSS_LTR) in acpi_lpss_platform_notify()
1327 sysfs_remove_group(&pdev->dev.kobj, &lpss_attr_group); in acpi_lpss_platform_notify()
1328 dev_pm_domain_set(&pdev->dev, NULL); in acpi_lpss_platform_notify()
1345 if (!pdata || !pdata->mmio_base || !(pdata->dev_desc->flags & LPSS_LTR)) in acpi_lpss_bind()
1348 if (pdata->mmio_size >= pdata->dev_desc->prv_offset + LPSS_LTR_SIZE) in acpi_lpss_bind()
1349 dev->power.set_latency_tolerance = acpi_lpss_set_ltr; in acpi_lpss_bind()
1356 dev->power.set_latency_tolerance = NULL; in acpi_lpss_unbind()