diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-09-07 23:14:19 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-09-07 23:14:19 -0400 |
commit | 8de4651abe61c6b6a94a70a57ef163020fed05ee (patch) | |
tree | a2455b59b7df7239a5819b9cf2248e27eef483c4 /drivers/mfd | |
parent | 327fff3e1391a27dcc89de6e0481689a865361c9 (diff) | |
parent | 9c31e8840836de447e1e508a6d756af419790ed6 (diff) |
Merge tag 'mfd-3.12-1' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-next
Pull MFD (multi-function device) updates from Samuel Ortiz:
"For the 3.12 merge window we have one new driver for the DA9063 PMIC
from Dialog Semiconductor.
Besides that driver we also have:
- Device tree support for the s2mps11 driver
- More devm_* conversion for the pm8921, max89xx, menelaus, tps65010,
wl1273 and pcf50633-adc drivers.
- A conversion to threaded IRQ and IRQ domain for the twl6030 driver.
- A fairly big update for the rtsx driver: Better power saving
support, better vendor settings handling, and a few fixes.
- Support for a couple more boards (COMe-bHL6 and COMe-cTH6) for the
Kontron driver.
- A conversion to the dev_get_platdata() API for all MFD drivers.
- A removal of non-DT (legacy) support for the twl6040 driver.
- A few fixes and additions (Mic detect level) to the wm5110 register
tables.
- Regmap support for the davinci_voicecodec driver.
- The usual bunch of minor cleanups and janitorial fixes"
* tag 'mfd-3.12-1' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-next: (81 commits)
mfd: ucb1x00-core: Rewrite ucb1x00_add_dev()
mfd: ab8500-debugfs: Apply a check for -ENOMEM after allocating memory for event name
mfd: ab8500-debugfs: Apply a check for -ENOMEM after allocating memory for sysfs
mfd: timberdale: Use module_pci_driver
mfd: timberdale: Remove redundant break
mfd: timberdale: Staticize local variables
mfd: ab8500-debugfs: Staticize local variables
mfd: db8500-prcmu: Staticize clk_mgt
mfd: db8500-prcmu: Use ANSI function declaration
mfd: omap-usb-host: Staticize usbhs_driver_name
mfd: 88pm805: Fix potential NULL pdata dereference
mfd: 88pm800: Fix potential NULL pdata dereference
mfd: twl6040: Use regmap for register cache
mfd: davinci_voicecodec: Provide a regmap for register I/O
mfd: davinci_voicecodec: Remove unused read and write functions
mmc: memstick: rtsx: Modify copyright comments
mmc: rtsx: Clear SD_CLK toggle enable bit if switching voltage fail
mfd: mmc: rtsx: Change default tx phase
mfd: pcf50633-adc: Use devm_*() functions
mfd: rtsx: Copyright modifications
...
Diffstat (limited to 'drivers/mfd')
89 files changed, 1702 insertions, 621 deletions
diff --git a/drivers/mfd/88pm800.c b/drivers/mfd/88pm800.c index 6c954835d61e..a65447d65605 100644 --- a/drivers/mfd/88pm800.c +++ b/drivers/mfd/88pm800.c | |||
@@ -333,9 +333,11 @@ static int device_rtc_init(struct pm80x_chip *chip, | |||
333 | { | 333 | { |
334 | int ret; | 334 | int ret; |
335 | 335 | ||
336 | rtc_devs[0].platform_data = pdata->rtc; | 336 | if (pdata) { |
337 | rtc_devs[0].pdata_size = | 337 | rtc_devs[0].platform_data = pdata->rtc; |
338 | pdata->rtc ? sizeof(struct pm80x_rtc_pdata) : 0; | 338 | rtc_devs[0].pdata_size = |
339 | pdata->rtc ? sizeof(struct pm80x_rtc_pdata) : 0; | ||
340 | } | ||
339 | ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0], | 341 | ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0], |
340 | ARRAY_SIZE(rtc_devs), NULL, 0, NULL); | 342 | ARRAY_SIZE(rtc_devs), NULL, 0, NULL); |
341 | if (ret) { | 343 | if (ret) { |
@@ -541,7 +543,7 @@ static int pm800_probe(struct i2c_client *client, | |||
541 | { | 543 | { |
542 | int ret = 0; | 544 | int ret = 0; |
543 | struct pm80x_chip *chip; | 545 | struct pm80x_chip *chip; |
544 | struct pm80x_platform_data *pdata = client->dev.platform_data; | 546 | struct pm80x_platform_data *pdata = dev_get_platdata(&client->dev); |
545 | struct pm80x_subchip *subchip; | 547 | struct pm80x_subchip *subchip; |
546 | 548 | ||
547 | ret = pm80x_init(client); | 549 | ret = pm80x_init(client); |
@@ -578,7 +580,7 @@ static int pm800_probe(struct i2c_client *client, | |||
578 | goto err_device_init; | 580 | goto err_device_init; |
579 | } | 581 | } |
580 | 582 | ||
581 | if (pdata->plat_config) | 583 | if (pdata && pdata->plat_config) |
582 | pdata->plat_config(chip, pdata); | 584 | pdata->plat_config(chip, pdata); |
583 | 585 | ||
584 | return 0; | 586 | return 0; |
diff --git a/drivers/mfd/88pm805.c b/drivers/mfd/88pm805.c index 521602231c7b..8a5b6ffb5afb 100644 --- a/drivers/mfd/88pm805.c +++ b/drivers/mfd/88pm805.c | |||
@@ -227,7 +227,7 @@ static int pm805_probe(struct i2c_client *client, | |||
227 | { | 227 | { |
228 | int ret = 0; | 228 | int ret = 0; |
229 | struct pm80x_chip *chip; | 229 | struct pm80x_chip *chip; |
230 | struct pm80x_platform_data *pdata = client->dev.platform_data; | 230 | struct pm80x_platform_data *pdata = dev_get_platdata(&client->dev); |
231 | 231 | ||
232 | ret = pm80x_init(client); | 232 | ret = pm80x_init(client); |
233 | if (ret) { | 233 | if (ret) { |
@@ -243,7 +243,7 @@ static int pm805_probe(struct i2c_client *client, | |||
243 | goto err_805_init; | 243 | goto err_805_init; |
244 | } | 244 | } |
245 | 245 | ||
246 | if (pdata->plat_config) | 246 | if (pdata && pdata->plat_config) |
247 | pdata->plat_config(chip, pdata); | 247 | pdata->plat_config(chip, pdata); |
248 | 248 | ||
249 | err_805_init: | 249 | err_805_init: |
diff --git a/drivers/mfd/88pm860x-core.c b/drivers/mfd/88pm860x-core.c index eeb481d426b5..7ebe9ef1eba6 100644 --- a/drivers/mfd/88pm860x-core.c +++ b/drivers/mfd/88pm860x-core.c | |||
@@ -1130,7 +1130,7 @@ static int pm860x_dt_init(struct device_node *np, | |||
1130 | static int pm860x_probe(struct i2c_client *client, | 1130 | static int pm860x_probe(struct i2c_client *client, |
1131 | const struct i2c_device_id *id) | 1131 | const struct i2c_device_id *id) |
1132 | { | 1132 | { |
1133 | struct pm860x_platform_data *pdata = client->dev.platform_data; | 1133 | struct pm860x_platform_data *pdata = dev_get_platdata(&client->dev); |
1134 | struct device_node *node = client->dev.of_node; | 1134 | struct device_node *node = client->dev.of_node; |
1135 | struct pm860x_chip *chip; | 1135 | struct pm860x_chip *chip; |
1136 | int ret; | 1136 | int ret; |
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index aecd6ddcbbbf..e0e46f50f95d 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig | |||
@@ -139,6 +139,18 @@ config MFD_DA9055 | |||
139 | This driver can be built as a module. If built as a module it will be | 139 | This driver can be built as a module. If built as a module it will be |
140 | called "da9055" | 140 | called "da9055" |
141 | 141 | ||
142 | config MFD_DA9063 | ||
143 | bool "Dialog Semiconductor DA9063 PMIC Support" | ||
144 | select MFD_CORE | ||
145 | select REGMAP_I2C | ||
146 | select REGMAP_IRQ | ||
147 | depends on I2C=y && GENERIC_HARDIRQS | ||
148 | help | ||
149 | Say yes here for support for the Dialog Semiconductor DA9063 PMIC. | ||
150 | This includes the I2C driver and core APIs. | ||
151 | Additional drivers must be enabled in order to use the functionality | ||
152 | of the device. | ||
153 | |||
142 | config MFD_MC13783 | 154 | config MFD_MC13783 |
143 | tristate | 155 | tristate |
144 | 156 | ||
@@ -1070,7 +1082,7 @@ config MFD_WM5110 | |||
1070 | Support for Wolfson Microelectronics WM5110 low power audio SoC | 1082 | Support for Wolfson Microelectronics WM5110 low power audio SoC |
1071 | 1083 | ||
1072 | config MFD_WM8997 | 1084 | config MFD_WM8997 |
1073 | bool "Support Wolfson Microelectronics WM8997" | 1085 | bool "Wolfson Microelectronics WM8997" |
1074 | depends on MFD_ARIZONA | 1086 | depends on MFD_ARIZONA |
1075 | help | 1087 | help |
1076 | Support for Wolfson Microelectronics WM8997 low power audio SoC | 1088 | Support for Wolfson Microelectronics WM8997 low power audio SoC |
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 3c90051ffa5a..15b905c6553c 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile | |||
@@ -107,6 +107,9 @@ obj-$(CONFIG_MFD_LP8788) += lp8788.o lp8788-irq.o | |||
107 | da9055-objs := da9055-core.o da9055-i2c.o | 107 | da9055-objs := da9055-core.o da9055-i2c.o |
108 | obj-$(CONFIG_MFD_DA9055) += da9055.o | 108 | obj-$(CONFIG_MFD_DA9055) += da9055.o |
109 | 109 | ||
110 | da9063-objs := da9063-core.o da9063-irq.o da9063-i2c.o | ||
111 | obj-$(CONFIG_MFD_DA9063) += da9063.o | ||
112 | |||
110 | obj-$(CONFIG_MFD_MAX77686) += max77686.o max77686-irq.o | 113 | obj-$(CONFIG_MFD_MAX77686) += max77686.o max77686-irq.o |
111 | obj-$(CONFIG_MFD_MAX77693) += max77693.o max77693-irq.o | 114 | obj-$(CONFIG_MFD_MAX77693) += max77693.o max77693-irq.o |
112 | obj-$(CONFIG_MFD_MAX8907) += max8907.o | 115 | obj-$(CONFIG_MFD_MAX8907) += max8907.o |
diff --git a/drivers/mfd/aat2870-core.c b/drivers/mfd/aat2870-core.c index d4f594517521..6f68472e0ca6 100644 --- a/drivers/mfd/aat2870-core.c +++ b/drivers/mfd/aat2870-core.c | |||
@@ -363,7 +363,7 @@ static inline void aat2870_uninit_debugfs(struct aat2870_data *aat2870) | |||
363 | static int aat2870_i2c_probe(struct i2c_client *client, | 363 | static int aat2870_i2c_probe(struct i2c_client *client, |
364 | const struct i2c_device_id *id) | 364 | const struct i2c_device_id *id) |
365 | { | 365 | { |
366 | struct aat2870_platform_data *pdata = client->dev.platform_data; | 366 | struct aat2870_platform_data *pdata = dev_get_platdata(&client->dev); |
367 | struct aat2870_data *aat2870; | 367 | struct aat2870_data *aat2870; |
368 | int i, j; | 368 | int i, j; |
369 | int ret = 0; | 369 | int ret = 0; |
diff --git a/drivers/mfd/ab3100-core.c b/drivers/mfd/ab3100-core.c index ddc669d19530..b348ae520629 100644 --- a/drivers/mfd/ab3100-core.c +++ b/drivers/mfd/ab3100-core.c | |||
@@ -854,7 +854,7 @@ static int ab3100_probe(struct i2c_client *client, | |||
854 | { | 854 | { |
855 | struct ab3100 *ab3100; | 855 | struct ab3100 *ab3100; |
856 | struct ab3100_platform_data *ab3100_plf_data = | 856 | struct ab3100_platform_data *ab3100_plf_data = |
857 | client->dev.platform_data; | 857 | dev_get_platdata(&client->dev); |
858 | int err; | 858 | int err; |
859 | int i; | 859 | int i; |
860 | 860 | ||
diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c index 7d1f1b08fc4b..e33e385af0a2 100644 --- a/drivers/mfd/ab8500-debugfs.c +++ b/drivers/mfd/ab8500-debugfs.c | |||
@@ -159,7 +159,7 @@ static struct hwreg_cfg hwreg_cfg = { | |||
159 | 159 | ||
160 | static struct ab8500_prcmu_ranges *debug_ranges; | 160 | static struct ab8500_prcmu_ranges *debug_ranges; |
161 | 161 | ||
162 | struct ab8500_prcmu_ranges ab8500_debug_ranges[AB8500_NUM_BANKS] = { | 162 | static struct ab8500_prcmu_ranges ab8500_debug_ranges[AB8500_NUM_BANKS] = { |
163 | [0x0] = { | 163 | [0x0] = { |
164 | .num_ranges = 0, | 164 | .num_ranges = 0, |
165 | .range = NULL, | 165 | .range = NULL, |
@@ -488,7 +488,7 @@ struct ab8500_prcmu_ranges ab8500_debug_ranges[AB8500_NUM_BANKS] = { | |||
488 | }, | 488 | }, |
489 | }; | 489 | }; |
490 | 490 | ||
491 | struct ab8500_prcmu_ranges ab8505_debug_ranges[AB8500_NUM_BANKS] = { | 491 | static struct ab8500_prcmu_ranges ab8505_debug_ranges[AB8500_NUM_BANKS] = { |
492 | [0x0] = { | 492 | [0x0] = { |
493 | .num_ranges = 0, | 493 | .num_ranges = 0, |
494 | .range = NULL, | 494 | .range = NULL, |
@@ -847,7 +847,7 @@ struct ab8500_prcmu_ranges ab8505_debug_ranges[AB8500_NUM_BANKS] = { | |||
847 | }, | 847 | }, |
848 | }; | 848 | }; |
849 | 849 | ||
850 | struct ab8500_prcmu_ranges ab8540_debug_ranges[AB8500_NUM_BANKS] = { | 850 | static struct ab8500_prcmu_ranges ab8540_debug_ranges[AB8500_NUM_BANKS] = { |
851 | [AB8500_M_FSM_RANK] = { | 851 | [AB8500_M_FSM_RANK] = { |
852 | .num_ranges = 1, | 852 | .num_ranges = 1, |
853 | .range = (struct ab8500_reg_range[]) { | 853 | .range = (struct ab8500_reg_range[]) { |
@@ -1377,7 +1377,7 @@ void ab8500_dump_all_banks(struct device *dev) | |||
1377 | 1377 | ||
1378 | /* Space for 500 registers. */ | 1378 | /* Space for 500 registers. */ |
1379 | #define DUMP_MAX_REGS 700 | 1379 | #define DUMP_MAX_REGS 700 |
1380 | struct ab8500_register_dump | 1380 | static struct ab8500_register_dump |
1381 | { | 1381 | { |
1382 | u8 bank; | 1382 | u8 bank; |
1383 | u8 reg; | 1383 | u8 reg; |
@@ -2800,7 +2800,13 @@ static ssize_t ab8500_subscribe_write(struct file *file, | |||
2800 | */ | 2800 | */ |
2801 | dev_attr[irq_index] = kmalloc(sizeof(struct device_attribute), | 2801 | dev_attr[irq_index] = kmalloc(sizeof(struct device_attribute), |
2802 | GFP_KERNEL); | 2802 | GFP_KERNEL); |
2803 | if (!dev_attr[irq_index]) | ||
2804 | return -ENOMEM; | ||
2805 | |||
2803 | event_name[irq_index] = kmalloc(count, GFP_KERNEL); | 2806 | event_name[irq_index] = kmalloc(count, GFP_KERNEL); |
2807 | if (!event_name[irq_index]) | ||
2808 | return -ENOMEM; | ||
2809 | |||
2804 | sprintf(event_name[irq_index], "%lu", user_val); | 2810 | sprintf(event_name[irq_index], "%lu", user_val); |
2805 | dev_attr[irq_index]->show = show_irq; | 2811 | dev_attr[irq_index]->show = show_irq; |
2806 | dev_attr[irq_index]->store = NULL; | 2812 | dev_attr[irq_index]->store = NULL; |
diff --git a/drivers/mfd/ab8500-gpadc.c b/drivers/mfd/ab8500-gpadc.c index 7623e9123828..36000f920981 100644 --- a/drivers/mfd/ab8500-gpadc.c +++ b/drivers/mfd/ab8500-gpadc.c | |||
@@ -867,6 +867,7 @@ static void ab8500_gpadc_read_calibration_data(struct ab8500_gpadc *gpadc) | |||
867 | gpadc->cal_data[ADC_INPUT_VBAT].offset); | 867 | gpadc->cal_data[ADC_INPUT_VBAT].offset); |
868 | } | 868 | } |
869 | 869 | ||
870 | #ifdef CONFIG_PM_RUNTIME | ||
870 | static int ab8500_gpadc_runtime_suspend(struct device *dev) | 871 | static int ab8500_gpadc_runtime_suspend(struct device *dev) |
871 | { | 872 | { |
872 | struct ab8500_gpadc *gpadc = dev_get_drvdata(dev); | 873 | struct ab8500_gpadc *gpadc = dev_get_drvdata(dev); |
@@ -885,7 +886,9 @@ static int ab8500_gpadc_runtime_resume(struct device *dev) | |||
885 | dev_err(dev, "Failed to enable vtvout LDO: %d\n", ret); | 886 | dev_err(dev, "Failed to enable vtvout LDO: %d\n", ret); |
886 | return ret; | 887 | return ret; |
887 | } | 888 | } |
889 | #endif | ||
888 | 890 | ||
891 | #ifdef CONFIG_PM_SLEEP | ||
889 | static int ab8500_gpadc_suspend(struct device *dev) | 892 | static int ab8500_gpadc_suspend(struct device *dev) |
890 | { | 893 | { |
891 | struct ab8500_gpadc *gpadc = dev_get_drvdata(dev); | 894 | struct ab8500_gpadc *gpadc = dev_get_drvdata(dev); |
@@ -913,6 +916,7 @@ static int ab8500_gpadc_resume(struct device *dev) | |||
913 | mutex_unlock(&gpadc->ab8500_gpadc_lock); | 916 | mutex_unlock(&gpadc->ab8500_gpadc_lock); |
914 | return ret; | 917 | return ret; |
915 | } | 918 | } |
919 | #endif | ||
916 | 920 | ||
917 | static int ab8500_gpadc_probe(struct platform_device *pdev) | 921 | static int ab8500_gpadc_probe(struct platform_device *pdev) |
918 | { | 922 | { |
diff --git a/drivers/mfd/adp5520.c b/drivers/mfd/adp5520.c index 28346ad0b4a6..62501553d63c 100644 --- a/drivers/mfd/adp5520.c +++ b/drivers/mfd/adp5520.c | |||
@@ -207,7 +207,7 @@ static int adp5520_remove_subdevs(struct adp5520_chip *chip) | |||
207 | static int adp5520_probe(struct i2c_client *client, | 207 | static int adp5520_probe(struct i2c_client *client, |
208 | const struct i2c_device_id *id) | 208 | const struct i2c_device_id *id) |
209 | { | 209 | { |
210 | struct adp5520_platform_data *pdata = client->dev.platform_data; | 210 | struct adp5520_platform_data *pdata = dev_get_platdata(&client->dev); |
211 | struct platform_device *pdev; | 211 | struct platform_device *pdev; |
212 | struct adp5520_chip *chip; | 212 | struct adp5520_chip *chip; |
213 | int ret; | 213 | int ret; |
diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c index 89a115301a0c..5ac3aa48473b 100644 --- a/drivers/mfd/arizona-core.c +++ b/drivers/mfd/arizona-core.c | |||
@@ -438,9 +438,9 @@ static int arizona_runtime_suspend(struct device *dev) | |||
438 | } | 438 | } |
439 | } | 439 | } |
440 | 440 | ||
441 | regulator_disable(arizona->dcvdd); | ||
442 | regcache_cache_only(arizona->regmap, true); | 441 | regcache_cache_only(arizona->regmap, true); |
443 | regcache_mark_dirty(arizona->regmap); | 442 | regcache_mark_dirty(arizona->regmap); |
443 | regulator_disable(arizona->dcvdd); | ||
444 | 444 | ||
445 | return 0; | 445 | return 0; |
446 | } | 446 | } |
diff --git a/drivers/mfd/as3711.c b/drivers/mfd/as3711.c index 01e414162702..abd3ab7c0908 100644 --- a/drivers/mfd/as3711.c +++ b/drivers/mfd/as3711.c | |||
@@ -129,7 +129,7 @@ static int as3711_i2c_probe(struct i2c_client *client, | |||
129 | int ret; | 129 | int ret; |
130 | 130 | ||
131 | if (!client->dev.of_node) { | 131 | if (!client->dev.of_node) { |
132 | pdata = client->dev.platform_data; | 132 | pdata = dev_get_platdata(&client->dev); |
133 | if (!pdata) | 133 | if (!pdata) |
134 | dev_dbg(&client->dev, "Platform data not found\n"); | 134 | dev_dbg(&client->dev, "Platform data not found\n"); |
135 | } else { | 135 | } else { |
diff --git a/drivers/mfd/asic3.c b/drivers/mfd/asic3.c index 9532f749412f..fa22154c84e4 100644 --- a/drivers/mfd/asic3.c +++ b/drivers/mfd/asic3.c | |||
@@ -952,7 +952,7 @@ static void asic3_mfd_remove(struct platform_device *pdev) | |||
952 | /* Core */ | 952 | /* Core */ |
953 | static int __init asic3_probe(struct platform_device *pdev) | 953 | static int __init asic3_probe(struct platform_device *pdev) |
954 | { | 954 | { |
955 | struct asic3_platform_data *pdata = pdev->dev.platform_data; | 955 | struct asic3_platform_data *pdata = dev_get_platdata(&pdev->dev); |
956 | struct asic3 *asic; | 956 | struct asic3 *asic; |
957 | struct resource *mem; | 957 | struct resource *mem; |
958 | unsigned long clksel; | 958 | unsigned long clksel; |
diff --git a/drivers/mfd/da903x.c b/drivers/mfd/da903x.c index f1a316e0d6a6..e0a2e0ee603b 100644 --- a/drivers/mfd/da903x.c +++ b/drivers/mfd/da903x.c | |||
@@ -494,7 +494,7 @@ failed: | |||
494 | static int da903x_probe(struct i2c_client *client, | 494 | static int da903x_probe(struct i2c_client *client, |
495 | const struct i2c_device_id *id) | 495 | const struct i2c_device_id *id) |
496 | { | 496 | { |
497 | struct da903x_platform_data *pdata = client->dev.platform_data; | 497 | struct da903x_platform_data *pdata = dev_get_platdata(&client->dev); |
498 | struct da903x_chip *chip; | 498 | struct da903x_chip *chip; |
499 | unsigned int tmp; | 499 | unsigned int tmp; |
500 | int ret; | 500 | int ret; |
diff --git a/drivers/mfd/da9052-core.c b/drivers/mfd/da9052-core.c index a3c9613f9166..ea28a33576e4 100644 --- a/drivers/mfd/da9052-core.c +++ b/drivers/mfd/da9052-core.c | |||
@@ -534,7 +534,7 @@ EXPORT_SYMBOL_GPL(da9052_regmap_config); | |||
534 | 534 | ||
535 | int da9052_device_init(struct da9052 *da9052, u8 chip_id) | 535 | int da9052_device_init(struct da9052 *da9052, u8 chip_id) |
536 | { | 536 | { |
537 | struct da9052_pdata *pdata = da9052->dev->platform_data; | 537 | struct da9052_pdata *pdata = dev_get_platdata(da9052->dev); |
538 | int ret; | 538 | int ret; |
539 | 539 | ||
540 | mutex_init(&da9052->auxadc_lock); | 540 | mutex_init(&da9052->auxadc_lock); |
diff --git a/drivers/mfd/da9055-core.c b/drivers/mfd/da9055-core.c index 49cb23d37469..d3670cd3c3c6 100644 --- a/drivers/mfd/da9055-core.c +++ b/drivers/mfd/da9055-core.c | |||
@@ -379,8 +379,9 @@ static struct regmap_irq_chip da9055_regmap_irq_chip = { | |||
379 | 379 | ||
380 | int da9055_device_init(struct da9055 *da9055) | 380 | int da9055_device_init(struct da9055 *da9055) |
381 | { | 381 | { |
382 | struct da9055_pdata *pdata = da9055->dev->platform_data; | 382 | struct da9055_pdata *pdata = dev_get_platdata(da9055->dev); |
383 | int ret; | 383 | int ret; |
384 | uint8_t clear_events[3] = {0xFF, 0xFF, 0xFF}; | ||
384 | 385 | ||
385 | if (pdata && pdata->init != NULL) | 386 | if (pdata && pdata->init != NULL) |
386 | pdata->init(da9055); | 387 | pdata->init(da9055); |
@@ -390,6 +391,10 @@ int da9055_device_init(struct da9055 *da9055) | |||
390 | else | 391 | else |
391 | da9055->irq_base = pdata->irq_base; | 392 | da9055->irq_base = pdata->irq_base; |
392 | 393 | ||
394 | ret = da9055_group_write(da9055, DA9055_REG_EVENT_A, 3, clear_events); | ||
395 | if (ret < 0) | ||
396 | return ret; | ||
397 | |||
393 | ret = regmap_add_irq_chip(da9055->regmap, da9055->chip_irq, | 398 | ret = regmap_add_irq_chip(da9055->regmap, da9055->chip_irq, |
394 | IRQF_TRIGGER_LOW | IRQF_ONESHOT, | 399 | IRQF_TRIGGER_LOW | IRQF_ONESHOT, |
395 | da9055->irq_base, &da9055_regmap_irq_chip, | 400 | da9055->irq_base, &da9055_regmap_irq_chip, |
diff --git a/drivers/mfd/da9055-i2c.c b/drivers/mfd/da9055-i2c.c index 607387ffe8ca..13af7e50021e 100644 --- a/drivers/mfd/da9055-i2c.c +++ b/drivers/mfd/da9055-i2c.c | |||
@@ -54,7 +54,7 @@ static int da9055_i2c_remove(struct i2c_client *i2c) | |||
54 | } | 54 | } |
55 | 55 | ||
56 | static struct i2c_device_id da9055_i2c_id[] = { | 56 | static struct i2c_device_id da9055_i2c_id[] = { |
57 | {"da9055-pmic", 0}, | 57 | {"da9055", 0}, |
58 | { } | 58 | { } |
59 | }; | 59 | }; |
60 | 60 | ||
diff --git a/drivers/mfd/da9063-core.c b/drivers/mfd/da9063-core.c new file mode 100644 index 000000000000..c9cf8d988406 --- /dev/null +++ b/drivers/mfd/da9063-core.c | |||
@@ -0,0 +1,185 @@ | |||
1 | /* | ||
2 | * da9063-core.c: Device access for Dialog DA9063 modules | ||
3 | * | ||
4 | * Copyright 2012 Dialog Semiconductors Ltd. | ||
5 | * Copyright 2013 Philipp Zabel, Pengutronix | ||
6 | * | ||
7 | * Author: Krystian Garbaciak <krystian.garbaciak@diasemi.com>, | ||
8 | * Michal Hajduk <michal.hajduk@diasemi.com> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify it | ||
11 | * under the terms of the GNU General Public License as published by the | ||
12 | * Free Software Foundation; either version 2 of the License, or (at your | ||
13 | * option) any later version. | ||
14 | * | ||
15 | */ | ||
16 | |||
17 | #include <linux/kernel.h> | ||
18 | #include <linux/module.h> | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/slab.h> | ||
21 | #include <linux/device.h> | ||
22 | #include <linux/delay.h> | ||
23 | #include <linux/interrupt.h> | ||
24 | #include <linux/mutex.h> | ||
25 | #include <linux/mfd/core.h> | ||
26 | #include <linux/regmap.h> | ||
27 | |||
28 | #include <linux/mfd/da9063/core.h> | ||
29 | #include <linux/mfd/da9063/pdata.h> | ||
30 | #include <linux/mfd/da9063/registers.h> | ||
31 | |||
32 | #include <linux/proc_fs.h> | ||
33 | #include <linux/kthread.h> | ||
34 | #include <linux/uaccess.h> | ||
35 | |||
36 | |||
37 | static struct resource da9063_regulators_resources[] = { | ||
38 | { | ||
39 | .name = "LDO_LIM", | ||
40 | .start = DA9063_IRQ_LDO_LIM, | ||
41 | .end = DA9063_IRQ_LDO_LIM, | ||
42 | .flags = IORESOURCE_IRQ, | ||
43 | }, | ||
44 | }; | ||
45 | |||
46 | static struct resource da9063_rtc_resources[] = { | ||
47 | { | ||
48 | .name = "ALARM", | ||
49 | .start = DA9063_IRQ_ALARM, | ||
50 | .end = DA9063_IRQ_ALARM, | ||
51 | .flags = IORESOURCE_IRQ, | ||
52 | }, | ||
53 | { | ||
54 | .name = "TICK", | ||
55 | .start = DA9063_IRQ_TICK, | ||
56 | .end = DA9063_IRQ_TICK, | ||
57 | .flags = IORESOURCE_IRQ, | ||
58 | } | ||
59 | }; | ||
60 | |||
61 | static struct resource da9063_onkey_resources[] = { | ||
62 | { | ||
63 | .start = DA9063_IRQ_ONKEY, | ||
64 | .end = DA9063_IRQ_ONKEY, | ||
65 | .flags = IORESOURCE_IRQ, | ||
66 | }, | ||
67 | }; | ||
68 | |||
69 | static struct resource da9063_hwmon_resources[] = { | ||
70 | { | ||
71 | .start = DA9063_IRQ_ADC_RDY, | ||
72 | .end = DA9063_IRQ_ADC_RDY, | ||
73 | .flags = IORESOURCE_IRQ, | ||
74 | }, | ||
75 | }; | ||
76 | |||
77 | |||
78 | static struct mfd_cell da9063_devs[] = { | ||
79 | { | ||
80 | .name = DA9063_DRVNAME_REGULATORS, | ||
81 | .num_resources = ARRAY_SIZE(da9063_regulators_resources), | ||
82 | .resources = da9063_regulators_resources, | ||
83 | }, | ||
84 | { | ||
85 | .name = DA9063_DRVNAME_LEDS, | ||
86 | }, | ||
87 | { | ||
88 | .name = DA9063_DRVNAME_WATCHDOG, | ||
89 | }, | ||
90 | { | ||
91 | .name = DA9063_DRVNAME_HWMON, | ||
92 | .num_resources = ARRAY_SIZE(da9063_hwmon_resources), | ||
93 | .resources = da9063_hwmon_resources, | ||
94 | }, | ||
95 | { | ||
96 | .name = DA9063_DRVNAME_ONKEY, | ||
97 | .num_resources = ARRAY_SIZE(da9063_onkey_resources), | ||
98 | .resources = da9063_onkey_resources, | ||
99 | }, | ||
100 | { | ||
101 | .name = DA9063_DRVNAME_RTC, | ||
102 | .num_resources = ARRAY_SIZE(da9063_rtc_resources), | ||
103 | .resources = da9063_rtc_resources, | ||
104 | }, | ||
105 | { | ||
106 | .name = DA9063_DRVNAME_VIBRATION, | ||
107 | }, | ||
108 | }; | ||
109 | |||
110 | int da9063_device_init(struct da9063 *da9063, unsigned int irq) | ||
111 | { | ||
112 | struct da9063_pdata *pdata = da9063->dev->platform_data; | ||
113 | int model, revision; | ||
114 | int ret; | ||
115 | |||
116 | if (pdata) { | ||
117 | da9063->flags = pdata->flags; | ||
118 | da9063->irq_base = pdata->irq_base; | ||
119 | } else { | ||
120 | da9063->flags = 0; | ||
121 | da9063->irq_base = 0; | ||
122 | } | ||
123 | da9063->chip_irq = irq; | ||
124 | |||
125 | if (pdata && pdata->init != NULL) { | ||
126 | ret = pdata->init(da9063); | ||
127 | if (ret != 0) { | ||
128 | dev_err(da9063->dev, | ||
129 | "Platform initialization failed.\n"); | ||
130 | return ret; | ||
131 | } | ||
132 | } | ||
133 | |||
134 | ret = regmap_read(da9063->regmap, DA9063_REG_CHIP_ID, &model); | ||
135 | if (ret < 0) { | ||
136 | dev_err(da9063->dev, "Cannot read chip model id.\n"); | ||
137 | return -EIO; | ||
138 | } | ||
139 | if (model != PMIC_DA9063) { | ||
140 | dev_err(da9063->dev, "Invalid chip model id: 0x%02x\n", model); | ||
141 | return -ENODEV; | ||
142 | } | ||
143 | |||
144 | ret = regmap_read(da9063->regmap, DA9063_REG_CHIP_VARIANT, &revision); | ||
145 | if (ret < 0) { | ||
146 | dev_err(da9063->dev, "Cannot read chip revision id.\n"); | ||
147 | return -EIO; | ||
148 | } | ||
149 | revision >>= DA9063_CHIP_VARIANT_SHIFT; | ||
150 | if (revision != 3) { | ||
151 | dev_err(da9063->dev, "Unknown chip revision: %d\n", revision); | ||
152 | return -ENODEV; | ||
153 | } | ||
154 | |||
155 | da9063->model = model; | ||
156 | da9063->revision = revision; | ||
157 | |||
158 | dev_info(da9063->dev, | ||
159 | "Device detected (model-ID: 0x%02X rev-ID: 0x%02X)\n", | ||
160 | model, revision); | ||
161 | |||
162 | ret = da9063_irq_init(da9063); | ||
163 | if (ret) { | ||
164 | dev_err(da9063->dev, "Cannot initialize interrupts.\n"); | ||
165 | return ret; | ||
166 | } | ||
167 | |||
168 | ret = mfd_add_devices(da9063->dev, -1, da9063_devs, | ||
169 | ARRAY_SIZE(da9063_devs), NULL, da9063->irq_base, | ||
170 | NULL); | ||
171 | if (ret) | ||
172 | dev_err(da9063->dev, "Cannot add MFD cells\n"); | ||
173 | |||
174 | return ret; | ||
175 | } | ||
176 | |||
177 | void da9063_device_exit(struct da9063 *da9063) | ||
178 | { | ||
179 | mfd_remove_devices(da9063->dev); | ||
180 | da9063_irq_exit(da9063); | ||
181 | } | ||
182 | |||
183 | MODULE_DESCRIPTION("PMIC driver for Dialog DA9063"); | ||
184 | MODULE_AUTHOR("Krystian Garbaciak <krystian.garbaciak@diasemi.com>, Michal Hajduk <michal.hajduk@diasemi.com>"); | ||
185 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/mfd/da9063-i2c.c b/drivers/mfd/da9063-i2c.c new file mode 100644 index 000000000000..8db5c805c64f --- /dev/null +++ b/drivers/mfd/da9063-i2c.c | |||
@@ -0,0 +1,182 @@ | |||
1 | /* da9063-i2c.c: Interrupt support for Dialog DA9063 | ||
2 | * | ||
3 | * Copyright 2012 Dialog Semiconductor Ltd. | ||
4 | * Copyright 2013 Philipp Zabel, Pengutronix | ||
5 | * | ||
6 | * Author: Krystian Garbaciak <krystian.garbaciak@diasemi.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License as published by the | ||
10 | * Free Software Foundation; either version 2 of the License, or (at your | ||
11 | * option) any later version. | ||
12 | * | ||
13 | */ | ||
14 | |||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/module.h> | ||
17 | #include <linux/i2c.h> | ||
18 | #include <linux/regmap.h> | ||
19 | #include <linux/delay.h> | ||
20 | #include <linux/slab.h> | ||
21 | #include <linux/err.h> | ||
22 | |||
23 | #include <linux/mfd/core.h> | ||
24 | #include <linux/mfd/da9063/core.h> | ||
25 | #include <linux/mfd/da9063/pdata.h> | ||
26 | #include <linux/mfd/da9063/registers.h> | ||
27 | |||
28 | static const struct regmap_range da9063_readable_ranges[] = { | ||
29 | { | ||
30 | .range_min = DA9063_REG_PAGE_CON, | ||
31 | .range_max = DA9063_REG_SECOND_D, | ||
32 | }, { | ||
33 | .range_min = DA9063_REG_SEQ, | ||
34 | .range_max = DA9063_REG_ID_32_31, | ||
35 | }, { | ||
36 | .range_min = DA9063_REG_SEQ_A, | ||
37 | .range_max = DA9063_REG_AUTO3_LOW, | ||
38 | }, { | ||
39 | .range_min = DA9063_REG_T_OFFSET, | ||
40 | .range_max = DA9063_REG_GP_ID_19, | ||
41 | }, { | ||
42 | .range_min = DA9063_REG_CHIP_ID, | ||
43 | .range_max = DA9063_REG_CHIP_VARIANT, | ||
44 | }, | ||
45 | }; | ||
46 | |||
47 | static const struct regmap_range da9063_writeable_ranges[] = { | ||
48 | { | ||
49 | .range_min = DA9063_REG_PAGE_CON, | ||
50 | .range_max = DA9063_REG_PAGE_CON, | ||
51 | }, { | ||
52 | .range_min = DA9063_REG_FAULT_LOG, | ||
53 | .range_max = DA9063_REG_VSYS_MON, | ||
54 | }, { | ||
55 | .range_min = DA9063_REG_COUNT_S, | ||
56 | .range_max = DA9063_REG_ALARM_Y, | ||
57 | }, { | ||
58 | .range_min = DA9063_REG_SEQ, | ||
59 | .range_max = DA9063_REG_ID_32_31, | ||
60 | }, { | ||
61 | .range_min = DA9063_REG_SEQ_A, | ||
62 | .range_max = DA9063_REG_AUTO3_LOW, | ||
63 | }, { | ||
64 | .range_min = DA9063_REG_CONFIG_I, | ||
65 | .range_max = DA9063_REG_MON_REG_4, | ||
66 | }, { | ||
67 | .range_min = DA9063_REG_GP_ID_0, | ||
68 | .range_max = DA9063_REG_GP_ID_19, | ||
69 | }, | ||
70 | }; | ||
71 | |||
72 | static const struct regmap_range da9063_volatile_ranges[] = { | ||
73 | { | ||
74 | .range_min = DA9063_REG_STATUS_A, | ||
75 | .range_max = DA9063_REG_EVENT_D, | ||
76 | }, { | ||
77 | .range_min = DA9063_REG_CONTROL_F, | ||
78 | .range_max = DA9063_REG_CONTROL_F, | ||
79 | }, { | ||
80 | .range_min = DA9063_REG_ADC_MAN, | ||
81 | .range_max = DA9063_REG_ADC_MAN, | ||
82 | }, { | ||
83 | .range_min = DA9063_REG_ADC_RES_L, | ||
84 | .range_max = DA9063_REG_SECOND_D, | ||
85 | }, { | ||
86 | .range_min = DA9063_REG_MON_REG_5, | ||
87 | .range_max = DA9063_REG_MON_REG_6, | ||
88 | }, | ||
89 | }; | ||
90 | |||
91 | static const struct regmap_access_table da9063_readable_table = { | ||
92 | .yes_ranges = da9063_readable_ranges, | ||
93 | .n_yes_ranges = ARRAY_SIZE(da9063_readable_ranges), | ||
94 | }; | ||
95 | |||
96 | static const struct regmap_access_table da9063_writeable_table = { | ||
97 | .yes_ranges = da9063_writeable_ranges, | ||
98 | .n_yes_ranges = ARRAY_SIZE(da9063_writeable_ranges), | ||
99 | }; | ||
100 | |||
101 | static const struct regmap_access_table da9063_volatile_table = { | ||
102 | .yes_ranges = da9063_volatile_ranges, | ||
103 | .n_yes_ranges = ARRAY_SIZE(da9063_volatile_ranges), | ||
104 | }; | ||
105 | |||
106 | static const struct regmap_range_cfg da9063_range_cfg[] = { | ||
107 | { | ||
108 | .range_min = DA9063_REG_PAGE_CON, | ||
109 | .range_max = DA9063_REG_CHIP_VARIANT, | ||
110 | .selector_reg = DA9063_REG_PAGE_CON, | ||
111 | .selector_mask = 1 << DA9063_I2C_PAGE_SEL_SHIFT, | ||
112 | .selector_shift = DA9063_I2C_PAGE_SEL_SHIFT, | ||
113 | .window_start = 0, | ||
114 | .window_len = 256, | ||
115 | } | ||
116 | }; | ||
117 | |||
118 | static struct regmap_config da9063_regmap_config = { | ||
119 | .reg_bits = 8, | ||
120 | .val_bits = 8, | ||
121 | .ranges = da9063_range_cfg, | ||
122 | .num_ranges = ARRAY_SIZE(da9063_range_cfg), | ||
123 | .max_register = DA9063_REG_CHIP_VARIANT, | ||
124 | |||
125 | .cache_type = REGCACHE_RBTREE, | ||
126 | |||
127 | .rd_table = &da9063_readable_table, | ||
128 | .wr_table = &da9063_writeable_table, | ||
129 | .volatile_table = &da9063_volatile_table, | ||
130 | }; | ||
131 | |||
132 | static int da9063_i2c_probe(struct i2c_client *i2c, | ||
133 | const struct i2c_device_id *id) | ||
134 | { | ||
135 | struct da9063 *da9063; | ||
136 | int ret; | ||
137 | |||
138 | da9063 = devm_kzalloc(&i2c->dev, sizeof(struct da9063), GFP_KERNEL); | ||
139 | if (da9063 == NULL) | ||
140 | return -ENOMEM; | ||
141 | |||
142 | i2c_set_clientdata(i2c, da9063); | ||
143 | da9063->dev = &i2c->dev; | ||
144 | da9063->chip_irq = i2c->irq; | ||
145 | |||
146 | da9063->regmap = devm_regmap_init_i2c(i2c, &da9063_regmap_config); | ||
147 | if (IS_ERR(da9063->regmap)) { | ||
148 | ret = PTR_ERR(da9063->regmap); | ||
149 | dev_err(da9063->dev, "Failed to allocate register map: %d\n", | ||
150 | ret); | ||
151 | return ret; | ||
152 | } | ||
153 | |||
154 | return da9063_device_init(da9063, i2c->irq); | ||
155 | } | ||
156 | |||
157 | static int da9063_i2c_remove(struct i2c_client *i2c) | ||
158 | { | ||
159 | struct da9063 *da9063 = i2c_get_clientdata(i2c); | ||
160 | |||
161 | da9063_device_exit(da9063); | ||
162 | |||
163 | return 0; | ||
164 | } | ||
165 | |||
166 | static const struct i2c_device_id da9063_i2c_id[] = { | ||
167 | {"da9063", PMIC_DA9063}, | ||
168 | {}, | ||
169 | }; | ||
170 | MODULE_DEVICE_TABLE(i2c, da9063_i2c_id); | ||
171 | |||
172 | static struct i2c_driver da9063_i2c_driver = { | ||
173 | .driver = { | ||
174 | .name = "da9063", | ||
175 | .owner = THIS_MODULE, | ||
176 | }, | ||
177 | .probe = da9063_i2c_probe, | ||
178 | .remove = da9063_i2c_remove, | ||
179 | .id_table = da9063_i2c_id, | ||
180 | }; | ||
181 | |||
182 | module_i2c_driver(da9063_i2c_driver); | ||
diff --git a/drivers/mfd/da9063-irq.c b/drivers/mfd/da9063-irq.c new file mode 100644 index 000000000000..822922602ce9 --- /dev/null +++ b/drivers/mfd/da9063-irq.c | |||
@@ -0,0 +1,193 @@ | |||
1 | /* da9063-irq.c: Interrupts support for Dialog DA9063 | ||
2 | * | ||
3 | * Copyright 2012 Dialog Semiconductor Ltd. | ||
4 | * Copyright 2013 Philipp Zabel, Pengutronix | ||
5 | * | ||
6 | * Author: Michal Hajduk <michal.hajduk@diasemi.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License as published by the | ||
10 | * Free Software Foundation; either version 2 of the License, or (at your | ||
11 | * option) any later version. | ||
12 | * | ||
13 | */ | ||
14 | |||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/module.h> | ||
17 | #include <linux/irq.h> | ||
18 | #include <linux/mfd/core.h> | ||
19 | #include <linux/interrupt.h> | ||
20 | #include <linux/regmap.h> | ||
21 | #include <linux/mfd/da9063/core.h> | ||
22 | #include <linux/mfd/da9063/pdata.h> | ||
23 | |||
24 | #define DA9063_REG_EVENT_A_OFFSET 0 | ||
25 | #define DA9063_REG_EVENT_B_OFFSET 1 | ||
26 | #define DA9063_REG_EVENT_C_OFFSET 2 | ||
27 | #define DA9063_REG_EVENT_D_OFFSET 3 | ||
28 | #define EVENTS_BUF_LEN 4 | ||
29 | |||
30 | static const u8 mask_events_buf[] = { [0 ... (EVENTS_BUF_LEN - 1)] = ~0 }; | ||
31 | |||
32 | struct da9063_irq_data { | ||
33 | u16 reg; | ||
34 | u8 mask; | ||
35 | }; | ||
36 | |||
37 | static struct regmap_irq da9063_irqs[] = { | ||
38 | /* DA9063 event A register */ | ||
39 | [DA9063_IRQ_ONKEY] = { | ||
40 | .reg_offset = DA9063_REG_EVENT_A_OFFSET, | ||
41 | .mask = DA9063_M_ONKEY, | ||
42 | }, | ||
43 | [DA9063_IRQ_ALARM] = { | ||
44 | .reg_offset = DA9063_REG_EVENT_A_OFFSET, | ||
45 | .mask = DA9063_M_ALARM, | ||
46 | }, | ||
47 | [DA9063_IRQ_TICK] = { | ||
48 | .reg_offset = DA9063_REG_EVENT_A_OFFSET, | ||
49 | .mask = DA9063_M_TICK, | ||
50 | }, | ||
51 | [DA9063_IRQ_ADC_RDY] = { | ||
52 | .reg_offset = DA9063_REG_EVENT_A_OFFSET, | ||
53 | .mask = DA9063_M_ADC_RDY, | ||
54 | }, | ||
55 | [DA9063_IRQ_SEQ_RDY] = { | ||
56 | .reg_offset = DA9063_REG_EVENT_A_OFFSET, | ||
57 | .mask = DA9063_M_SEQ_RDY, | ||
58 | }, | ||
59 | /* DA9063 event B register */ | ||
60 | [DA9063_IRQ_WAKE] = { | ||
61 | .reg_offset = DA9063_REG_EVENT_B_OFFSET, | ||
62 | .mask = DA9063_M_WAKE, | ||
63 | }, | ||
64 | [DA9063_IRQ_TEMP] = { | ||
65 | .reg_offset = DA9063_REG_EVENT_B_OFFSET, | ||
66 | .mask = DA9063_M_TEMP, | ||
67 | }, | ||
68 | [DA9063_IRQ_COMP_1V2] = { | ||
69 | .reg_offset = DA9063_REG_EVENT_B_OFFSET, | ||
70 | .mask = DA9063_M_COMP_1V2, | ||
71 | }, | ||
72 | [DA9063_IRQ_LDO_LIM] = { | ||
73 | .reg_offset = DA9063_REG_EVENT_B_OFFSET, | ||
74 | .mask = DA9063_M_LDO_LIM, | ||
75 | }, | ||
76 | [DA9063_IRQ_REG_UVOV] = { | ||
77 | .reg_offset = DA9063_REG_EVENT_B_OFFSET, | ||
78 | .mask = DA9063_M_UVOV, | ||
79 | }, | ||
80 | [DA9063_IRQ_VDD_MON] = { | ||
81 | .reg_offset = DA9063_REG_EVENT_B_OFFSET, | ||
82 | .mask = DA9063_M_VDD_MON, | ||
83 | }, | ||
84 | [DA9063_IRQ_WARN] = { | ||
85 | .reg_offset = DA9063_REG_EVENT_B_OFFSET, | ||
86 | .mask = DA9063_M_VDD_WARN, | ||
87 | }, | ||
88 | /* DA9063 event C register */ | ||
89 | [DA9063_IRQ_GPI0] = { | ||
90 | .reg_offset = DA9063_REG_EVENT_C_OFFSET, | ||
91 | .mask = DA9063_M_GPI0, | ||
92 | }, | ||
93 | [DA9063_IRQ_GPI1] = { | ||
94 | .reg_offset = DA9063_REG_EVENT_C_OFFSET, | ||
95 | .mask = DA9063_M_GPI1, | ||
96 | }, | ||
97 | [DA9063_IRQ_GPI2] = { | ||
98 | .reg_offset = DA9063_REG_EVENT_C_OFFSET, | ||
99 | .mask = DA9063_M_GPI2, | ||
100 | }, | ||
101 | [DA9063_IRQ_GPI3] = { | ||
102 | .reg_offset = DA9063_REG_EVENT_C_OFFSET, | ||
103 | .mask = DA9063_M_GPI3, | ||
104 | }, | ||
105 | [DA9063_IRQ_GPI4] = { | ||
106 | .reg_offset = DA9063_REG_EVENT_C_OFFSET, | ||
107 | .mask = DA9063_M_GPI4, | ||
108 | }, | ||
109 | [DA9063_IRQ_GPI5] = { | ||
110 | .reg_offset = DA9063_REG_EVENT_C_OFFSET, | ||
111 | .mask = DA9063_M_GPI5, | ||
112 | }, | ||
113 | [DA9063_IRQ_GPI6] = { | ||
114 | .reg_offset = DA9063_REG_EVENT_C_OFFSET, | ||
115 | .mask = DA9063_M_GPI6, | ||
116 | }, | ||
117 | [DA9063_IRQ_GPI7] = { | ||
118 | .reg_offset = DA9063_REG_EVENT_C_OFFSET, | ||
119 | .mask = DA9063_M_GPI7, | ||
120 | }, | ||
121 | /* DA9063 event D register */ | ||
122 | [DA9063_IRQ_GPI8] = { | ||
123 | .reg_offset = DA9063_REG_EVENT_D_OFFSET, | ||
124 | .mask = DA9063_M_GPI8, | ||
125 | }, | ||
126 | [DA9063_IRQ_GPI9] = { | ||
127 | .reg_offset = DA9063_REG_EVENT_D_OFFSET, | ||
128 | .mask = DA9063_M_GPI9, | ||
129 | }, | ||
130 | [DA9063_IRQ_GPI10] = { | ||
131 | .reg_offset = DA9063_REG_EVENT_D_OFFSET, | ||
132 | .mask = DA9063_M_GPI10, | ||
133 | }, | ||
134 | [DA9063_IRQ_GPI11] = { | ||
135 | .reg_offset = DA9063_REG_EVENT_D_OFFSET, | ||
136 | .mask = DA9063_M_GPI11, | ||
137 | }, | ||
138 | [DA9063_IRQ_GPI12] = { | ||
139 | .reg_offset = DA9063_REG_EVENT_D_OFFSET, | ||
140 | .mask = DA9063_M_GPI12, | ||
141 | }, | ||
142 | [DA9063_IRQ_GPI13] = { | ||
143 | .reg_offset = DA9063_REG_EVENT_D_OFFSET, | ||
144 | .mask = DA9063_M_GPI13, | ||
145 | }, | ||
146 | [DA9063_IRQ_GPI14] = { | ||
147 | .reg_offset = DA9063_REG_EVENT_D_OFFSET, | ||
148 | .mask = DA9063_M_GPI14, | ||
149 | }, | ||
150 | [DA9063_IRQ_GPI15] = { | ||
151 | .reg_offset = DA9063_REG_EVENT_D_OFFSET, | ||
152 | .mask = DA9063_M_GPI15, | ||
153 | }, | ||
154 | }; | ||
155 | |||
156 | static struct regmap_irq_chip da9063_irq_chip = { | ||
157 | .name = "da9063-irq", | ||
158 | .irqs = da9063_irqs, | ||
159 | .num_irqs = DA9063_NUM_IRQ, | ||
160 | |||
161 | .num_regs = 4, | ||
162 | .status_base = DA9063_REG_EVENT_A, | ||
163 | .mask_base = DA9063_REG_IRQ_MASK_A, | ||
164 | .ack_base = DA9063_REG_EVENT_A, | ||
165 | .init_ack_masked = true, | ||
166 | }; | ||
167 | |||
168 | int da9063_irq_init(struct da9063 *da9063) | ||
169 | { | ||
170 | int ret; | ||
171 | |||
172 | if (!da9063->chip_irq) { | ||
173 | dev_err(da9063->dev, "No IRQ configured\n"); | ||
174 | return -EINVAL; | ||
175 | } | ||
176 | |||
177 | ret = regmap_add_irq_chip(da9063->regmap, da9063->chip_irq, | ||
178 | IRQF_TRIGGER_LOW | IRQF_ONESHOT | IRQF_SHARED, | ||
179 | da9063->irq_base, &da9063_irq_chip, | ||
180 | &da9063->regmap_irq); | ||
181 | if (ret) { | ||
182 | dev_err(da9063->dev, "Failed to reguest IRQ %d: %d\n", | ||
183 | da9063->chip_irq, ret); | ||
184 | return ret; | ||
185 | } | ||
186 | |||
187 | return 0; | ||
188 | } | ||
189 | |||
190 | void da9063_irq_exit(struct da9063 *da9063) | ||
191 | { | ||
192 | regmap_del_irq_chip(da9063->chip_irq, da9063->regmap_irq); | ||
193 | } | ||
diff --git a/drivers/mfd/davinci_voicecodec.c b/drivers/mfd/davinci_voicecodec.c index fb64398506e9..013ba8159dcd 100644 --- a/drivers/mfd/davinci_voicecodec.c +++ b/drivers/mfd/davinci_voicecodec.c | |||
@@ -27,21 +27,16 @@ | |||
27 | #include <linux/delay.h> | 27 | #include <linux/delay.h> |
28 | #include <linux/io.h> | 28 | #include <linux/io.h> |
29 | #include <linux/clk.h> | 29 | #include <linux/clk.h> |
30 | #include <linux/regmap.h> | ||
30 | 31 | ||
31 | #include <sound/pcm.h> | 32 | #include <sound/pcm.h> |
32 | 33 | ||
33 | #include <linux/mfd/davinci_voicecodec.h> | 34 | #include <linux/mfd/davinci_voicecodec.h> |
34 | 35 | ||
35 | u32 davinci_vc_read(struct davinci_vc *davinci_vc, int reg) | 36 | static struct regmap_config davinci_vc_regmap = { |
36 | { | 37 | .reg_bits = 32, |
37 | return __raw_readl(davinci_vc->base + reg); | 38 | .val_bits = 32, |
38 | } | 39 | }; |
39 | |||
40 | void davinci_vc_write(struct davinci_vc *davinci_vc, | ||
41 | int reg, u32 val) | ||
42 | { | ||
43 | __raw_writel(val, davinci_vc->base + reg); | ||
44 | } | ||
45 | 40 | ||
46 | static int __init davinci_vc_probe(struct platform_device *pdev) | 41 | static int __init davinci_vc_probe(struct platform_device *pdev) |
47 | { | 42 | { |
@@ -74,6 +69,14 @@ static int __init davinci_vc_probe(struct platform_device *pdev) | |||
74 | goto fail; | 69 | goto fail; |
75 | } | 70 | } |
76 | 71 | ||
72 | davinci_vc->regmap = devm_regmap_init_mmio(&pdev->dev, | ||
73 | davinci_vc->base, | ||
74 | &davinci_vc_regmap); | ||
75 | if (IS_ERR(davinci_vc->regmap)) { | ||
76 | ret = PTR_ERR(davinci_vc->regmap); | ||
77 | goto fail; | ||
78 | } | ||
79 | |||
77 | res = platform_get_resource(pdev, IORESOURCE_DMA, 0); | 80 | res = platform_get_resource(pdev, IORESOURCE_DMA, 0); |
78 | if (!res) { | 81 | if (!res) { |
79 | dev_err(&pdev->dev, "no DMA resource\n"); | 82 | dev_err(&pdev->dev, "no DMA resource\n"); |
diff --git a/drivers/mfd/db8500-prcmu.c b/drivers/mfd/db8500-prcmu.c index 0d68eb1a5ec5..53f371dcbb6e 100644 --- a/drivers/mfd/db8500-prcmu.c +++ b/drivers/mfd/db8500-prcmu.c | |||
@@ -465,7 +465,7 @@ static DEFINE_SPINLOCK(clk_mgt_lock); | |||
465 | 465 | ||
466 | #define CLK_MGT_ENTRY(_name, _branch, _clk38div)[PRCMU_##_name] = \ | 466 | #define CLK_MGT_ENTRY(_name, _branch, _clk38div)[PRCMU_##_name] = \ |
467 | { (PRCM_##_name##_MGT), 0 , _branch, _clk38div} | 467 | { (PRCM_##_name##_MGT), 0 , _branch, _clk38div} |
468 | struct clk_mgt clk_mgt[PRCMU_NUM_REG_CLOCKS] = { | 468 | static struct clk_mgt clk_mgt[PRCMU_NUM_REG_CLOCKS] = { |
469 | CLK_MGT_ENTRY(SGACLK, PLL_DIV, false), | 469 | CLK_MGT_ENTRY(SGACLK, PLL_DIV, false), |
470 | CLK_MGT_ENTRY(UARTCLK, PLL_FIX, true), | 470 | CLK_MGT_ENTRY(UARTCLK, PLL_FIX, true), |
471 | CLK_MGT_ENTRY(MSP02CLK, PLL_FIX, true), | 471 | CLK_MGT_ENTRY(MSP02CLK, PLL_FIX, true), |
@@ -2319,7 +2319,7 @@ unlock_and_return: | |||
2319 | /** | 2319 | /** |
2320 | * prcmu_ac_sleep_req - called when ARM no longer needs to talk to modem | 2320 | * prcmu_ac_sleep_req - called when ARM no longer needs to talk to modem |
2321 | */ | 2321 | */ |
2322 | void prcmu_ac_sleep_req() | 2322 | void prcmu_ac_sleep_req(void) |
2323 | { | 2323 | { |
2324 | u32 val; | 2324 | u32 val; |
2325 | 2325 | ||
diff --git a/drivers/mfd/dm355evm_msp.c b/drivers/mfd/dm355evm_msp.c index 7710227d284e..7a55c0071fa8 100644 --- a/drivers/mfd/dm355evm_msp.c +++ b/drivers/mfd/dm355evm_msp.c | |||
@@ -315,8 +315,8 @@ static int add_children(struct i2c_client *client) | |||
315 | } | 315 | } |
316 | 316 | ||
317 | /* MMC/SD inputs -- right after the last config input */ | 317 | /* MMC/SD inputs -- right after the last config input */ |
318 | if (client->dev.platform_data) { | 318 | if (dev_get_platdata(&client->dev)) { |
319 | void (*mmcsd_setup)(unsigned) = client->dev.platform_data; | 319 | void (*mmcsd_setup)(unsigned) = dev_get_platdata(&client->dev); |
320 | 320 | ||
321 | mmcsd_setup(dm355evm_msp_gpio.base + 8 + 5); | 321 | mmcsd_setup(dm355evm_msp_gpio.base + 8 + 5); |
322 | } | 322 | } |
diff --git a/drivers/mfd/ezx-pcap.c b/drivers/mfd/ezx-pcap.c index 5502106ad515..7245b0c5b794 100644 --- a/drivers/mfd/ezx-pcap.c +++ b/drivers/mfd/ezx-pcap.c | |||
@@ -177,7 +177,7 @@ static void pcap_msr_work(struct work_struct *work) | |||
177 | static void pcap_isr_work(struct work_struct *work) | 177 | static void pcap_isr_work(struct work_struct *work) |
178 | { | 178 | { |
179 | struct pcap_chip *pcap = container_of(work, struct pcap_chip, isr_work); | 179 | struct pcap_chip *pcap = container_of(work, struct pcap_chip, isr_work); |
180 | struct pcap_platform_data *pdata = pcap->spi->dev.platform_data; | 180 | struct pcap_platform_data *pdata = dev_get_platdata(&pcap->spi->dev); |
181 | u32 msr, isr, int_sel, service; | 181 | u32 msr, isr, int_sel, service; |
182 | int irq; | 182 | int irq; |
183 | 183 | ||
@@ -394,7 +394,7 @@ static int pcap_add_subdev(struct pcap_chip *pcap, | |||
394 | static int ezx_pcap_remove(struct spi_device *spi) | 394 | static int ezx_pcap_remove(struct spi_device *spi) |
395 | { | 395 | { |
396 | struct pcap_chip *pcap = spi_get_drvdata(spi); | 396 | struct pcap_chip *pcap = spi_get_drvdata(spi); |
397 | struct pcap_platform_data *pdata = spi->dev.platform_data; | 397 | struct pcap_platform_data *pdata = dev_get_platdata(&spi->dev); |
398 | int i, adc_irq; | 398 | int i, adc_irq; |
399 | 399 | ||
400 | /* remove all registered subdevs */ | 400 | /* remove all registered subdevs */ |
@@ -420,7 +420,7 @@ static int ezx_pcap_remove(struct spi_device *spi) | |||
420 | 420 | ||
421 | static int ezx_pcap_probe(struct spi_device *spi) | 421 | static int ezx_pcap_probe(struct spi_device *spi) |
422 | { | 422 | { |
423 | struct pcap_platform_data *pdata = spi->dev.platform_data; | 423 | struct pcap_platform_data *pdata = dev_get_platdata(&spi->dev); |
424 | struct pcap_chip *pcap; | 424 | struct pcap_chip *pcap; |
425 | int i, adc_irq; | 425 | int i, adc_irq; |
426 | int ret = -ENODEV; | 426 | int ret = -ENODEV; |
diff --git a/drivers/mfd/htc-egpio.c b/drivers/mfd/htc-egpio.c index 26aca545084b..49f39feca784 100644 --- a/drivers/mfd/htc-egpio.c +++ b/drivers/mfd/htc-egpio.c | |||
@@ -261,7 +261,7 @@ static void egpio_write_cache(struct egpio_info *ei) | |||
261 | 261 | ||
262 | static int __init egpio_probe(struct platform_device *pdev) | 262 | static int __init egpio_probe(struct platform_device *pdev) |
263 | { | 263 | { |
264 | struct htc_egpio_platform_data *pdata = pdev->dev.platform_data; | 264 | struct htc_egpio_platform_data *pdata = dev_get_platdata(&pdev->dev); |
265 | struct resource *res; | 265 | struct resource *res; |
266 | struct egpio_info *ei; | 266 | struct egpio_info *ei; |
267 | struct gpio_chip *chip; | 267 | struct gpio_chip *chip; |
diff --git a/drivers/mfd/htc-i2cpld.c b/drivers/mfd/htc-i2cpld.c index c9dfce6ae0c2..d7b2a75aca3e 100644 --- a/drivers/mfd/htc-i2cpld.c +++ b/drivers/mfd/htc-i2cpld.c | |||
@@ -340,7 +340,7 @@ static int htcpld_setup_chip_irq( | |||
340 | int ret = 0; | 340 | int ret = 0; |
341 | 341 | ||
342 | /* Get the platform and driver data */ | 342 | /* Get the platform and driver data */ |
343 | pdata = dev->platform_data; | 343 | pdata = dev_get_platdata(dev); |
344 | htcpld = platform_get_drvdata(pdev); | 344 | htcpld = platform_get_drvdata(pdev); |
345 | chip = &htcpld->chip[chip_index]; | 345 | chip = &htcpld->chip[chip_index]; |
346 | plat_chip_data = &pdata->chip[chip_index]; | 346 | plat_chip_data = &pdata->chip[chip_index]; |
@@ -375,7 +375,7 @@ static int htcpld_register_chip_i2c( | |||
375 | struct i2c_board_info info; | 375 | struct i2c_board_info info; |
376 | 376 | ||
377 | /* Get the platform and driver data */ | 377 | /* Get the platform and driver data */ |
378 | pdata = dev->platform_data; | 378 | pdata = dev_get_platdata(dev); |
379 | htcpld = platform_get_drvdata(pdev); | 379 | htcpld = platform_get_drvdata(pdev); |
380 | chip = &htcpld->chip[chip_index]; | 380 | chip = &htcpld->chip[chip_index]; |
381 | plat_chip_data = &pdata->chip[chip_index]; | 381 | plat_chip_data = &pdata->chip[chip_index]; |
@@ -447,7 +447,7 @@ static int htcpld_register_chip_gpio( | |||
447 | int ret = 0; | 447 | int ret = 0; |
448 | 448 | ||
449 | /* Get the platform and driver data */ | 449 | /* Get the platform and driver data */ |
450 | pdata = dev->platform_data; | 450 | pdata = dev_get_platdata(dev); |
451 | htcpld = platform_get_drvdata(pdev); | 451 | htcpld = platform_get_drvdata(pdev); |
452 | chip = &htcpld->chip[chip_index]; | 452 | chip = &htcpld->chip[chip_index]; |
453 | plat_chip_data = &pdata->chip[chip_index]; | 453 | plat_chip_data = &pdata->chip[chip_index]; |
@@ -509,7 +509,7 @@ static int htcpld_setup_chips(struct platform_device *pdev) | |||
509 | int i; | 509 | int i; |
510 | 510 | ||
511 | /* Get the platform and driver data */ | 511 | /* Get the platform and driver data */ |
512 | pdata = dev->platform_data; | 512 | pdata = dev_get_platdata(dev); |
513 | htcpld = platform_get_drvdata(pdev); | 513 | htcpld = platform_get_drvdata(pdev); |
514 | 514 | ||
515 | /* Setup each chip's output GPIOs */ | 515 | /* Setup each chip's output GPIOs */ |
@@ -574,7 +574,7 @@ static int htcpld_core_probe(struct platform_device *pdev) | |||
574 | if (!dev) | 574 | if (!dev) |
575 | return -ENODEV; | 575 | return -ENODEV; |
576 | 576 | ||
577 | pdata = dev->platform_data; | 577 | pdata = dev_get_platdata(dev); |
578 | if (!pdata) { | 578 | if (!pdata) { |
579 | dev_warn(dev, "Platform data not found for htcpld core!\n"); | 579 | dev_warn(dev, "Platform data not found for htcpld core!\n"); |
580 | return -ENXIO; | 580 | return -ENXIO; |
diff --git a/drivers/mfd/htc-pasic3.c b/drivers/mfd/htc-pasic3.c index 0a5e85fd8517..6bf92a507b95 100644 --- a/drivers/mfd/htc-pasic3.c +++ b/drivers/mfd/htc-pasic3.c | |||
@@ -126,7 +126,7 @@ static struct mfd_cell ds1wm_cell __initdata = { | |||
126 | 126 | ||
127 | static int __init pasic3_probe(struct platform_device *pdev) | 127 | static int __init pasic3_probe(struct platform_device *pdev) |
128 | { | 128 | { |
129 | struct pasic3_platform_data *pdata = pdev->dev.platform_data; | 129 | struct pasic3_platform_data *pdata = dev_get_platdata(&pdev->dev); |
130 | struct device *dev = &pdev->dev; | 130 | struct device *dev = &pdev->dev; |
131 | struct pasic3_data *asic; | 131 | struct pasic3_data *asic; |
132 | struct resource *r; | 132 | struct resource *r; |
diff --git a/drivers/mfd/intel_msic.c b/drivers/mfd/intel_msic.c index 4f2462f0963e..9203d47cdbb1 100644 --- a/drivers/mfd/intel_msic.c +++ b/drivers/mfd/intel_msic.c | |||
@@ -310,7 +310,7 @@ EXPORT_SYMBOL_GPL(intel_msic_irq_read); | |||
310 | static int intel_msic_init_devices(struct intel_msic *msic) | 310 | static int intel_msic_init_devices(struct intel_msic *msic) |
311 | { | 311 | { |
312 | struct platform_device *pdev = msic->pdev; | 312 | struct platform_device *pdev = msic->pdev; |
313 | struct intel_msic_platform_data *pdata = pdev->dev.platform_data; | 313 | struct intel_msic_platform_data *pdata = dev_get_platdata(&pdev->dev); |
314 | int ret, i; | 314 | int ret, i; |
315 | 315 | ||
316 | if (pdata->gpio) { | 316 | if (pdata->gpio) { |
@@ -372,7 +372,7 @@ static void intel_msic_remove_devices(struct intel_msic *msic) | |||
372 | 372 | ||
373 | static int intel_msic_probe(struct platform_device *pdev) | 373 | static int intel_msic_probe(struct platform_device *pdev) |
374 | { | 374 | { |
375 | struct intel_msic_platform_data *pdata = pdev->dev.platform_data; | 375 | struct intel_msic_platform_data *pdata = dev_get_platdata(&pdev->dev); |
376 | struct intel_msic *msic; | 376 | struct intel_msic *msic; |
377 | struct resource *res; | 377 | struct resource *res; |
378 | u8 id0, id1; | 378 | u8 id0, id1; |
diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c index 686a4565acb6..d3e23278d299 100644 --- a/drivers/mfd/kempld-core.c +++ b/drivers/mfd/kempld-core.c | |||
@@ -258,7 +258,7 @@ EXPORT_SYMBOL_GPL(kempld_write32); | |||
258 | */ | 258 | */ |
259 | void kempld_get_mutex(struct kempld_device_data *pld) | 259 | void kempld_get_mutex(struct kempld_device_data *pld) |
260 | { | 260 | { |
261 | struct kempld_platform_data *pdata = pld->dev->platform_data; | 261 | struct kempld_platform_data *pdata = dev_get_platdata(pld->dev); |
262 | 262 | ||
263 | mutex_lock(&pld->lock); | 263 | mutex_lock(&pld->lock); |
264 | pdata->get_hardware_mutex(pld); | 264 | pdata->get_hardware_mutex(pld); |
@@ -271,7 +271,7 @@ EXPORT_SYMBOL_GPL(kempld_get_mutex); | |||
271 | */ | 271 | */ |
272 | void kempld_release_mutex(struct kempld_device_data *pld) | 272 | void kempld_release_mutex(struct kempld_device_data *pld) |
273 | { | 273 | { |
274 | struct kempld_platform_data *pdata = pld->dev->platform_data; | 274 | struct kempld_platform_data *pdata = dev_get_platdata(pld->dev); |
275 | 275 | ||
276 | pdata->release_hardware_mutex(pld); | 276 | pdata->release_hardware_mutex(pld); |
277 | mutex_unlock(&pld->lock); | 277 | mutex_unlock(&pld->lock); |
@@ -288,7 +288,7 @@ EXPORT_SYMBOL_GPL(kempld_release_mutex); | |||
288 | */ | 288 | */ |
289 | static int kempld_get_info(struct kempld_device_data *pld) | 289 | static int kempld_get_info(struct kempld_device_data *pld) |
290 | { | 290 | { |
291 | struct kempld_platform_data *pdata = pld->dev->platform_data; | 291 | struct kempld_platform_data *pdata = dev_get_platdata(pld->dev); |
292 | 292 | ||
293 | return pdata->get_info(pld); | 293 | return pdata->get_info(pld); |
294 | } | 294 | } |
@@ -302,7 +302,7 @@ static int kempld_get_info(struct kempld_device_data *pld) | |||
302 | */ | 302 | */ |
303 | static int kempld_register_cells(struct kempld_device_data *pld) | 303 | static int kempld_register_cells(struct kempld_device_data *pld) |
304 | { | 304 | { |
305 | struct kempld_platform_data *pdata = pld->dev->platform_data; | 305 | struct kempld_platform_data *pdata = dev_get_platdata(pld->dev); |
306 | 306 | ||
307 | return pdata->register_cells(pld); | 307 | return pdata->register_cells(pld); |
308 | } | 308 | } |
@@ -357,7 +357,7 @@ static int kempld_detect_device(struct kempld_device_data *pld) | |||
357 | 357 | ||
358 | static int kempld_probe(struct platform_device *pdev) | 358 | static int kempld_probe(struct platform_device *pdev) |
359 | { | 359 | { |
360 | struct kempld_platform_data *pdata = pdev->dev.platform_data; | 360 | struct kempld_platform_data *pdata = dev_get_platdata(&pdev->dev); |
361 | struct device *dev = &pdev->dev; | 361 | struct device *dev = &pdev->dev; |
362 | struct kempld_device_data *pld; | 362 | struct kempld_device_data *pld; |
363 | struct resource *ioport; | 363 | struct resource *ioport; |
@@ -394,7 +394,7 @@ static int kempld_probe(struct platform_device *pdev) | |||
394 | static int kempld_remove(struct platform_device *pdev) | 394 | static int kempld_remove(struct platform_device *pdev) |
395 | { | 395 | { |
396 | struct kempld_device_data *pld = platform_get_drvdata(pdev); | 396 | struct kempld_device_data *pld = platform_get_drvdata(pdev); |
397 | struct kempld_platform_data *pdata = pld->dev->platform_data; | 397 | struct kempld_platform_data *pdata = dev_get_platdata(pld->dev); |
398 | 398 | ||
399 | mfd_remove_devices(&pdev->dev); | 399 | mfd_remove_devices(&pdev->dev); |
400 | pdata->release_hardware_mutex(pld); | 400 | pdata->release_hardware_mutex(pld); |
@@ -413,6 +413,15 @@ static struct platform_driver kempld_driver = { | |||
413 | 413 | ||
414 | static struct dmi_system_id __initdata kempld_dmi_table[] = { | 414 | static struct dmi_system_id __initdata kempld_dmi_table[] = { |
415 | { | 415 | { |
416 | .ident = "BHL6", | ||
417 | .matches = { | ||
418 | DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"), | ||
419 | DMI_MATCH(DMI_BOARD_NAME, "COMe-bHL6"), | ||
420 | }, | ||
421 | .driver_data = (void *)&kempld_platform_data_generic, | ||
422 | .callback = kempld_create_platform_device, | ||
423 | }, | ||
424 | { | ||
416 | .ident = "CCR2", | 425 | .ident = "CCR2", |
417 | .matches = { | 426 | .matches = { |
418 | DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"), | 427 | DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"), |
@@ -596,6 +605,15 @@ static struct dmi_system_id __initdata kempld_dmi_table[] = { | |||
596 | .driver_data = (void *)&kempld_platform_data_generic, | 605 | .driver_data = (void *)&kempld_platform_data_generic, |
597 | .callback = kempld_create_platform_device, | 606 | .callback = kempld_create_platform_device, |
598 | }, | 607 | }, |
608 | { | ||
609 | .ident = "UTH6", | ||
610 | .matches = { | ||
611 | DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"), | ||
612 | DMI_MATCH(DMI_BOARD_NAME, "COMe-cTH6"), | ||
613 | }, | ||
614 | .driver_data = (void *)&kempld_platform_data_generic, | ||
615 | .callback = kempld_create_platform_device, | ||
616 | }, | ||
599 | {} | 617 | {} |
600 | }; | 618 | }; |
601 | MODULE_DEVICE_TABLE(dmi, kempld_dmi_table); | 619 | MODULE_DEVICE_TABLE(dmi, kempld_dmi_table); |
diff --git a/drivers/mfd/lm3533-core.c b/drivers/mfd/lm3533-core.c index 4b7e6dac1de8..8c29f7b27324 100644 --- a/drivers/mfd/lm3533-core.c +++ b/drivers/mfd/lm3533-core.c | |||
@@ -384,7 +384,7 @@ static struct attribute_group lm3533_attribute_group = { | |||
384 | 384 | ||
385 | static int lm3533_device_als_init(struct lm3533 *lm3533) | 385 | static int lm3533_device_als_init(struct lm3533 *lm3533) |
386 | { | 386 | { |
387 | struct lm3533_platform_data *pdata = lm3533->dev->platform_data; | 387 | struct lm3533_platform_data *pdata = dev_get_platdata(lm3533->dev); |
388 | int ret; | 388 | int ret; |
389 | 389 | ||
390 | if (!pdata->als) | 390 | if (!pdata->als) |
@@ -407,7 +407,7 @@ static int lm3533_device_als_init(struct lm3533 *lm3533) | |||
407 | 407 | ||
408 | static int lm3533_device_bl_init(struct lm3533 *lm3533) | 408 | static int lm3533_device_bl_init(struct lm3533 *lm3533) |
409 | { | 409 | { |
410 | struct lm3533_platform_data *pdata = lm3533->dev->platform_data; | 410 | struct lm3533_platform_data *pdata = dev_get_platdata(lm3533->dev); |
411 | int i; | 411 | int i; |
412 | int ret; | 412 | int ret; |
413 | 413 | ||
@@ -436,7 +436,7 @@ static int lm3533_device_bl_init(struct lm3533 *lm3533) | |||
436 | 436 | ||
437 | static int lm3533_device_led_init(struct lm3533 *lm3533) | 437 | static int lm3533_device_led_init(struct lm3533 *lm3533) |
438 | { | 438 | { |
439 | struct lm3533_platform_data *pdata = lm3533->dev->platform_data; | 439 | struct lm3533_platform_data *pdata = dev_get_platdata(lm3533->dev); |
440 | int i; | 440 | int i; |
441 | int ret; | 441 | int ret; |
442 | 442 | ||
@@ -481,7 +481,7 @@ static int lm3533_device_setup(struct lm3533 *lm3533, | |||
481 | 481 | ||
482 | static int lm3533_device_init(struct lm3533 *lm3533) | 482 | static int lm3533_device_init(struct lm3533 *lm3533) |
483 | { | 483 | { |
484 | struct lm3533_platform_data *pdata = lm3533->dev->platform_data; | 484 | struct lm3533_platform_data *pdata = dev_get_platdata(lm3533->dev); |
485 | int ret; | 485 | int ret; |
486 | 486 | ||
487 | dev_dbg(lm3533->dev, "%s\n", __func__); | 487 | dev_dbg(lm3533->dev, "%s\n", __func__); |
diff --git a/drivers/mfd/lp8788.c b/drivers/mfd/lp8788.c index c3d3c9b4d3ad..0f1221911018 100644 --- a/drivers/mfd/lp8788.c +++ b/drivers/mfd/lp8788.c | |||
@@ -173,7 +173,7 @@ static const struct regmap_config lp8788_regmap_config = { | |||
173 | static int lp8788_probe(struct i2c_client *cl, const struct i2c_device_id *id) | 173 | static int lp8788_probe(struct i2c_client *cl, const struct i2c_device_id *id) |
174 | { | 174 | { |
175 | struct lp8788 *lp; | 175 | struct lp8788 *lp; |
176 | struct lp8788_platform_data *pdata = cl->dev.platform_data; | 176 | struct lp8788_platform_data *pdata = dev_get_platdata(&cl->dev); |
177 | int ret; | 177 | int ret; |
178 | 178 | ||
179 | lp = devm_kzalloc(&cl->dev, sizeof(struct lp8788), GFP_KERNEL); | 179 | lp = devm_kzalloc(&cl->dev, sizeof(struct lp8788), GFP_KERNEL); |
diff --git a/drivers/mfd/lpc_ich.c b/drivers/mfd/lpc_ich.c index 24033324c17a..9483bc8472a5 100644 --- a/drivers/mfd/lpc_ich.c +++ b/drivers/mfd/lpc_ich.c | |||
@@ -213,7 +213,7 @@ enum lpc_chipsets { | |||
213 | LPC_COLETO, /* Coleto Creek */ | 213 | LPC_COLETO, /* Coleto Creek */ |
214 | }; | 214 | }; |
215 | 215 | ||
216 | struct lpc_ich_info lpc_chipset_info[] = { | 216 | static struct lpc_ich_info lpc_chipset_info[] = { |
217 | [LPC_ICH] = { | 217 | [LPC_ICH] = { |
218 | .name = "ICH", | 218 | .name = "ICH", |
219 | .iTCO_version = 1, | 219 | .iTCO_version = 1, |
diff --git a/drivers/mfd/max77686.c b/drivers/mfd/max77686.c index f27a21831583..522be67b2e68 100644 --- a/drivers/mfd/max77686.c +++ b/drivers/mfd/max77686.c | |||
@@ -77,7 +77,7 @@ static int max77686_i2c_probe(struct i2c_client *i2c, | |||
77 | const struct i2c_device_id *id) | 77 | const struct i2c_device_id *id) |
78 | { | 78 | { |
79 | struct max77686_dev *max77686 = NULL; | 79 | struct max77686_dev *max77686 = NULL; |
80 | struct max77686_platform_data *pdata = i2c->dev.platform_data; | 80 | struct max77686_platform_data *pdata = dev_get_platdata(&i2c->dev); |
81 | unsigned int data; | 81 | unsigned int data; |
82 | int ret = 0; | 82 | int ret = 0; |
83 | 83 | ||
diff --git a/drivers/mfd/max77693.c b/drivers/mfd/max77693.c index 9e60fed5ff82..c04723efc707 100644 --- a/drivers/mfd/max77693.c +++ b/drivers/mfd/max77693.c | |||
@@ -110,7 +110,7 @@ static int max77693_i2c_probe(struct i2c_client *i2c, | |||
110 | const struct i2c_device_id *id) | 110 | const struct i2c_device_id *id) |
111 | { | 111 | { |
112 | struct max77693_dev *max77693; | 112 | struct max77693_dev *max77693; |
113 | struct max77693_platform_data *pdata = i2c->dev.platform_data; | 113 | struct max77693_platform_data *pdata = dev_get_platdata(&i2c->dev); |
114 | u8 reg_data; | 114 | u8 reg_data; |
115 | int ret = 0; | 115 | int ret = 0; |
116 | 116 | ||
diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c index 8042b3205eaa..de7fb80a6052 100644 --- a/drivers/mfd/max8925-i2c.c +++ b/drivers/mfd/max8925-i2c.c | |||
@@ -151,7 +151,7 @@ static int max8925_dt_init(struct device_node *np, struct device *dev, | |||
151 | static int max8925_probe(struct i2c_client *client, | 151 | static int max8925_probe(struct i2c_client *client, |
152 | const struct i2c_device_id *id) | 152 | const struct i2c_device_id *id) |
153 | { | 153 | { |
154 | struct max8925_platform_data *pdata = client->dev.platform_data; | 154 | struct max8925_platform_data *pdata = dev_get_platdata(&client->dev); |
155 | static struct max8925_chip *chip; | 155 | static struct max8925_chip *chip; |
156 | struct device_node *node = client->dev.of_node; | 156 | struct device_node *node = client->dev.of_node; |
157 | 157 | ||
diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c index 14714058f2d2..cee098c0dae3 100644 --- a/drivers/mfd/max8997.c +++ b/drivers/mfd/max8997.c | |||
@@ -51,7 +51,7 @@ static struct mfd_cell max8997_devs[] = { | |||
51 | 51 | ||
52 | #ifdef CONFIG_OF | 52 | #ifdef CONFIG_OF |
53 | static struct of_device_id max8997_pmic_dt_match[] = { | 53 | static struct of_device_id max8997_pmic_dt_match[] = { |
54 | { .compatible = "maxim,max8997-pmic", .data = TYPE_MAX8997 }, | 54 | { .compatible = "maxim,max8997-pmic", .data = (void *)TYPE_MAX8997 }, |
55 | {}, | 55 | {}, |
56 | }; | 56 | }; |
57 | #endif | 57 | #endif |
@@ -188,10 +188,11 @@ static int max8997_i2c_probe(struct i2c_client *i2c, | |||
188 | const struct i2c_device_id *id) | 188 | const struct i2c_device_id *id) |
189 | { | 189 | { |
190 | struct max8997_dev *max8997; | 190 | struct max8997_dev *max8997; |
191 | struct max8997_platform_data *pdata = i2c->dev.platform_data; | 191 | struct max8997_platform_data *pdata = dev_get_platdata(&i2c->dev); |
192 | int ret = 0; | 192 | int ret = 0; |
193 | 193 | ||
194 | max8997 = kzalloc(sizeof(struct max8997_dev), GFP_KERNEL); | 194 | max8997 = devm_kzalloc(&i2c->dev, sizeof(struct max8997_dev), |
195 | GFP_KERNEL); | ||
195 | if (max8997 == NULL) | 196 | if (max8997 == NULL) |
196 | return -ENOMEM; | 197 | return -ENOMEM; |
197 | 198 | ||
@@ -203,14 +204,12 @@ static int max8997_i2c_probe(struct i2c_client *i2c, | |||
203 | 204 | ||
204 | if (max8997->dev->of_node) { | 205 | if (max8997->dev->of_node) { |
205 | pdata = max8997_i2c_parse_dt_pdata(max8997->dev); | 206 | pdata = max8997_i2c_parse_dt_pdata(max8997->dev); |
206 | if (IS_ERR(pdata)) { | 207 | if (IS_ERR(pdata)) |
207 | ret = PTR_ERR(pdata); | 208 | return PTR_ERR(pdata); |
208 | goto err; | ||
209 | } | ||
210 | } | 209 | } |
211 | 210 | ||
212 | if (!pdata) | 211 | if (!pdata) |
213 | goto err; | 212 | return ret; |
214 | 213 | ||
215 | max8997->pdata = pdata; | 214 | max8997->pdata = pdata; |
216 | max8997->ono = pdata->ono; | 215 | max8997->ono = pdata->ono; |
@@ -250,8 +249,6 @@ err_mfd: | |||
250 | i2c_unregister_device(max8997->muic); | 249 | i2c_unregister_device(max8997->muic); |
251 | i2c_unregister_device(max8997->haptic); | 250 | i2c_unregister_device(max8997->haptic); |
252 | i2c_unregister_device(max8997->rtc); | 251 | i2c_unregister_device(max8997->rtc); |
253 | err: | ||
254 | kfree(max8997); | ||
255 | return ret; | 252 | return ret; |
256 | } | 253 | } |
257 | 254 | ||
@@ -263,7 +260,6 @@ static int max8997_i2c_remove(struct i2c_client *i2c) | |||
263 | i2c_unregister_device(max8997->muic); | 260 | i2c_unregister_device(max8997->muic); |
264 | i2c_unregister_device(max8997->haptic); | 261 | i2c_unregister_device(max8997->haptic); |
265 | i2c_unregister_device(max8997->rtc); | 262 | i2c_unregister_device(max8997->rtc); |
266 | kfree(max8997); | ||
267 | 263 | ||
268 | return 0; | 264 | return 0; |
269 | } | 265 | } |
diff --git a/drivers/mfd/max8998.c b/drivers/mfd/max8998.c index 21af51a499f4..fe6332dcabee 100644 --- a/drivers/mfd/max8998.c +++ b/drivers/mfd/max8998.c | |||
@@ -184,11 +184,12 @@ static inline int max8998_i2c_get_driver_data(struct i2c_client *i2c, | |||
184 | static int max8998_i2c_probe(struct i2c_client *i2c, | 184 | static int max8998_i2c_probe(struct i2c_client *i2c, |
185 | const struct i2c_device_id *id) | 185 | const struct i2c_device_id *id) |
186 | { | 186 | { |
187 | struct max8998_platform_data *pdata = i2c->dev.platform_data; | 187 | struct max8998_platform_data *pdata = dev_get_platdata(&i2c->dev); |
188 | struct max8998_dev *max8998; | 188 | struct max8998_dev *max8998; |
189 | int ret = 0; | 189 | int ret = 0; |
190 | 190 | ||
191 | max8998 = kzalloc(sizeof(struct max8998_dev), GFP_KERNEL); | 191 | max8998 = devm_kzalloc(&i2c->dev, sizeof(struct max8998_dev), |
192 | GFP_KERNEL); | ||
192 | if (max8998 == NULL) | 193 | if (max8998 == NULL) |
193 | return -ENOMEM; | 194 | return -ENOMEM; |
194 | 195 | ||
@@ -246,7 +247,6 @@ err: | |||
246 | mfd_remove_devices(max8998->dev); | 247 | mfd_remove_devices(max8998->dev); |
247 | max8998_irq_exit(max8998); | 248 | max8998_irq_exit(max8998); |
248 | i2c_unregister_device(max8998->rtc); | 249 | i2c_unregister_device(max8998->rtc); |
249 | kfree(max8998); | ||
250 | return ret; | 250 | return ret; |
251 | } | 251 | } |
252 | 252 | ||
@@ -257,7 +257,6 @@ static int max8998_i2c_remove(struct i2c_client *i2c) | |||
257 | mfd_remove_devices(max8998->dev); | 257 | mfd_remove_devices(max8998->dev); |
258 | max8998_irq_exit(max8998); | 258 | max8998_irq_exit(max8998); |
259 | i2c_unregister_device(max8998->rtc); | 259 | i2c_unregister_device(max8998->rtc); |
260 | kfree(max8998); | ||
261 | 260 | ||
262 | return 0; | 261 | return 0; |
263 | } | 262 | } |
diff --git a/drivers/mfd/mcp-sa11x0.c b/drivers/mfd/mcp-sa11x0.c index 13198d937e36..41c31b3ac940 100644 --- a/drivers/mfd/mcp-sa11x0.c +++ b/drivers/mfd/mcp-sa11x0.c | |||
@@ -156,7 +156,7 @@ static struct mcp_ops mcp_sa11x0 = { | |||
156 | 156 | ||
157 | static int mcp_sa11x0_probe(struct platform_device *dev) | 157 | static int mcp_sa11x0_probe(struct platform_device *dev) |
158 | { | 158 | { |
159 | struct mcp_plat_data *data = dev->dev.platform_data; | 159 | struct mcp_plat_data *data = dev_get_platdata(&dev->dev); |
160 | struct resource *mem0, *mem1; | 160 | struct resource *mem0, *mem1; |
161 | struct mcp_sa11x0 *m; | 161 | struct mcp_sa11x0 *m; |
162 | struct mcp *mcp; | 162 | struct mcp *mcp; |
diff --git a/drivers/mfd/menelaus.c b/drivers/mfd/menelaus.c index 998ce8cb3065..ad25bfa3fb02 100644 --- a/drivers/mfd/menelaus.c +++ b/drivers/mfd/menelaus.c | |||
@@ -442,7 +442,7 @@ void menelaus_unregister_mmc_callback(void) | |||
442 | menelaus_remove_irq_work(MENELAUS_MMC_S2D1_IRQ); | 442 | menelaus_remove_irq_work(MENELAUS_MMC_S2D1_IRQ); |
443 | 443 | ||
444 | the_menelaus->mmc_callback = NULL; | 444 | the_menelaus->mmc_callback = NULL; |
445 | the_menelaus->mmc_callback_data = 0; | 445 | the_menelaus->mmc_callback_data = NULL; |
446 | } | 446 | } |
447 | EXPORT_SYMBOL(menelaus_unregister_mmc_callback); | 447 | EXPORT_SYMBOL(menelaus_unregister_mmc_callback); |
448 | 448 | ||
@@ -466,7 +466,7 @@ static int menelaus_set_voltage(const struct menelaus_vtg *vtg, int mV, | |||
466 | struct i2c_client *c = the_menelaus->client; | 466 | struct i2c_client *c = the_menelaus->client; |
467 | 467 | ||
468 | mutex_lock(&the_menelaus->lock); | 468 | mutex_lock(&the_menelaus->lock); |
469 | if (vtg == 0) | 469 | if (!vtg) |
470 | goto set_voltage; | 470 | goto set_voltage; |
471 | 471 | ||
472 | ret = menelaus_read_reg(vtg->vtg_reg); | 472 | ret = menelaus_read_reg(vtg->vtg_reg); |
@@ -1189,7 +1189,7 @@ static int menelaus_probe(struct i2c_client *client, | |||
1189 | int rev = 0, val; | 1189 | int rev = 0, val; |
1190 | int err = 0; | 1190 | int err = 0; |
1191 | struct menelaus_platform_data *menelaus_pdata = | 1191 | struct menelaus_platform_data *menelaus_pdata = |
1192 | client->dev.platform_data; | 1192 | dev_get_platdata(&client->dev); |
1193 | 1193 | ||
1194 | if (the_menelaus) { | 1194 | if (the_menelaus) { |
1195 | dev_dbg(&client->dev, "only one %s for now\n", | 1195 | dev_dbg(&client->dev, "only one %s for now\n", |
@@ -1197,7 +1197,7 @@ static int menelaus_probe(struct i2c_client *client, | |||
1197 | return -ENODEV; | 1197 | return -ENODEV; |
1198 | } | 1198 | } |
1199 | 1199 | ||
1200 | menelaus = kzalloc(sizeof *menelaus, GFP_KERNEL); | 1200 | menelaus = devm_kzalloc(&client->dev, sizeof(*menelaus), GFP_KERNEL); |
1201 | if (!menelaus) | 1201 | if (!menelaus) |
1202 | return -ENOMEM; | 1202 | return -ENOMEM; |
1203 | 1203 | ||
@@ -1210,8 +1210,7 @@ static int menelaus_probe(struct i2c_client *client, | |||
1210 | rev = menelaus_read_reg(MENELAUS_REV); | 1210 | rev = menelaus_read_reg(MENELAUS_REV); |
1211 | if (rev < 0) { | 1211 | if (rev < 0) { |
1212 | pr_err(DRIVER_NAME ": device not found"); | 1212 | pr_err(DRIVER_NAME ": device not found"); |
1213 | err = -ENODEV; | 1213 | return -ENODEV; |
1214 | goto fail1; | ||
1215 | } | 1214 | } |
1216 | 1215 | ||
1217 | /* Ack and disable all Menelaus interrupts */ | 1216 | /* Ack and disable all Menelaus interrupts */ |
@@ -1231,7 +1230,7 @@ static int menelaus_probe(struct i2c_client *client, | |||
1231 | if (err) { | 1230 | if (err) { |
1232 | dev_dbg(&client->dev, "can't get IRQ %d, err %d\n", | 1231 | dev_dbg(&client->dev, "can't get IRQ %d, err %d\n", |
1233 | client->irq, err); | 1232 | client->irq, err); |
1234 | goto fail1; | 1233 | return err; |
1235 | } | 1234 | } |
1236 | } | 1235 | } |
1237 | 1236 | ||
@@ -1242,7 +1241,7 @@ static int menelaus_probe(struct i2c_client *client, | |||
1242 | 1241 | ||
1243 | val = menelaus_read_reg(MENELAUS_VCORE_CTRL1); | 1242 | val = menelaus_read_reg(MENELAUS_VCORE_CTRL1); |
1244 | if (val < 0) | 1243 | if (val < 0) |
1245 | goto fail2; | 1244 | goto fail; |
1246 | if (val & (1 << 7)) | 1245 | if (val & (1 << 7)) |
1247 | menelaus->vcore_hw_mode = 1; | 1246 | menelaus->vcore_hw_mode = 1; |
1248 | else | 1247 | else |
@@ -1251,17 +1250,15 @@ static int menelaus_probe(struct i2c_client *client, | |||
1251 | if (menelaus_pdata != NULL && menelaus_pdata->late_init != NULL) { | 1250 | if (menelaus_pdata != NULL && menelaus_pdata->late_init != NULL) { |
1252 | err = menelaus_pdata->late_init(&client->dev); | 1251 | err = menelaus_pdata->late_init(&client->dev); |
1253 | if (err < 0) | 1252 | if (err < 0) |
1254 | goto fail2; | 1253 | goto fail; |
1255 | } | 1254 | } |
1256 | 1255 | ||
1257 | menelaus_rtc_init(menelaus); | 1256 | menelaus_rtc_init(menelaus); |
1258 | 1257 | ||
1259 | return 0; | 1258 | return 0; |
1260 | fail2: | 1259 | fail: |
1261 | free_irq(client->irq, menelaus); | 1260 | free_irq(client->irq, menelaus); |
1262 | flush_work(&menelaus->work); | 1261 | flush_work(&menelaus->work); |
1263 | fail1: | ||
1264 | kfree(menelaus); | ||
1265 | return err; | 1262 | return err; |
1266 | } | 1263 | } |
1267 | 1264 | ||
@@ -1271,7 +1268,6 @@ static int __exit menelaus_remove(struct i2c_client *client) | |||
1271 | 1268 | ||
1272 | free_irq(client->irq, menelaus); | 1269 | free_irq(client->irq, menelaus); |
1273 | flush_work(&menelaus->work); | 1270 | flush_work(&menelaus->work); |
1274 | kfree(menelaus); | ||
1275 | the_menelaus = NULL; | 1271 | the_menelaus = NULL; |
1276 | return 0; | 1272 | return 0; |
1277 | } | 1273 | } |
diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c index 7604f4e5df40..f421586f29fb 100644 --- a/drivers/mfd/mfd-core.c +++ b/drivers/mfd/mfd-core.c | |||
@@ -96,6 +96,8 @@ static int mfd_add_device(struct device *parent, int id, | |||
96 | 96 | ||
97 | pdev->dev.parent = parent; | 97 | pdev->dev.parent = parent; |
98 | pdev->dev.type = &mfd_dev_type; | 98 | pdev->dev.type = &mfd_dev_type; |
99 | pdev->dev.dma_mask = parent->dma_mask; | ||
100 | pdev->dev.dma_parms = parent->dma_parms; | ||
99 | 101 | ||
100 | if (parent->of_node && cell->of_compatible) { | 102 | if (parent->of_node && cell->of_compatible) { |
101 | for_each_child_of_node(parent->of_node, np) { | 103 | for_each_child_of_node(parent->of_node, np) { |
diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c index 759fae3ca7fb..29ee54d68512 100644 --- a/drivers/mfd/omap-usb-host.c +++ b/drivers/mfd/omap-usb-host.c | |||
@@ -114,7 +114,7 @@ struct usbhs_hcd_omap { | |||
114 | }; | 114 | }; |
115 | /*-------------------------------------------------------------------------*/ | 115 | /*-------------------------------------------------------------------------*/ |
116 | 116 | ||
117 | const char usbhs_driver_name[] = USBHS_DRIVER_NAME; | 117 | static const char usbhs_driver_name[] = USBHS_DRIVER_NAME; |
118 | static u64 usbhs_dmamask = DMA_BIT_MASK(32); | 118 | static u64 usbhs_dmamask = DMA_BIT_MASK(32); |
119 | 119 | ||
120 | /*-------------------------------------------------------------------------*/ | 120 | /*-------------------------------------------------------------------------*/ |
@@ -232,7 +232,7 @@ err_end: | |||
232 | static int omap_usbhs_alloc_children(struct platform_device *pdev) | 232 | static int omap_usbhs_alloc_children(struct platform_device *pdev) |
233 | { | 233 | { |
234 | struct device *dev = &pdev->dev; | 234 | struct device *dev = &pdev->dev; |
235 | struct usbhs_omap_platform_data *pdata = dev->platform_data; | 235 | struct usbhs_omap_platform_data *pdata = dev_get_platdata(dev); |
236 | struct platform_device *ehci; | 236 | struct platform_device *ehci; |
237 | struct platform_device *ohci; | 237 | struct platform_device *ohci; |
238 | struct resource *res; | 238 | struct resource *res; |
@@ -571,7 +571,7 @@ static struct of_device_id usbhs_child_match_table[] = { | |||
571 | static int usbhs_omap_probe(struct platform_device *pdev) | 571 | static int usbhs_omap_probe(struct platform_device *pdev) |
572 | { | 572 | { |
573 | struct device *dev = &pdev->dev; | 573 | struct device *dev = &pdev->dev; |
574 | struct usbhs_omap_platform_data *pdata = dev->platform_data; | 574 | struct usbhs_omap_platform_data *pdata = dev_get_platdata(dev); |
575 | struct usbhs_hcd_omap *omap; | 575 | struct usbhs_hcd_omap *omap; |
576 | struct resource *res; | 576 | struct resource *res; |
577 | int ret = 0; | 577 | int ret = 0; |
diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c index e4d1c706df8b..135afabe4ae2 100644 --- a/drivers/mfd/palmas.c +++ b/drivers/mfd/palmas.c | |||
@@ -25,6 +25,52 @@ | |||
25 | #include <linux/mfd/palmas.h> | 25 | #include <linux/mfd/palmas.h> |
26 | #include <linux/of_device.h> | 26 | #include <linux/of_device.h> |
27 | 27 | ||
28 | #define PALMAS_EXT_REQ (PALMAS_EXT_CONTROL_ENABLE1 | \ | ||
29 | PALMAS_EXT_CONTROL_ENABLE2 | \ | ||
30 | PALMAS_EXT_CONTROL_NSLEEP) | ||
31 | |||
32 | struct palmas_sleep_requestor_info { | ||
33 | int id; | ||
34 | int reg_offset; | ||
35 | int bit_pos; | ||
36 | }; | ||
37 | |||
38 | #define EXTERNAL_REQUESTOR(_id, _offset, _pos) \ | ||
39 | [PALMAS_EXTERNAL_REQSTR_ID_##_id] = { \ | ||
40 | .id = PALMAS_EXTERNAL_REQSTR_ID_##_id, \ | ||
41 | .reg_offset = _offset, \ | ||
42 | .bit_pos = _pos, \ | ||
43 | } | ||
44 | |||
45 | static struct palmas_sleep_requestor_info sleep_req_info[] = { | ||
46 | EXTERNAL_REQUESTOR(REGEN1, 0, 0), | ||
47 | EXTERNAL_REQUESTOR(REGEN2, 0, 1), | ||
48 | EXTERNAL_REQUESTOR(SYSEN1, 0, 2), | ||
49 | EXTERNAL_REQUESTOR(SYSEN2, 0, 3), | ||
50 | EXTERNAL_REQUESTOR(CLK32KG, 0, 4), | ||
51 | EXTERNAL_REQUESTOR(CLK32KGAUDIO, 0, 5), | ||
52 | EXTERNAL_REQUESTOR(REGEN3, 0, 6), | ||
53 | EXTERNAL_REQUESTOR(SMPS12, 1, 0), | ||
54 | EXTERNAL_REQUESTOR(SMPS3, 1, 1), | ||
55 | EXTERNAL_REQUESTOR(SMPS45, 1, 2), | ||
56 | EXTERNAL_REQUESTOR(SMPS6, 1, 3), | ||
57 | EXTERNAL_REQUESTOR(SMPS7, 1, 4), | ||
58 | EXTERNAL_REQUESTOR(SMPS8, 1, 5), | ||
59 | EXTERNAL_REQUESTOR(SMPS9, 1, 6), | ||
60 | EXTERNAL_REQUESTOR(SMPS10, 1, 7), | ||
61 | EXTERNAL_REQUESTOR(LDO1, 2, 0), | ||
62 | EXTERNAL_REQUESTOR(LDO2, 2, 1), | ||
63 | EXTERNAL_REQUESTOR(LDO3, 2, 2), | ||
64 | EXTERNAL_REQUESTOR(LDO4, 2, 3), | ||
65 | EXTERNAL_REQUESTOR(LDO5, 2, 4), | ||
66 | EXTERNAL_REQUESTOR(LDO6, 2, 5), | ||
67 | EXTERNAL_REQUESTOR(LDO7, 2, 6), | ||
68 | EXTERNAL_REQUESTOR(LDO8, 2, 7), | ||
69 | EXTERNAL_REQUESTOR(LDO9, 3, 0), | ||
70 | EXTERNAL_REQUESTOR(LDOLN, 3, 1), | ||
71 | EXTERNAL_REQUESTOR(LDOUSB, 3, 2), | ||
72 | }; | ||
73 | |||
28 | static const struct regmap_config palmas_regmap_config[PALMAS_NUM_CLIENTS] = { | 74 | static const struct regmap_config palmas_regmap_config[PALMAS_NUM_CLIENTS] = { |
29 | { | 75 | { |
30 | .reg_bits = 8, | 76 | .reg_bits = 8, |
@@ -186,6 +232,57 @@ static struct regmap_irq_chip palmas_irq_chip = { | |||
186 | PALMAS_INT1_MASK), | 232 | PALMAS_INT1_MASK), |
187 | }; | 233 | }; |
188 | 234 | ||
235 | int palmas_ext_control_req_config(struct palmas *palmas, | ||
236 | enum palmas_external_requestor_id id, int ext_ctrl, bool enable) | ||
237 | { | ||
238 | int preq_mask_bit = 0; | ||
239 | int reg_add = 0; | ||
240 | int bit_pos; | ||
241 | int ret; | ||
242 | |||
243 | if (!(ext_ctrl & PALMAS_EXT_REQ)) | ||
244 | return 0; | ||
245 | |||
246 | if (id >= PALMAS_EXTERNAL_REQSTR_ID_MAX) | ||
247 | return 0; | ||
248 | |||
249 | if (ext_ctrl & PALMAS_EXT_CONTROL_NSLEEP) { | ||
250 | reg_add = PALMAS_NSLEEP_RES_ASSIGN; | ||
251 | preq_mask_bit = 0; | ||
252 | } else if (ext_ctrl & PALMAS_EXT_CONTROL_ENABLE1) { | ||
253 | reg_add = PALMAS_ENABLE1_RES_ASSIGN; | ||
254 | preq_mask_bit = 1; | ||
255 | } else if (ext_ctrl & PALMAS_EXT_CONTROL_ENABLE2) { | ||
256 | reg_add = PALMAS_ENABLE2_RES_ASSIGN; | ||
257 | preq_mask_bit = 2; | ||
258 | } | ||
259 | |||
260 | bit_pos = sleep_req_info[id].bit_pos; | ||
261 | reg_add += sleep_req_info[id].reg_offset; | ||
262 | if (enable) | ||
263 | ret = palmas_update_bits(palmas, PALMAS_RESOURCE_BASE, | ||
264 | reg_add, BIT(bit_pos), BIT(bit_pos)); | ||
265 | else | ||
266 | ret = palmas_update_bits(palmas, PALMAS_RESOURCE_BASE, | ||
267 | reg_add, BIT(bit_pos), 0); | ||
268 | if (ret < 0) { | ||
269 | dev_err(palmas->dev, "Resource reg 0x%02x update failed %d\n", | ||
270 | reg_add, ret); | ||
271 | return ret; | ||
272 | } | ||
273 | |||
274 | /* Unmask the PREQ */ | ||
275 | ret = palmas_update_bits(palmas, PALMAS_PMU_CONTROL_BASE, | ||
276 | PALMAS_POWER_CTRL, BIT(preq_mask_bit), 0); | ||
277 | if (ret < 0) { | ||
278 | dev_err(palmas->dev, "POWER_CTRL register update failed %d\n", | ||
279 | ret); | ||
280 | return ret; | ||
281 | } | ||
282 | return ret; | ||
283 | } | ||
284 | EXPORT_SYMBOL_GPL(palmas_ext_control_req_config); | ||
285 | |||
189 | static int palmas_set_pdata_irq_flag(struct i2c_client *i2c, | 286 | static int palmas_set_pdata_irq_flag(struct i2c_client *i2c, |
190 | struct palmas_platform_data *pdata) | 287 | struct palmas_platform_data *pdata) |
191 | { | 288 | { |
@@ -229,6 +326,32 @@ static void palmas_dt_to_pdata(struct i2c_client *i2c, | |||
229 | PALMAS_POWER_CTRL_ENABLE2_MASK; | 326 | PALMAS_POWER_CTRL_ENABLE2_MASK; |
230 | if (i2c->irq) | 327 | if (i2c->irq) |
231 | palmas_set_pdata_irq_flag(i2c, pdata); | 328 | palmas_set_pdata_irq_flag(i2c, pdata); |
329 | |||
330 | pdata->pm_off = of_property_read_bool(node, | ||
331 | "ti,system-power-controller"); | ||
332 | } | ||
333 | |||
334 | static struct palmas *palmas_dev; | ||
335 | static void palmas_power_off(void) | ||
336 | { | ||
337 | unsigned int addr; | ||
338 | int ret, slave; | ||
339 | |||
340 | if (!palmas_dev) | ||
341 | return; | ||
342 | |||
343 | slave = PALMAS_BASE_TO_SLAVE(PALMAS_PMU_CONTROL_BASE); | ||
344 | addr = PALMAS_BASE_TO_REG(PALMAS_PMU_CONTROL_BASE, PALMAS_DEV_CTRL); | ||
345 | |||
346 | ret = regmap_update_bits( | ||
347 | palmas_dev->regmap[slave], | ||
348 | addr, | ||
349 | PALMAS_DEV_CTRL_DEV_ON, | ||
350 | 0); | ||
351 | |||
352 | if (ret) | ||
353 | pr_err("%s: Unable to write to DEV_CTRL_DEV_ON: %d\n", | ||
354 | __func__, ret); | ||
232 | } | 355 | } |
233 | 356 | ||
234 | static unsigned int palmas_features = PALMAS_PMIC_FEATURE_SMPS10_BOOST; | 357 | static unsigned int palmas_features = PALMAS_PMIC_FEATURE_SMPS10_BOOST; |
@@ -423,10 +546,13 @@ no_irq: | |||
423 | */ | 546 | */ |
424 | if (node) { | 547 | if (node) { |
425 | ret = of_platform_populate(node, NULL, NULL, &i2c->dev); | 548 | ret = of_platform_populate(node, NULL, NULL, &i2c->dev); |
426 | if (ret < 0) | 549 | if (ret < 0) { |
427 | goto err_irq; | 550 | goto err_irq; |
428 | else | 551 | } else if (pdata->pm_off && !pm_power_off) { |
552 | palmas_dev = palmas; | ||
553 | pm_power_off = palmas_power_off; | ||
429 | return ret; | 554 | return ret; |
555 | } | ||
430 | } | 556 | } |
431 | 557 | ||
432 | return ret; | 558 | return ret; |
diff --git a/drivers/mfd/pcf50633-adc.c b/drivers/mfd/pcf50633-adc.c index 18b53cb72fea..b8941a556d71 100644 --- a/drivers/mfd/pcf50633-adc.c +++ b/drivers/mfd/pcf50633-adc.c | |||
@@ -203,7 +203,7 @@ static int pcf50633_adc_probe(struct platform_device *pdev) | |||
203 | { | 203 | { |
204 | struct pcf50633_adc *adc; | 204 | struct pcf50633_adc *adc; |
205 | 205 | ||
206 | adc = kzalloc(sizeof(*adc), GFP_KERNEL); | 206 | adc = devm_kzalloc(&pdev->dev, sizeof(*adc), GFP_KERNEL); |
207 | if (!adc) | 207 | if (!adc) |
208 | return -ENOMEM; | 208 | return -ENOMEM; |
209 | 209 | ||
@@ -236,7 +236,6 @@ static int pcf50633_adc_remove(struct platform_device *pdev) | |||
236 | kfree(adc->queue[i]); | 236 | kfree(adc->queue[i]); |
237 | 237 | ||
238 | mutex_unlock(&adc->queue_mutex); | 238 | mutex_unlock(&adc->queue_mutex); |
239 | kfree(adc); | ||
240 | 239 | ||
241 | return 0; | 240 | return 0; |
242 | } | 241 | } |
diff --git a/drivers/mfd/pcf50633-core.c b/drivers/mfd/pcf50633-core.c index d11567307fbe..6841d6805fd6 100644 --- a/drivers/mfd/pcf50633-core.c +++ b/drivers/mfd/pcf50633-core.c | |||
@@ -195,7 +195,7 @@ static int pcf50633_probe(struct i2c_client *client, | |||
195 | const struct i2c_device_id *ids) | 195 | const struct i2c_device_id *ids) |
196 | { | 196 | { |
197 | struct pcf50633 *pcf; | 197 | struct pcf50633 *pcf; |
198 | struct pcf50633_platform_data *pdata = client->dev.platform_data; | 198 | struct pcf50633_platform_data *pdata = dev_get_platdata(&client->dev); |
199 | int i, ret; | 199 | int i, ret; |
200 | int version, variant; | 200 | int version, variant; |
201 | 201 | ||
diff --git a/drivers/mfd/pm8921-core.c b/drivers/mfd/pm8921-core.c index ecc137ffa8c3..a6841f77aa5e 100644 --- a/drivers/mfd/pm8921-core.c +++ b/drivers/mfd/pm8921-core.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #define pr_fmt(fmt) "%s: " fmt, __func__ | 14 | #define pr_fmt(fmt) "%s: " fmt, __func__ |
15 | 15 | ||
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/module.h> | ||
17 | #include <linux/platform_device.h> | 18 | #include <linux/platform_device.h> |
18 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
19 | #include <linux/err.h> | 20 | #include <linux/err.h> |
@@ -106,7 +107,7 @@ static int pm8921_add_subdevices(const struct pm8921_platform_data | |||
106 | 107 | ||
107 | static int pm8921_probe(struct platform_device *pdev) | 108 | static int pm8921_probe(struct platform_device *pdev) |
108 | { | 109 | { |
109 | const struct pm8921_platform_data *pdata = pdev->dev.platform_data; | 110 | const struct pm8921_platform_data *pdata = dev_get_platdata(&pdev->dev); |
110 | struct pm8921 *pmic; | 111 | struct pm8921 *pmic; |
111 | int rc; | 112 | int rc; |
112 | u8 val; | 113 | u8 val; |
@@ -117,7 +118,7 @@ static int pm8921_probe(struct platform_device *pdev) | |||
117 | return -EINVAL; | 118 | return -EINVAL; |
118 | } | 119 | } |
119 | 120 | ||
120 | pmic = kzalloc(sizeof(struct pm8921), GFP_KERNEL); | 121 | pmic = devm_kzalloc(&pdev->dev, sizeof(struct pm8921), GFP_KERNEL); |
121 | if (!pmic) { | 122 | if (!pmic) { |
122 | pr_err("Cannot alloc pm8921 struct\n"); | 123 | pr_err("Cannot alloc pm8921 struct\n"); |
123 | return -ENOMEM; | 124 | return -ENOMEM; |
@@ -127,7 +128,7 @@ static int pm8921_probe(struct platform_device *pdev) | |||
127 | rc = ssbi_read(pdev->dev.parent, REG_HWREV, &val, sizeof(val)); | 128 | rc = ssbi_read(pdev->dev.parent, REG_HWREV, &val, sizeof(val)); |
128 | if (rc) { | 129 | if (rc) { |
129 | pr_err("Failed to read hw rev reg %d:rc=%d\n", REG_HWREV, rc); | 130 | pr_err("Failed to read hw rev reg %d:rc=%d\n", REG_HWREV, rc); |
130 | goto err_read_rev; | 131 | return rc; |
131 | } | 132 | } |
132 | pr_info("PMIC revision 1: %02X\n", val); | 133 | pr_info("PMIC revision 1: %02X\n", val); |
133 | rev = val; | 134 | rev = val; |
@@ -137,7 +138,7 @@ static int pm8921_probe(struct platform_device *pdev) | |||
137 | if (rc) { | 138 | if (rc) { |
138 | pr_err("Failed to read hw rev 2 reg %d:rc=%d\n", | 139 | pr_err("Failed to read hw rev 2 reg %d:rc=%d\n", |
139 | REG_HWREV_2, rc); | 140 | REG_HWREV_2, rc); |
140 | goto err_read_rev; | 141 | return rc; |
141 | } | 142 | } |
142 | pr_info("PMIC revision 2: %02X\n", val); | 143 | pr_info("PMIC revision 2: %02X\n", val); |
143 | rev |= val << BITS_PER_BYTE; | 144 | rev |= val << BITS_PER_BYTE; |
@@ -159,9 +160,6 @@ static int pm8921_probe(struct platform_device *pdev) | |||
159 | 160 | ||
160 | err: | 161 | err: |
161 | mfd_remove_devices(pmic->dev); | 162 | mfd_remove_devices(pmic->dev); |
162 | platform_set_drvdata(pdev, NULL); | ||
163 | err_read_rev: | ||
164 | kfree(pmic); | ||
165 | return rc; | 163 | return rc; |
166 | } | 164 | } |
167 | 165 | ||
@@ -179,8 +177,6 @@ static int pm8921_remove(struct platform_device *pdev) | |||
179 | pm8xxx_irq_exit(pmic->irq_chip); | 177 | pm8xxx_irq_exit(pmic->irq_chip); |
180 | pmic->irq_chip = NULL; | 178 | pmic->irq_chip = NULL; |
181 | } | 179 | } |
182 | platform_set_drvdata(pdev, NULL); | ||
183 | kfree(pmic); | ||
184 | 180 | ||
185 | return 0; | 181 | return 0; |
186 | } | 182 | } |
diff --git a/drivers/mfd/rc5t583.c b/drivers/mfd/rc5t583.c index 14bdaccefbec..346330176afc 100644 --- a/drivers/mfd/rc5t583.c +++ b/drivers/mfd/rc5t583.c | |||
@@ -250,7 +250,7 @@ static int rc5t583_i2c_probe(struct i2c_client *i2c, | |||
250 | const struct i2c_device_id *id) | 250 | const struct i2c_device_id *id) |
251 | { | 251 | { |
252 | struct rc5t583 *rc5t583; | 252 | struct rc5t583 *rc5t583; |
253 | struct rc5t583_platform_data *pdata = i2c->dev.platform_data; | 253 | struct rc5t583_platform_data *pdata = dev_get_platdata(&i2c->dev); |
254 | int ret; | 254 | int ret; |
255 | bool irq_init_success = false; | 255 | bool irq_init_success = false; |
256 | 256 | ||
diff --git a/drivers/mfd/rtl8411.c b/drivers/mfd/rtl8411.c index c436bf27e78d..52801351864d 100644 --- a/drivers/mfd/rtl8411.c +++ b/drivers/mfd/rtl8411.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* Driver for Realtek PCI-Express card reader | 1 | /* Driver for Realtek PCI-Express card reader |
2 | * | 2 | * |
3 | * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. | 3 | * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or modify it |
6 | * under the terms of the GNU General Public License as published by the | 6 | * under the terms of the GNU General Public License as published by the |
@@ -17,7 +17,7 @@ | |||
17 | * | 17 | * |
18 | * Author: | 18 | * Author: |
19 | * Wei WANG <wei_wang@realsil.com.cn> | 19 | * Wei WANG <wei_wang@realsil.com.cn> |
20 | * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China | 20 | * Roger Tseng <rogerable@realtek.com> |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
@@ -47,19 +47,77 @@ static int rtl8411b_is_qfn48(struct rtsx_pcr *pcr) | |||
47 | return 0; | 47 | return 0; |
48 | } | 48 | } |
49 | 49 | ||
50 | static void rtl8411_fetch_vendor_settings(struct rtsx_pcr *pcr) | ||
51 | { | ||
52 | u32 reg1; | ||
53 | u8 reg3; | ||
54 | |||
55 | rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG1, ®1); | ||
56 | dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg1); | ||
57 | |||
58 | if (!rtsx_vendor_setting_valid(reg1)) | ||
59 | return; | ||
60 | |||
61 | pcr->aspm_en = rtsx_reg_to_aspm(reg1); | ||
62 | pcr->sd30_drive_sel_1v8 = | ||
63 | map_sd_drive(rtsx_reg_to_sd30_drive_sel_1v8(reg1)); | ||
64 | pcr->card_drive_sel &= 0x3F; | ||
65 | pcr->card_drive_sel |= rtsx_reg_to_card_drive_sel(reg1); | ||
66 | |||
67 | rtsx_pci_read_config_byte(pcr, PCR_SETTING_REG3, ®3); | ||
68 | dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG3, reg3); | ||
69 | pcr->sd30_drive_sel_3v3 = rtl8411_reg_to_sd30_drive_sel_3v3(reg3); | ||
70 | } | ||
71 | |||
72 | static void rtl8411b_fetch_vendor_settings(struct rtsx_pcr *pcr) | ||
73 | { | ||
74 | u32 reg; | ||
75 | |||
76 | rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG1, ®); | ||
77 | dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg); | ||
78 | |||
79 | if (!rtsx_vendor_setting_valid(reg)) | ||
80 | return; | ||
81 | |||
82 | pcr->aspm_en = rtsx_reg_to_aspm(reg); | ||
83 | pcr->sd30_drive_sel_1v8 = | ||
84 | map_sd_drive(rtsx_reg_to_sd30_drive_sel_1v8(reg)); | ||
85 | pcr->sd30_drive_sel_3v3 = | ||
86 | map_sd_drive(rtl8411b_reg_to_sd30_drive_sel_3v3(reg)); | ||
87 | } | ||
88 | |||
89 | static void rtl8411_force_power_down(struct rtsx_pcr *pcr, u8 pm_state) | ||
90 | { | ||
91 | rtsx_pci_write_register(pcr, FPDCTL, 0x07, 0x07); | ||
92 | } | ||
93 | |||
50 | static int rtl8411_extra_init_hw(struct rtsx_pcr *pcr) | 94 | static int rtl8411_extra_init_hw(struct rtsx_pcr *pcr) |
51 | { | 95 | { |
52 | return rtsx_pci_write_register(pcr, CD_PAD_CTL, | 96 | rtsx_pci_init_cmd(pcr); |
97 | |||
98 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_DRIVE_SEL, | ||
99 | 0xFF, pcr->sd30_drive_sel_3v3); | ||
100 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CD_PAD_CTL, | ||
53 | CD_DISABLE_MASK | CD_AUTO_DISABLE, CD_ENABLE); | 101 | CD_DISABLE_MASK | CD_AUTO_DISABLE, CD_ENABLE); |
102 | |||
103 | return rtsx_pci_send_cmd(pcr, 100); | ||
54 | } | 104 | } |
55 | 105 | ||
56 | static int rtl8411b_extra_init_hw(struct rtsx_pcr *pcr) | 106 | static int rtl8411b_extra_init_hw(struct rtsx_pcr *pcr) |
57 | { | 107 | { |
58 | if (rtl8411b_is_qfn48(pcr)) | 108 | rtsx_pci_init_cmd(pcr); |
59 | rtsx_pci_write_register(pcr, CARD_PULL_CTL3, 0xFF, 0xF5); | ||
60 | 109 | ||
61 | return rtsx_pci_write_register(pcr, CD_PAD_CTL, | 110 | if (rtl8411b_is_qfn48(pcr)) |
111 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, | ||
112 | CARD_PULL_CTL3, 0xFF, 0xF5); | ||
113 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_DRIVE_SEL, | ||
114 | 0xFF, pcr->sd30_drive_sel_3v3); | ||
115 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CD_PAD_CTL, | ||
62 | CD_DISABLE_MASK | CD_AUTO_DISABLE, CD_ENABLE); | 116 | CD_DISABLE_MASK | CD_AUTO_DISABLE, CD_ENABLE); |
117 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, FUNC_FORCE_CTL, | ||
118 | 0x06, 0x00); | ||
119 | |||
120 | return rtsx_pci_send_cmd(pcr, 100); | ||
63 | } | 121 | } |
64 | 122 | ||
65 | static int rtl8411_turn_on_led(struct rtsx_pcr *pcr) | 123 | static int rtl8411_turn_on_led(struct rtsx_pcr *pcr) |
@@ -141,13 +199,13 @@ static int rtl8411_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage) | |||
141 | mask = (BPP_REG_TUNED18 << BPP_TUNED18_SHIFT_8411) | BPP_PAD_MASK; | 199 | mask = (BPP_REG_TUNED18 << BPP_TUNED18_SHIFT_8411) | BPP_PAD_MASK; |
142 | if (voltage == OUTPUT_3V3) { | 200 | if (voltage == OUTPUT_3V3) { |
143 | err = rtsx_pci_write_register(pcr, | 201 | err = rtsx_pci_write_register(pcr, |
144 | SD30_DRIVE_SEL, 0x07, DRIVER_TYPE_D); | 202 | SD30_DRIVE_SEL, 0x07, pcr->sd30_drive_sel_3v3); |
145 | if (err < 0) | 203 | if (err < 0) |
146 | return err; | 204 | return err; |
147 | val = (BPP_ASIC_3V3 << BPP_TUNED18_SHIFT_8411) | BPP_PAD_3V3; | 205 | val = (BPP_ASIC_3V3 << BPP_TUNED18_SHIFT_8411) | BPP_PAD_3V3; |
148 | } else if (voltage == OUTPUT_1V8) { | 206 | } else if (voltage == OUTPUT_1V8) { |
149 | err = rtsx_pci_write_register(pcr, | 207 | err = rtsx_pci_write_register(pcr, |
150 | SD30_DRIVE_SEL, 0x07, DRIVER_TYPE_B); | 208 | SD30_DRIVE_SEL, 0x07, pcr->sd30_drive_sel_1v8); |
151 | if (err < 0) | 209 | if (err < 0) |
152 | return err; | 210 | return err; |
153 | val = (BPP_ASIC_1V8 << BPP_TUNED18_SHIFT_8411) | BPP_PAD_1V8; | 211 | val = (BPP_ASIC_1V8 << BPP_TUNED18_SHIFT_8411) | BPP_PAD_1V8; |
@@ -222,6 +280,7 @@ static int rtl8411_conv_clk_and_div_n(int input, int dir) | |||
222 | } | 280 | } |
223 | 281 | ||
224 | static const struct pcr_ops rtl8411_pcr_ops = { | 282 | static const struct pcr_ops rtl8411_pcr_ops = { |
283 | .fetch_vendor_settings = rtl8411_fetch_vendor_settings, | ||
225 | .extra_init_hw = rtl8411_extra_init_hw, | 284 | .extra_init_hw = rtl8411_extra_init_hw, |
226 | .optimize_phy = NULL, | 285 | .optimize_phy = NULL, |
227 | .turn_on_led = rtl8411_turn_on_led, | 286 | .turn_on_led = rtl8411_turn_on_led, |
@@ -233,9 +292,11 @@ static const struct pcr_ops rtl8411_pcr_ops = { | |||
233 | .switch_output_voltage = rtl8411_switch_output_voltage, | 292 | .switch_output_voltage = rtl8411_switch_output_voltage, |
234 | .cd_deglitch = rtl8411_cd_deglitch, | 293 | .cd_deglitch = rtl8411_cd_deglitch, |
235 | .conv_clk_and_div_n = rtl8411_conv_clk_and_div_n, | 294 | .conv_clk_and_div_n = rtl8411_conv_clk_and_div_n, |
295 | .force_power_down = rtl8411_force_power_down, | ||
236 | }; | 296 | }; |
237 | 297 | ||
238 | static const struct pcr_ops rtl8411b_pcr_ops = { | 298 | static const struct pcr_ops rtl8411b_pcr_ops = { |
299 | .fetch_vendor_settings = rtl8411b_fetch_vendor_settings, | ||
239 | .extra_init_hw = rtl8411b_extra_init_hw, | 300 | .extra_init_hw = rtl8411b_extra_init_hw, |
240 | .optimize_phy = NULL, | 301 | .optimize_phy = NULL, |
241 | .turn_on_led = rtl8411_turn_on_led, | 302 | .turn_on_led = rtl8411_turn_on_led, |
@@ -247,6 +308,7 @@ static const struct pcr_ops rtl8411b_pcr_ops = { | |||
247 | .switch_output_voltage = rtl8411_switch_output_voltage, | 308 | .switch_output_voltage = rtl8411_switch_output_voltage, |
248 | .cd_deglitch = rtl8411_cd_deglitch, | 309 | .cd_deglitch = rtl8411_cd_deglitch, |
249 | .conv_clk_and_div_n = rtl8411_conv_clk_and_div_n, | 310 | .conv_clk_and_div_n = rtl8411_conv_clk_and_div_n, |
311 | .force_power_down = rtl8411_force_power_down, | ||
250 | }; | 312 | }; |
251 | 313 | ||
252 | /* SD Pull Control Enable: | 314 | /* SD Pull Control Enable: |
@@ -385,6 +447,14 @@ void rtl8411_init_params(struct rtsx_pcr *pcr) | |||
385 | pcr->num_slots = 2; | 447 | pcr->num_slots = 2; |
386 | pcr->ops = &rtl8411_pcr_ops; | 448 | pcr->ops = &rtl8411_pcr_ops; |
387 | 449 | ||
450 | pcr->flags = 0; | ||
451 | pcr->card_drive_sel = RTL8411_CARD_DRIVE_DEFAULT; | ||
452 | pcr->sd30_drive_sel_1v8 = DRIVER_TYPE_B; | ||
453 | pcr->sd30_drive_sel_3v3 = DRIVER_TYPE_D; | ||
454 | pcr->aspm_en = ASPM_L1_EN; | ||
455 | pcr->tx_initial_phase = SET_CLOCK_PHASE(23, 7, 14); | ||
456 | pcr->rx_initial_phase = SET_CLOCK_PHASE(4, 3, 10); | ||
457 | |||
388 | pcr->ic_version = rtl8411_get_ic_version(pcr); | 458 | pcr->ic_version = rtl8411_get_ic_version(pcr); |
389 | pcr->sd_pull_ctl_enable_tbl = rtl8411_sd_pull_ctl_enable_tbl; | 459 | pcr->sd_pull_ctl_enable_tbl = rtl8411_sd_pull_ctl_enable_tbl; |
390 | pcr->sd_pull_ctl_disable_tbl = rtl8411_sd_pull_ctl_disable_tbl; | 460 | pcr->sd_pull_ctl_disable_tbl = rtl8411_sd_pull_ctl_disable_tbl; |
@@ -398,6 +468,14 @@ void rtl8411b_init_params(struct rtsx_pcr *pcr) | |||
398 | pcr->num_slots = 2; | 468 | pcr->num_slots = 2; |
399 | pcr->ops = &rtl8411b_pcr_ops; | 469 | pcr->ops = &rtl8411b_pcr_ops; |
400 | 470 | ||
471 | pcr->flags = 0; | ||
472 | pcr->card_drive_sel = RTL8411_CARD_DRIVE_DEFAULT; | ||
473 | pcr->sd30_drive_sel_1v8 = DRIVER_TYPE_B; | ||
474 | pcr->sd30_drive_sel_3v3 = DRIVER_TYPE_D; | ||
475 | pcr->aspm_en = ASPM_L1_EN; | ||
476 | pcr->tx_initial_phase = SET_CLOCK_PHASE(23, 7, 14); | ||
477 | pcr->rx_initial_phase = SET_CLOCK_PHASE(4, 3, 10); | ||
478 | |||
401 | pcr->ic_version = rtl8411_get_ic_version(pcr); | 479 | pcr->ic_version = rtl8411_get_ic_version(pcr); |
402 | 480 | ||
403 | if (rtl8411b_is_qfn48(pcr)) { | 481 | if (rtl8411b_is_qfn48(pcr)) { |
diff --git a/drivers/mfd/rts5209.c b/drivers/mfd/rts5209.c index ec78d9fb0879..cb04174a8924 100644 --- a/drivers/mfd/rts5209.c +++ b/drivers/mfd/rts5209.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* Driver for Realtek PCI-Express card reader | 1 | /* Driver for Realtek PCI-Express card reader |
2 | * | 2 | * |
3 | * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. | 3 | * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or modify it |
6 | * under the terms of the GNU General Public License as published by the | 6 | * under the terms of the GNU General Public License as published by the |
@@ -17,7 +17,6 @@ | |||
17 | * | 17 | * |
18 | * Author: | 18 | * Author: |
19 | * Wei WANG <wei_wang@realsil.com.cn> | 19 | * Wei WANG <wei_wang@realsil.com.cn> |
20 | * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China | ||
21 | */ | 20 | */ |
22 | 21 | ||
23 | #include <linux/module.h> | 22 | #include <linux/module.h> |
@@ -34,19 +33,34 @@ static u8 rts5209_get_ic_version(struct rtsx_pcr *pcr) | |||
34 | return val & 0x0F; | 33 | return val & 0x0F; |
35 | } | 34 | } |
36 | 35 | ||
37 | static void rts5209_init_vendor_cfg(struct rtsx_pcr *pcr) | 36 | static void rts5209_fetch_vendor_settings(struct rtsx_pcr *pcr) |
38 | { | 37 | { |
39 | u32 val; | 38 | u32 reg; |
40 | 39 | ||
41 | rtsx_pci_read_config_dword(pcr, 0x724, &val); | 40 | rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG1, ®); |
42 | dev_dbg(&(pcr->pci->dev), "Cfg 0x724: 0x%x\n", val); | 41 | dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg); |
43 | 42 | ||
44 | if (!(val & 0x80)) { | 43 | if (rts5209_vendor_setting1_valid(reg)) { |
45 | if (val & 0x08) | 44 | if (rts5209_reg_check_ms_pmos(reg)) |
46 | pcr->ms_pmos = false; | 45 | pcr->flags |= PCR_MS_PMOS; |
47 | else | 46 | pcr->aspm_en = rts5209_reg_to_aspm(reg); |
48 | pcr->ms_pmos = true; | ||
49 | } | 47 | } |
48 | |||
49 | rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG2, ®); | ||
50 | dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG2, reg); | ||
51 | |||
52 | if (rts5209_vendor_setting2_valid(reg)) { | ||
53 | pcr->sd30_drive_sel_1v8 = | ||
54 | rts5209_reg_to_sd30_drive_sel_1v8(reg); | ||
55 | pcr->sd30_drive_sel_3v3 = | ||
56 | rts5209_reg_to_sd30_drive_sel_3v3(reg); | ||
57 | pcr->card_drive_sel = rts5209_reg_to_card_drive_sel(reg); | ||
58 | } | ||
59 | } | ||
60 | |||
61 | static void rts5209_force_power_down(struct rtsx_pcr *pcr, u8 pm_state) | ||
62 | { | ||
63 | rtsx_pci_write_register(pcr, FPDCTL, 0x07, 0x07); | ||
50 | } | 64 | } |
51 | 65 | ||
52 | static int rts5209_extra_init_hw(struct rtsx_pcr *pcr) | 66 | static int rts5209_extra_init_hw(struct rtsx_pcr *pcr) |
@@ -55,8 +69,15 @@ static int rts5209_extra_init_hw(struct rtsx_pcr *pcr) | |||
55 | 69 | ||
56 | /* Turn off LED */ | 70 | /* Turn off LED */ |
57 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_GPIO, 0xFF, 0x03); | 71 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_GPIO, 0xFF, 0x03); |
72 | /* Reset ASPM state to default value */ | ||
73 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, ASPM_FORCE_CTL, 0x3F, 0); | ||
74 | /* Force CLKREQ# PIN to drive 0 to request clock */ | ||
75 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0x08, 0x08); | ||
58 | /* Configure GPIO as output */ | 76 | /* Configure GPIO as output */ |
59 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_GPIO_DIR, 0xFF, 0x03); | 77 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_GPIO_DIR, 0xFF, 0x03); |
78 | /* Configure driving */ | ||
79 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_DRIVE_SEL, | ||
80 | 0xFF, pcr->sd30_drive_sel_3v3); | ||
60 | 81 | ||
61 | return rtsx_pci_send_cmd(pcr, 100); | 82 | return rtsx_pci_send_cmd(pcr, 100); |
62 | } | 83 | } |
@@ -95,7 +116,7 @@ static int rts5209_card_power_on(struct rtsx_pcr *pcr, int card) | |||
95 | partial_pwr_on = SD_PARTIAL_POWER_ON; | 116 | partial_pwr_on = SD_PARTIAL_POWER_ON; |
96 | pwr_on = SD_POWER_ON; | 117 | pwr_on = SD_POWER_ON; |
97 | 118 | ||
98 | if (pcr->ms_pmos && (card == RTSX_MS_CARD)) { | 119 | if ((pcr->flags & PCR_MS_PMOS) && (card == RTSX_MS_CARD)) { |
99 | pwr_mask = MS_POWER_MASK; | 120 | pwr_mask = MS_POWER_MASK; |
100 | partial_pwr_on = MS_PARTIAL_POWER_ON; | 121 | partial_pwr_on = MS_PARTIAL_POWER_ON; |
101 | pwr_on = MS_POWER_ON; | 122 | pwr_on = MS_POWER_ON; |
@@ -131,7 +152,7 @@ static int rts5209_card_power_off(struct rtsx_pcr *pcr, int card) | |||
131 | pwr_mask = SD_POWER_MASK; | 152 | pwr_mask = SD_POWER_MASK; |
132 | pwr_off = SD_POWER_OFF; | 153 | pwr_off = SD_POWER_OFF; |
133 | 154 | ||
134 | if (pcr->ms_pmos && (card == RTSX_MS_CARD)) { | 155 | if ((pcr->flags & PCR_MS_PMOS) && (card == RTSX_MS_CARD)) { |
135 | pwr_mask = MS_POWER_MASK; | 156 | pwr_mask = MS_POWER_MASK; |
136 | pwr_off = MS_POWER_OFF; | 157 | pwr_off = MS_POWER_OFF; |
137 | } | 158 | } |
@@ -140,7 +161,7 @@ static int rts5209_card_power_off(struct rtsx_pcr *pcr, int card) | |||
140 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_PWR_CTL, | 161 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_PWR_CTL, |
141 | pwr_mask | PMOS_STRG_MASK, pwr_off | PMOS_STRG_400mA); | 162 | pwr_mask | PMOS_STRG_MASK, pwr_off | PMOS_STRG_400mA); |
142 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PWR_GATE_CTRL, | 163 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PWR_GATE_CTRL, |
143 | LDO3318_PWR_MASK, 0X06); | 164 | LDO3318_PWR_MASK, 0x06); |
144 | return rtsx_pci_send_cmd(pcr, 100); | 165 | return rtsx_pci_send_cmd(pcr, 100); |
145 | } | 166 | } |
146 | 167 | ||
@@ -150,7 +171,7 @@ static int rts5209_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage) | |||
150 | 171 | ||
151 | if (voltage == OUTPUT_3V3) { | 172 | if (voltage == OUTPUT_3V3) { |
152 | err = rtsx_pci_write_register(pcr, | 173 | err = rtsx_pci_write_register(pcr, |
153 | SD30_DRIVE_SEL, 0x07, DRIVER_TYPE_D); | 174 | SD30_DRIVE_SEL, 0x07, pcr->sd30_drive_sel_3v3); |
154 | if (err < 0) | 175 | if (err < 0) |
155 | return err; | 176 | return err; |
156 | err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4FC0 | 0x24); | 177 | err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4FC0 | 0x24); |
@@ -158,7 +179,7 @@ static int rts5209_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage) | |||
158 | return err; | 179 | return err; |
159 | } else if (voltage == OUTPUT_1V8) { | 180 | } else if (voltage == OUTPUT_1V8) { |
160 | err = rtsx_pci_write_register(pcr, | 181 | err = rtsx_pci_write_register(pcr, |
161 | SD30_DRIVE_SEL, 0x07, DRIVER_TYPE_B); | 182 | SD30_DRIVE_SEL, 0x07, pcr->sd30_drive_sel_1v8); |
162 | if (err < 0) | 183 | if (err < 0) |
163 | return err; | 184 | return err; |
164 | err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4C40 | 0x24); | 185 | err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4C40 | 0x24); |
@@ -172,6 +193,7 @@ static int rts5209_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage) | |||
172 | } | 193 | } |
173 | 194 | ||
174 | static const struct pcr_ops rts5209_pcr_ops = { | 195 | static const struct pcr_ops rts5209_pcr_ops = { |
196 | .fetch_vendor_settings = rts5209_fetch_vendor_settings, | ||
175 | .extra_init_hw = rts5209_extra_init_hw, | 197 | .extra_init_hw = rts5209_extra_init_hw, |
176 | .optimize_phy = rts5209_optimize_phy, | 198 | .optimize_phy = rts5209_optimize_phy, |
177 | .turn_on_led = rts5209_turn_on_led, | 199 | .turn_on_led = rts5209_turn_on_led, |
@@ -183,6 +205,7 @@ static const struct pcr_ops rts5209_pcr_ops = { | |||
183 | .switch_output_voltage = rts5209_switch_output_voltage, | 205 | .switch_output_voltage = rts5209_switch_output_voltage, |
184 | .cd_deglitch = NULL, | 206 | .cd_deglitch = NULL, |
185 | .conv_clk_and_div_n = NULL, | 207 | .conv_clk_and_div_n = NULL, |
208 | .force_power_down = rts5209_force_power_down, | ||
186 | }; | 209 | }; |
187 | 210 | ||
188 | /* SD Pull Control Enable: | 211 | /* SD Pull Control Enable: |
@@ -242,7 +265,13 @@ void rts5209_init_params(struct rtsx_pcr *pcr) | |||
242 | pcr->num_slots = 2; | 265 | pcr->num_slots = 2; |
243 | pcr->ops = &rts5209_pcr_ops; | 266 | pcr->ops = &rts5209_pcr_ops; |
244 | 267 | ||
245 | rts5209_init_vendor_cfg(pcr); | 268 | pcr->flags = 0; |
269 | pcr->card_drive_sel = RTS5209_CARD_DRIVE_DEFAULT; | ||
270 | pcr->sd30_drive_sel_1v8 = DRIVER_TYPE_B; | ||
271 | pcr->sd30_drive_sel_3v3 = DRIVER_TYPE_D; | ||
272 | pcr->aspm_en = ASPM_L1_EN; | ||
273 | pcr->tx_initial_phase = SET_CLOCK_PHASE(27, 27, 16); | ||
274 | pcr->rx_initial_phase = SET_CLOCK_PHASE(24, 6, 5); | ||
246 | 275 | ||
247 | pcr->ic_version = rts5209_get_ic_version(pcr); | 276 | pcr->ic_version = rts5209_get_ic_version(pcr); |
248 | pcr->sd_pull_ctl_enable_tbl = rts5209_sd_pull_ctl_enable_tbl; | 277 | pcr->sd_pull_ctl_enable_tbl = rts5209_sd_pull_ctl_enable_tbl; |
diff --git a/drivers/mfd/rts5227.c b/drivers/mfd/rts5227.c index 164b7faa70c9..9c8eec80ceed 100644 --- a/drivers/mfd/rts5227.c +++ b/drivers/mfd/rts5227.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* Driver for Realtek PCI-Express card reader | 1 | /* Driver for Realtek PCI-Express card reader |
2 | * | 2 | * |
3 | * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. | 3 | * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or modify it |
6 | * under the terms of the GNU General Public License as published by the | 6 | * under the terms of the GNU General Public License as published by the |
@@ -17,10 +17,7 @@ | |||
17 | * | 17 | * |
18 | * Author: | 18 | * Author: |
19 | * Wei WANG <wei_wang@realsil.com.cn> | 19 | * Wei WANG <wei_wang@realsil.com.cn> |
20 | * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China | ||
21 | * | ||
22 | * Roger Tseng <rogerable@realtek.com> | 20 | * Roger Tseng <rogerable@realtek.com> |
23 | * No. 2, Innovation Road II, Hsinchu Science Park, Hsinchu 300, Taiwan | ||
24 | */ | 21 | */ |
25 | 22 | ||
26 | #include <linux/module.h> | 23 | #include <linux/module.h> |
@@ -29,6 +26,73 @@ | |||
29 | 26 | ||
30 | #include "rtsx_pcr.h" | 27 | #include "rtsx_pcr.h" |
31 | 28 | ||
29 | static void rts5227_fill_driving(struct rtsx_pcr *pcr, u8 voltage) | ||
30 | { | ||
31 | u8 driving_3v3[4][3] = { | ||
32 | {0x13, 0x13, 0x13}, | ||
33 | {0x96, 0x96, 0x96}, | ||
34 | {0x7F, 0x7F, 0x7F}, | ||
35 | {0x96, 0x96, 0x96}, | ||
36 | }; | ||
37 | u8 driving_1v8[4][3] = { | ||
38 | {0x99, 0x99, 0x99}, | ||
39 | {0xAA, 0xAA, 0xAA}, | ||
40 | {0xFE, 0xFE, 0xFE}, | ||
41 | {0xB3, 0xB3, 0xB3}, | ||
42 | }; | ||
43 | u8 (*driving)[3], drive_sel; | ||
44 | |||
45 | if (voltage == OUTPUT_3V3) { | ||
46 | driving = driving_3v3; | ||
47 | drive_sel = pcr->sd30_drive_sel_3v3; | ||
48 | } else { | ||
49 | driving = driving_1v8; | ||
50 | drive_sel = pcr->sd30_drive_sel_1v8; | ||
51 | } | ||
52 | |||
53 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_CLK_DRIVE_SEL, | ||
54 | 0xFF, driving[drive_sel][0]); | ||
55 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_CMD_DRIVE_SEL, | ||
56 | 0xFF, driving[drive_sel][1]); | ||
57 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_DAT_DRIVE_SEL, | ||
58 | 0xFF, driving[drive_sel][2]); | ||
59 | } | ||
60 | |||
61 | static void rts5227_fetch_vendor_settings(struct rtsx_pcr *pcr) | ||
62 | { | ||
63 | u32 reg; | ||
64 | |||
65 | rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG1, ®); | ||
66 | dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg); | ||
67 | |||
68 | if (!rtsx_vendor_setting_valid(reg)) | ||
69 | return; | ||
70 | |||
71 | pcr->aspm_en = rtsx_reg_to_aspm(reg); | ||
72 | pcr->sd30_drive_sel_1v8 = rtsx_reg_to_sd30_drive_sel_1v8(reg); | ||
73 | pcr->card_drive_sel &= 0x3F; | ||
74 | pcr->card_drive_sel |= rtsx_reg_to_card_drive_sel(reg); | ||
75 | |||
76 | rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG2, ®); | ||
77 | dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG2, reg); | ||
78 | pcr->sd30_drive_sel_3v3 = rtsx_reg_to_sd30_drive_sel_3v3(reg); | ||
79 | if (rtsx_reg_check_reverse_socket(reg)) | ||
80 | pcr->flags |= PCR_REVERSE_SOCKET; | ||
81 | } | ||
82 | |||
83 | static void rts5227_force_power_down(struct rtsx_pcr *pcr, u8 pm_state) | ||
84 | { | ||
85 | /* Set relink_time to 0 */ | ||
86 | rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 1, 0xFF, 0); | ||
87 | rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 2, 0xFF, 0); | ||
88 | rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 3, 0x01, 0); | ||
89 | |||
90 | if (pm_state == HOST_ENTER_S3) | ||
91 | rtsx_pci_write_register(pcr, PM_CTRL3, 0x10, 0x10); | ||
92 | |||
93 | rtsx_pci_write_register(pcr, FPDCTL, 0x03, 0x03); | ||
94 | } | ||
95 | |||
32 | static int rts5227_extra_init_hw(struct rtsx_pcr *pcr) | 96 | static int rts5227_extra_init_hw(struct rtsx_pcr *pcr) |
33 | { | 97 | { |
34 | u16 cap; | 98 | u16 cap; |
@@ -37,6 +101,8 @@ static int rts5227_extra_init_hw(struct rtsx_pcr *pcr) | |||
37 | 101 | ||
38 | /* Configure GPIO as output */ | 102 | /* Configure GPIO as output */ |
39 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, GPIO_CTL, 0x02, 0x02); | 103 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, GPIO_CTL, 0x02, 0x02); |
104 | /* Reset ASPM state to default value */ | ||
105 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, ASPM_FORCE_CTL, 0x3F, 0); | ||
40 | /* Switch LDO3318 source from DV33 to card_3v3 */ | 106 | /* Switch LDO3318 source from DV33 to card_3v3 */ |
41 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LDO_PWR_SEL, 0x03, 0x00); | 107 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LDO_PWR_SEL, 0x03, 0x00); |
42 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LDO_PWR_SEL, 0x03, 0x01); | 108 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LDO_PWR_SEL, 0x03, 0x01); |
@@ -48,17 +114,16 @@ static int rts5227_extra_init_hw(struct rtsx_pcr *pcr) | |||
48 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LTR_CTL, 0xFF, 0xA3); | 114 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LTR_CTL, 0xFF, 0xA3); |
49 | /* Configure OBFF */ | 115 | /* Configure OBFF */ |
50 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, OBFF_CFG, 0x03, 0x03); | 116 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, OBFF_CFG, 0x03, 0x03); |
51 | /* Configure force_clock_req | 117 | /* Configure driving */ |
52 | * Maybe We should define 0xFF03 as some name | 118 | rts5227_fill_driving(pcr, OUTPUT_3V3); |
53 | */ | 119 | /* Configure force_clock_req */ |
54 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, 0xFF03, 0x08, 0x08); | 120 | if (pcr->flags & PCR_REVERSE_SOCKET) |
55 | /* Correct driving */ | 121 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, |
56 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, | 122 | AUTOLOAD_CFG_BASE + 3, 0xB8, 0xB8); |
57 | SD30_CLK_DRIVE_SEL, 0xFF, 0x96); | 123 | else |
58 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, | 124 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, |
59 | SD30_CMD_DRIVE_SEL, 0xFF, 0x96); | 125 | AUTOLOAD_CFG_BASE + 3, 0xB8, 0x88); |
60 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, | 126 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PM_CTRL3, 0x10, 0x00); |
61 | SD30_DAT_DRIVE_SEL, 0xFF, 0x96); | ||
62 | 127 | ||
63 | return rtsx_pci_send_cmd(pcr, 100); | 128 | return rtsx_pci_send_cmd(pcr, 100); |
64 | } | 129 | } |
@@ -131,13 +196,11 @@ static int rts5227_card_power_off(struct rtsx_pcr *pcr, int card) | |||
131 | static int rts5227_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage) | 196 | static int rts5227_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage) |
132 | { | 197 | { |
133 | int err; | 198 | int err; |
134 | u8 drive_sel; | ||
135 | 199 | ||
136 | if (voltage == OUTPUT_3V3) { | 200 | if (voltage == OUTPUT_3V3) { |
137 | err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4FC0 | 0x24); | 201 | err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4FC0 | 0x24); |
138 | if (err < 0) | 202 | if (err < 0) |
139 | return err; | 203 | return err; |
140 | drive_sel = 0x96; | ||
141 | } else if (voltage == OUTPUT_1V8) { | 204 | } else if (voltage == OUTPUT_1V8) { |
142 | err = rtsx_pci_write_phy_register(pcr, 0x11, 0x3C02); | 205 | err = rtsx_pci_write_phy_register(pcr, 0x11, 0x3C02); |
143 | if (err < 0) | 206 | if (err < 0) |
@@ -145,23 +208,18 @@ static int rts5227_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage) | |||
145 | err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4C80 | 0x24); | 208 | err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4C80 | 0x24); |
146 | if (err < 0) | 209 | if (err < 0) |
147 | return err; | 210 | return err; |
148 | drive_sel = 0xB3; | ||
149 | } else { | 211 | } else { |
150 | return -EINVAL; | 212 | return -EINVAL; |
151 | } | 213 | } |
152 | 214 | ||
153 | /* set pad drive */ | 215 | /* set pad drive */ |
154 | rtsx_pci_init_cmd(pcr); | 216 | rtsx_pci_init_cmd(pcr); |
155 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_CLK_DRIVE_SEL, | 217 | rts5227_fill_driving(pcr, voltage); |
156 | 0xFF, drive_sel); | ||
157 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_CMD_DRIVE_SEL, | ||
158 | 0xFF, drive_sel); | ||
159 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_DAT_DRIVE_SEL, | ||
160 | 0xFF, drive_sel); | ||
161 | return rtsx_pci_send_cmd(pcr, 100); | 218 | return rtsx_pci_send_cmd(pcr, 100); |
162 | } | 219 | } |
163 | 220 | ||
164 | static const struct pcr_ops rts5227_pcr_ops = { | 221 | static const struct pcr_ops rts5227_pcr_ops = { |
222 | .fetch_vendor_settings = rts5227_fetch_vendor_settings, | ||
165 | .extra_init_hw = rts5227_extra_init_hw, | 223 | .extra_init_hw = rts5227_extra_init_hw, |
166 | .optimize_phy = rts5227_optimize_phy, | 224 | .optimize_phy = rts5227_optimize_phy, |
167 | .turn_on_led = rts5227_turn_on_led, | 225 | .turn_on_led = rts5227_turn_on_led, |
@@ -173,6 +231,7 @@ static const struct pcr_ops rts5227_pcr_ops = { | |||
173 | .switch_output_voltage = rts5227_switch_output_voltage, | 231 | .switch_output_voltage = rts5227_switch_output_voltage, |
174 | .cd_deglitch = NULL, | 232 | .cd_deglitch = NULL, |
175 | .conv_clk_and_div_n = NULL, | 233 | .conv_clk_and_div_n = NULL, |
234 | .force_power_down = rts5227_force_power_down, | ||
176 | }; | 235 | }; |
177 | 236 | ||
178 | /* SD Pull Control Enable: | 237 | /* SD Pull Control Enable: |
@@ -227,6 +286,14 @@ void rts5227_init_params(struct rtsx_pcr *pcr) | |||
227 | pcr->num_slots = 2; | 286 | pcr->num_slots = 2; |
228 | pcr->ops = &rts5227_pcr_ops; | 287 | pcr->ops = &rts5227_pcr_ops; |
229 | 288 | ||
289 | pcr->flags = 0; | ||
290 | pcr->card_drive_sel = RTSX_CARD_DRIVE_DEFAULT; | ||
291 | pcr->sd30_drive_sel_1v8 = CFG_DRIVER_TYPE_B; | ||
292 | pcr->sd30_drive_sel_3v3 = CFG_DRIVER_TYPE_B; | ||
293 | pcr->aspm_en = ASPM_L1_EN; | ||
294 | pcr->tx_initial_phase = SET_CLOCK_PHASE(27, 27, 15); | ||
295 | pcr->rx_initial_phase = SET_CLOCK_PHASE(30, 7, 7); | ||
296 | |||
230 | pcr->sd_pull_ctl_enable_tbl = rts5227_sd_pull_ctl_enable_tbl; | 297 | pcr->sd_pull_ctl_enable_tbl = rts5227_sd_pull_ctl_enable_tbl; |
231 | pcr->sd_pull_ctl_disable_tbl = rts5227_sd_pull_ctl_disable_tbl; | 298 | pcr->sd_pull_ctl_disable_tbl = rts5227_sd_pull_ctl_disable_tbl; |
232 | pcr->ms_pull_ctl_enable_tbl = rts5227_ms_pull_ctl_enable_tbl; | 299 | pcr->ms_pull_ctl_enable_tbl = rts5227_ms_pull_ctl_enable_tbl; |
diff --git a/drivers/mfd/rts5229.c b/drivers/mfd/rts5229.c index 58af4dbe3586..6353f5df087a 100644 --- a/drivers/mfd/rts5229.c +++ b/drivers/mfd/rts5229.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* Driver for Realtek PCI-Express card reader | 1 | /* Driver for Realtek PCI-Express card reader |
2 | * | 2 | * |
3 | * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. | 3 | * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or modify it |
6 | * under the terms of the GNU General Public License as published by the | 6 | * under the terms of the GNU General Public License as published by the |
@@ -17,7 +17,6 @@ | |||
17 | * | 17 | * |
18 | * Author: | 18 | * Author: |
19 | * Wei WANG <wei_wang@realsil.com.cn> | 19 | * Wei WANG <wei_wang@realsil.com.cn> |
20 | * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China | ||
21 | */ | 20 | */ |
22 | 21 | ||
23 | #include <linux/module.h> | 22 | #include <linux/module.h> |
@@ -34,17 +33,51 @@ static u8 rts5229_get_ic_version(struct rtsx_pcr *pcr) | |||
34 | return val & 0x0F; | 33 | return val & 0x0F; |
35 | } | 34 | } |
36 | 35 | ||
36 | static void rts5229_fetch_vendor_settings(struct rtsx_pcr *pcr) | ||
37 | { | ||
38 | u32 reg; | ||
39 | |||
40 | rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG1, ®); | ||
41 | dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg); | ||
42 | |||
43 | if (!rtsx_vendor_setting_valid(reg)) | ||
44 | return; | ||
45 | |||
46 | pcr->aspm_en = rtsx_reg_to_aspm(reg); | ||
47 | pcr->sd30_drive_sel_1v8 = | ||
48 | map_sd_drive(rtsx_reg_to_sd30_drive_sel_1v8(reg)); | ||
49 | pcr->card_drive_sel &= 0x3F; | ||
50 | pcr->card_drive_sel |= rtsx_reg_to_card_drive_sel(reg); | ||
51 | |||
52 | rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG2, ®); | ||
53 | dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG2, reg); | ||
54 | pcr->sd30_drive_sel_3v3 = | ||
55 | map_sd_drive(rtsx_reg_to_sd30_drive_sel_3v3(reg)); | ||
56 | } | ||
57 | |||
58 | static void rts5229_force_power_down(struct rtsx_pcr *pcr, u8 pm_state) | ||
59 | { | ||
60 | rtsx_pci_write_register(pcr, FPDCTL, 0x03, 0x03); | ||
61 | } | ||
62 | |||
37 | static int rts5229_extra_init_hw(struct rtsx_pcr *pcr) | 63 | static int rts5229_extra_init_hw(struct rtsx_pcr *pcr) |
38 | { | 64 | { |
39 | rtsx_pci_init_cmd(pcr); | 65 | rtsx_pci_init_cmd(pcr); |
40 | 66 | ||
41 | /* Configure GPIO as output */ | 67 | /* Configure GPIO as output */ |
42 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, GPIO_CTL, 0x02, 0x02); | 68 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, GPIO_CTL, 0x02, 0x02); |
69 | /* Reset ASPM state to default value */ | ||
70 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, ASPM_FORCE_CTL, 0x3F, 0); | ||
71 | /* Force CLKREQ# PIN to drive 0 to request clock */ | ||
72 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0x08, 0x08); | ||
43 | /* Switch LDO3318 source from DV33 to card_3v3 */ | 73 | /* Switch LDO3318 source from DV33 to card_3v3 */ |
44 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LDO_PWR_SEL, 0x03, 0x00); | 74 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LDO_PWR_SEL, 0x03, 0x00); |
45 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LDO_PWR_SEL, 0x03, 0x01); | 75 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LDO_PWR_SEL, 0x03, 0x01); |
46 | /* LED shine disabled, set initial shine cycle period */ | 76 | /* LED shine disabled, set initial shine cycle period */ |
47 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, OLT_LED_CTL, 0x0F, 0x02); | 77 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, OLT_LED_CTL, 0x0F, 0x02); |
78 | /* Configure driving */ | ||
79 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_DRIVE_SEL, | ||
80 | 0xFF, pcr->sd30_drive_sel_3v3); | ||
48 | 81 | ||
49 | return rtsx_pci_send_cmd(pcr, 100); | 82 | return rtsx_pci_send_cmd(pcr, 100); |
50 | } | 83 | } |
@@ -110,7 +143,7 @@ static int rts5229_card_power_off(struct rtsx_pcr *pcr, int card) | |||
110 | SD_POWER_MASK | PMOS_STRG_MASK, | 143 | SD_POWER_MASK | PMOS_STRG_MASK, |
111 | SD_POWER_OFF | PMOS_STRG_400mA); | 144 | SD_POWER_OFF | PMOS_STRG_400mA); |
112 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PWR_GATE_CTRL, | 145 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PWR_GATE_CTRL, |
113 | LDO3318_PWR_MASK, 0X00); | 146 | LDO3318_PWR_MASK, 0x00); |
114 | return rtsx_pci_send_cmd(pcr, 100); | 147 | return rtsx_pci_send_cmd(pcr, 100); |
115 | } | 148 | } |
116 | 149 | ||
@@ -120,7 +153,7 @@ static int rts5229_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage) | |||
120 | 153 | ||
121 | if (voltage == OUTPUT_3V3) { | 154 | if (voltage == OUTPUT_3V3) { |
122 | err = rtsx_pci_write_register(pcr, | 155 | err = rtsx_pci_write_register(pcr, |
123 | SD30_DRIVE_SEL, 0x07, DRIVER_TYPE_D); | 156 | SD30_DRIVE_SEL, 0x07, pcr->sd30_drive_sel_3v3); |
124 | if (err < 0) | 157 | if (err < 0) |
125 | return err; | 158 | return err; |
126 | err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4FC0 | 0x24); | 159 | err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4FC0 | 0x24); |
@@ -128,7 +161,7 @@ static int rts5229_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage) | |||
128 | return err; | 161 | return err; |
129 | } else if (voltage == OUTPUT_1V8) { | 162 | } else if (voltage == OUTPUT_1V8) { |
130 | err = rtsx_pci_write_register(pcr, | 163 | err = rtsx_pci_write_register(pcr, |
131 | SD30_DRIVE_SEL, 0x07, DRIVER_TYPE_B); | 164 | SD30_DRIVE_SEL, 0x07, pcr->sd30_drive_sel_1v8); |
132 | if (err < 0) | 165 | if (err < 0) |
133 | return err; | 166 | return err; |
134 | err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4C40 | 0x24); | 167 | err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4C40 | 0x24); |
@@ -142,6 +175,7 @@ static int rts5229_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage) | |||
142 | } | 175 | } |
143 | 176 | ||
144 | static const struct pcr_ops rts5229_pcr_ops = { | 177 | static const struct pcr_ops rts5229_pcr_ops = { |
178 | .fetch_vendor_settings = rts5229_fetch_vendor_settings, | ||
145 | .extra_init_hw = rts5229_extra_init_hw, | 179 | .extra_init_hw = rts5229_extra_init_hw, |
146 | .optimize_phy = rts5229_optimize_phy, | 180 | .optimize_phy = rts5229_optimize_phy, |
147 | .turn_on_led = rts5229_turn_on_led, | 181 | .turn_on_led = rts5229_turn_on_led, |
@@ -153,6 +187,7 @@ static const struct pcr_ops rts5229_pcr_ops = { | |||
153 | .switch_output_voltage = rts5229_switch_output_voltage, | 187 | .switch_output_voltage = rts5229_switch_output_voltage, |
154 | .cd_deglitch = NULL, | 188 | .cd_deglitch = NULL, |
155 | .conv_clk_and_div_n = NULL, | 189 | .conv_clk_and_div_n = NULL, |
190 | .force_power_down = rts5229_force_power_down, | ||
156 | }; | 191 | }; |
157 | 192 | ||
158 | /* SD Pull Control Enable: | 193 | /* SD Pull Control Enable: |
@@ -221,6 +256,14 @@ void rts5229_init_params(struct rtsx_pcr *pcr) | |||
221 | pcr->num_slots = 2; | 256 | pcr->num_slots = 2; |
222 | pcr->ops = &rts5229_pcr_ops; | 257 | pcr->ops = &rts5229_pcr_ops; |
223 | 258 | ||
259 | pcr->flags = 0; | ||
260 | pcr->card_drive_sel = RTSX_CARD_DRIVE_DEFAULT; | ||
261 | pcr->sd30_drive_sel_1v8 = DRIVER_TYPE_B; | ||
262 | pcr->sd30_drive_sel_3v3 = DRIVER_TYPE_D; | ||
263 | pcr->aspm_en = ASPM_L1_EN; | ||
264 | pcr->tx_initial_phase = SET_CLOCK_PHASE(27, 27, 15); | ||
265 | pcr->rx_initial_phase = SET_CLOCK_PHASE(30, 6, 6); | ||
266 | |||
224 | pcr->ic_version = rts5229_get_ic_version(pcr); | 267 | pcr->ic_version = rts5229_get_ic_version(pcr); |
225 | if (pcr->ic_version == IC_VER_C) { | 268 | if (pcr->ic_version == IC_VER_C) { |
226 | pcr->sd_pull_ctl_enable_tbl = rts5229_sd_pull_ctl_enable_tbl2; | 269 | pcr->sd_pull_ctl_enable_tbl = rts5229_sd_pull_ctl_enable_tbl2; |
diff --git a/drivers/mfd/rts5249.c b/drivers/mfd/rts5249.c index 15dc848bc081..3b835f593e35 100644 --- a/drivers/mfd/rts5249.c +++ b/drivers/mfd/rts5249.c | |||
@@ -17,7 +17,6 @@ | |||
17 | * | 17 | * |
18 | * Author: | 18 | * Author: |
19 | * Wei WANG <wei_wang@realsil.com.cn> | 19 | * Wei WANG <wei_wang@realsil.com.cn> |
20 | * No. 128, West Shenhu Road, Suzhou Industry Park, Suzhou, China | ||
21 | */ | 20 | */ |
22 | 21 | ||
23 | #include <linux/module.h> | 22 | #include <linux/module.h> |
@@ -34,24 +33,95 @@ static u8 rts5249_get_ic_version(struct rtsx_pcr *pcr) | |||
34 | return val & 0x0F; | 33 | return val & 0x0F; |
35 | } | 34 | } |
36 | 35 | ||
36 | static void rts5249_fill_driving(struct rtsx_pcr *pcr, u8 voltage) | ||
37 | { | ||
38 | u8 driving_3v3[4][3] = { | ||
39 | {0x11, 0x11, 0x11}, | ||
40 | {0x55, 0x55, 0x5C}, | ||
41 | {0x99, 0x99, 0x92}, | ||
42 | {0x99, 0x99, 0x92}, | ||
43 | }; | ||
44 | u8 driving_1v8[4][3] = { | ||
45 | {0x3C, 0x3C, 0x3C}, | ||
46 | {0xB3, 0xB3, 0xB3}, | ||
47 | {0xFE, 0xFE, 0xFE}, | ||
48 | {0xC4, 0xC4, 0xC4}, | ||
49 | }; | ||
50 | u8 (*driving)[3], drive_sel; | ||
51 | |||
52 | if (voltage == OUTPUT_3V3) { | ||
53 | driving = driving_3v3; | ||
54 | drive_sel = pcr->sd30_drive_sel_3v3; | ||
55 | } else { | ||
56 | driving = driving_1v8; | ||
57 | drive_sel = pcr->sd30_drive_sel_1v8; | ||
58 | } | ||
59 | |||
60 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_CLK_DRIVE_SEL, | ||
61 | 0xFF, driving[drive_sel][0]); | ||
62 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_CMD_DRIVE_SEL, | ||
63 | 0xFF, driving[drive_sel][1]); | ||
64 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_DAT_DRIVE_SEL, | ||
65 | 0xFF, driving[drive_sel][2]); | ||
66 | } | ||
67 | |||
68 | static void rts5249_fetch_vendor_settings(struct rtsx_pcr *pcr) | ||
69 | { | ||
70 | u32 reg; | ||
71 | |||
72 | rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG1, ®); | ||
73 | dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg); | ||
74 | |||
75 | if (!rtsx_vendor_setting_valid(reg)) | ||
76 | return; | ||
77 | |||
78 | pcr->aspm_en = rtsx_reg_to_aspm(reg); | ||
79 | pcr->sd30_drive_sel_1v8 = rtsx_reg_to_sd30_drive_sel_1v8(reg); | ||
80 | pcr->card_drive_sel &= 0x3F; | ||
81 | pcr->card_drive_sel |= rtsx_reg_to_card_drive_sel(reg); | ||
82 | |||
83 | rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG2, ®); | ||
84 | dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG2, reg); | ||
85 | pcr->sd30_drive_sel_3v3 = rtsx_reg_to_sd30_drive_sel_3v3(reg); | ||
86 | if (rtsx_reg_check_reverse_socket(reg)) | ||
87 | pcr->flags |= PCR_REVERSE_SOCKET; | ||
88 | } | ||
89 | |||
90 | static void rts5249_force_power_down(struct rtsx_pcr *pcr, u8 pm_state) | ||
91 | { | ||
92 | /* Set relink_time to 0 */ | ||
93 | rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 1, 0xFF, 0); | ||
94 | rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 2, 0xFF, 0); | ||
95 | rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 3, 0x01, 0); | ||
96 | |||
97 | if (pm_state == HOST_ENTER_S3) | ||
98 | rtsx_pci_write_register(pcr, PM_CTRL3, 0x10, 0x10); | ||
99 | |||
100 | rtsx_pci_write_register(pcr, FPDCTL, 0x03, 0x03); | ||
101 | } | ||
102 | |||
37 | static int rts5249_extra_init_hw(struct rtsx_pcr *pcr) | 103 | static int rts5249_extra_init_hw(struct rtsx_pcr *pcr) |
38 | { | 104 | { |
39 | rtsx_pci_init_cmd(pcr); | 105 | rtsx_pci_init_cmd(pcr); |
40 | 106 | ||
41 | /* Configure GPIO as output */ | 107 | /* Configure GPIO as output */ |
42 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, GPIO_CTL, 0x02, 0x02); | 108 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, GPIO_CTL, 0x02, 0x02); |
109 | /* Reset ASPM state to default value */ | ||
110 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, ASPM_FORCE_CTL, 0x3F, 0); | ||
43 | /* Switch LDO3318 source from DV33 to card_3v3 */ | 111 | /* Switch LDO3318 source from DV33 to card_3v3 */ |
44 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LDO_PWR_SEL, 0x03, 0x00); | 112 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LDO_PWR_SEL, 0x03, 0x00); |
45 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LDO_PWR_SEL, 0x03, 0x01); | 113 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LDO_PWR_SEL, 0x03, 0x01); |
46 | /* LED shine disabled, set initial shine cycle period */ | 114 | /* LED shine disabled, set initial shine cycle period */ |
47 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, OLT_LED_CTL, 0x0F, 0x02); | 115 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, OLT_LED_CTL, 0x0F, 0x02); |
48 | /* Correct driving */ | 116 | /* Configure driving */ |
49 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, | 117 | rts5249_fill_driving(pcr, OUTPUT_3V3); |
50 | SD30_CLK_DRIVE_SEL, 0xFF, 0x99); | 118 | if (pcr->flags & PCR_REVERSE_SOCKET) |
51 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, | 119 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, |
52 | SD30_CMD_DRIVE_SEL, 0xFF, 0x99); | 120 | AUTOLOAD_CFG_BASE + 3, 0xB0, 0xB0); |
53 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, | 121 | else |
54 | SD30_DAT_DRIVE_SEL, 0xFF, 0x92); | 122 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, |
123 | AUTOLOAD_CFG_BASE + 3, 0xB0, 0x80); | ||
124 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PM_CTRL3, 0x10, 0x00); | ||
55 | 125 | ||
56 | return rtsx_pci_send_cmd(pcr, 100); | 126 | return rtsx_pci_send_cmd(pcr, 100); |
57 | } | 127 | } |
@@ -129,15 +199,11 @@ static int rts5249_card_power_off(struct rtsx_pcr *pcr, int card) | |||
129 | static int rts5249_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage) | 199 | static int rts5249_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage) |
130 | { | 200 | { |
131 | int err; | 201 | int err; |
132 | u8 clk_drive, cmd_drive, dat_drive; | ||
133 | 202 | ||
134 | if (voltage == OUTPUT_3V3) { | 203 | if (voltage == OUTPUT_3V3) { |
135 | err = rtsx_pci_write_phy_register(pcr, PHY_TUNE, 0x4FC0 | 0x24); | 204 | err = rtsx_pci_write_phy_register(pcr, PHY_TUNE, 0x4FC0 | 0x24); |
136 | if (err < 0) | 205 | if (err < 0) |
137 | return err; | 206 | return err; |
138 | clk_drive = 0x99; | ||
139 | cmd_drive = 0x99; | ||
140 | dat_drive = 0x92; | ||
141 | } else if (voltage == OUTPUT_1V8) { | 207 | } else if (voltage == OUTPUT_1V8) { |
142 | err = rtsx_pci_write_phy_register(pcr, PHY_BACR, 0x3C02); | 208 | err = rtsx_pci_write_phy_register(pcr, PHY_BACR, 0x3C02); |
143 | if (err < 0) | 209 | if (err < 0) |
@@ -145,25 +211,18 @@ static int rts5249_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage) | |||
145 | err = rtsx_pci_write_phy_register(pcr, PHY_TUNE, 0x4C40 | 0x24); | 211 | err = rtsx_pci_write_phy_register(pcr, PHY_TUNE, 0x4C40 | 0x24); |
146 | if (err < 0) | 212 | if (err < 0) |
147 | return err; | 213 | return err; |
148 | clk_drive = 0xb3; | ||
149 | cmd_drive = 0xb3; | ||
150 | dat_drive = 0xb3; | ||
151 | } else { | 214 | } else { |
152 | return -EINVAL; | 215 | return -EINVAL; |
153 | } | 216 | } |
154 | 217 | ||
155 | /* set pad drive */ | 218 | /* set pad drive */ |
156 | rtsx_pci_init_cmd(pcr); | 219 | rtsx_pci_init_cmd(pcr); |
157 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_CLK_DRIVE_SEL, | 220 | rts5249_fill_driving(pcr, voltage); |
158 | 0xFF, clk_drive); | ||
159 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_CMD_DRIVE_SEL, | ||
160 | 0xFF, cmd_drive); | ||
161 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_DAT_DRIVE_SEL, | ||
162 | 0xFF, dat_drive); | ||
163 | return rtsx_pci_send_cmd(pcr, 100); | 221 | return rtsx_pci_send_cmd(pcr, 100); |
164 | } | 222 | } |
165 | 223 | ||
166 | static const struct pcr_ops rts5249_pcr_ops = { | 224 | static const struct pcr_ops rts5249_pcr_ops = { |
225 | .fetch_vendor_settings = rts5249_fetch_vendor_settings, | ||
167 | .extra_init_hw = rts5249_extra_init_hw, | 226 | .extra_init_hw = rts5249_extra_init_hw, |
168 | .optimize_phy = rts5249_optimize_phy, | 227 | .optimize_phy = rts5249_optimize_phy, |
169 | .turn_on_led = rts5249_turn_on_led, | 228 | .turn_on_led = rts5249_turn_on_led, |
@@ -173,6 +232,7 @@ static const struct pcr_ops rts5249_pcr_ops = { | |||
173 | .card_power_on = rts5249_card_power_on, | 232 | .card_power_on = rts5249_card_power_on, |
174 | .card_power_off = rts5249_card_power_off, | 233 | .card_power_off = rts5249_card_power_off, |
175 | .switch_output_voltage = rts5249_switch_output_voltage, | 234 | .switch_output_voltage = rts5249_switch_output_voltage, |
235 | .force_power_down = rts5249_force_power_down, | ||
176 | }; | 236 | }; |
177 | 237 | ||
178 | /* SD Pull Control Enable: | 238 | /* SD Pull Control Enable: |
@@ -233,6 +293,14 @@ void rts5249_init_params(struct rtsx_pcr *pcr) | |||
233 | pcr->num_slots = 2; | 293 | pcr->num_slots = 2; |
234 | pcr->ops = &rts5249_pcr_ops; | 294 | pcr->ops = &rts5249_pcr_ops; |
235 | 295 | ||
296 | pcr->flags = 0; | ||
297 | pcr->card_drive_sel = RTSX_CARD_DRIVE_DEFAULT; | ||
298 | pcr->sd30_drive_sel_1v8 = CFG_DRIVER_TYPE_C; | ||
299 | pcr->sd30_drive_sel_3v3 = CFG_DRIVER_TYPE_B; | ||
300 | pcr->aspm_en = ASPM_L1_EN; | ||
301 | pcr->tx_initial_phase = SET_CLOCK_PHASE(1, 29, 16); | ||
302 | pcr->rx_initial_phase = SET_CLOCK_PHASE(24, 6, 5); | ||
303 | |||
236 | pcr->ic_version = rts5249_get_ic_version(pcr); | 304 | pcr->ic_version = rts5249_get_ic_version(pcr); |
237 | pcr->sd_pull_ctl_enable_tbl = rts5249_sd_pull_ctl_enable_tbl; | 305 | pcr->sd_pull_ctl_enable_tbl = rts5249_sd_pull_ctl_enable_tbl; |
238 | pcr->sd_pull_ctl_disable_tbl = rts5249_sd_pull_ctl_disable_tbl; | 306 | pcr->sd_pull_ctl_disable_tbl = rts5249_sd_pull_ctl_disable_tbl; |
diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c index dd186c4103c1..e6ae7720f9e1 100644 --- a/drivers/mfd/rtsx_pcr.c +++ b/drivers/mfd/rtsx_pcr.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* Driver for Realtek PCI-Express card reader | 1 | /* Driver for Realtek PCI-Express card reader |
2 | * | 2 | * |
3 | * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. | 3 | * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or modify it |
6 | * under the terms of the GNU General Public License as published by the | 6 | * under the terms of the GNU General Public License as published by the |
@@ -17,7 +17,6 @@ | |||
17 | * | 17 | * |
18 | * Author: | 18 | * Author: |
19 | * Wei WANG <wei_wang@realsil.com.cn> | 19 | * Wei WANG <wei_wang@realsil.com.cn> |
20 | * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China | ||
21 | */ | 20 | */ |
22 | 21 | ||
23 | #include <linux/pci.h> | 22 | #include <linux/pci.h> |
@@ -73,6 +72,9 @@ void rtsx_pci_start_run(struct rtsx_pcr *pcr) | |||
73 | pcr->state = PDEV_STAT_RUN; | 72 | pcr->state = PDEV_STAT_RUN; |
74 | if (pcr->ops->enable_auto_blink) | 73 | if (pcr->ops->enable_auto_blink) |
75 | pcr->ops->enable_auto_blink(pcr); | 74 | pcr->ops->enable_auto_blink(pcr); |
75 | |||
76 | if (pcr->aspm_en) | ||
77 | rtsx_pci_write_config_byte(pcr, LCTLR, 0); | ||
76 | } | 78 | } |
77 | 79 | ||
78 | mod_delayed_work(system_wq, &pcr->idle_work, msecs_to_jiffies(200)); | 80 | mod_delayed_work(system_wq, &pcr->idle_work, msecs_to_jiffies(200)); |
@@ -717,7 +719,7 @@ int rtsx_pci_card_exclusive_check(struct rtsx_pcr *pcr, int card) | |||
717 | [RTSX_MS_CARD] = MS_EXIST | 719 | [RTSX_MS_CARD] = MS_EXIST |
718 | }; | 720 | }; |
719 | 721 | ||
720 | if (!pcr->ms_pmos) { | 722 | if (!(pcr->flags & PCR_MS_PMOS)) { |
721 | /* When using single PMOS, accessing card is not permitted | 723 | /* When using single PMOS, accessing card is not permitted |
722 | * if the existing card is not the designated one. | 724 | * if the existing card is not the designated one. |
723 | */ | 725 | */ |
@@ -918,9 +920,27 @@ static void rtsx_pci_idle_work(struct work_struct *work) | |||
918 | if (pcr->ops->turn_off_led) | 920 | if (pcr->ops->turn_off_led) |
919 | pcr->ops->turn_off_led(pcr); | 921 | pcr->ops->turn_off_led(pcr); |
920 | 922 | ||
923 | if (pcr->aspm_en) | ||
924 | rtsx_pci_write_config_byte(pcr, LCTLR, pcr->aspm_en); | ||
925 | |||
921 | mutex_unlock(&pcr->pcr_mutex); | 926 | mutex_unlock(&pcr->pcr_mutex); |
922 | } | 927 | } |
923 | 928 | ||
929 | static void rtsx_pci_power_off(struct rtsx_pcr *pcr, u8 pm_state) | ||
930 | { | ||
931 | if (pcr->ops->turn_off_led) | ||
932 | pcr->ops->turn_off_led(pcr); | ||
933 | |||
934 | rtsx_pci_writel(pcr, RTSX_BIER, 0); | ||
935 | pcr->bier = 0; | ||
936 | |||
937 | rtsx_pci_write_register(pcr, PETXCFG, 0x08, 0x08); | ||
938 | rtsx_pci_write_register(pcr, HOST_SLEEP_STATE, 0x03, pm_state); | ||
939 | |||
940 | if (pcr->ops->force_power_down) | ||
941 | pcr->ops->force_power_down(pcr, pm_state); | ||
942 | } | ||
943 | |||
924 | static int rtsx_pci_init_hw(struct rtsx_pcr *pcr) | 944 | static int rtsx_pci_init_hw(struct rtsx_pcr *pcr) |
925 | { | 945 | { |
926 | int err; | 946 | int err; |
@@ -951,13 +971,11 @@ static int rtsx_pci_init_hw(struct rtsx_pcr *pcr) | |||
951 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, HOST_SLEEP_STATE, 0x03, 0x00); | 971 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, HOST_SLEEP_STATE, 0x03, 0x00); |
952 | /* Disable card clock */ | 972 | /* Disable card clock */ |
953 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_CLK_EN, 0x1E, 0); | 973 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_CLK_EN, 0x1E, 0); |
954 | /* Reset ASPM state to default value */ | ||
955 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, ASPM_FORCE_CTL, 0x3F, 0); | ||
956 | /* Reset delink mode */ | 974 | /* Reset delink mode */ |
957 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CHANGE_LINK_STATE, 0x0A, 0); | 975 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CHANGE_LINK_STATE, 0x0A, 0); |
958 | /* Card driving select */ | 976 | /* Card driving select */ |
959 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_DRIVE_SEL, | 977 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_DRIVE_SEL, |
960 | 0x07, DRIVER_TYPE_D); | 978 | 0xFF, pcr->card_drive_sel); |
961 | /* Enable SSC Clock */ | 979 | /* Enable SSC Clock */ |
962 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SSC_CTL1, | 980 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SSC_CTL1, |
963 | 0xFF, SSC_8X_EN | SSC_SEL_4M); | 981 | 0xFF, SSC_8X_EN | SSC_SEL_4M); |
@@ -982,13 +1000,13 @@ static int rtsx_pci_init_hw(struct rtsx_pcr *pcr) | |||
982 | * 0: ELBI interrupt flag[31:22] & [7:0] only can be write clear | 1000 | * 0: ELBI interrupt flag[31:22] & [7:0] only can be write clear |
983 | */ | 1001 | */ |
984 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, NFTS_TX_CTRL, 0x02, 0); | 1002 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, NFTS_TX_CTRL, 0x02, 0); |
985 | /* Force CLKREQ# PIN to drive 0 to request clock */ | ||
986 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0x08, 0x08); | ||
987 | 1003 | ||
988 | err = rtsx_pci_send_cmd(pcr, 100); | 1004 | err = rtsx_pci_send_cmd(pcr, 100); |
989 | if (err < 0) | 1005 | if (err < 0) |
990 | return err; | 1006 | return err; |
991 | 1007 | ||
1008 | rtsx_pci_write_config_byte(pcr, LCTLR, 0); | ||
1009 | |||
992 | /* Enable clk_request_n to enable clock power management */ | 1010 | /* Enable clk_request_n to enable clock power management */ |
993 | rtsx_pci_write_config_byte(pcr, 0x81, 1); | 1011 | rtsx_pci_write_config_byte(pcr, 0x81, 1); |
994 | /* Enter L1 when host tx idle */ | 1012 | /* Enter L1 when host tx idle */ |
@@ -1053,6 +1071,18 @@ static int rtsx_pci_init_chip(struct rtsx_pcr *pcr) | |||
1053 | if (!pcr->slots) | 1071 | if (!pcr->slots) |
1054 | return -ENOMEM; | 1072 | return -ENOMEM; |
1055 | 1073 | ||
1074 | if (pcr->ops->fetch_vendor_settings) | ||
1075 | pcr->ops->fetch_vendor_settings(pcr); | ||
1076 | |||
1077 | dev_dbg(&(pcr->pci->dev), "pcr->aspm_en = 0x%x\n", pcr->aspm_en); | ||
1078 | dev_dbg(&(pcr->pci->dev), "pcr->sd30_drive_sel_1v8 = 0x%x\n", | ||
1079 | pcr->sd30_drive_sel_1v8); | ||
1080 | dev_dbg(&(pcr->pci->dev), "pcr->sd30_drive_sel_3v3 = 0x%x\n", | ||
1081 | pcr->sd30_drive_sel_3v3); | ||
1082 | dev_dbg(&(pcr->pci->dev), "pcr->card_drive_sel = 0x%x\n", | ||
1083 | pcr->card_drive_sel); | ||
1084 | dev_dbg(&(pcr->pci->dev), "pcr->flags = 0x%x\n", pcr->flags); | ||
1085 | |||
1056 | pcr->state = PDEV_STAT_IDLE; | 1086 | pcr->state = PDEV_STAT_IDLE; |
1057 | err = rtsx_pci_init_hw(pcr); | 1087 | err = rtsx_pci_init_hw(pcr); |
1058 | if (err < 0) { | 1088 | if (err < 0) { |
@@ -1235,7 +1265,6 @@ static int rtsx_pci_suspend(struct pci_dev *pcidev, pm_message_t state) | |||
1235 | { | 1265 | { |
1236 | struct pcr_handle *handle; | 1266 | struct pcr_handle *handle; |
1237 | struct rtsx_pcr *pcr; | 1267 | struct rtsx_pcr *pcr; |
1238 | int ret = 0; | ||
1239 | 1268 | ||
1240 | dev_dbg(&(pcidev->dev), "--> %s\n", __func__); | 1269 | dev_dbg(&(pcidev->dev), "--> %s\n", __func__); |
1241 | 1270 | ||
@@ -1247,14 +1276,7 @@ static int rtsx_pci_suspend(struct pci_dev *pcidev, pm_message_t state) | |||
1247 | 1276 | ||
1248 | mutex_lock(&pcr->pcr_mutex); | 1277 | mutex_lock(&pcr->pcr_mutex); |
1249 | 1278 | ||
1250 | if (pcr->ops->turn_off_led) | 1279 | rtsx_pci_power_off(pcr, HOST_ENTER_S3); |
1251 | pcr->ops->turn_off_led(pcr); | ||
1252 | |||
1253 | rtsx_pci_writel(pcr, RTSX_BIER, 0); | ||
1254 | pcr->bier = 0; | ||
1255 | |||
1256 | rtsx_pci_write_register(pcr, PETXCFG, 0x08, 0x08); | ||
1257 | rtsx_pci_write_register(pcr, HOST_SLEEP_STATE, 0x03, 0x02); | ||
1258 | 1280 | ||
1259 | pci_save_state(pcidev); | 1281 | pci_save_state(pcidev); |
1260 | pci_enable_wake(pcidev, pci_choose_state(pcidev, state), 0); | 1282 | pci_enable_wake(pcidev, pci_choose_state(pcidev, state), 0); |
@@ -1262,7 +1284,7 @@ static int rtsx_pci_suspend(struct pci_dev *pcidev, pm_message_t state) | |||
1262 | pci_set_power_state(pcidev, pci_choose_state(pcidev, state)); | 1284 | pci_set_power_state(pcidev, pci_choose_state(pcidev, state)); |
1263 | 1285 | ||
1264 | mutex_unlock(&pcr->pcr_mutex); | 1286 | mutex_unlock(&pcr->pcr_mutex); |
1265 | return ret; | 1287 | return 0; |
1266 | } | 1288 | } |
1267 | 1289 | ||
1268 | static int rtsx_pci_resume(struct pci_dev *pcidev) | 1290 | static int rtsx_pci_resume(struct pci_dev *pcidev) |
@@ -1300,10 +1322,25 @@ out: | |||
1300 | return ret; | 1322 | return ret; |
1301 | } | 1323 | } |
1302 | 1324 | ||
1325 | static void rtsx_pci_shutdown(struct pci_dev *pcidev) | ||
1326 | { | ||
1327 | struct pcr_handle *handle; | ||
1328 | struct rtsx_pcr *pcr; | ||
1329 | |||
1330 | dev_dbg(&(pcidev->dev), "--> %s\n", __func__); | ||
1331 | |||
1332 | handle = pci_get_drvdata(pcidev); | ||
1333 | pcr = handle->pcr; | ||
1334 | rtsx_pci_power_off(pcr, HOST_ENTER_S1); | ||
1335 | |||
1336 | pci_disable_device(pcidev); | ||
1337 | } | ||
1338 | |||
1303 | #else /* CONFIG_PM */ | 1339 | #else /* CONFIG_PM */ |
1304 | 1340 | ||
1305 | #define rtsx_pci_suspend NULL | 1341 | #define rtsx_pci_suspend NULL |
1306 | #define rtsx_pci_resume NULL | 1342 | #define rtsx_pci_resume NULL |
1343 | #define rtsx_pci_shutdown NULL | ||
1307 | 1344 | ||
1308 | #endif /* CONFIG_PM */ | 1345 | #endif /* CONFIG_PM */ |
1309 | 1346 | ||
@@ -1314,6 +1351,7 @@ static struct pci_driver rtsx_pci_driver = { | |||
1314 | .remove = rtsx_pci_remove, | 1351 | .remove = rtsx_pci_remove, |
1315 | .suspend = rtsx_pci_suspend, | 1352 | .suspend = rtsx_pci_suspend, |
1316 | .resume = rtsx_pci_resume, | 1353 | .resume = rtsx_pci_resume, |
1354 | .shutdown = rtsx_pci_shutdown, | ||
1317 | }; | 1355 | }; |
1318 | module_pci_driver(rtsx_pci_driver); | 1356 | module_pci_driver(rtsx_pci_driver); |
1319 | 1357 | ||
diff --git a/drivers/mfd/rtsx_pcr.h b/drivers/mfd/rtsx_pcr.h index c0cac7e8972f..947e79b05ceb 100644 --- a/drivers/mfd/rtsx_pcr.h +++ b/drivers/mfd/rtsx_pcr.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* Driver for Realtek PCI-Express card reader | 1 | /* Driver for Realtek PCI-Express card reader |
2 | * | 2 | * |
3 | * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. | 3 | * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or modify it |
6 | * under the terms of the GNU General Public License as published by the | 6 | * under the terms of the GNU General Public License as published by the |
@@ -17,7 +17,6 @@ | |||
17 | * | 17 | * |
18 | * Author: | 18 | * Author: |
19 | * Wei WANG <wei_wang@realsil.com.cn> | 19 | * Wei WANG <wei_wang@realsil.com.cn> |
20 | * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China | ||
21 | */ | 20 | */ |
22 | 21 | ||
23 | #ifndef __RTSX_PCR_H | 22 | #ifndef __RTSX_PCR_H |
@@ -35,4 +34,33 @@ void rts5227_init_params(struct rtsx_pcr *pcr); | |||
35 | void rts5249_init_params(struct rtsx_pcr *pcr); | 34 | void rts5249_init_params(struct rtsx_pcr *pcr); |
36 | void rtl8411b_init_params(struct rtsx_pcr *pcr); | 35 | void rtl8411b_init_params(struct rtsx_pcr *pcr); |
37 | 36 | ||
37 | static inline u8 map_sd_drive(int idx) | ||
38 | { | ||
39 | u8 sd_drive[4] = { | ||
40 | 0x01, /* Type D */ | ||
41 | 0x02, /* Type C */ | ||
42 | 0x05, /* Type A */ | ||
43 | 0x03 /* Type B */ | ||
44 | }; | ||
45 | |||
46 | return sd_drive[idx]; | ||
47 | } | ||
48 | |||
49 | #define rtsx_vendor_setting_valid(reg) (!((reg) & 0x1000000)) | ||
50 | #define rts5209_vendor_setting1_valid(reg) (!((reg) & 0x80)) | ||
51 | #define rts5209_vendor_setting2_valid(reg) ((reg) & 0x80) | ||
52 | |||
53 | #define rtsx_reg_to_aspm(reg) (((reg) >> 28) & 0x03) | ||
54 | #define rtsx_reg_to_sd30_drive_sel_1v8(reg) (((reg) >> 26) & 0x03) | ||
55 | #define rtsx_reg_to_sd30_drive_sel_3v3(reg) (((reg) >> 5) & 0x03) | ||
56 | #define rtsx_reg_to_card_drive_sel(reg) ((((reg) >> 25) & 0x01) << 6) | ||
57 | #define rtsx_reg_check_reverse_socket(reg) ((reg) & 0x4000) | ||
58 | #define rts5209_reg_to_aspm(reg) (((reg) >> 5) & 0x03) | ||
59 | #define rts5209_reg_check_ms_pmos(reg) (!((reg) & 0x08)) | ||
60 | #define rts5209_reg_to_sd30_drive_sel_1v8(reg) (((reg) >> 3) & 0x07) | ||
61 | #define rts5209_reg_to_sd30_drive_sel_3v3(reg) ((reg) & 0x07) | ||
62 | #define rts5209_reg_to_card_drive_sel(reg) ((reg) >> 8) | ||
63 | #define rtl8411_reg_to_sd30_drive_sel_3v3(reg) (((reg) >> 5) & 0x07) | ||
64 | #define rtl8411b_reg_to_sd30_drive_sel_3v3(reg) ((reg) & 0x03) | ||
65 | |||
38 | #endif | 66 | #endif |
diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c index 79767681483a..f530e4b73f19 100644 --- a/drivers/mfd/sec-core.c +++ b/drivers/mfd/sec-core.c | |||
@@ -61,7 +61,9 @@ static struct mfd_cell s5m8767_devs[] = { | |||
61 | static struct mfd_cell s2mps11_devs[] = { | 61 | static struct mfd_cell s2mps11_devs[] = { |
62 | { | 62 | { |
63 | .name = "s2mps11-pmic", | 63 | .name = "s2mps11-pmic", |
64 | }, | 64 | }, { |
65 | .name = "s2mps11-clk", | ||
66 | } | ||
65 | }; | 67 | }; |
66 | 68 | ||
67 | #ifdef CONFIG_OF | 69 | #ifdef CONFIG_OF |
@@ -69,6 +71,9 @@ static struct of_device_id sec_dt_match[] = { | |||
69 | { .compatible = "samsung,s5m8767-pmic", | 71 | { .compatible = "samsung,s5m8767-pmic", |
70 | .data = (void *)S5M8767X, | 72 | .data = (void *)S5M8767X, |
71 | }, | 73 | }, |
74 | { .compatible = "samsung,s2mps11-pmic", | ||
75 | .data = (void *)S2MPS11X, | ||
76 | }, | ||
72 | {}, | 77 | {}, |
73 | }; | 78 | }; |
74 | #endif | 79 | #endif |
@@ -103,6 +108,31 @@ int sec_reg_update(struct sec_pmic_dev *sec_pmic, u8 reg, u8 val, u8 mask) | |||
103 | } | 108 | } |
104 | EXPORT_SYMBOL_GPL(sec_reg_update); | 109 | EXPORT_SYMBOL_GPL(sec_reg_update); |
105 | 110 | ||
111 | static bool s2mps11_volatile(struct device *dev, unsigned int reg) | ||
112 | { | ||
113 | switch (reg) { | ||
114 | case S2MPS11_REG_INT1M: | ||
115 | case S2MPS11_REG_INT2M: | ||
116 | case S2MPS11_REG_INT3M: | ||
117 | return false; | ||
118 | default: | ||
119 | return true; | ||
120 | } | ||
121 | } | ||
122 | |||
123 | static bool s5m8763_volatile(struct device *dev, unsigned int reg) | ||
124 | { | ||
125 | switch (reg) { | ||
126 | case S5M8763_REG_IRQM1: | ||
127 | case S5M8763_REG_IRQM2: | ||
128 | case S5M8763_REG_IRQM3: | ||
129 | case S5M8763_REG_IRQM4: | ||
130 | return false; | ||
131 | default: | ||
132 | return true; | ||
133 | } | ||
134 | } | ||
135 | |||
106 | static struct regmap_config sec_regmap_config = { | 136 | static struct regmap_config sec_regmap_config = { |
107 | .reg_bits = 8, | 137 | .reg_bits = 8, |
108 | .val_bits = 8, | 138 | .val_bits = 8, |
@@ -113,6 +143,8 @@ static struct regmap_config s2mps11_regmap_config = { | |||
113 | .val_bits = 8, | 143 | .val_bits = 8, |
114 | 144 | ||
115 | .max_register = S2MPS11_REG_L38CTRL, | 145 | .max_register = S2MPS11_REG_L38CTRL, |
146 | .volatile_reg = s2mps11_volatile, | ||
147 | .cache_type = REGCACHE_FLAT, | ||
116 | }; | 148 | }; |
117 | 149 | ||
118 | static struct regmap_config s5m8763_regmap_config = { | 150 | static struct regmap_config s5m8763_regmap_config = { |
@@ -120,6 +152,8 @@ static struct regmap_config s5m8763_regmap_config = { | |||
120 | .val_bits = 8, | 152 | .val_bits = 8, |
121 | 153 | ||
122 | .max_register = S5M8763_REG_LBCNFG2, | 154 | .max_register = S5M8763_REG_LBCNFG2, |
155 | .volatile_reg = s5m8763_volatile, | ||
156 | .cache_type = REGCACHE_FLAT, | ||
123 | }; | 157 | }; |
124 | 158 | ||
125 | static struct regmap_config s5m8767_regmap_config = { | 159 | static struct regmap_config s5m8767_regmap_config = { |
@@ -127,6 +161,8 @@ static struct regmap_config s5m8767_regmap_config = { | |||
127 | .val_bits = 8, | 161 | .val_bits = 8, |
128 | 162 | ||
129 | .max_register = S5M8767_REG_LDO28CTRL, | 163 | .max_register = S5M8767_REG_LDO28CTRL, |
164 | .volatile_reg = s2mps11_volatile, | ||
165 | .cache_type = REGCACHE_FLAT, | ||
130 | }; | 166 | }; |
131 | 167 | ||
132 | #ifdef CONFIG_OF | 168 | #ifdef CONFIG_OF |
@@ -182,7 +218,7 @@ static inline int sec_i2c_get_driver_data(struct i2c_client *i2c, | |||
182 | static int sec_pmic_probe(struct i2c_client *i2c, | 218 | static int sec_pmic_probe(struct i2c_client *i2c, |
183 | const struct i2c_device_id *id) | 219 | const struct i2c_device_id *id) |
184 | { | 220 | { |
185 | struct sec_platform_data *pdata = i2c->dev.platform_data; | 221 | struct sec_platform_data *pdata = dev_get_platdata(&i2c->dev); |
186 | const struct regmap_config *regmap; | 222 | const struct regmap_config *regmap; |
187 | struct sec_pmic_dev *sec_pmic; | 223 | struct sec_pmic_dev *sec_pmic; |
188 | int ret; | 224 | int ret; |
diff --git a/drivers/mfd/si476x-i2c.c b/drivers/mfd/si476x-i2c.c index f5bc8e4bd4bf..0e4a76daf187 100644 --- a/drivers/mfd/si476x-i2c.c +++ b/drivers/mfd/si476x-i2c.c | |||
@@ -718,7 +718,7 @@ static int si476x_core_probe(struct i2c_client *client, | |||
718 | atomic_set(&core->is_alive, 0); | 718 | atomic_set(&core->is_alive, 0); |
719 | core->power_state = SI476X_POWER_DOWN; | 719 | core->power_state = SI476X_POWER_DOWN; |
720 | 720 | ||
721 | pdata = client->dev.platform_data; | 721 | pdata = dev_get_platdata(&client->dev); |
722 | if (pdata) { | 722 | if (pdata) { |
723 | memcpy(&core->power_up_parameters, | 723 | memcpy(&core->power_up_parameters, |
724 | &pdata->power_up_parameters, | 724 | &pdata->power_up_parameters, |
diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c index 9816c232e583..33f040c558d0 100644 --- a/drivers/mfd/sm501.c +++ b/drivers/mfd/sm501.c | |||
@@ -840,7 +840,7 @@ static int sm501_register_uart(struct sm501_devdata *sm, int devices) | |||
840 | if (!pdev) | 840 | if (!pdev) |
841 | return -ENOMEM; | 841 | return -ENOMEM; |
842 | 842 | ||
843 | uart_data = pdev->dev.platform_data; | 843 | uart_data = dev_get_platdata(&pdev->dev); |
844 | 844 | ||
845 | if (devices & SM501_USE_UART0) { | 845 | if (devices & SM501_USE_UART0) { |
846 | sm501_setup_uart_data(sm, uart_data++, 0x30000); | 846 | sm501_setup_uart_data(sm, uart_data++, 0x30000); |
@@ -1167,7 +1167,7 @@ static int sm501_register_gpio_i2c_instance(struct sm501_devdata *sm, | |||
1167 | if (!pdev) | 1167 | if (!pdev) |
1168 | return -ENOMEM; | 1168 | return -ENOMEM; |
1169 | 1169 | ||
1170 | icd = pdev->dev.platform_data; | 1170 | icd = dev_get_platdata(&pdev->dev); |
1171 | 1171 | ||
1172 | /* We keep the pin_sda and pin_scl fields relative in case the | 1172 | /* We keep the pin_sda and pin_scl fields relative in case the |
1173 | * same platform data is passed to >1 SM501. | 1173 | * same platform data is passed to >1 SM501. |
@@ -1403,7 +1403,7 @@ static int sm501_plat_probe(struct platform_device *dev) | |||
1403 | 1403 | ||
1404 | sm->dev = &dev->dev; | 1404 | sm->dev = &dev->dev; |
1405 | sm->pdev_id = dev->id; | 1405 | sm->pdev_id = dev->id; |
1406 | sm->platdata = dev->dev.platform_data; | 1406 | sm->platdata = dev_get_platdata(&dev->dev); |
1407 | 1407 | ||
1408 | ret = platform_get_irq(dev, 0); | 1408 | ret = platform_get_irq(dev, 0); |
1409 | if (ret < 0) { | 1409 | if (ret < 0) { |
diff --git a/drivers/mfd/sta2x11-mfd.c b/drivers/mfd/sta2x11-mfd.c index d70a343078fd..65c6fa671acb 100644 --- a/drivers/mfd/sta2x11-mfd.c +++ b/drivers/mfd/sta2x11-mfd.c | |||
@@ -133,7 +133,7 @@ int sta2x11_mfd_get_regs_data(struct platform_device *dev, | |||
133 | void __iomem **regs, | 133 | void __iomem **regs, |
134 | spinlock_t **lock) | 134 | spinlock_t **lock) |
135 | { | 135 | { |
136 | struct pci_dev *pdev = *(struct pci_dev **)(dev->dev.platform_data); | 136 | struct pci_dev *pdev = *(struct pci_dev **)dev_get_platdata(&dev->dev); |
137 | struct sta2x11_mfd *mfd; | 137 | struct sta2x11_mfd *mfd; |
138 | 138 | ||
139 | if (!pdev) | 139 | if (!pdev) |
@@ -312,7 +312,7 @@ static int sta2x11_mfd_platform_probe(struct platform_device *dev, | |||
312 | const char *name = sta2x11_mfd_names[index]; | 312 | const char *name = sta2x11_mfd_names[index]; |
313 | struct regmap_config *regmap_config = sta2x11_mfd_regmap_configs[index]; | 313 | struct regmap_config *regmap_config = sta2x11_mfd_regmap_configs[index]; |
314 | 314 | ||
315 | pdev = dev->dev.platform_data; | 315 | pdev = dev_get_platdata(&dev->dev); |
316 | mfd = sta2x11_mfd_find(*pdev); | 316 | mfd = sta2x11_mfd_find(*pdev); |
317 | if (!mfd) | 317 | if (!mfd) |
318 | return -ENODEV; | 318 | return -ENODEV; |
diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c index 5d5e6f90424a..fff63a41862c 100644 --- a/drivers/mfd/stmpe.c +++ b/drivers/mfd/stmpe.c | |||
@@ -1106,7 +1106,8 @@ static int stmpe_devices_init(struct stmpe *stmpe) | |||
1106 | return ret; | 1106 | return ret; |
1107 | } | 1107 | } |
1108 | 1108 | ||
1109 | void stmpe_of_probe(struct stmpe_platform_data *pdata, struct device_node *np) | 1109 | static void stmpe_of_probe(struct stmpe_platform_data *pdata, |
1110 | struct device_node *np) | ||
1110 | { | 1111 | { |
1111 | struct device_node *child; | 1112 | struct device_node *child; |
1112 | 1113 | ||
diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c index 962a6e17a01a..71841f9181bd 100644 --- a/drivers/mfd/syscon.c +++ b/drivers/mfd/syscon.c | |||
@@ -25,7 +25,6 @@ | |||
25 | static struct platform_driver syscon_driver; | 25 | static struct platform_driver syscon_driver; |
26 | 26 | ||
27 | struct syscon { | 27 | struct syscon { |
28 | void __iomem *base; | ||
29 | struct regmap *regmap; | 28 | struct regmap *regmap; |
30 | }; | 29 | }; |
31 | 30 | ||
@@ -129,6 +128,7 @@ static int syscon_probe(struct platform_device *pdev) | |||
129 | struct device *dev = &pdev->dev; | 128 | struct device *dev = &pdev->dev; |
130 | struct syscon *syscon; | 129 | struct syscon *syscon; |
131 | struct resource *res; | 130 | struct resource *res; |
131 | void __iomem *base; | ||
132 | 132 | ||
133 | syscon = devm_kzalloc(dev, sizeof(*syscon), GFP_KERNEL); | 133 | syscon = devm_kzalloc(dev, sizeof(*syscon), GFP_KERNEL); |
134 | if (!syscon) | 134 | if (!syscon) |
@@ -138,12 +138,12 @@ static int syscon_probe(struct platform_device *pdev) | |||
138 | if (!res) | 138 | if (!res) |
139 | return -ENOENT; | 139 | return -ENOENT; |
140 | 140 | ||
141 | syscon->base = devm_ioremap(dev, res->start, resource_size(res)); | 141 | base = devm_ioremap(dev, res->start, resource_size(res)); |
142 | if (!syscon->base) | 142 | if (!base) |
143 | return -ENOMEM; | 143 | return -ENOMEM; |
144 | 144 | ||
145 | syscon_regmap_config.max_register = res->end - res->start - 3; | 145 | syscon_regmap_config.max_register = res->end - res->start - 3; |
146 | syscon->regmap = devm_regmap_init_mmio(dev, syscon->base, | 146 | syscon->regmap = devm_regmap_init_mmio(dev, base, |
147 | &syscon_regmap_config); | 147 | &syscon_regmap_config); |
148 | if (IS_ERR(syscon->regmap)) { | 148 | if (IS_ERR(syscon->regmap)) { |
149 | dev_err(dev, "regmap init failed\n"); | 149 | dev_err(dev, "regmap init failed\n"); |
diff --git a/drivers/mfd/t7l66xb.c b/drivers/mfd/t7l66xb.c index a21bff283a98..9e04a7485981 100644 --- a/drivers/mfd/t7l66xb.c +++ b/drivers/mfd/t7l66xb.c | |||
@@ -281,7 +281,7 @@ static void t7l66xb_detach_irq(struct platform_device *dev) | |||
281 | static int t7l66xb_suspend(struct platform_device *dev, pm_message_t state) | 281 | static int t7l66xb_suspend(struct platform_device *dev, pm_message_t state) |
282 | { | 282 | { |
283 | struct t7l66xb *t7l66xb = platform_get_drvdata(dev); | 283 | struct t7l66xb *t7l66xb = platform_get_drvdata(dev); |
284 | struct t7l66xb_platform_data *pdata = dev->dev.platform_data; | 284 | struct t7l66xb_platform_data *pdata = dev_get_platdata(&dev->dev); |
285 | 285 | ||
286 | if (pdata && pdata->suspend) | 286 | if (pdata && pdata->suspend) |
287 | pdata->suspend(dev); | 287 | pdata->suspend(dev); |
@@ -293,7 +293,7 @@ static int t7l66xb_suspend(struct platform_device *dev, pm_message_t state) | |||
293 | static int t7l66xb_resume(struct platform_device *dev) | 293 | static int t7l66xb_resume(struct platform_device *dev) |
294 | { | 294 | { |
295 | struct t7l66xb *t7l66xb = platform_get_drvdata(dev); | 295 | struct t7l66xb *t7l66xb = platform_get_drvdata(dev); |
296 | struct t7l66xb_platform_data *pdata = dev->dev.platform_data; | 296 | struct t7l66xb_platform_data *pdata = dev_get_platdata(&dev->dev); |
297 | 297 | ||
298 | clk_enable(t7l66xb->clk48m); | 298 | clk_enable(t7l66xb->clk48m); |
299 | if (pdata && pdata->resume) | 299 | if (pdata && pdata->resume) |
@@ -313,7 +313,7 @@ static int t7l66xb_resume(struct platform_device *dev) | |||
313 | 313 | ||
314 | static int t7l66xb_probe(struct platform_device *dev) | 314 | static int t7l66xb_probe(struct platform_device *dev) |
315 | { | 315 | { |
316 | struct t7l66xb_platform_data *pdata = dev->dev.platform_data; | 316 | struct t7l66xb_platform_data *pdata = dev_get_platdata(&dev->dev); |
317 | struct t7l66xb *t7l66xb; | 317 | struct t7l66xb *t7l66xb; |
318 | struct resource *iomem, *rscr; | 318 | struct resource *iomem, *rscr; |
319 | int ret; | 319 | int ret; |
@@ -409,7 +409,7 @@ err_noirq: | |||
409 | 409 | ||
410 | static int t7l66xb_remove(struct platform_device *dev) | 410 | static int t7l66xb_remove(struct platform_device *dev) |
411 | { | 411 | { |
412 | struct t7l66xb_platform_data *pdata = dev->dev.platform_data; | 412 | struct t7l66xb_platform_data *pdata = dev_get_platdata(&dev->dev); |
413 | struct t7l66xb *t7l66xb = platform_get_drvdata(dev); | 413 | struct t7l66xb *t7l66xb = platform_get_drvdata(dev); |
414 | int ret; | 414 | int ret; |
415 | 415 | ||
diff --git a/drivers/mfd/tc3589x.c b/drivers/mfd/tc3589x.c index 4cb92bb2aea2..70f4909fee13 100644 --- a/drivers/mfd/tc3589x.c +++ b/drivers/mfd/tc3589x.c | |||
@@ -325,7 +325,7 @@ static int tc3589x_of_probe(struct device_node *np, | |||
325 | static int tc3589x_probe(struct i2c_client *i2c, | 325 | static int tc3589x_probe(struct i2c_client *i2c, |
326 | const struct i2c_device_id *id) | 326 | const struct i2c_device_id *id) |
327 | { | 327 | { |
328 | struct tc3589x_platform_data *pdata = i2c->dev.platform_data; | 328 | struct tc3589x_platform_data *pdata = dev_get_platdata(&i2c->dev); |
329 | struct device_node *np = i2c->dev.of_node; | 329 | struct device_node *np = i2c->dev.of_node; |
330 | struct tc3589x *tc3589x; | 330 | struct tc3589x *tc3589x; |
331 | int ret; | 331 | int ret; |
diff --git a/drivers/mfd/tc6387xb.c b/drivers/mfd/tc6387xb.c index 65c425a517c5..acd0f3a41044 100644 --- a/drivers/mfd/tc6387xb.c +++ b/drivers/mfd/tc6387xb.c | |||
@@ -48,7 +48,7 @@ static struct resource tc6387xb_mmc_resources[] = { | |||
48 | static int tc6387xb_suspend(struct platform_device *dev, pm_message_t state) | 48 | static int tc6387xb_suspend(struct platform_device *dev, pm_message_t state) |
49 | { | 49 | { |
50 | struct tc6387xb *tc6387xb = platform_get_drvdata(dev); | 50 | struct tc6387xb *tc6387xb = platform_get_drvdata(dev); |
51 | struct tc6387xb_platform_data *pdata = dev->dev.platform_data; | 51 | struct tc6387xb_platform_data *pdata = dev_get_platdata(&dev->dev); |
52 | 52 | ||
53 | if (pdata && pdata->suspend) | 53 | if (pdata && pdata->suspend) |
54 | pdata->suspend(dev); | 54 | pdata->suspend(dev); |
@@ -60,7 +60,7 @@ static int tc6387xb_suspend(struct platform_device *dev, pm_message_t state) | |||
60 | static int tc6387xb_resume(struct platform_device *dev) | 60 | static int tc6387xb_resume(struct platform_device *dev) |
61 | { | 61 | { |
62 | struct tc6387xb *tc6387xb = platform_get_drvdata(dev); | 62 | struct tc6387xb *tc6387xb = platform_get_drvdata(dev); |
63 | struct tc6387xb_platform_data *pdata = dev->dev.platform_data; | 63 | struct tc6387xb_platform_data *pdata = dev_get_platdata(&dev->dev); |
64 | 64 | ||
65 | clk_enable(tc6387xb->clk32k); | 65 | clk_enable(tc6387xb->clk32k); |
66 | if (pdata && pdata->resume) | 66 | if (pdata && pdata->resume) |
@@ -140,7 +140,7 @@ static struct mfd_cell tc6387xb_cells[] = { | |||
140 | 140 | ||
141 | static int tc6387xb_probe(struct platform_device *dev) | 141 | static int tc6387xb_probe(struct platform_device *dev) |
142 | { | 142 | { |
143 | struct tc6387xb_platform_data *pdata = dev->dev.platform_data; | 143 | struct tc6387xb_platform_data *pdata = dev_get_platdata(&dev->dev); |
144 | struct resource *iomem, *rscr; | 144 | struct resource *iomem, *rscr; |
145 | struct clk *clk32k; | 145 | struct clk *clk32k; |
146 | struct tc6387xb *tc6387xb; | 146 | struct tc6387xb *tc6387xb; |
diff --git a/drivers/mfd/tc6393xb.c b/drivers/mfd/tc6393xb.c index a563dfa3cf87..11c19e538551 100644 --- a/drivers/mfd/tc6393xb.c +++ b/drivers/mfd/tc6393xb.c | |||
@@ -604,7 +604,7 @@ static void tc6393xb_detach_irq(struct platform_device *dev) | |||
604 | 604 | ||
605 | static int tc6393xb_probe(struct platform_device *dev) | 605 | static int tc6393xb_probe(struct platform_device *dev) |
606 | { | 606 | { |
607 | struct tc6393xb_platform_data *tcpd = dev->dev.platform_data; | 607 | struct tc6393xb_platform_data *tcpd = dev_get_platdata(&dev->dev); |
608 | struct tc6393xb *tc6393xb; | 608 | struct tc6393xb *tc6393xb; |
609 | struct resource *iomem, *rscr; | 609 | struct resource *iomem, *rscr; |
610 | int ret, temp; | 610 | int ret, temp; |
@@ -733,7 +733,7 @@ err_kzalloc: | |||
733 | 733 | ||
734 | static int tc6393xb_remove(struct platform_device *dev) | 734 | static int tc6393xb_remove(struct platform_device *dev) |
735 | { | 735 | { |
736 | struct tc6393xb_platform_data *tcpd = dev->dev.platform_data; | 736 | struct tc6393xb_platform_data *tcpd = dev_get_platdata(&dev->dev); |
737 | struct tc6393xb *tc6393xb = platform_get_drvdata(dev); | 737 | struct tc6393xb *tc6393xb = platform_get_drvdata(dev); |
738 | int ret; | 738 | int ret; |
739 | 739 | ||
@@ -765,7 +765,7 @@ static int tc6393xb_remove(struct platform_device *dev) | |||
765 | #ifdef CONFIG_PM | 765 | #ifdef CONFIG_PM |
766 | static int tc6393xb_suspend(struct platform_device *dev, pm_message_t state) | 766 | static int tc6393xb_suspend(struct platform_device *dev, pm_message_t state) |
767 | { | 767 | { |
768 | struct tc6393xb_platform_data *tcpd = dev->dev.platform_data; | 768 | struct tc6393xb_platform_data *tcpd = dev_get_platdata(&dev->dev); |
769 | struct tc6393xb *tc6393xb = platform_get_drvdata(dev); | 769 | struct tc6393xb *tc6393xb = platform_get_drvdata(dev); |
770 | int i, ret; | 770 | int i, ret; |
771 | 771 | ||
@@ -788,7 +788,7 @@ static int tc6393xb_suspend(struct platform_device *dev, pm_message_t state) | |||
788 | 788 | ||
789 | static int tc6393xb_resume(struct platform_device *dev) | 789 | static int tc6393xb_resume(struct platform_device *dev) |
790 | { | 790 | { |
791 | struct tc6393xb_platform_data *tcpd = dev->dev.platform_data; | 791 | struct tc6393xb_platform_data *tcpd = dev_get_platdata(&dev->dev); |
792 | struct tc6393xb *tc6393xb = platform_get_drvdata(dev); | 792 | struct tc6393xb *tc6393xb = platform_get_drvdata(dev); |
793 | int ret; | 793 | int ret; |
794 | int i; | 794 | int i; |
diff --git a/drivers/mfd/ti-ssp.c b/drivers/mfd/ti-ssp.c index 09a14cec351b..1c2b994e1f6c 100644 --- a/drivers/mfd/ti-ssp.c +++ b/drivers/mfd/ti-ssp.c | |||
@@ -318,7 +318,7 @@ static irqreturn_t ti_ssp_interrupt(int irq, void *dev_data) | |||
318 | static int ti_ssp_probe(struct platform_device *pdev) | 318 | static int ti_ssp_probe(struct platform_device *pdev) |
319 | { | 319 | { |
320 | static struct ti_ssp *ssp; | 320 | static struct ti_ssp *ssp; |
321 | const struct ti_ssp_data *pdata = pdev->dev.platform_data; | 321 | const struct ti_ssp_data *pdata = dev_get_platdata(&pdev->dev); |
322 | int error = 0, prediv = 0xff, id; | 322 | int error = 0, prediv = 0xff, id; |
323 | unsigned long sysclk; | 323 | unsigned long sysclk; |
324 | struct device *dev = &pdev->dev; | 324 | struct device *dev = &pdev->dev; |
diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c index b003a16ba227..baaf5a8123bb 100644 --- a/drivers/mfd/ti_am335x_tscadc.c +++ b/drivers/mfd/ti_am335x_tscadc.c | |||
@@ -57,20 +57,20 @@ EXPORT_SYMBOL_GPL(am335x_tsc_se_update); | |||
57 | void am335x_tsc_se_set(struct ti_tscadc_dev *tsadc, u32 val) | 57 | void am335x_tsc_se_set(struct ti_tscadc_dev *tsadc, u32 val) |
58 | { | 58 | { |
59 | spin_lock(&tsadc->reg_lock); | 59 | spin_lock(&tsadc->reg_lock); |
60 | tsadc->reg_se_cache = tscadc_readl(tsadc, REG_SE); | ||
60 | tsadc->reg_se_cache |= val; | 61 | tsadc->reg_se_cache |= val; |
61 | spin_unlock(&tsadc->reg_lock); | ||
62 | |||
63 | am335x_tsc_se_update(tsadc); | 62 | am335x_tsc_se_update(tsadc); |
63 | spin_unlock(&tsadc->reg_lock); | ||
64 | } | 64 | } |
65 | EXPORT_SYMBOL_GPL(am335x_tsc_se_set); | 65 | EXPORT_SYMBOL_GPL(am335x_tsc_se_set); |
66 | 66 | ||
67 | void am335x_tsc_se_clr(struct ti_tscadc_dev *tsadc, u32 val) | 67 | void am335x_tsc_se_clr(struct ti_tscadc_dev *tsadc, u32 val) |
68 | { | 68 | { |
69 | spin_lock(&tsadc->reg_lock); | 69 | spin_lock(&tsadc->reg_lock); |
70 | tsadc->reg_se_cache = tscadc_readl(tsadc, REG_SE); | ||
70 | tsadc->reg_se_cache &= ~val; | 71 | tsadc->reg_se_cache &= ~val; |
71 | spin_unlock(&tsadc->reg_lock); | ||
72 | |||
73 | am335x_tsc_se_update(tsadc); | 72 | am335x_tsc_se_update(tsadc); |
73 | spin_unlock(&tsadc->reg_lock); | ||
74 | } | 74 | } |
75 | EXPORT_SYMBOL_GPL(am335x_tsc_se_clr); | 75 | EXPORT_SYMBOL_GPL(am335x_tsc_se_clr); |
76 | 76 | ||
@@ -197,24 +197,21 @@ static int ti_tscadc_probe(struct platform_device *pdev) | |||
197 | clock_rate = clk_get_rate(clk); | 197 | clock_rate = clk_get_rate(clk); |
198 | clk_put(clk); | 198 | clk_put(clk); |
199 | clk_value = clock_rate / ADC_CLK; | 199 | clk_value = clock_rate / ADC_CLK; |
200 | if (clk_value < MAX_CLK_DIV) { | 200 | |
201 | dev_err(&pdev->dev, "clock input less than min clock requirement\n"); | ||
202 | err = -EINVAL; | ||
203 | goto err_disable_clk; | ||
204 | } | ||
205 | /* TSCADC_CLKDIV needs to be configured to the value minus 1 */ | 201 | /* TSCADC_CLKDIV needs to be configured to the value minus 1 */ |
206 | clk_value = clk_value - 1; | 202 | clk_value = clk_value - 1; |
207 | tscadc_writel(tscadc, REG_CLKDIV, clk_value); | 203 | tscadc_writel(tscadc, REG_CLKDIV, clk_value); |
208 | 204 | ||
209 | /* Set the control register bits */ | 205 | /* Set the control register bits */ |
210 | ctrl = CNTRLREG_STEPCONFIGWRT | | 206 | ctrl = CNTRLREG_STEPCONFIGWRT | |
211 | CNTRLREG_TSCENB | | 207 | CNTRLREG_STEPID; |
212 | CNTRLREG_STEPID | | 208 | if (tsc_wires > 0) |
213 | CNTRLREG_4WIRE; | 209 | ctrl |= CNTRLREG_4WIRE | CNTRLREG_TSCENB; |
214 | tscadc_writel(tscadc, REG_CTRL, ctrl); | 210 | tscadc_writel(tscadc, REG_CTRL, ctrl); |
215 | 211 | ||
216 | /* Set register bits for Idle Config Mode */ | 212 | /* Set register bits for Idle Config Mode */ |
217 | tscadc_idle_config(tscadc); | 213 | if (tsc_wires > 0) |
214 | tscadc_idle_config(tscadc); | ||
218 | 215 | ||
219 | /* Enable the TSC module enable bit */ | 216 | /* Enable the TSC module enable bit */ |
220 | ctrl = tscadc_readl(tscadc, REG_CTRL); | 217 | ctrl = tscadc_readl(tscadc, REG_CTRL); |
@@ -294,10 +291,13 @@ static int tscadc_resume(struct device *dev) | |||
294 | pm_runtime_get_sync(dev); | 291 | pm_runtime_get_sync(dev); |
295 | 292 | ||
296 | /* context restore */ | 293 | /* context restore */ |
297 | ctrl = CNTRLREG_STEPCONFIGWRT | CNTRLREG_TSCENB | | 294 | ctrl = CNTRLREG_STEPCONFIGWRT | CNTRLREG_STEPID; |
298 | CNTRLREG_STEPID | CNTRLREG_4WIRE; | 295 | if (tscadc_dev->tsc_cell != -1) |
296 | ctrl |= CNTRLREG_TSCENB | CNTRLREG_4WIRE; | ||
299 | tscadc_writel(tscadc_dev, REG_CTRL, ctrl); | 297 | tscadc_writel(tscadc_dev, REG_CTRL, ctrl); |
300 | tscadc_idle_config(tscadc_dev); | 298 | |
299 | if (tscadc_dev->tsc_cell != -1) | ||
300 | tscadc_idle_config(tscadc_dev); | ||
301 | am335x_tsc_se_update(tscadc_dev); | 301 | am335x_tsc_se_update(tscadc_dev); |
302 | restore = tscadc_readl(tscadc_dev, REG_CTRL); | 302 | restore = tscadc_readl(tscadc_dev, REG_CTRL); |
303 | tscadc_writel(tscadc_dev, REG_CTRL, | 303 | tscadc_writel(tscadc_dev, REG_CTRL, |
diff --git a/drivers/mfd/timberdale.c b/drivers/mfd/timberdale.c index 0c1fcbc23d04..a6755ec7bd6a 100644 --- a/drivers/mfd/timberdale.c +++ b/drivers/mfd/timberdale.c | |||
@@ -115,11 +115,11 @@ static const struct resource timberdale_ocores_resources[] = { | |||
115 | }, | 115 | }, |
116 | }; | 116 | }; |
117 | 117 | ||
118 | const struct max7301_platform_data timberdale_max7301_platform_data = { | 118 | static const struct max7301_platform_data timberdale_max7301_platform_data = { |
119 | .base = 200 | 119 | .base = 200 |
120 | }; | 120 | }; |
121 | 121 | ||
122 | const struct mc33880_platform_data timberdale_mc33880_platform_data = { | 122 | static const struct mc33880_platform_data timberdale_mc33880_platform_data = { |
123 | .base = 100 | 123 | .base = 100 |
124 | }; | 124 | }; |
125 | 125 | ||
@@ -781,7 +781,6 @@ static int timb_probe(struct pci_dev *dev, | |||
781 | priv->fw.major, priv->fw.minor, ip_setup); | 781 | priv->fw.major, priv->fw.minor, ip_setup); |
782 | err = -ENODEV; | 782 | err = -ENODEV; |
783 | goto err_mfd; | 783 | goto err_mfd; |
784 | break; | ||
785 | } | 784 | } |
786 | 785 | ||
787 | if (err) { | 786 | if (err) { |
@@ -869,34 +868,7 @@ static struct pci_driver timberdale_pci_driver = { | |||
869 | .remove = timb_remove, | 868 | .remove = timb_remove, |
870 | }; | 869 | }; |
871 | 870 | ||
872 | static int __init timberdale_init(void) | 871 | module_pci_driver(timberdale_pci_driver); |
873 | { | ||
874 | int err; | ||
875 | |||
876 | err = pci_register_driver(&timberdale_pci_driver); | ||
877 | if (err < 0) { | ||
878 | printk(KERN_ERR | ||
879 | "Failed to register PCI driver for %s device.\n", | ||
880 | timberdale_pci_driver.name); | ||
881 | return -ENODEV; | ||
882 | } | ||
883 | |||
884 | printk(KERN_INFO "Driver for %s has been successfully registered.\n", | ||
885 | timberdale_pci_driver.name); | ||
886 | |||
887 | return 0; | ||
888 | } | ||
889 | |||
890 | static void __exit timberdale_exit(void) | ||
891 | { | ||
892 | pci_unregister_driver(&timberdale_pci_driver); | ||
893 | |||
894 | printk(KERN_INFO "Driver for %s has been successfully unregistered.\n", | ||
895 | timberdale_pci_driver.name); | ||
896 | } | ||
897 | |||
898 | module_init(timberdale_init); | ||
899 | module_exit(timberdale_exit); | ||
900 | 872 | ||
901 | MODULE_AUTHOR("Mocean Laboratories <info@mocean-labs.com>"); | 873 | MODULE_AUTHOR("Mocean Laboratories <info@mocean-labs.com>"); |
902 | MODULE_VERSION(DRV_VERSION); | 874 | MODULE_VERSION(DRV_VERSION); |
diff --git a/drivers/mfd/tps6105x.c b/drivers/mfd/tps6105x.c index 1d302f583adf..b5dfa6e4e692 100644 --- a/drivers/mfd/tps6105x.c +++ b/drivers/mfd/tps6105x.c | |||
@@ -147,7 +147,7 @@ static int tps6105x_probe(struct i2c_client *client, | |||
147 | 147 | ||
148 | i2c_set_clientdata(client, tps6105x); | 148 | i2c_set_clientdata(client, tps6105x); |
149 | tps6105x->client = client; | 149 | tps6105x->client = client; |
150 | pdata = client->dev.platform_data; | 150 | pdata = dev_get_platdata(&client->dev); |
151 | tps6105x->pdata = pdata; | 151 | tps6105x->pdata = pdata; |
152 | mutex_init(&tps6105x->lock); | 152 | mutex_init(&tps6105x->lock); |
153 | 153 | ||
diff --git a/drivers/mfd/tps65010.c b/drivers/mfd/tps65010.c index da2691f22e11..743fb524fc8a 100644 --- a/drivers/mfd/tps65010.c +++ b/drivers/mfd/tps65010.c | |||
@@ -242,8 +242,8 @@ static int dbg_show(struct seq_file *s, void *_) | |||
242 | seq_printf(s, "mask2 %s\n", buf); | 242 | seq_printf(s, "mask2 %s\n", buf); |
243 | /* ignore ackint2 */ | 243 | /* ignore ackint2 */ |
244 | 244 | ||
245 | schedule_delayed_work(&tps->work, POWER_POLL_DELAY); | 245 | queue_delayed_work(system_power_efficient_wq, &tps->work, |
246 | 246 | POWER_POLL_DELAY); | |
247 | 247 | ||
248 | /* VMAIN voltage, enable lowpower, etc */ | 248 | /* VMAIN voltage, enable lowpower, etc */ |
249 | value = i2c_smbus_read_byte_data(tps->client, TPS_VDCDC1); | 249 | value = i2c_smbus_read_byte_data(tps->client, TPS_VDCDC1); |
@@ -400,7 +400,8 @@ static void tps65010_interrupt(struct tps65010 *tps) | |||
400 | && (tps->chgstatus & (TPS_CHG_USB|TPS_CHG_AC))) | 400 | && (tps->chgstatus & (TPS_CHG_USB|TPS_CHG_AC))) |
401 | poll = 1; | 401 | poll = 1; |
402 | if (poll) | 402 | if (poll) |
403 | schedule_delayed_work(&tps->work, POWER_POLL_DELAY); | 403 | queue_delayed_work(system_power_efficient_wq, &tps->work, |
404 | POWER_POLL_DELAY); | ||
404 | 405 | ||
405 | /* also potentially gpio-in rise or fall */ | 406 | /* also potentially gpio-in rise or fall */ |
406 | } | 407 | } |
@@ -448,7 +449,7 @@ static irqreturn_t tps65010_irq(int irq, void *_tps) | |||
448 | 449 | ||
449 | disable_irq_nosync(irq); | 450 | disable_irq_nosync(irq); |
450 | set_bit(FLAG_IRQ_ENABLE, &tps->flags); | 451 | set_bit(FLAG_IRQ_ENABLE, &tps->flags); |
451 | schedule_delayed_work(&tps->work, 0); | 452 | queue_delayed_work(system_power_efficient_wq, &tps->work, 0); |
452 | return IRQ_HANDLED; | 453 | return IRQ_HANDLED; |
453 | } | 454 | } |
454 | 455 | ||
@@ -517,7 +518,7 @@ static struct tps65010 *the_tps; | |||
517 | static int __exit tps65010_remove(struct i2c_client *client) | 518 | static int __exit tps65010_remove(struct i2c_client *client) |
518 | { | 519 | { |
519 | struct tps65010 *tps = i2c_get_clientdata(client); | 520 | struct tps65010 *tps = i2c_get_clientdata(client); |
520 | struct tps65010_board *board = client->dev.platform_data; | 521 | struct tps65010_board *board = dev_get_platdata(&client->dev); |
521 | 522 | ||
522 | if (board && board->teardown) { | 523 | if (board && board->teardown) { |
523 | int status = board->teardown(client, board->context); | 524 | int status = board->teardown(client, board->context); |
@@ -529,7 +530,6 @@ static int __exit tps65010_remove(struct i2c_client *client) | |||
529 | free_irq(client->irq, tps); | 530 | free_irq(client->irq, tps); |
530 | cancel_delayed_work_sync(&tps->work); | 531 | cancel_delayed_work_sync(&tps->work); |
531 | debugfs_remove(tps->file); | 532 | debugfs_remove(tps->file); |
532 | kfree(tps); | ||
533 | the_tps = NULL; | 533 | the_tps = NULL; |
534 | return 0; | 534 | return 0; |
535 | } | 535 | } |
@@ -539,7 +539,7 @@ static int tps65010_probe(struct i2c_client *client, | |||
539 | { | 539 | { |
540 | struct tps65010 *tps; | 540 | struct tps65010 *tps; |
541 | int status; | 541 | int status; |
542 | struct tps65010_board *board = client->dev.platform_data; | 542 | struct tps65010_board *board = dev_get_platdata(&client->dev); |
543 | 543 | ||
544 | if (the_tps) { | 544 | if (the_tps) { |
545 | dev_dbg(&client->dev, "only one tps6501x chip allowed\n"); | 545 | dev_dbg(&client->dev, "only one tps6501x chip allowed\n"); |
@@ -549,7 +549,7 @@ static int tps65010_probe(struct i2c_client *client, | |||
549 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 549 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
550 | return -EINVAL; | 550 | return -EINVAL; |
551 | 551 | ||
552 | tps = kzalloc(sizeof *tps, GFP_KERNEL); | 552 | tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); |
553 | if (!tps) | 553 | if (!tps) |
554 | return -ENOMEM; | 554 | return -ENOMEM; |
555 | 555 | ||
@@ -567,7 +567,7 @@ static int tps65010_probe(struct i2c_client *client, | |||
567 | if (status < 0) { | 567 | if (status < 0) { |
568 | dev_dbg(&client->dev, "can't get IRQ %d, err %d\n", | 568 | dev_dbg(&client->dev, "can't get IRQ %d, err %d\n", |
569 | client->irq, status); | 569 | client->irq, status); |
570 | goto fail1; | 570 | return status; |
571 | } | 571 | } |
572 | /* annoying race here, ideally we'd have an option | 572 | /* annoying race here, ideally we'd have an option |
573 | * to claim the irq now and enable it later. | 573 | * to claim the irq now and enable it later. |
@@ -667,9 +667,6 @@ static int tps65010_probe(struct i2c_client *client, | |||
667 | } | 667 | } |
668 | 668 | ||
669 | return 0; | 669 | return 0; |
670 | fail1: | ||
671 | kfree(tps); | ||
672 | return status; | ||
673 | } | 670 | } |
674 | 671 | ||
675 | static const struct i2c_device_id tps65010_id[] = { | 672 | static const struct i2c_device_id tps65010_id[] = { |
@@ -718,7 +715,8 @@ int tps65010_set_vbus_draw(unsigned mA) | |||
718 | && test_and_set_bit( | 715 | && test_and_set_bit( |
719 | FLAG_VBUS_CHANGED, &the_tps->flags)) { | 716 | FLAG_VBUS_CHANGED, &the_tps->flags)) { |
720 | /* gadget drivers call this in_irq() */ | 717 | /* gadget drivers call this in_irq() */ |
721 | schedule_delayed_work(&the_tps->work, 0); | 718 | queue_delayed_work(system_power_efficient_wq, &the_tps->work, |
719 | 0); | ||
722 | } | 720 | } |
723 | local_irq_restore(flags); | 721 | local_irq_restore(flags); |
724 | 722 | ||
diff --git a/drivers/mfd/tps65090.c b/drivers/mfd/tps65090.c index fbd6ee67b5a5..e6f03a733879 100644 --- a/drivers/mfd/tps65090.c +++ b/drivers/mfd/tps65090.c | |||
@@ -172,7 +172,7 @@ MODULE_DEVICE_TABLE(of, tps65090_of_match); | |||
172 | static int tps65090_i2c_probe(struct i2c_client *client, | 172 | static int tps65090_i2c_probe(struct i2c_client *client, |
173 | const struct i2c_device_id *id) | 173 | const struct i2c_device_id *id) |
174 | { | 174 | { |
175 | struct tps65090_platform_data *pdata = client->dev.platform_data; | 175 | struct tps65090_platform_data *pdata = dev_get_platdata(&client->dev); |
176 | int irq_base = 0; | 176 | int irq_base = 0; |
177 | struct tps65090 *tps65090; | 177 | struct tps65090 *tps65090; |
178 | int ret; | 178 | int ret; |
diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c index 4b93ed4d5cd6..f54fe4d4f77b 100644 --- a/drivers/mfd/tps6586x.c +++ b/drivers/mfd/tps6586x.c | |||
@@ -462,7 +462,7 @@ static void tps6586x_power_off(void) | |||
462 | static int tps6586x_i2c_probe(struct i2c_client *client, | 462 | static int tps6586x_i2c_probe(struct i2c_client *client, |
463 | const struct i2c_device_id *id) | 463 | const struct i2c_device_id *id) |
464 | { | 464 | { |
465 | struct tps6586x_platform_data *pdata = client->dev.platform_data; | 465 | struct tps6586x_platform_data *pdata = dev_get_platdata(&client->dev); |
466 | struct tps6586x *tps6586x; | 466 | struct tps6586x *tps6586x; |
467 | int ret; | 467 | int ret; |
468 | 468 | ||
diff --git a/drivers/mfd/tps65912-core.c b/drivers/mfd/tps65912-core.c index 479886a4cf80..925a044cbdf6 100644 --- a/drivers/mfd/tps65912-core.c +++ b/drivers/mfd/tps65912-core.c | |||
@@ -123,7 +123,7 @@ EXPORT_SYMBOL_GPL(tps65912_reg_write); | |||
123 | 123 | ||
124 | int tps65912_device_init(struct tps65912 *tps65912) | 124 | int tps65912_device_init(struct tps65912 *tps65912) |
125 | { | 125 | { |
126 | struct tps65912_board *pmic_plat_data = tps65912->dev->platform_data; | 126 | struct tps65912_board *pmic_plat_data = dev_get_platdata(tps65912->dev); |
127 | struct tps65912_platform_data *init_data; | 127 | struct tps65912_platform_data *init_data; |
128 | int ret, dcdc_avs, value; | 128 | int ret, dcdc_avs, value; |
129 | 129 | ||
diff --git a/drivers/mfd/tps80031.c b/drivers/mfd/tps80031.c index c90a2c450f51..f15ee6d5cfbf 100644 --- a/drivers/mfd/tps80031.c +++ b/drivers/mfd/tps80031.c | |||
@@ -418,7 +418,7 @@ static const struct regmap_config tps80031_regmap_configs[] = { | |||
418 | static int tps80031_probe(struct i2c_client *client, | 418 | static int tps80031_probe(struct i2c_client *client, |
419 | const struct i2c_device_id *id) | 419 | const struct i2c_device_id *id) |
420 | { | 420 | { |
421 | struct tps80031_platform_data *pdata = client->dev.platform_data; | 421 | struct tps80031_platform_data *pdata = dev_get_platdata(&client->dev); |
422 | struct tps80031 *tps80031; | 422 | struct tps80031 *tps80031; |
423 | int ret; | 423 | int ret; |
424 | uint8_t es_version; | 424 | uint8_t es_version; |
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c index 7f150d94d295..29473c2c95ae 100644 --- a/drivers/mfd/twl-core.c +++ b/drivers/mfd/twl-core.c | |||
@@ -1137,7 +1137,7 @@ static int twl_remove(struct i2c_client *client) | |||
1137 | static int | 1137 | static int |
1138 | twl_probe(struct i2c_client *client, const struct i2c_device_id *id) | 1138 | twl_probe(struct i2c_client *client, const struct i2c_device_id *id) |
1139 | { | 1139 | { |
1140 | struct twl4030_platform_data *pdata = client->dev.platform_data; | 1140 | struct twl4030_platform_data *pdata = dev_get_platdata(&client->dev); |
1141 | struct device_node *node = client->dev.of_node; | 1141 | struct device_node *node = client->dev.of_node; |
1142 | struct platform_device *pdev; | 1142 | struct platform_device *pdev; |
1143 | struct regmap_config *twl_regmap_config; | 1143 | struct regmap_config *twl_regmap_config; |
diff --git a/drivers/mfd/twl4030-audio.c b/drivers/mfd/twl4030-audio.c index a31fba96ef43..07fe542e6fc0 100644 --- a/drivers/mfd/twl4030-audio.c +++ b/drivers/mfd/twl4030-audio.c | |||
@@ -187,7 +187,7 @@ static bool twl4030_audio_has_vibra(struct twl4030_audio_data *pdata, | |||
187 | static int twl4030_audio_probe(struct platform_device *pdev) | 187 | static int twl4030_audio_probe(struct platform_device *pdev) |
188 | { | 188 | { |
189 | struct twl4030_audio *audio; | 189 | struct twl4030_audio *audio; |
190 | struct twl4030_audio_data *pdata = pdev->dev.platform_data; | 190 | struct twl4030_audio_data *pdata = dev_get_platdata(&pdev->dev); |
191 | struct device_node *node = pdev->dev.of_node; | 191 | struct device_node *node = pdev->dev.of_node; |
192 | struct mfd_cell *cell = NULL; | 192 | struct mfd_cell *cell = NULL; |
193 | int ret, childs = 0; | 193 | int ret, childs = 0; |
diff --git a/drivers/mfd/twl4030-madc.c b/drivers/mfd/twl4030-madc.c index 1ea54d4d003a..4c583e471339 100644 --- a/drivers/mfd/twl4030-madc.c +++ b/drivers/mfd/twl4030-madc.c | |||
@@ -701,7 +701,7 @@ static int twl4030_madc_set_power(struct twl4030_madc_data *madc, int on) | |||
701 | static int twl4030_madc_probe(struct platform_device *pdev) | 701 | static int twl4030_madc_probe(struct platform_device *pdev) |
702 | { | 702 | { |
703 | struct twl4030_madc_data *madc; | 703 | struct twl4030_madc_data *madc; |
704 | struct twl4030_madc_platform_data *pdata = pdev->dev.platform_data; | 704 | struct twl4030_madc_platform_data *pdata = dev_get_platdata(&pdev->dev); |
705 | int ret; | 705 | int ret; |
706 | u8 regval; | 706 | u8 regval; |
707 | 707 | ||
diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c index a5fd3c738211..96162b62f3c0 100644 --- a/drivers/mfd/twl4030-power.c +++ b/drivers/mfd/twl4030-power.c | |||
@@ -493,7 +493,7 @@ int twl4030_remove_script(u8 flags) | |||
493 | return err; | 493 | return err; |
494 | } | 494 | } |
495 | 495 | ||
496 | int twl4030_power_configure_scripts(struct twl4030_power_data *pdata) | 496 | static int twl4030_power_configure_scripts(struct twl4030_power_data *pdata) |
497 | { | 497 | { |
498 | int err; | 498 | int err; |
499 | int i; | 499 | int i; |
@@ -509,7 +509,7 @@ int twl4030_power_configure_scripts(struct twl4030_power_data *pdata) | |||
509 | return 0; | 509 | return 0; |
510 | } | 510 | } |
511 | 511 | ||
512 | int twl4030_power_configure_resources(struct twl4030_power_data *pdata) | 512 | static int twl4030_power_configure_resources(struct twl4030_power_data *pdata) |
513 | { | 513 | { |
514 | struct twl4030_resconfig *resconfig = pdata->resource_config; | 514 | struct twl4030_resconfig *resconfig = pdata->resource_config; |
515 | int err; | 515 | int err; |
@@ -553,9 +553,9 @@ static bool twl4030_power_use_poweroff(struct twl4030_power_data *pdata, | |||
553 | return false; | 553 | return false; |
554 | } | 554 | } |
555 | 555 | ||
556 | int twl4030_power_probe(struct platform_device *pdev) | 556 | static int twl4030_power_probe(struct platform_device *pdev) |
557 | { | 557 | { |
558 | struct twl4030_power_data *pdata = pdev->dev.platform_data; | 558 | struct twl4030_power_data *pdata = dev_get_platdata(&pdev->dev); |
559 | struct device_node *node = pdev->dev.of_node; | 559 | struct device_node *node = pdev->dev.of_node; |
560 | int err = 0; | 560 | int err = 0; |
561 | int err2 = 0; | 561 | int err2 = 0; |
diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c index 277a8dba42d5..517eda832f79 100644 --- a/drivers/mfd/twl6030-irq.c +++ b/drivers/mfd/twl6030-irq.c | |||
@@ -41,6 +41,7 @@ | |||
41 | #include <linux/suspend.h> | 41 | #include <linux/suspend.h> |
42 | #include <linux/of.h> | 42 | #include <linux/of.h> |
43 | #include <linux/irqdomain.h> | 43 | #include <linux/irqdomain.h> |
44 | #include <linux/of_device.h> | ||
44 | 45 | ||
45 | #include "twl-core.h" | 46 | #include "twl-core.h" |
46 | 47 | ||
@@ -84,39 +85,77 @@ static int twl6030_interrupt_mapping[24] = { | |||
84 | CHARGERFAULT_INTR_OFFSET, /* Bit 22 INT_CHRG */ | 85 | CHARGERFAULT_INTR_OFFSET, /* Bit 22 INT_CHRG */ |
85 | RSV_INTR_OFFSET, /* Bit 23 Reserved */ | 86 | RSV_INTR_OFFSET, /* Bit 23 Reserved */ |
86 | }; | 87 | }; |
88 | |||
89 | static int twl6032_interrupt_mapping[24] = { | ||
90 | PWR_INTR_OFFSET, /* Bit 0 PWRON */ | ||
91 | PWR_INTR_OFFSET, /* Bit 1 RPWRON */ | ||
92 | PWR_INTR_OFFSET, /* Bit 2 SYS_VLOW */ | ||
93 | RTC_INTR_OFFSET, /* Bit 3 RTC_ALARM */ | ||
94 | RTC_INTR_OFFSET, /* Bit 4 RTC_PERIOD */ | ||
95 | HOTDIE_INTR_OFFSET, /* Bit 5 HOT_DIE */ | ||
96 | SMPSLDO_INTR_OFFSET, /* Bit 6 VXXX_SHORT */ | ||
97 | PWR_INTR_OFFSET, /* Bit 7 SPDURATION */ | ||
98 | |||
99 | PWR_INTR_OFFSET, /* Bit 8 WATCHDOG */ | ||
100 | BATDETECT_INTR_OFFSET, /* Bit 9 BAT */ | ||
101 | SIMDETECT_INTR_OFFSET, /* Bit 10 SIM */ | ||
102 | MMCDETECT_INTR_OFFSET, /* Bit 11 MMC */ | ||
103 | MADC_INTR_OFFSET, /* Bit 12 GPADC_RT_EOC */ | ||
104 | MADC_INTR_OFFSET, /* Bit 13 GPADC_SW_EOC */ | ||
105 | GASGAUGE_INTR_OFFSET, /* Bit 14 CC_EOC */ | ||
106 | GASGAUGE_INTR_OFFSET, /* Bit 15 CC_AUTOCAL */ | ||
107 | |||
108 | USBOTG_INTR_OFFSET, /* Bit 16 ID_WKUP */ | ||
109 | USBOTG_INTR_OFFSET, /* Bit 17 VBUS_WKUP */ | ||
110 | USBOTG_INTR_OFFSET, /* Bit 18 ID */ | ||
111 | USB_PRES_INTR_OFFSET, /* Bit 19 VBUS */ | ||
112 | CHARGER_INTR_OFFSET, /* Bit 20 CHRG_CTRL */ | ||
113 | CHARGERFAULT_INTR_OFFSET, /* Bit 21 EXT_CHRG */ | ||
114 | CHARGERFAULT_INTR_OFFSET, /* Bit 22 INT_CHRG */ | ||
115 | RSV_INTR_OFFSET, /* Bit 23 Reserved */ | ||
116 | }; | ||
117 | |||
87 | /*----------------------------------------------------------------------*/ | 118 | /*----------------------------------------------------------------------*/ |
88 | 119 | ||
89 | static unsigned twl6030_irq_base; | 120 | struct twl6030_irq { |
90 | static int twl_irq; | 121 | unsigned int irq_base; |
91 | static bool twl_irq_wake_enabled; | 122 | int twl_irq; |
123 | bool irq_wake_enabled; | ||
124 | atomic_t wakeirqs; | ||
125 | struct notifier_block pm_nb; | ||
126 | struct irq_chip irq_chip; | ||
127 | struct irq_domain *irq_domain; | ||
128 | const int *irq_mapping_tbl; | ||
129 | }; | ||
92 | 130 | ||
93 | static struct completion irq_event; | 131 | static struct twl6030_irq *twl6030_irq; |
94 | static atomic_t twl6030_wakeirqs = ATOMIC_INIT(0); | ||
95 | 132 | ||
96 | static int twl6030_irq_pm_notifier(struct notifier_block *notifier, | 133 | static int twl6030_irq_pm_notifier(struct notifier_block *notifier, |
97 | unsigned long pm_event, void *unused) | 134 | unsigned long pm_event, void *unused) |
98 | { | 135 | { |
99 | int chained_wakeups; | 136 | int chained_wakeups; |
137 | struct twl6030_irq *pdata = container_of(notifier, struct twl6030_irq, | ||
138 | pm_nb); | ||
100 | 139 | ||
101 | switch (pm_event) { | 140 | switch (pm_event) { |
102 | case PM_SUSPEND_PREPARE: | 141 | case PM_SUSPEND_PREPARE: |
103 | chained_wakeups = atomic_read(&twl6030_wakeirqs); | 142 | chained_wakeups = atomic_read(&pdata->wakeirqs); |
104 | 143 | ||
105 | if (chained_wakeups && !twl_irq_wake_enabled) { | 144 | if (chained_wakeups && !pdata->irq_wake_enabled) { |
106 | if (enable_irq_wake(twl_irq)) | 145 | if (enable_irq_wake(pdata->twl_irq)) |
107 | pr_err("twl6030 IRQ wake enable failed\n"); | 146 | pr_err("twl6030 IRQ wake enable failed\n"); |
108 | else | 147 | else |
109 | twl_irq_wake_enabled = true; | 148 | pdata->irq_wake_enabled = true; |
110 | } else if (!chained_wakeups && twl_irq_wake_enabled) { | 149 | } else if (!chained_wakeups && pdata->irq_wake_enabled) { |
111 | disable_irq_wake(twl_irq); | 150 | disable_irq_wake(pdata->twl_irq); |
112 | twl_irq_wake_enabled = false; | 151 | pdata->irq_wake_enabled = false; |
113 | } | 152 | } |
114 | 153 | ||
115 | disable_irq(twl_irq); | 154 | disable_irq(pdata->twl_irq); |
116 | break; | 155 | break; |
117 | 156 | ||
118 | case PM_POST_SUSPEND: | 157 | case PM_POST_SUSPEND: |
119 | enable_irq(twl_irq); | 158 | enable_irq(pdata->twl_irq); |
120 | break; | 159 | break; |
121 | 160 | ||
122 | default: | 161 | default: |
@@ -126,124 +165,77 @@ static int twl6030_irq_pm_notifier(struct notifier_block *notifier, | |||
126 | return NOTIFY_DONE; | 165 | return NOTIFY_DONE; |
127 | } | 166 | } |
128 | 167 | ||
129 | static struct notifier_block twl6030_irq_pm_notifier_block = { | ||
130 | .notifier_call = twl6030_irq_pm_notifier, | ||
131 | }; | ||
132 | |||
133 | /* | 168 | /* |
134 | * This thread processes interrupts reported by the Primary Interrupt Handler. | 169 | * Threaded irq handler for the twl6030 interrupt. |
135 | */ | 170 | * We query the interrupt controller in the twl6030 to determine |
136 | static int twl6030_irq_thread(void *data) | 171 | * which module is generating the interrupt request and call |
172 | * handle_nested_irq for that module. | ||
173 | */ | ||
174 | static irqreturn_t twl6030_irq_thread(int irq, void *data) | ||
137 | { | 175 | { |
138 | long irq = (long)data; | 176 | int i, ret; |
139 | static unsigned i2c_errors; | 177 | union { |
140 | static const unsigned max_i2c_errors = 100; | ||
141 | int ret; | ||
142 | |||
143 | while (!kthread_should_stop()) { | ||
144 | int i; | ||
145 | union { | ||
146 | u8 bytes[4]; | 178 | u8 bytes[4]; |
147 | u32 int_sts; | 179 | u32 int_sts; |
148 | } sts; | 180 | } sts; |
149 | 181 | struct twl6030_irq *pdata = data; | |
150 | /* Wait for IRQ, then read PIH irq status (also blocking) */ | 182 | |
151 | wait_for_completion_interruptible(&irq_event); | 183 | /* read INT_STS_A, B and C in one shot using a burst read */ |
152 | 184 | ret = twl_i2c_read(TWL_MODULE_PIH, sts.bytes, REG_INT_STS_A, 3); | |
153 | /* read INT_STS_A, B and C in one shot using a burst read */ | 185 | if (ret) { |
154 | ret = twl_i2c_read(TWL_MODULE_PIH, sts.bytes, | 186 | pr_warn("twl6030_irq: I2C error %d reading PIH ISR\n", ret); |
155 | REG_INT_STS_A, 3); | 187 | return IRQ_HANDLED; |
156 | if (ret) { | 188 | } |
157 | pr_warning("twl6030: I2C error %d reading PIH ISR\n", | ||
158 | ret); | ||
159 | if (++i2c_errors >= max_i2c_errors) { | ||
160 | printk(KERN_ERR "Maximum I2C error count" | ||
161 | " exceeded. Terminating %s.\n", | ||
162 | __func__); | ||
163 | break; | ||
164 | } | ||
165 | complete(&irq_event); | ||
166 | continue; | ||
167 | } | ||
168 | |||
169 | |||
170 | 189 | ||
171 | sts.bytes[3] = 0; /* Only 24 bits are valid*/ | 190 | sts.bytes[3] = 0; /* Only 24 bits are valid*/ |
172 | 191 | ||
173 | /* | 192 | /* |
174 | * Since VBUS status bit is not reliable for VBUS disconnect | 193 | * Since VBUS status bit is not reliable for VBUS disconnect |
175 | * use CHARGER VBUS detection status bit instead. | 194 | * use CHARGER VBUS detection status bit instead. |
176 | */ | 195 | */ |
177 | if (sts.bytes[2] & 0x10) | 196 | if (sts.bytes[2] & 0x10) |
178 | sts.bytes[2] |= 0x08; | 197 | sts.bytes[2] |= 0x08; |
179 | 198 | ||
180 | for (i = 0; sts.int_sts; sts.int_sts >>= 1, i++) { | 199 | for (i = 0; sts.int_sts; sts.int_sts >>= 1, i++) |
181 | local_irq_disable(); | 200 | if (sts.int_sts & 0x1) { |
182 | if (sts.int_sts & 0x1) { | 201 | int module_irq = |
183 | int module_irq = twl6030_irq_base + | 202 | irq_find_mapping(pdata->irq_domain, |
184 | twl6030_interrupt_mapping[i]; | 203 | pdata->irq_mapping_tbl[i]); |
185 | generic_handle_irq(module_irq); | 204 | if (module_irq) |
186 | 205 | handle_nested_irq(module_irq); | |
187 | } | 206 | else |
188 | local_irq_enable(); | 207 | pr_err("twl6030_irq: Unmapped PIH ISR %u detected\n", |
208 | i); | ||
209 | pr_debug("twl6030_irq: PIH ISR %u, virq%u\n", | ||
210 | i, module_irq); | ||
189 | } | 211 | } |
190 | 212 | ||
191 | /* | 213 | /* |
192 | * NOTE: | 214 | * NOTE: |
193 | * Simulation confirms that documentation is wrong w.r.t the | 215 | * Simulation confirms that documentation is wrong w.r.t the |
194 | * interrupt status clear operation. A single *byte* write to | 216 | * interrupt status clear operation. A single *byte* write to |
195 | * any one of STS_A to STS_C register results in all three | 217 | * any one of STS_A to STS_C register results in all three |
196 | * STS registers being reset. Since it does not matter which | 218 | * STS registers being reset. Since it does not matter which |
197 | * value is written, all three registers are cleared on a | 219 | * value is written, all three registers are cleared on a |
198 | * single byte write, so we just use 0x0 to clear. | 220 | * single byte write, so we just use 0x0 to clear. |
199 | */ | 221 | */ |
200 | ret = twl_i2c_write_u8(TWL_MODULE_PIH, 0x00, REG_INT_STS_A); | 222 | ret = twl_i2c_write_u8(TWL_MODULE_PIH, 0x00, REG_INT_STS_A); |
201 | if (ret) | 223 | if (ret) |
202 | pr_warning("twl6030: I2C error in clearing PIH ISR\n"); | 224 | pr_warn("twl6030_irq: I2C error in clearing PIH ISR\n"); |
203 | |||
204 | enable_irq(irq); | ||
205 | } | ||
206 | |||
207 | return 0; | ||
208 | } | ||
209 | 225 | ||
210 | /* | ||
211 | * handle_twl6030_int() is the desc->handle method for the twl6030 interrupt. | ||
212 | * This is a chained interrupt, so there is no desc->action method for it. | ||
213 | * Now we need to query the interrupt controller in the twl6030 to determine | ||
214 | * which module is generating the interrupt request. However, we can't do i2c | ||
215 | * transactions in interrupt context, so we must defer that work to a kernel | ||
216 | * thread. All we do here is acknowledge and mask the interrupt and wakeup | ||
217 | * the kernel thread. | ||
218 | */ | ||
219 | static irqreturn_t handle_twl6030_pih(int irq, void *devid) | ||
220 | { | ||
221 | disable_irq_nosync(irq); | ||
222 | complete(devid); | ||
223 | return IRQ_HANDLED; | 226 | return IRQ_HANDLED; |
224 | } | 227 | } |
225 | 228 | ||
226 | /*----------------------------------------------------------------------*/ | 229 | /*----------------------------------------------------------------------*/ |
227 | 230 | ||
228 | static inline void activate_irq(int irq) | ||
229 | { | ||
230 | #ifdef CONFIG_ARM | ||
231 | /* ARM requires an extra step to clear IRQ_NOREQUEST, which it | ||
232 | * sets on behalf of every irq_chip. Also sets IRQ_NOPROBE. | ||
233 | */ | ||
234 | set_irq_flags(irq, IRQF_VALID); | ||
235 | #else | ||
236 | /* same effect on other architectures */ | ||
237 | irq_set_noprobe(irq); | ||
238 | #endif | ||
239 | } | ||
240 | |||
241 | static int twl6030_irq_set_wake(struct irq_data *d, unsigned int on) | 231 | static int twl6030_irq_set_wake(struct irq_data *d, unsigned int on) |
242 | { | 232 | { |
233 | struct twl6030_irq *pdata = irq_get_chip_data(d->irq); | ||
234 | |||
243 | if (on) | 235 | if (on) |
244 | atomic_inc(&twl6030_wakeirqs); | 236 | atomic_inc(&pdata->wakeirqs); |
245 | else | 237 | else |
246 | atomic_dec(&twl6030_wakeirqs); | 238 | atomic_dec(&pdata->wakeirqs); |
247 | 239 | ||
248 | return 0; | 240 | return 0; |
249 | } | 241 | } |
@@ -318,7 +310,8 @@ int twl6030_mmc_card_detect_config(void) | |||
318 | return ret; | 310 | return ret; |
319 | } | 311 | } |
320 | 312 | ||
321 | return twl6030_irq_base + MMCDETECT_INTR_OFFSET; | 313 | return irq_find_mapping(twl6030_irq->irq_domain, |
314 | MMCDETECT_INTR_OFFSET); | ||
322 | } | 315 | } |
323 | EXPORT_SYMBOL(twl6030_mmc_card_detect_config); | 316 | EXPORT_SYMBOL(twl6030_mmc_card_detect_config); |
324 | 317 | ||
@@ -347,99 +340,143 @@ int twl6030_mmc_card_detect(struct device *dev, int slot) | |||
347 | } | 340 | } |
348 | EXPORT_SYMBOL(twl6030_mmc_card_detect); | 341 | EXPORT_SYMBOL(twl6030_mmc_card_detect); |
349 | 342 | ||
343 | static int twl6030_irq_map(struct irq_domain *d, unsigned int virq, | ||
344 | irq_hw_number_t hwirq) | ||
345 | { | ||
346 | struct twl6030_irq *pdata = d->host_data; | ||
347 | |||
348 | irq_set_chip_data(virq, pdata); | ||
349 | irq_set_chip_and_handler(virq, &pdata->irq_chip, handle_simple_irq); | ||
350 | irq_set_nested_thread(virq, true); | ||
351 | irq_set_parent(virq, pdata->twl_irq); | ||
352 | |||
353 | #ifdef CONFIG_ARM | ||
354 | /* | ||
355 | * ARM requires an extra step to clear IRQ_NOREQUEST, which it | ||
356 | * sets on behalf of every irq_chip. Also sets IRQ_NOPROBE. | ||
357 | */ | ||
358 | set_irq_flags(virq, IRQF_VALID); | ||
359 | #else | ||
360 | /* same effect on other architectures */ | ||
361 | irq_set_noprobe(virq); | ||
362 | #endif | ||
363 | |||
364 | return 0; | ||
365 | } | ||
366 | |||
367 | static void twl6030_irq_unmap(struct irq_domain *d, unsigned int virq) | ||
368 | { | ||
369 | #ifdef CONFIG_ARM | ||
370 | set_irq_flags(virq, 0); | ||
371 | #endif | ||
372 | irq_set_chip_and_handler(virq, NULL, NULL); | ||
373 | irq_set_chip_data(virq, NULL); | ||
374 | } | ||
375 | |||
376 | static struct irq_domain_ops twl6030_irq_domain_ops = { | ||
377 | .map = twl6030_irq_map, | ||
378 | .unmap = twl6030_irq_unmap, | ||
379 | .xlate = irq_domain_xlate_onetwocell, | ||
380 | }; | ||
381 | |||
382 | static const struct of_device_id twl6030_of_match[] = { | ||
383 | {.compatible = "ti,twl6030", &twl6030_interrupt_mapping}, | ||
384 | {.compatible = "ti,twl6032", &twl6032_interrupt_mapping}, | ||
385 | { }, | ||
386 | }; | ||
387 | |||
350 | int twl6030_init_irq(struct device *dev, int irq_num) | 388 | int twl6030_init_irq(struct device *dev, int irq_num) |
351 | { | 389 | { |
352 | struct device_node *node = dev->of_node; | 390 | struct device_node *node = dev->of_node; |
353 | int nr_irqs, irq_base, irq_end; | 391 | int nr_irqs; |
354 | struct task_struct *task; | 392 | int status; |
355 | static struct irq_chip twl6030_irq_chip; | ||
356 | int status = 0; | ||
357 | int i; | ||
358 | u8 mask[3]; | 393 | u8 mask[3]; |
394 | const struct of_device_id *of_id; | ||
359 | 395 | ||
360 | nr_irqs = TWL6030_NR_IRQS; | 396 | of_id = of_match_device(twl6030_of_match, dev); |
361 | 397 | if (!of_id || !of_id->data) { | |
362 | irq_base = irq_alloc_descs(-1, 0, nr_irqs, 0); | 398 | dev_err(dev, "Unknown TWL device model\n"); |
363 | if (IS_ERR_VALUE(irq_base)) { | 399 | return -EINVAL; |
364 | dev_err(dev, "Fail to allocate IRQ descs\n"); | ||
365 | return irq_base; | ||
366 | } | 400 | } |
367 | 401 | ||
368 | irq_domain_add_legacy(node, nr_irqs, irq_base, 0, | 402 | nr_irqs = TWL6030_NR_IRQS; |
369 | &irq_domain_simple_ops, NULL); | ||
370 | 403 | ||
371 | irq_end = irq_base + nr_irqs; | 404 | twl6030_irq = devm_kzalloc(dev, sizeof(*twl6030_irq), GFP_KERNEL); |
405 | if (!twl6030_irq) { | ||
406 | dev_err(dev, "twl6030_irq: Memory allocation failed\n"); | ||
407 | return -ENOMEM; | ||
408 | } | ||
372 | 409 | ||
373 | mask[0] = 0xFF; | 410 | mask[0] = 0xFF; |
374 | mask[1] = 0xFF; | 411 | mask[1] = 0xFF; |
375 | mask[2] = 0xFF; | 412 | mask[2] = 0xFF; |
376 | 413 | ||
377 | /* mask all int lines */ | 414 | /* mask all int lines */ |
378 | twl_i2c_write(TWL_MODULE_PIH, &mask[0], REG_INT_MSK_LINE_A, 3); | 415 | status = twl_i2c_write(TWL_MODULE_PIH, &mask[0], REG_INT_MSK_LINE_A, 3); |
379 | /* mask all int sts */ | 416 | /* mask all int sts */ |
380 | twl_i2c_write(TWL_MODULE_PIH, &mask[0], REG_INT_MSK_STS_A, 3); | 417 | status |= twl_i2c_write(TWL_MODULE_PIH, &mask[0], REG_INT_MSK_STS_A, 3); |
381 | /* clear INT_STS_A,B,C */ | 418 | /* clear INT_STS_A,B,C */ |
382 | twl_i2c_write(TWL_MODULE_PIH, &mask[0], REG_INT_STS_A, 3); | 419 | status |= twl_i2c_write(TWL_MODULE_PIH, &mask[0], REG_INT_STS_A, 3); |
383 | 420 | ||
384 | twl6030_irq_base = irq_base; | 421 | if (status < 0) { |
422 | dev_err(dev, "I2C err writing TWL_MODULE_PIH: %d\n", status); | ||
423 | return status; | ||
424 | } | ||
385 | 425 | ||
386 | /* | 426 | /* |
387 | * install an irq handler for each of the modules; | 427 | * install an irq handler for each of the modules; |
388 | * clone dummy irq_chip since PIH can't *do* anything | 428 | * clone dummy irq_chip since PIH can't *do* anything |
389 | */ | 429 | */ |
390 | twl6030_irq_chip = dummy_irq_chip; | 430 | twl6030_irq->irq_chip = dummy_irq_chip; |
391 | twl6030_irq_chip.name = "twl6030"; | 431 | twl6030_irq->irq_chip.name = "twl6030"; |
392 | twl6030_irq_chip.irq_set_type = NULL; | 432 | twl6030_irq->irq_chip.irq_set_type = NULL; |
393 | twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake; | 433 | twl6030_irq->irq_chip.irq_set_wake = twl6030_irq_set_wake; |
394 | 434 | ||
395 | for (i = irq_base; i < irq_end; i++) { | 435 | twl6030_irq->pm_nb.notifier_call = twl6030_irq_pm_notifier; |
396 | irq_set_chip_and_handler(i, &twl6030_irq_chip, | 436 | atomic_set(&twl6030_irq->wakeirqs, 0); |
397 | handle_simple_irq); | 437 | twl6030_irq->irq_mapping_tbl = of_id->data; |
398 | irq_set_chip_data(i, (void *)irq_num); | 438 | |
399 | activate_irq(i); | 439 | twl6030_irq->irq_domain = |
440 | irq_domain_add_linear(node, nr_irqs, | ||
441 | &twl6030_irq_domain_ops, twl6030_irq); | ||
442 | if (!twl6030_irq->irq_domain) { | ||
443 | dev_err(dev, "Can't add irq_domain\n"); | ||
444 | return -ENOMEM; | ||
400 | } | 445 | } |
401 | 446 | ||
402 | dev_info(dev, "PIH (irq %d) chaining IRQs %d..%d\n", | 447 | dev_info(dev, "PIH (irq %d) nested IRQs\n", irq_num); |
403 | irq_num, irq_base, irq_end); | ||
404 | 448 | ||
405 | /* install an irq handler to demultiplex the TWL6030 interrupt */ | 449 | /* install an irq handler to demultiplex the TWL6030 interrupt */ |
406 | init_completion(&irq_event); | 450 | status = request_threaded_irq(irq_num, NULL, twl6030_irq_thread, |
407 | 451 | IRQF_ONESHOT, "TWL6030-PIH", twl6030_irq); | |
408 | status = request_irq(irq_num, handle_twl6030_pih, 0, "TWL6030-PIH", | ||
409 | &irq_event); | ||
410 | if (status < 0) { | 452 | if (status < 0) { |
411 | dev_err(dev, "could not claim irq %d: %d\n", irq_num, status); | 453 | dev_err(dev, "could not claim irq %d: %d\n", irq_num, status); |
412 | goto fail_irq; | 454 | goto fail_irq; |
413 | } | 455 | } |
414 | 456 | ||
415 | task = kthread_run(twl6030_irq_thread, (void *)irq_num, "twl6030-irq"); | 457 | twl6030_irq->twl_irq = irq_num; |
416 | if (IS_ERR(task)) { | 458 | register_pm_notifier(&twl6030_irq->pm_nb); |
417 | dev_err(dev, "could not create irq %d thread!\n", irq_num); | 459 | return 0; |
418 | status = PTR_ERR(task); | ||
419 | goto fail_kthread; | ||
420 | } | ||
421 | |||
422 | twl_irq = irq_num; | ||
423 | register_pm_notifier(&twl6030_irq_pm_notifier_block); | ||
424 | return irq_base; | ||
425 | |||
426 | fail_kthread: | ||
427 | free_irq(irq_num, &irq_event); | ||
428 | 460 | ||
429 | fail_irq: | 461 | fail_irq: |
430 | for (i = irq_base; i < irq_end; i++) | 462 | irq_domain_remove(twl6030_irq->irq_domain); |
431 | irq_set_chip_and_handler(i, NULL, NULL); | ||
432 | |||
433 | return status; | 463 | return status; |
434 | } | 464 | } |
435 | 465 | ||
436 | int twl6030_exit_irq(void) | 466 | int twl6030_exit_irq(void) |
437 | { | 467 | { |
438 | unregister_pm_notifier(&twl6030_irq_pm_notifier_block); | 468 | if (twl6030_irq && twl6030_irq->twl_irq) { |
439 | 469 | unregister_pm_notifier(&twl6030_irq->pm_nb); | |
440 | if (twl6030_irq_base) { | 470 | free_irq(twl6030_irq->twl_irq, NULL); |
441 | pr_err("twl6030: can't yet clean up IRQs?\n"); | 471 | /* |
442 | return -ENOSYS; | 472 | * TODO: IRQ domain and allocated nested IRQ descriptors |
473 | * should be freed somehow here. Now It can't be done, because | ||
474 | * child devices will not be deleted during removing of | ||
475 | * TWL Core driver and they will still contain allocated | ||
476 | * virt IRQs in their Resources tables. | ||
477 | * The same prevents us from using devm_request_threaded_irq() | ||
478 | * in this module. | ||
479 | */ | ||
443 | } | 480 | } |
444 | return 0; | 481 | return 0; |
445 | } | 482 | } |
diff --git a/drivers/mfd/twl6040.c b/drivers/mfd/twl6040.c index 492ee2cd3400..daf66942071c 100644 --- a/drivers/mfd/twl6040.c +++ b/drivers/mfd/twl6040.c | |||
@@ -44,17 +44,12 @@ | |||
44 | #define VIBRACTRL_MEMBER(reg) ((reg == TWL6040_REG_VIBCTLL) ? 0 : 1) | 44 | #define VIBRACTRL_MEMBER(reg) ((reg == TWL6040_REG_VIBCTLL) ? 0 : 1) |
45 | #define TWL6040_NUM_SUPPLIES (2) | 45 | #define TWL6040_NUM_SUPPLIES (2) |
46 | 46 | ||
47 | static bool twl6040_has_vibra(struct twl6040_platform_data *pdata, | 47 | static bool twl6040_has_vibra(struct device_node *node) |
48 | struct device_node *node) | ||
49 | { | 48 | { |
50 | if (pdata && pdata->vibra) | ||
51 | return true; | ||
52 | |||
53 | #ifdef CONFIG_OF | 49 | #ifdef CONFIG_OF |
54 | if (of_find_node_by_name(node, "vibra")) | 50 | if (of_find_node_by_name(node, "vibra")) |
55 | return true; | 51 | return true; |
56 | #endif | 52 | #endif |
57 | |||
58 | return false; | 53 | return false; |
59 | } | 54 | } |
60 | 55 | ||
@@ -63,15 +58,9 @@ int twl6040_reg_read(struct twl6040 *twl6040, unsigned int reg) | |||
63 | int ret; | 58 | int ret; |
64 | unsigned int val; | 59 | unsigned int val; |
65 | 60 | ||
66 | /* Vibra control registers from cache */ | 61 | ret = regmap_read(twl6040->regmap, reg, &val); |
67 | if (unlikely(reg == TWL6040_REG_VIBCTLL || | 62 | if (ret < 0) |
68 | reg == TWL6040_REG_VIBCTLR)) { | 63 | return ret; |
69 | val = twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)]; | ||
70 | } else { | ||
71 | ret = regmap_read(twl6040->regmap, reg, &val); | ||
72 | if (ret < 0) | ||
73 | return ret; | ||
74 | } | ||
75 | 64 | ||
76 | return val; | 65 | return val; |
77 | } | 66 | } |
@@ -82,9 +71,6 @@ int twl6040_reg_write(struct twl6040 *twl6040, unsigned int reg, u8 val) | |||
82 | int ret; | 71 | int ret; |
83 | 72 | ||
84 | ret = regmap_write(twl6040->regmap, reg, val); | 73 | ret = regmap_write(twl6040->regmap, reg, val); |
85 | /* Cache the vibra control registers */ | ||
86 | if (reg == TWL6040_REG_VIBCTLL || reg == TWL6040_REG_VIBCTLR) | ||
87 | twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)] = val; | ||
88 | 74 | ||
89 | return ret; | 75 | return ret; |
90 | } | 76 | } |
@@ -461,9 +447,20 @@ EXPORT_SYMBOL(twl6040_get_sysclk); | |||
461 | /* Get the combined status of the vibra control register */ | 447 | /* Get the combined status of the vibra control register */ |
462 | int twl6040_get_vibralr_status(struct twl6040 *twl6040) | 448 | int twl6040_get_vibralr_status(struct twl6040 *twl6040) |
463 | { | 449 | { |
450 | unsigned int reg; | ||
451 | int ret; | ||
464 | u8 status; | 452 | u8 status; |
465 | 453 | ||
466 | status = twl6040->vibra_ctrl_cache[0] | twl6040->vibra_ctrl_cache[1]; | 454 | ret = regmap_read(twl6040->regmap, TWL6040_REG_VIBCTLL, ®); |
455 | if (ret != 0) | ||
456 | return ret; | ||
457 | status = reg; | ||
458 | |||
459 | ret = regmap_read(twl6040->regmap, TWL6040_REG_VIBCTLR, ®); | ||
460 | if (ret != 0) | ||
461 | return ret; | ||
462 | status |= reg; | ||
463 | |||
467 | status &= (TWL6040_VIBENA | TWL6040_VIBSEL); | 464 | status &= (TWL6040_VIBENA | TWL6040_VIBSEL); |
468 | 465 | ||
469 | return status; | 466 | return status; |
@@ -490,12 +487,27 @@ static bool twl6040_readable_reg(struct device *dev, unsigned int reg) | |||
490 | return true; | 487 | return true; |
491 | } | 488 | } |
492 | 489 | ||
490 | static bool twl6040_volatile_reg(struct device *dev, unsigned int reg) | ||
491 | { | ||
492 | switch (reg) { | ||
493 | case TWL6040_REG_VIBCTLL: | ||
494 | case TWL6040_REG_VIBCTLR: | ||
495 | case TWL6040_REG_INTMR: | ||
496 | return false; | ||
497 | default: | ||
498 | return true; | ||
499 | } | ||
500 | } | ||
501 | |||
493 | static struct regmap_config twl6040_regmap_config = { | 502 | static struct regmap_config twl6040_regmap_config = { |
494 | .reg_bits = 8, | 503 | .reg_bits = 8, |
495 | .val_bits = 8, | 504 | .val_bits = 8, |
496 | .max_register = TWL6040_REG_STATUS, /* 0x2e */ | 505 | .max_register = TWL6040_REG_STATUS, /* 0x2e */ |
497 | 506 | ||
498 | .readable_reg = twl6040_readable_reg, | 507 | .readable_reg = twl6040_readable_reg, |
508 | .volatile_reg = twl6040_volatile_reg, | ||
509 | |||
510 | .cache_type = REGCACHE_RBTREE, | ||
499 | }; | 511 | }; |
500 | 512 | ||
501 | static const struct regmap_irq twl6040_irqs[] = { | 513 | static const struct regmap_irq twl6040_irqs[] = { |
@@ -520,14 +532,13 @@ static struct regmap_irq_chip twl6040_irq_chip = { | |||
520 | static int twl6040_probe(struct i2c_client *client, | 532 | static int twl6040_probe(struct i2c_client *client, |
521 | const struct i2c_device_id *id) | 533 | const struct i2c_device_id *id) |
522 | { | 534 | { |
523 | struct twl6040_platform_data *pdata = client->dev.platform_data; | ||
524 | struct device_node *node = client->dev.of_node; | 535 | struct device_node *node = client->dev.of_node; |
525 | struct twl6040 *twl6040; | 536 | struct twl6040 *twl6040; |
526 | struct mfd_cell *cell = NULL; | 537 | struct mfd_cell *cell = NULL; |
527 | int irq, ret, children = 0; | 538 | int irq, ret, children = 0; |
528 | 539 | ||
529 | if (!pdata && !node) { | 540 | if (!node) { |
530 | dev_err(&client->dev, "Platform data is missing\n"); | 541 | dev_err(&client->dev, "of node is missing\n"); |
531 | return -EINVAL; | 542 | return -EINVAL; |
532 | } | 543 | } |
533 | 544 | ||
@@ -539,23 +550,19 @@ static int twl6040_probe(struct i2c_client *client, | |||
539 | 550 | ||
540 | twl6040 = devm_kzalloc(&client->dev, sizeof(struct twl6040), | 551 | twl6040 = devm_kzalloc(&client->dev, sizeof(struct twl6040), |
541 | GFP_KERNEL); | 552 | GFP_KERNEL); |
542 | if (!twl6040) { | 553 | if (!twl6040) |
543 | ret = -ENOMEM; | 554 | return -ENOMEM; |
544 | goto err; | ||
545 | } | ||
546 | 555 | ||
547 | twl6040->regmap = devm_regmap_init_i2c(client, &twl6040_regmap_config); | 556 | twl6040->regmap = devm_regmap_init_i2c(client, &twl6040_regmap_config); |
548 | if (IS_ERR(twl6040->regmap)) { | 557 | if (IS_ERR(twl6040->regmap)) |
549 | ret = PTR_ERR(twl6040->regmap); | 558 | return PTR_ERR(twl6040->regmap); |
550 | goto err; | ||
551 | } | ||
552 | 559 | ||
553 | i2c_set_clientdata(client, twl6040); | 560 | i2c_set_clientdata(client, twl6040); |
554 | 561 | ||
555 | twl6040->supplies[0].supply = "vio"; | 562 | twl6040->supplies[0].supply = "vio"; |
556 | twl6040->supplies[1].supply = "v2v1"; | 563 | twl6040->supplies[1].supply = "v2v1"; |
557 | ret = devm_regulator_bulk_get(&client->dev, TWL6040_NUM_SUPPLIES, | 564 | ret = devm_regulator_bulk_get(&client->dev, TWL6040_NUM_SUPPLIES, |
558 | twl6040->supplies); | 565 | twl6040->supplies); |
559 | if (ret != 0) { | 566 | if (ret != 0) { |
560 | dev_err(&client->dev, "Failed to get supplies: %d\n", ret); | 567 | dev_err(&client->dev, "Failed to get supplies: %d\n", ret); |
561 | goto regulator_get_err; | 568 | goto regulator_get_err; |
@@ -576,44 +583,40 @@ static int twl6040_probe(struct i2c_client *client, | |||
576 | twl6040->rev = twl6040_reg_read(twl6040, TWL6040_REG_ASICREV); | 583 | twl6040->rev = twl6040_reg_read(twl6040, TWL6040_REG_ASICREV); |
577 | 584 | ||
578 | /* ERRATA: Automatic power-up is not possible in ES1.0 */ | 585 | /* ERRATA: Automatic power-up is not possible in ES1.0 */ |
579 | if (twl6040_get_revid(twl6040) > TWL6040_REV_ES1_0) { | 586 | if (twl6040_get_revid(twl6040) > TWL6040_REV_ES1_0) |
580 | if (pdata) | 587 | twl6040->audpwron = of_get_named_gpio(node, |
581 | twl6040->audpwron = pdata->audpwron_gpio; | 588 | "ti,audpwron-gpio", 0); |
582 | else | 589 | else |
583 | twl6040->audpwron = of_get_named_gpio(node, | ||
584 | "ti,audpwron-gpio", 0); | ||
585 | } else | ||
586 | twl6040->audpwron = -EINVAL; | 590 | twl6040->audpwron = -EINVAL; |
587 | 591 | ||
588 | if (gpio_is_valid(twl6040->audpwron)) { | 592 | if (gpio_is_valid(twl6040->audpwron)) { |
589 | ret = devm_gpio_request_one(&client->dev, twl6040->audpwron, | 593 | ret = devm_gpio_request_one(&client->dev, twl6040->audpwron, |
590 | GPIOF_OUT_INIT_LOW, "audpwron"); | 594 | GPIOF_OUT_INIT_LOW, "audpwron"); |
591 | if (ret) | 595 | if (ret) |
592 | goto gpio_err; | 596 | goto gpio_err; |
593 | } | 597 | } |
594 | 598 | ||
595 | ret = regmap_add_irq_chip(twl6040->regmap, twl6040->irq, | 599 | ret = regmap_add_irq_chip(twl6040->regmap, twl6040->irq, IRQF_ONESHOT, |
596 | IRQF_ONESHOT, 0, &twl6040_irq_chip, | 600 | 0, &twl6040_irq_chip,&twl6040->irq_data); |
597 | &twl6040->irq_data); | ||
598 | if (ret < 0) | 601 | if (ret < 0) |
599 | goto gpio_err; | 602 | goto gpio_err; |
600 | 603 | ||
601 | twl6040->irq_ready = regmap_irq_get_virq(twl6040->irq_data, | 604 | twl6040->irq_ready = regmap_irq_get_virq(twl6040->irq_data, |
602 | TWL6040_IRQ_READY); | 605 | TWL6040_IRQ_READY); |
603 | twl6040->irq_th = regmap_irq_get_virq(twl6040->irq_data, | 606 | twl6040->irq_th = regmap_irq_get_virq(twl6040->irq_data, |
604 | TWL6040_IRQ_TH); | 607 | TWL6040_IRQ_TH); |
605 | 608 | ||
606 | ret = devm_request_threaded_irq(twl6040->dev, twl6040->irq_ready, NULL, | 609 | ret = devm_request_threaded_irq(twl6040->dev, twl6040->irq_ready, NULL, |
607 | twl6040_readyint_handler, IRQF_ONESHOT, | 610 | twl6040_readyint_handler, IRQF_ONESHOT, |
608 | "twl6040_irq_ready", twl6040); | 611 | "twl6040_irq_ready", twl6040); |
609 | if (ret) { | 612 | if (ret) { |
610 | dev_err(twl6040->dev, "READY IRQ request failed: %d\n", ret); | 613 | dev_err(twl6040->dev, "READY IRQ request failed: %d\n", ret); |
611 | goto readyirq_err; | 614 | goto readyirq_err; |
612 | } | 615 | } |
613 | 616 | ||
614 | ret = devm_request_threaded_irq(twl6040->dev, twl6040->irq_th, NULL, | 617 | ret = devm_request_threaded_irq(twl6040->dev, twl6040->irq_th, NULL, |
615 | twl6040_thint_handler, IRQF_ONESHOT, | 618 | twl6040_thint_handler, IRQF_ONESHOT, |
616 | "twl6040_irq_th", twl6040); | 619 | "twl6040_irq_th", twl6040); |
617 | if (ret) { | 620 | if (ret) { |
618 | dev_err(twl6040->dev, "Thermal IRQ request failed: %d\n", ret); | 621 | dev_err(twl6040->dev, "Thermal IRQ request failed: %d\n", ret); |
619 | goto thirq_err; | 622 | goto thirq_err; |
@@ -625,8 +628,6 @@ static int twl6040_probe(struct i2c_client *client, | |||
625 | /* | 628 | /* |
626 | * The main functionality of twl6040 to provide audio on OMAP4+ systems. | 629 | * The main functionality of twl6040 to provide audio on OMAP4+ systems. |
627 | * We can add the ASoC codec child whenever this driver has been loaded. | 630 | * We can add the ASoC codec child whenever this driver has been loaded. |
628 | * The ASoC codec can work without pdata, pass the platform_data only if | ||
629 | * it has been provided. | ||
630 | */ | 631 | */ |
631 | irq = regmap_irq_get_virq(twl6040->irq_data, TWL6040_IRQ_PLUG); | 632 | irq = regmap_irq_get_virq(twl6040->irq_data, TWL6040_IRQ_PLUG); |
632 | cell = &twl6040->cells[children]; | 633 | cell = &twl6040->cells[children]; |
@@ -635,13 +636,10 @@ static int twl6040_probe(struct i2c_client *client, | |||
635 | twl6040_codec_rsrc[0].end = irq; | 636 | twl6040_codec_rsrc[0].end = irq; |
636 | cell->resources = twl6040_codec_rsrc; | 637 | cell->resources = twl6040_codec_rsrc; |
637 | cell->num_resources = ARRAY_SIZE(twl6040_codec_rsrc); | 638 | cell->num_resources = ARRAY_SIZE(twl6040_codec_rsrc); |
638 | if (pdata && pdata->codec) { | ||
639 | cell->platform_data = pdata->codec; | ||
640 | cell->pdata_size = sizeof(*pdata->codec); | ||
641 | } | ||
642 | children++; | 639 | children++; |
643 | 640 | ||
644 | if (twl6040_has_vibra(pdata, node)) { | 641 | /* Vibra input driver support */ |
642 | if (twl6040_has_vibra(node)) { | ||
645 | irq = regmap_irq_get_virq(twl6040->irq_data, TWL6040_IRQ_VIB); | 643 | irq = regmap_irq_get_virq(twl6040->irq_data, TWL6040_IRQ_VIB); |
646 | 644 | ||
647 | cell = &twl6040->cells[children]; | 645 | cell = &twl6040->cells[children]; |
@@ -650,28 +648,13 @@ static int twl6040_probe(struct i2c_client *client, | |||
650 | twl6040_vibra_rsrc[0].end = irq; | 648 | twl6040_vibra_rsrc[0].end = irq; |
651 | cell->resources = twl6040_vibra_rsrc; | 649 | cell->resources = twl6040_vibra_rsrc; |
652 | cell->num_resources = ARRAY_SIZE(twl6040_vibra_rsrc); | 650 | cell->num_resources = ARRAY_SIZE(twl6040_vibra_rsrc); |
653 | |||
654 | if (pdata && pdata->vibra) { | ||
655 | cell->platform_data = pdata->vibra; | ||
656 | cell->pdata_size = sizeof(*pdata->vibra); | ||
657 | } | ||
658 | children++; | 651 | children++; |
659 | } | 652 | } |
660 | 653 | ||
661 | /* | 654 | /* GPO support */ |
662 | * Enable the GPO driver in the following cases: | 655 | cell = &twl6040->cells[children]; |
663 | * DT booted kernel or legacy boot with valid gpo platform_data | 656 | cell->name = "twl6040-gpo"; |
664 | */ | 657 | children++; |
665 | if (!pdata || (pdata && pdata->gpo)) { | ||
666 | cell = &twl6040->cells[children]; | ||
667 | cell->name = "twl6040-gpo"; | ||
668 | |||
669 | if (pdata) { | ||
670 | cell->platform_data = pdata->gpo; | ||
671 | cell->pdata_size = sizeof(*pdata->gpo); | ||
672 | } | ||
673 | children++; | ||
674 | } | ||
675 | 658 | ||
676 | ret = mfd_add_devices(&client->dev, -1, twl6040->cells, children, | 659 | ret = mfd_add_devices(&client->dev, -1, twl6040->cells, children, |
677 | NULL, 0, NULL); | 660 | NULL, 0, NULL); |
@@ -690,7 +673,7 @@ gpio_err: | |||
690 | regulator_bulk_disable(TWL6040_NUM_SUPPLIES, twl6040->supplies); | 673 | regulator_bulk_disable(TWL6040_NUM_SUPPLIES, twl6040->supplies); |
691 | regulator_get_err: | 674 | regulator_get_err: |
692 | i2c_set_clientdata(client, NULL); | 675 | i2c_set_clientdata(client, NULL); |
693 | err: | 676 | |
694 | return ret; | 677 | return ret; |
695 | } | 678 | } |
696 | 679 | ||
diff --git a/drivers/mfd/ucb1400_core.c b/drivers/mfd/ucb1400_core.c index e9031fa9d53d..ebb20edf9c17 100644 --- a/drivers/mfd/ucb1400_core.c +++ b/drivers/mfd/ucb1400_core.c | |||
@@ -52,7 +52,7 @@ static int ucb1400_core_probe(struct device *dev) | |||
52 | struct ucb1400_ts ucb_ts; | 52 | struct ucb1400_ts ucb_ts; |
53 | struct ucb1400_gpio ucb_gpio; | 53 | struct ucb1400_gpio ucb_gpio; |
54 | struct snd_ac97 *ac97; | 54 | struct snd_ac97 *ac97; |
55 | struct ucb1400_pdata *pdata = dev->platform_data; | 55 | struct ucb1400_pdata *pdata = dev_get_platdata(dev); |
56 | 56 | ||
57 | memset(&ucb_ts, 0, sizeof(ucb_ts)); | 57 | memset(&ucb_ts, 0, sizeof(ucb_ts)); |
58 | memset(&ucb_gpio, 0, sizeof(ucb_gpio)); | 58 | memset(&ucb_gpio, 0, sizeof(ucb_gpio)); |
diff --git a/drivers/mfd/ucb1x00-core.c b/drivers/mfd/ucb1x00-core.c index 70f02daeb22a..d5966e6b5a7d 100644 --- a/drivers/mfd/ucb1x00-core.c +++ b/drivers/mfd/ucb1x00-core.c | |||
@@ -393,22 +393,24 @@ static struct irq_chip ucb1x00_irqchip = { | |||
393 | static int ucb1x00_add_dev(struct ucb1x00 *ucb, struct ucb1x00_driver *drv) | 393 | static int ucb1x00_add_dev(struct ucb1x00 *ucb, struct ucb1x00_driver *drv) |
394 | { | 394 | { |
395 | struct ucb1x00_dev *dev; | 395 | struct ucb1x00_dev *dev; |
396 | int ret = -ENOMEM; | 396 | int ret; |
397 | 397 | ||
398 | dev = kmalloc(sizeof(struct ucb1x00_dev), GFP_KERNEL); | 398 | dev = kmalloc(sizeof(struct ucb1x00_dev), GFP_KERNEL); |
399 | if (dev) { | 399 | if (!dev) |
400 | dev->ucb = ucb; | 400 | return -ENOMEM; |
401 | dev->drv = drv; | 401 | |
402 | 402 | dev->ucb = ucb; | |
403 | ret = drv->add(dev); | 403 | dev->drv = drv; |
404 | 404 | ||
405 | if (ret == 0) { | 405 | ret = drv->add(dev); |
406 | list_add_tail(&dev->dev_node, &ucb->devs); | 406 | if (ret) { |
407 | list_add_tail(&dev->drv_node, &drv->devs); | 407 | kfree(dev); |
408 | } else { | 408 | return ret; |
409 | kfree(dev); | ||
410 | } | ||
411 | } | 409 | } |
410 | |||
411 | list_add_tail(&dev->dev_node, &ucb->devs); | ||
412 | list_add_tail(&dev->drv_node, &drv->devs); | ||
413 | |||
412 | return ret; | 414 | return ret; |
413 | } | 415 | } |
414 | 416 | ||
@@ -669,9 +671,10 @@ void ucb1x00_unregister_driver(struct ucb1x00_driver *drv) | |||
669 | mutex_unlock(&ucb1x00_mutex); | 671 | mutex_unlock(&ucb1x00_mutex); |
670 | } | 672 | } |
671 | 673 | ||
674 | #ifdef CONFIG_PM_SLEEP | ||
672 | static int ucb1x00_suspend(struct device *dev) | 675 | static int ucb1x00_suspend(struct device *dev) |
673 | { | 676 | { |
674 | struct ucb1x00_plat_data *pdata = dev->platform_data; | 677 | struct ucb1x00_plat_data *pdata = dev_get_platdata(dev); |
675 | struct ucb1x00 *ucb = dev_get_drvdata(dev); | 678 | struct ucb1x00 *ucb = dev_get_drvdata(dev); |
676 | struct ucb1x00_dev *udev; | 679 | struct ucb1x00_dev *udev; |
677 | 680 | ||
@@ -703,7 +706,7 @@ static int ucb1x00_suspend(struct device *dev) | |||
703 | 706 | ||
704 | static int ucb1x00_resume(struct device *dev) | 707 | static int ucb1x00_resume(struct device *dev) |
705 | { | 708 | { |
706 | struct ucb1x00_plat_data *pdata = dev->platform_data; | 709 | struct ucb1x00_plat_data *pdata = dev_get_platdata(dev); |
707 | struct ucb1x00 *ucb = dev_get_drvdata(dev); | 710 | struct ucb1x00 *ucb = dev_get_drvdata(dev); |
708 | struct ucb1x00_dev *udev; | 711 | struct ucb1x00_dev *udev; |
709 | 712 | ||
@@ -736,6 +739,7 @@ static int ucb1x00_resume(struct device *dev) | |||
736 | mutex_unlock(&ucb1x00_mutex); | 739 | mutex_unlock(&ucb1x00_mutex); |
737 | return 0; | 740 | return 0; |
738 | } | 741 | } |
742 | #endif | ||
739 | 743 | ||
740 | static const struct dev_pm_ops ucb1x00_pm_ops = { | 744 | static const struct dev_pm_ops ucb1x00_pm_ops = { |
741 | SET_SYSTEM_SLEEP_PM_OPS(ucb1x00_suspend, ucb1x00_resume) | 745 | SET_SYSTEM_SLEEP_PM_OPS(ucb1x00_suspend, ucb1x00_resume) |
diff --git a/drivers/mfd/wl1273-core.c b/drivers/mfd/wl1273-core.c index edbe6c1b755a..f7c52d901040 100644 --- a/drivers/mfd/wl1273-core.c +++ b/drivers/mfd/wl1273-core.c | |||
@@ -172,12 +172,9 @@ static int wl1273_fm_set_volume(struct wl1273_core *core, unsigned int volume) | |||
172 | 172 | ||
173 | static int wl1273_core_remove(struct i2c_client *client) | 173 | static int wl1273_core_remove(struct i2c_client *client) |
174 | { | 174 | { |
175 | struct wl1273_core *core = i2c_get_clientdata(client); | ||
176 | |||
177 | dev_dbg(&client->dev, "%s\n", __func__); | 175 | dev_dbg(&client->dev, "%s\n", __func__); |
178 | 176 | ||
179 | mfd_remove_devices(&client->dev); | 177 | mfd_remove_devices(&client->dev); |
180 | kfree(core); | ||
181 | 178 | ||
182 | return 0; | 179 | return 0; |
183 | } | 180 | } |
@@ -185,7 +182,7 @@ static int wl1273_core_remove(struct i2c_client *client) | |||
185 | static int wl1273_core_probe(struct i2c_client *client, | 182 | static int wl1273_core_probe(struct i2c_client *client, |
186 | const struct i2c_device_id *id) | 183 | const struct i2c_device_id *id) |
187 | { | 184 | { |
188 | struct wl1273_fm_platform_data *pdata = client->dev.platform_data; | 185 | struct wl1273_fm_platform_data *pdata = dev_get_platdata(&client->dev); |
189 | struct wl1273_core *core; | 186 | struct wl1273_core *core; |
190 | struct mfd_cell *cell; | 187 | struct mfd_cell *cell; |
191 | int children = 0; | 188 | int children = 0; |
@@ -203,7 +200,7 @@ static int wl1273_core_probe(struct i2c_client *client, | |||
203 | return -EINVAL; | 200 | return -EINVAL; |
204 | } | 201 | } |
205 | 202 | ||
206 | core = kzalloc(sizeof(*core), GFP_KERNEL); | 203 | core = devm_kzalloc(&client->dev, sizeof(*core), GFP_KERNEL); |
207 | if (!core) | 204 | if (!core) |
208 | return -ENOMEM; | 205 | return -ENOMEM; |
209 | 206 | ||
@@ -249,7 +246,6 @@ static int wl1273_core_probe(struct i2c_client *client, | |||
249 | 246 | ||
250 | err: | 247 | err: |
251 | pdata->free_resources(); | 248 | pdata->free_resources(); |
252 | kfree(core); | ||
253 | 249 | ||
254 | dev_dbg(&client->dev, "%s\n", __func__); | 250 | dev_dbg(&client->dev, "%s\n", __func__); |
255 | 251 | ||
diff --git a/drivers/mfd/wm5110-tables.c b/drivers/mfd/wm5110-tables.c index 2a7972349159..3113e39b318e 100644 --- a/drivers/mfd/wm5110-tables.c +++ b/drivers/mfd/wm5110-tables.c | |||
@@ -468,12 +468,14 @@ static const struct reg_default wm5110_reg_default[] = { | |||
468 | { 0x00000176, 0x0000 }, /* R374 - FLL1 Control 6 */ | 468 | { 0x00000176, 0x0000 }, /* R374 - FLL1 Control 6 */ |
469 | { 0x00000177, 0x0281 }, /* R375 - FLL1 Loop Filter Test 1 */ | 469 | { 0x00000177, 0x0281 }, /* R375 - FLL1 Loop Filter Test 1 */ |
470 | { 0x00000178, 0x0000 }, /* R376 - FLL1 NCO Test 0 */ | 470 | { 0x00000178, 0x0000 }, /* R376 - FLL1 NCO Test 0 */ |
471 | { 0x00000179, 0x0000 }, /* R376 - FLL1 Control 7 */ | ||
471 | { 0x00000181, 0x0000 }, /* R385 - FLL1 Synchroniser 1 */ | 472 | { 0x00000181, 0x0000 }, /* R385 - FLL1 Synchroniser 1 */ |
472 | { 0x00000182, 0x0000 }, /* R386 - FLL1 Synchroniser 2 */ | 473 | { 0x00000182, 0x0000 }, /* R386 - FLL1 Synchroniser 2 */ |
473 | { 0x00000183, 0x0000 }, /* R387 - FLL1 Synchroniser 3 */ | 474 | { 0x00000183, 0x0000 }, /* R387 - FLL1 Synchroniser 3 */ |
474 | { 0x00000184, 0x0000 }, /* R388 - FLL1 Synchroniser 4 */ | 475 | { 0x00000184, 0x0000 }, /* R388 - FLL1 Synchroniser 4 */ |
475 | { 0x00000185, 0x0000 }, /* R389 - FLL1 Synchroniser 5 */ | 476 | { 0x00000185, 0x0000 }, /* R389 - FLL1 Synchroniser 5 */ |
476 | { 0x00000186, 0x0000 }, /* R390 - FLL1 Synchroniser 6 */ | 477 | { 0x00000186, 0x0000 }, /* R390 - FLL1 Synchroniser 6 */ |
478 | { 0x00000187, 0x0001 }, /* R390 - FLL1 Synchroniser 7 */ | ||
477 | { 0x00000189, 0x0000 }, /* R393 - FLL1 Spread Spectrum */ | 479 | { 0x00000189, 0x0000 }, /* R393 - FLL1 Spread Spectrum */ |
478 | { 0x0000018A, 0x0004 }, /* R394 - FLL1 GPIO Clock */ | 480 | { 0x0000018A, 0x0004 }, /* R394 - FLL1 GPIO Clock */ |
479 | { 0x00000191, 0x0000 }, /* R401 - FLL2 Control 1 */ | 481 | { 0x00000191, 0x0000 }, /* R401 - FLL2 Control 1 */ |
@@ -484,12 +486,14 @@ static const struct reg_default wm5110_reg_default[] = { | |||
484 | { 0x00000196, 0x0000 }, /* R406 - FLL2 Control 6 */ | 486 | { 0x00000196, 0x0000 }, /* R406 - FLL2 Control 6 */ |
485 | { 0x00000197, 0x0000 }, /* R407 - FLL2 Loop Filter Test 1 */ | 487 | { 0x00000197, 0x0000 }, /* R407 - FLL2 Loop Filter Test 1 */ |
486 | { 0x00000198, 0x0000 }, /* R408 - FLL2 NCO Test 0 */ | 488 | { 0x00000198, 0x0000 }, /* R408 - FLL2 NCO Test 0 */ |
489 | { 0x00000199, 0x0000 }, /* R408 - FLL2 Control 7 */ | ||
487 | { 0x000001A1, 0x0000 }, /* R417 - FLL2 Synchroniser 1 */ | 490 | { 0x000001A1, 0x0000 }, /* R417 - FLL2 Synchroniser 1 */ |
488 | { 0x000001A2, 0x0000 }, /* R418 - FLL2 Synchroniser 2 */ | 491 | { 0x000001A2, 0x0000 }, /* R418 - FLL2 Synchroniser 2 */ |
489 | { 0x000001A3, 0x0000 }, /* R419 - FLL2 Synchroniser 3 */ | 492 | { 0x000001A3, 0x0000 }, /* R419 - FLL2 Synchroniser 3 */ |
490 | { 0x000001A4, 0x0000 }, /* R420 - FLL2 Synchroniser 4 */ | 493 | { 0x000001A4, 0x0000 }, /* R420 - FLL2 Synchroniser 4 */ |
491 | { 0x000001A5, 0x0000 }, /* R421 - FLL2 Synchroniser 5 */ | 494 | { 0x000001A5, 0x0000 }, /* R421 - FLL2 Synchroniser 5 */ |
492 | { 0x000001A6, 0x0000 }, /* R422 - FLL2 Synchroniser 6 */ | 495 | { 0x000001A6, 0x0000 }, /* R422 - FLL2 Synchroniser 6 */ |
496 | { 0x000001A7, 0x0001 }, /* R422 - FLL2 Synchroniser 7 */ | ||
493 | { 0x000001A9, 0x0000 }, /* R425 - FLL2 Spread Spectrum */ | 497 | { 0x000001A9, 0x0000 }, /* R425 - FLL2 Spread Spectrum */ |
494 | { 0x000001AA, 0x0004 }, /* R426 - FLL2 GPIO Clock */ | 498 | { 0x000001AA, 0x0004 }, /* R426 - FLL2 GPIO Clock */ |
495 | { 0x00000200, 0x0006 }, /* R512 - Mic Charge Pump 1 */ | 499 | { 0x00000200, 0x0006 }, /* R512 - Mic Charge Pump 1 */ |
@@ -503,6 +507,11 @@ static const struct reg_default wm5110_reg_default[] = { | |||
503 | { 0x0000029C, 0x0000 }, /* R668 - Headphone Detect 2 */ | 507 | { 0x0000029C, 0x0000 }, /* R668 - Headphone Detect 2 */ |
504 | { 0x000002A3, 0x1102 }, /* R675 - Mic Detect 1 */ | 508 | { 0x000002A3, 0x1102 }, /* R675 - Mic Detect 1 */ |
505 | { 0x000002A4, 0x009F }, /* R676 - Mic Detect 2 */ | 509 | { 0x000002A4, 0x009F }, /* R676 - Mic Detect 2 */ |
510 | { 0x000002A5, 0x0000 }, /* R677 - Mic Detect 3 */ | ||
511 | { 0x000002A6, 0x3737 }, /* R678 - Mic Detect Level 1 */ | ||
512 | { 0x000002A7, 0x372C }, /* R679 - Mic Detect Level 2 */ | ||
513 | { 0x000002A8, 0x1422 }, /* R680 - Mic Detect Level 3 */ | ||
514 | { 0x000002A9, 0x300A }, /* R681 - Mic Detect Level 4 */ | ||
506 | { 0x000002C3, 0x0000 }, /* R707 - Mic noise mix control 1 */ | 515 | { 0x000002C3, 0x0000 }, /* R707 - Mic noise mix control 1 */ |
507 | { 0x000002D3, 0x0000 }, /* R723 - Jack detect analogue */ | 516 | { 0x000002D3, 0x0000 }, /* R723 - Jack detect analogue */ |
508 | { 0x00000300, 0x0000 }, /* R768 - Input Enables */ | 517 | { 0x00000300, 0x0000 }, /* R768 - Input Enables */ |
@@ -1392,6 +1401,7 @@ static bool wm5110_readable_register(struct device *dev, unsigned int reg) | |||
1392 | case ARIZONA_FLL1_CONTROL_4: | 1401 | case ARIZONA_FLL1_CONTROL_4: |
1393 | case ARIZONA_FLL1_CONTROL_5: | 1402 | case ARIZONA_FLL1_CONTROL_5: |
1394 | case ARIZONA_FLL1_CONTROL_6: | 1403 | case ARIZONA_FLL1_CONTROL_6: |
1404 | case ARIZONA_FLL1_CONTROL_7: | ||
1395 | case ARIZONA_FLL1_LOOP_FILTER_TEST_1: | 1405 | case ARIZONA_FLL1_LOOP_FILTER_TEST_1: |
1396 | case ARIZONA_FLL1_NCO_TEST_0: | 1406 | case ARIZONA_FLL1_NCO_TEST_0: |
1397 | case ARIZONA_FLL1_SYNCHRONISER_1: | 1407 | case ARIZONA_FLL1_SYNCHRONISER_1: |
@@ -1400,6 +1410,7 @@ static bool wm5110_readable_register(struct device *dev, unsigned int reg) | |||
1400 | case ARIZONA_FLL1_SYNCHRONISER_4: | 1410 | case ARIZONA_FLL1_SYNCHRONISER_4: |
1401 | case ARIZONA_FLL1_SYNCHRONISER_5: | 1411 | case ARIZONA_FLL1_SYNCHRONISER_5: |
1402 | case ARIZONA_FLL1_SYNCHRONISER_6: | 1412 | case ARIZONA_FLL1_SYNCHRONISER_6: |
1413 | case ARIZONA_FLL1_SYNCHRONISER_7: | ||
1403 | case ARIZONA_FLL1_SPREAD_SPECTRUM: | 1414 | case ARIZONA_FLL1_SPREAD_SPECTRUM: |
1404 | case ARIZONA_FLL1_GPIO_CLOCK: | 1415 | case ARIZONA_FLL1_GPIO_CLOCK: |
1405 | case ARIZONA_FLL2_CONTROL_1: | 1416 | case ARIZONA_FLL2_CONTROL_1: |
@@ -1408,6 +1419,7 @@ static bool wm5110_readable_register(struct device *dev, unsigned int reg) | |||
1408 | case ARIZONA_FLL2_CONTROL_4: | 1419 | case ARIZONA_FLL2_CONTROL_4: |
1409 | case ARIZONA_FLL2_CONTROL_5: | 1420 | case ARIZONA_FLL2_CONTROL_5: |
1410 | case ARIZONA_FLL2_CONTROL_6: | 1421 | case ARIZONA_FLL2_CONTROL_6: |
1422 | case ARIZONA_FLL2_CONTROL_7: | ||
1411 | case ARIZONA_FLL2_LOOP_FILTER_TEST_1: | 1423 | case ARIZONA_FLL2_LOOP_FILTER_TEST_1: |
1412 | case ARIZONA_FLL2_NCO_TEST_0: | 1424 | case ARIZONA_FLL2_NCO_TEST_0: |
1413 | case ARIZONA_FLL2_SYNCHRONISER_1: | 1425 | case ARIZONA_FLL2_SYNCHRONISER_1: |
@@ -1416,6 +1428,7 @@ static bool wm5110_readable_register(struct device *dev, unsigned int reg) | |||
1416 | case ARIZONA_FLL2_SYNCHRONISER_4: | 1428 | case ARIZONA_FLL2_SYNCHRONISER_4: |
1417 | case ARIZONA_FLL2_SYNCHRONISER_5: | 1429 | case ARIZONA_FLL2_SYNCHRONISER_5: |
1418 | case ARIZONA_FLL2_SYNCHRONISER_6: | 1430 | case ARIZONA_FLL2_SYNCHRONISER_6: |
1431 | case ARIZONA_FLL2_SYNCHRONISER_7: | ||
1419 | case ARIZONA_FLL2_SPREAD_SPECTRUM: | 1432 | case ARIZONA_FLL2_SPREAD_SPECTRUM: |
1420 | case ARIZONA_FLL2_GPIO_CLOCK: | 1433 | case ARIZONA_FLL2_GPIO_CLOCK: |
1421 | case ARIZONA_MIC_CHARGE_PUMP_1: | 1434 | case ARIZONA_MIC_CHARGE_PUMP_1: |
@@ -1430,6 +1443,10 @@ static bool wm5110_readable_register(struct device *dev, unsigned int reg) | |||
1430 | case ARIZONA_MIC_DETECT_1: | 1443 | case ARIZONA_MIC_DETECT_1: |
1431 | case ARIZONA_MIC_DETECT_2: | 1444 | case ARIZONA_MIC_DETECT_2: |
1432 | case ARIZONA_MIC_DETECT_3: | 1445 | case ARIZONA_MIC_DETECT_3: |
1446 | case ARIZONA_MIC_DETECT_LEVEL_1: | ||
1447 | case ARIZONA_MIC_DETECT_LEVEL_2: | ||
1448 | case ARIZONA_MIC_DETECT_LEVEL_3: | ||
1449 | case ARIZONA_MIC_DETECT_LEVEL_4: | ||
1433 | case ARIZONA_MIC_NOISE_MIX_CONTROL_1: | 1450 | case ARIZONA_MIC_NOISE_MIX_CONTROL_1: |
1434 | case ARIZONA_JACK_DETECT_ANALOGUE: | 1451 | case ARIZONA_JACK_DETECT_ANALOGUE: |
1435 | case ARIZONA_INPUT_ENABLES: | 1452 | case ARIZONA_INPUT_ENABLES: |
@@ -2332,6 +2349,7 @@ static bool wm5110_volatile_register(struct device *dev, unsigned int reg) | |||
2332 | case ARIZONA_IRQ_PIN_STATUS: | 2349 | case ARIZONA_IRQ_PIN_STATUS: |
2333 | case ARIZONA_AOD_IRQ1: | 2350 | case ARIZONA_AOD_IRQ1: |
2334 | case ARIZONA_AOD_IRQ2: | 2351 | case ARIZONA_AOD_IRQ2: |
2352 | case ARIZONA_FX_CTRL2: | ||
2335 | case ARIZONA_ASRC_STATUS: | 2353 | case ARIZONA_ASRC_STATUS: |
2336 | case ARIZONA_DSP_STATUS: | 2354 | case ARIZONA_DSP_STATUS: |
2337 | case ARIZONA_DSP1_CONTROL_1: | 2355 | case ARIZONA_DSP1_CONTROL_1: |
diff --git a/drivers/mfd/wm831x-core.c b/drivers/mfd/wm831x-core.c index 521340a708d3..5c459f469224 100644 --- a/drivers/mfd/wm831x-core.c +++ b/drivers/mfd/wm831x-core.c | |||
@@ -1618,7 +1618,7 @@ EXPORT_SYMBOL_GPL(wm831x_regmap_config); | |||
1618 | */ | 1618 | */ |
1619 | int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq) | 1619 | int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq) |
1620 | { | 1620 | { |
1621 | struct wm831x_pdata *pdata = wm831x->dev->platform_data; | 1621 | struct wm831x_pdata *pdata = dev_get_platdata(wm831x->dev); |
1622 | int rev, wm831x_num; | 1622 | int rev, wm831x_num; |
1623 | enum wm831x_parent parent; | 1623 | enum wm831x_parent parent; |
1624 | int ret, i; | 1624 | int ret, i; |
diff --git a/drivers/mfd/wm831x-irq.c b/drivers/mfd/wm831x-irq.c index 804e56ec99eb..64e512eadf17 100644 --- a/drivers/mfd/wm831x-irq.c +++ b/drivers/mfd/wm831x-irq.c | |||
@@ -571,7 +571,7 @@ static struct irq_domain_ops wm831x_irq_domain_ops = { | |||
571 | 571 | ||
572 | int wm831x_irq_init(struct wm831x *wm831x, int irq) | 572 | int wm831x_irq_init(struct wm831x *wm831x, int irq) |
573 | { | 573 | { |
574 | struct wm831x_pdata *pdata = wm831x->dev->platform_data; | 574 | struct wm831x_pdata *pdata = dev_get_platdata(wm831x->dev); |
575 | struct irq_domain *domain; | 575 | struct irq_domain *domain; |
576 | int i, ret, irq_base; | 576 | int i, ret, irq_base; |
577 | 577 | ||
diff --git a/drivers/mfd/wm831x-spi.c b/drivers/mfd/wm831x-spi.c index e7ed14f661d8..07de3cc5a0d9 100644 --- a/drivers/mfd/wm831x-spi.c +++ b/drivers/mfd/wm831x-spi.c | |||
@@ -34,7 +34,6 @@ static int wm831x_spi_probe(struct spi_device *spi) | |||
34 | if (wm831x == NULL) | 34 | if (wm831x == NULL) |
35 | return -ENOMEM; | 35 | return -ENOMEM; |
36 | 36 | ||
37 | spi->bits_per_word = 16; | ||
38 | spi->mode = SPI_MODE_0; | 37 | spi->mode = SPI_MODE_0; |
39 | 38 | ||
40 | spi_set_drvdata(spi, wm831x); | 39 | spi_set_drvdata(spi, wm831x); |
diff --git a/drivers/mfd/wm8350-i2c.c b/drivers/mfd/wm8350-i2c.c index 2e57101c8d3d..f919def05e24 100644 --- a/drivers/mfd/wm8350-i2c.c +++ b/drivers/mfd/wm8350-i2c.c | |||
@@ -27,6 +27,7 @@ static int wm8350_i2c_probe(struct i2c_client *i2c, | |||
27 | const struct i2c_device_id *id) | 27 | const struct i2c_device_id *id) |
28 | { | 28 | { |
29 | struct wm8350 *wm8350; | 29 | struct wm8350 *wm8350; |
30 | struct wm8350_platform_data *pdata = dev_get_platdata(&i2c->dev); | ||
30 | int ret = 0; | 31 | int ret = 0; |
31 | 32 | ||
32 | wm8350 = devm_kzalloc(&i2c->dev, sizeof(struct wm8350), GFP_KERNEL); | 33 | wm8350 = devm_kzalloc(&i2c->dev, sizeof(struct wm8350), GFP_KERNEL); |
@@ -44,7 +45,7 @@ static int wm8350_i2c_probe(struct i2c_client *i2c, | |||
44 | i2c_set_clientdata(i2c, wm8350); | 45 | i2c_set_clientdata(i2c, wm8350); |
45 | wm8350->dev = &i2c->dev; | 46 | wm8350->dev = &i2c->dev; |
46 | 47 | ||
47 | return wm8350_device_init(wm8350, i2c->irq, i2c->dev.platform_data); | 48 | return wm8350_device_init(wm8350, i2c->irq, pdata); |
48 | } | 49 | } |
49 | 50 | ||
50 | static int wm8350_i2c_remove(struct i2c_client *i2c) | 51 | static int wm8350_i2c_remove(struct i2c_client *i2c) |
diff --git a/drivers/mfd/wm8400-core.c b/drivers/mfd/wm8400-core.c index 639ca359242f..d66d256551fb 100644 --- a/drivers/mfd/wm8400-core.c +++ b/drivers/mfd/wm8400-core.c | |||
@@ -178,7 +178,7 @@ static int wm8400_i2c_probe(struct i2c_client *i2c, | |||
178 | wm8400->dev = &i2c->dev; | 178 | wm8400->dev = &i2c->dev; |
179 | i2c_set_clientdata(i2c, wm8400); | 179 | i2c_set_clientdata(i2c, wm8400); |
180 | 180 | ||
181 | ret = wm8400_init(wm8400, i2c->dev.platform_data); | 181 | ret = wm8400_init(wm8400, dev_get_platdata(&i2c->dev)); |
182 | if (ret != 0) | 182 | if (ret != 0) |
183 | goto err; | 183 | goto err; |
184 | 184 | ||
diff --git a/drivers/mfd/wm8994-core.c b/drivers/mfd/wm8994-core.c index 781115e8dca9..e1c283e6d4e5 100644 --- a/drivers/mfd/wm8994-core.c +++ b/drivers/mfd/wm8994-core.c | |||
@@ -201,35 +201,7 @@ static int wm8994_suspend(struct device *dev) | |||
201 | int ret; | 201 | int ret; |
202 | 202 | ||
203 | /* Don't actually go through with the suspend if the CODEC is | 203 | /* Don't actually go through with the suspend if the CODEC is |
204 | * still active (eg, for audio passthrough from CP. */ | 204 | * still active for accessory detect. */ |
205 | ret = wm8994_reg_read(wm8994, WM8994_POWER_MANAGEMENT_1); | ||
206 | if (ret < 0) { | ||
207 | dev_err(dev, "Failed to read power status: %d\n", ret); | ||
208 | } else if (ret & WM8994_VMID_SEL_MASK) { | ||
209 | dev_dbg(dev, "CODEC still active, ignoring suspend\n"); | ||
210 | return 0; | ||
211 | } | ||
212 | |||
213 | ret = wm8994_reg_read(wm8994, WM8994_POWER_MANAGEMENT_4); | ||
214 | if (ret < 0) { | ||
215 | dev_err(dev, "Failed to read power status: %d\n", ret); | ||
216 | } else if (ret & (WM8994_AIF2ADCL_ENA | WM8994_AIF2ADCR_ENA | | ||
217 | WM8994_AIF1ADC2L_ENA | WM8994_AIF1ADC2R_ENA | | ||
218 | WM8994_AIF1ADC1L_ENA | WM8994_AIF1ADC1R_ENA)) { | ||
219 | dev_dbg(dev, "CODEC still active, ignoring suspend\n"); | ||
220 | return 0; | ||
221 | } | ||
222 | |||
223 | ret = wm8994_reg_read(wm8994, WM8994_POWER_MANAGEMENT_5); | ||
224 | if (ret < 0) { | ||
225 | dev_err(dev, "Failed to read power status: %d\n", ret); | ||
226 | } else if (ret & (WM8994_AIF2DACL_ENA | WM8994_AIF2DACR_ENA | | ||
227 | WM8994_AIF1DAC2L_ENA | WM8994_AIF1DAC2R_ENA | | ||
228 | WM8994_AIF1DAC1L_ENA | WM8994_AIF1DAC1R_ENA)) { | ||
229 | dev_dbg(dev, "CODEC still active, ignoring suspend\n"); | ||
230 | return 0; | ||
231 | } | ||
232 | |||
233 | switch (wm8994->type) { | 205 | switch (wm8994->type) { |
234 | case WM8958: | 206 | case WM8958: |
235 | case WM1811: | 207 | case WM1811: |
@@ -245,20 +217,6 @@ static int wm8994_suspend(struct device *dev) | |||
245 | break; | 217 | break; |
246 | } | 218 | } |
247 | 219 | ||
248 | switch (wm8994->type) { | ||
249 | case WM1811: | ||
250 | ret = wm8994_reg_read(wm8994, WM8994_ANTIPOP_2); | ||
251 | if (ret < 0) { | ||
252 | dev_err(dev, "Failed to read jackdet: %d\n", ret); | ||
253 | } else if (ret & WM1811_JACKDET_MODE_MASK) { | ||
254 | dev_dbg(dev, "CODEC still active, ignoring suspend\n"); | ||
255 | return 0; | ||
256 | } | ||
257 | break; | ||
258 | default: | ||
259 | break; | ||
260 | } | ||
261 | |||
262 | /* Disable LDO pulldowns while the device is suspended if we | 220 | /* Disable LDO pulldowns while the device is suspended if we |
263 | * don't know that something will be driving them. */ | 221 | * don't know that something will be driving them. */ |
264 | if (!wm8994->ldo_ena_always_driven) | 222 | if (!wm8994->ldo_ena_always_driven) |
diff --git a/drivers/mfd/wm8994-irq.c b/drivers/mfd/wm8994-irq.c index d3a184a240f5..e74dedda5b55 100644 --- a/drivers/mfd/wm8994-irq.c +++ b/drivers/mfd/wm8994-irq.c | |||
@@ -193,7 +193,7 @@ int wm8994_irq_init(struct wm8994 *wm8994) | |||
193 | { | 193 | { |
194 | int ret; | 194 | int ret; |
195 | unsigned long irqflags; | 195 | unsigned long irqflags; |
196 | struct wm8994_pdata *pdata = wm8994->dev->platform_data; | 196 | struct wm8994_pdata *pdata = dev_get_platdata(wm8994->dev); |
197 | 197 | ||
198 | if (!wm8994->irq) { | 198 | if (!wm8994->irq) { |
199 | dev_warn(wm8994->dev, | 199 | dev_warn(wm8994->dev, |