From 374de1642ee4322cc4d6aa1d2679378b8547c368 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Wed, 13 Aug 2014 11:27:34 +0100 Subject: iio: sensors-core: st: Check st_sensors_set_drdy_int_pin()'s return value Value from st_sensors_set_drdy_int_pin() is assigned to err here, but that stored value is not used before it is overwritten. To fix this we're enforcing a check on st_sensors_set_drdy_int_pin()'s return value and if it's an error, we're returning right away. Cc: jic23@kernel.org Cc: linux-iio@vger.kernel.org Signed-off-by: Lee Jones --- drivers/iio/common/st_sensors/st_sensors_core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c index 8a4ec00a91a0..24cfe4e044f9 100644 --- a/drivers/iio/common/st_sensors/st_sensors_core.c +++ b/drivers/iio/common/st_sensors/st_sensors_core.c @@ -306,8 +306,11 @@ int st_sensors_init_sensor(struct iio_dev *indio_dev, if (of_pdata) pdata = of_pdata; - if (pdata) + if (pdata) { err = st_sensors_set_drdy_int_pin(indio_dev, pdata); + if (err < 0) + return err; + } err = st_sensors_set_enable(indio_dev, false); if (err < 0) -- cgit v1.2.3 From 4001998a43f4791b6e6c06df563f5d5bb3fbe4fb Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Wed, 13 Aug 2014 12:23:10 +0100 Subject: misc: st_core: Protect unsigned value against becoming negative Coverity reported: This less-than-zero comparison of an unsigned value is never true. In answer to that, we only ever decrement if protos_registered is positive. We can subsequently remove the paranoid checking during unregister. Cc: gregkh@linuxfoundation.org Signed-off-by: Lee Jones --- drivers/misc/ti-st/st_core.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/misc/ti-st/st_core.c b/drivers/misc/ti-st/st_core.c index 1972d57aadb3..54be83d3efdd 100644 --- a/drivers/misc/ti-st/st_core.c +++ b/drivers/misc/ti-st/st_core.c @@ -153,8 +153,9 @@ static void st_reg_complete(struct st_data_s *st_gdata, char err) (st_gdata->list[i]->priv_data, err); pr_info("protocol %d's cb sent %d\n", i, err); if (err) { /* cleanup registered protocol */ - st_gdata->protos_registered--; st_gdata->is_registered[i] = false; + if (st_gdata->protos_registered) + st_gdata->protos_registered--; } } } @@ -639,14 +640,12 @@ long st_unregister(struct st_proto_s *proto) return -EPROTONOSUPPORT; } - st_gdata->protos_registered--; + if (st_gdata->protos_registered) + st_gdata->protos_registered--; + remove_channel_from_table(st_gdata, proto); spin_unlock_irqrestore(&st_gdata->lock, flags); - /* paranoid check */ - if (st_gdata->protos_registered < ST_EMPTY) - st_gdata->protos_registered = ST_EMPTY; - if ((st_gdata->protos_registered == ST_EMPTY) && (!test_bit(ST_REG_PENDING, &st_gdata->st_state))) { pr_info(" all chnl_ids unregistered "); -- cgit v1.2.3 From fe4b7ea8e7c1f03601f6521c24898a688e565626 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Wed, 13 Aug 2014 13:48:27 +0100 Subject: mfd: htc-i2cpld: container_of() cannot return NULL Logically dead code (DEADCODE) dead_error_line: Execution cannot reach this statement: return; Remove the check for NULL. Signed-off-by: Lee Jones --- drivers/mfd/htc-i2cpld.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/mfd/htc-i2cpld.c b/drivers/mfd/htc-i2cpld.c index b44f0203983b..8e3ea076568e 100644 --- a/drivers/mfd/htc-i2cpld.c +++ b/drivers/mfd/htc-i2cpld.c @@ -227,13 +227,10 @@ static irqreturn_t htcpld_handler(int irq, void *dev) static void htcpld_chip_set(struct gpio_chip *chip, unsigned offset, int val) { struct i2c_client *client; - struct htcpld_chip *chip_data; + struct htcpld_chip *chip_data = + container_of(chip, struct htcpld_chip, chip_out); unsigned long flags; - chip_data = container_of(chip, struct htcpld_chip, chip_out); - if (!chip_data) - return; - client = chip_data->client; if (client == NULL) return; -- cgit v1.2.3 From 41cc08e955187b96867fa0f625c55496961699ba Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Wed, 13 Aug 2014 13:52:27 +0100 Subject: mfd: htc-i2cpld: Use '!variable' instead of 'variable == NULL' This aids in consistency, as the rest of the checks in the file use this notation. Signed-off-by: Lee Jones --- drivers/mfd/htc-i2cpld.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/mfd/htc-i2cpld.c b/drivers/mfd/htc-i2cpld.c index 8e3ea076568e..073e1801cdab 100644 --- a/drivers/mfd/htc-i2cpld.c +++ b/drivers/mfd/htc-i2cpld.c @@ -232,7 +232,7 @@ static void htcpld_chip_set(struct gpio_chip *chip, unsigned offset, int val) unsigned long flags; client = chip_data->client; - if (client == NULL) + if (!client) return; spin_lock_irqsave(&chip_data->lock, flags); @@ -373,7 +373,7 @@ static int htcpld_register_chip_i2c( plat_chip_data = &pdata->chip[chip_index]; adapter = i2c_get_adapter(pdata->i2c_adapter_id); - if (adapter == NULL) { + if (!adapter) { /* Eek, no such I2C adapter! Bail out. */ dev_warn(dev, "Chip at i2c address 0x%x: Invalid i2c adapter %d\n", plat_chip_data->addr, pdata->i2c_adapter_id); -- cgit v1.2.3 From 9b6a5ad9da4118e8c2a087501ddff33f51a9e6ba Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 18 Aug 2014 13:10:20 +0100 Subject: mfd: htc-i2cpld: Rectify pointer offset error Checking the result of container_of() against NULL will always result to false. Using the offset of member 'chip_out' to find the start of 'struct htcpld_chip' will result in an offset error when .get_chip() is attempting to obtain 'htcpld-in'. Instead, we'll use the correct member based on a previously the set chip label. Signed-off-by: Lee Jones --- drivers/mfd/htc-i2cpld.c | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) (limited to 'drivers') diff --git a/drivers/mfd/htc-i2cpld.c b/drivers/mfd/htc-i2cpld.c index 073e1801cdab..99b362e43329 100644 --- a/drivers/mfd/htc-i2cpld.c +++ b/drivers/mfd/htc-i2cpld.c @@ -258,31 +258,18 @@ static void htcpld_chip_set_ni(struct work_struct *work) static int htcpld_chip_get(struct gpio_chip *chip, unsigned offset) { struct htcpld_chip *chip_data; - int val = 0; - int is_input = 0; - - /* Try out first */ - chip_data = container_of(chip, struct htcpld_chip, chip_out); - if (!chip_data) { - /* Try in */ - is_input = 1; - chip_data = container_of(chip, struct htcpld_chip, chip_in); - if (!chip_data) - return -EINVAL; - } + u8 cache; - /* Determine if this is an input or output GPIO */ - if (!is_input) - /* Use the output cache */ - val = (chip_data->cache_out >> offset) & 1; - else - /* Use the input cache */ - val = (chip_data->cache_in >> offset) & 1; + if (!strncmp(chip->label, "htcpld-out", 10)) { + chip_data = container_of(chip, struct htcpld_chip, chip_out); + cache = chip_data->cache_out; + } else if (!strncmp(chip->label, "htcpld-in", 9)) { + chip_data = container_of(chip, struct htcpld_chip, chip_in); + cache = chip_data->cache_in; + } else + return -EINVAL; - if (val) - return 1; - else - return 0; + return (cache >> offset) & 1; } static int htcpld_direction_output(struct gpio_chip *chip, -- cgit v1.2.3 From 616e047992a4621a09ef45182076ff09b2495dec Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 18 Aug 2014 15:05:01 +0100 Subject: mfd: wm5102: Insert missing break in case statement Chip identifier wm5102_reva_patch is always overwritten with wm5102_revb_patch, even when the code is run on a Rev-A chip. Place in the missing break to force the code into doing something sensible instead. Signed-off-by: Lee Jones --- drivers/mfd/wm5102-tables.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/mfd/wm5102-tables.c b/drivers/mfd/wm5102-tables.c index fb4d4bb0f47d..a219888d7f4b 100644 --- a/drivers/mfd/wm5102-tables.c +++ b/drivers/mfd/wm5102-tables.c @@ -87,6 +87,7 @@ int wm5102_patch(struct arizona *arizona) case 0: wm5102_patch = wm5102_reva_patch; patch_size = ARRAY_SIZE(wm5102_reva_patch); + break; default: wm5102_patch = wm5102_revb_patch; patch_size = ARRAY_SIZE(wm5102_revb_patch); -- cgit v1.2.3 From b87d9a0fed5828e6cca4c3b02eacbc9c12a9a8e8 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 18 Aug 2014 15:41:59 +0100 Subject: mfd: max77686: Remove check which is always true As 'reg' is unsigned, it can't be less than 0, so checking if it is greater than or equal to 0 will always result in a true condition. Signed-off-by: Lee Jones --- drivers/mfd/max77686.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/mfd/max77686.c b/drivers/mfd/max77686.c index 86e552348db4..929795eae9fc 100644 --- a/drivers/mfd/max77686.c +++ b/drivers/mfd/max77686.c @@ -52,7 +52,7 @@ static const struct mfd_cell max77802_devs[] = { static bool max77802_pmic_is_accessible_reg(struct device *dev, unsigned int reg) { - return (reg >= MAX77802_REG_DEVICE_ID && reg < MAX77802_REG_PMIC_END); + return reg < MAX77802_REG_PMIC_END; } static bool max77802_rtc_is_accessible_reg(struct device *dev, -- cgit v1.2.3 From cddc11412d604ad673709e91e7a35e9f10c68b39 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 18 Aug 2014 15:54:06 +0100 Subject: mfd: pcf50633: Check return value of platform_device_add() The return value of platform_device_add() is checked after every other use throughout the kernel. We're also sliding in another cheeky dev_err() => dev_warn() change as we're not actually erroring out here, rather reporting the fact that something's gone wrong, but carrying on regardless. Signed-off-by: Lee Jones --- drivers/mfd/pcf50633-core.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'drivers') diff --git a/drivers/mfd/pcf50633-core.c b/drivers/mfd/pcf50633-core.c index c87f7a0a53f8..e15c060d2dc7 100644 --- a/drivers/mfd/pcf50633-core.c +++ b/drivers/mfd/pcf50633-core.c @@ -195,8 +195,9 @@ static int pcf50633_probe(struct i2c_client *client, const struct i2c_device_id *ids) { struct pcf50633 *pcf; + struct platform_device *pdev; struct pcf50633_platform_data *pdata = dev_get_platdata(&client->dev); - int i, ret; + int i, j, ret; int version, variant; if (!client->irq) { @@ -243,9 +244,6 @@ static int pcf50633_probe(struct i2c_client *client, for (i = 0; i < PCF50633_NUM_REGULATORS; i++) { - struct platform_device *pdev; - int j; - pdev = platform_device_alloc("pcf50633-regulator", i); if (!pdev) return -ENOMEM; @@ -253,25 +251,31 @@ static int pcf50633_probe(struct i2c_client *client, pdev->dev.parent = pcf->dev; ret = platform_device_add_data(pdev, &pdata->reg_init_data[i], sizeof(pdata->reg_init_data[i])); - if (ret) { - platform_device_put(pdev); - for (j = 0; j < i; j++) - platform_device_put(pcf->regulator_pdev[j]); - return ret; - } - pcf->regulator_pdev[i] = pdev; + if (ret) + goto err; + + ret = platform_device_add(pdev); + if (ret) + goto err; - platform_device_add(pdev); + pcf->regulator_pdev[i] = pdev; } ret = sysfs_create_group(&client->dev.kobj, &pcf_attr_group); if (ret) - dev_err(pcf->dev, "error creating sysfs entries\n"); + dev_warn(pcf->dev, "error creating sysfs entries\n"); if (pdata->probe_done) pdata->probe_done(pcf); return 0; + +err: + platform_device_put(pdev); + for (j = 0; j < i; j++) + platform_device_put(pcf->regulator_pdev[j]); + + return ret; } static int pcf50633_remove(struct i2c_client *client) -- cgit v1.2.3 From 8a012ff9d8723fdf7ea242f0f41703eed7365b79 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 18 Aug 2014 16:03:14 +0100 Subject: mfd: twl4030-irq: Check return value from twl_i2c_write() - warn() on failure In the original code a return value variable was provided, but it was never checked and the user was never informed of failure. Now it is and they are. Signed-off-by: Lee Jones --- drivers/mfd/twl4030-irq.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c index b1dabba763cf..1b772ef761cb 100644 --- a/drivers/mfd/twl4030-irq.c +++ b/drivers/mfd/twl4030-irq.c @@ -396,13 +396,17 @@ static int twl4030_init_sih_modules(unsigned line) status = twl_i2c_read(sih->module, rxbuf, sih->mask[line].isr_offset, sih->bytes_ixr); if (status < 0) - pr_err("twl4030: err %d initializing %s %s\n", + pr_warn("twl4030: err %d initializing %s %s\n", status, sih->name, "ISR"); - if (!sih->set_cor) + if (!sih->set_cor) { status = twl_i2c_write(sih->module, buf, sih->mask[line].isr_offset, sih->bytes_ixr); + if (status < 0) + pr_warn("twl4030: write failed: %d\n", + status); + } /* * else COR=1 means read sufficed. * (for most SIH modules...) -- cgit v1.2.3 From 5f114ebcee681b011e8b5bcd2b24169b85286050 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 18 Aug 2014 16:11:27 +0100 Subject: mfd: sm501: Avoid implicit sign extension Suspicious implicit sign extension where 'reg' (unsigned char) is promoted in reg << clksrc to int, then sign-extended to unsigned long. If reg << clksrc is greater than 0x7FFFFFFF, the upper bits of the result will all be 1. Signed-off-by: Lee Jones --- drivers/mfd/sm501.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c index 81e6d0932bf0..1f9233bf4c3e 100644 --- a/drivers/mfd/sm501.c +++ b/drivers/mfd/sm501.c @@ -514,9 +514,9 @@ unsigned long sm501_set_clock(struct device *dev, unsigned long mode = smc501_readl(sm->regs + SM501_POWER_MODE_CONTROL); unsigned long gate = smc501_readl(sm->regs + SM501_CURRENT_GATE); unsigned long clock = smc501_readl(sm->regs + SM501_CURRENT_CLOCK); - unsigned char reg; unsigned int pll_reg = 0; unsigned long sm501_freq; /* the actual frequency achieved */ + u64 reg; struct sm501_clock to; -- cgit v1.2.3 From 7821d9b24bf73eee7a4e3e3744f05c6eee88db48 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 22 Aug 2014 10:09:27 +0100 Subject: mfd: wm8994: Export symbols ready for built-in => modular build We'd like to be able to build the WM8994 family as modules, but the build will fail if the external symbols aren't exported first. Acked-by: Charles Keepax Signed-off-by: Lee Jones --- drivers/mfd/wm8994-irq.c | 2 ++ drivers/mfd/wm8994-regmap.c | 4 ++++ 2 files changed, 6 insertions(+) (limited to 'drivers') diff --git a/drivers/mfd/wm8994-irq.c b/drivers/mfd/wm8994-irq.c index e74dedda5b55..a14407edbd89 100644 --- a/drivers/mfd/wm8994-irq.c +++ b/drivers/mfd/wm8994-irq.c @@ -262,8 +262,10 @@ int wm8994_irq_init(struct wm8994 *wm8994) return 0; } +EXPORT_SYMBOL(wm8994_irq_init); void wm8994_irq_exit(struct wm8994 *wm8994) { regmap_del_irq_chip(wm8994->irq, wm8994->irq_data); } +EXPORT_SYMBOL(wm8994_irq_exit); diff --git a/drivers/mfd/wm8994-regmap.c b/drivers/mfd/wm8994-regmap.c index 770a25696468..300e9b6a2e96 100644 --- a/drivers/mfd/wm8994-regmap.c +++ b/drivers/mfd/wm8994-regmap.c @@ -1252,6 +1252,7 @@ struct regmap_config wm1811_regmap_config = { .volatile_reg = wm1811_volatile_register, .readable_reg = wm1811_readable_register, }; +EXPORT_SYMBOL(wm1811_regmap_config); struct regmap_config wm8994_regmap_config = { .reg_bits = 16, @@ -1266,6 +1267,7 @@ struct regmap_config wm8994_regmap_config = { .volatile_reg = wm8994_volatile_register, .readable_reg = wm8994_readable_register, }; +EXPORT_SYMBOL(wm8994_regmap_config); struct regmap_config wm8958_regmap_config = { .reg_bits = 16, @@ -1280,8 +1282,10 @@ struct regmap_config wm8958_regmap_config = { .volatile_reg = wm8958_volatile_register, .readable_reg = wm8958_readable_register, }; +EXPORT_SYMBOL(wm8958_regmap_config); struct regmap_config wm8994_base_regmap_config = { .reg_bits = 16, .val_bits = 16, }; +EXPORT_SYMBOL(wm8994_base_regmap_config); -- cgit v1.2.3 From e0c8a1f52d0d3dc5f79ce04d7bf6da0782dcee16 Mon Sep 17 00:00:00 2001 From: Himangi Saraogi Date: Sat, 9 Aug 2014 22:10:27 +0530 Subject: mfd: menelaus: Remove null pointer dereference If vtg is NULL, it is not possible to access its mode_reg field. At all sites where the static function menelaus_set_voltage is called, the first argument is the address of a structure defined in the file. So, the null test is unnecessary and is removed. Also, a label is done away with. This problem was found using the following Coccinelle semantic match: // @@ expression E, E1; identifier f; statement S1,S2,S3; @@ * if (E == NULL) { ... when != if (E == NULL) S1 else S2 when != E = E1 * E->f ... when any return ...; } else S3 // Signed-off-by: Himangi Saraogi Acked-by: Julia Lawall Signed-off-by: Lee Jones --- drivers/mfd/menelaus.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers') diff --git a/drivers/mfd/menelaus.c b/drivers/mfd/menelaus.c index 5e2667afe2bc..18ff56f3b52a 100644 --- a/drivers/mfd/menelaus.c +++ b/drivers/mfd/menelaus.c @@ -466,8 +466,6 @@ static int menelaus_set_voltage(const struct menelaus_vtg *vtg, int mV, struct i2c_client *c = the_menelaus->client; mutex_lock(&the_menelaus->lock); - if (!vtg) - goto set_voltage; ret = menelaus_read_reg(vtg->vtg_reg); if (ret < 0) @@ -482,7 +480,6 @@ static int menelaus_set_voltage(const struct menelaus_vtg *vtg, int mV, ret = menelaus_write_reg(vtg->vtg_reg, val); if (ret < 0) goto out; -set_voltage: ret = menelaus_write_reg(vtg->mode_reg, mode); out: mutex_unlock(&the_menelaus->lock); -- cgit v1.2.3 From 6052d83e716fde1af22a1b812b141e373153735e Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Thu, 31 Jul 2014 15:41:30 +0100 Subject: mfd: wm8994: Allow modular build The interfaces that used to be built in only (interrupts IIRC) no longer are so allow the driver to be built as a module fixing arm64 allmodconfig builds. Signed-off-by: Mark Brown Acked-by: Charles Keepax Signed-off-by: Lee Jones --- drivers/mfd/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index cf66ef1ffaf3..fc419da8d722 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -1243,11 +1243,11 @@ config MFD_WM8350_I2C selected to enable support for the functionality of the chip. config MFD_WM8994 - bool "Wolfson Microelectronics WM8994" + tristate "Wolfson Microelectronics WM8994" select MFD_CORE select REGMAP_I2C select REGMAP_IRQ - depends on I2C=y + depends on I2C help The WM8994 is a highly integrated hi-fi CODEC designed for smartphone applicatiosn. As well as audio functionality it -- cgit v1.2.3 From f2b86781619c0822b4e0b561ef9aa499b5ed76ff Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Wed, 6 Aug 2014 22:12:15 +0200 Subject: mfd: twl6040: Fix error return code Convert a zero return value on error to a negative one, as returned elsewhere in the function. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // ( if@p1 (\(ret < 0\|ret != 0\)) { ... return ret; } | ret@p1 = 0 ) ... when != ret = e1 when != &ret *if(...) { ... when != ret = e2 when forall return ret; } // Signed-off-by: Julia Lawall Signed-off-by: Lee Jones --- drivers/mfd/twl6040.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/mfd/twl6040.c b/drivers/mfd/twl6040.c index f9c06c542a41..9687645162ae 100644 --- a/drivers/mfd/twl6040.c +++ b/drivers/mfd/twl6040.c @@ -679,6 +679,7 @@ static int twl6040_probe(struct i2c_client *client, if (twl6040->rev < 0) { dev_err(&client->dev, "Failed to read revision register: %d\n", twl6040->rev); + ret = twl6040->rev; goto gpio_err; } -- cgit v1.2.3 From 5e9bbf17b35f89f31e6b76b4810d8c772621c153 Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Tue, 5 Aug 2014 21:42:28 -0700 Subject: mfd: rtsx_usb: Fix decimal printf format specifiers prefixed with 0x The prefix suggests the number should be printed in hex, so use the %x specifier to do that. Found by using regex suggested by Joe Perches. Signed-off-by: Hans Wennborg Signed-off-by: Lee Jones --- drivers/mfd/rtsx_usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/mfd/rtsx_usb.c b/drivers/mfd/rtsx_usb.c index 71f387ce8cbd..9cf98d142d9a 100644 --- a/drivers/mfd/rtsx_usb.c +++ b/drivers/mfd/rtsx_usb.c @@ -684,7 +684,7 @@ static int rtsx_usb_suspend(struct usb_interface *intf, pm_message_t message) struct rtsx_ucr *ucr = (struct rtsx_ucr *)usb_get_intfdata(intf); - dev_dbg(&intf->dev, "%s called with pm message 0x%04u\n", + dev_dbg(&intf->dev, "%s called with pm message 0x%04x\n", __func__, message.event); /* -- cgit v1.2.3 From 48018943eb906d81e48f40675c17b92abfeafcf1 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 13 Aug 2014 11:42:46 +0100 Subject: mfd: wm5102: Mark register write sequencer control 3 readable During init the core checks if the wm5102 has finished starting by reading register 0x19 and looking at the value. This read always fails since this is not a readable register, mark it as being one. While we're at it provide a constant for the register name (as supplied by Charles Keepax). Signed-off-by: Mark Brown Signed-off-by: Charles Keepax Signed-off-by: Lee Jones --- drivers/mfd/arizona-core.c | 3 ++- drivers/mfd/wm5102-tables.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c index 10a0cb90619a..7eabc36b97c1 100644 --- a/drivers/mfd/arizona-core.c +++ b/drivers/mfd/arizona-core.c @@ -784,7 +784,8 @@ int arizona_dev_init(struct arizona *arizona) /* Ensure device startup is complete */ switch (arizona->type) { case WM5102: - ret = regmap_read(arizona->regmap, 0x19, &val); + ret = regmap_read(arizona->regmap, + ARIZONA_WRITE_SEQUENCER_CTRL_3, &val); if (ret != 0) dev_err(dev, "Failed to check write sequencer state: %d\n", diff --git a/drivers/mfd/wm5102-tables.c b/drivers/mfd/wm5102-tables.c index a219888d7f4b..77e16e59a45d 100644 --- a/drivers/mfd/wm5102-tables.c +++ b/drivers/mfd/wm5102-tables.c @@ -1017,6 +1017,7 @@ static bool wm5102_readable_register(struct device *dev, unsigned int reg) case ARIZONA_WRITE_SEQUENCER_CTRL_0: case ARIZONA_WRITE_SEQUENCER_CTRL_1: case ARIZONA_WRITE_SEQUENCER_CTRL_2: + case ARIZONA_WRITE_SEQUENCER_CTRL_3: case ARIZONA_WRITE_SEQUENCER_PROM: case ARIZONA_TONE_GENERATOR_1: case ARIZONA_TONE_GENERATOR_2: -- cgit v1.2.3 From e569d937af96bc1ec00e33285fff33ae9c1e42d6 Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Wed, 13 Aug 2014 11:42:47 +0100 Subject: mfd: arizona: Mark additional registers as volatile Mark some additional registers as volatile. The write sequencer control registers should not be cached, as we don't ever want their value synchronised as this might cause a write sequence to be accidentally initiated. Additionally, the DAC_COMP registers require special preconditions to write so there values wouldn't be updated accurately during a register sync. Signed-off-by: Charles Keepax Signed-off-by: Lee Jones --- drivers/mfd/wm5102-tables.c | 11 ++++++++--- drivers/mfd/wm5110-tables.c | 6 +++--- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/mfd/wm5102-tables.c b/drivers/mfd/wm5102-tables.c index 77e16e59a45d..6d9b7f832bf5 100644 --- a/drivers/mfd/wm5102-tables.c +++ b/drivers/mfd/wm5102-tables.c @@ -246,9 +246,6 @@ const struct regmap_irq_chip wm5102_irq = { static const struct reg_default wm5102_reg_default[] = { { 0x00000008, 0x0019 }, /* R8 - Ctrl IF SPI CFG 1 */ { 0x00000009, 0x0001 }, /* R9 - Ctrl IF I2C1 CFG 1 */ - { 0x00000016, 0x0000 }, /* R22 - Write Sequencer Ctrl 0 */ - { 0x00000017, 0x0000 }, /* R23 - Write Sequencer Ctrl 1 */ - { 0x00000018, 0x0000 }, /* R24 - Write Sequencer Ctrl 2 */ { 0x00000020, 0x0000 }, /* R32 - Tone Generator 1 */ { 0x00000021, 0x1000 }, /* R33 - Tone Generator 2 */ { 0x00000022, 0x0000 }, /* R34 - Tone Generator 3 */ @@ -1882,6 +1879,10 @@ static bool wm5102_volatile_register(struct device *dev, unsigned int reg) switch (reg) { case ARIZONA_SOFTWARE_RESET: case ARIZONA_DEVICE_REVISION: + case ARIZONA_WRITE_SEQUENCER_CTRL_0: + case ARIZONA_WRITE_SEQUENCER_CTRL_1: + case ARIZONA_WRITE_SEQUENCER_CTRL_2: + case ARIZONA_WRITE_SEQUENCER_CTRL_3: case ARIZONA_OUTPUT_STATUS_1: case ARIZONA_RAW_OUTPUT_STATUS_1: case ARIZONA_SLIMBUS_RX_PORT_STATUS: @@ -1893,6 +1894,10 @@ static bool wm5102_volatile_register(struct device *dev, unsigned int reg) case ARIZONA_ASYNC_SAMPLE_RATE_1_STATUS: case ARIZONA_FLL1_NCO_TEST_0: case ARIZONA_FLL2_NCO_TEST_0: + case ARIZONA_DAC_COMP_1: + case ARIZONA_DAC_COMP_2: + case ARIZONA_DAC_COMP_3: + case ARIZONA_DAC_COMP_4: case ARIZONA_FX_CTRL2: case ARIZONA_INTERRUPT_STATUS_1: case ARIZONA_INTERRUPT_STATUS_2: diff --git a/drivers/mfd/wm5110-tables.c b/drivers/mfd/wm5110-tables.c index 9b98ee559188..beae0a397ee1 100644 --- a/drivers/mfd/wm5110-tables.c +++ b/drivers/mfd/wm5110-tables.c @@ -666,9 +666,6 @@ static const struct reg_default wm5110_reg_default[] = { { 0x0000000A, 0x0001 }, /* R10 - Ctrl IF I2C2 CFG 1 */ { 0x0000000B, 0x0036 }, /* R11 - Ctrl IF I2C1 CFG 2 */ { 0x0000000C, 0x0036 }, /* R12 - Ctrl IF I2C2 CFG 2 */ - { 0x00000016, 0x0000 }, /* R22 - Write Sequencer Ctrl 0 */ - { 0x00000017, 0x0000 }, /* R23 - Write Sequencer Ctrl 1 */ - { 0x00000018, 0x0000 }, /* R24 - Write Sequencer Ctrl 2 */ { 0x00000020, 0x0000 }, /* R32 - Tone Generator 1 */ { 0x00000021, 0x1000 }, /* R33 - Tone Generator 2 */ { 0x00000022, 0x0000 }, /* R34 - Tone Generator 3 */ @@ -2815,6 +2812,9 @@ static bool wm5110_volatile_register(struct device *dev, unsigned int reg) switch (reg) { case ARIZONA_SOFTWARE_RESET: case ARIZONA_DEVICE_REVISION: + case ARIZONA_WRITE_SEQUENCER_CTRL_0: + case ARIZONA_WRITE_SEQUENCER_CTRL_1: + case ARIZONA_WRITE_SEQUENCER_CTRL_2: case ARIZONA_HAPTICS_STATUS: case ARIZONA_SAMPLE_RATE_1_STATUS: case ARIZONA_SAMPLE_RATE_2_STATUS: -- cgit v1.2.3 From 2a3377ee2d8ca15ba21caf1d420cfeaf3ba4390a Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Tue, 12 Aug 2014 14:51:22 +0100 Subject: mfd: arizona: Avoid use of legacy IRQ mapping regmap_add_irq_chip is called from arizona_irq_init with the irq_base specified as -1 and regmap_add_irq_chip uses if (irq_base) to check if it should use legacy IRQ mapping. As such the irq mappings are currently added with irq_domain_add_legacy, rather than irq_domain_add_linear. This is clearly a typo as there is no reason why this driver can't use irq_domain_add_linear. This patch corrects this by passing the irq_base as zero to regmap_add_irq_chip. Signed-off-by: Charles Keepax Signed-off-by: Lee Jones --- drivers/mfd/arizona-irq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/mfd/arizona-irq.c b/drivers/mfd/arizona-irq.c index d420dbc0e2b0..9133d519b020 100644 --- a/drivers/mfd/arizona-irq.c +++ b/drivers/mfd/arizona-irq.c @@ -282,7 +282,7 @@ int arizona_irq_init(struct arizona *arizona) ret = regmap_add_irq_chip(arizona->regmap, irq_create_mapping(arizona->virq, 0), - IRQF_ONESHOT, -1, aod, + IRQF_ONESHOT, 0, aod, &arizona->aod_irq_chip); if (ret != 0) { dev_err(arizona->dev, "Failed to add AOD IRQs: %d\n", ret); @@ -291,7 +291,7 @@ int arizona_irq_init(struct arizona *arizona) ret = regmap_add_irq_chip(arizona->regmap, irq_create_mapping(arizona->virq, 1), - IRQF_ONESHOT, -1, irq, + IRQF_ONESHOT, 0, irq, &arizona->irq_chip); if (ret != 0) { dev_err(arizona->dev, "Failed to add main IRQs: %d\n", ret); -- cgit v1.2.3 From 42a71ef97b7ac31ae8f929c36048fec5cd201a49 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Thu, 21 Aug 2014 07:06:06 -0500 Subject: mfd: menelaus: Fix error return code Convert a zero return value on error to a negative one, as returned elsewhere in the function. Additionally, converted 1 << 7 to BIT(7) at the suggestion of Lee Jones. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // ( if@p1 (\(ret < 0\|ret != 0\)) { ... return ret; } | ret@p1 = 0 ) ... when != ret = e1 when != &ret *if(...) { ... when != ret = e2 when forall return ret; } // Signed-off-by: Julia Lawall Signed-off-by: Lee Jones --- drivers/mfd/menelaus.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/mfd/menelaus.c b/drivers/mfd/menelaus.c index 18ff56f3b52a..9f01aef539dd 100644 --- a/drivers/mfd/menelaus.c +++ b/drivers/mfd/menelaus.c @@ -1183,7 +1183,7 @@ static int menelaus_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct menelaus_chip *menelaus; - int rev = 0, val; + int rev = 0; int err = 0; struct menelaus_platform_data *menelaus_pdata = dev_get_platdata(&client->dev); @@ -1236,10 +1236,10 @@ static int menelaus_probe(struct i2c_client *client, pr_info("Menelaus rev %d.%d\n", rev >> 4, rev & 0x0f); - val = menelaus_read_reg(MENELAUS_VCORE_CTRL1); - if (val < 0) + err = menelaus_read_reg(MENELAUS_VCORE_CTRL1); + if (err < 0) goto fail; - if (val & (1 << 7)) + if (err & BIT(7)) menelaus->vcore_hw_mode = 1; else menelaus->vcore_hw_mode = 0; -- cgit v1.2.3 From 378515fc10c7e1b607980ef67f7e02d830dc2fae Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Fri, 15 Aug 2014 21:53:17 +0800 Subject: mfd: da9052-i2c: Remove duplicate test for I2C_FUNC_SMBUS_BYTE_DATA functionality Since commit b42261078a91 ("regmap: i2c: fallback to SMBus if the adapter does not support standard I2C"), regmap-i2c will check the I2C_FUNC_SMBUS_[BYTE|WORD]_DATA functionality based on the regmap_config setting if the adapter does not support standard I2C. So remove the I2C_FUNC_SMBUS_BYTE_DATA functionality check in the driver code. Signed-off-by: Axel Lin Signed-off-by: Lee Jones --- drivers/mfd/da9052-i2c.c | 7 ------- 1 file changed, 7 deletions(-) (limited to 'drivers') diff --git a/drivers/mfd/da9052-i2c.c b/drivers/mfd/da9052-i2c.c index 6da8ec8ff800..ec39287a245b 100644 --- a/drivers/mfd/da9052-i2c.c +++ b/drivers/mfd/da9052-i2c.c @@ -140,13 +140,6 @@ static int da9052_i2c_probe(struct i2c_client *client, if (!da9052) return -ENOMEM; - if (!i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_BYTE_DATA)) { - dev_info(&client->dev, "Error in %s:i2c_check_functionality\n", - __func__); - return -ENODEV; - } - da9052->dev = &client->dev; da9052->chip_irq = client->irq; da9052->fix_io = da9052_i2c_fix; -- cgit v1.2.3 From ff0c9da013d2c9f1ec232926a54e536ab48c6678 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Thu, 21 Aug 2014 12:46:25 +0300 Subject: mfd: lpc_ich: Add PCI ID for Intel Braswell This is the same as used in Baytrail so add the new PCI ID to the driver's list of supported IDs. Signed-off-by: Alan Cox Signed-off-by: Mika Westerberg Signed-off-by: Lee Jones --- drivers/mfd/lpc_ich.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'drivers') diff --git a/drivers/mfd/lpc_ich.c b/drivers/mfd/lpc_ich.c index 7d8482ff5868..8b8114e19c39 100644 --- a/drivers/mfd/lpc_ich.c +++ b/drivers/mfd/lpc_ich.c @@ -216,6 +216,7 @@ enum lpc_chipsets { LPC_BAYTRAIL, /* Bay Trail SoC */ LPC_COLETO, /* Coleto Creek */ LPC_WPT_LP, /* Wildcat Point-LP */ + LPC_BRASWELL, /* Braswell SoC */ }; static struct lpc_ich_info lpc_chipset_info[] = { @@ -519,6 +520,10 @@ static struct lpc_ich_info lpc_chipset_info[] = { .name = "Wildcat Point_LP", .iTCO_version = 2, }, + [LPC_BRASWELL] = { + .name = "Braswell SoC", + .iTCO_version = 3, + }, }; /* @@ -745,6 +750,7 @@ static const struct pci_device_id lpc_ich_ids[] = { { PCI_VDEVICE(INTEL, 0x9cc6), LPC_WPT_LP}, { PCI_VDEVICE(INTEL, 0x9cc7), LPC_WPT_LP}, { PCI_VDEVICE(INTEL, 0x9cc9), LPC_WPT_LP}, + { PCI_VDEVICE(INTEL, 0x229c), LPC_BRASWELL}, { 0, }, /* End of list */ }; MODULE_DEVICE_TABLE(pci, lpc_ich_ids); -- cgit v1.2.3 From a0bc607208e295f70d0355fa4e632a0c8c27533b Mon Sep 17 00:00:00 2001 From: Jacek Anaszewski Date: Fri, 22 Aug 2014 11:06:18 +0200 Subject: mfd: max77693: Improve support for the flash cell This patch improves support for the flash cell of max77693 mfd by adding relevant of_compatible field and a structure for caching related platform data. Added are also FLASH registers related macro definitions. Signed-off-by: Jacek Anaszewski Signed-off-by: Andrzej Hajda Acked-by: Kyungmin Park Signed-off-by: Lee Jones --- drivers/mfd/max77693.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/mfd/max77693.c b/drivers/mfd/max77693.c index 249c139ef04a..cf008f45968c 100644 --- a/drivers/mfd/max77693.c +++ b/drivers/mfd/max77693.c @@ -44,9 +44,12 @@ static const struct mfd_cell max77693_devs[] = { { .name = "max77693-pmic", }, { .name = "max77693-charger", }, - { .name = "max77693-flash", }, { .name = "max77693-muic", }, { .name = "max77693-haptic", }, + { + .name = "max77693-flash", + .of_compatible = "maxim,max77693-flash", + }, }; static const struct regmap_config max77693_regmap_config = { -- cgit v1.2.3 From fea31042ff613145c7784e2ce454bf3c151b97ba Mon Sep 17 00:00:00 2001 From: James Ralston Date: Wed, 27 Aug 2014 14:34:25 -0700 Subject: mfd: lpc_ich: Add Device IDs for Intel 9 Series PCH This patch adds the LPC Device IDs for the Intel 9 Series PCH. Signed-off-by: James Ralston Signed-off-by: Lee Jones --- drivers/mfd/lpc_ich.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'drivers') diff --git a/drivers/mfd/lpc_ich.c b/drivers/mfd/lpc_ich.c index 8b8114e19c39..f35d4280b2f7 100644 --- a/drivers/mfd/lpc_ich.c +++ b/drivers/mfd/lpc_ich.c @@ -54,6 +54,7 @@ * document number TBD : Avoton SoC * document number TBD : Coleto Creek * document number TBD : Wildcat Point-LP + * document number TBD : 9 Series */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt @@ -217,6 +218,7 @@ enum lpc_chipsets { LPC_COLETO, /* Coleto Creek */ LPC_WPT_LP, /* Wildcat Point-LP */ LPC_BRASWELL, /* Braswell SoC */ + LPC_9S, /* 9 Series */ }; static struct lpc_ich_info lpc_chipset_info[] = { @@ -524,6 +526,10 @@ static struct lpc_ich_info lpc_chipset_info[] = { .name = "Braswell SoC", .iTCO_version = 3, }, + [LPC_9S] = { + .name = "9 Series", + .iTCO_version = 2, + }, }; /* @@ -751,6 +757,11 @@ static const struct pci_device_id lpc_ich_ids[] = { { PCI_VDEVICE(INTEL, 0x9cc7), LPC_WPT_LP}, { PCI_VDEVICE(INTEL, 0x9cc9), LPC_WPT_LP}, { PCI_VDEVICE(INTEL, 0x229c), LPC_BRASWELL}, + { PCI_VDEVICE(INTEL, 0x8cc1), LPC_9S}, + { PCI_VDEVICE(INTEL, 0x8cc2), LPC_9S}, + { PCI_VDEVICE(INTEL, 0x8cc3), LPC_9S}, + { PCI_VDEVICE(INTEL, 0x8cc4), LPC_9S}, + { PCI_VDEVICE(INTEL, 0x8cc6), LPC_9S}, { 0, }, /* End of list */ }; MODULE_DEVICE_TABLE(pci, lpc_ich_ids); -- cgit v1.2.3 From 260a127bfbeba4bb574e7b46f07c12d4ddac57c1 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 28 Aug 2014 10:48:18 +0100 Subject: mfd: 88pm860x-i2c: Purge unused functions The following functions appear to be unused since v2.6.39: pm860x_page_reg_read() pm860x_page_bulk_write() pm860x_page_set_bits() Let's remove them. Signed-off-by: Lee Jones --- drivers/mfd/88pm860x-i2c.c | 64 ---------------------------------------------- 1 file changed, 64 deletions(-) (limited to 'drivers') diff --git a/drivers/mfd/88pm860x-i2c.c b/drivers/mfd/88pm860x-i2c.c index a93b4d0134a2..7063cfded699 100644 --- a/drivers/mfd/88pm860x-i2c.c +++ b/drivers/mfd/88pm860x-i2c.c @@ -140,26 +140,6 @@ static int write_device(struct i2c_client *i2c, int reg, return 0; } -int pm860x_page_reg_read(struct i2c_client *i2c, int reg) -{ - unsigned char zero = 0; - unsigned char data; - int ret; - - i2c_lock_adapter(i2c->adapter); - read_device(i2c, 0xFA, 0, &zero); - read_device(i2c, 0xFB, 0, &zero); - read_device(i2c, 0xFF, 0, &zero); - ret = read_device(i2c, reg, 1, &data); - if (ret >= 0) - ret = (int)data; - read_device(i2c, 0xFE, 0, &zero); - read_device(i2c, 0xFC, 0, &zero); - i2c_unlock_adapter(i2c->adapter); - return ret; -} -EXPORT_SYMBOL(pm860x_page_reg_read); - int pm860x_page_reg_write(struct i2c_client *i2c, int reg, unsigned char data) { @@ -195,47 +175,3 @@ int pm860x_page_bulk_read(struct i2c_client *i2c, int reg, return ret; } EXPORT_SYMBOL(pm860x_page_bulk_read); - -int pm860x_page_bulk_write(struct i2c_client *i2c, int reg, - int count, unsigned char *buf) -{ - unsigned char zero = 0; - int ret; - - i2c_lock_adapter(i2c->adapter); - read_device(i2c, 0xFA, 0, &zero); - read_device(i2c, 0xFB, 0, &zero); - read_device(i2c, 0xFF, 0, &zero); - ret = write_device(i2c, reg, count, buf); - read_device(i2c, 0xFE, 0, &zero); - read_device(i2c, 0xFC, 0, &zero); - i2c_unlock_adapter(i2c->adapter); - i2c_unlock_adapter(i2c->adapter); - return ret; -} -EXPORT_SYMBOL(pm860x_page_bulk_write); - -int pm860x_page_set_bits(struct i2c_client *i2c, int reg, - unsigned char mask, unsigned char data) -{ - unsigned char zero; - unsigned char value; - int ret; - - i2c_lock_adapter(i2c->adapter); - read_device(i2c, 0xFA, 0, &zero); - read_device(i2c, 0xFB, 0, &zero); - read_device(i2c, 0xFF, 0, &zero); - ret = read_device(i2c, reg, 1, &value); - if (ret < 0) - goto out; - value &= ~mask; - value |= data; - ret = write_device(i2c, reg, 1, &value); -out: - read_device(i2c, 0xFE, 0, &zero); - read_device(i2c, 0xFC, 0, &zero); - i2c_unlock_adapter(i2c->adapter); - return ret; -} -EXPORT_SYMBOL(pm860x_page_set_bits); -- cgit v1.2.3 From 7a36ceb284f76d696c80998cc38f6d1c6721ac6d Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 28 Aug 2014 10:51:26 +0100 Subject: mfd: 88pm860x-i2c: Fix variable length array Sparse warning drivers/mfd/88pm860x-i2c.c:125:33: warning: Variable length array is used. Signed-off-by: Lee Jones --- drivers/mfd/88pm860x-i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/mfd/88pm860x-i2c.c b/drivers/mfd/88pm860x-i2c.c index 7063cfded699..84e313107233 100644 --- a/drivers/mfd/88pm860x-i2c.c +++ b/drivers/mfd/88pm860x-i2c.c @@ -122,7 +122,7 @@ static int read_device(struct i2c_client *i2c, int reg, static int write_device(struct i2c_client *i2c, int reg, int bytes, void *src) { - unsigned char buf[bytes + 1]; + unsigned char buf[2]; struct i2c_adapter *adap = i2c->adapter; struct i2c_msg msg; int ret; -- cgit v1.2.3 From 87bd1c925040d97927c6f6b7fe41a487c7d976ef Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 28 Aug 2014 11:01:15 +0100 Subject: mfd: max8925-i2c: Fix variable length array Sparse warning The largest byte size in use currently is 8. Fix array size to 9. drivers/mfd/max8925-i2c.c:40:33: warning: Variable length array is used Signed-off-by: Lee Jones --- drivers/mfd/max8925-i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c index ecbe78ead3b6..c880c895c5a6 100644 --- a/drivers/mfd/max8925-i2c.c +++ b/drivers/mfd/max8925-i2c.c @@ -37,7 +37,7 @@ static inline int max8925_read_device(struct i2c_client *i2c, static inline int max8925_write_device(struct i2c_client *i2c, int reg, int bytes, void *src) { - unsigned char buf[bytes + 1]; + unsigned char buf[9]; int ret; buf[0] = (unsigned char)reg; -- cgit v1.2.3 From 7929fa7740f2a8cba6857aaa0f6513f81a0e3d88 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 28 Aug 2014 11:20:33 +0100 Subject: mfd: stmpe: Rid variable length array Sparse warnings Numbers are generated by taking the largest currently used values. drivers/mfd/stmpe.c:252:17: warning: Variable length array is used. drivers/mfd/stmpe.c:857:16: warning: Variable length array is used. Acked-by: Linus Walleij Signed-off-by: Lee Jones --- drivers/mfd/stmpe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c index 02a17c388e87..f9d46f035bb1 100644 --- a/drivers/mfd/stmpe.c +++ b/drivers/mfd/stmpe.c @@ -249,7 +249,7 @@ int stmpe_set_altfunc(struct stmpe *stmpe, u32 pins, enum stmpe_block block) int af_bits = variant->af_bits; int numregs = DIV_ROUND_UP(stmpe->num_gpios * af_bits, 8); int mask = (1 << af_bits) - 1; - u8 regs[numregs]; + u8 regs[8]; int af, afperreg, ret; if (!variant->get_altfunc) @@ -854,7 +854,7 @@ static irqreturn_t stmpe_irq(int irq, void *data) struct stmpe_variant_info *variant = stmpe->variant; int num = DIV_ROUND_UP(variant->num_irqs, 8); u8 israddr; - u8 isr[num]; + u8 isr[3]; int ret; int i; -- cgit v1.2.3 From be1c770028b832945680ebf5c0d49b831ba719d5 Mon Sep 17 00:00:00 2001 From: "Arnout Vandecappelle (Essensium/Mind)" Date: Fri, 22 Aug 2014 17:30:56 +0200 Subject: mfd: tps65910: Work around silicon erratum SWCZ010 http://www.ti.com/lit/pdf/SWCZ010: Glitch on SDA-SCL not managed correctly by the I2C IP Impact: The standard specifies that the I2C transfer should restart on a start event in all cases. The current design does not support two consecutive Start conditions. This can cause the first real access after such a glitch to be corrupted. Description: An unexpected glitch on SDA and SCL can generate a wrong start event. In the current design, the SCL line must toggle two times to detect a new start event and completely restart the I2C access; hence the real start event is not detected in the case of a single SCL toggle. Workaround: Repeat I2C access. A simpler workaround is to make a dummy transfer just before the first access to the tps65910 chip. This can be done unconditionally. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) Acked-by: Mark Brown Signed-off-by: Lee Jones --- drivers/mfd/tps65910.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers') diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c index f243e75d28f3..7612d89850dd 100644 --- a/drivers/mfd/tps65910.c +++ b/drivers/mfd/tps65910.c @@ -486,6 +486,11 @@ static int tps65910_i2c_probe(struct i2c_client *i2c, tps65910->i2c_client = i2c; tps65910->id = chip_id; + /* Work around silicon erratum SWCZ010: the tps65910 may miss the + * first I2C transfer. So issue a dummy transfer before the first + * real transfer. + */ + i2c_master_send(i2c, "", 1); tps65910->regmap = devm_regmap_init_i2c(i2c, &tps65910_regmap_config); if (IS_ERR(tps65910->regmap)) { ret = PTR_ERR(tps65910->regmap); -- cgit v1.2.3 From 6ac734d2242949f41eb1346ca0fd4ed010c937aa Mon Sep 17 00:00:00 2001 From: Vignesh R Date: Mon, 1 Sep 2014 12:01:06 +0530 Subject: mfd: ti_am335x_tscadc: Fix TSC operation after ADC continouous mode After enabling and disabling ADC continuous mode via sysfs, ts_print_raw fails to return any data. This is because when ADC is configured for continuous mode, it disables touch screen steps.These steps are not re-enabled when ADC continuous mode is disabled. Therefore existing values of REG_SE needs to be cached before enabling continuous mode and disabling touch screen steps and enabling ADC steps. The cached value are to be restored to REG_SE once ADC is disabled. Fixes: 7ca6740cd1cd ("mfd: input: iio: ti_amm335x: Rework TSC/ADC synchronization") Cc: stable@vger.kernel.org # v3.13+ Signed-off-by: Vignesh R Signed-off-by: Lee Jones --- drivers/mfd/ti_am335x_tscadc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c index dd4bf5816221..8b119ce20b93 100644 --- a/drivers/mfd/ti_am335x_tscadc.c +++ b/drivers/mfd/ti_am335x_tscadc.c @@ -53,7 +53,7 @@ void am335x_tsc_se_set_cache(struct ti_tscadc_dev *tsadc, u32 val) unsigned long flags; spin_lock_irqsave(&tsadc->reg_lock, flags); - tsadc->reg_se_cache = val; + tsadc->reg_se_cache |= val; if (tsadc->adc_waiting) wake_up(&tsadc->reg_se_wait); else if (!tsadc->adc_in_use) @@ -96,6 +96,7 @@ static void am335x_tscadc_need_adc(struct ti_tscadc_dev *tsadc) void am335x_tsc_se_set_once(struct ti_tscadc_dev *tsadc, u32 val) { spin_lock_irq(&tsadc->reg_lock); + tsadc->reg_se_cache |= val; am335x_tscadc_need_adc(tsadc); tscadc_writel(tsadc, REG_SE, val); -- cgit v1.2.3 From 9bb9e29c78f8d8ee310987fd58a2b908a4ce0c40 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Sat, 30 Aug 2014 14:50:23 +0200 Subject: mfd: Add Ricoh RN5T618 PMIC core driver Ricoh RN5T618 is a power management IC which integrates 3 step-down DCDC converters, 7 low-dropout regulators, a Li-ion battery charger, fuel gauge, ADC, GPIOs and a watchdog timer. This commit adds a MFD core driver to support the I2C communication with the device. Signed-off-by: Beniamino Galvani Signed-off-by: Lee Jones --- drivers/mfd/Kconfig | 11 +++++ drivers/mfd/Makefile | 1 + drivers/mfd/rn5t618.c | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 146 insertions(+) create mode 100644 drivers/mfd/rn5t618.c (limited to 'drivers') diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index fc419da8d722..82f70dcab136 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -597,6 +597,17 @@ config MFD_RC5T583 Additional drivers must be enabled in order to use the different functionality of the device. +config MFD_RN5T618 + tristate "Ricoh RN5T5618 PMIC" + depends on I2C + select MFD_CORE + select REGMAP_I2C + help + Say yes here to add support for the Ricoh RN5T618 PMIC. This + driver provides common support for accessing the device, + additional drivers must be enabled in order to use the + functionality of the device. + config MFD_SEC_CORE bool "SAMSUNG Electronics PMIC Series Support" depends on I2C=y diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index d58068aa8aa9..aa5a73a5ba47 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -160,6 +160,7 @@ obj-$(CONFIG_MFD_INTEL_MSIC) += intel_msic.o obj-$(CONFIG_MFD_PALMAS) += palmas.o obj-$(CONFIG_MFD_VIPERBOARD) += viperboard.o obj-$(CONFIG_MFD_RC5T583) += rc5t583.o rc5t583-irq.o +obj-$(CONFIG_MFD_RN5T618) += rn5t618.o obj-$(CONFIG_MFD_SEC_CORE) += sec-core.o sec-irq.o obj-$(CONFIG_MFD_SYSCON) += syscon.o obj-$(CONFIG_MFD_LM3533) += lm3533-core.o lm3533-ctrlbank.o diff --git a/drivers/mfd/rn5t618.c b/drivers/mfd/rn5t618.c new file mode 100644 index 000000000000..666857192dbe --- /dev/null +++ b/drivers/mfd/rn5t618.c @@ -0,0 +1,134 @@ +/* + * MFD core driver for Ricoh RN5T618 PMIC + * + * Copyright (C) 2014 Beniamino Galvani + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include +#include + +static const struct mfd_cell rn5t618_cells[] = { + { .name = "rn5t618-regulator" }, + { .name = "rn5t618-wdt" }, +}; + +static bool rn5t618_volatile_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case RN5T618_WATCHDOGCNT: + case RN5T618_DCIRQ: + case RN5T618_ILIMDATAH ... RN5T618_AIN0DATAL: + case RN5T618_IR_ADC1 ... RN5T618_IR_ADC3: + case RN5T618_IR_GPR: + case RN5T618_IR_GPF: + case RN5T618_MON_IOIN: + case RN5T618_INTMON: + return true; + default: + return false; + } +} + +static const struct regmap_config rn5t618_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .volatile_reg = rn5t618_volatile_reg, + .max_register = RN5T618_MAX_REG, + .cache_type = REGCACHE_RBTREE, +}; + +static struct rn5t618 *rn5t618_pm_power_off; + +static void rn5t618_power_off(void) +{ + /* disable automatic repower-on */ + regmap_update_bits(rn5t618_pm_power_off->regmap, RN5T618_REPCNT, + RN5T618_REPCNT_REPWRON, 0); + /* start power-off sequence */ + regmap_update_bits(rn5t618_pm_power_off->regmap, RN5T618_SLPCNT, + RN5T618_SLPCNT_SWPWROFF, RN5T618_SLPCNT_SWPWROFF); +} + +static int rn5t618_i2c_probe(struct i2c_client *i2c, + const struct i2c_device_id *id) +{ + struct rn5t618 *priv; + int ret; + + priv = devm_kzalloc(&i2c->dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + i2c_set_clientdata(i2c, priv); + + priv->regmap = devm_regmap_init_i2c(i2c, &rn5t618_regmap_config); + if (IS_ERR(priv->regmap)) { + ret = PTR_ERR(priv->regmap); + dev_err(&i2c->dev, "regmap init failed: %d\n", ret); + return ret; + } + + ret = mfd_add_devices(&i2c->dev, -1, rn5t618_cells, + ARRAY_SIZE(rn5t618_cells), NULL, 0, NULL); + if (ret) { + dev_err(&i2c->dev, "failed to add sub-devices: %d\n", ret); + return ret; + } + + if (!pm_power_off) { + rn5t618_pm_power_off = priv; + pm_power_off = rn5t618_power_off; + } + + return 0; +} + +static int rn5t618_i2c_remove(struct i2c_client *i2c) +{ + struct rn5t618 *priv = i2c_get_clientdata(i2c); + + if (priv == rn5t618_pm_power_off) { + rn5t618_pm_power_off = NULL; + pm_power_off = NULL; + } + + mfd_remove_devices(&i2c->dev); + return 0; +} + +static const struct of_device_id rn5t618_of_match[] = { + { .compatible = "ricoh,rn5t618" }, + { } +}; +MODULE_DEVICE_TABLE(of, rn5t618_of_match); + +static const struct i2c_device_id rn5t618_i2c_id[] = { + { } +}; +MODULE_DEVICE_TABLE(i2c, rn5t618_i2c_id); + +static struct i2c_driver rn5t618_i2c_driver = { + .driver = { + .name = "rn5t618", + .of_match_table = of_match_ptr(rn5t618_of_match), + }, + .probe = rn5t618_i2c_probe, + .remove = rn5t618_i2c_remove, + .id_table = rn5t618_i2c_id, +}; + +module_i2c_driver(rn5t618_i2c_driver); + +MODULE_AUTHOR("Beniamino Galvani "); +MODULE_DESCRIPTION("Ricoh RN5T618 MFD driver"); +MODULE_LICENSE("GPL v2"); -- cgit v1.2.3 From c24084db223aec7793201b94f0712cfdfa7e9fe7 Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Mon, 1 Sep 2014 15:48:52 +0100 Subject: mfd: arizona: Add ASYNC_SAMPLE_RATE_2 registers Some arizona devices have a second asynchronous sample rate, add the registers necessary to support this. Signed-off-by: Charles Keepax Acked-by: Mark Brown Signed-off-by: Lee Jones --- drivers/mfd/wm5102-tables.c | 3 +++ drivers/mfd/wm5110-tables.c | 4 ++++ 2 files changed, 7 insertions(+) (limited to 'drivers') diff --git a/drivers/mfd/wm5102-tables.c b/drivers/mfd/wm5102-tables.c index 6d9b7f832bf5..d6f35bbf795b 100644 --- a/drivers/mfd/wm5102-tables.c +++ b/drivers/mfd/wm5102-tables.c @@ -1059,6 +1059,8 @@ static bool wm5102_readable_register(struct device *dev, unsigned int reg) case ARIZONA_ASYNC_CLOCK_1: case ARIZONA_ASYNC_SAMPLE_RATE_1: case ARIZONA_ASYNC_SAMPLE_RATE_1_STATUS: + case ARIZONA_ASYNC_SAMPLE_RATE_2: + case ARIZONA_ASYNC_SAMPLE_RATE_2_STATUS: case ARIZONA_OUTPUT_SYSTEM_CLOCK: case ARIZONA_OUTPUT_ASYNC_CLOCK: case ARIZONA_RATE_ESTIMATOR_1: @@ -1892,6 +1894,7 @@ static bool wm5102_volatile_register(struct device *dev, unsigned int reg) case ARIZONA_SAMPLE_RATE_3_STATUS: case ARIZONA_HAPTICS_STATUS: case ARIZONA_ASYNC_SAMPLE_RATE_1_STATUS: + case ARIZONA_ASYNC_SAMPLE_RATE_2_STATUS: case ARIZONA_FLL1_NCO_TEST_0: case ARIZONA_FLL2_NCO_TEST_0: case ARIZONA_DAC_COMP_1: diff --git a/drivers/mfd/wm5110-tables.c b/drivers/mfd/wm5110-tables.c index beae0a397ee1..4642b5b816a0 100644 --- a/drivers/mfd/wm5110-tables.c +++ b/drivers/mfd/wm5110-tables.c @@ -702,6 +702,7 @@ static const struct reg_default wm5110_reg_default[] = { { 0x00000104, 0x0011 }, /* R260 - Sample rate 3 */ { 0x00000112, 0x0305 }, /* R274 - Async clock 1 */ { 0x00000113, 0x0011 }, /* R275 - Async sample rate 1 */ + { 0x00000114, 0x0011 }, /* R276 - Async sample rate 2 */ { 0x00000149, 0x0000 }, /* R329 - Output system clock */ { 0x0000014A, 0x0000 }, /* R330 - Output async clock */ { 0x00000152, 0x0000 }, /* R338 - Rate Estimator 1 */ @@ -1738,6 +1739,8 @@ static bool wm5110_readable_register(struct device *dev, unsigned int reg) case ARIZONA_ASYNC_CLOCK_1: case ARIZONA_ASYNC_SAMPLE_RATE_1: case ARIZONA_ASYNC_SAMPLE_RATE_1_STATUS: + case ARIZONA_ASYNC_SAMPLE_RATE_2: + case ARIZONA_ASYNC_SAMPLE_RATE_2_STATUS: case ARIZONA_OUTPUT_SYSTEM_CLOCK: case ARIZONA_OUTPUT_ASYNC_CLOCK: case ARIZONA_RATE_ESTIMATOR_1: @@ -2820,6 +2823,7 @@ static bool wm5110_volatile_register(struct device *dev, unsigned int reg) case ARIZONA_SAMPLE_RATE_2_STATUS: case ARIZONA_SAMPLE_RATE_3_STATUS: case ARIZONA_ASYNC_SAMPLE_RATE_1_STATUS: + case ARIZONA_ASYNC_SAMPLE_RATE_2_STATUS: case ARIZONA_MIC_DETECT_3: case ARIZONA_HEADPHONE_DETECT_2: case ARIZONA_INPUT_ENABLES_STATUS: -- cgit v1.2.3 From cc47aed9a1ef8eadd7bf14e32117896777b5cc41 Mon Sep 17 00:00:00 2001 From: Inha Song Date: Sat, 30 Aug 2014 11:27:18 +0900 Subject: mfd: arizona: Add support for INn_Mode register control Some boards need to set the INn_MODE[1:0] register to change the input signal patch. This wlf,inmode property is optional. If present, values must be specified less than or equal to the number of input singals. If values less than the number of input signals, elements that has not been specifed are set to 0 by default. Example: - wlf,inmode = <2 0 2>; /* IN1, IN3 use DMIC */ Signed-off-by: Inha Song Reviewed-by: Charles Keepax Signed-off-by: Lee Jones --- drivers/mfd/arizona-core.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'drivers') diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c index 7eabc36b97c1..4afb232b5cde 100644 --- a/drivers/mfd/arizona-core.c +++ b/drivers/mfd/arizona-core.c @@ -534,7 +534,11 @@ EXPORT_SYMBOL_GPL(arizona_of_get_named_gpio); static int arizona_of_get_core_pdata(struct arizona *arizona) { struct arizona_pdata *pdata = &arizona->pdata; + struct property *prop; + const __be32 *cur; + u32 val; int ret, i; + int count = 0; pdata->reset = arizona_of_get_named_gpio(arizona, "wlf,reset", true); @@ -560,6 +564,15 @@ static int arizona_of_get_core_pdata(struct arizona *arizona) ret); } + of_property_for_each_u32(arizona->dev->of_node, "wlf,inmode", prop, + cur, val) { + if (count == ARRAY_SIZE(arizona->pdata.inmode)) + break; + + arizona->pdata.inmode[count] = val; + count++; + } + return 0; } -- cgit v1.2.3 From c38715fed8f51a8fba4a15f86732ad885f073d78 Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Mon, 1 Sep 2014 15:29:11 +0100 Subject: mfd: arizona: Propagate irq_wake through to parent IRQ If one of the internal Arizona IRQs is set as a wake source this needs to be propogated back to the actual IRQ line that the Arizona device is attached to. Signed-off-by: Charles Keepax Signed-off-by: Lee Jones --- drivers/mfd/arizona-irq.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'drivers') diff --git a/drivers/mfd/arizona-irq.c b/drivers/mfd/arizona-irq.c index 9133d519b020..5e2f450a6176 100644 --- a/drivers/mfd/arizona-irq.c +++ b/drivers/mfd/arizona-irq.c @@ -152,10 +152,18 @@ static void arizona_irq_disable(struct irq_data *data) { } +static int arizona_irq_set_wake(struct irq_data *data, unsigned int on) +{ + struct arizona *arizona = irq_data_get_irq_chip_data(data); + + return irq_set_irq_wake(arizona->irq, on); +} + static struct irq_chip arizona_irq_chip = { .name = "arizona", .irq_disable = arizona_irq_disable, .irq_enable = arizona_irq_enable, + .irq_set_wake = arizona_irq_set_wake, }; static int arizona_irq_map(struct irq_domain *h, unsigned int virq, -- cgit v1.2.3 From e9e9d3973594cadd9e892bc79f914f299bb61124 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Sat, 16 Aug 2014 21:23:40 +0800 Subject: mfd: da9052: Avoid setting read_flag_mask for da9052-i2c driver Current code init regmap with &da9052_regmap_config for both da9052-spi and da9052-i2c drivers. da9052-spi sets the read_flag_mask. The same setting may be applied for da9052-i2c if da9052-spi driver is loaded first because they actually use the same regmap_config setting. Fix this issue by using a local variable for regmap_config in da9052-spi driver, so the settings in spi driver won't impact the settings in i2c driver. Also makes da9052_regmap_config const to avoid similar issue. Signed-off-by: Axel Lin Acked-by: Adam Thomson Signed-off-by: Lee Jones --- drivers/mfd/da9052-core.c | 2 +- drivers/mfd/da9052-spi.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/mfd/da9052-core.c b/drivers/mfd/da9052-core.c index e8af816d73a9..52a0c2f6264f 100644 --- a/drivers/mfd/da9052-core.c +++ b/drivers/mfd/da9052-core.c @@ -522,7 +522,7 @@ static const struct mfd_cell da9052_subdev_info[] = { }, }; -struct regmap_config da9052_regmap_config = { +const struct regmap_config da9052_regmap_config = { .reg_bits = 8, .val_bits = 8, diff --git a/drivers/mfd/da9052-spi.c b/drivers/mfd/da9052-spi.c index 17666b40b70c..45ae0b7d13ef 100644 --- a/drivers/mfd/da9052-spi.c +++ b/drivers/mfd/da9052-spi.c @@ -23,6 +23,7 @@ static int da9052_spi_probe(struct spi_device *spi) { + struct regmap_config config; int ret; const struct spi_device_id *id = spi_get_device_id(spi); struct da9052 *da9052; @@ -40,10 +41,10 @@ static int da9052_spi_probe(struct spi_device *spi) spi_set_drvdata(spi, da9052); - da9052_regmap_config.read_flag_mask = 1; - da9052_regmap_config.write_flag_mask = 0; + config = da9052_regmap_config; + config.read_flag_mask = 1; - da9052->regmap = devm_regmap_init_spi(spi, &da9052_regmap_config); + da9052->regmap = devm_regmap_init_spi(spi, &config); if (IS_ERR(da9052->regmap)) { ret = PTR_ERR(da9052->regmap); dev_err(&spi->dev, "Failed to allocate register map: %d\n", -- cgit v1.2.3 From f69a7cf74d5536faa180437581be2a9c0aad1bb1 Mon Sep 17 00:00:00 2001 From: Chris Zhong Date: Wed, 3 Sep 2014 21:51:44 +0800 Subject: mfd: RK808: Add new mfd driver for RK808 The RK808 chip is a power management IC for multimedia and handheld devices. It contains the following components: - Regulators - RTC - Clkout The RK808 core driver is registered as a platform driver and provides communication through I2C with the host device for the different components. Signed-off-by: Chris Zhong Signed-off-by: Zhang Qing Tested-by: Heiko Signed-off-by: Lee Jones --- drivers/mfd/Kconfig | 13 +++ drivers/mfd/Makefile | 1 + drivers/mfd/rk808.c | 245 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 259 insertions(+) create mode 100644 drivers/mfd/rk808.c (limited to 'drivers') diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 82f70dcab136..049796a28215 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -597,6 +597,19 @@ config MFD_RC5T583 Additional drivers must be enabled in order to use the different functionality of the device. +config MFD_RK808 + tristate "Rockchip RK808 Power Management chip" + depends on I2C && OF + select MFD_CORE + select REGMAP_I2C + select REGMAP_IRQ + help + If you say yes here you get support for the RK808 + Power Management chips. + This driver provides common support for accessing the device + through I2C interface. The device supports multiple sub-devices + including interrupts, RTC, LDO & DCDC regulators, and onkey. + config MFD_RN5T618 tristate "Ricoh RN5T5618 PMIC" depends on I2C diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index aa5a73a5ba47..bd111213bd58 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -160,6 +160,7 @@ obj-$(CONFIG_MFD_INTEL_MSIC) += intel_msic.o obj-$(CONFIG_MFD_PALMAS) += palmas.o obj-$(CONFIG_MFD_VIPERBOARD) += viperboard.o obj-$(CONFIG_MFD_RC5T583) += rc5t583.o rc5t583-irq.o +obj-$(CONFIG_MFD_RK808) += rk808.o obj-$(CONFIG_MFD_RN5T618) += rn5t618.o obj-$(CONFIG_MFD_SEC_CORE) += sec-core.o sec-irq.o obj-$(CONFIG_MFD_SYSCON) += syscon.o diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c new file mode 100644 index 000000000000..0324422b3b10 --- /dev/null +++ b/drivers/mfd/rk808.c @@ -0,0 +1,245 @@ +/* + * MFD core driver for Rockchip RK808 + * + * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd + * + * Author: Chris Zhong + * Author: Zhang Qing + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#include +#include +#include +#include +#include +#include + +struct rk808_reg_data { + int addr; + int mask; + int value; +}; + +static const struct regmap_config rk808_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .max_register = RK808_IO_POL_REG, +}; + +static struct resource rtc_resources[] = { + { + .start = RK808_IRQ_RTC_ALARM, + .end = RK808_IRQ_RTC_ALARM, + .flags = IORESOURCE_IRQ, + } +}; + +static const struct mfd_cell rk808s[] = { + { .name = "rk808-clkout", }, + { .name = "rk808-regulator", }, + { + .name = "rk808-rtc", + .num_resources = ARRAY_SIZE(rtc_resources), + .resources = &rtc_resources[0], + }, +}; + +static const struct rk808_reg_data pre_init_reg[] = { + { RK808_BUCK3_CONFIG_REG, BUCK_ILMIN_MASK, BUCK_ILMIN_150MA }, + { RK808_BUCK4_CONFIG_REG, BUCK_ILMIN_MASK, BUCK_ILMIN_200MA }, + { RK808_BOOST_CONFIG_REG, BOOST_ILMIN_MASK, BOOST_ILMIN_100MA }, + { RK808_BUCK1_CONFIG_REG, BUCK1_RATE_MASK, BUCK_ILMIN_200MA }, + { RK808_BUCK2_CONFIG_REG, BUCK2_RATE_MASK, BUCK_ILMIN_200MA }, + { RK808_VB_MON_REG, MASK_ALL, VB_LO_ACT | + VB_LO_SEL_3500MV }, +}; + +static const struct regmap_irq rk808_irqs[] = { + /* INT_STS */ + [RK808_IRQ_VOUT_LO] = { + .mask = RK808_IRQ_VOUT_LO_MSK, + .reg_offset = 0, + }, + [RK808_IRQ_VB_LO] = { + .mask = RK808_IRQ_VB_LO_MSK, + .reg_offset = 0, + }, + [RK808_IRQ_PWRON] = { + .mask = RK808_IRQ_PWRON_MSK, + .reg_offset = 0, + }, + [RK808_IRQ_PWRON_LP] = { + .mask = RK808_IRQ_PWRON_LP_MSK, + .reg_offset = 0, + }, + [RK808_IRQ_HOTDIE] = { + .mask = RK808_IRQ_HOTDIE_MSK, + .reg_offset = 0, + }, + [RK808_IRQ_RTC_ALARM] = { + .mask = RK808_IRQ_RTC_ALARM_MSK, + .reg_offset = 0, + }, + [RK808_IRQ_RTC_PERIOD] = { + .mask = RK808_IRQ_RTC_PERIOD_MSK, + .reg_offset = 0, + }, + + /* INT_STS2 */ + [RK808_IRQ_PLUG_IN_INT] = { + .mask = RK808_IRQ_PLUG_IN_INT_MSK, + .reg_offset = 1, + }, + [RK808_IRQ_PLUG_OUT_INT] = { + .mask = RK808_IRQ_PLUG_OUT_INT_MSK, + .reg_offset = 1, + }, +}; + +static struct regmap_irq_chip rk808_irq_chip = { + .name = "rk808", + .irqs = rk808_irqs, + .num_irqs = ARRAY_SIZE(rk808_irqs), + .num_regs = 2, + .irq_reg_stride = 2, + .status_base = RK808_INT_STS_REG1, + .mask_base = RK808_INT_STS_MSK_REG1, + .ack_base = RK808_INT_STS_REG1, + .init_ack_masked = true, +}; + +static struct i2c_client *rk808_i2c_client; +static void rk808_device_shutdown(void) +{ + int ret; + struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client); + + if (!rk808) { + dev_warn(&rk808_i2c_client->dev, + "have no rk808, so do nothing here\n"); + return; + } + + ret = regmap_update_bits(rk808->regmap, + RK808_DEVCTRL_REG, + DEV_OFF_RST, DEV_OFF_RST); + if (ret) + dev_err(&rk808_i2c_client->dev, "power off error!\n"); +} + +static int rk808_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct device_node *np = client->dev.of_node; + struct rk808 *rk808; + int pm_off = 0; + int ret; + int i; + + if (!client->irq) { + dev_err(&client->dev, "No interrupt support, no core IRQ\n"); + return -EINVAL; + } + + rk808 = devm_kzalloc(&client->dev, sizeof(*rk808), GFP_KERNEL); + if (!rk808) + return -ENOMEM; + + rk808->regmap = devm_regmap_init_i2c(client, &rk808_regmap_config); + if (IS_ERR(rk808->regmap)) { + dev_err(&client->dev, "regmap initialization failed\n"); + return PTR_ERR(rk808->regmap); + } + + for (i = 0; i < ARRAY_SIZE(pre_init_reg); i++) { + ret = regmap_update_bits(rk808->regmap, pre_init_reg[i].addr, + pre_init_reg[i].mask, + pre_init_reg[i].value); + if (ret) { + dev_err(&client->dev, + "0x%x write err\n", pre_init_reg[i].addr); + return ret; + } + } + + ret = regmap_add_irq_chip(rk808->regmap, client->irq, + IRQF_ONESHOT, -1, + &rk808_irq_chip, &rk808->irq_data); + if (ret) { + dev_err(&client->dev, "Failed to add irq_chip %d\n", ret); + return ret; + } + + rk808->i2c = client; + i2c_set_clientdata(client, rk808); + + ret = mfd_add_devices(&client->dev, -1, + rk808s, ARRAY_SIZE(rk808s), + NULL, 0, regmap_irq_get_domain(rk808->irq_data)); + if (ret) { + dev_err(&client->dev, "failed to add MFD devices %d\n", ret); + goto err_irq; + } + + pm_off = of_property_read_bool(np, + "rockchip,system-power-controller"); + if (pm_off && !pm_power_off) { + rk808_i2c_client = client; + pm_power_off = rk808_device_shutdown; + } + + return 0; + +err_irq: + regmap_del_irq_chip(client->irq, rk808->irq_data); + return ret; +} + +static int rk808_remove(struct i2c_client *client) +{ + struct rk808 *rk808 = i2c_get_clientdata(client); + + regmap_del_irq_chip(client->irq, rk808->irq_data); + mfd_remove_devices(&client->dev); + pm_power_off = NULL; + + return 0; +} + +static struct of_device_id rk808_of_match[] = { + { .compatible = "rockchip,rk808" }, + { }, +}; +MODULE_DEVICE_TABLE(of, rk808_of_match); + +static const struct i2c_device_id rk808_ids[] = { + { "rk808" }, + { }, +}; +MODULE_DEVICE_TABLE(i2c, rk808_ids); + +static struct i2c_driver rk808_i2c_driver = { + .driver = { + .name = "rk808", + .of_match_table = rk808_of_match, + }, + .probe = rk808_probe, + .remove = rk808_remove, + .id_table = rk808_ids, +}; + +module_i2c_driver(rk808_i2c_driver); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Chris Zhong "); +MODULE_AUTHOR("Zhang Qing "); +MODULE_DESCRIPTION("RK808 PMIC driver"); -- cgit v1.2.3 From b24512c860244716fa8ca74faff2ff617c465515 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Tue, 2 Sep 2014 13:45:19 +0300 Subject: mfd: lpc_sch: Reduce duplicate code and improve manageability This patch refactors the driver to use helper functions instead of copy'n'pasted pieces of code. It also introduces an additional struct to hold a chipset info. The chipset info will be used to store features that are supported by specific processor or chipset. LPC_SCH supports SMBUS, GPIO and WDT features. As this code base might expand further to support more processors, this implementation will help to keep code base clean and manageable. The patch is partially based on the work done by Chang Rebecca Swee Fun. Signed-off-by: Andy Shevchenko Tested-by: Chang Rebecca Swee Fun Signed-off-by: Lee Jones --- drivers/mfd/lpc_sch.c | 181 +++++++++++++++++++++++++++----------------------- 1 file changed, 99 insertions(+), 82 deletions(-) (limited to 'drivers') diff --git a/drivers/mfd/lpc_sch.c b/drivers/mfd/lpc_sch.c index 4ee755034f3b..bde070a3a3c0 100644 --- a/drivers/mfd/lpc_sch.c +++ b/drivers/mfd/lpc_sch.c @@ -40,120 +40,137 @@ #define WDTBASE 0x84 #define WDT_IO_SIZE 64 -static struct resource smbus_sch_resource = { - .flags = IORESOURCE_IO, +enum sch_chipsets { + LPC_SCH = 0, /* Intel Poulsbo SCH */ + LPC_ITC, /* Intel Tunnel Creek */ + LPC_CENTERTON, /* Intel Centerton */ }; -static struct resource gpio_sch_resource = { - .flags = IORESOURCE_IO, +struct lpc_sch_info { + unsigned int io_size_smbus; + unsigned int io_size_gpio; + unsigned int io_size_wdt; }; -static struct resource wdt_sch_resource = { - .flags = IORESOURCE_IO, -}; - -static struct mfd_cell lpc_sch_cells[3]; - -static struct mfd_cell isch_smbus_cell = { - .name = "isch_smbus", - .num_resources = 1, - .resources = &smbus_sch_resource, - .ignore_resource_conflicts = true, -}; - -static struct mfd_cell sch_gpio_cell = { - .name = "sch_gpio", - .num_resources = 1, - .resources = &gpio_sch_resource, - .ignore_resource_conflicts = true, -}; - -static struct mfd_cell wdt_sch_cell = { - .name = "ie6xx_wdt", - .num_resources = 1, - .resources = &wdt_sch_resource, - .ignore_resource_conflicts = true, +static struct lpc_sch_info sch_chipset_info[] = { + [LPC_SCH] = { + .io_size_smbus = SMBUS_IO_SIZE, + .io_size_gpio = GPIO_IO_SIZE, + }, + [LPC_ITC] = { + .io_size_smbus = SMBUS_IO_SIZE, + .io_size_gpio = GPIO_IO_SIZE, + .io_size_wdt = WDT_IO_SIZE, + }, + [LPC_CENTERTON] = { + .io_size_smbus = SMBUS_IO_SIZE, + .io_size_gpio = GPIO_IO_SIZE_CENTERTON, + .io_size_wdt = WDT_IO_SIZE, + }, }; static const struct pci_device_id lpc_sch_ids[] = { - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) }, - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ITC_LPC) }, - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CENTERTON_ILB) }, + { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC), LPC_SCH }, + { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ITC_LPC), LPC_ITC }, + { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_CENTERTON_ILB), LPC_CENTERTON }, { 0, } }; MODULE_DEVICE_TABLE(pci, lpc_sch_ids); -static int lpc_sch_probe(struct pci_dev *dev, - const struct pci_device_id *id) +#define LPC_NO_RESOURCE 1 +#define LPC_SKIP_RESOURCE 2 + +static int lpc_sch_get_io(struct pci_dev *pdev, int where, const char *name, + struct resource *res, int size) { unsigned int base_addr_cfg; unsigned short base_addr; - int i, cells = 0; - int ret; - pci_read_config_dword(dev, SMBASE, &base_addr_cfg); + if (size == 0) + return LPC_NO_RESOURCE; + + pci_read_config_dword(pdev, where, &base_addr_cfg); base_addr = 0; if (!(base_addr_cfg & (1 << 31))) - dev_warn(&dev->dev, "Decode of the SMBus I/O range disabled\n"); + dev_warn(&pdev->dev, "Decode of the %s I/O range disabled\n", + name); else base_addr = (unsigned short)base_addr_cfg; if (base_addr == 0) { - dev_warn(&dev->dev, "I/O space for SMBus uninitialized\n"); - } else { - lpc_sch_cells[cells++] = isch_smbus_cell; - smbus_sch_resource.start = base_addr; - smbus_sch_resource.end = base_addr + SMBUS_IO_SIZE - 1; + dev_warn(&pdev->dev, "I/O space for %s uninitialized\n", name); + return LPC_SKIP_RESOURCE; } - pci_read_config_dword(dev, GPIOBASE, &base_addr_cfg); - base_addr = 0; - if (!(base_addr_cfg & (1 << 31))) - dev_warn(&dev->dev, "Decode of the GPIO I/O range disabled\n"); - else - base_addr = (unsigned short)base_addr_cfg; + res->start = base_addr; + res->end = base_addr + size - 1; + res->flags = IORESOURCE_IO; - if (base_addr == 0) { - dev_warn(&dev->dev, "I/O space for GPIO uninitialized\n"); - } else { - lpc_sch_cells[cells++] = sch_gpio_cell; - gpio_sch_resource.start = base_addr; - if (id->device == PCI_DEVICE_ID_INTEL_CENTERTON_ILB) - gpio_sch_resource.end = base_addr + GPIO_IO_SIZE_CENTERTON - 1; - else - gpio_sch_resource.end = base_addr + GPIO_IO_SIZE - 1; - } + return 0; +} - if (id->device == PCI_DEVICE_ID_INTEL_ITC_LPC - || id->device == PCI_DEVICE_ID_INTEL_CENTERTON_ILB) { - pci_read_config_dword(dev, WDTBASE, &base_addr_cfg); - base_addr = 0; - if (!(base_addr_cfg & (1 << 31))) - dev_warn(&dev->dev, "Decode of the WDT I/O range disabled\n"); - else - base_addr = (unsigned short)base_addr_cfg; - if (base_addr == 0) - dev_warn(&dev->dev, "I/O space for WDT uninitialized\n"); - else { - lpc_sch_cells[cells++] = wdt_sch_cell; - wdt_sch_resource.start = base_addr; - wdt_sch_resource.end = base_addr + WDT_IO_SIZE - 1; - } - } +static int lpc_sch_populate_cell(struct pci_dev *pdev, int where, + const char *name, int size, int id, + struct mfd_cell *cell) +{ + struct resource *res; + int ret; - if (WARN_ON(cells > ARRAY_SIZE(lpc_sch_cells))) { - dev_err(&dev->dev, "Cell count exceeds array size"); - return -ENODEV; - } + res = devm_kzalloc(&pdev->dev, sizeof(*res), GFP_KERNEL); + if (!res) + return -ENOMEM; + + ret = lpc_sch_get_io(pdev, where, name, res, size); + if (ret) + return ret; + + memset(cell, 0, sizeof(*cell)); + + cell->name = name; + cell->resources = res; + cell->num_resources = 1; + cell->ignore_resource_conflicts = true; + cell->id = id; + + return 0; +} + +static int lpc_sch_probe(struct pci_dev *dev, const struct pci_device_id *id) +{ + struct mfd_cell lpc_sch_cells[3]; + struct lpc_sch_info *info = &sch_chipset_info[id->driver_data]; + unsigned int cells = 0; + int ret; + + ret = lpc_sch_populate_cell(dev, SMBASE, "isch_smbus", + info->io_size_smbus, + id->device, &lpc_sch_cells[cells]); + if (ret < 0) + return ret; + if (ret == 0) + cells++; + + ret = lpc_sch_populate_cell(dev, GPIOBASE, "sch_gpio", + info->io_size_gpio, + id->device, &lpc_sch_cells[cells]); + if (ret < 0) + return ret; + if (ret == 0) + cells++; + + ret = lpc_sch_populate_cell(dev, WDTBASE, "ie6xx_wdt", + info->io_size_wdt, + id->device, &lpc_sch_cells[cells]); + if (ret < 0) + return ret; + if (ret == 0) + cells++; if (cells == 0) { dev_err(&dev->dev, "All decode registers disabled.\n"); return -ENODEV; } - for (i = 0; i < cells; i++) - lpc_sch_cells[i].id = id->device; - ret = mfd_add_devices(&dev->dev, 0, lpc_sch_cells, cells, NULL, 0, NULL); if (ret) mfd_remove_devices(&dev->dev); -- cgit v1.2.3 From ec689a8a8155ce8b966bd5d7737a3916f5e48be3 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Tue, 2 Sep 2014 13:45:21 +0300 Subject: mfd: lpc_sch: Add support for Intel Quark X1000 Intel Quark X1000 SoC supports IRQ based GPIO. This patch will enable MFD support for Quark X1000 and provide IRQ resources to Quark X1000 GPIO device driver. Signed-off-by: Chang Rebecca Swee Fun Tested-by: Chang Rebecca Swee Fun Signed-off-by: Andy Shevchenko Signed-off-by: Lee Jones --- drivers/mfd/lpc_sch.c | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/mfd/lpc_sch.c b/drivers/mfd/lpc_sch.c index bde070a3a3c0..ae614b2aca7e 100644 --- a/drivers/mfd/lpc_sch.c +++ b/drivers/mfd/lpc_sch.c @@ -37,6 +37,9 @@ #define GPIO_IO_SIZE 64 #define GPIO_IO_SIZE_CENTERTON 128 +/* Intel Quark X1000 GPIO IRQ Number */ +#define GPIO_IRQ_QUARK_X1000 9 + #define WDTBASE 0x84 #define WDT_IO_SIZE 64 @@ -44,28 +47,37 @@ enum sch_chipsets { LPC_SCH = 0, /* Intel Poulsbo SCH */ LPC_ITC, /* Intel Tunnel Creek */ LPC_CENTERTON, /* Intel Centerton */ + LPC_QUARK_X1000, /* Intel Quark X1000 */ }; struct lpc_sch_info { unsigned int io_size_smbus; unsigned int io_size_gpio; unsigned int io_size_wdt; + int irq_gpio; }; static struct lpc_sch_info sch_chipset_info[] = { [LPC_SCH] = { .io_size_smbus = SMBUS_IO_SIZE, .io_size_gpio = GPIO_IO_SIZE, + .irq_gpio = -1, }, [LPC_ITC] = { .io_size_smbus = SMBUS_IO_SIZE, .io_size_gpio = GPIO_IO_SIZE, .io_size_wdt = WDT_IO_SIZE, + .irq_gpio = -1, }, [LPC_CENTERTON] = { .io_size_smbus = SMBUS_IO_SIZE, .io_size_gpio = GPIO_IO_SIZE_CENTERTON, .io_size_wdt = WDT_IO_SIZE, + .irq_gpio = -1, + }, + [LPC_QUARK_X1000] = { + .io_size_gpio = GPIO_IO_SIZE, + .irq_gpio = GPIO_IRQ_QUARK_X1000, }, }; @@ -73,6 +85,7 @@ static const struct pci_device_id lpc_sch_ids[] = { { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC), LPC_SCH }, { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ITC_LPC), LPC_ITC }, { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_CENTERTON_ILB), LPC_CENTERTON }, + { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_QUARK_X1000_ILB), LPC_QUARK_X1000 }, { 0, } }; MODULE_DEVICE_TABLE(pci, lpc_sch_ids); @@ -110,13 +123,13 @@ static int lpc_sch_get_io(struct pci_dev *pdev, int where, const char *name, } static int lpc_sch_populate_cell(struct pci_dev *pdev, int where, - const char *name, int size, int id, - struct mfd_cell *cell) + const char *name, int size, int irq, + int id, struct mfd_cell *cell) { struct resource *res; int ret; - res = devm_kzalloc(&pdev->dev, sizeof(*res), GFP_KERNEL); + res = devm_kcalloc(&pdev->dev, 2, sizeof(*res), GFP_KERNEL); if (!res) return -ENOMEM; @@ -132,6 +145,18 @@ static int lpc_sch_populate_cell(struct pci_dev *pdev, int where, cell->ignore_resource_conflicts = true; cell->id = id; + /* Check if we need to add an IRQ resource */ + if (irq < 0) + return 0; + + res++; + + res->start = irq; + res->end = irq; + res->flags = IORESOURCE_IRQ; + + cell->num_resources++; + return 0; } @@ -143,7 +168,7 @@ static int lpc_sch_probe(struct pci_dev *dev, const struct pci_device_id *id) int ret; ret = lpc_sch_populate_cell(dev, SMBASE, "isch_smbus", - info->io_size_smbus, + info->io_size_smbus, -1, id->device, &lpc_sch_cells[cells]); if (ret < 0) return ret; @@ -151,7 +176,7 @@ static int lpc_sch_probe(struct pci_dev *dev, const struct pci_device_id *id) cells++; ret = lpc_sch_populate_cell(dev, GPIOBASE, "sch_gpio", - info->io_size_gpio, + info->io_size_gpio, info->irq_gpio, id->device, &lpc_sch_cells[cells]); if (ret < 0) return ret; @@ -159,7 +184,7 @@ static int lpc_sch_probe(struct pci_dev *dev, const struct pci_device_id *id) cells++; ret = lpc_sch_populate_cell(dev, WDTBASE, "ie6xx_wdt", - info->io_size_wdt, + info->io_size_wdt, -1, id->device, &lpc_sch_cells[cells]); if (ret < 0) return ret; -- cgit v1.2.3 From 85de80e8df54b43fadf6e33b3704dc3ea60181f9 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Tue, 2 Sep 2014 13:45:22 +0300 Subject: mfd: lpc_sch: Remove FSF address This patch removes FSF address because it can be changed. While here, update the copyright lines by adding Intel Corp. to them. There is no functional change. Signed-off-by: Andy Shevchenko Signed-off-by: Lee Jones --- drivers/mfd/lpc_sch.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/mfd/lpc_sch.c b/drivers/mfd/lpc_sch.c index ae614b2aca7e..c980da479a35 100644 --- a/drivers/mfd/lpc_sch.c +++ b/drivers/mfd/lpc_sch.c @@ -7,6 +7,7 @@ * Configuration Registers. * * Copyright (c) 2010 CompuLab Ltd + * Copyright (c) 2014 Intel Corp. * Author: Denis Turischev * * This program is free software; you can redistribute it and/or modify @@ -17,10 +18,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include -- cgit v1.2.3 From 8bdf87b400271ebc7fbf71e117c299d19a97ebb4 Mon Sep 17 00:00:00 2001 From: Guodong Xu Date: Mon, 1 Sep 2014 16:28:34 +0800 Subject: mfd: Add HI6421 PMIC Core driver This adds driver to support HiSilicon Hi6421 PMIC. Hi6421 includes multi- functions, such as regulators, codec, ADCs, Coulomb counter, etc. This driver includes core APIs _only_. Drivers for individul components, like voltage regulators, are implemented in corresponding driver directories and files. Registers in Hi6421 are memory mapped, so using regmap-mmio API. Signed-off-by: Guodong Xu Signed-off-by: Lee Jones --- drivers/mfd/Kconfig | 13 +++++ drivers/mfd/Makefile | 1 + drivers/mfd/hi6421-pmic-core.c | 113 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 127 insertions(+) create mode 100644 drivers/mfd/hi6421-pmic-core.c (limited to 'drivers') diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 049796a28215..609b7a2144d6 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -210,6 +210,19 @@ config MFD_MC13XXX_I2C help Select this if your MC13xxx is connected via an I2C bus. +config MFD_HI6421_PMIC + tristate "HiSilicon Hi6421 PMU/Codec IC" + depends on OF + select MFD_CORE + select REGMAP_MMIO + help + Add support for HiSilicon Hi6421 PMIC. Hi6421 includes multi- + functions, such as regulators, RTC, codec, Coulomb counter, etc. + This driver includes core APIs _only_. You have to select + individul components like voltage regulators under corresponding + menus in order to enable them. + We communicate with the Hi6421 via memory-mapped I/O. + config HTC_EGPIO bool "HTC EGPIO support" depends on GPIOLIB && ARM diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index bd111213bd58..1d11a247abbb 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -172,6 +172,7 @@ obj-$(CONFIG_MFD_AS3722) += as3722.o obj-$(CONFIG_MFD_STW481X) += stw481x.o obj-$(CONFIG_MFD_IPAQ_MICRO) += ipaq-micro.o obj-$(CONFIG_MFD_MENF21BMC) += menf21bmc.o +obj-$(CONFIG_MFD_HI6421_PMIC) += hi6421-pmic-core.o intel-soc-pmic-objs := intel_soc_pmic_core.o intel_soc_pmic_crc.o obj-$(CONFIG_INTEL_SOC_PMIC) += intel-soc-pmic.o diff --git a/drivers/mfd/hi6421-pmic-core.c b/drivers/mfd/hi6421-pmic-core.c new file mode 100644 index 000000000000..321a2656fd00 --- /dev/null +++ b/drivers/mfd/hi6421-pmic-core.c @@ -0,0 +1,113 @@ +/* + * Device driver for Hi6421 IC + * + * Copyright (c) <2011-2014> HiSilicon Technologies Co., Ltd. + * http://www.hisilicon.com + * Copyright (c) <2013-2014> Linaro Ltd. + * http://www.linaro.org + * + * Author: Guodong Xu + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +static const struct mfd_cell hi6421_devs[] = { + { .name = "hi6421-regulator", }, +}; + +static struct regmap_config hi6421_regmap_config = { + .reg_bits = 32, + .reg_stride = 4, + .val_bits = 8, + .max_register = HI6421_REG_TO_BUS_ADDR(HI6421_REG_MAX), +}; + +static int hi6421_pmic_probe(struct platform_device *pdev) +{ + struct hi6421_pmic *pmic; + struct resource *res; + void __iomem *base; + int ret; + + pmic = devm_kzalloc(&pdev->dev, sizeof(*pmic), GFP_KERNEL); + if (!pmic) + return -ENOMEM; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(base)) + return PTR_ERR(base); + + pmic->regmap = devm_regmap_init_mmio_clk(&pdev->dev, NULL, base, + &hi6421_regmap_config); + if (IS_ERR(pmic->regmap)) { + dev_err(&pdev->dev, + "regmap init failed: %ld\n", PTR_ERR(pmic->regmap)); + return PTR_ERR(pmic->regmap); + } + + /* set over-current protection debounce 8ms */ + regmap_update_bits(pmic->regmap, HI6421_OCP_DEB_CTRL_REG, + (HI6421_OCP_DEB_SEL_MASK + | HI6421_OCP_EN_DEBOUNCE_MASK + | HI6421_OCP_AUTO_STOP_MASK), + (HI6421_OCP_DEB_SEL_8MS + | HI6421_OCP_EN_DEBOUNCE_ENABLE)); + + platform_set_drvdata(pdev, pmic); + + ret = mfd_add_devices(&pdev->dev, 0, hi6421_devs, + ARRAY_SIZE(hi6421_devs), NULL, 0, NULL); + if (ret) { + dev_err(&pdev->dev, "add mfd devices failed: %d\n", ret); + return ret; + } + + return 0; +} + +static int hi6421_pmic_remove(struct platform_device *pdev) +{ + mfd_remove_devices(&pdev->dev); + + return 0; +} + +static struct of_device_id of_hi6421_pmic_match_tbl[] = { + { .compatible = "hisilicon,hi6421-pmic", }, + { }, +}; + +static struct platform_driver hi6421_pmic_driver = { + .driver = { + .name = "hi6421_pmic", + .of_match_table = of_hi6421_pmic_match_tbl, + }, + .probe = hi6421_pmic_probe, + .remove = hi6421_pmic_remove, +}; +module_platform_driver(hi6421_pmic_driver); + +MODULE_AUTHOR("Guodong Xu "); +MODULE_DESCRIPTION("Hi6421 PMIC driver"); +MODULE_LICENSE("GPL v2"); -- cgit v1.2.3 From 970d9fbca95c2f5277a4f55c2fba9a8b615c38f7 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Thu, 4 Sep 2014 12:32:12 +0300 Subject: mfd: pcf50633: Use sprintf directly When dump a content of the registers let's use snprintf() directly with %*ph specifier. Signed-off-by: Andy Shevchenko Signed-off-by: Lee Jones --- drivers/mfd/pcf50633-core.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/mfd/pcf50633-core.c b/drivers/mfd/pcf50633-core.c index e15c060d2dc7..43664eb69c93 100644 --- a/drivers/mfd/pcf50633-core.c +++ b/drivers/mfd/pcf50633-core.c @@ -106,10 +106,7 @@ static ssize_t show_dump_regs(struct device *dev, struct device_attribute *attr, } else dump[n1] = pcf50633_reg_read(pcf, n + n1); - hex_dump_to_buffer(dump, sizeof(dump), 16, 1, buf1, 128, 0); - buf1 += strlen(buf1); - *buf1++ = '\n'; - *buf1 = '\0'; + buf1 += sprintf(buf1, "%*ph\n", (int)sizeof(dump), dump); } return buf1 - buf; -- cgit v1.2.3 From 34a4958e4cfe1a379ed18fb3e2d0b93ba08f28d3 Mon Sep 17 00:00:00 2001 From: Markus Pargmann Date: Mon, 8 Sep 2014 09:01:11 +0200 Subject: mfd: mc13xxx: Configure WDI reset Setup the PMIC to make a restart when a watchdog interrupt occures. If this is not configured, the PMIC will shut down the power supply without a restart. Signed-off-by: Markus Pargmann Signed-off-by: Lee Jones --- drivers/mfd/mc13xxx-core.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'drivers') diff --git a/drivers/mfd/mc13xxx-core.c b/drivers/mfd/mc13xxx-core.c index 2b6bc868cd3d..64dde5d24b32 100644 --- a/drivers/mfd/mc13xxx-core.c +++ b/drivers/mfd/mc13xxx-core.c @@ -36,6 +36,9 @@ #define MC34708_REVISION_FIN (0x07 << 6) #define MC34708_REVISION_FAB (0x07 << 9) +#define MC13XXX_PWRCTRL 15 +#define MC13XXX_PWRCTRL_WDIRESET (1 << 12) + #define MC13XXX_ADC1 44 #define MC13XXX_ADC1_ADEN (1 << 0) #define MC13XXX_ADC1_RAND (1 << 1) @@ -416,6 +419,11 @@ int mc13xxx_common_init(struct device *dev) mc13xxx->variant->print_revision(mc13xxx, revision); + ret = mc13xxx_reg_rmw(mc13xxx, MC13XXX_PWRCTRL, + MC13XXX_PWRCTRL_WDIRESET, MC13XXX_PWRCTRL_WDIRESET); + if (ret) + return ret; + for (i = 0; i < ARRAY_SIZE(mc13xxx->irqs); i++) { mc13xxx->irqs[i].reg_offset = i / MC13XXX_IRQ_PER_REG; mc13xxx->irqs[i].mask = BIT(i % MC13XXX_IRQ_PER_REG); -- cgit v1.2.3 From 0b496b4c95c74ba795bc642a6092263ebf905759 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 5 Sep 2014 22:16:18 +0100 Subject: mfd: tps65217: Tell regmap what registers are valid Allow regmap to provide debugfs access to the register map by telling it what registers are valid. Signed-off-by: Mark Brown Signed-off-by: Lee Jones --- drivers/mfd/tps65217.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/mfd/tps65217.c b/drivers/mfd/tps65217.c index 3cc4c7084b92..a8ee52c95f2f 100644 --- a/drivers/mfd/tps65217.c +++ b/drivers/mfd/tps65217.c @@ -146,6 +146,8 @@ EXPORT_SYMBOL_GPL(tps65217_clear_bits); static struct regmap_config tps65217_regmap_config = { .reg_bits = 8, .val_bits = 8, + + .max_register = TPS65217_REG_MAX, }; static const struct of_device_id tps65217_of_match[] = { -- cgit v1.2.3 From 6a71f38dd87f255a0586104ce2a14d5a3ddf3401 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Mon, 8 Sep 2014 15:28:42 +0200 Subject: mfd: ti_am335x_tscadc: Fix TSC resume In the resume path, the ADC invokes am335x_tsc_se_set_cache() with 0 as the steps argument if continous mode is not in use. This in turn disables all steps and so the TSC is not working until one ADC sampling is performed. This patch fixes it by writing the current cached mask instead of the passed steps. Fixes: 7ca6740cd1cd ("mfd: input: iio: ti_amm335x: Rework TSC/ADCA synchronization") Cc: stable@vger.kernel.org # v3.13+ Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Lee Jones --- drivers/mfd/ti_am335x_tscadc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c index 8b119ce20b93..121add8be456 100644 --- a/drivers/mfd/ti_am335x_tscadc.c +++ b/drivers/mfd/ti_am335x_tscadc.c @@ -57,7 +57,7 @@ void am335x_tsc_se_set_cache(struct ti_tscadc_dev *tsadc, u32 val) if (tsadc->adc_waiting) wake_up(&tsadc->reg_se_wait); else if (!tsadc->adc_in_use) - tscadc_writel(tsadc, REG_SE, val); + tscadc_writel(tsadc, REG_SE, tsadc->reg_se_cache); spin_unlock_irqrestore(&tsadc->reg_lock, flags); } -- cgit v1.2.3 From 5152970538a5e16c03bbcb9f1c780489a795ed40 Mon Sep 17 00:00:00 2001 From: Chris Ball Date: Thu, 4 Sep 2014 17:11:53 +0100 Subject: mfd: rtsx_pcr: Fix MSI enable error handling pci_enable_msi() can return failure with both positive and negative integers -- it returns 0 for success -- but is only tested here for "if (ret < 0)". This causes us to try to use MSI on the RTS5249 SD reader in the Dell XPS 11 when enabling MSI failed, causing: [ 1.737110] rtsx_pci: probe of 0000:05:00.0 failed with error -110 Cc: stable Reported-by: D. Jared Dominguez Tested-by: D. Jared Dominguez Signed-off-by: Chris Ball Signed-off-by: Lee Jones --- drivers/mfd/rtsx_pcr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c index d01b8c249231..f2643c221d34 100644 --- a/drivers/mfd/rtsx_pcr.c +++ b/drivers/mfd/rtsx_pcr.c @@ -1197,7 +1197,7 @@ static int rtsx_pci_probe(struct pci_dev *pcidev, pcr->msi_en = msi_en; if (pcr->msi_en) { ret = pci_enable_msi(pcidev); - if (ret < 0) + if (ret) pcr->msi_en = false; } -- cgit v1.2.3 From bdaf67030cbab21a91fd2d6b1771cf336a0dd092 Mon Sep 17 00:00:00 2001 From: Jaewon Kim Date: Fri, 12 Sep 2014 13:35:45 +0900 Subject: mfd: intel_soc_pmic: Add CONFIG_PM_SLEEP check for suspend_fn/resume_fn This patch fix warning message with CONFIG_PM_SLEEP disabled If CONFIG_PM_SLEEP is not enabled we receive the following warning message: drivers/mfd/intel_soc_pmic_core.c:118:12: warning: 'intel_soc_pmic_suspend' defined but not used Signed-off-by: Jaewon Kim Signed-off-by: Lee Jones --- drivers/mfd/intel_soc_pmic_core.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/mfd/intel_soc_pmic_core.c b/drivers/mfd/intel_soc_pmic_core.c index 2720922f90b4..df7b0642a5b4 100644 --- a/drivers/mfd/intel_soc_pmic_core.c +++ b/drivers/mfd/intel_soc_pmic_core.c @@ -115,6 +115,7 @@ static void intel_soc_pmic_shutdown(struct i2c_client *i2c) return; } +#if defined(CONFIG_PM_SLEEP) static int intel_soc_pmic_suspend(struct device *dev) { struct intel_soc_pmic *pmic = dev_get_drvdata(dev); @@ -132,6 +133,7 @@ static int intel_soc_pmic_resume(struct device *dev) return 0; } +#endif static SIMPLE_DEV_PM_OPS(intel_soc_pmic_pm_ops, intel_soc_pmic_suspend, intel_soc_pmic_resume); -- cgit v1.2.3 From 851ec59614d8cd0d122319c32a5be0f8799d36be Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Fri, 12 Sep 2014 11:18:33 +0800 Subject: mfd: stmpe: Support gpio over irq under device tree The stmpe_platform_data has a irq_over_gpio field, which allows the system to read STMPE events whenever an IRQ occurs on a GPIO pin. This patch adds the ability to configure this field and to use a GPIO as an IRQ source for boards configuring the STMPE in device tree. Signed-off-by: Sean Cross Signed-off-by: Lee Jones --- drivers/mfd/stmpe.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c index f9d46f035bb1..e2f9df1c0c36 100644 --- a/drivers/mfd/stmpe.c +++ b/drivers/mfd/stmpe.c @@ -1122,7 +1122,12 @@ static void stmpe_of_probe(struct stmpe_platform_data *pdata, if (pdata->id < 0) pdata->id = -1; - pdata->irq_trigger = IRQF_TRIGGER_NONE; + pdata->irq_gpio = of_get_named_gpio_flags(np, "irq-gpio", 0, + &pdata->irq_trigger); + if (gpio_is_valid(pdata->irq_gpio)) + pdata->irq_over_gpio = 1; + else + pdata->irq_trigger = IRQF_TRIGGER_NONE; of_property_read_u32(np, "st,autosleep-timeout", &pdata->autosleep_timeout); -- cgit v1.2.3 From be69e9e00718ac5e93a22184ed33d8d719bee9cd Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Fri, 5 Sep 2014 12:15:10 +0200 Subject: mfd: max14577: Don't pass IRQ domain to mfd_add_devices The max14577 MFD cells do not have any resources so the IRQ domain passed to mfd_add_devices is not used. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Lee Jones --- drivers/mfd/max14577.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/mfd/max14577.c b/drivers/mfd/max14577.c index b8af263be594..de96b7fb1f6d 100644 --- a/drivers/mfd/max14577.c +++ b/drivers/mfd/max14577.c @@ -456,8 +456,7 @@ static int max14577_i2c_probe(struct i2c_client *i2c, } ret = mfd_add_devices(max14577->dev, -1, mfd_devs, - mfd_devs_size, NULL, 0, - regmap_irq_get_domain(max14577->irq_data)); + mfd_devs_size, NULL, 0, NULL); if (ret < 0) goto err_mfd; -- cgit v1.2.3 From cfeb35da2ae36e26f6136b80351a06d34776587b Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Tue, 9 Sep 2014 17:00:09 +0100 Subject: mfd: arizona: Use handle_simple_irq for IRQ dispatch chip We use a dummy IRQ chip to dispatch interrupts to the two seperate IRQ domains on the Arizona devices. This is just a simple software IRQ chip and thus the current handle_edge_irq is unnecessary for its needs. Signed-off-by: Charles Keepax Signed-off-by: Lee Jones --- drivers/mfd/arizona-irq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/mfd/arizona-irq.c b/drivers/mfd/arizona-irq.c index 5e2f450a6176..3a3fe7cc6d61 100644 --- a/drivers/mfd/arizona-irq.c +++ b/drivers/mfd/arizona-irq.c @@ -172,7 +172,7 @@ static int arizona_irq_map(struct irq_domain *h, unsigned int virq, struct regmap_irq_chip_data *data = h->host_data; irq_set_chip_data(virq, data); - irq_set_chip_and_handler(virq, &arizona_irq_chip, handle_edge_irq); + irq_set_chip_and_handler(virq, &arizona_irq_chip, handle_simple_irq); irq_set_nested_thread(virq, 1); /* ARM needs us to explicitly flag the IRQ as valid -- cgit v1.2.3 From 2adb3b8e6fa310d64ea6209f8ac5d5575839f6da Mon Sep 17 00:00:00 2001 From: Doug Anderson Date: Tue, 9 Sep 2014 16:06:04 -0700 Subject: mfd: rk808: Add register caching Let's define the voltatile registers (those that can't be cached) and enable caching. The rk808 is accessed almost constantly with cpufreq so this is really nice. As measured by ftrace: before this change: cpu0_set_target() => ~2200us after this change: cpu0_set_target() => ~500us Signed-off-by: Doug Anderson Reviewed-by: Chris Zhong Signed-off-by: Lee Jones --- drivers/mfd/rk808.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'drivers') diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c index 0324422b3b10..bd0215069875 100644 --- a/drivers/mfd/rk808.c +++ b/drivers/mfd/rk808.c @@ -29,10 +29,40 @@ struct rk808_reg_data { int value; }; +static bool rk808_is_volatile_reg(struct device *dev, unsigned int reg) +{ + /* + * Notes: + * - Technically the ROUND_30s bit makes RTC_CTRL_REG volatile, but + * we don't use that feature. It's better to cache. + * - It's unlikely we care that RK808_DEVCTRL_REG is volatile since + * bits are cleared in case when we shutoff anyway, but better safe. + */ + + switch (reg) { + case RK808_SECONDS_REG ... RK808_WEEKS_REG: + case RK808_RTC_STATUS_REG: + case RK808_VB_MON_REG: + case RK808_THERMAL_REG: + case RK808_DCDC_UV_STS_REG: + case RK808_LDO_UV_STS_REG: + case RK808_DCDC_PG_REG: + case RK808_LDO_PG_REG: + case RK808_DEVCTRL_REG: + case RK808_INT_STS_REG1: + case RK808_INT_STS_REG2: + return true; + } + + return false; +} + static const struct regmap_config rk808_regmap_config = { .reg_bits = 8, .val_bits = 8, .max_register = RK808_IO_POL_REG, + .cache_type = REGCACHE_RBTREE, + .volatile_reg = rk808_is_volatile_reg, }; static struct resource rtc_resources[] = { -- cgit v1.2.3 From fecc4452b9b3f4bbab41c1b7583a72066ee0c77c Mon Sep 17 00:00:00 2001 From: Nishanth Menon Date: Wed, 17 Sep 2014 07:34:12 -0500 Subject: mfd: twl4030-power: Use 'ti,system-power-controller' as alternative way to support system power off ti,system-power-controller is more or less the standard way of indicating that the PMIC is the system wide power controller and hence may be used to switch off the system. Almost ALL TI PMIC drivers and many Maxim PMIC drivers follow the same style. So support 'ti,system-power-controller' in addition to the usual 'ti,use_poweroff' to indicate that the PMIC instance has control for switching off the system. Signed-off-by: Nishanth Menon Acked-by: Tony Lindgren Signed-off-by: Lee Jones --- drivers/mfd/twl4030-power.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers') diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c index 3bc969a5916b..1c129ba68dde 100644 --- a/drivers/mfd/twl4030-power.c +++ b/drivers/mfd/twl4030-power.c @@ -627,6 +627,9 @@ static bool twl4030_power_use_poweroff(const struct twl4030_power_data *pdata, if (pdata && pdata->use_poweroff) return true; + if (of_property_read_bool(node, "ti,system-power-controller")) + return true; + if (of_property_read_bool(node, "ti,use_poweroff")) return true; -- cgit v1.2.3 From 6e6240a449614148d3fb49b23a50435b19c6baed Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Sat, 20 Sep 2014 22:06:35 +0200 Subject: mfd: axp209x: Drop the parent supplies field Now that the regulator code get its parent supplies purely from the DT, we can drop the parent supplies resources in the MFD driver. Signed-off-by: Maxime Ripard Signed-off-by: Lee Jones --- drivers/mfd/axp20x.c | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'drivers') diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c index dee653989e3a..6231adbb295d 100644 --- a/drivers/mfd/axp20x.c +++ b/drivers/mfd/axp20x.c @@ -140,15 +140,6 @@ static const struct regmap_irq_chip axp20x_regmap_irq_chip = { .init_ack_masked = true, }; -static const char * const axp20x_supplies[] = { - "acin", - "vin2", - "vin3", - "ldo24in", - "ldo3in", - "ldo5in", -}; - static struct mfd_cell axp20x_cells[] = { { .name = "axp20x-pek", @@ -156,8 +147,6 @@ static struct mfd_cell axp20x_cells[] = { .resources = axp20x_pek_resources, }, { .name = "axp20x-regulator", - .parent_supplies = axp20x_supplies, - .num_parent_supplies = ARRAY_SIZE(axp20x_supplies), }, }; -- cgit v1.2.3 From c3a973a770a122a5ec9a9b827ae25c00f56b3e47 Mon Sep 17 00:00:00 2001 From: Josh Cartwright Date: Fri, 1 Aug 2014 17:30:48 +0300 Subject: mfd: Add support for Qualcomm SPMI PMICs The Qualcomm SPMI PMIC chips are components used with the Snapdragon 800 series SoC family. This driver exists largely as a glue mfd component, it exists to be an owner of an SPMI regmap for children devices described in device tree. Signed-off-by: Josh Cartwright Signed-off-by: Stanimir Varbanov Signed-off-by: Lee Jones --- drivers/mfd/Kconfig | 15 ++++++++++ drivers/mfd/Makefile | 1 + drivers/mfd/qcom-spmi-pmic.c | 67 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 drivers/mfd/qcom-spmi-pmic.c (limited to 'drivers') diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 609b7a2144d6..1456ea70bbc7 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -567,6 +567,21 @@ config MFD_PM8921_CORE Say M here if you want to include support for PM8921 chip as a module. This will build a module called "pm8921-core". +config MFD_SPMI_PMIC + tristate "Qualcomm SPMI PMICs" + depends on ARCH_QCOM || COMPILE_TEST + depends on OF + depends on SPMI + select REGMAP_SPMI + help + This enables support for the Qualcomm SPMI PMICs. + These PMICs are currently used with the Snapdragon 800 series of + SoCs. Note, that this will only be useful paired with descriptions + of the independent functions as children nodes in the device tree. + + Say M here if you want to include support for the SPMI PMIC + series as a module. The module will be called "qcom-spmi-pmic". + config MFD_RDC321X tristate "RDC R-321x southbridge" select MFD_CORE diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 1d11a247abbb..8bd54b1253af 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -153,6 +153,7 @@ obj-$(CONFIG_MFD_SI476X_CORE) += si476x-core.o obj-$(CONFIG_MFD_CS5535) += cs5535-mfd.o obj-$(CONFIG_MFD_OMAP_USB_HOST) += omap-usb-host.o omap-usb-tll.o obj-$(CONFIG_MFD_PM8921_CORE) += pm8921-core.o ssbi.o +obj-$(CONFIG_MFD_SPMI_PMIC) += qcom-spmi-pmic.o obj-$(CONFIG_TPS65911_COMPARATOR) += tps65911-comparator.o obj-$(CONFIG_MFD_TPS65090) += tps65090.o obj-$(CONFIG_MFD_AAT2870_CORE) += aat2870-core.o diff --git a/drivers/mfd/qcom-spmi-pmic.c b/drivers/mfd/qcom-spmi-pmic.c new file mode 100644 index 000000000000..4b8beb2a1579 --- /dev/null +++ b/drivers/mfd/qcom-spmi-pmic.c @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2014, The Linux Foundation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include + +static const struct regmap_config spmi_regmap_config = { + .reg_bits = 16, + .val_bits = 8, + .max_register = 0xffff, + .fast_io = true, +}; + +static int pmic_spmi_probe(struct spmi_device *sdev) +{ + struct device_node *root = sdev->dev.of_node; + struct regmap *regmap; + + regmap = devm_regmap_init_spmi_ext(sdev, &spmi_regmap_config); + if (IS_ERR(regmap)) + return PTR_ERR(regmap); + + return of_platform_populate(root, NULL, NULL, &sdev->dev); +} + +static void pmic_spmi_remove(struct spmi_device *sdev) +{ + of_platform_depopulate(&sdev->dev); +} + +static const struct of_device_id pmic_spmi_id_table[] = { + { .compatible = "qcom,spmi-pmic" }, + { .compatible = "qcom,pm8941" }, + { .compatible = "qcom,pm8841" }, + { .compatible = "qcom,pma8084" }, + { } +}; +MODULE_DEVICE_TABLE(of, pmic_spmi_id_table); + +static struct spmi_driver pmic_spmi_driver = { + .probe = pmic_spmi_probe, + .remove = pmic_spmi_remove, + .driver = { + .name = "pmic-spmi", + .of_match_table = pmic_spmi_id_table, + }, +}; +module_spmi_driver(pmic_spmi_driver); + +MODULE_DESCRIPTION("Qualcomm SPMI PMIC driver"); +MODULE_ALIAS("spmi:spmi-pmic"); +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("Josh Cartwright "); +MODULE_AUTHOR("Stanimir Varbanov "); -- cgit v1.2.3 From 4f08df1b06bb4022fab5a2a916f455915856ed9e Mon Sep 17 00:00:00 2001 From: Boris BREZILLON Date: Mon, 22 Sep 2014 21:37:55 +0200 Subject: mfd: Inherit coherent_dma_mask from parent device dma_mask and dma_parms are already inherited from the parent device but dma_coherent_mask was left uninitialized (set to zero thanks to kzalloc). Set sub-device coherent_dma_mask to its parent value to simplify sub-drivers making use of dma coherent helper functions (those drivers currently have to explicitly set the dma coherent mask using dma_set_coherent_mask function). Signed-off-by: Boris BREZILLON Acked-by: Arnd Bergmann Signed-off-by: Lee Jones --- drivers/mfd/mfd-core.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c index 892d343193ad..5d0fbe1e097a 100644 --- a/drivers/mfd/mfd-core.c +++ b/drivers/mfd/mfd-core.c @@ -101,6 +101,7 @@ static int mfd_add_device(struct device *parent, int id, pdev->dev.type = &mfd_dev_type; pdev->dev.dma_mask = parent->dma_mask; pdev->dev.dma_parms = parent->dma_parms; + pdev->dev.coherent_dma_mask = parent->coherent_dma_mask; ret = regulator_bulk_register_supply_alias( &pdev->dev, cell->parent_supplies, -- cgit v1.2.3 From f0933a60d1902c918249d11fb6d9a5ffd581ef5b Mon Sep 17 00:00:00 2001 From: Jeff Lance Date: Thu, 4 Sep 2014 19:01:57 +0200 Subject: mfd: ti_am335x_tscadc: Update logic in CTRL register for 5-wire TS The logic in AFE_Pen_Ctrl bitmask in the CTRL register is different for five wire versus four or eight wire touschscreens. This patch should fix this for five-wire touch screens. There should be no change needed here for four and eight wire tousch screens. Signed-off-by: Jeff Lance [bigeasy: keep the change mfd only] Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Lee Jones --- drivers/mfd/ti_am335x_tscadc.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'drivers') diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c index 121add8be456..d877e777cce6 100644 --- a/drivers/mfd/ti_am335x_tscadc.c +++ b/drivers/mfd/ti_am335x_tscadc.c @@ -242,18 +242,20 @@ static int ti_tscadc_probe(struct platform_device *pdev) tscadc_writel(tscadc, REG_CLKDIV, tscadc->clk_div); /* Set the control register bits */ - ctrl = CNTRLREG_STEPCONFIGWRT | - CNTRLREG_STEPID; - if (tsc_wires > 0) - ctrl |= CNTRLREG_4WIRE | CNTRLREG_TSCENB; + ctrl = CNTRLREG_STEPCONFIGWRT | CNTRLREG_STEPID; tscadc_writel(tscadc, REG_CTRL, ctrl); /* Set register bits for Idle Config Mode */ - if (tsc_wires > 0) + if (tsc_wires > 0) { + tscadc->tsc_wires = tsc_wires; + if (tsc_wires == 5) + ctrl |= CNTRLREG_5WIRE | CNTRLREG_TSCENB; + else + ctrl |= CNTRLREG_4WIRE | CNTRLREG_TSCENB; tscadc_idle_config(tscadc); + } /* Enable the TSC module enable bit */ - ctrl = tscadc_readl(tscadc, REG_CTRL); ctrl |= CNTRLREG_TSCSSENB; tscadc_writel(tscadc, REG_CTRL, ctrl); @@ -325,21 +327,23 @@ static int tscadc_suspend(struct device *dev) static int tscadc_resume(struct device *dev) { struct ti_tscadc_dev *tscadc_dev = dev_get_drvdata(dev); - unsigned int restore, ctrl; + u32 ctrl; pm_runtime_get_sync(dev); /* context restore */ ctrl = CNTRLREG_STEPCONFIGWRT | CNTRLREG_STEPID; - if (tscadc_dev->tsc_cell != -1) - ctrl |= CNTRLREG_TSCENB | CNTRLREG_4WIRE; tscadc_writel(tscadc_dev, REG_CTRL, ctrl); - if (tscadc_dev->tsc_cell != -1) + if (tscadc_dev->tsc_cell != -1) { + if (tscadc_dev->tsc_wires == 5) + ctrl |= CNTRLREG_5WIRE | CNTRLREG_TSCENB; + else + ctrl |= CNTRLREG_4WIRE | CNTRLREG_TSCENB; tscadc_idle_config(tscadc_dev); - restore = tscadc_readl(tscadc_dev, REG_CTRL); - tscadc_writel(tscadc_dev, REG_CTRL, - (restore | CNTRLREG_TSCSSENB)); + } + ctrl |= CNTRLREG_TSCSSENB; + tscadc_writel(tscadc_dev, REG_CTRL, ctrl); tscadc_writel(tscadc_dev, REG_CLKDIV, tscadc_dev->clk_div); -- cgit v1.2.3 From 7be180cc7a0c5768a984126d9468afc82dcf93a2 Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Wed, 24 Sep 2014 10:37:10 +0100 Subject: Revert "mfd: wm5102: Manually apply register patch" This reverts commit d9d03496f6f904a3588bdb8b215853bc4e50132c. It seems this commit was applied twice, once through ASoC and once through MFD: commit 4c9bb8bc352a14c9613c77bc3f1e9038cd086b9b mfd: wm5102: Manually apply register patch commit d9d03496f6f904a3588bdb8b215853bc4e50132c mfd: wm5102: Manually apply register patch This has lead to a small piece of duplicate code. It is harmless hence how it has gone unoticed for so long. This patch reverts one of the two commits removing the unneeded code. Signed-off-by: Charles Keepax Signed-off-by: Lee Jones --- drivers/mfd/arizona-core.c | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'drivers') diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c index 4afb232b5cde..72b3202c6674 100644 --- a/drivers/mfd/arizona-core.c +++ b/drivers/mfd/arizona-core.c @@ -393,18 +393,6 @@ static int arizona_runtime_resume(struct device *dev) break; } - switch (arizona->type) { - case WM5102: - ret = wm5102_patch(arizona); - if (ret != 0) { - dev_err(arizona->dev, "Failed to apply patch: %d\n", - ret); - goto err; - } - default: - break; - } - ret = regcache_sync(arizona->regmap); if (ret != 0) { dev_err(arizona->dev, "Failed to restore register cache\n"); -- cgit v1.2.3 From 6ab3430129e258ea31dd214adf1c760dfafde67a Mon Sep 17 00:00:00 2001 From: Mika Westerberg Date: Tue, 16 Sep 2014 14:52:36 +0300 Subject: mfd: Add ACPI support If an MFD device is backed by ACPI namespace, we should allow subdevice drivers to access their corresponding ACPI companion devices through normal means (e.g using ACPI_COMPANION()). This patch adds such support to the MFD core. If the MFD parent device does not specify any ACPI _HID/_CID for the child device, the child device will share the parent ACPI companion device. Otherwise the child device will be assigned with the corresponding ACPI companion, if found in the namespace below the parent. Signed-off-by: Mika Westerberg Reviewed-by: Darren Hart Signed-off-by: Lee Jones --- drivers/mfd/mfd-core.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'drivers') diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c index 5d0fbe1e097a..f3338fe9d069 100644 --- a/drivers/mfd/mfd-core.c +++ b/drivers/mfd/mfd-core.c @@ -78,6 +78,44 @@ static int mfd_platform_add_cell(struct platform_device *pdev, return 0; } +#if IS_ENABLED(CONFIG_ACPI) +static void mfd_acpi_add_device(const struct mfd_cell *cell, + struct platform_device *pdev) +{ + struct acpi_device *parent_adev; + struct acpi_device *adev; + + parent_adev = ACPI_COMPANION(pdev->dev.parent); + if (!parent_adev) + return; + + /* + * MFD child device gets its ACPI handle either from the ACPI + * device directly under the parent that matches the acpi_pnpid or + * it will use the parent handle if is no acpi_pnpid is given. + */ + adev = parent_adev; + if (cell->acpi_pnpid) { + struct acpi_device_id ids[2] = {}; + struct acpi_device *child_adev; + + strlcpy(ids[0].id, cell->acpi_pnpid, sizeof(ids[0].id)); + list_for_each_entry(child_adev, &parent_adev->children, node) + if (acpi_match_device_ids(child_adev, ids)) { + adev = child_adev; + break; + } + } + + ACPI_COMPANION_SET(&pdev->dev, adev); +} +#else +static inline void mfd_acpi_add_device(const struct mfd_cell *cell, + struct platform_device *pdev) +{ +} +#endif + static int mfd_add_device(struct device *parent, int id, const struct mfd_cell *cell, atomic_t *usage_count, struct resource *mem_base, @@ -119,6 +157,8 @@ static int mfd_add_device(struct device *parent, int id, } } + mfd_acpi_add_device(cell, pdev); + if (cell->pdata_size) { ret = platform_device_add_data(pdev, cell->platform_data, cell->pdata_size); -- cgit v1.2.3 From 71d134b9fa3b435649aca893f79811afc7e4f1f1 Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Wed, 24 Sep 2014 10:37:11 +0100 Subject: mfd: arizona: Correct mask to allow setting micbias external cap Currently the mask for the external capacitor bit is missing when writing the MICBIAS config meaning it will never be set this patch fixes this. Signed-off-by: Charles Keepax Signed-off-by: Lee Jones --- drivers/mfd/arizona-core.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c index 72b3202c6674..bce7c0784b6b 100644 --- a/drivers/mfd/arizona-core.c +++ b/drivers/mfd/arizona-core.c @@ -947,6 +947,7 @@ int arizona_dev_init(struct arizona *arizona) regmap_update_bits(arizona->regmap, ARIZONA_MIC_BIAS_CTRL_1 + i, ARIZONA_MICB1_LVL_MASK | + ARIZONA_MICB1_EXT_CAP | ARIZONA_MICB1_DISCH | ARIZONA_MICB1_BYPASS | ARIZONA_MICB1_RATE, val); -- cgit v1.2.3 From 659e142be09482cfd8b9017f616afebc7cf48fa3 Mon Sep 17 00:00:00 2001 From: Doug Anderson Date: Thu, 18 Sep 2014 17:18:54 +0200 Subject: mfd: cros_ec: Delay for 50ms when we see EC_CMD_REBOOT_EC If someone sends a EC_CMD_REBOOT_EC to the EC, the EC will likely be unresponsive for quite a while. Add a delay to the end of the command to prevent random failures of future commands. NOTES: * This could be optimized a bit by simply delaying the next command sent, but EC_CMD_REBOOT_EC is such a rare command that the extra complexity doesn't seem worth it. * This is a bit of an "ugly hack" since the SPI driver is effectively snooping on the communication and making a lot of assumptions. It would be nice to architect in some better solution long term. * This same logic probably needs to be applied to the i2c driver. Signed-off-by: Doug Anderson Reviewed-by: Randall Spangler Reviewed-by: Vadim Bendebury Signed-off-by: Javier Martinez Canillas Signed-off-by: Lee Jones --- drivers/mfd/cros_ec_spi.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'drivers') diff --git a/drivers/mfd/cros_ec_spi.c b/drivers/mfd/cros_ec_spi.c index 588c700af39c..b396705203fc 100644 --- a/drivers/mfd/cros_ec_spi.c +++ b/drivers/mfd/cros_ec_spi.c @@ -65,6 +65,12 @@ */ #define EC_SPI_RECOVERY_TIME_NS (200 * 1000) +/* + * The EC is unresponsive for a time after a reboot command. Add a + * simple delay to make sure that the bus stays locked. + */ +#define EC_REBOOT_DELAY_MS 50 + /** * struct cros_ec_spi - information about a SPI-connected EC * @@ -318,6 +324,9 @@ static int cros_ec_cmd_xfer_spi(struct cros_ec_device *ec_dev, ret = len; exit: + if (ec_msg->command == EC_CMD_REBOOT_EC) + msleep(EC_REBOOT_DELAY_MS); + mutex_unlock(&ec_spi->lock); return ret; } -- cgit v1.2.3 From a6551a76fff15056fde2342d0f7de41ee605264e Mon Sep 17 00:00:00 2001 From: Andrew Bresticker Date: Thu, 18 Sep 2014 17:18:56 +0200 Subject: mfd: cros_ec: stop calling ->cmd_xfer() directly Instead of having users of the ChromeOS EC call the interface-specific cmd_xfer() callback directly, introduce a central cros_ec_cmd_xfer() to use instead. This will allow us to put all the locking and retry logic in one place instead of duplicating it across the different drivers. Signed-off-by: Andrew Bresticker Reviewed-by: Simon Glass Signed-off-by: Javier Martinez Canillas Reviewed-by: Doug Anderson Signed-off-by: Lee Jones --- drivers/i2c/busses/i2c-cros-ec-tunnel.c | 2 +- drivers/input/keyboard/cros_ec_keyb.c | 2 +- drivers/mfd/cros_ec.c | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/i2c/busses/i2c-cros-ec-tunnel.c b/drivers/i2c/busses/i2c-cros-ec-tunnel.c index 05e033c98115..43be23dfb115 100644 --- a/drivers/i2c/busses/i2c-cros-ec-tunnel.c +++ b/drivers/i2c/busses/i2c-cros-ec-tunnel.c @@ -227,7 +227,7 @@ static int ec_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg i2c_msgs[], msg.indata = response; msg.insize = response_len; - result = bus->ec->cmd_xfer(bus->ec, &msg); + result = cros_ec_cmd_xfer(bus->ec, &msg); if (result < 0) goto exit; diff --git a/drivers/input/keyboard/cros_ec_keyb.c b/drivers/input/keyboard/cros_ec_keyb.c index 791781ade4e7..93111d1aa617 100644 --- a/drivers/input/keyboard/cros_ec_keyb.c +++ b/drivers/input/keyboard/cros_ec_keyb.c @@ -182,7 +182,7 @@ static int cros_ec_keyb_get_state(struct cros_ec_keyb *ckdev, uint8_t *kb_state) .insize = ckdev->cols, }; - return ckdev->ec->cmd_xfer(ckdev->ec, &msg); + return cros_ec_cmd_xfer(ckdev->ec, &msg); } static irqreturn_t cros_ec_keyb_irq(int irq, void *data) diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c index 4873f9c50452..a9faebdcfa14 100644 --- a/drivers/mfd/cros_ec.c +++ b/drivers/mfd/cros_ec.c @@ -62,6 +62,13 @@ int cros_ec_check_result(struct cros_ec_device *ec_dev, } EXPORT_SYMBOL(cros_ec_check_result); +int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev, + struct cros_ec_command *msg) +{ + return ec_dev->cmd_xfer(ec_dev, msg); +} +EXPORT_SYMBOL(cros_ec_cmd_xfer); + static const struct mfd_cell cros_devs[] = { { .name = "cros-ec-keyb", -- cgit v1.2.3 From 63427530fa7a78b42a19f47fb0c12b303c0666ca Mon Sep 17 00:00:00 2001 From: Andrew Bresticker Date: Thu, 18 Sep 2014 17:18:57 +0200 Subject: mfd: cros_ec: move locking into cros_ec_cmd_xfer Now that there's a central cros_ec_cmd_xfer(), move the locking out of the SPI driver. Signed-off-by: Andrew Bresticker Reviewed-by: Simon Glass Signed-off-by: Javier Martinez Canillas Reviewed-by: Doug Anderson Signed-off-by: Lee Jones --- drivers/mfd/cros_ec.c | 10 +++++++++- drivers/mfd/cros_ec_spi.c | 11 ----------- 2 files changed, 9 insertions(+), 12 deletions(-) (limited to 'drivers') diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c index a9faebdcfa14..c53804a1451d 100644 --- a/drivers/mfd/cros_ec.c +++ b/drivers/mfd/cros_ec.c @@ -65,7 +65,13 @@ EXPORT_SYMBOL(cros_ec_check_result); int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev, struct cros_ec_command *msg) { - return ec_dev->cmd_xfer(ec_dev, msg); + int ret; + + mutex_lock(&ec_dev->lock); + ret = ec_dev->cmd_xfer(ec_dev, msg); + mutex_unlock(&ec_dev->lock); + + return ret; } EXPORT_SYMBOL(cros_ec_cmd_xfer); @@ -98,6 +104,8 @@ int cros_ec_register(struct cros_ec_device *ec_dev) return -ENOMEM; } + mutex_init(&ec_dev->lock); + err = mfd_add_devices(dev, 0, cros_devs, ARRAY_SIZE(cros_devs), NULL, ec_dev->irq, NULL); diff --git a/drivers/mfd/cros_ec_spi.c b/drivers/mfd/cros_ec_spi.c index b396705203fc..bf6e08e8013e 100644 --- a/drivers/mfd/cros_ec_spi.c +++ b/drivers/mfd/cros_ec_spi.c @@ -79,13 +79,11 @@ * if no record * @end_of_msg_delay: used to set the delay_usecs on the spi_transfer that * is sent when we want to turn off CS at the end of a transaction. - * @lock: mutex to ensure only one user of cros_ec_cmd_xfer_spi at a time */ struct cros_ec_spi { struct spi_device *spi; s64 last_transfer_ns; unsigned int end_of_msg_delay; - struct mutex lock; }; static void debug_packet(struct device *dev, const char *name, u8 *ptr, @@ -232,13 +230,6 @@ static int cros_ec_cmd_xfer_spi(struct cros_ec_device *ec_dev, int sum; int ret = 0, final_ret; - /* - * We have the shared ec_dev buffer plus we do lots of separate spi_sync - * calls, so we need to make sure only one person is using this at a - * time. - */ - mutex_lock(&ec_spi->lock); - len = cros_ec_prepare_tx(ec_dev, ec_msg); dev_dbg(ec_dev->dev, "prepared, len=%d\n", len); @@ -327,7 +318,6 @@ exit: if (ec_msg->command == EC_CMD_REBOOT_EC) msleep(EC_REBOOT_DELAY_MS); - mutex_unlock(&ec_spi->lock); return ret; } @@ -359,7 +349,6 @@ static int cros_ec_spi_probe(struct spi_device *spi) if (ec_spi == NULL) return -ENOMEM; ec_spi->spi = spi; - mutex_init(&ec_spi->lock); ec_dev = devm_kzalloc(dev, sizeof(*ec_dev), GFP_KERNEL); if (!ec_dev) return -ENOMEM; -- cgit v1.2.3 From 97720706084dd8c45eecc61d39353c7b62939b8f Mon Sep 17 00:00:00 2001 From: Derek Basehore Date: Thu, 18 Sep 2014 17:18:55 +0200 Subject: i2c: i2c-cros-ec-tunnel: Set retries to 3 Since the i2c bus can get wedged on the EC sometimes, set the number of retries to 3. Since we un-wedge the bus immediately after the wedge happens, this is the correct fix since only one transfer will fail. Signed-off-by: Derek Basehore Reviewed-by: Doug Anderson Acked-by: Wolfram Sang Signed-off-by: Javier Martinez Canillas Signed-off-by: Lee Jones --- drivers/i2c/busses/i2c-cros-ec-tunnel.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers') diff --git a/drivers/i2c/busses/i2c-cros-ec-tunnel.c b/drivers/i2c/busses/i2c-cros-ec-tunnel.c index 43be23dfb115..8ca5cbbcec91 100644 --- a/drivers/i2c/busses/i2c-cros-ec-tunnel.c +++ b/drivers/i2c/busses/i2c-cros-ec-tunnel.c @@ -16,6 +16,8 @@ #include #include +#define I2C_MAX_RETRIES 3 + /** * struct ec_i2c_device - Driver data for I2C tunnel * @@ -290,6 +292,7 @@ static int ec_i2c_probe(struct platform_device *pdev) bus->adap.algo_data = bus; bus->adap.dev.parent = &pdev->dev; bus->adap.dev.of_node = np; + bus->adap.retries = I2C_MAX_RETRIES; err = i2c_add_adapter(&bus->adap); if (err) { -- cgit v1.2.3 From d86c21fd31114e3ef9fae64be335c76aa22859dc Mon Sep 17 00:00:00 2001 From: Andrew Bresticker Date: Thu, 18 Sep 2014 17:18:58 +0200 Subject: mfd: cros_ec: wait for completion of commands that return IN_PROGRESS When an EC command returns EC_RES_IN_PROGRESS, we need to query the state of the EC until it indicates that it is no longer busy. Do this in cros_ec_cmd_xfer() under the EC's mutex so that other commands (e.g. keyboard, I2C passtru) aren't issued to the EC while it is working on the in-progress command. The 10 milliseconds delay and the number of retries are the values that were used by the flashrom tool when retrying commands. Signed-off-by: Andrew Bresticker Reviewed-by: Simon Glass Signed-off-by: Javier Martinez Canillas Signed-off-by: Lee Jones --- drivers/mfd/cros_ec.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'drivers') diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c index c53804a1451d..fc0c81ef04ff 100644 --- a/drivers/mfd/cros_ec.c +++ b/drivers/mfd/cros_ec.c @@ -23,6 +23,9 @@ #include #include #include +#include + +#define EC_COMMAND_RETRIES 50 int cros_ec_prepare_tx(struct cros_ec_device *ec_dev, struct cros_ec_command *msg) @@ -69,6 +72,36 @@ int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev, mutex_lock(&ec_dev->lock); ret = ec_dev->cmd_xfer(ec_dev, msg); + if (msg->result == EC_RES_IN_PROGRESS) { + int i; + struct cros_ec_command status_msg; + struct ec_response_get_comms_status status; + + status_msg.version = 0; + status_msg.command = EC_CMD_GET_COMMS_STATUS; + status_msg.outdata = NULL; + status_msg.outsize = 0; + status_msg.indata = (uint8_t *)&status; + status_msg.insize = sizeof(status); + + /* + * Query the EC's status until it's no longer busy or + * we encounter an error. + */ + for (i = 0; i < EC_COMMAND_RETRIES; i++) { + usleep_range(10000, 11000); + + ret = ec_dev->cmd_xfer(ec_dev, &status_msg); + if (ret < 0) + break; + + msg->result = status_msg.result; + if (status_msg.result != EC_RES_SUCCESS) + break; + if (!(status.flags & EC_COMMS_STATUS_PROCESSING)) + break; + } + } mutex_unlock(&ec_dev->lock); return ret; -- cgit v1.2.3