mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-16 13:34:30 +00:00
ACPI / LPSS: introduce flags
Replace the booleans with a single flags member variable. Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
parent
69e273c0b0
commit
ff8c1af5e7
@ -54,6 +54,13 @@ ACPI_MODULE_NAME("acpi_lpss");
|
|||||||
|
|
||||||
#define LPSS_PRV_REG_COUNT 9
|
#define LPSS_PRV_REG_COUNT 9
|
||||||
|
|
||||||
|
/* LPSS Flags */
|
||||||
|
#define LPSS_CLK BIT(0)
|
||||||
|
#define LPSS_CLK_GATE BIT(1)
|
||||||
|
#define LPSS_CLK_DIVIDER BIT(2)
|
||||||
|
#define LPSS_LTR BIT(3)
|
||||||
|
#define LPSS_SAVE_CTX BIT(4)
|
||||||
|
|
||||||
struct lpss_shared_clock {
|
struct lpss_shared_clock {
|
||||||
const char *name;
|
const char *name;
|
||||||
unsigned long rate;
|
unsigned long rate;
|
||||||
@ -63,21 +70,17 @@ struct lpss_shared_clock {
|
|||||||
struct lpss_private_data;
|
struct lpss_private_data;
|
||||||
|
|
||||||
struct lpss_device_desc {
|
struct lpss_device_desc {
|
||||||
bool clk_required;
|
|
||||||
const char *clkdev_name;
|
const char *clkdev_name;
|
||||||
bool ltr_required;
|
unsigned int flags;
|
||||||
unsigned int prv_offset;
|
unsigned int prv_offset;
|
||||||
size_t prv_size_override;
|
size_t prv_size_override;
|
||||||
bool clk_divider;
|
|
||||||
bool clk_gate;
|
|
||||||
bool save_ctx;
|
|
||||||
struct lpss_shared_clock *shared_clock;
|
struct lpss_shared_clock *shared_clock;
|
||||||
void (*setup)(struct lpss_private_data *pdata);
|
void (*setup)(struct lpss_private_data *pdata);
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct lpss_device_desc lpss_dma_desc = {
|
static struct lpss_device_desc lpss_dma_desc = {
|
||||||
.clk_required = true,
|
|
||||||
.clkdev_name = "hclk",
|
.clkdev_name = "hclk",
|
||||||
|
.flags = LPSS_CLK,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct lpss_private_data {
|
struct lpss_private_data {
|
||||||
@ -113,42 +116,26 @@ static void lpss_i2c_setup(struct lpss_private_data *pdata)
|
|||||||
writel(val, pdata->mmio_base + offset);
|
writel(val, pdata->mmio_base + offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct lpss_device_desc wpt_dev_desc = {
|
|
||||||
.clk_required = true,
|
|
||||||
.prv_offset = 0x800,
|
|
||||||
.ltr_required = true,
|
|
||||||
.clk_divider = true,
|
|
||||||
.clk_gate = true,
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct lpss_device_desc lpt_dev_desc = {
|
static struct lpss_device_desc lpt_dev_desc = {
|
||||||
.clk_required = true,
|
.flags = LPSS_CLK | LPSS_CLK_GATE | LPSS_CLK_DIVIDER | LPSS_LTR,
|
||||||
.prv_offset = 0x800,
|
.prv_offset = 0x800,
|
||||||
.ltr_required = true,
|
|
||||||
.clk_divider = true,
|
|
||||||
.clk_gate = true,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct lpss_device_desc lpt_i2c_dev_desc = {
|
static struct lpss_device_desc lpt_i2c_dev_desc = {
|
||||||
.clk_required = true,
|
.flags = LPSS_CLK | LPSS_CLK_GATE | LPSS_LTR,
|
||||||
.prv_offset = 0x800,
|
.prv_offset = 0x800,
|
||||||
.ltr_required = true,
|
|
||||||
.clk_gate = true,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct lpss_device_desc lpt_uart_dev_desc = {
|
static struct lpss_device_desc lpt_uart_dev_desc = {
|
||||||
.clk_required = true,
|
.flags = LPSS_CLK | LPSS_CLK_GATE | LPSS_CLK_DIVIDER | LPSS_LTR,
|
||||||
.prv_offset = 0x800,
|
.prv_offset = 0x800,
|
||||||
.ltr_required = true,
|
|
||||||
.clk_divider = true,
|
|
||||||
.clk_gate = true,
|
|
||||||
.setup = lpss_uart_setup,
|
.setup = lpss_uart_setup,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct lpss_device_desc lpt_sdio_dev_desc = {
|
static struct lpss_device_desc lpt_sdio_dev_desc = {
|
||||||
|
.flags = LPSS_LTR,
|
||||||
.prv_offset = 0x1000,
|
.prv_offset = 0x1000,
|
||||||
.prv_size_override = 0x1018,
|
.prv_size_override = 0x1018,
|
||||||
.ltr_required = true,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct lpss_shared_clock pwm_clock = {
|
static struct lpss_shared_clock pwm_clock = {
|
||||||
@ -157,30 +144,23 @@ static struct lpss_shared_clock pwm_clock = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static struct lpss_device_desc byt_pwm_dev_desc = {
|
static struct lpss_device_desc byt_pwm_dev_desc = {
|
||||||
.clk_required = true,
|
.flags = LPSS_CLK | LPSS_SAVE_CTX,
|
||||||
.save_ctx = true,
|
|
||||||
.shared_clock = &pwm_clock,
|
.shared_clock = &pwm_clock,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct lpss_device_desc byt_uart_dev_desc = {
|
static struct lpss_device_desc byt_uart_dev_desc = {
|
||||||
.clk_required = true,
|
.flags = LPSS_CLK | LPSS_CLK_GATE | LPSS_CLK_DIVIDER | LPSS_SAVE_CTX,
|
||||||
.prv_offset = 0x800,
|
.prv_offset = 0x800,
|
||||||
.clk_divider = true,
|
|
||||||
.clk_gate = true,
|
|
||||||
.save_ctx = true,
|
|
||||||
.setup = lpss_uart_setup,
|
.setup = lpss_uart_setup,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct lpss_device_desc byt_spi_dev_desc = {
|
static struct lpss_device_desc byt_spi_dev_desc = {
|
||||||
.clk_required = true,
|
.flags = LPSS_CLK | LPSS_CLK_GATE | LPSS_CLK_DIVIDER | LPSS_SAVE_CTX,
|
||||||
.prv_offset = 0x400,
|
.prv_offset = 0x400,
|
||||||
.clk_divider = true,
|
|
||||||
.clk_gate = true,
|
|
||||||
.save_ctx = true,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct lpss_device_desc byt_sdio_dev_desc = {
|
static struct lpss_device_desc byt_sdio_dev_desc = {
|
||||||
.clk_required = true,
|
.flags = LPSS_CLK,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct lpss_shared_clock i2c_clock = {
|
static struct lpss_shared_clock i2c_clock = {
|
||||||
@ -189,9 +169,8 @@ static struct lpss_shared_clock i2c_clock = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static struct lpss_device_desc byt_i2c_dev_desc = {
|
static struct lpss_device_desc byt_i2c_dev_desc = {
|
||||||
.clk_required = true,
|
.flags = LPSS_CLK | LPSS_SAVE_CTX,
|
||||||
.prv_offset = 0x800,
|
.prv_offset = 0x800,
|
||||||
.save_ctx = true,
|
|
||||||
.shared_clock = &i2c_clock,
|
.shared_clock = &i2c_clock,
|
||||||
.setup = lpss_i2c_setup,
|
.setup = lpss_i2c_setup,
|
||||||
};
|
};
|
||||||
@ -202,8 +181,7 @@ static struct lpss_shared_clock bsw_pwm_clock = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static struct lpss_device_desc bsw_pwm_dev_desc = {
|
static struct lpss_device_desc bsw_pwm_dev_desc = {
|
||||||
.clk_required = true,
|
.flags = LPSS_CLK | LPSS_SAVE_CTX,
|
||||||
.save_ctx = true,
|
|
||||||
.shared_clock = &bsw_pwm_clock,
|
.shared_clock = &bsw_pwm_clock,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -251,7 +229,8 @@ static const struct acpi_device_id acpi_lpss_device_ids[] = {
|
|||||||
{ "INT3436", LPSS_ADDR(lpt_sdio_dev_desc) },
|
{ "INT3436", LPSS_ADDR(lpt_sdio_dev_desc) },
|
||||||
{ "INT3437", },
|
{ "INT3437", },
|
||||||
|
|
||||||
{ "INT3438", LPSS_ADDR(wpt_dev_desc) },
|
/* Wildcat Point LPSS devices */
|
||||||
|
{ "INT3438", LPSS_ADDR(lpt_dev_desc) },
|
||||||
|
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
@ -314,13 +293,13 @@ static int register_device_clock(struct acpi_device *adev,
|
|||||||
parent = shared_clock->name;
|
parent = shared_clock->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dev_desc->clk_gate) {
|
if (dev_desc->flags & LPSS_CLK_GATE) {
|
||||||
clk = clk_register_gate(NULL, devname, parent, 0,
|
clk = clk_register_gate(NULL, devname, parent, 0,
|
||||||
prv_base, 0, 0, NULL);
|
prv_base, 0, 0, NULL);
|
||||||
parent = devname;
|
parent = devname;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dev_desc->clk_divider) {
|
if (dev_desc->flags & LPSS_CLK_DIVIDER) {
|
||||||
/* Prevent division by zero */
|
/* Prevent division by zero */
|
||||||
if (!readl(prv_base))
|
if (!readl(prv_base))
|
||||||
writel(LPSS_CLK_DIVIDER_DEF_MASK, prv_base);
|
writel(LPSS_CLK_DIVIDER_DEF_MASK, prv_base);
|
||||||
@ -392,7 +371,7 @@ static int acpi_lpss_create_device(struct acpi_device *adev,
|
|||||||
|
|
||||||
pdata->dev_desc = dev_desc;
|
pdata->dev_desc = dev_desc;
|
||||||
|
|
||||||
if (dev_desc->clk_required) {
|
if (dev_desc->flags & LPSS_CLK) {
|
||||||
ret = register_device_clock(adev, pdata);
|
ret = register_device_clock(adev, pdata);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
/* Skip the device, but continue the namespace scan. */
|
/* Skip the device, but continue the namespace scan. */
|
||||||
@ -693,19 +672,19 @@ static int acpi_lpss_platform_notify(struct notifier_block *nb,
|
|||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case BUS_NOTIFY_BOUND_DRIVER:
|
case BUS_NOTIFY_BOUND_DRIVER:
|
||||||
if (pdata->dev_desc->save_ctx)
|
if (pdata->dev_desc->flags & LPSS_SAVE_CTX)
|
||||||
pdev->dev.pm_domain = &acpi_lpss_pm_domain;
|
pdev->dev.pm_domain = &acpi_lpss_pm_domain;
|
||||||
break;
|
break;
|
||||||
case BUS_NOTIFY_UNBOUND_DRIVER:
|
case BUS_NOTIFY_UNBOUND_DRIVER:
|
||||||
if (pdata->dev_desc->save_ctx)
|
if (pdata->dev_desc->flags & LPSS_SAVE_CTX)
|
||||||
pdev->dev.pm_domain = NULL;
|
pdev->dev.pm_domain = NULL;
|
||||||
break;
|
break;
|
||||||
case BUS_NOTIFY_ADD_DEVICE:
|
case BUS_NOTIFY_ADD_DEVICE:
|
||||||
if (pdata->dev_desc->ltr_required)
|
if (pdata->dev_desc->flags & LPSS_LTR)
|
||||||
return sysfs_create_group(&pdev->dev.kobj,
|
return sysfs_create_group(&pdev->dev.kobj,
|
||||||
&lpss_attr_group);
|
&lpss_attr_group);
|
||||||
case BUS_NOTIFY_DEL_DEVICE:
|
case BUS_NOTIFY_DEL_DEVICE:
|
||||||
if (pdata->dev_desc->ltr_required)
|
if (pdata->dev_desc->flags & LPSS_LTR)
|
||||||
sysfs_remove_group(&pdev->dev.kobj, &lpss_attr_group);
|
sysfs_remove_group(&pdev->dev.kobj, &lpss_attr_group);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -722,7 +701,7 @@ static void acpi_lpss_bind(struct device *dev)
|
|||||||
{
|
{
|
||||||
struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
|
struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
|
||||||
|
|
||||||
if (!pdata || !pdata->mmio_base || !pdata->dev_desc->ltr_required)
|
if (!pdata || !pdata->mmio_base || !(pdata->dev_desc->flags & LPSS_LTR))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (pdata->mmio_size >= pdata->dev_desc->prv_offset + LPSS_LTR_SIZE)
|
if (pdata->mmio_size >= pdata->dev_desc->prv_offset + LPSS_LTR_SIZE)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user