You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
Merge tag 'mfd-3.10-1' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-next
Pull MFD update from Samuel Ortiz:
"For 3.10 we have a few new MFD drivers for:
- The ChromeOS embedded controller which provides keyboard, battery
and power management services. This controller is accessible
through i2c or SPI.
- Silicon Laboratories 476x controller, providing access to their FM
chipset and their audio codec.
- Realtek's RTS5249, a memory stick, MMC and SD/SDIO PCI based
reader.
- Nokia's Tahvo power button and watchdog device. This device is
very similar to Retu and is thus supported by the same code base.
- STMicroelectronics STMPE1801, a keyboard and GPIO controller
supported by the stmpe driver.
- ST-Ericsson AB8540 and AB8505 power management and voltage
converter controllers through the existing ab8500 code.
Some other drivers got cleaned up or improved. In particular:
- The Linaro/STE guys got the ab8500 driver in sync with their
internal code through a series of optimizations, fixes and
improvements.
- The AS3711 and OMAP USB drivers now have DT support.
- The arizona clock and interrupt handling code got improved.
- The wm5102 register patch and boot mechanism also got improved."
* tag 'mfd-3.10-1' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-next: (104 commits)
mfd: si476x: Don't use 0bNNN
mfd: vexpress: Handle pending config transactions
mfd: ab8500: Export ab8500_gpadc_sw_hw_convert properly
mfd: si476x: Fix i2c warning
mfd: si476x: Add header files and Kbuild plumbing
mfd: si476x: Add chip properties handling code
mfd: si476x: Add the bulk of the core driver
mfd: si476x: Add commands abstraction layer
mfd: rtsx: Support RTS5249
mfd: retu: Add Tahvo support
mfd: ucb1400: Pass ucb1400-gpio data through ac97 bus
mfd: wm8994: Add some OF properties
mfd: wm8994: Add device ID data to WM8994 OF device IDs
input: Export matrix_keypad_parse_of_params()
mfd: tps65090: Add compatible string for charger subnode
mfd: db8500-prcmu: Support platform dependant device selection
mfd: syscon: Fix warnings when printing resource_size_t
of: Add stub of_get_parent for non-OF builds
mfd: omap-usb-tll: Convert to devm_ioremap_resource()
mfd: omap-usb-host: Convert to devm_ioremap_resource()
...
This commit is contained in:
@@ -1144,17 +1144,15 @@ static int pm860x_probe(struct i2c_client *client,
|
||||
return -ENOMEM;
|
||||
ret = pm860x_dt_init(node, &client->dev, pdata);
|
||||
if (ret)
|
||||
goto err;
|
||||
return ret;
|
||||
} else if (!pdata) {
|
||||
pr_info("No platform data in %s!\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
chip = kzalloc(sizeof(struct pm860x_chip), GFP_KERNEL);
|
||||
if (chip == NULL) {
|
||||
ret = -ENOMEM;
|
||||
goto err;
|
||||
}
|
||||
if (chip == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
chip->id = verify_addr(client);
|
||||
chip->regmap = regmap_init_i2c(client, &pm860x_regmap_config);
|
||||
@@ -1194,10 +1192,6 @@ static int pm860x_probe(struct i2c_client *client,
|
||||
|
||||
pm860x_device_init(chip, pdata);
|
||||
return 0;
|
||||
err:
|
||||
if (node)
|
||||
devm_kfree(&client->dev, pdata);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int pm860x_remove(struct i2c_client *client)
|
||||
|
||||
+800
-804
File diff suppressed because it is too large
Load Diff
@@ -8,8 +8,11 @@ obj-$(CONFIG_MFD_88PM800) += 88pm800.o 88pm80x.o
|
||||
obj-$(CONFIG_MFD_88PM805) += 88pm805.o 88pm80x.o
|
||||
obj-$(CONFIG_MFD_SM501) += sm501.o
|
||||
obj-$(CONFIG_MFD_ASIC3) += asic3.o tmio_core.o
|
||||
obj-$(CONFIG_MFD_CROS_EC) += cros_ec.o
|
||||
obj-$(CONFIG_MFD_CROS_EC_I2C) += cros_ec_i2c.o
|
||||
obj-$(CONFIG_MFD_CROS_EC_SPI) += cros_ec_spi.o
|
||||
|
||||
rtsx_pci-objs := rtsx_pcr.o rts5209.o rts5229.o rtl8411.o rts5227.o
|
||||
rtsx_pci-objs := rtsx_pcr.o rts5209.o rts5229.o rtl8411.o rts5227.o rts5249.o
|
||||
obj-$(CONFIG_MFD_RTSX_PCI) += rtsx_pci.o
|
||||
|
||||
obj-$(CONFIG_HTC_EGPIO) += htc-egpio.o
|
||||
@@ -131,6 +134,10 @@ obj-$(CONFIG_MFD_JZ4740_ADC) += jz4740-adc.o
|
||||
obj-$(CONFIG_MFD_TPS6586X) += tps6586x.o
|
||||
obj-$(CONFIG_MFD_VX855) += vx855.o
|
||||
obj-$(CONFIG_MFD_WL1273_CORE) += wl1273-core.o
|
||||
|
||||
si476x-core-y := si476x-cmd.o si476x-prop.o si476x-i2c.o
|
||||
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
|
||||
|
||||
@@ -367,12 +367,12 @@ static int aat2870_i2c_probe(struct i2c_client *client,
|
||||
int i, j;
|
||||
int ret = 0;
|
||||
|
||||
aat2870 = kzalloc(sizeof(struct aat2870_data), GFP_KERNEL);
|
||||
aat2870 = devm_kzalloc(&client->dev, sizeof(struct aat2870_data),
|
||||
GFP_KERNEL);
|
||||
if (!aat2870) {
|
||||
dev_err(&client->dev,
|
||||
"Failed to allocate memory for aat2870\n");
|
||||
ret = -ENOMEM;
|
||||
goto out;
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
aat2870->dev = &client->dev;
|
||||
@@ -400,12 +400,12 @@ static int aat2870_i2c_probe(struct i2c_client *client,
|
||||
aat2870->init(aat2870);
|
||||
|
||||
if (aat2870->en_pin >= 0) {
|
||||
ret = gpio_request_one(aat2870->en_pin, GPIOF_OUT_INIT_HIGH,
|
||||
"aat2870-en");
|
||||
ret = devm_gpio_request_one(&client->dev, aat2870->en_pin,
|
||||
GPIOF_OUT_INIT_HIGH, "aat2870-en");
|
||||
if (ret < 0) {
|
||||
dev_err(&client->dev,
|
||||
"Failed to request GPIO %d\n", aat2870->en_pin);
|
||||
goto out_kfree;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -436,11 +436,6 @@ static int aat2870_i2c_probe(struct i2c_client *client,
|
||||
|
||||
out_disable:
|
||||
aat2870_disable(aat2870);
|
||||
if (aat2870->en_pin >= 0)
|
||||
gpio_free(aat2870->en_pin);
|
||||
out_kfree:
|
||||
kfree(aat2870);
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -452,11 +447,8 @@ static int aat2870_i2c_remove(struct i2c_client *client)
|
||||
|
||||
mfd_remove_devices(aat2870->dev);
|
||||
aat2870_disable(aat2870);
|
||||
if (aat2870->en_pin >= 0)
|
||||
gpio_free(aat2870->en_pin);
|
||||
if (aat2870->uninit)
|
||||
aat2870->uninit(aat2870);
|
||||
kfree(aat2870);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -248,19 +248,7 @@ static struct platform_driver ab3100_otp_driver = {
|
||||
.remove = __exit_p(ab3100_otp_remove),
|
||||
};
|
||||
|
||||
static int __init ab3100_otp_init(void)
|
||||
{
|
||||
return platform_driver_probe(&ab3100_otp_driver,
|
||||
ab3100_otp_probe);
|
||||
}
|
||||
|
||||
static void __exit ab3100_otp_exit(void)
|
||||
{
|
||||
platform_driver_unregister(&ab3100_otp_driver);
|
||||
}
|
||||
|
||||
module_init(ab3100_otp_init);
|
||||
module_exit(ab3100_otp_exit);
|
||||
module_platform_driver_probe(ab3100_otp_driver, ab3100_otp_probe);
|
||||
|
||||
MODULE_AUTHOR("Linus Walleij <linus.walleij@stericsson.com>");
|
||||
MODULE_DESCRIPTION("AB3100 OTP Readout Driver");
|
||||
|
||||
+17
-15
@@ -458,22 +458,23 @@ static void update_latch_offset(u8 *offset, int i)
|
||||
static int ab8500_handle_hierarchical_line(struct ab8500 *ab8500,
|
||||
int latch_offset, u8 latch_val)
|
||||
{
|
||||
int int_bit = __ffs(latch_val);
|
||||
int line, i;
|
||||
int int_bit, line, i;
|
||||
|
||||
do {
|
||||
for (i = 0; i < ab8500->mask_size; i++)
|
||||
if (ab8500->irq_reg_offset[i] == latch_offset)
|
||||
break;
|
||||
|
||||
if (i >= ab8500->mask_size) {
|
||||
dev_err(ab8500->dev, "Register offset 0x%2x not declared\n",
|
||||
latch_offset);
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
/* ignore masked out interrupts */
|
||||
latch_val &= ~ab8500->mask[i];
|
||||
|
||||
while (latch_val) {
|
||||
int_bit = __ffs(latch_val);
|
||||
|
||||
for (i = 0; i < ab8500->mask_size; i++)
|
||||
if (ab8500->irq_reg_offset[i] == latch_offset)
|
||||
break;
|
||||
|
||||
if (i >= ab8500->mask_size) {
|
||||
dev_err(ab8500->dev, "Register offset 0x%2x not declared\n",
|
||||
latch_offset);
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
line = (i << 3) + int_bit;
|
||||
latch_val &= ~(1 << int_bit);
|
||||
|
||||
@@ -491,7 +492,7 @@ static int ab8500_handle_hierarchical_line(struct ab8500 *ab8500,
|
||||
line += 1;
|
||||
|
||||
handle_nested_irq(ab8500->irq_base + line);
|
||||
} while (latch_val);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1107,6 +1108,7 @@ static struct mfd_cell ab8500_devs[] = {
|
||||
},
|
||||
{
|
||||
.name = "ab8500-usb",
|
||||
.of_compatible = "stericsson,ab8500-usb",
|
||||
.num_resources = ARRAY_SIZE(ab8500_usb_resources),
|
||||
.resources = ab8500_usb_resources,
|
||||
},
|
||||
|
||||
@@ -332,7 +332,7 @@ if (ad_value < 0) {
|
||||
|
||||
return voltage;
|
||||
}
|
||||
EXPORT_SYMBOL(ab8500_gpadc_convert);
|
||||
EXPORT_SYMBOL(ab8500_gpadc_sw_hw_convert);
|
||||
|
||||
/**
|
||||
* ab8500_gpadc_read_raw() - gpadc read
|
||||
|
||||
@@ -242,7 +242,7 @@ static int __init ab8500_sysctrl_init(void)
|
||||
{
|
||||
return platform_driver_register(&ab8500_sysctrl_driver);
|
||||
}
|
||||
subsys_initcall(ab8500_sysctrl_init);
|
||||
arch_initcall(ab8500_sysctrl_init);
|
||||
|
||||
MODULE_AUTHOR("Mattias Nilsson <mattias.i.nilsson@stericsson.com");
|
||||
MODULE_DESCRIPTION("AB8500 system control driver");
|
||||
|
||||
+7
-13
@@ -36,6 +36,7 @@ struct adp5520_chip {
|
||||
struct blocking_notifier_head notifier_list;
|
||||
int irq;
|
||||
unsigned long id;
|
||||
uint8_t mode;
|
||||
};
|
||||
|
||||
static int __adp5520_read(struct i2c_client *client,
|
||||
@@ -326,7 +327,10 @@ static int adp5520_suspend(struct device *dev)
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct adp5520_chip *chip = dev_get_drvdata(&client->dev);
|
||||
|
||||
adp5520_clr_bits(chip->dev, ADP5520_MODE_STATUS, ADP5520_nSTNBY);
|
||||
adp5520_read(chip->dev, ADP5520_MODE_STATUS, &chip->mode);
|
||||
/* All other bits are W1C */
|
||||
chip->mode &= ADP5520_BL_EN | ADP5520_DIM_EN | ADP5520_nSTNBY;
|
||||
adp5520_write(chip->dev, ADP5520_MODE_STATUS, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -335,7 +339,7 @@ static int adp5520_resume(struct device *dev)
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct adp5520_chip *chip = dev_get_drvdata(&client->dev);
|
||||
|
||||
adp5520_set_bits(chip->dev, ADP5520_MODE_STATUS, ADP5520_nSTNBY);
|
||||
adp5520_write(chip->dev, ADP5520_MODE_STATUS, chip->mode);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@@ -360,17 +364,7 @@ static struct i2c_driver adp5520_driver = {
|
||||
.id_table = adp5520_id,
|
||||
};
|
||||
|
||||
static int __init adp5520_init(void)
|
||||
{
|
||||
return i2c_add_driver(&adp5520_driver);
|
||||
}
|
||||
module_init(adp5520_init);
|
||||
|
||||
static void __exit adp5520_exit(void)
|
||||
{
|
||||
i2c_del_driver(&adp5520_driver);
|
||||
}
|
||||
module_exit(adp5520_exit);
|
||||
module_i2c_driver(adp5520_driver);
|
||||
|
||||
MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
|
||||
MODULE_DESCRIPTION("ADP5520(01) PMIC-MFD Driver");
|
||||
|
||||
+223
-46
@@ -39,11 +39,21 @@ int arizona_clk32k_enable(struct arizona *arizona)
|
||||
|
||||
arizona->clk32k_ref++;
|
||||
|
||||
if (arizona->clk32k_ref == 1)
|
||||
if (arizona->clk32k_ref == 1) {
|
||||
switch (arizona->pdata.clk32k_src) {
|
||||
case ARIZONA_32KZ_MCLK1:
|
||||
ret = pm_runtime_get_sync(arizona->dev);
|
||||
if (ret != 0)
|
||||
goto out;
|
||||
break;
|
||||
}
|
||||
|
||||
ret = regmap_update_bits(arizona->regmap, ARIZONA_CLOCK_32K_1,
|
||||
ARIZONA_CLK_32K_ENA,
|
||||
ARIZONA_CLK_32K_ENA);
|
||||
}
|
||||
|
||||
out:
|
||||
if (ret != 0)
|
||||
arizona->clk32k_ref--;
|
||||
|
||||
@@ -63,10 +73,17 @@ int arizona_clk32k_disable(struct arizona *arizona)
|
||||
|
||||
arizona->clk32k_ref--;
|
||||
|
||||
if (arizona->clk32k_ref == 0)
|
||||
if (arizona->clk32k_ref == 0) {
|
||||
regmap_update_bits(arizona->regmap, ARIZONA_CLOCK_32K_1,
|
||||
ARIZONA_CLK_32K_ENA, 0);
|
||||
|
||||
switch (arizona->pdata.clk32k_src) {
|
||||
case ARIZONA_32KZ_MCLK1:
|
||||
pm_runtime_put_sync(arizona->dev);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mutex_unlock(&arizona->clk_lock);
|
||||
|
||||
return ret;
|
||||
@@ -179,42 +196,134 @@ static irqreturn_t arizona_overclocked(int irq, void *data)
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static int arizona_poll_reg(struct arizona *arizona,
|
||||
int timeout, unsigned int reg,
|
||||
unsigned int mask, unsigned int target)
|
||||
{
|
||||
unsigned int val = 0;
|
||||
int ret, i;
|
||||
|
||||
for (i = 0; i < timeout; i++) {
|
||||
ret = regmap_read(arizona->regmap, reg, &val);
|
||||
if (ret != 0) {
|
||||
dev_err(arizona->dev, "Failed to read reg %u: %d\n",
|
||||
reg, ret);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((val & mask) == target)
|
||||
return 0;
|
||||
|
||||
msleep(1);
|
||||
}
|
||||
|
||||
dev_err(arizona->dev, "Polling reg %u timed out: %x\n", reg, val);
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
static int arizona_wait_for_boot(struct arizona *arizona)
|
||||
{
|
||||
unsigned int reg;
|
||||
int ret, i;
|
||||
int ret;
|
||||
|
||||
/*
|
||||
* We can't use an interrupt as we need to runtime resume to do so,
|
||||
* we won't race with the interrupt handler as it'll be blocked on
|
||||
* runtime resume.
|
||||
*/
|
||||
for (i = 0; i < 5; i++) {
|
||||
msleep(1);
|
||||
ret = arizona_poll_reg(arizona, 5, ARIZONA_INTERRUPT_RAW_STATUS_5,
|
||||
ARIZONA_BOOT_DONE_STS, ARIZONA_BOOT_DONE_STS);
|
||||
|
||||
ret = regmap_read(arizona->regmap,
|
||||
ARIZONA_INTERRUPT_RAW_STATUS_5, ®);
|
||||
if (ret != 0) {
|
||||
dev_err(arizona->dev, "Failed to read boot state: %d\n",
|
||||
ret);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (reg & ARIZONA_BOOT_DONE_STS)
|
||||
break;
|
||||
}
|
||||
|
||||
if (reg & ARIZONA_BOOT_DONE_STS) {
|
||||
if (!ret)
|
||||
regmap_write(arizona->regmap, ARIZONA_INTERRUPT_STATUS_5,
|
||||
ARIZONA_BOOT_DONE_STS);
|
||||
} else {
|
||||
dev_err(arizona->dev, "Device boot timed out: %x\n", reg);
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
pm_runtime_mark_last_busy(arizona->dev);
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int arizona_apply_hardware_patch(struct arizona* arizona)
|
||||
{
|
||||
unsigned int fll, sysclk;
|
||||
int ret, err;
|
||||
|
||||
regcache_cache_bypass(arizona->regmap, true);
|
||||
|
||||
/* Cache existing FLL and SYSCLK settings */
|
||||
ret = regmap_read(arizona->regmap, ARIZONA_FLL1_CONTROL_1, &fll);
|
||||
if (ret != 0) {
|
||||
dev_err(arizona->dev, "Failed to cache FLL settings: %d\n",
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
ret = regmap_read(arizona->regmap, ARIZONA_SYSTEM_CLOCK_1, &sysclk);
|
||||
if (ret != 0) {
|
||||
dev_err(arizona->dev, "Failed to cache SYSCLK settings: %d\n",
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Start up SYSCLK using the FLL in free running mode */
|
||||
ret = regmap_write(arizona->regmap, ARIZONA_FLL1_CONTROL_1,
|
||||
ARIZONA_FLL1_ENA | ARIZONA_FLL1_FREERUN);
|
||||
if (ret != 0) {
|
||||
dev_err(arizona->dev,
|
||||
"Failed to start FLL in freerunning mode: %d\n",
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
ret = arizona_poll_reg(arizona, 25, ARIZONA_INTERRUPT_RAW_STATUS_5,
|
||||
ARIZONA_FLL1_CLOCK_OK_STS,
|
||||
ARIZONA_FLL1_CLOCK_OK_STS);
|
||||
if (ret != 0) {
|
||||
ret = -ETIMEDOUT;
|
||||
goto err_fll;
|
||||
}
|
||||
|
||||
ret = regmap_write(arizona->regmap, ARIZONA_SYSTEM_CLOCK_1, 0x0144);
|
||||
if (ret != 0) {
|
||||
dev_err(arizona->dev, "Failed to start SYSCLK: %d\n", ret);
|
||||
goto err_fll;
|
||||
}
|
||||
|
||||
/* Start the write sequencer and wait for it to finish */
|
||||
ret = regmap_write(arizona->regmap, ARIZONA_WRITE_SEQUENCER_CTRL_0,
|
||||
ARIZONA_WSEQ_ENA | ARIZONA_WSEQ_START | 160);
|
||||
if (ret != 0) {
|
||||
dev_err(arizona->dev, "Failed to start write sequencer: %d\n",
|
||||
ret);
|
||||
goto err_sysclk;
|
||||
}
|
||||
ret = arizona_poll_reg(arizona, 5, ARIZONA_WRITE_SEQUENCER_CTRL_1,
|
||||
ARIZONA_WSEQ_BUSY, 0);
|
||||
if (ret != 0) {
|
||||
regmap_write(arizona->regmap, ARIZONA_WRITE_SEQUENCER_CTRL_0,
|
||||
ARIZONA_WSEQ_ABORT);
|
||||
ret = -ETIMEDOUT;
|
||||
}
|
||||
|
||||
err_sysclk:
|
||||
err = regmap_write(arizona->regmap, ARIZONA_SYSTEM_CLOCK_1, sysclk);
|
||||
if (err != 0) {
|
||||
dev_err(arizona->dev,
|
||||
"Failed to re-apply old SYSCLK settings: %d\n",
|
||||
err);
|
||||
}
|
||||
|
||||
err_fll:
|
||||
err = regmap_write(arizona->regmap, ARIZONA_FLL1_CONTROL_1, fll);
|
||||
if (err != 0) {
|
||||
dev_err(arizona->dev,
|
||||
"Failed to re-apply old FLL settings: %d\n",
|
||||
err);
|
||||
}
|
||||
|
||||
regcache_cache_bypass(arizona->regmap, false);
|
||||
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
else
|
||||
return err;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_RUNTIME
|
||||
@@ -233,20 +342,44 @@ static int arizona_runtime_resume(struct device *dev)
|
||||
|
||||
regcache_cache_only(arizona->regmap, false);
|
||||
|
||||
ret = arizona_wait_for_boot(arizona);
|
||||
if (ret != 0) {
|
||||
regulator_disable(arizona->dcvdd);
|
||||
return ret;
|
||||
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;
|
||||
}
|
||||
|
||||
ret = arizona_apply_hardware_patch(arizona);
|
||||
if (ret != 0) {
|
||||
dev_err(arizona->dev,
|
||||
"Failed to apply hardware patch: %d\n",
|
||||
ret);
|
||||
goto err;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ret = arizona_wait_for_boot(arizona);
|
||||
if (ret != 0) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
ret = regcache_sync(arizona->regmap);
|
||||
if (ret != 0) {
|
||||
dev_err(arizona->dev, "Failed to restore register cache\n");
|
||||
regulator_disable(arizona->dcvdd);
|
||||
return ret;
|
||||
goto err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err:
|
||||
regcache_cache_only(arizona->regmap, true);
|
||||
regulator_disable(arizona->dcvdd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int arizona_runtime_suspend(struct device *dev)
|
||||
@@ -371,6 +504,17 @@ int arizona_dev_init(struct arizona *arizona)
|
||||
goto err_early;
|
||||
}
|
||||
|
||||
if (arizona->pdata.reset) {
|
||||
/* Start out with /RESET low to put the chip into reset */
|
||||
ret = gpio_request_one(arizona->pdata.reset,
|
||||
GPIOF_DIR_OUT | GPIOF_INIT_LOW,
|
||||
"arizona /RESET");
|
||||
if (ret != 0) {
|
||||
dev_err(dev, "Failed to request /RESET: %d\n", ret);
|
||||
goto err_early;
|
||||
}
|
||||
}
|
||||
|
||||
ret = regulator_bulk_enable(arizona->num_core_supplies,
|
||||
arizona->core_supplies);
|
||||
if (ret != 0) {
|
||||
@@ -386,16 +530,8 @@ int arizona_dev_init(struct arizona *arizona)
|
||||
}
|
||||
|
||||
if (arizona->pdata.reset) {
|
||||
/* Start out with /RESET low to put the chip into reset */
|
||||
ret = gpio_request_one(arizona->pdata.reset,
|
||||
GPIOF_DIR_OUT | GPIOF_INIT_LOW,
|
||||
"arizona /RESET");
|
||||
if (ret != 0) {
|
||||
dev_err(dev, "Failed to request /RESET: %d\n", ret);
|
||||
goto err_dcvdd;
|
||||
}
|
||||
|
||||
gpio_set_value_cansleep(arizona->pdata.reset, 1);
|
||||
msleep(1);
|
||||
}
|
||||
|
||||
regcache_cache_only(arizona->regmap, false);
|
||||
@@ -424,6 +560,7 @@ int arizona_dev_init(struct arizona *arizona)
|
||||
arizona->type = WM5102;
|
||||
}
|
||||
apply_patch = wm5102_patch;
|
||||
arizona->rev &= 0x7;
|
||||
break;
|
||||
#endif
|
||||
#ifdef CONFIG_MFD_WM5110
|
||||
@@ -454,6 +591,8 @@ int arizona_dev_init(struct arizona *arizona)
|
||||
goto err_reset;
|
||||
}
|
||||
|
||||
msleep(1);
|
||||
|
||||
ret = regcache_sync(arizona->regmap);
|
||||
if (ret != 0) {
|
||||
dev_err(dev, "Failed to sync device: %d\n", ret);
|
||||
@@ -461,10 +600,24 @@ int arizona_dev_init(struct arizona *arizona)
|
||||
}
|
||||
}
|
||||
|
||||
ret = arizona_wait_for_boot(arizona);
|
||||
if (ret != 0) {
|
||||
dev_err(arizona->dev, "Device failed initial boot: %d\n", ret);
|
||||
goto err_reset;
|
||||
switch (arizona->type) {
|
||||
case WM5102:
|
||||
ret = regmap_read(arizona->regmap, 0x19, &val);
|
||||
if (ret != 0)
|
||||
dev_err(dev,
|
||||
"Failed to check write sequencer state: %d\n",
|
||||
ret);
|
||||
else if (val & 0x01)
|
||||
break;
|
||||
/* Fall through */
|
||||
default:
|
||||
ret = arizona_wait_for_boot(arizona);
|
||||
if (ret != 0) {
|
||||
dev_err(arizona->dev,
|
||||
"Device failed initial boot: %d\n", ret);
|
||||
goto err_reset;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (apply_patch) {
|
||||
@@ -474,6 +627,20 @@ int arizona_dev_init(struct arizona *arizona)
|
||||
ret);
|
||||
goto err_reset;
|
||||
}
|
||||
|
||||
switch (arizona->type) {
|
||||
case WM5102:
|
||||
ret = arizona_apply_hardware_patch(arizona);
|
||||
if (ret != 0) {
|
||||
dev_err(arizona->dev,
|
||||
"Failed to apply hardware patch: %d\n",
|
||||
ret);
|
||||
goto err_reset;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(arizona->pdata.gpio_defaults); i++) {
|
||||
@@ -498,6 +665,7 @@ int arizona_dev_init(struct arizona *arizona)
|
||||
regmap_update_bits(arizona->regmap, ARIZONA_CLOCK_32K_1,
|
||||
ARIZONA_CLK_32K_SRC_MASK,
|
||||
arizona->pdata.clk32k_src - 1);
|
||||
arizona_clk32k_enable(arizona);
|
||||
break;
|
||||
case ARIZONA_32KZ_NONE:
|
||||
regmap_update_bits(arizona->regmap, ARIZONA_CLOCK_32K_1,
|
||||
@@ -511,10 +679,16 @@ int arizona_dev_init(struct arizona *arizona)
|
||||
}
|
||||
|
||||
for (i = 0; i < ARIZONA_MAX_MICBIAS; i++) {
|
||||
if (!arizona->pdata.micbias[i].mV)
|
||||
if (!arizona->pdata.micbias[i].mV &&
|
||||
!arizona->pdata.micbias[i].bypass)
|
||||
continue;
|
||||
|
||||
/* Apply default for bypass mode */
|
||||
if (!arizona->pdata.micbias[i].mV)
|
||||
arizona->pdata.micbias[i].mV = 2800;
|
||||
|
||||
val = (arizona->pdata.micbias[i].mV - 1500) / 100;
|
||||
|
||||
val <<= ARIZONA_MICB1_LVL_SHIFT;
|
||||
|
||||
if (arizona->pdata.micbias[i].ext_cap)
|
||||
@@ -526,10 +700,14 @@ int arizona_dev_init(struct arizona *arizona)
|
||||
if (arizona->pdata.micbias[i].fast_start)
|
||||
val |= ARIZONA_MICB1_RATE;
|
||||
|
||||
if (arizona->pdata.micbias[i].bypass)
|
||||
val |= ARIZONA_MICB1_BYPASS;
|
||||
|
||||
regmap_update_bits(arizona->regmap,
|
||||
ARIZONA_MIC_BIAS_CTRL_1 + i,
|
||||
ARIZONA_MICB1_LVL_MASK |
|
||||
ARIZONA_MICB1_DISCH |
|
||||
ARIZONA_MICB1_BYPASS |
|
||||
ARIZONA_MICB1_RATE, val);
|
||||
}
|
||||
|
||||
@@ -610,10 +788,9 @@ err_irq:
|
||||
arizona_irq_exit(arizona);
|
||||
err_reset:
|
||||
if (arizona->pdata.reset) {
|
||||
gpio_set_value_cansleep(arizona->pdata.reset, 1);
|
||||
gpio_set_value_cansleep(arizona->pdata.reset, 0);
|
||||
gpio_free(arizona->pdata.reset);
|
||||
}
|
||||
err_dcvdd:
|
||||
regulator_disable(arizona->dcvdd);
|
||||
err_enable:
|
||||
regulator_bulk_disable(arizona->num_core_supplies,
|
||||
|
||||
+87
-19
@@ -94,6 +94,7 @@ static irqreturn_t arizona_ctrlif_err(int irq, void *data)
|
||||
static irqreturn_t arizona_irq_thread(int irq, void *data)
|
||||
{
|
||||
struct arizona *arizona = data;
|
||||
bool poll;
|
||||
unsigned int val;
|
||||
int ret;
|
||||
|
||||
@@ -103,20 +104,39 @@ static irqreturn_t arizona_irq_thread(int irq, void *data)
|
||||
return IRQ_NONE;
|
||||
}
|
||||
|
||||
/* Always handle the AoD domain */
|
||||
handle_nested_irq(irq_find_mapping(arizona->virq, 0));
|
||||
do {
|
||||
poll = false;
|
||||
|
||||
/*
|
||||
* Check if one of the main interrupts is asserted and only
|
||||
* check that domain if it is.
|
||||
*/
|
||||
ret = regmap_read(arizona->regmap, ARIZONA_IRQ_PIN_STATUS, &val);
|
||||
if (ret == 0 && val & ARIZONA_IRQ1_STS) {
|
||||
handle_nested_irq(irq_find_mapping(arizona->virq, 1));
|
||||
} else if (ret != 0) {
|
||||
dev_err(arizona->dev, "Failed to read main IRQ status: %d\n",
|
||||
ret);
|
||||
}
|
||||
/* Always handle the AoD domain */
|
||||
handle_nested_irq(irq_find_mapping(arizona->virq, 0));
|
||||
|
||||
/*
|
||||
* Check if one of the main interrupts is asserted and only
|
||||
* check that domain if it is.
|
||||
*/
|
||||
ret = regmap_read(arizona->regmap, ARIZONA_IRQ_PIN_STATUS,
|
||||
&val);
|
||||
if (ret == 0 && val & ARIZONA_IRQ1_STS) {
|
||||
handle_nested_irq(irq_find_mapping(arizona->virq, 1));
|
||||
} else if (ret != 0) {
|
||||
dev_err(arizona->dev,
|
||||
"Failed to read main IRQ status: %d\n", ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* Poll the IRQ pin status to see if we're really done
|
||||
* if the interrupt controller can't do it for us.
|
||||
*/
|
||||
if (!arizona->pdata.irq_gpio) {
|
||||
break;
|
||||
} else if (arizona->pdata.irq_flags & IRQF_TRIGGER_RISING &&
|
||||
gpio_get_value_cansleep(arizona->pdata.irq_gpio)) {
|
||||
poll = true;
|
||||
} else if (arizona->pdata.irq_flags & IRQF_TRIGGER_FALLING &&
|
||||
!gpio_get_value_cansleep(arizona->pdata.irq_gpio)) {
|
||||
poll = true;
|
||||
}
|
||||
} while (poll);
|
||||
|
||||
pm_runtime_mark_last_busy(arizona->dev);
|
||||
pm_runtime_put_autosuspend(arizona->dev);
|
||||
@@ -169,6 +189,7 @@ int arizona_irq_init(struct arizona *arizona)
|
||||
int ret, i;
|
||||
const struct regmap_irq_chip *aod, *irq;
|
||||
bool ctrlif_error = true;
|
||||
struct irq_data *irq_data;
|
||||
|
||||
switch (arizona->type) {
|
||||
#ifdef CONFIG_MFD_WM5102
|
||||
@@ -192,7 +213,36 @@ int arizona_irq_init(struct arizona *arizona)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (arizona->pdata.irq_active_high) {
|
||||
/* Disable all wake sources by default */
|
||||
regmap_write(arizona->regmap, ARIZONA_WAKE_CONTROL, 0);
|
||||
|
||||
/* Read the flags from the interrupt controller if not specified */
|
||||
if (!arizona->pdata.irq_flags) {
|
||||
irq_data = irq_get_irq_data(arizona->irq);
|
||||
if (!irq_data) {
|
||||
dev_err(arizona->dev, "Invalid IRQ: %d\n",
|
||||
arizona->irq);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
arizona->pdata.irq_flags = irqd_get_trigger_type(irq_data);
|
||||
switch (arizona->pdata.irq_flags) {
|
||||
case IRQF_TRIGGER_LOW:
|
||||
case IRQF_TRIGGER_HIGH:
|
||||
case IRQF_TRIGGER_RISING:
|
||||
case IRQF_TRIGGER_FALLING:
|
||||
break;
|
||||
|
||||
case IRQ_TYPE_NONE:
|
||||
default:
|
||||
/* Device default */
|
||||
arizona->pdata.irq_flags = IRQF_TRIGGER_LOW;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (arizona->pdata.irq_flags & (IRQF_TRIGGER_HIGH |
|
||||
IRQF_TRIGGER_RISING)) {
|
||||
ret = regmap_update_bits(arizona->regmap, ARIZONA_IRQ_CTRL_1,
|
||||
ARIZONA_IRQ_POL, 0);
|
||||
if (ret != 0) {
|
||||
@@ -200,12 +250,10 @@ int arizona_irq_init(struct arizona *arizona)
|
||||
ret);
|
||||
goto err;
|
||||
}
|
||||
|
||||
flags |= IRQF_TRIGGER_HIGH;
|
||||
} else {
|
||||
flags |= IRQF_TRIGGER_LOW;
|
||||
}
|
||||
|
||||
flags |= arizona->pdata.irq_flags;
|
||||
|
||||
/* Allocate a virtual IRQ domain to distribute to the regmap domains */
|
||||
arizona->virq = irq_domain_add_linear(NULL, 2, &arizona_domain_ops,
|
||||
arizona);
|
||||
@@ -257,11 +305,31 @@ int arizona_irq_init(struct arizona *arizona)
|
||||
}
|
||||
}
|
||||
|
||||
/* Used to emulate edge trigger and to work around broken pinmux */
|
||||
if (arizona->pdata.irq_gpio) {
|
||||
if (gpio_to_irq(arizona->pdata.irq_gpio) != arizona->irq) {
|
||||
dev_warn(arizona->dev, "IRQ %d is not GPIO %d (%d)\n",
|
||||
arizona->irq, arizona->pdata.irq_gpio,
|
||||
gpio_to_irq(arizona->pdata.irq_gpio));
|
||||
arizona->irq = gpio_to_irq(arizona->pdata.irq_gpio);
|
||||
}
|
||||
|
||||
ret = devm_gpio_request_one(arizona->dev,
|
||||
arizona->pdata.irq_gpio,
|
||||
GPIOF_IN, "arizona IRQ");
|
||||
if (ret != 0) {
|
||||
dev_err(arizona->dev,
|
||||
"Failed to request IRQ GPIO %d:: %d\n",
|
||||
arizona->pdata.irq_gpio, ret);
|
||||
arizona->pdata.irq_gpio = 0;
|
||||
}
|
||||
}
|
||||
|
||||
ret = request_threaded_irq(arizona->irq, NULL, arizona_irq_thread,
|
||||
flags, "arizona", arizona);
|
||||
|
||||
if (ret != 0) {
|
||||
dev_err(arizona->dev, "Failed to request IRQ %d: %d\n",
|
||||
dev_err(arizona->dev, "Failed to request primary IRQ %d: %d\n",
|
||||
arizona->irq, ret);
|
||||
goto err_main_irq;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ static int arizona_spi_probe(struct spi_device *spi)
|
||||
|
||||
static int arizona_spi_remove(struct spi_device *spi)
|
||||
{
|
||||
struct arizona *arizona = dev_get_drvdata(&spi->dev);
|
||||
struct arizona *arizona = spi_get_drvdata(spi);
|
||||
arizona_dev_exit(arizona);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+23
-4
@@ -112,16 +112,34 @@ static const struct regmap_config as3711_regmap_config = {
|
||||
.cache_type = REGCACHE_RBTREE,
|
||||
};
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
static struct of_device_id as3711_of_match[] = {
|
||||
{.compatible = "ams,as3711",},
|
||||
{}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, as3711_of_match);
|
||||
#endif
|
||||
|
||||
static int as3711_i2c_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
struct as3711 *as3711;
|
||||
struct as3711_platform_data *pdata = client->dev.platform_data;
|
||||
struct as3711_platform_data *pdata;
|
||||
unsigned int id1, id2;
|
||||
int ret;
|
||||
|
||||
if (!pdata)
|
||||
dev_dbg(&client->dev, "Platform data not found\n");
|
||||
if (!client->dev.of_node) {
|
||||
pdata = client->dev.platform_data;
|
||||
if (!pdata)
|
||||
dev_dbg(&client->dev, "Platform data not found\n");
|
||||
} else {
|
||||
pdata = devm_kzalloc(&client->dev,
|
||||
sizeof(*pdata), GFP_KERNEL);
|
||||
if (!pdata) {
|
||||
dev_err(&client->dev, "Failed to allocate pdata\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
}
|
||||
|
||||
as3711 = devm_kzalloc(&client->dev, sizeof(struct as3711), GFP_KERNEL);
|
||||
if (!as3711) {
|
||||
@@ -193,7 +211,8 @@ static struct i2c_driver as3711_i2c_driver = {
|
||||
.driver = {
|
||||
.name = "as3711",
|
||||
.owner = THIS_MODULE,
|
||||
},
|
||||
.of_match_table = of_match_ptr(as3711_of_match),
|
||||
},
|
||||
.probe = as3711_i2c_probe,
|
||||
.remove = as3711_i2c_remove,
|
||||
.id_table = as3711_i2c_id,
|
||||
|
||||
@@ -0,0 +1,196 @@
|
||||
/*
|
||||
* ChromeOS EC multi-function device
|
||||
*
|
||||
* Copyright (C) 2012 Google, Inc
|
||||
*
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
* may be copied, distributed, and modified under those terms.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The ChromeOS EC multi function device is used to mux all the requests
|
||||
* to the EC device for its multiple features: keyboard controller,
|
||||
* battery charging and regulator control, firmware update.
|
||||
*/
|
||||
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/mfd/core.h>
|
||||
#include <linux/mfd/cros_ec.h>
|
||||
#include <linux/mfd/cros_ec_commands.h>
|
||||
|
||||
int cros_ec_prepare_tx(struct cros_ec_device *ec_dev,
|
||||
struct cros_ec_msg *msg)
|
||||
{
|
||||
uint8_t *out;
|
||||
int csum, i;
|
||||
|
||||
BUG_ON(msg->out_len > EC_HOST_PARAM_SIZE);
|
||||
out = ec_dev->dout;
|
||||
out[0] = EC_CMD_VERSION0 + msg->version;
|
||||
out[1] = msg->cmd;
|
||||
out[2] = msg->out_len;
|
||||
csum = out[0] + out[1] + out[2];
|
||||
for (i = 0; i < msg->out_len; i++)
|
||||
csum += out[EC_MSG_TX_HEADER_BYTES + i] = msg->out_buf[i];
|
||||
out[EC_MSG_TX_HEADER_BYTES + msg->out_len] = (uint8_t)(csum & 0xff);
|
||||
|
||||
return EC_MSG_TX_PROTO_BYTES + msg->out_len;
|
||||
}
|
||||
EXPORT_SYMBOL(cros_ec_prepare_tx);
|
||||
|
||||
static int cros_ec_command_sendrecv(struct cros_ec_device *ec_dev,
|
||||
uint16_t cmd, void *out_buf, int out_len,
|
||||
void *in_buf, int in_len)
|
||||
{
|
||||
struct cros_ec_msg msg;
|
||||
|
||||
msg.version = cmd >> 8;
|
||||
msg.cmd = cmd & 0xff;
|
||||
msg.out_buf = out_buf;
|
||||
msg.out_len = out_len;
|
||||
msg.in_buf = in_buf;
|
||||
msg.in_len = in_len;
|
||||
|
||||
return ec_dev->command_xfer(ec_dev, &msg);
|
||||
}
|
||||
|
||||
static int cros_ec_command_recv(struct cros_ec_device *ec_dev,
|
||||
uint16_t cmd, void *buf, int buf_len)
|
||||
{
|
||||
return cros_ec_command_sendrecv(ec_dev, cmd, NULL, 0, buf, buf_len);
|
||||
}
|
||||
|
||||
static int cros_ec_command_send(struct cros_ec_device *ec_dev,
|
||||
uint16_t cmd, void *buf, int buf_len)
|
||||
{
|
||||
return cros_ec_command_sendrecv(ec_dev, cmd, buf, buf_len, NULL, 0);
|
||||
}
|
||||
|
||||
static irqreturn_t ec_irq_thread(int irq, void *data)
|
||||
{
|
||||
struct cros_ec_device *ec_dev = data;
|
||||
|
||||
if (device_may_wakeup(ec_dev->dev))
|
||||
pm_wakeup_event(ec_dev->dev, 0);
|
||||
|
||||
blocking_notifier_call_chain(&ec_dev->event_notifier, 1, ec_dev);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static struct mfd_cell cros_devs[] = {
|
||||
{
|
||||
.name = "cros-ec-keyb",
|
||||
.id = 1,
|
||||
.of_compatible = "google,cros-ec-keyb",
|
||||
},
|
||||
};
|
||||
|
||||
int cros_ec_register(struct cros_ec_device *ec_dev)
|
||||
{
|
||||
struct device *dev = ec_dev->dev;
|
||||
int err = 0;
|
||||
|
||||
BLOCKING_INIT_NOTIFIER_HEAD(&ec_dev->event_notifier);
|
||||
|
||||
ec_dev->command_send = cros_ec_command_send;
|
||||
ec_dev->command_recv = cros_ec_command_recv;
|
||||
ec_dev->command_sendrecv = cros_ec_command_sendrecv;
|
||||
|
||||
if (ec_dev->din_size) {
|
||||
ec_dev->din = kmalloc(ec_dev->din_size, GFP_KERNEL);
|
||||
if (!ec_dev->din) {
|
||||
err = -ENOMEM;
|
||||
goto fail_din;
|
||||
}
|
||||
}
|
||||
if (ec_dev->dout_size) {
|
||||
ec_dev->dout = kmalloc(ec_dev->dout_size, GFP_KERNEL);
|
||||
if (!ec_dev->dout) {
|
||||
err = -ENOMEM;
|
||||
goto fail_dout;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ec_dev->irq) {
|
||||
dev_dbg(dev, "no valid IRQ: %d\n", ec_dev->irq);
|
||||
goto fail_irq;
|
||||
}
|
||||
|
||||
err = request_threaded_irq(ec_dev->irq, NULL, ec_irq_thread,
|
||||
IRQF_TRIGGER_LOW | IRQF_ONESHOT,
|
||||
"chromeos-ec", ec_dev);
|
||||
if (err) {
|
||||
dev_err(dev, "request irq %d: error %d\n", ec_dev->irq, err);
|
||||
goto fail_irq;
|
||||
}
|
||||
|
||||
err = mfd_add_devices(dev, 0, cros_devs,
|
||||
ARRAY_SIZE(cros_devs),
|
||||
NULL, ec_dev->irq, NULL);
|
||||
if (err) {
|
||||
dev_err(dev, "failed to add mfd devices\n");
|
||||
goto fail_mfd;
|
||||
}
|
||||
|
||||
dev_info(dev, "Chrome EC (%s)\n", ec_dev->name);
|
||||
|
||||
return 0;
|
||||
|
||||
fail_mfd:
|
||||
free_irq(ec_dev->irq, ec_dev);
|
||||
fail_irq:
|
||||
kfree(ec_dev->dout);
|
||||
fail_dout:
|
||||
kfree(ec_dev->din);
|
||||
fail_din:
|
||||
return err;
|
||||
}
|
||||
EXPORT_SYMBOL(cros_ec_register);
|
||||
|
||||
int cros_ec_remove(struct cros_ec_device *ec_dev)
|
||||
{
|
||||
mfd_remove_devices(ec_dev->dev);
|
||||
free_irq(ec_dev->irq, ec_dev);
|
||||
kfree(ec_dev->dout);
|
||||
kfree(ec_dev->din);
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(cros_ec_remove);
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
int cros_ec_suspend(struct cros_ec_device *ec_dev)
|
||||
{
|
||||
struct device *dev = ec_dev->dev;
|
||||
|
||||
if (device_may_wakeup(dev))
|
||||
ec_dev->wake_enabled = !enable_irq_wake(ec_dev->irq);
|
||||
|
||||
disable_irq(ec_dev->irq);
|
||||
ec_dev->was_wake_device = ec_dev->wake_enabled;
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(cros_ec_suspend);
|
||||
|
||||
int cros_ec_resume(struct cros_ec_device *ec_dev)
|
||||
{
|
||||
enable_irq(ec_dev->irq);
|
||||
|
||||
if (ec_dev->wake_enabled) {
|
||||
disable_irq_wake(ec_dev->irq);
|
||||
ec_dev->wake_enabled = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(cros_ec_resume);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,201 @@
|
||||
/*
|
||||
* ChromeOS EC multi-function device (I2C)
|
||||
*
|
||||
* Copyright (C) 2012 Google, Inc
|
||||
*
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
* may be copied, distributed, and modified under those terms.
|
||||
*
|
||||
* 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 <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/mfd/cros_ec.h>
|
||||
#include <linux/mfd/cros_ec_commands.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
static inline struct cros_ec_device *to_ec_dev(struct device *dev)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
|
||||
return i2c_get_clientdata(client);
|
||||
}
|
||||
|
||||
static int cros_ec_command_xfer(struct cros_ec_device *ec_dev,
|
||||
struct cros_ec_msg *msg)
|
||||
{
|
||||
struct i2c_client *client = ec_dev->priv;
|
||||
int ret = -ENOMEM;
|
||||
int i;
|
||||
int packet_len;
|
||||
u8 *out_buf = NULL;
|
||||
u8 *in_buf = NULL;
|
||||
u8 sum;
|
||||
struct i2c_msg i2c_msg[2];
|
||||
|
||||
i2c_msg[0].addr = client->addr;
|
||||
i2c_msg[0].flags = 0;
|
||||
i2c_msg[1].addr = client->addr;
|
||||
i2c_msg[1].flags = I2C_M_RD;
|
||||
|
||||
/*
|
||||
* allocate larger packet (one byte for checksum, one byte for
|
||||
* length, and one for result code)
|
||||
*/
|
||||
packet_len = msg->in_len + 3;
|
||||
in_buf = kzalloc(packet_len, GFP_KERNEL);
|
||||
if (!in_buf)
|
||||
goto done;
|
||||
i2c_msg[1].len = packet_len;
|
||||
i2c_msg[1].buf = (char *)in_buf;
|
||||
|
||||
/*
|
||||
* allocate larger packet (one byte for checksum, one for
|
||||
* command code, one for length, and one for command version)
|
||||
*/
|
||||
packet_len = msg->out_len + 4;
|
||||
out_buf = kzalloc(packet_len, GFP_KERNEL);
|
||||
if (!out_buf)
|
||||
goto done;
|
||||
i2c_msg[0].len = packet_len;
|
||||
i2c_msg[0].buf = (char *)out_buf;
|
||||
|
||||
out_buf[0] = EC_CMD_VERSION0 + msg->version;
|
||||
out_buf[1] = msg->cmd;
|
||||
out_buf[2] = msg->out_len;
|
||||
|
||||
/* copy message payload and compute checksum */
|
||||
sum = out_buf[0] + out_buf[1] + out_buf[2];
|
||||
for (i = 0; i < msg->out_len; i++) {
|
||||
out_buf[3 + i] = msg->out_buf[i];
|
||||
sum += out_buf[3 + i];
|
||||
}
|
||||
out_buf[3 + msg->out_len] = sum;
|
||||
|
||||
/* send command to EC and read answer */
|
||||
ret = i2c_transfer(client->adapter, i2c_msg, 2);
|
||||
if (ret < 0) {
|
||||
dev_err(ec_dev->dev, "i2c transfer failed: %d\n", ret);
|
||||
goto done;
|
||||
} else if (ret != 2) {
|
||||
dev_err(ec_dev->dev, "failed to get response: %d\n", ret);
|
||||
ret = -EIO;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* check response error code */
|
||||
if (i2c_msg[1].buf[0]) {
|
||||
dev_warn(ec_dev->dev, "command 0x%02x returned an error %d\n",
|
||||
msg->cmd, i2c_msg[1].buf[0]);
|
||||
ret = -EINVAL;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* copy response packet payload and compute checksum */
|
||||
sum = in_buf[0] + in_buf[1];
|
||||
for (i = 0; i < msg->in_len; i++) {
|
||||
msg->in_buf[i] = in_buf[2 + i];
|
||||
sum += in_buf[2 + i];
|
||||
}
|
||||
dev_dbg(ec_dev->dev, "packet: %*ph, sum = %02x\n",
|
||||
i2c_msg[1].len, in_buf, sum);
|
||||
if (sum != in_buf[2 + msg->in_len]) {
|
||||
dev_err(ec_dev->dev, "bad packet checksum\n");
|
||||
ret = -EBADMSG;
|
||||
goto done;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
done:
|
||||
kfree(in_buf);
|
||||
kfree(out_buf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int cros_ec_probe_i2c(struct i2c_client *client,
|
||||
const struct i2c_device_id *dev_id)
|
||||
{
|
||||
struct device *dev = &client->dev;
|
||||
struct cros_ec_device *ec_dev = NULL;
|
||||
int err;
|
||||
|
||||
ec_dev = devm_kzalloc(dev, sizeof(*ec_dev), GFP_KERNEL);
|
||||
if (!ec_dev)
|
||||
return -ENOMEM;
|
||||
|
||||
i2c_set_clientdata(client, ec_dev);
|
||||
ec_dev->name = "I2C";
|
||||
ec_dev->dev = dev;
|
||||
ec_dev->priv = client;
|
||||
ec_dev->irq = client->irq;
|
||||
ec_dev->command_xfer = cros_ec_command_xfer;
|
||||
ec_dev->ec_name = client->name;
|
||||
ec_dev->phys_name = client->adapter->name;
|
||||
ec_dev->parent = &client->dev;
|
||||
|
||||
err = cros_ec_register(ec_dev);
|
||||
if (err) {
|
||||
dev_err(dev, "cannot register EC\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cros_ec_remove_i2c(struct i2c_client *client)
|
||||
{
|
||||
struct cros_ec_device *ec_dev = i2c_get_clientdata(client);
|
||||
|
||||
cros_ec_remove(ec_dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
static int cros_ec_i2c_suspend(struct device *dev)
|
||||
{
|
||||
struct cros_ec_device *ec_dev = to_ec_dev(dev);
|
||||
|
||||
return cros_ec_suspend(ec_dev);
|
||||
}
|
||||
|
||||
static int cros_ec_i2c_resume(struct device *dev)
|
||||
{
|
||||
struct cros_ec_device *ec_dev = to_ec_dev(dev);
|
||||
|
||||
return cros_ec_resume(ec_dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
static SIMPLE_DEV_PM_OPS(cros_ec_i2c_pm_ops, cros_ec_i2c_suspend,
|
||||
cros_ec_i2c_resume);
|
||||
|
||||
static const struct i2c_device_id cros_ec_i2c_id[] = {
|
||||
{ "cros-ec-i2c", 0 },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, cros_ec_i2c_id);
|
||||
|
||||
static struct i2c_driver cros_ec_driver = {
|
||||
.driver = {
|
||||
.name = "cros-ec-i2c",
|
||||
.owner = THIS_MODULE,
|
||||
.pm = &cros_ec_i2c_pm_ops,
|
||||
},
|
||||
.probe = cros_ec_probe_i2c,
|
||||
.remove = cros_ec_remove_i2c,
|
||||
.id_table = cros_ec_i2c_id,
|
||||
};
|
||||
|
||||
module_i2c_driver(cros_ec_driver);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_DESCRIPTION("ChromeOS EC multi function device");
|
||||
@@ -0,0 +1,375 @@
|
||||
/*
|
||||
* ChromeOS EC multi-function device (SPI)
|
||||
*
|
||||
* Copyright (C) 2012 Google, Inc
|
||||
*
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
* may be copied, distributed, and modified under those terms.
|
||||
*
|
||||
* 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 <linux/delay.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/mfd/cros_ec.h>
|
||||
#include <linux/mfd/cros_ec_commands.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/spi/spi.h>
|
||||
|
||||
|
||||
/* The header byte, which follows the preamble */
|
||||
#define EC_MSG_HEADER 0xec
|
||||
|
||||
/*
|
||||
* Number of EC preamble bytes we read at a time. Since it takes
|
||||
* about 400-500us for the EC to respond there is not a lot of
|
||||
* point in tuning this. If the EC could respond faster then
|
||||
* we could increase this so that might expect the preamble and
|
||||
* message to occur in a single transaction. However, the maximum
|
||||
* SPI transfer size is 256 bytes, so at 5MHz we need a response
|
||||
* time of perhaps <320us (200 bytes / 1600 bits).
|
||||
*/
|
||||
#define EC_MSG_PREAMBLE_COUNT 32
|
||||
|
||||
/*
|
||||
* We must get a response from the EC in 5ms. This is a very long
|
||||
* time, but the flash write command can take 2-3ms. The EC command
|
||||
* processing is currently not very fast (about 500us). We could
|
||||
* look at speeding this up and making the flash write command a
|
||||
* 'slow' command, requiring a GET_STATUS wait loop, like flash
|
||||
* erase.
|
||||
*/
|
||||
#define EC_MSG_DEADLINE_MS 5
|
||||
|
||||
/*
|
||||
* Time between raising the SPI chip select (for the end of a
|
||||
* transaction) and dropping it again (for the next transaction).
|
||||
* If we go too fast, the EC will miss the transaction. It seems
|
||||
* that 50us is enough with the 16MHz STM32 EC.
|
||||
*/
|
||||
#define EC_SPI_RECOVERY_TIME_NS (50 * 1000)
|
||||
|
||||
/**
|
||||
* struct cros_ec_spi - information about a SPI-connected EC
|
||||
*
|
||||
* @spi: SPI device we are connected to
|
||||
* @last_transfer_ns: time that we last finished a transfer, or 0 if there
|
||||
* if no record
|
||||
*/
|
||||
struct cros_ec_spi {
|
||||
struct spi_device *spi;
|
||||
s64 last_transfer_ns;
|
||||
};
|
||||
|
||||
static void debug_packet(struct device *dev, const char *name, u8 *ptr,
|
||||
int len)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
int i;
|
||||
|
||||
dev_dbg(dev, "%s: ", name);
|
||||
for (i = 0; i < len; i++)
|
||||
dev_cont(dev, " %02x", ptr[i]);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* cros_ec_spi_receive_response - Receive a response from the EC.
|
||||
*
|
||||
* This function has two phases: reading the preamble bytes (since if we read
|
||||
* data from the EC before it is ready to send, we just get preamble) and
|
||||
* reading the actual message.
|
||||
*
|
||||
* The received data is placed into ec_dev->din.
|
||||
*
|
||||
* @ec_dev: ChromeOS EC device
|
||||
* @need_len: Number of message bytes we need to read
|
||||
*/
|
||||
static int cros_ec_spi_receive_response(struct cros_ec_device *ec_dev,
|
||||
int need_len)
|
||||
{
|
||||
struct cros_ec_spi *ec_spi = ec_dev->priv;
|
||||
struct spi_transfer trans;
|
||||
struct spi_message msg;
|
||||
u8 *ptr, *end;
|
||||
int ret;
|
||||
unsigned long deadline;
|
||||
int todo;
|
||||
|
||||
/* Receive data until we see the header byte */
|
||||
deadline = jiffies + msecs_to_jiffies(EC_MSG_DEADLINE_MS);
|
||||
do {
|
||||
memset(&trans, '\0', sizeof(trans));
|
||||
trans.cs_change = 1;
|
||||
trans.rx_buf = ptr = ec_dev->din;
|
||||
trans.len = EC_MSG_PREAMBLE_COUNT;
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&trans, &msg);
|
||||
ret = spi_sync(ec_spi->spi, &msg);
|
||||
if (ret < 0) {
|
||||
dev_err(ec_dev->dev, "spi transfer failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (end = ptr + EC_MSG_PREAMBLE_COUNT; ptr != end; ptr++) {
|
||||
if (*ptr == EC_MSG_HEADER) {
|
||||
dev_dbg(ec_dev->dev, "msg found at %ld\n",
|
||||
ptr - ec_dev->din);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (time_after(jiffies, deadline)) {
|
||||
dev_warn(ec_dev->dev, "EC failed to respond in time\n");
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
} while (ptr == end);
|
||||
|
||||
/*
|
||||
* ptr now points to the header byte. Copy any valid data to the
|
||||
* start of our buffer
|
||||
*/
|
||||
todo = end - ++ptr;
|
||||
BUG_ON(todo < 0 || todo > ec_dev->din_size);
|
||||
todo = min(todo, need_len);
|
||||
memmove(ec_dev->din, ptr, todo);
|
||||
ptr = ec_dev->din + todo;
|
||||
dev_dbg(ec_dev->dev, "need %d, got %d bytes from preamble\n",
|
||||
need_len, todo);
|
||||
need_len -= todo;
|
||||
|
||||
/* Receive data until we have it all */
|
||||
while (need_len > 0) {
|
||||
/*
|
||||
* We can't support transfers larger than the SPI FIFO size
|
||||
* unless we have DMA. We don't have DMA on the ISP SPI ports
|
||||
* for Exynos. We need a way of asking SPI driver for
|
||||
* maximum-supported transfer size.
|
||||
*/
|
||||
todo = min(need_len, 256);
|
||||
dev_dbg(ec_dev->dev, "loop, todo=%d, need_len=%d, ptr=%ld\n",
|
||||
todo, need_len, ptr - ec_dev->din);
|
||||
|
||||
memset(&trans, '\0', sizeof(trans));
|
||||
trans.cs_change = 1;
|
||||
trans.rx_buf = ptr;
|
||||
trans.len = todo;
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&trans, &msg);
|
||||
|
||||
/* send command to EC and read answer */
|
||||
BUG_ON((u8 *)trans.rx_buf - ec_dev->din + todo >
|
||||
ec_dev->din_size);
|
||||
ret = spi_sync(ec_spi->spi, &msg);
|
||||
if (ret < 0) {
|
||||
dev_err(ec_dev->dev, "spi transfer failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
debug_packet(ec_dev->dev, "interim", ptr, todo);
|
||||
ptr += todo;
|
||||
need_len -= todo;
|
||||
}
|
||||
|
||||
dev_dbg(ec_dev->dev, "loop done, ptr=%ld\n", ptr - ec_dev->din);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* cros_ec_command_spi_xfer - Transfer a message over SPI and receive the reply
|
||||
*
|
||||
* @ec_dev: ChromeOS EC device
|
||||
* @ec_msg: Message to transfer
|
||||
*/
|
||||
static int cros_ec_command_spi_xfer(struct cros_ec_device *ec_dev,
|
||||
struct cros_ec_msg *ec_msg)
|
||||
{
|
||||
struct cros_ec_spi *ec_spi = ec_dev->priv;
|
||||
struct spi_transfer trans;
|
||||
struct spi_message msg;
|
||||
int i, len;
|
||||
u8 *ptr;
|
||||
int sum;
|
||||
int ret = 0, final_ret;
|
||||
struct timespec ts;
|
||||
|
||||
len = cros_ec_prepare_tx(ec_dev, ec_msg);
|
||||
dev_dbg(ec_dev->dev, "prepared, len=%d\n", len);
|
||||
|
||||
/* If it's too soon to do another transaction, wait */
|
||||
if (ec_spi->last_transfer_ns) {
|
||||
struct timespec ts;
|
||||
unsigned long delay; /* The delay completed so far */
|
||||
|
||||
ktime_get_ts(&ts);
|
||||
delay = timespec_to_ns(&ts) - ec_spi->last_transfer_ns;
|
||||
if (delay < EC_SPI_RECOVERY_TIME_NS)
|
||||
ndelay(delay);
|
||||
}
|
||||
|
||||
/* Transmit phase - send our message */
|
||||
debug_packet(ec_dev->dev, "out", ec_dev->dout, len);
|
||||
memset(&trans, '\0', sizeof(trans));
|
||||
trans.tx_buf = ec_dev->dout;
|
||||
trans.len = len;
|
||||
trans.cs_change = 1;
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&trans, &msg);
|
||||
ret = spi_sync(ec_spi->spi, &msg);
|
||||
|
||||
/* Get the response */
|
||||
if (!ret) {
|
||||
ret = cros_ec_spi_receive_response(ec_dev,
|
||||
ec_msg->in_len + EC_MSG_TX_PROTO_BYTES);
|
||||
} else {
|
||||
dev_err(ec_dev->dev, "spi transfer failed: %d\n", ret);
|
||||
}
|
||||
|
||||
/* turn off CS */
|
||||
spi_message_init(&msg);
|
||||
final_ret = spi_sync(ec_spi->spi, &msg);
|
||||
ktime_get_ts(&ts);
|
||||
ec_spi->last_transfer_ns = timespec_to_ns(&ts);
|
||||
if (!ret)
|
||||
ret = final_ret;
|
||||
if (ret < 0) {
|
||||
dev_err(ec_dev->dev, "spi transfer failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* check response error code */
|
||||
ptr = ec_dev->din;
|
||||
if (ptr[0]) {
|
||||
dev_warn(ec_dev->dev, "command 0x%02x returned an error %d\n",
|
||||
ec_msg->cmd, ptr[0]);
|
||||
debug_packet(ec_dev->dev, "in_err", ptr, len);
|
||||
return -EINVAL;
|
||||
}
|
||||
len = ptr[1];
|
||||
sum = ptr[0] + ptr[1];
|
||||
if (len > ec_msg->in_len) {
|
||||
dev_err(ec_dev->dev, "packet too long (%d bytes, expected %d)",
|
||||
len, ec_msg->in_len);
|
||||
return -ENOSPC;
|
||||
}
|
||||
|
||||
/* copy response packet payload and compute checksum */
|
||||
for (i = 0; i < len; i++) {
|
||||
sum += ptr[i + 2];
|
||||
if (ec_msg->in_len)
|
||||
ec_msg->in_buf[i] = ptr[i + 2];
|
||||
}
|
||||
sum &= 0xff;
|
||||
|
||||
debug_packet(ec_dev->dev, "in", ptr, len + 3);
|
||||
|
||||
if (sum != ptr[len + 2]) {
|
||||
dev_err(ec_dev->dev,
|
||||
"bad packet checksum, expected %02x, got %02x\n",
|
||||
sum, ptr[len + 2]);
|
||||
return -EBADMSG;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cros_ec_probe_spi(struct spi_device *spi)
|
||||
{
|
||||
struct device *dev = &spi->dev;
|
||||
struct cros_ec_device *ec_dev;
|
||||
struct cros_ec_spi *ec_spi;
|
||||
int err;
|
||||
|
||||
spi->bits_per_word = 8;
|
||||
spi->mode = SPI_MODE_0;
|
||||
err = spi_setup(spi);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
ec_spi = devm_kzalloc(dev, sizeof(*ec_spi), GFP_KERNEL);
|
||||
if (ec_spi == NULL)
|
||||
return -ENOMEM;
|
||||
ec_spi->spi = spi;
|
||||
ec_dev = devm_kzalloc(dev, sizeof(*ec_dev), GFP_KERNEL);
|
||||
if (!ec_dev)
|
||||
return -ENOMEM;
|
||||
|
||||
spi_set_drvdata(spi, ec_dev);
|
||||
ec_dev->name = "SPI";
|
||||
ec_dev->dev = dev;
|
||||
ec_dev->priv = ec_spi;
|
||||
ec_dev->irq = spi->irq;
|
||||
ec_dev->command_xfer = cros_ec_command_spi_xfer;
|
||||
ec_dev->ec_name = ec_spi->spi->modalias;
|
||||
ec_dev->phys_name = dev_name(&ec_spi->spi->dev);
|
||||
ec_dev->parent = &ec_spi->spi->dev;
|
||||
ec_dev->din_size = EC_MSG_BYTES + EC_MSG_PREAMBLE_COUNT;
|
||||
ec_dev->dout_size = EC_MSG_BYTES;
|
||||
|
||||
err = cros_ec_register(ec_dev);
|
||||
if (err) {
|
||||
dev_err(dev, "cannot register EC\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cros_ec_remove_spi(struct spi_device *spi)
|
||||
{
|
||||
struct cros_ec_device *ec_dev;
|
||||
|
||||
ec_dev = spi_get_drvdata(spi);
|
||||
cros_ec_remove(ec_dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
static int cros_ec_spi_suspend(struct device *dev)
|
||||
{
|
||||
struct cros_ec_device *ec_dev = dev_get_drvdata(dev);
|
||||
|
||||
return cros_ec_suspend(ec_dev);
|
||||
}
|
||||
|
||||
static int cros_ec_spi_resume(struct device *dev)
|
||||
{
|
||||
struct cros_ec_device *ec_dev = dev_get_drvdata(dev);
|
||||
|
||||
return cros_ec_resume(ec_dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
static SIMPLE_DEV_PM_OPS(cros_ec_spi_pm_ops, cros_ec_spi_suspend,
|
||||
cros_ec_spi_resume);
|
||||
|
||||
static const struct spi_device_id cros_ec_spi_id[] = {
|
||||
{ "cros-ec-spi", 0 },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(spi, cros_ec_spi_id);
|
||||
|
||||
static struct spi_driver cros_ec_driver_spi = {
|
||||
.driver = {
|
||||
.name = "cros-ec-spi",
|
||||
.owner = THIS_MODULE,
|
||||
.pm = &cros_ec_spi_pm_ops,
|
||||
},
|
||||
.probe = cros_ec_probe_spi,
|
||||
.remove = cros_ec_remove_spi,
|
||||
.id_table = cros_ec_spi_id,
|
||||
};
|
||||
|
||||
module_spi_driver(cros_ec_driver_spi);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_DESCRIPTION("ChromeOS EC multi function device (SPI)");
|
||||
+6
-13
@@ -499,7 +499,8 @@ static int da903x_probe(struct i2c_client *client,
|
||||
unsigned int tmp;
|
||||
int ret;
|
||||
|
||||
chip = kzalloc(sizeof(struct da903x_chip), GFP_KERNEL);
|
||||
chip = devm_kzalloc(&client->dev, sizeof(struct da903x_chip),
|
||||
GFP_KERNEL);
|
||||
if (chip == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -515,33 +516,27 @@ static int da903x_probe(struct i2c_client *client,
|
||||
|
||||
ret = chip->ops->init_chip(chip);
|
||||
if (ret)
|
||||
goto out_free_chip;
|
||||
return ret;
|
||||
|
||||
/* mask and clear all IRQs */
|
||||
chip->events_mask = 0xffffffff;
|
||||
chip->ops->mask_events(chip, chip->events_mask);
|
||||
chip->ops->read_events(chip, &tmp);
|
||||
|
||||
ret = request_irq(client->irq, da903x_irq_handler,
|
||||
ret = devm_request_irq(&client->dev, client->irq, da903x_irq_handler,
|
||||
IRQF_TRIGGER_FALLING,
|
||||
"da903x", chip);
|
||||
if (ret) {
|
||||
dev_err(&client->dev, "failed to request irq %d\n",
|
||||
client->irq);
|
||||
goto out_free_chip;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = da903x_add_subdevs(chip, pdata);
|
||||
if (ret)
|
||||
goto out_free_irq;
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
|
||||
out_free_irq:
|
||||
free_irq(client->irq, chip);
|
||||
out_free_chip:
|
||||
kfree(chip);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int da903x_remove(struct i2c_client *client)
|
||||
@@ -549,8 +544,6 @@ static int da903x_remove(struct i2c_client *client)
|
||||
struct da903x_chip *chip = i2c_get_clientdata(client);
|
||||
|
||||
da903x_remove_subdevs(chip);
|
||||
free_irq(client->irq, chip);
|
||||
kfree(chip);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ static int da9052_spi_probe(struct spi_device *spi)
|
||||
da9052->dev = &spi->dev;
|
||||
da9052->chip_irq = spi->irq;
|
||||
|
||||
dev_set_drvdata(&spi->dev, da9052);
|
||||
spi_set_drvdata(spi, da9052);
|
||||
|
||||
da9052_regmap_config.read_flag_mask = 1;
|
||||
da9052_regmap_config.write_flag_mask = 0;
|
||||
@@ -60,7 +60,7 @@ static int da9052_spi_probe(struct spi_device *spi)
|
||||
|
||||
static int da9052_spi_remove(struct spi_device *spi)
|
||||
{
|
||||
struct da9052 *da9052 = dev_get_drvdata(&spi->dev);
|
||||
struct da9052 *da9052 = spi_get_drvdata(spi);
|
||||
|
||||
da9052_device_exit(da9052);
|
||||
return 0;
|
||||
|
||||
@@ -391,7 +391,7 @@ int da9055_device_init(struct da9055 *da9055)
|
||||
da9055->irq_base = pdata->irq_base;
|
||||
|
||||
ret = regmap_add_irq_chip(da9055->regmap, da9055->chip_irq,
|
||||
IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
|
||||
IRQF_TRIGGER_LOW | IRQF_ONESHOT,
|
||||
da9055->irq_base, &da9055_regmap_irq_chip,
|
||||
&da9055->irq_data);
|
||||
if (ret < 0)
|
||||
|
||||
@@ -177,17 +177,7 @@ static struct platform_driver davinci_vc_driver = {
|
||||
.remove = davinci_vc_remove,
|
||||
};
|
||||
|
||||
static int __init davinci_vc_init(void)
|
||||
{
|
||||
return platform_driver_probe(&davinci_vc_driver, davinci_vc_probe);
|
||||
}
|
||||
module_init(davinci_vc_init);
|
||||
|
||||
static void __exit davinci_vc_exit(void)
|
||||
{
|
||||
platform_driver_unregister(&davinci_vc_driver);
|
||||
}
|
||||
module_exit(davinci_vc_exit);
|
||||
module_platform_driver_probe(davinci_vc_driver, davinci_vc_probe);
|
||||
|
||||
MODULE_AUTHOR("Miguel Aguilar");
|
||||
MODULE_DESCRIPTION("Texas Instruments DaVinci Voice Codec Core Interface");
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user