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"),
170 /* Only call pwm_add_table for the first PWM controller */ in byt_pwm_setup()
171 if (acpi_dev_uid_match(pdata->adev, 1)) in byt_pwm_setup()
179 acpi_handle handle = pdata->adev->handle; in byt_i2c_setup()
185 if (!acpi_dev_uid_to_integer(pdata->adev, &uid) && uid) { in byt_i2c_setup()
189 pmc_atom_d3_mask &= ~(BIT_LPSS2_F1_I2C1 << (uid - 1)); in byt_i2c_setup()
194 if (readl(pdata->mmio_base + pdata->dev_desc->prv_offset)) in byt_i2c_setup()
195 pdata->fixed_clk_rate = 133000000; in byt_i2c_setup()
197 writel(0, pdata->mmio_base + LPSS_I2C_ENABLE); in byt_i2c_setup()
203 * touch controls on some models. These touch-controls have specialized
204 * drivers which know they need the "pwm_soc_lpss_2" con-id.
209 "pwm-lpss-platform"),
212 "pwm-lpss-platform"),
217 /* Only call pwm_add_table for the first PWM controller */ in bsw_pwm_setup()
218 if (acpi_dev_uid_match(pdata->adev, 1)) in bsw_pwm_setup()
223 PROPERTY_ENTRY_U32("intel,spi-pxa2xx-type", LPSS_LPT_SSP),
240 PROPERTY_ENTRY_U32("reg-io-width", 4),
241 PROPERTY_ENTRY_U32("reg-shift", 2),
242 PROPERTY_ENTRY_BOOL("snps,uart-16550-compatible"),
298 PROPERTY_ENTRY_U32("intel,spi-pxa2xx-type", LPSS_BYT_SSP),
327 PROPERTY_ENTRY_U32("intel,spi-pxa2xx-type", LPSS_BSW_SSP),
328 PROPERTY_ENTRY_U32("num-cs", 2),
403 lpss_clk_dev = platform_device_register_simple("clk-lpss-atom", in lpt_register_clock_device()
411 const struct lpss_device_desc *dev_desc = pdata->dev_desc; in register_device_clock()
412 const char *devname = dev_name(&adev->dev); in register_device_clock()
426 return -ENODEV; in register_device_clock()
427 clk = clk_data->clk; in register_device_clock()
429 if (!pdata->mmio_base in register_device_clock()
430 || pdata->mmio_size < dev_desc->prv_offset + LPSS_CLK_SIZE) in register_device_clock()
431 return -ENODATA; in register_device_clock()
433 parent = clk_data->name; in register_device_clock()
434 prv_base = pdata->mmio_base + dev_desc->prv_offset; in register_device_clock()
436 if (pdata->fixed_clk_rate) { in register_device_clock()
438 pdata->fixed_clk_rate); in register_device_clock()
442 if (dev_desc->flags & LPSS_CLK_GATE) { in register_device_clock()
448 if (dev_desc->flags & LPSS_CLK_DIVIDER) { in register_device_clock()
453 clk_name = kasprintf(GFP_KERNEL, "%s-div", devname); in register_device_clock()
455 return -ENOMEM; in register_device_clock()
462 clk_name = kasprintf(GFP_KERNEL, "%s-update", devname); in register_device_clock()
465 return -ENOMEM; in register_device_clock()
477 pdata->clk = clk; in register_device_clock()
478 clk_register_clkdev(clk, dev_desc->clk_con_id, devname); in register_device_clock()
526 return acpi_dev_hid_uid_match(adev, link->supplier_hid, link->supplier_uid); in acpi_lpss_is_supplier()
532 return acpi_dev_hid_uid_match(adev, link->consumer_hid, link->consumer_uid); in acpi_lpss_is_consumer()
548 return acpi_dev_hid_uid_match(adev, id->hid, id->uid); in match_hid_uid()
572 dev2 = acpi_lpss_find_device(link->consumer_hid, link->consumer_uid); in acpi_lpss_link_consumer()
576 if ((link->dep_missing_ids && dmi_check_system(link->dep_missing_ids)) in acpi_lpss_link_consumer()
578 device_link_add(dev2, dev1, link->flags); in acpi_lpss_link_consumer()
588 dev2 = acpi_lpss_find_device(link->supplier_hid, link->supplier_uid); in acpi_lpss_link_supplier()
592 if ((link->dep_missing_ids && dmi_check_system(link->dep_missing_ids)) in acpi_lpss_link_supplier()
594 device_link_add(dev1, dev2, link->flags); in acpi_lpss_link_supplier()
608 acpi_lpss_link_consumer(&pdev->dev, link); in acpi_lpss_create_device_links()
611 acpi_lpss_link_supplier(&pdev->dev, link); in acpi_lpss_create_device_links()
625 dev_desc = (const struct lpss_device_desc *)id->driver_data; in acpi_lpss_create_device()
627 return -EINVAL; in acpi_lpss_create_device()
631 return -ENOMEM; in acpi_lpss_create_device()
640 if (dev_desc->prv_size_override) in acpi_lpss_create_device()
641 pdata->mmio_size = dev_desc->prv_size_override; in acpi_lpss_create_device()
643 pdata->mmio_size = resource_size(rentry->res); in acpi_lpss_create_device()
644 pdata->mmio_base = ioremap(rentry->res->start, pdata->mmio_size); in acpi_lpss_create_device()
649 if (!pdata->mmio_base) { in acpi_lpss_create_device()
651 adev->pnp.type.platform_id = 0; in acpi_lpss_create_device()
655 pdata->adev = adev; in acpi_lpss_create_device()
656 pdata->dev_desc = dev_desc; in acpi_lpss_create_device()
658 if (dev_desc->setup) in acpi_lpss_create_device()
659 dev_desc->setup(pdata); in acpi_lpss_create_device()
661 if (dev_desc->flags & LPSS_CLK) { in acpi_lpss_create_device()
674 adev->driver_data = pdata; in acpi_lpss_create_device()
675 pdev = acpi_create_platform_device(adev, dev_desc->properties); in acpi_lpss_create_device()
677 adev->driver_data = NULL; in acpi_lpss_create_device()
695 return readl(pdata->mmio_base + pdata->dev_desc->prv_offset + reg); in __lpss_reg_read()
701 writel(val, pdata->mmio_base + pdata->dev_desc->prv_offset + reg); in __lpss_reg_write()
712 return -ENODEV; in lpss_reg_read()
714 spin_lock_irqsave(&dev->power.lock, flags); in lpss_reg_read()
716 ret = -EAGAIN; in lpss_reg_read()
720 if (WARN_ON(!pdata || !pdata->mmio_base)) { in lpss_reg_read()
721 ret = -ENODEV; in lpss_reg_read()
728 spin_unlock_irqrestore(&dev->power.lock, flags); in lpss_reg_read()
739 reg = strcmp(attr->attr.name, "auto_ltr") ? LPSS_SW_LTR : LPSS_AUTO_LTR; in lpss_ltr_show()
811 * acpi_lpss_save_ctx() - Save the private registers of LPSS device
827 pdata->prv_reg_ctx[i] = __lpss_reg_read(pdata, offset); in acpi_lpss_save_ctx()
829 pdata->prv_reg_ctx[i], offset); in acpi_lpss_save_ctx()
834 * acpi_lpss_restore_ctx() - Restore the private registers of LPSS device
848 __lpss_reg_write(pdata->prv_reg_ctx[i], pdata, offset); in acpi_lpss_restore_ctx()
850 pdata->prv_reg_ctx[i], offset); in acpi_lpss_restore_ctx()
857 * The following delay is needed or the subsequent write operations may in acpi_lpss_d3_to_d0_delay()
859 * expects 10ms delay before the device can be accessed after D3 to D0 in acpi_lpss_d3_to_d0_delay()
860 * transition. However some platforms like BSW does not need this delay. in acpi_lpss_d3_to_d0_delay()
862 unsigned int delay = 10; /* default 10ms delay */ in acpi_lpss_d3_to_d0_delay() local
864 if (pdata->dev_desc->flags & LPSS_NO_D3_DELAY) in acpi_lpss_d3_to_d0_delay()
865 delay = 0; in acpi_lpss_d3_to_d0_delay()
867 msleep(delay); in acpi_lpss_d3_to_d0_delay()
882 * This is called only on ->probe() stage where a device is either in in acpi_lpss_activate()
883 * known state defined by BIOS or most likely powered off. Due to this in acpi_lpss_activate()
884 * we have to deassert reset line to be sure that ->probe() will in acpi_lpss_activate()
887 if (pdata->dev_desc->flags & (LPSS_SAVE_CTX | LPSS_SAVE_CTX_ONCE)) in acpi_lpss_activate()
890 if (pdata->dev_desc->flags & LPSS_SAVE_CTX_ONCE) in acpi_lpss_activate()
1001 if (pdata->dev_desc->flags & LPSS_SAVE_CTX) in acpi_lpss_suspend()
1008 * wrong status for devices being about to be powered off. See in acpi_lpss_suspend()
1036 if (pdata->dev_desc->flags & (LPSS_SAVE_CTX | LPSS_SAVE_CTX_ONCE)) in acpi_lpss_resume()
1058 if (pdata->dev_desc->resume_from_noirq) in acpi_lpss_suspend_late()
1069 if (pdata->dev_desc->resume_from_noirq) { in acpi_lpss_suspend_noirq()
1071 * The driver's ->suspend_late callback will be invoked by in acpi_lpss_suspend_noirq()
1073 * driver really wanted to run that code in ->suspend_noirq, but in acpi_lpss_suspend_noirq()
1096 if (pdata->dev_desc->resume_from_noirq) in acpi_lpss_resume_early()
1118 if (!pdata->dev_desc->resume_from_noirq) in acpi_lpss_resume_noirq()
1122 * The driver's ->resume_early callback will be invoked by in acpi_lpss_resume_noirq()
1124 * really wanted to run that code in ->resume_noirq, but it could not in acpi_lpss_resume_noirq()
1142 if (pdata->dev_desc->resume_from_noirq) in acpi_lpss_restore_early()
1157 if (!pdata->dev_desc->resume_from_noirq) in acpi_lpss_restore_noirq()
1178 if (pdata->dev_desc->resume_from_noirq) in acpi_lpss_poweroff_late()
1191 if (pdata->dev_desc->resume_from_noirq) { in acpi_lpss_poweroff_noirq()
1254 id = acpi_match_device(acpi_lpss_device_ids, &pdev->dev); in acpi_lpss_platform_notify()
1255 if (!id || !id->driver_data) in acpi_lpss_platform_notify()
1258 adev = ACPI_COMPANION(&pdev->dev); in acpi_lpss_platform_notify()
1266 if (pdata->mmio_base && in acpi_lpss_platform_notify()
1267 pdata->mmio_size < pdata->dev_desc->prv_offset + LPSS_LTR_SIZE) { in acpi_lpss_platform_notify()
1268 dev_err(&pdev->dev, "MMIO size insufficient to access LTR\n"); in acpi_lpss_platform_notify()
1274 dev_pm_domain_set(&pdev->dev, &acpi_lpss_pm_domain); in acpi_lpss_platform_notify()
1278 dev_pm_domain_set(&pdev->dev, NULL); in acpi_lpss_platform_notify()
1281 dev_pm_domain_set(&pdev->dev, &acpi_lpss_pm_domain); in acpi_lpss_platform_notify()
1282 if (pdata->dev_desc->flags & LPSS_LTR) in acpi_lpss_platform_notify()
1283 return sysfs_create_group(&pdev->dev.kobj, in acpi_lpss_platform_notify()
1287 if (pdata->dev_desc->flags & LPSS_LTR) in acpi_lpss_platform_notify()
1288 sysfs_remove_group(&pdev->dev.kobj, &lpss_attr_group); in acpi_lpss_platform_notify()
1289 dev_pm_domain_set(&pdev->dev, NULL); in acpi_lpss_platform_notify()
1306 if (!pdata || !pdata->mmio_base || !(pdata->dev_desc->flags & LPSS_LTR)) in acpi_lpss_bind()
1309 if (pdata->mmio_size >= pdata->dev_desc->prv_offset + LPSS_LTR_SIZE) in acpi_lpss_bind()
1310 dev->power.set_latency_tolerance = acpi_lpss_set_ltr; in acpi_lpss_bind()
1317 dev->power.set_latency_tolerance = NULL; in acpi_lpss_unbind()