| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Intel Sunrisepoint LPSS core support. |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 7 | 8 | * Mika Westerberg <mika.westerberg@linux.intel.com> |
|---|
| 8 | 9 | * Heikki Krogerus <heikki.krogerus@linux.intel.com> |
|---|
| 9 | 10 | * Jarkko Nikula <jarkko.nikula@linux.intel.com> |
|---|
| 10 | | - * |
|---|
| 11 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 12 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 13 | | - * published by the Free Software Foundation. |
|---|
| 14 | 11 | */ |
|---|
| 15 | 12 | |
|---|
| 16 | 13 | #include <linux/clk.h> |
|---|
| .. | .. |
|---|
| 18 | 15 | #include <linux/clk-provider.h> |
|---|
| 19 | 16 | #include <linux/debugfs.h> |
|---|
| 20 | 17 | #include <linux/idr.h> |
|---|
| 18 | +#include <linux/io.h> |
|---|
| 21 | 19 | #include <linux/ioport.h> |
|---|
| 22 | 20 | #include <linux/kernel.h> |
|---|
| 23 | 21 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 27 | 25 | #include <linux/property.h> |
|---|
| 28 | 26 | #include <linux/seq_file.h> |
|---|
| 29 | 27 | #include <linux/io-64-nonatomic-lo-hi.h> |
|---|
| 28 | + |
|---|
| 29 | +#include <linux/dma/idma64.h> |
|---|
| 30 | 30 | |
|---|
| 31 | 31 | #include "intel-lpss.h" |
|---|
| 32 | 32 | |
|---|
| .. | .. |
|---|
| 47 | 47 | #define LPSS_PRIV_IDLELTR 0x14 |
|---|
| 48 | 48 | |
|---|
| 49 | 49 | #define LPSS_PRIV_LTR_REQ BIT(15) |
|---|
| 50 | | -#define LPSS_PRIV_LTR_SCALE_MASK 0xc00 |
|---|
| 51 | | -#define LPSS_PRIV_LTR_SCALE_1US 0x800 |
|---|
| 52 | | -#define LPSS_PRIV_LTR_SCALE_32US 0xc00 |
|---|
| 53 | | -#define LPSS_PRIV_LTR_VALUE_MASK 0x3ff |
|---|
| 50 | +#define LPSS_PRIV_LTR_SCALE_MASK GENMASK(11, 10) |
|---|
| 51 | +#define LPSS_PRIV_LTR_SCALE_1US (2 << 10) |
|---|
| 52 | +#define LPSS_PRIV_LTR_SCALE_32US (3 << 10) |
|---|
| 53 | +#define LPSS_PRIV_LTR_VALUE_MASK GENMASK(9, 0) |
|---|
| 54 | 54 | |
|---|
| 55 | 55 | #define LPSS_PRIV_SSP_REG 0x20 |
|---|
| 56 | 56 | #define LPSS_PRIV_SSP_REG_DIS_DMA_FIN BIT(0) |
|---|
| .. | .. |
|---|
| 59 | 59 | |
|---|
| 60 | 60 | #define LPSS_PRIV_CAPS 0xfc |
|---|
| 61 | 61 | #define LPSS_PRIV_CAPS_NO_IDMA BIT(8) |
|---|
| 62 | +#define LPSS_PRIV_CAPS_TYPE_MASK GENMASK(7, 4) |
|---|
| 62 | 63 | #define LPSS_PRIV_CAPS_TYPE_SHIFT 4 |
|---|
| 63 | | -#define LPSS_PRIV_CAPS_TYPE_MASK (0xf << LPSS_PRIV_CAPS_TYPE_SHIFT) |
|---|
| 64 | 64 | |
|---|
| 65 | 65 | /* This matches the type field in CAPS register */ |
|---|
| 66 | 66 | enum intel_lpss_dev_type { |
|---|
| .. | .. |
|---|
| 96 | 96 | DEFINE_RES_IRQ(0), |
|---|
| 97 | 97 | }; |
|---|
| 98 | 98 | |
|---|
| 99 | | -#define LPSS_IDMA64_DRIVER_NAME "idma64" |
|---|
| 100 | | - |
|---|
| 101 | 99 | /* |
|---|
| 102 | 100 | * Cells needs to be ordered so that the iDMA is created first. This is |
|---|
| 103 | 101 | * because we need to be sure the DMA is available when the host controller |
|---|
| .. | .. |
|---|
| 129 | 127 | |
|---|
| 130 | 128 | static DEFINE_IDA(intel_lpss_devid_ida); |
|---|
| 131 | 129 | static struct dentry *intel_lpss_debugfs; |
|---|
| 132 | | - |
|---|
| 133 | | -static int intel_lpss_request_dma_module(const char *name) |
|---|
| 134 | | -{ |
|---|
| 135 | | - static bool intel_lpss_dma_requested; |
|---|
| 136 | | - |
|---|
| 137 | | - if (intel_lpss_dma_requested) |
|---|
| 138 | | - return 0; |
|---|
| 139 | | - |
|---|
| 140 | | - intel_lpss_dma_requested = true; |
|---|
| 141 | | - return request_module("%s", name); |
|---|
| 142 | | -} |
|---|
| 143 | 130 | |
|---|
| 144 | 131 | static void intel_lpss_cache_ltr(struct intel_lpss *lpss) |
|---|
| 145 | 132 | { |
|---|
| .. | .. |
|---|
| 431 | 418 | dev_warn(dev, "Failed to create debugfs entries\n"); |
|---|
| 432 | 419 | |
|---|
| 433 | 420 | if (intel_lpss_has_idma(lpss)) { |
|---|
| 434 | | - /* |
|---|
| 435 | | - * Ensure the DMA driver is loaded before the host |
|---|
| 436 | | - * controller device appears, so that the host controller |
|---|
| 437 | | - * driver can request its DMA channels as early as |
|---|
| 438 | | - * possible. |
|---|
| 439 | | - * |
|---|
| 440 | | - * If the DMA module is not there that's OK as well. |
|---|
| 441 | | - */ |
|---|
| 442 | | - intel_lpss_request_dma_module(LPSS_IDMA64_DRIVER_NAME); |
|---|
| 443 | | - |
|---|
| 444 | 421 | ret = mfd_add_devices(dev, lpss->devid, &intel_lpss_idma64_cell, |
|---|
| 445 | 422 | 1, info->mem, info->irq, NULL); |
|---|
| 446 | 423 | if (ret) |
|---|
| .. | .. |
|---|
| 556 | 533 | MODULE_AUTHOR("Jarkko Nikula <jarkko.nikula@linux.intel.com>"); |
|---|
| 557 | 534 | MODULE_DESCRIPTION("Intel LPSS core driver"); |
|---|
| 558 | 535 | MODULE_LICENSE("GPL v2"); |
|---|
| 536 | +/* |
|---|
| 537 | + * Ensure the DMA driver is loaded before the host controller device appears, |
|---|
| 538 | + * so that the host controller driver can request its DMA channels as early |
|---|
| 539 | + * as possible. |
|---|
| 540 | + * |
|---|
| 541 | + * If the DMA module is not there that's OK as well. |
|---|
| 542 | + */ |
|---|
| 543 | +MODULE_SOFTDEP("pre: platform:" LPSS_IDMA64_DRIVER_NAME); |
|---|