From ff8c1af5e7ebfdf2da5d2063ee34e16a8d05643c Mon Sep 17 00:00:00 2001 From: Heikki Krogerus Date: Tue, 2 Sep 2014 10:55:07 +0300 Subject: ACPI / LPSS: introduce flags Replace the booleans with a single flags member variable. Signed-off-by: Heikki Krogerus Reviewed-by: Andy Shevchenko Acked-by: Mika Westerberg Signed-off-by: Rafael J. Wysocki --- drivers/acpi/acpi_lpss.c | 79 ++++++++++++++++++------------------------------ 1 file changed, 29 insertions(+), 50 deletions(-) (limited to 'drivers/acpi/acpi_lpss.c') diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c index 9dfec48dd4e5..4723a0e8335a 100644 --- a/drivers/acpi/acpi_lpss.c +++ b/drivers/acpi/acpi_lpss.c @@ -54,6 +54,13 @@ ACPI_MODULE_NAME("acpi_lpss"); #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 { const char *name; unsigned long rate; @@ -63,21 +70,17 @@ struct lpss_shared_clock { struct lpss_private_data; struct lpss_device_desc { - bool clk_required; const char *clkdev_name; - bool ltr_required; + unsigned int flags; unsigned int prv_offset; size_t prv_size_override; - bool clk_divider; - bool clk_gate; - bool save_ctx; struct lpss_shared_clock *shared_clock; void (*setup)(struct lpss_private_data *pdata); }; static struct lpss_device_desc lpss_dma_desc = { - .clk_required = true, .clkdev_name = "hclk", + .flags = LPSS_CLK, }; struct lpss_private_data { @@ -113,42 +116,26 @@ static void lpss_i2c_setup(struct lpss_private_data *pdata) 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 = { - .clk_required = true, + .flags = LPSS_CLK | LPSS_CLK_GATE | LPSS_CLK_DIVIDER | LPSS_LTR, .prv_offset = 0x800, - .ltr_required = true, - .clk_divider = true, - .clk_gate = true, }; static struct lpss_device_desc lpt_i2c_dev_desc = { - .clk_required = true, + .flags = LPSS_CLK | LPSS_CLK_GATE | LPSS_LTR, .prv_offset = 0x800, - .ltr_required = true, - .clk_gate = true, }; 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, - .ltr_required = true, - .clk_divider = true, - .clk_gate = true, .setup = lpss_uart_setup, }; static struct lpss_device_desc lpt_sdio_dev_desc = { + .flags = LPSS_LTR, .prv_offset = 0x1000, .prv_size_override = 0x1018, - .ltr_required = true, }; 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 = { - .clk_required = true, - .save_ctx = true, + .flags = LPSS_CLK | LPSS_SAVE_CTX, .shared_clock = &pwm_clock, }; 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, - .clk_divider = true, - .clk_gate = true, - .save_ctx = true, .setup = lpss_uart_setup, }; 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, - .clk_divider = true, - .clk_gate = true, - .save_ctx = true, }; static struct lpss_device_desc byt_sdio_dev_desc = { - .clk_required = true, + .flags = LPSS_CLK, }; 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 = { - .clk_required = true, + .flags = LPSS_CLK | LPSS_SAVE_CTX, .prv_offset = 0x800, - .save_ctx = true, .shared_clock = &i2c_clock, .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 = { - .clk_required = true, - .save_ctx = true, + .flags = LPSS_CLK | LPSS_SAVE_CTX, .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) }, { "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; } - if (dev_desc->clk_gate) { + if (dev_desc->flags & LPSS_CLK_GATE) { clk = clk_register_gate(NULL, devname, parent, 0, prv_base, 0, 0, NULL); parent = devname; } - if (dev_desc->clk_divider) { + if (dev_desc->flags & LPSS_CLK_DIVIDER) { /* Prevent division by zero */ if (!readl(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; - if (dev_desc->clk_required) { + if (dev_desc->flags & LPSS_CLK) { ret = register_device_clock(adev, pdata); if (ret) { /* Skip the device, but continue the namespace scan. */ @@ -693,19 +672,19 @@ static int acpi_lpss_platform_notify(struct notifier_block *nb, switch (action) { 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; break; case BUS_NOTIFY_UNBOUND_DRIVER: - if (pdata->dev_desc->save_ctx) + if (pdata->dev_desc->flags & LPSS_SAVE_CTX) pdev->dev.pm_domain = NULL; break; 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, &lpss_attr_group); 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); default: break; @@ -722,7 +701,7 @@ static void acpi_lpss_bind(struct device *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; if (pdata->mmio_size >= pdata->dev_desc->prv_offset + LPSS_LTR_SIZE) -- cgit v1.2.1 From b0d00f8bd526dab6878913dfd5690eee5d4be10e Mon Sep 17 00:00:00 2001 From: Heikki Krogerus Date: Tue, 2 Sep 2014 10:55:08 +0300 Subject: ACPI / LPSS: drop clkdev_name member from lpss_device_desc It was used to provide the correct con_id for the dma driver, but it's not needed. Even if the driver requests a clock with the con_id, it still gets the correct clock. The device name is enough to match a single clock. Signed-off-by: Heikki Krogerus Acked-by: Andy Shevchenko Acked-by: Mika Westerberg Signed-off-by: Rafael J. Wysocki --- drivers/acpi/acpi_lpss.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'drivers/acpi/acpi_lpss.c') diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c index 4723a0e8335a..db3498bc4c2a 100644 --- a/drivers/acpi/acpi_lpss.c +++ b/drivers/acpi/acpi_lpss.c @@ -70,7 +70,6 @@ struct lpss_shared_clock { struct lpss_private_data; struct lpss_device_desc { - const char *clkdev_name; unsigned int flags; unsigned int prv_offset; size_t prv_size_override; @@ -79,7 +78,6 @@ struct lpss_device_desc { }; static struct lpss_device_desc lpss_dma_desc = { - .clkdev_name = "hclk", .flags = LPSS_CLK, }; @@ -268,12 +266,7 @@ static int register_device_clock(struct acpi_device *adev, clk_data = platform_get_drvdata(lpss_clk_dev); if (!clk_data) return -ENODEV; - - if (dev_desc->clkdev_name) { - clk_register_clkdev(clk_data->clk, dev_desc->clkdev_name, - devname); - return 0; - } + clk = clk_data->clk; if (!pdata->mmio_base || pdata->mmio_size < dev_desc->prv_offset + LPSS_CLK_SIZE) -- cgit v1.2.1 From 03f09f73bbd805f918fdc76888a1a83cdc28f28b Mon Sep 17 00:00:00 2001 From: Heikki Krogerus Date: Tue, 2 Sep 2014 10:55:09 +0300 Subject: ACPI / LPSS: support for 133MHz I2C source clock on Baytrail The I2C controllers on Baytrail can get the clock from 100MHz or 133MHz source clock. The first bits in the private clock parameter register indicates which one is being used. Signed-off-by: Heikki Krogerus Acked-by: Mika Westerberg Signed-off-by: Rafael J. Wysocki --- drivers/acpi/acpi_lpss.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'drivers/acpi/acpi_lpss.c') diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c index db3498bc4c2a..b693098f2160 100644 --- a/drivers/acpi/acpi_lpss.c +++ b/drivers/acpi/acpi_lpss.c @@ -84,6 +84,7 @@ static struct lpss_device_desc lpss_dma_desc = { struct lpss_private_data { void __iomem *mmio_base; resource_size_t mmio_size; + unsigned int fixed_clk_rate; struct clk *clk; const struct lpss_device_desc *dev_desc; u32 prv_reg_ctx[LPSS_PRV_REG_COUNT]; @@ -103,7 +104,7 @@ static void lpss_uart_setup(struct lpss_private_data *pdata) writel(reg | LPSS_GENERAL_UART_RTS_OVRD, pdata->mmio_base + offset); } -static void lpss_i2c_setup(struct lpss_private_data *pdata) +static void byt_i2c_setup(struct lpss_private_data *pdata) { unsigned int offset; u32 val; @@ -112,6 +113,9 @@ static void lpss_i2c_setup(struct lpss_private_data *pdata) val = readl(pdata->mmio_base + offset); val |= LPSS_RESETS_RESET_APB | LPSS_RESETS_RESET_FUNC; writel(val, pdata->mmio_base + offset); + + if (readl(pdata->mmio_base + pdata->dev_desc->prv_offset)) + pdata->fixed_clk_rate = 133000000; } static struct lpss_device_desc lpt_dev_desc = { @@ -161,16 +165,10 @@ static struct lpss_device_desc byt_sdio_dev_desc = { .flags = LPSS_CLK, }; -static struct lpss_shared_clock i2c_clock = { - .name = "i2c_clk", - .rate = 100000000, -}; - static struct lpss_device_desc byt_i2c_dev_desc = { .flags = LPSS_CLK | LPSS_SAVE_CTX, .prv_offset = 0x800, - .shared_clock = &i2c_clock, - .setup = lpss_i2c_setup, + .setup = byt_i2c_setup, }; static struct lpss_shared_clock bsw_pwm_clock = { @@ -286,6 +284,12 @@ static int register_device_clock(struct acpi_device *adev, parent = shared_clock->name; } + if (pdata->fixed_clk_rate) { + clk = clk_register_fixed_rate(NULL, devname, parent, 0, + pdata->fixed_clk_rate); + goto out; + } + if (dev_desc->flags & LPSS_CLK_GATE) { clk = clk_register_gate(NULL, devname, parent, 0, prv_base, 0, 0, NULL); @@ -316,7 +320,7 @@ static int register_device_clock(struct acpi_device *adev, kfree(parent); kfree(clk_name); } - +out: if (IS_ERR(clk)) return PTR_ERR(clk); @@ -364,6 +368,9 @@ static int acpi_lpss_create_device(struct acpi_device *adev, pdata->dev_desc = dev_desc; + if (dev_desc->setup) + dev_desc->setup(pdata); + if (dev_desc->flags & LPSS_CLK) { ret = register_device_clock(adev, pdata); if (ret) { @@ -385,9 +392,6 @@ static int acpi_lpss_create_device(struct acpi_device *adev, goto err_out; } - if (dev_desc->setup) - dev_desc->setup(pdata); - adev->driver_data = pdata; pdev = acpi_create_platform_device(adev); if (!IS_ERR_OR_NULL(pdev)) { -- cgit v1.2.1 From 3f56bf3e939f0344febf92c41fbc0c26a21593c4 Mon Sep 17 00:00:00 2001 From: Heikki Krogerus Date: Tue, 2 Sep 2014 10:55:10 +0300 Subject: ACPI / LPSS: remove struct lpss_shared_clock Nothing requires it anymore. The PWM driver no longer uses clk framework to get the rate. Signed-off-by: Heikki Krogerus Reviewed-by: Andy Shevchenko Acked-by: Mika Westerberg Signed-off-by: Rafael J. Wysocki --- drivers/acpi/acpi_lpss.c | 39 ++------------------------------------- 1 file changed, 2 insertions(+), 37 deletions(-) (limited to 'drivers/acpi/acpi_lpss.c') diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c index b693098f2160..bcbdbd224c10 100644 --- a/drivers/acpi/acpi_lpss.c +++ b/drivers/acpi/acpi_lpss.c @@ -61,19 +61,12 @@ ACPI_MODULE_NAME("acpi_lpss"); #define LPSS_LTR BIT(3) #define LPSS_SAVE_CTX BIT(4) -struct lpss_shared_clock { - const char *name; - unsigned long rate; - struct clk *clk; -}; - struct lpss_private_data; struct lpss_device_desc { unsigned int flags; unsigned int prv_offset; size_t prv_size_override; - struct lpss_shared_clock *shared_clock; void (*setup)(struct lpss_private_data *pdata); }; @@ -140,14 +133,8 @@ static struct lpss_device_desc lpt_sdio_dev_desc = { .prv_size_override = 0x1018, }; -static struct lpss_shared_clock pwm_clock = { - .name = "pwm_clk", - .rate = 25000000, -}; - static struct lpss_device_desc byt_pwm_dev_desc = { - .flags = LPSS_CLK | LPSS_SAVE_CTX, - .shared_clock = &pwm_clock, + .flags = LPSS_SAVE_CTX, }; static struct lpss_device_desc byt_uart_dev_desc = { @@ -171,16 +158,6 @@ static struct lpss_device_desc byt_i2c_dev_desc = { .setup = byt_i2c_setup, }; -static struct lpss_shared_clock bsw_pwm_clock = { - .name = "pwm_clk", - .rate = 19200000, -}; - -static struct lpss_device_desc bsw_pwm_dev_desc = { - .flags = LPSS_CLK | LPSS_SAVE_CTX, - .shared_clock = &bsw_pwm_clock, -}; - #else #define LPSS_ADDR(desc) (0UL) @@ -211,7 +188,7 @@ static const struct acpi_device_id acpi_lpss_device_ids[] = { { "INT33FC", }, /* Braswell LPSS devices */ - { "80862288", LPSS_ADDR(bsw_pwm_dev_desc) }, + { "80862288", LPSS_ADDR(byt_pwm_dev_desc) }, { "8086228A", LPSS_ADDR(byt_uart_dev_desc) }, { "8086228E", LPSS_ADDR(byt_spi_dev_desc) }, { "808622C1", LPSS_ADDR(byt_i2c_dev_desc) }, @@ -251,7 +228,6 @@ static int register_device_clock(struct acpi_device *adev, struct lpss_private_data *pdata) { const struct lpss_device_desc *dev_desc = pdata->dev_desc; - struct lpss_shared_clock *shared_clock = dev_desc->shared_clock; const char *devname = dev_name(&adev->dev); struct clk *clk = ERR_PTR(-ENODEV); struct lpss_clk_data *clk_data; @@ -273,17 +249,6 @@ static int register_device_clock(struct acpi_device *adev, parent = clk_data->name; prv_base = pdata->mmio_base + dev_desc->prv_offset; - if (shared_clock) { - clk = shared_clock->clk; - if (!clk) { - clk = clk_register_fixed_rate(NULL, shared_clock->name, - "lpss_clk", 0, - shared_clock->rate); - shared_clock->clk = clk; - } - parent = shared_clock->name; - } - if (pdata->fixed_clk_rate) { clk = clk_register_fixed_rate(NULL, devname, parent, 0, pdata->fixed_clk_rate); -- cgit v1.2.1 From 1f47a77c4e4951f141bf20fe7f7c5d9438ea1663 Mon Sep 17 00:00:00 2001 From: Heikki Krogerus Date: Thu, 11 Sep 2014 15:19:33 +0300 Subject: ACPI / LPSS: not using UART RTS override with Auto Flow Control Adding a check for UART Auto Flow Control feature and only enabling the RTS override when it's not supported. RTS override is not needed when Auto Flow Control is used and they shouldn't be used together. Signed-off-by: Heikki Krogerus Signed-off-by: Rafael J. Wysocki --- drivers/acpi/acpi_lpss.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'drivers/acpi/acpi_lpss.c') diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c index 1951b5967aa9..76cc698055cd 100644 --- a/drivers/acpi/acpi_lpss.c +++ b/drivers/acpi/acpi_lpss.c @@ -83,18 +83,26 @@ struct lpss_private_data { u32 prv_reg_ctx[LPSS_PRV_REG_COUNT]; }; +/* UART Component Parameter Register */ +#define LPSS_UART_CPR 0xF4 +#define LPSS_UART_CPR_AFCE BIT(4) + static void lpss_uart_setup(struct lpss_private_data *pdata) { unsigned int offset; - u32 reg; + u32 val; offset = pdata->dev_desc->prv_offset + LPSS_TX_INT; - reg = readl(pdata->mmio_base + offset); - writel(reg | LPSS_TX_INT_MASK, pdata->mmio_base + offset); - - offset = pdata->dev_desc->prv_offset + LPSS_GENERAL; - reg = readl(pdata->mmio_base + offset); - writel(reg | LPSS_GENERAL_UART_RTS_OVRD, pdata->mmio_base + offset); + val = readl(pdata->mmio_base + offset); + writel(val | LPSS_TX_INT_MASK, pdata->mmio_base + offset); + + val = readl(pdata->mmio_base + LPSS_UART_CPR); + if (!(val & LPSS_UART_CPR_AFCE)) { + offset = pdata->dev_desc->prv_offset + LPSS_GENERAL; + val = readl(pdata->mmio_base + offset); + val |= LPSS_GENERAL_UART_RTS_OVRD; + writel(val, pdata->mmio_base + offset); + } } static void byt_i2c_setup(struct lpss_private_data *pdata) -- cgit v1.2.1